@dxos/react-ui 0.8.2-main.5885341 → 0.8.2-main.600d381
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 +839 -307
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +957 -423
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +839 -307
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Buttons/Button.stories.d.ts +10 -44
- package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
- package/dist/types/src/components/Buttons/IconButton.d.ts +4 -5
- package/dist/types/src/components/Buttons/IconButton.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 +2 -1
- 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/Dialog.d.ts +6 -2
- package/dist/types/src/components/Dialogs/Dialog.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.map +1 -1
- 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/TreeDropIndicator.d.ts.map +1 -1
- package/dist/types/src/components/Main/Main.d.ts.map +1 -1
- package/dist/types/src/components/Main/useSwipeToDismiss.d.ts.map +1 -1
- package/dist/types/src/components/ScrollArea/ScrollArea.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/Tooltip/Tooltip.d.ts +94 -20
- package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +40 -16
- package/dist/types/src/components/Tooltip/Tooltip.stories.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/playground/Custom.stories.d.ts +8 -0
- package/dist/types/src/playground/Custom.stories.d.ts.map +1 -0
- package/dist/types/src/testing/decorators/withVariants.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/src/components/Buttons/Button.stories.tsx +19 -14
- package/src/components/Buttons/IconButton.stories.tsx +2 -2
- package/src/components/Buttons/IconButton.tsx +8 -33
- package/src/components/Clipboard/CopyButton.tsx +22 -24
- package/src/components/Dialogs/Dialog.tsx +12 -7
- package/src/components/ScrollArea/ScrollArea.tsx +3 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +41 -16
- package/src/components/Tooltip/Tooltip.tsx +748 -58
- package/src/playground/Controls.stories.tsx +2 -2
- package/src/playground/Custom.stories.tsx +137 -0
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type IconProps } from '@phosphor-icons/react';
|
|
6
|
-
import React
|
|
6
|
+
import React 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 } from '../Buttons';
|
|
11
|
+
import { Button, type ButtonProps, IconButton } from '../Buttons';
|
|
12
12
|
import { Icon } from '../Icon';
|
|
13
13
|
import { useTranslation } from '../ThemeProvider';
|
|
14
|
-
import {
|
|
14
|
+
import { type TooltipScopedProps, useTooltipContext } from '../Tooltip';
|
|
15
15
|
|
|
16
16
|
export type CopyButtonProps = ButtonProps & {
|
|
17
17
|
value: string;
|
|
@@ -48,31 +48,29 @@ type CopyButtonIconOnlyProps = CopyButtonProps & {
|
|
|
48
48
|
label?: string;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
export const CopyButtonIconOnly = ({
|
|
51
|
+
export const CopyButtonIconOnly = ({
|
|
52
|
+
__scopeTooltip,
|
|
53
|
+
value,
|
|
54
|
+
classNames,
|
|
55
|
+
iconProps,
|
|
56
|
+
variant,
|
|
57
|
+
...props
|
|
58
|
+
}: TooltipScopedProps<CopyButtonIconOnlyProps>) => {
|
|
52
59
|
const { t } = useTranslation('os');
|
|
53
60
|
const { textValue, setTextValue } = useClipboard();
|
|
54
61
|
const isCopied = textValue === value;
|
|
55
62
|
const label = isCopied ? t('copy success label') : props.label ?? t('copy label');
|
|
56
|
-
const
|
|
63
|
+
const { onOpen } = useTooltipContext('CopyButton', __scopeTooltip);
|
|
57
64
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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>
|
|
65
|
+
<IconButton
|
|
66
|
+
iconOnly
|
|
67
|
+
label={label!}
|
|
68
|
+
icon='ph--copy--regular'
|
|
69
|
+
size={5}
|
|
70
|
+
variant={variant}
|
|
71
|
+
classNames={['inline-flex flex-col justify-center', classNames]}
|
|
72
|
+
onClick={() => setTextValue(value).then(onOpen)}
|
|
73
|
+
data-testid='copy-invitation'
|
|
74
|
+
/>
|
|
77
75
|
);
|
|
78
76
|
};
|
|
@@ -78,14 +78,18 @@ type DialogCloseProps = DialogClosePrimitiveProps;
|
|
|
78
78
|
|
|
79
79
|
const DialogClose: FunctionComponent<DialogCloseProps> = DialogClosePrimitive;
|
|
80
80
|
|
|
81
|
-
type OverlayLayoutContextValue = { inOverlayLayout?: boolean };
|
|
81
|
+
type OverlayLayoutContextValue = { descriptionId?: string; inOverlayLayout?: boolean };
|
|
82
82
|
const DIALOG_OVERLAY_NAME = 'DialogOverlay';
|
|
83
83
|
const DIALOG_CONTENT_NAME = 'DialogContent';
|
|
84
|
-
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
|
|
85
|
-
|
|
86
|
-
}
|
|
84
|
+
const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
|
|
85
|
+
DIALOG_OVERLAY_NAME,
|
|
86
|
+
{},
|
|
87
|
+
);
|
|
87
88
|
|
|
88
|
-
type DialogOverlayProps = ThemedClassName<
|
|
89
|
+
type DialogOverlayProps = ThemedClassName<
|
|
90
|
+
DialogOverlayPrimitiveProps &
|
|
91
|
+
Pick<OverlayLayoutContextValue, 'descriptionId'> & { blockAlign?: 'center' | 'start' | 'end' }
|
|
92
|
+
>;
|
|
89
93
|
|
|
90
94
|
const DialogOverlay: ForwardRefExoticComponent<DialogOverlayProps> = forwardRef<HTMLDivElement, DialogOverlayProps>(
|
|
91
95
|
({ classNames, children, blockAlign, ...props }, forwardedRef) => {
|
|
@@ -111,11 +115,12 @@ type DialogContentProps = ThemedClassName<DialogContentPrimitiveProps> & { inOve
|
|
|
111
115
|
const DialogContent: ForwardRefExoticComponent<DialogContentProps> = forwardRef<HTMLDivElement, DialogContentProps>(
|
|
112
116
|
({ classNames, children, inOverlayLayout: propsInOverlayLayout, ...props }, forwardedRef) => {
|
|
113
117
|
const { tx } = useThemeContext();
|
|
114
|
-
const { inOverlayLayout } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
|
|
118
|
+
const { inOverlayLayout, descriptionId } = useOverlayLayoutContext(DIALOG_CONTENT_NAME);
|
|
115
119
|
|
|
116
120
|
return (
|
|
117
121
|
<DialogContentPrimitive
|
|
118
|
-
|
|
122
|
+
// NOTE: Radix warning unless set.
|
|
123
|
+
aria-describedby={descriptionId ?? 'unknown'}
|
|
119
124
|
{...props}
|
|
120
125
|
className={tx(
|
|
121
126
|
'dialog.content',
|
|
@@ -23,6 +23,9 @@ type ScrollAreaVariant = 'coarse' | 'fine';
|
|
|
23
23
|
|
|
24
24
|
type ScrollAreaRootProps = ThemedClassName<ScrollAreaPrimitiveRootProps>;
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated
|
|
28
|
+
*/
|
|
26
29
|
const ScrollAreaRoot = forwardRef<HTMLDivElement, ScrollAreaRootProps>(({ classNames, ...props }, forwardedRef) => {
|
|
27
30
|
const { tx } = useThemeContext();
|
|
28
31
|
return (
|
|
@@ -3,29 +3,28 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
|
-
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
8
|
+
import { faker } from '@dxos/random';
|
|
9
|
+
|
|
9
10
|
import { Tooltip } from './Tooltip';
|
|
10
11
|
import { withTheme } from '../../testing';
|
|
11
12
|
import { Button } from '../Buttons';
|
|
12
13
|
|
|
13
14
|
type StoryTooltipProps = {
|
|
14
|
-
content: string;
|
|
15
|
+
tooltips: { label: string; content: string }[];
|
|
15
16
|
defaultOpen?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const StoryTooltip = ({
|
|
19
|
-
<Tooltip.Provider>
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</Tooltip.Content>
|
|
28
|
-
</Tooltip.Root>
|
|
19
|
+
const StoryTooltip = ({ tooltips, defaultOpen }: StoryTooltipProps) => (
|
|
20
|
+
<Tooltip.Provider defaultOpen={defaultOpen}>
|
|
21
|
+
<div role='none' className='is-32'>
|
|
22
|
+
{tooltips.map(({ label, content }, i) => (
|
|
23
|
+
<Tooltip.Trigger asChild key={i} content={content} side='right'>
|
|
24
|
+
<Button classNames='block is-full'>{label}</Button>
|
|
25
|
+
</Tooltip.Trigger>
|
|
26
|
+
))}
|
|
27
|
+
</div>
|
|
29
28
|
</Tooltip.Provider>
|
|
30
29
|
);
|
|
31
30
|
|
|
@@ -39,19 +38,45 @@ export default {
|
|
|
39
38
|
|
|
40
39
|
export const Default = {
|
|
41
40
|
args: {
|
|
42
|
-
|
|
41
|
+
tooltips: [
|
|
42
|
+
{
|
|
43
|
+
label: 'Tooltip trigger',
|
|
44
|
+
content: 'This is the tooltip content',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
43
47
|
},
|
|
44
48
|
parameters: {
|
|
45
49
|
chromatic: { delay: 500 },
|
|
46
50
|
},
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
export const
|
|
53
|
+
export const DefaultOpen = {
|
|
50
54
|
args: {
|
|
51
55
|
defaultOption: true,
|
|
52
|
-
|
|
56
|
+
tooltips: [
|
|
57
|
+
{
|
|
58
|
+
label: 'Tooltip trigger',
|
|
59
|
+
content: 'This is the tooltip content',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
53
62
|
},
|
|
54
63
|
parameters: {
|
|
55
64
|
chromatic: { delay: 500 },
|
|
56
65
|
},
|
|
57
66
|
};
|
|
67
|
+
|
|
68
|
+
export const StressTest = {
|
|
69
|
+
args: {
|
|
70
|
+
defaultOption: true,
|
|
71
|
+
tooltips: faker.helpers.multiple(
|
|
72
|
+
() => ({
|
|
73
|
+
label: faker.lorem.words(2),
|
|
74
|
+
content: faker.lorem.words(5),
|
|
75
|
+
}),
|
|
76
|
+
{ count: 32 },
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
parameters: {
|
|
80
|
+
chromatic: { disableSnapshot: true },
|
|
81
|
+
},
|
|
82
|
+
};
|