@dhis2-ui/file-input 10.0.0-alpha.5 → 10.0.0-alpha.7

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.
@@ -58,10 +58,10 @@ class FileInput extends _react.Component {
58
58
  }
59
59
  render() {
60
60
  const {
61
- accept,
61
+ accept = '*',
62
62
  buttonLabel,
63
63
  className,
64
- dataTest,
64
+ dataTest = 'dhis2-uicore-fileinput',
65
65
  disabled,
66
66
  error,
67
67
  initialFocus,
@@ -114,10 +114,10 @@ class FileInput extends _react.Component {
114
114
  }
115
115
  }
116
116
  exports.FileInput = FileInput;
117
- FileInput.defaultProps = {
117
+ _defineProperty(FileInput, "defaultProps", {
118
118
  accept: '*',
119
119
  dataTest: 'dhis2-uicore-fileinput'
120
- };
120
+ });
121
121
  FileInput.propTypes = {
122
122
  /**
123
123
  * The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
@@ -20,13 +20,15 @@ const translate = (prop, interpolationObject) => {
20
20
  }
21
21
  return prop;
22
22
  };
23
+ const defaultButtonLabel = () => _index3.default.t('Upload a file');
24
+ const defaultPlaceholder = () => _index3.default.t('No file uploaded yet');
23
25
  const FileInputField = _ref => {
24
26
  let {
25
- accept,
26
- buttonLabel,
27
+ accept = '*',
28
+ buttonLabel = defaultButtonLabel,
27
29
  children,
28
30
  className,
29
- dataTest,
31
+ dataTest = 'dhis2-uiwidgets-fileinputfield',
30
32
  disabled,
31
33
  error,
32
34
  helpText,
@@ -39,7 +41,7 @@ const FileInputField = _ref => {
39
41
  onChange,
40
42
  onFocus,
41
43
  onKeyDown,
42
- placeholder,
44
+ placeholder = defaultPlaceholder,
43
45
  required,
44
46
  small,
45
47
  tabIndex,
@@ -80,12 +82,6 @@ const FileInputField = _ref => {
80
82
  }), /*#__PURE__*/_react.default.createElement(_index2.FileList, null, children ? children : /*#__PURE__*/_react.default.createElement(_index2.FileListPlaceholder, null, translate(placeholder))));
81
83
  };
82
84
  exports.FileInputField = FileInputField;
