@panneau/form-resource 3.0.288 → 3.0.290

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.
Files changed (2) hide show
  1. package/es/index.js +30 -17
  2. package/package.json +9 -9
package/es/index.js CHANGED
@@ -15,7 +15,7 @@ import Button from '@panneau/element-button';
15
15
  import Form from '@panneau/element-form';
16
16
  import { useResourceValues } from '@panneau/intl';
17
17
 
18
- var _excluded$2 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "className"];
18
+ var _excluded$2 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
19
19
  var propTypes$2 = {
20
20
  resource: PropTypes.resource.isRequired,
21
21
  action: PropTypes$1.string,
@@ -28,6 +28,7 @@ var propTypes$2 = {
28
28
  status: PropTypes.formStatus,
29
29
  generalError: PropTypes$1.string,
30
30
  errors: PropTypes$1.objectOf(PropTypes$1.arrayOf(PropTypes$1.string)),
31
+ loading: PropTypes$1.bool,
31
32
  className: PropTypes$1.string
32
33
  };
33
34
  var defaultProps$2 = {
@@ -38,6 +39,7 @@ var defaultProps$2 = {
38
39
  onSubmit: null,
39
40
  generalError: null,
40
41
  errors: null,
42
+ loading: false,
41
43
  className: null
42
44
  };
43
45
  var DeleteForm = function DeleteForm(_ref) {
@@ -49,6 +51,7 @@ var DeleteForm = function DeleteForm(_ref) {
49
51
  onSubmit = _ref.onSubmit;
50
52
  _ref.errors;
51
53
  var generalError = _ref.generalError,
54
+ loading = _ref.loading,
52
55
  className = _ref.className,
53
56
  props = _objectWithoutProperties(_ref, _excluded$2);
54
57
  var _ref2 = value || {},
@@ -66,7 +69,8 @@ var DeleteForm = function DeleteForm(_ref) {
66
69
  action: action,
67
70
  onSubmit: onSubmit,
68
71
  withoutActions: true,
69
- withoutErrors: true
72
+ withoutErrors: true,
73
+ disabled: loading
70
74
  }, props), /*#__PURE__*/React.createElement("div", {
71
75
  className: classNames(['card', _defineProperty({}, className, className !== null)])
72
76
  }, /*#__PURE__*/React.createElement("div", {
@@ -114,7 +118,8 @@ var DeleteForm = function DeleteForm(_ref) {
114
118
  })) : null, /*#__PURE__*/React.createElement(Button, {
115
119
  type: "submit",
116
120
  className: "ms-auto",
117
- theme: "danger"
121
+ theme: "danger",
122
+ disabled: loading
118
123
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
119
124
  id: "Bhu3B2",
120
125
  defaultMessage: [{
@@ -125,9 +130,8 @@ var DeleteForm = function DeleteForm(_ref) {
125
130
  };
126
131
  DeleteForm.propTypes = propTypes$2;
127
132
  DeleteForm.defaultProps = defaultProps$2;
128
- var DeleteForm$1 = DeleteForm;
129
133
 
130
- var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "className"];
134
+ var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
131
135
  var propTypes$1 = {
132
136
  resource: PropTypes.resource.isRequired,
133
137
  action: PropTypes$1.string,
@@ -140,6 +144,7 @@ var propTypes$1 = {
140
144
  status: PropTypes.formStatus,
141
145
  generalError: PropTypes$1.string,
142
146
  errors: PropTypes$1.objectOf(PropTypes$1.arrayOf(PropTypes$1.string)),
147
+ loading: PropTypes$1.bool,
143
148
  className: PropTypes$1.string
144
149
  };
145
150
  var defaultProps$1 = {
@@ -150,6 +155,7 @@ var defaultProps$1 = {
150
155
  onSubmit: null,
151
156
  generalError: null,
152
157
  errors: null,
158
+ loading: false,
153
159
  className: null
154
160
  };
155
161
  var DuplicateForm = function DuplicateForm(_ref) {
@@ -161,6 +167,7 @@ var DuplicateForm = function DuplicateForm(_ref) {
161
167
  onSubmit = _ref.onSubmit;
162
168
  _ref.errors;
163
169
  var generalError = _ref.generalError,
170
+ loading = _ref.loading,
164
171
  className = _ref.className,
165
172
  props = _objectWithoutProperties(_ref, _excluded$1);
166
173
  var _ref2 = value || {},
@@ -176,7 +183,8 @@ var DuplicateForm = function DuplicateForm(_ref) {
176
183
  action: action,
177
184
  onSubmit: onSubmit,
178
185
  withoutActions: true,
179
- withoutErrors: true
186
+ withoutErrors: true,
187
+ disabled: loading
180
188
  }, props), /*#__PURE__*/React.createElement("div", {
181
189
  className: classNames(['card', _defineProperty({}, className, className !== null)])
182
190
  }, /*#__PURE__*/React.createElement("div", {
@@ -224,7 +232,8 @@ var DuplicateForm = function DuplicateForm(_ref) {
224
232
  })) : null, /*#__PURE__*/React.createElement(Button, {
225
233
  type: "submit",
226
234
  className: "ms-auto",
227
- theme: "warning"
235
+ theme: "warning",
236
+ disabled: loading
228
237
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
229
238
  id: "HzCxmr",
230
239
  defaultMessage: [{
@@ -235,7 +244,6 @@ var DuplicateForm = function DuplicateForm(_ref) {
235
244
  };
236
245
  DuplicateForm.propTypes = propTypes$1;
237
246
  DuplicateForm.defaultProps = defaultProps$1;
238
- var DuplicateForm$1 = DuplicateForm;
239
247
 
240
248
  var _excluded = ["component", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate"];
241
249
  var propTypes = {
@@ -316,13 +324,18 @@ var ResourceForm = function ResourceForm(_ref) {
316
324
  // Form routes
317
325
  var resourceRoute = useResourceUrlGenerator(resource);
318
326
  var _useResourceStore = useResourceStore(resource),
319
- store = _useResourceStore.store;
327
+ store = _useResourceStore.store,
328
+ storing = _useResourceStore.loading;
320
329
  var _useResourceUpdate = useResourceUpdate(resource, item !== null ? itemId : null),
321
- update = _useResourceUpdate.update;
330
+ update = _useResourceUpdate.update,
331
+ updating = _useResourceUpdate.loading;
322
332
  var _useResourceDestroy = useResourceDestroy(resource, item !== null ? itemId : null),
323
- destroy = _useResourceDestroy.destroy;
333
+ destroy = _useResourceDestroy.destroy,
334
+ destroying = _useResourceDestroy.loading;
324
335
  var _useResourceClone = useResourceClone(resource, item !== null ? itemId : null),
325
- clone = _useResourceClone.clone;
336
+ clone = _useResourceClone.clone,
337
+ cloning = _useResourceClone.loading;
338
+ var loading = storing || updating || destroying || cloning;
326
339
 
327
340
  // Post actions
328
341
  var postForm = useCallback(function (action, data) {
@@ -384,10 +397,10 @@ var ResourceForm = function ResourceForm(_ref) {
384
397
  var defaultFormName = isDelete || isDuplicate ? component || formComponent || null : component || formComponent || defaultComponent || 'normal';
385
398
  var finalComponent = component;
386
399
  if (isDelete) {
387
- finalComponent = DeleteForm$1;
400
+ finalComponent = DeleteForm;
388
401
  }
389
402
  if (isDuplicate) {
390
- finalComponent = DuplicateForm$1;
403
+ finalComponent = DuplicateForm;
391
404
  }
392
405
 
393
406
  // Form component
@@ -411,11 +424,11 @@ var ResourceForm = function ResourceForm(_ref) {
411
424
  onSubmit: onSubmit,
412
425
  isCreate: isCreate,
413
426
  value: value,
414
- onChange: setValue
427
+ onChange: setValue,
428
+ loading: loading
415
429
  })));
416
430
  };
417
431
  ResourceForm.propTypes = propTypes;
418
432
  ResourceForm.defaultProps = defaultProps;
419
- var Resource = ResourceForm;
420
433
 
421
- export { Resource as default };
434
+ export { ResourceForm as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-resource",
3
- "version": "3.0.288",
3
+ "version": "3.0.290",
4
4
  "description": "Default resource forms",
5
5
  "keywords": [
6
6
  "javascript"
@@ -49,13 +49,13 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.12.5",
52
- "@panneau/core": "^3.0.288",
53
- "@panneau/data": "^3.0.288",
54
- "@panneau/element-button": "^3.0.288",
55
- "@panneau/element-form": "^3.0.288",
56
- "@panneau/field-fields": "^3.0.288",
57
- "@panneau/intl": "^3.0.288",
58
- "@panneau/themes": "^3.0.288",
52
+ "@panneau/core": "^3.0.290",
53
+ "@panneau/data": "^3.0.290",
54
+ "@panneau/element-button": "^3.0.290",
55
+ "@panneau/element-form": "^3.0.290",
56
+ "@panneau/field-fields": "^3.0.290",
57
+ "@panneau/intl": "^3.0.290",
58
+ "@panneau/themes": "^3.0.290",
59
59
  "classnames": "^2.5.1",
60
60
  "lodash-es": "^4.17.21",
61
61
  "prop-types": "^15.7.2",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "26afc569a56dd1f7322679e571ecbdb5256b3047"
67
+ "gitHead": "682156ae8f9e789cca229bd2aab2c8f3228b5ffe"
68
68
  }