@panneau/modal-dialog 4.0.41 → 4.0.48

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,6 +1,6 @@
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
6
  interface ModalDialogProps extends Omit<ModalProps, 'title'> {
@@ -11,6 +11,13 @@ interface ModalDialogProps extends Omit<ModalProps, 'title'> {
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,9 @@ 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 ModalDialog({ 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 }: ModalDialogProps): react_jsx_runtime.JSX.Element;
23
32
 
24
33
  export { ModalDialog as default };
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';
@@ -13,6 +14,11 @@ function ModalDialog({
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]
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.48",
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.48",
64
+ "@panneau/element-button": "^4.0.48",
65
+ "@panneau/element-buttons": "^4.0.48",
66
+ "@panneau/element-label": "^4.0.48",
67
+ "@panneau/element-modal": "^4.0.48",
68
+ "@panneau/themes": "^4.0.48",
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": "668d90a05a094fe55fcea760df3f9c294c6cbb31"
77
77
  }