@modoock/components 1.1.0 → 2.1.0
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/accordion.d.ts +24 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +30 -0
- package/dist/agenda.d.ts +93 -0
- package/dist/agenda.d.ts.map +1 -0
- package/dist/agenda.js +581 -0
- package/dist/badge.d.ts +10 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +14 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +27 -0
- package/dist/date-picker.d.ts +47 -0
- package/dist/date-picker.d.ts.map +1 -0
- package/dist/date-picker.js +327 -0
- package/dist/icon.d.ts +21 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +24 -0
- package/{components/ui/index.ts → dist/index.d.ts} +28 -28
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/input.d.ts +41 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +105 -0
- package/dist/loader.d.ts +26 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/metric-bar.d.ts +11 -0
- package/dist/metric-bar.d.ts.map +1 -0
- package/dist/metric-bar.js +19 -0
- package/dist/modal.d.ts +19 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +88 -0
- package/dist/select.d.ts +59 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +153 -0
- package/dist/stepper.d.ts +13 -0
- package/dist/stepper.d.ts.map +1 -0
- package/dist/stepper.js +38 -0
- package/dist/tab.d.ts +34 -0
- package/dist/tab.d.ts.map +1 -0
- package/dist/tab.js +25 -0
- package/dist/table.d.ts +57 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +180 -0
- package/package.json +26 -2
- package/components/ui/accordion.tsx +0 -97
- package/components/ui/badge.tsx +0 -43
- package/components/ui/button.tsx +0 -104
- package/components/ui/icon.tsx +0 -78
- package/components/ui/input.tsx +0 -376
- package/components/ui/loader.tsx +0 -78
- package/components/ui/metric-bar.tsx +0 -49
- package/components/ui/modal.tsx +0 -177
- package/components/ui/select.tsx +0 -458
- package/components/ui/stepper.tsx +0 -96
- package/components/ui/tab.tsx +0 -85
- package/components/ui/table.tsx +0 -806
package/dist/agenda.js
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useState, } from "react";
|
|
4
|
+
import Badge from "./badge";
|
|
5
|
+
import ClickableButton from "./button";
|
|
6
|
+
import { DateRangePicker } from "./date-picker";
|
|
7
|
+
import Icon from "./icon";
|
|
8
|
+
import Input from "./input";
|
|
9
|
+
import Modal from "./modal";
|
|
10
|
+
import Table from "./table";
|
|
11
|
+
/* ------------------------------------------------------------------ */
|
|
12
|
+
/* Defaults */
|
|
13
|
+
/* ------------------------------------------------------------------ */
|
|
14
|
+
export const AGENDA_STATUS_OPTIONS = [
|
|
15
|
+
{ value: "planned", label: "Planifié" },
|
|
16
|
+
{ value: "confirmed", label: "Confirmé" },
|
|
17
|
+
{ value: "completed", label: "Terminé" },
|
|
18
|
+
{ value: "cancelled", label: "Annulé" },
|
|
19
|
+
{ value: "delayed", label: "Reporté" },
|
|
20
|
+
];
|
|
21
|
+
const DEFAULT_STATUS_STYLES = {
|
|
22
|
+
planned: {
|
|
23
|
+
event: "bg-info-light text-info-foreground",
|
|
24
|
+
accent: "bg-info",
|
|
25
|
+
dot: "bg-info",
|
|
26
|
+
badge: "info",
|
|
27
|
+
},
|
|
28
|
+
confirmed: {
|
|
29
|
+
event: "bg-primary-light text-primary",
|
|
30
|
+
accent: "bg-primary",
|
|
31
|
+
dot: "bg-primary",
|
|
32
|
+
badge: "primary",
|
|
33
|
+
},
|
|
34
|
+
completed: {
|
|
35
|
+
event: "bg-success-light text-success-foreground",
|
|
36
|
+
accent: "bg-success",
|
|
37
|
+
dot: "bg-success",
|
|
38
|
+
badge: "success",
|
|
39
|
+
},
|
|
40
|
+
cancelled: {
|
|
41
|
+
event: "bg-danger-light text-danger-foreground",
|
|
42
|
+
accent: "bg-danger",
|
|
43
|
+
dot: "bg-danger",
|
|
44
|
+
badge: "danger",
|
|
45
|
+
},
|
|
46
|
+
delayed: {
|
|
47
|
+
event: "bg-warning-light text-warning-foreground",
|
|
48
|
+
accent: "bg-warning",
|
|
49
|
+
dot: "bg-warning",
|
|
50
|
+
badge: "warning",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const VIEW_TABS = [
|
|
54
|
+
{ value: "month", label: "Mois" },
|
|
55
|
+
{ value: "week", label: "Semaine" },
|
|
56
|
+
{ value: "list", label: "Liste" },
|
|
57
|
+
];
|
|
58
|
+
const WEEKDAY_HEADERS = ["Lun", "Mar", "Mer", "Jeu", "Ven", "Sam", "Dim"];
|
|
59
|
+
const MONTH_FORMAT = new Intl.DateTimeFormat("fr-FR", {
|
|
60
|
+
month: "long",
|
|
61
|
+
year: "numeric",
|
|
62
|
+
});
|
|
63
|
+
const WEEKDAY_SHORT = new Intl.DateTimeFormat("fr-FR", { weekday: "short" });
|
|
64
|
+
const DAY_LONG = new Intl.DateTimeFormat("fr-FR", {
|
|
65
|
+
weekday: "long",
|
|
66
|
+
day: "numeric",
|
|
67
|
+
month: "long",
|
|
68
|
+
year: "numeric",
|
|
69
|
+
});
|
|
70
|
+
const TIME_FORMAT = new Intl.DateTimeFormat("fr-FR", {
|
|
71
|
+
hour: "2-digit",
|
|
72
|
+
minute: "2-digit",
|
|
73
|
+
});
|
|
74
|
+
const DATETIME_FORMAT = new Intl.DateTimeFormat("fr-FR", {
|
|
75
|
+
day: "2-digit",
|
|
76
|
+
month: "2-digit",
|
|
77
|
+
year: "numeric",
|
|
78
|
+
hour: "2-digit",
|
|
79
|
+
minute: "2-digit",
|
|
80
|
+
});
|
|
81
|
+
/* ------------------------------------------------------------------ */
|
|
82
|
+
/* Date helpers */
|
|
83
|
+
/* ------------------------------------------------------------------ */
|
|
84
|
+
function toDate(value) {
|
|
85
|
+
return value instanceof Date ? value : new Date(value);
|
|
86
|
+
}
|
|
87
|
+
function startOfDay(date) {
|
|
88
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
89
|
+
}
|
|
90
|
+
function dayKey(date) {
|
|
91
|
+
const y = date.getFullYear();
|
|
92
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
93
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
94
|
+
return `${y}-${m}-${d}`;
|
|
95
|
+
}
|
|
96
|
+
function isSameDay(a, b) {
|
|
97
|
+
return dayKey(a) === dayKey(b);
|
|
98
|
+
}
|
|
99
|
+
function isToday(date) {
|
|
100
|
+
return isSameDay(date, new Date());
|
|
101
|
+
}
|
|
102
|
+
function addDays(date, days) {
|
|
103
|
+
const next = new Date(date);
|
|
104
|
+
next.setDate(next.getDate() + days);
|
|
105
|
+
return next;
|
|
106
|
+
}
|
|
107
|
+
function addMonths(date, months) {
|
|
108
|
+
return new Date(date.getFullYear(), date.getMonth() + months, 1);
|
|
109
|
+
}
|
|
110
|
+
function addWeeks(date, weeks) {
|
|
111
|
+
return addDays(date, weeks * 7);
|
|
112
|
+
}
|
|
113
|
+
function startOfWeek(date) {
|
|
114
|
+
const d = startOfDay(date);
|
|
115
|
+
const offset = (d.getDay() + 6) % 7;
|
|
116
|
+
return addDays(d, -offset);
|
|
117
|
+
}
|
|
118
|
+
function getWeekDays(anchor) {
|
|
119
|
+
const start = startOfWeek(anchor);
|
|
120
|
+
return Array.from({ length: 7 }, (_, i) => addDays(start, i));
|
|
121
|
+
}
|
|
122
|
+
function layoutMonthGrid(anchor) {
|
|
123
|
+
const first = new Date(anchor.getFullYear(), anchor.getMonth(), 1);
|
|
124
|
+
const start = startOfWeek(first);
|
|
125
|
+
return Array.from({ length: 42 }, (_, i) => addDays(start, i));
|
|
126
|
+
}
|
|
127
|
+
function isInDisplayedMonth(date, anchor) {
|
|
128
|
+
return (date.getFullYear() === anchor.getFullYear() &&
|
|
129
|
+
date.getMonth() === anchor.getMonth());
|
|
130
|
+
}
|
|
131
|
+
function formatEventTime(value) {
|
|
132
|
+
return TIME_FORMAT.format(toDate(value));
|
|
133
|
+
}
|
|
134
|
+
function monthRange(anchor) {
|
|
135
|
+
return {
|
|
136
|
+
from: new Date(anchor.getFullYear(), anchor.getMonth(), 1),
|
|
137
|
+
to: new Date(anchor.getFullYear(), anchor.getMonth() + 1, 0),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function shiftRangeByMonths(range, months) {
|
|
141
|
+
const from = range.from
|
|
142
|
+
? new Date(range.from.getFullYear(), range.from.getMonth() + months, range.from.getDate())
|
|
143
|
+
: null;
|
|
144
|
+
const to = range.to
|
|
145
|
+
? new Date(range.to.getFullYear(), range.to.getMonth() + months, range.to.getDate())
|
|
146
|
+
: null;
|
|
147
|
+
return { from, to };
|
|
148
|
+
}
|
|
149
|
+
function endOfDay(date) {
|
|
150
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999);
|
|
151
|
+
}
|
|
152
|
+
function eventInRange(event, range) {
|
|
153
|
+
const t = toDate(event.startAt).getTime();
|
|
154
|
+
if (range.from && t < startOfDay(range.from).getTime())
|
|
155
|
+
return false;
|
|
156
|
+
if (range.to && t > endOfDay(range.to).getTime())
|
|
157
|
+
return false;
|
|
158
|
+
return Boolean(range.from || range.to);
|
|
159
|
+
}
|
|
160
|
+
function defaultPeriodLabel(view, anchor, listRange) {
|
|
161
|
+
if (view === "week") {
|
|
162
|
+
const days = getWeekDays(anchor);
|
|
163
|
+
const from = days[0];
|
|
164
|
+
const to = days[6];
|
|
165
|
+
const sameMonth = from.getMonth() === to.getMonth();
|
|
166
|
+
const fromLabel = new Intl.DateTimeFormat("fr-FR", {
|
|
167
|
+
day: "numeric",
|
|
168
|
+
month: sameMonth ? undefined : "short",
|
|
169
|
+
}).format(from);
|
|
170
|
+
const toLabel = new Intl.DateTimeFormat("fr-FR", {
|
|
171
|
+
day: "numeric",
|
|
172
|
+
month: "short",
|
|
173
|
+
year: "numeric",
|
|
174
|
+
}).format(to);
|
|
175
|
+
return `${fromLabel} – ${toLabel}`;
|
|
176
|
+
}
|
|
177
|
+
if (view === "list" && listRange?.from && listRange?.to) {
|
|
178
|
+
const sameMonth = listRange.from.getMonth() === listRange.to.getMonth() &&
|
|
179
|
+
listRange.from.getFullYear() === listRange.to.getFullYear();
|
|
180
|
+
if (sameMonth &&
|
|
181
|
+
listRange.from.getDate() === 1 &&
|
|
182
|
+
listRange.to.getDate() ===
|
|
183
|
+
new Date(listRange.to.getFullYear(), listRange.to.getMonth() + 1, 0).getDate()) {
|
|
184
|
+
return MONTH_FORMAT.format(listRange.from);
|
|
185
|
+
}
|
|
186
|
+
const fmt = new Intl.DateTimeFormat("fr-FR", {
|
|
187
|
+
day: "numeric",
|
|
188
|
+
month: "short",
|
|
189
|
+
year: "numeric",
|
|
190
|
+
});
|
|
191
|
+
return `${fmt.format(listRange.from)} – ${fmt.format(listRange.to)}`;
|
|
192
|
+
}
|
|
193
|
+
return MONTH_FORMAT.format(anchor);
|
|
194
|
+
}
|
|
195
|
+
function groupEventsByDay(events) {
|
|
196
|
+
const map = new Map();
|
|
197
|
+
for (const event of events) {
|
|
198
|
+
const key = dayKey(toDate(event.startAt));
|
|
199
|
+
const list = map.get(key);
|
|
200
|
+
if (list)
|
|
201
|
+
list.push(event);
|
|
202
|
+
else
|
|
203
|
+
map.set(key, [event]);
|
|
204
|
+
}
|
|
205
|
+
for (const list of map.values()) {
|
|
206
|
+
list.sort((a, b) => toDate(a.startAt).getTime() - toDate(b.startAt).getTime());
|
|
207
|
+
}
|
|
208
|
+
return map;
|
|
209
|
+
}
|
|
210
|
+
function minutesSinceMidnight(date) {
|
|
211
|
+
return date.getHours() * 60 + date.getMinutes();
|
|
212
|
+
}
|
|
213
|
+
function entryWeekPosition(event, startHour, endHour) {
|
|
214
|
+
const start = toDate(event.startAt);
|
|
215
|
+
const end = event.endAt
|
|
216
|
+
? toDate(event.endAt)
|
|
217
|
+
: new Date(start.getTime() + 60 * 60 * 1000);
|
|
218
|
+
const dayStart = startHour * 60;
|
|
219
|
+
const dayEnd = endHour * 60;
|
|
220
|
+
const span = Math.max(1, dayEnd - dayStart);
|
|
221
|
+
const top = Math.max(0, minutesSinceMidnight(start) - dayStart);
|
|
222
|
+
const bottom = Math.min(dayEnd, minutesSinceMidnight(end)) - dayStart;
|
|
223
|
+
const height = Math.max(28, bottom - top);
|
|
224
|
+
return {
|
|
225
|
+
topPct: (top / span) * 100,
|
|
226
|
+
heightPct: (height / span) * 100,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function resolveStyle(status, overrides) {
|
|
230
|
+
const key = status ?? "planned";
|
|
231
|
+
const base = overrides?.[key] ??
|
|
232
|
+
DEFAULT_STATUS_STYLES[key] ?? {
|
|
233
|
+
event: "bg-surface-muted text-foreground",
|
|
234
|
+
accent: "bg-muted-foreground",
|
|
235
|
+
dot: "bg-muted-foreground",
|
|
236
|
+
badge: "default",
|
|
237
|
+
};
|
|
238
|
+
return { ...base, accent: base.accent ?? base.dot };
|
|
239
|
+
}
|
|
240
|
+
function statusLabel(status, options) {
|
|
241
|
+
if (!status)
|
|
242
|
+
return "";
|
|
243
|
+
return options.find((o) => o.value === status)?.label ?? status;
|
|
244
|
+
}
|
|
245
|
+
/* ------------------------------------------------------------------ */
|
|
246
|
+
/* Shared UI pieces */
|
|
247
|
+
/* ------------------------------------------------------------------ */
|
|
248
|
+
function EmptyPeriod({ message }) {
|
|
249
|
+
return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-inline rounded-large border border-dashed border-border bg-surface px-card py-section text-center", children: [_jsx(Icon, { name: "CalendarOff", variant: "muted", size: "large", "aria-hidden": "true" }), _jsx("p", { className: "text-body text-muted-foreground", children: message })] }));
|
|
250
|
+
}
|
|
251
|
+
function StatusLegend({ options, statusStyles, }) {
|
|
252
|
+
return (_jsxs("div", { className: "flex flex-wrap items-center gap-component border-t border-border px-component py-control text-small text-muted-foreground", children: [_jsx("span", { className: "text-label text-foreground", children: "L\u00E9gende" }), options.map((opt) => {
|
|
253
|
+
const style = resolveStyle(opt.value, statusStyles);
|
|
254
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-micro", children: [_jsx("span", { className: `size-2 shrink-0 rounded-full ${style.dot}`, "aria-hidden": "true" }), opt.label] }, opt.value));
|
|
255
|
+
})] }));
|
|
256
|
+
}
|
|
257
|
+
function EventChip({ event, onSelect, statusStyles, }) {
|
|
258
|
+
const style = resolveStyle(event.status, statusStyles);
|
|
259
|
+
return (_jsxs("button", { type: "button", onClick: (e) => {
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
e.stopPropagation();
|
|
262
|
+
onSelect(event);
|
|
263
|
+
}, className: `flex w-full items-stretch overflow-hidden rounded-small text-left transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${style.event}`, title: `${formatEventTime(event.startAt)} — ${event.title}`, children: [_jsx("span", { className: `w-0.5 shrink-0 ${style.accent}`, "aria-hidden": "true" }), _jsxs("span", { className: "min-w-0 flex-1 truncate px-1.5 py-0.5 text-[10px] leading-tight", children: [_jsx("span", { className: "font-semibold tabular-nums", children: formatEventTime(event.startAt) }), " ", _jsx("span", { className: "opacity-90", children: event.title })] })] }));
|
|
264
|
+
}
|
|
265
|
+
function DayEventsModal({ open, title, events, onClose, onSelectEvent, statusOptions, statusStyles, }) {
|
|
266
|
+
if (!open)
|
|
267
|
+
return null;
|
|
268
|
+
return (_jsx(Modal, { open: open, title: title, onClose: onClose, secondaryAction: { label: "Fermer", onClick: onClose }, children: _jsx("ul", { className: "flex flex-col gap-inline", children: events.map((event) => {
|
|
269
|
+
const style = resolveStyle(event.status, statusStyles);
|
|
270
|
+
const label = statusLabel(event.status, statusOptions);
|
|
271
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => {
|
|
272
|
+
onClose();
|
|
273
|
+
onSelectEvent(event);
|
|
274
|
+
}, className: "flex w-full items-start gap-inline rounded-large border border-border bg-surface px-component py-control text-left transition-colors hover:border-primary hover:bg-primary-light/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", children: [_jsx("span", { className: `mt-1 size-2.5 shrink-0 rounded-full ${style.dot}`, "aria-hidden": "true" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex flex-wrap items-center gap-inline", children: [_jsxs("span", { className: "inline-flex items-center gap-micro text-body-medium text-foreground", children: [_jsx(Icon, { name: "Clock", size: "small", variant: "muted", "aria-hidden": "true" }), formatEventTime(event.startAt), event.endAt
|
|
275
|
+
? ` – ${formatEventTime(event.endAt)}`
|
|
276
|
+
: ""] }), label ? (_jsx(Badge, { variant: style.badge ?? "default", children: label })) : null] }), _jsx("span", { className: "mt-micro block text-body text-foreground", children: event.title }), (event.subtitle || event.kind) && (_jsx("span", { className: "mt-micro block text-small text-muted-foreground", children: [event.kind, event.subtitle].filter(Boolean).join(" · ") }))] }), _jsx(Icon, { name: "ChevronRight", size: "small", variant: "muted", "aria-hidden": "true", className: "mt-1 shrink-0" })] }) }, event.id));
|
|
277
|
+
}) }) }));
|
|
278
|
+
}
|
|
279
|
+
/** View switcher — same visual language as Tabs. */
|
|
280
|
+
function ViewSwitcher({ view, onViewChange, }) {
|
|
281
|
+
return (_jsx("div", { role: "tablist", "aria-label": "Vue agenda", className: "inline-flex max-w-full items-center gap-micro overflow-x-auto rounded-large bg-surface-muted p-micro", children: VIEW_TABS.map((tab) => {
|
|
282
|
+
const active = view === tab.value;
|
|
283
|
+
return (_jsx(ClickableButton, { type: "button", variant: "bare", role: "tab", "aria-selected": active, onClick: () => onViewChange(tab.value), className: `whitespace-nowrap rounded-large px-component py-inline text-body-medium focus-visible:ring-primary ${active
|
|
284
|
+
? "bg-surface text-primary shadow-sm"
|
|
285
|
+
: "bg-transparent text-muted-foreground hover:text-foreground"}`, children: tab.label }, tab.value));
|
|
286
|
+
}) }));
|
|
287
|
+
}
|
|
288
|
+
function PeriodNav({ view, periodLabel, onShift, onToday, }) {
|
|
289
|
+
const prevLabel = view === "week"
|
|
290
|
+
? "Semaine précédente"
|
|
291
|
+
: view === "list"
|
|
292
|
+
? "Période précédente"
|
|
293
|
+
: "Mois précédent";
|
|
294
|
+
const nextLabel = view === "week"
|
|
295
|
+
? "Semaine suivante"
|
|
296
|
+
: view === "list"
|
|
297
|
+
? "Période suivante"
|
|
298
|
+
: "Mois suivant";
|
|
299
|
+
return (_jsxs("div", { className: "flex flex-wrap items-center gap-inline", children: [_jsxs("div", { className: "flex items-center gap-micro", children: [_jsx(ClickableButton, { type: "button", variant: "secondary", size: "icon", "aria-label": prevLabel, onClick: () => onShift(-1), children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsx(ClickableButton, { type: "button", variant: "secondary", size: "icon", "aria-label": nextLabel, onClick: () => onShift(1), children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] }), _jsx("h3", { className: "min-w-0 text-component-title capitalize text-foreground", children: periodLabel }), _jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: onToday, children: "Aujourd'hui" })] }));
|
|
300
|
+
}
|
|
301
|
+
function AgendaToolbar({ view, onViewChange, anchorDate, onAnchorDateChange, periodLabel, searchQuery, onSearchChange, searchPlaceholder, filters, listRange, onListRangeChange, }) {
|
|
302
|
+
const shift = (direction) => {
|
|
303
|
+
if (view === "week") {
|
|
304
|
+
onAnchorDateChange(addWeeks(anchorDate, direction));
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (view === "list") {
|
|
308
|
+
const next = shiftRangeByMonths(listRange, direction);
|
|
309
|
+
onListRangeChange(next);
|
|
310
|
+
if (next.from)
|
|
311
|
+
onAnchorDateChange(next.from);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
onAnchorDateChange(addMonths(anchorDate, direction));
|
|
315
|
+
};
|
|
316
|
+
const goToday = () => {
|
|
317
|
+
const today = new Date();
|
|
318
|
+
onAnchorDateChange(today);
|
|
319
|
+
if (view === "list")
|
|
320
|
+
onListRangeChange(monthRange(today));
|
|
321
|
+
};
|
|
322
|
+
const showFilters = Boolean(onSearchChange || filters || view === "list");
|
|
323
|
+
return (_jsxs("div", { className: "flex flex-col gap-component", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-component", children: [_jsx(PeriodNav, { view: view, periodLabel: periodLabel, onShift: shift, onToday: goToday }), _jsx(ViewSwitcher, { view: view, onViewChange: onViewChange })] }), showFilters ? (_jsxs("div", { className: "flex flex-wrap items-end gap-inline rounded-large border border-border bg-surface p-component", children: [view === "list" ? (_jsx("div", { className: "min-w-[16rem] w-[18rem]", children: _jsx(DateRangePicker, { label: "P\u00E9riode", value: listRange, onChange: onListRangeChange, placeholder: "Du\u2026 au\u2026" }) })) : null, onSearchChange ? (_jsx("div", { className: "min-w-[14rem] flex-1 basis-[14rem]", children: _jsx(Input, { type: "search", label: "Recherche", value: searchQuery ?? "", onChange: (e) => onSearchChange(e.target.value), placeholder: searchPlaceholder, autoComplete: "off", clearable: true, onClear: () => onSearchChange(""), icon: _jsx(Icon, { name: "Search" }) }) })) : null, filters] })) : null] }));
|
|
324
|
+
}
|
|
325
|
+
/* ------------------------------------------------------------------ */
|
|
326
|
+
/* Month */
|
|
327
|
+
/* ------------------------------------------------------------------ */
|
|
328
|
+
function MonthView({ events, anchorDate, onSelectEvent, onCreateSlot, maxEventsPerDay, statusOptions, statusStyles, }) {
|
|
329
|
+
const [mounted, setMounted] = useState(false);
|
|
330
|
+
const [dayDialog, setDayDialog] = useState({
|
|
331
|
+
open: false,
|
|
332
|
+
title: "",
|
|
333
|
+
events: [],
|
|
334
|
+
});
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
setMounted(true);
|
|
337
|
+
}, []);
|
|
338
|
+
const byDay = useMemo(() => groupEventsByDay(events), [events]);
|
|
339
|
+
const cells = useMemo(() => layoutMonthGrid(anchorDate), [anchorDate]);
|
|
340
|
+
const openDay = (date, dayEvents) => {
|
|
341
|
+
if (dayEvents.length === 0) {
|
|
342
|
+
if (!onCreateSlot)
|
|
343
|
+
return;
|
|
344
|
+
const start = new Date(date);
|
|
345
|
+
start.setHours(9, 0, 0, 0);
|
|
346
|
+
onCreateSlot(start);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (dayEvents.length === 1) {
|
|
350
|
+
onSelectEvent(dayEvents[0]);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
setDayDialog({
|
|
354
|
+
open: true,
|
|
355
|
+
title: DAY_LONG.format(date),
|
|
356
|
+
events: dayEvents,
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "overflow-hidden rounded-large border border-border bg-surface", children: [_jsx("div", { className: "grid grid-cols-7 border-b border-border bg-surface-muted", children: WEEKDAY_HEADERS.map((label) => (_jsx("div", { className: "px-inline py-control text-center text-label uppercase tracking-wide text-muted-foreground", children: label }, label))) }), _jsx("div", { className: "grid grid-cols-7", children: cells.map((cellDate, cellIndex) => {
|
|
360
|
+
const key = dayKey(cellDate);
|
|
361
|
+
const dayEvents = byDay.get(key) ?? [];
|
|
362
|
+
const inMonth = isInDisplayedMonth(cellDate, anchorDate);
|
|
363
|
+
const today = isToday(cellDate);
|
|
364
|
+
const visible = dayEvents.slice(0, maxEventsPerDay);
|
|
365
|
+
const extra = dayEvents.length - maxEventsPerDay;
|
|
366
|
+
const canCreate = dayEvents.length === 0 && Boolean(onCreateSlot);
|
|
367
|
+
return (_jsxs("div", { role: "button", tabIndex: inMonth ? 0 : -1, "aria-label": canCreate
|
|
368
|
+
? `${cellDate.getDate()} — ajouter un créneau`
|
|
369
|
+
: `${cellDate.getDate()}, ${dayEvents.length} événement${dayEvents.length > 1 ? "s" : ""}`, onClick: () => openDay(cellDate, dayEvents), onKeyDown: (e) => {
|
|
370
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
371
|
+
e.preventDefault();
|
|
372
|
+
openDay(cellDate, dayEvents);
|
|
373
|
+
}
|
|
374
|
+
}, className: `group relative flex min-h-[6.5rem] flex-col gap-micro border-b border-r border-border p-inline transition-colors last:border-r-0 focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary ${inMonth
|
|
375
|
+
? "bg-surface hover:bg-surface-muted/60"
|
|
376
|
+
: "bg-surface-muted/40 text-muted-foreground"} ${cellIndex % 7 === 6 ? "border-r-0" : ""}`, children: [_jsxs("div", { className: "flex items-center justify-between gap-micro", children: [_jsx("span", { className: `inline-flex size-7 items-center justify-center rounded-full text-small ${today
|
|
377
|
+
? "bg-primary font-semibold text-primary-foreground"
|
|
378
|
+
: inMonth
|
|
379
|
+
? "font-medium text-foreground"
|
|
380
|
+
: "text-muted-foreground"}`, children: cellDate.getDate() }), canCreate ? (_jsx("span", { className: "pointer-events-none inline-flex size-6 items-center justify-center rounded-small text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100", children: _jsx(Icon, { name: "Plus", size: "small", "aria-hidden": "true" }) })) : dayEvents.length > 0 ? (_jsx("span", { className: "text-[10px] tabular-nums text-muted-foreground", children: dayEvents.length })) : null] }), _jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-micro", children: [mounted &&
|
|
381
|
+
visible.map((event) => (_jsx(EventChip, { event: event, onSelect: onSelectEvent, statusStyles: statusStyles }, event.id))), mounted && extra > 0 ? (_jsxs("button", { type: "button", onClick: (e) => {
|
|
382
|
+
e.stopPropagation();
|
|
383
|
+
openDay(cellDate, dayEvents);
|
|
384
|
+
}, className: "rounded-small px-1 py-0.5 text-left text-[10px] font-medium text-primary hover:bg-primary-light focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", children: ["+", extra, " autre", extra > 1 ? "s" : ""] })) : null] })] }, `${key}-${cellIndex}`));
|
|
385
|
+
}) }), _jsx(StatusLegend, { options: statusOptions, statusStyles: statusStyles })] }), _jsx(DayEventsModal, { open: dayDialog.open, title: dayDialog.title, events: dayDialog.events, onClose: () => setDayDialog((d) => ({ ...d, open: false })), onSelectEvent: onSelectEvent, statusOptions: statusOptions, statusStyles: statusStyles })] }));
|
|
386
|
+
}
|
|
387
|
+
/* ------------------------------------------------------------------ */
|
|
388
|
+
/* Week */
|
|
389
|
+
/* ------------------------------------------------------------------ */
|
|
390
|
+
function WeekView({ events, anchorDate, onSelectEvent, onCreateSlot, weekStartHour, weekEndHour, weekSlotMinutes, statusOptions, statusStyles, }) {
|
|
391
|
+
const [mounted, setMounted] = useState(false);
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
setMounted(true);
|
|
394
|
+
}, []);
|
|
395
|
+
const weekDays = useMemo(() => getWeekDays(anchorDate), [anchorDate]);
|
|
396
|
+
const byDay = useMemo(() => groupEventsByDay(events), [events]);
|
|
397
|
+
const slotCount = Math.max(1, ((weekEndHour - weekStartHour) * 60) / weekSlotMinutes);
|
|
398
|
+
const hourLabels = Array.from({ length: slotCount }, (_, i) => {
|
|
399
|
+
const min = weekStartHour * 60 + i * weekSlotMinutes;
|
|
400
|
+
const h = Math.floor(min / 60);
|
|
401
|
+
const m = min % 60;
|
|
402
|
+
return `${String(h).padStart(2, "0")}:${String(m).padStart(2, "0")}`;
|
|
403
|
+
});
|
|
404
|
+
const now = new Date();
|
|
405
|
+
const showNowLine = weekDays.some((d) => isToday(d)) &&
|
|
406
|
+
minutesSinceMidnight(now) >= weekStartHour * 60 &&
|
|
407
|
+
minutesSinceMidnight(now) <= weekEndHour * 60;
|
|
408
|
+
const nowTopPct = showNowLine
|
|
409
|
+
? ((minutesSinceMidnight(now) - weekStartHour * 60) /
|
|
410
|
+
Math.max(1, (weekEndHour - weekStartHour) * 60)) *
|
|
411
|
+
100
|
|
412
|
+
: 0;
|
|
413
|
+
const handleColumnClick = (day, event) => {
|
|
414
|
+
if (!onCreateSlot)
|
|
415
|
+
return;
|
|
416
|
+
if (event.target.closest("button"))
|
|
417
|
+
return;
|
|
418
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
419
|
+
const y = event.clientY - rect.top;
|
|
420
|
+
const pct = Math.max(0, Math.min(1, y / rect.height));
|
|
421
|
+
const minutes = weekStartHour * 60 +
|
|
422
|
+
Math.round((pct * (weekEndHour - weekStartHour) * 60) / weekSlotMinutes) *
|
|
423
|
+
weekSlotMinutes;
|
|
424
|
+
const start = new Date(day);
|
|
425
|
+
start.setHours(Math.floor(minutes / 60), minutes % 60, 0, 0);
|
|
426
|
+
onCreateSlot(start);
|
|
427
|
+
};
|
|
428
|
+
return (_jsxs("div", { className: "overflow-hidden rounded-large border border-border bg-surface", children: [_jsx("div", { className: "overflow-x-auto", children: _jsxs("div", { className: "min-w-[52rem]", children: [_jsxs("div", { className: "grid grid-cols-[3.75rem_repeat(7,1fr)] border-b border-border bg-surface-muted", children: [_jsx("div", { "aria-hidden": "true" }), weekDays.map((d) => {
|
|
429
|
+
const today = isToday(d);
|
|
430
|
+
return (_jsxs("div", { className: "border-l border-border px-inline py-control text-center", children: [_jsx("p", { className: "text-label uppercase text-muted-foreground", children: WEEKDAY_SHORT.format(d).replace(".", "") }), _jsx("p", { className: `mx-auto mt-micro inline-flex size-8 items-center justify-center rounded-full text-body-medium ${today
|
|
431
|
+
? "bg-primary font-semibold text-primary-foreground"
|
|
432
|
+
: "text-foreground"}`, children: d.getDate() })] }, dayKey(d)));
|
|
433
|
+
})] }), _jsxs("div", { className: "relative grid grid-cols-[3.75rem_repeat(7,1fr)]", children: [_jsx("div", { className: "border-r border-border", children: hourLabels.map((label, i) => (_jsx("div", { className: "flex h-8 items-start justify-end border-b border-border/50 pr-inline pt-0.5 text-[10px] tabular-nums text-muted-foreground", children: i % 2 === 0 ? label : "" }, label))) }), weekDays.map((d) => {
|
|
434
|
+
const dayEvents = byDay.get(dayKey(d)) ?? [];
|
|
435
|
+
return (_jsxs("div", { className: `relative border-l border-border ${onCreateSlot ? "cursor-pointer" : ""}`, style: { height: `${slotCount * 2}rem` }, onClick: (e) => handleColumnClick(d, e), title: onCreateSlot
|
|
436
|
+
? "Cliquer pour ajouter un créneau"
|
|
437
|
+
: undefined, children: [Array.from({ length: slotCount }).map((_, i) => (_jsx("div", { className: "absolute right-0 left-0 border-b border-border/40", style: {
|
|
438
|
+
top: `${(i / slotCount) * 100}%`,
|
|
439
|
+
height: `${100 / slotCount}%`,
|
|
440
|
+
} }, i))), showNowLine && isToday(d) ? (_jsx("div", { className: "pointer-events-none absolute right-0 left-0 z-[2] border-t-2 border-danger", style: { top: `${nowTopPct}%` }, "aria-hidden": "true", children: _jsx("span", { className: "absolute -left-1 -top-1.5 size-2.5 rounded-full bg-danger" }) })) : null, mounted &&
|
|
441
|
+
dayEvents.map((event) => {
|
|
442
|
+
const { topPct, heightPct } = entryWeekPosition(event, weekStartHour, weekEndHour);
|
|
443
|
+
const style = resolveStyle(event.status, statusStyles);
|
|
444
|
+
return (_jsxs("button", { type: "button", onClick: (e) => {
|
|
445
|
+
e.stopPropagation();
|
|
446
|
+
onSelectEvent(event);
|
|
447
|
+
}, className: `absolute right-1 left-1 z-[1] flex overflow-hidden rounded-small text-left shadow-sm transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${style.event}`, style: {
|
|
448
|
+
top: `${topPct}%`,
|
|
449
|
+
height: `${heightPct}%`,
|
|
450
|
+
minHeight: "1.35rem",
|
|
451
|
+
}, title: `${formatEventTime(event.startAt)} ${event.title}`, children: [_jsx("span", { className: `w-0.5 shrink-0 ${style.accent}`, "aria-hidden": "true" }), _jsxs("span", { className: "min-w-0 flex-1 overflow-hidden px-1 py-0.5", children: [_jsx("span", { className: "block text-[10px] font-semibold tabular-nums", children: formatEventTime(event.startAt) }), _jsx("span", { className: "block truncate text-[10px]", children: event.title })] })] }, event.id));
|
|
452
|
+
})] }, dayKey(d)));
|
|
453
|
+
})] })] }) }), _jsx(StatusLegend, { options: statusOptions, statusStyles: statusStyles })] }));
|
|
454
|
+
}
|
|
455
|
+
/* ------------------------------------------------------------------ */
|
|
456
|
+
/* List */
|
|
457
|
+
/* ------------------------------------------------------------------ */
|
|
458
|
+
function ListView({ events, onSelectEvent, listPageSize, listExtraColumns, statusOptions, statusStyles, emptyMessage, }) {
|
|
459
|
+
const rows = useMemo(() => [...events]
|
|
460
|
+
.sort((a, b) => toDate(a.startAt).getTime() - toDate(b.startAt).getTime())
|
|
461
|
+
.map((event) => ({
|
|
462
|
+
id: event.id,
|
|
463
|
+
startAt: toDate(event.startAt),
|
|
464
|
+
endAt: event.endAt ? toDate(event.endAt) : null,
|
|
465
|
+
title: event.title,
|
|
466
|
+
subtitle: event.subtitle ?? "",
|
|
467
|
+
kind: event.kind ?? "",
|
|
468
|
+
status: event.status ?? "",
|
|
469
|
+
event,
|
|
470
|
+
})), [events]);
|
|
471
|
+
const columns = useMemo(() => {
|
|
472
|
+
const base = [
|
|
473
|
+
{
|
|
474
|
+
key: "startAt",
|
|
475
|
+
label: "Date / heure",
|
|
476
|
+
sortable: true,
|
|
477
|
+
render: (row) => (_jsxs("span", { className: "inline-flex items-center gap-inline text-body-medium", children: [_jsx(Icon, { name: "Clock", size: "small", variant: "muted", "aria-hidden": "true" }), DATETIME_FORMAT.format(row.startAt)] })),
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
key: "title",
|
|
481
|
+
label: "Titre",
|
|
482
|
+
sortable: true,
|
|
483
|
+
render: (row) => (_jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: "text-body-medium text-foreground", children: row.title }), row.subtitle ? (_jsx("span", { className: "text-small text-muted-foreground", children: row.subtitle })) : null] })),
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
key: "kind",
|
|
487
|
+
label: "Type",
|
|
488
|
+
sortable: true,
|
|
489
|
+
className: "text-muted-foreground",
|
|
490
|
+
render: (row) => row.kind || "—",
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
key: "status",
|
|
494
|
+
label: "Statut",
|
|
495
|
+
sortable: true,
|
|
496
|
+
render: (row) => {
|
|
497
|
+
const style = resolveStyle(row.status, statusStyles);
|
|
498
|
+
const label = statusOptions.find((o) => o.value === row.status)?.label ??
|
|
499
|
+
row.status ??
|
|
500
|
+
"—";
|
|
501
|
+
return _jsx(Badge, { variant: style.badge ?? "default", children: label });
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
];
|
|
505
|
+
return listExtraColumns ? [...base, ...listExtraColumns] : base;
|
|
506
|
+
}, [listExtraColumns, statusOptions, statusStyles]);
|
|
507
|
+
if (events.length === 0) {
|
|
508
|
+
return _jsx(EmptyPeriod, { message: emptyMessage });
|
|
509
|
+
}
|
|
510
|
+
return (_jsx(Table, { columns: columns, data: rows, rowsPerPage: listPageSize, emptyMessage: emptyMessage, getRowKey: (row) => row.id, cardActions: {
|
|
511
|
+
row: (row) => [
|
|
512
|
+
{
|
|
513
|
+
label: "Voir",
|
|
514
|
+
icon: "Eye",
|
|
515
|
+
onSelect: () => onSelectEvent(row.event),
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
} }));
|
|
519
|
+
}
|
|
520
|
+
/* ------------------------------------------------------------------ */
|
|
521
|
+
/* Agenda */
|
|
522
|
+
/* ------------------------------------------------------------------ */
|
|
523
|
+
/**
|
|
524
|
+
* Multi-view agenda: month grid, week time grid, and paginated list.
|
|
525
|
+
* Filters stay open-ended via the `filters` slot; search is optional.
|
|
526
|
+
*/
|
|
527
|
+
export default function Agenda({ events, view, onViewChange, anchorDate, onAnchorDateChange, onSelectEvent, onCreateSlot, searchQuery, onSearchChange, searchPlaceholder = "Rechercher…", filters, statusOptions = AGENDA_STATUS_OPTIONS, statusStyles, periodLabel, weekStartHour = 8, weekEndHour = 20, weekSlotMinutes = 30, maxEventsPerDay = 3, listPageSize = 10, listExtraColumns, listRange: listRangeProp, onListRangeChange, className = "", emptyMessage = "Aucun événement pour cette période.", }) {
|
|
528
|
+
const [internalListRange, setInternalListRange] = useState(() => listRangeProp ?? monthRange(anchorDate));
|
|
529
|
+
const listRange = listRangeProp ?? internalListRange;
|
|
530
|
+
const setListRange = (range) => {
|
|
531
|
+
if (!listRangeProp)
|
|
532
|
+
setInternalListRange(range);
|
|
533
|
+
onListRangeChange?.(range);
|
|
534
|
+
if (range.from)
|
|
535
|
+
onAnchorDateChange(range.from);
|
|
536
|
+
};
|
|
537
|
+
// Keep uncontrolled range aligned when the user changes month outside list view.
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
if (listRangeProp)
|
|
540
|
+
return;
|
|
541
|
+
if (view !== "list")
|
|
542
|
+
setInternalListRange(monthRange(anchorDate));
|
|
543
|
+
}, [anchorDate, view, listRangeProp]);
|
|
544
|
+
const label = periodLabel ?? defaultPeriodLabel(view, anchorDate, listRange);
|
|
545
|
+
const filteredEvents = useMemo(() => {
|
|
546
|
+
const q = searchQuery?.trim().toLowerCase();
|
|
547
|
+
if (!q)
|
|
548
|
+
return events;
|
|
549
|
+
return events.filter((event) => {
|
|
550
|
+
const haystack = [event.title, event.subtitle, event.kind, event.status]
|
|
551
|
+
.filter(Boolean)
|
|
552
|
+
.join(" ")
|
|
553
|
+
.toLowerCase();
|
|
554
|
+
return haystack.includes(q);
|
|
555
|
+
});
|
|
556
|
+
}, [events, searchQuery]);
|
|
557
|
+
const periodEvents = useMemo(() => {
|
|
558
|
+
if (view === "week") {
|
|
559
|
+
const days = getWeekDays(anchorDate);
|
|
560
|
+
const from = startOfDay(days[0]).getTime();
|
|
561
|
+
const to = addDays(startOfDay(days[6]), 1).getTime();
|
|
562
|
+
return filteredEvents.filter((e) => {
|
|
563
|
+
const t = toDate(e.startAt).getTime();
|
|
564
|
+
return t >= from && t < to;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
if (view === "list") {
|
|
568
|
+
if (listRange.from || listRange.to) {
|
|
569
|
+
return filteredEvents.filter((e) => eventInRange(e, listRange));
|
|
570
|
+
}
|
|
571
|
+
// Incomplete range: fall back to the anchor month.
|
|
572
|
+
}
|
|
573
|
+
const y = anchorDate.getFullYear();
|
|
574
|
+
const m = anchorDate.getMonth();
|
|
575
|
+
return filteredEvents.filter((e) => {
|
|
576
|
+
const d = toDate(e.startAt);
|
|
577
|
+
return d.getFullYear() === y && d.getMonth() === m;
|
|
578
|
+
});
|
|
579
|
+
}, [filteredEvents, view, anchorDate, listRange]);
|
|
580
|
+
return (_jsxs("div", { className: `flex flex-col gap-component ${className}`.trim(), children: [_jsx(AgendaToolbar, { view: view, onViewChange: onViewChange, anchorDate: anchorDate, onAnchorDateChange: onAnchorDateChange, periodLabel: label, searchQuery: searchQuery, onSearchChange: onSearchChange, searchPlaceholder: searchPlaceholder, filters: filters, listRange: listRange, onListRangeChange: setListRange }), view === "month" && (_jsx(MonthView, { events: periodEvents, anchorDate: anchorDate, onSelectEvent: onSelectEvent, onCreateSlot: onCreateSlot, maxEventsPerDay: maxEventsPerDay, statusOptions: statusOptions, statusStyles: statusStyles })), view === "week" && (_jsx(WeekView, { events: periodEvents, anchorDate: anchorDate, onSelectEvent: onSelectEvent, onCreateSlot: onCreateSlot, weekStartHour: weekStartHour, weekEndHour: weekEndHour, weekSlotMinutes: weekSlotMinutes, statusOptions: statusOptions, statusStyles: statusStyles })), view === "list" && (_jsx(ListView, { events: periodEvents, onSelectEvent: onSelectEvent, listPageSize: listPageSize, listExtraColumns: listExtraColumns, statusOptions: statusOptions, statusStyles: statusStyles, emptyMessage: emptyMessage }))] }));
|
|
581
|
+
}
|
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type BadgeVariant = "default" | "primary" | "secondary" | "success" | "warning" | "danger" | "info" | "accent";
|
|
3
|
+
export interface BadgeProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
variant?: BadgeVariant;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export default function Badge({ children, variant, className, }: BadgeProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../components/ui/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,YAAY,GACb,SAAS,GACT,SAAS,GACT,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,GACR,MAAM,GACN,QAAQ,CAAC;AAEb,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,QAAQ,EACR,OAAmB,EACnB,SAAc,GACf,EAAE,UAAU,+BAQZ"}
|
package/dist/badge.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
const badgeStyles = {
|
|
3
|
+
default: "bg-surface-muted text-muted-foreground",
|
|
4
|
+
primary: "bg-primary-light text-primary",
|
|
5
|
+
secondary: "bg-surface text-foreground border border-border",
|
|
6
|
+
success: "bg-success-light text-success-foreground",
|
|
7
|
+
warning: "bg-warning-light text-warning-foreground",
|
|
8
|
+
danger: "bg-danger-light text-danger-foreground",
|
|
9
|
+
info: "bg-info-light text-info-foreground",
|
|
10
|
+
accent: "bg-accent-light text-accent",
|
|
11
|
+
};
|
|
12
|
+
export default function Badge({ children, variant = "default", className = "", }) {
|
|
13
|
+
return (_jsx("span", { className: `inline-flex items-center justify-center rounded-full px-component py-micro text-label whitespace-nowrap ${badgeStyles[variant]} ${className}`, children: children }));
|
|
14
|
+
}
|
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type ButtonVariant = "primary" | "secondary" | "ghost" | "bare" | "success" | "warning" | "danger" | "info" | "accent";
|
|
3
|
+
export type ButtonSize = "sm" | "md" | "lg" | "icon";
|
|
4
|
+
export interface ClickableButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
|
+
/** Controls the height, padding and radius of the button. */
|
|
8
|
+
size?: ButtonSize;
|
|
9
|
+
/** Optional leading icon (replaced by a spinner while `loading`). */
|
|
10
|
+
leftIcon?: ReactNode;
|
|
11
|
+
/** Optional trailing icon. */
|
|
12
|
+
rightIcon?: ReactNode;
|
|
13
|
+
/** Shows a spinner, disables the button and prevents interactions. */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** Text displayed while `loading` (defaults to `children`). */
|
|
16
|
+
loadingText?: string;
|
|
17
|
+
/** Expands the button to fill the available width. */
|
|
18
|
+
fullWidth?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export default function ClickableButton({ children, variant, size, leftIcon, rightIcon, loading, loadingText, fullWidth, disabled, className, ...props }: ClickableButtonProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG7D,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,WAAW,GACX,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,QAAQ,GACR,MAAM,GACN,QAAQ,CAAC;AAEb,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,oBACf,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAiCD,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,QAAQ,EACR,OAAmB,EACnB,IAAW,EACX,QAAQ,EACR,SAAS,EACT,OAAe,EACf,WAAW,EACX,SAAiB,EACjB,QAAQ,EACR,SAAc,EACd,GAAG,KAAK,EACT,EAAE,oBAAoB,+BA0BtB"}
|