@panneau/modal-form 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
@@ -9,15 +9,14 @@ interface ModalFormProps {
9
9
  fields?: Field[] | null;
10
10
  action?: string | null;
11
11
  type?: string;
12
- item?: {
13
- id?: string;
14
- } | null;
15
12
  onComplete?: ((value: unknown) => void) | null;
16
- onClose?: (() => void) | null;
13
+ onCancel?: (() => void) | null;
14
+ onClosed?: (() => void) | null;
17
15
  submitButtonLabel?: ReactNode | null;
16
+ withoutCloseOnComplete?: boolean;
18
17
  className?: string | null;
19
18
  children?: ReactNode | null;
20
19
  }
21
- declare function ModalForm({ id, title, name, fields, action, type, item, onComplete, onClose, submitButtonLabel, className, children, ...props }: ModalFormProps): react_jsx_runtime.JSX.Element;
20
+ declare function ModalForm({ id, title, name, fields, action, type, onComplete, onCancel, onClosed, submitButtonLabel, withoutCloseOnComplete, className, children, ...props }: ModalFormProps): react_jsx_runtime.JSX.Element;
22
21
 
23
22
  export { ModalForm as default };
package/dist/index.js CHANGED
@@ -1,71 +1,191 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useState } from 'react';
3
3
  import { FormattedMessage } from 'react-intl';
4
4
  import Form from '@panneau/form';
5
5
  import Dialog from '@panneau/modal-dialog';
6
- import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
7
 
