@synerise/ds-modal 1.4.14 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.5.0...@synerise/ds-modal@1.5.1) (2026-05-26)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **modal:** imperative api leak ([baca840](https://github.com/synerise/synerise-design/commit/baca840aea23d21f7fd156668c2c3361158979a2))
11
+
12
+ # [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)
13
+
14
+ ### Features
15
+
16
+ - **modal:** migration from antd ([3588b65](https://github.com/synerise/synerise-design/commit/3588b65fbe67838fed4ee5125090ad47d334e04b))
17
+
6
18
  ## [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)
7
19
 
8
20
  **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 offers various options and configurations to control the appearance and behavior of the modal dialogs.
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--default"></iframe>
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
- ## Deprecated Features
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
- Some features of the Modal component have been deprecated. Please refer to the [API](#api) and [FOOTER](#modalfooter) section for more information on deprecated features.
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
- **(Deprecated)** type Props is deprecated - recommended is using ModalProps
29
-
30
- ## ModalProps
31
-
32
- | Property | Description | Type | Default |
33
- | ------------------- | ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------- |
34
- | description | **(Deprecated)** The modal dialog's description | ReactNode | - |
35
- | headerBottomBar | Bottom bar rendered below title and description | ReactNode | - |
36
- | headerActions | Append additional content to header actions space | React.ReactNode | - |
37
- | headerTabProps | Props forwarded to the Tabs component rendered in the header | TabsProps | - |
38
- | size | The modal size | `small` / `medium` / `large` / `extraLarge`/ `fullSize`/ `fullScreen`. | - |
39
- | bodyBackground | Set color for body of modal | `white` / `grey` | `white` |
40
- | blank | Modal with header which contains only close button | Boolean | `false` |
41
- | titleContainerStyle | The modal title's container styles object | React.CSSProperties / undefined | - |
42
- | texts | Labels to render | `{ okButton?: ReactNode; cancelButton?: ReactNode }` | `{ okButton: 'Apply', cancelButton: 'Cancel' }` |
43
- | children | Children element to render | ReactNode | - |
44
- | open | Whether the modal dialog is visible or not | boolean | `false` |
45
- | confirmLoading | Whether to apply loading visual effect for OK button or not | boolean | `false` |
46
- | title | The modal dialog's title | string / ReactNode | - |
47
- | onOk | Specify a function that will be called when a user clicks the OK button | function(e) | - |
48
- | onCancel | Specify a function that will be called when a user clicks mask, close button on top right or Cancel button | function(e) | - |
49
- | afterClose | Specify a function that will be called when modal is closed completely. | function | - |
50
- | centered | Centered Modal | Boolean | `false` |
51
- | width | Width of the modal dialog (overridden by `size` when set) | string / number | 520 |
52
- | footer | Footer content, set as `footer={null}` when you don't need default buttons | ReactNode | OK and Cancel buttons |
53
- | okText | Text of the OK button | string / ReactNode | `OK` |
54
- | okType | Button `type` of the OK button | string | `primary` |
55
- | cancelText | Text of the Cancel button | string / ReactNode | `Cancel` |
56
- | maskClosable | Whether to close the modal dialog when the mask (area outside the modal) is clicked | boolean | `true` |
57
- | forceRender | Force render Modal | boolean | `false` |
58
- | okButtonProps | The ok button props | [ButtonProps](/components/button) | - |
59
- | cancelButtonProps | The cancel button props | [ButtonProps](/components/button) | - |
60
- | destroyOnClose | Whether to unmount child components on onClose | boolean | `false` |
61
- | style | Style of floating layer, typically used at least for adjusting the position. | object | - |
62
- | wrapClassName | The class name of the container of the modal dialog | string | - |
63
- | getContainer | Return the mount node for Modal | HTMLElement / () => HTMLElement / Selectors /`false` | document.body |
64
- | zIndex | The `z-index` of the Modal | Number | 1000 |
65
- | bodyStyle | Body style for modal body element. Such as height, padding etc. | object | {} |
66
- | mask | Whether show mask or not. | Boolean | `true` |
67
- | closeIcon | custom close icon | ReactNode | - |
68
- | maskStyle | Style for modal's mask element. | object | {} |
69
- | maxViewportHeight | Caps modal height and wraps body in a scrollbar. `true` = 80vh, number = custom vh | true / number | - |
70
- | disableScrollbar | Disables automatic scrollbar wrapping applied by `maxViewportHeight` | boolean | - |
71
-
72
- and it is extended by props for ModalFooterBuilder:
73
-
74
- | Property | Description | Type | Default | Version |
75
- | ------------------- | ------------------------------------------------------------ | ---------------------------- | -------- | ------- |
76
- | prefix | Element in footer, before Cancel Button | ReactNode | - | |
77
- | infix | Element in footer between Cancel Button and before Ok Button | ReactNode | - | |
78
- | suffix | Element in footer, after Ok Button | ReactNode | - | |
79
- | okButton | Custom OK button in footer | ReactNode | - | |
80
- | cancelButton | Custom Cancel button in footer | ReactNode | - | |
81
- | CustomFooterButton | Button component used to render ok/cancel buttons | `ComponentType<ButtonProps>` | `Button` | |
82
- | DSButton | **(Deprecated)** use `CustomFooterButton` | `ComponentType<ButtonProps>` | `Button` | |
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
- ```bash
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
- ```bash
103
- export type ModalFooterProps = Pick<
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
- **(Deprecated)** method buildModalFooter - use ModalFooter Component instead
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,116 @@
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 = (event) => {
87
+ onOk?.(event);
88
+ };
89
+ const cancelClick = (event) => {
90
+ event.stopPropagation();
91
+ };
92
+ const handleMaskClick = (event) => {
93
+ if (maskClosable) {
94
+ handleCancel(event);
95
+ }
96
+ };
97
+ const handleKeyDown = (event) => {
98
+ if (event.key === "Escape" && onCancel && closable) {
99
+ event.stopPropagation();
100
+ handleCancel(event);
101
+ }
102
+ };
103
+ const containerRef = useRef(null);
104
+ useFocusTrap(containerRef, !hidden);
105
+ return /* @__PURE__ */ jsxs(ModalRoot, { "data-testid": "ds-modal", ...rest, $hidden: hidden, "data-visible": !hidden, onKeyDown: handleKeyDown, tabIndex: -1, ref: containerRef, children: [
106
+ /* @__PURE__ */ jsx(ModalMask, {}),
107
+ /* @__PURE__ */ jsx(ModalScrollWrap, { ref: scrollRef, onClick: handleMaskClick, children: /* @__PURE__ */ jsxs(ModalContainer, { onClick: cancelClick, role: "dialog", isFullscreen, $width: size && SIZE_MAP[size], maxHeight, centered, children: [
108
+ /* @__PURE__ */ jsx(ModalTitle, { headerActions, blank, titleContainerStyle, onCancel: closable && onCancel ? handleCancel : void 0, title, description, headerTabProps, headerBottomBar }),
109
+ /* @__PURE__ */ jsx(ModalBody, { greyBackground: bodyBackground === "grey", bodyFullWidth, style: bodyStyle, children: maxHeight && !disableScrollbar ? /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, children }) }) : children }),
110
+ /* @__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 })
111
+ ] }) })
112
+ ] });
113
+ });
114
+ export {
115
+ ModalContent
116
+ };
@@ -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 { ModalProps } from '../../Modal.types';
3
- export type ModalFooterProps = Pick<ModalProps, 'prefix' | 'infix' | 'suffix' | 'okButton' | 'cancelButton' | 'CustomFooterButton' | 'DSButton' | 'texts' | 'onOk' | 'onCancel' | 'cancelText' | 'okText' | 'cancelButtonProps' | 'okType' | 'okButtonProps'>;
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 { jsxs, jsx } from "react/jsx-runtime";
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
- ...antModalProps
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
- const {
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
- antModalProps.cancelButton || /* @__PURE__ */ jsx(CustomButton, { type: "ghost", disabled: !onCancel, onClick: onCancel, ...antModalProps.cancelButtonProps, children: antModalProps.cancelText || texts?.cancelButton }),
26
+ cancelButton || /* @__PURE__ */ jsx(CustomFooterButton, { type: "ghost", onClick: onCancel, disabled: !onCancel, ...cancelButtonProps, children: cancelText || texts?.cancelButton }),
24
27
  infix,
25
- antModalProps.okButton || /* @__PURE__ */ jsx(CustomButton, { type: antModalProps.okType || "primary", disabled: !onOk, onClick: onOk, ...antModalProps.okButtonProps, children: antModalProps.okText || texts?.okButton }),
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 CustomFooterContainer: import('styled-components').StyledComponent<"div", any, {}, never>;
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
- })(["display:flex;align-items:center;justify-content:flex-end;"]);
6
- const CustomFooterContainer = /* @__PURE__ */ styled.div.withConfig({
7
- displayName: "ModalFooterstyles__CustomFooterContainer",
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-wrap:nowrap;"]);
9
+ })(["display:flex;align-items:center;justify-content:flex-end;gap:8px;"]);
10
10
  export {
11
- CustomFooterContainer,
12
- FooterContainer
11
+ FooterContainer,
12
+ FooterWrapper
13
13
  };
@@ -1,5 +1,3 @@
1
1
  import { default as React } from 'react';
2
- import { ModalProps } from '../../Modal.types';
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(Button, { mode: "single-icon", "data-testid": "modal-close", className: "close-modal", type: "ghost", onClick: onCancel, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CloseM, {}) }) }),
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<import('react').ForwardRefExoticComponent<import('antd/lib/typography/Title').TitleProps & import('react').RefAttributes<HTMLElement>>, any, {}, never>;
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 Typography from "@synerise/ds-typography";
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-0"
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(Typography.Title).withConfig({
21
+ const Title = /* @__PURE__ */ styled(Title$1).withConfig({
17
22
  displayName: "ModalTitlestyles__Title",
18
- componentId: "sc-hnk65g-1"
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-2"
23
- })(["display:flex;flex-direction:row;align-items:center;.ant-btn{margin:0 4px;}.close-modal{padding:0;display:flex;align-items:center;justify-content:center;margin-right:0;}"]);
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-3"
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-4"
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-5"
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%,rgba(255,255,255,0) 0% );background-repeat:repeat-x;background-size:4px 1px;background-position:top;"], (props) => props.theme.palette["grey-600"], (props) => props.theme.palette["grey-300"]);
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-6"
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,
@@ -1,2 +1 @@
1
1
  export * from './ModalTitle';
2
- export { TitleContainer } from './ModalTitle.styles';
@@ -1,6 +1,4 @@
1
1
  import { ModalTitle } from "./ModalTitle.js";
2
- import { TitleContainer } from "./ModalTitle.styles.js";
3
2
  export {
4
- ModalTitle,
5
- TitleContainer
3
+ ModalTitle
6
4
  };
@@ -0,0 +1,2 @@
1
+ import { ModalSize } from './Modal.types';
2
+ export declare const SIZE_MAP: Record<ModalSize, string>;
@@ -0,0 +1,11 @@
1
+ const SIZE_MAP = {
2
+ small: "520px",
3
+ medium: "792px",
4
+ large: "1044px",
5
+ extraLarge: "1280px",
6
+ fullSize: "100%",
7
+ fullScreen: "100%"
8
+ };
9
+ export {
10
+ SIZE_MAP
11
+ };
package/dist/Modal.d.ts CHANGED
@@ -1,14 +1,4 @@
1
1
  import { default as React } from 'react';
2
- import { ModalFooterProps } from './Elements/ModalFooter';
3
- import { ModalProps } from './Modal.types';
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 { Modal as Modal$1 } from "antd";
3
- import classnames from "classnames";
4
- import { ModalFooter } from "./Elements/ModalFooter/ModalFooter.js";
5
- import { ModalTitle } from "./Elements/ModalTitle/ModalTitle.js";
6
- import "styled-components";
7
- import "@synerise/ds-typography";
8
- import { AntdModal, ModalWrapper, Scrollbar } from "./Modal.styles.js";
9
- import "./style/index.css";
10
- const mapSizeToWidth = {
11
- small: 520,
12
- medium: 792,
13
- large: 1044,
14
- extraLarge: 1280,
15
- fullSize: "100%",
16
- fullScreen: "100%"
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
- return void 0;
52
- };
53
- const isFullscreen = size === "fullScreen";
54
- return /* @__PURE__ */ jsx(AntdModal, { ...antModalProps, maxHeight: maxHeight(), className, isFullscreen, width: size && mapSizeToWidth[size], closable: false, title: (title || description || blank || headerBottomBar) && /* @__PURE__ */ jsx(ModalTitle, { ...props }), footer: antModalProps.footer !== null ? antModalProps.footer || /* @__PURE__ */ jsx(ModalFooter, { ...props }) : null, children: maxHeight() && !disableScrollbar ? /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsx(Scrollbar, { absolute: true, children }) }) : children });
55
- };
56
- Modal.info = Modal$1.info;
57
- Modal.success = Modal$1.success;
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
  };
@@ -1,8 +1,8 @@
1
- import { ModalProps as AntdModalProps } from 'antd';
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 Props = ModalProps;
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
- /** Props forwarded to the Tabs component rendered in the header */
15
+ title?: ReactNode;
16
16
  headerTabProps?: TabsProps;
17
- /** Predefined modal width */
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
- /** Custom styles applied to the title container */
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
- /** When `true`, disables the automatic scrollbar wrapping applied by `maxViewportHeight` */
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,2 @@
1
+ import { ModalHandle, ModalProps } from './Modal.types';
2
+ export declare const showModal: ({ onOk, afterClose, ...initial }: ModalProps) => ModalHandle;
@@ -0,0 +1,33 @@
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 isThenable = (value) => !!value && typeof value.then === "function";
6
+ const showModal = ({
7
+ onOk,
8
+ afterClose,
9
+ ...initial
10
+ }) => {
11
+ const cleanup = () => {
12
+ setPortalContent(null);
13
+ };
14
+ const handle = {
15
+ destroy: cleanup
16
+ };
17
+ const handleOk = async (event) => {
18
+ const result = onOk?.(event);
19
+ if (isThenable(result)) {
20
+ await result;
21
+ handle.destroy();
22
+ }
23
+ };
24
+ modalInstanceId += 1;
25
+ setPortalContent(/* @__PURE__ */ jsx(Modal, { ...initial, open: true, onOk: onOk ? handleOk : void 0, afterClose: () => {
26
+ afterClose?.();
27
+ cleanup();
28
+ } }, modalInstanceId));
29
+ return handle;
30
+ };
31
+ export {
32
+ showModal
33
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { default, buildModalFooter } from './Modal';
2
- export { ModalTitle, TitleContainer } from './Elements/ModalTitle';
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 type { Props, ModalProps } from './Modal.types';
5
+ export * from './Modal.types';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { buildModalFooter, Modal } from "./Modal.js";
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
- TitleContainer,
9
- buildModalFooter,
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.4.14",
3
+ "version": "1.5.1",
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.29",
45
- "@synerise/ds-icon": "^1.18.0",
46
- "@synerise/ds-scrollbar": "^1.3.5",
47
- "@synerise/ds-tabs": "^1.1.37",
48
- "@synerise/ds-typography": "^1.1.22",
49
- "classnames": "^2.5.1"
41
+ "@synerise/ds-button": "^1.5.31",
42
+ "@synerise/ds-icon": "^1.18.2",
43
+ "@synerise/ds-scrollbar": "^1.4.1",
44
+ "@synerise/ds-tabs": "^1.1.39",
45
+ "@synerise/ds-typography": "^1.1.24",
46
+ "@synerise/ds-utils": "^1.9.1"
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": "ef14a62702ad420add6ad1c56da88df1f70a1bb8"
56
+ "gitHead": "be94b7e7ec28b566a3279e24248e610d87d8c0a5"
61
57
  }
@@ -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>;
@@ -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
@@ -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}