@panneau/form-resource 3.0.293 → 3.0.298

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 +35 -10
  2. package/package.json +13 -13
package/es/index.js CHANGED
@@ -245,33 +245,39 @@ var DuplicateForm = function DuplicateForm(_ref) {
245
245
  DuplicateForm.propTypes = propTypes$1;
246
246
  DuplicateForm.defaultProps = defaultProps$1;
247
247
 
248
- var _excluded = ["component", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate"];
248
+ var _excluded = ["component", "header", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate", "withContainer"];
249
249
  var propTypes = {
250
250
  resource: PropTypes.resource.isRequired,
251
251
  item: PropTypes$1.object,
252
252
  // eslint-disable-line react/forbid-prop-types
253
253
  type: PropTypes$1.string,
254
254
  component: PropTypes$1.string,
255
+ header: PropTypes$1.node,
255
256
  onSuccess: PropTypes$1.func,
256
257
  isDelete: PropTypes$1.bool,
257
- isDuplicate: PropTypes$1.bool
258
+ isDuplicate: PropTypes$1.bool,
259
+ withContainer: PropTypes$1.bool
258
260
  };
259
261
  var defaultProps = {
260
262
  item: null,
261
263
  type: null,
262
264
  component: null,
265
+ header: null,
263
266
  onSuccess: null,
264
267
  isDelete: false,
265
- isDuplicate: false
268
+ isDuplicate: false,
269
+ withContainer: false
266
270
  };
267
271
  var ResourceForm = function ResourceForm(_ref) {
268
272
  var component = _ref.component,
273
+ header = _ref.header,
269
274
  resource = _ref.resource,
270
275
  onSuccess = _ref.onSuccess,
271
276
  item = _ref.item,
272
277
  type = _ref.type,
273
278
  isDelete = _ref.isDelete,
274
279
  isDuplicate = _ref.isDuplicate,
280
+ withContainer = _ref.withContainer,
275
281
  props = _objectWithoutProperties(_ref, _excluded);
276
282
  var locales = useLocales();
277
283
  var FormComponents = useFormsComponents();
@@ -304,13 +310,21 @@ var ResourceForm = function ResourceForm(_ref) {
304
310
  var _ref5 = defaultForm || {},
305
311
  _ref5$fields = _ref5.fields,
306
312
  defaultFields = _ref5$fields === void 0 ? null : _ref5$fields,
307
- defaultComponent = _ref5.component;
313
+ defaultComponent = _ref5.component,
314
+ _ref5$withoutHeader = _ref5.withoutHeader,
315
+ defaultFormWithoutHeader = _ref5$withoutHeader === void 0 ? false : _ref5$withoutHeader,
316
+ _ref5$withoutContaine = _ref5.withoutContainer,
317
+ defaultFormWithoutContainer = _ref5$withoutContaine === void 0 ? false : _ref5$withoutContaine;
308
318
  var createOrEditSource = isCreate ? createForm || {} : editForm || {};
309
319
  var _ref6 = isDelete ? deleteForm || {} : createOrEditSource || {},
310
320
  _ref6$fields = _ref6.fields,
311
321
  formFields = _ref6$fields === void 0 ? null : _ref6$fields,
312
322
  _ref6$component = _ref6.component,
313
- formComponent = _ref6$component === void 0 ? null : _ref6$component;
323
+ formComponent = _ref6$component === void 0 ? null : _ref6$component,
324
+ _ref6$withoutHeader = _ref6.withoutHeader,
325
+ formWithoutHeader = _ref6$withoutHeader === void 0 ? false : _ref6$withoutHeader,
326
+ _ref6$withoutContaine = _ref6.withoutContainer,
327
+ formWithoutContainer = _ref6$withoutContaine === void 0 ? false : _ref6$withoutContaine;
314
328
  var finalFields = useMemo(function () {
315
329
  return (formFields || defaultFields || resourceTypeFields || resourceFields).filter(function (_ref7) {
316
330
  var _ref7$settings = _ref7.settings,
@@ -395,6 +409,8 @@ var ResourceForm = function ResourceForm(_ref) {
395
409
  generalError = _useForm.generalError,
396
410
  errors = _useForm.errors;
397
411
  var defaultFormName = isDelete || isDuplicate ? component || formComponent || null : component || formComponent || defaultComponent || 'normal';
412
+ var finalWithContainer = withContainer && defaultFormName !== 'two-pane' && !defaultFormWithoutContainer && !formWithoutContainer;
413
+ var finalWithHeader = header !== null && defaultFormName !== 'two-pane' && !defaultFormWithoutHeader && !formWithoutHeader;
398
414
  var finalComponent = component;
399
415
  if (isDelete) {
400
416
  finalComponent = DeleteForm;
@@ -410,10 +426,7 @@ var ResourceForm = function ResourceForm(_ref) {
410
426
  useEffect(function () {
411
427
  setValue(getInitialValue());
412
428
  }, [getInitialValue, setValue]);
413
- return /*#__PURE__*/React.createElement(FormProvider, {
414
- value: value,
415
- setValue: setValue
416
- }, /*#__PURE__*/React.createElement(FormComponent, Object.assign({}, props, {
429
+ var element = /*#__PURE__*/React.createElement(FormComponent, Object.assign({}, props, {
417
430
  status: status,
418
431
  resource: resource,
419
432
  item: item,
@@ -426,7 +439,19 @@ var ResourceForm = function ResourceForm(_ref) {
426
439
  value: value,
427
440
  onChange: setValue,
428
441
  loading: loading
429
- })));
442
+ }));
443
+ return /*#__PURE__*/React.createElement(FormProvider, {
444
+ value: value,
445
+ setValue: setValue
446
+ }, finalWithHeader ? header : /*#__PURE__*/React.createElement("div", {
447
+ className: "w-100 mb-3"
448
+ }), finalWithContainer ? /*#__PURE__*/React.createElement("div", {
449
+ className: "container-sm py-4"
450
+ }, /*#__PURE__*/React.createElement("div", {
451
+ className: "row justify-content-center"
452
+ }, /*#__PURE__*/React.createElement("div", {
453
+ className: "col-12 col-md-8 col-lg-7"
454
+ }, element))) : element);
430
455
  };
431
456
  ResourceForm.propTypes = propTypes;
432
457
  ResourceForm.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-resource",
3
- "version": "3.0.293",
3
+ "version": "3.0.298",
4
4
  "description": "Default resource forms",
5
5
  "keywords": [
6
6
  "javascript"
@@ -40,22 +40,22 @@
40
40
  "build": "../../scripts/prepare-package.sh"
41
41
  },
42
42
  "devDependencies": {
43
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
44
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
43
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
44
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
48
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
47
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
48
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.12.5",
52
- "@panneau/core": "^3.0.292",
53
- "@panneau/data": "^3.0.292",
54
- "@panneau/element-button": "^3.0.293",
55
- "@panneau/element-form": "^3.0.293",
56
- "@panneau/field-fields": "^3.0.293",
57
- "@panneau/intl": "^3.0.292",
58
- "@panneau/themes": "^3.0.293",
52
+ "@panneau/core": "^3.0.295",
53
+ "@panneau/data": "^3.0.295",
54
+ "@panneau/element-button": "^3.0.295",
55
+ "@panneau/element-form": "^3.0.298",
56
+ "@panneau/field-fields": "^3.0.295",
57
+ "@panneau/intl": "^3.0.295",
58
+ "@panneau/themes": "^3.0.295",
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": "4aa471be4c4ae77f72137e14dfb891a803964f61"
67
+ "gitHead": "166381f0615a215ab07ca018c97a7150396717fe"
68
68
  }