bromcom-ui-next 0.1.29 → 0.1.30
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/dist/bromcom-ui/_commonjsHelpers-CvGrISen.js.map +1 -0
- package/dist/bromcom-ui/bcm-accordion.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-alert.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-button.bcm-drawer.bcm-linked.bcm-modal.bcm-pop-confirm.bcm-popover.bcm-tooltip.entry.esm.js.map +1 -0
- package/dist/bromcom-ui/bcm-divider.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-dropdown.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-segmented-picker-option.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-segmented-picker.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-switch.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-tabs.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bcm-text.entry.esm.js.map +1 -1
- package/dist/bromcom-ui/bromcom-ui.esm.js +1 -1
- package/dist/bromcom-ui/bromcom-ui.esm.js.map +1 -1
- package/dist/bromcom-ui/floating-ui.dom-ltNPqX34.js.map +1 -0
- package/dist/bromcom-ui/generate-id-Crb5QsB-.js.map +1 -0
- package/dist/bromcom-ui/index-40rmUZjU.js.map +1 -0
- package/dist/bromcom-ui/index-BCaJmHBB.js.map +1 -0
- package/dist/bromcom-ui/{p-8ace5a6a.entry.js → p-0c7c6896.entry.js} +2 -2
- package/dist/bromcom-ui/p-0c7c6896.entry.js.map +1 -0
- package/dist/bromcom-ui/p-11d0e649.entry.js +2 -0
- package/dist/bromcom-ui/p-11d0e649.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-6b585adc.entry.js → p-12f38632.entry.js} +2 -2
- package/dist/bromcom-ui/p-12f38632.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-5e0702d1.entry.js → p-13cbd1f5.entry.js} +2 -2
- package/dist/bromcom-ui/p-13cbd1f5.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-2480e468.entry.js → p-1507908f.entry.js} +2 -2
- package/dist/bromcom-ui/p-1507908f.entry.js.map +1 -0
- package/dist/bromcom-ui/p-1ce9913f.entry.js +2 -0
- package/dist/bromcom-ui/p-1ce9913f.entry.js.map +1 -0
- package/dist/bromcom-ui/p-206d767e.entry.js +2 -0
- package/dist/bromcom-ui/p-206d767e.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-ee5f877f.entry.js → p-3cf7a7f4.entry.js} +2 -2
- package/dist/bromcom-ui/p-3cf7a7f4.entry.js.map +1 -0
- package/dist/bromcom-ui/p-4505feba.entry.js +2 -0
- package/dist/bromcom-ui/p-4505feba.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-089edfdc.entry.js → p-496014ca.entry.js} +2 -2
- package/dist/bromcom-ui/p-496014ca.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-26d2db9e.entry.js → p-4a932cd3.entry.js} +2 -2
- package/dist/bromcom-ui/p-4a932cd3.entry.js.map +1 -0
- package/dist/bromcom-ui/p-4e554b8d.entry.js +2 -0
- package/dist/bromcom-ui/p-4e554b8d.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-360bff8a.entry.js → p-57c4c4c4.entry.js} +2 -2
- package/dist/bromcom-ui/p-57c4c4c4.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-211ca6e0.entry.js → p-61293ab2.entry.js} +2 -2
- package/dist/bromcom-ui/p-61293ab2.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-83f64814.entry.js → p-61789456.entry.js} +2 -2
- package/dist/bromcom-ui/p-61789456.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-488d6ef4.entry.js → p-65d0f188.entry.js} +2 -2
- package/dist/bromcom-ui/p-65d0f188.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-11f3e129.entry.js → p-83f707dc.entry.js} +2 -2
- package/dist/bromcom-ui/p-83f707dc.entry.js.map +1 -0
- package/dist/bromcom-ui/p-8ba02e7e.entry.js +2 -0
- package/dist/bromcom-ui/p-8ba02e7e.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-22edf049.entry.js → p-9e9bf32e.entry.js} +2 -2
- package/dist/bromcom-ui/p-9e9bf32e.entry.js.map +1 -0
- package/dist/bromcom-ui/p-BfTCfPZ1.js.map +1 -1
- package/dist/bromcom-ui/p-CEcVC0yX.js.map +1 -1
- package/dist/bromcom-ui/p-CRwAh9Np.js +3 -0
- package/dist/bromcom-ui/p-CRwAh9Np.js.map +1 -0
- package/dist/bromcom-ui/p-IBjzkjef.js.map +1 -1
- package/dist/bromcom-ui/{p-a88f20e0.entry.js → p-c87a6acf.entry.js} +2 -2
- package/dist/bromcom-ui/p-c87a6acf.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-c34f0a66.entry.js → p-e0e235a8.entry.js} +2 -2
- package/dist/bromcom-ui/p-e0e235a8.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-0101b4f2.entry.js → p-e1ce8b55.entry.js} +2 -2
- package/dist/bromcom-ui/p-e1ce8b55.entry.js.map +1 -0
- package/dist/bromcom-ui/p-e4dddb0b.entry.js +2 -0
- package/dist/bromcom-ui/p-e4dddb0b.entry.js.map +1 -0
- package/dist/bromcom-ui/p-f9426924.entry.js +2 -0
- package/dist/bromcom-ui/p-f9426924.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-c0e7f9d6.entry.js → p-faa0e62c.entry.js} +2 -2
- package/dist/bromcom-ui/p-faa0e62c.entry.js.map +1 -0
- package/dist/bromcom-ui/{p-bdaf5653.entry.js → p-fcb4399f.entry.js} +2 -2
- package/dist/bromcom-ui/p-fcb4399f.entry.js.map +1 -0
- package/dist/bromcom-ui/tv-SlGJ5EfR.js.map +1 -0
- package/dist/bromcom-ui/validation-messages-CUvT12BL.js.map +1 -0
- package/dist/cjs/bcm-accordion-group.cjs.entry.js +2 -4
- package/dist/cjs/bcm-accordion.cjs.entry.js +3 -5
- package/dist/cjs/bcm-accordion.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-alert.cjs.entry.js +3 -5
- package/dist/cjs/bcm-alert.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-avatar.cjs.entry.js +1 -3
- package/dist/cjs/bcm-badge.cjs.entry.js +3 -5
- package/dist/cjs/bcm-basic-badge.cjs.entry.js +3 -5
- package/dist/cjs/bcm-button-group.cjs.entry.js +3 -5
- package/dist/cjs/bcm-button.bcm-drawer.bcm-linked.bcm-modal.bcm-pop-confirm.bcm-popover.bcm-tooltip.entry.cjs.js.map +1 -0
- package/dist/cjs/bcm-button_7.cjs.entry.js +4131 -0
- package/dist/cjs/bcm-checkbox.cjs.entry.js +2 -4
- package/dist/cjs/bcm-chip.cjs.entry.js +2 -4
- package/dist/cjs/bcm-divider.cjs.entry.js +3 -5
- package/dist/cjs/bcm-divider.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-dropdown-item.cjs.entry.js +3 -5
- package/dist/cjs/bcm-dropdown.cjs.entry.js +3 -13
- package/dist/cjs/bcm-dropdown.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-input.cjs.entry.js +3 -5
- package/dist/cjs/bcm-radio-group.cjs.entry.js +3 -5
- package/dist/cjs/bcm-radio.cjs.entry.js +2 -4
- package/dist/cjs/bcm-segmented-picker-option.cjs.entry.js +3 -5
- package/dist/cjs/bcm-segmented-picker-option.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-segmented-picker.cjs.entry.js +3 -5
- package/dist/cjs/bcm-segmented-picker.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-shortcut.cjs.entry.js +2 -4
- package/dist/cjs/bcm-switch.cjs.entry.js +4 -6
- package/dist/cjs/bcm-switch.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-tabs-content.cjs.entry.js +2 -4
- package/dist/cjs/bcm-tabs-list.cjs.entry.js +2 -4
- package/dist/cjs/bcm-tabs-trigger.cjs.entry.js +2 -4
- package/dist/cjs/bcm-tabs.cjs.entry.js +2 -4
- package/dist/cjs/bcm-tabs.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-text.cjs.entry.js +3 -5
- package/dist/cjs/bcm-text.entry.cjs.js.map +1 -1
- package/dist/cjs/bcm-textarea.cjs.entry.js +4 -6
- package/dist/cjs/bromcom-ui.cjs.js +3 -5
- package/dist/cjs/bromcom-ui.cjs.js.map +1 -1
- package/dist/cjs/generate-id-CG_BkTJu.js.map +1 -1
- package/dist/cjs/index-Bp6Dd2i1.js.map +1 -1
- package/dist/cjs/{index-BtiU-G2W.js → index-CmYzUr-k.js} +61 -372
- package/dist/cjs/index-CmYzUr-k.js.map +1 -0
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +2 -4
- package/dist/cjs/tv-ngpIbGlG.js.map +1 -1
- package/dist/collection/collection-manifest.json +5 -5
- package/dist/collection/components/accordion/accordion.component.js +8 -8
- package/dist/collection/components/accordion/accordion.component.js.map +1 -1
- package/dist/collection/components/accordion-group/accordion-group.component.js +3 -3
- package/dist/collection/components/accordion-group/types.js.map +1 -1
- package/dist/collection/components/alert/alert.component.js +6 -6
- package/dist/collection/components/alert/alert.css +1 -1
- package/dist/collection/components/avatar/avatar.component.js +14 -14
- package/dist/collection/components/badge/badge.component.js +15 -15
- package/dist/collection/components/basic-badge/basic-badge.component.js +9 -9
- package/dist/collection/components/button/button.component.js +32 -32
- package/dist/collection/components/button/button.css +1 -1
- package/dist/collection/components/button-group/button-group.component.js +15 -15
- package/dist/collection/components/checkbox/checkbox.component.js +13 -13
- package/dist/collection/components/chip/chip.component.js +8 -8
- package/dist/collection/components/divider/divider.component.js +4 -4
- package/dist/collection/components/divider/divider.css +1 -1
- package/dist/collection/components/drawer/drawer.component.js +429 -132
- package/dist/collection/components/drawer/drawer.component.js.map +1 -1
- package/dist/collection/components/drawer/drawer.css +1 -1
- package/dist/collection/components/drawer/types.js.map +1 -1
- package/dist/collection/components/dropdown/dropdown.component.js +3 -12
- package/dist/collection/components/dropdown/dropdown.component.js.map +1 -1
- package/dist/collection/components/dropdown/dropdown.css +1 -1
- package/dist/collection/components/dropdown-item/dropdown-item.component.js +9 -10
- package/dist/collection/components/dropdown-item/dropdown-item.component.js.map +1 -1
- package/dist/collection/components/input/input.component.js +44 -45
- package/dist/collection/components/input/input.component.js.map +1 -1
- package/dist/collection/components/linked/linked.component.js +507 -333
- package/dist/collection/components/linked/linked.component.js.map +1 -1
- package/dist/collection/components/linked/linked.css +1 -1
- package/dist/collection/components/modal/modal.component.js +137 -34
- package/dist/collection/components/modal/modal.component.js.map +1 -1
- package/dist/collection/components/modal/modal.css +1 -1
- package/dist/collection/components/pop-confirm/pop-confirm.component.js +668 -294
- package/dist/collection/components/pop-confirm/pop-confirm.component.js.map +1 -1
- package/dist/collection/components/pop-confirm/pop-confirm.css +1 -1
- package/dist/collection/components/popover/popover.component.js +533 -148
- package/dist/collection/components/popover/popover.component.js.map +1 -1
- package/dist/collection/components/popover/popover.css +1 -1
- package/dist/collection/components/radio/radio.component.js +13 -13
- package/dist/collection/components/radio-group/radio-group.component.js +15 -15
- package/dist/collection/components/segmented-picker/segmented-picker-option.component.js +10 -10
- package/dist/collection/components/segmented-picker/segmented-picker-option.component.js.map +1 -1
- package/dist/collection/components/segmented-picker/segmented-picker.component.js +7 -7
- package/dist/collection/components/segmented-picker/segmented-picker.component.js.map +1 -1
- package/dist/collection/components/shortcut/shortcut.js +4 -4
- package/dist/collection/components/switch/switch.component.js +17 -17
- package/dist/collection/components/switch/switch.css +1 -1
- package/dist/collection/components/tabs/tabs-content.component.js +3 -3
- package/dist/collection/components/tabs/tabs-list.component.js +3 -3
- package/dist/collection/components/tabs/tabs-trigger.component.js +8 -8
- package/dist/collection/components/tabs/tabs.component.js +6 -6
- package/dist/collection/components/tabs/tabs.component.js.map +1 -1
- package/dist/collection/components/text/text.component.js +6 -6
- package/dist/collection/components/text/text.css +1 -1
- package/dist/collection/components/textarea/textarea.component.js +39 -40
- package/dist/collection/components/textarea/textarea.component.js.map +1 -1
- package/dist/collection/components/tooltip/tooltip.component.js +567 -192
- package/dist/collection/components/tooltip/tooltip.component.js.map +1 -1
- package/dist/collection/components/tooltip/tooltip.css +1 -1
- package/dist/components/bcm-accordion-group.js +5 -3
- package/dist/components/bcm-accordion-group.js.map +1 -1
- package/dist/components/bcm-accordion.js +6 -4
- package/dist/components/bcm-accordion.js.map +1 -1
- package/dist/components/bcm-alert.js +6 -4
- package/dist/components/bcm-alert.js.map +1 -1
- package/dist/components/bcm-avatar.js +5 -3
- package/dist/components/bcm-avatar.js.map +1 -1
- package/dist/components/bcm-badge.js +1 -1
- package/dist/components/bcm-basic-badge.js +6 -4
- package/dist/components/bcm-basic-badge.js.map +1 -1
- package/dist/components/bcm-button-group.js +6 -4
- package/dist/components/bcm-button-group.js.map +1 -1
- package/dist/components/bcm-button.js +1 -1
- package/dist/components/bcm-checkbox.js +5 -3
- package/dist/components/bcm-checkbox.js.map +1 -1
- package/dist/components/bcm-chip.js +5 -3
- package/dist/components/bcm-chip.js.map +1 -1
- package/dist/components/bcm-divider.js +6 -4
- package/dist/components/bcm-divider.js.map +1 -1
- package/dist/components/bcm-drawer.js +228 -115
- package/dist/components/bcm-drawer.js.map +1 -1
- package/dist/components/bcm-dropdown-item.js +7 -5
- package/dist/components/bcm-dropdown-item.js.map +1 -1
- package/dist/components/bcm-dropdown.js +8 -15
- package/dist/components/bcm-dropdown.js.map +1 -1
- package/dist/components/bcm-input.js +6 -4
- package/dist/components/bcm-input.js.map +1 -1
- package/dist/components/bcm-linked.js +1 -1
- package/dist/components/bcm-modal.js +56 -4
- package/dist/components/bcm-modal.js.map +1 -1
- package/dist/components/bcm-pop-confirm.js +278 -171
- package/dist/components/bcm-pop-confirm.js.map +1 -1
- package/dist/components/bcm-popover.js +355 -110
- package/dist/components/bcm-popover.js.map +1 -1
- package/dist/components/bcm-radio-group.js +6 -4
- package/dist/components/bcm-radio-group.js.map +1 -1
- package/dist/components/bcm-radio.js +5 -3
- package/dist/components/bcm-radio.js.map +1 -1
- package/dist/components/bcm-segmented-picker-option.js +6 -4
- package/dist/components/bcm-segmented-picker-option.js.map +1 -1
- package/dist/components/bcm-segmented-picker.js +6 -4
- package/dist/components/bcm-segmented-picker.js.map +1 -1
- package/dist/components/bcm-shortcut.js +5 -3
- package/dist/components/bcm-shortcut.js.map +1 -1
- package/dist/components/bcm-switch.js +7 -5
- package/dist/components/bcm-switch.js.map +1 -1
- package/dist/components/bcm-tabs-content.js +5 -3
- package/dist/components/bcm-tabs-content.js.map +1 -1
- package/dist/components/bcm-tabs-list.js +5 -3
- package/dist/components/bcm-tabs-list.js.map +1 -1
- package/dist/components/bcm-tabs-trigger.js +5 -3
- package/dist/components/bcm-tabs-trigger.js.map +1 -1
- package/dist/components/bcm-tabs.js +5 -3
- package/dist/components/bcm-tabs.js.map +1 -1
- package/dist/components/bcm-text.js +6 -4
- package/dist/components/bcm-text.js.map +1 -1
- package/dist/components/bcm-textarea.js +7 -5
- package/dist/components/bcm-textarea.js.map +1 -1
- package/dist/components/bcm-tooltip.js +364 -127
- package/dist/components/bcm-tooltip.js.map +1 -1
- package/dist/components/index.js +41 -366
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-6VLsKZvR.js +469 -0
- package/dist/components/p-6VLsKZvR.js.map +1 -0
- package/dist/components/p-BfTCfPZ1.js.map +1 -1
- package/dist/components/p-CEcVC0yX.js.map +1 -1
- package/dist/components/{p-CQF7wlXf.js → p-CaemikSK.js} +8 -6
- package/dist/components/p-CaemikSK.js.map +1 -0
- package/dist/components/{p-DHONP_n4.js → p-CsIBm0J5.js} +9 -7
- package/dist/components/p-CsIBm0J5.js.map +1 -0
- package/dist/components/{p-CzcTU1ty.js → p-DBDSgIvP.js} +40 -23
- package/dist/components/p-DBDSgIvP.js.map +1 -0
- package/dist/components/p-IBjzkjef.js.map +1 -1
- package/dist/esm/bcm-accordion-group.entry.js +2 -4
- package/dist/esm/bcm-accordion.entry.js +3 -5
- package/dist/esm/bcm-accordion.entry.js.map +1 -1
- package/dist/esm/bcm-alert.entry.js +3 -5
- package/dist/esm/bcm-alert.entry.js.map +1 -1
- package/dist/esm/bcm-avatar.entry.js +1 -3
- package/dist/esm/bcm-badge.entry.js +3 -5
- package/dist/esm/bcm-basic-badge.entry.js +3 -5
- package/dist/esm/bcm-button-group.entry.js +3 -5
- package/dist/esm/bcm-button.bcm-drawer.bcm-linked.bcm-modal.bcm-pop-confirm.bcm-popover.bcm-tooltip.entry.js.map +1 -0
- package/dist/esm/bcm-button_7.entry.js +4123 -0
- package/dist/esm/bcm-checkbox.entry.js +2 -4
- package/dist/esm/bcm-chip.entry.js +2 -4
- package/dist/esm/bcm-divider.entry.js +3 -5
- package/dist/esm/bcm-divider.entry.js.map +1 -1
- package/dist/esm/bcm-dropdown-item.entry.js +3 -5
- package/dist/esm/bcm-dropdown.entry.js +3 -13
- package/dist/esm/bcm-dropdown.entry.js.map +1 -1
- package/dist/esm/bcm-input.entry.js +3 -5
- package/dist/esm/bcm-radio-group.entry.js +3 -5
- package/dist/esm/bcm-radio.entry.js +2 -4
- package/dist/esm/bcm-segmented-picker-option.entry.js +3 -5
- package/dist/esm/bcm-segmented-picker-option.entry.js.map +1 -1
- package/dist/esm/bcm-segmented-picker.entry.js +3 -5
- package/dist/esm/bcm-segmented-picker.entry.js.map +1 -1
- package/dist/esm/bcm-shortcut.entry.js +2 -4
- package/dist/esm/bcm-switch.entry.js +4 -6
- package/dist/esm/bcm-switch.entry.js.map +1 -1
- package/dist/esm/bcm-tabs-content.entry.js +2 -4
- package/dist/esm/bcm-tabs-list.entry.js +2 -4
- package/dist/esm/bcm-tabs-trigger.entry.js +2 -4
- package/dist/esm/bcm-tabs.entry.js +2 -4
- package/dist/esm/bcm-tabs.entry.js.map +1 -1
- package/dist/esm/bcm-text.entry.js +3 -5
- package/dist/esm/bcm-text.entry.js.map +1 -1
- package/dist/esm/bcm-textarea.entry.js +4 -6
- package/dist/esm/bromcom-ui.js +4 -6
- package/dist/esm/bromcom-ui.js.map +1 -1
- package/dist/esm/generate-id-IBjzkjef.js.map +1 -1
- package/dist/esm/index-BfTCfPZ1.js.map +1 -1
- package/dist/esm/{index-BuuGCw0z.js → index-CRwAh9Np.js} +62 -372
- package/dist/esm/index-CRwAh9Np.js.map +1 -0
- package/dist/esm/index.js +0 -2
- package/dist/esm/loader.js +3 -5
- package/dist/esm/tv-CEcVC0yX.js.map +1 -1
- package/dist/types/components/accordion-group/types.d.ts +2 -2
- package/dist/types/components/drawer/drawer.component.d.ts +143 -3
- package/dist/types/components/drawer/types.d.ts +1 -1
- package/dist/types/components/dropdown/dropdown.component.d.ts +0 -3
- package/dist/types/components/linked/linked.component.d.ts +152 -36
- package/dist/types/components/modal/modal.component.d.ts +121 -0
- package/dist/types/components/pop-confirm/pop-confirm.component.d.ts +263 -143
- package/dist/types/components/popover/popover.component.d.ts +94 -39
- package/dist/types/components/tooltip/tooltip.component.d.ts +147 -56
- package/dist/types/components.d.ts +1569 -359
- package/dist/types/stencil-public-runtime.d.ts +50 -3
- package/package.json +1 -1
- package/dist/bromcom-ui/bcm-button.bcm-drawer.bcm-modal.entry.esm.js.map +0 -1
- package/dist/bromcom-ui/bcm-linked.entry.esm.js.map +0 -1
- package/dist/bromcom-ui/bcm-pop-confirm.entry.esm.js.map +0 -1
- package/dist/bromcom-ui/bcm-popover.entry.esm.js.map +0 -1
- package/dist/bromcom-ui/bcm-tooltip.entry.esm.js.map +0 -1
- package/dist/bromcom-ui/p-0101b4f2.entry.js.map +0 -1
- package/dist/bromcom-ui/p-089edfdc.entry.js.map +0 -1
- package/dist/bromcom-ui/p-08bc93c5.entry.js +0 -2
- package/dist/bromcom-ui/p-08bc93c5.entry.js.map +0 -1
- package/dist/bromcom-ui/p-09be61c3.entry.js +0 -2
- package/dist/bromcom-ui/p-09be61c3.entry.js.map +0 -1
- package/dist/bromcom-ui/p-11851391.entry.js +0 -2
- package/dist/bromcom-ui/p-11851391.entry.js.map +0 -1
- package/dist/bromcom-ui/p-11f3e129.entry.js.map +0 -1
- package/dist/bromcom-ui/p-211ca6e0.entry.js.map +0 -1
- package/dist/bromcom-ui/p-22edf049.entry.js.map +0 -1
- package/dist/bromcom-ui/p-2480e468.entry.js.map +0 -1
- package/dist/bromcom-ui/p-26d2db9e.entry.js.map +0 -1
- package/dist/bromcom-ui/p-2d0a6472.entry.js +0 -2
- package/dist/bromcom-ui/p-2d0a6472.entry.js.map +0 -1
- package/dist/bromcom-ui/p-360bff8a.entry.js.map +0 -1
- package/dist/bromcom-ui/p-488d6ef4.entry.js.map +0 -1
- package/dist/bromcom-ui/p-5e0702d1.entry.js.map +0 -1
- package/dist/bromcom-ui/p-63228f7e.entry.js +0 -2
- package/dist/bromcom-ui/p-63228f7e.entry.js.map +0 -1
- package/dist/bromcom-ui/p-6b585adc.entry.js.map +0 -1
- package/dist/bromcom-ui/p-6d7d73d5.entry.js +0 -2
- package/dist/bromcom-ui/p-6d7d73d5.entry.js.map +0 -1
- package/dist/bromcom-ui/p-7234af90.entry.js +0 -2
- package/dist/bromcom-ui/p-7234af90.entry.js.map +0 -1
- package/dist/bromcom-ui/p-83f64814.entry.js.map +0 -1
- package/dist/bromcom-ui/p-8ace5a6a.entry.js.map +0 -1
- package/dist/bromcom-ui/p-8d74249a.entry.js +0 -2
- package/dist/bromcom-ui/p-8d74249a.entry.js.map +0 -1
- package/dist/bromcom-ui/p-BuuGCw0z.js +0 -3
- package/dist/bromcom-ui/p-BuuGCw0z.js.map +0 -1
- package/dist/bromcom-ui/p-DxMLMJ3r.js +0 -2
- package/dist/bromcom-ui/p-DxMLMJ3r.js.map +0 -1
- package/dist/bromcom-ui/p-a88f20e0.entry.js.map +0 -1
- package/dist/bromcom-ui/p-bad299f2.entry.js +0 -2
- package/dist/bromcom-ui/p-bad299f2.entry.js.map +0 -1
- package/dist/bromcom-ui/p-bdaf5653.entry.js.map +0 -1
- package/dist/bromcom-ui/p-c0e7f9d6.entry.js.map +0 -1
- package/dist/bromcom-ui/p-c34f0a66.entry.js.map +0 -1
- package/dist/bromcom-ui/p-d7cea19f.entry.js +0 -2
- package/dist/bromcom-ui/p-d7cea19f.entry.js.map +0 -1
- package/dist/bromcom-ui/p-e5e0ac07.entry.js +0 -2
- package/dist/bromcom-ui/p-e5e0ac07.entry.js.map +0 -1
- package/dist/bromcom-ui/p-ee5f877f.entry.js.map +0 -1
- package/dist/bromcom-ui/p-fbccbffc.entry.js +0 -2
- package/dist/bromcom-ui/p-fbccbffc.entry.js.map +0 -1
- package/dist/cjs/bcm-accordion-group.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-accordion.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-alert.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-avatar.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-badge.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-basic-badge.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-button-group.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-button.bcm-drawer.bcm-modal.entry.cjs.js.map +0 -1
- package/dist/cjs/bcm-button_3.cjs.entry.js +0 -794
- package/dist/cjs/bcm-button_3.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-checkbox.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-chip.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-divider.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-dropdown-item.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-dropdown.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-input.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-linked.cjs.entry.js +0 -343
- package/dist/cjs/bcm-linked.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-linked.entry.cjs.js.map +0 -1
- package/dist/cjs/bcm-pop-confirm.cjs.entry.js +0 -250
- package/dist/cjs/bcm-pop-confirm.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-pop-confirm.entry.cjs.js.map +0 -1
- package/dist/cjs/bcm-popover.cjs.entry.js +0 -189
- package/dist/cjs/bcm-popover.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-popover.entry.cjs.js.map +0 -1
- package/dist/cjs/bcm-radio-group.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-radio.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-segmented-picker-option.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-segmented-picker.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-shortcut.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-switch.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tabs-content.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tabs-list.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tabs-trigger.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tabs.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-text.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-textarea.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tooltip.cjs.entry.js +0 -180
- package/dist/cjs/bcm-tooltip.cjs.entry.js.map +0 -1
- package/dist/cjs/bcm-tooltip.entry.cjs.js.map +0 -1
- package/dist/cjs/floating-ui.dom-DyKmFgkP.js +0 -1605
- package/dist/cjs/floating-ui.dom-DyKmFgkP.js.map +0 -1
- package/dist/cjs/index-BtiU-G2W.js.map +0 -1
- package/dist/components/p-BHwftRkk.js +0 -379
- package/dist/components/p-BHwftRkk.js.map +0 -1
- package/dist/components/p-CQF7wlXf.js.map +0 -1
- package/dist/components/p-CzcTU1ty.js.map +0 -1
- package/dist/components/p-DHONP_n4.js.map +0 -1
- package/dist/esm/bcm-button.bcm-drawer.bcm-modal.entry.js.map +0 -1
- package/dist/esm/bcm-button_3.entry.js +0 -790
- package/dist/esm/bcm-button_3.entry.js.map +0 -1
- package/dist/esm/bcm-linked.entry.js +0 -341
- package/dist/esm/bcm-linked.entry.js.map +0 -1
- package/dist/esm/bcm-pop-confirm.entry.js +0 -248
- package/dist/esm/bcm-pop-confirm.entry.js.map +0 -1
- package/dist/esm/bcm-popover.entry.js +0 -187
- package/dist/esm/bcm-popover.entry.js.map +0 -1
- package/dist/esm/bcm-tooltip.entry.js +0 -178
- package/dist/esm/bcm-tooltip.entry.js.map +0 -1
- package/dist/esm/floating-ui.dom-DxMLMJ3r.js +0 -1598
- package/dist/esm/floating-ui.dom-DxMLMJ3r.js.map +0 -1
- package/dist/esm/index-BuuGCw0z.js.map +0 -1
|
@@ -0,0 +1,4131 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-CmYzUr-k.js');
|
|
4
|
+
var tv = require('./tv-ngpIbGlG.js');
|
|
5
|
+
|
|
6
|
+
const variantOptions = {
|
|
7
|
+
save: {
|
|
8
|
+
text: 'Save',
|
|
9
|
+
status: 'success',
|
|
10
|
+
icon: 'far fa-save',
|
|
11
|
+
iconPosition: 'prefix',
|
|
12
|
+
kind: 'primary',
|
|
13
|
+
},
|
|
14
|
+
ok: {
|
|
15
|
+
text: 'Ok',
|
|
16
|
+
status: 'success',
|
|
17
|
+
icon: 'far fa-check',
|
|
18
|
+
iconPosition: 'prefix',
|
|
19
|
+
},
|
|
20
|
+
new: {
|
|
21
|
+
text: 'New',
|
|
22
|
+
status: 'success',
|
|
23
|
+
icon: 'far fa-plus',
|
|
24
|
+
iconPosition: 'prefix',
|
|
25
|
+
},
|
|
26
|
+
add: {
|
|
27
|
+
text: 'Add',
|
|
28
|
+
status: 'success',
|
|
29
|
+
icon: 'far fa-plus',
|
|
30
|
+
iconPosition: 'prefix',
|
|
31
|
+
},
|
|
32
|
+
create: {
|
|
33
|
+
text: 'Create',
|
|
34
|
+
status: 'success',
|
|
35
|
+
icon: 'far fa-plus',
|
|
36
|
+
iconPosition: 'prefix',
|
|
37
|
+
},
|
|
38
|
+
prev: {
|
|
39
|
+
text: 'Prev',
|
|
40
|
+
status: 'default',
|
|
41
|
+
icon: 'far fa-arrow-left',
|
|
42
|
+
iconPosition: 'prefix',
|
|
43
|
+
},
|
|
44
|
+
next: {
|
|
45
|
+
text: 'Next',
|
|
46
|
+
status: 'default',
|
|
47
|
+
icon: 'far fa-arrow-right',
|
|
48
|
+
iconPosition: 'suffix',
|
|
49
|
+
},
|
|
50
|
+
apply: {
|
|
51
|
+
text: 'Apply',
|
|
52
|
+
status: 'default',
|
|
53
|
+
icon: 'far fa-check-circle',
|
|
54
|
+
iconPosition: 'prefix',
|
|
55
|
+
},
|
|
56
|
+
submit: {
|
|
57
|
+
text: 'Submit',
|
|
58
|
+
status: 'default',
|
|
59
|
+
icon: 'far fa-save',
|
|
60
|
+
iconPosition: 'prefix',
|
|
61
|
+
},
|
|
62
|
+
send: {
|
|
63
|
+
text: 'Send',
|
|
64
|
+
status: 'success',
|
|
65
|
+
icon: 'far fa-paper-plane',
|
|
66
|
+
iconPosition: 'prefix',
|
|
67
|
+
},
|
|
68
|
+
delete: {
|
|
69
|
+
text: 'Delete',
|
|
70
|
+
status: 'error',
|
|
71
|
+
icon: 'far fa-trash',
|
|
72
|
+
iconPosition: 'prefix',
|
|
73
|
+
},
|
|
74
|
+
cancel: {
|
|
75
|
+
text: 'Cancel',
|
|
76
|
+
status: 'error',
|
|
77
|
+
icon: 'far fa-times',
|
|
78
|
+
iconPosition: 'prefix',
|
|
79
|
+
},
|
|
80
|
+
decline: {
|
|
81
|
+
text: 'Decline',
|
|
82
|
+
status: 'error',
|
|
83
|
+
icon: 'far fa-ban',
|
|
84
|
+
iconPosition: 'prefix',
|
|
85
|
+
},
|
|
86
|
+
close: {
|
|
87
|
+
text: 'Close',
|
|
88
|
+
status: 'error',
|
|
89
|
+
icon: 'far fa-times-circle',
|
|
90
|
+
iconPosition: 'prefix',
|
|
91
|
+
},
|
|
92
|
+
archive: {
|
|
93
|
+
text: 'Archive',
|
|
94
|
+
status: 'error',
|
|
95
|
+
icon: 'far fa-folder-open',
|
|
96
|
+
iconPosition: 'prefix',
|
|
97
|
+
},
|
|
98
|
+
remove: {
|
|
99
|
+
text: 'Remove',
|
|
100
|
+
status: 'error',
|
|
101
|
+
icon: 'far fa-minus-circle',
|
|
102
|
+
iconPosition: 'prefix',
|
|
103
|
+
},
|
|
104
|
+
edit: {
|
|
105
|
+
text: 'Edit',
|
|
106
|
+
status: 'default',
|
|
107
|
+
icon: 'far fa-edit',
|
|
108
|
+
iconPosition: 'prefix',
|
|
109
|
+
},
|
|
110
|
+
export: {
|
|
111
|
+
text: 'Export',
|
|
112
|
+
status: 'default',
|
|
113
|
+
icon: 'far fa-sign-out',
|
|
114
|
+
iconPosition: 'prefix',
|
|
115
|
+
},
|
|
116
|
+
import: {
|
|
117
|
+
text: 'Import',
|
|
118
|
+
status: 'default',
|
|
119
|
+
icon: 'far fa-sign-in',
|
|
120
|
+
iconPosition: 'prefix',
|
|
121
|
+
},
|
|
122
|
+
filter: {
|
|
123
|
+
text: 'Filter',
|
|
124
|
+
status: 'default',
|
|
125
|
+
icon: 'far fa-filter',
|
|
126
|
+
iconPosition: 'prefix',
|
|
127
|
+
},
|
|
128
|
+
update: {
|
|
129
|
+
text: 'Update',
|
|
130
|
+
status: 'default',
|
|
131
|
+
icon: 'far fa-sync',
|
|
132
|
+
iconPosition: 'prefix',
|
|
133
|
+
},
|
|
134
|
+
reset: {
|
|
135
|
+
text: 'Reset',
|
|
136
|
+
status: 'default',
|
|
137
|
+
icon: 'far fa-sync',
|
|
138
|
+
iconPosition: 'prefix',
|
|
139
|
+
},
|
|
140
|
+
download: {
|
|
141
|
+
text: 'Download',
|
|
142
|
+
status: 'default',
|
|
143
|
+
icon: 'far fa-download',
|
|
144
|
+
iconPosition: 'prefix',
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const buttonCss = ".relative{position:relative}:host{display:inline-flex;height:-moz-fit-content;height:fit-content;position:relative;width:-moz-fit-content;width:fit-content}:host([full-width]){width:100%}:host([position=first]) .bcm-button{border-bottom-right-radius:0;border-top-right-radius:0}:host([position=middle]) .bcm-button{border-radius:0}:host([position=last]) .bcm-button{border-bottom-left-radius:0;border-top-left-radius:0}:host([position=first].orientation-vertical) .bcm-button{border-bottom-left-radius:0;border-bottom-right-radius:0;border-top-left-radius:var(--bcm-ui-border-radius,4px);border-top-right-radius:var(--bcm-ui-border-radius,4px)}:host([position=middle].orientation-vertical) .bcm-button{border-radius:0}:host([position=last].orientation-vertical) .bcm-button{border-bottom-left-radius:var(--bcm-ui-border-radius,4px);border-bottom-right-radius:var(--bcm-ui-border-radius,4px);border-top-left-radius:0;border-top-right-radius:0}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.z-\\[9999\\]{z-index:9999}.m-0{margin:0}.inline-block{display:inline-block}.flex{display:flex}.size-6{height:1.5rem;width:1.5rem}.h-3{height:.75rem}.w-3{width:.75rem}.max-w-64{max-width:16rem}.max-w-80{max-width:20rem}.max-w-96{max-width:24rem}.flex-1{flex:1 1 0%}.rotate-45{--tw-rotate:45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.gap-2{gap:.5rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.text-pretty{text-wrap:pretty}.rounded-full{border-radius:var(--bcm-ui-border-radius-full,9999px)}.rounded-lg{border-radius:var(--bcm-ui-border-radius-lg,8px)}.bg-\\[--popover-bg\\]{background-color:var(--popover-bg)}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.pr-8{padding-right:2rem}.font-sans{font-family:Inter,sans-serif}.text-size-4{font-size:var(--bcm-ui-font-size-4,14px);line-height:var(--bcm-ui-line-height-4,20px)}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.text-size-6{font-size:var(--bcm-ui-font-size-6,18px);line-height:var(--bcm-ui-line-height-6,24px)}.text-size-7{font-size:var(--bcm-ui-font-size-7,20px);line-height:var(--bcm-ui-line-height-7,28px)}.font-semibold{font-weight:600}.\\!text-color-header{color:var(--bcm-ui-color-text-header)!important}.text-\\[var\\(--bcm-ui-color-text-error\\)\\]{color:var(--bcm-ui-color-text-error)}.text-\\[var\\(--bcm-ui-color-text-info\\)\\]{color:var(--bcm-ui-color-text-info)}.text-\\[var\\(--bcm-ui-color-text-success\\)\\]{color:var(--bcm-ui-color-text-success)}.text-\\[var\\(--bcm-ui-color-text-warning\\)\\]{color:var(--bcm-ui-color-text-warning)}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.hover\\:bg-gray-100:hover{background-color:oklch(.967 .003 264.542)}.inline-flex{display:inline-flex}.min-h-10{min-height:2.5rem}.min-h-6{min-height:1.5rem}.min-h-8{min-height:2rem}.w-full{width:100%}.cursor-not-allowed{cursor:not-allowed}.appearance-none{appearance:none}.rounded{border-radius:var(--bcm-ui-border-radius-default,6px)}.border{border-width:1px}.border-solid{border-style:solid}.border-\\[--bcm-final-border-color\\]{border-color:var(--bcm-final-border-color)}.border-color-disabled{border-color:var(--bcm-ui-color-border-disabled)}.bg-\\[--bcm-final-bg-color\\]{background-color:var(--bcm-final-bg-color)}.bg-\\[--bcm-ui-color-background-disabled-default\\]{background-color:var(--bcm-ui-color-background-disabled-default)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-0\\.5{padding-bottom:.125rem;padding-top:.125rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-px{padding-bottom:1px;padding-top:1px}.leading-none{line-height:1}.text-\\[--bcm-final-text-color\\]{color:var(--bcm-final-text-color)}.text-color-disabled{color:var(--bcm-ui-color-text-disabled)}.outline-0{outline-width:0}.hover\\:bg-\\[--bcm-final-hover-bg-color\\]:hover{background-color:var(--bcm-final-hover-bg-color)}.focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}.active\\:bg-\\[--bcm-final-active-bg-color\\]:active{background-color:var(--bcm-final-active-bg-color)}.max-h-64{max-height:16rem}.min-w-10{min-width:2.5rem}.overflow-y-auto{overflow-y:auto}.bg-color-basic-panel{background-color:var(--bcm-ui-color-background-basic-panel)}.py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}";
|
|
149
|
+
|
|
150
|
+
const BcmButton = class {
|
|
151
|
+
constructor(hostRef) {
|
|
152
|
+
index.registerInstance(this, hostRef);
|
|
153
|
+
this.bcmClick = index.createEvent(this, "bcmClick", 1);
|
|
154
|
+
this.bcmFocus = index.createEvent(this, "bcmFocus", 1);
|
|
155
|
+
this.bcmBlur = index.createEvent(this, "bcmBlur", 1);
|
|
156
|
+
/** Defines the main visual style of the button */
|
|
157
|
+
this.kind = 'primary';
|
|
158
|
+
/** Controls the button size */
|
|
159
|
+
this.size = 'medium';
|
|
160
|
+
/** Defines the button's status/state color */
|
|
161
|
+
this.status = 'default';
|
|
162
|
+
/** Icon placement (prefix/suffix) */
|
|
163
|
+
this.iconPosition = 'prefix';
|
|
164
|
+
/** Icon-only button mode */
|
|
165
|
+
this.iconOnly = false;
|
|
166
|
+
/** Full width button */
|
|
167
|
+
this.fullWidth = false;
|
|
168
|
+
/** HTML button type */
|
|
169
|
+
this.type = 'button';
|
|
170
|
+
/** Loading state */
|
|
171
|
+
this.loading = false;
|
|
172
|
+
/** Disabled state */
|
|
173
|
+
this.disabled = false;
|
|
174
|
+
/** Active state */
|
|
175
|
+
this.active = false;
|
|
176
|
+
this.handleClick = (event) => {
|
|
177
|
+
if (!this.disabled && !this.loading) {
|
|
178
|
+
this.bcmClick.emit(event);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
this.handleFocus = (event) => {
|
|
182
|
+
this.bcmFocus.emit(event);
|
|
183
|
+
};
|
|
184
|
+
this.handleBlur = (event) => {
|
|
185
|
+
this.bcmBlur.emit(event);
|
|
186
|
+
};
|
|
187
|
+
this.buttonClass = tv.tv({
|
|
188
|
+
base: 'bcm-button appearance-none inline-flex items-center justify-center border border-solid rounded outline-0',
|
|
189
|
+
variants: {
|
|
190
|
+
size: {
|
|
191
|
+
small: 'text-size-4 py-px px-2 min-h-6',
|
|
192
|
+
medium: 'text-size-5 py-0.5 px-3 min-h-8',
|
|
193
|
+
large: 'text-size-6 py-1 px-3 min-h-10',
|
|
194
|
+
},
|
|
195
|
+
kind: {
|
|
196
|
+
primary: 'kind-primary',
|
|
197
|
+
ghost: 'kind-ghost',
|
|
198
|
+
text: 'kind-text',
|
|
199
|
+
outline: 'kind-outline',
|
|
200
|
+
},
|
|
201
|
+
fullWidth: {
|
|
202
|
+
true: 'full-width w-full',
|
|
203
|
+
},
|
|
204
|
+
disabled: {
|
|
205
|
+
true: 'disabled cursor-not-allowed bg-[--bcm-ui-color-background-disabled-default] text-color-disabled border-color-disabled',
|
|
206
|
+
false: [
|
|
207
|
+
'cursor-pointer',
|
|
208
|
+
'bg-[--bcm-final-bg-color] text-[--bcm-final-text-color] border-[--bcm-final-border-color]',
|
|
209
|
+
'hover:bg-[--bcm-final-hover-bg-color]',
|
|
210
|
+
'active:bg-[--bcm-final-active-bg-color]',
|
|
211
|
+
'focus-visible:ring',
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
loading: {
|
|
215
|
+
true: '',
|
|
216
|
+
},
|
|
217
|
+
position: {
|
|
218
|
+
first: 'position-first',
|
|
219
|
+
middle: 'position-middle',
|
|
220
|
+
last: 'position-last',
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
defaultVariants: {
|
|
224
|
+
size: 'medium',
|
|
225
|
+
kind: 'primary',
|
|
226
|
+
fullWidth: false,
|
|
227
|
+
disabled: false,
|
|
228
|
+
loading: false,
|
|
229
|
+
},
|
|
230
|
+
}, {
|
|
231
|
+
twMerge: false,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
get buttonText() {
|
|
235
|
+
return this.text || (this.variant && variantOptions[this.variant] ? variantOptions[this.variant].text : '');
|
|
236
|
+
}
|
|
237
|
+
get buttonIcon() {
|
|
238
|
+
var _a;
|
|
239
|
+
if (this.variant && ((_a = variantOptions[this.variant]) === null || _a === void 0 ? void 0 : _a.icon)) {
|
|
240
|
+
return {
|
|
241
|
+
icon: variantOptions[this.variant].icon,
|
|
242
|
+
position: variantOptions[this.variant].iconPosition || 'prefix',
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
icon: this.icon,
|
|
247
|
+
position: this.iconPosition,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
get buttonStatus() {
|
|
251
|
+
return this.variant && variantOptions[this.variant] ? variantOptions[this.variant].status : this.status;
|
|
252
|
+
}
|
|
253
|
+
get buttonStyles() {
|
|
254
|
+
const status = this.buttonStatus === 'default' ? 'primary' : this.buttonStatus;
|
|
255
|
+
// These are the internal default styles based on component props (kind, status)
|
|
256
|
+
const kindStyleMap = {
|
|
257
|
+
primary: {
|
|
258
|
+
'--bcm-button-bg': `var(--bcm-ui-color-background-${status}-default)`,
|
|
259
|
+
'--bcm-button-bg-hover': `var(--bcm-ui-color-background-${status}-hover)`,
|
|
260
|
+
'--bcm-button-bg-active': `var(--bcm-ui-color-background-${status}-active)`,
|
|
261
|
+
'--bcm-button-border': 'transparent',
|
|
262
|
+
'--bcm-button-text': 'var(--bcm-ui-color-text-base)',
|
|
263
|
+
},
|
|
264
|
+
outline: {
|
|
265
|
+
'--bcm-button-bg': 'var(--bcm-ui-color-background-default-default)',
|
|
266
|
+
'--bcm-button-bg-hover': 'var(--bcm-ui-color-background-default-hover)',
|
|
267
|
+
'--bcm-button-bg-active': 'var(--bcm-ui-color-background-default-active)',
|
|
268
|
+
'--bcm-button-border': `var(--bcm-ui-color-border-${this.buttonStatus})`,
|
|
269
|
+
'--bcm-button-text': `var(--bcm-ui-color-text-${this.buttonStatus})`,
|
|
270
|
+
},
|
|
271
|
+
ghost: {
|
|
272
|
+
'--bcm-button-bg': 'transparent',
|
|
273
|
+
'--bcm-button-bg-hover': 'var(--bcm-ui-color-background-default-hover)',
|
|
274
|
+
'--bcm-button-bg-active': 'var(--bcm-ui-color-background-default-active)',
|
|
275
|
+
'--bcm-button-border': 'transparent',
|
|
276
|
+
'--bcm-button-text': `var(--bcm-ui-color-text-${this.buttonStatus})`,
|
|
277
|
+
},
|
|
278
|
+
text: {
|
|
279
|
+
'--bcm-button-bg': 'transparent',
|
|
280
|
+
'--bcm-button-bg-hover': 'var(--bcm-ui-color-background-default-hover)',
|
|
281
|
+
'--bcm-button-bg-active': 'var(--bcm-ui-color-background-default-active)',
|
|
282
|
+
'--bcm-button-border': 'transparent',
|
|
283
|
+
'--bcm-button-text': `var(--bcm-ui-color-text-${status})`,
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
const internalDefaultStyles = kindStyleMap[this.kind];
|
|
287
|
+
// These are the "final" CSS custom properties used by the component's styling.
|
|
288
|
+
// They use the "--bcm-button-custom-..." token if provided by the user,
|
|
289
|
+
// otherwise, they fall back to the internal "--bcm-button-..." style defined above.
|
|
290
|
+
const finalEffectiveStyles = {
|
|
291
|
+
'--bcm-final-text-color': `var(--bcm-button-custom-text-color, ${internalDefaultStyles['--bcm-button-text']})`,
|
|
292
|
+
'--bcm-final-border-color': `var(--bcm-button-custom-border-color, ${internalDefaultStyles['--bcm-button-border']})`,
|
|
293
|
+
'--bcm-final-bg-color': `var(--bcm-button-custom-bg-color, ${internalDefaultStyles['--bcm-button-bg']})`,
|
|
294
|
+
'--bcm-final-hover-bg-color': `var(--bcm-button-custom-hover-bg-color, ${internalDefaultStyles['--bcm-button-bg-hover']})`,
|
|
295
|
+
'--bcm-final-active-bg-color': `var(--bcm-button-custom-active-bg-color, ${internalDefaultStyles['--bcm-button-bg-active']})`,
|
|
296
|
+
};
|
|
297
|
+
// return kindStyleMap[this.kind];
|
|
298
|
+
return Object.assign(Object.assign({}, internalDefaultStyles), finalEffectiveStyles);
|
|
299
|
+
}
|
|
300
|
+
render() {
|
|
301
|
+
const { icon, position } = this.buttonIcon;
|
|
302
|
+
return (index.h(index.Host, { key: 'a11591319f31f3ecfe6d1db5f5137f537b7cf71b' }, index.h("button", { key: 'e7e7876b08b2d2b82fedc97ee6d1135e886044cb', type: this.type, disabled: this.disabled || this.loading, "aria-label": this.label, "aria-expanded": this.expanded, "aria-controls": this.controls, "aria-disabled": this.disabled, onClick: this.handleClick, onFocus: this.handleFocus, onBlur: this.handleBlur, style: this.buttonStyles, class: this.buttonClass({
|
|
303
|
+
size: this.size,
|
|
304
|
+
kind: this.kind,
|
|
305
|
+
fullWidth: this.fullWidth,
|
|
306
|
+
disabled: this.disabled,
|
|
307
|
+
loading: this.loading,
|
|
308
|
+
position: this.position,
|
|
309
|
+
}) }, this.loading && index.h("slot", { key: 'c8b923e0fcb64f9c299602ab8a6ea1e25aaf5c8d', name: "loading" }), index.h("span", { key: '838f85afd0355eec4c7dea0e1ae02ffa98e8e260' }, index.h("slot", { key: '5f65cf6f40096595d6affcb4c30cde9eef0d7614', name: "prefix" }, position === 'prefix' && icon && index.h("i", { key: '96425b8dd1396ef268e30c6f209b495bf7f5f6d6', class: ' leading-none ' + icon }))), index.h("slot", { key: 'a34f07f25c2d06aa7a60673ac0e1329063a6887a' }, this.buttonText), index.h("span", { key: 'a375ba2ac1411a82850b60074fdc561272bdeda6' }, index.h("slot", { key: '8fc1cfcdcee4c9339b4894900c5a1e03e75820b0', name: "suffix" }, position === 'suffix' && icon && index.h("i", { key: 'd8f5b40843d278ad2cfc0260b0a071f42d5f73a5', class: ' leading-none ' + icon }))))));
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
BcmButton.style = buttonCss;
|
|
313
|
+
|
|
314
|
+
const drawerCss = ".contents{display:contents}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}:host{display:contents}[part=dialog]::backdrop{animation:backdrop-fade-in .2s ease-out}@keyframes backdrop-fade-in{0%{opacity:0}to{opacity:.5}}[part=drawer]{transition:transform .2s ease-out}:host([position=left]) [part=drawer]{transform:translateX(-20px)}:host([position=left][open]) [part=drawer]{transform:translateX(0)}:host([position=right]) [part=drawer]{transform:translateX(20px)}:host([position=right][open]) [part=drawer]{transform:translateX(0)}:host([position=top]) [part=drawer]{transform:translateY(-20px)}:host([position=top][open]) [part=drawer]{transform:translateY(0)}:host([position=bottom]) [part=drawer]{transform:translateY(20px)}:host([position=bottom][open]) [part=drawer]{transform:translateY(0)}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:0}.m-0{margin:0}.flex{display:flex}.hidden{display:none}.h-6{height:1.5rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-full{max-height:100%}.max-h-none{max-height:none}.w-6{width:1.5rem}.w-full{width:100%}.w-screen{width:100vw}.min-w-0{min-width:0}.max-w-full{max-width:100%}.max-w-none{max-width:none}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.flex-grow{flex-grow:1}.animate-shake{animation:shake .82s cubic-bezier(.36,.07,.19,.97) infinite;animation:shake .3s cubic-bezier(.36,.07,.19,.97) both}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:var(--bcm-ui-border-radius-default,6px)}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-t{border-top-width:1px}.border-solid{border-style:solid}.border-none{border-style:none}.border-color-default{border-color:var(--bcm-ui-color-border-default)}.bg-color-base{background-color:var(--bcm-ui-color-background-base-default)}.bg-transparent{background-color:transparent}.p-0{padding:0}.p-4{padding:1rem}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.text-size-6{font-size:var(--bcm-ui-font-size-6,18px);line-height:var(--bcm-ui-line-height-6,24px)}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-color-default{color:var(--bcm-ui-color-text-default)}.text-color-header{color:var(--bcm-ui-color-text-header)}.text-color-placeholder{color:var(--bcm-ui-color-text-placeholder)}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-2xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-2xl{--tw-shadow:var(--bcm-ui-box-shadow-2xl);--tw-shadow-colored:var(--bcm-ui-box-shadow-2xl)}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.backdrop\\:bg-color-default-dark::backdrop{background-color:var(--bcm-ui-color-background-default-dark-default)}.backdrop\\:opacity-50::backdrop{opacity:.5}.hover\\:bg-color-default-hover:hover{background-color:var(--bcm-ui-color-background-default-hover)}.focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}";
|
|
315
|
+
|
|
316
|
+
const BcmDrawer = class {
|
|
317
|
+
constructor(hostRef) {
|
|
318
|
+
index.registerInstance(this, hostRef);
|
|
319
|
+
this.bcmOpen = index.createEvent(this, "bcmOpen", 7);
|
|
320
|
+
this.bcmClose = index.createEvent(this, "bcmClose", 7);
|
|
321
|
+
this.bcmBeforeOpen = index.createEvent(this, "bcmBeforeOpen", 7);
|
|
322
|
+
this.bcmBeforeClose = index.createEvent(this, "bcmBeforeClose", 7);
|
|
323
|
+
/**
|
|
324
|
+
* Controls whether the drawer is open or closed
|
|
325
|
+
*/
|
|
326
|
+
this.open = false;
|
|
327
|
+
/**
|
|
328
|
+
* The size of the drawer. Can be a preset value or a custom CSS size
|
|
329
|
+
* - For left/right drawers:
|
|
330
|
+
* - 'small': 320px
|
|
331
|
+
* - 'medium': 480px
|
|
332
|
+
* - 'large': 1064px
|
|
333
|
+
* - For top/bottom drawers:
|
|
334
|
+
* - 'small': 40vh
|
|
335
|
+
* - 'medium': 60vh
|
|
336
|
+
* - 'large': 90vh
|
|
337
|
+
* - Custom values: Any valid CSS size (e.g., '600px', '50%', '30rem', '80vw')
|
|
338
|
+
*/
|
|
339
|
+
this.size = 'medium';
|
|
340
|
+
/**
|
|
341
|
+
* The position where the drawer slides in from
|
|
342
|
+
* - 'left': Slides from the left edge
|
|
343
|
+
* - 'right': Slides from the right edge
|
|
344
|
+
* - 'top': Slides from the top edge
|
|
345
|
+
* - 'bottom': Slides from the bottom edge
|
|
346
|
+
*/
|
|
347
|
+
this.position = 'right';
|
|
348
|
+
/**
|
|
349
|
+
* Makes the drawer take full width (for left/right) or full height (for top/bottom)
|
|
350
|
+
*/
|
|
351
|
+
this.fullWidth = false;
|
|
352
|
+
/**
|
|
353
|
+
* Makes the drawer take the full screen (100vw x 100vh)
|
|
354
|
+
*/
|
|
355
|
+
this.fullScreen = false;
|
|
356
|
+
/**
|
|
357
|
+
* Controls backdrop behavior
|
|
358
|
+
* - true: Shows backdrop, drawer can be closed by clicking outside
|
|
359
|
+
* - false: No backdrop
|
|
360
|
+
* - 'static': Shows backdrop but prevents closing by clicking outside (triggers shake animation)
|
|
361
|
+
*/
|
|
362
|
+
this.backdrop = true;
|
|
363
|
+
/**
|
|
364
|
+
* Hides the header section completely
|
|
365
|
+
*/
|
|
366
|
+
this.noHeader = false;
|
|
367
|
+
/**
|
|
368
|
+
* Hides the footer section completely
|
|
369
|
+
*/
|
|
370
|
+
this.noFooter = false;
|
|
371
|
+
/**
|
|
372
|
+
* Allows closing the drawer by clicking on the backdrop
|
|
373
|
+
*/
|
|
374
|
+
this.closeOnBackdrop = true;
|
|
375
|
+
/**
|
|
376
|
+
* Allows closing the drawer by pressing the Escape key
|
|
377
|
+
*/
|
|
378
|
+
this.closeOnEscape = true;
|
|
379
|
+
this.shake = false;
|
|
380
|
+
this.drawerClass = tv.tv({
|
|
381
|
+
slots: {
|
|
382
|
+
dialog: 'bcm-ui-element fixed inset-0 m-0 p-0 w-full max-w-full h-full max-h-full border-none bg-transparent backdrop:bg-color-default-dark backdrop:opacity-50',
|
|
383
|
+
container: 'fixed inset-0 flex overflow-hidden',
|
|
384
|
+
drawer: 'relative bg-color-base text-color-default shadow-2xl flex flex-col',
|
|
385
|
+
header: 'flex justify-between items-start bg-color-base text-color-default border-color-default border-solid border-0 py-3 px-4',
|
|
386
|
+
headerContent: 'flex-1 min-w-0 flex items-center gap-2',
|
|
387
|
+
title: 'font-semibold m-0 text-size-6 text-color-header',
|
|
388
|
+
helperText: 'text-size-5 text-color-placeholder m-0',
|
|
389
|
+
closeButton: 'text-size-5 font-medium text-color-default bg-transparent border-none p-0 h-6 w-6 rounded hover:bg-color-default-hover cursor-pointer active:bg-color-active transition-colors flex-shrink-0 outline-none focus-visible:ring',
|
|
390
|
+
content: 'flex-grow overflow-y-auto p-4',
|
|
391
|
+
footer: 'flex items-center justify-end gap-2 py-3 px-4',
|
|
392
|
+
},
|
|
393
|
+
variants: {
|
|
394
|
+
position: {
|
|
395
|
+
left: {
|
|
396
|
+
container: 'justify-start',
|
|
397
|
+
drawer: 'h-full',
|
|
398
|
+
header: 'border-b',
|
|
399
|
+
},
|
|
400
|
+
right: {
|
|
401
|
+
container: 'justify-end',
|
|
402
|
+
drawer: 'h-full',
|
|
403
|
+
header: 'border-b',
|
|
404
|
+
},
|
|
405
|
+
top: {
|
|
406
|
+
container: 'items-start',
|
|
407
|
+
drawer: 'w-full',
|
|
408
|
+
header: 'border-b',
|
|
409
|
+
},
|
|
410
|
+
bottom: {
|
|
411
|
+
container: 'items-end',
|
|
412
|
+
drawer: 'w-full',
|
|
413
|
+
header: 'border-t',
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
fullScreen: {
|
|
417
|
+
true: {
|
|
418
|
+
drawer: 'w-screen h-screen max-w-none max-h-none',
|
|
419
|
+
container: 'p-0',
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
shake: {
|
|
423
|
+
true: {
|
|
424
|
+
drawer: 'animate-shake',
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
noHeader: {
|
|
428
|
+
true: {
|
|
429
|
+
header: 'hidden',
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
noFooter: {
|
|
433
|
+
true: {
|
|
434
|
+
footer: 'hidden',
|
|
435
|
+
},
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
this.handleBackdropClick = (event) => {
|
|
440
|
+
const target = event.target;
|
|
441
|
+
// Check if click is on the container (backdrop area), not on drawer content
|
|
442
|
+
if (target.getAttribute('part') === 'container') {
|
|
443
|
+
if (this.backdrop === 'static') {
|
|
444
|
+
this.shakeDrawer();
|
|
445
|
+
}
|
|
446
|
+
else if (this.closeOnBackdrop) {
|
|
447
|
+
this.hide();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
this.handleDialogCancel = (event) => {
|
|
452
|
+
event.preventDefault();
|
|
453
|
+
if (this.backdrop === 'static') {
|
|
454
|
+
this.shakeDrawer();
|
|
455
|
+
// Force dialog to stay open for static backdrop
|
|
456
|
+
requestAnimationFrame(() => {
|
|
457
|
+
if (this.dialogRef && !this.dialogRef.open && this.open) {
|
|
458
|
+
this.dialogRef.showModal();
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
else if (this.closeOnEscape) {
|
|
463
|
+
this.hide();
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
this.handleDrawerClick = (e) => {
|
|
467
|
+
e.stopPropagation();
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
handleOpenChange(isOpen) {
|
|
471
|
+
if (isOpen) {
|
|
472
|
+
const event = this.bcmBeforeOpen.emit();
|
|
473
|
+
if (event.defaultPrevented) {
|
|
474
|
+
this.open = false;
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (this.dialogRef) {
|
|
478
|
+
if (!this.dialogRef.open) {
|
|
479
|
+
this.dialogRef.showModal();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
this.bcmOpen.emit();
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
const event = this.bcmBeforeClose.emit();
|
|
486
|
+
if (event.defaultPrevented) {
|
|
487
|
+
this.open = true;
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (this.dialogRef && this.dialogRef.open) {
|
|
491
|
+
this.dialogRef.close();
|
|
492
|
+
}
|
|
493
|
+
this.bcmClose.emit();
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
handleClick(event) {
|
|
497
|
+
const path = event.composedPath();
|
|
498
|
+
const dismissElement = path.find(el => { var _a; return (_a = el.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(el, 'data-dismiss'); });
|
|
499
|
+
if (dismissElement) {
|
|
500
|
+
this.hide();
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
event.stopPropagation();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Programmatically opens the drawer
|
|
507
|
+
*/
|
|
508
|
+
async show() {
|
|
509
|
+
this.open = true;
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Programmatically closes the drawer
|
|
513
|
+
*/
|
|
514
|
+
async hide() {
|
|
515
|
+
this.open = false;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Toggles the drawer open/closed state
|
|
519
|
+
*/
|
|
520
|
+
async toggle() {
|
|
521
|
+
this.open = !this.open;
|
|
522
|
+
}
|
|
523
|
+
shakeDrawer() {
|
|
524
|
+
this.shake = true;
|
|
525
|
+
setTimeout(() => {
|
|
526
|
+
this.shake = false;
|
|
527
|
+
}, 300);
|
|
528
|
+
}
|
|
529
|
+
componentDidLoad() {
|
|
530
|
+
if (this.open && this.dialogRef) {
|
|
531
|
+
this.dialogRef.showModal();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
disconnectedCallback() {
|
|
535
|
+
if (this.dialogRef && this.open) {
|
|
536
|
+
this.dialogRef.close();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
getDrawerStyle() {
|
|
540
|
+
const style = {};
|
|
541
|
+
if (this.fullScreen) {
|
|
542
|
+
style.width = '100vw';
|
|
543
|
+
style.height = '100vh';
|
|
544
|
+
style.maxWidth = 'none';
|
|
545
|
+
style.maxHeight = 'none';
|
|
546
|
+
return style;
|
|
547
|
+
}
|
|
548
|
+
if (this.fullWidth) {
|
|
549
|
+
if (this.position === 'left' || this.position === 'right') {
|
|
550
|
+
style.width = '100vw';
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
style.height = '100vh';
|
|
554
|
+
}
|
|
555
|
+
return style;
|
|
556
|
+
}
|
|
557
|
+
// Check if size is a custom value (contains px, %, rem, etc.)
|
|
558
|
+
const isCustomSize = this.size && (this.size.includes('px') || this.size.includes('%') || this.size.includes('rem') || this.size.includes('em') || this.size.includes('vw') || this.size.includes('vh'));
|
|
559
|
+
if (this.position === 'left' || this.position === 'right') {
|
|
560
|
+
if (isCustomSize) {
|
|
561
|
+
style.width = this.size;
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
switch (this.size) {
|
|
565
|
+
case 'small':
|
|
566
|
+
style.width = '320px';
|
|
567
|
+
break;
|
|
568
|
+
case 'medium':
|
|
569
|
+
style.width = '480px';
|
|
570
|
+
break;
|
|
571
|
+
case 'large':
|
|
572
|
+
style.width = '1064px';
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
if (isCustomSize) {
|
|
579
|
+
style.height = this.size;
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
switch (this.size) {
|
|
583
|
+
case 'small':
|
|
584
|
+
style.height = '40vh';
|
|
585
|
+
break;
|
|
586
|
+
case 'medium':
|
|
587
|
+
style.height = '60vh';
|
|
588
|
+
break;
|
|
589
|
+
case 'large':
|
|
590
|
+
style.height = '90vh';
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
return style;
|
|
596
|
+
}
|
|
597
|
+
render() {
|
|
598
|
+
const { dialog, container, drawer, header, headerContent, title, helperText, closeButton, content, footer } = this.drawerClass({
|
|
599
|
+
position: this.position,
|
|
600
|
+
fullScreen: this.fullScreen,
|
|
601
|
+
shake: this.shake,
|
|
602
|
+
noHeader: this.noHeader,
|
|
603
|
+
noFooter: this.noFooter,
|
|
604
|
+
});
|
|
605
|
+
return (index.h("dialog", { key: '2b60e637660a9aaed3d1223114d2f0df4c66bb44', ref: el => (this.dialogRef = el), part: "dialog", class: dialog(), onClick: this.handleBackdropClick, onCancel: this.handleDialogCancel, "aria-labelledby": "drawer-title", "aria-describedby": this.helperText ? 'drawer-helper' : undefined, "aria-modal": "true" }, index.h("div", { key: 'd08f1664dfc39e62bc0cf499b5976af0e14310da', part: "container", class: container() }, index.h("div", { key: 'ec18449ff5552177551606c5fdd48ce9116fd287', part: "drawer", class: drawer(), style: this.getDrawerStyle(), role: "document", onClick: this.handleDrawerClick }, !this.noHeader && (index.h("div", { key: '43a3e3afd31c5db5cf9c616f01a3212ec6e3472b', part: "header", class: header() }, index.h("div", { key: 'bb3d4eea627e0425422015cc400ccea81c70a1a5', part: "header-content", class: headerContent() }, index.h("h2", { key: '5c5cbd204a44f31171b932fba0932bfcba89e255', id: "drawer-title", part: "title", class: title() }, index.h("slot", { key: 'c8785c89adb151666c76c158c82f3e9ca6666199', name: "header" }, this.headerText)), this.helperText && (index.h("p", { key: '2ca315ad22086559305dc0cdcd63f32115a4f721', id: "drawer-helper", part: "helper-text", class: helperText() }, index.h("slot", { key: '93dcafee1e25675a0e72b53d9d6c848fd63c2f86', name: "helper" }, this.helperText)))), index.h("button", { key: '1eb3d5b2e9ac607bd1642ca9f067064bf376ce97', part: "close-button", class: closeButton(), onClick: () => this.hide(), "aria-label": "Close drawer", type: "button" }, index.h("bcm-icon", { key: '0c48991f9d68c874b78384de0d8a3bd15b27f363', name: "fa-solid fa-xmark" })))), index.h("div", { key: 'd34a886ca003e38bc84b86185fd0b5690954fd9f', part: "content", class: content() }, index.h("slot", { key: '1c3978b0a66f122b5d4ee5582ed0458c6fc16c73' })), !this.noFooter && (index.h("div", { key: 'db5faf3da663d11455299840e33732995aa75cf0', part: "footer", class: footer() }, index.h("slot", { key: '4836d78626ec999eb8f0aa8585d20df48a677f72', name: "footer" })))))));
|
|
606
|
+
}
|
|
607
|
+
get host() { return index.getElement(this); }
|
|
608
|
+
static get watchers() { return {
|
|
609
|
+
"open": ["handleOpenChange"]
|
|
610
|
+
}; }
|
|
611
|
+
};
|
|
612
|
+
BcmDrawer.style = drawerCss;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Custom positioning reference element.
|
|
616
|
+
* @see https://floating-ui.com/docs/virtual-elements
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
const min = Math.min;
|
|
620
|
+
const max = Math.max;
|
|
621
|
+
const round = Math.round;
|
|
622
|
+
const floor = Math.floor;
|
|
623
|
+
const createCoords = v => ({
|
|
624
|
+
x: v,
|
|
625
|
+
y: v
|
|
626
|
+
});
|
|
627
|
+
const oppositeSideMap = {
|
|
628
|
+
left: 'right',
|
|
629
|
+
right: 'left',
|
|
630
|
+
bottom: 'top',
|
|
631
|
+
top: 'bottom'
|
|
632
|
+
};
|
|
633
|
+
const oppositeAlignmentMap = {
|
|
634
|
+
start: 'end',
|
|
635
|
+
end: 'start'
|
|
636
|
+
};
|
|
637
|
+
function clamp(start, value, end) {
|
|
638
|
+
return max(start, min(value, end));
|
|
639
|
+
}
|
|
640
|
+
function evaluate(value, param) {
|
|
641
|
+
return typeof value === 'function' ? value(param) : value;
|
|
642
|
+
}
|
|
643
|
+
function getSide(placement) {
|
|
644
|
+
return placement.split('-')[0];
|
|
645
|
+
}
|
|
646
|
+
function getAlignment(placement) {
|
|
647
|
+
return placement.split('-')[1];
|
|
648
|
+
}
|
|
649
|
+
function getOppositeAxis(axis) {
|
|
650
|
+
return axis === 'x' ? 'y' : 'x';
|
|
651
|
+
}
|
|
652
|
+
function getAxisLength(axis) {
|
|
653
|
+
return axis === 'y' ? 'height' : 'width';
|
|
654
|
+
}
|
|
655
|
+
const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
|
|
656
|
+
function getSideAxis(placement) {
|
|
657
|
+
return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
|
|
658
|
+
}
|
|
659
|
+
function getAlignmentAxis(placement) {
|
|
660
|
+
return getOppositeAxis(getSideAxis(placement));
|
|
661
|
+
}
|
|
662
|
+
function getAlignmentSides(placement, rects, rtl) {
|
|
663
|
+
if (rtl === void 0) {
|
|
664
|
+
rtl = false;
|
|
665
|
+
}
|
|
666
|
+
const alignment = getAlignment(placement);
|
|
667
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
668
|
+
const length = getAxisLength(alignmentAxis);
|
|
669
|
+
let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
|
|
670
|
+
if (rects.reference[length] > rects.floating[length]) {
|
|
671
|
+
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
672
|
+
}
|
|
673
|
+
return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
|
|
674
|
+
}
|
|
675
|
+
function getExpandedPlacements(placement) {
|
|
676
|
+
const oppositePlacement = getOppositePlacement(placement);
|
|
677
|
+
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
678
|
+
}
|
|
679
|
+
function getOppositeAlignmentPlacement(placement) {
|
|
680
|
+
return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
|
|
681
|
+
}
|
|
682
|
+
const lrPlacement = ['left', 'right'];
|
|
683
|
+
const rlPlacement = ['right', 'left'];
|
|
684
|
+
const tbPlacement = ['top', 'bottom'];
|
|
685
|
+
const btPlacement = ['bottom', 'top'];
|
|
686
|
+
function getSideList(side, isStart, rtl) {
|
|
687
|
+
switch (side) {
|
|
688
|
+
case 'top':
|
|
689
|
+
case 'bottom':
|
|
690
|
+
if (rtl) return isStart ? rlPlacement : lrPlacement;
|
|
691
|
+
return isStart ? lrPlacement : rlPlacement;
|
|
692
|
+
case 'left':
|
|
693
|
+
case 'right':
|
|
694
|
+
return isStart ? tbPlacement : btPlacement;
|
|
695
|
+
default:
|
|
696
|
+
return [];
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
|
|
700
|
+
const alignment = getAlignment(placement);
|
|
701
|
+
let list = getSideList(getSide(placement), direction === 'start', rtl);
|
|
702
|
+
if (alignment) {
|
|
703
|
+
list = list.map(side => side + "-" + alignment);
|
|
704
|
+
if (flipAlignment) {
|
|
705
|
+
list = list.concat(list.map(getOppositeAlignmentPlacement));
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return list;
|
|
709
|
+
}
|
|
710
|
+
function getOppositePlacement(placement) {
|
|
711
|
+
return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
|
|
712
|
+
}
|
|
713
|
+
function expandPaddingObject(padding) {
|
|
714
|
+
return {
|
|
715
|
+
top: 0,
|
|
716
|
+
right: 0,
|
|
717
|
+
bottom: 0,
|
|
718
|
+
left: 0,
|
|
719
|
+
...padding
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function getPaddingObject(padding) {
|
|
723
|
+
return typeof padding !== 'number' ? expandPaddingObject(padding) : {
|
|
724
|
+
top: padding,
|
|
725
|
+
right: padding,
|
|
726
|
+
bottom: padding,
|
|
727
|
+
left: padding
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
function rectToClientRect(rect) {
|
|
731
|
+
const {
|
|
732
|
+
x,
|
|
733
|
+
y,
|
|
734
|
+
width,
|
|
735
|
+
height
|
|
736
|
+
} = rect;
|
|
737
|
+
return {
|
|
738
|
+
width,
|
|
739
|
+
height,
|
|
740
|
+
top: y,
|
|
741
|
+
left: x,
|
|
742
|
+
right: x + width,
|
|
743
|
+
bottom: y + height,
|
|
744
|
+
x,
|
|
745
|
+
y
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
750
|
+
let {
|
|
751
|
+
reference,
|
|
752
|
+
floating
|
|
753
|
+
} = _ref;
|
|
754
|
+
const sideAxis = getSideAxis(placement);
|
|
755
|
+
const alignmentAxis = getAlignmentAxis(placement);
|
|
756
|
+
const alignLength = getAxisLength(alignmentAxis);
|
|
757
|
+
const side = getSide(placement);
|
|
758
|
+
const isVertical = sideAxis === 'y';
|
|
759
|
+
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
760
|
+
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
761
|
+
const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
|
|
762
|
+
let coords;
|
|
763
|
+
switch (side) {
|
|
764
|
+
case 'top':
|
|
765
|
+
coords = {
|
|
766
|
+
x: commonX,
|
|
767
|
+
y: reference.y - floating.height
|
|
768
|
+
};
|
|
769
|
+
break;
|
|
770
|
+
case 'bottom':
|
|
771
|
+
coords = {
|
|
772
|
+
x: commonX,
|
|
773
|
+
y: reference.y + reference.height
|
|
774
|
+
};
|
|
775
|
+
break;
|
|
776
|
+
case 'right':
|
|
777
|
+
coords = {
|
|
778
|
+
x: reference.x + reference.width,
|
|
779
|
+
y: commonY
|
|
780
|
+
};
|
|
781
|
+
break;
|
|
782
|
+
case 'left':
|
|
783
|
+
coords = {
|
|
784
|
+
x: reference.x - floating.width,
|
|
785
|
+
y: commonY
|
|
786
|
+
};
|
|
787
|
+
break;
|
|
788
|
+
default:
|
|
789
|
+
coords = {
|
|
790
|
+
x: reference.x,
|
|
791
|
+
y: reference.y
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
switch (getAlignment(placement)) {
|
|
795
|
+
case 'start':
|
|
796
|
+
coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
797
|
+
break;
|
|
798
|
+
case 'end':
|
|
799
|
+
coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
return coords;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
807
|
+
* next to a given reference element.
|
|
808
|
+
*
|
|
809
|
+
* This export does not have any `platform` interface logic. You will need to
|
|
810
|
+
* write one for the platform you are using Floating UI with.
|
|
811
|
+
*/
|
|
812
|
+
const computePosition$1 = async (reference, floating, config) => {
|
|
813
|
+
const {
|
|
814
|
+
placement = 'bottom',
|
|
815
|
+
strategy = 'absolute',
|
|
816
|
+
middleware = [],
|
|
817
|
+
platform
|
|
818
|
+
} = config;
|
|
819
|
+
const validMiddleware = middleware.filter(Boolean);
|
|
820
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
|
|
821
|
+
let rects = await platform.getElementRects({
|
|
822
|
+
reference,
|
|
823
|
+
floating,
|
|
824
|
+
strategy
|
|
825
|
+
});
|
|
826
|
+
let {
|
|
827
|
+
x,
|
|
828
|
+
y
|
|
829
|
+
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
830
|
+
let statefulPlacement = placement;
|
|
831
|
+
let middlewareData = {};
|
|
832
|
+
let resetCount = 0;
|
|
833
|
+
for (let i = 0; i < validMiddleware.length; i++) {
|
|
834
|
+
const {
|
|
835
|
+
name,
|
|
836
|
+
fn
|
|
837
|
+
} = validMiddleware[i];
|
|
838
|
+
const {
|
|
839
|
+
x: nextX,
|
|
840
|
+
y: nextY,
|
|
841
|
+
data,
|
|
842
|
+
reset
|
|
843
|
+
} = await fn({
|
|
844
|
+
x,
|
|
845
|
+
y,
|
|
846
|
+
initialPlacement: placement,
|
|
847
|
+
placement: statefulPlacement,
|
|
848
|
+
strategy,
|
|
849
|
+
middlewareData,
|
|
850
|
+
rects,
|
|
851
|
+
platform,
|
|
852
|
+
elements: {
|
|
853
|
+
reference,
|
|
854
|
+
floating
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
x = nextX != null ? nextX : x;
|
|
858
|
+
y = nextY != null ? nextY : y;
|
|
859
|
+
middlewareData = {
|
|
860
|
+
...middlewareData,
|
|
861
|
+
[name]: {
|
|
862
|
+
...middlewareData[name],
|
|
863
|
+
...data
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
if (reset && resetCount <= 50) {
|
|
867
|
+
resetCount++;
|
|
868
|
+
if (typeof reset === 'object') {
|
|
869
|
+
if (reset.placement) {
|
|
870
|
+
statefulPlacement = reset.placement;
|
|
871
|
+
}
|
|
872
|
+
if (reset.rects) {
|
|
873
|
+
rects = reset.rects === true ? await platform.getElementRects({
|
|
874
|
+
reference,
|
|
875
|
+
floating,
|
|
876
|
+
strategy
|
|
877
|
+
}) : reset.rects;
|
|
878
|
+
}
|
|
879
|
+
({
|
|
880
|
+
x,
|
|
881
|
+
y
|
|
882
|
+
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
883
|
+
}
|
|
884
|
+
i = -1;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
x,
|
|
889
|
+
y,
|
|
890
|
+
placement: statefulPlacement,
|
|
891
|
+
strategy,
|
|
892
|
+
middlewareData
|
|
893
|
+
};
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Resolves with an object of overflow side offsets that determine how much the
|
|
898
|
+
* element is overflowing a given clipping boundary on each side.
|
|
899
|
+
* - positive = overflowing the boundary by that number of pixels
|
|
900
|
+
* - negative = how many pixels left before it will overflow
|
|
901
|
+
* - 0 = lies flush with the boundary
|
|
902
|
+
* @see https://floating-ui.com/docs/detectOverflow
|
|
903
|
+
*/
|
|
904
|
+
async function detectOverflow(state, options) {
|
|
905
|
+
var _await$platform$isEle;
|
|
906
|
+
if (options === void 0) {
|
|
907
|
+
options = {};
|
|
908
|
+
}
|
|
909
|
+
const {
|
|
910
|
+
x,
|
|
911
|
+
y,
|
|
912
|
+
platform,
|
|
913
|
+
rects,
|
|
914
|
+
elements,
|
|
915
|
+
strategy
|
|
916
|
+
} = state;
|
|
917
|
+
const {
|
|
918
|
+
boundary = 'clippingAncestors',
|
|
919
|
+
rootBoundary = 'viewport',
|
|
920
|
+
elementContext = 'floating',
|
|
921
|
+
altBoundary = false,
|
|
922
|
+
padding = 0
|
|
923
|
+
} = evaluate(options, state);
|
|
924
|
+
const paddingObject = getPaddingObject(padding);
|
|
925
|
+
const altContext = elementContext === 'floating' ? 'reference' : 'floating';
|
|
926
|
+
const element = elements[altBoundary ? altContext : elementContext];
|
|
927
|
+
const clippingClientRect = rectToClientRect(await platform.getClippingRect({
|
|
928
|
+
element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
|
|
929
|
+
boundary,
|
|
930
|
+
rootBoundary,
|
|
931
|
+
strategy
|
|
932
|
+
}));
|
|
933
|
+
const rect = elementContext === 'floating' ? {
|
|
934
|
+
x,
|
|
935
|
+
y,
|
|
936
|
+
width: rects.floating.width,
|
|
937
|
+
height: rects.floating.height
|
|
938
|
+
} : rects.reference;
|
|
939
|
+
const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
|
|
940
|
+
const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
|
|
941
|
+
x: 1,
|
|
942
|
+
y: 1
|
|
943
|
+
} : {
|
|
944
|
+
x: 1,
|
|
945
|
+
y: 1
|
|
946
|
+
};
|
|
947
|
+
const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
948
|
+
elements,
|
|
949
|
+
rect,
|
|
950
|
+
offsetParent,
|
|
951
|
+
strategy
|
|
952
|
+
}) : rect);
|
|
953
|
+
return {
|
|
954
|
+
top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
|
|
955
|
+
bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
|
|
956
|
+
left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
|
|
957
|
+
right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Provides data to position an inner element of the floating element so that it
|
|
963
|
+
* appears centered to the reference element.
|
|
964
|
+
* @see https://floating-ui.com/docs/arrow
|
|
965
|
+
*/
|
|
966
|
+
const arrow$1 = options => ({
|
|
967
|
+
name: 'arrow',
|
|
968
|
+
options,
|
|
969
|
+
async fn(state) {
|
|
970
|
+
const {
|
|
971
|
+
x,
|
|
972
|
+
y,
|
|
973
|
+
placement,
|
|
974
|
+
rects,
|
|
975
|
+
platform,
|
|
976
|
+
elements,
|
|
977
|
+
middlewareData
|
|
978
|
+
} = state;
|
|
979
|
+
// Since `element` is required, we don't Partial<> the type.
|
|
980
|
+
const {
|
|
981
|
+
element,
|
|
982
|
+
padding = 0
|
|
983
|
+
} = evaluate(options, state) || {};
|
|
984
|
+
if (element == null) {
|
|
985
|
+
return {};
|
|
986
|
+
}
|
|
987
|
+
const paddingObject = getPaddingObject(padding);
|
|
988
|
+
const coords = {
|
|
989
|
+
x,
|
|
990
|
+
y
|
|
991
|
+
};
|
|
992
|
+
const axis = getAlignmentAxis(placement);
|
|
993
|
+
const length = getAxisLength(axis);
|
|
994
|
+
const arrowDimensions = await platform.getDimensions(element);
|
|
995
|
+
const isYAxis = axis === 'y';
|
|
996
|
+
const minProp = isYAxis ? 'top' : 'left';
|
|
997
|
+
const maxProp = isYAxis ? 'bottom' : 'right';
|
|
998
|
+
const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
|
|
999
|
+
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
1000
|
+
const startDiff = coords[axis] - rects.reference[axis];
|
|
1001
|
+
const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
|
|
1002
|
+
let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
|
|
1003
|
+
|
|
1004
|
+
// DOM platform can return `window` as the `offsetParent`.
|
|
1005
|
+
if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
|
|
1006
|
+
clientSize = elements.floating[clientProp] || rects.floating[length];
|
|
1007
|
+
}
|
|
1008
|
+
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
1009
|
+
|
|
1010
|
+
// If the padding is large enough that it causes the arrow to no longer be
|
|
1011
|
+
// centered, modify the padding so that it is centered.
|
|
1012
|
+
const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
|
|
1013
|
+
const minPadding = min(paddingObject[minProp], largestPossiblePadding);
|
|
1014
|
+
const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
|
|
1015
|
+
|
|
1016
|
+
// Make sure the arrow doesn't overflow the floating element if the center
|
|
1017
|
+
// point is outside the floating element's bounds.
|
|
1018
|
+
const min$1 = minPadding;
|
|
1019
|
+
const max = clientSize - arrowDimensions[length] - maxPadding;
|
|
1020
|
+
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
1021
|
+
const offset = clamp(min$1, center, max);
|
|
1022
|
+
|
|
1023
|
+
// If the reference is small enough that the arrow's padding causes it to
|
|
1024
|
+
// to point to nothing for an aligned placement, adjust the offset of the
|
|
1025
|
+
// floating element itself. To ensure `shift()` continues to take action,
|
|
1026
|
+
// a single reset is performed when this is true.
|
|
1027
|
+
const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
|
|
1028
|
+
const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
|
|
1029
|
+
return {
|
|
1030
|
+
[axis]: coords[axis] + alignmentOffset,
|
|
1031
|
+
data: {
|
|
1032
|
+
[axis]: offset,
|
|
1033
|
+
centerOffset: center - offset - alignmentOffset,
|
|
1034
|
+
...(shouldAddOffset && {
|
|
1035
|
+
alignmentOffset
|
|
1036
|
+
})
|
|
1037
|
+
},
|
|
1038
|
+
reset: shouldAddOffset
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
1045
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
1046
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
1047
|
+
* @see https://floating-ui.com/docs/flip
|
|
1048
|
+
*/
|
|
1049
|
+
const flip$1 = function (options) {
|
|
1050
|
+
if (options === void 0) {
|
|
1051
|
+
options = {};
|
|
1052
|
+
}
|
|
1053
|
+
return {
|
|
1054
|
+
name: 'flip',
|
|
1055
|
+
options,
|
|
1056
|
+
async fn(state) {
|
|
1057
|
+
var _middlewareData$arrow, _middlewareData$flip;
|
|
1058
|
+
const {
|
|
1059
|
+
placement,
|
|
1060
|
+
middlewareData,
|
|
1061
|
+
rects,
|
|
1062
|
+
initialPlacement,
|
|
1063
|
+
platform,
|
|
1064
|
+
elements
|
|
1065
|
+
} = state;
|
|
1066
|
+
const {
|
|
1067
|
+
mainAxis: checkMainAxis = true,
|
|
1068
|
+
crossAxis: checkCrossAxis = true,
|
|
1069
|
+
fallbackPlacements: specifiedFallbackPlacements,
|
|
1070
|
+
fallbackStrategy = 'bestFit',
|
|
1071
|
+
fallbackAxisSideDirection = 'none',
|
|
1072
|
+
flipAlignment = true,
|
|
1073
|
+
...detectOverflowOptions
|
|
1074
|
+
} = evaluate(options, state);
|
|
1075
|
+
|
|
1076
|
+
// If a reset by the arrow was caused due to an alignment offset being
|
|
1077
|
+
// added, we should skip any logic now since `flip()` has already done its
|
|
1078
|
+
// work.
|
|
1079
|
+
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
|
|
1080
|
+
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1081
|
+
return {};
|
|
1082
|
+
}
|
|
1083
|
+
const side = getSide(placement);
|
|
1084
|
+
const initialSideAxis = getSideAxis(initialPlacement);
|
|
1085
|
+
const isBasePlacement = getSide(initialPlacement) === initialPlacement;
|
|
1086
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1087
|
+
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1088
|
+
const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
|
|
1089
|
+
if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
|
|
1090
|
+
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
|
|
1091
|
+
}
|
|
1092
|
+
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1093
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1094
|
+
const overflows = [];
|
|
1095
|
+
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1096
|
+
if (checkMainAxis) {
|
|
1097
|
+
overflows.push(overflow[side]);
|
|
1098
|
+
}
|
|
1099
|
+
if (checkCrossAxis) {
|
|
1100
|
+
const sides = getAlignmentSides(placement, rects, rtl);
|
|
1101
|
+
overflows.push(overflow[sides[0]], overflow[sides[1]]);
|
|
1102
|
+
}
|
|
1103
|
+
overflowsData = [...overflowsData, {
|
|
1104
|
+
placement,
|
|
1105
|
+
overflows
|
|
1106
|
+
}];
|
|
1107
|
+
|
|
1108
|
+
// One or more sides is overflowing.
|
|
1109
|
+
if (!overflows.every(side => side <= 0)) {
|
|
1110
|
+
var _middlewareData$flip2, _overflowsData$filter;
|
|
1111
|
+
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
|
|
1112
|
+
const nextPlacement = placements[nextIndex];
|
|
1113
|
+
if (nextPlacement) {
|
|
1114
|
+
const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
|
|
1115
|
+
if (!ignoreCrossAxisOverflow ||
|
|
1116
|
+
// We leave the current main axis only if every placement on that axis
|
|
1117
|
+
// overflows the main axis.
|
|
1118
|
+
overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
|
|
1119
|
+
// Try next placement and re-run the lifecycle.
|
|
1120
|
+
return {
|
|
1121
|
+
data: {
|
|
1122
|
+
index: nextIndex,
|
|
1123
|
+
overflows: overflowsData
|
|
1124
|
+
},
|
|
1125
|
+
reset: {
|
|
1126
|
+
placement: nextPlacement
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// First, find the candidates that fit on the mainAxis side of overflow,
|
|
1133
|
+
// then find the placement that fits the best on the main crossAxis side.
|
|
1134
|
+
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
|
|
1135
|
+
|
|
1136
|
+
// Otherwise fallback.
|
|
1137
|
+
if (!resetPlacement) {
|
|
1138
|
+
switch (fallbackStrategy) {
|
|
1139
|
+
case 'bestFit':
|
|
1140
|
+
{
|
|
1141
|
+
var _overflowsData$filter2;
|
|
1142
|
+
const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
|
|
1143
|
+
if (hasFallbackAxisSideDirection) {
|
|
1144
|
+
const currentSideAxis = getSideAxis(d.placement);
|
|
1145
|
+
return currentSideAxis === initialSideAxis ||
|
|
1146
|
+
// Create a bias to the `y` side axis due to horizontal
|
|
1147
|
+
// reading directions favoring greater width.
|
|
1148
|
+
currentSideAxis === 'y';
|
|
1149
|
+
}
|
|
1150
|
+
return true;
|
|
1151
|
+
}).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
|
|
1152
|
+
if (placement) {
|
|
1153
|
+
resetPlacement = placement;
|
|
1154
|
+
}
|
|
1155
|
+
break;
|
|
1156
|
+
}
|
|
1157
|
+
case 'initialPlacement':
|
|
1158
|
+
resetPlacement = initialPlacement;
|
|
1159
|
+
break;
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
if (placement !== resetPlacement) {
|
|
1163
|
+
return {
|
|
1164
|
+
reset: {
|
|
1165
|
+
placement: resetPlacement
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return {};
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
const originSides = /*#__PURE__*/new Set(['left', 'top']);
|
|
1176
|
+
|
|
1177
|
+
// For type backwards-compatibility, the `OffsetOptions` type was also
|
|
1178
|
+
// Derivable.
|
|
1179
|
+
|
|
1180
|
+
async function convertValueToCoords(state, options) {
|
|
1181
|
+
const {
|
|
1182
|
+
placement,
|
|
1183
|
+
platform,
|
|
1184
|
+
elements
|
|
1185
|
+
} = state;
|
|
1186
|
+
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
|
|
1187
|
+
const side = getSide(placement);
|
|
1188
|
+
const alignment = getAlignment(placement);
|
|
1189
|
+
const isVertical = getSideAxis(placement) === 'y';
|
|
1190
|
+
const mainAxisMulti = originSides.has(side) ? -1 : 1;
|
|
1191
|
+
const crossAxisMulti = rtl && isVertical ? -1 : 1;
|
|
1192
|
+
const rawValue = evaluate(options, state);
|
|
1193
|
+
|
|
1194
|
+
// eslint-disable-next-line prefer-const
|
|
1195
|
+
let {
|
|
1196
|
+
mainAxis,
|
|
1197
|
+
crossAxis,
|
|
1198
|
+
alignmentAxis
|
|
1199
|
+
} = typeof rawValue === 'number' ? {
|
|
1200
|
+
mainAxis: rawValue,
|
|
1201
|
+
crossAxis: 0,
|
|
1202
|
+
alignmentAxis: null
|
|
1203
|
+
} : {
|
|
1204
|
+
mainAxis: rawValue.mainAxis || 0,
|
|
1205
|
+
crossAxis: rawValue.crossAxis || 0,
|
|
1206
|
+
alignmentAxis: rawValue.alignmentAxis
|
|
1207
|
+
};
|
|
1208
|
+
if (alignment && typeof alignmentAxis === 'number') {
|
|
1209
|
+
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
|
|
1210
|
+
}
|
|
1211
|
+
return isVertical ? {
|
|
1212
|
+
x: crossAxis * crossAxisMulti,
|
|
1213
|
+
y: mainAxis * mainAxisMulti
|
|
1214
|
+
} : {
|
|
1215
|
+
x: mainAxis * mainAxisMulti,
|
|
1216
|
+
y: crossAxis * crossAxisMulti
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Modifies the placement by translating the floating element along the
|
|
1222
|
+
* specified axes.
|
|
1223
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
1224
|
+
* object may be passed.
|
|
1225
|
+
* @see https://floating-ui.com/docs/offset
|
|
1226
|
+
*/
|
|
1227
|
+
const offset$1 = function (options) {
|
|
1228
|
+
if (options === void 0) {
|
|
1229
|
+
options = 0;
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
name: 'offset',
|
|
1233
|
+
options,
|
|
1234
|
+
async fn(state) {
|
|
1235
|
+
var _middlewareData$offse, _middlewareData$arrow;
|
|
1236
|
+
const {
|
|
1237
|
+
x,
|
|
1238
|
+
y,
|
|
1239
|
+
placement,
|
|
1240
|
+
middlewareData
|
|
1241
|
+
} = state;
|
|
1242
|
+
const diffCoords = await convertValueToCoords(state, options);
|
|
1243
|
+
|
|
1244
|
+
// If the placement is the same and the arrow caused an alignment offset
|
|
1245
|
+
// then we don't need to change the positioning coordinates.
|
|
1246
|
+
if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
|
|
1247
|
+
return {};
|
|
1248
|
+
}
|
|
1249
|
+
return {
|
|
1250
|
+
x: x + diffCoords.x,
|
|
1251
|
+
y: y + diffCoords.y,
|
|
1252
|
+
data: {
|
|
1253
|
+
...diffCoords,
|
|
1254
|
+
placement
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
1263
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
1264
|
+
* @see https://floating-ui.com/docs/shift
|
|
1265
|
+
*/
|
|
1266
|
+
const shift$1 = function (options) {
|
|
1267
|
+
if (options === void 0) {
|
|
1268
|
+
options = {};
|
|
1269
|
+
}
|
|
1270
|
+
return {
|
|
1271
|
+
name: 'shift',
|
|
1272
|
+
options,
|
|
1273
|
+
async fn(state) {
|
|
1274
|
+
const {
|
|
1275
|
+
x,
|
|
1276
|
+
y,
|
|
1277
|
+
placement
|
|
1278
|
+
} = state;
|
|
1279
|
+
const {
|
|
1280
|
+
mainAxis: checkMainAxis = true,
|
|
1281
|
+
crossAxis: checkCrossAxis = false,
|
|
1282
|
+
limiter = {
|
|
1283
|
+
fn: _ref => {
|
|
1284
|
+
let {
|
|
1285
|
+
x,
|
|
1286
|
+
y
|
|
1287
|
+
} = _ref;
|
|
1288
|
+
return {
|
|
1289
|
+
x,
|
|
1290
|
+
y
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
},
|
|
1294
|
+
...detectOverflowOptions
|
|
1295
|
+
} = evaluate(options, state);
|
|
1296
|
+
const coords = {
|
|
1297
|
+
x,
|
|
1298
|
+
y
|
|
1299
|
+
};
|
|
1300
|
+
const overflow = await detectOverflow(state, detectOverflowOptions);
|
|
1301
|
+
const crossAxis = getSideAxis(getSide(placement));
|
|
1302
|
+
const mainAxis = getOppositeAxis(crossAxis);
|
|
1303
|
+
let mainAxisCoord = coords[mainAxis];
|
|
1304
|
+
let crossAxisCoord = coords[crossAxis];
|
|
1305
|
+
if (checkMainAxis) {
|
|
1306
|
+
const minSide = mainAxis === 'y' ? 'top' : 'left';
|
|
1307
|
+
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
|
|
1308
|
+
const min = mainAxisCoord + overflow[minSide];
|
|
1309
|
+
const max = mainAxisCoord - overflow[maxSide];
|
|
1310
|
+
mainAxisCoord = clamp(min, mainAxisCoord, max);
|
|
1311
|
+
}
|
|
1312
|
+
if (checkCrossAxis) {
|
|
1313
|
+
const minSide = crossAxis === 'y' ? 'top' : 'left';
|
|
1314
|
+
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
|
|
1315
|
+
const min = crossAxisCoord + overflow[minSide];
|
|
1316
|
+
const max = crossAxisCoord - overflow[maxSide];
|
|
1317
|
+
crossAxisCoord = clamp(min, crossAxisCoord, max);
|
|
1318
|
+
}
|
|
1319
|
+
const limitedCoords = limiter.fn({
|
|
1320
|
+
...state,
|
|
1321
|
+
[mainAxis]: mainAxisCoord,
|
|
1322
|
+
[crossAxis]: crossAxisCoord
|
|
1323
|
+
});
|
|
1324
|
+
return {
|
|
1325
|
+
...limitedCoords,
|
|
1326
|
+
data: {
|
|
1327
|
+
x: limitedCoords.x - x,
|
|
1328
|
+
y: limitedCoords.y - y,
|
|
1329
|
+
enabled: {
|
|
1330
|
+
[mainAxis]: checkMainAxis,
|
|
1331
|
+
[crossAxis]: checkCrossAxis
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
function hasWindow() {
|
|
1340
|
+
return typeof window !== 'undefined';
|
|
1341
|
+
}
|
|
1342
|
+
function getNodeName(node) {
|
|
1343
|
+
if (isNode(node)) {
|
|
1344
|
+
return (node.nodeName || '').toLowerCase();
|
|
1345
|
+
}
|
|
1346
|
+
// Mocked nodes in testing environments may not be instances of Node. By
|
|
1347
|
+
// returning `#document` an infinite loop won't occur.
|
|
1348
|
+
// https://github.com/floating-ui/floating-ui/issues/2317
|
|
1349
|
+
return '#document';
|
|
1350
|
+
}
|
|
1351
|
+
function getWindow(node) {
|
|
1352
|
+
var _node$ownerDocument;
|
|
1353
|
+
return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
|
|
1354
|
+
}
|
|
1355
|
+
function getDocumentElement(node) {
|
|
1356
|
+
var _ref;
|
|
1357
|
+
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
1358
|
+
}
|
|
1359
|
+
function isNode(value) {
|
|
1360
|
+
if (!hasWindow()) {
|
|
1361
|
+
return false;
|
|
1362
|
+
}
|
|
1363
|
+
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
1364
|
+
}
|
|
1365
|
+
function isElement(value) {
|
|
1366
|
+
if (!hasWindow()) {
|
|
1367
|
+
return false;
|
|
1368
|
+
}
|
|
1369
|
+
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
1370
|
+
}
|
|
1371
|
+
function isHTMLElement(value) {
|
|
1372
|
+
if (!hasWindow()) {
|
|
1373
|
+
return false;
|
|
1374
|
+
}
|
|
1375
|
+
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
1376
|
+
}
|
|
1377
|
+
function isShadowRoot(value) {
|
|
1378
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
1379
|
+
return false;
|
|
1380
|
+
}
|
|
1381
|
+
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
1382
|
+
}
|
|
1383
|
+
const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
|
|
1384
|
+
function isOverflowElement(element) {
|
|
1385
|
+
const {
|
|
1386
|
+
overflow,
|
|
1387
|
+
overflowX,
|
|
1388
|
+
overflowY,
|
|
1389
|
+
display
|
|
1390
|
+
} = getComputedStyle$1(element);
|
|
1391
|
+
return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
|
|
1392
|
+
}
|
|
1393
|
+
const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
|
|
1394
|
+
function isTableElement(element) {
|
|
1395
|
+
return tableElements.has(getNodeName(element));
|
|
1396
|
+
}
|
|
1397
|
+
const topLayerSelectors = [':popover-open', ':modal'];
|
|
1398
|
+
function isTopLayer(element) {
|
|
1399
|
+
return topLayerSelectors.some(selector => {
|
|
1400
|
+
try {
|
|
1401
|
+
return element.matches(selector);
|
|
1402
|
+
} catch (_e) {
|
|
1403
|
+
return false;
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
|
|
1408
|
+
const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
|
|
1409
|
+
const containValues = ['paint', 'layout', 'strict', 'content'];
|
|
1410
|
+
function isContainingBlock(elementOrCss) {
|
|
1411
|
+
const webkit = isWebKit();
|
|
1412
|
+
const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
|
|
1413
|
+
|
|
1414
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1415
|
+
// https://drafts.csswg.org/css-transforms-2/#individual-transforms
|
|
1416
|
+
return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
|
|
1417
|
+
}
|
|
1418
|
+
function getContainingBlock(element) {
|
|
1419
|
+
let currentNode = getParentNode(element);
|
|
1420
|
+
while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1421
|
+
if (isContainingBlock(currentNode)) {
|
|
1422
|
+
return currentNode;
|
|
1423
|
+
} else if (isTopLayer(currentNode)) {
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
currentNode = getParentNode(currentNode);
|
|
1427
|
+
}
|
|
1428
|
+
return null;
|
|
1429
|
+
}
|
|
1430
|
+
function isWebKit() {
|
|
1431
|
+
if (typeof CSS === 'undefined' || !CSS.supports) return false;
|
|
1432
|
+
return CSS.supports('-webkit-backdrop-filter', 'none');
|
|
1433
|
+
}
|
|
1434
|
+
const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
|
|
1435
|
+
function isLastTraversableNode(node) {
|
|
1436
|
+
return lastTraversableNodeNames.has(getNodeName(node));
|
|
1437
|
+
}
|
|
1438
|
+
function getComputedStyle$1(element) {
|
|
1439
|
+
return getWindow(element).getComputedStyle(element);
|
|
1440
|
+
}
|
|
1441
|
+
function getNodeScroll(element) {
|
|
1442
|
+
if (isElement(element)) {
|
|
1443
|
+
return {
|
|
1444
|
+
scrollLeft: element.scrollLeft,
|
|
1445
|
+
scrollTop: element.scrollTop
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
return {
|
|
1449
|
+
scrollLeft: element.scrollX,
|
|
1450
|
+
scrollTop: element.scrollY
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
function getParentNode(node) {
|
|
1454
|
+
if (getNodeName(node) === 'html') {
|
|
1455
|
+
return node;
|
|
1456
|
+
}
|
|
1457
|
+
const result =
|
|
1458
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
1459
|
+
node.assignedSlot ||
|
|
1460
|
+
// DOM Element detected.
|
|
1461
|
+
node.parentNode ||
|
|
1462
|
+
// ShadowRoot detected.
|
|
1463
|
+
isShadowRoot(node) && node.host ||
|
|
1464
|
+
// Fallback.
|
|
1465
|
+
getDocumentElement(node);
|
|
1466
|
+
return isShadowRoot(result) ? result.host : result;
|
|
1467
|
+
}
|
|
1468
|
+
function getNearestOverflowAncestor(node) {
|
|
1469
|
+
const parentNode = getParentNode(node);
|
|
1470
|
+
if (isLastTraversableNode(parentNode)) {
|
|
1471
|
+
return node.ownerDocument ? node.ownerDocument.body : node.body;
|
|
1472
|
+
}
|
|
1473
|
+
if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
|
|
1474
|
+
return parentNode;
|
|
1475
|
+
}
|
|
1476
|
+
return getNearestOverflowAncestor(parentNode);
|
|
1477
|
+
}
|
|
1478
|
+
function getOverflowAncestors(node, list, traverseIframes) {
|
|
1479
|
+
var _node$ownerDocument2;
|
|
1480
|
+
if (list === void 0) {
|
|
1481
|
+
list = [];
|
|
1482
|
+
}
|
|
1483
|
+
if (traverseIframes === void 0) {
|
|
1484
|
+
traverseIframes = true;
|
|
1485
|
+
}
|
|
1486
|
+
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1487
|
+
const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
|
|
1488
|
+
const win = getWindow(scrollableAncestor);
|
|
1489
|
+
if (isBody) {
|
|
1490
|
+
const frameElement = getFrameElement(win);
|
|
1491
|
+
return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
|
|
1492
|
+
}
|
|
1493
|
+
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
1494
|
+
}
|
|
1495
|
+
function getFrameElement(win) {
|
|
1496
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
function getCssDimensions(element) {
|
|
1500
|
+
const css = getComputedStyle$1(element);
|
|
1501
|
+
// In testing environments, the `width` and `height` properties are empty
|
|
1502
|
+
// strings for SVG elements, returning NaN. Fallback to `0` in this case.
|
|
1503
|
+
let width = parseFloat(css.width) || 0;
|
|
1504
|
+
let height = parseFloat(css.height) || 0;
|
|
1505
|
+
const hasOffset = isHTMLElement(element);
|
|
1506
|
+
const offsetWidth = hasOffset ? element.offsetWidth : width;
|
|
1507
|
+
const offsetHeight = hasOffset ? element.offsetHeight : height;
|
|
1508
|
+
const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
|
|
1509
|
+
if (shouldFallback) {
|
|
1510
|
+
width = offsetWidth;
|
|
1511
|
+
height = offsetHeight;
|
|
1512
|
+
}
|
|
1513
|
+
return {
|
|
1514
|
+
width,
|
|
1515
|
+
height,
|
|
1516
|
+
$: shouldFallback
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
function unwrapElement(element) {
|
|
1521
|
+
return !isElement(element) ? element.contextElement : element;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
function getScale(element) {
|
|
1525
|
+
const domElement = unwrapElement(element);
|
|
1526
|
+
if (!isHTMLElement(domElement)) {
|
|
1527
|
+
return createCoords(1);
|
|
1528
|
+
}
|
|
1529
|
+
const rect = domElement.getBoundingClientRect();
|
|
1530
|
+
const {
|
|
1531
|
+
width,
|
|
1532
|
+
height,
|
|
1533
|
+
$
|
|
1534
|
+
} = getCssDimensions(domElement);
|
|
1535
|
+
let x = ($ ? round(rect.width) : rect.width) / width;
|
|
1536
|
+
let y = ($ ? round(rect.height) : rect.height) / height;
|
|
1537
|
+
|
|
1538
|
+
// 0, NaN, or Infinity should always fallback to 1.
|
|
1539
|
+
|
|
1540
|
+
if (!x || !Number.isFinite(x)) {
|
|
1541
|
+
x = 1;
|
|
1542
|
+
}
|
|
1543
|
+
if (!y || !Number.isFinite(y)) {
|
|
1544
|
+
y = 1;
|
|
1545
|
+
}
|
|
1546
|
+
return {
|
|
1547
|
+
x,
|
|
1548
|
+
y
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
const noOffsets = /*#__PURE__*/createCoords(0);
|
|
1553
|
+
function getVisualOffsets(element) {
|
|
1554
|
+
const win = getWindow(element);
|
|
1555
|
+
if (!isWebKit() || !win.visualViewport) {
|
|
1556
|
+
return noOffsets;
|
|
1557
|
+
}
|
|
1558
|
+
return {
|
|
1559
|
+
x: win.visualViewport.offsetLeft,
|
|
1560
|
+
y: win.visualViewport.offsetTop
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
|
|
1564
|
+
if (isFixed === void 0) {
|
|
1565
|
+
isFixed = false;
|
|
1566
|
+
}
|
|
1567
|
+
if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
|
|
1568
|
+
return false;
|
|
1569
|
+
}
|
|
1570
|
+
return isFixed;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
|
|
1574
|
+
if (includeScale === void 0) {
|
|
1575
|
+
includeScale = false;
|
|
1576
|
+
}
|
|
1577
|
+
if (isFixedStrategy === void 0) {
|
|
1578
|
+
isFixedStrategy = false;
|
|
1579
|
+
}
|
|
1580
|
+
const clientRect = element.getBoundingClientRect();
|
|
1581
|
+
const domElement = unwrapElement(element);
|
|
1582
|
+
let scale = createCoords(1);
|
|
1583
|
+
if (includeScale) {
|
|
1584
|
+
if (offsetParent) {
|
|
1585
|
+
if (isElement(offsetParent)) {
|
|
1586
|
+
scale = getScale(offsetParent);
|
|
1587
|
+
}
|
|
1588
|
+
} else {
|
|
1589
|
+
scale = getScale(element);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
1593
|
+
let x = (clientRect.left + visualOffsets.x) / scale.x;
|
|
1594
|
+
let y = (clientRect.top + visualOffsets.y) / scale.y;
|
|
1595
|
+
let width = clientRect.width / scale.x;
|
|
1596
|
+
let height = clientRect.height / scale.y;
|
|
1597
|
+
if (domElement) {
|
|
1598
|
+
const win = getWindow(domElement);
|
|
1599
|
+
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
1600
|
+
let currentWin = win;
|
|
1601
|
+
let currentIFrame = getFrameElement(currentWin);
|
|
1602
|
+
while (currentIFrame && offsetParent && offsetWin !== currentWin) {
|
|
1603
|
+
const iframeScale = getScale(currentIFrame);
|
|
1604
|
+
const iframeRect = currentIFrame.getBoundingClientRect();
|
|
1605
|
+
const css = getComputedStyle$1(currentIFrame);
|
|
1606
|
+
const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
|
|
1607
|
+
const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
|
|
1608
|
+
x *= iframeScale.x;
|
|
1609
|
+
y *= iframeScale.y;
|
|
1610
|
+
width *= iframeScale.x;
|
|
1611
|
+
height *= iframeScale.y;
|
|
1612
|
+
x += left;
|
|
1613
|
+
y += top;
|
|
1614
|
+
currentWin = getWindow(currentIFrame);
|
|
1615
|
+
currentIFrame = getFrameElement(currentWin);
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
return rectToClientRect({
|
|
1619
|
+
width,
|
|
1620
|
+
height,
|
|
1621
|
+
x,
|
|
1622
|
+
y
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
1627
|
+
// incorrect for RTL.
|
|
1628
|
+
function getWindowScrollBarX(element, rect) {
|
|
1629
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
1630
|
+
if (!rect) {
|
|
1631
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
1632
|
+
}
|
|
1633
|
+
return rect.left + leftScroll;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
function getHTMLOffset(documentElement, scroll) {
|
|
1637
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
1638
|
+
const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
|
|
1639
|
+
const y = htmlRect.top + scroll.scrollTop;
|
|
1640
|
+
return {
|
|
1641
|
+
x,
|
|
1642
|
+
y
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1647
|
+
let {
|
|
1648
|
+
elements,
|
|
1649
|
+
rect,
|
|
1650
|
+
offsetParent,
|
|
1651
|
+
strategy
|
|
1652
|
+
} = _ref;
|
|
1653
|
+
const isFixed = strategy === 'fixed';
|
|
1654
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1655
|
+
const topLayer = elements ? isTopLayer(elements.floating) : false;
|
|
1656
|
+
if (offsetParent === documentElement || topLayer && isFixed) {
|
|
1657
|
+
return rect;
|
|
1658
|
+
}
|
|
1659
|
+
let scroll = {
|
|
1660
|
+
scrollLeft: 0,
|
|
1661
|
+
scrollTop: 0
|
|
1662
|
+
};
|
|
1663
|
+
let scale = createCoords(1);
|
|
1664
|
+
const offsets = createCoords(0);
|
|
1665
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1666
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1667
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1668
|
+
scroll = getNodeScroll(offsetParent);
|
|
1669
|
+
}
|
|
1670
|
+
if (isHTMLElement(offsetParent)) {
|
|
1671
|
+
const offsetRect = getBoundingClientRect(offsetParent);
|
|
1672
|
+
scale = getScale(offsetParent);
|
|
1673
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1674
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1678
|
+
return {
|
|
1679
|
+
width: rect.width * scale.x,
|
|
1680
|
+
height: rect.height * scale.y,
|
|
1681
|
+
x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
|
|
1682
|
+
y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
function getClientRects(element) {
|
|
1687
|
+
return Array.from(element.getClientRects());
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
// Gets the entire size of the scrollable document area, even extending outside
|
|
1691
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable.
|
|
1692
|
+
function getDocumentRect(element) {
|
|
1693
|
+
const html = getDocumentElement(element);
|
|
1694
|
+
const scroll = getNodeScroll(element);
|
|
1695
|
+
const body = element.ownerDocument.body;
|
|
1696
|
+
const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
|
|
1697
|
+
const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
|
|
1698
|
+
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1699
|
+
const y = -scroll.scrollTop;
|
|
1700
|
+
if (getComputedStyle$1(body).direction === 'rtl') {
|
|
1701
|
+
x += max(html.clientWidth, body.clientWidth) - width;
|
|
1702
|
+
}
|
|
1703
|
+
return {
|
|
1704
|
+
width,
|
|
1705
|
+
height,
|
|
1706
|
+
x,
|
|
1707
|
+
y
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
// Safety check: ensure the scrollbar space is reasonable in case this
|
|
1712
|
+
// calculation is affected by unusual styles.
|
|
1713
|
+
// Most scrollbars leave 15-18px of space.
|
|
1714
|
+
const SCROLLBAR_MAX = 25;
|
|
1715
|
+
function getViewportRect(element, strategy) {
|
|
1716
|
+
const win = getWindow(element);
|
|
1717
|
+
const html = getDocumentElement(element);
|
|
1718
|
+
const visualViewport = win.visualViewport;
|
|
1719
|
+
let width = html.clientWidth;
|
|
1720
|
+
let height = html.clientHeight;
|
|
1721
|
+
let x = 0;
|
|
1722
|
+
let y = 0;
|
|
1723
|
+
if (visualViewport) {
|
|
1724
|
+
width = visualViewport.width;
|
|
1725
|
+
height = visualViewport.height;
|
|
1726
|
+
const visualViewportBased = isWebKit();
|
|
1727
|
+
if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
|
|
1728
|
+
x = visualViewport.offsetLeft;
|
|
1729
|
+
y = visualViewport.offsetTop;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
const windowScrollbarX = getWindowScrollBarX(html);
|
|
1733
|
+
// <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
|
|
1734
|
+
// visual width of the <html> but this is not considered in the size
|
|
1735
|
+
// of `html.clientWidth`.
|
|
1736
|
+
if (windowScrollbarX <= 0) {
|
|
1737
|
+
const doc = html.ownerDocument;
|
|
1738
|
+
const body = doc.body;
|
|
1739
|
+
const bodyStyles = getComputedStyle(body);
|
|
1740
|
+
const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
|
|
1741
|
+
const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
|
|
1742
|
+
if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
|
|
1743
|
+
width -= clippingStableScrollbarWidth;
|
|
1744
|
+
}
|
|
1745
|
+
} else if (windowScrollbarX <= SCROLLBAR_MAX) {
|
|
1746
|
+
// If the <body> scrollbar is on the left, the width needs to be extended
|
|
1747
|
+
// by the scrollbar amount so there isn't extra space on the right.
|
|
1748
|
+
width += windowScrollbarX;
|
|
1749
|
+
}
|
|
1750
|
+
return {
|
|
1751
|
+
width,
|
|
1752
|
+
height,
|
|
1753
|
+
x,
|
|
1754
|
+
y
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
|
|
1759
|
+
// Returns the inner client rect, subtracting scrollbars if present.
|
|
1760
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
1761
|
+
const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
|
|
1762
|
+
const top = clientRect.top + element.clientTop;
|
|
1763
|
+
const left = clientRect.left + element.clientLeft;
|
|
1764
|
+
const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
1765
|
+
const width = element.clientWidth * scale.x;
|
|
1766
|
+
const height = element.clientHeight * scale.y;
|
|
1767
|
+
const x = left * scale.x;
|
|
1768
|
+
const y = top * scale.y;
|
|
1769
|
+
return {
|
|
1770
|
+
width,
|
|
1771
|
+
height,
|
|
1772
|
+
x,
|
|
1773
|
+
y
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
|
|
1777
|
+
let rect;
|
|
1778
|
+
if (clippingAncestor === 'viewport') {
|
|
1779
|
+
rect = getViewportRect(element, strategy);
|
|
1780
|
+
} else if (clippingAncestor === 'document') {
|
|
1781
|
+
rect = getDocumentRect(getDocumentElement(element));
|
|
1782
|
+
} else if (isElement(clippingAncestor)) {
|
|
1783
|
+
rect = getInnerBoundingClientRect(clippingAncestor, strategy);
|
|
1784
|
+
} else {
|
|
1785
|
+
const visualOffsets = getVisualOffsets(element);
|
|
1786
|
+
rect = {
|
|
1787
|
+
x: clippingAncestor.x - visualOffsets.x,
|
|
1788
|
+
y: clippingAncestor.y - visualOffsets.y,
|
|
1789
|
+
width: clippingAncestor.width,
|
|
1790
|
+
height: clippingAncestor.height
|
|
1791
|
+
};
|
|
1792
|
+
}
|
|
1793
|
+
return rectToClientRect(rect);
|
|
1794
|
+
}
|
|
1795
|
+
function hasFixedPositionAncestor(element, stopNode) {
|
|
1796
|
+
const parentNode = getParentNode(element);
|
|
1797
|
+
if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
|
|
1798
|
+
return false;
|
|
1799
|
+
}
|
|
1800
|
+
return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
// A "clipping ancestor" is an `overflow` element with the characteristic of
|
|
1804
|
+
// clipping (or hiding) child elements. This returns all clipping ancestors
|
|
1805
|
+
// of the given element up the tree.
|
|
1806
|
+
function getClippingElementAncestors(element, cache) {
|
|
1807
|
+
const cachedResult = cache.get(element);
|
|
1808
|
+
if (cachedResult) {
|
|
1809
|
+
return cachedResult;
|
|
1810
|
+
}
|
|
1811
|
+
let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
|
|
1812
|
+
let currentContainingBlockComputedStyle = null;
|
|
1813
|
+
const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
|
|
1814
|
+
let currentNode = elementIsFixed ? getParentNode(element) : element;
|
|
1815
|
+
|
|
1816
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
1817
|
+
while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
|
|
1818
|
+
const computedStyle = getComputedStyle$1(currentNode);
|
|
1819
|
+
const currentNodeIsContaining = isContainingBlock(currentNode);
|
|
1820
|
+
if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
|
|
1821
|
+
currentContainingBlockComputedStyle = null;
|
|
1822
|
+
}
|
|
1823
|
+
const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
|
|
1824
|
+
if (shouldDropCurrentNode) {
|
|
1825
|
+
// Drop non-containing blocks.
|
|
1826
|
+
result = result.filter(ancestor => ancestor !== currentNode);
|
|
1827
|
+
} else {
|
|
1828
|
+
// Record last containing block for next iteration.
|
|
1829
|
+
currentContainingBlockComputedStyle = computedStyle;
|
|
1830
|
+
}
|
|
1831
|
+
currentNode = getParentNode(currentNode);
|
|
1832
|
+
}
|
|
1833
|
+
cache.set(element, result);
|
|
1834
|
+
return result;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
// Gets the maximum area that the element is visible in due to any number of
|
|
1838
|
+
// clipping ancestors.
|
|
1839
|
+
function getClippingRect(_ref) {
|
|
1840
|
+
let {
|
|
1841
|
+
element,
|
|
1842
|
+
boundary,
|
|
1843
|
+
rootBoundary,
|
|
1844
|
+
strategy
|
|
1845
|
+
} = _ref;
|
|
1846
|
+
const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
|
|
1847
|
+
const clippingAncestors = [...elementClippingAncestors, rootBoundary];
|
|
1848
|
+
const firstClippingAncestor = clippingAncestors[0];
|
|
1849
|
+
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1850
|
+
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1851
|
+
accRect.top = max(rect.top, accRect.top);
|
|
1852
|
+
accRect.right = min(rect.right, accRect.right);
|
|
1853
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
1854
|
+
accRect.left = max(rect.left, accRect.left);
|
|
1855
|
+
return accRect;
|
|
1856
|
+
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1857
|
+
return {
|
|
1858
|
+
width: clippingRect.right - clippingRect.left,
|
|
1859
|
+
height: clippingRect.bottom - clippingRect.top,
|
|
1860
|
+
x: clippingRect.left,
|
|
1861
|
+
y: clippingRect.top
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
function getDimensions(element) {
|
|
1866
|
+
const {
|
|
1867
|
+
width,
|
|
1868
|
+
height
|
|
1869
|
+
} = getCssDimensions(element);
|
|
1870
|
+
return {
|
|
1871
|
+
width,
|
|
1872
|
+
height
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1877
|
+
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
1878
|
+
const documentElement = getDocumentElement(offsetParent);
|
|
1879
|
+
const isFixed = strategy === 'fixed';
|
|
1880
|
+
const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
|
|
1881
|
+
let scroll = {
|
|
1882
|
+
scrollLeft: 0,
|
|
1883
|
+
scrollTop: 0
|
|
1884
|
+
};
|
|
1885
|
+
const offsets = createCoords(0);
|
|
1886
|
+
|
|
1887
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
1888
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
1889
|
+
function setLeftRTLScrollbarOffset() {
|
|
1890
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
1891
|
+
}
|
|
1892
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
1893
|
+
if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
|
|
1894
|
+
scroll = getNodeScroll(offsetParent);
|
|
1895
|
+
}
|
|
1896
|
+
if (isOffsetParentAnElement) {
|
|
1897
|
+
const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
|
|
1898
|
+
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1899
|
+
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1900
|
+
} else if (documentElement) {
|
|
1901
|
+
setLeftRTLScrollbarOffset();
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
if (isFixed && !isOffsetParentAnElement && documentElement) {
|
|
1905
|
+
setLeftRTLScrollbarOffset();
|
|
1906
|
+
}
|
|
1907
|
+
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
1908
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
|
|
1909
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
|
|
1910
|
+
return {
|
|
1911
|
+
x,
|
|
1912
|
+
y,
|
|
1913
|
+
width: rect.width,
|
|
1914
|
+
height: rect.height
|
|
1915
|
+
};
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
function isStaticPositioned(element) {
|
|
1919
|
+
return getComputedStyle$1(element).position === 'static';
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
function getTrueOffsetParent(element, polyfill) {
|
|
1923
|
+
if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
|
|
1924
|
+
return null;
|
|
1925
|
+
}
|
|
1926
|
+
if (polyfill) {
|
|
1927
|
+
return polyfill(element);
|
|
1928
|
+
}
|
|
1929
|
+
let rawOffsetParent = element.offsetParent;
|
|
1930
|
+
|
|
1931
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
1932
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
1933
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
1934
|
+
// non-static.
|
|
1935
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
1936
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
1937
|
+
}
|
|
1938
|
+
return rawOffsetParent;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
// Gets the closest ancestor positioned element. Handles some edge cases,
|
|
1942
|
+
// such as table ancestors and cross browser bugs.
|
|
1943
|
+
function getOffsetParent(element, polyfill) {
|
|
1944
|
+
const win = getWindow(element);
|
|
1945
|
+
if (isTopLayer(element)) {
|
|
1946
|
+
return win;
|
|
1947
|
+
}
|
|
1948
|
+
if (!isHTMLElement(element)) {
|
|
1949
|
+
let svgOffsetParent = getParentNode(element);
|
|
1950
|
+
while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
|
|
1951
|
+
if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
|
|
1952
|
+
return svgOffsetParent;
|
|
1953
|
+
}
|
|
1954
|
+
svgOffsetParent = getParentNode(svgOffsetParent);
|
|
1955
|
+
}
|
|
1956
|
+
return win;
|
|
1957
|
+
}
|
|
1958
|
+
let offsetParent = getTrueOffsetParent(element, polyfill);
|
|
1959
|
+
while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
|
|
1960
|
+
offsetParent = getTrueOffsetParent(offsetParent, polyfill);
|
|
1961
|
+
}
|
|
1962
|
+
if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
|
|
1963
|
+
return win;
|
|
1964
|
+
}
|
|
1965
|
+
return offsetParent || getContainingBlock(element) || win;
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
const getElementRects = async function (data) {
|
|
1969
|
+
const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
|
|
1970
|
+
const getDimensionsFn = this.getDimensions;
|
|
1971
|
+
const floatingDimensions = await getDimensionsFn(data.floating);
|
|
1972
|
+
return {
|
|
1973
|
+
reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
|
|
1974
|
+
floating: {
|
|
1975
|
+
x: 0,
|
|
1976
|
+
y: 0,
|
|
1977
|
+
width: floatingDimensions.width,
|
|
1978
|
+
height: floatingDimensions.height
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
};
|
|
1982
|
+
|
|
1983
|
+
function isRTL(element) {
|
|
1984
|
+
return getComputedStyle$1(element).direction === 'rtl';
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
const platform = {
|
|
1988
|
+
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1989
|
+
getDocumentElement,
|
|
1990
|
+
getClippingRect,
|
|
1991
|
+
getOffsetParent,
|
|
1992
|
+
getElementRects,
|
|
1993
|
+
getClientRects,
|
|
1994
|
+
getDimensions,
|
|
1995
|
+
getScale,
|
|
1996
|
+
isElement,
|
|
1997
|
+
isRTL
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
function rectsAreEqual(a, b) {
|
|
2001
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
// https://samthor.au/2021/observing-dom/
|
|
2005
|
+
function observeMove(element, onMove) {
|
|
2006
|
+
let io = null;
|
|
2007
|
+
let timeoutId;
|
|
2008
|
+
const root = getDocumentElement(element);
|
|
2009
|
+
function cleanup() {
|
|
2010
|
+
var _io;
|
|
2011
|
+
clearTimeout(timeoutId);
|
|
2012
|
+
(_io = io) == null || _io.disconnect();
|
|
2013
|
+
io = null;
|
|
2014
|
+
}
|
|
2015
|
+
function refresh(skip, threshold) {
|
|
2016
|
+
if (skip === void 0) {
|
|
2017
|
+
skip = false;
|
|
2018
|
+
}
|
|
2019
|
+
if (threshold === void 0) {
|
|
2020
|
+
threshold = 1;
|
|
2021
|
+
}
|
|
2022
|
+
cleanup();
|
|
2023
|
+
const elementRectForRootMargin = element.getBoundingClientRect();
|
|
2024
|
+
const {
|
|
2025
|
+
left,
|
|
2026
|
+
top,
|
|
2027
|
+
width,
|
|
2028
|
+
height
|
|
2029
|
+
} = elementRectForRootMargin;
|
|
2030
|
+
if (!skip) {
|
|
2031
|
+
onMove();
|
|
2032
|
+
}
|
|
2033
|
+
if (!width || !height) {
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
const insetTop = floor(top);
|
|
2037
|
+
const insetRight = floor(root.clientWidth - (left + width));
|
|
2038
|
+
const insetBottom = floor(root.clientHeight - (top + height));
|
|
2039
|
+
const insetLeft = floor(left);
|
|
2040
|
+
const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
|
|
2041
|
+
const options = {
|
|
2042
|
+
rootMargin,
|
|
2043
|
+
threshold: max(0, min(1, threshold)) || 1
|
|
2044
|
+
};
|
|
2045
|
+
let isFirstUpdate = true;
|
|
2046
|
+
function handleObserve(entries) {
|
|
2047
|
+
const ratio = entries[0].intersectionRatio;
|
|
2048
|
+
if (ratio !== threshold) {
|
|
2049
|
+
if (!isFirstUpdate) {
|
|
2050
|
+
return refresh();
|
|
2051
|
+
}
|
|
2052
|
+
if (!ratio) {
|
|
2053
|
+
// If the reference is clipped, the ratio is 0. Throttle the refresh
|
|
2054
|
+
// to prevent an infinite loop of updates.
|
|
2055
|
+
timeoutId = setTimeout(() => {
|
|
2056
|
+
refresh(false, 1e-7);
|
|
2057
|
+
}, 1000);
|
|
2058
|
+
} else {
|
|
2059
|
+
refresh(false, ratio);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
|
|
2063
|
+
// It's possible that even though the ratio is reported as 1, the
|
|
2064
|
+
// element is not actually fully within the IntersectionObserver's root
|
|
2065
|
+
// area anymore. This can happen under performance constraints. This may
|
|
2066
|
+
// be a bug in the browser's IntersectionObserver implementation. To
|
|
2067
|
+
// work around this, we compare the element's bounding rect now with
|
|
2068
|
+
// what it was at the time we created the IntersectionObserver. If they
|
|
2069
|
+
// are not equal then the element moved, so we refresh.
|
|
2070
|
+
refresh();
|
|
2071
|
+
}
|
|
2072
|
+
isFirstUpdate = false;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
// Older browsers don't support a `document` as the root and will throw an
|
|
2076
|
+
// error.
|
|
2077
|
+
try {
|
|
2078
|
+
io = new IntersectionObserver(handleObserve, {
|
|
2079
|
+
...options,
|
|
2080
|
+
// Handle <iframe>s
|
|
2081
|
+
root: root.ownerDocument
|
|
2082
|
+
});
|
|
2083
|
+
} catch (_e) {
|
|
2084
|
+
io = new IntersectionObserver(handleObserve, options);
|
|
2085
|
+
}
|
|
2086
|
+
io.observe(element);
|
|
2087
|
+
}
|
|
2088
|
+
refresh(true);
|
|
2089
|
+
return cleanup;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* Automatically updates the position of the floating element when necessary.
|
|
2094
|
+
* Should only be called when the floating element is mounted on the DOM or
|
|
2095
|
+
* visible on the screen.
|
|
2096
|
+
* @returns cleanup function that should be invoked when the floating element is
|
|
2097
|
+
* removed from the DOM or hidden from the screen.
|
|
2098
|
+
* @see https://floating-ui.com/docs/autoUpdate
|
|
2099
|
+
*/
|
|
2100
|
+
function autoUpdate(reference, floating, update, options) {
|
|
2101
|
+
if (options === void 0) {
|
|
2102
|
+
options = {};
|
|
2103
|
+
}
|
|
2104
|
+
const {
|
|
2105
|
+
ancestorScroll = true,
|
|
2106
|
+
ancestorResize = true,
|
|
2107
|
+
elementResize = typeof ResizeObserver === 'function',
|
|
2108
|
+
layoutShift = typeof IntersectionObserver === 'function',
|
|
2109
|
+
animationFrame = false
|
|
2110
|
+
} = options;
|
|
2111
|
+
const referenceEl = unwrapElement(reference);
|
|
2112
|
+
const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
|
|
2113
|
+
ancestors.forEach(ancestor => {
|
|
2114
|
+
ancestorScroll && ancestor.addEventListener('scroll', update, {
|
|
2115
|
+
passive: true
|
|
2116
|
+
});
|
|
2117
|
+
ancestorResize && ancestor.addEventListener('resize', update);
|
|
2118
|
+
});
|
|
2119
|
+
const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
|
|
2120
|
+
let reobserveFrame = -1;
|
|
2121
|
+
let resizeObserver = null;
|
|
2122
|
+
if (elementResize) {
|
|
2123
|
+
resizeObserver = new ResizeObserver(_ref => {
|
|
2124
|
+
let [firstEntry] = _ref;
|
|
2125
|
+
if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
|
|
2126
|
+
// Prevent update loops when using the `size` middleware.
|
|
2127
|
+
// https://github.com/floating-ui/floating-ui/issues/1740
|
|
2128
|
+
resizeObserver.unobserve(floating);
|
|
2129
|
+
cancelAnimationFrame(reobserveFrame);
|
|
2130
|
+
reobserveFrame = requestAnimationFrame(() => {
|
|
2131
|
+
var _resizeObserver;
|
|
2132
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
update();
|
|
2136
|
+
});
|
|
2137
|
+
if (referenceEl && !animationFrame) {
|
|
2138
|
+
resizeObserver.observe(referenceEl);
|
|
2139
|
+
}
|
|
2140
|
+
resizeObserver.observe(floating);
|
|
2141
|
+
}
|
|
2142
|
+
let frameId;
|
|
2143
|
+
let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
|
|
2144
|
+
if (animationFrame) {
|
|
2145
|
+
frameLoop();
|
|
2146
|
+
}
|
|
2147
|
+
function frameLoop() {
|
|
2148
|
+
const nextRefRect = getBoundingClientRect(reference);
|
|
2149
|
+
if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
|
|
2150
|
+
update();
|
|
2151
|
+
}
|
|
2152
|
+
prevRefRect = nextRefRect;
|
|
2153
|
+
frameId = requestAnimationFrame(frameLoop);
|
|
2154
|
+
}
|
|
2155
|
+
update();
|
|
2156
|
+
return () => {
|
|
2157
|
+
var _resizeObserver2;
|
|
2158
|
+
ancestors.forEach(ancestor => {
|
|
2159
|
+
ancestorScroll && ancestor.removeEventListener('scroll', update);
|
|
2160
|
+
ancestorResize && ancestor.removeEventListener('resize', update);
|
|
2161
|
+
});
|
|
2162
|
+
cleanupIo == null || cleanupIo();
|
|
2163
|
+
(_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
|
|
2164
|
+
resizeObserver = null;
|
|
2165
|
+
if (animationFrame) {
|
|
2166
|
+
cancelAnimationFrame(frameId);
|
|
2167
|
+
}
|
|
2168
|
+
};
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
/**
|
|
2172
|
+
* Modifies the placement by translating the floating element along the
|
|
2173
|
+
* specified axes.
|
|
2174
|
+
* A number (shorthand for `mainAxis` or distance), or an axes configuration
|
|
2175
|
+
* object may be passed.
|
|
2176
|
+
* @see https://floating-ui.com/docs/offset
|
|
2177
|
+
*/
|
|
2178
|
+
const offset = offset$1;
|
|
2179
|
+
|
|
2180
|
+
/**
|
|
2181
|
+
* Optimizes the visibility of the floating element by shifting it in order to
|
|
2182
|
+
* keep it in view when it will overflow the clipping boundary.
|
|
2183
|
+
* @see https://floating-ui.com/docs/shift
|
|
2184
|
+
*/
|
|
2185
|
+
const shift = shift$1;
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* Optimizes the visibility of the floating element by flipping the `placement`
|
|
2189
|
+
* in order to keep it in view when the preferred placement(s) will overflow the
|
|
2190
|
+
* clipping boundary. Alternative to `autoPlacement`.
|
|
2191
|
+
* @see https://floating-ui.com/docs/flip
|
|
2192
|
+
*/
|
|
2193
|
+
const flip = flip$1;
|
|
2194
|
+
|
|
2195
|
+
/**
|
|
2196
|
+
* Provides data to position an inner element of the floating element so that it
|
|
2197
|
+
* appears centered to the reference element.
|
|
2198
|
+
* @see https://floating-ui.com/docs/arrow
|
|
2199
|
+
*/
|
|
2200
|
+
const arrow = arrow$1;
|
|
2201
|
+
|
|
2202
|
+
/**
|
|
2203
|
+
* Computes the `x` and `y` coordinates that will place the floating element
|
|
2204
|
+
* next to a given reference element.
|
|
2205
|
+
*/
|
|
2206
|
+
const computePosition = (reference, floating, options) => {
|
|
2207
|
+
// This caches the expensive `getClippingElementAncestors` function so that
|
|
2208
|
+
// multiple lifecycle resets re-use the same result. It only lives for a
|
|
2209
|
+
// single call. If other functions become expensive, we can add them as well.
|
|
2210
|
+
const cache = new Map();
|
|
2211
|
+
const mergedOptions = {
|
|
2212
|
+
platform,
|
|
2213
|
+
...options
|
|
2214
|
+
};
|
|
2215
|
+
const platformWithCache = {
|
|
2216
|
+
...mergedOptions.platform,
|
|
2217
|
+
_c: cache
|
|
2218
|
+
};
|
|
2219
|
+
return computePosition$1(reference, floating, {
|
|
2220
|
+
...mergedOptions,
|
|
2221
|
+
platform: platformWithCache
|
|
2222
|
+
});
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const linkedCss = ".visible{visibility:visible}.absolute{position:absolute}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.border{border-width:1px}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}:host{display:inline-block}[popover]{background:transparent;border:none;margin:0;opacity:0;overflow:visible;padding:0;position:absolute;transform:scale(.95);transition:opacity .15s ease-out,transform .15s ease-out,display allow-discrete .15s ease-out,overlay allow-discrete .15s ease-out}[popover]:popover-open{opacity:1;transform:scale(1)}@starting-style{[popover]:popover-open{opacity:0;transform:scale(.95)}}[data-placement^=top] [part=arrow]{border-left:none;border-top:none;bottom:-4px}[data-placement^=bottom] [part=arrow]{border-bottom:none;border-right:none;top:-4px}[data-placement^=left] [part=arrow]{border-bottom:none;border-left:none;right:-4px}[data-placement^=right] [part=arrow]{border-right:none;border-top:none;left:-4px}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.relative{position:relative}.inline-block{display:inline-block}.h-2{height:.5rem}.w-2{width:.5rem}.rotate-45{--tw-rotate:45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded-md{border-radius:var(--bcm-ui-border-radius-md,6px)}.bg-color-basic-base{background-color:var(--bcm-ui-color-background-basic-base)}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-lg{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--bcm-ui-box-shadow-lg);--tw-shadow-colored:var(--bcm-ui-box-shadow-lg)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.flex{display:flex}.max-h-64{max-height:16rem}.w-full{width:100%}.min-w-10{min-width:2.5rem}.max-w-64{max-width:16rem}.flex-col{flex-direction:column}.items-center{align-items:center}.overflow-y-auto{overflow-y:auto}.rounded-lg{border-radius:var(--bcm-ui-border-radius-lg,8px)}.bg-color-basic-panel{background-color:var(--bcm-ui-color-background-basic-panel)}.py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}.outline{outline-style:solid}";
|
|
2226
|
+
|
|
2227
|
+
const BcmLinked = class {
|
|
2228
|
+
constructor(hostRef) {
|
|
2229
|
+
index.registerInstance(this, hostRef);
|
|
2230
|
+
this.bcmBeforeShow = index.createEvent(this, "bcmBeforeShow", 1);
|
|
2231
|
+
this.bcmShow = index.createEvent(this, "bcmShow", 1);
|
|
2232
|
+
this.bcmBeforeHide = index.createEvent(this, "bcmBeforeHide", 1);
|
|
2233
|
+
this.bcmHide = index.createEvent(this, "bcmHide", 1);
|
|
2234
|
+
this.bcmShown = index.createEvent(this, "bcmShown", 1);
|
|
2235
|
+
this.bcmHidden = index.createEvent(this, "bcmHidden", 1);
|
|
2236
|
+
// Unique ID for ARIA
|
|
2237
|
+
this.componentId = `linked-${Math.random().toString(36).substring(2, 11)}`;
|
|
2238
|
+
/**
|
|
2239
|
+
* @prop {boolean} visible - Controls the visibility state of the floating element.
|
|
2240
|
+
* Can be set programmatically or toggled by user interaction.
|
|
2241
|
+
* Default: false
|
|
2242
|
+
*/
|
|
2243
|
+
this.visible = false;
|
|
2244
|
+
/**
|
|
2245
|
+
* @prop {TriggerType} trigger - Defines the interaction type to show/hide the floating element.
|
|
2246
|
+
* 'click' toggles on click, 'hover' shows on mouse enter and hides on mouse leave,
|
|
2247
|
+
* 'focus' shows on focus and hides on blur, 'manual' requires programmatic control.
|
|
2248
|
+
* Default: 'click'
|
|
2249
|
+
*/
|
|
2250
|
+
this.trigger = 'click';
|
|
2251
|
+
/**
|
|
2252
|
+
* @prop {Placement} placement - Defines the position of the floating element relative to the trigger.
|
|
2253
|
+
* Default: 'bottom-start'
|
|
2254
|
+
*/
|
|
2255
|
+
this.placement = 'bottom-start';
|
|
2256
|
+
/**
|
|
2257
|
+
* @prop {number} showDelay - Delay in milliseconds before showing the floating element.
|
|
2258
|
+
* Default: 0
|
|
2259
|
+
*/
|
|
2260
|
+
this.showDelay = 0;
|
|
2261
|
+
/**
|
|
2262
|
+
* @prop {number} hideDelay - Delay in milliseconds before hiding the floating element.
|
|
2263
|
+
* Default: 0
|
|
2264
|
+
*/
|
|
2265
|
+
this.hideDelay = 0;
|
|
2266
|
+
/**
|
|
2267
|
+
* @prop {number} offsetDistance - Distance in pixels between the floating element and the trigger.
|
|
2268
|
+
* Default: 8
|
|
2269
|
+
*/
|
|
2270
|
+
this.offsetDistance = 8;
|
|
2271
|
+
/**
|
|
2272
|
+
* @prop {boolean} showArrow - Whether to show an arrow pointing to the trigger element.
|
|
2273
|
+
* Default: true
|
|
2274
|
+
*/
|
|
2275
|
+
this.showArrow = true;
|
|
2276
|
+
/**
|
|
2277
|
+
* @prop {boolean} disabled - Disables the floating element, preventing it from showing.
|
|
2278
|
+
* Default: false
|
|
2279
|
+
*/
|
|
2280
|
+
this.disabled = false;
|
|
2281
|
+
/**
|
|
2282
|
+
* @prop {boolean} closeOnOutsideClick - Whether to close when clicking outside.
|
|
2283
|
+
* Default: true
|
|
2284
|
+
*/
|
|
2285
|
+
this.closeOnOutsideClick = true;
|
|
2286
|
+
/**
|
|
2287
|
+
* @prop {boolean} closeOnEscape - Whether to close when pressing Escape key.
|
|
2288
|
+
* Default: true
|
|
2289
|
+
*/
|
|
2290
|
+
this.closeOnEscape = true;
|
|
2291
|
+
// Internal state
|
|
2292
|
+
this.isVisible = false;
|
|
2293
|
+
this.handleTriggerSlotChange = () => {
|
|
2294
|
+
var _a;
|
|
2295
|
+
const slot = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot[name="trigger"]');
|
|
2296
|
+
if (!slot)
|
|
2297
|
+
return;
|
|
2298
|
+
const elements = slot.assignedElements();
|
|
2299
|
+
if (elements.length > 0) {
|
|
2300
|
+
this.removeTriggerListeners();
|
|
2301
|
+
this.triggerRef = elements[0];
|
|
2302
|
+
this.setupTriggerListeners();
|
|
2303
|
+
this.setupAriaAttributes();
|
|
2304
|
+
}
|
|
2305
|
+
};
|
|
2306
|
+
this.handleMouseEnter = () => {
|
|
2307
|
+
this.show();
|
|
2308
|
+
};
|
|
2309
|
+
this.handleMouseLeave = () => {
|
|
2310
|
+
this.hide();
|
|
2311
|
+
};
|
|
2312
|
+
this.handleFloatingMouseEnter = () => {
|
|
2313
|
+
this.clearTimeouts();
|
|
2314
|
+
};
|
|
2315
|
+
this.handleFloatingMouseLeave = () => {
|
|
2316
|
+
this.hide();
|
|
2317
|
+
};
|
|
2318
|
+
this.handleTriggerClick = (event) => {
|
|
2319
|
+
event.stopPropagation();
|
|
2320
|
+
this.toggle();
|
|
2321
|
+
};
|
|
2322
|
+
this.handleFocus = () => {
|
|
2323
|
+
this.show();
|
|
2324
|
+
};
|
|
2325
|
+
this.handleBlur = () => {
|
|
2326
|
+
this.hide();
|
|
2327
|
+
};
|
|
2328
|
+
this.handleOutsideClick = (event) => {
|
|
2329
|
+
var _a;
|
|
2330
|
+
if (!this.closeOnOutsideClick || !this.visible)
|
|
2331
|
+
return;
|
|
2332
|
+
const target = event.target;
|
|
2333
|
+
const path = event.composedPath();
|
|
2334
|
+
const isInsideHost = this.host.contains(target) || path.includes(this.host);
|
|
2335
|
+
const isInsideFloating = ((_a = this.floatingRef) === null || _a === void 0 ? void 0 : _a.contains(target)) || (this.floatingRef && path.includes(this.floatingRef));
|
|
2336
|
+
if (!isInsideHost && !isInsideFloating) {
|
|
2337
|
+
this.hide();
|
|
2338
|
+
}
|
|
2339
|
+
};
|
|
2340
|
+
this.handleToggle = (event) => {
|
|
2341
|
+
if (event.newState === 'open' && !this.isVisible) {
|
|
2342
|
+
this.isVisible = true;
|
|
2343
|
+
}
|
|
2344
|
+
else if (event.newState === 'closed' && this.isVisible) {
|
|
2345
|
+
this.isVisible = false;
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2348
|
+
this.linkedClass = tv.tv({
|
|
2349
|
+
slots: {
|
|
2350
|
+
wrapper: 'inline-block',
|
|
2351
|
+
floating: ['bcm-ui-element', 'fixed', 'bg-color-basic-base', 'rounded-md', 'shadow-lg', 'border', 'border-color-basic-subtle'],
|
|
2352
|
+
arrow: ['absolute', 'w-2', 'h-2', 'bg-color-basic-base', 'border', 'border-color-basic-subtle', 'rotate-45'],
|
|
2353
|
+
content: 'bg-color-basic-base',
|
|
2354
|
+
},
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
// Watch for visibility prop changes
|
|
2358
|
+
handleVisibleChange(newValue) {
|
|
2359
|
+
if (this.disabled)
|
|
2360
|
+
return;
|
|
2361
|
+
if (newValue) {
|
|
2362
|
+
this.showInternal();
|
|
2363
|
+
}
|
|
2364
|
+
else {
|
|
2365
|
+
this.hideInternal();
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
handleDisabledChange(isDisabled) {
|
|
2369
|
+
if (isDisabled && this.visible) {
|
|
2370
|
+
this.hide();
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
handlePositionPropsChange() {
|
|
2374
|
+
if (this.visible) {
|
|
2375
|
+
this.updatePosition();
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
// Internal show logic
|
|
2379
|
+
showInternal() {
|
|
2380
|
+
var _a;
|
|
2381
|
+
if (!this.floatingRef || this.disabled)
|
|
2382
|
+
return;
|
|
2383
|
+
this.bcmShow.emit();
|
|
2384
|
+
this.isVisible = true;
|
|
2385
|
+
this.floatingRef.showPopover();
|
|
2386
|
+
this.startAutoUpdate();
|
|
2387
|
+
this.updatePosition();
|
|
2388
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
|
|
2389
|
+
if (this.closeOnOutsideClick && this.trigger !== 'manual') {
|
|
2390
|
+
this.addOutsideClickListener();
|
|
2391
|
+
}
|
|
2392
|
+
// Emit bcmShown after animation
|
|
2393
|
+
requestAnimationFrame(() => {
|
|
2394
|
+
this.bcmShown.emit();
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
// Internal hide logic
|
|
2398
|
+
hideInternal() {
|
|
2399
|
+
var _a;
|
|
2400
|
+
if (!this.floatingRef)
|
|
2401
|
+
return;
|
|
2402
|
+
this.bcmHide.emit();
|
|
2403
|
+
this.isVisible = false;
|
|
2404
|
+
this.floatingRef.hidePopover();
|
|
2405
|
+
this.stopAutoUpdate();
|
|
2406
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
|
|
2407
|
+
this.removeOutsideClickListener();
|
|
2408
|
+
// Emit bcmHidden after animation
|
|
2409
|
+
setTimeout(() => {
|
|
2410
|
+
this.bcmHidden.emit();
|
|
2411
|
+
}, 150);
|
|
2412
|
+
}
|
|
2413
|
+
/**
|
|
2414
|
+
* Programmatically shows the floating element.
|
|
2415
|
+
* Respects the showDelay prop.
|
|
2416
|
+
*/
|
|
2417
|
+
async show() {
|
|
2418
|
+
if (this.visible || this.disabled)
|
|
2419
|
+
return;
|
|
2420
|
+
this.clearTimeouts();
|
|
2421
|
+
if (this.showDelay > 0) {
|
|
2422
|
+
this.showTimeout = window.setTimeout(() => {
|
|
2423
|
+
this.bcmBeforeShow.emit();
|
|
2424
|
+
this.visible = true;
|
|
2425
|
+
}, this.showDelay);
|
|
2426
|
+
}
|
|
2427
|
+
else {
|
|
2428
|
+
this.bcmBeforeShow.emit();
|
|
2429
|
+
this.visible = true;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Programmatically hides the floating element.
|
|
2434
|
+
* Respects the hideDelay prop.
|
|
2435
|
+
*/
|
|
2436
|
+
async hide() {
|
|
2437
|
+
if (!this.visible)
|
|
2438
|
+
return;
|
|
2439
|
+
this.clearTimeouts();
|
|
2440
|
+
if (this.hideDelay > 0) {
|
|
2441
|
+
this.hideTimeout = window.setTimeout(() => {
|
|
2442
|
+
this.bcmBeforeHide.emit();
|
|
2443
|
+
this.visible = false;
|
|
2444
|
+
}, this.hideDelay);
|
|
2445
|
+
}
|
|
2446
|
+
else {
|
|
2447
|
+
this.bcmBeforeHide.emit();
|
|
2448
|
+
this.visible = false;
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Toggles the floating element visibility.
|
|
2453
|
+
*/
|
|
2454
|
+
async toggle() {
|
|
2455
|
+
if (this.visible) {
|
|
2456
|
+
await this.hide();
|
|
2457
|
+
}
|
|
2458
|
+
else {
|
|
2459
|
+
await this.show();
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Updates the position of the floating element.
|
|
2464
|
+
* Useful when the trigger element moves or resizes.
|
|
2465
|
+
*/
|
|
2466
|
+
async updatePosition() {
|
|
2467
|
+
await this.calculatePosition();
|
|
2468
|
+
}
|
|
2469
|
+
clearTimeouts() {
|
|
2470
|
+
if (this.showTimeout) {
|
|
2471
|
+
clearTimeout(this.showTimeout);
|
|
2472
|
+
this.showTimeout = undefined;
|
|
2473
|
+
}
|
|
2474
|
+
if (this.hideTimeout) {
|
|
2475
|
+
clearTimeout(this.hideTimeout);
|
|
2476
|
+
this.hideTimeout = undefined;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
setupAriaAttributes() {
|
|
2480
|
+
if (!this.triggerRef)
|
|
2481
|
+
return;
|
|
2482
|
+
this.triggerRef.setAttribute('aria-describedby', this.componentId);
|
|
2483
|
+
this.triggerRef.setAttribute('aria-expanded', String(this.visible));
|
|
2484
|
+
this.triggerRef.setAttribute('aria-haspopup', 'true');
|
|
2485
|
+
}
|
|
2486
|
+
setupTriggerListeners() {
|
|
2487
|
+
var _a, _b;
|
|
2488
|
+
if (!this.triggerRef || this.disabled)
|
|
2489
|
+
return;
|
|
2490
|
+
switch (this.trigger) {
|
|
2491
|
+
case 'hover':
|
|
2492
|
+
this.triggerRef.addEventListener('mouseenter', this.handleMouseEnter);
|
|
2493
|
+
this.triggerRef.addEventListener('mouseleave', this.handleMouseLeave);
|
|
2494
|
+
(_a = this.floatingRef) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.handleFloatingMouseEnter);
|
|
2495
|
+
(_b = this.floatingRef) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.handleFloatingMouseLeave);
|
|
2496
|
+
break;
|
|
2497
|
+
case 'click':
|
|
2498
|
+
this.triggerRef.addEventListener('click', this.handleTriggerClick);
|
|
2499
|
+
break;
|
|
2500
|
+
case 'focus':
|
|
2501
|
+
this.triggerRef.addEventListener('focus', this.handleFocus);
|
|
2502
|
+
this.triggerRef.addEventListener('blur', this.handleBlur);
|
|
2503
|
+
break;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
removeTriggerListeners() {
|
|
2507
|
+
var _a, _b;
|
|
2508
|
+
if (!this.triggerRef)
|
|
2509
|
+
return;
|
|
2510
|
+
this.triggerRef.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
2511
|
+
this.triggerRef.removeEventListener('mouseleave', this.handleMouseLeave);
|
|
2512
|
+
this.triggerRef.removeEventListener('click', this.handleTriggerClick);
|
|
2513
|
+
this.triggerRef.removeEventListener('focus', this.handleFocus);
|
|
2514
|
+
this.triggerRef.removeEventListener('blur', this.handleBlur);
|
|
2515
|
+
(_a = this.floatingRef) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.handleFloatingMouseEnter);
|
|
2516
|
+
(_b = this.floatingRef) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.handleFloatingMouseLeave);
|
|
2517
|
+
}
|
|
2518
|
+
handleKeyDown(event) {
|
|
2519
|
+
var _a;
|
|
2520
|
+
if (!this.closeOnEscape || !this.visible)
|
|
2521
|
+
return;
|
|
2522
|
+
if (event.key === 'Escape') {
|
|
2523
|
+
const openLinked = Array.from(document.querySelectorAll('bcm-linked[visible]'));
|
|
2524
|
+
const topLinked = openLinked[openLinked.length - 1];
|
|
2525
|
+
if (topLinked === this.host) {
|
|
2526
|
+
event.preventDefault();
|
|
2527
|
+
this.hide();
|
|
2528
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
addOutsideClickListener() {
|
|
2533
|
+
setTimeout(() => {
|
|
2534
|
+
document.addEventListener('click', this.handleOutsideClick, true);
|
|
2535
|
+
}, 0);
|
|
2536
|
+
}
|
|
2537
|
+
removeOutsideClickListener() {
|
|
2538
|
+
document.removeEventListener('click', this.handleOutsideClick, true);
|
|
2539
|
+
}
|
|
2540
|
+
async calculatePosition() {
|
|
2541
|
+
if (!this.triggerRef || !this.floatingRef || !this.isVisible)
|
|
2542
|
+
return;
|
|
2543
|
+
const virtualElement = {
|
|
2544
|
+
getBoundingClientRect: () => this.triggerRef.getBoundingClientRect(),
|
|
2545
|
+
};
|
|
2546
|
+
const middlewareList = [
|
|
2547
|
+
offset(this.offsetDistance),
|
|
2548
|
+
flip({
|
|
2549
|
+
fallbackPlacements: ['top', 'bottom', 'left', 'right', 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end', 'right-start', 'right-end'],
|
|
2550
|
+
}),
|
|
2551
|
+
shift({
|
|
2552
|
+
padding: 8,
|
|
2553
|
+
}),
|
|
2554
|
+
];
|
|
2555
|
+
if (this.showArrow && this.arrowRef) {
|
|
2556
|
+
middlewareList.push(arrow({ element: this.arrowRef }));
|
|
2557
|
+
}
|
|
2558
|
+
const { x, y, placement, middlewareData } = await computePosition(virtualElement, this.floatingRef, {
|
|
2559
|
+
placement: this.placement,
|
|
2560
|
+
middleware: middlewareList,
|
|
2561
|
+
strategy: 'fixed',
|
|
2562
|
+
});
|
|
2563
|
+
Object.assign(this.floatingRef.style, {
|
|
2564
|
+
left: `${x}px`,
|
|
2565
|
+
top: `${y}px`,
|
|
2566
|
+
});
|
|
2567
|
+
// Arrow positioning
|
|
2568
|
+
if (this.showArrow && this.arrowRef && middlewareData.arrow) {
|
|
2569
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
2570
|
+
const staticSide = {
|
|
2571
|
+
top: 'bottom',
|
|
2572
|
+
right: 'left',
|
|
2573
|
+
bottom: 'top',
|
|
2574
|
+
left: 'right',
|
|
2575
|
+
}[placement.split('-')[0]];
|
|
2576
|
+
Object.assign(this.arrowRef.style, {
|
|
2577
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
2578
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
2579
|
+
right: '',
|
|
2580
|
+
bottom: '',
|
|
2581
|
+
[staticSide]: '-4px',
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
this.floatingRef.setAttribute('data-placement', placement);
|
|
2585
|
+
}
|
|
2586
|
+
startAutoUpdate() {
|
|
2587
|
+
if (!this.triggerRef || !this.floatingRef)
|
|
2588
|
+
return;
|
|
2589
|
+
this.cleanupAutoUpdate = autoUpdate(this.triggerRef, this.floatingRef, () => this.calculatePosition(), {
|
|
2590
|
+
ancestorScroll: true,
|
|
2591
|
+
ancestorResize: true,
|
|
2592
|
+
elementResize: true,
|
|
2593
|
+
layoutShift: true,
|
|
2594
|
+
});
|
|
2595
|
+
}
|
|
2596
|
+
stopAutoUpdate() {
|
|
2597
|
+
var _a;
|
|
2598
|
+
(_a = this.cleanupAutoUpdate) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
2599
|
+
this.cleanupAutoUpdate = undefined;
|
|
2600
|
+
}
|
|
2601
|
+
componentDidLoad() {
|
|
2602
|
+
var _a;
|
|
2603
|
+
// Toggle event listener (Popover API)
|
|
2604
|
+
(_a = this.floatingRef) === null || _a === void 0 ? void 0 : _a.addEventListener('toggle', this.handleToggle);
|
|
2605
|
+
// Initial trigger setup - manually trigger slot change handler
|
|
2606
|
+
this.handleTriggerSlotChange();
|
|
2607
|
+
// Initial state sync
|
|
2608
|
+
if (this.visible) {
|
|
2609
|
+
this.showInternal();
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
disconnectedCallback() {
|
|
2613
|
+
this.clearTimeouts();
|
|
2614
|
+
this.stopAutoUpdate();
|
|
2615
|
+
this.removeTriggerListeners();
|
|
2616
|
+
this.removeOutsideClickListener();
|
|
2617
|
+
if (this.floatingRef) {
|
|
2618
|
+
this.floatingRef.removeEventListener('toggle', this.handleToggle);
|
|
2619
|
+
if (this.isVisible) {
|
|
2620
|
+
try {
|
|
2621
|
+
this.floatingRef.hidePopover();
|
|
2622
|
+
}
|
|
2623
|
+
catch (e) {
|
|
2624
|
+
// Element might already be removed
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
render() {
|
|
2630
|
+
const { wrapper, floating, arrow, content } = this.linkedClass();
|
|
2631
|
+
return (index.h(index.Host, { key: 'f58760b6589329f9eabc42f39b6503fad10cf330' }, index.h("div", { key: 'adb9003eec4ca786bdddc657ba28cbc0a80baf57', class: wrapper() }, index.h("slot", { key: '61323463e76c395668d02288e5bdcb44826a31ea', name: "trigger", onSlotchange: this.handleTriggerSlotChange }), index.h("div", { key: '3b395b18152cd302b4511ef89928374f33012594', ref: el => (this.floatingRef = el), id: this.componentId, part: "floating", class: floating(),
|
|
2632
|
+
// @ts-ignore - popover is a valid HTML attribute
|
|
2633
|
+
popover: "manual", role: "dialog" }, this.showArrow && index.h("div", { key: '3f5311d21f7fce74c94ac0435a8d2fc076036b10', ref: el => (this.arrowRef = el), part: "arrow", class: arrow() }), index.h("div", { key: 'ee41f30c7f73c113f129f938fd721476658b5744', part: "content", class: content() }, index.h("slot", { key: '106502e2f8db8fdc90412fcf59da40d2de377988' }))))));
|
|
2634
|
+
}
|
|
2635
|
+
get host() { return index.getElement(this); }
|
|
2636
|
+
static get watchers() { return {
|
|
2637
|
+
"visible": ["handleVisibleChange"],
|
|
2638
|
+
"disabled": ["handleDisabledChange"],
|
|
2639
|
+
"placement": ["handlePositionPropsChange"],
|
|
2640
|
+
"offsetDistance": ["handlePositionPropsChange"],
|
|
2641
|
+
"showArrow": ["handlePositionPropsChange"]
|
|
2642
|
+
}; }
|
|
2643
|
+
};
|
|
2644
|
+
BcmLinked.style = linkedCss;
|
|
2645
|
+
|
|
2646
|
+
const modalCss = ".contents{display:contents}:host{display:contents}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.relative{position:relative}.inset-0{inset:0}.m-0{margin:0}.flex{display:flex}.hidden{display:none}.h-6{height:1.5rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-full{max-height:100%}.max-h-none{max-height:none}.w-6{width:1.5rem}.w-full{width:100%}.w-screen{width:100vw}.min-w-0{min-width:0}.max-w-full{max-width:100%}.max-w-none{max-width:none}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.flex-grow{flex-grow:1}.-translate-y-4{--tw-translate-y:-1rem}.-translate-y-4,.translate-y-0{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y:0px}.scale-100{--tw-scale-x:1;--tw-scale-y:1}.scale-100,.scale-95{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.scale-95{--tw-scale-x:.95;--tw-scale-y:.95}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.animate-shake{animation:shake .82s cubic-bezier(.36,.07,.19,.97) infinite;animation:shake .3s cubic-bezier(.36,.07,.19,.97) both}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-2{gap:.5rem}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.rounded{border-radius:var(--bcm-ui-border-radius-default,6px)}.rounded-lg{border-radius:var(--bcm-ui-border-radius-lg,8px)}.rounded-none{border-radius:var(--bcm-ui-border-radius-none,0)}.rounded-t-lg{border-top-left-radius:var(--bcm-ui-border-radius-lg,8px);border-top-right-radius:var(--bcm-ui-border-radius-lg,8px)}.border{border-width:1px}.border-0{border-width:0}.border-b{border-bottom-width:1px}.border-solid{border-style:solid}.border-none{border-style:none}.border-color-default{border-color:var(--bcm-ui-color-border-default)}.bg-color-base{background-color:var(--bcm-ui-color-background-base-default)}.bg-color-basic-base{background-color:var(--bcm-ui-color-background-basic-base)}.bg-transparent{background-color:transparent}.p-0{padding:0}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.py-3{padding-bottom:.75rem;padding-top:.75rem}.py-4{padding-bottom:1rem;padding-top:1rem}.py-5{padding-bottom:1.25rem;padding-top:1.25rem}.pt-20{padding-top:5rem}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.text-size-6{font-size:var(--bcm-ui-font-size-6,18px);line-height:var(--bcm-ui-line-height-6,24px)}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-color-default{color:var(--bcm-ui-color-text-default)}.text-color-header{color:var(--bcm-ui-color-text-header)}.text-color-placeholder{color:var(--bcm-ui-color-text-placeholder)}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-2xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-2xl{--tw-shadow:var(--bcm-ui-box-shadow-2xl);--tw-shadow-colored:var(--bcm-ui-box-shadow-2xl)}.outline-none{outline:2px solid transparent;outline-offset:2px}.transition-all{transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-colors{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.backdrop\\:bg-color-default-dark::backdrop{background-color:var(--bcm-ui-color-background-default-dark-default)}.backdrop\\:opacity-50::backdrop{opacity:.5}.backdrop\\:transition-opacity::backdrop{transition-duration:.15s;transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1)}.backdrop\\:duration-300::backdrop{transition-duration:.3s}.hover\\:bg-color-default-hover:hover{background-color:var(--bcm-ui-color-background-default-hover)}.focus-visible\\:ring:focus-visible{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000)}";
|
|
2647
|
+
|
|
2648
|
+
const BcmModal = class {
|
|
2649
|
+
constructor(hostRef) {
|
|
2650
|
+
index.registerInstance(this, hostRef);
|
|
2651
|
+
this.bcmOpen = index.createEvent(this, "bcmOpen", 7);
|
|
2652
|
+
this.bcmClose = index.createEvent(this, "bcmClose", 7);
|
|
2653
|
+
this.bcmBeforeOpen = index.createEvent(this, "bcmBeforeOpen", 7);
|
|
2654
|
+
this.bcmBeforeClose = index.createEvent(this, "bcmBeforeClose", 7);
|
|
2655
|
+
/**
|
|
2656
|
+
* Controls whether the modal is open or closed
|
|
2657
|
+
*/
|
|
2658
|
+
this.open = false;
|
|
2659
|
+
/**
|
|
2660
|
+
* The size of the modal
|
|
2661
|
+
* - 'small': 400px
|
|
2662
|
+
* - 'medium': 600px
|
|
2663
|
+
* - 'large': 800px
|
|
2664
|
+
* - 'xlarge': 1024px
|
|
2665
|
+
* - 'xxlarge': 1200px
|
|
2666
|
+
* - 'full': 100% width
|
|
2667
|
+
*/
|
|
2668
|
+
this.size = 'medium';
|
|
2669
|
+
/**
|
|
2670
|
+
* The placement of the modal on the screen
|
|
2671
|
+
* - 'center': Centered vertically and horizontally
|
|
2672
|
+
* - 'top': Aligned to the top with 80px padding
|
|
2673
|
+
*/
|
|
2674
|
+
this.placement = 'center';
|
|
2675
|
+
/**
|
|
2676
|
+
* Controls backdrop behavior
|
|
2677
|
+
* - true: Shows backdrop, modal can be closed by clicking outside
|
|
2678
|
+
* - false: No backdrop
|
|
2679
|
+
* - 'static': Shows backdrop but prevents closing by clicking outside (triggers shake animation)
|
|
2680
|
+
*/
|
|
2681
|
+
this.backdrop = true;
|
|
2682
|
+
/**
|
|
2683
|
+
* Makes the modal take full width of the viewport (max-width: 100%)
|
|
2684
|
+
*/
|
|
2685
|
+
this.fullWidth = false;
|
|
2686
|
+
/**
|
|
2687
|
+
* Makes the modal take the full screen (100vw x 100vh, no border radius)
|
|
2688
|
+
*/
|
|
2689
|
+
this.fullScreen = false;
|
|
2690
|
+
/**
|
|
2691
|
+
* Hides the header section completely
|
|
2692
|
+
*/
|
|
2693
|
+
this.noHeader = false;
|
|
2694
|
+
/**
|
|
2695
|
+
* Hides the footer section completely
|
|
2696
|
+
*/
|
|
2697
|
+
this.noFooter = false;
|
|
2698
|
+
/**
|
|
2699
|
+
* Allows closing the modal by clicking on the backdrop
|
|
2700
|
+
*/
|
|
2701
|
+
this.closeOnBackdrop = true;
|
|
2702
|
+
/**
|
|
2703
|
+
* Allows closing the modal by pressing the Escape key
|
|
2704
|
+
*/
|
|
2705
|
+
this.closeOnEscape = true;
|
|
2706
|
+
this.isAnimating = false;
|
|
2707
|
+
this.shake = false;
|
|
2708
|
+
this.modalClass = tv.tv({
|
|
2709
|
+
slots: {
|
|
2710
|
+
dialog: 'bcm-ui-element fixed inset-0 m-0 p-0 w-full max-w-full h-full max-h-full border-none bg-transparent backdrop:bg-color-default-dark backdrop:opacity-50 backdrop:transition-opacity backdrop:duration-300',
|
|
2711
|
+
container: 'fixed inset-0 flex items-start justify-center p-4 overflow-y-auto overscroll-contain',
|
|
2712
|
+
modal: 'relative bg-color-basic-base text-color-default rounded-lg shadow-2xl transform transition-all duration-300 ease-in-out flex flex-col',
|
|
2713
|
+
header: 'flex justify-between items-start bg-color-base text-color-default border-color-default border-solid border-0 border-b rounded-t-lg',
|
|
2714
|
+
headerContent: 'flex-1 min-w-0 flex items-center gap-2',
|
|
2715
|
+
title: 'font-semibold m-0 text-size-6 text-color-header',
|
|
2716
|
+
helperText: 'text-size-5 text-color-placeholder m-0',
|
|
2717
|
+
closeButton: 'text-size-5 font-medium text-color-default bg-transparent border-none p-0 h-6 w-6 rounded hover:bg-color-default-hover cursor-pointer active:bg-color-active transition-colors flex-shrink-0 outline-none focus-visible:ring ',
|
|
2718
|
+
content: 'flex-grow overflow-y-auto',
|
|
2719
|
+
footer: 'flex items-center justify-end gap-2',
|
|
2720
|
+
},
|
|
2721
|
+
variants: {
|
|
2722
|
+
open: {
|
|
2723
|
+
true: {
|
|
2724
|
+
modal: 'opacity-100 translate-y-0 scale-100',
|
|
2725
|
+
},
|
|
2726
|
+
false: {
|
|
2727
|
+
modal: 'opacity-0 -translate-y-4 scale-95',
|
|
2728
|
+
},
|
|
2729
|
+
},
|
|
2730
|
+
placement: {
|
|
2731
|
+
center: {
|
|
2732
|
+
container: 'items-center',
|
|
2733
|
+
},
|
|
2734
|
+
top: {
|
|
2735
|
+
container: 'items-start pt-20',
|
|
2736
|
+
},
|
|
2737
|
+
},
|
|
2738
|
+
size: {
|
|
2739
|
+
small: {
|
|
2740
|
+
header: 'py-3 px-4',
|
|
2741
|
+
content: 'p-4',
|
|
2742
|
+
footer: 'py-3 px-4',
|
|
2743
|
+
},
|
|
2744
|
+
medium: {
|
|
2745
|
+
header: 'py-4 px-5',
|
|
2746
|
+
content: 'p-5',
|
|
2747
|
+
footer: 'py-4 px-5',
|
|
2748
|
+
},
|
|
2749
|
+
large: {
|
|
2750
|
+
header: 'py-4 px-6',
|
|
2751
|
+
content: 'p-6',
|
|
2752
|
+
footer: 'py-4 px-6',
|
|
2753
|
+
},
|
|
2754
|
+
xlarge: {
|
|
2755
|
+
header: 'py-5 px-6',
|
|
2756
|
+
content: 'p-6',
|
|
2757
|
+
footer: 'py-5 px-6',
|
|
2758
|
+
},
|
|
2759
|
+
xxlarge: {
|
|
2760
|
+
header: 'py-5 px-8',
|
|
2761
|
+
content: 'p-8',
|
|
2762
|
+
footer: 'py-5 px-8',
|
|
2763
|
+
},
|
|
2764
|
+
full: {
|
|
2765
|
+
header: 'py-5 px-8',
|
|
2766
|
+
content: 'p-8',
|
|
2767
|
+
footer: 'py-5 px-8',
|
|
2768
|
+
},
|
|
2769
|
+
},
|
|
2770
|
+
fullScreen: {
|
|
2771
|
+
true: {
|
|
2772
|
+
modal: 'rounded-none w-screen h-screen max-w-none max-h-none',
|
|
2773
|
+
container: 'p-0',
|
|
2774
|
+
},
|
|
2775
|
+
},
|
|
2776
|
+
shake: {
|
|
2777
|
+
true: {
|
|
2778
|
+
modal: 'animate-shake',
|
|
2779
|
+
},
|
|
2780
|
+
},
|
|
2781
|
+
noHeader: {
|
|
2782
|
+
true: {
|
|
2783
|
+
header: 'hidden',
|
|
2784
|
+
},
|
|
2785
|
+
},
|
|
2786
|
+
noFooter: {
|
|
2787
|
+
true: {
|
|
2788
|
+
footer: 'hidden',
|
|
2789
|
+
},
|
|
2790
|
+
},
|
|
2791
|
+
},
|
|
2792
|
+
});
|
|
2793
|
+
this.handleBackdropClick = (event) => {
|
|
2794
|
+
const target = event.target;
|
|
2795
|
+
// Check if click is on the container (backdrop area), not on modal content
|
|
2796
|
+
if (target.getAttribute('part') === 'container') {
|
|
2797
|
+
if (this.backdrop === 'static') {
|
|
2798
|
+
this.shakeModal();
|
|
2799
|
+
}
|
|
2800
|
+
else if (this.closeOnBackdrop) {
|
|
2801
|
+
this.hide();
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
this.handleDialogCancel = (event) => {
|
|
2806
|
+
event.preventDefault();
|
|
2807
|
+
if (this.closeOnEscape) {
|
|
2808
|
+
if (this.backdrop === 'static') {
|
|
2809
|
+
this.shakeModal();
|
|
2810
|
+
}
|
|
2811
|
+
else {
|
|
2812
|
+
this.hide();
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
async handleOpenChange(isOpen) {
|
|
2818
|
+
if (isOpen) {
|
|
2819
|
+
this.isAnimating = true;
|
|
2820
|
+
const event = this.bcmBeforeOpen.emit();
|
|
2821
|
+
if (event.defaultPrevented) {
|
|
2822
|
+
this.open = false;
|
|
2823
|
+
return;
|
|
2824
|
+
}
|
|
2825
|
+
// Use native dialog API with top-layer
|
|
2826
|
+
if (this.dialogRef) {
|
|
2827
|
+
this.dialogRef.showModal();
|
|
2828
|
+
// Small delay for animation
|
|
2829
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
2830
|
+
this.isAnimating = false;
|
|
2831
|
+
this.bcmOpen.emit();
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
else {
|
|
2835
|
+
this.isAnimating = true;
|
|
2836
|
+
const event = this.bcmBeforeClose.emit();
|
|
2837
|
+
if (event.defaultPrevented) {
|
|
2838
|
+
this.open = true;
|
|
2839
|
+
return;
|
|
2840
|
+
}
|
|
2841
|
+
// Wait for animation before closing
|
|
2842
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
2843
|
+
if (this.dialogRef) {
|
|
2844
|
+
this.dialogRef.close();
|
|
2845
|
+
}
|
|
2846
|
+
this.isAnimating = false;
|
|
2847
|
+
this.bcmClose.emit();
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
handleClick(event) {
|
|
2851
|
+
// Use composedPath to work with shadow DOM and slots
|
|
2852
|
+
const path = event.composedPath();
|
|
2853
|
+
const dismissElement = path.find(el => { var _a; return (_a = el.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(el, 'data-dismiss'); });
|
|
2854
|
+
const closeModalElement = path.find(el => { var _a; return (_a = el.hasAttribute) === null || _a === void 0 ? void 0 : _a.call(el, 'data-close-modal'); });
|
|
2855
|
+
if (dismissElement) {
|
|
2856
|
+
this.hide();
|
|
2857
|
+
event.preventDefault();
|
|
2858
|
+
event.stopPropagation();
|
|
2859
|
+
}
|
|
2860
|
+
else if (closeModalElement) {
|
|
2861
|
+
const modalId = closeModalElement.getAttribute('data-close-modal');
|
|
2862
|
+
// If modalId matches this modal's id, close it
|
|
2863
|
+
if (!modalId || modalId === this.host.id) {
|
|
2864
|
+
this.hide();
|
|
2865
|
+
event.preventDefault();
|
|
2866
|
+
event.stopPropagation();
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
handleKeyDown(event) {
|
|
2871
|
+
if (event.key === 'Escape' && this.open) {
|
|
2872
|
+
// Only handle ESC if this is the topmost modal
|
|
2873
|
+
const openModals = Array.from(document.querySelectorAll('bcm-modal[open]'));
|
|
2874
|
+
const topModal = openModals[openModals.length - 1];
|
|
2875
|
+
if (topModal !== this.host) {
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
event.preventDefault();
|
|
2879
|
+
if (this.closeOnEscape) {
|
|
2880
|
+
if (this.backdrop === 'static') {
|
|
2881
|
+
this.shakeModal();
|
|
2882
|
+
}
|
|
2883
|
+
else {
|
|
2884
|
+
this.hide();
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
else if (this.backdrop === 'static') {
|
|
2888
|
+
this.shakeModal();
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Programmatically opens the modal
|
|
2894
|
+
*/
|
|
2895
|
+
async show() {
|
|
2896
|
+
this.open = true;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Programmatically closes the modal
|
|
2900
|
+
*/
|
|
2901
|
+
async hide() {
|
|
2902
|
+
this.open = false;
|
|
2903
|
+
}
|
|
2904
|
+
/**
|
|
2905
|
+
* Toggles the modal open/closed state
|
|
2906
|
+
*/
|
|
2907
|
+
async toggle() {
|
|
2908
|
+
this.open = !this.open;
|
|
2909
|
+
}
|
|
2910
|
+
shakeModal() {
|
|
2911
|
+
this.shake = true;
|
|
2912
|
+
setTimeout(() => {
|
|
2913
|
+
this.shake = false;
|
|
2914
|
+
}, 300);
|
|
2915
|
+
}
|
|
2916
|
+
getModalStyle() {
|
|
2917
|
+
if (this.fullScreen) {
|
|
2918
|
+
return {
|
|
2919
|
+
width: '100vw',
|
|
2920
|
+
height: '100vh',
|
|
2921
|
+
maxWidth: 'none',
|
|
2922
|
+
maxHeight: 'none',
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
if (this.fullWidth) {
|
|
2926
|
+
return {
|
|
2927
|
+
width: '100%',
|
|
2928
|
+
maxWidth: '100%',
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
const widths = {
|
|
2932
|
+
small: '400px',
|
|
2933
|
+
medium: '600px',
|
|
2934
|
+
large: '800px',
|
|
2935
|
+
xlarge: '1024px',
|
|
2936
|
+
xxlarge: '1200px',
|
|
2937
|
+
full: '100%',
|
|
2938
|
+
};
|
|
2939
|
+
return {
|
|
2940
|
+
width: widths[this.size],
|
|
2941
|
+
maxWidth: this.fullScreen ? 'none' : '90vw',
|
|
2942
|
+
maxHeight: this.fullScreen ? 'none' : '90vh',
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
componentDidLoad() {
|
|
2946
|
+
if (this.open && this.dialogRef) {
|
|
2947
|
+
this.dialogRef.showModal();
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2950
|
+
disconnectedCallback() {
|
|
2951
|
+
if (this.dialogRef && this.open) {
|
|
2952
|
+
this.dialogRef.close();
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
render() {
|
|
2956
|
+
const { dialog, container, modal, header, headerContent, title, helperText, closeButton, content, footer } = this.modalClass({
|
|
2957
|
+
open: this.open,
|
|
2958
|
+
placement: this.placement,
|
|
2959
|
+
size: this.size,
|
|
2960
|
+
fullScreen: this.fullScreen,
|
|
2961
|
+
shake: this.shake,
|
|
2962
|
+
noHeader: this.noHeader,
|
|
2963
|
+
noFooter: this.noFooter,
|
|
2964
|
+
});
|
|
2965
|
+
return (index.h("dialog", { key: '604224de7fad889eff33705ec549d41927728f7d', ref: el => (this.dialogRef = el), part: "dialog", class: dialog(), onClick: this.handleBackdropClick, onCancel: this.handleDialogCancel, "aria-labelledby": "modal-title", "aria-describedby": this.helperText ? 'modal-helper' : undefined, "aria-modal": "true" }, index.h("div", { key: '7182bea36412891a27153711392e9e70920ac9c4', part: "container", class: container() }, index.h("div", { key: 'a8ad382c7766e1db2fc330aa73479bb3e5002eff', part: "modal", class: modal(), style: this.getModalStyle(), role: "document", onClick: e => e.stopPropagation() }, !this.noHeader && (index.h("div", { key: '8ea66d15bc39c5b06d887529e8af07020bfe4fc4', part: "header", class: header() }, index.h("div", { key: '24ed7baca534c2016a0e6abcaa396643ab91f5c7', part: "header-content", class: headerContent() }, index.h("h2", { key: '4dd835faebd8b96c1a77dfc07731aa76418e2afc', id: "modal-title", part: "title", class: title() }, index.h("slot", { key: 'bf2d40045ccc6040d990d7caccbefa1e0f9e9164', name: "header" }, this.headerText)), this.helperText && (index.h("p", { key: '4dac43e3355fc7d53500dc90fcbfe3191e174c76', id: "modal-helper", part: "helper-text", class: helperText() }, index.h("slot", { key: 'dd37c548df818e4a758bdeede4dc0fd49ca241a3', name: "helper" }, this.helperText)))), index.h("button", { key: '38262ebb76c8d471f4e6070c32e3a4ef4ca01007', part: "close-button", class: closeButton(), onClick: () => this.hide(), "aria-label": "Close modal", type: "button" }, index.h("bcm-icon", { key: '69fca23e4377193ead2931283c6321df9189e3c7', name: "fa-solid fa-xmark" })))), index.h("div", { key: 'e67d5ee554203441246394a2062d4a5662f04b21', part: "content", class: content() }, index.h("slot", { key: '71020c0e5593186befb4ea9841b459986a6dfc2b' })), !this.noFooter && (index.h("div", { key: '12bf38555e3cf905a56543a24742746364c3a41d', part: "footer", class: footer() }, index.h("slot", { key: 'afc38ce22fcb46b85795f8d95eab2f20c6ef3deb', name: "footer" })))))));
|
|
2966
|
+
}
|
|
2967
|
+
get host() { return index.getElement(this); }
|
|
2968
|
+
static get watchers() { return {
|
|
2969
|
+
"open": ["handleOpenChange"]
|
|
2970
|
+
}; }
|
|
2971
|
+
};
|
|
2972
|
+
BcmModal.style = modalCss;
|
|
2973
|
+
|
|
2974
|
+
const popConfirmCss = ".visible{visibility:visible}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.text-wrap{text-wrap:wrap}.border{border-width:1px}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}:host{--popover-bg:var(--bcm-ui-color-background-basic-panel);display:inline-block}[popover]{border:none;overflow:visible;padding:0}[popover]:not(:popover-open){display:none}[popover]:popover-open{opacity:1;transform:scale(1);transition:opacity .15s ease-out,transform .15s ease-out}@starting-style{[popover]:popover-open{opacity:0;transform:scale(.95)}}::slotted([slot=body]){text-wrap:pretty;font-family:Inter,sans-serif}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}@media (min-width:1536px){.container{max-width:1536px}}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-3{top:.75rem}.top-4{top:1rem}.top-6{top:1.5rem}.z-\\[9999\\]{z-index:9999}.m-0{margin:0}.inline-block{display:inline-block}.flex{display:flex}.size-6{height:1.5rem;width:1.5rem}.h-3{height:.75rem}.w-3{width:.75rem}.max-w-64{max-width:16rem}.max-w-80{max-width:20rem}.max-w-96{max-width:24rem}.flex-1{flex:1 1 0%}.rotate-45{--tw-rotate:45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.gap-2{gap:.5rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-8{gap:2rem}.text-pretty{text-wrap:pretty}.rounded-full{border-radius:var(--bcm-ui-border-radius-full,9999px)}.rounded-lg{border-radius:var(--bcm-ui-border-radius-lg,8px)}.bg-\\[--popover-bg\\]{background-color:var(--popover-bg)}.p-4{padding:1rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.pr-8{padding-right:2rem}.font-sans{font-family:Inter,sans-serif}.text-size-4{font-size:var(--bcm-ui-font-size-4,14px);line-height:var(--bcm-ui-line-height-4,20px)}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.text-size-6{font-size:var(--bcm-ui-font-size-6,18px);line-height:var(--bcm-ui-line-height-6,24px)}.text-size-7{font-size:var(--bcm-ui-font-size-7,20px);line-height:var(--bcm-ui-line-height-7,28px)}.font-semibold{font-weight:600}.\\!text-color-header{color:var(--bcm-ui-color-text-header)!important}.text-\\[var\\(--bcm-ui-color-text-error\\)\\]{color:var(--bcm-ui-color-text-error)}.text-\\[var\\(--bcm-ui-color-text-info\\)\\]{color:var(--bcm-ui-color-text-info)}.text-\\[var\\(--bcm-ui-color-text-success\\)\\]{color:var(--bcm-ui-color-text-success)}.text-\\[var\\(--bcm-ui-color-text-warning\\)\\]{color:var(--bcm-ui-color-text-warning)}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}.outline{outline-style:solid}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.hover\\:bg-gray-100:hover{background-color:oklch(.967 .003 264.542)}";
|
|
2975
|
+
|
|
2976
|
+
const statusIcons = {
|
|
2977
|
+
info: 'fa-solid fa-circle-info',
|
|
2978
|
+
success: 'fa-solid fa-circle-check',
|
|
2979
|
+
warning: 'fa-solid fa-triangle-exclamation',
|
|
2980
|
+
error: 'fa-solid fa-circle-xmark',
|
|
2981
|
+
};
|
|
2982
|
+
const BcmPopConfirm = class {
|
|
2983
|
+
constructor(hostRef) {
|
|
2984
|
+
index.registerInstance(this, hostRef);
|
|
2985
|
+
this.bcmBeforeOpen = index.createEvent(this, "bcmBeforeOpen", 1);
|
|
2986
|
+
this.bcmOpen = index.createEvent(this, "bcmOpen", 1);
|
|
2987
|
+
this.bcmBeforeClose = index.createEvent(this, "bcmBeforeClose", 1);
|
|
2988
|
+
this.bcmClose = index.createEvent(this, "bcmClose", 1);
|
|
2989
|
+
this.bcmConfirm = index.createEvent(this, "bcmConfirm", 1);
|
|
2990
|
+
this.bcmCancel = index.createEvent(this, "bcmCancel", 1);
|
|
2991
|
+
/**
|
|
2992
|
+
* @prop {PopConfirmPlacement} placement - Position of the popover relative to the trigger element.
|
|
2993
|
+
* Automatically flips if there's not enough space.
|
|
2994
|
+
* Default: 'top'
|
|
2995
|
+
*/
|
|
2996
|
+
this.placement = 'top';
|
|
2997
|
+
/**
|
|
2998
|
+
* @prop {PopConfirmSize} size - Size variant that controls padding and text size.
|
|
2999
|
+
* - 'small': Compact size with minimal padding
|
|
3000
|
+
* - 'medium': Standard size
|
|
3001
|
+
* - 'large': Spacious size with more padding
|
|
3002
|
+
* Default: 'medium'
|
|
3003
|
+
*/
|
|
3004
|
+
this.size = 'medium';
|
|
3005
|
+
/**
|
|
3006
|
+
* @prop {PopConfirmStatus} status - Status type that determines the color scheme and icon.
|
|
3007
|
+
* - 'info': Informational (blue)
|
|
3008
|
+
* - 'success': Success/positive action (green)
|
|
3009
|
+
* - 'warning': Warning/caution (yellow)
|
|
3010
|
+
* - 'error': Error/destructive action (red)
|
|
3011
|
+
* Default: 'info'
|
|
3012
|
+
*/
|
|
3013
|
+
this.status = 'info';
|
|
3014
|
+
/**
|
|
3015
|
+
* @prop {string} headerText - Text displayed in the header section.
|
|
3016
|
+
* Can be overridden by using the 'header' slot.
|
|
3017
|
+
* Default: ''
|
|
3018
|
+
*/
|
|
3019
|
+
this.headerText = '';
|
|
3020
|
+
/**
|
|
3021
|
+
* @prop {string} description - Description text displayed in the body section.
|
|
3022
|
+
* Can be overridden by using the 'body' slot.
|
|
3023
|
+
* Default: ''
|
|
3024
|
+
*/
|
|
3025
|
+
this.description = '';
|
|
3026
|
+
/**
|
|
3027
|
+
* @prop {string} confirmText - Text for the confirm button.
|
|
3028
|
+
* Default: 'Yes'
|
|
3029
|
+
*/
|
|
3030
|
+
this.confirmText = 'Yes';
|
|
3031
|
+
/**
|
|
3032
|
+
* @prop {string} cancelText - Text for the cancel button.
|
|
3033
|
+
* Default: 'Cancel'
|
|
3034
|
+
*/
|
|
3035
|
+
this.cancelText = 'Cancel';
|
|
3036
|
+
/**
|
|
3037
|
+
* @prop {boolean} showArrow - Whether to show the arrow pointing to the trigger.
|
|
3038
|
+
* Default: true
|
|
3039
|
+
*/
|
|
3040
|
+
this.showArrow = true;
|
|
3041
|
+
/**
|
|
3042
|
+
* @prop {boolean} statusIcon - Whether to show the status icon in the header.
|
|
3043
|
+
* Icon only shows if headerText is also provided.
|
|
3044
|
+
* Default: true
|
|
3045
|
+
*/
|
|
3046
|
+
this.statusIcon = true;
|
|
3047
|
+
/**
|
|
3048
|
+
* @prop {number} offsetDistance - Distance in pixels between the popover and trigger element.
|
|
3049
|
+
* Default: 12
|
|
3050
|
+
*/
|
|
3051
|
+
this.offsetDistance = 12;
|
|
3052
|
+
/**
|
|
3053
|
+
* @prop {boolean} closeOnOutsideClick - Whether to close when clicking outside the popover.
|
|
3054
|
+
* Default: true
|
|
3055
|
+
*/
|
|
3056
|
+
this.closeOnOutsideClick = true;
|
|
3057
|
+
/**
|
|
3058
|
+
* @prop {boolean} closeOnEscape - Whether to close when pressing the Escape key.
|
|
3059
|
+
* Default: true
|
|
3060
|
+
*/
|
|
3061
|
+
this.closeOnEscape = true;
|
|
3062
|
+
this.isOpen = false;
|
|
3063
|
+
this.handleSlotChange = () => {
|
|
3064
|
+
var _a;
|
|
3065
|
+
const slot = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
3066
|
+
if (!slot)
|
|
3067
|
+
return;
|
|
3068
|
+
const elements = slot.assignedElements();
|
|
3069
|
+
const assignedElement = elements[0];
|
|
3070
|
+
this.triggerRef = (assignedElement || this.host);
|
|
3071
|
+
if (!this.triggerRef)
|
|
3072
|
+
return;
|
|
3073
|
+
if (this.popconfirmRef && this.popconfirmId) {
|
|
3074
|
+
this.triggerRef.setAttribute('aria-describedby', this.popconfirmId);
|
|
3075
|
+
}
|
|
3076
|
+
this.removeTriggerListeners();
|
|
3077
|
+
this.setupTriggerListeners();
|
|
3078
|
+
};
|
|
3079
|
+
this.handleTriggerClick = () => {
|
|
3080
|
+
this.toggle();
|
|
3081
|
+
};
|
|
3082
|
+
this.handleOutsideClick = (e) => {
|
|
3083
|
+
var _a;
|
|
3084
|
+
if (!this.closeOnOutsideClick || !this.isOpen)
|
|
3085
|
+
return;
|
|
3086
|
+
const target = e.target;
|
|
3087
|
+
if (!this.host.contains(target) && !((_a = this.popconfirmRef) === null || _a === void 0 ? void 0 : _a.contains(target))) {
|
|
3088
|
+
this.handleCancel();
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
3091
|
+
this.handleToggle = (e) => {
|
|
3092
|
+
const toggleEvent = e;
|
|
3093
|
+
if (toggleEvent.newState === 'open' && !this.isOpen) {
|
|
3094
|
+
this.isOpen = true;
|
|
3095
|
+
}
|
|
3096
|
+
else if (toggleEvent.newState === 'closed' && this.isOpen) {
|
|
3097
|
+
this.isOpen = false;
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
3100
|
+
this.handleConfirm = () => {
|
|
3101
|
+
this.bcmConfirm.emit();
|
|
3102
|
+
this.hide();
|
|
3103
|
+
};
|
|
3104
|
+
this.handleCancel = () => {
|
|
3105
|
+
this.bcmCancel.emit();
|
|
3106
|
+
this.hide();
|
|
3107
|
+
};
|
|
3108
|
+
this.popconfirmClass = tv.tv({
|
|
3109
|
+
slots: {
|
|
3110
|
+
container: 'bcm-ui-element fixed m-0 flex flex-col bg-[--popover-bg] rounded-lg shadow-3 z-[9999]',
|
|
3111
|
+
arrow: 'absolute w-3 h-3 bg-[--popover-bg] rotate-45',
|
|
3112
|
+
closeBtn: 'absolute flex size-6 items-center justify-center hover:bg-gray-100 rounded-full cursor-pointer text-color-muted',
|
|
3113
|
+
header: 'flex items-center pr-8',
|
|
3114
|
+
headerLeft: 'flex items-center gap-2',
|
|
3115
|
+
title: '!text-color-header font-semibold',
|
|
3116
|
+
body: 'flex-1 font-sans text-pretty',
|
|
3117
|
+
footer: 'flex flex-row justify-end gap-2',
|
|
3118
|
+
},
|
|
3119
|
+
variants: {
|
|
3120
|
+
size: {
|
|
3121
|
+
small: {
|
|
3122
|
+
container: 'text-size-4 max-w-64 p-4 gap-4',
|
|
3123
|
+
title: 'text-size-5',
|
|
3124
|
+
closeBtn: 'top-3 right-3',
|
|
3125
|
+
},
|
|
3126
|
+
medium: {
|
|
3127
|
+
container: 'text-size-5 max-w-80 p-6 gap-6',
|
|
3128
|
+
title: 'text-size-6',
|
|
3129
|
+
closeBtn: 'top-4 right-4',
|
|
3130
|
+
},
|
|
3131
|
+
large: {
|
|
3132
|
+
container: 'text-size-6 max-w-96 p-8 gap-8',
|
|
3133
|
+
title: 'text-size-7',
|
|
3134
|
+
closeBtn: 'top-6 right-6',
|
|
3135
|
+
},
|
|
3136
|
+
},
|
|
3137
|
+
status: {
|
|
3138
|
+
info: { headerLeft: 'text-[var(--bcm-ui-color-text-info)]' },
|
|
3139
|
+
success: { headerLeft: 'text-[var(--bcm-ui-color-text-success)]' },
|
|
3140
|
+
warning: { headerLeft: 'text-[var(--bcm-ui-color-text-warning)]' },
|
|
3141
|
+
error: { headerLeft: 'text-[var(--bcm-ui-color-text-error)]' },
|
|
3142
|
+
},
|
|
3143
|
+
},
|
|
3144
|
+
});
|
|
3145
|
+
}
|
|
3146
|
+
async handleOpenChange(open) {
|
|
3147
|
+
if (!this.popconfirmRef)
|
|
3148
|
+
return;
|
|
3149
|
+
if (open) {
|
|
3150
|
+
this.popconfirmRef.showPopover();
|
|
3151
|
+
await new Promise(resolve => requestAnimationFrame(() => resolve(undefined)));
|
|
3152
|
+
await this.updatePosition();
|
|
3153
|
+
this.startAutoUpdate();
|
|
3154
|
+
this.bcmOpen.emit();
|
|
3155
|
+
// Add outside click listener after a frame to avoid immediate close
|
|
3156
|
+
if (this.closeOnOutsideClick) {
|
|
3157
|
+
requestAnimationFrame(() => {
|
|
3158
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
else {
|
|
3163
|
+
this.popconfirmRef.hidePopover();
|
|
3164
|
+
this.stopAutoUpdate();
|
|
3165
|
+
this.bcmClose.emit();
|
|
3166
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
/**
|
|
3170
|
+
* Programmatically shows the popconfirm.
|
|
3171
|
+
* @returns Promise that resolves when the show operation begins
|
|
3172
|
+
*/
|
|
3173
|
+
async show() {
|
|
3174
|
+
if (this.isOpen)
|
|
3175
|
+
return;
|
|
3176
|
+
this.bcmBeforeOpen.emit();
|
|
3177
|
+
this.isOpen = true;
|
|
3178
|
+
}
|
|
3179
|
+
/**
|
|
3180
|
+
* Programmatically hides the popconfirm.
|
|
3181
|
+
* @returns Promise that resolves when the hide operation begins
|
|
3182
|
+
*/
|
|
3183
|
+
async hide() {
|
|
3184
|
+
if (!this.isOpen)
|
|
3185
|
+
return;
|
|
3186
|
+
this.bcmBeforeClose.emit();
|
|
3187
|
+
this.isOpen = false;
|
|
3188
|
+
}
|
|
3189
|
+
/**
|
|
3190
|
+
* Toggles the popconfirm visibility.
|
|
3191
|
+
* If open, it will close. If closed, it will open.
|
|
3192
|
+
* @returns Promise that resolves when the toggle operation completes
|
|
3193
|
+
*/
|
|
3194
|
+
async toggle() {
|
|
3195
|
+
if (this.isOpen) {
|
|
3196
|
+
await this.hide();
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
await this.show();
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
startAutoUpdate() {
|
|
3203
|
+
if (!this.triggerRef || !this.popconfirmRef)
|
|
3204
|
+
return;
|
|
3205
|
+
this.cleanupAutoUpdate = autoUpdate(this.triggerRef, this.popconfirmRef, () => this.updatePosition(), {
|
|
3206
|
+
ancestorScroll: true,
|
|
3207
|
+
ancestorResize: true,
|
|
3208
|
+
elementResize: true,
|
|
3209
|
+
layoutShift: true,
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
stopAutoUpdate() {
|
|
3213
|
+
if (this.cleanupAutoUpdate) {
|
|
3214
|
+
this.cleanupAutoUpdate();
|
|
3215
|
+
this.cleanupAutoUpdate = undefined;
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
async updatePosition() {
|
|
3219
|
+
if (!this.triggerRef || !this.popconfirmRef)
|
|
3220
|
+
return;
|
|
3221
|
+
const middleware = [offset(this.offsetDistance), flip(), shift({ padding: 8 })];
|
|
3222
|
+
if (this.showArrow && this.arrowRef) {
|
|
3223
|
+
middleware.push(arrow({ element: this.arrowRef }));
|
|
3224
|
+
}
|
|
3225
|
+
const virtualElement = {
|
|
3226
|
+
getBoundingClientRect: () => this.triggerRef.getBoundingClientRect(),
|
|
3227
|
+
};
|
|
3228
|
+
const { x, y, placement, middlewareData } = await computePosition(virtualElement, this.popconfirmRef, {
|
|
3229
|
+
placement: this.placement,
|
|
3230
|
+
strategy: 'fixed',
|
|
3231
|
+
middleware,
|
|
3232
|
+
});
|
|
3233
|
+
this.popconfirmRef.style.left = `${x}px`;
|
|
3234
|
+
this.popconfirmRef.style.top = `${y}px`;
|
|
3235
|
+
if (this.showArrow && this.arrowRef && middlewareData.arrow) {
|
|
3236
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
3237
|
+
const side = placement.split('-')[0];
|
|
3238
|
+
const staticSide = {
|
|
3239
|
+
top: 'bottom',
|
|
3240
|
+
right: 'left',
|
|
3241
|
+
bottom: 'top',
|
|
3242
|
+
left: 'right',
|
|
3243
|
+
}[side];
|
|
3244
|
+
Object.assign(this.arrowRef.style, {
|
|
3245
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
3246
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
3247
|
+
right: '',
|
|
3248
|
+
bottom: '',
|
|
3249
|
+
[staticSide]: '-4px',
|
|
3250
|
+
});
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
setupTriggerListeners() {
|
|
3254
|
+
if (!this.triggerRef)
|
|
3255
|
+
return;
|
|
3256
|
+
this.triggerRef.addEventListener('click', this.handleTriggerClick);
|
|
3257
|
+
}
|
|
3258
|
+
removeTriggerListeners() {
|
|
3259
|
+
if (!this.triggerRef)
|
|
3260
|
+
return;
|
|
3261
|
+
this.triggerRef.removeEventListener('click', this.handleTriggerClick);
|
|
3262
|
+
}
|
|
3263
|
+
handleKeyDown(e) {
|
|
3264
|
+
if (!this.closeOnEscape || !this.isOpen)
|
|
3265
|
+
return;
|
|
3266
|
+
if (e.key === 'Escape') {
|
|
3267
|
+
// Check if this is the topmost open popconfirm
|
|
3268
|
+
const openPopconfirms = Array.from(document.querySelectorAll('bcm-pop-confirm')).filter(el => {
|
|
3269
|
+
var _a;
|
|
3270
|
+
const popconfirmEl = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[popover]');
|
|
3271
|
+
return popconfirmEl === null || popconfirmEl === void 0 ? void 0 : popconfirmEl.matches(':popover-open');
|
|
3272
|
+
});
|
|
3273
|
+
const topPopconfirm = openPopconfirms[openPopconfirms.length - 1];
|
|
3274
|
+
if (topPopconfirm === this.host) {
|
|
3275
|
+
e.preventDefault();
|
|
3276
|
+
e.stopPropagation();
|
|
3277
|
+
this.handleCancel();
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
componentWillLoad() {
|
|
3282
|
+
this.popconfirmId = `popconfirm-${Math.random().toString(36).substring(2, 11)}`;
|
|
3283
|
+
}
|
|
3284
|
+
componentDidLoad() {
|
|
3285
|
+
if (this.popconfirmRef) {
|
|
3286
|
+
this.popconfirmRef.addEventListener('toggle', this.handleToggle);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
disconnectedCallback() {
|
|
3290
|
+
this.stopAutoUpdate();
|
|
3291
|
+
this.removeTriggerListeners();
|
|
3292
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
3293
|
+
if (this.popconfirmRef) {
|
|
3294
|
+
this.popconfirmRef.removeEventListener('toggle', this.handleToggle);
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
render() {
|
|
3298
|
+
const { container, arrow: arrowClass, header, headerLeft, title, closeBtn, body, footer } = this.popconfirmClass({
|
|
3299
|
+
size: this.size,
|
|
3300
|
+
status: this.status,
|
|
3301
|
+
});
|
|
3302
|
+
// Only show header if there's actual header content (headerText or custom header slot)
|
|
3303
|
+
// Status icon only shows if explicitly enabled AND there's header text
|
|
3304
|
+
const showStatusIcon = this.statusIcon && this.headerText;
|
|
3305
|
+
const hasHeaderText = Boolean(this.headerText);
|
|
3306
|
+
return (index.h("div", { key: '7329eb6db100b57368ca73b36a2a2ad66b218b8e', class: "inline-block" }, index.h("slot", { key: '0d775cf4a00b4ef97e8e75e2620ddf420caf43c6', onSlotchange: this.handleSlotChange }), index.h("div", { key: '19c4c001fbf51b895a45b271365b3a7cb22590bb', ref: el => (this.popconfirmRef = el), id: this.popconfirmId, part: "container", class: container(), popover: "manual", role: "alertdialog", "aria-labelledby": hasHeaderText ? `${this.popconfirmId}-header` : undefined, "aria-describedby": `${this.popconfirmId}-body` }, this.showArrow && index.h("div", { key: '91aaa976265c10537cea1d0d57d08df27c838645', ref: el => (this.arrowRef = el), part: "arrow", class: arrowClass() }), index.h("div", { key: '91a049dd52d47d267d11c8e8c628aa417fb40663', class: closeBtn(), onClick: this.handleCancel, role: "button", tabIndex: 0, "aria-label": "Close" }, index.h("bcm-icon", { key: 'd15fb5922185f246c15e9480c3a4652ef9e96ffa', "icon-name": "far fa-times" })), index.h("header", { key: 'b62f81fd72a05aa116ecad7614f20645aa85f060', class: header() }, index.h("div", { key: '226cbb6ac92d294b67eb0c33ed0faea52d56689a', class: headerLeft() }, showStatusIcon && index.h("bcm-icon", { key: '0e5cd64e8369876b9016af3c9607cdb406828651', "icon-name": statusIcons[this.status] }), hasHeaderText && (index.h("span", { key: '4a1cf44acf56bc46ad52fda1d1d29da0c838fded', id: `${this.popconfirmId}-header`, class: title() }, this.headerText)), index.h("slot", { key: '5e159545f0b12d97c9b632653955f636866c2a14', name: "header" }))), index.h("main", { key: '6e082c73048583a1447dc4fb7c9940a677e7d587', id: `${this.popconfirmId}-body`, part: "body", class: body() }, index.h("slot", { key: '6d0546a06ca77118d82074fffb9164c4b4f86a5c', name: "body" }, this.description)), index.h("footer", { key: '4f36400e44847e31d6ceed5fd7f47d35f68af458', part: "footer", class: footer() }, index.h("slot", { key: '97b85bb7dd3d39790b91e6bffef01f7eb077c2c3', name: "footer" }, index.h("bcm-button", { key: '8e8b7175a1dd9e069e9cbca7b430fdc1e9a7beab', kind: "outline", size: this.size, onClick: this.handleCancel }, this.cancelText), index.h("bcm-button", { key: 'ae9daeacaf77c8abfe92951eefe2e885d23eab79', size: this.size, status: this.status, kind: "primary", onClick: this.handleConfirm }, this.confirmText))))));
|
|
3307
|
+
}
|
|
3308
|
+
get host() { return index.getElement(this); }
|
|
3309
|
+
static get watchers() { return {
|
|
3310
|
+
"isOpen": ["handleOpenChange"]
|
|
3311
|
+
}; }
|
|
3312
|
+
};
|
|
3313
|
+
BcmPopConfirm.style = popConfirmCss;
|
|
3314
|
+
|
|
3315
|
+
const popoverCss = ".visible{visibility:visible}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.border{border-width:1px}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}:host{--popover-bg:var(--bcm-ui-color-background-base-default);display:inline-block}[popover]{border:none;overflow:visible;padding:0}[popover]:not(:popover-open){display:none}[popover]:popover-open{opacity:1;transform:scale(1);transition:opacity .15s ease-out,transform .15s ease-out}@starting-style{[popover]:popover-open{opacity:0;transform:scale(.95)}}[data-placement^=top] [part=arrow]{border-left:none;border-top:none}[data-placement^=bottom] [part=arrow]{border-bottom:none;border-right:none}[data-placement^=left] [part=arrow]{border-bottom:none;border-left:none}[data-placement^=right] [part=arrow]{border-right:none;border-top:none}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.m-0{margin:0}.inline-block{display:inline-block}.flex{display:flex}.h-3{height:.75rem}.w-3{width:.75rem}.min-w-max{min-width:max-content}.rotate-45{--tw-rotate:45deg}.rotate-45,.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.flex-col{flex-direction:column}.gap-1\\.5{gap:.375rem}.rounded-md{border-radius:var(--bcm-ui-border-radius-md,6px)}.bg-\\[--popover-bg\\]{background-color:var(--popover-bg)}.p-3{padding:.75rem}.text-size-3{font-size:var(--bcm-ui-font-size-3,12px);line-height:var(--bcm-ui-line-height-3,16px)}.text-size-4{font-size:var(--bcm-ui-font-size-4,14px);line-height:var(--bcm-ui-line-height-4,20px)}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.font-normal{font-weight:400}.font-semibold{font-weight:600}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}";
|
|
3316
|
+
|
|
3317
|
+
const Popover = class {
|
|
3318
|
+
constructor(hostRef) {
|
|
3319
|
+
index.registerInstance(this, hostRef);
|
|
3320
|
+
this.bcmBeforeOpen = index.createEvent(this, "bcmBeforeOpen", 1);
|
|
3321
|
+
this.bcmOpen = index.createEvent(this, "bcmOpen", 1);
|
|
3322
|
+
this.bcmBeforeClose = index.createEvent(this, "bcmBeforeClose", 1);
|
|
3323
|
+
this.bcmClose = index.createEvent(this, "bcmClose", 1);
|
|
3324
|
+
// Unique ID for ARIA
|
|
3325
|
+
this.popoverId = `popover-${Math.random().toString(36).substring(2, 11)}`;
|
|
3326
|
+
/**
|
|
3327
|
+
* @prop {('small' | 'medium' | 'large')} size - Defines the size of the popover.
|
|
3328
|
+
* Controls the text size and padding of the popover content.
|
|
3329
|
+
* Default: 'medium'
|
|
3330
|
+
*/
|
|
3331
|
+
this.size = 'medium';
|
|
3332
|
+
/**
|
|
3333
|
+
* @prop {('top' | 'right' | 'bottom' | 'left')} placement - Defines the position of the popover relative to the target element.
|
|
3334
|
+
* Determines where the popover appears around the trigger element.
|
|
3335
|
+
* Default: 'top'
|
|
3336
|
+
*/
|
|
3337
|
+
this.placement = 'top';
|
|
3338
|
+
/**
|
|
3339
|
+
* @prop {('click' | 'hover' | 'hover focus')} trigger - Defines the interaction type to show/hide the popover.
|
|
3340
|
+
* 'click' toggles on click, 'hover' shows on mouse enter and hides on mouse leave, 'hover focus' combines both.
|
|
3341
|
+
* Default: 'click'
|
|
3342
|
+
*/
|
|
3343
|
+
this.trigger = 'click';
|
|
3344
|
+
/**
|
|
3345
|
+
* @prop {number} showDelay - Delay in milliseconds before showing the popover.
|
|
3346
|
+
* Useful to prevent popovers from appearing on quick mouse movements.
|
|
3347
|
+
* Default: 0
|
|
3348
|
+
*/
|
|
3349
|
+
this.showDelay = 0;
|
|
3350
|
+
/**
|
|
3351
|
+
* @prop {number} hideDelay - Delay in milliseconds before hiding the popover.
|
|
3352
|
+
* Provides a grace period for mouse movements.
|
|
3353
|
+
* Default: 0
|
|
3354
|
+
*/
|
|
3355
|
+
this.hideDelay = 0;
|
|
3356
|
+
/**
|
|
3357
|
+
* @prop {boolean} open - Controls the open state of the popover.
|
|
3358
|
+
* Can be set programmatically or toggled by user interaction.
|
|
3359
|
+
* Default: false
|
|
3360
|
+
*/
|
|
3361
|
+
this.open = false;
|
|
3362
|
+
/**
|
|
3363
|
+
* @prop {boolean} closeOnOutsideClick - Whether to close the popover when clicking outside.
|
|
3364
|
+
* Default: true
|
|
3365
|
+
*/
|
|
3366
|
+
this.closeOnOutsideClick = true;
|
|
3367
|
+
/**
|
|
3368
|
+
* @prop {boolean} closeOnEscape - Whether to close the popover when pressing Escape key.
|
|
3369
|
+
* Default: true
|
|
3370
|
+
*/
|
|
3371
|
+
this.closeOnEscape = true;
|
|
3372
|
+
/**
|
|
3373
|
+
* @prop {boolean} arrow - Whether to show an arrow pointing to the trigger element.
|
|
3374
|
+
* Default: true
|
|
3375
|
+
*/
|
|
3376
|
+
this.arrow = true;
|
|
3377
|
+
// Internal state
|
|
3378
|
+
this.isOpen = false;
|
|
3379
|
+
this.handleSlotChange = () => {
|
|
3380
|
+
var _a;
|
|
3381
|
+
const slot = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
3382
|
+
if (!slot)
|
|
3383
|
+
return;
|
|
3384
|
+
const elements = slot.assignedElements();
|
|
3385
|
+
if (elements.length > 0) {
|
|
3386
|
+
// Remove old listeners
|
|
3387
|
+
this.removeTriggerListeners();
|
|
3388
|
+
this.triggerRef = elements[0];
|
|
3389
|
+
this.setupTriggerListeners();
|
|
3390
|
+
this.setupAriaAttributes();
|
|
3391
|
+
}
|
|
3392
|
+
};
|
|
3393
|
+
this.handleMouseEnter = () => {
|
|
3394
|
+
this.show();
|
|
3395
|
+
};
|
|
3396
|
+
this.handleMouseLeave = () => {
|
|
3397
|
+
this.hide();
|
|
3398
|
+
};
|
|
3399
|
+
this.handlePopoverMouseEnter = () => {
|
|
3400
|
+
this.clearTimeouts();
|
|
3401
|
+
};
|
|
3402
|
+
this.handlePopoverMouseLeave = () => {
|
|
3403
|
+
this.hide();
|
|
3404
|
+
};
|
|
3405
|
+
this.handleTriggerClick = (event) => {
|
|
3406
|
+
event.stopPropagation();
|
|
3407
|
+
this.toggle();
|
|
3408
|
+
};
|
|
3409
|
+
this.handleFocus = () => {
|
|
3410
|
+
this.show();
|
|
3411
|
+
};
|
|
3412
|
+
this.handleBlur = () => {
|
|
3413
|
+
this.hide();
|
|
3414
|
+
};
|
|
3415
|
+
this.handleOutsideClick = (event) => {
|
|
3416
|
+
var _a;
|
|
3417
|
+
if (!this.closeOnOutsideClick || !this.open)
|
|
3418
|
+
return;
|
|
3419
|
+
const target = event.target;
|
|
3420
|
+
const path = event.composedPath();
|
|
3421
|
+
const isInsideHost = this.host.contains(target) || path.includes(this.host);
|
|
3422
|
+
const isInsidePopover = ((_a = this.popoverRef) === null || _a === void 0 ? void 0 : _a.contains(target)) || (this.popoverRef && path.includes(this.popoverRef));
|
|
3423
|
+
if (!isInsideHost && !isInsidePopover) {
|
|
3424
|
+
this.hide();
|
|
3425
|
+
}
|
|
3426
|
+
};
|
|
3427
|
+
this.handleToggle = (event) => {
|
|
3428
|
+
// Sync internal state with native popover state
|
|
3429
|
+
if (event.newState === 'open' && !this.isOpen) {
|
|
3430
|
+
this.isOpen = true;
|
|
3431
|
+
}
|
|
3432
|
+
else if (event.newState === 'closed' && this.isOpen) {
|
|
3433
|
+
this.isOpen = false;
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3436
|
+
this.updatePosition = async () => {
|
|
3437
|
+
if (!this.triggerRef || !this.popoverRef)
|
|
3438
|
+
return;
|
|
3439
|
+
// Check if trigger element is still in viewport
|
|
3440
|
+
const triggerRect = this.triggerRef.getBoundingClientRect();
|
|
3441
|
+
const isInViewport = triggerRect.bottom > 0 && triggerRect.top < window.innerHeight && triggerRect.right > 0 && triggerRect.left < window.innerWidth;
|
|
3442
|
+
// Hide popover if trigger is out of viewport
|
|
3443
|
+
if (!isInViewport && this.open) {
|
|
3444
|
+
this.hide();
|
|
3445
|
+
return;
|
|
3446
|
+
}
|
|
3447
|
+
// Virtual element for shadow DOM boundary
|
|
3448
|
+
const virtualElement = {
|
|
3449
|
+
getBoundingClientRect: () => this.triggerRef.getBoundingClientRect(),
|
|
3450
|
+
};
|
|
3451
|
+
const middleware = [offset(12), flip({ fallbackPlacements: ['top', 'left', 'bottom', 'right'] }), shift({ padding: 8 })];
|
|
3452
|
+
if (this.arrow && this.arrowRef) {
|
|
3453
|
+
middleware.push(arrow({ element: this.arrowRef }));
|
|
3454
|
+
}
|
|
3455
|
+
const { x, y, placement, middlewareData } = await computePosition(virtualElement, this.popoverRef, {
|
|
3456
|
+
placement: this.placement,
|
|
3457
|
+
strategy: 'fixed',
|
|
3458
|
+
middleware,
|
|
3459
|
+
});
|
|
3460
|
+
Object.assign(this.popoverRef.style, {
|
|
3461
|
+
left: `${x}px`,
|
|
3462
|
+
top: `${y}px`,
|
|
3463
|
+
});
|
|
3464
|
+
// Update placement attribute for CSS
|
|
3465
|
+
this.popoverRef.setAttribute('data-placement', placement);
|
|
3466
|
+
// Arrow positioning
|
|
3467
|
+
if (this.arrow && this.arrowRef && middlewareData.arrow) {
|
|
3468
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
3469
|
+
const basePlacement = placement.split('-')[0];
|
|
3470
|
+
const staticSide = {
|
|
3471
|
+
top: 'bottom',
|
|
3472
|
+
right: 'left',
|
|
3473
|
+
bottom: 'top',
|
|
3474
|
+
left: 'right',
|
|
3475
|
+
}[basePlacement];
|
|
3476
|
+
Object.assign(this.arrowRef.style, {
|
|
3477
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
3478
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
3479
|
+
right: '',
|
|
3480
|
+
bottom: '',
|
|
3481
|
+
[staticSide]: '-4px',
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
this.popoverClass = tv.tv({
|
|
3486
|
+
slots: {
|
|
3487
|
+
box: [
|
|
3488
|
+
'bcm-ui-element',
|
|
3489
|
+
'bcm-popover',
|
|
3490
|
+
'fixed',
|
|
3491
|
+
'm-0',
|
|
3492
|
+
'flex',
|
|
3493
|
+
'flex-col',
|
|
3494
|
+
'bg-[--popover-bg]',
|
|
3495
|
+
'rounded-md',
|
|
3496
|
+
'shadow-3',
|
|
3497
|
+
'p-3',
|
|
3498
|
+
'gap-1.5',
|
|
3499
|
+
'min-w-max',
|
|
3500
|
+
],
|
|
3501
|
+
header: 'font-semibold text-color',
|
|
3502
|
+
content: 'font-normal text-color',
|
|
3503
|
+
arrow: 'absolute w-3 h-3 bg-[--popover-bg] transform rotate-45',
|
|
3504
|
+
},
|
|
3505
|
+
variants: {
|
|
3506
|
+
size: {
|
|
3507
|
+
small: { box: 'text-size-3' },
|
|
3508
|
+
medium: { box: 'text-size-4' },
|
|
3509
|
+
large: { box: 'text-size-5' },
|
|
3510
|
+
},
|
|
3511
|
+
},
|
|
3512
|
+
defaultVariants: {
|
|
3513
|
+
size: 'medium',
|
|
3514
|
+
},
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
// Watch for open prop changes
|
|
3518
|
+
handleOpenChange(newValue) {
|
|
3519
|
+
if (newValue) {
|
|
3520
|
+
this.showInternal();
|
|
3521
|
+
}
|
|
3522
|
+
else {
|
|
3523
|
+
this.hideInternal();
|
|
3524
|
+
}
|
|
3525
|
+
}
|
|
3526
|
+
// Internal show logic
|
|
3527
|
+
showInternal() {
|
|
3528
|
+
var _a;
|
|
3529
|
+
if (!this.popoverRef)
|
|
3530
|
+
return;
|
|
3531
|
+
this.isOpen = true;
|
|
3532
|
+
this.popoverRef.showPopover();
|
|
3533
|
+
this.startAutoUpdate();
|
|
3534
|
+
this.updatePosition();
|
|
3535
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
|
|
3536
|
+
this.bcmOpen.emit();
|
|
3537
|
+
if (this.closeOnOutsideClick) {
|
|
3538
|
+
this.addOutsideClickListener();
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
// Internal hide logic
|
|
3542
|
+
hideInternal() {
|
|
3543
|
+
var _a;
|
|
3544
|
+
if (!this.popoverRef)
|
|
3545
|
+
return;
|
|
3546
|
+
this.isOpen = false;
|
|
3547
|
+
this.popoverRef.hidePopover();
|
|
3548
|
+
this.stopAutoUpdate();
|
|
3549
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
|
|
3550
|
+
this.bcmClose.emit();
|
|
3551
|
+
this.removeOutsideClickListener();
|
|
3552
|
+
}
|
|
3553
|
+
/**
|
|
3554
|
+
* Programmatically shows the popover.
|
|
3555
|
+
* Respects the showDelay prop.
|
|
3556
|
+
*/
|
|
3557
|
+
async show() {
|
|
3558
|
+
if (this.open)
|
|
3559
|
+
return;
|
|
3560
|
+
this.clearTimeouts();
|
|
3561
|
+
if (this.showDelay > 0) {
|
|
3562
|
+
this.showTimeout = window.setTimeout(() => {
|
|
3563
|
+
this.bcmBeforeOpen.emit();
|
|
3564
|
+
this.open = true;
|
|
3565
|
+
}, this.showDelay);
|
|
3566
|
+
}
|
|
3567
|
+
else {
|
|
3568
|
+
this.bcmBeforeOpen.emit();
|
|
3569
|
+
this.open = true;
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
/**
|
|
3573
|
+
* Programmatically hides the popover.
|
|
3574
|
+
* Respects the hideDelay prop.
|
|
3575
|
+
*/
|
|
3576
|
+
async hide() {
|
|
3577
|
+
if (!this.open)
|
|
3578
|
+
return;
|
|
3579
|
+
this.clearTimeouts();
|
|
3580
|
+
if (this.hideDelay > 0) {
|
|
3581
|
+
this.hideTimeout = window.setTimeout(() => {
|
|
3582
|
+
this.bcmBeforeClose.emit();
|
|
3583
|
+
this.open = false;
|
|
3584
|
+
}, this.hideDelay);
|
|
3585
|
+
}
|
|
3586
|
+
else {
|
|
3587
|
+
this.bcmBeforeClose.emit();
|
|
3588
|
+
this.open = false;
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
/**
|
|
3592
|
+
* Toggles the popover visibility.
|
|
3593
|
+
*/
|
|
3594
|
+
async toggle() {
|
|
3595
|
+
if (this.open) {
|
|
3596
|
+
await this.hide();
|
|
3597
|
+
}
|
|
3598
|
+
else {
|
|
3599
|
+
await this.show();
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
clearTimeouts() {
|
|
3603
|
+
if (this.showTimeout) {
|
|
3604
|
+
clearTimeout(this.showTimeout);
|
|
3605
|
+
this.showTimeout = undefined;
|
|
3606
|
+
}
|
|
3607
|
+
if (this.hideTimeout) {
|
|
3608
|
+
clearTimeout(this.hideTimeout);
|
|
3609
|
+
this.hideTimeout = undefined;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
startAutoUpdate() {
|
|
3613
|
+
if (!this.triggerRef || !this.popoverRef)
|
|
3614
|
+
return;
|
|
3615
|
+
this.cleanupAutoUpdate = autoUpdate(this.triggerRef, this.popoverRef, () => this.updatePosition(), {
|
|
3616
|
+
ancestorScroll: true,
|
|
3617
|
+
ancestorResize: true,
|
|
3618
|
+
elementResize: true,
|
|
3619
|
+
layoutShift: true,
|
|
3620
|
+
});
|
|
3621
|
+
}
|
|
3622
|
+
stopAutoUpdate() {
|
|
3623
|
+
var _a;
|
|
3624
|
+
(_a = this.cleanupAutoUpdate) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
3625
|
+
this.cleanupAutoUpdate = undefined;
|
|
3626
|
+
}
|
|
3627
|
+
setupTriggerListeners() {
|
|
3628
|
+
var _a, _b;
|
|
3629
|
+
if (!this.triggerRef)
|
|
3630
|
+
return;
|
|
3631
|
+
if (this.trigger === 'hover' || this.trigger === 'hover focus') {
|
|
3632
|
+
this.triggerRef.addEventListener('mouseenter', this.handleMouseEnter);
|
|
3633
|
+
this.triggerRef.addEventListener('mouseleave', this.handleMouseLeave);
|
|
3634
|
+
(_a = this.popoverRef) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.handlePopoverMouseEnter);
|
|
3635
|
+
(_b = this.popoverRef) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.handlePopoverMouseLeave);
|
|
3636
|
+
}
|
|
3637
|
+
if (this.trigger === 'click') {
|
|
3638
|
+
this.triggerRef.addEventListener('click', this.handleTriggerClick);
|
|
3639
|
+
}
|
|
3640
|
+
if (this.trigger === 'hover focus') {
|
|
3641
|
+
this.triggerRef.addEventListener('focus', this.handleFocus);
|
|
3642
|
+
this.triggerRef.addEventListener('blur', this.handleBlur);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
removeTriggerListeners() {
|
|
3646
|
+
var _a, _b;
|
|
3647
|
+
if (!this.triggerRef)
|
|
3648
|
+
return;
|
|
3649
|
+
this.triggerRef.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
3650
|
+
this.triggerRef.removeEventListener('mouseleave', this.handleMouseLeave);
|
|
3651
|
+
this.triggerRef.removeEventListener('click', this.handleTriggerClick);
|
|
3652
|
+
this.triggerRef.removeEventListener('focus', this.handleFocus);
|
|
3653
|
+
this.triggerRef.removeEventListener('blur', this.handleBlur);
|
|
3654
|
+
(_a = this.popoverRef) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.handlePopoverMouseEnter);
|
|
3655
|
+
(_b = this.popoverRef) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.handlePopoverMouseLeave);
|
|
3656
|
+
}
|
|
3657
|
+
setupAriaAttributes() {
|
|
3658
|
+
if (!this.triggerRef)
|
|
3659
|
+
return;
|
|
3660
|
+
this.triggerRef.setAttribute('aria-describedby', this.popoverId);
|
|
3661
|
+
this.triggerRef.setAttribute('aria-expanded', String(this.open));
|
|
3662
|
+
this.triggerRef.setAttribute('aria-haspopup', 'dialog');
|
|
3663
|
+
}
|
|
3664
|
+
handleKeyDown(event) {
|
|
3665
|
+
var _a;
|
|
3666
|
+
if (!this.closeOnEscape || !this.open)
|
|
3667
|
+
return;
|
|
3668
|
+
if (event.key === 'Escape') {
|
|
3669
|
+
// Topmost popover check
|
|
3670
|
+
const openPopovers = Array.from(document.querySelectorAll('bcm-popover[open]'));
|
|
3671
|
+
const topPopover = openPopovers[openPopovers.length - 1];
|
|
3672
|
+
if (topPopover === this.host) {
|
|
3673
|
+
event.preventDefault();
|
|
3674
|
+
this.hide();
|
|
3675
|
+
(_a = this.triggerRef) === null || _a === void 0 ? void 0 : _a.focus();
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
}
|
|
3679
|
+
addOutsideClickListener() {
|
|
3680
|
+
// Add on next tick to avoid catching current click
|
|
3681
|
+
setTimeout(() => {
|
|
3682
|
+
document.addEventListener('click', this.handleOutsideClick, true);
|
|
3683
|
+
}, 0);
|
|
3684
|
+
}
|
|
3685
|
+
removeOutsideClickListener() {
|
|
3686
|
+
document.removeEventListener('click', this.handleOutsideClick, true);
|
|
3687
|
+
}
|
|
3688
|
+
componentDidLoad() {
|
|
3689
|
+
var _a;
|
|
3690
|
+
// Toggle event listener (Popover API)
|
|
3691
|
+
(_a = this.popoverRef) === null || _a === void 0 ? void 0 : _a.addEventListener('toggle', this.handleToggle);
|
|
3692
|
+
// Initial state sync
|
|
3693
|
+
if (this.open) {
|
|
3694
|
+
this.showInternal();
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
disconnectedCallback() {
|
|
3698
|
+
this.clearTimeouts();
|
|
3699
|
+
this.stopAutoUpdate();
|
|
3700
|
+
this.removeTriggerListeners();
|
|
3701
|
+
this.removeOutsideClickListener();
|
|
3702
|
+
if (this.popoverRef) {
|
|
3703
|
+
this.popoverRef.removeEventListener('toggle', this.handleToggle);
|
|
3704
|
+
if (this.isOpen) {
|
|
3705
|
+
try {
|
|
3706
|
+
this.popoverRef.hidePopover();
|
|
3707
|
+
}
|
|
3708
|
+
catch (e) {
|
|
3709
|
+
// Element might already be removed
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
render() {
|
|
3715
|
+
const { box, header, content, arrow: arrowClass } = this.popoverClass({
|
|
3716
|
+
size: this.size,
|
|
3717
|
+
});
|
|
3718
|
+
return (index.h("div", { key: '79e275204246ae56d255cf6eb3cd048631d4e89b', class: "inline-block" }, index.h("slot", { key: '787bce1db3d40d8e95631e4963011432f567ce38', onSlotchange: this.handleSlotChange }), index.h("div", { key: '11aac4ed45dfc6ea5ac73df72c1f95708c02b033', ref: el => (this.popoverRef = el), id: this.popoverId, part: "popover", class: box(),
|
|
3719
|
+
// @ts-ignore - popover is a valid HTML attribute
|
|
3720
|
+
popover: "manual", role: "dialog", "aria-labelledby": this.headerText ? `${this.popoverId}-header` : undefined }, this.arrow && index.h("div", { key: '86eff698c15414eac0b8341d0378deae0ffa9f22', ref: el => (this.arrowRef = el), part: "arrow", class: arrowClass() }), index.h("div", { key: '9ab131a4a26f552c9628dcec39dbfea8244abeb2', id: `${this.popoverId}-header`, part: "header", class: header() }, index.h("slot", { key: 'f9db05dc65149e097d086f7c93ee8962e7e2c32f', name: "header" }, this.headerText)), index.h("div", { key: '9e03b53071f8f3cf22e1347eaa812ecaf6e806a8', part: "content", class: content() }, index.h("slot", { key: '771733f668c6fd1d6f7a2f73b994a4ba906f2b6b', name: "content" }, this.message)))));
|
|
3721
|
+
}
|
|
3722
|
+
get host() { return index.getElement(this); }
|
|
3723
|
+
static get watchers() { return {
|
|
3724
|
+
"open": ["handleOpenChange"]
|
|
3725
|
+
}; }
|
|
3726
|
+
};
|
|
3727
|
+
Popover.style = popoverCss;
|
|
3728
|
+
|
|
3729
|
+
const tooltipCss = ".visible{visibility:visible}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.border{border-width:1px}.transition{transition-duration:.15s;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}:host{display:inline-block}[popover]{border:none;opacity:0;overflow:visible;padding:0;transform:scale(.95);transition:opacity .1s ease-out,transform .1s ease-out}[popover]:popover-open{opacity:1;transform:scale(1)}@starting-style{[popover]:popover-open{opacity:0;transform:scale(.95)}}.bcm-ui-element{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,sans-serif}.pointer-events-none{pointer-events:none}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.z-\\[9999\\]{z-index:9999}.m-0{margin:0}.inline-block{display:inline-block}.hidden{display:none}.h-2{height:.5rem}.w-2{width:.5rem}.rotate-45{--tw-rotate:45deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded-md{border-radius:var(--bcm-ui-border-radius-md,6px)}.bg-color-default-dark{background-color:var(--bcm-ui-color-background-default-dark-default)}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-1{padding-bottom:.25rem;padding-top:.25rem}.py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.py-2{padding-bottom:.5rem;padding-top:.5rem}.text-size-3{font-size:var(--bcm-ui-font-size-3,12px);line-height:var(--bcm-ui-line-height-3,16px)}.text-size-4{font-size:var(--bcm-ui-font-size-4,14px);line-height:var(--bcm-ui-line-height-4,20px)}.text-size-5{font-size:var(--bcm-ui-font-size-5,16px);line-height:var(--bcm-ui-line-height-5,24px)}.font-medium{font-weight:500}.text-color-base{color:var(--bcm-ui-color-text-base)}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}";
|
|
3730
|
+
|
|
3731
|
+
const BcmTooltip = class {
|
|
3732
|
+
constructor(hostRef) {
|
|
3733
|
+
index.registerInstance(this, hostRef);
|
|
3734
|
+
this.mouseX = 0;
|
|
3735
|
+
this.mouseY = 0;
|
|
3736
|
+
/**
|
|
3737
|
+
* How the tooltip is triggered
|
|
3738
|
+
* - 'hover': Shows on mouse enter, hides on mouse leave
|
|
3739
|
+
* - 'click': Toggles on click, closes on outside click or Escape key
|
|
3740
|
+
*/
|
|
3741
|
+
this.trigger = 'hover';
|
|
3742
|
+
/**
|
|
3743
|
+
* Preferred placement of the tooltip relative to the trigger
|
|
3744
|
+
* Note: Tooltip will automatically flip if there's not enough space
|
|
3745
|
+
* - 'top': Above the trigger element
|
|
3746
|
+
* - 'right': To the right of the trigger element
|
|
3747
|
+
* - 'bottom': Below the trigger element
|
|
3748
|
+
* - 'left': To the left of the trigger element
|
|
3749
|
+
*/
|
|
3750
|
+
this.placement = 'top';
|
|
3751
|
+
/**
|
|
3752
|
+
* Size variant of the tooltip
|
|
3753
|
+
* - 'small': Compact tooltip with minimal padding (text-size-3, py-1 px-2)
|
|
3754
|
+
* - 'medium': Standard tooltip size (text-size-4, py-1.5 px-3)
|
|
3755
|
+
* - 'large': Larger tooltip for more content (text-size-5, py-2 px-4)
|
|
3756
|
+
*/
|
|
3757
|
+
this.size = 'medium';
|
|
3758
|
+
/**
|
|
3759
|
+
* Delay in milliseconds before showing the tooltip
|
|
3760
|
+
* Useful to prevent tooltips from appearing on quick mouse movements
|
|
3761
|
+
*/
|
|
3762
|
+
this.showDelay = 150;
|
|
3763
|
+
/**
|
|
3764
|
+
* Delay in milliseconds before hiding the tooltip
|
|
3765
|
+
* Provides a grace period for mouse movements
|
|
3766
|
+
*/
|
|
3767
|
+
this.hideDelay = 100;
|
|
3768
|
+
/**
|
|
3769
|
+
* Whether to show an arrow pointing to the trigger element
|
|
3770
|
+
* Note: Arrow is automatically hidden in 'follow' mode
|
|
3771
|
+
*/
|
|
3772
|
+
this.arrow = true;
|
|
3773
|
+
/**
|
|
3774
|
+
* Disables the tooltip, preventing it from showing
|
|
3775
|
+
* Useful for conditional tooltips based on application state
|
|
3776
|
+
*/
|
|
3777
|
+
this.disabled = false;
|
|
3778
|
+
/**
|
|
3779
|
+
* Distance in pixels between the tooltip and the trigger element
|
|
3780
|
+
* Also used as the offset in 'follow' mode
|
|
3781
|
+
*/
|
|
3782
|
+
this.offset = 12;
|
|
3783
|
+
/**
|
|
3784
|
+
* Makes the tooltip follow the mouse cursor
|
|
3785
|
+
* When enabled:
|
|
3786
|
+
* - Arrow is hidden
|
|
3787
|
+
* - Tooltip position updates smoothly with cursor movement
|
|
3788
|
+
* - Pointer events are disabled on tooltip to prevent interference
|
|
3789
|
+
*/
|
|
3790
|
+
this.follow = false;
|
|
3791
|
+
this.isOpen = false;
|
|
3792
|
+
this.handleSlotChange = () => {
|
|
3793
|
+
var _a;
|
|
3794
|
+
const slot = (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
3795
|
+
if (!slot)
|
|
3796
|
+
return;
|
|
3797
|
+
const elements = slot.assignedElements();
|
|
3798
|
+
const assignedElement = elements[0];
|
|
3799
|
+
// Get the actual element position from the host, not shadow DOM
|
|
3800
|
+
// This ensures proper positioning across shadow boundaries
|
|
3801
|
+
this.triggerRef = (assignedElement || this.host);
|
|
3802
|
+
if (!this.triggerRef)
|
|
3803
|
+
return;
|
|
3804
|
+
// Setup ARIA relationship
|
|
3805
|
+
if (this.tooltipRef && this.tooltipId) {
|
|
3806
|
+
this.triggerRef.setAttribute('aria-describedby', this.tooltipId);
|
|
3807
|
+
}
|
|
3808
|
+
// Remove old listeners
|
|
3809
|
+
this.removeTriggerListeners();
|
|
3810
|
+
// Add new listeners
|
|
3811
|
+
this.setupTriggerListeners();
|
|
3812
|
+
};
|
|
3813
|
+
this.handleMouseEnter = () => {
|
|
3814
|
+
if (!this.disabled) {
|
|
3815
|
+
this.show();
|
|
3816
|
+
}
|
|
3817
|
+
};
|
|
3818
|
+
this.handleMouseLeave = () => {
|
|
3819
|
+
this.hide();
|
|
3820
|
+
};
|
|
3821
|
+
this.handleMouseMove = (e) => {
|
|
3822
|
+
this.mouseX = e.clientX;
|
|
3823
|
+
this.mouseY = e.clientY;
|
|
3824
|
+
};
|
|
3825
|
+
this.handleClick = () => {
|
|
3826
|
+
if (!this.disabled) {
|
|
3827
|
+
this.toggle();
|
|
3828
|
+
}
|
|
3829
|
+
};
|
|
3830
|
+
this.handleOutsideClick = (e) => {
|
|
3831
|
+
var _a;
|
|
3832
|
+
const target = e.target;
|
|
3833
|
+
if (!this.host.contains(target) && !((_a = this.tooltipRef) === null || _a === void 0 ? void 0 : _a.contains(target))) {
|
|
3834
|
+
this.hide();
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3837
|
+
this.handleKeyDown = (e) => {
|
|
3838
|
+
if (e.key === 'Escape' && this.isOpen) {
|
|
3839
|
+
// Only close if this tooltip's popover element is the topmost
|
|
3840
|
+
const topmostPopover = document.querySelector('[popover]:popover-open:last-of-type');
|
|
3841
|
+
if (topmostPopover === this.tooltipRef) {
|
|
3842
|
+
e.stopPropagation(); // Prevent event from reaching parent popovers
|
|
3843
|
+
this.hide();
|
|
3844
|
+
// Return focus to trigger element
|
|
3845
|
+
if (this.triggerRef && 'focus' in this.triggerRef) {
|
|
3846
|
+
this.triggerRef.focus();
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
};
|
|
3851
|
+
this.handleToggle = (e) => {
|
|
3852
|
+
const toggleEvent = e;
|
|
3853
|
+
// Sync our internal state with popover state
|
|
3854
|
+
if (toggleEvent.newState === 'open' && !this.isOpen) {
|
|
3855
|
+
this.isOpen = true;
|
|
3856
|
+
}
|
|
3857
|
+
else if (toggleEvent.newState === 'closed' && this.isOpen) {
|
|
3858
|
+
this.isOpen = false;
|
|
3859
|
+
}
|
|
3860
|
+
};
|
|
3861
|
+
this.tooltipClass = tv.tv({
|
|
3862
|
+
slots: {
|
|
3863
|
+
tooltip: 'bcm-ui-element fixed m-0 bg-color-default-dark text-color-base rounded-md shadow-3 font-medium z-[9999]',
|
|
3864
|
+
arrow: 'absolute w-2 h-2 bg-color-default-dark rotate-45',
|
|
3865
|
+
content: '',
|
|
3866
|
+
},
|
|
3867
|
+
variants: {
|
|
3868
|
+
size: {
|
|
3869
|
+
small: {
|
|
3870
|
+
tooltip: 'text-size-3 py-1 px-2',
|
|
3871
|
+
},
|
|
3872
|
+
medium: {
|
|
3873
|
+
tooltip: 'text-size-4 py-1.5 px-3',
|
|
3874
|
+
},
|
|
3875
|
+
large: {
|
|
3876
|
+
tooltip: 'text-size-5 py-2 px-4',
|
|
3877
|
+
},
|
|
3878
|
+
},
|
|
3879
|
+
follow: {
|
|
3880
|
+
true: {
|
|
3881
|
+
tooltip: 'pointer-events-none',
|
|
3882
|
+
},
|
|
3883
|
+
},
|
|
3884
|
+
},
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3887
|
+
handleDisabledChange(disabled) {
|
|
3888
|
+
if (disabled && this.isOpen) {
|
|
3889
|
+
this.hide();
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
handleTriggerChange() {
|
|
3893
|
+
this.removeTriggerListeners();
|
|
3894
|
+
this.setupOutsideClickListener();
|
|
3895
|
+
if (this.triggerRef) {
|
|
3896
|
+
this.setupTriggerListeners();
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
async handleOpenChange(open) {
|
|
3900
|
+
if (!this.tooltipRef)
|
|
3901
|
+
return;
|
|
3902
|
+
if (open) {
|
|
3903
|
+
this.tooltipRef.showPopover();
|
|
3904
|
+
// Wait for next frame to ensure popover is rendered
|
|
3905
|
+
await new Promise(resolve => requestAnimationFrame(() => resolve(undefined)));
|
|
3906
|
+
if (this.follow) {
|
|
3907
|
+
this.startFollowing();
|
|
3908
|
+
}
|
|
3909
|
+
else {
|
|
3910
|
+
await this.updatePosition();
|
|
3911
|
+
this.startAutoUpdate();
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
else {
|
|
3915
|
+
this.tooltipRef.hidePopover();
|
|
3916
|
+
this.stopFollowing();
|
|
3917
|
+
this.stopAutoUpdate();
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
/**
|
|
3921
|
+
* Programmatically shows the tooltip
|
|
3922
|
+
* Respects the showDelay prop and disabled state
|
|
3923
|
+
*/
|
|
3924
|
+
async show() {
|
|
3925
|
+
if (this.disabled)
|
|
3926
|
+
return;
|
|
3927
|
+
this.clearTimeouts();
|
|
3928
|
+
this.showTimeout = window.setTimeout(() => {
|
|
3929
|
+
this.isOpen = true;
|
|
3930
|
+
}, this.showDelay);
|
|
3931
|
+
}
|
|
3932
|
+
/**
|
|
3933
|
+
* Programmatically hides the tooltip
|
|
3934
|
+
* Respects the hideDelay prop
|
|
3935
|
+
*/
|
|
3936
|
+
async hide() {
|
|
3937
|
+
this.clearTimeouts();
|
|
3938
|
+
this.hideTimeout = window.setTimeout(() => {
|
|
3939
|
+
this.isOpen = false;
|
|
3940
|
+
}, this.hideDelay);
|
|
3941
|
+
}
|
|
3942
|
+
/**
|
|
3943
|
+
* Toggles the tooltip visibility
|
|
3944
|
+
* If open, hides it; if closed, shows it
|
|
3945
|
+
*/
|
|
3946
|
+
async toggle() {
|
|
3947
|
+
if (this.isOpen) {
|
|
3948
|
+
await this.hide();
|
|
3949
|
+
}
|
|
3950
|
+
else {
|
|
3951
|
+
await this.show();
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
clearTimeouts() {
|
|
3955
|
+
if (this.showTimeout) {
|
|
3956
|
+
clearTimeout(this.showTimeout);
|
|
3957
|
+
this.showTimeout = undefined;
|
|
3958
|
+
}
|
|
3959
|
+
if (this.hideTimeout) {
|
|
3960
|
+
clearTimeout(this.hideTimeout);
|
|
3961
|
+
this.hideTimeout = undefined;
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
startAutoUpdate() {
|
|
3965
|
+
if (!this.triggerRef || !this.tooltipRef || this.follow)
|
|
3966
|
+
return;
|
|
3967
|
+
this.cleanupAutoUpdate = autoUpdate(this.triggerRef, this.tooltipRef, () => this.updatePosition(), {
|
|
3968
|
+
ancestorScroll: true,
|
|
3969
|
+
ancestorResize: true,
|
|
3970
|
+
elementResize: true,
|
|
3971
|
+
layoutShift: true,
|
|
3972
|
+
});
|
|
3973
|
+
}
|
|
3974
|
+
stopAutoUpdate() {
|
|
3975
|
+
if (this.cleanupAutoUpdate) {
|
|
3976
|
+
this.cleanupAutoUpdate();
|
|
3977
|
+
this.cleanupAutoUpdate = undefined;
|
|
3978
|
+
}
|
|
3979
|
+
}
|
|
3980
|
+
startFollowing() {
|
|
3981
|
+
if (!this.follow)
|
|
3982
|
+
return;
|
|
3983
|
+
const updateFollowPosition = () => {
|
|
3984
|
+
if (!this.isOpen || !this.tooltipRef) {
|
|
3985
|
+
this.rafId = undefined;
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
const offsetX = this.offset;
|
|
3989
|
+
const offsetY = this.offset;
|
|
3990
|
+
this.tooltipRef.style.left = `${this.mouseX + offsetX}px`;
|
|
3991
|
+
this.tooltipRef.style.top = `${this.mouseY + offsetY}px`;
|
|
3992
|
+
this.rafId = requestAnimationFrame(updateFollowPosition);
|
|
3993
|
+
};
|
|
3994
|
+
this.rafId = requestAnimationFrame(updateFollowPosition);
|
|
3995
|
+
}
|
|
3996
|
+
stopFollowing() {
|
|
3997
|
+
if (this.rafId) {
|
|
3998
|
+
cancelAnimationFrame(this.rafId);
|
|
3999
|
+
this.rafId = undefined;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
async updatePosition() {
|
|
4003
|
+
if (!this.triggerRef || !this.tooltipRef || this.follow)
|
|
4004
|
+
return;
|
|
4005
|
+
try {
|
|
4006
|
+
// Check if trigger element is still in viewport
|
|
4007
|
+
const triggerRect = this.triggerRef.getBoundingClientRect();
|
|
4008
|
+
const isInViewport = triggerRect.bottom > 0 && triggerRect.top < window.innerHeight && triggerRect.right > 0 && triggerRect.left < window.innerWidth;
|
|
4009
|
+
// Hide tooltip if trigger is out of viewport
|
|
4010
|
+
if (!isInViewport && this.isOpen) {
|
|
4011
|
+
this.hide();
|
|
4012
|
+
return;
|
|
4013
|
+
}
|
|
4014
|
+
const middleware = [offset(this.offset), flip(), shift({ padding: 8 })];
|
|
4015
|
+
if (this.arrow && this.arrowRef) {
|
|
4016
|
+
middleware.push(arrow({ element: this.arrowRef }));
|
|
4017
|
+
}
|
|
4018
|
+
// Use virtual element to properly handle shadow DOM boundaries
|
|
4019
|
+
const virtualElement = {
|
|
4020
|
+
getBoundingClientRect: () => this.triggerRef.getBoundingClientRect(),
|
|
4021
|
+
};
|
|
4022
|
+
const { x, y, placement, middlewareData } = await computePosition(virtualElement, this.tooltipRef, {
|
|
4023
|
+
placement: this.placement,
|
|
4024
|
+
strategy: 'fixed',
|
|
4025
|
+
middleware,
|
|
4026
|
+
});
|
|
4027
|
+
this.tooltipRef.style.left = `${x}px`;
|
|
4028
|
+
this.tooltipRef.style.top = `${y}px`;
|
|
4029
|
+
// Arrow positioning
|
|
4030
|
+
if (this.arrow && this.arrowRef && middlewareData.arrow) {
|
|
4031
|
+
const { x: arrowX, y: arrowY } = middlewareData.arrow;
|
|
4032
|
+
const side = placement.split('-')[0];
|
|
4033
|
+
const staticSide = {
|
|
4034
|
+
top: 'bottom',
|
|
4035
|
+
right: 'left',
|
|
4036
|
+
bottom: 'top',
|
|
4037
|
+
left: 'right',
|
|
4038
|
+
}[side];
|
|
4039
|
+
Object.assign(this.arrowRef.style, {
|
|
4040
|
+
left: arrowX != null ? `${arrowX}px` : '',
|
|
4041
|
+
top: arrowY != null ? `${arrowY}px` : '',
|
|
4042
|
+
right: '',
|
|
4043
|
+
bottom: '',
|
|
4044
|
+
[staticSide]: '-4px',
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
catch (error) {
|
|
4049
|
+
console.error('Failed to compute tooltip position:', error);
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
setupTriggerListeners() {
|
|
4053
|
+
if (!this.triggerRef)
|
|
4054
|
+
return;
|
|
4055
|
+
// Add new listeners based on trigger type
|
|
4056
|
+
if (this.trigger === 'hover') {
|
|
4057
|
+
this.triggerRef.addEventListener('mouseenter', this.handleMouseEnter);
|
|
4058
|
+
this.triggerRef.addEventListener('mouseleave', this.handleMouseLeave);
|
|
4059
|
+
if (this.follow) {
|
|
4060
|
+
this.triggerRef.addEventListener('mousemove', this.handleMouseMove);
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
else if (this.trigger === 'click') {
|
|
4064
|
+
this.triggerRef.addEventListener('click', this.handleClick);
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
removeTriggerListeners() {
|
|
4068
|
+
if (!this.triggerRef)
|
|
4069
|
+
return;
|
|
4070
|
+
this.triggerRef.removeEventListener('mouseenter', this.handleMouseEnter);
|
|
4071
|
+
this.triggerRef.removeEventListener('mouseleave', this.handleMouseLeave);
|
|
4072
|
+
this.triggerRef.removeEventListener('mousemove', this.handleMouseMove);
|
|
4073
|
+
this.triggerRef.removeEventListener('click', this.handleClick);
|
|
4074
|
+
}
|
|
4075
|
+
setupOutsideClickListener() {
|
|
4076
|
+
// Remove existing listener first
|
|
4077
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
4078
|
+
// Add listener only for click trigger
|
|
4079
|
+
if (this.trigger === 'click') {
|
|
4080
|
+
document.addEventListener('click', this.handleOutsideClick);
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
componentDidLoad() {
|
|
4084
|
+
// Generate unique ID for ARIA relationship
|
|
4085
|
+
this.tooltipId = `tooltip-${Math.random().toString(36).substring(2, 11)}`;
|
|
4086
|
+
// Setup outside click listener for click trigger
|
|
4087
|
+
this.setupOutsideClickListener();
|
|
4088
|
+
// Listen to popover toggle event to sync state
|
|
4089
|
+
if (this.tooltipRef) {
|
|
4090
|
+
this.tooltipRef.addEventListener('toggle', this.handleToggle);
|
|
4091
|
+
}
|
|
4092
|
+
// Setup keyboard listener for manual popover escape handling
|
|
4093
|
+
document.addEventListener('keydown', this.handleKeyDown);
|
|
4094
|
+
}
|
|
4095
|
+
disconnectedCallback() {
|
|
4096
|
+
this.clearTimeouts();
|
|
4097
|
+
this.stopAutoUpdate();
|
|
4098
|
+
this.stopFollowing();
|
|
4099
|
+
this.removeTriggerListeners();
|
|
4100
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
|
4101
|
+
document.removeEventListener('keydown', this.handleKeyDown);
|
|
4102
|
+
if (this.tooltipRef) {
|
|
4103
|
+
this.tooltipRef.removeEventListener('toggle', this.handleToggle);
|
|
4104
|
+
}
|
|
4105
|
+
}
|
|
4106
|
+
render() {
|
|
4107
|
+
const { tooltip, arrow: arrowClass } = this.tooltipClass({
|
|
4108
|
+
size: this.size,
|
|
4109
|
+
follow: this.follow,
|
|
4110
|
+
});
|
|
4111
|
+
return (index.h("div", { key: 'a539406275e1443e4446ec559cb3388ed2456328', class: "inline-block" }, index.h("slot", { key: 'b144f258b14a04369ff75ed90b7607ea05e23e67', onSlotchange: this.handleSlotChange }), index.h("div", { key: 'bbd08333a311e09e50bb2f1b3646892546f57164', ref: el => (this.tooltipRef = el), id: this.tooltipId, part: "tooltip", class: tooltip(),
|
|
4112
|
+
// @ts-ignore - popover is a valid attribute
|
|
4113
|
+
popover: "manual", role: "tooltip" }, this.arrow && !this.follow && index.h("div", { key: '7170aba70efdf413f4823cf2eff5618271b2fa70', ref: el => (this.arrowRef = el), part: "arrow", class: arrowClass() }), index.h("div", { key: '4fd9b56ce036663caaf1a75874e95ea566e214ef', part: "content" }, index.h("slot", { key: 'd5ab1ab3ef54e1c827ed1d009e226258a099378b', name: "content" }, this.message)))));
|
|
4114
|
+
}
|
|
4115
|
+
get host() { return index.getElement(this); }
|
|
4116
|
+
static get watchers() { return {
|
|
4117
|
+
"disabled": ["handleDisabledChange"],
|
|
4118
|
+
"trigger": ["handleTriggerChange"],
|
|
4119
|
+
"isOpen": ["handleOpenChange"]
|
|
4120
|
+
}; }
|
|
4121
|
+
};
|
|
4122
|
+
BcmTooltip.style = tooltipCss;
|
|
4123
|
+
|
|
4124
|
+
exports.bcm_button = BcmButton;
|
|
4125
|
+
exports.bcm_drawer = BcmDrawer;
|
|
4126
|
+
exports.bcm_linked = BcmLinked;
|
|
4127
|
+
exports.bcm_modal = BcmModal;
|
|
4128
|
+
exports.bcm_pop_confirm = BcmPopConfirm;
|
|
4129
|
+
exports.bcm_popover = Popover;
|
|
4130
|
+
exports.bcm_tooltip = BcmTooltip;
|
|
4131
|
+
//# sourceMappingURL=bcm-button.bcm-drawer.bcm-linked.bcm-modal.bcm-pop-confirm.bcm-popover.bcm-tooltip.entry.cjs.js.map
|