@dxos/react-ui 0.6.14-staging.934c9de → 0.6.14-staging.9b873ce

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.
@@ -0,0 +1,56 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { forwardRef } from 'react';
6
+
7
+ import { Button, type ButtonProps } from './Button';
8
+ import { useThemeContext } from '../../hooks';
9
+ import { Icon, type IconProps } from '../Icon';
10
+ import { Tooltip } from '../Tooltip';
11
+
12
+ type IconButtonProps = Omit<ButtonProps, 'children'> &
13
+ Pick<IconProps, 'icon'> & { label: string; iconOnly?: boolean; tooltipPortal?: boolean; tooltipZIndex?: string };
14
+
15
+ const IconOnlyButton = forwardRef<HTMLButtonElement, IconButtonProps>(
16
+ ({ tooltipPortal = true, tooltipZIndex: zIndex, ...props }, forwardedRef) => {
17
+ const content = (
18
+ <Tooltip.Content {...(zIndex && { style: { zIndex } })}>
19
+ {props.label}
20
+ <Tooltip.Arrow />
21
+ </Tooltip.Content>
22
+ );
23
+ return (
24
+ <Tooltip.Root>
25
+ <Tooltip.Trigger asChild>
26
+ <LabelledIconButton {...props} ref={forwardedRef} />
27
+ </Tooltip.Trigger>
28
+ {tooltipPortal ? <Tooltip.Portal>{content}</Tooltip.Portal> : content}
29
+ </Tooltip.Root>
30
+ );
31
+ },
32
+ );
33
+
34
+ const LabelledIconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
35
+ ({ icon, iconOnly, label, classNames, ...props }, forwardedRef) => {
36
+ const { tx } = useThemeContext();
37
+ return (
38
+ <Button {...props} classNames={tx('iconButton.root', 'iconButton', {}, classNames)} ref={forwardedRef}>
39
+ <Icon icon={icon} />
40
+ <span className={iconOnly ? 'sr-only' : undefined}>{label}</span>
41
+ </Button>
42
+ );
43
+ },
44
+ );
45
+
46
+ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>((props, forwardedRef) =>
47
+ props.iconOnly ? (
48
+ <IconOnlyButton {...props} ref={forwardedRef} />
49
+ ) : (
50
+ <LabelledIconButton {...props} ref={forwardedRef} />
51
+ ),
52
+ );
53
+
54
+ export { IconButton };
55
+
56
+ export type { IconButtonProps };
@@ -3,5 +3,6 @@
3
3
  //
4
4
 
5
5
  export * from './Button';
6
+ export * from './IconButton';
6
7
  export * from './Toggle';
7
8
  export * from './ToggleGroup';
@@ -102,9 +102,22 @@ const SelectScrollDownButton = forwardRef<HTMLDivElement, SelectScrollDownButton
102
102
  },
103
103
  );
104
104
 
105
- type SelectViewportProps = SelectPrimitive.SelectViewportProps;
105
+ type SelectViewportProps = ThemedClassName<SelectPrimitive.SelectViewportProps>;
106
106
 
107
- const SelectViewport = SelectPrimitive.Viewport;
107
+ const SelectViewport = forwardRef<HTMLDivElement, SelectViewportProps>(
108
+ ({ classNames, asChild, children, ...props }, forwardedRef) => {
109
+ const { tx } = useThemeContext();
110
+ return (
111
+ <SelectPrimitive.SelectViewport
112
+ {...props}
113
+ className={tx('select.viewport', 'select__viewport', {}, classNames)}
114
+ ref={forwardedRef}
115
+ >
116
+ {children}
117
+ </SelectPrimitive.SelectViewport>
118
+ );
119
+ },
120
+ );
108
121
 
109
122
  type SelectItemProps = ThemedClassName<SelectPrimitive.SelectItemProps>;
110
123
 
@@ -9,22 +9,23 @@ import { type ThemedClassName } from '../../util';
9
9
 
10
10
  type StatusProps = ThemedClassName<ComponentPropsWithRef<'span'>> & {
11
11
  indeterminate?: boolean;
12
+ variant?: 'default' | 'main-bottom';
12
13
  progress?: number;
13
14
  };
14
15
 
15
16
  const Status = forwardRef<HTMLSpanElement, StatusProps>(
16
- ({ classNames, children, progress = 0, indeterminate, ...props }, forwardedRef) => {
17
+ ({ classNames, children, progress = 0, indeterminate, variant, ...props }, forwardedRef) => {
17
18
  const { tx } = useThemeContext();
18
19
  return (
19
20
  <span
20
21
  role='status'
21
22
  {...props}
22
- className={tx('status.root', 'status', { indeterminate }, classNames)}
23
+ className={tx('status.root', 'status', { indeterminate, variant }, classNames)}
23
24
  ref={forwardedRef}
24
25
  >
25
26
  <span
26
27
  role='none'
27
- className={tx('status.bar', 'status__bar', { indeterminate }, classNames)}
28
+ className={tx('status.bar', 'status__bar', { indeterminate, variant }, classNames)}
28
29
  {...(!indeterminate && { style: { width: `${Math.round(progress * 100)}%` } })}
29
30
  />
30
31
  {children}