@flikk/ui 1.0.0-beta.14 → 1.0.0-beta.16
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 +52 -0
- package/dist/components/ai/CodeBlock/CodeBlock.theme.js +1 -1
- package/dist/components/ai/PromptInput/PromptInput.js +3 -1
- package/dist/components/ai/PromptSuggestions/PromptSuggestion.theme.js +4 -4
- package/dist/components/ai/StreamingResponse/AnimatedText.js +3 -3
- package/dist/components/ai/StreamingResponse/MarkdownRenderer.js +22 -22
- package/dist/components/ai/StreamingResponse/StreamingCursor.js +1 -1
- package/dist/components/ai/StreamingResponse/StreamingResponse.animations.js +10 -10
- package/dist/components/ai/StreamingResponse/StreamingResponse.js +9 -3
- package/dist/components/ai/StreamingResponse/WordAnimationContext.d.ts +1 -1
- package/dist/components/ai/StreamingResponse/WordAnimationContext.js +11 -11
- package/dist/components/ai/index.d.ts +0 -7
- package/dist/components/ai/index.js +8 -6
- package/dist/components/charts/DonutChart/DonutChart.js +1 -1
- package/dist/components/charts/DonutChart/MultiSegmentDonutChart.js +1 -1
- package/dist/components/charts/shared/ChartLegend/ChartLegend.types.d.ts +13 -1
- package/dist/components/charts/shared/ChartLegend/ChartLegendContent.js +1 -1
- package/dist/components/charts/shared/ChartTooltip/ChartTooltip.types.d.ts +13 -2
- package/dist/components/core/Accordion/AccordionItem.js +1 -1
- package/dist/components/core/Accordion/AccordionTrigger.js +1 -1
- package/dist/components/core/Alert/Alert.animations.d.ts +11 -0
- package/dist/components/core/Alert/Alert.animations.js +44 -0
- package/dist/components/core/Alert/Alert.js +16 -3
- package/dist/components/core/Avatar/Avatar.js +12 -7
- package/dist/components/core/Avatar/Avatar.theme.d.ts +4 -6
- package/dist/components/core/Avatar/Avatar.theme.js +22 -12
- package/dist/components/core/Avatar/Avatar.types.d.ts +9 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.animations.js +2 -2
- package/dist/components/core/AvatarGroup/AvatarGroup.js +1 -2
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +1 -1
- package/dist/components/core/Badge/Badge.animations.js +1 -1
- package/dist/components/core/Badge/Badge.js +23 -47
- package/dist/components/core/Badge/Badge.theme.js +48 -62
- package/dist/components/core/Badge/Badge.types.d.ts +5 -29
- package/dist/components/core/Button/Button.js +2 -2
- package/dist/components/core/Button/Button.theme.js +2 -2
- package/dist/components/core/ButtonGroup/ButtonGroup.theme.js +6 -6
- package/dist/components/core/ButtonGroup/ButtonGroupText.js +1 -3
- package/dist/components/core/Calendar/Calendar.js +29 -3
- package/dist/components/core/Calendar/Calendar.theme.js +11 -7
- package/dist/components/core/Calendar/Calendar.types.d.ts +3 -0
- package/dist/components/core/Carousel/CarouselBody.js +0 -1
- package/dist/components/core/CommandPalette/CommandItem.js +1 -1
- package/dist/components/core/CommandPalette/CommandPalette.js +6 -4
- package/dist/components/core/CommandPalette/CommandPalette.theme.js +1 -0
- package/dist/components/core/CommandPalette/CommandPalette.types.d.ts +6 -0
- package/dist/components/core/ContextMenu/ContextMenu.js +5 -4
- package/dist/components/core/ContextMenu/ContextMenuTrigger.js +5 -6
- package/dist/components/core/Drawer/Drawer.d.ts +1 -1
- package/dist/components/core/Drawer/Drawer.js +25 -2
- package/dist/components/core/Drawer/Drawer.theme.js +2 -2
- package/dist/components/core/Drawer/Drawer.types.d.ts +6 -0
- package/dist/components/core/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/core/Dropdown/Dropdown.js +5 -1
- package/dist/components/core/Dropdown/Dropdown.types.d.ts +1 -0
- package/dist/components/core/Dropdown/DropdownItem.js +1 -1
- package/dist/components/core/Dropdown/DropdownMenu.js +4 -4
- package/dist/components/core/Dropdown/DropdownSection.js +1 -1
- package/dist/components/core/Dropdown/DropdownSeparator.js +1 -1
- package/dist/components/core/Dropdown/DropdownTrigger.d.ts +6 -1
- package/dist/components/core/Dropdown/DropdownTrigger.js +10 -8
- package/dist/components/core/Kbd/Kbd.theme.js +3 -3
- package/dist/components/core/Link/Link.js +3 -1
- package/dist/components/core/Message/Message.d.ts +9 -0
- package/dist/components/core/Message/Message.js +44 -3
- package/dist/components/core/Message/Message.theme.js +22 -0
- package/dist/components/core/Message/Message.types.d.ts +115 -0
- package/dist/components/core/Message/MessageAudio.d.ts +8 -0
- package/dist/components/core/Message/MessageAudio.js +11 -0
- package/dist/components/core/Message/MessageContext.d.ts +3 -1
- package/dist/components/core/Message/MessageDateDivider.d.ts +6 -0
- package/dist/components/core/Message/MessageDateDivider.js +10 -0
- package/dist/components/core/Message/MessageFile.d.ts +9 -0
- package/dist/components/core/Message/MessageFile.js +15 -0
- package/dist/components/core/Message/MessageImage.d.ts +11 -0
- package/dist/components/core/Message/MessageImage.js +13 -0
- package/dist/components/core/Message/MessageLink.d.ts +10 -0
- package/dist/components/core/Message/MessageLink.js +15 -0
- package/dist/components/core/Message/MessageReactions.d.ts +8 -0
- package/dist/components/core/Message/MessageReactions.js +12 -0
- package/dist/components/core/Message/MessageReply.d.ts +8 -0
- package/dist/components/core/Message/MessageReply.js +10 -0
- package/dist/components/core/Message/MessageSenderName.d.ts +6 -0
- package/dist/components/core/Message/MessageSenderName.js +10 -0
- package/dist/components/core/Message/MessageStatusIndicator.d.ts +9 -0
- package/dist/components/core/Message/MessageStatusIndicator.js +45 -0
- package/dist/components/core/Message/index.d.ts +19 -1
- package/dist/components/core/Modal/Modal.animations.d.ts +1 -0
- package/dist/components/core/Modal/Modal.animations.js +14 -11
- package/dist/components/core/Pagination/Pagination.theme.js +1 -1
- package/dist/components/core/Popover/Popover.d.ts +1 -1
- package/dist/components/core/Popover/PopoverBody.js +2 -2
- package/dist/components/core/Popover/PopoverTrigger.d.ts +1 -1
- package/dist/components/core/Popover/PopoverTrigger.js +11 -11
- package/dist/components/core/Progress/Progress.d.ts +9 -8
- package/dist/components/core/Progress/Progress.js +16 -16
- package/dist/components/core/Progress/Progress.theme.js +4 -15
- package/dist/components/core/Progress/Progress.types.d.ts +2 -20
- package/dist/components/core/Progress/index.d.ts +1 -1
- package/dist/components/core/ScrollArea/ScrollArea.js +49 -7
- package/dist/components/core/ScrollArea/ScrollArea.types.d.ts +12 -3
- package/dist/components/core/ScrollArea/index.d.ts +1 -1
- package/dist/components/core/Segmented/SegmentedItem.js +1 -1
- package/dist/components/core/Sidebar/Sidebar.js +2 -1
- package/dist/components/core/Sidebar/SidebarMobileTrigger.js +2 -1
- package/dist/components/core/Sidebar/SidebarToggle.js +2 -1
- package/dist/components/core/Sidebar/SidebarUserProfile.js +1 -1
- package/dist/components/core/SocialIcon/SocialIcon.js +1 -1
- package/dist/components/core/Sortable/Sortable.js +2 -2
- package/dist/components/core/Sortable/Sortable.theme.js +1 -1
- package/dist/components/core/Sortable/Sortable.types.d.ts +7 -5
- package/dist/components/core/Tabs/TabsBody.js +1 -1
- package/dist/components/core/Tabs/TabsTrigger.js +1 -1
- package/dist/components/core/Tag/Tag.js +2 -2
- package/dist/components/core/Toast/Toast.d.ts +2 -2
- package/dist/components/core/Toast/Toast.js +30 -21
- package/dist/components/core/Toast/Toast.theme.js +4 -9
- package/dist/components/core/Toast/Toast.types.d.ts +4 -21
- package/dist/components/core/Toast/index.d.ts +1 -1
- package/dist/components/core/Tooltip/Tooltip.js +1 -1
- package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
- package/dist/components/core/index.js +9 -0
- package/dist/components/data-display/GanttChart/GanttChart.types.d.ts +2 -2
- package/dist/components/data-display/Table/Table.types.d.ts +8 -8
- package/dist/components/effects/CustomCursor/CustomCursor.js +2 -2
- package/dist/components/effects/GlassSurface/GlassSurface.d.ts +1 -1
- package/dist/components/effects/GlassSurface/GlassSurface.js +17 -9
- package/dist/components/effects/GlassSurface/GlassSurface.types.d.ts +6 -0
- package/dist/components/effects/InteractiveCharacters/InteractiveCharacters.animations.d.ts +39 -0
- package/dist/components/effects/InteractiveCharacters/InteractiveCharacters.animations.js +98 -0
- package/dist/components/effects/InteractiveCharacters/InteractiveCharacters.d.ts +3 -0
- package/dist/components/effects/InteractiveCharacters/InteractiveCharacters.js +104 -0
- package/dist/components/effects/InteractiveCharacters/InteractiveCharacters.types.d.ts +30 -0
- package/dist/components/effects/InteractiveCharacters/characters/BlobCharacter.d.ts +3 -0
- package/dist/components/effects/InteractiveCharacters/characters/BlobCharacter.js +36 -0
- package/dist/components/effects/InteractiveCharacters/characters/SmallCharacter.d.ts +3 -0
- package/dist/components/effects/InteractiveCharacters/characters/SmallCharacter.js +36 -0
- package/dist/components/effects/InteractiveCharacters/characters/TallCharacter.d.ts +3 -0
- package/dist/components/effects/InteractiveCharacters/characters/TallCharacter.js +37 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useBlink.d.ts +14 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useBlink.js +41 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useIdleAnimation.d.ts +25 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useIdleAnimation.js +84 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useMouseTracking.d.ts +18 -0
- package/dist/components/effects/InteractiveCharacters/hooks/useMouseTracking.js +35 -0
- package/dist/components/effects/InteractiveCharacters/index.d.ts +2 -0
- package/dist/components/effects/MorphingText/MorphingText.d.ts +1 -1
- package/dist/components/effects/MorphingText/MorphingText.js +6 -5
- package/dist/components/effects/Neumorphic/InsetCircleButton.d.ts +10 -0
- package/dist/components/effects/Neumorphic/InsetCircleButton.js +10 -0
- package/dist/components/effects/Neumorphic/InsetPill.d.ts +8 -0
- package/dist/components/effects/Neumorphic/InsetPill.js +7 -0
- package/dist/components/effects/Neumorphic/index.d.ts +4 -0
- package/dist/components/effects/NoiseOverlay/NoiseOverlay.d.ts +1 -1
- package/dist/components/effects/NoiseOverlay/NoiseOverlay.js +4 -4
- package/dist/components/effects/Overlay/Overlay.js +6 -4
- package/dist/components/effects/PageTransition/PageTransition.animations.d.ts +8 -0
- package/dist/components/effects/PageTransition/PageTransition.animations.js +53 -0
- package/dist/components/effects/PageTransition/PageTransition.d.ts +3 -0
- package/dist/components/effects/PageTransition/PageTransition.js +71 -0
- package/dist/components/effects/PageTransition/PageTransition.types.d.ts +15 -0
- package/dist/components/effects/PageTransition/index.d.ts +2 -0
- package/dist/components/effects/index.d.ts +6 -0
- package/dist/components/effects/index.js +4 -0
- package/dist/components/forms/Checkbox/Checkbox.animations.d.ts +14 -0
- package/dist/components/forms/Checkbox/Checkbox.animations.js +53 -0
- package/dist/components/forms/Checkbox/Checkbox.js +4 -2
- package/dist/components/forms/Checkbox/Checkbox.theme.js +3 -3
- package/dist/components/forms/ColorPicker/ColorPicker.types.d.ts +1 -1
- package/dist/components/forms/ColorPicker/ColorPickerBody.js +3 -3
- package/dist/components/forms/Combobox/Combobox.js +5 -3
- package/dist/components/forms/DatePicker/DatePickerBody.js +1 -1
- package/dist/components/forms/DateRangePicker/DateRangePicker.animations.d.ts +1 -0
- package/dist/components/forms/DateRangePicker/DateRangePicker.d.ts +37 -0
- package/dist/components/forms/DateRangePicker/DateRangePicker.js +110 -0
- package/dist/components/forms/DateRangePicker/DateRangePicker.theme.d.ts +5 -0
- package/dist/components/forms/DateRangePicker/DateRangePicker.theme.js +52 -0
- package/dist/components/forms/DateRangePicker/DateRangePicker.types.d.ts +154 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerBody.d.ts +6 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerBody.js +208 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerPresets.d.ts +6 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerPresets.js +41 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerTrigger.d.ts +6 -0
- package/dist/components/forms/DateRangePicker/DateRangePickerTrigger.js +32 -0
- package/dist/components/forms/DateRangePicker/dateRangePresets.d.ts +5 -0
- package/dist/components/forms/DateRangePicker/dateRangePresets.js +59 -0
- package/dist/components/forms/DateRangePicker/index.d.ts +4 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.animations.d.ts +36 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.animations.js +22 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.d.ts +3 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.js +111 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.theme.d.ts +19 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.theme.js +27 -0
- package/dist/components/forms/FileUpload/FileUploadProgress.types.d.ts +33 -0
- package/dist/components/forms/FileUpload/index.d.ts +3 -0
- package/dist/components/forms/Input/Input.js +8 -13
- package/dist/components/forms/Input/Input.types.d.ts +6 -0
- package/dist/components/forms/InputAddress/InputAddress.theme.js +1 -1
- package/dist/components/forms/InputCounter/InputCounter.js +1 -1
- package/dist/components/forms/InputCreditCard/InputCreditCard.theme.js +1 -1
- package/dist/components/forms/InputOTP/InputOTP.theme.js +1 -1
- package/dist/components/forms/Radio/Radio.animations.d.ts +10 -0
- package/dist/components/forms/Radio/Radio.animations.js +33 -0
- package/dist/components/forms/Radio/Radio.js +11 -2
- package/dist/components/forms/Radio/Radio.theme.js +3 -3
- package/dist/components/forms/RichTextEditor/RichTextEditor.js +13 -4
- package/dist/components/forms/RichTextEditor/RichTextEditor.theme.js +2 -2
- package/dist/components/forms/RichTextEditor/RichTextEditor.types.d.ts +11 -0
- package/dist/components/forms/Select/Select.d.ts +1 -1
- package/dist/components/forms/Select/Select.js +7 -7
- package/dist/components/forms/Select/Select.types.d.ts +3 -3
- package/dist/components/forms/SelectableCard/SelectableCard.js +1 -1
- package/dist/components/forms/Slider/Slider.js +10 -3
- package/dist/components/forms/Slider/Slider.theme.js +3 -3
- package/dist/components/forms/Switch/Switch.js +10 -2
- package/dist/components/forms/Switch/Switch.theme.js +3 -3
- package/dist/components/forms/forms.theme.js +1 -1
- package/dist/components/forms/index.d.ts +6 -3
- package/dist/components/forms/index.js +8 -2
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useMediaQuery.d.ts +5 -0
- package/dist/hooks/useMediaQuery.js +21 -0
- package/dist/index.js +21 -2
- package/dist/styles.css +1 -1
- package/dist/utils/dateUtils.js +56 -5
- package/dist/utils/formatUtils.d.ts +10 -0
- package/dist/utils/formatUtils.js +24 -0
- package/dist/utils/index.d.ts +1 -1
- package/package.json +12 -4
- package/src/global.scss +319 -39
- package/src/styles/theme.css +105 -16
- package/src/theme-plugin.css +13 -0
- package/dist/components/ai/ApprovalCard/ApprovalCard.d.ts +0 -3
- package/dist/components/ai/ApprovalCard/ApprovalCard.js +0 -16
- package/dist/components/ai/ApprovalCard/ApprovalCard.theme.d.ts +0 -13
- package/dist/components/ai/ApprovalCard/ApprovalCard.theme.js +0 -15
- package/dist/components/ai/ApprovalCard/ApprovalCard.types.d.ts +0 -43
- package/dist/components/ai/ApprovalCard/index.d.ts +0 -2
- package/dist/components/ai/MessageHistory/MessageHistory.d.ts +0 -18
- package/dist/components/ai/MessageHistory/MessageHistory.js +0 -98
- package/dist/components/ai/MessageHistory/MessageHistory.theme.d.ts +0 -2
- package/dist/components/ai/MessageHistory/MessageHistory.theme.js +0 -8
- package/dist/components/ai/MessageHistory/MessageHistory.types.d.ts +0 -94
- package/dist/components/ai/MessageHistory/index.d.ts +0 -3
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.animations.d.ts +0 -10
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.animations.js +0 -47
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.d.ts +0 -20
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.js +0 -55
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.theme.d.ts +0 -2
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.theme.js +0 -20
- package/dist/components/ai/ThinkingIndicator/ThinkingIndicator.types.d.ts +0 -67
- package/dist/components/ai/ThinkingIndicator/index.d.ts +0 -3
- package/dist/components/forms/TransferList/TransferList.animations.d.ts +0 -10
- package/dist/components/forms/TransferList/TransferList.animations.js +0 -32
- package/dist/components/forms/TransferList/TransferList.d.ts +0 -28
- package/dist/components/forms/TransferList/TransferList.js +0 -199
- package/dist/components/forms/TransferList/TransferList.theme.d.ts +0 -6
- package/dist/components/forms/TransferList/TransferList.theme.js +0 -60
- package/dist/components/forms/TransferList/TransferList.types.d.ts +0 -101
- package/dist/components/forms/TransferList/index.d.ts +0 -3
- package/dist/icons/Icon.d.ts +0 -24
- package/dist/icons/Icon.js +0 -30
- package/dist/icons/Index.d.ts +0 -16
- package/dist/icons/core/ChevronUpDown.d.ts +0 -1
- package/dist/icons/core/ChevronUpDown.js +0 -7
- package/dist/icons/core/DollarIcon.d.ts +0 -1
- package/dist/icons/core/DollarIcon.js +0 -5
- package/dist/icons/core/LockIcon.d.ts +0 -1
- package/dist/icons/core/LockIcon.js +0 -5
- package/dist/icons/core/MinusIcon.d.ts +0 -1
- package/dist/icons/core/MinusIcon.js +0 -7
- package/dist/icons/core/PlusIcon.d.ts +0 -1
- package/dist/icons/core/PlusIcon.js +0 -7
- package/dist/icons/core/SearchIcon.d.ts +0 -1
- package/dist/icons/core/SearchIcon.js +0 -7
- package/dist/icons/core/TickIcon.d.ts +0 -1
- package/dist/icons/core/TickIcon.js +0 -5
- package/dist/icons/core/User.d.ts +0 -1
- package/dist/utils/useClickOutside.d.ts +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert entrance/exit animation variants
|
|
3
|
+
* Entrance: slide down from -8px + fade in
|
|
4
|
+
* Exit: fade out + collapse height
|
|
5
|
+
*/
|
|
6
|
+
const alertVariants = {
|
|
7
|
+
hidden: {
|
|
8
|
+
opacity: 0,
|
|
9
|
+
y: -8,
|
|
10
|
+
height: 0,
|
|
11
|
+
paddingTop: 0,
|
|
12
|
+
paddingBottom: 0,
|
|
13
|
+
marginTop: 0,
|
|
14
|
+
marginBottom: 0,
|
|
15
|
+
overflow: "hidden",
|
|
16
|
+
transition: {
|
|
17
|
+
duration: 0.15,
|
|
18
|
+
ease: [0.4, 0, 1, 1],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
visible: {
|
|
22
|
+
opacity: 1,
|
|
23
|
+
y: 0,
|
|
24
|
+
height: "auto",
|
|
25
|
+
paddingTop: undefined,
|
|
26
|
+
paddingBottom: undefined,
|
|
27
|
+
marginTop: undefined,
|
|
28
|
+
marginBottom: undefined,
|
|
29
|
+
overflow: "visible",
|
|
30
|
+
transition: {
|
|
31
|
+
duration: 0.2,
|
|
32
|
+
ease: [0.4, 0, 0.2, 1],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Reduced motion variants — instant opacity toggle, no slide or collapse
|
|
38
|
+
*/
|
|
39
|
+
const reducedMotionAlertVariants = {
|
|
40
|
+
hidden: { opacity: 0 },
|
|
41
|
+
visible: { opacity: 1 },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { alertVariants, reducedMotionAlertVariants };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import React__default from 'react';
|
|
2
|
+
import React__default, { useState } from 'react';
|
|
3
|
+
import { useReducedMotion, motion } from 'motion/react';
|
|
3
4
|
import { cn } from '../../../utils/cn.js';
|
|
4
5
|
import { alertTheme } from './Alert.theme.js';
|
|
6
|
+
import { reducedMotionAlertVariants, alertVariants } from './Alert.animations.js';
|
|
5
7
|
import { XMarkIcon, XCircleIcon, ExclamationTriangleIcon, CheckCircleIcon, InformationCircleIcon, BellIcon } from '@heroicons/react/24/solid';
|
|
6
8
|
import { Button } from '../Button/Button.js';
|
|
7
9
|
|
|
@@ -15,10 +17,16 @@ const defaultIcons = {
|
|
|
15
17
|
};
|
|
16
18
|
const Alert = React__default.forwardRef(({ variant = "default", color = "primary", title, subtitle, dismissible, icon, showIcon = true, avatar, actions, onDismiss, className, children, darkMode = false, ...props }, ref) => {
|
|
17
19
|
var _a;
|
|
20
|
+
const shouldReduceMotion = useReducedMotion();
|
|
21
|
+
const [isDismissing, setIsDismissing] = useState(false);
|
|
18
22
|
const iconColor = (_a = alertTheme.iconColors[color]) !== null && _a !== void 0 ? _a : alertTheme.iconColors.primary;
|
|
19
23
|
const showDismiss = dismissible === true || (dismissible !== false && !!onDismiss);
|
|
20
24
|
const handleDismiss = () => {
|
|
21
|
-
|
|
25
|
+
if (shouldReduceMotion) {
|
|
26
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setIsDismissing(true);
|
|
22
30
|
};
|
|
23
31
|
const renderIconOrAvatar = () => {
|
|
24
32
|
if (avatar) {
|
|
@@ -33,11 +41,16 @@ const Alert = React__default.forwardRef(({ variant = "default", color = "primary
|
|
|
33
41
|
const IconComponent = defaultIcons[color];
|
|
34
42
|
return (jsx("div", { className: "flex-shrink-0 w-6 h-6 mt-1", "aria-hidden": "true", children: jsx(IconComponent, { className: cn("w-6 h-6", iconColor) }) }));
|
|
35
43
|
};
|
|
36
|
-
const
|
|
44
|
+
const alertContent = (jsxs("div", { ref: ref, className: cn(alertTheme.baseStyle, alertTheme.variants[variant], className), role: "alert", "aria-live": "assertive", "aria-atomic": "true", ...props, children: [renderIconOrAvatar(), jsxs("div", { className: `flex-1 min-w-0 ${showDismiss ? "mr-5" : ""}`, children: [title && (typeof title === 'string'
|
|
37
45
|
? jsx("div", { className: cn("font-semibold text-[var(--color-text-primary)]"), children: title })
|
|
38
46
|
: title), subtitle && (typeof subtitle === 'string'
|
|
39
47
|
? jsx("div", { className: "text-[var(--color-text-secondary)]/90 mt-1", children: subtitle })
|
|
40
48
|
: subtitle), children && jsx("div", { className: "mt-2", children: children }), actions && (jsx("div", { className: "flex items-center gap-2 mt-6", children: actions }))] }), showDismiss && (jsx(Button, { variant: "link", color: "neutral", size: "sm", iconOnly: true, onClick: handleDismiss, "aria-label": "Dismiss alert", className: "rounded-full absolute top-2 right-2 flex-shrink-0", children: jsx(XMarkIcon, { className: "size-4", strokeWidth: 2 }) }))] }));
|
|
49
|
+
const alertNode = (jsx(motion.div, { variants: shouldReduceMotion ? reducedMotionAlertVariants : alertVariants, initial: "hidden", animate: isDismissing ? "hidden" : "visible", onAnimationComplete: (definition) => {
|
|
50
|
+
if (definition === "hidden" && isDismissing) {
|
|
51
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
52
|
+
}
|
|
53
|
+
}, children: alertContent }));
|
|
41
54
|
if (darkMode) {
|
|
42
55
|
return jsx("div", { className: "dark", children: alertNode });
|
|
43
56
|
}
|
|
@@ -6,7 +6,7 @@ import { Tooltip } from '../Tooltip/Tooltip.js';
|
|
|
6
6
|
import '../Tooltip/Tooltip.animations.js';
|
|
7
7
|
import { UserIcon } from '@heroicons/react/24/solid';
|
|
8
8
|
|
|
9
|
-
const Avatar = React__default.forwardRef(({ src, name, size = "md", status = "none", fallback, className, role, lazyLoad = true, retryCount = 0, retryDelay = 1000, contextualLabel, groupPosition, showTooltip = false, initialsCount = 2, ...props }, ref) => {
|
|
9
|
+
const Avatar = React__default.forwardRef(({ src, name, size = "md", status = "none", fallback, className, role, lazyLoad = true, retryCount = 0, retryDelay = 1000, contextualLabel, groupPosition, showTooltip = false, initialsCount = 2, title, subtitle, ...props }, ref) => {
|
|
10
10
|
const [imageError, setImageError] = useState(false);
|
|
11
11
|
const [retries, setRetries] = useState(0);
|
|
12
12
|
const retryTimerRef = useRef(null);
|
|
@@ -86,13 +86,18 @@ const Avatar = React__default.forwardRef(({ src, name, size = "md", status = "no
|
|
|
86
86
|
: (resolvedName !== null && resolvedName !== void 0 ? resolvedName : "Avatar");
|
|
87
87
|
// Determine appropriate ARIA role
|
|
88
88
|
const ariaRole = role || (src ? undefined : "img");
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
//
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
const resolvedTitle = title !== null && title !== void 0 ? title : (subtitle ? resolvedName : undefined);
|
|
90
|
+
const hasTextSection = !!(resolvedTitle || subtitle);
|
|
91
|
+
// The avatar circle with status indicator
|
|
92
|
+
const avatarCircle = (jsxs("div", { className: cn("relative inline-flex avatar-wrapper shrink-0", groupPosition), children: [jsx("div", { className: cn(avatarTheme.baseStyle, avatarTheme.sizes[size], className), "aria-hidden": ariaRole === "presentation" ? "true" : undefined, "data-size": size, children: src && !imageError ? (jsx("img", { src: src, alt: resolvedName !== null && resolvedName !== void 0 ? resolvedName : "Avatar", className: "size-full object-cover object-top", onError: handleImageError, loading: lazyLoad ? "lazy" : undefined, "aria-hidden": ariaRole === "presentation" ? "true" : undefined, "data-loaded": "true" })) : (jsx("div", { className: "avatar-fallback flex items-center justify-center size-full", children: getFallbackContent() })) }), status !== "none" && (jsx("span", { className: cn("absolute rounded-full ring-2 ring-[var(--color-background)]", getStatusSize(), avatarTheme.statuses[status]), "aria-label": `Status: ${status}`, role: "status", "data-status": status }))] }));
|
|
93
|
+
// Wrap circle in tooltip if needed
|
|
94
|
+
const avatarWithTooltip = showTooltip && resolvedName ? (jsx(Tooltip, { content: resolvedName, placement: "top", children: avatarCircle })) : (avatarCircle);
|
|
95
|
+
// If no text section, render just the avatar
|
|
96
|
+
if (!hasTextSection) {
|
|
97
|
+
return (jsx("div", { ref: ref, role: ariaRole === "presentation" ? "presentation" : undefined, "aria-label": ariaRole === "presentation" ? undefined : accessibilityLabel, "data-size": size, "data-status": status, "data-error": imageError ? "true" : "false", ...props, children: avatarWithTooltip }));
|
|
94
98
|
}
|
|
95
|
-
|
|
99
|
+
// Render avatar with text section
|
|
100
|
+
return (jsxs("div", { ref: ref, className: cn("inline-flex items-center", avatarTheme.gapSizes[size]), role: ariaRole === "presentation" ? "presentation" : undefined, "aria-label": ariaRole === "presentation" ? undefined : accessibilityLabel, "data-size": size, "data-status": status, "data-error": imageError ? "true" : "false", ...props, children: [avatarWithTooltip, jsxs("div", { className: "min-w-0", children: [resolvedTitle && (jsx("div", { className: cn(avatarTheme.titleStyle, avatarTheme.textSizes[size]), children: resolvedTitle })), subtitle && (jsx("div", { className: cn(avatarTheme.subtitleStyle, avatarTheme.textSizes[size]), children: subtitle }))] })] }));
|
|
96
101
|
});
|
|
97
102
|
// Set display name for dev tools and Storybook
|
|
98
103
|
Avatar.displayName = "Avatar";
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { AvatarSize, AvatarStatus } from "./Avatar.types";
|
|
2
|
-
/**
|
|
3
|
-
* Internal theme structure for the Avatar component
|
|
4
|
-
*/
|
|
5
2
|
interface AvatarTheme {
|
|
6
3
|
baseStyle: string;
|
|
7
4
|
sizes: Record<AvatarSize, string>;
|
|
8
5
|
statuses: Record<AvatarStatus, string>;
|
|
6
|
+
titleStyle: string;
|
|
7
|
+
subtitleStyle: string;
|
|
8
|
+
textSizes: Record<AvatarSize, string>;
|
|
9
|
+
gapSizes: Record<AvatarSize, string>;
|
|
9
10
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Default theme for the Avatar component
|
|
12
|
-
*/
|
|
13
11
|
export declare const avatarTheme: AvatarTheme;
|
|
14
12
|
export {};
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default theme for the Avatar component
|
|
3
|
-
*/
|
|
4
1
|
const avatarTheme = {
|
|
5
|
-
|
|
6
|
-
baseStyle: "relative inline-flex items-center justify-center overflow-hidden bg-neutral-200 text-[var(--color-text-primary)] font-bold tracking-tighter rounded-[var(--avatar-radius)] border border-[var(--color-border)] transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)] focus-visible:ring-offset-2",
|
|
7
|
-
// Size variants using CSS variables
|
|
2
|
+
baseStyle: "relative inline-flex items-center justify-center overflow-hidden bg-[var(--color-surface)] text-[var(--color-text-primary)] font-bold tracking-tighter rounded-[var(--avatar-radius)] border border-[var(--color-border)] transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)] focus-visible:ring-offset-2",
|
|
8
3
|
sizes: {
|
|
9
|
-
xs: "size-[var(--avatar-size-xs)] text-
|
|
4
|
+
xs: "size-[var(--avatar-size-xs)] text-sm",
|
|
10
5
|
sm: "size-[var(--avatar-size-sm)] text-sm",
|
|
11
|
-
md: "size-[var(--avatar-size-md)] text-
|
|
12
|
-
lg: "size-[var(--avatar-size-lg)] text-
|
|
13
|
-
xl: "size-[var(--avatar-size-xl)] text-
|
|
6
|
+
md: "size-[var(--avatar-size-md)] text-base",
|
|
7
|
+
lg: "size-[var(--avatar-size-lg)] text-base",
|
|
8
|
+
xl: "size-[var(--avatar-size-xl)] text-base",
|
|
14
9
|
},
|
|
15
|
-
// Status indicator styles
|
|
16
10
|
statuses: {
|
|
17
11
|
online: "bg-[var(--color-success)]",
|
|
18
|
-
offline: "bg-
|
|
12
|
+
offline: "bg-[var(--color-text-muted)]",
|
|
19
13
|
busy: "bg-[var(--color-danger)]",
|
|
20
14
|
away: "bg-[var(--color-warning)]",
|
|
21
15
|
none: "",
|
|
22
16
|
},
|
|
17
|
+
titleStyle: "font-medium leading-tight text-[var(--color-text-primary)] truncate",
|
|
18
|
+
subtitleStyle: "leading-tight text-[var(--color-text-muted)] truncate",
|
|
19
|
+
textSizes: {
|
|
20
|
+
xs: "text-sm",
|
|
21
|
+
sm: "text-sm",
|
|
22
|
+
md: "text-base",
|
|
23
|
+
lg: "text-base",
|
|
24
|
+
xl: "text-base",
|
|
25
|
+
},
|
|
26
|
+
gapSizes: {
|
|
27
|
+
xs: "gap-1.5",
|
|
28
|
+
sm: "gap-2",
|
|
29
|
+
md: "gap-2.5",
|
|
30
|
+
lg: "gap-3",
|
|
31
|
+
xl: "gap-3",
|
|
32
|
+
},
|
|
23
33
|
};
|
|
24
34
|
|
|
25
35
|
export { avatarTheme };
|
|
@@ -67,4 +67,13 @@ export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
67
67
|
* @default 2
|
|
68
68
|
*/
|
|
69
69
|
initialsCount?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Title text displayed next to the avatar.
|
|
72
|
+
* Defaults to `name` if not provided.
|
|
73
|
+
*/
|
|
74
|
+
title?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Subtitle text displayed below the title (e.g., email, role).
|
|
77
|
+
*/
|
|
78
|
+
subtitle?: string;
|
|
70
79
|
}
|
|
@@ -48,8 +48,7 @@ const AvatarGroup = React__default.forwardRef(({ avatars = [], max = 5, size = "
|
|
|
48
48
|
index > 0 ? spacingClass : "z-10"), "data-position": position, "data-index": index, ...motionProps, children: jsx(Avatar, { size: size, ...avatarProps, contextualLabel: contextLabel,
|
|
49
49
|
// Ensure that groupPosition is not passed to avoid conflicts
|
|
50
50
|
groupPosition: undefined }) }, index));
|
|
51
|
-
}), overflowCount > 0 && (jsx("div", { className: cn(spacingClass,
|
|
52
|
-
"transition-transform duration-200 hover:scale-110"), "data-overflow-count": overflowCount, children: overflowIndicator ? (overflowIndicator(overflowCount)) : (jsx(Avatar, { size: size, name: `+${overflowCount} more`, fallback: jsxs("span", { children: ["+", overflowCount] }), className: avatarGroupTheme.overflowAvatarStyle, role: "img", "aria-label": `+ ${overflowCount} more users` })) }))] }));
|
|
51
|
+
}), overflowCount > 0 && (jsx("div", { className: cn(spacingClass, "self-center"), "data-overflow-count": overflowCount, children: overflowIndicator ? (overflowIndicator(overflowCount)) : (jsx(Avatar, { size: size, name: `+${overflowCount} more`, fallback: jsxs("span", { children: ["+", overflowCount] }), className: avatarGroupTheme.overflowAvatarStyle, role: "img", "aria-label": `+ ${overflowCount} more users` })) }))] }));
|
|
53
52
|
});
|
|
54
53
|
// Set display name for dev tools and Storybook
|
|
55
54
|
AvatarGroup.displayName = "AvatarGroup";
|
|
@@ -11,7 +11,7 @@ const avatarGroupTheme = {
|
|
|
11
11
|
loose: "-ml-2 z-10",
|
|
12
12
|
},
|
|
13
13
|
// Overflow avatar styles
|
|
14
|
-
overflowAvatarStyle: "bg-[var(--color-
|
|
14
|
+
overflowAvatarStyle: "bg-[var(--color-surface)] text-[var(--color-text-secondary)] font-semibold text-sm flex items-center justify-center size-7",
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { avatarGroupTheme };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import React__default, { useState, useMemo,
|
|
2
|
+
import React__default, { useState, useMemo, useCallback } from 'react';
|
|
3
3
|
import { AnimatePresence, motion } from 'motion/react';
|
|
4
4
|
import { XMarkIcon } from '@heroicons/react/24/outline';
|
|
5
|
+
import { UserIcon } from '@heroicons/react/16/solid';
|
|
5
6
|
import { cn } from '../../../utils/cn.js';
|
|
6
7
|
import { Avatar } from '../Avatar/Avatar.js';
|
|
7
8
|
import { animationTiming, dismissVariants, badgeVariants, dismissButtonVariants, dotVariants } from './Badge.animations.js';
|
|
@@ -31,16 +32,11 @@ const getShouldAnimate = () => {
|
|
|
31
32
|
* <Badge dismissible onDismiss={handleDismiss}>Removable</Badge>
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
34
|
-
const Badge = React__default.memo(React__default.forwardRef(({ children, variant = "filled", color = "primary", size = "md", pill = false, withDot = false, iconStart, avatar, dismissible = false, onDismiss,
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q
|
|
35
|
+
const Badge = React__default.memo(React__default.forwardRef(({ children, variant = "filled", color = "primary", size = "md", pill = false, withDot = false, iconStart, avatar, dismissible = false, onDismiss, disabled = false, maxWidth, className, theme: customTheme = {}, onClick, darkMode = false, ...props }, ref) => {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
36
37
|
// State management
|
|
37
38
|
const [isVisible, setIsVisible] = useState(true);
|
|
38
|
-
const [isSelected, setIsSelected] = useState(selected);
|
|
39
39
|
const shouldAnimate = useMemo(getShouldAnimate, []);
|
|
40
|
-
// Sync internal state with controlled prop
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
setIsSelected(selected);
|
|
43
|
-
}, [selected]);
|
|
44
40
|
// Development-only warnings
|
|
45
41
|
if (process.env.NODE_ENV !== "production") {
|
|
46
42
|
if (dismissible && !onDismiss) {
|
|
@@ -49,9 +45,6 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
49
45
|
if (avatar && iconStart) {
|
|
50
46
|
console.warn("[Badge]: Both avatar and iconStart provided. Avatar takes precedence.");
|
|
51
47
|
}
|
|
52
|
-
if (selectable && !onSelect && selected === undefined) {
|
|
53
|
-
console.warn("[Badge]: selectable is true but no onSelect callback or selected prop provided. Component will work in uncontrolled mode.");
|
|
54
|
-
}
|
|
55
48
|
}
|
|
56
49
|
// Handle dismiss button click
|
|
57
50
|
const handleDismiss = useCallback((e) => {
|
|
@@ -62,17 +55,12 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
62
55
|
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss(e);
|
|
63
56
|
}, animationTiming.dismissDelay);
|
|
64
57
|
}, [onDismiss]);
|
|
65
|
-
// Handle badge click
|
|
58
|
+
// Handle badge click
|
|
66
59
|
const handleClick = useCallback((e) => {
|
|
67
60
|
if (disabled)
|
|
68
61
|
return;
|
|
69
|
-
if (selectable) {
|
|
70
|
-
const newSelected = !isSelected;
|
|
71
|
-
setIsSelected(newSelected);
|
|
72
|
-
onSelect === null || onSelect === void 0 ? void 0 : onSelect(newSelected);
|
|
73
|
-
}
|
|
74
62
|
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
75
|
-
}, [
|
|
63
|
+
}, [onClick, disabled]);
|
|
76
64
|
// Merge default theme with custom theme overrides
|
|
77
65
|
const theme = {
|
|
78
66
|
...badgeTheme,
|
|
@@ -103,10 +91,6 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
103
91
|
...badgeTheme.pillSizes,
|
|
104
92
|
...customTheme.pillSizes,
|
|
105
93
|
},
|
|
106
|
-
radiusSizes: {
|
|
107
|
-
...badgeTheme.radiusSizes,
|
|
108
|
-
...customTheme.radiusSizes,
|
|
109
|
-
},
|
|
110
94
|
iconSizes: {
|
|
111
95
|
...badgeTheme.iconSizes,
|
|
112
96
|
...customTheme.iconSizes,
|
|
@@ -115,13 +99,9 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
115
99
|
...badgeTheme.avatarSizes,
|
|
116
100
|
...customTheme.avatarSizes,
|
|
117
101
|
},
|
|
118
|
-
|
|
119
|
-
...badgeTheme.
|
|
120
|
-
...customTheme.
|
|
121
|
-
},
|
|
122
|
-
dismissIconSizes: {
|
|
123
|
-
...badgeTheme.dismissIconSizes,
|
|
124
|
-
...customTheme.dismissIconSizes,
|
|
102
|
+
dismissSizes: {
|
|
103
|
+
...badgeTheme.dismissSizes,
|
|
104
|
+
...customTheme.dismissSizes,
|
|
125
105
|
},
|
|
126
106
|
dotColors: {
|
|
127
107
|
...badgeTheme.dotColors,
|
|
@@ -138,11 +118,11 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
138
118
|
const sizeStyle = ((_k = theme.sizes) === null || _k === void 0 ? void 0 : _k[size]) || "";
|
|
139
119
|
const shapeStyle = pill
|
|
140
120
|
? "rounded-full"
|
|
141
|
-
:
|
|
142
|
-
const dotColorStyle = ((
|
|
121
|
+
: "rounded-[var(--badge-radius)]";
|
|
122
|
+
const dotColorStyle = ((_l = theme.dotColors) === null || _l === void 0 ? void 0 : _l[color]) || "";
|
|
143
123
|
// Build base styles with all states
|
|
144
|
-
const isInteractive =
|
|
145
|
-
const baseStyles = cn(theme.baseStyle, shapeStyle, variantStyles, colorStyles, sizeStyle, pill && ((
|
|
124
|
+
const isInteractive = dismissible;
|
|
125
|
+
const baseStyles = cn(theme.baseStyle, shapeStyle, variantStyles, colorStyles, sizeStyle, pill && ((_m = theme.pillSizes) === null || _m === void 0 ? void 0 : _m[size]), isInteractive && "cursor-pointer", disabled && ((_o = theme.states) === null || _o === void 0 ? void 0 : _o.disabled), darkMode && "dark", className);
|
|
146
126
|
// Create data attributes for styling hooks
|
|
147
127
|
const dataAttributes = {
|
|
148
128
|
"data-variant": variant,
|
|
@@ -152,59 +132,55 @@ const Badge = React__default.memo(React__default.forwardRef(({ children, variant
|
|
|
152
132
|
"data-pill": pill ? "true" : "false",
|
|
153
133
|
"data-with-dot": withDot ? "true" : "false",
|
|
154
134
|
"data-dismissible": dismissible ? "true" : "false",
|
|
155
|
-
"data-selected": isSelected ? "true" : "false",
|
|
156
|
-
"data-selectable": selectable ? "true" : "false",
|
|
157
135
|
"data-disabled": disabled ? "true" : "false",
|
|
158
136
|
"data-interactive": isInteractive ? "true" : "false",
|
|
159
137
|
};
|
|
160
138
|
// Render left content (priority: avatar → iconStart → dot)
|
|
161
139
|
const renderLeftContent = () => {
|
|
162
|
-
var _a, _b;
|
|
140
|
+
var _a, _b, _c;
|
|
163
141
|
if (avatar) {
|
|
164
142
|
// Apply negative margin for overlap effect (scales with badge size)
|
|
165
143
|
const avatarMargin = pill
|
|
166
144
|
? {
|
|
167
|
-
xs: "-ml-1",
|
|
168
145
|
sm: "-ml-1.5",
|
|
169
146
|
md: "-ml-1.5",
|
|
170
147
|
}[size]
|
|
171
148
|
: {
|
|
172
|
-
xs: "-ml-1",
|
|
173
149
|
sm: "-ml-1.5",
|
|
174
150
|
md: "-ml-1",
|
|
175
151
|
}[size];
|
|
176
|
-
return (jsx(
|
|
152
|
+
return (jsx("span", { className: cn("inline-flex items-center justify-center shrink-0 overflow-hidden", (_a = theme.avatarSizes) === null || _a === void 0 ? void 0 : _a[size], avatarMargin, pill ? "rounded-full" : "rounded-md"), children: jsx(Avatar, { src: avatar.src, name: avatar.name, fallback: (_b = avatar.fallback) !== null && _b !== void 0 ? _b : jsx(UserIcon, { className: "size-2.5" }), initialsCount: avatar.initialsCount, size: "xs", className: cn("!size-full border-0", pill ? "rounded-full" : "rounded-md ring-0") }) }));
|
|
177
153
|
}
|
|
178
154
|
if (iconStart) {
|
|
179
|
-
return (jsx("span", { className: cn("inline-flex items-center justify-center flex-shrink-0", (
|
|
155
|
+
return (jsx("span", { className: cn("inline-flex items-center justify-center flex-shrink-0", (_c = theme.iconSizes) === null || _c === void 0 ? void 0 : _c[size]), "aria-hidden": "true", children: iconStart }));
|
|
180
156
|
}
|
|
181
157
|
if (withDot) {
|
|
182
158
|
if (shouldAnimate) {
|
|
183
|
-
return (jsx(motion.span, { className: cn("badge-dot rounded-full shrink-0 size-1.5", dotColorStyle), variants: dotVariants, "aria-hidden": "true" }));
|
|
159
|
+
return (jsx(motion.span, { className: cn("badge-dot rounded-full shrink-0 size-1.5 ring-2 ring-current/20", dotColorStyle), variants: dotVariants, "aria-hidden": "true" }));
|
|
184
160
|
}
|
|
185
161
|
return (jsx("span", { className: cn("badge-dot rounded-full shrink-0 size-1.5", dotColorStyle), "aria-hidden": "true" }));
|
|
186
162
|
}
|
|
187
163
|
return null;
|
|
188
164
|
};
|
|
189
165
|
if (!shouldAnimate) {
|
|
190
|
-
//
|
|
191
|
-
const
|
|
166
|
+
// Spread props directly — Badge only receives HTMLSpanElement attributes
|
|
167
|
+
const restHtmlProps = props;
|
|
192
168
|
// Non-animated render for Storybook or reduced-motion environments
|
|
193
|
-
return isVisible ? (jsxs("span", { ref: ref, className: baseStyles, onClick: handleClick,
|
|
169
|
+
return isVisible ? (jsxs("span", { ref: ref, className: baseStyles, onClick: handleClick, "aria-disabled": disabled || undefined, ...dataAttributes, ...restHtmlProps, children: [renderLeftContent(), jsx("span", { className: cn("badge-content", maxWidth && "truncate"), style: maxWidth
|
|
194
170
|
? {
|
|
195
171
|
maxWidth: typeof maxWidth === "number"
|
|
196
172
|
? `${maxWidth}px`
|
|
197
173
|
: maxWidth,
|
|
198
174
|
}
|
|
199
|
-
: undefined, children: children }), dismissible && (jsx("button", { type: "button", onClick: handleDismiss, className:
|
|
175
|
+
: undefined, children: children }), dismissible && (jsx("button", { type: "button", onClick: handleDismiss, className: "badge-dismiss-btn -ml-1 -mr-1 rounded-full p-0.5 cursor-pointer", "aria-label": "Dismiss", disabled: disabled, children: jsx(XMarkIcon, { className: cn("badge-dismiss-icon", (_p = theme.dismissSizes) === null || _p === void 0 ? void 0 : _p[size]), "aria-hidden": "true" }) }))] })) : null;
|
|
200
176
|
}
|
|
201
|
-
return (jsx(AnimatePresence, { mode: "wait", children: isVisible && (jsxs(motion.span, { ref: ref, className: baseStyles, onClick: handleClick,
|
|
177
|
+
return (jsx(AnimatePresence, { mode: "wait", children: isVisible && (jsxs(motion.span, { ref: ref, className: baseStyles, onClick: handleClick, "aria-disabled": disabled || undefined, variants: dismissible ? dismissVariants : badgeVariants, initial: "initial", animate: "animate", exit: "exit", ...dataAttributes, ...props, children: [renderLeftContent(), jsx("span", { className: cn("badge-content", maxWidth && "truncate"), style: maxWidth
|
|
202
178
|
? {
|
|
203
179
|
maxWidth: typeof maxWidth === "number"
|
|
204
180
|
? `${maxWidth}px`
|
|
205
181
|
: maxWidth,
|
|
206
182
|
}
|
|
207
|
-
: undefined, children: children }), dismissible && (jsx(motion.button, { type: "button", onClick: handleDismiss, className:
|
|
183
|
+
: undefined, children: children }), dismissible && (jsx(motion.button, { type: "button", onClick: handleDismiss, className: "badge-dismiss-btn -ml-1 -mr-1 rounded-full p-0.5 cursor-pointer", "aria-label": "Dismiss", disabled: disabled, variants: dismissButtonVariants, initial: "initial", whileHover: "hover", whileTap: "tap", children: jsx(XMarkIcon, { className: cn("badge-dismiss-icon", (_q = theme.dismissSizes) === null || _q === void 0 ? void 0 : _q[size]), "aria-hidden": "true", strokeWidth: 2 }) }))] })) }));
|
|
208
184
|
}));
|
|
209
185
|
Badge.displayName = "Badge";
|
|
210
186
|
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
import { semanticBgColors } from '../../../utils/colorUtils.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Default theme configuration for Badge component
|
|
5
3
|
* Uses variant-first color organization for reliable dark mode and className overrides
|
|
6
4
|
*/
|
|
7
5
|
const badgeTheme = {
|
|
8
6
|
// Base styles applied to all badges
|
|
9
|
-
baseStyle: "inline-flex items-center align-middle select-none whitespace-nowrap transition-all duration-300 h-fit",
|
|
7
|
+
baseStyle: "inline-flex items-center align-middle select-none whitespace-nowrap transition-all duration-300 h-fit w-fit tracking-tight font-semibold border",
|
|
10
8
|
// Visual style variants (structure only, no colors)
|
|
9
|
+
// All variants get `border` via baseStyle for consistent box sizing
|
|
11
10
|
variants: {
|
|
12
|
-
filled: "",
|
|
13
|
-
outline: "bg-transparent
|
|
14
|
-
soft: "
|
|
11
|
+
filled: "border-transparent",
|
|
12
|
+
outline: "bg-transparent",
|
|
13
|
+
soft: "",
|
|
15
14
|
},
|
|
16
15
|
// Color styles organized PER VARIANT
|
|
17
16
|
// This structure enables reliable dark: variants and className overrides
|
|
18
17
|
variantColors: {
|
|
19
|
-
// Filled variant - solid backgrounds
|
|
18
|
+
// Filled variant - solid backgrounds, no visible border
|
|
20
19
|
filled: {
|
|
21
|
-
neutral: "bg-[var(--color-neutral-900)] text-white
|
|
22
|
-
"dark:bg-[var(--color-neutral-700)]
|
|
23
|
-
primary: "bg-[var(--color-primary)] text-[var(--color-primary-contrast)]
|
|
24
|
-
"dark:bg-[var(--color-primary-600)]
|
|
25
|
-
secondary: "bg-[var(--color-secondary)] text-[var(--color-secondary-contrast)]
|
|
26
|
-
"dark:bg-[var(--color-secondary-600)]
|
|
27
|
-
success: "bg-[var(--color-success-600)] text-[var(--color-success-contrast)]
|
|
28
|
-
"dark:bg-[var(--color-success-600)]
|
|
29
|
-
warning: "bg-[var(--color-warning)] text-[var(--color-warning-contrast)]
|
|
30
|
-
"dark:bg-[var(--color-warning-600)]
|
|
31
|
-
danger: "bg-[var(--color-danger)] text-[var(--color-danger-contrast)]
|
|
32
|
-
"dark:bg-[var(--color-danger-600)]
|
|
20
|
+
neutral: "bg-[var(--color-neutral-900)] text-white " +
|
|
21
|
+
"dark:bg-[var(--color-neutral-700)]",
|
|
22
|
+
primary: "bg-[var(--color-primary)] text-[var(--color-primary-contrast)] " +
|
|
23
|
+
"dark:bg-[var(--color-primary-600)]",
|
|
24
|
+
secondary: "bg-[var(--color-secondary)] text-[var(--color-secondary-contrast)] " +
|
|
25
|
+
"dark:bg-[var(--color-secondary-600)]",
|
|
26
|
+
success: "bg-[var(--color-success-600)] text-[var(--color-success-contrast)] " +
|
|
27
|
+
"dark:bg-[var(--color-success-600)]",
|
|
28
|
+
warning: "bg-[var(--color-warning)] text-[var(--color-warning-contrast)] " +
|
|
29
|
+
"dark:bg-[var(--color-warning-600)]",
|
|
30
|
+
danger: "bg-[var(--color-danger)] text-[var(--color-danger-contrast)] " +
|
|
31
|
+
"dark:bg-[var(--color-danger-600)]",
|
|
33
32
|
},
|
|
34
33
|
// Outline variant - transparent bg with colored border
|
|
35
34
|
outline: {
|
|
36
|
-
neutral: "text-[var(--color-text-
|
|
35
|
+
neutral: "text-[var(--color-text-primary)] border-[var(--color-border)] " + "",
|
|
37
36
|
primary: "text-[var(--color-primary)] border-[var(--color-border)] " +
|
|
38
37
|
"dark:text-[var(--color-primary-400)]",
|
|
39
38
|
secondary: "text-[var(--color-secondary)] border-[var(--color-border)] " +
|
|
@@ -45,68 +44,55 @@ const badgeTheme = {
|
|
|
45
44
|
danger: "text-[var(--color-danger)] border-[var(--color-border)] " +
|
|
46
45
|
"dark:text-[var(--color-danger-400)]",
|
|
47
46
|
},
|
|
48
|
-
// Soft variant - subtle background tints
|
|
47
|
+
// Soft variant - subtle background tints (Preline-style: 800 text, 500/20 dark bg)
|
|
49
48
|
soft: {
|
|
50
|
-
neutral: "bg-[var(--color-neutral-
|
|
51
|
-
"dark:bg-[var(--color-neutral-900)]
|
|
52
|
-
primary: "bg-[var(--color-primary-100)] text-[var(--color-primary-
|
|
53
|
-
"dark:bg-[var(--color-primary-
|
|
54
|
-
secondary: "bg-[var(--color-secondary-100)] text-[var(--color-secondary-
|
|
55
|
-
"dark:bg-[var(--color-secondary-
|
|
56
|
-
success: "bg-[var(--color-success-100)] text-[var(--color-success-
|
|
57
|
-
"dark:bg-[var(--color-success-
|
|
58
|
-
warning: "bg-[var(--color-warning-100)] text-[var(--color-warning-
|
|
59
|
-
"dark:bg-[var(--color-warning-
|
|
60
|
-
danger: "bg-[var(--color-danger-100)] text-[var(--color-danger-
|
|
61
|
-
"dark:bg-[var(--color-danger-
|
|
49
|
+
neutral: "bg-[var(--color-neutral-100)] text-[var(--color-text-primary)] border-[var(--color-text-primary)]/10 " +
|
|
50
|
+
"dark:bg-[var(--color-neutral-900)]",
|
|
51
|
+
primary: "bg-[var(--color-primary-100)] text-[var(--color-primary-800)] border-[var(--color-primary-800)]/20 " +
|
|
52
|
+
"dark:bg-[var(--color-primary-500)]/20 dark:text-[var(--color-primary-300)]",
|
|
53
|
+
secondary: "bg-[var(--color-secondary-100)] text-[var(--color-secondary-800)] border-[var(--color-secondary-800)]/10 " +
|
|
54
|
+
"dark:bg-[var(--color-secondary-500)]/20 dark:text-[var(--color-secondary-400)]",
|
|
55
|
+
success: "bg-[var(--color-success-100)] text-[var(--color-success-800)] border-[var(--color-success-800)]/20 " +
|
|
56
|
+
"dark:bg-[var(--color-success-500)]/20 dark:text-[var(--color-success-400)]",
|
|
57
|
+
warning: "bg-[var(--color-warning-100)] text-[var(--color-warning-800)] border-[var(--color-warning-800)]/20 " +
|
|
58
|
+
"dark:bg-[var(--color-warning-500)]/20 dark:text-[var(--color-warning-400)]",
|
|
59
|
+
danger: "bg-[var(--color-danger-100)] text-[var(--color-danger-800)] border-[var(--color-danger-800)]/20 " +
|
|
60
|
+
"dark:bg-[var(--color-danger-500)]/20 dark:text-[var(--color-danger-400)]",
|
|
62
61
|
},
|
|
63
62
|
},
|
|
64
63
|
// Flat size structure (no nested objects)
|
|
65
64
|
sizes: {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
md: "text-sm px-2 py-0.25 gap-1 font-semibold",
|
|
69
|
-
},
|
|
70
|
-
// Border radius per size (using CSS variable)
|
|
71
|
-
radiusSizes: {
|
|
72
|
-
xs: "rounded-[calc(var(--badge-radius)*0.5)]",
|
|
73
|
-
sm: "rounded-[calc(var(--badge-radius)*0.75)]",
|
|
74
|
-
md: "rounded-[var(--badge-radius)]",
|
|
65
|
+
sm: "text-sm px-1.5 py-0.25 gap-1",
|
|
66
|
+
md: "text-base px-2 py-0.25 gap-1",
|
|
75
67
|
},
|
|
76
68
|
// Additional padding for pill shape
|
|
77
69
|
pillSizes: {
|
|
78
|
-
xs: "px-1.5",
|
|
79
70
|
sm: "px-2",
|
|
80
71
|
md: "px-2.5",
|
|
81
72
|
},
|
|
82
|
-
// Icon sizes
|
|
73
|
+
// Icon sizes — applies to wrapper span; [&>svg] selector ensures SVG scales to fit
|
|
83
74
|
iconSizes: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
md: "size-3.5",
|
|
75
|
+
sm: "size-3.5 [&>svg]:size-3.5",
|
|
76
|
+
md: "size-4 [&>svg]:size-4",
|
|
87
77
|
},
|
|
88
78
|
// Avatar sizes (base sizes without negative margin)
|
|
89
79
|
avatarSizes: {
|
|
90
|
-
xs: "size-3.5",
|
|
91
80
|
sm: "size-4",
|
|
92
|
-
md: "size-
|
|
81
|
+
md: "size-5",
|
|
93
82
|
},
|
|
94
|
-
// Dismiss button
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
sm: "size-3.5",
|
|
83
|
+
// Dismiss icon sizes (button sizes itself from icon + padding)
|
|
84
|
+
dismissSizes: {
|
|
85
|
+
sm: "size-3",
|
|
98
86
|
md: "size-4",
|
|
99
87
|
},
|
|
100
|
-
//
|
|
101
|
-
dismissIconSizes: {
|
|
102
|
-
xs: "size-2",
|
|
103
|
-
sm: "size-2.5",
|
|
104
|
-
md: "size-3",
|
|
105
|
-
},
|
|
106
|
-
// Dot indicator colors (simple, no dark mode needed - inherits from parent)
|
|
88
|
+
// Dot inherits text color via currentColor — works across all variants/colors
|
|
107
89
|
dotColors: {
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
neutral: "bg-current",
|
|
91
|
+
primary: "bg-current",
|
|
92
|
+
secondary: "bg-current",
|
|
93
|
+
success: "bg-current",
|
|
94
|
+
warning: "bg-current",
|
|
95
|
+
danger: "bg-current",
|
|
110
96
|
},
|
|
111
97
|
// State styles
|
|
112
98
|
states: {
|