@dododog/ui 0.14.0 → 0.15.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 (73) hide show
  1. package/README.md +3 -3
  2. package/dist/{chunk-SZ3SV4SJ.mjs → chunk-4DHZ6MIL.mjs} +1 -1
  3. package/dist/chunk-5KOWMIWK.mjs +110 -0
  4. package/dist/{chunk-77WKG2D7.js → chunk-5UNG2O64.js} +38 -8
  5. package/dist/{chunk-MCF3EQTV.js → chunk-73BHQJW6.js} +13 -1
  6. package/dist/{chunk-U3XWNFHH.js → chunk-A3M3XQ35.js} +96 -29
  7. package/dist/chunk-BKM5VCUS.mjs +569 -0
  8. package/dist/{chunk-333YD5QI.mjs → chunk-EAATIFYL.mjs} +40 -6
  9. package/dist/{chunk-C4RZBOKH.js → chunk-EQPT6VZF.js} +1 -1
  10. package/dist/chunk-FLKEMER2.js +592 -0
  11. package/dist/{chunk-NBDPT3XQ.js → chunk-HH4X2JYO.js} +94 -15
  12. package/dist/{chunk-I4S3R6C6.js → chunk-JUB3NGJR.js} +51 -6
  13. package/dist/{chunk-GRG4USTC.mjs → chunk-JWOV5H6G.mjs} +38 -8
  14. package/dist/chunk-JWQ2OUEG.js +132 -0
  15. package/dist/{chunk-3R7PT3JG.js → chunk-LJSMPON7.js} +40 -6
  16. package/dist/chunk-N5ZNXNCO.mjs +178 -0
  17. package/dist/{chunk-DMCMWOBJ.mjs → chunk-PBXH4I5N.mjs} +51 -6
  18. package/dist/{chunk-ERL3WXNY.mjs → chunk-PZZWQ6IG.mjs} +5 -5
  19. package/dist/{chunk-GBWVIY3C.mjs → chunk-UJEIFKSK.mjs} +96 -29
  20. package/dist/chunk-WY24TZ4R.mjs +94 -0
  21. package/dist/chunk-XBNIHUSG.js +116 -0
  22. package/dist/{chunk-TDGU5Y2P.js → chunk-XOFTU3T7.js} +5 -5
  23. package/dist/{chunk-NZ7GF6RF.mjs → chunk-YOMOULLR.mjs} +13 -1
  24. package/dist/components/Accordion/index.js +2 -2
  25. package/dist/components/Accordion/index.mjs +1 -1
  26. package/dist/components/Counter/index.d.mts +12 -0
  27. package/dist/components/Counter/index.d.ts +12 -0
  28. package/dist/components/Counter/index.js +2 -2
  29. package/dist/components/Counter/index.mjs +1 -1
  30. package/dist/components/DateRangePicker/index.d.mts +7 -1
  31. package/dist/components/DateRangePicker/index.d.ts +7 -1
  32. package/dist/components/DateRangePicker/index.js +3 -3
  33. package/dist/components/DateRangePicker/index.mjs +1 -1
  34. package/dist/components/Drawer/index.d.mts +21 -1
  35. package/dist/components/Drawer/index.d.ts +21 -1
  36. package/dist/components/Drawer/index.js +2 -2
  37. package/dist/components/Drawer/index.mjs +1 -1
  38. package/dist/components/DualRangeSlider/index.js +2 -2
  39. package/dist/components/DualRangeSlider/index.mjs +1 -1
  40. package/dist/components/Footer/index.js +2 -2
  41. package/dist/components/Footer/index.mjs +1 -1
  42. package/dist/components/Input/index.js +3 -3
  43. package/dist/components/Input/index.mjs +1 -1
  44. package/dist/components/Lightbox/index.d.mts +2 -0
  45. package/dist/components/Lightbox/index.d.ts +2 -0
  46. package/dist/components/Lightbox/index.js +2 -2
  47. package/dist/components/Lightbox/index.mjs +1 -1
  48. package/dist/components/Modal/index.d.mts +12 -0
  49. package/dist/components/Modal/index.d.ts +12 -0
  50. package/dist/components/Modal/index.js +2 -2
  51. package/dist/components/Modal/index.mjs +1 -1
  52. package/dist/components/Select/index.d.mts +8 -0
  53. package/dist/components/Select/index.d.ts +8 -0
  54. package/dist/components/Select/index.js +3 -3
  55. package/dist/components/Select/index.mjs +1 -1
  56. package/dist/components/Switch/index.d.mts +41 -1
  57. package/dist/components/Switch/index.d.ts +41 -1
  58. package/dist/components/Switch/index.js +4 -4
  59. package/dist/components/Switch/index.mjs +1 -1
  60. package/dist/index.js +45 -45
  61. package/dist/index.mjs +14 -14
  62. package/dist/tailwind-preset.d.mts +2 -2
  63. package/dist/tailwind-preset.d.ts +2 -2
  64. package/dist/tailwind-preset.js +2 -2
  65. package/dist/tailwind-preset.mjs +2 -2
  66. package/package.json +14 -14
  67. package/dist/chunk-74B2EGKT.mjs +0 -99
  68. package/dist/chunk-AIA3NHCK.js +0 -373
  69. package/dist/chunk-FL3GD5FJ.mjs +0 -350
  70. package/dist/chunk-LRNSVRUN.mjs +0 -55
  71. package/dist/chunk-T4AT3YCT.js +0 -77
  72. package/dist/chunk-VWFY24XF.js +0 -89
  73. package/dist/chunk-ZLF7IL3Y.mjs +0 -67
