laif-ds 0.2.74 → 0.2.76
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/CHANGELOG.md +446 -0
- package/dist/agent-docs/adoption-report.json +615 -0
- package/dist/agent-docs/components/Accordion.md +46 -16
- package/dist/agent-docs/components/Alert.md +90 -95
- package/dist/agent-docs/components/AlertDialog.md +132 -126
- package/dist/agent-docs/components/AppEditor.md +90 -90
- package/dist/agent-docs/components/AppRadioGroup.md +18 -18
- package/dist/agent-docs/components/AppSidebar.md +129 -122
- package/dist/agent-docs/components/AppStepper.md +81 -77
- package/dist/agent-docs/components/AspectRatio.md +70 -62
- package/dist/agent-docs/components/AudioVisualizer.md +5 -5
- package/dist/agent-docs/components/Avatar.md +112 -113
- package/dist/agent-docs/components/Badge.md +123 -118
- package/dist/agent-docs/components/Breadcrumb.md +8 -1
- package/dist/agent-docs/components/Button.md +131 -129
- package/dist/agent-docs/components/Card.md +172 -147
- package/dist/agent-docs/components/Carousel.md +148 -129
- package/dist/agent-docs/components/Chat.md +121 -109
- package/dist/agent-docs/components/ChatMessage.md +72 -61
- package/dist/agent-docs/components/Checkbox.md +150 -135
- package/dist/agent-docs/components/CircularProgress.md +53 -49
- package/dist/agent-docs/components/CodeHighlighter.md +4 -4
- package/dist/agent-docs/components/Collapsible.md +114 -95
- package/dist/agent-docs/components/Command.md +141 -142
- package/dist/agent-docs/components/Confirmer.md +182 -175
- package/dist/agent-docs/components/ContextMenu.md +196 -191
- package/dist/agent-docs/components/DataCrossTable.md +114 -94
- package/dist/agent-docs/components/DataTable.md +32 -24
- package/dist/agent-docs/components/Dialog.md +130 -125
- package/dist/agent-docs/components/Drawer.md +141 -127
- package/dist/agent-docs/components/FilePreviewer.md +138 -139
- package/dist/agent-docs/components/FileUploader.md +149 -129
- package/dist/agent-docs/components/Form.md +3 -1
- package/dist/agent-docs/components/FormComposer.md +163 -137
- package/dist/agent-docs/components/GanttChart.md +125 -122
- package/dist/agent-docs/components/HoverCard.md +1 -1
- package/dist/agent-docs/components/Icon.md +98 -99
- package/dist/agent-docs/components/Input.md +173 -138
- package/dist/agent-docs/components/InputOtp.md +6 -1
- package/dist/agent-docs/components/InputSelector.md +94 -97
- package/dist/agent-docs/components/InterruptPrompt.md +4 -4
- package/dist/agent-docs/components/MarkdownRenderer.md +5 -2
- package/dist/agent-docs/components/Menubar.md +60 -57
- package/dist/agent-docs/components/MessageInput.md +134 -131
- package/dist/agent-docs/components/MessageList.md +110 -96
- package/dist/agent-docs/components/MultipleSelector.md +147 -146
- package/dist/agent-docs/components/NavigationMenu.md +6 -2
- package/dist/agent-docs/components/Popover.md +112 -103
- package/dist/agent-docs/components/PromptSuggestions.md +5 -5
- package/dist/agent-docs/components/RadioGroup.md +97 -90
- package/dist/agent-docs/components/Resizable.md +4 -1
- package/dist/agent-docs/components/ResizePrompt.md +12 -13
- package/dist/agent-docs/components/ScrollArea.md +6 -2
- package/dist/agent-docs/components/SecurePdfViewer.md +10 -6
- package/dist/agent-docs/components/Select.md +131 -132
- package/dist/agent-docs/components/Sheet.md +8 -1
- package/dist/agent-docs/components/ShikiHighlighter.md +5 -5
- package/dist/agent-docs/components/Sidebar.md +94 -85
- package/dist/agent-docs/components/Slider.md +62 -58
- package/dist/agent-docs/components/Sonner.md +1 -0
- package/dist/agent-docs/components/Spinner.md +14 -14
- package/dist/agent-docs/components/Stepper.md +93 -67
- package/dist/agent-docs/components/Switch.md +41 -42
- package/dist/agent-docs/components/TableSkeleton.md +8 -8
- package/dist/agent-docs/components/Tabs.md +106 -86
- package/dist/agent-docs/components/TextArea.md +51 -52
- package/dist/agent-docs/components/ThemeSwitcher.md +72 -69
- package/dist/agent-docs/components/Toaster.md +1 -0
- package/dist/agent-docs/components/Tooltip.md +102 -91
- package/dist/agent-docs/components/Typo.md +68 -65
- package/dist/agent-docs/components/WeeklyCalendar.md +63 -64
- package/dist/agent-docs/components-list.md +1 -0
- package/dist/agent-docs/manifest.json +5981 -0
- package/dist/agent-docs/truncated-cell.md +342 -0
- package/dist/components/editor/editor-hooks/use-update-toolbar.js +6 -6
- package/dist/components/editor/plugins/actions/counter-character-plugin.js +6 -6
- package/dist/components/editor/plugins/toolbar/font-format-toolbar-plugin.js +18 -18
- package/dist/components/editor/plugins/toolbar/history-toolbar-plugin.js +10 -10
- package/dist/components/editor/plugins/toolbar/toolbar-plugin.js +9 -9
- package/dist/components/ui/app-checkbox.js +1 -1
- package/dist/components/ui/app-dialog.js +70 -64
- package/dist/components/ui/app-editor.js +51 -51
- package/dist/components/ui/app-form.js +81 -81
- package/dist/components/ui/app-multiple-select-dropdown.js +36 -36
- package/dist/components/ui/app-select.js +109 -104
- package/dist/components/ui/app-sidebar.js +41 -41
- package/dist/components/ui/app-stepper.js +1 -1
- package/dist/components/ui/app-time-picker.js +18 -18
- package/dist/components/ui/app-tooltip.js +1 -1
- package/dist/components/ui/async-select.js +5 -5
- package/dist/components/ui/audio-visualizer.js +61 -58
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/carousel.js +2 -2
- package/dist/components/ui/chart.js +1 -1
- package/dist/components/ui/chat-message.js +8 -8
- package/dist/components/ui/chat.js +86 -88
- package/dist/components/ui/command.js +2 -2
- package/dist/components/ui/copy-button.js +4 -4
- package/dist/components/ui/date-picker.js +20 -20
- package/dist/components/ui/file-preview/index.js +13 -13
- package/dist/components/ui/file-previewer.js +12 -11
- package/dist/components/ui/file-uploader.js +86 -78
- package/dist/components/ui/form.js +2 -2
- package/dist/components/ui/gantt/components/Chart/Bars/Bars.js +56 -56
- package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarItem/BarItem.js +12 -12
- package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarsItems/BarItems.js +1 -1
- package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/BarsRow.js +4 -4
- package/dist/components/ui/gantt/components/Chart/Bars/BarsRow/RepeteadBars/RepeteadBars.js +2 -2
- package/dist/components/ui/gantt/components/Chart/Chart.js +23 -23
- package/dist/components/ui/gantt/components/Chart/Scale/Scale.js +1 -1
- package/dist/components/ui/gantt/components/Chart/Tree/Tree.js +34 -34
- package/dist/components/ui/gantt/components/Controls/Controls.js +5 -5
- package/dist/components/ui/gantt/components/Gantt/Gantt.js +4 -4
- package/dist/components/ui/gantt/hooks/useGanttCalculate.js +25 -18
- package/dist/components/ui/input-selector.js +1 -1
- package/dist/components/ui/input.js +23 -23
- package/dist/components/ui/kanban.js +8 -9
- package/dist/components/ui/markdown-renderer.js +41 -35
- package/dist/components/ui/message-input.js +45 -44
- package/dist/components/ui/multiple-selector.js +91 -82
- package/dist/components/ui/secure-pdf-viewer.js +19 -7
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/slider.js +1 -1
- package/dist/components/ui/spinner.js +4 -4
- package/dist/components/ui/stepper.js +157 -138
- package/dist/components/ui/tables/data-cross-table/data-cross-table-buttons.js +29 -29
- package/dist/components/ui/tables/data-cross-table/data-cross-table.js +258 -246
- package/dist/components/ui/tables/data-table/components/data-table-advanced-filter.js +4 -1
- package/dist/components/ui/tables/data-table/components/data-table-body.js +211 -367
- package/dist/components/ui/tables/data-table/components/data-table-filter-inputs.js +114 -112
- package/dist/components/ui/tables/data-table/components/data-table-filters.js +116 -96
- package/dist/components/ui/tables/data-table/components/data-table-header.js +211 -0
- package/dist/components/ui/tables/data-table/components/data-table-searchbar.js +8 -8
- package/dist/components/ui/tables/data-table/components/data-table-skeleton-rows.js +33 -0
- package/dist/components/ui/tables/data-table/data-table.js +258 -250
- package/dist/components/ui/tables/data-table/data-table.service.js +112 -97
- package/dist/components/ui/tables/data-table/data-table.utils.js +25 -15
- package/dist/components/ui/textarea.js +2 -2
- package/dist/components/ui/theme-switcher.js +1 -1
- package/dist/components/ui/toggle-group.js +2 -2
- package/dist/components/ui/truncated-cell.js +100 -0
- package/dist/components/ui/weekly-calendar/appointment-card.js +16 -16
- package/dist/components/ui/weekly-calendar/calendar-context.js +6 -6
- package/dist/components/ui/weekly-calendar/calendar-header.js +12 -12
- package/dist/components/ui/weekly-calendar/day-column.js +16 -16
- package/dist/components/ui/weekly-calendar/time-column.js +4 -4
- package/dist/components/ui/weekly-calendar/weekly-calendar.js +4 -4
- package/dist/hooks/use-audio-recording.js +1 -1
- package/dist/hooks/use-auto-scroll.js +18 -18
- package/dist/hooks/use-autosize-textarea.js +12 -13
- package/dist/index.d.ts +100 -45
- package/dist/index.js +362 -360
- package/dist/lib/utils.js +6 -6
- package/dist/styles.v3.css +1 -1
- package/package.json +14 -4
|
@@ -8,26 +8,31 @@ Powerful table built on TanStack Table v8. Supports client-side and server-side
|
|
|
8
8
|
|
|
9
9
|
## Props
|
|
10
10
|
|
|
11
|
-
| Prop
|
|
12
|
-
|
|
|
13
|
-
| `columns`
|
|
14
|
-
| `data`
|
|
15
|
-
| `loading`
|
|
16
|
-
| `emptyComponent`
|
|
17
|
-
| `className`
|
|
18
|
-
| `checkable`
|
|
19
|
-
| `rowSelection`
|
|
20
|
-
| `onRowSelectionChange`
|
|
21
|
-
| `onCheckedRowsChange`
|
|
22
|
-
| `actions`
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
| ----------------------- | ------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------- |
|
|
13
|
+
| `columns` | `ColumnDef<TData, TValue>[]` | — | TanStack column definitions. Use `meta` to enable features. |
|
|
14
|
+
| `data` | `TData[]` | — | Table data. |
|
|
15
|
+
| `loading` | `boolean` | `false` | Show skeleton rows. |
|
|
16
|
+
| `emptyComponent` | `ReactNode` | `undefined` | Rendered when no rows. |
|
|
17
|
+
| `className` | `string` | `undefined` | Wrapper classes. |
|
|
18
|
+
| `checkable` | `boolean` | `false` | Adds a left checkbox column for row selection. |
|
|
19
|
+
| `rowSelection` | `Record<string, boolean>` | `{}` | Controlled selection map. |
|
|
20
|
+
| `onRowSelectionChange` | `OnChangeFn<Record<string, boolean>>` | `undefined` | Selection change handler (controlled selection). |
|
|
21
|
+
| `onCheckedRowsChange` | `(checkedRows: TData[]) => void` | `undefined` | Returns selected row values (requires `checkable`). |
|
|
22
|
+
| `actions` | `DataTableActions[]` | `[]` | Actions for the actions row. |
|
|
23
|
+
| `customComponentsLeft` | `ReactNode` | `undefined` | Custom components rendered on the left of the actions row. |
|
|
24
|
+
| `customComponentsRight` | `ReactNode` | `undefined` | Custom components rendered on the right of the actions row. |
|
|
25
|
+
| `hidePagination` | `boolean` | `false` | Hide pagination UI. |
|
|
26
|
+
| `hideActionsRow` | `boolean` | `false` | Hide actions row. |
|
|
27
|
+
| `i18n` | `DataTableI18n` | `defaultDataTableI18n` | Internationalization strings (sorting/filtering popovers included). |
|
|
28
|
+
| `maxSortedColumns` | `number` | `2` | Max number of sorted columns. |
|
|
29
|
+
| `initialState` | `DataTableState<TData>` | `undefined` | Initial filters, sorting, pagination, optional `columnVisibility`, and searchbar value. |
|
|
30
|
+
| `serverMode` | `boolean` | `false` | Enable server-side mode (client-side filtering/sorting when `false`). |
|
|
31
|
+
| `serverConfig` | `DataTableServerConfig` | `undefined` | `{ totalItems, onStateChange, serverDebounceTime? }` handler for server mode. |
|
|
32
|
+
| `disableAutoPageSize` | `boolean` | `false` | Disable auto pageSize (still updates pageIndex). |
|
|
33
|
+
| `id` | `string` | `undefined` | Test/accessibility hook for the root element. |
|
|
34
|
+
| `data-testid` | `string` | `undefined` | Test identifier forwarded to the root element. |
|
|
35
|
+
| `rowClassName` | `string \| ((row) => string)` | `undefined` | Add custom CSS classes to table rows based on row data or state. |
|
|
31
36
|
|
|
32
37
|
---
|
|
33
38
|
|
|
@@ -52,6 +57,8 @@ type ColumnMeta = {
|
|
|
52
57
|
searchable?: boolean;
|
|
53
58
|
pinned?: "left" | "right";
|
|
54
59
|
listOptions?: { value: string; label: string }[];
|
|
60
|
+
cellClassName?: string | ((value: any, row: TData) => string);
|
|
61
|
+
headerClassName?: string;
|
|
55
62
|
};
|
|
56
63
|
```
|
|
57
64
|
|
|
@@ -65,10 +72,10 @@ Notes:
|
|
|
65
72
|
|
|
66
73
|
## Behavior
|
|
67
74
|
|
|
68
|
-
- **Filtering**: Badge filters + advanced builder with logical `_and`/`_or`.
|
|
69
|
-
- **Global search**: Across `meta.searchable` columns; strings use `like`, arrays use `array_overlap` (mapped automatically).
|
|
75
|
+
- **Filtering**: Badge filters + advanced builder with logical `_and`/`_or`; client-side application when `serverMode=false`, state emission when `serverMode=true`.
|
|
76
|
+
- **Global search**: Across `meta.searchable` columns; strings use `like`, arrays use `array_overlap` (mapped automatically for list single select).
|
|
70
77
|
- **Operators**: Full operator set per type, including `eq_null`/`n_eq_null`, list operators (`array_overlap`, `n_array_overlap`), date/time before/after, checked/unchecked.
|
|
71
|
-
- **Sorting**: Multi-column (limited by `maxSortedColumns`).
|
|
78
|
+
- **Sorting**: Multi-column (limited by `maxSortedColumns`); client-side when `serverMode=false`, emitted to server otherwise.
|
|
72
79
|
- **Selection**: Integrated checkbox column when `checkable`.
|
|
73
80
|
- **Column visibility**: Columns can start hidden via `initialState.columnVisibility` and be toggled from the eye icon popover in the toolbar (supports drag-and-drop reordering).
|
|
74
81
|
- **Non-hideable columns**: Set `enableHiding: false` on a column to prevent it from being hidden.
|
|
@@ -94,7 +101,8 @@ type ServerState = {
|
|
|
94
101
|
};
|
|
95
102
|
```
|
|
96
103
|
|
|
97
|
-
|
|
104
|
+
- `computedFilter`/`computedSorting` are auto-generated from the UI and preserved across updates.
|
|
105
|
+
- Debounced emissions are configurable via `serverConfig.serverDebounceTime`.
|
|
98
106
|
|
|
99
107
|
---
|
|
100
108
|
|
|
@@ -1,125 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
| -------- |
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Accessible modal dialog built on Radix. Includes overlay, content with size variants, header/footer layout, title/description, trigger and close controls.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### Dialog (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` | Called when open state changes. |
|
|
18
|
+
| `modal` | `boolean` | `true` | Modal behavior (trap focus, background). |
|
|
19
|
+
|
|
20
|
+
### DialogContent
|
|
21
|
+
|
|
22
|
+
Additional prop:
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Default | Description |
|
|
25
|
+
| ----------- | -------- | --------- | --------------------------------- | ----- | ----------- | --------------------------------- |
|
|
26
|
+
| `size` | `"sm" | "default" | "lg" | "xl"` | `"default"` | Max-width preset for the content. |
|
|
27
|
+
| `className` | `string` | `""` | Additional classes for the panel. |
|
|
28
|
+
|
|
29
|
+
### Subcomponents
|
|
30
|
+
|
|
31
|
+
- `DialogTrigger`: Element that opens the dialog (supports `asChild`).
|
|
32
|
+
- `DialogPortal` / `DialogOverlay`: Portal root and backdrop.
|
|
33
|
+
- `DialogContent`: Centered panel with animations and close button.
|
|
34
|
+
- `DialogHeader` / `DialogFooter`: Layout helpers for content.
|
|
35
|
+
- `DialogTitle` / `DialogDescription`: Accessible title and description.
|
|
36
|
+
- `DialogClose`: Close button (already included inside `DialogContent`).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Behavior
|
|
41
|
+
|
|
42
|
+
- **Focus management**: Traps focus while open; returns on close.
|
|
43
|
+
- **Pointer outside exception**: Clicks inside elements marked `data-command-portal` are ignored to prevent unintended close.
|
|
44
|
+
- **Sizes**: `size` controls the max-width (`sm`, `default`, `lg`, `xl`).
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### Basic
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { Button } from "laif-ds";
|
|
54
|
+
import {
|
|
55
|
+
Dialog,
|
|
56
|
+
DialogTrigger,
|
|
57
|
+
DialogContent,
|
|
58
|
+
DialogHeader,
|
|
59
|
+
DialogTitle,
|
|
60
|
+
DialogDescription,
|
|
61
|
+
DialogFooter,
|
|
62
|
+
} from "laif-ds";
|
|
63
|
+
|
|
64
|
+
export function BasicDialog() {
|
|
65
|
+
return (
|
|
66
|
+
<Dialog>
|
|
67
|
+
<DialogTrigger asChild>
|
|
68
|
+
<Button variant="outline">Open Dialog</Button>
|
|
69
|
+
</DialogTrigger>
|
|
70
|
+
<DialogContent>
|
|
71
|
+
<DialogHeader>
|
|
72
|
+
<DialogTitle>Basic Dialog</DialogTitle>
|
|
73
|
+
<DialogDescription>
|
|
74
|
+
This is a basic dialog with title and description.
|
|
75
|
+
</DialogDescription>
|
|
76
|
+
</DialogHeader>
|
|
77
|
+
<div className="py-4">
|
|
78
|
+
<p className="text-d-secondary-foreground text-sm">
|
|
79
|
+
Dialog content goes here.
|
|
80
|
+
</p>
|
|
81
|
+
</div>
|
|
82
|
+
<DialogFooter>
|
|
83
|
+
<Button type="submit">Save changes</Button>
|
|
84
|
+
</DialogFooter>
|
|
85
|
+
</DialogContent>
|
|
86
|
+
</Dialog>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Size Variants
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { Button } from "laif-ds";
|
|
95
|
+
import {
|
|
96
|
+
Dialog,
|
|
97
|
+
DialogTrigger,
|
|
98
|
+
DialogContent,
|
|
99
|
+
DialogHeader,
|
|
100
|
+
DialogTitle,
|
|
101
|
+
} from "laif-ds";
|
|
102
|
+
|
|
103
|
+
export function SizeVariants() {
|
|
104
|
+
return (
|
|
105
|
+
<div className="flex flex-wrap gap-3">
|
|
106
|
+
{["sm", "default", "lg", "xl"].map((sz) => (
|
|
107
|
+
<Dialog key={sz as string}>
|
|
108
|
+
<DialogTrigger asChild>
|
|
109
|
+
<Button variant="outline">Open {String(sz)}</Button>
|
|
110
|
+
</DialogTrigger>
|
|
111
|
+
<DialogContent size={sz as any}>
|
|
112
|
+
<DialogHeader>
|
|
113
|
+
<DialogTitle>Size: {String(sz)}</DialogTitle>
|
|
114
|
+
</DialogHeader>
|
|
115
|
+
<div className="text-sm">Content for {String(sz)}</div>
|
|
116
|
+
</DialogContent>
|
|
117
|
+
</Dialog>
|
|
118
|
+
))}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Notes
|
|
127
|
+
|
|
128
|
+
- **Accessibility**: Use `DialogTitle` and `DialogDescription` for screen readers.
|
|
129
|
+
- **Styling**: Customize panel via `className` on `DialogContent`.
|
|
130
|
+
- **Closing**: A close button is rendered in the top-right of `DialogContent`.
|
|
@@ -1,127 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
# Drawer
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Sliding panel component (top/right/bottom/left) built on Vaul. Supports modal behavior, background scaling, snap points, and full keyboard accessibility.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
### Drawer (Root)
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| ----------------------- | ------------------------- | ----------- | ----------------------------------------------------------------- | ---------------------------------- | ---------- | ------------------------- |
|
|
15
|
+
| `open` | `boolean` | `undefined` | Controlled open state. |
|
|
16
|
+
| `onOpenChange` | `(open: boolean) => void` | `undefined` | Called when open state changes. |
|
|
17
|
+
| `direction` | `"top" | "right" | "bottom" | "left"` | `"bottom"` | Drawer opening direction. |
|
|
18
|
+
| `modal` | `boolean` | `true` | Modal behavior (trap focus, block background interaction). |
|
|
19
|
+
| `shouldScaleBackground` | `boolean` | `true` | Scales the background when the drawer is open. |
|
|
20
|
+
| `snapPoints` | `number[]` | `[]` | Optional snap points (fractions of viewport: e.g., `0.4`, `0.6`). |
|
|
21
|
+
| `activeSnapPoint` | `number | string` | `undefined` | The active snap point index/value. |
|
|
22
|
+
| `closeThreshold` | `number` | `undefined` | Threshold to trigger close on drag. |
|
|
23
|
+
|
|
24
|
+
### Subcomponents
|
|
25
|
+
|
|
26
|
+
- `DrawerTrigger`: Element that opens the drawer (supports `asChild`).
|
|
27
|
+
- `DrawerPortal` / `DrawerOverlay`: Portal root and backdrop.
|
|
28
|
+
- `DrawerContent`: Panel container; includes a grab handle in bottom direction.
|
|
29
|
+
- `DrawerHeader` / `DrawerFooter`: Layout helpers for content.
|
|
30
|
+
- `DrawerTitle` / `DrawerDescription`: Header title and description.
|
|
31
|
+
- `DrawerClose`: Close button helper to wrap an element.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Behavior
|
|
36
|
+
|
|
37
|
+
- **Directions**: Open from any side via `direction` prop.
|
|
38
|
+
- **Snap points**: Provide a list of fractional heights; control active point via `activeSnapPoint`.
|
|
39
|
+
- **Modal**: When `modal` is true, interaction outside is blocked and overlay is shown.
|
|
40
|
+
- **Accessibility**: Focus trapping and keyboard navigation handled by the underlying library.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
### Interactive Drawer
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Button } from "laif-ds";
|
|
50
|
+
import {
|
|
51
|
+
Drawer,
|
|
52
|
+
DrawerTrigger,
|
|
53
|
+
DrawerContent,
|
|
54
|
+
DrawerHeader,
|
|
55
|
+
DrawerTitle,
|
|
56
|
+
DrawerDescription,
|
|
57
|
+
DrawerFooter,
|
|
58
|
+
DrawerClose,
|
|
59
|
+
} from "laif-ds";
|
|
60
|
+
import { Input } from "laif-ds";
|
|
61
|
+
|
|
62
|
+
export function InteractiveDrawer() {
|
|
63
|
+
return (
|
|
64
|
+
<Drawer direction="bottom" modal shouldScaleBackground>
|
|
65
|
+
<DrawerTrigger asChild>
|
|
66
|
+
<Button variant="outline">Apri Drawer</Button>
|
|
67
|
+
</DrawerTrigger>
|
|
68
|
+
<DrawerContent>
|
|
69
|
+
<DrawerHeader>
|
|
70
|
+
<DrawerTitle>Drawer di Esempio</DrawerTitle>
|
|
71
|
+
<DrawerDescription>
|
|
72
|
+
Personalizza contenuti e comportamento tramite le props.
|
|
73
|
+
</DrawerDescription>
|
|
74
|
+
</DrawerHeader>
|
|
75
|
+
<div className="space-y-4 p-4">
|
|
76
|
+
<Input label="Nome" placeholder="Inserisci il tuo nome" />
|
|
77
|
+
<Input
|
|
78
|
+
label="Email"
|
|
79
|
+
type="email"
|
|
80
|
+
placeholder="Inserisci la tua email"
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
<DrawerFooter>
|
|
84
|
+
<Button>Salva modifiche</Button>
|
|
85
|
+
<DrawerClose asChild>
|
|
86
|
+
<Button variant="outline">Annulla</Button>
|
|
87
|
+
</DrawerClose>
|
|
88
|
+
</DrawerFooter>
|
|
89
|
+
</DrawerContent>
|
|
90
|
+
</Drawer>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### With Snap Points
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { Button } from "laif-ds";
|
|
99
|
+
import {
|
|
100
|
+
Drawer,
|
|
101
|
+
DrawerTrigger,
|
|
102
|
+
DrawerContent,
|
|
103
|
+
DrawerHeader,
|
|
104
|
+
DrawerTitle,
|
|
105
|
+
DrawerDescription,
|
|
106
|
+
DrawerFooter,
|
|
107
|
+
DrawerClose,
|
|
108
|
+
} from "laif-ds";
|
|
109
|
+
|
|
110
|
+
export function DrawerWithSnapPoints() {
|
|
111
|
+
const snapPoints = [0.4, 0.6, 0.9];
|
|
112
|
+
return (
|
|
113
|
+
<Drawer snapPoints={snapPoints} activeSnapPoint={0}>
|
|
114
|
+
<DrawerTrigger asChild>
|
|
115
|
+
<Button variant="outline">Drawer con Snap Points</Button>
|
|
116
|
+
</DrawerTrigger>
|
|
117
|
+
<DrawerContent>
|
|
118
|
+
<DrawerHeader>
|
|
119
|
+
<DrawerTitle>Drawer con Snap Points</DrawerTitle>
|
|
120
|
+
<DrawerDescription>
|
|
121
|
+
Snap a 40%, 60% e 90% dell'altezza.
|
|
122
|
+
</DrawerDescription>
|
|
123
|
+
</DrawerHeader>
|
|
124
|
+
<DrawerFooter>
|
|
125
|
+
<DrawerClose asChild>
|
|
126
|
+
<Button variant="outline">Chiudi</Button>
|
|
127
|
+
</DrawerClose>
|
|
128
|
+
</DrawerFooter>
|
|
129
|
+
</DrawerContent>
|
|
130
|
+
</Drawer>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Notes
|
|
138
|
+
|
|
139
|
+
- **Handle**: A grab handle is visible for bottom direction.
|
|
140
|
+
- **Layout**: Use `DrawerHeader`/`DrawerFooter` and your own content in between.
|
|
141
|
+
- **Styling**: Customize via `className` on `DrawerContent`.
|