@dxos/react-ui 0.7.4 → 0.7.5-main.9cb18ac

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 (58) hide show
  1. package/dist/lib/browser/index.mjs +254 -163
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +354 -271
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +254 -163
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/Dialogs/AlertDialog.d.ts.map +1 -1
  11. package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
  12. package/dist/types/src/components/Input/Input.d.ts +5 -6
  13. package/dist/types/src/components/Input/Input.d.ts.map +1 -1
  14. package/dist/types/src/components/Input/Input.stories.d.ts +1 -3
  15. package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
  16. package/dist/types/src/components/Lists/List.d.ts +2 -0
  17. package/dist/types/src/components/Lists/List.d.ts.map +1 -1
  18. package/dist/types/src/components/Lists/ListDropIndicator.d.ts +11 -0
  19. package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +1 -0
  20. package/dist/types/src/components/Lists/Tree.d.ts +2 -0
  21. package/dist/types/src/components/Lists/Tree.d.ts.map +1 -1
  22. package/dist/types/src/components/Lists/TreeDropIndicator.d.ts +8 -0
  23. package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +1 -0
  24. package/dist/types/src/components/Main/Main.d.ts.map +1 -1
  25. package/dist/types/src/components/Menus/ContextMenu.d.ts.map +1 -1
  26. package/dist/types/src/components/Menus/DropdownMenu.d.ts.map +1 -1
  27. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  28. package/dist/types/src/components/Select/Select.d.ts.map +1 -1
  29. package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +1 -1
  30. package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
  31. package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -0
  32. package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
  33. package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  34. package/dist/types/tsconfig.tsbuildinfo +1 -0
  35. package/package.json +13 -12
  36. package/src/components/Clipboard/CopyButton.tsx +1 -1
  37. package/src/components/Dialogs/AlertDialog.tsx +6 -2
  38. package/src/components/Dialogs/Dialog.tsx +6 -2
  39. package/src/components/Input/Input.stories.tsx +4 -6
  40. package/src/components/Input/Input.tsx +29 -44
  41. package/src/components/Lists/List.stories.tsx +2 -2
  42. package/src/components/Lists/List.tsx +3 -0
  43. package/src/components/Lists/ListDropIndicator.tsx +62 -0
  44. package/src/components/Lists/Tree.tsx +3 -0
  45. package/src/components/Lists/TreeDropIndicator.tsx +70 -0
  46. package/src/components/Main/Main.tsx +1 -2
  47. package/src/components/Menus/ContextMenu.tsx +4 -4
  48. package/src/components/Menus/DropdownMenu.tsx +3 -2
  49. package/src/components/Popover/Popover.tsx +4 -2
  50. package/src/components/ScrollArea/ScrollArea.stories.tsx +2 -2
  51. package/src/components/Select/Select.tsx +3 -2
  52. package/src/components/ThemeProvider/ThemeProvider.tsx +1 -2
  53. package/src/components/Toast/Toast.tsx +1 -1
  54. package/src/components/Tooltip/Tooltip.tsx +3 -2
  55. package/src/testing/decorators/withVariants.tsx +4 -4
  56. package/dist/types/src/playground/Surfaces.stories.d.ts +0 -21
  57. package/dist/types/src/playground/Surfaces.stories.d.ts.map +0 -1
  58. package/src/playground/Surfaces.stories.tsx +0 -73
@@ -28,7 +28,7 @@ import React, {
28
28
  type RefObject,
29
29
  } from 'react';
30
30
 
31
- import { useThemeContext } from '../../hooks';
31
+ import { useElevationContext, useThemeContext } from '../../hooks';
32
32
  import { type ThemedClassName } from '../../util';
33
33
 
34
34
  type Direction = 'ltr' | 'rtl';
@@ -235,6 +235,7 @@ const DropdownMenuContent = forwardRef<DropdownMenuContentElement, DropdownMenuC
235
235
  const { __scopeDropdownMenu, classNames, ...contentProps } = props;
236
236
  const { tx } = useThemeContext();
237
237
  const context = useDropdownMenuContext(CONTENT_NAME, __scopeDropdownMenu);
238
+ const elevation = useElevationContext();
238
239
  const menuScope = useMenuScope(__scopeDropdownMenu);
