@panneau/form-resource 3.0.308 → 4.0.0
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/es/index.js +53 -114
- package/package.json +10 -10
package/es/index.js
CHANGED
|
@@ -2,9 +2,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
5
|
import React, { useMemo, useCallback, useState, useEffect } from 'react';
|
|
7
|
-
import { PropTypes as PropTypes$1 } from '@panneau/core';
|
|
8
6
|
import { useLocales, useFormsComponents, FormProvider } from '@panneau/core/contexts';
|
|
9
7
|
import { useResourceUrlGenerator, useForm } from '@panneau/core/hooks';
|
|
10
8
|
import { getComponentFromName } from '@panneau/core/utils';
|
|
@@ -16,43 +14,24 @@ import Form from '@panneau/element-form';
|
|
|
16
14
|
import { useResourceValues } from '@panneau/intl';
|
|
17
15
|
|
|
18
16
|
var _excluded$2 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
|
|
19
|
-
|
|
20
|
-
resource: PropTypes$1.resource.isRequired,
|
|
21
|
-
action: PropTypes.string,
|
|
22
|
-
previous: PropTypes.string,
|
|
23
|
-
fields: PropTypes$1.fields.isRequired,
|
|
24
|
-
value: PropTypes.object,
|
|
25
|
-
// eslint-disable-line react/forbid-prop-types
|
|
26
|
-
onChange: PropTypes.func.isRequired,
|
|
27
|
-
onSubmit: PropTypes.func,
|
|
28
|
-
status: PropTypes$1.formStatus,
|
|
29
|
-
generalError: PropTypes.string,
|
|
30
|
-
errors: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
|
|
31
|
-
loading: PropTypes.bool,
|
|
32
|
-
className: PropTypes.string
|
|
33
|
-
};
|
|
34
|
-
var defaultProps$2 = {
|
|
35
|
-
action: null,
|
|
36
|
-
previous: null,
|
|
37
|
-
status: null,
|
|
38
|
-
value: null,
|
|
39
|
-
onSubmit: null,
|
|
40
|
-
generalError: null,
|
|
41
|
-
errors: null,
|
|
42
|
-
loading: false,
|
|
43
|
-
className: null
|
|
44
|
-
};
|
|
45
|
-
var DeleteForm = function DeleteForm(_ref) {
|
|
17
|
+
function DeleteForm(_ref) {
|
|
46
18
|
var resource = _ref.resource,
|
|
47
|
-
action = _ref.action,
|
|
48
|
-
|
|
19
|
+
_ref$action = _ref.action,
|
|
20
|
+
action = _ref$action === void 0 ? null : _ref$action,
|
|
21
|
+
_ref$previous = _ref.previous,
|
|
22
|
+
previous = _ref$previous === void 0 ? null : _ref$previous;
|
|
49
23
|
_ref.status;
|
|
50
|
-
var value = _ref.value,
|
|
51
|
-
|
|
24
|
+
var _ref$value = _ref.value,
|
|
25
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
26
|
+
_ref$onSubmit = _ref.onSubmit,
|
|
27
|
+
onSubmit = _ref$onSubmit === void 0 ? null : _ref$onSubmit;
|
|
52
28
|
_ref.errors;
|
|
53
|
-
var generalError = _ref.generalError,
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
var _ref$generalError = _ref.generalError,
|
|
30
|
+
generalError = _ref$generalError === void 0 ? null : _ref$generalError,
|
|
31
|
+
_ref$loading = _ref.loading,
|
|
32
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
33
|
+
_ref$className = _ref.className,
|
|
34
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
56
35
|
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
57
36
|
var _ref2 = value || {},
|
|
58
37
|
_ref2$id = _ref2.id,
|
|
@@ -127,48 +106,27 @@ var DeleteForm = function DeleteForm(_ref) {
|
|
|
127
106
|
"value": "Delete"
|
|
128
107
|
}]
|
|
129
108
|
})))));
|
|
130
|
-
}
|
|
131
|
-
DeleteForm.propTypes = propTypes$2;
|
|
132
|
-
DeleteForm.defaultProps = defaultProps$2;
|
|
109
|
+
}
|
|
133
110
|
|
|
134
111
|
var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
|
|
135
|
-
|
|
136
|
-
resource: PropTypes$1.resource.isRequired,
|
|
137
|
-
action: PropTypes.string,
|
|
138
|
-
previous: PropTypes.string,
|
|
139
|
-
fields: PropTypes$1.fields.isRequired,
|
|
140
|
-
value: PropTypes.object,
|
|
141
|
-
// eslint-disable-line react/forbid-prop-types
|
|
142
|
-
onChange: PropTypes.func.isRequired,
|
|
143
|
-
onSubmit: PropTypes.func,
|
|
144
|
-
status: PropTypes$1.formStatus,
|
|
145
|
-
generalError: PropTypes.string,
|
|
146
|
-
errors: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
|
|
147
|
-
loading: PropTypes.bool,
|
|
148
|
-
className: PropTypes.string
|
|
149
|
-
};
|
|
150
|
-
var defaultProps$1 = {
|
|
151
|
-
action: null,
|
|
152
|
-
previous: null,
|
|
153
|
-
status: null,
|
|
154
|
-
value: null,
|
|
155
|
-
onSubmit: null,
|
|
156
|
-
generalError: null,
|
|
157
|
-
errors: null,
|
|
158
|
-
loading: false,
|
|
159
|
-
className: null
|
|
160
|
-
};
|
|
161
|
-
var DuplicateForm = function DuplicateForm(_ref) {
|
|
112
|
+
function DuplicateForm(_ref) {
|
|
162
113
|
var resource = _ref.resource,
|
|
163
|
-
action = _ref.action,
|
|
164
|
-
|
|
114
|
+
_ref$action = _ref.action,
|
|
115
|
+
action = _ref$action === void 0 ? null : _ref$action,
|
|
116
|
+
_ref$previous = _ref.previous,
|
|
117
|
+
previous = _ref$previous === void 0 ? null : _ref$previous;
|
|
165
118
|
_ref.status;
|
|
166
|
-
var value = _ref.value,
|
|
167
|
-
|
|
119
|
+
var _ref$value = _ref.value,
|
|
120
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
121
|
+
_ref$onSubmit = _ref.onSubmit,
|
|
122
|
+
onSubmit = _ref$onSubmit === void 0 ? null : _ref$onSubmit;
|
|
168
123
|
_ref.errors;
|
|
169
|
-
var generalError = _ref.generalError,
|
|
170
|
-
|
|
171
|
-
|
|
124
|
+
var _ref$generalError = _ref.generalError,
|
|
125
|
+
generalError = _ref$generalError === void 0 ? null : _ref$generalError,
|
|
126
|
+
_ref$loading = _ref.loading,
|
|
127
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
128
|
+
_ref$className = _ref.className,
|
|
129
|
+
className = _ref$className === void 0 ? null : _ref$className,
|
|
172
130
|
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
173
131
|
var _ref2 = value || {},
|
|
174
132
|
_ref2$id = _ref2.id,
|
|
@@ -241,46 +199,29 @@ var DuplicateForm = function DuplicateForm(_ref) {
|
|
|
241
199
|
"value": "Duplicate"
|
|
242
200
|
}]
|
|
243
201
|
})))));
|
|
244
|
-
}
|
|
245
|
-
DuplicateForm.propTypes = propTypes$1;
|
|
246
|
-
DuplicateForm.defaultProps = defaultProps$1;
|
|
202
|
+
}
|
|
247
203
|
|
|
248
204
|
var _excluded = ["component", "header", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate", "isModal", "withContainer"];
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
component: PropTypes.string,
|
|
255
|
-
header: PropTypes.node,
|
|
256
|
-
onSuccess: PropTypes.func,
|
|
257
|
-
isDelete: PropTypes.bool,
|
|
258
|
-
isDuplicate: PropTypes.bool,
|
|
259
|
-
isModal: PropTypes.bool,
|
|
260
|
-
withContainer: PropTypes.bool
|
|
261
|
-
};
|
|
262
|
-
var defaultProps = {
|
|
263
|
-
item: null,
|
|
264
|
-
type: null,
|
|
265
|
-
component: null,
|
|
266
|
-
header: null,
|
|
267
|
-
onSuccess: null,
|
|
268
|
-
isDelete: false,
|
|
269
|
-
isDuplicate: false,
|
|
270
|
-
isModal: false,
|
|
271
|
-
withContainer: false
|
|
272
|
-
};
|
|
273
|
-
var ResourceForm = function ResourceForm(_ref) {
|
|
274
|
-
var component = _ref.component,
|
|
275
|
-
header = _ref.header,
|
|
205
|
+
function ResourceForm(_ref) {
|
|
206
|
+
var _ref$component = _ref.component,
|
|
207
|
+
component = _ref$component === void 0 ? null : _ref$component,
|
|
208
|
+
_ref$header = _ref.header,
|
|
209
|
+
header = _ref$header === void 0 ? null : _ref$header,
|
|
276
210
|
resource = _ref.resource,
|
|
277
|
-
onSuccess = _ref.onSuccess,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
211
|
+
_ref$onSuccess = _ref.onSuccess,
|
|
212
|
+
onSuccess = _ref$onSuccess === void 0 ? null : _ref$onSuccess,
|
|
213
|
+
_ref$item = _ref.item,
|
|
214
|
+
item = _ref$item === void 0 ? null : _ref$item,
|
|
215
|
+
_ref$type = _ref.type,
|
|
216
|
+
type = _ref$type === void 0 ? null : _ref$type,
|
|
217
|
+
_ref$isDelete = _ref.isDelete,
|
|
218
|
+
isDelete = _ref$isDelete === void 0 ? false : _ref$isDelete,
|
|
219
|
+
_ref$isDuplicate = _ref.isDuplicate,
|
|
220
|
+
isDuplicate = _ref$isDuplicate === void 0 ? false : _ref$isDuplicate,
|
|
221
|
+
_ref$isModal = _ref.isModal,
|
|
222
|
+
isModal = _ref$isModal === void 0 ? false : _ref$isModal,
|
|
223
|
+
_ref$withContainer = _ref.withContainer,
|
|
224
|
+
withContainer = _ref$withContainer === void 0 ? false : _ref$withContainer,
|
|
284
225
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
285
226
|
var locales = useLocales();
|
|
286
227
|
var FormComponents = useFormsComponents();
|
|
@@ -386,7 +327,7 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
386
327
|
return defaultValue !== null ? _objectSpread(_objectSpread({}, defaultValues), {}, _defineProperty({}, name, defaultValue)) : defaultValues;
|
|
387
328
|
}, type !== null ? {
|
|
388
329
|
type: type
|
|
389
|
-
} :
|
|
330
|
+
} : {});
|
|
390
331
|
}, [item, type, finalFields]);
|
|
391
332
|
var _useState = useState(getInitialValue()),
|
|
392
333
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -464,8 +405,6 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
464
405
|
}, /*#__PURE__*/React.createElement("div", {
|
|
465
406
|
className: "col-12 col-md-8 col-lg-7"
|
|
466
407
|
}, element))) : element);
|
|
467
|
-
}
|
|
468
|
-
ResourceForm.propTypes = propTypes;
|
|
469
|
-
ResourceForm.defaultProps = defaultProps;
|
|
408
|
+
}
|
|
470
409
|
|
|
471
410
|
export { ResourceForm as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/form-resource",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Default resource forms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -49,20 +49,20 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.12.5",
|
|
52
|
-
"@panneau/core": "^
|
|
53
|
-
"@panneau/data": "^
|
|
54
|
-
"@panneau/element-button": "^
|
|
55
|
-
"@panneau/element-form": "^
|
|
56
|
-
"@panneau/field-fields": "^
|
|
57
|
-
"@panneau/intl": "^
|
|
58
|
-
"@panneau/themes": "^
|
|
52
|
+
"@panneau/core": "^4.0.0",
|
|
53
|
+
"@panneau/data": "^4.0.0",
|
|
54
|
+
"@panneau/element-button": "^4.0.0",
|
|
55
|
+
"@panneau/element-form": "^4.0.0",
|
|
56
|
+
"@panneau/field-fields": "^4.0.0",
|
|
57
|
+
"@panneau/intl": "^4.0.0",
|
|
58
|
+
"@panneau/themes": "^4.0.0",
|
|
59
59
|
"classnames": "^2.5.1",
|
|
60
60
|
"lodash-es": "^4.17.21",
|
|
61
61
|
"prop-types": "^15.7.2",
|
|
62
|
-
"react-intl": "^5.15.8
|
|
62
|
+
"react-intl": "^5.15.8 || ^6.0.0 || ^7.0.0"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "2cca874e0388b4a20c39aadb205c0e67d5a946fc"
|
|
68
68
|
}
|