@sap-ux/ui-components 1.13.5 → 1.14.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/dist/components/Icons.d.ts +150 -150
- package/dist/components/Icons.js +628 -628
- package/dist/components/UIActionCallout/UIActionCallout.d.ts +64 -64
- package/dist/components/UIActionCallout/UIActionCallout.js +67 -67
- package/dist/components/UIActionCallout/index.d.ts +1 -1
- package/dist/components/UIActionCallout/index.js +17 -17
- package/dist/components/UIBreadcrumb/UIBreadcrumb.d.ts +23 -23
- package/dist/components/UIBreadcrumb/UIBreadcrumb.js +38 -38
- package/dist/components/UIBreadcrumb/index.d.ts +1 -1
- package/dist/components/UIBreadcrumb/index.js +17 -17
- package/dist/components/UIButton/UIActionButton.d.ts +23 -23
- package/dist/components/UIButton/UIActionButton.js +89 -89
- package/dist/components/UIButton/UIDefaultButton.d.ts +41 -23
- package/dist/components/UIButton/UIDefaultButton.d.ts.map +1 -1
- package/dist/components/UIButton/UIDefaultButton.js +255 -237
- package/dist/components/UIButton/UIDefaultButton.js.map +1 -1
- package/dist/components/UIButton/UIIconButton.d.ts +37 -37
- package/dist/components/UIButton/UIIconButton.js +106 -106
- package/dist/components/UIButton/UISmallButton.d.ts +34 -34
- package/dist/components/UIButton/UISmallButton.js +115 -115
- package/dist/components/UIButton/UISplitButton.d.ts +44 -44
- package/dist/components/UIButton/UISplitButton.js +86 -86
- package/dist/components/UIButton/index.d.ts +7 -7
- package/dist/components/UIButton/index.js +21 -21
- package/dist/components/UICallout/CalloutCollisionTransform.d.ts +54 -54
- package/dist/components/UICallout/CalloutCollisionTransform.js +160 -160
- package/dist/components/UICallout/UICallout.d.ts +48 -48
- package/dist/components/UICallout/UICallout.js +122 -122
- package/dist/components/UICallout/index.d.ts +2 -2
- package/dist/components/UICallout/index.js +18 -18
- package/dist/components/UICheckbox/UICheckbox.d.ts +34 -34
- package/dist/components/UICheckbox/UICheckbox.js +135 -135
- package/dist/components/UICheckbox/index.d.ts +1 -1
- package/dist/components/UICheckbox/index.js +17 -17
- package/dist/components/UIChoiceGroup/UIChoiceGroup.d.ts +28 -28
- package/dist/components/UIChoiceGroup/UIChoiceGroup.js +182 -182
- package/dist/components/UIChoiceGroup/index.d.ts +1 -1
- package/dist/components/UIChoiceGroup/index.js +17 -17
- package/dist/components/UIComboBox/UIComboBox.d.ts +208 -200
- package/dist/components/UIComboBox/UIComboBox.d.ts.map +1 -1
- package/dist/components/UIComboBox/UIComboBox.js +563 -541
- package/dist/components/UIComboBox/UIComboBox.js.map +1 -1
- package/dist/components/UIComboBox/index.d.ts +1 -1
- package/dist/components/UIComboBox/index.js +17 -17
- package/dist/components/UIContextualMenu/UIContextualMenu.d.ts +31 -31
- package/dist/components/UIContextualMenu/UIContextualMenu.js +126 -126
- package/dist/components/UIContextualMenu/UIHighlightMenuOption.d.ts +19 -19
- package/dist/components/UIContextualMenu/UIHighlightMenuOption.js +50 -50
- package/dist/components/UIContextualMenu/index.d.ts +2 -2
- package/dist/components/UIContextualMenu/index.js +18 -18
- package/dist/components/UICreateSelect/UICreateSelect.d.ts +36 -36
- package/dist/components/UICreateSelect/UICreateSelect.js +172 -172
- package/dist/components/UICreateSelect/index.d.ts +1 -1
- package/dist/components/UICreateSelect/index.js +17 -17
- package/dist/components/UIDatePicker/UIDatePicker.d.ts +49 -49
- package/dist/components/UIDatePicker/UIDatePicker.js +72 -72
- package/dist/components/UIDatePicker/index.d.ts +1 -1
- package/dist/components/UIDatePicker/index.js +17 -17
- package/dist/components/UIDialog/UIDialog.d.ts +118 -118
- package/dist/components/UIDialog/UIDialog.js +281 -281
- package/dist/components/UIDialog/index.d.ts +1 -1
- package/dist/components/UIDialog/index.js +17 -17
- package/dist/components/UIDropdown/UIDropdown.d.ts +94 -94
- package/dist/components/UIDropdown/UIDropdown.js +224 -224
- package/dist/components/UIDropdown/index.d.ts +2 -2
- package/dist/components/UIDropdown/index.js +18 -18
- package/dist/components/UIDropdown/utils.d.ts +20 -20
- package/dist/components/UIDropdown/utils.js +43 -43
- package/dist/components/UIFlexibleTable/RowActions.d.ts +16 -16
- package/dist/components/UIFlexibleTable/RowActions.js +73 -73
- package/dist/components/UIFlexibleTable/RowData.d.ts +16 -16
- package/dist/components/UIFlexibleTable/RowData.js +111 -111
- package/dist/components/UIFlexibleTable/UIFlexibleTable.d.ts +11 -11
- package/dist/components/UIFlexibleTable/UIFlexibleTable.js +280 -280
- package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.d.ts +20 -20
- package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.js +20 -20
- package/dist/components/UIFlexibleTable/UIFlexibleTableRow.d.ts +26 -26
- package/dist/components/UIFlexibleTable/UIFlexibleTableRow.js +219 -219
- package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.d.ts +20 -20
- package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.js +19 -19
- package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.d.ts +15 -15
- package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.js +28 -28
- package/dist/components/UIFlexibleTable/index.d.ts +5 -5
- package/dist/components/UIFlexibleTable/index.js +21 -21
- package/dist/components/UIFlexibleTable/types.d.ts +143 -143
- package/dist/components/UIFlexibleTable/types.js +14 -14
- package/dist/components/UIFlexibleTable/utils.d.ts +25 -25
- package/dist/components/UIFlexibleTable/utils.js +49 -49
- package/dist/components/UIFocusZone/UIFocusTrapZone.d.ts +22 -22
- package/dist/components/UIFocusZone/UIFocusTrapZone.js +33 -33
- package/dist/components/UIFocusZone/UIFocusZone.d.ts +23 -23
- package/dist/components/UIFocusZone/UIFocusZone.js +35 -35
- package/dist/components/UIFocusZone/index.d.ts +2 -2
- package/dist/components/UIFocusZone/index.js +18 -18
- package/dist/components/UIIcon/UIIcon.d.ts +24 -24
- package/dist/components/UIIcon/UIIcon.js +37 -37
- package/dist/components/UIIcon/index.d.ts +1 -1
- package/dist/components/UIIcon/index.js +17 -17
- package/dist/components/UIInput/UITextInput.d.ts +51 -51
- package/dist/components/UIInput/UITextInput.js +244 -244
- package/dist/components/UIInput/index.d.ts +1 -1
- package/dist/components/UIInput/index.js +17 -17
- package/dist/components/UILabel/UILabel.d.ts +30 -30
- package/dist/components/UILabel/UILabel.js +64 -64
- package/dist/components/UILabel/index.d.ts +1 -1
- package/dist/components/UILabel/index.js +17 -17
- package/dist/components/UILink/UILink.d.ts +25 -25
- package/dist/components/UILink/UILink.js +71 -71
- package/dist/components/UILink/index.d.ts +1 -1
- package/dist/components/UILink/index.js +17 -17
- package/dist/components/UIList/UIList.d.ts +31 -31
- package/dist/components/UIList/UIList.js +120 -120
- package/dist/components/UIList/index.d.ts +1 -1
- package/dist/components/UIList/index.js +17 -17
- package/dist/components/UILoader/UILoader.d.ts +27 -27
- package/dist/components/UILoader/UILoader.js +78 -78
- package/dist/components/UILoader/index.d.ts +1 -1
- package/dist/components/UILoader/index.js +17 -17
- package/dist/components/UIMessageBar/UIMessageBar.d.ts +25 -25
- package/dist/components/UIMessageBar/UIMessageBar.js +56 -56
- package/dist/components/UIMessageBar/index.d.ts +1 -1
- package/dist/components/UIMessageBar/index.js +17 -17
- package/dist/components/UIModal/UIModal.d.ts +23 -23
- package/dist/components/UIModal/UIModal.js +43 -43
- package/dist/components/UIModal/index.d.ts +1 -1
- package/dist/components/UIModal/index.js +17 -17
- package/dist/components/UIOverlay/UIOverlay.d.ts +22 -22
- package/dist/components/UIOverlay/UIOverlay.js +38 -38
- package/dist/components/UIOverlay/index.d.ts +1 -1
- package/dist/components/UIOverlay/index.js +17 -17
- package/dist/components/UIPersona/UIPersona.d.ts +27 -27
- package/dist/components/UIPersona/UIPersona.js +48 -48
- package/dist/components/UIPersona/index.d.ts +1 -1
- package/dist/components/UIPersona/index.js +17 -17
- package/dist/components/UISearchBox/UISearchBox.d.ts +22 -22
- package/dist/components/UISearchBox/UISearchBox.js +155 -155
- package/dist/components/UISearchBox/index.d.ts +3 -3
- package/dist/components/UISearchBox/index.js +17 -17
- package/dist/components/UISection/UISection.d.ts +34 -34
- package/dist/components/UISection/UISection.js +44 -44
- package/dist/components/UISection/UISections.d.ts +249 -249
- package/dist/components/UISection/UISections.js +707 -707
- package/dist/components/UISection/UISplitter.d.ts +96 -96
- package/dist/components/UISection/UISplitter.js +220 -220
- package/dist/components/UISection/index.d.ts +3 -3
- package/dist/components/UISection/index.js +19 -19
- package/dist/components/UISeparator/UISeparator.d.ts +25 -25
- package/dist/components/UISeparator/UISeparator.js +65 -65
- package/dist/components/UISeparator/index.d.ts +1 -1
- package/dist/components/UISeparator/index.js +17 -17
- package/dist/components/UITable/UITable-helper.d.ts +88 -88
- package/dist/components/UITable/UITable-helper.js +263 -263
- package/dist/components/UITable/UITable.d.ts +213 -213
- package/dist/components/UITable/UITable.js +779 -779
- package/dist/components/UITable/index.d.ts +2 -2
- package/dist/components/UITable/index.js +18 -18
- package/dist/components/UITable/types.d.ts +77 -77
- package/dist/components/UITable/types.js +28 -28
- package/dist/components/UITabs/UITabs.d.ts +28 -28
- package/dist/components/UITabs/UITabs.js +70 -70
- package/dist/components/UITabs/index.d.ts +1 -1
- package/dist/components/UITabs/index.js +17 -17
- package/dist/components/UIToggle/UIToggle.d.ts +39 -39
- package/dist/components/UIToggle/UIToggle.js +181 -181
- package/dist/components/UIToggle/index.d.ts +1 -1
- package/dist/components/UIToggle/index.js +17 -17
- package/dist/components/UIToggleGroup/UIToggleGroup.d.ts +31 -31
- package/dist/components/UIToggleGroup/UIToggleGroup.js +139 -139
- package/dist/components/UIToggleGroup/UIToggleGroup.types.d.ts +22 -22
- package/dist/components/UIToggleGroup/UIToggleGroup.types.js +2 -2
- package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.d.ts +25 -25
- package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.js +77 -77
- package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.d.ts +10 -10
- package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.js +2 -2
- package/dist/components/UIToggleGroup/UIToggleGroupOption/index.d.ts +2 -2
- package/dist/components/UIToggleGroup/UIToggleGroupOption/index.js +18 -18
- package/dist/components/UIToggleGroup/index.d.ts +2 -2
- package/dist/components/UIToggleGroup/index.js +18 -18
- package/dist/components/UIToolbar/UIToolbar.d.ts +36 -36
- package/dist/components/UIToolbar/UIToolbar.js +104 -104
- package/dist/components/UIToolbar/UIToolbarColumn.d.ts +7 -7
- package/dist/components/UIToolbar/UIToolbarColumn.js +33 -33
- package/dist/components/UIToolbar/UIToolbarDivider.d.ts +27 -27
- package/dist/components/UIToolbar/UIToolbarDivider.js +52 -52
- package/dist/components/UIToolbar/index.d.ts +3 -3
- package/dist/components/UIToolbar/index.js +19 -19
- package/dist/components/UITooltip/UITooltip.d.ts +29 -29
- package/dist/components/UITooltip/UITooltip.js +77 -77
- package/dist/components/UITooltip/UITooltipUtils.d.ts +17 -17
- package/dist/components/UITooltip/UITooltipUtils.js +45 -45
- package/dist/components/UITooltip/index.d.ts +2 -2
- package/dist/components/UITooltip/index.js +18 -18
- package/dist/components/UITranslationInput/UIFormattedText.d.ts +46 -46
- package/dist/components/UITranslationInput/UIFormattedText.js +121 -121
- package/dist/components/UITranslationInput/UILoadButton.d.ts +52 -52
- package/dist/components/UITranslationInput/UILoadButton.js +109 -109
- package/dist/components/UITranslationInput/UITranslationButton.d.ts +14 -14
- package/dist/components/UITranslationInput/UITranslationButton.js +88 -88
- package/dist/components/UITranslationInput/UITranslationButton.types.d.ts +67 -67
- package/dist/components/UITranslationInput/UITranslationButton.types.js +21 -21
- package/dist/components/UITranslationInput/UITranslationInput.d.ts +25 -25
- package/dist/components/UITranslationInput/UITranslationInput.js +169 -169
- package/dist/components/UITranslationInput/UITranslationUtils.d.ts +64 -64
- package/dist/components/UITranslationInput/UITranslationUtils.js +168 -168
- package/dist/components/UITranslationInput/defaults.d.ts +2 -2
- package/dist/components/UITranslationInput/defaults.js +15 -15
- package/dist/components/UITranslationInput/index.d.ts +2 -2
- package/dist/components/UITranslationInput/index.js +18 -18
- package/dist/components/UITreeDropdown/UITreeDropdown.d.ts +265 -265
- package/dist/components/UITreeDropdown/UITreeDropdown.js +660 -660
- package/dist/components/UITreeDropdown/index.d.ts +1 -1
- package/dist/components/UITreeDropdown/index.js +17 -17
- package/dist/components/UIVerticalDivider/UIVerticalDivider.d.ts +23 -23
- package/dist/components/UIVerticalDivider/UIVerticalDivider.js +41 -41
- package/dist/components/UIVerticalDivider/index.d.ts +1 -1
- package/dist/components/UIVerticalDivider/index.js +17 -17
- package/dist/components/UIVirtualList/UIAutoSizer.d.ts +22 -22
- package/dist/components/UIVirtualList/UIAutoSizer.js +33 -33
- package/dist/components/UIVirtualList/UICellMeasurer.d.ts +23 -23
- package/dist/components/UIVirtualList/UICellMeasurer.js +33 -33
- package/dist/components/UIVirtualList/UIVirtualList.d.ts +43 -43
- package/dist/components/UIVirtualList/UIVirtualList.js +70 -70
- package/dist/components/UIVirtualList/index.d.ts +3 -3
- package/dist/components/UIVirtualList/index.js +19 -19
- package/dist/components/index.d.ts +38 -38
- package/dist/components/index.js +54 -54
- package/dist/helper/ValidationMessage/MessageWrapper.d.ts +17 -17
- package/dist/helper/ValidationMessage/MessageWrapper.js +34 -34
- package/dist/helper/ValidationMessage/index.d.ts +2 -2
- package/dist/helper/ValidationMessage/index.js +18 -18
- package/dist/helper/ValidationMessage/utils.d.ts +31 -31
- package/dist/helper/ValidationMessage/utils.js +121 -121
- package/dist/index.d.ts +2 -2
- package/dist/index.js +18 -18
- package/dist/utilities/DeepMerge.d.ts +10 -10
- package/dist/utilities/DeepMerge.js +48 -48
- package/dist/utilities/Dom.d.ts +14 -7
- package/dist/utilities/Dom.d.ts.map +1 -1
- package/dist/utilities/Dom.js +23 -13
- package/dist/utilities/Dom.js.map +1 -1
- package/dist/utilities/Focus.d.ts +14 -14
- package/dist/utilities/Focus.js +34 -34
- package/dist/utilities/Id.d.ts +2 -2
- package/dist/utilities/Id.js +5 -5
- package/dist/utilities/Keys.d.ts +2 -2
- package/dist/utilities/Keys.js +5 -5
- package/dist/utilities/index.d.ts +4 -4
- package/dist/utilities/index.js +20 -20
- package/package.json +1 -1
- package/storybook/494.d8aaa4d7.iframe.bundle.js +1 -0
- package/storybook/580.057c85e9.iframe.bundle.js +1 -0
- package/storybook/{930.1b3c5615.iframe.bundle.js → 930.3177b0dc.iframe.bundle.js} +2 -2
- package/storybook/UIActionCallout-story.9ee56c83.iframe.bundle.js +2 -0
- package/storybook/UIToggleGroup-story.573848ba.iframe.bundle.js +2 -0
- package/storybook/iframe.html +3 -3
- package/storybook/main.5f68bcca.iframe.bundle.js +1 -0
- package/storybook/project.json +1 -1
- package/storybook/{runtime~main.7c93d414.iframe.bundle.js → runtime~main.a213c0ae.iframe.bundle.js} +1 -1
- package/storybook/494.1829058d.iframe.bundle.js +0 -1
- package/storybook/580.c5ddde6e.iframe.bundle.js +0 -1
- package/storybook/UIActionCallout-story.13bdf055.iframe.bundle.js +0 -2
- package/storybook/UIToggleGroup-story.6f3e7d06.iframe.bundle.js +0 -2
- package/storybook/main.4ed99289.iframe.bundle.js +0 -1
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CalloutCollisionTransform = void 0;
|
|
4
|
-
// Default properties which applies for dialog scenario with footer buttons
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
target: '.ms-Dialog-actions',
|
|
7
|
-
container: '.ms-Dialog-main',
|
|
8
|
-
absolute: true,
|
|
9
|
-
minPagePadding: 10
|
|
10
|
-
};
|
|
11
|
-
const TRANSFORMATION_OFFSET = 20;
|
|
12
|
-
/**
|
|
13
|
-
* This class is responsible for Dialog/Container element transformation to avoid collision/overlap between Callout/Dropdown Menu and target element.
|
|
14
|
-
* In example when multi select dropdown is used inside dialog with actions,
|
|
15
|
-
* then class will apply transformation dialog to make sure that dialog actions and dropdown menu is visible.
|
|
16
|
-
*/
|
|
17
|
-
class CalloutCollisionTransform {
|
|
18
|
-
/**
|
|
19
|
-
* Initializes class with options.
|
|
20
|
-
*
|
|
21
|
-
* @param source Source element.
|
|
22
|
-
* @param callout Dropdown menu/callout element.
|
|
23
|
-
* @param props Transformation properties.
|
|
24
|
-
*/
|
|
25
|
-
constructor(source, callout, props = defaultProps) {
|
|
26
|
-
// Original style properties of container
|
|
27
|
-
this.originalStyle = {};
|
|
28
|
-
this.source = source;
|
|
29
|
-
this.callout = callout;
|
|
30
|
-
this.props = props;
|
|
31
|
-
this.applyTransformation = this.applyTransformation.bind(this);
|
|
32
|
-
this.resetTransformation = this.resetTransformation.bind(this);
|
|
33
|
-
this.preventDismissOnEvent = this.preventDismissOnEvent.bind(this);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Method creates placeholder element with given size.
|
|
37
|
-
*
|
|
38
|
-
* @param size Size of placeholder.
|
|
39
|
-
* @returns HTML element for placeholder.
|
|
40
|
-
*/
|
|
41
|
-
createPlaceholder(size) {
|
|
42
|
-
const element = document.createElement('div');
|
|
43
|
-
element.classList.add('ts-Callout-transformation');
|
|
44
|
-
element.style.height = `${size}px`;
|
|
45
|
-
return element;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Method returns DOM elements and rectangles of associated elements(container, target, callout).
|
|
49
|
-
*
|
|
50
|
-
* @returns DOM elements and rectangles of associated elements.
|
|
51
|
-
*/
|
|
52
|
-
getElements() {
|
|
53
|
-
const source = this.source.current;
|
|
54
|
-
const container = source?.closest(this.props.container);
|
|
55
|
-
if (container && source) {
|
|
56
|
-
const target = container?.querySelector(this.props.target);
|
|
57
|
-
if (target) {
|
|
58
|
-
const elements = {
|
|
59
|
-
container: {
|
|
60
|
-
dom: container,
|
|
61
|
-
rect: container.getBoundingClientRect()
|
|
62
|
-
},
|
|
63
|
-
target: {
|
|
64
|
-
dom: target,
|
|
65
|
-
rect: target.getBoundingClientRect()
|
|
66
|
-
},
|
|
67
|
-
source: {
|
|
68
|
-
dom: source,
|
|
69
|
-
rect: source.getBoundingClientRect()
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const callout = this.callout.current;
|
|
73
|
-
if (callout) {
|
|
74
|
-
elements.callout = { dom: callout, rect: callout.getBoundingClientRect() };
|
|
75
|
-
}
|
|
76
|
-
return elements;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Method calculates callout overlap with target and applies transformation to make target visible.
|
|
83
|
-
*/
|
|
84
|
-
applyTransformation() {
|
|
85
|
-
const elements = this.getElements();
|
|
86
|
-
if (!elements) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const { container, target, callout, source } = elements;
|
|
90
|
-
if (callout) {
|
|
91
|
-
const maxHeight = window.innerHeight - defaultProps.minPagePadding;
|
|
92
|
-
const height = callout.rect.height;
|
|
93
|
-
const top = source.rect.bottom;
|
|
94
|
-
// Calculate if action is overlaps
|
|
95
|
-
let diff = top + height - target.rect.top;
|
|
96
|
-
let bottomPosition = top + callout.rect.height;
|
|
97
|
-
if (diff <= 0 || bottomPosition >= maxHeight) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// Apply additional offset to make target more visible
|
|
101
|
-
bottomPosition += target.rect.height;
|
|
102
|
-
if (bottomPosition <= maxHeight) {
|
|
103
|
-
diff += TRANSFORMATION_OFFSET;
|
|
104
|
-
}
|
|
105
|
-
// Apply absolute position to fix position and avoid recentering
|
|
106
|
-
if (this.props.absolute) {
|
|
107
|
-
const containerStyle = container.dom.style;
|
|
108
|
-
this.originalStyle = {
|
|
109
|
-
transform: containerStyle.transform,
|
|
110
|
-
position: containerStyle.position,
|
|
111
|
-
top: containerStyle.top,
|
|
112
|
-
left: containerStyle.left
|
|
113
|
-
};
|
|
114
|
-
containerStyle.transform = '';
|
|
115
|
-
containerStyle.position = 'absolute';
|
|
116
|
-
containerStyle.top = `${container.rect.top}px`;
|
|
117
|
-
containerStyle.left = `${container.rect.left}px`;
|
|
118
|
-
}
|
|
119
|
-
// Apply placeholder element - gap to make target visible
|
|
120
|
-
this.placeholder = this.createPlaceholder(diff);
|
|
121
|
-
target.dom.prepend(this.placeholder);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Method resets current applied transformation.
|
|
126
|
-
*/
|
|
127
|
-
resetTransformation() {
|
|
128
|
-
const elements = this.getElements();
|
|
129
|
-
if (!elements) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const { container, target } = elements;
|
|
133
|
-
for (const styleName in this.originalStyle) {
|
|
134
|
-
const styleValue = this.originalStyle[styleName];
|
|
135
|
-
if (typeof styleValue === 'string') {
|
|
136
|
-
container.dom.style[styleName] = styleValue;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
this.originalStyle = {};
|
|
140
|
-
// Remove placeholder element
|
|
141
|
-
if (this.placeholder) {
|
|
142
|
-
target.dom.removeChild(this.placeholder);
|
|
143
|
-
this.placeholder = undefined;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Method prevents callout dismiss/close if focus/click on target elements.
|
|
148
|
-
*
|
|
149
|
-
* @param event Triggered event to check.
|
|
150
|
-
* @returns Returns true if callout should not be closed.
|
|
151
|
-
*/
|
|
152
|
-
preventDismissOnEvent(event) {
|
|
153
|
-
const elements = this.getElements();
|
|
154
|
-
if (event.type === 'focus' && elements?.target.dom.contains(event.target)) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.CalloutCollisionTransform = CalloutCollisionTransform;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CalloutCollisionTransform = void 0;
|
|
4
|
+
// Default properties which applies for dialog scenario with footer buttons
|
|
5
|
+
const defaultProps = {
|
|
6
|
+
target: '.ms-Dialog-actions',
|
|
7
|
+
container: '.ms-Dialog-main',
|
|
8
|
+
absolute: true,
|
|
9
|
+
minPagePadding: 10
|
|
10
|
+
};
|
|
11
|
+
const TRANSFORMATION_OFFSET = 20;
|
|
12
|
+
/**
|
|
13
|
+
* This class is responsible for Dialog/Container element transformation to avoid collision/overlap between Callout/Dropdown Menu and target element.
|
|
14
|
+
* In example when multi select dropdown is used inside dialog with actions,
|
|
15
|
+
* then class will apply transformation dialog to make sure that dialog actions and dropdown menu is visible.
|
|
16
|
+
*/
|
|
17
|
+
class CalloutCollisionTransform {
|
|
18
|
+
/**
|
|
19
|
+
* Initializes class with options.
|
|
20
|
+
*
|
|
21
|
+
* @param source Source element.
|
|
22
|
+
* @param callout Dropdown menu/callout element.
|
|
23
|
+
* @param props Transformation properties.
|
|
24
|
+
*/
|
|
25
|
+
constructor(source, callout, props = defaultProps) {
|
|
26
|
+
// Original style properties of container
|
|
27
|
+
this.originalStyle = {};
|
|
28
|
+
this.source = source;
|
|
29
|
+
this.callout = callout;
|
|
30
|
+
this.props = props;
|
|
31
|
+
this.applyTransformation = this.applyTransformation.bind(this);
|
|
32
|
+
this.resetTransformation = this.resetTransformation.bind(this);
|
|
33
|
+
this.preventDismissOnEvent = this.preventDismissOnEvent.bind(this);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Method creates placeholder element with given size.
|
|
37
|
+
*
|
|
38
|
+
* @param size Size of placeholder.
|
|
39
|
+
* @returns HTML element for placeholder.
|
|
40
|
+
*/
|
|
41
|
+
createPlaceholder(size) {
|
|
42
|
+
const element = document.createElement('div');
|
|
43
|
+
element.classList.add('ts-Callout-transformation');
|
|
44
|
+
element.style.height = `${size}px`;
|
|
45
|
+
return element;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Method returns DOM elements and rectangles of associated elements(container, target, callout).
|
|
49
|
+
*
|
|
50
|
+
* @returns DOM elements and rectangles of associated elements.
|
|
51
|
+
*/
|
|
52
|
+
getElements() {
|
|
53
|
+
const source = this.source.current;
|
|
54
|
+
const container = source?.closest(this.props.container);
|
|
55
|
+
if (container && source) {
|
|
56
|
+
const target = container?.querySelector(this.props.target);
|
|
57
|
+
if (target) {
|
|
58
|
+
const elements = {
|
|
59
|
+
container: {
|
|
60
|
+
dom: container,
|
|
61
|
+
rect: container.getBoundingClientRect()
|
|
62
|
+
},
|
|
63
|
+
target: {
|
|
64
|
+
dom: target,
|
|
65
|
+
rect: target.getBoundingClientRect()
|
|
66
|
+
},
|
|
67
|
+
source: {
|
|
68
|
+
dom: source,
|
|
69
|
+
rect: source.getBoundingClientRect()
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const callout = this.callout.current;
|
|
73
|
+
if (callout) {
|
|
74
|
+
elements.callout = { dom: callout, rect: callout.getBoundingClientRect() };
|
|
75
|
+
}
|
|
76
|
+
return elements;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Method calculates callout overlap with target and applies transformation to make target visible.
|
|
83
|
+
*/
|
|
84
|
+
applyTransformation() {
|
|
85
|
+
const elements = this.getElements();
|
|
86
|
+
if (!elements) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const { container, target, callout, source } = elements;
|
|
90
|
+
if (callout) {
|
|
91
|
+
const maxHeight = window.innerHeight - defaultProps.minPagePadding;
|
|
92
|
+
const height = callout.rect.height;
|
|
93
|
+
const top = source.rect.bottom;
|
|
94
|
+
// Calculate if action is overlaps
|
|
95
|
+
let diff = top + height - target.rect.top;
|
|
96
|
+
let bottomPosition = top + callout.rect.height;
|
|
97
|
+
if (diff <= 0 || bottomPosition >= maxHeight) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Apply additional offset to make target more visible
|
|
101
|
+
bottomPosition += target.rect.height;
|
|
102
|
+
if (bottomPosition <= maxHeight) {
|
|
103
|
+
diff += TRANSFORMATION_OFFSET;
|
|
104
|
+
}
|
|
105
|
+
// Apply absolute position to fix position and avoid recentering
|
|
106
|
+
if (this.props.absolute) {
|
|
107
|
+
const containerStyle = container.dom.style;
|
|
108
|
+
this.originalStyle = {
|
|
109
|
+
transform: containerStyle.transform,
|
|
110
|
+
position: containerStyle.position,
|
|
111
|
+
top: containerStyle.top,
|
|
112
|
+
left: containerStyle.left
|
|
113
|
+
};
|
|
114
|
+
containerStyle.transform = '';
|
|
115
|
+
containerStyle.position = 'absolute';
|
|
116
|
+
containerStyle.top = `${container.rect.top}px`;
|
|
117
|
+
containerStyle.left = `${container.rect.left}px`;
|
|
118
|
+
}
|
|
119
|
+
// Apply placeholder element - gap to make target visible
|
|
120
|
+
this.placeholder = this.createPlaceholder(diff);
|
|
121
|
+
target.dom.prepend(this.placeholder);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Method resets current applied transformation.
|
|
126
|
+
*/
|
|
127
|
+
resetTransformation() {
|
|
128
|
+
const elements = this.getElements();
|
|
129
|
+
if (!elements) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const { container, target } = elements;
|
|
133
|
+
for (const styleName in this.originalStyle) {
|
|
134
|
+
const styleValue = this.originalStyle[styleName];
|
|
135
|
+
if (typeof styleValue === 'string') {
|
|
136
|
+
container.dom.style[styleName] = styleValue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
this.originalStyle = {};
|
|
140
|
+
// Remove placeholder element
|
|
141
|
+
if (this.placeholder) {
|
|
142
|
+
target.dom.removeChild(this.placeholder);
|
|
143
|
+
this.placeholder = undefined;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Method prevents callout dismiss/close if focus/click on target elements.
|
|
148
|
+
*
|
|
149
|
+
* @param event Triggered event to check.
|
|
150
|
+
* @returns Returns true if callout should not be closed.
|
|
151
|
+
*/
|
|
152
|
+
preventDismissOnEvent(event) {
|
|
153
|
+
const elements = this.getElements();
|
|
154
|
+
if (event.type === 'focus' && elements?.target.dom.contains(event.target)) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.CalloutCollisionTransform = CalloutCollisionTransform;
|
|
161
161
|
//# sourceMappingURL=CalloutCollisionTransform.js.map
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ICalloutProps, ICalloutContentStyles } from '@fluentui/react';
|
|
3
|
-
export interface UICalloutProps extends ICalloutProps {
|
|
4
|
-
calloutMinWidth?: number;
|
|
5
|
-
contentPadding?: UICalloutContentPadding;
|
|
6
|
-
focusTargetSiblingOnTabPress?: boolean;
|
|
7
|
-
}
|
|
8
|
-
import '../../styles/_shadows.scss';
|
|
9
|
-
export declare const CALLOUT_STYLES: {
|
|
10
|
-
background: string;
|
|
11
|
-
boxShadow: string;
|
|
12
|
-
text: string;
|
|
13
|
-
font: string;
|
|
14
|
-
borderRadius: number;
|
|
15
|
-
};
|
|
16
|
-
export declare enum UICalloutContentPadding {
|
|
17
|
-
None = "None",
|
|
18
|
-
Standard = "Standard"
|
|
19
|
-
}
|
|
20
|
-
export declare const getCalloutStyle: (props: UICalloutProps) => ICalloutContentStyles;
|
|
21
|
-
/**
|
|
22
|
-
* UICallout component.
|
|
23
|
-
* based on https://developer.microsoft.com/en-us/fluentui#/controls/web/callout
|
|
24
|
-
*
|
|
25
|
-
* @exports
|
|
26
|
-
* @class UICallout
|
|
27
|
-
* @extends {React.Component<ICalloutProps, {}>}
|
|
28
|
-
*/
|
|
29
|
-
export declare class UICallout extends React.Component<UICalloutProps, {}> {
|
|
30
|
-
/**
|
|
31
|
-
* Initializes component properties.
|
|
32
|
-
*
|
|
33
|
-
* @param {UICalloutProps} props
|
|
34
|
-
*/
|
|
35
|
-
constructor(props: UICalloutProps);
|
|
36
|
-
/**
|
|
37
|
-
* Method handles keydown event.
|
|
38
|
-
* If "focusTargetSiblingOnTabPress" property is set and 'Tab' key is pressed,
|
|
39
|
-
* then method tries to focus next/previous sibling based on target.
|
|
40
|
-
*
|
|
41
|
-
* @param event Keydown event
|
|
42
|
-
*/
|
|
43
|
-
private onKeyDown;
|
|
44
|
-
/**
|
|
45
|
-
* @returns {JSX.Element}
|
|
46
|
-
*/
|
|
47
|
-
render(): JSX.Element;
|
|
48
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ICalloutProps, ICalloutContentStyles } from '@fluentui/react';
|
|
3
|
+
export interface UICalloutProps extends ICalloutProps {
|
|
4
|
+
calloutMinWidth?: number;
|
|
5
|
+
contentPadding?: UICalloutContentPadding;
|
|
6
|
+
focusTargetSiblingOnTabPress?: boolean;
|
|
7
|
+
}
|
|
8
|
+
import '../../styles/_shadows.scss';
|
|
9
|
+
export declare const CALLOUT_STYLES: {
|
|
10
|
+
background: string;
|
|
11
|
+
boxShadow: string;
|
|
12
|
+
text: string;
|
|
13
|
+
font: string;
|
|
14
|
+
borderRadius: number;
|
|
15
|
+
};
|
|
16
|
+
export declare enum UICalloutContentPadding {
|
|
17
|
+
None = "None",
|
|
18
|
+
Standard = "Standard"
|
|
19
|
+
}
|
|
20
|
+
export declare const getCalloutStyle: (props: UICalloutProps) => ICalloutContentStyles;
|
|
21
|
+
/**
|
|
22
|
+
* UICallout component.
|
|
23
|
+
* based on https://developer.microsoft.com/en-us/fluentui#/controls/web/callout
|
|
24
|
+
*
|
|
25
|
+
* @exports
|
|
26
|
+
* @class UICallout
|
|
27
|
+
* @extends {React.Component<ICalloutProps, {}>}
|
|
28
|
+
*/
|
|
29
|
+
export declare class UICallout extends React.Component<UICalloutProps, {}> {
|
|
30
|
+
/**
|
|
31
|
+
* Initializes component properties.
|
|
32
|
+
*
|
|
33
|
+
* @param {UICalloutProps} props
|
|
34
|
+
*/
|
|
35
|
+
constructor(props: UICalloutProps);
|
|
36
|
+
/**
|
|
37
|
+
* Method handles keydown event.
|
|
38
|
+
* If "focusTargetSiblingOnTabPress" property is set and 'Tab' key is pressed,
|
|
39
|
+
* then method tries to focus next/previous sibling based on target.
|
|
40
|
+
*
|
|
41
|
+
* @param event Keydown event
|
|
42
|
+
*/
|
|
43
|
+
private onKeyDown;
|
|
44
|
+
/**
|
|
45
|
+
* @returns {JSX.Element}
|
|
46
|
+
*/
|
|
47
|
+
render(): JSX.Element;
|
|
48
|
+
}
|
|
49
49
|
//# sourceMappingURL=UICallout.d.ts.map
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.UICallout = exports.getCalloutStyle = exports.UICalloutContentPadding = exports.CALLOUT_STYLES = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const react_2 = require("@fluentui/react");
|
|
9
|
-
const utilities_1 = require("../../utilities");
|
|
10
|
-
require("../../styles/_shadows.scss");
|
|
11
|
-
exports.CALLOUT_STYLES = {
|
|
12
|
-
background: 'var(--vscode-editorSuggestWidget-background)',
|
|
13
|
-
boxShadow: 'var(--ui-box-shadow-small)',
|
|
14
|
-
text: 'var(--vscode-editorSuggestWidget-foreground)',
|
|
15
|
-
font: 'var(--vscode-font-family)',
|
|
16
|
-
borderRadius: 4
|
|
17
|
-
};
|
|
18
|
-
var UICalloutContentPadding;
|
|
19
|
-
(function (UICalloutContentPadding) {
|
|
20
|
-
UICalloutContentPadding["None"] = "None";
|
|
21
|
-
UICalloutContentPadding["Standard"] = "Standard";
|
|
22
|
-
})(UICalloutContentPadding = exports.UICalloutContentPadding || (exports.UICalloutContentPadding = {}));
|
|
23
|
-
// Control content padding with different states to avoid different hardcoded values across extensions
|
|
24
|
-
const CALLOUT_CONTENT_PADDING = new Map([[UICalloutContentPadding.Standard, 8]]);
|
|
25
|
-
/**
|
|
26
|
-
* Method receives callout style and extracts into raw styles object.
|
|
27
|
-
*
|
|
28
|
-
* @param {IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles> | undefined} styles Callout styles.
|
|
29
|
-
* @param {keyof ICalloutContentStyles} name Callout style type.
|
|
30
|
-
* @returns {IRawStyle} Raw style object.
|
|
31
|
-
*/
|
|
32
|
-
const extractRawStyles = (styles, name) => {
|
|
33
|
-
if (typeof styles === 'object' && typeof styles[name] === 'object') {
|
|
34
|
-
return styles[name];
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
};
|
|
38
|
-
const getCalloutStyle = (props) => {
|
|
39
|
-
return {
|
|
40
|
-
root: {
|
|
41
|
-
boxShadow: exports.CALLOUT_STYLES.boxShadow,
|
|
42
|
-
backgroundColor: 'transparent',
|
|
43
|
-
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
44
|
-
...extractRawStyles(props.styles, 'root')
|
|
45
|
-
},
|
|
46
|
-
beak: {
|
|
47
|
-
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
48
|
-
boxShadow: exports.CALLOUT_STYLES.boxShadow,
|
|
49
|
-
...extractRawStyles(props.styles, 'beak')
|
|
50
|
-
},
|
|
51
|
-
beakCurtain: {
|
|
52
|
-
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
53
|
-
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
54
|
-
...extractRawStyles(props.styles, 'beakCurtain')
|
|
55
|
-
},
|
|
56
|
-
calloutMain: {
|
|
57
|
-
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
58
|
-
color: exports.CALLOUT_STYLES.text,
|
|
59
|
-
fontFamily: exports.CALLOUT_STYLES.font,
|
|
60
|
-
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
61
|
-
minWidth: props.calloutMinWidth ?? 300,
|
|
62
|
-
boxSizing: 'border-box',
|
|
63
|
-
padding: CALLOUT_CONTENT_PADDING.get(props.contentPadding || UICalloutContentPadding.None),
|
|
64
|
-
...extractRawStyles(props.styles, 'calloutMain')
|
|
65
|
-
},
|
|
66
|
-
container: extractRawStyles(props.styles, 'container')
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
exports.getCalloutStyle = getCalloutStyle;
|
|
70
|
-
/**
|
|
71
|
-
* UICallout component.
|
|
72
|
-
* based on https://developer.microsoft.com/en-us/fluentui#/controls/web/callout
|
|
73
|
-
*
|
|
74
|
-
* @exports
|
|
75
|
-
* @class UICallout
|
|
76
|
-
* @extends {React.Component<ICalloutProps, {}>}
|
|
77
|
-
*/
|
|
78
|
-
class UICallout extends react_1.default.Component {
|
|
79
|
-
/**
|
|
80
|
-
* Initializes component properties.
|
|
81
|
-
*
|
|
82
|
-
* @param {UICalloutProps} props
|
|
83
|
-
*/
|
|
84
|
-
constructor(props) {
|
|
85
|
-
super(props);
|
|
86
|
-
this.onKeyDown = this.onKeyDown.bind(this);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Method handles keydown event.
|
|
90
|
-
* If "focusTargetSiblingOnTabPress" property is set and 'Tab' key is pressed,
|
|
91
|
-
* then method tries to focus next/previous sibling based on target.
|
|
92
|
-
*
|
|
93
|
-
* @param event Keydown event
|
|
94
|
-
*/
|
|
95
|
-
onKeyDown(event) {
|
|
96
|
-
const { onKeyDown, focusTargetSiblingOnTabPress, target } = this.props;
|
|
97
|
-
if (focusTargetSiblingOnTabPress && event.key === 'Tab' && target) {
|
|
98
|
-
let targetRef = null;
|
|
99
|
-
if (typeof target === 'string') {
|
|
100
|
-
const currentDoc = (0, react_2.getDocument)();
|
|
101
|
-
targetRef = currentDoc?.querySelector(target);
|
|
102
|
-
}
|
|
103
|
-
else if ('getBoundingClientRect' in target && (0, utilities_1.isHTMLElement)(target)) {
|
|
104
|
-
targetRef = target;
|
|
105
|
-
}
|
|
106
|
-
if (targetRef && (0, utilities_1.focusToSibling)(targetRef, !event.shiftKey)) {
|
|
107
|
-
// Stop event bubbling to avoid default browser behavior
|
|
108
|
-
event.stopPropagation();
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// Call external subscriber
|
|
113
|
-
onKeyDown?.(event);
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* @returns {JSX.Element}
|
|
117
|
-
*/
|
|
118
|
-
render() {
|
|
119
|
-
return (react_1.default.createElement(react_2.Callout, { ...this.props, onKeyDown: this.onKeyDown, styles: (0, exports.getCalloutStyle)(this.props) }, this.props.children));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.UICallout = UICallout;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UICallout = exports.getCalloutStyle = exports.UICalloutContentPadding = exports.CALLOUT_STYLES = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const react_2 = require("@fluentui/react");
|
|
9
|
+
const utilities_1 = require("../../utilities");
|
|
10
|
+
require("../../styles/_shadows.scss");
|
|
11
|
+
exports.CALLOUT_STYLES = {
|
|
12
|
+
background: 'var(--vscode-editorSuggestWidget-background)',
|
|
13
|
+
boxShadow: 'var(--ui-box-shadow-small)',
|
|
14
|
+
text: 'var(--vscode-editorSuggestWidget-foreground)',
|
|
15
|
+
font: 'var(--vscode-font-family)',
|
|
16
|
+
borderRadius: 4
|
|
17
|
+
};
|
|
18
|
+
var UICalloutContentPadding;
|
|
19
|
+
(function (UICalloutContentPadding) {
|
|
20
|
+
UICalloutContentPadding["None"] = "None";
|
|
21
|
+
UICalloutContentPadding["Standard"] = "Standard";
|
|
22
|
+
})(UICalloutContentPadding = exports.UICalloutContentPadding || (exports.UICalloutContentPadding = {}));
|
|
23
|
+
// Control content padding with different states to avoid different hardcoded values across extensions
|
|
24
|
+
const CALLOUT_CONTENT_PADDING = new Map([[UICalloutContentPadding.Standard, 8]]);
|
|
25
|
+
/**
|
|
26
|
+
* Method receives callout style and extracts into raw styles object.
|
|
27
|
+
*
|
|
28
|
+
* @param {IStyleFunctionOrObject<ICalloutContentStyleProps, ICalloutContentStyles> | undefined} styles Callout styles.
|
|
29
|
+
* @param {keyof ICalloutContentStyles} name Callout style type.
|
|
30
|
+
* @returns {IRawStyle} Raw style object.
|
|
31
|
+
*/
|
|
32
|
+
const extractRawStyles = (styles, name) => {
|
|
33
|
+
if (typeof styles === 'object' && typeof styles[name] === 'object') {
|
|
34
|
+
return styles[name];
|
|
35
|
+
}
|
|
36
|
+
return {};
|
|
37
|
+
};
|
|
38
|
+
const getCalloutStyle = (props) => {
|
|
39
|
+
return {
|
|
40
|
+
root: {
|
|
41
|
+
boxShadow: exports.CALLOUT_STYLES.boxShadow,
|
|
42
|
+
backgroundColor: 'transparent',
|
|
43
|
+
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
44
|
+
...extractRawStyles(props.styles, 'root')
|
|
45
|
+
},
|
|
46
|
+
beak: {
|
|
47
|
+
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
48
|
+
boxShadow: exports.CALLOUT_STYLES.boxShadow,
|
|
49
|
+
...extractRawStyles(props.styles, 'beak')
|
|
50
|
+
},
|
|
51
|
+
beakCurtain: {
|
|
52
|
+
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
53
|
+
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
54
|
+
...extractRawStyles(props.styles, 'beakCurtain')
|
|
55
|
+
},
|
|
56
|
+
calloutMain: {
|
|
57
|
+
backgroundColor: exports.CALLOUT_STYLES.background,
|
|
58
|
+
color: exports.CALLOUT_STYLES.text,
|
|
59
|
+
fontFamily: exports.CALLOUT_STYLES.font,
|
|
60
|
+
borderRadius: exports.CALLOUT_STYLES.borderRadius,
|
|
61
|
+
minWidth: props.calloutMinWidth ?? 300,
|
|
62
|
+
boxSizing: 'border-box',
|
|
63
|
+
padding: CALLOUT_CONTENT_PADDING.get(props.contentPadding || UICalloutContentPadding.None),
|
|
64
|
+
...extractRawStyles(props.styles, 'calloutMain')
|
|
65
|
+
},
|
|
66
|
+
container: extractRawStyles(props.styles, 'container')
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
exports.getCalloutStyle = getCalloutStyle;
|
|
70
|
+
/**
|
|
71
|
+
* UICallout component.
|
|
72
|
+
* based on https://developer.microsoft.com/en-us/fluentui#/controls/web/callout
|
|
73
|
+
*
|
|
74
|
+
* @exports
|
|
75
|
+
* @class UICallout
|
|
76
|
+
* @extends {React.Component<ICalloutProps, {}>}
|
|
77
|
+
*/
|
|
78
|
+
class UICallout extends react_1.default.Component {
|
|
79
|
+
/**
|
|
80
|
+
* Initializes component properties.
|
|
81
|
+
*
|
|
82
|
+
* @param {UICalloutProps} props
|
|
83
|
+
*/
|
|
84
|
+
constructor(props) {
|
|
85
|
+
super(props);
|
|
86
|
+
this.onKeyDown = this.onKeyDown.bind(this);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Method handles keydown event.
|
|
90
|
+
* If "focusTargetSiblingOnTabPress" property is set and 'Tab' key is pressed,
|
|
91
|
+
* then method tries to focus next/previous sibling based on target.
|
|
92
|
+
*
|
|
93
|
+
* @param event Keydown event
|
|
94
|
+
*/
|
|
95
|
+
onKeyDown(event) {
|
|
96
|
+
const { onKeyDown, focusTargetSiblingOnTabPress, target } = this.props;
|
|
97
|
+
if (focusTargetSiblingOnTabPress && event.key === 'Tab' && target) {
|
|
98
|
+
let targetRef = null;
|
|
99
|
+
if (typeof target === 'string') {
|
|
100
|
+
const currentDoc = (0, react_2.getDocument)();
|
|
101
|
+
targetRef = currentDoc?.querySelector(target);
|
|
102
|
+
}
|
|
103
|
+
else if ('getBoundingClientRect' in target && (0, utilities_1.isHTMLElement)(target)) {
|
|
104
|
+
targetRef = target;
|
|
105
|
+
}
|
|
106
|
+
if (targetRef && (0, utilities_1.focusToSibling)(targetRef, !event.shiftKey)) {
|
|
107
|
+
// Stop event bubbling to avoid default browser behavior
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Call external subscriber
|
|
113
|
+
onKeyDown?.(event);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* @returns {JSX.Element}
|
|
117
|
+
*/
|
|
118
|
+
render() {
|
|
119
|
+
return (react_1.default.createElement(react_2.Callout, { ...this.props, onKeyDown: this.onKeyDown, styles: (0, exports.getCalloutStyle)(this.props) }, this.props.children));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.UICallout = UICallout;
|
|
123
123
|
//# sourceMappingURL=UICallout.js.map
|