@panneau/modal-confirm 4.0.38 → 4.0.40-alpha.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/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ interface ConfirmModalProps {
5
5
  id: string | number;
6
6
  title?: ReactNode | null;
7
7
  onConfirm?: (() => void) | null;
8
- onClose?: (() => void) | null;
8
+ onClosed?: (() => void) | null;
9
9
  confirmButton?: {
10
10
  label?: string;
11
11
  } | null;
@@ -15,6 +15,6 @@ interface ConfirmModalProps {
15
15
  className?: string | null;
16
16
  children?: ReactNode | null;
17
17
  }
18
- declare function ConfirmModal({ id, title, onConfirm, onClose, confirmButton, cancelButton, className, children, }: ConfirmModalProps): react_jsx_runtime.JSX.Element;
18
+ declare function ConfirmModal({ id, title, onConfirm, onClosed, confirmButton, cancelButton, className, children, }: ConfirmModalProps): react_jsx_runtime.JSX.Element;
19
19
 
20
20
  export { ConfirmModal as default };
package/dist/index.js CHANGED
@@ -1,57 +1,163 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useState } from 'react';
2
3
  import { FormattedMessage } from 'react-intl';
3
4
  import Dialog from '@panneau/modal-dialog';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
 
6
- function ConfirmModal(_ref) {
7
- var id = _ref.id,
8
- _ref$title = _ref.title,
9
- title = _ref$title === void 0 ? null : _ref$title,
10
- _ref$onConfirm = _ref.onConfirm,
11
- onConfirm = _ref$onConfirm === void 0 ? null : _ref$onConfirm,
12
- _ref$onClose = _ref.onClose,
13
- onClose = _ref$onClose === void 0 ? null : _ref$onClose,
14
- _ref$confirmButton = _ref.confirmButton,
15
- confirmButton = _ref$confirmButton === void 0 ? null : _ref$confirmButton,
16
- _ref$cancelButton = _ref.cancelButton,
17
- cancelButton = _ref$cancelButton === void 0 ? null : _ref$cancelButton,
18
- _ref$className = _ref.className,
19
- className = _ref$className === void 0 ? null : _ref$className,
20
- _ref$children = _ref.children,
21
- children = _ref$children === void 0 ? null : _ref$children;
22
- return /*#__PURE__*/jsx(Dialog, {
23
- id: id,
24
- title: title,
25
- size: "lg",
26
- onClose: onClose,
27
- className: className,
28
- buttons: [_objectSpread({
29
- id: 'no',
30
- name: 'no',
31
- label: /*#__PURE__*/jsx(FormattedMessage, {
32
- id: "yhU8J6",
33
- defaultMessage: [{
34
- "type": 0,
35
- "value": "No"
36
- }]
37
- }),
38
- theme: 'secondary',
39
- onClick: onClose
40
- }, cancelButton), _objectSpread({
41
- id: 'yes',
42
- name: 'yes',
43
- label: /*#__PURE__*/jsx(FormattedMessage, {
44
- id: "3ebjtX",
45
- defaultMessage: [{
46
- "type": 0,
47
- "value": "Yes"
48
- }]
49
- }),
50
- theme: 'primary',
51
- onClick: onConfirm
52
- }, confirmButton)],
53
- children: children
54
- });
7
+ function ConfirmModal(t0) {
8
+ const $ = c(24);
9
+ const {
10
+ id,
11
+ title: t1,
12
+ onConfirm: t2,
13
+ onClosed: t3,
14
+ confirmButton: t4,
15
+ cancelButton: t5,
16
+ className: t6,
17
+ children: t7
18
+ } = t0;
19
+ const title = t1 === undefined ? null : t1;
20
+ const onConfirm = t2 === undefined ? null : t2;
21
+ const onClosed = t3 === undefined ? null : t3;
22
+ const confirmButton = t4 === undefined ? null : t4;
23
+ const cancelButton = t5 === undefined ? null : t5;
24
+ const className = t6 === undefined ? null : t6;
25
+ const children = t7 === undefined ? null : t7;
26
+ const [opened, setOpened] = useState(true);
27
+ const [confirmed, setConfirmed] = useState(false);
28
+ let t8;
29
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
30
+ t8 = () => {
31
+ setOpened(false);
32
+ };
33
+ $[0] = t8;
34
+ } else {
35
+ t8 = $[0];
36
+ }
37
+ const requestClose = t8;
38
+ let t9;
39
+ if ($[1] !== confirmed || $[2] !== onClosed || $[3] !== onConfirm) {
40
+ t9 = () => {
41
+ if (confirmed && onConfirm !== null) {
42
+ onConfirm();
43
+ } else {
44
+ if (!confirmed && onClosed !== null) {
45
+ onClosed();
46
+ }
47
+ }
48
+ };
49
+ $[1] = confirmed;
50
+ $[2] = onClosed;
51
+ $[3] = onConfirm;
52
+ $[4] = t9;
53
+ } else {
54
+ t9 = $[4];
55
+ }
56
+ const onModalClosed = t9;
57
+ let t10;
58
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
59
+ t10 = () => {
60
+ setConfirmed(false);
61
+ setOpened(false);
62
+ };
63
+ $[5] = t10;
64
+ } else {
65
+ t10 = $[5];
66
+ }
67
+ const onClickCancel = t10;
68
+ let t11;
69
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
70
+ t11 = () => {
71
+ setConfirmed(true);
72
+ setOpened(false);
73
+ };
74
+ $[6] = t11;
75
+ } else {
76
+ t11 = $[6];
77
+ }
78
+ const onClickConfirm = t11;
79
+ let t12;
80
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
81
+ t12 = /*#__PURE__*/jsx(FormattedMessage, {
82
+ id: "yhU8J6"
83
+ });
84
+ $[7] = t12;
85
+ } else {
86
+ t12 = $[7];
87
+ }
88
+ let t13;
89
+ if ($[8] !== cancelButton) {
90
+ t13 = {
91
+ id: "no",
92
+ name: "no",
93
+ label: t12,
94
+ theme: "secondary",
95
+ onClick: onClickCancel,
96
+ ...cancelButton
97
+ };
98
+ $[8] = cancelButton;
99
+ $[9] = t13;
100
+ } else {
101
+ t13 = $[9];
102
+ }
103
+ let t14;
104
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
105
+ t14 = /*#__PURE__*/jsx(FormattedMessage, {
106
+ id: "3ebjtX"
107
+ });
108
+ $[10] = t14;
109
+ } else {
110
+ t14 = $[10];
111
+ }
112
+ let t15;
113
+ if ($[11] !== confirmButton) {
114
+ t15 = {
115
+ id: "yes",
116
+ name: "yes",
117
+ label: t14,
118
+ theme: "primary",
119
+ onClick: onClickConfirm,
120
+ ...confirmButton
121
+ };
122
+ $[11] = confirmButton;
123
+ $[12] = t15;
124
+ } else {
125
+ t15 = $[12];
126
+ }
127
+ let t16;
128
+ if ($[13] !== t13 || $[14] !== t15) {
129
+ t16 = [t13, t15];
130
+ $[13] = t13;
131
+ $[14] = t15;
132
+ $[15] = t16;
133
+ } else {
134
+ t16 = $[15];
135
+ }
136
+ let t17;
137
+ if ($[16] !== children || $[17] !== className || $[18] !== id || $[19] !== onModalClosed || $[20] !== opened || $[21] !== t16 || $[22] !== title) {
138
+ t17 = /*#__PURE__*/jsx(Dialog, {
139
+ id: id,
140
+ title: title,
141
+ size: "lg",
142
+ visible: opened,
143
+ requestClose: requestClose,
144
+ onClosed: onModalClosed,
145
+ className: className,
146
+ buttons: t16,
147
+ children: children
148
+ });
149
+ $[16] = children;
150
+ $[17] = className;
151
+ $[18] = id;
152
+ $[19] = onModalClosed;
153
+ $[20] = opened;
154
+ $[21] = t16;
155
+ $[22] = title;
156
+ $[23] = t17;
157
+ } else {
158
+ t17 = $[23];
159
+ }
160
+ return t17;
55
161
  }
56
162
 
57
163
  export { ConfirmModal as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-confirm",
3
- "version": "4.0.38",
3
+ "version": "4.0.40-alpha.1",
4
4
  "description": "Confirm modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,10 +52,10 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.28.6",
55
- "@panneau/core": "^4.0.38",
56
- "@panneau/intl": "^4.0.38",
57
- "@panneau/modal-dialog": "^4.0.38",
58
- "@panneau/themes": "^4.0.38",
55
+ "@panneau/core": "^4.0.40-alpha.1",
56
+ "@panneau/intl": "^4.0.40-alpha.1",
57
+ "@panneau/modal-dialog": "^4.0.40-alpha.1",
58
+ "@panneau/themes": "^4.0.40-alpha.1",
59
59
  "classnames": "^2.5.1",
60
60
  "lodash": "^4.17.21",
61
61
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "fa4b9c4ec7fe5c0e360dda5a40f8b5d8c7ada651"
66
+ "gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
67
67
  }