@elastic/eui 88.5.0 → 88.5.2
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/eui_theme_dark.css +8 -21
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +8 -21
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
- package/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +4 -14
- package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +57 -0
- package/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +25 -0
- package/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +156 -0
- package/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +19 -0
- package/es/components/collapsible_nav_beta/collapsible_nav_group/index.js +9 -0
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +16 -63
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +2 -10
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -41
- package/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -3
- package/es/components/combo_box/combo_box.js +12 -25
- package/es/components/combo_box/combo_box_input/combo_box_input.js +61 -54
- package/es/components/text_truncate/index.js +1 -1
- package/es/components/text_truncate/utils.js +88 -138
- package/es/services/canvas/canvas_text_utils.js +64 -0
- package/es/services/canvas/index.js +9 -0
- package/es/services/index.js +1 -0
- package/eui.d.ts +186 -105
- package/i18ntokens.json +8 -8
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
- package/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
- package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +67 -0
- package/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
- package/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +166 -0
- package/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
- package/lib/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +14 -61
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -39
- package/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
- package/lib/components/combo_box/combo_box.js +12 -25
- package/lib/components/combo_box/combo_box_input/combo_box_input.js +60 -53
- package/lib/components/text_truncate/index.js +0 -6
- package/lib/components/text_truncate/utils.js +97 -148
- package/lib/services/canvas/canvas_text_utils.js +70 -0
- package/lib/services/canvas/index.js +12 -0
- package/lib/services/index.js +8 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.js +17 -3
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +4 -14
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.js +56 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +25 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +48 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +19 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_group/index.js +9 -0
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +7 -33
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +2 -10
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +54 -21
- package/optimize/es/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -3
- package/optimize/es/components/combo_box/combo_box.js +12 -25
- package/optimize/es/components/combo_box/combo_box_input/combo_box_input.js +61 -53
- package/optimize/es/components/text_truncate/index.js +1 -1
- package/optimize/es/components/text_truncate/utils.js +87 -137
- package/optimize/es/services/canvas/canvas_text_utils.js +60 -0
- package/optimize/es/services/canvas/index.js +9 -0
- package/optimize/es/services/index.js +1 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.js +15 -1
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.js +66 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +58 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +5 -31
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +54 -20
- package/optimize/lib/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
- package/optimize/lib/components/combo_box/combo_box.js +12 -25
- package/optimize/lib/components/combo_box/combo_box_input/combo_box_input.js +60 -52
- package/optimize/lib/components/text_truncate/index.js +0 -6
- package/optimize/lib/components/text_truncate/utils.js +96 -147
- package/optimize/lib/services/canvas/canvas_text_utils.js +67 -0
- package/optimize/lib/services/canvas/index.js +12 -0
- package/optimize/lib/services/index.js +8 -0
- package/package.json +2 -5
- package/src/components/combo_box/_combo_box.scss +12 -19
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.js +20 -6
- package/test-env/components/collapsible_nav_beta/collapsible_nav_beta.styles.js +11 -19
- package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.js +66 -0
- package/test-env/components/collapsible_nav_beta/collapsible_nav_body_footer.styles.js +33 -0
- package/test-env/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.js +165 -0
- package/test-env/components/collapsible_nav_beta/collapsible_nav_group/collapsible_nav_group.styles.js +26 -0
- package/test-env/components/collapsible_nav_beta/collapsible_nav_group/index.js +12 -0
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_button.js +3 -7
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_item.js +3 -7
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsed/collapsed_nav_popover.js +4 -8
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.js +14 -61
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_accordion.styles.js +1 -9
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.js +122 -39
- package/test-env/components/collapsible_nav_beta/collapsible_nav_item/collapsible_nav_item.styles.js +13 -4
- package/test-env/components/combo_box/combo_box.js +12 -25
- package/test-env/components/combo_box/combo_box_input/combo_box_input.js +60 -53
- package/test-env/components/text_truncate/index.js +0 -6
- package/test-env/components/text_truncate/utils.js +96 -147
- package/test-env/services/canvas/canvas_text_utils.js +30 -0
- package/test-env/services/canvas/index.js +12 -0
- package/test-env/services/index.js +8 -0
|
@@ -86,10 +86,6 @@ export var EuiComboBox = /*#__PURE__*/function (_Component) {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
-
_defineProperty(_assertThisInitialized(_this), "autoSizeInputRefInstance", null);
|
|
90
|
-
_defineProperty(_assertThisInitialized(_this), "autoSizeInputRefCallback", function (ref) {
|
|
91
|
-
_this.autoSizeInputRefInstance = ref;
|
|
92
|
-
});
|
|
93
89
|
_defineProperty(_assertThisInitialized(_this), "searchInputRefInstance", null);
|
|
94
90
|
_defineProperty(_assertThisInitialized(_this), "searchInputRefCallback", function (ref) {
|
|
95
91
|
_this.searchInputRefInstance = ref;
|
|
@@ -562,15 +558,7 @@ export var EuiComboBox = /*#__PURE__*/function (_Component) {
|
|
|
562
558
|
_createClass(EuiComboBox, [{
|
|
563
559
|
key: "componentDidMount",
|
|
564
560
|
value: function componentDidMount() {
|
|
565
|
-
var _this2 = this;
|
|
566
561
|
this._isMounted = true;
|
|
567
|
-
|
|
568
|
-
// TODO: This will need to be called once the actual stylesheet loads.
|
|
569
|
-
setTimeout(function () {
|
|
570
|
-
if (_this2.autoSizeInputRefInstance) {
|
|
571
|
-
_this2.autoSizeInputRefInstance.copyInputStyles();
|
|
572
|
-
}
|
|
573
|
-
}, 100);
|
|
574
562
|
}
|
|
575
563
|
}, {
|
|
576
564
|
key: "componentDidUpdate",
|
|
@@ -603,7 +591,7 @@ export var EuiComboBox = /*#__PURE__*/function (_Component) {
|
|
|
603
591
|
}, {
|
|
604
592
|
key: "render",
|
|
605
593
|
value: function render() {
|
|
606
|
-
var
|
|
594
|
+
var _this2 = this;
|
|
607
595
|
var _this$props8 = this.props,
|
|
608
596
|
dataTestSubj = _this$props8['data-test-subj'],
|
|
609
597
|
async = _this$props8.async,
|
|
@@ -674,32 +662,32 @@ export var EuiComboBox = /*#__PURE__*/function (_Component) {
|
|
|
674
662
|
default: "Choose from the following options"
|
|
675
663
|
}, function (listboxAriaLabel) {
|
|
676
664
|
return ___EmotionJSX(EuiComboBoxOptionsList, {
|
|
677
|
-
zIndex:
|
|
678
|
-
activeOptionIndex:
|
|
679
|
-
areAllOptionsSelected:
|
|
665
|
+
zIndex: _this2.state.listZIndex,
|
|
666
|
+
activeOptionIndex: _this2.state.activeOptionIndex,
|
|
667
|
+
areAllOptionsSelected: _this2.areAllOptionsSelected(),
|
|
680
668
|
customOptionText: customOptionText,
|
|
681
669
|
"data-test-subj": optionsListDataTestSubj,
|
|
682
670
|
fullWidth: fullWidth,
|
|
683
671
|
isCaseSensitive: isCaseSensitive,
|
|
684
672
|
isLoading: isLoading,
|
|
685
|
-
listRef:
|
|
673
|
+
listRef: _this2.listRefCallback,
|
|
686
674
|
matchingOptions: matchingOptions,
|
|
687
|
-
onCloseList:
|
|
675
|
+
onCloseList: _this2.closeList,
|
|
688
676
|
onCreateOption: onCreateOption,
|
|
689
|
-
onOptionClick:
|
|
690
|
-
onOptionEnterKey:
|
|
691
|
-
onScroll:
|
|
692
|
-
optionRef:
|
|
677
|
+
onOptionClick: _this2.onOptionClick,
|
|
678
|
+
onOptionEnterKey: _this2.onOptionEnterKey,
|
|
679
|
+
onScroll: _this2.onOptionListScroll,
|
|
680
|
+
optionRef: _this2.optionRefCallback,
|
|
693
681
|
options: options,
|
|
694
682
|
position: listPosition,
|
|
695
683
|
singleSelection: singleSelection,
|
|
696
684
|
renderOption: renderOption,
|
|
697
|
-
rootId:
|
|
685
|
+
rootId: _this2.rootId,
|
|
698
686
|
rowHeight: rowHeight,
|
|
699
687
|
scrollToIndex: activeOptionIndex,
|
|
700
688
|
searchValue: searchValue,
|
|
701
689
|
selectedOptions: selectedOptions,
|
|
702
|
-
updatePosition:
|
|
690
|
+
updatePosition: _this2.updatePosition,
|
|
703
691
|
width: width,
|
|
704
692
|
delimiter: delimiter,
|
|
705
693
|
getSelectedOptionForSearchValue: getSelectedOptionForSearchValue,
|
|
@@ -723,7 +711,6 @@ export var EuiComboBox = /*#__PURE__*/function (_Component) {
|
|
|
723
711
|
onBlur: this.onContainerBlur,
|
|
724
712
|
ref: this.comboBoxRefCallback
|
|
725
713
|
}), ___EmotionJSX(EuiComboBoxInput, {
|
|
726
|
-
autoSizeInputRef: this.autoSizeInputRefCallback,
|
|
727
714
|
compressed: compressed,
|
|
728
715
|
focusedOptionId: this.hasActiveOption() ? this.rootId("_option-".concat(this.state.activeOptionIndex)) : undefined,
|
|
729
716
|
fullWidth: fullWidth,
|
|
@@ -21,8 +21,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
21
21
|
|
|
22
22
|
import React, { Component } from 'react';
|
|
23
23
|
import classNames from 'classnames';
|
|
24
|
-
import
|
|
25
|
-
import { keys } from '../../../services';
|
|
24
|
+
import { keys, CanvasTextUtils } from '../../../services';
|
|
26
25
|
import { EuiScreenReaderOnly } from '../../accessibility';
|
|
27
26
|
import { EuiFormControlLayout } from '../../form/form_control_layout';
|
|
28
27
|
import { getFormControlClassNameForIconCount } from '../../form/form_control_layout/_num_icons';
|
|
@@ -39,8 +38,27 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
39
38
|
}
|
|
40
39
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
40
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
41
|
+
inputWidth: 2,
|
|
42
42
|
hasFocus: false
|
|
43
43
|
});
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "widthUtils", void 0);
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "inputRefCallback", function (el) {
|
|
46
|
+
var _this$props$inputRef, _this$props;
|
|
47
|
+
_this.widthUtils = new CanvasTextUtils({
|
|
48
|
+
container: el
|
|
49
|
+
});
|
|
50
|
+
(_this$props$inputRef = (_this$props = _this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, el);
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "updateInputSize", function (inputValue) {
|
|
53
|
+
if (!_this.widthUtils) return;
|
|
54
|
+
_this.widthUtils.setTextToCheck(inputValue);
|
|
55
|
+
// Canvas has minute subpixel differences in rendering compared to DOM
|
|
56
|
+
// We'll buffer the input by ~2px just to ensure sufficient width
|
|
57
|
+
var inputWidth = Math.ceil(_this.widthUtils.textWidth) + 2;
|
|
58
|
+
_this.setState({
|
|
59
|
+
inputWidth: inputWidth
|
|
60
|
+
});
|
|
61
|
+
});
|
|
44
62
|
_defineProperty(_assertThisInitialized(_this), "updatePosition", function () {
|
|
45
63
|
// Wait a beat for the DOM to update, since we depend on DOM elements' bounds.
|
|
46
64
|
requestAnimationFrame(function () {
|
|
@@ -62,13 +80,13 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
62
80
|
});
|
|
63
81
|
});
|
|
64
82
|
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
65
|
-
var _this$
|
|
66
|
-
searchValue = _this$
|
|
67
|
-
selectedOptions = _this$
|
|
68
|
-
onRemoveOption = _this$
|
|
69
|
-
singleSelection = _this$
|
|
70
|
-
isListOpen = _this$
|
|
71
|
-
onOpenListClick = _this$
|
|
83
|
+
var _this$props2 = _this.props,
|
|
84
|
+
searchValue = _this$props2.searchValue,
|
|
85
|
+
selectedOptions = _this$props2.selectedOptions,
|
|
86
|
+
onRemoveOption = _this$props2.onRemoveOption,
|
|
87
|
+
singleSelection = _this$props2.singleSelection,
|
|
88
|
+
isListOpen = _this$props2.isListOpen,
|
|
89
|
+
onOpenListClick = _this$props2.onOpenListClick;
|
|
72
90
|
|
|
73
91
|
// When backspacing from an empty input, delete the last pill option in the list
|
|
74
92
|
var searchIsEmpty = !searchValue.length;
|
|
@@ -81,18 +99,10 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
81
99
|
}
|
|
82
100
|
});
|
|
83
101
|
_defineProperty(_assertThisInitialized(_this), "inputOnChange", function (event) {
|
|
84
|
-
var _this$
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onChange(event.target.value);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
_defineProperty(_assertThisInitialized(_this), "inputRefCallback", function (ref) {
|
|
92
|
-
var autoSizeInputRef = _this.props.autoSizeInputRef;
|
|
93
|
-
if (autoSizeInputRef) {
|
|
94
|
-
autoSizeInputRef(ref);
|
|
95
|
-
}
|
|
102
|
+
var _this$props$onChange, _this$props3;
|
|
103
|
+
var value = event.target.value;
|
|
104
|
+
_this.updateInputSize(value);
|
|
105
|
+
(_this$props$onChange = (_this$props3 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props3, value);
|
|
96
106
|
});
|
|
97
107
|
return _this;
|
|
98
108
|
}
|
|
@@ -110,35 +120,34 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
110
120
|
}, {
|
|
111
121
|
key: "render",
|
|
112
122
|
value: function render() {
|
|
113
|
-
var _this$
|
|
114
|
-
compressed = _this$
|
|
115
|
-
focusedOptionId = _this$
|
|
116
|
-
fullWidth = _this$
|
|
117
|
-
hasSelectedOptions = _this$
|
|
118
|
-
id = _this$
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
ariaLabelledby = _this$props3['aria-labelledby'];
|
|
123
|
+
var _this$props4 = this.props,
|
|
124
|
+
compressed = _this$props4.compressed,
|
|
125
|
+
focusedOptionId = _this$props4.focusedOptionId,
|
|
126
|
+
fullWidth = _this$props4.fullWidth,
|
|
127
|
+
hasSelectedOptions = _this$props4.hasSelectedOptions,
|
|
128
|
+
id = _this$props4.id,
|
|
129
|
+
isDisabled = _this$props4.isDisabled,
|
|
130
|
+
isListOpen = _this$props4.isListOpen,
|
|
131
|
+
noIcon = _this$props4.noIcon,
|
|
132
|
+
onClear = _this$props4.onClear,
|
|
133
|
+
onClick = _this$props4.onClick,
|
|
134
|
+
onCloseListClick = _this$props4.onCloseListClick,
|
|
135
|
+
onOpenListClick = _this$props4.onOpenListClick,
|
|
136
|
+
onRemoveOption = _this$props4.onRemoveOption,
|
|
137
|
+
placeholder = _this$props4.placeholder,
|
|
138
|
+
rootId = _this$props4.rootId,
|
|
139
|
+
searchValue = _this$props4.searchValue,
|
|
140
|
+
selectedOptions = _this$props4.selectedOptions,
|
|
141
|
+
singleSelectionProp = _this$props4.singleSelection,
|
|
142
|
+
toggleButtonRef = _this$props4.toggleButtonRef,
|
|
143
|
+
value = _this$props4.value,
|
|
144
|
+
prepend = _this$props4.prepend,
|
|
145
|
+
append = _this$props4.append,
|
|
146
|
+
isLoading = _this$props4.isLoading,
|
|
147
|
+
isInvalid = _this$props4.isInvalid,
|
|
148
|
+
autoFocus = _this$props4.autoFocus,
|
|
149
|
+
ariaLabel = _this$props4['aria-label'],
|
|
150
|
+
ariaLabelledby = _this$props4['aria-labelledby'];
|
|
142
151
|
var singleSelection = Boolean(singleSelectionProp);
|
|
143
152
|
var asPlainText = singleSelectionProp && _typeof(singleSelectionProp) === 'object' && singleSelectionProp.asPlainText || false;
|
|
144
153
|
var pills = selectedOptions ? selectedOptions.map(function (option) {
|
|
@@ -230,7 +239,7 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
230
239
|
"data-test-subj": "comboBoxInput",
|
|
231
240
|
onClick: onClick,
|
|
232
241
|
tabIndex: -1 // becomes onBlur event's relatedTarget, otherwise relatedTarget is null when clicking on this div
|
|
233
|
-
}, !singleSelection || !searchValue ? pills : null, placeholderMessage, ___EmotionJSX(
|
|
242
|
+
}, !singleSelection || !searchValue ? pills : null, placeholderMessage, ___EmotionJSX("input", {
|
|
234
243
|
"aria-activedescendant": focusedOptionId,
|
|
235
244
|
"aria-autocomplete": "list",
|
|
236
245
|
"aria-controls": isListOpen ? rootId('listbox') : '',
|
|
@@ -242,7 +251,6 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
242
251
|
"data-test-subj": "comboBoxSearchInput",
|
|
243
252
|
disabled: isDisabled,
|
|
244
253
|
id: id,
|
|
245
|
-
inputRef: inputRef,
|
|
246
254
|
onBlur: this.onBlur,
|
|
247
255
|
onChange: this.inputOnChange,
|
|
248
256
|
onFocus: this.onFocus,
|
|
@@ -250,7 +258,7 @@ export var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
250
258
|
ref: this.inputRefCallback,
|
|
251
259
|
role: "combobox",
|
|
252
260
|
style: {
|
|
253
|
-
|
|
261
|
+
inlineSize: this.state.inputWidth
|
|
254
262
|
},
|
|
255
263
|
value: searchValue,
|
|
256
264
|
autoFocus: autoFocus
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
5
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
6
|
import _get from "@babel/runtime/helpers/get";
|
|
5
7
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
8
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
9
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
11
|
var _excluded = ["fullText", "ellipsis", "availableWidth"];
|
|
12
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -19,57 +19,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
19
19
|
* Side Public License, v 1.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
* Under the hood, a temporary Canvas element is created for manipulating text
|
|
24
|
-
* & determining text width.
|
|
25
|
-
*
|
|
26
|
-
* To accurately measure text, canvas rendering requires either a container to
|
|
27
|
-
* compute/derive font styles from, or a static font string (useful for usage
|
|
28
|
-
* outside the DOM). Particular care should be applied when fallback fonts are
|
|
29
|
-
* used, as more fallback fonts can lead to less precision.
|
|
30
|
-
*
|
|
31
|
-
* Please note that while canvas is more significantly more performant than DOM
|
|
32
|
-
* measurement, there are subpixel to single digit pixel differences between
|
|
33
|
-
* DOM and canvas measurement due to the different rendering engines used.
|
|
34
|
-
*/
|
|
35
|
-
export var CanvasTextUtils = /*#__PURE__*/function () {
|
|
36
|
-
function CanvasTextUtils(_ref) {
|
|
37
|
-
var _this = this;
|
|
38
|
-
var font = _ref.font,
|
|
39
|
-
container = _ref.container;
|
|
40
|
-
_classCallCheck(this, CanvasTextUtils);
|
|
41
|
-
_defineProperty(this, "context", void 0);
|
|
42
|
-
_defineProperty(this, "currentText", '');
|
|
43
|
-
_defineProperty(this, "computeFontFromElement", function (element) {
|
|
44
|
-
var computedStyles = window.getComputedStyle(element);
|
|
45
|
-
// TODO: font-stretch is not included even though it potentially should be
|
|
46
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/font#constituent_properties
|
|
47
|
-
// It appears to be unsupported and/or breaks font computation in canvas
|
|
48
|
-
return ['font-style', 'font-variant', 'font-weight', 'font-size', 'font-family'].map(function (prop) {
|
|
49
|
-
return computedStyles.getPropertyValue(prop);
|
|
50
|
-
}).join(' ').trim();
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(this, "setTextToCheck", function (text) {
|
|
53
|
-
_this.currentText = text;
|
|
54
|
-
});
|
|
55
|
-
this.context = document.createElement('canvas').getContext('2d');
|
|
56
|
-
|
|
57
|
-
// Set the canvas font to ensure text width calculations are correct
|
|
58
|
-
if (font) {
|
|
59
|
-
this.context.font = font;
|
|
60
|
-
} else if (container) {
|
|
61
|
-
this.context.font = this.computeFontFromElement(container);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
_createClass(CanvasTextUtils, [{
|
|
65
|
-
key: "textWidth",
|
|
66
|
-
get: function get() {
|
|
67
|
-
return this.context.measureText(this.currentText).width;
|
|
68
|
-
}
|
|
69
|
-
}]);
|
|
70
|
-
return CanvasTextUtils;
|
|
71
|
-
}();
|
|
72
|
-
|
|
22
|
+
import { CanvasTextUtils } from '../../services/canvas';
|
|
73
23
|
/**
|
|
74
24
|
* Utilities for truncating types at various positions, as well as
|
|
75
25
|
* determining whether truncation is possible or even necessary.
|
|
@@ -77,22 +27,22 @@ export var CanvasTextUtils = /*#__PURE__*/function () {
|
|
|
77
27
|
export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
78
28
|
_inherits(TruncationUtils, _CanvasTextUtils);
|
|
79
29
|
var _super = _createSuper(TruncationUtils);
|
|
80
|
-
function TruncationUtils(
|
|
81
|
-
var
|
|
82
|
-
var fullText =
|
|
83
|
-
ellipsis =
|
|
84
|
-
_availableWidth =
|
|
85
|
-
rest = _objectWithoutProperties(
|
|
30
|
+
function TruncationUtils(_ref) {
|
|
31
|
+
var _this;
|
|
32
|
+
var fullText = _ref.fullText,
|
|
33
|
+
ellipsis = _ref.ellipsis,
|
|
34
|
+
_availableWidth = _ref.availableWidth,
|
|
35
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
86
36
|
_classCallCheck(this, TruncationUtils);
|
|
87
|
-
|
|
88
|
-
_defineProperty(_assertThisInitialized(
|
|
89
|
-
_defineProperty(_assertThisInitialized(
|
|
90
|
-
_defineProperty(_assertThisInitialized(
|
|
37
|
+
_this = _super.call(this, rest);
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "fullText", void 0);
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "ellipsis", void 0);
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "availableWidth", void 0);
|
|
91
41
|
/**
|
|
92
42
|
* Performance utilities
|
|
93
43
|
*/
|
|
94
|
-
_defineProperty(_assertThisInitialized(
|
|
95
|
-
_defineProperty(_assertThisInitialized(
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "debugPerformance", false);
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "debugCounter", 0);
|
|
96
46
|
/**
|
|
97
47
|
* Internal utils for calculating a ratio based on the passed available width
|
|
98
48
|
* vs the full text width.
|
|
@@ -100,21 +50,21 @@ export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
|
100
50
|
* be slightly over the available width, which we can then remove from
|
|
101
51
|
* character-by-character until the text just fits within the available width.
|
|
102
52
|
*/
|
|
103
|
-
_defineProperty(_assertThisInitialized(
|
|
104
|
-
_defineProperty(_assertThisInitialized(
|
|
105
|
-
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "widthRatio", 0);
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "setTextWidthRatio", function () {
|
|
55
|
+
var text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.fullText;
|
|
106
56
|
var textToOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
107
57
|
// Account for reduced available width due to (e.g.) truncation offset
|
|
108
|
-
var availableWidth =
|
|
58
|
+
var availableWidth = _this.availableWidth;
|
|
109
59
|
if (textToOffset) {
|
|
110
|
-
|
|
111
|
-
availableWidth = availableWidth -
|
|
60
|
+
_this.setTextToCheck(textToOffset);
|
|
61
|
+
availableWidth = availableWidth - _this.textWidth;
|
|
112
62
|
}
|
|
113
|
-
|
|
114
|
-
|
|
63
|
+
_this.setTextToCheck(text);
|
|
64
|
+
_this.widthRatio = availableWidth / _this.textWidth;
|
|
115
65
|
});
|
|
116
|
-
_defineProperty(_assertThisInitialized(
|
|
117
|
-
var characterRatio = Math.ceil(text.length *
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "getTextFromRatio", function (text, type) {
|
|
67
|
+
var characterRatio = Math.ceil(text.length * _this.widthRatio);
|
|
118
68
|
var index = type === 'start' ? text.length - characterRatio : characterRatio;
|
|
119
69
|
var _splitText$at = splitText(text).at(index),
|
|
120
70
|
_splitText$at2 = _slicedToArray(_splitText$at, 2),
|
|
@@ -125,24 +75,24 @@ export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
|
125
75
|
/**
|
|
126
76
|
* Early return checks
|
|
127
77
|
*/
|
|
128
|
-
_defineProperty(_assertThisInitialized(
|
|
129
|
-
|
|
130
|
-
if (
|
|
78
|
+
_defineProperty(_assertThisInitialized(_this), "checkIfTruncationIsNeeded", function () {
|
|
79
|
+
_this.setTextToCheck(_this.fullText);
|
|
80
|
+
if (_this.availableWidth >= _this.textWidth) {
|
|
131
81
|
return false;
|
|
132
82
|
}
|
|
133
83
|
});
|
|
134
|
-
_defineProperty(_assertThisInitialized(
|
|
135
|
-
var textToCheck = truncation === 'startEnd' ? "".concat(
|
|
136
|
-
:
|
|
137
|
-
|
|
138
|
-
if (
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "checkSufficientEllipsisWidth", function (truncation) {
|
|
85
|
+
var textToCheck = truncation === 'startEnd' ? "".concat(_this.ellipsis, " ").concat(_this.ellipsis) // startEnd needs a little more space
|
|
86
|
+
: _this.ellipsis;
|
|
87
|
+
_this.setTextToCheck(textToCheck);
|
|
88
|
+
if (_this.textWidth >= _this.availableWidth * 0.9) {
|
|
139
89
|
console.error('The truncation ellipsis is larger than the available width. No text can be rendered.');
|
|
140
90
|
return false;
|
|
141
91
|
}
|
|
142
92
|
});
|
|
143
|
-
_defineProperty(_assertThisInitialized(
|
|
144
|
-
|
|
145
|
-
if (
|
|
93
|
+
_defineProperty(_assertThisInitialized(_this), "checkTruncationOffsetWidth", function (text) {
|
|
94
|
+
_this.setTextToCheck(text);
|
|
95
|
+
if (_this.textWidth > _this.availableWidth) {
|
|
146
96
|
console.error('The passed truncationOffset is too large for the available width. Truncating the offset instead.');
|
|
147
97
|
return false;
|
|
148
98
|
}
|
|
@@ -150,19 +100,19 @@ export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
|
150
100
|
/**
|
|
151
101
|
* Truncation types logic. This is where the magic happens
|
|
152
102
|
*/
|
|
153
|
-
_defineProperty(_assertThisInitialized(
|
|
154
|
-
var truncatedText =
|
|
103
|
+
_defineProperty(_assertThisInitialized(_this), "truncateStart", function (truncationOffset) {
|
|
104
|
+
var truncatedText = _this.fullText;
|
|
155
105
|
var leadingText = '';
|
|
156
106
|
var combinedText = function combinedText() {
|
|
157
107
|
return leadingText + truncatedText;
|
|
158
108
|
};
|
|
159
109
|
if (truncationOffset) {
|
|
160
|
-
var _splitText$at3 = splitText(
|
|
110
|
+
var _splitText$at3 = splitText(_this.fullText).at(truncationOffset);
|
|
161
111
|
var _splitText$at4 = _slicedToArray(_splitText$at3, 2);
|
|
162
112
|
leadingText = _splitText$at4[0];
|
|
163
113
|
truncatedText = _splitText$at4[1];
|
|
164
|
-
var widthCheck = leadingText +
|
|
165
|
-
if (
|
|
114
|
+
var widthCheck = leadingText + _this.ellipsis;
|
|
115
|
+
if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
166
116
|
truncatedText = leadingText;
|
|
167
117
|
leadingText = '';
|
|
168
118
|
}
|
|
@@ -170,30 +120,30 @@ export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
|
170
120
|
|
|
171
121
|
// Get text width ratio width accounting for any truncation offset text,
|
|
172
122
|
// and guesstimate an initial truncated string
|
|
173
|
-
|
|
174
|
-
truncatedText =
|
|
175
|
-
leadingText +=
|
|
176
|
-
|
|
177
|
-
while (
|
|
123
|
+
_this.setTextWidthRatio(truncatedText, leadingText);
|
|
124
|
+
truncatedText = _this.getTextFromRatio(truncatedText, 'start');
|
|
125
|
+
leadingText += _this.ellipsis;
|
|
126
|
+
_this.setTextToCheck(combinedText());
|
|
127
|
+
while (_this.textWidth > _this.availableWidth) {
|
|
178
128
|
truncatedText = removeFirstCharacter(truncatedText);
|
|
179
|
-
|
|
129
|
+
_this.setTextToCheck(combinedText());
|
|
180
130
|
}
|
|
181
131
|
return combinedText();
|
|
182
132
|
});
|
|
183
|
-
_defineProperty(_assertThisInitialized(
|
|
184
|
-
var truncatedText =
|
|
133
|
+
_defineProperty(_assertThisInitialized(_this), "truncateEnd", function (truncationOffset) {
|
|
134
|
+
var truncatedText = _this.fullText;
|
|
185
135
|
var trailingText = '';
|
|
186
136
|
var combinedText = function combinedText() {
|
|
187
137
|
return truncatedText + trailingText;
|
|
188
138
|
};
|
|
189
139
|
if (truncationOffset) {
|
|
190
|
-
var index =
|
|
191
|
-
var _splitText$at5 = splitText(
|
|
140
|
+
var index = _this.fullText.length - truncationOffset;
|
|
141
|
+
var _splitText$at5 = splitText(_this.fullText).at(index);
|
|
192
142
|
var _splitText$at6 = _slicedToArray(_splitText$at5, 2);
|
|
193
143
|
truncatedText = _splitText$at6[0];
|
|
194
144
|
trailingText = _splitText$at6[1];
|
|
195
|
-
var widthCheck =
|
|
196
|
-
if (
|
|
145
|
+
var widthCheck = _this.ellipsis + trailingText;
|
|
146
|
+
if (_this.checkTruncationOffsetWidth(widthCheck) === false) {
|
|
197
147
|
truncatedText = trailingText;
|
|
198
148
|
trailingText = '';
|
|
199
149
|
}
|
|
@@ -201,78 +151,78 @@ export var TruncationUtils = /*#__PURE__*/function (_CanvasTextUtils) {
|
|
|
201
151
|
|
|
202
152
|
// Get text width ratio width accounting for any truncation offset text,
|
|
203
153
|
// and guesstimate an initial truncated string
|
|
204
|
-
|
|
205
|
-
truncatedText =
|
|
206
|
-
trailingText =
|
|
207
|
-
|
|
208
|
-
while (
|
|
154
|
+
_this.setTextWidthRatio(truncatedText, trailingText);
|
|
155
|
+
truncatedText = _this.getTextFromRatio(truncatedText, 'end');
|
|
156
|
+
trailingText = _this.ellipsis + trailingText;
|
|
157
|
+
_this.setTextToCheck(combinedText());
|
|
158
|
+
while (_this.textWidth > _this.availableWidth) {
|
|
209
159
|
truncatedText = removeLastCharacter(truncatedText);
|
|
210
|
-
|
|
160
|
+
_this.setTextToCheck(combinedText());
|
|
211
161
|
}
|
|
212
162
|
return combinedText();
|
|
213
163
|
});
|
|
214
|
-
_defineProperty(_assertThisInitialized(
|
|
164
|
+
_defineProperty(_assertThisInitialized(_this), "truncateStartEndAtPosition", function (truncationPosition) {
|
|
215
165
|
// Split the text from the anchor position, using the width ratio
|
|
216
166
|
// to get the starting and ending indices from the position
|
|
217
|
-
|
|
218
|
-
var characterRatio = Math.floor(
|
|
167
|
+
_this.setTextWidthRatio();
|
|
168
|
+
var characterRatio = Math.floor(_this.fullText.length * _this.widthRatio / 2);
|
|
219
169
|
var truncateStart = truncationPosition - characterRatio;
|
|
220
170
|
var truncateEnd = truncationPosition + characterRatio;
|
|
221
171
|
|
|
222
172
|
// If either of the approximate start/end truncation indices go beyond the
|
|
223
173
|
// bounds of the actual text, we can simply use end or start truncation instead
|
|
224
174
|
if (truncateStart < 0) {
|
|
225
|
-
return
|
|
175
|
+
return _this.truncateEnd();
|
|
226
176
|
}
|
|
227
|
-
if (truncateEnd >=
|
|
228
|
-
return
|
|
177
|
+
if (truncateEnd >= _this.fullText.length) {
|
|
178
|
+
return _this.truncateStart();
|
|
229
179
|
}
|
|
230
|
-
var truncatedText =
|
|
180
|
+
var truncatedText = _this.fullText.substring(truncateStart, truncateEnd);
|
|
231
181
|
var combinedText = function combinedText() {
|
|
232
|
-
return
|
|
182
|
+
return _this.ellipsis + truncatedText + _this.ellipsis;
|
|
233
183
|
};
|
|
234
|
-
|
|
184
|
+
_this.setTextToCheck(combinedText());
|
|
235
185
|
var alternating;
|
|
236
|
-
while (
|
|
186
|
+
while (_this.textWidth > _this.availableWidth) {
|
|
237
187
|
truncatedText = alternating ? removeLastCharacter(truncatedText) : removeFirstCharacter(truncatedText);
|
|
238
188
|
alternating = !alternating;
|
|
239
|
-
|
|
189
|
+
_this.setTextToCheck(combinedText());
|
|
240
190
|
}
|
|
241
191
|
return combinedText();
|
|
242
192
|
});
|
|
243
|
-
_defineProperty(_assertThisInitialized(
|
|
244
|
-
var middlePosition = Math.floor(
|
|
245
|
-
return
|
|
193
|
+
_defineProperty(_assertThisInitialized(_this), "truncateStartEndAtMiddle", function () {
|
|
194
|
+
var middlePosition = Math.floor(_this.fullText.length / 2);
|
|
195
|
+
return _this.truncateStartEndAtPosition(middlePosition);
|
|
246
196
|
});
|
|
247
|
-
_defineProperty(_assertThisInitialized(
|
|
248
|
-
var middlePosition = Math.floor(
|
|
249
|
-
var _splitText$at7 = splitText(
|
|
197
|
+
_defineProperty(_assertThisInitialized(_this), "truncateMiddle", function () {
|
|
198
|
+
var middlePosition = Math.floor(_this.fullText.length / 2);
|
|
199
|
+
var _splitText$at7 = splitText(_this.fullText).at(middlePosition),
|
|
250
200
|
_splitText$at8 = _slicedToArray(_splitText$at7, 2),
|
|
251
201
|
firstHalf = _splitText$at8[0],
|
|
252
202
|
secondHalf = _splitText$at8[1];
|
|
253
|
-
|
|
254
|
-
firstHalf =
|
|
255
|
-
secondHalf =
|
|
203
|
+
_this.setTextWidthRatio();
|
|
204
|
+
firstHalf = _this.getTextFromRatio(firstHalf, 'end');
|
|
205
|
+
secondHalf = _this.getTextFromRatio(secondHalf, 'start');
|
|
256
206
|
var combinedText = function combinedText() {
|
|
257
|
-
return firstHalf +
|
|
207
|
+
return firstHalf + _this.ellipsis + secondHalf;
|
|
258
208
|
};
|
|
259
|
-
|
|
209
|
+
_this.setTextToCheck(combinedText());
|
|
260
210
|
var alternating;
|
|
261
|
-
while (
|
|
211
|
+
while (_this.textWidth > _this.availableWidth) {
|
|
262
212
|
alternating = !alternating;
|
|
263
213
|
if (alternating) {
|
|
264
214
|
firstHalf = removeLastCharacter(firstHalf);
|
|
265
215
|
} else {
|
|
266
216
|
secondHalf = removeFirstCharacter(secondHalf);
|
|
267
217
|
}
|
|
268
|
-
|
|
218
|
+
_this.setTextToCheck(combinedText());
|
|
269
219
|
}
|
|
270
220
|
return combinedText();
|
|
271
221
|
});
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return
|
|
222
|
+
_this.fullText = fullText;
|
|
223
|
+
_this.ellipsis = ellipsis;
|
|
224
|
+
_this.availableWidth = _availableWidth;
|
|
225
|
+
return _this;
|
|
276
226
|
}
|
|
277
227
|
_createClass(TruncationUtils, [{
|
|
278
228
|
key: "textWidth",
|