@digigov/react-core 0.16.1 → 0.16.3

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.
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["name", "className", "children"];
3
+ var _excluded = ["name", "className", "children", "disabled", "hasFiles"];
4
4
  import React from 'react';
5
5
  import Base from '@digigov/react-core/Base';
6
6
  import clsx from 'clsx';
@@ -13,16 +13,23 @@ export var FileUpload = /*#__PURE__*/React.forwardRef(function FileUpload(_ref,
13
13
  var name = _ref.name,
14
14
  className = _ref.className,
15
15
  children = _ref.children,
16
+ disabled = _ref.disabled,
17
+ _ref$hasFiles = _ref.hasFiles,
18
+ hasFiles = _ref$hasFiles === void 0 ? false : _ref$hasFiles,
16
19
  props = _objectWithoutProperties(_ref, _excluded);
17
20
 
18
- return /*#__PURE__*/React.createElement("div", _extends({
19
- className: clsx(className, true && 'upload-file')
20
- }, props), children, /*#__PURE__*/React.createElement(Base, _extends({
21
+ return /*#__PURE__*/React.createElement(Base, {
22
+ as: "label",
23
+ tabIndex: 0,
24
+ role: "button",
25
+ className: clsx(className, !hasFiles && ['govgr-btn', 'govgr-btn-secondary'], hasFiles && 'govgr-link', true && 'govgr-label-file')
26
+ }, /*#__PURE__*/React.createElement(Base, _extends({
21
27
  as: "input",
22
28
  ref: ref,
23
29
  type: "file",
24
30
  name: name,
25
- className: clsx(true && 'govgr-file-upload')
26
- }, props)));
31
+ disabled: disabled,
32
+ className: clsx(true && 'govgr-file-input')
33
+ }, props)), children);
27
34
  });
28
35
  export default FileUpload;
@@ -0,0 +1,29 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders the FileUpload with hasUploadedFile prop 1`] = `
4
+ <ForwardRef(FileUploadContainer)
5
+ hasUploadedFile={true}
6
+ >
7
+ <ForwardRef(Base)
8
+ as="div"
9
+ className="govgr-uploaded-file"
10
+ >
11
+ <div
12
+ className="govgr-uploaded-file"
13
+ />
14
+ </ForwardRef(Base)>
15
+ </ForwardRef(FileUploadContainer)>
16
+ `;
17
+
18
+ exports[`renders the FileUpload with no props 1`] = `
19
+ <ForwardRef(FileUploadContainer)>
20
+ <ForwardRef(Base)
21
+ as="div"
22
+ className=""
23
+ >
24
+ <div
25
+ className=""
26
+ />
27
+ </ForwardRef(Base)>
28
+ </ForwardRef(FileUploadContainer)>
29
+ `;
@@ -0,0 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["className", "children", "hasUploadedFile"];
4
+ import React from 'react';
5
+ import Base from '@digigov/react-core/Base';
6
+ import clsx from 'clsx';
7
+
8
+ /**
9
+ * Details for the FileUploadContainer.
10
+ * FileUploadContainer component is used for wrapping the FileUpload component
11
+ */
12
+ export var FileUploadContainer = /*#__PURE__*/React.forwardRef(function FileUploadContainer(_ref, ref) {
13
+ var className = _ref.className,
14
+ children = _ref.children,
15
+ _ref$hasUploadedFile = _ref.hasUploadedFile,
16
+ hasUploadedFile = _ref$hasUploadedFile === void 0 ? false : _ref$hasUploadedFile,
17
+ props = _objectWithoutProperties(_ref, _excluded);
18
+
19
+ return /*#__PURE__*/React.createElement(Base, _extends({
20
+ ref: ref,
21
+ as: "div",
22
+ className: clsx(className, hasUploadedFile && 'govgr-uploaded-file')
23
+ }, props), children);
24
+ });
25
+ export default FileUploadContainer;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import FileUploadContainer from '@digigov/react-core/FileUploadContainer';
4
+
5
+ var _ref = /*#__PURE__*/React.createElement(FileUploadContainer, null);
6
+
7
+ it('renders the FileUpload with no props', function () {
8
+ expect(mount(_ref)).toMatchSnapshot();
9
+ });
10
+
11
+ var _ref2 = /*#__PURE__*/React.createElement(FileUploadContainer, {
12
+ hasUploadedFile: true
13
+ });
14
+
15
+ it('renders the FileUpload with hasUploadedFile prop', function () {
16
+ expect(mount(_ref2)).toMatchSnapshot();
17
+ });