@compa11y/react 0.1.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/LICENSE +21 -0
- package/README.md +252 -0
- package/dist/chunk-2S4C6FGA.js +380 -0
- package/dist/chunk-2S4C6FGA.js.map +1 -0
- package/dist/chunk-52J4Z3QD.cjs +45 -0
- package/dist/chunk-52J4Z3QD.cjs.map +1 -0
- package/dist/chunk-C7QK2I7H.js +373 -0
- package/dist/chunk-C7QK2I7H.js.map +1 -0
- package/dist/chunk-D2UMS62N.cjs +245 -0
- package/dist/chunk-D2UMS62N.cjs.map +1 -0
- package/dist/chunk-E265U2RK.js +234 -0
- package/dist/chunk-E265U2RK.js.map +1 -0
- package/dist/chunk-E4XJRXWM.js +215 -0
- package/dist/chunk-E4XJRXWM.js.map +1 -0
- package/dist/chunk-GDLOJH6K.cjs +110 -0
- package/dist/chunk-GDLOJH6K.cjs.map +1 -0
- package/dist/chunk-IR46CNNY.cjs +329 -0
- package/dist/chunk-IR46CNNY.cjs.map +1 -0
- package/dist/chunk-JXYOE7SH.js +103 -0
- package/dist/chunk-JXYOE7SH.js.map +1 -0
- package/dist/chunk-O3YYQZ5O.js +317 -0
- package/dist/chunk-O3YYQZ5O.js.map +1 -0
- package/dist/chunk-OIVTOU4Z.cjs +386 -0
- package/dist/chunk-OIVTOU4Z.cjs.map +1 -0
- package/dist/chunk-OND5B7UG.js +85 -0
- package/dist/chunk-OND5B7UG.js.map +1 -0
- package/dist/chunk-R4FR6M6I.cjs +383 -0
- package/dist/chunk-R4FR6M6I.cjs.map +1 -0
- package/dist/chunk-RBDQCIS7.cjs +89 -0
- package/dist/chunk-RBDQCIS7.cjs.map +1 -0
- package/dist/chunk-SOBS7MIH.cjs +220 -0
- package/dist/chunk-SOBS7MIH.cjs.map +1 -0
- package/dist/chunk-WURPAE3R.js +41 -0
- package/dist/chunk-WURPAE3R.js.map +1 -0
- package/dist/components/combobox/index.cjs +31 -0
- package/dist/components/combobox/index.cjs.map +1 -0
- package/dist/components/combobox/index.d.cts +55 -0
- package/dist/components/combobox/index.d.ts +55 -0
- package/dist/components/combobox/index.js +6 -0
- package/dist/components/combobox/index.js.map +1 -0
- package/dist/components/dialog/index.cjs +46 -0
- package/dist/components/dialog/index.cjs.map +1 -0
- package/dist/components/dialog/index.d.cts +84 -0
- package/dist/components/dialog/index.d.ts +84 -0
- package/dist/components/dialog/index.js +5 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/menu/index.cjs +46 -0
- package/dist/components/menu/index.cjs.map +1 -0
- package/dist/components/menu/index.d.cts +80 -0
- package/dist/components/menu/index.d.ts +80 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/menu/index.js.map +1 -0
- package/dist/components/tabs/index.cjs +35 -0
- package/dist/components/tabs/index.cjs.map +1 -0
- package/dist/components/tabs/index.d.cts +65 -0
- package/dist/components/tabs/index.d.ts +65 -0
- package/dist/components/tabs/index.js +6 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/toast/index.cjs +24 -0
- package/dist/components/toast/index.cjs.map +1 -0
- package/dist/components/toast/index.d.cts +49 -0
- package/dist/components/toast/index.d.ts +49 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/index.js.map +1 -0
- package/dist/index.cjs +702 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +402 -0
- package/dist/index.d.ts +402 -0
- package/dist/index.js +430 -0
- package/dist/index.js.map +1 -0
- package/package.json +99 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var reactDom = require('react-dom');
|
|
5
|
+
var core = require('@compa11y/core');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
// src/components/toast/toast.tsx
|
|
9
|
+
var ToastContext = react.createContext(null);
|
|
10
|
+
function useToast() {
|
|
11
|
+
const context = react.useContext(ToastContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new Error("useToast must be used within a ToastProvider");
|
|
14
|
+
}
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
function ToastProvider({
|
|
18
|
+
children,
|
|
19
|
+
duration = 5e3,
|
|
20
|
+
maxToasts = 5
|
|
21
|
+
}) {
|
|
22
|
+
const [toasts, setToasts] = react.useState([]);
|
|
23
|
+
const toastIdCounter = react.useRef(0);
|
|
24
|
+
const addToast = react.useCallback(
|
|
25
|
+
(toast) => {
|
|
26
|
+
const id = `toast-${++toastIdCounter.current}`;
|
|
27
|
+
const newToast = {
|
|
28
|
+
...toast,
|
|
29
|
+
id,
|
|
30
|
+
duration: toast.duration ?? duration
|
|
31
|
+
};
|
|
32
|
+
setToasts((prev) => {
|
|
33
|
+
const updated = [...prev, newToast];
|
|
34
|
+
return updated.slice(-maxToasts);
|
|
35
|
+
});
|
|
36
|
+
const message = toast.title ? `${toast.title}. ${toast.description || ""}` : toast.description || "";
|
|
37
|
+
if (toast.type === "error") {
|
|
38
|
+
core.announceAssertive(message);
|
|
39
|
+
} else {
|
|
40
|
+
core.announce(message, { politeness: "polite" });
|
|
41
|
+
}
|
|
42
|
+
return id;
|
|
43
|
+
},
|
|
44
|
+
[duration, maxToasts]
|
|
45
|
+
);
|
|
46
|
+
const removeToast = react.useCallback((id) => {
|
|
47
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
48
|
+
}, []);
|
|
49
|
+
const updateToast = react.useCallback(
|
|
50
|
+
(id, updates) => {
|
|
51
|
+
setToasts(
|
|
52
|
+
(prev) => prev.map((t) => t.id === id ? { ...t, ...updates } : t)
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
[]
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
|
+
ToastContext.Provider,
|
|
59
|
+
{
|
|
60
|
+
value: { toasts, addToast, removeToast, updateToast },
|
|
61
|
+
children
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
var positionStyles = {
|
|
66
|
+
"top-left": { top: 0, left: 0 },
|
|
67
|
+
"top-center": { top: 0, left: "50%", transform: "translateX(-50%)" },
|
|
68
|
+
"top-right": { top: 0, right: 0 },
|
|
69
|
+
"bottom-left": { bottom: 0, left: 0 },
|
|
70
|
+
"bottom-center": { bottom: 0, left: "50%", transform: "translateX(-50%)" },
|
|
71
|
+
"bottom-right": { bottom: 0, right: 0 }
|
|
72
|
+
};
|
|
73
|
+
var ToastViewport = react.forwardRef(
|
|
74
|
+
function ToastViewport2({
|
|
75
|
+
position = "bottom-right",
|
|
76
|
+
label = "Notifications",
|
|
77
|
+
style,
|
|
78
|
+
children,
|
|
79
|
+
...props
|
|
80
|
+
}, ref) {
|
|
81
|
+
const { toasts, removeToast } = useToast();
|
|
82
|
+
const viewport = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
ref,
|
|
86
|
+
role: "region",
|
|
87
|
+
"aria-label": label,
|
|
88
|
+
"aria-live": "polite",
|
|
89
|
+
"aria-relevant": "additions removals",
|
|
90
|
+
tabIndex: -1,
|
|
91
|
+
style: {
|
|
92
|
+
position: "fixed",
|
|
93
|
+
zIndex: 9999,
|
|
94
|
+
padding: "1rem",
|
|
95
|
+
display: "flex",
|
|
96
|
+
flexDirection: "column",
|
|
97
|
+
gap: "0.5rem",
|
|
98
|
+
...positionStyles[position],
|
|
99
|
+
...style
|
|
100
|
+
},
|
|
101
|
+
"data-compa11y-toast-viewport": true,
|
|
102
|
+
"data-position": position,
|
|
103
|
+
...props,
|
|
104
|
+
children: [
|
|
105
|
+
toasts.map((toast) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
ToastItem,
|
|
107
|
+
{
|
|
108
|
+
toast,
|
|
109
|
+
onClose: () => removeToast(toast.id)
|
|
110
|
+
},
|
|
111
|
+
toast.id
|
|
112
|
+
)),
|
|
113
|
+
children
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
return reactDom.createPortal(viewport, document.body);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
function ToastItem({ toast, onClose }) {
|
|
121
|
+
const [isVisible, setIsVisible] = react.useState(true);
|
|
122
|
+
const [, setIsPaused] = react.useState(false);
|
|
123
|
+
const timerRef = react.useRef(null);
|
|
124
|
+
const remainingRef = react.useRef(toast.duration || 5e3);
|
|
125
|
+
const startTimeRef = react.useRef(Date.now());
|
|
126
|
+
const startTimer = react.useCallback(() => {
|
|
127
|
+
if (toast.duration === 0) return;
|
|
128
|
+
startTimeRef.current = Date.now();
|
|
129
|
+
timerRef.current = setTimeout(() => {
|
|
130
|
+
setIsVisible(false);
|
|
131
|
+
setTimeout(onClose, 200);
|
|
132
|
+
}, remainingRef.current);
|
|
133
|
+
}, [toast.duration, onClose]);
|
|
134
|
+
const pauseTimer = react.useCallback(() => {
|
|
135
|
+
if (timerRef.current) {
|
|
136
|
+
clearTimeout(timerRef.current);
|
|
137
|
+
remainingRef.current -= Date.now() - startTimeRef.current;
|
|
138
|
+
}
|
|
139
|
+
}, []);
|
|
140
|
+
react.useEffect(() => {
|
|
141
|
+
startTimer();
|
|
142
|
+
return () => {
|
|
143
|
+
if (timerRef.current) {
|
|
144
|
+
clearTimeout(timerRef.current);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}, [startTimer]);
|
|
148
|
+
const handleMouseEnter = () => {
|
|
149
|
+
setIsPaused(true);
|
|
150
|
+
pauseTimer();
|
|
151
|
+
};
|
|
152
|
+
const handleMouseLeave = () => {
|
|
153
|
+
setIsPaused(false);
|
|
154
|
+
startTimer();
|
|
155
|
+
};
|
|
156
|
+
const handleKeyDown = (event) => {
|
|
157
|
+
if (event.key === "Escape") {
|
|
158
|
+
onClose();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
role: "alert",
|
|
165
|
+
"aria-atomic": "true",
|
|
166
|
+
tabIndex: 0,
|
|
167
|
+
onMouseEnter: handleMouseEnter,
|
|
168
|
+
onMouseLeave: handleMouseLeave,
|
|
169
|
+
onKeyDown: handleKeyDown,
|
|
170
|
+
"data-type": toast.type,
|
|
171
|
+
"data-visible": isVisible,
|
|
172
|
+
"data-compa11y-toast": true,
|
|
173
|
+
children: [
|
|
174
|
+
toast.title && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-compa11y-toast-title": true, children: toast.title }),
|
|
175
|
+
toast.description && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-compa11y-toast-description": true, children: toast.description }),
|
|
176
|
+
toast.action && /* @__PURE__ */ jsxRuntime.jsx(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
type: "button",
|
|
180
|
+
tabIndex: 0,
|
|
181
|
+
onClick: () => {
|
|
182
|
+
toast.action?.onClick();
|
|
183
|
+
onClose();
|
|
184
|
+
},
|
|
185
|
+
"data-compa11y-toast-action": true,
|
|
186
|
+
children: toast.action.label
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
+
"button",
|
|
191
|
+
{
|
|
192
|
+
type: "button",
|
|
193
|
+
tabIndex: 0,
|
|
194
|
+
"aria-label": "Dismiss",
|
|
195
|
+
onClick: onClose,
|
|
196
|
+
"data-compa11y-toast-close": true,
|
|
197
|
+
children: "\xD7"
|
|
198
|
+
}
|
|
199
|
+
)
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
function useToastHelpers() {
|
|
205
|
+
const { addToast } = useToast();
|
|
206
|
+
return {
|
|
207
|
+
toast: addToast,
|
|
208
|
+
success: (title, description) => addToast({ type: "success", title, description }),
|
|
209
|
+
error: (title, description) => addToast({ type: "error", title, description }),
|
|
210
|
+
warning: (title, description) => addToast({ type: "warning", title, description }),
|
|
211
|
+
info: (title, description) => addToast({ type: "info", title, description })
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
exports.ToastProvider = ToastProvider;
|
|
216
|
+
exports.ToastViewport = ToastViewport;
|
|
217
|
+
exports.useToast = useToast;
|
|
218
|
+
exports.useToastHelpers = useToastHelpers;
|
|
219
|
+
//# sourceMappingURL=chunk-SOBS7MIH.cjs.map
|
|
220
|
+
//# sourceMappingURL=chunk-SOBS7MIH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/toast/toast.tsx"],"names":["createContext","useContext","useState","useRef","useCallback","announceAssertive","announce","jsx","forwardRef","ToastViewport","jsxs","createPortal","useEffect"],"mappings":";;;;;;;;AAgCA,IAAM,YAAA,GAAeA,oBAAwC,IAAI,CAAA;AAE1D,SAAS,QAAA,GAAW;AACzB,EAAA,MAAM,OAAA,GAAUC,iBAAW,YAAY,CAAA;AACvC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,8CAA8C,CAAA;AAAA,EAChE;AACA,EAAA,OAAO,OAAA;AACT;AAUO,SAAS,aAAA,CAAc;AAAA,EAC5B,QAAA;AAAA,EACA,QAAA,GAAW,GAAA;AAAA,EACX,SAAA,GAAY;AACd,CAAA,EAAuB;AACrB,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAS,CAAA,GAAIC,cAAA,CAAkB,EAAE,CAAA;AAChD,EAAA,MAAM,cAAA,GAAiBC,aAAO,CAAC,CAAA;AAE/B,EAAA,MAAM,QAAA,GAAWC,iBAAA;AAAA,IACf,CAAC,KAAA,KAAqC;AACpC,MAAA,MAAM,EAAA,GAAK,CAAA,MAAA,EAAS,EAAE,cAAA,CAAe,OAAO,CAAA,CAAA;AAC5C,MAAA,MAAM,QAAA,GAAkB;AAAA,QACtB,GAAG,KAAA;AAAA,QACH,EAAA;AAAA,QACA,QAAA,EAAU,MAAM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A,IAClD,KAAA,EAAO,CAAC,KAAA,EAAe,WAAA,KACrB,QAAA,CAAS,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAO,WAAA,EAAa,CAAA;AAAA,IAChD,OAAA,EAAS,CAAC,KAAA,EAAe,WAAA,KACvB,QAAA,CAAS,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,WAAA,EAAa,CAAA;AAAA,IAClD,IAAA,EAAM,CAAC,KAAA,EAAe,WAAA,KACpB,QAAA,CAAS,EAAE,IAAA,EAAM,MAAA,EAAQ,KAAA,EAAO,WAAA,EAAa;AAAA,GACjD;AACF","file":"chunk-SOBS7MIH.cjs","sourcesContent":["import React, {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { announce, announceAssertive } from '@compa11y/core';\nexport type ToastType = 'info' | 'success' | 'warning' | 'error';\n\nexport interface Toast {\n id: string;\n title?: string;\n description?: string;\n type: ToastType;\n duration?: number;\n action?: {\n label: string;\n onClick: () => void;\n };\n}\n\ninterface ToastContextValue {\n toasts: Toast[];\n addToast: (toast: Omit<Toast, 'id'>) => string;\n removeToast: (id: string) => void;\n updateToast: (id: string, toast: Partial<Omit<Toast, 'id'>>) => void;\n}\n\nconst ToastContext = createContext<ToastContextValue | null>(null);\n\nexport function useToast() {\n const context = useContext(ToastContext);\n if (!context) {\n throw new Error('useToast must be used within a ToastProvider');\n }\n return context;\n}\n\nexport interface ToastProviderProps {\n children: React.ReactNode;\n /** Default duration for toasts in ms */\n duration?: number;\n /** Maximum number of visible toasts */\n maxToasts?: number;\n}\n\nexport function ToastProvider({\n children,\n duration = 5000,\n maxToasts = 5,\n}: ToastProviderProps) {\n const [toasts, setToasts] = useState<Toast[]>([]);\n const toastIdCounter = useRef(0);\n\n const addToast = useCallback(\n (toast: Omit<Toast, 'id'>): string => {\n const id = `toast-${++toastIdCounter.current}`;\n const newToast: Toast = {\n ...toast,\n id,\n duration: toast.duration ?? duration,\n };\n\n setToasts((prev) => {\n const updated = [...prev, newToast];\n // Limit visible toasts\n return updated.slice(-maxToasts);\n });\n\n // Announce to screen readers\n const message = toast.title\n ? `${toast.title}. ${toast.description || ''}`\n : toast.description || '';\n\n if (toast.type === 'error') {\n announceAssertive(message);\n } else {\n announce(message, { politeness: 'polite' });\n }\n\n return id;\n },\n [duration, maxToasts]\n );\n\n const removeToast = useCallback((id: string) => {\n setToasts((prev) => prev.filter((t) => t.id !== id));\n }, []);\n\n const updateToast = useCallback(\n (id: string, updates: Partial<Omit<Toast, 'id'>>) => {\n setToasts((prev) =>\n prev.map((t) => (t.id === id ? { ...t, ...updates } : t))\n );\n },\n []\n );\n\n return (\n <ToastContext.Provider\n value={{ toasts, addToast, removeToast, updateToast }}\n >\n {children}\n </ToastContext.Provider>\n );\n}\n\nexport interface ToastViewportProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Position of the toast container */\n position?:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right';\n /** Label for screen readers */\n label?: string;\n}\n\nconst positionStyles: Record<string, React.CSSProperties> = {\n 'top-left': { top: 0, left: 0 },\n 'top-center': { top: 0, left: '50%', transform: 'translateX(-50%)' },\n 'top-right': { top: 0, right: 0 },\n 'bottom-left': { bottom: 0, left: 0 },\n 'bottom-center': { bottom: 0, left: '50%', transform: 'translateX(-50%)' },\n 'bottom-right': { bottom: 0, right: 0 },\n};\n\nexport const ToastViewport = forwardRef<HTMLDivElement, ToastViewportProps>(\n function ToastViewport(\n {\n position = 'bottom-right',\n label = 'Notifications',\n style,\n children,\n ...props\n },\n ref\n ) {\n const { toasts, removeToast } = useToast();\n\n const viewport = (\n <div\n ref={ref}\n role=\"region\"\n aria-label={label}\n aria-live=\"polite\"\n aria-relevant=\"additions removals\"\n tabIndex={-1}\n style={{\n position: 'fixed',\n zIndex: 9999,\n padding: '1rem',\n display: 'flex',\n flexDirection: 'column',\n gap: '0.5rem',\n ...positionStyles[position],\n ...style,\n }}\n data-compa11y-toast-viewport\n data-position={position}\n {...props}\n >\n {toasts.map((toast) => (\n <ToastItem\n key={toast.id}\n toast={toast}\n onClose={() => removeToast(toast.id)}\n />\n ))}\n {children}\n </div>\n );\n\n return createPortal(viewport, document.body);\n }\n);\n\ninterface ToastItemProps {\n toast: Toast;\n onClose: () => void;\n}\n\nfunction ToastItem({ toast, onClose }: ToastItemProps) {\n const [isVisible, setIsVisible] = useState(true);\n const [, setIsPaused] = useState(false);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const remainingRef = useRef(toast.duration || 5000);\n const startTimeRef = useRef(Date.now());\n\n const startTimer = useCallback(() => {\n if (toast.duration === 0) return; // Infinite duration\n\n startTimeRef.current = Date.now();\n timerRef.current = setTimeout(() => {\n setIsVisible(false);\n setTimeout(onClose, 200); // Allow exit animation\n }, remainingRef.current);\n }, [toast.duration, onClose]);\n\n const pauseTimer = useCallback(() => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n remainingRef.current -= Date.now() - startTimeRef.current;\n }\n }, []);\n\n useEffect(() => {\n startTimer();\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, [startTimer]);\n\n const handleMouseEnter = () => {\n setIsPaused(true);\n pauseTimer();\n };\n\n const handleMouseLeave = () => {\n setIsPaused(false);\n startTimer();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (event.key === 'Escape') {\n onClose();\n }\n };\n\n return (\n <div\n role=\"alert\"\n aria-atomic=\"true\"\n tabIndex={0}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onKeyDown={handleKeyDown}\n data-type={toast.type}\n data-visible={isVisible}\n data-compa11y-toast\n >\n {toast.title && <div data-compa11y-toast-title>{toast.title}</div>}\n {toast.description && (\n <div data-compa11y-toast-description>{toast.description}</div>\n )}\n {toast.action && (\n <button\n type=\"button\"\n // Safari fix: Ensure button is in tab order\n tabIndex={0}\n onClick={() => {\n toast.action?.onClick();\n onClose();\n }}\n data-compa11y-toast-action\n >\n {toast.action.label}\n </button>\n )}\n <button\n type=\"button\"\n // Safari fix: Ensure button is in tab order\n tabIndex={0}\n aria-label=\"Dismiss\"\n onClick={onClose}\n data-compa11y-toast-close\n >\n ×\n </button>\n </div>\n );\n}\n\n/**\n * Hook for common toast patterns\n */\nexport function useToastHelpers() {\n const { addToast } = useToast();\n\n return {\n toast: addToast,\n success: (title: string, description?: string) =>\n addToast({ type: 'success', title, description }),\n error: (title: string, description?: string) =>\n addToast({ type: 'error', title, description }),\n warning: (title: string, description?: string) =>\n addToast({ type: 'warning', title, description }),\n info: (title: string, description?: string) =>\n addToast({ type: 'info', title, description }),\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useId as useId$1, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
// src/hooks/use-id.ts
|
|
4
|
+
function useId(prefix) {
|
|
5
|
+
const reactId = useId$1();
|
|
6
|
+
return useMemo(() => {
|
|
7
|
+
const cleanId = reactId.replace(/:/g, "");
|
|
8
|
+
return prefix ? `compa11y-${prefix}-${cleanId}` : `compa11y-${cleanId}`;
|
|
9
|
+
}, [reactId, prefix]);
|
|
10
|
+
}
|
|
11
|
+
function useIds(parts, prefix) {
|
|
12
|
+
const baseId = useId(prefix);
|
|
13
|
+
return useMemo(() => {
|
|
14
|
+
const ids = {};
|
|
15
|
+
for (const part of parts) {
|
|
16
|
+
ids[part] = `${baseId}-${part}`;
|
|
17
|
+
}
|
|
18
|
+
return ids;
|
|
19
|
+
}, [baseId, parts]);
|
|
20
|
+
}
|
|
21
|
+
function useIdScope(componentName) {
|
|
22
|
+
const scopeId = useId(componentName);
|
|
23
|
+
return useMemo(
|
|
24
|
+
() => ({
|
|
25
|
+
id: scopeId,
|
|
26
|
+
generate: (suffix) => `${scopeId}-${suffix}`,
|
|
27
|
+
generateMultiple: (parts) => {
|
|
28
|
+
const ids = {};
|
|
29
|
+
for (const part of parts) {
|
|
30
|
+
ids[part] = `${scopeId}-${part}`;
|
|
31
|
+
}
|
|
32
|
+
return ids;
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
[scopeId]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { useId, useIdScope, useIds };
|
|
40
|
+
//# sourceMappingURL=chunk-WURPAE3R.js.map
|
|
41
|
+
//# sourceMappingURL=chunk-WURPAE3R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-id.ts"],"names":["useReactId"],"mappings":";;;AAOO,SAAS,MAAM,MAAA,EAAyB;AAE7C,EAAA,MAAM,UAAUA,OAAA,EAAW;AAE3B,EAAA,OAAO,QAAQ,MAAM;AAEnB,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,CAAQ,IAAA,EAAM,EAAE,CAAA;AACxC,IAAA,OAAO,SAAS,CAAA,SAAA,EAAY,MAAM,IAAI,OAAO,CAAA,CAAA,GAAK,YAAY,OAAO,CAAA,CAAA;AAAA,EACvE,CAAA,EAAG,CAAC,OAAA,EAAS,MAAM,CAAC,CAAA;AACtB;AAKO,SAAS,MAAA,CACd,OACA,MAAA,EAC2B;AAC3B,EAAA,MAAM,MAAA,GAAS,MAAM,MAAM,CAAA;AAE3B,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,MAAM,MAAM,EAAC;AACb,IAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,MAAA,GAAA,CAAI,IAAI,CAAA,GAAI,CAAA,EAAG,MAAM,IAAI,IAAI,CAAA,CAAA;AAAA,IAC/B;AACA,IAAA,OAAO,GAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAA,EAAQ,KAAK,CAAC,CAAA;AACpB;AAKO,SAAS,WAAW,aAAA,EAAuB;AAChD,EAAA,MAAM,OAAA,GAAU,MAAM,aAAa,CAAA;AAEnC,EAAA,OAAO,OAAA;AAAA,IACL,OAAO;AAAA,MACL,EAAA,EAAI,OAAA;AAAA,MACJ,UAAU,CAAC,MAAA,KAAmB,CAAA,EAAG,OAAO,IAAI,MAAM,CAAA,CAAA;AAAA,MAClD,gBAAA,EAAkB,CAA8B,KAAA,KAAa;AAC3D,QAAA,MAAM,MAAM,EAAC;AACb,QAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,UAAA,GAAA,CAAI,IAAI,CAAA,GAAI,CAAA,EAAG,OAAO,IAAI,IAAI,CAAA,CAAA;AAAA,QAChC;AACA,QAAA,OAAO,GAAA;AAAA,MACT;AAAA,KACF,CAAA;AAAA,IACA,CAAC,OAAO;AAAA,GACV;AACF","file":"chunk-WURPAE3R.js","sourcesContent":["import { useId as useReactId, useMemo } from 'react';\n\n/**\n * Generate a unique ID for accessibility purposes\n *\n * Uses React's useId when available, with a fallback for SSR\n */\nexport function useId(prefix?: string): string {\n // Use React 18's useId as the base\n const reactId = useReactId();\n\n return useMemo(() => {\n // Clean up React's ID format (removes colons)\n const cleanId = reactId.replace(/:/g, '');\n return prefix ? `compa11y-${prefix}-${cleanId}` : `compa11y-${cleanId}`;\n }, [reactId, prefix]);\n}\n\n/**\n * Generate multiple related IDs for a component\n */\nexport function useIds<T extends readonly string[]>(\n parts: T,\n prefix?: string\n): Record<T[number], string> {\n const baseId = useId(prefix);\n\n return useMemo(() => {\n const ids = {} as Record<string, string>;\n for (const part of parts) {\n ids[part] = `${baseId}-${part}`;\n }\n return ids as Record<T[number], string>;\n }, [baseId, parts]);\n}\n\n/**\n * Create a scoped ID generator for complex components\n */\nexport function useIdScope(componentName: string) {\n const scopeId = useId(componentName);\n\n return useMemo(\n () => ({\n id: scopeId,\n generate: (suffix: string) => `${scopeId}-${suffix}`,\n generateMultiple: <T extends readonly string[]>(parts: T) => {\n const ids = {} as Record<string, string>;\n for (const part of parts) {\n ids[part] = `${scopeId}-${part}`;\n }\n return ids as Record<T[number], string>;\n },\n }),\n [scopeId]\n );\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkOIVTOU4Z_cjs = require('../../chunk-OIVTOU4Z.cjs');
|
|
4
|
+
require('../../chunk-RBDQCIS7.cjs');
|
|
5
|
+
require('../../chunk-GDLOJH6K.cjs');
|
|
6
|
+
require('../../chunk-52J4Z3QD.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "Combobox", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkOIVTOU4Z_cjs.Combobox; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "ComboboxCompound", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkOIVTOU4Z_cjs.ComboboxCompound; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ComboboxInput", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkOIVTOU4Z_cjs.ComboboxInput; }
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "ComboboxListbox", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return chunkOIVTOU4Z_cjs.ComboboxListbox; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ComboboxOption", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunkOIVTOU4Z_cjs.ComboboxOption; }
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.cjs.map
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface ComboboxProps {
|
|
5
|
+
/** List of options */
|
|
6
|
+
options: ComboboxOption[];
|
|
7
|
+
/** Currently selected value */
|
|
8
|
+
value?: string | null;
|
|
9
|
+
/** Called when selection changes */
|
|
10
|
+
onValueChange?: (value: string | null) => void;
|
|
11
|
+
/** Called when input changes */
|
|
12
|
+
onInputChange?: (value: string) => void;
|
|
13
|
+
/** Default input value */
|
|
14
|
+
defaultInputValue?: string;
|
|
15
|
+
/** Whether the combobox is disabled */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Placeholder text */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/** Custom filter function */
|
|
20
|
+
filterFn?: (option: ComboboxOption, inputValue: string) => boolean;
|
|
21
|
+
/** Accessible label */
|
|
22
|
+
'aria-label'?: string;
|
|
23
|
+
/** ID of labelling element */
|
|
24
|
+
'aria-labelledby'?: string;
|
|
25
|
+
children: React__default.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
declare function Combobox({ options, value: controlledValue, onValueChange, onInputChange, defaultInputValue, disabled, filterFn, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, children, }: ComboboxProps): react_jsx_runtime.JSX.Element;
|
|
28
|
+
interface ComboboxInputProps extends Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
|
|
29
|
+
/** Show clear button */
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare const ComboboxInput: React__default.ForwardRefExoticComponent<ComboboxInputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
33
|
+
interface ComboboxListboxProps extends React__default.HTMLAttributes<HTMLUListElement> {
|
|
34
|
+
/** Render when no options match */
|
|
35
|
+
emptyMessage?: React__default.ReactNode;
|
|
36
|
+
children?: React__default.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
declare const ComboboxListbox: React__default.ForwardRefExoticComponent<ComboboxListboxProps & React__default.RefAttributes<HTMLUListElement>>;
|
|
39
|
+
interface ComboboxOptionProps extends React__default.LiHTMLAttributes<HTMLLIElement> {
|
|
40
|
+
option: ComboboxOption;
|
|
41
|
+
index: number;
|
|
42
|
+
}
|
|
43
|
+
interface ComboboxOption {
|
|
44
|
+
value: string;
|
|
45
|
+
label: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
}
|
|
48
|
+
declare const ComboboxOption: React__default.ForwardRefExoticComponent<ComboboxOptionProps & React__default.RefAttributes<HTMLLIElement>>;
|
|
49
|
+
declare const ComboboxCompound: typeof Combobox & {
|
|
50
|
+
Input: React__default.ForwardRefExoticComponent<ComboboxInputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
51
|
+
Listbox: React__default.ForwardRefExoticComponent<ComboboxListboxProps & React__default.RefAttributes<HTMLUListElement>>;
|
|
52
|
+
Option: React__default.ForwardRefExoticComponent<ComboboxOptionProps & React__default.RefAttributes<HTMLLIElement>>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { Combobox, ComboboxCompound, ComboboxInput, type ComboboxInputProps, ComboboxListbox, type ComboboxListboxProps, ComboboxOption, type ComboboxOptionProps, ComboboxOption as ComboboxOptionType, type ComboboxProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
interface ComboboxProps {
|
|
5
|
+
/** List of options */
|
|
6
|
+
options: ComboboxOption[];
|
|
7
|
+
/** Currently selected value */
|
|
8
|
+
value?: string | null;
|
|
9
|
+
/** Called when selection changes */
|
|
10
|
+
onValueChange?: (value: string | null) => void;
|
|
11
|
+
/** Called when input changes */
|
|
12
|
+
onInputChange?: (value: string) => void;
|
|
13
|
+
/** Default input value */
|
|
14
|
+
defaultInputValue?: string;
|
|
15
|
+
/** Whether the combobox is disabled */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Placeholder text */
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
/** Custom filter function */
|
|
20
|
+
filterFn?: (option: ComboboxOption, inputValue: string) => boolean;
|
|
21
|
+
/** Accessible label */
|
|
22
|
+
'aria-label'?: string;
|
|
23
|
+
/** ID of labelling element */
|
|
24
|
+
'aria-labelledby'?: string;
|
|
25
|
+
children: React__default.ReactNode;
|
|
26
|
+
}
|
|
27
|
+
declare function Combobox({ options, value: controlledValue, onValueChange, onInputChange, defaultInputValue, disabled, filterFn, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, children, }: ComboboxProps): react_jsx_runtime.JSX.Element;
|
|
28
|
+
interface ComboboxInputProps extends Omit<React__default.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
|
|
29
|
+
/** Show clear button */
|
|
30
|
+
clearable?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare const ComboboxInput: React__default.ForwardRefExoticComponent<ComboboxInputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
33
|
+
interface ComboboxListboxProps extends React__default.HTMLAttributes<HTMLUListElement> {
|
|
34
|
+
/** Render when no options match */
|
|
35
|
+
emptyMessage?: React__default.ReactNode;
|
|
36
|
+
children?: React__default.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
declare const ComboboxListbox: React__default.ForwardRefExoticComponent<ComboboxListboxProps & React__default.RefAttributes<HTMLUListElement>>;
|
|
39
|
+
interface ComboboxOptionProps extends React__default.LiHTMLAttributes<HTMLLIElement> {
|
|
40
|
+
option: ComboboxOption;
|
|
41
|
+
index: number;
|
|
42
|
+
}
|
|
43
|
+
interface ComboboxOption {
|
|
44
|
+
value: string;
|
|
45
|
+
label: string;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
}
|
|
48
|
+
declare const ComboboxOption: React__default.ForwardRefExoticComponent<ComboboxOptionProps & React__default.RefAttributes<HTMLLIElement>>;
|
|
49
|
+
declare const ComboboxCompound: typeof Combobox & {
|
|
50
|
+
Input: React__default.ForwardRefExoticComponent<ComboboxInputProps & React__default.RefAttributes<HTMLInputElement>>;
|
|
51
|
+
Listbox: React__default.ForwardRefExoticComponent<ComboboxListboxProps & React__default.RefAttributes<HTMLUListElement>>;
|
|
52
|
+
Option: React__default.ForwardRefExoticComponent<ComboboxOptionProps & React__default.RefAttributes<HTMLLIElement>>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { Combobox, ComboboxCompound, ComboboxInput, type ComboboxInputProps, ComboboxListbox, type ComboboxListboxProps, ComboboxOption, type ComboboxOptionProps, ComboboxOption as ComboboxOptionType, type ComboboxProps };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Combobox, ComboboxCompound, ComboboxInput, ComboboxListbox, ComboboxOption } from '../../chunk-2S4C6FGA.js';
|
|
2
|
+
import '../../chunk-OND5B7UG.js';
|
|
3
|
+
import '../../chunk-JXYOE7SH.js';
|
|
4
|
+
import '../../chunk-WURPAE3R.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkIR46CNNY_cjs = require('../../chunk-IR46CNNY.cjs');
|
|
4
|
+
require('../../chunk-RBDQCIS7.cjs');
|
|
5
|
+
require('../../chunk-52J4Z3QD.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "Dialog", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkIR46CNNY_cjs.Dialog; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "DialogActions", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkIR46CNNY_cjs.DialogActions; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DialogClose", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkIR46CNNY_cjs.DialogClose; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "DialogCompound", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkIR46CNNY_cjs.DialogCompound; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "DialogContent", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkIR46CNNY_cjs.DialogContent; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "DialogDescription", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkIR46CNNY_cjs.DialogDescription; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "DialogTitle", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunkIR46CNNY_cjs.DialogTitle; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "DialogTrigger", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return chunkIR46CNNY_cjs.DialogTrigger; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "useDialogContext", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return chunkIR46CNNY_cjs.useDialogContext; }
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.cjs.map
|
|
46
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface DialogProps {
|
|
4
|
+
/** Whether the dialog is open */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** Called when the dialog should close */
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
/** The dialog content */
|
|
9
|
+
children: React__default.ReactNode;
|
|
10
|
+
/** Custom class name */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Element to focus when dialog opens */
|
|
13
|
+
initialFocus?: React__default.RefObject<HTMLElement>;
|
|
14
|
+
/** Whether clicking outside closes the dialog */
|
|
15
|
+
closeOnOutsideClick?: boolean;
|
|
16
|
+
/** Whether pressing Escape closes the dialog */
|
|
17
|
+
closeOnEscape?: boolean;
|
|
18
|
+
/** Portal container (defaults to document.body) */
|
|
19
|
+
container?: HTMLElement;
|
|
20
|
+
/** Accessible label (required if no DialogTitle) */
|
|
21
|
+
'aria-label'?: string;
|
|
22
|
+
/** ID of element that labels the dialog */
|
|
23
|
+
'aria-labelledby'?: string;
|
|
24
|
+
/** Remove default styles to allow full customization via className */
|
|
25
|
+
unstyled?: boolean;
|
|
26
|
+
}
|
|
27
|
+
declare function Dialog({ open, onOpenChange, children, className, initialFocus, closeOnOutsideClick, closeOnEscape, container, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, unstyled, }: DialogProps): React__default.ReactPortal | null;
|
|
28
|
+
interface DialogTriggerProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
29
|
+
children: React__default.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
declare const DialogTrigger: React__default.ForwardRefExoticComponent<DialogTriggerProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
interface DialogTitleProps extends React__default.HTMLAttributes<HTMLHeadingElement> {
|
|
33
|
+
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
34
|
+
children: React__default.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare const DialogTitle: React__default.ForwardRefExoticComponent<DialogTitleProps & React__default.RefAttributes<HTMLHeadingElement>>;
|
|
37
|
+
interface DialogDescriptionProps extends React__default.HTMLAttributes<HTMLParagraphElement> {
|
|
38
|
+
children: React__default.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
declare const DialogDescription: React__default.ForwardRefExoticComponent<DialogDescriptionProps & React__default.RefAttributes<HTMLParagraphElement>>;
|
|
41
|
+
interface DialogCloseProps extends React__default.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
42
|
+
children?: React__default.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
declare const DialogClose: React__default.ForwardRefExoticComponent<DialogCloseProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
interface DialogContentProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
46
|
+
children: React__default.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
declare const DialogContent: React__default.ForwardRefExoticComponent<DialogContentProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
49
|
+
interface DialogActionsProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
50
|
+
children: React__default.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
declare const DialogActions: React__default.ForwardRefExoticComponent<DialogActionsProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
53
|
+
declare const DialogCompound: typeof Dialog & {
|
|
54
|
+
Trigger: React__default.ForwardRefExoticComponent<DialogTriggerProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
55
|
+
Title: React__default.ForwardRefExoticComponent<DialogTitleProps & React__default.RefAttributes<HTMLHeadingElement>>;
|
|
56
|
+
Description: React__default.ForwardRefExoticComponent<DialogDescriptionProps & React__default.RefAttributes<HTMLParagraphElement>>;
|
|
57
|
+
Close: React__default.ForwardRefExoticComponent<DialogCloseProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
58
|
+
Content: React__default.ForwardRefExoticComponent<DialogContentProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
59
|
+
Actions: React__default.ForwardRefExoticComponent<DialogActionsProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
interface DialogContextValue {
|
|
63
|
+
/** Whether the dialog is open */
|
|
64
|
+
isOpen: boolean;
|
|
65
|
+
/** Close the dialog */
|
|
66
|
+
close: () => void;
|
|
67
|
+
/** ID for the dialog element */
|
|
68
|
+
dialogId: string;
|
|
69
|
+
/** ID for the title element */
|
|
70
|
+
titleId: string;
|
|
71
|
+
/** ID for the description element */
|
|
72
|
+
descriptionId: string;
|
|
73
|
+
/** Whether the dialog has a visible title */
|
|
74
|
+
hasTitle: boolean;
|
|
75
|
+
/** Whether the dialog has a visible description */
|
|
76
|
+
hasDescription: boolean;
|
|
77
|
+
/** Set whether title is rendered */
|
|
78
|
+
setHasTitle: (value: boolean) => void;
|
|
79
|
+
/** Set whether description is rendered */
|
|
80
|
+
setHasDescription: (value: boolean) => void;
|
|
81
|
+
}
|
|
82
|
+
declare function useDialogContext(): DialogContextValue;
|
|
83
|
+
|
|
84
|
+
export { Dialog, DialogActions, type DialogActionsProps, DialogClose, type DialogCloseProps, DialogCompound, DialogContent, type DialogContentProps, type DialogContextValue, DialogDescription, type DialogDescriptionProps, type DialogProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, useDialogContext };
|