@dxos/react-ui 0.8.2-main.5ca3450 → 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.
Files changed (38) hide show
  1. package/dist/lib/browser/index.mjs +839 -307
  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 +957 -423
  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 +839 -307
  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/Buttons/Button.stories.d.ts +10 -44
  11. package/dist/types/src/components/Buttons/Button.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Buttons/IconButton.d.ts +4 -5
  13. package/dist/types/src/components/Buttons/IconButton.d.ts.map +1 -1
  14. package/dist/types/src/components/Clipboard/CopyButton.d.ts +2 -1
  15. package/dist/types/src/components/Clipboard/CopyButton.d.ts.map +1 -1
  16. package/dist/types/src/components/Clipboard/index.d.ts +2 -2
  17. package/dist/types/src/components/Dialogs/Dialog.d.ts +6 -2
  18. package/dist/types/src/components/Dialogs/Dialog.d.ts.map +1 -1
  19. package/dist/types/src/components/ScrollArea/ScrollArea.d.ts.map +1 -1
  20. package/dist/types/src/components/Tooltip/Tooltip.d.ts +94 -20
  21. package/dist/types/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  22. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts +40 -16
  23. package/dist/types/src/components/Tooltip/Tooltip.stories.d.ts.map +1 -1
  24. package/dist/types/src/playground/Controls.stories.d.ts +1 -1
  25. package/dist/types/src/playground/Controls.stories.d.ts.map +1 -1
  26. package/dist/types/src/playground/Custom.stories.d.ts +8 -0
  27. package/dist/types/src/playground/Custom.stories.d.ts.map +1 -0
  28. package/package.json +14 -13
  29. package/src/components/Buttons/Button.stories.tsx +19 -14
  30. package/src/components/Buttons/IconButton.stories.tsx +2 -2
  31. package/src/components/Buttons/IconButton.tsx +8 -33
  32. package/src/components/Clipboard/CopyButton.tsx +22 -24
  33. package/src/components/Dialogs/Dialog.tsx +12 -7
  34. package/src/components/ScrollArea/ScrollArea.tsx +3 -0
  35. package/src/components/Tooltip/Tooltip.stories.tsx +41 -16
  36. package/src/components/Tooltip/Tooltip.tsx +748 -58
  37. package/src/playground/Controls.stories.tsx +2 -2
  38. package/src/playground/Custom.stories.tsx +137 -0
