@panneau/modal-dialog 4.0.41 → 4.0.50

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/dist/index.d.ts CHANGED
@@ -1,16 +1,23 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { Label, Button } from '@panneau/core';
3
+ import { Label, Button, ButtonSize } from '@panneau/core';
4
4
  import { ModalProps } from '@panneau/element-modal';
5
5
 
6
- interface ModalDialogProps extends Omit<ModalProps, 'title'> {
6
+ interface DialogModalProps extends Omit<ModalProps, 'title'> {
7
7
  id: string;
8
8
  title?: Label | null;
9
- size?: string | null;
9
+ size?: 'lg' | 'sm' | null;
10
10
  header?: ReactNode | null;
11
11
  children?: ReactNode | null;
12
12
  footer?: ReactNode | null;
13
13
  buttons?: Button[] | null;
14
+ buttonsSize?: ButtonSize | null;
15
+ submitButtonLabel?: Label | null;
16
+ cancelButtonLabel?: Label | null;
17
+ cancelButton?: Partial<Button> | null;
18
+ submitButton?: Partial<Button> | null;
19
+ withSubmitButton?: boolean;
20
+ withCancelButton?: boolean;
14
21
  withCloseOutside?: boolean;
15
22
  withoutClose?: boolean;
16
23
  className?: string | null;
@@ -18,7 +25,10 @@ interface ModalDialogProps extends Omit<ModalProps, 'title'> {
18
25
  bodyClassName?: string | null;
19
26
  footerClassName?: string | null;
20
27
  buttonsClassName?: string | null;
28
+ onClickSubmit?: (() => void) | null;
29
+ onClickCancel?: (() => void) | null;
21
30
  }
22
- declare function ModalDialog({ id, title, size, header, children, buttons, footer, requestClose, withoutClose, withCloseOutside, className, headerClassName, bodyClassName, footerClassName, buttonsClassName, ...props }: ModalDialogProps): react_jsx_runtime.JSX.Element;
31
+ declare function DialogModal({ id, title, size, header, children, buttons, buttonsSize, submitButtonLabel, cancelButtonLabel, cancelButton, submitButton, footer, requestClose, withoutClose, withCloseOutside, className, headerClassName, bodyClassName, footerClassName, buttonsClassName, withCancelButton, withSubmitButton, onClickCancel, onClickSubmit, ...props }: DialogModalProps): react_jsx_runtime.JSX.Element;
23
32
 
24
- export { ModalDialog as default };
33
+ export { DialogModal as default };
34
+ export type { DialogModalProps };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import classNames from 'classnames';
2
+ import { FormattedMessage } from 'react-intl';
2
3
  import { isMessage } from '@panneau/core/utils';
3
4
  import Button from '@panneau/element-button';
4
5
  import Buttons from '@panneau/element-buttons';
@@ -6,13 +7,18 @@ import Label from '@panneau/element-label';
6
7
  import Modal from '@panneau/element-modal';
7
8
  import { jsx, jsxs } from 'react/jsx-runtime';
8
9
 
9
- function ModalDialog({
10
+ function DialogModal({
10
11
  id,
11
12
  title = null,
12
13
  size = null,
13
14
  header = null,
14
15
  children = null,
15
16
  buttons = null,
17
+ buttonsSize = null,
18
+ submitButtonLabel = null,
19
+ cancelButtonLabel = null,
20
+ cancelButton = null,
21
+ submitButton = null,
16
22
  footer = null,
17
23
  requestClose = null,
18
24
  withoutClose = false,
@@ -22,9 +28,29 @@ function ModalDialog({
22
28
  bodyClassName = null,
23
29
  footerClassName = null,
24
30
  buttonsClassName = null,
31
+ withCancelButton = false,
32
+ withSubmitButton = false,
33
+ onClickCancel = null,
34
+ onClickSubmit = null,
25
35
  ...props
26
36
  }) {
27
37
  const onCloseButtonOutside = header === null && title === null || withCloseOutside;
38
+ const finalButtons = buttons || [withCancelButton ? {
39
+ label: cancelButtonLabel ?? /*#__PURE__*/jsx(FormattedMessage, {
40
+ id: "PyxZY2"
41
+ }),
42
+ onClick: onClickCancel || requestClose || undefined,
43
+ theme: 'secondary',
44
+ ...cancelButton
45
+ } : null, withSubmitButton ? {
46
+ label: submitButtonLabel ?? /*#__PURE__*/jsx(FormattedMessage, {
47
+ id: "R1HYj0"
48
+ }),
49
+ theme: 'primary',
50
+ onClick: onClickSubmit || undefined,
51
+ ...submitButton
52
+ } : null].filter(button => button !== null);
53
+ const hasButtons = finalButtons !== null && finalButtons.length > 0;
28
54
  return /*#__PURE__*/jsx(Modal, {
29
55
  id: id,
30
56
  requestClose: requestClose,
@@ -59,10 +85,11 @@ function ModalDialog({
59
85
  }), /*#__PURE__*/jsx("div", {
60
86
  className: classNames(['modal-body', bodyClassName]),
61
87
  children: children
62
- }), footer !== null || buttons !== null ? /*#__PURE__*/jsxs("div", {
88
+ }), footer !== null || hasButtons ? /*#__PURE__*/jsxs("div", {
63
89
  className: classNames(['modal-footer', footerClassName]),
64
- children: [footer !== null ? footer : null, buttons !== null ? /*#__PURE__*/jsx(Buttons, {
65
- items: buttons,
90
+ children: [footer !== null ? footer : null, hasButtons ? /*#__PURE__*/jsx(Buttons, {
91
+ items: finalButtons,
92
+ size: buttonsSize,
66
93
  className: buttonsClassName
67
94
  }) : null]
68
95
  }) : null]
@@ -71,4 +98,4 @@ function ModalDialog({
71
98
  });
72
99
  }
73
100
 
74
- export { ModalDialog as default };
101
+ export { DialogModal as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-dialog",
3
- "version": "4.0.41",
3
+ "version": "4.0.50",
4
4
  "description": "Default modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -60,12 +60,12 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@babel/runtime": "^7.28.6",
63
- "@panneau/core": "^4.0.41",
64
- "@panneau/element-button": "^4.0.41",
65
- "@panneau/element-buttons": "^4.0.41",
66
- "@panneau/element-label": "^4.0.41",
67
- "@panneau/element-modal": "^4.0.41",
68
- "@panneau/themes": "^4.0.41",
63
+ "@panneau/core": "^4.0.50",
64
+ "@panneau/element-button": "^4.0.50",
65
+ "@panneau/element-buttons": "^4.0.50",
66
+ "@panneau/element-label": "^4.0.50",
67
+ "@panneau/element-modal": "^4.0.50",
68
+ "@panneau/themes": "^4.0.50",
69
69
  "classnames": "^2.5.1",
70
70
  "lodash": "^4.17.21",
71
71
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "a61617e40bef47e494f069697896191ce578a909"
76
+ "gitHead": "c5d4004686dae5529035f8eac83571739e24340d"
77
77
  }