@dxos/react-ui 0.1.5 → 0.1.7

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 (91) hide show
  1. package/LICENSE +5 -18
  2. package/dist/src/components/Avatar/Avatar.d.ts +1 -1
  3. package/dist/src/components/Avatar/Avatar.d.ts.map +1 -1
  4. package/dist/src/components/Avatar/Avatar.stories.d.ts +1 -1
  5. package/dist/src/components/Button/Button.d.ts +1 -1
  6. package/dist/src/components/Button/Button.d.ts.map +1 -1
  7. package/dist/src/components/Button/Button.stories.d.ts +1 -1
  8. package/dist/src/components/Button/ButtonGroup.d.ts +6 -0
  9. package/dist/src/components/Button/ButtonGroup.d.ts.map +1 -0
  10. package/dist/src/components/Button/ButtonGroup.js +16 -0
  11. package/dist/src/components/Button/ButtonGroup.js.map +1 -0
  12. package/dist/src/components/Button/index.d.ts +1 -0
  13. package/dist/src/components/Button/index.d.ts.map +1 -1
  14. package/dist/src/components/Button/index.js +1 -0
  15. package/dist/src/components/Button/index.js.map +1 -1
  16. package/dist/src/components/Dialog/Dialog.js +2 -2
  17. package/dist/src/components/Dialog/Dialog.js.map +1 -1
  18. package/dist/src/components/Heading/Heading.d.ts +0 -3
  19. package/dist/src/components/Heading/Heading.d.ts.map +1 -1
  20. package/dist/src/components/Heading/Heading.stories.d.ts +0 -3
  21. package/dist/src/components/Heading/Heading.stories.d.ts.map +1 -1
  22. package/dist/src/components/Input/BarePinInput.d.ts +0 -3
  23. package/dist/src/components/Input/BarePinInput.d.ts.map +1 -1
  24. package/dist/src/components/Input/BarePinInput.js +1 -1
  25. package/dist/src/components/Input/BarePinInput.js.map +1 -1
  26. package/dist/src/components/Input/BareTextInput.d.ts.map +1 -1
  27. package/dist/src/components/Input/BareTextInput.js +2 -1
  28. package/dist/src/components/Input/BareTextInput.js.map +1 -1
  29. package/dist/src/components/Input/BareTextareaInput.d.ts +5 -0
  30. package/dist/src/components/Input/BareTextareaInput.d.ts.map +1 -0
  31. package/dist/src/components/Input/BareTextareaInput.js +17 -0
  32. package/dist/src/components/Input/BareTextareaInput.js.map +1 -0
  33. package/dist/src/components/Input/Input.d.ts.map +1 -1
  34. package/dist/src/components/Input/Input.js +6 -4
  35. package/dist/src/components/Input/Input.js.map +1 -1
  36. package/dist/src/components/Input/InputProps.d.ts +7 -2
  37. package/dist/src/components/Input/InputProps.d.ts.map +1 -1
  38. package/dist/src/components/QrCode/QrCode.d.ts +13 -2
  39. package/dist/src/components/QrCode/QrCode.d.ts.map +1 -1
  40. package/dist/src/components/QrCode/QrCode.js +32 -4
  41. package/dist/src/components/QrCode/QrCode.js.map +1 -1
  42. package/dist/src/components/QrCode/QrCode.stories.d.ts +4 -3
  43. package/dist/src/components/QrCode/QrCode.stories.d.ts.map +1 -1
  44. package/dist/src/components/QrCode/QrCode.stories.js +14 -1
  45. package/dist/src/components/QrCode/QrCode.stories.js.map +1 -1
  46. package/dist/src/components/Tooltip/Tooltip.d.ts +3 -1
  47. package/dist/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  48. package/dist/src/components/Tooltip/Tooltip.js +2 -2
  49. package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
  50. package/dist/src/components/Tooltip/Tooltip.stories.d.ts +1 -1
  51. package/dist/src/hooks/useId.d.ts +1 -0
  52. package/dist/src/hooks/useId.d.ts.map +1 -1
  53. package/dist/src/hooks/useId.js +3 -2
  54. package/dist/src/hooks/useId.js.map +1 -1
  55. package/dist/src/styles/focus.d.ts +1 -1
  56. package/dist/src/styles/focus.d.ts.map +1 -1
  57. package/dist/src/styles/focus.js +1 -1
  58. package/dist/src/styles/focus.js.map +1 -1
  59. package/dist/src/styles/group.d.ts +3 -1
  60. package/dist/src/styles/group.d.ts.map +1 -1
  61. package/dist/src/styles/group.js +2 -2
  62. package/dist/src/styles/group.js.map +1 -1
  63. package/dist/src/styles/hover.d.ts +1 -1
  64. package/dist/src/styles/hover.d.ts.map +1 -1
  65. package/dist/src/styles/hover.js +1 -1
  66. package/dist/src/styles/hover.js.map +1 -1
  67. package/dist/src/styles/shimmer.d.ts +2 -1
  68. package/dist/src/styles/shimmer.d.ts.map +1 -1
  69. package/dist/src/styles/shimmer.js +3 -2
  70. package/dist/src/styles/shimmer.js.map +1 -1
  71. package/dist/src/theme.css +3 -0
  72. package/package.json +4 -3
  73. package/plugin.d.ts +5 -0
  74. package/plugin.js +8 -0
  75. package/src/components/Button/ButtonGroup.tsx +22 -0
  76. package/src/components/Button/index.ts +1 -0
  77. package/src/components/Dialog/Dialog.tsx +3 -3
  78. package/src/components/Input/BarePinInput.tsx +1 -1
  79. package/src/components/Input/BareTextInput.tsx +2 -1
  80. package/src/components/Input/BareTextareaInput.tsx +29 -0
  81. package/src/components/Input/Input.tsx +7 -4
  82. package/src/components/Input/InputProps.ts +10 -2
  83. package/src/components/QrCode/QrCode.stories.tsx +16 -1
  84. package/src/components/QrCode/QrCode.tsx +115 -5
  85. package/src/components/Tooltip/Tooltip.tsx +14 -2
  86. package/src/hooks/useId.ts +1 -1
  87. package/src/styles/focus.ts +1 -1
  88. package/src/styles/group.ts +11 -2
  89. package/src/styles/hover.ts +1 -1
  90. package/src/styles/shimmer.ts +4 -1
  91. package/src/theme.css +3 -0
