@patternfly/elements 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +13726 -12682
- package/package.json +17 -14
- package/pf-accordion/pf-accordion-header.css +37 -0
- package/pf-accordion/pf-accordion-header.d.ts +0 -61
- package/pf-accordion/pf-accordion-header.js +180 -2
- package/pf-accordion/pf-accordion-header.js.map +1 -1
- package/pf-accordion/pf-accordion-panel.css +12 -0
- package/pf-accordion/pf-accordion-panel.d.ts +0 -34
- package/pf-accordion/pf-accordion-panel.js +87 -2
- package/pf-accordion/pf-accordion-panel.js.map +1 -1
- package/pf-accordion/pf-accordion.css +62 -0
- package/pf-accordion/pf-accordion.d.ts +1 -64
- package/pf-accordion/pf-accordion.js +156 -2
- package/pf-accordion/pf-accordion.js.map +1 -1
- package/pf-avatar/pf-avatar.css +14 -0
- package/pf-avatar/pf-avatar.d.ts +1 -14
- package/pf-avatar/pf-avatar.js +82 -2
- package/pf-avatar/pf-avatar.js.map +1 -1
- package/pf-back-to-top/pf-back-to-top.css +12 -0
- package/pf-back-to-top/pf-back-to-top.d.ts +1 -17
- package/pf-back-to-top/pf-back-to-top.js +87 -3
- package/pf-back-to-top/pf-back-to-top.js.map +1 -1
- package/pf-background-image/pf-background-image.css +7 -0
- package/pf-background-image/pf-background-image.d.ts +1 -8
- package/pf-background-image/pf-background-image.js +76 -2
- package/pf-background-image/pf-background-image.js.map +1 -1
- package/pf-badge/pf-badge.css +13 -0
- package/pf-badge/pf-badge.d.ts +1 -13
- package/pf-badge/pf-badge.js +53 -2
- package/pf-badge/pf-badge.js.map +1 -1
- package/pf-banner/pf-banner.css +21 -0
- package/pf-banner/pf-banner.d.ts +1 -19
- package/pf-banner/pf-banner.js +122 -2
- package/pf-banner/pf-banner.js.map +1 -1
- package/pf-button/pf-button-tokens.css +38 -0
- package/pf-button/pf-button.d.ts +1 -106
- package/pf-button/pf-button.js +837 -4
- package/pf-button/pf-button.js.map +1 -1
- package/pf-card/pf-card.css +24 -0
- package/pf-card/pf-card.d.ts +1 -38
- package/pf-card/pf-card.js +248 -2
- package/pf-card/pf-card.js.map +1 -1
- package/pf-chip/pf-chip-group.css +15 -0
- package/pf-chip/pf-chip-group.d.ts +0 -15
- package/pf-chip/pf-chip-group.js +111 -2
- package/pf-chip/pf-chip-group.js.map +1 -1
- package/pf-chip/pf-chip.css +30 -1
- package/pf-chip/pf-chip.d.ts +1 -20
- package/pf-chip/pf-chip.js +135 -2
- package/pf-chip/pf-chip.js.map +1 -1
- package/pf-clipboard-copy/pf-clipboard-copy.css +25 -0
- package/pf-clipboard-copy/pf-clipboard-copy.d.ts +1 -27
- package/pf-clipboard-copy/pf-clipboard-copy.js +318 -3
- package/pf-clipboard-copy/pf-clipboard-copy.js.map +1 -1
- package/pf-code-block/pf-code-block.css +11 -1
- package/pf-code-block/pf-code-block.js +70 -18
- package/pf-code-block/pf-code-block.js.map +1 -1
- package/pf-dropdown/pf-dropdown-group.js +40 -2
- package/pf-dropdown/pf-dropdown-group.js.map +1 -1
- package/pf-dropdown/pf-dropdown-item.css +10 -0
- package/pf-dropdown/pf-dropdown-item.d.ts +0 -27
- package/pf-dropdown/pf-dropdown-item.js +155 -2
- package/pf-dropdown/pf-dropdown-item.js.map +1 -1
- package/pf-dropdown/pf-dropdown-menu.js +39 -2
- package/pf-dropdown/pf-dropdown-menu.js.map +1 -1
- package/pf-dropdown/pf-dropdown.css +5 -0
- package/pf-dropdown/pf-dropdown.d.ts +1 -9
- package/pf-dropdown/pf-dropdown.js +350 -2
- package/pf-dropdown/pf-dropdown.js.map +1 -1
- package/pf-icon/pf-icon.css +1 -0
- package/pf-icon/pf-icon.d.ts +1 -3
- package/pf-icon/pf-icon.js +44 -4
- package/pf-icon/pf-icon.js.map +1 -1
- package/pf-jump-links/pf-jump-links-item.css +7 -1
- package/pf-jump-links/pf-jump-links-item.d.ts +0 -8
- package/pf-jump-links/pf-jump-links-item.js +77 -2
- package/pf-jump-links/pf-jump-links-item.js.map +1 -1
- package/pf-jump-links/pf-jump-links-list.css +3 -0
- package/pf-jump-links/pf-jump-links-list.d.ts +0 -5
- package/pf-jump-links/pf-jump-links-list.js +20 -2
- package/pf-jump-links/pf-jump-links-list.js.map +1 -1
- package/pf-jump-links/pf-jump-links.css +36 -0
- package/pf-jump-links/pf-jump-links.d.ts +1 -38
- package/pf-jump-links/pf-jump-links.js +179 -2
- package/pf-jump-links/pf-jump-links.js.map +1 -1
- package/pf-label/pf-label.css +51 -1
- package/pf-label/pf-label.d.ts +1 -58
- package/pf-label/pf-label.js +257 -2
- package/pf-label/pf-label.js.map +1 -1
- package/pf-modal/pf-modal.css +11 -0
- package/pf-modal/pf-modal.d.ts +1 -24
- package/pf-modal/pf-modal.js +215 -2
- package/pf-modal/pf-modal.js.map +1 -1
- package/pf-panel/pf-panel.css +29 -0
- package/pf-panel/pf-panel.d.ts +1 -32
- package/pf-panel/pf-panel.js +204 -2
- package/pf-panel/pf-panel.js.map +1 -1
- package/pf-popover/pf-popover.css +33 -0
- package/pf-popover/pf-popover.d.ts +1 -108
- package/pf-popover/pf-popover.js +251 -3
- package/pf-popover/pf-popover.js.map +1 -1
- package/pf-progress/pf-progress.css +19 -0
- package/pf-progress/pf-progress.d.ts +1 -57
- package/pf-progress/pf-progress.js +231 -2
- package/pf-progress/pf-progress.js.map +1 -1
- package/pf-progress-stepper/pf-progress-step.js +126 -2
- package/pf-progress-stepper/pf-progress-step.js.map +1 -1
- package/pf-progress-stepper/pf-progress-stepper.css +96 -0
- package/pf-progress-stepper/pf-progress-stepper.d.ts +1 -115
- package/pf-progress-stepper/pf-progress-stepper.js +326 -2
- package/pf-progress-stepper/pf-progress-stepper.js.map +1 -1
- package/pf-search-input/pf-search-input.css +308 -0
- package/pf-search-input/pf-search-input.d.ts +75 -0
- package/pf-search-input/pf-search-input.js +630 -0
- package/pf-search-input/pf-search-input.js.map +1 -0
- package/pf-search-input/test/pf-search-input.e2e.d.ts +1 -0
- package/pf-search-input/test/pf-search-input.e2e.js +23 -0
- package/pf-search-input/test/pf-search-input.e2e.js.map +1 -0
- package/pf-search-input/test/pf-search-input.spec.d.ts +1 -0
- package/pf-search-input/test/pf-search-input.spec.js +1021 -0
- package/pf-search-input/test/pf-search-input.spec.js.map +1 -0
- package/pf-select/pf-option-group.js +27 -2
- package/pf-select/pf-option-group.js.map +1 -1
- package/pf-select/pf-option.css +9 -1
- package/pf-select/pf-option.js +83 -2
- package/pf-select/pf-option.js.map +1 -1
- package/pf-select/pf-select.css +157 -0
- package/pf-select/pf-select.d.ts +1 -158
- package/pf-select/pf-select.js +542 -5
- package/pf-select/pf-select.js.map +1 -1
- package/pf-spinner/pf-spinner.css +13 -0
- package/pf-spinner/pf-spinner.d.ts +1 -14
- package/pf-spinner/pf-spinner.js +101 -2
- package/pf-spinner/pf-spinner.js.map +1 -1
- package/pf-switch/pf-switch.css +22 -0
- package/pf-switch/pf-switch.d.ts +1 -30
- package/pf-switch/pf-switch.js +156 -2
- package/pf-switch/pf-switch.js.map +1 -1
- package/pf-table/pf-caption.js +10 -2
- package/pf-table/pf-caption.js.map +1 -1
- package/pf-table/pf-table.css +211 -0
- package/pf-table/pf-table.d.ts +1 -635
- package/pf-table/pf-table.js +437 -2
- package/pf-table/pf-table.js.map +1 -1
- package/pf-table/pf-tbody.js +18 -2
- package/pf-table/pf-tbody.js.map +1 -1
- package/pf-table/pf-td.js +107 -2
- package/pf-table/pf-td.js.map +1 -1
- package/pf-table/pf-th.js +95 -2
- package/pf-table/pf-th.js.map +1 -1
- package/pf-table/pf-thead.js +20 -2
- package/pf-table/pf-thead.js.map +1 -1
- package/pf-table/pf-tr.js +89 -2
- package/pf-table/pf-tr.js.map +1 -1
- package/pf-tabs/pf-tab-panel.css +1 -0
- package/pf-tabs/pf-tab-panel.d.ts +0 -2
- package/pf-tabs/pf-tab-panel.js +19 -3
- package/pf-tabs/pf-tab-panel.js.map +1 -1
- package/pf-tabs/pf-tab.css +33 -0
- package/pf-tabs/pf-tab.d.ts +0 -40
- package/pf-tabs/pf-tab.js +231 -2
- package/pf-tabs/pf-tab.js.map +1 -1
- package/pf-tabs/pf-tabs.css +26 -0
- package/pf-tabs/pf-tabs.d.ts +1 -34
- package/pf-tabs/pf-tabs.js +307 -2
- package/pf-tabs/pf-tabs.js.map +1 -1
- package/pf-text-area/pf-text-area.css +125 -0
- package/pf-text-area/pf-text-area.d.ts +1 -125
- package/pf-text-area/pf-text-area.js +320 -2
- package/pf-text-area/pf-text-area.js.map +1 -1
- package/pf-text-input/pf-text-input.css +126 -0
- package/pf-text-input/pf-text-input.d.ts +1 -126
- package/pf-text-input/pf-text-input.js +395 -2
- package/pf-text-input/pf-text-input.js.map +1 -1
- package/pf-tile/pf-tile.css +28 -8
- package/pf-tile/pf-tile.d.ts +1 -24
- package/pf-tile/pf-tile.js +156 -2
- package/pf-tile/pf-tile.js.map +1 -1
- package/pf-timestamp/pf-timestamp.d.ts +1 -0
- package/pf-timestamp/pf-timestamp.js +10 -2
- package/pf-timestamp/pf-timestamp.js.map +1 -1
- package/pf-tooltip/pf-tooltip.css +10 -0
- package/pf-tooltip/pf-tooltip.d.ts +1 -79
- package/pf-tooltip/pf-tooltip.js +113 -3
- package/pf-tooltip/pf-tooltip.js.map +1 -1
- package/pfe.min.js +0 -7439
- package/pfe.min.js.LEGAL.txt +0 -57
- package/pfe.min.js.map +0 -7
- package/react/pf-accordion/pf-accordion-header.d.ts +0 -5
- package/react/pf-accordion/pf-accordion-header.js +0 -12
- package/react/pf-accordion/pf-accordion-panel.d.ts +0 -5
- package/react/pf-accordion/pf-accordion-panel.js +0 -10
- package/react/pf-accordion/pf-accordion.d.ts +0 -5
- package/react/pf-accordion/pf-accordion.js +0 -13
- package/react/pf-avatar/pf-avatar.d.ts +0 -5
- package/react/pf-avatar/pf-avatar.js +0 -12
- package/react/pf-back-to-top/pf-back-to-top.d.ts +0 -5
- package/react/pf-back-to-top/pf-back-to-top.js +0 -10
- package/react/pf-background-image/pf-background-image.d.ts +0 -5
- package/react/pf-background-image/pf-background-image.js +0 -10
- package/react/pf-badge/pf-badge.d.ts +0 -5
- package/react/pf-badge/pf-badge.js +0 -10
- package/react/pf-banner/pf-banner.d.ts +0 -5
- package/react/pf-banner/pf-banner.js +0 -10
- package/react/pf-button/pf-button.d.ts +0 -5
- package/react/pf-button/pf-button.js +0 -12
- package/react/pf-card/pf-card.d.ts +0 -5
- package/react/pf-card/pf-card.js +0 -10
- package/react/pf-chip/pf-chip-group.d.ts +0 -5
- package/react/pf-chip/pf-chip-group.js +0 -13
- package/react/pf-chip/pf-chip.d.ts +0 -5
- package/react/pf-chip/pf-chip.js +0 -13
- package/react/pf-clipboard-copy/pf-clipboard-copy.d.ts +0 -5
- package/react/pf-clipboard-copy/pf-clipboard-copy.js +0 -12
- package/react/pf-code-block/pf-code-block.d.ts +0 -5
- package/react/pf-code-block/pf-code-block.js +0 -10
- package/react/pf-dropdown/pf-dropdown-group.d.ts +0 -5
- package/react/pf-dropdown/pf-dropdown-group.js +0 -10
- package/react/pf-dropdown/pf-dropdown-item.d.ts +0 -5
- package/react/pf-dropdown/pf-dropdown-item.js +0 -10
- package/react/pf-dropdown/pf-dropdown-menu.d.ts +0 -5
- package/react/pf-dropdown/pf-dropdown-menu.js +0 -10
- package/react/pf-dropdown/pf-dropdown.d.ts +0 -5
- package/react/pf-dropdown/pf-dropdown.js +0 -14
- package/react/pf-icon/pf-icon.d.ts +0 -5
- package/react/pf-icon/pf-icon.js +0 -13
- package/react/pf-jump-links/pf-jump-links-item.d.ts +0 -5
- package/react/pf-jump-links/pf-jump-links-item.js +0 -13
- package/react/pf-jump-links/pf-jump-links-list.d.ts +0 -5
- package/react/pf-jump-links/pf-jump-links-list.js +0 -10
- package/react/pf-jump-links/pf-jump-links.d.ts +0 -5
- package/react/pf-jump-links/pf-jump-links.js +0 -12
- package/react/pf-label/pf-label.d.ts +0 -5
- package/react/pf-label/pf-label.js +0 -12
- package/react/pf-modal/pf-modal.d.ts +0 -5
- package/react/pf-modal/pf-modal.js +0 -13
- package/react/pf-panel/pf-panel.d.ts +0 -5
- package/react/pf-panel/pf-panel.js +0 -10
- package/react/pf-popover/pf-popover.d.ts +0 -5
- package/react/pf-popover/pf-popover.js +0 -10
- package/react/pf-progress/pf-progress.d.ts +0 -5
- package/react/pf-progress/pf-progress.js +0 -10
- package/react/pf-progress-stepper/pf-progress-step.d.ts +0 -5
- package/react/pf-progress-stepper/pf-progress-step.js +0 -10
- package/react/pf-progress-stepper/pf-progress-stepper.d.ts +0 -5
- package/react/pf-progress-stepper/pf-progress-stepper.js +0 -10
- package/react/pf-select/pf-option-group.d.ts +0 -5
- package/react/pf-select/pf-option-group.js +0 -10
- package/react/pf-select/pf-option.d.ts +0 -5
- package/react/pf-select/pf-option.js +0 -10
- package/react/pf-select/pf-select.d.ts +0 -5
- package/react/pf-select/pf-select.js +0 -13
- package/react/pf-spinner/pf-spinner.d.ts +0 -5
- package/react/pf-spinner/pf-spinner.js +0 -10
- package/react/pf-switch/pf-switch.d.ts +0 -5
- package/react/pf-switch/pf-switch.js +0 -12
- package/react/pf-table/pf-caption.d.ts +0 -5
- package/react/pf-table/pf-caption.js +0 -10
- package/react/pf-table/pf-table.d.ts +0 -5
- package/react/pf-table/pf-table.js +0 -10
- package/react/pf-table/pf-tbody.d.ts +0 -5
- package/react/pf-table/pf-tbody.js +0 -10
- package/react/pf-table/pf-td.d.ts +0 -5
- package/react/pf-table/pf-td.js +0 -10
- package/react/pf-table/pf-th.d.ts +0 -5
- package/react/pf-table/pf-th.js +0 -10
- package/react/pf-table/pf-thead.d.ts +0 -5
- package/react/pf-table/pf-thead.js +0 -10
- package/react/pf-table/pf-tr.d.ts +0 -5
- package/react/pf-table/pf-tr.js +0 -10
- package/react/pf-tabs/pf-tab-panel.d.ts +0 -5
- package/react/pf-tabs/pf-tab-panel.js +0 -10
- package/react/pf-tabs/pf-tab.d.ts +0 -5
- package/react/pf-tabs/pf-tab.js +0 -12
- package/react/pf-tabs/pf-tabs.d.ts +0 -5
- package/react/pf-tabs/pf-tabs.js +0 -10
- package/react/pf-text-area/pf-text-area.d.ts +0 -5
- package/react/pf-text-area/pf-text-area.js +0 -10
- package/react/pf-text-input/pf-text-input.d.ts +0 -5
- package/react/pf-text-input/pf-text-input.js +0 -10
- package/react/pf-tile/pf-tile.d.ts +0 -5
- package/react/pf-tile/pf-tile.js +0 -10
- package/react/pf-timestamp/pf-timestamp.d.ts +0 -5
- package/react/pf-timestamp/pf-timestamp.js +0 -10
- package/react/pf-tooltip/pf-tooltip.d.ts +0 -5
- package/react/pf-tooltip/pf-tooltip.js +0 -10
package/pf-modal/pf-modal.js
CHANGED
|
@@ -11,7 +11,202 @@ import { bound, initializer, observes } from '@patternfly/pfe-core/decorators.js
|
|
|
11
11
|
import { getRandomId } from '@patternfly/pfe-core/functions/random.js';
|
|
12
12
|
import { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';
|
|
13
13
|
import { css } from "lit";
|
|
14
|
-
const style = css `:host {
|
|
14
|
+
const style = css `:host {
|
|
15
|
+
\tdisplay: block;
|
|
16
|
+
\tposition: relative;
|
|
17
|
+
--_spacer-align-top: var(--pf-c-modal-box--m-align-top--spacer,
|
|
18
|
+
var(--pf-global--spacer--sm, 0.5rem));
|
|
19
|
+
--_height-offset: min(var(--_spacer-align-top), var(--pf-global--spacer--2xl, 3rem));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[hidden] {
|
|
23
|
+
display: none !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
section {
|
|
27
|
+
display: flex;
|
|
28
|
+
position: fixed;
|
|
29
|
+
height: 100%;
|
|
30
|
+
width: 100%;
|
|
31
|
+
top: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
/** Z-index for modal box */
|
|
36
|
+
z-index: var(--pf-c-modal-box--ZIndex,
|
|
37
|
+
var(--pf-global--ZIndex--xl,
|
|
38
|
+
500));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#container {
|
|
42
|
+
position: relative;
|
|
43
|
+
max-height: inherit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part=overlay] {
|
|
47
|
+
position: fixed;
|
|
48
|
+
height: 100%;
|
|
49
|
+
width: 100%;
|
|
50
|
+
top: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
background-color: var(--pf-c-backdrop--BackgroundColor,
|
|
53
|
+
var(--pf-global--BackgroundColor--dark-transparent-100,
|
|
54
|
+
rgba(3, 3, 3, 0.62)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[part=dialog] {
|
|
58
|
+
position: relative;
|
|
59
|
+
margin: 0 auto;
|
|
60
|
+
|
|
61
|
+
/** Width of modal */
|
|
62
|
+
width: var(--pf-c-modal-box--Width,
|
|
63
|
+
calc(100% - var(--pf-global--spacer--xl,2rem)));
|
|
64
|
+
|
|
65
|
+
/** Max width of modal */
|
|
66
|
+
max-width: var(--pf-c-modal-box--MaxWidth,
|
|
67
|
+
calc(100% - var(--pf-global--spacer--xl,2rem)));
|
|
68
|
+
|
|
69
|
+
/** Max height of modal */
|
|
70
|
+
max-height: var(--pf-c-modal-box--MaxHeight,
|
|
71
|
+
calc(100% - var(--pf-global--spacer--2xl,3rem)));
|
|
72
|
+
|
|
73
|
+
/** Box shadow for modal */
|
|
74
|
+
box-shadow: var(--pf-c-modal-box--BoxShadow,
|
|
75
|
+
var(--pf-global--BoxShadow--xl,
|
|
76
|
+
0 1rem 2rem 0 rgba(3, 3, 3, 0.16),
|
|
77
|
+
0 0 0.5rem 0 rgba(3, 3, 3, 0.1)));
|
|
78
|
+
|
|
79
|
+
\t/** Background color for modal */
|
|
80
|
+
\tbackground-color: var(--pf-c-modal-box--BackgroundColor,
|
|
81
|
+
var(--pf-global--BackgroundColor--100,
|
|
82
|
+
var(--pf-global--BackgroundColor--100, #fff)));
|
|
83
|
+
|
|
84
|
+
padding: var(--pf-global--spacer--lg, 1.5rem);
|
|
85
|
+
margin-inline: var(--pf-global--spacer--md, 1rem);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host([width]) [part=dialog],
|
|
89
|
+
:host([variant]) [part=dialog] {
|
|
90
|
+
margin-inline: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:host([width="small"]) [part=dialog],
|
|
94
|
+
:host([variant="small"]) [part=dialog] {
|
|
95
|
+
/** Max width for small modal */
|
|
96
|
+
--pf-c-modal-box--Width: var(--pf-c-modal-box--m-sm--sm--MaxWidth, 35rem);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([width="medium"]) [part=dialog],
|
|
100
|
+
:host([variant="medium"]) [part=dialog] {
|
|
101
|
+
/** Max width for medium modal */
|
|
102
|
+
--pf-c-modal-box--Width: var(--pf-c-modal-box--m-md--Width, 52.5rem);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([width="large"]) [part=dialog],
|
|
106
|
+
:host([variant="large"]) [part=dialog] {
|
|
107
|
+
/** Max width for large modal */
|
|
108
|
+
--pf-c-modal-box--Width: var(--pf-c-modal-box--m-lg--lg--MaxWidth, 70rem);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[part=content] {
|
|
112
|
+
overflow-y: auto;
|
|
113
|
+
overscroll-behavior: contain;
|
|
114
|
+
|
|
115
|
+
max-height: var(--pf-c-modal-box--MaxHeight,
|
|
116
|
+
calc(100vh - var(--pf-global--spacer--2xl,
|
|
117
|
+
3rem)));
|
|
118
|
+
|
|
119
|
+
box-sizing: border-box;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
[part=content] ::slotted([slot="header"]) {
|
|
123
|
+
margin-top: 0 !important;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
header {
|
|
127
|
+
position: sticky;
|
|
128
|
+
top: 0;
|
|
129
|
+
\tbackground-color: var(--pf-c-modal-box--BackgroundColor,
|
|
130
|
+
var(--pf-global--BackgroundColor--100,
|
|
131
|
+
var(--pf-global--BackgroundColor--100,
|
|
132
|
+
#fff)));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
header ::slotted(:is(h1,h2,h3,h4,h5,h6)[slot="header"]) {
|
|
136
|
+
/** Font size for modal title */
|
|
137
|
+
font-size: var(--pf-c-modal-box__title--FontSize,
|
|
138
|
+
var(--pf-global--FontSize--2xl,
|
|
139
|
+
1.5rem));
|
|
140
|
+
font-weight: var(--pf-global--FontWeight--normal, 400);
|
|
141
|
+
/** Font family for modal title */
|
|
142
|
+
font-family: var(--pf-c-modal-box__title--FontFamily,
|
|
143
|
+
var(--pf-global--FontFamily--heading--sans-serif,
|
|
144
|
+
var(--pf-global--FontFamily--redhat-updated--heading--sans-serif,
|
|
145
|
+
"RedHatDisplayUpdated", "Overpass", overpass, helvetica, arial, sans-serif)));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
[part=close-button] {
|
|
149
|
+
background-color: transparent;
|
|
150
|
+
border: none;
|
|
151
|
+
margin: 0;
|
|
152
|
+
padding: 0;
|
|
153
|
+
text-align: left;
|
|
154
|
+
|
|
155
|
+
position: absolute;
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
line-height: 24px;
|
|
158
|
+
padding-block:
|
|
159
|
+
var(--pf-c-button--PaddingTop,
|
|
160
|
+
var(--pf-global--spacer--form-element, 0.375rem));
|
|
161
|
+
padding-inline:
|
|
162
|
+
var(--pf-c-button--PaddingRight,
|
|
163
|
+
var(--pf-global--spacer--md, 1rem));
|
|
164
|
+
top: 0;
|
|
165
|
+
right: calc(var(--pf-global--spacer--lg, 1.5rem) / -3);
|
|
166
|
+
color: var(--pf-c-button--m-plain--Color,
|
|
167
|
+
var(--pf-global--Color--200,
|
|
168
|
+
#6a6e73));
|
|
169
|
+
font-size: var(--pf-c-button--FontSize,
|
|
170
|
+
var(--pf-global--FontSize--md,
|
|
171
|
+
1rem));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[part=close-button]:is(:focus-within, :focus-visible, :hover) {
|
|
175
|
+
color: var(--pf-c-button--m-plain--focus--Color, var(--pf-global--Color--100, #151515));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[part=close-button] > svg {
|
|
179
|
+
font-size: 16px;
|
|
180
|
+
width: var(--pf-global--spacer--md, 1rem);
|
|
181
|
+
aspect-ratio: 1/1;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
:host([position="top"]) #dialog {
|
|
185
|
+
align-self: start;
|
|
186
|
+
|
|
187
|
+
margin-block: var(--pf-c-modal-box--m-align-top--MarginTop,
|
|
188
|
+
var(--pf-c-modal-box--m-align-top--spacer,
|
|
189
|
+
2rem));
|
|
190
|
+
|
|
191
|
+
margin-inline: var(--pf-global--spacer--md, 1rem);
|
|
192
|
+
|
|
193
|
+
width: 100%;
|
|
194
|
+
|
|
195
|
+
max-width: var(--pf-c-modal-box--m-align-top--MaxWidth,
|
|
196
|
+
calc(100% - min(
|
|
197
|
+
var(--pf-c-modal-box--m-align-top--spacer, 2rem) * 2,
|
|
198
|
+
var(--pf-global--spacer--xl, 2rem))));
|
|
199
|
+
|
|
200
|
+
max-height: var(--pf-c-modal-box--m-align-top--MaxHeight,
|
|
201
|
+
calc(100% - var(--_height-offset) - var(--_spacer-align-top)));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
footer {
|
|
205
|
+
display: flex;
|
|
206
|
+
align-items: center;
|
|
207
|
+
gap: var(--pf-global--spacer--xl, 0.5rem);
|
|
208
|
+
}
|
|
209
|
+
`;
|
|
15
210
|
export class ModalCancelEvent extends ComposedEvent {
|
|
16
211
|
constructor() {
|
|
17
212
|
super('cancel');
|
|
@@ -57,7 +252,9 @@ let PfModal = class PfModal extends LitElement {
|
|
|
57
252
|
const hasFooter = __classPrivateFieldGet(this, _PfModal_slots, "f").hasSlotted('footer');
|
|
58
253
|
return html `
|
|
59
254
|
<section ?hidden=${!this.open}>
|
|
255
|
+
<!-- summary: The modal overlay which lies under the dialog and above the page body -->
|
|
60
256
|
<div id="overlay" part="overlay" ?hidden=${!this.open}></div>
|
|
257
|
+
<!-- summary: The dialog element -->
|
|
61
258
|
<div id="dialog"
|
|
62
259
|
part="dialog"
|
|
63
260
|
tabindex="0"
|
|
@@ -66,18 +263,34 @@ let PfModal = class PfModal extends LitElement {
|
|
|
66
263
|
aria-label=${ifDefined(headerLabel)}
|
|
67
264
|
?hidden="${!this.open}">
|
|
68
265
|
<div id="container">
|
|
266
|
+
<!-- summary: The container for the dialog content -->
|
|
69
267
|
<div id="content" part="content" class=${classMap({ hasHeader, hasDescription, hasFooter })}>
|
|
268
|
+
<!-- summary: The container for the optional dialog header -->
|
|
70
269
|
<header part="header">
|
|
270
|
+
<!-- summary: Heading tag
|
|
271
|
+
description: |
|
|
272
|
+
The header is an optional slot that appears at the top of the modal window.
|
|
273
|
+
It should be a heading tag (h2-h6). -->
|
|
71
274
|
<slot name="header"></slot>
|
|
275
|
+
<!-- summary: The container for the optional dialog description in the header -->
|
|
72
276
|
<div part="description" ?hidden=${!hasDescription}>
|
|
73
277
|
<slot name="description"></slot>
|
|
74
278
|
</div>
|
|
75
279
|
</header>
|
|
280
|
+
<!--
|
|
281
|
+
summary: Modal dialog content
|
|
282
|
+
description: |
|
|
283
|
+
The default slot can contain any type of content. When the header is not present,
|
|
284
|
+
this unnamed slot appear at the top of the modal window (to the left of the close
|
|
285
|
+
button). Otherwise it will appear beneath the header. -->
|
|
76
286
|
<slot></slot>
|
|
287
|
+
<!-- summary: Actions footer container -->
|
|
77
288
|
<footer ?hidden=${!hasFooter} part="footer">
|
|
289
|
+
<!-- summary: Optional footer content. Good place to put action buttons. -->
|
|
78
290
|
<slot name="footer"></slot>
|
|
79
291
|
</footer>
|
|
80
292
|
</div>
|
|
293
|
+
<!-- summary: The modal's close button -->
|
|
81
294
|
<button id="close-button"
|
|
82
295
|
part="close-button"
|
|
83
296
|
aria-label="Close dialog"
|
|
@@ -242,7 +455,7 @@ PfModal.shadowRootOptions = {
|
|
|
242
455
|
PfModal.styles = [style];
|
|
243
456
|
/** Should the dialog close when user clicks outside the dialog? */
|
|
244
457
|
PfModal.closeOnOutsideClick = false;
|
|
245
|
-
PfModal.version = "4.
|
|
458
|
+
PfModal.version = "4.2.0";
|
|
246
459
|
__decorate([
|
|
247
460
|
property({ reflect: true })
|
|
248
461
|
], PfModal.prototype, "variant", void 0);
|
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,EAAuB,MAAM,KAAK,CAAC;AAC5D,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,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;;;AAIrF,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IACjD;QACE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAChD;QACE,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,aAAa;IAC/C;IACE,4DAA4D;IACrD,OAA2B;QAElC,KAAK,CAAC,MAAM,CAAC,CAAC;Q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Ec,cAAM,GAAoB,CAAC,KAAK,CAAC,AAA3B,CAA4B;AAElD,mEAAmE;AAClD,2BAAmB,GAAG,KAAK,AAAR,CAAS;;AAMhB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAwC;AAKvC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAAkB;AAEF;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qCAAc;AAG7C;IAAX,QAAQ,EAAE;wCAAkB;AAKF;IAA1B,KAAK,CAAC,UAAU,CAAC;wCAAsC;AAC9B;IAAzB,KAAK,CAAC,SAAS,CAAC;uCAAqC;AACtB;IAA/B,KAAK,CAAC,eAAe,CAAC;4CAA0C;AAuEjD;IADf,WAAW,EAAE;oCAkBb;AAGe;IADf,QAAQ,CAAC,MAAM,CAAC;0CAyBhB;AAGS;IADT,QAAQ,CAAC,SAAS,CAAC;6CAOnB;AAEc;IAAd,KAAK;6CAIL;AAEc;IAAd,KAAK;sCAWL;AAEc;IAAd,KAAK;wCAoBL;AAoBM;IAAN,KAAK;qCAEL;AAQM;IAAN,KAAK;mCAEL;AAEM;IAAN,KAAK;wCAGL;AASM;IAAN,KAAK;oCAML;AAzPU,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO","sourcesContent":["import { LitElement, html, type TemplateResult } 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, observes } 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=500]\n * @cssprop {<length>} [--pf-c-modal-box--Width=calc(100 - 2rem)] - Width of the modal\n * @cssprop {<length>} [--pf-c-modal-box--MaxWidth=calc(100 - 2rem)] - Max width of the modal\n * @cssprop {<length>} [--pf-c-modal-box--m-sm--sm--MaxWidth=35rem] - Max width of the small variant modal\n * @cssprop {<length>} [--pf-c-modal-box--m-md--MaxWidth=52.5rem] - Max width of the small variant modal\n * @cssprop {<length>} [--pf-c-modal-box--m-lg--lg--MaxWidth=70rem] - Max width of the large variant modal\n * @cssprop {<length>} [--pf-c-modal-box--MaxHeight=calc(100 - 3rem)] - Max height of the modal\n * @cssprop {<length>} [--pf-c-modal-box--BoxShadow=var(--pf-global--BoxShadow--xl)] -\n * @cssprop {<length>} [--pf-c-modal-box__title--FontSize=1.5rem] -\n * @cssprop {<length>} [--pf-c-modal-box--m-align-top--MarginTop=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=#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: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static readonly styles: CSSStyleSheet[] = [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 @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\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(): void {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render(): TemplateResult<1> {\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(): void {\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(): Promise<void> {\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 @observes('open')\n protected async openChanged(oldValue?: boolean, newValue?: boolean): Promise<void> {\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 @observes('trigger')\n protected triggerChanged(): void {\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): void {\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(): void {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show(): void {\n this.open = true;\n }\n\n @bound showModal(): void {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n * @param returnValue dialog return value\n */\n @bound close(returnValue?: string): void {\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,EAAuB,MAAM,KAAK,CAAC;AAC5D,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,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;;;;;;;;;;;;;;;;;;;;;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Ad,KAAK;wCAoBL;AAoBM;IAAN,KAAK;qCAEL;AAQM;IAAN,KAAK;mCAEL;AAEM;IAAN,KAAK;wCAGL;AASM;IAAN,KAAK;oCAML;AA3QU,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO","sourcesContent":["import { LitElement, html, type TemplateResult } 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, observes } 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 * @alias Modal\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@customElement('pf-modal')\nexport class PfModal extends LitElement implements HTMLDialogElement {\n static override readonly shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n static readonly styles: CSSStyleSheet[] = [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 @property({ type: Boolean, reflect: true }) open = false;\n\n /** Optional ID of the trigger element */\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(): void {\n super.connectedCallback();\n this.addEventListener('keydown', this.onKeydown);\n this.addEventListener('click', this.onClick);\n }\n\n render(): TemplateResult<1> {\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 <!-- summary: The modal overlay which lies under the dialog and above the page body -->\n <div id=\"overlay\" part=\"overlay\" ?hidden=${!this.open}></div>\n <!-- summary: The dialog element -->\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 <!-- summary: The container for the dialog content -->\n <div id=\"content\" part=\"content\" class=${classMap({ hasHeader, hasDescription, hasFooter })}>\n <!-- summary: The container for the optional dialog header -->\n <header part=\"header\">\n <!-- summary: Heading tag\n description: |\n The header is an optional slot that appears at the top of the modal window.\n It should be a heading tag (h2-h6). -->\n <slot name=\"header\"></slot>\n <!-- summary: The container for the optional dialog description in the header -->\n <div part=\"description\" ?hidden=${!hasDescription}>\n <slot name=\"description\"></slot>\n </div>\n </header>\n <!--\n summary: Modal dialog content\n description: |\n The default slot can contain any type of content. When the header is not present,\n this unnamed slot appear at the top of the modal window (to the left of the close\n button). Otherwise it will appear beneath the header. -->\n <slot></slot>\n <!-- summary: Actions footer container -->\n <footer ?hidden=${!hasFooter} part=\"footer\">\n <!-- summary: Optional footer content. Good place to put action buttons. -->\n <slot name=\"footer\"></slot>\n </footer>\n </div>\n <!-- summary: The modal's close button -->\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(): void {\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(): Promise<void> {\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 @observes('open')\n protected async openChanged(oldValue?: boolean, newValue?: boolean): Promise<void> {\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 @observes('trigger')\n protected triggerChanged(): void {\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): void {\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(): void {\n this.open = !this.open;\n }\n\n /**\n * Manually opens the modal.\n * ```js\n * modal.open();\n * ```\n */\n @bound show(): void {\n this.open = true;\n }\n\n @bound showModal(): void {\n // TODO: non-modal mode\n this.show();\n }\n\n /**\n * Manually closes the modal.\n * ```js\n * modal.close();\n * ```\n * @param returnValue dialog return value\n */\n @bound close(returnValue?: string): void {\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"]}
|
package/pf-panel/pf-panel.css
CHANGED
|
@@ -1,33 +1,62 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
/* NB: upstream sets these on the container, which is why we do not use fallbacks here. */
|
|
3
|
+
/** Width of panel */
|
|
3
4
|
--pf-c-panel--Width: auto;
|
|
5
|
+
/** Minimum width of panel */
|
|
4
6
|
--pf-c-panel--MinWidth: auto;
|
|
7
|
+
/** Maximum width of panel */
|
|
5
8
|
--pf-c-panel--MaxWidth: none;
|
|
9
|
+
/** Z-index of panel */
|
|
6
10
|
--pf-c-panel--ZIndex: auto;
|
|
11
|
+
/** Background color of panel */
|
|
7
12
|
--pf-c-panel--BackgroundColor: var(--pf-global--BackgroundColor--100, #fff);
|
|
13
|
+
/** Box shadow of panel */
|
|
8
14
|
--pf-c-panel--BoxShadow: none;
|
|
15
|
+
/** Border width of panel before element */
|
|
9
16
|
--pf-c-panel--before--BorderWidth: 0;
|
|
17
|
+
/** Border color of panel before element */
|
|
10
18
|
--pf-c-panel--before--BorderColor: var(--pf-global--BorderColor--100, #d2d2d2);
|
|
19
|
+
/** Border width of bordered panel before element */
|
|
11
20
|
--pf-c-panel--m-bordered--before--BorderWidth: var(--pf-global--BorderWidth--sm, 1px);
|
|
21
|
+
/** Box shadow of raised panel */
|
|
12
22
|
--pf-c-panel--m-raised--BoxShadow: var(--pf-global--BoxShadow--md, 0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12), 0 0 0.25rem 0 rgba(3, 3, 3, 0.06));
|
|
23
|
+
/** Z-index of raised panel */
|
|
13
24
|
--pf-c-panel--m-raised--ZIndex: var(--pf-global--ZIndex--sm, 200);
|
|
25
|
+
/** Top padding of panel header */
|
|
14
26
|
--pf-c-panel__header--PaddingTop: var(--pf-global--spacer--md, 1rem);
|
|
27
|
+
/** Right padding of panel header */
|
|
15
28
|
--pf-c-panel__header--PaddingRight: var(--pf-global--spacer--md, 1rem);
|
|
29
|
+
/** Bottom padding of panel header */
|
|
16
30
|
--pf-c-panel__header--PaddingBottom: var(--pf-global--spacer--md, 1rem);
|
|
31
|
+
/** Left padding of panel header */
|
|
17
32
|
--pf-c-panel__header--PaddingLeft: var(--pf-global--spacer--md, 1rem);
|
|
33
|
+
/** Maximum height of panel main */
|
|
18
34
|
--pf-c-panel__main--MaxHeight: none;
|
|
35
|
+
/** Overflow of panel main */
|
|
19
36
|
--pf-c-panel__main--Overflow: visible;
|
|
37
|
+
/** Top padding of panel main body */
|
|
20
38
|
--pf-c-panel__main-body--PaddingTop: var(--pf-global--spacer--md, 1rem);
|
|
39
|
+
/** Right padding of panel main body */
|
|
21
40
|
--pf-c-panel__main-body--PaddingRight: var(--pf-global--spacer--md, 1rem);
|
|
41
|
+
/** Bottom padding of panel main body */
|
|
22
42
|
--pf-c-panel__main-body--PaddingBottom: var(--pf-global--spacer--md, 1rem);
|
|
43
|
+
/** Left padding of panel main body */
|
|
23
44
|
--pf-c-panel__main-body--PaddingLeft: var(--pf-global--spacer--md, 1rem);
|
|
45
|
+
/** Top padding of panel footer */
|
|
24
46
|
--pf-c-panel__footer--PaddingTop: var(--pf-global--spacer--md, 1rem);
|
|
47
|
+
/** Right padding of panel footer */
|
|
25
48
|
--pf-c-panel__footer--PaddingRight: var(--pf-global--spacer--md, 1rem);
|
|
49
|
+
/** Bottom padding of panel footer */
|
|
26
50
|
--pf-c-panel__footer--PaddingBottom: var(--pf-global--spacer--md, 1rem);
|
|
51
|
+
/** Left padding of panel footer */
|
|
27
52
|
--pf-c-panel__footer--PaddingLeft: var(--pf-global--spacer--md, 1rem);
|
|
53
|
+
/** Box shadow of panel footer */
|
|
28
54
|
--pf-c-panel__footer--BoxShadow: none;
|
|
55
|
+
/** Maximum height of scrollable panel main */
|
|
29
56
|
--pf-c-panel--m-scrollable__main--MaxHeight: 18.75rem;
|
|
57
|
+
/** Overflow of scrollable panel main */
|
|
30
58
|
--pf-c-panel--m-scrollable__main--Overflow: auto;
|
|
59
|
+
/** Box shadow of scrollable panel footer */
|
|
31
60
|
--pf-c-panel--m-scrollable__footer--BoxShadow: 0 -0.3125rem 0.25rem -0.25rem rgba(3, 3, 3, 0.16);
|
|
32
61
|
position: relative;
|
|
33
62
|
z-index: var(--pf-c-panel--ZIndex);
|
package/pf-panel/pf-panel.d.ts
CHANGED
|
@@ -4,38 +4,7 @@ import { LitElement, type TemplateResult } from 'lit';
|
|
|
4
4
|
* be used to house other components such as fields, forms, videos, buttons, and more.
|
|
5
5
|
* The panel should not be confused with the [drawer](https://www.patternfly.org/v4/components/drawer/design-guidelines/)
|
|
6
6
|
* component, which allows you to surface information via a collapsable container.
|
|
7
|
-
* @
|
|
8
|
-
* @slot - Place main content here
|
|
9
|
-
* @slot footer - Place footer content here
|
|
10
|
-
* @cssprop [--pf-c-panel--Width=auto]
|
|
11
|
-
* @cssprop [--pf-c-panel--MinWidth=auto]
|
|
12
|
-
* @cssprop [--pf-c-panel--MaxWidth=none]
|
|
13
|
-
* @cssprop [--pf-c-panel--ZIndex=auto]
|
|
14
|
-
* @cssprop [--pf-c-panel--BackgroundColor=var(--pf-global--BackgroundColor--100, #fff)]
|
|
15
|
-
* @cssprop [--pf-c-panel--BoxShadow=none]
|
|
16
|
-
* @cssprop [--pf-c-panel--before--BorderWidth=0]
|
|
17
|
-
* @cssprop [--pf-c-panel--before--BorderColor=var(--pf-global--BorderColor--100, #d2d2d2)]
|
|
18
|
-
* @cssprop [--pf-c-panel--m-bordered--before--BorderWidth=var(--pf-global--BorderWidth--sm, 1px)]
|
|
19
|
-
* @cssprop [--pf-c-panel--m-raised--BoxShadow=var(--pf-global--BoxShadow--md, 0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12), 0 0 0.25rem 0 rgba(3, 3, 3, 0.06))]
|
|
20
|
-
* @cssprop [--pf-c-panel--m-raised--ZIndex=var(--pf-global--ZIndex--sm, 200)]
|
|
21
|
-
* @cssprop [--pf-c-panel__header--PaddingTop=var(--pf-global--spacer--md, 1rem)]
|
|
22
|
-
* @cssprop [--pf-c-panel__header--PaddingRight=var(--pf-global--spacer--md, 1rem)]
|
|
23
|
-
* @cssprop [--pf-c-panel__header--PaddingBottom=var(--pf-global--spacer--md, 1rem)]
|
|
24
|
-
* @cssprop [--pf-c-panel__header--PaddingLeft=var(--pf-global--spacer--md, 1rem)]
|
|
25
|
-
* @cssprop [--pf-c-panel__main--MaxHeight=none]
|
|
26
|
-
* @cssprop [--pf-c-panel__main--Overflow=visible]
|
|
27
|
-
* @cssprop [--pf-c-panel__main-body--PaddingTop=var(--pf-global--spacer--md, 1rem)]
|
|
28
|
-
* @cssprop [--pf-c-panel__main-body--PaddingRight=var(--pf-global--spacer--md, 1rem)]
|
|
29
|
-
* @cssprop [--pf-c-panel__main-body--PaddingBottom=var(--pf-global--spacer--md, 1rem)]
|
|
30
|
-
* @cssprop [--pf-c-panel__main-body--PaddingLeft=var(--pf-global--spacer--md, 1rem)]
|
|
31
|
-
* @cssprop [--pf-c-panel__footer--PaddingTop=var(--pf-global--spacer--md, 1rem)]
|
|
32
|
-
* @cssprop [--pf-c-panel__footer--PaddingRight=var(--pf-global--spacer--md, 1rem)]
|
|
33
|
-
* @cssprop [--pf-c-panel__footer--PaddingBottom=var(--pf-global--spacer--md, 1rem)]
|
|
34
|
-
* @cssprop [--pf-c-panel__footer--PaddingLeft=var(--pf-global--spacer--md, 1rem)]
|
|
35
|
-
* @cssprop [--pf-c-panel__footer--BoxShadow=none]
|
|
36
|
-
* @cssprop [--pf-c-panel--m-scrollable__main--MaxHeight=18.75rem]
|
|
37
|
-
* @cssprop [--pf-c-panel--m-scrollable__main--Overflow=auto]
|
|
38
|
-
* @cssprop [--pf-c-panel--m-scrollable__footer--BoxShadow=0 -0.3125rem 0.25rem -0.25rem rgba(3, 3, 3, 0.16)]
|
|
7
|
+
* @alias Panel
|
|
39
8
|
*/
|
|
40
9
|
export declare class PfPanel extends LitElement {
|
|
41
10
|
#private;
|