@@ -1,23 +1,97 @@
1
- import { type TooltipProviderProps as TooltipProviderPrimitiveProps, type TooltipProps as TooltipRootPrimitiveProps, type TooltipContentProps as TooltipContentPrimitiveProps, type TooltipTriggerProps as TooltipTriggerPrimitiveProps, type TooltipPortalProps as TooltipPortalPrimitiveProps, type TooltipArrowProps as TooltipArrowPrimitiveProps } from '@radix-ui/react-tooltip';
2
- import React from 'react';
3
- import { type ThemedClassName } from '../../util';
4
- type TooltipProviderProps = TooltipProviderPrimitiveProps;
5
- type TooltipRootProps = TooltipRootPrimitiveProps;
6
- type TooltipPortalProps = TooltipPortalPrimitiveProps;
7
- type TooltipTriggerProps = TooltipTriggerPrimitiveProps;
8
- type TooltipArrowProps = ThemedClassName<TooltipArrowPrimitiveProps>;
9
- type TooltipContentProps = ThemedClassName<TooltipContentPrimitiveProps>;
1
+ import type { Scope } from '@radix-ui/react-context';
2
+ import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
3
+ import * as PopperPrimitive from '@radix-ui/react-popper';
4
+ import { Primitive } from '@radix-ui/react-primitive';
5
+ import { type TooltipProps } from '@radix-ui/react-tooltip';
6
+ import React, { type ComponentPropsWithoutRef, type ElementRef, type SyntheticEvent, type MutableRefObject, type ReactNode } from 'react';
7
+ type TooltipScopedProps<P = {}> = P & {
8
+ __scopeTooltip?: Scope;
9
+ };
10
+ declare const createTooltipScope: import("@radix-ui/react-context").CreateScope;
11
+ type TooltipContextValue = {
12
+ contentId: string;
13
+ open: boolean;
14
+ stateAttribute: 'closed' | 'delayed-open' | 'instant-open';
15
+ trigger: TooltipTriggerElement | null;
16
+ onTriggerChange(trigger: TooltipTriggerElement | null): void;
17
+ onTriggerEnter(): void;
18
+ onTriggerLeave(): void;
19
+ onOpen(): void;
20
+ onClose(): void;
21
+ onPointerInTransitChange(inTransit: boolean): void;
22
+ isPointerInTransitRef: MutableRefObject<boolean>;
23
+ disableHoverableContent: boolean;
24
+ };
25
+ declare const useTooltipContext: (consumerName: string, scope: Scope<TooltipContextValue | undefined>) => TooltipContextValue;
26
+ interface TooltipProviderProps {
27
+ children?: ReactNode;
28
+ open?: boolean;
29
+ defaultOpen?: boolean;
30
+ onOpenChange?: (open: boolean) => void;
31
+ /**
32
+ * The duration from when the pointer enters the trigger until the tooltip gets opened. This will
33
+ * override the prop with the same name passed to Provider.
34
+ * @defaultValue 700
35
+ */
36
+ delayDuration?: number;
37
+ /**
38
+ * When `true`, trying to hover the content will result in the tooltip closing as the pointer leaves the trigger.
39
+ * @defaultValue false
40
+ */
41
+ disableHoverableContent?: boolean;
42
+ /**
43
+ * How much time a user has to enter another trigger without incurring a delay again.
44
+ * @defaultValue 300
45
+ */
46
+ skipDelayDuration?: number;
47
+ }
48
+ type TooltipTriggerElement = ElementRef<typeof Primitive.button>;
49
+ type PrimitiveButtonProps = ComponentPropsWithoutRef<typeof Primitive.button>;
50
+ type TooltipTriggerProps = PrimitiveButtonProps & Pick<TooltipProps, 'delayDuration'> & {
51
+ content?: string;
52
+ side?: TooltipSide;
53
+ suppressNextTooltip?: MutableRefObject<boolean>;
54
+ onInteract?: (event: SyntheticEvent) => void;
55
+ };
56
+ interface TooltipContentProps extends TooltipContentImplProps {
57
+ /**
58
+ * Used to force mounting when more control is needed. Useful when
59
+ * controlling animation with React animation libraries.
60
+ */
61
+ forceMount?: true;
62
+ }
63
+ type DismissableLayerProps = ComponentPropsWithoutRef<typeof DismissableLayer>;
64
+ type PopperContentProps = ComponentPropsWithoutRef<typeof PopperPrimitive.Content>;
65
+ interface TooltipContentImplProps extends Omit<PopperContentProps, 'onPlaced'> {
66
+ /**
67
+ * A more descriptive label for accessibility purpose
68
+ */
69
+ 'aria-label'?: string;
70
+ /**
71
+ * Event handler called when the escape key is down.
72
+ * Can be prevented.
73
+ */
74
+ onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];
75
+ /**
76
+ * Event handler called when the a `pointerdown` event happens outside of the `Tooltip`.
77
+ * Can be prevented.
78
+ */
79
+ onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
80
+ }
81
+ type TooltipSide = NonNullable<TooltipContentProps['side']>;
10
82
  export declare const Tooltip: {
11
- Provider: React.FunctionComponent<TooltipProviderPrimitiveProps>;
12
- Root: React.FunctionComponent<TooltipRootPrimitiveProps>;
13
- Portal: React.FC<TooltipPortalPrimitiveProps>;
14
- Trigger: React.ForwardRefExoticComponent<TooltipTriggerPrimitiveProps & React.RefAttributes<HTMLButtonElement>>;
15
- Arrow: React.ForwardRefExoticComponent<Omit<TooltipArrowPrimitiveProps, "className"> & {
16
- classNames?: import("@dxos/react-ui-types").ClassNameValue;
17
- } & React.RefAttributes<SVGSVGElement>>;
18
- Content: React.ForwardRefExoticComponent<Omit<TooltipContentPrimitiveProps, "className"> & {
19
- classNames?: import("@dxos/react-ui-types").ClassNameValue;
20
- } & React.RefAttributes<HTMLDivElement>>;
83
+ Provider: React.FC<TooltipProviderProps>;
84
+ Trigger: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
85
+ ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLButtonElement> | null | undefined;
86
+ } & {
87
+ asChild?: boolean;
88
+ }, "ref"> & Pick<TooltipProps, "delayDuration"> & {
89
+ content?: string;
90
+ side?: TooltipSide;
91
+ suppressNextTooltip?: MutableRefObject<boolean>;
92
+ onInteract?: (event: SyntheticEvent) => void;
93
+ } & React.RefAttributes<HTMLButtonElement>>;
21
94
  };
