@dreamtree-org/twreact-ui 1.3.8 → 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/DESIGN.md +11 -3
- package/README.md +9 -1
- package/ai-skills/dreamtree-ui.md +2 -2
- package/dist/ai-schema.json +19 -8
- package/dist/charts/index.js +69 -24
- package/dist/components/blocks/AppShell.d.ts.map +1 -1
- package/dist/components/charts/chartTheme.d.ts +2 -5
- package/dist/components/charts/chartTheme.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/Table.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/Table/useClickOutside.d.ts +5 -2
- package/dist/components/core/Table/useClickOutside.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/components/utility/Portal.d.ts +6 -0
- package/dist/components/utility/Portal.d.ts.map +1 -0
- package/dist/esm/components/blocks/AppShell.js +24 -18
- package/dist/esm/components/charts/CartesianChart.js +2 -1
- package/dist/esm/components/charts/DonutChart.js +2 -1
- package/dist/esm/components/charts/Sparkline.js +2 -1
- package/dist/esm/components/charts/chartTheme.js +1 -22
- package/dist/esm/components/core/Accordion.js +40 -9
- package/dist/esm/components/core/Button.js +8 -8
- 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/Table.js +11 -5
- 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/useClickOutside.js +51 -0
- package/dist/esm/hooks/useFocusTrap.js +10 -2
- package/dist/esm/hooks/useMediaQuery.js +61 -0
- package/dist/esm/hooks/useReducedMotion.js +17 -0
- package/dist/esm/hooks/useScrollLock.js +76 -9
- package/dist/esm/hooks/useTheme.js +6 -1
- package/dist/esm/utils/position.js +6 -0
- package/dist/hooks/useClickOutside.d.ts +14 -0
- package/dist/hooks/useClickOutside.d.ts.map +1 -0
- package/dist/hooks/useFloatingPosition.d.ts +37 -0
- package/dist/hooks/useFloatingPosition.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useMediaQuery.d.ts +22 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/hooks/usePresence.d.ts +16 -0
- package/dist/hooks/usePresence.d.ts.map +1 -0
- package/dist/hooks/usePresentation.d.ts +9 -0
- package/dist/hooks/usePresentation.d.ts.map +1 -0
- package/dist/hooks/useReducedMotion.d.ts +10 -0
- package/dist/hooks/useReducedMotion.d.ts.map +1 -0
- package/dist/hooks/useScrollLock.d.ts +11 -1
- package/dist/hooks/useScrollLock.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +1719 -1201
- package/dist/index.js +1718 -1200
- package/dist/tokens/tailwind3-preset.cjs +101 -8
- package/dist/tokens/theme.css +27 -0
- package/dist/tokens/tokens.json +175 -0
- package/dist/tokens/vars.css +2 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/position.d.ts.map +1 -1
- package/dist/utils/touchTarget.d.ts +1 -0
- package/dist/utils/touchTarget.d.ts.map +1 -1
- package/mcp/catalog.snapshot.json +83 -53
- package/package.json +2 -1
- package/tokens/lib.cjs +35 -0
- package/tokens/tokens.json +58 -2
- package/dist/esm/components/core/Table/useClickOutside.js +0 -26
|
@@ -4,7 +4,8 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { ResponsiveContainer, PieChart, Tooltip, Pie } from 'recharts';
|
|
6
6
|
import { ChartFrame, ChartTooltipContent } from './ChartFrame.js';
|
|
7
|
-
import { useChartTheme,
|
|
7
|
+
import { useChartTheme, useChartId, defaultValueFormatter } from './chartTheme.js';
|
|
8
|
+
import { useReducedMotion } from '../../hooks/useReducedMotion.js';
|
|
8
9
|
|
|
9
10
|
var _excluded = ["data", "index", "category", "colors", "valueFormatter", "variant", "innerRadius", "outerRadius", "centerLabel", "height", "showLegend", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
|
|
10
11
|
var DonutChart = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
@@ -4,7 +4,8 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { ResponsiveContainer, AreaChart, LineChart, YAxis, Tooltip, Area, Line } from 'recharts';
|
|
6
6
|
import { ChartFrame, ChartTooltipContent } from './ChartFrame.js';
|
|
7
|
-
import { useChartTheme,
|
|
7
|
+
import { useChartTheme, useChartId, defaultValueFormatter } from './chartTheme.js';
|
|
8
|
+
import { useReducedMotion } from '../../hooks/useReducedMotion.js';
|
|
8
9
|
|
|
9
10
|
var _excluded = ["data", "category", "index", "color", "type", "valueFormatter", "height", "showTooltip", "animate", "title", "description", "emptyState", "accessibleTable", "className"];
|
|
10
11
|
/** A word-sized trend line: no axes, grid or legend — just the shape of the data. */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
3
|
import { useSyncExternalStore, useId } from 'react';
|
|
4
|
-
import { prefersReducedMotion } from '../../utils/position.js';
|
|
5
4
|
|
|
6
5
|
var CHART_PALETTES = ["primary", "secondary", "success", "warning", "error", "info", "gray"];
|
|
7
6
|
var DEFAULT_CHART_COLORS = ["primary", "success", "warning", "error", "info", "secondary", "gray"];
|
|
@@ -90,26 +89,6 @@ function useChartTheme(categories, colors) {
|
|
|
90
89
|
series: seriesColors(categories, colors, live)
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
function subscribeReducedMotion(onChange) {
|
|
94
|
-
var _query$addEventListen;
|
|
95
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return function () {};
|
|
96
|
-
var query = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
97
|
-
(_query$addEventListen = query.addEventListener) === null || _query$addEventListen === void 0 || _query$addEventListen.call(query, "change", onChange);
|
|
98
|
-
return function () {
|
|
99
|
-
var _query$removeEventLis;
|
|
100
|
-
return (_query$removeEventLis = query.removeEventListener) === null || _query$removeEventLis === void 0 ? void 0 : _query$removeEventLis.call(query, "change", onChange);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
var serverReducedMotion = function serverReducedMotion() {
|
|
104
|
-
return false;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* `true` while the user asks the OS for reduced motion; follows changes live.
|
|
108
|
-
* `false` on the server and while hydrating, so the first render matches.
|
|
109
|
-
*/
|
|
110
|
-
function useReducedMotion() {
|
|
111
|
-
return useSyncExternalStore(subscribeReducedMotion, prefersReducedMotion, serverReducedMotion);
|
|
112
|
-
}
|
|
113
92
|
var defaultValueFormatter = function defaultValueFormatter(value) {
|
|
114
93
|
return typeof value === "number" ? value.toLocaleString() : value == null ? "" : String(value);
|
|
115
94
|
};
|
|
@@ -123,4 +102,4 @@ function useChartId() {
|
|
|
123
102
|
return "dt-chart-".concat(useId().replace(/[^A-Za-z0-9_-]/g, ""));
|
|
124
103
|
}
|
|
125
104
|
|
|
126
|
-
export { CHART_PALETTES, DEFAULT_CHART_COLORS, defaultValueFormatter, resolveColor, seriesColors, tokenVar, useChartId, useChartTheme
|
|
105
|
+
export { CHART_PALETTES, DEFAULT_CHART_COLORS, defaultValueFormatter, resolveColor, seriesColors, tokenVar, useChartId, useChartTheme };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
3
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { forwardRef, useState, useRef, useEffect, useLayoutEffect } from 'react';
|
|
4
|
+
import { forwardRef, useState, useRef, useEffect, useId, useLayoutEffect } from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
import { useLatestRef } from '../../hooks/useLatestRef.js';
|
|
7
|
+
import { useReducedMotion } from '../../hooks/useReducedMotion.js';
|
|
7
8
|
|
|
8
9
|
var _excluded = ["items", "allowMultiple", "defaultOpenIndexes", "onChange", "className", "headerClassName", "contentClassName", "chevronPosition", "chevronIcon", "bordered", "rounded", "size", "transitionDuration"];
|
|
9
10
|
/**
|
|
@@ -65,15 +66,45 @@ var Accordion = /*#__PURE__*/forwardRef(function Accordion(_ref, ref) {
|
|
|
65
66
|
useEffect(function () {
|
|
66
67
|
if (typeof onChangeRef.current === "function") onChangeRef.current(openIndexes);
|
|
67
68
|
}, [openIndexes, onChangeRef]);
|
|
68
|
-
//
|
|
69
|
-
|
|
69
|
+
// Unique per instance so two accordions on one page never share ids.
|
|
70
|
+
var uid = useId();
|
|
71
|
+
var reducedMotion = useReducedMotion();
|
|
72
|
+
var duration = reducedMotion ? 0 : transitionDuration;
|
|
73
|
+
// Which panels were open on the previous layout pass (null = first mount).
|
|
74
|
+
var prevOpenRef = useRef(null);
|
|
75
|
+
// Size panels imperatively (not via the style prop) so render never reads
|
|
76
|
+
// refs / the DOM. An open panel settles on `max-height: none` so content
|
|
77
|
+
// that grows after opening is never clipped; closed panels are `inert` so
|
|
78
|
+
// Tab cannot land inside collapsed content.
|
|
70
79
|
useLayoutEffect(function () {
|
|
80
|
+
var prevOpen = prevOpenRef.current;
|
|
81
|
+
var timers = [];
|
|
71
82
|
panelRefs.current.forEach(function (panelEl, idx) {
|
|
72
83
|
if (!panelEl) return;
|
|
73
84
|
var open = openIndexes.includes(idx);
|
|
74
|
-
|
|
85
|
+
var wasOpen = prevOpen ? prevOpen.includes(idx) : open;
|
|
86
|
+
if (open) panelEl.removeAttribute("inert");else panelEl.setAttribute("inert", "");
|
|
87
|
+
if (open === wasOpen || duration === 0) {
|
|
88
|
+
panelEl.style.maxHeight = open ? "none" : "0px";
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (open) {
|
|
92
|
+
panelEl.style.maxHeight = panelEl.scrollHeight + "px";
|
|
93
|
+
timers.push(setTimeout(function () {
|
|
94
|
+
if (panelEl.getAttribute("inert") === null) panelEl.style.maxHeight = "none";
|
|
95
|
+
}, duration));
|
|
96
|
+
} else {
|
|
97
|
+
// Collapse from a concrete height; `none` -> 0 cannot be transitioned.
|
|
98
|
+
panelEl.style.maxHeight = panelEl.scrollHeight + "px";
|
|
99
|
+
void panelEl.offsetHeight; // force reflow so the transition starts
|
|
100
|
+
panelEl.style.maxHeight = "0px";
|
|
101
|
+
}
|
|
75
102
|
});
|
|
76
|
-
|
|
103
|
+
prevOpenRef.current = openIndexes;
|
|
104
|
+
return function () {
|
|
105
|
+
return timers.forEach(clearTimeout);
|
|
106
|
+
};
|
|
107
|
+
}, [openIndexes, items, duration]);
|
|
77
108
|
var isOpen = function isOpen(index) {
|
|
78
109
|
return openIndexes.includes(index);
|
|
79
110
|
};
|
|
@@ -166,8 +197,8 @@ var Accordion = /*#__PURE__*/forwardRef(function Accordion(_ref, ref) {
|
|
|
166
197
|
var _item$id;
|
|
167
198
|
var id = (_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : index;
|
|
168
199
|
var open = isOpen(index);
|
|
169
|
-
var headerId = "accordion-header-".concat(id);
|
|
170
|
-
var panelId = "accordion-panel-".concat(id);
|
|
200
|
+
var headerId = "".concat(uid, "accordion-header-").concat(id);
|
|
201
|
+
var panelId = "".concat(uid, "accordion-panel-").concat(id);
|
|
171
202
|
var leftIconEl = renderLeftIcon(item, index);
|
|
172
203
|
return jsxs("div", {
|
|
173
204
|
className: "bg-white",
|
|
@@ -187,7 +218,7 @@ var Accordion = /*#__PURE__*/forwardRef(function Accordion(_ref, ref) {
|
|
|
187
218
|
return handleHeaderKeyDown(e, index);
|
|
188
219
|
},
|
|
189
220
|
type: "button",
|
|
190
|
-
className: "w-full flex items-center ".concat(sizeMap[size].header, " justify-between focus:outline-none focus:ring-2 focus:ring-
|
|
221
|
+
className: "w-full flex items-center ".concat(sizeMap[size].header, " justify-between focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 ").concat(headerClassName, " ").concat(item.disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"),
|
|
191
222
|
children: jsxs("div", {
|
|
192
223
|
className: "flex items-center gap-3 w-full",
|
|
193
224
|
children: [chevronPosition === "left" ? jsx("span", {
|
|
@@ -242,7 +273,7 @@ var Accordion = /*#__PURE__*/forwardRef(function Accordion(_ref, ref) {
|
|
|
242
273
|
return panelRefs.current[index] = el;
|
|
243
274
|
},
|
|
244
275
|
style: {
|
|
245
|
-
transition: "max-height ".concat(
|
|
276
|
+
transition: duration ? "max-height ".concat(duration, "ms ease") : "none",
|
|
246
277
|
overflow: "hidden"
|
|
247
278
|
},
|
|
248
279
|
className: "".concat(contentClassName, " ").concat(sizeMap[size].content),
|
|
@@ -26,15 +26,15 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
26
26
|
var Component = as || (props.href !== undefined ? 'a' : 'button');
|
|
27
27
|
var isNativeButton = Component === 'button';
|
|
28
28
|
var isDisabled = disabled || loading;
|
|
29
|
-
var baseClasses = cn('inline-flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:pointer-events-none', {
|
|
29
|
+
var baseClasses = cn('inline-flex items-center justify-center rounded-md font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:pointer-events-none', {
|
|
30
30
|
// Variants
|
|
31
|
-
'bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500': variant === 'primary',
|
|
32
|
-
'bg-secondary-100 text-secondary-900 hover:bg-secondary-200 focus:ring-secondary-500': variant === 'secondary',
|
|
33
|
-
'bg-transparent border border-gray-300 hover:bg-gray-50 focus:ring-primary-500 dark:border-gray-600 dark:text-gray-100 dark:hover:bg-gray-800 dark:focus:ring-offset-gray-900': variant === 'outline',
|
|
34
|
-
'bg-transparent text-primary-600 hover:bg-primary-50 focus:ring-primary-500': variant === 'ghost',
|
|
35
|
-
'bg-error-600 text-white hover:bg-error-700 focus:ring-error-500': variant === 'destructive',
|
|
36
|
-
'bg-success-600 text-white hover:bg-success-700 focus:ring-success-500': variant === 'success',
|
|
37
|
-
'bg-warning-600 text-white hover:bg-warning-700 focus:ring-warning-500': variant === 'warning',
|
|
31
|
+
'bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500': variant === 'primary',
|
|
32
|
+
'bg-secondary-100 text-secondary-900 hover:bg-secondary-200 focus-visible:ring-secondary-500': variant === 'secondary',
|
|
33
|
+
'bg-transparent border border-gray-300 hover:bg-gray-50 focus-visible:ring-primary-500 dark:border-gray-600 dark:text-gray-100 dark:hover:bg-gray-800 dark:focus-visible:ring-offset-gray-900': variant === 'outline',
|
|
34
|
+
'bg-transparent text-primary-600 hover:bg-primary-50 focus-visible:ring-primary-500': variant === 'ghost',
|
|
35
|
+
'bg-error-600 text-white hover:bg-error-700 focus-visible:ring-error-500': variant === 'destructive',
|
|
36
|
+
'bg-success-600 text-white hover:bg-success-700 focus-visible:ring-success-500': variant === 'success',
|
|
37
|
+
'bg-warning-600 text-white hover:bg-warning-700 focus-visible:ring-warning-500': variant === 'warning',
|
|
38
38
|
// Sizes — every value of the shared `Size` type gets a real height.
|
|
39
39
|
'h-7 px-2 text-xs': size === 'xs',
|
|
40
40
|
'h-8 px-3 text-xs': size === 'sm',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { forwardRef, useMemo, useState } from 'react';
|
|
4
|
+
import { forwardRef, useId, useMemo, useState } from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
|
|
7
7
|
var _excluded = ["value", "defaultValue", "onChange", "swatches", "showAlpha", "size", "disabled", "className", "label", "id"];
|
|
@@ -150,6 +150,12 @@ var ColorPicker = /*#__PURE__*/forwardRef(function ColorPicker(props, ref) {
|
|
|
150
150
|
label = _props$label === void 0 ? "Pick a color" : _props$label,
|
|
151
151
|
id = props.id,
|
|
152
152
|
rest = _objectWithoutProperties(props, _excluded);
|
|
153
|
+
// The visible <label> must point at a real control: the text value input
|
|
154
|
+
// takes the caller's `id` (or a generated one).
|
|
155
|
+
var autoId = useId();
|
|
156
|
+
var inputId = id !== null && id !== void 0 ? id : "".concat(autoId, "color-input");
|
|
157
|
+
var labelId = "".concat(inputId, "-label");
|
|
158
|
+
var valueLabelId = "".concat(inputId, "-value-label");
|
|
153
159
|
var parsedControlled = useMemo(function () {
|
|
154
160
|
return parseColor(value !== null && value !== void 0 ? value : null);
|
|
155
161
|
}, [value]);
|
|
@@ -212,8 +218,9 @@ var ColorPicker = /*#__PURE__*/forwardRef(function ColorPicker(props, ref) {
|
|
|
212
218
|
className: cn("inline-block", className)
|
|
213
219
|
}, rest), {}, {
|
|
214
220
|
children: [jsx("label", {
|
|
221
|
+
id: labelId,
|
|
215
222
|
className: "block mb-2 ".concat(sizeMap.font),
|
|
216
|
-
htmlFor:
|
|
223
|
+
htmlFor: inputId,
|
|
217
224
|
children: label
|
|
218
225
|
}), jsxs("div", {
|
|
219
226
|
className: "flex ".concat(sizeMap.gap, " items-start flex-col"),
|
|
@@ -234,7 +241,7 @@ var ColorPicker = /*#__PURE__*/forwardRef(function ColorPicker(props, ref) {
|
|
|
234
241
|
onClick: function onClick() {
|
|
235
242
|
return pushChange(c);
|
|
236
243
|
},
|
|
237
|
-
className: "rounded-md border border-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-1 focus:ring-
|
|
244
|
+
className: "rounded-md border border-gray-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-primary-500 ".concat(sizeMap.swatch, " overflow-hidden"),
|
|
238
245
|
style: {
|
|
239
246
|
background: "rgba(".concat(c.r, ",").concat(c.g, ",").concat(c.b, ",").concat(c.a, ")")
|
|
240
247
|
},
|
|
@@ -274,9 +281,14 @@ var ColorPicker = /*#__PURE__*/forwardRef(function ColorPicker(props, ref) {
|
|
|
274
281
|
},
|
|
275
282
|
className: "w-10 h-10 p-0 border-none bg-transparent",
|
|
276
283
|
"aria-label": "Native color input"
|
|
277
|
-
}),
|
|
284
|
+
}), jsxs("div", {
|
|
278
285
|
className: "flex-1",
|
|
279
|
-
children: jsx("
|
|
286
|
+
children: [jsx("span", {
|
|
287
|
+
id: valueLabelId,
|
|
288
|
+
className: "sr-only",
|
|
289
|
+
children: "Color value"
|
|
290
|
+
}), jsx("input", {
|
|
291
|
+
id: inputId,
|
|
280
292
|
type: "text",
|
|
281
293
|
disabled: disabled,
|
|
282
294
|
value: showAlpha ? rgbaToString(internal) : rgbaToHex(internal, showAlpha),
|
|
@@ -292,8 +304,8 @@ var ColorPicker = /*#__PURE__*/forwardRef(function ColorPicker(props, ref) {
|
|
|
292
304
|
}
|
|
293
305
|
},
|
|
294
306
|
className: "w-full rounded-md border border-gray-200 px-2 py-1 font-mono",
|
|
295
|
-
"aria-
|
|
296
|
-
})
|
|
307
|
+
"aria-labelledby": "".concat(labelId, " ").concat(valueLabelId)
|
|
308
|
+
})]
|
|
297
309
|
})]
|
|
298
310
|
}), jsx("div", {
|
|
299
311
|
className: "mt-3 space-y-2",
|
|
@@ -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",
|