@pareto-engineering/design-system 4.2.1-alpha.0 → 4.2.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.
Files changed (73) hide show
  1. package/dist/cjs/a/XMLEditor/XMLEditor.js +3 -15
  2. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  3. package/dist/cjs/f/common/utils/index.js +8 -1
  4. package/dist/cjs/f/common/utils/validators.js +17 -0
  5. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
  6. package/dist/cjs/f/fields/EditorInput/EditorInput.js +2 -15
  7. package/dist/cjs/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -7
  8. package/dist/cjs/f/fields/FileUpload/FileUpload.js +228 -0
  9. package/dist/cjs/f/fields/FileUpload/common/FilePreview/FilePreview.js +90 -0
  10. package/dist/cjs/f/fields/FileUpload/common/FilePreview/index.js +13 -0
  11. package/dist/cjs/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
  12. package/dist/cjs/f/fields/FileUpload/common/index.js +12 -0
  13. package/dist/cjs/f/fields/FileUpload/fileUploadOptions.js +31 -0
  14. package/dist/cjs/f/fields/FileUpload/index.js +20 -0
  15. package/dist/cjs/f/fields/FileUpload/styles.scss +73 -0
  16. package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  17. package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  18. package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
  19. package/dist/cjs/f/fields/index.js +14 -1
  20. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +34 -7
  21. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  22. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +9 -3
  23. package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -2
  24. package/dist/es/a/XMLEditor/XMLEditor.js +3 -15
  25. package/dist/es/f/FormInput/FormInput.js +7 -1
  26. package/dist/es/f/common/utils/index.js +2 -1
  27. package/dist/es/f/common/utils/validators.js +10 -0
  28. package/dist/es/f/fields/ChoicesInput/common/Choice/Choice.js +3 -2
  29. package/dist/es/f/fields/EditorInput/EditorInput.js +2 -15
  30. package/dist/es/f/fields/EditorInput/common/StopPropagationPlugin.js +2 -6
  31. package/dist/es/f/fields/FileUpload/FileUpload.js +218 -0
  32. package/dist/es/f/fields/FileUpload/common/FilePreview/FilePreview.js +80 -0
  33. package/dist/es/f/fields/FileUpload/common/FilePreview/index.js +2 -0
  34. package/dist/es/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
  35. package/dist/es/f/fields/FileUpload/common/index.js +2 -0
  36. package/dist/es/f/fields/FileUpload/fileUploadOptions.js +25 -0
  37. package/dist/es/f/fields/FileUpload/index.js +3 -0
  38. package/dist/es/f/fields/FileUpload/styles.scss +73 -0
  39. package/dist/es/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  40. package/dist/es/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  41. package/dist/es/f/fields/SelectInput/styles.scss +1 -1
  42. package/dist/es/f/fields/index.js +2 -1
  43. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +35 -8
  44. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  45. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +9 -3
  46. package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -1
  47. package/package.json +4 -4
  48. package/src/stories/f/FileUpload.stories.jsx +55 -0
  49. package/src/stories/g/FormBuilder.stories.jsx +19 -97
  50. package/src/ui/a/XMLEditor/XMLEditor.jsx +1 -15
  51. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  52. package/src/ui/f/common/utils/index.js +1 -0
  53. package/src/ui/f/common/utils/validators.js +10 -0
  54. package/src/ui/f/fields/ChoicesInput/common/Choice/Choice.jsx +2 -0
  55. package/src/ui/f/fields/EditorInput/EditorInput.jsx +1 -15
  56. package/src/ui/f/fields/EditorInput/common/StopPropagationPlugin.jsx +2 -6
  57. package/src/ui/f/fields/FileUpload/FileUpload.jsx +277 -0
  58. package/src/ui/f/fields/FileUpload/common/FilePreview/FilePreview.jsx +115 -0
  59. package/src/ui/f/fields/FileUpload/common/FilePreview/index.js +2 -0
  60. package/src/ui/f/fields/FileUpload/common/FilePreview/styles.scss +92 -0
  61. package/src/ui/f/fields/FileUpload/common/index.js +2 -0
  62. package/src/ui/f/fields/FileUpload/fileUploadOptions.js +32 -0
  63. package/src/ui/f/fields/FileUpload/index.js +3 -0
  64. package/src/ui/f/fields/FileUpload/styles.scss +73 -0
  65. package/src/ui/f/fields/SelectInput/common/Menu/Menu.jsx +1 -0
  66. package/src/ui/f/fields/SelectInput/common/Multiple/Multiple.jsx +1 -1
  67. package/src/ui/f/fields/SelectInput/styles.scss +1 -1
  68. package/src/ui/f/fields/index.js +1 -0
  69. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +53 -11
  70. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/styles.scss +11 -0
  71. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +13 -3
  72. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +7 -2
  73. package/tests/__snapshots__/Storyshots.test.js.snap +163 -159
