@endfield-ui/react 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +4 -3
- package/README.md +32 -5
- package/dist/components/accordion/Accordion.d.ts +46 -0
- package/dist/components/accordion/Accordion.js +2 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/alert/Alert.d.ts +28 -0
- package/dist/components/alert/Alert.js +2 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/avatar/Avatar.d.ts +24 -0
- package/dist/components/avatar/Avatar.js +2 -0
- package/dist/components/avatar/AvatarSwitcher.d.ts +46 -0
- package/dist/components/avatar/AvatarSwitcher.js +2 -0
- package/dist/components/avatar/index.d.ts +4 -0
- package/dist/components/back-to-top/BackToTop.d.ts +21 -0
- package/dist/components/back-to-top/BackToTop.js +2 -0
- package/dist/components/back-to-top/index.d.ts +3 -0
- package/dist/components/badge/Badge.d.ts +20 -0
- package/dist/components/badge/Badge.js +2 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/bracket-title/BracketTitle.d.ts +17 -0
- package/dist/components/bracket-title/BracketTitle.js +2 -0
- package/dist/components/bracket-title/index.d.ts +3 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +26 -0
- package/dist/components/breadcrumb/Breadcrumb.js +2 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/button/Button.d.ts +50 -0
- package/dist/components/button/Button.js +2 -0
- package/dist/components/button/ButtonGroup.d.ts +21 -0
- package/dist/components/button/ButtonGroup.js +2 -0
- package/dist/components/button/index.d.ts +4 -0
- package/dist/components/calendar/Calendar.d.ts +57 -0
- package/dist/components/calendar/Calendar.js +2 -0
- package/dist/components/calendar/index.d.ts +3 -0
- package/dist/components/carousel/Carousel.d.ts +38 -0
- package/dist/components/carousel/Carousel.js +2 -0
- package/dist/components/carousel/index.d.ts +3 -0
- package/dist/components/carousel/snap-track.js +2 -0
- package/dist/components/checkbox/Checkbox.d.ts +18 -0
- package/dist/components/checkbox/Checkbox.js +2 -0
- package/dist/components/checkbox/choice-style.js +2 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/chip/FilterChip.d.ts +18 -0
- package/dist/components/chip/FilterChip.js +2 -0
- package/dist/components/chip/ResourceChip.d.ts +16 -0
- package/dist/components/chip/ResourceChip.js +2 -0
- package/dist/components/chip/capsule-style.d.ts +4 -0
- package/dist/components/chip/capsule-style.js +2 -0
- package/dist/components/chip/index.d.ts +4 -0
- package/dist/components/combobox/Combobox.d.ts +105 -0
- package/dist/components/combobox/Combobox.js +2 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/completion-banner/CompletionBanner.d.ts +26 -0
- package/dist/components/completion-banner/CompletionBanner.js +2 -0
- package/dist/components/completion-banner/index.d.ts +3 -0
- package/dist/components/context-menu/ContextMenu.d.ts +30 -0
- package/dist/components/context-menu/ContextMenu.js +2 -0
- package/dist/components/context-menu/index.d.ts +3 -0
- package/dist/components/corner-brackets/CornerBrackets.d.ts +20 -0
- package/dist/components/corner-brackets/CornerBrackets.js +2 -0
- package/dist/components/corner-brackets/index.d.ts +3 -0
- package/dist/components/countdown/Countdown.d.ts +26 -0
- package/dist/components/countdown/Countdown.js +2 -0
- package/dist/components/countdown/index.d.ts +3 -0
- package/dist/components/dash-indicator/DashIndicator.d.ts +15 -0
- package/dist/components/dash-indicator/DashIndicator.js +2 -0
- package/dist/components/dash-indicator/index.d.ts +3 -0
- package/dist/components/data-row/DataRow.d.ts +58 -0
- package/dist/components/data-row/DataRow.js +2 -0
- package/dist/components/data-row/index.d.ts +3 -0
- package/dist/components/date-picker/DateField.js +2 -0
- package/dist/components/date-picker/DatePicker.d.ts +56 -0
- package/dist/components/date-picker/DatePicker.js +2 -0
- package/dist/components/date-picker/DateRangePicker.d.ts +57 -0
- package/dist/components/date-picker/DateRangePicker.js +2 -0
- package/dist/components/date-picker/index.d.ts +4 -0
- package/dist/components/dialog/Dialog.d.ts +55 -0
- package/dist/components/dialog/Dialog.js +2 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dialog/initial-focus.js +2 -0
- package/dist/components/dialog/overlay-style.js +2 -0
- package/dist/components/drawer/Drawer.d.ts +48 -0
- package/dist/components/drawer/Drawer.js +2 -0
- package/dist/components/drawer/index.d.ts +3 -0
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +115 -0
- package/dist/components/dropdown-menu/DropdownMenu.js +2 -0
- package/dist/components/dropdown-menu/MenuCheck.js +2 -0
- package/dist/components/dropdown-menu/index.d.ts +3 -0
- package/dist/components/dropdown-menu/menu-style.d.ts +4 -0
- package/dist/components/dropdown-menu/menu-style.js +2 -0
- package/dist/components/empty-state/EmptyState.d.ts +22 -0
- package/dist/components/empty-state/EmptyState.js +2 -0
- package/dist/components/empty-state/index.d.ts +3 -0
- package/dist/components/field/Field.d.ts +58 -0
- package/dist/components/field/Field.js +2 -0
- package/dist/components/field/index.d.ts +3 -0
- package/dist/components/file-upload/FileItem.d.ts +50 -0
- package/dist/components/file-upload/FileItem.js +2 -0
- package/dist/components/file-upload/FileUpload.d.ts +82 -0
- package/dist/components/file-upload/FileUpload.js +2 -0
- package/dist/components/file-upload/index.d.ts +4 -0
- package/dist/components/flyout-bar/FlyoutBar.d.ts +46 -0
- package/dist/components/flyout-bar/FlyoutBar.js +2 -0
- package/dist/components/flyout-bar/index.d.ts +3 -0
- package/dist/components/ghost-text/GhostText.d.ts +21 -0
- package/dist/components/ghost-text/GhostText.js +2 -0
- package/dist/components/ghost-text/index.d.ts +3 -0
- package/dist/components/hatch/Hatch.d.ts +18 -0
- package/dist/components/hatch/Hatch.js +2 -0
- package/dist/components/hatch/index.d.ts +3 -0
- package/dist/components/hazard-stripe/HazardStripe.d.ts +15 -0
- package/dist/components/hazard-stripe/HazardStripe.js +2 -0
- package/dist/components/hazard-stripe/index.d.ts +3 -0
- package/dist/components/hover-card/HoverCard.d.ts +35 -0
- package/dist/components/hover-card/HoverCard.js +2 -0
- package/dist/components/hover-card/index.d.ts +3 -0
- package/dist/components/icon-button/IconButton.d.ts +21 -0
- package/dist/components/icon-button/IconButton.js +2 -0
- package/dist/components/icon-button/index.d.ts +3 -0
- package/dist/components/image-viewer/ImageViewer.d.ts +48 -0
- package/dist/components/image-viewer/ImageViewer.js +2 -0
- package/dist/components/image-viewer/index.d.ts +3 -0
- package/dist/components/input/Input.d.ts +27 -0
- package/dist/components/input/Input.js +2 -0
- package/dist/components/input/control-box.d.ts +5 -0
- package/dist/components/input/control-box.js +2 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/value-chip.js +2 -0
- package/dist/components/item-slot/ItemGrid.d.ts +12 -0
- package/dist/components/item-slot/ItemGrid.js +2 -0
- package/dist/components/item-slot/ItemSlot.d.ts +54 -0
- package/dist/components/item-slot/ItemSlot.js +2 -0
- package/dist/components/item-slot/index.d.ts +4 -0
- package/dist/components/kbd/Kbd.d.ts +15 -0
- package/dist/components/kbd/Kbd.js +2 -0
- package/dist/components/kbd/index.d.ts +3 -0
- package/dist/components/link-element/LinkElement.d.ts +6 -0
- package/dist/components/link-element/LinkElement.js +2 -0
- package/dist/components/list/List.d.ts +46 -0
- package/dist/components/list/List.js +2 -0
- package/dist/components/list/band-style.js +2 -0
- package/dist/components/list/index.d.ts +3 -0
- package/dist/components/loader/Loader.d.ts +23 -0
- package/dist/components/loader/Loader.js +2 -0
- package/dist/components/loader/index.d.ts +3 -0
- package/dist/components/marquee/Marquee.d.ts +22 -0
- package/dist/components/marquee/Marquee.js +2 -0
- package/dist/components/marquee/index.d.ts +3 -0
- package/dist/components/media-card/MediaCard.d.ts +36 -0
- package/dist/components/media-card/MediaCard.js +2 -0
- package/dist/components/media-card/index.d.ts +3 -0
- package/dist/components/nav-action/NavAction.d.ts +34 -0
- package/dist/components/nav-action/NavAction.js +2 -0
- package/dist/components/nav-action/index.d.ts +3 -0
- package/dist/components/nav-menu/NavMenu.d.ts +57 -0
- package/dist/components/nav-menu/NavMenu.js +2 -0
- package/dist/components/nav-menu/index.d.ts +3 -0
- package/dist/components/navigator/Navigator.d.ts +27 -0
- package/dist/components/navigator/Navigator.js +2 -0
- package/dist/components/navigator/index.d.ts +3 -0
- package/dist/components/otp-input/OtpInput.d.ts +52 -0
- package/dist/components/otp-input/OtpInput.js +2 -0
- package/dist/components/otp-input/index.d.ts +3 -0
- package/dist/components/page-header/PageHeader.d.ts +56 -0
- package/dist/components/page-header/PageHeader.js +2 -0
- package/dist/components/page-header/index.d.ts +3 -0
- package/dist/components/pagination/Pagination.d.ts +29 -0
- package/dist/components/pagination/Pagination.js +2 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/panel/Panel.d.ts +36 -0
- package/dist/components/panel/Panel.js +2 -0
- package/dist/components/panel/index.d.ts +3 -0
- package/dist/components/play-button/PlayButton.d.ts +20 -0
- package/dist/components/play-button/PlayButton.js +2 -0
- package/dist/components/play-button/index.d.ts +3 -0
- package/dist/components/popover/Popover.d.ts +36 -0
- package/dist/components/popover/Popover.js +2 -0
- package/dist/components/popover/index.d.ts +3 -0
- package/dist/components/popover/panel-style.js +2 -0
- package/dist/components/progress/Progress.d.ts +27 -0
- package/dist/components/progress/Progress.js +2 -0
- package/dist/components/progress/ProgressRing.d.ts +23 -0
- package/dist/components/progress/ProgressRing.js +2 -0
- package/dist/components/progress/index.d.ts +4 -0
- package/dist/components/radio/Radio.d.ts +33 -0
- package/dist/components/radio/Radio.js +2 -0
- package/dist/components/radio/index.d.ts +3 -0
- package/dist/components/rec-indicator/RecIndicator.d.ts +16 -0
- package/dist/components/rec-indicator/RecIndicator.js +2 -0
- package/dist/components/rec-indicator/index.d.ts +3 -0
- package/dist/components/registration-strip/RegistrationStrip.d.ts +16 -0
- package/dist/components/registration-strip/RegistrationStrip.js +2 -0
- package/dist/components/registration-strip/index.d.ts +3 -0
- package/dist/components/rolling-number/RollingNumber.d.ts +25 -0
- package/dist/components/rolling-number/RollingNumber.js +2 -0
- package/dist/components/rolling-number/index.d.ts +3 -0
- package/dist/components/schedule/Schedule.d.ts +78 -0
- package/dist/components/schedule/Schedule.js +2 -0
- package/dist/components/schedule/index.d.ts +3 -0
- package/dist/components/scroll-area/ScrollArea.d.ts +26 -0
- package/dist/components/scroll-area/ScrollArea.js +2 -0
- package/dist/components/scroll-area/index.d.ts +3 -0
- package/dist/components/scroll-hint/ScrollHint.d.ts +23 -0
- package/dist/components/scroll-hint/ScrollHint.js +2 -0
- package/dist/components/scroll-hint/index.d.ts +3 -0
- package/dist/components/section-title/SectionTitle.d.ts +33 -0
- package/dist/components/section-title/SectionTitle.js +2 -0
- package/dist/components/section-title/index.d.ts +3 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts +49 -0
- package/dist/components/segmented-control/SegmentedControl.js +2 -0
- package/dist/components/segmented-control/index.d.ts +3 -0
- package/dist/components/select/Select.d.ts +95 -0
- package/dist/components/select/Select.js +2 -0
- package/dist/components/select/index.d.ts +3 -0
- package/dist/components/side-rail/SideRail.d.ts +62 -0
- package/dist/components/side-rail/SideRail.js +2 -0
- package/dist/components/side-rail/SideRailSub.d.ts +47 -0
- package/dist/components/side-rail/SideRailSub.js +2 -0
- package/dist/components/side-rail/index.d.ts +4 -0
- package/dist/components/skeleton/Skeleton.d.ts +22 -0
- package/dist/components/skeleton/Skeleton.js +2 -0
- package/dist/components/skeleton/index.d.ts +3 -0
- package/dist/components/slider/Slider.d.ts +63 -0
- package/dist/components/slider/Slider.js +2 -0
- package/dist/components/slider/index.d.ts +3 -0
- package/dist/components/sparkline/Sparkline.d.ts +32 -0
- package/dist/components/sparkline/Sparkline.js +2 -0
- package/dist/components/sparkline/index.d.ts +3 -0
- package/dist/components/spinner/Spinner.d.ts +19 -0
- package/dist/components/spinner/Spinner.js +2 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/splash-screen/SplashScreen.d.ts +43 -0
- package/dist/components/splash-screen/SplashScreen.js +2 -0
- package/dist/components/splash-screen/index.d.ts +3 -0
- package/dist/components/stat/Stat.d.ts +22 -0
- package/dist/components/stat/Stat.js +2 -0
- package/dist/components/stat/index.d.ts +3 -0
- package/dist/components/stepper/Stepper.d.ts +29 -0
- package/dist/components/stepper/Stepper.js +2 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/steps/Steps.d.ts +55 -0
- package/dist/components/steps/Steps.js +2 -0
- package/dist/components/steps/index.d.ts +3 -0
- package/dist/components/switch/Switch.d.ts +28 -0
- package/dist/components/switch/Switch.js +2 -0
- package/dist/components/switch/index.d.ts +3 -0
- package/dist/components/table/Table.d.ts +96 -0
- package/dist/components/table/Table.js +2 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/tabs/Tabs.d.ts +39 -0
- package/dist/components/tabs/Tabs.js +2 -0
- package/dist/components/tabs/index.d.ts +3 -0
- package/dist/components/tag/Tag.d.ts +25 -0
- package/dist/components/tag/Tag.js +2 -0
- package/dist/components/tag/TagPair.d.ts +16 -0
- package/dist/components/tag/TagPair.js +2 -0
- package/dist/components/tag/index.d.ts +4 -0
- package/dist/components/tag-input/TagInput.d.ts +66 -0
- package/dist/components/tag-input/TagInput.js +3 -0
- package/dist/components/tag-input/index.d.ts +3 -0
- package/dist/components/term/Term.d.ts +19 -0
- package/dist/components/term/Term.js +2 -0
- package/dist/components/term/index.d.ts +3 -0
- package/dist/components/textarea/Textarea.d.ts +17 -0
- package/dist/components/textarea/Textarea.js +2 -0
- package/dist/components/textarea/index.d.ts +3 -0
- package/dist/components/texture/Texture.d.ts +19 -0
- package/dist/components/texture/Texture.js +2 -0
- package/dist/components/texture/index.d.ts +3 -0
- package/dist/components/tick-ring/TickRing.d.ts +22 -0
- package/dist/components/tick-ring/TickRing.js +2 -0
- package/dist/components/tick-ring/index.d.ts +3 -0
- package/dist/components/timeline/Timeline.d.ts +22 -0
- package/dist/components/timeline/Timeline.js +2 -0
- package/dist/components/timeline/index.d.ts +3 -0
- package/dist/components/toast/Toast.d.ts +45 -0
- package/dist/components/toast/Toast.js +2 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toc/Toc.d.ts +46 -0
- package/dist/components/toc/Toc.js +2 -0
- package/dist/components/toc/index.d.ts +3 -0
- package/dist/components/toolbar/Toolbar.d.ts +97 -0
- package/dist/components/toolbar/Toolbar.js +2 -0
- package/dist/components/toolbar/index.d.ts +3 -0
- package/dist/components/tooltip/Tooltip.d.ts +47 -0
- package/dist/components/tooltip/Tooltip.js +2 -0
- package/dist/components/tooltip/index.d.ts +3 -0
- package/dist/components/top-bar/TopBar.d.ts +21 -0
- package/dist/components/top-bar/TopBar.js +2 -0
- package/dist/components/top-bar/index.d.ts +3 -0
- package/dist/components/viewfinder/Viewfinder.d.ts +35 -0
- package/dist/components/viewfinder/Viewfinder.js +2 -0
- package/dist/components/viewfinder/index.d.ts +3 -0
- package/dist/game/animated-dialog/AnimatedDialog.d.ts +53 -0
- package/dist/game/animated-dialog/AnimatedDialog.js +2 -0
- package/dist/game/animated-dialog/index.d.ts +3 -0
- package/dist/game/assets/splash_bg.jpg +0 -0
- package/dist/game/assets/splash_bg_portrait.jpg +0 -0
- package/dist/game/assets/splash_deco.svg +4 -0
- package/dist/game/assets/splash_logo.svg +1 -0
- package/dist/game/assets/splash_triangles.svg +4 -0
- package/dist/game/banner-alert/AlertIcons.js +2 -0
- package/dist/game/banner-alert/AlertModal.js +2 -0
- package/dist/game/banner-alert/BannerAlert.d.ts +6 -0
- package/dist/game/banner-alert/BannerAlert.js +2 -0
- package/dist/game/banner-alert/index.d.ts +3 -0
- package/dist/game/banner-alert/types.d.ts +48 -0
- package/dist/game/banner-alert/types.js +2 -0
- package/dist/game/banner-alert/useAlertActions.js +2 -0
- package/dist/game/banner-alert/useAlertGlitch.js +2 -0
- package/dist/game/full-width-alert/FullWidthAlert.d.ts +7 -0
- package/dist/game/full-width-alert/FullWidthAlert.js +2 -0
- package/dist/game/full-width-alert/index.d.ts +3 -0
- package/dist/game/item-card/ItemCard.d.ts +48 -0
- package/dist/game/item-card/ItemCard.js +2 -0
- package/dist/game/item-card/index.d.ts +3 -0
- package/dist/game/item-hover-card/ItemHoverCard.d.ts +31 -0
- package/dist/game/item-hover-card/ItemHoverCard.js +2 -0
- package/dist/game/item-hover-card/events.js +2 -0
- package/dist/game/item-hover-card/index.d.ts +3 -0
- package/dist/game/item-icon/ItemIcon.d.ts +5 -0
- package/dist/game/item-icon/ItemIcon.js +2 -0
- package/dist/game/item-icon/helpers.d.ts +22 -0
- package/dist/game/item-icon/helpers.js +2 -0
- package/dist/game/item-icon/index.d.ts +5 -0
- package/dist/game/item-icon/types.d.ts +32 -0
- package/dist/game/item-tooltip-card/ItemTooltipCard.d.ts +6 -0
- package/dist/game/item-tooltip-card/ItemTooltipCard.js +2 -0
- package/dist/game/item-tooltip-card/icons.js +2 -0
- package/dist/game/item-tooltip-card/index.d.ts +4 -0
- package/dist/game/item-tooltip-card/types.d.ts +40 -0
- package/dist/game/lib/core.d.ts +8 -0
- package/dist/game/lib/first-focusable.js +2 -0
- package/dist/game/resource-provenance.json +70 -1
- package/dist/game/rounded-button/RoundedButton.d.ts +22 -0
- package/dist/game/rounded-button/RoundedButton.js +2 -0
- package/dist/game/rounded-button/RoundedIconButton.d.ts +10 -0
- package/dist/game/rounded-button/RoundedIconButton.js +2 -0
- package/dist/game/rounded-button/index.d.ts +4 -0
- package/dist/game/rounded-select/RoundedSelect.d.ts +43 -0
- package/dist/game/rounded-select/RoundedSelect.js +2 -0
- package/dist/game/rounded-select/index.d.ts +3 -0
- package/dist/game/rounded-switch/RoundedSwitch.d.ts +16 -0
- package/dist/game/rounded-switch/RoundedSwitch.js +2 -0
- package/dist/game/rounded-switch/index.d.ts +3 -0
- package/dist/game/rounded-toggle/RoundedToggle.d.ts +23 -0
- package/dist/game/rounded-toggle/RoundedToggle.js +2 -0
- package/dist/game/rounded-toggle/index.d.ts +3 -0
- package/dist/game/rounded-toggle/keyboard.js +2 -0
- package/dist/game/rounded-toggle/spring-highlight.js +2 -0
- package/dist/game/splash-screen/EndfieldSplashScreen.d.ts +14 -0
- package/dist/game/splash-screen/EndfieldSplashScreen.js +2 -0
- package/dist/game/splash-screen/index.d.ts +3 -0
- package/dist/game/styles.css +1 -1
- package/dist/game.d.ts +29 -371
- package/dist/game.js +1 -2041
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useAddedKeys.js +2 -0
- package/dist/hooks/useControllableState.d.ts +12 -0
- package/dist/hooks/useControllableState.js +2 -0
- package/dist/hooks/useFlip.js +2 -0
- package/dist/hooks/useInView.d.ts +15 -0
- package/dist/hooks/useInView.js +2 -0
- package/dist/hooks/useIndicator.js +2 -0
- package/dist/hooks/useLingering.js +2 -0
- package/dist/hooks/useOverflowing.js +2 -0
- package/dist/hooks/usePortalScope.d.ts +26 -0
- package/dist/hooks/usePortalScope.js +2 -0
- package/dist/hooks/usePresence.js +2 -0
- package/dist/hooks/useReducedMotion.d.ts +10 -0
- package/dist/hooks/useReducedMotion.js +2 -0
- package/dist/hooks/useScrollPosition.js +2 -0
- package/dist/hooks/useTheme.d.ts +21 -0
- package/dist/hooks/useTheme.js +2 -0
- package/dist/icons/ArrowCorner.d.ts +9 -0
- package/dist/icons/ArrowCorner.js +2 -0
- package/dist/icons/ArrowLeft.d.ts +8 -0
- package/dist/icons/ArrowLeft.js +2 -0
- package/dist/icons/ArrowRight.d.ts +8 -0
- package/dist/icons/ArrowRight.js +2 -0
- package/dist/icons/CalendarIcon.d.ts +12 -0
- package/dist/icons/CalendarIcon.js +2 -0
- package/dist/icons/Check.d.ts +9 -0
- package/dist/icons/Check.js +2 -0
- package/dist/icons/ChevronDown.d.ts +8 -0
- package/dist/icons/ChevronDown.js +2 -0
- package/dist/icons/ChevronLeft.d.ts +8 -0
- package/dist/icons/ChevronLeft.js +2 -0
- package/dist/icons/ChevronRight.d.ts +8 -0
- package/dist/icons/ChevronRight.js +2 -0
- package/dist/icons/Close.d.ts +8 -0
- package/dist/icons/Close.js +2 -0
- package/dist/icons/Crosshair.d.ts +9 -0
- package/dist/icons/Crosshair.js +2 -0
- package/dist/icons/Lock.d.ts +8 -0
- package/dist/icons/Lock.js +2 -0
- package/dist/icons/Menu.d.ts +9 -0
- package/dist/icons/Menu.js +2 -0
- package/dist/icons/Minus.d.ts +9 -0
- package/dist/icons/Minus.js +2 -0
- package/dist/icons/Plus.d.ts +8 -0
- package/dist/icons/Plus.js +2 -0
- package/dist/icons/StatusDanger.d.ts +9 -0
- package/dist/icons/StatusDanger.js +2 -0
- package/dist/icons/StatusInfo.d.ts +9 -0
- package/dist/icons/StatusInfo.js +2 -0
- package/dist/icons/StatusSuccess.d.ts +9 -0
- package/dist/icons/StatusSuccess.js +2 -0
- package/dist/icons/StatusWarning.d.ts +9 -0
- package/dist/icons/StatusWarning.js +2 -0
- package/dist/icons/TriangleRight.d.ts +9 -0
- package/dist/icons/TriangleRight.js +2 -0
- package/dist/icons/Upload.d.ts +9 -0
- package/dist/icons/Upload.js +2 -0
- package/dist/icons/createIcon.d.ts +16 -0
- package/dist/icons/createIcon.js +2 -0
- package/dist/icons/index.d.ts +23 -0
- package/dist/index.d.ts +209 -3505
- package/dist/index.js +1 -9625
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +2 -0
- package/dist/lib/create-lazy-context.js +2 -0
- package/dist/lib/date.js +2 -0
- package/dist/lib/decor.js +2 -0
- package/dist/lib/defined.js +2 -0
- package/dist/lib/file.js +2 -0
- package/dist/lib/focus-ring.js +2 -0
- package/dist/lib/inline-style.js +2 -0
- package/dist/lib/merge-refs.js +2 -0
- package/dist/lib/motion.js +2 -0
- package/dist/styles.css +1 -1
- package/package.json +17 -11
- package/src/components/accordion/Accordion.tsx +13 -5
- package/src/components/alert/Alert.tsx +1 -1
- package/src/components/avatar/AvatarSwitcher.tsx +7 -5
- package/src/components/carousel/Carousel.tsx +6 -5
- package/src/components/context-menu/ContextMenu.tsx +5 -2
- package/src/components/data-row/DataRow.tsx +10 -4
- package/src/components/date-picker/DateField.tsx +1 -3
- package/src/components/dropdown-menu/DropdownMenu.tsx +7 -4
- package/src/components/dropdown-menu/menu-style.ts +9 -3
- package/src/components/field/Field.tsx +10 -6
- package/src/components/file-upload/FileUpload.tsx +5 -2
- package/src/components/flyout-bar/FlyoutBar.tsx +1 -1
- package/src/components/image-viewer/ImageViewer.tsx +6 -5
- package/src/components/input/control-box.ts +30 -10
- package/src/components/list/List.tsx +7 -5
- package/src/components/nav-action/NavAction.tsx +4 -3
- package/src/components/nav-menu/NavMenu.tsx +13 -7
- package/src/components/otp-input/OtpInput.tsx +35 -43
- package/src/components/radio/Radio.tsx +7 -5
- package/src/components/schedule/Schedule.tsx +7 -5
- package/src/components/segmented-control/SegmentedControl.tsx +9 -7
- package/src/components/select/Select.tsx +11 -11
- package/src/components/side-rail/SideRail.tsx +15 -9
- package/src/components/side-rail/SideRailSub.tsx +12 -7
- package/src/components/splash-screen/SplashScreen.tsx +340 -0
- package/src/components/splash-screen/index.ts +1 -0
- package/src/components/steps/Steps.tsx +7 -5
- package/src/components/table/Table.tsx +23 -17
- package/src/components/tabs/Tabs.tsx +7 -5
- package/src/components/tag-input/TagInput.tsx +5 -2
- package/src/components/toast/Toast.tsx +12 -8
- package/src/components/toc/Toc.tsx +5 -4
- package/src/components/toolbar/Toolbar.tsx +7 -6
- package/src/components/tooltip/Tooltip.tsx +7 -4
- package/src/components/top-bar/TopBar.tsx +7 -2
- package/src/icons/ArrowCorner.tsx +1 -1
- package/src/icons/ArrowLeft.tsx +1 -1
- package/src/icons/ArrowRight.tsx +1 -1
- package/src/icons/CalendarIcon.tsx +1 -1
- package/src/icons/Check.tsx +4 -1
- package/src/icons/ChevronDown.tsx +4 -1
- package/src/icons/ChevronLeft.tsx +1 -1
- package/src/icons/ChevronRight.tsx +1 -1
- package/src/icons/Close.tsx +4 -1
- package/src/icons/Crosshair.tsx +1 -1
- package/src/icons/Lock.tsx +1 -1
- package/src/icons/Menu.tsx +4 -1
- package/src/icons/Minus.tsx +1 -1
- package/src/icons/Plus.tsx +4 -1
- package/src/icons/StatusDanger.tsx +1 -1
- package/src/icons/StatusInfo.tsx +1 -1
- package/src/icons/StatusSuccess.tsx +1 -1
- package/src/icons/StatusWarning.tsx +1 -1
- package/src/icons/TriangleRight.tsx +1 -1
- package/src/icons/Upload.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lib/cn.ts +1 -1
- package/src/lib/create-lazy-context.ts +6 -0
- package/src/styles/theme.css +33 -0
- package/src/styles/utilities.css +8 -0
- package/src/components/README.md +0 -190
- package/src/hooks/README.md +0 -20
- package/src/icons/README.md +0 -31
- package/src/lib/README.md +0 -19
- package/src/styles/README.md +0 -74
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
|
|
2
|
+
import { MenuVariant } from "../dropdown-menu/menu-style.js";
|
|
3
|
+
import { ControlSize, ControlVariant } from "../input/control-box.js";
|
|
4
|
+
import { ComponentProps, ReactNode, Ref } from "react";
|
|
5
|
+
//#region src/components/select/Select.d.ts
|
|
6
|
+
export type SelectSize = ControlSize;
|
|
7
|
+
export type SelectVariant = ControlVariant;
|
|
8
|
+
export type SelectOption = {
|
|
9
|
+
value: string;
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type SelectCommonProps = {
|
|
14
|
+
/**
|
|
15
|
+
* 选项。只传它就够了;需要分组时改用子元素(`SelectGroup`、`SelectItem`),
|
|
16
|
+
* 并仍然把全部选项传进来——触发器靠它在面板没打开时显示当前项的文字。
|
|
17
|
+
*/
|
|
18
|
+
items: readonly SelectOption[];
|
|
19
|
+
/** 没选时显示的文字 */
|
|
20
|
+
placeholder?: ReactNode;
|
|
21
|
+
/** 表单字段名:选中的值会随表单提交 */
|
|
22
|
+
name?: string;
|
|
23
|
+
/**
|
|
24
|
+
* 触发器的画法,和输入框相同:
|
|
25
|
+
* - `sunken` 凹陷的底 + 一条底边线,默认;
|
|
26
|
+
* - `outline` 四边描边,放在凹陷底色的区域里时用。
|
|
27
|
+
*/
|
|
28
|
+
variant?: SelectVariant;
|
|
29
|
+
/** 32 / 40 / 56px 高 */
|
|
30
|
+
size?: SelectSize;
|
|
31
|
+
/**
|
|
32
|
+
* 面板的画法:
|
|
33
|
+
* - `plain` 跟随主题,默认;
|
|
34
|
+
* - `strong` 固定的深色面板,当前项整行黄底墨字。
|
|
35
|
+
*/
|
|
36
|
+
panelVariant?: MenuVariant;
|
|
37
|
+
/** 错误态。放在 `Field` 里时跟随它的 `error` */
|
|
38
|
+
invalid?: boolean;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
open?: boolean;
|
|
42
|
+
defaultOpen?: boolean;
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
44
|
+
id?: string;
|
|
45
|
+
"aria-label"?: string;
|
|
46
|
+
"aria-describedby"?: string;
|
|
47
|
+
/** 给触发器的外框 */
|
|
48
|
+
className?: string;
|
|
49
|
+
/** 给触发按钮 */
|
|
50
|
+
ref?: Ref<HTMLButtonElement>;
|
|
51
|
+
/** 自定义面板里的内容:`SelectItem`、`SelectGroup`、`SelectSeparator` */
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
};
|
|
54
|
+
export type SelectSingleProps = SelectCommonProps & {
|
|
55
|
+
multiple?: false;
|
|
56
|
+
value?: string | null;
|
|
57
|
+
defaultValue?: string | null;
|
|
58
|
+
onValueChange?: (value: string) => void;
|
|
59
|
+
renderValue?: never;
|
|
60
|
+
};
|
|
61
|
+
export type SelectMultipleProps = SelectCommonProps & {
|
|
62
|
+
/** 可以选多项:值是数组,选项行首多一个小方格,选了不关面板 */
|
|
63
|
+
multiple: true;
|
|
64
|
+
value?: string[];
|
|
65
|
+
defaultValue?: string[];
|
|
66
|
+
onValueChange?: (value: string[]) => void;
|
|
67
|
+
/**
|
|
68
|
+
* 自己画触发器里的内容,拿到的是已选的选项(按 `items` 的顺序)。
|
|
69
|
+
* 默认把标签用顿号连起来,两项以上时后面跟一个计数。一项都没选时显示 `placeholder`
|
|
70
|
+
*/
|
|
71
|
+
renderValue?: (selected: SelectOption[]) => ReactNode;
|
|
72
|
+
};
|
|
73
|
+
export type SelectProps = SelectSingleProps | SelectMultipleProps;
|
|
74
|
+
/**
|
|
75
|
+
* 下拉选择:外观同输入框的触发器 + 一个落在它下方的面板。
|
|
76
|
+
* 每个下拉都要有标签:放进 `Field`,或者自己传 `aria-label`。
|
|
77
|
+
* 加 `multiple` 可以选多项,这时值是数组。
|
|
78
|
+
* 选项只有两三个、又都该一眼看到时,用单选或页签,不用它。
|
|
79
|
+
*/
|
|
80
|
+
export declare function Select(props: SelectProps): import("react").JSX.Element;
|
|
81
|
+
export type SelectItemProps = Omit<ComponentProps<"div">, "value" | "id" | "style"> & {
|
|
82
|
+
value: string;
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** 面板里的一个选项。只在自定义面板内容时用。 */
|
|
86
|
+
export declare function SelectItem({ value, disabled, className, children, ...props }: SelectItemProps): import("react").JSX.Element;
|
|
87
|
+
export type SelectGroupProps = Omit<ComponentProps<"div">, "style"> & {
|
|
88
|
+
/** 分组的小标题 */
|
|
89
|
+
label: ReactNode;
|
|
90
|
+
};
|
|
91
|
+
export declare function SelectGroup({ label, className, children, ...props }: SelectGroupProps): import("react").JSX.Element;
|
|
92
|
+
export type SelectSeparatorProps = Omit<ComponentProps<"div">, "style">;
|
|
93
|
+
export declare function SelectSeparator({ className, ...props }: SelectSeparatorProps): import("react").JSX.Element;
|
|
94
|
+
//#endregion
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{createLazyContext as t}from"../../lib/create-lazy-context.js";import{StatusDanger as n}from"../../icons/StatusDanger.js";import{usePortalScope as r}from"../../hooks/usePortalScope.js";import{TriangleRight as i}from"../../icons/TriangleRight.js";import{MenuCheck as a}from"../dropdown-menu/MenuCheck.js";import{getMenuVariantContext as o,menuGroupLabel as s,menuItem as c,menuItemCurrent as l,menuItemHover as u,menuPanel as d,menuSeparator as f}from"../dropdown-menu/menu-style.js";import{useFieldControl as p}from"../field/Field.js";import{controlBox as m,controlIconSize as h,controlSize as g}from"../input/control-box.js";import{Fragment as _,useContext as v,useRef as y}from"react";import{Fragment as b,jsx as x,jsxs as S}from"react/jsx-runtime";import{Select as C}from"@base-ui/react/select";const w=/* @__PURE__ */ t(!1);function T(e){return/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(`span`,{className:`min-w-0 truncate`,children:e.map((e,t)=>/* @__PURE__ */ S(_,{children:[t>0&&`、`,e.label]},e.value))}),e.length>1&&/* @__PURE__ */ S(`span`,{className:`shrink-0 font-tech text-xs text-ink-secondary tabular-nums`,children:[e.length,` 项`]})]})}function E(t){let a=o(),s=w(),{items:c,placeholder:l,name:u,variant:f=`sunken`,size:_=`md`,panelVariant:v=`plain`,invalid:E,disabled:O,required:k,open:A,defaultOpen:j,onOpenChange:M,id:N,"aria-label":P,"aria-describedby":F,className:I,ref:L,children:R}=t,{id:z,disabled:B,required:V,invalid:H,...U}=p({id:N,disabled:O,required:k,invalid:E,"aria-describedby":F}),W=y(null),{anchorRef:G,portalRef:K}=r(),q=h[_],J=t.multiple===!0,Y={items:c,name:u,disabled:B,required:V,open:A,defaultOpen:j,onOpenChange:M&&(e=>M(e))},X=/* @__PURE__ */ S(b,{children:[/* @__PURE__ */ x(`div`,{ref:e=>{W.current=e,G(e)},"data-variant":f,"data-size":_,"data-invalid":H?``:void 0,className:e(m({variant:f,invalid:H,disabled:B,readOnly:!1}),g[_],I),children:/* @__PURE__ */ S(C.Trigger,{ref:L,id:z,"aria-label":P,"aria-invalid":H||void 0,"aria-describedby":U[`aria-describedby`],className:`flex h-full min-w-0 flex-1 cursor-default items-center gap-2 pr-3 pl-3 text-left outline-none disabled:cursor-not-allowed`,children:[t.multiple?/* @__PURE__ */ x(C.Value,{className:`flex min-w-0 flex-1 items-center gap-2 data-placeholder:text-ink-tertiary`,children:e=>{let n=c.filter(t=>e.includes(t.value));return n.length===0?/* @__PURE__ */ x(`span`,{className:`min-w-0 truncate`,children:l}):(t.renderValue??T)(n)}}):/* @__PURE__ */ x(C.Value,{placeholder:l,className:`min-w-0 flex-1 truncate data-placeholder:text-ink-tertiary`}),H&&/* @__PURE__ */ x(n,{size:q,className:`shrink-0 text-danger`}),/* @__PURE__ */ x(C.Icon,{className:e(`flex shrink-0 rotate-90 transition-transform duration-(--duration-fast) ease-standard data-popup-open:-rotate-90`,B?`text-ink-disabled`:`text-ink-secondary`),children:/* @__PURE__ */ x(i,{size:q-4})})]})}),/* @__PURE__ */ x(C.Portal,{ref:K,children:/* @__PURE__ */ x(C.Positioner,{anchor:W,alignItemWithTrigger:!1,side:`bottom`,align:`start`,sideOffset:4,className:`z-(--z-overlay) outline-none`,children:/* @__PURE__ */ x(C.Popup,{"data-theme":v===`strong`?`dark`:void 0,"data-variant":v,className:e(d,`min-w-(--anchor-width)`),children:/* @__PURE__ */ x(C.List,{className:`max-h-[min(var(--available-height),20rem)] overflow-y-auto overscroll-contain`,children:/* @__PURE__ */ x(a.Provider,{value:v,children:/* @__PURE__ */ x(s.Provider,{value:J,children:R??c.map(e=>/* @__PURE__ */ x(D,{value:e.value,disabled:e.disabled,children:e.label},e.value))})})})})})})]});if(t.multiple){let{value:e,defaultValue:n,onValueChange:r}=t;return/* @__PURE__ */ x(C.Root,{...Y,multiple:!0,value:e,defaultValue:n,onValueChange:r&&(e=>r(e)),children:X})}let{value:Z,defaultValue:Q,onValueChange:$}=t;return/* @__PURE__ */ x(C.Root,{...Y,value:Z,defaultValue:Q,onValueChange:e=>{e!==null&&$?.(e)},children:X})}function D({value:t,disabled:n,className:r,children:i,...s}){let d=v(o()),f=v(w());return/* @__PURE__ */ x(C.Item,{...s,value:t,disabled:n,className:t=>e(c,f?[u,t.selected&&`font-medium`]:t.selected?l[d]:u,r),render:f?({children:e,...t},n)=>/* @__PURE__ */ S(`div`,{...t,children:[/* @__PURE__ */ x(a,{checked:n.selected,disabled:n.disabled}),e]}):void 0,children:/* @__PURE__ */ x(C.ItemText,{className:`min-w-0 flex-1 truncate`,children:i})})}function O({label:e,className:t,children:n,...r}){return/* @__PURE__ */ S(C.Group,{...r,className:t,children:[/* @__PURE__ */ x(C.GroupLabel,{className:s,children:e}),n]})}function k({className:t,...n}){return/* @__PURE__ */ x(C.Separator,{...n,className:e(f,t)})}export{E as Select,O as SelectGroup,D as SelectItem,k as SelectSeparator};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { Select, SelectGroup, SelectGroupProps, SelectItem, SelectItemProps, SelectMultipleProps, SelectOption, SelectProps, SelectSeparator, SelectSeparatorProps, SelectSingleProps, SelectSize, SelectVariant } from "./Select.js";
|
|
3
|
+
export { Select, SelectGroup, type SelectGroupProps, SelectItem, type SelectItemProps, type SelectMultipleProps, type SelectOption, type SelectProps, SelectSeparator, type SelectSeparatorProps, type SelectSingleProps, type SelectSize, type SelectVariant };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
|
|
2
|
+
import { LinkRender } from "../link-element/LinkElement.js";
|
|
3
|
+
import { ComponentProps, MouseEvent, ReactNode } from "react";
|
|
4
|
+
//#region src/components/side-rail/SideRail.d.ts
|
|
5
|
+
export type SideRailProps = Omit<ComponentProps<"nav">, "aria-label"> & {
|
|
6
|
+
/** 这块导航的名称,比如"主导航" */
|
|
7
|
+
"aria-label": string;
|
|
8
|
+
/**
|
|
9
|
+
* 收起成只有图标的窄轨(64px)。默认是展开的(224px,图标 + 文字)。
|
|
10
|
+
* 栏目少且固定、屏幕空间紧张时才收起
|
|
11
|
+
*/
|
|
12
|
+
collapsed?: boolean;
|
|
13
|
+
/** 最上面的标志。本库不带标志,传你自己的 */
|
|
14
|
+
brand?: ReactNode;
|
|
15
|
+
/** 导航项下面的工具组:几个图标按钮 */
|
|
16
|
+
tools?: ReactNode;
|
|
17
|
+
/** 主行动块:放一个 `NavAction` */
|
|
18
|
+
action?: ReactNode;
|
|
19
|
+
/** 最下面的次要入口 */
|
|
20
|
+
footer?: ReactNode;
|
|
21
|
+
/** `SideRailItem`、`SideRailGroup`、`SideRailSub` */
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 侧轨:桌面端贴在左边的主导航。自上而下是标志、导航项、工具组、主行动块、次要入口;
|
|
26
|
+
* 导航项放不下时在中间那一段里滚动。
|
|
27
|
+
*
|
|
28
|
+
* 默认 `sticky`、占满视口高;窄屏上不要把它缩小,换成 `TopBar` + `NavMenu`。
|
|
29
|
+
*/
|
|
30
|
+
export declare function SideRail({ collapsed, brand, tools, action, footer, className, children, ...props }: SideRailProps): import("react").JSX.Element;
|
|
31
|
+
type ItemOwnProps = {
|
|
32
|
+
/** 图标。收起时只剩它,所以每一项都要有 */
|
|
33
|
+
icon: ReactNode;
|
|
34
|
+
/** 当前所在的栏目:墨色 + 左缘一条短竖条,输出 `aria-current="page"` */
|
|
35
|
+
current?: boolean;
|
|
36
|
+
/** 行尾的补充:计数、角标。收起时不显示 */
|
|
37
|
+
end?: ReactNode;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** 传了就渲染成链接 */
|
|
40
|
+
href?: string;
|
|
41
|
+
target?: string;
|
|
42
|
+
rel?: string;
|
|
43
|
+
/** 用这个元素代替 `<a>`(路由库的链接组件)。传了就按链接处理 */
|
|
44
|
+
render?: LinkRender;
|
|
45
|
+
/** 没有 `href` 和 `render` 时渲染成按钮 */
|
|
46
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
47
|
+
/** 栏目的名称。收起时看不见,但仍然是这一项的可访问名称 */
|
|
48
|
+
children: ReactNode;
|
|
49
|
+
};
|
|
50
|
+
export type SideRailItemProps = ItemOwnProps & Omit<ComponentProps<"li">, keyof ItemOwnProps>;
|
|
51
|
+
/** 侧轨里的一个栏目。 */
|
|
52
|
+
export declare function SideRailItem({ icon, current, end, disabled, href, target, rel, render, onClick, children, ...props }: SideRailItemProps): import("react").JSX.Element;
|
|
53
|
+
export type SideRailGroupProps = Omit<ComponentProps<"li">, "children"> & {
|
|
54
|
+
/** 这一组的小标题。收起时换成一条短线,名称仍然读得到 */
|
|
55
|
+
label: string;
|
|
56
|
+
/** `SideRailItem` */
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
};
|
|
59
|
+
/** 把几个栏目归成一组。栏目多的时候用。它只是分组;能展开收起的是 `SideRailSub`。 */
|
|
60
|
+
export declare function SideRailGroup({ label, className, children, ...props }: SideRailGroupProps): import("react").JSX.Element;
|
|
61
|
+
//#endregion
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{focusRingInset as t}from"../../lib/focus-ring.js";import{createLazyContext as n}from"../../lib/create-lazy-context.js";import{LinkElement as r}from"../link-element/LinkElement.js";import{usePortalScope as i}from"../../hooks/usePortalScope.js";import{getNavActionContext as a}from"../nav-action/NavAction.js";import{useContext as o,useMemo as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import{Tooltip as d}from"@base-ui/react/tooltip";const f=/* @__PURE__ */ n({collapsed:!1});function p({current:n,disabled:r}){return e(`relative flex h-12 w-full items-center gap-3 pr-4 pl-5 text-left text-sm font-medium`,`transition-colors duration-(--duration-fast) ease-standard`,t,r?`cursor-not-allowed text-ink-disabled`:[n?`font-bold text-ink`:`text-ink-secondary`,`hover:bg-surface-muted hover:text-ink`,`data-popup-open:bg-surface-muted data-popup-open:text-ink`],n&&`before:absolute before:top-1/2 before:left-0 before:h-5 before:w-1 before:-translate-y-1/2 before:bg-ink before:content-['']`)}function m({children:e}){return/* @__PURE__ */ l(`span`,{"aria-hidden":`true`,className:`flex size-6 shrink-0 items-center justify-center [&_svg]:size-5`,children:e})}function h({collapsed:t=!1,brand:n,tools:r,action:i,footer:o,className:c,children:d,...p}){let m=f(),h=a(),g=s(()=>({collapsed:t}),[t]);return/* @__PURE__ */ l(m.Provider,{value:g,children:/* @__PURE__ */ u(`nav`,{...p,"data-collapsed":t?``:void 0,className:e(`sticky top-0 z-(--z-nav) flex h-dvh shrink-0 flex-col border-r border-line bg-surface text-ink shadow-rail`,`transition-[width] duration-(--duration-base) ease-standard`,t?`w-16`:`w-56`,c),children:[n&&/* @__PURE__ */ l(`div`,{className:e(`flex h-16 shrink-0 items-center overflow-hidden`,t?`justify-center`:`px-5`),children:n}),/* @__PURE__ */ l(`ul`,{className:`flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto overscroll-contain py-2`,children:d}),r&&/* @__PURE__ */ l(`div`,{className:e(`flex shrink-0 gap-1 p-3`,t?`flex-col items-center`:`flex-wrap`),children:r}),i&&/* @__PURE__ */ l(`div`,{className:e(`flex shrink-0 p-3`,t&&`justify-center`),children:/* @__PURE__ */ l(h.Provider,{value:t?`stacked`:`block`,children:i})}),o&&/* @__PURE__ */ l(`div`,{className:e(`flex shrink-0 flex-col gap-1 border-t border-line p-3 text-xs text-ink-secondary`,t&&`items-center`),children:o})]})})}function g({icon:t,current:n=!1,end:a,disabled:s=!1,href:h,target:g,rel:_,render:v,onClick:y,children:b,...x}){let{collapsed:S}=o(f()),{anchorRef:C,portalRef:w}=i(),T=h!==void 0||v!==void 0,E=p({current:n,disabled:s}),D=/* @__PURE__ */ u(c,{children:[/* @__PURE__ */ l(m,{children:t}),/* @__PURE__ */ l(`span`,{className:S?`sr-only`:`min-w-0 flex-1 truncate`,children:b}),!S&&a&&/* @__PURE__ */ l(`span`,{className:`flex shrink-0 items-center`,children:a})]}),O=T?/* @__PURE__ */ l(r,{render:v,href:s?void 0:h,role:s?`link`:void 0,"aria-disabled":s||void 0,target:g,rel:_,"aria-current":n?`page`:void 0,onClick:s?e=>e.preventDefault():y,className:E,children:D}):/* @__PURE__ */ l(`button`,{type:`button`,disabled:s,"aria-current":n?`page`:void 0,onClick:y,className:E,children:D});return/* @__PURE__ */ l(`li`,{...x,children:S&&!s?/* @__PURE__ */ u(d.Root,{children:[/* @__PURE__ */ l(d.Trigger,{ref:C,render:O,delay:0,closeDelay:0}),/* @__PURE__ */ l(d.Portal,{ref:w,children:/* @__PURE__ */ l(d.Positioner,{side:`right`,align:`center`,sideOffset:0,className:`pointer-events-none z-(--z-overlay)`,children:/* @__PURE__ */ l(d.Popup,{"aria-hidden":`true`,className:e(`flex h-(--anchor-height) items-center bg-surface-muted pr-5 pl-1 text-sm font-medium whitespace-nowrap text-ink`,`[clip-path:inset(0)] transition-[clip-path] duration-(--duration-fast) ease-exit data-instant:transition-none`,`data-ending-style:[clip-path:inset(0_100%_0_0)] data-starting-style:[clip-path:inset(0_100%_0_0)]`),children:b})})})]}):O})}function _({label:t,className:n,children:r,...i}){let{collapsed:a}=o(f());return/* @__PURE__ */ u(`li`,{...i,className:e(`not-first:mt-2`,n),children:[a?/* @__PURE__ */ l(`div`,{"aria-hidden":`true`,className:`mx-auto mb-2 h-px w-6 bg-line-strong [li:first-child>&]:hidden`}):/* @__PURE__ */ l(`div`,{"aria-hidden":`true`,className:`truncate px-5 pt-2 pb-1 font-tech text-xs text-ink-tertiary`,children:`// ${t}`}),/* @__PURE__ */ l(`ul`,{"aria-label":t,children:r})]})}export{m as RailIcon,h as SideRail,_ as SideRailGroup,g as SideRailItem,f as getSideRailContext,p as railItemClass};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import { LinkRender } from "../link-element/LinkElement.js";
|
|
3
|
+
import { ComponentProps, MouseEvent, ReactNode } from "react";
|
|
4
|
+
//#region src/components/side-rail/SideRailSub.d.ts
|
|
5
|
+
type SubOwnProps = {
|
|
6
|
+
/** 图标。收起时只剩它 */
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
/** 这一组的名称:父项上的文字,也是子列表和菜单的名称 */
|
|
9
|
+
label: string;
|
|
10
|
+
/** 展开着吗。只在侧轨展开时有意义;收起的侧轨上是弹出的菜单 */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 一开始展开着吗。默认:当前项在里面就展开。
|
|
14
|
+
* 之后当前项换到了里面(从别处导航过来),也会自己展开
|
|
15
|
+
*/
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
/** 直接放 `SideRailSubItem` */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export type SideRailSubProps = SubOwnProps & Omit<ComponentProps<"li">, keyof SubOwnProps>;
|
|
22
|
+
/**
|
|
23
|
+
* 侧轨里带二级的栏目。父项本身不是一个去处:点它只是展开收起。
|
|
24
|
+
* 侧轨收起时没有地方就地展开,改成向右弹出一块菜单。
|
|
25
|
+
*/
|
|
26
|
+
export declare function SideRailSub({ icon, label, open: openProp, defaultOpen, onOpenChange, children, ...props }: SideRailSubProps): import("react").JSX.Element;
|
|
27
|
+
type SubItemOwnProps = {
|
|
28
|
+
/** 当前所在的页面:墨色、加粗,引线在这一段变成粗条;输出 `aria-current="page"` */
|
|
29
|
+
current?: boolean;
|
|
30
|
+
/** 行尾的补充:计数、角标 */
|
|
31
|
+
end?: ReactNode;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** 传了就渲染成链接 */
|
|
34
|
+
href?: string;
|
|
35
|
+
target?: string;
|
|
36
|
+
rel?: string;
|
|
37
|
+
/** 用这个元素代替 `<a>`(路由库的链接组件)。传了就按链接处理 */
|
|
38
|
+
render?: LinkRender;
|
|
39
|
+
/** 没有 `href` 和 `render` 时渲染成按钮 */
|
|
40
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
};
|
|
43
|
+
export type SideRailSubItemProps = SubItemOwnProps & Omit<ComponentProps<"li">, keyof SubItemOwnProps>;
|
|
44
|
+
/** 二级里的一项。直接放在 `SideRailSub` 里。 */
|
|
45
|
+
export declare function SideRailSubItem({ current, end, disabled, href, target, rel, render, onClick, children, ...props }: SideRailSubItemProps): import("react").JSX.Element;
|
|
46
|
+
//#endregion
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{focusRingInset as t}from"../../lib/focus-ring.js";import{createLazyContext as n}from"../../lib/create-lazy-context.js";import{useControllableState as r}from"../../hooks/useControllableState.js";import{defined as i}from"../../lib/defined.js";import{LinkElement as a}from"../link-element/LinkElement.js";import{usePortalScope as o}from"../../hooks/usePortalScope.js";import{TriangleRight as s}from"../../icons/TriangleRight.js";import{menuGroupLabel as c,menuItem as l,menuItemCurrent as u,menuItemHover as d,menuPanel as f}from"../dropdown-menu/menu-style.js";import{RailIcon as p,getSideRailContext as m,railItemClass as h}from"./SideRail.js";import{Children as g,isValidElement as _,useContext as v,useEffect as y,useRef as b}from"react";import{Fragment as x,jsx as S,jsxs as C}from"react/jsx-runtime";import{Menu as w}from"@base-ui/react/menu";import{Collapsible as T}from"@base-ui/react/collapsible";const E=/* @__PURE__ */ n(`list`);function D({icon:t,label:n,open:i,defaultOpen:a,onOpenChange:l,children:u,...d}){let x=E(),{collapsed:D}=v(m()),{anchorRef:O,portalRef:k}=o(),A=g.toArray(u).some(e=>_(e)&&e.props.current===!0),[j,M]=r({value:i,defaultValue:a??A,onChange:l}),N=b(A);return y(()=>{A&&!N.current&&M(!0),N.current=A},[A,M]),D?/* @__PURE__ */ S(`li`,{...d,children:/* @__PURE__ */ C(w.Root,{modal:!1,children:[/* @__PURE__ */ C(w.Trigger,{ref:O,openOnHover:!0,delay:0,className:h({current:A,disabled:!1}),children:[/* @__PURE__ */ S(p,{children:t}),/* @__PURE__ */ S(`span`,{className:`sr-only`,children:n})]}),/* @__PURE__ */ S(w.Portal,{ref:k,children:/* @__PURE__ */ S(w.Positioner,{side:`right`,align:`start`,sideOffset:0,className:`z-(--z-overlay) outline-none`,children:/* @__PURE__ */ S(w.Popup,{className:e(f,`max-h-(--available-height) overflow-y-auto overscroll-contain`),children:/* @__PURE__ */ C(w.Group,{children:[/* @__PURE__ */ S(w.GroupLabel,{className:c,children:n}),/* @__PURE__ */ S(x.Provider,{value:`menu`,children:u})]})})})})]})}):/* @__PURE__ */ S(`li`,{...d,children:/* @__PURE__ */ C(T.Root,{open:j,onOpenChange:e=>M(e),children:[/* @__PURE__ */ C(T.Trigger,{className:t=>e(`group/sub`,h({current:A&&!t.open,disabled:!1}),A&&`text-ink`),children:[/* @__PURE__ */ S(p,{children:t}),/* @__PURE__ */ S(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),/* @__PURE__ */ S(s,{size:8,className:`shrink-0 transition-transform duration-(--duration-fast) ease-standard group-data-panel-open/sub:rotate-90`})]}),/* @__PURE__ */ S(T.Panel,{className:e(`h-(--collapsible-panel-height) overflow-hidden`,`transition-[height] duration-(--duration-base) ease-standard`,`data-ending-style:h-0 data-starting-style:h-0`),children:/* @__PURE__ */ S(`ul`,{"aria-label":n,className:`relative before:absolute before:inset-y-0 before:left-8 before:w-px before:bg-line before:content-['']`,children:/* @__PURE__ */ S(x.Provider,{value:`list`,children:u})})})]})})}function O({current:n=!1,end:r,disabled:o=!1,href:s,target:c,rel:f,render:p,onClick:m,children:h,...g}){let _=v(E()),y=s!==void 0||p!==void 0,b=/* @__PURE__ */ C(x,{children:[/* @__PURE__ */ S(`span`,{className:`min-w-0 flex-1 truncate`,children:h}),r&&/* @__PURE__ */ S(`span`,{className:`flex shrink-0 items-center`,children:r})]});if(_===`menu`){let t=e(l,n?u.plain:d);return y?/* @__PURE__ */ S(w.LinkItem,{render:p,...i({href:o?void 0:s,target:c,rel:f}),"aria-current":n?`page`:void 0,"aria-disabled":o||void 0,"data-disabled":o?``:void 0,closeOnClick:!0,onClick:o?e=>e.preventDefault():m,className:t,children:b}):/* @__PURE__ */ S(w.Item,{disabled:o,"aria-current":n?`page`:void 0,onClick:m,className:t,children:b})}let T=e(`relative flex h-10 w-full items-center gap-3 pr-4 pl-14 text-left text-sm`,`transition-colors duration-(--duration-fast) ease-standard`,t,o?`cursor-not-allowed text-ink-disabled`:[n?`font-bold text-ink`:`text-ink-secondary`,`hover:bg-surface-muted hover:text-ink`],n&&`before:absolute before:inset-y-2 before:left-[31px] before:w-[3px] before:bg-ink before:content-['']`);return/* @__PURE__ */ S(`li`,{...g,children:y?/* @__PURE__ */ S(a,{render:p,href:o?void 0:s,role:o?`link`:void 0,"aria-disabled":o||void 0,target:c,rel:f,"aria-current":n?`page`:void 0,onClick:o?e=>e.preventDefault():m,className:T,children:b}):/* @__PURE__ */ S(`button`,{type:`button`,disabled:o,"aria-current":n?`page`:void 0,onClick:m,className:T,children:b})})}export{D as SideRailSub,O as SideRailSubItem};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
|
|
2
|
+
import { SideRail, SideRailGroup, SideRailGroupProps, SideRailItem, SideRailItemProps, SideRailProps } from "./SideRail.js";
|
|
3
|
+
import { SideRailSub, SideRailSubItem, SideRailSubItemProps, SideRailSubProps } from "./SideRailSub.js";
|
|
4
|
+
export { SideRail, SideRailGroup, type SideRailGroupProps, SideRailItem, type SideRailItemProps, type SideRailProps, SideRailSub, SideRailSubItem, type SideRailSubItemProps, type SideRailSubProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/skeleton/Skeleton.d.ts
|
|
4
|
+
export type SkeletonVariant = "block" | "text" | "circle";
|
|
5
|
+
export type SkeletonProps = Omit<ComponentProps<"span">, "children"> & {
|
|
6
|
+
/**
|
|
7
|
+
* - `block` 与内容等大的色块,尺寸用 `className` 给(`h-40 w-full`),默认;
|
|
8
|
+
* - `text` 几行文字,行高跟随所在位置的字号;
|
|
9
|
+
* - `circle` 圆形,头像、图标。
|
|
10
|
+
*/
|
|
11
|
+
variant?: SkeletonVariant;
|
|
12
|
+
/** `text` 的行数,默认 3。多于一行时末行短一截 */
|
|
13
|
+
lines?: number;
|
|
14
|
+
/** 很轻的明度往返。默认不动 */
|
|
15
|
+
pulse?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 骨架:只画大块,不画细节。
|
|
19
|
+
* 自身对辅助技术隐藏;"正在加载"由外层区域的 `aria-busy="true"` 表达。
|
|
20
|
+
*/
|
|
21
|
+
export declare function Skeleton({ variant, lines, pulse, className, ...props }: SkeletonProps): import("react").JSX.Element;
|
|
22
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{jsx as t}from"react/jsx-runtime";const n=`block bg-surface-muted forced-colors:outline forced-colors:-outline-offset-1 forced-colors:outline-[GrayText]`;function r({variant:r=`block`,lines:i=3,pulse:a=!1,className:o,...s}){let c=a&&`animate-pulse`;if(r===`text`){let a=Math.max(1,Math.floor(i));return/* @__PURE__ */ t(`span`,{...s,"aria-hidden":`true`,"data-variant":r,className:e(`flex flex-col gap-[0.6em]`,c,o),children:Array.from({length:a},(r,i)=>/* @__PURE__ */ t(`span`,{className:e(n,`h-[0.9em]`,a>1&&i===a-1?`w-3/5`:`w-full`)},i))})}return/* @__PURE__ */ t(`span`,{...s,"aria-hidden":`true`,"data-variant":r,className:e(n,r===`circle`?`size-10 rounded-full`:`h-16 w-full`,c,o)})}export{r as Skeleton};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/components/slider/Slider.d.ts
|
|
4
|
+
export type SliderSize = "sm" | "md";
|
|
5
|
+
export type SliderMark = {
|
|
6
|
+
value: number;
|
|
7
|
+
/** 刻度下面的标注;不传就只有一条短线 */
|
|
8
|
+
label?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
type SliderCommonProps = {
|
|
11
|
+
/** 下限,默认 0 */
|
|
12
|
+
min?: number;
|
|
13
|
+
/** 上限,默认 100 */
|
|
14
|
+
max?: number;
|
|
15
|
+
/** 一步走多少,默认 1 */
|
|
16
|
+
step?: number;
|
|
17
|
+
/** `PageUp` / `PageDown`、`Shift` + 方向键一次走多少,默认 10 */
|
|
18
|
+
largeStep?: number;
|
|
19
|
+
/** 整个控件占 32 / 40px 高,默认 `md` */
|
|
20
|
+
size?: SliderSize;
|
|
21
|
+
/** 在右侧显示当前值 */
|
|
22
|
+
showValue?: boolean;
|
|
23
|
+
/** 数值怎么写:`Intl.NumberFormat` 的选项(百分比、单位、小数位) */
|
|
24
|
+
format?: Intl.NumberFormatOptions;
|
|
25
|
+
/** 轨道下面的刻度。只是标注,不改变步长 */
|
|
26
|
+
marks?: readonly SliderMark[];
|
|
27
|
+
/** 表单字段名:值随表单提交 */
|
|
28
|
+
name?: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** 不在 `Field` 里时必须给 */
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
"aria-describedby"?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
};
|
|
35
|
+
export type SliderSingleProps = SliderCommonProps & {
|
|
36
|
+
value?: number;
|
|
37
|
+
defaultValue?: number;
|
|
38
|
+
/** 拖动的每一步都触发 */
|
|
39
|
+
onValueChange?: (value: number) => void;
|
|
40
|
+
/** 松手(或一次按键)之后触发:要发请求的事放这里 */
|
|
41
|
+
onValueCommitted?: (value: number) => void;
|
|
42
|
+
thumbLabels?: never;
|
|
43
|
+
minStepsBetweenValues?: never;
|
|
44
|
+
};
|
|
45
|
+
export type SliderRangeProps = SliderCommonProps & {
|
|
46
|
+
/** 传两个数就是范围滑块 */
|
|
47
|
+
value?: readonly [number, number];
|
|
48
|
+
defaultValue?: readonly [number, number];
|
|
49
|
+
onValueChange?: (value: [number, number]) => void;
|
|
50
|
+
onValueCommitted?: (value: [number, number]) => void;
|
|
51
|
+
/** 两个滑块各自的名称,默认"最小值""最大值" */
|
|
52
|
+
thumbLabels?: readonly [string, string];
|
|
53
|
+
/** 两个滑块之间至少隔几步,默认 0 */
|
|
54
|
+
minStepsBetweenValues?: number;
|
|
55
|
+
};
|
|
56
|
+
export type SliderProps = SliderSingleProps | SliderRangeProps;
|
|
57
|
+
/**
|
|
58
|
+
* 滑块:在一个范围里拖着选一个数。要的是确切的数时用 `Stepper`。
|
|
59
|
+
* 每个滑块都要有名称:放进 `Field`,或者自己传 `aria-label`。
|
|
60
|
+
*/
|
|
61
|
+
export declare function Slider(props: SliderProps): import("react").JSX.Element;
|
|
62
|
+
//#endregion
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{focusRingWithin as t}from"../../lib/focus-ring.js";import{useFieldContext as n,useFieldControl as r}from"../field/Field.js";import{useMemo as i}from"react";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{Slider as s}from"@base-ui/react/slider";const c={sm:`h-8`,md:`h-10`},l=e=>`calc(6px + (100% - 12px) * ${e})`,u=[`relative h-5 w-3 bg-surface-inverse shadow-[0_0_0_2px_var(--ef-surface)]`,`transition-[inset-inline-start] duration-(--duration-fast) ease-standard data-dragging:transition-none`,`before:absolute before:-inset-x-3.5 before:-inset-y-2.5 before:content-['']`,`after:absolute after:inset-y-1 after:left-1/2 after:w-0.5 after:-translate-x-1/2 after:bg-accent-ink-inverse after:opacity-0 after:transition-opacity after:duration-(--duration-fast) after:ease-standard after:content-[''] data-dragging:after:opacity-100`,`choice-diamond:size-3.5 choice-diamond:rotate-45 choice-diamond:after:inset-1 choice-diamond:after:w-auto choice-diamond:after:translate-x-0`,`data-disabled:bg-ink-disabled`,`forced-colors:bg-[ButtonText] forced-colors:data-disabled:bg-[GrayText]`,t].join(` `);function d(t){let{min:d=0,max:f=100,step:p=1,largeStep:m=10,size:h=`md`,showValue:g=!1,format:_,marks:v,name:y,disabled:b,"aria-label":x,"aria-describedby":S,className:C}=t,w=n(),{disabled:T,"aria-describedby":E}=r({disabled:b,"aria-describedby":S}),D=x?void 0:w?.labelId,O=Array.isArray(t.value??t.defaultValue),k=t.thumbLabels??[`最小值`,`最大值`],A=i(()=>{let e=new Intl.NumberFormat(void 0,_),t=Math.max(e.format(d).length,e.format(f).length);return`${O?t*2+3:t}ch`},[_,d,f,O]);return/* @__PURE__ */ o(s.Root,{value:t.value,defaultValue:t.defaultValue,onValueChange:e=>t.onValueChange?.(e),onValueCommitted:e=>t.onValueCommitted?.(e),min:d,max:f,step:p,largeStep:m,minStepsBetweenValues:t.minStepsBetweenValues,thumbCollisionBehavior:`none`,format:_,name:y,disabled:T,...O&&{"aria-label":x,"aria-labelledby":D},"data-size":h,className:e(`flex w-full items-start gap-3 text-ink`,C),children:[/* @__PURE__ */ o(`div`,{className:`min-w-0 flex-1`,children:[/* @__PURE__ */ a(s.Control,{className:e(`flex touch-none items-center px-1.5 select-none data-disabled:cursor-not-allowed`,c[h]),children:/* @__PURE__ */ o(s.Track,{className:e(`h-1 w-full bg-line`,`forced-colors:outline forced-colors:-outline-offset-1 forced-colors:outline-[ButtonText] forced-colors:data-disabled:outline-[GrayText]`),children:[/* @__PURE__ */ a(s.Indicator,{className:e(`bg-ink transition-[inset-inline-start,width] duration-(--duration-fast) ease-standard data-disabled:bg-ink-disabled data-dragging:transition-none`,`forced-colors:bg-[Highlight] forced-colors:data-disabled:bg-[GrayText]`)}),(O?[0,1]:[0]).map(e=>/* @__PURE__ */ a(s.Thumb,{index:e,...O?{"aria-label":k[e]}:{"aria-label":x,"aria-labelledby":D},"aria-describedby":E,className:u},e))]})}),v&&v.length>0&&/* @__PURE__ */ a(`div`,{"aria-hidden":`true`,className:`relative h-6 text-xs`,children:v.map(t=>/* @__PURE__ */ a(`span`,{style:{left:l((t.value-d)/(f-d))},className:e(`absolute top-0 flex flex-col gap-0.5 whitespace-nowrap text-ink-secondary before:h-1.5 before:w-px before:bg-line-strong before:content-[''] forced-colors:before:bg-[ButtonText]`,t.value<=d?`items-start`:t.value>=f?`-translate-x-full items-end`:`-translate-x-1/2 items-center`),children:t.label},t.value))})]}),g&&/* @__PURE__ */ a(s.Value,{style:{minWidth:A},className:e(`flex shrink-0 items-center justify-end font-tech text-sm font-bold tabular-nums data-disabled:text-ink-disabled forced-colors:data-disabled:text-[GrayText]`,c[h]),children:e=>e.join(` – `)})]})}export{d as Slider};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/sparkline/Sparkline.d.ts
|
|
4
|
+
export type SparklineVariant = "area" | "line";
|
|
5
|
+
export type SparklineTone = "info" | "danger" | "accent" | "neutral";
|
|
6
|
+
export type SparklineProps = Omit<ComponentProps<"svg">, "children"> & {
|
|
7
|
+
/** 一串数值,按先后顺序。少于两个点时什么都不画 */
|
|
8
|
+
data: readonly number[];
|
|
9
|
+
/** `area` 一块填充的面积,默认;`line` 一条折线 */
|
|
10
|
+
variant?: SparklineVariant;
|
|
11
|
+
/**
|
|
12
|
+
* - `info` 量值图表的蓝,默认;
|
|
13
|
+
* - `danger` 超支、异常的红;
|
|
14
|
+
* - `accent` 强调色;
|
|
15
|
+
* - `neutral` 次要的墨色。
|
|
16
|
+
*/
|
|
17
|
+
tone?: SparklineTone;
|
|
18
|
+
/** 纵向范围的下端。默认从数据的最小值往下再留四分之一,让最低的那一点也有厚度 */
|
|
19
|
+
min?: number;
|
|
20
|
+
/** 纵向范围的上端。默认是数据的最大值 */
|
|
21
|
+
max?: number;
|
|
22
|
+
/** 传了它就是一张有名称的图;不传是纯装饰,对读屏隐藏 */
|
|
23
|
+
label?: string;
|
|
24
|
+
/** 进入视口时从左画出一次。默认开启 */
|
|
25
|
+
animate?: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* 行内的小型图表:没有坐标轴、网格和图例,只有一块面积或一条折线。
|
|
29
|
+
* 撑满给它的盒子(默认高 32px、通宽)。它旁边应该有数字——图只是帮着看趋势。
|
|
30
|
+
*/
|
|
31
|
+
export declare function Sparkline({ data, variant, tone, min, max, label, animate, className, ref, ...props }: SparklineProps): import("react").JSX.Element;
|
|
32
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{mergeRefs as t}from"../../lib/merge-refs.js";import{useInView as n}from"../../hooks/useInView.js";import{jsx as r}from"react/jsx-runtime";const i=e=>Math.round(e*100)/100;function a(e,t={}){if(e.length<2)return null;let n=Math.min(...e),r=Math.max(...e),a=t.max??r,o=t.min??n-(r-n)*.25,s=a-o,c=`M${e.map((t,n)=>{let r=n/(e.length-1)*100,a=s>0?(t-o)/s:.5,c=100-Math.min(Math.max(a,0),1)*100;return`${i(r)} ${i(c)}`}).join(`L`)}`;return{line:c,area:`${c}L100 100L0 100Z`}}const o={info:`fill-data/75`,danger:`fill-alert/75`,accent:`fill-accent-ink/75`,neutral:`fill-ink-secondary/75`},s={info:`stroke-data`,danger:`stroke-alert`,accent:`stroke-accent-ink`,neutral:`stroke-ink-secondary`};function c({data:i,variant:c=`area`,tone:l=`info`,min:u,max:d,label:f,animate:p=!0,className:m,ref:h,...g}){let _=a(i,{min:u,max:d}),[v,y]=n({disabled:!p}),b=p&&!y,x=p&&y;return/* @__PURE__ */ r(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,role:f?`img`:void 0,"aria-label":f,"aria-hidden":f?void 0:`true`,focusable:`false`,"data-variant":c,"data-tone":l,...g,ref:t(v,h),className:e(`block h-8 w-full overflow-visible`,b&&`[clip-path:inset(0_100%_0_0)]`,x&&`animate-wipe-in [animation-duration:var(--duration-slower)] [--wipe-bleed:4px]`,m),children:_&&(c===`area`?/* @__PURE__ */ r(`path`,{d:_.area,className:e(o[l],`forced-colors:fill-[CanvasText]`)}):/* @__PURE__ */ r(`path`,{d:_.line,fill:`none`,strokeWidth:1.5,strokeLinejoin:`miter`,vectorEffect:`non-scaling-stroke`,className:e(s[l],`forced-colors:stroke-[CanvasText]`)}))})}export{c as Sparkline,a as sparklinePath};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/components/spinner/Spinner.d.ts
|
|
4
|
+
export type SpinnerSize = "sm" | "md";
|
|
5
|
+
export type SpinnerProps = Omit<ComponentProps<"span">, "children"> & {
|
|
6
|
+
/** 12px 或 16px。要别的尺寸用 `className` 给 `size-*` */
|
|
7
|
+
size?: SpinnerSize;
|
|
8
|
+
/**
|
|
9
|
+
* 读屏听到的话,默认"加载中"。
|
|
10
|
+
* 旁边已经有文字说明正在加载时传 `null`:这时它只是装饰,对读屏隐藏。
|
|
11
|
+
*/
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 行内加载指示:一个匀速旋转的小方块,颜色继承文字。
|
|
16
|
+
* 圆环形的用 `<ProgressRing size={16} />`;整块内容加载用 `Skeleton`。
|
|
17
|
+
*/
|
|
18
|
+
export declare function Spinner({ size, label, className, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";const r={sm:`size-3`,md:`size-4`},i=[`animate-spin bg-current motion-reduce:rotate-45 motion-reduce:animate-none`,`forced-colors:bg-[CanvasText]`].join(` `);function a({size:a=`md`,label:o=`加载中`,className:s,...c}){return o===null?/* @__PURE__ */ t(`span`,{...c,"aria-hidden":`true`,className:e(`inline-block shrink-0 align-middle`,i,r[a],s)}):/* @__PURE__ */ n(`span`,{...c,role:`status`,className:e(`inline-flex shrink-0 align-middle`,r[a],s),children:[/* @__PURE__ */ t(`span`,{"aria-hidden":`true`,className:e(`block size-full`,i)}),/* @__PURE__ */ t(`span`,{className:`sr-only`,children:o})]})}export{a as Spinner};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/components/splash-screen/SplashScreen.d.ts
|
|
4
|
+
export type SplashScreenProps = Omit<ComponentProps<"div">, "children"> & {
|
|
5
|
+
/** 真实进度,0 – 100。不知道就不传:显示不确定进度,不显示数字 */
|
|
6
|
+
value?: number;
|
|
7
|
+
/** 标志:自己的图或 SVG。放在画面偏右的一个盒子里,竖排时居中 */
|
|
8
|
+
logo?: ReactNode;
|
|
9
|
+
/** 标志下面的一行标语 */
|
|
10
|
+
tagline?: ReactNode;
|
|
11
|
+
/** 标语上方那组微标里的微文字。纯氛围,对读屏隐藏 */
|
|
12
|
+
caption?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* 换掉标语上方的整组微标。不传是代码画的一组(小方框、`caption`、方点阵,旁边一枚三角标),
|
|
15
|
+
* 传 `null` 是不要
|
|
16
|
+
*/
|
|
17
|
+
decor?: ReactNode;
|
|
18
|
+
/** 读数下面的状态字。默认 `LOADING` */
|
|
19
|
+
status?: ReactNode;
|
|
20
|
+
/** 底图:铺满整块,随进度从模糊变清晰 */
|
|
21
|
+
backdrop?: ReactNode;
|
|
22
|
+
/** 置为 `false` 开始退场:走满、铺满、淡出,结束后卸载。默认 `true` */
|
|
23
|
+
open?: boolean;
|
|
24
|
+
/** 铺满视口并锁住页面(默认);关掉则铺满所在的定位容器 */
|
|
25
|
+
fullscreen?: boolean;
|
|
26
|
+
/** 进度条的可访问名称 */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** 开始淡出、页面露出来的那一刻触发:页面自己的入场从这里起 */
|
|
29
|
+
onReveal?: () => void;
|
|
30
|
+
/** 淡出结束、已经卸载之后触发 */
|
|
31
|
+
onExited?: () => void;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 开屏页:照官网首次载入的那一页排的。近黑底,一根贴边的黄色进度条,读数跟着条的末端走;
|
|
35
|
+
* 画面偏右是标志,下面一组微标、一条分隔线和一行标语。就绪后黄色铺满整屏,再整层淡出。
|
|
36
|
+
*
|
|
37
|
+
* 标志和底图是插槽,库里不带任何图。横竖看它所在的那一块自己的宽高比,不看视口;
|
|
38
|
+
* 尺寸跟着那一块的宽度等比缩放,插槽里的东西可以用 `--ef-splash-unit` 跟着缩。
|
|
39
|
+
*
|
|
40
|
+
* 只要一块盖住整页的等待、不要这些排场,用 `Loader`。
|
|
41
|
+
*/
|
|
42
|
+
export declare function SplashScreen({ value, logo, tagline, caption, decor, status, backdrop, open, fullscreen, label, onReveal, onExited, onKeyDown, className, style, ref, ...props }: SplashScreenProps): import("react").JSX.Element | null;
|
|
43
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{usePresence as t}from"../../hooks/usePresence.js";import{mergeRefs as n}from"../../lib/merge-refs.js";import{decor as r}from"../../lib/decor.js";import{useCallback as i,useEffect as a,useLayoutEffect as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";function d(){return/* @__PURE__ */ l(`svg`,{viewBox:`0 0 24 21`,"aria-hidden":`true`,className:e(r,`absolute -top-[calc(var(--ef-splash-unit)*2.5)] -left-[calc(var(--ef-splash-unit)*3.375)] h-[calc(var(--ef-splash-unit)*1.3125)] w-[calc(var(--ef-splash-unit)*1.4375)] fill-action cq-portrait:hidden`),children:/* @__PURE__ */ l(`path`,{d:`M0 0h11.6L5.8 10zM12.4 0H24l-5.8 10zM6.2 11h11.6L12 21z`})})}function f({caption:e}){return/* @__PURE__ */ u(`div`,{className:`flex min-h-[calc(var(--ef-splash-unit)*4)] flex-col items-start justify-between gap-[calc(var(--ef-splash-unit)*0.5)] text-neutral-600`,children:[/* @__PURE__ */ l(`svg`,{viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,className:`size-[calc(var(--ef-splash-unit)*1.125)]`,children:/* @__PURE__ */ l(`path`,{d:`M.5.5h11v11H.5zM6 3v6M3 6h6`})}),e!==void 0&&/* @__PURE__ */ l(`p`,{className:`font-latin text-[length:max(calc(var(--ef-splash-unit)*0.75),var(--text-micro))] leading-[1.2] font-medium tracking-label whitespace-pre-line text-ink-tertiary uppercase cq-portrait:hidden`,children:e}),/* @__PURE__ */ l(`svg`,{viewBox:`0 0 62 18`,fill:`currentColor`,className:`h-[calc(var(--ef-splash-unit)*1.125)] w-[calc(var(--ef-splash-unit)*3.875)]`,children:[0,11].flatMap(e=>[0,11,22,33,44,55].map(t=>/* @__PURE__ */ l(`rect`,{x:t,y:e,width:`7`,height:`7`},`${t}-${e}`)))})]})}function p({value:p,logo:m,tagline:h,caption:g,decor:_,status:v=`LOADING`,backdrop:y,open:b=!0,fullscreen:x=!0,label:S=`加载中`,onReveal:C,onExited:w,onKeyDown:T,className:E,style:D,ref:O,...k}){let[A,j]=c(!1);b&&A&&j(!1);let M=s({onReveal:C}),N=s(!1);o(()=>{M.current={onReveal:C},b&&(N.current=!1)});let P=i(()=>{N.current||(N.current=!0,j(!0),M.current.onReveal?.())},[]),{ref:F,mounted:I}=t(b,{onExited:()=>{P(),w?.()}}),L=I&&!b;o(()=>{let e=F.current;if(!L||!e)return;let t=t=>{t.target===e&&t.propertyName===`opacity`&&P()};return e.addEventListener(`transitionstart`,t),()=>e.removeEventListener(`transitionstart`,t)},[L,F,P]);let R=I&&(b||!A);if(a(()=>{if(!x||!R)return;let e=document.documentElement,t=e.style.overflow,n=document.activeElement;return e.style.overflow=`hidden`,F.current?.focus({preventScroll:!0}),()=>{e.style.overflow=t,n instanceof HTMLElement&&n.isConnected&&n.focus({preventScroll:!0})}},[x,R,F]),!I)return null;let z=e=>{T?.(e),x&&R&&e.key===`Tab`&&e.preventDefault()},B=p===void 0,V=b?B?0:Math.min(Math.max(p,0),100):100,H=B&&b;return/* @__PURE__ */ u(`div`,{tabIndex:-1,...k,ref:n(F,O),"data-theme":`dark`,"data-state":b?`open`:`closing`,onKeyDown:z,style:{...D,"--ef-splash-progress":V,"--ef-splash-percent":Math.round(V)},className:e(`overflow-hidden bg-surface text-ink outline-none [container-type:size]`,x?`fixed inset-0 z-(--z-loader)`:`absolute inset-0`,L?`[transition:--ef-splash-progress_500ms_var(--ease-exit),--ef-splash-percent_500ms_var(--ease-exit),opacity_1s_var(--ease-standard)_1.4s]`:`[transition:--ef-splash-progress_500ms_var(--ease-exit),--ef-splash-percent_500ms_var(--ease-exit)]`,L&&`opacity-0`,!R&&`pointer-events-none`,E),children:[/* @__PURE__ */ u(`div`,{className:`absolute inset-0 [--_status:max(var(--ef-splash-unit),var(--text-xs))] [--_tagline:max(calc(var(--ef-splash-unit)*1.5),var(--text-xs))] [--ef-splash-unit:0.625cqw] cq-portrait:[--ef-splash-unit:1.4815cqw]`,children:[y!==void 0&&/* @__PURE__ */ l(`div`,{"aria-hidden":`true`,className:e(`pointer-events-none select-none forced-colors:hidden print:hidden`,`absolute inset-0 blur-[calc((100_-_var(--ef-splash-progress))*0.08px)] *:size-full [&>img]:object-cover`),children:y}),m!==void 0&&/* @__PURE__ */ l(`div`,{className:`absolute top-[min(calc(var(--ef-splash-unit)*27.625),calc(100%_-_var(--ef-splash-unit)*44.25))] left-[64.4531%] flex h-[calc(var(--ef-splash-unit)*16.75)] w-[calc(var(--ef-splash-unit)*16.5)] items-center justify-center cq-portrait:top-[min(calc(var(--ef-splash-unit)*50),41.667%)] cq-portrait:left-1/2 cq-portrait:h-[calc(var(--ef-splash-unit)*20.9375)] cq-portrait:w-[calc(var(--ef-splash-unit)*19.3125)] cq-portrait:-translate-1/2 [&>:is(img,svg)]:size-full [&>img]:object-contain`,children:m}),/* @__PURE__ */ u(`div`,{className:`absolute top-[min(calc(var(--ef-splash-unit)*63.375),calc(100%_-_var(--ef-splash-unit)*8.5))] right-[calc(var(--ef-splash-unit)*2)] left-[64.4531%] cq-portrait:top-auto cq-portrait:right-[calc(var(--ef-splash-unit)*4.625)] cq-portrait:bottom-[calc(var(--ef-splash-unit)*5.75)] cq-portrait:left-[calc(var(--ef-splash-unit)*4.625)]`,children:[_===void 0&&/* @__PURE__ */ l(d,{}),_!==null&&/* @__PURE__ */ l(`div`,{"aria-hidden":`true`,className:e(`pointer-events-none select-none forced-colors:hidden print:hidden`,`absolute bottom-full left-0`),children:_===void 0?/* @__PURE__ */ l(f,{caption:g}):_}),/* @__PURE__ */ l(`span`,{"aria-hidden":`true`,className:e(r,`mt-[calc(var(--ef-splash-unit)*1.25)] mb-[calc(var(--ef-splash-unit))] -ml-[calc(var(--ef-splash-unit)*21.625)] block h-0.5 w-[calc(var(--ef-splash-unit)*70)] bg-linear-to-r from-transparent via-neutral-0/10 to-transparent`)}),h!==void 0&&/* @__PURE__ */ l(`p`,{className:`text-[length:var(--_tagline)] leading-[1.35] wrap-anywhere`,children:h})]}),/* @__PURE__ */ u(`div`,{role:`progressbar`,"aria-label":S,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":H?void 0:V,className:`absolute top-0 left-0 h-full w-[calc(var(--ef-splash-unit)*1.25)] forced-colors:outline forced-colors:-outline-offset-1 forced-colors:outline-[CanvasText] cq-portrait:top-auto cq-portrait:bottom-[calc(var(--ef-splash-unit)*17.75_+_(var(--_status)_-_var(--ef-splash-unit))*1.25_+_(var(--_tagline)_-_var(--ef-splash-unit)*1.5)*1.35)] cq-portrait:h-[calc(var(--ef-splash-unit)*2.5)] cq-portrait:w-[82.4074%]`,children:[H?/* @__PURE__ */ l(`span`,{className:`absolute inset-0 overflow-hidden`,children:/* @__PURE__ */ l(`span`,{className:`absolute inset-x-0 top-0 h-2/5 animate-indeterminate-y bg-action motion-reduce:translate-y-3/4 forced-colors:bg-[Highlight] cq-portrait:inset-x-auto cq-portrait:inset-y-0 cq-portrait:left-0 cq-portrait:h-auto cq-portrait:w-2/5 cq-portrait:animate-indeterminate cq-portrait:motion-reduce:translate-x-3/4 cq-portrait:motion-reduce:translate-y-0`})}):/* @__PURE__ */ l(`span`,{className:`absolute top-0 left-0 h-[calc(var(--ef-splash-progress)*1%)] w-full bg-action forced-colors:bg-[Highlight] cq-portrait:h-full cq-portrait:w-[calc(var(--ef-splash-progress)*1%)]`}),/* @__PURE__ */ u(`div`,{"aria-hidden":`true`,className:e(`absolute top-[calc(var(--ef-splash-progress)*1%)] left-[calc(var(--ef-splash-unit)*3.125)] h-0 whitespace-nowrap cq-portrait:top-auto cq-portrait:-bottom-[calc(var(--ef-splash-unit)*1.75)] cq-portrait:left-[calc(var(--ef-splash-progress)*1%)] cq-portrait:ml-[calc(var(--ef-splash-unit)*0.75)]`,H&&`translate-y-[calc(var(--ef-splash-unit)*3)] cq-portrait:translate-y-0`),children:[!B&&/* @__PURE__ */ u(`p`,{className:`absolute bottom-[calc(var(--ef-splash-unit)*1.625)] left-0 leading-none text-action`,children:[/* @__PURE__ */ l(`span`,{className:`mb-[calc(var(--ef-splash-unit)*0.25)] block h-[calc(var(--ef-splash-unit)*1.875)] w-[calc(var(--ef-splash-unit)*0.5)] rounded-[calc(var(--ef-splash-unit)*0.25)] bg-action`}),/* @__PURE__ */ l(`span`,{className:`text-[length:calc(var(--ef-splash-unit)*4.375)] font-medium tabular-nums [counter-reset:ef-splash_var(--ef-splash-percent)] before:content-[counter(ef-splash)]`}),/* @__PURE__ */ l(`span`,{className:`text-[length:calc(var(--ef-splash-unit)*3.25)]`,children:`%`})]}),/* @__PURE__ */ u(`p`,{className:`absolute -top-[calc(var(--ef-splash-unit)*0.5)] left-0 text-[length:var(--_status)] leading-[1.25] text-ink-tertiary`,children:[/* @__PURE__ */ l(`span`,{className:`block h-[calc(var(--ef-splash-unit)*0.5)] w-[calc(var(--ef-splash-unit)*1.25)] border-x-[length:calc(var(--ef-splash-unit)*0.5)] border-current`}),v]})]})]})]}),L&&/* @__PURE__ */ l(`span`,{"aria-hidden":`true`,className:`absolute inset-0 origin-left animate-fill bg-action [animation-delay:500ms] [animation-timing-function:cubic-bezier(1,0,0.7,1)] motion-reduce:hidden forced-colors:bg-[Highlight]`})]})}export{p as SplashScreen};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/components/stat/Stat.d.ts
|
|
4
|
+
export type StatSize = "md" | "lg";
|
|
5
|
+
export type StatTrend = "up" | "down";
|
|
6
|
+
export type StatProps = Omit<ComponentProps<"div">, "children"> & {
|
|
7
|
+
/** 微标,说明这是什么数。前面的 `//` 由组件加,不用自己写 */
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
/** 主角:一个需要被一眼看到的数字 */
|
|
10
|
+
value: ReactNode;
|
|
11
|
+
/** 单位,小一号、与数字基线对齐 */
|
|
12
|
+
unit?: ReactNode;
|
|
13
|
+
/** 增量,连同正负号一起传,如 `+6%`、`−2%` */
|
|
14
|
+
delta?: ReactNode;
|
|
15
|
+
/** `up` 渲染为增益签,默认;`down` 渲染为危险色文字 */
|
|
16
|
+
trend?: StatTrend;
|
|
17
|
+
/** 并排几个时,让最重要的那个用 `lg` */
|
|
18
|
+
size?: StatSize;
|
|
19
|
+
};
|
|
20
|
+
/** 统计块:不装进卡片,只用左缘一条墨色竖线。 */
|
|
21
|
+
export declare function Stat({ label, value, unit, delta, trend, size, className, ...props }: StatProps): import("react").JSX.Element;
|
|
22
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{cn as e}from"../../lib/cn.js";import{Tag as t}from"../tag/Tag.js";import{jsx as n,jsxs as r}from"react/jsx-runtime";const i={md:`text-4xl`,lg:`text-5xl`};function a({label:a,value:o,unit:s,delta:c,trend:l=`up`,size:u=`md`,className:d,...f}){let p=c!=null;return/* @__PURE__ */ r(`div`,{...f,"data-size":u,className:e(`min-w-0 border-l-4 border-ink pl-4 text-ink`,d),children:[/* @__PURE__ */ r(`p`,{className:`font-tech text-xs tracking-label text-ink-secondary`,children:[/* @__PURE__ */ n(`span`,{"aria-hidden":`true`,children:`// `}),a]}),/* @__PURE__ */ r(`p`,{className:`mt-2 flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[/* @__PURE__ */ n(`span`,{className:e(`min-w-0 font-tech leading-none font-medium wrap-anywhere tabular-nums`,i[u]),children:o}),s!=null&&/* @__PURE__ */ n(`span`,{className:`text-sm text-ink-secondary`,children:s}),p&&(l===`down`?/* @__PURE__ */ n(`span`,{"data-trend":`down`,className:`font-tech text-sm font-bold text-danger tabular-nums`,children:c}):/* @__PURE__ */ n(t,{variant:`gain`,size:`sm`,numeric:!0,"data-trend":`up`,children:c}))]})]})}export{a as Stat};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
//#region src/components/stepper/Stepper.d.ts
|
|
4
|
+
export type StepperSize = "sm" | "md" | "lg";
|
|
5
|
+
export type StepperProps = Omit<ComponentProps<"input">, "type" | "size" | "value" | "defaultValue" | "onChange" | "min" | "max" | "step"> & {
|
|
6
|
+
/** 受控的当前值 */
|
|
7
|
+
value?: number;
|
|
8
|
+
/** 非受控时的初始值,缺省取 `min`,没有 `min` 则为 0 */
|
|
9
|
+
defaultValue?: number;
|
|
10
|
+
onValueChange?: (value: number) => void;
|
|
11
|
+
min?: number;
|
|
12
|
+
max?: number;
|
|
13
|
+
/** 每一步的增量,默认 1;可以是小数 */
|
|
14
|
+
step?: number;
|
|
15
|
+
/** 32 / 40 / 56px 高 */
|
|
16
|
+
size?: StepperSize;
|
|
17
|
+
/** 错误态:数字下方出现一条红线。放在 `Field` 里时跟随它的 `error` */
|
|
18
|
+
invalid?: boolean;
|
|
19
|
+
/** 两端按钮的可访问名称 */
|
|
20
|
+
decrementLabel?: string;
|
|
21
|
+
incrementLabel?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* 步进器:`−` 钮 + 数字 + `+` 钮,三段紧贴。数字可以直接输入,
|
|
25
|
+
* 也可以用 ↑ ↓(一步)、PageUp / PageDown(十步)、Home / End(上下限)。
|
|
26
|
+
* `className` 给外框,其余属性与 `ref` 给中间的 `<input>`。
|
|
27
|
+
*/
|
|
28
|
+
export declare function Stepper({ value: valueProp, defaultValue, onValueChange, min, max, step, size, invalid: invalidProp, decrementLabel, incrementLabel, id: idProp, disabled: disabledProp, required: requiredProp, readOnly, "aria-describedby": describedByProp, onKeyDown, onBlur, className, ...props }: StepperProps): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{Minus as e}from"../../icons/Minus.js";import{cn as t}from"../../lib/cn.js";import{focusRingWithin as n}from"../../lib/focus-ring.js";import{useControllableState as r}from"../../hooks/useControllableState.js";import{useFieldControl as i}from"../field/Field.js";import{Plus as a}from"../../icons/Plus.js";import{useEffect as o,useRef as s,useState as c}from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";const d={sm:`h-8 text-sm`,md:`h-10 text-base`,lg:`h-14 text-lg`},f={sm:`w-8`,md:`w-10`,lg:`w-14`},p={sm:`w-12`,md:`w-14`,lg:`w-20`},m={sm:14,md:16,lg:20};function h(e){let t=String(e),n=t.indexOf(`.`);return n===-1?0:t.length-n-1}function g({value:g,defaultValue:_,onValueChange:v,min:y,max:b,step:x=1,size:S=`md`,invalid:C,decrementLabel:w=`减少`,incrementLabel:T=`增加`,id:E,disabled:D,required:O,readOnly:k=!1,"aria-describedby":A,onKeyDown:ee,onBlur:te,className:ne,...j}){let{id:M,disabled:N,required:P,invalid:F,...I}=i({id:E,disabled:D,required:O,invalid:C,"aria-describedby":A}),L=Math.max(h(x),h(y??0),h(b??0)),R=e=>Number(Math.min(Math.max(e,y??-1/0),b??1/0).toFixed(L)),[z,B]=r({value:g,defaultValue:_??R(0),onChange:v}),[V,H]=c(null),U=y!==void 0&&z<=y,W=b!==void 0&&z>=b,G=N||k,K=e=>{let t=V===null||V.trim()===``?NaN:Number(V),n=R((Number.isFinite(t)?t:z)+e);return H(null),n!==z&&(B(n),!0)},q=()=>{if(V===null)return;let e=V.trim()===``?NaN:Number(V);H(null),Number.isFinite(e)&&B(R(e))},J=s(K);o(()=>{J.current=K});let Y=s({}),X=()=>{window.clearTimeout(Y.current.delay),window.clearInterval(Y.current.repeat),Y.current={}};o(()=>X,[]);let Z=(e,t)=>{e.button>0||(X(),J.current(t)&&(Y.current.delay=window.setTimeout(()=>{Y.current.repeat=window.setInterval(()=>{J.current(t)||X()},80)},400)))},Q=(e,t)=>{e.detail===0&&K(t)},re=e=>{let t=e.target.value;/^-?\d*\.?\d*$/.test(t)&&H(t)},ie=e=>{if(ee?.(e),!(e.defaultPrevented||G)){switch(e.key){case`ArrowUp`:K(x);break;case`ArrowDown`:K(-x);break;case`PageUp`:K(x*10);break;case`PageDown`:K(-x*10);break;case`Home`:if(y===void 0)return;H(null),B(y);break;case`End`:if(b===void 0)return;H(null),B(b);break;case`Enter`:q();return;default:return}e.preventDefault()}},ae=e=>{te?.(e),q()},$=e=>t(`flex shrink-0 items-center justify-center select-none`,`transition-colors duration-(--duration-fast) ease-standard`,`forced-colors:border forced-colors:border-[ButtonText] forced-colors:disabled:border-[GrayText]`,f[S],e?`cursor-not-allowed bg-disabled text-on-disabled`:`bg-control text-on-control hover:bg-control-hover active:bg-control-pressed`);return/* @__PURE__ */ u(`div`,{"data-size":S,"data-invalid":F?``:void 0,className:t(`inline-flex items-stretch`,n,d[S],ne),children:[/* @__PURE__ */ l(`button`,{type:`button`,tabIndex:-1,"aria-label":w,disabled:G||U,onPointerDown:e=>Z(e,-x),onPointerUp:X,onPointerLeave:X,onPointerCancel:X,onClick:e=>Q(e,-x),className:$(G||U),children:/* @__PURE__ */ l(e,{size:m[S]})}),/* @__PURE__ */ l(`input`,{...j,id:M,type:`text`,role:`spinbutton`,inputMode:L>0?`decimal`:`numeric`,autoComplete:`off`,value:V??String(z),disabled:N,required:P,readOnly:k,"aria-valuenow":z,"aria-valuemin":y,"aria-valuemax":b,"aria-invalid":F||void 0,"aria-describedby":I[`aria-describedby`],onChange:re,onKeyDown:ie,onBlur:ae,className:t(`min-w-0 flex-1 border-y-2 border-transparent bg-surface-sunken text-center font-tech font-bold tabular-nums outline-none`,`disabled:cursor-not-allowed`,`forced-colors:border-y forced-colors:border-[ButtonText] forced-colors:disabled:border-[GrayText]`,p[S],N?`text-ink-disabled`:`text-ink`,F&&!N&&`border-b-danger`)}),/* @__PURE__ */ l(`button`,{type:`button`,tabIndex:-1,"aria-label":T,disabled:G||W,onPointerDown:e=>Z(e,x),onPointerUp:X,onPointerLeave:X,onPointerCancel:X,onClick:e=>Q(e,x),className:$(G||W),children:/* @__PURE__ */ l(a,{size:m[S]})})]})}export{g as Stepper};
|