aural-ui 2.0.2 → 2.0.3
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/dist/components/button/Button.stories.tsx +43 -0
- package/dist/components/button/index.tsx +10 -4
- package/dist/components/chip/index.tsx +3 -3
- package/dist/components/icon-button/IconButton.stories.tsx +48 -0
- package/dist/components/icon-button/index.tsx +6 -2
- package/dist/components/input/index.tsx +4 -0
- package/dist/components/overlay/index.tsx +22 -5
- package/dist/components/tag/index.tsx +2 -2
- package/dist/components/textarea/index.tsx +2 -0
- package/dist/components/tooltip/index.tsx +45 -0
- package/dist/hooks/index.ts +1 -0
- package/dist/hooks/use-change-state/UseChangeState.stories.tsx +744 -0
- package/dist/hooks/use-change-state/index.tsx +17 -0
- package/dist/hooks/use-change-state/meta.ts +6 -0
- package/dist/icons/circle-tick-icon/CircleTickIcon.stories.tsx +1204 -0
- package/dist/icons/circle-tick-icon/index.tsx +22 -0
- package/dist/icons/circle-tick-icon/meta.ts +8 -0
- package/dist/icons/copy-icon/CopyIcon.stories.tsx +1021 -0
- package/dist/icons/copy-icon/index.tsx +21 -0
- package/dist/icons/copy-icon/meta.ts +8 -0
- package/dist/icons/download-icon/DownloadIcon.stories.tsx +877 -0
- package/dist/icons/download-icon/index.tsx +22 -0
- package/dist/icons/download-icon/meta.ts +8 -0
- package/dist/icons/filter-bar-row-icon/FilterBarRowIcon.stories.tsx +1109 -0
- package/dist/icons/filter-bar-row-icon/index.tsx +24 -0
- package/dist/icons/filter-bar-row-icon/meta.ts +8 -0
- package/dist/icons/index.ts +8 -0
- package/dist/icons/notepad-icon/NotepadIcon.stories.tsx +1159 -0
- package/dist/icons/notepad-icon/index.tsx +21 -0
- package/dist/icons/notepad-icon/meta.ts +8 -0
- package/dist/icons/notes-icon/NotesIcon.stories.tsx +1159 -0
- package/dist/icons/notes-icon/index.tsx +24 -0
- package/dist/icons/notes-icon/meta.ts +8 -0
- package/dist/icons/paper-plane-icon/PaperPlaneIcon.stories.tsx +936 -0
- package/dist/icons/paper-plane-icon/index.tsx +33 -0
- package/dist/icons/paper-plane-icon/meta.ts +8 -0
- package/dist/icons/suggestion-icon/SuggestionIcon.stories.tsx +907 -0
- package/dist/icons/suggestion-icon/index.tsx +33 -0
- package/dist/icons/suggestion-icon/meta.ts +8 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from "react"
|
|
1
2
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
3
|
|
|
3
4
|
import { Button } from "."
|
|
@@ -79,3 +80,45 @@ export const Disabled: Story = {
|
|
|
79
80
|
variant: "primary",
|
|
80
81
|
},
|
|
81
82
|
}
|
|
83
|
+
|
|
84
|
+
export const WithToolTip: Story = {
|
|
85
|
+
render: () => (
|
|
86
|
+
<div className="flex gap-6 rounded p-8">
|
|
87
|
+
<Button
|
|
88
|
+
tooltip="Primary Variant"
|
|
89
|
+
tooltipContentProps={{
|
|
90
|
+
align: "center",
|
|
91
|
+
side: "top",
|
|
92
|
+
sideOffset: 10,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
Primary
|
|
96
|
+
</Button>
|
|
97
|
+
<Button
|
|
98
|
+
variant="secondary"
|
|
99
|
+
tooltip="Secondary Variant"
|
|
100
|
+
tooltipContentProps={{
|
|
101
|
+
align: "center",
|
|
102
|
+
side: "bottom",
|
|
103
|
+
sideOffset: 10,
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
Secondary
|
|
107
|
+
</Button>
|
|
108
|
+
<Button
|
|
109
|
+
variant="outline"
|
|
110
|
+
tooltip="Outline Variant"
|
|
111
|
+
tooltipContentProps={{
|
|
112
|
+
align: "center",
|
|
113
|
+
side: "top",
|
|
114
|
+
sideOffset: 10,
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
Outline
|
|
118
|
+
</Button>
|
|
119
|
+
<Button variant="text" tooltip="Text Variant">
|
|
120
|
+
Text
|
|
121
|
+
</Button>
|
|
122
|
+
</div>
|
|
123
|
+
),
|
|
124
|
+
}
|
|
@@ -3,6 +3,8 @@ import { FeatureShineIcon } from "@icons/feature-shine-icon"
|
|
|
3
3
|
import { cn } from "@lib/utils"
|
|
4
4
|
import { cva } from "class-variance-authority"
|
|
5
5
|
|
|
6
|
+
import { withTooltip } from "../tooltip"
|
|
7
|
+
|
|
6
8
|
export const buttonVariants = cva(
|
|
7
9
|
"group relative font-fm-brand focus-visible:ring-fm-primary focus-visible:ring-offset-fm-contrast outline-none focus-visible:ring-2 focus-visible:ring-offset-6",
|
|
8
10
|
{
|
|
@@ -68,8 +70,8 @@ export const innerButtonVariants = cva(
|
|
|
68
70
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
69
71
|
children: React.ReactNode
|
|
70
72
|
className?: string
|
|
71
|
-
leftIcon?: React.ReactNode
|
|
72
|
-
rightIcon?: React.ReactNode
|
|
73
|
+
leftIcon?: React.ReactNode
|
|
74
|
+
rightIcon?: React.ReactNode
|
|
73
75
|
iconProps?: React.SVGProps<SVGSVGElement>
|
|
74
76
|
innerClassName?: string
|
|
75
77
|
isDisabled?: boolean
|
|
@@ -77,7 +79,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
77
79
|
variant?: "primary" | "secondary" | "outline" | "text"
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
export const
|
|
82
|
+
export const RawButton = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
81
83
|
(
|
|
82
84
|
{
|
|
83
85
|
variant = "primary",
|
|
@@ -99,7 +101,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
99
101
|
? "var(--color-fm-secondary-800)"
|
|
100
102
|
: "var(--color-fm-primary)"
|
|
101
103
|
|
|
102
|
-
const renderIcon = (icon: React.ReactNode
|
|
104
|
+
const renderIcon = (icon: React.ReactNode) => {
|
|
103
105
|
if (!icon) {
|
|
104
106
|
return null
|
|
105
107
|
}
|
|
@@ -156,3 +158,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
156
158
|
)
|
|
157
159
|
}
|
|
158
160
|
)
|
|
161
|
+
|
|
162
|
+
RawButton.displayName = "RawButton"
|
|
163
|
+
|
|
164
|
+
export const Button = withTooltip(RawButton)
|
|
@@ -9,9 +9,9 @@ export interface ChipProps
|
|
|
9
9
|
/** Sets the chip to selected state */
|
|
10
10
|
selected?: boolean
|
|
11
11
|
/** Icon to display on the left side (overrides icon prop for left side) */
|
|
12
|
-
leftIcon?: ReactNode
|
|
12
|
+
leftIcon?: ReactNode
|
|
13
13
|
/** Icon to display on the right side (overrides icon prop for right side) */
|
|
14
|
-
rightIcon?: ReactNode
|
|
14
|
+
rightIcon?: ReactNode
|
|
15
15
|
/** Icon properties for the left and right icons */
|
|
16
16
|
iconProps?: React.SVGProps<SVGSVGElement>
|
|
17
17
|
/** Callback fired when the chip is selected */
|
|
@@ -43,7 +43,7 @@ export const Chip = forwardRef<HTMLButtonElement, ChipProps>(
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const renderIcon = (icon: React.ReactNode
|
|
46
|
+
const renderIcon = (icon: React.ReactNode) => {
|
|
47
47
|
if (!icon) {
|
|
48
48
|
return null
|
|
49
49
|
}
|
|
@@ -4,6 +4,8 @@ import { FeatureShineIcon } from "@icons/feature-shine-icon"
|
|
|
4
4
|
import { SearchIcon } from "@icons/search-icon"
|
|
5
5
|
import { type Meta, type StoryObj } from "@storybook/react"
|
|
6
6
|
|
|
7
|
+
import { NotepadIcon } from "src/ui/icons"
|
|
8
|
+
|
|
7
9
|
import { IconButton } from "."
|
|
8
10
|
|
|
9
11
|
const meta: Meta<typeof IconButton> = {
|
|
@@ -133,6 +135,52 @@ export const WithoutBackground: Story = {
|
|
|
133
135
|
),
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
export const WithToolTip: Story = {
|
|
139
|
+
render: () => (
|
|
140
|
+
<div className="bg-fm-neutral-0 flex flex-col space-y-6 rounded p-8">
|
|
141
|
+
<h2 className="text-fm-yellow-500 text-sm font-bold">
|
|
142
|
+
With ToolTip EXAMPLES
|
|
143
|
+
</h2>
|
|
144
|
+
|
|
145
|
+
<div className="flex space-x-4">
|
|
146
|
+
<IconButton
|
|
147
|
+
variant="background"
|
|
148
|
+
icon={<SearchIcon />}
|
|
149
|
+
label="Search"
|
|
150
|
+
onClick={() => alert("Search clicked")}
|
|
151
|
+
tooltip="Search Items"
|
|
152
|
+
tooltipContentProps={{
|
|
153
|
+
align: "center",
|
|
154
|
+
side: "bottom",
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
<IconButton
|
|
158
|
+
variant="ghost"
|
|
159
|
+
icon={<CrossIcon />}
|
|
160
|
+
label="Close"
|
|
161
|
+
onClick={() => alert("Close clicked")}
|
|
162
|
+
tooltip="Cancel"
|
|
163
|
+
tooltipContentProps={{
|
|
164
|
+
align: "center",
|
|
165
|
+
side: "bottom",
|
|
166
|
+
}}
|
|
167
|
+
/>
|
|
168
|
+
<IconButton
|
|
169
|
+
variant="outlined"
|
|
170
|
+
icon={<NotepadIcon />}
|
|
171
|
+
label="Add"
|
|
172
|
+
onClick={() => alert("Add clicked")}
|
|
173
|
+
tooltip="Notes"
|
|
174
|
+
tooltipContentProps={{
|
|
175
|
+
align: "center",
|
|
176
|
+
side: "bottom",
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
),
|
|
182
|
+
}
|
|
183
|
+
|
|
136
184
|
export const Outlined: Story = {
|
|
137
185
|
args: {
|
|
138
186
|
label: "Search",
|
|
@@ -3,6 +3,8 @@ import { cn } from "@lib/utils"
|
|
|
3
3
|
import { AccessibleIcon } from "@radix-ui/react-accessible-icon"
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
5
|
|
|
6
|
+
import { withTooltip } from "../tooltip"
|
|
7
|
+
|
|
6
8
|
// Define variants with class-variance-authority
|
|
7
9
|
const iconButtonVariants = cva(
|
|
8
10
|
// Base styles for all icon buttons
|
|
@@ -65,7 +67,7 @@ export interface IconButtonProps
|
|
|
65
67
|
className?: string
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
const
|
|
70
|
+
const IconButtonComp = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
69
71
|
(
|
|
70
72
|
{
|
|
71
73
|
className,
|
|
@@ -125,6 +127,8 @@ const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
|
125
127
|
}
|
|
126
128
|
)
|
|
127
129
|
|
|
128
|
-
IconButton
|
|
130
|
+
const IconButton = withTooltip(IconButtonComp)
|
|
131
|
+
|
|
132
|
+
IconButtonComp.displayName = "IconButton"
|
|
129
133
|
|
|
130
134
|
export { IconButton, iconButtonVariants }
|
|
@@ -83,6 +83,7 @@ type InputProps = {
|
|
|
83
83
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
84
84
|
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void
|
|
85
85
|
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void
|
|
86
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void
|
|
86
87
|
startIcon?: ReactNode
|
|
87
88
|
endIcon?: ReactNode
|
|
88
89
|
id?: string
|
|
@@ -223,6 +224,7 @@ const InputBase = forwardRef<
|
|
|
223
224
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
224
225
|
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void
|
|
225
226
|
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void
|
|
227
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void
|
|
226
228
|
id?: string
|
|
227
229
|
name?: string
|
|
228
230
|
required?: boolean
|
|
@@ -337,6 +339,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
337
339
|
onChange,
|
|
338
340
|
onBlur,
|
|
339
341
|
onFocus,
|
|
342
|
+
onKeyDown,
|
|
340
343
|
startIcon,
|
|
341
344
|
endIcon,
|
|
342
345
|
id,
|
|
@@ -418,6 +421,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
418
421
|
onChange={handleChange}
|
|
419
422
|
onFocus={onFocus}
|
|
420
423
|
onBlur={onBlur}
|
|
424
|
+
onKeyDown={onKeyDown}
|
|
421
425
|
required={required}
|
|
422
426
|
maxLength={maxLength}
|
|
423
427
|
startIcon={!!startIcon}
|
|
@@ -35,19 +35,36 @@ const overlayVariants = cva(
|
|
|
35
35
|
|
|
36
36
|
export interface OverlayProps
|
|
37
37
|
extends React.HTMLAttributes<HTMLDivElement>,
|
|
38
|
-
VariantProps<typeof overlayVariants> {
|
|
38
|
+
VariantProps<typeof overlayVariants> {
|
|
39
|
+
classes?: {
|
|
40
|
+
content?: string
|
|
41
|
+
root?: string
|
|
42
|
+
wrapper?: string
|
|
43
|
+
}
|
|
44
|
+
}
|
|
39
45
|
|
|
40
46
|
const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>(
|
|
41
|
-
({ opacity, glass, noise, className, children, ...props }, ref) => (
|
|
47
|
+
({ opacity, glass, noise, className, children, classes, ...props }, ref) => (
|
|
42
48
|
<>
|
|
43
49
|
<div
|
|
44
50
|
ref={ref}
|
|
45
|
-
className={cn(
|
|
51
|
+
className={cn(
|
|
52
|
+
overlayVariants({ opacity, glass, noise }),
|
|
53
|
+
className,
|
|
54
|
+
classes?.root
|
|
55
|
+
)}
|
|
46
56
|
{...props}
|
|
47
57
|
/>
|
|
48
58
|
{children && (
|
|
49
|
-
<div
|
|
50
|
-
|
|
59
|
+
<div
|
|
60
|
+
className={cn(
|
|
61
|
+
"pointer-events-none fixed inset-0 z-50 flex items-center justify-center",
|
|
62
|
+
classes?.wrapper
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
<div className={cn("pointer-events-auto", classes?.content)}>
|
|
66
|
+
{children}
|
|
67
|
+
</div>
|
|
51
68
|
</div>
|
|
52
69
|
)}
|
|
53
70
|
</>
|
|
@@ -20,8 +20,8 @@ interface TagProps {
|
|
|
20
20
|
emphasis?: "primary" | "secondary" | "tertiary"
|
|
21
21
|
className?: string
|
|
22
22
|
size?: "xs" | "sm" | "md"
|
|
23
|
-
leftIcon?: React.ReactNode
|
|
24
|
-
rightIcon?: React.ReactNode
|
|
23
|
+
leftIcon?: React.ReactNode
|
|
24
|
+
rightIcon?: React.ReactNode
|
|
25
25
|
children: React.ReactNode
|
|
26
26
|
iconProps?: React.SVGProps<SVGSVGElement>
|
|
27
27
|
id?: string
|
|
@@ -30,6 +30,8 @@ interface TextAreaBaseProps {
|
|
|
30
30
|
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void
|
|
31
31
|
onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void
|
|
32
32
|
onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void
|
|
33
|
+
onInput?: (e: React.FocusEvent<HTMLTextAreaElement>) => void
|
|
34
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLTextAreaElement>) => void
|
|
33
35
|
id?: string
|
|
34
36
|
name?: string
|
|
35
37
|
required?: boolean
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import * as React from "react"
|
|
2
3
|
import { cn } from "@lib/utils"
|
|
3
4
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
|
|
@@ -301,4 +302,48 @@ function TooltipContent({
|
|
|
301
302
|
)
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
export function withTooltip<
|
|
306
|
+
T extends
|
|
307
|
+
| keyof React.JSX.IntrinsicElements
|
|
308
|
+
| React.ForwardRefExoticComponent<any>,
|
|
309
|
+
>(Component: T) {
|
|
310
|
+
return React.forwardRef<
|
|
311
|
+
React.ElementRef<T>,
|
|
312
|
+
{
|
|
313
|
+
tooltip?: React.ReactNode
|
|
314
|
+
tooltipContentProps?: Omit<
|
|
315
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>,
|
|
316
|
+
"children"
|
|
317
|
+
>
|
|
318
|
+
tooltipProps?: Omit<
|
|
319
|
+
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>,
|
|
320
|
+
"children"
|
|
321
|
+
>
|
|
322
|
+
} & React.ComponentPropsWithoutRef<T>
|
|
323
|
+
>(function ExtendComponent(
|
|
324
|
+
{ tooltip, tooltipContentProps, tooltipProps, ...props },
|
|
325
|
+
ref
|
|
326
|
+
) {
|
|
327
|
+
const [mounted, setMounted] = React.useState(false)
|
|
328
|
+
|
|
329
|
+
React.useEffect(() => {
|
|
330
|
+
setMounted(true)
|
|
331
|
+
}, [])
|
|
332
|
+
|
|
333
|
+
const component = <Component ref={ref} {...(props as any)} />
|
|
334
|
+
|
|
335
|
+
if (tooltip && mounted) {
|
|
336
|
+
return (
|
|
337
|
+
<Tooltip delayDuration={200} {...tooltipProps}>
|
|
338
|
+
<TooltipTrigger asChild>{component}</TooltipTrigger>
|
|
339
|
+
|
|
340
|
+
<TooltipContent {...tooltipContentProps}>{tooltip}</TooltipContent>
|
|
341
|
+
</Tooltip>
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
return component
|
|
346
|
+
})
|
|
347
|
+
}
|
|
348
|
+
|
|
304
349
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
package/dist/hooks/index.ts
CHANGED