@elastic/eui 81.3.0 → 82.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/eui_charts_theme.js.map +1 -1
  2. package/es/components/form/range/range_track.js +21 -7
  3. package/es/components/header/header_links/header_links.js +25 -1
  4. package/es/components/popover/popover.js +25 -1
  5. package/es/components/popover/popover_panel/_popover_panel.js +0 -10
  6. package/es/components/tour/tour_step.js +25 -1
  7. package/es/global_styling/variables/breakpoint.js +2 -1
  8. package/eui.d.ts +99 -14
  9. package/i18ntokens.json +2 -2
  10. package/lib/components/form/range/range_track.js +21 -7
  11. package/lib/components/header/header_links/header_links.js +25 -1
  12. package/lib/components/page/page_content/page_content.js +4 -4
  13. package/lib/components/page/page_template.js +4 -4
  14. package/lib/components/popover/popover_panel/_popover_panel.js +0 -33
  15. package/lib/global_styling/variables/breakpoint.js +2 -1
  16. package/optimize/es/components/form/range/range_track.js +21 -7
  17. package/optimize/es/global_styling/variables/breakpoint.js +2 -1
  18. package/optimize/lib/components/form/range/range_track.js +21 -7
  19. package/optimize/lib/global_styling/variables/breakpoint.js +2 -1
  20. package/package.json +1 -1
  21. package/test-env/components/form/range/range_track.js +21 -7
  22. package/test-env/components/header/header_links/header_links.js +25 -1
  23. package/test-env/components/page/page_content/page_content.js +4 -4
  24. package/test-env/components/page/page_template.js +4 -4
  25. package/test-env/components/popover/popover_panel/_popover_panel.js +0 -33
  26. package/test-env/global_styling/variables/breakpoint.js +2 -1
@@ -50,6 +50,10 @@ var EuiRangeTrack = function EuiRangeTrack(_ref) {
50
50
  step: step
51
51
  });
52
52
  }, [value, min, max, step]);
53
+ var _useState = (0, _react.useState)(0),
54
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
55
+ trackWidth = _useState2[0],
56
+ setTrackWidth = _useState2[1];
53
57
  var tickSequence = (0, _react.useMemo)(function () {
54
58
  if (showTicks !== true) return;
55
59
  var sequence;
@@ -84,18 +88,14 @@ var EuiRangeTrack = function EuiRangeTrack(_ref) {
84
88
  }
85
89
 
86
90
  // Error out if there are too many ticks to render
87
- if (sequence.length > 20) {
88
- throw new Error("The number of ticks to render is too high (".concat(sequence.length, "), reduce the interval."));
91
+ if (trackWidth && sequence.length) {
92
+ validateTickRenderCount(trackWidth, sequence.length);
89
93
  }
90
94
  return sequence;
91
- }, [showTicks, ticks, min, max, tickInterval, step]);
95
+ }, [showTicks, ticks, min, max, tickInterval, step, trackWidth]);
92
96
  var euiTheme = (0, _services.useEuiTheme)();
93
97
  var styles = (0, _range_track.euiRangeTrackStyles)(euiTheme);
94
98
  var cssStyles = [styles.euiRangeTrack, disabled && styles.disabled, levels && !!levels.length && styles.hasLevels, showTicks && (tickSequence || ticks) && styles.hasTicks];
95
- var _useState = (0, _react.useState)(0),
96
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
97
- trackWidth = _useState2[0],
98
- setTrackWidth = _useState2[1];
99
99
  var classes = (0, _classnames.default)('euiRangeTrack', className);
