@neut/ui 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -56
- package/README.zh-CN.md +137 -0
- package/dist/components/accordion/Accordion/Accordion.context.js.map +1 -1
- package/dist/components/accordion/Accordion/Accordion.js +21 -20
- package/dist/components/accordion/Accordion/Accordion.js.map +1 -1
- package/dist/components/accordion/Accordion/Accordion.styles.d.ts +2 -0
- package/dist/components/accordion/Accordion/Accordion.styles.js +7 -0
- package/dist/components/accordion/Accordion/Accordion.styles.js.map +1 -0
- package/dist/components/accordion/Accordion/useAccordion.js +1 -3
- package/dist/components/accordion/Accordion/useAccordion.js.map +1 -1
- package/dist/components/accordion/AccordionContent/AccordionContent.js +25 -21
- package/dist/components/accordion/AccordionContent/AccordionContent.js.map +1 -1
- package/dist/components/accordion/AccordionContent/AccordionContent.styles.d.ts +5 -0
- package/dist/components/accordion/AccordionContent/AccordionContent.styles.js +9 -0
- package/dist/components/accordion/AccordionContent/AccordionContent.styles.js.map +1 -0
- package/dist/components/accordion/AccordionContent/index.d.ts +1 -0
- package/dist/components/accordion/AccordionItem/AccordionItem.context.js.map +1 -1
- package/dist/components/accordion/AccordionItem/AccordionItem.js +19 -18
- package/dist/components/accordion/AccordionItem/AccordionItem.js.map +1 -1
- package/dist/components/accordion/AccordionItem/AccordionItem.styles.d.ts +2 -0
- package/dist/components/accordion/AccordionItem/AccordionItem.styles.js +6 -0
- package/dist/components/accordion/AccordionItem/AccordionItem.styles.js.map +1 -0
- package/dist/components/accordion/AccordionItem/index.d.ts +1 -0
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.js +26 -18
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.js.map +1 -1
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.styles.d.ts +6 -0
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.styles.js +10 -0
- package/dist/components/accordion/AccordionTrigger/AccordionTrigger.styles.js.map +1 -0
- package/dist/components/accordion/AccordionTrigger/index.d.ts +1 -0
- package/dist/components/accordion/index.d.ts +4 -4
- package/dist/components/accordion/index.js +6 -5
- package/dist/components/alert/Alert/Alert.js +1 -1
- package/dist/components/alert/Alert/Alert.js.map +1 -1
- package/dist/components/alert/Alert/Alert.styles.js +3 -3
- package/dist/components/alert/Alert/Alert.styles.js.map +1 -1
- package/dist/components/alert/AlertAction/AlertAction.js +2 -2
- package/dist/components/alert/AlertAction/AlertAction.js.map +1 -1
- package/dist/components/alert/AlertAction/AlertAction.styles.d.ts +2 -1
- package/dist/components/alert/AlertAction/AlertAction.styles.js +1 -1
- package/dist/components/alert/AlertAction/AlertAction.styles.js.map +1 -1
- package/dist/components/alert/AlertDescription/AlertDescription.js +2 -2
- package/dist/components/alert/AlertDescription/AlertDescription.js.map +1 -1
- package/dist/components/alert/AlertDescription/AlertDescription.styles.d.ts +2 -1
- package/dist/components/alert/AlertDescription/AlertDescription.styles.js +2 -2
- package/dist/components/alert/AlertDescription/AlertDescription.styles.js.map +1 -1
- package/dist/components/alert/AlertTitle/AlertTitle.js +2 -2
- package/dist/components/alert/AlertTitle/AlertTitle.js.map +1 -1
- package/dist/components/alert/AlertTitle/AlertTitle.styles.d.ts +2 -1
- package/dist/components/alert/AlertTitle/AlertTitle.styles.js +2 -2
- package/dist/components/alert/AlertTitle/AlertTitle.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialog/AlertDialog.context.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialog/AlertDialog.js +1 -1
- package/dist/components/alert-dialog/AlertDialog/AlertDialog.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogAction/AlertDialogAction.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.js +3 -3
- package/dist/components/alert-dialog/AlertDialogCancel/AlertDialogCancel.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.context.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.js +11 -11
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogContent/AlertDialogContent.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogDescription/AlertDialogDescription.js +2 -2
- package/dist/components/alert-dialog/AlertDialogDescription/AlertDialogDescription.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogDescription/AlertDialogDescription.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogDescription/AlertDialogDescription.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogDescription/AlertDialogDescription.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogFooter/AlertDialogFooter.js +2 -2
- package/dist/components/alert-dialog/AlertDialogFooter/AlertDialogFooter.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogFooter/AlertDialogFooter.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogFooter/AlertDialogFooter.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogFooter/AlertDialogFooter.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogHeader/AlertDialogHeader.js +2 -2
- package/dist/components/alert-dialog/AlertDialogHeader/AlertDialogHeader.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogHeader/AlertDialogHeader.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogHeader/AlertDialogHeader.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogHeader/AlertDialogHeader.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogMedia/AlertDialogMedia.js +2 -2
- package/dist/components/alert-dialog/AlertDialogMedia/AlertDialogMedia.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogMedia/AlertDialogMedia.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogMedia/AlertDialogMedia.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogMedia/AlertDialogMedia.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogOverlay/AlertDialogOverlay.js +2 -2
- package/dist/components/alert-dialog/AlertDialogOverlay/AlertDialogOverlay.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogOverlay/AlertDialogOverlay.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogOverlay/AlertDialogOverlay.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogOverlay/AlertDialogOverlay.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogPortal/AlertDialogPortal.js +1 -1
- package/dist/components/alert-dialog/AlertDialogPortal/AlertDialogPortal.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogTitle/AlertDialogTitle.js +2 -2
- package/dist/components/alert-dialog/AlertDialogTitle/AlertDialogTitle.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogTitle/AlertDialogTitle.styles.d.ts +2 -1
- package/dist/components/alert-dialog/AlertDialogTitle/AlertDialogTitle.styles.js +2 -2
- package/dist/components/alert-dialog/AlertDialogTitle/AlertDialogTitle.styles.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogTrigger/AlertDialogTrigger.js.map +1 -1
- package/dist/components/alert-dialog/AlertDialogTrigger/useAlertDialogTrigger.js.map +1 -1
- package/dist/components/aspect-ratio/AspectRatio.js +1 -1
- package/dist/components/aspect-ratio/AspectRatio.js.map +1 -1
- package/dist/components/aspect-ratio/AspectRatio.styles.js.map +1 -1
- package/dist/components/avatar/Avatar/Avatar.context.js.map +1 -1
- package/dist/components/avatar/Avatar/Avatar.js +9 -9
- package/dist/components/avatar/Avatar/Avatar.js.map +1 -1
- package/dist/components/avatar/AvatarBadge/AvatarBadge.js +1 -1
- package/dist/components/avatar/AvatarBadge/AvatarBadge.js.map +1 -1
- package/dist/components/avatar/AvatarFallback/AvatarFallback.js +1 -1
- package/dist/components/avatar/AvatarFallback/AvatarFallback.js.map +1 -1
- package/dist/components/avatar/AvatarGroup/AvatarGroup.js +1 -1
- package/dist/components/avatar/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/avatar/AvatarGroupCount/AvatarGroupCount.js +1 -1
- package/dist/components/avatar/AvatarGroupCount/AvatarGroupCount.js.map +1 -1
- package/dist/components/avatar/AvatarImage/AvatarImage.js +1 -1
- package/dist/components/avatar/AvatarImage/AvatarImage.js.map +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/badge/Badge.js.map +1 -1
- package/dist/components/badge/Badge.styles.js +9 -10
- package/dist/components/badge/Badge.styles.js.map +1 -1
- package/dist/components/breadcrumb/Breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb/Breadcrumb.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.js +1 -1
- package/dist/components/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbItem/BreadcrumbItem.js +1 -1
- package/dist/components/breadcrumb/BreadcrumbItem/BreadcrumbItem.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbLink/BreadcrumbLink.js +6 -6
- package/dist/components/breadcrumb/BreadcrumbLink/BreadcrumbLink.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbList/BreadcrumbList.js +1 -1
- package/dist/components/breadcrumb/BreadcrumbList/BreadcrumbList.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbPage/BreadcrumbPage.js +1 -1
- package/dist/components/breadcrumb/BreadcrumbPage/BreadcrumbPage.js.map +1 -1
- package/dist/components/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.js +1 -1
- package/dist/components/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.js.map +1 -1
- package/dist/components/button/Button.js +34 -31
- package/dist/components/button/Button.js.map +1 -1
- package/dist/components/button/Button.styles.d.ts +1 -1
- package/dist/components/button/Button.styles.js +10 -10
- package/dist/components/button/Button.styles.js.map +1 -1
- package/dist/components/button/Button.types.d.ts +4 -30
- package/dist/components/button-group/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/components/button-group/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/components/button-group/ButtonGroup/ButtonGroup.styles.js.map +1 -1
- package/dist/components/button-group/ButtonGroupSeparator/ButtonGroupSeparator.js +1 -1
- package/dist/components/button-group/ButtonGroupSeparator/ButtonGroupSeparator.js.map +1 -1
- package/dist/components/button-group/ButtonGroupSeparator/ButtonGroupSeparator.styles.d.ts +2 -1
- package/dist/components/button-group/ButtonGroupSeparator/ButtonGroupSeparator.styles.js +2 -3
- package/dist/components/button-group/ButtonGroupSeparator/ButtonGroupSeparator.styles.js.map +1 -1
- package/dist/components/button-group/ButtonGroupText/ButtonGroupText.js +2 -2
- package/dist/components/button-group/ButtonGroupText/ButtonGroupText.js.map +1 -1
- package/dist/components/button-group/ButtonGroupText/ButtonGroupText.styles.d.ts +2 -1
- package/dist/components/button-group/ButtonGroupText/ButtonGroupText.styles.js +2 -3
- package/dist/components/button-group/ButtonGroupText/ButtonGroupText.styles.js.map +1 -1
- package/dist/components/card/Card/Card.js +6 -6
- package/dist/components/card/Card/Card.js.map +1 -1
- package/dist/components/card/Card/Card.styles.d.ts +2 -1
- package/dist/components/card/Card/Card.styles.js +2 -2
- package/dist/components/card/Card/Card.styles.js.map +1 -1
- package/dist/components/card/CardAction/CardAction.js +2 -2
- package/dist/components/card/CardAction/CardAction.js.map +1 -1
- package/dist/components/card/CardAction/CardAction.styles.d.ts +2 -1
- package/dist/components/card/CardAction/CardAction.styles.js +1 -1
- package/dist/components/card/CardAction/CardAction.styles.js.map +1 -1
- package/dist/components/card/CardContent/CardContent.js +2 -2
- package/dist/components/card/CardContent/CardContent.js.map +1 -1
- package/dist/components/card/CardContent/CardContent.styles.d.ts +2 -1
- package/dist/components/card/CardContent/CardContent.styles.js +2 -2
- package/dist/components/card/CardContent/CardContent.styles.js.map +1 -1
- package/dist/components/card/CardDescription/CardDescription.js +2 -2
- package/dist/components/card/CardDescription/CardDescription.js.map +1 -1
- package/dist/components/card/CardDescription/CardDescription.styles.d.ts +2 -1
- package/dist/components/card/CardDescription/CardDescription.styles.js +2 -2
- package/dist/components/card/CardDescription/CardDescription.styles.js.map +1 -1
- package/dist/components/card/CardFooter/CardFooter.js +2 -2
- package/dist/components/card/CardFooter/CardFooter.js.map +1 -1
- package/dist/components/card/CardFooter/CardFooter.styles.d.ts +2 -1
- package/dist/components/card/CardFooter/CardFooter.styles.js +2 -2
- package/dist/components/card/CardFooter/CardFooter.styles.js.map +1 -1
- package/dist/components/card/CardHeader/CardHeader.js +2 -2
- package/dist/components/card/CardHeader/CardHeader.js.map +1 -1
- package/dist/components/card/CardHeader/CardHeader.styles.d.ts +2 -1
- package/dist/components/card/CardHeader/CardHeader.styles.js +2 -2
- package/dist/components/card/CardHeader/CardHeader.styles.js.map +1 -1
- package/dist/components/card/CardTitle/CardTitle.js +2 -2
- package/dist/components/card/CardTitle/CardTitle.js.map +1 -1
- package/dist/components/card/CardTitle/CardTitle.styles.d.ts +2 -1
- package/dist/components/card/CardTitle/CardTitle.styles.js +1 -1
- package/dist/components/card/CardTitle/CardTitle.styles.js.map +1 -1
- package/dist/components/carousel/Carousel/Carousel.context.js.map +1 -1
- package/dist/components/carousel/Carousel/Carousel.js +14 -13
- package/dist/components/carousel/Carousel/Carousel.js.map +1 -1
- package/dist/components/carousel/Carousel/Carousel.styles.d.ts +2 -0
- package/dist/components/carousel/Carousel/Carousel.styles.js +6 -0
- package/dist/components/carousel/Carousel/Carousel.styles.js.map +1 -0
- package/dist/components/carousel/Carousel/useAutoPlay.js.map +1 -1
- package/dist/components/carousel/Carousel/useCarousel.js.map +1 -1
- package/dist/components/carousel/Carousel/useKeyboardNavigation.js.map +1 -1
- package/dist/components/carousel/CarouselContent/CarouselContent.js +1 -1
- package/dist/components/carousel/CarouselContent/CarouselContent.js.map +1 -1
- package/dist/components/carousel/CarouselContent/useItemSizeMeasure.js.map +1 -1
- package/dist/components/carousel/CarouselDots/CarouselDots.js +1 -1
- package/dist/components/carousel/CarouselDots/CarouselDots.js.map +1 -1
- package/dist/components/carousel/CarouselItem/CarouselItem.js +4 -3
- package/dist/components/carousel/CarouselItem/CarouselItem.js.map +1 -1
- package/dist/components/carousel/CarouselNext/CarouselNext.js +4 -4
- package/dist/components/carousel/CarouselNext/CarouselNext.js.map +1 -1
- package/dist/components/carousel/CarouselPrevious/CarouselPrevious.js +4 -4
- package/dist/components/carousel/CarouselPrevious/CarouselPrevious.js.map +1 -1
- package/dist/components/checkbox/Checkbox/Checkbox.js +18 -18
- package/dist/components/checkbox/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/checkbox/Checkbox/Checkbox.styles.js.map +1 -1
- package/dist/components/checkbox/CheckboxIndicator/CheckboxIndicator.js +1 -1
- package/dist/components/checkbox/CheckboxIndicator/CheckboxIndicator.js.map +1 -1
- package/dist/components/collapsible/Collapsible/Collapsible.context.js.map +1 -1
- package/dist/components/collapsible/Collapsible/Collapsible.js +1 -1
- package/dist/components/collapsible/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/collapsible/CollapsibleContent/CollapsibleContent.js +1 -1
- package/dist/components/collapsible/CollapsibleContent/CollapsibleContent.js.map +1 -1
- package/dist/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.js +1 -1
- package/dist/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.js.map +1 -1
- package/dist/components/collapsible/CollapsibleTrigger/CollapsibleTrigger.types.d.ts +1 -1
- package/dist/components/dialog/Dialog/Dialog.context.js.map +1 -1
- package/dist/components/dialog/Dialog/Dialog.js +1 -1
- package/dist/components/dialog/Dialog/Dialog.js.map +1 -1
- package/dist/components/dialog/DialogClose/DialogClose.js +4 -6
- package/dist/components/dialog/DialogClose/DialogClose.js.map +1 -1
- package/dist/components/dialog/DialogClose/DialogClose.types.d.ts +2 -2
- package/dist/components/dialog/DialogContent/DialogContent.context.js.map +1 -1
- package/dist/components/dialog/DialogContent/DialogContent.js +10 -10
- package/dist/components/dialog/DialogContent/DialogContent.js.map +1 -1
- package/dist/components/dialog/DialogDescription/DialogDescription.js +1 -1
- package/dist/components/dialog/DialogDescription/DialogDescription.js.map +1 -1
- package/dist/components/dialog/DialogFooter/DialogFooter.js +1 -1
- package/dist/components/dialog/DialogFooter/DialogFooter.js.map +1 -1
- package/dist/components/dialog/DialogHeader/DialogHeader.js +1 -1
- package/dist/components/dialog/DialogHeader/DialogHeader.js.map +1 -1
- package/dist/components/dialog/DialogOverlay/DialogOverlay.js +1 -1
- package/dist/components/dialog/DialogOverlay/DialogOverlay.js.map +1 -1
- package/dist/components/dialog/DialogPortal/DialogPortal.js +1 -1
- package/dist/components/dialog/DialogPortal/DialogPortal.js.map +1 -1
- package/dist/components/dialog/DialogTitle/DialogTitle.js +1 -1
- package/dist/components/dialog/DialogTitle/DialogTitle.js.map +1 -1
- package/dist/components/dialog/DialogTrigger/DialogTrigger.js.map +1 -1
- package/dist/components/dialog/DialogTrigger/useDialogTrigger.js.map +1 -1
- package/dist/components/field/Field/Field.js +5 -5
- package/dist/components/field/Field/Field.js.map +1 -1
- package/dist/components/field/Field/Field.styles.js +1 -1
- package/dist/components/field/Field/Field.styles.js.map +1 -1
- package/dist/components/field/FieldContent/FieldContent.js +1 -1
- package/dist/components/field/FieldContent/FieldContent.js.map +1 -1
- package/dist/components/field/FieldDescription/FieldDescription.js +2 -2
- package/dist/components/field/FieldDescription/FieldDescription.js.map +1 -1
- package/dist/components/field/FieldError/FieldError.js +2 -2
- package/dist/components/field/FieldError/FieldError.js.map +1 -1
- package/dist/components/field/FieldGroup/FieldGroup.js +1 -1
- package/dist/components/field/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/components/field/FieldLabel/FieldLabel.js +1 -1
- package/dist/components/field/FieldLabel/FieldLabel.js.map +1 -1
- package/dist/components/field/FieldLegend/FieldLegend.js +5 -5
- package/dist/components/field/FieldLegend/FieldLegend.js.map +1 -1
- package/dist/components/field/FieldSeparator/FieldSeparator.js +14 -14
- package/dist/components/field/FieldSeparator/FieldSeparator.js.map +1 -1
- package/dist/components/field/FieldSet/FieldSet.js +1 -1
- package/dist/components/field/FieldSet/FieldSet.js.map +1 -1
- package/dist/components/field/FieldTitle/FieldTitle.js +1 -1
- package/dist/components/field/FieldTitle/FieldTitle.js.map +1 -1
- package/dist/components/image/Image.config.js +1 -1
- package/dist/components/image/Image.config.js.map +1 -1
- package/dist/components/image/Image.js +13 -13
- package/dist/components/image/Image.js.map +1 -1
- package/dist/components/image/Image.utils.js +67 -67
- package/dist/components/image/Image.utils.js.map +1 -1
- package/dist/components/image/ImageElement.js +19 -19
- package/dist/components/image/ImageElement.js.map +1 -1
- package/dist/components/image/ImagePreload.js +1 -1
- package/dist/components/image/ImagePreload.js.map +1 -1
- package/dist/components/input/Input.js +13 -13
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/input-group/InputGroup/InputGroup.js +2 -2
- package/dist/components/input-group/InputGroup/InputGroup.js.map +1 -1
- package/dist/components/input-group/InputGroupAddon/InputGroupAddon.js +5 -5
- package/dist/components/input-group/InputGroupAddon/InputGroupAddon.js.map +1 -1
- package/dist/components/input-group/InputGroupAddon/InputGroupAddon.styles.js +1 -1
- package/dist/components/input-group/InputGroupAddon/InputGroupAddon.styles.js.map +1 -1
- package/dist/components/input-group/InputGroupButton/InputGroupButton.js +9 -9
- package/dist/components/input-group/InputGroupButton/InputGroupButton.js.map +1 -1
- package/dist/components/input-group/InputGroupButton/InputGroupButton.styles.js.map +1 -1
- package/dist/components/input-group/InputGroupButton/InputGroupButton.types.d.ts +2 -3
- package/dist/components/input-group/InputGroupInput/InputGroupInput.js.map +1 -1
- package/dist/components/input-group/InputGroupText/InputGroupText.js +2 -2
- package/dist/components/input-group/InputGroupText/InputGroupText.js.map +1 -1
- package/dist/components/input-group/InputGroupTextarea/InputGroupTextarea.js.map +1 -1
- package/dist/components/item/Item/Item.js +9 -9
- package/dist/components/item/Item/Item.js.map +1 -1
- package/dist/components/item/Item/Item.styles.js +3 -3
- package/dist/components/item/Item/Item.styles.js.map +1 -1
- package/dist/components/item/ItemActions/ItemActions.js +1 -1
- package/dist/components/item/ItemActions/ItemActions.js.map +1 -1
- package/dist/components/item/ItemContent/ItemContent.js +1 -1
- package/dist/components/item/ItemContent/ItemContent.js.map +1 -1
- package/dist/components/item/ItemDescription/ItemDescription.js +2 -2
- package/dist/components/item/ItemDescription/ItemDescription.js.map +1 -1
- package/dist/components/item/ItemFooter/ItemFooter.js +1 -1
- package/dist/components/item/ItemFooter/ItemFooter.js.map +1 -1
- package/dist/components/item/ItemGroup/ItemGroup.js +1 -1
- package/dist/components/item/ItemGroup/ItemGroup.js.map +1 -1
- package/dist/components/item/ItemHeader/ItemHeader.js +1 -1
- package/dist/components/item/ItemHeader/ItemHeader.js.map +1 -1
- package/dist/components/item/ItemMedia/ItemMedia.js +5 -5
- package/dist/components/item/ItemMedia/ItemMedia.js.map +1 -1
- package/dist/components/item/ItemMedia/ItemMedia.styles.js.map +1 -1
- package/dist/components/item/ItemSeparator/ItemSeparator.js.map +1 -1
- package/dist/components/item/ItemTitle/ItemTitle.js +1 -1
- package/dist/components/item/ItemTitle/ItemTitle.js.map +1 -1
- package/dist/components/kbd/Kbd.js +2 -2
- package/dist/components/kbd/Kbd.js.map +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/label/Label.js.map +1 -1
- package/dist/components/pagination/Pagination/Pagination.js +1 -1
- package/dist/components/pagination/Pagination/Pagination.js.map +1 -1
- package/dist/components/pagination/PaginationContent/PaginationContent.js +1 -1
- package/dist/components/pagination/PaginationContent/PaginationContent.js.map +1 -1
- package/dist/components/pagination/PaginationEllipsis/PaginationEllipsis.js +1 -1
- package/dist/components/pagination/PaginationEllipsis/PaginationEllipsis.js.map +1 -1
- package/dist/components/pagination/PaginationItem/PaginationItem.js +1 -1
- package/dist/components/pagination/PaginationItem/PaginationItem.js.map +1 -1
- package/dist/components/pagination/PaginationLink/PaginationLink.js +13 -10
- package/dist/components/pagination/PaginationLink/PaginationLink.js.map +1 -1
- package/dist/components/pagination/PaginationNext/PaginationNext.js +5 -5
- package/dist/components/pagination/PaginationNext/PaginationNext.js.map +1 -1
- package/dist/components/pagination/PaginationPrevious/PaginationPrevious.js +5 -5
- package/dist/components/pagination/PaginationPrevious/PaginationPrevious.js.map +1 -1
- package/dist/components/progress/Progress/Progress.context.js.map +1 -1
- package/dist/components/progress/Progress/Progress.js +1 -1
- package/dist/components/progress/Progress/Progress.js.map +1 -1
- package/dist/components/progress/ProgressIndicator/ProgressIndicator.js +1 -1
- package/dist/components/progress/ProgressIndicator/ProgressIndicator.js.map +1 -1
- package/dist/components/progress/ProgressIndicator/ProgressIndicator.styles.d.ts +1 -1
- package/dist/components/progress/ProgressIndicator/ProgressIndicator.styles.js +1 -1
- package/dist/components/progress/ProgressIndicator/ProgressIndicator.styles.js.map +1 -1
- package/dist/components/progress/ProgressLabel/ProgressLabel.js +1 -1
- package/dist/components/progress/ProgressLabel/ProgressLabel.js.map +1 -1
- package/dist/components/progress/ProgressTrack/ProgressTrack.js +1 -1
- package/dist/components/progress/ProgressTrack/ProgressTrack.js.map +1 -1
- package/dist/components/progress/ProgressTrack/ProgressTrack.styles.d.ts +1 -1
- package/dist/components/progress/ProgressTrack/ProgressTrack.styles.js +1 -1
- package/dist/components/progress/ProgressTrack/ProgressTrack.styles.js.map +1 -1
- package/dist/components/progress/ProgressValue/ProgressValue.js +1 -1
- package/dist/components/progress/ProgressValue/ProgressValue.js.map +1 -1
- package/dist/components/progress/ProgressValue/ProgressValue.styles.d.ts +1 -1
- package/dist/components/progress/ProgressValue/ProgressValue.styles.js +1 -1
- package/dist/components/progress/ProgressValue/ProgressValue.styles.js.map +1 -1
- package/dist/components/scroll-area/ScrollArea/ScrollArea.context.js.map +1 -1
- package/dist/components/scroll-area/ScrollArea/ScrollArea.js +2 -2
- package/dist/components/scroll-area/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/components/scroll-area/ScrollArea/ScrollArea.utils.js.map +1 -1
- package/dist/components/scroll-area/ScrollBar/ScrollBar.js +26 -26
- package/dist/components/scroll-area/ScrollBar/ScrollBar.js.map +1 -1
- package/dist/components/separator/Separator.js +7 -7
- package/dist/components/separator/Separator.js.map +1 -1
- package/dist/components/separator/Separator.styles.js +1 -1
- package/dist/components/separator/Separator.styles.js.map +1 -1
- package/dist/components/sidebar/Sidebar/Sidebar.js +10 -10
- package/dist/components/sidebar/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/sidebar/Sidebar/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarContent/SidebarContent.js +1 -1
- package/dist/components/sidebar/SidebarContent/SidebarContent.js.map +1 -1
- package/dist/components/sidebar/SidebarContent/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarFooter/SidebarFooter.js +1 -1
- package/dist/components/sidebar/SidebarFooter/SidebarFooter.js.map +1 -1
- package/dist/components/sidebar/SidebarFooter/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarGroup/SidebarGroup.js +1 -1
- package/dist/components/sidebar/SidebarGroup/SidebarGroup.js.map +1 -1
- package/dist/components/sidebar/SidebarGroup/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarGroupAction/SidebarGroupAction.js +5 -5
- package/dist/components/sidebar/SidebarGroupAction/SidebarGroupAction.js.map +1 -1
- package/dist/components/sidebar/SidebarGroupAction/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarGroupContent/SidebarGroupContent.js +1 -1
- package/dist/components/sidebar/SidebarGroupContent/SidebarGroupContent.js.map +1 -1
- package/dist/components/sidebar/SidebarGroupContent/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarGroupLabel/SidebarGroupLabel.js +5 -5
- package/dist/components/sidebar/SidebarGroupLabel/SidebarGroupLabel.js.map +1 -1
- package/dist/components/sidebar/SidebarGroupLabel/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarHeader/SidebarHeader.js +1 -1
- package/dist/components/sidebar/SidebarHeader/SidebarHeader.js.map +1 -1
- package/dist/components/sidebar/SidebarHeader/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarInput/SidebarInput.js +1 -1
- package/dist/components/sidebar/SidebarInput/SidebarInput.js.map +1 -1
- package/dist/components/sidebar/SidebarInput/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarInset/SidebarInset.js +2 -2
- package/dist/components/sidebar/SidebarInset/SidebarInset.js.map +1 -1
- package/dist/components/sidebar/SidebarInset/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenu/SidebarMenu.js +1 -1
- package/dist/components/sidebar/SidebarMenu/SidebarMenu.js.map +1 -1
- package/dist/components/sidebar/SidebarMenu/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuBadge/SidebarMenuBadge.js +2 -2
- package/dist/components/sidebar/SidebarMenuBadge/SidebarMenuBadge.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuBadge/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.js +47 -31
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.styles.js +5 -6
- package/dist/components/sidebar/SidebarMenuButton/SidebarMenuButton.styles.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuButton/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuItem/SidebarMenuItem.js +1 -1
- package/dist/components/sidebar/SidebarMenuItem/SidebarMenuItem.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuItem/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuSkeleton/SidebarMenuSkeleton.js +7 -7
- package/dist/components/sidebar/SidebarMenuSkeleton/SidebarMenuSkeleton.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuSkeleton/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuSub/SidebarMenuSub.js +2 -2
- package/dist/components/sidebar/SidebarMenuSub/SidebarMenuSub.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuSub/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuSubButton/SidebarMenuSubButton.js +9 -9
- package/dist/components/sidebar/SidebarMenuSubButton/SidebarMenuSubButton.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuSubButton/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarMenuSubItem/SidebarMenuSubItem.js +1 -1
- package/dist/components/sidebar/SidebarMenuSubItem/SidebarMenuSubItem.js.map +1 -1
- package/dist/components/sidebar/SidebarMenuSubItem/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarProvider/SidebarProvider.consts.js +1 -1
- package/dist/components/sidebar/SidebarProvider/SidebarProvider.consts.js.map +1 -1
- package/dist/components/sidebar/SidebarProvider/SidebarProvider.context.js.map +1 -1
- package/dist/components/sidebar/SidebarProvider/SidebarProvider.js +17 -17
- package/dist/components/sidebar/SidebarProvider/SidebarProvider.js.map +1 -1
- package/dist/components/sidebar/SidebarRail/SidebarRail.js +2 -2
- package/dist/components/sidebar/SidebarRail/SidebarRail.js.map +1 -1
- package/dist/components/sidebar/SidebarRail/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarSeparator/SidebarSeparator.js.map +1 -1
- package/dist/components/sidebar/SidebarSeparator/index.d.ts +1 -0
- package/dist/components/sidebar/SidebarTrigger/SidebarTrigger.js.map +1 -1
- package/dist/components/sidebar/SidebarTrigger/index.d.ts +1 -0
- package/dist/components/sidebar/index.d.ts +21 -21
- package/dist/components/skeleton/Skeleton.js +2 -2
- package/dist/components/skeleton/Skeleton.js.map +1 -1
- package/dist/components/slider/Slider/Slider.context.js.map +1 -1
- package/dist/components/slider/Slider/Slider.js +10 -10
- package/dist/components/slider/Slider/Slider.js.map +1 -1
- package/dist/components/slider/Slider/useSlider.js.map +1 -1
- package/dist/components/slider/SliderControl/SliderControl.js +1 -1
- package/dist/components/slider/SliderControl/SliderControl.js.map +1 -1
- package/dist/components/slider/SliderControl/useSliderControl.js.map +1 -1
- package/dist/components/slider/SliderIndicator/SliderIndicator.js +1 -1
- package/dist/components/slider/SliderIndicator/SliderIndicator.js.map +1 -1
- package/dist/components/slider/SliderIndicator/SliderIndicator.styles.js +1 -1
- package/dist/components/slider/SliderIndicator/SliderIndicator.styles.js.map +1 -1
- package/dist/components/slider/SliderIndicator/useSliderIndicator.js.map +1 -1
- package/dist/components/slider/SliderThumb/SliderThumb.js +1 -1
- package/dist/components/slider/SliderThumb/SliderThumb.js.map +1 -1
- package/dist/components/slider/SliderThumb/SliderThumb.styles.js +1 -1
- package/dist/components/slider/SliderThumb/SliderThumb.styles.js.map +1 -1
- package/dist/components/slider/SliderThumb/useSliderThumb.js.map +1 -1
- package/dist/components/slider/SliderTrack/SliderTrack.js +1 -1
- package/dist/components/slider/SliderTrack/SliderTrack.js.map +1 -1
- package/dist/components/slider/SliderTrack/SliderTrack.styles.d.ts +1 -1
- package/dist/components/slider/SliderTrack/SliderTrack.styles.js +1 -1
- package/dist/components/slider/SliderTrack/SliderTrack.styles.js.map +1 -1
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/spinner/Spinner.styles.js.map +1 -1
- package/dist/components/switch/Switch.js +19 -19
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/switch/Switch.styles.js +2 -2
- package/dist/components/switch/Switch.styles.js.map +1 -1
- package/dist/components/textarea/Textarea.js +2 -2
- package/dist/components/textarea/Textarea.js.map +1 -1
- package/dist/components/toast/components/Assets.js +1 -1
- package/dist/components/toast/components/Assets.js.map +1 -1
- package/dist/components/toast/components/Toast.js +2 -5
- package/dist/components/toast/components/Toast.js.map +1 -1
- package/dist/components/toast/components/ToastActions.js +1 -1
- package/dist/components/toast/components/ToastActions.js.map +1 -1
- package/dist/components/toast/components/ToastContent.js +1 -1
- package/dist/components/toast/components/ToastContent.js.map +1 -1
- package/dist/components/toast/components/ToastIcon.js +1 -1
- package/dist/components/toast/components/ToastIcon.js.map +1 -1
- package/dist/components/toast/components/Toaster.js +1 -1
- package/dist/components/toast/components/Toaster.js.map +1 -1
- package/dist/components/toast/hooks/useSwipe.js.map +1 -1
- package/dist/components/toast/hooks/useTheme.js.map +1 -1
- package/dist/components/toast/hooks/useToastHeight.js.map +1 -1
- package/dist/components/toast/hooks/useToastSubscription.js +3 -2
- package/dist/components/toast/hooks/useToastSubscription.js.map +1 -1
- package/dist/components/toast/hooks/useToastTimer.js.map +1 -1
- package/dist/components/toast/hooks/useToasterKeyboard.js.map +1 -1
- package/dist/components/toast/hooks.js +3 -2
- package/dist/components/toast/hooks.js.map +1 -1
- package/dist/components/toast/state.js +5 -5
- package/dist/components/toast/state.js.map +1 -1
- package/dist/components/toast/utils.js.map +1 -1
- package/dist/components/tooltip/Tooltip/Tooltip.context.d.ts +2 -11
- package/dist/components/tooltip/Tooltip/Tooltip.context.js +4 -4
- package/dist/components/tooltip/Tooltip/Tooltip.context.js.map +1 -1
- package/dist/components/tooltip/Tooltip/Tooltip.d.ts +21 -5
- package/dist/components/tooltip/Tooltip/Tooltip.js +60 -23
- package/dist/components/tooltip/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/tooltip/Tooltip/Tooltip.types.d.ts +58 -0
- package/dist/components/tooltip/Tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/TooltipArrow/TooltipArrow.d.ts +34 -1
- package/dist/components/tooltip/TooltipArrow/TooltipArrow.js +48 -12
- package/dist/components/tooltip/TooltipArrow/TooltipArrow.js.map +1 -1
- package/dist/components/tooltip/TooltipArrow/index.d.ts +1 -0
- package/dist/components/tooltip/TooltipContent/TooltipContent.context.d.ts +19 -5
- package/dist/components/tooltip/TooltipContent/TooltipContent.context.js +4 -4
- package/dist/components/tooltip/TooltipContent/TooltipContent.context.js.map +1 -1
- package/dist/components/tooltip/TooltipContent/TooltipContent.d.ts +10 -1
- package/dist/components/tooltip/TooltipContent/TooltipContent.js +60 -46
- package/dist/components/tooltip/TooltipContent/TooltipContent.js.map +1 -1
- package/dist/components/tooltip/TooltipContent/TooltipContent.types.d.ts +13 -3
- package/dist/components/tooltip/TooltipContent/TooltipContent.utils.d.ts +57 -6
- package/dist/components/tooltip/TooltipContent/TooltipContent.utils.js +34 -58
- package/dist/components/tooltip/TooltipContent/TooltipContent.utils.js.map +1 -1
- package/dist/components/tooltip/TooltipContent/index.d.ts +7 -0
- package/dist/components/tooltip/TooltipContent/useTooltipContent.d.ts +45 -8
- package/dist/components/tooltip/TooltipContent/useTooltipContent.js +70 -41
- package/dist/components/tooltip/TooltipContent/useTooltipContent.js.map +1 -1
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.context.d.ts +29 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.context.js +10 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.context.js.map +1 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.d.ts +2 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.js +25 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.js.map +1 -0
- package/dist/components/tooltip/TooltipGroup/TooltipGroup.types.d.ts +10 -0
- package/dist/components/tooltip/TooltipGroup/index.d.ts +4 -0
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.d.ts +4 -2
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.js +26 -6
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.js.map +1 -1
- package/dist/components/tooltip/TooltipTrigger/TooltipTrigger.types.d.ts +3 -0
- package/dist/components/tooltip/TooltipTrigger/index.d.ts +3 -0
- package/dist/components/tooltip/TooltipTrigger/useTooltipTrigger.d.ts +29 -2
- package/dist/components/tooltip/TooltipTrigger/useTooltipTrigger.js +27 -27
- package/dist/components/tooltip/TooltipTrigger/useTooltipTrigger.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +6 -0
- package/dist/components/tooltip/index.js +2 -1
- package/dist/hooks/useFontLoader.js +1 -1
- package/dist/hooks/useFontLoader.js.map +1 -1
- package/dist/index.js +155 -152
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/positioner/auto-update.d.ts +19 -0
- package/dist/lib/positioner/auto-update.js +20 -0
- package/dist/lib/positioner/auto-update.js.map +1 -0
- package/dist/lib/positioner/core/compute-position.d.ts +9 -0
- package/dist/lib/positioner/core/compute-position.js +47 -0
- package/dist/lib/positioner/core/compute-position.js.map +1 -0
- package/dist/lib/positioner/core/placement.d.ts +14 -0
- package/dist/lib/positioner/core/placement.js +45 -0
- package/dist/lib/positioner/core/placement.js.map +1 -0
- package/dist/lib/positioner/create-positioner.d.ts +63 -0
- package/dist/lib/positioner/create-positioner.js +51 -0
- package/dist/lib/positioner/create-positioner.js.map +1 -0
- package/dist/lib/positioner/index.d.ts +11 -0
- package/dist/lib/positioner/middleware/arrow.d.ts +23 -0
- package/dist/lib/positioner/middleware/arrow.js +23 -0
- package/dist/lib/positioner/middleware/arrow.js.map +1 -0
- package/dist/lib/positioner/middleware/containing-block-offset.d.ts +27 -0
- package/dist/lib/positioner/middleware/containing-block-offset.js +46 -0
- package/dist/lib/positioner/middleware/containing-block-offset.js.map +1 -0
- package/dist/lib/positioner/middleware/flip.d.ts +9 -0
- package/dist/lib/positioner/middleware/flip.js +54 -0
- package/dist/lib/positioner/middleware/flip.js.map +1 -0
- package/dist/lib/positioner/middleware/hide.d.ts +22 -0
- package/dist/lib/positioner/middleware/hide.js +19 -0
- package/dist/lib/positioner/middleware/hide.js.map +1 -0
- package/dist/lib/positioner/middleware/index.d.ts +13 -0
- package/dist/lib/positioner/middleware/offset.d.ts +10 -0
- package/dist/lib/positioner/middleware/offset.js +21 -0
- package/dist/lib/positioner/middleware/offset.js.map +1 -0
- package/dist/lib/positioner/middleware/shift.d.ts +13 -0
- package/dist/lib/positioner/middleware/shift.js +30 -0
- package/dist/lib/positioner/middleware/shift.js.map +1 -0
- package/dist/lib/positioner/middleware/size.d.ts +13 -0
- package/dist/lib/positioner/types.d.ts +74 -0
- package/dist/lib/positioner/utils/dom.d.ts +16 -0
- package/dist/lib/positioner/utils/dom.js +43 -0
- package/dist/lib/positioner/utils/dom.js.map +1 -0
- package/dist/lib/positioner/virtual-element.d.ts +21 -0
- package/dist/types/props.types.d.ts +10 -9
- package/dist/ui.css +2 -2
- package/dist/utils/clsx.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -2
- package/dist/utils/logger.d.ts +73 -0
- package/dist/utils/logger.js +37 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/warn-once.js.map +1 -1
- package/package.json +13 -12
- package/dist/components/alert-dialog/AlertDialog/AlertDialog.styles.d.ts +0 -0
- package/dist/components/carousel/CarouselContent/CarouselContent.styles.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwipe.js","names":[],"sources":["../../../../src/components/toast/hooks/useSwipe.ts"],"sourcesContent":["import { createSignal } from \"solid-js\";\nimport { SWIPE_THRESHOLD } from \"../constants\";\nimport { getDefaultSwipeDirections } from \"../utils\";\nimport type { SwipeDirection, ToastT } from \"../types\";\n\ninterface UseSwipeOptions {\n toastRef: () => HTMLLIElement | undefined;\n toast: ToastT;\n dismissible: boolean;\n position: string;\n swipeDirections?: SwipeDirection[];\n offset: () => number;\n deleteToast: () => void;\n}\n\nexport function useSwipe(opts: UseSwipeOptions) {\n const [swiping, setSwiping] = createSignal(false);\n const [swipeOut, setSwipeOut] = createSignal(false);\n const [swipeOutDirection, setSwipeOutDirection] = createSignal<\n \"left\" | \"right\" | \"up\" | \"down\" | null\n >(null);\n const [isSwiped, setIsSwiped] = createSignal(false);\n const [offsetBeforeRemove, setOffsetBeforeRemove] = createSignal(0);\n\n let swipeDirection: \"x\" | \"y\" | null = null;\n let pointerStart: { x: number; y: number } | null = null;\n let dragStartTime: Date | null = null;\n\n const disabled = () => opts.toast.type === \"loading\";\n\n const onPointerDown = (e: PointerEvent) => {\n if (e.button === 2) return;\n if (disabled() || !opts.dismissible) return;\n dragStartTime = new Date();\n setOffsetBeforeRemove(opts.offset());\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n if ((e.target as HTMLElement).tagName === \"BUTTON\") return;\n setSwiping(true);\n pointerStart = { x: e.clientX, y: e.clientY };\n };\n\n const onPointerUp = () => {\n if (swipeOut() || !opts.dismissible) return;\n pointerStart = null;\n\n const el = opts.toastRef();\n const amtX = Number(\n el?.style.getPropertyValue(\"--swipe-amount-x\").replace(\"px\", \"\") || 0,\n );\n const amtY = Number(\n el?.style.getPropertyValue(\"--swipe-amount-y\").replace(\"px\", \"\") || 0,\n );\n const timeTaken = Date.now() - (dragStartTime?.getTime() ?? 0);\n const swipeAmt = swipeDirection === \"x\" ? amtX : amtY;\n const velocity = Math.abs(swipeAmt) / timeTaken;\n\n if (Math.abs(swipeAmt) >= SWIPE_THRESHOLD || velocity > 0.11) {\n setOffsetBeforeRemove(opts.offset());\n opts.toast.onDismiss?.(opts.toast);\n if (swipeDirection === \"x\") {\n setSwipeOutDirection(amtX > 0 ? \"right\" : \"left\");\n } else {\n setSwipeOutDirection(amtY > 0 ? \"down\" : \"up\");\n }\n opts.deleteToast();\n setSwipeOut(true);\n return;\n }\n\n el?.style.setProperty(\"--swipe-amount-x\", \"0px\");\n el?.style.setProperty(\"--swipe-amount-y\", \"0px\");\n setIsSwiped(false);\n setSwiping(false);\n swipeDirection = null;\n };\n\n const onPointerMove = (e: PointerEvent) => {\n if (!pointerStart || !opts.dismissible) return;\n if ((window.getSelection()?.toString().length ?? 0) > 0) return;\n\n const yDelta = e.clientY - pointerStart.y;\n const xDelta = e.clientX - pointerStart.x;\n const dirs =\n opts.swipeDirections ?? getDefaultSwipeDirections(opts.position);\n\n if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {\n swipeDirection = Math.abs(xDelta) > Math.abs(yDelta) ? \"x\" : \"y\";\n }\n\n const getDampen = (delta: number) => 1 / (1.5 + Math.abs(delta) / 20);\n\n const swipeAmt = { x: 0, y: 0 };\n\n if (\n swipeDirection === \"y\" &&\n (dirs.includes(\"top\") || dirs.includes(\"bottom\"))\n ) {\n if (\n (dirs.includes(\"top\") && yDelta < 0) ||\n (dirs.includes(\"bottom\") && yDelta > 0)\n ) {\n swipeAmt.y = yDelta;\n } else {\n const d = yDelta * getDampen(yDelta);\n swipeAmt.y = Math.abs(d) < Math.abs(yDelta) ? d : yDelta;\n }\n } else if (\n swipeDirection === \"x\" &&\n (dirs.includes(\"left\") || dirs.includes(\"right\"))\n ) {\n if (\n (dirs.includes(\"left\") && xDelta < 0) ||\n (dirs.includes(\"right\") && xDelta > 0)\n ) {\n swipeAmt.x = xDelta;\n } else {\n const d = xDelta * getDampen(xDelta);\n swipeAmt.x = Math.abs(d) < Math.abs(xDelta) ? d : xDelta;\n }\n }\n\n if (Math.abs(swipeAmt.x) > 0 || Math.abs(swipeAmt.y) > 0) setIsSwiped(true);\n\n const el = opts.toastRef();\n el?.style.setProperty(\"--swipe-amount-x\", `${swipeAmt.x}px`);\n el?.style.setProperty(\"--swipe-amount-y\", `${swipeAmt.y}px`);\n };\n\n const onDragEnd = () => {\n setSwiping(false);\n swipeDirection = null;\n pointerStart = null;\n };\n\n return {\n swiping,\n swipeOut,\n swipeOutDirection,\n isSwiped,\n offsetBeforeRemove,\n setOffsetBeforeRemove,\n onPointerDown,\n onPointerUp,\n onPointerMove,\n onDragEnd,\n };\n}\n"],"mappings":";;;AAeA,SAAgB,EAAS,GAAuB;CAC9C,IAAM,CAAC,GAAS,KAAc,EAAa,
|
|
1
|
+
{"version":3,"file":"useSwipe.js","names":[],"sources":["../../../../src/components/toast/hooks/useSwipe.ts"],"sourcesContent":["import { createSignal } from \"solid-js\";\nimport { SWIPE_THRESHOLD } from \"../constants\";\nimport { getDefaultSwipeDirections } from \"../utils\";\nimport type { SwipeDirection, ToastT } from \"../types\";\n\ninterface UseSwipeOptions {\n toastRef: () => HTMLLIElement | undefined;\n toast: ToastT;\n dismissible: boolean;\n position: string;\n swipeDirections?: SwipeDirection[];\n offset: () => number;\n deleteToast: () => void;\n}\n\nexport function useSwipe(opts: UseSwipeOptions) {\n const [swiping, setSwiping] = createSignal(false);\n const [swipeOut, setSwipeOut] = createSignal(false);\n const [swipeOutDirection, setSwipeOutDirection] = createSignal<\n \"left\" | \"right\" | \"up\" | \"down\" | null\n >(null);\n const [isSwiped, setIsSwiped] = createSignal(false);\n const [offsetBeforeRemove, setOffsetBeforeRemove] = createSignal(0);\n\n let swipeDirection: \"x\" | \"y\" | null = null;\n let pointerStart: { x: number; y: number } | null = null;\n let dragStartTime: Date | null = null;\n\n const disabled = () => opts.toast.type === \"loading\";\n\n const onPointerDown = (e: PointerEvent) => {\n if (e.button === 2) return;\n if (disabled() || !opts.dismissible) return;\n dragStartTime = new Date();\n setOffsetBeforeRemove(opts.offset());\n (e.target as HTMLElement).setPointerCapture(e.pointerId);\n if ((e.target as HTMLElement).tagName === \"BUTTON\") return;\n setSwiping(true);\n pointerStart = { x: e.clientX, y: e.clientY };\n };\n\n const onPointerUp = () => {\n if (swipeOut() || !opts.dismissible) return;\n pointerStart = null;\n\n const el = opts.toastRef();\n const amtX = Number(\n el?.style.getPropertyValue(\"--swipe-amount-x\").replace(\"px\", \"\") || 0,\n );\n const amtY = Number(\n el?.style.getPropertyValue(\"--swipe-amount-y\").replace(\"px\", \"\") || 0,\n );\n const timeTaken = Date.now() - (dragStartTime?.getTime() ?? 0);\n const swipeAmt = swipeDirection === \"x\" ? amtX : amtY;\n const velocity = Math.abs(swipeAmt) / timeTaken;\n\n if (Math.abs(swipeAmt) >= SWIPE_THRESHOLD || velocity > 0.11) {\n setOffsetBeforeRemove(opts.offset());\n opts.toast.onDismiss?.(opts.toast);\n if (swipeDirection === \"x\") {\n setSwipeOutDirection(amtX > 0 ? \"right\" : \"left\");\n } else {\n setSwipeOutDirection(amtY > 0 ? \"down\" : \"up\");\n }\n opts.deleteToast();\n setSwipeOut(true);\n return;\n }\n\n el?.style.setProperty(\"--swipe-amount-x\", \"0px\");\n el?.style.setProperty(\"--swipe-amount-y\", \"0px\");\n setIsSwiped(false);\n setSwiping(false);\n swipeDirection = null;\n };\n\n const onPointerMove = (e: PointerEvent) => {\n if (!pointerStart || !opts.dismissible) return;\n if ((window.getSelection()?.toString().length ?? 0) > 0) return;\n\n const yDelta = e.clientY - pointerStart.y;\n const xDelta = e.clientX - pointerStart.x;\n const dirs =\n opts.swipeDirections ?? getDefaultSwipeDirections(opts.position);\n\n if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {\n swipeDirection = Math.abs(xDelta) > Math.abs(yDelta) ? \"x\" : \"y\";\n }\n\n const getDampen = (delta: number) => 1 / (1.5 + Math.abs(delta) / 20);\n\n const swipeAmt = { x: 0, y: 0 };\n\n if (\n swipeDirection === \"y\" &&\n (dirs.includes(\"top\") || dirs.includes(\"bottom\"))\n ) {\n if (\n (dirs.includes(\"top\") && yDelta < 0) ||\n (dirs.includes(\"bottom\") && yDelta > 0)\n ) {\n swipeAmt.y = yDelta;\n } else {\n const d = yDelta * getDampen(yDelta);\n swipeAmt.y = Math.abs(d) < Math.abs(yDelta) ? d : yDelta;\n }\n } else if (\n swipeDirection === \"x\" &&\n (dirs.includes(\"left\") || dirs.includes(\"right\"))\n ) {\n if (\n (dirs.includes(\"left\") && xDelta < 0) ||\n (dirs.includes(\"right\") && xDelta > 0)\n ) {\n swipeAmt.x = xDelta;\n } else {\n const d = xDelta * getDampen(xDelta);\n swipeAmt.x = Math.abs(d) < Math.abs(xDelta) ? d : xDelta;\n }\n }\n\n if (Math.abs(swipeAmt.x) > 0 || Math.abs(swipeAmt.y) > 0) setIsSwiped(true);\n\n const el = opts.toastRef();\n el?.style.setProperty(\"--swipe-amount-x\", `${swipeAmt.x}px`);\n el?.style.setProperty(\"--swipe-amount-y\", `${swipeAmt.y}px`);\n };\n\n const onDragEnd = () => {\n setSwiping(false);\n swipeDirection = null;\n pointerStart = null;\n };\n\n return {\n swiping,\n swipeOut,\n swipeOutDirection,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M,IAAI,IAAS,EAAU,CAAM;IACnC,EAAS,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAM,IAAI,IAAI;GACpD;GAGF,CAAI,KAAK,IAAI,EAAS,CAAC,IAAI,KAAK,KAAK,IAAI,EAAS,CAAC,IAAI,MAAG,EAAY,EAAI;GAE1E,IAAM,IAAK,EAAK,SAAS;GAEzB,AADA,GAAI,MAAM,YAAY,oBAAoB,GAAG,EAAS,EAAE,GAAG,GAC3D,GAAI,MAAM,YAAY,oBAAoB,GAAG,EAAS,EAAE,GAAG;EAC7D;EAkBE,iBAhBsB;GAGtB,AAFA,EAAW,EAAK,GAChB,IAAiB,MACjB,IAAe;EACjB;CAaA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.js","names":[],"sources":["../../../../src/components/toast/hooks/useTheme.ts"],"sourcesContent":["import { createEffect, createSignal, onCleanup } from \"solid-js\";\nimport type { Theme } from \"../types\";\n\nexport function useTheme(theme: () => Theme | \"system\") {\n const getSystemTheme = (): Theme =>\n typeof window !== \"undefined\" &&\n window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n\n const [actualTheme, setActualTheme] = createSignal<Theme>(\n theme() !== \"system\" ? (theme() as Theme) : getSystemTheme(),\n );\n\n createEffect(() => {\n if (theme() !== \"system\") {\n setActualTheme(theme() as Theme);\n return;\n }\n\n setActualTheme(getSystemTheme());\n\n if (typeof window === \"undefined\") return;\n const mq = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (e: MediaQueryListEvent) =>\n setActualTheme(e.matches ? \"dark\" : \"light\");\n\n try {\n mq.addEventListener(\"change\", handler);\n onCleanup(() => mq.removeEventListener(\"change\", handler));\n } catch {\n // Safari < 14 fallback\n mq.addListener(handler);\n onCleanup(() => mq.removeListener(handler as any));\n }\n });\n\n return actualTheme;\n}\n"],"mappings":";;AAGA,SAAgB,EAAS,GAA+B;CACtD,IAAM,UACJ,OAAO,SAAW,OAClB,OAAO,aAAa
|
|
1
|
+
{"version":3,"file":"useTheme.js","names":[],"sources":["../../../../src/components/toast/hooks/useTheme.ts"],"sourcesContent":["import { createEffect, createSignal, onCleanup } from \"solid-js\";\nimport type { Theme } from \"../types\";\n\nexport function useTheme(theme: () => Theme | \"system\") {\n const getSystemTheme = (): Theme =>\n typeof window !== \"undefined\" &&\n window.matchMedia?.(\"(prefers-color-scheme: dark)\").matches\n ? \"dark\"\n : \"light\";\n\n const [actualTheme, setActualTheme] = createSignal<Theme>(\n theme() !== \"system\" ? (theme() as Theme) : getSystemTheme(),\n );\n\n createEffect(() => {\n if (theme() !== \"system\") {\n setActualTheme(theme() as Theme);\n return;\n }\n\n setActualTheme(getSystemTheme());\n\n if (typeof window === \"undefined\") return;\n const mq = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const handler = (e: MediaQueryListEvent) =>\n setActualTheme(e.matches ? \"dark\" : \"light\");\n\n try {\n mq.addEventListener(\"change\", handler);\n onCleanup(() => mq.removeEventListener(\"change\", handler));\n } catch {\n // Safari < 14 fallback\n mq.addListener(handler);\n onCleanup(() => mq.removeListener(handler as any));\n }\n });\n\n return actualTheme;\n}\n"],"mappings":";;AAGA,SAAgB,EAAS,GAA+B;CACtD,IAAM,UACJ,OAAO,SAAW,OAClB,OAAO,aAAa,8BAA8B,CAAC,CAAC,UAChD,SACA,SAEA,CAAC,GAAa,KAAkB,EACpC,EAAM,MAAM,WAAgC,EAAe,IAAnC,EAAM,CAChC;CAyBA,OAvBA,QAAmB;EACjB,IAAI,EAAM,MAAM,UAAU;GACxB,EAAe,EAAM,CAAU;GAC/B;EACF;EAIA,IAFA,EAAe,EAAe,CAAC,GAE3B,OAAO,SAAW,KAAa;EACnC,IAAM,IAAK,OAAO,WAAW,8BAA8B,GACrD,KAAW,MACf,EAAe,EAAE,UAAU,SAAS,OAAO;EAE7C,IAAI;GAEF,AADA,EAAG,iBAAiB,UAAU,CAAO,GACrC,QAAgB,EAAG,oBAAoB,UAAU,CAAO,CAAC;EAC3D,QAAQ;GAGN,AADA,EAAG,YAAY,CAAO,GACtB,QAAgB,EAAG,eAAe,CAAc,CAAC;EACnD;CACF,CAAC,GAEM;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToastHeight.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastHeight.ts"],"sourcesContent":["import { createEffect, createSignal, onCleanup } from \"solid-js\";\nimport type { HeightT, Position, ToastT } from \"../types\";\n\ninterface UseToastHeightOptions {\n toastRef: () => HTMLLIElement | undefined;\n toast: () => ToastT;\n mounted: () => boolean;\n setHeights: (updater: (prev: HeightT[]) => HeightT[]) => void;\n}\n\nexport function useToastHeight(opts: UseToastHeightOptions) {\n const [initialHeight, setInitialHeight] = createSignal(0);\n\n const toast = opts.toast();\n\n // Register height on first mount\n createEffect(() => {\n const el = opts.toastRef();\n if (!el) return;\n const h = el.getBoundingClientRect().height;\n setInitialHeight(h);\n opts.setHeights((prev) => [\n {\n toastId: toast.id,\n height: h,\n position: toast.position as Position,\n },\n ...prev,\n ]);\n onCleanup(() =>\n opts.setHeights((prev) => prev.filter((x) => x.toastId !== toast.id)),\n );\n });\n\n // Keep height in sync when content changes\n createEffect(() => {\n if (!opts.mounted()) return;\n const el = opts.toastRef();\n if (!el) return;\n\n // Read deps so effect re-runs on content change\n void toast.title;\n void toast.description;\n void toast.jsx;\n void toast.action;\n void toast.cancel;\n\n const orig = el.style.height;\n el.style.height = \"auto\";\n const newH = el.getBoundingClientRect().height;\n el.style.height = orig;\n setInitialHeight(newH);\n\n opts.setHeights((prev) => {\n const exists = prev.find((x) => x.toastId === toast.id);\n if (!exists) {\n return [\n {\n toastId: toast.id,\n height: newH,\n position: toast.position as Position,\n },\n ...prev,\n ];\n }\n return prev.map((x) =>\n x.toastId === toast.id ? { ...x, height: newH } : x,\n );\n });\n });\n\n return { initialHeight };\n}\n"],"mappings":";;AAUA,SAAgB,EAAe,GAA6B;CAC1D,IAAM,CAAC,GAAe,KAAoB,EAAa,
|
|
1
|
+
{"version":3,"file":"useToastHeight.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastHeight.ts"],"sourcesContent":["import { createEffect, createSignal, onCleanup } from \"solid-js\";\nimport type { HeightT, Position, ToastT } from \"../types\";\n\ninterface UseToastHeightOptions {\n toastRef: () => HTMLLIElement | undefined;\n toast: () => ToastT;\n mounted: () => boolean;\n setHeights: (updater: (prev: HeightT[]) => HeightT[]) => void;\n}\n\nexport function useToastHeight(opts: UseToastHeightOptions) {\n const [initialHeight, setInitialHeight] = createSignal(0);\n\n const toast = opts.toast();\n\n // Register height on first mount\n createEffect(() => {\n const el = opts.toastRef();\n if (!el) return;\n const h = el.getBoundingClientRect().height;\n setInitialHeight(h);\n opts.setHeights((prev) => [\n {\n toastId: toast.id,\n height: h,\n position: toast.position as Position,\n },\n ...prev,\n ]);\n onCleanup(() =>\n opts.setHeights((prev) => prev.filter((x) => x.toastId !== toast.id)),\n );\n });\n\n // Keep height in sync when content changes\n createEffect(() => {\n if (!opts.mounted()) return;\n const el = opts.toastRef();\n if (!el) return;\n\n // Read deps so effect re-runs on content change\n void toast.title;\n void toast.description;\n void toast.jsx;\n void toast.action;\n void toast.cancel;\n\n const orig = el.style.height;\n el.style.height = \"auto\";\n const newH = el.getBoundingClientRect().height;\n el.style.height = orig;\n setInitialHeight(newH);\n\n opts.setHeights((prev) => {\n const exists = prev.find((x) => x.toastId === toast.id);\n if (!exists) {\n return [\n {\n toastId: toast.id,\n height: newH,\n position: toast.position as Position,\n },\n ...prev,\n ];\n }\n return prev.map((x) =>\n x.toastId === toast.id ? { ...x, height: newH } : x,\n );\n });\n });\n\n return { initialHeight };\n}\n"],"mappings":";;AAUA,SAAgB,EAAe,GAA6B;CAC1D,IAAM,CAAC,GAAe,KAAoB,EAAa,CAAC,GAElD,IAAQ,EAAK,MAAM;CA0DzB,OAvDA,QAAmB;EACjB,IAAM,IAAK,EAAK,SAAS;EACzB,IAAI,CAAC,GAAI;EACT,IAAM,IAAI,EAAG,sBAAsB,CAAC,CAAC;EAUrC,AATA,EAAiB,CAAC,GAClB,EAAK,YAAY,MAAS,CACxB;GACE,SAAS,EAAM;GACf,QAAQ;GACR,UAAU,EAAM;EAClB,GACA,GAAG,CACL,CAAC,GACD,QACE,EAAK,YAAY,MAAS,EAAK,QAAQ,MAAM,EAAE,YAAY,EAAM,EAAE,CAAC,CACtE;CACF,CAAC,GAGD,QAAmB;EACjB,IAAI,CAAC,EAAK,QAAQ,GAAG;EACrB,IAAM,IAAK,EAAK,SAAS;EACzB,IAAI,CAAC,GAAI;EAOT,AAJA,EAAW,OACX,EAAW,aACX,EAAW,KACX,EAAW,QACX,EAAW;EAEX,IAAM,IAAO,EAAG,MAAM;EACtB,EAAG,MAAM,SAAS;EAClB,IAAM,IAAO,EAAG,sBAAsB,CAAC,CAAC;EAIxC,AAHA,EAAG,MAAM,SAAS,GAClB,EAAiB,CAAI,GAErB,EAAK,YAAY,MACA,EAAK,MAAM,MAAM,EAAE,YAAY,EAAM,EAC/C,IAUE,EAAK,KAAK,MACf,EAAE,YAAY,EAAM,KAAK;GAAE,GAAG;GAAG,QAAQ;EAAK,IAAI,CACpD,IAXS,CACL;GACE,SAAS,EAAM;GACf,QAAQ;GACR,UAAU,EAAM;EAClB,GACA,GAAG,CACL,CAKH;CACH,CAAC,GAEM,EAAE,iBAAc;AACzB"}
|
|
@@ -4,7 +4,7 @@ import { createSignal as t, onCleanup as n, onMount as r } from "solid-js";
|
|
|
4
4
|
function i() {
|
|
5
5
|
let [i, a] = t([]);
|
|
6
6
|
return r(() => {
|
|
7
|
-
|
|
7
|
+
let t = e.subscribe((e) => {
|
|
8
8
|
if (e.dismiss) {
|
|
9
9
|
a((t) => t.map((t) => t.id === e.id ? {
|
|
10
10
|
...t,
|
|
@@ -23,7 +23,8 @@ function i() {
|
|
|
23
23
|
...t.slice(n + 1)
|
|
24
24
|
];
|
|
25
25
|
});
|
|
26
|
-
})
|
|
26
|
+
});
|
|
27
|
+
n(t);
|
|
27
28
|
}), {
|
|
28
29
|
toasts: i,
|
|
29
30
|
removeToast: (t) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToastSubscription.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastSubscription.ts"],"sourcesContent":["/**\n * hooks/useToastSubscription.ts\n * Subscribes to the global ToastState observable and maintains a local reactive\n * list of toasts for the Toaster component.\n * Single responsibility: state synchronization between the observer and Solid signals.\n */\nimport { createSignal, onCleanup, onMount } from \"solid-js\";\nimport { ToastState } from \"../state\";\nimport type { ToastT, ToastToDismiss } from \"../types\";\n\nexport function useToastSubscription() {\n const [toasts, setToasts] = createSignal<ToastT[]>([]);\n\n onMount(() => {\n const unsubscribe = ToastState.subscribe((incoming) => {\n if ((incoming as ToastToDismiss).dismiss) {\n // Mark as deleted — the Toast component will animate out\n setToasts((prev) =>\n prev.map((t) => (t.id === incoming.id ? { ...t, delete: true } : t)),\n );\n return;\n }\n\n setToasts((prev) => {\n const idx = prev.findIndex((t) => t.id === incoming.id);\n if (idx !== -1) {\n return [\n ...prev.slice(0, idx),\n { ...prev[idx], ...(incoming as ToastT) },\n ...prev.slice(idx + 1),\n ];\n }\n return [incoming as ToastT, ...prev];\n });\n });\n\n onCleanup(unsubscribe);\n });\n\n const removeToast = (toast: ToastT) => {\n if (!toast.delete) ToastState.dismiss(toast.id);\n setToasts((prev) => prev.filter((t) => t.id !== toast.id));\n };\n\n return { toasts, removeToast };\n}\n"],"mappings":";;;AAUA,SAAgB,IAAuB;CACrC,IAAM,CAAC,GAAQ,KAAa,EAAuB,
|
|
1
|
+
{"version":3,"file":"useToastSubscription.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastSubscription.ts"],"sourcesContent":["/**\n * hooks/useToastSubscription.ts\n * Subscribes to the global ToastState observable and maintains a local reactive\n * list of toasts for the Toaster component.\n * Single responsibility: state synchronization between the observer and Solid signals.\n */\nimport { createSignal, onCleanup, onMount } from \"solid-js\";\nimport { ToastState } from \"../state\";\nimport type { ToastT, ToastToDismiss } from \"../types\";\n\nexport function useToastSubscription() {\n const [toasts, setToasts] = createSignal<ToastT[]>([]);\n\n onMount(() => {\n const unsubscribe = ToastState.subscribe((incoming) => {\n if ((incoming as ToastToDismiss).dismiss) {\n // Mark as deleted — the Toast component will animate out\n setToasts((prev) =>\n prev.map((t) => (t.id === incoming.id ? { ...t, delete: true } : t)),\n );\n return;\n }\n\n setToasts((prev) => {\n const idx = prev.findIndex((t) => t.id === incoming.id);\n if (idx !== -1) {\n return [\n ...prev.slice(0, idx),\n { ...prev[idx], ...(incoming as ToastT) },\n ...prev.slice(idx + 1),\n ];\n }\n return [incoming as ToastT, ...prev];\n });\n });\n\n onCleanup(unsubscribe);\n });\n\n const removeToast = (toast: ToastT) => {\n if (!toast.delete) ToastState.dismiss(toast.id);\n setToasts((prev) => prev.filter((t) => t.id !== toast.id));\n };\n\n return { toasts, removeToast };\n}\n"],"mappings":";;;AAUA,SAAgB,IAAuB;CACrC,IAAM,CAAC,GAAQ,KAAa,EAAuB,CAAC,CAAC;CAiCrD,OA/BA,QAAc;EACZ,IAAM,IAAc,EAAW,WAAW,MAAa;GACrD,IAAK,EAA4B,SAAS;IAExC,GAAW,MACT,EAAK,KAAK,MAAO,EAAE,OAAO,EAAS,KAAK;KAAE,GAAG;KAAG,QAAQ;IAAK,IAAI,CAAE,CACrE;IACA;GACF;GAEA,GAAW,MAAS;IAClB,IAAM,IAAM,EAAK,WAAW,MAAM,EAAE,OAAO,EAAS,EAAE;IAQtD,OAPI,MAAQ,KAOL,CAAC,GAAoB,GAAG,CAAI,IAN1B;KACL,GAAG,EAAK,MAAM,GAAG,CAAG;KACpB;MAAE,GAAG,EAAK;MAAM,GAAI;KAAoB;KACxC,GAAG,EAAK,MAAM,IAAM,CAAC;IACvB;GAGJ,CAAC;EACH,CAAC;EAED,EAAU,CAAW;CACvB,CAAC,GAOM;EAAE;EAAQ,cALI,MAAkB;GAErC,AADK,EAAM,UAAQ,EAAW,QAAQ,EAAM,EAAE,GAC9C,GAAW,MAAS,EAAK,QAAQ,MAAM,EAAE,OAAO,EAAM,EAAE,CAAC;EAC3D;CAE6B;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToastTimer.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastTimer.ts"],"sourcesContent":["/**\n * hooks/useToastTimer.ts\n * Manages the auto-dismiss countdown for a single toast.\n * Single responsibility: start, pause, and resume a timer; call deleteToast when done.\n */\nimport { createEffect, onCleanup } from \"solid-js\";\nimport type { ToastT } from \"../types\";\n\ninterface UseToastTimerOptions {\n toast: ToastT;\n duration: number;\n expanded: () => boolean;\n interacting: () => boolean;\n isDocumentHidden: () => boolean;\n deleteToast: () => void;\n}\n\nexport function useToastTimer(opts: UseToastTimerOptions) {\n let remainingTime = opts.toast.duration ?? opts.duration;\n let closeTimerStart = 0;\n let lastPauseTime = 0;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const shouldSkip = () =>\n (opts.toast.promise && opts.toast.type === \"loading\") ||\n opts.toast.duration === Infinity ||\n opts.toast.type === \"loading\";\n\n const pauseTimer = () => {\n if (lastPauseTime < closeTimerStart) {\n const elapsed = Date.now() - closeTimerStart;\n remainingTime = Math.max(0, remainingTime - elapsed);\n }\n lastPauseTime = Date.now();\n };\n\n const startTimer = () => {\n if (remainingTime === Infinity) return;\n clearTimeout(timeoutId);\n closeTimerStart = Date.now();\n timeoutId = setTimeout(() => {\n opts.toast.onAutoClose?.(opts.toast);\n opts.deleteToast();\n }, remainingTime);\n };\n\n createEffect(() => {\n if (shouldSkip()) return;\n if (opts.expanded() || opts.interacting() || opts.isDocumentHidden()) {\n pauseTimer();\n } else {\n startTimer();\n }\n onCleanup(() => clearTimeout(timeoutId));\n });\n}\n"],"mappings":";;AAiBA,SAAgB,EAAc,GAA4B;CACxD,IAAI,IAAgB,EAAK,MAAM,YAAY,EAAK,UAC5C,IAAkB,GAClB,IAAgB,GAChB,GAEE,UACH,EAAK,MAAM,WAAW,EAAK,MAAM,SAAS,aAC3C,EAAK,MAAM,aAAa,YACxB,EAAK,MAAM,SAAS,WAEhB,UAAmB;
|
|
1
|
+
{"version":3,"file":"useToastTimer.js","names":[],"sources":["../../../../src/components/toast/hooks/useToastTimer.ts"],"sourcesContent":["/**\n * hooks/useToastTimer.ts\n * Manages the auto-dismiss countdown for a single toast.\n * Single responsibility: start, pause, and resume a timer; call deleteToast when done.\n */\nimport { createEffect, onCleanup } from \"solid-js\";\nimport type { ToastT } from \"../types\";\n\ninterface UseToastTimerOptions {\n toast: ToastT;\n duration: number;\n expanded: () => boolean;\n interacting: () => boolean;\n isDocumentHidden: () => boolean;\n deleteToast: () => void;\n}\n\nexport function useToastTimer(opts: UseToastTimerOptions) {\n let remainingTime = opts.toast.duration ?? opts.duration;\n let closeTimerStart = 0;\n let lastPauseTime = 0;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n const shouldSkip = () =>\n (opts.toast.promise && opts.toast.type === \"loading\") ||\n opts.toast.duration === Infinity ||\n opts.toast.type === \"loading\";\n\n const pauseTimer = () => {\n if (lastPauseTime < closeTimerStart) {\n const elapsed = Date.now() - closeTimerStart;\n remainingTime = Math.max(0, remainingTime - elapsed);\n }\n lastPauseTime = Date.now();\n };\n\n const startTimer = () => {\n if (remainingTime === Infinity) return;\n clearTimeout(timeoutId);\n closeTimerStart = Date.now();\n timeoutId = setTimeout(() => {\n opts.toast.onAutoClose?.(opts.toast);\n opts.deleteToast();\n }, remainingTime);\n };\n\n createEffect(() => {\n if (shouldSkip()) return;\n if (opts.expanded() || opts.interacting() || opts.isDocumentHidden()) {\n pauseTimer();\n } else {\n startTimer();\n }\n onCleanup(() => clearTimeout(timeoutId));\n });\n}\n"],"mappings":";;AAiBA,SAAgB,EAAc,GAA4B;CACxD,IAAI,IAAgB,EAAK,MAAM,YAAY,EAAK,UAC5C,IAAkB,GAClB,IAAgB,GAChB,GAEE,UACH,EAAK,MAAM,WAAW,EAAK,MAAM,SAAS,aAC3C,EAAK,MAAM,aAAa,YACxB,EAAK,MAAM,SAAS,WAEhB,UAAmB;EACvB,IAAI,IAAgB,GAAiB;GACnC,IAAM,IAAU,KAAK,IAAI,IAAI;GAC7B,IAAgB,KAAK,IAAI,GAAG,IAAgB,CAAO;EACrD;EACA,IAAgB,KAAK,IAAI;CAC3B,GAEM,UAAmB;EACnB,MAAkB,aACtB,aAAa,CAAS,GACtB,IAAkB,KAAK,IAAI,GAC3B,IAAY,iBAAiB;GAE3B,AADA,EAAK,MAAM,cAAc,EAAK,KAAK,GACnC,EAAK,YAAY;EACnB,GAAG,CAAa;CAClB;CAEA,QAAmB;EACb,EAAW,MACX,EAAK,SAAS,KAAK,EAAK,YAAY,KAAK,EAAK,iBAAiB,IACjE,EAAW,IAEX,EAAW,GAEb,QAAgB,aAAa,CAAS,CAAC;CACzC,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToasterKeyboard.js","names":[],"sources":["../../../../src/components/toast/hooks/useToasterKeyboard.ts"],"sourcesContent":["/**\n * hooks/useToasterKeyboard.ts\n * Handles keyboard interactions for the Toaster:\n * - Custom hotkey → expand the toast list and focus it\n * - Escape → collapse the toast list\n * Single responsibility: keyboard event binding only.\n */\nimport { onCleanup, onMount } from \"solid-js\";\n\ninterface UseToasterKeyboardOptions {\n hotkey: string[];\n listRef: () => HTMLOListElement | undefined;\n setExpanded: (v: boolean) => void;\n}\n\nexport function useToasterKeyboard(opts: UseToasterKeyboardOptions) {\n onMount(() => {\n const handler = (e: KeyboardEvent) => {\n const hotkeyPressed =\n opts.hotkey.length > 0 &&\n opts.hotkey.every((k) => (e as any)[k] || e.code === k);\n\n if (hotkeyPressed) {\n opts.setExpanded(true);\n opts.listRef()?.focus();\n }\n\n if (\n e.code === \"Escape\" &&\n (document.activeElement === opts.listRef() ||\n opts.listRef()?.contains(document.activeElement))\n ) {\n opts.setExpanded(false);\n }\n };\n\n document.addEventListener(\"keydown\", handler);\n onCleanup(() => document.removeEventListener(\"keydown\", handler));\n });\n}\n"],"mappings":";;AAeA,SAAgB,EAAmB,GAAiC;
|
|
1
|
+
{"version":3,"file":"useToasterKeyboard.js","names":[],"sources":["../../../../src/components/toast/hooks/useToasterKeyboard.ts"],"sourcesContent":["/**\n * hooks/useToasterKeyboard.ts\n * Handles keyboard interactions for the Toaster:\n * - Custom hotkey → expand the toast list and focus it\n * - Escape → collapse the toast list\n * Single responsibility: keyboard event binding only.\n */\nimport { onCleanup, onMount } from \"solid-js\";\n\ninterface UseToasterKeyboardOptions {\n hotkey: string[];\n listRef: () => HTMLOListElement | undefined;\n setExpanded: (v: boolean) => void;\n}\n\nexport function useToasterKeyboard(opts: UseToasterKeyboardOptions) {\n onMount(() => {\n const handler = (e: KeyboardEvent) => {\n const hotkeyPressed =\n opts.hotkey.length > 0 &&\n opts.hotkey.every((k) => (e as any)[k] || e.code === k);\n\n if (hotkeyPressed) {\n opts.setExpanded(true);\n opts.listRef()?.focus();\n }\n\n if (\n e.code === \"Escape\" &&\n (document.activeElement === opts.listRef() ||\n opts.listRef()?.contains(document.activeElement))\n ) {\n opts.setExpanded(false);\n }\n };\n\n document.addEventListener(\"keydown\", handler);\n onCleanup(() => document.removeEventListener(\"keydown\", handler));\n });\n}\n"],"mappings":";;AAeA,SAAgB,EAAmB,GAAiC;CAClE,QAAc;EACZ,IAAM,KAAW,MAAqB;GAUpC,AARE,EAAK,OAAO,SAAS,KACrB,EAAK,OAAO,OAAO,MAAO,EAAU,MAAM,EAAE,SAAS,CAAC,MAGtD,EAAK,YAAY,EAAI,GACrB,EAAK,QAAQ,CAAC,EAAE,MAAM,IAItB,EAAE,SAAS,aACV,SAAS,kBAAkB,EAAK,QAAQ,KACvC,EAAK,QAAQ,CAAC,EAAE,SAAS,SAAS,aAAa,MAEjD,EAAK,YAAY,EAAK;EAE1B;EAGA,AADA,SAAS,iBAAiB,WAAW,CAAO,GAC5C,QAAgB,SAAS,oBAAoB,WAAW,CAAO,CAAC;CAClE,CAAC;AACH"}
|
|
@@ -11,7 +11,7 @@ function i() {
|
|
|
11
11
|
function a() {
|
|
12
12
|
let [i, a] = t([]);
|
|
13
13
|
return r(() => {
|
|
14
|
-
|
|
14
|
+
let t = e.subscribe((e) => {
|
|
15
15
|
if (e.dismiss) {
|
|
16
16
|
a((t) => t.filter((t) => t.id !== e.id));
|
|
17
17
|
return;
|
|
@@ -27,7 +27,8 @@ function a() {
|
|
|
27
27
|
...t.slice(n + 1)
|
|
28
28
|
];
|
|
29
29
|
});
|
|
30
|
-
})
|
|
30
|
+
});
|
|
31
|
+
n(t);
|
|
31
32
|
}), { toasts: i };
|
|
32
33
|
}
|
|
33
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../../../src/components/toast/hooks.ts"],"sourcesContent":["import { createSignal, onCleanup, onMount } from \"solid-js\";\nimport { ToastState } from \"./state\";\nimport type { ToastT, ToastToDismiss } from \"./types\";\n\n// ─── Document visibility ───────────────────────────────────────────────────────\n/**\n * Returns a reactive boolean that tracks whether the browser tab is hidden.\n * Used to pause auto-dismiss timers while the user has switched tabs.\n */\nexport function useIsDocumentHidden() {\n const [isHidden, setIsHidden] = createSignal(document.hidden);\n\n onMount(() => {\n const handler = () => setIsHidden(document.hidden);\n document.addEventListener(\"visibilitychange\", handler);\n onCleanup(() => document.removeEventListener(\"visibilitychange\", handler));\n });\n\n return isHidden;\n}\n\n// ─── Active toasts (for external consumers) ────────────────────────────────────\n/**\n * Subscribes to the global ToastState and returns the list of currently visible\n * toasts as a SolidJS signal. Useful for building custom toast UIs.\n */\nexport function useSonner() {\n const [activeToasts, setActiveToasts] = createSignal<ToastT[]>([]);\n\n onMount(() => {\n const unsubscribe = ToastState.subscribe((toast) => {\n if ((toast as ToastToDismiss).dismiss) {\n setActiveToasts((prev) => prev.filter((t) => t.id !== toast.id));\n return;\n }\n\n setActiveToasts((prev) => {\n const idx = prev.findIndex((t) => t.id === toast.id);\n if (idx !== -1) {\n return [\n ...prev.slice(0, idx),\n { ...prev[idx], ...(toast as ToastT) },\n ...prev.slice(idx + 1),\n ];\n }\n return [toast as ToastT, ...prev];\n });\n });\n\n onCleanup(unsubscribe);\n });\n\n return { toasts: activeToasts };\n}\n"],"mappings":";;;AASA,SAAgB,IAAsB;CACpC,IAAM,CAAC,GAAU,KAAe,EAAa,SAAS,
|
|
1
|
+
{"version":3,"file":"hooks.js","names":[],"sources":["../../../src/components/toast/hooks.ts"],"sourcesContent":["import { createSignal, onCleanup, onMount } from \"solid-js\";\nimport { ToastState } from \"./state\";\nimport type { ToastT, ToastToDismiss } from \"./types\";\n\n// ─── Document visibility ───────────────────────────────────────────────────────\n/**\n * Returns a reactive boolean that tracks whether the browser tab is hidden.\n * Used to pause auto-dismiss timers while the user has switched tabs.\n */\nexport function useIsDocumentHidden() {\n const [isHidden, setIsHidden] = createSignal(document.hidden);\n\n onMount(() => {\n const handler = () => setIsHidden(document.hidden);\n document.addEventListener(\"visibilitychange\", handler);\n onCleanup(() => document.removeEventListener(\"visibilitychange\", handler));\n });\n\n return isHidden;\n}\n\n// ─── Active toasts (for external consumers) ────────────────────────────────────\n/**\n * Subscribes to the global ToastState and returns the list of currently visible\n * toasts as a SolidJS signal. Useful for building custom toast UIs.\n */\nexport function useSonner() {\n const [activeToasts, setActiveToasts] = createSignal<ToastT[]>([]);\n\n onMount(() => {\n const unsubscribe = ToastState.subscribe((toast) => {\n if ((toast as ToastToDismiss).dismiss) {\n setActiveToasts((prev) => prev.filter((t) => t.id !== toast.id));\n return;\n }\n\n setActiveToasts((prev) => {\n const idx = prev.findIndex((t) => t.id === toast.id);\n if (idx !== -1) {\n return [\n ...prev.slice(0, idx),\n { ...prev[idx], ...(toast as ToastT) },\n ...prev.slice(idx + 1),\n ];\n }\n return [toast as ToastT, ...prev];\n });\n });\n\n onCleanup(unsubscribe);\n });\n\n return { toasts: activeToasts };\n}\n"],"mappings":";;;AASA,SAAgB,IAAsB;CACpC,IAAM,CAAC,GAAU,KAAe,EAAa,SAAS,MAAM;CAQ5D,OANA,QAAc;EACZ,IAAM,UAAgB,EAAY,SAAS,MAAM;EAEjD,AADA,SAAS,iBAAiB,oBAAoB,CAAO,GACrD,QAAgB,SAAS,oBAAoB,oBAAoB,CAAO,CAAC;CAC3E,CAAC,GAEM;AACT;AAOA,SAAgB,IAAY;CAC1B,IAAM,CAAC,GAAc,KAAmB,EAAuB,CAAC,CAAC;CAyBjE,OAvBA,QAAc;EACZ,IAAM,IAAc,EAAW,WAAW,MAAU;GAClD,IAAK,EAAyB,SAAS;IACrC,GAAiB,MAAS,EAAK,QAAQ,MAAM,EAAE,OAAO,EAAM,EAAE,CAAC;IAC/D;GACF;GAEA,GAAiB,MAAS;IACxB,IAAM,IAAM,EAAK,WAAW,MAAM,EAAE,OAAO,EAAM,EAAE;IAQnD,OAPI,MAAQ,KAOL,CAAC,GAAiB,GAAG,CAAI,IANvB;KACL,GAAG,EAAK,MAAM,GAAG,CAAG;KACpB;MAAE,GAAG,EAAK;MAAM,GAAI;KAAiB;KACrC,GAAG,EAAK,MAAM,IAAM,CAAC;IACvB;GAGJ,CAAC;EACH,CAAC;EAED,EAAU,CAAW;CACvB,CAAC,GAEM,EAAE,QAAQ,EAAa;AAChC"}
|
|
@@ -15,7 +15,7 @@ var t = (e) => !("id" in e && "message" in e), n = new class {
|
|
|
15
15
|
this.publish(e), this.toasts = [...this.toasts, e];
|
|
16
16
|
};
|
|
17
17
|
create = (t) => {
|
|
18
|
-
let { message: n, ...r } = t, i = typeof t?.id == "number" || t.id?.length > 0 ? t.id : e(), a = this.toasts.find((e) => e.id === i), o = t.dismissible === void 0
|
|
18
|
+
let { message: n, ...r } = t, i = typeof t?.id == "number" || t.id?.length > 0 ? t.id : e(), a = this.toasts.find((e) => e.id === i), o = t.dismissible === void 0 || t.dismissible;
|
|
19
19
|
return this.dismissedToasts.has(i) && this.dismissedToasts.delete(i), a ? this.toasts = this.toasts.map((e) => e.id === i ? (this.publish({
|
|
20
20
|
...e,
|
|
21
21
|
...t,
|
|
@@ -150,7 +150,7 @@ var t = (e) => !("id" in e && "message" in e), n = new class {
|
|
|
150
150
|
...r,
|
|
151
151
|
id: i
|
|
152
152
|
}), i;
|
|
153
|
-
}, i = (e) => e && typeof e == "object" && "ok" in e && typeof e.ok == "boolean" && "status" in e && typeof e.status == "number", a = Object.assign(r, {
|
|
153
|
+
}, i = (e) => e && typeof e == "object" && "ok" in e && typeof e.ok == "boolean" && "status" in e && typeof e.status == "number", a = () => n.toasts, o = () => n.getActiveToasts(), s = Object.assign(r, {
|
|
154
154
|
success: n.success,
|
|
155
155
|
info: n.info,
|
|
156
156
|
warning: n.warning,
|
|
@@ -161,10 +161,10 @@ var t = (e) => !("id" in e && "message" in e), n = new class {
|
|
|
161
161
|
dismiss: n.dismiss,
|
|
162
162
|
loading: n.loading
|
|
163
163
|
}, {
|
|
164
|
-
getHistory:
|
|
165
|
-
getToasts:
|
|
164
|
+
getHistory: a,
|
|
165
|
+
getToasts: o
|
|
166
166
|
});
|
|
167
167
|
//#endregion
|
|
168
|
-
export { n as ToastState, a as toast };
|
|
168
|
+
export { n as ToastState, a as getHistory, o as getToasts, s as toast };
|
|
169
169
|
|
|
170
170
|
//# sourceMappingURL=state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","names":[],"sources":["../../../src/components/toast/state.ts"],"sourcesContent":["/**\n * state.ts\n * Pure observable store — no framework dependency.\n * Responsible for: creating, updating, dismissing toasts, and notifying subscribers.\n */\nimport { createUniqueId, type JSXElement } from \"solid-js\";\nimport type {\n ExternalToast,\n PromiseData,\n PromiseIExtendedResult,\n PromiseT,\n ToastT,\n ToastToDismiss,\n ToastTypes,\n} from \"./types\";\n\nconst isValidElement = (src: object): boolean => {\n return !(\"id\" in src && \"message\" in src);\n};\n\n// ─── Observer (pub/sub) ────────────────────────────────────────────────────────\nclass Observer {\n subscribers: Array<(toast: ToastT | ToastToDismiss) => void> = [];\n toasts: Array<ToastT | ToastToDismiss> = [];\n dismissedToasts: Set<string> = new Set();\n\n subscribe = (subscriber: (toast: ToastT | ToastToDismiss) => void) => {\n this.subscribers.push(subscriber);\n return () => {\n const index = this.subscribers.indexOf(subscriber);\n this.subscribers.splice(index, 1);\n };\n };\n\n publish = (data: ToastT) => {\n for (const subscriber of this.subscribers) {\n subscriber(data);\n }\n };\n\n addToast = (data: ToastT) => {\n this.publish(data);\n this.toasts = [...this.toasts, data];\n };\n\n create = (\n data: ExternalToast & {\n message?: JSXElement;\n type?: ToastTypes;\n promise?: PromiseT;\n jsx?: (() => JSXElement) | JSXElement;\n },\n ) => {\n const { message, ...rest } = data;\n const id =\n typeof data?.id === \"number\" || (data.id as string)?.length > 0\n ? data.id!\n : createUniqueId();\n\n const alreadyExists = this.toasts.find((t) => t.id === id);\n const dismissible =\n data.dismissible === undefined ? true : data.dismissible;\n\n if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);\n\n if (alreadyExists) {\n this.toasts = this.toasts.map((t) => {\n if (t.id === id) {\n this.publish({ ...t, ...data, id, title: message } as ToastT);\n return { ...t, ...data, id, dismissible, title: message } as ToastT;\n }\n return t;\n });\n } else {\n this.addToast({ title: message, ...rest, dismissible, id } as ToastT);\n }\n\n return id;\n };\n\n dismiss = (id?: string) => {\n if (id !== undefined) {\n this.dismissedToasts.add(id);\n requestAnimationFrame(() => {\n for (const subscriber of this.subscribers) {\n subscriber({ id, dismiss: true });\n }\n });\n } else {\n requestAnimationFrame(() => {\n for (const toast of this.toasts) {\n for (const subscriber of this.subscribers) {\n subscriber({ id: toast.id, dismiss: true });\n }\n }\n });\n }\n\n return id;\n };\n\n message = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, message });\n\n error = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, message, type: \"error\" });\n\n success = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"success\", message });\n\n info = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"info\", message });\n\n warning = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"warning\", message });\n\n loading = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"loading\", message });\n\n promise = <ToastData>(\n promise: PromiseT<ToastData>,\n data?: PromiseData<ToastData>,\n ) => {\n if (!data) return;\n\n let id: string | undefined;\n if (data.loading !== undefined) {\n id = this.create({\n ...data,\n promise,\n type: \"loading\",\n message: data.loading,\n description:\n typeof data.description !== \"function\" ? data.description : undefined,\n });\n }\n\n const p = Promise.resolve(\n promise instanceof Function ? promise() : promise,\n );\n\n let shouldDismiss = id !== undefined;\n let result: [\"resolve\", ToastData] | [\"reject\", unknown];\n\n const originalPromise = p\n .then(async (response) => {\n result = [\"resolve\", response];\n const isElement = isValidElement(response as any);\n if (isElement) {\n shouldDismiss = false;\n this.create({ id, type: \"default\", message: response as any });\n } else if (isHttpResponse(response) && !(response as Response).ok) {\n shouldDismiss = false;\n const errMsg = `HTTP error! status: ${(response as Response).status}`;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(errMsg)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(errMsg)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n } else if (response instanceof Error) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(response)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(response)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n } else if (data.success !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.success === \"function\"\n ? await data.success(response)\n : data.success;\n const description =\n typeof data.description === \"function\"\n ? await data.description(response)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"success\", description, ...toastSettings });\n }\n })\n .catch(async (error) => {\n result = [\"reject\", error];\n if (data.error !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(error)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(error)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n }\n })\n .finally(() => {\n if (shouldDismiss) {\n this.dismiss(id);\n id = undefined;\n }\n data.finally?.();\n });\n\n const unwrap = () =>\n new Promise<ToastData>((resolve, reject) =>\n originalPromise\n .then(() =>\n result[0] === \"reject\"\n ? reject(result[1])\n : resolve(result[1] as ToastData),\n )\n .catch(reject),\n );\n\n if (typeof id !== \"string\" && typeof id !== \"number\") return { unwrap };\n return Object.assign(id, { unwrap });\n };\n\n custom = (jsx: (id: number | string) => any, data?: ExternalToast) => {\n const id = data?.id || createUniqueId();\n this.create({ jsx: jsx(id), ...data, id });\n return id;\n };\n\n getActiveToasts = () =>\n this.toasts.filter((t) => !this.dismissedToasts.has(t.id));\n}\n\n// ─── Singleton & public API ────────────────────────────────────────────────────\nexport const ToastState = new Observer();\n\nconst toastFunction = (message: JSXElement, data?: ExternalToast) => {\n const id = createUniqueId();\n ToastState.addToast({ title: message, ...data, id } as ToastT);\n return id;\n};\n\nconst isHttpResponse = (data: any): data is Response =>\n data &&\n typeof data === \"object\" &&\n \"ok\" in data &&\n typeof data.ok === \"boolean\" &&\n \"status\" in data &&\n typeof data.status === \"number\";\n\nexport const getHistory = () => ToastState.toasts;\nexport const getToasts = () => ToastState.getActiveToasts();\n\nexport const toast = Object.assign(\n toastFunction,\n {\n success: ToastState.success,\n info: ToastState.info,\n warning: ToastState.warning,\n error: ToastState.error,\n custom: ToastState.custom,\n message: ToastState.message,\n promise: ToastState.promise,\n dismiss: ToastState.dismiss,\n loading: ToastState.loading,\n },\n { getHistory, getToasts },\n);\n"],"mappings":";;AAgBA,IAAM,KAAkB,MACf,EAAE,QAAQ,KAAO,aAAa,IAmP1B,IAAa,IA/O1B,MAAe;CACb,cAA+D,EAAE;CACjE,SAAyC,EAAE;CAC3C,kCAA+B,IAAI,KAAK;CAExC,aAAa,OACX,KAAK,YAAY,KAAK,EAAW,QACpB;EACX,IAAM,IAAQ,KAAK,YAAY,QAAQ,EAAW;AAClD,OAAK,YAAY,OAAO,GAAO,EAAE;;CAIrC,WAAW,MAAiB;AAC1B,OAAK,IAAM,KAAc,KAAK,YAC5B,GAAW,EAAK;;CAIpB,YAAY,MAAiB;AAE3B,EADA,KAAK,QAAQ,EAAK,EAClB,KAAK,SAAS,CAAC,GAAG,KAAK,QAAQ,EAAK;;CAGtC,UACE,MAMG;EACH,IAAM,EAAE,YAAS,GAAG,MAAS,GACvB,IACJ,OAAO,GAAM,MAAO,YAAa,EAAK,IAAe,SAAS,IAC1D,EAAK,KACL,GAAgB,EAEhB,IAAgB,KAAK,OAAO,MAAM,MAAM,EAAE,OAAO,EAAG,EACpD,IACJ,EAAK,gBAAgB,KAAA,IAAY,KAAO,EAAK;AAgB/C,SAdI,KAAK,gBAAgB,IAAI,EAAG,IAAE,KAAK,gBAAgB,OAAO,EAAG,EAE7D,IACF,KAAK,SAAS,KAAK,OAAO,KAAK,MACzB,EAAE,OAAO,KACX,KAAK,QAAQ;GAAE,GAAG;GAAG,GAAG;GAAM;GAAI,OAAO;GAAS,CAAW,EACtD;GAAE,GAAG;GAAG,GAAG;GAAM;GAA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,GACA;CACE,SAAS,EAAW;CACpB,MAAM,EAAW;CACjB,SAAS,EAAW;CACpB,OAAO,EAAW;CAClB,QAAQ,EAAW;CACnB,SAAS,EAAW;CACpB,SAAS,EAAW;CACpB,SAAS,EAAW;CACpB,SAAS,EAAW;CACrB,EACD;CAAE,kBAhB4B,EAAW;CAgB3B,iBAfe,EAAW,iBAAiB;CAehC,CAC1B"}
|
|
1
|
+
{"version":3,"file":"state.js","names":[],"sources":["../../../src/components/toast/state.ts"],"sourcesContent":["/**\n * state.ts\n * Pure observable store — no framework dependency.\n * Responsible for: creating, updating, dismissing toasts, and notifying subscribers.\n */\nimport { createUniqueId, type JSXElement } from \"solid-js\";\nimport type {\n ExternalToast,\n PromiseData,\n PromiseIExtendedResult,\n PromiseT,\n ToastT,\n ToastToDismiss,\n ToastTypes,\n} from \"./types\";\n\nconst isValidElement = (src: object): boolean => {\n return !(\"id\" in src && \"message\" in src);\n};\n\n// ─── Observer (pub/sub) ────────────────────────────────────────────────────────\nclass Observer {\n subscribers: Array<(toast: ToastT | ToastToDismiss) => void> = [];\n toasts: Array<ToastT | ToastToDismiss> = [];\n dismissedToasts: Set<string> = new Set();\n\n subscribe = (subscriber: (toast: ToastT | ToastToDismiss) => void) => {\n this.subscribers.push(subscriber);\n return () => {\n const index = this.subscribers.indexOf(subscriber);\n this.subscribers.splice(index, 1);\n };\n };\n\n publish = (data: ToastT) => {\n for (const subscriber of this.subscribers) {\n subscriber(data);\n }\n };\n\n addToast = (data: ToastT) => {\n this.publish(data);\n this.toasts = [...this.toasts, data];\n };\n\n create = (\n data: ExternalToast & {\n message?: JSXElement;\n type?: ToastTypes;\n promise?: PromiseT;\n jsx?: (() => JSXElement) | JSXElement;\n },\n ) => {\n const { message, ...rest } = data;\n const id =\n typeof data?.id === \"number\" || (data.id as string)?.length > 0\n ? data.id!\n : createUniqueId();\n\n const alreadyExists = this.toasts.find((t) => t.id === id);\n const dismissible =\n data.dismissible === undefined ? true : data.dismissible;\n\n if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);\n\n if (alreadyExists) {\n this.toasts = this.toasts.map((t) => {\n if (t.id === id) {\n this.publish({ ...t, ...data, id, title: message } as ToastT);\n return { ...t, ...data, id, dismissible, title: message } as ToastT;\n }\n return t;\n });\n } else {\n this.addToast({ title: message, ...rest, dismissible, id } as ToastT);\n }\n\n return id;\n };\n\n dismiss = (id?: string) => {\n if (id !== undefined) {\n this.dismissedToasts.add(id);\n requestAnimationFrame(() => {\n for (const subscriber of this.subscribers) {\n subscriber({ id, dismiss: true });\n }\n });\n } else {\n requestAnimationFrame(() => {\n for (const toast of this.toasts) {\n for (const subscriber of this.subscribers) {\n subscriber({ id: toast.id, dismiss: true });\n }\n }\n });\n }\n\n return id;\n };\n\n message = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, message });\n\n error = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, message, type: \"error\" });\n\n success = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"success\", message });\n\n info = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"info\", message });\n\n warning = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"warning\", message });\n\n loading = (message: JSXElement, data?: ExternalToast) =>\n this.create({ ...data, type: \"loading\", message });\n\n promise = <ToastData>(\n promise: PromiseT<ToastData>,\n data?: PromiseData<ToastData>,\n ) => {\n if (!data) return;\n\n let id: string | undefined;\n if (data.loading !== undefined) {\n id = this.create({\n ...data,\n promise,\n type: \"loading\",\n message: data.loading,\n description:\n typeof data.description !== \"function\" ? data.description : undefined,\n });\n }\n\n const p = Promise.resolve(\n promise instanceof Function ? promise() : promise,\n );\n\n let shouldDismiss = id !== undefined;\n let result: [\"resolve\", ToastData] | [\"reject\", unknown];\n\n const originalPromise = p\n .then(async (response) => {\n result = [\"resolve\", response];\n const isElement = isValidElement(response as any);\n if (isElement) {\n shouldDismiss = false;\n this.create({ id, type: \"default\", message: response as any });\n } else if (isHttpResponse(response) && !(response as Response).ok) {\n shouldDismiss = false;\n const errMsg = `HTTP error! status: ${(response as Response).status}`;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(errMsg)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(errMsg)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n } else if (response instanceof Error) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(response)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(response)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n } else if (data.success !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.success === \"function\"\n ? await data.success(response)\n : data.success;\n const description =\n typeof data.description === \"function\"\n ? await data.description(response)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"success\", description, ...toastSettings });\n }\n })\n .catch(async (error) => {\n result = [\"reject\", error];\n if (data.error !== undefined) {\n shouldDismiss = false;\n const promiseData =\n typeof data.error === \"function\"\n ? await data.error(error)\n : data.error;\n const description =\n typeof data.description === \"function\"\n ? await data.description(error)\n : data.description;\n const isExtended =\n typeof promiseData === \"object\" &&\n !isValidElement(promiseData as any);\n const toastSettings: PromiseIExtendedResult = isExtended\n ? (promiseData as PromiseIExtendedResult)\n : { message: promiseData as any };\n this.create({ id, type: \"error\", description, ...toastSettings });\n }\n })\n .finally(() => {\n if (shouldDismiss) {\n this.dismiss(id);\n id = undefined;\n }\n data.finally?.();\n });\n\n const unwrap = () =>\n new Promise<ToastData>((resolve, reject) =>\n originalPromise\n .then(() =>\n result[0] === \"reject\"\n ? reject(result[1])\n : resolve(result[1] as ToastData),\n )\n .catch(reject),\n );\n\n if (typeof id !== \"string\" && typeof id !== \"number\") return { unwrap };\n return Object.assign(id, { unwrap });\n };\n\n custom = (jsx: (id: number | string) => any, data?: ExternalToast) => {\n const id = data?.id || createUniqueId();\n this.create({ jsx: jsx(id), ...data, id });\n return id;\n };\n\n getActiveToasts = () =>\n this.toasts.filter((t) => !this.dismissedToasts.has(t.id));\n}\n\n// ─── Singleton & public API ────────────────────────────────────────────────────\nexport const ToastState = new Observer();\n\nconst toastFunction = (message: JSXElement, data?: ExternalToast) => {\n const id = createUniqueId();\n ToastState.addToast({ title: message, ...data, id } as ToastT);\n return id;\n};\n\nconst isHttpResponse = (data: any): data is Response =>\n data &&\n typeof data === \"object\" &&\n \"ok\" in data &&\n typeof data.ok === \"boolean\" &&\n \"status\" in data &&\n typeof data.status === \"number\";\n\nexport const getHistory = () => ToastState.toasts;\nexport const getToasts = () => ToastState.getActiveToasts();\n\nexport const toast = Object.assign(\n toastFunction,\n {\n success: ToastState.success,\n info: ToastState.info,\n warning: ToastState.warning,\n error: ToastState.error,\n custom: ToastState.custom,\n message: ToastState.message,\n promise: ToastState.promise,\n dismiss: ToastState.dismiss,\n loading: ToastState.loading,\n },\n { getHistory, getToasts },\n);\n"],"mappings":";;AAgBA,IAAM,KAAkB,MACf,EAAE,QAAQ,KAAO,aAAa,IAmP1B,IAAa,IAAI,MA/Of;CACb,cAA+D,CAAC;CAChE,SAAyC,CAAC;CAC1C,kCAA+B,IAAI,IAAI;CAEvC,aAAa,OACX,KAAK,YAAY,KAAK,CAAU,SACnB;EACX,IAAM,IAAQ,KAAK,YAAY,QAAQ,CAAU;EACjD,KAAK,YAAY,OAAO,GAAO,CAAC;CAClC;CAGF,WAAW,MAAiB;EAC1B,KAA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SAAoB,GAAS,MAC/B,EACG,WACC,EAAO,OAAO,WACV,EAAO,EAAO,EAAE,IAChB,EAAQ,EAAO,EAAe,CACpC,CAAC,CACA,MAAM,CAAM,CACjB;EAGF,OADI,OAAO,KAAO,YAAY,OAAO,KAAO,WAAiB,EAAE,UAAO,IAC/D,OAAO,OAAO,GAAI,EAAE,UAAO,CAAC;CACrC;CAEA,UAAU,GAAmC,MAAyB;EACpE,IAAM,IAAK,GAAM,MAAM,EAAe;EAEtC,OADA,KAAK,OAAO;GAAE,KAAK,EAAI,CAAE;GAAG,GAAG;GAAM;EAAG,CAAC,GAClC;CACT;CAEA,wBACE,KAAK,OAAO,QAAQ,MAAM,CAAC,KAAK,gBAAgB,IAAI,EAAE,EAAE,CAAC;AAC7D,EAGuC,GAEjC,KAAiB,GAAqB,MAAyB;CACnE,IAAM,IAAK,EAAe;CAE1B,OADA,EAAW,SAAS;EAAE,OAAO;EAAS,GAAG;EAAM;CAAG,CAAW,GACtD;AACT,GAEM,KAAkB,MACtB,KACA,OAAO,KAAS,YAChB,QAAQ,KACR,OAAO,EAAK,MAAO,aACnB,YAAY,KACZ,OAAO,EAAK,UAAW,UAEZ,UAAmB,EAAW,QAC9B,UAAkB,EAAW,gBAAgB,GAE7C,IAAQ,OAAO,OAC1B,GACA;CACE,SAAS,EAAW;CACpB,MAAM,EAAW;CACjB,SAAS,EAAW;CACpB,OAAO,EAAW;CAClB,QAAQ,EAAW;CACnB,SAAS,EAAW;CACpB,SAAS,EAAW;CACpB,SAAS,EAAW;CACpB,SAAS,EAAW;AACtB,GACA;CAAE;CAAY;AAAU,CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/toast/utils.ts"],"sourcesContent":["import type { SwipeDirection, ToasterProps } from \"./types\";\nimport { MOBILE_VIEWPORT_OFFSET, VIEWPORT_OFFSET } from \"./constants\";\n\n/** Derives default swipe directions from a position string like \"bottom-right\" */\nexport function getDefaultSwipeDirections(position: string): SwipeDirection[] {\n const [y, x] = position.split(\"-\");\n const directions: SwipeDirection[] = [];\n if (y) directions.push(y as SwipeDirection);\n if (x) directions.push(x as SwipeDirection);\n return directions;\n}\n\n/** Reads the document text direction (for RTL support) */\nexport function getDocumentDirection(): ToasterProps[\"dir\"] {\n if (typeof window === \"undefined\") return \"ltr\";\n if (typeof document === \"undefined\") return \"ltr\";\n const dir = document.documentElement.getAttribute(\"dir\");\n if (dir === \"auto\" || !dir) {\n return window.getComputedStyle(document.documentElement)\n .direction as ToasterProps[\"dir\"];\n }\n return dir as ToasterProps[\"dir\"];\n}\n\n/**\n * Converts offset prop (string | number | object) into CSS custom property map.\n * Produces both desktop (`--offset-*`) and mobile (`--mobile-offset-*`) vars.\n */\nexport function assignOffset(\n defaultOffset: ToasterProps[\"offset\"],\n mobileOffset: ToasterProps[\"mobileOffset\"],\n): Record<string, string> {\n const styles: Record<string, string> = {};\n\n [defaultOffset, mobileOffset].forEach((offset, i) => {\n const isMobile = i === 1;\n const prefix = isMobile ? \"--mobile-offset\" : \"--offset\";\n const fallback = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;\n\n const assignAll = (value: string | number) => {\n [\"top\", \"right\", \"bottom\", \"left\"].forEach((side) => {\n styles[`${prefix}-${side}`] =\n typeof value === \"number\" ? `${value}px` : value;\n });\n };\n\n if (typeof offset === \"number\" || typeof offset === \"string\") {\n assignAll(offset);\n } else if (typeof offset === \"object\" && offset !== null) {\n [\"top\", \"right\", \"bottom\", \"left\"].forEach((side) => {\n const val = (offset as Record<string, string | number | undefined>)[\n side\n ];\n styles[`${prefix}-${side}`] =\n val === undefined\n ? fallback\n : typeof val === \"number\"\n ? `${val}px`\n : val;\n });\n } else {\n assignAll(fallback);\n }\n });\n\n return styles;\n}\n"],"mappings":";;AAIA,SAAgB,EAA0B,GAAoC;CAC5E,IAAM,CAAC,GAAG,KAAK,EAAS,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/toast/utils.ts"],"sourcesContent":["import type { SwipeDirection, ToasterProps } from \"./types\";\nimport { MOBILE_VIEWPORT_OFFSET, VIEWPORT_OFFSET } from \"./constants\";\n\n/** Derives default swipe directions from a position string like \"bottom-right\" */\nexport function getDefaultSwipeDirections(position: string): SwipeDirection[] {\n const [y, x] = position.split(\"-\");\n const directions: SwipeDirection[] = [];\n if (y) directions.push(y as SwipeDirection);\n if (x) directions.push(x as SwipeDirection);\n return directions;\n}\n\n/** Reads the document text direction (for RTL support) */\nexport function getDocumentDirection(): ToasterProps[\"dir\"] {\n if (typeof window === \"undefined\") return \"ltr\";\n if (typeof document === \"undefined\") return \"ltr\";\n const dir = document.documentElement.getAttribute(\"dir\");\n if (dir === \"auto\" || !dir) {\n return window.getComputedStyle(document.documentElement)\n .direction as ToasterProps[\"dir\"];\n }\n return dir as ToasterProps[\"dir\"];\n}\n\n/**\n * Converts offset prop (string | number | object) into CSS custom property map.\n * Produces both desktop (`--offset-*`) and mobile (`--mobile-offset-*`) vars.\n */\nexport function assignOffset(\n defaultOffset: ToasterProps[\"offset\"],\n mobileOffset: ToasterProps[\"mobileOffset\"],\n): Record<string, string> {\n const styles: Record<string, string> = {};\n\n [defaultOffset, mobileOffset].forEach((offset, i) => {\n const isMobile = i === 1;\n const prefix = isMobile ? \"--mobile-offset\" : \"--offset\";\n const fallback = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;\n\n const assignAll = (value: string | number) => {\n [\"top\", \"right\", \"bottom\", \"left\"].forEach((side) => {\n styles[`${prefix}-${side}`] =\n typeof value === \"number\" ? `${value}px` : value;\n });\n };\n\n if (typeof offset === \"number\" || typeof offset === \"string\") {\n assignAll(offset);\n } else if (typeof offset === \"object\" && offset !== null) {\n [\"top\", \"right\", \"bottom\", \"left\"].forEach((side) => {\n const val = (offset as Record<string, string | number | undefined>)[\n side\n ];\n styles[`${prefix}-${side}`] =\n val === undefined\n ? fallback\n : typeof val === \"number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) => void;
|
|
4
|
-
triggerRef: HTMLElement | undefined;
|
|
5
|
-
setTriggerRef: (el: HTMLElement) => void;
|
|
6
|
-
contentId: string;
|
|
7
|
-
openDelay: number;
|
|
8
|
-
closeDelay: number;
|
|
9
|
-
};
|
|
1
|
+
import { TooltipContextValue } from './Tooltip.types';
|
|
10
2
|
export declare const TooltipContext: import('solid-js').Context<TooltipContextValue | undefined>;
|
|
11
|
-
export declare function useTooltipContext(): TooltipContextValue;
|
|
12
|
-
export {};
|
|
3
|
+
export declare function useTooltipContext(component: string): TooltipContextValue;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createContext as e, useContext as t } from "solid-js";
|
|
2
2
|
//#region src/components/tooltip/Tooltip/Tooltip.context.ts
|
|
3
3
|
var n = e();
|
|
4
|
-
function r() {
|
|
5
|
-
let
|
|
6
|
-
if (!
|
|
7
|
-
return
|
|
4
|
+
function r(e) {
|
|
5
|
+
let r = t(n);
|
|
6
|
+
if (!r) throw Error(`<${e}> 必须渲染在 <Tooltip> 内部`);
|
|
7
|
+
return r;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { n as TooltipContext, r as useTooltipContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.context.js","names":[],"sources":["../../../../src/components/tooltip/Tooltip/Tooltip.context.ts"],"sourcesContent":["import { createContext, useContext } from \"solid-js\";\
|
|
1
|
+
{"version":3,"file":"Tooltip.context.js","names":[],"sources":["../../../../src/components/tooltip/Tooltip/Tooltip.context.ts"],"sourcesContent":["import { createContext, useContext } from \"solid-js\";\nimport type { TooltipContextValue } from \"./Tooltip.types\";\n\nexport const TooltipContext = createContext<TooltipContextValue>();\n\nexport function useTooltipContext(component: string): TooltipContextValue {\n const ctx = useContext(TooltipContext);\n if (!ctx) {\n throw new Error(`<${component}> 必须渲染在 <Tooltip> 内部`);\n }\n return ctx;\n}\n"],"mappings":";;AAGA,IAAa,IAAiB,EAAmC;AAEjE,SAAgB,EAAkB,GAAwC;CACxE,IAAM,IAAM,EAAW,CAAc;CACrC,IAAI,CAAC,GACH,MAAU,MAAM,IAAI,EAAU,qBAAqB;CAErD,OAAO;AACT"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { TooltipProps } from './Tooltip.types';
|
|
3
|
+
/**
|
|
4
|
+
* Tooltip 根组件:不渲染任何 DOM,只负责状态管理 + 提供 context。
|
|
5
|
+
* 真正的展示交给 <TooltipTrigger>/<TooltipContent>/<TooltipArrow>。
|
|
6
|
+
*
|
|
7
|
+
* 如果外面包了 <TooltipGroup>,组内相邻 trigger 之间切换 hover 会跳过
|
|
8
|
+
* openDelay,并触发"从旧位置滑到新位置"的过渡(细节见 TooltipGroup.context.ts)。
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Tooltip openDelay={300}>
|
|
13
|
+
* <TooltipTrigger>悬停我</TooltipTrigger>
|
|
14
|
+
* <TooltipContent>
|
|
15
|
+
* 提示内容
|
|
16
|
+
* <TooltipArrow />
|
|
17
|
+
* </TooltipContent>
|
|
18
|
+
* </Tooltip>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function Tooltip(props: TooltipProps): JSX.Element;
|
|
@@ -1,33 +1,70 @@
|
|
|
1
1
|
import { TooltipContext as e } from "./Tooltip.context.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useTooltipGroupContext as t } from "../TooltipGroup/TooltipGroup.context.js";
|
|
3
|
+
import { createComponent as n } from "solid-js/web";
|
|
4
|
+
import { createEffect as r, createMemo as i, createSignal as a, createUniqueId as o, onCleanup as s } from "solid-js";
|
|
4
5
|
//#region src/components/tooltip/Tooltip/Tooltip.tsx
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var c = 300, l = 150;
|
|
7
|
+
function u(u) {
|
|
8
|
+
let d = t(), [f, p] = a(u.defaultOpen ?? !1), m = i(() => u.open === void 0 ? f() : u.open), h = i(() => !!u.disabled), [g, _] = a(), [v, y] = a(), [b, x] = a(), [S, C] = a(!1), w = (e) => {
|
|
9
|
+
u.open === void 0 && p(e), u.onOpenChange?.(e);
|
|
10
|
+
}, T, E, D = () => {
|
|
11
|
+
T !== void 0 && (window.clearTimeout(T), T = void 0), E !== void 0 && (window.clearTimeout(E), E = void 0);
|
|
12
|
+
}, O = () => {
|
|
13
|
+
if (D(), h() || m()) return;
|
|
14
|
+
let e = d?.claim();
|
|
15
|
+
if (e) {
|
|
16
|
+
x(e), w(!0);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
T = window.setTimeout(() => w(!0), u.openDelay ?? c);
|
|
20
|
+
}, k = () => {
|
|
21
|
+
D(), E = window.setTimeout(() => w(!1), u.closeDelay ?? l);
|
|
22
|
+
}, A = () => {
|
|
23
|
+
h() || (D(), w(!0));
|
|
24
|
+
}, j = () => {
|
|
25
|
+
D(), w(!1);
|
|
26
|
+
}, M = () => {
|
|
27
|
+
C(!0), D(), w(!1);
|
|
28
|
+
}, N = () => {
|
|
29
|
+
E !== void 0 && (window.clearTimeout(E), E = void 0);
|
|
8
30
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
s(D), r(() => {
|
|
32
|
+
if (!d || !m()) return;
|
|
33
|
+
let e = d.registerActive({
|
|
34
|
+
rect: () => v()?.getBoundingClientRect(),
|
|
35
|
+
forceClose: M
|
|
36
|
+
});
|
|
37
|
+
s(e);
|
|
38
|
+
});
|
|
39
|
+
let P = {
|
|
40
|
+
open: m,
|
|
41
|
+
disabled: h,
|
|
42
|
+
contentId: `tooltip-${o()}`,
|
|
43
|
+
reference: g,
|
|
44
|
+
setReference: _,
|
|
45
|
+
floating: v,
|
|
46
|
+
setFloating: y,
|
|
47
|
+
requestOpen: O,
|
|
48
|
+
requestClose: k,
|
|
49
|
+
openImmediate: A,
|
|
50
|
+
closeImmediate: j,
|
|
51
|
+
keepOpen: N,
|
|
52
|
+
pendingSlideFrom: b,
|
|
53
|
+
clearPendingSlideFrom: () => x(void 0),
|
|
54
|
+
suppressExitAnimation: S,
|
|
55
|
+
consumeSuppressExitAnimation: () => {
|
|
56
|
+
let e = S();
|
|
57
|
+
return e && C(!1), e;
|
|
58
|
+
}
|
|
20
59
|
};
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
}), t(e.Provider, {
|
|
24
|
-
value: u,
|
|
60
|
+
return n(e.Provider, {
|
|
61
|
+
value: P,
|
|
25
62
|
get children() {
|
|
26
|
-
return
|
|
63
|
+
return u.children;
|
|
27
64
|
}
|
|
28
65
|
});
|
|
29
|
-
}
|
|
66
|
+
}
|
|
30
67
|
//#endregion
|
|
31
|
-
export {
|
|
68
|
+
export { u as Tooltip };
|
|
32
69
|
|
|
33
70
|
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","names":["createSignal","createUniqueId","onCleanup","
|
|
1
|
+
{"version":3,"file":"Tooltip.js","names":["createSignal","createMemo","createUniqueId","createEffect","onCleanup","JSX","TooltipContext","useTooltipGroupContext","TooltipContextValue","TooltipProps","Rect","DEFAULT_OPEN_DELAY","DEFAULT_CLOSE_DELAY","Tooltip","props","Element","group","internalOpen","setInternalOpen","defaultOpen","open","undefined","disabled","reference","setReference","floating","setFloating","HTMLElement","pendingSlideFrom","setPendingSlideFrom","suppressExitAnimation","setSuppressExitAnimation","commit","next","onOpenChange","openTimer","closeTimer","clearTimers","window","clearTimeout","requestOpen","claimedRect","claim","setTimeout","openDelay","requestClose","closeDelay","openImmediate","closeImmediate","forceCloseForGroup","keepOpen","unregister","registerActive","rect","getBoundingClientRect","forceClose","contentId","ctx","clearPendingSlideFrom","consumeSuppressExitAnimation","value","_$createComponent","Provider","children"],"sources":["../../../../src/components/tooltip/Tooltip/Tooltip.tsx"],"sourcesContent":["import {\n createSignal,\n createMemo,\n createUniqueId,\n createEffect,\n onCleanup,\n type JSX,\n} from \"solid-js\";\nimport { TooltipContext } from \"./Tooltip.context\";\nimport { useTooltipGroupContext } from \"../TooltipGroup/TooltipGroup.context\";\nimport type { TooltipContextValue, TooltipProps } from \"./Tooltip.types\";\nimport type { Rect } from \"~/lib\";\n\nconst DEFAULT_OPEN_DELAY = 300;\nconst DEFAULT_CLOSE_DELAY = 150;\n\n/**\n * Tooltip 根组件:不渲染任何 DOM,只负责状态管理 + 提供 context。\n * 真正的展示交给 <TooltipTrigger>/<TooltipContent>/<TooltipArrow>。\n *\n * 如果外面包了 <TooltipGroup>,组内相邻 trigger 之间切换 hover 会跳过\n * openDelay,并触发\"从旧位置滑到新位置\"的过渡(细节见 TooltipGroup.context.ts)。\n *\n * @example\n * ```tsx\n * <Tooltip openDelay={300}>\n * <TooltipTrigger>悬停我</TooltipTrigger>\n * <TooltipContent>\n * 提示内容\n * <TooltipArrow />\n * </TooltipContent>\n * </Tooltip>\n * ```\n */\nexport function Tooltip(props: TooltipProps): JSX.Element {\n const group = useTooltipGroupContext(); // undefined 是正常情况,代表没用 TooltipGroup\n\n const [internalOpen, setInternalOpen] = createSignal(\n props.defaultOpen ?? false,\n );\n const open = createMemo(() =>\n props.open !== undefined ? props.open : internalOpen(),\n );\n const disabled = createMemo(() => !!props.disabled);\n\n const [reference, setReference] = createSignal<Element>();\n const [floating, setFloating] = createSignal<HTMLElement>();\n const [pendingSlideFrom, setPendingSlideFrom] = createSignal<Rect>();\n const [suppressExitAnimation, setSuppressExitAnimation] = createSignal(false);\n\n const commit = (next: boolean) => {\n if (props.open === undefined) setInternalOpen(next);\n props.onOpenChange?.(next);\n };\n\n // 用 window.setTimeout/clearTimeout(而不是裸的全局 setTimeout)显式拿到\n // DOM lib 的重载(返回 number),避免和 @types/node 的 NodeJS.Timeout 重载冲突。\n let openTimer: number | undefined;\n let closeTimer: number | undefined;\n\n const clearTimers = () => {\n if (openTimer !== undefined) {\n window.clearTimeout(openTimer);\n openTimer = undefined;\n }\n if (closeTimer !== undefined) {\n window.clearTimeout(closeTimer);\n closeTimer = undefined;\n }\n };\n\n const requestOpen = () => {\n clearTimers();\n if (disabled() || open()) return;\n\n // 组内抢占:如果当前组里已经有一个活跃的 tooltip(哪怕它还在自己的\n // closeDelay 倒计时里,还没真正关闭),claim() 会立即强制关闭它、\n // 把它此刻的矩形要回来——这里直接跳过 openDelay,走\"滑入\"路径。\n const claimedRect = group?.claim();\n if (claimedRect) {\n setPendingSlideFrom(claimedRect);\n commit(true);\n return;\n }\n\n openTimer = window.setTimeout(\n () => commit(true),\n props.openDelay ?? DEFAULT_OPEN_DELAY,\n );\n };\n\n const requestClose = () => {\n clearTimers();\n closeTimer = window.setTimeout(\n () => commit(false),\n props.closeDelay ?? DEFAULT_CLOSE_DELAY,\n );\n };\n\n const openImmediate = () => {\n if (disabled()) return;\n clearTimers();\n commit(true);\n };\n\n const closeImmediate = () => {\n clearTimers();\n commit(false);\n };\n\n /**\n * 专门给 <TooltipGroup> 抢占用的关闭方式:和 closeImmediate 的区别是,\n * 这里会额外标记 suppressExitAnimation,告诉 TooltipContent 的 Presence\n * 逻辑跳过退场动画、立即卸载——因为这次关闭是\"被新 tooltip 取代\",而不是\n * 用户主动关闭,旧的应该立刻让位,不该和正在滑入的新 tooltip 同时可见。\n * Escape/blur 等正常关闭场景依然走 closeImmediate,退场动画不受影响。\n */\n const forceCloseForGroup = () => {\n setSuppressExitAnimation(true);\n clearTimers();\n commit(false);\n };\n\n const keepOpen = () => {\n if (closeTimer !== undefined) {\n window.clearTimeout(closeTimer);\n closeTimer = undefined;\n }\n };\n\n onCleanup(clearTimers);\n\n // 打开期间把自己登记成\"组内当前活跃的 tooltip\",供其他 trigger 打开时\n // claim 走(触发平移过渡)。关闭或卸载时自动取消登记。\n createEffect(() => {\n if (!group || !open()) return;\n const unregister = group.registerActive({\n rect: () => floating()?.getBoundingClientRect(),\n forceClose: forceCloseForGroup,\n });\n onCleanup(unregister);\n });\n\n const contentId = `tooltip-${createUniqueId()}`;\n\n const ctx: TooltipContextValue = {\n open,\n disabled,\n contentId,\n reference,\n setReference,\n floating,\n setFloating,\n requestOpen,\n requestClose,\n openImmediate,\n closeImmediate,\n keepOpen,\n pendingSlideFrom,\n clearPendingSlideFrom: () => setPendingSlideFrom(undefined),\n suppressExitAnimation,\n consumeSuppressExitAnimation: () => {\n const value = suppressExitAnimation();\n if (value) setSuppressExitAnimation(false);\n return value;\n },\n };\n\n return (\n <TooltipContext.Provider value={ctx}>\n {props.children}\n </TooltipContext.Provider>\n );\n}\n"],"mappings":";;;;;AAaA,IAAMW,IAAqB,KACrBC,IAAsB;AAoB5B,SAAgBC,EAAQC,GAAkC;CACxD,IAAME,IAAQT,EAAuB,GAE/B,CAACU,GAAcC,KAAmBlB,EACtCc,EAAMK,eAAe,EACvB,GACMC,IAAOnB,QACXa,EAAMM,SAASC,KAAAA,IAAyBJ,EAAa,IAA1BH,EAAMM,IACnC,GACME,IAAWrB,QAAiB,CAAC,CAACa,EAAMQ,QAAQ,GAE5C,CAACC,GAAWC,KAAgBxB,EAAsB,GAClD,CAACyB,GAAUC,KAAe1B,EAA0B,GACpD,CAAC4B,GAAkBC,KAAuB7B,EAAmB,GAC7D,CAAC8B,GAAuBC,KAA4B/B,EAAa,EAAK,GAEtEgC,KAAUC,MAAkB;EAEhCnB,AADIA,EAAMM,SAASC,KAAAA,KAAWH,EAAgBe,CAAI,GAClDnB,EAAMoB,eAAeD,CAAI;CAC3B,GAIIE,GACAC,GAEEC,UAAoB;EAKxB,AAJIF,MAAcd,KAAAA,MAChBiB,OAAOC,aAAaJ,CAAS,GAC7BA,IAAYd,KAAAA,IAEVe,MAAef,KAAAA,MACjBiB,OAAOC,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AC,EACGvD,EAAewD,UAAQ;EAACF,OAAOH;EAAG,IAAAM,WAAA;GAAA,OAChCjD,EAAMiD;EAAQ;CAAA,CAAA;AAGrB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Accessor, ParentProps } from 'solid-js';
|
|
2
|
+
import { Rect } from '../../../lib';
|
|
3
|
+
export interface TooltipProps extends ParentProps {
|
|
4
|
+
/** 受控 open 状态;不传则内部自管理(非受控模式) */
|
|
5
|
+
open?: boolean;
|
|
6
|
+
/** 非受控模式下的初始状态,默认 false */
|
|
7
|
+
defaultOpen?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
/**
|
|
10
|
+
* 鼠标悬停多久后打开(ms)。键盘 focus 打开不受这个延迟影响——
|
|
11
|
+
* 无障碍角度看,键盘用户不应该被迫等待,所以 focus 走 openImmediate。
|
|
12
|
+
* 默认 700,贴近系统 tooltip 的习惯延迟。
|
|
13
|
+
*/
|
|
14
|
+
openDelay?: number;
|
|
15
|
+
/**
|
|
16
|
+
* 鼠标移出后多久关闭(ms),留出时间让用户把鼠标移动到 tooltip 内容上
|
|
17
|
+
* (比如内容里有可以选中复制的文字)。默认 150。
|
|
18
|
+
*/
|
|
19
|
+
closeDelay?: number;
|
|
20
|
+
/** 禁用整个 tooltip(trigger 上也可以单独再禁用) */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface TooltipContextValue {
|
|
24
|
+
open: Accessor<boolean>;
|
|
25
|
+
disabled: Accessor<boolean>;
|
|
26
|
+
/** 用于 trigger 的 aria-describedby 和 content 的 id 关联 */
|
|
27
|
+
contentId: string;
|
|
28
|
+
reference: Accessor<Element | undefined>;
|
|
29
|
+
setReference: (el: Element) => void;
|
|
30
|
+
floating: Accessor<HTMLElement | undefined>;
|
|
31
|
+
setFloating: (el: HTMLElement | undefined) => void;
|
|
32
|
+
/** 按 openDelay 延迟打开;已经打开则不做任何事,只清掉可能存在的关闭计时器 */
|
|
33
|
+
requestOpen: () => void;
|
|
34
|
+
/** 按 closeDelay 延迟关闭 */
|
|
35
|
+
requestClose: () => void;
|
|
36
|
+
/** 跳过延迟立即打开(键盘 focus 场景) */
|
|
37
|
+
openImmediate: () => void;
|
|
38
|
+
/** 跳过延迟立即关闭(Escape / blur 场景) */
|
|
39
|
+
closeImmediate: () => void;
|
|
40
|
+
/** 取消任何待执行的关闭计时器,但不改变当前状态(鼠标移到 content 上时用) */
|
|
41
|
+
keepOpen: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* 命中 <TooltipGroup> 的"抢占"时,记录被抢占的旧 tooltip 此刻的矩形——
|
|
44
|
+
* TooltipContent 用它计算出一个初始偏移量,做"从旧位置滑到新位置"的过渡,
|
|
45
|
+
* 消费一次之后应该调用 clearPendingSlideFrom 清空,避免后续 autoUpdate
|
|
46
|
+
* 重新定位(比如滚动、窗口 resize)时又误触发一次滑入动画。
|
|
47
|
+
*/
|
|
48
|
+
pendingSlideFrom: Accessor<Rect | undefined>;
|
|
49
|
+
clearPendingSlideFrom: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* 被 <TooltipGroup> 抢占强制关闭时会置为 true——TooltipContent 的 Presence
|
|
52
|
+
* 逻辑据此判断这次关闭要不要跳过退场动画、立即卸载(避免和正在滑入的新
|
|
53
|
+
* tooltip 同时出现在屏幕上)。consumeSuppressExitAnimation 读取的同时会
|
|
54
|
+
* 把它重置为 false,只消费一次,不影响后续正常关闭时的退场动画。
|
|
55
|
+
*/
|
|
56
|
+
suppressExitAnimation: Accessor<boolean>;
|
|
57
|
+
consumeSuppressExitAnimation: () => boolean;
|
|
58
|
+
}
|