@dreamtree-org/twreact-ui 1.3.9 → 1.3.10
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/README.md +2 -0
- package/dist/ai-schema.json +19 -8
- package/dist/components/blocks/AppShell.d.ts.map +1 -1
- package/dist/components/core/Accordion.d.ts.map +1 -1
- package/dist/components/core/ColorPicker.d.ts.map +1 -1
- package/dist/components/core/DatePicker.d.ts.map +1 -1
- package/dist/components/core/Form.d.ts.map +1 -1
- package/dist/components/core/Input.d.ts.map +1 -1
- package/dist/components/core/PriceRangePicker.d.ts +0 -29
- package/dist/components/core/PriceRangePicker.d.ts.map +1 -1
- package/dist/components/core/Radio.d.ts.map +1 -1
- package/dist/components/core/Rate.d.ts.map +1 -1
- package/dist/components/core/RoundedTag.d.ts.map +1 -1
- package/dist/components/core/Table/ColumnMenu.d.ts.map +1 -1
- package/dist/components/core/Table/Pagination.d.ts.map +1 -1
- package/dist/components/core/Table/TableRow.d.ts.map +1 -1
- package/dist/components/core/Table/helpers.d.ts +2 -0
- package/dist/components/core/Table/helpers.d.ts.map +1 -1
- package/dist/components/core/Tabs.d.ts.map +1 -1
- package/dist/components/core/TextToSpeech.d.ts +2 -7
- package/dist/components/core/TextToSpeech.d.ts.map +1 -1
- package/dist/components/core/Tooltip.d.ts.map +1 -1
- package/dist/components/feedback/Alert.d.ts.map +1 -1
- package/dist/components/feedback/Dialog.d.ts.map +1 -1
- package/dist/components/feedback/Toast.d.ts.map +1 -1
- package/dist/components/navigation/Sidebar.d.ts.map +1 -1
- package/dist/components/utility/Avatar.d.ts.map +1 -1
- package/dist/components/utility/Carousel.d.ts.map +1 -1
- package/dist/esm/components/blocks/AppShell.js +24 -18
- package/dist/esm/components/core/Accordion.js +40 -9
- package/dist/esm/components/core/ColorPicker.js +19 -7
- package/dist/esm/components/core/DatePicker.js +97 -58
- package/dist/esm/components/core/Form.js +35 -8
- package/dist/esm/components/core/Input.js +3 -1
- package/dist/esm/components/core/PriceRangePicker.js +205 -218
- package/dist/esm/components/core/Radio.js +36 -6
- package/dist/esm/components/core/Rate.js +41 -50
- package/dist/esm/components/core/RoundedTag.js +25 -8
- package/dist/esm/components/core/Table/ColumnMenu.js +2 -4
- package/dist/esm/components/core/Table/Pagination.js +15 -18
- package/dist/esm/components/core/Table/TableRow.js +2 -2
- package/dist/esm/components/core/Table/helpers.js +33 -1
- package/dist/esm/components/core/Tabs.js +6 -5
- package/dist/esm/components/core/TextToSpeech.js +121 -28
- package/dist/esm/components/core/Tooltip.js +100 -28
- package/dist/esm/components/feedback/Alert.js +21 -11
- package/dist/esm/components/feedback/Dialog.js +44 -100
- package/dist/esm/components/feedback/Toast.js +24 -5
- package/dist/esm/components/navigation/Sidebar.js +13 -61
- package/dist/esm/components/utility/Avatar.js +23 -10
- package/dist/esm/components/utility/Carousel.js +34 -17
- package/dist/esm/components/utility/Pagination.js +2 -2
- package/dist/esm/hooks/useFocusTrap.js +10 -2
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1760 -1350
- package/dist/index.js +1759 -1349
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/mcp/catalog.snapshot.json +82 -52
- package/package.json +1 -1
|
@@ -3,9 +3,10 @@ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React, { useId, useMemo, useState, useRef, useImperativeHandle, useEffect, useLayoutEffect } from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
-
import { parseISO, startOfMonth, startOfWeek, endOfMonth, endOfWeek, eachDayOfInterval, startOfDay, subMonths, format, addMonths,
|
|
6
|
+
import { parseISO, startOfMonth, startOfWeek, endOfMonth, endOfWeek, eachDayOfInterval, startOfDay, isSameDay, subMonths, format, addMonths, isSameMonth, isToday, isBefore, isAfter, addDays } from 'date-fns';
|
|
7
7
|
import { cn } from '../../utils/cn.js';
|
|
8
|
-
import {
|
|
8
|
+
import { TOUCH_TARGET } from '../../utils/touchTarget.js';
|
|
9
|
+
import { ChevronLeft, ChevronRight, Calendar, X } from 'lucide-react';
|
|
9
10
|
|
|
10
11
|
var _excluded = ["value", "onChange", "placeholder", "label", "error", "helperText", "disabled", "required", "minDate", "maxDate", "className", "weekStartsOn", "portal", "displayFormat", "locale", "showClear", "closeOnSelect"];
|
|
11
12
|
var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
@@ -64,19 +65,27 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
64
65
|
setCurrentMonth = _useState4[1];
|
|
65
66
|
var datePickerRef = useRef(null);
|
|
66
67
|
var popupRef = useRef(null);
|
|
68
|
+
var triggerRef = useRef(null);
|
|
67
69
|
var gridButtonRefs = useRef([]);
|
|
68
|
-
|
|
70
|
+
// Roving tabindex: the day the user moved to with the keyboard (or focused).
|
|
71
|
+
var _useState5 = useState(null),
|
|
69
72
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
focusedDate = _useState6[0],
|
|
74
|
+
setFocusedDate = _useState6[1];
|
|
75
|
+
// Set when a keyboard action / open should move DOM focus to the active day.
|
|
76
|
+
var pendingFocusRef = useRef(false);
|
|
77
|
+
var _useState7 = useState({}),
|
|
78
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
79
|
+
popupStyle = _useState8[0],
|
|
80
|
+
setPopupStyle = _useState8[1];
|
|
72
81
|
useImperativeHandle(forwardedRef, function () {
|
|
73
82
|
return datePickerRef.current;
|
|
74
83
|
}, []);
|
|
75
84
|
// Keep currentMonth in sync with external value changes
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
prevSelected =
|
|
79
|
-
setPrevSelected =
|
|
85
|
+
var _useState9 = useState(selected),
|
|
86
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
87
|
+
prevSelected = _useState0[0],
|
|
88
|
+
setPrevSelected = _useState0[1];
|
|
80
89
|
if (selected !== prevSelected) {
|
|
81
90
|
setPrevSelected(selected);
|
|
82
91
|
if (selected) setCurrentMonth(selected);
|
|
@@ -98,7 +107,10 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
98
107
|
var handleKey = function handleKey(e) {
|
|
99
108
|
if (!isOpen) return;
|
|
100
109
|
if (e.key === "Escape") {
|
|
110
|
+
var _triggerRef$current;
|
|
111
|
+
var hadFocusInside = popupRef.current && popupRef.current.contains(document.activeElement);
|
|
101
112
|
setIsOpen(false);
|
|
113
|
+
if (hadFocusInside) (_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 || _triggerRef$current.focus();
|
|
102
114
|
}
|
|
103
115
|
};
|
|
104
116
|
document.addEventListener("keydown", handleKey);
|
|
@@ -139,62 +151,81 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
139
151
|
var handleDateSelect = function handleDateSelect(date) {
|
|
140
152
|
if (isDateDisabled(date)) return;
|
|
141
153
|
onChange === null || onChange === void 0 || onChange(date);
|
|
142
|
-
if (closeOnSelect)
|
|
154
|
+
if (closeOnSelect) {
|
|
155
|
+
var _triggerRef$current2;
|
|
156
|
+
setIsOpen(false);
|
|
157
|
+
// The focused day unmounts with the popup; keep focus on the field.
|
|
158
|
+
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 || _triggerRef$current2.focus();
|
|
159
|
+
}
|
|
143
160
|
};
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
// Roving tabindex target: exactly one enabled day in the grid is tabbable.
|
|
162
|
+
// Priority: keyboard-focused day ?? selected ?? today (if shown & enabled)
|
|
163
|
+
// ?? first enabled day of the visible month ?? first enabled grid day.
|
|
164
|
+
var isUsable = function isUsable(d) {
|
|
165
|
+
return d && isSameMonth(d, currentMonth) && !isDateDisabled(d);
|
|
166
|
+
};
|
|
167
|
+
var activeDate = null;
|
|
168
|
+
if (isUsable(focusedDate)) activeDate = focusedDate;else if (isUsable(selected)) activeDate = selected;else if (isUsable(new Date())) activeDate = new Date();else activeDate = days.find(function (d) {
|
|
169
|
+
return isUsable(d);
|
|
170
|
+
}) || days.find(function (d) {
|
|
171
|
+
return !isDateDisabled(d);
|
|
172
|
+
}) || null;
|
|
173
|
+
var activeIndex = activeDate ? days.findIndex(function (d) {
|
|
174
|
+
return isSameDay(d, activeDate);
|
|
175
|
+
}) : -1;
|
|
176
|
+
// Move DOM focus to the active day after a keyboard action / open.
|
|
177
|
+
useEffect(function () {
|
|
178
|
+
if (!isOpen || !pendingFocusRef.current) return;
|
|
179
|
+
pendingFocusRef.current = false;
|
|
180
|
+
var btn = gridButtonRefs.current[activeIndex];
|
|
147
181
|
if (btn && typeof btn.focus === "function") btn.focus();
|
|
182
|
+
});
|
|
183
|
+
var moveFocusTo = function moveFocusTo(date) {
|
|
184
|
+
if (!date || isDateDisabled(date)) return;
|
|
185
|
+
if (!isSameMonth(date, currentMonth)) setCurrentMonth(date);
|
|
186
|
+
setFocusedDate(date);
|
|
187
|
+
pendingFocusRef.current = true;
|
|
148
188
|
};
|
|
149
189
|
var handleGridKeyDown = function handleGridKeyDown(e, idx) {
|
|
190
|
+
var day = days[idx];
|
|
150
191
|
if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", "Enter"].includes(e.key)) {
|
|
151
192
|
e.preventDefault();
|
|
152
193
|
}
|
|
153
194
|
switch (e.key) {
|
|
154
195
|
case "ArrowLeft":
|
|
155
|
-
|
|
196
|
+
moveFocusTo(addDays(day, -1));
|
|
156
197
|
break;
|
|
157
198
|
case "ArrowRight":
|
|
158
|
-
|
|
199
|
+
moveFocusTo(addDays(day, 1));
|
|
159
200
|
break;
|
|
160
201
|
case "ArrowUp":
|
|
161
|
-
|
|
202
|
+
moveFocusTo(addDays(day, -7));
|
|
162
203
|
break;
|
|
163
204
|
case "ArrowDown":
|
|
164
|
-
|
|
205
|
+
moveFocusTo(addDays(day, 7));
|
|
165
206
|
break;
|
|
166
207
|
case "PageUp":
|
|
167
|
-
|
|
168
|
-
return subMonths(m, 1);
|
|
169
|
-
});
|
|
208
|
+
moveFocusTo(subMonths(day, 1));
|
|
170
209
|
break;
|
|
171
210
|
case "PageDown":
|
|
172
|
-
|
|
173
|
-
return addMonths(m, 1);
|
|
174
|
-
});
|
|
211
|
+
moveFocusTo(addMonths(day, 1));
|
|
175
212
|
break;
|
|
176
213
|
case "Home":
|
|
177
|
-
|
|
214
|
+
moveFocusTo(days[Math.floor(idx / 7) * 7]);
|
|
178
215
|
break;
|
|
179
216
|
case "End":
|
|
180
|
-
|
|
217
|
+
moveFocusTo(days[Math.min(days.length - 1, Math.floor(idx / 7) * 7 + 6)]);
|
|
181
218
|
break;
|
|
182
219
|
case "Enter":
|
|
183
|
-
if (!isDateDisabled(
|
|
220
|
+
if (!isDateDisabled(day)) handleDateSelect(day);
|
|
184
221
|
break;
|
|
185
222
|
}
|
|
186
223
|
};
|
|
187
224
|
var openAndFocusSelected = function openAndFocusSelected() {
|
|
225
|
+
setFocusedDate(null);
|
|
188
226
|
setIsOpen(true);
|
|
189
|
-
// focus
|
|
190
|
-
|
|
191
|
-
var idx = selected ? days.findIndex(function (d) {
|
|
192
|
-
return isSameDay(d, selected);
|
|
193
|
-
}) : days.findIndex(function (d) {
|
|
194
|
-
return isToday(d);
|
|
195
|
-
});
|
|
196
|
-
if (idx >= 0) focusDayAtIndex(idx);
|
|
197
|
-
}, 0);
|
|
227
|
+
// the active-day effect moves focus once the grid has rendered
|
|
228
|
+
pendingFocusRef.current = true;
|
|
198
229
|
};
|
|
199
230
|
// compute popup position so it's aware of viewport edges (top/bottom/left/right)
|
|
200
231
|
var computePopupPosition = function computePopupPosition() {
|
|
@@ -266,7 +297,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
266
297
|
className: "mb-4 flex items-center justify-between",
|
|
267
298
|
children: [jsx("button", {
|
|
268
299
|
type: "button",
|
|
269
|
-
className: "rounded-md p-1 hover:bg-gray-100",
|
|
300
|
+
className: cn("inline-flex items-center justify-center rounded-md p-1 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", TOUCH_TARGET),
|
|
270
301
|
onClick: function onClick() {
|
|
271
302
|
return setCurrentMonth(subMonths(currentMonth, 1));
|
|
272
303
|
},
|
|
@@ -279,7 +310,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
279
310
|
children: format(currentMonth, "MMMM yyyy")
|
|
280
311
|
}), jsx("button", {
|
|
281
312
|
type: "button",
|
|
282
|
-
className: "rounded-md p-1 hover:bg-gray-100",
|
|
313
|
+
className: cn("inline-flex items-center justify-center rounded-md p-1 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", TOUCH_TARGET),
|
|
283
314
|
onClick: function onClick() {
|
|
284
315
|
return setCurrentMonth(addMonths(currentMonth, 1));
|
|
285
316
|
},
|
|
@@ -321,12 +352,15 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
321
352
|
return gridButtonRefs.current[idx] = el;
|
|
322
353
|
},
|
|
323
354
|
role: "gridcell",
|
|
324
|
-
tabIndex:
|
|
325
|
-
"aria-selected": isSelected,
|
|
355
|
+
tabIndex: idx === activeIndex ? 0 : -1,
|
|
356
|
+
"aria-selected": Boolean(isSelected),
|
|
326
357
|
onKeyDown: function onKeyDown(e) {
|
|
327
358
|
return handleGridKeyDown(e, idx);
|
|
328
359
|
},
|
|
329
|
-
|
|
360
|
+
onFocus: function onFocus() {
|
|
361
|
+
if (!focusedDate || !isSameDay(focusedDate, day)) setFocusedDate(day);
|
|
362
|
+
},
|
|
363
|
+
className: cn("h-8 w-8 rounded-md text-sm transition-colors motion-reduce:transition-none focus-visible:outline-2 focus-visible:outline-offset-1", {
|
|
330
364
|
"text-primary-400": !isCurrentMonth,
|
|
331
365
|
"bg-primary-600 text-white": isSelected,
|
|
332
366
|
"bg-primary-100 text-primary-600": isTodayDate && !isSelected,
|
|
@@ -382,6 +416,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
382
416
|
ref: datePickerRef,
|
|
383
417
|
className: "relative",
|
|
384
418
|
children: [jsxs("button", _objectSpread2(_objectSpread2({
|
|
419
|
+
ref: triggerRef,
|
|
385
420
|
type: "button",
|
|
386
421
|
id: fieldId,
|
|
387
422
|
"aria-labelledby": label ? "".concat(labelId, " ").concat(valueId) : valueId,
|
|
@@ -389,7 +424,9 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
389
424
|
"aria-invalid": error ? true : undefined,
|
|
390
425
|
className: cn("flex w-full items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:cursor-not-allowed disabled:opacity-50", {
|
|
391
426
|
"border-error-500 focus:ring-error-500": error,
|
|
392
|
-
"text-primary-500": !selected
|
|
427
|
+
"text-primary-500": !selected,
|
|
428
|
+
// leave room for the sibling clear button overlaid on the field
|
|
429
|
+
"pr-16": showClear && selected
|
|
393
430
|
}, className),
|
|
394
431
|
onClick: function onClick() {
|
|
395
432
|
return isOpen ? setIsOpen(false) : openAndFocusSelected();
|
|
@@ -402,24 +439,26 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
402
439
|
className: "truncate",
|
|
403
440
|
id: valueId,
|
|
404
441
|
children: formatDisplayValue()
|
|
405
|
-
}),
|
|
406
|
-
className: "
|
|
407
|
-
|
|
408
|
-
type: "button",
|
|
409
|
-
onClick: function onClick(e) {
|
|
410
|
-
e.stopPropagation();
|
|
411
|
-
onChange === null || onChange === void 0 || onChange(null);
|
|
412
|
-
},
|
|
413
|
-
"aria-label": "Clear date",
|
|
414
|
-
className: "p-1",
|
|
415
|
-
children: jsx(X, {
|
|
416
|
-
className: "h-4 w-4 text-primary-400"
|
|
417
|
-
})
|
|
418
|
-
}), jsx(Calendar, {
|
|
419
|
-
className: "h-4 w-4 text-primary-400"
|
|
420
|
-
})]
|
|
442
|
+
}), jsx(Calendar, {
|
|
443
|
+
className: "h-4 w-4 shrink-0 text-primary-400",
|
|
444
|
+
"aria-hidden": "true"
|
|
421
445
|
})]
|
|
422
|
-
})),
|
|
446
|
+
})), showClear && selected && jsx("button", {
|
|
447
|
+
type: "button",
|
|
448
|
+
"aria-label": "Clear date",
|
|
449
|
+
disabled: disabled,
|
|
450
|
+
onClick: function onClick() {
|
|
451
|
+
var _triggerRef$current3;
|
|
452
|
+
onChange === null || onChange === void 0 || onChange(null);
|
|
453
|
+
// this button unmounts once the value clears
|
|
454
|
+
(_triggerRef$current3 = triggerRef.current) === null || _triggerRef$current3 === void 0 || _triggerRef$current3.focus();
|
|
455
|
+
},
|
|
456
|
+
className: "absolute right-9 top-1/2 inline-flex -translate-y-1/2 items-center justify-center rounded-md p-1 text-primary-400 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
457
|
+
children: jsx(X, {
|
|
458
|
+
className: "h-4 w-4",
|
|
459
|
+
"aria-hidden": "true"
|
|
460
|
+
})
|
|
461
|
+
}), isOpen && (portal ? /*#__PURE__*/ReactDOM.createPortal(calendarPopup, document.body) : calendarPopup)]
|
|
423
462
|
}), error ? jsx("p", {
|
|
424
463
|
id: errorId,
|
|
425
464
|
className: "mt-1 text-sm text-error-500",
|
|
@@ -40,6 +40,19 @@ var FieldMessage = function FieldMessage(_ref) {
|
|
|
40
40
|
}
|
|
41
41
|
return null;
|
|
42
42
|
};
|
|
43
|
+
// Static class map for field groups (DTUI-19). A dynamic `grid-cols-${n}`
|
|
44
|
+
// string is invisible to Tailwind's content scan and gets purged, so every
|
|
45
|
+
// layout is spelled out here. All layouts collapse to one column below `sm`.
|
|
46
|
+
var GRID_COLS = {
|
|
47
|
+
1: "grid-cols-1",
|
|
48
|
+
2: "grid-cols-1 sm:grid-cols-2",
|
|
49
|
+
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
|
50
|
+
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4"
|
|
51
|
+
};
|
|
52
|
+
var gridColsClass = function gridColsClass(n) {
|
|
53
|
+
var cols = Math.min(4, Math.max(1, Math.trunc(Number(n)) || 1));
|
|
54
|
+
return GRID_COLS[cols];
|
|
55
|
+
};
|
|
43
56
|
var describedByFor = function describedByFor(fieldId, error, helperText) {
|
|
44
57
|
return error ? "".concat(fieldId, "-error") : helperText ? "".concat(fieldId, "-helper") : undefined;
|
|
45
58
|
};
|
|
@@ -72,8 +85,12 @@ var Form = /*#__PURE__*/forwardRef(function Form(_ref2, ref) {
|
|
|
72
85
|
_methods$formState = methods.formState,
|
|
73
86
|
errors = _methods$formState.errors,
|
|
74
87
|
isSubmitting = _methods$formState.isSubmitting;
|
|
75
|
-
var handleFormSubmit = useCallback(
|
|
76
|
-
|
|
88
|
+
var handleFormSubmit = useCallback(
|
|
89
|
+
// Return the handler's result so react-hook-form awaits an async
|
|
90
|
+
// onSubmit and `isSubmitting` (the submit button's loading state)
|
|
91
|
+
// reflects the real work (DTUI-19).
|
|
92
|
+
function (data) {
|
|
93
|
+
return onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(data);
|
|
77
94
|
}, [onSubmit]);
|
|
78
95
|
var handleReset = useCallback(function () {
|
|
79
96
|
reset(defaultValues);
|
|
@@ -259,7 +276,8 @@ var Form = /*#__PURE__*/forwardRef(function Form(_ref2, ref) {
|
|
|
259
276
|
ref = _ref8$field.ref;
|
|
260
277
|
return jsxs("div", {
|
|
261
278
|
className: "w-full",
|
|
262
|
-
children: [label && jsxs("
|
|
279
|
+
children: [label && jsxs("span", {
|
|
280
|
+
id: "".concat(fieldId, "-label"),
|
|
263
281
|
className: "block text-sm font-medium mb-2",
|
|
264
282
|
children: [label, required && jsx("span", {
|
|
265
283
|
className: "text-error-500 ml-1",
|
|
@@ -268,20 +286,29 @@ var Form = /*#__PURE__*/forwardRef(function Form(_ref2, ref) {
|
|
|
268
286
|
}), jsx("div", {
|
|
269
287
|
className: "space-y-2",
|
|
270
288
|
role: "radiogroup",
|
|
271
|
-
"aria-
|
|
289
|
+
"aria-labelledby": label ? "".concat(fieldId, "-label") : undefined,
|
|
290
|
+
"aria-required": required ? "true" : undefined,
|
|
272
291
|
"aria-describedby": describedBy,
|
|
273
|
-
children: options === null || options === void 0 ? void 0 : options.map(function (option) {
|
|
292
|
+
children: options === null || options === void 0 ? void 0 : options.map(function (option, index) {
|
|
293
|
+
// Shared `name` makes the options one native group
|
|
294
|
+
// (arrow keys, single tab stop); id/htmlFor makes each
|
|
295
|
+
// option label clickable and its accessible name.
|
|
296
|
+
var optionId = "".concat(fieldId, "-option-").concat(index);
|
|
274
297
|
return jsxs("div", {
|
|
275
298
|
className: "flex items-center",
|
|
276
299
|
children: [jsx("input", {
|
|
277
|
-
ref: ref,
|
|
300
|
+
ref: index === 0 ? ref : undefined,
|
|
301
|
+
id: optionId,
|
|
278
302
|
type: "radio",
|
|
303
|
+
name: name,
|
|
304
|
+
value: String(option.value),
|
|
279
305
|
checked: value === option.value,
|
|
280
306
|
onChange: function onChange() {
|
|
281
307
|
return _onChange2(option.value);
|
|
282
308
|
},
|
|
283
|
-
className: "text-primary-600 focus:ring-primary-500"
|
|
309
|
+
className: "text-primary-600 focus:ring-primary-500 focus-visible:ring-2"
|
|
284
310
|
}), jsx("label", {
|
|
311
|
+
htmlFor: optionId,
|
|
285
312
|
className: "ml-2 text-sm",
|
|
286
313
|
children: option.label
|
|
287
314
|
})]
|
|
@@ -484,7 +511,7 @@ var Form = /*#__PURE__*/forwardRef(function Form(_ref2, ref) {
|
|
|
484
511
|
className: "text-sm text-primary-600",
|
|
485
512
|
children: group.description
|
|
486
513
|
}), jsx("div", {
|
|
487
|
-
className: cn("grid gap-4",
|
|
514
|
+
className: cn("grid gap-4", gridColsClass(group.gridCols)),
|
|
488
515
|
children: group.fields.map(renderField)
|
|
489
516
|
})]
|
|
490
517
|
}, group.name);
|
|
@@ -90,7 +90,9 @@ var Input = /*#__PURE__*/forwardRef(function (props, forwardedRef) {
|
|
|
90
90
|
var paddingClass = cn(leftHasIcon ? "pl-10" : "pl-3", rightHasIcon ? "pr-12" : "pr-3");
|
|
91
91
|
var baseClasses = cn("w-full rounded-md border bg-white text-sm placeholder-gray-400 disabled:opacity-50", "h-10 leading-10",
|
|
92
92
|
// consistent height
|
|
93
|
-
paddingClass, error ? "border-red-500 focus:ring-red-500" : "border-gray-300", success ? "border-green-500 focus:ring-green-500" : "",
|
|
93
|
+
paddingClass, error ? "border-red-500 focus:ring-red-500" : "border-gray-300", success ? "border-green-500 focus:ring-green-500" : "",
|
|
94
|
+
// Neutral state needs a visible keyboard focus indicator too.
|
|
95
|
+
!error && !success && "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", className);
|
|
94
96
|
var inputType = isPassword && showPassword ? "text" : type;
|
|
95
97
|
return jsxs("div", {
|
|
96
98
|
className: "w-full",
|