@pareto-engineering/design-system 4.2.1 → 4.3.0

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 (58) hide show
  1. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  2. package/dist/cjs/f/common/utils/index.js +8 -1
  3. package/dist/cjs/f/common/utils/validators.js +17 -0
  4. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
  5. package/dist/cjs/f/fields/FileUpload/FileUpload.js +234 -0
  6. package/dist/cjs/f/fields/FileUpload/common/FilePreview/FilePreview.js +118 -0
  7. package/dist/cjs/f/fields/FileUpload/common/FilePreview/index.js +13 -0
  8. package/dist/cjs/f/fields/FileUpload/common/FilePreview/styles.scss +93 -0
  9. package/dist/cjs/f/fields/FileUpload/common/index.js +12 -0
  10. package/dist/cjs/f/fields/FileUpload/index.js +32 -0
  11. package/dist/cjs/f/fields/FileUpload/styles.scss +73 -0
  12. package/dist/cjs/f/fields/FileUpload/utils.js +45 -0
  13. package/dist/cjs/f/fields/index.js +26 -1
  14. package/dist/cjs/g/FormBuilder/FormBuilder.js +11 -3
  15. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +34 -7
  16. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  17. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +14 -4
  18. package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -4
  19. package/dist/es/f/FormInput/FormInput.js +7 -1
  20. package/dist/es/f/common/utils/index.js +2 -1
  21. package/dist/es/f/common/utils/validators.js +10 -0
  22. package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
  23. package/dist/es/f/fields/FileUpload/FileUpload.js +223 -0
  24. package/dist/es/f/fields/FileUpload/common/FilePreview/FilePreview.js +108 -0
  25. package/dist/es/f/fields/FileUpload/common/FilePreview/index.js +2 -0
  26. package/dist/es/f/fields/FileUpload/common/FilePreview/styles.scss +93 -0
  27. package/dist/es/f/fields/FileUpload/common/index.js +2 -0
  28. package/dist/es/f/fields/FileUpload/index.js +3 -0
  29. package/dist/es/f/fields/FileUpload/styles.scss +73 -0
  30. package/dist/es/f/fields/FileUpload/utils.js +37 -0
  31. package/dist/es/f/fields/index.js +2 -1
  32. package/dist/es/g/FormBuilder/FormBuilder.js +11 -3
  33. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +35 -8
  34. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  35. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +14 -4
  36. package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +8 -3
  37. package/package.json +3 -3
  38. package/src/stories/f/FileUpload.stories.jsx +55 -0
  39. package/src/stories/g/FormBuilder.stories.jsx +19 -97
  40. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  41. package/src/ui/f/common/utils/index.js +1 -0
  42. package/src/ui/f/common/utils/validators.js +10 -0
  43. package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +2 -0
  44. package/src/ui/f/fields/FileUpload/FileUpload.jsx +279 -0
  45. package/src/ui/f/fields/FileUpload/common/FilePreview/FilePreview.jsx +160 -0
  46. package/src/ui/f/fields/FileUpload/common/FilePreview/index.js +2 -0
  47. package/src/ui/f/fields/FileUpload/common/FilePreview/styles.scss +93 -0
  48. package/src/ui/f/fields/FileUpload/common/index.js +2 -0
  49. package/src/ui/f/fields/FileUpload/index.js +3 -0
  50. package/src/ui/f/fields/FileUpload/styles.scss +73 -0
  51. package/src/ui/f/fields/FileUpload/utils.js +49 -0
  52. package/src/ui/f/fields/index.js +6 -0
  53. package/src/ui/g/FormBuilder/FormBuilder.jsx +9 -0
  54. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +53 -11
  55. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  56. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +17 -3
  57. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +11 -2
  58. package/tests/__snapshots__/Storyshots.test.js.snap +180 -154
