main
Some checks failed
UI Deploy (Next-Auth Support) 🎨 / build-and-deploy (push) Failing after 2m42s
Some checks failed
UI Deploy (Next-Auth Support) 🎨 / build-and-deploy (push) Failing after 2m42s
This commit is contained in:
26
src/components/ui/data-display/avatar.tsx
Normal file
26
src/components/ui/data-display/avatar.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Avatar as ChakraAvatar, AvatarGroup as ChakraAvatarGroup } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
|
||||
type ImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
||||
|
||||
export interface AvatarProps extends ChakraAvatar.RootProps {
|
||||
name?: string;
|
||||
src?: string;
|
||||
srcSet?: string;
|
||||
loading?: ImageProps['loading'];
|
||||
icon?: React.ReactElement;
|
||||
fallback?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>(function Avatar(props, ref) {
|
||||
const { name, src, srcSet, loading, icon, fallback, children, ...rest } = props;
|
||||
return (
|
||||
<ChakraAvatar.Root ref={ref} {...rest}>
|
||||
<ChakraAvatar.Fallback name={name}>{icon || fallback}</ChakraAvatar.Fallback>
|
||||
<ChakraAvatar.Image src={src} srcSet={srcSet} loading={loading} />
|
||||
{children}
|
||||
</ChakraAvatar.Root>
|
||||
);
|
||||
});
|
||||
|
||||
export const AvatarGroup = ChakraAvatarGroup;
|
||||
79
src/components/ui/data-display/clipboard.tsx
Normal file
79
src/components/ui/data-display/clipboard.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import type { ButtonProps, InputProps } from '@chakra-ui/react';
|
||||
import { Button, Clipboard as ChakraClipboard, IconButton, Input } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
import { LuCheck, LuClipboard, LuLink } from 'react-icons/lu';
|
||||
|
||||
const ClipboardIcon = React.forwardRef<HTMLDivElement, ChakraClipboard.IndicatorProps>(
|
||||
function ClipboardIcon(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Indicator copied={<LuCheck />} {...props} ref={ref}>
|
||||
<LuClipboard />
|
||||
</ChakraClipboard.Indicator>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
const ClipboardCopyText = React.forwardRef<HTMLDivElement, ChakraClipboard.IndicatorProps>(
|
||||
function ClipboardCopyText(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Indicator copied='Copied' {...props} ref={ref}>
|
||||
Copy
|
||||
</ChakraClipboard.Indicator>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export const ClipboardLabel = React.forwardRef<HTMLLabelElement, ChakraClipboard.LabelProps>(
|
||||
function ClipboardLabel(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Label textStyle='sm' fontWeight='medium' display='inline-block' mb='1' {...props} ref={ref} />
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export const ClipboardButton = React.forwardRef<HTMLButtonElement, ButtonProps>(function ClipboardButton(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Trigger asChild>
|
||||
<Button ref={ref} size='sm' variant='surface' {...props}>
|
||||
<ClipboardIcon />
|
||||
<ClipboardCopyText />
|
||||
</Button>
|
||||
</ChakraClipboard.Trigger>
|
||||
);
|
||||
});
|
||||
|
||||
export const ClipboardLink = React.forwardRef<HTMLButtonElement, ButtonProps>(function ClipboardLink(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Trigger asChild>
|
||||
<Button unstyled variant='plain' size='xs' display='inline-flex' alignItems='center' gap='2' ref={ref} {...props}>
|
||||
<LuLink />
|
||||
<ClipboardCopyText />
|
||||
</Button>
|
||||
</ChakraClipboard.Trigger>
|
||||
);
|
||||
});
|
||||
|
||||
export const ClipboardIconButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
function ClipboardIconButton(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Trigger asChild>
|
||||
<IconButton ref={ref} size='xs' variant='subtle' {...props}>
|
||||
<ClipboardIcon />
|
||||
<ClipboardCopyText srOnly />
|
||||
</IconButton>
|
||||
</ChakraClipboard.Trigger>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export const ClipboardInput = React.forwardRef<HTMLInputElement, InputProps>(
|
||||
function ClipboardInputElement(props, ref) {
|
||||
return (
|
||||
<ChakraClipboard.Input asChild>
|
||||
<Input ref={ref} {...props} />
|
||||
</ChakraClipboard.Input>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
export const ClipboardRoot = ChakraClipboard.Root;
|
||||
26
src/components/ui/data-display/data-list.tsx
Normal file
26
src/components/ui/data-display/data-list.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { DataList as ChakraDataList } from '@chakra-ui/react';
|
||||
import { InfoTip } from '@/components/ui/overlays/toggle-tip';
|
||||
import * as React from 'react';
|
||||
|
||||
export const DataListRoot = ChakraDataList.Root;
|
||||
|
||||
interface ItemProps extends ChakraDataList.ItemProps {
|
||||
label: React.ReactNode;
|
||||
value: React.ReactNode;
|
||||
info?: React.ReactNode;
|
||||
grow?: boolean;
|
||||
}
|
||||
|
||||
export const DataListItem = React.forwardRef<HTMLDivElement, ItemProps>(function DataListItem(props, ref) {
|
||||
const { label, info, value, children, grow, ...rest } = props;
|
||||
return (
|
||||
<ChakraDataList.Item ref={ref} {...rest}>
|
||||
<ChakraDataList.ItemLabel flex={grow ? '1' : undefined}>
|
||||
{label}
|
||||
{info && <InfoTip>{info}</InfoTip>}
|
||||
</ChakraDataList.ItemLabel>
|
||||
<ChakraDataList.ItemValue flex={grow ? '1' : undefined}>{value}</ChakraDataList.ItemValue>
|
||||
{children}
|
||||
</ChakraDataList.Item>
|
||||
);
|
||||
});
|
||||
20
src/components/ui/data-display/qr-code.tsx
Normal file
20
src/components/ui/data-display/qr-code.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { QrCode as ChakraQrCode } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
|
||||
export interface QrCodeProps extends Omit<ChakraQrCode.RootProps, 'fill' | 'overlay'> {
|
||||
fill?: string;
|
||||
overlay?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const QrCode = React.forwardRef<HTMLDivElement, QrCodeProps>(function QrCode(props, ref) {
|
||||
const { children, fill, overlay, ...rest } = props;
|
||||
return (
|
||||
<ChakraQrCode.Root ref={ref} {...rest}>
|
||||
<ChakraQrCode.Frame style={{ fill }}>
|
||||
<ChakraQrCode.Pattern />
|
||||
</ChakraQrCode.Frame>
|
||||
{children}
|
||||
{overlay && <ChakraQrCode.Overlay>{overlay}</ChakraQrCode.Overlay>}
|
||||
</ChakraQrCode.Root>
|
||||
);
|
||||
});
|
||||
53
src/components/ui/data-display/stat.tsx
Normal file
53
src/components/ui/data-display/stat.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Badge, type BadgeProps, Stat as ChakraStat, FormatNumber } from '@chakra-ui/react';
|
||||
import { InfoTip } from '@/components/ui/overlays/toggle-tip';
|
||||
import * as React from 'react';
|
||||
|
||||
interface StatLabelProps extends ChakraStat.LabelProps {
|
||||
info?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const StatLabel = React.forwardRef<HTMLDivElement, StatLabelProps>(function StatLabel(props, ref) {
|
||||
const { info, children, ...rest } = props;
|
||||
return (
|
||||
<ChakraStat.Label {...rest} ref={ref}>
|
||||
{children}
|
||||
{info && <InfoTip>{info}</InfoTip>}
|
||||
</ChakraStat.Label>
|
||||
);
|
||||
});
|
||||
|
||||
interface StatValueTextProps extends ChakraStat.ValueTextProps {
|
||||
value?: number;
|
||||
formatOptions?: Intl.NumberFormatOptions;
|
||||
}
|
||||
|
||||
export const StatValueText = React.forwardRef<HTMLDivElement, StatValueTextProps>(function StatValueText(props, ref) {
|
||||
const { value, formatOptions, children, ...rest } = props;
|
||||
return (
|
||||
<ChakraStat.ValueText {...rest} ref={ref}>
|
||||
{children || (value != null && <FormatNumber value={value} {...formatOptions} />)}
|
||||
</ChakraStat.ValueText>
|
||||
);
|
||||
});
|
||||
|
||||
export const StatUpTrend = React.forwardRef<HTMLDivElement, BadgeProps>(function StatUpTrend(props, ref) {
|
||||
return (
|
||||
<Badge colorPalette='green' gap='0' {...props} ref={ref}>
|
||||
<ChakraStat.UpIndicator />
|
||||
{props.children}
|
||||
</Badge>
|
||||
);
|
||||
});
|
||||
|
||||
export const StatDownTrend = React.forwardRef<HTMLDivElement, BadgeProps>(function StatDownTrend(props, ref) {
|
||||
return (
|
||||
<Badge colorPalette='red' gap='0' {...props} ref={ref}>
|
||||
<ChakraStat.DownIndicator />
|
||||
{props.children}
|
||||
</Badge>
|
||||
);
|
||||
});
|
||||
|
||||
export const StatRoot = ChakraStat.Root;
|
||||
export const StatHelpText = ChakraStat.HelpText;
|
||||
export const StatValueUnit = ChakraStat.ValueUnit;
|
||||
26
src/components/ui/data-display/tag.tsx
Normal file
26
src/components/ui/data-display/tag.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Tag as ChakraTag } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
|
||||
export interface TagProps extends ChakraTag.RootProps {
|
||||
startElement?: React.ReactNode;
|
||||
endElement?: React.ReactNode;
|
||||
onClose?: VoidFunction;
|
||||
closable?: boolean;
|
||||
}
|
||||
|
||||
export const Tag = React.forwardRef<HTMLSpanElement, TagProps>(function Tag(props, ref) {
|
||||
const { startElement, endElement, onClose, closable = !!onClose, children, ...rest } = props;
|
||||
|
||||
return (
|
||||
<ChakraTag.Root ref={ref} {...rest}>
|
||||
{startElement && <ChakraTag.StartElement>{startElement}</ChakraTag.StartElement>}
|
||||
<ChakraTag.Label>{children}</ChakraTag.Label>
|
||||
{endElement && <ChakraTag.EndElement>{endElement}</ChakraTag.EndElement>}
|
||||
{closable && (
|
||||
<ChakraTag.EndElement>
|
||||
<ChakraTag.CloseTrigger onClick={onClose} />
|
||||
</ChakraTag.EndElement>
|
||||
)}
|
||||
</ChakraTag.Root>
|
||||
);
|
||||
});
|
||||
25
src/components/ui/data-display/timeline.tsx
Normal file
25
src/components/ui/data-display/timeline.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Timeline as ChakraTimeline } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
|
||||
interface TimelineConnectorProps extends ChakraTimeline.IndicatorProps {
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const TimelineConnector = React.forwardRef<HTMLDivElement, TimelineConnectorProps>(function TimelineConnector(
|
||||
{ icon, ...props },
|
||||
ref,
|
||||
) {
|
||||
return (
|
||||
<ChakraTimeline.Connector ref={ref}>
|
||||
<ChakraTimeline.Separator />
|
||||
<ChakraTimeline.Indicator {...props}>{icon}</ChakraTimeline.Indicator>
|
||||
</ChakraTimeline.Connector>
|
||||
);
|
||||
});
|
||||
|
||||
export const TimelineRoot = ChakraTimeline.Root;
|
||||
export const TimelineContent = ChakraTimeline.Content;
|
||||
export const TimelineItem = ChakraTimeline.Item;
|
||||
export const TimelineIndicator = ChakraTimeline.Indicator;
|
||||
export const TimelineTitle = ChakraTimeline.Title;
|
||||
export const TimelineDescription = ChakraTimeline.Description;
|
||||
Reference in New Issue
Block a user