horizon-design 0.0.1
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/LICENSE +21 -0
- package/README.md +2444 -0
- package/dist/components/accordion/Accordion.svelte +36 -0
- package/dist/components/accordion/Accordion.svelte.d.ts +14 -0
- package/dist/components/accordion/AccordionItem.svelte +49 -0
- package/dist/components/accordion/AccordionItem.svelte.d.ts +11 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/action-bar/ActionBar.svelte +25 -0
- package/dist/components/action-bar/ActionBar.svelte.d.ts +9 -0
- package/dist/components/action-bar/ActionBarSeparator.svelte +18 -0
- package/dist/components/action-bar/ActionBarSeparator.svelte.d.ts +7 -0
- package/dist/components/action-bar/index.d.ts +2 -0
- package/dist/components/action-bar/index.js +2 -0
- package/dist/components/alert/Alert.svelte +78 -0
- package/dist/components/alert/Alert.svelte.d.ts +13 -0
- package/dist/components/alert/index.d.ts +1 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/alert-dialog/AlertDialog.svelte +89 -0
- package/dist/components/alert-dialog/AlertDialog.svelte.d.ts +16 -0
- package/dist/components/alert-dialog/index.d.ts +1 -0
- package/dist/components/alert-dialog/index.js +1 -0
- package/dist/components/angle-slider/AngleSlider.svelte +49 -0
- package/dist/components/angle-slider/AngleSlider.svelte.d.ts +12 -0
- package/dist/components/angle-slider/index.d.ts +1 -0
- package/dist/components/angle-slider/index.js +1 -0
- package/dist/components/announcement/Announcement.svelte +25 -0
- package/dist/components/announcement/Announcement.svelte.d.ts +9 -0
- package/dist/components/announcement/index.d.ts +1 -0
- package/dist/components/announcement/index.js +1 -0
- package/dist/components/aspect-ratio/AspectRatio.svelte +27 -0
- package/dist/components/aspect-ratio/AspectRatio.svelte.d.ts +10 -0
- package/dist/components/aspect-ratio/index.d.ts +1 -0
- package/dist/components/aspect-ratio/index.js +1 -0
- package/dist/components/avatar/Avatar.svelte +48 -0
- package/dist/components/avatar/Avatar.svelte.d.ts +12 -0
- package/dist/components/avatar/AvatarGroup.svelte +18 -0
- package/dist/components/avatar/AvatarGroup.svelte.d.ts +9 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/badge/Badge.svelte +42 -0
- package/dist/components/badge/Badge.svelte.d.ts +11 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/bottom-navigation/BottomNavigation.svelte +49 -0
- package/dist/components/bottom-navigation/BottomNavigation.svelte.d.ts +15 -0
- package/dist/components/bottom-navigation/index.d.ts +1 -0
- package/dist/components/bottom-navigation/index.js +1 -0
- package/dist/components/breadcrumb/Breadcrumb.svelte +49 -0
- package/dist/components/breadcrumb/Breadcrumb.svelte.d.ts +12 -0
- package/dist/components/breadcrumb/index.d.ts +1 -0
- package/dist/components/breadcrumb/index.js +1 -0
- package/dist/components/button/Button.svelte +94 -0
- package/dist/components/button/Button.svelte.d.ts +14 -0
- package/dist/components/button/button-variants.d.ts +33 -0
- package/dist/components/button/button-variants.js +31 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/button-group/ButtonGroup.svelte +34 -0
- package/dist/components/button-group/ButtonGroup.svelte.d.ts +10 -0
- package/dist/components/button-group/index.d.ts +1 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/calendar/Calendar.svelte +180 -0
- package/dist/components/calendar/Calendar.svelte.d.ts +9 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +1 -0
- package/dist/components/card/Card.svelte +52 -0
- package/dist/components/card/Card.svelte.d.ts +12 -0
- package/dist/components/card/index.d.ts +1 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/carousel/Carousel.svelte +67 -0
- package/dist/components/carousel/Carousel.svelte.d.ts +12 -0
- package/dist/components/carousel/index.d.ts +1 -0
- package/dist/components/carousel/index.js +1 -0
- package/dist/components/checkbox/Checkbox.svelte +64 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +13 -0
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/circular-progress/CircularProgress.svelte +82 -0
- package/dist/components/circular-progress/CircularProgress.svelte.d.ts +15 -0
- package/dist/components/circular-progress/index.d.ts +1 -0
- package/dist/components/circular-progress/index.js +1 -0
- package/dist/components/circular-slider/CircularSlider.svelte +115 -0
- package/dist/components/circular-slider/CircularSlider.svelte.d.ts +14 -0
- package/dist/components/circular-slider/circular-slider-context.d.ts +9 -0
- package/dist/components/circular-slider/circular-slider-context.js +8 -0
- package/dist/components/circular-slider/index.d.ts +1 -0
- package/dist/components/circular-slider/index.js +1 -0
- package/dist/components/clipboard/Clipboard.svelte +53 -0
- package/dist/components/clipboard/Clipboard.svelte.d.ts +10 -0
- package/dist/components/clipboard/index.d.ts +1 -0
- package/dist/components/clipboard/index.js +1 -0
- package/dist/components/collapsible/Collapsible.svelte +42 -0
- package/dist/components/collapsible/Collapsible.svelte.d.ts +12 -0
- package/dist/components/collapsible/index.d.ts +1 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/color-picker/ColorPicker.svelte +101 -0
- package/dist/components/color-picker/ColorPicker.svelte.d.ts +11 -0
- package/dist/components/color-picker/index.d.ts +1 -0
- package/dist/components/color-picker/index.js +1 -0
- package/dist/components/combobox/Combobox.svelte +73 -0
- package/dist/components/combobox/Combobox.svelte.d.ts +14 -0
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/combobox/index.js +1 -0
- package/dist/components/context-menu/ContextMenu.svelte +66 -0
- package/dist/components/context-menu/ContextMenu.svelte.d.ts +15 -0
- package/dist/components/context-menu/index.d.ts +1 -0
- package/dist/components/context-menu/index.js +1 -0
- package/dist/components/data-list/DataList.svelte +40 -0
- package/dist/components/data-list/DataList.svelte.d.ts +13 -0
- package/dist/components/data-list/index.d.ts +1 -0
- package/dist/components/data-list/index.js +1 -0
- package/dist/components/date-picker/DatePicker.svelte +173 -0
- package/dist/components/date-picker/DatePicker.svelte.d.ts +12 -0
- package/dist/components/date-picker/index.d.ts +1 -0
- package/dist/components/date-picker/index.js +1 -0
- package/dist/components/dialog/Dialog.svelte +93 -0
- package/dist/components/dialog/Dialog.svelte.d.ts +17 -0
- package/dist/components/dialog/DialogClose.svelte +44 -0
- package/dist/components/dialog/DialogClose.svelte.d.ts +9 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/drawer/Drawer.svelte +89 -0
- package/dist/components/drawer/Drawer.svelte.d.ts +17 -0
- package/dist/components/drawer/DrawerClose.svelte +16 -0
- package/dist/components/drawer/DrawerClose.svelte.d.ts +8 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/editable/Editable.svelte +44 -0
- package/dist/components/editable/Editable.svelte.d.ts +12 -0
- package/dist/components/editable/index.d.ts +1 -0
- package/dist/components/editable/index.js +1 -0
- package/dist/components/field/Field.svelte +44 -0
- package/dist/components/field/Field.svelte.d.ts +13 -0
- package/dist/components/field/index.d.ts +1 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/file-tree/FileTree.svelte +214 -0
- package/dist/components/file-tree/FileTree.svelte.d.ts +28 -0
- package/dist/components/file-tree/index.d.ts +3 -0
- package/dist/components/file-tree/index.js +2 -0
- package/dist/components/file-upload/FileUpload.svelte +50 -0
- package/dist/components/file-upload/FileUpload.svelte.d.ts +12 -0
- package/dist/components/file-upload/index.d.ts +1 -0
- package/dist/components/file-upload/index.js +1 -0
- package/dist/components/float/Float.svelte +32 -0
- package/dist/components/float/Float.svelte.d.ts +10 -0
- package/dist/components/float/index.d.ts +1 -0
- package/dist/components/float/index.js +1 -0
- package/dist/components/floating-panel/FloatingPanel.svelte +66 -0
- package/dist/components/floating-panel/FloatingPanel.svelte.d.ts +13 -0
- package/dist/components/floating-panel/index.d.ts +1 -0
- package/dist/components/floating-panel/index.js +1 -0
- package/dist/components/frame/Frame.svelte +41 -0
- package/dist/components/frame/Frame.svelte.d.ts +10 -0
- package/dist/components/frame/index.d.ts +1 -0
- package/dist/components/frame/index.js +1 -0
- package/dist/components/hierarchy-view/HierarchyView.svelte +763 -0
- package/dist/components/hierarchy-view/HierarchyView.svelte.d.ts +27 -0
- package/dist/components/hierarchy-view/index.d.ts +1 -0
- package/dist/components/hierarchy-view/index.js +1 -0
- package/dist/components/hint/Hint.svelte +18 -0
- package/dist/components/hint/Hint.svelte.d.ts +9 -0
- package/dist/components/hint/index.d.ts +1 -0
- package/dist/components/hint/index.js +1 -0
- package/dist/components/horizon-layout/HorizonLayout.svelte +78 -0
- package/dist/components/horizon-layout/HorizonLayout.svelte.d.ts +51 -0
- package/dist/components/horizon-layout/horizon-layout.css +425 -0
- package/dist/components/horizon-layout/index.d.ts +2 -0
- package/dist/components/horizon-layout/index.js +2 -0
- package/dist/components/hover-card/HoverCard.svelte +41 -0
- package/dist/components/hover-card/HoverCard.svelte.d.ts +12 -0
- package/dist/components/hover-card/index.d.ts +1 -0
- package/dist/components/hover-card/index.js +1 -0
- package/dist/components/image-cropper/ImageCropper.svelte +88 -0
- package/dist/components/image-cropper/ImageCropper.svelte.d.ts +11 -0
- package/dist/components/image-cropper/index.d.ts +1 -0
- package/dist/components/image-cropper/index.js +1 -0
- package/dist/components/input/Input.svelte +33 -0
- package/dist/components/input/Input.svelte.d.ts +9 -0
- package/dist/components/input/index.d.ts +1 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input-group/InputAddon.svelte +25 -0
- package/dist/components/input-group/InputAddon.svelte.d.ts +9 -0
- package/dist/components/input-group/InputGroup.svelte +25 -0
- package/dist/components/input-group/InputGroup.svelte.d.ts +9 -0
- package/dist/components/input-group/index.d.ts +2 -0
- package/dist/components/input-group/index.js +2 -0
- package/dist/components/item/Item.svelte +25 -0
- package/dist/components/item/Item.svelte.d.ts +9 -0
- package/dist/components/item/index.d.ts +1 -0
- package/dist/components/item/index.js +1 -0
- package/dist/components/kbd/Kbd.svelte +25 -0
- package/dist/components/kbd/Kbd.svelte.d.ts +9 -0
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/index.js +1 -0
- package/dist/components/link-overlay/LinkBox.svelte +18 -0
- package/dist/components/link-overlay/LinkBox.svelte.d.ts +9 -0
- package/dist/components/link-overlay/LinkOverlay.svelte +25 -0
- package/dist/components/link-overlay/LinkOverlay.svelte.d.ts +10 -0
- package/dist/components/link-overlay/index.d.ts +2 -0
- package/dist/components/link-overlay/index.js +2 -0
- package/dist/components/listbox/Listbox.svelte +62 -0
- package/dist/components/listbox/Listbox.svelte.d.ts +20 -0
- package/dist/components/listbox/index.d.ts +1 -0
- package/dist/components/listbox/index.js +1 -0
- package/dist/components/marquee/Marquee.svelte +30 -0
- package/dist/components/marquee/Marquee.svelte.d.ts +10 -0
- package/dist/components/marquee/MarqueeItem.svelte +18 -0
- package/dist/components/marquee/MarqueeItem.svelte.d.ts +9 -0
- package/dist/components/marquee/index.d.ts +2 -0
- package/dist/components/marquee/index.js +2 -0
- package/dist/components/menu/Menu.svelte +43 -0
- package/dist/components/menu/Menu.svelte.d.ts +13 -0
- package/dist/components/menu/MenuGroup.svelte +21 -0
- package/dist/components/menu/MenuGroup.svelte.d.ts +10 -0
- package/dist/components/menu/MenuGroupLabel.svelte +23 -0
- package/dist/components/menu/MenuGroupLabel.svelte.d.ts +9 -0
- package/dist/components/menu/MenuItem.svelte +29 -0
- package/dist/components/menu/MenuItem.svelte.d.ts +10 -0
- package/dist/components/menu/MenuSeparator.svelte +18 -0
- package/dist/components/menu/MenuSeparator.svelte.d.ts +7 -0
- package/dist/components/menu/index.d.ts +5 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/native-select/NativeSelect.svelte +31 -0
- package/dist/components/native-select/NativeSelect.svelte.d.ts +9 -0
- package/dist/components/native-select/index.d.ts +1 -0
- package/dist/components/native-select/index.js +1 -0
- package/dist/components/number-input/NumberInput.svelte +55 -0
- package/dist/components/number-input/NumberInput.svelte.d.ts +12 -0
- package/dist/components/number-input/index.d.ts +1 -0
- package/dist/components/number-input/index.js +1 -0
- package/dist/components/pagination/Pagination.svelte +63 -0
- package/dist/components/pagination/Pagination.svelte.d.ts +12 -0
- package/dist/components/pagination/PaginationContext.svelte +7 -0
- package/dist/components/pagination/PaginationContext.svelte.d.ts +4 -0
- package/dist/components/pagination/PaginationEllipsis.svelte +30 -0
- package/dist/components/pagination/PaginationEllipsis.svelte.d.ts +10 -0
- package/dist/components/pagination/PaginationItem.svelte +30 -0
- package/dist/components/pagination/PaginationItem.svelte.d.ts +10 -0
- package/dist/components/pagination/PaginationNextTrigger.svelte +26 -0
- package/dist/components/pagination/PaginationNextTrigger.svelte.d.ts +9 -0
- package/dist/components/pagination/PaginationPrevTrigger.svelte +26 -0
- package/dist/components/pagination/PaginationPrevTrigger.svelte.d.ts +9 -0
- package/dist/components/pagination/index.d.ts +6 -0
- package/dist/components/pagination/index.js +6 -0
- package/dist/components/pin-input/PinInput.svelte +45 -0
- package/dist/components/pin-input/PinInput.svelte.d.ts +13 -0
- package/dist/components/pin-input/index.d.ts +1 -0
- package/dist/components/pin-input/index.js +1 -0
- package/dist/components/popover/Popover.svelte +70 -0
- package/dist/components/popover/Popover.svelte.d.ts +16 -0
- package/dist/components/popover/PopoverClose.svelte +19 -0
- package/dist/components/popover/PopoverClose.svelte.d.ts +9 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/progress/Progress.svelte +37 -0
- package/dist/components/progress/Progress.svelte.d.ts +13 -0
- package/dist/components/progress/index.d.ts +1 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/prose/Prose.svelte +25 -0
- package/dist/components/prose/Prose.svelte.d.ts +9 -0
- package/dist/components/prose/index.d.ts +1 -0
- package/dist/components/prose/index.js +1 -0
- package/dist/components/qr-code/QrCode.svelte +25 -0
- package/dist/components/qr-code/QrCode.svelte.d.ts +10 -0
- package/dist/components/qr-code/index.d.ts +1 -0
- package/dist/components/qr-code/index.js +1 -0
- package/dist/components/radio-group/RadioGroup.svelte +81 -0
- package/dist/components/radio-group/RadioGroup.svelte.d.ts +19 -0
- package/dist/components/radio-group/index.d.ts +1 -0
- package/dist/components/radio-group/index.js +1 -0
- package/dist/components/rating-group/RatingGroup.svelte +41 -0
- package/dist/components/rating-group/RatingGroup.svelte.d.ts +10 -0
- package/dist/components/rating-group/index.d.ts +1 -0
- package/dist/components/rating-group/index.js +1 -0
- package/dist/components/scroll-area/ScrollArea.svelte +36 -0
- package/dist/components/scroll-area/ScrollArea.svelte.d.ts +10 -0
- package/dist/components/scroll-area/index.d.ts +1 -0
- package/dist/components/scroll-area/index.js +1 -0
- package/dist/components/segment-group/SegmentGroup.svelte +74 -0
- package/dist/components/segment-group/SegmentGroup.svelte.d.ts +16 -0
- package/dist/components/segment-group/index.d.ts +1 -0
- package/dist/components/segment-group/index.js +1 -0
- package/dist/components/select/Select.svelte +84 -0
- package/dist/components/select/Select.svelte.d.ts +18 -0
- package/dist/components/select/index.d.ts +1 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/separator/Separator.svelte +27 -0
- package/dist/components/separator/Separator.svelte.d.ts +9 -0
- package/dist/components/separator/index.d.ts +1 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/sheet/Sheet.svelte +98 -0
- package/dist/components/sheet/Sheet.svelte.d.ts +17 -0
- package/dist/components/sheet/index.d.ts +1 -0
- package/dist/components/sheet/index.js +1 -0
- package/dist/components/sidebar/Sidebar.svelte +45 -0
- package/dist/components/sidebar/Sidebar.svelte.d.ts +12 -0
- package/dist/components/sidebar/SidebarItem.svelte +44 -0
- package/dist/components/sidebar/SidebarItem.svelte.d.ts +11 -0
- package/dist/components/sidebar/SidebarSection.svelte +25 -0
- package/dist/components/sidebar/SidebarSection.svelte.d.ts +10 -0
- package/dist/components/sidebar/index.d.ts +3 -0
- package/dist/components/sidebar/index.js +3 -0
- package/dist/components/signature-pad/SignaturePad.svelte +44 -0
- package/dist/components/signature-pad/SignaturePad.svelte.d.ts +11 -0
- package/dist/components/signature-pad/index.d.ts +1 -0
- package/dist/components/signature-pad/index.js +1 -0
- package/dist/components/skeleton/Skeleton.svelte +17 -0
- package/dist/components/skeleton/Skeleton.svelte.d.ts +7 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skip-nav/SkipNav.svelte +28 -0
- package/dist/components/skip-nav/SkipNav.svelte.d.ts +10 -0
- package/dist/components/skip-nav/index.d.ts +1 -0
- package/dist/components/skip-nav/index.js +1 -0
- package/dist/components/slider/Slider.svelte +55 -0
- package/dist/components/slider/Slider.svelte.d.ts +13 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/spinner/Spinner.svelte +31 -0
- package/dist/components/spinner/Spinner.svelte.d.ts +9 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/splitter/Splitter.svelte +29 -0
- package/dist/components/splitter/Splitter.svelte.d.ts +11 -0
- package/dist/components/splitter/SplitterPanel.svelte +21 -0
- package/dist/components/splitter/SplitterPanel.svelte.d.ts +10 -0
- package/dist/components/splitter/SplitterResizeTrigger.svelte +24 -0
- package/dist/components/splitter/SplitterResizeTrigger.svelte.d.ts +8 -0
- package/dist/components/splitter/index.d.ts +3 -0
- package/dist/components/splitter/index.js +3 -0
- package/dist/components/status/Status.svelte +28 -0
- package/dist/components/status/Status.svelte.d.ts +8 -0
- package/dist/components/status/index.d.ts +1 -0
- package/dist/components/status/index.js +1 -0
- package/dist/components/steps/Steps.svelte +90 -0
- package/dist/components/steps/Steps.svelte.d.ts +18 -0
- package/dist/components/steps/index.d.ts +1 -0
- package/dist/components/steps/index.js +1 -0
- package/dist/components/swap/Swap.svelte +32 -0
- package/dist/components/swap/Swap.svelte.d.ts +14 -0
- package/dist/components/swap/index.d.ts +1 -0
- package/dist/components/swap/index.js +1 -0
- package/dist/components/switch/Switch.svelte +130 -0
- package/dist/components/switch/Switch.svelte.d.ts +16 -0
- package/dist/components/switch/index.d.ts +1 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/table/Table.svelte +69 -0
- package/dist/components/table/Table.svelte.d.ts +18 -0
- package/dist/components/table/TableBody.svelte +18 -0
- package/dist/components/table/TableBody.svelte.d.ts +9 -0
- package/dist/components/table/TableCell.svelte +25 -0
- package/dist/components/table/TableCell.svelte.d.ts +9 -0
- package/dist/components/table/TableHead.svelte +25 -0
- package/dist/components/table/TableHead.svelte.d.ts +9 -0
- package/dist/components/table/TableHeader.svelte +22 -0
- package/dist/components/table/TableHeader.svelte.d.ts +9 -0
- package/dist/components/table/TableRow.svelte +25 -0
- package/dist/components/table/TableRow.svelte.d.ts +9 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/tabs/Tabs.svelte +111 -0
- package/dist/components/tabs/Tabs.svelte.d.ts +19 -0
- package/dist/components/tabs/index.d.ts +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/textarea/Textarea.svelte +21 -0
- package/dist/components/textarea/Textarea.svelte.d.ts +7 -0
- package/dist/components/textarea/index.d.ts +1 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/theme-switch/ThemeSwitch.svelte +125 -0
- package/dist/components/theme-switch/ThemeSwitch.svelte.d.ts +7 -0
- package/dist/components/theme-switch/index.d.ts +1 -0
- package/dist/components/theme-switch/index.js +1 -0
- package/dist/components/thumb-card/ThumbCard.svelte +42 -0
- package/dist/components/thumb-card/ThumbCard.svelte.d.ts +11 -0
- package/dist/components/thumb-card/index.d.ts +1 -0
- package/dist/components/thumb-card/index.js +1 -0
- package/dist/components/timer/Timer.svelte +61 -0
- package/dist/components/timer/Timer.svelte.d.ts +11 -0
- package/dist/components/timer/index.d.ts +1 -0
- package/dist/components/timer/index.js +1 -0
- package/dist/components/toast/Toast.svelte +61 -0
- package/dist/components/toast/Toast.svelte.d.ts +13 -0
- package/dist/components/toast/Toaster.svelte +29 -0
- package/dist/components/toast/Toaster.svelte.d.ts +9 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toggle/Toggle.svelte +45 -0
- package/dist/components/toggle/Toggle.svelte.d.ts +13 -0
- package/dist/components/toggle/index.d.ts +1 -0
- package/dist/components/toggle/index.js +1 -0
- package/dist/components/toggle-group/ToggleGroup.svelte +43 -0
- package/dist/components/toggle-group/ToggleGroup.svelte.d.ts +15 -0
- package/dist/components/toggle-group/index.d.ts +1 -0
- package/dist/components/toggle-group/index.js +1 -0
- package/dist/components/toggle-tooltip/ToggleTooltip.svelte +40 -0
- package/dist/components/toggle-tooltip/ToggleTooltip.svelte.d.ts +11 -0
- package/dist/components/toggle-tooltip/index.d.ts +1 -0
- package/dist/components/toggle-tooltip/index.js +1 -0
- package/dist/components/tooltip/Tooltip.svelte +47 -0
- package/dist/components/tooltip/Tooltip.svelte.d.ts +14 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tour/Tour.svelte +126 -0
- package/dist/components/tour/Tour.svelte.d.ts +14 -0
- package/dist/components/tour/index.d.ts +1 -0
- package/dist/components/tour/index.js +1 -0
- package/dist/fonts/EncodeSans.woff2 +0 -0
- package/dist/fonts/Lilex.woff2 +0 -0
- package/dist/horizon-design.css +716 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +91 -0
- package/dist/monaco-theme.d.ts +12 -0
- package/dist/monaco-theme.js +153 -0
- package/dist/theme.svelte.d.ts +12 -0
- package/dist/theme.svelte.js +52 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +5 -0
- package/package.json +76 -0
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { cn } from '../../utils';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import MingcuteRightLine from '~icons/mingcute/right-line';
|
|
6
|
+
import MingcuteFileLine from '~icons/mingcute/file-line';
|
|
7
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
8
|
+
|
|
9
|
+
type AnyNode = {
|
|
10
|
+
id?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
children?: AnyNode[];
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
type DropTarget = { value: string; position: 'before' | 'inside' | 'after' } | null;
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
class: className = '',
|
|
20
|
+
data,
|
|
21
|
+
nodeToValue = (n: AnyNode) => (n.id ?? n.name ?? '') as string,
|
|
22
|
+
nodeToString = (n: AnyNode) => (n.name ?? n.label ?? '') as string,
|
|
23
|
+
icon,
|
|
24
|
+
selectedValue = $bindable<string[]>([]),
|
|
25
|
+
expandedValue = $bindable<string[]>([]),
|
|
26
|
+
onSelectionChange,
|
|
27
|
+
onExpandedChange,
|
|
28
|
+
onDataChange
|
|
29
|
+
}: {
|
|
30
|
+
class?: string;
|
|
31
|
+
data: AnyNode[];
|
|
32
|
+
nodeToValue?: (node: AnyNode) => string;
|
|
33
|
+
nodeToString?: (node: AnyNode) => string;
|
|
34
|
+
icon?: Snippet<[AnyNode]>;
|
|
35
|
+
selectedValue?: string[];
|
|
36
|
+
expandedValue?: string[];
|
|
37
|
+
onSelectionChange?: (details: { selectedValue: string[] }) => void;
|
|
38
|
+
onExpandedChange?: (details: { expandedValue: string[] }) => void;
|
|
39
|
+
onDataChange?: (data: AnyNode[]) => void;
|
|
40
|
+
} = $props();
|
|
41
|
+
|
|
42
|
+
let treeData = $state<AnyNode>(untrack(() => ({ children: structuredClone(data) })));
|
|
43
|
+
let pivot = $state<string | null>(null);
|
|
44
|
+
let containerEl = $state<HTMLElement | null>(null);
|
|
45
|
+
|
|
46
|
+
let isDragging = $state(false);
|
|
47
|
+
let dragValues = $state<string[]>([]);
|
|
48
|
+
let ghostPos = $state({ x: 0, y: 0 });
|
|
49
|
+
let dropTarget = $state<DropTarget>(null);
|
|
50
|
+
let justFinishedDrag = false;
|
|
51
|
+
let longPressTimer: ReturnType<typeof setTimeout> | null = null;
|
|
52
|
+
let pressStart: { x: number; y: number } | null = null;
|
|
53
|
+
let isOverInvalidTarget = false;
|
|
54
|
+
|
|
55
|
+
let renamingValue = $state<string | null>(null);
|
|
56
|
+
let renameText = $state('');
|
|
57
|
+
let renameInputEl = $state<HTMLInputElement | null>(null);
|
|
58
|
+
|
|
59
|
+
let cursorValue = $state<string | null>(null);
|
|
60
|
+
let isKeyboardMode = $state(false);
|
|
61
|
+
let justMovedValue = $state<string | null>(null);
|
|
62
|
+
let justMovedTimer: ReturnType<typeof setTimeout> | null = null;
|
|
63
|
+
|
|
64
|
+
function portal(node: HTMLElement) {
|
|
65
|
+
document.body.appendChild(node);
|
|
66
|
+
return {
|
|
67
|
+
destroy() {
|
|
68
|
+
node.remove();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getValue(node: AnyNode): string {
|
|
74
|
+
return nodeToValue(node);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function findNodes(root: AnyNode, values: Set<string>, found: AnyNode[] = []): AnyNode[] {
|
|
78
|
+
if (values.has(getValue(root))) found.push(root);
|
|
79
|
+
for (const c of root.children ?? []) findNodes(c, values, found);
|
|
80
|
+
return found;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function findNodeLabel(value: string): string {
|
|
84
|
+
function find(node: AnyNode): string | null {
|
|
85
|
+
if (getValue(node) === value) return nodeToString(node);
|
|
86
|
+
for (const c of node.children ?? []) {
|
|
87
|
+
const r = find(c);
|
|
88
|
+
if (r !== null) return r;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return find(treeData) ?? value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function removeNodes(node: AnyNode, vals: Set<string>): AnyNode {
|
|
96
|
+
return {
|
|
97
|
+
...node,
|
|
98
|
+
children: (node.children ?? [])
|
|
99
|
+
.filter((c) => !vals.has(getValue(c)))
|
|
100
|
+
.map((c) => removeNodes(c, vals))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function insertAt(
|
|
105
|
+
root: AnyNode,
|
|
106
|
+
targetValue: string,
|
|
107
|
+
nodesToInsert: AnyNode[],
|
|
108
|
+
position: 'before' | 'inside' | 'after'
|
|
109
|
+
): AnyNode {
|
|
110
|
+
if (position === 'inside' && getValue(root) === targetValue) {
|
|
111
|
+
return { ...root, children: [...(root.children ?? []), ...nodesToInsert] };
|
|
112
|
+
}
|
|
113
|
+
if (!root.children?.length) return root;
|
|
114
|
+
const newChildren: AnyNode[] = [];
|
|
115
|
+
for (const child of root.children) {
|
|
116
|
+
const cv = getValue(child);
|
|
117
|
+
if (position === 'before' && cv === targetValue) newChildren.push(...nodesToInsert);
|
|
118
|
+
newChildren.push(insertAt(child, targetValue, nodesToInsert, position));
|
|
119
|
+
if (position === 'after' && cv === targetValue) newChildren.push(...nodesToInsert);
|
|
120
|
+
}
|
|
121
|
+
return { ...root, children: newChildren };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function isDescendantOrSelf(root: AnyNode, ancestorValue: string, targetValue: string): boolean {
|
|
125
|
+
function search(node: AnyNode, inSubtree: boolean): boolean {
|
|
126
|
+
const v = getValue(node);
|
|
127
|
+
const entering = inSubtree || v === ancestorValue;
|
|
128
|
+
if (entering && v === targetValue) return true;
|
|
129
|
+
return (node.children ?? []).some((c) => search(c, entering));
|
|
130
|
+
}
|
|
131
|
+
return search(root, false);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function renameNodeInTree(root: AnyNode, targetValue: string, newName: string): AnyNode {
|
|
135
|
+
if (getValue(root) === targetValue) {
|
|
136
|
+
const updated = { ...root };
|
|
137
|
+
if ('name' in root) updated.name = newName;
|
|
138
|
+
if ('label' in root) updated.label = newName;
|
|
139
|
+
return updated;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...root,
|
|
143
|
+
children: root.children?.map((c) => renameNodeInTree(c, targetValue, newName))
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function collectSubtreeValues(root: AnyNode, targetValue: string): Set<string> {
|
|
148
|
+
const result = new SvelteSet<string>();
|
|
149
|
+
function collect(node: AnyNode, inSubtree: boolean) {
|
|
150
|
+
const v = getValue(node);
|
|
151
|
+
const entering = inSubtree || v === targetValue;
|
|
152
|
+
if (entering) result.add(v);
|
|
153
|
+
for (const c of node.children ?? []) collect(c, entering);
|
|
154
|
+
}
|
|
155
|
+
collect(root, false);
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function findParentAndIndex(
|
|
160
|
+
root: AnyNode,
|
|
161
|
+
targetValue: string
|
|
162
|
+
): { parent: AnyNode; index: number } | null {
|
|
163
|
+
for (let i = 0; i < (root.children?.length ?? 0); i++) {
|
|
164
|
+
if (getValue(root.children![i]) === targetValue) return { parent: root, index: i };
|
|
165
|
+
const found = findParentAndIndex(root.children![i], targetValue);
|
|
166
|
+
if (found) return found;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function replaceChildren(root: AnyNode, parentValue: string, newChildren: AnyNode[]): AnyNode {
|
|
172
|
+
if (getValue(root) === parentValue) return { ...root, children: newChildren };
|
|
173
|
+
if (!root.children?.length) return root;
|
|
174
|
+
return {
|
|
175
|
+
...root,
|
|
176
|
+
children: root.children.map((c) => replaceChildren(c, parentValue, newChildren))
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function findNode(root: AnyNode, targetValue: string): AnyNode | null {
|
|
181
|
+
if (getValue(root) === targetValue) return root;
|
|
182
|
+
for (const c of root.children ?? []) {
|
|
183
|
+
const found = findNode(c, targetValue);
|
|
184
|
+
if (found) return found;
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function findParent(root: AnyNode, targetValue: string): AnyNode | null {
|
|
190
|
+
for (const c of root.children ?? []) {
|
|
191
|
+
if (getValue(c) === targetValue) return root;
|
|
192
|
+
const found = findParent(c, targetValue);
|
|
193
|
+
if (found) return found;
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function getVisibleValues(): string[] {
|
|
199
|
+
const result: string[] = [];
|
|
200
|
+
function traverse(nodes: AnyNode[]) {
|
|
201
|
+
for (const node of nodes) {
|
|
202
|
+
const value = getValue(node);
|
|
203
|
+
result.push(value);
|
|
204
|
+
if (node.children?.length && expandedValue.includes(value)) traverse(node.children);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
traverse((treeData.children ?? []) as AnyNode[]);
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function moveCursor(value: string) {
|
|
212
|
+
cursorValue = value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function flashMoved(value: string) {
|
|
216
|
+
if (justMovedTimer) clearTimeout(justMovedTimer);
|
|
217
|
+
justMovedValue = value;
|
|
218
|
+
justMovedTimer = setTimeout(() => {
|
|
219
|
+
justMovedValue = null;
|
|
220
|
+
}, 350);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function moveNodeUp(targetValue: string) {
|
|
224
|
+
const info = findParentAndIndex(treeData, targetValue);
|
|
225
|
+
if (!info || info.index === 0) return;
|
|
226
|
+
const siblings = [...info.parent.children!];
|
|
227
|
+
[siblings[info.index - 1], siblings[info.index]] = [
|
|
228
|
+
siblings[info.index],
|
|
229
|
+
siblings[info.index - 1]
|
|
230
|
+
];
|
|
231
|
+
treeData = replaceChildren(treeData, getValue(info.parent), siblings);
|
|
232
|
+
onDataChange?.(treeData.children ?? []);
|
|
233
|
+
flashMoved(targetValue);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function moveNodeDown(targetValue: string) {
|
|
237
|
+
const info = findParentAndIndex(treeData, targetValue);
|
|
238
|
+
if (!info || info.index >= (info.parent.children?.length ?? 0) - 1) return;
|
|
239
|
+
const siblings = [...info.parent.children!];
|
|
240
|
+
[siblings[info.index], siblings[info.index + 1]] = [
|
|
241
|
+
siblings[info.index + 1],
|
|
242
|
+
siblings[info.index]
|
|
243
|
+
];
|
|
244
|
+
treeData = replaceChildren(treeData, getValue(info.parent), siblings);
|
|
245
|
+
onDataChange?.(treeData.children ?? []);
|
|
246
|
+
flashMoved(targetValue);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function indentNode(targetValue: string) {
|
|
250
|
+
const info = findParentAndIndex(treeData, targetValue);
|
|
251
|
+
if (!info || info.index === 0) return;
|
|
252
|
+
|
|
253
|
+
const node = info.parent.children![info.index];
|
|
254
|
+
const prevSibling = info.parent.children![info.index - 1];
|
|
255
|
+
|
|
256
|
+
const newParentChildren = info.parent.children!.filter((_, i) => i !== info.index);
|
|
257
|
+
|
|
258
|
+
newParentChildren[info.index - 1] = {
|
|
259
|
+
...prevSibling,
|
|
260
|
+
children: [...(prevSibling.children ?? []), node]
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
treeData = replaceChildren(treeData, getValue(info.parent), newParentChildren);
|
|
264
|
+
|
|
265
|
+
if (!expandedValue.includes(getValue(prevSibling))) {
|
|
266
|
+
expandedValue = [...expandedValue, getValue(prevSibling)];
|
|
267
|
+
onExpandedChange?.({ expandedValue });
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
onDataChange?.(treeData.children ?? []);
|
|
271
|
+
flashMoved(targetValue);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function outdentNode(targetValue: string) {
|
|
275
|
+
const info = findParentAndIndex(treeData, targetValue);
|
|
276
|
+
if (!info || getValue(info.parent) === getValue(treeData)) return;
|
|
277
|
+
|
|
278
|
+
const grandInfo = findParentAndIndex(treeData, getValue(info.parent));
|
|
279
|
+
if (!grandInfo) return;
|
|
280
|
+
|
|
281
|
+
const node = info.parent.children![info.index];
|
|
282
|
+
|
|
283
|
+
const newParentChildren = info.parent.children!.filter((_, i) => i !== info.index);
|
|
284
|
+
|
|
285
|
+
const newGrandChildren = [...grandInfo.parent.children!];
|
|
286
|
+
|
|
287
|
+
newGrandChildren[grandInfo.index] = {
|
|
288
|
+
...info.parent,
|
|
289
|
+
children: newParentChildren
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
newGrandChildren.splice(grandInfo.index + 1, 0, node);
|
|
293
|
+
|
|
294
|
+
treeData = replaceChildren(treeData, getValue(grandInfo.parent), newGrandChildren);
|
|
295
|
+
|
|
296
|
+
onDataChange?.(treeData.children ?? []);
|
|
297
|
+
flashMoved(targetValue);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function toggleExpand(value: string) {
|
|
301
|
+
const next = expandedValue.includes(value)
|
|
302
|
+
? expandedValue.filter((v) => v !== value)
|
|
303
|
+
: [...expandedValue, value];
|
|
304
|
+
expandedValue = next;
|
|
305
|
+
onExpandedChange?.({ expandedValue: next });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
309
|
+
if (e.target instanceof HTMLInputElement) return;
|
|
310
|
+
isKeyboardMode = true;
|
|
311
|
+
|
|
312
|
+
if (e.shiftKey && cursorValue) {
|
|
313
|
+
if (e.key === 'ArrowUp') {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
moveNodeUp(cursorValue);
|
|
316
|
+
return;
|
|
317
|
+
} else if (e.key === 'ArrowDown') {
|
|
318
|
+
e.preventDefault();
|
|
319
|
+
moveNodeDown(cursorValue);
|
|
320
|
+
return;
|
|
321
|
+
} else if (e.key === 'ArrowLeft') {
|
|
322
|
+
e.preventDefault();
|
|
323
|
+
outdentNode(cursorValue);
|
|
324
|
+
return;
|
|
325
|
+
} else if (e.key === 'ArrowRight') {
|
|
326
|
+
e.preventDefault();
|
|
327
|
+
indentNode(cursorValue);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const visible = getVisibleValues();
|
|
333
|
+
if (visible.length === 0) return;
|
|
334
|
+
const idx = cursorValue ? visible.indexOf(cursorValue) : -1;
|
|
335
|
+
|
|
336
|
+
if (e.key === 'ArrowDown') {
|
|
337
|
+
e.preventDefault();
|
|
338
|
+
moveCursor(idx < visible.length - 1 ? visible[idx + 1] : visible[0]);
|
|
339
|
+
} else if (e.key === 'ArrowUp') {
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
moveCursor(idx > 0 ? visible[idx - 1] : visible[visible.length - 1]);
|
|
342
|
+
} else if (e.key === 'ArrowRight') {
|
|
343
|
+
if (!cursorValue) return;
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
const node = findNode(treeData, cursorValue);
|
|
346
|
+
if (!node) return;
|
|
347
|
+
const hasBranch = (node.children?.length ?? 0) > 0;
|
|
348
|
+
if (hasBranch && !expandedValue.includes(cursorValue)) {
|
|
349
|
+
toggleExpand(cursorValue);
|
|
350
|
+
} else if (hasBranch && expandedValue.includes(cursorValue)) {
|
|
351
|
+
moveCursor(getValue(node.children![0]));
|
|
352
|
+
}
|
|
353
|
+
} else if (e.key === 'ArrowLeft') {
|
|
354
|
+
if (!cursorValue) return;
|
|
355
|
+
e.preventDefault();
|
|
356
|
+
if (expandedValue.includes(cursorValue)) {
|
|
357
|
+
toggleExpand(cursorValue);
|
|
358
|
+
} else {
|
|
359
|
+
const parent = findParent(treeData, cursorValue);
|
|
360
|
+
if (parent && getValue(parent) !== getValue(treeData)) {
|
|
361
|
+
moveCursor(getValue(parent));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
} else if (e.key === 'Home') {
|
|
365
|
+
e.preventDefault();
|
|
366
|
+
moveCursor(visible[0]);
|
|
367
|
+
} else if (e.key === 'End') {
|
|
368
|
+
e.preventDefault();
|
|
369
|
+
moveCursor(visible[visible.length - 1]);
|
|
370
|
+
} else if (e.key === 'Enter' || e.key === ' ') {
|
|
371
|
+
if (!cursorValue) return;
|
|
372
|
+
e.preventDefault();
|
|
373
|
+
const isSelected = selectedValue.includes(cursorValue);
|
|
374
|
+
if (isSelected) {
|
|
375
|
+
const next = selectedValue.filter((v) => v !== cursorValue);
|
|
376
|
+
selectedValue = next;
|
|
377
|
+
if (next.length === 0) pivot = null;
|
|
378
|
+
onSelectionChange?.({ selectedValue: next });
|
|
379
|
+
} else {
|
|
380
|
+
selectedValue = [...selectedValue, cursorValue];
|
|
381
|
+
pivot = cursorValue;
|
|
382
|
+
onSelectionChange?.({ selectedValue });
|
|
383
|
+
}
|
|
384
|
+
} else if (e.key === 'F2') {
|
|
385
|
+
if (!cursorValue) return;
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
renamingValue = cursorValue;
|
|
388
|
+
renameText = findNodeLabel(cursorValue);
|
|
389
|
+
} else if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
390
|
+
if (!cursorValue) return;
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
const deleted = collectSubtreeValues(treeData, cursorValue);
|
|
393
|
+
const before = visible.slice(0, idx).filter((v) => !deleted.has(v));
|
|
394
|
+
const after = visible.slice(idx + 1).filter((v) => !deleted.has(v));
|
|
395
|
+
cursorValue = after[0] ?? before[before.length - 1] ?? null;
|
|
396
|
+
treeData = removeNodes(treeData, deleted);
|
|
397
|
+
selectedValue = selectedValue.filter((v) => !deleted.has(v));
|
|
398
|
+
pivot = pivot && !deleted.has(pivot) ? pivot : null;
|
|
399
|
+
onSelectionChange?.({ selectedValue });
|
|
400
|
+
onDataChange?.(treeData.children ?? []);
|
|
401
|
+
} else if (e.key === 'Escape') {
|
|
402
|
+
selectedValue = [];
|
|
403
|
+
pivot = null;
|
|
404
|
+
cursorValue = null;
|
|
405
|
+
onSelectionChange?.({ selectedValue: [] });
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function handlePointerDown(e: PointerEvent) {
|
|
410
|
+
isKeyboardMode = false;
|
|
411
|
+
const target = e.target as Element;
|
|
412
|
+
if (target.closest('input') || target.closest('[data-part="trigger"]')) return;
|
|
413
|
+
const rowEl = target.closest('[data-part="row"]') as HTMLElement | null;
|
|
414
|
+
if (!rowEl) return;
|
|
415
|
+
const value = rowEl.getAttribute('data-value');
|
|
416
|
+
if (!value) return;
|
|
417
|
+
|
|
418
|
+
pressStart = { x: e.clientX, y: e.clientY };
|
|
419
|
+
|
|
420
|
+
longPressTimer = setTimeout(() => {
|
|
421
|
+
if (!pressStart) return;
|
|
422
|
+
const valuesToDrag = selectedValue.includes(value) ? [...selectedValue] : [value];
|
|
423
|
+
isDragging = true;
|
|
424
|
+
dragValues = valuesToDrag;
|
|
425
|
+
ghostPos = { x: e.clientX + 14, y: e.clientY - 12 };
|
|
426
|
+
window.addEventListener('mousemove', onDragMove);
|
|
427
|
+
window.addEventListener('mouseup', onDragEnd);
|
|
428
|
+
window.addEventListener('pointercancel', onDragEnd);
|
|
429
|
+
}, 320);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function cancelPress() {
|
|
433
|
+
if (longPressTimer) {
|
|
434
|
+
clearTimeout(longPressTimer);
|
|
435
|
+
longPressTimer = null;
|
|
436
|
+
}
|
|
437
|
+
pressStart = null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function onDragMove(e: MouseEvent) {
|
|
441
|
+
if (e.buttons === 0) {
|
|
442
|
+
onDragEnd();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
ghostPos = { x: e.clientX + 14, y: e.clientY - 12 };
|
|
446
|
+
computeDropTarget(e.clientX, e.clientY);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function computeDropTarget(x: number, y: number) {
|
|
450
|
+
const ghostEl = document.querySelector('[data-drag-ghost]') as HTMLElement | null;
|
|
451
|
+
if (ghostEl) ghostEl.style.pointerEvents = 'none';
|
|
452
|
+
const els = document.elementsFromPoint(x, y);
|
|
453
|
+
if (ghostEl) ghostEl.style.pointerEvents = '';
|
|
454
|
+
|
|
455
|
+
let found: DropTarget = null;
|
|
456
|
+
isOverInvalidTarget = false;
|
|
457
|
+
for (const el of els) {
|
|
458
|
+
const rowEl = el.closest('[data-part="row"]') as HTMLElement | null;
|
|
459
|
+
if (!rowEl) continue;
|
|
460
|
+
const value = rowEl.getAttribute('data-value');
|
|
461
|
+
if (!value || dragValues.includes(value)) continue;
|
|
462
|
+
if (dragValues.some((dv) => isDescendantOrSelf(treeData, dv, value))) {
|
|
463
|
+
isOverInvalidTarget = true;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
const rect = rowEl.getBoundingClientRect();
|
|
467
|
+
const relY = (y - rect.top) / rect.height;
|
|
468
|
+
found = {
|
|
469
|
+
value,
|
|
470
|
+
position: relY < 0.25 ? 'before' : relY > 0.75 ? 'after' : 'inside'
|
|
471
|
+
};
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
dropTarget = found;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function onDragEnd() {
|
|
478
|
+
window.removeEventListener('mousemove', onDragMove);
|
|
479
|
+
window.removeEventListener('mouseup', onDragEnd);
|
|
480
|
+
window.removeEventListener('pointercancel', onDragEnd);
|
|
481
|
+
if (dropTarget) {
|
|
482
|
+
executeDrop(dropTarget);
|
|
483
|
+
} else if (!isOverInvalidTarget) {
|
|
484
|
+
const vals = new Set(dragValues);
|
|
485
|
+
const nodesToInsert = findNodes(treeData, vals);
|
|
486
|
+
const newTree = removeNodes(treeData, vals);
|
|
487
|
+
treeData = { ...newTree, children: [...(newTree.children ?? []), ...nodesToInsert] };
|
|
488
|
+
onDataChange?.(treeData.children ?? []);
|
|
489
|
+
}
|
|
490
|
+
isDragging = false;
|
|
491
|
+
dragValues = [];
|
|
492
|
+
dropTarget = null;
|
|
493
|
+
pressStart = null;
|
|
494
|
+
justFinishedDrag = true;
|
|
495
|
+
setTimeout(() => {
|
|
496
|
+
justFinishedDrag = false;
|
|
497
|
+
}, 60);
|
|
498
|
+
selectedValue = [];
|
|
499
|
+
pivot = null;
|
|
500
|
+
cursorValue = null;
|
|
501
|
+
onSelectionChange?.({ selectedValue: [] });
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
function executeDrop(target: NonNullable<DropTarget>) {
|
|
505
|
+
const vals = new Set(dragValues);
|
|
506
|
+
const nodesToInsert = findNodes(treeData, vals);
|
|
507
|
+
let newTree = removeNodes(treeData, vals);
|
|
508
|
+
newTree = insertAt(newTree, target.value, nodesToInsert, target.position);
|
|
509
|
+
treeData = newTree;
|
|
510
|
+
onDataChange?.(treeData.children ?? []);
|
|
511
|
+
if (target.position === 'inside' && !expandedValue.includes(target.value)) {
|
|
512
|
+
expandedValue = [...expandedValue, target.value];
|
|
513
|
+
onExpandedChange?.({ expandedValue });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function handleClick(e: MouseEvent) {
|
|
518
|
+
if (isDragging || justFinishedDrag) return;
|
|
519
|
+
const target = e.target as Element;
|
|
520
|
+
if (target.closest('[data-part="trigger"]') || target.closest('input')) return;
|
|
521
|
+
const rowEl = target.closest('[data-part="row"]');
|
|
522
|
+
if (!rowEl) {
|
|
523
|
+
selectedValue = [];
|
|
524
|
+
pivot = null;
|
|
525
|
+
cursorValue = null;
|
|
526
|
+
onSelectionChange?.({ selectedValue: [] });
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const value = rowEl.getAttribute('data-value');
|
|
530
|
+
if (!value) return;
|
|
531
|
+
e.stopPropagation();
|
|
532
|
+
cursorValue = value;
|
|
533
|
+
const isSelected = selectedValue.includes(value);
|
|
534
|
+
if (isSelected && !e.shiftKey) {
|
|
535
|
+
const next = selectedValue.filter((v) => v !== value);
|
|
536
|
+
selectedValue = next;
|
|
537
|
+
if (next.length === 0) pivot = null;
|
|
538
|
+
onSelectionChange?.({ selectedValue: next });
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
if (e.shiftKey && pivot) {
|
|
542
|
+
const visible = getVisibleValues();
|
|
543
|
+
const pivotIdx = visible.indexOf(pivot);
|
|
544
|
+
const currIdx = visible.indexOf(value);
|
|
545
|
+
if (pivotIdx !== -1 && currIdx !== -1) {
|
|
546
|
+
const [start, end] = pivotIdx < currIdx ? [pivotIdx, currIdx] : [currIdx, pivotIdx];
|
|
547
|
+
selectedValue = visible.slice(start, end + 1);
|
|
548
|
+
onSelectionChange?.({ selectedValue });
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
selectedValue = [...selectedValue, value];
|
|
553
|
+
pivot = value;
|
|
554
|
+
onSelectionChange?.({ selectedValue });
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function handleDblClick(e: MouseEvent) {
|
|
558
|
+
if (isDragging) return;
|
|
559
|
+
const target = e.target as Element;
|
|
560
|
+
if (target.closest('[data-part="trigger"]') || target.closest('input')) return;
|
|
561
|
+
const rowEl = target.closest('[data-part="row"]');
|
|
562
|
+
const value = rowEl?.getAttribute('data-value');
|
|
563
|
+
if (!value) return;
|
|
564
|
+
e.stopPropagation();
|
|
565
|
+
renamingValue = value;
|
|
566
|
+
renameText = findNodeLabel(value);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function commitRename() {
|
|
570
|
+
if (!renamingValue) return;
|
|
571
|
+
if (renameText.trim()) {
|
|
572
|
+
treeData = renameNodeInTree(treeData, renamingValue, renameText.trim());
|
|
573
|
+
onDataChange?.(treeData.children ?? []);
|
|
574
|
+
}
|
|
575
|
+
renamingValue = null;
|
|
576
|
+
renameText = '';
|
|
577
|
+
containerEl?.focus();
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
function cancelRename() {
|
|
581
|
+
renamingValue = null;
|
|
582
|
+
renameText = '';
|
|
583
|
+
containerEl?.focus();
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function handleRenameKeydown(e: KeyboardEvent) {
|
|
587
|
+
e.stopPropagation();
|
|
588
|
+
if (e.key === 'Enter') {
|
|
589
|
+
e.preventDefault();
|
|
590
|
+
commitRename();
|
|
591
|
+
} else if (e.key === 'Escape') {
|
|
592
|
+
cancelRename();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
$effect(() => {
|
|
597
|
+
if (!isDragging) return;
|
|
598
|
+
document.body.style.cursor = 'grabbing';
|
|
599
|
+
return () => {
|
|
600
|
+
document.body.style.cursor = '';
|
|
601
|
+
};
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
$effect(() => {
|
|
605
|
+
if (renamingValue && renameInputEl) {
|
|
606
|
+
renameInputEl.focus();
|
|
607
|
+
renameInputEl.select();
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
$effect(() => {
|
|
612
|
+
function onOutsidePointerDown(e: PointerEvent) {
|
|
613
|
+
if (!containerEl || containerEl.contains(e.target as Node)) return;
|
|
614
|
+
selectedValue = [];
|
|
615
|
+
pivot = null;
|
|
616
|
+
cursorValue = null;
|
|
617
|
+
onSelectionChange?.({ selectedValue: [] });
|
|
618
|
+
}
|
|
619
|
+
document.addEventListener('pointerdown', onOutsidePointerDown, true);
|
|
620
|
+
return () => document.removeEventListener('pointerdown', onOutsidePointerDown, true);
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
$effect(() => {
|
|
624
|
+
const el = containerEl;
|
|
625
|
+
if (!el) return;
|
|
626
|
+
const cancelIfNotDragging = () => {
|
|
627
|
+
if (!isDragging) cancelPress();
|
|
628
|
+
};
|
|
629
|
+
el.addEventListener('click', handleClick, true);
|
|
630
|
+
el.addEventListener('dblclick', handleDblClick, true);
|
|
631
|
+
el.addEventListener('pointerdown', handlePointerDown, true);
|
|
632
|
+
el.addEventListener('pointercancel', cancelIfNotDragging, true);
|
|
633
|
+
el.addEventListener('pointerup', cancelIfNotDragging, true);
|
|
634
|
+
return () => {
|
|
635
|
+
el.removeEventListener('click', handleClick, true);
|
|
636
|
+
el.removeEventListener('dblclick', handleDblClick, true);
|
|
637
|
+
el.removeEventListener('pointerdown', handlePointerDown, true);
|
|
638
|
+
el.removeEventListener('pointercancel', cancelIfNotDragging, true);
|
|
639
|
+
el.removeEventListener('pointerup', cancelIfNotDragging, true);
|
|
640
|
+
};
|
|
641
|
+
});
|
|
642
|
+
</script>
|
|
643
|
+
|
|
644
|
+
{#if isDragging}
|
|
645
|
+
<div
|
|
646
|
+
use:portal
|
|
647
|
+
data-drag-ghost
|
|
648
|
+
style="position:fixed; z-index:9999; left:{ghostPos.x}px; top:{ghostPos.y}px"
|
|
649
|
+
class="bg-background pointer-events-none max-w-48 truncate rounded border px-2 py-1 text-sm shadow-lg"
|
|
650
|
+
>
|
|
651
|
+
{#if dragValues.length === 1}
|
|
652
|
+
{findNodeLabel(dragValues[0])}
|
|
653
|
+
{:else}
|
|
654
|
+
{dragValues.length} items
|
|
655
|
+
{/if}
|
|
656
|
+
</div>
|
|
657
|
+
{/if}
|
|
658
|
+
|
|
659
|
+
<div
|
|
660
|
+
bind:this={containerEl}
|
|
661
|
+
role="tree"
|
|
662
|
+
tabindex="0"
|
|
663
|
+
data-slot="hierarchy-view"
|
|
664
|
+
class={cn('flex size-full flex-col text-sm outline-none select-none', className)}
|
|
665
|
+
ondragstart={(e) => e.preventDefault()}
|
|
666
|
+
onkeydown={handleKeyDown}
|
|
667
|
+
onfocus={() => {
|
|
668
|
+
if (containerEl?.matches(':focus-visible') && !cursorValue)
|
|
669
|
+
cursorValue = getVisibleValues()[0] ?? null;
|
|
670
|
+
}}
|
|
671
|
+
>
|
|
672
|
+
{#each treeData.children ?? [] as node (getValue(node))}
|
|
673
|
+
{@render renderNode(node, 1)}
|
|
674
|
+
{/each}
|
|
675
|
+
</div>
|
|
676
|
+
|
|
677
|
+
{#snippet renderNode(node: AnyNode, depth: number)}
|
|
678
|
+
{@const v = getValue(node)}
|
|
679
|
+
{@const hasBranch = (node.children?.length ?? 0) > 0}
|
|
680
|
+
{@const isExpanded = expandedValue.includes(v)}
|
|
681
|
+
{@const isSelected = selectedValue.includes(v)}
|
|
682
|
+
{@const dt = dropTarget}
|
|
683
|
+
{@const isDropInside = dt?.value === v && dt?.position === 'inside'}
|
|
684
|
+
{@const isDropBefore = dt?.value === v && dt?.position === 'before'}
|
|
685
|
+
{@const isDropAfter = dt?.value === v && dt?.position === 'after'}
|
|
686
|
+
{@const isRenaming = renamingValue === v}
|
|
687
|
+
{@const isCursor = cursorValue === v && isKeyboardMode}
|
|
688
|
+
{@const isJustMoved = justMovedValue === v}
|
|
689
|
+
|
|
690
|
+
<div
|
|
691
|
+
role="treeitem"
|
|
692
|
+
aria-level={depth}
|
|
693
|
+
aria-expanded={hasBranch ? isExpanded : undefined}
|
|
694
|
+
aria-selected={isSelected}
|
|
695
|
+
class="flex flex-col"
|
|
696
|
+
>
|
|
697
|
+
<div
|
|
698
|
+
data-part="row"
|
|
699
|
+
data-value={v}
|
|
700
|
+
data-slot="hierarchy-view-row"
|
|
701
|
+
style="padding-left: calc({depth - 1} * 1rem)"
|
|
702
|
+
class={cn(
|
|
703
|
+
'hover:bg-muted flex w-full cursor-default items-center gap-1.5 py-1 pr-2 transition-colors',
|
|
704
|
+
isSelected && 'bg-accent text-accent-foreground hover:bg-accent',
|
|
705
|
+
isCursor && !isSelected && 'bg-muted',
|
|
706
|
+
isCursor && 'ring-primary ring-1 ring-inset',
|
|
707
|
+
isJustMoved && !isSelected && 'bg-primary-subtle-bg',
|
|
708
|
+
isDropInside && 'outline-primary outline -outline-offset-2',
|
|
709
|
+
isDropBefore && 'border-primary border-t-2',
|
|
710
|
+
isDropAfter && 'border-primary border-b-2'
|
|
711
|
+
)}
|
|
712
|
+
>
|
|
713
|
+
{#if hasBranch}
|
|
714
|
+
<button
|
|
715
|
+
data-part="trigger"
|
|
716
|
+
tabindex="-1"
|
|
717
|
+
class="text-muted-foreground flex shrink-0 items-center"
|
|
718
|
+
onclick={(e) => {
|
|
719
|
+
e.stopPropagation();
|
|
720
|
+
toggleExpand(v);
|
|
721
|
+
}}
|
|
722
|
+
>
|
|
723
|
+
<MingcuteRightLine
|
|
724
|
+
class={cn('size-3.5 transition-transform', isExpanded && 'rotate-90')}
|
|
725
|
+
/>
|
|
726
|
+
</button>
|
|
727
|
+
{:else}
|
|
728
|
+
<span class="size-3.5 shrink-0"></span>
|
|
729
|
+
{/if}
|
|
730
|
+
{#if icon}
|
|
731
|
+
{@render icon(node)}
|
|
732
|
+
{:else}
|
|
733
|
+
<MingcuteFileLine class="text-muted-foreground size-4 shrink-0" />
|
|
734
|
+
{/if}
|
|
735
|
+
{#if isRenaming}
|
|
736
|
+
<input
|
|
737
|
+
bind:this={renameInputEl}
|
|
738
|
+
bind:value={renameText}
|
|
739
|
+
onkeydown={handleRenameKeydown}
|
|
740
|
+
onblur={commitRename}
|
|
741
|
+
onclick={(e: MouseEvent) => e.stopPropagation()}
|
|
742
|
+
class="outline-primary min-w-0 flex-1 rounded bg-transparent px-0.5 outline focus-visible:outline-2"
|
|
743
|
+
/>
|
|
744
|
+
{:else}
|
|
745
|
+
<span class="truncate">{nodeToString(node)}</span>
|
|
746
|
+
{/if}
|
|
747
|
+
</div>
|
|
748
|
+
{#if hasBranch}
|
|
749
|
+
<div
|
|
750
|
+
class={cn(
|
|
751
|
+
'grid transition-[grid-template-rows] duration-150 ease-out',
|
|
752
|
+
isExpanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]'
|
|
753
|
+
)}
|
|
754
|
+
>
|
|
755
|
+
<div class="flex flex-col overflow-hidden">
|
|
756
|
+
{#each node.children ?? [] as child (getValue(child))}
|
|
757
|
+
{@render renderNode(child, depth + 1)}
|
|
758
|
+
{/each}
|
|
759
|
+
</div>
|
|
760
|
+
</div>
|
|
761
|
+
{/if}
|
|
762
|
+
</div>
|
|
763
|
+
{/snippet}
|