22
- export type { TooltipProviderProps, TooltipRootProps, TooltipPortalProps, TooltipTriggerProps, TooltipArrowProps, TooltipContentProps, };
95
+ export { createTooltipScope, useTooltipContext };
96
+ export type { TooltipProviderProps, TooltipTriggerProps, TooltipScopedProps, TooltipSide };
23
97
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,oBAAoB,IAAI,6BAA6B,EAE1D,KAAK,YAAY,IAAI,yBAAyB,EAC9C,KAAK,mBAAmB,IAAI,4BAA4B,EAExD,KAAK,mBAAmB,IAAI,4BAA4B,EAExD,KAAK,kBAAkB,IAAI,2BAA2B,EAEtD,KAAK,iBAAiB,IAAI,0BAA0B,EAErD,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAA6C,MAAM,OAAO,CAAC;AAIlE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,oBAAoB,GAAG,6BAA6B,CAAC;AAI1D,KAAK,gBAAgB,GAAG,yBAAyB,CAAC;AAIlD,KAAK,kBAAkB,GAAG,2BAA2B,CAAC;AAItD,KAAK,mBAAmB,GAAG,4BAA4B,CAAC;AAIxD,KAAK,iBAAiB,GAAG,eAAe,CAAC,0BAA0B,CAAC,CAAC;AAarE,KAAK,mBAAmB,GAAG,eAAe,CAAC,4BAA4B,CAAC,CAAC;AAmBzE,eAAO,MAAM,OAAO;;;;;;;;;;;CAOnB,CAAC;AAEF,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAA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AqB,CAAC,iBAAiB,CAAC,CAAC;IAC3D;;;OAGG;IACH,oBAAoB,CAAC,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;CACtE;AAuGD,KAAK,WAAW,GAAG,WAAW,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;AA0J5D,eAAO,MAAM,OAAO;;;;;;;kBAxgBN,MAAM;eACT,WAAW;8BACI,gBAAgB,CAAC,OAAO,CAAC;qBAClC,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI;;CAwgB/C,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;AAEjD,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC"}
@@ -1,24 +1,28 @@
1
1
  import '@dxos-theme';
2
2
  import React from 'react';
3
3
  type StoryTooltipProps = {
4
- content: string;
4
+ tooltips: {
5
+ label: string;
6
+ content: string;
7
+ }[];
5
8
  defaultOpen?: boolean;
6
9
  };
7
10
  declare const _default: {
8
11
  title: string;
9
12
  component: {
10
- Provider: React.FunctionComponent<import("@radix-ui/react-tooltip").TooltipProviderProps>;
11
- Root: React.FunctionComponent<import("@radix-ui/react-tooltip").TooltipProps>;
12
- Portal: React.FC<import("@radix-ui/react-tooltip").TooltipPortalProps>;
13
- Trigger: React.ForwardRefExoticComponent<import("@radix-ui/react-tooltip").TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
14
- Arrow: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-tooltip").TooltipArrowProps, "className"> & {
15
- classNames?: import("@dxos/react-ui-types").ClassNameValue;
16
- } & React.RefAttributes<SVGSVGElement>>;
17
- Content: React.ForwardRefExoticComponent<Omit<import("@radix-ui/react-tooltip").TooltipContentProps, "className"> & {
18
- classNames?: import("@dxos/react-ui-types").ClassNameValue;
19
- } & React.RefAttributes<HTMLDivElement>>;
20
- };
21
- render: ({ content, defaultOpen }: StoryTooltipProps) => React.JSX.Element;
13
+ Provider: React.FC<import("./Tooltip").TooltipProviderProps>;
14
+ Trigger: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
15
+ ref?: ((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLButtonElement> | null | undefined;
16
+ } & {
17
+ asChild?: boolean;
18
+ }, "ref"> & Pick<import("@radix-ui/react-tooltip").TooltipProps, "delayDuration"> & {
19
+ content?: string;
20
+ side?: import("./Tooltip").TooltipSide;
21
+ suppressNextTooltip?: React.MutableRefObject<boolean>;
22
+ onInteract?: (event: React.SyntheticEvent) => void;
23
+ } & React.RefAttributes<HTMLButtonElement>>;
24
+ };
25
+ render: ({ tooltips, defaultOpen }: StoryTooltipProps) => React.JSX.Element;
22
26
  decorators: import("@storybook/react").Decorator[];
