@modoock/components 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ export type CheckboxSize = "sm" | "md";
2
+ export interface CheckboxProps {
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
+ /** Mixed state (e.g. “select all” when some children are checked). */
11
+ indeterminate?: boolean;
12
+ disabled?: boolean;
13
+ id?: string;
14
+ name?: string;
15
+ value?: string;
16
+ size?: CheckboxSize;
17
+ className?: string;
18
+ }
19
+ /**
20
+ * Case à cocher — option binaire ou mixte.
21
+ * Identité Modoock : fond primary à l’activation, icône blanche.
22
+ */
23
+ export default function Checkbox({ checked, onCheckedChange, label, description, indeterminate, disabled, id, name, value, size, className, }: CheckboxProps): import("react").JSX.Element;
24
+ //# sourceMappingURL=checkbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../components/ui/checkbox.tsx"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC,MAAM,WAAW,aAAa;IAC5B,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,sEAAsE;IACtE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAOD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,OAAO,EACP,eAAe,EACf,KAAK,EACL,WAAW,EACX,aAAqB,EACrB,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,KAAK,EACL,IAAW,EACX,SAAc,GACf,EAAE,aAAa,+BA0Ef"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef } from "react";
4
+ import Icon from "./icon";
5
+ const BOX_SIZE = {
6
+ sm: "size-4",
7
+ md: "size-5",
8
+ };
9
+ /**
10
+ * Case à cocher — option binaire ou mixte.
11
+ * Identité Modoock : fond primary à l’activation, icône blanche.
12
+ */
13
+ export default function Checkbox({ checked, onCheckedChange, label, description, indeterminate = false, disabled = false, id, name, value, size = "md", className = "", }) {
14
+ const generatedId = useId();
15
+ const inputId = id ?? generatedId;
16
+ const descriptionId = description ? `${inputId}-description` : undefined;
17
+ const inputRef = useRef(null);
18
+ const isOn = checked || indeterminate;
19
+ useEffect(() => {
20
+ if (inputRef.current) {
21
+ inputRef.current.indeterminate = indeterminate;
22
+ }
23
+ }, [indeterminate]);
24
+ return (_jsxs("div", { className: `inline-flex items-start gap-control ${disabled ? "opacity-60" : ""} ${className}`, children: [_jsxs("span", { className: "relative mt-micro inline-flex shrink-0", children: [_jsx("input", { ref: inputRef, type: "checkbox", id: inputId, name: name, value: value, checked: checked, disabled: disabled, "aria-checked": indeterminate ? "mixed" : checked, "aria-describedby": descriptionId, onChange: (event) => onCheckedChange(event.target.checked), className: `appearance-none rounded-small border 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 ${BOX_SIZE[size]} ${disabled ? "cursor-not-allowed" : "cursor-pointer"} ${isOn ? "border-primary bg-primary" : "border-border bg-surface"}` }), _jsx("span", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 grid place-items-center", children: indeterminate ? (_jsx(Icon, { name: "Minus", variant: "white", size: "small", className: "size-2.5" })) : checked ? (_jsx(Icon, { name: "Check", variant: "white", size: "small", className: "size-2.5" })) : null })] }), _jsxs("div", { className: "min-w-0 pt-micro", children: [_jsx("label", { htmlFor: inputId, 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] })] }));
25
+ }
@@ -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;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"}
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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BAAgB,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,+BA+HtB"}
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useEffect, useId, useMemo, useRef, useState, } from "react";
4
4
  import Icon from "./icon";
5
5
  import ClickableButton from "./button";
@@ -73,6 +73,76 @@ function formatRangeLabel(value) {
73
73
  return `${DATE_FORMAT.format(value.from)} – …`;
74
74
  return `… – ${DATE_FORMAT.format(value.to)}`;
75
75
  }
76
+ function addDays(date, days) {
77
+ const day = startOfDay(date);
78
+ return new Date(day.getFullYear(), day.getMonth(), day.getDate() + days);
79
+ }
80
+ function startOfWeek(date) {
81
+ const day = startOfDay(date);
82
+ const offset = (day.getDay() + 6) % 7;
83
+ return addDays(day, -offset);
84
+ }
85
+ function startOfMonth(date) {
86
+ return new Date(date.getFullYear(), date.getMonth(), 1);
87
+ }
88
+ function startOfYear(date) {
89
+ return new Date(date.getFullYear(), 0, 1);
90
+ }
91
+ function monthIsOutOfBounds(year, month, minDate, maxDate) {
92
+ const start = new Date(year, month, 1);
93
+ const end = new Date(year, month + 1, 0);
94
+ if (minDate && isAfterDay(minDate, end))
95
+ return true;
96
+ if (maxDate && isBeforeDay(maxDate, start))
97
+ return true;
98
+ return false;
99
+ }
100
+ function yearIsOutOfBounds(year, minDate, maxDate) {
101
+ const start = new Date(year, 0, 1);
102
+ const end = new Date(year, 11, 31);
103
+ if (minDate && isAfterDay(minDate, end))
104
+ return true;
105
+ if (maxDate && isBeforeDay(maxDate, start))
106
+ return true;
107
+ return false;
108
+ }
109
+ function clampRange(range, minDate, maxDate) {
110
+ let from = range.from ? clampToBounds(range.from, minDate, maxDate) : null;
111
+ let to = range.to ? clampToBounds(range.to, minDate, maxDate) : null;
112
+ if (from && to && isAfterDay(from, to)) {
113
+ const swap = from;
114
+ from = to;
115
+ to = swap;
116
+ }
117
+ return { from, to };
118
+ }
119
+ const MONTH_SHORT_LABELS = Array.from({ length: 12 }, (_, month) => new Intl.DateTimeFormat("fr-FR", { month: "short" }).format(new Date(2020, month, 1)));
120
+ const DATE_PRESETS = [
121
+ { label: "Aujourd'hui", get: (today) => today },
122
+ { label: "Hier", get: (today) => addDays(today, -1) },
123
+ { label: "Demain", get: (today) => addDays(today, 1) },
124
+ ];
125
+ const RANGE_PRESETS = [
126
+ {
127
+ label: "Aujourd'hui",
128
+ get: (today) => ({ from: today, to: today }),
129
+ },
130
+ {
131
+ label: "Cette semaine",
132
+ get: (today) => ({ from: startOfWeek(today), to: today }),
133
+ },
134
+ {
135
+ label: "Ce mois",
136
+ get: (today) => ({ from: startOfMonth(today), to: today }),
137
+ },
138
+ {
139
+ label: "Cette année",
140
+ get: (today) => ({ from: startOfYear(today), to: today }),
141
+ },
142
+ ];
143
+ function PresetButton({ label, onSelect, }) {
144
+ return (_jsx("button", { type: "button", onClick: onSelect, className: "rounded-full border border-border bg-surface px-control py-micro text-label text-foreground transition-colors duration-200 ease-out hover:border-primary hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none", children: label }));
145
+ }
76
146
  /* ------------------------------------------------------------------ */
77
147
  /* Field chrome */
78
148
  /* ------------------------------------------------------------------ */
@@ -145,44 +215,105 @@ function buildMonthCells(viewMonth) {
145
215
  cells.push(null);
146
216
  return cells;
147
217
  }
218
+ function CalendarNavButton({ label, onClick, children, }) {
219
+ return (_jsx("button", { type: "button", "aria-label": label, onClick: onClick, className: "flex size-8 items-center justify-center rounded-small text-muted-foreground transition-colors duration-200 ease-out hover:bg-surface-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none [&_svg]:size-[var(--icon-small)]", children: children }));
220
+ }
148
221
  function Calendar({ viewMonth, onViewMonthChange, onSelectDay, isSelected, isInRange, isRangeStart, isRangeEnd, minDate, maxDate, footer, }) {
149
222
  const cells = useMemo(() => buildMonthCells(viewMonth), [viewMonth]);
223
+ const [panel, setPanel] = useState("days");
150
224
  const title = MONTH_TITLE_FORMAT.format(viewMonth);
151
225
  const today = startOfDay(new Date());
226
+ const year = viewMonth.getFullYear();
227
+ const month = viewMonth.getMonth();
228
+ const yearStart = Math.floor(year / 12) * 12;
229
+ const years = Array.from({ length: 12 }, (_, index) => yearStart + index);
152
230
  const goMonth = (delta) => {
153
- onViewMonthChange(new Date(viewMonth.getFullYear(), viewMonth.getMonth() + delta, 1));
231
+ onViewMonthChange(new Date(year, month + delta, 1));
232
+ };
233
+ const goYear = (delta) => {
234
+ onViewMonthChange(new Date(year + delta, month, 1));
154
235
  };
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
- if (!day) {
157
- return _jsx("div", { className: "h-8" }, `empty-${index}`);
158
- }
159
- const disabled = (minDate ? isBeforeDay(day, minDate) : false) ||
160
- (maxDate ? isAfterDay(day, maxDate) : false);
161
- const selected = isSelected(day);
162
- const inRange = isInRange?.(day) ?? false;
163
- const rangeStart = isRangeStart?.(day) ?? false;
164
- const rangeEnd = isRangeEnd?.(day) ?? false;
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 duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none";
167
- if (disabled) {
168
- dayClass += " cursor-not-allowed text-muted-foreground/40";
169
- }
170
- else if (selected || rangeStart || rangeEnd) {
171
- dayClass +=
172
- " bg-primary text-primary-foreground hover:bg-primary-hover";
173
- }
174
- else if (inRange) {
175
- dayClass += " bg-primary-light text-primary hover:bg-primary-muted";
176
- }
177
- else {
178
- dayClass +=
179
- " text-foreground hover:bg-surface-muted";
180
- }
181
- if (isToday && !selected && !rangeStart && !rangeEnd) {
182
- dayClass += " font-semibold ring-1 ring-inset ring-primary/40";
183
- }
184
- return (_jsx("button", { type: "button", role: "gridcell", disabled: disabled, "aria-selected": selected || rangeStart || rangeEnd, "aria-current": isToday ? "date" : undefined, onClick: () => onSelectDay(day), className: dayClass, children: day.getDate() }, day.toISOString()));
185
- }) }), footer ? _jsx("div", { className: "mt-3 border-t border-border pt-3", children: footer }) : null] }));
236
+ const goYearPage = (delta) => {
237
+ onViewMonthChange(new Date(year + delta * 12, month, 1));
238
+ };
239
+ const cellButtonClass = "flex h-8 w-full items-center justify-center rounded-small text-sm capitalize transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none disabled:cursor-not-allowed disabled:text-muted-foreground/40";
240
+ return (_jsxs("div", { className: "w-[17.5rem] p-3", children: [_jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [_jsx(CalendarNavButton, { label: panel === "years"
241
+ ? "Années précédentes"
242
+ : panel === "months"
243
+ ? "Année précédente"
244
+ : "Mois précédent", onClick: () => {
245
+ if (panel === "years")
246
+ goYearPage(-1);
247
+ else if (panel === "months")
248
+ goYear(-1);
249
+ else
250
+ goMonth(-1);
251
+ }, children: _jsx(Icon, { name: "ChevronLeft", "aria-hidden": "true" }) }), _jsxs("button", { type: "button", "aria-label": panel === "years"
252
+ ? "Revenir au calendrier"
253
+ : "Choisir l’année, puis le mois", onClick: () => setPanel(panel === "years" ? "days" : "years"), className: "flex min-w-0 items-center gap-micro rounded-small px-2 py-1 text-sm font-medium capitalize text-foreground transition-colors duration-200 ease-out hover:bg-surface-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none", children: [_jsx("span", { className: "truncate", children: panel === "years"
254
+ ? `${yearStart} – ${yearStart + 11}`
255
+ : panel === "months"
256
+ ? String(year)
257
+ : title }), _jsx(Icon, { name: panel === "days" ? "ChevronDown" : "ChevronUp", size: "small", "aria-hidden": "true" })] }), _jsx(CalendarNavButton, { label: panel === "years"
258
+ ? "Années suivantes"
259
+ : panel === "months"
260
+ ? "Année suivante"
261
+ : "Mois suivant", onClick: () => {
262
+ if (panel === "years")
263
+ goYearPage(1);
264
+ else if (panel === "months")
265
+ goYear(1);
266
+ else
267
+ goMonth(1);
268
+ }, children: _jsx(Icon, { name: "ChevronRight", "aria-hidden": "true" }) })] }), panel === "years" ? (_jsx("div", { className: "grid grid-cols-3 gap-1", children: years.map((item) => {
269
+ const disabled = yearIsOutOfBounds(item, minDate, maxDate);
270
+ const selected = item === year;
271
+ return (_jsx("button", { type: "button", disabled: disabled, onClick: () => {
272
+ onViewMonthChange(new Date(item, month, 1));
273
+ setPanel("months");
274
+ }, className: `${cellButtonClass} ${selected
275
+ ? "bg-primary text-primary-foreground hover:bg-primary-hover"
276
+ : "text-foreground hover:bg-surface-muted"}`, children: item }, item));
277
+ }) })) : null, panel === "months" ? (_jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTH_SHORT_LABELS.map((label, index) => {
278
+ const disabled = monthIsOutOfBounds(year, index, minDate, maxDate);
279
+ const selected = index === month;
280
+ return (_jsx("button", { type: "button", disabled: disabled, onClick: () => {
281
+ onViewMonthChange(new Date(year, index, 1));
282
+ setPanel("days");
283
+ }, className: `${cellButtonClass} ${selected
284
+ ? "bg-primary text-primary-foreground hover:bg-primary-hover"
285
+ : "text-foreground hover:bg-surface-muted"}`, children: label }, label));
286
+ }) })) : null, panel === "days" ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "mb-1 grid grid-cols-7 gap-0.5", children: WEEKDAY_LABELS.map((label) => (_jsx("div", { className: "flex h-8 items-center justify-center text-xs font-medium text-muted-foreground", children: label }, label))) }), _jsx("div", { className: "grid grid-cols-7 gap-0.5", role: "grid", "aria-label": title, children: cells.map((day, index) => {
287
+ if (!day) {
288
+ return _jsx("div", { className: "h-8" }, `empty-${index}`);
289
+ }
290
+ const disabled = (minDate ? isBeforeDay(day, minDate) : false) ||
291
+ (maxDate ? isAfterDay(day, maxDate) : false);
292
+ const selected = isSelected(day);
293
+ const inRange = isInRange?.(day) ?? false;
294
+ const rangeStart = isRangeStart?.(day) ?? false;
295
+ const rangeEnd = isRangeEnd?.(day) ?? false;
296
+ const isToday = isSameDay(day, today);
297
+ let dayClass = "relative flex h-8 w-full items-center justify-center rounded-small text-sm transition-colors duration-200 ease-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-reduce:transition-none";
298
+ if (disabled) {
299
+ dayClass += " cursor-not-allowed text-muted-foreground/40";
300
+ }
301
+ else if (selected || rangeStart || rangeEnd) {
302
+ dayClass +=
303
+ " bg-primary text-primary-foreground hover:bg-primary-hover";
304
+ }
305
+ else if (inRange) {
306
+ dayClass += " bg-primary-light text-primary hover:bg-primary-muted";
307
+ }
308
+ else {
309
+ dayClass +=
310
+ " text-foreground hover:bg-surface-muted";
311
+ }
312
+ if (isToday && !selected && !rangeStart && !rangeEnd) {
313
+ dayClass += " font-semibold ring-1 ring-inset ring-primary/40";
314
+ }
315
+ return (_jsx("button", { type: "button", role: "gridcell", disabled: disabled, "aria-selected": selected || rangeStart || rangeEnd, "aria-current": isToday ? "date" : undefined, onClick: () => onSelectDay(day), className: dayClass, children: day.getDate() }, day.toISOString()));
316
+ }) })] })) : null, footer ? _jsx("div", { className: "mt-3 border-t border-border pt-3", children: footer }) : null] }));
186
317
  }
