@splunk/react-ui 4.21.1 → 4.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ResultsMenu.js CHANGED
@@ -79,70 +79,74 @@
79
79
  const c = require("lodash/omit");
80
80
  var p = e.n(c);
81
81
  // CONCATENATED MODULE: external "@splunk/ui-utils/i18n"
82
- const f = require("@splunk/ui-utils/i18n");
82
+ const d = require("@splunk/ui-utils/i18n");
83
83
  // CONCATENATED MODULE: external "@splunk/ui-utils/userAgent"
84
- const d = require("@splunk/ui-utils/userAgent");
84
+ const f = require("@splunk/ui-utils/userAgent");
85
85
  // CONCATENATED MODULE: external "@splunk/react-ui/Menu"
86
86
  const m = require("@splunk/react-ui/Menu");
87
87
  var h = e.n(m);
88
88
  // CONCATENATED MODULE: external "styled-components"
89
89
  const v = require("styled-components");
90
- var g = e.n(v);
90
+ var y = e.n(v);
91
91
  // CONCATENATED MODULE: external "@splunk/react-ui/WaitSpinner"
92
92
  const b = require("@splunk/react-ui/WaitSpinner");
93
- var y = e.n(b);
93
+ var g = e.n(b);
94
94
  // CONCATENATED MODULE: external "@splunk/themes"
95
- const M = require("@splunk/themes");
95
+ const S = require("@splunk/themes");
96
96
  // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenuStyles.ts
