@modoock/components 2.2.0 → 2.3.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/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +5 -3
- 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 +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -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/select.d.ts.map +1 -1
- package/dist/select.js +9 -5
- 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.js +6 -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/accordion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../components/ui/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIjD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,uCAAuC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,KAAK,EACL,aAAoB,EACpB,SAAc,GACf,EAAE,cAAc,+
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../components/ui/accordion.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIjD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,uCAAuC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,cAAc;IACtB,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,KAAK,EACL,aAAoB,EACpB,SAAc,GACf,EAAE,cAAc,+BAsEhB"}
|
package/dist/accordion.js
CHANGED
|
@@ -25,6 +25,6 @@ export default function Accordion({ items, allowMultiple = true, className = "",
|
|
|
25
25
|
const isOpen = openIds.has(item.id);
|
|
26
26
|
const panelId = `accordion-panel-${item.id}`;
|
|
27
27
|
const headerId = `accordion-header-${item.id}`;
|
|
28
|
-
return (_jsxs("section", { className: "overflow-hidden rounded-large border border-border bg-surface", children: [_jsx("h3", { className: "m-0", children: _jsxs(ClickableButton, { type: "button", variant: "bare", id: headerId, "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(item.id), className: "flex !h-auto w-full items-center justify-between gap-inline rounded-none px-component py-component text-left text-component-title text-foreground hover:bg-surface-muted focus-visible:ring-primary", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx(Icon, { name: "ChevronDown", "aria-hidden": "true", className: `shrink-0 transition-transform ${isOpen ? "rotate-180" : ""}` })] }) }),
|
|
28
|
+
return (_jsxs("section", { className: "overflow-hidden rounded-large border border-border bg-surface", children: [_jsx("h3", { className: "m-0", children: _jsxs(ClickableButton, { type: "button", variant: "bare", id: headerId, "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(item.id), className: "flex !h-auto w-full items-center justify-between gap-inline rounded-none px-component py-component text-left text-component-title text-foreground transition-colors duration-200 ease-out hover:bg-surface-muted focus-visible:ring-primary motion-reduce:transition-none", children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx(Icon, { name: "ChevronDown", "aria-hidden": "true", className: `shrink-0 transition-transform duration-200 ease-out motion-reduce:transition-none ${isOpen ? "rotate-180" : ""}` })] }) }), _jsx("div", { id: panelId, role: "region", "aria-labelledby": headerId, "aria-hidden": !isOpen, inert: !isOpen ? true : undefined, className: `grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${isOpen ? "grid-rows-[1fr]" : "grid-rows-[0fr]"}`, children: _jsx("div", { className: "min-h-0 overflow-hidden", children: _jsx("div", { className: "border-t border-border px-component py-component", children: item.content }) }) })] }, item.id));
|
|
29
29
|
}) }));
|
|
30
30
|
}
|
package/dist/agenda.js
CHANGED
|
@@ -260,7 +260,7 @@ function EventChip({ event, onSelect, statusStyles, }) {
|
|
|
260
260
|
e.preventDefault();
|
|
261
261
|
e.stopPropagation();
|
|
262
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 })] })] }));
|
|
263
|
+
}, className: `flex w-full items-stretch overflow-hidden rounded-small text-left transition-opacity duration-200 ease-out motion-reduce:transition-none 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
264
|
}
|
|
265
265
|
function DayEventsModal({ open, title, events, onClose, onSelectEvent, statusOptions, statusStyles, }) {
|
|
266
266
|
if (!open)
|
|
@@ -271,7 +271,7 @@ function DayEventsModal({ open, title, events, onClose, onSelectEvent, statusOpt
|
|
|
271
271
|
return (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => {
|
|
272
272
|
onClose();
|
|
273
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
|
|
274
|
+
}, className: "flex w-full items-start gap-inline rounded-large border border-border bg-surface px-component py-control text-left transition-colors duration-200 ease-out motion-reduce:transition-none 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
275
|
? ` – ${formatEventTime(event.endAt)}`
|
|
276
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
277
|
}) }) }));
|
|
@@ -371,13 +371,13 @@ function MonthView({ events, anchorDate, onSelectEvent, onCreateSlot, maxEventsP
|
|
|
371
371
|
e.preventDefault();
|
|
372
372
|
openDay(cellDate, dayEvents);
|
|
373
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
|
|
374
|
+
}, className: `group relative flex min-h-[6.5rem] flex-col gap-micro border-b border-r border-border p-inline transition-colors duration-200 ease-out motion-reduce:transition-none 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
375
|
? "bg-surface hover:bg-surface-muted/60"
|
|
376
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
377
|
? "bg-primary font-semibold text-primary-foreground"
|
|
378
378
|
: inMonth
|
|
379
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 &&
|
|
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 duration-200 ease-out motion-reduce:transition-none 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
381
|
visible.map((event) => (_jsx(EventChip, { event: event, onSelect: onSelectEvent, statusStyles: statusStyles }, event.id))), mounted && extra > 0 ? (_jsxs("button", { type: "button", onClick: (e) => {
|
|
382
382
|
e.stopPropagation();
|
|
383
383
|
openDay(cellDate, dayEvents);
|
|
@@ -444,7 +444,7 @@ function WeekView({ events, anchorDate, onSelectEvent, onCreateSlot, weekStartHo
|
|
|
444
444
|
return (_jsxs("button", { type: "button", onClick: (e) => {
|
|
445
445
|
e.stopPropagation();
|
|
446
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: {
|
|
447
|
+
}, className: `absolute right-1 left-1 z-[1] flex overflow-hidden rounded-small text-left shadow-sm transition-opacity duration-200 ease-out motion-reduce:transition-none hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${style.event}`, style: {
|
|
448
448
|
top: `${topPct}%`,
|
|
449
449
|
height: `${heightPct}%`,
|
|
450
450
|
minHeight: "1.35rem",
|
package/dist/button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Icon from "./icon";
|
|
3
|
-
const BASE_CLASS = "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-medium text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current";
|
|
3
|
+
const BASE_CLASS = "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-medium text-sm font-medium outline-none transition-[color,background-color,border-color,opacity,filter] duration-200 ease-out focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60 motion-reduce:transition-none [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0 [&_svg]:text-current";
|
|
4
4
|
const SIZE_CLASS = {
|
|
5
5
|
sm: "h-9 px-3",
|
|
6
6
|
md: "h-10 px-4",
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type ChartType = "line" | "area" | "bar" | "stacked-bar" | "donut" | "sparkline";
|
|
2
|
+
export type ChartDataPoint = Record<string, string | number>;
|
|
3
|
+
export interface ChartSeries {
|
|
4
|
+
/** Key in each data point. */
|
|
5
|
+
key: string;
|
|
6
|
+
/** Legend / tooltip label (French in product copy). */
|
|
7
|
+
label: string;
|
|
8
|
+
/** CSS color (token var or hex). Defaults to the Modoock palette. */
|
|
9
|
+
color?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ChartProps {
|
|
12
|
+
type: ChartType;
|
|
13
|
+
data: ChartDataPoint[];
|
|
14
|
+
/**
|
|
15
|
+
* Category axis key (line/area/bar) or slice name key (donut).
|
|
16
|
+
* Ignored for sparkline.
|
|
17
|
+
*/
|
|
18
|
+
categoryKey: string;
|
|
19
|
+
series: ChartSeries[];
|
|
20
|
+
/** Chart height in pixels. Defaults by type. */
|
|
21
|
+
height?: number;
|
|
22
|
+
showGrid?: boolean;
|
|
23
|
+
showLegend?: boolean;
|
|
24
|
+
showTooltip?: boolean;
|
|
25
|
+
className?: string;
|
|
26
|
+
/** Accessible name for the chart region. */
|
|
27
|
+
"aria-label"?: string;
|
|
28
|
+
emptyTitle?: string;
|
|
29
|
+
emptyDescription?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const CHART_COLORS: readonly ["var(--color-primary)", "var(--color-info)", "var(--color-success)", "var(--color-accent)", "var(--color-border-strong)", "var(--color-muted-foreground)"];
|
|
32
|
+
/**
|
|
33
|
+
* Graphiques métier (argent, santé, tableaux de bord) via Recharts.
|
|
34
|
+
* Types : line, area, bar, stacked-bar, donut, sparkline.
|
|
35
|
+
*/
|
|
36
|
+
export default function Chart({ type, data, categoryKey, series, height, showGrid, showLegend, showTooltip, className, "aria-label": ariaLabel, emptyTitle, emptyDescription, }: ChartProps): import("react").JSX.Element;
|
|
37
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../components/ui/chart.tsx"],"names":[],"mappings":"AA0BA,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,MAAM,GACN,KAAK,GACL,aAAa,GACb,OAAO,GACP,WAAW,CAAC;AAEhB,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD,eAAO,MAAM,YAAY,sKAOf,CAAC;AAyHX;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,MAAM,EACN,MAAM,EACN,QAAe,EACf,UAAiB,EACjB,WAAkB,EAClB,SAAc,EACd,YAAY,EAAE,SAAS,EACvB,UAA4B,EAC5B,gBAAkF,GACnF,EAAE,UAAU,+BA4MZ"}
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, Legend, Line, LineChart, Pie, PieChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts";
|
|
4
|
+
import Icon from "./icon";
|
|
5
|
+
/* ------------------------------------------------------------------ */
|
|
6
|
+
/* Palette — avoid orange/warning as decorative series colors */
|
|
7
|
+
/* ------------------------------------------------------------------ */
|
|
8
|
+
export const CHART_COLORS = [
|
|
9
|
+
"var(--color-primary)",
|
|
10
|
+
"var(--color-info)",
|
|
11
|
+
"var(--color-success)",
|
|
12
|
+
"var(--color-accent)",
|
|
13
|
+
"var(--color-border-strong)",
|
|
14
|
+
"var(--color-muted-foreground)",
|
|
15
|
+
];
|
|
16
|
+
function seriesColor(series, index) {
|
|
17
|
+
return series.color ?? CHART_COLORS[index % CHART_COLORS.length];
|
|
18
|
+
}
|
|
19
|
+
/* ------------------------------------------------------------------ */
|
|
20
|
+
/* Shared chrome */
|
|
21
|
+
/* ------------------------------------------------------------------ */
|
|
22
|
+
const AXIS_TICK = {
|
|
23
|
+
fill: "var(--color-muted-foreground)",
|
|
24
|
+
fontSize: 12,
|
|
25
|
+
};
|
|
26
|
+
const GRID_STROKE = "var(--color-border)";
|
|
27
|
+
const TOOLTIP_CURSOR = { fill: "var(--color-surface-muted)" };
|
|
28
|
+
function defaultHeight(type) {
|
|
29
|
+
if (type === "sparkline")
|
|
30
|
+
return 40;
|
|
31
|
+
if (type === "donut")
|
|
32
|
+
return 240;
|
|
33
|
+
return 280;
|
|
34
|
+
}
|
|
35
|
+
function ChartEmpty({ title, description, height, }) {
|
|
36
|
+
return (_jsxs("div", { className: "flex w-full flex-col items-center justify-center gap-inline rounded-medium border border-dashed border-border bg-surface-muted px-component text-center", style: { height }, role: "status", children: [_jsx(Icon, { name: "ChartColumnIncreasing", variant: "muted", "aria-hidden": "true" }), _jsx("p", { className: "text-body-medium text-foreground", children: title }), _jsx("p", { className: "max-w-xs text-small text-muted-foreground", children: description })] }));
|
|
37
|
+
}
|
|
38
|
+
function ChartTooltipContent({ active, payload, label, series, }) {
|
|
39
|
+
if (!active || !payload?.length)
|
|
40
|
+
return null;
|
|
41
|
+
const labelByKey = new Map(series.map((item) => [item.key, item.label]));
|
|
42
|
+
return (_jsxs("div", { className: "rounded-medium border border-border bg-surface px-component py-control shadow-lg", children: [label != null && label !== "" && (_jsx("p", { className: "mb-micro text-label text-muted-foreground", children: label })), _jsx("ul", { className: "flex flex-col gap-micro", children: payload.map((entry, index) => {
|
|
43
|
+
const key = String(entry.dataKey ?? "");
|
|
44
|
+
const rowLabel = entry.name && !labelByKey.has(String(entry.name))
|
|
45
|
+
? entry.name
|
|
46
|
+
: (labelByKey.get(key) ?? entry.name ?? key);
|
|
47
|
+
return (_jsxs("li", { className: "flex items-center justify-between gap-component text-small text-foreground", children: [_jsx("span", { children: rowLabel }), _jsx("span", { className: "font-medium tabular-nums", children: entry.value })] }, `${key}-${index}`));
|
|
48
|
+
}) })] }));
|
|
49
|
+
}
|
|
50
|
+
function ChartFrame({ height, className, ariaLabel, children, }) {
|
|
51
|
+
return (_jsx("div", { className: `w-full min-w-0 ${className}`, style: { height }, role: "img", "aria-label": ariaLabel, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: children }) }));
|
|
52
|
+
}
|
|
53
|
+
/* ------------------------------------------------------------------ */
|
|
54
|
+
/* Chart */
|
|
55
|
+
/* ------------------------------------------------------------------ */
|
|
56
|
+
/**
|
|
57
|
+
* Graphiques métier (argent, santé, tableaux de bord) via Recharts.
|
|
58
|
+
* Types : line, area, bar, stacked-bar, donut, sparkline.
|
|
59
|
+
*/
|
|
60
|
+
export default function Chart({ type, data, categoryKey, series, height, showGrid = true, showLegend = true, showTooltip = true, className = "", "aria-label": ariaLabel, emptyTitle = "Aucune donnée", emptyDescription = "Les valeurs apparaîtront ici dès qu’elles seront disponibles.", }) {
|
|
61
|
+
const resolvedHeight = height ?? defaultHeight(type);
|
|
62
|
+
if (!data.length || !series.length) {
|
|
63
|
+
return (_jsx(ChartEmpty, { title: emptyTitle, description: emptyDescription, height: resolvedHeight }));
|
|
64
|
+
}
|
|
65
|
+
const tooltip = showTooltip ? (_jsx(Tooltip, { content: _jsx(ChartTooltipContent, { series: series }), cursor: type === "bar" || type === "stacked-bar" ? TOOLTIP_CURSOR : undefined })) : null;
|
|
66
|
+
const legend = showLegend ? (_jsx(Legend, { wrapperStyle: { fontSize: 12, color: "var(--color-muted-foreground)" }, formatter: (value) => {
|
|
67
|
+
const match = series.find((item) => item.key === value);
|
|
68
|
+
return match?.label ?? value;
|
|
69
|
+
} })) : null;
|
|
70
|
+
const grid = showGrid ? (_jsx(CartesianGrid, { stroke: GRID_STROKE, strokeDasharray: "3 3", vertical: false })) : null;
|
|
71
|
+
if (type === "sparkline") {
|
|
72
|
+
const primary = series[0];
|
|
73
|
+
const color = seriesColor(primary, 0);
|
|
74
|
+
return (_jsx(ChartFrame, { height: resolvedHeight, className: className, ariaLabel: ariaLabel ?? primary.label, children: _jsx(LineChart, { data: data, margin: { top: 4, right: 0, left: 0, bottom: 0 }, children: _jsx(Line, { type: "monotone", dataKey: primary.key, stroke: color, strokeWidth: 2, dot: false, isAnimationActive: true, animationDuration: 200 }) }) }));
|
|
75
|
+
}
|
|
76
|
+
if (type === "donut") {
|
|
77
|
+
const valueKey = series[0].key;
|
|
78
|
+
return (_jsx(ChartFrame, { height: resolvedHeight, className: className, ariaLabel: ariaLabel ?? "Répartition", children: _jsxs(PieChart, { children: [_jsx(Pie, { data: data, dataKey: valueKey, nameKey: categoryKey, innerRadius: "58%", outerRadius: "80%", paddingAngle: 2, stroke: "var(--color-surface)", strokeWidth: 2, isAnimationActive: true, animationDuration: 200, children: data.map((_, index) => (_jsx(Cell, { fill: seriesColor(series[0], index) }, `slice-${index}`))) }), tooltip, legend] }) }));
|
|
79
|
+
}
|
|
80
|
+
if (type === "line") {
|
|
81
|
+
return (_jsx(ChartFrame, { height: resolvedHeight, className: className, ariaLabel: ariaLabel, children: _jsxs(LineChart, { data: data, margin: { top: 8, right: 8, left: 0, bottom: 0 }, children: [grid, _jsx(XAxis, { dataKey: categoryKey, tick: AXIS_TICK, axisLine: false, tickLine: false }), _jsx(YAxis, { tick: AXIS_TICK, axisLine: false, tickLine: false, width: 40 }), tooltip, legend, series.map((item, index) => (_jsx(Line, { type: "monotone", dataKey: item.key, name: item.key, stroke: seriesColor(item, index), strokeWidth: 2, dot: false, activeDot: { r: 4 }, isAnimationActive: true, animationDuration: 200 }, item.key)))] }) }));
|
|
82
|
+
}
|
|
83
|
+
if (type === "area") {
|
|
84
|
+
return (_jsx(ChartFrame, { height: resolvedHeight, className: className, ariaLabel: ariaLabel, children: _jsxs(AreaChart, { data: data, margin: { top: 8, right: 8, left: 0, bottom: 0 }, children: [grid, _jsx(XAxis, { dataKey: categoryKey, tick: AXIS_TICK, axisLine: false, tickLine: false }), _jsx(YAxis, { tick: AXIS_TICK, axisLine: false, tickLine: false, width: 40 }), tooltip, legend, series.map((item, index) => {
|
|
85
|
+
const color = seriesColor(item, index);
|
|
86
|
+
return (_jsx(Area, { type: "monotone", dataKey: item.key, name: item.key, stroke: color, fill: color, fillOpacity: 0.15, strokeWidth: 2, isAnimationActive: true, animationDuration: 200 }, item.key));
|
|
87
|
+
})] }) }));
|
|
88
|
+
}
|
|
89
|
+
// bar | stacked-bar
|
|
90
|
+
const stacked = type === "stacked-bar";
|
|
91
|
+
return (_jsx(ChartFrame, { height: resolvedHeight, className: className, ariaLabel: ariaLabel, children: _jsxs(BarChart, { data: data, margin: { top: 8, right: 8, left: 0, bottom: 0 }, children: [grid, _jsx(XAxis, { dataKey: categoryKey, tick: AXIS_TICK, axisLine: false, tickLine: false }), _jsx(YAxis, { tick: AXIS_TICK, axisLine: false, tickLine: false, width: 40 }), tooltip, legend, series.map((item, index) => (_jsx(Bar, { dataKey: item.key, name: item.key, fill: seriesColor(item, index), radius: stacked ? [0, 0, 0, 0] : [4, 4, 0, 0], stackId: stacked ? "stack" : undefined, isAnimationActive: true, animationDuration: 200 }, item.key)))] }) }));
|
|
92
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../components/ui/date-picker.tsx"],"names":[],"mappings":"AAkBA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;CACjB,CAAC;AAEF,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAoB,SAAQ,gBAAgB;IACpD,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC3C;
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../components/ui/date-picker.tsx"],"names":[],"mappings":"AAkBA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;CACjB,CAAC;AAEF,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAoB,SAAQ,gBAAgB;IACpD,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,mBAAoB,SAAQ,mBAAmB;IAC9D,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC3C;AA0bD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAsC,EACtC,OAAO,EACP,OAAO,EACP,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAgB,EAChB,SAAc,GACf,EAAE,eAAe,+BAkEjB;AAMD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAmD,EACnD,OAAO,EACP,OAAO,EACP,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAgB,EAChB,SAAc,GACf,EAAE,mBAAmB,+BAwGrB;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAyC,EACzC,OAAO,EACP,OAAO,EACP,QAAgB,EAChB,QAAgB,EAChB,KAAK,EACL,MAAM,EACN,SAAgB,EAChB,SAAc,GACf,EAAE,oBAAoB,+BA4GtB"}
|
package/dist/date-picker.js
CHANGED
|
@@ -152,7 +152,7 @@ function Calendar({ viewMonth, onViewMonthChange, onSelectDay, isSelected, isInR
|
|
|
152
152
|
const goMonth = (delta) => {
|
|
153
153
|
onViewMonthChange(new Date(viewMonth.getFullYear(), viewMonth.getMonth() + delta, 1));
|
|
154
154
|
};
|
|
155
|
-
return (_jsxs("div", { className: "w-[17.5rem] p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [_jsx("button", { type: "button", "aria-label": "Mois pr\u00E9c\u00E9dent", onClick: () => goMonth(-1), className: "flex size-8 items-center justify-center rounded-small text-muted-foreground transition-colors hover:bg-surface-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary [&_svg]:size-[var(--icon-small)]", children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsx("p", { className: "text-sm font-medium capitalize text-foreground", children: title }), _jsx("button", { type: "button", "aria-label": "Mois suivant", onClick: () => goMonth(1), className: "flex size-8 items-center justify-center rounded-small text-muted-foreground transition-colors hover:bg-surface-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary [&_svg]:size-[var(--icon-small)]", children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] }), _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) => {
|
|
155
|
+
return (_jsxs("div", { className: "w-[17.5rem] p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [_jsx("button", { type: "button", "aria-label": "Mois pr\u00E9c\u00E9dent", onClick: () => goMonth(-1), 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: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsx("p", { className: "text-sm font-medium capitalize text-foreground", children: title }), _jsx("button", { type: "button", "aria-label": "Mois suivant", onClick: () => goMonth(1), 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: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] }), _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) => {
|
|
156
156
|
if (!day) {
|
|
157
157
|
return _jsx("div", { className: "h-8" }, `empty-${index}`);
|
|
158
158
|
}
|
|
@@ -163,7 +163,7 @@ function Calendar({ viewMonth, onViewMonthChange, onSelectDay, isSelected, isInR
|
|
|
163
163
|
const rangeStart = isRangeStart?.(day) ?? false;
|
|
164
164
|
const rangeEnd = isRangeEnd?.(day) ?? false;
|
|
165
165
|
const isToday = isSameDay(day, today);
|
|
166
|
-
let dayClass = "relative flex h-8 w-full items-center justify-center rounded-small text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary";
|
|
166
|
+
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";
|
|
167
167
|
if (disabled) {
|
|
168
168
|
dayClass += " cursor-not-allowed text-muted-foreground/40";
|
|
169
169
|
}
|
|
@@ -196,7 +196,9 @@ function DateFieldShell({ label, required, disabled, error, helper, className =
|
|
|
196
196
|
.join(" ") || undefined;
|
|
197
197
|
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
198
|
? "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" })] }),
|
|
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 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
|
|
200
|
+
? "pointer-events-auto translate-y-0 opacity-100"
|
|
201
|
+
: "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
202
|
}
|
|
201
203
|
function initialViewMonth(value, fallback) {
|
|
202
204
|
const source = value ?? fallback ?? new Date();
|
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,12 @@ 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";
|
|
30
40
|
//# 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,UAAU,CAAC;AACtG,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,OAAO,CAAC;AACxC,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,cAAc,IAAI,oBAAoB,GACvC,MAAM,UAAU,CAAC"}
|
|
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,UAAU,CAAC;AACtG,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,OAAO,CAAC;AACxC,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACpE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,cAAc,IAAI,oBAAoB,GACvC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,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"}
|
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,7 @@ 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";
|
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"}
|
package/dist/modal.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useId, useRef, } from "react";
|
|
3
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import Icon from "./icon";
|
|
6
6
|
import ClickableButton from "./button";
|
|
7
|
+
/** Matches Tailwind `duration-200` for enter/exit unmount timing. */
|
|
8
|
+
const ANIMATION_MS = 200;
|
|
7
9
|
/** Selector matching every focusable element the dialog can own. */
|
|
8
10
|
const FOCUSABLE_SELECTOR = [
|
|
9
11
|
"a[href]",
|
|
@@ -25,16 +27,31 @@ export default function Modal({ open, title, children, onClose, footer, primaryA
|
|
|
25
27
|
const panelRef = useRef(null);
|
|
26
28
|
// Element that had focus before the modal opened, restored on close.
|
|
27
29
|
const previouslyFocusedRef = useRef(null);
|
|
28
|
-
|
|
30
|
+
const [present, setPresent] = useState(open);
|
|
31
|
+
const [visible, setVisible] = useState(open);
|
|
32
|
+
// Keep the portal mounted through the exit transition.
|
|
29
33
|
useEffect(() => {
|
|
30
|
-
if (
|
|
34
|
+
if (open) {
|
|
35
|
+
setPresent(true);
|
|
36
|
+
const frame = requestAnimationFrame(() => {
|
|
37
|
+
requestAnimationFrame(() => setVisible(true));
|
|
38
|
+
});
|
|
39
|
+
return () => cancelAnimationFrame(frame);
|
|
40
|
+
}
|
|
41
|
+
setVisible(false);
|
|
42
|
+
const timeout = window.setTimeout(() => setPresent(false), ANIMATION_MS);
|
|
43
|
+
return () => window.clearTimeout(timeout);
|
|
44
|
+
}, [open]);
|
|
45
|
+
// Lock body scroll while the dialog is present (including exit animation).
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!present)
|
|
31
48
|
return;
|
|
32
49
|
const previousOverflow = document.body.style.overflow;
|
|
33
50
|
document.body.style.overflow = "hidden";
|
|
34
51
|
return () => {
|
|
35
52
|
document.body.style.overflow = previousOverflow;
|
|
36
53
|
};
|
|
37
|
-
}, [
|
|
54
|
+
}, [present]);
|
|
38
55
|
// Close on Escape.
|
|
39
56
|
useEffect(() => {
|
|
40
57
|
if (!open)
|
|
@@ -61,7 +78,7 @@ export default function Modal({ open, title, children, onClose, footer, primaryA
|
|
|
61
78
|
previouslyFocusedRef.current = null;
|
|
62
79
|
};
|
|
63
80
|
}, [open]);
|
|
64
|
-
if (!
|
|
81
|
+
if (!present)
|
|
65
82
|
return null;
|
|
66
83
|
// Keep Tab / Shift+Tab cycling within the dialog panel.
|
|
67
84
|
const handlePanelKeyDown = (event) => {
|
|
@@ -84,5 +101,7 @@ export default function Modal({ open, title, children, onClose, footer, primaryA
|
|
|
84
101
|
last.focus();
|
|
85
102
|
}
|
|
86
103
|
};
|
|
87
|
-
return createPortal(_jsx("div", { className:
|
|
104
|
+
return createPortal(_jsx("div", { className: `fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4 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: `flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-large border border-border bg-surface shadow-lg transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${visible
|
|
105
|
+
? "translate-y-0 scale-100 opacity-100"
|
|
106
|
+
: "translate-y-2 scale-95 opacity-0"}`, 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 && footer, primaryAction && (_jsx(ClickableButton, { onClick: primaryAction.onClick, children: primaryAction.label }))] }))] }) }), document.body);
|
|
88
107
|
}
|
package/dist/select.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../components/ui/select.tsx"],"names":[],"mappings":"AAOA,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,WAAY,SAAQ,eAAe;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,UAAU,gBAAiB,SAAQ,eAAe;IAChD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../components/ui/select.tsx"],"names":[],"mappings":"AAOA,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,WAAY,SAAQ,eAAe;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,UAAU,gBAAiB,SAAQ,eAAe;IAChD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA2KD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,WAA+B,EAC/B,YAAY,GACb,EAAE,WAAW,+BAgCb;AAmDD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,WAA+B,EAC/B,YAAY,EACZ,eAAmB,GACpB,EAAE,gBAAgB,+BAgClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,WAA+B,EAC/B,YAAY,GACb,EAAE,WAAW,+BAgCb;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,WAA+B,EAC/B,YAAY,EACZ,eAAmB,GACpB,EAAE,gBAAgB,+BAgClB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,OAAO,EACP,MAAM,EACN,QAAQ,EACR,WAA0B,EAC1B,YAAY,EACZ,eAAe,GAChB,EAAE,gBAAgB,+BAYlB"}
|
package/dist/select.js
CHANGED
|
@@ -46,7 +46,7 @@ function useDismissibleOpen() {
|
|
|
46
46
|
return { open, setOpen, rootRef };
|
|
47
47
|
}
|
|
48
48
|
function SelectTrigger({ open, onOpenChange, children, }) {
|
|
49
|
-
return (_jsxs("button", { type: "button", "aria-haspopup": "true", "aria-expanded": open, onClick: () => onOpenChange(!open), className: "ds-input flex cursor-pointer items-center justify-between gap-2 text-left [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0", children: [children, _jsx(Icon, { name: "ChevronDown", variant: "muted", "aria-hidden": "true", className: `transition-transform duration-
|
|
49
|
+
return (_jsxs("button", { type: "button", "aria-haspopup": "true", "aria-expanded": open, onClick: () => onOpenChange(!open), className: "ds-input flex cursor-pointer items-center justify-between gap-2 text-left [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0", children: [children, _jsx(Icon, { name: "ChevronDown", variant: "muted", "aria-hidden": "true", className: `transition-transform duration-200 ease-out motion-reduce:transition-none ${open ? "rotate-180" : ""}` })] }));
|
|
50
50
|
}
|
|
51
51
|
function SelectDropdown({ open, options, selected, multiple, searchable, searchablePlaceholder = "Rechercher...", onToggle, emptyMessage = "Aucun résultat trouvé.", }) {
|
|
52
52
|
const [searchQuery, setSearchQuery] = useState("");
|
|
@@ -57,11 +57,15 @@ function SelectDropdown({ open, options, selected, multiple, searchable, searcha
|
|
|
57
57
|
return options.filter((option) => option.label.toLowerCase().includes(query) ||
|
|
58
58
|
option.value.toLowerCase().includes(query));
|
|
59
59
|
}, [options, searchQuery]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (!open)
|
|
62
|
+
setSearchQuery("");
|
|
63
|
+
}, [open]);
|
|
64
|
+
return (_jsxs("div", { "aria-hidden": !open, inert: !open ? true : undefined, className: `absolute top-full z-50 mt-1 max-h-64 w-full min-w-[10rem] overflow-hidden rounded-medium border border-border bg-surface shadow-lg transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${open
|
|
65
|
+
? "pointer-events-auto translate-y-0 opacity-100"
|
|
66
|
+
: "pointer-events-none -translate-y-1 opacity-0"}`, children: [searchable && (_jsx("div", { className: "border-b border-border p-2", children: _jsx(Input, { type: "text", placeholder: searchablePlaceholder, value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), icon: _jsx(Icon, { name: "Search" }), "aria-label": searchablePlaceholder }) })), _jsx("div", { className: "overflow-y-auto", children: filteredOptions.length === 0 ? (_jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: emptyMessage })) : (filteredOptions.map((option) => {
|
|
63
67
|
const isSelected = selected.has(option.value);
|
|
64
|
-
return (_jsxs("div", { className: "flex items-center justify-between px-3 py-2 text-sm text-foreground hover:bg-surface-muted
|
|
68
|
+
return (_jsxs("div", { className: "flex cursor-pointer items-center justify-between px-3 py-2 text-sm text-foreground transition-colors duration-200 ease-out hover:bg-surface-muted motion-reduce:transition-none [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0", onClick: () => onToggle(option.value), children: [_jsx("span", { children: option.label }), multiple ? (_jsx("div", { className: `flex h-4 w-4 items-center justify-center rounded-sm border transition-[background-color,border-color] duration-200 ease-out motion-reduce:transition-none [&_svg]:size-3 [&_svg]:text-current ${isSelected ? "border-primary bg-primary text-primary-foreground" : "border-muted-foreground"}`, children: isSelected && _jsx(Icon, { name: "Check" }) })) : isSelected ? (_jsx(Icon, { name: "Check", variant: "primary" })) : null] }, option.value));
|
|
65
69
|
})) })] }));
|
|
66
70
|
}
|
|
67
71
|
/**
|
package/dist/stepper.js
CHANGED
|
@@ -33,6 +33,6 @@ export default function Stepper({ steps, currentIndex, complete = false, rejecte
|
|
|
33
33
|
return (_jsx("ol", { "aria-label": label, className: "flex flex-col gap-control md:flex-row md:items-center", children: steps.map((step, index) => {
|
|
34
34
|
const visual = stepState(index, currentIndex, complete, rejected);
|
|
35
35
|
const last = index === steps.length - 1;
|
|
36
|
-
return (_jsxs("li", { className: "flex min-w-0 items-center gap-inline md:flex-1", "aria-label": `${step}, ${STATE_NAME[visual]}`, "aria-current": visual === "current" || visual === "rejected" ? "step" : undefined, children: [_jsx("span", { className: `grid size-8 shrink-0 place-items-center rounded-full text-label ${CIRCLE_CLASS[visual]}`, children: visual === "done" ? (_jsx(Icon, { name: "Check", variant: "white", size: "small", "aria-hidden": "true" })) : (index + 1) }), _jsx("span", { className: `min-w-0 text-label ${LABEL_CLASS[visual]}`, children: step }), last ? null : (_jsx("span", { className: `hidden h-px flex-1 md:block ${visual === "done" ? "bg-success" : "bg-border"}`, "aria-hidden": "true" }))] }, step));
|
|
36
|
+
return (_jsxs("li", { className: "flex min-w-0 items-center gap-inline md:flex-1", "aria-label": `${step}, ${STATE_NAME[visual]}`, "aria-current": visual === "current" || visual === "rejected" ? "step" : undefined, children: [_jsx("span", { className: `grid size-8 shrink-0 place-items-center rounded-full text-label transition-[background-color,color,box-shadow] duration-200 ease-out motion-reduce:transition-none ${CIRCLE_CLASS[visual]}`, children: visual === "done" ? (_jsx(Icon, { name: "Check", variant: "white", size: "small", "aria-hidden": "true" })) : (index + 1) }), _jsx("span", { className: `min-w-0 text-label transition-colors duration-200 ease-out motion-reduce:transition-none ${LABEL_CLASS[visual]}`, children: step }), last ? null : (_jsx("span", { className: `hidden h-px flex-1 md:block ${visual === "done" ? "bg-success" : "bg-border"}`, "aria-hidden": "true" }))] }, step));
|
|
37
37
|
}) }));
|
|
38
38
|
}
|
package/dist/switch.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type SwitchSize = "sm" | "md";
|
|
2
|
+
export interface SwitchProps {
|
|
3
|
+
/** Controlled checked state. */
|
|
4
|
+
checked: boolean;
|
|
5
|
+
onCheckedChange: (checked: boolean) => void;
|
|
6
|
+
/** Visible label — required for accessibility. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Optional helper text under the label. */
|
|
9
|
+
description?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
size?: SwitchSize;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Interrupteur (switch) — bascule on/off.
|
|
18
|
+
* Identité Modoock : piste primary à l’activation, pastille blanche.
|
|
19
|
+
*/
|
|
20
|
+
export default function Switch({ checked, onCheckedChange, label, description, disabled, id, name, size, className, }: SwitchProps): import("react").JSX.Element;
|
|
21
|
+
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../components/ui/switch.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiBD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,OAAO,EACP,eAAe,EACf,KAAK,EACL,WAAW,EACX,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,IAAW,EACX,SAAc,GACf,EAAE,WAAW,+BAmDb"}
|
package/dist/switch.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
const TRACK_SIZE = {
|
|
5
|
+
sm: "h-5 w-9",
|
|
6
|
+
md: "h-6 w-11",
|
|
7
|
+
};
|
|
8
|
+
const THUMB_SIZE = {
|
|
9
|
+
sm: "size-4",
|
|
10
|
+
md: "size-5",
|
|
11
|
+
};
|
|
12
|
+
const THUMB_ON = {
|
|
13
|
+
sm: "translate-x-4",
|
|
14
|
+
md: "translate-x-5",
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Interrupteur (switch) — bascule on/off.
|
|
18
|
+
* Identité Modoock : piste primary à l’activation, pastille blanche.
|
|
19
|
+
*/
|
|
20
|
+
export default function Switch({ checked, onCheckedChange, label, description, disabled = false, id, name, size = "md", className = "", }) {
|
|
21
|
+
const generatedId = useId();
|
|
22
|
+
const switchId = id ?? generatedId;
|
|
23
|
+
const descriptionId = description ? `${switchId}-description` : undefined;
|
|
24
|
+
return (_jsxs("div", { className: `inline-flex items-start gap-control ${disabled ? "opacity-60" : ""} ${className}`, children: [_jsx("button", { type: "button", role: "switch", id: switchId, name: name, "aria-checked": checked, "aria-describedby": descriptionId, disabled: disabled, onClick: () => onCheckedChange(!checked), className: `relative inline-flex shrink-0 cursor-pointer items-center rounded-full border p-0.5 outline-none transition-[background-color,border-color] duration-200 ease-out focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 disabled:cursor-not-allowed motion-reduce:transition-none ${TRACK_SIZE[size]} ${checked
|
|
25
|
+
? "border-primary bg-primary"
|
|
26
|
+
: "border-border bg-surface-muted"}`, children: _jsx("span", { "aria-hidden": "true", className: `pointer-events-none block rounded-full bg-white shadow-sm transition-transform duration-200 ease-out motion-reduce:transition-none ${THUMB_SIZE[size]} ${checked ? THUMB_ON[size] : "translate-x-0"}` }) }), _jsxs("div", { className: "min-w-0 pt-micro", children: [_jsx("label", { htmlFor: switchId, className: `text-body-medium leading-snug text-foreground ${disabled ? "cursor-not-allowed" : "cursor-pointer"}`, children: label }), description ? (_jsx("p", { id: descriptionId, className: "mt-0 text-small leading-snug text-muted-foreground", children: description })) : null] })] }));
|
|
27
|
+
}
|
package/dist/tab.js
CHANGED
|
@@ -18,7 +18,7 @@ export default function Tabs({ tabs, defaultValue, onChange, children, panelClas
|
|
|
18
18
|
};
|
|
19
19
|
return (_jsxs("div", { className: "flex h-full min-h-0 w-full flex-col", children: [_jsx("div", { role: "tablist", className: "inline-flex max-w-full items-center gap-micro overflow-x-auto rounded-large bg-surface-muted p-micro", children: tabs.map((tab) => {
|
|
20
20
|
const isActive = activeTab === tab.value;
|
|
21
|
-
return (_jsx(ClickableButton, { type: "button", variant: "bare", role: "tab", "aria-selected": isActive, "aria-current": isActive ? "page" : undefined, onClick: () => handleSelect(tab.value), className: `whitespace-nowrap rounded-large px-component py-inline text-body-medium focus-visible:ring-primary ${isActive
|
|
21
|
+
return (_jsx(ClickableButton, { type: "button", variant: "bare", role: "tab", "aria-selected": isActive, "aria-current": isActive ? "page" : undefined, onClick: () => handleSelect(tab.value), className: `whitespace-nowrap rounded-large px-component py-inline text-body-medium transition-[color,background-color,box-shadow] duration-200 ease-out focus-visible:ring-primary motion-reduce:transition-none ${isActive
|
|
22
22
|
? "bg-surface text-primary shadow-sm"
|
|
23
23
|
: "bg-transparent text-muted-foreground hover:text-foreground"}`, children: tab.label }, tab.value));
|
|
24
24
|
}) }), children && _jsx("div", { className: panelClassName, children: children(activeTab) })] }));
|
package/dist/table.js
CHANGED
|
@@ -24,8 +24,8 @@ function CardActionsMenu({ tableActions, rowActions, open, onToggle, onClose, tr
|
|
|
24
24
|
_jsx("div", { onClick: onClose, className: "rounded-small focus-within:ring-primary", children: action.content }, action.label || `derived-${index}`)) : (_jsxs("button", { type: "button", role: "menuitem", onClick: () => {
|
|
25
25
|
onClose();
|
|
26
26
|
action.onSelect();
|
|
27
|
-
}, className: `flex items-center gap-inline whitespace-nowrap rounded-small px-component py-control text-left text-body-medium transition-colors hover:bg-surface-muted focus-visible:ring-primary ${action.danger ? "text-danger" : "text-foreground"}`, children: [action.icon && (_jsx(Icon, { name: action.icon, size: "small", variant: action.danger ? "danger" : "muted", "aria-hidden": "true" })), action.label] }, action.label)));
|
|
28
|
-
return (_jsxs("div", { className: "relative", children: [trigger === "kebab" ? (_jsx(ClickableButton, { type: "button", variant: "ghost", size: "icon", "aria-label": "Plus d'actions", "aria-haspopup": "menu", "aria-expanded": open, onClick: onToggle, className: "text-muted-foreground hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: "EllipsisVertical", "aria-hidden": "true" }) })) : (_jsxs(ClickableButton, { type: "button", variant: "secondary", size: "sm", "aria-haspopup": "menu", "aria-expanded": open, onClick: onToggle, leftIcon: _jsx(Icon, { name: "EllipsisVertical", size: "small" }), children: ["Actions", _jsx(Icon, { name: "ChevronDown", size: "small", className: `transition-transform ${open ? "rotate-180" : ""}` })] })), open && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "aria-label": "Fermer le menu", tabIndex: -1, onClick: onClose, className: "fixed inset-0 z-40 cursor-default" }), _jsxs("div", { role: "menu", className: `absolute right-0 z-50 flex min-w-40 max-w-[16rem] flex-col rounded-medium border border-border bg-surface shadow-lg ${direction === "up" ? "bottom-full mb-micro" : "top-full mt-micro"}`, children: [hasGroups && (_jsx("p", { className: "px-component pt-micro text-label text-muted-foreground", children: "Tableau" })), renderGroup(tableActions), hasGroups && _jsx("div", { className: "mx-component my-micro h-px bg-border" }), hasGroups && (_jsx("p", { className: "px-component pt-micro text-label text-muted-foreground", children: "Cette ligne" })), renderGroup(rowActions)] })] }))] }));
|
|
27
|
+
}, className: `flex items-center gap-inline whitespace-nowrap rounded-small px-component py-control text-left text-body-medium transition-colors duration-200 ease-out motion-reduce:transition-none hover:bg-surface-muted focus-visible:ring-primary ${action.danger ? "text-danger" : "text-foreground"}`, children: [action.icon && (_jsx(Icon, { name: action.icon, size: "small", variant: action.danger ? "danger" : "muted", "aria-hidden": "true" })), action.label] }, action.label)));
|
|
28
|
+
return (_jsxs("div", { className: "relative", children: [trigger === "kebab" ? (_jsx(ClickableButton, { type: "button", variant: "ghost", size: "icon", "aria-label": "Plus d'actions", "aria-haspopup": "menu", "aria-expanded": open, onClick: onToggle, className: "text-muted-foreground hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: "EllipsisVertical", "aria-hidden": "true" }) })) : (_jsxs(ClickableButton, { type: "button", variant: "secondary", size: "sm", "aria-haspopup": "menu", "aria-expanded": open, onClick: onToggle, leftIcon: _jsx(Icon, { name: "EllipsisVertical", size: "small" }), children: ["Actions", _jsx(Icon, { name: "ChevronDown", size: "small", className: `transition-transform duration-200 ease-out motion-reduce:transition-none ${open ? "rotate-180" : ""}` })] })), open && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "aria-label": "Fermer le menu", tabIndex: -1, onClick: onClose, className: "fixed inset-0 z-40 cursor-default" }), _jsxs("div", { role: "menu", className: `absolute right-0 z-50 flex min-w-40 max-w-[16rem] flex-col rounded-medium border border-border bg-surface shadow-lg ${direction === "up" ? "bottom-full mb-micro" : "top-full mt-micro"}`, children: [hasGroups && (_jsx("p", { className: "px-component pt-micro text-label text-muted-foreground", children: "Tableau" })), renderGroup(tableActions), hasGroups && _jsx("div", { className: "mx-component my-micro h-px bg-border" }), hasGroups && (_jsx("p", { className: "px-component pt-micro text-label text-muted-foreground", children: "Cette ligne" })), renderGroup(rowActions)] })] }))] }));
|
|
29
29
|
}
|
|
30
30
|
function TableActionsBar({ selectAllAction, allSelected, tableActions, open, direction = "down", onToggle, onClose, }) {
|
|
31
31
|
return (_jsxs("div", { className: "flex items-center justify-end gap-inline", children: [selectAllAction ? (_jsx(ClickableButton, { type: "button", variant: "secondary", size: "sm", "aria-pressed": allSelected, onClick: selectAllAction.onSelect, leftIcon: selectAllAction.icon ? (_jsx(Icon, { name: selectAllAction.icon, size: "small", variant: allSelected ? "primary" : "muted", "aria-hidden": "true" })) : undefined, children: selectAllAction.label })) : null, tableActions.length > 0 ? (_jsx(CardActionsMenu, { trigger: "labeled", direction: direction, tableActions: tableActions, rowActions: [], open: open, onToggle: onToggle, onClose: onClose })) : null] }));
|
|
@@ -154,11 +154,11 @@ export default function Table({ columns, data, rowsPerPage = 8, emptyMessage = "
|
|
|
154
154
|
return (_jsx("div", { className: "flex justify-end", children: _jsx(ClickableButton, { type: "button", variant: action.danger ? "danger" : "secondary", size: "sm", onClick: action.onSelect, children: action.label }) }));
|
|
155
155
|
};
|
|
156
156
|
const SortIcon = () => (_jsx(Icon, { name: "ChevronsUpDown", "aria-hidden": "true" }));
|
|
157
|
-
const SortableHeader = ({ column }) => (_jsx("th", { className: "text-left", children: _jsxs(ClickableButton, { type: "button", variant: "bare", onClick: () => handleSort(column), className: "px-component py-control text-muted-foreground transition-colors hover:text-primary focus-visible:ring-primary", children: [_jsx("span", { className: "text-label", children: column.label }), _jsx(SortIcon, {})] }) }));
|
|
157
|
+
const SortableHeader = ({ column }) => (_jsx("th", { className: "text-left", children: _jsxs(ClickableButton, { type: "button", variant: "bare", onClick: () => handleSort(column), className: "px-component py-control text-muted-foreground transition-colors duration-200 ease-out motion-reduce:transition-none hover:text-primary focus-visible:ring-primary", children: [_jsx("span", { className: "text-label", children: column.label }), _jsx(SortIcon, {})] }) }));
|
|
158
158
|
return (_jsxs("div", { className: `flex flex-col overflow-hidden rounded-large border border-border bg-surface md:h-full ${className ?? ""}`, children: [tableActions.length > 0 || selectAllAction ? (_jsx("div", { className: "hidden shrink-0 border-b border-border px-component py-control md:flex md:justify-end", children: _jsx(TableActionsBar, { selectAllAction: selectAllAction, allSelected: allSelected, tableActions: tableActions, open: openMenu === "actions-desktop", onToggle: () => toggleMenu("actions-desktop"), onClose: closeMenus }) })) : null, _jsx("div", { className: "hidden min-h-0 flex-1 overflow-auto md:block", children: _jsx("table", { className: "w-full border-collapse text-body", children: transpose ? (_jsxs(_Fragment, { children: [_jsx("thead", { className: "sticky top-0 z-10 bg-surface-muted", children: _jsxs("tr", { className: "border-b border-border", children: [_jsx("th", { className: "px-component py-control text-left text-label text-muted-foreground", children: transposeLabel ?? columns[0]?.label ?? "" }), data.map((item, i) => (_jsx("th", { className: "px-component py-control text-left", children: transposeHeader ? transposeHeader(item) : null }, i)))] }) }), _jsx("tbody", { children: data.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: 1, className: "px-component py-section text-center text-muted-foreground", children: emptyMessage }) })) : (columns.slice(1).map((column) => (_jsxs("tr", { className: "h-12 border-t border-border", children: [_jsx("td", { className: "px-component align-middle text-label text-muted-foreground", children: column.label }), data.map((item, i) => (_jsx("td", { className: `px-component align-middle ${column.className ?? "text-body-medium text-foreground"}`, children: getCellValue(item, column) }, i)))] }, String(column.key))))) })] })) : (_jsxs(_Fragment, { children: [_jsx("thead", { className: "sticky top-0 z-10 bg-surface-muted", children: _jsxs("tr", { className: "border-b border-border", children: [hasSelectionControl ? (_jsx("th", { className: "w-10 px-component py-control", children: selectAllAction ? (_jsx(ClickableButton, { type: "button", variant: "ghost", size: "icon", "aria-label": selectAllAction.label, "aria-pressed": allSelected, onClick: selectAllAction.onSelect, className: "text-muted-foreground hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: allSelected ? "SquareCheck" : "Square", "aria-hidden": "true" }) })) : null })) : null, visibleColumns.map((column, columnIndex) => column.sortable ? (_jsx(SortableHeader, { column: column }, `col-${columnIndex}`)) : (_jsx("th", { className: "px-component py-control text-left text-label text-muted-foreground", children: column.label }, `col-${columnIndex}`)))] }) }), _jsx("tbody", { children: visibleData.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columnCount, className: "px-component py-section text-center text-muted-foreground", children: emptyMessage }) })) : (visibleData.map((row, rowIndex) => {
|
|
159
159
|
const rowKey = getRowKey(row, startIndex + rowIndex);
|
|
160
160
|
const selected = selectedKeys?.has(rowKey) ?? false;
|
|
161
|
-
return (_jsxs("tr", { className: "h-12 border-b border-border transition-colors last:border-b-0 hover:bg-surface-muted", children: [hasSelectionControl ? (_jsx("td", { className: "px-component align-middle", children: _jsx(ClickableButton, { type: "button", variant: "ghost", size: "icon", "aria-pressed": selected, "aria-label": selected
|
|
161
|
+
return (_jsxs("tr", { className: "h-12 border-b border-border transition-colors duration-200 ease-out motion-reduce:transition-none last:border-b-0 hover:bg-surface-muted", children: [hasSelectionControl ? (_jsx("td", { className: "px-component align-middle", children: _jsx(ClickableButton, { type: "button", variant: "ghost", size: "icon", "aria-pressed": selected, "aria-label": selected
|
|
162
162
|
? "Retirer la sélection"
|
|
163
163
|
: "Sélectionner", onClick: () => onToggleSelect?.(rowKey), className: "text-muted-foreground hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: selected ? "SquareCheck" : "Square", "aria-hidden": "true" }) }) })) : null, visibleColumns.map((column, columnIndex) => (_jsx("td", { className: `px-component align-middle ${column.className ?? "text-body-medium text-foreground"}`, children: cardActions?.row && column === rowActionColumn ? (renderPersonalActions(row, rowKey)) : (getCellValue(row, column)) }, `col-${columnIndex}`)))] }, rowKey));
|
|
164
164
|
})) })] })) }) }), _jsx("div", { className: "md:hidden", children: visibleData.length === 0 ? (_jsx("div", { className: "px-component py-section text-center text-muted-foreground", children: emptyMessage })) : (_jsxs("div", { className: "flex flex-col gap-component p-component", children: [tableActions.length > 0 || selectAllAction ? (_jsx("div", { className: "flex justify-end", children: _jsx(TableActionsBar, { selectAllAction: selectAllAction, allSelected: allSelected, tableActions: tableActions, direction: "down", open: openMenu === "actions-top", onToggle: () => toggleMenu("actions-top"), onClose: closeMenus }) })) : null, visibleData.map((row, rowIndex) => {
|
|
@@ -173,8 +173,8 @@ export default function Table({ columns, data, rowsPerPage = 8, emptyMessage = "
|
|
|
173
173
|
const menuKey = `card:${String(rowKey)}`;
|
|
174
174
|
return (_jsxs("article", { className: "flex flex-col overflow-hidden rounded-large border border-border bg-surface", children: [_jsxs("div", { className: "flex items-center gap-inline bg-surface-muted px-component py-control", children: [hasSelectionControl ? (_jsx("button", { type: "button", onClick: () => onToggleSelect?.(rowKey), "aria-pressed": selectedKeys?.has(rowKey) ?? false, "aria-label": selectedKeys?.has(rowKey)
|
|
175
175
|
? "Retirer la sélection"
|
|
176
|
-
: "Sélectionner", className: "grid size-8 shrink-0 place-items-center rounded-small text-muted-foreground transition-colors hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: selectedKeys?.has(rowKey) ? "SquareCheck" : "Square", size: "default", "aria-hidden": "true" }) })) : (headerControlColumn && (_jsx("div", { className: "shrink-0", children: getCellValue(row, headerControlColumn) }))), _jsx("p", { className: "min-w-0 flex-1 text-component-title text-foreground", children: getCellValue(row, titleColumn) }), rowActions.length > 0 ? (_jsx(CardActionsMenu, { trigger: "kebab", tableActions: [], rowActions: rowActions, open: openMenu === menuKey, onToggle: () => toggleMenu(menuKey), onClose: closeMenus })) : null] }), visiblePairs.map((column) => (_jsxs("div", { className: "flex items-center justify-between gap-inline border-t border-border px-component py-control", children: [_jsx("span", { className: "shrink-0 text-label text-muted-foreground", children: column.label }), _jsx("span", { className: "min-w-0 text-right text-body-medium text-foreground", children: getCellValue(row, column) })] }, String(column.key)))), collapsible && (_jsx("div", { className: "border-t border-border px-component py-control", children: _jsxs(ClickableButton, { type: "button", variant: "bare", onClick: () => toggleCard(rowKey), "aria-expanded": isExpanded, className: "flex items-center gap-micro text-small text-primary transition-colors hover:text-primary focus-visible:ring-primary", children: [_jsx(Icon, { name: "ChevronDown", "aria-hidden": "true", className: `transition-transform ${isExpanded ? "rotate-180" : ""}` }), isExpanded
|
|
176
|
+
: "Sélectionner", className: "grid size-8 shrink-0 place-items-center rounded-small text-muted-foreground transition-colors duration-200 ease-out motion-reduce:transition-none hover:text-primary focus-visible:ring-primary", children: _jsx(Icon, { name: selectedKeys?.has(rowKey) ? "SquareCheck" : "Square", size: "default", "aria-hidden": "true" }) })) : (headerControlColumn && (_jsx("div", { className: "shrink-0", children: getCellValue(row, headerControlColumn) }))), _jsx("p", { className: "min-w-0 flex-1 text-component-title text-foreground", children: getCellValue(row, titleColumn) }), rowActions.length > 0 ? (_jsx(CardActionsMenu, { trigger: "kebab", tableActions: [], rowActions: rowActions, open: openMenu === menuKey, onToggle: () => toggleMenu(menuKey), onClose: closeMenus })) : null] }), visiblePairs.map((column) => (_jsxs("div", { className: "flex items-center justify-between gap-inline border-t border-border px-component py-control", children: [_jsx("span", { className: "shrink-0 text-label text-muted-foreground", children: column.label }), _jsx("span", { className: "min-w-0 text-right text-body-medium text-foreground", children: getCellValue(row, column) })] }, String(column.key)))), collapsible && (_jsx("div", { className: "border-t border-border px-component py-control", children: _jsxs(ClickableButton, { type: "button", variant: "bare", onClick: () => toggleCard(rowKey), "aria-expanded": isExpanded, className: "flex items-center gap-micro text-small text-primary transition-colors duration-200 ease-out motion-reduce:transition-none hover:text-primary focus-visible:ring-primary", children: [_jsx(Icon, { name: "ChevronDown", "aria-hidden": "true", className: `transition-transform duration-200 ease-out motion-reduce:transition-none ${isExpanded ? "rotate-180" : ""}` }), isExpanded
|
|
177
177
|
? "Réduire"
|
|
178
178
|
: `Voir tout (+${contentColumns.length - pairLimit})`] }) })), actionColumn && rowActions.length === 0 ? (_jsx("div", { className: "flex justify-end border-t border-border px-component py-control", children: getCellValue(row, actionColumn) })) : null] }, rowKey));
|
|
179
|
-
}), tableActions.length > 0 || selectAllAction ? (_jsx("div", { className: "flex justify-end", children: _jsx(TableActionsBar, { selectAllAction: selectAllAction, allSelected: allSelected, tableActions: tableActions, direction: "up", open: openMenu === "actions-bottom", onToggle: () => toggleMenu("actions-bottom"), onClose: closeMenus }) })) : null] })) }), totalPages > 1 && (_jsxs("div", { className: "flex items-center justify-between border-t border-border bg-surface px-component py-control", children: [_jsxs("p", { className: "text-small text-muted-foreground", children: [startIndex + 1, "\u2013", Math.min(startIndex + rowsPerPage, sortedData.length), " sur", " ", sortedData.length] }), _jsxs("div", { className: "flex items-center gap-inline", children: [_jsx(ClickableButton, { type: "button", variant: "bare", onClick: () => setCurrentPage((page) => Math.max(1, page - 1)), disabled: safePage === 1, className: "rounded-medium border border-border p-inline text-muted-foreground transition-colors hover:text-primary disabled:opacity-50 focus-visible:ring-primary", "aria-label": "Page pr\u00E9c\u00E9dente", children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsxs("span", { className: "text-small text-muted-foreground", children: [safePage, " / ", totalPages] }), _jsx(ClickableButton, { type: "button", variant: "bare", onClick: () => setCurrentPage((page) => Math.min(totalPages, page + 1)), disabled: safePage === totalPages, className: "rounded-medium border border-border p-inline text-muted-foreground transition-colors hover:text-primary disabled:opacity-50 focus-visible:ring-primary", "aria-label": "Page suivante", children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] })] }))] }));
|
|
179
|
+
}), tableActions.length > 0 || selectAllAction ? (_jsx("div", { className: "flex justify-end", children: _jsx(TableActionsBar, { selectAllAction: selectAllAction, allSelected: allSelected, tableActions: tableActions, direction: "up", open: openMenu === "actions-bottom", onToggle: () => toggleMenu("actions-bottom"), onClose: closeMenus }) })) : null] })) }), totalPages > 1 && (_jsxs("div", { className: "flex items-center justify-between border-t border-border bg-surface px-component py-control", children: [_jsxs("p", { className: "text-small text-muted-foreground", children: [startIndex + 1, "\u2013", Math.min(startIndex + rowsPerPage, sortedData.length), " sur", " ", sortedData.length] }), _jsxs("div", { className: "flex items-center gap-inline", children: [_jsx(ClickableButton, { type: "button", variant: "bare", onClick: () => setCurrentPage((page) => Math.max(1, page - 1)), disabled: safePage === 1, className: "rounded-medium border border-border p-inline text-muted-foreground transition-colors duration-200 ease-out motion-reduce:transition-none hover:text-primary disabled:opacity-50 focus-visible:ring-primary", "aria-label": "Page pr\u00E9c\u00E9dente", children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsxs("span", { className: "text-small text-muted-foreground", children: [safePage, " / ", totalPages] }), _jsx(ClickableButton, { type: "button", variant: "bare", onClick: () => setCurrentPage((page) => Math.min(totalPages, page + 1)), disabled: safePage === totalPages, className: "rounded-medium border border-border p-inline text-muted-foreground transition-colors duration-200 ease-out motion-reduce:transition-none hover:text-primary disabled:opacity-50 focus-visible:ring-primary", "aria-label": "Page suivante", children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] })] }))] }));
|
|
180
180
|
}
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ToastVariant = "default" | "success" | "warning" | "danger" | "info";
|
|
2
|
+
export type ToastPosition = "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
variant?: ToastVariant;
|
|
7
|
+
/** Auto-dismiss delay in ms. `0` keeps the toast until closed. Default 4000. */
|
|
8
|
+
duration?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ToasterProps {
|
|
11
|
+
position?: ToastPosition;
|
|
12
|
+
/** Max visible toasts. Oldest are dismissed first. Default 4. */
|
|
13
|
+
max?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function dismiss(id: string): void;
|
|
17
|
+
export declare const toast: ((options: ToastOptions) => string) & {
|
|
18
|
+
success: (title: string, description: string, options?: Omit<ToastOptions, "title" | "description" | "variant">) => string;
|
|
19
|
+
warning: (title: string, description: string, options?: Omit<ToastOptions, "title" | "description" | "variant">) => string;
|
|
20
|
+
danger: (title: string, description: string, options?: Omit<ToastOptions, "title" | "description" | "variant">) => string;
|
|
21
|
+
info: (title: string, description: string, options?: Omit<ToastOptions, "title" | "description" | "variant">) => string;
|
|
22
|
+
message: (title: string, description: string, options?: Omit<ToastOptions, "title" | "description" | "variant">) => string;
|
|
23
|
+
dismiss: typeof dismiss;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Conteneur des toasts — monter une seule fois (layout racine).
|
|
27
|
+
* Déclencher via `toast.success("…")` / `toast({ title, … })`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function Toaster({ position, max, className, }: ToasterProps): import("react").ReactPortal | null;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../components/ui/toast.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,MAAM,CAAC;AAEX,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,UAAU,GACV,cAAc,GACd,aAAa,CAAC;AAElB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,iEAAiE;IACjE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8CD,iBAAS,OAAO,CAAC,EAAE,EAAE,MAAM,QAU1B;AAmDD,eAAO,MAAM,KAAK,aACN,YAAY;qBAPb,MAAM,eACA,MAAM,YACT,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;qBAF1D,MAAM,eACA,MAAM,YACT,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;oBAF1D,MAAM,eACA,MAAM,YACT,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;kBAF1D,MAAM,eACA,MAAM,YACT,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;qBAF1D,MAAM,eACA,MAAM,YACT,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAAC;;CAcpE,CAAC;AA4HF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EACtB,QAAyB,EACzB,GAAiB,EACjB,SAAc,GACf,EAAE,YAAY,sCA4Bd"}
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import Icon from "./icon";
|
|
6
|
+
/* ------------------------------------------------------------------ */
|
|
7
|
+
/* Store */
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
const ANIMATION_MS = 200;
|
|
10
|
+
const DEFAULT_DURATION = 4000;
|
|
11
|
+
const DEFAULT_MAX = 4;
|
|
12
|
+
let items = [];
|
|
13
|
+
let maxToasts = DEFAULT_MAX;
|
|
14
|
+
const listeners = new Set();
|
|
15
|
+
const timers = new Map();
|
|
16
|
+
function emit() {
|
|
17
|
+
for (const listener of listeners)
|
|
18
|
+
listener(items);
|
|
19
|
+
}
|
|
20
|
+
function subscribe(listener) {
|
|
21
|
+
listeners.add(listener);
|
|
22
|
+
listener(items);
|
|
23
|
+
return () => {
|
|
24
|
+
listeners.delete(listener);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function remove(id) {
|
|
28
|
+
const timer = timers.get(id);
|
|
29
|
+
if (timer != null) {
|
|
30
|
+
window.clearTimeout(timer);
|
|
31
|
+
timers.delete(id);
|
|
32
|
+
}
|
|
33
|
+
items = items.filter((item) => item.id !== id);
|
|
34
|
+
emit();
|
|
35
|
+
}
|
|
36
|
+
function dismiss(id) {
|
|
37
|
+
const current = items.find((item) => item.id === id);
|
|
38
|
+
if (!current || !current.open)
|
|
39
|
+
return;
|
|
40
|
+
items = items.map((item) => item.id === id ? { ...item, open: false } : item);
|
|
41
|
+
emit();
|
|
42
|
+
window.setTimeout(() => remove(id), ANIMATION_MS);
|
|
43
|
+
}
|
|
44
|
+
function trimToMax(max) {
|
|
45
|
+
const openItems = items.filter((item) => item.open);
|
|
46
|
+
if (openItems.length <= max)
|
|
47
|
+
return;
|
|
48
|
+
const overflow = openItems.length - max;
|
|
49
|
+
for (let i = 0; i < overflow; i += 1) {
|
|
50
|
+
dismiss(openItems[i].id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function createId() {
|
|
54
|
+
return `toast-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
55
|
+
}
|
|
56
|
+
function pushToast(options) {
|
|
57
|
+
const id = createId();
|
|
58
|
+
const duration = options.duration ?? DEFAULT_DURATION;
|
|
59
|
+
const record = {
|
|
60
|
+
id,
|
|
61
|
+
title: options.title,
|
|
62
|
+
description: options.description,
|
|
63
|
+
variant: options.variant ?? "default",
|
|
64
|
+
duration,
|
|
65
|
+
open: true,
|
|
66
|
+
};
|
|
67
|
+
items = [...items, record];
|
|
68
|
+
emit();
|
|
69
|
+
trimToMax(maxToasts);
|
|
70
|
+
if (duration > 0) {
|
|
71
|
+
const timer = window.setTimeout(() => dismiss(id), duration);
|
|
72
|
+
timers.set(id, timer);
|
|
73
|
+
}
|
|
74
|
+
return id;
|
|
75
|
+
}
|
|
76
|
+
/* ------------------------------------------------------------------ */
|
|
77
|
+
/* Imperative API */
|
|
78
|
+
/* ------------------------------------------------------------------ */
|
|
79
|
+
function createToastFn(variant) {
|
|
80
|
+
return (title, description, options) => pushToast({ ...options, title, description, variant });
|
|
81
|
+
}
|
|
82
|
+
export const toast = Object.assign((options) => pushToast(options), {
|
|
83
|
+
success: createToastFn("success"),
|
|
84
|
+
warning: createToastFn("warning"),
|
|
85
|
+
danger: createToastFn("danger"),
|
|
86
|
+
info: createToastFn("info"),
|
|
87
|
+
message: createToastFn("default"),
|
|
88
|
+
dismiss,
|
|
89
|
+
});
|
|
90
|
+
/* ------------------------------------------------------------------ */
|
|
91
|
+
/* Visual */
|
|
92
|
+
/* ------------------------------------------------------------------ */
|
|
93
|
+
const VARIANT_ICON = {
|
|
94
|
+
default: "Info",
|
|
95
|
+
success: "CircleCheck",
|
|
96
|
+
warning: "TriangleAlert",
|
|
97
|
+
danger: "CircleAlert",
|
|
98
|
+
info: "Info",
|
|
99
|
+
};
|
|
100
|
+
const VARIANT_ICON_WRAP = {
|
|
101
|
+
default: "bg-muted text-muted-foreground",
|
|
102
|
+
success: "bg-success text-white",
|
|
103
|
+
warning: "bg-warning text-white",
|
|
104
|
+
danger: "bg-danger text-white",
|
|
105
|
+
info: "bg-info text-white",
|
|
106
|
+
};
|
|
107
|
+
const VARIANT_PROGRESS = {
|
|
108
|
+
default: "bg-border-strong",
|
|
109
|
+
success: "bg-success",
|
|
110
|
+
warning: "bg-warning",
|
|
111
|
+
danger: "bg-danger",
|
|
112
|
+
info: "bg-info",
|
|
113
|
+
};
|
|
114
|
+
const POSITION_CLASS = {
|
|
115
|
+
"top-right": "top-component right-component items-end",
|
|
116
|
+
"top-left": "top-component left-component items-start",
|
|
117
|
+
"bottom-right": "bottom-component right-component items-end",
|
|
118
|
+
"bottom-left": "bottom-component left-component items-start",
|
|
119
|
+
};
|
|
120
|
+
function isTop(position) {
|
|
121
|
+
return position.startsWith("top");
|
|
122
|
+
}
|
|
123
|
+
function ToastCard({ item, fromTop, }) {
|
|
124
|
+
const [progress, setProgress] = useState(item.duration > 0 ? 1 : 0);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (item.duration <= 0 || !item.open)
|
|
127
|
+
return;
|
|
128
|
+
const frame = requestAnimationFrame(() => {
|
|
129
|
+
requestAnimationFrame(() => setProgress(0));
|
|
130
|
+
});
|
|
131
|
+
return () => cancelAnimationFrame(frame);
|
|
132
|
+
}, [item.duration, item.id, item.open]);
|
|
133
|
+
return (_jsxs("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: `pointer-events-auto relative w-[min(22rem,calc(100vw-2rem))] overflow-hidden rounded-large border border-border/80 bg-surface/90 shadow-lg backdrop-blur-md transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none ${item.open
|
|
134
|
+
? "translate-y-0 scale-100 opacity-100"
|
|
135
|
+
: fromTop
|
|
136
|
+
? "-translate-y-2 scale-[0.98] opacity-0"
|
|
137
|
+
: "translate-y-2 scale-[0.98] opacity-0"}`, children: [_jsxs("div", { className: "flex min-w-0 items-start gap-control px-component pb-control pt-component", children: [_jsx("span", { className: `grid size-9 shrink-0 place-items-center rounded-full ${VARIANT_ICON_WRAP[item.variant]}`, "aria-hidden": "true", children: _jsx(Icon, { name: VARIANT_ICON[item.variant], size: "small", variant: item.variant === "default" ? "muted" : "white" }) }), _jsxs("div", { className: "min-w-0 flex-1 pt-micro", children: [_jsx("p", { className: "text-body-medium leading-snug tracking-tight text-foreground", children: item.title }), _jsx("p", { className: "mt-0 text-small leading-snug text-muted-foreground", children: item.description })] }), _jsx("button", { type: "button", onClick: () => dismiss(item.id), className: "grid size-8 shrink-0 place-items-center rounded-full 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 la notification", children: _jsx(Icon, { name: "X", "aria-hidden": "true" }) })] }), item.duration > 0 ? (_jsx("div", { className: "h-0.5 w-full bg-muted", "aria-hidden": "true", children: _jsx("div", { className: `h-full origin-left ${VARIANT_PROGRESS[item.variant]} motion-reduce:transition-none`, style: {
|
|
138
|
+
transform: `scaleX(${progress})`,
|
|
139
|
+
transition: progress === 0
|
|
140
|
+
? `transform ${item.duration}ms linear`
|
|
141
|
+
: undefined,
|
|
142
|
+
} }) })) : null] }));
|
|
143
|
+
}
|
|
144
|
+
/* ------------------------------------------------------------------ */
|
|
145
|
+
/* Toaster */
|
|
146
|
+
/* ------------------------------------------------------------------ */
|
|
147
|
+
/**
|
|
148
|
+
* Conteneur des toasts — monter une seule fois (layout racine).
|
|
149
|
+
* Déclencher via `toast.success("…")` / `toast({ title, … })`.
|
|
150
|
+
*/
|
|
151
|
+
export function Toaster({ position = "bottom-right", max = DEFAULT_MAX, className = "", }) {
|
|
152
|
+
const [toasts, setToasts] = useState([]);
|
|
153
|
+
const [mounted, setMounted] = useState(false);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
maxToasts = max;
|
|
156
|
+
}, [max]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
setMounted(true);
|
|
159
|
+
return subscribe(setToasts);
|
|
160
|
+
}, []);
|
|
161
|
+
if (!mounted)
|
|
162
|
+
return null;
|
|
163
|
+
const fromTop = isTop(position);
|
|
164
|
+
return createPortal(_jsx("div", { className: `pointer-events-none fixed z-[60] flex flex-col gap-inline ${POSITION_CLASS[position]} ${className}`, "aria-label": "Notifications", children: toasts.map((item) => (_jsx(ToastCard, { item: item, fromTop: fromTop }, item.id))) }), document.body);
|
|
165
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type TooltipSide = "top" | "right" | "bottom" | "left";
|
|
3
|
+
export interface TooltipProps {
|
|
4
|
+
/** Tooltip text (French in product copy). */
|
|
5
|
+
content: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
/** Placement relative to the trigger. Default `top`. */
|
|
8
|
+
side?: TooltipSide;
|
|
9
|
+
/** Delay before show (ms). Default 200. */
|
|
10
|
+
delay?: number;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Infobulle — aide secondaire au survol / focus.
|
|
15
|
+
* Ne remplace pas un label accessible (aria-label / texte visible).
|
|
16
|
+
*/
|
|
17
|
+
export default function Tooltip({ content, children, side, delay, className, }: TooltipProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../components/ui/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IACpB,wDAAwD;IACxD,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiCD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,OAAO,EACP,QAAQ,EACR,IAAY,EACZ,KAAW,EACX,SAAc,GACf,EAAE,YAAY,+BA4Ed"}
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useRef, useState, } from "react";
|
|
4
|
+
const SIDE_CLASS = {
|
|
5
|
+
top: "bottom-full left-1/2 mb-micro -translate-x-1/2",
|
|
6
|
+
bottom: "top-full left-1/2 mt-micro -translate-x-1/2",
|
|
7
|
+
left: "right-full top-1/2 mr-micro -translate-y-1/2",
|
|
8
|
+
right: "left-full top-1/2 ml-micro -translate-y-1/2",
|
|
9
|
+
};
|
|
10
|
+
const SIDE_MOTION = {
|
|
11
|
+
top: {
|
|
12
|
+
open: "translate-y-0 opacity-100",
|
|
13
|
+
closed: "translate-y-1 opacity-0",
|
|
14
|
+
},
|
|
15
|
+
bottom: {
|
|
16
|
+
open: "translate-y-0 opacity-100",
|
|
17
|
+
closed: "-translate-y-1 opacity-0",
|
|
18
|
+
},
|
|
19
|
+
left: {
|
|
20
|
+
open: "translate-x-0 opacity-100",
|
|
21
|
+
closed: "translate-x-1 opacity-0",
|
|
22
|
+
},
|
|
23
|
+
right: {
|
|
24
|
+
open: "translate-x-0 opacity-100",
|
|
25
|
+
closed: "-translate-x-1 opacity-0",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const ANIMATION_MS = 150;
|
|
29
|
+
/**
|
|
30
|
+
* Infobulle — aide secondaire au survol / focus.
|
|
31
|
+
* Ne remplace pas un label accessible (aria-label / texte visible).
|
|
32
|
+
*/
|
|
33
|
+
export default function Tooltip({ content, children, side = "top", delay = 200, className = "", }) {
|
|
34
|
+
const tooltipId = useId();
|
|
35
|
+
const showTimer = useRef(null);
|
|
36
|
+
const hideTimer = useRef(null);
|
|
37
|
+
const [present, setPresent] = useState(false);
|
|
38
|
+
const [visible, setVisible] = useState(false);
|
|
39
|
+
const clearTimers = () => {
|
|
40
|
+
if (showTimer.current != null) {
|
|
41
|
+
window.clearTimeout(showTimer.current);
|
|
42
|
+
showTimer.current = null;
|
|
43
|
+
}
|
|
44
|
+
if (hideTimer.current != null) {
|
|
45
|
+
window.clearTimeout(hideTimer.current);
|
|
46
|
+
hideTimer.current = null;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const open = () => {
|
|
50
|
+
clearTimers();
|
|
51
|
+
showTimer.current = window.setTimeout(() => {
|
|
52
|
+
setPresent(true);
|
|
53
|
+
requestAnimationFrame(() => {
|
|
54
|
+
requestAnimationFrame(() => setVisible(true));
|
|
55
|
+
});
|
|
56
|
+
}, delay);
|
|
57
|
+
};
|
|
58
|
+
const close = () => {
|
|
59
|
+
clearTimers();
|
|
60
|
+
setVisible(false);
|
|
61
|
+
hideTimer.current = window.setTimeout(() => {
|
|
62
|
+
setPresent(false);
|
|
63
|
+
}, ANIMATION_MS);
|
|
64
|
+
};
|
|
65
|
+
useEffect(() => () => clearTimers(), []);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!present)
|
|
68
|
+
return;
|
|
69
|
+
const onKeyDown = (event) => {
|
|
70
|
+
if (event.key === "Escape")
|
|
71
|
+
close();
|
|
72
|
+
};
|
|
73
|
+
document.addEventListener("keydown", onKeyDown);
|
|
74
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
75
|
+
}, [present]);
|
|
76
|
+
const motion = SIDE_MOTION[side];
|
|
77
|
+
return (_jsxs("span", { className: `relative inline-flex ${className}`, onMouseEnter: open, onMouseLeave: close, onFocus: open, onBlur: close, children: [_jsx("span", { className: "inline-flex", "aria-describedby": present ? tooltipId : undefined, children: children }), present ? (_jsx("span", { id: tooltipId, role: "tooltip", className: `pointer-events-none absolute z-50 w-max max-w-sm rounded-medium border border-border bg-surface px-component py-control text-left text-small leading-snug text-foreground shadow-lg transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-none ${SIDE_CLASS[side]} ${visible ? motion.open : motion.closed}`, children: content })) : null] }));
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modoock/components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Modoock source components for internal projects.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"build": "tsc"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
+
"lucide-react": ">=1",
|
|
22
23
|
"react": ">=18",
|
|
23
24
|
"react-dom": ">=18",
|
|
24
|
-
"
|
|
25
|
+
"recharts": ">=2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@types/react": "^19",
|
|
@@ -30,5 +31,8 @@
|
|
|
30
31
|
"react-dom": "^19",
|
|
31
32
|
"typescript": "^5"
|
|
32
33
|
},
|
|
33
|
-
"license": "MIT"
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"recharts": "^3.10.1"
|
|
37
|
+
}
|
|
34
38
|
}
|