@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,250 @@
|
|
|
1
|
+
import { jsxs as L, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as de, useState as x, useMemo as N, useCallback as b } from "react";
|
|
3
|
+
import { cn as be } from "../../utils/cn.js";
|
|
4
|
+
import { DARK_THEME as pe, LIGHT_THEME as fe, DEFAULT_TAB_SIZE as ue, AUTO_CLOSE_PAIRS as G, LINE_HEIGHT as D, DEFAULT_FONT_SIZE as me, DEFAULT_FONT_FAMILY as ke, GUTTER_WIDTH as Ee } from "./CodeEditor.const.js";
|
|
5
|
+
import { tokenizeLine as ge } from "./CodeEditor.utils.js";
|
|
6
|
+
const Te = ({
|
|
7
|
+
value: s,
|
|
8
|
+
onChange: r,
|
|
9
|
+
language: A = "typescript",
|
|
10
|
+
theme: F = "dark",
|
|
11
|
+
customTheme: p,
|
|
12
|
+
placeholder: J = "Start typing...",
|
|
13
|
+
showLineNumbers: T = !0,
|
|
14
|
+
showGutter: h = !0,
|
|
15
|
+
highlightActiveLine: O = !0,
|
|
16
|
+
readOnly: f = !1,
|
|
17
|
+
fontSize: _ = me,
|
|
18
|
+
fontFamily: H = ke,
|
|
19
|
+
tabSize: u = ue,
|
|
20
|
+
autoIndent: I = !0,
|
|
21
|
+
autoCloseBrackets: R = !0,
|
|
22
|
+
wordWrap: E = !1,
|
|
23
|
+
minHeight: U,
|
|
24
|
+
maxHeight: q,
|
|
25
|
+
height: K,
|
|
26
|
+
className: Q,
|
|
27
|
+
style: X,
|
|
28
|
+
testId: W,
|
|
29
|
+
onFocus: g,
|
|
30
|
+
onBlur: v
|
|
31
|
+
}) => {
|
|
32
|
+
const y = de(null), [M, V] = x(!1), [S, z] = x(0), [$, C] = x(0), [ee, te] = x(0), B = F === "dark" ? pe : fe, n = N(
|
|
33
|
+
() => ({
|
|
34
|
+
...B,
|
|
35
|
+
...p,
|
|
36
|
+
tokens: { ...B.tokens, ...p == null ? void 0 : p.tokens }
|
|
37
|
+
}),
|
|
38
|
+
[F, p]
|
|
39
|
+
), w = N(() => s.split(`
|
|
40
|
+
`), [s]), re = N(
|
|
41
|
+
() => w.map((e) => ge(e, A)),
|
|
42
|
+
[w, A]
|
|
43
|
+
), j = b(() => {
|
|
44
|
+
const e = y.current;
|
|
45
|
+
if (!e) return;
|
|
46
|
+
const t = e.value.substring(0, e.selectionStart);
|
|
47
|
+
z(t.split(`
|
|
48
|
+
`).length - 1);
|
|
49
|
+
}, []), se = b(
|
|
50
|
+
(e) => {
|
|
51
|
+
var Y;
|
|
52
|
+
if (f) return;
|
|
53
|
+
const t = y.current;
|
|
54
|
+
if (!t) return;
|
|
55
|
+
const { selectionStart: i, selectionEnd: o } = t;
|
|
56
|
+
if (e.key === "Tab") {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
const a = " ".repeat(u), c = s.substring(0, i), m = s.substring(o), l = c + a + m;
|
|
59
|
+
r == null || r(l), requestAnimationFrame(() => {
|
|
60
|
+
t.selectionStart = t.selectionEnd = i + u;
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (e.key === "Enter" && I) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const a = s.substring(0, i), c = s.substring(o), l = ((Y = (a.split(`
|
|
67
|
+
`).pop() ?? "").match(/^\s*/)) == null ? void 0 : Y[0]) ?? "", k = a.trim().slice(-1), Z = ["{", "(", "[", ":"].includes(k) ? " ".repeat(u) : "", le = a + `
|
|
68
|
+
` + l + Z + c;
|
|
69
|
+
r == null || r(le), requestAnimationFrame(() => {
|
|
70
|
+
const ce = i + 1 + l.length + Z.length;
|
|
71
|
+
t.selectionStart = t.selectionEnd = ce;
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (R && G[e.key]) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
const a = G[e.key], c = s.substring(0, i), m = s.substring(i, o), l = s.substring(o);
|
|
78
|
+
if (m) {
|
|
79
|
+
const k = c + e.key + m + a + l;
|
|
80
|
+
r == null || r(k), requestAnimationFrame(() => {
|
|
81
|
+
t.selectionStart = i + 1, t.selectionEnd = o + 1;
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
const k = c + e.key + a + l;
|
|
85
|
+
r == null || r(k), requestAnimationFrame(() => {
|
|
86
|
+
t.selectionStart = t.selectionEnd = i + 1;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[s, r, f, u, I, R]
|
|
93
|
+
), ne = b(
|
|
94
|
+
(e) => {
|
|
95
|
+
f || r == null || r(e.target.value);
|
|
96
|
+
},
|
|
97
|
+
[r, f]
|
|
98
|
+
), ie = b(() => {
|
|
99
|
+
const e = y.current;
|
|
100
|
+
e && (C(e.scrollTop), te(e.scrollLeft));
|
|
101
|
+
}, []), ae = b(() => {
|
|
102
|
+
V(!0), g == null || g();
|
|
103
|
+
}, [g]), oe = b(() => {
|
|
104
|
+
V(!1), v == null || v();
|
|
105
|
+
}, [v]), P = _ * D;
|
|
106
|
+
return /* @__PURE__ */ L(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: be(
|
|
110
|
+
"bear-relative bear-overflow-hidden bear-rounded-lg bear-font-mono",
|
|
111
|
+
"bear-border",
|
|
112
|
+
M ? "bear-ring-2 bear-ring-offset-1" : "",
|
|
113
|
+
Q
|
|
114
|
+
),
|
|
115
|
+
style: {
|
|
116
|
+
background: n.background,
|
|
117
|
+
borderColor: n.gutterBorder,
|
|
118
|
+
fontFamily: H,
|
|
119
|
+
fontSize: _,
|
|
120
|
+
lineHeight: D,
|
|
121
|
+
minHeight: U,
|
|
122
|
+
maxHeight: q,
|
|
123
|
+
height: K,
|
|
124
|
+
"--bear-editor-ring": "var(--bear-primary-500)",
|
|
125
|
+
...X
|
|
126
|
+
},
|
|
127
|
+
"data-testid": W,
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ L("div", { className: "bear-relative bear-flex bear-h-full", children: [
|
|
130
|
+
h && T && /* @__PURE__ */ d(
|
|
131
|
+
"div",
|
|
132
|
+
{
|
|
133
|
+
className: "bear-flex-shrink-0 bear-select-none bear-text-right bear-pr-3 bear-overflow-hidden",
|
|
134
|
+
style: {
|
|
135
|
+
width: Ee,
|
|
136
|
+
background: n.gutterBackground,
|
|
137
|
+
borderRight: `1px solid ${n.gutterBorder}`,
|
|
138
|
+
paddingTop: 12,
|
|
139
|
+
transform: `translateY(-${$}px)`
|
|
140
|
+
},
|
|
141
|
+
"aria-hidden": "true",
|
|
142
|
+
children: w.map((e, t) => /* @__PURE__ */ d(
|
|
143
|
+
"div",
|
|
144
|
+
{
|
|
145
|
+
style: {
|
|
146
|
+
height: P,
|
|
147
|
+
color: t === S ? n.lineNumberActive : n.lineNumber,
|
|
148
|
+
fontWeight: t === S ? 600 : 400
|
|
149
|
+
},
|
|
150
|
+
children: t + 1
|
|
151
|
+
},
|
|
152
|
+
t
|
|
153
|
+
))
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ L("div", { className: "bear-relative bear-flex-1 bear-overflow-hidden", children: [
|
|
157
|
+
/* @__PURE__ */ d(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
className: "bear-absolute bear-inset-0 bear-pointer-events-none bear-overflow-hidden",
|
|
161
|
+
style: {
|
|
162
|
+
padding: 12,
|
|
163
|
+
paddingLeft: h && !T ? 12 : 16,
|
|
164
|
+
transform: `translate(-${ee}px, -${$}px)`,
|
|
165
|
+
whiteSpace: E ? "pre-wrap" : "pre",
|
|
166
|
+
wordBreak: E ? "break-all" : "normal"
|
|
167
|
+
},
|
|
168
|
+
"aria-hidden": "true",
|
|
169
|
+
children: re.map((e, t) => /* @__PURE__ */ L(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
style: {
|
|
173
|
+
height: P,
|
|
174
|
+
background: O && t === S && M ? n.selection : "transparent"
|
|
175
|
+
},
|
|
176
|
+
children: [
|
|
177
|
+
e.map((i, o) => /* @__PURE__ */ d(
|
|
178
|
+
"span",
|
|
179
|
+
{
|
|
180
|
+
style: {
|
|
181
|
+
color: n.tokens[i.type] ?? n.foreground
|
|
182
|
+
},
|
|
183
|
+
children: i.value
|
|
184
|
+
},
|
|
185
|
+
o
|
|
186
|
+
)),
|
|
187
|
+
e.length === 0 && " "
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
t
|
|
191
|
+
))
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ d(
|
|
195
|
+
"textarea",
|
|
196
|
+
{
|
|
197
|
+
ref: y,
|
|
198
|
+
value: s,
|
|
199
|
+
onChange: ne,
|
|
200
|
+
onKeyDown: se,
|
|
201
|
+
onScroll: ie,
|
|
202
|
+
onFocus: ae,
|
|
203
|
+
onBlur: oe,
|
|
204
|
+
onClick: j,
|
|
205
|
+
onKeyUp: j,
|
|
206
|
+
readOnly: f,
|
|
207
|
+
placeholder: s ? void 0 : J,
|
|
208
|
+
spellCheck: !1,
|
|
209
|
+
autoComplete: "off",
|
|
210
|
+
autoCorrect: "off",
|
|
211
|
+
autoCapitalize: "off",
|
|
212
|
+
className: "bear-w-full bear-h-full bear-resize-none bear-outline-none",
|
|
213
|
+
style: {
|
|
214
|
+
padding: 12,
|
|
215
|
+
paddingLeft: h && !T ? 12 : 16,
|
|
216
|
+
background: "transparent",
|
|
217
|
+
color: "transparent",
|
|
218
|
+
caretColor: n.cursor,
|
|
219
|
+
fontFamily: H,
|
|
220
|
+
fontSize: _,
|
|
221
|
+
lineHeight: D,
|
|
222
|
+
tabSize: u,
|
|
223
|
+
whiteSpace: E ? "pre-wrap" : "pre",
|
|
224
|
+
wordBreak: E ? "break-all" : "normal",
|
|
225
|
+
minHeight: U ?? 100,
|
|
226
|
+
maxHeight: q,
|
|
227
|
+
height: K ?? "auto"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
] })
|
|
232
|
+
] }),
|
|
233
|
+
/* @__PURE__ */ d(
|
|
234
|
+
"div",
|
|
235
|
+
{
|
|
236
|
+
className: "bear-absolute bear-bottom-2 bear-right-3 bear-text-xs bear-font-medium bear-px-2 bear-py-0.5 bear-rounded bear-select-none",
|
|
237
|
+
style: {
|
|
238
|
+
color: n.lineNumber,
|
|
239
|
+
background: n.gutterBackground
|
|
240
|
+
},
|
|
241
|
+
children: A
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
export {
|
|
249
|
+
Te as CodeEditor
|
|
250
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Supported programming languages
|
|
4
|
+
*/
|
|
5
|
+
export type CodeEditorLanguage = 'javascript' | 'typescript' | 'jsx' | 'tsx' | 'html' | 'css' | 'json' | 'python' | 'markdown' | 'sql' | 'shell' | 'yaml' | 'xml' | 'plaintext';
|
|
6
|
+
/**
|
|
7
|
+
* Syntax token type for highlighting
|
|
8
|
+
*/
|
|
9
|
+
export type TokenType = 'keyword' | 'string' | 'number' | 'comment' | 'operator' | 'punctuation' | 'function' | 'variable' | 'tag' | 'attribute' | 'property' | 'builtin' | 'regex' | 'boolean' | 'null' | 'type' | 'default';
|
|
10
|
+
/**
|
|
11
|
+
* Token from syntax analysis
|
|
12
|
+
*/
|
|
13
|
+
export interface SyntaxToken {
|
|
14
|
+
type: TokenType;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Theme colors for the editor
|
|
19
|
+
*/
|
|
20
|
+
export interface CodeEditorTheme {
|
|
21
|
+
background: string;
|
|
22
|
+
foreground: string;
|
|
23
|
+
cursor: string;
|
|
24
|
+
selection: string;
|
|
25
|
+
lineNumber: string;
|
|
26
|
+
lineNumberActive: string;
|
|
27
|
+
gutterBackground: string;
|
|
28
|
+
gutterBorder: string;
|
|
29
|
+
tokens: Partial<Record<TokenType, string>>;
|
|
30
|
+
}
|
|
31
|
+
export interface CodeEditorProps {
|
|
32
|
+
/** Current value */
|
|
33
|
+
value: string;
|
|
34
|
+
/** Called on value change */
|
|
35
|
+
onChange?: (value: string) => void;
|
|
36
|
+
/** Programming language for syntax highlighting */
|
|
37
|
+
language?: CodeEditorLanguage;
|
|
38
|
+
/** Editor theme ('dark' | 'light') */
|
|
39
|
+
theme?: 'dark' | 'light';
|
|
40
|
+
/** Custom theme overrides */
|
|
41
|
+
customTheme?: Partial<CodeEditorTheme>;
|
|
42
|
+
/** Placeholder text */
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
/** Show line numbers */
|
|
45
|
+
showLineNumbers?: boolean;
|
|
46
|
+
/** Show gutter (line number area) */
|
|
47
|
+
showGutter?: boolean;
|
|
48
|
+
/** Highlight active line */
|
|
49
|
+
highlightActiveLine?: boolean;
|
|
50
|
+
/** Read-only mode */
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
/** Font size in px */
|
|
53
|
+
fontSize?: number;
|
|
54
|
+
/** Font family */
|
|
55
|
+
fontFamily?: string;
|
|
56
|
+
/** Tab size (spaces) */
|
|
57
|
+
tabSize?: number;
|
|
58
|
+
/** Auto-indent on new line */
|
|
59
|
+
autoIndent?: boolean;
|
|
60
|
+
/** Auto-close brackets */
|
|
61
|
+
autoCloseBrackets?: boolean;
|
|
62
|
+
/** Word wrap */
|
|
63
|
+
wordWrap?: boolean;
|
|
64
|
+
/** Min height */
|
|
65
|
+
minHeight?: string | number;
|
|
66
|
+
/** Max height */
|
|
67
|
+
maxHeight?: string | number;
|
|
68
|
+
/** Height */
|
|
69
|
+
height?: string | number;
|
|
70
|
+
/** Custom class name */
|
|
71
|
+
className?: string;
|
|
72
|
+
/** Custom styles */
|
|
73
|
+
style?: CSSProperties;
|
|
74
|
+
/** Test ID */
|
|
75
|
+
testId?: string;
|
|
76
|
+
/** Called on focus */
|
|
77
|
+
onFocus?: () => void;
|
|
78
|
+
/** Called on blur */
|
|
79
|
+
onBlur?: () => void;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./CodeEditor.const.cjs"),u=(e,f)=>{if(f==="plaintext"||f==="markdown")return[{type:"default",value:e}];const r=[],h=i.LANGUAGE_KEYWORDS[f]??[];let t=0;const c=(s,o)=>{o&&r.push({type:s,value:o})};for(;t<e.length;){if(e[t]==="/"&&e[t+1]==="/"){c("comment",e.slice(t));break}if(e[t]==="/"&&e[t+1]==="*"){const s=e.indexOf("*/",t+2),o=s===-1?e.slice(t):e.slice(t,s+2);c("comment",o),t+=o.length;continue}if(e[t]==="#"&&(f==="python"||f==="shell"||f==="yaml")){c("comment",e.slice(t));break}if(e[t]==='"'||e[t]==="'"||e[t]==="`"){const s=e[t];let o=t+1;for(;o<e.length&&e[o]!==s;)e[o]==="\\"&&o++,o++;c("string",e.slice(t,o+1)),t=o+1;continue}if(/[0-9]/.test(e[t])&&(t===0||/[^a-zA-Z_$]/.test(e[t-1]))){let s=t;for(;s<e.length&&/[0-9.xXa-fA-F_eEn]/.test(e[s]);)s++;c("number",e.slice(t,s)),t=s;continue}if(/[a-zA-Z_$]/.test(e[t])){let s=t;for(;s<e.length&&/[a-zA-Z0-9_$]/.test(e[s]);)s++;const o=e.slice(t,s);o==="true"||o==="false"?c("boolean",o):o==="null"||o==="undefined"||o==="None"||o==="NaN"?c("null",o):h.includes(o)?c("keyword",o):i.BUILTIN_FUNCTIONS.includes(o)?c("builtin",o):s<e.length&&e[s]==="("?c("function",o):t>0&&e[t-1]==="."?c("property",o):c("variable",o),t=s;continue}if(e[t]==="<"&&(f==="html"||f==="jsx"||f==="tsx"||f==="xml")){e[t+1]==="/"?(c("tag","</"),t+=2):(c("tag","<"),t+=1);continue}if(e[t]===">"&&(f==="html"||f==="jsx"||f==="tsx"||f==="xml")){c("tag",">"),t+=1;continue}if(/[+\-*/%=!<>&|^~?:]/.test(e[t])){let s=t;for(;s<e.length&&/[+\-*/%=!<>&|^~?:]/.test(e[s]);)s++;c("operator",e.slice(t,s)),t=s;continue}if(/[(){}[\],;.]/.test(e[t])){c("punctuation",e[t]),t++;continue}if(/\s/.test(e[t])){let s=t;for(;s<e.length&&/\s/.test(e[s]);)s++;c("default",e.slice(t,s)),t=s;continue}c("default",e[t]),t++}return r};exports.tokenizeLine=u;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CodeEditorLanguage, SyntaxToken } from './CodeEditor.types';
|
|
2
|
+
/**
|
|
3
|
+
* Simple tokenizer for syntax highlighting
|
|
4
|
+
* Produces tokens for a single line of code
|
|
5
|
+
*/
|
|
6
|
+
export declare const tokenizeLine: (line: string, language: CodeEditorLanguage) => SyntaxToken[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { LANGUAGE_KEYWORDS as i, BUILTIN_FUNCTIONS as m } from "./CodeEditor.const.js";
|
|
2
|
+
const d = (s, f) => {
|
|
3
|
+
if (f === "plaintext" || f === "markdown")
|
|
4
|
+
return [{ type: "default", value: s }];
|
|
5
|
+
const r = [], h = i[f] ?? [];
|
|
6
|
+
let t = 0;
|
|
7
|
+
const c = (e, o) => {
|
|
8
|
+
o && r.push({ type: e, value: o });
|
|
9
|
+
};
|
|
10
|
+
for (; t < s.length; ) {
|
|
11
|
+
if (s[t] === "/" && s[t + 1] === "/") {
|
|
12
|
+
c("comment", s.slice(t));
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
if (s[t] === "/" && s[t + 1] === "*") {
|
|
16
|
+
const e = s.indexOf("*/", t + 2), o = e === -1 ? s.slice(t) : s.slice(t, e + 2);
|
|
17
|
+
c("comment", o), t += o.length;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (s[t] === "#" && (f === "python" || f === "shell" || f === "yaml")) {
|
|
21
|
+
c("comment", s.slice(t));
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
if (s[t] === '"' || s[t] === "'" || s[t] === "`") {
|
|
25
|
+
const e = s[t];
|
|
26
|
+
let o = t + 1;
|
|
27
|
+
for (; o < s.length && s[o] !== e; )
|
|
28
|
+
s[o] === "\\" && o++, o++;
|
|
29
|
+
c("string", s.slice(t, o + 1)), t = o + 1;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (/[0-9]/.test(s[t]) && (t === 0 || /[^a-zA-Z_$]/.test(s[t - 1]))) {
|
|
33
|
+
let e = t;
|
|
34
|
+
for (; e < s.length && /[0-9.xXa-fA-F_eEn]/.test(s[e]); ) e++;
|
|
35
|
+
c("number", s.slice(t, e)), t = e;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (/[a-zA-Z_$]/.test(s[t])) {
|
|
39
|
+
let e = t;
|
|
40
|
+
for (; e < s.length && /[a-zA-Z0-9_$]/.test(s[e]); ) e++;
|
|
41
|
+
const o = s.slice(t, e);
|
|
42
|
+
o === "true" || o === "false" ? c("boolean", o) : o === "null" || o === "undefined" || o === "None" || o === "NaN" ? c("null", o) : h.includes(o) ? c("keyword", o) : m.includes(o) ? c("builtin", o) : e < s.length && s[e] === "(" ? c("function", o) : t > 0 && s[t - 1] === "." ? c("property", o) : c("variable", o), t = e;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (s[t] === "<" && (f === "html" || f === "jsx" || f === "tsx" || f === "xml")) {
|
|
46
|
+
s[t + 1] === "/" ? (c("tag", "</"), t += 2) : (c("tag", "<"), t += 1);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (s[t] === ">" && (f === "html" || f === "jsx" || f === "tsx" || f === "xml")) {
|
|
50
|
+
c("tag", ">"), t += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (/[+\-*/%=!<>&|^~?:]/.test(s[t])) {
|
|
54
|
+
let e = t;
|
|
55
|
+
for (; e < s.length && /[+\-*/%=!<>&|^~?:]/.test(s[e]); ) e++;
|
|
56
|
+
c("operator", s.slice(t, e)), t = e;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (/[(){}[\],;.]/.test(s[t])) {
|
|
60
|
+
c("punctuation", s[t]), t++;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (/\s/.test(s[t])) {
|
|
64
|
+
let e = t;
|
|
65
|
+
for (; e < s.length && /\s/.test(s[e]); ) e++;
|
|
66
|
+
c("default", s.slice(t, e)), t = e;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
c("default", s[t]), t++;
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
d as tokenizeLine
|
|
75
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),a=require("../../utils/cn.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),a=require("../../utils/cn.cjs");require("react");const c={none:"0",xs:"0.5rem",sm:"1rem",md:"1.5rem",lg:"2rem",xl:"3rem"},b=({children:l,count:e="auto",gap:n="md",fill:r=!1,minWidth:o,className:s,style:m})=>{const t={columnCount:e==="auto"?"auto":e,columnGap:c[n],columnFill:r?"balance":"auto",...o&&{columnWidth:typeof o=="number"?`${o}px`:o},...m};return u.jsx("div",{className:a.cn("bear-w-full",s),style:t,children:l})},i=({children:l,span:e="avoid",className:n,style:r})=>u.jsx("div",{className:a.cn("bear-inline-block bear-w-full bear-mb-4",e==="avoid"&&"bear-break-inside-avoid",n),style:r,children:l});exports.Column=i;exports.Columns=b;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { cn as n } from "../../utils/cn.js";
|
|
3
|
+
import "react";
|
|
3
4
|
const c = {
|
|
4
5
|
none: "0",
|
|
5
6
|
xs: "0.5rem",
|
|
@@ -10,16 +11,16 @@ const c = {
|
|
|
10
11
|
}, d = ({
|
|
11
12
|
children: l,
|
|
12
13
|
count: o = "auto",
|
|
13
|
-
gap:
|
|
14
|
-
fill:
|
|
14
|
+
gap: r = "md",
|
|
15
|
+
fill: a = !1,
|
|
15
16
|
minWidth: e,
|
|
16
17
|
className: u,
|
|
17
18
|
style: s
|
|
18
19
|
}) => {
|
|
19
20
|
const t = {
|
|
20
21
|
columnCount: o === "auto" ? "auto" : o,
|
|
21
|
-
columnGap: c[
|
|
22
|
-
columnFill:
|
|
22
|
+
columnGap: c[r],
|
|
23
|
+
columnFill: a ? "balance" : "auto",
|
|
23
24
|
...e && { columnWidth: typeof e == "number" ? `${e}px` : e },
|
|
24
25
|
...s
|
|
25
26
|
};
|
|
@@ -34,17 +35,17 @@ const c = {
|
|
|
34
35
|
}, f = ({
|
|
35
36
|
children: l,
|
|
36
37
|
span: o = "avoid",
|
|
37
|
-
className:
|
|
38
|
-
style:
|
|
38
|
+
className: r,
|
|
39
|
+
style: a
|
|
39
40
|
}) => /* @__PURE__ */ m(
|
|
40
41
|
"div",
|
|
41
42
|
{
|
|
42
43
|
className: n(
|
|
43
44
|
"bear-inline-block bear-w-full bear-mb-4",
|
|
44
45
|
o === "avoid" && "bear-break-inside-avoid",
|
|
45
|
-
|
|
46
|
+
r
|
|
46
47
|
),
|
|
47
|
-
style:
|
|
48
|
+
style: a,
|
|
48
49
|
children: l
|
|
49
50
|
}
|
|
50
51
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react/jsx-runtime"),n=require("react"),g=require("../../utils/cn.cjs"),r=require("./Confetti.const.cjs"),v=({active:E=!1,count:c=r.CONFETTI_DEFAULTS.COUNT,duration:h=r.CONFETTI_DEFAULTS.DURATION,colors:T=r.CONFETTI_COLORS,originX:I=r.CONFETTI_DEFAULTS.ORIGIN_X,originY:f=r.CONFETTI_DEFAULTS.ORIGIN_Y,spread:F=r.CONFETTI_DEFAULTS.SPREAD,velocity:S=r.CONFETTI_DEFAULTS.VELOCITY,gravity:O=r.CONFETTI_DEFAULTS.GRAVITY,autoHide:N=r.CONFETTI_DEFAULTS.AUTO_HIDE,onComplete:o,className:x,testId:y})=>{const[m,d]=n.useState([]),[b,A]=n.useState(!1),a=n.useRef(),i=n.useRef(0),_=n.useCallback(()=>{const t=[],l=F*Math.PI/180;for(let s=0;s<c;s++){const e=-Math.PI/2+(Math.random()-.5)*l,C=S*(.5+Math.random()*.5);t.push({id:s,x:I*100,y:f*100,rotation:Math.random()*360,color:T[Math.floor(Math.random()*T.length)],size:r.CONFETTI_SIZE_RANGE.min+Math.random()*(r.CONFETTI_SIZE_RANGE.max-r.CONFETTI_SIZE_RANGE.min),velocity:{x:Math.cos(e)*C,y:Math.sin(e)*C},rotationSpeed:(Math.random()-.5)*20,shape:r.CONFETTI_SHAPES[Math.floor(Math.random()*r.CONFETTI_SHAPES.length)]})}return t},[c,T,I,f,F,S]),u=n.useCallback(t=>{if(i.current||(i.current=t),t-i.current>=h&&N){A(!1),d([]),o==null||o();return}d(s=>s.map(e=>({...e,x:e.x+e.velocity.x*.1,y:e.y+e.velocity.y*.1,rotation:e.rotation+e.rotationSpeed,velocity:{x:e.velocity.x*.99,y:e.velocity.y+O}}))),a.current=requestAnimationFrame(u)},[h,O,N,o]);n.useEffect(()=>(E?(A(!0),d(_()),i.current=0,a.current=requestAnimationFrame(u)):a.current&&cancelAnimationFrame(a.current),()=>{a.current&&cancelAnimationFrame(a.current)}),[E,_,u]);const M=t=>{const l={position:"absolute",left:`${t.x}%`,top:`${t.y}%`,width:t.size,height:t.size,transform:`rotate(${t.rotation}deg)`,backgroundColor:t.shape!=="triangle"?t.color:"transparent",borderRadius:t.shape==="circle"?"50%":0,borderLeft:t.shape==="triangle"?`${t.size/2}px solid transparent`:void 0,borderRight:t.shape==="triangle"?`${t.size/2}px solid transparent`:void 0,borderBottom:t.shape==="triangle"?`${t.size}px solid ${t.color}`:void 0,opacity:.9};return R.jsx("div",{style:l},t.id)};return!b||m.length===0?null:R.jsx("div",{className:g.cn("Bear-Confetti","bear-fixed bear-inset-0 bear-pointer-events-none bear-overflow-hidden",x),style:{zIndex:99999},"data-testid":y,children:m.map(M)})};exports.Confetti=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T={COUNT:100,DURATION:3e3,ORIGIN_X:.5,ORIGIN_Y:.5,SPREAD:60,VELOCITY:30,GRAVITY:.5,AUTO_HIDE:!0},E=["#ec4899","#8b5cf6","#3b82f6","#10b981","#f59e0b","#ef4444","#06b6d4","#f97316"],O=["square","circle","triangle"],I={min:8,max:14};exports.CONFETTI_COLORS=E;exports.CONFETTI_DEFAULTS=T;exports.CONFETTI_SHAPES=O;exports.CONFETTI_SIZE_RANGE=I;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const CONFETTI_DEFAULTS: {
|
|
2
|
+
readonly COUNT: 100;
|
|
3
|
+
readonly DURATION: 3000;
|
|
4
|
+
readonly ORIGIN_X: 0.5;
|
|
5
|
+
readonly ORIGIN_Y: 0.5;
|
|
6
|
+
readonly SPREAD: 60;
|
|
7
|
+
readonly VELOCITY: 30;
|
|
8
|
+
readonly GRAVITY: 0.5;
|
|
9
|
+
readonly AUTO_HIDE: true;
|
|
10
|
+
};
|
|
11
|
+
export declare const CONFETTI_COLORS: readonly ["#ec4899", "#8b5cf6", "#3b82f6", "#10b981", "#f59e0b", "#ef4444", "#06b6d4", "#f97316"];
|
|
12
|
+
export declare const CONFETTI_SHAPES: readonly ["square", "circle", "triangle"];
|
|
13
|
+
export declare const CONFETTI_SIZE_RANGE: {
|
|
14
|
+
readonly min: 8;
|
|
15
|
+
readonly max: 14;
|
|
16
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const T = {
|
|
2
|
+
COUNT: 100,
|
|
3
|
+
DURATION: 3e3,
|
|
4
|
+
ORIGIN_X: 0.5,
|
|
5
|
+
ORIGIN_Y: 0.5,
|
|
6
|
+
SPREAD: 60,
|
|
7
|
+
VELOCITY: 30,
|
|
8
|
+
GRAVITY: 0.5,
|
|
9
|
+
AUTO_HIDE: !0
|
|
10
|
+
}, I = [
|
|
11
|
+
"#ec4899",
|
|
12
|
+
// Pink (Bear primary)
|
|
13
|
+
"#8b5cf6",
|
|
14
|
+
// Purple
|
|
15
|
+
"#3b82f6",
|
|
16
|
+
// Blue
|
|
17
|
+
"#10b981",
|
|
18
|
+
// Green
|
|
19
|
+
"#f59e0b",
|
|
20
|
+
// Amber
|
|
21
|
+
"#ef4444",
|
|
22
|
+
// Red
|
|
23
|
+
"#06b6d4",
|
|
24
|
+
// Cyan
|
|
25
|
+
"#f97316"
|
|
26
|
+
// Orange
|
|
27
|
+
], O = ["square", "circle", "triangle"], E = {
|
|
28
|
+
min: 8,
|
|
29
|
+
max: 14
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
I as CONFETTI_COLORS,
|
|
33
|
+
T as CONFETTI_DEFAULTS,
|
|
34
|
+
O as CONFETTI_SHAPES,
|
|
35
|
+
E as CONFETTI_SIZE_RANGE
|
|
36
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ConfettiProps } from './Confetti.types';
|
|
3
|
+
/**
|
|
4
|
+
* Confetti - Celebration confetti effect 🎉
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Basic usage
|
|
9
|
+
* const [showConfetti, setShowConfetti] = useState(false);
|
|
10
|
+
* <Confetti active={showConfetti} onComplete={() => setShowConfetti(false)} />
|
|
11
|
+
* <Button onClick={() => setShowConfetti(true)}>Celebrate!</Button>
|
|
12
|
+
*
|
|
13
|
+
* // Custom colors and position
|
|
14
|
+
* <Confetti
|
|
15
|
+
* active={true}
|
|
16
|
+
* colors={['#ff0000', '#00ff00', '#0000ff']}
|
|
17
|
+
* originX={0.5}
|
|
18
|
+
* originY={0.3}
|
|
19
|
+
* />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const Confetti: FC<ConfettiProps>;
|
|
23
|
+
export default Confetti;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useRef as N, useCallback as S, useEffect as C } from "react";
|
|
3
|
+
import { cn as D } from "../../utils/cn.js";
|
|
4
|
+
import { CONFETTI_DEFAULTS as a, CONFETTI_SHAPES as F, CONFETTI_COLORS as G, CONFETTI_SIZE_RANGE as f } from "./Confetti.const.js";
|
|
5
|
+
const k = ({
|
|
6
|
+
active: m = !1,
|
|
7
|
+
count: u = a.COUNT,
|
|
8
|
+
duration: c = a.DURATION,
|
|
9
|
+
colors: l = G,
|
|
10
|
+
originX: I = a.ORIGIN_X,
|
|
11
|
+
originY: x = a.ORIGIN_Y,
|
|
12
|
+
spread: y = a.SPREAD,
|
|
13
|
+
velocity: T = a.VELOCITY,
|
|
14
|
+
gravity: b = a.GRAVITY,
|
|
15
|
+
autoHide: M = a.AUTO_HIDE,
|
|
16
|
+
onComplete: o,
|
|
17
|
+
className: _,
|
|
18
|
+
testId: z
|
|
19
|
+
}) => {
|
|
20
|
+
const [R, d] = v([]), [P, E] = v(!1), n = N(), s = N(0), O = S(() => {
|
|
21
|
+
const t = [], i = y * Math.PI / 180;
|
|
22
|
+
for (let e = 0; e < u; e++) {
|
|
23
|
+
const r = -Math.PI / 2 + (Math.random() - 0.5) * i, A = T * (0.5 + Math.random() * 0.5);
|
|
24
|
+
t.push({
|
|
25
|
+
id: e,
|
|
26
|
+
x: I * 100,
|
|
27
|
+
y: x * 100,
|
|
28
|
+
rotation: Math.random() * 360,
|
|
29
|
+
color: l[Math.floor(Math.random() * l.length)],
|
|
30
|
+
size: f.min + Math.random() * (f.max - f.min),
|
|
31
|
+
velocity: {
|
|
32
|
+
x: Math.cos(r) * A,
|
|
33
|
+
y: Math.sin(r) * A
|
|
34
|
+
},
|
|
35
|
+
rotationSpeed: (Math.random() - 0.5) * 20,
|
|
36
|
+
shape: F[Math.floor(Math.random() * F.length)]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return t;
|
|
40
|
+
}, [u, l, I, x, y, T]), h = S((t) => {
|
|
41
|
+
if (s.current || (s.current = t), t - s.current >= c && M) {
|
|
42
|
+
E(!1), d([]), o == null || o();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
d(
|
|
46
|
+
(e) => e.map((r) => ({
|
|
47
|
+
...r,
|
|
48
|
+
x: r.x + r.velocity.x * 0.1,
|
|
49
|
+
y: r.y + r.velocity.y * 0.1,
|
|
50
|
+
rotation: r.rotation + r.rotationSpeed,
|
|
51
|
+
velocity: {
|
|
52
|
+
x: r.velocity.x * 0.99,
|
|
53
|
+
y: r.velocity.y + b
|
|
54
|
+
}
|
|
55
|
+
}))
|
|
56
|
+
), n.current = requestAnimationFrame(h);
|
|
57
|
+
}, [c, b, M, o]);
|
|
58
|
+
C(() => (m ? (E(!0), d(O()), s.current = 0, n.current = requestAnimationFrame(h)) : n.current && cancelAnimationFrame(n.current), () => {
|
|
59
|
+
n.current && cancelAnimationFrame(n.current);
|
|
60
|
+
}), [m, O, h]);
|
|
61
|
+
const $ = (t) => {
|
|
62
|
+
const i = {
|
|
63
|
+
position: "absolute",
|
|
64
|
+
left: `${t.x}%`,
|
|
65
|
+
top: `${t.y}%`,
|
|
66
|
+
width: t.size,
|
|
67
|
+
height: t.size,
|
|
68
|
+
transform: `rotate(${t.rotation}deg)`,
|
|
69
|
+
backgroundColor: t.shape !== "triangle" ? t.color : "transparent",
|
|
70
|
+
borderRadius: t.shape === "circle" ? "50%" : 0,
|
|
71
|
+
borderLeft: t.shape === "triangle" ? `${t.size / 2}px solid transparent` : void 0,
|
|
72
|
+
borderRight: t.shape === "triangle" ? `${t.size / 2}px solid transparent` : void 0,
|
|
73
|
+
borderBottom: t.shape === "triangle" ? `${t.size}px solid ${t.color}` : void 0,
|
|
74
|
+
opacity: 0.9
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ g("div", { style: i }, t.id);
|
|
77
|
+
};
|
|
78
|
+
return !P || R.length === 0 ? null : /* @__PURE__ */ g(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: D(
|
|
82
|
+
"Bear-Confetti",
|
|
83
|
+
"bear-fixed bear-inset-0 bear-pointer-events-none bear-overflow-hidden",
|
|
84
|
+
_
|
|
85
|
+
),
|
|
86
|
+
style: { zIndex: 99999 },
|
|
87
|
+
"data-testid": z,
|
|
88
|
+
children: R.map($)
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
k as Confetti
|
|
94
|
+
};
|