@dxos/react-ui 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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 +1081 -1616
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1404 -1941
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1081 -1616
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Avatars/Avatar.d.ts +2 -2
- package/dist/types/src/components/Avatars/Avatar.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts +3 -3
- package/dist/types/src/components/Avatars/Avatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts +1 -0
- package/dist/types/src/components/Avatars/AvatarGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +44 -10
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts +5 -4
- package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts +6 -7
- package/dist/types/src/components/Buttons/IconButton.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/Toggle.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts +4 -1
- package/dist/types/src/components/Buttons/ToggleGroup.stories.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/ClipboardProvider.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/CopyButton.d.ts +1 -2
- package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
- package/dist/types/src/components/Clipboard/index.d.ts +2 -2
- package/dist/types/src/components/DensityProvider/DensityProvider.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/AlertDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts +2 -2
- package/dist/types/src/components/Dialogs/Dialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/ElevationProvider/ElevationProvider.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.d.ts +1 -1
- package/dist/types/src/components/Input/Input.d.ts.map +1 -1
- package/dist/types/src/components/Input/Input.stories.d.ts +159 -33
- package/dist/types/src/components/Input/Input.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/ListDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/components/Lists/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts +1 -1
- package/dist/types/src/components/Lists/Treegrid.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.stories.d.ts.map +1 -1
- package/dist/types/src/components/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/Message/Message.stories.d.ts +2 -2
- package/dist/types/src/components/Message/Message.stories.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts +6 -15
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.stories.d.ts +1 -5
- package/dist/types/src/components/Popover/Popover.stories.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.stories.d.ts.map +1 -1
- package/dist/types/src/components/Status/Status.stories.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/ThemeProvider.d.ts.map +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts +1 -1
- package/dist/types/src/components/ThemeProvider/TranslationsProvider.d.ts.map +1 -1
- package/dist/types/src/components/Toast/Toast.stories.d.ts +2 -2
- package/dist/types/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.d.ts +20 -94
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +17 -41
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDensityContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useElevationContext.d.ts.map +1 -1
- package/dist/types/src/hooks/useIconHref.d.ts.map +1 -1
- package/dist/types/src/hooks/useSafeCollisionPadding.d.ts.map +1 -1
- package/dist/types/src/hooks/useVisualViewport.d.ts.map +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts +1 -1
- package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -14
- package/src/components/Avatars/Avatar.stories.tsx +27 -27
- package/src/components/Avatars/Avatar.tsx +13 -17
- package/src/components/Avatars/AvatarGroup.stories.tsx +5 -4
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +2 -2
- package/src/components/Buttons/Button.stories.tsx +14 -19
- package/src/components/Buttons/IconButton.stories.tsx +10 -9
- package/src/components/Buttons/IconButton.tsx +33 -8
- package/src/components/Buttons/Toggle.stories.tsx +2 -2
- package/src/components/Buttons/ToggleGroup.stories.tsx +7 -3
- package/src/components/Clipboard/CopyButton.tsx +24 -22
- package/src/components/Dialogs/AlertDialog.stories.tsx +11 -4
- package/src/components/Dialogs/Dialog.stories.tsx +3 -3
- package/src/components/Dialogs/Dialog.tsx +4 -8
- package/src/components/Input/Input.stories.tsx +56 -67
- package/src/components/Input/Input.tsx +0 -1
- package/src/components/Lists/Tree.stories.tsx +2 -2
- package/src/components/Lists/Treegrid.stories.tsx +12 -12
- package/src/components/Main/Main.stories.tsx +2 -2
- package/src/components/Menus/ContextMenu.stories.tsx +2 -2
- package/src/components/Menus/DropdownMenu.stories.tsx +2 -2
- package/src/components/Message/Message.stories.tsx +3 -3
- package/src/components/Popover/Popover.stories.tsx +2 -2
- package/src/components/Popover/Popover.tsx +4 -8
- package/src/components/ScrollArea/ScrollArea.stories.tsx +2 -2
- package/src/components/ScrollArea/ScrollArea.tsx +0 -3
- package/src/components/Toast/Toast.stories.tsx +10 -15
- package/src/components/Toolbar/Toolbar.stories.tsx +2 -2
- package/src/components/Tooltip/Tooltip.stories.tsx +18 -43
- package/src/components/Tooltip/Tooltip.tsx +58 -748
- package/src/components/index.ts +1 -1
- package/src/playground/Controls.stories.tsx +2 -2
- package/src/playground/Typography.stories.tsx +2 -2
- package/dist/types/src/playground/Custom.stories.d.ts +0 -8
- package/dist/types/src/playground/Custom.stories.d.ts.map +0 -1
- package/src/playground/Custom.stories.tsx +0 -137
|
@@ -13,7 +13,7 @@ import { withTheme } from '../../testing';
|
|
|
13
13
|
|
|
14
14
|
const hues = ['lime', 'teal', 'purple', 'pink'];
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const StorybookAvatarGroupItem = ({ n }: { n: number }) => {
|
|
17
17
|
const emoji = toEmoji(n);
|
|
18
18
|
return (
|
|
19
19
|
<Avatar.Root>
|
|
@@ -22,12 +22,12 @@ const AvatarItem = ({ n }: { n: number }) => {
|
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const StorybookAvatarGroup = () => {
|
|
26
26
|
const labelId = useId('sb-avatar-group');
|
|
27
27
|
return (
|
|
28
28
|
<div className='dx-avatar-group' aria-labelledby={labelId}>
|
|
29
29
|
{[0, 1, 2, 3].map((n) => (
|
|
30
|
-
<
|
|
30
|
+
<StorybookAvatarGroupItem key={n} n={n} />
|
|
31
31
|
))}
|
|
32
32
|
<span className='sr-only' id={labelId}>
|
|
33
33
|
23
|
|
@@ -38,7 +38,8 @@ const DefaultStory = () => {
|
|
|
38
38
|
|
|
39
39
|
export default {
|
|
40
40
|
title: 'ui/react-ui-core/AvatarGroup',
|
|
41
|
-
|
|
41
|
+
component: StorybookAvatarGroup,
|
|
42
|
+
render: StorybookAvatarGroup,
|
|
42
43
|
decorators: [withTheme],
|
|
43
44
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
44
45
|
};
|
|
@@ -10,7 +10,7 @@ import { Breadcrumb } from './Breadcrumb';
|
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
import { Button } from '../Buttons';
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const StorybookBreadcrumb = () => {
|
|
14
14
|
return (
|
|
15
15
|
<Breadcrumb.Root aria-label='Breadcrumb'>
|
|
16
16
|
<Breadcrumb.List>
|
|
@@ -41,7 +41,7 @@ const DefaultStory = () => {
|
|
|
41
41
|
export default {
|
|
42
42
|
title: 'ui/react-ui-core/Breadcrumb',
|
|
43
43
|
component: Breadcrumb,
|
|
44
|
-
render:
|
|
44
|
+
render: StorybookBreadcrumb,
|
|
45
45
|
decorators: [withTheme],
|
|
46
46
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
47
47
|
};
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
7
|
import { CaretLeft, CaretRight } from '@phosphor-icons/react';
|
|
8
|
-
import { type StoryObj, type Meta } from '@storybook/react';
|
|
9
8
|
import React from 'react';
|
|
10
9
|
|
|
11
10
|
import { Button, ButtonGroup, type ButtonProps } from './Button';
|
|
@@ -32,36 +31,32 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
|
|
|
32
31
|
);
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
const
|
|
36
|
-
title: 'ui/react-ui-core/Button',
|
|
37
|
-
component: Button,
|
|
38
|
-
render: DefaultStory,
|
|
39
|
-
decorators: [withVariants(), withTheme],
|
|
40
|
-
parameters: { chromatic: { disableSnapshot: false } },
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default meta;
|
|
44
|
-
|
|
45
|
-
type Story = StoryObj<typeof meta>;
|
|
34
|
+
const defaults = { children: 'Test' };
|
|
46
35
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
export const Default: Story = {
|
|
36
|
+
export const Default = {
|
|
50
37
|
args: { ...defaults, variant: 'default' },
|
|
51
38
|
};
|
|
52
39
|
|
|
53
|
-
export const Primary
|
|
40
|
+
export const Primary = {
|
|
54
41
|
args: { ...defaults, variant: 'primary' },
|
|
55
42
|
};
|
|
56
43
|
|
|
57
|
-
export const Destructive
|
|
44
|
+
export const Destructive = {
|
|
58
45
|
args: { ...defaults, variant: 'destructive' },
|
|
59
46
|
};
|
|
60
47
|
|
|
61
|
-
export const Outline
|
|
48
|
+
export const Outline = {
|
|
62
49
|
args: { ...defaults, variant: 'outline' },
|
|
63
50
|
};
|
|
64
51
|
|
|
65
|
-
export const Ghost
|
|
52
|
+
export const Ghost = {
|
|
66
53
|
args: { ...defaults, variant: 'ghost' },
|
|
67
54
|
};
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
title: 'ui/react-ui-core/Button',
|
|
58
|
+
component: Button,
|
|
59
|
+
decorators: [withVariants(), withTheme],
|
|
60
|
+
render: DefaultStory,
|
|
61
|
+
parameters: { chromatic: { disableSnapshot: false } },
|
|
62
|
+
};
|
|
@@ -6,18 +6,22 @@ import '@dxos-theme';
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
|
|
9
|
-
import { IconButton
|
|
9
|
+
import { IconButton } from './IconButton';
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
import { Tooltip } from '../Tooltip';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
type StorybookIconButtonProps = {
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const StorybookIconButton = (props: StorybookIconButtonProps) => {
|
|
14
18
|
return (
|
|
15
19
|
<Tooltip.Provider>
|
|
16
20
|
<div className='mbe-4'>
|
|
17
|
-
<IconButton {...props} />
|
|
21
|
+
<IconButton label='Bold' icon='ph--text-b--bold' {...props} />
|
|
18
22
|
</div>
|
|
19
23
|
<div className='mbe-4'>
|
|
20
|
-
<IconButton iconOnly {...props} />
|
|
24
|
+
<IconButton iconOnly label='Bold' icon='ph--text-b--bold' {...props} />
|
|
21
25
|
</div>
|
|
22
26
|
</Tooltip.Provider>
|
|
23
27
|
);
|
|
@@ -26,14 +30,11 @@ const DefaultStory = (props: IconButtonProps) => {
|
|
|
26
30
|
export default {
|
|
27
31
|
title: 'ui/react-ui-core/IconButton',
|
|
28
32
|
component: IconButton,
|
|
29
|
-
render:
|
|
33
|
+
render: StorybookIconButton,
|
|
30
34
|
decorators: [withTheme],
|
|
31
35
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
export const Default = {
|
|
35
|
-
args: {
|
|
36
|
-
label: 'Bold',
|
|
37
|
-
icon: 'ph--text-b--regular',
|
|
38
|
-
},
|
|
39
|
+
args: {},
|
|
39
40
|
};
|
|
@@ -2,35 +2,60 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { forwardRef, type MutableRefObject } from 'react';
|
|
5
|
+
import React, { forwardRef, type ReactNode, type MutableRefObject, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Button, type ButtonProps } from './Button';
|
|
8
8
|
import { useThemeContext } from '../../hooks';
|
|
9
9
|
import { type ThemedClassName } from '../../util';
|
|
10
10
|
import { Icon, type IconProps } from '../Icon';
|
|
11
|
-
import { Tooltip, type
|
|
11
|
+
import { Tooltip, type TooltipContentProps } from '../Tooltip';
|
|
12
12
|
|
|
13
13
|
type IconButtonProps = Omit<ButtonProps, 'children'> &
|
|
14
14
|
Pick<IconProps, 'icon' | 'size'> & {
|
|
15
|
-
label:
|
|
15
|
+
label: NonNullable<ReactNode>;
|
|
16
16
|
iconOnly?: boolean;
|
|
17
17
|
noTooltip?: boolean;
|
|
18
18
|
caretDown?: boolean;
|
|
19
|
+
// TODO(burdon): Create slots abstraction?
|
|
19
20
|
iconClassNames?: ThemedClassName<any>['classNames'];
|
|
20
21
|
tooltipPortal?: boolean;
|
|
21
|
-
|
|
22
|
+
tooltipZIndex?: string;
|
|
23
|
+
tooltipSide?: TooltipContentProps['side'];
|
|
22
24
|
suppressNextTooltip?: MutableRefObject<boolean>;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
const IconOnlyButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
26
|
-
(
|
|
28
|
+
(
|
|
29
|
+
{ noTooltip, tooltipPortal = true, tooltipZIndex: zIndex, tooltipSide, suppressNextTooltip, ...props },
|
|
30
|
+
forwardedRef,
|
|
31
|
+
) => {
|
|
32
|
+
const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
|
|
27
33
|
if (noTooltip) {
|
|
28
34
|
return <LabelledIconButton {...props} ref={forwardedRef} />;
|
|
29
35
|
}
|
|
36
|
+
const content = (
|
|
37
|
+
<Tooltip.Content {...(zIndex && { style: { zIndex } })} side={tooltipSide}>
|
|
38
|
+
{props.label}
|
|
39
|
+
<Tooltip.Arrow />
|
|
40
|
+
</Tooltip.Content>
|
|
41
|
+
);
|
|
30
42
|
return (
|
|
31
|
-
<Tooltip.
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
<Tooltip.Root
|
|
44
|
+
open={triggerTooltipOpen}
|
|
45
|
+
onOpenChange={(nextOpen) => {
|
|
46
|
+
if (suppressNextTooltip?.current) {
|
|
47
|
+
setTriggerTooltipOpen(false);
|
|
48
|
+
suppressNextTooltip.current = false;
|
|
49
|
+
} else {
|
|
50
|
+
setTriggerTooltipOpen(nextOpen);
|
|
51
|
+
}
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<Tooltip.Trigger asChild>
|
|
55
|
+
<LabelledIconButton {...props} ref={forwardedRef} />
|
|
56
|
+
</Tooltip.Trigger>
|
|
57
|
+
{tooltipPortal ? <Tooltip.Portal>{content}</Tooltip.Portal> : content}
|
|
58
|
+
</Tooltip.Root>
|
|
34
59
|
);
|
|
35
60
|
},
|
|
36
61
|
);
|
|
@@ -12,7 +12,7 @@ import { withTheme } from '../../testing';
|
|
|
12
12
|
|
|
13
13
|
type StorybookToggleProps = {};
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const StorybookToggle = (props: StorybookToggleProps) => {
|
|
16
16
|
return (
|
|
17
17
|
<Toggle {...props}>
|
|
18
18
|
<TextB />
|
|
@@ -23,7 +23,7 @@ const DefaultStory = (props: StorybookToggleProps) => {
|
|
|
23
23
|
export default {
|
|
24
24
|
title: 'ui/react-ui-core/Toggle',
|
|
25
25
|
component: Toggle,
|
|
26
|
-
render:
|
|
26
|
+
render: StorybookToggle,
|
|
27
27
|
decorators: [withTheme],
|
|
28
28
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
29
29
|
};
|
|
@@ -10,8 +10,12 @@ import React from 'react';
|
|
|
10
10
|
import { ToggleGroup, ToggleGroupItem, type ToggleGroupProps } from './ToggleGroup';
|
|
11
11
|
import { withTheme } from '../../testing';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
type StorybookToggleGroupProps = {
|
|
14
|
+
type: ToggleGroupProps['type'];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// TODO(burdon): ToggleGroup.Item.
|
|
18
|
+
const StorybookToggleGroup = (props: StorybookToggleGroupProps) => {
|
|
15
19
|
return (
|
|
16
20
|
<ToggleGroup {...props}>
|
|
17
21
|
<ToggleGroupItem value='textb'>
|
|
@@ -27,7 +31,7 @@ const DefaultStory = (props: ToggleGroupProps) => {
|
|
|
27
31
|
export default {
|
|
28
32
|
title: 'ui/react-ui-core/ToggleGroup',
|
|
29
33
|
component: ToggleGroup,
|
|
30
|
-
render:
|
|
34
|
+
render: StorybookToggleGroup,
|
|
31
35
|
decorators: [withTheme],
|
|
32
36
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
33
37
|
};
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type IconProps } from '@phosphor-icons/react';
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { mx } from '@dxos/react-ui-theme';
|
|
9
9
|
|
|
10
10
|
import { useClipboard } from './ClipboardProvider';
|
|
11
|
-
import { Button, type ButtonProps
|
|
11
|
+
import { Button, type ButtonProps } from '../Buttons';
|
|
12
12
|
import { Icon } from '../Icon';
|
|
13
13
|
import { useTranslation } from '../ThemeProvider';
|
|
14
|
-
import {
|
|
14
|
+
import { Tooltip } from '../Tooltip';
|
|
15
15
|
|
|
16
16
|
export type CopyButtonProps = ButtonProps & {
|
|
17
17
|
value: string;
|
|
@@ -48,29 +48,31 @@ type CopyButtonIconOnlyProps = CopyButtonProps & {
|
|
|
48
48
|
label?: string;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export const CopyButtonIconOnly = ({
|
|
52
|
-
__scopeTooltip,
|
|
53
|
-
value,
|
|
54
|
-
classNames,
|
|
55
|
-
iconProps,
|
|
56
|
-
variant,
|
|
57
|
-
...props
|
|
58
|
-
}: TooltipScopedProps<CopyButtonIconOnlyProps>) => {
|
|
51
|
+
export const CopyButtonIconOnly = ({ value, classNames, iconProps, variant, ...props }: CopyButtonIconOnlyProps) => {
|
|
59
52
|
const { t } = useTranslation('os');
|
|
60
53
|
const { textValue, setTextValue } = useClipboard();
|
|
61
54
|
const isCopied = textValue === value;
|
|
62
55
|
const label = isCopied ? t('copy success label') : props.label ?? t('copy label');
|
|
63
|
-
const
|
|
56
|
+
const [open, setOpen] = useState(false);
|
|
64
57
|
return (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
58
|
+
<Tooltip.Root delayDuration={1500} open={open} onOpenChange={setOpen}>
|
|
59
|
+
<Tooltip.Portal>
|
|
60
|
+
<Tooltip.Content side='bottom' sideOffset={12}>
|
|
61
|
+
<span>{label}</span>
|
|
62
|
+
<Tooltip.Arrow />
|
|
63
|
+
</Tooltip.Content>
|
|
64
|
+
</Tooltip.Portal>
|
|
65
|
+
<Tooltip.Trigger
|
|
66
|
+
aria-label={label}
|
|
67
|
+
{...props}
|
|
68
|
+
onClick={() => setTextValue(value).then(() => setOpen(true))}
|
|
69
|
+
data-testid='copy-invitation'
|
|
70
|
+
asChild
|
|
71
|
+
>
|
|
72
|
+
<Button variant={variant} classNames={['inline-flex flex-col justify-center', classNames]}>
|
|
73
|
+
<Icon icon='ph--copy--regular' size={5 as any} {...iconProps} />
|
|
74
|
+
</Button>
|
|
75
|
+
</Tooltip.Trigger>
|
|
76
|
+
</Tooltip.Root>
|
|
75
77
|
);
|
|
76
78
|
};
|
|
@@ -11,16 +11,23 @@ import { withTheme } from '../../testing';
|
|
|
11
11
|
import { Button } from '../Buttons';
|
|
12
12
|
import { Toolbar } from '../Toolbar';
|
|
13
13
|
|
|
14
|
-
type
|
|
14
|
+
type StorybookAlertDialogProps = Partial<{
|
|
15
15
|
title: string;
|
|
16
16
|
description: string;
|
|
17
17
|
body: string;
|
|
18
|
-
cancelTrigger: string;
|
|
18
|
+
cancelTrigger: string; // TODO(burdon): Why trigger?
|
|
19
19
|
actionTrigger: string;
|
|
20
20
|
openTrigger: string;
|
|
21
21
|
}>;
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const StorybookAlertDialog = ({
|
|
24
|
+
title,
|
|
25
|
+
openTrigger,
|
|
26
|
+
description,
|
|
27
|
+
body,
|
|
28
|
+
cancelTrigger,
|
|
29
|
+
actionTrigger,
|
|
30
|
+
}: StorybookAlertDialogProps) => {
|
|
24
31
|
return (
|
|
25
32
|
<AlertDialog.Root defaultOpen>
|
|
26
33
|
<AlertDialog.Trigger asChild>
|
|
@@ -49,7 +56,7 @@ const DefaultStory = ({ title, openTrigger, description, body, cancelTrigger, ac
|
|
|
49
56
|
export default {
|
|
50
57
|
title: 'ui/react-ui-core/AlertDialog',
|
|
51
58
|
component: AlertDialog,
|
|
52
|
-
render:
|
|
59
|
+
render: StorybookAlertDialog,
|
|
53
60
|
decorators: [withTheme],
|
|
54
61
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
55
62
|
};
|
|
@@ -10,7 +10,7 @@ import { Dialog } from './Dialog';
|
|
|
10
10
|
import { withTheme } from '../../testing';
|
|
11
11
|
import { Button } from '../Buttons';
|
|
12
12
|
|
|
13
|
-
type
|
|
13
|
+
type StorybookDialogProps = Partial<{
|
|
14
14
|
title: string;
|
|
15
15
|
description: string;
|
|
16
16
|
body: string;
|
|
@@ -19,7 +19,7 @@ type DefaultStoryProps = Partial<{
|
|
|
19
19
|
blockAlign: 'center' | 'start';
|
|
20
20
|
}>;
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const StorybookDialog = ({ title, openTrigger, description, body, closeTrigger, blockAlign }: StorybookDialogProps) => {
|
|
23
23
|
return (
|
|
24
24
|
<Dialog.Root defaultOpen>
|
|
25
25
|
<Dialog.Trigger asChild>
|
|
@@ -42,7 +42,7 @@ const DefaultStory = ({ title, openTrigger, description, body, closeTrigger, blo
|
|
|
42
42
|
export default {
|
|
43
43
|
title: 'ui/react-ui-core/Dialog',
|
|
44
44
|
component: Dialog,
|
|
45
|
-
render:
|
|
45
|
+
render: StorybookDialog,
|
|
46
46
|
decorators: [withTheme],
|
|
47
47
|
parameters: { chromatic: { disableSnapshot: false } },
|
|
48
48
|
};
|
|
@@ -81,12 +81,11 @@ const DialogClose: FunctionComponent<DialogCloseProps> = DialogClosePrimitive;
|
|
|
81
81
|
type OverlayLayoutContextValue = { inOverlayLayout?: boolean };
|
|
82
82
|
const DIALOG_OVERLAY_NAME = 'DialogOverlay';
|
|
83
83
|
const DIALOG_CONTENT_NAME = 'DialogContent';
|
|
84
|
-
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
84
|
+
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(DIALOG_OVERLAY_NAME, {
|
|
85
|
+
inOverlayLayout: false,
|
|
86
|
+
});
|
|
88
87
|
|
|
89
|
-
type DialogOverlayProps = ThemedClassName<DialogOverlayPrimitiveProps & { blockAlign?: 'center' | 'start' | 'end' }
|
|
88
|
+
type DialogOverlayProps = ThemedClassName<DialogOverlayPrimitiveProps> & { blockAlign?: 'center' | 'start' | 'end' };
|
|
90
89
|
|
|
91
90
|
const DialogOverlay: ForwardRefExoticComponent<DialogOverlayProps> = forwardRef<HTMLDivElement, DialogOverlayProps>(
|
|
92
91
|
({ classNames, children, blockAlign, ...props }, forwardedRef) => {
|
|
@@ -116,9 +115,6 @@ const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<
|
|
|
116
115
|
|
|
117
116
|
return (
|
|
118
117
|
<DialogContentPrimitive
|
|
119
|
-
// NOTE: Radix warning unless set to undefined.
|
|
120
|
-
// https://www.radix-ui.com/primitives/docs/components/dialog#description
|
|
121
|
-
aria-describedby={undefined}
|
|
122
118
|
{...props}
|
|
123
119
|
className={tx(
|
|
124
120
|
'dialog.content',
|