@vonage/vivid 3.0.0-next.6 → 3.0.0-next.7
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/.babelrc +3 -0
- package/.eslintrc.json +70 -0
- package/.stylelintrc.json +8 -0
- package/CHANGELOG.json +343 -0
- package/CHANGELOG.md +45 -0
- package/jest.config.cjs +20 -0
- package/package.json +4 -13
- package/playwright.config.dev.ts +21 -0
- package/playwright.config.ts +34 -0
- package/project.json +122 -0
- package/rollup.config.prod.ts +50 -0
- package/setupJestTests.js +17 -0
- package/{index.d.ts → src/index.ts} +2 -2
- package/src/lib/accordion/README.md +55 -0
- package/src/lib/accordion/accordion.scss +10 -0
- package/src/lib/accordion/accordion.spec.ts +91 -0
- package/src/lib/accordion/accordion.template.ts +23 -0
- package/src/lib/accordion/accordion.ts +49 -0
- package/src/lib/accordion/index.ts +14 -0
- package/src/lib/accordion/ui.test.ts +37 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Chrome-Stable-darwin.png +0 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Chrome-Stable-linux.png +0 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Desktop-Firefox-linux.png +0 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Desktop-Safari-darwin.png +0 -0
- package/src/lib/accordion/ui.test.ts-snapshots/snapshots-accordion-Desktop-Safari-linux.png +0 -0
- package/src/lib/accordion-item/README.md +113 -0
- package/src/lib/accordion-item/accordion-item.scss +91 -0
- package/src/lib/accordion-item/accordion-item.spec.ts +103 -0
- package/src/lib/accordion-item/accordion-item.template.ts +62 -0
- package/src/lib/accordion-item/accordion-item.ts +67 -0
- package/src/lib/accordion-item/index.ts +14 -0
- package/src/lib/accordion-item/partials/variables.scss +1 -0
- package/src/lib/accordion-item/ui.test.ts +37 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Chrome-Stable-darwin.png +0 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Chrome-Stable-linux.png +0 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Desktop-Firefox-linux.png +0 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Desktop-Safari-darwin.png +0 -0
- package/src/lib/accordion-item/ui.test.ts-snapshots/snapshots-accordion-item-Desktop-Safari-linux.png +0 -0
- package/src/lib/badge/README.md +112 -0
- package/src/lib/badge/badge.scss +64 -0
- package/src/lib/badge/badge.spec.ts +114 -0
- package/src/lib/badge/badge.template.ts +36 -0
- package/src/lib/badge/badge.ts +97 -0
- package/src/lib/badge/index.ts +23 -0
- package/src/lib/badge/ui.test.ts +28 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Chrome-Stable-darwin.png +0 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Chrome-Stable-linux.png +0 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Desktop-Firefox-linux.png +0 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Desktop-Safari-darwin.png +0 -0
- package/src/lib/badge/ui.test.ts-snapshots/snapshots-badge-Desktop-Safari-linux.png +0 -0
- package/src/lib/banner/README.md +117 -0
- package/src/lib/banner/banner.scss +71 -0
- package/src/lib/banner/banner.spec.ts +355 -0
- package/src/lib/banner/banner.template.ts +61 -0
- package/src/lib/banner/banner.ts +77 -0
- package/src/lib/banner/index.ts +14 -0
- package/src/lib/banner/ui.test.ts +64 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Chrome-Stable-darwin.png +0 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Chrome-Stable-linux.png +0 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Desktop-Firefox-linux.png +0 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Desktop-Safari-darwin.png +0 -0
- package/src/lib/banner/ui.test.ts-snapshots/snapshots-banner-Desktop-Safari-linux.png +0 -0
- package/src/lib/breadcrumb/README.md +25 -0
- package/src/lib/breadcrumb/breadcrumb.scss +3 -0
- package/src/lib/breadcrumb/breadcrumb.spec.ts +78 -0
- package/src/lib/breadcrumb/breadcrumb.ts +10 -0
- package/src/lib/breadcrumb/index.ts +13 -0
- package/src/lib/breadcrumb/ui.test.ts +36 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Chrome-Stable-darwin.png +0 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Chrome-Stable-linux.png +0 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Desktop-Firefox-linux.png +0 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Desktop-Safari-darwin.png +0 -0
- package/src/lib/breadcrumb/ui.test.ts-snapshots/snapshots-breadcrumb-Desktop-Safari-linux.png +0 -0
- package/src/lib/breadcrumb-item/README.md +40 -0
- package/src/lib/breadcrumb-item/breadcrumb-item.scss +28 -0
- package/src/lib/breadcrumb-item/breadcrumb-item.spec.ts +192 -0
- package/src/lib/breadcrumb-item/breadcrumb-item.template.ts +37 -0
- package/src/lib/breadcrumb-item/breadcrumb-item.ts +15 -0
- package/src/lib/breadcrumb-item/index.ts +16 -0
- package/src/lib/breadcrumb-item/ui.test.ts +38 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Chrome-Stable-darwin.png +0 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Chrome-Stable-linux.png +0 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Desktop-Firefox-linux.png +0 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Desktop-Safari-darwin.png +0 -0
- package/src/lib/breadcrumb-item/ui.test.ts-snapshots/snapshots-breadcrumb-item-Desktop-Safari-linux.png +0 -0
- package/src/lib/button/README.md +120 -0
- package/src/lib/button/button.scss +142 -0
- package/src/lib/button/button.spec.ts +131 -0
- package/src/lib/button/button.template.ts +89 -0
- package/src/lib/button/button.ts +95 -0
- package/src/lib/button/index.ts +25 -0
- package/src/lib/button/partials/variables.scss +2 -0
- package/src/lib/button/ui.test.ts +32 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Chrome-Stable-darwin.png +0 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Chrome-Stable-linux.png +0 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Desktop-Firefox-linux.png +0 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Desktop-Safari-darwin.png +0 -0
- package/src/lib/button/ui.test.ts-snapshots/snapshots-button-Desktop-Safari-linux.png +0 -0
- package/src/lib/calendar/README.md +70 -0
- package/src/lib/calendar/calendar.scss +176 -0
- package/src/lib/calendar/calendar.spec.ts +341 -0
- package/src/lib/calendar/calendar.template.ts +93 -0
- package/src/lib/calendar/calendar.ts +139 -0
- package/src/lib/calendar/helpers/calendar.date-functions.ts +31 -0
- package/src/lib/calendar/helpers/calendar.event-context.ts +72 -0
- package/src/lib/calendar/helpers/calendar.keyboard-interactions.ts +65 -0
- package/src/lib/calendar/index.ts +16 -0
- package/src/lib/calendar/partials/_variables.scss +15 -0
- package/src/lib/calendar/ui.test.ts +32 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Chrome-Stable-darwin.png +0 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Chrome-Stable-linux.png +0 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Desktop-Firefox-linux.png +0 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Desktop-Safari-darwin.png +0 -0
- package/src/lib/calendar/ui.test.ts-snapshots/snapshots-calendar-Desktop-Safari-linux.png +0 -0
- package/src/lib/components.spec.ts +7 -0
- package/{lib/components.d.ts → src/lib/components.ts} +16 -16
- package/src/lib/elevation/README.md +99 -0
- package/src/lib/elevation/elevation.scss +15 -0
- package/src/lib/elevation/elevation.spec.ts +55 -0
- package/src/lib/elevation/elevation.template.ts +26 -0
- package/src/lib/elevation/elevation.ts +17 -0
- package/src/lib/elevation/index.ts +17 -0
- package/src/lib/elevation/partials/_elevation.mixin.scss +4 -0
- package/src/lib/elevation/ui.test.ts +32 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Chrome-Stable-darwin.png +0 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Chrome-Stable-linux.png +0 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Desktop-Firefox-linux.png +0 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Desktop-Safari-darwin.png +0 -0
- package/src/lib/elevation/ui.test.ts-snapshots/snapshots-elevation-Desktop-Safari-linux.png +0 -0
- package/src/lib/enums.ts +55 -0
- package/src/lib/focus/README.md +1 -0
- package/src/lib/focus/focus.scss +17 -0
- package/src/lib/focus/focus.template.ts +16 -0
- package/src/lib/focus/focus.ts +10 -0
- package/src/lib/focus/index.ts +21 -0
- package/src/lib/focus/partials/variables.scss +2 -0
- package/src/lib/icon/README.md +70 -0
- package/src/lib/icon/__snapshots__/icon.spec.ts.snap +16 -0
- package/src/lib/icon/icon.placeholder.ts +12 -0
- package/src/lib/icon/icon.scss +52 -0
- package/src/lib/icon/icon.spec.ts +106 -0
- package/src/lib/icon/icon.template.ts +23 -0
- package/src/lib/icon/icon.ts +93 -0
- package/src/lib/icon/index.ts +14 -0
- package/src/lib/layout/README.md +154 -0
- package/src/lib/layout/index.ts +18 -0
- package/src/lib/layout/layout.scss +40 -0
- package/src/lib/layout/layout.spec.ts +73 -0
- package/src/lib/layout/layout.template.ts +29 -0
- package/src/lib/layout/layout.ts +46 -0
- package/src/lib/layout/partials/_functions.scss +15 -0
- package/src/lib/layout/partials/_mixins.scss +5 -0
- package/src/lib/layout/partials/_variables.scss +23 -0
- package/src/lib/layout/ui.test.ts +32 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Chrome-Stable-darwin.png +0 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Chrome-Stable-linux.png +0 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Desktop-Firefox-linux.png +0 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Desktop-Safari-darwin.png +0 -0
- package/src/lib/layout/ui.test.ts-snapshots/snapshots-layout-Desktop-Safari-linux.png +0 -0
- package/src/lib/popup/README.md +261 -0
- package/src/lib/popup/index.ts +21 -0
- package/src/lib/popup/popup.scss +43 -0
- package/src/lib/popup/popup.spec.ts +265 -0
- package/src/lib/popup/popup.template.ts +41 -0
- package/src/lib/popup/popup.ts +158 -0
- package/src/lib/popup/ui.test.ts +111 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Chrome-Stable-darwin.png +0 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Chrome-Stable-linux.png +0 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Desktop-Firefox-linux.png +0 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Desktop-Safari-darwin.png +0 -0
- package/src/lib/popup/ui.test.ts-snapshots/snapshots-popup-Desktop-Safari-linux.png +0 -0
- package/src/lib/progress/README.md +107 -0
- package/src/lib/progress/index.ts +14 -0
- package/src/lib/progress/progress.scss +133 -0
- package/src/lib/progress/progress.spec.ts +173 -0
- package/src/lib/progress/progress.template.ts +62 -0
- package/src/lib/progress/progress.ts +25 -0
- package/src/lib/progress/ui.test.ts +70 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Chrome-Stable-darwin.png +0 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Chrome-Stable-linux.png +0 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Desktop-Firefox-linux.png +0 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Desktop-Safari-darwin.png +0 -0
- package/src/lib/progress/ui.test.ts-snapshots/snapshots-progress-Desktop-Safari-linux.png +0 -0
- package/src/lib/progress-ring/README.md +90 -0
- package/src/lib/progress-ring/index.ts +15 -0
- package/src/lib/progress-ring/progress-ring.scss +75 -0
- package/src/lib/progress-ring/progress-ring.spec.ts +139 -0
- package/src/lib/progress-ring/progress-ring.template.ts +82 -0
- package/src/lib/progress-ring/progress-ring.ts +18 -0
- package/src/lib/progress-ring/ui.test.ts +35 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Chrome-Stable-darwin.png +0 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Chrome-Stable-linux.png +0 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Desktop-Firefox-linux.png +0 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Desktop-Safari-darwin.png +0 -0
- package/src/lib/progress-ring/ui.test.ts-snapshots/snapshots-progress-ring-Desktop-Safari-linux.png +0 -0
- package/src/lib/side-drawer/README.md +304 -0
- package/src/lib/side-drawer/index.ts +16 -0
- package/src/lib/side-drawer/partials/variables.scss +6 -0
- package/src/lib/side-drawer/side-drawer.scss +109 -0
- package/src/lib/side-drawer/side-drawer.spec.ts +118 -0
- package/src/lib/side-drawer/side-drawer.template.ts +51 -0
- package/src/lib/side-drawer/side-drawer.ts +58 -0
- package/src/lib/side-drawer/ui.test.ts +102 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Chrome-Stable-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Chrome-Stable-linux.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Desktop-Firefox-linux.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Desktop-Safari-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-Desktop-Safari-linux.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Chrome-Stable-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Chrome-Stable-linux.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Desktop-Firefox-linux.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Desktop-Safari-darwin.png +0 -0
- package/src/lib/side-drawer/ui.test.ts-snapshots/snapshots-side-drawer-modal-Desktop-Safari-linux.png +0 -0
- package/src/lib/sidenav-item/README.md +41 -0
- package/src/lib/sidenav-item/index.ts +20 -0
- package/src/lib/sidenav-item/sidenav-item.scss +51 -0
- package/src/lib/sidenav-item/sidenav-item.spec.ts +64 -0
- package/src/lib/sidenav-item/sidenav-item.template.ts +25 -0
- package/src/lib/sidenav-item/sidenav-item.ts +15 -0
- package/src/lib/sidenav-item/ui.test.ts +32 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Chrome-Stable-darwin.png +0 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Chrome-Stable-linux.png +0 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Desktop-Firefox-linux.png +0 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Desktop-Safari-darwin.png +0 -0
- package/src/lib/sidenav-item/ui.test.ts-snapshots/snapshots-sidenav-item-Desktop-Safari-linux.png +0 -0
- package/src/lib/text/README.md +119 -0
- package/src/lib/text/index.ts +14 -0
- package/src/lib/text/text.scss +92 -0
- package/src/lib/text/text.spec.ts +54 -0
- package/src/lib/text/text.template.ts +28 -0
- package/src/lib/text/text.ts +55 -0
- package/src/lib/text/ui.test.ts +39 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Chrome-Stable-darwin.png +0 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Chrome-Stable-linux.png +0 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Desktop-Firefox-linux.png +0 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Desktop-Safari-darwin.png +0 -0
- package/src/lib/text/ui.test.ts-snapshots/snapshots-text-Desktop-Safari-linux.png +0 -0
- package/src/lib/text-anchor/README.md +5 -0
- package/src/lib/text-anchor/index.ts +12 -0
- package/src/lib/text-anchor/text-anchor.spec.ts +153 -0
- package/src/lib/text-anchor/text-anchor.template.ts +66 -0
- package/src/lib/text-anchor/text-anchor.ts +22 -0
- package/src/lib/tooltip/README.md +132 -0
- package/src/lib/tooltip/index.ts +16 -0
- package/src/lib/tooltip/partials/variables.scss +1 -0
- package/src/lib/tooltip/tooltip.scss +18 -0
- package/src/lib/tooltip/tooltip.spec.ts +70 -0
- package/src/lib/tooltip/tooltip.template.ts +30 -0
- package/src/lib/tooltip/tooltip.ts +44 -0
- package/src/lib/tooltip/ui.test.ts +53 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Chrome-Stable-darwin.png +0 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Chrome-Stable-linux.png +0 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Desktop-Firefox-darwin.png +0 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Desktop-Firefox-linux.png +0 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Desktop-Safari-darwin.png +0 -0
- package/src/lib/tooltip/ui.test.ts-snapshots/snapshots-tooltip-Desktop-Safari-linux.png +0 -0
- package/src/shared/design-system/index.ts +12 -0
- package/src/shared/patterns/affix.ts +56 -0
- package/{shared/patterns/index.d.ts → src/shared/patterns/index.ts} +1 -1
- package/src/types/extract-gfm.d.ts +5 -0
- package/src/types/style.d.ts +4 -0
- package/src/visual-tests/visual-tests-utils.ts +76 -0
- package/tsconfig.json +36 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.spec.json +16 -0
- package/accordion/index.js +0 -61
- package/accordion-item/index.js +0 -125
- package/badge/index.js +0 -64
- package/banner/index.js +0 -212
- package/breadcrumb/index.js +0 -100
- package/breadcrumb-item/index.js +0 -55
- package/button/index.js +0 -761
- package/calendar/index.js +0 -1521
- package/elevation/index.js +0 -31
- package/focus/index.js +0 -3
- package/icon/index.js +0 -34
- package/index.js +0 -32
- package/layout/index.js +0 -53
- package/lib/accordion/accordion.d.ts +0 -9
- package/lib/accordion/accordion.template.d.ts +0 -4
- package/lib/accordion/index.d.ts +0 -2
- package/lib/accordion-item/accordion-item.d.ts +0 -13
- package/lib/accordion-item/accordion-item.template.d.ts +0 -4
- package/lib/accordion-item/index.d.ts +0 -3
- package/lib/badge/badge.d.ts +0 -17
- package/lib/badge/badge.template.d.ts +0 -4
- package/lib/badge/index.d.ts +0 -3
- package/lib/banner/banner.d.ts +0 -20
- package/lib/banner/banner.template.d.ts +0 -6
- package/lib/banner/index.d.ts +0 -2
- package/lib/breadcrumb/breadcrumb.d.ts +0 -3
- package/lib/breadcrumb/index.d.ts +0 -2
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +0 -5
- package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +0 -4
- package/lib/breadcrumb-item/index.d.ts +0 -3
- package/lib/button/button.d.ts +0 -17
- package/lib/button/button.template.d.ts +0 -4
- package/lib/button/index.d.ts +0 -21
- package/lib/calendar/calendar.d.ts +0 -11
- package/lib/calendar/calendar.template.d.ts +0 -4
- package/lib/calendar/helpers/calendar.date-functions.d.ts +0 -2
- package/lib/calendar/helpers/calendar.event-context.d.ts +0 -6
- package/lib/calendar/helpers/calendar.keyboard-interactions.d.ts +0 -9
- package/lib/calendar/index.d.ts +0 -3
- package/lib/elevation/elevation.d.ts +0 -4
- package/lib/elevation/elevation.template.d.ts +0 -4
- package/lib/elevation/index.d.ts +0 -2
- package/lib/enums.d.ts +0 -45
- package/lib/focus/focus.d.ts +0 -3
- package/lib/focus/focus.template.d.ts +0 -4
- package/lib/focus/index.d.ts +0 -2
- package/lib/icon/icon.d.ts +0 -11
- package/lib/icon/icon.placeholder.d.ts +0 -1
- package/lib/icon/icon.template.d.ts +0 -4
- package/lib/icon/index.d.ts +0 -2
- package/lib/layout/index.d.ts +0 -2
- package/lib/layout/layout.d.ts +0 -16
- package/lib/layout/layout.template.d.ts +0 -4
- package/lib/popup/index.d.ts +0 -4
- package/lib/popup/popup.d.ts +0 -29
- package/lib/popup/popup.template.d.ts +0 -4
- package/lib/progress/index.d.ts +0 -2
- package/lib/progress/progress.d.ts +0 -9
- package/lib/progress/progress.template.d.ts +0 -5
- package/lib/progress-ring/index.d.ts +0 -2
- package/lib/progress-ring/progress-ring.d.ts +0 -6
- package/lib/progress-ring/progress-ring.template.d.ts +0 -4
- package/lib/side-drawer/index.d.ts +0 -2
- package/lib/side-drawer/side-drawer.d.ts +0 -12
- package/lib/side-drawer/side-drawer.template.d.ts +0 -4
- package/lib/sidenav-item/index.d.ts +0 -3
- package/lib/sidenav-item/sidenav-item.d.ts +0 -6
- package/lib/sidenav-item/sidenav-item.template.d.ts +0 -4
- package/lib/text/index.d.ts +0 -2
- package/lib/text/text.d.ts +0 -10
- package/lib/text/text.template.d.ts +0 -4
- package/lib/text-anchor/index.d.ts +0 -2
- package/lib/text-anchor/text-anchor.d.ts +0 -7
- package/lib/text-anchor/text-anchor.template.d.ts +0 -4
- package/lib/tooltip/index.d.ts +0 -3
- package/lib/tooltip/tooltip.d.ts +0 -10
- package/lib/tooltip/tooltip.template.d.ts +0 -4
- package/popup/index.js +0 -2087
- package/progress/index.js +0 -98
- package/progress-ring/index.js +0 -76
- package/shared/_has.js +0 -58
- package/shared/affix.js +0 -29
- package/shared/anchor.js +0 -78
- package/shared/apply-mixins.js +0 -22
- package/shared/aria-global.js +0 -156
- package/shared/base-progress.js +0 -65
- package/shared/breadcrumb-item.js +0 -25
- package/shared/class-names.js +0 -15
- package/shared/design-system/index.d.ts +0 -3
- package/shared/es.object.assign.js +0 -68
- package/shared/icon.js +0 -1393
- package/shared/index.js +0 -4991
- package/shared/index2.js +0 -21
- package/shared/patterns/affix.d.ts +0 -9
- package/shared/slotted.js +0 -119
- package/shared/style-inject.es.js +0 -28
- package/shared/text-anchor.js +0 -21
- package/shared/text-anchor.template.js +0 -54
- package/shared/web.dom-collections.iterator.js +0 -1479
- package/shared/when.js +0 -15
- package/side-drawer/index.js +0 -103
- package/sidenav-item/index.js +0 -38
- package/styles/fonts/spezia.css +0 -23
- package/styles/themes/dark.css +0 -193
- package/styles/themes/light.css +0 -193
- package/text/index.js +0 -45
- package/text-anchor/index.js +0 -19
- package/tooltip/index.js +0 -73
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# popup
|
|
2
|
+
|
|
3
|
+
Popup are used to display a message or notification to the user and are displayed on top of all other web page elements.
|
|
4
|
+
Popup's goal is to provide additional, helpful content. To trigger the Popup, it should be paired with an anchor (e.g., a button).
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
<script type='module'>
|
|
8
|
+
import '@vonage/vivid/popup';
|
|
9
|
+
</script>
|
|
10
|
+
```
|
|
11
|
+
## Anchor
|
|
12
|
+
|
|
13
|
+
Use the `anchor` attribute to reference the ID to element in the popup’s owner document.
|
|
14
|
+
|
|
15
|
+
The popup is positioned absolutely to its anchor. It is recommended to wrap it with a div element and set its position `relative`.
|
|
16
|
+
|
|
17
|
+
- Type: `string`
|
|
18
|
+
- Default: `''`
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
<div class="wrapper" style="position:relative;">
|
|
22
|
+
<vwc-button id="anchor"></vwc-button>
|
|
23
|
+
<vwc-popup anchor="anchor"></vwc-popup>
|
|
24
|
+
</div>
|
|
25
|
+
```
|
|
26
|
+
## Open
|
|
27
|
+
Use the `open` attribute to indicate whether the popup is open.
|
|
28
|
+
|
|
29
|
+
- Type: `boolean`
|
|
30
|
+
- Default: `false`
|
|
31
|
+
|
|
32
|
+
```html preview
|
|
33
|
+
<style>
|
|
34
|
+
.content {
|
|
35
|
+
width: 200px;
|
|
36
|
+
padding: 1rem;
|
|
37
|
+
}
|
|
38
|
+
.wrapper{
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 120px;
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
<div class="wrapper">
|
|
47
|
+
<vwc-button id="anchor1" appearance='outlined' label='Click on me!'></vwc-button>
|
|
48
|
+
<vwc-popup id="popup" anchor="anchor1" open>
|
|
49
|
+
<div class="content">
|
|
50
|
+
<vwc-text tight font-face="body-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</vwc-text>
|
|
51
|
+
</div>
|
|
52
|
+
</vwc-popup>
|
|
53
|
+
</div>
|
|
54
|
+
<script>
|
|
55
|
+
anchor1.addEventListener('click', toggleOpen);
|
|
56
|
+
function toggleOpen() {
|
|
57
|
+
popup.open = !popup.open;
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Dismissible
|
|
63
|
+
|
|
64
|
+
Add the `dismissible` attribute to add a close button to the popup.
|
|
65
|
+
|
|
66
|
+
- Type: `boolean`
|
|
67
|
+
- Default: `false`
|
|
68
|
+
|
|
69
|
+
```html preview
|
|
70
|
+
<style>
|
|
71
|
+
.content {
|
|
72
|
+
width: 120px;
|
|
73
|
+
padding: 1rem;
|
|
74
|
+
}
|
|
75
|
+
.wrapper{
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 120px;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
83
|
+
<div class="wrapper">
|
|
84
|
+
<vwc-button id="anchor2" appearance='outlined' label='Click on me!'></vwc-button>
|
|
85
|
+
<vwc-popup id="popup" anchor="anchor2" open dismissible>
|
|
86
|
+
<div class="content">
|
|
87
|
+
<vwc-text tight font-face="body-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</vwc-text>
|
|
88
|
+
</div>
|
|
89
|
+
</vwc-popup>
|
|
90
|
+
</div>
|
|
91
|
+
<script>
|
|
92
|
+
anchor2.addEventListener('click', toggleOpen);
|
|
93
|
+
function toggleOpen() {
|
|
94
|
+
popup.open = !popup.open;
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
## Arrow
|
|
99
|
+
Add the `arrow` attribute to add a small triangle to indicate the trigger element.
|
|
100
|
+
|
|
101
|
+
- Type: `boolean`
|
|
102
|
+
- Default: `false`
|
|
103
|
+
|
|
104
|
+
```html preview
|
|
105
|
+
<style>
|
|
106
|
+
.content {
|
|
107
|
+
width: 200px;
|
|
108
|
+
padding: 1rem;
|
|
109
|
+
}
|
|
110
|
+
.wrapper{
|
|
111
|
+
width: 100%;
|
|
112
|
+
height: 120px;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
}
|
|
117
|
+
</style>
|
|
118
|
+
<div class="wrapper">
|
|
119
|
+
<vwc-icon id="anchor3" type='info-line'></vwc-icon>
|
|
120
|
+
<vwc-popup anchor="anchor3" open arrow>
|
|
121
|
+
<div class="content">
|
|
122
|
+
<vwc-text tight font-face="body-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</vwc-text>
|
|
123
|
+
</div>
|
|
124
|
+
</vwc-popup>
|
|
125
|
+
</div>
|
|
126
|
+
```
|
|
127
|
+
## Alternate
|
|
128
|
+
Add the `alternate` attribute to set the color-scheme to dark or light (depending on current user's system settings).
|
|
129
|
+
|
|
130
|
+
- Type: `boolean`
|
|
131
|
+
- Default: `false`
|
|
132
|
+
|
|
133
|
+
```html preview
|
|
134
|
+
<style>
|
|
135
|
+
.content {
|
|
136
|
+
width: 200px;
|
|
137
|
+
padding: 1rem;
|
|
138
|
+
}
|
|
139
|
+
.wrapper{
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 120px;
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: center;
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
147
|
+
<div class="wrapper">
|
|
148
|
+
<vwc-icon id="anchor4" type='info-line'></vwc-icon>
|
|
149
|
+
<vwc-popup anchor="anchor4" open alternate>
|
|
150
|
+
<div class="content">
|
|
151
|
+
<vwc-text tight font-face="body-2">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</vwc-text>
|
|
152
|
+
</div>
|
|
153
|
+
</vwc-popup>
|
|
154
|
+
</div>
|
|
155
|
+
```
|
|
156
|
+
## Corner
|
|
157
|
+
|
|
158
|
+
Use the `corner` attribute to set the placement of the popup around the anchor.
|
|
159
|
+
|
|
160
|
+
- Type: `'top'` | `'top-start'` | `'top-end'` | `'right'` | `'right-start'` | `'right-end'` | `'bottom'` | `'bottom-start'` | `'bottom-end'`| `'left'` | `'left-start'`| `'left-end'`
|
|
161
|
+
- Default: `'left'`
|
|
162
|
+
|
|
163
|
+
```html preview
|
|
164
|
+
<style>
|
|
165
|
+
.contentWrapper{
|
|
166
|
+
width: 70px;
|
|
167
|
+
padding: 0.25rem;
|
|
168
|
+
}
|
|
169
|
+
.square {
|
|
170
|
+
height: 150px;
|
|
171
|
+
width: 300px;
|
|
172
|
+
background-color: var(--vvd-color-neutral-10);;
|
|
173
|
+
}
|
|
174
|
+
.wrapper{
|
|
175
|
+
width: 100%;
|
|
176
|
+
height: 250px;
|
|
177
|
+
display: flex;
|
|
178
|
+
align-items: center;
|
|
179
|
+
justify-content: center;
|
|
180
|
+
}
|
|
181
|
+
</style>
|
|
182
|
+
<div class="wrapper">
|
|
183
|
+
<div id="anchor5" class="square"></div>
|
|
184
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="right-end">
|
|
185
|
+
<div class="contentWrapper">
|
|
186
|
+
<vwc-text tight font-face="body-2">right-end</vwc-text>
|
|
187
|
+
</div>
|
|
188
|
+
</vwc-popup>
|
|
189
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="right">
|
|
190
|
+
<div class="contentWrapper">
|
|
191
|
+
<vwc-text tight font-face="body-2">right</vwc-text>
|
|
192
|
+
</div>
|
|
193
|
+
</vwc-popup>
|
|
194
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="right-start">
|
|
195
|
+
<div class="contentWrapper">
|
|
196
|
+
<vwc-text tight font-face="body-2">right-start</vwc-text>
|
|
197
|
+
</div>
|
|
198
|
+
</vwc-popup>
|
|
199
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="left-end">
|
|
200
|
+
<div class="contentWrapper">
|
|
201
|
+
<vwc-text tight font-face="body-2">left-end</vwc-text>
|
|
202
|
+
</div>
|
|
203
|
+
</vwc-popup>
|
|
204
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="left">
|
|
205
|
+
<div class="contentWrapper">
|
|
206
|
+
<vwc-text tight font-face="body-2">left</vwc-text>
|
|
207
|
+
</div>
|
|
208
|
+
</vwc-popup>
|
|
209
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="left-start">
|
|
210
|
+
<div class="contentWrapper">
|
|
211
|
+
<vwc-text tight font-face="body-2">left-start</vwc-text>
|
|
212
|
+
</div>
|
|
213
|
+
</vwc-popup>
|
|
214
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="top-end">
|
|
215
|
+
<div class="contentWrapper">
|
|
216
|
+
<vwc-text tight font-face="body-2">top-end</vwc-text>
|
|
217
|
+
</div>
|
|
218
|
+
</vwc-popup>
|
|
219
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="top">
|
|
220
|
+
<div class="contentWrapper">
|
|
221
|
+
<vwc-text tight font-face="body-2">top</vwc-text>
|
|
222
|
+
</div>
|
|
223
|
+
</vwc-popup>
|
|
224
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="top-start">
|
|
225
|
+
<div class="contentWrapper">
|
|
226
|
+
<vwc-text tight font-face="body-2">top-start</vwc-text>
|
|
227
|
+
</div>
|
|
228
|
+
</vwc-popup>
|
|
229
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="bottom-end">
|
|
230
|
+
<div class="contentWrapper">
|
|
231
|
+
<vwc-text tight font-face="body-2">bottom-end</vwc-text>
|
|
232
|
+
</div>
|
|
233
|
+
</vwc-popup>
|
|
234
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="bottom">
|
|
235
|
+
<div class="contentWrapper">
|
|
236
|
+
<vwc-text tight font-face="body-2">bottom</vwc-text>
|
|
237
|
+
</div>
|
|
238
|
+
</vwc-popup>
|
|
239
|
+
<vwc-popup id="popup" anchor="anchor5" open corner="bottom-start">
|
|
240
|
+
<div class="contentWrapper">
|
|
241
|
+
<vwc-text tight font-face="body-2">bottom-start</vwc-text>
|
|
242
|
+
</div>
|
|
243
|
+
</vwc-popup>
|
|
244
|
+
</div>
|
|
245
|
+
```
|
|
246
|
+
## Caveat
|
|
247
|
+
|
|
248
|
+
Document elements display precedence is formed by the imaginary z-axis [stacking context](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context), commonly by order of which elements are rendered and special properties (e.g. _z-index_).
|
|
249
|
+
Popup component is a low level element, unaware of its document context, but in most cases required to overlay on top of all elements.
|
|
250
|
+
|
|
251
|
+
A common practice used in apps / frameworks to promote a popup component to top other elements z-axis, is to utilise a service that dynamically appends a popup component to the end of the body element, when called for.
|
|
252
|
+
|
|
253
|
+
This helps ensure elements don't render over top a popup undesirebly.
|
|
254
|
+
|
|
255
|
+
## Methods
|
|
256
|
+
### updatePosition()
|
|
257
|
+
|
|
258
|
+
- Type: function
|
|
259
|
+
- Returns: void
|
|
260
|
+
|
|
261
|
+
Updates popup's position.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import '../elevation';
|
|
2
|
+
import '../button';
|
|
3
|
+
|
|
4
|
+
import type { FoundationElementDefinition } from '@microsoft/fast-foundation';
|
|
5
|
+
import { designSystem } from '../../shared/design-system';
|
|
6
|
+
import { Popup } from './popup';
|
|
7
|
+
import styles from './popup.scss';
|
|
8
|
+
import { popupTemplate as template } from './popup.template';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a popup custom element.
|
|
13
|
+
* popup is...
|
|
14
|
+
*/
|
|
15
|
+
export const VIVIDPopup = Popup.compose<FoundationElementDefinition>({
|
|
16
|
+
baseName: 'popup',
|
|
17
|
+
template: template as any,
|
|
18
|
+
styles,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
designSystem.register(VIVIDPopup());
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
$popup-bg: --vvd-color-surface-4dp;
|
|
2
|
+
|
|
3
|
+
.control {
|
|
4
|
+
width: min-content;
|
|
5
|
+
background-color: var(#{$popup-bg});
|
|
6
|
+
border-radius: inherit;
|
|
7
|
+
contain: layout;
|
|
8
|
+
|
|
9
|
+
&:not(.open) {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.popup-wrapper {
|
|
15
|
+
position: fixed;
|
|
16
|
+
border-radius: 6px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.popup-content {
|
|
20
|
+
display: grid;
|
|
21
|
+
color: var(--vvd-color-on-canvas);
|
|
22
|
+
|
|
23
|
+
.dismissible & {
|
|
24
|
+
align-content: start;
|
|
25
|
+
grid-template-columns: 1fr auto;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.arrow {
|
|
30
|
+
position: absolute;
|
|
31
|
+
z-index: -1;
|
|
32
|
+
width: 8px;
|
|
33
|
+
height: 8px;
|
|
34
|
+
background-color: var(#{$popup-bg});
|
|
35
|
+
transform: rotate(45deg);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dismissible {
|
|
39
|
+
align-self: flex-start;
|
|
40
|
+
margin-block-start: 0.25rem;
|
|
41
|
+
margin-inline-end: 0.25rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ADD_TEMPLATE_TO_FIXTURE,
|
|
3
|
+
elementUpdated,
|
|
4
|
+
fixture,
|
|
5
|
+
getControlElement
|
|
6
|
+
} from '@vivid-nx/shared';
|
|
7
|
+
import * as floatingUI from '@floating-ui/dom';
|
|
8
|
+
import type { Button } from '../button/button';
|
|
9
|
+
import { Popup } from './popup';
|
|
10
|
+
import '.';
|
|
11
|
+
|
|
12
|
+
const COMPONENT_TAG = 'vwc-popup';
|
|
13
|
+
|
|
14
|
+
describe('vwc-popup', () => {
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
async function setupPopupToOpenWithAnchor() {
|
|
19
|
+
const anchor = await setAnchor();
|
|
20
|
+
element.anchor = 'anchor';
|
|
21
|
+
await elementUpdated(element);
|
|
22
|
+
element.open = true;
|
|
23
|
+
return anchor;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let element: Popup;
|
|
27
|
+
|
|
28
|
+
beforeEach(async () => {
|
|
29
|
+
element = await fixture(`<${COMPONENT_TAG}></${COMPONENT_TAG}>`) as Popup;
|
|
30
|
+
global.ResizeObserver = jest.fn()
|
|
31
|
+
.mockImplementation(() => ({
|
|
32
|
+
observe: jest.fn(),
|
|
33
|
+
unobserve: jest.fn(),
|
|
34
|
+
disconnect: jest.fn()
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(function () {
|
|
39
|
+
jest.clearAllMocks();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('clean observable', () => {
|
|
43
|
+
it('should clean observable on disconnectedCallback', async function () {
|
|
44
|
+
const cleanupMock = jest.fn();
|
|
45
|
+
jest.spyOn(floatingUI, 'autoUpdate').mockReturnValue(cleanupMock);
|
|
46
|
+
await setupPopupToOpenWithAnchor();
|
|
47
|
+
element.disconnectedCallback();
|
|
48
|
+
expect(cleanupMock).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should clean observable when anchor is undefined', async function () {
|
|
52
|
+
const cleanupMock = jest.fn();
|
|
53
|
+
jest.spyOn(floatingUI, 'autoUpdate').mockReturnValue(cleanupMock);
|
|
54
|
+
await setupPopupToOpenWithAnchor();
|
|
55
|
+
element.anchor = '';
|
|
56
|
+
await elementUpdated(element);
|
|
57
|
+
expect(cleanupMock).toHaveBeenCalled();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('viewport visibility transition', function () {
|
|
62
|
+
|
|
63
|
+
const computePositionResult = {
|
|
64
|
+
'x': -15,
|
|
65
|
+
'y': 0,
|
|
66
|
+
'placement': 'left',
|
|
67
|
+
'strategy': 'fixed',
|
|
68
|
+
'middlewareData': {
|
|
69
|
+
'flip': {},
|
|
70
|
+
'hide': {
|
|
71
|
+
'referenceHiddenOffsets': {
|
|
72
|
+
'top': 0,
|
|
73
|
+
'right': 0,
|
|
74
|
+
'bottom': 0,
|
|
75
|
+
'left': 0
|
|
76
|
+
},
|
|
77
|
+
'referenceHidden': true
|
|
78
|
+
},
|
|
79
|
+
'inline': {},
|
|
80
|
+
'arrow': {
|
|
81
|
+
'y': 0,
|
|
82
|
+
'centerOffset': 0
|
|
83
|
+
},
|
|
84
|
+
'offset': {
|
|
85
|
+
'x': -12,
|
|
86
|
+
'y': 0
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
beforeEach(function () {
|
|
92
|
+
jest.spyOn(floatingUI, 'computePosition');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
afterEach(function () {
|
|
96
|
+
(floatingUI.computePosition as jest.MockedFunction<any>).mockRestore();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param hidden
|
|
101
|
+
*/
|
|
102
|
+
async function makePopupHidden(hidden = true) {
|
|
103
|
+
computePositionResult.middlewareData.hide.referenceHidden = hidden;
|
|
104
|
+
(floatingUI.computePosition as jest.MockedFunction<any>).mockReturnValue(Promise.resolve(computePositionResult));
|
|
105
|
+
await element.updatePosition();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
it('should be hidden when not in viewport', async function () {
|
|
109
|
+
await setupPopupToOpenWithAnchor();
|
|
110
|
+
await makePopupHidden(true);
|
|
111
|
+
|
|
112
|
+
expect(element.popupEl.style.visibility)
|
|
113
|
+
.toEqual('hidden');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should be hidden when not in viewport', async function () {
|
|
117
|
+
await setupPopupToOpenWithAnchor();
|
|
118
|
+
await makePopupHidden(false);
|
|
119
|
+
expect(element.popupEl.style.visibility)
|
|
120
|
+
.toEqual('visible');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('basic', () => {
|
|
125
|
+
it('initializes as a vwc-popup', async () => {
|
|
126
|
+
expect(element)
|
|
127
|
+
.toBeInstanceOf(Popup);
|
|
128
|
+
expect(element.open)
|
|
129
|
+
.toBeFalsy();
|
|
130
|
+
expect(element.arrow)
|
|
131
|
+
.toBeFalsy();
|
|
132
|
+
expect(element.dismissible)
|
|
133
|
+
.toBeFalsy();
|
|
134
|
+
expect(element.anchor)
|
|
135
|
+
.toBeUndefined();
|
|
136
|
+
expect(element.corner)
|
|
137
|
+
.toEqual('left');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe('show', () => {
|
|
142
|
+
it('should set "open" to true', async () => {
|
|
143
|
+
await setAnchor();
|
|
144
|
+
element.anchor = 'anchor';
|
|
145
|
+
await elementUpdated(element);
|
|
146
|
+
|
|
147
|
+
element.open = true;
|
|
148
|
+
element.updatePosition();
|
|
149
|
+
await elementUpdated(element);
|
|
150
|
+
|
|
151
|
+
expect(element.open)
|
|
152
|
+
.toEqual(true);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('hide', () => {
|
|
157
|
+
it('should set "open" to false', async () => {
|
|
158
|
+
element.open = true;
|
|
159
|
+
|
|
160
|
+
element.open = false;
|
|
161
|
+
element.updatePosition();
|
|
162
|
+
await elementUpdated(element);
|
|
163
|
+
|
|
164
|
+
expect(element.open)
|
|
165
|
+
.toEqual(false);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('render arrow', () => {
|
|
170
|
+
it('should remove the arrow class on the container if arrow is false', async () => {
|
|
171
|
+
expect(element.shadowRoot?.querySelector('.arrow'))
|
|
172
|
+
.toBeNull();
|
|
173
|
+
});
|
|
174
|
+
it('should set the arrow class on the container if arrow is true', async () => {
|
|
175
|
+
element.arrow = true;
|
|
176
|
+
element.open = true;
|
|
177
|
+
await elementUpdated(element);
|
|
178
|
+
|
|
179
|
+
await setAnchor();
|
|
180
|
+
element.anchor = 'anchor';
|
|
181
|
+
await elementUpdated(element);
|
|
182
|
+
|
|
183
|
+
element.arrowEl = element.shadowRoot?.querySelector('.arrow') as HTMLElement;
|
|
184
|
+
element.updatePosition();
|
|
185
|
+
await elementUpdated(element);
|
|
186
|
+
|
|
187
|
+
expect(element.shadowRoot?.querySelector('.arrow'))
|
|
188
|
+
.not
|
|
189
|
+
.toBeNull();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('render dismiss', () => {
|
|
194
|
+
it('should remove the dismiss class on the container if dismissible is false', async () => {
|
|
195
|
+
expect(element.shadowRoot?.querySelector('.dismissible'))
|
|
196
|
+
.toBeNull();
|
|
197
|
+
});
|
|
198
|
+
it('should set the dismiss class on the container if dismissible is true', async () => {
|
|
199
|
+
element.dismissible = true;
|
|
200
|
+
|
|
201
|
+
await elementUpdated(element);
|
|
202
|
+
expect(element.shadowRoot?.querySelector('.dismissible'))
|
|
203
|
+
.not
|
|
204
|
+
.toBeNull();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('handle dismiss', () => {
|
|
209
|
+
it('should hide when dismiss button is clicked', async () => {
|
|
210
|
+
await setAnchor();
|
|
211
|
+
element.anchor = 'anchor';
|
|
212
|
+
element.dismissible = true;
|
|
213
|
+
await elementUpdated(element);
|
|
214
|
+
|
|
215
|
+
element.open = true;
|
|
216
|
+
expect(element.open)
|
|
217
|
+
.toEqual(true);
|
|
218
|
+
|
|
219
|
+
await elementUpdated(element);
|
|
220
|
+
const dismissButton = element.shadowRoot?.querySelector('vwc-button');
|
|
221
|
+
(dismissButton as HTMLElement).click();
|
|
222
|
+
await elementUpdated(element);
|
|
223
|
+
|
|
224
|
+
expect(element.open)
|
|
225
|
+
.toEqual(false);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe('alternate', () => {
|
|
230
|
+
it('should set to alternate', async () => {
|
|
231
|
+
expect(getControlElement(element)
|
|
232
|
+
.getAttribute('part'))
|
|
233
|
+
.toEqual('');
|
|
234
|
+
element.alternate = true;
|
|
235
|
+
|
|
236
|
+
await elementUpdated(element);
|
|
237
|
+
expect(getControlElement(element)
|
|
238
|
+
.getAttribute('part'))
|
|
239
|
+
.toEqual('vvd-theme-alternate');
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe('accessibility', () => {
|
|
244
|
+
it('should set aria-hidden', async () => {
|
|
245
|
+
expect(getControlElement(element)
|
|
246
|
+
.getAttribute('aria-hidden'))
|
|
247
|
+
.toEqual('true');
|
|
248
|
+
element.open = true;
|
|
249
|
+
|
|
250
|
+
await elementUpdated(element);
|
|
251
|
+
expect(getControlElement(element)
|
|
252
|
+
.getAttribute('aria-hidden'))
|
|
253
|
+
.toEqual('false');
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
*
|
|
259
|
+
*/
|
|
260
|
+
async function setAnchor() {
|
|
261
|
+
const anchorEl = await fixture('<vwc-button id="anchor"></vwc-button>', ADD_TEMPLATE_TO_FIXTURE) as Button;
|
|
262
|
+
await elementUpdated(anchorEl);
|
|
263
|
+
return anchorEl;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { html, ref, when } from '@microsoft/fast-element';
|
|
2
|
+
import { classNames } from '@microsoft/fast-web-utilities';
|
|
3
|
+
import type { ViewTemplate } from '@microsoft/fast-element';
|
|
4
|
+
import type { ElementDefinitionContext, FoundationElementDefinition } from '@microsoft/fast-foundation';
|
|
5
|
+
import type { Popup } from './popup';
|
|
6
|
+
|
|
7
|
+
const getClasses = ({
|
|
8
|
+
open, dismissible, alternate
|
|
9
|
+
}: Popup) => classNames(
|
|
10
|
+
'control',
|
|
11
|
+
['open', Boolean(open)],
|
|
12
|
+
['dismissible', Boolean(dismissible)],
|
|
13
|
+
['alternate', Boolean(alternate)]
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The template for the {@link @vonage/vivid#Popup} component.
|
|
18
|
+
*
|
|
19
|
+
* @returns {ViewTemplate<Popup>} A template capable of creating HTMLView instances or rendering directly to DOM.
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export const popupTemplate: (
|
|
23
|
+
context: ElementDefinitionContext,
|
|
24
|
+
definition: FoundationElementDefinition
|
|
25
|
+
) => ViewTemplate<Popup> = () => html`
|
|
26
|
+
<vwc-elevation>
|
|
27
|
+
<!--the popup-wrapper is needed for alternating the inside of the popup nd not its shadow-->
|
|
28
|
+
<div class="popup-wrapper" ${ref('popupEl')}>
|
|
29
|
+
<div class="${getClasses}" aria-hidden="${(x) => x.open ? 'false' : 'true'}"
|
|
30
|
+
part="${(x) => x.alternate ? 'vvd-theme-alternate' : ''}">
|
|
31
|
+
<div class="popup-content">
|
|
32
|
+
<slot></slot>
|
|
33
|
+
${when(x => x.dismissible,
|
|
34
|
+
html<Popup>`<vwc-button size="base-small" @click="${x => (x.open = false)}"
|
|
35
|
+
class="dismissible" icon="close-small-solid" shape="pill"></vwc-button>`)}
|
|
36
|
+
</div>
|
|
37
|
+
${when(x => x.arrow,
|
|
38
|
+
html<Popup>`<div class="arrow" ${ref('arrowEl')}></div>`)}
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</vwc-elevation>`;
|