Skip to content

Commit a2e818a

Browse files
committed
[skip ci] repo-sync
1 parent 7be37ac commit a2e818a

File tree

101 files changed

+7983
-1741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+7983
-1741
lines changed

.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"react/prop-types": "off"
4+
}
5+
}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
node_modules
2-
.DS_Store
1+
node_modules/
2+
lib/
3+
yarn-error.log

index.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ export {
1515
AlertDialogCancel,
1616
} from "./src/AlertDialog"
1717
export { Avatar, AvatarImage, AvatarFallback } from "./src/Avatar"
18-
export { Button } from "./src/Button"
18+
export { Button, getButtonClasses } from "./src/Button"
1919
export type { ButtonProps } from "./src/Button"
2020
export { Checkbox } from "./src/Checkbox"
2121
export { Chip } from "./src/Chip"
22-
export { Collapsible, CollapsibleTrigger, CollapsibleContent } from "./src/Collapsible"
2322

2423
export {
2524
Dialog,
@@ -52,22 +51,15 @@ export {
5251
} from "./src/DropdownMenu"
5352
export { HoverCard, HoverCardTrigger, HoverCardContent } from "./src/HoverCard"
5453
export { IconButton } from "./src/IconButton"
55-
export { Input } from "./src/Input"
54+
export { Input, type InputProps } from "./src/Input"
5655
export { Label } from "./src/Label"
5756
export { Popover, PopoverContent, PopoverRoot, PopoverTrigger, PopoverPortal } from "./src/Popover"
58-
export { Progress } from "./src/Progress"
59-
export { RadioGroup, RadioGroupItem } from "./src/RadioGroup"
57+
export { RichTooltip, type RichTooltipProps, type RichTooltipAction } from "./src/RichTooltip"
58+
export { Progress, ProgressVariant } from "./src/Progress"
59+
export { RadioGroup, RadioGroupItem, LabeledRadioGroupItem } from "./src/RadioGroup"
6060
export { ScrollArea, ScrollBar } from "./src/ScrollArea"
61-
export {
62-
Select,
63-
SelectGroup,
64-
SelectValue,
65-
SelectTrigger,
66-
SelectContent,
67-
SelectLabel,
68-
SelectItem,
69-
SelectSeparator,
70-
} from "./src/Select"
61+
export * from "./src/Select"
62+
export * from "./src/Autocomplete"
7163
export { Separator } from "./src/Separator"
7264
export { Slider } from "./src/Slider"
7365
export { Switch } from "./src/Switch"
@@ -81,10 +73,16 @@ export {
8173
TableCell,
8274
TableCaption,
8375
} from "./src/Table"
84-
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./src/Tabs"
76+
export * from "./src/Tabs"
8577
export { Toggle } from "./src/Toggle"
8678
export { ToggleGroup, ToggleGroupItem } from "./src/ToggleGroup"
87-
79+
export {
80+
ModalDialog,
81+
type ModalProps,
82+
type ModalDialogInstance,
83+
type ModalAction,
84+
type SecondaryModalAction,
85+
} from "./src/ModalDialog"
8886
export { DropdownButton } from "./src/DropdownButton"
8987
export {
9088
Tooltip,
@@ -94,9 +92,14 @@ export {
9492
TooltipRoot,
9593
TooltipPortal,
9694
} from "./src/Tooltip"
97-
export { DataTable, DataTableRowContext } from "./src/DataTable"
95+
export { Count, type CountProps, CountSize, CountTheme } from "./src/Count"
96+
export * from "./src/DataTable"
9897
export { FixedText } from "./src/FixedText"
9998
export { Slot } from "@radix-ui/react-slot"
10099
export * from "./src/index"
101-
export { Select as EnchangedSelect, SelectVariant } from "./src/Select/Select"
102100
export { CodeExample } from "./src/CodeExample"
101+
export { SegmentedToggle, type SegmentedToggleProps, type SegmentItem } from "./src/SegmentedToggle"
102+
export * from "./src/DataTable/components"
103+
export * from "./src/SkeletonWrapper"
104+
export { Loading } from "./src/Loading"
105+
export * from "./src/Toast"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
"main": "index.ts",
66
"peerDependencies": {
77
"@loft-enterprise/client": "0.1.0",
8-
"@loft-enterprise/icons": "*",
9-
"framer-motion": "9.0.1",
108
"tailwindcss": "3.4.0"
119
},
1210
"dependencies": {
@@ -37,6 +35,8 @@
3735
"@radix-ui/react-toggle-group": "1.0.4",
3836
"@radix-ui/react-toolbar": "1.0.4",
3937
"@radix-ui/react-tooltip": "1.0.7",
40-
"react-select": "^5.8.0"
38+
"framer-motion": "9.0.1",
39+
"react-day-picker": "9.3.0",
40+
"recharts": "2.13.3"
4141
}
4242
}

src/Accordion.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
1+
import DownOutlined from "@ant-design/icons/DownOutlined"
12
import * as AccordionPrimitive from "@radix-ui/react-accordion"
23
import * as React from "react"
34

45
import cn from "../clsx"
5-
import { DownOutlined } from "@loft-enterprise/icons"
66

77
const Accordion = AccordionPrimitive.Root
88

99
const AccordionItem = React.forwardRef<
1010
React.ElementRef<typeof AccordionPrimitive.Item>,
1111
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
1212
>(({ className, ...props }, ref) => (
13-
<AccordionPrimitive.Item ref={ref} className={className} {...props} />
13+
<AccordionPrimitive.Item ref={ref} className={cn("group/accordion", className)} {...props} />
1414
))
1515
AccordionItem.displayName = "AccordionItem"
1616

17+
type TAccordionTriggerProps = React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> & {
18+
customTrigger?: React.ReactNode
19+
}
20+
1721
const AccordionTrigger = React.forwardRef<
1822
React.ElementRef<typeof AccordionPrimitive.Trigger>,
19-
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
20-
>(({ className, children, ...props }, ref) => (
21-
<AccordionPrimitive.Header>
22-
<AccordionPrimitive.Trigger
23-
ref={ref}
24-
className={cn(
25-
"group/accordion flex cursor-pointer items-center justify-between bg-transparent p-2 transition-all [&[aria-expanded=true]>svg]:rotate-180",
26-
className
27-
)}
28-
{...props}>
29-
{children}
23+
TAccordionTriggerProps
24+
>(({ className, children, customTrigger, ...props }, ref) => (
25+
<AccordionPrimitive.Trigger
26+
ref={ref}
27+
className={cn(
28+
"group/accordion flex cursor-pointer items-center justify-between bg-transparent p-2 transition-all [&[aria-expanded=true]>svg]:rotate-180",
29+
className
30+
)}
31+
{...props}>
32+
{children}
33+
{customTrigger ?? (
3034
<DownOutlined
3135
className="transition-transform
32-
duration-200 ease-in-out *:size-3 group-aria-[expanded=true]/accordion:rotate-180"
36+
duration-200 ease-in-out *:size-3 group-aria-[expanded=true]/accordion:rotate-180"
3337
/>
34-
</AccordionPrimitive.Trigger>
35-
</AccordionPrimitive.Header>
38+
)}
39+
</AccordionPrimitive.Trigger>
3640
))
3741
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
3842

@@ -42,7 +46,7 @@ const AccordionContent = React.forwardRef<
4246
>(({ className, children, ...props }, ref) => (
4347
<AccordionPrimitive.Content
4448
ref={ref}
45-
className="overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
49+
className="w-full overflow-hidden transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
4650
{...props}>
4751
<div className={cn("", className)}>{children}</div>
4852
</AccordionPrimitive.Content>

src/Alert.tsx

Lines changed: 117 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,57 @@
1+
import BulbOutlined from "@ant-design/icons/BulbOutlined"
2+
import ExclamationCircleFilled from "@ant-design/icons/ExclamationCircleFilled"
3+
import InfoCircleOutlined from "@ant-design/icons/InfoCircleOutlined"
4+
import WarningOutlined from "@ant-design/icons/WarningOutlined"
15
import React from "react"
26

37
import cn from "../clsx"
4-
import { Button, ButtonProps } from "./Button"
5-
import {
6-
BulbOutlined,
7-
ExclamationCircleFilled,
8-
InfoCircleOutlined,
9-
WarningOutlined,
10-
} from "@loft-enterprise/icons"
8+
import { Button, ButtonProps, ButtonStyles } from "./Button"
119

12-
type Props = {
10+
type AlertVariant = "info" | "warning" | "error" | "blank" | "neutral" | "danger"
11+
12+
type AlertBoxProps = {
1313
title?: string
14-
text: string
15-
buttonText?: string
16-
onButtonClick?: () => Promise<void>
17-
linkText?: string
18-
linkUrl?: string
19-
variant?: "info" | "warning" | "error" | "blank"
14+
variant?: AlertVariant
2015
className?: string
2116
children?: React.ReactNode
17+
role?: string
18+
}
19+
20+
export type AlertProps = AlertBoxProps & {
21+
text?: string | React.ReactNode
22+
buttonText?: React.ReactNode
23+
buttonStyles?: ButtonStyles
24+
onButtonClick?: () => void | Promise<void>
25+
linkText?: React.ReactNode
26+
linkUrl?: string
27+
linkHideUnderline?: boolean
2228
icon?: React.ReactNode
29+
hideIcon?: boolean
30+
textClassName?: string
31+
contentClassName?: string
32+
iconWrapperClassName?: string
33+
}
34+
35+
function AlertBox({ title, variant, className, children, role }: AlertBoxProps) {
36+
return (
37+
<div
38+
role={role}
39+
className={cn(
40+
"rounded-md border px-3 py-3",
41+
{
42+
"border-primary-light bg-primary-extra-light": variant === "info",
43+
"border-warning-light bg-warning-extra-light": variant === "warning",
44+
"border-error-light bg-error-extra-light": variant === "error",
45+
"border-neutral-light bg-neutral-extra-light": variant === "neutral",
46+
"border-neutral-light": variant === "blank",
47+
"border-danger-light bg-danger-extra-light": variant === "danger",
48+
"flex flex-col gap-2": title,
49+
},
50+
className
51+
)}>
52+
{children}
53+
</div>
54+
)
2355
}
2456

2557
function Alert({
@@ -32,47 +64,89 @@ function Alert({
3264
variant = "info",
3365
className,
3466
children,
67+
buttonStyles,
68+
linkHideUnderline,
3569
icon: Icon,
36-
}: Props) {
70+
hideIcon = false,
71+
textClassName,
72+
contentClassName,
73+
iconWrapperClassName,
74+
}: AlertProps) {
3775
const icon = {
3876
info: <InfoCircleOutlined />,
77+
neutral: <InfoCircleOutlined />,
3978
warning: <WarningOutlined />,
4079
error: <ExclamationCircleFilled />,
4180
blank: <BulbOutlined />,
81+
danger: <WarningOutlined />,
4282
}
4383

4484
const buttonChild = React.Children.toArray(children).find(
4585
(child) => React.isValidElement(child) && (child.type as any)?.name === "AlertButton"
4686
) as React.ReactElement | undefined
4787

88+
const contentChildren = React.Children.toArray(children).filter(
89+
(child) => !React.isValidElement(child) || (child.type as any)?.name !== "AlertButton"
90+
)
91+
92+
const getRole = (variant: AlertVariant): string => {
93+
switch (variant) {
94+
case "error":
95+
case "danger":
96+
return "alert"
97+
case "info":
98+
case "warning":
99+
case "neutral":
100+
case "blank":
101+
default:
102+
return "note"
103+
}
104+
}
105+
48106
return (
49-
<div
50-
className={cn("rounded-md border px-3 py-3", className, {
51-
"border-primary-light bg-primary-extra-light": variant === "info",
52-
"border-warning-light bg-warning-extra-light": variant === "warning",
53-
"border-error-light bg-error-extra-light": variant === "error",
54-
"border-neutral-light": variant === "blank",
55-
"flex flex-col gap-2": title,
56-
})}>
57-
<span className="flex flex-row items-center gap-2 [&_svg]:size-4">
58-
{Icon ? Icon : icon[variant]}
59-
{title ? <span className="font-bold">{title}</span> : <span>{text}</span>}
60-
</span>
61-
{title && <span className="text-primary-main text-sm">{text}</span>}
62-
<div className="flex flex-row items-center gap-2">
63-
{buttonText && !buttonChild && (
64-
<Button className="self-start" size="small" onClickAsync={onButtonClick}>
65-
{buttonText}
66-
</Button>
67-
)}
68-
{buttonChild}
69-
{linkText && linkUrl && (
70-
<a href={linkUrl} rel="noreferrer" target="_blank" className="text-xs underline">
71-
<span className="text-primary-main">{linkText}</span>
72-
</a>
107+
<AlertBox className={className} title={title} variant={variant} role={getRole(variant)}>
108+
<div className={cn("flex flex-row items-center gap-2 [&_svg]:size-4", contentClassName)}>
109+
{!hideIcon && <div className={iconWrapperClassName}>{Icon ? Icon : icon[variant]}</div>}
110+
{title ? (
111+
<span className="text-sm font-semibold">{title}</span>
112+
) : (
113+
<span className={cn("text-sm", textClassName)}>{text}</span>
73114
)}
74115
</div>
75-
</div>
116+
{title &&
117+
(contentChildren.length > 0 ? (
118+
<span className="text-primary-main text-sm">{contentChildren}</span>
119+
) : (
120+
text && (
121+
<span className={cn("text-primary-main whitespace-pre-wrap text-sm", textClassName)}>
122+
{text}
123+
</span>
124+
)
125+
))}
126+
{!!(buttonText || buttonChild || linkText) && (
127+
<div className="flex flex-row items-center gap-2">
128+
{buttonText && !buttonChild && (
129+
<Button
130+
{...buttonStyles}
131+
className="self-start"
132+
size="small"
133+
onClickAsync={onButtonClick}>
134+
{buttonText}
135+
</Button>
136+
)}
137+
{buttonChild}
138+
{linkText && linkUrl && (
139+
<a
140+
href={linkUrl}
141+
rel="noreferrer"
142+
target="_blank"
143+
className={cn("text-xs", { underline: !linkHideUnderline })}>
144+
<span className="text-primary-main">{linkText}</span>
145+
</a>
146+
)}
147+
</div>
148+
)}
149+
</AlertBox>
76150
)
77151
}
78152

@@ -82,6 +156,8 @@ function AlertButton({ children, ...props }: ButtonProps) {
82156

83157
AlertButton.displayName = "AlertButton"
84158

159+
Alert.Box = AlertBox
160+
85161
Alert.Button = AlertButton
86162

87-
export { Alert }
163+
export { Alert, AlertBox }

0 commit comments

Comments
 (0)