@panneau/action-upload 3.0.193 → 3.0.197

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 (3) hide show
  1. package/es/index.js +18 -60
  2. package/lib/index.js +17 -59
  3. package/package.json +6 -5
package/es/index.js CHANGED
@@ -1,20 +1,19 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
3
  import classNames from 'classnames';
5
- import isArray from 'lodash/isArray';
6
4
  import PropTypes from 'prop-types';
7
- import React, { useState, useCallback, useMemo } from 'react';
5
+ import React from 'react';
8
6
  import { FormattedMessage } from 'react-intl';
9
- import Button from '@panneau/element-button';
7
+ import UploadField from '@panneau/field-upload';
10
8
 
11
9
  var styles = {};
12
10
 
13
- var _excluded = ["title", "description", "fields", "endpoint", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "withConfirmation", "className"];
11
+ var _excluded = ["id", "title", "description", "fields", "endpoint", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "withConfirmation", "className"];
14
12
 
15
13
  // TODO: fix this
16
14
 
17
15
  var propTypes = {
16
+ id: PropTypes.string.isRequired,
18
17
  title: PropTypes.node,
19
18
  description: PropTypes.node,
20
19
  fields: PropTypes.arrayOf(PropTypes.shape({})),
@@ -51,71 +50,30 @@ var defaultProps = {
51
50
  className: null
52
51
  };
53
52
  var UploadAction = function UploadAction(_ref) {
54
- _ref.title;
53
+ _ref.id;
54
+ _ref.title;
55
55
  _ref.description;
56
56
  _ref.fields;
57
57
  _ref.endpoint;
58
58
  var label = _ref.label,
59
- icon = _ref.icon,
60
- value = _ref.value,
61
- theme = _ref.theme,
62
- disabled = _ref.disabled,
63
- onChange = _ref.onChange,
64
- onConfirmed = _ref.onConfirmed,
65
- withConfirmation = _ref.withConfirmation,
66
- className = _ref.className,
59
+ icon = _ref.icon;
60
+ _ref.value;
61
+ var theme = _ref.theme,
62
+ disabled = _ref.disabled;
63
+ _ref.onChange;
64
+ _ref.onConfirmed;
65
+ _ref.withConfirmation;
66
+ var className = _ref.className,
67
67
  props = _objectWithoutProperties(_ref, _excluded);
68
- var _useState = useState(false),
69
- _useState2 = _slicedToArray(_useState, 2),
70
- showModal = _useState2[0],
71
- setShowModal = _useState2[1];
72
- var onOpen = useCallback(function () {
73
- setShowModal(true);
74
- }, [setShowModal]);
75
- useCallback(function (newValue) {
76
- setShowModal(false);
77
- if (onConfirmed !== null) {
78
- onConfirmed(newValue);
79
- }
80
- if (onChange !== null) {
81
- onChange(newValue);
82
- }
83
- }, [onChange, setShowModal]);
84
- useCallback(function () {
85
- setShowModal(false);
86
- }, [setShowModal]);
87
- var ids = useMemo(function () {
88
- if (value == null) {
89
- return null;
90
- }
91
- if (isArray(value)) {
92
- return value.map(function () {
93
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
94
- _ref2$id = _ref2.id,
95
- id = _ref2$id === void 0 ? null : _ref2$id;
96
- return id;
97
- }).filter(function (id) {
98
- return id !== null;
99
- });
100
- }
101
- return value !== null ? [value === null || value === void 0 ? void 0 : value.id] : null;
102
- }, [value]);
103
- useMemo(function () {
104
- return (ids || []).map(function (id) {
105
- return "#".concat(id);
106
- }).join(', ');
107
- }, [ids]);
108
- useMemo(function () {
109
- return value !== null && value.length > 1;
110
- }, [value]);
111
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, Object.assign({
68
+ // const { ids, idLabels, modalKey } = useActionProps(value);
69
+ console.log('upload action...');
70
+ return /*#__PURE__*/React.createElement(UploadField, Object.assign({
112
71
  className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
113
72
  label: label,
114
73
  icon: icon,
115
- onClick: withConfirmation ? onOpen : null,
116
74
  disabled: disabled,
117
75
  theme: disabled ? 'secondary' : theme
118
- }, props)), showModal ? 'Something' : null);
76
+ }, props));
119
77
  };
120
78
  UploadAction.propTypes = propTypes;
121
79
  UploadAction.defaultProps = defaultProps;
package/lib/index.js CHANGED
@@ -3,22 +3,21 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
7
6
  var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
8
7
  var classNames = require('classnames');
9
- var isArray = require('lodash/isArray');
10
8
  var PropTypes = require('prop-types');
11
9
  var React = require('react');
12
10
  var reactIntl = require('react-intl');
13
- var Button = require('@panneau/element-button');
11
+ var UploadField = require('@panneau/field-upload');
14
12
 
15
13
  var styles = {};
16
14
 