@@ -38,9 +38,7 @@ const XMLEditor = _ref => {
38
38
  gutterWidth,
39
39
  config,
40
40
  onChange,
41
- onBlur,
42
- stopAllPropagation,
43
- stopPropagationKeys
41
+ onBlur
44
42
  } = _ref;
45
43
  const editorRef = (0, _react.useRef)();
46
44
  (0, _react.useEffect)(() => {
@@ -55,9 +53,7 @@ const XMLEditor = _ref => {
55
53
  }
56
54
  }), _view.EditorView.domEventHandlers({
57
55
  keydown(e) {
58
- if (stopPropagationKeys?.includes(e.key) || stopAllPropagation) {
59
- e.stopPropagation();
60
- }
56
+ e.stopPropagation();
61
57
  }
62
58
  })]
63
59
  });
@@ -113,18 +109,10 @@ XMLEditor.propTypes = {
113
109
  * The width of the gutter.
114
110
  */
115
111
  gutterWidth: _propTypes.default.string,
116
- /**
117
- * The keys to stop propagation on.
118
- */
119
- stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string),
120
112
  /**
121
113
  * The callback for when the editor loses focus.
122
114
  */
123
- onBlur: _propTypes.default.func,
124
- /**
125
- * Whether to stop all propagation of keys to keep focus on the editor.
126
- */
127
- stopAllPropagation: _propTypes.default.bool
115
+ onBlur: _propTypes.default.func
128
116
  };
