@dxos/react-ui 0.6.13 → 0.6.14-main.2b6a0f3
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/lib/browser/index.mjs +34 -29
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +2395 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node-esm/index.mjs +2396 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +15 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +6 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts +9 -1
- package/dist/types/src/components/Breadcrumb/Breadcrumb.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +12 -17
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts +2 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +20 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +12 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +11 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +16 -1
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/List.stories.d.ts +2 -3
- package/dist/types/src/components/Lists/List.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts +5 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +3 -2
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts +5 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/ContextMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts +29 -1
- package/dist/types/src/components/Menus/DropdownMenu.stories.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +6 -1
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +15 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts +20 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.d.ts.map +1 -1
- package/dist/types/src/components/Select/Select.stories.d.ts +10 -11
- package/dist/types/src/components/Select/Select.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts +0 -3
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts +4 -5
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +4 -4
- package/dist/types/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +20 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +4 -2
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +30 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +13 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useThemeContext.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +2 -6
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Surfaces.stories.d.ts +6 -2
- package/dist/types/src/playground/Surfaces.stories.d.ts.map +1 -1
- package/dist/types/src/playground/Typography.stories.d.ts +1 -1
- package/dist/types/src/testing/decorators/index.d.ts +1 -0
- package/dist/types/src/testing/decorators/index.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withVariants.d.ts +13 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -0
- package/package.json +20 -14
- package/src/components/Avatars/Avatar.stories.tsx +3 -2
- package/src/components/Avatars/AvatarGroup.stories.tsx +3 -2
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +3 -2
- package/src/components/Buttons/Button.stories.tsx +34 -63
- package/src/components/Buttons/Toggle.stories.tsx +3 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +3 -2
- package/src/components/DensityProvider/DensityProvider.tsx +1 -1
- package/src/components/Dialogs/AlertDialog.stories.tsx +3 -2
- package/src/components/Dialogs/Dialog.stories.tsx +3 -2
- package/src/components/Input/Input.stories.tsx +4 -3
- package/src/components/Link/Link.stories.tsx +1 -1
- package/src/components/Lists/List.stories.tsx +4 -4
- package/src/components/Lists/Tree.stories.tsx +3 -2
- package/src/components/Lists/Treegrid.stories.tsx +7 -5
- package/src/components/Main/Main.stories.tsx +3 -2
- package/src/components/Menus/ContextMenu.stories.tsx +3 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +3 -2
- package/src/components/Message/Message.stories.tsx +3 -2
- package/src/components/Popover/Popover.stories.tsx +3 -2
- package/src/components/ScrollArea/ScrollArea.stories.tsx +3 -2
- package/src/components/Select/Select.stories.tsx +14 -31
- package/src/components/Select/Select.tsx +9 -10
- package/src/components/Status/Status.stories.tsx +1 -2
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/ThemeProvider/ThemeProvider.tsx +17 -18
- package/src/components/Toast/Toast.stories.tsx +3 -2
- package/src/components/Toast/Toast.tsx +1 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +3 -2
- package/src/components/Toolbar/Toolbar.tsx +21 -1
- package/src/components/Tooltip/Tooltip.stories.tsx +3 -2
- package/src/hooks/useThemeContext.ts +3 -1
- package/src/playground/Controls.stories.tsx +7 -10
- package/src/playground/Surfaces.stories.tsx +4 -3
- package/src/playground/Typography.stories.tsx +2 -2
- package/src/testing/decorators/index.ts +1 -0
- package/src/testing/decorators/withVariants.tsx +45 -0
- package/dist/types/src/playground/helpers.d.ts +0 -6
- package/dist/types/src/playground/helpers.d.ts.map +0 -1
- package/src/playground/helpers.tsx +0 -32
|
@@ -7,7 +7,15 @@ import React, { forwardRef } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useThemeContext } from '../../hooks';
|
|
9
9
|
import { type ThemedClassName } from '../../util';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
ButtonGroup,
|
|
13
|
+
type ButtonGroupProps,
|
|
14
|
+
type ButtonProps,
|
|
15
|
+
Toggle,
|
|
16
|
+
type ToggleGroupItemProps,
|
|
17
|
+
type ToggleProps,
|
|
18
|
+
} from '../Buttons';
|
|
11
19
|
import { Link, type LinkProps } from '../Link';
|
|
12
20
|
import { Separator, type SeparatorProps } from '../Separator';
|
|
13
21
|
|
|
@@ -32,6 +40,16 @@ const ToolbarButton = forwardRef<HTMLButtonElement, ToolbarButtonProps>((props,
|
|
|
32
40
|
);
|
|
33
41
|
});
|
|
34
42
|
|
|
43
|
+
type ToolbarToggleProps = ToggleProps;
|
|
44
|
+
|
|
45
|
+
const ToolbarToggle = forwardRef<HTMLButtonElement, ToolbarToggleProps>((props, forwardedRef) => {
|
|
46
|
+
return (
|
|
47
|
+
<ToolbarPrimitive.Button asChild>
|
|
48
|
+
<Toggle {...props} ref={forwardedRef} />
|
|
49
|
+
</ToolbarPrimitive.Button>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
35
53
|
type ToolbarLinkProps = LinkProps;
|
|
36
54
|
|
|
37
55
|
const ToolbarLink = forwardRef<HTMLAnchorElement, ToolbarLinkProps>((props, forwardedRef) => {
|
|
@@ -84,6 +102,7 @@ export const Toolbar = {
|
|
|
84
102
|
Root: ToolbarRoot,
|
|
85
103
|
Button: ToolbarButton,
|
|
86
104
|
Link: ToolbarLink,
|
|
105
|
+
Toggle: ToolbarToggle,
|
|
87
106
|
ToggleGroup: ToolbarToggleGroup,
|
|
88
107
|
ToggleGroupItem: ToolbarToggleGroupItem,
|
|
89
108
|
Separator: ToolbarSeparator,
|
|
@@ -93,6 +112,7 @@ export type {
|
|
|
93
112
|
ToolbarRootProps,
|
|
94
113
|
ToolbarButtonProps,
|
|
95
114
|
ToolbarLinkProps,
|
|
115
|
+
ToolbarToggleProps,
|
|
96
116
|
ToolbarToggleGroupProps,
|
|
97
117
|
ToolbarToggleGroupItemProps,
|
|
98
118
|
ToolbarSeparatorProps,
|
|
@@ -29,8 +29,9 @@ const StoryTooltip = ({ content }: StoryTooltipProps) => (
|
|
|
29
29
|
);
|
|
30
30
|
|
|
31
31
|
export default {
|
|
32
|
-
title: 'react-ui/Tooltip',
|
|
33
|
-
component:
|
|
32
|
+
title: 'ui/react-ui-core/Tooltip',
|
|
33
|
+
component: Tooltip,
|
|
34
|
+
render: StoryTooltip,
|
|
34
35
|
decorators: [withTheme],
|
|
35
36
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
36
37
|
};
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { useContext } from 'react';
|
|
6
6
|
|
|
7
|
+
import { raise } from '@dxos/debug';
|
|
8
|
+
|
|
7
9
|
import { ThemeContext } from '../components';
|
|
8
10
|
|
|
9
|
-
export const useThemeContext = () => useContext(ThemeContext);
|
|
11
|
+
export const useThemeContext = () => useContext(ThemeContext) ?? raise(new Error('Missing ThemeContext'));
|
|
@@ -7,11 +7,10 @@ import '@dxos-theme';
|
|
|
7
7
|
import { FileTs, FileJs, ArrowClockwise, Bug, TextUnderline, TextB, TextItalic } from '@phosphor-icons/react';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { createScenarios } from './helpers';
|
|
11
10
|
import { Input, Select, Toggle, Toolbar } from '../components';
|
|
12
|
-
import { withTheme } from '../testing';
|
|
11
|
+
import { withTheme, withVariants } from '../testing';
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const DefaultStory = () => {
|
|
15
14
|
const [checked, setChecked] = useState<boolean>(false);
|
|
16
15
|
const [select, setSelect] = useState<string>();
|
|
17
16
|
|
|
@@ -82,13 +81,11 @@ const Story = () => {
|
|
|
82
81
|
);
|
|
83
82
|
};
|
|
84
83
|
|
|
84
|
+
export const Default = {};
|
|
85
|
+
|
|
85
86
|
export default {
|
|
86
|
-
title: 'react-ui/
|
|
87
|
-
|
|
88
|
-
decorators: [withTheme],
|
|
87
|
+
title: 'ui/react-ui-core/Playground/Controls',
|
|
88
|
+
render: DefaultStory,
|
|
89
|
+
decorators: [withVariants(), withTheme],
|
|
89
90
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
-
export const Default = {
|
|
93
|
-
render: createScenarios(Story),
|
|
94
|
-
};
|
|
@@ -47,7 +47,7 @@ const Surface = ({ children, level }: PropsWithChildren & { level: SurfaceLevel
|
|
|
47
47
|
);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const SurfaceStory = () => {
|
|
51
51
|
return (
|
|
52
52
|
<div className='bg-cubes p-10 m-0'>
|
|
53
53
|
<Surface level='fixed' />
|
|
@@ -61,8 +61,9 @@ const SurfacesStory = () => {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export default {
|
|
64
|
-
title: 'react-ui/
|
|
65
|
-
component:
|
|
64
|
+
title: 'ui/react-ui-core/Playground/Surfaces',
|
|
65
|
+
component: Surface,
|
|
66
|
+
render: SurfaceStory,
|
|
66
67
|
decorators: [withTheme],
|
|
67
68
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
68
69
|
};
|
|
@@ -44,8 +44,8 @@ const TypographyStory = () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export default {
|
|
47
|
-
title: 'react-ui/
|
|
48
|
-
|
|
47
|
+
title: 'ui/react-ui-core/Playground/Typography',
|
|
48
|
+
render: TypographyStory,
|
|
49
49
|
decorators: [withTheme],
|
|
50
50
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
51
51
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Decorator } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { modalSurface, groupSurface, mx, surfaceElevation } from '@dxos/react-ui-theme';
|
|
11
|
+
import { type Density, type Elevation } from '@dxos/react-ui-types';
|
|
12
|
+
|
|
13
|
+
import { DensityProvider, ElevationProvider } from '../../components';
|
|
14
|
+
|
|
15
|
+
type Config = {
|
|
16
|
+
elevations?: { elevation: Elevation; surface?: string }[];
|
|
17
|
+
densities?: Density[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const withVariants = ({
|
|
21
|
+
elevations = [
|
|
22
|
+
{ elevation: 'base' },
|
|
23
|
+
{ elevation: 'group', surface: groupSurface },
|
|
24
|
+
{ elevation: 'chrome', surface: modalSurface },
|
|
25
|
+
],
|
|
26
|
+
densities = ['coarse', 'fine'],
|
|
27
|
+
}: Config = {}): Decorator => {
|
|
28
|
+
return (Story) => (
|
|
29
|
+
<div className='flex flex-col gap-8'>
|
|
30
|
+
{elevations.map(({ elevation, surface }) => (
|
|
31
|
+
<ElevationProvider key={elevation} elevation={elevation}>
|
|
32
|
+
<div className='flex flex-col gap-8'>
|
|
33
|
+
{densities.map((density) => (
|
|
34
|
+
<DensityProvider key={density} density={density}>
|
|
35
|
+
<div className={mx('p-4 rounded-lg', surface, surfaceElevation({ elevation }))}>
|
|
36
|
+
<Story />
|
|
37
|
+
</div>
|
|
38
|
+
</DensityProvider>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
</ElevationProvider>
|
|
42
|
+
))}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/playground/helpers.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOtD,eAAO,MAAM,eAAe,cACd,iBAAiB,CAAC,GAAG,CAAC;;uBAiBjC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import React, { type FunctionComponent } from 'react';
|
|
8
|
-
|
|
9
|
-
import { type Density } from '@dxos/react-ui-types';
|
|
10
|
-
|
|
11
|
-
import { DensityProvider, ElevationProvider } from '../components';
|
|
12
|
-
|
|
13
|
-
// TODO(burdon): Grid: density, variant (context?), elevation.
|
|
14
|
-
export const createScenarios =
|
|
15
|
-
(Component: FunctionComponent<any>) =>
|
|
16
|
-
({ ...props }) => {
|
|
17
|
-
const densities: Density[] = ['coarse', 'fine'];
|
|
18
|
-
return (
|
|
19
|
-
<div className='flex flex-col space-y-8'>
|
|
20
|
-
{densities.map((density) => (
|
|
21
|
-
<div key={density}>
|
|
22
|
-
<ElevationProvider elevation='chrome'>
|
|
23
|
-
<DensityProvider density={density}>
|
|
24
|
-
<label className='p-2 text-xs'>{density}</label>
|
|
25
|
-
<Component {...props} />
|
|
26
|
-
</DensityProvider>
|
|
27
|
-
</ElevationProvider>
|
|
28
|
-
</div>
|
|
29
|
-
))}
|
|
30
|
-
</div>
|
|
31
|
-
);
|
|
32
|
-
};
|