@splunk/react-ui 4.31.0 → 4.33.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 (40) hide show
  1. package/Button.js +42 -45
  2. package/ButtonSimple.js +533 -302
  3. package/CHANGELOG.md +32 -1
  4. package/Card.js +22 -24
  5. package/Clickable.js +86 -76
  6. package/FormRows.js +229 -207
  7. package/MIGRATION.mdx +23 -0
  8. package/Menu.js +1 -1
  9. package/Modal.js +156 -131
  10. package/Multiselect.js +47 -33
  11. package/Select.js +236 -220
  12. package/TabBar.js +18 -18
  13. package/Text.js +21 -32
  14. package/package.json +6 -6
  15. package/types/src/Button/Button.d.ts +4 -4
  16. package/types/src/ButtonSimple/ButtonSimple.d.ts +8 -6
  17. package/types/src/ButtonSimple/mixin.d.ts +27 -0
  18. package/types/src/Card/Card.d.ts +13 -5
  19. package/types/src/Clickable/Clickable.d.ts +7 -10
  20. package/types/src/Clickable/NavigationProvider.d.ts +8 -1
  21. package/types/src/Date/Date.d.ts +2 -2
  22. package/types/src/Menu/Item.d.ts +0 -1
  23. package/types/src/Number/Number.d.ts +2 -2
  24. package/types/src/Select/Select.d.ts +6 -2
  25. package/types/src/Select/SelectBase.d.ts +6 -2
  26. package/types/src/Slider/Slider.d.ts +2 -2
  27. package/types/src/Text/docs/examples/Basic.d.ts +1 -9
  28. package/types/src/Text/docs/examples/Error.d.ts +2 -10
  29. package/types/src/Text/docs/examples/Inline.d.ts +1 -9
  30. package/types/src/Text/docs/examples/Multiline.d.ts +1 -9
  31. package/types/src/Text/docs/examples/Password.d.ts +1 -9
  32. package/types/src/Text/docs/examples/Search.d.ts +1 -9
  33. package/types/src/Button/docs/examples/prisma/Basic.d.ts +0 -2
  34. package/types/src/Button/docs/examples/prisma/Block.d.ts +0 -2
  35. package/types/src/Button/docs/examples/prisma/Disabled.d.ts +0 -2
  36. package/types/src/Button/docs/examples/prisma/Icons.d.ts +0 -2
  37. package/types/src/Button/docs/examples/prisma/Menus.d.ts +0 -2
  38. package/types/src/Button/docs/examples/prisma/To.d.ts +0 -2
  39. package/types/src/Button/docs/examples/prisma/Truncated.d.ts +0 -2
  40. /package/types/src/{Button/docs/examples/prisma → Clickable/docs/examples}/Dimmed.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,12 +1,43 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 4.33.0 - July 8, 2024
5
+ ----------
6
+ New Features:
7
+ * `Clickable` now supports the `"dimmed"` value for the `disabled` prop (SUI-5819).
8
+ * If set to `"dimmed"`, the component does not respond to mouse events and `aria-disabled` is set to `true`.
9
+ * `Button` now supports `appearance="subtle"` with a visual appearance similar to the Enterprise `"pill"` and Prisma `"secondary"` appearances (SUI-6051).
10
+ * `Button` now sets the `aria-pressed` attribute appropriately when the `selected` prop is provided (SUI-2791).
11
+ * `Select` has a new `toggleContent` prop that specifies whether the children (`"optionChildren"`) or label (`"optionLabel"`) of the matched `Option` are rendered in the toggle button (SUI-6316).
12
+ * `Menu.Item` now supports `descriptionPosition="right"` for Prisma themes (SUI-5664).
13
+
14
+ Bug Fixes:
15
+ * `Modal.Header` uses semantic HTML elements for the `title` and `subtitle` props to improve accessibility.
16
+ * `TabBar.Tab` has a correctly sized active indicator when vertical and the `to` prop is passed (SUI-6205).
17
+ * `Button`'s text is now centered correctly when combining the `icon` and `to` props (SUI-6331).
18
+ * `Button`'s external icon now has the same size as an icon rendered by the `icon` prop (SUI-6255).
19
+ * `Select` now constructs `aria-label` out of the `Option`-s `label`s rather than `children` (SUI-6316).
20
+
21
+ Deprecations:
22
+ * `Button`'s `"flat"`, `"pill"`, and `"toggle"` values of the `appearance` prop have been deprecated and will be removed in the next major version (SUI-6501).
23
+
24
+ Docs:
25
+ * Fixed an issue where `SidePanel`'s Test Hooks content was not shown (SUI-6322).
26
+
27
+ 4.32.0 - June 4, 2024
28
+ ----------
29
+ New Features:
30
+ * `Clickable`'s `NavigationProvider` now accepts a new `onLinkClick` prop to handle click events globally (SUI-5291).
31
+
32
+ Typescript:
33
+ * `Card`'s `selected` prop now requires `onClick` to also be provided (SUI-6200).
34
+
4
35
  4.31.0 - May 16, 2024
