@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.
Files changed (52) hide show
  1. package/dist/accordion.d.ts +24 -0
  2. package/dist/accordion.d.ts.map +1 -0
  3. package/dist/accordion.js +30 -0
  4. package/dist/badge.d.ts +10 -0
  5. package/dist/badge.d.ts.map +1 -0
  6. package/dist/badge.js +14 -0
  7. package/dist/button.d.ts +21 -0
  8. package/dist/button.d.ts.map +1 -0
  9. package/dist/button.js +27 -0
  10. package/dist/icon.d.ts +21 -0
  11. package/dist/icon.d.ts.map +1 -0
  12. package/dist/icon.js +24 -0
  13. package/{components/ui/index.ts → dist/index.d.ts} +24 -28
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +12 -0
  16. package/dist/input.d.ts +41 -0
  17. package/dist/input.d.ts.map +1 -0
  18. package/dist/input.js +105 -0
  19. package/dist/loader.d.ts +26 -0
  20. package/dist/loader.d.ts.map +1 -0
  21. package/dist/loader.js +20 -0
  22. package/dist/metric-bar.d.ts +11 -0
  23. package/dist/metric-bar.d.ts.map +1 -0
  24. package/dist/metric-bar.js +19 -0
  25. package/dist/modal.d.ts +19 -0
  26. package/dist/modal.d.ts.map +1 -0
  27. package/dist/modal.js +88 -0
  28. package/dist/select.d.ts +59 -0
  29. package/dist/select.d.ts.map +1 -0
  30. package/dist/select.js +153 -0
  31. package/dist/stepper.d.ts +13 -0
  32. package/dist/stepper.d.ts.map +1 -0
  33. package/dist/stepper.js +38 -0
  34. package/dist/tab.d.ts +34 -0
  35. package/dist/tab.d.ts.map +1 -0
  36. package/dist/tab.js +25 -0
  37. package/dist/table.d.ts +57 -0
  38. package/dist/table.d.ts.map +1 -0
  39. package/dist/table.js +180 -0
  40. package/package.json +27 -3
  41. package/components/ui/action-stack.tsx +0 -42
  42. package/components/ui/badge.tsx +0 -43
  43. package/components/ui/button.tsx +0 -104
  44. package/components/ui/icon.tsx +0 -78
  45. package/components/ui/input.tsx +0 -376
  46. package/components/ui/loader.tsx +0 -78
  47. package/components/ui/metric-bar.tsx +0 -49
  48. package/components/ui/modal.tsx +0 -177
  49. package/components/ui/select.tsx +0 -458
  50. package/components/ui/stepper.tsx +0 -96
  51. package/components/ui/tab.tsx +0 -85
  52. package/components/ui/user-table.tsx +0 -806
