@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
|
@@ -1,53 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import React, { useRef, useId, useCallback, useEffect
|
|
4
|
+
import React, { useRef, useId, useCallback, useEffect } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { cn } from '../../utils/cn.js';
|
|
7
|
-
import { setRefs
|
|
7
|
+
import { setRefs } from '../../utils/position.js';
|
|
8
8
|
import { useFocusTrap, getFocusable } from '../../hooks/useFocusTrap.js';
|
|
9
9
|
import { useControllableState } from '../../hooks/useControllableState.js';
|
|
10
|
+
import { useFloatingPosition } from '../../hooks/useFloatingPosition.js';
|
|
11
|
+
import { usePresentation } from '../../hooks/usePresentation.js';
|
|
12
|
+
import Sheet from '../feedback/Sheet.js';
|
|
10
13
|
|
|
11
|
-
var _excluded = ["trigger", "children", "open", "defaultOpen", "onOpenChange", "placement", "offset", "title", "initialFocusRef", "disabled", "id", "className"];
|
|
12
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
13
|
-
function usePopoverPosition(open, anchorRef, panelRef, placement, offset) {
|
|
14
|
-
useIsomorphicLayoutEffect(function () {
|
|
15
|
-
if (!open) return undefined;
|
|
16
|
-
var update = function update() {
|
|
17
|
-
var _anchorRef$current;
|
|
18
|
-
var anchor = ((_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.firstElementChild) || anchorRef.current;
|
|
19
|
-
var panel = panelRef.current;
|
|
20
|
-
if (!anchor || !panel) return;
|
|
21
|
-
var size = {
|
|
22
|
-
width: panel.offsetWidth,
|
|
23
|
-
height: panel.offsetHeight
|
|
24
|
-
};
|
|
25
|
-
var _computePosition = computePosition(anchor.getBoundingClientRect(), size, {
|
|
26
|
-
placement: placement,
|
|
27
|
-
offset: offset
|
|
28
|
-
}),
|
|
29
|
-
top = _computePosition.top,
|
|
30
|
-
left = _computePosition.left,
|
|
31
|
-
side = _computePosition.side;
|
|
32
|
-
panel.style.top = "".concat(top, "px");
|
|
33
|
-
panel.style.left = "".concat(left, "px");
|
|
34
|
-
panel.setAttribute("data-side", side);
|
|
35
|
-
};
|
|
36
|
-
update();
|
|
37
|
-
window.addEventListener("resize", update);
|
|
38
|
-
window.addEventListener("scroll", update, true);
|
|
39
|
-
return function () {
|
|
40
|
-
window.removeEventListener("resize", update);
|
|
41
|
-
window.removeEventListener("scroll", update, true);
|
|
42
|
-
};
|
|
43
|
-
}, [open, placement, offset, anchorRef, panelRef]);
|
|
44
|
-
}
|
|
14
|
+
var _excluded = ["trigger", "children", "open", "defaultOpen", "onOpenChange", "placement", "offset", "title", "initialFocusRef", "disabled", "presentation", "id", "className", "style"];
|
|
45
15
|
function useOutsideClose(open, anchorRef, panelRef, close) {
|
|
46
16
|
useEffect(function () {
|
|
47
17
|
if (!open) return undefined;
|
|
48
18
|
var onDown = function onDown(e) {
|
|
49
|
-
var _panelRef$current, _anchorRef$
|
|
50
|
-
if ((_panelRef$current = panelRef.current) !== null && _panelRef$current !== void 0 && _panelRef$current.contains(e.target) || (_anchorRef$
|
|
19
|
+
var _panelRef$current, _anchorRef$current;
|
|
20
|
+
if ((_panelRef$current = panelRef.current) !== null && _panelRef$current !== void 0 && _panelRef$current.contains(e.target) || (_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(e.target)) return;
|
|
51
21
|
close();
|
|
52
22
|
};
|
|
53
23
|
document.addEventListener("mousedown", onDown);
|
|
@@ -74,8 +44,11 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref, _ref2) {
|
|
|
74
44
|
initialFocusRef = _ref.initialFocusRef,
|
|
75
45
|
_ref$disabled = _ref.disabled,
|
|
76
46
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
47
|
+
_ref$presentation = _ref.presentation,
|
|
48
|
+
presentation = _ref$presentation === void 0 ? "auto" : _ref$presentation,
|
|
77
49
|
idProp = _ref.id,
|
|
78
50
|
className = _ref.className,
|
|
51
|
+
style = _ref.style,
|
|
79
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
80
53
|
var anchorRef = useRef(null);
|
|
81
54
|
var panelRef = useRef(null);
|
|
@@ -90,6 +63,18 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref, _ref2) {
|
|
|
90
63
|
_useControllableState2 = _slicedToArray(_useControllableState, 2),
|
|
91
64
|
open = _useControllableState2[0],
|
|
92
65
|
setOpen = _useControllableState2[1];
|
|
66
|
+
var asSheet = usePresentation(presentation) === "sheet";
|
|
67
|
+
var popoverOpen = open && !asSheet;
|
|
68
|
+
var _useFloatingPosition = useFloatingPosition({
|
|
69
|
+
placement: placement,
|
|
70
|
+
offset: offset,
|
|
71
|
+
open: popoverOpen
|
|
72
|
+
}),
|
|
73
|
+
refs = _useFloatingPosition.refs,
|
|
74
|
+
floatingStyles = _useFloatingPosition.floatingStyles,
|
|
75
|
+
resolvedPlacement = _useFloatingPosition.placement;
|
|
76
|
+
var setReference = refs.setReference,
|
|
77
|
+
setFloating = refs.setFloating;
|
|
93
78
|
var close = useCallback(function () {
|
|
94
79
|
return setOpen(false);
|
|
95
80
|
}, [setOpen]);
|
|
@@ -97,10 +82,9 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref, _ref2) {
|
|
|
97
82
|
var _getFocusable$;
|
|
98
83
|
return (_getFocusable$ = getFocusable(anchorRef.current)[0]) === null || _getFocusable$ === void 0 ? void 0 : _getFocusable$.focus();
|
|
99
84
|
};
|
|
100
|
-
|
|
101
|
-
useOutsideClose(open, anchorRef, panelRef, close);
|
|
85
|
+
useOutsideClose(popoverOpen, anchorRef, panelRef, close);
|
|
102
86
|
useFocusTrap(panelRef, {
|
|
103
|
-
active:
|
|
87
|
+
active: popoverOpen,
|
|
104
88
|
trap: false,
|
|
105
89
|
initialFocusRef: initialFocusRef,
|
|
106
90
|
onEscape: function onEscape() {
|
|
@@ -142,21 +126,48 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref, _ref2) {
|
|
|
142
126
|
var content = typeof children === "function" ? children({
|
|
143
127
|
close: close
|
|
144
128
|
}) : children;
|
|
129
|
+
var anchor = jsx("span", {
|
|
130
|
+
ref: function ref(node) {
|
|
131
|
+
return setRefs(node, anchorRef, setReference);
|
|
132
|
+
},
|
|
133
|
+
className: "inline-flex",
|
|
134
|
+
children: triggerNode
|
|
135
|
+
});
|
|
136
|
+
// Phones (ADR 0001): the same content in a bottom sheet. Sheet owns the
|
|
137
|
+
// backdrop, the modal focus trap, Escape and focus return.
|
|
138
|
+
if (asSheet) {
|
|
139
|
+
return jsxs(Fragment, {
|
|
140
|
+
children: [anchor, jsx(Sheet, _objectSpread2(_objectSpread2({
|
|
141
|
+
ref: _ref2,
|
|
142
|
+
open: open,
|
|
143
|
+
onClose: close,
|
|
144
|
+
title: title,
|
|
145
|
+
initialFocus: initialFocusRef,
|
|
146
|
+
id: panelId,
|
|
147
|
+
className: className,
|
|
148
|
+
style: style,
|
|
149
|
+
"data-presentation": "sheet"
|
|
150
|
+
}, props), {}, {
|
|
151
|
+
children: jsx(Sheet.Body, {
|
|
152
|
+
children: content
|
|
153
|
+
})
|
|
154
|
+
}))]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
145
157
|
return jsxs(Fragment, {
|
|
146
|
-
children: [
|
|
147
|
-
ref: anchorRef,
|
|
148
|
-
className: "inline-flex",
|
|
149
|
-
children: triggerNode
|
|
150
|
-
}), open && typeof document !== "undefined" && /*#__PURE__*/createPortal(jsxs("div", _objectSpread2(_objectSpread2({
|
|
158
|
+
children: [anchor, open && typeof document !== "undefined" && /*#__PURE__*/createPortal(jsxs("div", _objectSpread2(_objectSpread2({
|
|
151
159
|
ref: function ref(node) {
|
|
152
|
-
return setRefs(node, panelRef, _ref2);
|
|
160
|
+
return setRefs(node, panelRef, _ref2, setFloating);
|
|
153
161
|
},
|
|
154
162
|
id: panelId,
|
|
155
163
|
role: "dialog",
|
|
156
164
|
"aria-labelledby": title ? titleId : undefined,
|
|
157
165
|
tabIndex: -1,
|
|
158
166
|
onKeyDown: handlePanelKeyDown,
|
|
159
|
-
|
|
167
|
+
"data-side": resolvedPlacement.split("-")[0],
|
|
168
|
+
"data-presentation": "popover",
|
|
169
|
+
className: cn("z-popover min-w-[12rem] max-w-sm rounded-lg border border-gray-200 bg-white p-4 text-sm text-gray-900 shadow-lg focus:outline-none", "dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100", "animate-fade-in motion-reduce:animate-none", className),
|
|
170
|
+
style: _objectSpread2(_objectSpread2({}, floatingStyles), style)
|
|
160
171
|
}, props), {}, {
|
|
161
172
|
children: [title && jsx("h2", {
|
|
162
173
|
id: titleId,
|
|
@@ -4,50 +4,41 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
|
|
7
|
-
var _excluded = ["value", "max", "size", "showValue", "rounded", "
|
|
8
|
-
// ProgressBar.
|
|
9
|
-
//
|
|
7
|
+
var _excluded = ["value", "max", "size", "showValue", "rounded", "variant", "striped", "animated", "label", "ariaLabel", "className", "style"];
|
|
8
|
+
// ProgressBar. Colours come only from role tokens, so it follows the brand and
|
|
9
|
+
// dark mode (STUDIO-59). The HEX props `color` / `bgColor` / `valueColor` were
|
|
10
|
+
// removed in 2.0.0 (DTUI-65); pick a token tone with `variant` instead.
|
|
10
11
|
var SIZE_MAP = {
|
|
11
12
|
xs: "h-1",
|
|
12
13
|
sm: "h-2",
|
|
13
14
|
md: "h-3",
|
|
14
15
|
lg: "h-5"
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
return 0.2126 * srgb[0] + 0.7152 * srgb[1] + 0.0722 * srgb[2];
|
|
41
|
-
}
|
|
42
|
-
function readableTextColor(bgHex, preferred) {
|
|
43
|
-
// If preferred is provided and valid, use it; otherwise pick black/white based on contrast
|
|
44
|
-
if (isHexColor(preferred)) return preferred;
|
|
45
|
-
var L = luminance(bgHex);
|
|
46
|
-
// WCAG suggests threshold around 0.179 for black/white contrast — we'll use 0.179
|
|
47
|
-
return L > 0.179 ? '#000000' : '#ffffff';
|
|
48
|
-
}
|
|
17
|
+
// Static class strings (no runtime-built Tailwind classes) per token tone.
|
|
18
|
+
var VARIANT_MAP = {
|
|
19
|
+
primary: {
|
|
20
|
+
fill: "bg-primary-600",
|
|
21
|
+
track: "bg-primary-100 dark:bg-primary-900/40"
|
|
22
|
+
},
|
|
23
|
+
secondary: {
|
|
24
|
+
fill: "bg-secondary-600",
|
|
25
|
+
track: "bg-secondary-100 dark:bg-secondary-900/40"
|
|
26
|
+
},
|
|
27
|
+
success: {
|
|
28
|
+
fill: "bg-success-600",
|
|
29
|
+
track: "bg-success-100 dark:bg-success-900/40"
|
|
30
|
+
},
|
|
31
|
+
warning: {
|
|
32
|
+
fill: "bg-warning-600",
|
|
33
|
+
track: "bg-warning-100 dark:bg-warning-900/40"
|
|
34
|
+
},
|
|
35
|
+
destructive: {
|
|
36
|
+
fill: "bg-error-600",
|
|
37
|
+
track: "bg-error-100 dark:bg-error-900/40"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
49
40
|
var ProgressBar = /*#__PURE__*/forwardRef(function ProgressBar(_ref, ref) {
|
|
50
|
-
var _SIZE_MAP$size;
|
|
41
|
+
var _VARIANT_MAP$variant, _SIZE_MAP$size;
|
|
51
42
|
var _ref$value = _ref.value,
|
|
52
43
|
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
53
44
|
_ref$max = _ref.max,
|
|
@@ -58,12 +49,8 @@ var ProgressBar = /*#__PURE__*/forwardRef(function ProgressBar(_ref, ref) {
|
|
|
58
49
|
showValue = _ref$showValue === void 0 ? false : _ref$showValue,
|
|
59
50
|
_ref$rounded = _ref.rounded,
|
|
60
51
|
rounded = _ref$rounded === void 0 ? true : _ref$rounded,
|
|
61
|
-
_ref$
|
|
62
|
-
|
|
63
|
-
_ref$bgColor = _ref.bgColor,
|
|
64
|
-
bgColor = _ref$bgColor === void 0 ? undefined : _ref$bgColor,
|
|
65
|
-
_ref$valueColor = _ref.valueColor,
|
|
66
|
-
valueColor = _ref$valueColor === void 0 ? undefined : _ref$valueColor,
|
|
52
|
+
_ref$variant = _ref.variant,
|
|
53
|
+
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
67
54
|
_ref$striped = _ref.striped,
|
|
68
55
|
striped = _ref$striped === void 0 ? false : _ref$striped,
|
|
69
56
|
_ref$animated = _ref.animated,
|
|
@@ -81,13 +68,7 @@ var ProgressBar = /*#__PURE__*/forwardRef(function ProgressBar(_ref, ref) {
|
|
|
81
68
|
var safeValue = typeof value === 'number' ? value : 0;
|
|
82
69
|
var clamped = Math.max(0, Math.min(safeValue, safeMax));
|
|
83
70
|
var percent = safeMax === 0 ? 0 : clamped / safeMax * 100;
|
|
84
|
-
|
|
85
|
-
var fillHex = isHexColor(color) ? color : null;
|
|
86
|
-
var trackHex = isHexColor(bgColor) ? bgColor : null;
|
|
87
|
-
var textHex = isHexColor(valueColor) ? valueColor : fillHex ? readableTextColor(fillHex, undefined) : null;
|
|
88
|
-
var fillClass = fillHex ? '' : 'bg-primary-600';
|
|
89
|
-
var trackClass = trackHex ? '' : 'bg-primary-100';
|
|
90
|
-
var textClass = textHex ? '' : 'text-white';
|
|
71
|
+
var tone = (_VARIANT_MAP$variant = VARIANT_MAP[variant]) !== null && _VARIANT_MAP$variant !== void 0 ? _VARIANT_MAP$variant : VARIANT_MAP.primary;
|
|
91
72
|
// height class or inline style
|
|
92
73
|
var heightClass = typeof size === 'number' ? '' : (_SIZE_MAP$size = SIZE_MAP[size]) !== null && _SIZE_MAP$size !== void 0 ? _SIZE_MAP$size : SIZE_MAP['md'];
|
|
93
74
|
var heightStyle = typeof size === 'number' ? {
|
|
@@ -101,46 +82,33 @@ var ProgressBar = /*#__PURE__*/forwardRef(function ProgressBar(_ref, ref) {
|
|
|
101
82
|
backgroundSize: '20px 20px',
|
|
102
83
|
overflow: 'hidden'
|
|
103
84
|
} : {};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var finalFillStyle = _objectSpread2(
|
|
85
|
+
// Stripe motion is a Tailwind animation (DTUI-48) — no per-instance <style> tag —
|
|
86
|
+
// and stops under prefers-reduced-motion, as does the width transition.
|
|
87
|
+
var animatedClass = animated ? 'animate-progress-stripes motion-reduce:animate-none' : '';
|
|
88
|
+
var finalFillStyle = _objectSpread2({
|
|
108
89
|
width: "".concat(percent, "%")
|
|
109
|
-
},
|
|
110
|
-
backgroundColor: fillHex
|
|
111
|
-
} : {}), textHex ? {
|
|
112
|
-
color: textHex
|
|
113
|
-
} : {}), stripeStyle), animatedStyle), {}, {
|
|
114
|
-
transition: 'width 300ms ease-out'
|
|
115
|
-
});
|
|
90
|
+
}, stripeStyle);
|
|
116
91
|
return jsxs("div", _objectSpread2(_objectSpread2({
|
|
117
92
|
ref: ref,
|
|
118
93
|
className: cn("w-full", className),
|
|
119
94
|
style: style
|
|
120
95
|
}, rest), {}, {
|
|
121
|
-
children: [jsx("
|
|
122
|
-
children: "@keyframes stripeShift { 0% { background-position: 0 0; } 100% { background-position: 40px 0; } }"
|
|
123
|
-
}), label ? jsx("div", {
|
|
96
|
+
children: [label ? jsx("div", {
|
|
124
97
|
className: "mb-2 text-sm font-medium",
|
|
125
98
|
children: label
|
|
126
99
|
}) : null, jsx("div", {
|
|
127
|
-
className: cn('w-full relative overflow-hidden', trackRadiusClass,
|
|
128
|
-
style:
|
|
129
|
-
backgroundColor: trackHex
|
|
130
|
-
} : {}), heightStyle),
|
|
100
|
+
className: cn('w-full relative overflow-hidden', trackRadiusClass, tone.track),
|
|
101
|
+
style: heightStyle,
|
|
131
102
|
role: "progressbar",
|
|
132
103
|
"aria-label": ariaLabel,
|
|
133
104
|
"aria-valuemin": 0,
|
|
134
105
|
"aria-valuemax": safeMax,
|
|
135
106
|
"aria-valuenow": clamped,
|
|
136
107
|
children: jsx("div", {
|
|
137
|
-
className: cn(radiusClass, heightClass,
|
|
108
|
+
className: cn(radiusClass, heightClass, tone.fill, 'text-white', 'flex items-center justify-center text-sm font-medium', 'transition-[width] duration-300 ease-out motion-reduce:transition-none', animatedClass),
|
|
138
109
|
style: finalFillStyle,
|
|
139
110
|
children: showValue ? jsxs("div", {
|
|
140
111
|
className: "px-2 whitespace-nowrap truncate",
|
|
141
|
-
style: textHex ? {
|
|
142
|
-
color: textHex
|
|
143
|
-
} : undefined,
|
|
144
112
|
children: [Math.round(percent), "%"]
|
|
145
113
|
}) : null
|
|
146
114
|
})
|
|
@@ -3,14 +3,9 @@ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _
|
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef, useId, useState, useRef, useCallback, useEffect } from 'react';
|
|
5
5
|
import PropTypes from '../../_vendor/prop-types/index.js';
|
|
6
|
+
import { cn } from '../../utils/cn.js';
|
|
6
7
|
|
|
7
8
|
var _excluded = ["id", "name", "value", "checked", "defaultChecked", "onChange", "disabled", "required", "label", "size", "labelPosition", "radioColor", "className", "ariaLabel"];
|
|
8
|
-
var cn = function cn() {
|
|
9
|
-
for (var _len = arguments.length, vals = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
10
|
-
vals[_key] = arguments[_key];
|
|
11
|
-
}
|
|
12
|
-
return vals.filter(Boolean).join(" ");
|
|
13
|
-
};
|
|
14
9
|
var SIZE_MAP = {
|
|
15
10
|
sm: {
|
|
16
11
|
outer: "h-4 w-4",
|
|
@@ -108,10 +103,13 @@ var Radio = /*#__PURE__*/forwardRef(function Radio(_ref, ref) {
|
|
|
108
103
|
var showLabelLeft = label && labelPosition === "left";
|
|
109
104
|
return jsxs("label", {
|
|
110
105
|
htmlFor: inputId,
|
|
111
|
-
className: cn(
|
|
106
|
+
className: cn(
|
|
107
|
+
// The invisible input covers the whole label, so the row is the hit
|
|
108
|
+
// area; on coarse pointers it is at least 44px tall.
|
|
109
|
+
"relative inline-flex items-center select-none gap-2 [@media(pointer:coarse)]:min-h-11", disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer", className),
|
|
112
110
|
"aria-disabled": disabled ? "true" : undefined,
|
|
113
111
|
children: [showLabelLeft && jsxs("span", {
|
|
114
|
-
className: cn(sizeClasses.label, "leading-none", disabled && "text-primary-400"),
|
|
112
|
+
className: cn(sizeClasses.label, "leading-none text-foreground", disabled && "text-primary-400"),
|
|
115
113
|
children: [label, required ? jsx("span", {
|
|
116
114
|
"aria-hidden": "true",
|
|
117
115
|
children: " *"
|
|
@@ -132,7 +130,7 @@ var Radio = /*#__PURE__*/forwardRef(function Radio(_ref, ref) {
|
|
|
132
130
|
}, props)), jsx("span", {
|
|
133
131
|
"aria-hidden": true,
|
|
134
132
|
"data-state": isChecked ? "checked" : "unchecked",
|
|
135
|
-
className: cn("inline-flex items-center justify-center rounded-full transition-
|
|
133
|
+
className: cn("inline-flex shrink-0 items-center justify-center rounded-full transition-shadow duration-fast motion-reduce:transition-none",
|
|
136
134
|
// Visible focus indicator: the native input is opacity-0, so the
|
|
137
135
|
// ring is drawn on the visual circle when the input has focus.
|
|
138
136
|
"peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500 peer-focus-visible:ring-offset-2 dark:peer-focus-visible:ring-offset-gray-900"),
|
|
@@ -140,10 +138,10 @@ var Radio = /*#__PURE__*/forwardRef(function Radio(_ref, ref) {
|
|
|
140
138
|
"--radio-accent": accentColor
|
|
141
139
|
},
|
|
142
140
|
children: jsx("span", {
|
|
143
|
-
className: cn("flex items-center justify-center rounded-full border transition-colors duration-
|
|
141
|
+
className: cn("flex items-center justify-center rounded-full border transition-colors duration-fast ease-standard motion-reduce:transition-none", isChecked ? "border-[color:var(--radio-accent)]" : "border-gray-300 dark:border-gray-600", sizeClasses.outer, disabled ? "bg-gray-100 dark:bg-gray-800" : "bg-surface", isChecked ? "shadow-inner" : ""),
|
|
144
142
|
children: jsx("span", {
|
|
145
143
|
"aria-hidden": true,
|
|
146
|
-
className: cn("rounded-full transform transition-
|
|
144
|
+
className: cn("rounded-full transform transition-[opacity,transform] duration-base ease-spring-out motion-reduce:transition-none", sizeClasses.dot),
|
|
147
145
|
style: {
|
|
148
146
|
backgroundColor: isChecked ? accentColor : "transparent",
|
|
149
147
|
opacity: isChecked ? 1 : 0,
|
|
@@ -152,7 +150,7 @@ var Radio = /*#__PURE__*/forwardRef(function Radio(_ref, ref) {
|
|
|
152
150
|
})
|
|
153
151
|
})
|
|
154
152
|
}), !showLabelLeft && label && jsxs("span", {
|
|
155
|
-
className: cn(sizeClasses.label, "leading-none", disabled && "text-primary-400"),
|
|
153
|
+
className: cn(sizeClasses.label, "leading-none text-foreground", disabled && "text-primary-400"),
|
|
156
154
|
children: [label, required ? jsx("span", {
|
|
157
155
|
"aria-hidden": "true",
|
|
158
156
|
children: " *"
|
|
@@ -5,7 +5,7 @@ import { forwardRef, useState, useRef } from 'react';
|
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
6
|
import { TOUCH_TARGET } from '../../utils/touchTarget.js';
|
|
7
7
|
|
|
8
|
-
var _excluded = ["count", "value", "defaultValue", "readOnly", "icon", "toggledIcon", "
|
|
8
|
+
var _excluded = ["count", "value", "defaultValue", "readOnly", "icon", "toggledIcon", "size", "onChange", "onClick", "text", "className", "id", "name"];
|
|
9
9
|
function StarFilled(_ref) {
|
|
10
10
|
var _ref$size = _ref.size,
|
|
11
11
|
size = _ref$size === void 0 ? 20 : _ref$size;
|
|
@@ -50,8 +50,6 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
50
50
|
readOnly = _ref3$readOnly === void 0 ? false : _ref3$readOnly,
|
|
51
51
|
icon = _ref3.icon,
|
|
52
52
|
toggledIcon = _ref3.toggledIcon,
|
|
53
|
-
activeColor = _ref3.activeColor,
|
|
54
|
-
inactiveColor = _ref3.inactiveColor,
|
|
55
53
|
_ref3$size = _ref3.size,
|
|
56
54
|
size = _ref3$size === void 0 ? 20 : _ref3$size,
|
|
57
55
|
onChange = _ref3.onChange,
|
|
@@ -71,6 +69,9 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
71
69
|
hoverValue = _useState4[0],
|
|
72
70
|
setHoverValue = _useState4[1];
|
|
73
71
|
var starRefs = useRef([]);
|
|
72
|
+
// Touch drag (DTUI-42): { pointerId, moved, value } while a finger is down.
|
|
73
|
+
var drag = useRef(null);
|
|
74
|
+
var suppressClick = useRef(false);
|
|
74
75
|
var isControlled = value != null;
|
|
75
76
|
var selectedValue = isControlled ? value : internalValue;
|
|
76
77
|
// Hover preview (pointer devices only) wins over the committed value.
|
|
@@ -103,6 +104,63 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
103
104
|
if (readOnly) return;
|
|
104
105
|
setHoverValue(null);
|
|
105
106
|
};
|
|
107
|
+
// Star under clientX: the last star whose left edge is at or before the finger,
|
|
108
|
+
// clamped to 1..count so sliding off either end keeps a valid rating.
|
|
109
|
+
var starAt = function starAt(clientX) {
|
|
110
|
+
var n = 1;
|
|
111
|
+
starRefs.current.slice(0, count).forEach(function (el, i) {
|
|
112
|
+
if (el && el.getBoundingClientRect().left <= clientX) n = i + 1;
|
|
113
|
+
});
|
|
114
|
+
return n;
|
|
115
|
+
};
|
|
116
|
+
var handleDragStart = function handleDragStart(e) {
|
|
117
|
+
var _e$currentTarget$setP, _e$currentTarget;
|
|
118
|
+
if (readOnly || e.pointerType !== "touch") return;
|
|
119
|
+
var start = starAt(e.clientX);
|
|
120
|
+
drag.current = {
|
|
121
|
+
pointerId: e.pointerId,
|
|
122
|
+
moved: false,
|
|
123
|
+
value: start,
|
|
124
|
+
startX: e.clientX
|
|
125
|
+
};
|
|
126
|
+
(_e$currentTarget$setP = (_e$currentTarget = e.currentTarget).setPointerCapture) === null || _e$currentTarget$setP === void 0 || _e$currentTarget$setP.call(_e$currentTarget, e.pointerId);
|
|
127
|
+
};
|
|
128
|
+
var handleDragMove = function handleDragMove(e) {
|
|
129
|
+
var d = drag.current;
|
|
130
|
+
if (!d || d.pointerId !== e.pointerId) return;
|
|
131
|
+
if (!d.moved && Math.abs(e.clientX - d.startX) < 4) return;
|
|
132
|
+
d.moved = true;
|
|
133
|
+
d.value = starAt(e.clientX);
|
|
134
|
+
setHoverValue(d.value);
|
|
135
|
+
};
|
|
136
|
+
var handleDragEnd = function handleDragEnd(e) {
|
|
137
|
+
var _e$currentTarget$rele, _e$currentTarget2, _starRefs$current;
|
|
138
|
+
var d = drag.current;
|
|
139
|
+
if (!d || d.pointerId !== e.pointerId) return;
|
|
140
|
+
drag.current = null;
|
|
141
|
+
(_e$currentTarget$rele = (_e$currentTarget2 = e.currentTarget).releasePointerCapture) === null || _e$currentTarget$rele === void 0 || _e$currentTarget$rele.call(_e$currentTarget2, e.pointerId);
|
|
142
|
+
setHoverValue(null);
|
|
143
|
+
if (!d.moved) return; // a plain tap: the star's click commits it
|
|
144
|
+
// The compat click that follows a drag must not re-commit the start star.
|
|
145
|
+
suppressClick.current = true;
|
|
146
|
+
setTimeout(function () {
|
|
147
|
+
suppressClick.current = false;
|
|
148
|
+
}, 400);
|
|
149
|
+
commit(d.value);
|
|
150
|
+
(_starRefs$current = starRefs.current[d.value - 1]) === null || _starRefs$current === void 0 || _starRefs$current.focus();
|
|
151
|
+
};
|
|
152
|
+
var handleDragCancel = function handleDragCancel(e) {
|
|
153
|
+
if (!drag.current || drag.current.pointerId !== e.pointerId) return;
|
|
154
|
+
drag.current = null;
|
|
155
|
+
setHoverValue(null);
|
|
156
|
+
};
|
|
157
|
+
var handleStarClick = function handleStarClick(n) {
|
|
158
|
+
if (suppressClick.current) {
|
|
159
|
+
suppressClick.current = false;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
commit(n);
|
|
163
|
+
};
|
|
106
164
|
var handleKeyDown = function handleKeyDown(e, n) {
|
|
107
165
|
if (readOnly) return;
|
|
108
166
|
if (e.key === "Enter" || e.key === " ") {
|
|
@@ -131,18 +189,26 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
131
189
|
role: "radiogroup",
|
|
132
190
|
"aria-label": name || "Rating",
|
|
133
191
|
"aria-readonly": readOnly ? "true" : undefined,
|
|
134
|
-
className: "inline-flex gap-1",
|
|
135
|
-
onPointerLeave:
|
|
136
|
-
|
|
192
|
+
className: cn("inline-flex gap-1", !readOnly && "touch-pan-y select-none"),
|
|
193
|
+
onPointerLeave: function onPointerLeave(e) {
|
|
194
|
+
if (!drag.current) clearHover();
|
|
195
|
+
},
|
|
196
|
+
onPointerCancel: function onPointerCancel(e) {
|
|
197
|
+
handleDragCancel(e);
|
|
198
|
+
clearHover();
|
|
199
|
+
},
|
|
200
|
+
onPointerDown: handleDragStart,
|
|
201
|
+
onPointerMove: handleDragMove,
|
|
202
|
+
onPointerUp: handleDragEnd,
|
|
137
203
|
children: Array.from({
|
|
138
204
|
length: count
|
|
139
205
|
}, function (_, i) {
|
|
140
206
|
var starNumber = i + 1;
|
|
141
207
|
var filled = starNumber <= (displayValue || 0);
|
|
142
208
|
var checked = starNumber === selectedValue;
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
var colorClass =
|
|
209
|
+
// Token classes only, so brands and dark mode apply (STUDIO-59). The inline
|
|
210
|
+
// activeColor / inactiveColor overrides were removed in 2.0.0 (DTUI-65).
|
|
211
|
+
var colorClass = filled ? "text-warning-400" : "text-gray-200";
|
|
146
212
|
return jsx("button", {
|
|
147
213
|
ref: function ref(el) {
|
|
148
214
|
starRefs.current[i] = el;
|
|
@@ -153,7 +219,7 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
153
219
|
"aria-label": "".concat(starNumber, " star").concat(starNumber > 1 ? "s" : ""),
|
|
154
220
|
tabIndex: !readOnly && starNumber === tabStop ? 0 : -1,
|
|
155
221
|
onClick: function onClick() {
|
|
156
|
-
return
|
|
222
|
+
return handleStarClick(starNumber);
|
|
157
223
|
},
|
|
158
224
|
onKeyDown: function onKeyDown(e) {
|
|
159
225
|
return handleKeyDown(e, starNumber);
|
|
@@ -166,10 +232,7 @@ var Rate = /*#__PURE__*/forwardRef(function Rate(_ref3, ref) {
|
|
|
166
232
|
},
|
|
167
233
|
disabled: readOnly,
|
|
168
234
|
title: "".concat(starNumber, " of ").concat(count),
|
|
169
|
-
className: cn("p-0 m-0 bg-transparent border-0 inline-flex items-center justify-center leading-0 rounded", "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500", "transition-colors motion-reduce:transition-none", TOUCH_TARGET, colorClass
|
|
170
|
-
style: color ? {
|
|
171
|
-
color: color
|
|
172
|
-
} : undefined,
|
|
235
|
+
className: cn("p-0 m-0 bg-transparent border-0 inline-flex items-center justify-center leading-0 rounded", "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500", "transition-colors motion-reduce:transition-none", TOUCH_TARGET, colorClass),
|
|
173
236
|
children: filled ? ActiveIcon : InactiveIcon
|
|
174
237
|
}, i);
|
|
175
238
|
})
|
|
@@ -3,7 +3,7 @@ import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _
|
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
|
-
import { TOUCH_TARGET } from '../../utils/touchTarget.js';
|
|
6
|
+
import { TOUCH_TARGET, PRESS_FEEDBACK } from '../../utils/touchTarget.js';
|
|
7
7
|
|
|
8
8
|
var _excluded = ["label", "avatarSrc", "avatarAlt", "initials", "size", "onRemove", "onClick", "className", "closeClass", "ariaLabel", "onKeyDown", "avatarPosition", "avatarClassname", "initialClassname"];
|
|
9
9
|
var RoundedTag = /*#__PURE__*/forwardRef(function RoundedTag(_ref, ref) {
|
|
@@ -82,7 +82,7 @@ var RoundedTag = /*#__PURE__*/forwardRef(function RoundedTag(_ref, ref) {
|
|
|
82
82
|
var gapClass = showAvatar ? s.gapWithAvatar : s.gapNoAvatar;
|
|
83
83
|
var AvatarNode = showAvatar && jsx(Fragment, {
|
|
84
84
|
children: avatarSrc ? jsx("div", {
|
|
85
|
-
className: "flex-shrink-0 rounded-full overflow-hidden bg-gray-300 flex items-center justify-center ".concat(s.avatar, " ").concat(avatarClassname),
|
|
85
|
+
className: "flex-shrink-0 rounded-full overflow-hidden bg-gray-300 dark:bg-gray-600 dark:text-gray-100 flex items-center justify-center ".concat(s.avatar, " ").concat(avatarClassname),
|
|
86
86
|
"aria-hidden": avatarSrc ? undefined : "true",
|
|
87
87
|
children: jsx("img", {
|
|
88
88
|
src: avatarSrc,
|
|
@@ -90,14 +90,14 @@ var RoundedTag = /*#__PURE__*/forwardRef(function RoundedTag(_ref, ref) {
|
|
|
90
90
|
className: "w-full h-full object-cover"
|
|
91
91
|
})
|
|
92
92
|
}) : jsx("div", {
|
|
93
|
-
className: "flex-shrink-0 rounded-full overflow-hidden bg-gray-300 flex items-center justify-center ".concat(s.avatar, " ").concat(initialClassname),
|
|
93
|
+
className: "flex-shrink-0 rounded-full overflow-hidden bg-gray-300 dark:bg-gray-600 dark:text-gray-100 flex items-center justify-center ".concat(s.avatar, " ").concat(initialClassname),
|
|
94
94
|
"aria-hidden": avatarSrc ? undefined : "true",
|
|
95
95
|
children: initials
|
|
96
96
|
})
|
|
97
97
|
});
|
|
98
98
|
return jsxs("div", _objectSpread2(_objectSpread2({
|
|
99
99
|
ref: ref,
|
|
100
|
-
className: cn("inline-flex items-center rounded-full bg-gray-100 text-primary-800", paddingClass, gapClass, s.text, clickable && "cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-1", className),
|
|
100
|
+
className: cn("inline-flex items-center rounded-full bg-gray-100 text-primary-800 dark:bg-gray-800 dark:text-gray-100", paddingClass, gapClass, s.text, clickable && ["cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-1 dark:focus-visible:ring-offset-gray-900", PRESS_FEEDBACK], className),
|
|
101
101
|
role: clickable ? "button" : "group",
|
|
102
102
|
tabIndex: clickable ? 0 : undefined,
|
|
103
103
|
"aria-label": ariaLabel,
|
|
@@ -113,7 +113,7 @@ var RoundedTag = /*#__PURE__*/forwardRef(function RoundedTag(_ref, ref) {
|
|
|
113
113
|
type: "button",
|
|
114
114
|
"aria-label": removeLabel,
|
|
115
115
|
onClick: handleRemove,
|
|
116
|
-
className: cn("inline-flex items-center justify-center rounded-full p-1 hover:bg-gray-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", TOUCH_TARGET, closeClass),
|
|
116
|
+
className: cn("inline-flex items-center justify-center rounded-full p-1 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-fast motion-reduce:transition-none focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500", TOUCH_TARGET, closeClass),
|
|
117
117
|
children: jsx("svg", {
|
|
118
118
|
"aria-hidden": "true",
|
|
119
119
|
className: "w-3 h-3",
|