187
318
  /* ------------------------------------------------------------------ */
188
319
  /* Trigger + shell */
@@ -223,10 +354,10 @@ export function DatePicker({ label, value, onChange, placeholder = "Sélectionne
223
354
  onChange(next);
224
355
  setOpen(false);
225
356
  };
226
- return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATE_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelect, isSelected: (day) => isSameDay(day, value), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
227
- onChange(null);
228
- setOpen(false);
229
- }, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "secondary", size: "sm", onClick: () => handleSelect(clampToBounds(startOfDay(new Date()), minDate, maxDate)), children: "Aujourd'hui" })] }) }) }));
357
+ return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATE_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelect, isSelected: (day) => isSameDay(day, value), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => handleSelect(clampToBounds(preset.get(startOfDay(new Date())), minDate, maxDate)) }, preset.label))) }), _jsx("div", { className: "flex justify-end", children: _jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
358
+ onChange(null);
359
+ setOpen(false);
360
+ }, children: "Effacer" }) })] }) }) }));
230
361
  }
231
362
  /* ------------------------------------------------------------------ */
232
363
  /* DateTimePicker — date + time */
@@ -262,7 +393,11 @@ export function DateTimePicker({ label, value, onChange, placeholder = "Sélecti
262
393
  apply(draftDate, nextTime);
263
394
  }
264
395
  };