83
- FileInputField.defaultProps = {
84
- accept: '*',
85
- dataTest: 'dhis2-uiwidgets-fileinputfield',
86
- buttonLabel: () => _index3.default.t('Upload a file'),
87
- placeholder: () => _index3.default.t('No file uploaded yet')
88
- };
89
85
  FileInputField.propTypes = {
90
86
  /** The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) */
91
87
  accept: _propTypes.default.string,
@@ -33,7 +33,9 @@ var _default = exports.default = {
33
33
  // Default args:
34
34
  args: {
35
35
  // Handle default values (see comment in Transfer.js)
36
- ..._fileInputField.FileInputField.defaultProps,
36
+ accept: '*',
37
+ dataTest: 'dhis2-uiwidgets-fileinputfield',
38
+ placeholder: 'No file uploaded yet',
37
39
  onChange: onChange,
38
40
  name: 'uploadName',
39
41
  label: 'Upload something',
@@ -73,12 +73,12 @@ class FileInputFieldWithList extends _react.Component {
73
73
  render() {
74
74
  const {
75
75
  accept,
76
- buttonLabel,
76
+ buttonLabel = FileInputFieldWithList.defaultProps.buttonLabel,
77
77
  className,
78
- dataTest,
78
+ dataTest = 'dhis2-uiwidgets-fileinputfieldwithlist',
79
79
  disabled,
80
80
  error,
81
- files,
81
+ files = [],
82
82
  helpText,
83
83
  initialFocus,
84
84
  label,
@@ -88,8 +88,8 @@ class FileInputFieldWithList extends _react.Component {
88
88
  onBlur,
89
89
  onFocus,
90
90
  onKeyDown,
91
- placeholder,
92
- removeText,
91
+ placeholder = FileInputFieldWithList.defaultProps.placeholder,
92
+ removeText = FileInputFieldWithList.defaultProps.removeText,
93
93
  required,
94
94
  small,
95
95
  tabIndex,
@@ -131,13 +131,13 @@ class FileInputFieldWithList extends _react.Component {
131
131
  }
132
132
  }
133
133
  exports.FileInputFieldWithList = FileInputFieldWithList;
134
- FileInputFieldWithList.defaultProps = {
135
- dataTest: 'dhis2-uiwidgets-fileinputfieldwithlist',
136
- files: [],
134
+ _defineProperty(FileInputFieldWithList, "defaultProps", {
135
+ accept: '*',
136
+ dataTest: 'dhis2-uiwidgets-fileinputfield',
137
137
  buttonLabel: () => _index2.default.t('Upload a file'),
138
138
  placeholder: () => _index2.default.t('No file uploaded yet'),
139
139
  removeText: () => _index2.default.t('Remove')
140
- };
140
+ });
141
141
  FileInputFieldWithList.propTypes = {
142
142
  /** Called with signature `({ name: string, files: [File] }, event)` */
143
143
  onChange: _propTypes.default.func.isRequired,
@@ -34,7 +34,11 @@ var _default = exports.default = {
34
34
  },
35
35
  args: {
36
36
  // Handle default props bug (see Transfer stories)
37
- ..._fileInputFieldWithList.FileInputFieldWithList.defaultProps,
37
+ dataTest: 'dhis2-uiwidgets-fileinputfieldwithlist',
38
+ files: [],
39
+ buttonLabel: 'Upload a file',
40
+ placeholder: 'No file uploaded yet',
41
+ removeText: 'Remove',
38
42
  multiple: true,
39
43
  onChange: onChange,
40
44
  name: 'uploadName'
@@ -21,7 +21,7 @@ const FileListItem = _ref => {
21
21
  loading,
22
22
  onCancel,
23
23
  cancelText,
24
- dataTest
24
+ dataTest = 'dhis2-uicore-filelistitem'
25
25
  } = _ref;
26
26
  const handleKeyDown = event => {
27
27
  if (!onRemove) {
@@ -60,9 +60,6 @@ const FileListItem = _ref => {
60
60
  }, [`p.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:0;padding-top:${_uiConstants.spacers.dp4};}`, "span.__jsx-style-dynamic-selector{display:inline-block;}", ".icon.__jsx-style-dynamic-selector{margin-inline-end:4px;-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-top:1px;}", ".text.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;}", `.label.__jsx-style-dynamic-selector{font-size:14px;color:${_uiConstants.colors.grey900};word-break:break-all;}`, ".label.__jsx-style-dynamic-selector::after{content:' ';display:inline-block;width:12px;}", `.action.__jsx-style-dynamic-selector{font-size:12px;line-height:12px;margin-top:0;-webkit-text-decoration:underline;text-decoration:underline;cursor:pointer;color:${_uiConstants.colors.grey700};}`, `.action.__jsx-style-dynamic-selector:hover{color:${_uiConstants.colors.red700};}`, `.action.__jsx-style-dynamic-selector:active{color:${_uiConstants.colors.red800};}`, `.action.__jsx-style-dynamic-selector:focus{outline:3px solid ${_uiConstants.theme.focus};outline-offset:2px;}`]));
61
61
  };
62
62
  exports.FileListItem = FileListItem;
63
- FileListItem.defaultProps = {
64
- dataTest: 'dhis2-uicore-filelistitem'
65
- };
66
63
  FileListItem.propTypes = {
67
64
  onRemove: _propTypes.default.func.isRequired,
68
65
  cancelText: _propTypes.default.string,
@@ -12,7 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
12
12
  const FileListPlaceholder = _ref => {
13
13
  let {
14
14
  children,
15
- dataTest
15
+ dataTest = 'dhis2-uicore-filelistplaceholder'
16
16
  } = _ref;
17
17
  return /*#__PURE__*/_react.default.createElement("p", {
18
18
  "data-test": dataTest,
@@ -23,9 +23,6 @@ const FileListPlaceholder = _ref => {
23
23
  }, [`p.__jsx-style-dynamic-selector{margin:0;padding-top:${_uiConstants.spacers.dp4};font-size:14px;color:${_uiConstants.colors.grey700};}`]));
24
24
  };
25
25
  exports.FileListPlaceholder = FileListPlaceholder;
26
- FileListPlaceholder.defaultProps = {
27
- dataTest: 'dhis2-uicore-filelistplaceholder'
28
- };
29
26
  FileListPlaceholder.propTypes = {
30
27
  children: _propTypes.default.string,
31
28
  dataTest: _propTypes.default.string
@@ -12,7 +12,7 @@ const FileList = _ref => {
12
12
  let {
13
13
  children,
14
14
  className,
15
- dataTest
15
+ dataTest = 'dhis2-uicore-filelist'
16
16
  } = _ref;
17
17
  return /*#__PURE__*/_react.default.createElement("div", {
18
18
  "data-test": dataTest,
@@ -22,9 +22,6 @@ const FileList = _ref => {
22
22
  }, ["div.jsx-2770071620{padding-top:4px;}", ".file-input+div.jsx-2770071620{padding-top:0;}"]));
23
23
  };
24
24
  exports.FileList = FileList;
25
- FileList.defaultProps = {
26
- dataTest: 'dhis2-uicore-filelist'
27
- };
28
25
  FileList.propTypes = {
29
26
  children: _propTypes.default.node,
30
27
  className: _propTypes.default.string,
@@ -49,10 +49,10 @@ class FileInput extends Component {
49
49
  }
50
50
  render() {
51
51
  const {
52
- accept,
52
+ accept = '*',
53
53
  buttonLabel,
54
54
  className,
55
- dataTest,
55
+ dataTest = 'dhis2-uicore-fileinput',
56
56
  disabled,
57
57
  error,
58
58
  initialFocus,
@@ -104,10 +104,10 @@ class FileInput extends Component {
104
104
  }, ["input.__jsx-style-dynamic-selector{display:none;}", `.file-input.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;gap:${spacers.dp8};padding-bottom:${spacers.dp4};}`]));
105
105
  }
106
106
  }
107
- FileInput.defaultProps = {
107
+ _defineProperty(FileInput, "defaultProps", {
108
108
  accept: '*',
109
109
  dataTest: 'dhis2-uicore-fileinput'
110
- };
110
+ });
111
111
  FileInput.propTypes = {
112
112
  /**
113
113
  * The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
@@ -14,13 +14,15 @@ const translate = (prop, interpolationObject) => {
14
14
  }
15
15
  return prop;
16
16
  };
17
+ const defaultButtonLabel = () => i18n.t('Upload a file');
18
+ const defaultPlaceholder = () => i18n.t('No file uploaded yet');
17
19
  const FileInputField = _ref => {
18
20
  let {
19
- accept,
20
- buttonLabel,
21
+ accept = '*',
22
+ buttonLabel = defaultButtonLabel,
21
23
  children,
22
24
  className,
23
- dataTest,
25
+ dataTest = 'dhis2-uiwidgets-fileinputfield',
24
26
  disabled,
25
27
  error,
26
28
  helpText,
@@ -33,7 +35,7 @@ const FileInputField = _ref => {
33
35
  onChange,
34
36
  onFocus,
35
37
  onKeyDown,
36
- placeholder,
38
+ placeholder = defaultPlaceholder,
37
39
  required,
38
40
  small,
39
41
  tabIndex,
@@ -73,12 +75,6 @@ const FileInputField = _ref => {
73
75
  warning: warning
74
76
  }), /*#__PURE__*/React.createElement(FileList, null, children ? children : /*#__PURE__*/React.createElement(FileListPlaceholder, null, translate(placeholder))));
75
77
  };
76
- FileInputField.defaultProps = {
77
- accept: '*',
78
- dataTest: 'dhis2-uiwidgets-fileinputfield',
79
- buttonLabel: () => i18n.t('Upload a file'),
80
- placeholder: () => i18n.t('No file uploaded yet')
81
- };
82
78
  FileInputField.propTypes = {
83
79
  /** The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) */
84
80
  accept: PropTypes.string,
@@ -26,7 +26,9 @@ export default {
26
26
  // Default args:
27
27
  args: {
28
28
  // Handle default values (see comment in Transfer.js)
29
- ...FileInputField.defaultProps,
29
+ accept: '*',
30
+ dataTest: 'dhis2-uiwidgets-fileinputfield',
31
+ placeholder: 'No file uploaded yet',
30
32
  onChange: onChange,
31
33
  name: 'uploadName',
32
34
  label: 'Upload something',
@@ -65,12 +65,12 @@ class FileInputFieldWithList extends Component {
65
65
  render() {
66
66
  const {
67
67
  accept,
68
- buttonLabel,
68
+ buttonLabel = FileInputFieldWithList.defaultProps.buttonLabel,
69
69
  className,
70
- dataTest,
70
+ dataTest = 'dhis2-uiwidgets-fileinputfieldwithlist',
71
71
  disabled,
72
72
  error,
73
- files,
73
+ files = [],
74
74
  helpText,
75
75
  initialFocus,
76
76
  label,
@@ -80,8 +80,8 @@ class FileInputFieldWithList extends Component {
80
80
  onBlur,
81
81
  onFocus,
82
82
  onKeyDown,
83
- placeholder,
84
- removeText,
83
+ placeholder = FileInputFieldWithList.defaultProps.placeholder,
84
+ removeText = FileInputFieldWithList.defaultProps.removeText,
85
85
  required,
86
86
  small,
87
87
  tabIndex,
@@ -122,13 +122,13 @@ class FileInputFieldWithList extends Component {
122
122
  })));
123
123
  }
124
124
  }
125
- FileInputFieldWithList.defaultProps = {
126
- dataTest: 'dhis2-uiwidgets-fileinputfieldwithlist',
127
- files: [],
125
+ _defineProperty(FileInputFieldWithList, "defaultProps", {
126
+ accept: '*',
127
+ dataTest: 'dhis2-uiwidgets-fileinputfield',
128
128
  buttonLabel: () => i18n.t('Upload a file'),
129
129
  placeholder: () => i18n.t('No file uploaded yet'),
130
130
  removeText: () => i18n.t('Remove')
131
- };
131
+ });
132
132
  FileInputFieldWithList.propTypes = {
133
133
  /** Called with signature `({ name: string, files: [File] }, event)` */
134
134
  onChange: PropTypes.func.isRequired,
@@ -27,7 +27,11 @@ export default {
27
27
  },
28
28
  args: {
29
29
  // Handle default props bug (see Transfer stories)
30
- ...FileInputFieldWithList.defaultProps,
30
+ dataTest: 'dhis2-uiwidgets-fileinputfieldwithlist',
31
+ files: [],
32
+ buttonLabel: 'Upload a file',
33
+ placeholder: 'No file uploaded yet',
34
+ removeText: 'Remove',
31
35
  multiple: true,
32
36
  onChange: onChange,
33
37
  name: 'uploadName'
@@ -14,7 +14,7 @@ const FileListItem = _ref => {
14
14
  loading,
15
15
  onCancel,
16
16
  cancelText,
17
- dataTest
17
+ dataTest = 'dhis2-uicore-filelistitem'
18
18
  } = _ref;
19
19
  const handleKeyDown = event => {
20
20
  if (!onRemove) {
@@ -52,9 +52,6 @@ const FileListItem = _ref => {
52
52
  dynamic: [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]
53
53
  }, [`p.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:0;padding-top:${spacers.dp4};}`, "span.__jsx-style-dynamic-selector{display:inline-block;}", ".icon.__jsx-style-dynamic-selector{margin-inline-end:4px;-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-top:1px;}", ".text.__jsx-style-dynamic-selector{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-flex-shrink:1;-ms-flex-negative:1;flex-shrink:1;}", `.label.__jsx-style-dynamic-selector{font-size:14px;color:${colors.grey900};word-break:break-all;}`, ".label.__jsx-style-dynamic-selector::after{content:' ';display:inline-block;width:12px;}", `.action.__jsx-style-dynamic-selector{font-size:12px;line-height:12px;margin-top:0;-webkit-text-decoration:underline;text-decoration:underline;cursor:pointer;color:${colors.grey700};}`, `.action.__jsx-style-dynamic-selector:hover{color:${colors.red700};}`, `.action.__jsx-style-dynamic-selector:active{color:${colors.red800};}`, `.action.__jsx-style-dynamic-selector:focus{outline:3px solid ${theme.focus};outline-offset:2px;}`]));
54
54
  };
55
- FileListItem.defaultProps = {
56
- dataTest: 'dhis2-uicore-filelistitem'
57
- };
58
55
  FileListItem.propTypes = {
59
56
  onRemove: PropTypes.func.isRequired,
60
57
  cancelText: PropTypes.string,
@@ -5,7 +5,7 @@ import React from 'react';
5
5
  const FileListPlaceholder = _ref => {
6
6
  let {
7
7
  children,
8
- dataTest
8
+ dataTest = 'dhis2-uicore-filelistplaceholder'
9
9
  } = _ref;
10
10
  return /*#__PURE__*/React.createElement("p", {
11
11
  "data-test": dataTest,
@@ -15,9 +15,6 @@ const FileListPlaceholder = _ref => {
15
15
  dynamic: [spacers.dp4, colors.grey700]
16
16
  }, [`p.__jsx-style-dynamic-selector{margin:0;padding-top:${spacers.dp4};font-size:14px;color:${colors.grey700};}`]));
17
17
  };
18
- FileListPlaceholder.defaultProps = {
19
- dataTest: 'dhis2-uicore-filelistplaceholder'
20
- };
21
18
  FileListPlaceholder.propTypes = {
22
19
  children: PropTypes.string,
23
20
  dataTest: PropTypes.string
@@ -5,7 +5,7 @@ const FileList = _ref => {
5
5
  let {
6
6
  children,
7
7
  className,
8
- dataTest
8
+ dataTest = 'dhis2-uicore-filelist'
9
9
  } = _ref;
10
10
  return /*#__PURE__*/React.createElement("div", {
11
11
  "data-test": dataTest,
@@ -14,9 +14,6 @@ const FileList = _ref => {
14
14
  id: "2770071620"
15
15
  }, ["div.jsx-2770071620{padding-top:4px;}", ".file-input+div.jsx-2770071620{padding-top:0;}"]));
16
16
  };
17
- FileList.defaultProps = {
18
- dataTest: 'dhis2-uicore-filelist'
19
- };
20
17
  FileList.propTypes = {
21
18
  children: PropTypes.node,
22
19
  className: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/file-input",
3
- "version": "10.0.0-alpha.5",
3
+ "version": "10.0.0-alpha.7",
4
4
  "description": "UI FileInput",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,13 +34,13 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@dhis2/prop-types": "^3.1.2",
37
- "@dhis2-ui/button": "10.0.0-alpha.5",
38
- "@dhis2-ui/field": "10.0.0-alpha.5",
39
- "@dhis2-ui/label": "10.0.0-alpha.5",
40
- "@dhis2-ui/loader": "10.0.0-alpha.5",
41
- "@dhis2-ui/status-icon": "10.0.0-alpha.5",
42
- "@dhis2/ui-constants": "10.0.0-alpha.5",
43
- "@dhis2/ui-icons": "10.0.0-alpha.5",
37
+ "@dhis2-ui/button": "10.0.0-alpha.7",
38
+ "@dhis2-ui/field": "10.0.0-alpha.7",
39
+ "@dhis2-ui/label": "10.0.0-alpha.7",
40
+ "@dhis2-ui/loader": "10.0.0-alpha.7",
41
+ "@dhis2-ui/status-icon": "10.0.0-alpha.7",
42
+ "@dhis2/ui-constants": "10.0.0-alpha.7",
43
+ "@dhis2/ui-icons": "10.0.0-alpha.7",
44
44
  "classnames": "^2.3.1",
45
45
  "prop-types": "^15.7.2"
46
46
  },