@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/RadioBar.js CHANGED
@@ -90,7 +90,7 @@
90
90
  const y = require("@splunk/react-ui/Clickable");
91
91
  var h = e.n(y);
92
92
  // CONCATENATED MODULE: ./src/RadioBar/OptionStyles.ts
93
- var m = b()(h()).withConfig({
93
+ var g = b()(h()).withConfig({
94
94
  displayName: "OptionStyles__StyledClickable",
95
95
  componentId: "fyq77p-0"
96
96
  })([ "border-radius:3px;flex:1 1 auto;display:flex;justify-content:center;align-items:center;color:", ";padding:2px 12px;height:calc(", " - 6px);position:relative;gap:", ";& + &{margin-left:2px;}", " ", " &:focus{color:", ";box-shadow:", ";z-index:2;&:active{background-color:", ";}}", " ", "" ], f.variables.contentColorDefault, f.variables.inputHeight, f.variables.spacingXSmall, (function(e) {
@@ -110,7 +110,7 @@
110
110
  var r = e.disabled;
111
111
  return r && (0, v.css)([ "color:", ";" ], f.variables.contentColorDisabled);
112
112
  }));
113
- var g = b().div.withConfig({
113
+ var m = b().div.withConfig({
114
114
  displayName: "OptionStyles__StyledIcon",
115
115
  componentId: "fyq77p-1"
116
116
  })([ "flex:0 0 auto;margin-top:-2px;font-size:15px;" ]);
@@ -120,19 +120,19 @@
120
120
  })([ "", " flex:0 1 auto;", "" ], f.mixins.ellipsis, (0, f.pick)({
121
121
  enterprise: (0, v.css)([ "&:not(:first-child){margin-left:", ";}" ], f.variables.spacingXSmall)
122
122
  }));
123
- var k = b().div.withConfig({
123
+ var x = b().div.withConfig({
124
124
  displayName: "OptionStyles__StyledAdornment",
125
125
  componentId: "fyq77p-3"
126
126
  })([ "flex:0 0 auto;", "" ], (0, f.pick)({
127
127
  enterprise: (0, v.css)([ "&:not(:first-child){margin-left:", ";}" ], f.variables.spacingXSmall)
128
128
  }));
129
129
  // CONCATENATED MODULE: ./src/RadioBar/RadioBarContext.tsx
130
- var C = (0, t.createContext)({});
131
- C.displayName = "RadioBar";
132
- /* harmony default export */ const S = C;
130
+ var k = (0, t.createContext)({});
131
+ k.displayName = "RadioBar";
132
+ /* harmony default export */ const w = k;
133
133
  // CONCATENATED MODULE: ./src/RadioBar/Option.tsx
134
- function w() {
135
- w = Object.assign || function(e) {
134
+ function C() {
135
+ C = Object.assign || function(e) {
136
136
  for (var r = 1; r < arguments.length; r++) {
137
137
  var t = arguments[r];
138
138
  for (var n in t) {
@@ -143,11 +143,11 @@
143
143
  }
144
144
  return e;
145
145
  };
146
- return w.apply(this, arguments);
146
+ return C.apply(this, arguments);
147
147
  }
148
- function j(e, r) {
148
+ function S(e, r) {
149
149
  if (e == null) return {};
150
- var t = x(e, r);
150
+ var t = j(e, r);
151
151
  var n, a;
152
152
  if (Object.getOwnPropertySymbols) {
153
153
  var l = Object.getOwnPropertySymbols(e);
@@ -160,7 +160,7 @@
160
160
  }
161
161
  return t;
162
162
  }
163
- function x(e, r) {
163
+ function j(e, r) {
164
164
  if (e == null) return {};
165
165
  var t = {};
166
166
  var n = Object.keys(e);
@@ -184,22 +184,22 @@
184
184
  value: l().any.isRequired
185
185
  };
186
186
  function E(e) {
187
- var r = e.disabled, a = e.icon, l = e.label, o = e.selected, i = e.startAdornment, u = e.endAdornment, c = e.value, s = j(e, [ "disabled", "icon", "label", "selected", "startAdornment", "endAdornment", "value" ]);
187
+ var r = e.disabled, a = e.icon, l = e.label, o = e.selected, i = e.startAdornment, u = e.endAdornment, c = e.value, s = S(e, [ "disabled", "icon", "label", "selected", "startAdornment", "endAdornment", "value" ]);
188
188
  // @docs-props-type OptionPropsBase
189
- var f = (0, t.useContext)(S), d = f.onClick, v = f.appearance, b = f.error, y = f.onKeyDown, h = f.firstValue, C = f.selectedValue;
189
+ var f = (0, t.useContext)(w), d = f.onClick, v = f.appearance, b = f.error, y = f.onKeyDown, h = f.firstValue, k = f.selectedValue;
190
190
  if (false) {}
191
- var x = -1;
192
- if (C) {
193
- if (c === C) {
194
- x = 0;
191
+ var j = -1;
192
+ if (k) {
193
+ if (c === k) {
194
+ j = 0;
195
195
  }
196
196
  } else if (c === h) {
197
- x = 0;
197
+ j = 0;
198
198
  }
199
- var P = x;
199
+ var P = j;
200
200
  if (v === "prisma") {
201
201
 
202
- return n().createElement(m, w({
202
+ return n().createElement(g, C({
203
203
  "data-test": "option",
204
204
  "data-test-value": c
205
205
  }, s, {
@@ -220,10 +220,10 @@
220
220
  label: l
221
221
  });
222
222
  }
223
- }), a && n().createElement(g, null, a), i && n().createElement(k, null, i), l && n().createElement(O, null, l), u && n().createElement(k, null, u));
223
+ }), a && n().createElement(m, null, a), i && n().createElement(x, null, i), l && n().createElement(O, null, l), u && n().createElement(x, null, u));
224
224
  }
225
225
 
226
- return n().createElement(p(), w({
226
+ return n().createElement(p(), C({
227
227
  "data-test": "option",
228
228
  "data-test-value": c,
229
229
  appearance: v,
@@ -248,15 +248,15 @@
248
248
  label: l
249
249
  });
250
250
  }
251
- }), i && n().createElement(k, null, i), l && n().createElement(O, null, l), u && n().createElement(k, null, u));
251
+ }), i && n().createElement(x, null, i), l && n().createElement(O, null, l), u && n().createElement(x, null, u));
252
252
  }
253
253
  E.propTypes = P;
254
254
  /* harmony default export */ const _ = E;
255
255
  // CONCATENATED MODULE: external "@splunk/react-ui/Box"
256
- const q = require("@splunk/react-ui/Box");
257
- var D = e.n(q);
256
+ const T = require("@splunk/react-ui/Box");
257
+ var q = e.n(T);
258
258
  // CONCATENATED MODULE: ./src/RadioBar/RadioBarStyles.ts
259
- var V = b()(D()).withConfig({
259
+ var D = b()(q()).withConfig({
260
260
  displayName: "RadioBarStyles__StyledRadioBar",
261
261
  componentId: "gg1b79-0"
262
262
  })([ "height:", ";", " [data-inline] + &{margin-left:", ";}" ], f.variables.inputHeight, (0,
@@ -273,21 +273,21 @@
273
273
  prisma: f.variables.spacingSmall
274
274
  }));
275
275
  // CONCATENATED MODULE: ./src/RadioBar/RadioBar.tsx
276
- function T(e) {
276
+ function R(e) {
277
277
  "@babel/helpers - typeof";
278
278
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
279
- T = function e(r) {
279
+ R = function e(r) {
280
280
  return typeof r;
281
281
  };
282
282
  } else {
283
- T = function e(r) {
283
+ R = function e(r) {
284
284
  return r && typeof Symbol === "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
285
285
  };
286
286
  }
287
- return T(e);
287
+ return R(e);
288
288
  }
289
- function A() {
290
- A = Object.assign || function(e) {
289
+ function V() {
290
+ V = Object.assign || function(e) {
291
291
  for (var r = 1; r < arguments.length; r++) {
292
292
  var t = arguments[r];
293
293
  for (var n in t) {
@@ -298,11 +298,11 @@
298
298
  }
299
299
  return e;
300
300
  };
301
- return A.apply(this, arguments);
301
+ return V.apply(this, arguments);
302
302
  }
303
- function B(e, r) {
303
+ function A(e, r) {
304
304
  if (e == null) return {};
305
- var t = R(e, r);
305
+ var t = B(e, r);
306
306
  var n, a;
307
307
  if (Object.getOwnPropertySymbols) {
308
308
  var l = Object.getOwnPropertySymbols(e);
@@ -315,7 +315,7 @@
315
315
  }
316
316
  return t;
317
317
  }
318
- function R(e, r) {
318
+ function B(e, r) {
319
319
  if (e == null) return {};
320
320
  var t = {};
321
321
  var n = Object.keys(e);
@@ -338,7 +338,7 @@
338
338
  }
339
339
  return t;
340
340
  }
341
- function $(e) {
341
+ function N(e) {
342
342
  for (var r = 1; r < arguments.length; r++) {
343
343
  var t = arguments[r] != null ? arguments[r] : {};
344
344
  if (r % 2) {
@@ -355,7 +355,7 @@
355
355
  }
356
356
  return e;
357
357
  }
358
- function N(e, r) {
358
+ function $(e, r) {
359
359
  if (!(e instanceof r)) {
360
360
  throw new TypeError("Cannot call a class as a function");
361
361
  }
@@ -408,7 +408,7 @@
408
408
  };
409
409
  }
410
410
  function L(e, r) {
411
- if (r && (T(r) === "object" || typeof r === "function")) {
411
+ if (r && (R(r) === "object" || typeof r === "function")) {
412
412
  return r;
413
413
  }
414
414
  return U(e);
@@ -480,7 +480,7 @@
480
480
  // eslint-disable-line @typescript-eslint/no-explicit-any
481
481
  function a(e) {
482
482
  var t;
483
- N(this, a);
483
+ $(this, a);
484
484
  t = r.call(this, e);
485
485
  J(U(t), "controlledExternally", void 0);
486
486
  J(U(t), "filteredValues", []);
@@ -495,28 +495,22 @@
495
495
  var u = 0;
496
496
  var c = t.filteredValues.indexOf(n);
497
497
  if (l === "down" || l === "right") {
498
- var f;
499
498
  e.preventDefault();
500
- u = c + 1;
501
- if (u > t.filteredValues.length - 1) {
502
- u = 0;
503
- }
504
- i = o.nextSibling ? o.nextSibling : (f = o.parentElement) === null || f === void 0 ? void 0 : f.firstElementChild;
499
+ var f = t.getNextTarget("forward", o, c), d = f.nextTargetRes, p = f.nextIndexRes;
500
+ i = d;
501
+ u = p;
505
502
  } else if (l === "up" || l === "left") {
506
- var d;
507
503
  e.preventDefault();
508
- u = c - 1;
509
- if (u < 0) {
510
- u = t.filteredValues.length - 1;
511
- }
512
- i = o.previousSibling ? o.previousSibling : (d = o.parentElement) === null || d === void 0 ? void 0 : d.lastElementChild;
504
+ var v = t.getNextTarget("backward", o, c), b = v.nextTargetRes, y = v.nextIndexRes;
505
+ i = b;
506
+ u = y;
513
507
  }
514
508
  if (i) {
515
- var p;
516
- (p = i) === null || p === void 0 ? void 0 : p.focus();
517
- var v = t.filteredValues[u];
509
+ var h;
510
+ (h = i) === null || h === void 0 ? void 0 : h.focus();
511
+ var g = t.filteredValues[u];
518
512
  t.handleOnChange(e, {
519
- value: v,
513
+ value: g,
520
514
  label: a
521
515
  });
522
516
  }
@@ -524,7 +518,7 @@
524
518
  J(U(t), "handleOnChange", (function(e, r) {
525
519
  if (t.props.value !== r.value) {
526
520
  var n, a;
527
- (n = (a = t.props).onChange) === null || n === void 0 ? void 0 : n.call(a, e, $({
521
+ (n = (a = t.props).onChange) === null || n === void 0 ? void 0 : n.call(a, e, N({
528
522
  name: t.props.name
529
523
  }, r));
530
524
  if (!t.isControlled()) {
@@ -554,17 +548,47 @@
554
548
  value: function e() {
555
549
  return this.controlledExternally;
556
550
  }
551
+ // TODO: Once converted to a functional component, this function can be removed and RadioBar should use useRovingFocus hook
552
+ }, {
553
+ key: "getNextTarget",
554
+ value: function e(r, t, n) {
555
+ var a = r === "forward" ? 1 : -1;
556
+ var l = r === "forward" ? "nextSibling" : "previousSibling";
557
+ var o = r === "forward" ? "firstElementChild" : "lastElementChild";
558
+ var i = r === "forward" ? 0 : this.filteredValues.length - 1;
559
+ var u = t[l];
560
+ var c = null;
561
+ var s = n + a;
562
+ while (u !== t && c === null) {
563
+ if (u === null) {
564
+ var f;
565
+ u = (f = t.parentElement) === null || f === void 0 ? void 0 : f[o];
566
+ s = i;
567
+ }
568
+ if (u.disabled) {
569
+ var d = u[l];
570
+ u = d;
571
+ s += a;
572
+ } else {
573
+ c = u;
574
+ }
575
+ }
576
+ return {
577
+ nextTargetRes: c,
578
+ nextIndexRes: s
579
+ };
580
+ }
557
581
  }, {
558
582
  key: "render",
559
583
  value: function e() {
560
584
  var r = this;
561
- var a = this.props, l = a.appearance, o = a.children, i = a.describedBy, u = a.error, s = a.labelledBy, f = a.splunkTheme, d = a.value, p = a.required, v = B(a, [ "appearance", "children", "describedBy", "error", "labelledBy", "splunkTheme", "value", "required" ]);
585
+ var a = this.props, l = a.appearance, o = a.children, i = a.describedBy, u = a.error, s = a.labelledBy, f = a.splunkTheme, d = a.value, p = a.required, v = A(a, [ "appearance", "children", "describedBy", "error", "labelledBy", "splunkTheme", "value", "required" ]);
562
586
  if (false) {}
563
587
  var b = this.isControlled() ? d : this.state.value;
564
588
  var y = f.isPrisma;
565
589
  var h = true;
566
590
  this.filteredValues = [];
567
- var m = t.Children.toArray(o).filter(t.isValidElement).map((function(e, n, a) {
591
+ var g = t.Children.toArray(o).filter(t.isValidElement).map((function(e, n, a) {
568
592
  var l = a.length;
569
593
  r.filteredValues.push(e.props.value);
570
594
  if (e.props && !e.props.disabled) {
@@ -578,19 +602,19 @@
578
602
  prepend: n > 0
579
603
  });
580
604
  }));
581
- var g = this.filteredValues[0];
605
+ var m = this.filteredValues[0];
582
606
  var O = d == null || this.filteredValues.includes(b);
583
607
  if (false) {}
584
- var k = {
608
+ var x = {
585
609
  appearance: y ? "prisma" : l,
586
610
  onClick: this.handleClick,
587
611
  error: y ? false : u,
588
612
  onKeyDown: this.handleOnKeyDown,
589
- firstValue: g,
613
+ firstValue: m,
590
614
  selectedValue: O ? b : undefined
591
615
  };
592
616
 
593
- return n().createElement(V, A({
617
+ return n().createElement(D, V({
594
618
  flex: true,
595
619
  $disabled: h,
596
620
  $error: u,
@@ -600,9 +624,9 @@
600
624
  "aria-labelledby": s,
601
625
  "aria-describedby": i,
602
626
  "aria-required": p
603
- }, c()(v, "onChange")), n().createElement(S.Provider, {
604
- value: k
605
- }, m));
627
+ }, c()(v, "onChange")), n().createElement(w.Provider, {
628
+ value: x
629
+ }, g));
606
630
  }
607
631
  } ]);
608
632
  return a;