@luscii-healthtech/web-ui 25.0.0 → 25.1.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/dist/components/FileUpload/FileUpload.d.ts +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.development.js +55 -0
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type FileUploadProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The file types that the input should accept.
|
|
5
|
+
*/
|
|
6
|
+
accept?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The maximum size of the file in MBs.
|
|
9
|
+
*/
|
|
10
|
+
maxFileSize?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The name of the field input.
|
|
13
|
+
*/
|
|
14
|
+
name?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The id of the field input.
|
|
17
|
+
* To be used with a `<label htmlFor={id}>`.
|
|
18
|
+
*/
|
|
19
|
+
id?: string;
|
|
20
|
+
onChange?: (file: File) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Disallow the user to change the file input value.
|
|
23
|
+
*/
|
|
24
|
+
isDisabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The text to be displayed on the button controlling the file input.
|
|
27
|
+
*
|
|
28
|
+
* @default "Upload a file"
|
|
29
|
+
*/
|
|
30
|
+
buttonText: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const FileUpload: React.FC<FileUploadProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -92,4 +92,5 @@ export { Dropzone, type DropzoneProps } from "./components/Dropzone";
|
|
|
92
92
|
export { FilterBar, FilterBarUtils } from "./components/FilterBar";
|
|
93
93
|
export { type Weekday, WeekdaysPicker, } from "./components/WeekdaysPicker/WeekdaysPicker";
|
|
94
94
|
export { default as DragHandle, type DragHandleProps, } from "./components/DragHandle";
|
|
95
|
+
export { FileUpload as File, type FileUploadProps as FileProps, } from "./components/FileUpload/FileUpload";
|
|
95
96
|
export { StatusIndicator } from "./components/StatusIndicator/StatusIndicator";
|
|
@@ -6016,6 +6016,60 @@ const WeekdaysPicker = (props) => {
|
|
|
6016
6016
|
WeekdaysPicker.weekdayNameToIndex = weekdayNameToIndex;
|
|
6017
6017
|
WeekdaysPicker.indexToWeekdayName = indexToWeekdayName;
|
|
6018
6018
|
|
|
6019
|
+
const FileUpload = React.forwardRef((props, ref) => {
|
|
6020
|
+
const { accept, maxFileSize, name, id, onChange, isDisabled = false, buttonText = "Upload a file" } = props, otherProps = __rest(props, ["accept", "maxFileSize", "name", "id", "onChange", "isDisabled", "buttonText"]);
|
|
6021
|
+
const [selectedFile, setSelectedFile] = React.useState(null);
|
|
6022
|
+
const fileUploadRef = React.useRef(null);
|
|
6023
|
+
const handleOnUploadClick = () => {
|
|
6024
|
+
var _a;
|
|
6025
|
+
(_a = fileUploadRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
6026
|
+
};
|
|
6027
|
+
const handleChangeEvent = (event) => {
|
|
6028
|
+
var _a;
|
|
6029
|
+
const uploadedFile = (_a = event.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
6030
|
+
if (uploadedFile) {
|
|
6031
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(uploadedFile);
|
|
6032
|
+
setSelectedFile(uploadedFile);
|
|
6033
|
+
}
|
|
6034
|
+
};
|
|
6035
|
+
const handleOnUnselectFile = () => {
|
|
6036
|
+
setSelectedFile(null);
|
|
6037
|
+
if (fileUploadRef.current) {
|
|
6038
|
+
fileUploadRef.current.value = "";
|
|
6039
|
+
}
|
|
6040
|
+
};
|
|
6041
|
+
if (selectedFile) {
|
|
6042
|
+
return React__namespace.default.createElement(UploadedFileSection, { file: selectedFile, onRemove: handleOnUnselectFile });
|
|
6043
|
+
}
|
|
6044
|
+
return React__namespace.default.createElement(
|
|
6045
|
+
FlexRow,
|
|
6046
|
+
null,
|
|
6047
|
+
React__namespace.default.createElement(SecondaryButton, { onClick: handleOnUploadClick }, buttonText),
|
|
6048
|
+
React__namespace.default.createElement("input", Object.assign({ type: "file", className: "ui-hidden", accept, size: maxFileSize ? maxFileSize * 1024 * 1024 : void 0, name, id, ref: (element) => {
|
|
6049
|
+
fileUploadRef.current = element;
|
|
6050
|
+
if (ref) {
|
|
6051
|
+
if (typeof ref === "function") {
|
|
6052
|
+
ref(element);
|
|
6053
|
+
} else {
|
|
6054
|
+
ref.current = element;
|
|
6055
|
+
}
|
|
6056
|
+
}
|
|
6057
|
+
}, onChange: handleChangeEvent, disabled: isDisabled }, otherProps))
|
|
6058
|
+
);
|
|
6059
|
+
});
|
|
6060
|
+
const UploadedFileSection = ({ file, onRemove }) => {
|
|
6061
|
+
return React__namespace.default.createElement(
|
|
6062
|
+
"div",
|
|
6063
|
+
{ className: "ui-inline-block ui-flex-row ui-rounded-lg ui-bg-blue-100" },
|
|
6064
|
+
React__namespace.default.createElement(
|
|
6065
|
+
Stack,
|
|
6066
|
+
{ axis: "x", justify: "center", align: "center", gap: "xxxs", py: "xxs", px: "m", title: file.name },
|
|
6067
|
+
React__namespace.default.createElement(Text, { truncate: true, className: "ui-max-w-55" }, file.name),
|
|
6068
|
+
React__namespace.default.createElement(TertiaryButton, { icon: "TrashBinIcon", onClick: onRemove })
|
|
6069
|
+
)
|
|
6070
|
+
);
|
|
6071
|
+
};
|
|
6072
|
+
|
|
6019
6073
|
const StatusIndicator = (props) => {
|
|
6020
6074
|
const { status, children } = props;
|
|
6021
6075
|
return React__namespace.default.createElement(
|
|
@@ -6100,6 +6154,7 @@ exports.EyeClosedIcon = EyeClosedIcon;
|
|
|
6100
6154
|
exports.EyeIcon = EyeOpenIcon;
|
|
6101
6155
|
exports.EyeIconSlashed = EyeClosedIcon;
|
|
6102
6156
|
exports.EyeOpenIcon = EyeOpenIcon;
|
|
6157
|
+
exports.File = FileUpload;
|
|
6103
6158
|
exports.FilterBar = FilterBar;
|
|
6104
6159
|
exports.FilterBarUtils = FilterBar_utils;
|
|
6105
6160
|
exports.FilterIcon = FilterIcon;
|