5
36
  ----------
6
37
  New Features:
7
38
  * `Divider` has a new `decorative` prop for disabling the default semantics of `role="separator"`.
8
39
 
9
- Bug Fixes:
40
+ Bug Fixes:
10
41
  * `SidePanel` incorrectly rendered the overlay mask when `useLayerForClickAway={false}`. This has been fixed (SUI-6260).
11
42
 
12
43
  4.30.0 - May 6, 2024
package/Card.js CHANGED
@@ -695,26 +695,24 @@
695
695
  };
696
696
  var Pe = {
697
697
  openInNewContext: false,
698
- selected: false,
699
698
  showBorder: true
700
699
  };
701
700
  function _e(e) {
702
701
  return !!e.onClick || !!e.to;
703
702
  }
704
703
  function Te(e) {
705
- var r = e.margin, t = e.maxWidth, n = e.minWidth, o = e.selected, i = e.showBorder, a = e.style, l = ke(e, [ "margin", "maxWidth", "minWidth", "selected", "showBorder", "style" ]);
706
- var c = xe({
704
+ var r = e.margin, t = e.maxWidth, n = e.minWidth, o = e.showBorder, i = e.style, a = ke(e, [ "margin", "maxWidth", "minWidth", "showBorder", "style" ]);
705
+ var l = xe({
707
706
  minWidth: n,
708
707
  maxWidth: t,
709
708
  margin: r
710
- }, a);
711
- var s = {
712
- showBorder: i,
713
- selected: o,
709
+ }, i);
710
+ var c = {
711
+ showBorder: o,
714
712
  "data-test": "card",
715
- style: c
713
+ style: l
716
714
  };
717
- return [ s, l ];
715
+ return [ c, a ];
718
716
  }
719
717
  var Ee = function(e) {
720
718
  be(t, e);
@@ -730,7 +728,7 @@
730
728
  var t, n;
731
729
  var o = e.props, i = o.selected, a = o.value;
732
730
  (t = (n = e.props).onClick) === null || t === void 0 ? void 0 : t.call(n, r, {
733
- selected: i,
731
+ selected: i || false,
734
732
  value: a
735
733
  });
736
734
  }));
@@ -741,29 +739,29 @@
741
739
  value: function e() {
742
740
  if (_e(this.props)) {
743
741
  var r = Te(this.props), t = ie(r, 2), o = t[0], i = t[1];
744
- var a = o.selected, l = o.showBorder;
745
- var c = i.children, s = i.elementRef, u = i.onClick, p = i.openInNewContext, d = i.to, f = ke(i, [ "children", "elementRef", "onClick", "openInNewContext", "to" ]);
742
+ var a = o.showBorder;
743
+ var l = i.children, c = i.elementRef, s = i.onClick, u = i.openInNewContext, p = i.selected, d = i.to, f = ke(i, [ "children", "elementRef", "onClick", "openInNewContext", "selected", "to" ]);
746
744
 
747
745
  return n().createElement(re, oe({
748
746
  "data-clickable": true,
749
- $selected: a,
750
- $cardHasBorder: l,
751
- elementRef: s
747
+ $selected: p || false,
748
+ $cardHasBorder: a,
749
+ elementRef: c
752
750
  }, o, f, {
753
- onClick: u ? this.handleCardClick : undefined,
754
- openInNewContext: p,
751
+ onClick: s ? this.handleCardClick : undefined,
752
+ openInNewContext: u,
755
753
  to: d || undefined
756
- }), n().createElement(te, null, c));
754
+ }), n().createElement(te, null, l));
757
755
  }
758
756
  var b = Te(this.props), v = ie(b, 2), y = v[0], m = v[1];
759
- var h = y.selected, g = y.showBorder;
760
- var w = m.children, O = m.elementRef, x = ke(m, [ "children", "elementRef" ]);
757
+ var h = y.showBorder;
758
+ var g = m.children, w = m.elementRef, O = ke(m, [ "children", "elementRef" ]);
761
759
 
