laif-ds 0.2.44 → 0.2.45
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/_virtual/index4.js +5 -5
- package/dist/_virtual/index5.js +5 -5
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/agent-docs/components/Accordion.md +157 -0
- package/dist/agent-docs/components/Alert.md +95 -0
- package/dist/agent-docs/components/AlertDialog.md +126 -0
- package/dist/agent-docs/components/AppEditor.md +90 -0
- package/dist/agent-docs/components/AppForm.md +242 -0
- package/dist/agent-docs/components/AppMultipleSelectDropdown.md +38 -0
- package/dist/agent-docs/components/AppRadioGroup.md +223 -0
- package/dist/agent-docs/components/AppSelect.md +427 -0
- package/dist/agent-docs/components/AppSidebar.md +122 -0
- package/dist/agent-docs/components/AppStepper.md +77 -0
- package/dist/agent-docs/components/AspectRatio.md +87 -0
- package/dist/agent-docs/components/AsyncSelect.md +127 -0
- package/dist/agent-docs/components/AudioVisualizer.md +41 -0
- package/dist/agent-docs/components/Avatar.md +113 -0
- package/dist/agent-docs/components/Badge.md +118 -0
- package/dist/agent-docs/components/Breadcrumb.md +78 -0
- package/dist/agent-docs/components/Button.md +129 -0
- package/dist/agent-docs/components/Calendar.md +222 -0
- package/dist/agent-docs/components/Card.md +147 -0
- package/dist/agent-docs/components/Carousel.md +129 -0
- package/dist/agent-docs/components/Chart.md +75 -0
- package/dist/agent-docs/components/Chat.md +109 -0
- package/dist/agent-docs/components/ChatMessage.md +61 -0
- package/dist/agent-docs/components/Checkbox.md +135 -0
- package/dist/agent-docs/components/CircularProgress.md +49 -0
- package/dist/agent-docs/components/CodeHighlighter.md +31 -0
- package/dist/agent-docs/components/Collapsible.md +95 -0
- package/dist/agent-docs/components/Command.md +142 -0
- package/dist/agent-docs/components/Confirmer.md +175 -0
- package/dist/agent-docs/components/ContextMenu.md +191 -0
- package/dist/agent-docs/components/CopyButton.md +26 -0
- package/dist/agent-docs/components/DataCrossTable.md +94 -0
- package/dist/agent-docs/components/DataTable.md +254 -0
- package/dist/agent-docs/components/DatePicker.md +109 -0
- package/dist/agent-docs/components/Dialog.md +125 -0
- package/dist/agent-docs/components/Drawer.md +127 -0
- package/dist/agent-docs/components/DropdownMenu.md +57 -0
- package/dist/agent-docs/components/FilePreview.md +99 -0
- package/dist/agent-docs/components/FilePreviewer.md +139 -0
- package/dist/agent-docs/components/FileUploader.md +129 -0
- package/dist/agent-docs/components/Form.md +62 -0
- package/dist/agent-docs/components/FormComposer.md +137 -0
- package/dist/agent-docs/components/GanttChart.md +122 -0
- package/dist/agent-docs/components/HoverCard.md +37 -0
- package/dist/agent-docs/components/Icon.md +99 -0
- package/dist/agent-docs/components/Input.md +138 -0
- package/dist/agent-docs/components/InputOtp.md +40 -0
- package/dist/agent-docs/components/InputSelector.md +97 -0
- package/dist/agent-docs/components/InterruptPrompt.md +32 -0
- package/dist/agent-docs/components/Label.md +28 -0
- package/dist/agent-docs/components/MarkdownRenderer.md +36 -0
- package/dist/agent-docs/components/Menubar.md +164 -0
- package/dist/agent-docs/components/MessageInput.md +131 -0
- package/dist/agent-docs/components/MessageList.md +96 -0
- package/dist/agent-docs/components/MultipleSelector.md +146 -0
- package/dist/agent-docs/components/NavigationMenu.md +51 -0
- package/dist/agent-docs/components/Pagination.md +55 -0
- package/dist/agent-docs/components/Popover.md +103 -0
- package/dist/agent-docs/components/Progress.md +30 -0
- package/dist/agent-docs/components/PromptSuggestions.md +33 -0
- package/dist/agent-docs/components/RadioGroup.md +90 -0
- package/dist/agent-docs/components/Resizable.md +35 -0
- package/dist/agent-docs/components/ResizePrompt.md +13 -0
- package/dist/agent-docs/components/ScrollArea.md +49 -0
- package/dist/agent-docs/components/SecurePdfViewer.md +38 -0
- package/dist/agent-docs/components/Select.md +132 -0
- package/dist/agent-docs/components/Separator.md +32 -0
- package/dist/agent-docs/components/Sheet.md +40 -0
- package/dist/agent-docs/components/ShikiHighlighter.md +31 -0
- package/dist/agent-docs/components/Sidebar.md +85 -0
- package/dist/agent-docs/components/Skeleton.md +29 -0
- package/dist/agent-docs/components/Slider.md +58 -0
- package/dist/agent-docs/components/Sonner.md +21 -0
- package/dist/agent-docs/components/Spinner.md +139 -0
- package/dist/agent-docs/components/Stepper.md +67 -0
- package/dist/agent-docs/components/Switch.md +42 -0
- package/dist/agent-docs/components/Table.md +63 -0
- package/dist/agent-docs/components/TableSkeleton.md +46 -0
- package/dist/agent-docs/components/Tabs.md +86 -0
- package/dist/agent-docs/components/TextArea.md +52 -0
- package/dist/agent-docs/components/ThemeSwitcher.md +69 -0
- package/dist/agent-docs/components/Toaster.md +23 -0
- package/dist/agent-docs/components/Toggle.md +31 -0
- package/dist/agent-docs/components/ToggleGroup.md +30 -0
- package/dist/agent-docs/components/Tooltip.md +91 -0
- package/dist/agent-docs/components/TypingIndicator.md +21 -0
- package/dist/agent-docs/components/Typo.md +65 -0
- package/dist/agent-docs/components/WeeklyCalendar.md +64 -0
- package/dist/agent-docs/components-list.md +144 -0
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/package.json +3 -2
package/dist/_virtual/index4.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getDefaultExportFromCjs as
|
|
3
|
-
import { __require as
|
|
4
|
-
var t =
|
|
5
|
-
const
|
|
2
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
|
|
4
|
+
var t = e();
|
|
5
|
+
const a = /* @__PURE__ */ r(t);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
a as default
|
|
8
8
|
};
|
package/dist/_virtual/index5.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getDefaultExportFromCjs as
|
|
3
|
-
import { __require as
|
|
4
|
-
var t =
|
|
5
|
-
const
|
|
2
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as r } from "../node_modules/extend/index.js";
|
|
4
|
+
var t = r();
|
|
5
|
+
const x = /* @__PURE__ */ e(t);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
x as default
|
|
8
8
|
};
|
package/dist/_virtual/index6.js
CHANGED
package/dist/_virtual/index7.js
CHANGED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
An accessible, animated accordion to organize content in collapsible sections. Supports single or multiple open items, keyboard navigation, and flexible styling.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
Props are passed through to the underlying Radix Accordion primitives. The most relevant props for `Accordion` (root) are listed below.
|
|
12
|
+
|
|
13
|
+
### Accordion (Root)
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Description |
|
|
16
|
+
| --------------- | ----------------------------------- | ----------- | --------------------------------------------------------------------------- |
|
|
17
|
+
| `type` | `"single" \| "multiple"` | `"single"` | Single allows one item open at a time. Multiple allows many open items. |
|
|
18
|
+
| `collapsible` | `boolean` | `false` | Only for `type="single"`. If true, allows closing the last open item. |
|
|
19
|
+
| `value` | `string \| string[]` | `undefined` | Controlled value of the open item(s). |
|
|
20
|
+
| `defaultValue` | `string \| string[]` | `undefined` | Uncontrolled default open item(s). |
|
|
21
|
+
| `onValueChange` | `(value: string \| string[]) => any` | `undefined` | Callback fired when open item(s) change. |
|
|
22
|
+
| `className` | `string` | `""` | Additional classes applied to the root. |
|
|
23
|
+
|
|
24
|
+
### Subcomponents
|
|
25
|
+
|
|
26
|
+
- `AccordionItem`: Container for a single section. Requires a unique `value` prop.
|
|
27
|
+
- `AccordionTrigger`: The clickable header that toggles the item.
|
|
28
|
+
- `AccordionContent`: The collapsible content area with open/close animations.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Behavior
|
|
33
|
+
|
|
34
|
+
- **Single mode**: Only one `AccordionItem` can be open at a time. If `collapsible` is `false`, one item must remain open.
|
|
35
|
+
- **Multiple mode**: Any number of items can be open simultaneously.
|
|
36
|
+
- **Keyboard navigation**: Fully accessible trigger buttons with ARIA attributes.
|
|
37
|
+
- **Animations**: Smooth open/close transitions for content.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
### Basic (Single)
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "laif-ds";
|
|
47
|
+
|
|
48
|
+
export function BasicAccordion() {
|
|
49
|
+
return (
|
|
50
|
+
<Accordion type="single" className="w-96">
|
|
51
|
+
<AccordionItem value="item-1">
|
|
52
|
+
<AccordionTrigger>Is it accessible?</AccordionTrigger>
|
|
53
|
+
<AccordionContent>
|
|
54
|
+
Yes. It adheres to the WAI-ARIA design pattern.
|
|
55
|
+
</AccordionContent>
|
|
56
|
+
</AccordionItem>
|
|
57
|
+
<AccordionItem value="item-2">
|
|
58
|
+
<AccordionTrigger>Is it styled?</AccordionTrigger>
|
|
59
|
+
<AccordionContent>
|
|
60
|
+
Yes. It comes with default styles that match the other components.
|
|
61
|
+
</AccordionContent>
|
|
62
|
+
</AccordionItem>
|
|
63
|
+
<AccordionItem value="item-3">
|
|
64
|
+
<AccordionTrigger>Is it animated?</AccordionTrigger>
|
|
65
|
+
<AccordionContent>
|
|
66
|
+
Yes. It's animated by default, but you can disable it if you prefer.
|
|
67
|
+
</AccordionContent>
|
|
68
|
+
</AccordionItem>
|
|
69
|
+
</Accordion>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### With Default Open (Single, collapsible)
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "laif-ds";
|
|
78
|
+
|
|
79
|
+
export function AccordionWithDefaultOpen() {
|
|
80
|
+
return (
|
|
81
|
+
<Accordion type="single" collapsible defaultValue="item-2" className="w-96">
|
|
82
|
+
<AccordionItem value="item-1">
|
|
83
|
+
<AccordionTrigger>First section</AccordionTrigger>
|
|
84
|
+
<AccordionContent>This is the first section content.</AccordionContent>
|
|
85
|
+
</AccordionItem>
|
|
86
|
+
<AccordionItem value="item-2">
|
|
87
|
+
<AccordionTrigger>Second section (default open)</AccordionTrigger>
|
|
88
|
+
<AccordionContent>
|
|
89
|
+
This section is open by default because we set defaultValue="item-2".
|
|
90
|
+
</AccordionContent>
|
|
91
|
+
</AccordionItem>
|
|
92
|
+
<AccordionItem value="item-3">
|
|
93
|
+
<AccordionTrigger>Third section</AccordionTrigger>
|
|
94
|
+
<AccordionContent>This is the third section content.</AccordionContent>
|
|
95
|
+
</AccordionItem>
|
|
96
|
+
</Accordion>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Multiple Mode with Multiple Default Open
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "laif-ds";
|
|
105
|
+
|
|
106
|
+
export function MultipleModeAccordion() {
|
|
107
|
+
return (
|
|
108
|
+
<Accordion type="multiple" defaultValue={["item-1", "item-3"]} className="w-96">
|
|
109
|
+
<AccordionItem value="item-1">
|
|
110
|
+
<AccordionTrigger>First section (default open)</AccordionTrigger>
|
|
111
|
+
<AccordionContent>This section is open by default.</AccordionContent>
|
|
112
|
+
</AccordionItem>
|
|
113
|
+
<AccordionItem value="item-2">
|
|
114
|
+
<AccordionTrigger>Second section</AccordionTrigger>
|
|
115
|
+
<AccordionContent>This section is closed by default.</AccordionContent>
|
|
116
|
+
</AccordionItem>
|
|
117
|
+
<AccordionItem value="item-3">
|
|
118
|
+
<AccordionTrigger>Third section (default open)</AccordionTrigger>
|
|
119
|
+
<AccordionContent>This section is also open by default.</AccordionContent>
|
|
120
|
+
</AccordionItem>
|
|
121
|
+
</Accordion>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Controlled Single Mode
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { useState } from "react";
|
|
130
|
+
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "laif-ds";
|
|
131
|
+
|
|
132
|
+
export function ControlledAccordion() {
|
|
133
|
+
const [open, setOpen] = useState<string>("item-1");
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Accordion type="single" value={open} onValueChange={(v) => setOpen(v as string)} className="w-96">
|
|
137
|
+
<AccordionItem value="item-1">
|
|
138
|
+
<AccordionTrigger>First</AccordionTrigger>
|
|
139
|
+
<AccordionContent>First content</AccordionContent>
|
|
140
|
+
</AccordionItem>
|
|
141
|
+
<AccordionItem value="item-2">
|
|
142
|
+
<AccordionTrigger>Second</AccordionTrigger>
|
|
143
|
+
<AccordionContent>Second content</AccordionContent>
|
|
144
|
+
</AccordionItem>
|
|
145
|
+
</Accordion>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Notes
|
|
153
|
+
|
|
154
|
+
- **Accessibility**: Uses proper ARIA roles/attributes and keyboard navigation.
|
|
155
|
+
- **Animations**: `AccordionContent` has built-in open/close animations.
|
|
156
|
+
- **Styling**: Customize with `className` on root/items/triggers/contents.
|
|
157
|
+
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Alert
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A simple, accessible alert component with title and description. Supports variants for information and destructive/error states.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### Alert (Root)
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| ----------- | -------------------------------------- | ----------- | ---------------------------------------------- |
|
|
15
|
+
| `variant` | `"default" | "destructive"` | `"default"` | Visual style of the alert. |
|
|
16
|
+
| `className` | `string` | `""` | Additional classes applied to the root element.|
|
|
17
|
+
| `children` | `React.ReactNode` | **required**| Content of the alert (title/description/icon). |
|
|
18
|
+
|
|
19
|
+
### Subcomponents
|
|
20
|
+
|
|
21
|
+
- `AlertTitle`: Title area of the alert (bold line).
|
|
22
|
+
- `AlertDescription`: Secondary text, supports rich content and paragraphs.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Behavior
|
|
27
|
+
|
|
28
|
+
- **Accessible**: Uses `role="alert"` and semantic slots for screen readers.
|
|
29
|
+
- **Variants**: `destructive` applies error coloring; `default` uses neutral styling.
|
|
30
|
+
- **Layout**: Supports optional leading icon; layout adapts when an icon is present.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Default
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Alert, AlertTitle, AlertDescription } from "laif-ds";
|
|
40
|
+
|
|
41
|
+
export function DefaultAlert() {
|
|
42
|
+
return (
|
|
43
|
+
<Alert>
|
|
44
|
+
<AlertTitle>Default Alert</AlertTitle>
|
|
45
|
+
<AlertDescription>
|
|
46
|
+
This is a default alert message.
|
|
47
|
+
</AlertDescription>
|
|
48
|
+
</Alert>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### With Icon
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Alert, AlertTitle, AlertDescription, Icon } from "laif-ds";
|
|
57
|
+
|
|
58
|
+
export function AlertWithIcon() {
|
|
59
|
+
return (
|
|
60
|
+
<Alert>
|
|
61
|
+
<Icon name="Info" />
|
|
62
|
+
<AlertTitle>Information</AlertTitle>
|
|
63
|
+
<AlertDescription>
|
|
64
|
+
This alert includes an icon.
|
|
65
|
+
</AlertDescription>
|
|
66
|
+
</Alert>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Destructive
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
import { Alert, AlertTitle, AlertDescription } from "laif-ds";
|
|
75
|
+
|
|
76
|
+
export function DestructiveAlert() {
|
|
77
|
+
return (
|
|
78
|
+
<Alert variant="destructive">
|
|
79
|
+
<AlertTitle>Error</AlertTitle>
|
|
80
|
+
<AlertDescription>
|
|
81
|
+
Something went wrong. Please try again.
|
|
82
|
+
</AlertDescription>
|
|
83
|
+
</Alert>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Notes
|
|
91
|
+
|
|
92
|
+
- **Styling**: Use `className` on the root to add layout constraints (e.g., width).
|
|
93
|
+
- **Content**: `AlertDescription` supports rich content and multi-line paragraphs.
|
|
94
|
+
- **Icons**: Use `Icon` from `laif-ds` to add an optional leading icon.
|
|
95
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# AlertDialog
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Accessible modal dialog for critical confirmations. Built on Radix Alert Dialog primitives with composable subcomponents and focus management.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### AlertDialog (Root)
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| --------------- | ----------------- | ----------- | -------------------------------------------- |
|
|
15
|
+
| `open` | `boolean` | `undefined` | Controlled open state. |
|
|
16
|
+
| `defaultOpen` | `boolean` | `false` | Uncontrolled initial open state. |
|
|
17
|
+
| `onOpenChange` | `(open: boolean) => void` | `undefined` | Callback when open state changes. |
|
|
18
|
+
|
|
19
|
+
### Subcomponents
|
|
20
|
+
|
|
21
|
+
- `AlertDialogTrigger`: Element that opens the dialog (can be `asChild`).
|
|
22
|
+
- `AlertDialogContent`: The dialog content container.
|
|
23
|
+
- `AlertDialogHeader` / `AlertDialogFooter`: Layout sections for content and actions.
|
|
24
|
+
- `AlertDialogTitle` / `AlertDialogDescription`: Title and supporting description.
|
|
25
|
+
- `AlertDialogAction`: Primary action button.
|
|
26
|
+
- `AlertDialogCancel`: Secondary cancel button.
|
|
27
|
+
- `AlertDialogPortal`, `AlertDialogOverlay`: Portal and overlay elements.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Behavior
|
|
32
|
+
|
|
33
|
+
- **Focus management**: Traps focus within the dialog, returns focus on close.
|
|
34
|
+
- **Accessibility**: Proper ARIA roles and keyboard interactions (Esc to close).
|
|
35
|
+
- **Composability**: Use any button (e.g., `Button`) with `AlertDialogTrigger asChild`.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
### Basic
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {
|
|
45
|
+
AlertDialog,
|
|
46
|
+
AlertDialogAction,
|
|
47
|
+
AlertDialogCancel,
|
|
48
|
+
AlertDialogContent,
|
|
49
|
+
AlertDialogDescription,
|
|
50
|
+
AlertDialogFooter,
|
|
51
|
+
AlertDialogHeader,
|
|
52
|
+
AlertDialogTitle,
|
|
53
|
+
AlertDialogTrigger,
|
|
54
|
+
} from "laif-ds";
|
|
55
|
+
import { Button } from "laif-ds";
|
|
56
|
+
|
|
57
|
+
export function BasicAlertDialog() {
|
|
58
|
+
return (
|
|
59
|
+
<AlertDialog>
|
|
60
|
+
<AlertDialogTrigger asChild>
|
|
61
|
+
<Button variant="outline">Show Alert Dialog</Button>
|
|
62
|
+
</AlertDialogTrigger>
|
|
63
|
+
<AlertDialogContent>
|
|
64
|
+
<AlertDialogHeader>
|
|
65
|
+
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
|
66
|
+
<AlertDialogDescription>
|
|
67
|
+
This action cannot be undone. This will permanently delete your account and remove your data from our servers.
|
|
68
|
+
</AlertDialogDescription>
|
|
69
|
+
</AlertDialogHeader>
|
|
70
|
+
<AlertDialogFooter>
|
|
71
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
72
|
+
<AlertDialogAction>Continue</AlertDialogAction>
|
|
73
|
+
</AlertDialogFooter>
|
|
74
|
+
</AlertDialogContent>
|
|
75
|
+
</AlertDialog>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Controlled
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { useState } from "react";
|
|
84
|
+
import {
|
|
85
|
+
AlertDialog,
|
|
86
|
+
AlertDialogAction,
|
|
87
|
+
AlertDialogCancel,
|
|
88
|
+
AlertDialogContent,
|
|
89
|
+
AlertDialogDescription,
|
|
90
|
+
AlertDialogFooter,
|
|
91
|
+
AlertDialogHeader,
|
|
92
|
+
AlertDialogTitle,
|
|
93
|
+
} from "laif-ds";
|
|
94
|
+
import { Button } from "laif-ds";
|
|
95
|
+
|
|
96
|
+
export function ControlledAlertDialog() {
|
|
97
|
+
const [open, setOpen] = useState(false);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<>
|
|
101
|
+
<Button onClick={() => setOpen(true)}>Open dialog</Button>
|
|
102
|
+
<AlertDialog open={open} onOpenChange={setOpen}>
|
|
103
|
+
<AlertDialogContent>
|
|
104
|
+
<AlertDialogHeader>
|
|
105
|
+
<AlertDialogTitle>Confirm action</AlertDialogTitle>
|
|
106
|
+
<AlertDialogDescription>Are you sure you want to proceed?</AlertDialogDescription>
|
|
107
|
+
</AlertDialogHeader>
|
|
108
|
+
<AlertDialogFooter>
|
|
109
|
+
<AlertDialogCancel onClick={() => setOpen(false)}>Cancel</AlertDialogCancel>
|
|
110
|
+
<AlertDialogAction onClick={() => setOpen(false)}>Confirm</AlertDialogAction>
|
|
111
|
+
</AlertDialogFooter>
|
|
112
|
+
</AlertDialogContent>
|
|
113
|
+
</AlertDialog>
|
|
114
|
+
</>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Notes
|
|
122
|
+
|
|
123
|
+
- **Styling**: `AlertDialogContent` is centered and responsive; customize with `className`.
|
|
124
|
+
- **Overlay**: `AlertDialogOverlay` provides a backdrop with fade animations.
|
|
125
|
+
- **Buttons**: `AlertDialogAction` uses default button styles; pass `className` to adjust.
|
|
126
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# AppEditor
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Rich text editor powered by Lexical with optional Markdown sync. Supports configurable toolbars (block format, font format, history), clear action, and character counter.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
| --------------- | ------------------------------------ | --------- | ----------- |
|
|
13
|
+
| `defaultValue` | `string` | `undefined` | Initial content. Interpreted as Markdown when `onlyMarkdown=true`, plain text otherwise. |
|
|
14
|
+
| `onMarkdownEdit`| `(markdown: string) => void` | `undefined` | Emits current content as Markdown on change. |
|
|
15
|
+
| `plugins` | `("clear" | "counter")[]` | `[]` | Enable optional plugins: clear buttons, character counter. |
|
|
16
|
+
| `toolbars` | `("block-format" | "font-format" | "history")[]` | `[]` | Enable toolbar groups. |
|
|
17
|
+
| `placeholder` | `string` | `"Start typing..."` | Placeholder for empty editor. |
|
|
18
|
+
| `onlyMarkdown` | `boolean` | `true` | Treat `defaultValue` as Markdown and sync editor to Markdown. If `false`, `defaultValue` is plain text. |
|
|
19
|
+
| `className` | `string` | `"overflow-hidden rounded-lg border border-d-border"` | Extra classes for the content editable. |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Behavior
|
|
24
|
+
|
|
25
|
+
- **Markdown sync**: When `onlyMarkdown=true`, initializes from Markdown and emits Markdown on every change.
|
|
26
|
+
- **Toolbars**:
|
|
27
|
+
- `history`: undo/redo toolbar.
|
|
28
|
+
- `block-format`: heading levels, list types, quote.
|
|
29
|
+
- `font-format`: bold/italic/underline/strikethrough.
|
|
30
|
+
- **Plugins**:
|
|
31
|
+
- `clear`: clear actions in the footer.
|
|
32
|
+
- `counter`: UTF-16 character counter in the footer.
|
|
33
|
+
- **Editing**: Autosave via `onMarkdownEdit`. Keyboard navigation and selection per Lexical defaults.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
### Full Toolbar + Plugins
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import * as React from "react";
|
|
43
|
+
import { AppEditor } from "laif-ds";
|
|
44
|
+
|
|
45
|
+
export function EditorFull() {
|
|
46
|
+
const [markdown, setMarkdown] = React.useState("Hello world");
|
|
47
|
+
return (
|
|
48
|
+
<div className="space-y-4">
|
|
49
|
+
<AppEditor
|
|
50
|
+
defaultValue={markdown}
|
|
51
|
+
onMarkdownEdit={setMarkdown}
|
|
52
|
+
toolbars={["block-format", "font-format", "history"]}
|
|
53
|
+
plugins={["clear", "counter"]}
|
|
54
|
+
className="h-96"
|
|
55
|
+
/>
|
|
56
|
+
<div className="text-d-muted-foreground text-sm">
|
|
57
|
+
<span className="font-medium">Current markdown:</span> {markdown || "(empty)"}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Markdown Default Value
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import * as React from "react";
|
|
68
|
+
import { AppEditor } from "laif-ds";
|
|
69
|
+
|
|
70
|
+
export function MarkdownDefault() {
|
|
71
|
+
const initial = "**Titolo** con testo in markdown";
|
|
72
|
+
const [md, setMd] = React.useState(initial);
|
|
73
|
+
return (
|
|
74
|
+
<AppEditor
|
|
75
|
+
defaultValue={initial}
|
|
76
|
+
onMarkdownEdit={setMd}
|
|
77
|
+
toolbars={["block-format", "font-format", "history"]}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Notes
|
|
86
|
+
|
|
87
|
+
- **Sizing**: Control height via `className` (e.g., `h-96`).
|
|
88
|
+
- **Performance**: Prefer Markdown mode for content pipelines that store Markdown; use `onlyMarkdown=false` for plain text initialization.
|
|
89
|
+
- **Accessibility**: Toolbar buttons and editor area follow Lexical best practices.
|
|
90
|
+
|