@particle-academy/react-fancy 1.7.1 → 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/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
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# FileUpload
|
|
2
|
+
|
|
3
|
+
Compound file upload component with drag-and-drop dropzone and file list display (list or thumbnail mode).
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { FileUpload } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<FileUpload onChange={(files) => console.log(files)}>
|
|
15
|
+
<FileUpload.Dropzone />
|
|
16
|
+
<FileUpload.List />
|
|
17
|
+
</FileUpload>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Components
|
|
21
|
+
|
|
22
|
+
### `FileUpload` (root)
|
|
23
|
+
|
|
24
|
+
Provides file state context to its children.
|
|
25
|
+
|
|
26
|
+
| Prop | Type | Default | Description |
|
|
27
|
+
|------|------|---------|-------------|
|
|
28
|
+
| `children` | `ReactNode` | **required** | Must contain `Dropzone` and/or `List` |
|
|
29
|
+
| `value` | `File[]` | - | Controlled file list |
|
|
30
|
+
| `onChange` | `(files: File[]) => void` | - | Callback when files change |
|
|
31
|
+
| `accept` | `string` | - | Accepted file types (e.g. `"image/*,.pdf"`) |
|
|
32
|
+
| `multiple` | `boolean` | `true` | Allow multiple files |
|
|
33
|
+
| `maxFiles` | `number` | - | Maximum number of files |
|
|
34
|
+
| `maxSize` | `number` | - | Maximum file size in bytes (files exceeding this are silently filtered) |
|
|
35
|
+
| `disabled` | `boolean` | `false` | Disables upload and removal |
|
|
36
|
+
| `className` | `string` | - | Additional CSS classes on the wrapper |
|
|
37
|
+
|
|
38
|
+
### `FileUpload.Dropzone`
|
|
39
|
+
|
|
40
|
+
Drag-and-drop area that also opens a file picker on click.
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Default | Description |
|
|
43
|
+
|------|------|---------|-------------|
|
|
44
|
+
| `children` | `ReactNode` | Default upload icon + text | Custom dropzone content |
|
|
45
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
46
|
+
|
|
47
|
+
### `FileUpload.List`
|
|
48
|
+
|
|
49
|
+
Displays the uploaded files with remove buttons.
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| `thumbnail` | `boolean` | `false` | Show image thumbnails in a grid instead of a file list |
|
|
54
|
+
| `className` | `string` | - | Additional CSS classes |
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### With file constraints
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<FileUpload
|
|
62
|
+
accept="image/*"
|
|
63
|
+
maxFiles={5}
|
|
64
|
+
maxSize={5 * 1024 * 1024}
|
|
65
|
+
onChange={setFiles}
|
|
66
|
+
>
|
|
67
|
+
<FileUpload.Dropzone>
|
|
68
|
+
<p>Drop images here (max 5MB each)</p>
|
|
69
|
+
</FileUpload.Dropzone>
|
|
70
|
+
<FileUpload.List thumbnail />
|
|
71
|
+
</FileUpload>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### List mode
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<FileUpload onChange={handleUpload}>
|
|
78
|
+
<FileUpload.Dropzone />
|
|
79
|
+
<FileUpload.List />
|
|
80
|
+
</FileUpload>
|
|
81
|
+
```
|
package/docs/Heading.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Heading
|
|
2
|
+
|
|
3
|
+
A heading component that renders semantic heading elements with configurable size and weight.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Heading } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Heading>Page Title</Heading>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| as | `"h1" \| "h2" \| "h3" \| "h4" \| "h5" \| "h6"` | `"h2"` | Which heading element to render |
|
|
22
|
+
| size | `"xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl"` | `"lg"` | Text size |
|
|
23
|
+
| weight | `"normal" \| "medium" \| "semibold" \| "bold"` | `"bold"` | Font weight |
|
|
24
|
+
|
|
25
|
+
Also extends all native `<h1>`-`<h6>` HTML attributes.
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
### Page title
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<Heading as="h1" size="2xl">
|
|
33
|
+
Welcome
|
|
34
|
+
</Heading>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Section heading
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<Heading as="h3" size="md" weight="semibold">
|
|
41
|
+
Settings
|
|
42
|
+
</Heading>
|
|
43
|
+
```
|
package/docs/Icon.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Icon
|
|
2
|
+
|
|
3
|
+
An icon container that resolves icon names from registered icon sets (Lucide by default).
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Icon, registerIconSet, configureIcons } from "@particle-academy/react-fancy";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Icon name="rocket" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Props
|
|
18
|
+
|
|
19
|
+
| Prop | Type | Default | Description |
|
|
20
|
+
|------|------|---------|-------------|
|
|
21
|
+
| name | `string` | - | Icon name to resolve from the registered icon set (e.g., `"rocket"`, `"arrow-right"`) |
|
|
22
|
+
| size | `"xs" \| "sm" \| "md" \| "lg" \| "xl"` | `"md"` | Icon container size. Maps to: xs=12px, sm=16px, md=20px, lg=24px, xl=32px |
|
|
23
|
+
| iconSet | `string` | - | Which registered icon set to use (defaults to the configured default) |
|
|
24
|
+
|
|
25
|
+
Also extends all native `<span>` HTML attributes. When `children` are provided, they render instead of the resolved icon.
|
|
26
|
+
|
|
27
|
+
## Icon Configuration
|
|
28
|
+
|
|
29
|
+
### registerIconSet
|
|
30
|
+
|
|
31
|
+
Register a custom icon set by name.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { registerIconSet } from "@particle-academy/react-fancy";
|
|
35
|
+
|
|
36
|
+
registerIconSet("custom", {
|
|
37
|
+
resolve: (name) => MyCustomIconMap[name] ?? null,
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The `IconSet` interface requires a single `resolve` method:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
interface IconSet {
|
|
45
|
+
resolve: (name: string) => ComponentType<{ className?: string; size?: number }> | null;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### configureIcons
|
|
50
|
+
|
|
51
|
+
Set the default icon set used when `iconSet` is not specified on `<Icon>`.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { configureIcons } from "@particle-academy/react-fancy";
|
|
55
|
+
|
|
56
|
+
configureIcons({ defaultSet: "custom" });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The built-in default is `"lucide"`, which resolves kebab-case names (e.g., `"arrow-right"`) to Lucide React icons.
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
### Different sizes
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<Icon name="star" size="xs" />
|
|
67
|
+
<Icon name="star" size="md" />
|
|
68
|
+
<Icon name="star" size="xl" />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Using a specific icon set
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<Icon name="home" iconSet="custom" size="lg" />
|
|
75
|
+
```
|