@forgedevstack/bear 1.0.7 → 1.0.9
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/dist/components/ActivityItem/ActivityItem.cjs +1 -1
- package/dist/components/ActivityItem/ActivityItem.js +1 -0
- package/dist/components/Alert/Alert.cjs +1 -1
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.d.ts +4 -0
- package/dist/components/Alert/Alert.const.js +10 -15
- package/dist/components/Alert/Alert.js +43 -38
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +19 -14
- package/dist/components/BackTop/BackTop.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.cjs +1 -0
- package/dist/components/BackTop/BackTop.const.d.ts +34 -0
- package/dist/components/BackTop/BackTop.const.js +29 -0
- package/dist/components/BackTop/BackTop.d.ts +21 -0
- package/dist/components/BackTop/BackTop.js +87 -0
- package/dist/components/BackTop/BackTop.types.d.ts +28 -0
- package/dist/components/BackTop/index.d.ts +3 -0
- package/dist/components/Badge/Badge.cjs +1 -1
- package/dist/components/Badge/Badge.constants.d.ts +4 -4
- package/dist/components/Badge/Badge.js +15 -14
- package/dist/components/Badge/Badge.types.d.ts +3 -3
- package/dist/components/BearLogo/EmberLogo.cjs +1 -1
- package/dist/components/BearLogo/EmberLogo.js +3 -2
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js +3 -2
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +39 -38
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +38 -48
- package/dist/components/Button/Button.constants.d.ts +22 -3
- package/dist/components/Button/Button.constants.js +51 -50
- package/dist/components/Button/Button.d.ts +14 -7
- package/dist/components/Button/Button.js +123 -45
- package/dist/components/Button/Button.types.d.ts +22 -4
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.js +3 -2
- package/dist/components/Card/Card.const.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +2 -2
- package/dist/components/Carousel/Carousel.cjs +1 -1
- package/dist/components/Carousel/Carousel.const.cjs +1 -0
- package/dist/components/Carousel/Carousel.const.d.ts +12 -0
- package/dist/components/Carousel/Carousel.const.js +9 -0
- package/dist/components/Carousel/Carousel.d.ts +14 -3
- package/dist/components/Carousel/Carousel.js +222 -75
- package/dist/components/Carousel/Carousel.types.d.ts +32 -2
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Chat/Chat.cjs +1 -0
- package/dist/components/Chat/Chat.const.cjs +1 -0
- package/dist/components/Chat/Chat.const.d.ts +26 -0
- package/dist/components/Chat/Chat.const.js +29 -0
- package/dist/components/Chat/Chat.d.ts +21 -0
- package/dist/components/Chat/Chat.js +179 -0
- package/dist/components/Chat/Chat.types.d.ts +55 -0
- package/dist/components/Chat/index.d.ts +2 -0
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.js +3 -2
- package/dist/components/CodeEditor/CodeEditor.cjs +5 -0
- package/dist/components/CodeEditor/CodeEditor.const.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.const.d.ts +21 -0
- package/dist/components/CodeEditor/CodeEditor.const.js +119 -0
- package/dist/components/CodeEditor/CodeEditor.d.ts +22 -0
- package/dist/components/CodeEditor/CodeEditor.js +250 -0
- package/dist/components/CodeEditor/CodeEditor.types.d.ts +80 -0
- package/dist/components/CodeEditor/CodeEditor.utils.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.utils.d.ts +6 -0
- package/dist/components/CodeEditor/CodeEditor.utils.js +75 -0
- package/dist/components/CodeEditor/index.d.ts +2 -0
- package/dist/components/Columns/Columns.cjs +1 -1
- package/dist/components/Columns/Columns.js +9 -8
- package/dist/components/Confetti/Confetti.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.cjs +1 -0
- package/dist/components/Confetti/Confetti.const.d.ts +16 -0
- package/dist/components/Confetti/Confetti.const.js +36 -0
- package/dist/components/Confetti/Confetti.d.ts +23 -0
- package/dist/components/Confetti/Confetti.js +94 -0
- package/dist/components/Confetti/Confetti.types.d.ts +50 -0
- package/dist/components/Confetti/index.d.ts +4 -0
- package/dist/components/Confetti/useConfetti.cjs +1 -0
- package/dist/components/Confetti/useConfetti.d.ts +13 -0
- package/dist/components/Confetti/useConfetti.js +12 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +27 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +35 -0
- package/dist/components/CountdownTimer/CountdownTimer.d.ts +7 -0
- package/dist/components/CountdownTimer/CountdownTimer.js +115 -0
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +56 -0
- package/dist/components/CountdownTimer/index.d.ts +2 -0
- package/dist/components/Cropper/Cropper.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.d.ts +31 -0
- package/dist/components/Cropper/Cropper.const.js +33 -0
- package/dist/components/Cropper/Cropper.d.ts +21 -0
- package/dist/components/Cropper/Cropper.js +362 -0
- package/dist/components/Cropper/Cropper.types.d.ts +72 -0
- package/dist/components/Cropper/index.d.ts +2 -0
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.js +5 -4
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +3 -2
- package/dist/components/DiffViewer/DiffViewer.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -0
- package/dist/components/DiffViewer/DiffViewer.const.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.const.js +21 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +18 -0
- package/dist/components/DiffViewer/DiffViewer.js +127 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +40 -0
- package/dist/components/DiffViewer/DiffViewer.utils.cjs +3 -0
- package/dist/components/DiffViewer/DiffViewer.utils.d.ts +9 -0
- package/dist/components/DiffViewer/DiffViewer.utils.js +39 -0
- package/dist/components/DiffViewer/index.d.ts +2 -0
- package/dist/components/Divider/Divider.cjs +1 -1
- package/dist/components/Divider/Divider.js +15 -14
- package/dist/components/Dock/Dock.cjs +1 -0
- package/dist/components/Dock/Dock.const.cjs +1 -0
- package/dist/components/Dock/Dock.const.d.ts +25 -0
- package/dist/components/Dock/Dock.const.js +22 -0
- package/dist/components/Dock/Dock.d.ts +7 -0
- package/dist/components/Dock/Dock.js +144 -0
- package/dist/components/Dock/Dock.types.d.ts +42 -0
- package/dist/components/Dock/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +35 -35
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.js +7 -6
- package/dist/components/FloatingChat/FloatingChat.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.cjs +1 -0
- package/dist/components/FloatingChat/FloatingChat.const.d.ts +12 -0
- package/dist/components/FloatingChat/FloatingChat.const.js +15 -0
- package/dist/components/FloatingChat/FloatingChat.d.ts +19 -0
- package/dist/components/FloatingChat/FloatingChat.js +144 -0
- package/dist/components/FloatingChat/FloatingChat.types.d.ts +44 -0
- package/dist/components/FloatingChat/index.d.ts +2 -0
- package/dist/components/GradientText/GradientText.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.d.ts +15 -0
- package/dist/components/GradientText/GradientText.const.js +36 -0
- package/dist/components/GradientText/GradientText.d.ts +7 -0
- package/dist/components/GradientText/GradientText.js +52 -0
- package/dist/components/GradientText/GradientText.types.d.ts +27 -0
- package/dist/components/GradientText/index.d.ts +2 -0
- package/dist/components/Highlight/Highlight.cjs +1 -1
- package/dist/components/Highlight/Highlight.const.cjs +1 -0
- package/dist/components/Highlight/Highlight.const.d.ts +8 -0
- package/dist/components/Highlight/Highlight.const.js +15 -0
- package/dist/components/Highlight/Highlight.d.ts +4 -0
- package/dist/components/Highlight/Highlight.js +32 -24
- package/dist/components/Highlight/Highlight.types.d.ts +9 -1
- package/dist/components/Highlight/index.d.ts +1 -1
- package/dist/components/Icon/Icon.cjs +1 -1
- package/dist/components/Icon/Icon.js +17 -16
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +12 -11
- package/dist/components/JsonViewer/JsonViewer.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.cjs +1 -0
- package/dist/components/JsonViewer/JsonViewer.const.d.ts +4 -0
- package/dist/components/JsonViewer/JsonViewer.const.js +24 -0
- package/dist/components/JsonViewer/JsonViewer.d.ts +17 -0
- package/dist/components/JsonViewer/JsonViewer.js +195 -0
- package/dist/components/JsonViewer/JsonViewer.types.d.ts +54 -0
- package/dist/components/JsonViewer/index.d.ts +2 -0
- package/dist/components/Kanban/Kanban.cjs +1 -1
- package/dist/components/Kanban/Kanban.js +18 -17
- package/dist/components/Kbd/Kbd.cjs +1 -1
- package/dist/components/Kbd/Kbd.js +17 -16
- package/dist/components/Map/Map.cjs +1 -0
- package/dist/components/Map/Map.const.cjs +1 -0
- package/dist/components/Map/Map.const.d.ts +20 -0
- package/dist/components/Map/Map.const.js +26 -0
- package/dist/components/Map/Map.d.ts +20 -0
- package/dist/components/Map/Map.js +259 -0
- package/dist/components/Map/Map.types.d.ts +81 -0
- package/dist/components/Map/index.d.ts +2 -0
- package/dist/components/Marquee/Marquee.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.d.ts +11 -0
- package/dist/components/Marquee/Marquee.const.js +12 -0
- package/dist/components/Marquee/Marquee.d.ts +7 -0
- package/dist/components/Marquee/Marquee.js +106 -0
- package/dist/components/Marquee/Marquee.types.d.ts +32 -0
- package/dist/components/Marquee/index.d.ts +2 -0
- package/dist/components/Masonry/Masonry.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.d.ts +9 -0
- package/dist/components/Masonry/Masonry.const.js +9 -0
- package/dist/components/Masonry/Masonry.d.ts +7 -0
- package/dist/components/Masonry/Masonry.js +51 -0
- package/dist/components/Masonry/Masonry.types.d.ts +21 -0
- package/dist/components/Masonry/index.d.ts +2 -0
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +23 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.js +33 -0
- package/dist/components/NavigableSelect/NavigableSelect.d.ts +7 -0
- package/dist/components/NavigableSelect/NavigableSelect.js +361 -0
- package/dist/components/NavigableSelect/NavigableSelect.types.d.ts +56 -0
- package/dist/components/NavigableSelect/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.js +3 -2
- package/dist/components/QRCode/QRCode.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.cjs +1 -0
- package/dist/components/QRCode/QRCode.const.d.ts +21 -0
- package/dist/components/QRCode/QRCode.const.js +11 -0
- package/dist/components/QRCode/QRCode.d.ts +29 -0
- package/dist/components/QRCode/QRCode.js +68 -0
- package/dist/components/QRCode/QRCode.types.d.ts +32 -0
- package/dist/components/QRCode/QRCode.utils.cjs +1 -0
- package/dist/components/QRCode/QRCode.utils.d.ts +12 -0
- package/dist/components/QRCode/QRCode.utils.js +74 -0
- package/dist/components/QRCode/index.d.ts +3 -0
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +3 -2
- package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +3 -2
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.js +13 -12
- package/dist/components/Spinner/Spinner.cjs +1 -1
- package/dist/components/Spinner/Spinner.js +3 -2
- package/dist/components/Spinner/Spinner.types.d.ts +2 -2
- package/dist/components/Spotlight/Spotlight.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.d.ts +18 -0
- package/dist/components/Spotlight/Spotlight.const.js +9 -0
- package/dist/components/Spotlight/Spotlight.d.ts +7 -0
- package/dist/components/Spotlight/Spotlight.js +220 -0
- package/dist/components/Spotlight/Spotlight.types.d.ts +51 -0
- package/dist/components/Spotlight/index.d.ts +2 -0
- package/dist/components/StatCard/StatCard.cjs +1 -1
- package/dist/components/StatCard/StatCard.js +9 -8
- package/dist/components/Statistic/Statistic.cjs +1 -1
- package/dist/components/Statistic/Statistic.js +7 -6
- package/dist/components/Switch/Switch.cjs +1 -1
- package/dist/components/Switch/Switch.js +11 -10
- package/dist/components/Terminal/Terminal.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.cjs +1 -0
- package/dist/components/Terminal/Terminal.const.d.ts +32 -0
- package/dist/components/Terminal/Terminal.const.js +42 -0
- package/dist/components/Terminal/Terminal.d.ts +27 -0
- package/dist/components/Terminal/Terminal.js +155 -0
- package/dist/components/Terminal/Terminal.types.d.ts +49 -0
- package/dist/components/Terminal/index.d.ts +2 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +16 -15
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +13 -12
- package/dist/components/Tour/Tour.cjs +1 -0
- package/dist/components/Tour/Tour.const.cjs +1 -0
- package/dist/components/Tour/Tour.const.d.ts +25 -0
- package/dist/components/Tour/Tour.const.js +38 -0
- package/dist/components/Tour/Tour.d.ts +17 -0
- package/dist/components/Tour/Tour.js +179 -0
- package/dist/components/Tour/Tour.types.d.ts +80 -0
- package/dist/components/Tour/index.d.ts +4 -0
- package/dist/components/Tour/useTour.cjs +1 -0
- package/dist/components/Tour/useTour.d.ts +14 -0
- package/dist/components/Tour/useTour.js +27 -0
- package/dist/components/Transition/Transition.cjs +1 -0
- package/dist/components/Transition/Transition.const.cjs +1 -0
- package/dist/components/Transition/Transition.const.d.ts +15 -0
- package/dist/components/Transition/Transition.const.js +73 -0
- package/dist/components/Transition/Transition.d.ts +37 -0
- package/dist/components/Transition/Transition.js +107 -0
- package/dist/components/Transition/Transition.types.d.ts +69 -0
- package/dist/components/Transition/index.d.ts +2 -0
- package/dist/components/Typewriter/Typewriter.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.d.ts +22 -0
- package/dist/components/Typewriter/Typewriter.const.js +11 -0
- package/dist/components/Typewriter/Typewriter.d.ts +7 -0
- package/dist/components/Typewriter/Typewriter.js +88 -0
- package/dist/components/Typewriter/Typewriter.types.d.ts +32 -0
- package/dist/components/Typewriter/index.d.ts +2 -0
- package/dist/components/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.d.ts +5 -1
- package/dist/components/Typography/Typography.js +93 -57
- package/dist/components/Typography/Typography.types.d.ts +29 -2
- package/dist/components/Watermark/Watermark.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.d.ts +30 -0
- package/dist/components/Watermark/Watermark.const.js +18 -0
- package/dist/components/Watermark/Watermark.d.ts +7 -0
- package/dist/components/Watermark/Watermark.js +96 -0
- package/dist/components/Watermark/Watermark.types.d.ts +35 -0
- package/dist/components/Watermark/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +46 -2
- package/dist/components/index.js +288 -237
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +110 -5
- package/dist/context/BearProvider.js +198 -53
- package/dist/context/defaultTheme.cjs +1 -1
- package/dist/context/defaultTheme.js +11 -11
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.js +61 -39
- package/dist/hooks/useAnimate.cjs +1 -0
- package/dist/hooks/useAnimate.d.ts +61 -0
- package/dist/hooks/useAnimate.js +125 -0
- package/dist/hooks/useBearComponent/index.d.ts +2 -0
- package/dist/hooks/useBearComponent/useBearComponent.cjs +1 -0
- package/dist/hooks/useBearComponent/useBearComponent.d.ts +71 -0
- package/dist/hooks/useBearComponent/useBearComponent.js +54 -0
- package/dist/hooks/useBearComponent/useBearComponent.types.d.ts +40 -0
- package/dist/hooks/useIdle/index.d.ts +2 -0
- package/dist/hooks/useIdle/useIdle.cjs +1 -0
- package/dist/hooks/useIdle/useIdle.d.ts +22 -0
- package/dist/hooks/useIdle/useIdle.js +66 -0
- package/dist/hooks/useIdle/useIdle.types.d.ts +29 -0
- package/dist/hooks/useLongPress/index.d.ts +2 -0
- package/dist/hooks/useLongPress/useLongPress.cjs +1 -0
- package/dist/hooks/useLongPress/useLongPress.d.ts +17 -0
- package/dist/hooks/useLongPress/useLongPress.js +44 -0
- package/dist/hooks/useLongPress/useLongPress.types.d.ts +26 -0
- package/dist/hooks/useOnline/index.d.ts +2 -0
- package/dist/hooks/useOnline/useOnline.cjs +1 -0
- package/dist/hooks/useOnline/useOnline.d.ts +16 -0
- package/dist/hooks/useOnline/useOnline.js +25 -0
- package/dist/hooks/useOnline/useOnline.types.d.ts +15 -0
- package/dist/hooks/usePageVisibility/index.d.ts +2 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.cjs +1 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.d.ts +19 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.js +26 -0
- package/dist/hooks/usePageVisibility/usePageVisibility.types.d.ts +15 -0
- package/dist/hooks/useResponsive.cjs +1 -0
- package/dist/hooks/useResponsive.d.ts +35 -0
- package/dist/hooks/useResponsive.js +74 -0
- package/dist/hooks/useSpotlight/index.d.ts +2 -0
- package/dist/hooks/useSpotlight/useSpotlight.cjs +1 -0
- package/dist/hooks/useSpotlight/useSpotlight.d.ts +24 -0
- package/dist/hooks/useSpotlight/useSpotlight.js +49 -0
- package/dist/hooks/useSpotlight/useSpotlight.types.d.ts +23 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.cjs +1 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +22 -0
- package/dist/hooks/useWebSocket/useWebSocket.js +75 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +44 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +363 -288
- package/dist/styles.css +1 -1
- package/dist/types/component.types.d.ts +125 -42
- package/dist/types/theme.types.d.ts +82 -0
- package/dist/utils/createSlots.cjs +1 -0
- package/dist/utils/createSlots.d.ts +70 -0
- package/dist/utils/createSlots.js +65 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface ConfettiPiece {
|
|
2
|
+
id: number;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
rotation: number;
|
|
6
|
+
color: string;
|
|
7
|
+
size: number;
|
|
8
|
+
velocity: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
rotationSpeed: number;
|
|
13
|
+
shape: 'square' | 'circle' | 'triangle';
|
|
14
|
+
}
|
|
15
|
+
export interface ConfettiProps {
|
|
16
|
+
/** Whether confetti is active */
|
|
17
|
+
active?: boolean;
|
|
18
|
+
/** Number of confetti pieces */
|
|
19
|
+
count?: number;
|
|
20
|
+
/** Duration in ms before confetti disappears */
|
|
21
|
+
duration?: number;
|
|
22
|
+
/** Custom colors array */
|
|
23
|
+
colors?: string[];
|
|
24
|
+
/** Confetti origin x position (0-1) */
|
|
25
|
+
originX?: number;
|
|
26
|
+
/** Confetti origin y position (0-1) */
|
|
27
|
+
originY?: number;
|
|
28
|
+
/** Spread angle in degrees */
|
|
29
|
+
spread?: number;
|
|
30
|
+
/** Initial velocity */
|
|
31
|
+
velocity?: number;
|
|
32
|
+
/** Gravity effect */
|
|
33
|
+
gravity?: number;
|
|
34
|
+
/** Whether to auto-hide after duration */
|
|
35
|
+
autoHide?: boolean;
|
|
36
|
+
/** Callback when animation completes */
|
|
37
|
+
onComplete?: () => void;
|
|
38
|
+
/** Custom class name */
|
|
39
|
+
className?: string;
|
|
40
|
+
/** Test ID */
|
|
41
|
+
testId?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface UseConfettiReturn {
|
|
44
|
+
/** Fire confetti */
|
|
45
|
+
fire: () => void;
|
|
46
|
+
/** Stop confetti */
|
|
47
|
+
stop: () => void;
|
|
48
|
+
/** Whether confetti is active */
|
|
49
|
+
isActive: boolean;
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),u=()=>{const[s,t]=e.useState(!1),c=e.useCallback(()=>{t(!0)},[]),o=e.useCallback(()=>{t(!1)},[]);return{fire:c,stop:o,isActive:s}};exports.useConfetti=u;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseConfettiReturn } from './Confetti.types';
|
|
2
|
+
/**
|
|
3
|
+
* useConfetti - Hook to control confetti programmatically
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const { fire, stop, isActive } = useConfetti();
|
|
8
|
+
*
|
|
9
|
+
* <Confetti active={isActive} onComplete={stop} />
|
|
10
|
+
* <Button onClick={fire}>Celebrate!</Button>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const useConfetti: () => UseConfettiReturn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),s=require("react"),b=require("../../utils/cn.cjs"),e=require("./CountdownTimer.const.cjs"),S=n=>String(n).padStart(e.PAD_LENGTH,"0"),y=(n,o)=>{const r=Math.max(0,n-o);return{days:Math.floor(r/e.MS_PER_DAY),hours:Math.floor(r%e.MS_PER_DAY/e.MS_PER_HOUR),minutes:Math.floor(r%e.MS_PER_HOUR/e.MS_PER_MINUTE),seconds:Math.floor(r%e.MS_PER_MINUTE/e.MS_PER_SECOND),totalSeconds:Math.floor(r/e.MS_PER_SECOND),isComplete:r<=0}},Z=n=>{const{targetDate:o,duration:r,variant:f="default",size:m="md",showDays:M=!0,showHours:R=!0,showMinutes:D=!0,showSeconds:I=!0,showLabels:L=!0,showSeparator:P=!0,separator:v=e.DEFAULT_SEPARATOR,labels:p,onComplete:d,onTick:u,paused:w=!1,render:C,className:N,style:j,testId:k}=n,c=s.useMemo(()=>({...e.DEFAULT_LABELS,...p}),[p]),x=s.useRef(!1),B=s.useCallback(()=>o?new Date(o).getTime():r?Date.now()+r*e.MS_PER_SECOND:Date.now(),[o,r]),[_]=s.useState(B),[i,O]=s.useState(()=>y(_,Date.now()));if(s.useEffect(()=>{if(w)return;const t=()=>{const h=y(_,Date.now());O(h),u==null||u(h),h.isComplete&&!x.current&&(x.current=!0,d==null||d())};t();const g=setInterval(t,e.UPDATE_INTERVAL);return()=>clearInterval(g)},[_,w,d,u]),C)return a.jsx(a.Fragment,{children:C(i)});const A=e.SIZE_DIGIT_CLASSES[m]??e.SIZE_DIGIT_CLASSES.md,U=e.SIZE_LABEL_CLASSES[m]??e.SIZE_LABEL_CLASSES.md,G=e.SIZE_GAP_CLASSES[m]??e.SIZE_GAP_CLASSES.md,l=[];M&&l.push({value:S(i.days),label:c.days}),R&&l.push({value:S(i.hours),label:c.hours}),D&&l.push({value:S(i.minutes),label:c.minutes}),I&&l.push({value:S(i.seconds),label:c.seconds});const E=f==="card",T=f==="flip";return a.jsx("div",{className:b.cn("Bear-CountdownTimer","bear-flex bear-items-center",G,N),style:j,"data-testid":k,role:"timer","aria-label":"Countdown timer",children:l.map((t,g)=>a.jsxs("div",{className:"Bear-CountdownTimer__segment bear-flex bear-items-center",children:[g>0&&P&&!E&&a.jsx("span",{className:b.cn("Bear-CountdownTimer__separator",A,e.SEPARATOR_MARGIN,"bear-text-gray-400 dark:bear-text-gray-500"),"aria-hidden":"true",children:v}),a.jsxs("div",{className:"Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center",children:[a.jsx("div",{className:b.cn("Bear-CountdownTimer__digit",A,"bear-tabular-nums bear-tracking-wider",E&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-100 dark:bear-bg-gray-800","bear-border bear-border-gray-200 dark:bear-border-gray-700"],T&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-900 dark:bear-bg-gray-100","bear-text-white dark:bear-text-gray-900","bear-shadow-lg"],!E&&!T&&"bear-text-[var(--bear-text-primary)]"),children:t.value}),L&&a.jsx("span",{className:b.cn("Bear-CountdownTimer__label",U,"bear-mt-1 bear-uppercase bear-tracking-widest","bear-text-gray-500 dark:bear-text-gray-400"),children:t.label})]})]},t.label))})};exports.CountdownTimer=Z;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=1e3,E=60*S,t=60*E,e=24*t,_={days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},A=":",s=2,o={sm:"bear-text-lg bear-font-bold",md:"bear-text-3xl bear-font-bold",lg:"bear-text-5xl bear-font-bold",xl:"bear-text-7xl bear-font-bold"},a={sm:"bear-text-[10px]",md:"bear-text-xs",lg:"bear-text-sm",xl:"bear-text-base"},b={sm:"bear-gap-2",md:"bear-gap-3",lg:"bear-gap-4",xl:"bear-gap-5"},r="bear-mx-1",n=1e3;exports.DEFAULT_LABELS=_;exports.DEFAULT_SEPARATOR=A;exports.MS_PER_DAY=e;exports.MS_PER_HOUR=t;exports.MS_PER_MINUTE=E;exports.MS_PER_SECOND=S;exports.PAD_LENGTH=s;exports.SEPARATOR_MARGIN=r;exports.SIZE_DIGIT_CLASSES=o;exports.SIZE_GAP_CLASSES=b;exports.SIZE_LABEL_CLASSES=a;exports.UPDATE_INTERVAL=n;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CountdownTimerSize } from './CountdownTimer.types';
|
|
2
|
+
/** Milliseconds in time units */
|
|
3
|
+
export declare const MS_PER_SECOND = 1000;
|
|
4
|
+
export declare const MS_PER_MINUTE: number;
|
|
5
|
+
export declare const MS_PER_HOUR: number;
|
|
6
|
+
export declare const MS_PER_DAY: number;
|
|
7
|
+
/** Default labels */
|
|
8
|
+
export declare const DEFAULT_LABELS: {
|
|
9
|
+
readonly days: "Days";
|
|
10
|
+
readonly hours: "Hours";
|
|
11
|
+
readonly minutes: "Minutes";
|
|
12
|
+
readonly seconds: "Seconds";
|
|
13
|
+
};
|
|
14
|
+
/** Default separator */
|
|
15
|
+
export declare const DEFAULT_SEPARATOR = ":";
|
|
16
|
+
/** Pad length for digits */
|
|
17
|
+
export declare const PAD_LENGTH = 2;
|
|
18
|
+
/** Digit classes per size */
|
|
19
|
+
export declare const SIZE_DIGIT_CLASSES: Record<CountdownTimerSize, string>;
|
|
20
|
+
/** Label classes per size */
|
|
21
|
+
export declare const SIZE_LABEL_CLASSES: Record<CountdownTimerSize, string>;
|
|
22
|
+
/** Gap classes per size */
|
|
23
|
+
export declare const SIZE_GAP_CLASSES: Record<CountdownTimerSize, string>;
|
|
24
|
+
/** Separator horizontal margin */
|
|
25
|
+
export declare const SEPARATOR_MARGIN = "bear-mx-1";
|
|
26
|
+
/** Update interval in ms */
|
|
27
|
+
export declare const UPDATE_INTERVAL = 1000;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const t = 1e3, e = 6e4, s = 36e5, E = 864e5, o = {
|
|
2
|
+
days: "Days",
|
|
3
|
+
hours: "Hours",
|
|
4
|
+
minutes: "Minutes",
|
|
5
|
+
seconds: "Seconds"
|
|
6
|
+
}, S = ":", _ = 2, a = {
|
|
7
|
+
sm: "bear-text-lg bear-font-bold",
|
|
8
|
+
md: "bear-text-3xl bear-font-bold",
|
|
9
|
+
lg: "bear-text-5xl bear-font-bold",
|
|
10
|
+
xl: "bear-text-7xl bear-font-bold"
|
|
11
|
+
}, b = {
|
|
12
|
+
sm: "bear-text-[10px]",
|
|
13
|
+
md: "bear-text-xs",
|
|
14
|
+
lg: "bear-text-sm",
|
|
15
|
+
xl: "bear-text-base"
|
|
16
|
+
}, n = {
|
|
17
|
+
sm: "bear-gap-2",
|
|
18
|
+
md: "bear-gap-3",
|
|
19
|
+
lg: "bear-gap-4",
|
|
20
|
+
xl: "bear-gap-5"
|
|
21
|
+
}, r = "bear-mx-1", x = 1e3;
|
|
22
|
+
export {
|
|
23
|
+
o as DEFAULT_LABELS,
|
|
24
|
+
S as DEFAULT_SEPARATOR,
|
|
25
|
+
E as MS_PER_DAY,
|
|
26
|
+
s as MS_PER_HOUR,
|
|
27
|
+
e as MS_PER_MINUTE,
|
|
28
|
+
t as MS_PER_SECOND,
|
|
29
|
+
_ as PAD_LENGTH,
|
|
30
|
+
r as SEPARATOR_MARGIN,
|
|
31
|
+
a as SIZE_DIGIT_CLASSES,
|
|
32
|
+
n as SIZE_GAP_CLASSES,
|
|
33
|
+
b as SIZE_LABEL_CLASSES,
|
|
34
|
+
x as UPDATE_INTERVAL
|
|
35
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CountdownTimerProps } from './CountdownTimer.types';
|
|
3
|
+
/**
|
|
4
|
+
* CountdownTimer - Visual countdown with days/hours/minutes/seconds.
|
|
5
|
+
* Multiple variants, sizes, and theming via BearProvider CSS variables.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CountdownTimer: FC<CountdownTimerProps>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as o, Fragment as J, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as K, useRef as Q, useCallback as W, useState as A, useEffect as X } from "react";
|
|
3
|
+
import { cn as u } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_SEPARATOR as $, DEFAULT_LABELS as ee, MS_PER_SECOND as h, UPDATE_INTERVAL as re, SEPARATOR_MARGIN as ae, SIZE_DIGIT_CLASSES as v, SIZE_LABEL_CLASSES as D, SIZE_GAP_CLASSES as M, MS_PER_MINUTE as R, MS_PER_HOUR as L, MS_PER_DAY as N, PAD_LENGTH as te } from "./CountdownTimer.const.js";
|
|
5
|
+
const b = (a) => String(a).padStart(te, "0"), I = (a, t) => {
|
|
6
|
+
const e = Math.max(0, a - t);
|
|
7
|
+
return {
|
|
8
|
+
days: Math.floor(e / N),
|
|
9
|
+
hours: Math.floor(e % N / L),
|
|
10
|
+
minutes: Math.floor(e % L / R),
|
|
11
|
+
seconds: Math.floor(e % R / h),
|
|
12
|
+
totalSeconds: Math.floor(e / h),
|
|
13
|
+
isComplete: e <= 0
|
|
14
|
+
};
|
|
15
|
+
}, ie = (a) => {
|
|
16
|
+
const {
|
|
17
|
+
targetDate: t,
|
|
18
|
+
duration: e,
|
|
19
|
+
variant: _ = "default",
|
|
20
|
+
size: c = "md",
|
|
21
|
+
showDays: P = !0,
|
|
22
|
+
showHours: k = !0,
|
|
23
|
+
showMinutes: B = !0,
|
|
24
|
+
showSeconds: F = !0,
|
|
25
|
+
showLabels: U = !0,
|
|
26
|
+
showSeparator: G = !0,
|
|
27
|
+
separator: O = $,
|
|
28
|
+
labels: S,
|
|
29
|
+
onComplete: l,
|
|
30
|
+
onTick: i,
|
|
31
|
+
paused: w = !1,
|
|
32
|
+
render: E,
|
|
33
|
+
className: H,
|
|
34
|
+
style: Z,
|
|
35
|
+
testId: j
|
|
36
|
+
} = a, d = K(() => ({ ...ee, ...S }), [S]), y = Q(!1), z = W(() => t ? new Date(t).getTime() : e ? Date.now() + e * h : Date.now(), [t, e]), [m] = A(z), [s, V] = A(() => I(m, Date.now()));
|
|
37
|
+
if (X(() => {
|
|
38
|
+
if (w) return;
|
|
39
|
+
const r = () => {
|
|
40
|
+
const p = I(m, Date.now());
|
|
41
|
+
V(p), i == null || i(p), p.isComplete && !y.current && (y.current = !0, l == null || l());
|
|
42
|
+
};
|
|
43
|
+
r();
|
|
44
|
+
const f = setInterval(r, re);
|
|
45
|
+
return () => clearInterval(f);
|
|
46
|
+
}, [m, w, l, i]), E) return /* @__PURE__ */ o(J, { children: E(s) });
|
|
47
|
+
const x = v[c] ?? v.md, Y = D[c] ?? D.md, q = M[c] ?? M.md, n = [];
|
|
48
|
+
P && n.push({ value: b(s.days), label: d.days }), k && n.push({ value: b(s.hours), label: d.hours }), B && n.push({ value: b(s.minutes), label: d.minutes }), F && n.push({ value: b(s.seconds), label: d.seconds });
|
|
49
|
+
const g = _ === "card", C = _ === "flip";
|
|
50
|
+
return /* @__PURE__ */ o(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: u("Bear-CountdownTimer", "bear-flex bear-items-center", q, H),
|
|
54
|
+
style: Z,
|
|
55
|
+
"data-testid": j,
|
|
56
|
+
role: "timer",
|
|
57
|
+
"aria-label": "Countdown timer",
|
|
58
|
+
children: n.map((r, f) => /* @__PURE__ */ T("div", { className: "Bear-CountdownTimer__segment bear-flex bear-items-center", children: [
|
|
59
|
+
f > 0 && G && !g && /* @__PURE__ */ o(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
className: u(
|
|
63
|
+
"Bear-CountdownTimer__separator",
|
|
64
|
+
x,
|
|
65
|
+
ae,
|
|
66
|
+
"bear-text-gray-400 dark:bear-text-gray-500"
|
|
67
|
+
),
|
|
68
|
+
"aria-hidden": "true",
|
|
69
|
+
children: O
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ T("div", { className: "Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center", children: [
|
|
73
|
+
/* @__PURE__ */ o(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: u(
|
|
77
|
+
"Bear-CountdownTimer__digit",
|
|
78
|
+
x,
|
|
79
|
+
"bear-tabular-nums bear-tracking-wider",
|
|
80
|
+
g && [
|
|
81
|
+
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
82
|
+
"bear-bg-gray-100 dark:bear-bg-gray-800",
|
|
83
|
+
"bear-border bear-border-gray-200 dark:bear-border-gray-700"
|
|
84
|
+
],
|
|
85
|
+
C && [
|
|
86
|
+
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
87
|
+
"bear-bg-gray-900 dark:bear-bg-gray-100",
|
|
88
|
+
"bear-text-white dark:bear-text-gray-900",
|
|
89
|
+
"bear-shadow-lg"
|
|
90
|
+
],
|
|
91
|
+
!g && !C && "bear-text-[var(--bear-text-primary)]"
|
|
92
|
+
),
|
|
93
|
+
children: r.value
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
U && /* @__PURE__ */ o(
|
|
97
|
+
"span",
|
|
98
|
+
{
|
|
99
|
+
className: u(
|
|
100
|
+
"Bear-CountdownTimer__label",
|
|
101
|
+
Y,
|
|
102
|
+
"bear-mt-1 bear-uppercase bear-tracking-widest",
|
|
103
|
+
"bear-text-gray-500 dark:bear-text-gray-400"
|
|
104
|
+
),
|
|
105
|
+
children: r.label
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] })
|
|
109
|
+
] }, r.label))
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
ie as CountdownTimer
|
|
115
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type CountdownTimerVariant = 'default' | 'card' | 'minimal' | 'flip';
|
|
3
|
+
export type CountdownTimerSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
export interface CountdownTimerProps {
|
|
5
|
+
/** Target date/time to count down to */
|
|
6
|
+
targetDate?: Date | string | number;
|
|
7
|
+
/** Duration in seconds (alternative to targetDate) */
|
|
8
|
+
duration?: number;
|
|
9
|
+
/** Visual variant */
|
|
10
|
+
variant?: CountdownTimerVariant | (string & {});
|
|
11
|
+
/** Size preset */
|
|
12
|
+
size?: CountdownTimerSize;
|
|
13
|
+
/** Whether to show days */
|
|
14
|
+
showDays?: boolean;
|
|
15
|
+
/** Whether to show hours */
|
|
16
|
+
showHours?: boolean;
|
|
17
|
+
/** Whether to show minutes */
|
|
18
|
+
showMinutes?: boolean;
|
|
19
|
+
/** Whether to show seconds */
|
|
20
|
+
showSeconds?: boolean;
|
|
21
|
+
/** Whether to show labels */
|
|
22
|
+
showLabels?: boolean;
|
|
23
|
+
/** Whether to show separator */
|
|
24
|
+
showSeparator?: boolean;
|
|
25
|
+
/** Separator character */
|
|
26
|
+
separator?: string;
|
|
27
|
+
/** Custom labels */
|
|
28
|
+
labels?: {
|
|
29
|
+
days?: string;
|
|
30
|
+
hours?: string;
|
|
31
|
+
minutes?: string;
|
|
32
|
+
seconds?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Called when countdown reaches zero */
|
|
35
|
+
onComplete?: () => void;
|
|
36
|
+
/** Called every second */
|
|
37
|
+
onTick?: (remaining: CountdownTime) => void;
|
|
38
|
+
/** Whether countdown is paused */
|
|
39
|
+
paused?: boolean;
|
|
40
|
+
/** Custom renderer */
|
|
41
|
+
render?: (time: CountdownTime) => ReactNode;
|
|
42
|
+
/** Custom class name */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** Custom style */
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
/** Test ID */
|
|
47
|
+
testId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CountdownTime {
|
|
50
|
+
days: number;
|
|
51
|
+
hours: number;
|
|
52
|
+
minutes: number;
|
|
53
|
+
seconds: number;
|
|
54
|
+
totalSeconds: number;
|
|
55
|
+
isComplete: boolean;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),S=require("../../utils/cn.cjs"),n=require("./Cropper.const.cjs"),ue=({src:p,crop:O,onCropChange:y,onCropComplete:v,aspectRatio:M="free",shape:I="rectangle",zoom:_,onZoomChange:N,minZoom:j=n.MIN_ZOOM,maxZoom:E=n.MAX_ZOOM,rotation:D,onRotationChange:k,showZoomSlider:o=!1,showRotationSlider:g=!1,showGrid:X=!1,gridOpacity:Y=n.DEFAULT_GRID_OPACITY,overlayColor:q=n.OVERLAY_COLOR,borderColor:B=n.BORDER_COLOR,borderWidth:V=n.BORDER_WIDTH,width:J="100%",height:K=400,className:Q,style:C,testId:Z})=>{const L=i.useRef(null),H=i.useRef(null),$=i.useRef(null),[ee,te]=i.useState(n.DEFAULT_CROP),[ae,re]=i.useState(n.DEFAULT_ZOOM),[se,ne]=i.useState(0),[f,W]=i.useState("none"),[w,P]=i.useState(null),[ie,ce]=i.useState(!1),[,le]=i.useState({w:0,h:0}),a=O??ee,x=_??ae,A=D??se,h=i.useMemo(()=>typeof M=="number"?M:n.ASPECT_RATIO_VALUES[M]??null,[M]),z=i.useCallback(e=>{O||te(e),y==null||y(e)},[O,y]),T=i.useCallback(e=>{const t=Math.max(j,Math.min(E,e));_||re(t),N==null||N(t)},[_,N,j,E]),he=i.useCallback(e=>{const t=Math.max(n.MIN_ROTATION,Math.min(n.MAX_ROTATION,e));D||ne(t),k==null||k(t)},[D,k]);i.useEffect(()=>{const e=new Image;e.crossOrigin="anonymous",e.onload=()=>{$.current=e,le({w:e.naturalWidth,h:e.naturalHeight}),ce(!0)},e.src=p},[p]);const b=i.useCallback(e=>{const t=L.current;if(!t)return e;const c=t.clientWidth,r=t.clientHeight-(o||g?60:0);let{x:l,y:m,width:u,height:d}=e;return u=Math.max(n.MIN_CROP_SIZE,u),d=Math.max(n.MIN_CROP_SIZE,d),h&&(d=u/h),l=Math.max(0,Math.min(c-u,l)),m=Math.max(0,Math.min(r-d,m)),{x:l,y:m,width:u,height:d}},[h,o,g]),G=i.useCallback(()=>{const e=H.current,t=$.current,c=L.current;if(!e||!t||!c)return"";const r=c.clientWidth,l=c.clientHeight-(o||g?60:0),m=t.naturalWidth/(r*x),u=t.naturalHeight/(l*x);e.width=a.width*m,e.height=a.height*u;const d=e.getContext("2d");return d?(I==="circle"&&(d.beginPath(),d.arc(e.width/2,e.height/2,Math.min(e.width,e.height)/2,0,Math.PI*2),d.clip()),d.drawImage(t,a.x*m,a.y*u,a.width*m,a.height*u,0,0,e.width,e.height),e.toDataURL("image/png")):""},[a,x,I,o,g]),R=i.useCallback(e=>t=>{t.preventDefault(),t.stopPropagation(),W(e),P({x:t.clientX,y:t.clientY,crop:{...a}})},[a]),de=i.useCallback(e=>{if(f==="none"||!w)return;const t=e.clientX-w.x,c=e.clientY-w.y,{crop:r}=w;let l;switch(f){case"move":l=b({...r,x:r.x+t,y:r.y+c});break;case"se":l=b({...r,width:r.width+t,height:h?(r.width+t)/h:r.height+c});break;case"sw":l=b({...r,x:r.x+t,width:r.width-t,height:h?(r.width-t)/h:r.height+c});break;case"ne":l=b({...r,y:h?r.y:r.y+c,width:r.width+t,height:h?(r.width+t)/h:r.height-c});break;case"nw":l=b({x:r.x+t,y:r.y+c,width:r.width-t,height:h?(r.width-t)/h:r.height-c});break;case"n":l=b({...r,y:r.y+c,height:r.height-c});break;case"s":l=b({...r,height:r.height+c});break;case"e":l=b({...r,width:r.width+t});break;case"w":l=b({...r,x:r.x+t,width:r.width-t});break;default:return}z(l)},[f,w,b,z,h]),U=i.useCallback(()=>{if(f!=="none"){const e=G();v==null||v(a,e)}W("none"),P(null)},[f,a,G,v]),be=i.useCallback(e=>{e.preventDefault();const t=e.deltaY>0?-n.ZOOM_STEP:n.ZOOM_STEP;T(x+t)},[x,T]),F=o||g?60:0;return s.jsxs("div",{className:S.cn("bear-relative bear-overflow-hidden bear-rounded-lg","bear-bg-gray-900 bear-select-none",Q),style:{width:J,height:K,...C},"data-testid":Z,children:[s.jsx("canvas",{ref:H,className:"bear-hidden"}),s.jsxs("div",{ref:L,className:"bear-relative bear-overflow-hidden bear-cursor-crosshair",style:{height:`calc(100% - ${F}px)`},onMouseMove:de,onMouseUp:U,onMouseLeave:U,onWheel:be,children:[ie&&s.jsx("img",{src:p,alt:"",className:"bear-absolute bear-inset-0 bear-w-full bear-h-full bear-object-contain bear-pointer-events-none",style:{transform:`scale(${x}) rotate(${A}deg)`,transition:f!=="none"?"none":"transform 0.2s ease"},draggable:!1}),s.jsxs("svg",{className:"bear-absolute bear-inset-0 bear-w-full bear-h-full bear-pointer-events-none",children:[s.jsx("defs",{children:s.jsxs("mask",{id:"crop-mask",children:[s.jsx("rect",{width:"100%",height:"100%",fill:"white"}),I==="circle"?s.jsx("ellipse",{cx:a.x+a.width/2,cy:a.y+a.height/2,rx:a.width/2,ry:a.height/2,fill:"black"}):s.jsx("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"black"})]})}),s.jsx("rect",{width:"100%",height:"100%",fill:q,mask:"url(#crop-mask)"})]}),s.jsx("div",{className:"bear-absolute bear-pointer-events-none",style:{left:a.x,top:a.y,width:a.width,height:a.height,border:`${V}px solid ${B}`,borderRadius:I==="circle"?"50%":0,boxShadow:"0 0 0 9999px transparent"},children:X&&s.jsxs("svg",{className:"bear-absolute bear-inset-0 bear-w-full bear-h-full",style:{opacity:Y},children:[Array.from({length:n.GRID_LINES-1}).map((e,t)=>s.jsx("line",{x1:`${(t+1)/n.GRID_LINES*100}%`,y1:"0",x2:`${(t+1)/n.GRID_LINES*100}%`,y2:"100%",stroke:"white",strokeWidth:"0.5"},`v-${t}`)),Array.from({length:n.GRID_LINES-1}).map((e,t)=>s.jsx("line",{x1:"0",y1:`${(t+1)/n.GRID_LINES*100}%`,x2:"100%",y2:`${(t+1)/n.GRID_LINES*100}%`,stroke:"white",strokeWidth:"0.5"},`h-${t}`))]})}),s.jsx("div",{className:"bear-absolute bear-cursor-move",style:{left:a.x,top:a.y,width:a.width,height:a.height},onMouseDown:R("move")}),["nw","ne","sw","se"].map(e=>{const t=e.includes("w"),c=e.includes("n");return s.jsx("div",{className:S.cn("bear-absolute bear-bg-white bear-border-2 bear-rounded-sm","bear-shadow-md bear-z-10"),style:{width:n.HANDLE_SIZE,height:n.HANDLE_SIZE,left:(t?a.x:a.x+a.width)-n.HANDLE_SIZE/2,top:(c?a.y:a.y+a.height)-n.HANDLE_SIZE/2,borderColor:"var(--bear-primary-500)",cursor:`${e}-resize`},onMouseDown:R(e)},e)}),["n","s","e","w"].map(e=>{const t=e==="n"||e==="s";return s.jsx("div",{className:"bear-absolute bear-z-10",style:{left:e==="w"?a.x-4:e==="e"?a.x+a.width-4:a.x+a.width/2-12,top:e==="n"?a.y-4:e==="s"?a.y+a.height-4:a.y+a.height/2-12,width:t?24:8,height:t?8:24,cursor:t?`${e}-resize`:`${e}-resize`},onMouseDown:R(e)},e)})]}),(o||g)&&s.jsxs("div",{className:S.cn("bear-flex bear-items-center bear-gap-4 bear-px-4","bear-bg-gray-800/90 bear-backdrop-blur-sm"),style:{height:F},children:[o&&s.jsxs("div",{className:"bear-flex bear-items-center bear-gap-2 bear-flex-1",children:[s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),s.jsx("input",{type:"range",min:j,max:E,step:n.ZOOM_STEP,value:x,onChange:e=>T(parseFloat(e.target.value)),className:"bear-flex-1 bear-h-1 bear-accent-pink-500"}),s.jsxs("span",{className:"bear-text-xs bear-text-gray-400 bear-w-10 bear-text-right",children:[(x*100).toFixed(0),"%"]})]}),g&&s.jsxs("div",{className:"bear-flex bear-items-center bear-gap-2 bear-flex-1",children:[s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),s.jsx("input",{type:"range",min:n.MIN_ROTATION,max:n.MAX_ROTATION,step:n.ROTATION_STEP,value:A,onChange:e=>he(parseFloat(e.target.value)),className:"bear-flex-1 bear-h-1 bear-accent-pink-500"}),s.jsxs("span",{className:"bear-text-xs bear-text-gray-400 bear-w-10 bear-text-right",children:[A,"°"]})]})]})]})};exports.Cropper=ue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O={x:50,y:50,width:200,height:200},_=20,T=1,R=.5,A=5,E=.1,I=-180,t=180,o=1,n="rgba(0, 0, 0, 0.6)",M="#ffffff",c=2,s=3,D=.4,L=12,N={free:null,"1:1":1,"4:3":4/3,"3:2":3/2,"16:9":16/9,"2:3":2/3,"3:4":3/4,"9:16":9/16};exports.ASPECT_RATIO_VALUES=N;exports.BORDER_COLOR=M;exports.BORDER_WIDTH=c;exports.DEFAULT_CROP=O;exports.DEFAULT_GRID_OPACITY=D;exports.DEFAULT_ZOOM=T;exports.GRID_LINES=s;exports.HANDLE_SIZE=L;exports.MAX_ROTATION=t;exports.MAX_ZOOM=A;exports.MIN_CROP_SIZE=_;exports.MIN_ROTATION=I;exports.MIN_ZOOM=R;exports.OVERLAY_COLOR=n;exports.ROTATION_STEP=o;exports.ZOOM_STEP=E;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CropArea, AspectRatioPreset } from './Cropper.types';
|
|
2
|
+
/** Default crop area */
|
|
3
|
+
export declare const DEFAULT_CROP: CropArea;
|
|
4
|
+
/** Min crop dimensions */
|
|
5
|
+
export declare const MIN_CROP_SIZE = 20;
|
|
6
|
+
/** Default zoom */
|
|
7
|
+
export declare const DEFAULT_ZOOM = 1;
|
|
8
|
+
/** Zoom range */
|
|
9
|
+
export declare const MIN_ZOOM = 0.5;
|
|
10
|
+
export declare const MAX_ZOOM = 5;
|
|
11
|
+
/** Zoom step for slider */
|
|
12
|
+
export declare const ZOOM_STEP = 0.1;
|
|
13
|
+
/** Rotation range */
|
|
14
|
+
export declare const MIN_ROTATION = -180;
|
|
15
|
+
export declare const MAX_ROTATION = 180;
|
|
16
|
+
/** Rotation step for slider */
|
|
17
|
+
export declare const ROTATION_STEP = 1;
|
|
18
|
+
/** Default overlay color */
|
|
19
|
+
export declare const OVERLAY_COLOR = "rgba(0, 0, 0, 0.6)";
|
|
20
|
+
/** Default border color */
|
|
21
|
+
export declare const BORDER_COLOR = "#ffffff";
|
|
22
|
+
/** Default border width */
|
|
23
|
+
export declare const BORDER_WIDTH = 2;
|
|
24
|
+
/** Grid line count per axis */
|
|
25
|
+
export declare const GRID_LINES = 3;
|
|
26
|
+
/** Default grid opacity */
|
|
27
|
+
export declare const DEFAULT_GRID_OPACITY = 0.4;
|
|
28
|
+
/** Handle size in px */
|
|
29
|
+
export declare const HANDLE_SIZE = 12;
|
|
30
|
+
/** Aspect ratio numeric values */
|
|
31
|
+
export declare const ASPECT_RATIO_VALUES: Record<AspectRatioPreset, number | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const O = {
|
|
2
|
+
x: 50,
|
|
3
|
+
y: 50,
|
|
4
|
+
width: 200,
|
|
5
|
+
height: 200
|
|
6
|
+
}, t = 20, _ = 1, n = 0.5, o = 5, c = 0.1, s = -180, R = 180, T = 1, A = "rgba(0, 0, 0, 0.6)", E = "#ffffff", I = 2, D = 3, L = 0.4, M = 12, N = {
|
|
7
|
+
free: null,
|
|
8
|
+
"1:1": 1,
|
|
9
|
+
"4:3": 4 / 3,
|
|
10
|
+
"3:2": 3 / 2,
|
|
11
|
+
"16:9": 16 / 9,
|
|
12
|
+
"2:3": 2 / 3,
|
|
13
|
+
"3:4": 3 / 4,
|
|
14
|
+
"9:16": 9 / 16
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
N as ASPECT_RATIO_VALUES,
|
|
18
|
+
E as BORDER_COLOR,
|
|
19
|
+
I as BORDER_WIDTH,
|
|
20
|
+
O as DEFAULT_CROP,
|
|
21
|
+
L as DEFAULT_GRID_OPACITY,
|
|
22
|
+
_ as DEFAULT_ZOOM,
|
|
23
|
+
D as GRID_LINES,
|
|
24
|
+
M as HANDLE_SIZE,
|
|
25
|
+
R as MAX_ROTATION,
|
|
26
|
+
o as MAX_ZOOM,
|
|
27
|
+
t as MIN_CROP_SIZE,
|
|
28
|
+
s as MIN_ROTATION,
|
|
29
|
+
n as MIN_ZOOM,
|
|
30
|
+
A as OVERLAY_COLOR,
|
|
31
|
+
T as ROTATION_STEP,
|
|
32
|
+
c as ZOOM_STEP
|
|
33
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CropperProps } from './Cropper.types';
|
|
3
|
+
/**
|
|
4
|
+
* Cropper - Image cropping component with zoom, rotate, and aspect ratio
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Interactive image cropper with handles, zoom, rotation, grid overlay,
|
|
8
|
+
* and aspect ratio presets. Outputs cropped image as data URL.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Cropper
|
|
13
|
+
* src="/photo.jpg"
|
|
14
|
+
* aspectRatio="16:9"
|
|
15
|
+
* showZoomSlider
|
|
16
|
+
* showGrid
|
|
17
|
+
* onCropComplete={(crop, url) => console.log(url)}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const Cropper: FC<CropperProps>;
|