@veritone-ce/design-system 2.7.6 → 2.8.1

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 (39) hide show
  1. package/dist/cjs/FileUploader/controlled.js +310 -0
  2. package/dist/cjs/FileUploader/styles.module.scss.js +1 -1
  3. package/dist/cjs/index.js +8 -8
  4. package/dist/cjs/styles.css +1 -1
  5. package/dist/cjs/unstable/LinearProgress/index.js +41 -0
  6. package/dist/cjs/unstable/LinearProgress/styles.module.scss.js +7 -0
  7. package/dist/cjs/unstable/extras/forms/index.js +4 -0
  8. package/dist/cjs/unstable/extras/forms/select.js +36 -30
  9. package/dist/cjs/unstable/extras/forms/upload.js +103 -0
  10. package/dist/cjs/unstable/index.js +11 -9
  11. package/dist/esm/FileUploader/controlled.js +304 -0
  12. package/dist/esm/FileUploader/styles.module.scss.js +1 -1
  13. package/dist/esm/index.js +1 -1
  14. package/dist/esm/styles.css +1 -1
  15. package/dist/esm/unstable/LinearProgress/index.js +37 -0
  16. package/dist/esm/unstable/LinearProgress/styles.module.scss.js +3 -0
  17. package/dist/esm/unstable/extras/forms/index.js +2 -1
  18. package/dist/esm/unstable/extras/forms/select.js +36 -31
  19. package/dist/esm/unstable/extras/forms/upload.js +100 -0
  20. package/dist/esm/unstable/index.js +1 -0
  21. package/dist/types/FileUploader/controlled.d.ts +59 -0
  22. package/dist/types/FileUploader/index.d.ts +1 -1
  23. package/dist/types/Table/AutoTable/common.d.ts +1 -1
  24. package/dist/types/Table/AutoTable/index.d.ts +1 -1
  25. package/dist/types/extras/uploady/uploady.d.ts +30 -0
  26. package/dist/types/unstable/LinearProgress/index.d.ts +14 -0
  27. package/dist/types/unstable/extras/forms/button.d.ts +3 -3
  28. package/dist/types/unstable/extras/forms/checkbox.d.ts +2 -2
  29. package/dist/types/unstable/extras/forms/index.d.ts +1 -0
  30. package/dist/types/unstable/extras/forms/input.d.ts +2 -2
  31. package/dist/types/unstable/extras/forms/select.d.ts +6 -3
  32. package/dist/types/unstable/extras/forms/shared.d.ts +4 -4
  33. package/dist/types/unstable/extras/forms/textarea.d.ts +2 -2
  34. package/dist/types/unstable/extras/forms/upload.d.ts +13 -0
  35. package/dist/types/unstable/index.d.ts +2 -0
  36. package/package.json +8 -5
  37. package/dist/cjs/FileUploader/components.js +0 -262
  38. package/dist/esm/FileUploader/components.js +0 -256
  39. package/dist/types/FileUploader/components.d.ts +0 -41
