@dreamtree-org/twreact-ui 1.3.10 → 2.0.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/README.md +70 -6
- package/ai-skills/dreamtree-ui.md +58 -15
- package/codemods/v2.cjs +198 -0
- package/dist/ai-schema.json +745 -53
- package/dist/charts/index.js +195 -66
- package/dist/components/blocks/AppShell.d.ts.map +1 -1
- package/dist/components/blocks/BottomActionBar.d.ts +6 -0
- package/dist/components/blocks/BottomActionBar.d.ts.map +1 -0
- package/dist/components/blocks/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/blocks/PageHeader.d.ts.map +1 -1
- package/dist/components/charts/CartesianChart.d.ts.map +1 -1
- package/dist/components/charts/ChartFrame.d.ts.map +1 -1
- package/dist/components/charts/useChartLayout.d.ts +25 -0
- package/dist/components/charts/useChartLayout.d.ts.map +1 -0
- package/dist/components/core/Button.d.ts.map +1 -1
- package/dist/components/core/Checkbox.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/DateRangePicker.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/Loader.d.ts.map +1 -1
- package/dist/components/core/LocationPicker.d.ts.map +1 -1
- package/dist/components/core/Popover.d.ts.map +1 -1
- package/dist/components/core/ProgressBar.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/SearchField.d.ts +9 -0
- package/dist/components/core/SearchField.d.ts.map +1 -0
- package/dist/components/core/SegmentedControl.d.ts +8 -0
- package/dist/components/core/SegmentedControl.d.ts.map +1 -0
- package/dist/components/core/Select.d.ts.map +1 -1
- package/dist/components/core/Skeleton.d.ts.map +1 -1
- package/dist/components/core/Slider.d.ts.map +1 -1
- package/dist/components/core/SpeechToText.d.ts.map +1 -1
- package/dist/components/core/SwipeableListItem.d.ts +4 -0
- package/dist/components/core/SwipeableListItem.d.ts.map +1 -0
- package/dist/components/core/SwipeableListItemGesture.d.ts +58 -0
- package/dist/components/core/SwipeableListItemGesture.d.ts.map +1 -0
- package/dist/components/core/Switch.d.ts.map +1 -1
- package/dist/components/core/Table/ActionMenu.d.ts +10 -3
- package/dist/components/core/Table/ActionMenu.d.ts.map +1 -1
- package/dist/components/core/Table/MobileCard.d.ts +10 -1
- package/dist/components/core/Table/MobileCard.d.ts.map +1 -1
- package/dist/components/core/Table/MobileFilters.d.ts +8 -2
- package/dist/components/core/Table/MobileFilters.d.ts.map +1 -1
- package/dist/components/core/Table/Table.d.ts.map +1 -1
- package/dist/components/core/Table/TableRow.d.ts +2 -1
- package/dist/components/core/Table/TableRow.d.ts.map +1 -1
- package/dist/components/core/Tabs.d.ts +5 -8
- package/dist/components/core/Tabs.d.ts.map +1 -1
- package/dist/components/core/Textarea.d.ts.map +1 -1
- package/dist/components/core/ThreeDotPopover.d.ts +10 -22
- package/dist/components/core/ThreeDotPopover.d.ts.map +1 -1
- package/dist/components/core/Tooltip.d.ts +2 -1
- package/dist/components/core/Tooltip.d.ts.map +1 -1
- package/dist/components/core/internal/Calendar.d.ts +77 -0
- package/dist/components/core/internal/Calendar.d.ts.map +1 -0
- package/dist/components/core/menu/ActionMenuSurface.d.ts +42 -0
- package/dist/components/core/menu/ActionMenuSurface.d.ts.map +1 -0
- package/dist/components/core/menu/ActionSheetMenu.d.ts +17 -0
- package/dist/components/core/menu/ActionSheetMenu.d.ts.map +1 -0
- package/dist/components/core/menu/MenuPopover.d.ts +21 -0
- package/dist/components/core/menu/MenuPopover.d.ts.map +1 -0
- package/dist/components/core/menu/menuItems.d.ts +21 -0
- package/dist/components/core/menu/menuItems.d.ts.map +1 -0
- package/dist/components/core/menu/menuKeyboard.d.ts +16 -0
- package/dist/components/core/menu/menuKeyboard.d.ts.map +1 -0
- package/dist/components/feedback/ActionSheet.d.ts +4 -0
- package/dist/components/feedback/ActionSheet.d.ts.map +1 -0
- package/dist/components/feedback/Alert.d.ts.map +1 -1
- package/dist/components/feedback/Dialog.d.ts.map +1 -1
- package/dist/components/feedback/Drawer.d.ts.map +1 -1
- package/dist/components/feedback/Sheet.d.ts +4 -0
- package/dist/components/feedback/Sheet.d.ts.map +1 -0
- package/dist/components/feedback/Toast.d.ts +4 -3
- package/dist/components/feedback/Toast.d.ts.map +1 -1
- package/dist/components/feedback/ToastItem.d.ts +47 -0
- package/dist/components/feedback/ToastItem.d.ts.map +1 -0
- package/dist/components/feedback/ToastStack.d.ts +20 -0
- package/dist/components/feedback/ToastStack.d.ts.map +1 -0
- package/dist/components/feedback/ToastSwipe.d.ts +22 -0
- package/dist/components/feedback/ToastSwipe.d.ts.map +1 -0
- package/dist/components/feedback/Tour.d.ts.map +1 -1
- package/dist/components/feedback/sheetCore.d.ts +30 -0
- package/dist/components/feedback/sheetCore.d.ts.map +1 -0
- package/dist/components/navigation/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/navigation/FootNav.d.ts.map +1 -1
- package/dist/components/navigation/Navbar.d.ts.map +1 -1
- package/dist/components/navigation/Sidebar.d.ts +6 -0
- package/dist/components/navigation/Sidebar.d.ts.map +1 -1
- package/dist/components/rich-text/RichTextEditor.d.ts.map +1 -1
- package/dist/components/rich-text/RichTextToolbar.d.ts +6 -2
- package/dist/components/rich-text/RichTextToolbar.d.ts.map +1 -1
- package/dist/components/utility/Avatar.d.ts +8 -0
- package/dist/components/utility/Avatar.d.ts.map +1 -1
- package/dist/components/utility/AvatarGroup.d.ts +4 -0
- package/dist/components/utility/AvatarGroup.d.ts.map +1 -0
- package/dist/components/utility/Badge.d.ts.map +1 -1
- package/dist/components/utility/Card.d.ts.map +1 -1
- package/dist/components/utility/Carousel.d.ts.map +1 -1
- package/dist/components/utility/FileUpload.d.ts.map +1 -1
- package/dist/components/utility/Pagination.d.ts.map +1 -1
- package/dist/components/utility/PullToRefresh.d.ts +5 -0
- package/dist/components/utility/PullToRefresh.d.ts.map +1 -0
- package/dist/components/utility/Sortable.d.ts.map +1 -1
- package/dist/components/utility/Stepper.d.ts.map +1 -1
- package/dist/esm/components/blocks/AppShell.js +97 -90
- package/dist/esm/components/blocks/BottomActionBar.js +132 -0
- package/dist/esm/components/blocks/ConfirmDialog.js +40 -4
- package/dist/esm/components/blocks/EmptyState.js +1 -1
- package/dist/esm/components/blocks/ErrorState.js +1 -1
- package/dist/esm/components/blocks/LoadingState.js +4 -4
- package/dist/esm/components/blocks/PageHeader.js +16 -3
- package/dist/esm/components/blocks/StatCard.js +6 -6
- package/dist/esm/components/blocks/StatusPill.js +5 -8
- package/dist/esm/components/charts/CartesianChart.js +85 -62
- package/dist/esm/components/charts/ChartFrame.js +12 -5
- package/dist/esm/components/charts/useChartLayout.js +105 -0
- package/dist/esm/components/core/Button.js +49 -25
- package/dist/esm/components/core/Checkbox.js +72 -57
- package/dist/esm/components/core/ColorPicker.js +31 -42
- package/dist/esm/components/core/DatePicker.js +117 -304
- package/dist/esm/components/core/DateRangePicker.js +260 -308
- package/dist/esm/components/core/Form.js +11 -2
- package/dist/esm/components/core/Input.js +100 -38
- package/dist/esm/components/core/Loader.js +30 -44
- package/dist/esm/components/core/LocationPicker.js +82 -16
- package/dist/esm/components/core/Popover.js +59 -48
- package/dist/esm/components/core/ProgressBar.js +40 -72
- package/dist/esm/components/core/Radio.js +10 -12
- package/dist/esm/components/core/Rate.js +77 -14
- package/dist/esm/components/core/RoundedTag.js +5 -5
- package/dist/esm/components/core/SearchField.js +311 -0
- package/dist/esm/components/core/SegmentedControl.js +189 -0
- package/dist/esm/components/core/Select.js +185 -190
- package/dist/esm/components/core/Skeleton.js +13 -14
- package/dist/esm/components/core/Slider.js +24 -6
- package/dist/esm/components/core/SpeechToText.js +68 -16
- package/dist/esm/components/core/SwipeableListItem.js +286 -0
- package/dist/esm/components/core/SwipeableListItemGesture.js +219 -0
- package/dist/esm/components/core/Switch.js +98 -28
- package/dist/esm/components/core/Table/ActionMenu.js +45 -231
- package/dist/esm/components/core/Table/ColumnMenu.js +1 -1
- package/dist/esm/components/core/Table/MobileCard.js +66 -16
- package/dist/esm/components/core/Table/MobileFilters.js +181 -10
- package/dist/esm/components/core/Table/Table.js +149 -102
- package/dist/esm/components/core/Table/TableRow.js +10 -2
- package/dist/esm/components/core/Tabs.js +186 -39
- package/dist/esm/components/core/Textarea.js +10 -2
- package/dist/esm/components/core/ThreeDotPopover.js +93 -99
- package/dist/esm/components/core/Tooltip.js +138 -145
- package/dist/esm/components/core/internal/Calendar.js +381 -0
- package/dist/esm/components/core/menu/ActionMenuSurface.js +110 -0
- package/dist/esm/components/core/menu/ActionSheetMenu.js +140 -0
- package/dist/esm/components/core/menu/MenuPopover.js +177 -0
- package/dist/esm/components/core/menu/menuItems.js +61 -0
- package/dist/esm/components/core/menu/menuKeyboard.js +54 -0
- package/dist/esm/components/feedback/ActionSheet.js +55 -0
- package/dist/esm/components/feedback/Alert.js +63 -53
- package/dist/esm/components/feedback/Dialog.js +141 -53
- package/dist/esm/components/feedback/Drawer.js +130 -132
- package/dist/esm/components/feedback/Sheet.js +125 -0
- package/dist/esm/components/feedback/Toast.js +21 -291
- package/dist/esm/components/feedback/ToastItem.js +348 -0
- package/dist/esm/components/feedback/ToastStack.js +130 -0
- package/dist/esm/components/feedback/ToastSwipe.js +52 -0
- package/dist/esm/components/feedback/Tour.js +107 -30
- package/dist/esm/components/feedback/sheetCore.js +494 -0
- package/dist/esm/components/navigation/Breadcrumbs.js +97 -35
- package/dist/esm/components/navigation/Dropdown.js +1 -1
- package/dist/esm/components/navigation/FootNav.js +102 -13
- package/dist/esm/components/navigation/Navbar.js +172 -37
- package/dist/esm/components/navigation/Sidebar.js +263 -111
- package/dist/esm/components/rich-text/RichTextEditor.js +9 -3
- package/dist/esm/components/rich-text/RichTextToolbar.js +29 -9
- package/dist/esm/components/utility/Avatar.js +14 -12
- package/dist/esm/components/utility/AvatarGroup.js +56 -0
- package/dist/esm/components/utility/Badge.js +43 -23
- package/dist/esm/components/utility/Card.js +32 -8
- package/dist/esm/components/utility/Carousel.js +139 -29
- package/dist/esm/components/utility/FileUpload.js +106 -31
- package/dist/esm/components/utility/Pagination.js +31 -13
- package/dist/esm/components/utility/Portal.js +31 -0
- package/dist/esm/components/utility/PullToRefresh.js +229 -0
- package/dist/esm/components/utility/Sortable.js +6 -2
- package/dist/esm/components/utility/Stepper.js +110 -47
- package/dist/esm/hooks/useFloatingPosition.js +82 -0
- package/dist/esm/hooks/useHaptics.js +65 -0
- package/dist/esm/hooks/usePresence.js +58 -0
- package/dist/esm/hooks/usePresentation.js +21 -0
- package/dist/esm/hooks/useSheetDrag.js +220 -0
- package/dist/esm/hooks/useSliderValues.js +8 -2
- package/dist/esm/hooks/useSortable.js +107 -5
- package/dist/esm/index.js +14 -2
- package/dist/esm/utils/position.js +10 -63
- package/dist/esm/utils/touchTarget.js +4 -1
- package/dist/hooks/useFloatingPosition.d.ts +8 -4
- package/dist/hooks/useFloatingPosition.d.ts.map +1 -1
- package/dist/hooks/useHaptics.d.ts +19 -0
- package/dist/hooks/useHaptics.d.ts.map +1 -0
- package/dist/hooks/useSheetDrag.d.ts +31 -0
- package/dist/hooks/useSheetDrag.d.ts.map +1 -0
- package/dist/hooks/useSliderValues.d.ts +6 -2
- package/dist/hooks/useSliderValues.d.ts.map +1 -1
- package/dist/hooks/useSortable.d.ts +11 -1
- package/dist/hooks/useSortable.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +10645 -3842
- package/dist/index.js +10657 -3845
- package/dist/rich-text/index.js +41 -11
- package/dist/types/blocks.d.ts +32 -2
- package/dist/types/blocks.d.ts.map +1 -1
- package/dist/types/charts.d.ts +3 -1
- package/dist/types/charts.d.ts.map +1 -1
- package/dist/types/index.d.ts +409 -26
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rich-text.d.ts +5 -0
- package/dist/types/rich-text.d.ts.map +1 -1
- package/dist/utils/position.d.ts +0 -15
- package/dist/utils/position.d.ts.map +1 -1
- package/doc/README.md +16 -0
- package/mcp/catalog.snapshot.json +1540 -407
- package/package.json +7 -2
- package/dist/esm/hooks/useSwipeToClose.js +0 -66
- package/dist/hooks/useSwipeToClose.d.ts +0 -24
- package/dist/hooks/useSwipeToClose.d.ts.map +0 -1
|
@@ -4,6 +4,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import React, { useState, useRef, useEffect } from 'react';
|
|
5
5
|
import { Redo, Undo, Link, SquareCode, Quote, ListOrdered, List, Heading3, Heading2, Heading1, Code, Strikethrough, Italic, Bold } from 'lucide-react';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
|
+
import { TOUCH_TARGET } from '../../utils/touchTarget.js';
|
|
7
8
|
|
|
8
9
|
var isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || "");
|
|
9
10
|
var shortcutLabel = function shortcutLabel(keys) {
|
|
@@ -285,9 +286,23 @@ function LinkForm(_ref) {
|
|
|
285
286
|
});
|
|
286
287
|
}
|
|
287
288
|
var formButton = "h-8 rounded-md px-2 text-sm font-medium text-gray-700 hover:bg-gray-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:text-gray-200 dark:hover:bg-gray-800";
|
|
289
|
+
// Keeps the editor selection when a toolbar button is pressed. `pointerdown`
|
|
290
|
+
// covers touch and pen (iOS drops the selection on a plain tap otherwise);
|
|
291
|
+
// `mousedown` stays for desktop browsers that move focus on mousedown even
|
|
292
|
+
// when pointerdown was cancelled.
|
|
293
|
+
var keepSelection = function keepSelection(e) {
|
|
294
|
+
return e.preventDefault();
|
|
295
|
+
};
|
|
296
|
+
/** `top` offset for a sticky toolbar: `true` → 0, a number → px, a string → any CSS length. */
|
|
297
|
+
function stickyTop(sticky) {
|
|
298
|
+
if (typeof sticky === "number") return "".concat(sticky, "px");
|
|
299
|
+
if (typeof sticky === "string" && sticky) return sticky;
|
|
300
|
+
return "0px";
|
|
301
|
+
}
|
|
288
302
|
/**
|
|
289
303
|
* A WAI-ARIA toolbar: one tab stop, arrow keys / Home / End move between the
|
|
290
|
-
* buttons (roving tabindex), toggles report `aria-pressed`.
|
|
304
|
+
* buttons (roving tabindex), toggles report `aria-pressed`. With `sticky` it
|
|
305
|
+
* stays pinned to the top of the scrolling page while the content scrolls.
|
|
291
306
|
*/
|
|
292
307
|
function RichTextToolbar(_ref2) {
|
|
293
308
|
var editor = _ref2.editor,
|
|
@@ -296,7 +311,9 @@ function RichTextToolbar(_ref2) {
|
|
|
296
311
|
disabled = _ref2.disabled,
|
|
297
312
|
controlsId = _ref2.controlsId,
|
|
298
313
|
_ref2$label = _ref2.label,
|
|
299
|
-
label = _ref2$label === void 0 ? "Formatting" : _ref2$label
|
|
314
|
+
label = _ref2$label === void 0 ? "Formatting" : _ref2$label,
|
|
315
|
+
_ref2$sticky = _ref2.sticky,
|
|
316
|
+
sticky = _ref2$sticky === void 0 ? false : _ref2$sticky;
|
|
300
317
|
var _useState5 = useState(0),
|
|
301
318
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
302
319
|
focusIndex = _useState6[0],
|
|
@@ -345,7 +362,11 @@ function RichTextToolbar(_ref2) {
|
|
|
345
362
|
"aria-controls": controlsId,
|
|
346
363
|
"aria-orientation": "horizontal",
|
|
347
364
|
onKeyDown: onKeyDown,
|
|
348
|
-
|
|
365
|
+
"data-sticky": sticky ? "" : undefined,
|
|
366
|
+
style: sticky ? {
|
|
367
|
+
top: stickyTop(sticky)
|
|
368
|
+
} : undefined,
|
|
369
|
+
className: cn("flex flex-wrap items-center gap-0.5 border-b border-line bg-background px-1 py-1", sticky && "sticky z-sticky"),
|
|
349
370
|
children: keys.map(function (key, i) {
|
|
350
371
|
var item = TOOLBAR_ITEMS[key];
|
|
351
372
|
var Icon = item.icon;
|
|
@@ -354,7 +375,7 @@ function RichTextToolbar(_ref2) {
|
|
|
354
375
|
var newGroup = i > 0 && TOOLBAR_ITEMS[keys[i - 1]].group !== item.group;
|
|
355
376
|
return jsxs(React.Fragment, {
|
|
356
377
|
children: [newGroup && jsx("span", {
|
|
357
|
-
className: "mx-1 h-5 w-px bg-
|
|
378
|
+
className: "mx-1 h-5 w-px bg-line",
|
|
358
379
|
"aria-hidden": "true"
|
|
359
380
|
}), jsx("button", {
|
|
360
381
|
ref: function ref(node) {
|
|
@@ -371,13 +392,12 @@ function RichTextToolbar(_ref2) {
|
|
|
371
392
|
onFocus: function onFocus() {
|
|
372
393
|
return setFocusIndex(i);
|
|
373
394
|
},
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
},
|
|
395
|
+
onPointerDown: keepSelection,
|
|
396
|
+
onMouseDown: keepSelection,
|
|
377
397
|
onClick: function onClick() {
|
|
378
398
|
return activate(key);
|
|
379
399
|
},
|
|
380
|
-
className: cn("inline-flex h-8 w-8 items-center justify-center rounded-md text-
|
|
400
|
+
className: cn("inline-flex h-8 w-8 items-center justify-center rounded-md text-muted transition-colors duration-fast motion-reduce:transition-none", TOUCH_TARGET, "hover:bg-muted/10 hover:text-foreground", "focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", "disabled:cursor-not-allowed disabled:opacity-50", pressed && "bg-primary-100 text-primary-700 dark:bg-primary-900/40 dark:text-primary-300", unavailable && "opacity-40"),
|
|
381
401
|
children: jsx(Icon, {
|
|
382
402
|
className: "h-4 w-4",
|
|
383
403
|
"aria-hidden": "true"
|
|
@@ -394,4 +414,4 @@ function RichTextToolbar(_ref2) {
|
|
|
394
414
|
});
|
|
395
415
|
}
|
|
396
416
|
|
|
397
|
-
export { DEFAULT_TOOLBAR, RichTextToolbar, TOOLBAR_ITEMS, normalizeUrl, selectToolbarState };
|
|
417
|
+
export { DEFAULT_TOOLBAR, RichTextToolbar, TOOLBAR_ITEMS, normalizeUrl, selectToolbarState, stickyTop };
|
|
@@ -6,6 +6,15 @@ import { cn } from '../../utils/cn.js';
|
|
|
6
6
|
import { User } from 'lucide-react';
|
|
7
7
|
|
|
8
8
|
var _excluded = ["src", "alt", "name", "size", "shape", "status", "className"];
|
|
9
|
+
// Internal (not exported from the package): shared with AvatarGroup's "+N" tile.
|
|
10
|
+
var AVATAR_SIZES = {
|
|
11
|
+
xs: 'h-6 w-6 text-xs',
|
|
12
|
+
sm: 'h-8 w-8 text-sm',
|
|
13
|
+
md: 'h-10 w-10 text-base',
|
|
14
|
+
lg: 'h-12 w-12 text-lg',
|
|
15
|
+
xl: 'h-16 w-16 text-xl',
|
|
16
|
+
'2xl': 'h-20 w-20 text-2xl'
|
|
17
|
+
};
|
|
9
18
|
var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
10
19
|
var src = _ref.src,
|
|
11
20
|
alt = _ref.alt,
|
|
@@ -33,14 +42,7 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
33
42
|
setImgFailed(false);
|
|
34
43
|
}
|
|
35
44
|
var showImage = Boolean(src) && !imgFailed;
|
|
36
|
-
var sizes =
|
|
37
|
-
xs: 'h-6 w-6 text-xs',
|
|
38
|
-
sm: 'h-8 w-8 text-sm',
|
|
39
|
-
md: 'h-10 w-10 text-base',
|
|
40
|
-
lg: 'h-12 w-12 text-lg',
|
|
41
|
-
xl: 'h-16 w-16 text-xl',
|
|
42
|
-
'2xl': 'h-20 w-20 text-2xl'
|
|
43
|
-
};
|
|
45
|
+
var sizes = AVATAR_SIZES;
|
|
44
46
|
var getInitials = function getInitials(name) {
|
|
45
47
|
if (!name) return '';
|
|
46
48
|
return name.split(' ').map(function (word) {
|
|
@@ -49,7 +51,7 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
49
51
|
};
|
|
50
52
|
var statusColors = {
|
|
51
53
|
online: 'bg-success-500',
|
|
52
|
-
offline: 'bg-gray-400',
|
|
54
|
+
offline: 'bg-gray-400 dark:bg-gray-500',
|
|
53
55
|
away: 'bg-warning-500',
|
|
54
56
|
busy: 'bg-error-500'
|
|
55
57
|
};
|
|
@@ -65,7 +67,7 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
65
67
|
ref: ref,
|
|
66
68
|
className: "relative inline-block",
|
|
67
69
|
children: [jsx("div", _objectSpread2(_objectSpread2({
|
|
68
|
-
className: cn('flex items-center justify-center bg-gray-100 text-primary-600 font-medium', sizes[size], {
|
|
70
|
+
className: cn('flex items-center justify-center bg-gray-100 text-primary-600 font-medium dark:bg-gray-800 dark:text-primary-300', sizes[size], {
|
|
69
71
|
'rounded-full': shape === 'circle',
|
|
70
72
|
'rounded-md': shape === 'square',
|
|
71
73
|
'rounded-lg': shape === 'rounded'
|
|
@@ -93,10 +95,10 @@ var Avatar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
93
95
|
})
|
|
94
96
|
})
|
|
95
97
|
})), status && jsx("span", {
|
|
96
|
-
className: cn('absolute bottom-0 right-0 rounded-full border-2 border-
|
|
98
|
+
className: cn('absolute bottom-0 right-0 rounded-full border-2 border-surface', statusColors[status], statusSizes[size])
|
|
97
99
|
})]
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
102
|
Avatar.displayName = 'Avatar';
|
|
101
103
|
|
|
102
|
-
export { Avatar as default };
|
|
104
|
+
export { AVATAR_SIZES, Avatar as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
|
+
import { jsxs } from 'react/jsx-runtime';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { cn } from '../../utils/cn.js';
|
|
6
|
+
import { AVATAR_SIZES } from './Avatar.js';
|
|
7
|
+
|
|
8
|
+
var _excluded = ["children", "max", "size", "className"];
|
|
9
|
+
// Overlap grows with the avatar so the stack reads the same at every size.
|
|
10
|
+
var OVERLAP = {
|
|
11
|
+
xs: '-space-x-1.5',
|
|
12
|
+
sm: '-space-x-2',
|
|
13
|
+
md: '-space-x-2',
|
|
14
|
+
lg: '-space-x-3',
|
|
15
|
+
xl: '-space-x-4',
|
|
16
|
+
'2xl': '-space-x-5'
|
|
17
|
+
};
|
|
18
|
+
// Each avatar is ringed in the surface colour so it reads as cut out of the
|
|
19
|
+
// one behind it (dark-mode aware).
|
|
20
|
+
var RING = 'ring-2 ring-surface';
|
|
21
|
+
var AvatarGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
22
|
+
var children = _ref.children,
|
|
23
|
+
max = _ref.max,
|
|
24
|
+
_ref$size = _ref.size,
|
|
25
|
+
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
26
|
+
className = _ref.className,
|
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
var avatars = React.Children.toArray(children).filter(React.isValidElement);
|
|
29
|
+
var limit = typeof max === 'number' && max >= 0 ? max : avatars.length;
|
|
30
|
+
var visible = avatars.slice(0, limit);
|
|
31
|
+
var overflow = avatars.length - visible.length;
|
|
32
|
+
var sizeKey = AVATAR_SIZES[size] ? size : 'md';
|
|
33
|
+
return jsxs("div", _objectSpread2(_objectSpread2({
|
|
34
|
+
ref: ref,
|
|
35
|
+
role: "group",
|
|
36
|
+
className: cn('flex items-center', OVERLAP[sizeKey], className)
|
|
37
|
+
}, props), {}, {
|
|
38
|
+
children: [visible.map(function (child) {
|
|
39
|
+
var _child$props$size;
|
|
40
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
41
|
+
// An avatar's own `size` wins; otherwise the group's size applies.
|
|
42
|
+
size: (_child$props$size = child.props.size) !== null && _child$props$size !== void 0 ? _child$props$size : size,
|
|
43
|
+
className: cn(RING, child.props.className)
|
|
44
|
+
});
|
|
45
|
+
}), overflow > 0 && jsxs("span", {
|
|
46
|
+
role: "img",
|
|
47
|
+
"aria-label": "".concat(overflow, " more"),
|
|
48
|
+
"data-slot": "overflow",
|
|
49
|
+
className: cn('relative inline-flex shrink-0 items-center justify-center rounded-full bg-gray-200 font-medium text-gray-700 dark:bg-gray-700 dark:text-gray-100', RING, AVATAR_SIZES[sizeKey]),
|
|
50
|
+
children: ["+", overflow]
|
|
51
|
+
})]
|
|
52
|
+
}));
|
|
53
|
+
});
|
|
54
|
+
AvatarGroup.displayName = 'AvatarGroup';
|
|
55
|
+
|
|
56
|
+
export { AvatarGroup as default };
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
|
|
7
|
-
var _excluded = ["children", "variant", "size", "rounded", "className"];
|
|
7
|
+
var _excluded = ["children", "variant", "size", "rounded", "dot", "icon", "max", "className"];
|
|
8
|
+
// Light: 100 fill + 800 text (≥4.5:1). Dark: a tinted 900 fill + 200 text.
|
|
9
|
+
var variants = {
|
|
10
|
+
"default": 'bg-gray-100 text-primary-800 dark:bg-gray-800 dark:text-gray-100',
|
|
11
|
+
primary: 'bg-primary-100 text-primary-800 dark:bg-primary-900/40 dark:text-primary-200',
|
|
12
|
+
secondary: 'bg-secondary-100 text-secondary-800 dark:bg-secondary-800 dark:text-secondary-100',
|
|
13
|
+
success: 'bg-success-100 text-success-800 dark:bg-success-900/40 dark:text-success-200',
|
|
14
|
+
warning: 'bg-warning-100 text-warning-800 dark:bg-warning-900/40 dark:text-warning-200',
|
|
15
|
+
error: 'bg-error-100 text-error-800 dark:bg-error-900/40 dark:text-error-200',
|
|
16
|
+
info: 'bg-info-100 text-info-800 dark:bg-info-900/40 dark:text-info-200',
|
|
17
|
+
outline: 'border border-gray-300 text-gray-700 dark:border-gray-600 dark:text-gray-200'
|
|
18
|
+
};
|
|
19
|
+
var sizes = {
|
|
20
|
+
xs: 'px-1.5 py-px text-xs',
|
|
21
|
+
sm: 'px-2 py-0.5 text-xs',
|
|
22
|
+
md: 'px-2.5 py-0.5 text-sm',
|
|
23
|
+
lg: 'px-3 py-1 text-base',
|
|
24
|
+
xl: 'px-3.5 py-1 text-lg',
|
|
25
|
+
'2xl': 'px-4 py-1.5 text-xl'
|
|
26
|
+
};
|
|
27
|
+
// A numeric count above `max` reads `${max}+` (e.g. 99+).
|
|
28
|
+
var formatCount = function formatCount(children, max) {
|
|
29
|
+
return typeof children === 'number' && typeof max === 'number' && children > max ? "".concat(max, "+") : children;
|
|
30
|
+
};
|
|
8
31
|
var Badge = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
9
32
|
var children = _ref.children,
|
|
10
33
|
_ref$variant = _ref.variant,
|
|
@@ -13,34 +36,31 @@ var Badge = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
13
36
|
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
14
37
|
_ref$rounded = _ref.rounded,
|
|
15
38
|
rounded = _ref$rounded === void 0 ? true : _ref$rounded,
|
|
39
|
+
_ref$dot = _ref.dot,
|
|
40
|
+
dot = _ref$dot === void 0 ? false : _ref$dot,
|
|
41
|
+
icon = _ref.icon,
|
|
42
|
+
max = _ref.max,
|
|
16
43
|
className = _ref.className,
|
|
17
44
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
primary: 'bg-primary-100 text-primary-800',
|
|
21
|
-
secondary: 'bg-secondary-100 text-secondary-800',
|
|
22
|
-
success: 'bg-success-100 text-success-800',
|
|
23
|
-
warning: 'bg-warning-100 text-warning-800',
|
|
24
|
-
error: 'bg-error-100 text-error-800',
|
|
25
|
-
info: 'bg-info-100 text-info-800',
|
|
26
|
-
outline: 'border border-gray-300'
|
|
27
|
-
};
|
|
28
|
-
var sizes = {
|
|
29
|
-
xs: 'px-1.5 py-px text-xs',
|
|
30
|
-
sm: 'px-2 py-0.5 text-xs',
|
|
31
|
-
md: 'px-2.5 py-0.5 text-sm',
|
|
32
|
-
lg: 'px-3 py-1 text-base',
|
|
33
|
-
xl: 'px-3.5 py-1 text-lg',
|
|
34
|
-
'2xl': 'px-4 py-1.5 text-xl'
|
|
35
|
-
};
|
|
36
|
-
return jsx("span", _objectSpread2(_objectSpread2({
|
|
45
|
+
var hasLead = dot || Boolean(icon);
|
|
46
|
+
return jsxs("span", _objectSpread2(_objectSpread2({
|
|
37
47
|
ref: ref,
|
|
38
48
|
className: cn('inline-flex items-center font-medium', variants[variant], sizes[size] || sizes.md, {
|
|
39
49
|
'rounded-full': rounded,
|
|
40
|
-
'rounded-md': !rounded
|
|
50
|
+
'rounded-md': !rounded,
|
|
51
|
+
'gap-1': hasLead
|
|
41
52
|
}, className)
|
|
42
53
|
}, props), {}, {
|
|
43
|
-
children:
|
|
54
|
+
children: [dot && jsx("span", {
|
|
55
|
+
className: "h-1.5 w-1.5 shrink-0 rounded-full bg-current",
|
|
56
|
+
"aria-hidden": "true",
|
|
57
|
+
"data-slot": "dot"
|
|
58
|
+
}), icon && jsx("span", {
|
|
59
|
+
className: "inline-flex h-3.5 w-3.5 shrink-0 items-center",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
"data-slot": "icon",
|
|
62
|
+
children: icon
|
|
63
|
+
}), formatCount(children, max)]
|
|
44
64
|
}));
|
|
45
65
|
});
|
|
46
66
|
Badge.displayName = 'Badge';
|
|
@@ -1,26 +1,50 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
|
+
import { PRESS_FEEDBACK } from '../../utils/touchTarget.js';
|
|
6
7
|
|
|
7
|
-
var _excluded = ["children", "className", "hover"],
|
|
8
|
+
var _excluded = ["children", "className", "hover", "interactive", "onClick", "onKeyDown"],
|
|
8
9
|
_excluded2 = ["children", "className"],
|
|
9
10
|
_excluded3 = ["children", "className"],
|
|
10
11
|
_excluded4 = ["children", "className"],
|
|
11
12
|
_excluded5 = ["children", "className"],
|
|
12
13
|
_excluded6 = ["children", "className"];
|
|
14
|
+
// Interactive cards: hover lift, press shrink and a keyboard focus ring. The
|
|
15
|
+
// transition list covers both the shadow and the press transform.
|
|
16
|
+
var INTERACTIVE_CLASSES = cn('cursor-pointer hover:shadow-md focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-gray-900', PRESS_FEEDBACK, 'transition-[box-shadow,transform] duration-fast ease-standard motion-reduce:transition-none');
|
|
13
17
|
var Card = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
14
18
|
var children = _ref.children,
|
|
15
19
|
className = _ref.className,
|
|
16
20
|
_ref$hover = _ref.hover,
|
|
17
21
|
hover = _ref$hover === void 0 ? false : _ref$hover,
|
|
22
|
+
_ref$interactive = _ref.interactive,
|
|
23
|
+
interactive = _ref$interactive === void 0 ? false : _ref$interactive,
|
|
24
|
+
onClick = _ref.onClick,
|
|
25
|
+
onKeyDown = _ref.onKeyDown,
|
|
18
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
// A clickable interactive card with no role of its own becomes a keyboard
|
|
28
|
+
// operable button (Tab to it, Enter / Space to activate).
|
|
29
|
+
var actsAsButton = interactive && typeof onClick === 'function' && props.role === undefined;
|
|
30
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
31
|
+
onKeyDown === null || onKeyDown === void 0 || onKeyDown(e);
|
|
32
|
+
if (!actsAsButton || e.defaultPrevented || e.target !== e.currentTarget) return;
|
|
33
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
onClick(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
19
38
|
return jsx("div", _objectSpread2(_objectSpread2({
|
|
20
39
|
ref: ref,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
role: actsAsButton ? 'button' : undefined,
|
|
41
|
+
tabIndex: actsAsButton ? 0 : undefined,
|
|
42
|
+
onClick: onClick,
|
|
43
|
+
onKeyDown: actsAsButton ? handleKeyDown : onKeyDown,
|
|
44
|
+
"data-interactive": interactive || undefined,
|
|
45
|
+
className: cn('rounded-card border border-line bg-surface shadow-sm', _defineProperty({
|
|
46
|
+
'hover:shadow-md transition-shadow': hover && !interactive
|
|
47
|
+
}, INTERACTIVE_CLASSES, interactive), className)
|
|
24
48
|
}, props), {}, {
|
|
25
49
|
children: children
|
|
26
50
|
}));
|
|
@@ -31,7 +55,7 @@ var CardHeader = function CardHeader(_ref2) {
|
|
|
31
55
|
className = _ref2.className,
|
|
32
56
|
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
33
57
|
return jsx("div", _objectSpread2(_objectSpread2({
|
|
34
|
-
className: cn('px-6 py-4 border-b border-line', className)
|
|
58
|
+
className: cn('px-4 sm:px-6 py-4 border-b border-line', className)
|
|
35
59
|
}, props), {}, {
|
|
36
60
|
children: children
|
|
37
61
|
}));
|
|
@@ -61,7 +85,7 @@ var CardContent = function CardContent(_ref5) {
|
|
|
61
85
|
className = _ref5.className,
|
|
62
86
|
props = _objectWithoutProperties(_ref5, _excluded5);
|
|
63
87
|
return jsx("div", _objectSpread2(_objectSpread2({
|
|
64
|
-
className: cn('px-6 py-4', className)
|
|
88
|
+
className: cn('px-4 sm:px-6 py-4', className)
|
|
65
89
|
}, props), {}, {
|
|
66
90
|
children: children
|
|
67
91
|
}));
|
|
@@ -71,7 +95,7 @@ var CardFooter = function CardFooter(_ref6) {
|
|
|
71
95
|
className = _ref6.className,
|
|
72
96
|
props = _objectWithoutProperties(_ref6, _excluded6);
|
|
73
97
|
return jsx("div", _objectSpread2(_objectSpread2({
|
|
74
|
-
className: cn('px-6 py-4 border-t border-line', className)
|
|
98
|
+
className: cn('px-4 sm:px-6 py-4 border-t border-line', className)
|
|
75
99
|
}, props), {}, {
|
|
76
100
|
children: children
|
|
77
101
|
}));
|
|
@@ -4,12 +4,29 @@ 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
|
+
import { TOUCH_TARGET, PRESS_FEEDBACK } from '../../utils/touchTarget.js';
|
|
8
|
+
import { useReducedMotion } from '../../hooks/useReducedMotion.js';
|
|
9
|
+
import { useLatestRef } from '../../hooks/useLatestRef.js';
|
|
8
10
|
|
|
9
|
-
var _excluded = ["children", "autoPlay", "interval", "showDots", "className", "itemClassName", "onMouseEnter", "onMouseLeave"];
|
|
11
|
+
var _excluded = ["children", "autoPlay", "interval", "showDots", "className", "itemClassName", "onMouseEnter", "onMouseLeave", "onFocus", "onBlur", "onTouchStart", "onTouchEnd"];
|
|
10
12
|
// Arrows stay visible at rest (touch devices have no hover) and use the surface /
|
|
11
13
|
// foreground role tokens so they read on light and dark themes alike.
|
|
12
14
|
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";
|
|
15
|
+
// The track is a native horizontal scroller with mandatory snap points, so
|
|
16
|
+
// touch users get momentum swipe for free. The scrollbar is hidden; the arrows,
|
|
17
|
+
// dots and keyboard (focus the track, then arrow keys) are the visible controls.
|
|
18
|
+
var TRACK_CLASSES = "flex overflow-x-auto snap-x snap-mandatory scroll-smooth motion-reduce:scroll-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500";
|
|
19
|
+
function scrollTrackTo(track, slide, behavior) {
|
|
20
|
+
if (!track || !slide) return;
|
|
21
|
+
if (typeof track.scrollTo === "function") {
|
|
22
|
+
track.scrollTo({
|
|
23
|
+
left: slide.offsetLeft,
|
|
24
|
+
behavior: behavior
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
track.scrollLeft = slide.offsetLeft;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
13
30
|
var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
14
31
|
var children = props.children,
|
|
15
32
|
_props$autoPlay = props.autoPlay,
|
|
@@ -22,59 +39,146 @@ var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
|
22
39
|
itemClassName = props.itemClassName,
|
|
23
40
|
_onMouseEnter = props.onMouseEnter,
|
|
24
41
|
_onMouseLeave = props.onMouseLeave,
|
|
42
|
+
_onFocus = props.onFocus,
|
|
43
|
+
_onBlur = props.onBlur,
|
|
44
|
+
_onTouchStart = props.onTouchStart,
|
|
45
|
+
_onTouchEnd = props.onTouchEnd,
|
|
25
46
|
rest = _objectWithoutProperties(props, _excluded);
|
|
47
|
+
var reducedMotion = useReducedMotion();
|
|
26
48
|
var _React$useState = React.useState(0),
|
|
27
49
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
28
50
|
currentIndex = _React$useState2[0],
|
|
29
51
|
setCurrentIndex = _React$useState2[1];
|
|
30
52
|
var _React$useState3 = React.useState(false),
|
|
31
53
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
54
|
+
hovered = _React$useState4[0],
|
|
55
|
+
setHovered = _React$useState4[1];
|
|
56
|
+
var _React$useState5 = React.useState(false),
|
|
57
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
58
|
+
focusWithin = _React$useState6[0],
|
|
59
|
+
setFocusWithin = _React$useState6[1];
|
|
60
|
+
var _React$useState7 = React.useState(false),
|
|
61
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
62
|
+
touching = _React$useState8[0],
|
|
63
|
+
setTouching = _React$useState8[1];
|
|
64
|
+
var trackRef = React.useRef(null);
|
|
65
|
+
var slideRefs = React.useRef([]);
|
|
66
|
+
var indexRef = useLatestRef(currentIndex);
|
|
67
|
+
var childrenArray = React.Children.toArray(children);
|
|
68
|
+
var count = childrenArray.length;
|
|
69
|
+
var goTo = React.useCallback(function (index) {
|
|
70
|
+
if (count === 0) return;
|
|
71
|
+
var target = (index % count + count) % count;
|
|
72
|
+
indexRef.current = target;
|
|
73
|
+
setCurrentIndex(target);
|
|
74
|
+
scrollTrackTo(trackRef.current, slideRefs.current[target], reducedMotion ? "auto" : "smooth");
|
|
75
|
+
}, [count, reducedMotion, indexRef]);
|
|
35
76
|
var next = React.useCallback(function () {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
}, [children]);
|
|
77
|
+
return goTo(indexRef.current + 1);
|
|
78
|
+
}, [goTo, indexRef]);
|
|
40
79
|
var prev = React.useCallback(function () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
80
|
+
return goTo(indexRef.current - 1);
|
|
81
|
+
}, [goTo, indexRef]);
|
|
82
|
+
// Swipes / native scrolling move the track without going through goTo(), so the
|
|
83
|
+
// active slide is whichever one is mostly in view.
|
|
84
|
+
React.useEffect(function () {
|
|
85
|
+
var track = trackRef.current;
|
|
86
|
+
if (!track || typeof IntersectionObserver === "undefined") return undefined;
|
|
87
|
+
var observer = new IntersectionObserver(function (entries) {
|
|
88
|
+
entries.forEach(function (entry) {
|
|
89
|
+
if (entry.isIntersecting && entry.intersectionRatio >= 0.6) {
|
|
90
|
+
var index = Number(entry.target.getAttribute("data-index"));
|
|
91
|
+
if (!Number.isNaN(index)) setCurrentIndex(index);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, {
|
|
95
|
+
root: track,
|
|
96
|
+
threshold: [0.6]
|
|
44
97
|
});
|
|
45
|
-
|
|
98
|
+
slideRefs.current.slice(0, count).forEach(function (slide) {
|
|
99
|
+
return slide && observer.observe(slide);
|
|
100
|
+
});
|
|
101
|
+
return function () {
|
|
102
|
+
return observer.disconnect();
|
|
103
|
+
};
|
|
104
|
+
}, [count]);
|
|
105
|
+
var isPaused = hovered || focusWithin || touching;
|
|
106
|
+
var isAutoPlaying = autoPlay && !reducedMotion && !isPaused && count > 1;
|
|
46
107
|
React.useEffect(function () {
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
}
|
|
108
|
+
if (!isAutoPlaying) return undefined;
|
|
109
|
+
var timer = setInterval(next, interval);
|
|
50
110
|
return function () {
|
|
51
|
-
|
|
111
|
+
return clearInterval(timer);
|
|
52
112
|
};
|
|
53
|
-
}, [
|
|
54
|
-
var childrenArray = React.Children.toArray(children);
|
|
113
|
+
}, [isAutoPlaying, next, interval]);
|
|
55
114
|
return jsxs("div", _objectSpread2(_objectSpread2({
|
|
56
115
|
ref: ref,
|
|
116
|
+
role: "region",
|
|
117
|
+
"aria-roledescription": "carousel",
|
|
118
|
+
"aria-label": "Carousel",
|
|
57
119
|
className: cn("relative overflow-hidden rounded-xl bg-surface border border-line shadow-sm", className),
|
|
58
120
|
onMouseEnter: function onMouseEnter(e) {
|
|
59
|
-
|
|
121
|
+
setHovered(true);
|
|
60
122
|
_onMouseEnter === null || _onMouseEnter === void 0 || _onMouseEnter(e);
|
|
61
123
|
},
|
|
62
124
|
onMouseLeave: function onMouseLeave(e) {
|
|
63
|
-
|
|
125
|
+
setHovered(false);
|
|
64
126
|
_onMouseLeave === null || _onMouseLeave === void 0 || _onMouseLeave(e);
|
|
127
|
+
},
|
|
128
|
+
onFocus: function onFocus(e) {
|
|
129
|
+
setFocusWithin(true);
|
|
130
|
+
_onFocus === null || _onFocus === void 0 || _onFocus(e);
|
|
131
|
+
},
|
|
132
|
+
onBlur: function onBlur(e) {
|
|
133
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setFocusWithin(false);
|
|
134
|
+
_onBlur === null || _onBlur === void 0 || _onBlur(e);
|
|
135
|
+
},
|
|
136
|
+
onTouchStart: function onTouchStart(e) {
|
|
137
|
+
setTouching(true);
|
|
138
|
+
_onTouchStart === null || _onTouchStart === void 0 || _onTouchStart(e);
|
|
139
|
+
},
|
|
140
|
+
onTouchEnd: function onTouchEnd(e) {
|
|
141
|
+
setTouching(false);
|
|
142
|
+
_onTouchEnd === null || _onTouchEnd === void 0 || _onTouchEnd(e);
|
|
143
|
+
},
|
|
144
|
+
onTouchCancel: function onTouchCancel() {
|
|
145
|
+
return setTouching(false);
|
|
65
146
|
}
|
|
66
147
|
}, rest), {}, {
|
|
67
148
|
children: [jsx("div", {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
149
|
+
ref: trackRef,
|
|
150
|
+
className: TRACK_CLASSES,
|
|
151
|
+
tabIndex: 0,
|
|
152
|
+
"aria-label": "Slides",
|
|
153
|
+
"data-carousel-track": "",
|
|
154
|
+
onKeyDown: function onKeyDown(e) {
|
|
155
|
+
if (e.key === "ArrowRight") {
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
next();
|
|
158
|
+
} else if (e.key === "ArrowLeft") {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
prev();
|
|
161
|
+
}
|
|
71
162
|
},
|
|
72
163
|
children: childrenArray.map(function (child, index) {
|
|
73
164
|
return jsx("div", {
|
|
74
|
-
|
|
165
|
+
ref: function ref(node) {
|
|
166
|
+
slideRefs.current[index] = node;
|
|
167
|
+
},
|
|
168
|
+
"data-index": index,
|
|
169
|
+
role: "group",
|
|
170
|
+
"aria-roledescription": "slide",
|
|
171
|
+
"aria-label": "".concat(index + 1, " of ").concat(count),
|
|
172
|
+
className: cn("w-full flex-shrink-0 min-w-full snap-start snap-always", itemClassName),
|
|
75
173
|
children: child
|
|
76
174
|
}, index);
|
|
77
175
|
})
|
|
176
|
+
}), jsx("div", {
|
|
177
|
+
className: "sr-only",
|
|
178
|
+
"aria-live": isAutoPlaying ? "off" : "polite",
|
|
179
|
+
"aria-atomic": "true",
|
|
180
|
+
"data-carousel-status": "",
|
|
181
|
+
children: count > 0 ? "Slide ".concat(currentIndex + 1, " of ").concat(count) : ""
|
|
78
182
|
}), jsx("button", {
|
|
79
183
|
type: "button",
|
|
80
184
|
onClick: prev,
|
|
@@ -94,16 +198,22 @@ var Carousel = /*#__PURE__*/React.forwardRef(function Carousel(props, ref) {
|
|
|
94
198
|
"aria-hidden": "true"
|
|
95
199
|
})
|
|
96
200
|
}), showDots && jsx("div", {
|
|
97
|
-
className: "absolute bottom-
|
|
201
|
+
className: "absolute bottom-1 left-1/2 -translate-x-1/2 flex z-10",
|
|
98
202
|
children: childrenArray.map(function (_, index) {
|
|
203
|
+
var active = currentIndex === index;
|
|
99
204
|
return jsx("button", {
|
|
100
205
|
type: "button",
|
|
101
206
|
onClick: function onClick() {
|
|
102
|
-
return
|
|
207
|
+
return goTo(index);
|
|
103
208
|
},
|
|
104
|
-
className: cn("h-
|
|
209
|
+
className: cn("group inline-flex h-11 min-w-11 items-center justify-center rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-inset", PRESS_FEEDBACK),
|
|
105
210
|
"aria-label": "Go to slide ".concat(index + 1),
|
|
106
|
-
"aria-current":
|
|
211
|
+
"aria-current": active ? "true" : undefined,
|
|
212
|
+
children: jsx("span", {
|
|
213
|
+
"aria-hidden": "true",
|
|
214
|
+
"data-carousel-dot": "",
|
|
215
|
+
className: cn("block h-2 rounded-full transition-all duration-base ease-standard motion-reduce:transition-none", active ? "bg-primary-600 w-6" : "w-2 bg-muted/40 group-hover:bg-muted/70")
|
|
216
|
+
})
|
|
107
217
|
}, index);
|
|
108
218
|
})
|
|
109
219
|
})]
|