@@ -3,24 +3,45 @@
3
3
  //
4
4
 
5
5
  import cx from 'classnames';
6
+ import { QrCode as QrCodeIcon, CopySimple } from 'phosphor-react';
6
7
  import { QRCodeSVG } from 'qrcode.react';
7
8
  import React, { useCallback, ReactHTMLElement } from 'react';
8
9
 
9
10
  import { useId } from '../../hooks';
10
11
  import { Size } from '../../props';
11
12
  import { getSize } from '../../styles';
12
- import { Button, ButtonProps } from '../Button';
13
+ import { Button, ButtonGroup, ButtonProps } from '../Button';
13
14
  import { Tooltip, TooltipProps } from '../Tooltip';
14
15
 
15
- export interface QrCodeProps
16
- extends Omit<ButtonProps, 'onClick' | 'ref'>,
16
+ interface SharedQrCodeProps
17
+ extends Omit<ButtonProps, 'onClick' | 'ref' | 'variant'>,
17
18
  Pick<TooltipProps, 'side' | 'sideOffset' | 'collisionPadding'> {
18
19
  value: string;
20
+ buttonCompact?: boolean;
21
+ }
22
+
23
+ export interface FullQrCodeProps extends SharedQrCodeProps {
19
24
  label: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
20
25
  size?: Size;
21
26
  }
22
27
 
