@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/TabBar.js CHANGED
@@ -61,8 +61,8 @@
61
61
  e.r(t);
62
62
  // EXPORTS
63
63
  e.d(t, {
64
- Tab: () => /* reexport */ L,
65
- default: () => /* reexport */ te
64
+ Tab: () => /* reexport */ Y,
65
+ default: () => /* reexport */ re
66
66
  });
67
67
  // CONCATENATED MODULE: external "react"
68
68
  const r = require("react");
@@ -93,19 +93,16 @@
93
93
  }),
94
94
  enterprise: (0, l.css)([ "&::before{border-bottom-width:1px;}" ])
95
95
  },
96
- vertical: {
97
- enterprise: (0, l.css)([ "display:inline-block;&::before{border-right-width:1px;}" ]),
98
- prisma: (0, l.css)([ "display:inline-block;&::before{border-right-width:1px;}" ])
99
- }
96
+ vertical: (0, l.css)([ "display:inline-block;&::before{border-right-width:1px;}" ])
100
97
  }));
101
98
  // CONCATENATED MODULE: external "@splunk/react-ui/Popover"
102
99
  const u = require("@splunk/react-ui/Popover");
103
100
  var d = e.n(u);
104
101
  // CONCATENATED MODULE: external "@splunk/react-ui/ScreenReaderContent"
105
102
  const f = require("@splunk/react-ui/ScreenReaderContent");
106
- var b = e.n(f);
103
+ var v = e.n(f);
107
104
  // CONCATENATED MODULE: external "@splunk/ui-utils/id"
108
- const v = require("@splunk/ui-utils/id");
105
+ const b = require("@splunk/ui-utils/id");
109
106
  // CONCATENATED MODULE: external "@splunk/react-ui/Clickable"
110
107
  const h = require("@splunk/react-ui/Clickable");
111
108
  var y = e.n(h);