239
240
  const hasInteractedOutsideRef = useRef(false);
240
241
 
@@ -261,7 +262,7 @@ const DropdownMenuContent = forwardRef<DropdownMenuContentElement, DropdownMenuC
261
262
  hasInteractedOutsideRef.current = true;
262
263
  }
263
264
  })}
264
- className={tx('menu.content', 'menu', {}, classNames)}
265
+ className={tx('menu.content', 'menu', { elevation }, classNames)}
265
266
  style={{
266
267
  ...props.style,
267
268
  // re-namespace exposed content custom properties
@@ -36,7 +36,7 @@ import React, {
36
36
  } from 'react';
37
37
  import { RemoveScroll } from 'react-remove-scroll';
38
38
 
39
- import { useThemeContext } from '../../hooks';
39
+ import { useElevationContext, useThemeContext } from '../../hooks';
40
40
  import { type ThemedClassName } from '../../util';
41
41
 
42
42
  /* -------------------------------------------------------------------------------------------------
@@ -258,6 +258,7 @@ const PopoverContent = forwardRef<PopoverContentTypeElement, PopoverContentProps
258
258
  const portalContext = usePortalContext(CONTENT_NAME, props.__scopePopover);
259
259
  const { forceMount = portalContext.forceMount, ...contentProps } = props;
260
260
  const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
261
+
261
262
  return (
262
263
  <Presence present={forceMount || context.open}>
263
264
  {context.modal ? (
@@ -433,6 +434,7 @@ const PopoverContentImpl = forwardRef<PopoverContentImplElement, PopoverContentI
433
434
  const context = usePopoverContext(CONTENT_NAME, __scopePopover);
434
435
  const popperScope = usePopperScope(__scopePopover);
435
436
  const { tx } = useThemeContext();
437
+ const elevation = useElevationContext();
436
438
 
437
439
  // Make sure the whole tree has focus guards as our `Popover` may be
438
440
  // the last element in the DOM (because of the `Portal`)
@@ -461,7 +463,7 @@ const PopoverContentImpl = forwardRef<PopoverContentImplElement, PopoverContentI
461
463
  id={context.contentId}
462
464
  {...popperScope}
463
465
  {...contentProps}
464
- className={tx('popover.content', 'popover', {}, classNames)}
466
+ className={tx('popover.content', 'popover', { elevation }, classNames)}
465
467
  ref={forwardedRef}
466
468
  style={{
467
469
  ...contentProps.style,
@@ -7,7 +7,7 @@ import '@dxos-theme';
7
7
  import React, { type PropsWithChildren } from 'react';
8
8
 
9
9
  import { faker } from '@dxos/random';
10
- import { groupSurface, surfaceElevation } from '@dxos/react-ui-theme';
10
+ import { groupSurface, surfaceShadow } from '@dxos/react-ui-theme';
11
11
 
12
12
  import { ScrollArea } from './ScrollArea';
13
13
  import { withTheme } from '../../testing';
@@ -17,7 +17,7 @@ faker.seed(1234);
17
17
  const StorybookScrollArea = ({ children }: PropsWithChildren<{}>) => {
18
18
  return (
19
19
  <ScrollArea.Root
20
- classNames={['is-[300px] bs-[400px] rounded', groupSurface, surfaceElevation({ elevation: 'group' })]}
20
+ classNames={['is-[300px] bs-[400px] rounded', groupSurface, surfaceShadow({ elevation: 'positioned' })]}
21
21
  >
22
22
  <ScrollArea.Viewport classNames='rounded p-4'>
23
23
  <p>{children}</p>
@@ -6,7 +6,7 @@ import { CaretDown, CaretUp } from '@phosphor-icons/react';
6
6
  import * as SelectPrimitive from '@radix-ui/react-select';
7
7
  import React, { forwardRef } from 'react';
8
8
 
9
- import { useThemeContext } from '../../hooks';
9
+ import { useElevationContext, useThemeContext } from '../../hooks';
10
10
  import { type ThemedClassName } from '../../util';
11
11
  import { Button, type ButtonProps } from '../Buttons';
12
12
  import { Icon } from '../Icon';
@@ -55,10 +55,11 @@ type SelectContentProps = ThemedClassName<SelectPrimitive.SelectContentProps>;
55
55
  const SelectContent = forwardRef<HTMLDivElement, SelectContentProps>(
56
56
  ({ classNames, children, ...props }, forwardedRef) => {
57
57
  const { tx } = useThemeContext();
58
+ const elevation = useElevationContext();
58
59
  return (
59
60
  <SelectPrimitive.Content
60
61
  {...props}
61
- className={tx('select.content', 'select__content', {}, classNames)}
62
+ className={tx('select.content', 'select__content', { elevation }, classNames)}
62
63
  position='popper'
63
64
  ref={forwardedRef}
64
65
  >
@@ -41,7 +41,6 @@ export const ThemeProvider = ({
41
41
  tx = (_path, defaultClassName, _styleProps, ..._options) => defaultClassName,
42
42
  themeMode = 'dark',
43
43
  rootDensity = 'fine',
44
- rootElevation = 'base',
45
44
  ...rest
46
45
  }: ThemeProviderProps) => {
47
46
  useEffect(() => {
@@ -61,7 +60,7 @@ export const ThemeProvider = ({
61
60
  appNs,
62
61
  }}
63
62
  >
64
- <ElevationProvider elevation={rootElevation}>
63
+ <ElevationProvider elevation='base'>
65
64
  <DensityProvider density={rootDensity}>{children}</DensityProvider>
66
65
  </ElevationProvider>
67
66
  </TranslationsProvider>
@@ -45,7 +45,7 @@ const ToastRoot = forwardRef<HTMLLIElement, ToastRootProps>(({ classNames, child
45
45
  const { tx } = useThemeContext();
46
46
  return (
47
47
  <ToastRootPrimitive {...props} className={tx('toast.root', 'toast', {}, classNames)} ref={forwardedRef}>
48
- <ElevationProvider elevation='chrome'>{children}</ElevationProvider>
48
+ <ElevationProvider elevation='toast'>{children}</ElevationProvider>
49
49
  </ToastRootPrimitive>
50
50
  );
51
51
  });
@@ -18,7 +18,7 @@ import {
18
18
  } from '@radix-ui/react-tooltip';
19
19
  import React, { forwardRef, type FunctionComponent } from 'react';
20
20
 
21
- import { useThemeContext } from '../../hooks';
21
+ import { useElevationContext, useThemeContext } from '../../hooks';
22
22
  import { type ThemedClassName } from '../../util';
23
23
 
24
24
  type TooltipProviderProps = TooltipProviderPrimitiveProps;
@@ -54,12 +54,13 @@ type TooltipContentProps = ThemedClassName<TooltipContentPrimitiveProps>;
54
54
 
55
55
  const TooltipContent = forwardRef<HTMLDivElement, TooltipContentProps>(({ classNames, ...props }, forwardedRef) => {
56
56
  const { tx } = useThemeContext();
57
+ const elevation = useElevationContext();
57
58
  return (
58
59
  <TooltipContentPrimitive
59
60
  sideOffset={4}
60
61
  collisionPadding={8}
61
62
  {...props}
62
- className={tx('tooltip.content', 'tooltip', {}, classNames)}
63
+ className={tx('tooltip.content', 'tooltip', { elevation }, classNames)}
63
64
  ref={forwardedRef}
64
65
  />
65
66
  );
@@ -7,7 +7,7 @@ import '@dxos-theme';
7
7
  import { type Decorator } from '@storybook/react';
8
8
  import React from 'react';
9
9
 
10
- import { modalSurface, groupSurface, mx, surfaceElevation } from '@dxos/react-ui-theme';
10
+ import { modalSurface, groupSurface, mx, surfaceShadow } from '@dxos/react-ui-theme';
11
11
  import { type Density, type Elevation } from '@dxos/react-ui-types';
12
12
 
13
13
  import { DensityProvider, ElevationProvider } from '../../components';
@@ -20,8 +20,8 @@ type Config = {
20
20
  export const withVariants = ({
21
21
  elevations = [
22
22
  { elevation: 'base' },
23
- { elevation: 'group', surface: groupSurface },
24
- { elevation: 'chrome', surface: modalSurface },
23
+ { elevation: 'positioned', surface: groupSurface },
24
+ { elevation: 'dialog', surface: modalSurface },
25
25
  ],
26
26
  densities = ['coarse', 'fine'],
27
27
  }: Config = {}): Decorator => {
@@ -32,7 +32,7 @@ export const withVariants = ({
32
32
  <div className='flex flex-col gap-8'>
33
33
  {densities.map((density) => (
34
34
  <DensityProvider key={density} density={density}>
35
- <div className={mx('p-4 rounded-lg', surface, surfaceElevation({ elevation }))}>
35
+ <div className={mx('p-4 rounded-lg', surface, surfaceShadow({ elevation }))}>
36
36
  <Story />
37
37
  </div>
38
38
  </DensityProvider>
@@ -1,21 +0,0 @@
1
- import '@dxos-theme';
2
- import React, { type PropsWithChildren } from 'react';
3
- type SurfaceLevel = 'base' | 'group' | 'chrome' | 'fixed' | 'input' | 'accent';
4
- declare const _default: {
5
- title: string;
6
- component: ({ children, level }: PropsWithChildren & {
7
- level: SurfaceLevel;
8
- }) => React.JSX.Element;
9
- render: () => React.JSX.Element;
10
- decorators: import("@storybook/react/*").Decorator[];
11
- parameters: {
12
- chromatic: {
13
- disableSnapshot: boolean;
14
- };
15
- };
16
- };
17
- export default _default;
18
- export declare const Default: {
19
- args: {};
20
- };
21
- //# sourceMappingURL=Surfaces.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Surfaces.stories.d.ts","sourceRoot":"","sources":["../../../../src/playground/Surfaces.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgBtD,KAAK,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;;;qCAEzC,iBAAiB,GAAG;QAAE,KAAK,EAAE,YAAY,CAAA;KAAE;;;;;;;;;AAsCjF,wBAME;AAEF,eAAO,MAAM,OAAO;;CAEnB,CAAC"}
@@ -1,73 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import React, { type PropsWithChildren } from 'react';
8
-
9
- import {
10
- baseSurface,
11
- modalSurface,
12
- groupSurface,
13
- mx,
14
- surfaceElevation,
15
- fixedSurface,
16
- fixedBorder,
17
- attentionSurface,
18
- accentSurface,
19
- } from '@dxos/react-ui-theme';
20
-
21
- import { withTheme } from '../testing';
22
-
23
- type SurfaceLevel = 'base' | 'group' | 'chrome' | 'fixed' | 'input' | 'accent';
24
-
25
- const Surface = ({ children, level }: PropsWithChildren & { level: SurfaceLevel }) => {
26
- const surface =
27
- level === 'chrome'
28
- ? [modalSurface, surfaceElevation({ elevation: 'chrome' })]
29
- : level === 'group'
30
- ? [groupSurface, surfaceElevation({ elevation: 'group' })]
31
- : level === 'input'
32
- ? [attentionSurface, surfaceElevation({ elevation: 'group' })]
33
- : level === 'fixed'
34
- ? [fixedSurface, fixedBorder, 'border', surfaceElevation({ elevation: 'chrome' })]
35
- : level === 'accent'
36
- ? [accentSurface, surfaceElevation({ elevation: 'chrome' })]
37
- : [baseSurface];
38
-
39
- return (
40
- <div
41
- role='region'
42
- className={mx('flex justify-center items-center m-8 p-2 w-[320px] h-[160px] rounded-lg', ...surface)}
43
- >
44
- <div>{level}</div>
45
- {children}
46
- </div>
47
- );
48
- };
49
-
50
- const SurfaceStory = () => {
51
- return (
52
- <div className='bg-cubes p-10 m-0'>
53
- <Surface level='fixed' />
54
- <Surface level='base' />
55
- <Surface level='group' />
56
- <Surface level='chrome' />
57
- <Surface level='input' />
58
- <Surface level='accent' />
59
- </div>
60
- );
61
- };
62
-
63
- export default {
64
- title: 'ui/react-ui-core/Playground/Surfaces',
65
- component: Surface,
66
- render: SurfaceStory,
67
- decorators: [withTheme],
68
- parameters: { chromatic: { disableSnapshot: false } },
69
- };
70
-
71
- export const Default = {
72
- args: {},
73
- };