23
- export const QrCode = ({ value, label, size, side, sideOffset, collisionPadding, ...buttonProps }: QrCodeProps) => {
28
+ export type QrCodeProps = FullQrCodeProps;
29
+
30
+ export interface CompactQrCodeProps extends SharedQrCodeProps {
31
+ displayQrLabel: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
32
+ copyLabel: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
33
+ }
34
+
35
+ export const FullQrCode = ({
36
+ value,
37
+ label,
38
+ size,
39
+ side,
40
+ sideOffset,
41
+ collisionPadding,
42
+ buttonCompact = true,
43
+ ...buttonProps
44
+ }: FullQrCodeProps) => {
24
45
  const labelId = useId('qr-label');
25
46
  const copyValue = useCallback(() => {
26
47
  void navigator.clipboard.writeText(value);
@@ -28,7 +49,7 @@ export const QrCode = ({ value, label, size, side, sideOffset, collisionPadding,
28
49
  return (
29
50
  <Tooltip content={label} {...{ side, sideOffset, collisionPadding }}>
30
51
  <Button
31
- compact
52
+ compact={buttonCompact}
32
53
  {...buttonProps}
33
54
  className={cx('overflow-hidden p-0', getSize(size ?? 32), buttonProps.className)}
34
55
  onClick={copyValue}
@@ -41,3 +62,92 @@ export const QrCode = ({ value, label, size, side, sideOffset, collisionPadding,
41
62
  </Tooltip>
42
63
  );
43
64
  };
65
+
66
+ export const CompactQrCode = ({
67
+ value,
68
+ displayQrLabel,
69
+ copyLabel,
70
+ side,
71
+ sideOffset,
72
+ collisionPadding,
73
+ compact,
74
+ buttonCompact,
75
+ ...buttonProps
76
+ }: CompactQrCodeProps) => {
77
+ const labelId = useId('qr-label');
78
+ const copyValue = useCallback(() => {
79
+ void navigator.clipboard.writeText(value);
80
+ }, [value]);
81
+ return (
82
+ <>
83
+ <ButtonGroup className='inline-flex grow md:hidden'>
84
+ <span className='sr-only' id={labelId}>
85
+ {displayQrLabel}
86
+ </span>
87
+ <Tooltip
88
+ compact
89
+ content={
90
+ <div role='none' className='overflow-hidden rounded-md'>
91
+ <QRCodeSVG value={value} includeMargin role='none' className={getSize(32)} />
92
+ </div>
93
+ }
94
+ {...{ side: side ?? 'left', sideOffset, collisionPadding }}
95
+ >
96
+ <Button
97
+ rounding='rounded-is-md'
98
+ compact={buttonCompact}
99
+ {...buttonProps}
100
+ className={cx('border-ie-0 grow', buttonProps.className)}
101
+ aria-labelledby={labelId}
102
+ >
103
+ <QrCodeIcon className={getSize(5)} />
104
+ </Button>
105
+ </Tooltip>
106
+ <Tooltip content={copyLabel} tooltipLabelsTrigger {...{ side, sideOffset, collisionPadding }}>
107
+ <Button
108
+ rounding='rounded-ie-md grow'
109
+ compact={buttonCompact}
110
+ {...buttonProps}
111
+ className={buttonProps.className}
112
+ onClick={copyValue}
113
+ >
114
+ <CopySimple className={getSize(5)} />
115
+ </Button>
116
+ </Tooltip>
117
+ </ButtonGroup>
118
+ <ButtonGroup className='hidden md:inline-flex'>
119
+ <Tooltip
120
+ compact
121
+ content={
122
+ <div role='none' className='overflow-hidden rounded-md'>
123
+ <QRCodeSVG value={value} includeMargin role='none' className={getSize(32)} />
124
+ </div>
125
+ }
126
+ {...{ side: side ?? 'left', sideOffset, collisionPadding }}
127
+ >
128
+ <Button
129
+ rounding='rounded-is-md'
130
+ compact={buttonCompact}
131
+ {...buttonProps}
132
+ className={cx('border-ie-0 flex gap-1', buttonProps.className)}
133
+ >
134
+ <QrCodeIcon className={getSize(5)} />
135
+ {displayQrLabel}
136
+ </Button>
137
+ </Tooltip>
138
+ <Button
139
+ rounding='rounded-ie-md'
140
+ compact={buttonCompact}
141
+ {...buttonProps}
142
+ className={cx('flex gap-1', buttonProps.className)}
143
+ onClick={copyValue}
144
+ >
145
+ <CopySimple className={getSize(5)} />
146
+ {copyLabel}
147
+ </Button>
148
+ </ButtonGroup>
149
+ </>
150
+ );
151
+ };
152
+
153
+ export const QrCode = FullQrCode;
@@ -12,11 +12,21 @@ import { defaultTooltip } from '../../styles';
12
12
  export interface TooltipProps extends Omit<ComponentProps<typeof TooltipPrimitive.Content>, 'children'> {
13
13
  content: ReactNode;
14
14
  children: ReactNode;
15
+ compact?: boolean;
15
16
  tooltipLabelsTrigger?: boolean;
16
17
  mountAsSibling?: boolean;
18
+ zIndex?: string;
17
19
  }
18
20
 
19
- export const Tooltip = ({ content, children, tooltipLabelsTrigger, mountAsSibling, ...contentProps }: TooltipProps) => {
21
+ export const Tooltip = ({
22
+ content,
23
+ children,
24
+ compact,
25
+ tooltipLabelsTrigger,
26
+ mountAsSibling,
27
+ zIndex = 'z-[2]',
28
+ ...contentProps
29
+ }: TooltipProps) => {
20
30
  const [isOpen, setIsOpen] = useState(false);
21
31
  const labelId = useId('tooltipLabel');
22
32
 
@@ -29,7 +39,9 @@ export const Tooltip = ({ content, children, tooltipLabelsTrigger, mountAsSiblin
29
39
  'radix-side-right:animate-slide-left-fade',
30
40
  'radix-side-bottom:animate-slide-up-fade',
31
41
  'radix-side-left:animate-slide-right-fade',
32
- 'inline-flex items-center rounded-md px-4 py-2.5',
42
+ 'inline-flex items-center rounded-md',
43
+ zIndex,
44
+ !compact && 'px-4 py-2.5',
33
45
  'shadow-lg bg-white dark:bg-neutral-800',
34
46
  !isOpen && 'sr-only',
35
47
  defaultTooltip,
@@ -13,7 +13,7 @@ const Alea: PrngFactory = alea as unknown as PrngFactory;
13
13
 
14
14
  const prng = new Alea('@dxos/react-ui');
15
15
 
16
- const randomString = (n = 4) =>
16
+ export const randomString = (n = 4) =>
17
17
  prng()
18
18
  .toString(16)
19
19
  .slice(2, n + 2);
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  export const defaultFocus =
6
- 'focus:outline-none focus-visible:hover:outline-none dark:focus-visible:hover:outline-none focus-visible:ring focus-visible:ring-offset-1 focus-visible:ring-primary-500 focus-visible:ring-offset-white dark:focus-visible:ring-primary-200 dark:focus-visible:ring-offset-black';
6
+ 'focus:outline-none focus-visible:z-[1] focus-visible:hover:outline-none dark:focus-visible:hover:outline-none focus-visible:ring focus-visible:ring-offset-1 focus-visible:ring-primary-500 focus-visible:ring-offset-white dark:focus-visible:ring-primary-200 dark:focus-visible:ring-offset-black';
7
7
 
8
8
  export const staticFocus =
9
9
  'ring ring-offset-1 ring-primary-500 ring-offset-white dark:ring-primary-200 dark:ring-offset-black';
@@ -16,9 +16,18 @@ const elevationClassNameMap = new Map<number, string>([
16
16
  [6, 'shadow-2xl']
17
17
  ]);
18
18
 
19
- export const defaultGroup = ({ elevation }: { elevation: Elevation }) => {
19
+ export const defaultGroup = ({
20
+ elevation,
21
+ rounding,
22
+ spacing
23
+ }: {
24
+ elevation: Elevation;
25
+ rounding?: string;
26
+ spacing?: string;
27
+ }) => {
20
28
  return cx(
21
- 'rounded-lg p-4',
29
+ rounding ?? 'rounded-lg',
30
+ spacing ?? 'p-4',
22
31
  elevation === 0
23
32
  ? 'bg-transparent border border-neutral-200 dark:border-neutral-700'
24
33
  : 'bg-white dark:bg-neutral-800 elevated-buttons',
@@ -5,6 +5,6 @@
5
5
  export const defaultHover = ({ disabled }: { disabled?: boolean }) => {
6
6
  return (
7
7
  !disabled &&
8
- 'outline outline-3 outline-transparent hover:outline-primary-300 dark:hover:outline-primary-400 hover:focus:outline-primary-300 dark:hover:focus:outline-primary-400'
8
+ 'outline outline-3 outline-transparent hover:z-[1] hover:outline-primary-300 dark:hover:outline-primary-400 hover:focus:outline-primary-300 dark:hover:focus:outline-primary-400'
9
9
  );
10
10
  };
@@ -3,4 +3,7 @@
3
3
  //
4
4
 
5
5
  export const defaultShimmer =
6
- 'relative before:absolute before:inset-0 before:-translate-x-full before:animate-shimmer before:bg-gradient-to-r before:from-transparent before:via-neutral-100/20 before:to-transparent isolate overflow-hidden before:border-t before:border-neutral-100/20';
6
+ 'relative before:absolute before:inset-0 before:-translate-x-full before:animate-shimmer before:bg-gradient-to-r before:from-transparent before:via-neutral-100/10 before:to-transparent isolate overflow-hidden';
7
+
8
+ export const strongShimmer =
9
+ 'relative before:absolute before:inset-0 before:-translate-x-full before:animate-shimmer before:bg-gradient-to-r before:from-transparent before:via-primary-100/80 before:to-transparent isolate overflow-hidden';
package/src/theme.css CHANGED
@@ -42,6 +42,9 @@
42
42
  .elevated-buttons {
43
43
  --button-elevation: theme(boxShadow.sm);
44
44
  }
45
+ .grouped-buttons {
46
+ --button-elevation: theme(boxShadow.none);
47
+ }
45
48
  }
46
49
 
47
50
  :root {