@synerise/ds-modal 1.4.13 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +144 -66
- package/dist/Elements/ModalContent/ModalContent.d.ts +6 -0
- package/dist/Elements/ModalContent/ModalContent.js +123 -0
- package/dist/Elements/ModalContent/ModalContent.styles.d.ts +18 -0
- package/dist/Elements/ModalContent/ModalContent.styles.js +39 -0
- package/dist/Elements/ModalFooter/ModalFooter.d.ts +2 -3
- package/dist/Elements/ModalFooter/ModalFooter.js +20 -17
- package/dist/Elements/ModalFooter/ModalFooter.styles.d.ts +1 -1
- package/dist/Elements/ModalFooter/ModalFooter.styles.js +6 -6
- package/dist/Elements/ModalTitle/ModalTitle.d.ts +1 -3
- package/dist/Elements/ModalTitle/ModalTitle.js +2 -2
- package/dist/Elements/ModalTitle/ModalTitle.styles.d.ts +3 -1
- package/dist/Elements/ModalTitle/ModalTitle.styles.js +17 -11
- package/dist/Elements/ModalTitle/index.d.ts +0 -1
- package/dist/Elements/ModalTitle/index.js +1 -3
- package/dist/Modal.const.d.ts +2 -0
- package/dist/Modal.const.js +11 -0
- package/dist/Modal.d.ts +2 -12
- package/dist/Modal.js +23 -59
- package/dist/Modal.types.d.ts +41 -17
- package/dist/ShowModal.d.ts +2 -0
- package/dist/ShowModal.js +23 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -5
- package/package.json +9 -13
- package/dist/Modal.styles.d.ts +0 -12
- package/dist/Modal.styles.js +0 -30
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/style/index.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.5.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.4.14...@synerise/ds-modal@1.5.0) (2026-05-22)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **modal:** migration from antd ([3588b65](https://github.com/synerise/synerise-design/commit/3588b65fbe67838fed4ee5125090ad47d334e04b))
|
|
11
|
+
|
|
12
|
+
## [1.4.14](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.4.13...@synerise/ds-modal@1.4.14) (2026-05-15)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @synerise/ds-modal
|
|
15
|
+
|
|
6
16
|
## [1.4.13](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.4.12...@synerise/ds-modal@1.4.13) (2026-05-13)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @synerise/ds-modal
|
package/README.md
CHANGED
|
@@ -5,85 +5,155 @@ title: Modal
|
|
|
5
5
|
|
|
6
6
|
# Modal UI Component
|
|
7
7
|
|
|
8
|
-
The Modal component provides a flexible and customizable way to display modal dialogs in your React applications. It
|
|
8
|
+
The Modal component provides a flexible and customizable way to display modal dialogs in your React applications. It is a native React implementation (no Ant Design dependency) with portal-based rendering and full async handler support.
|
|
9
9
|
|
|
10
10
|
## Demo
|
|
11
11
|
|
|
12
|
-
<iframe src="/storybook-static/iframe.html?id=components-modal--
|
|
12
|
+
<iframe src="/storybook-static/iframe.html?id=components-modal--with-footer"></iframe>
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
-
Install the Modal component using npm:
|
|
17
|
-
|
|
18
16
|
```bash
|
|
19
17
|
npm install @synerise/ds-modal
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
##
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import Modal from '@synerise/ds-modal';
|
|
24
|
+
|
|
25
|
+
<Modal
|
|
26
|
+
title="Confirm action"
|
|
27
|
+
open={isOpen}
|
|
28
|
+
onOk={handleOk}
|
|
29
|
+
onCancel={handleCancel}
|
|
30
|
+
>
|
|
31
|
+
Modal body content
|
|
32
|
+
</Modal>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Imperative API
|
|
36
|
+
|
|
37
|
+
Use `showModal` when you need to open a modal outside of the React component tree:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { showModal } from '@synerise/ds-modal';
|
|
41
|
+
|
|
42
|
+
const ref = showModal({
|
|
43
|
+
title: 'Confirm',
|
|
44
|
+
onOk: () => ref.destroy(),
|
|
45
|
+
onCancel: () => ref.destroy(),
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`showModal` returns a `ModalHandle` with a single `destroy()` method that unmounts the modal.
|
|
50
|
+
|
|
51
|
+
### Async handlers
|
|
52
|
+
|
|
53
|
+
Both `onOk` and `onCancel` accept handlers that return a `Promise`. The modal stays open until the promise resolves:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Modal
|
|
57
|
+
onOk={async () => {
|
|
58
|
+
await saveData();
|
|
59
|
+
}}
|
|
60
|
+
onCancel={async () => {
|
|
61
|
+
await cleanup();
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Scroll imperative handle
|
|
67
|
+
|
|
68
|
+
Use a `ref` to imperatively scroll the modal body:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import Modal from '@synerise/ds-modal';
|
|
72
|
+
import type { ModalRef } from '@synerise/ds-modal';
|
|
23
73
|
|
|
24
|
-
|
|
74
|
+
const ref = useRef<ModalRef>(null);
|
|
75
|
+
|
|
76
|
+
<Modal ref={ref} open>
|
|
77
|
+
{/* content */}
|
|
78
|
+
</Modal>
|
|
79
|
+
|
|
80
|
+
ref.current?.scrollToTop();
|
|
81
|
+
ref.current?.scrollToBottom();
|
|
82
|
+
```
|
|
25
83
|
|
|
26
84
|
## API
|
|
27
85
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
| description
|
|
35
|
-
| headerBottomBar
|
|
36
|
-
| headerActions
|
|
37
|
-
| headerTabProps
|
|
38
|
-
| size
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
|
86
|
+
### ModalProps
|
|
87
|
+
|
|
88
|
+
| Property | Description | Type | Default |
|
|
89
|
+
| ------------------- | ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------- |
|
|
90
|
+
| `open` | Whether the modal is visible | `boolean` | `false` |
|
|
91
|
+
| `title` | Modal header title | `ReactNode` | – |
|
|
92
|
+
| `description` | Subtitle rendered below the title (**deprecated** — use `headerBottomBar` instead) | `ReactNode` | – |
|
|
93
|
+
| `headerBottomBar` | Content rendered below the title and description in the header | `ReactNode` | – |
|
|
94
|
+
| `headerActions` | Content rendered in the top-right area of the header | `ReactNode` | – |
|
|
95
|
+
| `headerTabProps` | Props forwarded to the `Tabs` component rendered inside the header | `TabsProps` | – |
|
|
96
|
+
| `size` | Predefined width of the modal | `small` \| `medium` \| `large` \| `extraLarge` \| `fullSize` \| `fullScreen` | – |
|
|
97
|
+
| `blank` | Renders a minimal modal without any header/footer chrome; only a close button is shown when `onCancel` is set | `boolean` | `false` |
|
|
98
|
+
| `centered` | Vertically centers the modal in the viewport | `boolean` | `false` |
|
|
99
|
+
| `closable` | Whether the close (×) button is shown | `boolean` | `true` |
|
|
100
|
+
| `maskClosable` | Whether clicking the backdrop closes the modal | `boolean` | `true` |
|
|
101
|
+
| `onOk` | Called when the OK / Apply button is clicked; may return a `Promise` — modal stays open until it resolves | `(e: MouseEvent) => void \| Promise<unknown>` | – |
|
|
102
|
+
| `onCancel` | Called when the close button, backdrop, or Cancel button is clicked; may return a `Promise` | `(e: MouseEvent) => void \| Promise<unknown>` | – |
|
|
103
|
+
| `afterClose` | Called after the modal has fully unmounted | `() => void` | – |
|
|
104
|
+
| `footer` | Custom footer content. Set `footer={null}` to remove the footer entirely | `ReactNode` | OK + Cancel buttons |
|
|
105
|
+
| `okText` | Label for the OK button | `ReactNode` | `Apply` |
|
|
106
|
+
| `cancelText` | Label for the Cancel button | `ReactNode` | `Cancel` |
|
|
107
|
+
| `okType` | Button type for the OK button | `ButtonType` | `primary` |
|
|
108
|
+
| `okButtonProps` | Extra props forwarded to the OK button | `ButtonProps` | – |
|
|
109
|
+
| `cancelButtonProps` | Extra props forwarded to the Cancel button | `ButtonProps` | – |
|
|
110
|
+
| `texts` | Override both button labels at once | `{ okButton?: ReactNode; cancelButton?: ReactNode }` | – |
|
|
111
|
+
| `bodyBackground` | Background colour of the modal body | `white` \| `grey` | `white` |
|
|
112
|
+
| `bodyStyle` | Inline styles applied to the modal body element | `CSSProperties` | – |
|
|
113
|
+
| `bodyFullWidth` | Removes horizontal padding from the modal body | `boolean` | `false` |
|
|
114
|
+
| `maxViewportHeight` | Constrains the modal height to a percentage of the viewport and wraps children in a scrollbar. Pass `true` for 80 vh or a number for a custom value | `true \| number` | – |
|
|
115
|
+
| `disableScrollbar` | When `maxViewportHeight` is set, disables the built-in scrollbar wrapper | `boolean` | `false` |
|
|
116
|
+
| `titleContainerStyle` | Inline styles applied to the title container element | `CSSProperties` | – |
|
|
117
|
+
| `getContainer` | Returns the DOM node to mount the modal into | `() => HTMLElement` | `document.body` |
|
|
118
|
+
| `zIndex` | `z-index` of the modal | `number` | – |
|
|
119
|
+
| `className` | CSS class applied to the modal root | `string` | – |
|
|
120
|
+
| `style` | Inline styles applied to the modal root | `CSSProperties` | – |
|
|
121
|
+
|
|
122
|
+
### Footer layout slots
|
|
123
|
+
|
|
124
|
+
These props allow fine-grained control of the default footer layout:
|
|
125
|
+
|
|
126
|
+
| Property | Description | Type |
|
|
127
|
+
| ------------------- | ---------------------------------------------------- | ----------- |
|
|
128
|
+
| `prefix` | Content placed before the Cancel button | `ReactNode` |
|
|
129
|
+
| `infix` | Content placed between Cancel and OK buttons | `ReactNode` |
|
|
130
|
+
| `suffix` | Content placed after the OK button | `ReactNode` |
|
|
131
|
+
| `okButton` | Replaces the default OK button | `ReactNode` |
|
|
132
|
+
| `cancelButton` | Replaces the default Cancel button | `ReactNode` |
|
|
133
|
+
| `CustomFooterButton`| Component type used instead of the default button | `ComponentType<ButtonProps>` |
|
|
134
|
+
|
|
135
|
+
### ModalRef
|
|
136
|
+
|
|
137
|
+
Obtained via `useRef<ModalRef>()` passed to the `ref` prop.
|
|
138
|
+
|
|
139
|
+
| Method | Description |
|
|
140
|
+
| ---------------- | ---------------------------------------- |
|
|
141
|
+
| `scrollToTop()` | Scrolls the modal body to the top |
|
|
142
|
+
| `scrollToBottom()` | Scrolls the modal body to the bottom |
|
|
143
|
+
|
|
144
|
+
### ModalHandle
|
|
145
|
+
|
|
146
|
+
Returned by `showModal()`.
|
|
147
|
+
|
|
148
|
+
| Property | Description |
|
|
149
|
+
| ----------- | ---------------------------------- |
|
|
150
|
+
| `destroy()` | Unmounts the imperatively-opened modal |
|
|
83
151
|
|
|
84
152
|
## ModalTitle
|
|
85
153
|
|
|
86
|
-
|
|
154
|
+
Sub-component for the modal header. Props are a subset of `ModalProps`:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
87
157
|
type ModalTitleProps = Pick<
|
|
88
158
|
ModalProps,
|
|
89
159
|
| 'headerActions'
|
|
@@ -99,16 +169,18 @@ type ModalTitleProps = Pick<
|
|
|
99
169
|
|
|
100
170
|
## ModalFooter
|
|
101
171
|
|
|
102
|
-
|
|
103
|
-
|
|
172
|
+
Sub-component for the modal footer. Props are a subset of `ModalProps`:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
type ModalFooterProps = Pick<
|
|
104
176
|
ModalProps,
|
|
177
|
+
| 'footer'
|
|
105
178
|
| 'prefix'
|
|
106
179
|
| 'infix'
|
|
107
180
|
| 'suffix'
|
|
108
181
|
| 'okButton'
|
|
109
182
|
| 'cancelButton'
|
|
110
183
|
| 'CustomFooterButton'
|
|
111
|
-
| 'DSButton'
|
|
112
184
|
| 'texts'
|
|
113
185
|
| 'onOk'
|
|
114
186
|
| 'onCancel'
|
|
@@ -120,4 +192,10 @@ export type ModalFooterProps = Pick<
|
|
|
120
192
|
>;
|
|
121
193
|
```
|
|
122
194
|
|
|
123
|
-
|
|
195
|
+
## Deprecated
|
|
196
|
+
|
|
197
|
+
The following prop is **deprecated** and will be removed in a future major version:
|
|
198
|
+
|
|
199
|
+
| Prop | Replacement |
|
|
200
|
+
| ---- | ----------- |
|
|
201
|
+
| `description` | `headerBottomBar` |
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { ModalRef } from '../../Modal.types';
|
|
3
|
+
export declare const ModalContent: React.ForwardRefExoticComponent<Omit<import('../../Modal.types').ModalProps, "getContainer" | "open" | "destroyOnClose"> & {
|
|
4
|
+
closeModal: () => void;
|
|
5
|
+
hidden?: boolean;
|
|
6
|
+
} & React.RefAttributes<ModalRef>>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useMemo, useEffect, useCallback, useImperativeHandle } from "react";
|
|
3
|
+
import { useFocusTrap } from "@synerise/ds-utils";
|
|
4
|
+
import { SIZE_MAP } from "../../Modal.const.js";
|
|
5
|
+
import { ModalFooter } from "../ModalFooter/ModalFooter.js";
|
|
6
|
+
import { ModalTitle } from "../ModalTitle/ModalTitle.js";
|
|
7
|
+
import { ModalRoot, ModalMask, ModalScrollWrap, ModalContainer, ModalBody, ModalWrapper, Scrollbar } from "./ModalContent.styles.js";
|
|
8
|
+
const ModalContent = forwardRef(({
|
|
9
|
+
children,
|
|
10
|
+
size = "small",
|
|
11
|
+
afterClose,
|
|
12
|
+
maxViewportHeight,
|
|
13
|
+
headerActions,
|
|
14
|
+
blank,
|
|
15
|
+
titleContainerStyle,
|
|
16
|
+
title,
|
|
17
|
+
closeModal,
|
|
18
|
+
description,
|
|
19
|
+
headerTabProps,
|
|
20
|
+
headerBottomBar,
|
|
21
|
+
CustomFooterButton,
|
|
22
|
+
prefix,
|
|
23
|
+
infix,
|
|
24
|
+
suffix,
|
|
25
|
+
onOk,
|
|
26
|
+
onCancel,
|
|
27
|
+
texts,
|
|
28
|
+
okButton,
|
|
29
|
+
okButtonProps,
|
|
30
|
+
cancelButton,
|
|
31
|
+
cancelButtonProps,
|
|
32
|
+
cancelText,
|
|
33
|
+
okText,
|
|
34
|
+
okType,
|
|
35
|
+
bodyBackground,
|
|
36
|
+
bodyFullWidth,
|
|
37
|
+
footer,
|
|
38
|
+
bodyStyle,
|
|
39
|
+
disableScrollbar,
|
|
40
|
+
closable = true,
|
|
41
|
+
maskClosable = true,
|
|
42
|
+
centered,
|
|
43
|
+
hidden,
|
|
44
|
+
...rest
|
|
45
|
+
}, modalRef) => {
|
|
46
|
+
const scrollRef = useRef(null);
|
|
47
|
+
const DEFAULT_VIEWPORT_HEIGHT = 80;
|
|
48
|
+
const isFullscreen = size === "fullScreen";
|
|
49
|
+
const maxHeight = useMemo(() => {
|
|
50
|
+
if (maxViewportHeight !== void 0) {
|
|
51
|
+
if (typeof maxViewportHeight === "number") {
|
|
52
|
+
return maxViewportHeight;
|
|
53
|
+
}
|
|
54
|
+
return DEFAULT_VIEWPORT_HEIGHT;
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
}, [maxViewportHeight]);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
return () => {
|
|
60
|
+
afterClose?.();
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
const scrollToTop = useCallback(() => {
|
|
64
|
+
scrollRef.current?.scrollTo(0, 0);
|
|
65
|
+
}, []);
|
|
66
|
+
const scrollToBottom = useCallback(() => {
|
|
67
|
+
if (scrollRef.current) {
|
|
68
|
+
scrollRef.current.scrollTo(0, scrollRef.current.scrollHeight);
|
|
69
|
+
}
|
|
70
|
+
}, []);
|
|
71
|
+
useImperativeHandle(modalRef, () => ({
|
|
72
|
+
scrollToTop,
|
|
73
|
+
scrollToBottom
|
|
74
|
+
}));
|
|
75
|
+
const handleCancel = async (event) => {
|
|
76
|
+
if (!onCancel) {
|
|
77
|
+
closeModal();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const onCancelResult = onCancel(event);
|
|
81
|
+
if (onCancelResult?.then !== void 0) {
|
|
82
|
+
await onCancelResult;
|
|
83
|
+
}
|
|
84
|
+
closeModal();
|
|
85
|
+
};
|
|
86
|
+
const handleOk = async (event) => {
|
|
87
|
+
if (!onOk) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const onOkResult = onOk(event);
|
|
91
|
+
if (onOkResult?.then !== void 0) {
|
|
92
|
+
await onOkResult;
|
|
93
|
+
closeModal();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const cancelClick = (event) => {
|
|
97
|
+
event.stopPropagation();
|
|
98
|
+
};
|
|
99
|
+
const handleMaskClick = (event) => {
|
|
100
|
+
if (maskClosable) {
|
|
101
|
+
handleCancel(event);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const handleKeyDown = (event) => {
|
|
105
|
+
if (event.key === "Escape" && onCancel && closable) {
|
|
106
|
+
event.stopPropagation();
|
|
107
|
+
handleCancel(event);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const containerRef = useRef(null);
|
|
111
|
+
useFocusTrap(containerRef, !hidden);
|
|
112
|
+
return /* @__PURE__ */ jsxs(ModalRoot, { "data-testid": "ds-modal", ...rest, $hidden: hidden, "data-visible": !hidden, onKeyDown: handleKeyDown, tabIndex: -1, ref: containerRef, children: [
|
|
113
|
+
/* @__PURE__ */ jsx(ModalMask, {}),
|
|
114
|
+
/* @__PURE__ */ jsx(ModalScrollWrap, { ref: scrollRef, onClick: handleMaskClick, children: /* @__PURE__ */ jsxs(ModalContainer, { onClick: cancelClick, role: "dialog", isFullscreen, $width: size && SIZE_MAP[size], maxHeight, centered, children: [
|
|
115
|
+
/* @__PURE__ */ jsx(ModalTitle, { headerActions, blank, titleContainerStyle, onCancel: closable && onCancel ? handleCancel : void 0, title, description, headerTabProps, headerBottomBar }),
|
|
116
|
+
/* @__PURE__ */ jsx(ModalBody, { greyBackground: bodyBackground === "grey", bodyFullWidth, style: bodyStyle, children: maxHeight && !disableScrollbar ? /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, children }) }) : children }),
|
|
117
|
+
/* @__PURE__ */ jsx(ModalFooter, { CustomFooterButton, prefix, infix, suffix, onOk: onOk ? handleOk : void 0, onCancel: onCancel ? handleCancel : void 0, texts, okButton, okButtonProps, cancelButton, cancelButtonProps, cancelText, okText, okType, footer })
|
|
118
|
+
] }) })
|
|
119
|
+
] });
|
|
120
|
+
});
|
|
121
|
+
export {
|
|
122
|
+
ModalContent
|
|
123
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ModalScrollWrap: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const ModalWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const Scrollbar: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<(import('@synerise/ds-scrollbar').ScrollbarProps | import('@synerise/ds-scrollbar').VirtualScrollbarProps) & import('react').RefAttributes<HTMLElement>>, any, {}, never>;
|
|
4
|
+
export declare const ModalBody: import('styled-components').StyledComponent<"div", any, {
|
|
5
|
+
greyBackground?: boolean;
|
|
6
|
+
bodyFullWidth?: boolean;
|
|
7
|
+
}, never>;
|
|
8
|
+
export declare const ModalContainer: import('styled-components').StyledComponent<"div", any, {
|
|
9
|
+
$width?: string | number;
|
|
10
|
+
isFullscreen?: boolean;
|
|
11
|
+
centered?: boolean;
|
|
12
|
+
maxHeight?: number;
|
|
13
|
+
}, never>;
|
|
14
|
+
export declare const ModalRoot: import('styled-components').StyledComponent<"div", any, {
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
$hidden?: boolean;
|
|
17
|
+
}, never>;
|
|
18
|
+
export declare const ModalMask: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import ScrollbarBase from "@synerise/ds-scrollbar";
|
|
3
|
+
const ModalScrollWrap = /* @__PURE__ */ styled.div.withConfig({
|
|
4
|
+
displayName: "ModalContentstyles__ModalScrollWrap",
|
|
5
|
+
componentId: "sc-1sk67uc-0"
|
|
6
|
+
})(["position:fixed;top:0;left:0;right:0;bottom:0;overflow:auto;"]);
|
|
7
|
+
const ModalWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
8
|
+
displayName: "ModalContentstyles__ModalWrapper",
|
|
9
|
+
componentId: "sc-1sk67uc-1"
|
|
10
|
+
})(["position:relative;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden;"]);
|
|
11
|
+
const Scrollbar = /* @__PURE__ */ styled(ScrollbarBase).withConfig({
|
|
12
|
+
displayName: "ModalContentstyles__Scrollbar",
|
|
13
|
+
componentId: "sc-1sk67uc-2"
|
|
14
|
+
})(["display:flex;flex-direction:column;min-height:0;.scrollbar-container{min-height:0;}"]);
|
|
15
|
+
const ModalBody = /* @__PURE__ */ styled.div.withConfig({
|
|
16
|
+
displayName: "ModalContentstyles__ModalBody",
|
|
17
|
+
componentId: "sc-1sk67uc-3"
|
|
18
|
+
})(["", " ", ""], (props) => !props.bodyFullWidth && `padding: 24px;`, (props) => props.greyBackground && `background: ${props.theme.palette["grey-050"]};`);
|
|
19
|
+
const ModalContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
20
|
+
displayName: "ModalContentstyles__ModalContainer",
|
|
21
|
+
componentId: "sc-1sk67uc-4"
|
|
22
|
+
})(["background:", ";width:", ";position:absolute;box-shadow:", ";border-radius:3px;", ""], (props) => props.theme.palette["white"], (props) => props.$width, (props) => props.theme.variables["box-shadow-2"], (props) => props.isFullscreen ? css(["&&{position:fixed;top:0;left:0;right:0;bottom:0;margin:0;max-width:none;padding:0;display:flex;flex-direction:column;height:100%;", "{flex:1 1 100%;overflow:scroll;}}"], ModalBody) : css(["left:50%;", " ", ""], props.centered ? css(["top:50%;transform:translate(-50%,-50%);"]) : css(["top:100px;transform:translateX(-50%);"]), props.maxHeight && css(["display:flex;flex-direction:column;height:", "vh;", "{flex:1 1 100%;overflow:scroll;padding-right:0;}"], props.maxHeight, ModalBody)));
|
|
23
|
+
const ModalRoot = /* @__PURE__ */ styled.div.withConfig({
|
|
24
|
+
displayName: "ModalContentstyles__ModalRoot",
|
|
25
|
+
componentId: "sc-1sk67uc-5"
|
|
26
|
+
})(["position:absolute;z-index:", ";", ""], (props) => props.zIndex ?? props.theme.variables["zindex-modal"], (props) => props.$hidden && "display: none;");
|
|
27
|
+
const ModalMask = /* @__PURE__ */ styled.div.withConfig({
|
|
28
|
+
displayName: "ModalContentstyles__ModalMask",
|
|
29
|
+
componentId: "sc-1sk67uc-6"
|
|
30
|
+
})(["position:fixed;top:0;left:0;right:0;bottom:0;background:", ";opacity:0.2;"], (props) => props.theme.palette["grey-800"]);
|
|
31
|
+
export {
|
|
32
|
+
ModalBody,
|
|
33
|
+
ModalContainer,
|
|
34
|
+
ModalMask,
|
|
35
|
+
ModalRoot,
|
|
36
|
+
ModalScrollWrap,
|
|
37
|
+
ModalWrapper,
|
|
38
|
+
Scrollbar
|
|
39
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
export declare const ModalFooter: ({ CustomFooterButton, DSButton, prefix, infix, suffix, ...antModalProps }: ModalFooterProps) => React.JSX.Element;
|
|
2
|
+
import { ModalFooterProps } from '../../Modal.types';
|
|
3
|
+
export declare const ModalFooter: ({ CustomFooterButton, prefix, infix, suffix, onOk, onCancel, texts, okButton, okButtonProps, cancelButton, cancelButtonProps, cancelText, okText, okType, footer, }: Partial<ModalFooterProps>) => React.JSX.Element | null;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Button from "@synerise/ds-button";
|
|
3
|
-
import { FooterContainer } from "./ModalFooter.styles.js";
|
|
3
|
+
import { FooterContainer, FooterWrapper } from "./ModalFooter.styles.js";
|
|
4
4
|
const ModalFooter = ({
|
|
5
5
|
CustomFooterButton = Button,
|
|
6
|
-
DSButton = Button,
|
|
7
6
|
prefix,
|
|
8
7
|
infix,
|
|
9
8
|
suffix,
|
|
10
|
-
|
|
9
|
+
onOk,
|
|
10
|
+
onCancel,
|
|
11
|
+
texts = {
|
|
12
|
+
okButton: "Apply",
|
|
13
|
+
cancelButton: "Cancel"
|
|
14
|
+
},
|
|
15
|
+
okButton,
|
|
16
|
+
okButtonProps,
|
|
17
|
+
cancelButton,
|
|
18
|
+
cancelButtonProps,
|
|
19
|
+
cancelText,
|
|
20
|
+
okText,
|
|
21
|
+
okType,
|
|
22
|
+
footer
|
|
11
23
|
}) => {
|
|
12
|
-
|
|
13
|
-
onOk,
|
|
14
|
-
onCancel,
|
|
15
|
-
texts = {
|
|
16
|
-
okButton: "Apply",
|
|
17
|
-
cancelButton: "Cancel"
|
|
18
|
-
}
|
|
19
|
-
} = antModalProps;
|
|
20
|
-
const CustomButton = CustomFooterButton || DSButton;
|
|
21
|
-
return /* @__PURE__ */ jsxs(FooterContainer, { "data-testid": "modal-footer", children: [
|
|
24
|
+
return footer !== null ? /* @__PURE__ */ jsx(FooterContainer, { children: footer || /* @__PURE__ */ jsxs(FooterWrapper, { "data-testid": "modal-footer", children: [
|
|
22
25
|
prefix,
|
|
23
|
-
|
|
26
|
+
cancelButton || /* @__PURE__ */ jsx(CustomFooterButton, { type: "ghost", onClick: onCancel, disabled: !onCancel, ...cancelButtonProps, children: cancelText || texts?.cancelButton }),
|
|
24
27
|
infix,
|
|
25
|
-
|
|
28
|
+
okButton || /* @__PURE__ */ jsx(CustomFooterButton, { type: okType || "primary", onClick: onOk, disabled: !onOk, ...okButtonProps, children: okText || texts?.okButton }),
|
|
26
29
|
suffix
|
|
27
|
-
] });
|
|
30
|
+
] }) }) : null;
|
|
28
31
|
};
|
|
29
32
|
export {
|
|
30
33
|
ModalFooter
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const FooterContainer: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const FooterWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -2,12 +2,12 @@ import styled from "styled-components";
|
|
|
2
2
|
const FooterContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "ModalFooterstyles__FooterContainer",
|
|
4
4
|
componentId: "sc-1h4mu26-0"
|
|
5
|
-
})(["
|
|
6
|
-
const
|
|
7
|
-
displayName: "
|
|
5
|
+
})(["min-height:81px;background:", ";padding:24px 24px;border-top:1px solid ", ";border-radius:0 0 3px 3px;"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["grey-100"]);
|
|
6
|
+
const FooterWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
7
|
+
displayName: "ModalFooterstyles__FooterWrapper",
|
|
8
8
|
componentId: "sc-1h4mu26-1"
|
|
9
|
-
})(["display:flex;flex-
|
|
9
|
+
})(["display:flex;align-items:center;justify-content:flex-end;gap:8px;"]);
|
|
10
10
|
export {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
FooterContainer,
|
|
12
|
+
FooterWrapper
|
|
13
13
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type ModalTitleProps = Pick<ModalProps, 'headerActions' | 'headerTabProps' | 'onCancel' | 'titleContainerStyle' | 'blank' | 'description' | 'title' | 'headerBottomBar'>;
|
|
2
|
+
import { ModalTitleProps } from '../../Modal.types';
|
|
4
3
|
export declare const ModalTitle: ({ headerActions, blank, titleContainerStyle, onCancel, title, description, headerTabProps, headerBottomBar, }: ModalTitleProps) => React.JSX.Element;
|
|
5
|
-
export {};
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import Button from "@synerise/ds-button";
|
|
3
3
|
import Icon, { CloseM } from "@synerise/ds-icon";
|
|
4
4
|
import Tabs from "@synerise/ds-tabs";
|
|
5
|
-
import { ModalTitleWrapper, TitleContainer, Title, ActionButtons, Description, TabsWrapper, BottomBar } from "./ModalTitle.styles.js";
|
|
5
|
+
import { CloseButton, ModalTitleWrapper, TitleContainer, Title, ActionButtons, Description, TabsWrapper, BottomBar } from "./ModalTitle.styles.js";
|
|
6
6
|
const ModalTitle = ({
|
|
7
7
|
headerActions,
|
|
8
8
|
blank,
|
|
@@ -14,7 +14,7 @@ const ModalTitle = ({
|
|
|
14
14
|
headerBottomBar
|
|
15
15
|
}) => {
|
|
16
16
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17
|
-
blank && onCancel && /* @__PURE__ */ jsx(
|
|
17
|
+
blank && onCancel && /* @__PURE__ */ jsx(CloseButton, { mode: "single-icon", "data-testid": "modal-close", className: "close-modal", type: "ghost", onClick: onCancel, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CloseM, {}) }) }),
|
|
18
18
|
(title || description || headerTabProps) && /* @__PURE__ */ jsxs(ModalTitleWrapper, { withDescription: !!description, withTabs: !!headerTabProps, children: [
|
|
19
19
|
title && /* @__PURE__ */ jsxs(TitleContainer, { style: titleContainerStyle, "data-testid": "modal-title", children: [
|
|
20
20
|
/* @__PURE__ */ jsx(Title, { level: 3, children: title }),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { StyledButton } from '@synerise/ds-button';
|
|
2
|
+
export declare const CloseButton: StyledButton;
|
|
1
3
|
export declare const TitleContainer: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const Title: import('styled-components').StyledComponent<
|
|
4
|
+
export declare const Title: import('styled-components').StyledComponent<({ level, withoutMargin, children, className, ellipsis, ...antdProps }: import('@synerise/ds-typography/dist/Title.types').Props) => React.JSX.Element, any, {}, never>;
|
|
3
5
|
export declare const ActionButtons: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
6
|
export declare const BottomBar: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
5
7
|
export declare const ModalTitleWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import { Title as Title$1 } from "@synerise/ds-typography";
|
|
3
4
|
const getBottomPadding = (withTabs, withDescription) => {
|
|
4
5
|
if (withTabs) {
|
|
5
6
|
return 0;
|
|
@@ -9,37 +10,42 @@ const getBottomPadding = (withTabs, withDescription) => {
|
|
|
9
10
|
}
|
|
10
11
|
return 20;
|
|
11
12
|
};
|
|
13
|
+
const CloseButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
14
|
+
displayName: "ModalTitlestyles__CloseButton",
|
|
15
|
+
componentId: "sc-hnk65g-0"
|
|
16
|
+
})(["&&&{position:absolute;top:20px;right:24px;z-index:1;margin:0;}"]);
|
|
12
17
|
const TitleContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
13
18
|
displayName: "ModalTitlestyles__TitleContainer",
|
|
14
|
-
componentId: "sc-hnk65g-
|
|
19
|
+
componentId: "sc-hnk65g-1"
|
|
15
20
|
})(["display:flex;align-items:center;flex-wrap:nowrap;&&{.close-modal{line-height:1;}}"]);
|
|
16
|
-
const Title = /* @__PURE__ */ styled(
|
|
21
|
+
const Title = /* @__PURE__ */ styled(Title$1).withConfig({
|
|
17
22
|
displayName: "ModalTitlestyles__Title",
|
|
18
|
-
componentId: "sc-hnk65g-
|
|
23
|
+
componentId: "sc-hnk65g-2"
|
|
19
24
|
})(["width:100%;color:", ";white-space:nowrap;overflow:hidden;text-overflow:ellipsis;&&{margin:0;}"], (props) => props.theme.palette["grey-800"]);
|
|
20
25
|
const ActionButtons = /* @__PURE__ */ styled.div.withConfig({
|
|
21
26
|
displayName: "ModalTitlestyles__ActionButtons",
|
|
22
|
-
componentId: "sc-hnk65g-
|
|
23
|
-
})(["display:flex;flex-direction:row;align-items:center
|
|
27
|
+
componentId: "sc-hnk65g-3"
|
|
28
|
+
})(["display:flex;flex-direction:row;align-items:center;gap:8px;"]);
|
|
24
29
|
const BottomBar = /* @__PURE__ */ styled.div.withConfig({
|
|
25
30
|
displayName: "ModalTitlestyles__BottomBar",
|
|
26
|
-
componentId: "sc-hnk65g-
|
|
31
|
+
componentId: "sc-hnk65g-4"
|
|
27
32
|
})(["padding:12px 24px;border-bottom:1px solid ", ";"], (props) => props.theme.palette["grey-100"]);
|
|
28
33
|
const ModalTitleWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
29
34
|
displayName: "ModalTitlestyles__ModalTitleWrapper",
|
|
30
|
-
componentId: "sc-hnk65g-
|
|
35
|
+
componentId: "sc-hnk65g-5"
|
|
31
36
|
})(["padding:20px 24px;padding-bottom:", "px;font-size:18px;line-height:32px;border-bottom:1px solid ", ";"], (props) => getBottomPadding(!!props.withTabs, !!props.withDescription), (props) => props.theme.palette["grey-100"]);
|
|
32
37
|
const Description = /* @__PURE__ */ styled.div.withConfig({
|
|
33
38
|
displayName: "ModalTitlestyles__Description",
|
|
34
|
-
componentId: "sc-hnk65g-
|
|
35
|
-
})(["font-size:13px;font-weight:normal;line-height:18px;color:", ";display:block;padding:12px 0 0;margin:14px 0 0;background-image:linear-gradient( to right,", " 33%,
|
|
39
|
+
componentId: "sc-hnk65g-6"
|
|
40
|
+
})(["font-size:13px;font-weight:normal;line-height:18px;color:", ";display:block;padding:12px 0 0;margin:14px 0 0;background-image:linear-gradient( to right,", " 33%,", " 0% );background-repeat:repeat-x;background-size:4px 1px;background-position:top;"], (props) => props.theme.palette["grey-600"], (props) => props.theme.palette["grey-300"], (props) => props.theme.palette["white"]);
|
|
36
41
|
const TabsWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
37
42
|
displayName: "ModalTitlestyles__TabsWrapper",
|
|
38
|
-
componentId: "sc-hnk65g-
|
|
43
|
+
componentId: "sc-hnk65g-7"
|
|
39
44
|
})(["padding-bottom:1px;"]);
|
|
40
45
|
export {
|
|
41
46
|
ActionButtons,
|
|
42
47
|
BottomBar,
|
|
48
|
+
CloseButton,
|
|
43
49
|
Description,
|
|
44
50
|
ModalTitleWrapper,
|
|
45
51
|
TabsWrapper,
|
package/dist/Modal.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/** @deprecated */
|
|
5
|
-
export declare const buildModalFooter: (props: ModalFooterProps) => React.JSX.Element;
|
|
6
|
-
export declare const Modal: {
|
|
7
|
-
(props: ModalProps): React.JSX.Element;
|
|
8
|
-
info: import('antd/lib/modal/confirm').ModalFunc;
|
|
9
|
-
success: import('antd/lib/modal/confirm').ModalFunc;
|
|
10
|
-
error: import('antd/lib/modal/confirm').ModalFunc;
|
|
11
|
-
warning: import('antd/lib/modal/confirm').ModalFunc;
|
|
12
|
-
confirm: import('antd/lib/modal/confirm').ModalFunc;
|
|
13
|
-
};
|
|
2
|
+
import { ModalProps, ModalRef } from './Modal.types';
|
|
3
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<ModalRef>>;
|
|
14
4
|
export default Modal;
|
package/dist/Modal.js
CHANGED
|
@@ -1,65 +1,29 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const buildModalFooter = (props) => /* @__PURE__ */ jsx(ModalFooter, { ...props });
|
|
19
|
-
const Modal = (props) => {
|
|
20
|
-
const {
|
|
21
|
-
texts,
|
|
22
|
-
bodyBackground = "white",
|
|
23
|
-
headerActions,
|
|
24
|
-
title,
|
|
25
|
-
description,
|
|
26
|
-
headerBottomBar,
|
|
27
|
-
size,
|
|
28
|
-
blank,
|
|
29
|
-
titleContainerStyle,
|
|
30
|
-
maxViewportHeight,
|
|
31
|
-
disableScrollbar,
|
|
32
|
-
children,
|
|
33
|
-
okType,
|
|
34
|
-
okButtonProps,
|
|
35
|
-
cancelButtonProps,
|
|
36
|
-
...antModalProps
|
|
37
|
-
} = props;
|
|
38
|
-
const className = classnames(`bodybg-${bodyBackground}`, antModalProps.className, {
|
|
39
|
-
"modal-blank": Boolean(blank)
|
|
40
|
-
}, {
|
|
41
|
-
"with-description": Boolean(description)
|
|
42
|
-
});
|
|
43
|
-
const DEFAULT_VIEWPORT_HEIGHT = 80;
|
|
44
|
-
const maxHeight = () => {
|
|
45
|
-
if (maxViewportHeight !== void 0) {
|
|
46
|
-
if (typeof maxViewportHeight === "number") {
|
|
47
|
-
return maxViewportHeight;
|
|
48
|
-
}
|
|
49
|
-
return DEFAULT_VIEWPORT_HEIGHT;
|
|
2
|
+
import { forwardRef, useState, useEffect } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { ModalContent } from "./Elements/ModalContent/ModalContent.js";
|
|
5
|
+
const Modal = forwardRef(({
|
|
6
|
+
open,
|
|
7
|
+
afterClose,
|
|
8
|
+
getContainer,
|
|
9
|
+
destroyOnClose = false,
|
|
10
|
+
...props
|
|
11
|
+
}, ref) => {
|
|
12
|
+
const [isOpen, setIsOpen] = useState(open);
|
|
13
|
+
const [hasBeenOpened, setHasBeenOpened] = useState(open);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setIsOpen(open);
|
|
16
|
+
if (open) {
|
|
17
|
+
setHasBeenOpened(true);
|
|
50
18
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Modal.error = Modal$1.error;
|
|
59
|
-
Modal.warning = Modal$1.warning;
|
|
60
|
-
Modal.confirm = Modal$1.confirm;
|
|
19
|
+
}, [open]);
|
|
20
|
+
const shouldRender = destroyOnClose ? isOpen : isOpen || hasBeenOpened;
|
|
21
|
+
if (!shouldRender) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return createPortal(/* @__PURE__ */ jsx(ModalContent, { ...props, afterClose, ref, hidden: !isOpen, closeModal: () => setIsOpen(false) }), getContainer?.() || document.body);
|
|
25
|
+
});
|
|
61
26
|
export {
|
|
62
27
|
Modal,
|
|
63
|
-
buildModalFooter,
|
|
64
28
|
Modal as default
|
|
65
29
|
};
|
package/dist/Modal.types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSSProperties, ComponentType, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, ComponentType, MouseEvent, ReactNode } from 'react';
|
|
3
2
|
import { ButtonProps, ButtonType } from '@synerise/ds-button';
|
|
4
3
|
import { TabsProps } from '@synerise/ds-tabs';
|
|
5
|
-
export type
|
|
4
|
+
export type ModalSize = 'small' | 'medium' | 'large' | 'extraLarge' | 'fullSize' | 'fullScreen';
|
|
5
|
+
type ModalButtonHandler = ((e: MouseEvent<HTMLElement>) => void) | ((e: MouseEvent<HTMLElement>) => Promise<unknown>);
|
|
6
6
|
export type ModalProps = {
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated - this prop will be removed soon
|
|
@@ -12,15 +12,20 @@ export type ModalProps = {
|
|
|
12
12
|
headerBottomBar?: ReactNode;
|
|
13
13
|
/** Actions rendered in the top-right area of the header */
|
|
14
14
|
headerActions?: ReactNode;
|
|
15
|
-
|
|
15
|
+
title?: ReactNode;
|
|
16
16
|
headerTabProps?: TabsProps;
|
|
17
|
-
|
|
18
|
-
size?: 'small' | 'medium' | 'large' | 'extraLarge' | 'fullSize' | 'fullScreen';
|
|
19
|
-
/** Background color of the modal body */
|
|
17
|
+
size?: ModalSize;
|
|
20
18
|
bodyBackground?: 'white' | 'grey';
|
|
21
19
|
/** Renders a minimal modal without header and footer chrome */
|
|
22
20
|
blank?: boolean;
|
|
23
|
-
|
|
21
|
+
disableScrollbar?: boolean;
|
|
22
|
+
bodyFullWidth?: boolean;
|
|
23
|
+
centered?: boolean;
|
|
24
|
+
closable?: boolean;
|
|
25
|
+
maskClosable?: boolean;
|
|
26
|
+
open?: boolean;
|
|
27
|
+
/** When true, unmounts children when the modal closes. When false (default), keeps children mounted but hidden. */
|
|
28
|
+
destroyOnClose?: boolean;
|
|
24
29
|
titleContainerStyle?: CSSProperties;
|
|
25
30
|
/** Localised button labels */
|
|
26
31
|
texts?: {
|
|
@@ -30,19 +35,38 @@ export type ModalProps = {
|
|
|
30
35
|
children?: ReactNode;
|
|
31
36
|
/** Constrains modal height to a percentage of the viewport and wraps children in a scrollbar. Pass `true` for 80 vh or a number for a custom value. */
|
|
32
37
|
maxViewportHeight?: true | number;
|
|
33
|
-
|
|
34
|
-
disableScrollbar?: boolean;
|
|
35
|
-
} & Omit<AntdModalProps, 'okType' | 'okButtonProps' | 'cancelButtonProps'> & {
|
|
36
|
-
okType?: ButtonType;
|
|
37
|
-
okButtonProps?: ButtonProps;
|
|
38
|
-
cancelButtonProps?: ButtonProps;
|
|
39
|
-
} & ModalFooterBuilder;
|
|
40
|
-
export type ModalFooterBuilder = {
|
|
38
|
+
getContainer?: () => HTMLElement;
|
|
41
39
|
prefix?: ReactNode;
|
|
42
40
|
infix?: ReactNode;
|
|
43
41
|
suffix?: ReactNode;
|
|
44
42
|
okButton?: ReactNode;
|
|
45
43
|
cancelButton?: ReactNode;
|
|
46
|
-
DSButton?: ComponentType<ButtonProps>;
|
|
47
44
|
CustomFooterButton?: ComponentType<ButtonProps>;
|
|
45
|
+
afterClose?: () => void;
|
|
46
|
+
footer?: ReactNode;
|
|
47
|
+
onCancel?: ModalButtonHandler;
|
|
48
|
+
cancelText?: ReactNode;
|
|
49
|
+
cancelButtonProps?: ButtonProps;
|
|
50
|
+
onOk?: ModalButtonHandler;
|
|
51
|
+
okText?: ReactNode;
|
|
52
|
+
okButtonProps?: ButtonProps;
|
|
53
|
+
okType?: ButtonType;
|
|
54
|
+
bodyStyle?: CSSProperties;
|
|
55
|
+
zIndex?: number;
|
|
56
|
+
className?: string;
|
|
57
|
+
style?: CSSProperties;
|
|
58
|
+
};
|
|
59
|
+
export type ModalContentProps = Omit<ModalProps, 'getContainer' | 'open' | 'destroyOnClose'> & {
|
|
60
|
+
closeModal: () => void;
|
|
61
|
+
hidden?: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type ModalTitleProps = Pick<ModalContentProps, 'headerActions' | 'headerTabProps' | 'onCancel' | 'titleContainerStyle' | 'blank' | 'description' | 'title' | 'headerBottomBar'>;
|
|
64
|
+
export type ModalFooterProps = Pick<ModalContentProps, 'footer' | 'prefix' | 'infix' | 'suffix' | 'okButton' | 'cancelButton' | 'CustomFooterButton' | 'texts' | 'onOk' | 'onCancel' | 'cancelText' | 'okText' | 'cancelButtonProps' | 'okType' | 'okButtonProps'>;
|
|
65
|
+
export type ModalHandle = {
|
|
66
|
+
destroy: () => void;
|
|
67
|
+
};
|
|
68
|
+
export type ModalRef = {
|
|
69
|
+
scrollToTop: () => void;
|
|
70
|
+
scrollToBottom: () => void;
|
|
48
71
|
};
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { setPortalContent } from "@synerise/ds-core";
|
|
3
|
+
import { Modal } from "./Modal.js";
|
|
4
|
+
let modalInstanceId = 0;
|
|
5
|
+
const showModal = ({
|
|
6
|
+
afterClose,
|
|
7
|
+
...initial
|
|
8
|
+
}) => {
|
|
9
|
+
const cleanup = () => {
|
|
10
|
+
setPortalContent(null);
|
|
11
|
+
};
|
|
12
|
+
modalInstanceId += 1;
|
|
13
|
+
setPortalContent(/* @__PURE__ */ jsx(Modal, { ...initial, open: true, afterClose: () => {
|
|
14
|
+
afterClose?.();
|
|
15
|
+
cleanup();
|
|
16
|
+
} }, modalInstanceId));
|
|
17
|
+
return {
|
|
18
|
+
destroy: cleanup
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
showModal
|
|
23
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { default,
|
|
2
|
-
export {
|
|
1
|
+
export { default, Modal } from './Modal';
|
|
2
|
+
export { showModal } from './ShowModal';
|
|
3
|
+
export { ModalTitle } from './Elements/ModalTitle';
|
|
3
4
|
export { ModalFooter } from './Elements/ModalFooter';
|
|
4
|
-
export
|
|
5
|
+
export * from './Modal.types';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Modal, Modal as Modal2 } from "./Modal.js";
|
|
2
|
+
import { showModal } from "./ShowModal.js";
|
|
2
3
|
import { ModalTitle } from "./Elements/ModalTitle/ModalTitle.js";
|
|
3
|
-
import { TitleContainer } from "./Elements/ModalTitle/ModalTitle.styles.js";
|
|
4
4
|
import { ModalFooter } from "./Elements/ModalFooter/ModalFooter.js";
|
|
5
5
|
export {
|
|
6
|
+
Modal,
|
|
6
7
|
ModalFooter,
|
|
7
8
|
ModalTitle,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Modal as default
|
|
9
|
+
Modal2 as default,
|
|
10
|
+
showModal
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-modal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Modal UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -35,27 +35,23 @@
|
|
|
35
35
|
"check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
|
|
36
36
|
"upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
|
|
37
37
|
},
|
|
38
|
-
"sideEffects":
|
|
39
|
-
"dist/style/*",
|
|
40
|
-
"*.less"
|
|
41
|
-
],
|
|
38
|
+
"sideEffects": false,
|
|
42
39
|
"types": "dist/index.d.ts",
|
|
43
40
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-button": "^1.5.
|
|
45
|
-
"@synerise/ds-icon": "^1.18.
|
|
46
|
-
"@synerise/ds-scrollbar": "^1.
|
|
47
|
-
"@synerise/ds-tabs": "^1.1.
|
|
48
|
-
"@synerise/ds-typography": "^1.1.
|
|
49
|
-
"
|
|
41
|
+
"@synerise/ds-button": "^1.5.30",
|
|
42
|
+
"@synerise/ds-icon": "^1.18.1",
|
|
43
|
+
"@synerise/ds-scrollbar": "^1.4.0",
|
|
44
|
+
"@synerise/ds-tabs": "^1.1.38",
|
|
45
|
+
"@synerise/ds-typography": "^1.1.23",
|
|
46
|
+
"@synerise/ds-utils": "^1.9.0"
|
|
50
47
|
},
|
|
51
48
|
"devDependencies": {
|
|
52
49
|
"vitest": "4"
|
|
53
50
|
},
|
|
54
51
|
"peerDependencies": {
|
|
55
52
|
"@synerise/ds-core": "*",
|
|
56
|
-
"antd": "4.24.16",
|
|
57
53
|
"react": ">=16.9.0 <= 18.3.1",
|
|
58
54
|
"styled-components": "^5.3.3"
|
|
59
55
|
},
|
|
60
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "f257f56d8991010593efd5ea9915335e813671a6"
|
|
61
57
|
}
|
package/dist/Modal.styles.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const SettingButton: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
-
export declare const ButtonsWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export declare const Scrollbar: import('styled-components').StyledComponent<import('react').ForwardRefExoticComponent<(import('@synerise/ds-scrollbar').ScrollbarProps | import('@synerise/ds-scrollbar').VirtualScrollbarProps) & import('react').RefAttributes<HTMLElement>>, any, {}, never>;
|
|
4
|
-
export declare const AntdModal: import('styled-components').StyledComponent<import('react').FC<import('antd').ModalProps> & import('antd/lib/modal/confirm').ModalStaticFunctions & {
|
|
5
|
-
useModal: typeof import('antd/lib/modal/useModal').default;
|
|
6
|
-
destroyAll: () => void;
|
|
7
|
-
config: typeof import('antd/lib/modal/confirm').modalGlobalConfig;
|
|
8
|
-
}, any, {
|
|
9
|
-
isFullscreen?: boolean;
|
|
10
|
-
maxHeight?: number;
|
|
11
|
-
}, never>;
|
|
12
|
-
export declare const ModalWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
package/dist/Modal.styles.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Modal } from "antd";
|
|
2
|
-
import styled, { css } from "styled-components";
|
|
3
|
-
import ScrollbarBase from "@synerise/ds-scrollbar";
|
|
4
|
-
const SettingButton = /* @__PURE__ */ styled.div.withConfig({
|
|
5
|
-
displayName: "Modalstyles__SettingButton",
|
|
6
|
-
componentId: "sc-jdspxw-0"
|
|
7
|
-
})(["display:flex;width:100%;"]);
|
|
8
|
-
const ButtonsWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
9
|
-
displayName: "Modalstyles__ButtonsWrapper",
|
|
10
|
-
componentId: "sc-jdspxw-1"
|
|
11
|
-
})(["display:flex;"]);
|
|
12
|
-
const Scrollbar = /* @__PURE__ */ styled(ScrollbarBase).withConfig({
|
|
13
|
-
displayName: "Modalstyles__Scrollbar",
|
|
14
|
-
componentId: "sc-jdspxw-2"
|
|
15
|
-
})(["display:flex;flex-direction:column;min-height:0;.scrollbar-container{min-height:0;}"]);
|
|
16
|
-
const AntdModal = /* @__PURE__ */ styled(Modal).withConfig({
|
|
17
|
-
displayName: "Modalstyles__AntdModal",
|
|
18
|
-
componentId: "sc-jdspxw-3"
|
|
19
|
-
})(["", " ", ""], (props) => props.isFullscreen && css(["&&{position:fixed;top:0;left:0;right:0;bottom:0;margin:0;max-width:none;padding:0;.ant-modal-content{display:flex;flex-direction:column;height:100%;}.ant-modal-body{flex:1 1 100%;overflow:scroll;}}"]), (props) => props.maxHeight && css(["&&{position:fixed;left:50%;bottom:0;translate:-50%;.ant-modal-content{max-height:", "vh;display:flex;flex-direction:column;}.ant-modal-body{flex:1 1 100%;overflow:scroll;padding-right:0px;display:flex;flex-direction:column;min-height:0;}}"], props.maxHeight));
|
|
20
|
-
const ModalWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
21
|
-
displayName: "Modalstyles__ModalWrapper",
|
|
22
|
-
componentId: "sc-jdspxw-4"
|
|
23
|
-
})(["position:relative;height:100%;min-height:0;display:flex;flex-direction:column;overflow:hidden;"]);
|
|
24
|
-
export {
|
|
25
|
-
AntdModal,
|
|
26
|
-
ButtonsWrapper,
|
|
27
|
-
ModalWrapper,
|
|
28
|
-
Scrollbar,
|
|
29
|
-
SettingButton
|
|
30
|
-
};
|
|
File without changes
|
package/dist/style/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.ant-modal{box-sizing:border-box;margin:0;padding:0;color:#6a7580;font-size:13px;font-variant:tabular-nums;line-height:1.38;list-style:none;font-feature-settings:'tnum';pointer-events:none;position:relative;top:100px;width:auto;max-width:calc(100vw - 32px);margin:0 auto;padding-bottom:24px}.ant-modal.ant-zoom-appear,.ant-modal.ant-zoom-enter{transform:none;opacity:0;animation-duration:.3s;user-select:none}.ant-modal-mask{position:fixed;top:0;right:0;bottom:0;left:0;z-index:991000;height:100%;background-color:rgba(0,0,0,.2)}.ant-modal-mask-hidden{display:none}.ant-modal-wrap{position:fixed;top:0;right:0;bottom:0;left:0;overflow:auto;outline:0}.ant-modal-wrap{z-index:991000}.ant-modal-title{margin:0;color:#384350;font-weight:500;font-size:13px;line-height:22px;word-wrap:break-word}.ant-modal-content{position:relative;background-color:#fff;background-clip:padding-box;border:0;border-radius:3px;box-shadow:0 2px 6px rgba(171,178,183,.12);pointer-events:auto}.ant-modal-close{position:absolute;top:0;right:0;z-index:10;padding:0;color:#232936;font-weight:700;line-height:1;text-decoration:none;background:0 0;border:0;outline:0;cursor:pointer;transition:color .3s}.ant-modal-close-x{display:block;width:54px;height:54px;font-size:13px;font-style:normal;line-height:54px;text-align:center;text-transform:none;text-rendering:auto}.ant-modal-close:focus,.ant-modal-close:hover{color:rgba(0,0,0,.75);text-decoration:none}.ant-modal-header{padding:16px 32px;color:#6a7580;background:#fff;border-bottom:1px solid #e9edee;border-radius:3px 3px 0 0}.ant-modal-body{padding:32px;font-size:13px;line-height:1.38;word-wrap:break-word}.ant-modal-footer{padding:10px 16px;text-align:right;background:0 0;border-top:1px solid #e9edee;border-radius:0 0 3px 3px}.ant-modal-footer .ant-btn+.ant-btn:not(.ant-dropdown-trigger){margin-bottom:0;margin-left:8px}.ant-modal-open{overflow:hidden}.ant-modal-centered{text-align:center}.ant-modal-centered::before{display:inline-block;width:0;height:100%;vertical-align:middle;content:''}.ant-modal-centered .ant-modal{top:0;display:inline-block;padding-bottom:0;text-align:left;vertical-align:middle}@media (max-width:767px){.ant-modal{max-width:calc(100vw - 16px);margin:8px auto}.ant-modal-centered .ant-modal{flex:1}}.ant-modal-confirm .ant-modal-header{display:none}.ant-modal-confirm .ant-modal-body{padding:32px 32px 24px}.ant-modal-confirm-body-wrapper::before{display:table;content:''}.ant-modal-confirm-body-wrapper::after{display:table;clear:both;content:''}.ant-modal-confirm-body .ant-modal-confirm-title{display:block;overflow:hidden;color:#384350;font-weight:500;font-size:13px;line-height:1.4}.ant-modal-confirm-body .ant-modal-confirm-content{margin-top:8px;color:#6a7580;font-size:13px}.ant-modal-confirm-body>.anticon{float:left;margin-right:16px;font-size:22px}.ant-modal-confirm-body>.anticon+.ant-modal-confirm-title+.ant-modal-confirm-content{margin-left:38px}.ant-modal-confirm .ant-modal-confirm-btns{margin-top:24px;text-align:right}.ant-modal-confirm .ant-modal-confirm-btns .ant-btn+.ant-btn{margin-bottom:0;margin-left:8px}.ant-modal-confirm-error .ant-modal-confirm-body>.anticon{color:#f52922}.ant-modal-confirm-confirm .ant-modal-confirm-body>.anticon,.ant-modal-confirm-warning .ant-modal-confirm-body>.anticon{color:#fab700}.ant-modal-confirm-info .ant-modal-confirm-body>.anticon{color:#0b68ff}.ant-modal-confirm-success .ant-modal-confirm-body>.anticon{color:#54cb0b}.ant-modal-confirm .ant-zoom-leave .ant-modal-confirm-btns{pointer-events:none}.ant-modal-wrap-rtl{direction:rtl}.ant-modal-wrap-rtl .ant-modal-close{right:initial;left:0}.ant-modal-wrap-rtl .ant-modal-footer{text-align:left}.ant-modal-wrap-rtl .ant-modal-footer .ant-btn+.ant-btn{margin-right:8px;margin-left:0}.ant-modal-wrap-rtl .ant-modal-confirm-body{direction:rtl}.ant-modal-wrap-rtl .ant-modal-confirm-body>.anticon{float:right;margin-right:0;margin-left:16px}.ant-modal-wrap-rtl .ant-modal-confirm-body>.anticon+.ant-modal-confirm-title+.ant-modal-confirm-content{margin-right:38px;margin-left:0}.ant-modal-wrap-rtl .ant-modal-confirm-btns{text-align:left}.ant-modal-wrap-rtl .ant-modal-confirm-btns .ant-btn+.ant-btn{margin-right:8px;margin-left:0}.ant-modal-wrap-rtl.ant-modal-centered .ant-modal{text-align:right}.ant-modal{transform-origin:center!important}.ant-modal-title{margin:0;font-weight:500;color:#384350}.ant-modal-content{position:relative;background-color:#fff;border:0;border-radius:3px;background-clip:padding-box;box-shadow:0 8px 16px rgba(171,178,183,.32)}.ant-modal-mask.ant-modal-mask{background-color:rgba(56,67,80,.2)}.ant-modal-close{color:#6a7580;height:32px}.ant-modal-close:focus,.ant-modal-close:hover{color:#384350}.ant-modal-header.ant-modal-header{padding:0;background:#fff;color:#6a7580;border-bottom:0}.ant-modal-header .close-modal{height:32px;width:32px;margin:0 0 0 4px;text-align:center;padding:0!important;line-height:34px;display:flex!important;justify-content:center;align-items:center}.ant-modal-header .close-modal i{font-size:15px}.ant-modal-body.ant-modal-body{padding:24px;font-size:13px;line-height:1.38}.ant-modal-footer.ant-modal-footer{min-height:81px;background-color:#f9fafb;padding:24px 24px;border-top:1px solid #f3f5f6}.ant-modal-footer button+button{margin-left:8px;margin-bottom:0}.ant-modal.ant-modal.bodybg-grey .ant-modal-body{background-color:#f9fafb}.ant-modal.modal-blank .ant-modal-header{border:0;padding:0}.ant-modal.modal-blank .ant-modal-header .close-modal{position:absolute;top:20px;right:24px;z-index:1;margin:0}
|