@modoock/components 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordion.d.ts +24 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +30 -0
- package/dist/badge.d.ts +10 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +14 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.d.ts.map +1 -0
- package/dist/button.js +27 -0
- package/dist/icon.d.ts +21 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +24 -0
- package/{components/ui/index.ts → dist/index.d.ts} +24 -28
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/input.d.ts +41 -0
- package/dist/input.d.ts.map +1 -0
- package/dist/input.js +105 -0
- package/dist/loader.d.ts +26 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +20 -0
- package/dist/metric-bar.d.ts +11 -0
- package/dist/metric-bar.d.ts.map +1 -0
- package/dist/metric-bar.js +19 -0
- package/dist/modal.d.ts +19 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +88 -0
- package/dist/select.d.ts +59 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +153 -0
- package/dist/stepper.d.ts +13 -0
- package/dist/stepper.d.ts.map +1 -0
- package/dist/stepper.js +38 -0
- package/dist/tab.d.ts +34 -0
- package/dist/tab.d.ts.map +1 -0
- package/dist/tab.js +25 -0
- package/dist/table.d.ts +57 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +180 -0
- package/package.json +27 -3
- package/components/ui/action-stack.tsx +0 -42
- package/components/ui/badge.tsx +0 -43
- package/components/ui/button.tsx +0 -104
- package/components/ui/icon.tsx +0 -78
- package/components/ui/input.tsx +0 -376
- package/components/ui/loader.tsx +0 -78
- package/components/ui/metric-bar.tsx +0 -49
- package/components/ui/modal.tsx +0 -177
- package/components/ui/select.tsx +0 -458
- package/components/ui/stepper.tsx +0 -96
- package/components/ui/tab.tsx +0 -85
- package/components/ui/user-table.tsx +0 -806
package/components/ui/select.tsx
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
|
4
|
-
import Badge from "./badge";
|
|
5
|
-
import Icon from "./icon";
|
|
6
|
-
import Input from "./input";
|
|
7
|
-
|
|
8
|
-
/** Public option shape shared by every selection variant. */
|
|
9
|
-
export interface SelectOption {
|
|
10
|
-
value: string;
|
|
11
|
-
label: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface BaseSelectProps {
|
|
15
|
-
label?: string;
|
|
16
|
-
options: SelectOption[];
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
emptyMessage?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface SelectProps extends BaseSelectProps {
|
|
22
|
-
value: string;
|
|
23
|
-
onChange: (value: string) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface MultiSelectProps extends BaseSelectProps {
|
|
27
|
-
values: string[];
|
|
28
|
-
onChange: (values: string[]) => void;
|
|
29
|
-
/**
|
|
30
|
-
* Nombre maximal de chips d'options sélectionnées affichées dans le champ ;
|
|
31
|
-
* au-delà, un indicateur « +N » signale les autres (info-bulle = liste).
|
|
32
|
-
*/
|
|
33
|
-
maxVisibleChips?: number;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface SelectDropdownProps {
|
|
37
|
-
open: boolean;
|
|
38
|
-
options: SelectOption[];
|
|
39
|
-
selected: Set<string>;
|
|
40
|
-
multiple: boolean;
|
|
41
|
-
searchable: boolean;
|
|
42
|
-
searchablePlaceholder?: string;
|
|
43
|
-
onToggle: (value: string) => void;
|
|
44
|
-
emptyMessage?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const LABEL_CLASS = "mb-inline block text-label text-muted-foreground";
|
|
48
|
-
|
|
49
|
-
function useDismissibleOpen() {
|
|
50
|
-
const [open, setOpen] = useState(false);
|
|
51
|
-
const rootRef = useRef<HTMLDivElement>(null);
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!open) return;
|
|
55
|
-
|
|
56
|
-
const close = () => setOpen(false);
|
|
57
|
-
|
|
58
|
-
const focusTrigger = () => {
|
|
59
|
-
rootRef.current
|
|
60
|
-
?.querySelector<HTMLButtonElement>("button[aria-haspopup]")
|
|
61
|
-
?.focus();
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const isOutside = (target: EventTarget | null) =>
|
|
65
|
-
target instanceof Node && !rootRef.current?.contains(target);
|
|
66
|
-
|
|
67
|
-
const onPointerDown = (event: PointerEvent) => {
|
|
68
|
-
if (isOutside(event.target)) close();
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const onKeyDown = (event: KeyboardEvent) => {
|
|
72
|
-
if (event.key !== "Escape") return;
|
|
73
|
-
event.preventDefault();
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
focusTrigger();
|
|
76
|
-
close();
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const onFocusIn = (event: FocusEvent) => {
|
|
80
|
-
if (isOutside(event.target)) close();
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
document.addEventListener("pointerdown", onPointerDown, true);
|
|
84
|
-
document.addEventListener("keydown", onKeyDown, true);
|
|
85
|
-
document.addEventListener("focusin", onFocusIn);
|
|
86
|
-
return () => {
|
|
87
|
-
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
88
|
-
document.removeEventListener("keydown", onKeyDown, true);
|
|
89
|
-
document.removeEventListener("focusin", onFocusIn);
|
|
90
|
-
};
|
|
91
|
-
}, [open]);
|
|
92
|
-
|
|
93
|
-
return { open, setOpen, rootRef };
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function SelectTrigger({
|
|
97
|
-
open,
|
|
98
|
-
onOpenChange,
|
|
99
|
-
children,
|
|
100
|
-
}: {
|
|
101
|
-
open: boolean;
|
|
102
|
-
onOpenChange: (open: boolean) => void;
|
|
103
|
-
children: ReactNode;
|
|
104
|
-
}) {
|
|
105
|
-
return (
|
|
106
|
-
<button
|
|
107
|
-
type="button"
|
|
108
|
-
aria-haspopup="true"
|
|
109
|
-
aria-expanded={open}
|
|
110
|
-
onClick={() => onOpenChange(!open)}
|
|
111
|
-
className="ds-input flex cursor-pointer items-center justify-between gap-2 text-left [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0"
|
|
112
|
-
>
|
|
113
|
-
{children}
|
|
114
|
-
<Icon
|
|
115
|
-
name="ChevronDown"
|
|
116
|
-
variant="muted"
|
|
117
|
-
aria-hidden="true"
|
|
118
|
-
className={`transition-transform duration-150 ${open ? "rotate-180" : ""}`}
|
|
119
|
-
/>
|
|
120
|
-
</button>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function SelectDropdown({
|
|
125
|
-
open,
|
|
126
|
-
options,
|
|
127
|
-
selected,
|
|
128
|
-
multiple,
|
|
129
|
-
searchable,
|
|
130
|
-
searchablePlaceholder = "Rechercher...",
|
|
131
|
-
onToggle,
|
|
132
|
-
emptyMessage = "Aucun résultat trouvé.",
|
|
133
|
-
}: SelectDropdownProps) {
|
|
134
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
135
|
-
|
|
136
|
-
const filteredOptions = useMemo(() => {
|
|
137
|
-
if (!searchQuery.trim()) return options;
|
|
138
|
-
const query = searchQuery.toLowerCase();
|
|
139
|
-
return options.filter(
|
|
140
|
-
(option) =>
|
|
141
|
-
option.label.toLowerCase().includes(query) ||
|
|
142
|
-
option.value.toLowerCase().includes(query),
|
|
143
|
-
);
|
|
144
|
-
}, [options, searchQuery]);
|
|
145
|
-
|
|
146
|
-
if (!open) return null;
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<div 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">
|
|
150
|
-
{searchable && (
|
|
151
|
-
<div className="border-b border-border p-2">
|
|
152
|
-
<Input
|
|
153
|
-
type="text"
|
|
154
|
-
placeholder={searchablePlaceholder}
|
|
155
|
-
value={searchQuery}
|
|
156
|
-
onChange={(e) => setSearchQuery(e.target.value)}
|
|
157
|
-
icon={<Icon name="Search" />}
|
|
158
|
-
aria-label={searchablePlaceholder}
|
|
159
|
-
/>
|
|
160
|
-
</div>
|
|
161
|
-
)}
|
|
162
|
-
<div className="overflow-y-auto">
|
|
163
|
-
{filteredOptions.length === 0 ? (
|
|
164
|
-
<div className="px-3 py-2 text-sm text-muted-foreground">
|
|
165
|
-
{emptyMessage}
|
|
166
|
-
</div>
|
|
167
|
-
) : (
|
|
168
|
-
filteredOptions.map((option) => {
|
|
169
|
-
const isSelected = selected.has(option.value);
|
|
170
|
-
return (
|
|
171
|
-
<div
|
|
172
|
-
key={option.value}
|
|
173
|
-
className="flex items-center justify-between px-3 py-2 text-sm text-foreground hover:bg-surface-muted cursor-pointer [&_svg]:size-[var(--icon-small)] [&_svg]:shrink-0"
|
|
174
|
-
onClick={() => onToggle(option.value)}
|
|
175
|
-
>
|
|
176
|
-
<span>{option.label}</span>
|
|
177
|
-
{multiple ? (
|
|
178
|
-
<div
|
|
179
|
-
className={`flex h-4 w-4 items-center justify-center rounded-sm border [&_svg]:size-3 [&_svg]:text-current ${isSelected ? "border-primary bg-primary text-primary-foreground" : "border-muted-foreground"}`}
|
|
180
|
-
>
|
|
181
|
-
{isSelected && <Icon name="Check" />}
|
|
182
|
-
</div>
|
|
183
|
-
) : isSelected ? (
|
|
184
|
-
<Icon name="Check" variant="primary" />
|
|
185
|
-
) : null}
|
|
186
|
-
</div>
|
|
187
|
-
);
|
|
188
|
-
})
|
|
189
|
-
)}
|
|
190
|
-
</div>
|
|
191
|
-
</div>
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Single-select dropdown component.
|
|
197
|
-
* Follows Design System rules:
|
|
198
|
-
* - Displays selected value with a chevron indicator.
|
|
199
|
-
* - Opens a dropdown directly below the field on click.
|
|
200
|
-
* - Each option is on its own row with consistent alignment.
|
|
201
|
-
* - Selected option is marked with a check icon.
|
|
202
|
-
*/
|
|
203
|
-
export function Select({
|
|
204
|
-
label,
|
|
205
|
-
options,
|
|
206
|
-
value,
|
|
207
|
-
onChange,
|
|
208
|
-
placeholder = "Sélectionner...",
|
|
209
|
-
emptyMessage,
|
|
210
|
-
}: SelectProps) {
|
|
211
|
-
const { open, setOpen, rootRef } = useDismissibleOpen();
|
|
212
|
-
|
|
213
|
-
const selectedOption = useMemo(
|
|
214
|
-
() => options.find((opt) => opt.value === value),
|
|
215
|
-
[options, value],
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
const handleSelect = (optionValue: string) => {
|
|
219
|
-
onChange(optionValue);
|
|
220
|
-
setOpen(false);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
return (
|
|
224
|
-
<div ref={rootRef} className="relative w-full">
|
|
225
|
-
{label ? <label className={LABEL_CLASS}>{label}</label> : null}
|
|
226
|
-
<SelectTrigger open={open} onOpenChange={setOpen}>
|
|
227
|
-
<span className={selectedOption ? "text-foreground" : "text-muted-foreground"}>
|
|
228
|
-
{selectedOption ? selectedOption.label : placeholder}
|
|
229
|
-
</span>
|
|
230
|
-
</SelectTrigger>
|
|
231
|
-
<SelectDropdown
|
|
232
|
-
open={open}
|
|
233
|
-
options={options}
|
|
234
|
-
selected={new Set(value ? [value] : [])}
|
|
235
|
-
multiple={false}
|
|
236
|
-
searchable={false}
|
|
237
|
-
onToggle={handleSelect}
|
|
238
|
-
emptyMessage={emptyMessage}
|
|
239
|
-
/>
|
|
240
|
-
</div>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
interface MultiSelectValueProps {
|
|
245
|
-
options: SelectOption[];
|
|
246
|
-
values: string[];
|
|
247
|
-
placeholder?: string;
|
|
248
|
-
maxVisibleChips: number;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Contenu du champ multi-sélection : chips des options choisies jusqu'à
|
|
253
|
-
* `maxVisibleChips`, puis un indicateur « +N » (info-bulle = liste des
|
|
254
|
-
* autres sélectionnées) lorsqu'il y en a davantage.
|
|
255
|
-
*/
|
|
256
|
-
function MultiSelectValue({
|
|
257
|
-
options,
|
|
258
|
-
values,
|
|
259
|
-
placeholder,
|
|
260
|
-
maxVisibleChips,
|
|
261
|
-
}: MultiSelectValueProps) {
|
|
262
|
-
if (values.length === 0) {
|
|
263
|
-
return <span className="text-muted-foreground">{placeholder}</span>;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const selectedOptions = values
|
|
267
|
-
.map((value) => options.find((option) => option.value === value))
|
|
268
|
-
.filter((option): option is SelectOption => Boolean(option));
|
|
269
|
-
const visibleOptions = selectedOptions.slice(0, Math.max(1, maxVisibleChips));
|
|
270
|
-
const hiddenOptions = selectedOptions.slice(visibleOptions.length);
|
|
271
|
-
|
|
272
|
-
return (
|
|
273
|
-
<span className="flex min-w-0 flex-1 flex-wrap items-center gap-1">
|
|
274
|
-
{visibleOptions.map((option) => (
|
|
275
|
-
<Badge key={option.value} variant="primary">
|
|
276
|
-
{option.label}
|
|
277
|
-
</Badge>
|
|
278
|
-
))}
|
|
279
|
-
{hiddenOptions.length > 0 && (
|
|
280
|
-
<span
|
|
281
|
-
title={`Aussi sélectionné : ${hiddenOptions
|
|
282
|
-
.map((option) => option.label)
|
|
283
|
-
.join(", ")}`}
|
|
284
|
-
className="inline-flex"
|
|
285
|
-
>
|
|
286
|
-
<Badge variant="default">+{hiddenOptions.length}</Badge>
|
|
287
|
-
</span>
|
|
288
|
-
)}
|
|
289
|
-
</span>
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Multi-select dropdown component.
|
|
295
|
-
* Follows Design System rules:
|
|
296
|
-
* - Same visual language as single select.
|
|
297
|
-
* - Each option has a checkbox-style selector on the left.
|
|
298
|
-
* - Empty when unselected, checked when selected.
|
|
299
|
-
* - Multiple options can be selected simultaneously.
|
|
300
|
-
*/
|
|
301
|
-
export function MultiSelect({
|
|
302
|
-
label,
|
|
303
|
-
options,
|
|
304
|
-
values,
|
|
305
|
-
onChange,
|
|
306
|
-
placeholder = "Sélectionner...",
|
|
307
|
-
emptyMessage,
|
|
308
|
-
maxVisibleChips = 2,
|
|
309
|
-
}: MultiSelectProps) {
|
|
310
|
-
const { open, setOpen, rootRef } = useDismissibleOpen();
|
|
311
|
-
|
|
312
|
-
const handleToggle = (optionValue: string) => {
|
|
313
|
-
const newValues = values.includes(optionValue)
|
|
314
|
-
? values.filter((v) => v !== optionValue)
|
|
315
|
-
: [...values, optionValue];
|
|
316
|
-
onChange(newValues);
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
return (
|
|
320
|
-
<div ref={rootRef} className="relative w-full">
|
|
321
|
-
{label ? <label className={LABEL_CLASS}>{label}</label> : null}
|
|
322
|
-
<SelectTrigger open={open} onOpenChange={setOpen}>
|
|
323
|
-
<MultiSelectValue
|
|
324
|
-
options={options}
|
|
325
|
-
values={values}
|
|
326
|
-
placeholder={placeholder}
|
|
327
|
-
maxVisibleChips={maxVisibleChips}
|
|
328
|
-
/>
|
|
329
|
-
</SelectTrigger>
|
|
330
|
-
<SelectDropdown
|
|
331
|
-
open={open}
|
|
332
|
-
options={options}
|
|
333
|
-
selected={new Set(values)}
|
|
334
|
-
multiple={true}
|
|
335
|
-
searchable={false}
|
|
336
|
-
onToggle={handleToggle}
|
|
337
|
-
emptyMessage={emptyMessage}
|
|
338
|
-
/>
|
|
339
|
-
</div>
|
|
340
|
-
);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Single-select dropdown with search.
|
|
345
|
-
* For long lists where searching is helpful.
|
|
346
|
-
*/
|
|
347
|
-
export function SelectWithSearch({
|
|
348
|
-
label,
|
|
349
|
-
options,
|
|
350
|
-
value,
|
|
351
|
-
onChange,
|
|
352
|
-
placeholder = "Sélectionner...",
|
|
353
|
-
emptyMessage,
|
|
354
|
-
}: SelectProps) {
|
|
355
|
-
const { open, setOpen, rootRef } = useDismissibleOpen();
|
|
356
|
-
|
|
357
|
-
const selectedOption = useMemo(
|
|
358
|
-
() => options.find((opt) => opt.value === value),
|
|
359
|
-
[options, value],
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
const handleSelect = (optionValue: string) => {
|
|
363
|
-
onChange(optionValue);
|
|
364
|
-
setOpen(false);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
return (
|
|
368
|
-
<div ref={rootRef} className="relative w-full">
|
|
369
|
-
{label ? <label className={LABEL_CLASS}>{label}</label> : null}
|
|
370
|
-
<SelectTrigger open={open} onOpenChange={setOpen}>
|
|
371
|
-
<span className={selectedOption ? "text-foreground" : "text-muted-foreground"}>
|
|
372
|
-
{selectedOption ? selectedOption.label : placeholder}
|
|
373
|
-
</span>
|
|
374
|
-
</SelectTrigger>
|
|
375
|
-
<SelectDropdown
|
|
376
|
-
open={open}
|
|
377
|
-
options={options}
|
|
378
|
-
selected={new Set(value ? [value] : [])}
|
|
379
|
-
multiple={false}
|
|
380
|
-
searchable={true}
|
|
381
|
-
onToggle={handleSelect}
|
|
382
|
-
emptyMessage={emptyMessage}
|
|
383
|
-
/>
|
|
384
|
-
</div>
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* Multi-select dropdown with search.
|
|
390
|
-
* For long lists where searching and multiple selection is needed.
|
|
391
|
-
*/
|
|
392
|
-
export function MultiSelectWithSearch({
|
|
393
|
-
label,
|
|
394
|
-
options,
|
|
395
|
-
values,
|
|
396
|
-
onChange,
|
|
397
|
-
placeholder = "Sélectionner...",
|
|
398
|
-
emptyMessage,
|
|
399
|
-
maxVisibleChips = 2,
|
|
400
|
-
}: MultiSelectProps) {
|
|
401
|
-
const { open, setOpen, rootRef } = useDismissibleOpen();
|
|
402
|
-
|
|
403
|
-
const handleToggle = (optionValue: string) => {
|
|
404
|
-
const newValues = values.includes(optionValue)
|
|
405
|
-
? values.filter((v) => v !== optionValue)
|
|
406
|
-
: [...values, optionValue];
|
|
407
|
-
onChange(newValues);
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
return (
|
|
411
|
-
<div ref={rootRef} className="relative w-full">
|
|
412
|
-
{label ? <label className={LABEL_CLASS}>{label}</label> : null}
|
|
413
|
-
<SelectTrigger open={open} onOpenChange={setOpen}>
|
|
414
|
-
<MultiSelectValue
|
|
415
|
-
options={options}
|
|
416
|
-
values={values}
|
|
417
|
-
placeholder={placeholder}
|
|
418
|
-
maxVisibleChips={maxVisibleChips}
|
|
419
|
-
/>
|
|
420
|
-
</SelectTrigger>
|
|
421
|
-
<SelectDropdown
|
|
422
|
-
open={open}
|
|
423
|
-
options={options}
|
|
424
|
-
selected={new Set(values)}
|
|
425
|
-
multiple={true}
|
|
426
|
-
searchable={true}
|
|
427
|
-
onToggle={handleToggle}
|
|
428
|
-
emptyMessage={emptyMessage}
|
|
429
|
-
/>
|
|
430
|
-
</div>
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Filter-style multi-select dropdown.
|
|
436
|
-
* Alias for MultiSelectWithSearch optimized for table column filtering.
|
|
437
|
-
*/
|
|
438
|
-
export function SelectFilter({
|
|
439
|
-
label,
|
|
440
|
-
options,
|
|
441
|
-
values,
|
|
442
|
-
onChange,
|
|
443
|
-
placeholder = "Filtrer...",
|
|
444
|
-
emptyMessage,
|
|
445
|
-
maxVisibleChips,
|
|
446
|
-
}: MultiSelectProps) {
|
|
447
|
-
return (
|
|
448
|
-
<MultiSelectWithSearch
|
|
449
|
-
label={label}
|
|
450
|
-
options={options}
|
|
451
|
-
values={values}
|
|
452
|
-
onChange={onChange}
|
|
453
|
-
placeholder={placeholder}
|
|
454
|
-
emptyMessage={emptyMessage}
|
|
455
|
-
maxVisibleChips={maxVisibleChips}
|
|
456
|
-
/>
|
|
457
|
-
);
|
|
458
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import Icon from "./icon";
|
|
2
|
-
|
|
3
|
-
export type StepperStepState = "done" | "current" | "upcoming" | "rejected";
|
|
4
|
-
|
|
5
|
-
const CIRCLE_CLASS: Record<StepperStepState, string> = {
|
|
6
|
-
done: "bg-success text-white",
|
|
7
|
-
current: "bg-primary text-white ring-2 ring-primary ring-offset-2",
|
|
8
|
-
upcoming: "bg-surface-muted text-muted-foreground",
|
|
9
|
-
rejected: "bg-danger text-white ring-2 ring-danger ring-offset-2",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const LABEL_CLASS: Record<StepperStepState, string> = {
|
|
13
|
-
done: "text-success-foreground",
|
|
14
|
-
current: "text-foreground",
|
|
15
|
-
upcoming: "text-muted-foreground",
|
|
16
|
-
rejected: "text-danger-foreground",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const STATE_NAME: Record<StepperStepState, string> = {
|
|
20
|
-
done: "terminée",
|
|
21
|
-
current: "étape actuelle",
|
|
22
|
-
upcoming: "à venir",
|
|
23
|
-
rejected: "rejetée",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function stepState(
|
|
27
|
-
index: number,
|
|
28
|
-
currentIndex: number,
|
|
29
|
-
complete: boolean,
|
|
30
|
-
rejected: boolean,
|
|
31
|
-
): StepperStepState {
|
|
32
|
-
if (complete || index < currentIndex) return "done";
|
|
33
|
-
if (index !== currentIndex) return "upcoming";
|
|
34
|
-
return rejected ? "rejected" : "current";
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Progression visuelle d'un cycle (brouillon → … → terminé).
|
|
39
|
-
* Réutilisée par les dossiers à traiter étape par étape.
|
|
40
|
-
*/
|
|
41
|
-
export default function Stepper({
|
|
42
|
-
steps,
|
|
43
|
-
currentIndex,
|
|
44
|
-
complete = false,
|
|
45
|
-
rejected = false,
|
|
46
|
-
label,
|
|
47
|
-
}: {
|
|
48
|
-
steps: readonly string[];
|
|
49
|
-
currentIndex: number;
|
|
50
|
-
complete?: boolean;
|
|
51
|
-
rejected?: boolean;
|
|
52
|
-
label: string;
|
|
53
|
-
}) {
|
|
54
|
-
return (
|
|
55
|
-
<ol
|
|
56
|
-
aria-label={label}
|
|
57
|
-
className="flex flex-col gap-control md:flex-row md:items-center"
|
|
58
|
-
>
|
|
59
|
-
{steps.map((step, index) => {
|
|
60
|
-
const visual = stepState(index, currentIndex, complete, rejected);
|
|
61
|
-
const last = index === steps.length - 1;
|
|
62
|
-
return (
|
|
63
|
-
<li
|
|
64
|
-
key={step}
|
|
65
|
-
className="flex min-w-0 items-center gap-inline md:flex-1"
|
|
66
|
-
aria-label={`${step}, ${STATE_NAME[visual]}`}
|
|
67
|
-
aria-current={
|
|
68
|
-
visual === "current" || visual === "rejected" ? "step" : undefined
|
|
69
|
-
}
|
|
70
|
-
>
|
|
71
|
-
<span
|
|
72
|
-
className={`grid size-8 shrink-0 place-items-center rounded-full text-label ${CIRCLE_CLASS[visual]}`}
|
|
73
|
-
>
|
|
74
|
-
{visual === "done" ? (
|
|
75
|
-
<Icon name="Check" variant="white" size="small" aria-hidden="true" />
|
|
76
|
-
) : (
|
|
77
|
-
index + 1
|
|
78
|
-
)}
|
|
79
|
-
</span>
|
|
80
|
-
<span className={`min-w-0 text-label ${LABEL_CLASS[visual]}`}>
|
|
81
|
-
{step}
|
|
82
|
-
</span>
|
|
83
|
-
{last ? null : (
|
|
84
|
-
<span
|
|
85
|
-
className={`hidden h-px flex-1 md:block ${
|
|
86
|
-
visual === "done" ? "bg-success" : "bg-border"
|
|
87
|
-
}`}
|
|
88
|
-
aria-hidden="true"
|
|
89
|
-
/>
|
|
90
|
-
)}
|
|
91
|
-
</li>
|
|
92
|
-
);
|
|
93
|
-
})}
|
|
94
|
-
</ol>
|
|
95
|
-
);
|
|
96
|
-
}
|
package/components/ui/tab.tsx
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState, type ReactNode } from "react";
|
|
4
|
-
import ClickableButton from "./button";
|
|
5
|
-
|
|
6
|
-
export interface Tab {
|
|
7
|
-
value: string;
|
|
8
|
-
label: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface TabsProps {
|
|
12
|
-
tabs: Tab[];
|
|
13
|
-
defaultValue?: string;
|
|
14
|
-
onChange?: (value: string) => void;
|
|
15
|
-
children?: (activeTab: string) => ReactNode;
|
|
16
|
-
/**
|
|
17
|
-
* Classes for the panel wrapper.
|
|
18
|
-
* For Dashboard & Detail pages (see `knowledge-base/rules/architecture/layout.mdc`),
|
|
19
|
-
* the panel should fill the main scroll container without creating its own
|
|
20
|
-
* page-level scroll. At `md+`, internal component scrolling is allowed
|
|
21
|
-
* when content requires it — rely on component-internal `overflow-auto`
|
|
22
|
-
* (e.g. InfoCard `scrollable`, UserTable) rather than on the panel wrapper.
|
|
23
|
-
* Below `md`, page-level vertical scrolling is allowed and internal component
|
|
24
|
-
* scrolling MUST NOT be used — so do NOT put `overflow-y-auto` here; let the
|
|
25
|
-
* page scroll keep reflowed content reachable.
|
|
26
|
-
*/
|
|
27
|
-
panelClassName?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Tabbed pages navigation component.
|
|
32
|
-
* Follows Design System rules:
|
|
33
|
-
* - Tabs are presented on a single row.
|
|
34
|
-
* - Only one tab can be active at a time.
|
|
35
|
-
* - The active tab is clearly distinguished from inactive ones.
|
|
36
|
-
* - Clicking a tab activates it immediately and shows its associated content.
|
|
37
|
-
*/
|
|
38
|
-
export default function Tabs({
|
|
39
|
-
tabs,
|
|
40
|
-
defaultValue,
|
|
41
|
-
onChange,
|
|
42
|
-
children,
|
|
43
|
-
panelClassName = "mt-component",
|
|
44
|
-
}: TabsProps) {
|
|
45
|
-
const [activeTab, setActiveTab] = useState(
|
|
46
|
-
defaultValue ?? tabs[0]?.value,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const handleSelect = (value: string) => {
|
|
50
|
-
setActiveTab(value);
|
|
51
|
-
onChange?.(value);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<div className="flex h-full min-h-0 w-full flex-col">
|
|
56
|
-
<div
|
|
57
|
-
role="tablist"
|
|
58
|
-
className="inline-flex max-w-full items-center gap-micro overflow-x-auto rounded-medium bg-surface-muted p-micro"
|
|
59
|
-
>
|
|
60
|
-
{tabs.map((tab) => {
|
|
61
|
-
const isActive = activeTab === tab.value;
|
|
62
|
-
return (
|
|
63
|
-
<ClickableButton
|
|
64
|
-
key={tab.value}
|
|
65
|
-
type="button"
|
|
66
|
-
variant="bare"
|
|
67
|
-
role="tab"
|
|
68
|
-
aria-selected={isActive}
|
|
69
|
-
aria-current={isActive ? "page" : undefined}
|
|
70
|
-
onClick={() => handleSelect(tab.value)}
|
|
71
|
-
className={`whitespace-nowrap rounded-small px-component py-inline text-body-medium focus-visible:ring-primary ${
|
|
72
|
-
isActive
|
|
73
|
-
? "bg-surface text-primary shadow-sm"
|
|
74
|
-
: "bg-transparent text-muted-foreground hover:text-foreground"
|
|
75
|
-
}`}
|
|
76
|
-
>
|
|
77
|
-
{tab.label}
|
|
78
|
-
</ClickableButton>
|
|
79
|
-
);
|
|
80
|
-
})}
|
|
81
|
-
</div>
|
|
82
|
-
{children && <div className={panelClassName}>{children(activeTab!)}</div>}
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
}
|