17
- var _excluded = ["title", "description", "fields", "endpoint", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "withConfirmation", "className"];
15
+ var _excluded = ["id", "title", "description", "fields", "endpoint", "label", "icon", "value", "theme", "disabled", "onChange", "onConfirmed", "withConfirmation", "className"];
18
16
 
19
17
  // TODO: fix this
20
18
 
21
19
  var propTypes = {
20
+ id: PropTypes.string.isRequired,
22
21
  title: PropTypes.node,
23
22
  description: PropTypes.node,
24
23
  fields: PropTypes.arrayOf(PropTypes.shape({})),
@@ -55,71 +54,30 @@ var defaultProps = {
55
54
  className: null
56
55
  };
57
56
  var UploadAction = function UploadAction(_ref) {
58
- _ref.title;
57
+ _ref.id;
58
+ _ref.title;
59
59
  _ref.description;
60
60
  _ref.fields;
61
61
  _ref.endpoint;
62
62
  var label = _ref.label,
63
- icon = _ref.icon,
64
- value = _ref.value,
65
- theme = _ref.theme,
66
- disabled = _ref.disabled,
67
- onChange = _ref.onChange,
68
- onConfirmed = _ref.onConfirmed,
69
- withConfirmation = _ref.withConfirmation,
70
- className = _ref.className,
63
+ icon = _ref.icon;
64
+ _ref.value;
65
+ var theme = _ref.theme,
66
+ disabled = _ref.disabled;
67
+ _ref.onChange;
68
+ _ref.onConfirmed;
69
+ _ref.withConfirmation;
70
+ var className = _ref.className,
71
71
  props = _objectWithoutProperties(_ref, _excluded);
72
- var _useState = React.useState(false),
73
- _useState2 = _slicedToArray(_useState, 2),
74
- showModal = _useState2[0],
75
- setShowModal = _useState2[1];
76
- var onOpen = React.useCallback(function () {
77
- setShowModal(true);
78
- }, [setShowModal]);
79
- React.useCallback(function (newValue) {
80
- setShowModal(false);
81
- if (onConfirmed !== null) {
82
- onConfirmed(newValue);
83
- }
84
- if (onChange !== null) {
85
- onChange(newValue);
86
- }
87
- }, [onChange, setShowModal]);
88
- React.useCallback(function () {
89
- setShowModal(false);
90
- }, [setShowModal]);
91
- var ids = React.useMemo(function () {
92
- if (value == null) {
93
- return null;
94
- }
95
- if (isArray(value)) {
96
- return value.map(function () {
97
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
98
- _ref2$id = _ref2.id,
99
- id = _ref2$id === void 0 ? null : _ref2$id;
100
- return id;
101
- }).filter(function (id) {
102
- return id !== null;
103
- });
104
- }
105
- return value !== null ? [value === null || value === void 0 ? void 0 : value.id] : null;
106
- }, [value]);
107
- React.useMemo(function () {
108
- return (ids || []).map(function (id) {
109
- return "#".concat(id);
110
- }).join(', ');
111
- }, [ids]);
112
- React.useMemo(function () {
113
- return value !== null && value.length > 1;
114
- }, [value]);
115
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, Object.assign({
72
+ // const { ids, idLabels, modalKey } = useActionProps(value);
73
+ console.log('upload action...');
74
+ return /*#__PURE__*/React.createElement(UploadField, Object.assign({
116
75
  className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
117
76
  label: label,
118
77
  icon: icon,
119
- onClick: withConfirmation ? onOpen : null,
120
78
  disabled: disabled,
121
79
  theme: disabled ? 'secondary' : theme
122
- }, props)), showModal ? 'Something' : null);
80
+ }, props));
123
81
  };
124
82
  UploadAction.propTypes = propTypes;
125
83
  UploadAction.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/action-upload",
3
- "version": "3.0.193",
3
+ "version": "3.0.197",
4
4
  "description": "Upload action",
5
5
  "keywords": [
6
6
  "javascript"
@@ -46,9 +46,10 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.12.5",
49
- "@panneau/core": "^3.0.193",
50
- "@panneau/element-button": "^3.0.193",
51
- "@panneau/themes": "^3.0.193",
49
+ "@panneau/core": "^3.0.194",
50
+ "@panneau/element-button": "^3.0.194",
51
+ "@panneau/field-upload": "^3.0.197",
52
+ "@panneau/themes": "^3.0.194",
52
53
  "classnames": "^2.5.1",
53
54
  "prop-types": "^15.7.2",
54
55
  "react-intl": "^5.15.8||^6.0.0"
@@ -56,5 +57,5 @@
56
57
  "publishConfig": {
57
58
  "access": "public"
58
59
  },
59
- "gitHead": "cd6f69216ddbee75b352f3bd1d39352ff3332848"
60
+ "gitHead": "1d58a5294a2f28a96c998462f1eb421503db2bc2"
60
61
  }