@veritone-ce/design-system 2.8.2 → 2.8.4

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.
@@ -20,6 +20,7 @@ require('../styles/css-vars.js');
20
20
  var index$1 = require('../Button/index.js');
21
21
  var index = require('../Typography/index.js');
22
22
  var index$2 = require('../IconButton/index.js');
23
+ var internal = require('../Icon/internal.js');
23
24
 
24
25
  function _interopNamespaceDefault(e) {
25
26
  var n = Object.create(null);
@@ -221,7 +222,7 @@ const DialogCloseButton = React__namespace.forwardRef(function DialogCloseButton
221
222
  }
222
223
  );
223
224
  });
224
- const DialogCloseIconButton = React__namespace.forwardRef(function DialogCloseIconButton2(props, ref) {
225
+ const DialogCloseIconButton = React__namespace.forwardRef(function DialogCloseIconButton2({ children = /* @__PURE__ */ jsxRuntime.jsx(internal.CloseIcon, {}), ...props }, ref) {
225
226
  const { dismiss } = state.useDialogContext();
226
227
  return /* @__PURE__ */ jsxRuntime.jsx(
227
228
  index$2.default,
@@ -231,7 +232,8 @@ const DialogCloseIconButton = React__namespace.forwardRef(function DialogCloseIc
231
232
  onClick: (e) => {
232
233
  dismiss();
233
234
  props.onClick?.(e);
234
- }
235
+ },
236
+ children
235
237
  }
236
238
  );
237
239
  });
@@ -20,6 +20,7 @@ require('../styles/css-vars.js');
20
20
  var index$1 = require('../Button/index.js');
21
21
  var index = require('../Typography/index.js');
22
22
  var index$2 = require('../IconButton/index.js');
23
+ var internal = require('../Icon/internal.js');
23
24
 
24
25
  function _interopNamespaceDefault(e) {
25
26
  var n = Object.create(null);
@@ -262,7 +263,7 @@ const DrawerCloseButton = React__namespace.forwardRef(function DrawerCloseButton
262
263
  }
263
264
  );
264
265
  });
265
- const DrawerCloseIconButton = React__namespace.forwardRef(function DrawerCloseIconButton2(props, ref) {
266
+ const DrawerCloseIconButton = React__namespace.forwardRef(function DrawerCloseIconButton2({ children = /* @__PURE__ */ jsxRuntime.jsx(internal.CloseIcon, {}), ...props }, ref) {
266
267
  const { dismiss } = state.useDrawerContext();
267
268
  return /* @__PURE__ */ jsxRuntime.jsx(
268
269
  index$2.default,
@@ -272,7 +273,8 @@ const DrawerCloseIconButton = React__namespace.forwardRef(function DrawerCloseIc
272
273
  onClick: (e) => {
273
274
  dismiss();
274
275
  props.onClick?.(e);
275
- }
276
+ },
277
+ children
276
278
  }
277
279
  );
278
280
  });
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+ 'use client';
3
+ 'use strict';
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
+ var components = require('../../../Dialog/components.js');
8
+ var index = require('../../../ErrorBoundary/index.js');
9
+ var vanilla = require('../../../bundled_modules/jotai/esm/vanilla.js');
10
+ var react = require('../../../bundled_modules/jotai/esm/react.js');
11
+
12
+ function createDialog(config, store = vanilla.getDefaultStore()) {
13
+ const dialogAtom = vanilla.atom(false);
14
+ return {
15
+ Component: createBoundDialogComponent(dialogAtom, config),
16
+ useDialog: () => react.useAtom(dialogAtom),
17
+ setOpen(open) {
18
+ store.set(dialogAtom, open);
19
+ }
20
+ };
21
+ }
22
+ function createBoundDialogComponent(dialogAtom, config) {
23
+ return function BoundDialog() {
24
+ const [open, setOpen] = react.useAtom(dialogAtom);
25
+ const cachedOpenRef = React.useRef(open);
26
+ React.useEffect(() => {
27
+ if (open !== false) {
28
+ cachedOpenRef.current = open;
29
+ }
30
+ }, [open]);
31
+ const cachedOpen = cachedOpenRef.current !== false ? cachedOpenRef.current : open;
32
+ return /* @__PURE__ */ jsxRuntime.jsx(
33
+ components.default,
34
+ {
35
+ ...config.dialogProps,
36
+ open: open !== false,
37
+ onDismiss: () => {
38
+ setOpen(false);
39
+ config.dialogProps?.onDismiss?.();
40
+ },
41
+ className: config.dialogProps?.className,
42
+ children: cachedOpen !== false && /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { fallback: config.errorFallback, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: config.loadingFallback, children: /* @__PURE__ */ jsxRuntime.jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
43
+ }
44
+ );
45
+ };
46
+ }
47
+
48
+ exports.createDialog = createDialog;
@@ -5,7 +5,6 @@
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
7
  var index_module = require('./index.module.scss.js');
8
- var internal = require('../../../Icon/internal.js');
9
8
  var components = require('../../../Drawer/components.js');
10
9
  var cx = require('../../../styles/cx.js');
11
10
  require('../../../styles/defaultThemeOptions.js');
@@ -38,7 +37,7 @@ function createBoundDrawerComponent(drawerAtom, config) {
38
37
  }
39
38
  }, [open]);
