@particle-academy/react-fancy 1.7.0 → 1.7.2
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/README.md +76 -82
- package/docs/Accordion.md +78 -0
- package/docs/Action.md +76 -0
- package/docs/Autocomplete.md +74 -0
- package/docs/Avatar.md +40 -0
- package/docs/Badge.md +42 -0
- package/docs/Brand.md +44 -0
- package/docs/Breadcrumbs.md +51 -0
- package/docs/Calendar.md +72 -0
- package/docs/Callout.md +46 -0
- package/docs/Canvas.md +102 -0
- package/docs/Card.md +68 -0
- package/docs/Carousel.md +97 -0
- package/docs/Chart.md +126 -0
- package/docs/Checkbox.md +86 -0
- package/docs/ColorPicker.md +49 -0
- package/docs/Command.md +88 -0
- package/docs/Composer.md +60 -0
- package/docs/ContentRenderer.md +68 -0
- package/docs/ContextMenu.md +82 -0
- package/docs/DatePicker.md +64 -0
- package/docs/Diagram.md +119 -0
- package/docs/Dropdown.md +79 -0
- package/docs/Editor.md +84 -0
- package/docs/Emoji.md +40 -0
- package/docs/EmojiSelect.md +47 -0
- package/docs/Field.md +48 -0
- package/docs/FileUpload.md +81 -0
- package/docs/Heading.md +43 -0
- package/docs/Icon.md +75 -0
- package/docs/Input.md +73 -0
- package/docs/Kanban.md +79 -0
- package/docs/Menu.md +71 -0
- package/docs/MobileMenu.md +69 -0
- package/docs/Modal.md +74 -0
- package/docs/MultiSwitch.md +64 -0
- package/docs/Navbar.md +65 -0
- package/docs/OtpInput.md +48 -0
- package/docs/Pagination.md +48 -0
- package/docs/Pillbox.md +53 -0
- package/docs/Popover.md +82 -0
- package/docs/Portal.md +40 -0
- package/docs/Profile.md +52 -0
- package/docs/Progress.md +42 -0
- package/docs/RadioGroup.md +69 -0
- package/docs/Select.md +122 -0
- package/docs/Separator.md +41 -0
- package/docs/Sidebar.md +88 -0
- package/docs/Skeleton.md +44 -0
- package/docs/Slider.md +75 -0
- package/docs/Switch.md +55 -0
- package/docs/Table.md +133 -0
- package/docs/Tabs.md +85 -0
- package/docs/Text.md +44 -0
- package/docs/Textarea.md +62 -0
- package/docs/TimePicker.md +45 -0
- package/docs/Timeline.md +118 -0
- package/docs/Toast.md +79 -0
- package/docs/Tooltip.md +46 -0
- package/docs/hooks.md +180 -0
- package/docs/utilities.md +74 -0
- package/package.json +2 -1
package/docs/Toast.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
A notification system with timed auto-dismiss, multiple variants, and configurable screen position. Uses a provider + hook pattern.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Toast, useToast } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
Wrap your app with `Toast.Provider`:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<Toast.Provider position="bottom-right" maxToasts={5}>
|
|
17
|
+
<App />
|
|
18
|
+
</Toast.Provider>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
function MyComponent() {
|
|
25
|
+
const { toast, dismiss } = useToast();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
onClick={() =>
|
|
30
|
+
toast({
|
|
31
|
+
title: "Saved",
|
|
32
|
+
description: "Your changes have been saved.",
|
|
33
|
+
variant: "success",
|
|
34
|
+
duration: 4000,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
Save
|
|
39
|
+
</button>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Props
|
|
45
|
+
|
|
46
|
+
### Toast.Provider
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
|------|------|---------|-------------|
|
|
50
|
+
| position | `"top-right" \| "top-left" \| "bottom-right" \| "bottom-left"` | `"bottom-right"` | Screen corner for toast stack |
|
|
51
|
+
| maxToasts | `number` | `5` | Maximum visible toasts (oldest removed first) |
|
|
52
|
+
|
|
53
|
+
### useToast() return value
|
|
54
|
+
|
|
55
|
+
| Property | Type | Description |
|
|
56
|
+
|----------|------|-------------|
|
|
57
|
+
| toasts | `ToastData[]` | Current list of active toasts |
|
|
58
|
+
| toast | `(data: Omit<ToastData, "id">) => string` | Show a toast, returns its id |
|
|
59
|
+
| dismiss | `(id: string) => void` | Manually dismiss a toast by id |
|
|
60
|
+
|
|
61
|
+
### ToastData
|
|
62
|
+
|
|
63
|
+
| Field | Type | Default | Description |
|
|
64
|
+
|-------|------|---------|-------------|
|
|
65
|
+
| title | `string` | - | Toast title (required) |
|
|
66
|
+
| description | `string` | - | Optional description text |
|
|
67
|
+
| variant | `"default" \| "success" \| "error" \| "warning" \| "info"` | `"default"` | Visual variant |
|
|
68
|
+
| duration | `number` | - | Auto-dismiss duration in ms |
|
|
69
|
+
|
|
70
|
+
## Example with Variants
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
const { toast } = useToast();
|
|
74
|
+
|
|
75
|
+
toast({ title: "Info", variant: "info" });
|
|
76
|
+
toast({ title: "Success!", variant: "success", description: "Item created." });
|
|
77
|
+
toast({ title: "Error", variant: "error", description: "Something went wrong." });
|
|
78
|
+
toast({ title: "Warning", variant: "warning", duration: 6000 });
|
|
79
|
+
```
|
package/docs/Tooltip.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Tooltip
|
|
2
|
+
|
|
3
|
+
A tooltip that appears on hover/focus around a trigger element, rendered via Portal for correct stacking.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Tooltip } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Tooltip content="Save changes">
|
|
15
|
+
<button>Save</button>
|
|
16
|
+
</Tooltip>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Default | Description |
|
|
22
|
+
|------|------|---------|-------------|
|
|
23
|
+
| children | `ReactElement` | **required** | Trigger element (must accept ref, onMouseEnter, onMouseLeave, onFocus, onBlur) |
|
|
24
|
+
| content | `ReactNode` | **required** | Tooltip content |
|
|
25
|
+
| placement | `Placement` | `"top"` | Position relative to trigger. One of: `"top"`, `"bottom"`, `"left"`, `"right"`, `"top-start"`, `"top-end"`, `"bottom-start"`, `"bottom-end"` |
|
|
26
|
+
| delay | `number` | `200` | Delay in ms before showing |
|
|
27
|
+
| offset | `number` | `8` | Distance in px from the trigger |
|
|
28
|
+
| className | `string` | - | Additional CSS classes for the tooltip |
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Bottom placement with longer delay
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<Tooltip content="Delete this item" placement="bottom" delay={500}>
|
|
36
|
+
<button>Delete</button>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Rich content
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<Tooltip content={<span>Press <kbd>Ctrl+S</kbd> to save</span>}>
|
|
44
|
+
<button>Save</button>
|
|
45
|
+
</Tooltip>
|
|
46
|
+
```
|
package/docs/hooks.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Hooks
|
|
2
|
+
|
|
3
|
+
Shared React hooks used internally by components and available for direct use.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import {
|
|
9
|
+
useControllableState,
|
|
10
|
+
useOutsideClick,
|
|
11
|
+
useEscapeKey,
|
|
12
|
+
useFocusTrap,
|
|
13
|
+
useFloatingPosition,
|
|
14
|
+
useAnimation,
|
|
15
|
+
useId,
|
|
16
|
+
usePanZoom,
|
|
17
|
+
} from "@particle-academy/react-fancy";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## useControllableState
|
|
23
|
+
|
|
24
|
+
Unifies controlled and uncontrolled component patterns into a single state hook.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
const [value, setValue] = useControllableState(controlledValue, defaultValue, onChange);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Param | Type | Description |
|
|
31
|
+
|-------|------|-------------|
|
|
32
|
+
| controlledValue | `T \| undefined` | External controlled value (pass `undefined` for uncontrolled) |
|
|
33
|
+
| defaultValue | `T` | Initial value when uncontrolled |
|
|
34
|
+
| onChange | `(value: T) => void` | Optional callback fired on every change |
|
|
35
|
+
|
|
36
|
+
**Returns:** `[T, (value: T | ((prev: T) => T)) => void]` -- current value and setter.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## useOutsideClick
|
|
41
|
+
|
|
42
|
+
Calls a handler when a click or touch occurs outside the referenced element.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
useOutsideClick(ref, handler, enabled, ignoreRef);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Param | Type | Default | Description |
|
|
49
|
+
|-------|------|---------|-------------|
|
|
50
|
+
| ref | `RefObject<HTMLElement \| null>` | - | Element to monitor |
|
|
51
|
+
| handler | `(event: MouseEvent \| TouchEvent) => void` | - | Called on outside click |
|
|
52
|
+
| enabled | `boolean` | `true` | Enable/disable the listener |
|
|
53
|
+
| ignoreRef | `RefObject<HTMLElement \| null>` | - | Optional element to exclude (e.g. a trigger) |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## useEscapeKey
|
|
58
|
+
|
|
59
|
+
Calls a handler when the Escape key is pressed.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
useEscapeKey(handler, enabled);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Param | Type | Default | Description |
|
|
66
|
+
|-------|------|---------|-------------|
|
|
67
|
+
| handler | `() => void` | - | Called on Escape keydown |
|
|
68
|
+
| enabled | `boolean` | `true` | Enable/disable the listener |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## useFocusTrap
|
|
73
|
+
|
|
74
|
+
Traps keyboard focus within a container element. Focuses the first focusable element on mount and restores focus on unmount.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
useFocusTrap(ref, enabled);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
| Param | Type | Default | Description |
|
|
81
|
+
|-------|------|---------|-------------|
|
|
82
|
+
| ref | `RefObject<HTMLElement \| null>` | - | Container to trap focus within |
|
|
83
|
+
| enabled | `boolean` | `true` | Enable/disable the trap |
|
|
84
|
+
|
|
85
|
+
Focusable elements: `a[href]`, `button:not([disabled])`, `input:not([disabled])`, `textarea:not([disabled])`, `select:not([disabled])`, `[tabindex]:not([tabindex='-1'])`.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## useFloatingPosition
|
|
90
|
+
|
|
91
|
+
Computes the absolute position for a floating element anchored to a reference element. Handles viewport clamping and automatic placement flipping.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
const { x, y, placement } = useFloatingPosition(anchorRef, floatingRef, options);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Param | Type | Description |
|
|
98
|
+
|-------|------|-------------|
|
|
99
|
+
| anchorRef | `RefObject<HTMLElement \| null>` | Reference/trigger element |
|
|
100
|
+
| floatingRef | `RefObject<HTMLElement \| null>` | Floating element to position |
|
|
101
|
+
| options | `object` | Configuration (see below) |
|
|
102
|
+
|
|
103
|
+
**Options:**
|
|
104
|
+
|
|
105
|
+
| Key | Type | Default | Description |
|
|
106
|
+
|-----|------|---------|-------------|
|
|
107
|
+
| placement | `Placement` | `"bottom"` | Desired placement |
|
|
108
|
+
| offset | `number` | `8` | Pixel gap between anchor and floating element |
|
|
109
|
+
| enabled | `boolean` | `true` | Enable/disable positioning |
|
|
110
|
+
|
|
111
|
+
**Returns:** `{ x: number, y: number, placement: Placement }` -- the resolved position may differ from requested if the element was flipped to stay in viewport.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## useAnimation
|
|
116
|
+
|
|
117
|
+
Manages CSS animation mount/unmount lifecycle. Keeps the element mounted during the exit animation, then unmounts after `animationend`.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
const { mounted, className, ref } = useAnimation({ open, enterClass, exitClass });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Option | Type | Description |
|
|
124
|
+
|--------|------|-------------|
|
|
125
|
+
| open | `boolean` | Whether the animated element should be visible |
|
|
126
|
+
| enterClass | `string` | CSS class applied on enter |
|
|
127
|
+
| exitClass | `string` | CSS class applied on exit |
|
|
128
|
+
|
|
129
|
+
**Returns:**
|
|
130
|
+
|
|
131
|
+
| Key | Type | Description |
|
|
132
|
+
|-----|------|-------------|
|
|
133
|
+
| mounted | `boolean` | Whether the element should be in the DOM |
|
|
134
|
+
| className | `string` | Current animation class to apply |
|
|
135
|
+
| ref | `RefObject<HTMLElement \| null>` | Attach to the animated element for `animationend` detection |
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## useId
|
|
140
|
+
|
|
141
|
+
Generates a stable unique ID, optionally with a prefix. Wraps React's `useId`.
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
const id = useId("dialog"); // e.g. "dialog-:r0:"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
| Param | Type | Default | Description |
|
|
148
|
+
|-------|------|---------|-------------|
|
|
149
|
+
| prefix | `string` | - | Optional prefix prepended to the id |
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## usePanZoom
|
|
154
|
+
|
|
155
|
+
Provides pointer-event handlers for panning (click+drag on background) and Ctrl+wheel zooming on a container element.
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
const { containerProps, isPanning } = usePanZoom(options);
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Options:**
|
|
162
|
+
|
|
163
|
+
| Key | Type | Description |
|
|
164
|
+
|-----|------|-------------|
|
|
165
|
+
| viewport | `ViewportState` | Current `{ panX, panY, zoom }` |
|
|
166
|
+
| setViewport | `(vp \| updater) => void` | State setter for viewport |
|
|
167
|
+
| minZoom | `number` | Minimum zoom level |
|
|
168
|
+
| maxZoom | `number` | Maximum zoom level |
|
|
169
|
+
| pannable | `boolean` | Enable panning |
|
|
170
|
+
| zoomable | `boolean` | Enable zooming |
|
|
171
|
+
| containerRef | `RefObject<HTMLElement \| null>` | The scrollable container |
|
|
172
|
+
|
|
173
|
+
**Returns:**
|
|
174
|
+
|
|
175
|
+
| Key | Type | Description |
|
|
176
|
+
|-----|------|-------------|
|
|
177
|
+
| containerProps | `{ onPointerDown, onPointerMove, onPointerUp }` | Spread onto the container element |
|
|
178
|
+
| isPanning | `boolean` | Whether a pan gesture is active |
|
|
179
|
+
|
|
180
|
+
Zooming requires Ctrl+wheel (or Cmd+wheel / pinch gesture). Normal scrolling is not hijacked.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Utilities
|
|
2
|
+
|
|
3
|
+
Shared utility functions and types.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { cn } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## cn()
|
|
14
|
+
|
|
15
|
+
Merges class names using `clsx` + `tailwind-merge`. Handles conditional classes and deduplicates conflicting Tailwind utilities.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
cn("px-4 py-2", isActive && "bg-blue-500", className);
|
|
19
|
+
// => "px-4 py-2 bg-blue-500"
|
|
20
|
+
|
|
21
|
+
cn("px-4 text-sm", "px-6");
|
|
22
|
+
// => "px-6 text-sm" (tailwind-merge resolves px conflict)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Signature:**
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
function cn(...inputs: ClassValue[]): string;
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Accepts strings, objects, arrays, `undefined`, `null`, and `false` -- anything `clsx` supports.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Shared Types
|
|
36
|
+
|
|
37
|
+
### Size
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
type Size = "xs" | "sm" | "md" | "lg" | "xl";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Color
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
type Color =
|
|
47
|
+
| "zinc" | "red" | "orange" | "amber" | "yellow" | "lime"
|
|
48
|
+
| "green" | "emerald" | "teal" | "cyan" | "sky" | "blue"
|
|
49
|
+
| "indigo" | "violet" | "purple" | "fuchsia" | "pink" | "rose";
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Variant
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
type Variant = "solid" | "outline" | "ghost" | "soft";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### ActionColor
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
type ActionColor =
|
|
62
|
+
| "blue" | "emerald" | "amber" | "red" | "violet"
|
|
63
|
+
| "indigo" | "sky" | "rose" | "orange" | "zinc";
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Placement
|
|
67
|
+
|
|
68
|
+
Used by Popover, Dropdown, and `useFloatingPosition`.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
type Placement =
|
|
72
|
+
| "top" | "bottom" | "left" | "right"
|
|
73
|
+
| "top-start" | "top-end" | "bottom-start" | "bottom-end";
|
|
74
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-academy/react-fancy",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "React UI component library — React port of the fancy-flux Blade component library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"dist",
|
|
24
|
+
"docs",
|
|
24
25
|
"README.md"
|
|
25
26
|
],
|
|
26
27
|
"scripts": {
|