@panneau/action-upload 3.0.244 → 3.0.245

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 CHANGED
@@ -1,84 +1,79 @@
1
1
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
2
2
  import PropTypes from 'prop-types';
3
- import React from 'react';
3
+ import React, { useCallback } from 'react';
4
4
  import { FormattedMessage } from 'react-intl';
5
+ import { useFieldsComponentsManager } from '@panneau/core/contexts';
5
6
 
6
- var _excluded = ["id", "title", "description", "fields", "endpoint", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "withConfirmation", "className"];
7
+ var _excluded = ["endpoint", "action", "label", "value", "icon", "theme", "disabled", "onConfirmed", "fieldComponent", "className"];
7
8
 
8
- // TODO: fix this
9
+ // TODO: figure out what happens when an item / multiple items are selected
9
10
 
10
11
  var propTypes = {
11
- id: PropTypes.string.isRequired,
12
- title: PropTypes.node,
13
- description: PropTypes.node,
14
- fields: PropTypes.arrayOf(PropTypes.shape({})),
12
+ // eslint-disable-next-line react/no-unused-prop-types
13
+ id: PropTypes.string,
15
14
  endpoint: PropTypes.string,
15
+ action: PropTypes.func,
16
+ // Promise
16
17
  label: PropTypes.string,
17
- value: PropTypes.bool,
18
+ value: PropTypes.shape({}),
18
19
  icon: PropTypes.string,
19
20
  theme: PropTypes.string,
20
21
  disabled: PropTypes.bool,
21
- onChange: PropTypes.func,
22
+ fieldComponent: PropTypes.string,
22
23
  onConfirmed: PropTypes.func,
23
- withConfirmation: PropTypes.bool,
24
24
  className: PropTypes.string
25
25
  };
26
26
  var defaultProps = {
27
- title: null,
28
- description: null,
29
- fields: null,
30
- endpoint: null,
31
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
32
- id: "rklw2v",
33
- defaultMessage: [{
34
- "type": 0,
35
- "value": "Add a file"
36
- }]
37
- }),
38
- icon: 'upload',
27
+ id: null,
28
+ endpoint: '/import',
29
+ action: null,
30
+ label: null,
39
31
  value: null,
32
+ icon: 'upload',
40
33
  theme: 'primary',
41
34
  disabled: false,
42
- onChange: null,
35
+ fieldComponent: 'upload',
43
36
  onConfirmed: null,
44
- withConfirmation: false,
45
37
  className: null
46
38
  };
47
- var UploadAction = function UploadAction(_ref) {
48
- _ref.id;
49
- _ref.title;
50
- _ref.description;
51
- _ref.fields;
52
- _ref.endpoint;
53
- _ref.label;
54
- _ref.icon;
39
+ var ImportAction = function ImportAction(_ref) {
40
+ _ref.endpoint;
41
+ _ref.action;
42
+ var label = _ref.label;
55
43
  _ref.value;
56
- _ref.theme;
57
- _ref.disabled;
58
- _ref.onChange;
59
- _ref.onConfirmed;
60
- _ref.withConfirmation;
61
- _ref.className;
62
- _objectWithoutProperties(_ref, _excluded);
63
- // const { ids, idLabels, modalKey } = useActionProps(value);
64
- console.log('upload action...');
65
- return 'Upload';
66
- // <UploadField
67
- // className={classNames([
68
- // styles.container,
69
- // {
70
- // [className]: className !== null,
71
- // },
72
- // ])}
73
- // label={label}
74
- // icon={icon}
75
- // disabled={disabled}
76
- // theme={disabled ? 'secondary' : theme}
77
- // {...props}
78
- // />
44
+ var icon = _ref.icon,
45
+ theme = _ref.theme,
46
+ disabled = _ref.disabled,
47
+ onConfirmed = _ref.onConfirmed,
48
+ fieldComponent = _ref.fieldComponent,
49
+ className = _ref.className,
50
+ props = _objectWithoutProperties(_ref, _excluded);
51
+ var FieldComponents = useFieldsComponentsManager();
52
+ var FieldComponent = FieldComponents.getComponent(fieldComponent);
53
+ var onComplete = useCallback(function (data) {
54
+ if (onConfirmed !== null) {
55
+ onConfirmed(data);
56
+ }
57
+ }, [onConfirmed]);
58
+ return /*#__PURE__*/React.createElement(FieldComponent, Object.assign({
59
+ withButton: true,
60
+ outline: false,
61
+ theme: theme,
62
+ addButtonIcon: icon,
63
+ addButtonLabel: label || /*#__PURE__*/React.createElement(FormattedMessage, {
64
+ id: "eL+nIp",
65
+ defaultMessage: [{
66
+ "type": 0,
67
+ "value": "Add file"
68
+ }]
69
+ }),
70
+ onChange: onComplete,
71
+ disabled: disabled,
72
+ className: className
73
+ }, props));
79
74
  };
80
- UploadAction.propTypes = propTypes;
81
- UploadAction.defaultProps = defaultProps;
82
- var UploadAction$1 = UploadAction;
75
+ ImportAction.propTypes = propTypes;
76
+ ImportAction.defaultProps = defaultProps;
77
+ var UploadAction = ImportAction;
83
78
 
84
- export { UploadAction$1 as default };
79
+ export { UploadAction as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/action-upload",
3
- "version": "3.0.244",
3
+ "version": "3.0.245",
4
4
  "description": "Upload action",
5
5
  "keywords": [
6
6
  "javascript"
@@ -53,7 +53,7 @@
53
53
  "@babel/runtime": "^7.12.5",
54
54
  "@panneau/core": "^3.0.244",
55
55
  "@panneau/element-button": "^3.0.244",
56
- "@panneau/field-upload": "^3.0.244",
56
+ "@panneau/field-upload": "^3.0.245",
57
57
  "@panneau/themes": "^3.0.244",
58
58
  "classnames": "^2.5.1",
59
59
  "prop-types": "^15.7.2",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "41028d7e3eddfb81b41a4f9c9a80b4a5cf63c2f0"
65
+ "gitHead": "9365cf9236eaa94e879099b12cccb5cf22645e1e"
66
66
  }
File without changes