@panneau/form-resource 3.0.286 → 3.0.289

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 +27 -11
  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: [{
@@ -127,7 +132,7 @@ DeleteForm.propTypes = propTypes$2;
127
132
  DeleteForm.defaultProps = defaultProps$2;
128
133
  var DeleteForm$1 = DeleteForm;
129
134
 
130
- var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "className"];
135
+ var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
131
136
  var propTypes$1 = {
132
137
  resource: PropTypes.resource.isRequired,
133
138
  action: PropTypes$1.string,
@@ -140,6 +145,7 @@ var propTypes$1 = {
140
145
  status: PropTypes.formStatus,
141
146
  generalError: PropTypes$1.string,
142
147
  errors: PropTypes$1.objectOf(PropTypes$1.arrayOf(PropTypes$1.string)),
148
+ loading: PropTypes$1.bool,
143
149
  className: PropTypes$1.string
144
150
  };
145
151
  var defaultProps$1 = {
@@ -150,6 +156,7 @@ var defaultProps$1 = {
150
156
  onSubmit: null,
151
157
  generalError: null,
152
158
  errors: null,
159
+ loading: false,
153
160
  className: null
154
161
  };
155
162
  var DuplicateForm = function DuplicateForm(_ref) {
@@ -161,6 +168,7 @@ var DuplicateForm = function DuplicateForm(_ref) {
161
168
  onSubmit = _ref.onSubmit;
162
169
  _ref.errors;
163
170
  var generalError = _ref.generalError,
171
+ loading = _ref.loading,
164
172
  className = _ref.className,
165
173
  props = _objectWithoutProperties(_ref, _excluded$1);
166
174
  var _ref2 = value || {},
@@ -176,7 +184,8 @@ var DuplicateForm = function DuplicateForm(_ref) {
176
184
  action: action,
177
185
  onSubmit: onSubmit,
178
186
  withoutActions: true,
179
- withoutErrors: true
187
+ withoutErrors: true,
188
+ disabled: loading
180
189
  }, props), /*#__PURE__*/React.createElement("div", {
181
190
  className: classNames(['card', _defineProperty({}, className, className !== null)])
182
191
  }, /*#__PURE__*/React.createElement("div", {
@@ -224,7 +233,8 @@ var DuplicateForm = function DuplicateForm(_ref) {
224
233
  })) : null, /*#__PURE__*/React.createElement(Button, {
225
234
  type: "submit",
226
235
  className: "ms-auto",
227
- theme: "warning"
236
+ theme: "warning",
237
+ disabled: loading
228
238
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
229
239
  id: "HzCxmr",
230
240
  defaultMessage: [{
@@ -316,13 +326,18 @@ var ResourceForm = function ResourceForm(_ref) {
316
326
  // Form routes
317
327
  var resourceRoute = useResourceUrlGenerator(resource);
318
328
  var _useResourceStore = useResourceStore(resource),
319
- store = _useResourceStore.store;
329
+ store = _useResourceStore.store,
330
+ storing = _useResourceStore.loading;
320
331
  var _useResourceUpdate = useResourceUpdate(resource, item !== null ? itemId : null),
321
- update = _useResourceUpdate.update;
332
+ update = _useResourceUpdate.update,
333
+ updating = _useResourceUpdate.loading;
322
334
  var _useResourceDestroy = useResourceDestroy(resource, item !== null ? itemId : null),
323
- destroy = _useResourceDestroy.destroy;
335
+ destroy = _useResourceDestroy.destroy,
336
+ destroying = _useResourceDestroy.loading;
324
337
  var _useResourceClone = useResourceClone(resource, item !== null ? itemId : null),
325
- clone = _useResourceClone.clone;
338
+ clone = _useResourceClone.clone,
339
+ cloning = _useResourceClone.loading;
340
+ var loading = storing || updating || destroying || cloning;
326
341
 
327
342
  // Post actions
328
343
  var postForm = useCallback(function (action, data) {
@@ -411,7 +426,8 @@ var ResourceForm = function ResourceForm(_ref) {
411
426
  onSubmit: onSubmit,
412
427
  isCreate: isCreate,
413
428
  value: value,
414
- onChange: setValue
429
+ onChange: setValue,
430
+ loading: loading
415
431
  })));
416
432
  };
417
433
  ResourceForm.propTypes = propTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-resource",
3
- "version": "3.0.286",
3
+ "version": "3.0.289",
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.286",
53
- "@panneau/data": "^3.0.286",
54
- "@panneau/element-button": "^3.0.286",
55
- "@panneau/element-form": "^3.0.286",
56
- "@panneau/field-fields": "^3.0.286",
57
- "@panneau/intl": "^3.0.286",
58
- "@panneau/themes": "^3.0.286",
52
+ "@panneau/core": "^3.0.289",
53
+ "@panneau/data": "^3.0.289",
54
+ "@panneau/element-button": "^3.0.289",
55
+ "@panneau/element-form": "^3.0.289",
56
+ "@panneau/field-fields": "^3.0.289",
57
+ "@panneau/intl": "^3.0.289",
58
+ "@panneau/themes": "^3.0.289",
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": "9ed649fd8f438f86ca833411ee0b81bbf0439966"
67
+ "gitHead": "edc1e168d65812a581fdc4315bf9b0832fb1b888"
68
68
  }