@@ -0,0 +1,93 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-padding: 1rem;
6
+ $default-margin: 1rem;
7
+ $files-per-row: 3;
8
+ $total-gaps: $files-per-row - 1;
9
+ $combined-gap: calc(var(--gap) * $total-gaps);
10
+ $width-without-gaps: calc(100% - $combined-gap);
11
+ $default-file-width: calc($width-without-gaps / $files-per-row);
12
+
13
+ .#{bem.$base}.file-preview {
14
+ border: var(--theme-default-border-style) var(--ui-lines);
15
+ border-radius: calc(var(--theme-default-border-radius) / 2);
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: calc(var(--gap) / 4);
19
+ padding: $default-padding;
20
+ width: $default-file-width;
21
+
22
+ > .identity {
23
+ align-items: center;
24
+ display: flex;
25
+ gap: calc(var(--gap) / 2);
26
+
27
+ > .type {
28
+ padding-block: calc($default-padding / 4);
29
+ padding-inline: calc($default-padding / 2);
30
+
31
+ // TODO: update the colors to use variables. These are colors from the new DS
32
+ &.pdf {
33
+ background-color: #fdead7;
34
+ color: #b93814;
35
+ }
36
+
37
+ &.file {
38
+ background-color: #eef2f6;
39
+ color: #364151;
40
+ }
41
+
42
+ &.txt {
43
+ background-color: #d1dfff;
44
+ color: #004eeb;
45
+ }
46
+
47
+
48
+ &.vid {
49
+ background-color: #ebe9fe;
50
+ color: #5a25dc;
51
+ }
52
+
53
+ &.img {
54
+ background-color: #cbfbef;
55
+ color: #107569;
56
+ }
57
+
58
+ &.aud {
59
+ background-color: #fef7c3;
60
+ color: #a15c08;
61
+ }
62
+ }
63
+
64
+ > .name {
65
+ overflow: hidden;
66
+ text-overflow: ellipsis;
67
+ white-space: nowrap;
68
+ }
69
+
70
+ > .#{bem.$base}.button {
71
+ cursor: pointer;
72
+ margin-left: auto;
73
+ }
74
+ }
75
+
76
+ > .progress-status {
77
+ > .status {
78
+ align-items: center;
79
+ color: var(--x);
80
+ display: flex;
81
+ gap: calc(var(--gap) / 2);
82
+ margin-bottom: calc($default-margin / 4);
83
+
84
+ > .icon {
85
+ background-color: var(--x);
86
+ border-radius: 50%;
87
+ color: var(--on-x);
88
+ font-size: calc(var(--s-2) * 1rem);
89
+ padding: calc($default-padding / 4);
90
+ }
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,2 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+ export { FilePreview } from "./FilePreview";
@@ -0,0 +1,3 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+ export { default as FileUpload } from "./FileUpload";
3
+ export { fileUploadOptions, getFileType, getFileTypeFromUrl } from "./utils";
@@ -0,0 +1,73 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-padding: 1rem;
6
+ $default-margin: 1rem;
7
+
8
+ .#{bem.$base}.file-upload {
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: var(--gap);
12
+
13
+
14
+ > p {
15
+ color: var(--y);
16
+ margin: 0;
17
+ }
18
+
19
+ > .#{bem.$base}.description {
20
+ height: auto;
21
+ }
22
+
23
+ > .#{bem.$base}.form-label {
24
+ align-items: center;
25
+ border: var(--theme-default-border-style) var(--ui-lines);
26
+ border-radius: calc(var(--theme-default-border-radius) / 2);
27
+ color: var(--heading);
28
+ cursor: pointer;
29
+ display: flex;
30
+ gap: calc(var(--gap) / 2);
31
+ padding: $default-padding;
32
+ width: fit-content;
33
+
34
+ &:has(>input:disabled) {
35
+ --icon-color: var(--hard-disabled);
36
+ color: var(--hard-disabled);
37
+ cursor: not-allowed;
38
+ }
39
+
40
+ &:has(>input:not(:disabled)) {
41
+ &:hover,
42
+ &:active {
43
+ border: var(--theme-hover-input-border);
44
+ }
45
+ }
46
+
47
+ > .ai-icon {
48
+ color: var(--icon-color, var(--interactive));
49
+ font-size: calc(var(--s2) * 1rem);
50
+ }
51
+
52
+ > input[type="file"] {
53
+ display: none;
54
+ }
55
+ }
56
+
57
+ > .attached-files {
58
+ display: flex;
59
+ gap: var(--gap);
60
+
61
+ > p {
62
+ margin: 0;
63
+ }
64
+
65
+ > .files {
66
+ align-items: center;
67
+ display: flex;
68
+ flex-wrap: wrap;
69
+ gap: var(--gap);
70
+ width: 100%;
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,37 @@
1
+ export const fileUploadOptions = [{
2
+ key: 'FILE',
3
+ value: '.doc,.docx,.odt,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text',
4
+ label: 'Documents'
5
+ }, {
6
+ key: 'TXT',
7
+ value: '.xls,.xlsx,.ods,.csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet,text/csv',
8
+ label: 'Spreadsheets'
9
+ }, {
10
+ key: 'PDF',
11
+ value: '.pdf,application/pdf',
12
+ label: 'PDF'
13
+ }, {
14
+ key: 'VID',
15
+ value: '.mp4,.ogg,.webm,video/mp4,video/ogg,video/webm',
16
+ label: 'Videos'
17
+ }, {
18
+ key: 'IMG',
19
+ value: '.png,.jpeg,.jpg,.gif,.webp,image/png,image/jpeg,image/gif,image/webp',
20
+ label: 'Images'
21
+ }, {
22
+ key: 'AUD',
23
+ value: '.mp3,.ogg,.wav,audio/mpeg,audio/ogg,audio/wav',
24
+ label: 'Audio'
25
+ }];
26
+ export const getFileType = file => {
27
+ const mimeType = file?.type;
28
+ const extension = file?.name?.split('.').pop().toLowerCase();
29
+ const fileType = fileUploadOptions.find(option => option.value.includes(mimeType) || option.value.includes(extension));
30
+ return fileType ? fileType.key : 'unknown';
31
+ };
32
+ export const getFileTypeFromUrl = url => {
33
+ const urlWithoutParams = url.split('?')[0];
34
+ const extension = urlWithoutParams.split('.').pop().toLowerCase();
35
+ const fileType = fileUploadOptions.find(option => option.value.includes(extension));
36
+ return fileType ? fileType.key : 'unknown';
37
+ };
@@ -8,4 +8,5 @@ export { QuerySelect } from "./QuerySelect";
8
8
  export { Checkbox } from "./Checkbox";
9
9
  export { QueryChoices } from "./QueryChoices";
10
10
  export { LinkInput } from "./LinkInput";
11
- export { EditorInput } from "./EditorInput";
11
+ export { EditorInput } from "./EditorInput";
12
+ export { FileUpload, fileUploadOptions, getFileType, getFileTypeFromUrl } from "./FileUpload";
@@ -27,7 +27,9 @@ const FormBuilder = ({
27
27
  onRendererError,
28
28
  onRendererFormSave,
29
29
  onBuilderValidate,
30
- initialBuilderValues
30
+ initialBuilderValues,
31
+ fileUploadStatus,
32
+ handleFileDelete
31
33
  // ...otherProps
32
34
  }) => /*#__PURE__*/React.createElement("div", {
33
35
  id: id,
@@ -45,7 +47,9 @@ const FormBuilder = ({
45
47
  onSave: onRendererFormSave,
46
48
  readOnly: readOnly,
47
49
  shouldSubmit: shouldSubmit,
48
- onError: onRendererError
50
+ onError: onRendererError,
51
+ fileUploadStatus: fileUploadStatus,
52
+ handleFileDelete: handleFileDelete
49
53
  }));
50
54
  FormBuilder.propTypes = {
51
55
  /**
@@ -87,7 +91,11 @@ FormBuilder.propTypes = {
87
91
  /**
88
92
  * Whether the form builder in renderer mode should submit the form values itself
89
93
  */
90
- shouldSubmit: PropTypes.bool
94
+ shouldSubmit: PropTypes.bool,
95
+ /**
96
+ * The upload status of files if any
97
+ */
98
+ fileUploadStatus: PropTypes.objectOf(PropTypes.string)
91
99
  };
92
100
  FormBuilder.defaultProps = {
93
101
  mode: 'build',
@@ -4,7 +4,7 @@ import { useState } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { FieldArray, useFormikContext } from 'formik';
6
6
  import styleNames from '@pareto-engineering/bem/exports';
7
- import { SelectInput, TextInput } from "../../../../../../f";
7
+ import { ChoicesInput, SelectInput, TextInput, integerAndGreaterThanZero, fileUploadOptions } from "../../../../../../f";
8
8
  import { ToggleSwitch } from "../../../../../../a";
9
9
  import "./styles.scss";
10
10
 
@@ -13,6 +13,9 @@ import "./styles.scss";
13
13
  import { ActionsContainer } from "../ActionsContainer";
14
14
  const baseClassName = styleNames.base;
15
15
  const componentClassName = 'input-builder';
16
+ const getToggleSwitchStyles = condition => condition ? {
17
+ '--slider-background-color': 'var(--disabled)'
18
+ } : {};
16
19
 
17
20
  /**
18
21
  * This is the component description.
@@ -35,11 +38,6 @@ const InputBuilder = ({
35
38
  const handleToggleRequired = () => {
36
39
  setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.required`, !input?.required);
37
40
  };
38
- const toggleSwitchStyles = {
39
- ...(!input?.required ? {
40
- '--slider-background-color': 'var(--disabled)'
41
- } : {})
42
- };
43
41
  const [hasDescription, setHasDescription] = useState(false);
44
42
 
45
43
  // TODO: handle nav logic
@@ -59,6 +57,10 @@ const InputBuilder = ({
59
57
  } = e.target;
60
58
  setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.options.${optionIndex}.label`, value);
61
59
  };
60
+ const isFile = input?.type === 'file';
61
+ const handleToggleShowSpecificFileTypes = () => {
62
+ setFieldValue(`sections.${sectionIndex}.inputs.${inputIndex}.showSpecificFileTypes`, !input.showSpecificFileTypes);
63
+ };
62
64
  return /*#__PURE__*/React.createElement("div", {
63
65
  id: id,
64
66
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
@@ -92,6 +94,9 @@ const InputBuilder = ({
92
94
  }, {
93
95
  value: 'choices',
94
96
  label: 'Radio buttons'
97
+ }, {
98
+ value: 'file',
99
+ label: 'File upload'
95
100
  }]
96
101
  }), /*#__PURE__*/React.createElement("div", {
97
102
  className: "controls"
@@ -107,7 +112,7 @@ const InputBuilder = ({
107
112
  }, "Required"), /*#__PURE__*/React.createElement(ToggleSwitch, {
108
113
  handleOnChange: handleToggleRequired,
109
114
  checked: input?.required,
110
- style: toggleSwitchStyles,
115
+ style: getToggleSwitchStyles(!input?.required),
111
116
  inputId: `sections_${sectionIndex}_inputs.${inputIndex}_toggle`
112
117
  })), /*#__PURE__*/React.createElement(ActionsContainer, null, /*#__PURE__*/React.createElement("p", null, "Show"), /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
113
118
  className: `option ${hasDescription ? 'with-check-mark' : ''}`
@@ -168,7 +173,29 @@ const InputBuilder = ({
168
173
  className: "icon"
169
174
  }, "+")), /*#__PURE__*/React.createElement("span", {
170
175
  className: "text x-paragraph c-x"
171
- }, "Add Option"))))));
176
+ }, "Add Option")))), isFile && /*#__PURE__*/React.createElement("div", {
177
+ className: "input-file-options"
178
+ }, /*#__PURE__*/React.createElement(TextInput, {
179
+ label: "Maximum number of files",
180
+ name: `sections.${sectionIndex}.inputs.${inputIndex}.maxCount`,
181
+ placeholder: "1",
182
+ type: "number",
183
+ min: "0",
184
+ validate: integerAndGreaterThanZero
185
+ }), /*#__PURE__*/React.createElement("div", {
186
+ className: "specific-file-types"
187
+ }, /*#__PURE__*/React.createElement(ToggleSwitch, {
188
+ handleOnChange: handleToggleShowSpecificFileTypes,
189
+ checked: input?.showSpecificFileTypes,
190
+ style: getToggleSwitchStyles(!input?.showSpecificFileTypes),
191
+ inputId: `sections_${sectionIndex}_inputs.${inputIndex}_show_specific_file_types`
192
+ }), /*#__PURE__*/React.createElement("span", {
193
+ className: "s0"
194
+ }, "Allow only specific file types")), input?.showSpecificFileTypes && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ChoicesInput, {
195
+ name: `sections.${sectionIndex}.inputs.${inputIndex}.accept`,
196
+ options: fileUploadOptions,
197
+ multiple: true
198
+ })))));
172
199
  };
