@veritone-ce/design-system 2.5.13 → 2.5.15

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.
@@ -216,8 +216,7 @@ function UploadListItem({ item }) {
216
216
  ) : null : null })
217
217
  ] });
218
218
  }
219
- const UploadButton = React.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
220
- const { processPending } = uploady.useUploadyContext();
219
+ function useUploadStatus() {
221
220
  const [batchState, setBatchState] = React.useState(
222
221
  uploady.BATCH_STATES.PENDING
223
222
  );
@@ -233,6 +232,11 @@ const UploadButton = React.forwardRef(function UploadButton2({ children, onClick
233
232
  setLoading(false);
234
233
  setBatchState(batch.state);
235
234
  });
235
+ return { loading, itemCount, batchState };
236
+ }
237
+ const UploadButton = React.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
238
+ const { processPending } = uploady.useUploadyContext();
239
+ const { itemCount, batchState, loading } = useUploadStatus();
236
240
  const onButtonClick = React.useCallback(
237
241
  (e) => {
238
242
  processPending();
@@ -257,3 +261,4 @@ exports.UploadButton = UploadButton;
257
261
  exports.UploadDropzone = UploadDropzone;
258
262
  exports.UploadList = UploadList;
259
263
  exports.UploadListItem = UploadListItem;
264
+ exports.useUploadStatus = useUploadStatus;
@@ -185,13 +185,15 @@ function ControlledSelect({
185
185
  label: option.label,
186
186
  icon: option.icon,
187
187
  onSelect(e) {
188
- props.onChange(
189
- e,
190
- multiple ? [
191
- ...value ?? [],
192
- option.value
193
- ] : option.value
194
- );
188
+ if (multiple) {
189
+ const multiValue = value || [];
190
+ const hasValue = multiValue && multiValue.some((val) => val === option.value);
191
+ if (!hasValue) {
192
+ props.onChange(e, [...multiValue, option.value]);
193
+ }
194
+ } else {
195
+ props.onChange(e, option.value);
196
+ }
195
197
  props.onInputChange(e, "");
196
198
  setOpen(false);
197
199
  }
@@ -54,13 +54,13 @@ function useToast() {
54
54
  const snackbar = notistack.useSnackbar();
55
55
  return {
56
56
  enqueueToast(options = {}) {
57
- snackbar.enqueueSnackbar({
57
+ return snackbar.enqueueSnackbar({
58
58
  variant: "veritone",
59
59
  ...options
60
60
  });
61
61
  },
62
- closeToast() {
63
- snackbar.closeSnackbar();
62
+ closeToast(key) {
63
+ snackbar.closeSnackbar(key);
64
64
  }
65
65
  };
66
66
  }
package/dist/cjs/index.js CHANGED
@@ -122,6 +122,7 @@ exports.UploadButton = components$2.UploadButton;
122
122
  exports.UploadDropzone = components$2.UploadDropzone;
123
123
  exports.UploadList = components$2.UploadList;
124
124
  exports.UploadListItem = components$2.UploadListItem;
125
+ exports.useUploadStatus = components$2.useUploadStatus;
125
126
  exports.FormControl = index$b.default;
126
127
  exports.GlobalStyles = index$c.default;
127
128
  exports.adaptMuiSvgIcon = wrappers.adaptMuiSvgIcon;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
  'use client';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
- import React__default, { useState, useCallback } from 'react';
4
+ import React__default, { useCallback, useState } from 'react';
5
5
  import { CloudUploadOutlined, DeleteOutline, CheckOutlined, WarningOutlined } from '@mui/icons-material';
6
6
  import { useDropzone } from 'react-dropzone';
7
7
  import { cx } from '../styles/cx.js';
@@ -214,8 +214,7 @@ function UploadListItem({ item }) {
214
214
  ) : null : null })
215
215
  ] });
216
216
  }
217
- const UploadButton = React__default.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
218
- const { processPending } = useUploadyContext();
217
+ function useUploadStatus() {
219
218
  const [batchState, setBatchState] = useState(
220
219
  BATCH_STATES.PENDING
221
220
  );
@@ -231,6 +230,11 @@ const UploadButton = React__default.forwardRef(function UploadButton2({ children
231
230
  setLoading(false);
232
231
  setBatchState(batch.state);
233
232
  });
233
+ return { loading, itemCount, batchState };
234
+ }
235
+ const UploadButton = React__default.forwardRef(function UploadButton2({ children, onClick, disabled, ...props }, ref) {
236
+ const { processPending } = useUploadyContext();
237
+ const { itemCount, batchState, loading } = useUploadStatus();
234
238
  const onButtonClick = useCallback(
235
239
  (e) => {
236
240
  processPending();
@@ -251,4 +255,4 @@ const UploadButton = React__default.forwardRef(function UploadButton2({ children
251
255
  );
252
256
  });
253
257
 
254
- export { UploadButton, UploadDropzone, UploadList, UploadListItem };
258
+ export { UploadButton, UploadDropzone, UploadList, UploadListItem, useUploadStatus };
@@ -181,13 +181,15 @@ function ControlledSelect({
181
181
  label: option.label,
182
182
  icon: option.icon,
183
183
  onSelect(e) {
184
- props.onChange(
185
- e,
186
- multiple ? [
187
- ...value ?? [],
188
- option.value
189
- ] : option.value
190
- );
184
+ if (multiple) {
185
+ const multiValue = value || [];
186
+ const hasValue = multiValue && multiValue.some((val) => val === option.value);
187
+ if (!hasValue) {
188
+ props.onChange(e, [...multiValue, option.value]);
189
+ }
190
+ } else {
191
+ props.onChange(e, option.value);
192
+ }
191
193
  props.onInputChange(e, "");
192
194
  setOpen(false);
193
195
  }
@@ -52,13 +52,13 @@ function useToast() {
52
52
  const snackbar = useSnackbar();
53
53
  return {
54
54
  enqueueToast(options = {}) {
55
- snackbar.enqueueSnackbar({
55
+ return snackbar.enqueueSnackbar({
56
56
  variant: "veritone",
57
57
  ...options
58
58
  });
59
59
  },
60
- closeToast() {
61
- snackbar.closeSnackbar();
60
+ closeToast(key) {
61
+ snackbar.closeSnackbar(key);
62
62
  }
63
63
  };
64
64
  }
package/dist/esm/index.js CHANGED
@@ -29,7 +29,7 @@ export { createDialogComponent } from './Dialog/factory.js';
29
29
  export { default as Drawer, DrawerActions, DrawerCloseButton, DrawerCloseIconButton, DrawerContent, DrawerDescription, DrawerEnd, DrawerStart, DrawerTitle, DrawerTypography } from './Drawer/components.js';
30
30
  export { createDrawerComponent } from './Drawer/factory.js';
31
31
  export { default as ErrorBoundary } from './ErrorBoundary/index.js';
32
- export { UploadButton, UploadDropzone, UploadList, UploadListItem } from './FileUploader/components.js';
32
+ export { UploadButton, UploadDropzone, UploadList, UploadListItem, useUploadStatus } from './FileUploader/components.js';
33
33
  export { default as FormControl } from './FormControl/index.js';
34
34
  export { default as GlobalStyles } from './GlobalStyles/index.js';
35
35
  export { adaptMuiSvgIcon, adaptSvgIcon } from './Icon/wrappers.js';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Accept } from 'react-dropzone';
3
- import { type BatchItem } from '@rpldy/uploady';
3
+ import { BATCH_STATES, type BatchItem } from '@rpldy/uploady';
4
4
  import { type ButtonProps } from '../Button/index.js';
5
5
  export type UploadDropzoneProps = {
6
6
  'data-testid'?: string;
@@ -22,6 +22,11 @@ export type UploadListItemProps = {
22
22
  };
23
23
  export declare function UploadListItem({ item }: UploadListItemProps): import("react/jsx-runtime").JSX.Element;
24
24
  export type UploadButtonProps = ButtonProps;
25
+ export declare function useUploadStatus(): {
26
+ loading: boolean;
27
+ itemCount: number;
28
+ batchState: BATCH_STATES;
29
+ };
25
30
  export declare const UploadButton: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
26
31
  variant?: import("../Button/index.js").ButtonVariant | undefined;
27
32
  palette?: import("../styles/palette.js").PaletteActionVariantsColors | import("../styles/css-vars.js").RecursiveStringObject<import("../styles/palette.js").PaletteActionVariantsColors> | undefined;
@@ -6,6 +6,7 @@ export type ToastOptions = {
6
6
  action?: React.ReactNode;
7
7
  severity?: AlertSeverity;
8
8
  };
9
+ export type ToastKey = string | number;
9
10
  declare module 'notistack' {
10
11
  interface VariantOverrides {
11
12
  veritone: ToastOptions;
@@ -16,6 +17,6 @@ export type ToastProviderProps = {
16
17
  };
17
18
  export declare const ToastProvider: (props: ToastProviderProps) => import("react/jsx-runtime").JSX.Element;
18
19
  export declare function useToast(): {
19
- enqueueToast(options?: ToastOptions): void;
20
- closeToast(): void;
20
+ enqueueToast(options?: ToastOptions): ToastKey;
21
+ closeToast(key?: ToastKey): void;
21
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritone-ce/design-system",
3
- "version": "2.5.13",
3
+ "version": "2.5.15",
4
4
  "private": false,
5
5
  "description": "Design System for Veritone CE",
6
6
  "keywords": [