762
760
  return n().createElement(ee, oe({
763
- $selected: h,
764
- $cardHasBorder: g,
765
- ref: O
766
- }, y, x), w);
761
+ $selected: false,
762
+ $cardHasBorder: h,
763
+ ref: w
764
+ }, y, O), g);
767
765
  }
768
766
  } ]);
769
767
  return t;
package/Clickable.js CHANGED
@@ -65,7 +65,7 @@
65
65
  NavigationProvider: () => /* reexport */ m,
66
66
  default: () => /* reexport */ F,
67
67
  isInternalLink: () => /* reexport */ z,
68
- isRootRelativeLink: () => /* reexport */ L
68
+ isRootRelativeLink: () => /* reexport */ D
69
69
  });
70
70
  // CONCATENATED MODULE: external "react"
71
71
  const n = require("react");
@@ -98,6 +98,7 @@
98
98
  var y = {
99
99
  children: i().node,
100
100
  onClick: i().func,
101
+ onLinkClick: i().func,
101
102
  prefix: i().string,
102
103
  transformUrl: i().func
103
104
  };
@@ -106,29 +107,30 @@
106
107
  * Used to provide an override for the `onClick` for links for single page applications so that
107
108
  * internal links can navigate without a page reload.
108
109
  */ function m(e) {
109
- var t = e.children, o = e.onClick, i = e.prefix, l = e.transformUrl;
110
+ var t = e.children, o = e.onClick, i = e.onLinkClick, l = e.prefix, a = e.transformUrl;
110
111
  // @docs-props-type NavigationProviderProps
111
- var a = (0, n.useMemo)((function() {
112
+ var u = (0, n.useMemo)((function() {
112
113
  var e;
113
- if (l != null) {
114
+ if (a != null) {
114
115
  if (false) {}
115
- e = l;
116
- } else if (i != null) {
116
+ e = a;
117
+ } else if (l != null) {
117
118
  if (false) {}
118
119
  e = function e() {
119
120
  var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
120
121
  var n = arguments.length > 1 ? arguments[1] : undefined, r = n.isInternal, o = n.isRootRelative;
121
- return i != null && r && o ? "".concat(i).concat(t) : t;
122
+ return l != null && r && o ? "".concat(l).concat(t) : t;
122
123
  };
123
124
  }
124
125
  return {
125
126
  onClick: o,
127
+ onLinkClick: i,
126
128
  transformUrl: e
127
129
  };
128
- }), [ o, i, l ]);
130
+ }), [ o, i, l, a ]);
129
131
 
130
132
  return r().createElement(h.Provider, {
131
- value: a
133
+ value: u
132
134
  }, t);
133
135
  }
134
136
  m.propTypes = y;
@@ -139,7 +141,7 @@
139
141
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
140
142
  * @param current - The new value of the ref.
141
143
  */
142
- function g(e, t) {
144
+ function k(e, t) {
143
145
  if (e) {
144
146
  if (typeof e === "function") {
145
147
  e(t);
@@ -152,21 +154,21 @@
152
154
  }
153
155
  }
154
156
  // CONCATENATED MODULE: ./src/Clickable/Clickable.tsx
155
- function k(e) {
157
+ function g(e) {
156
158
  "@babel/helpers - typeof";
157
159
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
158
- k = function e(t) {
160
+ g = function e(t) {
159
161
  return typeof t;
160
162
  };
161
163
  } else {
162
- k = function e(t) {
164
+ g = function e(t) {
163
165
  return t && typeof Symbol === "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
164
166
  };
165
167
  }
166
- return k(e);
168
+ return g(e);
167
169
  }
168
- function O() {
169
- O = Object.assign || function(e) {
170
+ function C() {
171
+ C = Object.assign || function(e) {
170
172
  for (var t = 1; t < arguments.length; t++) {
171
173
  var n = arguments[t];
172
174
  for (var r in n) {
@@ -177,9 +179,9 @@
177
179
  }
178
180
  return e;
179
181
  };
180
- return O.apply(this, arguments);
182
+ return C.apply(this, arguments);
181
183
  }
182
- function C(e, t) {
184
+ function O(e, t) {
183
185
  if (e == null) return {};
184
186
  var n = w(e, t);
185
187
  var r, o;
@@ -246,31 +248,31 @@
246
248
  return S(e, t);
247
249
  }
248
250
  function _(e) {
249
- var t = N();
251
+ var t = L();
250
252
  return function n() {
251
- var r = M(e), o;
253
+ var r = N(e), o;
252
254
  if (t) {
253
- var i = M(this).constructor;
255
+ var i = N(this).constructor;
254
256
  o = Reflect.construct(r, arguments, i);
255
257
  } else {
256
258
  o = r.apply(this, arguments);
257
259
  }
258
- return I(this, o);
260
+ return T(this, o);
259
261
  };
260
262
  }
261
- function I(e, t) {
262
- if (t && (k(t) === "object" || typeof t === "function")) {
263
+ function T(e, t) {
264
+ if (t && (g(t) === "object" || typeof t === "function")) {
263
265
  return t;
264
266
  }
265
- return T(e);
267
+ return I(e);
266
268
  }
267
- function T(e) {
269
+ function I(e) {
268
270
  if (e === void 0) {
269
271
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
270
272
  }
271
273
  return e;
272
274
  }
273
- function N() {
275
+ function L() {
274
276
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
275
277
  if (Reflect.construct.sham) return false;
276
278
  if (typeof Proxy === "function") return true;
@@ -281,13 +283,13 @@
281
283
  return false;
282
284
  }
283
285
  }
284
- function M(e) {
285
- M = Object.setPrototypeOf ? Object.getPrototypeOf : function e(t) {
286
+ function N(e) {
287
+ N = Object.setPrototypeOf ? Object.getPrototypeOf : function e(t) {
286
288
  return t.__proto__ || Object.getPrototypeOf(t);
287
289
  };
288
- return M(e);
290
+ return N(e);
289
291
  }
290
- function q(e, t, n) {
292
+ function M(e, t, n) {
291
293
  if (t in e) {
292
294
  Object.defineProperty(e, t, {
293
295
  value: n,
@@ -300,20 +302,20 @@
300
302
  }
301
303
  return e;
302
304
  }
303
- var E = /^[a-z0-9]+:/;
304
- var U = /^\/\//;
305
- var D = /^\//;
306
- var L = function e(t) {
307
- return t != null && D.test(t);
305
+ var q = /^[a-z0-9]+:/;
306
+ var E = /^\/\//;
307
+ var U = /^\//;
308
+ var D = function e(t) {
309
+ return t != null && U.test(t);
308
310
  };
309
311
  var z = function e(t) {
310
- return t != null && !E.test(t) && !U.test(t);
312
+ return t != null && !q.test(t) && !E.test(t);
311
313
  };
312
314
  var H = {
313
315
  /** @private */
314
316
  allowDisabledLink: i().bool,
315
317
  children: i().node,
316
- disabled: i().bool,
318
+ disabled: i().oneOfType([ i().bool, i().oneOf([ "dimmed" ]) ]),
317
319
  elementRef: i().oneOfType([ i().func, i().object ]),
318
320
  onClick: i().func,
319
321
  openInNewContext: i().bool,
@@ -339,13 +341,14 @@
339
341
  var r;
340
342
  x(this, n);
341
343
  r = t.call(this, e);
342
- q(T(r), "el", null);
343
- q(T(r), "handleMount", (function(e) {
344
+ M(I(r), "el", null);
345
+ M(I(r), "handleMount", (function(e) {
344
346
  r.el = e;
345
- g(r.props.elementRef, e);
347
+ k(r.props.elementRef, e);
346
348
  }));
347
- q(T(r), "createHandleOnClick", (function(e) {
348
- return function(t) {
349
+ M(I(r), "createHandleOnClick", (function() {
350
+ var e = r.context, t = e.onClick, n = e.onLinkClick;
351
+ return function(e) {
349
352
  if (A(r.props)) {
350
353
  // when user command-click on mac or ctrl-click on other platforms, and
351
354
  // Tag is an <a>, let the click pass through, let the <a> to achieve user's
@@ -353,31 +356,37 @@
353
356
  // on mac, ctrl-click will be caught and open option menu even before hitting
354
357
  // the DOM, so we're safe to check both metaKey and ctrlKey here
355
358
  // without platform sniffing
356
- if ((t.metaKey || t.ctrlKey) && r.props.to) {
359
+ if ((e.metaKey || e.ctrlKey) && r.props.to) {
357
360
  return;
358
361
  }
359
362
  }
360
363
  if (r.props.onClick) {
361
- r.props.onClick(t);
362
- } else if (A(r.props) && e) {
363
- var n = r.props.navigationLabel;
364
- if (!n && u()(r.props.children)) {
365
- n = r.props.children;
364
+ r.props.onClick(e);
365
+ }
366
+ var o = r.props.onClick == null && t != null;
367
+ if (A(r.props) && (o || n != null)) {
368
+ var i = r.props.navigationLabel;
369
+ if (!i && u()(r.props.children)) {
370
+ i = r.props.children;
366
371
  }
367
- e(t, {
372
+ var l = {
368
373
  to: r.getTransformedUrl(r.props.to),
369
374
  originalTo: r.props.to,
370
375
  openInNewContext: r.props.openInNewContext,
371
- label: n
372
- });
376
+ label: i
377
+ };
378
+ if (o) {
379
+ t(e, l);
380
+ }
381
+ n === null || n === void 0 ? void 0 : n(e, l);
373
382
  }
374
383
  };
375
384
  }));
376
- q(T(r), "getTransformedUrl", (function(e) {
385
+ M(I(r), "getTransformedUrl", (function(e) {
377
386
  var t = r.context.transformUrl;
378
387
  return t != null ? t(e, {
379
388
  isInternal: z(e),
380
- isRootRelative: L(e)
389
+ isRootRelative: D(e)
381
390
  }) : e;
382
391
  }));
383
392
  if (false) {}
@@ -395,53 +404,54 @@
395
404
  }, {
396
405
  key: "render",
397
406
  value: function e() {
398
- var t = this.context.onClick;
399
- var n = this.createHandleOnClick(t);
407
+ var t = this.createHandleOnClick();
400
408
  // Only set the href attribute when enabled, and therefore using an <a> tag
401
409
  if (A(this.props)) {
402
- var o = this.props, i = o.children, l = o.openInNewContext, a = o.to, u = C(o, [ "children", "openInNewContext", "to" ]);
403
- var c = l ? "_blank" : undefined;
404
- var s = l && z(a) ? "noopener noreferrer" : undefined;
410
+ var n = this.props, o = n.children, i = n.openInNewContext, l = n.to, a = O(n, [ "children", "openInNewContext", "to" ]);
411
+ var u = i ? "_blank" : undefined;
412
+ var c = i && z(l) ? "noopener noreferrer" : undefined;
405
413
 
406
- return r().createElement(v, O({
414
+ return r().createElement(v, C({
407
415
  "data-test": "clickable",
408
416
  ref: this.handleMount,
409
417
  href: this.getTransformedUrl(this.props.to),
410
- target: c,
411
- rel: s,
412
- onClick: n
413
- }, f()(u, "disabled", "elementRef", "onClick")), i);
418
+ target: u,
419
+ rel: c,
420
+ onClick: t
421
+ }, f()(a, "disabled", "elementRef", "onClick")), o);
414
422
  }
415
423
  if (this.props.allowDisabledLink) {
416
- var p = this.props, d = p.children, b = C(p, [ "children" ]);
424
+ var s = this.props, p = s.children, d = O(s, [ "children" ]);
417
425
  if (this.props.disabled && this.props.to != null) {
418
426
 
419
- return r().createElement(v, O({
427
+ return r().createElement(v, C({
420
428
  "data-test": "clickable",
421
429
  ref: this.handleMount,
422
430
  role: "link",
423
431
  "aria-disabled": "true"
424
- }, f()(b, "href", "to", "elementRef", "onClick", "disabled")), d);
432
+ }, f()(d, "href", "to", "elementRef", "onClick", "disabled")), p);
425
433
  }
426
434
  }
427
435
  // button variant
428
- var y = this.props, h = y.children, m = y.type, g = C(y, [ "children", "type" ]);
436
+ var b = this.props, y = b.children, h = b.onClick, m = b.disabled, k = b.type, g = O(b, [ "children", "onClick", "disabled", "type" ]);
429
437
 
430
- return r().createElement(v, O({
438
+ return r().createElement(v, C({
431
439
  as: "button",
440
+ "aria-disabled": m === "dimmed" || undefined,
432
441
  "data-test": "clickable",
433
442
  ref: this.handleMount,
434
- type: m || "button",
435
- onClick: n
436
- }, f()(g, "elementRef", "onClick", "openInNewContext", "to")), h);
443
+ type: k || "button",
444
+ disabled: m === true,
445
+ onClick: h && !m ? t : undefined
446
+ }, f()(g, "elementRef", "openInNewContext", "to")), y);
437
447
  }
438
448
  } ]);
439
449
  return n;
440
450
  }(n.Component);
441
- q(B, "contextType", h);
442
- q(B, "propTypes", H);
443
- q(B, "defaultProps", K);
444
- q(B, s.legacyRefMode, true);
451
+ M(B, "contextType", h);
452
+ M(B, "propTypes", H);
453
+ M(B, "defaultProps", K);
454
+ M(B, s.legacyRefMode, true);
445
455
  /* harmony default export */ const F = B;
446
456
  // CONCATENATED MODULE: ./src/Clickable/index.ts
447
457
  module.exports = t;