Skip to content

Commit 7fb2060

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

Some content is hidden

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

76 files changed

+5296
-1514
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: 19 additions & 18 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,14 @@ 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"
7162
export { Separator } from "./src/Separator"
7263
export { Slider } from "./src/Slider"
7364
export { Switch } from "./src/Switch"
@@ -84,7 +75,13 @@ export {
8475
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./src/Tabs"
8576
export { Toggle } from "./src/Toggle"
8677
export { ToggleGroup, ToggleGroupItem } from "./src/ToggleGroup"
87-
78+
export {
79+
ModalDialog,
80+
type ModalProps,
81+
type ModalDialogInstance,
82+
type ModalAction,
83+
type SecondaryModalAction,
84+
} from "./src/ModalDialog"
8885
export { DropdownButton } from "./src/DropdownButton"
8986
export {
9087
Tooltip,
@@ -94,9 +91,13 @@ export {
9491
TooltipRoot,
9592
TooltipPortal,
9693
} from "./src/Tooltip"
97-
export { DataTable, DataTableRowContext } from "./src/DataTable"
94+
export { Count, type CountProps, CountSize, CountTheme } from "./src/Count"
95+
export * from "./src/DataTable"
9896
export { FixedText } from "./src/FixedText"
9997
export { Slot } from "@radix-ui/react-slot"
10098
export * from "./src/index"
101-
export { Select as EnchangedSelect, SelectVariant } from "./src/Select/Select"
99+
export { Select as EnchangedSelect, SelectVariant } from "./src/ReactSelect/Select"
102100
export { CodeExample } from "./src/CodeExample"
101+
export { SegmentedToggle } from "./src/SegmentedToggle"
102+
export * from "./src/DataTable/components"
103+
export * from "./src/SkeletonWrapper"

package.json

Lines changed: 4 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,9 @@
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+
"react-select": "^5.8.0",
39+
"framer-motion": "9.0.1",
40+
"react-day-picker": "9.3.0",
41+
"recharts": "2.13.3"
4142
}
4243
}

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: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,48 @@
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+
}
18+
19+
type Props = AlertBoxProps & {
20+
text?: string
21+
buttonText?: React.ReactNode
22+
buttonStyles?: ButtonStyles
23+
onButtonClick?: () => void | Promise<void>
24+
linkText?: React.ReactNode
25+
linkUrl?: string
26+
linkHideUnderline?: boolean
2227
icon?: React.ReactNode
28+
hideIcon?: boolean
29+
}
30+
31+
function AlertBox({ title, variant, className, children }: AlertBoxProps) {
32+
return (
33+
<div
34+
className={cn("rounded-md border px-3 py-3", className, {
35+
"border-primary-light bg-primary-extra-light": variant === "info",
36+
"border-warning-light bg-warning-extra-light": variant === "warning",
37+
"border-error-light bg-error-extra-light": variant === "error",
38+
"border-neutral-light bg-neutral-extra-light": variant === "neutral",
39+
"border-neutral-light": variant === "blank",
40+
"border-danger-light bg-danger-extra-light": variant === "danger",
41+
"flex flex-col gap-2": title,
42+
})}>
43+
{children}
44+
</div>
45+
)
2346
}
2447

2548
function Alert({
@@ -32,47 +55,66 @@ function Alert({
3255
variant = "info",
3356
className,
3457
children,
58+
buttonStyles,
59+
linkHideUnderline,
3560
icon: Icon,
61+
hideIcon = false,
3662
}: Props) {
3763
const icon = {
3864
info: <InfoCircleOutlined />,
65+
neutral: <InfoCircleOutlined />,
3966
warning: <WarningOutlined />,
4067
error: <ExclamationCircleFilled />,
4168
blank: <BulbOutlined />,
69+
danger: <WarningOutlined />,
4270
}
4371

4472
const buttonChild = React.Children.toArray(children).find(
4573
(child) => React.isValidElement(child) && (child.type as any)?.name === "AlertButton"
4674
) as React.ReactElement | undefined
4775

76+
const contentChildren = React.Children.toArray(children).filter(
77+
(child) => !React.isValidElement(child) || (child.type as any)?.name !== "AlertButton"
78+
)
79+
4880
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-
})}>
81+
<AlertBox className={className} title={title} variant={variant}>
5782
<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>}
83+
{!hideIcon && (Icon ? Icon : icon[variant])}
84+
{title ? (
85+
<span className="text-sm font-semibold">{title}</span>
86+
) : (
87+
<span className="text-sm">{text}</span>
88+
)}
6089
</span>
61-
{title && <span className="text-primary-main text-sm">{text}</span>}
90+
{title &&
91+
(contentChildren.length > 0 ? (
92+
<span className="text-primary-main text-sm">{contentChildren}</span>
93+
) : (
94+
text && <span className="text-primary-main whitespace-pre-wrap text-sm">{text}</span>
95+
))}
6296
<div className="flex flex-row items-center gap-2">
6397
{buttonText && !buttonChild && (
64-
<Button className="self-start" size="small" onClickAsync={onButtonClick}>
98+
<Button
99+
{...buttonStyles}
100+
className="self-start"
101+
size="small"
102+
onClickAsync={onButtonClick}>
65103
{buttonText}
66104
</Button>
67105
)}
68106
{buttonChild}
69107
{linkText && linkUrl && (
70-
<a href={linkUrl} rel="noreferrer" target="_blank" className="text-xs underline">
108+
<a
109+
href={linkUrl}
110+
rel="noreferrer"
111+
target="_blank"
112+
className={cn("text-xs", { underline: !linkHideUnderline })}>
71113
<span className="text-primary-main">{linkText}</span>
72114
</a>
73115
)}
74116
</div>
75-
</div>
117+
</AlertBox>
76118
)
77119
}
78120

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

83125
AlertButton.displayName = "AlertButton"
84126

127+
Alert.Box = AlertBox
128+
85129
Alert.Button = AlertButton
86130

87131
export { Alert }

0 commit comments

Comments
 (0)