@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
|
@@ -6,6 +6,8 @@ import { cn } from '../../utils/cn.js';
|
|
|
6
6
|
import { ChevronRight, ChevronLeft, ChevronDown } from 'lucide-react';
|
|
7
7
|
import Tooltip from '../core/Tooltip.js';
|
|
8
8
|
import { useLatestRef } from '../../hooks/useLatestRef.js';
|
|
9
|
+
import { useFocusTrap } from '../../hooks/useFocusTrap.js';
|
|
10
|
+
import { useScrollLock } from '../../hooks/useScrollLock.js';
|
|
9
11
|
|
|
10
12
|
var _excluded = ["items", "collapsed", "onToggle", "className", "containerClassName", "stickyOffset", "logo", "footer", "user", "onUserClick", "drawerPosition", "isMobileOpen", "setIsMobileOpen", "showCollapsedTooltips", "tooltipOptions", "linkAs", "expandedIds", "defaultExpandedIds", "onExpandedChange"];
|
|
11
13
|
// useLayoutEffect warns during SSR; fall back to useEffect on the server.
|
|
@@ -15,13 +17,6 @@ var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect
|
|
|
15
17
|
var isModifiedClick = function isModifiedClick(e) {
|
|
16
18
|
return Boolean(e && (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || typeof e.button === "number" && e.button !== 0));
|
|
17
19
|
};
|
|
18
|
-
// Focus trap for the mobile drawer (same selector as feedback/Dialog).
|
|
19
|
-
var FOCUSABLE_SELECTOR = ["a[href]", "button:not([disabled])", "textarea:not([disabled])", "input:not([disabled])", "select:not([disabled])", '[tabindex]:not([tabindex="-1"])'].join(",");
|
|
20
|
-
var getFocusable = function getFocusable(root) {
|
|
21
|
-
return root ? Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter(function (el) {
|
|
22
|
-
return el.getAttribute("aria-hidden") !== "true";
|
|
23
|
-
}) : [];
|
|
24
|
-
};
|
|
25
20
|
var hasChildItems = function hasChildItems(item) {
|
|
26
21
|
return Array.isArray(item.children) && item.children.length > 0;
|
|
27
22
|
};
|
|
@@ -171,12 +166,8 @@ var Sidebar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
171
166
|
var setIsMobileOpenRef = useLatestRef(setIsMobileOpen);
|
|
172
167
|
var mobileOpen = isMobileOpen !== null && isMobileOpen !== void 0 ? isMobileOpen : false;
|
|
173
168
|
var effectiveCollapsed = mobileOpen ? false : collapsed;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return function () {
|
|
177
|
-
document.body.style.overflow = "";
|
|
178
|
-
};
|
|
179
|
-
}, [mobileOpen]);
|
|
169
|
+
// Ref-counted, so a Dialog/Drawer stacked on top never unlocks the page early.
|
|
170
|
+
useScrollLock(mobileOpen);
|
|
180
171
|
// The drawer stays mounted (it slides in/out), so when it is shut it must
|
|
181
172
|
// leave the tab order and the a11y tree. `inert` is set imperatively: React
|
|
182
173
|
// 18 does not know the attribute and React 19 treats `inert=""` as false.
|
|
@@ -185,54 +176,15 @@ var Sidebar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
185
176
|
if (!drawer) return;
|
|
186
177
|
if (mobileOpen) drawer.removeAttribute("inert");else drawer.setAttribute("inert", "");
|
|
187
178
|
}, [mobileOpen]);
|
|
188
|
-
// Open drawer = modal dialog: initial focus inside, Tab trapped
|
|
189
|
-
// closes, focus returns to the opener
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var handleKeyDown = function handleKeyDown(e) {
|
|
198
|
-
if (e.key === "Escape") {
|
|
199
|
-
var _setIsMobileOpenRef$c;
|
|
200
|
-
(_setIsMobileOpenRef$c = setIsMobileOpenRef.current) === null || _setIsMobileOpenRef$c === void 0 || _setIsMobileOpenRef$c.call(setIsMobileOpenRef, false);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (e.key !== "Tab" || !drawer) return;
|
|
204
|
-
// md+ viewports hide the drawer (md:hidden): nothing to trap.
|
|
205
|
-
if (window.getComputedStyle(drawer).display === "none") return;
|
|
206
|
-
var nodes = getFocusable(drawer);
|
|
207
|
-
if (nodes.length === 0) {
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
drawer.focus();
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
var first = nodes[0];
|
|
213
|
-
var last = nodes[nodes.length - 1];
|
|
214
|
-
var active = document.activeElement;
|
|
215
|
-
var outside = !drawer.contains(active) || active === drawer;
|
|
216
|
-
if (e.shiftKey && (active === first || outside)) {
|
|
217
|
-
e.preventDefault();
|
|
218
|
-
last.focus();
|
|
219
|
-
} else if (!e.shiftKey && (active === last || outside)) {
|
|
220
|
-
e.preventDefault();
|
|
221
|
-
first.focus();
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
225
|
-
return function () {
|
|
226
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
227
|
-
// Restore focus only if it is still in the drawer (or was dropped to
|
|
228
|
-
// <body> when the drawer went inert) — never steal it from elsewhere.
|
|
229
|
-
var active = document.activeElement;
|
|
230
|
-
var focusLost = !active || active === document.body || (drawer === null || drawer === void 0 ? void 0 : drawer.contains(active));
|
|
231
|
-
if (focusLost && previouslyFocused && previouslyFocused !== document.body && typeof previouslyFocused.focus === "function" && document.contains(previouslyFocused)) {
|
|
232
|
-
previouslyFocused.focus();
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}, [mobileOpen, setIsMobileOpenRef]);
|
|
179
|
+
// Open drawer = modal dialog: initial focus inside, Tab trapped (skipped
|
|
180
|
+
// while md:hidden hides it), Escape closes, focus returns to the opener.
|
|
181
|
+
useFocusTrap(drawerRef, {
|
|
182
|
+
active: mobileOpen,
|
|
183
|
+
onEscape: function onEscape() {
|
|
184
|
+
var _setIsMobileOpenRef$c;
|
|
185
|
+
return (_setIsMobileOpenRef$c = setIsMobileOpenRef.current) === null || _setIsMobileOpenRef$c === void 0 ? void 0 : _setIsMobileOpenRef$c.call(setIsMobileOpenRef, false);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
236
188
|
var closeMobile = function closeMobile() {
|
|
237
189
|
if (mobileOpen && setIsMobileOpen) setIsMobileOpen(false);
|
|
238
190
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
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
4
|
import React from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
@@ -17,6 +17,22 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
17
17
|
status = _ref.status,
|
|
18
18
|
className = _ref.className,
|
|
19
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
// State-driven fallback: a broken image swaps to initials / icon without
|
|
21
|
+
// touching the DOM directly. Reset whenever `src` changes
|
|
22
|
+
// (adjust-during-render pattern).
|
|
23
|
+
var _React$useState = React.useState(false),
|
|
24
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
25
|
+
imgFailed = _React$useState2[0],
|
|
26
|
+
setImgFailed = _React$useState2[1];
|
|
27
|
+
var _React$useState3 = React.useState(src),
|
|
28
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
29
|
+
prevSrc = _React$useState4[0],
|
|
30
|
+
setPrevSrc = _React$useState4[1];
|
|
31
|
+
if (src !== prevSrc) {
|
|
32
|
+
setPrevSrc(src);
|
|
33
|
+
setImgFailed(false);
|
|
34
|
+
}
|
|
35
|
+
var showImage = Boolean(src) && !imgFailed;
|
|
20
36
|
var sizes = {
|
|
21
37
|
xs: 'h-6 w-6 text-xs',
|
|
22
38
|
sm: 'h-8 w-8 text-sm',
|
|
@@ -48,14 +64,14 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
48
64
|
return jsxs("div", {
|
|
49
65
|
ref: ref,
|
|
50
66
|
className: "relative inline-block",
|
|
51
|
-
children: [
|
|
67
|
+
children: [jsx("div", _objectSpread2(_objectSpread2({
|
|
52
68
|
className: cn('flex items-center justify-center bg-gray-100 text-primary-600 font-medium', sizes[size], {
|
|
53
69
|
'rounded-full': shape === 'circle',
|
|
54
70
|
'rounded-md': shape === 'square',
|
|
55
71
|
'rounded-lg': shape === 'rounded'
|
|
56
72
|
}, className)
|
|
57
73
|
}, props), {}, {
|
|
58
|
-
children:
|
|
74
|
+
children: showImage ? jsx("img", {
|
|
59
75
|
src: src,
|
|
60
76
|
alt: alt || name,
|
|
61
77
|
className: cn('h-full w-full object-cover', {
|
|
@@ -63,22 +79,19 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
63
79
|
'rounded-md': shape === 'square',
|
|
64
80
|
'rounded-lg': shape === 'rounded'
|
|
65
81
|
}),
|
|
66
|
-
onError: function onError(
|
|
67
|
-
|
|
68
|
-
e.target.nextSibling.style.display = 'flex';
|
|
82
|
+
onError: function onError() {
|
|
83
|
+
return setImgFailed(true);
|
|
69
84
|
}
|
|
70
|
-
}) :
|
|
85
|
+
}) : jsx("div", {
|
|
71
86
|
className: cn('flex items-center justify-center h-full w-full', {
|
|
72
87
|
'rounded-full': shape === 'circle',
|
|
73
88
|
'rounded-md': shape === 'square',
|
|
74
89
|
'rounded-lg': shape === 'rounded'
|
|
75
|
-
}, {
|
|
76
|
-
'hidden': src
|
|
77
90
|
}),
|
|
78
91
|
children: name ? getInitials(name) : jsx(User, {
|
|
79
92
|
className: "h-1/2 w-1/2"
|
|
80
93
|
})
|
|
81
|
-
})
|
|
94
|
+
})
|
|
82
95
|
})), status && jsx("span", {
|
|
83
96
|
className: cn('absolute bottom-0 right-0 rounded-full border-2 border-white', statusColors[status], statusSizes[size])
|
|
84
97
|
})]
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
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
4
|
import React from 'react';
|
|
5
5
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
|
+
import { TOUCH_TARGET } from '../../utils/touchTarget.js';
|
|
7
8
|
|
|
9
|
+
var _excluded = ["children", "autoPlay", "interval", "showDots", "className", "itemClassName", "onMouseEnter", "onMouseLeave"];
|
|
10
|
+
// Arrows stay visible at rest (touch devices have no hover) and use the surface /
|
|
11
|
+
// foreground role tokens so they read on light and dark themes alike.
|
|
12
|
+
var ARROW_CLASSES = "absolute top-1/2 -translate-y-1/2 z-10 inline-flex items-center justify-center p-2 rounded-full bg-surface/80 backdrop-blur-md border border-line text-foreground shadow-lg transition-colors motion-reduce:transition-none hover:bg-surface focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500";
|
|
8
13
|
var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
9
14
|
var children = props.children,
|
|
10
15
|
_props$autoPlay = props.autoPlay,
|
|
@@ -14,7 +19,10 @@ var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
|
14
19
|
_props$showDots = props.showDots,
|
|
15
20
|
showDots = _props$showDots === void 0 ? true : _props$showDots,
|
|
16
21
|
className = props.className,
|
|
17
|
-
itemClassName = props.itemClassName
|
|
22
|
+
itemClassName = props.itemClassName,
|
|
23
|
+
_onMouseEnter = props.onMouseEnter,
|
|
24
|
+
_onMouseLeave = props.onMouseLeave,
|
|
25
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
18
26
|
var _React$useState = React.useState(0),
|
|
19
27
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
20
28
|
currentIndex = _React$useState2[0],
|
|
@@ -44,17 +52,20 @@ var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
|
44
52
|
};
|
|
45
53
|
}, [autoPlay, isPaused, next, interval]);
|
|
46
54
|
var childrenArray = React.Children.toArray(children);
|
|
47
|
-
return jsxs("div", {
|
|
55
|
+
return jsxs("div", _objectSpread2(_objectSpread2({
|
|
48
56
|
ref: ref,
|
|
49
|
-
className: cn("relative
|
|
50
|
-
onMouseEnter: function onMouseEnter() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onMouseLeave: function onMouseLeave() {
|
|
54
|
-
return setIsPaused(false);
|
|
57
|
+
className: cn("relative overflow-hidden rounded-xl bg-surface border border-line shadow-sm", className),
|
|
58
|
+
onMouseEnter: function onMouseEnter(e) {
|
|
59
|
+
setIsPaused(true);
|
|
60
|
+
_onMouseEnter === null || _onMouseEnter === void 0 || _onMouseEnter(e);
|
|
55
61
|
},
|
|
62
|
+
onMouseLeave: function onMouseLeave(e) {
|
|
63
|
+
setIsPaused(false);
|
|
64
|
+
_onMouseLeave === null || _onMouseLeave === void 0 || _onMouseLeave(e);
|
|
65
|
+
}
|
|
66
|
+
}, rest), {}, {
|
|
56
67
|
children: [jsx("div", {
|
|
57
|
-
className: "flex transition-transform duration-500 ease-out",
|
|
68
|
+
className: "flex transition-transform duration-500 ease-out motion-reduce:transition-none",
|
|
58
69
|
style: {
|
|
59
70
|
transform: "translateX(-".concat(currentIndex * 100, "%)")
|
|
60
71
|
},
|
|
@@ -65,32 +76,38 @@ var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
|
65
76
|
}, index);
|
|
66
77
|
})
|
|
67
78
|
}), jsx("button", {
|
|
79
|
+
type: "button",
|
|
68
80
|
onClick: prev,
|
|
69
|
-
className: "
|
|
81
|
+
className: cn(ARROW_CLASSES, TOUCH_TARGET, "left-4"),
|
|
70
82
|
"aria-label": "Previous slide",
|
|
71
83
|
children: jsx(ChevronLeft, {
|
|
72
|
-
className: "w-5 h-5
|
|
84
|
+
className: "w-5 h-5",
|
|
85
|
+
"aria-hidden": "true"
|
|
73
86
|
})
|
|
74
87
|
}), jsx("button", {
|
|
88
|
+
type: "button",
|
|
75
89
|
onClick: next,
|
|
76
|
-
className: "
|
|
90
|
+
className: cn(ARROW_CLASSES, TOUCH_TARGET, "right-4"),
|
|
77
91
|
"aria-label": "Next slide",
|
|
78
92
|
children: jsx(ChevronRight, {
|
|
79
|
-
className: "w-5 h-5
|
|
93
|
+
className: "w-5 h-5",
|
|
94
|
+
"aria-hidden": "true"
|
|
80
95
|
})
|
|
81
96
|
}), showDots && jsx("div", {
|
|
82
97
|
className: "absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-10",
|
|
83
98
|
children: childrenArray.map(function (_, index) {
|
|
84
99
|
return jsx("button", {
|
|
100
|
+
type: "button",
|
|
85
101
|
onClick: function onClick() {
|
|
86
102
|
return setCurrentIndex(index);
|
|
87
103
|
},
|
|
88
|
-
className: cn("
|
|
89
|
-
"aria-label": "Go to slide ".concat(index + 1)
|
|
104
|
+
className: cn("h-2 rounded-full transition-all duration-300 motion-reduce:transition-none focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2", currentIndex === index ? "bg-primary-600 w-6" : "w-2 bg-muted/40 hover:bg-muted/70"),
|
|
105
|
+
"aria-label": "Go to slide ".concat(index + 1),
|
|
106
|
+
"aria-current": currentIndex === index ? "true" : undefined
|
|
90
107
|
}, index);
|
|
91
108
|
})
|
|
92
109
|
})]
|
|
93
|
-
});
|
|
110
|
+
}));
|
|
94
111
|
});
|
|
95
112
|
Carousel.displayName = "Carousel";
|
|
96
113
|
|
|
@@ -50,7 +50,7 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
50
50
|
className: cn('flex items-center justify-center space-x-1', className),
|
|
51
51
|
"aria-label": "Pagination"
|
|
52
52
|
}, props), {}, {
|
|
53
|
-
children: [showFirstLast &&
|
|
53
|
+
children: [showFirstLast && visiblePages[0] > 1 && jsx("button", {
|
|
54
54
|
className: "rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2",
|
|
55
55
|
onClick: function onClick() {
|
|
56
56
|
return handlePageClick(1);
|
|
@@ -96,7 +96,7 @@ var Pagination = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
96
96
|
children: jsx(ChevronRight, {
|
|
97
97
|
className: "h-4 w-4"
|
|
98
98
|
})
|
|
99
|
-
}), showFirstLast &&
|
|
99
|
+
}), showFirstLast && visiblePages[visiblePages.length - 1] < totalPages && jsx("button", {
|
|
100
100
|
className: "rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2",
|
|
101
101
|
onClick: function onClick() {
|
|
102
102
|
return handlePageClick(totalPages);
|
|
@@ -3,8 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import { useLatestRef } from './useLatestRef.js';
|
|
4
4
|
|
|
5
5
|
// Internal (not exported from the package). Shared focus management for the
|
|
6
|
-
// overlay primitives (Drawer, Popover, Tour).
|
|
7
|
-
// behavior is untouched.
|
|
6
|
+
// overlay primitives (Drawer, Dialog, Popover, Tour, Sidebar, AppShell).
|
|
8
7
|
var FOCUSABLE_SELECTOR = ["a[href]", "button:not([disabled])", "textarea:not([disabled])", "input:not([disabled])", "select:not([disabled])", '[tabindex]:not([tabindex="-1"])'].join(",");
|
|
9
8
|
var getFocusable = function getFocusable(root) {
|
|
10
9
|
return root ? Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter(function (el) {
|
|
@@ -17,7 +16,16 @@ var layerStack = [];
|
|
|
17
16
|
var isTopLayer = function isTopLayer(token) {
|
|
18
17
|
return layerStack[layerStack.length - 1] === token;
|
|
19
18
|
};
|
|
19
|
+
// A responsive drawer (Sidebar's `md:hidden`, AppShell's `lg:hidden`) can be
|
|
20
|
+
// "open" while CSS hides it on wide viewports; there is nothing to trap then.
|
|
21
|
+
var isDisplayNone = function isDisplayNone(el) {
|
|
22
|
+
for (var node = el; node && node.nodeType === 1; node = node.parentElement) {
|
|
23
|
+
if (window.getComputedStyle(node).display === "none") return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
20
27
|
function cycleFocus(e, panel) {
|
|
28
|
+
if (isDisplayNone(panel)) return;
|
|
21
29
|
var focusables = getFocusable(panel);
|
|
22
30
|
if (focusables.length === 0) {
|
|
23
31
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFocusTrap.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocusTrap.js"],"names":[],"mappings":"AAyDA;;;;GAIG;AACH;;;;;;SAmCC;AA3FD,wCAOY;AAEL,+CAKC"}
|