@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,80 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { CheckIcon, Filter, RefreshCcw } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
DropdownMenu,
|
|
9
|
+
DropdownMenuContent,
|
|
10
|
+
DropdownMenuItem,
|
|
11
|
+
DropdownMenuTrigger
|
|
12
|
+
} from '@kivacore/ui-pro-shared/components/dropdown-menu';
|
|
13
|
+
import { Separator } from '@kivacore/ui-pro-shared/components/separator';
|
|
14
|
+
import { Toggle } from '@kivacore/ui-pro-shared/components/toggle';
|
|
15
|
+
|
|
16
|
+
import { useUiTranslation } from '@kivacore/ui-pro-shared/hooks/kiva/use-ui-translation';
|
|
17
|
+
|
|
18
|
+
import { type TEventColor } from '../types';
|
|
19
|
+
import { useCalendar } from '../contexts/calendar-context';
|
|
20
|
+
|
|
21
|
+
export default function FilterEvents() {
|
|
22
|
+
const {
|
|
23
|
+
selectedColors, filterEventsBySelectedColors, clearFilter
|
|
24
|
+
} = useCalendar();
|
|
25
|
+
const { t } = useUiTranslation();
|
|
26
|
+
|
|
27
|
+
const colors: Array<TEventColor> = [
|
|
28
|
+
'blue',
|
|
29
|
+
'green',
|
|
30
|
+
'red',
|
|
31
|
+
'yellow',
|
|
32
|
+
'purple',
|
|
33
|
+
'orange'
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<DropdownMenu>
|
|
38
|
+
<DropdownMenuTrigger asChild>
|
|
39
|
+
<Toggle variant="outline" className="cursor-pointer w-fit">
|
|
40
|
+
<Filter className="size-4" />
|
|
41
|
+
</Toggle>
|
|
42
|
+
</DropdownMenuTrigger>
|
|
43
|
+
<DropdownMenuContent align="end" className="w-[150px]">
|
|
44
|
+
{colors.map(color => (
|
|
45
|
+
<DropdownMenuItem
|
|
46
|
+
key={color}
|
|
47
|
+
className="flex items-center gap-2 cursor-pointer"
|
|
48
|
+
onClick={(e) => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
filterEventsBySelectedColors(color);
|
|
51
|
+
}}>
|
|
52
|
+
<div
|
|
53
|
+
className={`size-3.5 rounded-full bg-${color}-600 dark:bg-${color}-700`} />
|
|
54
|
+
<span className="capitalize flex justify-center items-center gap-2">
|
|
55
|
+
{color}
|
|
56
|
+
<span>
|
|
57
|
+
{selectedColors.includes(color) && (
|
|
58
|
+
<span className="text-blue-500">
|
|
59
|
+
<CheckIcon className="size-4" />
|
|
60
|
+
</span>
|
|
61
|
+
)}
|
|
62
|
+
</span>
|
|
63
|
+
</span>
|
|
64
|
+
</DropdownMenuItem>
|
|
65
|
+
))}
|
|
66
|
+
<Separator className="my-2" />
|
|
67
|
+
<DropdownMenuItem
|
|
68
|
+
disabled={selectedColors.length === 0}
|
|
69
|
+
className="flex gap-2 cursor-pointer"
|
|
70
|
+
onClick={(e) => {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
clearFilter();
|
|
73
|
+
}}>
|
|
74
|
+
<RefreshCcw className="size-3.5" />
|
|
75
|
+
{t('ui.calendar.clearFilter', 'Clear filter')}
|
|
76
|
+
</DropdownMenuItem>
|
|
77
|
+
</DropdownMenuContent>
|
|
78
|
+
</DropdownMenu>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { motion } from 'motion/react';
|
|
8
|
+
|
|
9
|
+
import { Button } from '@kivacore/ui-pro-shared/components/button';
|
|
10
|
+
|
|
11
|
+
import { buttonHover, transition } from '../animations';
|
|
12
|
+
import { useCalendar } from '../contexts/calendar-context';
|
|
13
|
+
|
|
14
|
+
const MotionButton = motion.create(Button);
|
|
15
|
+
|
|
16
|
+
const monthShortFormatter = new Intl.DateTimeFormat(undefined, { month: 'short' });
|
|
17
|
+
|
|
18
|
+
export function TodayButton() {
|
|
19
|
+
const { setSelectedDate } = useCalendar();
|
|
20
|
+
const [today] = useState(() => new Date());
|
|
21
|
+
|
|
22
|
+
const handleClick = () => setSelectedDate(new Date());
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MotionButton
|
|
26
|
+
variant="outline"
|
|
27
|
+
className="flex size-14 flex-col items-center justify-center p-0 text-center"
|
|
28
|
+
onClick={handleClick}
|
|
29
|
+
variants={buttonHover}
|
|
30
|
+
whileHover="hover"
|
|
31
|
+
whileTap="tap"
|
|
32
|
+
transition={transition}>
|
|
33
|
+
<motion.span
|
|
34
|
+
className="w-full bg-primary py-1 text-xs font-semibold text-primary-foreground"
|
|
35
|
+
initial={{ y: -10, opacity: 0 }}
|
|
36
|
+
animate={{ y: 0, opacity: 1 }}
|
|
37
|
+
transition={{ delay: 0.1, ...transition }}>
|
|
38
|
+
{monthShortFormatter.format(today).toUpperCase()}
|
|
39
|
+
</motion.span>
|
|
40
|
+
<motion.span
|
|
41
|
+
className="text-lg font-bold"
|
|
42
|
+
initial={{ y: 10, opacity: 0 }}
|
|
43
|
+
animate={{ y: 0, opacity: 1 }}
|
|
44
|
+
transition={{ delay: 0.2, ...transition }}>
|
|
45
|
+
{today.getDate()}
|
|
46
|
+
</motion.span>
|
|
47
|
+
</MotionButton>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { Avatar, AvatarFallback, AvatarImage } from '@kivacore/ui-pro-shared/components/avatar';
|
|
6
|
+
import { AvatarGroup } from '@kivacore/ui-pro-shared/components/avatar-group';
|
|
7
|
+
import {
|
|
8
|
+
Select,
|
|
9
|
+
SelectContent,
|
|
10
|
+
SelectItem,
|
|
11
|
+
SelectTrigger,
|
|
12
|
+
SelectValue
|
|
13
|
+
} from '@kivacore/ui-pro-shared/components/select';
|
|
14
|
+
|
|
15
|
+
import { useUiTranslation } from '@kivacore/ui-pro-shared/hooks/kiva/use-ui-translation';
|
|
16
|
+
|
|
17
|
+
import { useCalendar } from '../contexts/calendar-context';
|
|
18
|
+
|
|
19
|
+
export function UserSelect() {
|
|
20
|
+
const ctx = useCalendar();
|
|
21
|
+
const {
|
|
22
|
+
users,
|
|
23
|
+
selectedUserId,
|
|
24
|
+
filterEventsBySelectedUser,
|
|
25
|
+
filterItems,
|
|
26
|
+
selectedFilterId,
|
|
27
|
+
onFilterChange,
|
|
28
|
+
renderFilterSelect
|
|
29
|
+
} = ctx;
|
|
30
|
+
const { t } = useUiTranslation();
|
|
31
|
+
|
|
32
|
+
if (renderFilterSelect) {
|
|
33
|
+
return <>{renderFilterSelect(ctx)}</>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (filterItems && filterItems.length > 0) {
|
|
37
|
+
return (
|
|
38
|
+
<Select value={selectedFilterId} onValueChange={id => onFilterChange?.(id)}>
|
|
39
|
+
<SelectTrigger className="w-auto min-w-28">
|
|
40
|
+
<SelectValue placeholder={t('ui.calendar.all', 'All')} />
|
|
41
|
+
</SelectTrigger>
|
|
42
|
+
<SelectContent align="end">
|
|
43
|
+
<SelectItem value="all">{t('ui.calendar.all', 'All')}</SelectItem>
|
|
44
|
+
{filterItems.map(item => (
|
|
45
|
+
<SelectItem
|
|
46
|
+
key={item.id}
|
|
47
|
+
value={item.id}
|
|
48
|
+
className="cursor-pointer">
|
|
49
|
+
<div className="flex items-center gap-2">
|
|
50
|
+
{item.image && (
|
|
51
|
+
<Avatar className="size-6">
|
|
52
|
+
<AvatarImage src={item.image} alt={item.label} />
|
|
53
|
+
<AvatarFallback className="text-xs">
|
|
54
|
+
{item.label[0]}
|
|
55
|
+
</AvatarFallback>
|
|
56
|
+
</Avatar>
|
|
57
|
+
)}
|
|
58
|
+
<p className="truncate">{item.label}</p>
|
|
59
|
+
</div>
|
|
60
|
+
</SelectItem>
|
|
61
|
+
))}
|
|
62
|
+
</SelectContent>
|
|
63
|
+
</Select>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Select value={selectedUserId} onValueChange={filterEventsBySelectedUser}>
|
|
69
|
+
<SelectTrigger className="w-auto min-w-28">
|
|
70
|
+
<SelectValue placeholder={t('ui.calendar.selectUser', 'Select user')} />
|
|
71
|
+
</SelectTrigger>
|
|
72
|
+
<SelectContent align="end">
|
|
73
|
+
<SelectItem value="all">
|
|
74
|
+
<AvatarGroup className="mx-2 flex items-center" max={3} size={24}>
|
|
75
|
+
{users.map(user => (
|
|
76
|
+
<Avatar key={user.id} className="size-6 text-xs">
|
|
77
|
+
<AvatarImage
|
|
78
|
+
src={user.picturePath ?? undefined}
|
|
79
|
+
alt={user.name} />
|
|
80
|
+
<AvatarFallback className="text-xs">
|
|
81
|
+
{user.name[0]}
|
|
82
|
+
</AvatarFallback>
|
|
83
|
+
</Avatar>
|
|
84
|
+
))}
|
|
85
|
+
</AvatarGroup>
|
|
86
|
+
{t('ui.calendar.all', 'All')}
|
|
87
|
+
</SelectItem>
|
|
88
|
+
|
|
89
|
+
{users.map(user => (
|
|
90
|
+
<SelectItem
|
|
91
|
+
key={user.id}
|
|
92
|
+
value={user.id}
|
|
93
|
+
className="flex-1 cursor-pointer">
|
|
94
|
+
<div className="flex items-center gap-2">
|
|
95
|
+
<Avatar key={user.id} className="size-6">
|
|
96
|
+
<AvatarImage
|
|
97
|
+
src={user.picturePath ?? undefined}
|
|
98
|
+
alt={user.name} />
|
|
99
|
+
<AvatarFallback className="text-xs">
|
|
100
|
+
{user.name[0]}
|
|
101
|
+
</AvatarFallback>
|
|
102
|
+
</Avatar>
|
|
103
|
+
|
|
104
|
+
<p className="truncate">{user.name}</p>
|
|
105
|
+
</div>
|
|
106
|
+
</SelectItem>
|
|
107
|
+
))}
|
|
108
|
+
</SelectContent>
|
|
109
|
+
</Select>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { memo, type JSX } from 'react';
|
|
6
|
+
|
|
7
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
8
|
+
import {
|
|
9
|
+
CalendarDays,
|
|
10
|
+
CalendarRange,
|
|
11
|
+
ChartGantt,
|
|
12
|
+
Columns,
|
|
13
|
+
Grid2X2,
|
|
14
|
+
Grid3X3,
|
|
15
|
+
List,
|
|
16
|
+
Rows3
|
|
17
|
+
} from 'lucide-react';
|
|
18
|
+
|
|
19
|
+
import { Tabs, TabsList, TabsTrigger } from '@kivacore/ui-pro-shared/components/tabs';
|
|
20
|
+
import { cn } from '@kivacore/ui-pro-shared/lib/utils';
|
|
21
|
+
|
|
22
|
+
import { useUiTranslation } from '@kivacore/ui-pro-shared/hooks/kiva/use-ui-translation';
|
|
23
|
+
|
|
24
|
+
import { type TCalendarView } from '../types';
|
|
25
|
+
import { useCalendar } from '../contexts/calendar-context';
|
|
26
|
+
|
|
27
|
+
const tabs: Array<{
|
|
28
|
+
i18nKey: string; fallback: string; value: string; icon: () => JSX.Element;
|
|
29
|
+
}> = [
|
|
30
|
+
{
|
|
31
|
+
i18nKey: 'ui.calendar.viewAgenda',
|
|
32
|
+
fallback: 'Agenda',
|
|
33
|
+
value: 'agenda',
|
|
34
|
+
icon: () => <CalendarRange className="size-4" />
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
i18nKey: 'ui.calendar.viewDay',
|
|
38
|
+
fallback: 'Day',
|
|
39
|
+
value: 'day',
|
|
40
|
+
icon: () => <List className="size-4" />
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
i18nKey: 'ui.calendar.viewWeek',
|
|
44
|
+
fallback: 'Week',
|
|
45
|
+
value: 'week',
|
|
46
|
+
icon: () => <Columns className="size-4" />
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
i18nKey: 'ui.calendar.viewMonth',
|
|
50
|
+
fallback: 'Month',
|
|
51
|
+
value: 'month',
|
|
52
|
+
icon: () => <Grid3X3 className="size-4" />
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
i18nKey: 'ui.calendar.viewYear',
|
|
56
|
+
fallback: 'Year',
|
|
57
|
+
value: 'year',
|
|
58
|
+
icon: () => <Grid2X2 className="size-4" />
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
i18nKey: 'ui.calendar.viewYearTimeline',
|
|
62
|
+
fallback: 'Year Timeline',
|
|
63
|
+
value: 'year-timeline',
|
|
64
|
+
icon: () => <ChartGantt className="size-4" />
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
i18nKey: 'ui.calendar.viewQuarter',
|
|
68
|
+
fallback: 'Quarter',
|
|
69
|
+
value: 'quarter',
|
|
70
|
+
icon: () => <CalendarDays className="size-4" />
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
i18nKey: 'ui.calendar.view13Weeks',
|
|
74
|
+
fallback: '13 Weeks',
|
|
75
|
+
value: '13weeks',
|
|
76
|
+
icon: () => <Rows3 className="size-4" />
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
function Views() {
|
|
81
|
+
const { view, setView, visibleViews } = useCalendar();
|
|
82
|
+
const { t } = useUiTranslation();
|
|
83
|
+
|
|
84
|
+
const filteredTabs = visibleViews ? tabs.filter(tab => visibleViews.includes(tab.value as TCalendarView)) : tabs;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Tabs
|
|
88
|
+
value={view}
|
|
89
|
+
onValueChange={value => setView(value as TCalendarView)}
|
|
90
|
+
className="gap-4 sm:w-auto w-full">
|
|
91
|
+
<TabsList className="h-auto gap-2 rounded-xl p-1 w-full">
|
|
92
|
+
{filteredTabs.map(({
|
|
93
|
+
icon: Icon, i18nKey, fallback, value
|
|
94
|
+
}) => {
|
|
95
|
+
const isActive = view === value;
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<motion.div
|
|
99
|
+
key={value}
|
|
100
|
+
layout
|
|
101
|
+
className={cn(
|
|
102
|
+
'flex h-8 items-center justify-center overflow-hidden rounded-md',
|
|
103
|
+
isActive ? 'flex-1' : 'flex-none'
|
|
104
|
+
)}
|
|
105
|
+
onClick={() => setView(value as TCalendarView)}
|
|
106
|
+
initial={false}
|
|
107
|
+
animate={{
|
|
108
|
+
width: isActive ? 120 : 32
|
|
109
|
+
}}
|
|
110
|
+
transition={{
|
|
111
|
+
type: 'tween',
|
|
112
|
+
stiffness: 400,
|
|
113
|
+
damping: 25
|
|
114
|
+
}}>
|
|
115
|
+
<TabsTrigger value={value} asChild>
|
|
116
|
+
<motion.div
|
|
117
|
+
className="flex h-8 w-full items-center justify-center cursor-pointer"
|
|
118
|
+
animate={{ filter: 'blur(0px)' }}
|
|
119
|
+
exit={{ filter: 'blur(2px)' }}
|
|
120
|
+
transition={{ duration: 0.25, ease: 'easeOut' }}>
|
|
121
|
+
<Icon />
|
|
122
|
+
<AnimatePresence initial={false}>
|
|
123
|
+
{isActive && (
|
|
124
|
+
<motion.span
|
|
125
|
+
className="font-medium"
|
|
126
|
+
initial={{ opacity: 0, scaleX: 0.8 }}
|
|
127
|
+
animate={{ opacity: 1, scaleX: 1 }}
|
|
128
|
+
transition={{ duration: 0.25, ease: 'easeOut' }}
|
|
129
|
+
style={{ originX: 0 }}>
|
|
130
|
+
{t(i18nKey, fallback)}
|
|
131
|
+
</motion.span>
|
|
132
|
+
)}
|
|
133
|
+
</AnimatePresence>
|
|
134
|
+
</motion.div>
|
|
135
|
+
</TabsTrigger>
|
|
136
|
+
</motion.div>
|
|
137
|
+
);
|
|
138
|
+
})}
|
|
139
|
+
</TabsList>
|
|
140
|
+
</Tabs>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export default memo(Views);
|