@patternfly/elements 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +490 -484
- package/package.json +1 -1
- package/pf-accordion/BaseAccordion.js +2 -1
- package/pf-accordion/BaseAccordion.js.map +1 -1
- package/pf-accordion/BaseAccordionHeader.js +4 -1
- package/pf-accordion/BaseAccordionHeader.js.map +1 -1
- package/pf-accordion/BaseAccordionPanel.d.ts +1 -1
- package/pf-accordion/pf-accordion-header.d.ts +1 -1
- package/pf-accordion/pf-accordion.d.ts +0 -5
- package/pf-accordion/pf-accordion.js +0 -5
- package/pf-accordion/pf-accordion.js.map +1 -1
- package/pf-accordion/test/pf-accordion.e2e.d.ts +1 -0
- package/pf-accordion/test/pf-accordion.e2e.js +11 -0
- package/pf-accordion/test/pf-accordion.e2e.js.map +1 -0
- package/pf-accordion/test/pf-accordion.spec.d.ts +1 -0
- package/pf-accordion/test/pf-accordion.spec.js +1222 -0
- package/pf-accordion/test/pf-accordion.spec.js.map +1 -0
- package/pf-avatar/BaseAvatar.d.ts +1 -1
- package/pf-avatar/test/pf-avatar.e2e.d.ts +1 -0
- package/pf-avatar/test/pf-avatar.e2e.js +11 -0
- package/pf-avatar/test/pf-avatar.e2e.js.map +1 -0
- package/pf-avatar/test/pf-avatar.spec.d.ts +1 -0
- package/pf-avatar/test/pf-avatar.spec.js +45 -0
- package/pf-avatar/test/pf-avatar.spec.js.map +1 -0
- package/pf-back-to-top/demo/demo.css +25 -0
- package/pf-back-to-top/pf-back-to-top.d.ts +1 -1
- package/pf-back-to-top/test/pf-back-to-top.e2e.d.ts +1 -0
- package/pf-back-to-top/test/pf-back-to-top.e2e.js +11 -0
- package/pf-back-to-top/test/pf-back-to-top.e2e.js.map +1 -0
- package/pf-back-to-top/test/pf-back-to-top.spec.d.ts +1 -0
- package/pf-back-to-top/test/pf-back-to-top.spec.js +267 -0
- package/pf-back-to-top/test/pf-back-to-top.spec.js.map +1 -0
- package/pf-background-image/pf-background-image.d.ts +1 -4
- package/pf-background-image/pf-background-image.js +1 -4
- package/pf-background-image/pf-background-image.js.map +1 -1
- package/pf-background-image/test/pf-background-image.e2e.d.ts +1 -0
- package/pf-background-image/test/pf-background-image.e2e.js +11 -0
- package/pf-background-image/test/pf-background-image.e2e.js.map +1 -0
- package/pf-background-image/test/pf-background-image.spec.d.ts +1 -0
- package/pf-background-image/test/pf-background-image.spec.js +89 -0
- package/pf-background-image/test/pf-background-image.spec.js.map +1 -0
- package/pf-badge/BaseBadge.d.ts +1 -1
- package/pf-badge/test/pf-badge.e2e.d.ts +1 -0
- package/pf-badge/test/pf-badge.e2e.js +11 -0
- package/pf-badge/test/pf-badge.e2e.js.map +1 -0
- package/pf-badge/test/pf-badge.spec.d.ts +1 -0
- package/pf-badge/test/pf-badge.spec.js +52 -0
- package/pf-badge/test/pf-badge.spec.js.map +1 -0
- package/pf-banner/pf-banner.d.ts +1 -10
- package/pf-banner/pf-banner.js +0 -9
- package/pf-banner/pf-banner.js.map +1 -1
- package/pf-banner/test/pf-banner.e2e.d.ts +1 -0
- package/pf-banner/test/pf-banner.e2e.js +11 -0
- package/pf-banner/test/pf-banner.e2e.js.map +1 -0
- package/pf-banner/test/pf-banner.spec.d.ts +1 -0
- package/pf-banner/test/pf-banner.spec.js +81 -0
- package/pf-banner/test/pf-banner.spec.js.map +1 -0
- package/pf-button/BaseButton.d.ts +7 -2
- package/pf-button/BaseButton.js +4 -1
- package/pf-button/BaseButton.js.map +1 -1
- package/pf-button/pf-button.d.ts +1 -17
- package/pf-button/pf-button.js +10 -18
- package/pf-button/pf-button.js.map +1 -1
- package/pf-button/test/pf-button.e2e.d.ts +1 -0
- package/pf-button/test/pf-button.e2e.js +11 -0
- package/pf-button/test/pf-button.e2e.js.map +1 -0
- package/pf-button/test/pf-button.spec.d.ts +1 -0
- package/pf-button/test/pf-button.spec.js +124 -0
- package/pf-button/test/pf-button.spec.js.map +1 -0
- package/pf-card/BaseCard.d.ts +1 -1
- package/pf-card/test/pf-card.e2e.d.ts +1 -0
- package/pf-card/test/pf-card.e2e.js +11 -0
- package/pf-card/test/pf-card.e2e.js.map +1 -0
- package/pf-card/test/pf-card.spec.d.ts +1 -0
- package/pf-card/test/pf-card.spec.js +160 -0
- package/pf-card/test/pf-card.spec.js.map +1 -0
- package/pf-chip/pf-chip-group.d.ts +8 -5
- package/pf-chip/pf-chip-group.js +10 -10
- package/pf-chip/pf-chip-group.js.map +1 -1
- package/pf-chip/pf-chip.d.ts +8 -5
- package/pf-chip/pf-chip.js +4 -4
- package/pf-chip/pf-chip.js.map +1 -1
- package/pf-chip/test/pf-chip-group.spec.d.ts +1 -0
- package/pf-chip/test/pf-chip-group.spec.js +189 -0
- package/pf-chip/test/pf-chip-group.spec.js.map +1 -0
- package/pf-chip/test/pf-chip.e2e.d.ts +1 -0
- package/pf-chip/test/pf-chip.e2e.js +11 -0
- package/pf-chip/test/pf-chip.e2e.js.map +1 -0
- package/pf-chip/test/pf-chip.spec.d.ts +1 -0
- package/pf-chip/test/pf-chip.spec.js +116 -0
- package/pf-chip/test/pf-chip.spec.js.map +1 -0
- package/pf-clipboard-copy/pf-clipboard-copy.d.ts +8 -3
- package/pf-clipboard-copy/pf-clipboard-copy.js +5 -3
- package/pf-clipboard-copy/pf-clipboard-copy.js.map +1 -1
- package/pf-clipboard-copy/test/pf-clipboard-copy.e2e.d.ts +1 -0
- package/pf-clipboard-copy/test/pf-clipboard-copy.e2e.js +11 -0
- package/pf-clipboard-copy/test/pf-clipboard-copy.e2e.js.map +1 -0
- package/pf-clipboard-copy/test/pf-clipboard-copy.spec.d.ts +1 -0
- package/pf-clipboard-copy/test/pf-clipboard-copy.spec.js +103 -0
- package/pf-clipboard-copy/test/pf-clipboard-copy.spec.js.map +1 -0
- package/pf-code-block/BaseCodeBlock.js +2 -2
- package/pf-code-block/BaseCodeBlock.js.map +1 -1
- package/pf-code-block/pf-code-block.d.ts +1 -1
- package/pf-code-block/test/pf-code-block.e2e.d.ts +1 -0
- package/pf-code-block/test/pf-code-block.e2e.js +11 -0
- package/pf-code-block/test/pf-code-block.e2e.js.map +1 -0
- package/pf-code-block/test/pf-code-block.spec.d.ts +1 -0
- package/pf-code-block/test/pf-code-block.spec.js +89 -0
- package/pf-code-block/test/pf-code-block.spec.js.map +1 -0
- package/pf-dropdown/pf-dropdown-group.d.ts +1 -1
- package/pf-dropdown/pf-dropdown-group.js +4 -1
- package/pf-dropdown/pf-dropdown-group.js.map +1 -1
- package/pf-dropdown/pf-dropdown-item.d.ts +1 -2
- package/pf-dropdown/pf-dropdown-item.js +4 -2
- package/pf-dropdown/pf-dropdown-item.js.map +1 -1
- package/pf-dropdown/pf-dropdown-menu.d.ts +1 -2
- package/pf-dropdown/pf-dropdown-menu.js +8 -6
- package/pf-dropdown/pf-dropdown-menu.js.map +1 -1
- package/pf-dropdown/pf-dropdown.d.ts +8 -6
- package/pf-dropdown/pf-dropdown.js +11 -11
- package/pf-dropdown/pf-dropdown.js.map +1 -1
- package/pf-dropdown/test/pf-dropdown.e2e.d.ts +1 -0
- package/pf-dropdown/test/pf-dropdown.e2e.js +11 -0
- package/pf-dropdown/test/pf-dropdown.e2e.js.map +1 -0
- package/pf-dropdown/test/pf-dropdown.spec.d.ts +1 -0
- package/pf-dropdown/test/pf-dropdown.spec.js +129 -0
- package/pf-dropdown/test/pf-dropdown.spec.js.map +1 -0
- package/pf-icon/BaseIcon.d.ts +1 -2
- package/pf-icon/BaseIcon.js +3 -4
- package/pf-icon/BaseIcon.js.map +1 -1
- package/pf-icon/demo/icons/rh/boba-tea.js +5 -0
- package/pf-icon/demo/icons/rh/lifecycle.js +3 -0
- package/pf-icon/test/pf-icon.e2e.d.ts +1 -0
- package/pf-icon/test/pf-icon.e2e.js +11 -0
- package/pf-icon/test/pf-icon.e2e.js.map +1 -0
- package/pf-icon/test/pf-icon.spec.d.ts +1 -0
- package/pf-icon/test/pf-icon.spec.js +130 -0
- package/pf-icon/test/pf-icon.spec.js.map +1 -0
- package/pf-icon/test/rh-icon-aed.js +2 -0
- package/pf-icon/test/rh-icon-api.js +2 -0
- package/pf-icon/test/rh-icon-atom.js +2 -0
- package/pf-icon/test/rh-icon-bike.js +2 -0
- package/pf-jump-links/pf-jump-links-item.d.ts +8 -2
- package/pf-jump-links/pf-jump-links-item.js +4 -1
- package/pf-jump-links/pf-jump-links-item.js.map +1 -1
- package/pf-jump-links/pf-jump-links-list.d.ts +1 -1
- package/pf-jump-links/pf-jump-links.d.ts +1 -7
- package/pf-jump-links/pf-jump-links.js +1 -7
- package/pf-jump-links/pf-jump-links.js.map +1 -1
- package/pf-jump-links/test/pf-jump-links.e2e.d.ts +1 -0
- package/pf-jump-links/test/pf-jump-links.e2e.js +11 -0
- package/pf-jump-links/test/pf-jump-links.e2e.js.map +1 -0
- package/pf-jump-links/test/pf-jump-links.spec.d.ts +1 -0
- package/pf-jump-links/test/pf-jump-links.spec.js +85 -0
- package/pf-jump-links/test/pf-jump-links.spec.js.map +1 -0
- package/pf-label/BaseLabel.d.ts +1 -1
- package/pf-label/pf-label.d.ts +10 -24
- package/pf-label/pf-label.js +4 -21
- package/pf-label/pf-label.js.map +1 -1
- package/pf-label/test/pf-label.e2e.d.ts +1 -0
- package/pf-label/test/pf-label.e2e.js +11 -0
- package/pf-label/test/pf-label.e2e.js.map +1 -0
- package/pf-label/test/pf-label.spec.d.ts +1 -0
- package/pf-label/test/pf-label.spec.js +111 -0
- package/pf-label/test/pf-label.spec.js.map +1 -0
- package/pf-modal/pf-modal.d.ts +1 -6
- package/pf-modal/pf-modal.js +6 -8
- package/pf-modal/pf-modal.js.map +1 -1
- package/pf-modal/test/pf-modal.e2e.d.ts +1 -0
- package/pf-modal/test/pf-modal.e2e.js +13 -0
- package/pf-modal/test/pf-modal.e2e.js.map +1 -0
- package/pf-modal/test/pf-modal.spec.d.ts +1 -0
- package/pf-modal/test/pf-modal.spec.js +197 -0
- package/pf-modal/test/pf-modal.spec.js.map +1 -0
- package/pf-panel/pf-panel.d.ts +1 -1
- package/pf-panel/test/pf-panel.e2e.d.ts +1 -0
- package/pf-panel/test/pf-panel.e2e.js +11 -0
- package/pf-panel/test/pf-panel.e2e.js.map +1 -0
- package/pf-panel/test/pf-panel.spec.d.ts +1 -0
- package/pf-panel/test/pf-panel.spec.js +22 -0
- package/pf-panel/test/pf-panel.spec.js.map +1 -0
- package/pf-popover/pf-popover.d.ts +1 -5
- package/pf-popover/pf-popover.js +12 -7
- package/pf-popover/pf-popover.js.map +1 -1
- package/pf-popover/test/pf-popover.e2e.d.ts +1 -0
- package/pf-popover/test/pf-popover.e2e.js +11 -0
- package/pf-popover/test/pf-popover.e2e.js.map +1 -0
- package/pf-popover/test/pf-popover.spec.d.ts +1 -0
- package/pf-popover/test/pf-popover.spec.js +233 -0
- package/pf-popover/test/pf-popover.spec.js.map +1 -0
- package/pf-progress/demo/kitchen-sink.css +4 -0
- package/pf-progress/pf-progress.d.ts +1 -22
- package/pf-progress/pf-progress.js +1 -22
- package/pf-progress/pf-progress.js.map +1 -1
- package/pf-progress/test/pf-progress.e2e.d.ts +1 -0
- package/pf-progress/test/pf-progress.e2e.js +11 -0
- package/pf-progress/test/pf-progress.e2e.js.map +1 -0
- package/pf-progress/test/pf-progress.spec.d.ts +1 -0
- package/pf-progress/test/pf-progress.spec.js +45 -0
- package/pf-progress/test/pf-progress.spec.js.map +1 -0
- package/pf-progress-stepper/pf-progress-step.d.ts +1 -1
- package/pf-progress-stepper/pf-progress-stepper.d.ts +1 -1
- package/pf-progress-stepper/test/pf-progress-stepper.e2e.d.ts +1 -0
- package/pf-progress-stepper/test/pf-progress-stepper.e2e.js +11 -0
- package/pf-progress-stepper/test/pf-progress-stepper.e2e.js.map +1 -0
- package/pf-progress-stepper/test/pf-progress-stepper.spec.d.ts +1 -0
- package/pf-progress-stepper/test/pf-progress-stepper.spec.js +18 -0
- package/pf-progress-stepper/test/pf-progress-stepper.spec.js.map +1 -0
- package/pf-select/pf-option-group.d.ts +1 -1
- package/pf-select/pf-option-group.js +2 -0
- package/pf-select/pf-option-group.js.map +1 -1
- package/pf-select/pf-option.d.ts +1 -2
- package/pf-select/pf-option.js +3 -4
- package/pf-select/pf-option.js.map +1 -1
- package/pf-select/pf-select.d.ts +8 -3
- package/pf-select/pf-select.js +51 -21
- package/pf-select/pf-select.js.map +1 -1
- package/pf-select/test/pf-select.e2e.d.ts +1 -0
- package/pf-select/test/pf-select.e2e.js +11 -0
- package/pf-select/test/pf-select.e2e.js.map +1 -0
- package/pf-select/test/pf-select.spec.d.ts +1 -0
- package/pf-select/test/pf-select.spec.js +866 -0
- package/pf-select/test/pf-select.spec.js.map +1 -0
- package/pf-spinner/BaseSpinner.d.ts +1 -2
- package/pf-spinner/BaseSpinner.js +2 -4
- package/pf-spinner/BaseSpinner.js.map +1 -1
- package/pf-spinner/pf-spinner.d.ts +2 -2
- package/pf-spinner/pf-spinner.js +8 -1
- package/pf-spinner/pf-spinner.js.map +1 -1
- package/pf-spinner/test/pf-spinner.e2e.d.ts +1 -0
- package/pf-spinner/test/pf-spinner.e2e.js +11 -0
- package/pf-spinner/test/pf-spinner.e2e.js.map +1 -0
- package/pf-spinner/test/pf-spinner.spec.d.ts +1 -0
- package/pf-spinner/test/pf-spinner.spec.js +64 -0
- package/pf-spinner/test/pf-spinner.spec.js.map +1 -0
- package/pf-switch/BaseSwitch.d.ts +1 -1
- package/pf-switch/BaseSwitch.js +3 -3
- package/pf-switch/BaseSwitch.js.map +1 -1
- package/pf-switch/test/pf-switch.e2e.d.ts +1 -0
- package/pf-switch/test/pf-switch.e2e.js +11 -0
- package/pf-switch/test/pf-switch.e2e.js.map +1 -0
- package/pf-switch/test/pf-switch.spec.d.ts +1 -0
- package/pf-switch/test/pf-switch.spec.js +191 -0
- package/pf-switch/test/pf-switch.spec.js.map +1 -0
- package/pf-table/pf-caption.d.ts +1 -1
- package/pf-table/pf-table.d.ts +1 -3
- package/pf-table/pf-table.js +2 -4
- package/pf-table/pf-table.js.map +1 -1
- package/pf-table/pf-tbody.d.ts +1 -1
- package/pf-table/pf-td.d.ts +1 -1
- package/pf-table/pf-th.d.ts +1 -1
- package/pf-table/pf-th.js +3 -3
- package/pf-table/pf-th.js.map +1 -1
- package/pf-table/pf-thead.d.ts +1 -1
- package/pf-table/pf-tr.d.ts +1 -1
- package/pf-table/pf-tr.js +4 -4
- package/pf-table/pf-tr.js.map +1 -1
- package/pf-table/test/pf-table.e2e.d.ts +1 -0
- package/pf-table/test/pf-table.e2e.js +11 -0
- package/pf-table/test/pf-table.e2e.js.map +1 -0
- package/pf-table/test/pf-table.spec.d.ts +1 -0
- package/pf-table/test/pf-table.spec.js +17 -0
- package/pf-table/test/pf-table.spec.js.map +1 -0
- package/pf-tabs/BaseTab.d.ts +2 -2
- package/pf-tabs/BaseTab.js +4 -1
- package/pf-tabs/BaseTab.js.map +1 -1
- package/pf-tabs/BaseTabPanel.d.ts +1 -1
- package/pf-tabs/BaseTabs.d.ts +1 -3
- package/pf-tabs/BaseTabs.js +11 -12
- package/pf-tabs/BaseTabs.js.map +1 -1
- package/pf-tabs/pf-tab-panel.d.ts +1 -1
- package/pf-tabs/pf-tab.d.ts +1 -17
- package/pf-tabs/pf-tab.js +0 -16
- package/pf-tabs/pf-tab.js.map +1 -1
- package/pf-tabs/pf-tabs.d.ts +1 -12
- package/pf-tabs/pf-tabs.js +2 -13
- package/pf-tabs/pf-tabs.js.map +1 -1
- package/pf-tabs/test/pf-tabs.e2e.d.ts +1 -0
- package/pf-tabs/test/pf-tabs.e2e.js +13 -0
- package/pf-tabs/test/pf-tabs.e2e.js.map +1 -0
- package/pf-tabs/test/pf-tabs.spec.d.ts +1 -0
- package/pf-tabs/test/pf-tabs.spec.js +285 -0
- package/pf-tabs/test/pf-tabs.spec.js.map +1 -0
- package/pf-text-area/pf-text-area.d.ts +1 -2
- package/pf-text-area/pf-text-area.js +5 -5
- package/pf-text-area/pf-text-area.js.map +1 -1
- package/pf-text-area/test/pf-text-area.e2e.d.ts +1 -0
- package/pf-text-area/test/pf-text-area.e2e.js +11 -0
- package/pf-text-area/test/pf-text-area.e2e.js.map +1 -0
- package/pf-text-area/test/pf-text-area.spec.d.ts +1 -0
- package/pf-text-area/test/pf-text-area.spec.js +89 -0
- package/pf-text-area/test/pf-text-area.spec.js.map +1 -0
- package/pf-text-input/demo/demo.css +6 -0
- package/pf-text-input/pf-text-input.d.ts +8 -3
- package/pf-text-input/pf-text-input.js +4 -2
- package/pf-text-input/pf-text-input.js.map +1 -1
- package/pf-text-input/test/pf-text-input.e2e.d.ts +1 -0
- package/pf-text-input/test/pf-text-input.e2e.js +11 -0
- package/pf-text-input/test/pf-text-input.e2e.js.map +1 -0
- package/pf-text-input/test/pf-text-input.spec.d.ts +1 -0
- package/pf-text-input/test/pf-text-input.spec.js +20 -0
- package/pf-text-input/test/pf-text-input.spec.js.map +1 -0
- package/pf-tile/BaseTile.d.ts +1 -1
- package/pf-tile/pf-tile.d.ts +0 -12
- package/pf-tile/pf-tile.js +0 -12
- package/pf-tile/pf-tile.js.map +1 -1
- package/pf-tile/test/pf-tile.e2e.d.ts +1 -0
- package/pf-tile/test/pf-tile.e2e.js +11 -0
- package/pf-tile/test/pf-tile.e2e.js.map +1 -0
- package/pf-tile/test/pf-tile.spec.d.ts +1 -0
- package/pf-tile/test/pf-tile.spec.js +54 -0
- package/pf-tile/test/pf-tile.spec.js.map +1 -0
- package/pf-timestamp/pf-timestamp.d.ts +1 -1
- package/pf-timestamp/pf-timestamp.js +5 -1
- package/pf-timestamp/pf-timestamp.js.map +1 -1
- package/pf-timestamp/test/pf-timestamp.e2e.d.ts +1 -0
- package/pf-timestamp/test/pf-timestamp.e2e.js +12 -0
- package/pf-timestamp/test/pf-timestamp.e2e.js.map +1 -0
- package/pf-timestamp/test/pf-timestamp.spec.d.ts +1 -0
- package/pf-timestamp/test/pf-timestamp.spec.js +156 -0
- package/pf-timestamp/test/pf-timestamp.spec.js.map +1 -0
- package/pf-tooltip/BaseTooltip.d.ts +1 -1
- package/pf-tooltip/pf-tooltip.d.ts +1 -4
- package/pf-tooltip/pf-tooltip.js +6 -7
- package/pf-tooltip/pf-tooltip.js.map +1 -1
- package/pf-tooltip/test/pf-tooltip.e2e.d.ts +1 -0
- package/pf-tooltip/test/pf-tooltip.e2e.js +11 -0
- package/pf-tooltip/test/pf-tooltip.e2e.js.map +1 -0
- package/pf-tooltip/test/pf-tooltip.spec.d.ts +1 -0
- package/pf-tooltip/test/pf-tooltip.spec.js +53 -0
- package/pf-tooltip/test/pf-tooltip.spec.js.map +1 -0
- package/pfe.min.js +269 -266
- package/pfe.min.js.map +3 -3
- package/pf-accordion/README.md +0 -44
- package/pf-avatar/README.md +0 -31
- package/pf-back-to-top/README.md +0 -32
- package/pf-background-image/README.md +0 -37
- package/pf-badge/README.md +0 -57
- package/pf-banner/README.md +0 -60
- package/pf-button/README.md +0 -61
- package/pf-card/README.md +0 -34
- package/pf-chip/README.md +0 -20
- package/pf-clipboard-copy/README.md +0 -8
- package/pf-code-block/README.md +0 -77
- package/pf-dropdown/README.md +0 -46
- package/pf-icon/README.md +0 -86
- package/pf-icon/icons/fab/readme.svg +0 -1
- package/pf-jump-links/README.md +0 -27
- package/pf-label/README.md +0 -61
- package/pf-modal/README.md +0 -63
- package/pf-panel/README.md +0 -10
- package/pf-popover/README.md +0 -48
- package/pf-progress/README.md +0 -33
- package/pf-progress-stepper/README.md +0 -41
- package/pf-select/README.md +0 -21
- package/pf-spinner/README.md +0 -46
- package/pf-switch/README.md +0 -91
- package/pf-table/README.md +0 -43
- package/pf-tabs/README.md +0 -40
- package/pf-text-area/README.md +0 -11
- package/pf-text-input/README.md +0 -9
- package/pf-tile/README.md +0 -12
- package/pf-timestamp/README.md +0 -64
- package/pf-tooltip/README.md +0 -64
package/pf-label/pf-label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-label.js","sourceRoot":"","sources":["pf-label.ts"],"names":[],"mappings":";AAAA,OAAO,E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S;;8BAE3B,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;6BACrD,IAAI,CAAC,gBAAgB,IAAI,QAAQ;;;;;;KAMzD,CAAC;IACJ,CAAC;;AAxDe,cAAM,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,AAAhC,CAAiC;AAEvC,yBAAiB,GAAmB,EAAE,GAAG,SAAS,CAAC,iBAAiB,EAAE,cAAc,EAAE,IAAI,EAAE,AAA3E,CAA4E;AAOjG;IAAX,QAAQ,EAAE;wCAAkC;AAKjC;IAAX,QAAQ,EAAE;sCAA4B;AAG3B;IAAX,QAAQ,EAAE;qCAAe;AAGG;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAAiB;AAGhB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAmB;AAGlB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CAAmB;AAGA;IAA9C,QAAQ,CAAC,EAAE,SAAS,EAAE,oBAAoB,EAAE,CAAC;iDAA2B;AA9B9D,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA0DnB","sourcesContent":["import { html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\n\nimport { BaseLabel } from './BaseLabel.js';\n\nimport '@patternfly/elements/pf-button/pf-button.js';\n\nimport styles from './pf-label.css';\n\nexport type LabelVariant = (\n | 'filled'\n | 'outline'\n);\n\nexport type LabelColor = (\n | 'blue'\n | 'cyan'\n | 'green'\n | 'orange'\n | 'purple'\n | 'red'\n | 'grey'\n | 'gold'\n)\n\n/**\n * The **label** component allows users to add specific element captions for user\n * clarity and convenience.\n *\n * @summary Allows users to display meta data in a stylized form.\n *\n * @fires close - when a removable label's close button is clicked\n *\n * @cssprop {<length>} --pf-c-label--FontSize {@default `0.875em`}\n *\n * @cssprop {<length>} --pf-c-label--PaddingTop {@default `0.25rem`}\n * @cssprop {<length>} --pf-c-label--PaddingRight {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-label--PaddingBottom {@default `0.25rem`}\n * @cssprop {<length>} --pf-c-label--PaddingLeft {@default `0.5rem`}\n *\n * @cssprop {<color>} --pf-c-label--Color {@default `#151515`}\n * @cssprop {<color>} --pf-c-label--BackgroundColor {@default `#f5f5f5`}\n *\n * @cssprop {<length>} --pf-c-label--BorderRadius {@default `30em`}\n *\n * @cssprop {<length>} --pf-c-label__content--MaxWidth {@default `100%`}\n * @cssprop {<color>} --pf-c-label__content--Color {@default `#151515`}\n * @cssprop {<length>} --pf-c-label__content--before--BorderWidth {@default `1px`}\n * @cssprop {<color>} --pf-c-label__content--before--BorderColor {@default `#d2d2d2`}\n *\n * @cssprop {<color>} --pf-c-label--m-outline__content--Color {@default `#151515`}\n * @cssprop {<color>} --pf-c-label--m-outline--BackgroundColor {@default `#ffffff`}\n *\n * @cssprop {<color>} --pf-c-label--m-blue__content--Color {@default `#002952`}\n * @cssprop {<color>} --pf-c-label--m-blue--BackgroundColor {@default `#e7f1fa`}\n * @cssprop {<color>} --pf-c-label--m-blue__content--before--BorderColor {@default `#bee1f4`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-blue__content--Color {@default `#06c`}\n *\n * @cssprop {<color>} --pf-c-label--m-cyan__content--Color {@default `#3b1f00`}\n * @cssprop {<color>} --pf-c-label--m-cyan--BackgroundColor {@default `#f2f9f9`}\n * @cssprop {<color>} --pf-c-label--m-cyan__content--before--BorderColor {@default `#a2d9d9`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-cyan__content--Color {@default `#005f60`}\n *\n * @cssprop {<color>} --pf-c-label--m-green__content--Color {@default `#1e4f18`}\n * @cssprop {<color>} --pf-c-label--m-green--BackgroundColor {@default `#f3faf2`}\n * @cssprop {<color>} --pf-c-label--m-green__content--before--BorderColor {@default `#bde5b8`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-green__content--Color {@default `#3e8635`}\n *\n * @cssprop {<color>} --pf-c-label--m-orange__content--Color {@default `#003737`}\n * @cssprop {<color>} --pf-c-label--m-orange--BackgroundColor {@default `#fff6ec`}\n * @cssprop {<color>} --pf-c-label--m-orange__content--before--BorderColor {@default `#f4b678`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-orange__content--Color {@default `#8f4700`}\n *\n * @cssprop {<color>} --pf-c-label--m-purple__content--Color {@default `#1f0066`}\n * @cssprop {<color>} --pf-c-label--m-purple--BackgroundColor {@default `#f2f0fc`}\n * @cssprop {<color>} --pf-c-label--m-purple__content--before--BorderColor {@default `#cbc1ff`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-purple__content--Color {@default `#6753ac`}\n *\n * @cssprop {<color>} --pf-c-label--m-red__content--Color {@default `#7d1007`}\n * @cssprop {<color>} --pf-c-label--m-red--BackgroundColor {@default `#faeae8`}\n * @cssprop {<color>} --pf-c-label--m-red__content--before--BorderColor {@default `#c9190b`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-red__content--Color {@default `#c9190b`}\n *\n * @cssprop {<color>} --pf-c-label--m-gold__content--Color {@default `#3d2c00`}\n * @cssprop {<color>} --pf-c-label--m-gold--BackgroundColor {@default `#fdf7e7`}\n * @cssprop {<color>} --pf-c-label--m-gold__content--before--BorderColor {@default `#f9e0a2`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-gold__content--Color {@default `#795600`}\n\n * @cssprop {<color>} --pf-c-label--m-blue__icon--Color {@default `#06c`}\n * @cssprop {<color>} --pf-c-label--m-cyan__icon--Color {@default `#009596`}\n * @cssprop {<color>} --pf-c-label--m-green__icon--Color {@default `#3e8635`}\n * @cssprop {<color>} --pf-c-label--m-orange__icon--Color {@default `#ec7a08`}\n * @cssprop {<color>} --pf-c-label--m-red__icon--Color {@default `#c9190b`}\n * @cssprop {<color>} --pf-c-label--m-gold__icon--Color {@default `#f0ab00`}\n *\n * @csspart icon - container for the label icon\n * @csspart close-button - container for removable labels' close button\n *\n * @slot icon\n * Contains the labels's icon, e.g. web-icon-alert-success.\n *\n * @slot\n * Must contain the text for the label.\n *\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingTop {@default `0`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingRight {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingBottom {@default `0`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingLeft {@default `0.5rem`}\n */\n@customElement('pf-label')\nexport class PfLabel extends BaseLabel {\n static readonly styles = [...BaseLabel.styles, styles];\n\n static readonly shadowRootOptions: ShadowRootInit = { ...BaseLabel.shadowRootOptions, delegatesFocus: true };\n\n /**\n * Changes the style of the label.\n * - Filled: Colored background with colored border.\n * - Outline: White background with colored border.\n */\n @property() variant: LabelVariant = 'filled';\n\n /**\n * Changes the color of the label\n */\n @property() color: LabelColor = 'grey';\n\n /** Shorthand for the `icon` slot, the value is icon name */\n @property() icon?: string;\n\n /** Flag indicating the label is compact */\n @property({ type: Boolean }) compact = false;\n\n /** Flag indicating the label text should be truncated */\n @property({ type: Boolean }) truncated = false;\n\n /** Flag indicating the label is removable */\n @property({ type: Boolean }) removable = false;\n\n /** Text label for a removable label's close button */\n @property({ attribute: 'close-button-label' }) closeButtonLabel?: string;\n\n override render() {\n const { compact, truncated } = this;\n return html`\n <span id=\"pf-container\" class=\"${classMap({ compact, truncated })}\">${super.render()}</span>\n `;\n }\n\n protected override renderDefaultIcon() {\n return !this.icon ? '' : html`\n <pf-icon icon=\"${this.icon}\" size=\"sm\"></pf-icon>\n `;\n }\n\n protected override renderSuffix() {\n return !this.removable ? '' : html`\n <span part=\"close-button\" ?hidden=${!this.removable}>\n <pf-button plain\n @click=\"${() => this.dispatchEvent(new ComposedEvent('close'))}\"\n label=\"${this.closeButtonLabel ?? 'remove'}\">\n <svg viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"/>\n </svg>\n </pf-button>\n </span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-label': PfLabel;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pf-label.js","sourceRoot":"","sources":["pf-label.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,6CAA6C,CAAC;;;AAoBrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,SAAS;IAA/B;;QAQL;;;;WAIG;QACS,YAAO,GAAiB,QAAQ,CAAC;QAE7C;;WAEG;QACS,UAAK,GAAe,MAAM,CAAC;QAKvC,2CAA2C;QACd,YAAO,GAAG,KAAK,CAAC;QAE7C,yDAAyD;QAC5B,cAAS,GAAG,KAAK,CAAC;QAE/C,6CAA6C;Q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,SAAS,EAAE,oBAAoB,EAAE,CAAC;iDAA2B;AAjC9D,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA6DnB","sourcesContent":["import { html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\n\nimport { BaseLabel } from './BaseLabel.js';\n\nimport '@patternfly/elements/pf-button/pf-button.js';\n\nimport styles from './pf-label.css';\n\nexport type LabelVariant = (\n | 'filled'\n | 'outline'\n);\n\nexport type LabelColor = (\n | 'blue'\n | 'cyan'\n | 'green'\n | 'orange'\n | 'purple'\n | 'red'\n | 'grey'\n | 'gold'\n);\n\n/**\n * The **label** component allows users to add specific element captions for user\n * clarity and convenience.\n * @summary Allows users to display meta data in a stylized form.\n * @fires close - when a removable label's close button is clicked\n * @cssprop {<length>} --pf-c-label--FontSize {@default `0.875em`}\n * @cssprop {<length>} --pf-c-label--PaddingTop {@default `0.25rem`}\n * @cssprop {<length>} --pf-c-label--PaddingRight {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-label--PaddingBottom {@default `0.25rem`}\n * @cssprop {<length>} --pf-c-label--PaddingLeft {@default `0.5rem`}\n * @cssprop {<color>} --pf-c-label--Color {@default `#151515`}\n * @cssprop {<color>} --pf-c-label--BackgroundColor {@default `#f5f5f5`}\n * @cssprop {<length>} --pf-c-label--BorderRadius {@default `30em`}\n * @cssprop {<length>} --pf-c-label__content--MaxWidth {@default `100%`}\n * @cssprop {<color>} --pf-c-label__content--Color {@default `#151515`}\n * @cssprop {<length>} --pf-c-label__content--before--BorderWidth {@default `1px`}\n * @cssprop {<color>} --pf-c-label__content--before--BorderColor {@default `#d2d2d2`}\n * @cssprop {<color>} --pf-c-label--m-outline__content--Color {@default `#151515`}\n * @cssprop {<color>} --pf-c-label--m-outline--BackgroundColor {@default `#ffffff`}\n * @cssprop {<color>} --pf-c-label--m-blue__content--Color {@default `#002952`}\n * @cssprop {<color>} --pf-c-label--m-blue--BackgroundColor {@default `#e7f1fa`}\n * @cssprop {<color>} --pf-c-label--m-blue__content--before--BorderColor {@default `#bee1f4`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-blue__content--Color {@default `#06c`}\n * @cssprop {<color>} --pf-c-label--m-cyan__content--Color {@default `#3b1f00`}\n * @cssprop {<color>} --pf-c-label--m-cyan--BackgroundColor {@default `#f2f9f9`}\n * @cssprop {<color>} --pf-c-label--m-cyan__content--before--BorderColor {@default `#a2d9d9`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-cyan__content--Color {@default `#005f60`}\n * @cssprop {<color>} --pf-c-label--m-green__content--Color {@default `#1e4f18`}\n * @cssprop {<color>} --pf-c-label--m-green--BackgroundColor {@default `#f3faf2`}\n * @cssprop {<color>} --pf-c-label--m-green__content--before--BorderColor {@default `#bde5b8`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-green__content--Color {@default `#3e8635`}\n * @cssprop {<color>} --pf-c-label--m-orange__content--Color {@default `#003737`}\n * @cssprop {<color>} --pf-c-label--m-orange--BackgroundColor {@default `#fff6ec`}\n * @cssprop {<color>} --pf-c-label--m-orange__content--before--BorderColor {@default `#f4b678`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-orange__content--Color {@default `#8f4700`}\n * @cssprop {<color>} --pf-c-label--m-purple__content--Color {@default `#1f0066`}\n * @cssprop {<color>} --pf-c-label--m-purple--BackgroundColor {@default `#f2f0fc`}\n * @cssprop {<color>} --pf-c-label--m-purple__content--before--BorderColor {@default `#cbc1ff`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-purple__content--Color {@default `#6753ac`}\n * @cssprop {<color>} --pf-c-label--m-red__content--Color {@default `#7d1007`}\n * @cssprop {<color>} --pf-c-label--m-red--BackgroundColor {@default `#faeae8`}\n * @cssprop {<color>} --pf-c-label--m-red__content--before--BorderColor {@default `#c9190b`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-red__content--Color {@default `#c9190b`}\n * @cssprop {<color>} --pf-c-label--m-gold__content--Color {@default `#3d2c00`}\n * @cssprop {<color>} --pf-c-label--m-gold--BackgroundColor {@default `#fdf7e7`}\n * @cssprop {<color>} --pf-c-label--m-gold__content--before--BorderColor {@default `#f9e0a2`}\n * @cssprop {<color>} --pf-c-label--m-outline--m-gold__content--Color {@default `#795600`}\n * @cssprop {<color>} --pf-c-label--m-blue__icon--Color {@default `#06c`}\n * @cssprop {<color>} --pf-c-label--m-cyan__icon--Color {@default `#009596`}\n * @cssprop {<color>} --pf-c-label--m-green__icon--Color {@default `#3e8635`}\n * @cssprop {<color>} --pf-c-label--m-orange__icon--Color {@default `#ec7a08`}\n * @cssprop {<color>} --pf-c-label--m-red__icon--Color {@default `#c9190b`}\n * @cssprop {<color>} --pf-c-label--m-gold__icon--Color {@default `#f0ab00`}\n * @csspart icon - container for the label icon\n * @csspart close-button - container for removable labels' close button\n * @slot icon\n * Contains the labels's icon, e.g. web-icon-alert-success.\n * @slot\n * Must contain the text for the label.\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingTop {@default `0`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingRight {@default `0.5rem`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingBottom {@default `0`}\n * @cssprop {<length>} --pf-c-label--m-compact--PaddingLeft {@default `0.5rem`}\n */\n@customElement('pf-label')\nexport class PfLabel extends BaseLabel {\n static readonly styles = [...BaseLabel.styles, styles];\n\n static override readonly shadowRootOptions = {\n ...BaseLabel.shadowRootOptions,\n delegatesFocus: true,\n };\n\n /**\n * Changes the style of the label.\n * - Filled: Colored background with colored border.\n * - Outline: White background with colored border.\n */\n @property() variant: LabelVariant = 'filled';\n\n /**\n * Changes the color of the label\n */\n @property() color: LabelColor = 'grey';\n\n /** Shorthand for the `icon` slot, the value is icon name */\n @property() icon?: string;\n\n /** Flag indicating the label is compact */\n @property({ type: Boolean }) compact = false;\n\n /** Flag indicating the label text should be truncated */\n @property({ type: Boolean }) truncated = false;\n\n /** Flag indicating the label is removable */\n @property({ type: Boolean }) removable = false;\n\n /** Text label for a removable label's close button */\n @property({ attribute: 'close-button-label' }) closeButtonLabel?: string;\n\n override render() {\n const { compact, truncated } = this;\n return html`\n <span id=\"pf-container\" class=\"${classMap({ compact, truncated })}\">${super.render()}</span>\n `;\n }\n\n protected override renderDefaultIcon() {\n return !this.icon ? '' : html`\n <pf-icon icon=\"${this.icon}\" size=\"sm\"></pf-icon>\n `;\n }\n\n protected override renderSuffix() {\n return !this.removable ? '' : html`\n <span part=\"close-button\" ?hidden=${!this.removable}>\n <pf-button plain\n @click=\"${() => this.dispatchEvent(new ComposedEvent('close'))}\"\n label=\"${this.closeButtonLabel ?? 'remove'}\">\n <svg viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"/>\n </svg>\n </pf-button>\n </span>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-label': PfLabel;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { test } from '@playwright/test';
|
|
2
|
+
import { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js';
|
|
3
|
+
const tagName = 'pf-label';
|
|
4
|
+
test.describe(tagName, () => {
|
|
5
|
+
test('snapshot', async ({ page }) => {
|
|
6
|
+
const componentPage = new PfeDemoPage(page, tagName);
|
|
7
|
+
await componentPage.navigate();
|
|
8
|
+
await componentPage.snapshot();
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=pf-label.e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pf-label.e2e.js","sourceRoot":"","sources":["pf-label.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAEnF,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAClC,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;QAC/B,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { test } from '@playwright/test';\nimport { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js';\n\nconst tagName = 'pf-label';\n\ntest.describe(tagName, () => {\n test('snapshot', async ({ page }) => {\n const componentPage = new PfeDemoPage(page, tagName);\n await componentPage.navigate();\n await componentPage.snapshot();\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@patternfly/pfe-tools/test/stub-logger.js';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { expect, html } from '@open-wc/testing';
|
|
2
|
+
import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js';
|
|
3
|
+
import { getColor, hexToRgb } from '@patternfly/pfe-tools/test/hex-to-rgb.js';
|
|
4
|
+
import { PfLabel } from '@patternfly/elements/pf-label/pf-label.js';
|
|
5
|
+
import { PfIcon } from '@patternfly/elements/pf-icon/pf-icon.js';
|
|
6
|
+
import '@patternfly/pfe-tools/test/stub-logger.js';
|
|
7
|
+
const example = html `
|
|
8
|
+
<pf-label>Default</pf-label>
|
|
9
|
+
`;
|
|
10
|
+
const exampleWithColorAttribute = html `
|
|
11
|
+
<pf-label color="red">Red</pf-label>
|
|
12
|
+
`;
|
|
13
|
+
const exampleWithColorAttributeEmpty = html `
|
|
14
|
+
<pf-label color="">Default</pf-label>
|
|
15
|
+
`;
|
|
16
|
+
const exampleWithOutlineAttribute = html `
|
|
17
|
+
<pf-label variant="outline">Default Outline</pf-label>
|
|
18
|
+
`;
|
|
19
|
+
const exampleWithIconAttribute = html `
|
|
20
|
+
<pf-label icon="rh-icon-virtual-storage-stack">Default Icon</pf-label>
|
|
21
|
+
`;
|
|
22
|
+
const exampleWithIconAttributeEmpty = html `
|
|
23
|
+
<pf-label icon="">Default</pf-label>
|
|
24
|
+
`;
|
|
25
|
+
const exampleWithCompactAttribute = html `
|
|
26
|
+
<pf-label compact>Default Compact</pf-label>
|
|
27
|
+
`;
|
|
28
|
+
describe('<pf-label>', function () {
|
|
29
|
+
before(function () {
|
|
30
|
+
// replace the default built-in icon set resolveIconName function
|
|
31
|
+
// with one that loads local icons. we don't want tests dependent on
|
|
32
|
+
// prod servers.
|
|
33
|
+
PfIcon.addIconSet('rh', function (name) {
|
|
34
|
+
return new URL(`/elements/pf-icon/test/${name.replace('rh', 'rh-icon')}.svg`);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it('imperatively instantiates', function () {
|
|
38
|
+
expect(document.createElement('pf-label')).to.be.an.instanceof(PfLabel);
|
|
39
|
+
});
|
|
40
|
+
it('should upgrade', async function () {
|
|
41
|
+
const el = await createFixture(example);
|
|
42
|
+
const klass = customElements.get('pf-label');
|
|
43
|
+
expect(el)
|
|
44
|
+
.to.be.an.instanceOf(klass)
|
|
45
|
+
.and
|
|
46
|
+
.to.be.an.instanceOf(PfLabel);
|
|
47
|
+
});
|
|
48
|
+
it('should display default variant', async function () {
|
|
49
|
+
const el = await createFixture(example);
|
|
50
|
+
await el.updateComplete;
|
|
51
|
+
const container = el.shadowRoot.querySelector('#container');
|
|
52
|
+
const beforeStyles = getComputedStyle(container, '::before');
|
|
53
|
+
expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));
|
|
54
|
+
expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));
|
|
55
|
+
expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');
|
|
56
|
+
});
|
|
57
|
+
it('should display color variant if color attribute is present', async function () {
|
|
58
|
+
const el = await createFixture(exampleWithColorAttribute);
|
|
59
|
+
await el.updateComplete;
|
|
60
|
+
const container = el.shadowRoot.querySelector('#container');
|
|
61
|
+
const beforeStyles = getComputedStyle(container, '::before');
|
|
62
|
+
expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#7d1007'));
|
|
63
|
+
expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#faeae8'));
|
|
64
|
+
expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(201, 25, 11)');
|
|
65
|
+
});
|
|
66
|
+
it('should display default variant if color attribute is present but empty', async function () {
|
|
67
|
+
const el = await createFixture(exampleWithColorAttributeEmpty);
|
|
68
|
+
await el.updateComplete;
|
|
69
|
+
const container = el.shadowRoot.querySelector('#container');
|
|
70
|
+
const beforeStyles = getComputedStyle(container, '::before');
|
|
71
|
+
expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));
|
|
72
|
+
expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));
|
|
73
|
+
expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');
|
|
74
|
+
});
|
|
75
|
+
it('should display outline variant if the attribute outline is present', async function () {
|
|
76
|
+
const el = await createFixture(exampleWithOutlineAttribute);
|
|
77
|
+
await el.updateComplete;
|
|
78
|
+
const container = el.shadowRoot.querySelector('#container');
|
|
79
|
+
const beforeStyles = getComputedStyle(container, '::before');
|
|
80
|
+
expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));
|
|
81
|
+
expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#ffffff'));
|
|
82
|
+
expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');
|
|
83
|
+
});
|
|
84
|
+
it('should render a pf-icon if the icon attribute is present and valid', async function () {
|
|
85
|
+
const el = await createFixture(exampleWithIconAttribute);
|
|
86
|
+
await el.updateComplete;
|
|
87
|
+
const icon = el.shadowRoot.querySelector('pf-icon');
|
|
88
|
+
expect(icon.icon).to.equal(el.icon);
|
|
89
|
+
});
|
|
90
|
+
it('should not render a pf-icon if the icon attribute is present but empty', async function () {
|
|
91
|
+
const el = await createFixture(exampleWithIconAttributeEmpty);
|
|
92
|
+
await el.updateComplete;
|
|
93
|
+
const icon = el.shadowRoot.querySelector('pf-icon');
|
|
94
|
+
expect(icon).to.be.equal(null);
|
|
95
|
+
});
|
|
96
|
+
it('should display compact version if the attribute is-compact is present', async function () {
|
|
97
|
+
const el = await createFixture(exampleWithCompactAttribute);
|
|
98
|
+
await el.updateComplete;
|
|
99
|
+
const container = el.shadowRoot.querySelector('#container');
|
|
100
|
+
const beforeStyles = getComputedStyle(container, '::before');
|
|
101
|
+
const containerStyles = getComputedStyle(container);
|
|
102
|
+
expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));
|
|
103
|
+
expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));
|
|
104
|
+
expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');
|
|
105
|
+
expect(containerStyles.getPropertyValue('padding-top')).to.equal('0px');
|
|
106
|
+
expect(containerStyles.getPropertyValue('padding-right')).to.equal('8px'); // 0.5rem = 8px @ 16px browser default
|
|
107
|
+
expect(containerStyles.getPropertyValue('padding-bottom')).to.equal('0px');
|
|
108
|
+
expect(containerStyles.getPropertyValue('padding-left')).to.equal('8px'); // 0.5rem = 8px @ 16px browser default
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=pf-label.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pf-label.spec.js","sourceRoot":"","sources":["pf-label.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AAEjE,OAAO,2CAA2C,CAAC;AAEnD,MAAM,OAAO,GAAG,IAAI,CAAA;;CAEnB,CAAC;AAEF,MAAM,yBAAyB,GAAG,IAAI,CAAA;;CAErC,CAAC;AAEF,MAAM,8BAA8B,GAAG,IAAI,CAAA;;CAE1C,CAAC;AAEF,MAAM,2BAA2B,GAAG,IAAI,CAAA;;CAEvC,CAAC;AAEF,MAAM,wBAAwB,GAAG,IAAI,CAAA;;CAEpC,CAAC;AAEF,MAAM,6BAA6B,GAAG,IAAI,CAAA;;CAEzC,CAAC;AAEF,MAAM,2BAA2B,GAAG,IAAI,CAAA;;CAEvC,CAAC;AAGF,QAAQ,CAAC,YAAY,EAAE;IACrB,MAAM,CAAC;QACL,iEAAiE;QACjE,qEAAqE;QACrE,gBAAgB;QAChB,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,UAAS,IAAY;YAC3C,OAAO,IAAI,GAAG,CAAC,0BAA0B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE;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eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,sCAAsC;QACjH,MAAM,CAAC,eAAe,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3E,MAAM,CAAC,eAAe,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,sCAAsC;IAClH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, html } from '@open-wc/testing';\nimport { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js';\nimport { getColor, hexToRgb } from '@patternfly/pfe-tools/test/hex-to-rgb.js';\nimport { PfLabel } from '@patternfly/elements/pf-label/pf-label.js';\nimport { PfIcon } from '@patternfly/elements/pf-icon/pf-icon.js';\n\nimport '@patternfly/pfe-tools/test/stub-logger.js';\n\nconst example = html`\n <pf-label>Default</pf-label>\n`;\n\nconst exampleWithColorAttribute = html`\n <pf-label color=\"red\">Red</pf-label>\n`;\n\nconst exampleWithColorAttributeEmpty = html`\n <pf-label color=\"\">Default</pf-label>\n`;\n\nconst exampleWithOutlineAttribute = html`\n <pf-label variant=\"outline\">Default Outline</pf-label>\n`;\n\nconst exampleWithIconAttribute = html`\n <pf-label icon=\"rh-icon-virtual-storage-stack\">Default Icon</pf-label>\n`;\n\nconst exampleWithIconAttributeEmpty = html`\n <pf-label icon=\"\">Default</pf-label>\n`;\n\nconst exampleWithCompactAttribute = html`\n <pf-label compact>Default Compact</pf-label>\n`;\n\n\ndescribe('<pf-label>', function() {\n before(function() {\n // replace the default built-in icon set resolveIconName function\n // with one that loads local icons. we don't want tests dependent on\n // prod servers.\n PfIcon.addIconSet('rh', function(name: string) {\n return new URL(`/elements/pf-icon/test/${name.replace('rh', 'rh-icon')}.svg`);\n });\n });\n\n it('imperatively instantiates', function() {\n expect(document.createElement('pf-label')).to.be.an.instanceof(PfLabel);\n });\n\n it('should upgrade', async function() {\n const el = await createFixture<PfLabel>(example);\n const klass = customElements.get('pf-label');\n expect(el)\n .to.be.an.instanceOf(klass)\n .and\n .to.be.an.instanceOf(PfLabel);\n });\n\n it('should display default variant', async function() {\n const el = await createFixture<PfLabel>(example);\n await el.updateComplete;\n const container = el.shadowRoot!.querySelector('#container')!;\n const beforeStyles = getComputedStyle(container, '::before');\n\n expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));\n expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));\n expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');\n });\n\n it('should display color variant if color attribute is present', async function() {\n const el = await createFixture<PfLabel>(exampleWithColorAttribute);\n await el.updateComplete;\n const container = el.shadowRoot!.querySelector('#container')!;\n const beforeStyles = getComputedStyle(container, '::before');\n\n expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#7d1007'));\n expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#faeae8'));\n expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(201, 25, 11)');\n });\n\n it('should display default variant if color attribute is present but empty', async function() {\n const el = await createFixture<PfLabel>( exampleWithColorAttributeEmpty);\n await el.updateComplete;\n const container = el.shadowRoot!.querySelector('#container')!;\n const beforeStyles = getComputedStyle(container, '::before');\n\n expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));\n expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));\n expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');\n });\n\n it('should display outline variant if the attribute outline is present', async function() {\n const el = await createFixture<PfLabel>(exampleWithOutlineAttribute);\n await el.updateComplete;\n const container = el.shadowRoot!.querySelector('#container')!;\n const beforeStyles = getComputedStyle(container, '::before');\n\n expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));\n expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#ffffff'));\n expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');\n });\n\n it('should render a pf-icon if the icon attribute is present and valid', async function() {\n const el = await createFixture<PfLabel>(exampleWithIconAttribute);\n await el.updateComplete;\n const icon = el.shadowRoot!.querySelector('pf-icon')!;\n expect(icon.icon).to.equal(el.icon);\n });\n\n it('should not render a pf-icon if the icon attribute is present but empty', async function() {\n const el = await createFixture<PfLabel>(exampleWithIconAttributeEmpty);\n await el.updateComplete;\n const icon = el.shadowRoot!.querySelector('pf-icon')!;\n expect(icon).to.be.equal(null);\n });\n\n it('should display compact version if the attribute is-compact is present', async function() {\n const el = await createFixture<PfLabel>(exampleWithCompactAttribute);\n await el.updateComplete;\n const container = el.shadowRoot!.querySelector('#container')!;\n const beforeStyles = getComputedStyle(container, '::before');\n const containerStyles = getComputedStyle(container);\n\n expect(getColor(container, 'color')).to.deep.equal(hexToRgb('#151515'));\n expect(getColor(container, 'background-color')).to.deep.equal(hexToRgb('#f5f5f5'));\n expect(beforeStyles.getPropertyValue('border-color')).to.equal('rgb(210, 210, 210)');\n\n expect(containerStyles.getPropertyValue('padding-top')).to.equal('0px');\n expect(containerStyles.getPropertyValue('padding-right')).to.equal('8px'); // 0.5rem = 8px @ 16px browser default\n expect(containerStyles.getPropertyValue('padding-bottom')).to.equal('0px');\n expect(containerStyles.getPropertyValue('padding-left')).to.equal('8px'); // 0.5rem = 8px @ 16px browser default\n });\n});\n"]}
|
package/pf-modal/pf-modal.d.ts
CHANGED
|
@@ -16,16 +16,12 @@ export declare class ModalOpenEvent extends ComposedEvent {
|
|
|
16
16
|
/**
|
|
17
17
|
* A **modal** displays important information to a user without requiring them to navigate
|
|
18
18
|
* to a new page.
|
|
19
|
-
*
|
|
20
19
|
* @summary Displays information or helps a user focus on a task
|
|
21
|
-
*
|
|
22
20
|
* @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.
|
|
23
21
|
* @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).
|
|
24
22
|
* @slot footer - Optional footer content. Good place to put action buttons.
|
|
25
|
-
*
|
|
26
23
|
* @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.
|
|
27
24
|
* @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.
|
|
28
|
-
*
|
|
29
25
|
* @csspart overlay - The modal overlay which lies under the dialog and above the page body
|
|
30
26
|
* @csspart dialog - The dialog element
|
|
31
27
|
* @csspart content - The container for the dialog content
|
|
@@ -33,7 +29,6 @@ export declare class ModalOpenEvent extends ComposedEvent {
|
|
|
33
29
|
* @csspart description - The container for the optional dialog description in the header
|
|
34
30
|
* @csspart close-button - The modal's close button
|
|
35
31
|
* @csspart footer - Actions footer container
|
|
36
|
-
*
|
|
37
32
|
* @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}
|
|
38
33
|
* @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}
|
|
39
34
|
* @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}
|
|
@@ -79,7 +74,7 @@ export declare class PfModal extends LitElement implements HTMLDialogElement {
|
|
|
79
74
|
private dialog?;
|
|
80
75
|
private closeButton?;
|
|
81
76
|
connectedCallback(): void;
|
|
82
|
-
render(): import("lit").TemplateResult<1>;
|
|
77
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
83
78
|
disconnectedCallback(): void;
|
|
84
79
|
protected _init(): Promise<void>;
|
|
85
80
|
protected _openChanged(oldValue?: boolean, newValue?: boolean): Promise<void>;
|
package/pf-modal/pf-modal.js
CHANGED
|
@@ -34,16 +34,12 @@ export class ModalOpenEvent extends ComposedEvent {
|
|
|
34
34
|
/**
|
|
35
35
|
* A **modal** displays important information to a user without requiring them to navigate
|
|
36
36
|
* to a new page.
|
|
37
|
-
*
|
|
38
37
|
* @summary Displays information or helps a user focus on a task
|
|
39
|
-
*
|
|
40
38
|
* @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.
|
|
41
39
|
* @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).
|
|
42
40
|
* @slot footer - Optional footer content. Good place to put action buttons.
|
|
43
|
-
*
|
|
44
41
|
* @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.
|
|
45
42
|
* @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.
|
|
46
|
-
*
|
|
47
43
|
* @csspart overlay - The modal overlay which lies under the dialog and above the page body
|
|
48
44
|
* @csspart dialog - The dialog element
|
|
49
45
|
* @csspart content - The container for the dialog content
|
|
@@ -51,7 +47,6 @@ export class ModalOpenEvent extends ComposedEvent {
|
|
|
51
47
|
* @csspart description - The container for the optional dialog description in the header
|
|
52
48
|
* @csspart close-button - The modal's close button
|
|
53
49
|
* @csspart footer - Actions footer container
|
|
54
|
-
*
|
|
55
50
|
* @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}
|
|
56
51
|
* @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}
|
|
57
52
|
* @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}
|
|
@@ -177,7 +172,8 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
177
172
|
}
|
|
178
173
|
_triggerChanged() {
|
|
179
174
|
if (this.trigger) {
|
|
180
|
-
__classPrivateFieldSet(this, _PfModal_triggerElement, this.getRootNode()
|
|
175
|
+
__classPrivateFieldSet(this, _PfModal_triggerElement, this.getRootNode()
|
|
176
|
+
.getElementById(this.trigger), "f");
|
|
181
177
|
__classPrivateFieldGet(this, _PfModal_triggerElement, "f")?.addEventListener('click', this.onTriggerClick);
|
|
182
178
|
}
|
|
183
179
|
}
|
|
@@ -191,7 +187,6 @@ let PfModal = PfModal_1 = class PfModal extends LitElement {
|
|
|
191
187
|
if (open) {
|
|
192
188
|
const path = event.composedPath();
|
|
193
189
|
const { closeOnOutsideClick } = this.constructor;
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
195
190
|
if (closeOnOutsideClick && path.includes(overlay) && !path.includes(dialog)) {
|
|
196
191
|
event.preventDefault();
|
|
197
192
|
this.cancel();
|
|
@@ -271,7 +266,10 @@ _PfModal_body = new WeakMap();
|
|
|
271
266
|
_PfModal_headings = new WeakMap();
|
|
272
267
|
_PfModal_cancelling = new WeakMap();
|
|
273
268
|
_PfModal_slots = new WeakMap();
|
|
274
|
-
PfModal.shadowRootOptions = {
|
|
269
|
+
PfModal.shadowRootOptions = {
|
|
270
|
+
...LitElement.shadowRootOptions,
|
|
271
|
+
delegatesFocus: true,
|
|
272
|
+
};
|
|
275
273
|
PfModal.styles = [style];
|
|
276
274
|
/** Should the dialog close when user clicks outside the dialog? */
|
|
277
275
|
PfModal.closeOnOutsideClick = false;
|
package/pf-modal/pf-modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pf-modal.js","sourceRoot":"","sources":["pf-modal.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,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C,UAAU,CAAC;GACb,OAAO,CAqPnB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\nimport { bound, initializer, observed } from '@patternfly/pfe-core/decorators.js';\nimport { getRandomId } from '@patternfly/pfe-core/functions/random.js';\n\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\n\nimport style from './pf-modal.css';\n\nexport class ModalCancelEvent extends ComposedEvent {\n constructor() {\n super('cancel');\n }\n}\n\nexport class ModalCloseEvent extends ComposedEvent {\n constructor() {\n super('close');\n }\n}\n\nexport class ModalOpenEvent extends ComposedEvent {\n constructor(\n /** The trigger element which triggered the modal to open */\n public trigger: HTMLElement | null\n ) {\n super('open');\n }\n}\n\n/**\n * A **modal** displays important information to a user without requiring them to navigate\n * to a new page.\n *\n * @summary Displays information or helps a user focus on a task\n *\n * @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.\n * @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).\n * @slot footer - Optional footer content. Good place to put action buttons.\n *\n * @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.\n * @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.\n *\n * @csspart overlay - The modal overlay which lies under the dialog and above the page body\n * @csspart dialog - The dialog element\n * @csspart content - The container for the dialog content\n * @csspart header - The container for the optional dialog header\n * @csspart description - The container for the optional dialog description in the header\n * @csspart close-button - The modal's close button\n * @csspart footer - Actions footer container\n *\n * @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}\n * @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--m-sm--sm--MaxWidth - Max width of the small variant modal {@default 35rem}\n * @cssprop {<length>} --pf-c-modal-box--m-md--MaxWidth - Max width of the small variant modal {@default 52.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-lg--lg--MaxWidth - Max width of the large variant modal {@default 70rem}\n * @cssprop {<length>} --pf-c-modal-box--MaxHeight - Max height of the modal {@default calc(100% - 3rem)}\n * @cssprop {<length>} --pf-c-modal-box--BoxShadow - {@default var(--pf-global--BoxShadow--xl)}\n * @cssprop {<length>} --pf-c-modal-box__title--FontSize - {@default 1.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MarginTop - {@default 2rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxWidth\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxHeight\n * @cssprop {<color>} --pf-c-modal-box--BackgroundColor - {@default #fff}\n * @cssprop --pf-c-modal-box__title--FontFamily - default font family for header-slotted headings\n */\n@customElement('pf-modal')\nexport class PfModal extends LitElement implements HTMLDialogElement {\n static readonly shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static readonly styles = [style];\n\n /** Should the dialog close when user clicks outside the dialog? */\n protected static closeOnOutsideClick = false;\n\n /**\n * The `variant` controls the width of the modal.\n * There are three options: `small`, `medium` and `large`. The default is `large`.\n */\n @property({ reflect: true }) variant?: 'small' | 'medium' | 'large';\n\n /**\n * `position=\"top\"` aligns the dialog with the top of the page\n */\n @property({ reflect: true }) position?: 'top';\n\n @observed\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\n @observed\n @property() trigger?: string;\n\n /** @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue */\n public returnValue = '';\n\n @query('#overlay') private overlay?: HTMLElement | null;\n @query('#dialog') private dialog?: HTMLElement | null;\n @query('#close-button') private closeButton?: HTMLElement | null;\n\n #headerId = getRandomId();\n #triggerElement: HTMLElement | null = null;\n #header: HTMLElement | null = null;\n #body: Element[] = [];\n #headings: Element[] = [];\n #cancelling = false;\n\n #slots = new SlotController(this, null, 'header', 'description', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render() {\n const headerId = (this.#header || this.#headings.length) ? this.#headerId : undefined;\n const headerLabel = this.#triggerElement ? this.#triggerElement.innerText : undefined;\n const hasHeader = this.#slots.hasSlotted('header');\n const hasDescription = this.#slots.hasSlotted('description');\n const hasFooter = this.#slots.hasSlotted('footer');\n\n return html`\n <section ?hidden=${!this.open}>\n <div id=\"overlay\" part=\"overlay\" ?hidden=${!this.open}></div>\n <div id=\"dialog\"\n part=\"dialog\"\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=${ifDefined(headerId)}\n aria-label=${ifDefined(headerLabel)}\n ?hidden=\"${!this.open}\">\n <div id=\"container\">\n <div id=\"content\" part=\"content\" class=${classMap({ hasHeader, hasDescription, hasFooter })}>\n <header part=\"header\">\n <slot name=\"header\"></slot>\n <div part=\"description\" ?hidden=${!hasDescription}>\n <slot name=\"description\"></slot>\n </div>\n </header>\n <slot></slot>\n <footer ?hidden=${!hasFooter} part=\"footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n <button id=\"close-button\"\n part=\"close-button\"\n aria-label=\"Close dialog\"\n @keydown=${this.onKeydown}\n @click=${this.close}>\n <svg fill=\"currentColor\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"></path>\n </svg>\n </button>\n </div>\n </div>\n </section>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n this.removeEventListener('keydown', this.onKeydown);\n\n this.#triggerElement?.removeEventListener('click', this.onTriggerClick);\n }\n\n @initializer()\n protected async _init() {\n await this.updateComplete;\n this.#header = this.querySelector(`[slot$=\"header\"]`);\n this.#body = [...this.querySelectorAll(`*:not([slot])`)];\n this.#headings = this.#body.filter(el => el.tagName.slice(0, 1) === 'H');\n\n if (this.#triggerElement) {\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n this.removeAttribute('hidden');\n }\n\n if (this.#header) {\n this.#header.id = this.#headerId;\n } else if (this.#headings.length > 0) {\n // Get the first heading in the modal if it exists\n this.#headings[0].id = this.#headerId;\n }\n }\n\n protected async _openChanged(oldValue?: boolean, newValue?: boolean) {\n // loosening types to prevent running these effects in unexpected circumstances\n // eslint-disable-next-line eqeqeq\n if (oldValue == null || newValue == null || oldValue == newValue) {\n return;\n } else if (this.open) {\n // This prevents background scroll\n document.body.style.overflow = 'hidden';\n await this.updateComplete;\n // Set the focus to the container\n this.dialog?.focus();\n this.dispatchEvent(new ModalOpenEvent(this.#triggerElement));\n } else {\n // Return scrollability\n document.body.style.overflow = 'auto';\n\n await this.updateComplete;\n\n if (this.#triggerElement) {\n this.#triggerElement.focus();\n }\n\n this.dispatchEvent(this.#cancelling ? new ModalCancelEvent() : new ModalCloseEvent());\n }\n }\n\n protected _triggerChanged() {\n if (this.trigger) {\n this.#triggerElement = (this.getRootNode() as Document | ShadowRoot).getElementById(this.trigger);\n this.#triggerElement?.addEventListener('click', this.onTriggerClick);\n }\n }\n\n @bound private onTriggerClick(event: MouseEvent) {\n event.preventDefault();\n // TODO: in non-modal case, toggle the dialog\n this.showModal();\n }\n\n @bound private onClick(event: MouseEvent) {\n const { open, overlay, dialog } = this;\n if (open) {\n const path = event.composedPath();\n const { closeOnOutsideClick } = this.constructor as typeof PfModal;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (closeOnOutsideClick && path.includes(overlay!) && !path.includes(dialog!)) {\n event.preventDefault();\n this.cancel();\n }\n }\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Tab':\n if (event.target === this.closeButton) {\n event.preventDefault();\n this.dialog?.focus();\n }\n return;\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.cancel();\n return;\n case 'Enter':\n if (event.target === this.#triggerElement) {\n event.preventDefault();\n this.showModal();\n }\n return;\n }\n }\n\n private async cancel() {\n this.#cancelling = true;\n this.open = false;\n await this.updateComplete;\n this.#cancelling = false;\n }\n\n setTrigger(element: HTMLElement) {\n this.#triggerElement = element;\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n }\n\n /**\n * Manually toggles the modal.\n * ```js\n * modal.toggle();\n * ```\n */\n @bound toggle() {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show() {\n this.open = true;\n }\n\n @bound showModal() {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n */\n @bound close(returnValue?: string) {\n if (typeof returnValue === 'string') {\n this.returnValue = returnValue;\n }\n\n this.open = false;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-modal': PfModal;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pf-modal.js","sourceRoot":"","sources":["pf-modal.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD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,EAAE;oCAkBb;AAoCc;IAAd,KAAK;6CAIL;AAEc;IAAd,KAAK;sCAWL;AAEc;IAAd,KAAK;wCAoBL;AAoBM;IAAN,KAAK;qCAEL;AAQM;IAAN,KAAK;mCAEL;AAEM;IAAN,KAAK;wCAGL;AAQM;IAAN,KAAK;oCAML;AAxPU,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAyPnB","sourcesContent":["import { LitElement, html } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { property } from 'lit/decorators/property.js';\nimport { query } from 'lit/decorators/query.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { classMap } from 'lit/directives/class-map.js';\n\nimport { ComposedEvent } from '@patternfly/pfe-core';\nimport { bound, initializer, observed } from '@patternfly/pfe-core/decorators.js';\nimport { getRandomId } from '@patternfly/pfe-core/functions/random.js';\n\nimport { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';\n\nimport style from './pf-modal.css';\n\nexport class ModalCancelEvent extends ComposedEvent {\n constructor() {\n super('cancel');\n }\n}\n\nexport class ModalCloseEvent extends ComposedEvent {\n constructor() {\n super('close');\n }\n}\n\nexport class ModalOpenEvent extends ComposedEvent {\n constructor(\n /** The trigger element which triggered the modal to open */\n public trigger: HTMLElement | null\n ) {\n super('open');\n }\n}\n\n/**\n * A **modal** displays important information to a user without requiring them to navigate\n * to a new page.\n * @summary Displays information or helps a user focus on a task\n * @slot - The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header.\n * @slot header - The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6).\n * @slot footer - Optional footer content. Good place to put action buttons.\n * @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.\n * @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.\n * @csspart overlay - The modal overlay which lies under the dialog and above the page body\n * @csspart dialog - The dialog element\n * @csspart content - The container for the dialog content\n * @csspart header - The container for the optional dialog header\n * @csspart description - The container for the optional dialog description in the header\n * @csspart close-button - The modal's close button\n * @csspart footer - Actions footer container\n * @cssprop {<length>} --pf-c-modal-box--ZIndex {@default 500}\n * @cssprop {<length>} --pf-c-modal-box--Width - Width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--MaxWidth - Max width of the modal {@default calc(100% - 2rem)}\n * @cssprop {<length>} --pf-c-modal-box--m-sm--sm--MaxWidth - Max width of the small variant modal {@default 35rem}\n * @cssprop {<length>} --pf-c-modal-box--m-md--MaxWidth - Max width of the small variant modal {@default 52.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-lg--lg--MaxWidth - Max width of the large variant modal {@default 70rem}\n * @cssprop {<length>} --pf-c-modal-box--MaxHeight - Max height of the modal {@default calc(100% - 3rem)}\n * @cssprop {<length>} --pf-c-modal-box--BoxShadow - {@default var(--pf-global--BoxShadow--xl)}\n * @cssprop {<length>} --pf-c-modal-box__title--FontSize - {@default 1.5rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MarginTop - {@default 2rem}\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxWidth\n * @cssprop {<length>} --pf-c-modal-box--m-align-top--MaxHeight\n * @cssprop {<color>} --pf-c-modal-box--BackgroundColor - {@default #fff}\n * @cssprop --pf-c-modal-box__title--FontFamily - default font family for header-slotted headings\n */\n@customElement('pf-modal')\nexport class PfModal extends LitElement implements HTMLDialogElement {\n static override readonly shadowRootOptions = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static readonly styles = [style];\n\n /** Should the dialog close when user clicks outside the dialog? */\n protected static closeOnOutsideClick = false;\n\n /**\n * The `variant` controls the width of the modal.\n * There are three options: `small`, `medium` and `large`. The default is `large`.\n */\n @property({ reflect: true }) variant?: 'small' | 'medium' | 'large';\n\n /**\n * `position=\"top\"` aligns the dialog with the top of the page\n */\n @property({ reflect: true }) position?: 'top';\n\n @observed\n @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\n @observed\n @property() trigger?: string;\n\n /** @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue */\n public returnValue = '';\n\n @query('#overlay') private overlay?: HTMLElement | null;\n @query('#dialog') private dialog?: HTMLElement | null;\n @query('#close-button') private closeButton?: HTMLElement | null;\n\n #headerId = getRandomId();\n #triggerElement: HTMLElement | null = null;\n #header: HTMLElement | null = null;\n #body: Element[] = [];\n #headings: Element[] = [];\n #cancelling = false;\n\n #slots = new SlotController(this, null, 'header', 'description', 'footer');\n\n connectedCallback() {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render() {\n const headerId = (this.#header || this.#headings.length) ? this.#headerId : undefined;\n const headerLabel = this.#triggerElement ? this.#triggerElement.innerText : undefined;\n const hasHeader = this.#slots.hasSlotted('header');\n const hasDescription = this.#slots.hasSlotted('description');\n const hasFooter = this.#slots.hasSlotted('footer');\n\n return html`\n <section ?hidden=${!this.open}>\n <div id=\"overlay\" part=\"overlay\" ?hidden=${!this.open}></div>\n <div id=\"dialog\"\n part=\"dialog\"\n tabindex=\"0\"\n role=\"dialog\"\n aria-labelledby=${ifDefined(headerId)}\n aria-label=${ifDefined(headerLabel)}\n ?hidden=\"${!this.open}\">\n <div id=\"container\">\n <div id=\"content\" part=\"content\" class=${classMap({ hasHeader, hasDescription, hasFooter })}>\n <header part=\"header\">\n <slot name=\"header\"></slot>\n <div part=\"description\" ?hidden=${!hasDescription}>\n <slot name=\"description\"></slot>\n </div>\n </header>\n <slot></slot>\n <footer ?hidden=${!hasFooter} part=\"footer\">\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n <button id=\"close-button\"\n part=\"close-button\"\n aria-label=\"Close dialog\"\n @keydown=${this.onKeydown}\n @click=${this.close}>\n <svg fill=\"currentColor\" viewBox=\"0 0 352 512\">\n <path d=\"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z\"></path>\n </svg>\n </button>\n </div>\n </div>\n </section>\n `;\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n this.removeEventListener('keydown', this.onKeydown);\n\n this.#triggerElement?.removeEventListener('click', this.onTriggerClick);\n }\n\n @initializer()\n protected async _init() {\n await this.updateComplete;\n this.#header = this.querySelector(`[slot$=\"header\"]`);\n this.#body = [...this.querySelectorAll(`*:not([slot])`)];\n this.#headings = this.#body.filter(el => el.tagName.slice(0, 1) === 'H');\n\n if (this.#triggerElement) {\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n this.removeAttribute('hidden');\n }\n\n if (this.#header) {\n this.#header.id = this.#headerId;\n } else if (this.#headings.length > 0) {\n // Get the first heading in the modal if it exists\n this.#headings[0].id = this.#headerId;\n }\n }\n\n protected async _openChanged(oldValue?: boolean, newValue?: boolean) {\n // loosening types to prevent running these effects in unexpected circumstances\n // eslint-disable-next-line eqeqeq\n if (oldValue == null || newValue == null || oldValue == newValue) {\n return;\n } else if (this.open) {\n // This prevents background scroll\n document.body.style.overflow = 'hidden';\n await this.updateComplete;\n // Set the focus to the container\n this.dialog?.focus();\n this.dispatchEvent(new ModalOpenEvent(this.#triggerElement));\n } else {\n // Return scrollability\n document.body.style.overflow = 'auto';\n\n await this.updateComplete;\n\n if (this.#triggerElement) {\n this.#triggerElement.focus();\n }\n\n this.dispatchEvent(this.#cancelling ? new ModalCancelEvent() : new ModalCloseEvent());\n }\n }\n\n protected _triggerChanged() {\n if (this.trigger) {\n this.#triggerElement = (this.getRootNode() as Document | ShadowRoot)\n .getElementById(this.trigger);\n this.#triggerElement?.addEventListener('click', this.onTriggerClick);\n }\n }\n\n @bound private onTriggerClick(event: MouseEvent) {\n event.preventDefault();\n // TODO: in non-modal case, toggle the dialog\n this.showModal();\n }\n\n @bound private onClick(event: MouseEvent) {\n const { open, overlay, dialog } = this;\n if (open) {\n const path = event.composedPath();\n const { closeOnOutsideClick } = this.constructor as typeof PfModal;\n\n if (closeOnOutsideClick && path.includes(overlay!) && !path.includes(dialog!)) {\n event.preventDefault();\n this.cancel();\n }\n }\n }\n\n @bound private onKeydown(event: KeyboardEvent) {\n switch (event.key) {\n case 'Tab':\n if (event.target === this.closeButton) {\n event.preventDefault();\n this.dialog?.focus();\n }\n return;\n case 'Escape':\n case 'Esc':\n event.preventDefault();\n this.cancel();\n return;\n case 'Enter':\n if (event.target === this.#triggerElement) {\n event.preventDefault();\n this.showModal();\n }\n return;\n }\n }\n\n private async cancel() {\n this.#cancelling = true;\n this.open = false;\n await this.updateComplete;\n this.#cancelling = false;\n }\n\n setTrigger(element: HTMLElement) {\n this.#triggerElement = element;\n this.#triggerElement.addEventListener('click', this.onTriggerClick);\n }\n\n /**\n * Manually toggles the modal.\n * ```js\n * modal.toggle();\n * ```\n */\n @bound toggle() {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show() {\n this.open = true;\n }\n\n @bound showModal() {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n */\n @bound close(returnValue?: string) {\n if (typeof returnValue === 'string') {\n this.returnValue = returnValue;\n }\n\n this.open = false;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'pf-modal': PfModal;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { test } from '@playwright/test';
|
|
2
|
+
import { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js';
|
|
3
|
+
const tagName = 'pf-modal';
|
|
4
|
+
test.describe(tagName, () => {
|
|
5
|
+
test('snapshot', async ({ page }) => {
|
|
6
|
+
const componentPage = new PfeDemoPage(page, tagName);
|
|
7
|
+
await componentPage.navigate();
|
|
8
|
+
await componentPage.click(`${tagName} button`);
|
|
9
|
+
await page.waitForTimeout(100);
|
|
10
|
+
await componentPage.snapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=pf-modal.e2e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pf-modal.e2e.js","sourceRoot":"","sources":["pf-modal.e2e.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAC;AAEnF,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QAClC,MAAM,aAAa,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;QAE/B,MAAM,aAAa,CAAC,KAAK,CAAC,GAAG,OAAO,SAAS,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QAE/B,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { test } from '@playwright/test';\nimport { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js';\n\nconst tagName = 'pf-modal';\n\ntest.describe(tagName, () => {\n test('snapshot', async ({ page }) => {\n const componentPage = new PfeDemoPage(page, tagName);\n await componentPage.navigate();\n\n await componentPage.click(`${tagName} button`);\n await page.waitForTimeout(100);\n\n await componentPage.snapshot();\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@patternfly/pfe-tools/test/stub-logger.js';
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { expect, nextFrame, html } from '@open-wc/testing';
|
|
2
|
+
import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js';
|
|
3
|
+
import { setViewport } from '@web/test-runner-commands';
|
|
4
|
+
import { PfModal } from '@patternfly/elements/pf-modal/pf-modal.js';
|
|
5
|
+
import '@patternfly/pfe-tools/test/stub-logger.js';
|
|
6
|
+
// One element, defined here, is used
|
|
7
|
+
// in multiple tests. It's torn down and recreated each time.
|
|
8
|
+
const TEMPLATES = {
|
|
9
|
+
testElement: html `<pf-modal></pf-modal>`,
|
|
10
|
+
smallModal: html `
|
|
11
|
+
<pf-modal variant="small">
|
|
12
|
+
<h2 slot="header">Small modal</h2>
|
|
13
|
+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
14
|
+
</pf-modal>
|
|
15
|
+
`,
|
|
16
|
+
mediumModal: html `
|
|
17
|
+
<pf-modal variant="medium">
|
|
18
|
+
<h2 slot="header">Medium modal</h2>
|
|
19
|
+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
20
|
+
</pf-modal>
|
|
21
|
+
`,
|
|
22
|
+
largeModal: html `
|
|
23
|
+
<pf-modal variant="large">
|
|
24
|
+
<h2 slot="header">Large modal</h2>
|
|
25
|
+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
26
|
+
</pf-modal>
|
|
27
|
+
`,
|
|
28
|
+
};
|
|
29
|
+
describe('<pf-modal>', function () {
|
|
30
|
+
it('imperatively instantiates', function () {
|
|
31
|
+
expect(document.createElement('pf-modal')).to.be.an.instanceof(PfModal);
|
|
32
|
+
});
|
|
33
|
+
it('should upgrade', async function () {
|
|
34
|
+
const el = await createFixture(TEMPLATES.testElement);
|
|
35
|
+
expect(el, 'pf-modal should be an instance of PfModal')
|
|
36
|
+
.to.be.an.instanceOf(customElements.get('pf-modal'))
|
|
37
|
+
.and
|
|
38
|
+
.to.be.an.instanceOf(PfModal);
|
|
39
|
+
});
|
|
40
|
+
// Example test.
|
|
41
|
+
it('should apply attributes correctly', async function () {
|
|
42
|
+
// Use the same markup that's declared at the top of the file.
|
|
43
|
+
const el = await createFixture(html `
|
|
44
|
+
<pf-modal>
|
|
45
|
+
<h2 slot="header">Modal with a header</h2>
|
|
46
|
+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
47
|
+
</pf-modal>
|
|
48
|
+
`);
|
|
49
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
50
|
+
const button = el.shadowRoot.querySelector('[part=close-button]');
|
|
51
|
+
await nextFrame();
|
|
52
|
+
expect(modalWindow.getAttribute('tabindex'), 'dialog tabindex').to.equal('0');
|
|
53
|
+
expect(modalWindow.hasAttribute('hidden'), 'hidden').to.be.true;
|
|
54
|
+
expect(button.getAttribute('aria-label'), 'button aria-label').to.equal('Close dialog');
|
|
55
|
+
});
|
|
56
|
+
it('should open the modal window when the trigger is clicked', async function () {
|
|
57
|
+
const el = await createFixture(html `
|
|
58
|
+
<pf-modal trigger="trigger">
|
|
59
|
+
<h2 slot="header">Modal with a header</h2>
|
|
60
|
+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
61
|
+
</pf-modal>
|
|
62
|
+
<pf-button id="trigger">Open a modal</pf-button>
|
|
63
|
+
`);
|
|
64
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
65
|
+
const trigger = document.getElementById('trigger');
|
|
66
|
+
trigger.click();
|
|
67
|
+
await el.updateComplete;
|
|
68
|
+
expect(modalWindow.hasAttribute('hidden')).to.not.be.true;
|
|
69
|
+
// reset
|
|
70
|
+
el.close();
|
|
71
|
+
await el.updateComplete;
|
|
72
|
+
expect(modalWindow.hasAttribute('hidden')).to.be.true;
|
|
73
|
+
});
|
|
74
|
+
it('should remove the hidden attribute from the host on upgrade', async function () {
|
|
75
|
+
const el = await createFixture(TEMPLATES.testElement);
|
|
76
|
+
await new Promise(r => setTimeout(r, 25));
|
|
77
|
+
// test for the hidden attribute on the host
|
|
78
|
+
expect(el.hasAttribute('hidden')).to.not.be.true;
|
|
79
|
+
});
|
|
80
|
+
describe('on extra large screen', function () {
|
|
81
|
+
beforeEach(async function () {
|
|
82
|
+
await setViewport({ width: 1600, height: 1200 });
|
|
83
|
+
});
|
|
84
|
+
describe('with variant=small attribute', function () {
|
|
85
|
+
it('has small modal width', async function () {
|
|
86
|
+
const el = await createFixture(TEMPLATES.smallModal);
|
|
87
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
88
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
89
|
+
.to.equal('calc(100% - 32px)');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe('with variant=medium attribute', function () {
|
|
93
|
+
it('has medium modal width', async function () {
|
|
94
|
+
const el = await createFixture(TEMPLATES.mediumModal);
|
|
95
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
96
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
97
|
+
.to.equal('calc(100% - 32px)');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
describe('with variant=large attribute', function () {
|
|
101
|
+
it('has large modal width', async function () {
|
|
102
|
+
const el = await createFixture(TEMPLATES.largeModal);
|
|
103
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
104
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
105
|
+
.to.equal('calc(100% - 32px)');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('on large screen', function () {
|
|
110
|
+
beforeEach(async function () {
|
|
111
|
+
await setViewport({ width: 1000, height: 800 });
|
|
112
|
+
});
|
|
113
|
+
describe('with variant=small attribute', function () {
|
|
114
|
+
it('has small modal width', async function () {
|
|
115
|
+
const el = await createFixture(TEMPLATES.smallModal);
|
|
116
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
117
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
118
|
+
.to.equal('calc(100% - 32px)');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('with variant=medium attribute', function () {
|
|
122
|
+
it('has medium modal width', async function () {
|
|
123
|
+
const el = await createFixture(TEMPLATES.mediumModal);
|
|
124
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
125
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
126
|
+
.to.equal('calc(100% - 32px)');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('with variant=large attribute', function () {
|
|
130
|
+
it('has large modal width', async function () {
|
|
131
|
+
const el = await createFixture(TEMPLATES.largeModal);
|
|
132
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
133
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
134
|
+
.to.equal('calc(100% - 32px)');
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
describe('on medium screen', function () {
|
|
139
|
+
beforeEach(async function () {
|
|
140
|
+
await setViewport({ width: 768, height: 600 });
|
|
141
|
+
});
|
|
142
|
+
describe('with variant=small attribute', function () {
|
|
143
|
+
it('has small modal width', async function () {
|
|
144
|
+
const el = await createFixture(TEMPLATES.smallModal);
|
|
145
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
146
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
147
|
+
.to.equal('calc(100% - 32px)');
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe('with variant=medium attribute', function () {
|
|
151
|
+
it('has medium modal width', async function () {
|
|
152
|
+
const el = await createFixture(TEMPLATES.mediumModal);
|
|
153
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
154
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
155
|
+
.to.equal('calc(100% - 32px)');
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
describe('with variant=large attribute', function () {
|
|
159
|
+
it('has large modal width', async function () {
|
|
160
|
+
const el = await createFixture(TEMPLATES.largeModal);
|
|
161
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
162
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
163
|
+
.to.equal('calc(100% - 32px)');
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
describe('on small screen', function () {
|
|
168
|
+
beforeEach(async function () {
|
|
169
|
+
await setViewport({ width: 480, height: 540 });
|
|
170
|
+
});
|
|
171
|
+
describe('with variant=small attribute', function () {
|
|
172
|
+
it('has small modal width', async function () {
|
|
173
|
+
const el = await createFixture(TEMPLATES.smallModal);
|
|
174
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
175
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
176
|
+
.to.equal('calc(100% - 32px)');
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
describe('with variant=medium attribute', function () {
|
|
180
|
+
it('has medium modal width', async function () {
|
|
181
|
+
const el = await createFixture(TEMPLATES.mediumModal);
|
|
182
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
183
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
184
|
+
.to.equal('calc(100% - 32px)');
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
describe('with variant=large attribute', function () {
|
|
188
|
+
it('has large modal width', async function () {
|
|
189
|
+
const el = await createFixture(TEMPLATES.largeModal);
|
|
190
|
+
const modalWindow = el.shadowRoot.querySelector('#dialog');
|
|
191
|
+
expect(getComputedStyle(modalWindow).getPropertyValue('max-width'))
|
|
192
|
+
.to.equal('calc(100% - 32px)');
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
//# sourceMappingURL=pf-modal.spec.js.map
|