8
- var _excluded = ["id", "title", "name", "fields", "action", "type", "item", "onComplete", "onClose", "submitButtonLabel", "className", "children"];
9
- function ModalForm(_ref) {
10
- var id = _ref.id,
11
- _ref$title = _ref.title,
12
- title = _ref$title === void 0 ? null : _ref$title,
13
- _ref$name = _ref.name,
14
- name = _ref$name === void 0 ? null : _ref$name,
15
- _ref$fields = _ref.fields,
16
- fields = _ref$fields === void 0 ? null : _ref$fields,
17
- _ref$action = _ref.action,
18
- action = _ref$action === void 0 ? null : _ref$action,
19
- _ref$type = _ref.type,
20
- type = _ref$type === void 0 ? 'normal' : _ref$type,
21
- _ref$item = _ref.item,
22
- item = _ref$item === void 0 ? null : _ref$item,
23
- _ref$onComplete = _ref.onComplete,
24
- onComplete = _ref$onComplete === void 0 ? null : _ref$onComplete,
25
- _ref$onClose = _ref.onClose,
26
- onClose = _ref$onClose === void 0 ? null : _ref$onClose,
27
- _ref$submitButtonLabe = _ref.submitButtonLabel,
28
- submitButtonLabel = _ref$submitButtonLabe === void 0 ? null : _ref$submitButtonLabe,
29
- _ref$className = _ref.className,
30
- className = _ref$className === void 0 ? null : _ref$className,
31
- _ref$children = _ref.children,
32
- children = _ref$children === void 0 ? null : _ref$children,
33
- props = _objectWithoutProperties(_ref, _excluded);
34
- return /*#__PURE__*/jsxs(Dialog, {
35
- id: id,
36
- title: title || (name !== null ? /*#__PURE__*/jsx(FormattedMessage, {
8
+ function ModalForm(t0) {
9
+ const $ = c(40);
10
+ let id;
11
+ let props;
12
+ let t1;
13
+ let t10;
14
+ let t11;
15
+ let t12;
16
+ let t2;
17
+ let t3;
18
+ let t4;
19
+ let t5;
20
+ let t6;
21
+ let t7;
22
+ let t8;
23
+ let t9;
24
+ if ($[0] !== t0) {
25
+ ({
26
+ id,
27
+ title: t1,
28
+ name: t2,
29
+ fields: t3,
30
+ action: t4,
31
+ type: t5,
32
+ onComplete: t6,
33
+ onCancel: t7,
34
+ onClosed: t8,
35
+ submitButtonLabel: t9,
36
+ withoutCloseOnComplete: t10,
37
+ className: t11,
38
+ children: t12,
39
+ ...props
40
+ } = t0);
41
+ $[0] = t0;
42
+ $[1] = id;
43
+ $[2] = props;
44
+ $[3] = t1;
45
+ $[4] = t10;
46
+ $[5] = t11;
47
+ $[6] = t12;
48
+ $[7] = t2;
49
+ $[8] = t3;
50
+ $[9] = t4;
51
+ $[10] = t5;
52
+ $[11] = t6;
53
+ $[12] = t7;
54
+ $[13] = t8;
55
+ $[14] = t9;
56
+ } else {
57
+ id = $[1];
58
+ props = $[2];
59
+ t1 = $[3];
60
+ t10 = $[4];
61
+ t11 = $[5];
62
+ t12 = $[6];
63
+ t2 = $[7];
64
+ t3 = $[8];
65
+ t4 = $[9];
66
+ t5 = $[10];
67
+ t6 = $[11];
68
+ t7 = $[12];
69
+ t8 = $[13];
70
+ t9 = $[14];
71
+ }
72
+ const title = t1 === undefined ? null : t1;
73
+ const name = t2 === undefined ? null : t2;
74
+ const fields = t3 === undefined ? null : t3;
75
+ const action = t4 === undefined ? null : t4;
76
+ const type = t5 === undefined ? "normal" : t5;
77
+ const onComplete = t6 === undefined ? null : t6;
78
+ const onCancel = t7 === undefined ? null : t7;
79
+ const onClosed = t8 === undefined ? null : t8;
80
+ const submitButtonLabel = t9 === undefined ? null : t9;
81
+ const withoutCloseOnComplete = t10 === undefined ? false : t10;
82
+ const className = t11 === undefined ? null : t11;
83
+ const children = t12 === undefined ? null : t12;
84
+ const [opened, setOpened] = useState(true);
85
+ let t13;
86
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
87
+ t13 = () => {
88
+ setOpened(false);
89
+ };
90
+ $[15] = t13;
91
+ } else {
92
+ t13 = $[15];
93
+ }
94
+ const requestClose = t13;
95
+ let t14;
96
+ if ($[16] !== onCancel) {
97
+ t14 = () => {
98
+ setOpened(false);
99
+ if (onCancel !== null) {
100
+ onCancel();
101
+ }
102
+ };
103
+ $[16] = onCancel;
104
+ $[17] = t14;
105
+ } else {
106
+ t14 = $[17];
107
+ }
108
+ const onFormCancel = t14;
109
+ let t15;
110
+ if ($[18] !== onComplete || $[19] !== withoutCloseOnComplete) {
111
+ t15 = value => {
112
+ if (!withoutCloseOnComplete) {
113
+ setOpened(false);
114
+ }
115
+ if (onComplete !== null) {
116
+ onComplete(value);
117
+ }
118
+ };
119
+ $[18] = onComplete;
120
+ $[19] = withoutCloseOnComplete;
121
+ $[20] = t15;
122
+ } else {
123
+ t15 = $[20];
124
+ }
125
+ const onFormComplete = t15;
126
+ let t16;
127
+ if ($[21] !== name || $[22] !== title) {
128
+ t16 = title || (name !== null ? /*#__PURE__*/jsx(FormattedMessage, {
37
129
  id: "smqUAV",
38
- defaultMessage: [{
39
- "type": 0,
40
- "value": "Edit "
41
- }, {
42
- "type": 1,
43
- "value": "name"
44
- }],
45
130
  values: {
46
- name: name
131
+ name
47
132
  }
48
133
  }) : /*#__PURE__*/jsx(FormattedMessage, {
49
- id: "T/NPHK",
50
- defaultMessage: [{
51
- "type": 0,
52
- "value": "Edit"
53
- }]
54
- })),
55
- size: "lg",
56
- onClose: onClose,
57
- className: className,
58
- children: [children, /*#__PURE__*/jsx(Form, _objectSpread(_objectSpread({}, props), {}, {
134
+ id: "T/NPHK"
135
+ }));
136
+ $[21] = name;
137
+ $[22] = title;
138
+ $[23] = t16;
139
+ } else {
140
+ t16 = $[23];
141
+ }
142
+ let t17;
143
+ if ($[24] !== action || $[25] !== fields || $[26] !== onFormCancel || $[27] !== onFormComplete || $[28] !== props || $[29] !== submitButtonLabel || $[30] !== type) {
144
+ t17 = /*#__PURE__*/jsx(Form, {
145
+ ...props,
59
146
  fields: fields,
60
147
  action: action,
61
148
  type: type,
62
- item: item,
63
149
  buttonSize: "md",
64
- onComplete: onComplete,
65
- onCancel: onClose,
150
+ onComplete: onFormComplete,
151
+ onCancel: onFormCancel,
66
152
  submitButtonLabel: submitButtonLabel
67
- }))]
68
- });
153
+ });
154
+ $[24] = action;
155
+ $[25] = fields;
156
+ $[26] = onFormCancel;
157
+ $[27] = onFormComplete;
158
+ $[28] = props;
159
+ $[29] = submitButtonLabel;
160
+ $[30] = type;
161
+ $[31] = t17;
162
+ } else {
163
+ t17 = $[31];
164
+ }
165
+ let t18;
166
+ if ($[32] !== children || $[33] !== className || $[34] !== id || $[35] !== onClosed || $[36] !== opened || $[37] !== t16 || $[38] !== t17) {
167
+ t18 = /*#__PURE__*/jsxs(Dialog, {
168
+ id: id,
169
+ title: t16,
170
+ size: "lg",
171
+ visible: opened,
172
+ requestClose: requestClose,
173
+ onClosed: onClosed,
174
+ className: className,
175
+ children: [children, t17]
176
+ });
177
+ $[32] = children;
178
+ $[33] = className;
179
+ $[34] = id;
180
+ $[35] = onClosed;
181
+ $[36] = opened;
182
+ $[37] = t16;
183
+ $[38] = t17;
184
+ $[39] = t18;
185
+ } else {
186
+ t18 = $[39];
187
+ }
188
+ return t18;
69
189
  }
70
190
 
71
191
  export { ModalForm as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-form",
3
- "version": "4.0.38",
3
+ "version": "4.0.40-alpha.1",
4
4
  "description": "Resource form modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,11 +52,11 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.28.6",
55
- "@panneau/core": "^4.0.38",
56
- "@panneau/form": "^4.0.38",
57
- "@panneau/intl": "^4.0.38",
58
- "@panneau/modal-dialog": "^4.0.38",
59
- "@panneau/themes": "^4.0.38",
55
+ "@panneau/core": "^4.0.40-alpha.1",
56
+ "@panneau/form": "^4.0.40-alpha.1",
57
+ "@panneau/intl": "^4.0.40-alpha.1",
58
+ "@panneau/modal-dialog": "^4.0.40-alpha.1",
59
+ "@panneau/themes": "^4.0.40-alpha.1",
60
60
  "classnames": "^2.5.1",
61
61
  "lodash": "^4.17.21",
62
62
  "react-intl": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^10.0.0"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "fa4b9c4ec7fe5c0e360dda5a40f8b5d8c7ada651"
67
+ "gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
68
68
  }