doom-design-system 0.1.12 → 0.1.14

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.
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
3
  label?: string;
4
4
  error?: string;
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  var __rest = (this && this.__rest) || function (s, e) {
3
3
  var t = {};
4
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -11,14 +11,18 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useState } from 'react';
15
- import clsx from 'clsx';
16
- import { Label } from '../Label/Label.js';
17
- import styles from './Input.module.css';
14
+ import { useState, useId } from "react";
15
+ import clsx from "clsx";
16
+ import { Label } from "../Label/Label.js";
17
+ import styles from "./Input.module.css";
18
18
  export function Input(_a) {
19
19
  var { label, error: errorProp, helperText, startAdornment, endAdornment, style, className, format, validate, onBlur, onFocus, value, id, required } = _a, props = __rest(_a, ["label", "error", "helperText", "startAdornment", "endAdornment", "style", "className", "format", "validate", "onBlur", "onFocus", "value", "id", "required"]);
20
20
  const [isFocused, setIsFocused] = useState(false);
21
21
  const [internalError, setInternalError] = useState(undefined);
22
+ const reactId = useId();
23
+ const inputId = id || `input-${reactId}`;
24
+ const helperId = `${inputId}-helper`;
25
+ const errorId = `${inputId}-error`;
22
26
  const error = errorProp || internalError;
23
27
  const handleBlur = (e) => {
24
28
  setIsFocused(false);
@@ -33,8 +37,7 @@ export function Input(_a) {
33
37
  if (onFocus)
34
38
  onFocus(e);
35
39
  };
36
- const displayValue = (!isFocused && format && value !== undefined)
37
- ? format(value)
38
- : value;
39
- return (_jsxs("div", { className: clsx(styles.container, className), style: style, children: [label && (_jsx(Label, { htmlFor: id, required: required, children: label })), _jsxs("div", { className: styles.wrapper, children: [startAdornment && (_jsx("span", { className: clsx(styles.adornment, styles.start), children: startAdornment })), _jsx("input", Object.assign({ className: clsx(styles.input, startAdornment && styles.hasStartAdornment, endAdornment && styles.hasEndAdornment, error && styles.error), id: id, required: required, value: displayValue, onBlur: handleBlur, onFocus: handleFocus }, props)), endAdornment && (_jsx("span", { className: clsx(styles.adornment, styles.end), children: endAdornment }))] }), helperText && !error && (_jsx("span", { className: styles.helperText, children: helperText })), error && (_jsx("span", { className: clsx(styles.helperText, styles.error), children: error }))] }));
40
+ const displayValue = !isFocused && format && value !== undefined ? format(value) : value;
41
+ const describedBy = clsx(helperText && helperId, error && errorId) || undefined;
42
+ return (_jsxs("div", { className: clsx(styles.container, className), style: style, children: [label && (_jsx(Label, { htmlFor: inputId, required: required, children: label })), _jsxs("div", { className: styles.wrapper, children: [startAdornment && (_jsx("span", { className: clsx(styles.adornment, styles.start), children: startAdornment })), _jsx("input", Object.assign({ className: clsx(styles.input, startAdornment && styles.hasStartAdornment, endAdornment && styles.hasEndAdornment, error && styles.error), id: inputId, required: required, value: displayValue, onBlur: handleBlur, onFocus: handleFocus, "aria-invalid": !!error, "aria-describedby": describedBy }, props)), endAdornment && (_jsx("span", { className: clsx(styles.adornment, styles.end), children: endAdornment }))] }), helperText && !error && (_jsx("span", { id: helperId, className: styles.helperText, children: helperText })), error && (_jsx("span", { id: errorId, className: clsx(styles.helperText, styles.error), role: "alert", children: error }))] }));
40
43
  }
@@ -1,22 +1,23 @@
1
- import React from 'react';
2
- interface ModalProps {
1
+ import React from "react";
2
+ interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  isOpen: boolean;
4
4
  onClose: () => void;
5
5
  title?: string;
6
6
  children: React.ReactNode;
7
7
  footer?: React.ReactNode;
8
8
  }
9
- export declare function ModalHeader({ children, className }: {
9
+ export declare function ModalHeader({ children, className, id, }: {
10
10
  children: React.ReactNode;
11
11
  className?: string;
12
+ id?: string;
12
13
  }): import("react/jsx-runtime").JSX.Element;
13
- export declare function ModalBody({ children, className }: {
14
+ export declare function ModalBody({ children, className, }: {
14
15
  children: React.ReactNode;
15
16
  className?: string;
16
17
  }): import("react/jsx-runtime").JSX.Element;
17
- export declare function ModalFooter({ children, className }: {
18
+ export declare function ModalFooter({ children, className, }: {
18
19
  children: React.ReactNode;
19
20
  className?: string;
20
21
  }): import("react/jsx-runtime").JSX.Element;
21
- export declare function Modal({ isOpen, onClose, title, children, footer }: ModalProps): React.ReactPortal | null;
22
+ export declare function Modal({ isOpen, onClose, title, children, footer, className, style, ...props }: ModalProps): React.ReactPortal | null;
22
23
  export {};
@@ -1,38 +1,54 @@
1
- 'use client';
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import React, { useEffect, useRef } from 'react';
4
- import { createPortal } from 'react-dom';
5
- import { X } from 'lucide-react';
6
- import clsx from 'clsx';
7
- import { Card } from '../Card/Card.js';
8
- import { Button } from '../Button/Button.js';
9
- import { Flex } from '../Layout/Layout.js';
10
- import styles from './Modal.module.css';
11
- const ModalContext = React.createContext({ onClose: () => { } });
12
- export function ModalHeader({ children, className }) {
13
- const { onClose } = React.useContext(ModalContext);
14
- return (_jsxs(Flex, { align: "center", justify: "space-between", className: clsx(styles.header, className), children: [_jsx("h2", { children: children }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onClose, children: _jsx(X, { size: 20, strokeWidth: 2.5 }) })] }));
14
+ import React, { useEffect, useRef, useId } from "react";
15
+ import { createPortal } from "react-dom";
16
+ import { X } from "lucide-react";
17
+ import clsx from "clsx";
18
+ import { Card } from "../Card/Card.js";
19
+ import { Button } from "../Button/Button.js";
20
+ import { Flex } from "../Layout/Layout.js";
21
+ import styles from "./Modal.module.css";
22
+ const ModalContext = React.createContext({
23
+ onClose: () => { },
24
+ });
25
+ export function ModalHeader({ children, className, id, }) {
26
+ const { onClose, titleId } = React.useContext(ModalContext);
27
+ return (_jsxs(Flex, { align: "center", justify: "space-between", className: clsx(styles.header, className), children: [_jsx("h2", { id: id || titleId, children: children }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onClose, "aria-label": "Close modal", children: _jsx(X, { size: 20, strokeWidth: 2.5 }) })] }));
15
28
  }
16
- export function ModalBody({ children, className }) {
17
- return (_jsx("div", { className: clsx(styles.body, className), children: children }));
29
+ export function ModalBody({ children, className, }) {
30
+ return _jsx("div", { className: clsx(styles.body, className), children: children });
18
31
  }
19
- export function ModalFooter({ children, className }) {
20
- return (_jsx("div", { className: clsx(styles.footer, className), children: children }));
32
+ export function ModalFooter({ children, className, }) {
33
+ return _jsx("div", { className: clsx(styles.footer, className), children: children });
21
34
  }
22
- export function Modal({ isOpen, onClose, title, children, footer }) {
35
+ export function Modal(_a) {
36
+ var { isOpen, onClose, title, children, footer, className, style } = _a, props = __rest(_a, ["isOpen", "onClose", "title", "children", "footer", "className", "style"]);
23
37
  const overlayRef = useRef(null);
38
+ const reactId = useId();
39
+ const titleId = `modal-title-${reactId}`;
24
40
  useEffect(() => {
25
41
  const handleEscape = (e) => {
26
- if (e.key === 'Escape')
42
+ if (e.key === "Escape")
27
43
  onClose();
28
44
  };
29
45
  if (isOpen) {
30
- document.addEventListener('keydown', handleEscape);
31
- document.body.style.overflow = 'hidden';
46
+ document.addEventListener("keydown", handleEscape);
47
+ document.body.style.overflow = "hidden";
32
48
  }
33
49
  return () => {
34
- document.removeEventListener('keydown', handleEscape);
35
- document.body.style.overflow = 'unset';
50
+ document.removeEventListener("keydown", handleEscape);
51
+ document.body.style.overflow = "unset";
36
52
  };
37
53
  }, [isOpen, onClose]);
38
54
  if (!isOpen)
@@ -42,5 +58,5 @@ export function Modal({ isOpen, onClose, title, children, footer }) {
42
58
  onClose();
43
59
  }
44
60
  };
45
- return createPortal(_jsx(ModalContext.Provider, { value: { onClose }, children: _jsx("div", { className: styles.overlay, ref: overlayRef, onClick: handleOverlayClick, children: _jsx("div", { className: styles.contentContainer, children: _jsx(Card, { style: { padding: 0, overflow: 'hidden' }, children: title ? (_jsxs(_Fragment, { children: [_jsx(ModalHeader, { children: title }), _jsx(ModalBody, { children: children }), footer && _jsx(ModalFooter, { children: footer })] })) : (children) }) }) }) }), document.body);
61
+ return createPortal(_jsx(ModalContext.Provider, { value: { onClose, titleId }, children: _jsx("div", { className: clsx(styles.overlay, className), ref: overlayRef, onClick: handleOverlayClick, style: style, children: _jsx("div", { className: styles.contentContainer, children: _jsx("div", Object.assign({ role: "dialog", "aria-modal": "true", "aria-labelledby": title ? titleId : undefined }, props, { children: _jsx(Card, { style: { padding: 0, overflow: "hidden" }, children: title ? (_jsxs(_Fragment, { children: [_jsx(ModalHeader, { children: title }), _jsx(ModalBody, { children: children }), footer && _jsx(ModalFooter, { children: footer })] })) : (children) }) })) }) }) }), document.body);
46
62
  }
@@ -1,12 +1,10 @@
1
- import React from 'react';
2
- interface ProgressBarProps {
1
+ import React from "react";
2
+ interface ProgressBarProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  value: number;
4
4
  max?: number;
5
5
  height?: string | number;
6
6
  color?: string;
7
7
  showStripes?: boolean;
8
- className?: string;
9
- style?: React.CSSProperties;
10
8
  }
11
- export declare function ProgressBar({ value, max, height, color, showStripes, className, style }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ProgressBar({ value, max, height, color, showStripes, className, style, ...props }: ProgressBarProps): import("react/jsx-runtime").JSX.Element;
12
10
  export {};
@@ -1,12 +1,25 @@
1
- 'use client';
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import clsx from 'clsx';
4
- import styles from './ProgressBar.module.css';
5
- export function ProgressBar({ value, max = 100, height = '24px', color = 'var(--primary)', showStripes = true, className, style }) {
14
+ import clsx from "clsx";
15
+ import styles from "./ProgressBar.module.css";
16
+ export function ProgressBar(_a) {
17
+ var { value, max = 100, height = "24px", color = "var(--primary)", showStripes = true, className, style } = _a, props = __rest(_a, ["value", "max", "height", "color", "showStripes", "className", "style"]);
6
18
  const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
7
- const heightStyle = typeof height === 'number' ? `${height}px` : height;
8
- return (_jsxs("div", { className: clsx(styles.container, className), style: Object.assign({ '--height': heightStyle }, style), children: [_jsx("div", { className: styles.fill, style: {
9
- '--percentage': `${percentage}%`,
10
- '--color': color
11
- }, "data-complete": percentage >= 100 }), showStripes && _jsx("div", { className: styles.stripes })] }));
19
+ const clampedValue = Math.min(Math.max(value, 0), max);
20
+ const heightStyle = typeof height === "number" ? `${height}px` : height;
21
+ return (_jsxs("div", Object.assign({ role: "progressbar", "aria-valuenow": clampedValue, "aria-valuemin": 0, "aria-valuemax": max, className: clsx(styles.container, className), style: Object.assign({ "--height": heightStyle }, style) }, props, { children: [_jsx("div", { className: styles.fill, style: {
22
+ "--percentage": `${percentage}%`,
23
+ "--color": color,
24
+ }, "data-complete": percentage >= 100 }), showStripes && _jsx("div", { className: styles.stripes })] })));
12
25
  }
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'onChange'> {
1
+ import React from "react";
2
+ interface SelectProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "value" | "defaultValue"> {
3
3
  options: {
4
4
  value: string | number;
5
5
  label: string;
@@ -7,6 +7,10 @@ interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>
7
7
  label?: string;
8
8
  onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
9
9
  placeholder?: string;
10
+ value?: string | number;
11
+ defaultValue?: string | number;
12
+ name?: string;
13
+ required?: boolean;
10
14
  }
11
- export declare function Select({ options, className, label, style, value, defaultValue, onChange, placeholder, id, required, disabled, name, form, autoFocus, ...props }: SelectProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function Select({ options, className, label, style, value, defaultValue, onChange, placeholder, id, required, disabled, name, autoFocus, ...props }: SelectProps): import("react/jsx-runtime").JSX.Element;
12
16
  export {};
@@ -1,4 +1,4 @@
1
- 'use client';
1
+ "use client";
2
2
  var __rest = (this && this.__rest) || function (s, e) {
3
3
  var t = {};
4
4
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -11,28 +11,29 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- import { useState, useRef, useEffect, useId } from 'react';
15
- import clsx from 'clsx';
16
- import { Text } from '../Text/Text.js';
17
- import { Popover } from '../Popover/Popover.js';
18
- import { Check, ChevronDown } from 'lucide-react';
19
- import styles from './Select.module.css';
14
+ import { useState, useRef, useEffect, useId, } from "react";
15
+ import clsx from "clsx";
16
+ import { Text } from "../Text/Text.js";
17
+ import { Popover } from "../Popover/Popover.js";
18
+ import { Check, ChevronDown } from "lucide-react";
19
+ import styles from "./Select.module.css";
20
20
  export function Select(_a) {
21
21
  var _b;
22
- var { options, className, label, style, value, defaultValue, onChange, placeholder, id, required, disabled, name, form, autoFocus } = _a, props = __rest(_a, ["options", "className", "label", "style", "value", "defaultValue", "onChange", "placeholder", "id", "required", "disabled", "name", "form", "autoFocus"]);
22
+ var { options, className, label, style, value, defaultValue, onChange, placeholder, id, required, disabled, name, autoFocus } = _a, props = __rest(_a, ["options", "className", "label", "style", "value", "defaultValue", "onChange", "placeholder", "id", "required", "disabled", "name", "autoFocus"]);
23
23
  const [isOpen, setIsOpen] = useState(false);
24
- const [internalValue, setInternalValue] = useState(defaultValue || '');
24
+ const [internalValue, setInternalValue] = useState(defaultValue || "");
25
25
  const [highlightedIndex, setHighlightedIndex] = useState(-1);
26
26
  const reactId = useId();
27
27
  const triggerRef = useRef(null);
28
- const listboxId = id ? `${id}-listbox` : `select-listbox-${reactId}`;
29
- const labelId = id ? `${id}-label` : `select-label-${reactId}`;
28
+ const selectId = id || `select-${reactId}`;
29
+ const listboxId = `${selectId}-listbox`;
30
+ const labelId = `${selectId}-label`;
30
31
  const currentValue = value !== undefined ? value : internalValue;
31
- const selectedOption = options.find(opt => String(opt.value) === String(currentValue));
32
+ const selectedOption = options.find((opt) => String(opt.value) === String(currentValue));
32
33
  // Reset highlighted index when opening
33
34
  useEffect(() => {
34
35
  if (isOpen) {
35
- const index = options.findIndex(opt => String(opt.value) === String(currentValue));
36
+ const index = options.findIndex((opt) => String(opt.value) === String(currentValue));
36
37
  setHighlightedIndex(index >= 0 ? index : 0);
37
38
  }
38
39
  }, [isOpen, currentValue, options]);
@@ -43,8 +44,8 @@ export function Select(_a) {
43
44
  }
44
45
  if (onChange) {
45
46
  const syntheticEvent = {
46
- target: { value: newValue, name: name },
47
- currentTarget: { value: newValue, name: name },
47
+ target: { value: newValue, name: name, id: selectId },
48
+ currentTarget: { value: newValue, name: name, id: selectId },
48
49
  preventDefault: () => { },
49
50
  stopPropagation: () => { },
50
51
  };
@@ -56,8 +57,8 @@ export function Select(_a) {
56
57
  const handleKeyDown = (e) => {
57
58
  var _a;
58
59
  switch (e.key) {
59
- case 'Enter':
60
- case ' ':
60
+ case "Enter":
61
+ case " ":
61
62
  e.preventDefault();
62
63
  if (isOpen) {
63
64
  if (highlightedIndex >= 0 && highlightedIndex < options.length) {
@@ -68,49 +69,43 @@ export function Select(_a) {
68
69
  setIsOpen(true);
69
70
  }
70
71
  break;
71
- case 'ArrowDown':
72
+ case "ArrowDown":
72
73
  e.preventDefault();
73
74
  if (!isOpen) {
74
75
  setIsOpen(true);
75
76
  }
76
77
  else {
77
- setHighlightedIndex(prev => (prev < options.length - 1 ? prev + 1 : 0));
78
+ setHighlightedIndex((prev) => prev < options.length - 1 ? prev + 1 : 0);
78
79
  }
79
80
  break;
80
- case 'ArrowUp':
81
+ case "ArrowUp":
81
82
  e.preventDefault();
82
83
  if (!isOpen) {
83
84
  setIsOpen(true);
84
85
  }
85
86
  else {
86
- setHighlightedIndex(prev => (prev > 0 ? prev - 1 : options.length - 1));
87
+ setHighlightedIndex((prev) => prev > 0 ? prev - 1 : options.length - 1);
87
88
  }
88
89
  break;
89
- case 'Escape':
90
+ case "Escape":
90
91
  if (isOpen) {
91
92
  e.preventDefault();
92
93
  setIsOpen(false);
93
94
  (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
94
95
  }
95
96
  break;
96
- case 'Tab':
97
+ case "Tab":
97
98
  if (isOpen) {
98
99
  setIsOpen(false);
99
100
  }
100
101
  break;
101
102
  }
102
103
  };
103
- return (_jsxs("div", { className: clsx(styles.container, className), style: style, children: [label && (_jsx(Text, { as: "label", id: labelId, variant: "small", weight: "bold", color: "muted", className: "mb-1 block", htmlFor: id, children: label })), _jsx(Popover, { isOpen: isOpen, onClose: () => setIsOpen(false), placement: "bottom-start", trigger: _jsxs("button", Object.assign({ ref: triggerRef, className: styles.trigger, type: "button", id: id, onClick: () => setIsOpen(!isOpen), onKeyDown: handleKeyDown, "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-labelledby": label ? labelId : undefined, disabled: disabled, autoFocus: autoFocus }, props, { children: [_jsx("span", { children: selectedOption ? selectedOption.label : (placeholder || 'Select...') }), _jsx(ChevronDown, { size: 16, strokeWidth: 2.5, style: { marginLeft: '0.5rem' } })] })), content: _jsx("ul", { id: listboxId, role: "listbox", "aria-labelledby": label ? labelId : undefined, className: styles.optionsList, style: { width: (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth }, children: options.map((opt, index) => {
104
+ return (_jsxs("div", { className: clsx(styles.container, className), style: style, children: [label && (_jsx(Text, { as: "label", id: labelId, variant: "small", weight: "bold", color: "muted", className: "mb-1 block", htmlFor: selectId, children: label })), _jsx(Popover, { isOpen: isOpen, onClose: () => setIsOpen(false), placement: "bottom-start", trigger: _jsxs("button", Object.assign({ ref: triggerRef, className: styles.trigger, type: "button", id: selectId, onClick: () => setIsOpen(!isOpen), onKeyDown: handleKeyDown, role: "combobox", "aria-haspopup": "listbox", "aria-expanded": isOpen, "aria-controls": listboxId, "aria-labelledby": label ? labelId : undefined, "aria-required": required, disabled: disabled, autoFocus: autoFocus }, props, { children: [_jsx("span", { children: selectedOption
105
+ ? selectedOption.label
106
+ : placeholder || "Select..." }), _jsx(ChevronDown, { size: 16, strokeWidth: 2.5, style: { marginLeft: "0.5rem" } })] })), content: _jsx("ul", { id: listboxId, role: "listbox", "aria-labelledby": label ? labelId : undefined, className: styles.optionsList, style: { width: (_b = triggerRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth }, children: options.map((opt, index) => {
104
107
  const isSelected = String(opt.value) === String(currentValue);
105
108
  const isHighlighted = index === highlightedIndex;
106
- return (_jsxs("li", { id: `${listboxId}-option-${index}`, role: "option", "aria-selected": isSelected, className: clsx(styles.optionItem, isSelected && styles.selected, isHighlighted && styles.highlighted), onClick: () => handleSelect(opt.value), onMouseEnter: () => setHighlightedIndex(index), children: [_jsx("span", { children: opt.label }), isSelected && _jsx(Check, { size: 14, strokeWidth: 3 })] }, opt.value));
107
- }) }) }), _jsx("input", { type: "text", name: name, value: currentValue, required: required, form: form, tabIndex: -1, readOnly: true, style: {
108
- opacity: 0,
109
- height: '1px',
110
- width: '1px',
111
- position: 'absolute',
112
- bottom: 0,
113
- left: 0,
114
- pointerEvents: 'none',
115
- } })] }));
109
+ return (_jsxs("li", { id: `${listboxId}-option-${index}`, role: "option", "aria-selected": isSelected, className: clsx(styles.optionItem, isSelected && styles.selected, isHighlighted && styles.highlighted), onClick: () => handleSelect(opt.value), onMouseEnter: () => setHighlightedIndex(index), children: [_jsx("span", { children: opt.label }), isSelected && (_jsx(Check, { size: 14, strokeWidth: 3, "aria-hidden": "true" }))] }, opt.value));
110
+ }) }) }), _jsx("input", { type: "hidden", name: name, value: currentValue, required: required, "aria-hidden": "true" })] }));
116
111
  }
@@ -1,34 +1,27 @@
1
- import React from 'react';
2
- interface TabsProps {
1
+ import React from "react";
2
+ interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
3
3
  defaultValue?: string;
4
4
  value?: string;
5
5
  onValueChange?: (value: string) => void;
6
6
  children: React.ReactNode;
7
- className?: string;
8
7
  }
9
- export declare function Tabs({ defaultValue, value, onValueChange, children, className }: TabsProps): import("react/jsx-runtime").JSX.Element;
10
- interface TabsListProps {
8
+ export declare function Tabs({ defaultValue, value, onValueChange, children, className, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
9
+ interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {
11
10
  children: React.ReactNode;
12
- className?: string;
13
11
  }
14
- export declare function TabsList({ children, className }: TabsListProps): import("react/jsx-runtime").JSX.Element;
15
- interface TabsTriggerProps {
12
+ export declare function TabsList({ children, className, ...props }: TabsListProps): import("react/jsx-runtime").JSX.Element;
13
+ interface TabsTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
16
14
  value: string;
17
15
  children: React.ReactNode;
18
- className?: string;
19
- onClick?: () => void;
20
16
  }
21
- export declare function TabsTrigger({ value, children, className, onClick }: TabsTriggerProps): import("react/jsx-runtime").JSX.Element;
22
- interface TabsBodyProps {
17
+ export declare function TabsTrigger({ value, children, className, onClick, ...props }: TabsTriggerProps): import("react/jsx-runtime").JSX.Element;
18
+ interface TabsBodyProps extends React.HTMLAttributes<HTMLDivElement> {
23
19
  children: React.ReactNode;
24
- className?: string;
25
- style?: React.CSSProperties;
26
20
  }
27
- export declare function TabsBody({ children, className, style }: TabsBodyProps): import("react/jsx-runtime").JSX.Element;
28
- interface TabsContentProps {
21
+ export declare function TabsBody({ children, className, style, ...props }: TabsBodyProps): import("react/jsx-runtime").JSX.Element;
22
+ interface TabsContentProps extends React.HTMLAttributes<HTMLDivElement> {
29
23
  value: string;
30
24
  children: React.ReactNode;
31
- className?: string;
32
25
  }
33
- export declare function TabsContent({ value, children, className }: TabsContentProps): import("react/jsx-runtime").JSX.Element | null;
26
+ export declare function TabsContent({ value, children, className, ...props }: TabsContentProps): import("react/jsx-runtime").JSX.Element | null;
34
27
  export {};
@@ -1,11 +1,24 @@
1
- 'use client';
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import clsx from 'clsx';
4
- import styles from './Tabs.module.css';
5
- import { createContext, useContext, useState } from 'react';
14
+ import clsx from "clsx";
15
+ import styles from "./Tabs.module.css";
16
+ import { createContext, useContext, useState, useId } from "react";
6
17
  const TabsContext = createContext(null);
7
- export function Tabs({ defaultValue, value, onValueChange, children, className }) {
8
- const [internalActiveTab, setInternalActiveTab] = useState(defaultValue || '');
18
+ export function Tabs(_a) {
19
+ var { defaultValue, value, onValueChange, children, className } = _a, props = __rest(_a, ["defaultValue", "value", "onValueChange", "children", "className"]);
20
+ const [internalActiveTab, setInternalActiveTab] = useState(defaultValue || "");
21
+ const reactId = useId();
9
22
  const isControlled = value !== undefined;
10
23
  const activeTab = isControlled ? value : internalActiveTab;
11
24
  const setActiveTab = (newValue) => {
@@ -14,29 +27,38 @@ export function Tabs({ defaultValue, value, onValueChange, children, className }
14
27
  }
15
28
  onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
16
29
  };
17
- return (_jsx(TabsContext.Provider, { value: { activeTab, setActiveTab }, children: _jsx("div", { className: className, children: children }) }));
30
+ return (_jsx(TabsContext.Provider, { value: { activeTab, setActiveTab, baseId: reactId }, children: _jsx("div", Object.assign({ className: className }, props, { children: children })) }));
18
31
  }
19
- export function TabsList({ children, className }) {
20
- return _jsx("div", { className: clsx(styles.tabsList, className), children: children });
32
+ export function TabsList(_a) {
33
+ var { children, className } = _a, props = __rest(_a, ["children", "className"]);
34
+ return (_jsx("div", Object.assign({ role: "tablist", "aria-orientation": "horizontal", className: clsx(styles.tabsList, className) }, props, { children: children })));
21
35
  }
22
- export function TabsTrigger({ value, children, className, onClick }) {
36
+ export function TabsTrigger(_a) {
37
+ var { value, children, className, onClick } = _a, props = __rest(_a, ["value", "children", "className", "onClick"]);
23
38
  const context = useContext(TabsContext);
24
39
  if (!context)
25
- throw new Error('TabsTrigger must be used within Tabs');
40
+ throw new Error("TabsTrigger must be used within Tabs");
26
41
  const isActive = context.activeTab === value;
27
- return (_jsx("button", { className: clsx(styles.tabsTrigger, isActive && styles.active, className), onClick: () => {
42
+ const triggerId = `tabs-trigger-${context.baseId}-${value}`;
43
+ const contentId = `tabs-content-${context.baseId}-${value}`;
44
+ return (_jsx("button", Object.assign({ id: triggerId, role: "tab", type: "button", "aria-selected": isActive, "aria-controls": contentId, className: clsx(styles.tabsTrigger, isActive && styles.active, className), onClick: (e) => {
28
45
  context.setActiveTab(value);
29
- onClick === null || onClick === void 0 ? void 0 : onClick();
30
- }, children: children }));
46
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
47
+ }, tabIndex: isActive ? 0 : -1 }, props, { children: children })));
31
48
  }
32
- export function TabsBody({ children, className, style }) {
33
- return _jsx("div", { className: clsx(styles.tabsBody, className), style: style, children: children });
49
+ export function TabsBody(_a) {
50
+ var { children, className, style } = _a, props = __rest(_a, ["children", "className", "style"]);
51
+ return (_jsx("div", Object.assign({ className: clsx(styles.tabsBody, className), style: style }, props, { children: children })));
34
52
  }
35
- export function TabsContent({ value, children, className }) {
53
+ export function TabsContent(_a) {
54
+ var { value, children, className } = _a, props = __rest(_a, ["value", "children", "className"]);
36
55
  const context = useContext(TabsContext);
37
56
  if (!context)
38
- throw new Error('TabsContent must be used within Tabs');
39
- if (context.activeTab !== value)
57
+ throw new Error("TabsContent must be used within Tabs");
58
+ const isActive = context.activeTab === value;
59
+ const triggerId = `tabs-trigger-${context.baseId}-${value}`;
60
+ const contentId = `tabs-content-${context.baseId}-${value}`;
61
+ if (!isActive)
40
62
  return null;
41
- return _jsx("div", { className: clsx(styles.tabsContent, className), children: children });
63
+ return (_jsx("div", Object.assign({ id: contentId, role: "tabpanel", "aria-labelledby": triggerId, tabIndex: 0, className: clsx(styles.tabsContent, className) }, props, { children: children })));
42
64
  }