265
- return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATETIME_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: (day) => isSameDay(day, draftDate), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("label", { className: "flex items-center justify-between gap-2 text-label text-muted-foreground", children: [_jsx("span", { children: "Heure" }), _jsx("input", { type: "time", value: timeText, onChange: (event) => handleTimeChange(event.target.value), className: "ds-input w-auto py-1.5", "aria-label": "Heure" })] }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
396
+ return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: value ? DATETIME_FORMAT.format(value) : null, placeholder: placeholder, clearable: clearable, hasValue: Boolean(value), onClear: () => onChange(null), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: (day) => isSameDay(day, draftDate), minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: DATE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => {
397
+ const nextDay = clampToBounds(preset.get(startOfDay(new Date())), minDate, maxDate);
398
+ setViewMonth(initialViewMonth(nextDay));
399
+ handleSelectDay(nextDay);
400
+ } }, preset.label))) }), _jsxs("label", { className: "flex items-center justify-between gap-2 text-label text-muted-foreground", children: [_jsx("span", { children: "Heure" }), _jsx("input", { type: "time", value: timeText, onChange: (event) => handleTimeChange(event.target.value), className: "ds-input w-auto py-1.5", "aria-label": "Heure" })] }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
266
401
  onChange(null);
267
402
  setOpen(false);
268
403
  }, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "primary", size: "sm", disabled: !draftDate, onClick: () => {
@@ -311,19 +446,27 @@ export function DateRangePicker({ label, value, onChange, placeholder = "Sélect
311
446
  !isSameDay(day, draft.from) &&
312
447
  !isSameDay(day, draft.to);
313
448
  };
314
- return (_jsx(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: formatRangeLabel(value), placeholder: placeholder, clearable: clearable, hasValue: Boolean(value.from || value.to), onClear: () => onChange({ from: null, to: null }), children: _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: () => false, isRangeStart: (day) => isSameDay(day, draft.from), isRangeEnd: (day) => isSameDay(day, draft.to), isInRange: inRange, minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-small text-muted-foreground", children: !draft.from
315
- ? "Choisissez la date de début."
316
- : !draft.to
317
- ? "Choisissez la date de fin."
318
- : `${DATE_FORMAT.format(draft.from)} – ${DATE_FORMAT.format(draft.to)}` }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
319
- const empty = { from: null, to: null };
320
- setDraft(empty);
321
- onChange(empty);
322
- setOpen(false);
323
- }, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "primary", size: "sm", disabled: !draft.from || !draft.to, onClick: () => {
324
- if (!draft.from || !draft.to)
325
- return;
326
- onChange(draft);
327
- setOpen(false);
328
- }, children: "Appliquer" })] })] }) }) }));
449
+ const pickingEnd = Boolean(draft.from && !draft.to);
450
+ const rangeComplete = Boolean(draft.from && draft.to);
451
+ const applyRange = (next) => {
452
+ const clamped = clampRange(next, minDate, maxDate);
453
+ setDraft(clamped);
454
+ if (clamped.from)
455
+ setViewMonth(initialViewMonth(clamped.from, clamped.to));
456
+ };
457
+ return (_jsxs(DateFieldShell, { rootRef: rootRef, label: label, required: required, disabled: disabled, error: error, helper: helper, className: className, open: open, onOpenChange: setOpen, display: formatRangeLabel(value), placeholder: placeholder, clearable: clearable, hasValue: Boolean(value.from || value.to), onClear: () => onChange({ from: null, to: null }), children: [_jsx("p", { className: "w-[17.5rem] border-b border-border px-3 py-control text-center text-body-medium text-primary", children: rangeComplete
458
+ ? `${DATE_FORMAT.format(draft.from)} – ${DATE_FORMAT.format(draft.to)}`
459
+ : pickingEnd
460
+ ? "Choisissez la date de fin."
461
+ : "Choisissez la date de début." }), _jsx(Calendar, { viewMonth: viewMonth, onViewMonthChange: setViewMonth, onSelectDay: handleSelectDay, isSelected: () => false, isRangeStart: (day) => isSameDay(day, draft.from), isRangeEnd: (day) => isSameDay(day, draft.to), isInRange: inRange, minDate: minDate, maxDate: maxDate, footer: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap gap-1", children: RANGE_PRESETS.map((preset) => (_jsx(PresetButton, { label: preset.label, onSelect: () => applyRange(preset.get(startOfDay(new Date()))) }, preset.label))) }), _jsxs("div", { className: "flex justify-between gap-2", children: [_jsx(ClickableButton, { type: "button", variant: "ghost", size: "sm", onClick: () => {
462
+ const empty = { from: null, to: null };
463
+ setDraft(empty);
464
+ onChange(empty);
465
+ setOpen(false);
466
+ }, children: "Effacer" }), _jsx(ClickableButton, { type: "button", variant: "primary", size: "sm", disabled: !draft.from || !draft.to, onClick: () => {
467
+ if (!draft.from || !draft.to)
468
+ return;
469
+ onChange(draft);
470
+ setOpen(false);
471
+ }, children: "Appliquer" })] })] }) })] }));
329
472
  }
