@kivacore/ui-pro-shared 0.0.9 → 0.0.10
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/package.json +187 -21
- package/src/.kiva/config.json +27 -0
- package/src/components/avatar-group.tsx +222 -0
- package/src/components/kiva/bulk-update-dialog/bulk-update-dialog.tsx +240 -0
- package/src/components/kiva/bulk-update-dialog/index.tsx +6 -0
- package/src/components/kiva/bulk-update-dialog/types.ts +33 -0
- package/src/components/kiva/calendar/animations.ts +40 -0
- package/src/components/kiva/calendar/calendar-body.tsx +106 -0
- package/src/components/kiva/calendar/calendar-sidebar.tsx +103 -0
- package/src/components/kiva/calendar/calendar.tsx +243 -0
- package/src/components/kiva/calendar/constants.ts +12 -0
- package/src/components/kiva/calendar/contexts/calendar-context.tsx +696 -0
- package/src/components/kiva/calendar/contexts/dnd-context.tsx +173 -0
- package/src/components/kiva/calendar/dialogs/add-edit-event-dialog.tsx +287 -0
- package/src/components/kiva/calendar/dialogs/delete-event-dialog.tsx +73 -0
- package/src/components/kiva/calendar/dialogs/event-details-dialog.tsx +163 -0
- package/src/components/kiva/calendar/dialogs/events-list-dialog.tsx +122 -0
- package/src/components/kiva/calendar/dnd/draggable-event.tsx +66 -0
- package/src/components/kiva/calendar/dnd/droppable-area.tsx +53 -0
- package/src/components/kiva/calendar/dnd/resizable-event.tsx +190 -0
- package/src/components/kiva/calendar/header/calendar-header.tsx +84 -0
- package/src/components/kiva/calendar/header/date-navigator.tsx +188 -0
- package/src/components/kiva/calendar/header/filter.tsx +80 -0
- package/src/components/kiva/calendar/header/today-button.tsx +49 -0
- package/src/components/kiva/calendar/header/user-select.tsx +111 -0
- package/src/components/kiva/calendar/header/view-tabs.tsx +144 -0
- package/src/components/kiva/calendar/helpers.ts +617 -0
- package/src/components/kiva/calendar/hooks/use-disclosure.ts +19 -0
- package/src/components/kiva/calendar/hooks/use-local-storage.ts +40 -0
- package/src/components/kiva/calendar/hooks/use-media-query.ts +25 -0
- package/src/components/kiva/calendar/hooks.ts +5 -0
- package/src/components/kiva/calendar/index.tsx +27 -0
- package/src/components/kiva/calendar/interfaces.ts +35 -0
- package/src/components/kiva/calendar/schemas.ts +20 -0
- package/src/components/kiva/calendar/settings/settings.tsx +116 -0
- package/src/components/kiva/calendar/skeletons/calendar-header-skeleton.tsx +27 -0
- package/src/components/kiva/calendar/skeletons/calendar-skeleton.tsx +19 -0
- package/src/components/kiva/calendar/skeletons/day-view-skeleton.tsx +40 -0
- package/src/components/kiva/calendar/skeletons/month-view-skeleton.tsx +36 -0
- package/src/components/kiva/calendar/skeletons/week-view-skeleton.tsx +48 -0
- package/src/components/kiva/calendar/skeletons/year-view-skeleton.tsx +42 -0
- package/src/components/kiva/calendar/types.ts +25 -0
- package/src/components/kiva/calendar/views/agenda-view/agenda-events.tsx +150 -0
- package/src/components/kiva/calendar/views/month-view/calendar-month-view.tsx +82 -0
- package/src/components/kiva/calendar/views/month-view/day-cell.tsx +218 -0
- package/src/components/kiva/calendar/views/month-view/event-bullet.tsx +46 -0
- package/src/components/kiva/calendar/views/month-view/month-event-badge.tsx +154 -0
- package/src/components/kiva/calendar/views/timeline/calendar-timeline-view.tsx +100 -0
- package/src/components/kiva/calendar/views/timeline/lib/timeline-layout.ts +130 -0
- package/src/components/kiva/calendar/views/timeline/lib/timeline-model.ts +504 -0
- package/src/components/kiva/calendar/views/timeline/timeline-event-bar.tsx +68 -0
- package/src/components/kiva/calendar/views/timeline/timeline-grid-header.tsx +125 -0
- package/src/components/kiva/calendar/views/timeline/timeline-row.tsx +159 -0
- package/src/components/kiva/calendar/views/timeline/timeline-section.tsx +61 -0
- package/src/components/kiva/calendar/views/timeline/use-timeline-sections.ts +278 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-day-view.tsx +277 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-time-line.tsx +47 -0
- package/src/components/kiva/calendar/views/week-and-day-view/calendar-week-view.tsx +229 -0
- package/src/components/kiva/calendar/views/week-and-day-view/day-view-multi-day-events-row.tsx +79 -0
- package/src/components/kiva/calendar/views/week-and-day-view/event-block.tsx +116 -0
- package/src/components/kiva/calendar/views/week-and-day-view/render-grouped-events.tsx +54 -0
- package/src/components/kiva/calendar/views/week-and-day-view/week-view-multi-day-events-row.tsx +159 -0
- package/src/components/kiva/calendar/views/year-view/calendar-year-view.tsx +159 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-active-chips.tsx +137 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-clear.tsx +34 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-search.tsx +67 -0
- package/src/components/kiva/data-table-side-filters/components/side-filter-section.tsx +77 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-async-options.tsx +354 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-boolean.tsx +66 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-checkbox-list.tsx +137 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-date-range.tsx +204 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-numeric-range.tsx +162 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-options-dropdown.tsx +191 -0
- package/src/components/kiva/data-table-side-filters/controllers/side-filter-text.tsx +53 -0
- package/src/components/kiva/data-table-side-filters/core/query-translator.ts +367 -0
- package/src/components/kiva/data-table-side-filters/core/types.ts +81 -0
- package/src/components/kiva/data-table-side-filters/data-table-side-filters.tsx +483 -0
- package/src/components/kiva/data-table-side-filters/hooks/use-data-table-side-filters.tsx +160 -0
- package/src/components/kiva/data-table-side-filters/hooks/use-show-more.tsx +62 -0
- package/src/components/kiva/data-table-side-filters/index.tsx +44 -0
- package/src/components/kiva/data-table-side-filters/lib/render-mode.ts +62 -0
- package/src/components/kiva/date-time-picker.tsx +163 -0
- package/src/components/kiva/editable-record-detail.tsx +809 -0
- package/src/components/kiva/enum-option-editor/enum-option-editor.tsx +891 -0
- package/src/components/kiva/enum-option-editor/index.tsx +26 -0
- package/src/components/kiva/enum-option-editor/kiva-enum-option-editor.tsx +320 -0
- package/src/components/kiva/enum-option-editor/types.ts +90 -0
- package/src/components/kiva/kanban.tsx +1376 -0
- package/src/components/kiva/kiva-data-export-menu.tsx +543 -0
- package/src/components/kiva/map.tsx +1631 -0
- package/src/components/kiva/pivot-calendar/components/group-sidebar.tsx +95 -0
- package/src/components/kiva/pivot-calendar/components/pivot-calendar-toolbar.tsx +113 -0
- package/src/components/kiva/pivot-calendar/components/stats-cell.tsx +126 -0
- package/src/components/kiva/pivot-calendar/helpers.ts +374 -0
- package/src/components/kiva/pivot-calendar/hooks/use-pivot-calendar.ts +222 -0
- package/src/components/kiva/pivot-calendar/index.tsx +32 -0
- package/src/components/kiva/pivot-calendar/pivot-calendar.tsx +107 -0
- package/src/components/kiva/pivot-calendar/types.ts +154 -0
- package/src/components/kiva/pivot-calendar/views/days-of-month-view.tsx +37 -0
- package/src/components/kiva/pivot-calendar/views/days-of-week-view.tsx +37 -0
- package/src/components/kiva/pivot-calendar/views/month-calendar-view.tsx +154 -0
- package/src/components/kiva/pivot-calendar/views/months-of-year-view.tsx +40 -0
- package/src/components/kiva/pivot-calendar/views/pivot-grid-view.tsx +251 -0
- package/src/components/kiva/pivot-filter/index.tsx +9 -0
- package/src/components/kiva/pivot-filter/pivot-filter-item.tsx +159 -0
- package/src/components/kiva/pivot-filter/pivot-filter-settings.tsx +161 -0
- package/src/components/kiva/pivot-filter/pivot-filter.tsx +187 -0
- package/src/components/kiva/pivot-filter/types.ts +82 -0
- package/src/components/kiva/pivot-grid/hooks/use-pivot-grid.ts +683 -0
- package/src/components/kiva/pivot-grid/index.tsx +23 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-color-rules.ts +98 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-export.ts +265 -0
- package/src/components/kiva/pivot-grid/lib/pivot-grid-model.ts +1110 -0
- package/src/components/kiva/pivot-grid/pivot-grid-demo-data.ts +200 -0
- package/src/components/kiva/pivot-grid/pivot-grid-export-menu.tsx +66 -0
- package/src/components/kiva/pivot-grid/pivot-grid-toolbar.tsx +85 -0
- package/src/components/kiva/pivot-grid/pivot-grid.tsx +601 -0
- package/src/components/kiva/pivot-grid/types.ts +195 -0
- package/src/components/kiva/place-autocomplete.tsx +484 -0
- package/src/components/kiva/record-delete-confirm-dialog/index.tsx +10 -0
- package/src/components/kiva/record-delete-confirm-dialog/record-delete-confirm-dialog.tsx +266 -0
- package/src/components/kiva/record-delete-confirm-dialog/types.ts +25 -0
- package/src/hooks/kiva/_internal/autonumber-setting.ts +112 -0
- package/src/hooks/kiva/_internal/form-layout-to-view.ts +665 -0
- package/src/hooks/kiva/_internal/kiva-hook-utils.ts +143 -0
- package/src/hooks/kiva/_internal/use-computed-field-evaluator.tsx +310 -0
- package/src/hooks/kiva/_internal/use-field-actions-evaluator.tsx +398 -0
- package/src/hooks/kiva/_internal/use-form-actions-evaluator.tsx +363 -0
- package/src/hooks/kiva/_internal/use-form-view-engine.tsx +2200 -0
- package/src/hooks/kiva/_internal/use-kiva-form-view-fields.tsx +190 -0
- package/src/hooks/kiva/_internal/use-kiva-kanban-cards.tsx +311 -0
- package/src/hooks/kiva/use-data-export.tsx +265 -0
- package/src/hooks/kiva/use-kiva-calendar.tsx +992 -0
- package/src/hooks/kiva/use-kiva-data-export.tsx +173 -0
- package/src/hooks/kiva/use-kiva-data-grid.tsx +4750 -0
- package/src/hooks/kiva/use-kiva-data-view-select.tsx +1273 -0
- package/src/hooks/kiva/use-kiva-form-view.tsx +1581 -0
- package/src/hooks/kiva/use-kiva-inventory.tsx +184 -0
- package/src/hooks/kiva/use-kiva-kanban.tsx +1750 -0
- package/src/hooks/kiva/use-kiva-map-view.tsx +2255 -0
- package/src/hooks/kiva/use-kiva-pivot-calendar.tsx +759 -0
- package/src/hooks/kiva/use-kiva-pivot-filter.tsx +1523 -0
- package/src/hooks/kiva/use-kiva-pivot-grid.tsx +543 -0
- package/src/hooks/kiva/use-kiva-tenant.tsx +313 -0
- package/src/hooks/kiva/use-parameter-persistence.ts +191 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import {
|
|
6
|
+
useCallback, useId, useMemo, useState
|
|
7
|
+
} from 'react';
|
|
8
|
+
|
|
9
|
+
import { useMutation } from '@tanstack/react-query';
|
|
10
|
+
import { Loader2 } from 'lucide-react';
|
|
11
|
+
|
|
12
|
+
import { Button } from '@kivacore/ui-pro-shared/components/button';
|
|
13
|
+
import {
|
|
14
|
+
Dialog,
|
|
15
|
+
DialogContent,
|
|
16
|
+
DialogDescription,
|
|
17
|
+
DialogFooter,
|
|
18
|
+
DialogHeader,
|
|
19
|
+
DialogTitle
|
|
20
|
+
} from '@kivacore/ui-pro-shared/components/dialog';
|
|
21
|
+
import { Label } from '@kivacore/ui-pro-shared/components/label';
|
|
22
|
+
import {
|
|
23
|
+
Select,
|
|
24
|
+
SelectContent,
|
|
25
|
+
SelectItem,
|
|
26
|
+
SelectTrigger,
|
|
27
|
+
SelectValue
|
|
28
|
+
} from '@kivacore/ui-pro-shared/components/select';
|
|
29
|
+
import { cn } from '@kivacore/ui-pro-shared/lib/utils';
|
|
30
|
+
|
|
31
|
+
import { SchemaRepeater } from '@kivacore/ui-pro-shared/components/kiva/schema-repeater';
|
|
32
|
+
import { useKivaFormView } from '@kivacore/ui-pro-shared/hooks/kiva/use-kiva-form-view';
|
|
33
|
+
|
|
34
|
+
import { type BulkUpdateDialogProps, type BulkUpdateRecord } from './types';
|
|
35
|
+
|
|
36
|
+
interface FieldEntry {
|
|
37
|
+
/** Stable id for the SchemaRepeater. */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Slug picked from the data source — empty string when not chosen yet. */
|
|
40
|
+
slug: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function createEntry(): FieldEntry {
|
|
44
|
+
return { id: cryptoId(), slug: '' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function cryptoId(): string {
|
|
48
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
49
|
+
return crypto.randomUUID();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return `bulk-${Math.random().toString(36).slice(2, 10)}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function BulkUpdateDialog({
|
|
56
|
+
open,
|
|
57
|
+
onOpenChange,
|
|
58
|
+
client,
|
|
59
|
+
appSlug,
|
|
60
|
+
dataSourceSlug,
|
|
61
|
+
records,
|
|
62
|
+
enableAutomation = true,
|
|
63
|
+
enableChangeLogging = true,
|
|
64
|
+
onSuccess,
|
|
65
|
+
allowedFieldSlugs,
|
|
66
|
+
className
|
|
67
|
+
}: BulkUpdateDialogProps) {
|
|
68
|
+
const labelId = useId();
|
|
69
|
+
const [entries, setEntries] = useState<Array<FieldEntry>>(() => [createEntry()]);
|
|
70
|
+
|
|
71
|
+
const formView = useKivaFormView({
|
|
72
|
+
client,
|
|
73
|
+
appSlug,
|
|
74
|
+
dataSourceSlug,
|
|
75
|
+
mode: 'create',
|
|
76
|
+
enabled: open,
|
|
77
|
+
gridColumns: 1
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const fieldOptions = useMemo(() => {
|
|
81
|
+
const slugSet = allowedFieldSlugs ? new Set(allowedFieldSlugs) : null;
|
|
82
|
+
|
|
83
|
+
return formView.fields
|
|
84
|
+
.filter(field => !field.readOnly && field.editable && (!slugSet || slugSet.has(field.slug)))
|
|
85
|
+
.map(field => ({ value: field.slug, label: typeof field.field.name === 'string' ? field.field.name : field.slug }));
|
|
86
|
+
}, [formView.fields, allowedFieldSlugs]);
|
|
87
|
+
|
|
88
|
+
const usedSlugs = useMemo(() => {
|
|
89
|
+
const set = new Set<string>();
|
|
90
|
+
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
if (entry.slug) set.add(entry.slug);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return set;
|
|
96
|
+
}, [entries]);
|
|
97
|
+
|
|
98
|
+
const updateMutation = useMutation({
|
|
99
|
+
mutationFn: async (payload: Array<Record<string, unknown>>) => {
|
|
100
|
+
const response = await client.patch<{ data?: Array<BulkUpdateRecord> } | Array<BulkUpdateRecord>>(
|
|
101
|
+
`/v1/apps/${appSlug}/data-sources/${dataSourceSlug}/items/bulk`,
|
|
102
|
+
{
|
|
103
|
+
records: payload,
|
|
104
|
+
enableAutomation,
|
|
105
|
+
enableChangeLogging
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const data = Array.isArray(response) ? response : (response as { data?: Array<BulkUpdateRecord> }).data ?? [];
|
|
110
|
+
|
|
111
|
+
return data;
|
|
112
|
+
},
|
|
113
|
+
onSuccess: (data) => {
|
|
114
|
+
onSuccess?.(data);
|
|
115
|
+
setEntries([createEntry()]);
|
|
116
|
+
onOpenChange(false);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const onSubmit = useCallback(async () => {
|
|
121
|
+
if (records.length === 0) return;
|
|
122
|
+
|
|
123
|
+
const filledSlugs = entries
|
|
124
|
+
.map(entry => entry.slug)
|
|
125
|
+
.filter((slug): slug is string => Boolean(slug));
|
|
126
|
+
|
|
127
|
+
if (filledSlugs.length === 0) return;
|
|
128
|
+
|
|
129
|
+
const updates: Record<string, unknown> = {};
|
|
130
|
+
|
|
131
|
+
for (const slug of filledSlugs) {
|
|
132
|
+
updates[slug] = formView.values[slug];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const payload = records.map(record => ({ id: record.id, ...updates }));
|
|
136
|
+
|
|
137
|
+
await updateMutation.mutateAsync(payload);
|
|
138
|
+
}, [
|
|
139
|
+
records,
|
|
140
|
+
entries,
|
|
141
|
+
formView.values,
|
|
142
|
+
updateMutation
|
|
143
|
+
]);
|
|
144
|
+
|
|
145
|
+
const { isPending } = updateMutation;
|
|
146
|
+
const filledCount = entries.filter(entry => Boolean(entry.slug)).length;
|
|
147
|
+
const canSubmit = !isPending && !formView.isLoading && filledCount > 0 && records.length > 0;
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<Dialog
|
|
151
|
+
open={open}
|
|
152
|
+
onOpenChange={(next) => {
|
|
153
|
+
if (isPending) return;
|
|
154
|
+
onOpenChange(next);
|
|
155
|
+
}}>
|
|
156
|
+
<DialogContent className={cn('max-w-xl', className)}>
|
|
157
|
+
<DialogHeader>
|
|
158
|
+
<DialogTitle>
|
|
159
|
+
Bulk update
|
|
160
|
+
{records.length > 0 ? ` · ${records.length} record${records.length === 1 ? '' : 's'}` : ''}
|
|
161
|
+
</DialogTitle>
|
|
162
|
+
<DialogDescription>
|
|
163
|
+
Pick the fields you want to overwrite on every selected record. Untouched fields stay as they are.
|
|
164
|
+
</DialogDescription>
|
|
165
|
+
</DialogHeader>
|
|
166
|
+
|
|
167
|
+
<div className="flex max-h-[60vh] flex-col gap-3 overflow-y-auto">
|
|
168
|
+
{formView.isLoading ? (
|
|
169
|
+
<div className="flex items-center justify-center py-8 text-muted-foreground">
|
|
170
|
+
<Loader2 className="size-5 animate-spin" />
|
|
171
|
+
</div>
|
|
172
|
+
) : (
|
|
173
|
+
<>
|
|
174
|
+
<Label id={labelId} className="text-sm font-medium">Field updates</Label>
|
|
175
|
+
<SchemaRepeater<FieldEntry>
|
|
176
|
+
value={entries}
|
|
177
|
+
onValueChange={setEntries}
|
|
178
|
+
createItem={createEntry}
|
|
179
|
+
addLabel="Add field"
|
|
180
|
+
disabled={isPending}
|
|
181
|
+
renderItem={(entry, index, helpers) => (
|
|
182
|
+
<div className="flex flex-col gap-2 rounded-md border bg-card p-3">
|
|
183
|
+
<Select
|
|
184
|
+
value={entry.slug}
|
|
185
|
+
onValueChange={slug => helpers.update({ slug })}
|
|
186
|
+
disabled={isPending}>
|
|
187
|
+
<SelectTrigger
|
|
188
|
+
aria-label={`Field ${index + 1}`}
|
|
189
|
+
aria-labelledby={labelId}>
|
|
190
|
+
<SelectValue placeholder="Choose a field…" />
|
|
191
|
+
</SelectTrigger>
|
|
192
|
+
<SelectContent>
|
|
193
|
+
{fieldOptions.map((option) => {
|
|
194
|
+
const taken = option.value !== entry.slug && usedSlugs.has(option.value);
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<SelectItem
|
|
198
|
+
key={option.value}
|
|
199
|
+
value={option.value}
|
|
200
|
+
disabled={taken}>
|
|
201
|
+
{option.label}
|
|
202
|
+
{taken ? ' (already added)' : ''}
|
|
203
|
+
</SelectItem>
|
|
204
|
+
);
|
|
205
|
+
})}
|
|
206
|
+
</SelectContent>
|
|
207
|
+
</Select>
|
|
208
|
+
{entry.slug ? (
|
|
209
|
+
<div className="min-w-0">
|
|
210
|
+
{formView.renderField(entry.slug, { mode: 'create' })}
|
|
211
|
+
</div>
|
|
212
|
+
) : null}
|
|
213
|
+
</div>
|
|
214
|
+
)} />
|
|
215
|
+
</>
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
<DialogFooter>
|
|
220
|
+
<Button
|
|
221
|
+
type="button"
|
|
222
|
+
variant="outline"
|
|
223
|
+
size="sm"
|
|
224
|
+
onClick={() => onOpenChange(false)}
|
|
225
|
+
disabled={isPending}>
|
|
226
|
+
Cancel
|
|
227
|
+
</Button>
|
|
228
|
+
<Button
|
|
229
|
+
type="button"
|
|
230
|
+
size="sm"
|
|
231
|
+
onClick={onSubmit}
|
|
232
|
+
disabled={!canSubmit}>
|
|
233
|
+
{isPending && <Loader2 className="size-4 animate-spin" />}
|
|
234
|
+
Update {records.length} record{records.length === 1 ? '' : 's'}
|
|
235
|
+
</Button>
|
|
236
|
+
</DialogFooter>
|
|
237
|
+
</DialogContent>
|
|
238
|
+
</Dialog>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { type RestApiClient } from '@kivacore/api-client';
|
|
4
|
+
|
|
5
|
+
export interface BulkUpdateRecord {
|
|
6
|
+
/** Record id — required by the bulk-update endpoint. */
|
|
7
|
+
id: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BulkUpdateDialogProps {
|
|
12
|
+
open: boolean;
|
|
13
|
+
onOpenChange: (open: boolean) => void;
|
|
14
|
+
client: RestApiClient;
|
|
15
|
+
appSlug: string;
|
|
16
|
+
dataSourceSlug: string;
|
|
17
|
+
/** Rows the user has selected in the grid. Only `id` is read. */
|
|
18
|
+
records: ReadonlyArray<BulkUpdateRecord>;
|
|
19
|
+
/** When `true`, downstream automations run on each updated row. Default `true`. */
|
|
20
|
+
enableAutomation?: boolean;
|
|
21
|
+
/** When `true`, change-log entries are written. Default `true`. */
|
|
22
|
+
enableChangeLogging?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Called after the bulk PATCH resolves. The `data` argument is whatever the
|
|
25
|
+
* server returns (`response.data` is unwrapped first).
|
|
26
|
+
*/
|
|
27
|
+
onSuccess?: (data: Array<BulkUpdateRecord>) => void;
|
|
28
|
+
/** Hide / restrict the field picker to a subset of slugs. */
|
|
29
|
+
allowedFieldSlugs?: ReadonlyArray<string>;
|
|
30
|
+
/** Optional pre-resolved data source id (avoids a round-trip). */
|
|
31
|
+
dataSourceId?: string;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { type Variants } from 'motion/react';
|
|
4
|
+
|
|
5
|
+
export const fadeIn: Variants = {
|
|
6
|
+
initial: { opacity: 0 },
|
|
7
|
+
animate: { opacity: 1 },
|
|
8
|
+
exit: { opacity: 0 }
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const slideFromLeft: Variants = {
|
|
12
|
+
initial: { x: -20, opacity: 0 },
|
|
13
|
+
animate: { x: 0, opacity: 1 },
|
|
14
|
+
exit: { x: 20, opacity: 0 }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const slideFromRight: Variants = {
|
|
18
|
+
initial: { x: 20, opacity: 0 },
|
|
19
|
+
animate: { x: 0, opacity: 1 },
|
|
20
|
+
exit: { x: -20, opacity: 0 }
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const transition = {
|
|
24
|
+
type: 'spring',
|
|
25
|
+
stiffness: 200,
|
|
26
|
+
damping: 20
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
export const staggerContainer: Variants = {
|
|
30
|
+
animate: {
|
|
31
|
+
transition: {
|
|
32
|
+
staggerChildren: 0.1
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const buttonHover: Variants = {
|
|
38
|
+
hover: { scale: 1.05 },
|
|
39
|
+
tap: { scale: 0.95 }
|
|
40
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { isSameDay, parseISO } from 'date-fns';
|
|
8
|
+
import { Loader2 } from 'lucide-react';
|
|
9
|
+
import { motion } from 'motion/react';
|
|
10
|
+
|
|
11
|
+
import { useUiTranslation } from '@kivacore/ui-pro-shared/hooks/kiva/use-ui-translation';
|
|
12
|
+
|
|
13
|
+
import { fadeIn, transition } from './animations';
|
|
14
|
+
import { useCalendar } from './contexts/calendar-context';
|
|
15
|
+
import { type IEvent } from './interfaces';
|
|
16
|
+
import { AgendaEvents } from './views/agenda-view/agenda-events';
|
|
17
|
+
import { CalendarMonthView } from './views/month-view/calendar-month-view';
|
|
18
|
+
import { CalendarDayView } from './views/week-and-day-view/calendar-day-view';
|
|
19
|
+
import { CalendarWeekView } from './views/week-and-day-view/calendar-week-view';
|
|
20
|
+
import { CalendarTimelineView } from './views/timeline/calendar-timeline-view';
|
|
21
|
+
import { CalendarYearView } from './views/year-view/calendar-year-view';
|
|
22
|
+
|
|
23
|
+
export function CalendarBody() {
|
|
24
|
+
const { view, events, isRefreshing } = useCalendar();
|
|
25
|
+
const { t } = useUiTranslation();
|
|
26
|
+
|
|
27
|
+
const { singleDayEvents, multiDayEvents } = useMemo(() => {
|
|
28
|
+
const singles: IEvent[] = [];
|
|
29
|
+
const multis: IEvent[] = [];
|
|
30
|
+
|
|
31
|
+
for (const event of events) {
|
|
32
|
+
const startDate = parseISO(event.startDate);
|
|
33
|
+
const endDate = parseISO(event.endDate);
|
|
34
|
+
|
|
35
|
+
if (isSameDay(startDate, endDate)) {
|
|
36
|
+
singles.push(event);
|
|
37
|
+
} else {
|
|
38
|
+
multis.push(event);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { singleDayEvents: singles, multiDayEvents: multis };
|
|
43
|
+
}, [events]);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div className="relative w-full h-full">
|
|
47
|
+
<div className="w-full h-full overflow-scroll relative">
|
|
48
|
+
<motion.div
|
|
49
|
+
key={view}
|
|
50
|
+
initial="initial"
|
|
51
|
+
animate="animate"
|
|
52
|
+
exit="exit"
|
|
53
|
+
variants={fadeIn}
|
|
54
|
+
transition={transition}>
|
|
55
|
+
{view === 'month' && (
|
|
56
|
+
<CalendarMonthView
|
|
57
|
+
singleDayEvents={singleDayEvents}
|
|
58
|
+
multiDayEvents={multiDayEvents} />
|
|
59
|
+
)}
|
|
60
|
+
{view === 'week' && (
|
|
61
|
+
<CalendarWeekView
|
|
62
|
+
singleDayEvents={singleDayEvents}
|
|
63
|
+
multiDayEvents={multiDayEvents} />
|
|
64
|
+
)}
|
|
65
|
+
{view === 'day' && (
|
|
66
|
+
<CalendarDayView
|
|
67
|
+
singleDayEvents={singleDayEvents}
|
|
68
|
+
multiDayEvents={multiDayEvents} />
|
|
69
|
+
)}
|
|
70
|
+
{view === 'year' && (
|
|
71
|
+
<CalendarYearView
|
|
72
|
+
singleDayEvents={singleDayEvents}
|
|
73
|
+
multiDayEvents={multiDayEvents} />
|
|
74
|
+
)}
|
|
75
|
+
{(view === 'year-timeline' || view === 'quarter' || view === '13weeks') && (
|
|
76
|
+
<CalendarTimelineView view={view} />
|
|
77
|
+
)}
|
|
78
|
+
{view === 'agenda' && (
|
|
79
|
+
<motion.div
|
|
80
|
+
key="agenda"
|
|
81
|
+
initial="initial"
|
|
82
|
+
animate="animate"
|
|
83
|
+
exit="exit"
|
|
84
|
+
variants={fadeIn}
|
|
85
|
+
transition={transition}>
|
|
86
|
+
<AgendaEvents />
|
|
87
|
+
</motion.div>
|
|
88
|
+
)}
|
|
89
|
+
</motion.div>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
{/* Pinned to the visible area (not the scrolled content) so the spinner
|
|
93
|
+
* is always where the user is looking while a period is being fetched. */}
|
|
94
|
+
{isRefreshing && (
|
|
95
|
+
<div
|
|
96
|
+
aria-busy="true"
|
|
97
|
+
className="absolute inset-0 z-50 flex items-center justify-center bg-background/60 backdrop-blur-[1px]">
|
|
98
|
+
<span className="flex items-center gap-2 rounded-md border bg-background px-3 py-1.5 text-sm shadow-sm">
|
|
99
|
+
<Loader2 className="size-4 animate-spin" />
|
|
100
|
+
{t('ui.calendar.loading', 'Loading…')}
|
|
101
|
+
</span>
|
|
102
|
+
</div>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { Avatar, AvatarFallback } from '@kivacore/ui-pro-shared/components/avatar';
|
|
6
|
+
import { Switch } from '@kivacore/ui-pro-shared/components/switch';
|
|
7
|
+
|
|
8
|
+
import { useUiTranslation } from '@kivacore/ui-pro-shared/hooks/kiva/use-ui-translation';
|
|
9
|
+
|
|
10
|
+
import { useCalendar } from './contexts/calendar-context';
|
|
11
|
+
|
|
12
|
+
function getInitials(name: string): string {
|
|
13
|
+
return name
|
|
14
|
+
.split(' ')
|
|
15
|
+
.map(n => n[0])
|
|
16
|
+
.join('')
|
|
17
|
+
.toUpperCase()
|
|
18
|
+
.slice(0, 2);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface CalendarSidebarProps {
|
|
22
|
+
weekTaskCount: number;
|
|
23
|
+
highPriorityCount: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function CalendarSidebar({
|
|
27
|
+
weekTaskCount,
|
|
28
|
+
highPriorityCount
|
|
29
|
+
}: CalendarSidebarProps) {
|
|
30
|
+
const { t } = useUiTranslation();
|
|
31
|
+
const { users } = useCalendar();
|
|
32
|
+
const teamMembers = users.slice(0, 5);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="space-y-6">
|
|
36
|
+
{/* Team Visibility */}
|
|
37
|
+
<div>
|
|
38
|
+
<h3 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
|
39
|
+
{t('ui.calendar.teamVisibility', 'Team Visibility')}
|
|
40
|
+
</h3>
|
|
41
|
+
<div className="space-y-3">
|
|
42
|
+
{teamMembers.map((user) => {
|
|
43
|
+
return (
|
|
44
|
+
<div key={user.id} className="flex items-center gap-2.5">
|
|
45
|
+
<Switch defaultChecked />
|
|
46
|
+
<Avatar className="size-7">
|
|
47
|
+
<AvatarFallback className="text-xs">
|
|
48
|
+
{getInitials(user.name)}
|
|
49
|
+
</AvatarFallback>
|
|
50
|
+
</Avatar>
|
|
51
|
+
<span className="text-sm">{user.name}</span>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
})}
|
|
55
|
+
{teamMembers.length === 0 && (
|
|
56
|
+
<p className="text-xs text-muted-foreground">
|
|
57
|
+
{t('ui.calendar.noTeamMembers', 'No team members found.')}
|
|
58
|
+
</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
{/* Milestones */}
|
|
64
|
+
<div>
|
|
65
|
+
<h3 className="mb-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
|
66
|
+
{t('ui.calendar.milestones', 'Milestones')}
|
|
67
|
+
</h3>
|
|
68
|
+
<div className="space-y-2.5">
|
|
69
|
+
<div className="flex items-center justify-between">
|
|
70
|
+
<div className="flex items-center gap-2">
|
|
71
|
+
<div className="size-2 rounded-full bg-green-500" />
|
|
72
|
+
<span className="text-sm">Beta Launch</span>
|
|
73
|
+
</div>
|
|
74
|
+
<span className="text-xs text-muted-foreground">Coming soon</span>
|
|
75
|
+
</div>
|
|
76
|
+
<div className="flex items-center justify-between">
|
|
77
|
+
<div className="flex items-center gap-2">
|
|
78
|
+
<div className="size-2 rounded-full bg-blue-500" />
|
|
79
|
+
<span className="text-sm">Final QA</span>
|
|
80
|
+
</div>
|
|
81
|
+
<span className="text-xs text-muted-foreground">Coming soon</span>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
{/* Weekly Summary */}
|
|
87
|
+
<div className="rounded-xl bg-primary p-4 text-primary-foreground">
|
|
88
|
+
<h3 className="font-semibold">{t('ui.calendar.weeklySummary', 'Weekly Summary')}</h3>
|
|
89
|
+
<p className="mt-1 text-sm opacity-90">
|
|
90
|
+
{t('ui.calendar.tasksScheduled', 'You have {count} tasks scheduled this week.').replace('{count}', String(weekTaskCount))}
|
|
91
|
+
{highPriorityCount > 0 && (
|
|
92
|
+
<> {t('ui.calendar.highPriority', '{count} are high priority.').replace('{count}', String(highPriorityCount))}</>
|
|
93
|
+
)}
|
|
94
|
+
</p>
|
|
95
|
+
<button
|
|
96
|
+
type="button"
|
|
97
|
+
className="mt-3 w-full rounded-lg bg-primary-foreground/20 px-3 py-1.5 text-sm font-medium transition-colors hover:bg-primary-foreground/30">
|
|
98
|
+
{t('ui.calendar.viewAnalytics', 'View Analytics')}
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|