@g4rcez/components 5.0.1 → 5.0.2
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/components/core/button.d.ts +77 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.jsx +79 -0
- package/dist/components/core/heading.d.ts +3 -0
- package/dist/components/core/heading.d.ts.map +1 -0
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/polymorph.d.ts +10 -0
- package/dist/components/core/polymorph.d.ts.map +1 -0
- package/dist/components/core/polymorph.jsx +5 -0
- package/dist/components/core/render-on-view.d.ts +7 -0
- package/dist/components/core/render-on-view.d.ts.map +1 -0
- package/dist/components/core/render-on-view.jsx +31 -0
- package/dist/components/core/resizable.d.ts +3 -0
- package/dist/components/core/resizable.d.ts.map +1 -0
- package/dist/components/core/resizable.jsx +51 -0
- package/dist/components/core/slot.d.ts +16 -0
- package/dist/components/core/slot.d.ts.map +1 -0
- package/dist/components/core/slot.jsx +156 -0
- package/dist/components/core/tag.d.ts +35 -0
- package/dist/components/core/tag.d.ts.map +1 -0
- package/dist/components/core/tag.jsx +53 -0
- package/dist/components/core/typography.d.ts +25 -0
- package/dist/components/core/typography.d.ts.map +1 -0
- package/dist/components/core/typography.jsx +20 -0
- package/dist/components/display/alert.d.ts +28 -0
- package/dist/components/display/alert.d.ts.map +1 -0
- package/dist/components/display/alert.jsx +61 -0
- package/dist/components/display/calendar.d.ts +42 -0
- package/dist/components/display/calendar.d.ts.map +1 -0
- package/dist/components/display/calendar.jsx +318 -0
- package/dist/components/display/card.d.ts +29 -0
- package/dist/components/display/card.d.ts.map +1 -0
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +8 -0
- package/dist/components/display/empty.d.ts.map +1 -0
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +16 -0
- package/dist/components/display/list.d.ts.map +1 -0
- package/dist/components/display/list.jsx +85 -0
- package/dist/components/display/notifications.d.ts +27 -0
- package/dist/components/display/notifications.d.ts.map +1 -0
- package/dist/components/display/notifications.jsx +130 -0
- package/dist/components/display/progress.d.ts +16 -0
- package/dist/components/display/progress.d.ts.map +1 -0
- package/dist/components/display/progress.jsx +21 -0
- package/dist/components/display/shortcut.d.ts +4 -0
- package/dist/components/display/shortcut.d.ts.map +1 -0
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +12 -0
- package/dist/components/display/skeleton.d.ts.map +1 -0
- package/dist/components/display/skeleton.jsx +19 -0
- package/dist/components/display/spinner.d.ts +5 -0
- package/dist/components/display/spinner.d.ts.map +1 -0
- package/dist/components/display/spinner.jsx +11 -0
- package/dist/components/display/stats.d.ts +12 -0
- package/dist/components/display/stats.d.ts.map +1 -0
- package/dist/components/display/stats.jsx +16 -0
- package/dist/components/display/step.d.ts +24 -0
- package/dist/components/display/step.d.ts.map +1 -0
- package/dist/components/display/step.jsx +145 -0
- package/dist/components/display/tabs.d.ts +24 -0
- package/dist/components/display/tabs.d.ts.map +1 -0
- package/dist/components/display/tabs.jsx +125 -0
- package/dist/components/display/timeline.d.ts +10 -0
- package/dist/components/display/timeline.d.ts.map +1 -0
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +49 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -0
- package/dist/components/floating/command-palette.jsx +223 -0
- package/dist/components/floating/dropdown.d.ts +15 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -0
- package/dist/components/floating/dropdown.jsx +56 -0
- package/dist/components/floating/expand.d.ts +11 -0
- package/dist/components/floating/expand.d.ts.map +1 -0
- package/dist/components/floating/expand.jsx +44 -0
- package/dist/components/floating/menu.d.ts +52 -0
- package/dist/components/floating/menu.d.ts.map +1 -0
- package/dist/components/floating/menu.jsx +165 -0
- package/dist/components/floating/modal.d.ts +60 -0
- package/dist/components/floating/modal.d.ts.map +1 -0
- package/dist/components/floating/modal.jsx +336 -0
- package/dist/components/floating/toolbar.d.ts +6 -0
- package/dist/components/floating/toolbar.d.ts.map +1 -0
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/tooltip.d.ts +17 -0
- package/dist/components/floating/tooltip.d.ts.map +1 -0
- package/dist/components/floating/tooltip.jsx +67 -0
- package/dist/components/floating/wizard.d.ts +26 -0
- package/dist/components/floating/wizard.d.ts.map +1 -0
- package/dist/components/floating/wizard.jsx +165 -0
- package/dist/components/form/autocomplete.d.ts +16 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -0
- package/dist/components/form/autocomplete.jsx +290 -0
- package/dist/components/form/checkbox.d.ts +12 -0
- package/dist/components/form/checkbox.d.ts.map +1 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/date-picker.d.ts +10 -0
- package/dist/components/form/date-picker.d.ts.map +1 -0
- package/dist/components/form/date-picker.jsx +115 -0
- package/dist/components/form/file-upload.d.ts +15 -0
- package/dist/components/form/file-upload.d.ts.map +1 -0
- package/dist/components/form/file-upload.jsx +138 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.jsx +10 -0
- package/dist/components/form/formReset.d.ts +2 -0
- package/dist/components/form/formReset.d.ts.map +1 -0
- package/dist/components/form/formReset.jsx +17 -0
- package/dist/components/form/free-text.d.ts +11 -0
- package/dist/components/form/free-text.d.ts.map +1 -0
- package/dist/components/form/free-text.jsx +41 -0
- package/dist/components/form/input-field.d.ts +34 -0
- package/dist/components/form/input-field.d.ts.map +1 -0
- package/dist/components/form/input-field.jsx +58 -0
- package/dist/components/form/input.d.ts +52 -0
- package/dist/components/form/input.d.ts.map +1 -0
- package/dist/components/form/input.jsx +36 -0
- package/dist/components/form/multi-select.d.ts +19 -0
- package/dist/components/form/multi-select.d.ts.map +1 -0
- package/dist/components/form/multi-select.jsx +344 -0
- package/dist/components/form/radiobox.d.ts +7 -0
- package/dist/components/form/radiobox.d.ts.map +1 -0
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.d.ts +13 -0
- package/dist/components/form/select.d.ts.map +1 -0
- package/dist/components/form/select.jsx +44 -0
- package/dist/components/form/slider.d.ts +7 -0
- package/dist/components/form/slider.d.ts.map +1 -0
- package/dist/components/form/slider.jsx +45 -0
- package/dist/components/form/switch.d.ts +9 -0
- package/dist/components/form/switch.d.ts.map +1 -0
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +3 -0
- package/dist/components/form/task-list.d.ts.map +1 -0
- package/dist/components/form/task-list.jsx +26 -0
- package/dist/components/form/textarea.d.ts +5 -0
- package/dist/components/form/textarea.d.ts.map +1 -0
- package/dist/components/form/textarea.jsx +26 -0
- package/dist/components/index.d.ts +45 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +44 -0
- package/dist/components/page-calendar/calendar-header.d.ts +16 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
- package/dist/components/page-calendar/calendar-header.jsx +83 -0
- package/dist/components/page-calendar/day-view.d.ts +12 -0
- package/dist/components/page-calendar/day-view.d.ts.map +1 -0
- package/dist/components/page-calendar/day-view.jsx +89 -0
- package/dist/components/page-calendar/event-pill.d.ts +9 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.d.ts +4 -0
- package/dist/components/page-calendar/index.d.ts.map +1 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.d.ts +11 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +46 -0
- package/dist/components/page-calendar/page-calendar.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts +24 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +93 -0
- package/dist/components/page-calendar/week-view.d.ts +11 -0
- package/dist/components/page-calendar/week-view.d.ts.map +1 -0
- package/dist/components/page-calendar/week-view.jsx +66 -0
- package/dist/components/table/filter.d.ts +42 -0
- package/dist/components/table/filter.d.ts.map +1 -0
- package/dist/components/table/filter.jsx +169 -0
- package/dist/components/table/group.d.ts +17 -0
- package/dist/components/table/group.d.ts.map +1 -0
- package/dist/components/table/group.jsx +75 -0
- package/dist/components/table/index.d.ts +19 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.jsx +63 -0
- package/dist/components/table/inner-table.d.ts +29 -0
- package/dist/components/table/inner-table.d.ts.map +1 -0
- package/dist/components/table/inner-table.jsx +102 -0
- package/dist/components/table/metadata.d.ts +4 -0
- package/dist/components/table/metadata.d.ts.map +1 -0
- package/dist/components/table/metadata.jsx +36 -0
- package/dist/components/table/pagination.d.ts +5 -0
- package/dist/components/table/pagination.d.ts.map +1 -0
- package/dist/components/table/pagination.jsx +74 -0
- package/dist/components/table/row.d.ts +11 -0
- package/dist/components/table/row.d.ts.map +1 -0
- package/dist/components/table/row.jsx +49 -0
- package/dist/components/table/sort.d.ts +28 -0
- package/dist/components/table/sort.d.ts.map +1 -0
- package/dist/components/table/sort.jsx +109 -0
- package/dist/components/table/table-lib.d.ts +135 -0
- package/dist/components/table/table-lib.d.ts.map +1 -0
- package/dist/components/table/table-lib.js +83 -0
- package/dist/components/table/table.context.d.ts +10 -0
- package/dist/components/table/table.context.d.ts.map +1 -0
- package/dist/components/table/table.context.jsx +5 -0
- package/dist/components/table/thead.d.ts +9 -0
- package/dist/components/table/thead.d.ts.map +1 -0
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/context.d.ts +21 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +12 -0
- package/dist/config/default-translations.d.ts +94 -0
- package/dist/config/default-translations.d.ts.map +1 -0
- package/dist/config/default-translations.jsx +87 -0
- package/dist/config/default-tweaks.d.ts +13 -0
- package/dist/config/default-tweaks.d.ts.map +1 -0
- package/dist/config/default-tweaks.js +4 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/hooks/use-click-outside.d.ts +3 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-click-outside.js +17 -0
- package/dist/hooks/use-color-parser.d.ts +2 -0
- package/dist/hooks/use-color-parser.d.ts.map +1 -0
- package/dist/hooks/use-color-parser.js +9 -0
- package/dist/hooks/use-components-provider.d.ts +15 -0
- package/dist/hooks/use-components-provider.d.ts.map +1 -0
- package/dist/hooks/use-components-provider.jsx +22 -0
- package/dist/hooks/use-debounce.d.ts +5 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +12 -0
- package/dist/hooks/use-floating-ref.d.ts +2 -0
- package/dist/hooks/use-floating-ref.d.ts.map +1 -0
- package/dist/hooks/use-floating-ref.js +6 -0
- package/dist/hooks/use-form.d.ts +394 -0
- package/dist/hooks/use-form.d.ts.map +1 -0
- package/dist/hooks/use-form.js +563 -0
- package/dist/hooks/use-hover.d.ts +3 -0
- package/dist/hooks/use-hover.d.ts.map +1 -0
- package/dist/hooks/use-hover.js +18 -0
- package/dist/hooks/use-input-id.d.ts +4 -0
- package/dist/hooks/use-input-id.d.ts.map +1 -0
- package/dist/hooks/use-input-id.js +5 -0
- package/dist/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/hooks/use-is-coarse-device.js +12 -0
- package/dist/hooks/use-locale.d.ts +3 -0
- package/dist/hooks/use-locale.d.ts.map +1 -0
- package/dist/hooks/use-locale.js +10 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-on-event.d.ts +4 -0
- package/dist/hooks/use-on-event.d.ts.map +1 -0
- package/dist/hooks/use-on-event.js +10 -0
- package/dist/hooks/use-parent.d.ts +3 -0
- package/dist/hooks/use-parent.d.ts.map +1 -0
- package/dist/hooks/use-parent.js +21 -0
- package/dist/hooks/use-preferences.d.ts +2 -0
- package/dist/hooks/use-preferences.d.ts.map +1 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/hooks/use-previous.d.ts +2 -0
- package/dist/hooks/use-previous.d.ts.map +1 -0
- package/dist/hooks/use-previous.js +9 -0
- package/dist/hooks/use-reactive.d.ts +2 -0
- package/dist/hooks/use-reactive.d.ts.map +1 -0
- package/dist/hooks/use-reactive.js +9 -0
- package/dist/hooks/use-remove-scroll.d.ts +4 -0
- package/dist/hooks/use-remove-scroll.d.ts.map +1 -0
- package/dist/hooks/use-remove-scroll.js +48 -0
- package/dist/hooks/use-resize-observer.d.ts +2 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-stable-ref.d.ts +2 -0
- package/dist/hooks/use-stable-ref.d.ts.map +1 -0
- package/dist/hooks/use-stable-ref.js +9 -0
- package/dist/hooks/use-swipe.d.ts +8 -0
- package/dist/hooks/use-swipe.d.ts.map +1 -0
- package/dist/hooks/use-swipe.js +17 -0
- package/dist/hooks/use-translations.d.ts +92 -0
- package/dist/hooks/use-translations.d.ts.map +1 -0
- package/dist/hooks/use-translations.js +9 -0
- package/dist/hooks/use-tweaks.d.ts +3 -0
- package/dist/hooks/use-tweaks.d.ts.map +1 -0
- package/dist/hooks/use-tweaks.js +9 -0
- package/dist/hooks/use-window-size.d.ts +5 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -7932
- package/dist/lib/combi-keys.d.ts +15 -0
- package/dist/lib/combi-keys.d.ts.map +1 -0
- package/dist/lib/combi-keys.js +60 -0
- package/dist/lib/dict.d.ts +9 -0
- package/dist/lib/dict.d.ts.map +1 -0
- package/dist/lib/dict.js +28 -0
- package/dist/lib/dom.d.ts +20 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +185 -0
- package/dist/lib/fns.d.ts +11 -0
- package/dist/lib/fns.d.ts.map +1 -0
- package/dist/lib/fns.js +46 -0
- package/dist/lib/fzf.d.ts +16 -0
- package/dist/lib/fzf.d.ts.map +1 -0
- package/dist/lib/fzf.js +115 -0
- package/dist/lib/keyboard-area.d.ts +16 -0
- package/dist/lib/keyboard-area.d.ts.map +1 -0
- package/dist/lib/keyboard-area.js +14 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { addDays, startOfMonth, startOfWeek, getISOWeek } from "date-fns";
|
|
2
|
+
export function toDateKey(d) {
|
|
3
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
4
|
+
}
|
|
5
|
+
export function groupEventsByDate(events) {
|
|
6
|
+
const map = new Map();
|
|
7
|
+
for (const event of events) {
|
|
8
|
+
const key = toDateKey(event.date);
|
|
9
|
+
const existing = map.get(key);
|
|
10
|
+
if (existing) {
|
|
11
|
+
existing.push(event);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
map.set(key, [event]);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return map;
|
|
18
|
+
}
|
|
19
|
+
export function getMonthDays(date) {
|
|
20
|
+
const monthStart = startOfMonth(date);
|
|
21
|
+
const gridStart = startOfWeek(monthStart, { weekStartsOn: 1 });
|
|
22
|
+
const days = [];
|
|
23
|
+
for (let i = 0; i < 42; i++) {
|
|
24
|
+
days.push(addDays(gridStart, i));
|
|
25
|
+
}
|
|
26
|
+
return days;
|
|
27
|
+
}
|
|
28
|
+
export function getWeekDays(date) {
|
|
29
|
+
const weekStart = startOfWeek(date, { weekStartsOn: 1 });
|
|
30
|
+
const days = [];
|
|
31
|
+
for (let i = 0; i < 7; i++) {
|
|
32
|
+
days.push(addDays(weekStart, i));
|
|
33
|
+
}
|
|
34
|
+
return days;
|
|
35
|
+
}
|
|
36
|
+
export function getHourSlots() {
|
|
37
|
+
return Array.from({ length: 24 }, (_, i) => i);
|
|
38
|
+
}
|
|
39
|
+
export function formatEventTime(date, locale) {
|
|
40
|
+
return new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit", hour12: false }).format(new Date(date));
|
|
41
|
+
}
|
|
42
|
+
export function formatDay(date, locale) {
|
|
43
|
+
return new Intl.DateTimeFormat(locale, { day: "numeric" }).format(date);
|
|
44
|
+
}
|
|
45
|
+
export function formatWeekDay(date, locale) {
|
|
46
|
+
return new Intl.DateTimeFormat(locale, { weekday: "short" }).format(date);
|
|
47
|
+
}
|
|
48
|
+
export function formatWeekdayLong(date, locale) {
|
|
49
|
+
return new Intl.DateTimeFormat(locale, { weekday: "long" }).format(date);
|
|
50
|
+
}
|
|
51
|
+
export function formatWeekdayShort(date, locale) {
|
|
52
|
+
return new Intl.DateTimeFormat(locale, { weekday: "short" }).format(date);
|
|
53
|
+
}
|
|
54
|
+
export function formatMonthYear(date, locale) {
|
|
55
|
+
return new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(date);
|
|
56
|
+
}
|
|
57
|
+
export function formatMonthShort(date, locale) {
|
|
58
|
+
return new Intl.DateTimeFormat(locale, { month: "short" }).format(date);
|
|
59
|
+
}
|
|
60
|
+
export function formatHourLabel(hour, locale) {
|
|
61
|
+
return new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit", hour12: false }).format(new Date(0, 0, 0, hour));
|
|
62
|
+
}
|
|
63
|
+
export function formatFullDate(date, locale) {
|
|
64
|
+
return new Intl.DateTimeFormat(locale, { weekday: "long", month: "short", day: "numeric", year: "numeric" }).format(date);
|
|
65
|
+
}
|
|
66
|
+
export function formatTime(date, locale) {
|
|
67
|
+
return new Intl.DateTimeFormat(locale, { hour: "2-digit", minute: "2-digit", hour12: false }).format(date);
|
|
68
|
+
}
|
|
69
|
+
export function getWeekNumber(date) {
|
|
70
|
+
return getISOWeek(date);
|
|
71
|
+
}
|
|
72
|
+
export function computeEventColumns(events) {
|
|
73
|
+
const sorted = [...events].sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
74
|
+
const hourGroups = new Map();
|
|
75
|
+
for (const event of sorted) {
|
|
76
|
+
const hour = event.date.getHours();
|
|
77
|
+
const group = hourGroups.get(hour);
|
|
78
|
+
if (group) {
|
|
79
|
+
group.push(event);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
hourGroups.set(hour, [event]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const result = [];
|
|
86
|
+
for (const group of hourGroups.values()) {
|
|
87
|
+
const columnCount = group.length;
|
|
88
|
+
group.forEach((event, columnIndex) => {
|
|
89
|
+
result.push({ event, columnIndex, columnCount });
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CalendarEvent } from "./page-calendar.types";
|
|
2
|
+
type WeekViewProps = {
|
|
3
|
+
days: Date[];
|
|
4
|
+
eventsByDate: Map<string, CalendarEvent[]>;
|
|
5
|
+
currentDate: Date;
|
|
6
|
+
onEventClick: (event: CalendarEvent) => void;
|
|
7
|
+
onSlotClick?: (date: Date) => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function WeekView({ days, eventsByDate, onEventClick, onSlotClick }: WeekViewProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=week-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"week-view.d.ts","sourceRoot":"","sources":["../../../src/components/page-calendar/week-view.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAM3D,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,IAAI,EAAE,CAAC;IACb,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;IAC3C,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACtC,CAAC;AAQF,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,aAAa,+BAwFxF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { isToday } from "date-fns";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useLocale } from "../../hooks/use-locale";
|
|
4
|
+
import { EventPill } from "./event-pill";
|
|
5
|
+
import { getHourSlots, toDateKey, formatWeekdayShort, formatDay, formatHourLabel, formatFullDate, computeEventColumns } from "./page-calendar.utils";
|
|
6
|
+
const HOUR_HEIGHT = 48;
|
|
7
|
+
function getTopOffset(event) {
|
|
8
|
+
const hour = event.date.getHours();
|
|
9
|
+
const minutes = event.date.getMinutes();
|
|
10
|
+
return hour * HOUR_HEIGHT + (minutes / 60) * HOUR_HEIGHT;
|
|
11
|
+
}
|
|
12
|
+
export function WeekView({ days, eventsByDate, onEventClick, onSlotClick }) {
|
|
13
|
+
const locale = useLocale();
|
|
14
|
+
const currentHourRef = useRef(null);
|
|
15
|
+
const scrollBodyRef = useRef(null);
|
|
16
|
+
const hours = getHourSlots();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (scrollBodyRef.current && currentHourRef.current) {
|
|
19
|
+
const top = currentHourRef.current.offsetTop;
|
|
20
|
+
scrollBodyRef.current.scrollTop = top - scrollBodyRef.current.clientHeight / 2;
|
|
21
|
+
}
|
|
22
|
+
}, []);
|
|
23
|
+
return (<div className="flex flex-1 flex-col overflow-hidden">
|
|
24
|
+
<div className="flex flex-shrink-0 border-b border-border">
|
|
25
|
+
<div className="w-page-calendar-gutter-w flex-shrink-0"/>
|
|
26
|
+
{days.map((day, idx) => {
|
|
27
|
+
const isCurrentDay = isToday(day);
|
|
28
|
+
return (<div key={idx} aria-label={formatFullDate(day, locale)} className="flex-1 py-page-calendar-weekday-py text-center text-page-calendar-weekday-text font-medium text-muted-foreground">
|
|
29
|
+
<span className="block">{formatWeekdayShort(day, locale)}</span>
|
|
30
|
+
<span className={`inline-flex size-page-calendar-week-badge-size items-center justify-center rounded-full text-page-calendar-week-badge-text font-bold ${isCurrentDay ? "bg-primary text-primary-foreground" : "text-foreground"}`}>
|
|
31
|
+
{formatDay(day, locale)}
|
|
32
|
+
</span>
|
|
33
|
+
</div>);
|
|
34
|
+
})}
|
|
35
|
+
</div>
|
|
36
|
+
<div ref={scrollBodyRef} className="flex flex-1 items-start overflow-y-auto">
|
|
37
|
+
<div className="w-page-calendar-gutter-w flex-shrink-0">
|
|
38
|
+
{hours.map((hour) => (<div key={hour} className="relative" style={{ height: HOUR_HEIGHT }}>
|
|
39
|
+
<span className="absolute -top-2.5 right-2 text-page-calendar-hour-text text-muted-foreground">
|
|
40
|
+
{hour === 0 ? "" : formatHourLabel(hour, locale)}
|
|
41
|
+
</span>
|
|
42
|
+
{hour === new Date().getHours() && <div ref={currentHourRef}/>}
|
|
43
|
+
</div>))}
|
|
44
|
+
</div>
|
|
45
|
+
{days.map((day, dayIdx) => {
|
|
46
|
+
const key = toDateKey(day);
|
|
47
|
+
const events = eventsByDate.get(key) || [];
|
|
48
|
+
return (<div key={dayIdx} className="relative flex-1 border-l border-card-border">
|
|
49
|
+
{hours.map((hour) => {
|
|
50
|
+
const slotDate = new Date(day);
|
|
51
|
+
slotDate.setHours(hour, 0, 0, 0);
|
|
52
|
+
return (<button key={hour} type="button" aria-label={formatHourLabel(hour, locale)} className="w-full cursor-pointer border-b border-border/50 hover:bg-muted/20" style={{ height: HOUR_HEIGHT }} onClick={() => onSlotClick?.(slotDate)}/>);
|
|
53
|
+
})}
|
|
54
|
+
{computeEventColumns(events).map(({ event, columnIndex, columnCount }) => (<div key={event.id} role="presentation" className="absolute" style={{
|
|
55
|
+
top: getTopOffset(event),
|
|
56
|
+
height: HOUR_HEIGHT,
|
|
57
|
+
left: `calc(${(columnIndex / columnCount) * 100}% + 1px)`,
|
|
58
|
+
width: `calc(${100 / columnCount}% - 2px)`,
|
|
59
|
+
}} onClick={(e) => e.stopPropagation()} onKeyDown={(e) => e.stopPropagation()}>
|
|
60
|
+
<EventPill event={event} onClick={() => onEventClick(event)}/>
|
|
61
|
+
</div>))}
|
|
62
|
+
</div>);
|
|
63
|
+
})}
|
|
64
|
+
</div>
|
|
65
|
+
</div>);
|
|
66
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AllPaths } from "sidekicker";
|
|
3
|
+
import { Any, Label } from "../../types";
|
|
4
|
+
import { OptionProps } from "../form/select";
|
|
5
|
+
import { Col, ColType, TableConfiguration } from "./table-lib";
|
|
6
|
+
type Operators = {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
symbol: string;
|
|
10
|
+
"data-default"?: string;
|
|
11
|
+
};
|
|
12
|
+
type OperatorTypes = "contains" | "is" | "isNot" | "notContains" | "lessThan" | "greaterThan" | "startsWith" | "endsWith";
|
|
13
|
+
type Operations = Record<OperatorTypes, Operators>;
|
|
14
|
+
type OperationOptions = Partial<Record<ColType, OptionProps[]>>;
|
|
15
|
+
type FilterValue = string | number | string[] | boolean;
|
|
16
|
+
export type FilterConfig<T extends object = object> = {
|
|
17
|
+
id: string;
|
|
18
|
+
label: Label;
|
|
19
|
+
name: AllPaths<T>;
|
|
20
|
+
type: ColType;
|
|
21
|
+
operation: Operators;
|
|
22
|
+
value: FilterValue;
|
|
23
|
+
};
|
|
24
|
+
type Props<T extends object> = TableConfiguration<T, {
|
|
25
|
+
cols: Col<T>[];
|
|
26
|
+
filters: FilterConfig<T>[];
|
|
27
|
+
set: React.Dispatch<React.SetStateAction<FilterConfig<T>[]>>;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const createFilterFromCol: <T extends Any>(f: Col<T>, options: OperationOptions, operations: Operations, rest?: Partial<FilterConfig<T>>) => FilterConfig<T>;
|
|
30
|
+
export declare const useOperators: () => {
|
|
31
|
+
options: Partial<Record<ColType, OptionProps[]>>;
|
|
32
|
+
operations: Operations;
|
|
33
|
+
};
|
|
34
|
+
export declare const Filter: <T extends object>(props: Props<T>) => React.JSX.Element;
|
|
35
|
+
type ColumnHeaderFilterProps<T extends object> = {
|
|
36
|
+
filter: FilterConfig<T>;
|
|
37
|
+
onDelete: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
38
|
+
set: React.Dispatch<React.SetStateAction<FilterConfig<T>[]>>;
|
|
39
|
+
};
|
|
40
|
+
export declare const ColumnHeaderFilter: <T extends object>({ filter, onDelete, set }: ColumnHeaderFilterProps<T>) => React.JSX.Element;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/components/table/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAU,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAY,kBAAkB,EAAiB,MAAM,aAAa,CAAC;AAExF,KAAK,SAAS,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,KAAK,aAAa,GAAG,UAAU,GAAG,IAAI,GAAG,OAAO,GAAG,aAAa,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1H,KAAK,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAEnD,KAAK,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAEhE,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAC7C,CAAC,EACD;IACI,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CACJ,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,GAAG,EAC7C,GAAG,GAAG,CAAC,CAAC,CAAC,EACT,SAAS,gBAAgB,EACzB,YAAY,UAAU,EACtB,OAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAM,KACpC,YAAY,CAAC,CAAC,CAehB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CA8DxB,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,sBA0GvD,CAAC;AAEF,KAAK,uBAAuB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC7C,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC3D,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,EAAE,2BAA2B,uBAAuB,CAAC,CAAC,CAAC,sBAiDzG,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { FunnelIcon, PlusIcon, TrashIcon } from "@phosphor-icons/react";
|
|
2
|
+
import React, { Fragment, useMemo } from "react";
|
|
3
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
4
|
+
import { uuid } from "../../lib/fns";
|
|
5
|
+
import { Dropdown } from "../floating/dropdown";
|
|
6
|
+
import { Input } from "../form/input";
|
|
7
|
+
import { Select } from "../form/select";
|
|
8
|
+
import { ColType, getLabel, valueFromType } from "./table-lib";
|
|
9
|
+
export const createFilterFromCol = (f, options, operations, rest = {}) => {
|
|
10
|
+
const name = f.id;
|
|
11
|
+
const type = f.type ?? ColType.Text;
|
|
12
|
+
const typeOptions = options[type] ?? [];
|
|
13
|
+
const operatorId = (typeOptions.find((x) => x["data-default"])?.value ?? typeOptions[0]?.value);
|
|
14
|
+
const operation = operations[operatorId];
|
|
15
|
+
return {
|
|
16
|
+
id: uuid(),
|
|
17
|
+
operation,
|
|
18
|
+
label: getLabel(f),
|
|
19
|
+
name,
|
|
20
|
+
type,
|
|
21
|
+
value: "",
|
|
22
|
+
...rest,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const useOperators = () => {
|
|
26
|
+
const translation = useTranslations();
|
|
27
|
+
const operations = useMemo(() => ({
|
|
28
|
+
contains: {
|
|
29
|
+
value: "contains",
|
|
30
|
+
label: translation.tableFilterTypeContains,
|
|
31
|
+
symbol: "includes",
|
|
32
|
+
"data-default": "true",
|
|
33
|
+
},
|
|
34
|
+
is: { value: "is", label: translation.tableFilterTypeIs, symbol: "is" },
|
|
35
|
+
isNot: {
|
|
36
|
+
value: "isNot",
|
|
37
|
+
label: translation.tableFilterTypeIsNot,
|
|
38
|
+
symbol: "!==",
|
|
39
|
+
},
|
|
40
|
+
notContains: {
|
|
41
|
+
value: "notContains",
|
|
42
|
+
label: translation.tableFilterTypeNotContains,
|
|
43
|
+
symbol: "notIncludes",
|
|
44
|
+
},
|
|
45
|
+
lessThan: {
|
|
46
|
+
value: "lessThan",
|
|
47
|
+
label: translation.tableFilterTypeLessThan,
|
|
48
|
+
symbol: "<=",
|
|
49
|
+
},
|
|
50
|
+
greaterThan: {
|
|
51
|
+
value: "greaterThan",
|
|
52
|
+
label: translation.tableFilterTypeGreaterThan,
|
|
53
|
+
symbol: ">=",
|
|
54
|
+
},
|
|
55
|
+
startsWith: {
|
|
56
|
+
value: "startsWith",
|
|
57
|
+
label: translation.tableFilterTypeStartsWith,
|
|
58
|
+
symbol: "startsWith",
|
|
59
|
+
},
|
|
60
|
+
endsWith: {
|
|
61
|
+
value: "endsWith",
|
|
62
|
+
label: translation.tableFilterTypeEndsWith,
|
|
63
|
+
symbol: "endsWith",
|
|
64
|
+
},
|
|
65
|
+
}), [translation]);
|
|
66
|
+
const options = useMemo(() => ({
|
|
67
|
+
[ColType.Text]: [
|
|
68
|
+
operations.is,
|
|
69
|
+
operations.isNot,
|
|
70
|
+
operations.contains,
|
|
71
|
+
operations.notContains,
|
|
72
|
+
operations.startsWith,
|
|
73
|
+
operations.endsWith,
|
|
74
|
+
],
|
|
75
|
+
[ColType.Boolean]: [operations.is, operations.isNot],
|
|
76
|
+
[ColType.Number]: [operations.is, operations.isNot, operations.greaterThan, operations.lessThan],
|
|
77
|
+
}), [operations]);
|
|
78
|
+
return { options, operations };
|
|
79
|
+
};
|
|
80
|
+
export const Filter = (props) => {
|
|
81
|
+
const translation = useTranslations();
|
|
82
|
+
const operators = useOperators();
|
|
83
|
+
const onAddFilter = () => {
|
|
84
|
+
const col = props.cols.at(0);
|
|
85
|
+
props.set((prev) => [...prev, createFilterFromCol(col, operators.options, operators.operations)]);
|
|
86
|
+
};
|
|
87
|
+
const onSelectProperty = (e) => {
|
|
88
|
+
const changedId = e.target.dataset.id || "";
|
|
89
|
+
const newId = e.target.value;
|
|
90
|
+
props.set((prev) => prev.map((x) => {
|
|
91
|
+
if (changedId !== x.id)
|
|
92
|
+
return x;
|
|
93
|
+
const col = props.cols.find((x) => newId === x.id);
|
|
94
|
+
return createFilterFromCol(col, operators.options, operators.operations, { value: "" });
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
const onSelectOperation = (e) => {
|
|
98
|
+
const id = e.target.dataset.id || "";
|
|
99
|
+
const operator = e.target.value;
|
|
100
|
+
props.set((prev) => prev.map((x) => x.id === id
|
|
101
|
+
? {
|
|
102
|
+
...x,
|
|
103
|
+
operation: operators.operations[operator],
|
|
104
|
+
}
|
|
105
|
+
: x));
|
|
106
|
+
};
|
|
107
|
+
const onDelete = (e) => {
|
|
108
|
+
const id = e.currentTarget.dataset.id || "";
|
|
109
|
+
props.set((prev) => prev.filter((x) => x.id !== id));
|
|
110
|
+
};
|
|
111
|
+
const onChangeValue = (e) => {
|
|
112
|
+
const id = e.target.dataset.id || "";
|
|
113
|
+
const value = valueFromType(e.target);
|
|
114
|
+
props.set((prev) => prev.map((x) => (x.id === id ? { ...x, value } : x)));
|
|
115
|
+
};
|
|
116
|
+
return (<Fragment>
|
|
117
|
+
<Dropdown arrow title={translation.tableFilterDropdownTitle} trigger={<span className="flex items-center gap-table-inline-gap-tight proportional-nums">
|
|
118
|
+
<FunnelIcon size={14}/>
|
|
119
|
+
{translation.tableFilterLabel} {props.filters.length === 0 ? "" : ` (${props.filters.length})`}
|
|
120
|
+
</span>}>
|
|
121
|
+
<ul className="mt-table-filter-list-mt space-y-2">
|
|
122
|
+
{props.filters.map((filter) => {
|
|
123
|
+
const options = operators.options[filter.type];
|
|
124
|
+
return (<li key={`filter-select-${filter.id}`} className="flex flex-nowrap gap-table-filter-row-gap">
|
|
125
|
+
<Select options={props.options} title={translation.tableFilterColumnTitle} placeholder={translation.tableFilterColumnPlaceholder} value={filter.name} data-id={filter.id} onChange={onSelectProperty}/>
|
|
126
|
+
<Select data-id={filter.id} onChange={onSelectOperation} value={filter.operation.value} options={options} title={translation.tableFilterOperatorTitle} placeholder={translation.tableFilterOperatorPlaceholder}/>
|
|
127
|
+
<Input optionalText="" data-id={filter.id} onChange={onChangeValue} value={filter.value} type={filter.type} title={translation.tableFilterValueTitle} placeholder={translation.tableFilterValuePlaceholder}/>
|
|
128
|
+
<div className="mt-5 flex items-center justify-center">
|
|
129
|
+
<button data-id={filter.id} type="button" onClick={onDelete}>
|
|
130
|
+
<TrashIcon className="text-danger" size={16}/>
|
|
131
|
+
</button>
|
|
132
|
+
</div>
|
|
133
|
+
</li>);
|
|
134
|
+
})}
|
|
135
|
+
<li>
|
|
136
|
+
<button type="button" onClick={onAddFilter} className="flex items-center gap-table-inline-gap-tight text-primary">
|
|
137
|
+
<PlusIcon size={14}/> {translation.tableFilterNewFilter}
|
|
138
|
+
</button>
|
|
139
|
+
</li>
|
|
140
|
+
</ul>
|
|
141
|
+
</Dropdown>
|
|
142
|
+
</Fragment>);
|
|
143
|
+
};
|
|
144
|
+
export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
|
|
145
|
+
const translation = useTranslations();
|
|
146
|
+
const operators = useOperators();
|
|
147
|
+
const onSelectOperation = (e) => {
|
|
148
|
+
const operator = e.target.value;
|
|
149
|
+
const id = e.target.dataset.id || "";
|
|
150
|
+
set((prev) => prev.map((x) => x.id === id
|
|
151
|
+
? {
|
|
152
|
+
...x,
|
|
153
|
+
operation: operators.operations[operator],
|
|
154
|
+
}
|
|
155
|
+
: x));
|
|
156
|
+
};
|
|
157
|
+
const onChangeValue = (e) => {
|
|
158
|
+
const id = e.target.dataset.id || "";
|
|
159
|
+
const value = valueFromType(e.target);
|
|
160
|
+
set((prev) => prev.map((x) => (x.id === id ? { ...x, value } : x)));
|
|
161
|
+
};
|
|
162
|
+
return (<div className="flex flex-nowrap items-center gap-table-filter-inline-gap py-table-filter-inline-py">
|
|
163
|
+
<Select data-id={filter.id} onChange={onSelectOperation} value={filter.operation.value} options={operators.options[filter.type]} title={translation.tableFilterColumnTitle} placeholder={translation.tableFilterColumnPlaceholder}/>
|
|
164
|
+
<Input optionalText=" " data-id={filter.id} onChange={onChangeValue} value={filter.value} type={filter.type} title={translation.tableFilterValueTitle} placeholder={translation.tableFilterValueTitle}/>
|
|
165
|
+
<button onClick={onDelete} data-id={filter.id} type="button" className="mt-4">
|
|
166
|
+
<TrashIcon className="text-danger" size={14}/>
|
|
167
|
+
</button>
|
|
168
|
+
</div>);
|
|
169
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Col, TableConfiguration } from "./table-lib";
|
|
3
|
+
export type GroupItem<T extends object> = Col<T> & {
|
|
4
|
+
rows: T[];
|
|
5
|
+
index: number;
|
|
6
|
+
groupId: string;
|
|
7
|
+
groupName: string;
|
|
8
|
+
groupKey: keyof T;
|
|
9
|
+
};
|
|
10
|
+
type Props<T extends object> = TableConfiguration<T, {
|
|
11
|
+
rows: T[];
|
|
12
|
+
groups: GroupItem<T>[];
|
|
13
|
+
setGroups: React.Dispatch<React.SetStateAction<GroupItem<T>[]>>;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const Group: <T extends object>(props: Props<T>) => React.JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/components/table/group.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAOlD,OAAO,EAAE,GAAG,EAAoB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG;IAC/C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,CAAC;CACrB,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAC7C,CAAC,EACD;IACI,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnE,CACJ,CAAC;AAqBF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,sBAmFtD,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LayoutGroup, Reorder, useDragControls, useMotionValue } from "motion/react";
|
|
3
|
+
import Linq from "linq-arrays";
|
|
4
|
+
import { DotsSixVerticalIcon, TrashIcon, StackMinusIcon } from "@phosphor-icons/react";
|
|
5
|
+
import React, { Fragment, useState } from "react";
|
|
6
|
+
import { keys } from "sidekicker";
|
|
7
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
8
|
+
import { uuid } from "../../lib/fns";
|
|
9
|
+
import { Button } from "../core/button";
|
|
10
|
+
import { Dropdown } from "../floating/dropdown";
|
|
11
|
+
import { Select } from "../form/select";
|
|
12
|
+
import { createOptionCols } from "./table-lib";
|
|
13
|
+
const Item = ({ item, onPointerDown }) => {
|
|
14
|
+
const y = useMotionValue(0);
|
|
15
|
+
return (<Reorder.Item onPointerDown={onPointerDown} id={item.groupId} className="flex flex-row items-center gap-2" key={item.groupId} value={item} style={{ y }}>
|
|
16
|
+
<button type="button" className="cursor-grab">
|
|
17
|
+
<DotsSixVerticalIcon size={14}/>
|
|
18
|
+
</button>
|
|
19
|
+
<span>{item.groupName}</span>
|
|
20
|
+
</Reorder.Item>);
|
|
21
|
+
};
|
|
22
|
+
export const Group = (props) => {
|
|
23
|
+
const translations = useTranslations();
|
|
24
|
+
const options = createOptionCols(props.cols);
|
|
25
|
+
const controls = useDragControls();
|
|
26
|
+
const [group, setGroup] = useState(props.groups[0]?.thead || "");
|
|
27
|
+
const onChange = (e) => {
|
|
28
|
+
const select = e.target;
|
|
29
|
+
const key = select.value;
|
|
30
|
+
const index = select.options.selectedIndex;
|
|
31
|
+
const label = select.options.item(index)?.label || "";
|
|
32
|
+
setGroup(label);
|
|
33
|
+
const groupBy = new Linq(props.rows).GroupBy(key);
|
|
34
|
+
const col = props.cols.find((x) => x.id === key);
|
|
35
|
+
props.setGroups(keys(groupBy).map((groupName, index) => {
|
|
36
|
+
const rows = groupBy[groupName];
|
|
37
|
+
return {
|
|
38
|
+
...col,
|
|
39
|
+
groupId: uuid(),
|
|
40
|
+
groupKey: key,
|
|
41
|
+
index,
|
|
42
|
+
rows,
|
|
43
|
+
groupName: groupName,
|
|
44
|
+
};
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
const onDelete = () => props.setGroups([]);
|
|
48
|
+
return (<Fragment>
|
|
49
|
+
<Dropdown arrow={false} title={translations.tableGroupLabel} trigger={<span className="flex items-center gap-table-inline-gap-tight proportional-nums">
|
|
50
|
+
<StackMinusIcon size={14}/>
|
|
51
|
+
{translations.tableGroupLabelWithCount}
|
|
52
|
+
{props.groups.length > 0 ? ` - ${group}(${props.groups.length})` : ""}
|
|
53
|
+
</span>}>
|
|
54
|
+
<div className="flex flex-nowrap items-center">
|
|
55
|
+
<Select value={group} title="Tipo de agrupamento" onChange={onChange} options={options} placeholder="Agrupar por..."/>
|
|
56
|
+
<Button className="mt-table-groups-mt" onClick={onDelete} theme="raw" data-id={group}>
|
|
57
|
+
<TrashIcon size={16} className="text-danger"/>
|
|
58
|
+
</Button>
|
|
59
|
+
</div>
|
|
60
|
+
{props.groups.length > 0 ? (<section className="my-table-groups-my">
|
|
61
|
+
<header>
|
|
62
|
+
<h2 className="text-typography-xl font-medium">Order groups</h2>
|
|
63
|
+
</header>
|
|
64
|
+
<LayoutGroup>
|
|
65
|
+
<Reorder.Group axis="y" className="relative space-y-2" drag dragControls={controls} dragListener={false} layoutScroll onReorder={props.setGroups} values={props.groups}>
|
|
66
|
+
{props.groups.map((item) => (<Item key={item.groupId} item={item} onPointerDown={(e) => {
|
|
67
|
+
controls.start(e);
|
|
68
|
+
props.setGroups([...props.groups]);
|
|
69
|
+
}}/>))}
|
|
70
|
+
</Reorder.Group>
|
|
71
|
+
</LayoutGroup>
|
|
72
|
+
</section>) : null}
|
|
73
|
+
</Dropdown>
|
|
74
|
+
</Fragment>);
|
|
75
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { InnerTableProps } from "./inner-table";
|
|
3
|
+
import { TableOperationProps } from "./table-lib";
|
|
4
|
+
export type TableProps<T extends Record<string, unknown>> = Pick<InnerTableProps<T>, "cols" | "rows" | "loadingMore" | "border" | "Aside"> & {
|
|
5
|
+
name: string;
|
|
6
|
+
} & Partial<TableOperationProps<T> & {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
reference: keyof T;
|
|
9
|
+
operations: boolean;
|
|
10
|
+
useControl: boolean;
|
|
11
|
+
inlineFilter: boolean;
|
|
12
|
+
inlineSorter: boolean;
|
|
13
|
+
sticky: number | null;
|
|
14
|
+
onScrollEnd: () => void;
|
|
15
|
+
getScrollRef?: () => HTMLElement | undefined;
|
|
16
|
+
getRowProps: (row: T) => ComponentProps<"tr">;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const Table: <T extends Record<string, unknown>>(props: TableProps<T>) => import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAsB,MAAM,OAAO,CAAC;AAK3D,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,EAAuC,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG;IACzI,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CACH,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IAC7C,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;CACjD,CACJ,CAAC;AASN,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,gCA2H5E,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AnimatePresence } from "motion/react";
|
|
3
|
+
import { useEffect, useMemo } from "react";
|
|
4
|
+
import { useReducer } from "use-typed-reducer";
|
|
5
|
+
import { useTweaks } from "../../hooks/use-tweaks";
|
|
6
|
+
import { InnerTable } from "./inner-table";
|
|
7
|
+
import { Metadata } from "./metadata";
|
|
8
|
+
import { createOptionCols } from "./table-lib";
|
|
9
|
+
import { TableProvider } from "./table.context";
|
|
10
|
+
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
11
|
+
const compareAndExec = (prev, state, exec) => (prev === state ? undefined : exec?.(state));
|
|
12
|
+
export const Table = (props) => {
|
|
13
|
+
const tweaks = useTweaks();
|
|
14
|
+
const contextState = useMemo(() => ({
|
|
15
|
+
sticky: props.sticky === undefined ? (tweaks.table.sticky ?? undefined) : (props.sticky ?? undefined),
|
|
16
|
+
}), [props.sticky, tweaks.table.sticky]);
|
|
17
|
+
const operations = props.operations ?? tweaks.table.operations ?? true;
|
|
18
|
+
const optionCols = useMemo(() => createOptionCols(props.cols), [props.cols]);
|
|
19
|
+
const [state, dispatch] = useReducer({
|
|
20
|
+
cols: props.cols,
|
|
21
|
+
sorters: (props.sorters ?? []),
|
|
22
|
+
groups: (props.groups ?? []),
|
|
23
|
+
filters: (props.filters ?? []),
|
|
24
|
+
}, (get) => {
|
|
25
|
+
const create = (key) => (arg) => {
|
|
26
|
+
const state = get.state();
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
[key]: dispatcherFun(state[key], arg),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
cols: create("cols"),
|
|
34
|
+
sorters: create("sorters"),
|
|
35
|
+
groups: create("groups"),
|
|
36
|
+
filters: create("filters"),
|
|
37
|
+
};
|
|
38
|
+
}, {
|
|
39
|
+
postMiddleware: [
|
|
40
|
+
(state, prev) => {
|
|
41
|
+
props.set?.(state);
|
|
42
|
+
compareAndExec(prev?.filters ?? [], state.filters ?? [], props.setFilters);
|
|
43
|
+
compareAndExec(prev?.sorters ?? [], state.sorters ?? [], props.setSorters);
|
|
44
|
+
compareAndExec(prev?.groups ?? [], state.groups ?? [], props.setGroups);
|
|
45
|
+
compareAndExec(prev?.cols ?? [], state.cols ?? [], props.setCols);
|
|
46
|
+
return state;
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
dispatch.cols(props.cols);
|
|
52
|
+
}, [props.cols]);
|
|
53
|
+
return (<TableProvider value={contextState}>
|
|
54
|
+
<AnimatePresence propagate initial={false}>
|
|
55
|
+
{operations ? (<Metadata cols={state.cols} rows={props.rows} options={optionCols} groups={state.groups} filters={state.filters} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} pagination={props.pagination ?? null} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>) : null}
|
|
56
|
+
{state.groups.length === 0 ? (<InnerTable {...props} index={0} cols={state.cols} options={optionCols} groups={state.groups} filters={state.filters} optionCols={optionCols} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} onScrollEnd={props.onScrollEnd} pagination={props.pagination ?? null} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>) : (<div className="flex flex-wrap gap-table-groups-gap">
|
|
57
|
+
{state.groups.map((group, index) => (<div className="min-w-full" key={`group-${group.groupId}`}>
|
|
58
|
+
<InnerTable {...props} group={group} index={index} cols={state.cols} pagination={null} rows={group.rows} options={optionCols} groups={state.groups} filters={state.filters} optionCols={optionCols} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} onScrollEnd={props.onScrollEnd} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>
|
|
59
|
+
</div>))}
|
|
60
|
+
</div>)}
|
|
61
|
+
</AnimatePresence>
|
|
62
|
+
</TableProvider>);
|
|
63
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { ComponentProps, HTMLAttributes } from "react";
|
|
2
|
+
import { OptionProps } from "../form/select";
|
|
3
|
+
import { FilterConfig } from "./filter";
|
|
4
|
+
import { GroupItem } from "./group";
|
|
5
|
+
import { Sorter } from "./sort";
|
|
6
|
+
import { CellAsideElement, Col, TableOperationProps } from "./table-lib";
|
|
7
|
+
import { Any } from "../../types";
|
|
8
|
+
export type InnerTableProps<T extends Any> = HTMLAttributes<HTMLTableElement> & TableOperationProps<T> & {
|
|
9
|
+
rows: T[];
|
|
10
|
+
index: number;
|
|
11
|
+
cols: Col<T>[];
|
|
12
|
+
border?: boolean;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
group?: GroupItem<T>;
|
|
15
|
+
useControl?: boolean;
|
|
16
|
+
loadingMore?: boolean;
|
|
17
|
+
sorters?: Sorter<T>[];
|
|
18
|
+
showMetadata?: boolean;
|
|
19
|
+
groups?: GroupItem<T>[];
|
|
20
|
+
onScrollEnd?: () => void;
|
|
21
|
+
optionCols: OptionProps[];
|
|
22
|
+
filters?: FilterConfig<T>[];
|
|
23
|
+
Aside?: React.FC<CellAsideElement<T>>;
|
|
24
|
+
getScrollRef?: () => HTMLElement | undefined;
|
|
25
|
+
getRowProps?: (_: T) => ComponentProps<"tr">;
|
|
26
|
+
setGroups: React.Dispatch<React.SetStateAction<GroupItem<T>[]>>;
|
|
27
|
+
};
|
|
28
|
+
export declare const InnerTable: <T extends Record<string, unknown>>({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, getScrollRef, pagination, useControl, ...props }: InnerTableProps<T>) => React.JSX.Element;
|
|
29
|
+
//# sourceMappingURL=inner-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inner-table.d.ts","sourceRoot":"","sources":["../../../src/components/table/inner-table.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,cAAc,EAA2B,cAAc,EAAwC,MAAM,OAAO,CAAC;AAM7H,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAYlC,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACzE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IAC7C,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7C,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnE,CAAC;AAmFN,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,0HAY3D,eAAe,CAAC,CAAC,CAAC,sBA0EpB,CAAC"}
|