package/dist/index.d.ts CHANGED
@@ -37,4 +37,12 @@ export { default as Switch } from "./switch";
37
37
  export type { SwitchProps, SwitchSize } from "./switch";
38
38
  export { default as Tooltip } from "./tooltip";
39
39
  export type { TooltipProps, TooltipSide } from "./tooltip";
40
+ export { default as Checkbox } from "./checkbox";
41
+ export type { CheckboxProps, CheckboxSize } from "./checkbox";
42
+ export { RadioGroup, Radio } from "./radio";
43
+ export type { RadioGroupProps, RadioProps, RadioSize } from "./radio";
44
+ export { default as Skeleton } from "./skeleton";
45
+ export type { SkeletonProps, SkeletonShape } from "./skeleton";
46
+ export { default as Pagination } from "./pagination";
47
+ export type { PaginationProps } from "./pagination";
40
48
  //# sourceMappingURL=index.d.ts.map
@@ -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,CAA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I,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -18,3 +18,7 @@ export { default as Chart, CHART_COLORS } from "./chart";
18
18
  export { Toaster, toast } from "./toast";
19
19
  export { default as Switch } from "./switch";
20
20
  export { default as Tooltip } from "./tooltip";
21
+ export { default as Checkbox } from "./checkbox";
22
+ export { RadioGroup, Radio } from "./radio";
23
+ export { default as Skeleton } from "./skeleton";
24
+ export { default as Pagination } from "./pagination";
@@ -0,0 +1,16 @@
1
+ export interface PaginationProps {
2
+ /** Current page, 1-based. */
3
+ page: number;
4
+ /** Total number of pages (at least 1). */
5
+ pageCount: number;
6
+ onPageChange: (page: number) => void;
7
+ /** Total item count — used with `pageSize` for the range summary. */
8
+ totalItems?: number;
9
+ pageSize?: number;
10
+ className?: string;
11
+ }
12
+ /**
13
+ * Pagination — pages numérotées, précédent / suivant, résumé.
14
+ */
15
+ export default function Pagination({ page, pageCount, onPageChange, totalItems, pageSize, className, }: PaginationProps): import("react").JSX.Element;
16
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../components/ui/pagination.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAoCD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAc,GACf,EAAE,eAAe,+BA+DjB"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import ClickableButton from "./button";
4
+ import Icon from "./icon";
5
+ function pageItems(page, count) {
6
+ if (count <= 7) {
7
+ return Array.from({ length: count }, (_, index) => index + 1);
8
+ }
9
+ const items = [1];
10
+ const start = Math.max(2, page - 1);
11
+ const end = Math.min(count - 1, page + 1);
12
+ if (start > 2)
13
+ items.push("ellipsis-start");
14
+ for (let n = start; n <= end; n += 1)
15
+ items.push(n);
16
+ if (end < count - 1)
17
+ items.push("ellipsis-end");
18
+ items.push(count);
19
+ return items;
20
+ }
21
+ function rangeSummary(page, pageCount, totalItems, pageSize) {
22
+ if (totalItems != null && pageSize != null) {
23
+ if (totalItems === 0)
24
+ return "Aucun élément";
25
+ const start = (page - 1) * pageSize + 1;
26
+ const end = Math.min(page * pageSize, totalItems);
27
+ return `${start}–${end} sur ${totalItems}`;
28
+ }
29
+ return `Page ${page} sur ${pageCount}`;
30
+ }
31
+ /**
32
+ * Pagination — pages numérotées, précédent / suivant, résumé.
33
+ */
34
+ export default function Pagination({ page, pageCount, onPageChange, totalItems, pageSize, className = "", }) {
35
+ const count = Math.max(1, pageCount);
36
+ const current = Math.min(Math.max(1, page), count);
37
+ const summary = rangeSummary(current, count, totalItems, pageSize);
38
+ return (_jsxs("nav", { "aria-label": "Pagination", className: `flex flex-wrap items-center justify-between gap-control ${className}`, children: [_jsx("p", { className: "text-small text-muted-foreground", "aria-live": "polite", children: summary }), _jsxs("div", { className: "flex flex-wrap items-center gap-micro", children: [_jsx(ClickableButton, { type: "button", variant: "secondary", size: "sm", className: "w-9 px-0", "aria-label": "Page pr\u00E9c\u00E9dente", disabled: current <= 1, onClick: () => onPageChange(current - 1), children: _jsx(Icon, { name: "ChevronLeft", size: "small", "aria-hidden": "true" }) }), pageItems(current, count).map((item) => typeof item === "number" ? (_jsx(ClickableButton, { type: "button", variant: item === current ? "primary" : "secondary", size: "sm", className: "min-w-9 px-inline", "aria-label": `Page ${item}`, "aria-current": item === current ? "page" : undefined, onClick: () => onPageChange(item), children: item }, item)) : (_jsx("span", { className: "px-micro text-small text-muted-foreground", "aria-hidden": "true", children: "\u2026" }, item))), _jsx(ClickableButton, { type: "button", variant: "secondary", size: "sm", className: "w-9 px-0", "aria-label": "Page suivante", disabled: current >= count, onClick: () => onPageChange(current + 1), children: _jsx(Icon, { name: "ChevronRight", size: "small", "aria-hidden": "true" }) })] })] }));
39
+ }
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from "react";
2
+ export type RadioSize = "sm" | "md";
3
+ export interface RadioGroupProps {
4
+ /** Controlled selected value. */
5
+ value: string;
6
+ onValueChange: (value: string) => void;
7
+ /** Visible group label (fieldset legend) — required. */
8
+ label: string;
9
+ name?: string;
10
+ disabled?: boolean;
11
+ size?: RadioSize;
12
+ className?: string;
13
+ children: ReactNode;
14
+ }
15
+ /**
16
+ * Groupe de boutons radio — un seul choix parmi plusieurs.
17
+ */
18
+ export declare function RadioGroup({ value, onValueChange, label, name, disabled, size, className, children, }: RadioGroupProps): import("react").JSX.Element;
19
+ export interface RadioProps {
20
+ value: string;
21
+ /** Visible label — required for accessibility. */
22
+ label: string;
23
+ description?: string;
24
+ disabled?: boolean;
25
+ id?: string;
26
+ size?: RadioSize;
27
+ className?: string;
28
+ }
29
+ /**
30
+ * Bouton radio — à utiliser dans un RadioGroup.
31
+ * Identité Modoock : anneau primary, pastille primary.
32
+ */
33
+ export declare function Radio({ value, label, description, disabled, id, size, className, }: RadioProps): import("react").JSX.Element;
34
+ //# sourceMappingURL=radio.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../components/ui/radio.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC;AAYpC,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAYD;;GAEG;AACH,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,aAAa,EACb,KAAK,EACL,IAAI,EACJ,QAAgB,EAChB,IAAW,EACX,SAAc,EACd,QAAQ,GACT,EAAE,eAAe,+BAiBjB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,KAAK,EACL,WAAW,EACX,QAAgB,EAChB,EAAE,EACF,IAAI,EACJ,SAAc,GACf,EAAE,UAAU,+BA0DZ"}
package/dist/radio.js ADDED
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { createContext, useContext, useId, } from "react";
4
+ const RadioGroupContext = createContext(null);
5
+ const BOX_SIZE = {
6
+ sm: "size-4",
7
+ md: "size-5",
8
+ };
9
+ const DOT_SIZE = {
10
+ sm: "size-1.5",
11
+ md: "size-2",
12
+ };
13
+ /**
14
+ * Groupe de boutons radio — un seul choix parmi plusieurs.
15
+ */
16
+ export function RadioGroup({ value, onValueChange, label, name, disabled = false, size = "md", className = "", children, }) {
17
+ const generatedName = useId();
18
+ const groupName = name ?? generatedName;
19
+ return (_jsxs("fieldset", { disabled: disabled, className: `flex min-w-0 flex-col gap-control ${disabled ? "opacity-60" : ""} ${className}`, children: [_jsx("legend", { className: "px-0 text-label text-muted-foreground", children: label }), _jsx(RadioGroupContext.Provider, { value: { name: groupName, value, onValueChange, disabled, size }, children: children })] }));
20
+ }
21
+ /**
22
+ * Bouton radio — à utiliser dans un RadioGroup.
23
+ * Identité Modoock : anneau primary, pastille primary.
24
+ */
25
+ export function Radio({ value, label, description, disabled = false, id, size, className = "", }) {
26
+ const ctx = useContext(RadioGroupContext);
27
+ if (!ctx) {
28
+ throw new Error("Radio must be used inside RadioGroup.");
29
+ }
30
+ const generatedId = useId();
31
+ const inputId = id ?? generatedId;
32
+ const descriptionId = description ? `${inputId}-description` : undefined;
33
+ const checked = ctx.value === value;
34
+ const isDisabled = disabled || ctx.disabled;
35
+ const resolvedSize = size ?? ctx.size;
36
+ return (_jsxs("div", { className: `inline-flex items-start gap-control ${disabled && !ctx.disabled ? "opacity-60" : ""} ${className}`, children: [_jsxs("span", { className: "relative mt-micro inline-flex shrink-0", children: [_jsx("input", { type: "radio", id: inputId, name: ctx.name, value: value, checked: checked, disabled: isDisabled, "aria-describedby": descriptionId, onChange: () => ctx.onValueChange(value), className: `appearance-none rounded-full border bg-surface outline-none transition-[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 ${BOX_SIZE[resolvedSize]} ${isDisabled ? "cursor-not-allowed" : "cursor-pointer"} ${checked ? "border-primary" : "border-border"}` }), checked ? (_jsx("span", { "aria-hidden": "true", className: `pointer-events-none absolute inset-0 m-auto rounded-full bg-primary ${DOT_SIZE[resolvedSize]}` })) : null] }), _jsxs("div", { className: "min-w-0 pt-micro", children: [_jsx("label", { htmlFor: inputId, className: `text-body-medium leading-snug text-foreground ${isDisabled ? "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] })] }));
37
+ }
@@ -0,0 +1,12 @@
1
+ export type SkeletonShape = "line" | "circle" | "block";
2
+ export interface SkeletonProps {
3
+ /** Visual shape of the placeholder. */
4
+ shape?: SkeletonShape;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * Squelette — placeholder de chargement.
9
+ * Le parent peut poser `aria-busy` ; ces barres restent décoratives.
10
+ */
11
+ export default function Skeleton({ shape, className, }: SkeletonProps): import("react").JSX.Element;
12
+ //# sourceMappingURL=skeleton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.d.ts","sourceRoot":"","sources":["../components/ui/skeleton.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAc,EACd,SAAc,GACf,EAAE,aAAa,+BAOf"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const SHAPE_CLASS = {
3
+ line: "h-3 w-full rounded-small",
4
+ circle: "size-10 rounded-full",
5
+ block: "h-24 w-full rounded-medium",
6
+ };
7
+ /**
8
+ * Squelette — placeholder de chargement.
9
+ * Le parent peut poser `aria-busy` ; ces barres restent décoratives.
10
+ */
11
+ export default function Skeleton({ shape = "line", className = "", }) {
12
+ return (_jsx("div", { "aria-hidden": "true", className: `animate-pulse bg-muted motion-reduce:animate-none ${SHAPE_CLASS[shape]} ${className}` }));
13
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../components/ui/table.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAI7C,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;CACjC;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;I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;CAChC;AAED,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,GAAG,CAAC;IAEjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;uEAImE;IACnE,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAElC,YAAY,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;iFAG6E;IAC7E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;CAChD;AAiND,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,EAC9C,OAAO,EACP,IAAI,EACJ,WAAe,EACf,YAAuC,EACvC,SAAkC,EAClC,gBAAoB,EACpB,WAAW,EACX,YAAmB,EACnB,cAAqB,EACrB,SAAS,EACT,SAAiB,EACjB,cAAc,EACd,eAAe,GAChB,EAAE,UAAU,CAAC,CAAC,CAAC,+BA4ef"}
package/dist/table.js CHANGED
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useState } from "react";
4
4
  import Icon from "./icon";
5
5
  import ClickableButton from "./button";
6
+ import Pagination from "./pagination";
6
7
  function defaultCompare(a, b, key) {
7
8
  const aValue = a[key];
8
9
  const bValue = b[key];
@@ -176,5 +177,5 @@ export default function Table({ columns, data, rowsPerPage = 8, emptyMessage = "
176
177
  : "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
178
  ? "Réduire"
178
179
  : `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 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
+ }), 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 ? (_jsx(Pagination, { page: safePage, pageCount: totalPages, onPageChange: setCurrentPage, totalItems: sortedData.length, pageSize: rowsPerPage, className: "border-t border-border bg-surface px-component py-control" })) : null] }));
180
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modoock/components",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Modoock source components for internal projects.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",