@panneau/form-resource 3.0.120 → 3.0.126
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/lib/index.js +33 -45
- package/package.json +11 -10
package/lib/index.js
CHANGED
|
@@ -19,32 +19,20 @@ var Button = require('@panneau/element-button');
|
|
|
19
19
|
var Form = require('@panneau/element-form');
|
|
20
20
|
var intl = require('@panneau/intl');
|
|
21
21
|
|
|
22
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
|
-
|
|
24
|
-
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
25
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
26
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
27
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
28
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
29
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
30
|
-
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
31
|
-
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
32
|
-
var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form);
|
|
33
|
-
|
|
34
22
|
var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "className"];
|
|
35
23
|
var propTypes$1 = {
|
|
36
24
|
resource: core.PropTypes.resource.isRequired,
|
|
37
|
-
action:
|
|
38
|
-
previous:
|
|
25
|
+
action: PropTypes.string,
|
|
26
|
+
previous: PropTypes.string,
|
|
39
27
|
fields: core.PropTypes.fields.isRequired,
|
|
40
|
-
value:
|
|
28
|
+
value: PropTypes.object,
|
|
41
29
|
// eslint-disable-line react/forbid-prop-types
|
|
42
|
-
onChange:
|
|
43
|
-
onSubmit:
|
|
30
|
+
onChange: PropTypes.func.isRequired,
|
|
31
|
+
onSubmit: PropTypes.func,
|
|
44
32
|
status: core.PropTypes.formStatus,
|
|
45
|
-
generalError:
|
|
46
|
-
errors:
|
|
47
|
-
className:
|
|
33
|
+
generalError: PropTypes.string,
|
|
34
|
+
errors: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
|
|
35
|
+
className: PropTypes.string
|
|
48
36
|
};
|
|
49
37
|
var defaultProps$1 = {
|
|
50
38
|
action: null,
|
|
@@ -66,7 +54,7 @@ var DeleteForm = function DeleteForm(_ref) {
|
|
|
66
54
|
_ref.errors;
|
|
67
55
|
var generalError = _ref.generalError,
|
|
68
56
|
className = _ref.className,
|
|
69
|
-
props =
|
|
57
|
+
props = _objectWithoutProperties(_ref, _excluded$1);
|
|
70
58
|
var _ref2 = value || {},
|
|
71
59
|
_ref2$id = _ref2.id,
|
|
72
60
|
id = _ref2$id === void 0 ? null : _ref2$id;
|
|
@@ -75,19 +63,19 @@ var DeleteForm = function DeleteForm(_ref) {
|
|
|
75
63
|
});
|
|
76
64
|
// const { text, background } = usePanneauColorScheme();
|
|
77
65
|
|
|
78
|
-
return /*#__PURE__*/
|
|
79
|
-
className:
|
|
66
|
+
return /*#__PURE__*/React.createElement(Form, Object.assign({
|
|
67
|
+
className: classNames(['form', _defineProperty({
|
|
80
68
|
'invalid-feedback': generalError !== null
|
|
81
69
|
}, className, className !== null)]),
|
|
82
70
|
action: action,
|
|
83
71
|
onSubmit: onSubmit,
|
|
84
72
|
withoutActions: true,
|
|
85
73
|
withoutErrors: true
|
|
86
|
-
}, props), /*#__PURE__*/
|
|
87
|
-
className:
|
|
88
|
-
}, /*#__PURE__*/
|
|
74
|
+
}, props), /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
className: classNames(['card', _defineProperty({}, className, className !== null)])
|
|
76
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
89
77
|
className: "card-body"
|
|
90
|
-
}, /*#__PURE__*/
|
|
78
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
91
79
|
values: resourceValues,
|
|
92
80
|
id: "yzfiXJ",
|
|
93
81
|
defaultMessage: [{
|
|
@@ -106,32 +94,32 @@ var DeleteForm = function DeleteForm(_ref) {
|
|
|
106
94
|
"type": 0,
|
|
107
95
|
"value": "?"
|
|
108
96
|
}]
|
|
109
|
-
}), generalError ? /*#__PURE__*/
|
|
97
|
+
}), generalError ? /*#__PURE__*/React.createElement("p", {
|
|
110
98
|
className: "text-danger"
|
|
111
|
-
}, /*#__PURE__*/
|
|
99
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
112
100
|
id: "y9zauY",
|
|
113
101
|
defaultMessage: [{
|
|
114
102
|
"type": 0,
|
|
115
103
|
"value": "An error occured and we could not delete this item successfully."
|
|
116
104
|
}]
|
|
117
|
-
})) : null), /*#__PURE__*/
|
|
105
|
+
})) : null), /*#__PURE__*/React.createElement("div", {
|
|
118
106
|
className: "card-body d-flex"
|
|
119
|
-
}, previous !== null ? /*#__PURE__*/
|
|
107
|
+
}, previous !== null ? /*#__PURE__*/React.createElement(Button, {
|
|
120
108
|
href: previous,
|
|
121
109
|
className: "me-2",
|
|
122
110
|
theme: "secondary",
|
|
123
111
|
outline: true
|
|
124
|
-
}, /*#__PURE__*/
|
|
112
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
125
113
|
id: "PyxZY2",
|
|
126
114
|
defaultMessage: [{
|
|
127
115
|
"type": 0,
|
|
128
116
|
"value": "Cancel"
|
|
129
117
|
}]
|
|
130
|
-
})) : null, /*#__PURE__*/
|
|
118
|
+
})) : null, /*#__PURE__*/React.createElement(Button, {
|
|
131
119
|
type: "submit",
|
|
132
120
|
className: "ms-auto",
|
|
133
121
|
theme: "danger"
|
|
134
|
-
}, /*#__PURE__*/
|
|
122
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
|
135
123
|
id: "Bhu3B2",
|
|
136
124
|
defaultMessage: [{
|
|
137
125
|
"type": 0,
|
|
@@ -146,12 +134,12 @@ var DeleteForm$1 = DeleteForm;
|
|
|
146
134
|
var _excluded = ["component", "resource", "onSuccess", "item", "type", "isDelete"];
|
|
147
135
|
var propTypes = {
|
|
148
136
|
resource: core.PropTypes.resource.isRequired,
|
|
149
|
-
item:
|
|
137
|
+
item: PropTypes.object,
|
|
150
138
|
// eslint-disable-line react/forbid-prop-types
|
|
151
|
-
type:
|
|
152
|
-
component:
|
|
153
|
-
onSuccess:
|
|
154
|
-
isDelete:
|
|
139
|
+
type: PropTypes.string,
|
|
140
|
+
component: PropTypes.string,
|
|
141
|
+
onSuccess: PropTypes.func,
|
|
142
|
+
isDelete: PropTypes.bool
|
|
155
143
|
};
|
|
156
144
|
var defaultProps = {
|
|
157
145
|
item: null,
|
|
@@ -167,7 +155,7 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
167
155
|
item = _ref.item,
|
|
168
156
|
type = _ref.type,
|
|
169
157
|
isDelete = _ref.isDelete,
|
|
170
|
-
props =
|
|
158
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
171
159
|
var locales = contexts.useLocales();
|
|
172
160
|
var FormComponents = contexts.useFormsComponents();
|
|
173
161
|
var _resource$fields = resource.fields,
|
|
@@ -234,13 +222,13 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
234
222
|
var name = _ref7.name,
|
|
235
223
|
_ref7$defaultValue = _ref7.defaultValue,
|
|
236
224
|
defaultValue = _ref7$defaultValue === void 0 ? null : _ref7$defaultValue;
|
|
237
|
-
return defaultValue !== null ?
|
|
225
|
+
return defaultValue !== null ? _objectSpread(_objectSpread({}, defaultValues), {}, _defineProperty({}, name, defaultValue)) : defaultValues;
|
|
238
226
|
}, type !== null ? {
|
|
239
227
|
type: type
|
|
240
228
|
} : null);
|
|
241
229
|
}, [item, type, finalFields]);
|
|
242
230
|
var _useState = React.useState(getInitialValue()),
|
|
243
|
-
_useState2 =
|
|
231
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
244
232
|
value = _useState2[0],
|
|
245
233
|
setValueState = _useState2[1];
|
|
246
234
|
var setValue = React.useCallback(function (newValue) {
|
|
@@ -277,10 +265,10 @@ var ResourceForm = function ResourceForm(_ref) {
|
|
|
277
265
|
React.useEffect(function () {
|
|
278
266
|
setValue(getInitialValue());
|
|
279
267
|
}, [getInitialValue, setValue]);
|
|
280
|
-
return /*#__PURE__*/
|
|
268
|
+
return /*#__PURE__*/React.createElement(contexts.FormProvider, {
|
|
281
269
|
value: value,
|
|
282
270
|
setValue: setValue
|
|
283
|
-
}, /*#__PURE__*/
|
|
271
|
+
}, /*#__PURE__*/React.createElement(FormComponent, Object.assign({}, props, {
|
|
284
272
|
status: status,
|
|
285
273
|
resource: resource,
|
|
286
274
|
item: item,
|
|
@@ -298,4 +286,4 @@ ResourceForm.propTypes = propTypes;
|
|
|
298
286
|
ResourceForm.defaultProps = defaultProps;
|
|
299
287
|
var Resource = ResourceForm;
|
|
300
288
|
|
|
301
|
-
exports
|
|
289
|
+
exports.default = Resource;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/form-resource",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.126",
|
|
4
4
|
"description": "Default resource forms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"assets"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"
|
|
36
|
+
"prepublishOnly": "npm run build",
|
|
37
|
+
"build": "../../scripts/prepare-package.sh"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -45,13 +46,13 @@
|
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"@babel/runtime": "^7.12.5",
|
|
48
|
-
"@panneau/core": "^3.0.
|
|
49
|
-
"@panneau/data": "^3.0.
|
|
50
|
-
"@panneau/element-button": "^3.0.
|
|
51
|
-
"@panneau/element-form": "^3.0.
|
|
52
|
-
"@panneau/field-fields": "^3.0.
|
|
53
|
-
"@panneau/intl": "^3.0.
|
|
54
|
-
"@panneau/themes": "^3.0.
|
|
49
|
+
"@panneau/core": "^3.0.126",
|
|
50
|
+
"@panneau/data": "^3.0.126",
|
|
51
|
+
"@panneau/element-button": "^3.0.126",
|
|
52
|
+
"@panneau/element-form": "^3.0.126",
|
|
53
|
+
"@panneau/field-fields": "^3.0.126",
|
|
54
|
+
"@panneau/intl": "^3.0.126",
|
|
55
|
+
"@panneau/themes": "^3.0.126",
|
|
55
56
|
"classnames": "^2.2.6",
|
|
56
57
|
"lodash": "^4.17.21",
|
|
57
58
|
"prop-types": "^15.7.2",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"publishConfig": {
|
|
61
62
|
"access": "public"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "fa69ddff3f8cf22b00504093087608d5701e6f6a"
|
|
64
65
|
}
|