@synerise/ds-modal 1.5.1 → 1.6.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 CHANGED
@@ -3,6 +3,20 @@
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.6.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.5.2...@synerise/ds-modal@1.6.0) (2026-06-11)
7
+
8
+ ### Features
9
+
10
+ - add bodyScrollRef to Modal for external VirtualTable scroll ([72a8cbb](https://github.com/synerise/synerise-design/commit/72a8cbb40a75aa127ca11fc5984a46aef3a4fb80))
11
+ - focus dialog container on modal open, add initialFocusRef opt-in ([cf80110](https://github.com/synerise/synerise-design/commit/cf801100a30246bd1699debe293f4f7711c435b5))
12
+ - **tabs:** align dimensions with figma and add configurable group top padding ([bd8dbe4](https://github.com/synerise/synerise-design/commit/bd8dbe40a4f2e7dbd45acc3151cafd645181535e))
13
+
14
+ ## [1.5.2](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@1.5.1...@synerise/ds-modal@1.5.2) (2026-06-03)
15
+
16
+ ### Bug Fixes
17
+
18
+ - **modal:** a11y and other tweaks ([cfbeb11](https://github.com/synerise/synerise-design/commit/cfbeb11c8e1a60d99885ec87e91783eb1800c8d9))
19
+
6
20
  ## [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
21
 
8
22
  ### Bug Fixes
package/README.md CHANGED
@@ -118,6 +118,12 @@ ref.current?.scrollToBottom();
118
118
  | `zIndex` | `z-index` of the modal | `number` | – |
119
119
  | `className` | CSS class applied to the modal root | `string` | – |
120
120
  | `style` | Inline styles applied to the modal root | `CSSProperties` | – |
121
+ | `ariaLabel` | Accessible name for the dialog. Used as a fallback when `title` is absent (e.g. `blank` modals) or is a non-text node | `string` | – |
122
+ | `closeButtonAriaLabel` | Accessible name for the close button. Defaults to the localised `DS.MODAL.CLOSE` translation | `string` | `Close` |
123
+
124
+ ### Accessibility
125
+
126
+ The dialog container carries `role="dialog"` and `aria-modal="true"`. When a `title` is provided it is linked via `aria-labelledby`; otherwise pass `ariaLabel` to give the dialog an accessible name. A `description`, when present, is linked via `aria-describedby`. The close button's accessible name defaults to the localised `DS.MODAL.CLOSE` translation (`"Close"`), overridable with `closeButtonAriaLabel`. Focus is trapped while the modal is open and restored to the previously focused element on close, and `Escape` closes the modal when `onCancel` is set and `closable` is not `false`.
121
127
 
122
128
  ### Footer layout slots
123
129
 
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { ModalRef } from '../../Modal.types';
3
- export declare const ModalContent: React.ForwardRefExoticComponent<Omit<import('../../Modal.types').ModalProps, "getContainer" | "open" | "destroyOnClose"> & {
3
+ export declare const ModalContent: React.ForwardRefExoticComponent<Omit<import('../../Modal.types').ModalProps, "getContainer" | "open" | "destroyOnClose" | "afterClose"> & {
4
4
  closeModal: () => void;
5
5
  hidden?: boolean;
6
6
  } & React.RefAttributes<ModalRef>>;
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useRef, useMemo, useEffect, useCallback, useImperativeHandle } from "react";
2
+ import { forwardRef, useRef, useId, useMemo, useCallback, useImperativeHandle } from "react";
3
3
  import { useFocusTrap } from "@synerise/ds-utils";
4
4
  import { SIZE_MAP } from "../../Modal.const.js";
5
5
  import { ModalFooter } from "../ModalFooter/ModalFooter.js";
@@ -8,7 +8,6 @@ import { ModalRoot, ModalMask, ModalScrollWrap, ModalContainer, ModalBody, Modal
8
8
  const ModalContent = forwardRef(({
9
9
  children,
10
10
  size = "small",
11
- afterClose,
12
11
  maxViewportHeight,
13
12
  headerActions,
14
13
  blank,
@@ -37,13 +36,19 @@ const ModalContent = forwardRef(({
37
36
  footer,
38
37
  bodyStyle,
39
38
  disableScrollbar,
39
+ bodyScrollRef,
40
40
  closable = true,
41
41
  maskClosable = true,
42
42
  centered,
43
43
  hidden,
44
+ ariaLabel,
45
+ closeButtonAriaLabel,
46
+ initialFocusRef,
44
47
  ...rest
45
48
  }, modalRef) => {
46
49
  const scrollRef = useRef(null);
50
+ const titleId = useId();
51
+ const descriptionId = useId();
47
52
  const DEFAULT_VIEWPORT_HEIGHT = 80;
48
53
  const isFullscreen = size === "fullScreen";
49
54
  const maxHeight = useMemo(() => {
@@ -55,11 +60,7 @@ const ModalContent = forwardRef(({
55
60
  }
56
61
  return void 0;
57
62
  }, [maxViewportHeight]);
58
- useEffect(() => {
59
- return () => {
60
- afterClose?.();
61
- };
62
- }, []);
63
+ const useScrollbar = !!maxHeight && !disableScrollbar;
63
64
  const scrollToTop = useCallback(() => {
64
65
  scrollRef.current?.scrollTo(0, 0);
65
66
  }, []);
@@ -101,12 +102,17 @@ const ModalContent = forwardRef(({
101
102
  }
102
103
  };
103
104
  const containerRef = useRef(null);
104
- useFocusTrap(containerRef, !hidden);
105
+ const dialogRef = useRef(null);
106
+ useFocusTrap(containerRef, !hidden, {
107
+ initialFocus: initialFocusRef ?? dialogRef
108
+ });
105
109
  return /* @__PURE__ */ jsxs(ModalRoot, { "data-testid": "ds-modal", ...rest, $hidden: hidden, "data-visible": !hidden, onKeyDown: handleKeyDown, tabIndex: -1, ref: containerRef, children: [
106
110
  /* @__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 }),
111
+ /* @__PURE__ */ jsx(ModalScrollWrap, { ref: scrollRef, onClick: handleMaskClick, children: /* @__PURE__ */ jsxs(ModalContainer, { ref: dialogRef, tabIndex: -1, onClick: cancelClick, role: "dialog", "aria-modal": true, "aria-labelledby": title ? titleId : void 0, "aria-label": !title ? ariaLabel : void 0, "aria-describedby": description ? descriptionId : void 0, isFullscreen, $width: size && SIZE_MAP[size], maxHeight, centered, children: [
112
+ /* @__PURE__ */ jsx(ModalTitle, { headerActions, blank, titleContainerStyle, onCancel: closable && onCancel ? handleCancel : void 0, title, titleId, description, descriptionId, headerTabProps, headerBottomBar, closeButtonAriaLabel }),
113
+ /* @__PURE__ */ jsx(ModalBody, { ref: useScrollbar ? void 0 : bodyScrollRef, greyBackground: bodyBackground === "grey", bodyFullWidth, style: bodyStyle, children: useScrollbar ? /* @__PURE__ */ jsx(ModalWrapper, { children: /* @__PURE__ */ jsx(Scrollbar, { scrollbarOptions: {
114
+ suppressScrollX: true
115
+ }, absolute: true, classes: "ds-modal-body-scrollbar", ref: bodyScrollRef, children }) }) : children }),
110
116
  /* @__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
117
  ] }) })
112
118
  ] });
@@ -11,11 +11,11 @@ const ModalWrapper = /* @__PURE__ */ styled.div.withConfig({
11
11
  const Scrollbar = /* @__PURE__ */ styled(ScrollbarBase).withConfig({
12
12
  displayName: "ModalContentstyles__Scrollbar",
13
13
  componentId: "sc-1sk67uc-2"
14
- })(["display:flex;flex-direction:column;min-height:0;.scrollbar-container{min-height:0;}"]);
14
+ })(["display:flex;flex-direction:column;min-height:0;.scrollbar-container{min-height:0;}.ps__rail-y,.ps__rail-x{z-index:99;}.ds-modal-body-scrollbar{width:100%;overflow-x:clip;}"]);
15
15
  const ModalBody = /* @__PURE__ */ styled.div.withConfig({
16
16
  displayName: "ModalContentstyles__ModalBody",
17
17
  componentId: "sc-1sk67uc-3"
18
- })(["", " ", ""], (props) => !props.bodyFullWidth && `padding: 24px;`, (props) => props.greyBackground && `background: ${props.theme.palette["grey-050"]};`);
18
+ })(["", " ", " ", ""], (props) => !props.bodyFullWidth && `padding: 24px;`, (props) => props.greyBackground && `background: ${props.theme.palette["grey-050"]};`, (props) => !props.bodyFullWidth && css(["", "{.scrollbar-container{padding-right:24px;}}"], Scrollbar));
19
19
  const ModalContainer = /* @__PURE__ */ styled.div.withConfig({
20
20
  displayName: "ModalContentstyles__ModalContainer",
21
21
  componentId: "sc-1sk67uc-4"
@@ -1,3 +1,3 @@
1
1
  import { default as React } from 'react';
2
2
  import { ModalTitleProps } from '../../Modal.types';
3
- export declare const ModalTitle: ({ headerActions, blank, titleContainerStyle, onCancel, title, description, headerTabProps, headerBottomBar, }: ModalTitleProps) => React.JSX.Element;
3
+ export declare const ModalTitle: ({ headerActions, blank, titleContainerStyle, onCancel, title, titleId, description, descriptionId, headerTabProps, headerBottomBar, closeButtonAriaLabel, }: ModalTitleProps) => React.JSX.Element;
@@ -1,30 +1,43 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useIntl } from "react-intl";
2
3
  import Button from "@synerise/ds-button";
3
4
  import Icon, { CloseM } from "@synerise/ds-icon";
4
5
  import Tabs from "@synerise/ds-tabs";
5
- import { CloseButton, ModalTitleWrapper, TitleContainer, Title, ActionButtons, Description, TabsWrapper, BottomBar } from "./ModalTitle.styles.js";
6
+ import { CloseButton, ModalHeaderTop, ModalTitleWrapper, TitleContainer, Title, ActionButtons, Description, TabsWrapper, BottomBar } from "./ModalTitle.styles.js";
6
7
  const ModalTitle = ({
7
8
  headerActions,
8
9
  blank,
9
10
  titleContainerStyle,
10
11
  onCancel,
11
12
  title,
13
+ titleId,
12
14
  description,
15
+ descriptionId,
13
16
  headerTabProps,
14
- headerBottomBar
17
+ headerBottomBar,
18
+ closeButtonAriaLabel
15
19
  }) => {
20
+ const {
21
+ formatMessage
22
+ } = useIntl();
23
+ const closeLabel = closeButtonAriaLabel ?? formatMessage({
24
+ id: "DS.MODAL.CLOSE",
25
+ defaultMessage: "Close"
26
+ });
16
27
  return /* @__PURE__ */ jsxs(Fragment, { children: [
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
- (title || description || headerTabProps) && /* @__PURE__ */ jsxs(ModalTitleWrapper, { withDescription: !!description, withTabs: !!headerTabProps, children: [
19
- title && /* @__PURE__ */ jsxs(TitleContainer, { style: titleContainerStyle, "data-testid": "modal-title", children: [
20
- /* @__PURE__ */ jsx(Title, { level: 3, children: title }),
21
- /* @__PURE__ */ jsxs(ActionButtons, { children: [
22
- headerActions,
23
- 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, {}) }) })
24
- ] })
28
+ blank && onCancel && /* @__PURE__ */ jsx(CloseButton, { mode: "single-icon", "data-testid": "modal-close", className: "close-modal", type: "ghost", "aria-label": closeLabel, onClick: onCancel, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CloseM, {}) }) }),
29
+ (title || description || headerTabProps) && /* @__PURE__ */ jsxs(ModalHeaderTop, { children: [
30
+ /* @__PURE__ */ jsxs(ModalTitleWrapper, { withDescription: !!description, withTabs: !!headerTabProps, children: [
31
+ title && /* @__PURE__ */ jsxs(TitleContainer, { style: titleContainerStyle, "data-testid": "modal-title", children: [
32
+ /* @__PURE__ */ jsx(Title, { level: 3, id: titleId, children: title }),
33
+ /* @__PURE__ */ jsxs(ActionButtons, { children: [
34
+ headerActions,
35
+ onCancel && /* @__PURE__ */ jsx(Button, { mode: "single-icon", "data-testid": "modal-close", className: "close-modal", type: "ghost", "aria-label": closeLabel, onClick: onCancel, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CloseM, {}) }) })
36
+ ] })
37
+ ] }),
38
+ description && /* @__PURE__ */ jsx(Description, { id: descriptionId, children: description })
25
39
  ] }),
26
- description && /* @__PURE__ */ jsx(Description, { children: description }),
27
- headerTabProps && /* @__PURE__ */ jsx(TabsWrapper, { children: /* @__PURE__ */ jsx(Tabs, { ...headerTabProps }) })
40
+ headerTabProps && /* @__PURE__ */ jsx(TabsWrapper, { children: /* @__PURE__ */ jsx(Tabs, { topPadding: 0, ...headerTabProps }) })
28
41
  ] }),
29
42
  headerBottomBar && /* @__PURE__ */ jsx(BottomBar, { children: headerBottomBar })
30
43
  ] });
@@ -4,6 +4,7 @@ export declare const TitleContainer: import('styled-components').StyledComponent
4
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>;
5
5
  export declare const ActionButtons: import('styled-components').StyledComponent<"div", any, {}, never>;
6
6
  export declare const BottomBar: import('styled-components').StyledComponent<"div", any, {}, never>;
7
+ export declare const ModalHeaderTop: import('styled-components').StyledComponent<"div", any, {}, never>;
7
8
  export declare const ModalTitleWrapper: import('styled-components').StyledComponent<"div", any, {
8
9
  withDescription?: boolean;
9
10
  withTabs?: boolean;
@@ -1,15 +1,6 @@
1
1
  import styled from "styled-components";
2
2
  import Button from "@synerise/ds-button";
3
3
  import { Title as Title$1 } from "@synerise/ds-typography";
4
- const getBottomPadding = (withTabs, withDescription) => {
5
- if (withTabs) {
6
- return 0;
7
- }
8
- if (withDescription) {
9
- return 12;
10
- }
11
- return 20;
12
- };
13
4
  const CloseButton = /* @__PURE__ */ styled(Button).withConfig({
14
5
  displayName: "ModalTitlestyles__CloseButton",
15
6
  componentId: "sc-hnk65g-0"
@@ -17,7 +8,7 @@ const CloseButton = /* @__PURE__ */ styled(Button).withConfig({
17
8
  const TitleContainer = /* @__PURE__ */ styled.div.withConfig({
18
9
  displayName: "ModalTitlestyles__TitleContainer",
19
10
  componentId: "sc-hnk65g-1"
20
- })(["display:flex;align-items:center;flex-wrap:nowrap;&&{.close-modal{line-height:1;}}"]);
11
+ })(["display:flex;align-items:center;flex-wrap:nowrap;min-height:40px;&&{.close-modal{line-height:1;}}"]);
21
12
  const Title = /* @__PURE__ */ styled(Title$1).withConfig({
22
13
  displayName: "ModalTitlestyles__Title",
23
14
  componentId: "sc-hnk65g-2"
@@ -29,24 +20,29 @@ const ActionButtons = /* @__PURE__ */ styled.div.withConfig({
29
20
  const BottomBar = /* @__PURE__ */ styled.div.withConfig({
30
21
  displayName: "ModalTitlestyles__BottomBar",
31
22
  componentId: "sc-hnk65g-4"
32
- })(["padding:12px 24px;border-bottom:1px solid ", ";"], (props) => props.theme.palette["grey-100"]);
23
+ })(["padding:12px 24px;border-bottom:1px solid ", ";"], (props) => props.theme.palette["grey-200"]);
24
+ const ModalHeaderTop = /* @__PURE__ */ styled.div.withConfig({
25
+ displayName: "ModalTitlestyles__ModalHeaderTop",
26
+ componentId: "sc-hnk65g-5"
27
+ })(["border-bottom:1px solid ", ";"], (props) => props.theme.palette["grey-100"]);
33
28
  const ModalTitleWrapper = /* @__PURE__ */ styled.div.withConfig({
34
29
  displayName: "ModalTitlestyles__ModalTitleWrapper",
35
- componentId: "sc-hnk65g-5"
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"]);
30
+ componentId: "sc-hnk65g-6"
31
+ })(["padding:16px 24px;font-size:18px;line-height:32px;"]);
37
32
  const Description = /* @__PURE__ */ styled.div.withConfig({
38
33
  displayName: "ModalTitlestyles__Description",
39
- componentId: "sc-hnk65g-6"
34
+ componentId: "sc-hnk65g-7"
40
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%,", " 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"]);
41
36
  const TabsWrapper = /* @__PURE__ */ styled.div.withConfig({
42
37
  displayName: "ModalTitlestyles__TabsWrapper",
43
- componentId: "sc-hnk65g-7"
44
- })(["padding-bottom:1px;"]);
38
+ componentId: "sc-hnk65g-8"
39
+ })(["padding-bottom:1px;padding:0 24px;"]);
45
40
  export {
46
41
  ActionButtons,
47
42
  BottomBar,
48
43
  CloseButton,
49
44
  Description,
45
+ ModalHeaderTop,
50
46
  ModalTitleWrapper,
51
47
  TabsWrapper,
52
48
  Title,
package/dist/Modal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { forwardRef, useState, useEffect } from "react";
2
+ import { forwardRef, useState, useRef, useEffect } from "react";
3
3
  import { createPortal } from "react-dom";
4
4
  import { ModalContent } from "./Elements/ModalContent/ModalContent.js";
5
5
  const Modal = forwardRef(({
@@ -11,17 +11,29 @@ const Modal = forwardRef(({
11
11
  }, ref) => {
12
12
  const [isOpen, setIsOpen] = useState(open);
13
13
  const [hasBeenOpened, setHasBeenOpened] = useState(open);
14
+ const prevOpenRef = useRef(open);
14
15
  useEffect(() => {
15
16
  setIsOpen(open);
16
17
  if (open) {
17
18
  setHasBeenOpened(true);
19
+ } else if (prevOpenRef.current) {
20
+ afterClose?.();
18
21
  }
19
- }, [open]);
22
+ prevOpenRef.current = open;
23
+ }, [open, afterClose]);
24
+ const closeModal = () => {
25
+ setIsOpen((prev) => {
26
+ if (prev) {
27
+ afterClose?.();
28
+ }
29
+ return false;
30
+ });
31
+ };
20
32
  const shouldRender = destroyOnClose ? isOpen : isOpen || hasBeenOpened;
21
33
  if (!shouldRender) {
22
34
  return null;
23
35
  }
24
- return createPortal(/* @__PURE__ */ jsx(ModalContent, { ...props, afterClose, ref, hidden: !isOpen, closeModal: () => setIsOpen(false) }), getContainer?.() || document.body);
36
+ return createPortal(/* @__PURE__ */ jsx(ModalContent, { ...props, ref, hidden: !isOpen, closeModal }), getContainer?.() || document.body);
25
37
  });
26
38
  export {
27
39
  Modal,
@@ -1,72 +1,220 @@
1
- import { CSSProperties, ComponentType, MouseEvent, ReactNode } from 'react';
1
+ import { CSSProperties, ComponentType, MouseEvent, MutableRefObject, ReactNode, RefObject } from 'react';
2
2
  import { ButtonProps, ButtonType } from '@synerise/ds-button';
3
3
  import { TabsProps } from '@synerise/ds-tabs';
4
+ /**
5
+ * Predefined modal widths.
6
+ *
7
+ * - `small` — 520px
8
+ * - `medium` — 792px
9
+ * - `large` — 1044px
10
+ * - `extraLarge` — 1280px
11
+ * - `fullSize` — 100% width
12
+ * - `fullScreen` — 100%, `fixed`-positioned, covering the viewport
13
+ */
4
14
  export type ModalSize = 'small' | 'medium' | 'large' | 'extraLarge' | 'fullSize' | 'fullScreen';
15
+ /**
16
+ * Handler for the OK / Cancel buttons. May be synchronous or return a
17
+ * `Promise` — when a promise is returned, the modal stays open until it
18
+ * resolves.
19
+ */
5
20
  type ModalButtonHandler = ((e: MouseEvent<HTMLElement>) => void) | ((e: MouseEvent<HTMLElement>) => Promise<unknown>);
21
+ /** Props for the {@link Modal} component. */
6
22
  export type ModalProps = {
7
23
  /**
8
- * @deprecated - this prop will be removed soon
24
+ * Sub-title rendered with a dashed separator below the title.
25
+ * @deprecated this prop will be removed soon
9
26
  */
10
27
  description?: ReactNode;
11
- /** Content rendered below the modal header */
28
+ /** Full-width bar rendered below the modal header. */
12
29
  headerBottomBar?: ReactNode;
13
- /** Actions rendered in the top-right area of the header */
30
+ /** Actions (buttons/icons) rendered in the top-right area of the header. */
14
31
  headerActions?: ReactNode;
32
+ /** Modal header title. */
15
33
  title?: ReactNode;
34
+ /** When provided, renders a `Tabs` component in the header. */
16
35
  headerTabProps?: TabsProps;
36
+ /** Predefined modal width. @see {@link ModalSize} */
17
37
  size?: ModalSize;
38
+ /**
39
+ * Accessible name for the dialog, exposed via `aria-label`. Used as a
40
+ * fallback when `title` is absent (e.g. `blank` modals) or is a non-text
41
+ * node. When `title` is set it takes precedence via `aria-labelledby`.
42
+ */
43
+ ariaLabel?: string;
44
+ /**
45
+ * Accessible name for the close button, exposed via `aria-label`. When
46
+ * omitted, falls back to the localised `DS.MODAL.CLOSE` translation
47
+ * (default message `'Close'`).
48
+ */
49
+ closeButtonAriaLabel?: string;
50
+ /**
51
+ * Ref to the element that should receive focus when the modal opens. By
52
+ * default focus lands on the dialog container itself, which screen readers
53
+ * announce by the dialog's accessible name (no cursor in any field). Provide
54
+ * this only when focusing a specific control is genuinely useful — e.g. the
55
+ * search input of a search dialog or the name field of a rename dialog.
56
+ */
57
+ initialFocusRef?: RefObject<HTMLElement | null>;
58
+ /**
59
+ * Background colour of the modal body.
60
+ * @defaultValue `'white'`
61
+ */
18
62
  bodyBackground?: 'white' | 'grey';
19
- /** Renders a minimal modal without header and footer chrome */
63
+ /**
64
+ * Renders a minimal modal without header/footer chrome; shows only a close
65
+ * button when `onCancel` is provided.
66
+ */
20
67
  blank?: boolean;
68
+ /** When `maxViewportHeight` is set, disables the built-in scrollbar wrapper. */
21
69
  disableScrollbar?: boolean;
70
+ /**
71
+ * Ref to the modal body's scroll element. When the custom scrollbar is active
72
+ * (`maxViewportHeight` set, `disableScrollbar` not), it resolves to that scrollbar's
73
+ * scroll node; when `disableScrollbar` is set, it resolves to the body element itself.
74
+ * Pass the same ref to a child `VirtualTable`'s `scrollElementRef` to make the modal's
75
+ * scroll drive the table's virtualization. Note: when the custom scrollbar is active the
76
+ * node binds one tick after mount (see the ds-scrollbar ref chain).
77
+ */
78
+ bodyScrollRef?: MutableRefObject<HTMLDivElement | null>;
79
+ /** Removes the padding from the modal body. */
22
80
  bodyFullWidth?: boolean;
81
+ /**
82
+ * Vertically centres the modal in the viewport.
83
+ * @defaultValue `false`
84
+ */
23
85
  centered?: boolean;
86
+ /**
87
+ * Whether the close button is shown.
88
+ * @defaultValue `true`
89
+ */
24
90
  closable?: boolean;
91
+ /**
92
+ * Whether clicking the backdrop closes the modal.
93
+ * @defaultValue `true`
94
+ */
25
95
  maskClosable?: boolean;
96
+ /**
97
+ * Whether the modal is visible.
98
+ * @defaultValue `false`
99
+ */
26
100
  open?: boolean;
27
- /** When true, unmounts children when the modal closes. When false (default), keeps children mounted but hidden. */
101
+ /**
102
+ * When `true`, unmounts children when the modal closes. When `false`
103
+ * (default), keeps children mounted but hidden.
104
+ * @defaultValue `false`
105
+ */
28
106
  destroyOnClose?: boolean;
107
+ /** Inline styles applied to the title container element. */
29
108
  titleContainerStyle?: CSSProperties;
30
- /** Localised button labels */
109
+ /**
110
+ * Localised default button labels.
111
+ * @defaultValue `{ okButton: 'Apply', cancelButton: 'Cancel' }`
112
+ */
31
113
  texts?: {
114
+ /** Label for the OK / Apply button. */
32
115
  okButton?: ReactNode;
116
+ /** Label for the Cancel button. */
33
117
  cancelButton?: ReactNode;
34
118
  };
119
+ /** Modal body content. */
35
120
  children?: ReactNode;
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. */
121
+ /**
122
+ * Constrains modal height to a percentage of the viewport and wraps children
123
+ * in a scrollbar. Pass `true` for 80 vh or a number for a custom value.
124
+ * Anchors the modal to the bottom of the viewport (sheet-style).
125
+ */
37
126
  maxViewportHeight?: true | number;
127
+ /**
128
+ * Returns the DOM node the modal portal mounts into.
129
+ * @defaultValue `document.body`
130
+ */
38
131
  getContainer?: () => HTMLElement;
132
+ /** Footer slot rendered before the cancel button. */
39
133
  prefix?: ReactNode;
134
+ /** Footer slot rendered between the cancel and OK buttons. */
40
135
  infix?: ReactNode;
136
+ /** Footer slot rendered after the OK button. */
41
137
  suffix?: ReactNode;
138
+ /** Replaces the auto-generated OK button entirely. */
42
139
  okButton?: ReactNode;
140
+ /** Replaces the auto-generated cancel button entirely. */
43
141
  cancelButton?: ReactNode;
142
+ /**
143
+ * Custom button component used for the auto-generated ok/cancel buttons.
144
+ * @defaultValue `Button`
145
+ */
44
146
  CustomFooterButton?: ComponentType<ButtonProps>;
147
+ /**
148
+ * Called after each close transition (every `open: true → false`), matching
149
+ * antd Modal semantics. Does NOT fire on initial mount, and does NOT fire if
150
+ * the Modal is hard-unmounted while still open.
151
+ */
45
152
  afterClose?: () => void;
153
+ /**
154
+ * Custom footer content. `null` suppresses the footer entirely; a custom
155
+ * node overrides the auto-generated footer.
156
+ * @defaultValue auto-generated OK + Cancel buttons
157
+ */
46
158
  footer?: ReactNode;
159
+ /** Cancel/close handler; may return a `Promise`. @see {@link ModalButtonHandler} */
47
160
  onCancel?: ModalButtonHandler;
161
+ /** Label for the cancel button (overrides `texts.cancelButton`). */
48
162
  cancelText?: ReactNode;
163
+ /** Extra props forwarded to the cancel button. */
49
164
  cancelButtonProps?: ButtonProps;
165
+ /** OK button handler; may return a `Promise`. @see {@link ModalButtonHandler} */
50
166
  onOk?: ModalButtonHandler;
167
+ /** Label for the OK button (overrides `texts.okButton`). */
51
168
  okText?: ReactNode;
169
+ /** Extra props forwarded to the OK button. */
52
170
  okButtonProps?: ButtonProps;
171
+ /**
172
+ * Button type for the OK button.
173
+ * @defaultValue `'primary'`
174
+ */
53
175
  okType?: ButtonType;
176
+ /** Inline styles applied to the modal body element. */
54
177
  bodyStyle?: CSSProperties;
178
+ /**
179
+ * `z-index` of the modal root.
180
+ * @defaultValue theme `zindex-modal`
181
+ */
55
182
  zIndex?: number;
183
+ /** CSS class applied to the modal root. */
56
184
  className?: string;
185
+ /** Inline styles applied to the modal root. */
57
186
  style?: CSSProperties;
58
187
  };
59
- export type ModalContentProps = Omit<ModalProps, 'getContainer' | 'open' | 'destroyOnClose'> & {
188
+ /**
189
+ * Props for the internal `ModalContent` element. Extends {@link ModalProps}
190
+ * minus the props handled by the `Modal` wrapper, plus the internal close
191
+ * callback and hidden state.
192
+ */
193
+ export type ModalContentProps = Omit<ModalProps, 'getContainer' | 'open' | 'destroyOnClose' | 'afterClose'> & {
194
+ /** Closes the modal (drives the wrapper's open state). */
60
195
  closeModal: () => void;
196
+ /** When `true`, the modal is kept mounted but visually hidden. */
61
197
  hidden?: boolean;
62
198
  };
63
- export type ModalTitleProps = Pick<ModalContentProps, 'headerActions' | 'headerTabProps' | 'onCancel' | 'titleContainerStyle' | 'blank' | 'description' | 'title' | 'headerBottomBar'>;
199
+ /** Props for the `ModalTitle` header sub-component. */
200
+ export type ModalTitleProps = Pick<ModalContentProps, 'headerActions' | 'headerTabProps' | 'onCancel' | 'titleContainerStyle' | 'blank' | 'description' | 'title' | 'headerBottomBar' | 'closeButtonAriaLabel'> & {
201
+ /** Id applied to the title element, referenced by the dialog's `aria-labelledby`. */
202
+ titleId?: string;
203
+ /** Id applied to the description element, referenced by the dialog's `aria-describedby`. */
204
+ descriptionId?: string;
205
+ };
206
+ /** Props for the `ModalFooter` footer sub-component. */
64
207
  export type ModalFooterProps = Pick<ModalContentProps, 'footer' | 'prefix' | 'infix' | 'suffix' | 'okButton' | 'cancelButton' | 'CustomFooterButton' | 'texts' | 'onOk' | 'onCancel' | 'cancelText' | 'okText' | 'cancelButtonProps' | 'okType' | 'okButtonProps'>;
208
+ /** Imperative handle returned by `showModal()`. */
65
209
  export type ModalHandle = {
210
+ /** Unmounts the imperatively-rendered modal. */
66
211
  destroy: () => void;
67
212
  };
213
+ /** Ref handle exposed by `Modal` via `forwardRef` for scroll control. */
68
214
  export type ModalRef = {
215
+ /** Scrolls the modal body to the top. */
69
216
  scrollToTop: () => void;
217
+ /** Scrolls the modal body to the bottom. */
70
218
  scrollToBottom: () => void;
71
219
  };
72
220
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-modal",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Modal UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -38,12 +38,12 @@
38
38
  "sideEffects": false,
39
39
  "types": "dist/index.d.ts",
40
40
  "dependencies": {
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"
41
+ "@synerise/ds-button": "^1.5.32",
42
+ "@synerise/ds-icon": "^1.18.3",
43
+ "@synerise/ds-scrollbar": "^1.5.0",
44
+ "@synerise/ds-tabs": "^1.2.0",
45
+ "@synerise/ds-typography": "^1.1.25",
46
+ "@synerise/ds-utils": "^1.10.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "vitest": "4"
@@ -51,7 +51,8 @@
51
51
  "peerDependencies": {
52
52
  "@synerise/ds-core": "*",
53
53
  "react": ">=16.9.0 <= 18.3.1",
54
+ "react-intl": ">=3.12.0 <= 6.8",
54
55
  "styled-components": "^5.3.3"
55
56
  },
56
- "gitHead": "be94b7e7ec28b566a3279e24248e610d87d8c0a5"
57
+ "gitHead": "fe3379f50afdce6d8c61a2222ebbf03324107c95"
57
58
  }