23
27
  parameters: {
24
28
  chromatic: {
@@ -29,7 +33,10 @@ declare const _default: {
29
33
  export default _default;
30
34
  export declare const Default: {
31
35
  args: {
32
- content: string;
36
+ tooltips: {
37
+ label: string;
38
+ content: string;
39
+ }[];
33
40
  };
34
41
  parameters: {
35
42
  chromatic: {
@@ -37,10 +44,13 @@ export declare const Default: {
37
44
  };
38
45
  };
39
46
  };
40
- export declare const Testing: {
47
+ export declare const DefaultOpen: {
41
48
  args: {
42
49
  defaultOption: boolean;
43
- content: string;
50
+ tooltips: {
51
+ label: string;
52
+ content: string;
53
+ }[];
44
54
  };
45
55
  parameters: {
46
56
  chromatic: {
@@ -48,4 +58,18 @@ export declare const Testing: {
48
58
  };
49
59
  };
50
60
  };
61
+ export declare const StressTest: {
62
+ args: {
63
+ defaultOption: boolean;
64
+ tooltips: {
65
+ label: string;
66
+ content: string;
67
+ }[];
68
+ };
69
+ parameters: {
70
+ chromatic: {
71
+ disableSnapshot: boolean;
72
+ };
73
+ };
74
+ };
51
75
  //# sourceMappingURL=Tooltip.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;;;;;;;;;;;;;;;uCAE8C,iBAAiB;;;;;;;;AAcjE,wBAME;AAEF,eAAO,MAAM,OAAO;;;;;;;;;CAOnB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;CAQnB,CAAC"}
1
+ {"version":3,"file":"Tooltip.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AACrB,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC/C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;;;;;;;;;;;;;;;;wCAE+C,iBAAiB;;;;;;;;AAYlE,wBAME;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;CAYnB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;CActB,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import '@dxos-theme';
2
2
  import React from 'react';
3
- export declare const Default: {};
4
3
  declare const _default: {
5
4
  title: string;
6
5
  render: () => React.JSX.Element;
@@ -12,4 +11,5 @@ declare const _default: {
12
11
  };
13
12
  };
14
13
  export default _default;
14
+ export declare const Default: {};
15
15
  //# sourceMappingURL=Controls.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Controls.stories.d.ts","sourceRoot":"","sources":["../../../../src/playground/Controls.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAmB,MAAM,OAAO,CAAC;AA4ExC,eAAO,MAAM,OAAO,IAAK,CAAC;;;;;;;;;;;AAE1B,wBAKE"}
1
+ {"version":3,"file":"Controls.stories.d.ts","sourceRoot":"","sources":["../../../../src/playground/Controls.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAAmB,MAAM,OAAO,CAAC;;;;;;;;;;;AA4ExC,wBAKE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -0,0 +1,8 @@
1
+ import '@dxos-theme';
2
+ import { type StoryObj, type Meta } from '@storybook/react';
3
+ import { Button } from '../components';
4
+ declare const meta: Meta<typeof Button>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof meta>;
7
+ export declare const Default: Story;
8
+ //# sourceMappingURL=Custom.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Custom.stories.d.ts","sourceRoot":"","sources":["../../../../src/playground/Custom.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,MAAM,EAAyC,MAAM,eAAe,CAAC;AAiH9E,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAM7B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAErB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui",
3
- "version": "0.8.2-main.5ca3450",
3
+ "version": "0.8.2-main.600d381",
4
4
  "description": "Low-level React components for DXOS, applying a theme to a core group of primitives",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -56,20 +56,21 @@
56
56
  "@radix-ui/react-toolbar": "1.1.2",
57
57
  "@radix-ui/react-tooltip": "1.1.8",
58
58
  "@radix-ui/react-use-controllable-state": "1.1.0",
59
+ "@radix-ui/react-visually-hidden": "1.1.2",
59
60
  "aria-hidden": "^1.2.4",
60
61
  "date-fns": "^3.3.1",
61
62
  "i18next": "^21.10.0",
62
63
  "keyborg": "^2.5.0",
63
64
  "react-i18next": "^11.18.6",
64
65
  "react-remove-scroll": "^2.6.0",
65
- "@dxos/debug": "0.8.2-main.5ca3450",
66
- "@dxos/lit-ui": "0.8.2-main.5ca3450",
67
- "@dxos/log": "0.8.2-main.5ca3450",
68
- "@dxos/react-input": "0.8.2-main.5ca3450",
69
- "@dxos/react-hooks": "0.8.2-main.5ca3450",
70
- "@dxos/react-list": "0.8.2-main.5ca3450",
71
- "@dxos/util": "0.8.2-main.5ca3450",
72
- "@dxos/react-ui-types": "0.8.2-main.5ca3450"
66
+ "@dxos/debug": "0.8.2-main.600d381",
67
+ "@dxos/lit-ui": "0.8.2-main.600d381",
68
+ "@dxos/react-input": "0.8.2-main.600d381",
69
+ "@dxos/react-list": "0.8.2-main.600d381",
70
+ "@dxos/log": "0.8.2-main.600d381",
71
+ "@dxos/react-ui-types": "0.8.2-main.600d381",
72
+ "@dxos/react-hooks": "0.8.2-main.600d381",
73
+ "@dxos/util": "0.8.2-main.600d381"
73
74
  },
74
75
  "devDependencies": {
75
76
  "@dnd-kit/core": "^6.0.5",
@@ -81,15 +82,15 @@
81
82
  "react": "~18.2.0",
82
83
  "react-dom": "~18.2.0",
83
84
  "vite": "5.4.7",
84
- "@dxos/random": "0.8.2-main.5ca3450",
85
- "@dxos/react-ui-theme": "0.8.2-main.5ca3450",
86
- "@dxos/util": "0.8.2-main.5ca3450"
85
+ "@dxos/random": "0.8.2-main.600d381",
86
+ "@dxos/util": "0.8.2-main.600d381",
87
+ "@dxos/react-ui-theme": "0.8.2-main.600d381"
87
88
  },
88
89
  "peerDependencies": {
89
90
  "@phosphor-icons/react": "^2.1.5",
90
91
  "react": "~18.2.0",
91
92
  "react-dom": "~18.2.0",
92
- "@dxos/react-ui-theme": "0.8.2-main.5ca3450"
93
+ "@dxos/react-ui-theme": "0.8.2-main.600d381"
93
94
  },
94
95
  "publishConfig": {
95
96
  "access": "public"
@@ -5,6 +5,7 @@
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';
8
9
  import React from 'react';
9
10
 
10
11
  import { Button, ButtonGroup, type ButtonProps } from './Button';
@@ -31,32 +32,36 @@ const DefaultStory = ({ children, ...args }: Omit<ButtonProps, 'ref'>) => {
31
32
  );
32
33
  };
33
34
 
34
- const defaults = { children: 'Test' };
35
+ const meta: Meta<typeof Button> = {
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>;
35
46
 
36
- export const Default = {
47
+ const defaults: Story['args'] = { children: 'Test' };
48
+
49
+ export const Default: Story = {
37
50
  args: { ...defaults, variant: 'default' },
38
51
  };
39
52
 
40
- export const Primary = {
53
+ export const Primary: Story = {
41
54
  args: { ...defaults, variant: 'primary' },
42
55
  };
43
56
 
44
- export const Destructive = {
57
+ export const Destructive: Story = {
45
58
  args: { ...defaults, variant: 'destructive' },
46
59
  };
47
60
 
48
- export const Outline = {
61
+ export const Outline: Story = {
49
62
  args: { ...defaults, variant: 'outline' },
50
63
  };
51
64
 
52
- export const Ghost = {
65
+ export const Ghost: Story = {
53
66
  args: { ...defaults, variant: 'ghost' },
54
67
  };
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
- };
@@ -18,10 +18,10 @@ const StorybookIconButton = (props: StorybookIconButtonProps) => {
18
18
  return (
19
19
  <Tooltip.Provider>
20
20
  <div className='mbe-4'>
21
- <IconButton label='Bold' icon='ph--text-b--bold' {...props} />
21
+ <IconButton label='Bold' icon='ph--text-b--regular' {...props} />
22
22
  </div>
23
23
  <div className='mbe-4'>
24
- <IconButton iconOnly label='Bold' icon='ph--text-b--bold' {...props} />
24
+ <IconButton iconOnly label='Bold' icon='ph--text-b--regular' {...props} />
25
25
  </div>
26
26
  </Tooltip.Provider>
27
27
  );
@@ -2,60 +2,35 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { forwardRef, type ReactNode, type MutableRefObject, useState } from 'react';
5
+ import React, { forwardRef, type MutableRefObject } 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 TooltipContentProps } from '../Tooltip';
11
+ import { Tooltip, type TooltipSide } from '../Tooltip';
12
12
 
13
13
  type IconButtonProps = Omit<ButtonProps, 'children'> &
14
14
  Pick<IconProps, 'icon' | 'size'> & {
15
- label: NonNullable<ReactNode>;
15
+ label: string;
16
16
  iconOnly?: boolean;
17
17
  noTooltip?: boolean;
18
18
  caretDown?: boolean;
19
- // TODO(burdon): Create slots abstraction?
20
19
  iconClassNames?: ThemedClassName<any>['classNames'];
21
20
  tooltipPortal?: boolean;
22
- tooltipZIndex?: string;
23
- tooltipSide?: TooltipContentProps['side'];
21
+ tooltipSide?: TooltipSide;
24
22
  suppressNextTooltip?: MutableRefObject<boolean>;
25
23
  };
26
24
 
27
25
  const IconOnlyButton = forwardRef<HTMLButtonElement, IconButtonProps>(
28
- (
29
- { noTooltip, tooltipPortal = true, tooltipZIndex: zIndex, tooltipSide, suppressNextTooltip, ...props },
30
- forwardedRef,
31
- ) => {
32
- const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
26
+ ({ noTooltip, tooltipPortal = true, tooltipSide, suppressNextTooltip, ...props }, forwardedRef) => {
33
27
  if (noTooltip) {
34
28
  return <LabelledIconButton {...props} ref={forwardedRef} />;
35
29
  }
36
- const content = (
37
- <Tooltip.Content {...(zIndex && { style: { zIndex } })} side={tooltipSide}>
38
- {props.label}
39
- <Tooltip.Arrow />
40
- </Tooltip.Content>
41
- );
42
30
  return (
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>
31
+ <Tooltip.Trigger asChild content={props.label} side={tooltipSide} suppressNextTooltip={suppressNextTooltip}>
32
+ <LabelledIconButton {...props} ref={forwardedRef} />
33
+ </Tooltip.Trigger>
59
34
  );
60
35
  },
61
36
  );
@@ -3,15 +3,15 @@
3
3
  //
4
4
 
5
5
  import { type IconProps } from '@phosphor-icons/react';
6
- import React, { useState } from '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 { Tooltip } from '../Tooltip';
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 = ({ value, classNames, iconProps, variant, ...props }: CopyButtonIconOnlyProps) => {
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 [open, setOpen] = useState(false);
63
+ const { onOpen } = useTooltipContext('CopyButton', __scopeTooltip);
57
64
  return (
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>
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>(DIALOG_OVERLAY_NAME, {
85
- inOverlayLayout: false,
86
- });
84
+ const [OverlayLayoutProvider, useOverlayLayoutContext] = createContext<OverlayLayoutContextValue>(
85
+ DIALOG_OVERLAY_NAME,
86
+ {},
87
+ );
87
88
 
88
- type DialogOverlayProps = ThemedClassName<DialogOverlayPrimitiveProps> & { blockAlign?: 'center' | 'start' | 'end' };
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
- aria-describedby={undefined}
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 (