173
200
  InputBuilder.propTypes = {
174
201
  /**
@@ -137,6 +137,17 @@ $default-list-width: var(--action-button-width, 18rem);
137
137
  }
138
138
  }
139
139
  }
140
+
141
+ > .input-file-options {
142
+ display: flex;
143
+ flex-direction: column;
144
+ gap: var(--gap);
145
+ margin-bottom: $default-margin;
146
+
147
+ > .specific-file-types {
148
+ display: flex;
149
+ }
150
+ }
140
151
  }
141
152
  }
142
153
 
@@ -17,9 +17,14 @@ const reconstructFormDataWithValues = (formData, values) => {
17
17
  const newData = {
18
18
  ...formData
19
19
  };
20
- Object.keys(values).forEach(key => {
20
+ Object.keys(values).forEach(async key => {
21
21
  const [sectionIdx, inputIdx] = key.match(/\d+/g).map(Number);
22
- newData.sections[sectionIdx].inputs[inputIdx].value = values[key];
22
+ if (key.includes('files')) {
23
+ const files = values[key].map(file => URL.createObjectURL(file));
24
+ newData.sections[sectionIdx].inputs[inputIdx].files = files;
25
+ } else {
26
+ newData.sections[sectionIdx].inputs[inputIdx].value = values[key];
27
+ }
23
28
  });
24
29
  return newData;
25
30
  };
@@ -46,7 +51,9 @@ const Renderer = ({
46
51
  readOnly,
47
52
  onSave,
48
53
  onError,
49
- shouldSubmit
54
+ shouldSubmit,
55
+ fileUploadStatus,
56
+ handleFileDelete
50
57
  // ...otherProps
51
58
  }) => {
52
59
  const [currentSectionIndex, setCurrentSectionIndex] = useState(0);
@@ -118,7 +125,10 @@ const Renderer = ({
118
125
  return /*#__PURE__*/React.createElement(Form, null, updatedFormData.sections.map((section, sectionIndex) => sectionIndex === currentSectionIndex && /*#__PURE__*/React.createElement(Section, _extends({
119
126
  key: `${section.title}`
120
127
  }, section, {
121
- readOnly: readOnly
128
+ readOnly: readOnly,
129
+ setUpdatedFormData: setUpdatedFormData,
130
+ fileUploadStatus: fileUploadStatus,
131
+ handleFileDelete: handleFileDelete
122
132
  }))), /*#__PURE__*/React.createElement("div", {
123
133
  className: "navigator-container"
124
134
  }, /*#__PURE__*/React.createElement(Button, {
@@ -1,4 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+ /* eslint-disable no-alert */
2
3
  /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
3
4
  import * as React from 'react';
4
5
  import PropTypes from 'prop-types';
@@ -21,7 +22,9 @@ const Section = ({
21
22
  title,
22
23
  description,
23
24
  inputs,
24
- readOnly
25
+ readOnly,
26
+ fileUploadStatus,
27
+ handleFileDelete
25
28
  // ...otherProps
26
29
  }) => /*#__PURE__*/React.createElement("div", {
27
30
  id: id,
@@ -32,10 +35,12 @@ const Section = ({
32
35
  }, title), /*#__PURE__*/React.createElement(ExpandableLexicalPreview, {
33
36
  nodes: description,
34
37
  name: "instructions"
35
- }), inputs.map(input => /*#__PURE__*/React.createElement(FormInput, _extends({
38
+ }), inputs?.map(input => /*#__PURE__*/React.createElement(FormInput, _extends({
36
39
  key: input.name
37
40
  }, input, {
38
- disabled: readOnly
41
+ disabled: readOnly,
42
+ uploadStatus: fileUploadStatus,
43
+ handleFileDelete: handleFileDelete
39
44
  }))));
40
45
  Section.propTypes = {
41
46
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -59,7 +59,7 @@
59
59
  "@lexical/selection": "0.12.2",
60
60
  "@lexical/table": "0.12.2",
61
61
  "@lexical/utils": "0.12.2",
62
- "@pareto-engineering/assets": "^4.2.1",
62
+ "@pareto-engineering/assets": "^4.2.3",
63
63
  "@pareto-engineering/bem": "^4.2.1",
64
64
  "@pareto-engineering/styles": "^4.2.0",
65
65
  "@pareto-engineering/utils": "^4.0.0",
@@ -82,5 +82,5 @@
82
82
  "relay-test-utils": "^15.0.0"
83
83
  },
84
84
  "browserslist": "> 2%",
85
- "gitHead": "9dc4c06f6e3f8efe94eb0fa4f301ca6f046c5075"
85
+ "gitHead": "f9d0eb4bf3a4d825b2da863d3a27c8d4d25ee818"
86
86
  }
@@ -0,0 +1,55 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+ import * as React from 'react'
3
+
4
+ import { Formik, Form } from 'formik'
5
+
6
+ import { FileUpload } from 'ui'
7
+
8
+ export default {
9
+ title :'f/fields/FileUpload',
10
+ component :FileUpload,
11
+ subcomponents:{
12
+ // Item:FileUpload.Item
13
+ },
14
+ decorators:[
15
+ (storyfn) => (
16
+ <Formik
17
+ initialValues={{ files: [] }}
18
+ >
19
+ <Form>
20
+ { storyfn() }
21
+ </Form>
22
+ </Formik>
23
+ ),
24
+ ],
25
+ argTypes:{
26
+ backgroundColor:{ control: 'color' },
27
+ },
28
+ }
29
+
30
+ export const Base = {
31
+ args:{
32
+ name :'section_0_input_0',
33
+ label :'The file upload ',
34
+ type :'file',
35
+ description:'',
36
+ accept :[
37
+ '.mp4,.ogg,.webm,video/mp4,video/ogg,video/webm',
38
+ '.pdf,application/pdf',
39
+ ],
40
+ },
41
+ }
42
+
43
+ export const Multiple = {
44
+ args:{
45
+ ...Base.args,
46
+ multiple:true,
47
+ },
48
+ }
49
+
50
+ export const WithLimitedCount = {
51
+ args:{
52
+ ...Base.args,
53
+ maxCount:2,
54
+ },
55
+ }