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
|
@@ -1,137 +1,163 @@
|
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1
|
+
# FormComposer
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Declarative form builder using `react-hook-form` (with optional Zod). Renders inputs, selects, textareas, and checkboxes from a simple items config, handles validation, and provides a submit button with loading state.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Types
|
|
10
|
+
|
|
11
|
+
### FormComposerItem
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
interface FormComposerItem {
|
|
15
|
+
label: string;
|
|
16
|
+
component: "input" | "select" | "textarea" | "checkbox";
|
|
17
|
+
name: string;
|
|
18
|
+
defaultValue?: string | boolean | number;
|
|
19
|
+
options?: AppSelectOption[]; // only for "select"
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
| Prop | Type | Default | Description |
|
|
30
|
+
| --------------- | --------------------- | ------------ | -------------------------------------------------- | ----- | --------------------------- |
|
|
31
|
+
| `cols` | `"1" | "2" | "3"` | `"2"` | Grid columns for the items. |
|
|
32
|
+
| `items` | `FormComposerItem[]` | **required** | Field configuration list. |
|
|
33
|
+
| `schema` | `ZodTypeAny` | `undefined` | Optional Zod schema to enable validation/resolver. |
|
|
34
|
+
| `defaultValues` | `Record<string, any>` | `undefined` | RHF default values; overrides item `defaultValue`. |
|
|
35
|
+
| `submitText` | `string` | `"Invia"` | Submit button label. |
|
|
36
|
+
| `onSubmit` | `(data: any) => void` | `undefined` | Called with valid form values. |
|
|
37
|
+
| `isSubmitting` | `boolean` | `false` | Controls submit button loading/disabled state. |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Behavior
|
|
42
|
+
|
|
43
|
+
- **Validation**: If `schema` is provided, a Zod resolver is attached; otherwise native validity is used.
|
|
44
|
+
- **Defaults**: Each `item.defaultValue` is merged into RHF defaults, unless `defaultValues` is passed.
|
|
45
|
+
- **Components**:
|
|
46
|
+
- `component: "input"` → `Input` with `label` and `placeholder`.
|
|
47
|
+
- `component: "textarea"` → `Textarea` with `label`.
|
|
48
|
+
- `component: "select"` → `AppSelect` with `options`.
|
|
49
|
+
- `component: "checkbox"` → `Checkbox` + `Label` inline.
|
|
50
|
+
- **Errors**: Zod error messages are rendered under each field.
|
|
51
|
+
- **Layout**: Items are placed in a responsive grid with `cols` columns; last item may span full width.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### With Zod Schema
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { z } from "zod";
|
|
61
|
+
import { FormComposer } from "laif-ds";
|
|
62
|
+
|
|
63
|
+
const formSchema = z.object({
|
|
64
|
+
name: z.string().min(2, "Il nome è troppo corto"),
|
|
65
|
+
email: z.string().email("Email non valida"),
|
|
66
|
+
message: z.string().min(10, "Almeno 10 caratteri"),
|
|
67
|
+
select: z.string().min(1, "Seleziona una opzione"),
|
|
68
|
+
checkbox: z.boolean().default(false),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export function ContactForm() {
|
|
72
|
+
return (
|
|
73
|
+
<div className="w-[800px]">
|
|
74
|
+
<FormComposer
|
|
75
|
+
schema={formSchema}
|
|
76
|
+
items={[
|
|
77
|
+
{
|
|
78
|
+
label: "Name",
|
|
79
|
+
component: "input",
|
|
80
|
+
name: "name",
|
|
81
|
+
placeholder: "Inserisci il tuo nome",
|
|
82
|
+
defaultValue: "ciao",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: "Select",
|
|
86
|
+
component: "select",
|
|
87
|
+
name: "select",
|
|
88
|
+
defaultValue: "1",
|
|
89
|
+
options: [
|
|
90
|
+
{ value: "1", label: "Option 1" },
|
|
91
|
+
{ value: "2", label: "Option 2" },
|
|
92
|
+
{ value: "3", label: "Option 3" },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: "Email",
|
|
97
|
+
component: "input",
|
|
98
|
+
name: "email",
|
|
99
|
+
placeholder: "Inserisci la tua email",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: "Checkbox",
|
|
103
|
+
component: "checkbox",
|
|
104
|
+
name: "checkbox",
|
|
105
|
+
defaultValue: true,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
label: "Message",
|
|
109
|
+
component: "textarea",
|
|
110
|
+
name: "message",
|
|
111
|
+
placeholder: "Inserisci il tuo messaggio",
|
|
112
|
+
},
|
|
113
|
+
]}
|
|
114
|
+
onSubmit={(data) => console.log(data)}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Submit State
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import * as React from "react";
|
|
125
|
+
import { z } from "zod";
|
|
126
|
+
import { FormComposer } from "laif-ds";
|
|
127
|
+
|
|
128
|
+
const schema = z.object({ name: z.string().min(2), email: z.string().email() });
|
|
129
|
+
|
|
130
|
+
export function SubmitExample() {
|
|
131
|
+
const [values, setValues] = React.useState({});
|
|
132
|
+
const [isSubmitting, setSubmitting] = React.useState(false);
|
|
133
|
+
|
|
134
|
+
const onSubmit = (data: any) => {
|
|
135
|
+
setSubmitting(true);
|
|
136
|
+
setTimeout(() => setSubmitting(false), 2000);
|
|
137
|
+
setValues(data);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<div className="w-[800px]">
|
|
142
|
+
<FormComposer
|
|
143
|
+
schema={schema}
|
|
144
|
+
items={[
|
|
145
|
+
{ label: "Name", component: "input", name: "name" },
|
|
146
|
+
{ label: "Email", component: "input", name: "email" },
|
|
147
|
+
]}
|
|
148
|
+
onSubmit={onSubmit}
|
|
149
|
+
isSubmitting={isSubmitting}
|
|
150
|
+
/>
|
|
151
|
+
<pre>{JSON.stringify(values, null, 2)}</pre>
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Notes
|
|
160
|
+
|
|
161
|
+
- **Extensibility**: Use `startContent`, `endContent`, `iconLeft`, `iconRight` props of `Input` for richer fields.
|
|
162
|
+
- **Select**: Provide `options` for `component: "select"` (`AppSelectOption[]`).
|
|
163
|
+
- **Accessibility**: Labels are wired via `htmlFor`/`id`; errors use `role="alert"` and `aria-live` when relevant.
|
|
@@ -1,122 +1,125 @@
|
|
|
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
|
-
|
|
1
|
+
# GanttChart
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Composable Gantt chart with a tree, time scale, and draggable bars. Built as a root `Gantt` component with subcomponents `Gantt.Controls` and `Gantt.Chart`. Supports zoom dimensions, drag step sizes, programmatic callbacks, and custom left-render content for items.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Components & Props
|
|
10
|
+
|
|
11
|
+
### Gantt (root)
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| --------------------- | ----------------- | -------------------------- | ------------------------------------------- |
|
|
15
|
+
| `children` | `React.ReactNode` | — | Compose `Gantt.Controls` and `Gantt.Chart`. |
|
|
16
|
+
| `draggable` | `boolean` | `false` | Enable dragging/resizing of bars. |
|
|
17
|
+
| `defaultDimension` | `GanttDimensions` | `GanttDimensions.HOUR` | Initial zoom (hour, day, etc.). |
|
|
18
|
+
| `defaultDragStepSize` | `DragStepSizes` | `DragStepSizes.THIRTY_MIN` | Initial drag step. |
|
|
19
|
+
| `treeTitle` | `string` | `"Attività"` | Title of the left tree column. |
|
|
20
|
+
|
|
21
|
+
See `enums` in `ui/gantt/enums/` for `GanttDimensions` and `DragStepSizes` values.
|
|
22
|
+
|
|
23
|
+
### Gantt.Chart
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Default | Description |
|
|
26
|
+
| ------------------ | ------------------------ | ------------ | ------------------------------------------------ |
|
|
27
|
+
| `data` | `GanttDataType[]` | **required** | Items to render (with optional nested children). |
|
|
28
|
+
| `className` | `string` | `undefined` | Wrapper classes. |
|
|
29
|
+
| `onBarDoubleClick` | `(bar) => void` | `undefined` | Invoked on item double click. |
|
|
30
|
+
| `onBarChange` | `(bar, newData) => void` | `undefined` | Invoked after drag/resize changes. |
|
|
31
|
+
|
|
32
|
+
### Gantt.Controls
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
| ----------- | -------- | ----------- | ------------------------ |
|
|
36
|
+
| `className` | `string` | `undefined` | Toolbar wrapper classes. |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Data Types
|
|
41
|
+
|
|
42
|
+
Minimal item structure (`ui/gantt/types/GanttData.tsx`):
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type RawGanttDataType = {
|
|
46
|
+
key: string;
|
|
47
|
+
title: string;
|
|
48
|
+
color?: string;
|
|
49
|
+
data?: BarItemDataType; // Repeat or fixed datetime interval
|
|
50
|
+
children?: GanttDataType[]; // Nested items
|
|
51
|
+
leftRender?: React.ReactNode | ((bar) => React.ReactNode);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type NoRepeatDataType = { startDate: string; endDate: string };
|
|
55
|
+
type RepeatDataType = {
|
|
56
|
+
repeatType: DataRepeatTypes;
|
|
57
|
+
fromTime: number;
|
|
58
|
+
toTime: number;
|
|
59
|
+
fromDate?: string;
|
|
60
|
+
toDate?: string;
|
|
61
|
+
weekdays?: number[];
|
|
62
|
+
monthdays?: number[];
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Examples
|
|
69
|
+
|
|
70
|
+
### Default
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import Gantt from "laif-ds/ui/gantt/components/Gantt/Gantt";
|
|
74
|
+
|
|
75
|
+
export function Basic() {
|
|
76
|
+
return (
|
|
77
|
+
<div className="h-[500px]">
|
|
78
|
+
<Gantt>
|
|
79
|
+
<Gantt.Controls />
|
|
80
|
+
<Gantt.Chart data={sampleData} />
|
|
81
|
+
</Gantt>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Draggable + Defaults
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { GanttDimensions, DragStepSizes } from "laif-ds/ui/gantt/enums";
|
|
91
|
+
|
|
92
|
+
export function Draggable() {
|
|
93
|
+
return (
|
|
94
|
+
<div className="h-[500px]">
|
|
95
|
+
<Gantt
|
|
96
|
+
draggable
|
|
97
|
+
defaultDimension={GanttDimensions.DAY}
|
|
98
|
+
defaultDragStepSize={DragStepSizes.ONE_DAY}
|
|
99
|
+
>
|
|
100
|
+
<Gantt.Controls />
|
|
101
|
+
<Gantt.Chart data={sampleData} />
|
|
102
|
+
</Gantt>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Custom Tree Title
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<div className="h-[500px]">
|
|
112
|
+
<Gantt draggable treeTitle="Progetti">
|
|
113
|
+
<Gantt.Controls />
|
|
114
|
+
<Gantt.Chart data={sampleData} />
|
|
115
|
+
</Gantt>
|
|
116
|
+
</div>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Notes
|
|
122
|
+
|
|
123
|
+
- **Virtualization**: Tree, bars, and scale use windowed lists for performance.
|
|
124
|
+
- **Current time**: Auto-updates while scrolling to keep the date indicator in sync.
|
|
125
|
+
- **Left render**: Use `leftRender` to inject icons/actions next to item titles.
|
|
@@ -28,7 +28,7 @@ export function UserHover() {
|
|
|
28
28
|
<HoverCardContent className="w-64">
|
|
29
29
|
<div className="space-y-1">
|
|
30
30
|
<p className="font-medium">John Doe</p>
|
|
31
|
-
<p className="text-
|
|
31
|
+
<p className="text-muted-foreground text-sm">Frontend Engineer</p>
|
|
32
32
|
</div>
|
|
33
33
|
</HoverCardContent>
|
|
34
34
|
</HoverCard>
|