package/dist/modal.js ADDED
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useRef, } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import Icon from "./icon";
6
+ import ClickableButton from "./button";
7
+ /** Selector matching every focusable element the dialog can own. */
8
+ const FOCUSABLE_SELECTOR = [
9
+ "a[href]",
10
+ "button:not([disabled])",
11
+ "textarea:not([disabled])",
12
+ "input:not([disabled])",
13
+ "select:not([disabled])",
14
+ '[tabindex]:not([tabindex="-1"])',
15
+ ].join(", ");
16
+ /** Returns the focusable elements owned by a given dialog panel. */
17
+ function getFocusables(panel) {
18
+ return panel
19
+ ? Array.from(panel.querySelectorAll(FOCUSABLE_SELECTOR))
20
+ : [];
21
+ }
22
+ export default function Modal({ open, title, children, onClose, footer, primaryAction, secondaryAction, }) {
23
+ // Unique, stable id used to bind the dialog label to its title.
24
+ const titleId = useId();
25
+ const panelRef = useRef(null);
26
+ // Element that had focus before the modal opened, restored on close.
27
+ const previouslyFocusedRef = useRef(null);
28
+ // Lock body scroll while open.
29
+ useEffect(() => {
30
+ if (!open)
31
+ return;
32
+ const previousOverflow = document.body.style.overflow;
33
+ document.body.style.overflow = "hidden";
34
+ return () => {
35
+ document.body.style.overflow = previousOverflow;
36
+ };
37
+ }, [open]);
38
+ // Close on Escape.
39
+ useEffect(() => {
40
+ if (!open)
41
+ return;
42
+ const handleKeyDown = (event) => {
43
+ if (event.key === "Escape")
44
+ onClose();
45
+ };
46
+ document.addEventListener("keydown", handleKeyDown);
47
+ return () => document.removeEventListener("keydown", handleKeyDown);
48
+ }, [open, onClose]);
49
+ // Move focus into the dialog on open and restore it on close.
50
+ useEffect(() => {
51
+ if (!open)
52
+ return;
53
+ previouslyFocusedRef.current =
54
+ document.activeElement instanceof HTMLElement
55
+ ? document.activeElement
56
+ : null;
57
+ const focusables = getFocusables(panelRef.current);
58
+ (focusables[0] ?? panelRef.current)?.focus();
59
+ return () => {
60
+ previouslyFocusedRef.current?.focus?.();
61
+ previouslyFocusedRef.current = null;
62
+ };
63
+ }, [open]);
64
+ if (!open)
65
+ return null;
66
+ // Keep Tab / Shift+Tab cycling within the dialog panel.
67
+ const handlePanelKeyDown = (event) => {
68
+ if (event.key !== "Tab")
69
+ return;
70
+ const focusables = getFocusables(panelRef.current);
71
+ if (focusables.length === 0)
72
+ return;
73
+ const first = focusables[0];
74
+ const last = focusables[focusables.length - 1];
75
+ const active = document.activeElement;
76
+ if (!(event.shiftKey) &&
77
+ (!panelRef.current?.contains(active) || active === last)) {
78
+ event.preventDefault();
79
+ first.focus();
80
+ }
81
+ else if (event.shiftKey &&
82
+ (!panelRef.current?.contains(active) || active === first)) {
83
+ event.preventDefault();
84
+ last.focus();
85
+ }
86
+ };
87
+ return createPortal(_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, onClick: onClose, children: _jsxs("div", { ref: panelRef, className: "flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-large border border-border bg-surface shadow-lg", 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 hover:bg-surface-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary [&_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
+ }
@@ -0,0 +1,59 @@
1
+ /** Public option shape shared by every selection variant. */
2
+ export interface SelectOption {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ interface BaseSelectProps {
7
+ label?: string;
8
+ options: SelectOption[];
9
+ placeholder?: string;
10
+ emptyMessage?: string;
11
+ }
12
+ interface SelectProps extends BaseSelectProps {
13
+ value: string;
14
+ onChange: (value: string) => void;
15
+ }
16
+ interface MultiSelectProps extends BaseSelectProps {
17
+ values: string[];
18
+ onChange: (values: string[]) => void;
19
+ /**
20
+ * Nombre maximal de chips d'options sélectionnées affichées dans le champ ;
21
+ * au-delà, un indicateur « +N » signale les autres (info-bulle = liste).
22
+ */
23
+ maxVisibleChips?: number;
24
+ }
25
+ /**
26
+ * Single-select dropdown component.
27
+ * Follows Design System rules:
28
+ * - Displays selected value with a chevron indicator.
29
+ * - Opens a dropdown directly below the field on click.
30
+ * - Each option is on its own row with consistent alignment.
31
+ * - Selected option is marked with a check icon.
32
+ */
33
+ export declare function Select({ label, options, value, onChange, placeholder, emptyMessage, }: SelectProps): import("react").JSX.Element;
34
+ /**
35
+ * Multi-select dropdown component.
36
+ * Follows Design System rules:
37
+ * - Same visual language as single select.
38
+ * - Each option has a checkbox-style selector on the left.
39
+ * - Empty when unselected, checked when selected.
40
+ * - Multiple options can be selected simultaneously.
41
+ */
42
+ export declare function MultiSelect({ label, options, values, onChange, placeholder, emptyMessage, maxVisibleChips, }: MultiSelectProps): import("react").JSX.Element;
43
+ /**
44
+ * Single-select dropdown with search.
45
+ * For long lists where searching is helpful.
46
+ */
47
+ export declare function SelectWithSearch({ label, options, value, onChange, placeholder, emptyMessage, }: SelectProps): import("react").JSX.Element;
48
+ /**
49
+ * Multi-select dropdown with search.
50
+ * For long lists where searching and multiple selection is needed.
51
+ */
52
+ export declare function MultiSelectWithSearch({ label, options, values, onChange, placeholder, emptyMessage, maxVisibleChips, }: MultiSelectProps): import("react").JSX.Element;
53
+ /**
54
+ * Filter-style multi-select dropdown.
55
+ * Alias for MultiSelectWithSearch optimized for table column filtering.
56
+ */
57
+ export declare function SelectFilter({ label, options, values, onChange, placeholder, emptyMessage, maxVisibleChips, }: MultiSelectProps): import("react").JSX.Element;
58
+ export {};
59
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +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;AAiKD;;;;;;;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 ADDED
@@ -0,0 +1,153 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from "react";
4
+ import Badge from "./badge";
5
+ import Icon from "./icon";
6
+ import Input from "./input";
7
+ const LABEL_CLASS = "mb-inline block text-label text-muted-foreground";
8
+ function useDismissibleOpen() {
9
+ const [open, setOpen] = useState(false);
10
+ const rootRef = useRef(null);
11
+ useEffect(() => {
12
+ if (!open)
13
+ return;
14
+ const close = () => setOpen(false);
15
+ const focusTrigger = () => {
16
+ rootRef.current
17
+ ?.querySelector("button[aria-haspopup]")
18
+ ?.focus();
19
+ };
20
+ const isOutside = (target) => target instanceof Node && !rootRef.current?.contains(target);
21
+ const onPointerDown = (event) => {
22
+ if (isOutside(event.target))
23
+ close();
24
+ };
25
+ const onKeyDown = (event) => {
26
+ if (event.key !== "Escape")
27
+ return;
28
+ event.preventDefault();
29
+ event.stopPropagation();
30
+ focusTrigger();
31
+ close();
32
+ };
33
+ const onFocusIn = (event) => {
34
+ if (isOutside(event.target))
35
+ close();
36
+ };
37
+ document.addEventListener("pointerdown", onPointerDown, true);
38
+ document.addEventListener("keydown", onKeyDown, true);
39
+ document.addEventListener("focusin", onFocusIn);
40
+ return () => {
41
+ document.removeEventListener("pointerdown", onPointerDown, true);
42
+ document.removeEventListener("keydown", onKeyDown, true);
43
+ document.removeEventListener("focusin", onFocusIn);
44
+ };
45
+ }, [open]);
46
+ return { open, setOpen, rootRef };
47
+ }
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-150 ${open ? "rotate-180" : ""}` })] }));
50
+ }
51
+ function SelectDropdown({ open, options, selected, multiple, searchable, searchablePlaceholder = "Rechercher...", onToggle, emptyMessage = "Aucun résultat trouvé.", }) {
52
+ const [searchQuery, setSearchQuery] = useState("");
53
+ const filteredOptions = useMemo(() => {
54
+ if (!searchQuery.trim())
55
+ return options;
56
+ const query = searchQuery.toLowerCase();
57
+ return options.filter((option) => option.label.toLowerCase().includes(query) ||
58
+ option.value.toLowerCase().includes(query));
59
+ }, [options, searchQuery]);
60
+ if (!open)
61
+ return null;
62
+ return (_jsxs("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", 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
+ 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 cursor-pointer [&_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 [&_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
+ })) })] }));
66
+ }
67
+ /**
68
+ * Single-select dropdown component.
69
+ * Follows Design System rules:
70
+ * - Displays selected value with a chevron indicator.
71
+ * - Opens a dropdown directly below the field on click.
72
+ * - Each option is on its own row with consistent alignment.
73
+ * - Selected option is marked with a check icon.
74
+ */
75
+ export function Select({ label, options, value, onChange, placeholder = "Sélectionner...", emptyMessage, }) {
76
+ const { open, setOpen, rootRef } = useDismissibleOpen();
77
+ const selectedOption = useMemo(() => options.find((opt) => opt.value === value), [options, value]);
78
+ const handleSelect = (optionValue) => {
79
+ onChange(optionValue);
80
+ setOpen(false);
81
+ };
82
+ return (_jsxs("div", { ref: rootRef, className: "relative w-full", children: [label ? _jsx("label", { className: LABEL_CLASS, children: label }) : null, _jsx(SelectTrigger, { open: open, onOpenChange: setOpen, children: _jsx("span", { className: selectedOption ? "text-foreground" : "text-muted-foreground", children: selectedOption ? selectedOption.label : placeholder }) }), _jsx(SelectDropdown, { open: open, options: options, selected: new Set(value ? [value] : []), multiple: false, searchable: false, onToggle: handleSelect, emptyMessage: emptyMessage })] }));
83
+ }
84
+ /**
85
+ * Contenu du champ multi-sélection : chips des options choisies jusqu'à
86
+ * `maxVisibleChips`, puis un indicateur « +N » (info-bulle = liste des
87
+ * autres sélectionnées) lorsqu'il y en a davantage.
88
+ */
89
+ function MultiSelectValue({ options, values, placeholder, maxVisibleChips, }) {
90
+ if (values.length === 0) {
91
+ return _jsx("span", { className: "text-muted-foreground", children: placeholder });
92
+ }
93
+ const selectedOptions = values
94
+ .map((value) => options.find((option) => option.value === value))
95
+ .filter((option) => Boolean(option));
96
+ const visibleOptions = selectedOptions.slice(0, Math.max(1, maxVisibleChips));
97
+ const hiddenOptions = selectedOptions.slice(visibleOptions.length);
98
+ return (_jsxs("span", { className: "flex min-w-0 flex-1 flex-wrap items-center gap-1", children: [visibleOptions.map((option) => (_jsx(Badge, { variant: "primary", children: option.label }, option.value))), hiddenOptions.length > 0 && (_jsx("span", { title: `Aussi sélectionné : ${hiddenOptions
99
+ .map((option) => option.label)
100
+ .join(", ")}`, className: "inline-flex", children: _jsxs(Badge, { variant: "default", children: ["+", hiddenOptions.length] }) }))] }));
101
+ }
102
+ /**
103
+ * Multi-select dropdown component.
104
+ * Follows Design System rules:
105
+ * - Same visual language as single select.
106
+ * - Each option has a checkbox-style selector on the left.
107
+ * - Empty when unselected, checked when selected.
108
+ * - Multiple options can be selected simultaneously.
109
+ */
110
+ export function MultiSelect({ label, options, values, onChange, placeholder = "Sélectionner...", emptyMessage, maxVisibleChips = 2, }) {
111
+ const { open, setOpen, rootRef } = useDismissibleOpen();
112
+ const handleToggle = (optionValue) => {
113
+ const newValues = values.includes(optionValue)
114
+ ? values.filter((v) => v !== optionValue)
115
+ : [...values, optionValue];
116
+ onChange(newValues);
117
+ };
118
+ return (_jsxs("div", { ref: rootRef, className: "relative w-full", children: [label ? _jsx("label", { className: LABEL_CLASS, children: label }) : null, _jsx(SelectTrigger, { open: open, onOpenChange: setOpen, children: _jsx(MultiSelectValue, { options: options, values: values, placeholder: placeholder, maxVisibleChips: maxVisibleChips }) }), _jsx(SelectDropdown, { open: open, options: options, selected: new Set(values), multiple: true, searchable: false, onToggle: handleToggle, emptyMessage: emptyMessage })] }));
119
+ }
120
+ /**
121
+ * Single-select dropdown with search.
122
+ * For long lists where searching is helpful.
123
+ */
124
+ export function SelectWithSearch({ label, options, value, onChange, placeholder = "Sélectionner...", emptyMessage, }) {
125
+ const { open, setOpen, rootRef } = useDismissibleOpen();
126
+ const selectedOption = useMemo(() => options.find((opt) => opt.value === value), [options, value]);
127
+ const handleSelect = (optionValue) => {
128
+ onChange(optionValue);
129
+ setOpen(false);
130
+ };
131
+ return (_jsxs("div", { ref: rootRef, className: "relative w-full", children: [label ? _jsx("label", { className: LABEL_CLASS, children: label }) : null, _jsx(SelectTrigger, { open: open, onOpenChange: setOpen, children: _jsx("span", { className: selectedOption ? "text-foreground" : "text-muted-foreground", children: selectedOption ? selectedOption.label : placeholder }) }), _jsx(SelectDropdown, { open: open, options: options, selected: new Set(value ? [value] : []), multiple: false, searchable: true, onToggle: handleSelect, emptyMessage: emptyMessage })] }));
132
+ }
133
+ /**
134
+ * Multi-select dropdown with search.
135
+ * For long lists where searching and multiple selection is needed.
136
+ */
137
+ export function MultiSelectWithSearch({ label, options, values, onChange, placeholder = "Sélectionner...", emptyMessage, maxVisibleChips = 2, }) {
138
+ const { open, setOpen, rootRef } = useDismissibleOpen();
139
+ const handleToggle = (optionValue) => {
140
+ const newValues = values.includes(optionValue)
141
+ ? values.filter((v) => v !== optionValue)
142
+ : [...values, optionValue];
143
+ onChange(newValues);
144
+ };
145
+ return (_jsxs("div", { ref: rootRef, className: "relative w-full", children: [label ? _jsx("label", { className: LABEL_CLASS, children: label }) : null, _jsx(SelectTrigger, { open: open, onOpenChange: setOpen, children: _jsx(MultiSelectValue, { options: options, values: values, placeholder: placeholder, maxVisibleChips: maxVisibleChips }) }), _jsx(SelectDropdown, { open: open, options: options, selected: new Set(values), multiple: true, searchable: true, onToggle: handleToggle, emptyMessage: emptyMessage })] }));
146
+ }
147
+ /**
148
+ * Filter-style multi-select dropdown.
149
+ * Alias for MultiSelectWithSearch optimized for table column filtering.
150
+ */
151
+ export function SelectFilter({ label, options, values, onChange, placeholder = "Filtrer...", emptyMessage, maxVisibleChips, }) {
152
+ return (_jsx(MultiSelectWithSearch, { label: label, options: options, values: values, onChange: onChange, placeholder: placeholder, emptyMessage: emptyMessage, maxVisibleChips: maxVisibleChips }));
153
+ }
@@ -0,0 +1,13 @@
1
+ export type StepperStepState = "done" | "current" | "upcoming" | "rejected";
2
+ /**
3
+ * Progression visuelle d'un cycle (brouillon → … → terminé).
4
+ * Réutilisée par les dossiers à traiter étape par étape.
5
+ */
6
+ export default function Stepper({ steps, currentIndex, complete, rejected, label, }: {
7
+ steps: readonly string[];
8
+ currentIndex: number;
9
+ complete?: boolean;
10
+ rejected?: boolean;
11
+ label: string;
12
+ }): import("react").JSX.Element;
13
+ //# sourceMappingURL=stepper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stepper.d.ts","sourceRoot":"","sources":["../components/ui/stepper.tsx"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAkC5E;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,KAAK,EACL,YAAY,EACZ,QAAgB,EAChB,QAAgB,EAChB,KAAK,GACN,EAAE;IACD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,+BA2CA"}
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Icon from "./icon";
3
+ const CIRCLE_CLASS = {
4
+ done: "bg-success text-white",
5
+ current: "bg-primary text-white ring-2 ring-primary ring-offset-2",
6
+ upcoming: "bg-surface-muted text-muted-foreground",
7
+ rejected: "bg-danger text-white ring-2 ring-danger ring-offset-2",
8
+ };
9
+ const LABEL_CLASS = {
10
+ done: "text-success-foreground",
11
+ current: "text-foreground",
12
+ upcoming: "text-muted-foreground",
13
+ rejected: "text-danger-foreground",
14
+ };
15
+ const STATE_NAME = {
16
+ done: "terminée",
17
+ current: "étape actuelle",
18
+ upcoming: "à venir",
19
+ rejected: "rejetée",
20
+ };
21
+ function stepState(index, currentIndex, complete, rejected) {
22
+ if (complete || index < currentIndex)
23
+ return "done";
24
+ if (index !== currentIndex)
25
+ return "upcoming";
26
+ return rejected ? "rejected" : "current";
27
+ }
28
+ /**
29
+ * Progression visuelle d'un cycle (brouillon → … → terminé).
30
+ * Réutilisée par les dossiers à traiter étape par étape.
31
+ */
32
+ export default function Stepper({ steps, currentIndex, complete = false, rejected = false, label, }) {
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
+ const visual = stepState(index, currentIndex, complete, rejected);
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));
37
+ }) }));
38
+ }
package/dist/tab.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { type ReactNode } from "react";
2
+ export interface Tab {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ interface TabsProps {
7
+ tabs: Tab[];
8
+ defaultValue?: string;
9
+ onChange?: (value: string) => void;
10
+ children?: (activeTab: string) => ReactNode;
11
+ /**
12
+ * Classes for the panel wrapper.
13
+ * For Dashboard & Detail pages (see `knowledge-base/rules/architecture/layout.mdc`),
14
+ * the panel should fill the main scroll container without creating its own
15
+ * page-level scroll. At `md+`, internal component scrolling is allowed
16
+ * when content requires it — rely on component-internal `overflow-auto`
17
+ * (e.g. InfoCard `scrollable`, Table) rather than on the panel wrapper.
18
+ * Below `md`, page-level vertical scrolling is allowed and internal component
19
+ * scrolling MUST NOT be used — so do NOT put `overflow-y-auto` here; let the
20
+ * page scroll keep reflowed content reachable.
21
+ */
22
+ panelClassName?: string;
23
+ }
24
+ /**
25
+ * Tabbed pages navigation component.
26
+ * Follows Design System rules:
27
+ * - Tabs are presented on a single row.
28
+ * - Only one tab can be active at a time.
29
+ * - The active tab is clearly distinguished from inactive ones.
30
+ * - Clicking a tab activates it immediately and shows its associated content.
31
+ */
32
+ export default function Tabs({ tabs, defaultValue, onChange, children, panelClassName, }: TabsProps): import("react").JSX.Element;
33
+ export {};
34
+ //# sourceMappingURL=tab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../components/ui/tab.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjD,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,SAAS;IACjB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC;IAC5C;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,cAA+B,GAChC,EAAE,SAAS,+BAyCX"}
package/dist/tab.js ADDED
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import ClickableButton from "./button";
5
+ /**
6
+ * Tabbed pages navigation component.
7
+ * Follows Design System rules:
8
+ * - Tabs are presented on a single row.
9
+ * - Only one tab can be active at a time.
10
+ * - The active tab is clearly distinguished from inactive ones.
11
+ * - Clicking a tab activates it immediately and shows its associated content.
12
+ */
13
+ export default function Tabs({ tabs, defaultValue, onChange, children, panelClassName = "mt-component", }) {
14
+ const [activeTab, setActiveTab] = useState(defaultValue ?? tabs[0]?.value);
15
+ const handleSelect = (value) => {
16
+ setActiveTab(value);
17
+ onChange?.(value);
18
+ };
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-medium bg-surface-muted p-micro", children: tabs.map((tab) => {
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-small px-component py-inline text-body-medium focus-visible:ring-primary ${isActive
22
+ ? "bg-surface text-primary shadow-sm"
23
+ : "bg-transparent text-muted-foreground hover:text-foreground"}`, children: tab.label }, tab.value));
24
+ }) }), children && _jsx("div", { className: panelClassName, children: children(activeTab) })] }));
25
+ }
@@ -0,0 +1,57 @@
1
+ import type { ReactNode } from "react";
2
+ import { type IconName } from "./icon";
3
+ export interface Column<T> {
4
+ key: keyof T;
5
+ label: string;
6
+ sortable?: boolean;
7
+ render?: (row: T) => ReactNode;
8
+ className?: string;
9
+ sortFn?: (a: T, b: T) => number;
10
+ }
11
+ /** Action entry displayed inside the card action menus (mobile card view). */
12
+ export interface CardAction {
13
+ label: string;
14
+ icon?: IconName;
15
+ /** Destructive action styling. */
16
+ danger?: boolean;
17
+ /** Pre-rendered node used as the whole menu item. Used when an action is
18
+ * derived from the table itself (e.g. the action column cell); it replaces
19
+ * `label`/`icon` and keeps its own interactivity. */
20
+ content?: ReactNode;
21
+ onSelect: () => void;
22
+ }
23
+ export interface TableCardActions<T> {
24
+ /** Actions globales du dropdown « Actions » — jamais recopiées sur une carte. */
25
+ table?: CardAction[];
26
+ selectAll?: CardAction;
27
+ /** Actions personnelles de la ligne. Plusieurs → dropdown ; une seule → affichage direct. */
28
+ row?: (row: T) => CardAction[];
29
+ }
30
+ export interface TableProps<T> {
31
+ columns: Column<T>[];
32
+ data: T[];
33
+ rowsPerPage?: number;
34
+ emptyMessage?: ReactNode;
35
+ getRowKey?: (row: T, index: number) => React.Key;
36
+ cardVisiblePairs?: number;
37
+ /** Déclare des actions — voir `TableCardActions`.
38
+ * `table` : dropdowns globaux « Actions » (pas recopiés sur chaque carte).
39
+ * `row` : actions personnelles. Une seule s’affiche telle quelle ; plusieurs
40
+ * vont dans un dropdown (colonne tableau et menu 3 points de la carte).
41
+ * Sans `row`, la dernière colonne sans libellé est réutilisée. */
42
+ cardActions?: TableCardActions<T>;
43
+ selectedKeys?: Set<React.Key> | null;
44
+ onToggleSelect?: ((rowKey: React.Key) => void) | null;
45
+ className?: string;
46
+ /** When true, the table is transposed: the first column shows row labels and
47
+ * each subsequent column represents one item from `data`. The first column
48
+ * header uses `transposeLabel` (or the first column's label), and each
49
+ * remaining column header is rendered via `transposeHeader` if provided. */
50
+ transpose?: boolean;
51
+ /** Label for the first column (row headers) when `transpose` is true. */
52
+ transposeLabel?: string;
53
+ /** Renders the header for each data column when `transpose` is true. */
54
+ transposeHeader?: (item: T) => React.ReactNode;
55
+ }
56
+ export default function Table<T extends object>({ columns, data, rowsPerPage, emptyMessage, getRowKey, cardVisiblePairs, cardActions, selectedKeys, onToggleSelect, className, transpose, transposeLabel, transposeHeader, }: TableProps<T>): import("react").JSX.Element;
57
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +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;IAChB,kCAAkC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;0DAEsD;IACtD,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAGD,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,iFAAiF;IACjF,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IAErB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,6FAA6F;IAC7F,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,UAAU,EAAE,CAAC;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,+BAmgBf"}