97
- var S = g().div.withConfig({
97
+ var M = y().div.withConfig({
98
98
  displayName: "ResultsMenuStyles__Styled",
99
99
  componentId: "avbhl8-0"
100
- })([ "", ";flex-direction:column;max-height:calc(100vh - 20px);", "" ], M.mixins.reset("flex"), (0,
101
- M.pick)({
102
- prisma: (0, v.css)([ "border-radius:", ";background-color:", ";" ], M.variables.borderRadius, M.variables.backgroundColorPopup)
100
+ })([ "", ";flex-direction:column;max-height:calc(100vh - 20px);", "" ], S.mixins.reset("flex"), (0,
101
+ S.pick)({
102
+ prisma: (0, v.css)([ "border-radius:", ";background-color:", ";" ], S.variables.borderRadius, S.variables.backgroundColorPopup)
103
103
  }));
104
- var x = g().div.withConfig({
104
+ var x = y().div.withConfig({
105
105
  displayName: "ResultsMenuStyles__StyledFooter",
106
106
  componentId: "avbhl8-1"
107
- })([ "padding:", ";color:", ";", "" ], (0, M.pick)({
107
+ })([ "padding:", ";color:", ";", "" ], (0, S.pick)({
108
108
  prisma: {
109
109
  comfortable: "10px 16px",
110
110
  compact: "6px 16px"
111
111
  },
112
112
  enterprise: "6px 10px"
113
- }), (0, M.pick)({
114
- prisma: M.variables.contentColorMuted,
115
- enterprise: M.variables.textGray
113
+ }), (0, S.pick)({
114
+ prisma: S.variables.contentColorMuted,
115
+ enterprise: S.variables.textGray
116
116
  }), (function(e) {
117
117
  var t = e.$placement;
118
- return t === "above" ? (0, M.pick)({
119
- prisma: (0, v.css)([ "border-bottom:1px solid ", ";" ], M.variables.neutral200),
120
- enterprise: (0, v.css)([ "border-bottom:", ";" ], M.variables.border)
121
- }) : (0, M.pick)({
122
- prisma: (0, v.css)([ "border-top:1px solid ", ";" ], M.variables.neutral200),
123
- enterprise: (0, v.css)([ "border-top:", ";" ], M.variables.border)
118
+ return t === "above" ? (0, S.pick)({
119
+ prisma: (0, v.css)([ "border-bottom:1px solid ", ";" ], S.variables.neutral200),
120
+ enterprise: (0, v.css)([ "border-bottom:", ";" ], S.variables.border)
121
+ }) : (0, S.pick)({
122
+ prisma: (0, v.css)([ "border-top:1px solid ", ";" ], S.variables.neutral200),
123
+ enterprise: (0, v.css)([ "border-top:", ";" ], S.variables.border)
124
124
  });
125
125
  }));
126
- var E = g().li.withConfig({
126
+ var E = y().li.withConfig({
127
127
  displayName: "ResultsMenuStyles__StyledLoading",
128
128
  componentId: "avbhl8-2"
129
- })([ "", ";padding:", ";gap:", ";" ], M.mixins.reset("flex"), (0, M.pick)({
129
+ })([ "", ";padding:", ";gap:", ";" ], S.mixins.reset("flex"), (0, S.pick)({
130
130
  prisma: {
131
131
  comfortable: "10px 16px",
132
132
  compact: "6px 16px"
133
133
  },
134
134
  enterprise: "6px 10px"
135
- }), M.variables.spacingXSmall);
136
- var O = g()(y()).withConfig({
137
- displayName: "ResultsMenuStyles__StyledWait",
135
+ }), S.variables.spacingXSmall);
136
+ var O = y()(h()).withConfig({
137
+ displayName: "ResultsMenuStyles__StyledMenu",
138
138
  componentId: "avbhl8-3"
139
+ })([ "overflow:auto;flex-direction:column;" ]);
140
+ var k = y()(g()).withConfig({
141
+ displayName: "ResultsMenuStyles__StyledWait",
142
+ componentId: "avbhl8-4"
139
143
  })([ "flex:0 0 auto;" ]);
140
- var k = g().div.withConfig({
144
+ var w = y().div.withConfig({
141
145
  displayName: "ResultsMenuStyles__StyledLoadingMessage",
142
- componentId: "avbhl8-4"
143
- })([ "flex:1 0 0;color:", ";" ], (0, M.pick)({
144
- prisma: M.variables.contentColorMuted,
145
- enterprise: M.variables.textGray
146
+ componentId: "avbhl8-5"
147
+ })([ "flex:1 0 0;color:", ";" ], (0, S.pick)({
148
+ prisma: S.variables.contentColorMuted,
149
+ enterprise: S.variables.textGray
146
150
  }));
147
151
  // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
148
152
  /**
@@ -151,7 +155,7 @@
151
155
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
152
156
  * @param current - The new value of the ref.
153
157
  */
154
- function w(e, t) {
158
+ function _(e, t) {
155
159
  if (e) {
156
160
  if (typeof e === "function") {
157
161
  e(t);
@@ -164,21 +168,21 @@
164
168
  }
165
169
  }
166
170
  // CONCATENATED MODULE: ./src/ResultsMenu/ResultsMenu.tsx
167
- function _(e) {
171
+ function T(e) {
168
172
  "@babel/helpers - typeof";
169
173
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
170
- _ = function e(t) {
174
+ T = function e(t) {
171
175
  return typeof t;
172
176
  };
173
177
  } else {
174
- _ = function e(t) {
178
+ T = function e(t) {
175
179
  return t && typeof Symbol === "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
176
180
  };
177
181
  }
178
- return _(e);
182
+ return T(e);
179
183
  }
180
- function H() {
181
- H = Object.assign || function(e) {
184
+ function B() {
185
+ B = Object.assign || function(e) {
182
186
  for (var t = 1; t < arguments.length; t++) {
183
187
  var o = arguments[t];
184
188
  for (var n in o) {
@@ -189,14 +193,14 @@
189
193
  }
190
194
  return e;
191
195
  };
192
- return H.apply(this, arguments);
196
+ return B.apply(this, arguments);
193
197
  }
194
- function T(e, t) {
198
+ function C(e, t) {
195
199
  if (!(e instanceof t)) {
196
200
  throw new TypeError("Cannot call a class as a function");
197
201
  }
198
202
  }
199
- function B(e, t) {
203
+ function P(e, t) {
200
204
  for (var o = 0; o < t.length; o++) {
201
205
  var n = t[o];
202
206
  n.enumerable = n.enumerable || false;
@@ -205,12 +209,12 @@
205
209
  Object.defineProperty(e, n.key, n);
206
210
  }
207
211
  }
208
- function C(e, t, o) {
209
- if (t) B(e.prototype, t);
210
- if (o) B(e, o);
212
+ function L(e, t, o) {
213
+ if (t) P(e.prototype, t);
214
+ if (o) P(e, o);
211
215
  return e;
212
216
  }
213
- function P(e, t) {
217
+ function R(e, t) {
214
218
  if (typeof t !== "function" && t !== null) {
215
219
  throw new TypeError("Super expression must either be null or a function");
216
220
  }
@@ -221,41 +225,41 @@
221
225
  configurable: true
222
226
  }
223
227
  });
224
- if (t) L(e, t);
228
+ if (t) j(e, t);
225
229
  }
226
- function L(e, t) {
227
- L = Object.setPrototypeOf || function e(t, o) {
230
+ function j(e, t) {
231
+ j = Object.setPrototypeOf || function e(t, o) {
228
232
  t.__proto__ = o;
229
233
  return t;
230
234
  };
231
- return L(e, t);
235
+ return j(e, t);
232
236
  }
233
- function j(e) {
234
- var t = q();
237
+ function I(e) {
238
+ var t = F();
235
239
  return function o() {
236
- var n = F(e), r;
240
+ var n = N(e), r;
237
241
  if (t) {
238
- var l = F(this).constructor;
242
+ var l = N(this).constructor;
239
243
  r = Reflect.construct(n, arguments, l);
240
244
  } else {
241
245
  r = n.apply(this, arguments);
242
246
  }
243
- return R(this, r);
247
+ return q(this, r);
244
248
  };
245
249
  }
246
- function R(e, t) {
247
- if (t && (_(t) === "object" || typeof t === "function")) {
250
+ function q(e, t) {
251
+ if (t && (T(t) === "object" || typeof t === "function")) {
248
252
  return t;
249
253
  }
250
- return I(e);
254
+ return H(e);
251
255
  }
252
- function I(e) {
256
+ function H(e) {
253
257
  if (e === void 0) {
254
258
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
255
259
  }
256
260
  return e;
257
261
  }
258
- function q() {
262
+ function F() {
259
263
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
260
264
  if (Reflect.construct.sham) return false;
261
265
  if (typeof Proxy === "function") return true;
@@ -266,11 +270,11 @@
266
270
  return false;
267
271
  }
268
272
  }
269
- function F(e) {
270
- F = Object.setPrototypeOf ? Object.getPrototypeOf : function e(t) {
273
+ function N(e) {
274
+ N = Object.setPrototypeOf ? Object.getPrototypeOf : function e(t) {
271
275
  return t.__proto__ || Object.getPrototypeOf(t);
272
276
  };
273
- return F(e);
277
+ return N(e);
274
278
  }
275
279
  function D(e, t, o) {
276
280
  if (t in e) {
@@ -285,7 +289,7 @@
285
289
  }
286
290
  return e;
287
291
  }
288
- var N = {
292
+ var W = {
289
293
  animateLoading: l().bool,
290
294
  children: l().node,
291
295
  /** @private */
@@ -295,28 +299,20 @@
295
299
  footerMessage: l().node,
296
300
  isLoading: l().bool,
297
301
  loadingMessage: l().node,
298
- maxHeight: l().number,
299
302
  noOptionsMessage: l().node,
300
303
  onScroll: l().func,
301
304
  onScrollBottom: l().func,
302
305
  placement: l().string
303
306
  };
304
- var W = {
307
+ var A = {
305
308
  animateLoading: false,
306
309
  isLoading: false,
307
- loadingMessage: (0, f._)("Loading..."),
308
- noOptionsMessage: (0, f._)("No matches")
310
+ loadingMessage: (0, d._)("Loading..."),
311
+ noOptionsMessage: (0, d._)("No matches")
309
312
  };
310
- var A = {
313
+ var G = {
311
314
  role: "listbox"
312
315
  };
313
- var G = u()((function(e) {
314
- return {
315
- overflow: "auto",
316
- maxHeight: e || "calc(100vh - 20px)",
317
- flexDirection: "column"
318
- };
319
- }));
320
316
  var $ = u()((function(e) {
321
317
  return {
322
318
  height: e
@@ -324,36 +320,36 @@
324
320
  }));
325
321
  // @docs-props-type ResultsMenuPropsBase
326
322
  var z = function(e) {
327
- P(r, e);
328
- var t = j(r);
323
+ R(r, e);
324
+ var t = I(r);
329
325
  function r(e) {
330
326
  var n;
331
- T(this, r);
327
+ C(this, r);
332
328
  n = t.call(this, e);
333
- D(I(n), "scrollBottomOffset", void 0);
334
- D(I(n), "itemMinHeight", void 0);
335
- D(I(n), "handleMenuMount", (function(e) {
329
+ D(H(n), "scrollBottomOffset", void 0);
330
+ D(H(n), "itemMinHeight", void 0);
331
+ D(H(n), "handleMenuMount", (function(e) {
336
332
  n.setState({
337
333
  menuEl: e
338
334
  });
339
335
  }));
340
- D(I(n), "handleMount", (function(e) {
336
+ D(H(n), "handleMount", (function(e) {
341
337
  n.setState({
342
338
  containerEl: e
343
339
  });
344
- w(n.props.elementRef, e);
340
+ _(n.props.elementRef, e);
345
341
  }));
346
- D(I(n), "handleMouseEnter", (function() {
342
+ D(H(n), "handleMouseEnter", (function() {
347
343
  n.setState({
348
344
  windowTop: document.documentElement.scrollTop
349
345
  });
350
346
  }));
351
- D(I(n), "handleMouseLeave", (function() {
347
+ D(H(n), "handleMouseLeave", (function() {
352
348
  n.setState({
353
349
  windowTop: document.documentElement.scrollTop
354
350
  });
355
351
  }));
356
- D(I(n), "handleScroll", (function(e) {
352
+ D(H(n), "handleScroll", (function(e) {
357
353
  var t, o;
358
354
  if (n.props.onScrollBottom != null) {
359
355
  if (e.target && n.state.menuEl) {
@@ -366,14 +362,14 @@
366
362
  }
367
363
  (t = (o = n.props).onScroll) === null || t === void 0 ? void 0 : t.call(o, e);
368
364
  }));
369
- D(I(n), "handleWheelMenu", (function(e) {
365
+ D(H(n), "handleWheelMenu", (function(e) {
370
366
  // Safety net to ensure window doesn't scroll if menu is scrolled pass the numberOfItemsLoaded at high velocity.
371
367
  e.stopPropagation();
372
368
  document.documentElement.scrollTop = n.state.windowTop;
373
369
  }));
374
- D(I(n), "handleScrollBottomOnFullMenu", (function() {
370
+ D(H(n), "handleScrollBottomOnFullMenu", (function() {
375
371
  var e = o.Children.count(n.props.children);
376
- var t = n.state, r = t.childrenCount, l = t.menuMaxHeight;
372
+ var t = n.state.childrenCount;
377
373
  // If menu is full length, load more items.
378
374
  if (n.checkFullHeight()) {
379
375
  n.handleScrollBottom(null);
@@ -381,13 +377,13 @@
381
377
  // avoid triggering this logic if this.state.childrenCount is null
382
378
  // because that's not a real change in the number of children
383
379
  // and thus we want to avoid resetting the value of scrollBottomTriggered
384
- if (l && e != null && e !== r) {
380
+ if (t != null && e !== t) {
385
381
  n.setState({
386
- numberOfItemsLoaded: e - (r !== null && r !== void 0 ? r : 0),
382
+ numberOfItemsLoaded: e - (t !== null && t !== void 0 ? t : 0),
387
383
  scrollBottomTriggered: false
388
384
  });
389
385
  }
390
- if (e !== r) {
386
+ if (e !== t) {
391
387
  n.setState({
392
388
  childrenCount: e
393
389
  });
@@ -396,7 +392,6 @@
396
392
  n.state = {
397
393
  containerEl: null,
398
394
  menuEl: null,
399
- menuMaxHeight: undefined,
400
395
  numberOfItemsLoaded: 0,
401
396
  scrollBottomTriggered: false,
402
397
  windowTop: 0
@@ -406,25 +401,16 @@
406
401
  n.itemMinHeight = 28;
407
402
  return n;
408
403
  }
409
- C(r, [ {
404
+ L(r, [ {
410
405
  key: "componentDidUpdate",
411
406
  value: function e() {
412
- var t = this.state, o = t.containerEl, n = t.menuEl, r = t.menuMaxHeight;
413
- if (!d.isIE11 || !o || !n) {
407
+ var t, o;
408
+ var n = this.state, r = n.containerEl, l = n.menuEl;
409
+ if (!f.isIE11 || !r || !l) {
414
410
  return;
415
411
  }
416
- if (this.props.maxHeight) {
417
- var l = o.scrollHeight - n.clientHeight;
418
- var i = this.props.maxHeight - l;
419
- if (r === undefined || Math.abs(r - i) > 1) {
420
- // eslint-disable-next-line react/no-did-update-set-state
421
- this.setState({
422
- menuMaxHeight: i
423
- });
424
- }
425
- }
426
412
  // If onScrollBottom is defined, determine if it should be triggered.
427
- if (this.props && this.props.onScrollBottom && this.props.children) {
413
+ if (((t = this.props) === null || t === void 0 ? void 0 : t.onScrollBottom) && ((o = this.props) === null || o === void 0 ? void 0 : o.children)) {
428
414
  this.handleScrollBottomOnFullMenu();
429
415
  }
430
416
  }
@@ -458,50 +444,49 @@
458
444
  }, {
459
445
  key: "render",
460
446
  value: function e() {
461
- var t = this.props, l = t.animateLoading, i = t.children, s = t.controlledExternally, u = t.childrenStart, c = t.isLoading, f = t.loadingMessage, d = t.noOptionsMessage, v = t.onScrollBottom, g = t.placement, b = t.style, y = t.tabIndex;
462
- var M = p()(this.props, a()(r.propTypes));
447
+ var t = this.props, l = t.animateLoading, i = t.children, s = t.controlledExternally, u = t.childrenStart, c = t.isLoading, d = t.loadingMessage, f = t.noOptionsMessage, v = t.onScrollBottom, y = t.placement, b = t.style, g = t.tabIndex;
448
+ var S = p()(this.props, a()(r.propTypes));
463
449
  // Assumption: that you cannot be filtered if you are a result
464
450
  var x = o.Children.toArray(i).filter(o.isValidElement).some((function(e) {
465
451
  var t = e.type;
466
452
  return !(t === m.Divider && t.filterFirst || (t === m.Divider || t === m.Heading) && (t.filterLast || t.filterConsecutive));
467
453
  }));
468
- var w = this.checkFullHeight();
469
- var _ = G(this.state.menuMaxHeight);
454
+ var _ = this.checkFullHeight();
470
455
  var T = $(this.state.scrollBottomTriggered ? this.state.numberOfItemsLoaded * this.itemMinHeight || 0 : 0);
471
456
  /* eslint-disable jsx-a11y/aria-role */
472
- return n().createElement(S, H({
457
+ return n().createElement(M, B({
473
458
  key: "wrapper",
474
- style: b,
475
459
  ref: this.handleMount,
476
460
  onWheel: v ? this.handleWheelMenu : undefined,
477
461
  onMouseEnter: v ? this.handleMouseEnter : undefined,
478
462
  onMouseLeave: v ? this.handleMouseLeave : undefined
479
- }, p()(M, "tabIndex")), g !== "above" && u, g === "above" && this.renderFooterMessage(), n().createElement(m.MenuContext.Provider, {
480
- value: A
481
- }, n().createElement(h(), {
463
+ }, p()(S, "tabIndex"), {
464
+ style: b
465
+ }), y !== "above" && u, y === "above" && this.renderFooterMessage(), n().createElement(m.MenuContext.Provider, {
466
+ value: G
467
+ }, n().createElement(O, {
482
468
  key: "menu",
483
- style: _,
484
469
  controlledExternally: s,
485
470
  elementRef: this.handleMenuMount,
486
471
  onScroll: this.handleScroll,
487
472
  stopScrollPropagation: true,
488
- tabIndex: y
489
- }, !x && d && !c && n().createElement(h().Item, {
473
+ tabIndex: g
474
+ }, !x && f && !c && n().createElement(h().Item, {
490
475
  "data-test": "no-results-message",
491
476
  disabled: true
492
- }, d), i, v && !w &&
477
+ }, f), i, v && !_ &&
493
478
 
494
479
  // Bottom spacer fills in the space of new items being loaded by using the minimum possible height x menuItems.
495
480
  n().createElement("div", {
496
481
  "data-test": "results-menu-bottom-spacer",
497
482
  style: T
498
- }), c && n().createElement(E, null, l && n().createElement(O, null), n().createElement(k, null, f)))), g !== "above" && this.renderFooterMessage(), g === "above" && u);
483
+ }), c && n().createElement(E, null, l && n().createElement(k, null), n().createElement(w, null, d)))), y !== "above" && this.renderFooterMessage(), y === "above" && u);
499
484
  }
500
485
  } ]);
501
486
  return r;
502
487
  }(o.Component);
503
- D(z, "propTypes", N);
504
- D(z, "defaultProps", W);
488
+ D(z, "propTypes", W);
489
+ D(z, "defaultProps", A);
505
490
  /* harmony default export */ const U = z;
506
491
  // CONCATENATED MODULE: ./src/ResultsMenu/index.ts
507
492
  module.exports = t;