@dxos/react-ui-list 0.7.2 → 0.7.3-main.2dd075e

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.
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { type KeyboardEvent, forwardRef, memo, useCallback } from 'react';
5
+ import React, { type KeyboardEvent, type MouseEvent, forwardRef, memo, useCallback } from 'react';
6
6
 
7
7
  import { Button, Icon, toLocalizedString, useTranslation, type Label } from '@dxos/react-ui';
8
8
  import { TextTooltip } from '@dxos/react-ui-text-tooltip';
@@ -16,7 +16,7 @@ export type NavTreeItemHeadingProps = {
16
16
  className?: string;
17
17
  disabled?: boolean;
18
18
  current?: boolean;
19
- onSelect?: () => void;
19
+ onSelect?: (option: boolean) => void;
20
20
  };
21
21
 
22
22
  export const TreeItemHeading = memo(
@@ -24,12 +24,19 @@ export const TreeItemHeading = memo(
24
24
  ({ label, icon, className, disabled, current, onSelect }, forwardedRef) => {
25
25
  const { t } = useTranslation();
26
26
 
27
+ const handleSelect = useCallback(
28
+ (event: MouseEvent) => {
29
+ onSelect?.(event.altKey);
30
+ },
31
+ [onSelect],
32
+ );
33
+
27
34
  const handleButtonKeydown = useCallback(
28
35
  (event: KeyboardEvent) => {
29
36
  if (event.key === ' ' || event.key === 'Enter') {
30
37
  event.preventDefault();
31
38
  event.stopPropagation();
32
- onSelect?.();
39
+ onSelect?.(event.altKey);
33
40
  }
34
41
  },
35
42
  [onSelect],
@@ -55,12 +62,14 @@ export const TreeItemHeading = memo(
55
62
  className,
56
63
  )}
57
64
  disabled={disabled}
58
- onClick={onSelect}
65
+ onClick={handleSelect}
59
66
  onKeyDown={handleButtonKeydown}
60
67
  {...(current && { 'aria-current': 'location' })}
61
68
  >
62
69
  {icon && <Icon icon={icon ?? 'ph--placeholder--regular'} size={4} classNames='is-[1em] bs-[1em] mlb-1' />}
63
- <span className='flex-1 is-0 truncate text-start text-sm font-normal'>{toLocalizedString(label, t)}</span>
70
+ <span className='flex-1 is-0 truncate text-start text-sm font-normal' data-tooltip>
71
+ {toLocalizedString(label, t)}
72
+ </span>
64
73
  </Button>
65
74
  </TextTooltip>
66
75
  );