129
117
  XMLEditor.defaultProps = {
130
118
  config: `<View>
@@ -97,6 +97,12 @@ const FormInput = _ref => {
97
97
  disabled: disabled
98
98
  }, otherProps));
99
99
  }
100
+ if (type === 'file') {
101
+ return /*#__PURE__*/React.createElement(_fields.FileUpload, _extends({
102
+ className: newClassName,
103
+ disabled: disabled
104
+ }, otherProps));
105
+ }
100
106
  if (extraTypes?.[type]) {
101
107
  const Component = extraTypes[type];
102
108
  return /*#__PURE__*/React.createElement(Component, _extends({
@@ -3,10 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "integerAndGreaterThanZero", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _validators.integerAndGreaterThanZero;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "lookUpInputValueFromFetchedOptions", {
7
13
  enumerable: true,
8
14
  get: function () {
9
15
  return _lookUpInputValueFromFetchedOptions.lookUpInputValueFromFetchedOptions;
10
16
  }
11
17
  });
12
- var _lookUpInputValueFromFetchedOptions = require("./lookUpInputValueFromFetchedOptions");
18
+ var _lookUpInputValueFromFetchedOptions = require("./lookUpInputValueFromFetchedOptions");
19
+ var _validators = require("./validators");
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.integerAndGreaterThanZero = void 0;
7
+ const integerAndGreaterThanZero = value => {
8
+ let error = '';
9
+ if (value && value <= 0 || value === 0) {
10
+ error = 'Value must be greator than zero.';
11
+ }
12
+ if (value && value % 1 !== 0) {
13
+ error = 'You must enter a whole number.';
14
+ }
15
+ return error;
16
+ };
17
+ exports.integerAndGreaterThanZero = integerAndGreaterThanZero;
@@ -30,7 +30,8 @@ const Choice = _ref => {
30
30
  value,
31
31
  multiple,
32
32
  validate,
33
- disabled
33
+ disabled,
34
+ ...otherProps
34
35
  } = _ref;
35
36
  const type = multiple ? 'checkbox' : 'radio';
36
37
  const [field] = (0, _formik.useField)({
@@ -46,7 +47,7 @@ const Choice = _ref => {
46
47
  type: type,
47
48
  id: id,
48
49
  name: name
49
- }, field, {
50
+ }, field, otherProps, {
50
51
  value: value,
51
52
  disabled: disabled
52
53
  })), /*#__PURE__*/React.createElement("label", {
@@ -59,7 +59,6 @@ const EditorInput = _ref2 => {
59
59
  style,
60
60
  name,
61
61
  label,
62
- // validate,
63
62
  resize,
64
63
  color,
65
64
  rows,
@@ -68,7 +67,6 @@ const EditorInput = _ref2 => {
68
67
  description,
69
68
  disabled,
70
69
  showDebugger,
71
- stopPropagationKeys,
72
70
  setEditorState
73
71
  // ...otherProps
74
72
  } = _ref2;
@@ -156,9 +154,7 @@ const EditorInput = _ref2 => {
156
154
  onChange: onChange
157
155
  }), /*#__PURE__*/React.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/React.createElement(_LexicalClickableLinkPlugin.default, null), /*#__PURE__*/React.createElement(_LexicalTabIndentationPlugin.TabIndentationPlugin, null), setEditorState && /*#__PURE__*/React.createElement(ExposeEditorStatePlugin, {
158
156
  setEditorState: setEditorState
159
- }), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), stopPropagationKeys && /*#__PURE__*/React.createElement(_common2.StopPropagationPlugin, {
160
- stopPropagationKeys: stopPropagationKeys
161
- }), /*#__PURE__*/React.createElement(_common.FormDescription, {
157
+ }), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), /*#__PURE__*/React.createElement(_common2.StopPropagationPlugin, null), /*#__PURE__*/React.createElement(_common.FormDescription, {
162
158
  className: "s-1",
163
159
  description: description,
164
160
  name: name
@@ -185,11 +181,6 @@ EditorInput.propTypes = {
185
181
  * The input label
186
182
  */
187
183
  label: _propTypes.default.string.isRequired,
188
- /**
189
- * The input value validator function
190
- */
191
- // validate:PropTypes.func,
192
-
193
184
  /**
194
185
  * The number of rows int the text area
195
186
  */
@@ -221,11 +212,7 @@ EditorInput.propTypes = {
221
212
  /**
222
213
  * Whether to show the debugger or not
223
214
  */
224
- showDebugger: _propTypes.default.bool,
225
- /**
226
- * Map to stop propagation of the given keys
227
- */
228
- stopPropagationKeys: _propTypes.default.arrayOf(_propTypes.default.string)
215
+ showDebugger: _propTypes.default.bool
229
216
  };
230
217
  EditorInput.defaultProps = {
231
218
  rows: 10,
@@ -6,16 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
9
- const StopPropagationPlugin = _ref => {
10
- let {
11
- stopPropagationKeys
12
- } = _ref;
9
+ const StopPropagationPlugin = () => {
13
10
  const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
14
11
  (0, _react.useInsertionEffect)(() => {
15
12
  const onKeyDown = e => {
16
- if (stopPropagationKeys?.includes(e.key)) {
17
- e.stopPropagation();
18
- }
13
+ e.stopPropagation();
19
14
  };
20
15
  return editor.registerRootListener((rootElement, prevRootElement) => {
21
16
  if (prevRootElement !== null) {
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _formik = require("formik");
10
+ var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
11
+ require("./styles.scss");
12
+ var _common = require("./common");
13
+ var _common2 = require("../../common");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
18
+
19
+ // Local Definitions
20
+
21
+ const baseClassName = _exports.default.base;
22
+ const componentClassName = 'file-upload';
23
+
24
+ /**
25
+ * This is the component description.
26
+ */
27
+ const FileUpload = _ref => {
28
+ let {
29
+ id,
30
+ className: userClassName,
31
+ style,
32
+ label,
33
+ description,
34
+ accept,
35
+ multiple,
36
+ name,
37
+ disabled,
38
+ maxCount,
39
+ maxCountError,
40
+ maxSize,
41
+ maxSizeError,
42
+ onChange,
43
+ onDelete,
44
+ // TODO: TBD when connecting with BE
45
+ // onPreview,
46
+ // progress,
47
+ // percent,
48
+ // uploadStatus,
49
+ filePreviewAlignment,
50
+ optional,
51
+ labelColor,
52
+ color
53
+ // ...otherProps
54
+ } = _ref;
55
+ const [field,, helpers] = (0, _formik.useField)({
56
+ name
57
+ });
58
+ const {
59
+ value
60
+ } = field;
61
+ const {
62
+ setError,
63
+ setValue,
64
+ setTouched
65
+ } = helpers;
66
+ const handleChange = event => {
67
+ setTouched(true, false);
68
+ const newFiles = Array.from(event.currentTarget.files);
69
+ const currentFiles = value || [];
70
+ const currentCount = currentFiles.length + newFiles.length;
71
+ if (maxCount && currentCount > maxCount) {
72
+ setError(maxCountError || `Maximum of ${maxCount} files allowed`);
73
+ return;
74
+ }
75
+ const duplicateFiles = newFiles.filter(newFile => currentFiles.some(currentFile => currentFile.name === newFile.name));
76
+ if (duplicateFiles.length > 0) {
77
+ setError('You cannot upload the same file twice.');
78
+ return;
79
+ }
80
+ if (maxSize) {
81
+ const oversizedFiles = newFiles.filter(file => file.size > maxSize);
82
+ if (oversizedFiles.length > 0) {
83
+ setError(maxSizeError || `File size exceeds the limit of ${maxSize} bytes`);
84
+ return;
85
+ }
86
+ }
87
+ const updatedFiles = [...currentFiles, ...newFiles];
88
+ setValue(updatedFiles);
89
+ onChange?.(updatedFiles);
90
+
91
+ // eslint-disable-next-line no-param-reassign
92
+ event.target.value = null;
93
+ };
94
+ const handleDelete = fileIndex => {
95
+ const updatedFiles = value.filter((_, i) => i !== fileIndex);
96
+ setValue(updatedFiles);
97
+ onDelete?.(fileIndex);
98
+ };
99
+ const acceptOptions = Array.isArray(accept) ? accept?.join(',') : accept;
100
+ return /*#__PURE__*/React.createElement("div", {
101
+ id: id,
102
+ className: [baseClassName, componentClassName, userClassName, `preview-${filePreviewAlignment}`, `y-${color}`].filter(e => e).join(' '),
103
+ style: style
104
+ }, /*#__PURE__*/React.createElement("p", null, label), /*#__PURE__*/React.createElement(_common2.FormDescription, {
105
+ className: "s-1",
106
+ description: description,
107
+ name: name
108
+ }), !disabled && /*#__PURE__*/React.createElement(_common2.FormLabel, {
109
+ name: name,
110
+ color: labelColor,
111
+ optional: optional
112
+ }, /*#__PURE__*/React.createElement("input", {
113
+ id: name,
114
+ className: "file",
115
+ type: "file",
116
+ accept: acceptOptions,
117
+ multiple: multiple || maxCount && maxCount > 0,
118
+ disabled: disabled,
119
+ onChange: handleChange
120
+ }), /*#__PURE__*/React.createElement("span", {
121
+ className: "ai-icon"
122
+ }, "U"), /*#__PURE__*/React.createElement("span", null, "Attach file")), value?.length > 0 && /*#__PURE__*/React.createElement("div", {
123
+ className: "attached-files"
124
+ }, /*#__PURE__*/React.createElement("p", null, "Attached files:"), /*#__PURE__*/React.createElement("div", {
125
+ className: "files"
126
+ }, value.map((file, indx) => /*#__PURE__*/React.createElement(_common.FilePreview, {
127
+ file: file,
128
+ key: file.name,
129
+ disabled: disabled,
130
+ handleDelete: () => handleDelete(indx)
131
+ })))));
132
+ };
133
+ FileUpload.propTypes = {
134
+ /**
135
+ * The HTML id for this element
136
+ */
137
+ id: _propTypes.default.string,
138
+ /**
139
+ * The HTML class names for this element
140
+ */
141
+ className: _propTypes.default.string,
142
+ /**
143
+ * The React-written, css properties for this element.
144
+ */
145
+ style: _propTypes.default.objectOf(_propTypes.default.string),
146
+ /**
147
+ * The label text for the file input
148
+ */
149
+ label: _propTypes.default.string,
150
+ /**
151
+ * The description text below the label
152
+ */
153
+ description: _propTypes.default.string,
154
+ /**
155
+ * The color of the text
156
+ */
157
+ color: _propTypes.default.string,
158
+ /**
159
+ * The accepted file types (e.g., 'image/*')
160
+ */
161
+ accept: _propTypes.default.string,
162
+ /**
163
+ * Whether to allow multiple file uploads
164
+ */
165
+ multiple: _propTypes.default.bool,
166
+ /**
167
+ * The name attribute for the input
168
+ */
169
+ name: _propTypes.default.string.isRequired,
170
+ /**
171
+ * Whether the the input should be disabled
172
+ */
173
+ disabled: _propTypes.default.bool,
174
+ /**
175
+ * The maximum number of files allowed
176
+ */
177
+ maxCount: _propTypes.default.number,
178
+ /**
179
+ * The error message when max count is exceeded
180
+ */
181
+ maxCountError: _propTypes.default.string,
182
+ /**
183
+ * The maximum size of files allowed (in bytes)
184
+ */
185
+ maxSize: _propTypes.default.number,
186
+ /**
187
+ * The error message when file size exceeds max size
188
+ */
189
+ maxSizeError: _propTypes.default.string,
190
+ /**
191
+ * The upload progress value (0-100)
192
+ */
193
+ // progress:PropTypes.number,
194
+
195
+ /**
196
+ * The function to handle file change events
197
+ */
198
+ onChange: _propTypes.default.func,
199
+ /**
200
+ * The function to handle file delete events
201
+ */
202
+ onDelete: _propTypes.default.func,
203
+ /**
204
+ * The function to handle file download events
205
+ */
206
+ // onDownload:PropTypes.func,
207
+
208
+ /**
209
+ * The function to handle file preview events
210
+ */
211
+ // onPreview:PropTypes.func,
212
+
213
+ /**
214
+ * The upload status of the file if being sent to an external service (e.g., 'uploading', 'done')
215
+ */
216
+ // uploadStatus:PropTypes.oneOf(['uploading', 'done', 'failed']),
217
+
218
+ /**
219
+ * The alignment for file previews WRT the upload input
220
+ */
221
+ filePreviewAlignment: _propTypes.default.oneOf(['left', 'right', 'top', 'bottom'])
222
+ };
223
+ FileUpload.defaultProps = {
224
+ disabled: false,
225
+ color: 'paragraph',
226
+ filePreviewAlignment: 'bottom'
227
+ };
228
+ var _default = exports.default = FileUpload;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
10
+ require("./styles.scss");
11
+ var _a = require("../../../../../a");
12
+ var _b = require("../../../../../b");
13
+ var _fileUploadOptions = require("../../fileUploadOptions");
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
18
+
19
+ // Local Definitions
20
+
21
+ const baseClassName = _exports.default.base;
22
+ const componentClassName = 'file-preview';
23
+ const getFileType = file => {
24
+ const mimeType = file.type;
25
+ const extension = file.name.split('.').pop().toLowerCase();
26
+ const fileType = _fileUploadOptions.fileUploadOptions.find(option => option.value.includes(mimeType) || option.value.includes(extension));
27
+ return fileType ? fileType.key : 'unknown';
28
+ };
29
+
30
+ /**
31
+ * This is the component description.
32
+ */
33
+ const FilePreview = _ref => {
34
+ let {
35
+ id,
36
+ className: userClassName,
37
+ style,
38
+ file,
39
+ disabled,
40
+ handleDelete
41
+ // ...otherProps
42
+ } = _ref;
43
+ const type = getFileType(file);
44
+ return /*#__PURE__*/React.createElement("div", {
45
+ id: id,
46
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
47
+ style: style
48
+ }, /*#__PURE__*/React.createElement("div", {
49
+ className: "identity"
50
+ }, /*#__PURE__*/React.createElement("span", {
51
+ className: ['type', type.toLowerCase()].filter(e => e).join(' ')
52
+ }, type), /*#__PURE__*/React.createElement("span", {
53
+ title: file.name,
54
+ className: "name"
55
+ }, file.name), /*#__PURE__*/React.createElement(_b.Button, {
56
+ isCompact: true,
57
+ isSimple: true,
58
+ onClick: handleDelete
59
+ }, /*#__PURE__*/React.createElement("span", {
60
+ className: "icon x-ui-icons c-x"
61
+ }, "Y"))), !disabled && /*#__PURE__*/React.createElement("div", {
62
+ className: "progress-status"
63
+ }, /*#__PURE__*/React.createElement("div", {
64
+ className: "status"
65
+ }, /*#__PURE__*/React.createElement("span", {
66
+ className: "icon"
67
+ }, "I"), /*#__PURE__*/React.createElement("span", null, "Uploaded")), /*#__PURE__*/React.createElement(_a.ProgressBar, {
68
+ color: "green",
69
+ progress: 100,
70
+ height: "3px"
71
+ })));
72
+ };
73
+ FilePreview.propTypes = {
74
+ /**
75
+ * The HTML id for this element
76
+ */
77
+ id: _propTypes.default.string,
78
+ /**
79
+ * The HTML class names for this element
80
+ */
81
+ className: _propTypes.default.string,
82
+ /**
83
+ * The React-written, css properties for this element.
84
+ */
85
+ style: _propTypes.default.objectOf(_propTypes.default.string)
86
+ };
87
+ FilePreview.defaultProps = {
88
+ // someProp:false
89
+ };
90
+ var _default = exports.default = FilePreview;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "FilePreview", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _FilePreview.default;
10
+ }
11
+ });
12
+ var _FilePreview = _interopRequireDefault(require("./FilePreview"));
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,92 @@
1
+ /* @pareto-engineering/generator-front 1.1.1-alpha.2 */
2
+
3
+ @use "@pareto-engineering/bem";
4
+
5
+ $default-padding: 1rem;
6
+ $files-per-row: 3;
7
+ $total-gaps: $files-per-row - 1;
8
+ $combined-gap: calc(var(--gap) * $total-gaps);
9
+ $width-without-gaps: calc(100% - $combined-gap);
10
+ $default-file-width: calc($width-without-gaps / $files-per-row);
11
+
12
+ .#{bem.$base}.file-preview {
13
+ border: var(--theme-default-border-style) var(--ui-lines);
14
+ border-radius: calc(var(--theme-default-border-radius) / 2);
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: calc(var(--gap) / 4);
18
+ padding: $default-padding;
19
+ width: $default-file-width;
20
+
21
+ > .identity {
22
+ align-items: center;
23
+ display: flex;
24
+ gap: calc(var(--gap) / 2);
25
+
26
+ > .type {
27
+ padding-block: calc($default-padding / 4);
28
+ padding-inline: calc($default-padding / 2);
29
+
30
+ // TODO: update the colors to use variables. These are colors from the new DS
31
+ &.pdf {
32
+ background-color: #fdead7;
33
+ color: #b93814;
34
+ }
35
+
36
+ &.file {
37
+ background-color: #eef2f6;
38
+ color: #364151;
39
+ }
40
+
41
+ &.txt {
42
+ background-color: #d1dfff;
43
+ color: #004eeb;
44
+ }
45
+
46
+
47
+ &.vid {
48
+ background-color: #ebe9fe;
49
+ color: #5a25dc;
50
+ }
51
+
52
+ &.img {
53
+ background-color: #cbfbef;
54
+ color: #107569;
55
+ }
56
+
57
+ &.aud {
58
+ background-color: #fef7c3;
59
+ color: #a15c08;
60
+ }
61
+ }
62
+
63
+ > .name {
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ white-space: nowrap;
67
+ }
68
+
69
+ > .#{bem.$base}.button {
70
+ cursor: pointer;
71
+ margin-left: auto;
72
+ }
73
+ }
74
+
75
+ > .progress-status {
76
+ > .status {
77
+ align-items: center;
78
+ // TODO handle as a prop
79
+ color: var(--green);
80
+ display: flex;
81
+ gap: calc(var(--gap) / 2);
82
+
83
+ > .icon {
84
+ background-color: var(--green);
85
+ border-radius: 50%;
86
+ color: var(--on-green);
87
+ font-size: calc(var(--s-2) * 1rem);
88
+ padding: calc($default-padding / 4);
89
+ }
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "FilePreview", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _FilePreview.FilePreview;
10
+ }
11
+ });
12
+ var _FilePreview = require("./FilePreview");
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fileUploadOptions = void 0;
7
+ const fileUploadOptions = exports.fileUploadOptions = [{
8
+ key: 'FILE',
9
+ value: '.doc,.docx,.odt,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text',
10
+ label: 'Documents'
11
+ }, {
12
+ key: 'TXT',
13
+ value: '.xls,.xlsx,.ods,.csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.oasis.opendocument.spreadsheet,text/csv',
14
+ label: 'Spreadsheets'
15
+ }, {
16
+ key: 'PDF',
17
+ value: '.pdf,application/pdf',
18
+ label: 'PDF'
19
+ }, {
20
+ key: 'VID',
21
+ value: '.mp4,.ogg,.webm,video/mp4,video/ogg,video/webm',
22
+ label: 'Videos'
23
+ }, {
24
+ key: 'IMG',
25
+ value: '.png,.jpeg,.jpg,.gif,.webp,image/png,image/jpeg,image/gif,image/webp',
26
+ label: 'Images'
27
+ }, {
28
+ key: 'AUD',
29
+ value: '.mp3,.ogg,.wav,audio/mpeg,audio/ogg,audio/wav',
30
+ label: 'Audio'
31
+ }];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "FileUpload", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _FileUpload.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "fileUploadOptions", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _fileUploadOptions.fileUploadOptions;
16
+ }
17
+ });
18
+ var _FileUpload = _interopRequireDefault(require("./FileUpload"));
19
+ var _fileUploadOptions = require("./fileUploadOptions");
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }