@dhis2-ui/file-input 9.11.0 → 9.11.1-beta.2
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/build/cjs/file-input/__tests__/file-input.test.js +1 -9
- package/build/cjs/file-input/features/accepts_multiple_files/index.js +1 -2
- package/build/cjs/file-input/features/can_be_blurred/index.js +1 -2
- package/build/cjs/file-input/features/can_be_changed/index.js +1 -2
- package/build/cjs/file-input/features/can_be_focused/index.js +1 -2
- package/build/cjs/file-input/features/common/index.js +0 -1
- package/build/cjs/file-input/file-input.e2e.stories.js +49 -0
- package/build/cjs/file-input/file-input.js +13 -44
- package/build/cjs/file-input/{file-input.stories.js → file-input.prod.stories.js} +29 -36
- package/build/cjs/file-input/index.js +0 -1
- package/build/cjs/file-input-field/__tests__/file-input-field.test.js +1 -9
- package/build/cjs/file-input-field/features/can_be_required/index.js +0 -1
- package/build/cjs/file-input-field/features/has_default_button_label/index.js +0 -1
- package/build/cjs/file-input-field/features/has_default_placeholder/index.js +0 -1
- package/build/cjs/file-input-field/file-input-field.e2e.stories.js +24 -0
- package/build/cjs/file-input-field/file-input-field.js +8 -36
- package/build/cjs/file-input-field/{file-input-field.stories.js → file-input-field.prod.stories.js} +33 -51
- package/build/cjs/file-input-field/index.js +0 -1
- package/build/cjs/file-input-field-with-list/__tests__/file-input-field-with-list.test.js +1 -9
- package/build/cjs/file-input-field-with-list/features/common/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/deduplicates_the_file_list/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/disables_button_when_full/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/displays_files_in_a_list/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/files_can_be_removed/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/has_default_button_label/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/has_default_placeholder/index.js +0 -1
- package/build/cjs/file-input-field-with-list/features/has_default_remove_text/index.js +0 -1
- package/build/cjs/file-input-field-with-list/file-input-field-with-list.e2e.stories.js +63 -0
- package/build/cjs/file-input-field-with-list/file-input-field-with-list.js +9 -47
- package/build/cjs/file-input-field-with-list/{file-input-field-with-list.stories.js → file-input-field-with-list.prod.stories.js} +24 -27
- package/build/cjs/file-input-field-with-list/file-list-item-with-remove.js +7 -17
- package/build/cjs/file-input-field-with-list/index.js +0 -1
- package/build/cjs/file-list/features/accepts_cancel_text/index.js +1 -2
- package/build/cjs/file-list/features/accepts_label/index.js +0 -1
- package/build/cjs/file-list/features/accepts_remove_text/index.js +1 -2
- package/build/cjs/file-list/features/can_be_removed/index.js +1 -2
- package/build/cjs/file-list/features/file-list-item-accepts_children/index.js +0 -1
- package/build/cjs/file-list/features/file-list-placeholder-accepts_children/index.js +0 -1
- package/build/cjs/file-list/features/loading_can_be_cancelled/index.js +1 -2
- package/build/cjs/file-list/file-list-item.e2e.stories.js +49 -0
- package/build/cjs/file-list/file-list-item.js +5 -18
- package/build/cjs/file-list/file-list-placeholder.e2e.stories.js +14 -0
- package/build/cjs/file-list/file-list-placeholder.js +2 -9
- package/build/cjs/file-list/file-list.e2e.stories.js +14 -0
- package/build/cjs/file-list/file-list.js +1 -7
- package/build/cjs/file-list/index.js +0 -3
- package/build/cjs/index.js +0 -4
- package/build/cjs/locales/index.js +3 -73
- package/build/es/file-input/features/accepts_multiple_files/index.js +1 -1
- package/build/es/file-input/features/can_be_blurred/index.js +1 -1
- package/build/es/file-input/features/can_be_changed/index.js +1 -1
- package/build/es/file-input/features/can_be_focused/index.js +1 -1
- package/build/es/file-input/{file-input.stories.e2e.js → file-input.e2e.stories.js} +14 -9
- package/build/es/file-input/file-input.js +10 -31
- package/build/es/file-input/{file-input.stories.js → file-input.prod.stories.js} +23 -15
- package/build/es/file-input-field/file-input-field.e2e.stories.js +15 -0
- package/build/es/file-input-field/file-input-field.js +5 -23
- package/build/es/file-input-field/{file-input-field.stories.js → file-input-field.prod.stories.js} +21 -15
- package/build/es/file-input-field-with-list/{file-input-field-with-list.stories.e2e.js → file-input-field-with-list.e2e.stories.js} +15 -10
- package/build/es/file-input-field-with-list/file-input-field-with-list.js +8 -35
- package/build/es/file-input-field-with-list/{file-input-field-with-list.stories.js → file-input-field-with-list.prod.stories.js} +19 -11
- package/build/es/file-input-field-with-list/file-list-item-with-remove.js +4 -8
- package/build/es/file-list/features/accepts_cancel_text/index.js +1 -1
- package/build/es/file-list/features/accepts_remove_text/index.js +1 -1
- package/build/es/file-list/features/can_be_removed/index.js +1 -1
- package/build/es/file-list/features/loading_can_be_cancelled/index.js +1 -1
- package/build/es/file-list/{file-list-item.stories.e2e.js → file-list-item.e2e.stories.js} +13 -7
- package/build/es/file-list/file-list-item.js +4 -9
- package/build/es/file-list/file-list-placeholder.e2e.stories.js +6 -0
- package/build/es/file-list/file-list-placeholder.js +1 -3
- package/build/es/file-list/file-list.e2e.stories.js +6 -0
- package/build/es/file-list/file-list.js +0 -2
- package/package.json +11 -11
- package/build/cjs/file-input/file-input.stories.e2e.js +0 -40
- package/build/cjs/file-input-field/file-input-field.stories.e2e.js +0 -19
- package/build/cjs/file-input-field-with-list/file-input-field-with-list.stories.e2e.js +0 -53
- package/build/cjs/file-list/file-list-item.stories.e2e.js +0 -38
- package/build/cjs/file-list/file-list-placeholder.stories.e2e.js +0 -11
- package/build/cjs/file-list/file-list.stories.e2e.js +0 -11
- package/build/es/file-input-field/file-input-field.stories.e2e.js +0 -12
- package/build/es/file-list/file-list-placeholder.stories.e2e.js +0 -4
- package/build/es/file-list/file-list.stories.e2e.js +0 -4
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
function _defineProperty(
|
|
2
|
-
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
import React, { Component } from 'react';
|
|
5
|
-
import { FileListItem } from '../index.js';
|
|
6
|
-
|
|
6
|
+
import { FileListItem } from '../file-list/index.js';
|
|
7
7
|
class FileListItemWithRemove extends Component {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
|
-
|
|
11
10
|
_defineProperty(this, "handleRemove", event => {
|
|
12
11
|
const {
|
|
13
12
|
onRemove,
|
|
@@ -18,7 +17,6 @@ class FileListItemWithRemove extends Component {
|
|
|
18
17
|
}, event);
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
render() {
|
|
23
21
|
const {
|
|
24
22
|
label,
|
|
@@ -32,9 +30,7 @@ class FileListItemWithRemove extends Component {
|
|
|
32
30
|
className: className
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
|
-
|
|
36
33
|
}
|
|
37
|
-
|
|
38
34
|
FileListItemWithRemove.propTypes = {
|
|
39
35
|
label: PropTypes.string.isRequired,
|
|
40
36
|
removeText: PropTypes.string.isRequired,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a loading FileListItem with onCancel handler and cancelText is rendered', () => {
|
|
3
|
-
cy.visitStory('FileListItem', 'Loading with
|
|
3
|
+
cy.visitStory('FileListItem', 'Loading with on cancel and cancel text');
|
|
4
4
|
});
|
|
5
5
|
Then('the cancelText will be visible', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-filelistitem-cancel"]').contains('Cancel').should('be.visible');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a FileListItem with removeText is rendered', () => {
|
|
3
|
-
cy.visitStory('FileListItem', 'With
|
|
3
|
+
cy.visitStory('FileListItem', 'With remove text');
|
|
4
4
|
});
|
|
5
5
|
Then('the removeText will be visible', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-filelistitem-remove"]').contains('Remove').should('be.visible');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a FileListItem with Onremove handler is rendered', () => {
|
|
3
|
-
cy.visitStory('FileListItem', 'With
|
|
3
|
+
cy.visitStory('FileListItem', 'With on remove');
|
|
4
4
|
});
|
|
5
5
|
When('the user clicks on the remove text', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-filelistitem-remove"]').click();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a loading FileListItem with onCancel handler is rendered', () => {
|
|
3
|
-
cy.visitStory('FileListItem', 'Loading with
|
|
3
|
+
cy.visitStory('FileListItem', 'Loading with on cancel');
|
|
4
4
|
});
|
|
5
5
|
When('the user clicks on the cancel text', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-filelistitem-cancel"]').click();
|
|
@@ -1,31 +1,37 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { FileListItem } from './file-list-item.js';
|
|
4
3
|
window.onRemove = window.Cypress && window.Cypress.cy.stub();
|
|
5
4
|
window.onCancel = window.Cypress && window.Cypress.cy.stub();
|
|
6
|
-
|
|
5
|
+
export default {
|
|
6
|
+
title: 'FileListItem'
|
|
7
|
+
};
|
|
8
|
+
export const WithOnRemove = () => /*#__PURE__*/React.createElement(FileListItem, {
|
|
7
9
|
label: "File list item",
|
|
8
10
|
onRemove: window.onRemove,
|
|
9
11
|
removeText: "Remove"
|
|
10
|
-
})
|
|
12
|
+
});
|
|
13
|
+
export const LoadingWithOnCancel = () => /*#__PURE__*/React.createElement(FileListItem, {
|
|
11
14
|
loading: true,
|
|
12
15
|
label: "File list item",
|
|
13
16
|
removeText: "Remove",
|
|
14
17
|
onCancel: window.onCancel,
|
|
15
18
|
cancelText: "Cancel"
|
|
16
|
-
})
|
|
19
|
+
});
|
|
20
|
+
export const LoadingWithOnCancelAndCancelText = () => /*#__PURE__*/React.createElement(FileListItem, {
|
|
17
21
|
loading: true,
|
|
18
22
|
label: "File list item",
|
|
19
23
|
removeText: "Remove",
|
|
20
24
|
onCancel: () => {},
|
|
21
25
|
onRemove: () => {},
|
|
22
26
|
cancelText: "Cancel"
|
|
23
|
-
})
|
|
27
|
+
});
|
|
28
|
+
export const WithLabel = () => /*#__PURE__*/React.createElement(FileListItem, {
|
|
24
29
|
label: "Label",
|
|
25
30
|
removeText: "Remove",
|
|
26
31
|
onRemove: () => {}
|
|
27
|
-
})
|
|
32
|
+
});
|
|
33
|
+
export const WithRemoveText = () => /*#__PURE__*/React.createElement(FileListItem, {
|
|
28
34
|
label: "Label",
|
|
29
35
|
removeText: "Remove",
|
|
30
36
|
onRemove: () => {}
|
|
31
|
-
})
|
|
37
|
+
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
import { CircularLoader } from '@dhis2-ui/loader';
|
|
3
2
|
import { theme, colors, spacers } from '@dhis2/ui-constants';
|
|
4
3
|
import { IconAttachment16 } from '@dhis2/ui-icons';
|
|
4
|
+
import { CircularLoader } from '@dhis2-ui/loader';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import React from 'react';
|
|
8
|
-
|
|
9
8
|
const FileListItem = _ref => {
|
|
10
9
|
let {
|
|
11
10
|
className,
|
|
@@ -17,17 +16,14 @@ const FileListItem = _ref => {
|
|
|
17
16
|
cancelText,
|
|
18
17
|
dataTest
|
|
19
18
|
} = _ref;
|
|
20
|
-
|
|
21
19
|
const handleKeyDown = event => {
|
|
22
20
|
if (!onRemove) {
|
|
23
21
|
return;
|
|
24
22
|
}
|
|
25
|
-
|
|
26
23
|
if (event.key === 'Enter' || event.key === 'Backspace' || event.key === 'Delete') {
|
|
27
24
|
onRemove({}, event);
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
|
-
|
|
31
27
|
return /*#__PURE__*/React.createElement("p", {
|
|
32
28
|
"data-test": dataTest,
|
|
33
29
|
className: _JSXStyle.dynamic([["513536609", [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]]]) + " " + (cx('selected-file', className) || "")
|
|
@@ -43,20 +39,19 @@ const FileListItem = _ref => {
|
|
|
43
39
|
className: _JSXStyle.dynamic([["513536609", [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]]]) + " " + "label"
|
|
44
40
|
}, label), loading && onCancel && cancelText && /*#__PURE__*/React.createElement("span", {
|
|
45
41
|
onClick: event => onCancel({}, event),
|
|
46
|
-
"data-test":
|
|
42
|
+
"data-test": `${dataTest}-cancel`,
|
|
47
43
|
className: _JSXStyle.dynamic([["513536609", [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]]]) + " " + "action"
|
|
48
44
|
}, cancelText), !loading && /*#__PURE__*/React.createElement("span", {
|
|
49
45
|
onClick: event => onRemove({}, event),
|
|
50
|
-
"data-test":
|
|
46
|
+
"data-test": `${dataTest}-remove`,
|
|
51
47
|
tabIndex: 0,
|
|
52
48
|
onKeyDown: handleKeyDown,
|
|
53
49
|
className: _JSXStyle.dynamic([["513536609", [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]]]) + " " + "action"
|
|
54
50
|
}, removeText)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
55
51
|
id: "513536609",
|
|
56
52
|
dynamic: [spacers.dp4, colors.grey900, colors.grey700, colors.red700, colors.red800, theme.focus]
|
|
57
|
-
}, [
|
|
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;}`]));
|
|
58
54
|
};
|
|
59
|
-
|
|
60
55
|
FileListItem.defaultProps = {
|
|
61
56
|
dataTest: 'dhis2-uicore-filelistitem'
|
|
62
57
|
};
|
|
@@ -2,7 +2,6 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, spacers } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
|
|
6
5
|
const FileListPlaceholder = _ref => {
|
|
7
6
|
let {
|
|
8
7
|
children,
|
|
@@ -14,9 +13,8 @@ const FileListPlaceholder = _ref => {
|
|
|
14
13
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
15
14
|
id: "1287857385",
|
|
16
15
|
dynamic: [spacers.dp4, colors.grey700]
|
|
17
|
-
}, [
|
|
16
|
+
}, [`p.__jsx-style-dynamic-selector{margin:0;padding-top:${spacers.dp4};font-size:14px;color:${colors.grey700};}`]));
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
FileListPlaceholder.defaultProps = {
|
|
21
19
|
dataTest: 'dhis2-uicore-filelistplaceholder'
|
|
22
20
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
|
|
5
4
|
const FileList = _ref => {
|
|
6
5
|
let {
|
|
7
6
|
children,
|
|
@@ -15,7 +14,6 @@ const FileList = _ref => {
|
|
|
15
14
|
id: "2770071620"
|
|
16
15
|
}, ["div.jsx-2770071620{padding-top:4px;}", ".file-input+div.jsx-2770071620{padding-top:0;}"]));
|
|
17
16
|
};
|
|
18
|
-
|
|
19
17
|
FileList.defaultProps = {
|
|
20
18
|
dataTest: 'dhis2-uicore-filelist'
|
|
21
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/file-input",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.2",
|
|
4
4
|
"description": "UI FileInput",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,25 +22,25 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@dhis2/d2-i18n": "^1.1.0",
|
|
31
|
-
"react": "^16.
|
|
32
|
-
"react-dom": "^16.
|
|
31
|
+
"react": "^16.13",
|
|
32
|
+
"react-dom": "^16.13",
|
|
33
33
|
"styled-jsx": "^4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@dhis2/prop-types": "^3.1.2",
|
|
37
|
-
"@dhis2-ui/button": "9.11.
|
|
38
|
-
"@dhis2-ui/field": "9.11.
|
|
39
|
-
"@dhis2-ui/label": "9.11.
|
|
40
|
-
"@dhis2-ui/loader": "9.11.
|
|
41
|
-
"@dhis2-ui/status-icon": "9.11.
|
|
42
|
-
"@dhis2/ui-constants": "9.11.
|
|
43
|
-
"@dhis2/ui-icons": "9.11.
|
|
37
|
+
"@dhis2-ui/button": "9.11.1-beta.2",
|
|
38
|
+
"@dhis2-ui/field": "9.11.1-beta.2",
|
|
39
|
+
"@dhis2-ui/label": "9.11.1-beta.2",
|
|
40
|
+
"@dhis2-ui/loader": "9.11.1-beta.2",
|
|
41
|
+
"@dhis2-ui/status-icon": "9.11.1-beta.2",
|
|
42
|
+
"@dhis2/ui-constants": "9.11.1-beta.2",
|
|
43
|
+
"@dhis2/ui-icons": "9.11.1-beta.2",
|
|
44
44
|
"classnames": "^2.3.1",
|
|
45
45
|
"prop-types": "^15.7.2"
|
|
46
46
|
},
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("./index.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
13
|
-
|
|
14
|
-
const onChange = (payload, event) => {
|
|
15
|
-
// NOTE: if files is not transformed into an array,
|
|
16
|
-
// cypress will get an empty file list!
|
|
17
|
-
window.onChange({ ...payload,
|
|
18
|
-
files: [...payload.files]
|
|
19
|
-
}, event);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
(0, _react.storiesOf)('FileInput', module).add('With onChange', () => /*#__PURE__*/_react2.default.createElement(_index.FileInput, {
|
|
23
|
-
onChange: onChange,
|
|
24
|
-
buttonLabel: "Upload file",
|
|
25
|
-
name: "upload"
|
|
26
|
-
})).add('With onChange and multiple', () => /*#__PURE__*/_react2.default.createElement(_index.FileInput, {
|
|
27
|
-
name: "upload",
|
|
28
|
-
onChange: onChange,
|
|
29
|
-
buttonLabel: "Upload files",
|
|
30
|
-
multiple: true
|
|
31
|
-
})).add('With initialFocus and onBlur', () => /*#__PURE__*/_react2.default.createElement(_index.FileInput, {
|
|
32
|
-
buttonLabel: "Upload file",
|
|
33
|
-
name: "upload",
|
|
34
|
-
initialFocus: true,
|
|
35
|
-
onBlur: window.onBlur
|
|
36
|
-
})).add('With onFocus', () => /*#__PURE__*/_react2.default.createElement(_index.FileInput, {
|
|
37
|
-
buttonLabel: "Upload file",
|
|
38
|
-
name: "upload",
|
|
39
|
-
onFocus: window.onFocus
|
|
40
|
-
}));
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _fileInputField = require("./file-input-field.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('FileInputField', module).add('With label and required', () => /*#__PURE__*/_react2.default.createElement(_fileInputField.FileInputField, {
|
|
12
|
-
name: "upload",
|
|
13
|
-
label: "upload something",
|
|
14
|
-
buttonLabel: "Upload file",
|
|
15
|
-
required: true
|
|
16
|
-
})).add('Default', () => /*#__PURE__*/_react2.default.createElement(_fileInputField.FileInputField, {
|
|
17
|
-
name: "upload",
|
|
18
|
-
label: "upload something"
|
|
19
|
-
}));
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("./index.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
const singleFileArray = [new File([], 'dummy.txt')];
|
|
13
|
-
window.duplicateFileConstructorArgs = [[], 'duplicate.md', {
|
|
14
|
-
lastModified: 1581348175357,
|
|
15
|
-
type: 'text/markdown'
|
|
16
|
-
}];
|
|
17
|
-
const multipleFileArray = [new File([], 'test1.md'), new File(...window.duplicateFileConstructorArgs), new File([], 'test2.md')];
|
|
18
|
-
|
|
19
|
-
const onChange = (payload, event) => {
|
|
20
|
-
// NOTE: if files is not transformed into an array,
|
|
21
|
-
// cypress will get an empty file list!
|
|
22
|
-
window.onChange({ ...payload,
|
|
23
|
-
files: [...payload.files]
|
|
24
|
-
}, event);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
(0, _react.storiesOf)('FileInputFieldWithList', module).add('Single file - with file', () => /*#__PURE__*/_react2.default.createElement(_index.FileInputFieldWithList, {
|
|
28
|
-
buttonLabel: "Upload file",
|
|
29
|
-
name: "upload",
|
|
30
|
-
files: singleFileArray,
|
|
31
|
-
removeText: "remove",
|
|
32
|
-
onChange: onChange
|
|
33
|
-
})).add('Multiple files - empty', () => /*#__PURE__*/_react2.default.createElement(_index.FileInputFieldWithList, {
|
|
34
|
-
buttonLabel: "Upload file",
|
|
35
|
-
multiple: true,
|
|
36
|
-
name: "upload",
|
|
37
|
-
removeText: "remove",
|
|
38
|
-
onChange: onChange
|
|
39
|
-
})).add('Multiple files - with files', () => /*#__PURE__*/_react2.default.createElement(_index.FileInputFieldWithList, {
|
|
40
|
-
buttonLabel: "Upload file",
|
|
41
|
-
multiple: true,
|
|
42
|
-
name: "upload",
|
|
43
|
-
files: multipleFileArray,
|
|
44
|
-
removeText: "remove",
|
|
45
|
-
onChange: onChange
|
|
46
|
-
})).add('With file and default texts', () => /*#__PURE__*/_react2.default.createElement(_index.FileInputFieldWithList, {
|
|
47
|
-
name: "upload",
|
|
48
|
-
files: singleFileArray,
|
|
49
|
-
onChange: onChange
|
|
50
|
-
})).add('With default texts', () => /*#__PURE__*/_react2.default.createElement(_index.FileInputFieldWithList, {
|
|
51
|
-
name: "upload",
|
|
52
|
-
onChange: onChange
|
|
53
|
-
}));
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _fileListItem = require("./file-list-item.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
window.onRemove = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
window.onCancel = window.Cypress && window.Cypress.cy.stub();
|
|
13
|
-
(0, _react.storiesOf)('FileListItem', module).add('With onRemove', () => /*#__PURE__*/_react2.default.createElement(_fileListItem.FileListItem, {
|
|
14
|
-
label: "File list item",
|
|
15
|
-
onRemove: window.onRemove,
|
|
16
|
-
removeText: "Remove"
|
|
17
|
-
})).add('Loading with onCancel', () => /*#__PURE__*/_react2.default.createElement(_fileListItem.FileListItem, {
|
|
18
|
-
loading: true,
|
|
19
|
-
label: "File list item",
|
|
20
|
-
removeText: "Remove",
|
|
21
|
-
onCancel: window.onCancel,
|
|
22
|
-
cancelText: "Cancel"
|
|
23
|
-
})).add('Loading with onCancel and cancelText', () => /*#__PURE__*/_react2.default.createElement(_fileListItem.FileListItem, {
|
|
24
|
-
loading: true,
|
|
25
|
-
label: "File list item",
|
|
26
|
-
removeText: "Remove",
|
|
27
|
-
onCancel: () => {},
|
|
28
|
-
onRemove: () => {},
|
|
29
|
-
cancelText: "Cancel"
|
|
30
|
-
})).add('With label', () => /*#__PURE__*/_react2.default.createElement(_fileListItem.FileListItem, {
|
|
31
|
-
label: "Label",
|
|
32
|
-
removeText: "Remove",
|
|
33
|
-
onRemove: () => {}
|
|
34
|
-
})).add('With removeText', () => /*#__PURE__*/_react2.default.createElement(_fileListItem.FileListItem, {
|
|
35
|
-
label: "Label",
|
|
36
|
-
removeText: "Remove",
|
|
37
|
-
onRemove: () => {}
|
|
38
|
-
}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _fileListPlaceholder = require("./file-list-placeholder.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('FileListPlaceholder', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_fileListPlaceholder.FileListPlaceholder, null, "I am a child"));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _fileList = require("./file-list.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('FileList', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_fileList.FileList, null, "I am a child"));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FileInputField } from './file-input-field.js';
|
|
4
|
-
storiesOf('FileInputField', module).add('With label and required', () => /*#__PURE__*/React.createElement(FileInputField, {
|
|
5
|
-
name: "upload",
|
|
6
|
-
label: "upload something",
|
|
7
|
-
buttonLabel: "Upload file",
|
|
8
|
-
required: true
|
|
9
|
-
})).add('Default', () => /*#__PURE__*/React.createElement(FileInputField, {
|
|
10
|
-
name: "upload",
|
|
11
|
-
label: "upload something"
|
|
12
|
-
}));
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { FileListPlaceholder } from './file-list-placeholder.js';
|
|
4
|
-
storiesOf('FileListPlaceholder', module).add('With children', () => /*#__PURE__*/React.createElement(FileListPlaceholder, null, "I am a child"));
|