@monkey-mini-app/ui 0.1.0 → 0.1.4
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/README.md +58 -0
- package/dist/globals.css +1 -1
- package/dist/index.js +12 -2
- package/dist/manifest.json +6 -6
- package/dist/runtime.js +9 -0
- package/dist/sdk.js +158 -0
- package/dist/src/blocks/activity-feed.tsx +7 -0
- package/dist/src/blocks/app-shell.tsx +1 -0
- package/dist/src/blocks/attachment-gallery.tsx +7 -0
- package/dist/src/blocks/bar-chart.tsx +15 -1
- package/dist/src/blocks/comment-thread.tsx +7 -0
- package/dist/src/blocks/dashboard-shell.tsx +109 -0
- package/dist/src/blocks/description-list.tsx +7 -0
- package/dist/src/blocks/detail-panel.tsx +1 -0
- package/dist/src/blocks/donut-chart.tsx +19 -2
- package/dist/src/blocks/env-badge.tsx +7 -0
- package/dist/src/blocks/env-table.tsx +316 -0
- package/dist/src/blocks/file-tree.tsx +7 -0
- package/dist/src/blocks/filter-bar.tsx +1 -0
- package/dist/src/blocks/form-sheet.tsx +160 -0
- package/dist/src/blocks/gauge.tsx +29 -6
- package/dist/src/blocks/list-detail.tsx +121 -0
- package/dist/src/blocks/notification-center.tsx +7 -0
- package/dist/src/blocks/page-header.tsx +1 -0
- package/dist/src/blocks/progress-ring.tsx +20 -2
- package/dist/src/blocks/radar-chart.tsx +18 -1
- package/dist/src/blocks/request-inspector.tsx +7 -0
- package/dist/src/blocks/reveal.tsx +56 -0
- package/dist/src/blocks/run-timeline.tsx +7 -0
- package/dist/src/blocks/scrollspy.tsx +7 -0
- package/dist/src/blocks/settings-split.tsx +154 -0
- package/dist/src/blocks/severity-chip.tsx +7 -0
- package/dist/src/blocks/sparkline.tsx +12 -3
- package/dist/src/blocks/stat-card.tsx +1 -0
- package/dist/src/blocks/status-badge.tsx +1 -0
- package/dist/src/blocks/table-page.tsx +83 -0
- package/dist/src/blocks/terminal.tsx +21 -3
- package/dist/src/blocks/test-step-list.tsx +7 -0
- package/dist/src/blocks/trend-card.tsx +7 -0
- package/dist/src/blocks/wizard-shell.tsx +132 -0
- package/dist/src/cdn-modules.d.ts +5 -0
- package/dist/src/components/accordion.tsx +7 -0
- package/dist/src/components/alert-dialog.tsx +7 -0
- package/dist/src/components/alert.tsx +7 -0
- package/dist/src/components/aspect-ratio.tsx +4 -0
- package/dist/src/components/attachment.tsx +4 -0
- package/dist/src/components/avatar.tsx +4 -0
- package/dist/src/components/badge.tsx +7 -0
- package/dist/src/components/breadcrumb.tsx +4 -0
- package/dist/src/components/bubble.tsx +4 -0
- package/dist/src/components/button-group.tsx +6 -0
- package/dist/src/components/button.tsx +7 -0
- package/dist/src/components/calendar.tsx +4 -0
- package/dist/src/components/card.tsx +8 -1
- package/dist/src/components/chart.tsx +7 -0
- package/dist/src/components/checkbox.tsx +5 -0
- package/dist/src/components/collapsible.tsx +4 -0
- package/dist/src/components/combobox.tsx +4 -0
- package/dist/src/components/command.tsx +6 -0
- package/dist/src/components/context-menu.tsx +4 -0
- package/dist/src/components/dialog.tsx +21 -0
- package/dist/src/components/drawer.tsx +4 -0
- package/dist/src/components/dropdown-menu.tsx +7 -0
- package/dist/src/components/empty.tsx +7 -0
- package/dist/src/components/field.tsx +6 -0
- package/dist/src/components/hover-card.tsx +4 -0
- package/dist/src/components/input-group.tsx +4 -0
- package/dist/src/components/input.tsx +7 -0
- package/dist/src/components/item.tsx +4 -0
- package/dist/src/components/kbd.tsx +4 -0
- package/dist/src/components/label.tsx +7 -0
- package/dist/src/components/marker.tsx +4 -0
- package/dist/src/components/menubar.tsx +4 -0
- package/dist/src/components/message-scroller.tsx +4 -0
- package/dist/src/components/message.tsx +4 -0
- package/dist/src/components/native-select.tsx +4 -0
- package/dist/src/components/navigation-menu.tsx +4 -0
- package/dist/src/components/pagination.tsx +4 -0
- package/dist/src/components/popover.tsx +7 -0
- package/dist/src/components/progress.tsx +7 -0
- package/dist/src/components/questionnaire.tsx +4 -0
- package/dist/src/components/radio-group.tsx +4 -0
- package/dist/src/components/resizable.tsx +7 -0
- package/dist/src/components/scroll-area.tsx +4 -0
- package/dist/src/components/select.tsx +7 -0
- package/dist/src/components/separator.tsx +5 -0
- package/dist/src/components/sheet.tsx +22 -0
- package/dist/src/components/sidebar.tsx +4 -0
- package/dist/src/components/skeleton.tsx +7 -0
- package/dist/src/components/slider.tsx +4 -0
- package/dist/src/components/spinner.tsx +6 -0
- package/dist/src/components/switch.tsx +7 -0
- package/dist/src/components/table.tsx +7 -0
- package/dist/src/components/tabs.tsx +7 -0
- package/dist/src/components/textarea.tsx +7 -0
- package/dist/src/components/toast.tsx +7 -0
- package/dist/src/components/toggle-group.tsx +4 -0
- package/dist/src/components/toggle.tsx +4 -0
- package/dist/src/components/tooltip.tsx +7 -0
- package/dist/src/composites/autocomplete.tsx +7 -0
- package/dist/src/composites/cascader.tsx +7 -0
- package/dist/src/composites/color-picker.tsx +7 -0
- package/dist/src/composites/confirm-dialog.tsx +7 -0
- package/dist/src/composites/copyable.tsx +9 -1
- package/dist/src/composites/currency-input.tsx +7 -0
- package/dist/src/composites/date-picker.tsx +7 -0
- package/dist/src/composites/date-range-picker.tsx +4 -0
- package/dist/src/composites/date-time-picker.tsx +7 -0
- package/dist/src/composites/date-time-range-picker.tsx +7 -0
- package/dist/src/composites/duration-input.tsx +7 -0
- package/dist/src/composites/mini-calendar.tsx +7 -0
- package/dist/src/composites/number-field.tsx +7 -0
- package/dist/src/composites/password-field.tsx +7 -0
- package/dist/src/composites/phone-input.tsx +7 -0
- package/dist/src/composites/rating.tsx +7 -0
- package/dist/src/composites/relative-date-picker.tsx +7 -0
- package/dist/src/composites/search-input.tsx +7 -0
- package/dist/src/composites/slider-range.tsx +7 -0
- package/dist/src/composites/tag-input.tsx +7 -0
- package/dist/src/composites/time-picker.tsx +11 -1
- package/dist/src/composites/time-range-picker.tsx +7 -0
- package/dist/src/composites/timezone-select.tsx +7 -0
- package/dist/src/composites/transfer.tsx +7 -0
- package/dist/src/composites/user-picker.tsx +7 -0
- package/dist/src/hooks/use-html-dark.ts +37 -0
- package/dist/src/hooks/use-mobile.ts +3 -0
- package/dist/src/i18n/en.ts +109 -2
- package/dist/src/i18n/zh.ts +99 -2
- package/dist/src/index.ts +147 -134
- package/dist/src/lib/clipboard.ts +10 -0
- package/dist/src/lib/illustrations.tsx +2 -2
- package/dist/src/products/code-block.tsx +35 -18
- package/dist/src/products/code-editor.tsx +156 -24
- package/dist/src/products/commit-graph.tsx +644 -0
- package/dist/src/products/data-grid.tsx +2 -1
- package/dist/src/products/diff-viewer.tsx +104 -8
- package/dist/src/products/event-calendar.tsx +28 -823
- package/dist/src/products/file-dropzone.tsx +7 -0
- package/dist/src/products/full-calendar/animations.ts +38 -0
- package/dist/src/products/full-calendar/calendar-body.tsx +77 -0
- package/dist/src/products/full-calendar/constants.ts +10 -0
- package/dist/src/products/full-calendar/contexts/calendar-context.tsx +255 -0
- package/dist/src/products/full-calendar/contexts/dnd-context.tsx +157 -0
- package/dist/src/products/full-calendar/dialogs/add-edit-event-dialog.tsx +187 -0
- package/dist/src/products/full-calendar/dialogs/delete-event-dialog.tsx +39 -0
- package/dist/src/products/full-calendar/dialogs/event-details-dialog.tsx +100 -0
- package/dist/src/products/full-calendar/dialogs/events-list-dialog.tsx +87 -0
- package/dist/src/products/full-calendar/dnd/draggable-event.tsx +45 -0
- package/dist/src/products/full-calendar/dnd/droppable-area.tsx +45 -0
- package/dist/src/products/full-calendar/dnd/resizable-event.tsx +179 -0
- package/dist/src/products/full-calendar/header/calendar-header.tsx +65 -0
- package/dist/src/products/full-calendar/header/date-navigator.tsx +110 -0
- package/dist/src/products/full-calendar/header/filter.tsx +58 -0
- package/dist/src/products/full-calendar/header/today-button.tsx +45 -0
- package/dist/src/products/full-calendar/header/user-select.tsx +64 -0
- package/dist/src/products/full-calendar/header/view-tabs.tsx +36 -0
- package/dist/src/products/full-calendar/helpers.ts +453 -0
- package/dist/src/products/full-calendar/hooks/use-time-range-create.ts +152 -0
- package/dist/src/products/full-calendar/hooks.ts +70 -0
- package/dist/src/products/full-calendar/interfaces.ts +23 -0
- package/dist/src/products/full-calendar/settings/settings.tsx +80 -0
- package/dist/src/products/full-calendar/shims/avatar-group.tsx +16 -0
- package/dist/src/products/full-calendar/shims/day-picker.tsx +1 -0
- package/dist/src/products/full-calendar/shims/motion.tsx +97 -0
- package/dist/src/products/full-calendar/shims/next-themes.ts +6 -0
- package/dist/src/products/full-calendar/shims/re-resizable.tsx +25 -0
- package/dist/src/products/full-calendar/shims/sonner.ts +4 -0
- package/dist/src/products/full-calendar/types.ts +8 -0
- package/dist/src/products/full-calendar/views/agenda-view/agenda-events.tsx +140 -0
- package/dist/src/products/full-calendar/views/month-view/calendar-month-view.tsx +69 -0
- package/dist/src/products/full-calendar/views/month-view/day-cell.tsx +201 -0
- package/dist/src/products/full-calendar/views/month-view/event-bullet.tsx +40 -0
- package/dist/src/products/full-calendar/views/month-view/month-event-badge.tsx +143 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-day-view.tsx +295 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-time-line.tsx +35 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/calendar-week-view.tsx +253 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/day-view-multi-day-events-row.tsx +73 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/event-block.tsx +114 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/render-grouped-events.tsx +49 -0
- package/dist/src/products/full-calendar/views/week-and-day-view/week-view-multi-day-events-row.tsx +143 -0
- package/dist/src/products/full-calendar/views/year-view/calendar-year-view.tsx +161 -0
- package/dist/src/products/gantt.tsx +7 -0
- package/dist/src/products/jira-wiki.tsx +1 -0
- package/dist/src/products/jql-input.tsx +340 -37
- package/dist/src/products/json-viewer.tsx +7 -0
- package/dist/src/products/kanban-issue-panel.tsx +7 -0
- package/dist/src/products/kanban.tsx +1 -0
- package/dist/src/products/log-viewer.tsx +390 -18
- package/dist/src/products/markdown-editor.tsx +21 -6
- package/dist/src/products/markdown.tsx +7 -0
- package/dist/src/products/rich-text-editor.tsx +65 -59
- package/dist/src/products/sortable-list.tsx +7 -0
- package/dist/src/products/stepper.tsx +219 -70
- package/dist/src/products/timeline.tsx +7 -0
- package/dist/src/products/tree-view.tsx +7 -0
- package/dist/src/sdk/app-error-boundary.tsx +240 -0
- package/dist/src/sdk/app-id.ts +7 -0
- package/dist/src/sdk/use-app.ts +126 -0
- package/dist/src/styles/globals.css +7 -7
- package/dist/vendors/lodash.js +20 -0
- package/dist/vendors/motion.js +12 -0
- package/package.json +23 -19
- package/dist/src/products/jql-language.ts +0 -70
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { motion } from "../shims/motion";
|
|
4
|
+
import { Plus } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import { Button } from "@monkey-mini-app/ui/components/button";
|
|
7
|
+
import { useLabels } from "@monkey-mini-app/ui/i18n/context";
|
|
8
|
+
import {
|
|
9
|
+
slideFromLeft,
|
|
10
|
+
slideFromRight,
|
|
11
|
+
transition,
|
|
12
|
+
} from "../animations";
|
|
13
|
+
import { useCalendar } from "../contexts/calendar-context";
|
|
14
|
+
import { AddEditEventDialog } from "../dialogs/add-edit-event-dialog";
|
|
15
|
+
import { DateNavigator } from "./date-navigator";
|
|
16
|
+
import FilterEvents from "./filter";
|
|
17
|
+
import { TodayButton } from "./today-button";
|
|
18
|
+
import { UserSelect } from "./user-select";
|
|
19
|
+
import { Settings } from "../settings/settings";
|
|
20
|
+
import Views from "./view-tabs";
|
|
21
|
+
|
|
22
|
+
export function CalendarHeader() {
|
|
23
|
+
const { view, events, users } = useCalendar();
|
|
24
|
+
const t = useLabels("eventCalendar");
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className="flex flex-col gap-4 border-b p-4 lg:flex-row lg:items-center lg:justify-between">
|
|
28
|
+
<motion.div
|
|
29
|
+
className="flex items-center gap-3"
|
|
30
|
+
variants={slideFromLeft}
|
|
31
|
+
initial="initial"
|
|
32
|
+
animate="animate"
|
|
33
|
+
transition={transition}
|
|
34
|
+
>
|
|
35
|
+
<TodayButton />
|
|
36
|
+
<DateNavigator view={view} events={events} />
|
|
37
|
+
</motion.div>
|
|
38
|
+
|
|
39
|
+
<motion.div
|
|
40
|
+
className="flex flex-col gap-4 lg:flex-row lg:items-center lg:gap-1.5"
|
|
41
|
+
variants={slideFromRight}
|
|
42
|
+
initial="initial"
|
|
43
|
+
animate="animate"
|
|
44
|
+
transition={transition}
|
|
45
|
+
>
|
|
46
|
+
<div className="options flex-wrap flex items-center gap-4 md:gap-2">
|
|
47
|
+
<FilterEvents />
|
|
48
|
+
<Views />
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:gap-1.5">
|
|
52
|
+
{users.length > 0 ? <UserSelect /> : null}
|
|
53
|
+
|
|
54
|
+
<AddEditEventDialog>
|
|
55
|
+
<Button data-testid="calendar-add-event">
|
|
56
|
+
<Plus className="h-4 w-4" />
|
|
57
|
+
{t.addEvent}
|
|
58
|
+
</Button>
|
|
59
|
+
</AddEditEventDialog>
|
|
60
|
+
</div>
|
|
61
|
+
<Settings />
|
|
62
|
+
</motion.div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { formatDate } from "date-fns";
|
|
2
|
+
import { AnimatePresence, motion } from "../shims/motion";
|
|
3
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { Badge } from "@monkey-mini-app/ui/components/badge";
|
|
6
|
+
import { Button } from "@monkey-mini-app/ui/components/button";
|
|
7
|
+
import { useDateLocale, useLabels } from "@monkey-mini-app/ui/i18n/context";
|
|
8
|
+
import { buttonHover, transition } from "../animations";
|
|
9
|
+
import { useCalendar } from "../contexts/calendar-context";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
getEventsCount,
|
|
13
|
+
navigateDate,
|
|
14
|
+
rangeText,
|
|
15
|
+
} from "../helpers";
|
|
16
|
+
|
|
17
|
+
import type { IEvent } from "../interfaces";
|
|
18
|
+
import type { TCalendarView } from "../types";
|
|
19
|
+
|
|
20
|
+
interface IProps {
|
|
21
|
+
view: TCalendarView;
|
|
22
|
+
events: IEvent[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const MotionButton = motion.create(Button);
|
|
26
|
+
const MotionBadge = motion.create(Badge);
|
|
27
|
+
|
|
28
|
+
export function DateNavigator({ view, events }: IProps) {
|
|
29
|
+
const { selectedDate, setSelectedDate } = useCalendar();
|
|
30
|
+
const t = useLabels("eventCalendar");
|
|
31
|
+
const dateLocale = useDateLocale();
|
|
32
|
+
|
|
33
|
+
const month = formatDate(selectedDate, "MMMM", { locale: dateLocale });
|
|
34
|
+
const year = selectedDate.getFullYear();
|
|
35
|
+
|
|
36
|
+
const eventCount = useMemo(
|
|
37
|
+
() => getEventsCount(events, selectedDate, view),
|
|
38
|
+
[events, selectedDate, view],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const handlePrevious = () =>
|
|
42
|
+
setSelectedDate(navigateDate(selectedDate, view, "previous"));
|
|
43
|
+
const handleNext = () =>
|
|
44
|
+
setSelectedDate(navigateDate(selectedDate, view, "next"));
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className="space-y-0.5">
|
|
48
|
+
<div className="flex items-center gap-2">
|
|
49
|
+
<motion.span
|
|
50
|
+
className="text-lg font-semibold"
|
|
51
|
+
initial={{ x: -20, opacity: 0 }}
|
|
52
|
+
animate={{ x: 0, opacity: 1 }}
|
|
53
|
+
transition={transition}
|
|
54
|
+
>
|
|
55
|
+
{month} {year}
|
|
56
|
+
</motion.span>
|
|
57
|
+
<AnimatePresence mode="wait">
|
|
58
|
+
<MotionBadge
|
|
59
|
+
key={eventCount}
|
|
60
|
+
variant="secondary"
|
|
61
|
+
initial={{ scale: 0.8, opacity: 0 }}
|
|
62
|
+
animate={{ scale: 1, opacity: 1 }}
|
|
63
|
+
exit={{ scale: 0.8, opacity: 0 }}
|
|
64
|
+
transition={transition}
|
|
65
|
+
>
|
|
66
|
+
{t.eventsCount(eventCount)}
|
|
67
|
+
</MotionBadge>
|
|
68
|
+
</AnimatePresence>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div className="flex items-center gap-2">
|
|
72
|
+
<MotionButton
|
|
73
|
+
variant="outline"
|
|
74
|
+
size="icon"
|
|
75
|
+
className="h-6 w-6"
|
|
76
|
+
onClick={handlePrevious}
|
|
77
|
+
variants={buttonHover}
|
|
78
|
+
whileHover="hover"
|
|
79
|
+
whileTap="tap"
|
|
80
|
+
>
|
|
81
|
+
<ChevronLeft className="h-4 w-4" />
|
|
82
|
+
</MotionButton>
|
|
83
|
+
|
|
84
|
+
<motion.p
|
|
85
|
+
className="text-sm text-muted-foreground"
|
|
86
|
+
initial={{ opacity: 0 }}
|
|
87
|
+
animate={{ opacity: 1 }}
|
|
88
|
+
transition={transition}
|
|
89
|
+
>
|
|
90
|
+
{rangeText(view, selectedDate, {
|
|
91
|
+
locale: dateLocale,
|
|
92
|
+
formatError: t.formatError,
|
|
93
|
+
})}
|
|
94
|
+
</motion.p>
|
|
95
|
+
|
|
96
|
+
<MotionButton
|
|
97
|
+
variant="outline"
|
|
98
|
+
size="icon"
|
|
99
|
+
className="h-6 w-6"
|
|
100
|
+
onClick={handleNext}
|
|
101
|
+
variants={buttonHover}
|
|
102
|
+
whileHover="hover"
|
|
103
|
+
whileTap="tap"
|
|
104
|
+
>
|
|
105
|
+
<ChevronRight className="h-4 w-4" />
|
|
106
|
+
</MotionButton>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CheckIcon, Filter, RefreshCcw } from "lucide-react"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuTrigger,
|
|
8
|
+
} from "@monkey-mini-app/ui/components/dropdown-menu"
|
|
9
|
+
import { Separator } from "@monkey-mini-app/ui/components/separator"
|
|
10
|
+
import { useLabels } from "@monkey-mini-app/ui/i18n/context"
|
|
11
|
+
|
|
12
|
+
import { useCalendar } from "../contexts/calendar-context"
|
|
13
|
+
import type { TEventColor } from "../types"
|
|
14
|
+
|
|
15
|
+
const COLORS: TEventColor[] = ["blue", "green", "red", "yellow", "purple", "orange"]
|
|
16
|
+
|
|
17
|
+
export default function FilterEvents() {
|
|
18
|
+
const { selectedColors, filterEventsBySelectedColors, clearFilter } = useCalendar()
|
|
19
|
+
const t = useLabels("eventCalendar")
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<DropdownMenu>
|
|
23
|
+
<DropdownMenuTrigger className="inline-flex size-8 items-center justify-center rounded-lg border border-border bg-background">
|
|
24
|
+
<Filter className="h-4 w-4" />
|
|
25
|
+
</DropdownMenuTrigger>
|
|
26
|
+
<DropdownMenuContent align="end" className="w-[150px]">
|
|
27
|
+
{COLORS.map((color) => (
|
|
28
|
+
<DropdownMenuItem
|
|
29
|
+
key={color}
|
|
30
|
+
className="flex cursor-pointer items-center gap-2"
|
|
31
|
+
onClick={(e) => {
|
|
32
|
+
e.preventDefault()
|
|
33
|
+
filterEventsBySelectedColors(color)
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
<span className="size-3.5 rounded-full" style={{ backgroundColor: color }} />
|
|
37
|
+
<span className="flex items-center gap-2 capitalize">
|
|
38
|
+
{color}
|
|
39
|
+
{selectedColors.includes(color) ? <CheckIcon className="size-4 text-blue-500" /> : null}
|
|
40
|
+
</span>
|
|
41
|
+
</DropdownMenuItem>
|
|
42
|
+
))}
|
|
43
|
+
<Separator className="my-2" />
|
|
44
|
+
<DropdownMenuItem
|
|
45
|
+
disabled={selectedColors.length === 0}
|
|
46
|
+
className="flex cursor-pointer gap-2"
|
|
47
|
+
onClick={(e) => {
|
|
48
|
+
e.preventDefault()
|
|
49
|
+
clearFilter()
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<RefreshCcw className="size-3.5" />
|
|
53
|
+
{t.clearFilter}
|
|
54
|
+
</DropdownMenuItem>
|
|
55
|
+
</DropdownMenuContent>
|
|
56
|
+
</DropdownMenu>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { formatDate } from "date-fns";
|
|
2
|
+
import { motion } from "../shims/motion";
|
|
3
|
+
import { Button } from "@monkey-mini-app/ui/components/button";
|
|
4
|
+
import { useDateLocale } from "@monkey-mini-app/ui/i18n/context";
|
|
5
|
+
import { buttonHover, transition } from "../animations";
|
|
6
|
+
import { useCalendar } from "../contexts/calendar-context";
|
|
7
|
+
|
|
8
|
+
const MotionButton = motion.create(Button);
|
|
9
|
+
|
|
10
|
+
export function TodayButton() {
|
|
11
|
+
const { setSelectedDate } = useCalendar();
|
|
12
|
+
const dateLocale = useDateLocale();
|
|
13
|
+
|
|
14
|
+
const today = new Date();
|
|
15
|
+
const handleClick = () => setSelectedDate(today);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<MotionButton
|
|
19
|
+
variant="outline"
|
|
20
|
+
className="flex h-14 w-14 flex-col items-center justify-center p-0 text-center"
|
|
21
|
+
onClick={handleClick}
|
|
22
|
+
variants={buttonHover}
|
|
23
|
+
whileHover="hover"
|
|
24
|
+
whileTap="tap"
|
|
25
|
+
transition={transition}
|
|
26
|
+
>
|
|
27
|
+
<motion.span
|
|
28
|
+
className="w-full bg-primary py-1 text-xs font-semibold text-primary-foreground"
|
|
29
|
+
initial={{ y: -10, opacity: 0 }}
|
|
30
|
+
animate={{ y: 0, opacity: 1 }}
|
|
31
|
+
transition={{ delay: 0.1, ...transition }}
|
|
32
|
+
>
|
|
33
|
+
{formatDate(today, "MMM", { locale: dateLocale }).toUpperCase()}
|
|
34
|
+
</motion.span>
|
|
35
|
+
<motion.span
|
|
36
|
+
className="text-lg font-bold"
|
|
37
|
+
initial={{ y: 10, opacity: 0 }}
|
|
38
|
+
animate={{ y: 0, opacity: 1 }}
|
|
39
|
+
transition={{ delay: 0.2, ...transition }}
|
|
40
|
+
>
|
|
41
|
+
{today.getDate()}
|
|
42
|
+
</motion.span>
|
|
43
|
+
</MotionButton>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@monkey-mini-app/ui/components/avatar";
|
|
2
|
+
import { AvatarGroup } from "../shims/avatar-group";
|
|
3
|
+
import {
|
|
4
|
+
Select,
|
|
5
|
+
SelectContent,
|
|
6
|
+
SelectItem,
|
|
7
|
+
SelectTrigger,
|
|
8
|
+
SelectValue,
|
|
9
|
+
} from "@monkey-mini-app/ui/components/select";
|
|
10
|
+
import { useLabels } from "@monkey-mini-app/ui/i18n/context";
|
|
11
|
+
import { useCalendar } from "../contexts/calendar-context";
|
|
12
|
+
|
|
13
|
+
export function UserSelect() {
|
|
14
|
+
const { users, selectedUserId, filterEventsBySelectedUser } = useCalendar();
|
|
15
|
+
const t = useLabels("eventCalendar");
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Select value={selectedUserId!} onValueChange={(value) => value && filterEventsBySelectedUser(value)}>
|
|
19
|
+
<SelectTrigger className="w-full">
|
|
20
|
+
<SelectValue placeholder={t.selectUser} />
|
|
21
|
+
</SelectTrigger>
|
|
22
|
+
<SelectContent align="end">
|
|
23
|
+
<SelectItem value="all">
|
|
24
|
+
<AvatarGroup className="mx-2 flex items-center" max={3}>
|
|
25
|
+
{users.map((user) => (
|
|
26
|
+
<Avatar key={user.id} className="size-6 text-xxs">
|
|
27
|
+
<AvatarImage
|
|
28
|
+
src={user.picturePath ?? undefined}
|
|
29
|
+
alt={user.name}
|
|
30
|
+
/>
|
|
31
|
+
<AvatarFallback className="text-xxs">
|
|
32
|
+
{user.name[0]}
|
|
33
|
+
</AvatarFallback>
|
|
34
|
+
</Avatar>
|
|
35
|
+
))}
|
|
36
|
+
</AvatarGroup>
|
|
37
|
+
{t.allUsers}
|
|
38
|
+
</SelectItem>
|
|
39
|
+
|
|
40
|
+
{users.map((user) => (
|
|
41
|
+
<SelectItem
|
|
42
|
+
key={user.id}
|
|
43
|
+
value={user.id}
|
|
44
|
+
className="flex-1 cursor-pointer"
|
|
45
|
+
>
|
|
46
|
+
<div className="flex items-center gap-2">
|
|
47
|
+
<Avatar key={user.id} className="size-6">
|
|
48
|
+
<AvatarImage
|
|
49
|
+
src={user.picturePath ?? undefined}
|
|
50
|
+
alt={user.name}
|
|
51
|
+
/>
|
|
52
|
+
<AvatarFallback className="text-xxs">
|
|
53
|
+
{user.name[0]}
|
|
54
|
+
</AvatarFallback>
|
|
55
|
+
</Avatar>
|
|
56
|
+
|
|
57
|
+
<p className="truncate">{user.name}</p>
|
|
58
|
+
</div>
|
|
59
|
+
</SelectItem>
|
|
60
|
+
))}
|
|
61
|
+
</SelectContent>
|
|
62
|
+
</Select>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { memo } from "react"
|
|
2
|
+
|
|
3
|
+
import { Button } from "@monkey-mini-app/ui/components/button"
|
|
4
|
+
import { useLabels } from "@monkey-mini-app/ui/i18n/context"
|
|
5
|
+
|
|
6
|
+
import { useCalendar } from "../contexts/calendar-context"
|
|
7
|
+
import type { TCalendarView } from "../types"
|
|
8
|
+
|
|
9
|
+
function Views() {
|
|
10
|
+
const { view, setView } = useCalendar()
|
|
11
|
+
const t = useLabels("eventCalendar")
|
|
12
|
+
const tabs: { name: string; value: TCalendarView }[] = [
|
|
13
|
+
{ name: t.agenda, value: "agenda" },
|
|
14
|
+
{ name: t.day, value: "day" },
|
|
15
|
+
{ name: t.week, value: "week" },
|
|
16
|
+
{ name: t.month, value: "month" },
|
|
17
|
+
{ name: t.year, value: "year" },
|
|
18
|
+
]
|
|
19
|
+
return (
|
|
20
|
+
<div className="flex flex-wrap gap-1">
|
|
21
|
+
{tabs.map(({ name, value }) => (
|
|
22
|
+
<Button
|
|
23
|
+
key={value}
|
|
24
|
+
size="sm"
|
|
25
|
+
variant={view === value ? "default" : "outline"}
|
|
26
|
+
data-testid={`calendar-view-${value}`}
|
|
27
|
+
onClick={() => setView(value)}
|
|
28
|
+
>
|
|
29
|
+
{name}
|
|
30
|
+
</Button>
|
|
31
|
+
))}
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default memo(Views)
|