@@ -24,13 +24,89 @@ function _interopNamespace(e) {
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
26
 
27
+ var FOCUSABLE_SELECTOR = [
28
+ "a[href]",
29
+ "area[href]",
30
+ "button:not([disabled])",
31
+ "input:not([disabled]):not([type='hidden'])",
32
+ "select:not([disabled])",
33
+ "textarea:not([disabled])",
34
+ "iframe",
35
+ "audio[controls]",
36
+ "video[controls]",
37
+ "[contenteditable]:not([contenteditable='false'])",
38
+ '[tabindex]:not([tabindex="-1"])'
39
+ ].join(", ");
40
+ function getFocusableElements(panel) {
41
+ return Array.from(panel.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
42
+ (element) => !element.closest("[hidden], [aria-hidden='true'], details:not([open])")
43
+ );
44
+ }
45
+ function isTopMostDialog(panel) {
46
+ const dialogs = document.querySelectorAll('[role="dialog"][aria-modal="true"]');
47
+ const topMost = dialogs[dialogs.length - 1];
48
+ return !topMost || topMost.contains(panel);
49
+ }
27
50
  var Modal = React__namespace.forwardRef(
28
- ({ isOpen, onClose, children, title, className }, ref) => {
29
- const contentRef = React__namespace.useRef(null);
51
+ ({
52
+ isOpen,
53
+ onClose,
54
+ children,
55
+ title,
56
+ className,
57
+ "aria-label": ariaLabel,
58
+ "aria-labelledby": ariaLabelledBy,
59
+ "aria-describedby": ariaDescribedBy
60
+ }, ref) => {
61
+ const panelRef = React__namespace.useRef(null);
62
+ const generatedTitleId = React__namespace.useId();
63
+ const titleId = title ? `${generatedTitleId}-title` : void 0;
64
+ const labelledBy = ariaLabelledBy ?? titleId;
30
65
  React__namespace.useEffect(() => {
31
66
  if (!isOpen) return;
32
- const handleKeyDown = (e) => {
33
- if (e.key === "Escape") onClose();
67
+ const trigger = document.activeElement instanceof HTMLElement ? document.activeElement : null;
68
+ return () => {
69
+ if (trigger && trigger.isConnected) trigger.focus();
70
+ };
71
+ }, [isOpen]);
72
+ React__namespace.useEffect(() => {
73
+ if (!isOpen) return;
74
+ const panel = panelRef.current;
75
+ if (!panel) return;
76
+ const focusable = getFocusableElements(panel);
77
+ (focusable[0] ?? panel).focus();
78
+ }, [isOpen]);
79
+ React__namespace.useEffect(() => {
80
+ if (!isOpen) return;
81
+ const handleKeyDown = (event) => {
82
+ const panel = panelRef.current;
83
+ if (!panel || !isTopMostDialog(panel)) return;
84
+ if (event.key === "Escape") {
85
+ onClose();
86
+ return;
87
+ }
88
+ if (event.key !== "Tab") return;
89
+ const focusable = getFocusableElements(panel);
90
+ const active = document.activeElement instanceof HTMLElement ? document.activeElement : null;
91
+ if (focusable.length === 0) {
92
+ event.preventDefault();
93
+ panel.focus();
94
+ return;
95
+ }
96
+ const first = focusable[0];
97
+ const last = focusable[focusable.length - 1];
98
+ if (!active || !panel.contains(active)) {
99
+ event.preventDefault();
100
+ (event.shiftKey ? last : first).focus();
101
+ return;
102
+ }
103
+ if (event.shiftKey && active === first) {
104
+ event.preventDefault();
105
+ last.focus();
106
+ } else if (!event.shiftKey && active === last) {
107
+ event.preventDefault();
108
+ first.focus();
109
+ }
34
110
  };
35
111
  document.addEventListener("keydown", handleKeyDown);
36
112
  return () => document.removeEventListener("keydown", handleKeyDown);
@@ -43,13 +119,6 @@ var Modal = React__namespace.forwardRef(
43
119
  document.body.style.overflow = prev;
44
120
  };
45
121
  }, [isOpen]);
46
- React__namespace.useEffect(() => {
47
- if (!isOpen || !contentRef.current) return;
48
- const focusable = contentRef.current.querySelectorAll(
49
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
50
- );
51
- if (focusable.length > 0) focusable[0].focus();
52
- }, [isOpen]);
53
122
  if (!isOpen) return null;
54
123
  return /* @__PURE__ */ jsxRuntime.jsxs(
55
124
  "div",
@@ -58,7 +127,9 @@ var Modal = React__namespace.forwardRef(
58
127
  className: "fixed inset-0 z-50 flex items-center justify-center p-4",
59
128
  role: "dialog",
60
129
  "aria-modal": "true",
61
- "aria-label": title,
130
+ "aria-labelledby": labelledBy,
131
+ "aria-label": labelledBy ? void 0 : ariaLabel,
132
+ "aria-describedby": ariaDescribedBy,
62
133
  children: [
63
134
  /* @__PURE__ */ jsxRuntime.jsx(
64
135
  "div",
@@ -71,14 +142,22 @@ var Modal = React__namespace.forwardRef(
71
142
  /* @__PURE__ */ jsxRuntime.jsxs(
72
143
  "div",
73
144
  {
74
- ref: contentRef,
145
+ ref: panelRef,
146
+ tabIndex: -1,
75
147
  className: chunkADIDI7AJ_js.cn(
76
- "relative bg-white rounded-2xl shadow-xl max-w-md w-full max-h-[90vh] overflow-auto",
148
+ "relative bg-white rounded-2xl shadow-xl max-w-md w-full max-h-[90vh] overflow-auto outline-none",
77
149
  className
78
150
  ),
79
151
  children: [
80
152
  title && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-6 pt-6 pb-2", children: [
81
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-heading font-semibold text-primary", children: title }),
153
+ /* @__PURE__ */ jsxRuntime.jsx(
154
+ "h2",
155
+ {
156
+ id: titleId,
157
+ className: "text-lg font-heading font-semibold text-primary",
158
+ children: title
159
+ }
160
+ ),
82
161
  /* @__PURE__ */ jsxRuntime.jsx(
83
162
  "button",
84
163
  {
@@ -54,17 +54,47 @@ var switchThumbVariants = classVarianceAuthority.cva(
54
54
  }
55
55
  );
56
56
  var Switch = React__namespace.forwardRef(
57
- ({ checked = false, onCheckedChange, disabled = false, size, label, description, className, name }, ref) => {
58
- const id = React__namespace.useId();
57
+ ({
58
+ checked = false,
59
+ onCheckedChange,
60
+ disabled = false,
61
+ size,
62
+ label,
63
+ description,
64
+ className,
65
+ name,
66
+ id,
67
+ "aria-label": ariaLabel,
68
+ "aria-labelledby": ariaLabelledBy,
69
+ "aria-describedby": ariaDescribedBy
70
+ }, ref) => {
71
+ const generatedId = React__namespace.useId();
72
+ const switchId = id ?? generatedId;
73
+ const labelId = `${switchId}-label`;
74
+ const descriptionId = `${switchId}-description`;
75
+ const labelledBy = [label ? labelId : null, ariaLabelledBy].filter(Boolean).join(" ") || void 0;
76
+ const resolvedAriaLabel = labelledBy ? void 0 : ariaLabel ?? name;
77
+ const describedBy = [description ? descriptionId : null, ariaDescribedBy].filter(Boolean).join(" ") || void 0;
78
+ const hasAccessibleName = Boolean(labelledBy || resolvedAriaLabel);
79
+ React__namespace.useEffect(() => {
80
+ if (hasAccessibleName) return;
81
+ if (typeof process === "undefined") return;
82
+ if (process.env.NODE_ENV === "production") return;
83
+ console.warn(
84
+ "[@dododog/ui] Switch sans nom accessible : passer `label`, `aria-labelledby` ou `aria-label`."
85
+ );
86
+ }, [hasAccessibleName]);
59
87
  const track = /* @__PURE__ */ jsxRuntime.jsxs(
60
88
  "button",
61
89
  {
62
90
  ref,
63
- id,
91
+ id: switchId,
64
92
  type: "button",
65
93
  role: "switch",
66
94
  "aria-checked": checked,
67
- "aria-label": !label ? name : void 0,
95
+ "aria-labelledby": labelledBy,
96
+ "aria-label": resolvedAriaLabel,
97
+ "aria-describedby": describedBy,
68
98
  disabled,
69
99
  onClick: () => onCheckedChange?.(!checked),
70
100
  className: chunkADIDI7AJ_js.cn(
@@ -91,8 +121,23 @@ var Switch = React__namespace.forwardRef(
91
121
  if (!label && !description) return track;
92
122
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunkADIDI7AJ_js.cn("flex items-center justify-between gap-3", className), children: [
93
123
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
94
- label && /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "text-sm font-medium text-primary cursor-pointer", children: label }),
95
- description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-text-secondary mt-0.5", children: description })
124
+ label && /* @__PURE__ */ jsxRuntime.jsx(
125
+ "label",
126
+ {
127
+ id: labelId,
128
+ htmlFor: switchId,
129
+ className: "text-sm font-medium text-primary cursor-pointer",
130
+ children: label
131
+ }
132
+ ),
133
+ description && /* @__PURE__ */ jsxRuntime.jsx(
134
+ "p",
135
+ {
136
+ id: descriptionId,
137
+ className: "text-xs text-text-secondary mt-0.5",
138
+ children: description
139
+ }
140
+ )
96
141
  ] }),
97
142
  track
98
143
  ] });
@@ -24,31 +24,61 @@ var inputVariants = cva(
24
24
  }
25
25
  );
26
26
  var Input = React.forwardRef(
27
- ({ className, size, variant, label, error, required, leftIcon, rightIcon, ...props }, ref) => {
27
+ ({
28
+ className,
29
+ size,
30
+ variant,
31
+ label,
32
+ error,
33
+ required,
34
+ leftIcon,
35
+ rightIcon,
36
+ id,
37
+ "aria-describedby": ariaDescribedBy,
38
+ "aria-invalid": ariaInvalid,
39
+ "aria-required": ariaRequired,
40
+ ...props
41
+ }, ref) => {
42
+ const generatedId = React.useId();
43
+ const inputId = id ?? generatedId;
44
+ const errorId = `${inputId}-error`;
28
45
  const resolvedVariant = error ? "error" : variant ?? "default";
46
+ const describedBy = [ariaDescribedBy, error ? errorId : null].filter(Boolean).join(" ") || void 0;
29
47
  return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
30
- label && /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium text-primary mb-1.5", children: [
31
- label,
32
- required && /* @__PURE__ */ jsx("span", { className: "text-secondary", children: " *" })
33
- ] }),
48
+ label && /* @__PURE__ */ jsxs(
49
+ "label",
50
+ {
51
+ htmlFor: inputId,
52
+ className: "block text-sm font-medium text-primary mb-1.5",
53
+ children: [
54
+ label,
55
+ required && /* @__PURE__ */ jsx("span", { className: "text-secondary", "aria-hidden": "true", children: " *" })
56
+ ]
57
+ }
58
+ ),
34
59
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
35
60
  leftIcon && /* @__PURE__ */ jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-text-muted", children: leftIcon }),
36
61
  /* @__PURE__ */ jsx(
37
62
  "input",
38
63
  {
64
+ ...props,
39
65
  ref,
66
+ id: inputId,
67
+ required,
68
+ "aria-required": ariaRequired ?? (required ? true : void 0),
69
+ "aria-invalid": ariaInvalid ?? (error ? true : void 0),
70
+ "aria-describedby": describedBy,
40
71
  className: cn(
41
72
  inputVariants({ size, variant: resolvedVariant }),
42
73
  leftIcon && "pl-10",
43
74
  rightIcon && "pr-10",
44
75
  className
45
- ),
46
- ...props
76
+ )
47
77
  }
48
78
  ),
49
79
  rightIcon && /* @__PURE__ */ jsx("div", { className: "absolute right-3 top-1/2 -translate-y-1/2 text-text-muted", children: rightIcon })
50
80
  ] }),
51
- error && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-red-500", children: error })
81
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "mt-1 text-sm text-red-500", children: error })
52
82
  ] });
53
83
  }
54
84
  );
@@ -0,0 +1,132 @@
1
+ 'use strict';
2
+
3
+ var chunkADIDI7AJ_js = require('./chunk-ADIDI7AJ.js');
4
+ var React = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ var SIDE_CLASSES = {
28
+ right: "top-0 bottom-0 right-0 w-full max-w-md",
29
+ left: "top-0 bottom-0 left-0 w-full max-w-md",
30
+ bottom: "inset-x-0 bottom-0 w-full max-h-[90dvh] rounded-t-3xl"
31
+ };
32
+ var Drawer = React__namespace.forwardRef(
33
+ ({
34
+ isOpen,
35
+ onClose,
36
+ children,
37
+ side = "right",
38
+ title,
39
+ labelledById,
40
+ className,
41
+ overlayClassName,
42
+ contentClassName,
43
+ closeLabel = "Fermer"
44
+ }, ref) => {
45
+ React__namespace.useEffect(() => {
46
+ if (!isOpen) return;
47
+ const handleKeyDown = (e) => {
48
+ if (e.key === "Escape") onClose();
49
+ };
50
+ document.addEventListener("keydown", handleKeyDown);
51
+ return () => document.removeEventListener("keydown", handleKeyDown);
52
+ }, [isOpen, onClose]);
53
+ React__namespace.useEffect(() => {
54
+ if (!isOpen) return;
55
+ const prev = document.body.style.overflow;
56
+ document.body.style.overflow = "hidden";
57
+ return () => {
58
+ document.body.style.overflow = prev;
59
+ };
60
+ }, [isOpen]);
61
+ if (!isOpen) return null;
62
+ return /* @__PURE__ */ jsxRuntime.jsxs(
63
+ "div",
64
+ {
65
+ ref,
66
+ className: chunkADIDI7AJ_js.cn("fixed inset-0 z-50", overlayClassName),
67
+ role: "dialog",
68
+ "aria-modal": "true",
69
+ "aria-labelledby": labelledById,
70
+ "aria-label": labelledById ? void 0 : title,
71
+ children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx(
73
+ "div",
74
+ {
75
+ className: "absolute inset-0 bg-black/50 transition-opacity",
76
+ onClick: onClose,
77
+ "aria-hidden": "true"
78
+ }
79
+ ),
80
+ /* @__PURE__ */ jsxRuntime.jsxs(
81
+ "div",
82
+ {
83
+ className: chunkADIDI7AJ_js.cn(
84
+ "absolute bg-white shadow-xl flex flex-col overflow-hidden",
85
+ SIDE_CLASSES[side],
86
+ className
87
+ ),
88
+ children: [
89
+ /* @__PURE__ */ jsxRuntime.jsxs(
90
+ "div",
91
+ {
92
+ className: chunkADIDI7AJ_js.cn(
93
+ "flex items-center gap-2 px-4 h-16 shrink-0",
94
+ title ? "justify-between border-b border-gray-100" : "justify-end"
95
+ ),
96
+ children: [
97
+ title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-heading font-semibold text-primary truncate", children: title }),
98
+ /* @__PURE__ */ jsxRuntime.jsx(
99
+ "button",
100
+ {
101
+ type: "button",
102
+ onClick: onClose,
103
+ className: "p-2 hover:bg-gray-100 rounded-full transition-colors shrink-0",
104
+ "aria-label": closeLabel,
105
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
106
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18" }),
107
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12" })
108
+ ] })
109
+ }
110
+ )
111
+ ]
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsxRuntime.jsx(
115
+ "div",
116
+ {
117
+ "data-drawer-content": "",
118
+ className: chunkADIDI7AJ_js.cn("flex-1 overflow-y-auto overscroll-contain", contentClassName),
119
+ children
120
+ }
121
+ )
122
+ ]
123
+ }
124
+ )
125
+ ]
126
+ }
127
+ );
128
+ }
129
+ );
130
+ Drawer.displayName = "Drawer";
131
+
132
+ exports.Drawer = Drawer;
@@ -57,14 +57,27 @@ var Select = React__namespace.forwardRef(
57
57
  placeholder,
58
58
  value,
59
59
  onChange,
60
- disabled = false
60
+ disabled = false,
61
+ id,
62
+ "aria-label": ariaLabel,
63
+ "aria-labelledby": ariaLabelledBy,
64
+ "aria-describedby": ariaDescribedBy
61
65
  }, ref) => {
62
66
  const [isOpen, setIsOpen] = React__namespace.useState(false);
63
67
  const [highlightedIndex, setHighlightedIndex] = React__namespace.useState(-1);
64
68
  const containerRef = React__namespace.useRef(null);
65
69
  const listboxRef = React__namespace.useRef(null);
70
+ const generatedId = React__namespace.useId();
71
+ const selectId = id ?? generatedId;
72
+ const labelId = `${selectId}-label`;
73
+ const listboxId = `${selectId}-listbox`;
74
+ const errorId = `${selectId}-error`;
75
+ const optionId = (index) => `${selectId}-option-${index}`;
66
76
  const resolvedVariant = error ? "error" : variant ?? "default";
67
77
  const selectedOption = options.find((o) => o.value === value);
78
+ const labelledBy = [label ? labelId : null, ariaLabelledBy].filter(Boolean).join(" ") || void 0;
79
+ const describedBy = [ariaDescribedBy, error ? errorId : null].filter(Boolean).join(" ") || void 0;
80
+ const hasHighlight = isOpen && highlightedIndex >= 0 && highlightedIndex < options.length;
68
81
  React__namespace.useEffect(() => {
69
82
  const handleClickOutside = (e) => {
70
83
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -133,18 +146,34 @@ var Select = React__namespace.forwardRef(
133
146
  }
134
147
  };
135
148
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", ref, children: [
136
- label && /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "block text-sm font-medium text-primary mb-1.5", children: [
137
- label,
138
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-secondary", children: " *" })
139
- ] }),
149
+ label && /* @__PURE__ */ jsxRuntime.jsxs(
150
+ "label",
151
+ {
152
+ id: labelId,
153
+ htmlFor: selectId,
154
+ className: "block text-sm font-medium text-primary mb-1.5",
155
+ children: [
156
+ label,
157
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-secondary", "aria-hidden": "true", children: " *" })
158
+ ]
159
+ }
160
+ ),
140
161
  /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "relative", children: [
141
162
  /* @__PURE__ */ jsxRuntime.jsx(
142
163
  "button",
143
164
  {
144
165
  type: "button",
166
+ id: selectId,
145
167
  role: "combobox",
146
168
  "aria-expanded": isOpen,
147
169
  "aria-haspopup": "listbox",
170
+ "aria-controls": isOpen ? listboxId : void 0,
171
+ "aria-activedescendant": hasHighlight ? optionId(highlightedIndex) : void 0,
172
+ "aria-labelledby": labelledBy,
173
+ "aria-label": labelledBy ? void 0 : ariaLabel,
174
+ "aria-required": required ? true : void 0,
175
+ "aria-invalid": error ? true : void 0,
176
+ "aria-describedby": describedBy,
148
177
  disabled,
149
178
  onClick: handleToggle,
150
179
  onKeyDown: handleKeyDown,
@@ -170,6 +199,7 @@ var Select = React__namespace.forwardRef(
170
199
  strokeWidth: "2",
171
200
  strokeLinecap: "round",
172
201
  strokeLinejoin: "round",
202
+ "aria-hidden": "true",
173
203
  className: chunkADIDI7AJ_js.cn(
174
204
  "absolute right-3 top-1/2 -translate-y-1/2 text-text-muted pointer-events-none transition-transform",
175
205
  isOpen && "rotate-180"
@@ -181,12 +211,16 @@ var Select = React__namespace.forwardRef(
181
211
  "ul",
182
212
  {
183
213
  ref: listboxRef,
214
+ id: listboxId,
184
215
  role: "listbox",
216
+ "aria-labelledby": labelledBy,
217
+ "aria-label": labelledBy ? void 0 : ariaLabel,
185
218
  className: "absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-xl shadow-lg max-h-60 overflow-auto py-1",
186
219
  children: [
187
220
  options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
188
221
  "li",
189
222
  {
223
+ id: optionId(index),
190
224
  role: "option",
191
225
  "aria-selected": option.value === value,
192
226
  onClick: () => handleSelect(option.value),
@@ -205,7 +239,7 @@ var Select = React__namespace.forwardRef(
205
239
  }
206
240
  )
207
241
  ] }),
208
- error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-red-500", children: error })
242
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: "mt-1 text-sm text-red-500", children: error })
209
243
  ] });
210
244
  }
211
245
  );