@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.
- package/LICENSE +5 -18
- package/dist/src/components/Avatar/Avatar.d.ts +1 -1
- package/dist/src/components/Avatar/Avatar.d.ts.map +1 -1
- package/dist/src/components/Avatar/Avatar.stories.d.ts +1 -1
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/Button/Button.d.ts.map +1 -1
- package/dist/src/components/Button/Button.stories.d.ts +1 -1
- package/dist/src/components/Button/ButtonGroup.d.ts +6 -0
- package/dist/src/components/Button/ButtonGroup.d.ts.map +1 -0
- package/dist/src/components/Button/ButtonGroup.js +16 -0
- package/dist/src/components/Button/ButtonGroup.js.map +1 -0
- package/dist/src/components/Button/index.d.ts +1 -0
- package/dist/src/components/Button/index.d.ts.map +1 -1
- package/dist/src/components/Button/index.js +1 -0
- package/dist/src/components/Button/index.js.map +1 -1
- package/dist/src/components/Dialog/Dialog.js +2 -2
- package/dist/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/src/components/Heading/Heading.d.ts +0 -3
- package/dist/src/components/Heading/Heading.d.ts.map +1 -1
- package/dist/src/components/Heading/Heading.stories.d.ts +0 -3
- package/dist/src/components/Heading/Heading.stories.d.ts.map +1 -1
- package/dist/src/components/Input/BarePinInput.d.ts +0 -3
- package/dist/src/components/Input/BarePinInput.d.ts.map +1 -1
- package/dist/src/components/Input/BarePinInput.js +1 -1
- package/dist/src/components/Input/BarePinInput.js.map +1 -1
- package/dist/src/components/Input/BareTextInput.d.ts.map +1 -1
- package/dist/src/components/Input/BareTextInput.js +2 -1
- package/dist/src/components/Input/BareTextInput.js.map +1 -1
- package/dist/src/components/Input/BareTextareaInput.d.ts +5 -0
- package/dist/src/components/Input/BareTextareaInput.d.ts.map +1 -0
- package/dist/src/components/Input/BareTextareaInput.js +17 -0
- package/dist/src/components/Input/BareTextareaInput.js.map +1 -0
- package/dist/src/components/Input/Input.d.ts.map +1 -1
- package/dist/src/components/Input/Input.js +6 -4
- package/dist/src/components/Input/Input.js.map +1 -1
- package/dist/src/components/Input/InputProps.d.ts +7 -2
- package/dist/src/components/Input/InputProps.d.ts.map +1 -1
- package/dist/src/components/QrCode/QrCode.d.ts +13 -2
- package/dist/src/components/QrCode/QrCode.d.ts.map +1 -1
- package/dist/src/components/QrCode/QrCode.js +32 -4
- package/dist/src/components/QrCode/QrCode.js.map +1 -1
- package/dist/src/components/QrCode/QrCode.stories.d.ts +4 -3
- package/dist/src/components/QrCode/QrCode.stories.d.ts.map +1 -1
- package/dist/src/components/QrCode/QrCode.stories.js +14 -1
- package/dist/src/components/QrCode/QrCode.stories.js.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.d.ts +3 -1
- package/dist/src/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.js +2 -2
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.stories.d.ts +1 -1
- package/dist/src/hooks/useId.d.ts +1 -0
- package/dist/src/hooks/useId.d.ts.map +1 -1
- package/dist/src/hooks/useId.js +3 -2
- package/dist/src/hooks/useId.js.map +1 -1
- package/dist/src/styles/focus.d.ts +1 -1
- package/dist/src/styles/focus.d.ts.map +1 -1
- package/dist/src/styles/focus.js +1 -1
- package/dist/src/styles/focus.js.map +1 -1
- package/dist/src/styles/group.d.ts +3 -1
- package/dist/src/styles/group.d.ts.map +1 -1
- package/dist/src/styles/group.js +2 -2
- package/dist/src/styles/group.js.map +1 -1
- package/dist/src/styles/hover.d.ts +1 -1
- package/dist/src/styles/hover.d.ts.map +1 -1
- package/dist/src/styles/hover.js +1 -1
- package/dist/src/styles/hover.js.map +1 -1
- package/dist/src/styles/shimmer.d.ts +2 -1
- package/dist/src/styles/shimmer.d.ts.map +1 -1
- package/dist/src/styles/shimmer.js +3 -2
- package/dist/src/styles/shimmer.js.map +1 -1
- package/dist/src/theme.css +3 -0
- package/package.json +4 -3
- package/plugin.d.ts +5 -0
- package/plugin.js +8 -0
- package/src/components/Button/ButtonGroup.tsx +22 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Dialog/Dialog.tsx +3 -3
- package/src/components/Input/BarePinInput.tsx +1 -1
- package/src/components/Input/BareTextInput.tsx +2 -1
- package/src/components/Input/BareTextareaInput.tsx +29 -0
- package/src/components/Input/Input.tsx +7 -4
- package/src/components/Input/InputProps.ts +10 -2
- package/src/components/QrCode/QrCode.stories.tsx +16 -1
- package/src/components/QrCode/QrCode.tsx +115 -5
- package/src/components/Tooltip/Tooltip.tsx +14 -2
- package/src/hooks/useId.ts +1 -1
- package/src/styles/focus.ts +1 -1
- package/src/styles/group.ts +11 -2
- package/src/styles/hover.ts +1 -1
- package/src/styles/shimmer.ts +4 -1
- 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
|
-
|
|
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
|
|
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 = ({
|
|
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
|
|
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,
|
package/src/hooks/useId.ts
CHANGED
package/src/styles/focus.ts
CHANGED
|
@@ -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';
|
package/src/styles/group.ts
CHANGED
|
@@ -16,9 +16,18 @@ const elevationClassNameMap = new Map<number, string>([
|
|
|
16
16
|
[6, 'shadow-2xl']
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
|
-
export const defaultGroup = ({
|
|
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
|
|
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',
|
package/src/styles/hover.ts
CHANGED
|
@@ -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
|
};
|
package/src/styles/shimmer.ts
CHANGED
|
@@ -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/
|
|
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';
|