@modoock/components 2.2.0 → 2.4.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.map +1 -1
- package/dist/accordion.js +1 -1
- package/dist/agenda.js +5 -5
- package/dist/button.js +1 -1
- package/dist/chart.d.ts +37 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +92 -0
- package/dist/checkbox.d.ts +24 -0
- package/dist/checkbox.d.ts.map +1 -0
- package/dist/checkbox.js +25 -0
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +199 -54
- package/dist/drawer.d.ts +26 -0
- package/dist/drawer.d.ts.map +1 -0
- package/dist/drawer.js +125 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/input.js +2 -2
- package/dist/metric-bar.js +1 -1
- package/dist/modal.d.ts.map +1 -1
- package/dist/modal.js +25 -6
- package/dist/pagination.d.ts +16 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +39 -0
- package/dist/radio.d.ts +34 -0
- package/dist/radio.d.ts.map +1 -0
- package/dist/radio.js +37 -0
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +9 -5
- package/dist/skeleton.d.ts +12 -0
- package/dist/skeleton.d.ts.map +1 -0
- package/dist/skeleton.js +13 -0
- package/dist/stepper.js +1 -1
- package/dist/switch.d.ts +21 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/switch.js +27 -0
- package/dist/tab.js +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +7 -6
- package/dist/toast.d.ts +31 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +165 -0
- package/dist/tooltip.d.ts +18 -0
- package/dist/tooltip.d.ts.map +1 -0
- package/dist/tooltip.js +78 -0
- package/package.json +7 -3
package/dist/date-picker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
4
4
|
import Icon from "./icon";
|
|
5
5
|
import ClickableButton from "./button";
|
|
@@ -73,6 +73,76 @@ function formatRangeLabel(value) {
|
|
|
73
73
|
return `${DATE_FORMAT.format(value.from)} – …`;
|
|
74
74
|
return `… – ${DATE_FORMAT.format(value.to)}`;
|
|
75
75
|
}
|
|
76
|
+
function addDays(date, days) {
|
|
77
|
+
const day = startOfDay(date);
|
|
78
|
+
return new Date(day.getFullYear(), day.getMonth(), day.getDate() + days);
|
|
79
|
+
}
|
|
80
|
+
function startOfWeek(date) {
|
|
81
|
+
const day = startOfDay(date);
|
|
82
|
+
const offset = (day.getDay() + 6) % 7;
|
|
83
|
+
return addDays(day, -offset);
|
|
84
|
+
}
|
|
85
|
+
function startOfMonth(date) {
|
|
86
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
87
|
+
}
|
|
88
|
+
function startOfYear(date) {
|
|
89
|
+
return new Date(date.getFullYear(), 0, 1);
|
|
90
|
+
}
|
|
91
|
+
function monthIsOutOfBounds(year, month, minDate, maxDate) {
|
|
92
|
+
const start = new Date(year, month, 1);
|
|
93
|
+
const end = new Date(year, month + 1, 0);
|
|
94
|
+
if (minDate && isAfterDay(minDate, end))
|
|
95
|
+
return true;
|
|
96
|
+
if (maxDate && isBeforeDay(maxDate, start))
|
|
97
|
+
return true;
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
function yearIsOutOfBounds(year, minDate, maxDate) {
|
|
101
|
+
const start = new Date(year, 0, 1);
|
|
102
|
+
const end = new Date(year, 11, 31);
|
|
103
|
+
if (minDate && isAfterDay(minDate, end))
|
|
104
|
+
return true;
|
|
105
|
+
if (maxDate && isBeforeDay(maxDate, start))
|
|
106
|
+
return true;
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
function clampRange(range, minDate, maxDate) {
|
|
110
|
+
let from = range.from ? clampToBounds(range.from, minDate, maxDate) : null;
|
|
111
|
+
let to = range.to ? clampToBounds(range.to, minDate, maxDate) : null;
|
|
112
|
+
if (from && to && isAfterDay(from, to)) {
|
|
113
|
+
const swap = from;
|
|
114
|
+
from = to;
|
|
115
|
+
to = swap;
|
|
116
|
+
}
|
|
117
|
+
return { from, to };
|
|
118
|
+
}
|
|
119
|
+
const MONTH_SHORT_LABELS = Array.from({ length: 12 }, (_, month) => new Intl.DateTimeFormat("fr-FR", { month: "short" }).format(new Date(2020, month, 1)));
|
|
120
|
+
const DATE_PRESETS = [
|
|
121
|
+
{ label: "Aujourd'hui", get: (today) => today },
|
|
122
|
+
{ label: "Hier", get: (today) => addDays(today, -1) },
|
|
123
|
+
{ label: "Demain", get: (today) => addDays(today, 1) },
|
|
124
|
+
];
|
|
125
|
+
const RANGE_PRESETS = [
|
|
126
|
+
{
|
|
127
|
+
label: "Aujourd'hui",
|
|
128
|
+
get: (today) => ({ from: today, to: today }),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: "Cette semaine",
|
|
132
|
+
get: (today) => ({ from: startOfWeek(today), to: today }),
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
label: "Ce mois",
|
|
136
|
+
get: (today) => ({ from: startOfMonth(today), to: today }),
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: "Cette année",
|
|
140
|
+
get: (today) => ({ from: startOfYear(today), to: today }),
|
|
141
|
+
},
|
|
142
|
+
];
|
|
143
|
+
function PresetButton({ label, onSelect, }) {
|
|
144
|
+
return (_jsx("button", { type: "button", onClick: onSelect, className: "rounded-full border border-border bg-surface px-control py-micro text-label text-foreground transition-colors duration-200 ease-out hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none", children: label }));
|
|
145
|
+
}
|
|
76
146
|
/* ------------------------------------------------------------------ */
|
|
77
147
|
/* Field chrome */
|
|
78
148
|
/* ------------------------------------------------------------------ */
|
|
@@ -145,44 +215,105 @@ function buildMonthCells(viewMonth) {
|
|
|
145
215
|
cells.push(null);
|
|
146
216
|
return cells;
|
|
147
217
|
}
|
|
218
|
+
function CalendarNavButton({ label, onClick, children, }) {
|
|
219
|
+
return (_jsx("button", { type: "button", "aria-label": label, onClick: onClick, className: "flex size-8 items-center justify-center rounded-small text-muted-foreground transition-colors duration-200 ease-out hover:bg-surface-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none [&_svg]:size-[var(--icon-small)]", children: children }));
|
|
220
|
+
}
|
|
148
221
|
function Calendar({ viewMonth, onViewMonthChange, onSelectDay, isSelected, isInRange, isRangeStart, isRangeEnd, minDate, maxDate, footer, }) {
|
|
149
222
|
const cells = useMemo(() => buildMonthCells(viewMonth), [viewMonth]);
|
|
223
|
+
const [panel, setPanel] = useState("days");
|
|
150
224
|
const title = MONTH_TITLE_FORMAT.format(viewMonth);
|
|
151
225
|
const today = startOfDay(new Date());
|
|
226
|
+
const year = viewMonth.getFullYear();
|
|
227
|
+
const month = viewMonth.getMonth();
|
|
228
|
+
const yearStart = Math.floor(year / 12) * 12;
|
|
229
|
+
const years = Array.from({ length: 12 }, (_, index) => yearStart + index);
|
|
152
230
|
const goMonth = (delta) => {
|
|
153
|
-
onViewMonthChange(new Date(
|
|
231
|
+
onViewMonthChange(new Date(year, month + delta, 1));
|
|
232
|
+
};
|
|
233
|
+
const goYear = (delta) => {
|
|
234
|
+
onViewMonthChange(new Date(year + delta, month, 1));
|
|
154
235
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
236
|
+
const goYearPage = (delta) => {
|
|
237
|
+
onViewMonthChange(new Date(year + delta * 12, month, 1));
|
|
238
|
+
};
|
|
239
|
+
const cellButtonClass = "flex h-8 w-full items-center justify-center rounded-small text-sm capitalize transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none disabled:cursor-not-allowed disabled:text-muted-foreground/40";
|
|
240
|
+
return (_jsxs("div", { className: "w-[17.5rem] p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [_jsx(CalendarNavButton, { label: panel === "years"
|
|
241
|
+
? "Années précédentes"
|
|
242
|
+
: panel === "months"
|
|
243
|
+
? "Année précédente"
|
|
244
|
+
: "Mois précédent", onClick: () => {
|
|
245
|
+
if (panel === "years")
|
|
246
|
+
goYearPage(-1);
|
|
247
|
+
else if (panel === "months")
|
|
248
|
+
goYear(-1);
|
|
249
|
+
else
|
|
250
|
+
goMonth(-1);
|
|
251
|
+
}, children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsxs("button", { type: "button", "aria-label": panel === "years"
|
|
252
|
+
? "Revenir au calendrier"
|
|
253
|
+
: "Choisir l’année, puis le mois", onClick: () => setPanel(panel === "years" ? "days" : "years"), className: "flex min-w-0 items-center gap-micro rounded-small px-2 py-1 text-sm font-medium capitalize text-foreground transition-colors duration-200 ease-out hover:bg-surface-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none", children: [_jsx("span", { className: "truncate", children: panel === "years"
|
|
254
|
+
? `${yearStart} – ${yearStart + 11}`
|
|
255
|
+
: panel === "months"
|
|
256
|
+
? String(year)
|
|
257
|
+
: title }), _jsx(Icon, { name: panel === "days" ? "ChevronDown" : "ChevronUp", size: "small", "aria-hidden": "true" })] }), _jsx(CalendarNavButton, { label: panel === "years"
|
|
258
|
+
? "Années suivantes"
|
|
259
|
+
: panel === "months"
|
|
260
|
+
? "Année suivante"
|
|
261
|
+
: "Mois suivant", onClick: () => {
|
|
262
|
+
if (panel === "years")
|
|
263
|
+
goYearPage(1);
|
|
264
|
+
else if (panel === "months")
|
|
265
|
+
goYear(1);
|
|
266
|
+
else
|
|
267
|
+
goMonth(1);
|
|
268
|
+
}, children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] }), panel === "years" ? (_jsx("div", { className: "grid grid-cols-3 gap-1", children: years.map((item) => {
|
|
269
|
+
const disabled = yearIsOutOfBounds(item, minDate, maxDate);
|
|
270
|
+
const selected = item === year;
|
|
271
|
+
return (_jsx("button", { type: "button", disabled: disabled, onClick: () => {
|
|
272
|
+
onViewMonthChange(new Date(item, month, 1));
|
|
273
|
+
setPanel("months");
|
|
274
|
+
}, className: `${cellButtonClass} ${selected
|
|
275
|
+
? "bg-primary text-primary-foreground hover:bg-primary-hover"
|
|
276
|
+
: "text-foreground hover:bg-surface-muted"}`, children: item }, item));
|
|
277
|
+
}) })) : null, panel === "months" ? (_jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTH_SHORT_LABELS.map((label, index) => {
|
|
278
|
+
const disabled = monthIsOutOfBounds(year, index, minDate, maxDate);
|
|
279
|
+
const selected = index === month;
|
|
280
|
+
return (_jsx("button", { type: "button", disabled: disabled, onClick: () => {
|
|
281
|
+
onViewMonthChange(new Date(year, index, 1));
|
|
282
|
+
setPanel("days");
|
|
283
|
+
}, className: `${cellButtonClass} ${selected
|
|
284
|
+
? "bg-primary text-primary-foreground hover:bg-primary-hover"
|
|
285
|
+
: "text-foreground hover:bg-surface-muted"}`, children: label }, label));
|
|
286
|
+
}) })) : null, panel === "days" ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "mb-1 grid grid-cols-7 gap-0.5", children: WEEKDAY_LABELS.map((label) => (_jsx("div", { className: "flex h-8 items-center justify-center text-xs font-medium text-muted-foreground", children: label }, label))) }), _jsx("div", { className: "grid grid-cols-7 gap-0.5", role: "grid", "aria-label": title, children: cells.map((day, index) => {
|
|
287
|
+
if (!day) {
|
|
288
|
+
return _jsx("div", { className: "h-8" }, `empty-${index}`);
|
|
289
|
+
}
|
|
290
|
+
const disabled = (minDate ? isBeforeDay(day, minDate) : false) ||
|
|
291
|
+
(maxDate ? isAfterDay(day, maxDate) : false);
|
|
292
|
+
const selected = isSelected(day);
|
|
293
|
+
const inRange = isInRange?.(day) ?? false;
|
|
294
|
+
const rangeStart = isRangeStart?.(day) ?? false;
|
|
295
|
+
const rangeEnd = isRangeEnd?.(day) ?? false;
|
|
296
|
+
const isToday = isSameDay(day, today);
|
|
297
|
+
let dayClass = "relative flex h-8 w-full items-center justify-center rounded-small text-sm transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none";
|
|
298
|
+
if (disabled) {
|
|
299
|
+
dayClass += " cursor-not-allowed text-muted-foreground/40";
|
|
300
|
+
}
|
|
301
|
+
else if (selected || rangeStart || rangeEnd) {
|
|
302
|
+
dayClass +=
|
|
303
|
+
" bg-primary text-primary-foreground hover:bg-primary-hover";
|
|
304
|
+
}
|
|
305
|
+
else if (inRange) {
|
|
306
|
+
dayClass += " bg-primary-light text-primary hover:bg-primary-muted";
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
dayClass +=
|
|
310
|
+
" text-foreground hover:bg-surface-muted";
|
|
311
|
+
}
|
|
312
|
+
if (isToday && !selected && !rangeStart && !rangeEnd) {
|
|
313
|
+
dayClass += " font-semibold ring-1 ring-inset ring-primary/40";
|
|
314
|
+
}
|
|
315
|
+
return (_jsx("button", { type: "button", role: "gridcell", disabled: disabled, "aria-selected": selected || rangeStart || rangeEnd, "aria-current": isToday ? "date" : undefined, onClick: () => onSelectDay(day), className: dayClass, children: day.getDate() }, day.toISOString()));
|
|
316
|
+
}) })] })) : null, footer ? _jsx("div", { className: "mt-3 border-t border-border pt-3", children: footer }) : null] }));
|
|
186
317
|
}
|
|
187
318
|
/* ------------------------------------------------------------------ */
|
|
188
319
|
/* Trigger + shell */
|
|
@@ -196,7 +327,9 @@ function DateFieldShell({ label, required, disabled, error, helper, className =
|
|
|
196
327
|
.join(" ") || undefined;
|
|
197
328
|
return (_jsxs("div", { ref: rootRef, className: `relative w-full ${className}`.trim(), children: [label ? (_jsxs("label", { className: LABEL_CLASS, children: [_jsx("span", { className: "truncate", children: label }), required ? _jsx(RequiredMark, {}) : null] })) : null, _jsxs("div", { className: "relative", children: [_jsx("button", { type: "button", id: generatedId, disabled: disabled, "aria-haspopup": "dialog", "aria-expanded": open, "aria-invalid": Boolean(error) || undefined, "aria-required": required || undefined, "aria-describedby": describedBy, onClick: () => onOpenChange(!open), className: `ds-input flex cursor-pointer items-center justify-between gap-2 text-left disabled:cursor-not-allowed [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 ${clearable && hasValue && !disabled ? "pr-16" : "pr-9"} ${error
|
|
198
329
|
? "border-danger hover:border-danger focus:border-danger"
|
|
199
|
-
: ""}`, children: _jsx("span", { className: `min-w-0 flex-1 truncate ${display ? "text-foreground" : "text-muted-foreground"}`, children: display ?? placeholder }) }), _jsxs("span", { className: "pointer-events-none absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-inline text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0", children: [clearable && hasValue && !disabled ? (_jsx("button", { type: "button", "aria-label": "Effacer la valeur", disabled: disabled, onClick: onClear, className: "pointer-events-auto flex items-center rounded-small transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })) : null, _jsx(Icon, { name: "Calendar", "aria-hidden": "true" })] }),
|
|
330
|
+
: ""}`, children: _jsx("span", { className: `min-w-0 flex-1 truncate ${display ? "text-foreground" : "text-muted-foreground"}`, children: display ?? placeholder }) }), _jsxs("span", { className: "pointer-events-none absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-inline text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0", children: [clearable && hasValue && !disabled ? (_jsx("button", { type: "button", "aria-label": "Effacer la valeur", disabled: disabled, onClick: onClear, className: "pointer-events-auto flex items-center rounded-small transition-colors duration-200 ease-out hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })) : null, _jsx(Icon, { name: "Calendar", "aria-hidden": "true" })] }), _jsx("div", { role: "dialog", "aria-modal": "false", "aria-hidden": !open, inert: !open ? true : undefined, className: `absolute top-full z-50 mt-1 overflow-hidden rounded-medium border border-border bg-surface shadow-lg transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${open
|
|
331
|
+
? "pointer-events-auto translate-y-0 opacity-100"
|
|
332
|
+
: "pointer-events-none -translate-y-1 opacity-0"}`, children: children })] }), (error || helper) && (_jsx("div", { className: "mt-inline", children: error ? (_jsx(FieldFeedback, { id: errorId, error: error })) : helper ? (_jsx("p", { id: helperId, className: "text-small text-muted-foreground", children: helper })) : null }))] }));
|
|
200
333
|
}
|
|
201
334
|
function initialViewMonth(value, fallback) {
|
|
202
335
|
const source = value ?? fallback ?? new Date();
|
|
@@ -221,10 +354,10 @@ export function DatePicker({ label, value, onChange, placeholder = "Sélectionne
|
|
|
221
354
|
onChange(next);
|
|
222
355
|
setOpen(false);
|
|
223
356
|
};
|
|
224
|
-
return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATE_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelect, isSelected: (day) => isSameDay(day, value), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
357
|
+
return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATE_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelect, isSelected: (day) => isSameDay(day, value), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => handleSelect(clampToBounds(preset.get(startOfDay(new Date())), minDate, maxDate)) }, preset.label))) }), _jsx("div", { className: "flex justify-end", children: _jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
|
|
358
|
+
onChange(null);
|
|
359
|
+
setOpen(false);
|
|
360
|
+
}, children: "Effacer" }) })] }) }) }));
|
|
228
361
|
}
|
|
229
362
|
/* ------------------------------------------------------------------ */
|
|
230
363
|
/* DateTimePicker — date + time */
|
|
@@ -260,7 +393,11 @@ export function DateTimePicker({ label, value, onChange, placeholder = "Sélecti
|
|
|
260
393
|
apply(draftDate, nextTime);
|
|
261
394
|
}
|
|
262
395
|
};
|
|
263
|
-
return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATETIME_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: (day) => isSameDay(day, draftDate), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
396
|
+
return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATETIME_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: (day) => isSameDay(day, draftDate), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => {
|
|
397
|
+
const nextDay = clampToBounds(preset.get(startOfDay(new Date())), minDate, maxDate);
|
|
398
|
+
setViewMonth(initialViewMonth(nextDay));
|
|
399
|
+
handleSelectDay(nextDay);
|
|
400
|
+
} }, preset.label))) }), _jsxs("label", { className: "flex items-center justify-between gap-2 text-label text-muted-foreground", children: [_jsx("span", { children: "Heure" }), _jsx("input", { type: "time", value: timeText, onChange: (event) => handleTimeChange(event.target.value), className: "ds-input w-auto py-1.5", "aria-label": "Heure" })] }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
|
|
264
401
|
onChange(null);
|
|
265
402
|
setOpen(false);
|
|
266
403
|
}, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "primary", size: "sm", disabled: !draftDate, onClick: () => {
|
|
@@ -309,19 +446,27 @@ export function DateRangePicker({ label, value, onChange, placeholder = "Sélect
|
|
|
309
446
|
!isSameDay(day, draft.from) &&
|
|
310
447
|
!isSameDay(day, draft.to);
|
|
311
448
|
};
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
449
|
+
const pickingEnd = Boolean(draft.from && !draft.to);
|
|
450
|
+
const rangeComplete = Boolean(draft.from && draft.to);
|
|
451
|
+
const applyRange = (next) => {
|
|
452
|
+
const clamped = clampRange(next, minDate, maxDate);
|
|
453
|
+
setDraft(clamped);
|
|
454
|
+
if (clamped.from)
|
|
455
|
+
setViewMonth(initialViewMonth(clamped.from, clamped.to));
|
|
456
|
+
};
|
|
457
|
+
return (_jsxs(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: formatRangeLabel(value), placeholder: placeholder, clearable: clearable, hasValue: Boolean(value.from || value.to), onClear: () => onChange({ from: null, to: null }), children: [_jsx("p", { className: "w-[17.5rem] border-b border-border px-3 py-control text-center text-body-medium text-primary", children: rangeComplete
|
|
458
|
+
? `${DATE_FORMAT.format(draft.from)} – ${DATE_FORMAT.format(draft.to)}`
|
|
459
|
+
: pickingEnd
|
|
460
|
+
? "Choisissez la date de fin."
|
|
461
|
+
: "Choisissez la date de début." }), _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: () => false, isRangeStart: (day) => isSameDay(day, draft.from), isRangeEnd: (day) => isSameDay(day, draft.to), isInRange: inRange, minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: RANGE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => applyRange(preset.get(startOfDay(new Date()))) }, preset.label))) }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
|
|
462
|
+
const empty = { from: null, to: null };
|
|
463
|
+
setDraft(empty);
|
|
464
|
+
onChange(empty);
|
|
465
|
+
setOpen(false);
|
|
466
|
+
}, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "primary", size: "sm", disabled: !draft.from || !draft.to, onClick: () => {
|
|
467
|
+
if (!draft.from || !draft.to)
|
|
468
|
+
return;
|
|
469
|
+
onChange(draft);
|
|
470
|
+
setOpen(false);
|
|
471
|
+
}, children: "Appliquer" })] })] }) })] }));
|
|
327
472
|
}
|
package/dist/drawer.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type DrawerSide = "left" | "right" | "top" | "bottom";
|
|
3
|
+
export interface DrawerProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
title: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
/** Edge the panel slides from. Defaults to `bottom` (slides up). */
|
|
9
|
+
side?: DrawerSide;
|
|
10
|
+
footer?: ReactNode;
|
|
11
|
+
primaryAction?: {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
};
|
|
15
|
+
secondaryAction?: {
|
|
16
|
+
label: string;
|
|
17
|
+
onClick: () => void;
|
|
18
|
+
};
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Panneau latéral (tiroir) — glisse depuis un bord de l’écran.
|
|
23
|
+
* Même contrat que Modal : overlay, Escape, focus piégé, overscroll contenu.
|
|
24
|
+
*/
|
|
25
|
+
export default function Drawer({ open, title, children, onClose, side, footer, primaryAction, secondaryAction, className, }: DrawerProps): import("react").ReactPortal | null;
|
|
26
|
+
//# sourceMappingURL=drawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../components/ui/drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,aAAa,CAAC,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IACF,eAAe,CAAC,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAyCD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAe,EACf,MAAM,EACN,aAAa,EACb,eAAe,EACf,SAAc,GACf,EAAE,WAAW,sCAyIb"}
|
package/dist/drawer.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import Icon from "./icon";
|
|
6
|
+
import ClickableButton from "./button";
|
|
7
|
+
/** Matches Tailwind `duration-200` for enter/exit unmount timing. */
|
|
8
|
+
const ANIMATION_MS = 300;
|
|
9
|
+
const FOCUSABLE_SELECTOR = [
|
|
10
|
+
"a[href]",
|
|
11
|
+
"button:not([disabled])",
|
|
12
|
+
"textarea:not([disabled])",
|
|
13
|
+
"input:not([disabled])",
|
|
14
|
+
"select:not([disabled])",
|
|
15
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
16
|
+
].join(", ");
|
|
17
|
+
function getFocusables(panel) {
|
|
18
|
+
return panel
|
|
19
|
+
? Array.from(panel.querySelectorAll(FOCUSABLE_SELECTOR))
|
|
20
|
+
: [];
|
|
21
|
+
}
|
|
22
|
+
const SIDE_PANEL_CLASS = {
|
|
23
|
+
left: "left-0 top-0 h-full w-full max-w-md rounded-r-large border-r",
|
|
24
|
+
right: "right-0 top-0 h-full w-full max-w-md rounded-l-large border-l",
|
|
25
|
+
top: "left-0 top-0 w-full max-h-[85vh] rounded-b-large border-b",
|
|
26
|
+
bottom: "bottom-0 left-0 w-full max-h-[85vh] rounded-t-large border-t",
|
|
27
|
+
};
|
|
28
|
+
function sideMotionClass(side, visible) {
|
|
29
|
+
if (visible) {
|
|
30
|
+
return "translate-x-0 translate-y-0";
|
|
31
|
+
}
|
|
32
|
+
switch (side) {
|
|
33
|
+
case "left":
|
|
34
|
+
return "-translate-x-full";
|
|
35
|
+
case "right":
|
|
36
|
+
return "translate-x-full";
|
|
37
|
+
case "top":
|
|
38
|
+
return "-translate-y-full";
|
|
39
|
+
case "bottom":
|
|
40
|
+
// Off-screen below → slides up into view (bottom → top).
|
|
41
|
+
return "translate-y-full";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Panneau latéral (tiroir) — glisse depuis un bord de l’écran.
|
|
46
|
+
* Même contrat que Modal : overlay, Escape, focus piégé, overscroll contenu.
|
|
47
|
+
*/
|
|
48
|
+
export default function Drawer({ open, title, children, onClose, side = "bottom", footer, primaryAction, secondaryAction, className = "", }) {
|
|
49
|
+
const titleId = useId();
|
|
50
|
+
const panelRef = useRef(null);
|
|
51
|
+
const previouslyFocusedRef = useRef(null);
|
|
52
|
+
const [present, setPresent] = useState(open);
|
|
53
|
+
const [visible, setVisible] = useState(open);
|
|
54
|
+
// Keep the open side through the exit animation (callers often reset side on close).
|
|
55
|
+
const [activeSide, setActiveSide] = useState(side);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (open) {
|
|
58
|
+
setActiveSide(side);
|
|
59
|
+
setPresent(true);
|
|
60
|
+
const frame = requestAnimationFrame(() => {
|
|
61
|
+
requestAnimationFrame(() => setVisible(true));
|
|
62
|
+
});
|
|
63
|
+
return () => cancelAnimationFrame(frame);
|
|
64
|
+
}
|
|
65
|
+
setVisible(false);
|
|
66
|
+
const timeout = window.setTimeout(() => setPresent(false), ANIMATION_MS);
|
|
67
|
+
return () => window.clearTimeout(timeout);
|
|
68
|
+
}, [open, side]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!present)
|
|
71
|
+
return;
|
|
72
|
+
const previousOverflow = document.body.style.overflow;
|
|
73
|
+
document.body.style.overflow = "hidden";
|
|
74
|
+
return () => {
|
|
75
|
+
document.body.style.overflow = previousOverflow;
|
|
76
|
+
};
|
|
77
|
+
}, [present]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!open)
|
|
80
|
+
return;
|
|
81
|
+
const handleKeyDown = (event) => {
|
|
82
|
+
if (event.key === "Escape")
|
|
83
|
+
onClose();
|
|
84
|
+
};
|
|
85
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
86
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
87
|
+
}, [open, onClose]);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!open)
|
|
90
|
+
return;
|
|
91
|
+
previouslyFocusedRef.current =
|
|
92
|
+
document.activeElement instanceof HTMLElement
|
|
93
|
+
? document.activeElement
|
|
94
|
+
: null;
|
|
95
|
+
const focusables = getFocusables(panelRef.current);
|
|
96
|
+
(focusables[0] ?? panelRef.current)?.focus();
|
|
97
|
+
return () => {
|
|
98
|
+
previouslyFocusedRef.current?.focus?.();
|
|
99
|
+
previouslyFocusedRef.current = null;
|
|
100
|
+
};
|
|
101
|
+
}, [open]);
|
|
102
|
+
if (!present)
|
|
103
|
+
return null;
|
|
104
|
+
const handlePanelKeyDown = (event) => {
|
|
105
|
+
if (event.key !== "Tab")
|
|
106
|
+
return;
|
|
107
|
+
const focusables = getFocusables(panelRef.current);
|
|
108
|
+
if (focusables.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
const first = focusables[0];
|
|
111
|
+
const last = focusables[focusables.length - 1];
|
|
112
|
+
const active = document.activeElement;
|
|
113
|
+
if (!event.shiftKey &&
|
|
114
|
+
(!panelRef.current?.contains(active) || active === last)) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
first.focus();
|
|
117
|
+
}
|
|
118
|
+
else if (event.shiftKey &&
|
|
119
|
+
(!panelRef.current?.contains(active) || active === first)) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
last.focus();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return createPortal(_jsx("div", { className: `fixed inset-0 z-50 bg-black/60 transition-opacity duration-200 ease-out motion-reduce:transition-none ${visible ? "opacity-100" : "opacity-0"}`, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, onClick: onClose, children: _jsxs("div", { ref: panelRef, tabIndex: -1, className: `absolute flex flex-col overflow-hidden border-border bg-surface shadow-lg transition-transform duration-300 ease-out will-change-transform motion-reduce:transition-none motion-reduce:duration-0 ${SIDE_PANEL_CLASS[activeSide]} ${sideMotionClass(activeSide, visible)} ${className}`, onClick: (event) => event.stopPropagation(), onKeyDown: handlePanelKeyDown, children: [_jsxs("div", { className: "flex shrink-0 items-center justify-between border-b border-border px-component py-control", children: [_jsx("h2", { id: titleId, className: "text-component-title text-foreground", children: title }), _jsx("button", { type: "button", onClick: onClose, className: "grid size-8 place-items-center rounded-small text-muted-foreground outline-none transition-colors duration-200 ease-out hover:bg-surface-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", "aria-label": "Fermer", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })] }), _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain px-component py-control", children: children }), (footer || primaryAction || secondaryAction) && (_jsxs("div", { className: "flex shrink-0 items-center justify-end gap-inline border-t border-border px-component py-control", children: [secondaryAction && (_jsx(ClickableButton, { type: "button", onClick: secondaryAction.onClick, variant: "ghost", children: secondaryAction.label })), footer, primaryAction && (_jsx(ClickableButton, { onClick: primaryAction.onClick, children: primaryAction.label }))] }))] }) }), document.body);
|
|
125
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export type { Column, CardAction, TableCardActions } from "./table";
|
|
|
11
11
|
export { Select, MultiSelect, SelectWithSearch, MultiSelectWithSearch, SelectFilter } from "./select";
|
|
12
12
|
export type { SelectOption } from "./select";
|
|
13
13
|
export { default as Modal } from "./modal";
|
|
14
|
+
export { default as Drawer } from "./drawer";
|
|
15
|
+
export type { DrawerProps, DrawerSide } from "./drawer";
|
|
14
16
|
export { default as Tabs } from "./tab";
|
|
15
17
|
export type { Tab } from "./tab";
|
|
16
18
|
export { default as Icon } from "./icon";
|
|
@@ -27,4 +29,20 @@ export { DatePicker, DateTimePicker, DateRangePicker } from "./date-picker";
|
|
|
27
29
|
export type { DatePickerProps, DateTimePickerProps, DateRangePickerProps, DateRangeValue, } from "./date-picker";
|
|
28
30
|
export { default as Agenda, AGENDA_STATUS_OPTIONS } from "./agenda";
|
|
29
31
|
export type { AgendaProps, AgendaEvent, AgendaView, AgendaEventStatus, AgendaStatusOption, AgendaStatusStyle, AgendaListRow, DateRangeValue as AgendaDateRangeValue, } from "./agenda";
|
|
32
|
+
export { default as Chart, CHART_COLORS } from "./chart";
|
|
33
|
+
export type { ChartProps, ChartType, ChartSeries, ChartDataPoint, } from "./chart";
|
|
34
|
+
export { Toaster, toast } from "./toast";
|
|
35
|
+
export type { ToastOptions, ToastVariant, ToastPosition, ToasterProps, } from "./toast";
|
|
36
|
+
export { default as Switch } from "./switch";
|
|
37
|
+
export type { SwitchProps, SwitchSize } from "./switch";
|
|
38
|
+
export { default as Tooltip } from "./tooltip";
|
|
39
|
+
export type { TooltipProps, TooltipSide } from "./tooltip";
|
|
40
|
+
export { default as Checkbox } from "./checkbox";
|
|
41
|
+
export type { CheckboxProps, CheckboxSize } from "./checkbox";
|
|
42
|
+
export { RadioGroup, Radio } from "./radio";
|
|
43
|
+
export type { RadioGroupProps, RadioProps, RadioSize } from "./radio";
|
|
44
|
+
export { default as Skeleton } from "./skeleton";
|
|
45
|
+
export type { SkeletonProps, SkeletonShape } from "./skeleton";
|
|
46
|
+
export { default as Pagination } from "./pagination";
|
|
47
|
+
export type { PaginationProps } from "./pagination";
|
|
30
48
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../components/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,UAAU,CAAC;AACtD,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,UAAU,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,SAAS,CAAC;AACzC,YAAY,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7E,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,UA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IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as Avatar, AvatarGroup, getAvatarInitials } from "./avatar";
|
|
|
5
5
|
export { default as Table } from "./table";
|
|
6
6
|
export { Select, MultiSelect, SelectWithSearch, MultiSelectWithSearch, SelectFilter } from "./select";
|
|
7
7
|
export { default as Modal } from "./modal";
|
|
8
|
+
export { default as Drawer } from "./drawer";
|
|
8
9
|
export { default as Tabs } from "./tab";
|
|
9
10
|
export { default as Icon } from "./icon";
|
|
10
11
|
export { default as Loader } from "./loader";
|
|
@@ -13,3 +14,11 @@ export { default as Stepper } from "./stepper";
|
|
|
13
14
|
export { default as Accordion } from "./accordion";
|
|
14
15
|
export { DatePicker, DateTimePicker, DateRangePicker } from "./date-picker";
|
|
15
16
|
export { default as Agenda, AGENDA_STATUS_OPTIONS } from "./agenda";
|
|
17
|
+
export { default as Chart, CHART_COLORS } from "./chart";
|
|
18
|
+
export { Toaster, toast } from "./toast";
|
|
19
|
+
export { default as Switch } from "./switch";
|
|
20
|
+
export { default as Tooltip } from "./tooltip";
|
|
21
|
+
export { default as Checkbox } from "./checkbox";
|
|
22
|
+
export { RadioGroup, Radio } from "./radio";
|
|
23
|
+
export { default as Skeleton } from "./skeleton";
|
|
24
|
+
export { default as Pagination } from "./pagination";
|
package/dist/input.js
CHANGED
|
@@ -72,9 +72,9 @@ export default function Input({ label, icon, trailingIcon, state, error, helper,
|
|
|
72
72
|
: state === "invalid" || error
|
|
73
73
|
? "border-danger hover:border-danger focus:border-danger"
|
|
74
74
|
: "";
|
|
75
|
-
return (_jsxs("div", { className: "w-full", children: [label && (_jsxs("label", { htmlFor: inputId, className: LABEL_CLASS, children: [_jsx("span", { className: "truncate", children: label }), required && _jsx(RequiredMark, {})] })), _jsxs("div", { className: "relative w-full", children: [icon && (_jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: icon })), _jsx("input", { ref: setRefs, id: inputId, type: resolvedType, disabled: disabled, required: required, "aria-invalid": state === "invalid" || Boolean(error) || undefined, "aria-required": required || undefined, "aria-describedby": describedBy, maxLength: maxLength, value: value, defaultValue: defaultValue, onChange: handleChange, className: `ds-input ${icon ? "pl-9" : ""} ${rightPad} ${toneClass} ${className}`, ...props }), rightCount > 0 && (_jsxs("span", { className: "absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-inline", children: [state === "valid" && !trailingIcon && (_jsx(Icon, { name: "Check", variant: "success", "aria-hidden": "true" })), !trailingIcon && (state === "invalid" || error) && (_jsx(Icon, { name: "CircleAlert", variant: "danger", "aria-hidden": "true" })), trailingIcon && (_jsx("span", { className: "pointer-events-none text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: trailingIcon })), hasClear && (_jsx("button", { type: "button", onClick: handleClear, "aria-label": "Effacer la valeur", className: "flex items-center rounded-small text-muted-foreground transition-colors hover:text-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })), isPassword && (_jsx("button", { type: "button", onClick: () => setShowPassword((prev) => !prev), "aria-label": showPassword
|
|
75
|
+
return (_jsxs("div", { className: "w-full", children: [label && (_jsxs("label", { htmlFor: inputId, className: LABEL_CLASS, children: [_jsx("span", { className: "truncate", children: label }), required && _jsx(RequiredMark, {})] })), _jsxs("div", { className: "relative w-full", children: [icon && (_jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 flex -translate-y-1/2 items-center text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: icon })), _jsx("input", { ref: setRefs, id: inputId, type: resolvedType, disabled: disabled, required: required, "aria-invalid": state === "invalid" || Boolean(error) || undefined, "aria-required": required || undefined, "aria-describedby": describedBy, maxLength: maxLength, value: value, defaultValue: defaultValue, onChange: handleChange, className: `ds-input ${icon ? "pl-9" : ""} ${rightPad} ${toneClass} ${className}`, ...props }), rightCount > 0 && (_jsxs("span", { className: "absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-inline", children: [state === "valid" && !trailingIcon && (_jsx(Icon, { name: "Check", variant: "success", "aria-hidden": "true" })), !trailingIcon && (state === "invalid" || error) && (_jsx(Icon, { name: "CircleAlert", variant: "danger", "aria-hidden": "true" })), trailingIcon && (_jsx("span", { className: "pointer-events-none text-muted-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: trailingIcon })), hasClear && (_jsx("button", { type: "button", onClick: handleClear, "aria-label": "Effacer la valeur", className: "flex items-center rounded-small text-muted-foreground transition-colors duration-200 ease-out hover:text-foreground motion-reduce:transition-none [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })), isPassword && (_jsx("button", { type: "button", onClick: () => setShowPassword((prev) => !prev), "aria-label": showPassword
|
|
76
76
|
? "Masquer le mot de passe"
|
|
77
|
-
: "Afficher le mot de passe", className: "flex items-center rounded-small text-muted-foreground transition-colors hover:text-foreground [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: showPassword ? (_jsx(Icon, { name: "EyeOff", "aria-hidden": "true" })) : (_jsx(Icon, { name: "Eye", "aria-hidden": "true" })) }))] }))] }), (error || helper || counter) && (_jsxs("div", { className: "mt-inline flex items-start justify-between gap-inline", children: [_jsx("div", { className: "min-w-0", children: error ? (_jsx(FieldFeedback, { id: errorId, error: error })) : helper ? (_jsx("p", { id: helperId, className: "text-small text-muted-foreground", children: helper })) : null }), counter && (_jsxs("span", { className: "shrink-0 text-small text-muted-foreground", children: [effectiveValue.length, typeof maxLength === "number" ? ` / ${maxLength}` : ""] }))] }))] }));
|
|
77
|
+
: "Afficher le mot de passe", className: "flex items-center rounded-small text-muted-foreground transition-colors duration-200 ease-out hover:text-foreground motion-reduce:transition-none [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current", children: showPassword ? (_jsx(Icon, { name: "EyeOff", "aria-hidden": "true" })) : (_jsx(Icon, { name: "Eye", "aria-hidden": "true" })) }))] }))] }), (error || helper || counter) && (_jsxs("div", { className: "mt-inline flex items-start justify-between gap-inline", children: [_jsx("div", { className: "min-w-0", children: error ? (_jsx(FieldFeedback, { id: errorId, error: error })) : helper ? (_jsx("p", { id: helperId, className: "text-small text-muted-foreground", children: helper })) : null }), counter && (_jsxs("span", { className: "shrink-0 text-small text-muted-foreground", children: [effectiveValue.length, typeof maxLength === "number" ? ` / ${maxLength}` : ""] }))] }))] }));
|
|
78
78
|
}
|
|
79
79
|
export function Textarea({ label, state, error, helper, required = false, counter = false, id, disabled, maxLength, value, defaultValue, onChange, className = "", ref, ...props }) {
|
|
80
80
|
const generatedId = useId();
|
package/dist/metric-bar.js
CHANGED
|
@@ -15,5 +15,5 @@ const TONE_BG = {
|
|
|
15
15
|
*/
|
|
16
16
|
export default function MetricBar({ value, tone, }) {
|
|
17
17
|
const width = Math.min(100, Math.max(2, value));
|
|
18
|
-
return (_jsxs("div", { className: "flex items-center gap-inline", children: [_jsx("div", { className: "h-1.5 w-24 overflow-hidden rounded-full bg-surface-muted", children: _jsx("div", { className: `h-full rounded-full ${TONE_BG[tone]}`, style: { width: `${width}%` } }) }), _jsxs("span", { className: "text-small text-muted-foreground", children: [value.toFixed(0), " %"] })] }));
|
|
18
|
+
return (_jsxs("div", { className: "flex items-center gap-inline", children: [_jsx("div", { className: "h-1.5 w-24 overflow-hidden rounded-full bg-surface-muted", children: _jsx("div", { className: `h-full rounded-full transition-[width] duration-200 ease-out motion-reduce:transition-none ${TONE_BG[tone]}`, style: { width: `${width}%` } }) }), _jsxs("span", { className: "text-small text-muted-foreground", children: [value.toFixed(0), " %"] })] }));
|
|
19
19
|
}
|
package/dist/modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../components/ui/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../components/ui/modal.tsx"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,UAAU,UAAU;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,aAAa,CAAC,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;IACF,eAAe,CAAC,EAAE;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,CAAC;CACH;AAmBD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,EACP,MAAM,EACN,aAAa,EACb,eAAe,GAChB,EAAE,UAAU,sCAiJZ"}
|