@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/Composer.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Composer
|
|
2
|
+
|
|
3
|
+
A chat-style message input with auto-growing textarea, Enter-to-submit, action slot, and controlled/uncontrolled value.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Composer } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Composer
|
|
15
|
+
onSubmit={(message) => console.log("Sent:", message)}
|
|
16
|
+
placeholder="Type a message..."
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Props
|
|
21
|
+
|
|
22
|
+
| Prop | Type | Default | Description |
|
|
23
|
+
|------|------|---------|-------------|
|
|
24
|
+
| value | `string` | - | Controlled input value |
|
|
25
|
+
| defaultValue | `string` | `""` | Default value (uncontrolled) |
|
|
26
|
+
| onChange | `(value: string) => void` | - | Callback on input change |
|
|
27
|
+
| onSubmit | `(value: string) => void` | - | Callback when Enter is pressed (without Shift) |
|
|
28
|
+
| placeholder | `string` | `"Type a message..."` | Textarea placeholder |
|
|
29
|
+
| actions | `ReactNode` | - | Custom action buttons rendered in the bottom toolbar |
|
|
30
|
+
| disabled | `boolean` | `false` | Disable input and submit |
|
|
31
|
+
| className | `string` | - | Additional CSS classes |
|
|
32
|
+
|
|
33
|
+
## With Actions
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<Composer
|
|
37
|
+
onSubmit={handleSend}
|
|
38
|
+
actions={
|
|
39
|
+
<>
|
|
40
|
+
<button onClick={handleAttach}>Attach</button>
|
|
41
|
+
<button onClick={handleEmoji}>Emoji</button>
|
|
42
|
+
</>
|
|
43
|
+
}
|
|
44
|
+
/>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Controlled
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
const [message, setMessage] = useState("");
|
|
51
|
+
|
|
52
|
+
<Composer
|
|
53
|
+
value={message}
|
|
54
|
+
onChange={setMessage}
|
|
55
|
+
onSubmit={(val) => {
|
|
56
|
+
sendMessage(val);
|
|
57
|
+
setMessage("");
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# ContentRenderer
|
|
2
|
+
|
|
3
|
+
Renders HTML or Markdown strings as styled prose, with support for custom tag extensions.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ContentRenderer } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<ContentRenderer value="<h1>Hello</h1><p>World</p>" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| value | `string` | - | HTML or Markdown string to render (required) |
|
|
22
|
+
| format | `"html" \| "markdown" \| "auto"` | `"auto"` | Content format. `"auto"` detects based on content |
|
|
23
|
+
| lineSpacing | `number` | `1.6` | Line height |
|
|
24
|
+
| extensions | `RenderExtension[]` | - | Per-instance render extensions (merged with global) |
|
|
25
|
+
| className | `string` | - | Additional CSS classes |
|
|
26
|
+
|
|
27
|
+
## Render Extensions
|
|
28
|
+
|
|
29
|
+
Extensions let you define custom tags that are rendered by React components. Register globally or pass per-instance:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { registerExtension } from "@particle-academy/react-fancy";
|
|
33
|
+
|
|
34
|
+
registerExtension({
|
|
35
|
+
tag: "thinking",
|
|
36
|
+
component: ({ content }) => (
|
|
37
|
+
<details className="bg-zinc-100 p-3 rounded">
|
|
38
|
+
<summary>Thinking...</summary>
|
|
39
|
+
<div dangerouslySetInnerHTML={{ __html: content }} />
|
|
40
|
+
</details>
|
|
41
|
+
),
|
|
42
|
+
block: true,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Content with custom tags
|
|
46
|
+
<ContentRenderer value="<thinking>Some internal reasoning</thinking><p>Final answer.</p>" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### RenderExtension
|
|
50
|
+
|
|
51
|
+
| Field | Type | Default | Description |
|
|
52
|
+
|-------|------|---------|-------------|
|
|
53
|
+
| tag | `string` | - | Tag name to match (case-insensitive) |
|
|
54
|
+
| component | `ComponentType<RenderExtensionProps>` | - | React component to render the tag |
|
|
55
|
+
| block | `boolean` | `true` | Block-level (`<div>`) vs inline (`<span>`) wrapping |
|
|
56
|
+
|
|
57
|
+
### RenderExtensionProps
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Description |
|
|
60
|
+
|------|------|-------------|
|
|
61
|
+
| content | `string` | Inner content of the custom tag |
|
|
62
|
+
| attributes | `Record<string, string>` | Parsed HTML attributes from the opening tag |
|
|
63
|
+
|
|
64
|
+
## Markdown Rendering
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<ContentRenderer value="# Title\n\nParagraph with **bold** text." format="markdown" />
|
|
68
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# ContextMenu
|
|
2
|
+
|
|
3
|
+
A right-click context menu that appears at the cursor position. Compound component with Trigger, Content, Item, and Separator.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ContextMenu } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<ContextMenu>
|
|
15
|
+
<ContextMenu.Trigger>
|
|
16
|
+
<div className="w-64 h-32 border border-dashed rounded p-4">
|
|
17
|
+
Right-click here
|
|
18
|
+
</div>
|
|
19
|
+
</ContextMenu.Trigger>
|
|
20
|
+
<ContextMenu.Content>
|
|
21
|
+
<ContextMenu.Item onClick={() => console.log("cut")}>Cut</ContextMenu.Item>
|
|
22
|
+
<ContextMenu.Item onClick={() => console.log("copy")}>Copy</ContextMenu.Item>
|
|
23
|
+
<ContextMenu.Item onClick={() => console.log("paste")}>Paste</ContextMenu.Item>
|
|
24
|
+
<ContextMenu.Separator />
|
|
25
|
+
<ContextMenu.Item danger onClick={() => console.log("delete")}>Delete</ContextMenu.Item>
|
|
26
|
+
</ContextMenu.Content>
|
|
27
|
+
</ContextMenu>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Props
|
|
31
|
+
|
|
32
|
+
### ContextMenu (root)
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
|------|------|---------|-------------|
|
|
36
|
+
| children | `ReactNode` | - | Trigger and content children |
|
|
37
|
+
|
|
38
|
+
### ContextMenu.Trigger
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Default | Description |
|
|
41
|
+
|------|------|---------|-------------|
|
|
42
|
+
| children | `ReactNode` | - | Area that responds to right-click |
|
|
43
|
+
| className | `string` | - | Additional CSS classes |
|
|
44
|
+
|
|
45
|
+
### ContextMenu.Content
|
|
46
|
+
|
|
47
|
+
| Prop | Type | Default | Description |
|
|
48
|
+
|------|------|---------|-------------|
|
|
49
|
+
| children | `ReactNode` | - | Menu items |
|
|
50
|
+
| className | `string` | - | Additional CSS classes |
|
|
51
|
+
|
|
52
|
+
### ContextMenu.Item
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
|------|------|---------|-------------|
|
|
56
|
+
| children | `ReactNode` | - | Item content |
|
|
57
|
+
| onClick | `() => void` | - | Click handler |
|
|
58
|
+
| disabled | `boolean` | - | Disable the item |
|
|
59
|
+
| danger | `boolean` | - | Destructive action styling (red) |
|
|
60
|
+
| className | `string` | - | Additional CSS classes |
|
|
61
|
+
|
|
62
|
+
### ContextMenu.Separator
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Description |
|
|
65
|
+
|------|------|---------|-------------|
|
|
66
|
+
| className | `string` | - | Additional CSS classes |
|
|
67
|
+
|
|
68
|
+
## Example with Disabled Items
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<ContextMenu>
|
|
72
|
+
<ContextMenu.Trigger>
|
|
73
|
+
<div className="p-6 bg-zinc-100 rounded">Right-click target</div>
|
|
74
|
+
</ContextMenu.Trigger>
|
|
75
|
+
<ContextMenu.Content>
|
|
76
|
+
<ContextMenu.Item onClick={handleEdit}>Edit</ContextMenu.Item>
|
|
77
|
+
<ContextMenu.Item disabled>Move (unavailable)</ContextMenu.Item>
|
|
78
|
+
<ContextMenu.Separator />
|
|
79
|
+
<ContextMenu.Item danger onClick={handleRemove}>Remove</ContextMenu.Item>
|
|
80
|
+
</ContextMenu.Content>
|
|
81
|
+
</ContextMenu>
|
|
82
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# DatePicker
|
|
2
|
+
|
|
3
|
+
Date input using native browser date/datetime pickers, supporting single dates and date ranges.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { DatePicker } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<DatePicker label="Start date" onValueChange={(date) => console.log(date)} />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| `range` | `boolean` | `false` | Enable range mode (renders two inputs with "to" separator) |
|
|
22
|
+
| `includeTime` | `boolean` | `false` | Use `datetime-local` instead of `date` |
|
|
23
|
+
| `min` | `string` | - | Minimum date (ISO format, e.g. `"2024-01-01"`) |
|
|
24
|
+
| `max` | `string` | - | Maximum date |
|
|
25
|
+
| `value` | `string` (single) / `[string, string]` (range) | - | Controlled value |
|
|
26
|
+
| `defaultValue` | `string` / `[string, string]` | `""` / `["", ""]` | Default value (uncontrolled) |
|
|
27
|
+
| `onValueChange` | `(value) => void` | - | Callback when value changes |
|
|
28
|
+
| `label` | `string` | - | Wraps in a `Field` with this label |
|
|
29
|
+
| `description` | `string` | - | Helper text |
|
|
30
|
+
| `error` | `string` | - | Error message |
|
|
31
|
+
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Controls sizing |
|
|
32
|
+
| `dirty` | `boolean` | `false` | Amber ring |
|
|
33
|
+
| `required` | `boolean` | `false` | Native required attribute + red asterisk |
|
|
34
|
+
| `disabled` | `boolean` | `false` | Disables the input(s) |
|
|
35
|
+
| `name` | `string` | - | Form field name. In range mode, generates `name_start` and `name_end`. |
|
|
36
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Date with time
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<DatePicker
|
|
44
|
+
label="Event start"
|
|
45
|
+
includeTime
|
|
46
|
+
min="2024-01-01T00:00"
|
|
47
|
+
onValueChange={setEventStart}
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Date range
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
const [range, setRange] = useState<[string, string]>(["", ""]);
|
|
55
|
+
|
|
56
|
+
<DatePicker
|
|
57
|
+
label="Vacation"
|
|
58
|
+
range
|
|
59
|
+
value={range}
|
|
60
|
+
onValueChange={setRange}
|
|
61
|
+
min="2024-01-01"
|
|
62
|
+
max="2025-12-31"
|
|
63
|
+
/>
|
|
64
|
+
```
|
package/docs/Diagram.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Diagram
|
|
2
|
+
|
|
3
|
+
A high-level ERD/flowchart diagram built on top of Canvas. Accepts a schema of entities and relations, auto-layouts positions, and supports drag-to-move, export, and import.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Diagram } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage (Schema-driven)
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
const schema = {
|
|
15
|
+
entities: [
|
|
16
|
+
{
|
|
17
|
+
name: "users",
|
|
18
|
+
fields: [
|
|
19
|
+
{ name: "id", type: "bigint", primary: true },
|
|
20
|
+
{ name: "name", type: "varchar" },
|
|
21
|
+
{ name: "email", type: "varchar" },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "posts",
|
|
26
|
+
fields: [
|
|
27
|
+
{ name: "id", type: "bigint", primary: true },
|
|
28
|
+
{ name: "user_id", type: "bigint", foreign: true },
|
|
29
|
+
{ name: "title", type: "varchar" },
|
|
30
|
+
{ name: "body", type: "text", nullable: true },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
relations: [
|
|
35
|
+
{ from: "users", to: "posts", type: "one-to-many" },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
<Diagram schema={schema} className="h-[600px]" downloadable minimap />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Props
|
|
43
|
+
|
|
44
|
+
### Diagram (root)
|
|
45
|
+
|
|
46
|
+
| Prop | Type | Default | Description |
|
|
47
|
+
|------|------|---------|-------------|
|
|
48
|
+
| schema | `DiagramSchema` | - | Declarative schema of entities and relations |
|
|
49
|
+
| type | `"erd" \| "flowchart" \| "general"` | `"general"` | Diagram type (affects relation rendering) |
|
|
50
|
+
| viewport | `ViewportState` | - | Controlled viewport |
|
|
51
|
+
| defaultViewport | `ViewportState` | - | Default viewport (auto-computed from schema if omitted) |
|
|
52
|
+
| onViewportChange | `(viewport: ViewportState) => void` | - | Viewport change callback |
|
|
53
|
+
| downloadable | `boolean` | `false` | Enable download toolbar action |
|
|
54
|
+
| importable | `boolean` | `false` | Enable import toolbar action |
|
|
55
|
+
| exportFormats | `ExportFormat[]` | `["erd"]` | Export format options: `"erd"`, `"uml"`, `"dfd"` |
|
|
56
|
+
| onImport | `(schema: DiagramSchema) => void` | - | Callback when a schema is imported |
|
|
57
|
+
| minimap | `boolean` | `false` | Show minimap overlay |
|
|
58
|
+
| className | `string` | - | Additional CSS classes |
|
|
59
|
+
|
|
60
|
+
### Diagram.Entity
|
|
61
|
+
|
|
62
|
+
| Prop | Type | Default | Description |
|
|
63
|
+
|------|------|---------|-------------|
|
|
64
|
+
| id | `string` | - | Unique identifier (defaults to `name`) |
|
|
65
|
+
| name | `string` | - | Entity name (required) |
|
|
66
|
+
| x | `number` | - | X position |
|
|
67
|
+
| y | `number` | - | Y position |
|
|
68
|
+
| color | `string` | - | Header color |
|
|
69
|
+
| draggable | `boolean` | - | Allow drag-to-move |
|
|
70
|
+
| onPositionChange | `(x: number, y: number) => void` | - | Drag callback |
|
|
71
|
+
| children | `ReactNode` | - | Field children |
|
|
72
|
+
| className | `string` | - | Additional CSS classes |
|
|
73
|
+
|
|
74
|
+
### Diagram.Field
|
|
75
|
+
|
|
76
|
+
| Prop | Type | Default | Description |
|
|
77
|
+
|------|------|---------|-------------|
|
|
78
|
+
| name | `string` | - | Field name (required) |
|
|
79
|
+
| type | `string` | - | Data type label |
|
|
80
|
+
| primary | `boolean` | - | Primary key indicator |
|
|
81
|
+
| foreign | `boolean` | - | Foreign key indicator |
|
|
82
|
+
| nullable | `boolean` | - | Nullable indicator |
|
|
83
|
+
| className | `string` | - | Additional CSS classes |
|
|
84
|
+
|
|
85
|
+
### Diagram.Relation
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Description |
|
|
88
|
+
|------|------|---------|-------------|
|
|
89
|
+
| from | `string` | - | Source entity id (required) |
|
|
90
|
+
| to | `string` | - | Target entity id (required) |
|
|
91
|
+
| fromField | `string` | - | Source field name |
|
|
92
|
+
| toField | `string` | - | Target field name |
|
|
93
|
+
| type | `RelationType` | - | `"one-to-one"`, `"one-to-many"`, or `"many-to-many"` (required) |
|
|
94
|
+
| label | `string` | - | Edge label |
|
|
95
|
+
| className | `string` | - | Additional CSS classes |
|
|
96
|
+
|
|
97
|
+
### Diagram.Toolbar
|
|
98
|
+
|
|
99
|
+
| Prop | Type | Default | Description |
|
|
100
|
+
|------|------|---------|-------------|
|
|
101
|
+
| className | `string` | - | Additional CSS classes |
|
|
102
|
+
|
|
103
|
+
## Declarative Children
|
|
104
|
+
|
|
105
|
+
You can also compose entities and relations as JSX children instead of (or alongside) the schema prop:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<Diagram type="erd" className="h-[500px]">
|
|
109
|
+
<Diagram.Entity name="categories" x={0} y={0} draggable>
|
|
110
|
+
<Diagram.Field name="id" type="int" primary />
|
|
111
|
+
<Diagram.Field name="name" type="varchar" />
|
|
112
|
+
</Diagram.Entity>
|
|
113
|
+
<Diagram.Entity name="products" x={300} y={0} draggable>
|
|
114
|
+
<Diagram.Field name="id" type="int" primary />
|
|
115
|
+
<Diagram.Field name="category_id" type="int" foreign />
|
|
116
|
+
</Diagram.Entity>
|
|
117
|
+
<Diagram.Relation from="categories" to="products" type="one-to-many" />
|
|
118
|
+
</Diagram>
|
|
119
|
+
```
|
package/docs/Dropdown.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Dropdown
|
|
2
|
+
|
|
3
|
+
A click-triggered dropdown menu with keyboard navigation, floating positioning, and item states.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Dropdown } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Dropdown>
|
|
15
|
+
<Dropdown.Trigger>
|
|
16
|
+
<button>Options</button>
|
|
17
|
+
</Dropdown.Trigger>
|
|
18
|
+
<Dropdown.Items>
|
|
19
|
+
<Dropdown.Item onClick={() => console.log("edit")}>Edit</Dropdown.Item>
|
|
20
|
+
<Dropdown.Item onClick={() => console.log("copy")}>Copy</Dropdown.Item>
|
|
21
|
+
<Dropdown.Separator />
|
|
22
|
+
<Dropdown.Item danger onClick={() => console.log("delete")}>Delete</Dropdown.Item>
|
|
23
|
+
</Dropdown.Items>
|
|
24
|
+
</Dropdown>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
### Dropdown (root)
|
|
30
|
+
|
|
31
|
+
| Prop | Type | Default | Description |
|
|
32
|
+
|------|------|---------|-------------|
|
|
33
|
+
| placement | `Placement` | `"bottom-start"` | Position relative to trigger |
|
|
34
|
+
| offset | `number` | `4` | Pixel offset from the trigger |
|
|
35
|
+
|
|
36
|
+
### Dropdown.Trigger
|
|
37
|
+
|
|
38
|
+
| Prop | Type | Default | Description |
|
|
39
|
+
|------|------|---------|-------------|
|
|
40
|
+
| children | `ReactNode` | - | Trigger element |
|
|
41
|
+
|
|
42
|
+
### Dropdown.Items
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Description |
|
|
45
|
+
|------|------|---------|-------------|
|
|
46
|
+
| children | `ReactNode` | - | Menu items |
|
|
47
|
+
| className | `string` | - | Additional CSS classes |
|
|
48
|
+
|
|
49
|
+
### Dropdown.Item
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| children | `ReactNode` | - | Item content |
|
|
54
|
+
| onClick | `() => void` | - | Click handler |
|
|
55
|
+
| disabled | `boolean` | - | Disable the item |
|
|
56
|
+
| danger | `boolean` | - | Destructive action styling (red) |
|
|
57
|
+
| className | `string` | - | Additional CSS classes |
|
|
58
|
+
|
|
59
|
+
### Dropdown.Separator
|
|
60
|
+
|
|
61
|
+
| Prop | Type | Default | Description |
|
|
62
|
+
|------|------|---------|-------------|
|
|
63
|
+
| className | `string` | - | Additional CSS classes |
|
|
64
|
+
|
|
65
|
+
## Example with Placement
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<Dropdown placement="bottom-end" offset={8}>
|
|
69
|
+
<Dropdown.Trigger>
|
|
70
|
+
<button>More actions</button>
|
|
71
|
+
</Dropdown.Trigger>
|
|
72
|
+
<Dropdown.Items>
|
|
73
|
+
<Dropdown.Item onClick={handleRename}>Rename</Dropdown.Item>
|
|
74
|
+
<Dropdown.Item disabled>Archive</Dropdown.Item>
|
|
75
|
+
<Dropdown.Separator />
|
|
76
|
+
<Dropdown.Item danger onClick={handleDelete}>Delete</Dropdown.Item>
|
|
77
|
+
</Dropdown.Items>
|
|
78
|
+
</Dropdown>
|
|
79
|
+
```
|
package/docs/Editor.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Editor
|
|
2
|
+
|
|
3
|
+
A rich text editor built on `contentEditable` with a configurable toolbar, HTML or Markdown output, and support for render extensions.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Editor } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Editor defaultValue="<p>Hello world</p>" onChange={(html) => console.log(html)}>
|
|
15
|
+
<Editor.Toolbar />
|
|
16
|
+
<Editor.Content />
|
|
17
|
+
</Editor>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Props
|
|
21
|
+
|
|
22
|
+
### Editor (root)
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Default | Description |
|
|
25
|
+
|------|------|---------|-------------|
|
|
26
|
+
| value | `string` | - | Controlled content value |
|
|
27
|
+
| defaultValue | `string` | `""` | Default content (uncontrolled) |
|
|
28
|
+
| onChange | `(value: string) => void` | - | Callback when content changes |
|
|
29
|
+
| outputFormat | `"html" \| "markdown"` | `"html"` | Output format for the onChange value |
|
|
30
|
+
| lineSpacing | `number` | `1.6` | Line height for content area |
|
|
31
|
+
| placeholder | `string` | - | Placeholder text |
|
|
32
|
+
| extensions | `RenderExtension[]` | - | Per-instance render extensions (merged with global) |
|
|
33
|
+
| className | `string` | - | Additional CSS classes |
|
|
34
|
+
|
|
35
|
+
### Editor.Toolbar
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
|------|------|---------|-------------|
|
|
39
|
+
| actions | `EditorAction[]` | - | Custom toolbar actions |
|
|
40
|
+
| onAction | `(command: string) => void` | - | Custom action handler |
|
|
41
|
+
| children | `ReactNode` | - | Custom toolbar content |
|
|
42
|
+
| className | `string` | - | Additional CSS classes |
|
|
43
|
+
|
|
44
|
+
#### EditorAction
|
|
45
|
+
|
|
46
|
+
| Field | Type | Description |
|
|
47
|
+
|-------|------|-------------|
|
|
48
|
+
| icon | `ReactNode` | Action icon element |
|
|
49
|
+
| label | `string` | Tooltip label |
|
|
50
|
+
| command | `string` | `document.execCommand` command name |
|
|
51
|
+
| commandArg | `string` | Optional command argument |
|
|
52
|
+
| active | `boolean` | Whether the action is currently active |
|
|
53
|
+
|
|
54
|
+
### Editor.Toolbar.Separator
|
|
55
|
+
|
|
56
|
+
A visual separator between toolbar groups. No props.
|
|
57
|
+
|
|
58
|
+
### Editor.Content
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Default | Description |
|
|
61
|
+
|------|------|---------|-------------|
|
|
62
|
+
| className | `string` | - | Additional CSS classes |
|
|
63
|
+
|
|
64
|
+
## Markdown Output
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<Editor outputFormat="markdown" onChange={(md) => console.log(md)}>
|
|
68
|
+
<Editor.Toolbar />
|
|
69
|
+
<Editor.Content />
|
|
70
|
+
</Editor>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Custom Toolbar
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<Editor defaultValue="">
|
|
77
|
+
<Editor.Toolbar>
|
|
78
|
+
<button onClick={() => exec("bold")}>B</button>
|
|
79
|
+
<Editor.Toolbar.Separator />
|
|
80
|
+
<button onClick={() => exec("italic")}>I</button>
|
|
81
|
+
</Editor.Toolbar>
|
|
82
|
+
<Editor.Content />
|
|
83
|
+
</Editor>
|
|
84
|
+
```
|
package/docs/Emoji.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Emoji
|
|
2
|
+
|
|
3
|
+
Renders an emoji character by name slug or direct emoji string.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Emoji } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Emoji name="rocket" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| name | `string` | - | Emoji slug resolved via the built-in emoji utils |
|
|
22
|
+
| emoji | `string` | - | Direct emoji character (takes precedence over `name` resolution) |
|
|
23
|
+
| size | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Display size. Maps to: sm=text-base, md=text-2xl, lg=text-4xl, xl=text-6xl |
|
|
24
|
+
| className | `string` | - | Additional CSS classes |
|
|
25
|
+
|
|
26
|
+
Returns `null` if neither `emoji` nor `name` resolves to a character.
|
|
27
|
+
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
### By name
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<Emoji name="fire" size="lg" />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Direct emoji character
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<Emoji emoji="👋" size="xl" />
|
|
40
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# EmojiSelect
|
|
2
|
+
|
|
3
|
+
A dropdown picker for selecting an emoji, with search filtering and category grouping.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { EmojiSelect } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<EmojiSelect onChange={(emoji) => console.log(emoji)} />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| value | `string` | - | Controlled selected emoji character |
|
|
22
|
+
| defaultValue | `string` | `""` | Default selected emoji (uncontrolled) |
|
|
23
|
+
| onChange | `(emoji: string) => void` | - | Callback when an emoji is selected |
|
|
24
|
+
| placeholder | `string` | `"Search emojis..."` | Search input placeholder text |
|
|
25
|
+
| className | `string` | - | Additional CSS classes |
|
|
26
|
+
|
|
27
|
+
Supports both controlled (`value` + `onChange`) and uncontrolled (`defaultValue`) usage.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### Controlled
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
const [emoji, setEmoji] = useState("");
|
|
35
|
+
|
|
36
|
+
<EmojiSelect value={emoji} onChange={setEmoji} />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### With custom placeholder
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
<EmojiSelect
|
|
43
|
+
defaultValue="🎉"
|
|
44
|
+
placeholder="Find an emoji..."
|
|
45
|
+
onChange={(e) => console.log("Selected:", e)}
|
|
46
|
+
/>
|
|
47
|
+
```
|
package/docs/Field.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Field
|
|
2
|
+
|
|
3
|
+
Form wrapper that adds a label, description, and error message around any input.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Field } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Field label="Email" error={errors.email} required>
|
|
15
|
+
<input type="email" />
|
|
16
|
+
</Field>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Default | Description |
|
|
22
|
+
|------|------|---------|-------------|
|
|
23
|
+
| `label` | `string` | - | Label text displayed above the children |
|
|
24
|
+
| `description` | `string` | - | Helper text shown below children (hidden when `error` is set) |
|
|
25
|
+
| `error` | `string` | - | Error message shown below children in red |
|
|
26
|
+
| `required` | `boolean` | `false` | Appends a red asterisk to the label |
|
|
27
|
+
| `htmlFor` | `string` | - | Connects the label to an input via `id` |
|
|
28
|
+
| `size` | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Controls label text size |
|
|
29
|
+
| `children` | `ReactNode` | **required** | The input element(s) to wrap |
|
|
30
|
+
| `className` | `string` | - | Additional CSS classes on the outer `div` |
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
### With description
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Field label="Username" description="Must be 3-20 characters.">
|
|
38
|
+
<Input name="username" />
|
|
39
|
+
</Field>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### With error
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<Field label="Password" error="Password is required." required>
|
|
46
|
+
<Input type="password" name="password" />
|
|
47
|
+
</Field>
|
|
48
|
+
```
|