@mcp-b/web-components 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/accordion-B1Q3kuP_.d.ts +373 -0
- package/dist/accordion-item-DvPfhpm8.js +307 -0
- package/dist/accordion-item-bPRIahNn.d.ts +63 -0
- package/dist/accordion-zDr-Br4V.js +483 -0
- package/dist/action-bar-CYsjmhwP.d.ts +29 -0
- package/dist/action-bar-CjN_UcnP.js +56 -0
- package/dist/alert-dialog-4CnO3Nb5.d.ts +60 -0
- package/dist/alert-dialog-D25Oi_TS.js +126 -0
- package/dist/avatar-Bje_KpZo.d.ts +141 -0
- package/dist/avatar-CRP0kW3x.js +224 -0
- package/dist/badge-Ct95U4UO.js +301 -0
- package/dist/badge-D1DNQrWn.d.ts +106 -0
- package/dist/breadcrumb-BxZ-nQE5.d.ts +365 -0
- package/dist/breadcrumb-item-BC454oQe.d.ts +59 -0
- package/dist/breadcrumb-item-P5pdq_gE.js +151 -0
- package/dist/breadcrumb-uURhiqWJ.js +384 -0
- package/dist/button-5k_aL_gD.js +802 -0
- package/dist/button-BQofnUt4.d.ts +354 -0
- package/dist/button-group-BydvJTQy.js +197 -0
- package/dist/button-group-COodHeuB.d.ts +155 -0
- package/dist/callout-B8zTf8Go.js +188 -0
- package/dist/callout-DFwPao36.d.ts +103 -0
- package/dist/card-BYDzdMAU.d.ts +177 -0
- package/dist/card-DIg1-X2G.js +332 -0
- package/dist/carousel-Bktu7wrD.js +843 -0
- package/dist/carousel-DQITCtEY.d.ts +423 -0
- package/dist/carousel-item-B5-X31Ha.js +79 -0
- package/dist/carousel-item-BB3jL2tk.d.ts +34 -0
- package/dist/cdn/loader.js +530 -0
- package/dist/checkbox-D6r7PVPj.js +641 -0
- package/dist/checkbox-DoFcDEKB.d.ts +354 -0
- package/dist/checkbox-group-CLvNAO_F.js +201 -0
- package/dist/checkbox-group-Cnh8rAn4.d.ts +152 -0
- package/dist/color-input-Bky89xg_.d.ts +470 -0
- package/dist/color-input-DPIxi9wR.js +894 -0
- package/dist/color-picker-adwOmtRl.js +1240 -0
- package/dist/color-picker-wQw8bPsq.d.ts +360 -0
- package/dist/combobox-B6al50UG.js +1693 -0
- package/dist/combobox-item-D2H1CMxC.d.ts +714 -0
- package/dist/combobox-item-yM6tDrGG.js +225 -0
- package/dist/comparison-B1-nMwmp.d.ts +134 -0
- package/dist/comparison-CyqKrCN-.js +435 -0
- package/dist/components/accordion/accordion.d.ts +2 -0
- package/dist/components/accordion/accordion.js +2 -0
- package/dist/components/accordion-item/accordion-item.d.ts +2 -0
- package/dist/components/accordion-item/accordion-item.js +2 -0
- package/dist/components/action-bar/action-bar.d.ts +2 -0
- package/dist/components/action-bar/action-bar.js +2 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +2 -0
- package/dist/components/alert-dialog/alert-dialog.js +2 -0
- package/dist/components/avatar/avatar.d.ts +2 -0
- package/dist/components/avatar/avatar.js +2 -0
- package/dist/components/badge/badge.d.ts +2 -0
- package/dist/components/badge/badge.js +2 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.js +2 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.d.ts +2 -0
- package/dist/components/breadcrumb-item/breadcrumb-item.js +2 -0
- package/dist/components/button/button.d.ts +2 -0
- package/dist/components/button/button.js +2 -0
- package/dist/components/button-group/button-group.d.ts +2 -0
- package/dist/components/button-group/button-group.js +2 -0
- package/dist/components/callout/callout.d.ts +2 -0
- package/dist/components/callout/callout.js +2 -0
- package/dist/components/card/card.d.ts +2 -0
- package/dist/components/card/card.js +2 -0
- package/dist/components/carousel/carousel.d.ts +2 -0
- package/dist/components/carousel/carousel.js +2 -0
- package/dist/components/carousel-item/carousel-item.d.ts +2 -0
- package/dist/components/carousel-item/carousel-item.js +2 -0
- package/dist/components/checkbox/checkbox.d.ts +2 -0
- package/dist/components/checkbox/checkbox.js +2 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +2 -0
- package/dist/components/checkbox-group/checkbox-group.js +2 -0
- package/dist/components/color-input/color-input.d.ts +2 -0
- package/dist/components/color-input/color-input.js +2 -0
- package/dist/components/color-picker/color-picker.d.ts +2 -0
- package/dist/components/color-picker/color-picker.js +2 -0
- package/dist/components/combobox/combobox.d.ts +2 -0
- package/dist/components/combobox/combobox.js +2 -0
- package/dist/components/combobox-item/combobox-item.d.ts +2 -0
- package/dist/components/combobox-item/combobox-item.js +2 -0
- package/dist/components/comparison/comparison.d.ts +2 -0
- package/dist/components/comparison/comparison.js +2 -0
- package/dist/components/copy/copy.d.ts +2 -0
- package/dist/components/copy/copy.js +291 -0
- package/dist/components/data-table/data-table.d.ts +2 -0
- package/dist/components/data-table/data-table.js +2 -0
- package/dist/components/date/date.d.ts +2 -0
- package/dist/components/date/date.js +2 -0
- package/dist/components/dialog/dialog.d.ts +2 -0
- package/dist/components/dialog/dialog.js +2 -0
- package/dist/components/divider/divider.d.ts +2 -0
- package/dist/components/divider/divider.js +2 -0
- package/dist/components/dropdown/dropdown.d.ts +2 -0
- package/dist/components/dropdown/dropdown.js +2 -0
- package/dist/components/dropdown-item/dropdown-item.d.ts +2 -0
- package/dist/components/dropdown-item/dropdown-item.js +2 -0
- package/dist/components/empty-result/empty-result.d.ts +2 -0
- package/dist/components/empty-result/empty-result.js +2 -0
- package/dist/components/empty-state/empty-state.d.ts +2 -0
- package/dist/components/empty-state/empty-state.js +2 -0
- package/dist/components/expander/expander.d.ts +2 -0
- package/dist/components/expander/expander.js +2 -0
- package/dist/components/field/field.d.ts +2 -0
- package/dist/components/field/field.js +2 -0
- package/dist/components/file-input/file-input.d.ts +2 -0
- package/dist/components/file-input/file-input.js +2 -0
- package/dist/components/filter-bar/filter-bar.d.ts +2 -0
- package/dist/components/filter-bar/filter-bar.js +2 -0
- package/dist/components/form-section/form-section.d.ts +2 -0
- package/dist/components/form-section/form-section.js +2 -0
- package/dist/components/icon/icon.d.ts +2 -0
- package/dist/components/icon/icon.js +2 -0
- package/dist/components/include/include.d.ts +2 -0
- package/dist/components/include/include.js +2 -0
- package/dist/components/index.d.ts +85 -0
- package/dist/components/index.js +86 -0
- package/dist/components/infinite-scroller/infinite-scroller.d.ts +2 -0
- package/dist/components/infinite-scroller/infinite-scroller.js +2 -0
- package/dist/components/intersection-observer/intersection-observer.d.ts +2 -0
- package/dist/components/intersection-observer/intersection-observer.js +2 -0
- package/dist/components/listbox/listbox.d.ts +2 -0
- package/dist/components/listbox/listbox.js +2 -0
- package/dist/components/listbox-item/listbox-item.d.ts +2 -0
- package/dist/components/listbox-item/listbox-item.js +2 -0
- package/dist/components/lorem-ipsum/lorem-ipsum.d.ts +2 -0
- package/dist/components/lorem-ipsum/lorem-ipsum.js +2 -0
- package/dist/components/meter/meter.d.ts +2 -0
- package/dist/components/meter/meter.js +2 -0
- package/dist/components/metric/metric.d.ts +2 -0
- package/dist/components/metric/metric.js +2 -0
- package/dist/components/metric-grid/metric-grid.d.ts +2 -0
- package/dist/components/metric-grid/metric-grid.js +2 -0
- package/dist/components/mutation-observer/mutation-observer.d.ts +2 -0
- package/dist/components/mutation-observer/mutation-observer.js +2 -0
- package/dist/components/navicon/navicon.d.ts +2 -0
- package/dist/components/navicon/navicon.js +2 -0
- package/dist/components/number/number.d.ts +2 -0
- package/dist/components/number/number.js +2 -0
- package/dist/components/number-field/number-field.d.ts +2 -0
- package/dist/components/number-field/number-field.js +2 -0
- package/dist/components/pagination/pagination.d.ts +2 -0
- package/dist/components/pagination/pagination.js +2 -0
- package/dist/components/popover/popover.d.ts +2 -0
- package/dist/components/popover/popover.js +2 -0
- package/dist/components/preview-card/preview-card.d.ts +2 -0
- package/dist/components/preview-card/preview-card.js +2 -0
- package/dist/components/progress/progress.d.ts +2 -0
- package/dist/components/progress/progress.js +2 -0
- package/dist/components/radio/radio.d.ts +2 -0
- package/dist/components/radio/radio.js +2 -0
- package/dist/components/radio-item/radio-item.d.ts +2 -0
- package/dist/components/radio-item/radio-item.js +2 -0
- package/dist/components/random-content/random-content.d.ts +2 -0
- package/dist/components/random-content/random-content.js +2 -0
- package/dist/components/rating/rating.d.ts +2 -0
- package/dist/components/rating/rating.js +2 -0
- package/dist/components/resize-observer/resize-observer.d.ts +2 -0
- package/dist/components/resize-observer/resize-observer.js +2 -0
- package/dist/components/scroll-area/scroll-area.d.ts +2 -0
- package/dist/components/scroll-area/scroll-area.js +2 -0
- package/dist/components/scroller/scroller.d.ts +2 -0
- package/dist/components/scroller/scroller.js +2 -0
- package/dist/components/search-list/search-list.d.ts +2 -0
- package/dist/components/search-list/search-list.js +2 -0
- package/dist/components/select/select.d.ts +2 -0
- package/dist/components/select/select.js +2 -0
- package/dist/components/selection-summary/selection-summary.d.ts +2 -0
- package/dist/components/selection-summary/selection-summary.js +2 -0
- package/dist/components/share/share.d.ts +2 -0
- package/dist/components/share/share.js +2 -0
- package/dist/components/slide-activator/slide-activator.d.ts +2 -0
- package/dist/components/slide-activator/slide-activator.js +2 -0
- package/dist/components/slider/slider.d.ts +2 -0
- package/dist/components/slider/slider.js +2 -0
- package/dist/components/sparkline/sparkline.d.ts +2 -0
- package/dist/components/sparkline/sparkline.js +2 -0
- package/dist/components/spinner/spinner.d.ts +2 -0
- package/dist/components/spinner/spinner.js +2 -0
- package/dist/components/splitter/splitter.d.ts +2 -0
- package/dist/components/splitter/splitter.js +2 -0
- package/dist/components/switch/switch.d.ts +2 -0
- package/dist/components/switch/switch.js +2 -0
- package/dist/components/tab/tab.d.ts +2 -0
- package/dist/components/tab/tab.js +2 -0
- package/dist/components/tab-list/tab-list.d.ts +2 -0
- package/dist/components/tab-list/tab-list.js +2 -0
- package/dist/components/tab-panel/tab-panel.d.ts +2 -0
- package/dist/components/tab-panel/tab-panel.js +2 -0
- package/dist/components/text-area/text-area.d.ts +2 -0
- package/dist/components/text-area/text-area.js +2 -0
- package/dist/components/text-field/text-field.d.ts +2 -0
- package/dist/components/text-field/text-field.js +2 -0
- package/dist/components/text-mask/text-mask.d.ts +2 -0
- package/dist/components/text-mask/text-mask.js +2 -0
- package/dist/components/timed-content/timed-content.d.ts +2 -0
- package/dist/components/timed-content/timed-content.js +2 -0
- package/dist/components/toast/toast.d.ts +2 -0
- package/dist/components/toast/toast.js +2 -0
- package/dist/components/toast-item/toast-item.d.ts +2 -0
- package/dist/components/toast-item/toast-item.js +2 -0
- package/dist/components/toggle-icon/toggle-icon.d.ts +2 -0
- package/dist/components/toggle-icon/toggle-icon.js +2 -0
- package/dist/components/toggle-tag/toggle-tag.d.ts +2 -0
- package/dist/components/toggle-tag/toggle-tag.js +2 -0
- package/dist/components/toolbar/toolbar.d.ts +2 -0
- package/dist/components/toolbar/toolbar.js +2 -0
- package/dist/components/tooltip/tooltip.d.ts +2 -0
- package/dist/components/tooltip/tooltip.js +2 -0
- package/dist/components/transition-group/transition-group.d.ts +2 -0
- package/dist/components/transition-group/transition-group.js +2 -0
- package/dist/components/zoomable-frame/zoomable-frame.d.ts +2 -0
- package/dist/components/zoomable-frame/zoomable-frame.js +2 -0
- package/dist/copy-CvC9vaGw.d.ts +206 -0
- package/dist/copy.styles-DWGvGNTP.js +100 -0
- package/dist/data-table-CITa8DSn.js +247 -0
- package/dist/data-table-DL5RhE0d.d.ts +89 -0
- package/dist/date-CJPmOdi9.js +146 -0
- package/dist/date-DtaTBM71.d.ts +142 -0
- package/dist/decorate-DcF3lt7P.js +9 -0
- package/dist/dialog-Cx46HMaZ.js +983 -0
- package/dist/dialog-N-v0woIy.d.ts +414 -0
- package/dist/divider-9vNsfHW8.js +169 -0
- package/dist/divider-DWuAxcXv.d.ts +79 -0
- package/dist/docs/custom-elements.json +29301 -0
- package/dist/dropdown-BXSKpVX9.js +1123 -0
- package/dist/dropdown-Bo00Vlr5.d.ts +537 -0
- package/dist/dropdown-item-_lIs-Tfd.d.ts +111 -0
- package/dist/dropdown-item-i77cRuN6.js +504 -0
- package/dist/empty-result-B2ln1yFL.js +65 -0
- package/dist/empty-result-B54x_Ab2.d.ts +31 -0
- package/dist/empty-state-BLWjtKUo.js +186 -0
- package/dist/empty-state-SGKjpwp3.d.ts +117 -0
- package/dist/expander-BUev0BmM.d.ts +174 -0
- package/dist/expander-Bwvxj6Oa.js +342 -0
- package/dist/field-BEyS909F.js +163 -0
- package/dist/field-ITx0jVw-.d.ts +69 -0
- package/dist/file-input-BEumLJjg.js +841 -0
- package/dist/file-input-D2D6YC0B.d.ts +378 -0
- package/dist/filter-bar-Bj2QzEn9.d.ts +35 -0
- package/dist/filter-bar-Dcs67aXo.js +66 -0
- package/dist/form-section-BchPetkj.js +83 -0
- package/dist/form-section-xFBTBULQ.d.ts +34 -0
- package/dist/icon-BPVkNsY4.js +165 -0
- package/dist/icon-Ci9CPZJV.d.ts +72 -0
- package/dist/icon-library-D_if7p2h.d.ts +2 -0
- package/dist/include-CQHVVtNs.d.ts +103 -0
- package/dist/include-qNUh_6kT.js +155 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +92 -0
- package/dist/infinite-scroller-BmmtnWNt.js +285 -0
- package/dist/infinite-scroller-CuUEAlB9.d.ts +174 -0
- package/dist/intersection-observer-B6TciOAQ.js +503 -0
- package/dist/intersection-observer-B7nmP7Zz.d.ts +418 -0
- package/dist/listbox-C3XXRWGX.js +1257 -0
- package/dist/listbox-DD4ujIJe.d.ts +682 -0
- package/dist/listbox-item-CwD9s3VY.js +135 -0
- package/dist/listbox-item-DQEJWp4Z.d.ts +53 -0
- package/dist/localize-322EtXNX.d.ts +66 -0
- package/dist/lorem-ipsum-B2x3V-v8.js +198 -0
- package/dist/lorem-ipsum-CR82CSuJ.d.ts +130 -0
- package/dist/meter-BC7uaJWf.d.ts +73 -0
- package/dist/meter-BIDyjwFp.js +155 -0
- package/dist/metric-CjlLq_VA.d.ts +36 -0
- package/dist/metric-DbuOcDp_.js +86 -0
- package/dist/metric-grid-C2Pb0Zl3.js +37 -0
- package/dist/metric-grid-C5Xbb1_0.d.ts +27 -0
- package/dist/mutation-observer-BmrZ-GER.d.ts +326 -0
- package/dist/mutation-observer-DS8EBuOp.js +388 -0
- package/dist/navicon-Dic5Qjzb.d.ts +159 -0
- package/dist/navicon-_yMHY27-.js +486 -0
- package/dist/number-BNtNXNF3.js +162 -0
- package/dist/number-BwbnErlB.d.ts +143 -0
- package/dist/number-field-BQHB7UYo.js +726 -0
- package/dist/number-field-odk4lKXM.d.ts +422 -0
- package/dist/pagination-6z2qcf3U.d.ts +322 -0
- package/dist/pagination-DuKPuzdb.js +679 -0
- package/dist/popover-D0sxTU6o.d.ts +259 -0
- package/dist/popover-DJBrJ0za.js +556 -0
- package/dist/preview-card-C7H1FPfd.js +287 -0
- package/dist/preview-card-DitOCZTD.d.ts +86 -0
- package/dist/progress-Db0_axHQ.d.ts +181 -0
- package/dist/progress-DzVk260j.js +494 -0
- package/dist/radio-BtDG9xJM.js +658 -0
- package/dist/radio-CieMa4zU.d.ts +460 -0
- package/dist/radio-item-DIrUStAX.js +264 -0
- package/dist/radio-item-Xq2U3cMu.d.ts +69 -0
- package/dist/random-content-BhSeJFKz.d.ts +380 -0
- package/dist/random-content-BwiirXdG.js +450 -0
- package/dist/rating-4xNsWumY.d.ts +369 -0
- package/dist/rating-C1BcJDIO.js +722 -0
- package/dist/resize-observer-BseSbVWP.d.ts +187 -0
- package/dist/resize-observer-DcrLhddo.js +236 -0
- package/dist/scroll-area-COc1857S.js +127 -0
- package/dist/scroll-area-CVYDf5qY.d.ts +61 -0
- package/dist/scroller-LYgBVyfY.js +590 -0
- package/dist/scroller-bB2rGs7b.d.ts +374 -0
- package/dist/search-list-Clmrg8EV.js +884 -0
- package/dist/search-list-n0GYO7rh.d.ts +777 -0
- package/dist/select-CkZK2jJn.d.ts +506 -0
- package/dist/select-DLIaRnA4.js +690 -0
- package/dist/selection-summary-BVnNJ8Lw.js +48 -0
- package/dist/selection-summary-DmFkGyZI.d.ts +34 -0
- package/dist/share-DPlqP2dc.d.ts +162 -0
- package/dist/share-bsgXZCl7.js +250 -0
- package/dist/sigvelo.d.ts +5 -0
- package/dist/sigvelo.js +5 -0
- package/dist/sigvelo.loader.d.ts +3 -0
- package/dist/sigvelo.loader.js +102 -0
- package/dist/slide-activator-D7bBz69E.d.ts +429 -0
- package/dist/slide-activator-DlxQt9R9.js +798 -0
- package/dist/slider-B0FVsV1o.d.ts +921 -0
- package/dist/slider-B90Il7x3.js +1744 -0
- package/dist/sparkline-CcpTaJ_Z.js +358 -0
- package/dist/sparkline-DlCIt81-.d.ts +235 -0
- package/dist/spinner-C04Dmc0H.js +188 -0
- package/dist/spinner-CZ19x_dC.d.ts +99 -0
- package/dist/splitter-DBDJAzsp.d.ts +325 -0
- package/dist/splitter-MnD4In9H.js +638 -0
- package/dist/switch-CPaEKbog.js +581 -0
- package/dist/switch-Cief9M59.d.ts +248 -0
- package/dist/tab-BcqYGsuW.d.ts +44 -0
- package/dist/tab-C-FtuNmh.js +102 -0
- package/dist/tab-list-B_Ye_Oj9.js +691 -0
- package/dist/tab-list-DDvS8qHr.d.ts +450 -0
- package/dist/tab-panel-BaBl6eep.js +60 -0
- package/dist/tab-panel-BzSJlSfd.d.ts +38 -0
- package/dist/text-area-B_mjCE9W.d.ts +327 -0
- package/dist/text-area-Czixaz-_.js +556 -0
- package/dist/text-field-BClWMp6q.d.ts +424 -0
- package/dist/text-field-inpJfp0A.js +687 -0
- package/dist/text-mask-CNKVKSFp.d.ts +336 -0
- package/dist/text-mask-DDEurj90.js +370 -0
- package/dist/themes/sigvelo.css +10 -0
- package/dist/themes/utilities.css +9 -0
- package/dist/timed-content-D2mGFamc.d.ts +181 -0
- package/dist/timed-content-pvEP4l5V.js +226 -0
- package/dist/toast-BnZaIg6Z.js +636 -0
- package/dist/toast-cEBVK9NQ.d.ts +487 -0
- package/dist/toast-item-BPpJT6vD.d.ts +159 -0
- package/dist/toast-item-IS8IFUEg.js +372 -0
- package/dist/toggle-icon-4oLDeEt4.js +752 -0
- package/dist/toggle-icon-DlwMMWZL.d.ts +359 -0
- package/dist/toggle-tag-1sfTFJtg.js +434 -0
- package/dist/toggle-tag-IVvMGT4R.d.ts +245 -0
- package/dist/toolbar-CABq0ZL1.d.ts +122 -0
- package/dist/toolbar-CEZ0-F-X.js +196 -0
- package/dist/tooltip-DbyoPFNe.js +521 -0
- package/dist/tooltip-ahFthek8.d.ts +192 -0
- package/dist/transition-group-3hnAnwSd.js +801 -0
- package/dist/transition-group-DD_CjSNC.d.ts +608 -0
- package/dist/translations/en.d.ts +6 -0
- package/dist/translations/en.js +75 -0
- package/dist/translations/es.d.ts +6 -0
- package/dist/translations/es.js +75 -0
- package/dist/types/custom-element-jsx.d.ts +13723 -0
- package/dist/utilities/icon-library.d.ts +3 -0
- package/dist/utilities/icon-library.js +93 -0
- package/dist/utilities/localize.d.ts +2 -0
- package/dist/utilities/localize.js +6 -0
- package/dist/zoomable-frame-Cldvj5sE.js +398 -0
- package/dist/zoomable-frame-r6S6587z.d.ts +162 -0
- package/package.json +83 -0
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
+
import { css, html } from "lit";
|
|
3
|
+
import { property, query } from "lit/decorators.js";
|
|
4
|
+
import hostStyles from "@mcp-b/wc-support/styles/host.styles";
|
|
5
|
+
import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
6
|
+
import { animateWithClass } from "@mcp-b/wc-support/utilities/animate";
|
|
7
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
8
|
+
import { SigveloBeforeCloseEvent, SigveloBeforeOpenEvent, SigveloCloseEvent, SigveloOpenEvent } from "@mcp-b/wc-support/events/open-close";
|
|
9
|
+
import { stripElementPrefix } from "@mcp-b/wc-support/prefix";
|
|
10
|
+
import { arrow, autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
11
|
+
import { createId } from "@mcp-b/wc-support/utilities/math";
|
|
12
|
+
//#region src/components/popover/popover.styles.ts
|
|
13
|
+
var popover_styles_default = css`
|
|
14
|
+
:host {
|
|
15
|
+
--arrow-size: 0.3125rem;
|
|
16
|
+
--max-width: 25rem;
|
|
17
|
+
--show-duration: var(--sigvelo-motion-duration-interaction);
|
|
18
|
+
|
|
19
|
+
/* Internal calculated properties */
|
|
20
|
+
--arrow-diagonal-size: calc(var(--arrow-size) * sin(45deg));
|
|
21
|
+
|
|
22
|
+
display: contents;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
#dialog {
|
|
26
|
+
display: none;
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
overflow: visible;
|
|
33
|
+
border: none;
|
|
34
|
+
background: none;
|
|
35
|
+
|
|
36
|
+
&:focus {
|
|
37
|
+
outline: none;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&::backdrop {
|
|
41
|
+
background: transparent;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&.visible {
|
|
45
|
+
display: flex;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.show {
|
|
49
|
+
animation: show var(--show-duration) ease;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&.hide {
|
|
53
|
+
animation: show var(--show-duration) ease reverse;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#content {
|
|
58
|
+
z-index: 2;
|
|
59
|
+
max-width: var(--max-width);
|
|
60
|
+
padding: 1rem;
|
|
61
|
+
border: var(--sigvelo-border-style) var(--sigvelo-border-width)
|
|
62
|
+
var(--sigvelo-color-neutral-border-muted);
|
|
63
|
+
border-radius: var(--sigvelo-radius-md);
|
|
64
|
+
background-color: var(--sigvelo-color-canvas);
|
|
65
|
+
box-shadow: var(--sigvelo-elevation-raised);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#arrow {
|
|
69
|
+
z-index: 3;
|
|
70
|
+
position: absolute;
|
|
71
|
+
width: calc(var(--arrow-diagonal-size) * 2);
|
|
72
|
+
height: calc(var(--arrow-diagonal-size) * 2);
|
|
73
|
+
border-right: var(--sigvelo-border-style) var(--sigvelo-border-width)
|
|
74
|
+
var(--sigvelo-color-neutral-border-muted);
|
|
75
|
+
border-bottom: var(--sigvelo-border-style) var(--sigvelo-border-width)
|
|
76
|
+
var(--sigvelo-color-neutral-border-muted);
|
|
77
|
+
background-color: var(--sigvelo-color-canvas);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Prevent the popover from touching the edge of the viewport */
|
|
81
|
+
:host([data-placement^="top"]) #dialog,
|
|
82
|
+
:host([data-placement^="bottom"]) #dialog {
|
|
83
|
+
padding-inline: 0.5rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([data-placement^="left"]) #dialog,
|
|
87
|
+
:host([data-placement^="right"]) #dialog {
|
|
88
|
+
padding-block: 0.5rem;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Rotate border position based on placement */
|
|
92
|
+
:host([data-placement^="top"]) {
|
|
93
|
+
--show-x: 0;
|
|
94
|
+
--show-y: 0.25em;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:host([data-placement^="top"]) #arrow {
|
|
98
|
+
rotate: 45deg;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:host([data-placement^="right"]) {
|
|
102
|
+
--show-x: -0.25em;
|
|
103
|
+
--show-y: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:host([data-placement^="right"]) #arrow {
|
|
107
|
+
rotate: 135deg;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host([data-placement^="bottom"]) {
|
|
111
|
+
--show-x: 0;
|
|
112
|
+
--show-y: -0.25em;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host([data-placement^="bottom"]) #arrow {
|
|
116
|
+
rotate: 225deg;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host([data-placement^="left"]) {
|
|
120
|
+
--show-x: 0.25em;
|
|
121
|
+
--show-y: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([data-placement^="left"]) #arrow {
|
|
125
|
+
rotate: 315deg;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@keyframes show {
|
|
129
|
+
from {
|
|
130
|
+
translate: var(--show-x) var(--show-y);
|
|
131
|
+
scale: 0.9;
|
|
132
|
+
opacity: 0;
|
|
133
|
+
}
|
|
134
|
+
to {
|
|
135
|
+
translate: 0 0;
|
|
136
|
+
scale: 1;
|
|
137
|
+
opacity: 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/components/popover/popover.ts
|
|
143
|
+
const openPopovers = /* @__PURE__ */ new Set();
|
|
144
|
+
/**
|
|
145
|
+
* <sigvelo-popover>
|
|
146
|
+
*
|
|
147
|
+
* @summary Provides additional information or functionality without interrupting the flow of content.
|
|
148
|
+
* @tag sigvelo-popover
|
|
149
|
+
* @documentation https://design-system.sigvelo.com/docs/components/popover
|
|
150
|
+
* @status stable
|
|
151
|
+
* @since 1.0
|
|
152
|
+
*
|
|
153
|
+
* @slot - The popover's content. Do not include interactive elements such as button, links, etc. as they won't be
|
|
154
|
+
* accessible to users inside the popover.
|
|
155
|
+
*
|
|
156
|
+
* @event sigvelo-before-open - Emitted when the popover is instructed to open but before it is shown.
|
|
157
|
+
* @event sigvelo-open - Emitted when the popover has opened and the animation has completed.
|
|
158
|
+
* @event sigvelo-before-close - Emitted when the popover is dismissed but before it is hidden.
|
|
159
|
+
* @event sigvelo-close - Emitted when the popover has closed. and the animation has completed.
|
|
160
|
+
*
|
|
161
|
+
* @cssproperty [--arrow-size=0.3125rem] - The size of the arrow. To hide the arrow, use the `without-arrow` attribute.
|
|
162
|
+
* @cssproperty [--max-width=25rem] - The maximum width the popover be before wrapping.
|
|
163
|
+
* @cssproperty [--show-duration=100ms] - The duration of the show/hide animation.
|
|
164
|
+
|
|
165
|
+
* @csspart dialog - The element that powers the popover, a `<dialog>` element.
|
|
166
|
+
* @csspart content - The element that wraps the popover's content.
|
|
167
|
+
* @csspart arrow - The popover's arrow. To change the arrow's size, use `--arrow-size` instead.
|
|
168
|
+
*
|
|
169
|
+
* @cssstate open - Applied when the popover is open.
|
|
170
|
+
*
|
|
171
|
+
* @example Default
|
|
172
|
+
* Popovers appear when a corresponding anchor element is clicked. Unlike tooltips, popovers can contain interactive content such as links, buttons, and form controls. They are not modal, so no overlay is shown when open. Popovers will close when the user clicks outside of them or presses [[Escape]]. Only one popover can be open at a time.
|
|
173
|
+
*
|
|
174
|
+
* ```html
|
|
175
|
+
* <sigvelo-popover for="popover__overview">
|
|
176
|
+
* <div style="display: flex; gap: 1.5rem; align-items: center;">
|
|
177
|
+
* <img
|
|
178
|
+
* src="https://images.unsplash.com/photo-1579014868745-23e405c5605d?q=80&w=400&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
|
|
179
|
+
* alt="A gray kitten stares into the camera"
|
|
180
|
+
* style="max-width: 8rem;"
|
|
181
|
+
* >
|
|
182
|
+
* <div style="display: flex; flex-direction: column; justify-content: space-between; gap: 1.5rem">
|
|
183
|
+
* Cats love chasing popovers that appear on the screen. I wonder what they would do if they actually caught one.
|
|
184
|
+
* <sigvelo-button color="primary" size="sm">Learn more</sigvelo-button>
|
|
185
|
+
* </div>
|
|
186
|
+
* </div>
|
|
187
|
+
* </sigvelo-popover>
|
|
188
|
+
*
|
|
189
|
+
* <sigvelo-button id="popover__overview">Show popover</sigvelo-button>
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @example Assigning an anchor
|
|
193
|
+
* Popover anchors should be `<sigvelo-button>` or `<button>` elements. Use the `for` attribute on the popover to link it to the anchor's `id`.
|
|
194
|
+
*
|
|
195
|
+
* ```html
|
|
196
|
+
* <sigvelo-button id="popover__anchor-button">Show popover</sigvelo-button>
|
|
197
|
+
*
|
|
198
|
+
* <sigvelo-popover for="popover__anchor-button">
|
|
199
|
+
* I'm just a popover anchored to a button.
|
|
200
|
+
* </sigvelo-popover>
|
|
201
|
+
*
|
|
202
|
+
* <br><br>
|
|
203
|
+
*
|
|
204
|
+
* <button id="popover__anchor-native-button">Show popover</button>
|
|
205
|
+
*
|
|
206
|
+
* <sigvelo-popover for="popover__anchor-native-button">
|
|
207
|
+
* I'm just a popover anchored to a native button.
|
|
208
|
+
* </sigvelo-popover>
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* **Warning:** The anchor element must be in the DOM when the popover is connected, otherwise the popover won't be attached and a warning will be shown in the console.
|
|
212
|
+
*
|
|
213
|
+
* @example Opening and closing popovers
|
|
214
|
+
* Popovers will be shown when their anchor element is clicked. You can open and close a popover programmatically by obtaining a reference to it and setting the `open` property to `true` or `false`, respectively.
|
|
215
|
+
*
|
|
216
|
+
* As a convenience, you can add `data-popover="close"` to any button inside a popover to close it without additional JavaScript.
|
|
217
|
+
*
|
|
218
|
+
* ```html
|
|
219
|
+
* <sigvelo-popover for="popover__opening">
|
|
220
|
+
* <p>The button below has <code>data-popover="close"</code> so clicking it will close the popover.</p>
|
|
221
|
+
* <sigvelo-button data-popover="close" color="primary">Dismiss</sigvelo-button>
|
|
222
|
+
* </sigvelo-popover>
|
|
223
|
+
*
|
|
224
|
+
* <sigvelo-button id="popover__opening">Show popover</sigvelo-button>
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* **Note:** Nested popovers are allowed. When opening a popover, all non-ancestor popovers will close, but parent popovers will remain open.
|
|
228
|
+
*
|
|
229
|
+
* @example Placement
|
|
230
|
+
* Use the `placement` attribute to change the preferred location of the popover in reference to its anchor. The popover will shift to a more optimal location if the preferred placement doesn't have enough room. The default placement is `top`.
|
|
231
|
+
*
|
|
232
|
+
* ```html
|
|
233
|
+
* <sigvelo-button id="popover__top">Top</sigvelo-button>
|
|
234
|
+
* <sigvelo-popover for="popover__top" placement="top">I'm on the top</sigvelo-popover>
|
|
235
|
+
*
|
|
236
|
+
* <sigvelo-button id="popover__bottom">Bottom</sigvelo-button>
|
|
237
|
+
* <sigvelo-popover for="popover__bottom" placement="bottom">I'm on the bottom</sigvelo-popover>
|
|
238
|
+
*
|
|
239
|
+
* <sigvelo-button id="popover__left">Left</sigvelo-button>
|
|
240
|
+
* <sigvelo-popover for="popover__left" placement="left">I'm on the left </sigvelo-popover>
|
|
241
|
+
*
|
|
242
|
+
* <sigvelo-button id="popover__right">Right</sigvelo-button>
|
|
243
|
+
* <sigvelo-popover for="popover__right" placement="right">I'm on the right</sigvelo-popover>
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @example Distance
|
|
247
|
+
* You can change the distance of the popover from the anchor by setting the `distance` attribute to the desired number of pixels.
|
|
248
|
+
*
|
|
249
|
+
* ```html
|
|
250
|
+
* <sigvelo-button id="popover__distance-near">Near</sigvelo-button>
|
|
251
|
+
* <sigvelo-popover for="popover__distance-near" distance="0">I'm so near</sigvelo-popover>
|
|
252
|
+
*
|
|
253
|
+
* <sigvelo-button id="popover__distance-far">Far</sigvelo-button>
|
|
254
|
+
* <sigvelo-popover for="popover__distance-far" distance="30">I'm so far</sigvelo-popover>
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @example Changing the arrow size
|
|
258
|
+
* You can change the size of the popover's arrow with the `--arrow-size` custom property. To hide it, use the `without-arrow` attribute.
|
|
259
|
+
*
|
|
260
|
+
* ```html
|
|
261
|
+
* <sigvelo-button id="popover__big-arrow">Big arrow</sigvelo-button>
|
|
262
|
+
* <sigvelo-popover for="popover__big-arrow" style="--arrow-size: 8px;">I have a big arrow</sigvelo-popover>
|
|
263
|
+
*
|
|
264
|
+
* <sigvelo-button id="popover__no-arrow">No arrow</sigvelo-button>
|
|
265
|
+
* <sigvelo-popover for="popover__no-arrow" without-arrow>I don't have an arrow</sigvelo-popover>
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* @example Setting a max width
|
|
269
|
+
* Use the `--max-width` custom property to change the maximum width of the popover.
|
|
270
|
+
*
|
|
271
|
+
* ```html
|
|
272
|
+
* <sigvelo-button id="popover__max-width">Toggle me</sigvelo-button>
|
|
273
|
+
* <sigvelo-popover for="popover__max-width" style="--max-width: 160px;">
|
|
274
|
+
* Popovers will usually grow to be a lot wider, but this one has a custom max width.
|
|
275
|
+
* </sigvelo-popover>
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @example Setting focus on open
|
|
279
|
+
* To move focus to a specific form control when the popover opens, use the `autofocus` global attribute.
|
|
280
|
+
*
|
|
281
|
+
* ```html
|
|
282
|
+
* <sigvelo-popover for="popover__autofocus">
|
|
283
|
+
* <div style="display: flex; flex-direction: column; gap: 1rem;">
|
|
284
|
+
* <sigvelo-text-area
|
|
285
|
+
* autofocus
|
|
286
|
+
* placeholder="What did you think?"
|
|
287
|
+
* size="sm"
|
|
288
|
+
* resize="none"
|
|
289
|
+
* class="sigvelo-vh-label"
|
|
290
|
+
* ></sigvelo-text-area>
|
|
291
|
+
* <sigvelo-button color="primary" size="sm" data-popover="close">
|
|
292
|
+
* Submit
|
|
293
|
+
* </sigvelo-button>
|
|
294
|
+
* </div>
|
|
295
|
+
* </sigvelo-popover>
|
|
296
|
+
*
|
|
297
|
+
* <sigvelo-button id="popover__autofocus">
|
|
298
|
+
* <sigvelo-icon slot="start" name="message-circle"></sigvelo-icon>
|
|
299
|
+
* Feedback
|
|
300
|
+
* </sigvelo-button>
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @example Using popovers as confirmations
|
|
304
|
+
* A common popover pattern is to get confirmation before performing a destructive action.
|
|
305
|
+
*
|
|
306
|
+
* ```html
|
|
307
|
+
* <sigvelo-popover for="popover__confirmation" placement="right">
|
|
308
|
+
* <div style="display: flex; flex-direction: column; gap: 0.5rem;">
|
|
309
|
+
* <sigvelo-button color="destructive" size="sm" data-popover="close">Confirm delete</sigvelo-button>
|
|
310
|
+
* <sigvelo-button size="sm" data-popover="close">Cancel</sigvelo-button>
|
|
311
|
+
* </div>
|
|
312
|
+
* </sigvelo-popover>
|
|
313
|
+
*
|
|
314
|
+
* <sigvelo-button id="popover__confirmation" color="destructive">Delete</sigvelo-button>
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* @example Using tab lists in popovers
|
|
318
|
+
* You can use tab lists in popovers to categorize content as needed.
|
|
319
|
+
*
|
|
320
|
+
* ```html
|
|
321
|
+
* <sigvelo-popover for="popover__tabs" id="popover__tablist">
|
|
322
|
+
* <sigvelo-tab-list label="Select a tab">
|
|
323
|
+
* <sigvelo-tab panel="first">First</sigvelo-tab>
|
|
324
|
+
* <sigvelo-tab panel="second">Second</sigvelo-tab>
|
|
325
|
+
* <sigvelo-tab panel="third">Third</sigvelo-tab>
|
|
326
|
+
*
|
|
327
|
+
* <sigvelo-tab-panel name="first">Cats have a unique way of communicating — they can make over 100 vocal sounds, each meaning something different.</sigvelo-tab-panel>
|
|
328
|
+
* <sigvelo-tab-panel name="second">A cat's sense of smell is much stronger than that of humans, making their noses one of their most important tools.</sigvelo-tab-panel>
|
|
329
|
+
* <sigvelo-tab-panel name="third">A group of kittens is called a "kindle," a term that perfectly captures the warmth and charm they bring.</sigvelo-tab-panel>
|
|
330
|
+
* </sigvelo-tab-list>
|
|
331
|
+
* </sigvelo-popover>
|
|
332
|
+
*
|
|
333
|
+
* <sigvelo-button id="popover__tabs">Facts about cats</sigvelo-button>
|
|
334
|
+
*
|
|
335
|
+
* <style>
|
|
336
|
+
* #popover__tablist::part(content) {
|
|
337
|
+
* padding: 0;
|
|
338
|
+
* }
|
|
339
|
+
*
|
|
340
|
+
* #popover__tablist sigvelo-tab-list::part(panels) {
|
|
341
|
+
* padding: 1rem;
|
|
342
|
+
* }
|
|
343
|
+
* </style>
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
var SigveloPopover = class extends SigveloElement {
|
|
347
|
+
constructor(..._args) {
|
|
348
|
+
super(..._args);
|
|
349
|
+
this.open = false;
|
|
350
|
+
this.placement = "top";
|
|
351
|
+
this.distance = 8;
|
|
352
|
+
this.offset = 0;
|
|
353
|
+
this.withoutArrow = false;
|
|
354
|
+
this.handleAnchorClick = () => {
|
|
355
|
+
this.open = !this.open;
|
|
356
|
+
};
|
|
357
|
+
this.handleDocumentKeyDown = (event) => {
|
|
358
|
+
if (event.key === "Escape") {
|
|
359
|
+
event.preventDefault();
|
|
360
|
+
this.open = false;
|
|
361
|
+
this.anchor?.focus();
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
this.handleDocumentClick = (event) => {
|
|
365
|
+
if (this.anchor && event.composedPath().includes(this.anchor)) return;
|
|
366
|
+
if (!event.composedPath().includes(this)) this.open = false;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
static {
|
|
370
|
+
this.styles = [hostStyles, popover_styles_default];
|
|
371
|
+
}
|
|
372
|
+
firstUpdated() {
|
|
373
|
+
if (!this.id) this.id = createId("sigvelo-popover-");
|
|
374
|
+
}
|
|
375
|
+
disconnectedCallback() {
|
|
376
|
+
super.disconnectedCallback();
|
|
377
|
+
this.syncAnchorAria(null);
|
|
378
|
+
this.anchor?.removeEventListener("click", this.handleAnchorClick);
|
|
379
|
+
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
380
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
381
|
+
this.cleanup?.();
|
|
382
|
+
openPopovers.delete(this);
|
|
383
|
+
}
|
|
384
|
+
updated(changedProperties) {
|
|
385
|
+
if (changedProperties.has("open")) {
|
|
386
|
+
if (this.open && !this.dialog.classList.contains("visible")) this.show();
|
|
387
|
+
else this.hide();
|
|
388
|
+
this.syncAnchorAria(this.open);
|
|
389
|
+
}
|
|
390
|
+
if (changedProperties.has("for")) {
|
|
391
|
+
const root = this.getRootNode();
|
|
392
|
+
if (this.anchor) {
|
|
393
|
+
this.syncAnchorAria(null);
|
|
394
|
+
this.anchor.removeEventListener("click", this.handleAnchorClick);
|
|
395
|
+
}
|
|
396
|
+
this.anchor = this.for ? root.getElementById(this.for) : null;
|
|
397
|
+
if (this.anchor) {
|
|
398
|
+
this.anchor.addEventListener("click", this.handleAnchorClick);
|
|
399
|
+
this.syncAnchorAria(this.open);
|
|
400
|
+
} else if (this.for) console.warn(`A popover was assigned to an element with an ID of "${this.for}" but the element could not be found.`, this);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
setAnchorAria(target, open) {
|
|
404
|
+
if (open === null) {
|
|
405
|
+
target.removeAttribute("aria-haspopup");
|
|
406
|
+
target.removeAttribute("aria-controls");
|
|
407
|
+
target.removeAttribute("aria-expanded");
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
target.setAttribute("aria-haspopup", "dialog");
|
|
411
|
+
target.setAttribute("aria-controls", this.id);
|
|
412
|
+
target.setAttribute("aria-expanded", String(open));
|
|
413
|
+
}
|
|
414
|
+
syncAnchorAria(open) {
|
|
415
|
+
const anchor = this.anchor;
|
|
416
|
+
if (!anchor) return;
|
|
417
|
+
this.setAnchorAria(anchor, open);
|
|
418
|
+
if (stripElementPrefix(anchor.localName) === "button") customElements.whenDefined("sigvelo-button").then(async () => {
|
|
419
|
+
await anchor.updateComplete;
|
|
420
|
+
const nativeButton = anchor.shadowRoot?.querySelector("button");
|
|
421
|
+
if (nativeButton) this.setAnchorAria(nativeButton, open === null ? null : this.open);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
handleDialogClick(event) {
|
|
425
|
+
if (event.target.closest("[data-popover=\"close\"]")) {
|
|
426
|
+
event.stopPropagation();
|
|
427
|
+
this.open = false;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/** Shows the popover. This should only be called from within updated(). */
|
|
431
|
+
async show() {
|
|
432
|
+
if (!this.anchor) return;
|
|
433
|
+
const openEvent = new SigveloBeforeOpenEvent();
|
|
434
|
+
this.dispatchEvent(openEvent);
|
|
435
|
+
if (openEvent.defaultPrevented) {
|
|
436
|
+
this.open = false;
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
openPopovers.forEach((popover) => {
|
|
440
|
+
if (!popover.contains(this)) popover.open = false;
|
|
441
|
+
});
|
|
442
|
+
if (!this.dialog.isConnected) return;
|
|
443
|
+
this.dialog.showPopover();
|
|
444
|
+
this.customStates.set("open", true);
|
|
445
|
+
this.open = true;
|
|
446
|
+
openPopovers.add(this);
|
|
447
|
+
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
448
|
+
document.addEventListener("click", this.handleDocumentClick);
|
|
449
|
+
this.dialog.classList.add("visible");
|
|
450
|
+
this.cleanup = autoUpdate(this.anchor, this.dialog, () => this.reposition());
|
|
451
|
+
requestAnimationFrame(() => {
|
|
452
|
+
const elementToFocus = this.querySelector("[autofocus]");
|
|
453
|
+
if (elementToFocus && typeof elementToFocus.focus === "function") elementToFocus.focus();
|
|
454
|
+
else this.dialog.focus();
|
|
455
|
+
});
|
|
456
|
+
await animateWithClass(this.dialog, "show");
|
|
457
|
+
this.dispatchEvent(new SigveloOpenEvent());
|
|
458
|
+
}
|
|
459
|
+
/** Hides the popover. This should only be called from within updated(). */
|
|
460
|
+
async hide() {
|
|
461
|
+
const closeEvent = new SigveloBeforeCloseEvent({ source: this });
|
|
462
|
+
this.dispatchEvent(closeEvent);
|
|
463
|
+
if (closeEvent.defaultPrevented) {
|
|
464
|
+
this.open = true;
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
this.customStates.set("open", false);
|
|
468
|
+
this.open = false;
|
|
469
|
+
openPopovers.delete(this);
|
|
470
|
+
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
471
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
472
|
+
if (this.dialog.classList.contains("visible")) {
|
|
473
|
+
await animateWithClass(this.dialog, "hide");
|
|
474
|
+
this.dialog.classList.remove("visible");
|
|
475
|
+
this.dialog.hidePopover();
|
|
476
|
+
this.dispatchEvent(new SigveloCloseEvent());
|
|
477
|
+
}
|
|
478
|
+
if (this.cleanup) {
|
|
479
|
+
this.cleanup();
|
|
480
|
+
this.cleanup = void 0;
|
|
481
|
+
this.removeAttribute("data-placement");
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
/** Repositions the popover */
|
|
485
|
+
reposition() {
|
|
486
|
+
if (!this.anchor) return;
|
|
487
|
+
computePosition(this.anchor, this.dialog, {
|
|
488
|
+
placement: this.placement,
|
|
489
|
+
middleware: [
|
|
490
|
+
offset({
|
|
491
|
+
mainAxis: this.distance,
|
|
492
|
+
crossAxis: this.offset
|
|
493
|
+
}),
|
|
494
|
+
flip(),
|
|
495
|
+
shift(),
|
|
496
|
+
arrow({ element: this.arrow })
|
|
497
|
+
]
|
|
498
|
+
}).then(({ x, y, middlewareData, placement }) => {
|
|
499
|
+
this.setAttribute("data-placement", placement);
|
|
500
|
+
Object.assign(this.dialog.style, {
|
|
501
|
+
left: `${x}px`,
|
|
502
|
+
top: `${y}px`
|
|
503
|
+
});
|
|
504
|
+
if (middlewareData.arrow) {
|
|
505
|
+
const arrowX = middlewareData.arrow.x;
|
|
506
|
+
const arrowY = middlewareData.arrow.y;
|
|
507
|
+
const staticSide = {
|
|
508
|
+
top: "bottom",
|
|
509
|
+
right: "left",
|
|
510
|
+
bottom: "top",
|
|
511
|
+
left: "right"
|
|
512
|
+
}[placement.split("-")[0]];
|
|
513
|
+
Object.assign(this.arrow.style, {
|
|
514
|
+
left: typeof arrowX === "number" ? `${arrowX}px` : "",
|
|
515
|
+
top: typeof arrowY === "number" ? `${arrowY}px` : "",
|
|
516
|
+
[staticSide]: "calc(var(--arrow-diagonal-size) * -1)"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
render() {
|
|
522
|
+
return html`
|
|
523
|
+
<dialog
|
|
524
|
+
id="dialog"
|
|
525
|
+
part="dialog"
|
|
526
|
+
popover="manual"
|
|
527
|
+
aria-label=${ifDefined(this.label)}
|
|
528
|
+
@click=${this.handleDialogClick}
|
|
529
|
+
>
|
|
530
|
+
<div id="content" part="content">
|
|
531
|
+
<slot></slot>
|
|
532
|
+
</div>
|
|
533
|
+
<div id="arrow" part="arrow" role="presentation" ?hidden=${this.withoutArrow}></div>
|
|
534
|
+
</dialog>
|
|
535
|
+
`;
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
__decorate([query("#arrow")], SigveloPopover.prototype, "arrow", void 0);
|
|
539
|
+
__decorate([query("#dialog")], SigveloPopover.prototype, "dialog", void 0);
|
|
540
|
+
__decorate([property({ reflect: true })], SigveloPopover.prototype, "for", void 0);
|
|
541
|
+
__decorate([property()], SigveloPopover.prototype, "label", void 0);
|
|
542
|
+
__decorate([property({
|
|
543
|
+
type: Boolean,
|
|
544
|
+
reflect: true
|
|
545
|
+
})], SigveloPopover.prototype, "open", void 0);
|
|
546
|
+
__decorate([property({ reflect: true })], SigveloPopover.prototype, "placement", void 0);
|
|
547
|
+
__decorate([property({ type: Number })], SigveloPopover.prototype, "distance", void 0);
|
|
548
|
+
__decorate([property({ type: Number })], SigveloPopover.prototype, "offset", void 0);
|
|
549
|
+
__decorate([property({
|
|
550
|
+
attribute: "without-arrow",
|
|
551
|
+
type: Boolean,
|
|
552
|
+
reflect: true
|
|
553
|
+
})], SigveloPopover.prototype, "withoutArrow", void 0);
|
|
554
|
+
customElements.define("sigvelo-popover", SigveloPopover);
|
|
555
|
+
//#endregion
|
|
556
|
+
export { SigveloPopover as t };
|