@@ -1,256 +0,0 @@
1
- 'use strict';
2
- 'use client';
3
- import { jsx, jsxs } from 'react/jsx-runtime';
4
- import React__default, { useCallback, useState } from 'react';
5
- import { CloudUploadOutlined, DeleteOutline, CheckOutlined, WarningOutlined } from '@mui/icons-material';
6
- import { useDropzone } from 'react-dropzone';
7
- import { cx } from '../styles/cx.js';
8
- import '../styles/defaultThemeOptions.js';
9
- import '@capsizecss/core';
10
- import 'color2k';
11
- import '../styles/defaultTheme.js';
12
- import '../styles/provider.client.js';
13
- import '../styles/css-vars.js';
14
- import Typography from '../Typography/index.js';
15
- import { LinearProgress } from '@mui/material';
16
- import IconButton from '../IconButton/index.js';
17
- import { adaptMuiSvgIcon } from '../Icon/wrappers.js';
18
- import '../Icon/factory.js';
19
- import styles from './styles.module.scss.js';
20
- import { useUploadyContext, BATCH_STATES, useBatchAddListener, useBatchStartListener, useBatchFinalizeListener, useUploady, FILE_STATES, useBatchProgressListener, useAbortItem, useItemFinalizeListener, useItemProgressListener } from '@rpldy/uploady';
21
- import Button from '../Button/index.js';
22
-
23
- const CloudUploadOutlinedIcon = adaptMuiSvgIcon(CloudUploadOutlined);
24
- const DeleteOutlineIcon = adaptMuiSvgIcon(DeleteOutline);
25
- const CheckOutlineIcon = adaptMuiSvgIcon(CheckOutlined);
26
- const WarningOutlineIcon = adaptMuiSvgIcon(WarningOutlined);
27
- function UploadDropzone(props) {
28
- const disabled = props.disabled ?? false;
29
- const { upload, getOptions } = useUploady();
30
- const [batchState, setBatchState] = useState(
31
- BATCH_STATES.PENDING
32
- );
33
- const [progress, setProgress] = useState(0);
34
- const [hasError, setHasError] = useState(false);
35
- useBatchFinalizeListener((batch) => {
36
- setBatchState(batch.state);
37
- setHasError(batch.items.some((item) => item.state === FILE_STATES.ERROR));
38
- });
39
- useBatchProgressListener((batch) => {
40
- setBatchState(batch.state);
41
- setProgress(batch.completed);
42
- });
43
- const { getRootProps, getInputProps } = useDropzone({
44
- disabled,
45
- multiple: !getOptions().autoUpload,
46
- accept: props.accept,
47
- onDrop: (files) => {
48
- upload(files);
49
- setProgress(0);
50
- setBatchState(BATCH_STATES.PENDING);
51
- }
52
- });
53
- return /* @__PURE__ */ jsxs(
54
- "div",
55
- {
56
- "data-testid": props["data-testid"] ?? "dropzone",
57
- "data-disabled": disabled,
58
- "data-mini": props.mini,
59
- style: props.style,
60
- className: cx(styles.dropzone, props.className),
61
- ...getRootProps(),
62
- children: [
63
- /* @__PURE__ */ jsx("input", { type: "file", className: styles.input, ...getInputProps() }),
64
- /* @__PURE__ */ jsxs("span", { className: styles.uploadIconContainer, children: [
65
- batchState === BATCH_STATES.FINISHED ? hasError ? /* @__PURE__ */ jsx(WarningOutlineIcon, { className: styles.icon }) : /* @__PURE__ */ jsx(CheckOutlineIcon, { className: styles.icon }) : /* @__PURE__ */ jsx(CloudUploadOutlinedIcon, { className: styles.icon }),
66
- /* @__PURE__ */ jsxs(
67
- "svg",
68
- {
69
- viewBox: "0 0 250 250",
70
- className: styles.uploadProgress,
71
- style: {
72
- ...{
73
- "--progress": progress,
74
- "--error": hasError
75
- }
76
- },
77
- children: [
78
- /* @__PURE__ */ jsx("circle", { className: styles.uploadProgressBg }),
79
- progress > 0 && /* @__PURE__ */ jsx(
80
- "circle",
81
- {
82
- "data-success": batchState === BATCH_STATES.FINISHED,
83
- "data-error": hasError,
84
- className: styles.uploadProgressFg
85
- }
86
- )
87
- ]
88
- }
89
- )
90
- ] }),
91
- !props.mini && /* @__PURE__ */ jsxs("div", { children: [
92
- /* @__PURE__ */ jsxs("span", { children: [
93
- /* @__PURE__ */ jsx(
94
- Typography,
95
- {
96
- as: "span",
97
- variant: "paragraph2",
98
- className: styles.browseLabel,
99
- children: "Browse files"
100
- }
101
- ),
102
- /* @__PURE__ */ jsxs(Typography, { as: "span", variant: "paragraph2", children: [
103
- " ",
104
- "from your computer or drag and drop here"
105
- ] })
106
- ] }),
107
- /* @__PURE__ */ jsxs(
108
- Typography,
109
- {
110
- as: "p",
111
- variant: "paragraph3",
112
- className: styles.fileFormatLabel,
113
- children: [
114
- "Supported File Formats:",
115
- " ",
116
- Object.values(props.accept).flat().join(", ")
117
- ]
118
- }
119
- )
120
- ] })
121
- ]
122
- }
123
- );
124
- }
125
- function UploadList(props) {
126
- const [items, setItems] = useState([]);
127
- useBatchAddListener((batch) => {
128
- setItems((items2) => items2.concat(batch.items));
129
- });
130
- return /* @__PURE__ */ jsx(
131
- "div",
132
- {
133
- "data-testid": props["data-testid"],
134
- style: props.style,
135
- className: cx(styles.uploadsContainer, props.className),
136
- children: /* @__PURE__ */ jsx("table", { className: styles.uploads, children: /* @__PURE__ */ jsx("tbody", { children: items.map((item, index) => /* @__PURE__ */ jsx(UploadListItem, { item }, index)) }) })
137
- }
138
- );
139
- }
140
- function UploadListItem({ item }) {
141
- const [itemState, setState] = useState(item.state);
142
- const [progress, setProgress] = useState(0);
143
- const abortItem = useAbortItem();
144
- useItemFinalizeListener((item2) => {
145
- setState(item2.state);
146
- }, item.id);
147
- useItemProgressListener((item2) => {
148
- setProgress(item2.completed);
149
- });
150
- const isAborted = itemState === FILE_STATES.ABORTED;
151
- const isSuccess = itemState === FILE_STATES.FINISHED;
152
- const isError = itemState === FILE_STATES.ERROR;
153
- const isFinished = ![FILE_STATES.PENDING, FILE_STATES.UPLOADING].includes(
154
- itemState
155
- );
156
- const onAbortItem = () => {
157
- abortItem(item.id);
158
- };
159
- return /* @__PURE__ */ jsxs("tr", { "data-testid": "file-item", className: styles.lineItem, children: [
160
- /* @__PURE__ */ jsxs("td", { children: [
161
- /* @__PURE__ */ jsx(Typography, { as: "p", variant: "label", className: styles.label, children: item.file.name }),
162
- /* @__PURE__ */ jsx(
163
- "span",
164
- {
165
- className: styles.progressBar,
166
- "data-success": isSuccess,
167
- "data-error": isError,
168
- children: /* @__PURE__ */ jsx(
169
- LinearProgress,
170
- {
171
- value: progress,
172
- variant: "determinate",
173
- color: "inherit"
174
- }
175
- )
176
- }
177
- ),
178
- isError && /* @__PURE__ */ jsx(
179
- Typography,
180
- {
181
- as: "p",
182
- variant: "paragraph3",
183
- className: styles.feedbackText,
184
- children: "An error occurred."
185
- }
186
- )
187
- ] }),
188
- /* @__PURE__ */ jsx("td", { className: styles.deleteBtn, children: isFinished ? isSuccess ? /* @__PURE__ */ jsx(
189
- IconButton,
190
- {
191
- "data-testid": "file-item-success-button",
192
- "aria-label": "success",
193
- disabled: true,
194
- children: /* @__PURE__ */ jsx(CheckOutlineIcon, {})
195
- }
196
- ) : isError ? /* @__PURE__ */ jsx(
197
- IconButton,
198
- {
199
- "data-testid": "file-item-error-button",
200
- "aria-label": "error",
201
- disabled: true,
202
- children: /* @__PURE__ */ jsx(WarningOutlineIcon, {})
203
- }
204
- ) : !isAborted ? /* @__PURE__ */ jsx(
205
- IconButton,
206
- {
207
- "data-testid": "file-item-delete-button",
208
- "aria-label": "delete",
209
- onClick: onAbortItem,
210
- children: /* @__PURE__ */ jsx(DeleteOutlineIcon, {})
211
- }
212
- ) : null : null })
213
- ] });
214
- }
215
- function useUploadStatus() {
216
- const [batchState, setBatchState] = useState(
217
- BATCH_STATES.PENDING
218
- );
219
- const [itemCount, setItemCount] = useState(0);
220
- useBatchAddListener((batch) => {
221
- setItemCount(batch.total);
222
- });
223
- const [loading, setLoading] = useState(false);
224
- useBatchStartListener(() => {
225
- setLoading(true);
226
- });
227
- useBatchFinalizeListener((batch) => {
228
- setLoading(false);
229
- setBatchState(batch.state);
230
- });
231
- return { loading, itemCount, batchState };
232
- }
233
- const UploadButton = React__default.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
234
- const { processPending } = useUploadyContext();
235
- const { itemCount, batchState, loading } = useUploadStatus();
236
- const onButtonClick = useCallback(
237
- (e) => {
238
- processPending();
239
- onClick?.(e);
240
- },
241
- [processPending, onClick]
242
- );
243
- return /* @__PURE__ */ jsx(
244
- Button,
245
- {
246
- ref,
247
- onClick: onButtonClick,
248
- disabled: disabled || itemCount === 0 || batchState === BATCH_STATES.FINISHED,
249
- loading,
250
- ...props,
251
- children: children || "Upload"
252
- }
253
- );
254
- });
255
-
256
- export { UploadButton, UploadDropzone, UploadList, UploadListItem, useUploadStatus };
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { Accept } from 'react-dropzone';
3
- import { BATCH_STATES, type BatchItem } from '@rpldy/uploady';
4
- import { type ButtonProps } from '../Button/index.js';
5
- export type UploadDropzoneProps = {
6
- 'data-testid'?: string;
7
- accept: Accept;
8
- disabled?: boolean;
9
- mini?: boolean;
10
- style?: React.CSSProperties;
11
- className?: string;
12
- };
13
- export declare function UploadDropzone(props: UploadDropzoneProps): import("react/jsx-runtime").JSX.Element;
14
- export type UploadListProps = {
15
- 'data-testid'?: string;
16
- style?: React.CSSProperties;
17
- className?: string;
18
- };
19
- export declare function UploadList(props: UploadListProps): import("react/jsx-runtime").JSX.Element;
20
- export type UploadListItemProps = {
21
- item: BatchItem;
22
- };
23
- export declare function UploadListItem({ item }: UploadListItemProps): import("react/jsx-runtime").JSX.Element;
24
- export type UploadButtonProps = ButtonProps;
25
- export declare function useUploadStatus(): {
26
- loading: boolean;
27
- itemCount: number;
28
- batchState: BATCH_STATES;
29
- };
30
- export declare const UploadButton: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
31
- variant?: import("../Button/index.js").ButtonVariant | undefined;
32
- palette?: import("../styles/palette.js").PaletteActionVariantsColors | import("../styles/css-vars.js").RecursiveStringObject<import("../styles/palette.js").PaletteActionVariantsColors> | undefined;
33
- size?: import("../Button/index.js").ButtonSize | undefined;
34
- disabled?: boolean | undefined;
35
- loading?: boolean | undefined;
36
- active?: boolean | undefined;
37
- startIcon?: React.ReactNode;
38
- endIcon?: React.ReactNode;
39
- children?: React.ReactNode;
40
- 'data-testid'?: string | undefined;
41
- } & React.RefAttributes<HTMLButtonElement>>;