@primer/react-brand 0.81.0 → 0.81.1-rc.2c56871a
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/docs/components/RiverBreakoutTabs/index.md +4 -3
- package/docs/forms/ToggleSwitch/index.md +53 -19
- package/docs/index.md +2 -2
- package/esm/forms/FormControl/FormControl.d.ts.map +1 -1
- package/esm/forms/FormControl/FormControl.js +8 -8
- package/esm/forms/FormControl/FormControl.js.map +1 -1
- package/esm/forms/FormControl/FormControl.module-B7McDwHm.css +1 -0
- package/esm/forms/FormControl/FormControl.module.js +5 -4
- package/esm/forms/FormControl/FormControl.module.js.map +1 -1
- package/esm/forms/ToggleSwitch/ToggleSwitch.d.ts +10 -0
- package/esm/forms/ToggleSwitch/ToggleSwitch.d.ts.map +1 -1
- package/esm/forms/ToggleSwitch/ToggleSwitch.js +101 -52
- package/esm/forms/ToggleSwitch/ToggleSwitch.js.map +1 -1
- package/esm/forms/ToggleSwitch/ToggleSwitch.module-PKy9cLy8.css +1 -0
- package/esm/forms/ToggleSwitch/ToggleSwitch.module.js +7 -1
- package/esm/forms/ToggleSwitch/ToggleSwitch.module.js.map +1 -1
- package/esm/packages/design-tokens/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors-with-modes-QUNsZVCZ.css +1 -0
- package/esm/river/RiverBreakoutTabs/RiverBreakoutTabs.d.ts.map +1 -1
- package/esm/river/RiverBreakoutTabs/RiverBreakoutTabs.js +1 -0
- package/esm/river/RiverBreakoutTabs/RiverBreakoutTabs.js.map +1 -1
- package/lib/css/main.css +194 -94
- package/lib/design-tokens/css/tokens/base/colors/color-scales-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/base/colors/light.css +1 -1
- package/lib/design-tokens/css/tokens/base/size/size.css +1 -1
- package/lib/design-tokens/css/tokens/base/typography/typography.css +1 -1
- package/lib/design-tokens/css/tokens/functional/animation/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/colors/global-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/colors/global.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/accordion/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/action-menu/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/anchor-nav/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/bento/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/blinking-cursor/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/breadcrumbs/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/button/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/button/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/card/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/carousel-pagination/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/carousel-pagination/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/comparison-table/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/comparison-table/comparison-table.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/control/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/cta-banner/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/eyebrow-banner/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/eyebrow-banner/eyebrow-banner.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/faq/faq.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/feature-comparison-table/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/feature-comparison-table/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/footer/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/frosted-glass-vfx/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/frosted-glass-vfx/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/grid/grid.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/hero/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon-button/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon-button/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/icon-button/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/ide/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/ide/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/image/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-code/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-code/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/inline-link/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/label/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/label/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/link/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/link/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/logosuite/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/media-playlist/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/media-playlist/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/nav-list/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/pricing-options/pricing-options.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/prose/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/prose/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river/river.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/river-story-scroll/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/section/section.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/spinner/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/spinner/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/spinner/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/statistic/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/sub-nav/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/sub-nav/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/subdomain-nav-bar/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tabs/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/testimonial-group/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/text-cursor-animation/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tiles/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tiles/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/timeline/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/toggle-switch/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors-with-modes.css +12 -12
- package/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors.css +4 -4
- package/lib/design-tokens/css/tokens/functional/components/token/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/token/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tooltip/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/tooltip/colors.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/video-player/base.css +1 -1
- package/lib/design-tokens/css/tokens/functional/components/video-player/colors-with-modes.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/border.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/breakpoints.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size-coarse.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size-fine.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/size.css +1 -1
- package/lib/design-tokens/css/tokens/functional/size/viewport.css +1 -1
- package/lib/design-tokens/css/tokens/functional/typography/typography-responsive.css +1 -1
- package/lib/design-tokens/css/tokens/functional/typography/typography.css +1 -1
- package/lib/design-tokens/js/module/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/js/module/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/js/module/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/button/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/carousel-pagination/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/feature-comparison-table/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/icon-button/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/icon-button/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/spinner/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/spinner/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/testimonial-group/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tiles/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/toggle-switch/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/toggle-switch/colors.js +8 -8
- package/lib/design-tokens/js/module/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/js/module/tokens/functional/typography/typography.js +1 -1
- package/lib/design-tokens/js/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/js/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/js/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/js/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/button/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/carousel-pagination/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/feature-comparison-table/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/icon-button/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/icon-button/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/spinner/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/spinner/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/testimonial-group/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tiles/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/toggle-switch/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/toggle-switch/colors.js +4 -4
- package/lib/design-tokens/js/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/js/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/js/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/js/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/js/tokens/functional/typography/typography.js +1 -1
- package/lib/design-tokens/json/colors.json +3 -3
- package/lib/design-tokens/scss/tokens/base/colors/light.scss +1 -1
- package/lib/design-tokens/scss/tokens/base/size/size.scss +1 -1
- package/lib/design-tokens/scss/tokens/base/typography/typography.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/animation/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/colors/global.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/bento/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/button/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/card/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/card/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/carousel-pagination/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/comparison-table/comparison-table.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/eyebrow-banner/eyebrow-banner.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/faq/faq.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/feature-comparison-table/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/footer/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/footer/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/frosted-glass-vfx/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/grid/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/grid/grid.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/hero/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/icon/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/icon-button/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/icon-button/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/ide/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/image/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-code/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-link/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/inline-link/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/label/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/link/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/logosuite/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/logosuite/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/media-playlist/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/pricing-options/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/pricing-options/pricing-options.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/prose/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/river/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/river/river.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/section/section.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/spinner/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/spinner/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/statistic/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/sub-nav/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tabs/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tabs/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/testimonial/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/testimonial/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/testimonial-group/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/text-cursor-animation/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/text-cursor-animation/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tiles/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/timeline/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/timeline/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/toggle-switch/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/toggle-switch/colors.scss +4 -4
- package/lib/design-tokens/scss/tokens/functional/components/token/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/tooltip/colors.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/components/video-player/base.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/border.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/breakpoints.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size-coarse.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size-fine.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/size.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/size/viewport.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/typography/typography-responsive.scss +1 -1
- package/lib/design-tokens/scss/tokens/functional/typography/typography.scss +1 -1
- package/lib/design-tokens/ts/tokens/base/colors/light.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/colors/light.js +1 -1
- package/lib/design-tokens/ts/tokens/base/size/size.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/size/size.js +1 -1
- package/lib/design-tokens/ts/tokens/base/typography/typography.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/base/typography/typography.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/animation/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/animation/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/colors/global.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/colors/global.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/bento/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/bento/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/button/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/button/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/card/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/carousel-pagination/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/carousel-pagination/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/comparison-table/comparison-table.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/comparison-table/comparison-table.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/eyebrow-banner/eyebrow-banner.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/eyebrow-banner/eyebrow-banner.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/faq.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/faq/faq.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/feature-comparison-table/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/feature-comparison-table/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/footer/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/frosted-glass-vfx/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/frosted-glass-vfx/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/grid.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/grid/grid.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/hero/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/hero/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon-button/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon-button/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon-button/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/icon-button/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/ide/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/ide/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/image/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/image/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-code/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-code/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/inline-link/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/label/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/label/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/link/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/link/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/logosuite/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/media-playlist/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/media-playlist/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/pricing-options.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/pricing-options/pricing-options.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/prose/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/prose/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/river.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/river/river.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/section/section.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/section/section.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/spinner/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/spinner/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/spinner/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/spinner/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/statistic/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/statistic/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/sub-nav/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/sub-nav/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tabs/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial-group/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/testimonial-group/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/text-cursor-animation/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tiles/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tiles/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/timeline/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/toggle-switch/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/toggle-switch/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/toggle-switch/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/toggle-switch/colors.js +4 -4
- package/lib/design-tokens/ts/tokens/functional/components/token/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/token/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tooltip/colors.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/tooltip/colors.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/video-player/base.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/components/video-player/base.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/border.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/border.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/breakpoints.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/breakpoints.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-coarse.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-coarse.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-fine.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size-fine.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/size.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/viewport.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/size/viewport.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography-responsive.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography-responsive.js +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography.d.ts +1 -1
- package/lib/design-tokens/ts/tokens/functional/typography/typography.js +1 -1
- package/lib/forms/ToggleSwitch/ToggleSwitch.d.ts +10 -0
- package/lib/index.js +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/esm/forms/FormControl/FormControl.module-NDvIk_Aq.css +0 -1
- package/esm/forms/ToggleSwitch/ToggleSwitch.module-C_gXnHNW.css +0 -1
- package/esm/packages/design-tokens/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors-with-modes-Byi9AmE8.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleSwitch.js","names":[],"sources":["../../../src/forms/ToggleSwitch/ToggleSwitch.tsx"],"sourcesContent":["import React, {forwardRef, useEffect, useState, type ButtonHTMLAttributes, type MouseEventHandler} from 'react'\nimport {clsx} from 'clsx'\nimport {useId} from '../../hooks/useId'\nimport {Spinner} from '../../Spinner/Spinner'\n\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/toggle-switch/base.css'\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors-with-modes.css'\nimport styles from './ToggleSwitch.module.css'\n\ntype ToggleSwitchSize = 'small' | 'medium'\ntype ToggleSwitchSpinnerPosition = 'start' | 'end'\n\ntype ToggleSwitchButtonPropKeysToOmit =\n | 'aria-busy'\n | 'aria-checked'\n | 'aria-disabled'\n | 'children'\n | 'onChange'\n | 'role'\n | 'type'\n\nexport type ToggleSwitchProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, ToggleSwitchButtonPropKeysToOmit> & {\n 'data-testid'?: string\n checked?: boolean\n defaultChecked?: boolean\n onChange?: (checked: boolean) => void\n loading?: boolean\n size?: ToggleSwitchSize\n loadingLabel?: string\n loadingLabelDelay?: number\n spinnerPosition?: ToggleSwitchSpinnerPosition\n}\n\nexport type ToggleSwitchInternalProps = ToggleSwitchProps & {\n toggleSwitchSpinnerInLabel?: boolean\n}\n\nconst testIds = {\n root: 'ToggleSwitch',\n spinner: 'ToggleSwitch-spinner',\n loadingAnnouncement: 'ToggleSwitch-loading-announcement',\n}\n\ntype ToggleSwitchComponent = React.ForwardRefExoticComponent<ToggleSwitchProps & React.RefAttributes<HTMLButtonElement>>\n\nconst Root: ToggleSwitchComponent = forwardRef<HTMLButtonElement, ToggleSwitchInternalProps>(function ToggleSwitch(\n {\n checked,\n defaultChecked = false,\n onChange,\n onClick,\n disabled = false,\n loading = false,\n size = 'medium',\n loadingLabel = 'Loading',\n loadingLabelDelay = 2000,\n spinnerPosition = 'end',\n toggleSwitchSpinnerInLabel = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'data-testid': testId,\n ...rest\n },\n ref,\n) {\n const uniqueId = useId(id)\n const loadingId = `${uniqueId}-loading`\n const [internalChecked, setInternalChecked] = useState(defaultChecked)\n const [announceLoading, setAnnounceLoading] = useState(false)\n const isChecked = checked ?? internalChecked\n\n useEffect(() => {\n setAnnounceLoading(false)\n if (!loading) return\n\n const timeout = setTimeout(() => setAnnounceLoading(true), Math.max(0, loadingLabelDelay))\n return () => clearTimeout(timeout)\n }, [loading, loadingLabelDelay])\n\n const describedBy =\n [ariaDescribedBy, loading && announceLoading && loadingLabel && loadingId].filter(Boolean).join(' ') || undefined\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (disabled) {\n event.preventDefault()\n event.stopPropagation()\n return\n }\n\n onClick?.(event)\n if (event.defaultPrevented) return\n\n const nextChecked = !isChecked\n if (checked === undefined) setInternalChecked(nextChecked)\n onChange?.(nextChecked)\n }\n\n const spinnerElement =\n !toggleSwitchSpinnerInLabel && loading ? (\n <span className={styles['ToggleSwitch-spinnerSlot']} aria-hidden=\"true\">\n <Spinner\n size=\"small\"\n accessibleLabel={null}\n className={styles['ToggleSwitch-spinner']}\n data-testid={testIds.spinner}\n />\n </span>\n ) : null\n\n return (\n <div\n className={clsx(styles.ToggleSwitch, styles[`ToggleSwitch--${size}`], className)}\n data-testid={testId || testIds.root}\n >\n {spinnerPosition === 'start' && spinnerElement}\n <button\n {...rest}\n id={uniqueId}\n ref={ref}\n type=\"button\"\n role=\"switch\"\n aria-checked={isChecked}\n aria-disabled={disabled || undefined}\n aria-busy={loading || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={describedBy}\n aria-invalid={ariaInvalid}\n className={clsx(styles['ToggleSwitch-button'], disabled && styles['ToggleSwitch-button--unavailable'])}\n onClick={handleClick}\n >\n <span className={styles['ToggleSwitch-track']} aria-hidden=\"true\">\n <span\n className={clsx(\n styles['ToggleSwitch-thumb'],\n isChecked && styles['ToggleSwitch-thumb--checked'],\n disabled && styles['ToggleSwitch-thumb--disabled'],\n )}\n />\n </span>\n </button>\n {spinnerPosition === 'end' && spinnerElement}\n <span\n id={loadingId}\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className=\"visually-hidden\"\n data-testid={testIds.loadingAnnouncement}\n >\n {loading && announceLoading ? loadingLabel : null}\n </span>\n </div>\n )\n})\n\n/**\n * Use ToggleSwitch for settings that take effect immediately.\n * @see https://primer.style/brand/forms/ToggleSwitch\n */\nexport const ToggleSwitch = Object.assign(Root, {testIds})\n"],"mappings":";;;;;;;;;AAqCA,IAAM,IAAU;CACd,MAAM;CACN,SAAS;CACT,qBAAqB;AACvB,GAIM,IAA8B,EAAyD,SAC3F,EACE,YACA,oBAAiB,IACjB,aACA,YACA,cAAW,IACX,aAAU,IACV,UAAO,UACP,kBAAe,WACf,uBAAoB,KACpB,qBAAkB,OAClB,gCAA6B,IAC7B,OACA,cACA,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,GACf,GAAG,KAEL,GACA;CACA,IAAM,IAAW,EAAM,CAAE,GACnB,IAAY,GAAG,EAAS,WACxB,CAAC,GAAiB,KAAsB,EAAS,CAAc,GAC/D,CAAC,GAAiB,KAAsB,EAAS,EAAK,GACtD,IAAY,KAAW;CAE7B,QAAgB;EAEd,IADA,EAAmB,EAAK,GACpB,CAAC,GAAS;EAEd,IAAM,IAAU,iBAAiB,EAAmB,EAAI,GAAG,KAAK,IAAI,GAAG,CAAiB,CAAC;EACzF,aAAa,aAAa,CAAO;CACnC,GAAG,CAAC,GAAS,CAAiB,CAAC;CAE/B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;AAET,CAAC,GAMY,IAAe,OAAO,OAAO,GAAM,EAAC,WAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.js","names":[],"sources":["../../../src/forms/ToggleSwitch/ToggleSwitch.tsx"],"sourcesContent":["import React, {forwardRef, useEffect, useRef, useState, type ButtonHTMLAttributes, type MouseEventHandler} from 'react'\nimport {clsx} from 'clsx'\nimport {useId} from '../../hooks/useId'\nimport {Spinner} from '../../Spinner/Spinner'\nimport {Text} from '../../Text/Text'\n\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/toggle-switch/base.css'\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/toggle-switch/colors-with-modes.css'\nimport styles from './ToggleSwitch.module.css'\n\ntype ToggleSwitchSize = 'small' | 'medium'\ntype ToggleSwitchSpinnerPosition = 'start' | 'end'\ntype ToggleSwitchStatusLabelPosition = 'start' | 'end'\ntype ToggleSwitchLabels = {\n on?: string\n off?: string\n}\n\ntype ToggleSwitchButtonPropKeysToOmit =\n | 'aria-busy'\n | 'aria-checked'\n | 'aria-disabled'\n | 'children'\n | 'onChange'\n | 'role'\n | 'type'\n\nexport type ToggleSwitchProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, ToggleSwitchButtonPropKeysToOmit> & {\n 'data-testid'?: string\n checked?: boolean\n defaultChecked?: boolean\n onChange?: (checked: boolean) => void\n loading?: boolean\n size?: ToggleSwitchSize\n loadingLabel?: string\n loadingLabelDelay?: number\n spinnerPosition?: ToggleSwitchSpinnerPosition\n hasStatusLabel?: boolean\n statusLabelPosition?: ToggleSwitchStatusLabelPosition\n labels?: ToggleSwitchLabels\n}\n\nexport type ToggleSwitchInternalProps = ToggleSwitchProps & {\n toggleSwitchSpinnerInLabel?: boolean\n}\n\nconst testIds = {\n root: 'ToggleSwitch',\n spinner: 'ToggleSwitch-spinner',\n loadingAnnouncement: 'ToggleSwitch-loading-announcement',\n statusAnnouncement: 'ToggleSwitch-status-announcement',\n statusLabel: 'ToggleSwitch-status-label',\n}\n\ntype ToggleSwitchComponent = React.ForwardRefExoticComponent<ToggleSwitchProps & React.RefAttributes<HTMLButtonElement>>\n\nconst Root: ToggleSwitchComponent = forwardRef<HTMLButtonElement, ToggleSwitchInternalProps>(function ToggleSwitch(\n {\n checked,\n defaultChecked = false,\n onChange,\n onClick,\n disabled = false,\n loading = false,\n size = 'medium',\n loadingLabel = 'Loading',\n loadingLabelDelay = 2000,\n spinnerPosition = 'end',\n hasStatusLabel = false,\n statusLabelPosition = 'start',\n labels: {on: statusLabelOn = 'On', off: statusLabelOff = 'Off'} = {},\n toggleSwitchSpinnerInLabel = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'data-testid': testId,\n ...rest\n },\n ref,\n) {\n const uniqueId = useId(id)\n const statusDescriptionId = useId()\n const loadingId = `${uniqueId}-loading`\n const [internalChecked, setInternalChecked] = useState(defaultChecked)\n const [announceLoading, setAnnounceLoading] = useState(false)\n const [statusAnnouncement, setStatusAnnouncement] = useState('')\n const [pendingStatusChange, setPendingStatusChange] = useState<boolean | null>(null)\n const isChecked = checked ?? internalChecked\n const activeStatusLabel = isChecked ? statusLabelOn : statusLabelOff\n const defaultStatusLabel = isChecked ? 'On' : 'Off'\n const hasCustomStatusLabels = statusLabelOn !== 'On' || statusLabelOff !== 'Off'\n const hasStatusDescription = hasStatusLabel && activeStatusLabel !== defaultStatusLabel\n const previousChecked = useRef(isChecked)\n\n useEffect(() => {\n const stateChanged = previousChecked.current !== isChecked\n previousChecked.current = isChecked\n\n if (stateChanged) {\n setStatusAnnouncement(pendingStatusChange === isChecked && hasStatusDescription ? activeStatusLabel : '')\n } else {\n setStatusAnnouncement(current => (hasStatusDescription && current === activeStatusLabel ? current : ''))\n }\n\n if (pendingStatusChange !== null) setPendingStatusChange(null)\n }, [activeStatusLabel, hasStatusDescription, isChecked, pendingStatusChange])\n\n useEffect(() => {\n setAnnounceLoading(false)\n if (!loading) return\n\n const timeout = setTimeout(() => setAnnounceLoading(true), Math.max(0, loadingLabelDelay))\n return () => clearTimeout(timeout)\n }, [loading, loadingLabelDelay])\n\n const describedBy =\n [\n hasStatusDescription && statusDescriptionId,\n ariaDescribedBy,\n loading && announceLoading && loadingLabel && loadingId,\n ]\n .filter(Boolean)\n .join(' ') || undefined\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (disabled) {\n event.preventDefault()\n event.stopPropagation()\n return\n }\n\n onClick?.(event)\n if (event.defaultPrevented) return\n\n const nextChecked = !isChecked\n if (hasStatusLabel && hasCustomStatusLabels) setPendingStatusChange(nextChecked)\n if (checked === undefined) setInternalChecked(nextChecked)\n onChange?.(nextChecked)\n }\n\n const spinnerElement =\n !toggleSwitchSpinnerInLabel && loading ? (\n <span className={styles['ToggleSwitch-spinnerSlot']} aria-hidden=\"true\">\n <Spinner\n size=\"small\"\n accessibleLabel={null}\n className={styles['ToggleSwitch-spinner']}\n data-testid={testIds.spinner}\n />\n </span>\n ) : null\n\n // Both labels share one grid cell so the wider label reserves space and state changes do not shift layout.\n const statusLabelElement = hasStatusLabel ? (\n <span\n className={clsx(styles['ToggleSwitch-statusLabel'], styles[`ToggleSwitch-statusLabel--${statusLabelPosition}`])}\n aria-hidden=\"true\"\n data-testid={testIds.statusLabel}\n >\n <Text\n as=\"span\"\n size=\"100\"\n variant=\"muted\"\n className={clsx(\n styles['ToggleSwitch-statusLabelText'],\n !isChecked && styles['ToggleSwitch-statusLabelText--hidden'],\n )}\n >\n {statusLabelOn}\n </Text>\n <Text\n as=\"span\"\n size=\"100\"\n variant=\"muted\"\n className={clsx(\n styles['ToggleSwitch-statusLabelText'],\n isChecked && styles['ToggleSwitch-statusLabelText--hidden'],\n )}\n >\n {statusLabelOff}\n </Text>\n </span>\n ) : null\n\n return (\n <div\n className={clsx(\n styles.ToggleSwitch,\n styles[`ToggleSwitch--${size}`],\n hasStatusLabel && styles['ToggleSwitch--withStatusLabel'],\n className,\n )}\n data-testid={testId || testIds.root}\n >\n {spinnerPosition === 'start' && spinnerElement}\n <button\n {...rest}\n id={uniqueId}\n ref={ref}\n type=\"button\"\n role=\"switch\"\n aria-checked={isChecked}\n aria-disabled={disabled || undefined}\n aria-busy={loading || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={describedBy}\n aria-invalid={ariaInvalid}\n className={clsx(styles['ToggleSwitch-button'], disabled && styles['ToggleSwitch-button--unavailable'])}\n onClick={handleClick}\n >\n {statusLabelPosition === 'start' && statusLabelElement}\n <span className={styles['ToggleSwitch-track']} aria-hidden=\"true\">\n <span\n className={clsx(\n styles['ToggleSwitch-thumb'],\n isChecked && styles['ToggleSwitch-thumb--checked'],\n disabled && styles['ToggleSwitch-thumb--disabled'],\n )}\n />\n </span>\n {statusLabelPosition === 'end' && statusLabelElement}\n </button>\n {spinnerPosition === 'end' && spinnerElement}\n {hasStatusDescription ? (\n <span id={statusDescriptionId} className=\"visually-hidden\">\n {activeStatusLabel}\n </span>\n ) : null}\n {hasStatusLabel && hasCustomStatusLabels ? (\n <span\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className=\"visually-hidden\"\n data-testid={testIds.statusAnnouncement}\n >\n {statusAnnouncement}\n </span>\n ) : null}\n <span\n id={loadingId}\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n className=\"visually-hidden\"\n data-testid={testIds.loadingAnnouncement}\n >\n {loading && announceLoading ? loadingLabel : null}\n </span>\n </div>\n )\n})\n\n/**\n * Use ToggleSwitch for settings that take effect immediately.\n * @see https://primer.style/brand/forms/ToggleSwitch\n */\nexport const ToggleSwitch = Object.assign(Root, {testIds})\n"],"mappings":";;;;;;;;;;AA8CA,IAAM,IAAU;CACd,MAAM;CACN,SAAS;CACT,qBAAqB;CACrB,oBAAoB;CACpB,aAAa;AACf,GAIM,IAA8B,EAAyD,SAC3F,EACE,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,mCAAmC;IACrG,SAAS;cAdX;KAgBG,MAAwB,WAAW;KACpC,kBAAC,QAAD;MAAM,WAAW,EAAO;MAAuB,eAAY;gBACzD,kBAAC,QAAD,EACE,WAAW,EACT,EAAO,uBACP,KAAa,EAAO,gCACpB,KAAY,EAAO,+BACrB,EACD,CAAA;KACG,CAAA;KACL,MAAwB,SAAS;IAC5B;;GACP,MAAoB,SAAS;GAC7B,IACC,kBAAC,QAAD;IAAM,IAAI;IAAqB,WAAU;cACtC;GACG,CAAA,IACJ;GACH,KAAkB,IACjB,kBAAC,QAAD;IACE,MAAK;IACL,aAAU;IACV,eAAY;IACZ,WAAU;IACV,eAAa,EAAQ;cAEpB;GACG,CAAA,IACJ;GACJ,kBAAC,QAAD;IACE,IAAI;IACJ,MAAK;IACL,aAAU;IACV,eAAY;IACZ,WAAU;IACV,eAAa,EAAQ;cAEpB,KAAW,IAAkB,IAAe;GACzC,CAAA;EACH;;AAET,CAAC,GAMY,IAAe,OAAO,OAAO,GAAM,EAAC,WAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.Primer_Brand__ToggleSwitch-module__ToggleSwitch___jeVpE{align-items:center;gap:var(--brand-ToggleSwitch-loading-gap);vertical-align:middle;flex-shrink:0;display:inline-flex}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ{min-height:var(--brand-ToggleSwitch-target-minHeight);justify-content:center;align-items:center;gap:var(--base-size-8);cursor:pointer;appearance:none;background:0 0;border:0;padding:0;display:flex}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--withStatusLabel___LGu2L{flex-shrink:1;min-inline-size:0;max-inline-size:100%}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--withStatusLabel___LGu2L .Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ{min-inline-size:0;max-inline-size:100%}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:focus-visible{outline:none}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:focus-visible .Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{outline:var(--brand-ToggleSwitch-focus-width) solid var(--brand-color-focus);outline-offset:var(--brand-ToggleSwitch-focus-offset)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR{cursor:not-allowed}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{box-sizing:border-box;border:var(--brand-ToggleSwitch-track-borderWidth) solid var(--brand-ToggleSwitch-track-borderColor);border-radius:var(--brand-ToggleSwitch-track-borderRadius);background:var(--brand-ToggleSwitch-track-bgColor);flex:none;display:block;position:relative}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel___8gqdA{word-wrap:anywhere;min-inline-size:0;max-inline-size:100%;display:grid}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--start___gl9U_{justify-items:end}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--end___IoumP{justify-items:start}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--start___gl9U_ .Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4{text-align:end}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--end___IoumP .Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4{text-align:start}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4{grid-area:1/1}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText--hidden___DuJ9i{visibility:hidden}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{box-sizing:border-box;border:var(--brand-ToggleSwitch-thumb-borderWidth) solid var(--brand-ToggleSwitch-thumb-borderColor);border-radius:var(--brand-ToggleSwitch-thumb-borderRadius);background:var(--brand-ToggleSwitch-thumb-off-bgColor-rest);transition:inset-inline-start var(--brand-animation-duration-faster) var(--brand-animation-easing-default);position:absolute;top:50%;transform:translateY(-50%)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd{background:var(--brand-ToggleSwitch-thumb-on-bgColor-rest)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:not(.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR):hover .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{background:var(--brand-ToggleSwitch-thumb-off-bgColor-hover)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:not(.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR):hover .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd{background:var(--brand-ToggleSwitch-thumb-on-bgColor-hover)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--disabled___V14xX{background:var(--brand-ToggleSwitch-thumb-disabled-bgColor)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--medium___3nBxC .Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{width:var(--brand-ToggleSwitch-track-width-medium);height:var(--brand-ToggleSwitch-track-height-medium)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--small___rA6Qp .Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{width:var(--brand-ToggleSwitch-track-width-small);height:var(--brand-ToggleSwitch-track-height-small)}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--medium___3nBxC .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{width:var(--brand-ToggleSwitch-thumb-size-medium);height:var(--brand-ToggleSwitch-thumb-size-medium);inset-inline-start:calc(var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth))}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--small___rA6Qp .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{width:var(--brand-ToggleSwitch-thumb-size-small);height:var(--brand-ToggleSwitch-thumb-size-small);inset-inline-start:calc(var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth))}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--medium___3nBxC .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd{inset-inline-start:calc(var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth) + var(--brand-ToggleSwitch-thumb-travel-medium))}.Primer_Brand__ToggleSwitch-module__ToggleSwitch--small___rA6Qp .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd{inset-inline-start:calc(var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth) + var(--brand-ToggleSwitch-thumb-travel-small))}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-spinnerSlot___kHm79{flex:0 0 var(--brand-ToggleSwitch-loading-size);width:var(--brand-ToggleSwitch-loading-size);height:var(--brand-ToggleSwitch-loading-size);pointer-events:none;justify-content:center;align-items:center;display:flex}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-spinner___7lOlX{color:var(--brand-ToggleSwitch-loading-fgColor);animation-duration:var(--brand-ToggleSwitch-loading-duration)}@media (prefers-reduced-motion:reduce){.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{transition:none}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-spinner___7lOlX{animation:none}}@media (forced-colors:active){.Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{background:canvas;border-color:buttontext}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM,.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:not(.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR):hover .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM{forced-color-adjust:none;background:buttontext;border-color:buttontext}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd,.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:not(.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR):hover .Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd{background:highlight}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--disabled___V14xX{background:graytext}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ:focus-visible .Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK{outline-color:highlight}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-spinner___7lOlX{color:canvastext}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4{color:buttontext}.Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR .Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4{color:graytext}}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import './ToggleSwitch.module-
|
|
1
|
+
import './ToggleSwitch.module-PKy9cLy8.css';//#region src/forms/ToggleSwitch/ToggleSwitch.module.css
|
|
2
2
|
var e = "Primer_Brand__ToggleSwitch-module__ToggleSwitch___jeVpE", t = {
|
|
3
3
|
ToggleSwitch: e,
|
|
4
4
|
"ToggleSwitch-button": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-button___OGPOZ",
|
|
5
|
+
"ToggleSwitch--withStatusLabel": "Primer_Brand__ToggleSwitch-module__ToggleSwitch--withStatusLabel___LGu2L",
|
|
5
6
|
"ToggleSwitch-track": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-track___ROVFK",
|
|
6
7
|
"ToggleSwitch-button--unavailable": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-button--unavailable___NJjiR",
|
|
8
|
+
"ToggleSwitch-statusLabel": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel___8gqdA",
|
|
9
|
+
"ToggleSwitch-statusLabel--start": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--start___gl9U_",
|
|
10
|
+
"ToggleSwitch-statusLabel--end": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabel--end___IoumP",
|
|
11
|
+
"ToggleSwitch-statusLabelText": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText____TqA4",
|
|
12
|
+
"ToggleSwitch-statusLabelText--hidden": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-statusLabelText--hidden___DuJ9i",
|
|
7
13
|
"ToggleSwitch-thumb": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb___riVjM",
|
|
8
14
|
"ToggleSwitch-thumb--checked": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--checked___y1Okd",
|
|
9
15
|
"ToggleSwitch-thumb--disabled": "Primer_Brand__ToggleSwitch-module__ToggleSwitch-thumb--disabled___V14xX",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleSwitch.module.js","names":[],"sources":["../../../src/forms/ToggleSwitch/ToggleSwitch.module.css"],"sourcesContent":[".ToggleSwitch {\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n gap: var(--brand-ToggleSwitch-loading-gap);\n vertical-align: middle;\n}\n\n.ToggleSwitch-button {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: var(--brand-ToggleSwitch-target-minHeight);\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n appearance: none;\n}\n\n.ToggleSwitch-button:focus-visible {\n outline: none;\n}\n\n.ToggleSwitch-button:focus-visible .ToggleSwitch-track {\n outline: var(--brand-ToggleSwitch-focus-width) solid var(--brand-color-focus);\n outline-offset: var(--brand-ToggleSwitch-focus-offset);\n}\n\n.ToggleSwitch-button--unavailable {\n cursor: not-allowed;\n}\n\n.ToggleSwitch-track {\n position: relative;\n display: block;\n box-sizing: border-box;\n border: var(--brand-ToggleSwitch-track-borderWidth) solid var(--brand-ToggleSwitch-track-borderColor);\n border-radius: var(--brand-ToggleSwitch-track-borderRadius);\n background: var(--brand-ToggleSwitch-track-bgColor);\n}\n\n.ToggleSwitch-thumb {\n position: absolute;\n top: 50%;\n box-sizing: border-box;\n border: var(--brand-ToggleSwitch-thumb-borderWidth) solid var(--brand-ToggleSwitch-thumb-borderColor);\n border-radius: var(--brand-ToggleSwitch-thumb-borderRadius);\n background: var(--brand-ToggleSwitch-thumb-off-bgColor-rest);\n transform: translateY(-50%);\n transition: inset-inline-start var(--brand-animation-duration-faster) var(--brand-animation-easing-default);\n}\n\n.ToggleSwitch-thumb--checked {\n background: var(--brand-ToggleSwitch-thumb-on-bgColor-rest);\n}\n\n.ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb {\n background: var(--brand-ToggleSwitch-thumb-off-bgColor-hover);\n}\n\n.ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb--checked {\n background: var(--brand-ToggleSwitch-thumb-on-bgColor-hover);\n}\n\n.ToggleSwitch-thumb--disabled {\n background: var(--brand-ToggleSwitch-thumb-disabled-bgColor);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-track {\n width: var(--brand-ToggleSwitch-track-width-medium);\n height: var(--brand-ToggleSwitch-track-height-medium);\n}\n\n.ToggleSwitch--small .ToggleSwitch-track {\n width: var(--brand-ToggleSwitch-track-width-small);\n height: var(--brand-ToggleSwitch-track-height-small);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-thumb {\n inset-inline-start: calc(var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth));\n width: var(--brand-ToggleSwitch-thumb-size-medium);\n height: var(--brand-ToggleSwitch-thumb-size-medium);\n}\n\n.ToggleSwitch--small .ToggleSwitch-thumb {\n inset-inline-start: calc(var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth));\n width: var(--brand-ToggleSwitch-thumb-size-small);\n height: var(--brand-ToggleSwitch-thumb-size-small);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-thumb--checked {\n inset-inline-start: calc(\n var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth) +\n var(--brand-ToggleSwitch-thumb-travel-medium)\n );\n}\n\n.ToggleSwitch--small .ToggleSwitch-thumb--checked {\n inset-inline-start: calc(\n var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth) +\n var(--brand-ToggleSwitch-thumb-travel-small)\n );\n}\n\n.ToggleSwitch-spinnerSlot {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--brand-ToggleSwitch-loading-size);\n width: var(--brand-ToggleSwitch-loading-size);\n height: var(--brand-ToggleSwitch-loading-size);\n pointer-events: none;\n}\n\n.ToggleSwitch-spinner {\n color: var(--brand-ToggleSwitch-loading-fgColor);\n animation-duration: var(--brand-ToggleSwitch-loading-duration);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ToggleSwitch-thumb {\n transition: none;\n }\n\n .ToggleSwitch-spinner {\n animation: none;\n }\n}\n\n@media (forced-colors: active) {\n .ToggleSwitch-track {\n border-color: ButtonText;\n background: Canvas;\n }\n\n .ToggleSwitch-thumb,\n .ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: ButtonText;\n }\n\n .ToggleSwitch-thumb--checked,\n .ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb--checked {\n background: Highlight;\n }\n\n .ToggleSwitch-thumb--disabled {\n background: GrayText;\n }\n\n .ToggleSwitch-button:focus-visible .ToggleSwitch-track {\n outline-color: Highlight;\n }\n\n .ToggleSwitch-spinner {\n color: CanvasText;\n }\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ToggleSwitch.module.js","names":[],"sources":["../../../src/forms/ToggleSwitch/ToggleSwitch.module.css"],"sourcesContent":[".ToggleSwitch {\n display: inline-flex;\n flex-shrink: 0;\n align-items: center;\n gap: var(--brand-ToggleSwitch-loading-gap);\n vertical-align: middle;\n}\n\n.ToggleSwitch-button {\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: var(--brand-ToggleSwitch-target-minHeight);\n gap: var(--base-size-8);\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n appearance: none;\n}\n\n.ToggleSwitch--withStatusLabel {\n min-inline-size: 0;\n max-inline-size: 100%;\n flex-shrink: 1;\n}\n\n.ToggleSwitch--withStatusLabel .ToggleSwitch-button {\n min-inline-size: 0;\n max-inline-size: 100%;\n}\n\n.ToggleSwitch-button:focus-visible {\n outline: none;\n}\n\n.ToggleSwitch-button:focus-visible .ToggleSwitch-track {\n outline: var(--brand-ToggleSwitch-focus-width) solid var(--brand-color-focus);\n outline-offset: var(--brand-ToggleSwitch-focus-offset);\n}\n\n.ToggleSwitch-button--unavailable {\n cursor: not-allowed;\n}\n\n.ToggleSwitch-track {\n position: relative;\n display: block;\n box-sizing: border-box;\n border: var(--brand-ToggleSwitch-track-borderWidth) solid var(--brand-ToggleSwitch-track-borderColor);\n border-radius: var(--brand-ToggleSwitch-track-borderRadius);\n background: var(--brand-ToggleSwitch-track-bgColor);\n flex: 0 0 auto;\n}\n\n.ToggleSwitch-statusLabel {\n display: grid;\n min-inline-size: 0;\n max-inline-size: 100%;\n overflow-wrap: anywhere;\n}\n\n.ToggleSwitch-statusLabel--start {\n justify-items: end;\n}\n\n.ToggleSwitch-statusLabel--end {\n justify-items: start;\n}\n\n.ToggleSwitch-statusLabel--start .ToggleSwitch-statusLabelText {\n text-align: end;\n}\n\n.ToggleSwitch-statusLabel--end .ToggleSwitch-statusLabelText {\n text-align: start;\n}\n\n.ToggleSwitch-statusLabelText {\n grid-area: 1 / 1;\n}\n\n.ToggleSwitch-statusLabelText--hidden {\n visibility: hidden;\n}\n\n.ToggleSwitch-thumb {\n position: absolute;\n top: 50%;\n box-sizing: border-box;\n border: var(--brand-ToggleSwitch-thumb-borderWidth) solid var(--brand-ToggleSwitch-thumb-borderColor);\n border-radius: var(--brand-ToggleSwitch-thumb-borderRadius);\n background: var(--brand-ToggleSwitch-thumb-off-bgColor-rest);\n transform: translateY(-50%);\n transition: inset-inline-start var(--brand-animation-duration-faster) var(--brand-animation-easing-default);\n}\n\n.ToggleSwitch-thumb--checked {\n background: var(--brand-ToggleSwitch-thumb-on-bgColor-rest);\n}\n\n.ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb {\n background: var(--brand-ToggleSwitch-thumb-off-bgColor-hover);\n}\n\n.ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb--checked {\n background: var(--brand-ToggleSwitch-thumb-on-bgColor-hover);\n}\n\n.ToggleSwitch-thumb--disabled {\n background: var(--brand-ToggleSwitch-thumb-disabled-bgColor);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-track {\n width: var(--brand-ToggleSwitch-track-width-medium);\n height: var(--brand-ToggleSwitch-track-height-medium);\n}\n\n.ToggleSwitch--small .ToggleSwitch-track {\n width: var(--brand-ToggleSwitch-track-width-small);\n height: var(--brand-ToggleSwitch-track-height-small);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-thumb {\n inset-inline-start: calc(var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth));\n width: var(--brand-ToggleSwitch-thumb-size-medium);\n height: var(--brand-ToggleSwitch-thumb-size-medium);\n}\n\n.ToggleSwitch--small .ToggleSwitch-thumb {\n inset-inline-start: calc(var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth));\n width: var(--brand-ToggleSwitch-thumb-size-small);\n height: var(--brand-ToggleSwitch-thumb-size-small);\n}\n\n.ToggleSwitch--medium .ToggleSwitch-thumb--checked {\n inset-inline-start: calc(\n var(--brand-ToggleSwitch-thumb-inset-medium) - var(--brand-ToggleSwitch-track-borderWidth) +\n var(--brand-ToggleSwitch-thumb-travel-medium)\n );\n}\n\n.ToggleSwitch--small .ToggleSwitch-thumb--checked {\n inset-inline-start: calc(\n var(--brand-ToggleSwitch-thumb-inset-small) - var(--brand-ToggleSwitch-track-borderWidth) +\n var(--brand-ToggleSwitch-thumb-travel-small)\n );\n}\n\n.ToggleSwitch-spinnerSlot {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 var(--brand-ToggleSwitch-loading-size);\n width: var(--brand-ToggleSwitch-loading-size);\n height: var(--brand-ToggleSwitch-loading-size);\n pointer-events: none;\n}\n\n.ToggleSwitch-spinner {\n color: var(--brand-ToggleSwitch-loading-fgColor);\n animation-duration: var(--brand-ToggleSwitch-loading-duration);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .ToggleSwitch-thumb {\n transition: none;\n }\n\n .ToggleSwitch-spinner {\n animation: none;\n }\n}\n\n@media (forced-colors: active) {\n .ToggleSwitch-track {\n border-color: ButtonText;\n background: Canvas;\n }\n\n .ToggleSwitch-thumb,\n .ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: ButtonText;\n }\n\n .ToggleSwitch-thumb--checked,\n .ToggleSwitch-button:not(.ToggleSwitch-button--unavailable):hover .ToggleSwitch-thumb--checked {\n background: Highlight;\n }\n\n .ToggleSwitch-thumb--disabled {\n background: GrayText;\n }\n\n .ToggleSwitch-button:focus-visible .ToggleSwitch-track {\n outline-color: Highlight;\n }\n\n .ToggleSwitch-spinner {\n color: CanvasText;\n }\n\n .ToggleSwitch-statusLabelText {\n color: ButtonText;\n }\n\n .ToggleSwitch-button--unavailable .ToggleSwitch-statusLabelText {\n color: GrayText;\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root,[data-color-mode=light],[data-color-mode=auto]{--brand-ToggleSwitch-track-bgColor:var(--base-color-scale-gray-0);--brand-ToggleSwitch-track-borderColor:var(--base-color-scale-gray-7);--brand-ToggleSwitch-thumb-borderColor:#00000014;--brand-ToggleSwitch-thumb-on-bgColor-rest:var(--brand-color-text-emphasized);--brand-ToggleSwitch-thumb-on-bgColor-hover:color-mix(in srgb, var(--brand-color-text-emphasized), black 16%);--brand-ToggleSwitch-thumb-off-bgColor-rest:var(--base-color-scale-gray-7);--brand-ToggleSwitch-thumb-off-bgColor-hover:var(--base-color-scale-gray-8);--brand-ToggleSwitch-thumb-disabled-bgColor:var(--base-color-scale-gray-4);--brand-ToggleSwitch-loading-fgColor:var(--brand-color-text-muted)}[data-color-mode=dark]{--brand-ToggleSwitch-track-bgColor:var(--base-color-scale-gray-7);--brand-ToggleSwitch-track-borderColor:var(--base-color-scale-gray-2);--brand-ToggleSwitch-thumb-borderColor:#00000014;--brand-ToggleSwitch-thumb-on-bgColor-rest:var(--base-color-scale-green-2);--brand-ToggleSwitch-thumb-on-bgColor-hover:var(--base-color-scale-green-1);--brand-ToggleSwitch-thumb-off-bgColor-rest:var(--base-color-scale-gray-2);--brand-ToggleSwitch-thumb-off-bgColor-hover:var(--base-color-scale-gray-1);--brand-ToggleSwitch-thumb-disabled-bgColor:var(--base-color-scale-gray-5);--brand-ToggleSwitch-loading-fgColor:var(--brand-color-text-muted)}@media (prefers-color-scheme:dark){[data-color-mode=auto]{--brand-ToggleSwitch-track-bgColor:var(--base-color-scale-gray-7);--brand-ToggleSwitch-track-borderColor:var(--base-color-scale-gray-2);--brand-ToggleSwitch-thumb-borderColor:#00000014;--brand-ToggleSwitch-thumb-on-bgColor-rest:var(--base-color-scale-green-2);--brand-ToggleSwitch-thumb-on-bgColor-hover:var(--base-color-scale-green-1);--brand-ToggleSwitch-thumb-off-bgColor-rest:var(--base-color-scale-gray-2);--brand-ToggleSwitch-thumb-off-bgColor-hover:var(--base-color-scale-gray-1);--brand-ToggleSwitch-thumb-disabled-bgColor:var(--base-color-scale-gray-5);--brand-ToggleSwitch-loading-fgColor:var(--brand-color-text-muted)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RiverBreakoutTabs.d.ts","sourceRoot":"","sources":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AAY,CAAA;AAExD,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;AAEhF,MAAM,MAAM,0BAA0B,GAAG,SAAS,CAAA;AAElD,MAAM,MAAM,4BAA4B,GAAG,oBAAoB,CAAA;AAud/D;;GAEG;AACH,eAAO,MAAM,iBAAiB;2BA5fL,MAAM;oBACb,MAAM;eACX,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI;IAC1C;;;OAGG;uBACgB,KAAK,CAAC,SAAS;IAClC;;OAEG;oBACa,QAAQ,GAAG,WAAW;IACtC;;OAEG;gCACyB,OAAO;;;;wCA0C4B,iCAAiC;iDA6B/B,6BAA6B;mEAZ7F,6BAA6B;gCAX4B,0BAA0B;yBAR3C,0BAA0B;;CA4cnE,CAAA"}
|
|
@@ -173,6 +173,7 @@ var w = (e) => (t) => p.isValidElement(t) && t.type === e, T = ({ children: e })
|
|
|
173
173
|
open: n === X,
|
|
174
174
|
handleOpen: ee(n),
|
|
175
175
|
children: [/* @__PURE__ */ S(f.Heading, {
|
|
176
|
+
as: t.heading?.props.as ?? "h3",
|
|
176
177
|
className: d.RiverBreakoutTabs__accordionHeading,
|
|
177
178
|
children: /* @__PURE__ */ C("span", {
|
|
178
179
|
className: d.RiverBreakoutTabs__accordionHeadingInner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RiverBreakoutTabs.js","names":[],"sources":["../../../src/river/RiverBreakoutTabs/RiverBreakoutTabs.tsx"],"sourcesContent":["import React, {cloneElement, forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {clsx} from 'clsx'\n\nimport {Accordion, Heading, Link, Text, type HeadingProps} from '../..'\nimport {Icon, type IconProps} from '../../Icon'\nimport {RiverVisualBase, type RiverVisualBaseProps} from '../River/River'\nimport {useId} from '../../hooks/useId'\nimport {useTabs} from '../../hooks/useTabs'\nimport {useWindowSize} from '../../hooks/useWindowSize'\nimport riverStyles from '../river-shared.module.css'\nimport gridlineStyles from '../../component-helpers/shared.module.css'\n\n/**\n * Design tokens\n */\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/river/base.css'\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/river/river.css'\n\n/** Main Stylesheet (as a CSS Module) */\nimport styles from './RiverBreakoutTabs.module.css'\n\nconst createComponentTypeGuard =\n <T,>(componentType: React.ComponentType<T>) =>\n (element: unknown): element is React.ReactElement<T> =>\n React.isValidElement<T>(element) && element.type === componentType\n\nexport type RiverBreakoutTabsProps = React.PropsWithChildren<{\n defaultSelectedIndex?: number\n selectedIndex?: number\n onChange?: (selectedIndex: number) => void\n /**\n * Decorative background rendered behind the visual and persisted across tab\n * changes. Must not contain interactive and remain purely decorative.\n */\n backgroundVisual?: React.ReactNode\n /**\n * Alignment of media within the visual container when `backgroundVisual` is provided\n */\n imagePosition?: 'center' | 'block-end'\n /**\n * When `true`, the `backgroundVisual` bleeds out to the gridline edges instead of being inset within them\n */\n backgroundVisualFullBleed?: boolean\n}> &\n Omit<React.HTMLAttributes<HTMLElement>, 'onChange'>\n\nexport type RiverBreakoutTabsItemProps = React.PropsWithChildren<{\n className?: string\n}>\n\nexport type RiverBreakoutTabsA11yHeadingProps = React.PropsWithChildren<{\n as?: 'h2' | 'h3'\n id?: string\n}>\n\nexport type RiverBreakoutTabsHeadingProps = HeadingProps\n\nexport type RiverBreakoutTabsContentProps = React.HTMLAttributes<HTMLDivElement>\n\nexport type RiverBreakoutTabsIconProps = IconProps\n\nexport type RiverBreakoutTabsVisualProps = RiverVisualBaseProps\n\ntype RiverBreakoutTabsItemChild =\n | React.ReactElement<RiverBreakoutTabsIconProps>\n | React.ReactElement<RiverBreakoutTabsHeadingProps>\n | React.ReactElement<RiverBreakoutTabsContentProps>\n | React.ReactElement<RiverBreakoutTabsVisualProps>\n\ntype ExtractedItemParts = {\n icon: React.ReactElement<RiverBreakoutTabsIconProps> | null\n heading: React.ReactElement<RiverBreakoutTabsHeadingProps> | null\n content: React.ReactElement<RiverBreakoutTabsContentProps> | null\n visual: React.ReactElement<RiverBreakoutTabsVisualProps> | null\n className?: string\n}\n\ntype ExtractedContentParts = {\n action: React.ReactElement<React.ComponentProps<typeof Link>> | null\n body: React.ReactNode[]\n}\n\nconst RiverBreakoutTabsItem = ({children}: RiverBreakoutTabsItemProps) => <>{children}</>\n\nconst RiverBreakoutTabsA11yHeading = ({as = 'h3', children, id}: RiverBreakoutTabsA11yHeadingProps) => (\n <Heading as={as} id={id} className=\"visually-hidden\">\n {children}\n </Heading>\n)\n\nconst RiverBreakoutTabsIcon = ({color = 'green', ...props}: RiverBreakoutTabsIconProps) => (\n <Icon color={color} {...props} />\n)\n\nconst RiverBreakoutTabsHeading = ({\n as = 'h3',\n children,\n className,\n size = 'subhead-large',\n weight = 'normal',\n ...props\n}: RiverBreakoutTabsHeadingProps) => (\n <Heading\n as={as}\n className={clsx(styles.RiverBreakoutTabs__heading, className)}\n size={size}\n weight={weight}\n {...props}\n >\n {children}\n </Heading>\n)\n\nconst RiverBreakoutTabsContent = ({children, className, ...props}: RiverBreakoutTabsContentProps) => {\n const Children = useMemo(\n () =>\n React.Children.toArray(children).map(child => {\n if (isTextChild(child)) {\n return cloneElement(child, {\n as: child.props.as ?? 'p',\n variant: child.props.variant ?? 'muted',\n })\n }\n\n if (isLinkChild(child)) {\n return cloneElement(child, {\n className: clsx(child.props.className, styles.RiverBreakoutTabs__link),\n size: child.props.size ?? 'medium',\n variant: child.props.variant ?? 'accent',\n })\n }\n\n return child\n }),\n [children],\n )\n\n return (\n <div className={clsx(styles.RiverBreakoutTabs__content, className)} {...props}>\n {Children}\n </div>\n )\n}\n\nconst RiverBreakoutTabsVisual = forwardRef<HTMLDivElement, RiverBreakoutTabsVisualProps>(\n ({className, rounded = true, ...props}, ref) => (\n <RiverVisualBase\n ref={ref}\n className={clsx(rounded && styles['RiverBreakoutTabs__visual--rounded'], className)}\n rounded={rounded}\n {...props}\n />\n ),\n)\n\nconst isItem = createComponentTypeGuard(RiverBreakoutTabsItem)\nconst isA11yHeading = createComponentTypeGuard(RiverBreakoutTabsA11yHeading)\nconst isIcon = createComponentTypeGuard(RiverBreakoutTabsIcon)\nconst isHeading = createComponentTypeGuard(RiverBreakoutTabsHeading)\nconst isContent = createComponentTypeGuard(RiverBreakoutTabsContent)\nconst isVisual = createComponentTypeGuard(RiverBreakoutTabsVisual)\n\nconst isTextChild = (child: React.ReactNode): child is React.ReactElement<React.ComponentProps<typeof Text>> =>\n React.isValidElement<React.ComponentProps<typeof Text>>(child) && child.type === Text\n\nconst isLinkChild = (child: React.ReactNode): child is React.ReactElement<React.ComponentProps<typeof Link>> =>\n React.isValidElement<React.ComponentProps<typeof Link>>(child) && child.type === Link\n\nconst extractItemParts = (item: React.ReactElement<RiverBreakoutTabsItemProps>): ExtractedItemParts => {\n const Children = React.Children.toArray(item.props.children) as RiverBreakoutTabsItemChild[]\n\n return Children.reduce<ExtractedItemParts>(\n (acc, child) => {\n if (isIcon(child)) {\n acc.icon = child\n }\n\n if (isHeading(child)) {\n acc.heading = child\n }\n\n if (isContent(child)) {\n acc.content = child\n }\n\n if (isVisual(child)) {\n acc.visual = child\n }\n\n return acc\n },\n {icon: null, heading: null, content: null, visual: null, className: item.props.className},\n )\n}\n\nconst extractWideTabListContentParts = (\n content: React.ReactElement<RiverBreakoutTabsContentProps> | null,\n): ExtractedContentParts => {\n if (!content) {\n return {action: null, body: []}\n }\n\n const Children = React.Children.toArray(content.props.children).map(child => {\n if (isTextChild(child)) {\n return cloneElement(child, {\n as: child.props.as ?? 'p',\n variant: child.props.variant ?? 'muted',\n })\n }\n\n if (isLinkChild(child)) {\n return cloneElement(child, {\n className: clsx(child.props.className, styles.RiverBreakoutTabs__link),\n size: child.props.size ?? 'medium',\n variant: child.props.variant ?? 'accent',\n })\n }\n\n return child\n })\n\n return Children.reduce<ExtractedContentParts>(\n (acc, child) => {\n if (isLinkChild(child)) {\n if (!acc.action) {\n acc.action = child\n }\n\n return acc\n }\n\n acc.body.push(child)\n return acc\n },\n {action: null, body: []},\n )\n}\n\nconst clampIndex = (index: number, length: number) => {\n if (length === 0) return -1\n\n const normalizedIndex = Number.isFinite(index) ? Math.trunc(index) : 0\n return Math.min(Math.max(normalizedIndex, 0), length - 1)\n}\n\nconst RiverBreakoutTabsRoot = forwardRef<HTMLElement, RiverBreakoutTabsProps>(\n (\n {\n children,\n className,\n defaultSelectedIndex = 0,\n onChange,\n selectedIndex,\n backgroundVisual,\n imagePosition = 'center',\n backgroundVisualFullBleed = false,\n ...props\n },\n ref,\n ) => {\n const instanceId = useId()\n const {isLarge} = useWindowSize()\n\n const Children = useMemo(() => React.Children.toArray(children), [children])\n\n const A11yHeadingChild = Children.find(isA11yHeading) ?? null\n const Items = Children.filter(isItem)\n .map(extractItemParts)\n .filter(item => item.heading && item.content && item.visual)\n\n const defaultActiveIndex = clampIndex(defaultSelectedIndex, Items.length)\n const controlledActiveIndex =\n typeof selectedIndex === 'number' && Number.isFinite(selectedIndex)\n ? clampIndex(selectedIndex, Items.length)\n : null\n const initialActiveIndex = controlledActiveIndex ?? defaultActiveIndex\n const headingId = A11yHeadingChild?.props.id ?? `${instanceId}-heading`\n const wideTabListColumns = Math.min(Math.max(Items.length, 1), 3)\n const initialActiveTab = initialActiveIndex >= 0 ? String(initialActiveIndex) : undefined\n const isWideTabList = isLarge === true\n const suppressOnTabActivateRef = useRef(false)\n\n const handleTabActivate = useCallback(\n (id: string) => {\n if (suppressOnTabActivateRef.current) {\n suppressOnTabActivateRef.current = false\n return\n }\n\n if (!onChange) return\n\n const nextIndex = Number(id)\n if (!Number.isNaN(nextIndex)) {\n onChange(nextIndex)\n }\n },\n [onChange],\n )\n\n const {activeTab, activateTab, getTabListProps, getTabPanelProps, getTabProps} = useTabs({\n defaultTab: initialActiveTab,\n onTabActivate: handleTabActivate,\n })\n\n const [activeAccordionIndex, setActiveAccordionIndex] = useState(initialActiveIndex)\n\n useEffect(() => {\n if (activeTab === null) return\n\n const nextIndex = Number(activeTab)\n if (!Number.isNaN(nextIndex)) {\n setActiveAccordionIndex(nextIndex)\n }\n }, [activeTab])\n\n useEffect(() => {\n if (controlledActiveIndex === null || controlledActiveIndex < 0) return\n\n const controlledTab = String(controlledActiveIndex)\n if (activeTab !== controlledTab) {\n suppressOnTabActivateRef.current = true\n activateTab(controlledTab)\n }\n\n setActiveAccordionIndex(controlledActiveIndex)\n }, [activateTab, activeTab, controlledActiveIndex])\n\n if (!A11yHeadingChild && (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test')) {\n // eslint-disable-next-line no-console\n console.warn(\n 'RiverBreakoutTabs: A11yHeading child is required. This element will not be visible, only read by screenreaders.',\n )\n }\n\n const handleAccordionOpen = (index: number) => (isOpen: boolean) => {\n if (isOpen) {\n setActiveAccordionIndex(index)\n if (activeTab !== String(index)) {\n activateTab(String(index))\n }\n }\n }\n\n const handleAccordionToggle: React.ReactEventHandler<HTMLDetailsElement> = event => {\n const toggledIndex = Number(event.currentTarget.getAttribute('data-index'))\n\n if (!event.currentTarget.open && activeAccordionIndex === toggledIndex) {\n event.currentTarget.open = true\n }\n }\n\n const tabListProps = A11yHeadingChild\n ? getTabListProps({labelledBy: headingId})\n : getTabListProps({label: 'River breakout tabs'})\n const WideTabListContentParts = useMemo(\n () => Items.map(item => extractWideTabListContentParts(item.content)),\n [Items],\n )\n\n const BackgroundVisualLayer =\n backgroundVisual != null ? (\n <div className={styles.RiverBreakoutTabs__backgroundVisual} aria-hidden=\"true\">\n {backgroundVisual}\n </div>\n ) : null\n\n return (\n <section\n ref={ref}\n className={clsx(\n riverStyles.RiverBreakout,\n riverStyles['RiverBreakout--variant-gridline'],\n gridlineStyles.gridline,\n styles.RiverBreakoutTabs,\n backgroundVisual != null && styles['RiverBreakoutTabs--has-background-visual'],\n backgroundVisual != null &&\n imagePosition === 'block-end' &&\n styles['RiverBreakoutTabs--image-position-block-end'],\n backgroundVisual != null &&\n backgroundVisualFullBleed &&\n styles['RiverBreakoutTabs--background-visual-full-bleed'],\n className,\n )}\n {...props}\n >\n {A11yHeadingChild && cloneElement(A11yHeadingChild, {id: headingId})}\n\n {isWideTabList ? (\n <div\n className={styles.RiverBreakoutTabs__wideTabList}\n style={{'--river-breakout-tabs-columns': String(wideTabListColumns)} as React.CSSProperties}\n >\n <div {...tabListProps} className={styles.RiverBreakoutTabs__tablist}>\n {Items.map((item, index) => {\n const isSelected = activeTab === String(index)\n const tabProps = getTabProps<HTMLButtonElement>(String(index))\n\n return (\n <div\n key={index}\n className={clsx(\n styles.RiverBreakoutTabs__item,\n isSelected && styles['RiverBreakoutTabs__item--selected'],\n item.className,\n )}\n >\n <button type=\"button\" {...tabProps} className={styles.RiverBreakoutTabs__tab}>\n {item.icon &&\n cloneElement(item.icon, {\n className: item.icon.props.className,\n })}\n\n {item.heading &&\n cloneElement(item.heading, {\n className: clsx(item.heading.props.className, styles.RiverBreakoutTabs__tabHeading),\n })}\n </button>\n </div>\n )\n })}\n </div>\n\n <div className={styles.RiverBreakoutTabs__sharedVisuals}>\n {BackgroundVisualLayer}\n {Items.map((item, index) => {\n const panelProps = getTabPanelProps(String(index))\n\n return (\n <div\n key={index}\n {...panelProps}\n tabIndex={-1}\n className={styles.RiverBreakoutTabs__sharedVisualPanel}\n >\n {cloneElement(item.visual as React.ReactElement<RiverBreakoutTabsVisualProps>, {\n className: clsx(item.visual?.props.className, styles.RiverBreakoutTabs__sharedVisual),\n })}\n </div>\n )\n })}\n </div>\n\n {WideTabListContentParts.some(({body}) => body.length > 0) && (\n <div className={styles.RiverBreakoutTabs__wideTabListContentRow}>\n {WideTabListContentParts.map(({body}, index) => (\n <div\n key={index}\n className={styles.RiverBreakoutTabs__wideTabListContent}\n role={body.length > 0 ? 'group' : undefined}\n aria-labelledby={body.length > 0 ? getTabProps(String(index)).id : undefined}\n >\n {body}\n </div>\n ))}\n </div>\n )}\n\n {WideTabListContentParts.some(content => content.action) && (\n <div className={styles.RiverBreakoutTabs__wideTabListActions}>\n {Items.map((_, index) => {\n const {action} = WideTabListContentParts[index]\n\n return (\n <div key={index} className={styles.RiverBreakoutTabs__wideTabListActionItem}>\n {action &&\n cloneElement(action, {\n className: clsx(action.props.className, styles.RiverBreakoutTabs__wideTabListAction),\n })}\n </div>\n )\n })}\n </div>\n )}\n </div>\n ) : (\n <div className={styles.RiverBreakoutTabs__accordion}>\n {activeAccordionIndex >= 0 && Items[activeAccordionIndex]?.visual && (\n <div className={styles.RiverBreakoutTabs__accordionSharedVisuals}>\n {BackgroundVisualLayer}\n {cloneElement(Items[activeAccordionIndex].visual as React.ReactElement<RiverBreakoutTabsVisualProps>, {\n // Remount the visual so new media autoplays when the active item changes.\n key: String(activeAccordionIndex),\n className: clsx(\n Items[activeAccordionIndex].visual.props.className,\n styles.RiverBreakoutTabs__accordionSharedVisual,\n ),\n })}\n </div>\n )}\n\n {Items.map((item, index) => {\n return (\n <Accordion\n key={index}\n data-index={index}\n className={clsx(\n styles.RiverBreakoutTabs__accordionItem,\n index === activeAccordionIndex && styles['RiverBreakoutTabs__item--selected'],\n item.className,\n )}\n onToggle={handleAccordionToggle}\n open={index === activeAccordionIndex}\n handleOpen={handleAccordionOpen(index)}\n >\n <Accordion.Heading className={styles.RiverBreakoutTabs__accordionHeading}>\n <span className={styles.RiverBreakoutTabs__accordionHeadingInner}>\n {item.icon &&\n cloneElement(item.icon, {\n className: clsx(item.icon.props.className, styles.RiverBreakoutTabs__accordionIcon),\n })}\n <span className={styles.RiverBreakoutTabs__accordionLabel}>{item.heading?.props.children}</span>\n </span>\n </Accordion.Heading>\n\n <Accordion.Content className={styles.RiverBreakoutTabs__accordionPanel}>\n {cloneElement(item.content as React.ReactElement<RiverBreakoutTabsContentProps>, {\n className: clsx(item.content?.props.className, styles.RiverBreakoutTabs__accordionContent),\n })}\n </Accordion.Content>\n </Accordion>\n )\n })}\n </div>\n )}\n </section>\n )\n },\n)\n\n/**\n * Use RiverBreakoutTabs to showcase multiple feature stories within a single immersive surface.\n */\nexport const RiverBreakoutTabs = Object.assign(RiverBreakoutTabsRoot, {\n A11yHeading: RiverBreakoutTabsA11yHeading,\n Content: RiverBreakoutTabsContent,\n Heading: RiverBreakoutTabsHeading,\n Icon: RiverBreakoutTabsIcon,\n Item: RiverBreakoutTabsItem,\n Visual: RiverBreakoutTabsVisual,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAM,KACC,OACJ,MACC,EAAM,eAAkB,CAAO,KAAK,EAAQ,SAAS,GA0DnD,KAAyB,EAAC,kBAA0C,kBAAA,GAAA,EAAG,YAAW,CAAA,GAElF,KAAgC,EAAC,QAAK,MAAM,aAAU,YAC1D,kBAAC,GAAD;CAAa;CAAQ;CAAI,WAAU;CAChC;AACM,CAAA,GAGL,KAAyB,EAAC,WAAQ,SAAS,GAAG,QAClD,kBAAC,GAAD;CAAa;CAAO,GAAI;AAAQ,CAAA,GAG5B,KAA4B,EAChC,QAAK,MACL,aACA,cACA,UAAO,iBACP,YAAS,UACT,GAAG,QAEH,kBAAC,GAAD;CACM;CACJ,WAAW,EAAK,EAAO,4BAA4B,CAAS;CACtD;CACE;CACR,GAAI;CAEH;AACM,CAAA,GAGL,KAA4B,EAAC,aAAU,cAAW,GAAG,QAA0C;CACnG,IAAM,IAAW,QAEb,EAAM,SAAS,QAAQ,CAAQ,CAAC,CAAC,KAAI,MAC/B,EAAY,CAAK,IACZ,EAAa,GAAO;EACzB,IAAI,EAAM,MAAM,MAAM;EACtB,SAAS,EAAM,MAAM,WAAW;CAClC,CAAC,IAGC,EAAY,CAAK,IACZ,EAAa,GAAO;EACzB,WAAW,EAAK,EAAM,MAAM,WAAW,EAAO,uBAAuB;EACrE,MAAM,EAAM,MAAM,QAAQ;EAC1B,SAAS,EAAM,MAAM,WAAW;CAClC,CAAC,IAGI,CACR,GACH,CAAC,CAAQ,CACX;CAEA,OACE,kBAAC,OAAD;EAAK,WAAW,EAAK,EAAO,4BAA4B,CAAS;EAAG,GAAI;YACrE;CACE,CAAA;AAET,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,EAC/E,WAAW,EAAK,EAAK,SAAS,MAAM,WAAW,EAAO,mCAAmC,EAC3F,CAAC;IACgB,CAAA,CACV;MA1BJ,CA0BI,CAEd,CACE;IAEA;;AAEb,CACF,GAKa,IAAoB,OAAO,OAAO,GAAuB;CACpE,aAAa;CACb,SAAS;CACT,SAAS;CACT,MAAM;CACN,MAAM;CACN,QAAQ;AACV,CAAC"}
|
|
1
|
+
{"version":3,"file":"RiverBreakoutTabs.js","names":[],"sources":["../../../src/river/RiverBreakoutTabs/RiverBreakoutTabs.tsx"],"sourcesContent":["import React, {cloneElement, forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'\nimport {clsx} from 'clsx'\n\nimport {Accordion, Heading, Link, Text, type HeadingProps} from '../..'\nimport {Icon, type IconProps} from '../../Icon'\nimport {RiverVisualBase, type RiverVisualBaseProps} from '../River/River'\nimport {useId} from '../../hooks/useId'\nimport {useTabs} from '../../hooks/useTabs'\nimport {useWindowSize} from '../../hooks/useWindowSize'\nimport riverStyles from '../river-shared.module.css'\nimport gridlineStyles from '../../component-helpers/shared.module.css'\n\n/**\n * Design tokens\n */\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/river/base.css'\nimport '@primer/brand-primitives/lib/design-tokens/css/tokens/functional/components/river/river.css'\n\n/** Main Stylesheet (as a CSS Module) */\nimport styles from './RiverBreakoutTabs.module.css'\n\nconst createComponentTypeGuard =\n <T,>(componentType: React.ComponentType<T>) =>\n (element: unknown): element is React.ReactElement<T> =>\n React.isValidElement<T>(element) && element.type === componentType\n\nexport type RiverBreakoutTabsProps = React.PropsWithChildren<{\n defaultSelectedIndex?: number\n selectedIndex?: number\n onChange?: (selectedIndex: number) => void\n /**\n * Decorative background rendered behind the visual and persisted across tab\n * changes. Must not contain interactive and remain purely decorative.\n */\n backgroundVisual?: React.ReactNode\n /**\n * Alignment of media within the visual container when `backgroundVisual` is provided\n */\n imagePosition?: 'center' | 'block-end'\n /**\n * When `true`, the `backgroundVisual` bleeds out to the gridline edges instead of being inset within them\n */\n backgroundVisualFullBleed?: boolean\n}> &\n Omit<React.HTMLAttributes<HTMLElement>, 'onChange'>\n\nexport type RiverBreakoutTabsItemProps = React.PropsWithChildren<{\n className?: string\n}>\n\nexport type RiverBreakoutTabsA11yHeadingProps = React.PropsWithChildren<{\n as?: 'h2' | 'h3'\n id?: string\n}>\n\nexport type RiverBreakoutTabsHeadingProps = HeadingProps\n\nexport type RiverBreakoutTabsContentProps = React.HTMLAttributes<HTMLDivElement>\n\nexport type RiverBreakoutTabsIconProps = IconProps\n\nexport type RiverBreakoutTabsVisualProps = RiverVisualBaseProps\n\ntype RiverBreakoutTabsItemChild =\n | React.ReactElement<RiverBreakoutTabsIconProps>\n | React.ReactElement<RiverBreakoutTabsHeadingProps>\n | React.ReactElement<RiverBreakoutTabsContentProps>\n | React.ReactElement<RiverBreakoutTabsVisualProps>\n\ntype ExtractedItemParts = {\n icon: React.ReactElement<RiverBreakoutTabsIconProps> | null\n heading: React.ReactElement<RiverBreakoutTabsHeadingProps> | null\n content: React.ReactElement<RiverBreakoutTabsContentProps> | null\n visual: React.ReactElement<RiverBreakoutTabsVisualProps> | null\n className?: string\n}\n\ntype ExtractedContentParts = {\n action: React.ReactElement<React.ComponentProps<typeof Link>> | null\n body: React.ReactNode[]\n}\n\nconst RiverBreakoutTabsItem = ({children}: RiverBreakoutTabsItemProps) => <>{children}</>\n\nconst RiverBreakoutTabsA11yHeading = ({as = 'h3', children, id}: RiverBreakoutTabsA11yHeadingProps) => (\n <Heading as={as} id={id} className=\"visually-hidden\">\n {children}\n </Heading>\n)\n\nconst RiverBreakoutTabsIcon = ({color = 'green', ...props}: RiverBreakoutTabsIconProps) => (\n <Icon color={color} {...props} />\n)\n\nconst RiverBreakoutTabsHeading = ({\n as = 'h3',\n children,\n className,\n size = 'subhead-large',\n weight = 'normal',\n ...props\n}: RiverBreakoutTabsHeadingProps) => (\n <Heading\n as={as}\n className={clsx(styles.RiverBreakoutTabs__heading, className)}\n size={size}\n weight={weight}\n {...props}\n >\n {children}\n </Heading>\n)\n\nconst RiverBreakoutTabsContent = ({children, className, ...props}: RiverBreakoutTabsContentProps) => {\n const Children = useMemo(\n () =>\n React.Children.toArray(children).map(child => {\n if (isTextChild(child)) {\n return cloneElement(child, {\n as: child.props.as ?? 'p',\n variant: child.props.variant ?? 'muted',\n })\n }\n\n if (isLinkChild(child)) {\n return cloneElement(child, {\n className: clsx(child.props.className, styles.RiverBreakoutTabs__link),\n size: child.props.size ?? 'medium',\n variant: child.props.variant ?? 'accent',\n })\n }\n\n return child\n }),\n [children],\n )\n\n return (\n <div className={clsx(styles.RiverBreakoutTabs__content, className)} {...props}>\n {Children}\n </div>\n )\n}\n\nconst RiverBreakoutTabsVisual = forwardRef<HTMLDivElement, RiverBreakoutTabsVisualProps>(\n ({className, rounded = true, ...props}, ref) => (\n <RiverVisualBase\n ref={ref}\n className={clsx(rounded && styles['RiverBreakoutTabs__visual--rounded'], className)}\n rounded={rounded}\n {...props}\n />\n ),\n)\n\nconst isItem = createComponentTypeGuard(RiverBreakoutTabsItem)\nconst isA11yHeading = createComponentTypeGuard(RiverBreakoutTabsA11yHeading)\nconst isIcon = createComponentTypeGuard(RiverBreakoutTabsIcon)\nconst isHeading = createComponentTypeGuard(RiverBreakoutTabsHeading)\nconst isContent = createComponentTypeGuard(RiverBreakoutTabsContent)\nconst isVisual = createComponentTypeGuard(RiverBreakoutTabsVisual)\n\nconst isTextChild = (child: React.ReactNode): child is React.ReactElement<React.ComponentProps<typeof Text>> =>\n React.isValidElement<React.ComponentProps<typeof Text>>(child) && child.type === Text\n\nconst isLinkChild = (child: React.ReactNode): child is React.ReactElement<React.ComponentProps<typeof Link>> =>\n React.isValidElement<React.ComponentProps<typeof Link>>(child) && child.type === Link\n\nconst extractItemParts = (item: React.ReactElement<RiverBreakoutTabsItemProps>): ExtractedItemParts => {\n const Children = React.Children.toArray(item.props.children) as RiverBreakoutTabsItemChild[]\n\n return Children.reduce<ExtractedItemParts>(\n (acc, child) => {\n if (isIcon(child)) {\n acc.icon = child\n }\n\n if (isHeading(child)) {\n acc.heading = child\n }\n\n if (isContent(child)) {\n acc.content = child\n }\n\n if (isVisual(child)) {\n acc.visual = child\n }\n\n return acc\n },\n {icon: null, heading: null, content: null, visual: null, className: item.props.className},\n )\n}\n\nconst extractWideTabListContentParts = (\n content: React.ReactElement<RiverBreakoutTabsContentProps> | null,\n): ExtractedContentParts => {\n if (!content) {\n return {action: null, body: []}\n }\n\n const Children = React.Children.toArray(content.props.children).map(child => {\n if (isTextChild(child)) {\n return cloneElement(child, {\n as: child.props.as ?? 'p',\n variant: child.props.variant ?? 'muted',\n })\n }\n\n if (isLinkChild(child)) {\n return cloneElement(child, {\n className: clsx(child.props.className, styles.RiverBreakoutTabs__link),\n size: child.props.size ?? 'medium',\n variant: child.props.variant ?? 'accent',\n })\n }\n\n return child\n })\n\n return Children.reduce<ExtractedContentParts>(\n (acc, child) => {\n if (isLinkChild(child)) {\n if (!acc.action) {\n acc.action = child\n }\n\n return acc\n }\n\n acc.body.push(child)\n return acc\n },\n {action: null, body: []},\n )\n}\n\nconst clampIndex = (index: number, length: number) => {\n if (length === 0) return -1\n\n const normalizedIndex = Number.isFinite(index) ? Math.trunc(index) : 0\n return Math.min(Math.max(normalizedIndex, 0), length - 1)\n}\n\nconst RiverBreakoutTabsRoot = forwardRef<HTMLElement, RiverBreakoutTabsProps>(\n (\n {\n children,\n className,\n defaultSelectedIndex = 0,\n onChange,\n selectedIndex,\n backgroundVisual,\n imagePosition = 'center',\n backgroundVisualFullBleed = false,\n ...props\n },\n ref,\n ) => {\n const instanceId = useId()\n const {isLarge} = useWindowSize()\n\n const Children = useMemo(() => React.Children.toArray(children), [children])\n\n const A11yHeadingChild = Children.find(isA11yHeading) ?? null\n const Items = Children.filter(isItem)\n .map(extractItemParts)\n .filter(item => item.heading && item.content && item.visual)\n\n const defaultActiveIndex = clampIndex(defaultSelectedIndex, Items.length)\n const controlledActiveIndex =\n typeof selectedIndex === 'number' && Number.isFinite(selectedIndex)\n ? clampIndex(selectedIndex, Items.length)\n : null\n const initialActiveIndex = controlledActiveIndex ?? defaultActiveIndex\n const headingId = A11yHeadingChild?.props.id ?? `${instanceId}-heading`\n const wideTabListColumns = Math.min(Math.max(Items.length, 1), 3)\n const initialActiveTab = initialActiveIndex >= 0 ? String(initialActiveIndex) : undefined\n const isWideTabList = isLarge === true\n const suppressOnTabActivateRef = useRef(false)\n\n const handleTabActivate = useCallback(\n (id: string) => {\n if (suppressOnTabActivateRef.current) {\n suppressOnTabActivateRef.current = false\n return\n }\n\n if (!onChange) return\n\n const nextIndex = Number(id)\n if (!Number.isNaN(nextIndex)) {\n onChange(nextIndex)\n }\n },\n [onChange],\n )\n\n const {activeTab, activateTab, getTabListProps, getTabPanelProps, getTabProps} = useTabs({\n defaultTab: initialActiveTab,\n onTabActivate: handleTabActivate,\n })\n\n const [activeAccordionIndex, setActiveAccordionIndex] = useState(initialActiveIndex)\n\n useEffect(() => {\n if (activeTab === null) return\n\n const nextIndex = Number(activeTab)\n if (!Number.isNaN(nextIndex)) {\n setActiveAccordionIndex(nextIndex)\n }\n }, [activeTab])\n\n useEffect(() => {\n if (controlledActiveIndex === null || controlledActiveIndex < 0) return\n\n const controlledTab = String(controlledActiveIndex)\n if (activeTab !== controlledTab) {\n suppressOnTabActivateRef.current = true\n activateTab(controlledTab)\n }\n\n setActiveAccordionIndex(controlledActiveIndex)\n }, [activateTab, activeTab, controlledActiveIndex])\n\n if (!A11yHeadingChild && (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test')) {\n // eslint-disable-next-line no-console\n console.warn(\n 'RiverBreakoutTabs: A11yHeading child is required. This element will not be visible, only read by screenreaders.',\n )\n }\n\n const handleAccordionOpen = (index: number) => (isOpen: boolean) => {\n if (isOpen) {\n setActiveAccordionIndex(index)\n if (activeTab !== String(index)) {\n activateTab(String(index))\n }\n }\n }\n\n const handleAccordionToggle: React.ReactEventHandler<HTMLDetailsElement> = event => {\n const toggledIndex = Number(event.currentTarget.getAttribute('data-index'))\n\n if (!event.currentTarget.open && activeAccordionIndex === toggledIndex) {\n event.currentTarget.open = true\n }\n }\n\n const tabListProps = A11yHeadingChild\n ? getTabListProps({labelledBy: headingId})\n : getTabListProps({label: 'River breakout tabs'})\n const WideTabListContentParts = useMemo(\n () => Items.map(item => extractWideTabListContentParts(item.content)),\n [Items],\n )\n\n const BackgroundVisualLayer =\n backgroundVisual != null ? (\n <div className={styles.RiverBreakoutTabs__backgroundVisual} aria-hidden=\"true\">\n {backgroundVisual}\n </div>\n ) : null\n\n return (\n <section\n ref={ref}\n className={clsx(\n riverStyles.RiverBreakout,\n riverStyles['RiverBreakout--variant-gridline'],\n gridlineStyles.gridline,\n styles.RiverBreakoutTabs,\n backgroundVisual != null && styles['RiverBreakoutTabs--has-background-visual'],\n backgroundVisual != null &&\n imagePosition === 'block-end' &&\n styles['RiverBreakoutTabs--image-position-block-end'],\n backgroundVisual != null &&\n backgroundVisualFullBleed &&\n styles['RiverBreakoutTabs--background-visual-full-bleed'],\n className,\n )}\n {...props}\n >\n {A11yHeadingChild && cloneElement(A11yHeadingChild, {id: headingId})}\n\n {isWideTabList ? (\n <div\n className={styles.RiverBreakoutTabs__wideTabList}\n style={{'--river-breakout-tabs-columns': String(wideTabListColumns)} as React.CSSProperties}\n >\n <div {...tabListProps} className={styles.RiverBreakoutTabs__tablist}>\n {Items.map((item, index) => {\n const isSelected = activeTab === String(index)\n const tabProps = getTabProps<HTMLButtonElement>(String(index))\n\n return (\n <div\n key={index}\n className={clsx(\n styles.RiverBreakoutTabs__item,\n isSelected && styles['RiverBreakoutTabs__item--selected'],\n item.className,\n )}\n >\n <button type=\"button\" {...tabProps} className={styles.RiverBreakoutTabs__tab}>\n {item.icon &&\n cloneElement(item.icon, {\n className: item.icon.props.className,\n })}\n\n {item.heading &&\n cloneElement(item.heading, {\n className: clsx(item.heading.props.className, styles.RiverBreakoutTabs__tabHeading),\n })}\n </button>\n </div>\n )\n })}\n </div>\n\n <div className={styles.RiverBreakoutTabs__sharedVisuals}>\n {BackgroundVisualLayer}\n {Items.map((item, index) => {\n const panelProps = getTabPanelProps(String(index))\n\n return (\n <div\n key={index}\n {...panelProps}\n tabIndex={-1}\n className={styles.RiverBreakoutTabs__sharedVisualPanel}\n >\n {cloneElement(item.visual as React.ReactElement<RiverBreakoutTabsVisualProps>, {\n className: clsx(item.visual?.props.className, styles.RiverBreakoutTabs__sharedVisual),\n })}\n </div>\n )\n })}\n </div>\n\n {WideTabListContentParts.some(({body}) => body.length > 0) && (\n <div className={styles.RiverBreakoutTabs__wideTabListContentRow}>\n {WideTabListContentParts.map(({body}, index) => (\n <div\n key={index}\n className={styles.RiverBreakoutTabs__wideTabListContent}\n role={body.length > 0 ? 'group' : undefined}\n aria-labelledby={body.length > 0 ? getTabProps(String(index)).id : undefined}\n >\n {body}\n </div>\n ))}\n </div>\n )}\n\n {WideTabListContentParts.some(content => content.action) && (\n <div className={styles.RiverBreakoutTabs__wideTabListActions}>\n {Items.map((_, index) => {\n const {action} = WideTabListContentParts[index]\n\n return (\n <div key={index} className={styles.RiverBreakoutTabs__wideTabListActionItem}>\n {action &&\n cloneElement(action, {\n className: clsx(action.props.className, styles.RiverBreakoutTabs__wideTabListAction),\n })}\n </div>\n )\n })}\n </div>\n )}\n </div>\n ) : (\n <div className={styles.RiverBreakoutTabs__accordion}>\n {activeAccordionIndex >= 0 && Items[activeAccordionIndex]?.visual && (\n <div className={styles.RiverBreakoutTabs__accordionSharedVisuals}>\n {BackgroundVisualLayer}\n {cloneElement(Items[activeAccordionIndex].visual as React.ReactElement<RiverBreakoutTabsVisualProps>, {\n // Remount the visual so new media autoplays when the active item changes.\n key: String(activeAccordionIndex),\n className: clsx(\n Items[activeAccordionIndex].visual.props.className,\n styles.RiverBreakoutTabs__accordionSharedVisual,\n ),\n })}\n </div>\n )}\n\n {Items.map((item, index) => {\n return (\n <Accordion\n key={index}\n data-index={index}\n className={clsx(\n styles.RiverBreakoutTabs__accordionItem,\n index === activeAccordionIndex && styles['RiverBreakoutTabs__item--selected'],\n item.className,\n )}\n onToggle={handleAccordionToggle}\n open={index === activeAccordionIndex}\n handleOpen={handleAccordionOpen(index)}\n >\n <Accordion.Heading\n as={item.heading?.props.as ?? 'h3'}\n className={styles.RiverBreakoutTabs__accordionHeading}\n >\n <span className={styles.RiverBreakoutTabs__accordionHeadingInner}>\n {item.icon &&\n cloneElement(item.icon, {\n className: clsx(item.icon.props.className, styles.RiverBreakoutTabs__accordionIcon),\n })}\n <span className={styles.RiverBreakoutTabs__accordionLabel}>{item.heading?.props.children}</span>\n </span>\n </Accordion.Heading>\n\n <Accordion.Content className={styles.RiverBreakoutTabs__accordionPanel}>\n {cloneElement(item.content as React.ReactElement<RiverBreakoutTabsContentProps>, {\n className: clsx(item.content?.props.className, styles.RiverBreakoutTabs__accordionContent),\n })}\n </Accordion.Content>\n </Accordion>\n )\n })}\n </div>\n )}\n </section>\n )\n },\n)\n\n/**\n * Use RiverBreakoutTabs to showcase multiple feature stories within a single immersive surface.\n */\nexport const RiverBreakoutTabs = Object.assign(RiverBreakoutTabsRoot, {\n A11yHeading: RiverBreakoutTabsA11yHeading,\n Content: RiverBreakoutTabsContent,\n Heading: RiverBreakoutTabsHeading,\n Icon: RiverBreakoutTabsIcon,\n Item: RiverBreakoutTabsItem,\n Visual: RiverBreakoutTabsVisual,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAM,KACC,OACJ,MACC,EAAM,eAAkB,CAAO,KAAK,EAAQ,SAAS,GA0DnD,KAAyB,EAAC,kBAA0C,kBAAA,GAAA,EAAG,YAAW,CAAA,GAElF,KAAgC,EAAC,QAAK,MAAM,aAAU,YAC1D,kBAAC,GAAD;CAAa;CAAQ;CAAI,WAAU;CAChC;AACM,CAAA,GAGL,KAAyB,EAAC,WAAQ,SAAS,GAAG,QAClD,kBAAC,GAAD;CAAa;CAAO,GAAI;AAAQ,CAAA,GAG5B,KAA4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