40
39
  const cachedOpen = cachedOpenRef.current !== false ? cachedOpenRef.current : open;
41
- return /* @__PURE__ */ jsxRuntime.jsxs(
40
+ return /* @__PURE__ */ jsxRuntime.jsx(
42
41
  components.default,
43
42
  {
44
43
  disableAutoFocus: true,
@@ -50,17 +49,7 @@ function createBoundDrawerComponent(drawerAtom, config) {
50
49
  config.drawerProps?.onDismiss?.();
51
50
  },
52
51
  className: cx.cx(index_module.default.drawer, config.drawerProps?.className),
53
- children: [
54
- /* @__PURE__ */ jsxRuntime.jsx(
55
- components.DrawerTitle,
56
- {
57
- container: "text",
58
- actions: /* @__PURE__ */ jsxRuntime.jsx(components.DrawerCloseIconButton, { variant: "primary", children: /* @__PURE__ */ jsxRuntime.jsx(internal.CloseIcon, {}) }),
59
- children: config.title
60
- }
61
- ),
62
- cachedOpen !== false && /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
63
- ]
52
+ children: cachedOpen !== false && /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { fallback: config.errorFallback, children: /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: config.loadingFallback, children: /* @__PURE__ */ jsxRuntime.jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
64
53
  }
65
54
  );
66
55
  };
@@ -16,6 +16,7 @@ import '../styles/css-vars.js';
16
16
  import Button from '../Button/index.js';
17
17
  import Typography from '../Typography/index.js';
18
18
  import IconButton from '../IconButton/index.js';
19
+ import { CloseIcon } from '../Icon/internal.js';
19
20
 
20
21
  const Dialog = React.forwardRef(function Dialog2({
21
22
  children,
@@ -198,7 +199,7 @@ const DialogCloseButton = React.forwardRef(function DialogCloseButton2(props, re
198
199
  }
199
200
  );
200
201
  });
201
- const DialogCloseIconButton = React.forwardRef(function DialogCloseIconButton2(props, ref) {
202
+ const DialogCloseIconButton = React.forwardRef(function DialogCloseIconButton2({ children = /* @__PURE__ */ jsx(CloseIcon, {}), ...props }, ref) {
202
203
  const { dismiss } = useDialogContext();
203
204
  return /* @__PURE__ */ jsx(
204
205
  IconButton,
@@ -208,7 +209,8 @@ const DialogCloseIconButton = React.forwardRef(function DialogCloseIconButton2(p
208
209
  onClick: (e) => {
209
210
  dismiss();
210
211
  props.onClick?.(e);
211
- }
212
+ },
213
+ children
212
214
  }
213
215
  );
214
216
  });
@@ -16,6 +16,7 @@ import '../styles/css-vars.js';
16
16
  import Button from '../Button/index.js';
17
17
  import Typography from '../Typography/index.js';
18
18
  import IconButton from '../IconButton/index.js';
19
+ import { CloseIcon } from '../Icon/internal.js';
19
20
 
20
21
  const Drawer = React.forwardRef(function Drawer2({
21
22
  placement = "end",
@@ -239,7 +240,7 @@ const DrawerCloseButton = React.forwardRef(function DrawerCloseButton2(props, re
239
240
  }
240
241
  );
241
242
  });
242
- const DrawerCloseIconButton = React.forwardRef(function DrawerCloseIconButton2(props, ref) {
243
+ const DrawerCloseIconButton = React.forwardRef(function DrawerCloseIconButton2({ children = /* @__PURE__ */ jsx(CloseIcon, {}), ...props }, ref) {
243
244
  const { dismiss } = useDrawerContext();
244
245
  return /* @__PURE__ */ jsx(
245
246
  IconButton,
@@ -249,7 +250,8 @@ const DrawerCloseIconButton = React.forwardRef(function DrawerCloseIconButton2(p
249
250
  onClick: (e) => {
250
251
  dismiss();
251
252
  props.onClick?.(e);
252
- }
253
+ },
254
+ children
253
255
  }
254
256
  );
255
257
  });
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ 'use client';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { useRef, useEffect, Fragment, Suspense } from 'react';
5
+ import Dialog from '../../../Dialog/components.js';
6
+ import ErrorBoundary from '../../../ErrorBoundary/index.js';
7
+ import { getDefaultStore, atom } from '../../../bundled_modules/jotai/esm/vanilla.js';
8
+ import { useAtom } from '../../../bundled_modules/jotai/esm/react.js';
9
+
10
+ function createDialog(config, store = getDefaultStore()) {
11
+ const dialogAtom = atom(false);
12
+ return {
13
+ Component: createBoundDialogComponent(dialogAtom, config),
14
+ useDialog: () => useAtom(dialogAtom),
15
+ setOpen(open) {
16
+ store.set(dialogAtom, open);
17
+ }
18
+ };
19
+ }
20
+ function createBoundDialogComponent(dialogAtom, config) {
21
+ return function BoundDialog() {
22
+ const [open, setOpen] = useAtom(dialogAtom);
23
+ const cachedOpenRef = useRef(open);
24
+ useEffect(() => {
25
+ if (open !== false) {
26
+ cachedOpenRef.current = open;
27
+ }
28
+ }, [open]);
29
+ const cachedOpen = cachedOpenRef.current !== false ? cachedOpenRef.current : open;
30
+ return /* @__PURE__ */ jsx(
31
+ Dialog,
32
+ {
33
+ ...config.dialogProps,
34
+ open: open !== false,
35
+ onDismiss: () => {
36
+ setOpen(false);
37
+ config.dialogProps?.onDismiss?.();
38
+ },
39
+ className: config.dialogProps?.className,
40
+ children: cachedOpen !== false && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: config.errorFallback, children: /* @__PURE__ */ jsx(Suspense, { fallback: config.loadingFallback, children: /* @__PURE__ */ jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
41
+ }
42
+ );
43
+ };
44
+ }
45
+
46
+ export { createDialog };
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
  'use client';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { jsx } from 'react/jsx-runtime';
4
4
  import { useRef, useEffect, Fragment, Suspense } from 'react';
5
5
  import styles from './index.module.scss.js';
6
- import { CloseIcon } from '../../../Icon/internal.js';
7
- import Drawer, { DrawerTitle, DrawerCloseIconButton } from '../../../Drawer/components.js';
6
+ import Drawer from '../../../Drawer/components.js';
8
7
  import { cx } from '../../../styles/cx.js';
9
8
  import '../../../styles/defaultThemeOptions.js';
10
9
  import '@capsizecss/core';
@@ -36,7 +35,7 @@ function createBoundDrawerComponent(drawerAtom, config) {
36
35
  }
37
36
  }, [open]);
38
37
  const cachedOpen = cachedOpenRef.current !== false ? cachedOpenRef.current : open;
39
- return /* @__PURE__ */ jsxs(
38
+ return /* @__PURE__ */ jsx(
40
39
  Drawer,
41
40
  {
42
41
  disableAutoFocus: true,
@@ -48,17 +47,7 @@ function createBoundDrawerComponent(drawerAtom, config) {
48
47
  config.drawerProps?.onDismiss?.();
49
48
  },
50
49
  className: cx(styles.drawer, config.drawerProps?.className),
51
- children: [
52
- /* @__PURE__ */ jsx(
53
- DrawerTitle,
54
- {
55
- container: "text",
56
- actions: /* @__PURE__ */ jsx(DrawerCloseIconButton, { variant: "primary", children: /* @__PURE__ */ jsx(CloseIcon, {}) }),
57
- children: config.title
58
- }
59
- ),
60
- cachedOpen !== false && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
61
- ]
50
+ children: cachedOpen !== false && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: config.errorFallback, children: /* @__PURE__ */ jsx(Suspense, { fallback: config.loadingFallback, children: /* @__PURE__ */ jsx(config.Content, { open: cachedOpen }) }) }) }, JSON.stringify(cachedOpen))
62
51
  }
63
52
  );
64
53
  };
@@ -0,0 +1,19 @@
1
+ import { createStore } from 'jotai';
2
+ import { ReactNode } from 'react';
3
+ import { type DialogProps } from '../../../Dialog/index.js';
4
+ export type DialogAtom<O> = O | false;
5
+ export type OpenDialogContentProps<O> = {
6
+ open: O;
7
+ };
8
+ export type OpenDialogContentComponent<O> = (props: OpenDialogContentProps<O>) => ReactNode;
9
+ export type DialogConfig<O> = {
10
+ Content: OpenDialogContentComponent<O>;
11
+ loadingFallback?: ReactNode;
12
+ errorFallback?: ReactNode;
13
+ dialogProps?: Partial<Omit<DialogProps, 'open' | 'children'>>;
14
+ };
15
+ export declare function createDialog<O = true>(config: DialogConfig<O>, store?: ReturnType<typeof createStore>): {
16
+ Component: () => import("react/jsx-runtime").JSX.Element;
17
+ useDialog: () => [false | Awaited<O>, (args_0: DialogAtom<O> | ((prev: DialogAtom<O>) => DialogAtom<O>)) => void];
18
+ setOpen(open: DialogAtom<O>): void;
19
+ };
@@ -7,8 +7,9 @@ export type OpenDrawerContentProps<O> = {
7
7
  };
8
8
  export type OpenDrawerContentComponent<O> = (props: OpenDrawerContentProps<O>) => ReactNode;
9
9
  export type DrawerConfig<O> = {
10
- title: ReactNode;
11
10
  Content: OpenDrawerContentComponent<O>;
11
+ loadingFallback?: ReactNode;
12
+ errorFallback?: ReactNode;
12
13
  drawerProps?: Partial<Omit<DrawerProps, 'open' | 'children'>>;
13
14
  };
14
15
  export declare function createDrawer<O = true>(config: DrawerConfig<O>, store?: ReturnType<typeof createStore>): {
@@ -4,5 +4,5 @@ import { SelectProps } from '../../../Select/index.js';
4
4
  import type { ComponentType } from 'react';
5
5
  export type FormSelectControlledProps<OptionValue, Multiple extends boolean | undefined> = Pick<SelectProps<OptionValue, Multiple>, 'value' | 'onChange'>;
6
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;
7
+ export declare function formSelectFactory<OptionValue, S extends FormSelectControlledProps<OptionValue, boolean | undefined> = FormSelectControlledProps<OptionValue, boolean | undefined>>(Component: ComponentType<S>): <Multiple extends boolean | undefined, 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: <Multiple extends boolean | undefined, TFieldValues extends FieldValues, TName extends FieldPathByValue<TFieldValues, unknown> = FieldPathByValue<TFieldValues, unknown>>(props: FormSelectProps<TFieldValues, unknown, Multiple, SelectProps<unknown, boolean | undefined>, TName>) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { type FieldPathByValue, FieldValues, UseControllerProps } from 'react-hook-form';
2
2
  import type { FormControlProps } from '../../../FormControl/index.js';
3
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[]>;
4
+ type FilesFieldPath<TFieldValues extends FieldValues, F extends FileLike = FileLike> = FieldPathByValue<TFieldValues, F | F[]>;
5
5
  type FormUploadDropzoneInputProps = Partial<UploadDropzoneProps> & Omit<UploadDropzoneProps, 'onDrop'>;
6
6
  export type FormUploadDropzoneProps<TFieldValues extends FieldValues, TName extends FilesFieldPath<TFieldValues> = FilesFieldPath<TFieldValues>> = UseControllerProps<TFieldValues, TName> & FormControlProps & FormUploadDropzoneInputProps;
7
7
  export declare function FormUploadDropzone<TFieldValues extends FieldValues, TName extends FilesFieldPath<TFieldValues> = FilesFieldPath<TFieldValues>>(props: FormUploadDropzoneProps<TFieldValues, TName>): import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritone-ce/design-system",
3
- "version": "2.8.2",
3
+ "version": "2.8.4",
4
4
  "private": false,
5
5
  "description": "Design System for Veritone CE",
6
6
  "keywords": [