@@ -113,11 +110,11 @@
113
110
  var m = c()(y()).withConfig({
114
111
  displayName: "TabStyles__StyledClickable",
115
112
  componentId: "sc-1ry8mzj-0"
116
- })([ "flex:0 1 auto;display:block;position:relative;line-height:", ";text-align:center;white-space:nowrap;color:", ";", ";&[aria-selected='true']{cursor:default;", "}&[aria-selected='false']{box-shadow:none;font-weight:", ";", " &:hover:not([disabled]){", "}}&:focus{box-shadow:", ";", "}" ], (0,
113
+ })([ "flex:0 1 auto;display:block;position:relative;line-height:", ";text-align:center;white-space:nowrap;color:", ";&::after{display:block;content:attr(title);font-weight:", ";height:0;color:transparent;overflow:hidden;visibility:hidden;}", ";&[aria-selected='true']{cursor:default;", "}&[aria-selected='false']{box-shadow:none;font-weight:", ";&:hover:not([disabled]){", "}}&:focus{box-shadow:", ";", "}" ], (0,
117
114
  s.pick)({
118
115
  enterprise: "24px",
119
116
  prisma: "20px"
120
- }), s.variables.contentColorDefault, (0, s.pickVariant)("$layout", {
117
+ }), s.variables.contentColorDefault, s.variables.fontWeightBold, (0, s.pickVariant)("$layout", {
121
118
  horizontal: (0, l.css)([ "padding:", ";margin-bottom:1px;" ], (0, s.pick)({
122
119
  enterprise: "3px 20px",
123
120
  prisma: {
@@ -141,8 +138,6 @@
141
138
  }), (0, s.pick)({
142
139
  enterprise: "normal",
143
140
  prisma: s.variables.fontWeightSemiBold
144
- }), (0, s.pick)({
145
- prisma: (0, l.css)([ "&::after{display:block;content:attr(title);font-weight:", ";height:0;color:transparent;overflow:hidden;visibility:hidden;}" ], s.variables.fontWeightBold)
146
141
  }), (0, s.pick)({
147
142
  prisma: (0, l.css)([ "color:", ";" ], s.variables.contentColorActive)
148
143
  }), s.variables.focusShadowInset, (0, s.pick)({
@@ -217,16 +212,19 @@
217
212
  compact: "10px 0"
218
213
  }
219
214
  }));
220
- var w = c().div.withConfig({
215
+ var w = c().span.withConfig({
221
216
  displayName: "TabStyles__StyledCount",
222
217
  componentId: "sc-1ry8mzj-4"
223
- })([ "", " display:inline-block;border-radius:18px;color:", ";font-size:", ";line-height:10px;padding:4px 6px;margin-left:", ";", " &[disabled]{background:", ";color:", ";}" ], s.mixins.reset("inlne-block"), s.variables.contentColorDefault, (0,
218
+ })([ "display:inline-block;border-radius:18px;color:", ";font-size:", ";line-height:10px;padding:", ";margin-inline-start:", ";", " &[disabled]{background:", ";color:", ";}" ], s.variables.contentColorDefault, (0,
224
219
  s.pick)({
225
220
  enterprise: "inherit",
226
221
  prisma: "10px"
222
+ }), (0, s.pick)({
223
+ enterprise: "0.4em 0.3em",
224
+ prisma: "0.4em 0.6em"
227
225
  }), (0, s.pick)({
228
226
  enterprise: "0",
229
- prisma: "8px"
227
+ prisma: "0.3em"
230
228
  }), (0, s.pick)({
231
229
  enterprise: (0, l.css)([ "&::before{content:'(';}&::after{content:')';}" ]),
232
230
  prisma: (0, l.css)([ "background:", ";" ], s.variables.neutral100)
@@ -241,7 +239,7 @@
241
239
  /* harmony default export */ const C = S;
242
240
  // CONCATENATED MODULE: ./src/utils/getCountValue.ts
243
241
  // A utility for max count
244
- var I = function e(t, r) {
242
+ var T = function e(t, r) {
245
243
  if (t > r) {
246
244
  return "".concat(r, "+");
247
245
  }
@@ -254,7 +252,7 @@
254
252
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
255
253
  * @param current - The new value of the ref.
256
254
  */
257
- function j(e, t) {
255
+ function I(e, t) {
258
256
  if (e) {
259
257
  if (typeof e === "function") {
260
258
  e(t);
@@ -267,18 +265,18 @@
267
265
  }
268
266
  }
269
267
  // CONCATENATED MODULE: ./src/TabBar/Tab.tsx
270
- function T(e) {
268
+ function j(e) {
271
269
  "@babel/helpers - typeof";
272
270
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
273
- T = function e(t) {
271
+ j = function e(t) {
274
272
  return typeof t;
275
273
  };
276
274
  } else {
277
- T = function e(t) {
275
+ j = function e(t) {
278
276
  return t && typeof Symbol === "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
279
277
  };
280
278
  }
281
- return T(e);
279
+ return j(e);
282
280
  }
283
281
  function z() {
284
282
  z = Object.assign || function(e) {
@@ -374,7 +372,7 @@
374
372
  };
375
373
  }
376
374
  function K(e, t) {
377
- if (t && (T(t) === "object" || typeof t === "function")) {
375
+ if (t && (j(t) === "object" || typeof t === "function")) {
378
376
  return t;
379
377
  }
380
378
  return V(e);
@@ -427,6 +425,8 @@
427
425
  label: o().oneOfType([ o().string, o().element ]),
428
426
  /** @private Maximum count number in tab label */
429
427
  maxCount: o().number,
428
+ /** @private */
429
+ splunkTheme: o().object,
430
430
  tabId: o().string,
431
431
  /** @private. The internal key of the tab */
432
432
  tabKey: o().number,
@@ -450,7 +450,7 @@
450
450
  n.setState({
451
451
  anchor: e
452
452
  });
453
- j(n.props.elementRef, e);
453
+ I(n.props.elementRef, e);
454
454
  }));
455
455
  N(V(n), "handleTooltipOpen", (function() {
456
456
  n.setState({
@@ -486,8 +486,8 @@
486
486
  tabKey: i
487
487
  });
488
488
  }));
489
- n.popoverId = (0, v.createDOMID)("popover");
490
- n.ariaId = (0, v.createDOMID)("aria-id");
489
+ n.popoverId = (0, b.createDOMID)("popover");
490
+ n.ariaId = (0, b.createDOMID)("aria-id");
491
491
  n.state = {
492
492
  open: false,
493
493
  anchor: null
@@ -503,16 +503,28 @@
503
503
  }, {
504
504
  key: "render",
505
505
  value: function e() {
506
- var t = this.props, r = t.active, i = t.ariaControls, o = t.count, a = t.disabled, l = t.icon, c = t.label, s = t.tabId, p = t.maxCount, u = t.to, f = t.tooltip, v = _(t, [ "active", "ariaControls", "count", "disabled", "icon", "label", "tabId", "maxCount", "to", "tooltip" ]);
507
- var h = this.state, y = h.anchor, S = h.open;
508
- var C = this.context, j = C.appearance, T = C.disabled, E = C.iconSize, P = C.layout, $ = C.width;
509
- var R = v.style;
510
- var D = T || a || false;
511
- var M = E || "inline";
512
- var q = P || "horizontal";
513
- var K = $ ? {
514
- width: $
515
- } : R;
506
+ var t = this.props, r = t.active, i = t.ariaControls, o = t.count, a = t.disabled, l = t.icon, c = t.label, s = t.tabId, p = t.maxCount, u = t.splunkTheme, f = t.to, b = t.tooltip, h = _(t, [ "active", "ariaControls", "count", "disabled", "icon", "label", "tabId", "maxCount", "splunkTheme", "to", "tooltip" ]);
507
+ var y = this.state, S = y.anchor, C = y.open;
508
+ var I = this.context, j = I.appearance, E = I.disabled, P = I.iconSize, $ = I.layout, R = I.width;
509
+ var D = h.style;
510
+ var M = E || a || false;
511
+ var q = P || "inline";
512
+ var K = $ || "horizontal";
513
+ var V = R ? {
514
+ width: R
515
+ } : D;
516
+ var A = u.isEnterprise;
517
+ var B = c ? c.toString() : "";
518
+ var N = o === 0 || o ? "".concat(o === null || o === void 0 ? void 0 : o.toString()) : "";
519
+ // title is used for CSS styling in TabStyles. labelValue and countValue needs to be included in the title.
520
+ var W;
521
+ if (A) {
522
+ // countValue needs unicode space for width to not change after it's clicked.
523
+ var F = N ? "(".concat(N, ")  ") : "";
524
+ W = "".concat(B, " ").concat(F);
525
+ } else {
526
+ W = "".concat(B, "    ").concat(N);
527
+ }
516
528
 
517
529
  // TODO: Fix the ts error: https://splunk.atlassian.net/browse/SUI-5569
518
530
  // eslint-disable-next-line
@@ -523,13 +535,13 @@
523
535
  "aria-labelledby": this.ariaId,
524
536
  "data-test": "tab",
525
537
  "data-test-tab-id": s,
526
- "data-test-popover-id": f ? this.popoverId : undefined,
527
- $layout: q,
528
- $icon: l && M !== "inline" ? true : undefined,
529
- disabled: D,
538
+ "data-test-popover-id": b ? this.popoverId : undefined,
539
+ $layout: K,
540
+ $icon: l && q !== "inline" ? true : undefined,
541
+ disabled: M,
530
542
  elementRef: this.handleMount,
531
- style: K
532
- }, v, {
543
+ style: V
544
+ }, h, {
533
545
  onClick: this.handleClick,
534
546
  onFocus: this.handleFocus,
535
547
  onMouseEnter: this.handleTooltipOpen,
@@ -537,34 +549,35 @@
537
549
  onMouseLeave: this.handleTooltipClose,
538
550
  role: "tab",
539
551
  tabIndex: r ? undefined : -1,
540
- to: u
552
+ title: W,
553
+ to: f
541
554
  }), n().createElement(k, {
542
555
  "data-test": "label",
543
556
  $withUnderline: j === "navigation"
544
557
  }, l && n().createElement(x, {
545
- $iconSize: M
546
- }, l), c, (o === 0 || o) && n().createElement(n().Fragment, null, n().createElement(b(), null, " "), n().createElement(w, {
558
+ $iconSize: q
559
+ }, l), c, (o === 0 || o) && n().createElement(n().Fragment, null, n().createElement(v(), null, " "), n().createElement(w, {
547
560
  "data-test": "count",
548
- disabled: D
549
- }, p ? I(o, p) : o))), n().createElement(g, {
550
- $layout: q,
561
+ disabled: M
562
+ }, p ? T(o, p) : o))), n().createElement(g, {
563
+ $layout: K,
551
564
  $withUnderline: j === "navigation"
552
- }), !a && f && n().createElement(d(), {
565
+ }), !a && b && n().createElement(d(), {
553
566
  role: "tooltip",
554
- anchor: y,
567
+ anchor: S,
555
568
  animationConfig: {
556
569
  tension: 400
557
570
  },
558
571
  appearance: "inverted",
559
572
  closeReasons: [ "offScreen", "escapeKey" ],
560
- defaultPlacement: q === "vertical" ? "right" : "above",
573
+ defaultPlacement: K === "vertical" ? "right" : "above",
561
574
  id: this.popoverId,
562
- open: !!y && S,
575
+ open: !!S && C,
563
576
  align: "center"
564
- }, n().createElement(O, null, f)), f && n().createElement(b(), {
577
+ }, n().createElement(O, null, b)), b && n().createElement(v(), {
565
578
  "aria-hidden": "true",
566
579
  id: this.ariaId
567
- }, f));
580
+ }, b));
568
581
  }
569
582
  } ]);
570
583
  return r;
@@ -572,10 +585,12 @@
572
585
  N(U, "propTypes", W);
573
586
  N(U, "defaultProps", F);
574
587
  N(U, "contextType", C);
575
- /* harmony default export */ const L = U;
588
+ var L = (0, s.withSplunkTheme)(U);
589
+ L.propTypes = U.propTypes;
590
+ /* harmony default export */ const Y = L;
576
591
  // CONCATENATED MODULE: ./src/utils/navigateList.ts
577
592
  // A utility for keyboard navigation of lists
578
- function Y(e, t, r) {
593
+ function G(e, t, r) {
579
594
  for (var n = 0; n < e.length; n += 1) {
580
595
  var i;
581
596
  var o = (n + r) % e.length;
@@ -585,7 +600,7 @@
585
600
  }
586
601
  return e[t];
587
602
  }
588
- function G(e, t, r) {
603
+ function H(e, t, r) {
589
604
  for (var n = e.length; n > 0; n -= 1) {
590
605
  var i;
591
606
  var o = (n + r) % e.length;
@@ -596,8 +611,8 @@
596
611
  return e[t];
597
612
  }
598
613
  // CONCATENATED MODULE: ./src/TabBar/TabBar.tsx
599
- function H() {
600
- H = Object.assign || function(e) {
614
+ function J() {
615
+ J = Object.assign || function(e) {
601
616
  for (var t = 1; t < arguments.length; t++) {
602
617
  var r = arguments[t];
603
618
  for (var n in r) {
@@ -608,11 +623,11 @@
608
623
  }
609
624
  return e;
610
625
  };
611
- return H.apply(this, arguments);
626
+ return J.apply(this, arguments);
612
627
  }
613
- function J(e, t) {
628
+ function Q(e, t) {
614
629
  if (e == null) return {};
615
- var r = Q(e, t);
630
+ var r = X(e, t);
616
631
  var n, i;
617
632
  if (Object.getOwnPropertySymbols) {
618
633
  var o = Object.getOwnPropertySymbols(e);
@@ -625,7 +640,7 @@
625
640
  }
626
641
  return r;
627
642
  }
628
- function Q(e, t) {
643
+ function X(e, t) {
629
644
  if (e == null) return {};
630
645
  var r = {};
631
646
  var n = Object.keys(e);
@@ -637,8 +652,8 @@
637
652
  }
638
653
  return r;
639
654
  }
640
- var X = 50;
641
- /** @public */ var Z = {
655
+ var Z = 50;
656
+ /** @public */ var ee = {
642
657
  autoActivate: o().bool,
643
658
  activeTabId: o().string,
644
659
  appearance: o().oneOf([ "navigation", "context" ]),
@@ -651,8 +666,8 @@
651
666
  onChange: o().func,
652
667
  tabWidth: o().number
653
668
  };
654
- function ee(e) {
655
- var t = e.activeTabId, i = e.autoActivate, o = e.appearance, l = o === void 0 ? "navigation" : o, c = e.children, s = e.disabled, u = s === void 0 ? false : s, d = e.elementRef, f = e.iconSize, b = f === void 0 ? "inline" : f, v = e.layout, h = v === void 0 ? "horizontal" : v, y = e.onChange, m = e.tabWidth, g = J(e, [ "activeTabId", "autoActivate", "appearance", "children", "disabled", "elementRef", "iconSize", "layout", "onChange", "tabWidth" ]);
669
+ function te(e) {
670
+ var t = e.activeTabId, i = e.autoActivate, o = e.appearance, l = o === void 0 ? "navigation" : o, c = e.children, s = e.disabled, u = s === void 0 ? false : s, d = e.elementRef, f = e.iconSize, v = f === void 0 ? "inline" : f, b = e.layout, h = b === void 0 ? "horizontal" : b, y = e.onChange, m = e.tabWidth, g = Q(e, [ "activeTabId", "autoActivate", "appearance", "children", "disabled", "elementRef", "iconSize", "layout", "onChange", "tabWidth" ]);
656
671
  // @docs-props-type TabBarPropsBase
657
672
  var x = (0, r.useRef)(0);
658
673
  var k = [];
@@ -673,40 +688,40 @@
673
688
  });
674
689
  }
675
690
  };
676
- var I = function e(t, r) {
691
+ var T = function e(t, r) {
677
692
  y === null || y === void 0 ? void 0 : y(t, {
678
693
  selectedTabId: r.tabId
679
694
  });
680
695
  };
681
- var j = 0;
682
- var T = r.Children.toArray(c).filter(r.isValidElement).map((function(e) {
696
+ var I = 0;
697
+ var j = r.Children.toArray(c).filter(r.isValidElement).map((function(e) {
683
698
  // <TabBar> allows non-<Tab> children, pass them through without any modification
684
- if (typeof e.type === "string" || e.type.name !== L.name) {
699
+ if (typeof e.type === "string" || e.type.name !== Y.name) {
685
700
  return e;
686
701
  }
687
702
  var i = n().createRef();
688
703
  k.push(i);
689
704
  var o = {
690
705
  active: t === e.props.tabId,
691
- tabKey: j,
706
+ tabKey: I,
692
707
  ref: i
693
708
  };
694
- j += 1;
709
+ I += 1;
695
710
 
696
711
  return (0, r.cloneElement)(e, o);
697
712
  }));
698
- var z = m && m > X ? m : null;
713
+ var z = m && m > Z ? m : null;
699
714
  var _ = function e(t) {
700
715
  var r = (0, a.keycode)(t.nativeEvent);
701
716
  var n;
702
717
  if (r === w) {
703
- n = Y(k, x.current, x.current + 1);
718
+ n = G(k, x.current, x.current + 1);
704
719
  } else if (r === O) {
705
- n = G(k, x.current, x.current - 1);
720
+ n = H(k, x.current, x.current - 1);
706
721
  } else if (r === "home") {
707
- n = Y(k, x.current, 0);
722
+ n = G(k, x.current, 0);
708
723
  } else if (r === "end") {
709
- n = G(k, x.current, k.length - 1);
724
+ n = H(k, x.current, k.length - 1);
710
725
  }
711
726
  if (n != null) {
712
727
  var i;
@@ -715,7 +730,7 @@
715
730
  }
716
731
  };
717
732
 
718
- return n().createElement(p, H({
733
+ return n().createElement(p, J({
719
734
  "data-tab-layout": h,
720
735
  "data-test-active-tab-id": t,
721
736
  "data-test": "tab-bar",
@@ -728,17 +743,17 @@
728
743
  value: {
729
744
  appearance: l,
730
745
  disabled: u,
731
- iconSize: b,
746
+ iconSize: v,
732
747
  layout: h,
733
- onClick: I,
748
+ onClick: T,
734
749
  onFocus: S,
735
750
  width: z
736
751
  }
737
- }, T));
752
+ }, j));
738
753
  }
739
- ee.propTypes = Z;
740
- ee.Tab = L;
741
- /* harmony default export */ const te = ee;
754
+ te.propTypes = ee;
755
+ te.Tab = Y;
756
+ /* harmony default export */ const re = te;
742
757
  // CONCATENATED MODULE: ./src/TabBar/index.ts
743
758
  module.exports = t;
744
759
  /******/})();