@veritone-ce/design-system 2.7.5 → 2.8.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/cjs/FileUploader/controlled.js +310 -0
- package/dist/cjs/FileUploader/styles.module.scss.js +1 -1
- package/dist/cjs/index.js +8 -8
- package/dist/cjs/styles.css +1 -1
- package/dist/cjs/unstable/LinearProgress/index.js +41 -0
- package/dist/cjs/unstable/LinearProgress/styles.module.scss.js +7 -0
- package/dist/cjs/unstable/extras/forms/index.js +4 -0
- package/dist/cjs/unstable/extras/forms/select.js +36 -30
- package/dist/cjs/unstable/extras/forms/upload.js +103 -0
- package/dist/cjs/unstable/index.js +11 -9
- package/dist/esm/FileUploader/controlled.js +304 -0
- package/dist/esm/FileUploader/styles.module.scss.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/styles.css +1 -1
- package/dist/esm/unstable/LinearProgress/index.js +37 -0
- package/dist/esm/unstable/LinearProgress/styles.module.scss.js +3 -0
- package/dist/esm/unstable/extras/forms/index.js +2 -1
- package/dist/esm/unstable/extras/forms/select.js +36 -31
- package/dist/esm/unstable/extras/forms/upload.js +100 -0
- package/dist/esm/unstable/index.js +1 -0
- package/dist/types/FileUploader/controlled.d.ts +59 -0
- package/dist/types/FileUploader/index.d.ts +1 -1
- package/dist/types/Table/AutoTable/common.d.ts +1 -1
- package/dist/types/Table/AutoTable/index.d.ts +1 -1
- package/dist/types/extras/uploady/uploady.d.ts +30 -0
- package/dist/types/unstable/LinearProgress/index.d.ts +14 -0
- package/dist/types/unstable/extras/forms/button.d.ts +3 -3
- package/dist/types/unstable/extras/forms/checkbox.d.ts +2 -2
- package/dist/types/unstable/extras/forms/index.d.ts +1 -0
- package/dist/types/unstable/extras/forms/input.d.ts +2 -2
- package/dist/types/unstable/extras/forms/select.d.ts +6 -3
- package/dist/types/unstable/extras/forms/shared.d.ts +4 -4
- package/dist/types/unstable/extras/forms/textarea.d.ts +2 -2
- package/dist/types/unstable/extras/forms/upload.d.ts +13 -0
- package/dist/types/unstable/index.d.ts +2 -0
- package/package.json +8 -5
- package/dist/cjs/FileUploader/components.js +0 -262
- package/dist/esm/FileUploader/components.js +0 -256
- package/dist/types/FileUploader/components.d.ts +0 -41
|
@@ -3,7 +3,7 @@ import type { ColumnDef, ColumnHelper } from './types.js';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export declare function createColumnHelper<TData extends RowData, TMeta = unknown>(): ColumnHelper<TData, TMeta>;
|
|
5
5
|
export type AutoTableHookOptions<TData, TMeta = unknown> = {
|
|
6
|
-
data: TData[]
|
|
6
|
+
data: TData[] | ReadonlyArray<TData>;
|
|
7
7
|
columns: ColumnDef<TData, TMeta>[];
|
|
8
8
|
meta?: TMeta;
|
|
9
9
|
getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;
|
|
@@ -4,7 +4,7 @@ import type { ColumnDef } from './types.js';
|
|
|
4
4
|
import { type ErrorContainer as ErrorContainerType } from './common.js';
|
|
5
5
|
export { createColumnHelper } from './common.js';
|
|
6
6
|
export type AutoTableProps<TData, TMeta = unknown> = {
|
|
7
|
-
data: TData[]
|
|
7
|
+
data: TData[] | ReadonlyArray<TData>;
|
|
8
8
|
columns: ColumnDef<TData, TMeta>[];
|
|
9
9
|
meta?: TMeta;
|
|
10
10
|
getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BATCH_STATES, type BatchItem } from '@rpldy/uploady';
|
|
3
|
+
import { type ButtonProps } from '../../Button/index.js';
|
|
4
|
+
import { type UploadDropzoneOptions, type UploadListContainerProps } from '../../FileUploader/index.js';
|
|
5
|
+
export type UploadyDropzoneProps = Omit<UploadDropzoneOptions, 'multiple'>;
|
|
6
|
+
export declare function UploadyDropzone(props: UploadyDropzoneProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export type UploadyListProps = UploadListContainerProps;
|
|
8
|
+
export declare function UploadyList(props: UploadyListProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export type UploadyListItemProps = {
|
|
10
|
+
item: BatchItem;
|
|
11
|
+
};
|
|
12
|
+
export declare function UploadyListItem({ item }: UploadyListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export type UploadyButtonProps = ButtonProps;
|
|
14
|
+
export declare function useUploadStatus(): {
|
|
15
|
+
loading: boolean;
|
|
16
|
+
itemCount: number;
|
|
17
|
+
batchState: BATCH_STATES;
|
|
18
|
+
};
|
|
19
|
+
export declare const UploadyButton: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
|
|
20
|
+
variant?: import("../../Button/index.js").ButtonVariant | undefined;
|
|
21
|
+
palette?: import("../../index.js").PaletteActionVariantsColors | import("../../styles/css-vars.js").RecursiveStringObject<import("../../index.js").PaletteActionVariantsColors> | undefined;
|
|
22
|
+
size?: import("../../Button/index.js").ButtonSize | undefined;
|
|
23
|
+
disabled?: boolean | undefined;
|
|
24
|
+
loading?: boolean | undefined;
|
|
25
|
+
active?: boolean | undefined;
|
|
26
|
+
startIcon?: React.ReactNode;
|
|
27
|
+
endIcon?: React.ReactNode;
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
'data-testid'?: string | undefined;
|
|
30
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type LinearProgressProps = {
|
|
3
|
+
/**
|
|
4
|
+
* The value of the progress indicator.
|
|
5
|
+
* Value between 0 and 100.
|
|
6
|
+
*/
|
|
7
|
+
value?: number;
|
|
8
|
+
variant?: 'determinate' | 'indeterminate';
|
|
9
|
+
color?: string;
|
|
10
|
+
'data-testid'?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
};
|
|
14
|
+
export default function LinearProgress({ value, variant, className, ...props }: LinearProgressProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Control, FieldValues } from 'react-hook-form';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { ButtonProps } from '../../../Button/index.js';
|
|
4
|
-
export type FormSubmitButtonProps<
|
|
5
|
-
control: Control<
|
|
4
|
+
export type FormSubmitButtonProps<TFieldValues extends FieldValues> = ButtonProps & {
|
|
5
|
+
control: Control<TFieldValues>;
|
|
6
6
|
contentWhenSubmitted?: ReactNode;
|
|
7
7
|
};
|
|
8
|
-
export declare function FormSubmitButton<
|
|
8
|
+
export declare function FormSubmitButton<TFieldValues extends FieldValues>({ control, contentWhenSubmitted, ...props }: FormSubmitButtonProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldValues, UseControllerProps } from 'react-hook-form';
|
|
2
2
|
import type { FormControlProps } from '../../../FormControl/index.js';
|
|
3
3
|
import { CheckboxProps } from '../../../Checkbox/index.js';
|
|
4
|
-
export type FormCheckboxProps<
|
|
5
|
-
export declare function FormCheckbox<
|
|
4
|
+
export type FormCheckboxProps<TFieldValues extends FieldValues> = UseControllerProps<TFieldValues> & FormControlProps & Omit<CheckboxProps, 'checked'>;
|
|
5
|
+
export declare function FormCheckbox<TFieldValues extends FieldValues>(props: FormCheckboxProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldValues, UseControllerProps } from 'react-hook-form';
|
|
2
2
|
import type { FormControlProps } from '../../../FormControl/index.js';
|
|
3
3
|
import { InputProps } from '../../../Input/index.js';
|
|
4
|
-
export type FormInputProps<
|
|
5
|
-
export declare function FormInput<
|
|
4
|
+
export type FormInputProps<TFieldValues extends FieldValues> = UseControllerProps<TFieldValues> & FormControlProps & InputProps;
|
|
5
|
+
export declare function FormInput<TFieldValues extends FieldValues>(props: FormInputProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { FieldValues, UseControllerProps } from 'react-hook-form';
|
|
1
|
+
import { type FieldPathByValue, FieldValues, UseControllerProps } from 'react-hook-form';
|
|
2
2
|
import type { FormControlProps } from '../../../FormControl/index.js';
|
|
3
3
|
import { SelectProps } from '../../../Select/index.js';
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
import type { ComponentType } from 'react';
|
|
5
|
+
export type FormSelectControlledProps<OptionValue, Multiple extends boolean | undefined> = Pick<SelectProps<OptionValue, Multiple>, 'value' | 'onChange'>;
|
|
6
|
+
export type FormSelectProps<TFieldValues extends FieldValues, OptionValue, Multiple extends boolean | undefined, S extends FormSelectControlledProps<OptionValue, Multiple>, TName extends FieldPathByValue<TFieldValues, OptionValue | OptionValue[]> = FieldPathByValue<TFieldValues, OptionValue | OptionValue[]>> = UseControllerProps<TFieldValues, TName> & FormControlProps & S;
|
|
7
|
+
export declare function formSelectFactory<OptionValue, Multiple extends boolean | undefined = boolean | undefined, S extends FormSelectControlledProps<OptionValue, Multiple> = FormSelectControlledProps<OptionValue, Multiple>>(Component: ComponentType<S>): <TFieldValues extends FieldValues, TName extends FieldPathByValue<TFieldValues, OptionValue | OptionValue[]> = FieldPathByValue<TFieldValues, OptionValue | OptionValue[]>>(props: FormSelectProps<TFieldValues, OptionValue, Multiple, S, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const FormSelect: <TFieldValues extends FieldValues, TName extends FieldPathByValue<TFieldValues, unknown> = FieldPathByValue<TFieldValues, unknown>>(props: FormSelectProps<TFieldValues, unknown, boolean | undefined, SelectProps<unknown, boolean | undefined>, TName>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FieldError, FieldValues, UseControllerProps } from 'react-hook-form';
|
|
1
|
+
import { FieldError, FieldValues, UseControllerProps, FieldPath } from 'react-hook-form';
|
|
2
2
|
import type { FormControlProps } from '../../../FormControl/index.js';
|
|
3
3
|
export declare function useFormErrorMessage(error: FieldError | undefined): string | undefined;
|
|
4
|
-
export declare function extractControllerProps<
|
|
5
|
-
controllerProps: UseControllerProps<
|
|
4
|
+
export declare function extractControllerProps<TFieldValues extends FieldValues, I, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>, TTransformedValues = TFieldValues>(props: UseControllerProps<TFieldValues, TName, TTransformedValues> & FormControlProps & I): {
|
|
5
|
+
controllerProps: UseControllerProps<TFieldValues, TName, TTransformedValues>;
|
|
6
6
|
formControlProps: FormControlProps;
|
|
7
|
-
inputProps:
|
|
7
|
+
inputProps: I;
|
|
8
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldValues, UseControllerProps } from 'react-hook-form';
|
|
2
2
|
import { type FormControlProps } from '../../../FormControl/index.js';
|
|
3
3
|
import { type TextareaProps } from '../../../Textarea/index.js';
|
|
4
|
-
export type FormTextareaProps<
|
|
5
|
-
export declare function FormTextarea<
|
|
4
|
+
export type FormTextareaProps<TFieldValues extends FieldValues> = UseControllerProps<TFieldValues> & FormControlProps & TextareaProps;
|
|
5
|
+
export declare function FormTextarea<TFieldValues extends FieldValues>(props: FormTextareaProps<TFieldValues>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type FieldPathByValue, FieldValues, UseControllerProps } from 'react-hook-form';
|
|
2
|
+
import type { FormControlProps } from '../../../FormControl/index.js';
|
|
3
|
+
import { type FileLike, type FileState, type UploadDropzoneProps, type UploadListItemState, type UploadListProps } from '../../../FileUploader/index.js';
|
|
4
|
+
type FilesFieldPath<TFieldValues extends FieldValues, F extends FileLike = FileLike> = FieldPathByValue<TFieldValues, F[]>;
|
|
5
|
+
type FormUploadDropzoneInputProps = Partial<UploadDropzoneProps> & Omit<UploadDropzoneProps, 'onDrop'>;
|
|
6
|
+
export type FormUploadDropzoneProps<TFieldValues extends FieldValues, TName extends FilesFieldPath<TFieldValues> = FilesFieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TName> & FormControlProps & FormUploadDropzoneInputProps;
|
|
7
|
+
export declare function FormUploadDropzone<TFieldValues extends FieldValues, TName extends FilesFieldPath<TFieldValues> = FilesFieldPath<TFieldValues>>(props: FormUploadDropzoneProps<TFieldValues, TName>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
type FormUploadListInputProps<F extends FileLike> = Omit<UploadListProps<F>, 'items'> & {
|
|
9
|
+
state: FileState | UploadListItemState | Array<UploadListItemState>;
|
|
10
|
+
};
|
|
11
|
+
export type FormUploadListProps<TFieldValues extends FieldValues, F extends FileLike = FileLike, TName extends FilesFieldPath<TFieldValues, F> = FilesFieldPath<TFieldValues, F>> = UseControllerProps<TFieldValues, TName> & FormControlProps & FormUploadListInputProps<F>;
|
|
12
|
+
export declare function FormUploadList<TFieldValues extends FieldValues, F extends FileLike = FileLike, TName extends FilesFieldPath<TFieldValues, F> = FilesFieldPath<TFieldValues, F>>(props: FormUploadListProps<TFieldValues, F, TName>): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './Breadcrumbs/index.js';
|
|
2
2
|
export { default as Card } from './Card/index.js';
|
|
3
3
|
export * from './Card/index.js';
|
|
4
|
+
export { default as LinearProgress } from './LinearProgress/index.js';
|
|
5
|
+
export * from './LinearProgress/index.js';
|
|
4
6
|
export { default as Tabs } from './Tabs/index.js';
|
|
5
7
|
export * from './Tabs/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veritone-ce/design-system",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Design System for Veritone CE",
|
|
6
6
|
"keywords": [
|
|
@@ -116,8 +116,6 @@
|
|
|
116
116
|
"@floating-ui/react": "^0.26.6",
|
|
117
117
|
"@fontsource/nunito-sans": "5.1.1",
|
|
118
118
|
"@mui/utils": "^7.2.0",
|
|
119
|
-
"@rpldy/uploader": "^1.8.1",
|
|
120
|
-
"@rpldy/uploady": "^1.8.1",
|
|
121
119
|
"@tanstack/react-table": "^8.10.7",
|
|
122
120
|
"@tanstack/react-virtual": "^v3.0.0-beta.68",
|
|
123
121
|
"color2k": "^2.0.3",
|
|
@@ -139,6 +137,7 @@
|
|
|
139
137
|
"@mui/material": "^5.10.8",
|
|
140
138
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
141
139
|
"@rpldy/mock-sender": "^1.8.1",
|
|
140
|
+
"@rpldy/uploady": "^1.8.1",
|
|
142
141
|
"@storybook/addon-a11y": "9.0.16",
|
|
143
142
|
"@storybook/addon-docs": "^9.0.16",
|
|
144
143
|
"@storybook/addon-links": "9.0.16",
|
|
@@ -202,11 +201,12 @@
|
|
|
202
201
|
"@emotion/styled": "^11.10.4",
|
|
203
202
|
"@mui/icons-material": "^5.10.6",
|
|
204
203
|
"@mui/material": "^5.10.8",
|
|
204
|
+
"@rpldy/uploady": "^1.8.1",
|
|
205
|
+
"jotai": "^2.12.5",
|
|
205
206
|
"react": "^18||^19",
|
|
206
207
|
"react-dom": "^18||^19",
|
|
207
208
|
"react-hook-form": "^7.60.0",
|
|
208
|
-
"react-markdown": "^10.1.0"
|
|
209
|
-
"jotai": "^2.12.5"
|
|
209
|
+
"react-markdown": "^10.1.0"
|
|
210
210
|
},
|
|
211
211
|
"readme": "ERROR: No README data found!",
|
|
212
212
|
"publishConfig": {
|
|
@@ -226,6 +226,9 @@
|
|
|
226
226
|
},
|
|
227
227
|
"jotai": {
|
|
228
228
|
"optional": true
|
|
229
|
+
},
|
|
230
|
+
"@rpldy/uploady": {
|
|
231
|
+
"optional": true
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
'use client';
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var iconsMaterial = require('@mui/icons-material');
|
|
8
|
-
var reactDropzone = require('react-dropzone');
|
|
9
|
-
var cx = require('../styles/cx.js');
|
|
10
|
-
require('../styles/defaultThemeOptions.js');
|
|
11
|
-
require('@capsizecss/core');
|
|
12
|
-
require('color2k');
|
|
13
|
-
require('../styles/defaultTheme.js');
|
|
14
|
-
require('../styles/provider.client.js');
|
|
15
|
-
require('../styles/css-vars.js');
|
|
16
|
-
var index$1 = require('../Typography/index.js');
|
|
17
|
-
var material = require('@mui/material');
|
|
18
|
-
var index$2 = require('../IconButton/index.js');
|
|
19
|
-
var wrappers = require('../Icon/wrappers.js');
|
|
20
|
-
require('../Icon/factory.js');
|
|
21
|
-
var styles_module = require('./styles.module.scss.js');
|
|
22
|
-
var uploady = require('@rpldy/uploady');
|
|
23
|
-
var index = require('../Button/index.js');
|
|
24
|
-
|
|
25
|
-
const CloudUploadOutlinedIcon = wrappers.adaptMuiSvgIcon(iconsMaterial.CloudUploadOutlined);
|
|
26
|
-
const DeleteOutlineIcon = wrappers.adaptMuiSvgIcon(iconsMaterial.DeleteOutline);
|
|
27
|
-
const CheckOutlineIcon = wrappers.adaptMuiSvgIcon(iconsMaterial.CheckOutlined);
|
|
28
|
-
const WarningOutlineIcon = wrappers.adaptMuiSvgIcon(iconsMaterial.WarningOutlined);
|
|
29
|
-
function UploadDropzone(props) {
|
|
30
|
-
const disabled = props.disabled ?? false;
|
|
31
|
-
const { upload, getOptions } = uploady.useUploady();
|
|
32
|
-
const [batchState, setBatchState] = React.useState(
|
|
33
|
-
uploady.BATCH_STATES.PENDING
|
|
34
|
-
);
|
|
35
|
-
const [progress, setProgress] = React.useState(0);
|
|
36
|
-
const [hasError, setHasError] = React.useState(false);
|
|
37
|
-
uploady.useBatchFinalizeListener((batch) => {
|
|
38
|
-
setBatchState(batch.state);
|
|
39
|
-
setHasError(batch.items.some((item) => item.state === uploady.FILE_STATES.ERROR));
|
|
40
|
-
});
|
|
41
|
-
uploady.useBatchProgressListener((batch) => {
|
|
42
|
-
setBatchState(batch.state);
|
|
43
|
-
setProgress(batch.completed);
|
|
44
|
-
});
|
|
45
|
-
const { getRootProps, getInputProps } = reactDropzone.useDropzone({
|
|
46
|
-
disabled,
|
|
47
|
-
multiple: !getOptions().autoUpload,
|
|
48
|
-
accept: props.accept,
|
|
49
|
-
onDrop: (files) => {
|
|
50
|
-
upload(files);
|
|
51
|
-
setProgress(0);
|
|
52
|
-
setBatchState(uploady.BATCH_STATES.PENDING);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
56
|
-
"div",
|
|
57
|
-
{
|
|
58
|
-
"data-testid": props["data-testid"] ?? "dropzone",
|
|
59
|
-
"data-disabled": disabled,
|
|
60
|
-
"data-mini": props.mini,
|
|
61
|
-
style: props.style,
|
|
62
|
-
className: cx.cx(styles_module.default.dropzone, props.className),
|
|
63
|
-
...getRootProps(),
|
|
64
|
-
children: [
|
|
65
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "file", className: styles_module.default.input, ...getInputProps() }),
|
|
66
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles_module.default.uploadIconContainer, children: [
|
|
67
|
-
batchState === uploady.BATCH_STATES.FINISHED ? hasError ? /* @__PURE__ */ jsxRuntime.jsx(WarningOutlineIcon, { className: styles_module.default.icon }) : /* @__PURE__ */ jsxRuntime.jsx(CheckOutlineIcon, { className: styles_module.default.icon }) : /* @__PURE__ */ jsxRuntime.jsx(CloudUploadOutlinedIcon, { className: styles_module.default.icon }),
|
|
68
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
69
|
-
"svg",
|
|
70
|
-
{
|
|
71
|
-
viewBox: "0 0 250 250",
|
|
72
|
-
className: styles_module.default.uploadProgress,
|
|
73
|
-
style: {
|
|
74
|
-
...{
|
|
75
|
-
"--progress": progress,
|
|
76
|
-
"--error": hasError
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
children: [
|
|
80
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { className: styles_module.default.uploadProgressBg }),
|
|
81
|
-
progress > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
82
|
-
"circle",
|
|
83
|
-
{
|
|
84
|
-
"data-success": batchState === uploady.BATCH_STATES.FINISHED,
|
|
85
|
-
"data-error": hasError,
|
|
86
|
-
className: styles_module.default.uploadProgressFg
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
)
|
|
92
|
-
] }),
|
|
93
|
-
!props.mini && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
94
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
95
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
96
|
-
index$1.default,
|
|
97
|
-
{
|
|
98
|
-
as: "span",
|
|
99
|
-
variant: "paragraph2",
|
|
100
|
-
className: styles_module.default.browseLabel,
|
|
101
|
-
children: "Browse files"
|
|
102
|
-
}
|
|
103
|
-
),
|
|
104
|
-
/* @__PURE__ */ jsxRuntime.jsxs(index$1.default, { as: "span", variant: "paragraph2", children: [
|
|
105
|
-
" ",
|
|
106
|
-
"from your computer or drag and drop here"
|
|
107
|
-
] })
|
|
108
|
-
] }),
|
|
109
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
110
|
-
index$1.default,
|
|
111
|
-
{
|
|
112
|
-
as: "p",
|
|
113
|
-
variant: "paragraph3",
|
|
114
|
-
className: styles_module.default.fileFormatLabel,
|
|
115
|
-
children: [
|
|
116
|
-
"Supported File Formats:",
|
|
117
|
-
" ",
|
|
118
|
-
Object.values(props.accept).flat().join(", ")
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
] })
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
function UploadList(props) {
|
|
128
|
-
const [items, setItems] = React.useState([]);
|
|
129
|
-
uploady.useBatchAddListener((batch) => {
|
|
130
|
-
setItems((items2) => items2.concat(batch.items));
|
|
131
|
-
});
|
|
132
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
-
"div",
|
|
134
|
-
{
|
|
135
|
-
"data-testid": props["data-testid"],
|
|
136
|
-
style: props.style,
|
|
137
|
-
className: cx.cx(styles_module.default.uploadsContainer, props.className),
|
|
138
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("table", { className: styles_module.default.uploads, children: /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(UploadListItem, { item }, index)) }) })
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
function UploadListItem({ item }) {
|
|
143
|
-
const [itemState, setState] = React.useState(item.state);
|
|
144
|
-
const [progress, setProgress] = React.useState(0);
|
|
145
|
-
const abortItem = uploady.useAbortItem();
|
|
146
|
-
uploady.useItemFinalizeListener((item2) => {
|
|
147
|
-
setState(item2.state);
|
|
148
|
-
}, item.id);
|
|
149
|
-
uploady.useItemProgressListener((item2) => {
|
|
150
|
-
setProgress(item2.completed);
|
|
151
|
-
});
|
|
152
|
-
const isAborted = itemState === uploady.FILE_STATES.ABORTED;
|
|
153
|
-
const isSuccess = itemState === uploady.FILE_STATES.FINISHED;
|
|
154
|
-
const isError = itemState === uploady.FILE_STATES.ERROR;
|
|
155
|
-
const isFinished = ![uploady.FILE_STATES.PENDING, uploady.FILE_STATES.UPLOADING].includes(
|
|
156
|
-
itemState
|
|
157
|
-
);
|
|
158
|
-
const onAbortItem = () => {
|
|
159
|
-
abortItem(item.id);
|
|
160
|
-
};
|
|
161
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("tr", { "data-testid": "file-item", className: styles_module.default.lineItem, children: [
|
|
162
|
-
/* @__PURE__ */ jsxRuntime.jsxs("td", { children: [
|
|
163
|
-
/* @__PURE__ */ jsxRuntime.jsx(index$1.default, { as: "p", variant: "label", className: styles_module.default.label, children: item.file.name }),
|
|
164
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
165
|
-
"span",
|
|
166
|
-
{
|
|
167
|
-
className: styles_module.default.progressBar,
|
|
168
|
-
"data-success": isSuccess,
|
|
169
|
-
"data-error": isError,
|
|
170
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
171
|
-
material.LinearProgress,
|
|
172
|
-
{
|
|
173
|
-
value: progress,
|
|
174
|
-
variant: "determinate",
|
|
175
|
-
color: "inherit"
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
),
|
|
180
|
-
isError && /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
-
index$1.default,
|
|
182
|
-
{
|
|
183
|
-
as: "p",
|
|
184
|
-
variant: "paragraph3",
|
|
185
|
-
className: styles_module.default.feedbackText,
|
|
186
|
-
children: "An error occurred."
|
|
187
|
-
}
|
|
188
|
-
)
|
|
189
|
-
] }),
|
|
190
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: styles_module.default.deleteBtn, children: isFinished ? isSuccess ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
191
|
-
index$2.default,
|
|
192
|
-
{
|
|
193
|
-
"data-testid": "file-item-success-button",
|
|
194
|
-
"aria-label": "success",
|
|
195
|
-
disabled: true,
|
|
196
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(CheckOutlineIcon, {})
|
|
197
|
-
}
|
|
198
|
-
) : isError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
199
|
-
index$2.default,
|
|
200
|
-
{
|
|
201
|
-
"data-testid": "file-item-error-button",
|
|
202
|
-
"aria-label": "error",
|
|
203
|
-
disabled: true,
|
|
204
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(WarningOutlineIcon, {})
|
|
205
|
-
}
|
|
206
|
-
) : !isAborted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
207
|
-
index$2.default,
|
|
208
|
-
{
|
|
209
|
-
"data-testid": "file-item-delete-button",
|
|
210
|
-
"aria-label": "delete",
|
|
211
|
-
onClick: onAbortItem,
|
|
212
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DeleteOutlineIcon, {})
|
|
213
|
-
}
|
|
214
|
-
) : null : null })
|
|
215
|
-
] });
|
|
216
|
-
}
|
|
217
|
-
function useUploadStatus() {
|
|
218
|
-
const [batchState, setBatchState] = React.useState(
|
|
219
|
-
uploady.BATCH_STATES.PENDING
|
|
220
|
-
);
|
|
221
|
-
const [itemCount, setItemCount] = React.useState(0);
|
|
222
|
-
uploady.useBatchAddListener((batch) => {
|
|
223
|
-
setItemCount(batch.total);
|
|
224
|
-
});
|
|
225
|
-
const [loading, setLoading] = React.useState(false);
|
|
226
|
-
uploady.useBatchStartListener(() => {
|
|
227
|
-
setLoading(true);
|
|
228
|
-
});
|
|
229
|
-
uploady.useBatchFinalizeListener((batch) => {
|
|
230
|
-
setLoading(false);
|
|
231
|
-
setBatchState(batch.state);
|
|
232
|
-
});
|
|
233
|
-
return { loading, itemCount, batchState };
|
|
234
|
-
}
|
|
235
|
-
const UploadButton = React.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
|
|
236
|
-
const { processPending } = uploady.useUploadyContext();
|
|
237
|
-
const { itemCount, batchState, loading } = useUploadStatus();
|
|
238
|
-
const onButtonClick = React.useCallback(
|
|
239
|
-
(e) => {
|
|
240
|
-
processPending();
|
|
241
|
-
onClick?.(e);
|
|
242
|
-
},
|
|
243
|
-
[processPending, onClick]
|
|
244
|
-
);
|
|
245
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
246
|
-
index.default,
|
|
247
|
-
{
|
|
248
|
-
ref,
|
|
249
|
-
onClick: onButtonClick,
|
|
250
|
-
disabled: disabled || itemCount === 0 || batchState === uploady.BATCH_STATES.FINISHED,
|
|
251
|
-
loading,
|
|
252
|
-
...props,
|
|
253
|
-
children: children || "Upload"
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
exports.UploadButton = UploadButton;
|
|
259
|
-
exports.UploadDropzone = UploadDropzone;
|
|
260
|
-
exports.UploadList = UploadList;
|
|
261
|
-
exports.UploadListItem = UploadListItem;
|
|
262
|
-
exports.useUploadStatus = useUploadStatus;
|