@pnx-mixtape/mxds 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -0
- package/dist/build/Accordion.js +61 -0
- package/dist/build/Accordion.js.map +1 -0
- package/dist/build/AccordionDiv.js +62 -0
- package/dist/build/AccordionDiv.js.map +1 -0
- package/dist/build/AccordionGroup.js +85 -0
- package/dist/build/AccordionGroup.js.map +1 -0
- package/dist/build/AccordionMobile.js +31 -0
- package/dist/build/AccordionMobile.js.map +1 -0
- package/dist/build/Dialog.js +116 -0
- package/dist/build/Dialog.js.map +1 -0
- package/dist/build/DropMenu.js +132 -0
- package/dist/build/DropMenu.js.map +1 -0
- package/dist/build/GlobalToggle.js +103 -0
- package/dist/build/GlobalToggle.js.map +1 -0
- package/dist/build/InPageAlert.js +61 -0
- package/dist/build/InPageAlert.js.map +1 -0
- package/dist/build/InPageNavigation.js +92 -0
- package/dist/build/InPageNavigation.js.map +1 -0
- package/dist/build/Navigation.js +126 -0
- package/dist/build/Navigation.js.map +1 -0
- package/dist/build/Sticky.js +63 -0
- package/dist/build/Sticky.js.map +1 -0
- package/dist/build/Tabs.js +164 -0
- package/dist/build/Tabs.js.map +1 -0
- package/dist/build/accordion.css +108 -0
- package/dist/build/base.css +1000 -0
- package/dist/build/breadcrumb.css +47 -0
- package/dist/build/breakpoint-loader.js +52 -0
- package/dist/build/breakpoint-loader.js.map +1 -0
- package/dist/build/button.css +126 -0
- package/dist/build/callout.css +11 -0
- package/dist/build/card.css +135 -0
- package/dist/build/chunks/js.cookie-CiMiGxWx.js +101 -0
- package/dist/build/chunks/js.cookie-CiMiGxWx.js.map +1 -0
- package/dist/build/chunks/polyfills-CJ5uTmUJ.js +749 -0
- package/dist/build/chunks/polyfills-CJ5uTmUJ.js.map +1 -0
- package/dist/build/chunks/popover-wbPSyFRj.js +654 -0
- package/dist/build/chunks/popover-wbPSyFRj.js.map +1 -0
- package/dist/build/chunks/utilities-BIk0P2KX.js +61 -0
- package/dist/build/chunks/utilities-BIk0P2KX.js.map +1 -0
- package/dist/build/constants.css +120 -0
- package/dist/build/container-grid.css +207 -0
- package/dist/build/content-block.css +23 -0
- package/dist/build/cookie-compliance.js +122 -0
- package/dist/build/cookie-compliance.js.map +1 -0
- package/dist/build/dialog.css +98 -0
- package/dist/build/disclosure-widget.js +124 -0
- package/dist/build/disclosure-widget.js.map +1 -0
- package/dist/build/drop-menu.css +78 -0
- package/dist/build/drupal.css +74 -0
- package/dist/build/footer-menu.css +32 -0
- package/dist/build/footer.css +61 -0
- package/dist/build/form.css +589 -0
- package/dist/build/grid.css +200 -0
- package/dist/build/header.css +131 -0
- package/dist/build/hero-banner.css +62 -0
- package/dist/build/icon.css +399 -0
- package/dist/build/in-page-alert.css +94 -0
- package/dist/build/in-page-navigation.css +17 -0
- package/dist/build/index.css +4980 -0
- package/dist/build/io-loader.js +44 -0
- package/dist/build/io-loader.js.map +1 -0
- package/dist/build/keyboard.js +101 -0
- package/dist/build/keyboard.js.map +1 -0
- package/dist/build/link-list.css +72 -0
- package/dist/build/masthead.css +39 -0
- package/dist/build/nav-list.css +29 -0
- package/dist/build/navigation.css +371 -0
- package/dist/build/page.css +184 -0
- package/dist/build/pagination.css +123 -0
- package/dist/build/section.css +160 -0
- package/dist/build/sidebar.css +105 -0
- package/dist/build/sticky.css +47 -0
- package/dist/build/tabs.css +106 -0
- package/dist/build/tag.css +67 -0
- package/dist/build/tiles.css +61 -0
- package/dist/build/utilities.css +175 -0
- package/package.json +130 -0
- package/src/Atom/Background/Backgrounds.stories.ts +36 -0
- package/src/Atom/Background/__snapshots__/Backgrounds.stories.ts.snap +100 -0
- package/src/Atom/Background/_background.css +80 -0
- package/src/Atom/Background/backgrounds.twig +10 -0
- package/src/Atom/Base.mdx +76 -0
- package/src/Atom/Blockquote/_blockquote.css +7 -0
- package/src/Atom/Button/Button.stories.ts +71 -0
- package/src/Atom/Button/Button.stories.tsx +31 -0
- package/src/Atom/Button/Button.tsx +70 -0
- package/src/Atom/Button/README.md +30 -0
- package/src/Atom/Button/__snapshots__/Button.stories.ts.snap +41 -0
- package/src/Atom/Button/__snapshots__/Button.stories.tsx.snap +17 -0
- package/src/Atom/Button/_buttons-styles.css +48 -0
- package/src/Atom/Button/_buttons.css +71 -0
- package/src/Atom/Button/button.css +2 -0
- package/src/Atom/Button/button.twig +23 -0
- package/src/Atom/DefinitionList/DefinitionList.stories.tsx +25 -0
- package/src/Atom/DefinitionList/DefinitionList.tsx +27 -0
- package/src/Atom/DefinitionList/__snapshots__/DefinitionList.stories.tsx.snap +30 -0
- package/src/Atom/Heading/Heading.stories.ts +25 -0
- package/src/Atom/Heading/Heading.stories.tsx +19 -0
- package/src/Atom/Heading/Heading.tsx +44 -0
- package/src/Atom/Heading/__snapshots__/Heading.stories.ts.snap +7 -0
- package/src/Atom/Heading/__snapshots__/Heading.stories.tsx.snap +9 -0
- package/src/Atom/Heading/_headings.css +84 -0
- package/src/Atom/Heading/heading.twig +8 -0
- package/src/Atom/Icon/Icon.mdx +32 -0
- package/src/Atom/Icon/Icon.stories.ts +50 -0
- package/src/Atom/Icon/Icon.stories.tsx +44 -0
- package/src/Atom/Icon/Icon.tsx +30 -0
- package/src/Atom/Icon/README.md +7 -0
- package/src/Atom/Icon/__snapshots__/Icon.stories.ts.snap +18 -0
- package/src/Atom/Icon/__snapshots__/Icon.stories.tsx.snap +18 -0
- package/src/Atom/Icon/_extended-set.css +45 -0
- package/src/Atom/Icon/_icon.css +151 -0
- package/src/Atom/Icon/_mixin-icon.css +5 -0
- package/src/Atom/Icon/icon.css +2 -0
- package/src/Atom/Icon/icon.twig +12 -0
- package/src/Atom/Icon/images/arrow-down.svg +1 -0
- package/src/Atom/Icon/images/arrow-left.svg +1 -0
- package/src/Atom/Icon/images/arrow-right.svg +1 -0
- package/src/Atom/Icon/images/arrow-up.svg +1 -0
- package/src/Atom/Icon/images/attachment.svg +1 -0
- package/src/Atom/Icon/images/blockquote.svg +1 -0
- package/src/Atom/Icon/images/bluesky.svg +1 -0
- package/src/Atom/Icon/images/bookmark.svg +1 -0
- package/src/Atom/Icon/images/building.svg +1 -0
- package/src/Atom/Icon/images/calendar.svg +1 -0
- package/src/Atom/Icon/images/chevron-down.svg +1 -0
- package/src/Atom/Icon/images/chevron-left.svg +1 -0
- package/src/Atom/Icon/images/chevron-right.svg +1 -0
- package/src/Atom/Icon/images/chevron-up.svg +1 -0
- package/src/Atom/Icon/images/clock.svg +1 -0
- package/src/Atom/Icon/images/close.svg +1 -0
- package/src/Atom/Icon/images/collapse.svg +1 -0
- package/src/Atom/Icon/images/controls.svg +1 -0
- package/src/Atom/Icon/images/download.svg +1 -0
- package/src/Atom/Icon/images/drupal.svg +3 -0
- package/src/Atom/Icon/images/email.svg +1 -0
- package/src/Atom/Icon/images/error.svg +1 -0
- package/src/Atom/Icon/images/expand.svg +1 -0
- package/src/Atom/Icon/images/external-link.svg +1 -0
- package/src/Atom/Icon/images/facebook.svg +1 -0
- package/src/Atom/Icon/images/file.svg +1 -0
- package/src/Atom/Icon/images/globe.svg +1 -0
- package/src/Atom/Icon/images/google.svg +1 -0
- package/src/Atom/Icon/images/heart-selected.svg +1 -0
- package/src/Atom/Icon/images/heart-unselected.svg +1 -0
- package/src/Atom/Icon/images/home.svg +1 -0
- package/src/Atom/Icon/images/image.svg +1 -0
- package/src/Atom/Icon/images/info.svg +1 -0
- package/src/Atom/Icon/images/instagram.svg +1 -0
- package/src/Atom/Icon/images/link.svg +1 -0
- package/src/Atom/Icon/images/linkedin.svg +1 -0
- package/src/Atom/Icon/images/list.svg +1 -0
- package/src/Atom/Icon/images/lock.svg +1 -0
- package/src/Atom/Icon/images/login.svg +1 -0
- package/src/Atom/Icon/images/mastodon.svg +3 -0
- package/src/Atom/Icon/images/media-next.svg +1 -0
- package/src/Atom/Icon/images/media-pause.svg +1 -0
- package/src/Atom/Icon/images/media-play.svg +1 -0
- package/src/Atom/Icon/images/media-previous.svg +1 -0
- package/src/Atom/Icon/images/media-rewind.svg +1 -0
- package/src/Atom/Icon/images/media-skip.svg +1 -0
- package/src/Atom/Icon/images/media-stop.svg +1 -0
- package/src/Atom/Icon/images/menu.svg +1 -0
- package/src/Atom/Icon/images/more.svg +1 -0
- package/src/Atom/Icon/images/notification.svg +1 -0
- package/src/Atom/Icon/images/pencil.svg +1 -0
- package/src/Atom/Icon/images/phone.svg +1 -0
- package/src/Atom/Icon/images/pin.svg +1 -0
- package/src/Atom/Icon/images/print.svg +1 -0
- package/src/Atom/Icon/images/question.svg +1 -0
- package/src/Atom/Icon/images/restart.svg +1 -0
- package/src/Atom/Icon/images/search.svg +1 -0
- package/src/Atom/Icon/images/settings.svg +1 -0
- package/src/Atom/Icon/images/share.svg +1 -0
- package/src/Atom/Icon/images/star-selected.svg +1 -0
- package/src/Atom/Icon/images/star-unselected.svg +1 -0
- package/src/Atom/Icon/images/success.svg +1 -0
- package/src/Atom/Icon/images/tick.svg +1 -0
- package/src/Atom/Icon/images/trash.svg +1 -0
- package/src/Atom/Icon/images/twitter.svg +1 -0
- package/src/Atom/Icon/images/user.svg +1 -0
- package/src/Atom/Icon/images/video.svg +1 -0
- package/src/Atom/Icon/images/warning.svg +1 -0
- package/src/Atom/Icon/images/youtube.svg +1 -0
- package/src/Atom/Image/Image.stories.ts +20 -0
- package/src/Atom/Image/__snapshots__/Image.stories.ts.snap +9 -0
- package/src/Atom/Image/_image.css +29 -0
- package/src/Atom/Image/image.twig +13 -0
- package/src/Atom/Link/Link.stories.ts +37 -0
- package/src/Atom/Link/Link.stories.tsx +30 -0
- package/src/Atom/Link/Link.tsx +38 -0
- package/src/Atom/Link/__snapshots__/Link.stories.ts.snap +17 -0
- package/src/Atom/Link/__snapshots__/Link.stories.tsx.snap +25 -0
- package/src/Atom/Link/_links.css +39 -0
- package/src/Atom/Link/link.twig +12 -0
- package/src/Atom/Media/Media.stories.ts +26 -0
- package/src/Atom/Media/Media.stories.tsx +25 -0
- package/src/Atom/Media/Media.tsx +42 -0
- package/src/Atom/Media/__snapshots__/Media.stories.ts.snap +14 -0
- package/src/Atom/Media/__snapshots__/Media.stories.tsx.snap +18 -0
- package/src/Atom/Media/_media.css +40 -0
- package/src/Atom/Media/media.twig +18 -0
- package/src/Atom/NavList/NavList.stories.ts +15 -0
- package/src/Atom/NavList/__snapshots__/NavList.stories.ts.snap +43 -0
- package/src/Atom/NavList/nav-list.css +29 -0
- package/src/Atom/NavList/nav-list.twig +25 -0
- package/src/Atom/README.md +5 -0
- package/src/Atom/Spacing/Spacing.stories.ts +48 -0
- package/src/Atom/Spacing/__snapshots__/Spacing.stories.ts.snap +8 -0
- package/src/Atom/Spacing/_spacing.css +36 -0
- package/src/Atom/Spacing/spacing.twig +3 -0
- package/src/Atom/Table/Table.stories.ts +39 -0
- package/src/Atom/Table/TableResponsive.stories.ts +16 -0
- package/src/Atom/Table/__snapshots__/Table.stories.ts.snap +261 -0
- package/src/Atom/Table/__snapshots__/TableResponsive.stories.ts.snap +68 -0
- package/src/Atom/Table/_table.css +72 -0
- package/src/Atom/Table/table-responsive.twig +32 -0
- package/src/Atom/Table/table.twig +30 -0
- package/src/Atom/Text/Text.stories.tsx +20 -0
- package/src/Atom/Text/Text.tsx +26 -0
- package/src/Atom/Text/TextSizes.stories.ts +25 -0
- package/src/Atom/Text/__snapshots__/Text.stories.tsx.snap +7 -0
- package/src/Atom/Text/__snapshots__/TextSizes.stories.ts.snap +63 -0
- package/src/Atom/Text/_text-align.css +13 -0
- package/src/Atom/Text/_text-sizes.css +117 -0
- package/src/Atom/Text/text-alignment.twig +5 -0
- package/src/Atom/Text/text-style.twig +1 -0
- package/src/Atom/Text/text-styles-example.twig +35 -0
- package/src/Atom/Video/Video.stories.ts +16 -0
- package/src/Atom/Video/Video.tsx +17 -0
- package/src/Atom/Video/__snapshots__/Video.stories.ts.snap +21 -0
- package/src/Atom/Video/_video.css +10 -0
- package/src/Atom/Video/video.twig +5 -0
- package/src/Atom/_animated.css +65 -0
- package/src/Atom/_base.css +62 -0
- package/src/Atom/_flow-legacy.css +48 -0
- package/src/Atom/_flow.css +53 -0
- package/src/Atom/_generic.css +93 -0
- package/src/Atom/_hr.css +10 -0
- package/src/Atom/_mixins.css +22 -0
- package/src/Atom/_print.css +20 -0
- package/src/Atom/base.css +5 -0
- package/src/Atom/images/external-link.svg +1 -0
- package/src/Component/Accordion/Accordion.stories.ts +51 -0
- package/src/Component/Accordion/Accordion.stories.tsx +22 -0
- package/src/Component/Accordion/Accordion.tsx +83 -0
- package/src/Component/Accordion/Elements/Accordion.ts +82 -0
- package/src/Component/Accordion/Elements/AccordionDiv.ts +83 -0
- package/src/Component/Accordion/Elements/AccordionGroup.ts +106 -0
- package/src/Component/Accordion/Elements/AccordionMobile.ts +47 -0
- package/src/Component/Accordion/README.md +45 -0
- package/src/Component/Accordion/__snapshots__/Accordion.stories.ts.snap +94 -0
- package/src/Component/Accordion/__snapshots__/Accordion.stories.tsx.snap +26 -0
- package/src/Component/Accordion/accordion-item.twig +18 -0
- package/src/Component/Accordion/accordion.css +107 -0
- package/src/Component/Accordion/accordion.twig +19 -0
- package/src/Component/Accordion/images/collapse.svg +1 -0
- package/src/Component/Accordion/images/expand.svg +1 -0
- package/src/Component/Accordion/twig/accordion-div.twig +13 -0
- package/src/Component/Accordion/twig/accordion-example.twig +36 -0
- package/src/Component/Accordion/twig/accordion-mobile.twig +15 -0
- package/src/Component/Accordion/twig/accordion-story.twig +13 -0
- package/src/Component/Author/Author.stories.tsx +18 -0
- package/src/Component/Author/Author.tsx +30 -0
- package/src/Component/Author/__snapshots__/Author.stories.tsx.snap +21 -0
- package/src/Component/Breadcrumb/Breadcrumb.stories.ts +15 -0
- package/src/Component/Breadcrumb/Breadcrumb.stories.tsx +38 -0
- package/src/Component/Breadcrumb/Breadcrumb.tsx +34 -0
- package/src/Component/Breadcrumb/__snapshots__/Breadcrumb.stories.ts.snap +26 -0
- package/src/Component/Breadcrumb/__snapshots__/Breadcrumb.stories.tsx.snap +60 -0
- package/src/Component/Breadcrumb/breadcrumb.css +46 -0
- package/src/Component/Breadcrumb/breadcrumb.twig +12 -0
- package/src/Component/Callout/Callout.stories.ts +29 -0
- package/src/Component/Callout/callout.css +7 -0
- package/src/Component/Callout/callout.twig +10 -0
- package/src/Component/Callout/twig/callout-story.twig +11 -0
- package/src/Component/Card/CHANGELOG.md +187 -0
- package/src/Component/Card/Card.stories.ts +106 -0
- package/src/Component/Card/Card.stories.tsx +50 -0
- package/src/Component/Card/Card.tsx +56 -0
- package/src/Component/Card/README.md +21 -0
- package/src/Component/Card/__snapshots__/Card.stories.ts.snap +186 -0
- package/src/Component/Card/__snapshots__/Card.stories.tsx.snap +88 -0
- package/src/Component/Card/__snapshots__/CardGrid.stories.ts.snap +89 -0
- package/src/Component/Card/card-grid.twig +10 -0
- package/src/Component/Card/card.css +128 -0
- package/src/Component/Card/card.twig +45 -0
- package/src/Component/Card/twig/old-card.twig +17 -0
- package/src/Component/Card/twig/story-card.twig +29 -0
- package/src/Component/ContentBlock/ContentBlock.stories.ts +15 -0
- package/src/Component/ContentBlock/ContentBlock.stories.tsx +30 -0
- package/src/Component/ContentBlock/ContentBlock.tsx +37 -0
- package/src/Component/ContentBlock/README.md +21 -0
- package/src/Component/ContentBlock/__snapshots__/ContentBlock.stories.ts.snap +26 -0
- package/src/Component/ContentBlock/__snapshots__/ContentBlock.stories.tsx.snap +21 -0
- package/src/Component/ContentBlock/content-block.css +21 -0
- package/src/Component/ContentBlock/content-block.twig +12 -0
- package/src/Component/ContentBlock/twig/content-block-example.twig +7 -0
- package/src/Component/Dialog/Dialog.stories.ts +28 -0
- package/src/Component/Dialog/Dialog.stories.tsx +45 -0
- package/src/Component/Dialog/Dialog.tsx +79 -0
- package/src/Component/Dialog/Elements/Dialog.ts +145 -0
- package/src/Component/Dialog/README.md +63 -0
- package/src/Component/Dialog/__snapshots__/Dialog.stories.ts.snap +85 -0
- package/src/Component/Dialog/__snapshots__/Dialog.stories.tsx.snap +39 -0
- package/src/Component/Dialog/dialog.css +85 -0
- package/src/Component/Dialog/dialog.twig +19 -0
- package/src/Component/DropMenu/Components/DropMenuContext.tsx +192 -0
- package/src/Component/DropMenu/Components/DropMenuItem.tsx +35 -0
- package/src/Component/DropMenu/DropMenu.stories.ts +36 -0
- package/src/Component/DropMenu/DropMenu.stories.tsx +24 -0
- package/src/Component/DropMenu/DropMenu.tsx +81 -0
- package/src/Component/DropMenu/Elements/DropMenu.ts +172 -0
- package/src/Component/DropMenu/README.md +11 -0
- package/src/Component/DropMenu/__snapshots__/DropMenu.stories.ts.snap +32 -0
- package/src/Component/DropMenu/__snapshots__/DropMenu.stories.tsx.snap +47 -0
- package/src/Component/DropMenu/drop-menu.css +68 -0
- package/src/Component/DropMenu/drop-menu.twig +27 -0
- package/src/Component/DropMenu/polyfills.js +28 -0
- package/src/Component/HeroBanner/HeroBanner.stories.ts +75 -0
- package/src/Component/HeroBanner/HeroBanner.stories.tsx +30 -0
- package/src/Component/HeroBanner/HeroBanner.tsx +50 -0
- package/src/Component/HeroBanner/__snapshots__/PageTitle.stories.ts.snap +31 -0
- package/src/Component/HeroBanner/__snapshots__/PageTitle.stories.tsx.snap +36 -0
- package/src/Component/HeroBanner/hero-banner.css +51 -0
- package/src/Component/HeroBanner/hero-banner.twig +41 -0
- package/src/Component/HeroBanner/twig/hero-banner-story.twig +19 -0
- package/src/Component/InPageAlert/Elements/InPageAlert.ts +87 -0
- package/src/Component/InPageAlert/InPageAlert.stories.ts +35 -0
- package/src/Component/InPageAlert/InPageAlert.stories.tsx +43 -0
- package/src/Component/InPageAlert/InPageAlert.tsx +50 -0
- package/src/Component/InPageAlert/README.md +27 -0
- package/src/Component/InPageAlert/__snapshots__/InPageAlert.stories.ts.snap +43 -0
- package/src/Component/InPageAlert/__snapshots__/InPageAlert.stories.tsx.snap +69 -0
- package/src/Component/InPageAlert/in-page-alert.css +89 -0
- package/src/Component/InPageAlert/in-page-alert.twig +18 -0
- package/src/Component/InPageNavigation/Elements/InPageNavigation.ts +125 -0
- package/src/Component/InPageNavigation/Hooks/useInPageNavigation.ts +45 -0
- package/src/Component/InPageNavigation/InPageNavigation.stories.ts +16 -0
- package/src/Component/InPageNavigation/InPageNavigation.stories.tsx +86 -0
- package/src/Component/InPageNavigation/InPageNavigation.tsx +38 -0
- package/src/Component/InPageNavigation/README.md +30 -0
- package/src/Component/InPageNavigation/__snapshots__/InPageNavigation.stories.ts.snap +73 -0
- package/src/Component/InPageNavigation/__snapshots__/InPageNavigation.stories.tsx.snap +149 -0
- package/src/Component/InPageNavigation/in-page-navigation.css +17 -0
- package/src/Component/InPageNavigation/in-page-navigation.twig +17 -0
- package/src/Component/InPageNavigation/twig/in-page-navigation-content-example.twig +16 -0
- package/src/Component/InPageNavigation/twig/in-page-navigation-menu-example.twig +6 -0
- package/src/Component/LinkList/LinkList.stories.ts +29 -0
- package/src/Component/LinkList/LinkList.stories.tsx +29 -0
- package/src/Component/LinkList/LinkList.tsx +43 -0
- package/src/Component/LinkList/README.md +19 -0
- package/src/Component/LinkList/__snapshots__/LinkList.stories.ts.snap +58 -0
- package/src/Component/LinkList/__snapshots__/LinkList.stories.tsx.snap +53 -0
- package/src/Component/LinkList/link-list.css +68 -0
- package/src/Component/LinkList/link-list.twig +12 -0
- package/src/Component/ListItem/Teaser.stories.tsx +34 -0
- package/src/Component/ListItem/Teaser.tsx +54 -0
- package/src/Component/ListItem/__snapshots__/Teaser.stories.tsx.snap +32 -0
- package/src/Component/Navigation/Collapsible.stories.ts +16 -0
- package/src/Component/Navigation/Components/DropdownLevel.tsx +107 -0
- package/src/Component/Navigation/Dropdown.stories.ts +16 -0
- package/src/Component/Navigation/Dropdown.stories.tsx +46 -0
- package/src/Component/Navigation/Dropdown.tsx +39 -0
- package/src/Component/Navigation/Elements/Navigation.ts +174 -0
- package/src/Component/Navigation/MegaNav.stories.ts +16 -0
- package/src/Component/Navigation/Navigation.stories.ts +15 -0
- package/src/Component/Navigation/Navigation.stories.tsx +40 -0
- package/src/Component/Navigation/Navigation.tsx +51 -0
- package/src/Component/Navigation/README.md +17 -0
- package/src/Component/Navigation/__snapshots__/Collapsible.stories.ts.snap +123 -0
- package/src/Component/Navigation/__snapshots__/Dropdown.stories.ts.snap +125 -0
- package/src/Component/Navigation/__snapshots__/Dropdown.stories.tsx.snap +39 -0
- package/src/Component/Navigation/__snapshots__/Navigation.stories.ts.snap +25 -0
- package/src/Component/Navigation/__snapshots__/Navigation.stories.tsx.snap +61 -0
- package/src/Component/Navigation/_navigation-collapsible.css +72 -0
- package/src/Component/Navigation/_navigation-dropdown.css +152 -0
- package/src/Component/Navigation/_navigation-mega.css +51 -0
- package/src/Component/Navigation/_navigation.css +55 -0
- package/src/Component/Navigation/navigation-collapsible.twig +7 -0
- package/src/Component/Navigation/navigation-dropdown.twig +7 -0
- package/src/Component/Navigation/navigation-mega-nav.twig +7 -0
- package/src/Component/Navigation/navigation.css +4 -0
- package/src/Component/Navigation/navigation.twig +9 -0
- package/src/Component/Navigation/twig/navigation-subnav-list.twig +108 -0
- package/src/Component/Pagination/Components/PaginationContext.tsx +188 -0
- package/src/Component/Pagination/Components/PaginationItem.tsx +48 -0
- package/src/Component/Pagination/Pagination.stories.ts +15 -0
- package/src/Component/Pagination/Pagination.stories.tsx +25 -0
- package/src/Component/Pagination/Pagination.tsx +75 -0
- package/src/Component/Pagination/README.md +19 -0
- package/src/Component/Pagination/__snapshots__/Pagination.stories.ts.snap +58 -0
- package/src/Component/Pagination/__snapshots__/Pagination.stories.tsx.snap +57 -0
- package/src/Component/Pagination/pagination.css +112 -0
- package/src/Component/Pagination/pagination.twig +44 -0
- package/src/Component/SocialShare/SocialShare.stories.tsx +26 -0
- package/src/Component/SocialShare/SocialShare.tsx +53 -0
- package/src/Component/SocialShare/__snapshots__/SocialShare.stories.tsx.snap +25 -0
- package/src/Component/Sticky/Elements/Sticky.ts +93 -0
- package/src/Component/Sticky/README.md +23 -0
- package/src/Component/Sticky/Sticky.stories.ts +16 -0
- package/src/Component/Sticky/Sticky.stories.tsx +14 -0
- package/src/Component/Sticky/Sticky.tsx +34 -0
- package/src/Component/Sticky/__snapshots__/Sticky.stories.ts.snap +86 -0
- package/src/Component/Sticky/__snapshots__/Sticky.stories.tsx.snap +11 -0
- package/src/Component/Sticky/sticky.css +39 -0
- package/src/Component/Sticky/sticky.twig +21 -0
- package/src/Component/Sticky/twig/sticky-example.twig +4 -0
- package/src/Component/Tabs/Components/Tab.tsx +45 -0
- package/src/Component/Tabs/Components/TabDropMenu.tsx +14 -0
- package/src/Component/Tabs/Components/TabList.tsx +9 -0
- package/src/Component/Tabs/Components/TabPanel.tsx +32 -0
- package/src/Component/Tabs/Elements/Tabs.ts +213 -0
- package/src/Component/Tabs/README.md +23 -0
- package/src/Component/Tabs/Tabs.stories.ts +22 -0
- package/src/Component/Tabs/Tabs.stories.tsx +51 -0
- package/src/Component/Tabs/Tabs.tsx +100 -0
- package/src/Component/Tabs/__snapshots__/Tabs.stories.ts.snap +144 -0
- package/src/Component/Tabs/__snapshots__/Tabs.stories.tsx.snap +120 -0
- package/src/Component/Tabs/tabs.css +103 -0
- package/src/Component/Tabs/tabs.twig +49 -0
- package/src/Component/Tabs/twig/panel.twig +5 -0
- package/src/Component/Tabs/twig/tab-list.twig +26 -0
- package/src/Component/Tag/README.md +19 -0
- package/src/Component/Tag/Tag.stories.ts +54 -0
- package/src/Component/Tag/Tag.stories.tsx +13 -0
- package/src/Component/Tag/Tag.tsx +19 -0
- package/src/Component/Tag/__snapshots__/Tag.stories.ts.snap +64 -0
- package/src/Component/Tag/__snapshots__/Tag.stories.tsx.snap +7 -0
- package/src/Component/Tag/tag.css +57 -0
- package/src/Component/Tag/tags.twig +23 -0
- package/src/Component/Tile/README.md +3 -0
- package/src/Component/Tile/Tile.stories.ts +23 -0
- package/src/Component/Tile/Tile.stories.tsx +30 -0
- package/src/Component/Tile/Tile.tsx +40 -0
- package/src/Component/Tile/__snapshots__/Tile.stories.ts.snap +83 -0
- package/src/Component/Tile/__snapshots__/Tile.stories.tsx.snap +38 -0
- package/src/Component/Tile/tile.twig +10 -0
- package/src/Component/Tile/tiles.css +58 -0
- package/src/Component/Tile/twig/tiles.twig +18 -0
- package/src/Form/Checkbox/Checkboxes.stories.ts +47 -0
- package/src/Form/Checkbox/FormCheckbox.stories.tsx +32 -0
- package/src/Form/Checkbox/FormCheckbox.tsx +124 -0
- package/src/Form/Checkbox/__snapshots__/Checkboxes.stories.ts.snap +115 -0
- package/src/Form/Checkbox/input-checkbox-single.twig +6 -0
- package/src/Form/Checkbox/input-checkbox.twig +24 -0
- package/src/Form/Description/Description.stories.ts +16 -0
- package/src/Form/Description/ErrorMessage.stories.ts +16 -0
- package/src/Form/Description/FormDescription.stories.tsx +14 -0
- package/src/Form/Description/FormDescription.tsx +28 -0
- package/src/Form/Description/__snapshots__/Description.stories.ts.snap +17 -0
- package/src/Form/Description/__snapshots__/ErrorMessage.stories.ts.snap +20 -0
- package/src/Form/Description/__snapshots__/FormDescription.stories.tsx.snap +10 -0
- package/src/Form/Description/form-description.twig +3 -0
- package/src/Form/Description/form-error.twig +5 -0
- package/src/Form/Fieldset/Fieldset.stories.ts +34 -0
- package/src/Form/Fieldset/__snapshots__/Fieldset.stories.ts.snap +23 -0
- package/src/Form/Fieldset/fieldset.twig +4 -0
- package/src/Form/Form/Form.stories.tsx +10 -0
- package/src/Form/Form/Form.tsx +9 -0
- package/src/Form/Form/FormTitle.stories.tsx +14 -0
- package/src/Form/Form/FormTitle.tsx +12 -0
- package/src/Form/Form/__snapshots__/Form.stories.tsx.snap +6 -0
- package/src/Form/Form/__snapshots__/FormTitle.stories.tsx.snap +9 -0
- package/src/Form/Form/twig/form-example.twig +13 -0
- package/src/Form/Item/FormItem.stories.tsx +58 -0
- package/src/Form/Item/FormItem.tsx +26 -0
- package/src/Form/Item/__snapshots__/FormItem.stories.tsx.snap +102 -0
- package/src/Form/Label/FormLabel.stories.tsx +20 -0
- package/src/Form/Label/FormLabel.tsx +19 -0
- package/src/Form/Label/Label.stories.ts +34 -0
- package/src/Form/Label/__snapshots__/FormLabel.stories.tsx.snap +16 -0
- package/src/Form/Label/__snapshots__/Label.stories.ts.snap +23 -0
- package/src/Form/Label/label.twig +2 -0
- package/src/Form/README.md +11 -0
- package/src/Form/Radio/FormRadio.stories.tsx +37 -0
- package/src/Form/Radio/FormRadio.tsx +80 -0
- package/src/Form/Radio/Radios.stories.ts +47 -0
- package/src/Form/Radio/__snapshots__/Radios.stories.ts.snap +125 -0
- package/src/Form/Radio/input-radio.twig +24 -0
- package/src/Form/Search/TextInputWithInlineButton.stories.ts +16 -0
- package/src/Form/Search/__snapshots__/TextInputWithInlineButton.stories.ts.snap +26 -0
- package/src/Form/Search/input-text-inline-submit.twig +8 -0
- package/src/Form/Select/FormSelect.stories.tsx +34 -0
- package/src/Form/Select/FormSelect.tsx +67 -0
- package/src/Form/Select/Select.stories.ts +40 -0
- package/src/Form/Select/__snapshots__/FormSelect.stories.tsx.snap +23 -0
- package/src/Form/Select/__snapshots__/Select.stories.ts.snap +148 -0
- package/src/Form/Select/select.twig +16 -0
- package/src/Form/TextInput/FormText.stories.tsx +15 -0
- package/src/Form/TextInput/FormText.tsx +55 -0
- package/src/Form/TextInput/InputDivider.stories.ts +16 -0
- package/src/Form/TextInput/TextInput.stories.ts +57 -0
- package/src/Form/TextInput/TextInputWithIcon.stories.ts +40 -0
- package/src/Form/TextInput/__snapshots__/FormText.stories.tsx.snap +13 -0
- package/src/Form/TextInput/__snapshots__/InputDivider.stories.ts.snap +32 -0
- package/src/Form/TextInput/__snapshots__/TextInput.stories.ts.snap +101 -0
- package/src/Form/TextInput/__snapshots__/TextInputWithIcon.stories.ts.snap +67 -0
- package/src/Form/TextInput/input-divider.twig +11 -0
- package/src/Form/TextInput/input-text-icon.twig +7 -0
- package/src/Form/TextInput/input-text.twig +5 -0
- package/src/Form/Textarea/FormTextarea.stories.tsx +14 -0
- package/src/Form/Textarea/FormTextarea.tsx +53 -0
- package/src/Form/Textarea/Textarea.stories.ts +16 -0
- package/src/Form/Textarea/__snapshots__/FormTextarea.stories.tsx.snap +12 -0
- package/src/Form/Textarea/__snapshots__/Textarea.stories.ts.snap +19 -0
- package/src/Form/Textarea/textarea.twig +5 -0
- package/src/Form/form.css +479 -0
- package/src/Form/images/checkmark.svg +1 -0
- package/src/Form/images/form-chevron-down.svg +1 -0
- package/src/Form/images/form-error.svg +1 -0
- package/src/Form/images/form-success.svg +1 -0
- package/src/Layout/Footer/Footer.stories.ts +15 -0
- package/src/Layout/Footer/Footer.stories.tsx +42 -0
- package/src/Layout/Footer/Footer.tsx +55 -0
- package/src/Layout/Footer/FooterMenu/FooterMenu.stories.ts +15 -0
- package/src/Layout/Footer/FooterMenu/__snapshots__/FooterMenu.stories.ts.snap +101 -0
- package/src/Layout/Footer/FooterMenu/footer-menu.css +29 -0
- package/src/Layout/Footer/FooterMenu/footer-menu.twig +5 -0
- package/src/Layout/Footer/__snapshots__/Footer.stories.ts.snap +139 -0
- package/src/Layout/Footer/__snapshots__/Footer.stories.tsx.snap +70 -0
- package/src/Layout/Footer/footer.css +54 -0
- package/src/Layout/Footer/footer.twig +25 -0
- package/src/Layout/Grid/Grid.stories.ts +68 -0
- package/src/Layout/Grid/Grid.stories.tsx +125 -0
- package/src/Layout/Grid/Grid.tsx +51 -0
- package/src/Layout/Grid/__snapshots__/Grid.stories.ts.snap +103 -0
- package/src/Layout/Grid/__snapshots__/Grid.stories.tsx.snap +67 -0
- package/src/Layout/Grid/container-grid.css +190 -0
- package/src/Layout/Grid/grid-item.twig +16 -0
- package/src/Layout/Grid/grid.css +190 -0
- package/src/Layout/Grid/grid.twig +10 -0
- package/src/Layout/Grid/twig/container-grid-dynamic.twig +47 -0
- package/src/Layout/Grid/twig/container-grid.twig +46 -0
- package/src/Layout/Grid/twig/grid-story.twig +6 -0
- package/src/Layout/Grid/twig/old-grid.twig +46 -0
- package/src/Layout/Header/Components/GlobalToggle.tsx +35 -0
- package/src/Layout/Header/Components/Logo.tsx +17 -0
- package/src/Layout/Header/Elements/GlobalToggle.ts +137 -0
- package/src/Layout/Header/Header.stories.ts +18 -0
- package/src/Layout/Header/Header.stories.tsx +17 -0
- package/src/Layout/Header/Header.tsx +73 -0
- package/src/Layout/Header/Stacked/Stacked.stories.ts +16 -0
- package/src/Layout/Header/Stacked/__snapshots__/Stacked.stories.ts.snap +353 -0
- package/src/Layout/Header/Stacked/header-stacked.twig +33 -0
- package/src/Layout/Header/__snapshots__/Header.stories.ts.snap +157 -0
- package/src/Layout/Header/__snapshots__/Header.stories.tsx.snap +55 -0
- package/src/Layout/Header/_header.css +89 -0
- package/src/Layout/Header/_toggles.css +31 -0
- package/src/Layout/Header/header.css +2 -0
- package/src/Layout/Header/header.twig +24 -0
- package/src/Layout/Header/twig/global-header.twig +4 -0
- package/src/Layout/Header/twig/logo.twig +3 -0
- package/src/Layout/Masthead/Masthead.stories.ts +16 -0
- package/src/Layout/Masthead/__snapshots__/Masthead.stories.ts.snap +32 -0
- package/src/Layout/Masthead/masthead.css +36 -0
- package/src/Layout/Masthead/masthead.twig +10 -0
- package/src/Layout/Page/Page.stories.tsx +22 -0
- package/src/Layout/Page/Page.tsx +16 -0
- package/src/Layout/Page/README.md +19 -0
- package/src/Layout/Page/__snapshots__/Page.stories.tsx.snap +80 -0
- package/src/Layout/Page/page.css +150 -0
- package/src/Layout/Page/page.twig +3 -0
- package/src/Layout/README.md +19 -0
- package/src/Layout/Section/Background.stories.ts +25 -0
- package/src/Layout/Section/Breakouts.stories.ts +16 -0
- package/src/Layout/Section/Flow.stories.ts +16 -0
- package/src/Layout/Section/Section.stories.ts +63 -0
- package/src/Layout/Section/Section.stories.tsx +56 -0
- package/src/Layout/Section/Section.tsx +83 -0
- package/src/Layout/Section/SectionGrid.stories.tsx +53 -0
- package/src/Layout/Section/SectionGrid.tsx +71 -0
- package/src/Layout/Section/__snapshots__/Section.stories.ts.snap +19 -0
- package/src/Layout/Section/__snapshots__/Section.stories.tsx.snap +37 -0
- package/src/Layout/Section/__snapshots__/SectionBackground.stories.ts.snap +55 -0
- package/src/Layout/Section/__snapshots__/SectionGrid.stories.tsx.snap +37 -0
- package/src/Layout/Section/__snapshots__/SectionsBreakouts.stories.ts.snap +78 -0
- package/src/Layout/Section/__snapshots__/SectionsFlowsGroups.stories.ts.snap +89 -0
- package/src/Layout/Section/section.css +156 -0
- package/src/Layout/Section/section.twig +25 -0
- package/src/Layout/Section/twig/section-background.twig +12 -0
- package/src/Layout/Section/twig/section-story.twig +14 -0
- package/src/Layout/Section/twig/sections-breakout.twig +38 -0
- package/src/Layout/Section/twig/sections-flow.twig +51 -0
- package/src/Layout/Section/twig/sections-stacked.twig +28 -0
- package/src/Layout/Sidebar/Sidebar.stories.ts +35 -0
- package/src/Layout/Sidebar/Sidebar.stories.tsx +33 -0
- package/src/Layout/Sidebar/Sidebar.tsx +34 -0
- package/src/Layout/Sidebar/__snapshots__/Sidebar.stories.ts.snap +40 -0
- package/src/Layout/Sidebar/__snapshots__/Sidebar.stories.tsx.snap +47 -0
- package/src/Layout/Sidebar/sidebar.css +69 -0
- package/src/Layout/Sidebar/sidebar.twig +17 -0
- package/src/Layout/images/mixtape-logo.png +0 -0
- package/src/Utility/Context/ImageComponent.tsx +49 -0
- package/src/Utility/Context/LinkComponent.tsx +57 -0
- package/src/Utility/Drupal/README.md +9 -0
- package/src/Utility/Drupal/drupal.css +66 -0
- package/src/Utility/Drupal/twig/local-tasks.twig +17 -0
- package/src/Utility/Drupal/twig/login-form.twig +22 -0
- package/src/Utility/Elements/breakpoint-loader.ts +79 -0
- package/src/Utility/Elements/cookie-compliance.ts +174 -0
- package/src/Utility/Elements/disclosure-widget.ts +173 -0
- package/src/Utility/Elements/io-loader.ts +57 -0
- package/src/Utility/Elements/keyboard.ts +150 -0
- package/src/Utility/Hooks/useLocalStorage.ts +78 -0
- package/src/Utility/Hooks/useMediaQuery.ts +31 -0
- package/src/Utility/Hooks/useToggle.ts +17 -0
- package/src/Utility/Hooks/useUrlParams.ts +24 -0
- package/src/Utility/README.md +15 -0
- package/src/Utility/_layout-utils.css +78 -0
- package/src/Utility/global.d.ts +25 -0
- package/src/Utility/utilities.css +88 -0
- package/src/Utility/utilities.ts +163 -0
- package/src/_custom-media.css +33 -0
- package/src/constants.css +118 -0
- package/src/elements.ts +13 -0
- package/src/enums.ts +260 -0
- package/src/index.css +27 -0
- package/src/react.ts +68 -0
- package/src/tokens.js +119 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JSX,
|
|
3
|
+
ReactNode,
|
|
4
|
+
PropsWithChildren,
|
|
5
|
+
ComponentPropsWithoutRef,
|
|
6
|
+
RefObject,
|
|
7
|
+
useRef,
|
|
8
|
+
useEffect,
|
|
9
|
+
useCallback,
|
|
10
|
+
} from "react"
|
|
11
|
+
import classNames from "classnames"
|
|
12
|
+
import { DialogStyles } from "../../enums"
|
|
13
|
+
|
|
14
|
+
type DialogProps = ComponentPropsWithoutRef<"dialog"> &
|
|
15
|
+
PropsWithChildren & {
|
|
16
|
+
modifier?: DialogStyles
|
|
17
|
+
actions?: ReactNode
|
|
18
|
+
className?: string
|
|
19
|
+
modal?: boolean
|
|
20
|
+
onClose?: () => void
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const defaultOnClose = (): void => {}
|
|
24
|
+
|
|
25
|
+
const Dialog = ({
|
|
26
|
+
children,
|
|
27
|
+
modifier,
|
|
28
|
+
actions,
|
|
29
|
+
open = false,
|
|
30
|
+
onClose = defaultOnClose,
|
|
31
|
+
modal = true,
|
|
32
|
+
...props
|
|
33
|
+
}: DialogProps): JSX.Element => {
|
|
34
|
+
const dialogRef: RefObject<HTMLDialogElement> = useRef(null)
|
|
35
|
+
|
|
36
|
+
const handleClose = useCallback(() => {
|
|
37
|
+
if (!dialogRef.current) return
|
|
38
|
+
onClose()
|
|
39
|
+
dialogRef.current.close()
|
|
40
|
+
}, [dialogRef])
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!dialogRef.current) return
|
|
44
|
+
|
|
45
|
+
if (open) {
|
|
46
|
+
if (modal) {
|
|
47
|
+
dialogRef.current.showModal()
|
|
48
|
+
} else {
|
|
49
|
+
dialogRef.current.show()
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
dialogRef.current.close()
|
|
53
|
+
}
|
|
54
|
+
}, [open, dialogRef])
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<dialog
|
|
58
|
+
ref={dialogRef}
|
|
59
|
+
onClose={handleClose}
|
|
60
|
+
className={classNames("dialog", {
|
|
61
|
+
[`dialog--${modifier}`]: modifier,
|
|
62
|
+
})}
|
|
63
|
+
{...props}
|
|
64
|
+
>
|
|
65
|
+
<div className="dialog__content vertical-flow">{children}</div>
|
|
66
|
+
{actions}
|
|
67
|
+
<button
|
|
68
|
+
autoFocus
|
|
69
|
+
onClick={handleClose}
|
|
70
|
+
className="button button--icon-only icon icon--close"
|
|
71
|
+
type="button"
|
|
72
|
+
>
|
|
73
|
+
Close dialog
|
|
74
|
+
</button>
|
|
75
|
+
</dialog>
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default Dialog
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DialogBase
|
|
3
|
+
* @file Support opening/closing, and adding a scroll lock to the body.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { handleOutsideClick, handleEscape } from "../../../Utility/utilities"
|
|
7
|
+
|
|
8
|
+
export default class Dialog extends HTMLElement {
|
|
9
|
+
internals_: ElementInternals
|
|
10
|
+
controller: AbortController
|
|
11
|
+
scrollLockClass: string = "body--scroll-lock"
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super()
|
|
15
|
+
this.internals_ = this.attachInternals()
|
|
16
|
+
this.controller = new AbortController()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
connectedCallback(): void {
|
|
20
|
+
if (!this.openBtns || !this.dialog) return
|
|
21
|
+
|
|
22
|
+
const { signal }: AbortController = this.controller
|
|
23
|
+
|
|
24
|
+
// Open on toggle click.
|
|
25
|
+
document.addEventListener(
|
|
26
|
+
"click",
|
|
27
|
+
(e: MouseEvent): void => {
|
|
28
|
+
if (![...this.openBtns].includes(e.target as HTMLButtonElement)) return
|
|
29
|
+
this.handleOpen()
|
|
30
|
+
e.preventDefault()
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
signal,
|
|
34
|
+
},
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
// Close on close button click.
|
|
38
|
+
this.dialog.addEventListener(
|
|
39
|
+
"click",
|
|
40
|
+
(e: MouseEvent): void => {
|
|
41
|
+
if (![...this.closeBtns].includes(e.target as HTMLButtonElement)) return
|
|
42
|
+
this.handleClose()
|
|
43
|
+
e.preventDefault()
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
signal,
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// Close on outside click.
|
|
51
|
+
document.addEventListener(
|
|
52
|
+
"click",
|
|
53
|
+
(e: MouseEvent): void => {
|
|
54
|
+
if (!this.dialog?.open) return
|
|
55
|
+
handleOutsideClick(e, this.dialog as HTMLElement, this.handleClose, [
|
|
56
|
+
...this.openBtns,
|
|
57
|
+
...this.closeBtns,
|
|
58
|
+
])
|
|
59
|
+
},
|
|
60
|
+
{ signal },
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
// Close on escape keydown.
|
|
64
|
+
document.addEventListener(
|
|
65
|
+
"keydown",
|
|
66
|
+
(e: KeyboardEvent): void => {
|
|
67
|
+
if (!this.dialog?.open) return
|
|
68
|
+
handleEscape(e, this.handleClose)
|
|
69
|
+
},
|
|
70
|
+
{ signal },
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Disconnected.
|
|
76
|
+
*/
|
|
77
|
+
disconnectedCallback(): void {
|
|
78
|
+
if (!this.dialog) return
|
|
79
|
+
if (typeof this.dialog.close === "function") this.dialog.close()
|
|
80
|
+
this.openBtns.forEach((btn: Element) =>
|
|
81
|
+
btn.setAttribute("aria-expanded", "false"),
|
|
82
|
+
)
|
|
83
|
+
document.body.classList.remove(this.scrollLockClass)
|
|
84
|
+
this.controller.abort()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
handleOpen = (): void => {
|
|
88
|
+
if (!this.dialog) return
|
|
89
|
+
if (typeof this.dialog.show === "function") {
|
|
90
|
+
this.isModal ? this.dialog.showModal() : this.dialog.show()
|
|
91
|
+
}
|
|
92
|
+
this.openBtns.forEach((btn: Element) =>
|
|
93
|
+
btn.setAttribute("aria-expanded", "true"),
|
|
94
|
+
)
|
|
95
|
+
document.body.classList.add(this.scrollLockClass)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
handleClose = (): void => {
|
|
99
|
+
if (!this.dialog) return
|
|
100
|
+
if (typeof this.dialog.close === "function") this.dialog.close()
|
|
101
|
+
this.openBtns.forEach((btn: Element) =>
|
|
102
|
+
btn.setAttribute("aria-expanded", "false"),
|
|
103
|
+
)
|
|
104
|
+
document.body.classList.remove(this.scrollLockClass)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get dialog(): HTMLDialogElement | null {
|
|
108
|
+
const dialog: HTMLDialogElement | null = this.querySelector("dialog")
|
|
109
|
+
if (!dialog) {
|
|
110
|
+
throw new Error(`${this.localName} must contain a <dialog> element.`)
|
|
111
|
+
}
|
|
112
|
+
return dialog
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get openBtns(): NodeListOf<HTMLButtonElement> {
|
|
116
|
+
const btns: NodeListOf<HTMLButtonElement> = document.querySelectorAll(
|
|
117
|
+
`[href="#${this.id}"], [aria-controls="${this.id}"]`,
|
|
118
|
+
)
|
|
119
|
+
if (!btns) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`${this.localName} must have an associated opening element.`,
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
btns.forEach((btn: HTMLButtonElement): void => {
|
|
125
|
+
btn.setAttribute("aria-controls", this.id)
|
|
126
|
+
})
|
|
127
|
+
return btns
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get closeBtns(): NodeListOf<HTMLButtonElement> {
|
|
131
|
+
return this.querySelectorAll("button[data-close]")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get isModal(): boolean {
|
|
135
|
+
return this.hasAttribute("data-modal")
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
customElements.define("mx-dialog", Dialog)
|
|
140
|
+
|
|
141
|
+
declare global {
|
|
142
|
+
interface HTMLElementTagNameMap {
|
|
143
|
+
"mx-dialog": Dialog
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
### How to use
|
|
4
|
+
|
|
5
|
+
**CSS**
|
|
6
|
+
|
|
7
|
+
`@import '@pnx-mixtape/mxds/dialog.css';`
|
|
8
|
+
|
|
9
|
+
**Web Components**
|
|
10
|
+
|
|
11
|
+
Web Components are self defined, simply import the desired feature. These do not use the Shadow DOM. External CSS applies.
|
|
12
|
+
|
|
13
|
+
- DialogBase import: `import '@pnx-mixtape/mxds/dialog/DialogBase';` and be sure to include `<mx-dialog>` around the `<dialog />` tag.
|
|
14
|
+
- The triggering element should either have `aria-controls="[id]"` or `href="#[id]"` where the ID matches the dialog (required).
|
|
15
|
+
- Use the `[data-modal]` attribute to trigger `HTMLDialogElement.showModal()` on open. When omitted `HTMLDialogElement.show()` is used.
|
|
16
|
+
- Add `[data-close]` to any button that should call `HTMLDialogElement.close()`
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<button aria-controls="example-dialog" class="button button--primary">
|
|
20
|
+
Dialog trigger
|
|
21
|
+
</button>
|
|
22
|
+
<mx-dialog id="example-dialog" data-modal>
|
|
23
|
+
<dialog class="dialog">
|
|
24
|
+
<button
|
|
25
|
+
autofocus
|
|
26
|
+
class="button button--icon-only icon icon--close"
|
|
27
|
+
data-close
|
|
28
|
+
>
|
|
29
|
+
Close dialog
|
|
30
|
+
</button>
|
|
31
|
+
<div class="dialog__content">
|
|
32
|
+
<h2>Title</h2>
|
|
33
|
+
<p>Body content.</p>
|
|
34
|
+
</div>
|
|
35
|
+
</dialog>
|
|
36
|
+
</mx-dialog>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
See twig files for all HTML examples.
|
|
40
|
+
|
|
41
|
+
**Vanilla JS (to be deprecated)**
|
|
42
|
+
|
|
43
|
+
- ES6 import: `import Dialog from '@pnx-mixtape/mxds/dialog';`
|
|
44
|
+
- Script tag: `<script src="dist/dialog.js" type="text/javascript"></script>`
|
|
45
|
+
|
|
46
|
+
**HTML**
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<button
|
|
50
|
+
data-dialog
|
|
51
|
+
aria-controls="example-dialog"
|
|
52
|
+
class="button button--primary"
|
|
53
|
+
>
|
|
54
|
+
Dialog trigger
|
|
55
|
+
</button>
|
|
56
|
+
|
|
57
|
+
<dialog class="dialog" id="example-dialog">
|
|
58
|
+
<div class="dialog__content">
|
|
59
|
+
<h2>Title</h2>
|
|
60
|
+
<p>Body content.</p>
|
|
61
|
+
</div>
|
|
62
|
+
</dialog>
|
|
63
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Components/Dialog Dialog smoke-test 1`] = `
|
|
4
|
+
<p>
|
|
5
|
+
<a href="#dialog-df"
|
|
6
|
+
class="button is-excluded"
|
|
7
|
+
>
|
|
8
|
+
Open Me
|
|
9
|
+
</a>
|
|
10
|
+
</p>
|
|
11
|
+
<mx-dialog id="dialog-df"
|
|
12
|
+
data-modal
|
|
13
|
+
>
|
|
14
|
+
<dialog class="dialog">
|
|
15
|
+
<button autofocus
|
|
16
|
+
class="button button--icon-only icon icon--close"
|
|
17
|
+
data-close
|
|
18
|
+
>
|
|
19
|
+
Close dialog
|
|
20
|
+
</button>
|
|
21
|
+
<div class="dialog__content vertical-flow">
|
|
22
|
+
<h3>
|
|
23
|
+
Thanks you're almost done!
|
|
24
|
+
</h3>
|
|
25
|
+
<p>
|
|
26
|
+
To finish the process you will need to upload a few more documents. Please have your confirmation email ready before starting. Are you ready?
|
|
27
|
+
</p>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="form__actions">
|
|
30
|
+
<button class="button button--primary"
|
|
31
|
+
data-close
|
|
32
|
+
>
|
|
33
|
+
Let's get started
|
|
34
|
+
</button>
|
|
35
|
+
<button class="button"
|
|
36
|
+
data-close
|
|
37
|
+
>
|
|
38
|
+
Cancel
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
</dialog>
|
|
42
|
+
</mx-dialog>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Components/Dialog Fullscreen smoke-test 1`] = `
|
|
46
|
+
<p>
|
|
47
|
+
<a href="#dialog-df"
|
|
48
|
+
class="button is-excluded"
|
|
49
|
+
>
|
|
50
|
+
Open Me
|
|
51
|
+
</a>
|
|
52
|
+
</p>
|
|
53
|
+
<mx-dialog id="dialog-df"
|
|
54
|
+
data-modal
|
|
55
|
+
>
|
|
56
|
+
<dialog class="dialog dialog--fullscreen">
|
|
57
|
+
<button autofocus
|
|
58
|
+
class="button button--icon-only icon icon--close"
|
|
59
|
+
data-close
|
|
60
|
+
>
|
|
61
|
+
Close dialog
|
|
62
|
+
</button>
|
|
63
|
+
<div class="dialog__content vertical-flow">
|
|
64
|
+
<h3>
|
|
65
|
+
Thanks you're almost done!
|
|
66
|
+
</h3>
|
|
67
|
+
<p>
|
|
68
|
+
To finish the process you will need to upload a few more documents. Please have your confirmation email ready before starting. Are you ready?
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="form__actions">
|
|
72
|
+
<button class="button button--primary"
|
|
73
|
+
data-close
|
|
74
|
+
>
|
|
75
|
+
Let's get started
|
|
76
|
+
</button>
|
|
77
|
+
<button class="button"
|
|
78
|
+
data-close
|
|
79
|
+
>
|
|
80
|
+
Cancel
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
</dialog>
|
|
84
|
+
</mx-dialog>
|
|
85
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Components/Dialog Dialog smoke-test 1`] = `
|
|
4
|
+
<dialog class="dialog"
|
|
5
|
+
open
|
|
6
|
+
>
|
|
7
|
+
<div class="dialog__content vertical-flow">
|
|
8
|
+
<h2 class
|
|
9
|
+
level="h3"
|
|
10
|
+
id="thanks-youre-almost-d"
|
|
11
|
+
>
|
|
12
|
+
Thanks, you're almost done!
|
|
13
|
+
</h2>
|
|
14
|
+
<p class>
|
|
15
|
+
To finish the process, you will need to upload a few more documents. Please have your confirmation email ready before starting. Are you ready?
|
|
16
|
+
</p>
|
|
17
|
+
</div>
|
|
18
|
+
<form>
|
|
19
|
+
<div class="form__actions">
|
|
20
|
+
<button class="button button--primary"
|
|
21
|
+
type="button"
|
|
22
|
+
>
|
|
23
|
+
Let's get started
|
|
24
|
+
</button>
|
|
25
|
+
<button class="button"
|
|
26
|
+
formmethod="dialog"
|
|
27
|
+
type="button"
|
|
28
|
+
>
|
|
29
|
+
Cancel
|
|
30
|
+
</button>
|
|
31
|
+
</div>
|
|
32
|
+
</form>
|
|
33
|
+
<button class="button button--icon-only icon icon--close"
|
|
34
|
+
type="button"
|
|
35
|
+
>
|
|
36
|
+
Close dialog
|
|
37
|
+
</button>
|
|
38
|
+
</dialog>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialog
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@layer defaults {
|
|
6
|
+
mx-dialog {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@layer components {
|
|
12
|
+
.dialog {
|
|
13
|
+
max-inline-size: var(--container-max-width);
|
|
14
|
+
max-block-size: 90vh;
|
|
15
|
+
overflow: auto hidden;
|
|
16
|
+
overscroll-behavior: contain;
|
|
17
|
+
background-color: var(--dialog-background, var(--colour-background));
|
|
18
|
+
border: var(--line-width, 1px) solid
|
|
19
|
+
var(--line-colour, var(--colour-border));
|
|
20
|
+
padding: 0;
|
|
21
|
+
margin: auto;
|
|
22
|
+
|
|
23
|
+
&::backdrop {
|
|
24
|
+
background-color: hsla(0deg 0% 100% / 75%);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
& .dialog__content {
|
|
28
|
+
padding: var(--spacing-s);
|
|
29
|
+
|
|
30
|
+
@media (--medium-up) {
|
|
31
|
+
padding-block: var(--spacing-l);
|
|
32
|
+
padding-inline: var(--spacing-xl);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
& > .icon--close {
|
|
37
|
+
position: absolute;
|
|
38
|
+
inset-block-start: var(--spacing-xxs);
|
|
39
|
+
inset-inline-end: var(--spacing-xxs);
|
|
40
|
+
border: 0;
|
|
41
|
+
z-index: 11;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
& .form__actions {
|
|
45
|
+
border-block-start: var(--line-width, 1px) solid
|
|
46
|
+
var(--line-colour, var(--colour-border));
|
|
47
|
+
padding-block: var(--spacing-s);
|
|
48
|
+
place-content: center;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Dialog fullscreen.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
@layer components {
|
|
58
|
+
.dialog--fullscreen {
|
|
59
|
+
box-shadow: none;
|
|
60
|
+
border: 0;
|
|
61
|
+
inset-block-start: 0;
|
|
62
|
+
inline-size: 100%;
|
|
63
|
+
max-inline-size: none;
|
|
64
|
+
block-size: 100%;
|
|
65
|
+
max-block-size: none;
|
|
66
|
+
|
|
67
|
+
&[open] {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
& .dialog__content {
|
|
73
|
+
max-inline-size: var(--container-max-width);
|
|
74
|
+
margin: auto;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/* Prevent scrolling on the body. */
|
|
80
|
+
.body--scroll-lock,
|
|
81
|
+
.body-dialog--open {
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
position: fixed;
|
|
84
|
+
inline-size: 100vw;
|
|
85
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<p><a href="#{{ id|default('dialog-df') }}" class="button is-excluded">{{ title | default('Open Me') }}</a></p>
|
|
2
|
+
|
|
3
|
+
<mx-dialog id="{{ id|default('dialog-df') }}" data-modal>
|
|
4
|
+
<dialog class="dialog{% if fullscreen %} dialog--fullscreen{% endif %}">
|
|
5
|
+
<button autofocus class="button button--icon-only icon icon--close" data-close>Close dialog</button>
|
|
6
|
+
<div class="dialog__content vertical-flow">
|
|
7
|
+
{% block content %}
|
|
8
|
+
<h3>Thanks you're almost done!</h3>
|
|
9
|
+
<p>To finish the process you will need to upload a few more documents. Please have your confirmation email ready before starting. Are you ready?</p>
|
|
10
|
+
{% endblock %}
|
|
11
|
+
</div>
|
|
12
|
+
{% block actions %}
|
|
13
|
+
<div class="form__actions">
|
|
14
|
+
<button class="button button--primary" data-close>Let's get started</button>
|
|
15
|
+
<button class="button" data-close>Cancel</button>
|
|
16
|
+
</div>
|
|
17
|
+
{% endblock %}
|
|
18
|
+
</dialog>
|
|
19
|
+
</mx-dialog>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars, no-console, consistent-return, @eslint-react/web-api/no-leaked-event-listener */
|
|
2
|
+
/**
|
|
3
|
+
* @file Drop Menu hook.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
RefObject,
|
|
7
|
+
MouseEvent,
|
|
8
|
+
KeyboardEvent,
|
|
9
|
+
useEffect,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
useId,
|
|
13
|
+
Dispatch,
|
|
14
|
+
SetStateAction,
|
|
15
|
+
createContext,
|
|
16
|
+
useContext,
|
|
17
|
+
JSX,
|
|
18
|
+
useMemo,
|
|
19
|
+
PropsWithChildren,
|
|
20
|
+
} from "react"
|
|
21
|
+
import { Keyboard } from "../../../Utility/utilities"
|
|
22
|
+
import useToggle from "../../../Utility/Hooks/useToggle"
|
|
23
|
+
|
|
24
|
+
type DropMenuContextValues = {
|
|
25
|
+
selected?: string[]
|
|
26
|
+
setSelected?: Dispatch<SetStateAction<string[]>>
|
|
27
|
+
dropMenuId?: string
|
|
28
|
+
triggerId?: string
|
|
29
|
+
descriptionId?: string
|
|
30
|
+
on?: boolean
|
|
31
|
+
popoverRef?: RefObject<HTMLDivElement>
|
|
32
|
+
handleClick?: (event: MouseEvent | KeyboardEvent, key: string) => void
|
|
33
|
+
handleKeydown?: (event: KeyboardEvent, key: string) => void
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type DropMenuProviderProps = PropsWithChildren & {
|
|
37
|
+
id: string
|
|
38
|
+
multiple?: boolean
|
|
39
|
+
onClick?: (
|
|
40
|
+
event: MouseEvent | KeyboardEvent,
|
|
41
|
+
key: string,
|
|
42
|
+
updated?: string[],
|
|
43
|
+
) => void
|
|
44
|
+
closeOnClick?: boolean
|
|
45
|
+
selectedItem?: string[]
|
|
46
|
+
focusRef?: RefObject<HTMLElement>
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const DropMenuContext = createContext<DropMenuContextValues>(null)
|
|
50
|
+
export const useDropMenuContext = () => useContext(DropMenuContext)
|
|
51
|
+
|
|
52
|
+
const defaultSelected: string[] = []
|
|
53
|
+
const defaultOnClick = (): void => {}
|
|
54
|
+
|
|
55
|
+
const DropMenuProvider = ({
|
|
56
|
+
id,
|
|
57
|
+
children,
|
|
58
|
+
multiple = false,
|
|
59
|
+
onClick = defaultOnClick,
|
|
60
|
+
closeOnClick = true,
|
|
61
|
+
selectedItem = defaultSelected,
|
|
62
|
+
focusRef,
|
|
63
|
+
}: DropMenuProviderProps): JSX.Element => {
|
|
64
|
+
const polyfilled = useRef<boolean>(false)
|
|
65
|
+
const popoverRef = useRef<HTMLDivElement>(null)
|
|
66
|
+
const dropMenuId = id || useId()
|
|
67
|
+
const triggerId = `${dropMenuId}-target`
|
|
68
|
+
const descriptionId = `${dropMenuId}-description`
|
|
69
|
+
const [on, toggle] = useToggle(false)
|
|
70
|
+
const [selected, setSelected] = useState<string[]>(selectedItem)
|
|
71
|
+
const keyboard = new Keyboard()
|
|
72
|
+
const controller = new AbortController()
|
|
73
|
+
const { signal } = controller
|
|
74
|
+
|
|
75
|
+
// Polyfill anchor and popover APIs
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!popoverRef.current || polyfilled.current) return
|
|
78
|
+
const polyfill = async () => {
|
|
79
|
+
if (!("anchorName" in document.documentElement.style)) {
|
|
80
|
+
const { default: Polyfills } = await import("../polyfills")
|
|
81
|
+
new Polyfills(popoverRef.current)
|
|
82
|
+
polyfilled.current = true
|
|
83
|
+
}
|
|
84
|
+
if (!Object.hasOwn(HTMLElement, "popover")) {
|
|
85
|
+
await import("@oddbird/popover-polyfill")
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
polyfill().catch(error => console.warn(error))
|
|
89
|
+
}, [popoverRef, polyfilled])
|
|
90
|
+
|
|
91
|
+
const handleToggle = ({ newState }: ToggleEvent): void => {
|
|
92
|
+
toggle()
|
|
93
|
+
const handleClose = (): void => popoverRef.current?.togglePopover()
|
|
94
|
+
if (newState === "open") {
|
|
95
|
+
keyboard.attachPopup(popoverRef.current?.id, handleClose)
|
|
96
|
+
} else {
|
|
97
|
+
keyboard.detachPopup(popoverRef.current?.id)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Toggle on state when popover toggle event occurs.
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
if (!popoverRef.current) return
|
|
104
|
+
popoverRef.current.addEventListener("toggle", handleToggle, {
|
|
105
|
+
signal,
|
|
106
|
+
})
|
|
107
|
+
return () => {
|
|
108
|
+
if (!popoverRef.current) return
|
|
109
|
+
controller.abort()
|
|
110
|
+
}
|
|
111
|
+
}, [popoverRef])
|
|
112
|
+
|
|
113
|
+
// Attach keyboard when popover is open.
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!popoverRef.current || !on) return
|
|
116
|
+
const items: NodeListOf<HTMLButtonElement> =
|
|
117
|
+
popoverRef.current.querySelectorAll(":scope > button")
|
|
118
|
+
if (!items) return
|
|
119
|
+
|
|
120
|
+
const attachKeyboardMenu = () =>
|
|
121
|
+
keyboard.attachMenu(popoverRef.current, items)
|
|
122
|
+
popoverRef.current.addEventListener("focusin", attachKeyboardMenu, {
|
|
123
|
+
signal,
|
|
124
|
+
})
|
|
125
|
+
popoverRef.current.addEventListener("focusout", keyboard.detachMenu, {
|
|
126
|
+
signal,
|
|
127
|
+
})
|
|
128
|
+
keyboard.attachEventListeners(signal)
|
|
129
|
+
|
|
130
|
+
return () => {
|
|
131
|
+
if (!popoverRef.current) return
|
|
132
|
+
controller.abort()
|
|
133
|
+
keyboard.detachMenu()
|
|
134
|
+
}
|
|
135
|
+
}, [on, popoverRef])
|
|
136
|
+
|
|
137
|
+
// Handle item click events.
|
|
138
|
+
const handleClick = (
|
|
139
|
+
event: MouseEvent | KeyboardEvent,
|
|
140
|
+
key: string,
|
|
141
|
+
): void => {
|
|
142
|
+
event.preventDefault()
|
|
143
|
+
let updated: string[] = []
|
|
144
|
+
if (selected.includes(key)) {
|
|
145
|
+
// Unselect
|
|
146
|
+
updated = selected.filter(item => item !== key)
|
|
147
|
+
} else if (multiple) {
|
|
148
|
+
// Add to selection.
|
|
149
|
+
updated = [...selected, key]
|
|
150
|
+
} else {
|
|
151
|
+
// Replace selection.
|
|
152
|
+
updated = [key]
|
|
153
|
+
}
|
|
154
|
+
setSelected(updated)
|
|
155
|
+
onClick(event, key, updated)
|
|
156
|
+
if (closeOnClick) {
|
|
157
|
+
popoverRef.current.togglePopover()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Handle item keyboard events.
|
|
162
|
+
const handleKeyDown = (event: KeyboardEvent, key: string): void => {
|
|
163
|
+
if (event.key !== "Enter") return
|
|
164
|
+
handleClick(event, key)
|
|
165
|
+
if (focusRef && focusRef.current) {
|
|
166
|
+
focusRef.current.focus()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const values = useMemo<DropMenuContextValues>(
|
|
171
|
+
() => ({
|
|
172
|
+
dropMenuId,
|
|
173
|
+
triggerId,
|
|
174
|
+
descriptionId,
|
|
175
|
+
on,
|
|
176
|
+
popoverRef,
|
|
177
|
+
selected,
|
|
178
|
+
setSelected,
|
|
179
|
+
handleClick,
|
|
180
|
+
handleKeyDown,
|
|
181
|
+
}),
|
|
182
|
+
[dropMenuId, triggerId, descriptionId, on, popoverRef, selected],
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<DropMenuContext.Provider value={values}>
|
|
187
|
+
{children}
|
|
188
|
+
</DropMenuContext.Provider>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export default DropMenuProvider
|