@conveyorhq/arrow-ds 1.54.0 → 1.55.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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@conveyorhq/arrow-ds",
3
3
  "author": "Conveyor",
4
4
  "license": "MIT",
5
- "version": "1.54.0",
5
+ "version": "1.55.0",
6
6
  "description": "Arrow Design System",
7
7
  "repository": "https://github.com/conveyor/arrow-ds",
8
8
  "publishConfig": {
@@ -2,7 +2,8 @@ import React, { HTMLProps } from "react";
2
2
  import { ButtonProps } from "../Button";
3
3
  export interface FileUploadProps extends React.HTMLProps<HTMLLabelElement> {
4
4
  inputProps: HTMLProps<HTMLInputElement>;
5
- buttonProps: ButtonProps;
5
+ buttonProps?: ButtonProps;
6
6
  label?: string;
7
+ hideFileLabel?: boolean;
7
8
  }
8
- export declare const FileUpload: ({ className, inputProps, buttonProps, label, ...rest }: FileUploadProps) => JSX.Element;
9
+ export declare const FileUpload: ({ className, inputProps, buttonProps, label, hideFileLabel, ...rest }: FileUploadProps) => JSX.Element;
@@ -31,7 +31,7 @@ const FormGroupContext_1 = require("../FormGroup/FormGroupContext");
31
31
  const Text_1 = require("../Text");
32
32
  const Truncate_1 = require("../Truncate");
33
33
  const cn = "FileUpload";
34
- const FileUpload = ({ className, inputProps = {}, buttonProps = {}, label = "Select file", ...rest }) => {
34
+ const FileUpload = ({ className, inputProps = {}, buttonProps = {}, label = "Select file", hideFileLabel, ...rest }) => {
35
35
  const inputRef = react_1.useRef(null);
36
36
  const { id: idProp, onChange, ...inputRest } = inputProps;
37
37
  const { id: idContext } = react_1.useContext(FormGroupContext_1.FormGroupContext);
@@ -63,7 +63,7 @@ const FileUpload = ({ className, inputProps = {}, buttonProps = {}, label = "Sel
63
63
  return (react_1.default.createElement("label", Object.assign({ htmlFor: id, className: classnames_1.default(bem_1.bem(cn), className) }, rest),
64
64
  react_1.default.createElement("input", Object.assign({ className: classnames_1.default(bem_1.bem(cn, { e: "input" })), ref: inputRef, type: "file", id: id, onChange: handleChange }, inputRest)),
65
65
  react_1.default.createElement(Button_1.Button, Object.assign({ className: classnames_1.default(bem_1.bem(cn, { e: "button" })), as: "div", variant: Button_1.BUTTON_VARIANT.SECONDARY }, buttonProps), label),
66
- react_1.default.createElement(Truncate_1.Truncate, null,
67
- react_1.default.createElement(Text_1.Text, { className: classnames_1.default(bem_1.bem(cn, { e: "fileLabel" })) }, fileLabel))));
66
+ !hideFileLabel && (react_1.default.createElement(Truncate_1.Truncate, null,
67
+ react_1.default.createElement(Text_1.Text, { className: classnames_1.default(bem_1.bem(cn, { e: "fileLabel" })) }, fileLabel)))));
68
68
  };
69
69
  exports.FileUpload = FileUpload;
@@ -6,6 +6,7 @@ interface FileUploadDndPropsBase extends Omit<HTMLProps<HTMLLabelElement>, "onCh
6
6
  label?: string;
7
7
  inputProps?: HTMLProps<HTMLInputElement>;
8
8
  buttonProps?: ButtonProps;
9
+ hideFileLabel?: boolean;
9
10
  }
10
11
  interface FileUploadDndPropsSingle extends FileUploadDndPropsBase {
11
12
  onChange: (file: File | null) => void;
@@ -35,7 +35,7 @@ const Text_1 = require("../Text");
35
35
  const Truncate_1 = require("../Truncate");
36
36
  const cn = utilities_1.bemHOF("FileUpload");
37
37
  const ERROR_TIMEOUT = 5000;
38
- const FileUploadInput = ({ inputProps, buttonProps, className, accept, label = "Select file", ...props }) => {
38
+ const FileUploadInput = ({ inputProps, buttonProps, className, accept, label = "Select file", hideFileLabel, ...props }) => {
39
39
  const inputRef = react_1.useRef(null);
40
40
  const { id: contextId } = react_1.useContext(FormGroupContext_1.FormGroupContext);
41
41
  const inputId = inputProps ? inputProps.id : undefined;
@@ -139,7 +139,10 @@ const FileUploadInput = ({ inputProps, buttonProps, className, accept, label = "
139
139
  return (react_1.default.createElement("label", Object.assign({ ref: drop, htmlFor: id, className: classnames_1.default(cn(), isActive && cn({ m: "active" }), className) }, labelRest),
140
140
  react_1.default.createElement("input", Object.assign({ className: classnames_1.default(cn({ e: "input" }), inputClassName), ref: inputRef, type: "file", id: id, multiple: props.multiple, accept: accept }, inputRest, { onChange: handleInputChange })),
141
141
  react_1.default.createElement(Button_1.Button, Object.assign({ className: classnames_1.default(cn({ e: "button" })), as: "div", variant: Button_1.BUTTON_VARIANT.SECONDARY }, buttonProps), label),
142
- react_1.default.createElement(Truncate_1.Truncate, { className: cn({ e: "truncate" }) }, errorText ? (react_1.default.createElement(Text_1.Text, { as: "span", className: cn({ e: "error" }) }, errorText)) : (react_1.default.createElement(Text_1.Text, { className: classnames_1.default(cn({ e: "fileLabel" })) }, fileLabel)))));
142
+ errorText && (react_1.default.createElement(Truncate_1.Truncate, { className: cn({ e: "truncate" }) },
143
+ react_1.default.createElement(Text_1.Text, { as: "span", className: cn({ e: "error" }) }, errorText))),
144
+ !hideFileLabel && (react_1.default.createElement(Truncate_1.Truncate, { className: cn({ e: "truncate" }) },
145
+ react_1.default.createElement(Text_1.Text, { className: classnames_1.default(cn({ e: "fileLabel" })) }, fileLabel)))));
143
146
  };
144
147
  const FileUploadDnD = (props) => {
145
148
  return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
@@ -10,8 +10,9 @@ const cn = "FileUpload";
10
10
 
11
11
  export interface FileUploadProps extends React.HTMLProps<HTMLLabelElement> {
12
12
  inputProps: HTMLProps<HTMLInputElement>;
13
- buttonProps: ButtonProps;
13
+ buttonProps?: ButtonProps;
14
14
  label?: string;
15
+ hideFileLabel?: boolean;
15
16
  }
16
17
 
17
18
  // @Deprecated
@@ -22,6 +23,7 @@ export const FileUpload = ({
22
23
  inputProps = {},
23
24
  buttonProps = {},
24
25
  label = "Select file",
26
+ hideFileLabel,
25
27
  ...rest
26
28
  }: FileUploadProps) => {
27
29
  const inputRef = useRef<HTMLInputElement>(null);
@@ -74,11 +76,13 @@ export const FileUpload = ({
74
76
  >
75
77
  {label}
76
78
  </Button>
77
- <Truncate>
78
- <Text className={classNames(bem(cn, { e: "fileLabel" }))}>
79
- {fileLabel}
80
- </Text>
81
- </Truncate>
79
+ {!hideFileLabel && (
80
+ <Truncate>
81
+ <Text className={classNames(bem(cn, { e: "fileLabel" }))}>
82
+ {fileLabel}
83
+ </Text>
84
+ </Truncate>
85
+ )}
82
86
  </label>
83
87
  );
84
88
  };
@@ -49,6 +49,10 @@ interface FileUploadDndPropsBase
49
49
  * Props passed directly to the underlying `<Button>` element.
50
50
  */
51
51
  buttonProps?: ButtonProps;
52
+ /**
53
+ * If true, text showing selected file name will not be shown. Errors will still be shown.
54
+ */
55
+ hideFileLabel?: boolean;
52
56
  }
53
57
 
54
58
  interface FileUploadDndPropsSingle extends FileUploadDndPropsBase {
@@ -88,6 +92,7 @@ const FileUploadInput = ({
88
92
  className,
89
93
  accept,
90
94
  label = "Select file",
95
+ hideFileLabel,
91
96
  ...props
92
97
  }: FileUploadDndProps) => {
93
98
  const inputRef = useRef<HTMLInputElement>(null);
@@ -246,17 +251,20 @@ const FileUploadInput = ({
246
251
  >
247
252
  {label}
248
253
  </Button>
249
- <Truncate className={cn({ e: "truncate" })}>
250
- {errorText ? (
254
+ {errorText && (
255
+ <Truncate className={cn({ e: "truncate" })}>
251
256
  <Text as="span" className={cn({ e: "error" })}>
252
257
  {errorText}
253
258
  </Text>
254
- ) : (
259
+ </Truncate>
260
+ )}
261
+ {!hideFileLabel && (
262
+ <Truncate className={cn({ e: "truncate" })}>
255
263
  <Text className={classNames(cn({ e: "fileLabel" }))}>
256
264
  {fileLabel}
257
265
  </Text>
258
- )}
259
- </Truncate>
266
+ </Truncate>
267
+ )}
260
268
  </label>
261
269
  );
262
270
  };