100
100
  return (0, _react2.jsx)("div", (0, _extends2.default)({
101
101
  className: classes,
@@ -142,4 +142,18 @@ var validateValueIsInStep = function validateValueIsInStep(value, _ref2) {
142
142
  }
143
143
  // Return the value if nothing fails
144
144
  return value;
145
+ };
146
+ var validateTickRenderCount = function validateTickRenderCount(trackWidth, tickCount) {
147
+ var tickWidth = trackWidth / tickCount;
148
+
149
+ // These widths are guesstimations - it's possible we should use actual label content/widths instead
150
+ var COMFORTABLE_TICK_WIDTH = 20; // Set a warning threshold before throwing
151
+ var MIN_TICK_WIDTH = 5; // If ticks are smaller than this, something's gone seriously wrong and we should throw
152
+
153
+ var message = "The number of ticks to render (".concat(tickCount, ") is too high for the range width. Ensure all ticks are visible on the page at multiple screen widths, or use EUI's breakpoint hook utilities to reduce the tick interval responsively.");
154
+ if (tickWidth <= MIN_TICK_WIDTH) {
155
+ throw new Error(message);
156
+ } else if (tickWidth < COMFORTABLE_TICK_WIDTH) {
157
+ console.warn(message);
158
+ }
145
159
  };
@@ -17,5 +17,6 @@ var EuiThemeBreakpoints = ['xs', 's', 'm', 'l', 'xl'];
17
17
  // This type cannot be a string enum / must be a generic string
18
18
  // in case consumers add custom breakpoint sizes, such as xxl or xxs
19
19
 
20
- // Set the minimum window width at which to start to the breakpoint
20
+ // Explicitly list out each key so we can document default values
21
+ // via JSDoc (which is available to devs in IDE via intellisense)
21
22
  exports.EuiThemeBreakpoints = EuiThemeBreakpoints;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elastic/eui",
3
3
  "description": "Elastic UI Component Library",
4
- "version": "81.3.0",
4
+ "version": "82.0.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "lib",
7
7
  "module": "es",
@@ -51,6 +51,10 @@ var EuiRangeTrack = function EuiRangeTrack(_ref) {
51
51
  step: step
52
52
  });
53
53
  }, [value, min, max, step]);
54
+ var _useState = (0, _react.useState)(0),
55
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
56
+ trackWidth = _useState2[0],
57
+ setTrackWidth = _useState2[1];
54
58
  var tickSequence = (0, _react.useMemo)(function () {
55
59
  if (showTicks !== true) return;
56
60
  var sequence;
@@ -85,18 +89,14 @@ var EuiRangeTrack = function EuiRangeTrack(_ref) {
85
89
  }
86
90
 
87
91
  // Error out if there are too many ticks to render
88
- if (sequence.length > 20) {
89
- throw new Error("The number of ticks to render is too high (".concat(sequence.length, "), reduce the interval."));
92
+ if (trackWidth && sequence.length) {
93
+ validateTickRenderCount(trackWidth, sequence.length);
90
94
  }
91
95
  return sequence;
92
- }, [showTicks, ticks, min, max, tickInterval, step]);
96
+ }, [showTicks, ticks, min, max, tickInterval, step, trackWidth]);
93
97
  var euiTheme = (0, _services.useEuiTheme)();
94
98
  var styles = (0, _range_track.euiRangeTrackStyles)(euiTheme);
95
99
  var cssStyles = [styles.euiRangeTrack, disabled && styles.disabled, levels && !!levels.length && styles.hasLevels, showTicks && (tickSequence || ticks) && styles.hasTicks];
96
- var _useState = (0, _react.useState)(0),
97
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
98
- trackWidth = _useState2[0],
99
- setTrackWidth = _useState2[1];
100
100
  var classes = (0, _classnames.default)('euiRangeTrack', className);
