@panneau/modal-form 4.0.50 → 4.0.52

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,19 +1,13 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode, ForwardedRef } from 'react';
2
+ import { ForwardedRef } from 'react';
3
3
  import { FormProps } from '@panneau/form';
4
- import { DialogProps } from '@panneau/modal-dialog';
4
+ import { DialogModalProps } from '@panneau/modal-dialog';
5
5
 
6
- interface FormModalProps extends Omit<FormProps, 'id' | 'title'>, Pick<DialogProps, 'id' | 'title' | 'size'> {
7
- name?: string | null;
8
- type?: string;
9
- onCancel?: (() => void) | null;
10
- onClosed?: (() => void) | null;
6
+ interface FormModalProps extends Omit<FormProps, 'id' | 'title'>, DialogModalProps {
11
7
  withoutCloseOnComplete?: boolean;
12
- className?: string | null;
13
- children?: ReactNode | null;
14
8
  formRef?: ForwardedRef<HTMLFormElement> | null;
15
9
  }
16
- declare function FormModal({ id, title, name, fields, type, size, onComplete, onCancel, onClosed, withoutCloseOnComplete, className, children, formRef: customFormRef, submitButtonLabel, cancelButtonLabel, withCancelButton, withoutSubmitButton, ...props }: FormModalProps): react_jsx_runtime.JSX.Element;
10
+ declare function FormModal({ id, title, fields, size, visible, requestClose: customRequestClose, onComplete, onCancel, onClosed, withoutCloseOnComplete, className, children, formRef: customFormRef, submitButtonLabel, cancelButtonLabel, withCancelButton, withoutSubmitButton, ...props }: FormModalProps): react_jsx_runtime.JSX.Element;
17
11
 
18
12
  export { FormModal as default };
19
13
  export type { FormModalProps };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import Dialog from '@panneau/modal-dialog';
7
7
  import { jsx, jsxs } from 'react/jsx-runtime';
8
8
 
9
9
  function FormModal(t0) {
10
- const $ = c(51);
10
+ const $ = c(53);
11
11
  let id;
12
12
  let props;
13
13
  let t1;
@@ -30,10 +30,10 @@ function FormModal(t0) {
30
30
  ({
31
31
  id,
32
32
  title: t1,
33
- name: t2,
34
- fields: t3,
35
- type: t4,
36
- size: t5,
33
+ fields: t2,
34
+ size: t3,
35
+ visible: t4,
36
+ requestClose: t5,
37
37
  onComplete: t6,
38
38
  onCancel: t7,
39
39
  onClosed: t8,
@@ -87,10 +87,10 @@ function FormModal(t0) {
87
87
  t9 = $[18];
88
88
  }
89
89
  const title = t1 === undefined ? null : t1;
90
- const name = t2 === undefined ? null : t2;
91
- const fields = t3 === undefined ? null : t3;
92
- const type = t4 === undefined ? "normal" : t4;
93
- const size = t5 === undefined ? "lg" : t5;
90
+ const fields = t2 === undefined ? null : t2;
91
+ const size = t3 === undefined ? "lg" : t3;
92
+ const visible = t4 === undefined ? null : t4;
93
+ const customRequestClose = t5 === undefined ? null : t5;
94
94
  const onComplete = t6 === undefined ? null : t6;
95
95
  const onCancel = t7 === undefined ? null : t7;
96
96
  const onClosed = t8 === undefined ? null : t8;
@@ -105,138 +105,135 @@ function FormModal(t0) {
105
105
  const [opened, setOpened] = useState(true);
106
106
  const formRef = useRef(null);
107
107
  let t17;
108
- if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
109
- t17 = () => {
108
+ if ($[19] !== customRequestClose) {
109
+ t17 = customRequestClose ?? (() => {
110
110
  setOpened(false);
111
- };
112
- $[19] = t17;
111
+ });
112
+ $[19] = customRequestClose;
113
+ $[20] = t17;
113
114
  } else {
114
- t17 = $[19];
115
+ t17 = $[20];
115
116
  }
116
117
  const requestClose = t17;
117
118
  let t18;
118
- if ($[20] !== onCancel) {
119
+ if ($[21] !== onCancel || $[22] !== requestClose) {
119
120
  t18 = () => {
120
- setOpened(false);
121
+ requestClose();
121
122
  if (onCancel !== null) {
122
123
  onCancel();
123
124
  }
124
125
  };
125
- $[20] = onCancel;
126
- $[21] = t18;
126
+ $[21] = onCancel;
127
+ $[22] = requestClose;
128
+ $[23] = t18;
127
129
  } else {
128
- t18 = $[21];
130
+ t18 = $[23];
129
131
  }
130
132
  const onFormCancel = t18;
131
133
  let t19;
132
- if ($[22] !== onComplete || $[23] !== withoutCloseOnComplete) {
134
+ if ($[24] !== onComplete || $[25] !== requestClose || $[26] !== withoutCloseOnComplete) {
133
135
  t19 = value => {
134
136
  if (!withoutCloseOnComplete) {
135
- setOpened(false);
137
+ requestClose();
136
138
  }
137
139
  if (onComplete !== null) {
138
140
  onComplete(value);
139
141
  }
140
142
  };
141
- $[22] = onComplete;
142
- $[23] = withoutCloseOnComplete;
143
- $[24] = t19;
143
+ $[24] = onComplete;
144
+ $[25] = requestClose;
145
+ $[26] = withoutCloseOnComplete;
146
+ $[27] = t19;
144
147
  } else {
145
- t19 = $[24];
148
+ t19 = $[27];
146
149
  }
147
150
  const onFormComplete = t19;
148
151
  let t20;
149
- if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
152
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
150
153
  t20 = () => {
151
154
  if (formRef.current !== null) {
152
- formRef.current.submit();
155
+ formRef.current.requestSubmit();
153
156
  }
154
157
  };
155
- $[25] = t20;
158
+ $[28] = t20;
156
159
  } else {
157
- t20 = $[25];
160
+ t20 = $[28];
158
161
  }
159
162
  const onClickSubmit = t20;
160
163
  let t21;
161
- if ($[26] !== name || $[27] !== title) {
162
- t21 = title || (name !== null ? /*#__PURE__*/jsx(FormattedMessage, {
163
- id: "smqUAV",
164
- values: {
165
- name
166
- }
167
- }) : /*#__PURE__*/jsx(FormattedMessage, {
164
+ if ($[29] !== title) {
165
+ t21 = title || /*#__PURE__*/jsx(FormattedMessage, {
168
166
  id: "T/NPHK"
169
- }));
170
- $[26] = name;
171
- $[27] = title;
172
- $[28] = t21;
167
+ });
168
+ $[29] = title;
169
+ $[30] = t21;
173
170
  } else {
174
- t21 = $[28];
171
+ t21 = $[30];
175
172
  }
176
- const t22 = !withoutSubmitButton;
177
- let t23;
178
- if ($[29] !== customFormRef) {
179
- t23 = mergeRefs(formRef, customFormRef);
180
- $[29] = customFormRef;
181
- $[30] = t23;
173
+ const t22 = visible ?? opened;
174
+ const t23 = !withoutSubmitButton;
175
+ let t24;
176
+ if ($[31] !== customFormRef) {
177
+ t24 = mergeRefs(formRef, customFormRef);
178
+ $[31] = customFormRef;
179
+ $[32] = t24;
182
180
  } else {
183
- t23 = $[30];
181
+ t24 = $[32];
184
182
  }
185
- let t24;
186
- if ($[31] !== fields || $[32] !== onFormCancel || $[33] !== onFormComplete || $[34] !== props || $[35] !== t23 || $[36] !== type) {
187
- t24 = /*#__PURE__*/jsx(Form, {
183
+ let t25;
184
+ if ($[33] !== fields || $[34] !== onFormCancel || $[35] !== onFormComplete || $[36] !== props || $[37] !== t24) {
185
+ t25 = /*#__PURE__*/jsx(Form, {
188
186
  withoutActions: true,
189
187
  ...props,
190
- ref: t23,
188
+ ref: t24,
191
189
  fields: fields,
192
- type: type,
193
190
  onComplete: onFormComplete,
194
191
  onCancel: onFormCancel
195
192
  });
196
- $[31] = fields;
197
- $[32] = onFormCancel;
198
- $[33] = onFormComplete;
199
- $[34] = props;
200
- $[35] = t23;
201
- $[36] = type;
193
+ $[33] = fields;
194
+ $[34] = onFormCancel;
195
+ $[35] = onFormComplete;
196
+ $[36] = props;
202
197
  $[37] = t24;
198
+ $[38] = t25;
203
199
  } else {
204
- t24 = $[37];
200
+ t25 = $[38];
205
201
  }
206
- let t25;
207
- if ($[38] !== cancelButtonLabel || $[39] !== children || $[40] !== className || $[41] !== id || $[42] !== onClosed || $[43] !== opened || $[44] !== size || $[45] !== submitButtonLabel || $[46] !== t21 || $[47] !== t22 || $[48] !== t24 || $[49] !== withCancelButton) {
208
- t25 = /*#__PURE__*/jsxs(Dialog, {
202
+ let t26;
203
+ if ($[39] !== cancelButtonLabel || $[40] !== children || $[41] !== className || $[42] !== id || $[43] !== onClosed || $[44] !== requestClose || $[45] !== size || $[46] !== submitButtonLabel || $[47] !== t21 || $[48] !== t22 || $[49] !== t23 || $[50] !== t25 || $[51] !== withCancelButton) {
204
+ t26 = /*#__PURE__*/jsxs(Dialog, {
209
205
  id: id,
210
206
  title: t21,
211
207
  size: size,
212
- visible: opened,
208
+ visible: t22,
213
209
  withCancelButton: withCancelButton,
214
- withSubmitButton: t22,
210
+ withSubmitButton: t23,
215
211
  requestClose: requestClose,
216
212
  onClosed: onClosed,
217
213
  onClickSubmit: onClickSubmit,
218
214
  className: className,
219
215
  submitButtonLabel: submitButtonLabel,
220
216
  cancelButtonLabel: cancelButtonLabel,
221
- children: [children, t24]
217
+ children: [children, t25]
222
218
  });
223
- $[38] = cancelButtonLabel;
224
- $[39] = children;
225
- $[40] = className;
226
- $[41] = id;
227
- $[42] = onClosed;
228
- $[43] = opened;
229
- $[44] = size;
230
- $[45] = submitButtonLabel;
231
- $[46] = t21;
232
- $[47] = t22;
233
- $[48] = t24;
234
- $[49] = withCancelButton;
219
+ $[39] = cancelButtonLabel;
220
+ $[40] = children;
221
+ $[41] = className;
222
+ $[42] = id;
223
+ $[43] = onClosed;
224
+ $[44] = requestClose;
225
+ $[45] = size;
226
+ $[46] = submitButtonLabel;
227
+ $[47] = t21;
228
+ $[48] = t22;
229
+ $[49] = t23;
235
230
  $[50] = t25;
231
+ $[51] = withCancelButton;
232
+ $[52] = t26;
236
233
  } else {
237
- t25 = $[50];
234
+ t26 = $[52];
238
235
  }
239
- return t25;
236
+ return t26;
240
237
  }
241
238
 
242
239
  export { FormModal as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-form",
3
- "version": "4.0.50",
3
+ "version": "4.0.52",
4
4
  "description": "Resource form modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "c5d4004686dae5529035f8eac83571739e24340d"
67
+ "gitHead": "280155c90cf1dfc39e0c36c76ef8bc2fea627041"
68
68
  }