@panneau/form-resource 3.0.300 → 3.0.305

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 +51 -39
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -2,9 +2,9 @@ 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$1 from 'prop-types';
5
+ import PropTypes from 'prop-types';
6
6
  import React, { useMemo, useCallback, useState, useEffect } from 'react';
7
- import { PropTypes } from '@panneau/core';
7
+ import { PropTypes as PropTypes$1 } from '@panneau/core';
8
8
  import { useLocales, useFormsComponents, FormProvider } from '@panneau/core/contexts';
9
9
  import { useResourceUrlGenerator, useForm } from '@panneau/core/hooks';
10
10
  import { getComponentFromName } from '@panneau/core/utils';
@@ -17,19 +17,19 @@ import { useResourceValues } from '@panneau/intl';
17
17
 
18
18
  var _excluded$2 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
19
19
  var propTypes$2 = {
20
- resource: PropTypes.resource.isRequired,
21
- action: PropTypes$1.string,
22
- previous: PropTypes$1.string,
23
- fields: PropTypes.fields.isRequired,
24
- value: PropTypes$1.object,
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
25
  // eslint-disable-line react/forbid-prop-types
26
- onChange: PropTypes$1.func.isRequired,
27
- onSubmit: PropTypes$1.func,
28
- status: PropTypes.formStatus,
29
- generalError: PropTypes$1.string,
30
- errors: PropTypes$1.objectOf(PropTypes$1.arrayOf(PropTypes$1.string)),
31
- loading: PropTypes$1.bool,
32
- className: PropTypes$1.string
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
33
  };
34
34
  var defaultProps$2 = {
35
35
  action: null,
@@ -133,19 +133,19 @@ DeleteForm.defaultProps = defaultProps$2;
133
133
 
134
134
  var _excluded$1 = ["resource", "action", "previous", "status", "value", "onSubmit", "errors", "generalError", "loading", "className"];
135
135
  var propTypes$1 = {
136
- resource: PropTypes.resource.isRequired,
137
- action: PropTypes$1.string,
138
- previous: PropTypes$1.string,
139
- fields: PropTypes.fields.isRequired,
140
- value: PropTypes$1.object,
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
141
  // eslint-disable-line react/forbid-prop-types
142
- onChange: PropTypes$1.func.isRequired,
143
- onSubmit: PropTypes$1.func,
144
- status: PropTypes.formStatus,
145
- generalError: PropTypes$1.string,
146
- errors: PropTypes$1.objectOf(PropTypes$1.arrayOf(PropTypes$1.string)),
147
- loading: PropTypes$1.bool,
148
- className: PropTypes$1.string
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
149
  };
150
150
  var defaultProps$1 = {
151
151
  action: null,
@@ -245,18 +245,19 @@ var DuplicateForm = function DuplicateForm(_ref) {
245
245
  DuplicateForm.propTypes = propTypes$1;
246
246
  DuplicateForm.defaultProps = defaultProps$1;
247
247
 
248
- var _excluded = ["component", "header", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate", "withContainer"];
248
+ var _excluded = ["component", "header", "resource", "onSuccess", "item", "type", "isDelete", "isDuplicate", "isModal", "withContainer"];
249
249
  var propTypes = {
250
- resource: PropTypes.resource.isRequired,
251
- item: PropTypes$1.object,
250
+ resource: PropTypes$1.resource.isRequired,
251
+ item: PropTypes.object,
252
252
  // eslint-disable-line react/forbid-prop-types
253
- type: PropTypes$1.string,
254
- component: PropTypes$1.string,
255
- header: PropTypes$1.node,
256
- onSuccess: PropTypes$1.func,
257
- isDelete: PropTypes$1.bool,
258
- isDuplicate: PropTypes$1.bool,
259
- withContainer: PropTypes$1.bool
253
+ type: PropTypes.string,
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
260
261
  };
261
262
  var defaultProps = {
262
263
  item: null,
@@ -266,6 +267,7 @@ var defaultProps = {
266
267
  onSuccess: null,
267
268
  isDelete: false,
268
269
  isDuplicate: false,
270
+ isModal: false,
269
271
  withContainer: false
270
272
  };
271
273
  var ResourceForm = function ResourceForm(_ref) {
@@ -277,6 +279,7 @@ var ResourceForm = function ResourceForm(_ref) {
277
279
  type = _ref.type,
278
280
  isDelete = _ref.isDelete,
279
281
  isDuplicate = _ref.isDuplicate,
282
+ isModal = _ref.isModal,
280
283
  withContainer = _ref.withContainer,
281
284
  props = _objectWithoutProperties(_ref, _excluded);
282
285
  var locales = useLocales();
@@ -306,7 +309,9 @@ var ResourceForm = function ResourceForm(_ref) {
306
309
  _ref4$edit = _ref4.edit,
307
310
  editForm = _ref4$edit === void 0 ? null : _ref4$edit,
308
311
  _ref4$delete = _ref4["delete"],
309
- deleteForm = _ref4$delete === void 0 ? null : _ref4$delete;
312
+ deleteForm = _ref4$delete === void 0 ? null : _ref4$delete,
313
+ _ref4$modal = _ref4.modal,
314
+ modalForm = _ref4$modal === void 0 ? null : _ref4$modal;
310
315
  var _ref5 = defaultForm || {},
311
316
  _ref5$fields = _ref5.fields,
312
317
  defaultFields = _ref5$fields === void 0 ? null : _ref5$fields,
@@ -315,8 +320,15 @@ var ResourceForm = function ResourceForm(_ref) {
315
320
  defaultFormWithoutHeader = _ref5$withoutHeader === void 0 ? false : _ref5$withoutHeader,
316
321
  _ref5$withoutContaine = _ref5.withoutContainer,
317
322
  defaultFormWithoutContainer = _ref5$withoutContaine === void 0 ? false : _ref5$withoutContaine;
318
- var createOrEditSource = isCreate ? createForm || {} : editForm || {};
319
- var _ref6 = isDelete ? deleteForm || {} : createOrEditSource || {},
323
+ var currentForm = editForm || null;
324
+ if (isModal) {
325
+ currentForm = modalForm || null;
326
+ } else if (isDelete) {
327
+ currentForm = deleteForm || null;
328
+ } else if (isCreate) {
329
+ currentForm = createForm || null;
330
+ }
331
+ var _ref6 = currentForm || {},
320
332
  _ref6$fields = _ref6.fields,
321
333
  formFields = _ref6$fields === void 0 ? null : _ref6$fields,
322
334
  _ref6$component = _ref6.component,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/form-resource",
3
- "version": "3.0.300",
3
+ "version": "3.0.305",
4
4
  "description": "Default resource forms",
5
5
  "keywords": [
6
6
  "javascript"
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "129cddc67f11d3d51bc309af4c161ed027ad425f"
67
+ "gitHead": "521edd614cc4b97cded057b83c5c1272a9563a6b"
68
68
  }