101
101
  return (0, _react2.jsx)("div", (0, _extends2.default)({
102
102
  className: classes,
@@ -180,4 +180,18 @@ var validateValueIsInStep = function validateValueIsInStep(value, _ref2) {
180
180
  }
181
181
  // Return the value if nothing fails
182
182
  return value;
183
+ };
184
+ var validateTickRenderCount = function validateTickRenderCount(trackWidth, tickCount) {
185
+ var tickWidth = trackWidth / tickCount;
186
+
187
+ // These widths are guesstimations - it's possible we should use actual label content/widths instead
188
+ var COMFORTABLE_TICK_WIDTH = 20; // Set a warning threshold before throwing
189
+ var MIN_TICK_WIDTH = 5; // If ticks are smaller than this, something's gone seriously wrong and we should throw
190
+
191
+ var message = "The number of ticks to render (".concat(tickCount, ") is too high for the range width. Ensure all ticks are visible on the page at multiple screen widths, or use EUI's breakpoint hook utilities to reduce the tick interval responsively.");
192
+ if (tickWidth <= MIN_TICK_WIDTH) {
193
+ throw new Error(message);
194
+ } else if (tickWidth < COMFORTABLE_TICK_WIDTH) {
195
+ console.warn(message);
196
+ }
183
197
  };
@@ -206,7 +206,31 @@ EuiHeaderLinks.propTypes = {
206
206
  /**
207
207
  * Object of props passed to EuiPanel. See #EuiPopoverPanelProps
208
208
  */
209
- panelProps: _propTypes.default.any,
209
+ panelProps: _propTypes.default.shape({
210
+ element: _propTypes.default.oneOf(["div"]),
211
+ /**
212
+ * Padding for all four sides
213
+ */
214
+ paddingSize: _propTypes.default.any,
215
+ /**
216
+ * Corner border radius
217
+ */
218
+ borderRadius: _propTypes.default.any,
219
+ /**
220
+ * When true the panel will grow in height to match `EuiFlexItem`
221
+ */
222
+ grow: _propTypes.default.bool,
223
+ panelRef: _propTypes.default.any,
224
+ /**
225
+ * Background color of the panel;
226
+ * Usually a lightened form of the brand colors
227
+ */
228
+ color: _propTypes.default.any,
229
+ className: _propTypes.default.string,
230
+ "aria-label": _propTypes.default.string,
231
+ "data-test-subj": _propTypes.default.string,
232
+ css: _propTypes.default.any
233
+ }),
210
234
  panelRef: _propTypes.default.any,
211
235
  /**
212
236
  * Optional screen reader instructions to announce upon popover open,
@@ -52,10 +52,10 @@ var EuiPageContent_Deprecated = function EuiPageContent_Deprecated(_ref) {
52
52
  };
53
53
  exports.EuiPageContent_Deprecated = EuiPageContent_Deprecated;
54
54
  EuiPageContent_Deprecated.propTypes = {
55
- className: _propTypes.default.string,
56
- "aria-label": _propTypes.default.string,
57
- "data-test-subj": _propTypes.default.string,
58
- css: _propTypes.default.any,
55
+ className: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
56
+ "aria-label": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
57
+ "data-test-subj": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
58
+ css: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.any, _propTypes.default.any]), _propTypes.default.any]),
59
59
  /**
60
60
  * Adds a medium shadow to the panel;
61
61
  * Only works when `color="plain"`
@@ -417,10 +417,10 @@ EuiPageTemplate_Deprecated.propTypes = {
417
417
  * Gets passed along to the #EuiPageContent component
418
418
  */
419
419
  pageContentProps: _propTypes.default.shape({
420
- className: _propTypes.default.string,
421
- "aria-label": _propTypes.default.string,
422
- "data-test-subj": _propTypes.default.string,
423
- css: _propTypes.default.any,
420
+ className: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
421
+ "aria-label": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
422
+ "data-test-subj": _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.string]), _propTypes.default.string]),
423
+ css: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.any, _propTypes.default.any]), _propTypes.default.any]),
424
424
  /**
425
425
  * Adds a medium shadow to the panel;
426
426
  * Only works when `color="plain"`
@@ -69,39 +69,6 @@ var EuiPopoverPanel = function EuiPopoverPanel(_ref) {
69
69
  };
70
70
  exports.EuiPopoverPanel = EuiPopoverPanel;
71
71
  EuiPopoverPanel.propTypes = {
72
- element: _propTypes.default.oneOf(["div"]),
73
- /**
74
- * Adds a medium shadow to the panel;
75
- * Only works when `color="plain"`
76
- */
77
- hasShadow: _propTypes.default.bool,
78
- /**
79
- * Adds a slight 1px border on all edges.
80
- * Only works when `color="plain | transparent"`
81
- */
82
- hasBorder: _propTypes.default.bool,
83
- /**
84
- * Padding for all four sides
85
- */
86
- paddingSize: _propTypes.default.any,
87
- /**
88
- * Corner border radius
89
- */
90
- borderRadius: _propTypes.default.any,
91
- /**
92
- * When true the panel will grow in height to match `EuiFlexItem`
93
- */
94
- grow: _propTypes.default.bool,
95
- panelRef: _propTypes.default.any,
96
- /**
97
- * Background color of the panel;
98
- * Usually a lightened form of the brand colors
99
- */
100
- color: _propTypes.default.any,
101
- className: _propTypes.default.string,
102
- "aria-label": _propTypes.default.string,
103
- "data-test-subj": _propTypes.default.string,
104
- css: _propTypes.default.any,
105
72
  isOpen: _propTypes.default.bool,
106
73
  isAttached: _propTypes.default.bool,
107
74
  position: _propTypes.default.oneOfType([_propTypes.default.any.isRequired, _propTypes.default.oneOf([null])]),
@@ -17,5 +17,6 @@ var EuiThemeBreakpoints = ['xs', 's', 'm', 'l', 'xl'];
17
17
  // This type cannot be a string enum / must be a generic string
18
18
  // in case consumers add custom breakpoint sizes, such as xxl or xxs
19
19
 
20
- // Set the minimum window width at which to start to the breakpoint
20
+ // Explicitly list out each key so we can document default values
21
+ // via JSDoc (which is available to devs in IDE via intellisense)
21
22
  exports.EuiThemeBreakpoints = EuiThemeBreakpoints;