@endfield-ui/react 1.2.0 → 1.3.0
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 +8 -3
- 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/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/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.d.ts +29 -383
- package/dist/game.js +1 -2068
- 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 -3546
- package/dist/index.js +1 -9848
- 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/avatar/AvatarSwitcher.tsx +7 -5
- package/src/components/button/Button.tsx +77 -90
- 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 -1
- package/src/components/dropdown-menu/DropdownMenu.tsx +7 -4
- package/src/components/dropdown-menu/menu-style.ts +3 -2
- package/src/components/field/Field.tsx +10 -6
- package/src/components/flyout-bar/FlyoutBar.tsx +1 -1
- package/src/components/icon-button/IconButton.tsx +5 -5
- package/src/components/image-viewer/ImageViewer.tsx +6 -5
- package/src/components/list/List.tsx +7 -5
- package/src/components/nav-action/NavAction.tsx +6 -4
- package/src/components/nav-menu/NavMenu.tsx +13 -7
- package/src/components/page-header/PageHeader.tsx +1 -1
- package/src/components/play-button/PlayButton.tsx +1 -1
- package/src/components/radio/Radio.tsx +7 -5
- package/src/components/schedule/Schedule.tsx +7 -5
- package/src/components/segmented-control/SegmentedControl.tsx +7 -5
- package/src/components/select/Select.tsx +11 -9
- package/src/components/side-rail/SideRail.tsx +15 -9
- package/src/components/side-rail/SideRailSub.tsx +12 -7
- 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/toast/Toast.tsx +8 -5
- 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/lib/cn.ts +1 -1
- package/src/lib/create-lazy-context.ts +6 -0
- package/src/styles/theme.css +37 -0
- package/src/components/README.md +0 -191
- 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 -77
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
useId,
|
|
5
4
|
useMemo,
|
|
@@ -11,6 +10,7 @@ import { usePresence } from "../../hooks/usePresence";
|
|
|
11
10
|
import { StatusDanger } from "../../icons/StatusDanger";
|
|
12
11
|
import { cn } from "../../lib/cn";
|
|
13
12
|
import { collapse, collapseEnter, collapseInner } from "../../lib/motion";
|
|
13
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
14
14
|
|
|
15
15
|
type FieldContextValue = {
|
|
16
16
|
/** 单个控件的 id;`group` 字段里有多个控件,不提供 */
|
|
@@ -23,11 +23,12 @@ type FieldContextValue = {
|
|
|
23
23
|
group: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const getFieldContext =
|
|
27
|
+
/* @__PURE__ */ createLazyContext<FieldContextValue | null>(null);
|
|
27
28
|
|
|
28
29
|
/** 给成组的控件(单选组)读取所在字段的状态。不在 `Field` 里时返回 `null`。 */
|
|
29
30
|
export function useFieldContext(): FieldContextValue | null {
|
|
30
|
-
return useContext(
|
|
31
|
+
return useContext(getFieldContext());
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
type ControlProps = {
|
|
@@ -50,7 +51,7 @@ export function useFieldControl({
|
|
|
50
51
|
invalid,
|
|
51
52
|
"aria-describedby": describedBy,
|
|
52
53
|
}: ControlProps) {
|
|
53
|
-
const field = useContext(
|
|
54
|
+
const field = useContext(getFieldContext());
|
|
54
55
|
const mergedDescribedBy =
|
|
55
56
|
[describedBy, field?.describedBy].filter(Boolean).join(" ") || undefined;
|
|
56
57
|
|
|
@@ -97,6 +98,7 @@ export function Field({
|
|
|
97
98
|
children,
|
|
98
99
|
...props
|
|
99
100
|
}: FieldProps) {
|
|
101
|
+
const FieldContext = getFieldContext();
|
|
100
102
|
const baseId = useId();
|
|
101
103
|
const id = controlId ?? `${baseId}-control`;
|
|
102
104
|
const labelId = `${baseId}-label`;
|
|
@@ -212,7 +214,9 @@ export function Field({
|
|
|
212
214
|
</legend>
|
|
213
215
|
{/* 组里的控件默认竖排;要横排就自己包一层,作为这里唯一的子元素 */}
|
|
214
216
|
<div className="flex flex-col items-start">
|
|
215
|
-
<FieldContext value={context}>
|
|
217
|
+
<FieldContext.Provider value={context}>
|
|
218
|
+
{children}
|
|
219
|
+
</FieldContext.Provider>
|
|
216
220
|
</div>
|
|
217
221
|
{messages}
|
|
218
222
|
</fieldset>
|
|
@@ -228,7 +232,7 @@ export function Field({
|
|
|
228
232
|
<label id={labelId} htmlFor={id} className={cn(labelClass, "mb-1.5")}>
|
|
229
233
|
{labelContent}
|
|
230
234
|
</label>
|
|
231
|
-
<FieldContext value={context}>{children}</FieldContext>
|
|
235
|
+
<FieldContext.Provider value={context}>{children}</FieldContext.Provider>
|
|
232
236
|
{messages}
|
|
233
237
|
</div>
|
|
234
238
|
);
|
|
@@ -101,7 +101,7 @@ type ItemOwnProps = {
|
|
|
101
101
|
export type FlyoutBarItemProps = ItemOwnProps &
|
|
102
102
|
Omit<ComponentProps<"div">, keyof ItemOwnProps | "id" | "style">;
|
|
103
103
|
|
|
104
|
-
const itemClass = cn(
|
|
104
|
+
const itemClass = /* @__PURE__ */ cn(
|
|
105
105
|
"flex min-w-10 cursor-default items-center justify-center gap-2 px-2.5 text-sm select-none",
|
|
106
106
|
"transition-colors duration-(--duration-fast) ease-standard",
|
|
107
107
|
"data-disabled:text-ink-disabled data-highlighted:text-ink",
|
|
@@ -35,7 +35,7 @@ const enabledClass: Record<IconButtonVariant, string> = {
|
|
|
35
35
|
plain: restClass,
|
|
36
36
|
// 有意不随主题翻转:它要压在图像和深色版块上
|
|
37
37
|
floating:
|
|
38
|
-
"
|
|
38
|
+
"bg-neutral-50 text-neutral-900 shadow-sm hover:bg-neutral-200 active:bg-neutral-300",
|
|
39
39
|
accent:
|
|
40
40
|
"bg-surface-sunken text-ink-secondary hover:bg-action hover:text-on-action active:bg-action-pressed",
|
|
41
41
|
inverse:
|
|
@@ -45,8 +45,7 @@ const enabledClass: Record<IconButtonVariant, string> = {
|
|
|
45
45
|
|
|
46
46
|
const pressedClass: Record<IconButtonVariant, string> = {
|
|
47
47
|
plain: "bg-surface-muted text-ink active:bg-line",
|
|
48
|
-
floating:
|
|
49
|
-
"rounded-full bg-neutral-200 text-neutral-900 shadow-sm active:bg-neutral-300",
|
|
48
|
+
floating: "bg-neutral-200 text-neutral-900 shadow-sm active:bg-neutral-300",
|
|
50
49
|
accent: "bg-action text-on-action active:bg-action-pressed",
|
|
51
50
|
inverse: "bg-surface-inverse text-accent-ink-inverse",
|
|
52
51
|
};
|
|
@@ -64,8 +63,7 @@ const disabledForced = "forced-colors:border-[GrayText]";
|
|
|
64
63
|
|
|
65
64
|
const disabledClass: Record<IconButtonVariant, string> = {
|
|
66
65
|
plain: "cursor-not-allowed bg-surface-sunken text-ink-disabled",
|
|
67
|
-
floating:
|
|
68
|
-
"cursor-not-allowed rounded-full bg-neutral-50 text-neutral-400 shadow-sm",
|
|
66
|
+
floating: "cursor-not-allowed bg-neutral-50 text-neutral-400 shadow-sm",
|
|
69
67
|
accent: "cursor-not-allowed bg-surface-sunken text-ink-disabled",
|
|
70
68
|
inverse: "cursor-not-allowed bg-surface-sunken text-ink-disabled",
|
|
71
69
|
};
|
|
@@ -90,6 +88,8 @@ export function IconButton({
|
|
|
90
88
|
data-size={size}
|
|
91
89
|
className={cn(
|
|
92
90
|
"relative inline-flex shrink-0 items-center justify-center",
|
|
91
|
+
// 方形的三种和按钮一样是 4px 微圆角;浮动的那种是圆
|
|
92
|
+
variant === "floating" ? "rounded-full" : "rounded-sm",
|
|
93
93
|
"transition-colors duration-(--duration-fast) ease-standard",
|
|
94
94
|
focusRing,
|
|
95
95
|
sizeClass[size],
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
2
2
|
import {
|
|
3
3
|
Children,
|
|
4
|
-
createContext,
|
|
5
4
|
isValidElement,
|
|
6
5
|
useContext,
|
|
7
6
|
useRef,
|
|
@@ -22,6 +21,7 @@ import { useSnapTrack } from "../carousel/snap-track";
|
|
|
22
21
|
import { overlayClose, overlayHeader } from "../dialog/overlay-style";
|
|
23
22
|
import { IconButton } from "../icon-button/IconButton";
|
|
24
23
|
import { Viewfinder } from "../viewfinder/Viewfinder";
|
|
24
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
25
25
|
|
|
26
26
|
export type ImageViewerRatio = "16/9" | "4/3" | "1/1" | "3/4";
|
|
27
27
|
|
|
@@ -38,7 +38,7 @@ type ItemLike = {
|
|
|
38
38
|
children?: ReactNode;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const getItemContext = /* @__PURE__ */ createLazyContext<{
|
|
42
42
|
position: number;
|
|
43
43
|
count: number;
|
|
44
44
|
ratio: ImageViewerRatio;
|
|
@@ -93,6 +93,7 @@ export function ImageViewer({
|
|
|
93
93
|
children,
|
|
94
94
|
...props
|
|
95
95
|
}: ImageViewerProps) {
|
|
96
|
+
const ItemContext = getItemContext();
|
|
96
97
|
// 标题、说明和大图都从子元素上读,所以子元素必须直接是 ImageViewerItem
|
|
97
98
|
const items = Children.toArray(children).filter((child) =>
|
|
98
99
|
isValidElement<ItemLike>(child),
|
|
@@ -133,7 +134,7 @@ export function ImageViewer({
|
|
|
133
134
|
)}
|
|
134
135
|
>
|
|
135
136
|
{items.map((item, position) => (
|
|
136
|
-
<ItemContext
|
|
137
|
+
<ItemContext.Provider
|
|
137
138
|
key={position}
|
|
138
139
|
value={{
|
|
139
140
|
position,
|
|
@@ -145,7 +146,7 @@ export function ImageViewer({
|
|
|
145
146
|
}}
|
|
146
147
|
>
|
|
147
148
|
{item}
|
|
148
|
-
</ItemContext>
|
|
149
|
+
</ItemContext.Provider>
|
|
149
150
|
))}
|
|
150
151
|
</ul>
|
|
151
152
|
<BaseDialog.Root open={open} onOpenChange={(next) => setOpen(next)}>
|
|
@@ -427,7 +428,7 @@ export function ImageViewerItem({
|
|
|
427
428
|
children,
|
|
428
429
|
...props
|
|
429
430
|
}: ImageViewerItemProps) {
|
|
430
|
-
const item = useContext(
|
|
431
|
+
const item = useContext(getItemContext());
|
|
431
432
|
if (!item) {
|
|
432
433
|
throw new Error("ImageViewerItem 要直接放在 ImageViewer 里面");
|
|
433
434
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
type ComponentProps,
|
|
5
4
|
type MouseEvent,
|
|
@@ -10,6 +9,7 @@ import { focusRingInset } from "../../lib/focus-ring";
|
|
|
10
9
|
import { GhostText } from "../ghost-text/GhostText";
|
|
11
10
|
import { LinkElement, type LinkRender } from "../link-element/LinkElement";
|
|
12
11
|
import { bandCanvas, bandGap, bandRow } from "./band-style";
|
|
12
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
13
13
|
|
|
14
14
|
export type ListVariant = "plain" | "band";
|
|
15
15
|
|
|
@@ -21,12 +21,14 @@ export type ListProps = ComponentProps<"ul"> & {
|
|
|
21
21
|
variant?: ListVariant;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const getListVariantContext =
|
|
25
|
+
/* @__PURE__ */ createLazyContext<ListVariant>("plain");
|
|
25
26
|
|
|
26
27
|
/** 列表行的容器,外圈不描边。里面只放 `ListRow`。 */
|
|
27
28
|
export function List({ variant = "plain", className, ...props }: ListProps) {
|
|
29
|
+
const ListVariantContext = getListVariantContext();
|
|
28
30
|
return (
|
|
29
|
-
<ListVariantContext value={variant}>
|
|
31
|
+
<ListVariantContext.Provider value={variant}>
|
|
30
32
|
<ul
|
|
31
33
|
{...props}
|
|
32
34
|
data-variant={variant}
|
|
@@ -38,7 +40,7 @@ export function List({ variant = "plain", className, ...props }: ListProps) {
|
|
|
38
40
|
className,
|
|
39
41
|
)}
|
|
40
42
|
/>
|
|
41
|
-
</ListVariantContext>
|
|
43
|
+
</ListVariantContext.Provider>
|
|
42
44
|
);
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -103,7 +105,7 @@ export function ListRow({
|
|
|
103
105
|
children,
|
|
104
106
|
...props
|
|
105
107
|
}: ListRowProps) {
|
|
106
|
-
const band = useContext(
|
|
108
|
+
const band = useContext(getListVariantContext()) === "band";
|
|
107
109
|
const isLink = href !== undefined || render !== undefined;
|
|
108
110
|
const isButton = !isLink && onClick !== undefined;
|
|
109
111
|
const interactive = (isLink || isButton) && !disabled;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
type ComponentProps,
|
|
5
4
|
type MouseEvent,
|
|
@@ -9,11 +8,13 @@ import { TriangleRight } from "../../icons/TriangleRight";
|
|
|
9
8
|
import { cn } from "../../lib/cn";
|
|
10
9
|
import { focusRing } from "../../lib/focus-ring";
|
|
11
10
|
import { LinkElement, type LinkRender } from "../link-element/LinkElement";
|
|
11
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
12
12
|
|
|
13
13
|
export type NavActionLayout = "inline" | "block" | "stacked";
|
|
14
14
|
|
|
15
15
|
/** 侧轨和全屏菜单用它告诉里面的主行动块该怎么摆。不对外导出 */
|
|
16
|
-
export const
|
|
16
|
+
export const getNavActionContext =
|
|
17
|
+
/* @__PURE__ */ createLazyContext<NavActionLayout | null>(null);
|
|
17
18
|
|
|
18
19
|
type OwnProps = {
|
|
19
20
|
/** 换掉默认的实心三角 */
|
|
@@ -65,12 +66,13 @@ export function NavAction({
|
|
|
65
66
|
children,
|
|
66
67
|
...props
|
|
67
68
|
}: NavActionProps) {
|
|
68
|
-
const inherited = useContext(
|
|
69
|
+
const inherited = useContext(getNavActionContext());
|
|
69
70
|
const layout = layoutProp ?? inherited ?? "inline";
|
|
70
71
|
const stacked = layout === "stacked";
|
|
71
72
|
|
|
72
73
|
const classes = cn(
|
|
73
|
-
|
|
74
|
+
// 4px 微圆角:官网"前往游戏"块就是这样,也和按钮一致
|
|
75
|
+
"shrink-0 rounded-sm font-medium whitespace-nowrap select-none",
|
|
74
76
|
"transition-colors duration-(--duration-fast) ease-standard",
|
|
75
77
|
focusRing,
|
|
76
78
|
layoutClass[layout],
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
2
2
|
import {
|
|
3
|
-
createContext,
|
|
4
3
|
useContext,
|
|
5
4
|
useRef,
|
|
6
5
|
type ComponentProps,
|
|
@@ -18,10 +17,13 @@ import { firstFocusableIn } from "../dialog/initial-focus";
|
|
|
18
17
|
import { GhostText } from "../ghost-text/GhostText";
|
|
19
18
|
import { IconButton } from "../icon-button/IconButton";
|
|
20
19
|
import { LinkElement, type LinkRender } from "../link-element/LinkElement";
|
|
21
|
-
import {
|
|
20
|
+
import { getNavActionContext } from "../nav-action/NavAction";
|
|
21
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
22
22
|
|
|
23
23
|
/** 导航项点了之后要把菜单关上 */
|
|
24
|
-
const
|
|
24
|
+
const getNavMenuContext = /* @__PURE__ */ createLazyContext<() => void>(
|
|
25
|
+
() => {},
|
|
26
|
+
);
|
|
25
27
|
|
|
26
28
|
export type NavMenuProps = {
|
|
27
29
|
/** 菜单钮,通常是顶栏最右边的 `<IconButton>`。不传就用 `open` / `onOpenChange` 自己控制 */
|
|
@@ -68,6 +70,8 @@ export function NavMenu({
|
|
|
68
70
|
className,
|
|
69
71
|
children,
|
|
70
72
|
}: NavMenuProps) {
|
|
73
|
+
const NavMenuContext = getNavMenuContext();
|
|
74
|
+
const NavActionContext = getNavActionContext();
|
|
71
75
|
const [isOpen, setOpen] = useControllableState({
|
|
72
76
|
value: open,
|
|
73
77
|
defaultValue: defaultOpen,
|
|
@@ -114,11 +118,11 @@ export function NavMenu({
|
|
|
114
118
|
ref={bodyRef}
|
|
115
119
|
className="flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain"
|
|
116
120
|
>
|
|
117
|
-
<NavMenuContext value={() => setOpen(false)}>
|
|
121
|
+
<NavMenuContext.Provider value={() => setOpen(false)}>
|
|
118
122
|
<nav aria-label={navLabel}>
|
|
119
123
|
<ul className="flex flex-col gap-1 p-4">{children}</ul>
|
|
120
124
|
</nav>
|
|
121
|
-
</NavMenuContext>
|
|
125
|
+
</NavMenuContext.Provider>
|
|
122
126
|
|
|
123
127
|
{tools && (
|
|
124
128
|
<div className="mx-4 flex flex-wrap gap-1 bg-surface-muted p-1">
|
|
@@ -146,7 +150,9 @@ export function NavMenu({
|
|
|
146
150
|
|
|
147
151
|
{footer && (
|
|
148
152
|
<div className="flex shrink-0 flex-col gap-2 p-4">
|
|
149
|
-
<NavActionContext value="block">
|
|
153
|
+
<NavActionContext.Provider value="block">
|
|
154
|
+
{footer}
|
|
155
|
+
</NavActionContext.Provider>
|
|
150
156
|
</div>
|
|
151
157
|
)}
|
|
152
158
|
</div>
|
|
@@ -204,7 +210,7 @@ export function NavMenuItem({
|
|
|
204
210
|
children,
|
|
205
211
|
...props
|
|
206
212
|
}: NavMenuItemProps) {
|
|
207
|
-
const close = useContext(
|
|
213
|
+
const close = useContext(getNavMenuContext());
|
|
208
214
|
const isLink = href !== undefined || render !== undefined;
|
|
209
215
|
|
|
210
216
|
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
|
@@ -171,7 +171,7 @@ export function PageHeaderBack({
|
|
|
171
171
|
...props
|
|
172
172
|
}: PageHeaderBackProps) {
|
|
173
173
|
const classes = cn(
|
|
174
|
-
"relative inline-flex size-10 shrink-0 items-center justify-center",
|
|
174
|
+
"relative inline-flex size-10 shrink-0 items-center justify-center rounded-sm",
|
|
175
175
|
"transition-colors duration-(--duration-fast) ease-standard",
|
|
176
176
|
focusRing,
|
|
177
177
|
disabled
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
useId,
|
|
5
4
|
useMemo,
|
|
@@ -18,6 +17,7 @@ import {
|
|
|
18
17
|
choiceMark,
|
|
19
18
|
} from "../checkbox/choice-style";
|
|
20
19
|
import { useFieldContext } from "../field/Field";
|
|
20
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
21
21
|
|
|
22
22
|
type RadioGroupContextValue = {
|
|
23
23
|
name: string;
|
|
@@ -28,7 +28,8 @@ type RadioGroupContextValue = {
|
|
|
28
28
|
invalid: boolean;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const getRadioGroupContext =
|
|
32
|
+
/* @__PURE__ */ createLazyContext<RadioGroupContextValue | null>(null);
|
|
32
33
|
|
|
33
34
|
export type RadioGroupOrientation = "vertical" | "horizontal";
|
|
34
35
|
|
|
@@ -64,6 +65,7 @@ export function RadioGroup({
|
|
|
64
65
|
className,
|
|
65
66
|
...props
|
|
66
67
|
}: RadioGroupProps) {
|
|
68
|
+
const RadioGroupContext = getRadioGroupContext();
|
|
67
69
|
const field = useFieldContext();
|
|
68
70
|
const autoName = useId();
|
|
69
71
|
const [current, setCurrent] = useControllableState<string | undefined>({
|
|
@@ -92,7 +94,7 @@ export function RadioGroup({
|
|
|
92
94
|
);
|
|
93
95
|
|
|
94
96
|
return (
|
|
95
|
-
<RadioGroupContext value={context}>
|
|
97
|
+
<RadioGroupContext.Provider value={context}>
|
|
96
98
|
<div
|
|
97
99
|
role="radiogroup"
|
|
98
100
|
// 字段是 <fieldset> 时名称由 <legend> 给;否则指向字段的标签
|
|
@@ -109,7 +111,7 @@ export function RadioGroup({
|
|
|
109
111
|
className,
|
|
110
112
|
)}
|
|
111
113
|
/>
|
|
112
|
-
</RadioGroupContext>
|
|
114
|
+
</RadioGroupContext.Provider>
|
|
113
115
|
);
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -134,7 +136,7 @@ export function Radio({
|
|
|
134
136
|
children,
|
|
135
137
|
...props
|
|
136
138
|
}: RadioProps) {
|
|
137
|
-
const group = useContext(
|
|
139
|
+
const group = useContext(getRadioGroupContext());
|
|
138
140
|
|
|
139
141
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
140
142
|
onChange?.(event);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
useMemo,
|
|
5
4
|
type ComponentProps,
|
|
@@ -14,6 +13,7 @@ import { decor } from "../../lib/decor";
|
|
|
14
13
|
import { focusRingInset } from "../../lib/focus-ring";
|
|
15
14
|
import { LinkElement, type LinkRender } from "../link-element/LinkElement";
|
|
16
15
|
import { Tag } from "../tag/Tag";
|
|
16
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
17
17
|
|
|
18
18
|
type ScheduleContextValue = {
|
|
19
19
|
start: string;
|
|
@@ -23,10 +23,11 @@ type ScheduleContextValue = {
|
|
|
23
23
|
describe: (start: string, end: string) => string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const getScheduleContext =
|
|
27
|
+
/* @__PURE__ */ createLazyContext<ScheduleContextValue | null>(null);
|
|
27
28
|
|
|
28
29
|
function useSchedule(part: string) {
|
|
29
|
-
const context = useContext(
|
|
30
|
+
const context = useContext(getScheduleContext());
|
|
30
31
|
if (!context) throw new Error(`${part} 要放在 Schedule 里面`);
|
|
31
32
|
return context;
|
|
32
33
|
}
|
|
@@ -86,6 +87,7 @@ export function Schedule({
|
|
|
86
87
|
children,
|
|
87
88
|
...props
|
|
88
89
|
}: ScheduleProps) {
|
|
90
|
+
const ScheduleContext = getScheduleContext();
|
|
89
91
|
const [scrollerRef, overflowing] = useOverflowing();
|
|
90
92
|
const dates = useMemo(() => eachDay(start, end), [start, end]);
|
|
91
93
|
const days = dates.length;
|
|
@@ -125,7 +127,7 @@ export function Schedule({
|
|
|
125
127
|
: null;
|
|
126
128
|
|
|
127
129
|
return (
|
|
128
|
-
<ScheduleContext value={context}>
|
|
130
|
+
<ScheduleContext.Provider value={context}>
|
|
129
131
|
<div
|
|
130
132
|
ref={scrollerRef}
|
|
131
133
|
{...props}
|
|
@@ -257,7 +259,7 @@ export function Schedule({
|
|
|
257
259
|
)}
|
|
258
260
|
</div>
|
|
259
261
|
</div>
|
|
260
|
-
</ScheduleContext>
|
|
262
|
+
</ScheduleContext.Provider>
|
|
261
263
|
);
|
|
262
264
|
}
|
|
263
265
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
useContext,
|
|
4
3
|
useId,
|
|
5
4
|
useMemo,
|
|
@@ -18,6 +17,7 @@ import {
|
|
|
18
17
|
type ControlSize,
|
|
19
18
|
type ControlVariant,
|
|
20
19
|
} from "../input/control-box";
|
|
20
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
21
21
|
|
|
22
22
|
export type SegmentedControlSize = ControlSize;
|
|
23
23
|
export type SegmentedControlVariant = ControlVariant;
|
|
@@ -32,7 +32,8 @@ type SegmentedContextValue = {
|
|
|
32
32
|
invalid: boolean;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const getSegmentedContext =
|
|
36
|
+
/* @__PURE__ */ createLazyContext<SegmentedContextValue | null>(null);
|
|
36
37
|
|
|
37
38
|
export type SegmentedControlProps = Omit<
|
|
38
39
|
ComponentProps<"div">,
|
|
@@ -85,6 +86,7 @@ export function SegmentedControl({
|
|
|
85
86
|
ref,
|
|
86
87
|
...props
|
|
87
88
|
}: SegmentedControlProps) {
|
|
89
|
+
const SegmentedContext = getSegmentedContext();
|
|
88
90
|
const field = useFieldContext();
|
|
89
91
|
// 选中的那块底画在轨道上:换一段时是同一块滑过去
|
|
90
92
|
const trackRef = useIndicator<HTMLDivElement>("[data-selected]");
|
|
@@ -116,7 +118,7 @@ export function SegmentedControl({
|
|
|
116
118
|
);
|
|
117
119
|
|
|
118
120
|
return (
|
|
119
|
-
<SegmentedContext value={context}>
|
|
121
|
+
<SegmentedContext.Provider value={context}>
|
|
120
122
|
<div
|
|
121
123
|
role="radiogroup"
|
|
122
124
|
// 字段是 <fieldset> 时名称由 <legend> 给;否则指向字段的标签
|
|
@@ -149,7 +151,7 @@ export function SegmentedControl({
|
|
|
149
151
|
className,
|
|
150
152
|
)}
|
|
151
153
|
/>
|
|
152
|
-
</SegmentedContext>
|
|
154
|
+
</SegmentedContext.Provider>
|
|
153
155
|
);
|
|
154
156
|
}
|
|
155
157
|
|
|
@@ -182,7 +184,7 @@ export function Segment({
|
|
|
182
184
|
children,
|
|
183
185
|
...props
|
|
184
186
|
}: SegmentProps) {
|
|
185
|
-
const context = useContext(
|
|
187
|
+
const context = useContext(getSegmentedContext());
|
|
186
188
|
if (!context) {
|
|
187
189
|
throw new Error("<Segment> 必须放在 <SegmentedControl> 里");
|
|
188
190
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Select as BaseSelect } from "@base-ui/react/select";
|
|
2
2
|
import {
|
|
3
|
-
createContext,
|
|
4
3
|
Fragment,
|
|
5
4
|
useContext,
|
|
6
5
|
useRef,
|
|
@@ -13,7 +12,7 @@ import { StatusDanger } from "../../icons/StatusDanger";
|
|
|
13
12
|
import { TriangleRight } from "../../icons/TriangleRight";
|
|
14
13
|
import { cn } from "../../lib/cn";
|
|
15
14
|
import {
|
|
16
|
-
|
|
15
|
+
getMenuVariantContext,
|
|
17
16
|
menuGroupLabel,
|
|
18
17
|
menuItem,
|
|
19
18
|
menuItemCurrent,
|
|
@@ -31,6 +30,7 @@ import {
|
|
|
31
30
|
type ControlSize,
|
|
32
31
|
type ControlVariant,
|
|
33
32
|
} from "../input/control-box";
|
|
33
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
34
34
|
|
|
35
35
|
export type SelectSize = ControlSize;
|
|
36
36
|
export type SelectVariant = ControlVariant;
|
|
@@ -107,7 +107,7 @@ export type SelectMultipleProps = SelectCommonProps & {
|
|
|
107
107
|
export type SelectProps = SelectSingleProps | SelectMultipleProps;
|
|
108
108
|
|
|
109
109
|
/** 面板里的选项要知道自己在不在多选的下拉里 */
|
|
110
|
-
const
|
|
110
|
+
const getSelectMultipleContext = /* @__PURE__ */ createLazyContext(false);
|
|
111
111
|
|
|
112
112
|
function joinedLabels(selected: SelectOption[]) {
|
|
113
113
|
return (
|
|
@@ -137,6 +137,8 @@ function joinedLabels(selected: SelectOption[]) {
|
|
|
137
137
|
* 选项只有两三个、又都该一眼看到时,用单选或页签,不用它。
|
|
138
138
|
*/
|
|
139
139
|
export function Select(props: SelectProps) {
|
|
140
|
+
const MenuVariantContext = getMenuVariantContext();
|
|
141
|
+
const SelectMultipleContext = getSelectMultipleContext();
|
|
140
142
|
const {
|
|
141
143
|
items,
|
|
142
144
|
placeholder,
|
|
@@ -253,8 +255,8 @@ export function Select(props: SelectProps) {
|
|
|
253
255
|
className={cn(menuPanel, "min-w-(--anchor-width)")}
|
|
254
256
|
>
|
|
255
257
|
<BaseSelect.List className="max-h-[min(var(--available-height),20rem)] overflow-y-auto overscroll-contain">
|
|
256
|
-
<MenuVariantContext value={panelVariant}>
|
|
257
|
-
<SelectMultipleContext value={multiple}>
|
|
258
|
+
<MenuVariantContext.Provider value={panelVariant}>
|
|
259
|
+
<SelectMultipleContext.Provider value={multiple}>
|
|
258
260
|
{children ??
|
|
259
261
|
items.map((item) => (
|
|
260
262
|
<SelectItem
|
|
@@ -265,8 +267,8 @@ export function Select(props: SelectProps) {
|
|
|
265
267
|
{item.label}
|
|
266
268
|
</SelectItem>
|
|
267
269
|
))}
|
|
268
|
-
</SelectMultipleContext>
|
|
269
|
-
</MenuVariantContext>
|
|
270
|
+
</SelectMultipleContext.Provider>
|
|
271
|
+
</MenuVariantContext.Provider>
|
|
270
272
|
</BaseSelect.List>
|
|
271
273
|
</BaseSelect.Popup>
|
|
272
274
|
</BaseSelect.Positioner>
|
|
@@ -320,8 +322,8 @@ export function SelectItem({
|
|
|
320
322
|
children,
|
|
321
323
|
...props
|
|
322
324
|
}: SelectItemProps) {
|
|
323
|
-
const variant = useContext(
|
|
324
|
-
const multiple = useContext(
|
|
325
|
+
const variant = useContext(getMenuVariantContext());
|
|
326
|
+
const multiple = useContext(getSelectMultipleContext());
|
|
325
327
|
|
|
326
328
|
return (
|
|
327
329
|
<BaseSelect.Item
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
2
2
|
import {
|
|
3
|
-
createContext,
|
|
4
3
|
useContext,
|
|
5
4
|
useMemo,
|
|
6
5
|
type ComponentProps,
|
|
@@ -11,9 +10,14 @@ import { usePortalScope } from "../../hooks/usePortalScope";
|
|
|
11
10
|
import { cn } from "../../lib/cn";
|
|
12
11
|
import { focusRingInset } from "../../lib/focus-ring";
|
|
13
12
|
import { LinkElement, type LinkRender } from "../link-element/LinkElement";
|
|
14
|
-
import {
|
|
13
|
+
import { getNavActionContext } from "../nav-action/NavAction";
|
|
14
|
+
import { createLazyContext } from "../../lib/create-lazy-context";
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const getSideRailContext = /* @__PURE__ */ createLazyContext<{
|
|
17
|
+
collapsed: boolean;
|
|
18
|
+
}>({
|
|
19
|
+
collapsed: false,
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* 一行栏目的样子:普通栏目和二级的父项共用。
|
|
@@ -92,10 +96,12 @@ export function SideRail({
|
|
|
92
96
|
children,
|
|
93
97
|
...props
|
|
94
98
|
}: SideRailProps) {
|
|
99
|
+
const SideRailContext = getSideRailContext();
|
|
100
|
+
const NavActionContext = getNavActionContext();
|
|
95
101
|
const context = useMemo(() => ({ collapsed }), [collapsed]);
|
|
96
102
|
|
|
97
103
|
return (
|
|
98
|
-
<SideRailContext value={context}>
|
|
104
|
+
<SideRailContext.Provider value={context}>
|
|
99
105
|
<nav
|
|
100
106
|
{...props}
|
|
101
107
|
data-collapsed={collapsed ? "" : undefined}
|
|
@@ -137,9 +143,9 @@ export function SideRail({
|
|
|
137
143
|
<div
|
|
138
144
|
className={cn("flex shrink-0 p-3", collapsed && "justify-center")}
|
|
139
145
|
>
|
|
140
|
-
<NavActionContext value={collapsed ? "stacked" : "block"}>
|
|
146
|
+
<NavActionContext.Provider value={collapsed ? "stacked" : "block"}>
|
|
141
147
|
{action}
|
|
142
|
-
</NavActionContext>
|
|
148
|
+
</NavActionContext.Provider>
|
|
143
149
|
</div>
|
|
144
150
|
)}
|
|
145
151
|
|
|
@@ -154,7 +160,7 @@ export function SideRail({
|
|
|
154
160
|
</div>
|
|
155
161
|
)}
|
|
156
162
|
</nav>
|
|
157
|
-
</SideRailContext>
|
|
163
|
+
</SideRailContext.Provider>
|
|
158
164
|
);
|
|
159
165
|
}
|
|
160
166
|
|
|
@@ -195,7 +201,7 @@ export function SideRailItem({
|
|
|
195
201
|
children,
|
|
196
202
|
...props
|
|
197
203
|
}: SideRailItemProps) {
|
|
198
|
-
const { collapsed } = useContext(
|
|
204
|
+
const { collapsed } = useContext(getSideRailContext());
|
|
199
205
|
const { anchorRef, portalRef } = usePortalScope();
|
|
200
206
|
const isLink = href !== undefined || render !== undefined;
|
|
201
207
|
|
|
@@ -294,7 +300,7 @@ export function SideRailGroup({
|
|
|
294
300
|
children,
|
|
295
301
|
...props
|
|
296
302
|
}: SideRailGroupProps) {
|
|
297
|
-
const { collapsed } = useContext(
|
|
303
|
+
const { collapsed } = useContext(getSideRailContext());
|
|
298
304
|
|
|
299
305
|
return (
|
|
300
306
|
<li {...props} className={cn("not-first:mt-2", className)}>
|