@elastic/eui 88.5.1 → 88.5.3
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/es/components/combo_box/combo_box_input/combo_box_input.js +39 -43
- package/es/components/text_truncate/index.js +1 -1
- package/es/components/text_truncate/text_truncate.js +5 -2
- 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 +40 -31
- package/lib/components/combo_box/combo_box_input/combo_box_input.js +39 -43
- package/lib/components/text_truncate/index.js +0 -6
- package/lib/components/text_truncate/text_truncate.js +5 -2
- 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/combo_box/combo_box_input/combo_box_input.js +37 -41
- package/optimize/es/components/text_truncate/index.js +1 -1
- package/optimize/es/components/text_truncate/text_truncate.js +5 -2
- 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/combo_box/combo_box_input/combo_box_input.js +37 -41
- package/optimize/lib/components/text_truncate/index.js +0 -6
- package/optimize/lib/components/text_truncate/text_truncate.js +5 -2
- 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 +6 -5
- package/test-env/components/combo_box/combo_box_input/combo_box_input.js +39 -43
- package/test-env/components/text_truncate/index.js +0 -6
- package/test-env/components/text_truncate/text_truncate.js +5 -2
- package/test-env/components/text_truncate/utils.js +232 -38
- 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
package/eui.d.ts
CHANGED
|
@@ -8032,6 +8032,40 @@ declare module '@elastic/eui/src/services/breakpoint' {
|
|
|
8032
8032
|
export * from '@elastic/eui/src/services/breakpoint/current_breakpoint_hook';
|
|
8033
8033
|
export * from '@elastic/eui/src/services/breakpoint/is_within_hooks';
|
|
8034
8034
|
|
|
8035
|
+
}
|
|
8036
|
+
declare module '@elastic/eui/src/services/canvas/canvas_text_utils' {
|
|
8037
|
+
import type { ExclusiveUnion } from '@elastic/eui/src/components/common';
|
|
8038
|
+
export type CanvasTextParams = ExclusiveUnion<{
|
|
8039
|
+
container: HTMLElement;
|
|
8040
|
+
}, {
|
|
8041
|
+
font: CanvasTextDrawingStyles['font'];
|
|
8042
|
+
}>;
|
|
8043
|
+
/**
|
|
8044
|
+
* Creates a temporary Canvas element for manipulating text & determining text width.
|
|
8045
|
+
*
|
|
8046
|
+
* To accurately measure text, canvas rendering requires either a container to
|
|
8047
|
+
* compute/derive font styles from, or a static font string (useful for usage
|
|
8048
|
+
* outside the DOM). Particular care should be applied when fallback fonts are
|
|
8049
|
+
* used, as more fallback fonts can lead to less precision.
|
|
8050
|
+
*
|
|
8051
|
+
* Please note that while canvas is more significantly more performant than DOM
|
|
8052
|
+
* measurement, there are subpixel to single digit pixel differences between
|
|
8053
|
+
* DOM and canvas measurement due to the different rendering engines used.
|
|
8054
|
+
*/
|
|
8055
|
+
export class CanvasTextUtils {
|
|
8056
|
+
context: CanvasRenderingContext2D;
|
|
8057
|
+
currentText: string;
|
|
8058
|
+
constructor({ font, container }: CanvasTextParams);
|
|
8059
|
+
computeFontFromElement: (element: HTMLElement) => string;
|
|
8060
|
+
get textWidth(): number;
|
|
8061
|
+
setTextToCheck: (text: string) => void;
|
|
8062
|
+
}
|
|
8063
|
+
|
|
8064
|
+
}
|
|
8065
|
+
declare module '@elastic/eui/src/services/canvas' {
|
|
8066
|
+
export { CanvasTextUtils } from '@elastic/eui/src/services/canvas/canvas_text_utils';
|
|
8067
|
+
export type { CanvasTextParams } from '@elastic/eui/src/services/canvas/canvas_text_utils';
|
|
8068
|
+
|
|
8035
8069
|
}
|
|
8036
8070
|
declare module '@elastic/eui/src/services/color_picker/color_picker' {
|
|
8037
8071
|
interface colorStopsType {
|
|
@@ -8470,6 +8504,7 @@ declare module '@elastic/eui/src/services' {
|
|
|
8470
8504
|
export type { HorizontalAlignment } from '@elastic/eui/src/services/alignment';
|
|
8471
8505
|
export { CurrentEuiBreakpointContext, CurrentEuiBreakpointProvider, useCurrentEuiBreakpoint, useIsWithinBreakpoints, useIsWithinMaxBreakpoint, useIsWithinMinBreakpoint, } from '@elastic/eui/src/services/breakpoint';
|
|
8472
8506
|
export type { EuiBreakpointSize } from '@elastic/eui/src/services/breakpoint';
|
|
8507
|
+
export { CanvasTextUtils, type CanvasTextParams } from '@elastic/eui/src/services/canvas';
|
|
8473
8508
|
export { brighten, calculateContrast, calculateLuminance, colorPalette, darken, DEFAULT_VISUALIZATION_COLOR, desaturate, euiPaletteColorBlind, euiPaletteColorBlindBehindText, euiPaletteComplimentary, euiPaletteComplementary, euiPaletteCool, euiPaletteForDarkBackground, euiPaletteForLightBackground, euiPaletteForStatus, euiPaletteForTemperature, euiPaletteGray, euiPaletteNegative, euiPalettePositive, euiPaletteWarm, getSteppedGradient, hexToHsv, hexToRgb, hsvToHex, hsvToRgb, isColorDark, isValidHex, lightness, makeDisabledContrastColor, makeHighContrastColor, rgbToHex, rgbToHsv, saturate, shade, shadeOrTint, tint, tintOrShade, transparentize, VISUALIZATION_COLORS, wcagContrastMin, } from '@elastic/eui/src/services/color';
|
|
8474
8509
|
export type { HSV } from '@elastic/eui/src/services/color';
|
|
8475
8510
|
export { useColorPickerState, useColorStopsState } from '@elastic/eui/src/services/color_picker';
|
|
@@ -11447,36 +11482,11 @@ declare module '@elastic/eui/src/components/filter_group/filter_select_item' {
|
|
|
11447
11482
|
|
|
11448
11483
|
}
|
|
11449
11484
|
declare module '@elastic/eui/src/components/text_truncate/utils' {
|
|
11450
|
-
import
|
|
11451
|
-
container: HTMLElement;
|
|
11452
|
-
}, {
|
|
11453
|
-
font: CanvasTextDrawingStyles['font'];
|
|
11454
|
-
}>; type TruncationParams = CanvasTextParams & {
|
|
11485
|
+
import { CanvasTextParams, CanvasTextUtils } from '@elastic/eui/src/services/canvas'; type TruncationParams = CanvasTextParams & {
|
|
11455
11486
|
fullText: string;
|
|
11456
11487
|
ellipsis: string;
|
|
11457
11488
|
availableWidth: number;
|
|
11458
11489
|
};
|
|
11459
|
-
/**
|
|
11460
|
-
* Under the hood, a temporary Canvas element is created for manipulating text
|
|
11461
|
-
* & determining text width.
|
|
11462
|
-
*
|
|
11463
|
-
* To accurately measure text, canvas rendering requires either a container to
|
|
11464
|
-
* compute/derive font styles from, or a static font string (useful for usage
|
|
11465
|
-
* outside the DOM). Particular care should be applied when fallback fonts are
|
|
11466
|
-
* used, as more fallback fonts can lead to less precision.
|
|
11467
|
-
*
|
|
11468
|
-
* Please note that while canvas is more significantly more performant than DOM
|
|
11469
|
-
* measurement, there are subpixel to single digit pixel differences between
|
|
11470
|
-
* DOM and canvas measurement due to the different rendering engines used.
|
|
11471
|
-
*/
|
|
11472
|
-
export class CanvasTextUtils {
|
|
11473
|
-
context: CanvasRenderingContext2D;
|
|
11474
|
-
currentText: string;
|
|
11475
|
-
constructor({ font, container }: CanvasTextParams);
|
|
11476
|
-
computeFontFromElement: (element: HTMLElement) => string;
|
|
11477
|
-
get textWidth(): number;
|
|
11478
|
-
setTextToCheck: (text: string) => void;
|
|
11479
|
-
}
|
|
11480
11490
|
/**
|
|
11481
11491
|
* Utilities for truncating types at various positions, as well as
|
|
11482
11492
|
* determining whether truncation is possible or even necessary.
|
|
@@ -11608,7 +11618,7 @@ declare module '@elastic/eui/src/components/text_truncate/text_truncate' {
|
|
|
11608
11618
|
declare module '@elastic/eui/src/components/text_truncate' {
|
|
11609
11619
|
export type { EuiTextTruncateProps, EuiTextTruncationTypes, } from '@elastic/eui/src/components/text_truncate/text_truncate';
|
|
11610
11620
|
export { EuiTextTruncate } from '@elastic/eui/src/components/text_truncate/text_truncate';
|
|
11611
|
-
export {
|
|
11621
|
+
export { TruncationUtils } from '@elastic/eui/src/components/text_truncate/utils';
|
|
11612
11622
|
|
|
11613
11623
|
}
|
|
11614
11624
|
declare module '@elastic/eui/src/components/combo_box/types' {
|
|
@@ -11680,7 +11690,7 @@ declare module '@elastic/eui/src/components/combo_box/combo_box_input/combo_box_
|
|
|
11680
11690
|
|
|
11681
11691
|
}
|
|
11682
11692
|
declare module '@elastic/eui/src/components/combo_box/combo_box_input/combo_box_input' {
|
|
11683
|
-
import React, { Component,
|
|
11693
|
+
import React, { Component, FocusEventHandler, KeyboardEventHandler, RefCallback } from 'react';
|
|
11684
11694
|
import { CommonProps } from '@elastic/eui/src/components/common';
|
|
11685
11695
|
import { htmlIdGenerator } from '@elastic/eui/src/services';
|
|
11686
11696
|
import { EuiFormControlLayoutProps } from '@elastic/eui/src/components/form/form_control_layout';
|
|
@@ -11696,9 +11706,9 @@ declare module '@elastic/eui/src/components/combo_box/combo_box_input/combo_box_
|
|
|
11696
11706
|
isListOpen: boolean;
|
|
11697
11707
|
noIcon: boolean;
|
|
11698
11708
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
|
11699
|
-
onChange
|
|
11709
|
+
onChange: (searchValue: string) => void;
|
|
11700
11710
|
onClear?: () => void;
|
|
11701
|
-
onClick
|
|
11711
|
+
onClick: () => void;
|
|
11702
11712
|
onCloseListClick: () => void;
|
|
11703
11713
|
onFocus: FocusEventHandler<HTMLInputElement>;
|
|
11704
11714
|
onOpenListClick: () => void;
|
|
@@ -11733,7 +11743,6 @@ declare module '@elastic/eui/src/components/combo_box/combo_box_input/combo_box_
|
|
|
11733
11743
|
onBlur: FocusEventHandler<HTMLInputElement>;
|
|
11734
11744
|
onKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
|
11735
11745
|
componentDidUpdate(prevProps: EuiComboBoxInputProps<T>): void;
|
|
11736
|
-
inputOnChange: ChangeEventHandler<HTMLInputElement>;
|
|
11737
11746
|
render(): React.JSX.Element;
|
|
11738
11747
|
}
|
|
11739
11748
|
export {};
|
|
@@ -8,7 +8,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _services = require("../../../services");
|
|
11
|
-
var _text_truncate = require("../../text_truncate");
|
|
12
11
|
var _accessibility = require("../../accessibility");
|
|
13
12
|
var _form_control_layout = require("../../form/form_control_layout");
|
|
14
13
|
var _num_icons = require("../../form/form_control_layout/_num_icons");
|
|
@@ -58,7 +57,7 @@ var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
58
57
|
_defineProperty(_assertThisInitialized(_this), "widthUtils", void 0);
|
|
59
58
|
_defineProperty(_assertThisInitialized(_this), "inputRefCallback", function (el) {
|
|
60
59
|
var _this$props$inputRef, _this$props;
|
|
61
|
-
_this.widthUtils = new
|
|
60
|
+
_this.widthUtils = new _services.CanvasTextUtils({
|
|
62
61
|
container: el
|
|
63
62
|
});
|
|
64
63
|
(_this$props$inputRef = (_this$props = _this.props).inputRef) === null || _this$props$inputRef === void 0 ? void 0 : _this$props$inputRef.call(_this$props, el);
|
|
@@ -112,56 +111,51 @@ var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
});
|
|
115
|
-
_defineProperty(_assertThisInitialized(_this), "inputOnChange", function (event) {
|
|
116
|
-
var _this$props$onChange, _this$props3;
|
|
117
|
-
var value = event.target.value;
|
|
118
|
-
_this.updateInputSize(value);
|
|
119
|
-
(_this$props$onChange = (_this$props3 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props3, value);
|
|
120
|
-
});
|
|
121
114
|
return _this;
|
|
122
115
|
}
|
|
123
116
|
_createClass(EuiComboBoxInput, [{
|
|
124
117
|
key: "componentDidUpdate",
|
|
125
118
|
value: function componentDidUpdate(prevProps) {
|
|
126
|
-
|
|
119
|
+
if (prevProps.searchValue !== this.props.searchValue) {
|
|
120
|
+
this.updateInputSize(this.props.searchValue);
|
|
127
121
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (searchValue !== this.props.searchValue) {
|
|
122
|
+
// We need to update the position of everything if the user enters enough input to change
|
|
123
|
+
// the size of the input.
|
|
131
124
|
this.updatePosition();
|
|
132
125
|
}
|
|
133
126
|
}
|
|
134
127
|
}, {
|
|
135
128
|
key: "render",
|
|
136
129
|
value: function render() {
|
|
137
|
-
var _this$
|
|
138
|
-
compressed = _this$
|
|
139
|
-
focusedOptionId = _this$
|
|
140
|
-
fullWidth = _this$
|
|
141
|
-
hasSelectedOptions = _this$
|
|
142
|
-
id = _this$
|
|
143
|
-
isDisabled = _this$
|
|
144
|
-
isListOpen = _this$
|
|
145
|
-
noIcon = _this$
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
130
|
+
var _this$props3 = this.props,
|
|
131
|
+
compressed = _this$props3.compressed,
|
|
132
|
+
focusedOptionId = _this$props3.focusedOptionId,
|
|
133
|
+
fullWidth = _this$props3.fullWidth,
|
|
134
|
+
hasSelectedOptions = _this$props3.hasSelectedOptions,
|
|
135
|
+
id = _this$props3.id,
|
|
136
|
+
isDisabled = _this$props3.isDisabled,
|
|
137
|
+
isListOpen = _this$props3.isListOpen,
|
|
138
|
+
noIcon = _this$props3.noIcon,
|
|
139
|
+
_onChange = _this$props3.onChange,
|
|
140
|
+
onClear = _this$props3.onClear,
|
|
141
|
+
onClick = _this$props3.onClick,
|
|
142
|
+
onCloseListClick = _this$props3.onCloseListClick,
|
|
143
|
+
onOpenListClick = _this$props3.onOpenListClick,
|
|
144
|
+
onRemoveOption = _this$props3.onRemoveOption,
|
|
145
|
+
placeholder = _this$props3.placeholder,
|
|
146
|
+
rootId = _this$props3.rootId,
|
|
147
|
+
searchValue = _this$props3.searchValue,
|
|
148
|
+
selectedOptions = _this$props3.selectedOptions,
|
|
149
|
+
singleSelectionProp = _this$props3.singleSelection,
|
|
150
|
+
toggleButtonRef = _this$props3.toggleButtonRef,
|
|
151
|
+
value = _this$props3.value,
|
|
152
|
+
prepend = _this$props3.prepend,
|
|
153
|
+
append = _this$props3.append,
|
|
154
|
+
isLoading = _this$props3.isLoading,
|
|
155
|
+
isInvalid = _this$props3.isInvalid,
|
|
156
|
+
autoFocus = _this$props3.autoFocus,
|
|
157
|
+
ariaLabel = _this$props3['aria-label'],
|
|
158
|
+
ariaLabelledby = _this$props3['aria-labelledby'];
|
|
165
159
|
var singleSelection = Boolean(singleSelectionProp);
|
|
166
160
|
var asPlainText = singleSelectionProp && _typeof(singleSelectionProp) === 'object' && singleSelectionProp.asPlainText || false;
|
|
167
161
|
var pills = selectedOptions ? selectedOptions.map(function (option) {
|
|
@@ -266,7 +260,9 @@ var EuiComboBoxInput = /*#__PURE__*/function (_Component) {
|
|
|
266
260
|
disabled: isDisabled,
|
|
267
261
|
id: id,
|
|
268
262
|
onBlur: this.onBlur,
|
|
269
|
-
onChange:
|
|
263
|
+
onChange: function onChange(event) {
|
|
264
|
+
return _onChange(event.target.value);
|
|
265
|
+
},
|
|
270
266
|
onFocus: this.onFocus,
|
|
271
267
|
onKeyDown: this.onKeyDown,
|
|
272
268
|
ref: this.inputRefCallback,
|
|
@@ -293,9 +289,9 @@ EuiComboBoxInput.propTypes = {
|
|
|
293
289
|
isListOpen: _propTypes.default.bool.isRequired,
|
|
294
290
|
noIcon: _propTypes.default.bool.isRequired,
|
|
295
291
|
onBlur: _propTypes.default.any,
|
|
296
|
-
onChange: _propTypes.default.func,
|
|
292
|
+
onChange: _propTypes.default.func.isRequired,
|
|
297
293
|
onClear: _propTypes.default.func,
|
|
298
|
-
onClick: _propTypes.default.func,
|
|
294
|
+
onClick: _propTypes.default.func.isRequired,
|
|
299
295
|
onCloseListClick: _propTypes.default.func.isRequired,
|
|
300
296
|
onFocus: _propTypes.default.any.isRequired,
|
|
301
297
|
onOpenListClick: _propTypes.default.func.isRequired,
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "CanvasTextUtils", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _utils.CanvasTextUtils;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "EuiTextTruncate", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function get() {
|
|
@@ -13,7 +13,7 @@ var _resize_observer = require("../observer/resize_observer");
|
|
|
13
13
|
var _utils = require("./utils");
|
|
14
14
|
var _text_truncate = require("./text_truncate.styles");
|
|
15
15
|
var _react2 = require("@emotion/react");
|
|
16
|
-
var _excluded = ["width"],
|
|
16
|
+
var _excluded = ["width", "onResize"],
|
|
17
17
|
_excluded2 = ["width", "children", "text", "truncation", "truncationOffset", "truncationPosition", "ellipsis", "containerRef", "className"],
|
|
18
18
|
_excluded3 = ["onResize"];
|
|
19
19
|
/*
|
|
@@ -38,10 +38,13 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
38
38
|
var TRUNCATION_TYPES = ['end', 'start', 'startEnd', 'middle'];
|
|
39
39
|
var EuiTextTruncate = function EuiTextTruncate(_ref) {
|
|
40
40
|
var width = _ref.width,
|
|
41
|
+
onResize = _ref.onResize,
|
|
41
42
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
42
43
|
return width != null ? (0, _react2.jsx)(EuiTextTruncateWithWidth, _extends({
|
|
43
44
|
width: width
|
|
44
|
-
}, props)) : (0, _react2.jsx)(EuiTextTruncateWithResizeObserver,
|
|
45
|
+
}, props)) : (0, _react2.jsx)(EuiTextTruncateWithResizeObserver, _extends({
|
|
46
|
+
onResize: onResize
|
|
47
|
+
}, props));
|
|
45
48
|
};
|
|
46
49
|
exports.EuiTextTruncate = EuiTextTruncate;
|
|
47
50
|
EuiTextTruncate.propTypes = {
|