@splunk/react-ui 5.4.0 → 5.5.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 (76) hide show
  1. package/Badge.js +154 -0
  2. package/CHANGELOG.md +27 -0
  3. package/Code.js +1097 -500
  4. package/Color.js +142 -141
  5. package/ComboBox.js +6 -5
  6. package/Link.js +74 -44
  7. package/MIGRATION.md +32 -1
  8. package/Menu.js +41 -43
  9. package/Multiselect.js +596 -2143
  10. package/Number.js +3 -3
  11. package/PhoneNumber.d.ts +2 -0
  12. package/PhoneNumber.js +769 -0
  13. package/Popover.js +73 -75
  14. package/RadioList.js +166 -151
  15. package/ResultsMenu.js +27 -29
  16. package/Select.js +179 -1768
  17. package/SelectBase.d.ts +2 -0
  18. package/SelectBase.js +1681 -0
  19. package/Slider.js +202 -199
  20. package/SlidingPanels.js +55 -62
  21. package/Switch.js +42 -27
  22. package/TabBar.js +295 -294
  23. package/TabLayout.js +14 -14
  24. package/Table.js +1087 -1040
  25. package/TransitionOpen.js +82 -74
  26. package/docker-compose.yml +99 -52
  27. package/package.json +9 -5
  28. package/stubs-splunkui.d.ts +0 -86
  29. package/test-runner-jest.config.js +1 -0
  30. package/types/src/Badge/Badge.d.ts +29 -0
  31. package/types/src/Badge/docs/examples/Basic.d.ts +5 -0
  32. package/types/src/Badge/docs/examples/Count.d.ts +6 -0
  33. package/types/src/Badge/docs/examples/CustomColors.d.ts +8 -0
  34. package/types/src/Badge/docs/examples/Icon.d.ts +6 -0
  35. package/types/src/Badge/index.d.ts +2 -0
  36. package/types/src/Code/Code.d.ts +4 -3
  37. package/types/src/Code/index.d.ts +1 -0
  38. package/types/src/Link/Link.d.ts +4 -0
  39. package/types/src/Link/LinkContext.d.ts +14 -0
  40. package/types/src/Link/docs/examples/Visited.d.ts +7 -0
  41. package/types/src/Link/index.d.ts +1 -0
  42. package/types/src/Multiselect/Compact.d.ts +1 -1
  43. package/types/src/Multiselect/Multiselect.d.ts +1 -1
  44. package/types/src/PhoneNumber/PhoneNumber.d.ts +139 -0
  45. package/types/src/PhoneNumber/docs/examples/Controlled.d.ts +7 -0
  46. package/types/src/PhoneNumber/docs/examples/DefaultCountry.d.ts +7 -0
  47. package/types/src/PhoneNumber/docs/examples/Disabled.d.ts +6 -0
  48. package/types/src/PhoneNumber/docs/examples/Error.d.ts +6 -0
  49. package/types/src/PhoneNumber/docs/examples/Inline.d.ts +7 -0
  50. package/types/src/PhoneNumber/docs/examples/Uncontrolled.d.ts +7 -0
  51. package/types/src/PhoneNumber/index.d.ts +2 -0
  52. package/types/src/PhoneNumber/utils.d.ts +47 -0
  53. package/types/src/RadioList/Option.d.ts +6 -1
  54. package/types/src/RadioList/docs/examples/Description.d.ts +6 -0
  55. package/types/src/Select/Option.d.ts +8 -3
  56. package/types/src/Select/Select.d.ts +1 -1
  57. package/types/src/{Select → SelectBase}/OptionBase.d.ts +8 -2
  58. package/types/src/{Select → SelectBase}/SelectBase.d.ts +3 -1
  59. package/types/src/SelectBase/index.d.ts +2 -0
  60. package/types/src/Switch/Switch.d.ts +3 -0
  61. package/types/src/Table/Body.d.ts +6 -1
  62. package/types/src/Table/Cell.d.ts +5 -1
  63. package/types/src/Table/Head.d.ts +6 -2
  64. package/types/src/Table/HeadCell.d.ts +5 -1
  65. package/types/src/Table/Row.d.ts +5 -1
  66. package/types/src/Table/Table.d.ts +20 -1
  67. package/types/src/Table/TableContext.d.ts +1 -0
  68. package/types/src/Table/docs/examples/HorizontalOverflowScroll.d.ts +8 -0
  69. package/types/src/Table/docs/examples/PinActionColumn.d.ts +7 -0
  70. package/types/src/TransitionOpen/TransitionOpen.d.ts +3 -1
  71. package/types/src/useResizeObserver/useResizeObserver.d.ts +2 -0
  72. package/types/src/useRovingFocus/useRovingFocus.d.ts +8 -1
  73. package/usePrevious.d.ts +2 -0
  74. package/useResizeObserver.js +59 -92
  75. package/useRovingFocus.js +96 -41
  76. /package/types/src/{Select → SelectBase}/SelectAllOption.d.ts +0 -0
package/TransitionOpen.js CHANGED
@@ -72,8 +72,8 @@
72
72
  // CONCATENATED MODULE: external "@splunk/react-ui/Animation"
73
73
  const a = require("@splunk/react-ui/Animation");
74
74
  // CONCATENATED MODULE: external "@splunk/react-ui/usePrevious"
75
- const u = require("@splunk/react-ui/usePrevious");
76
- var l = e.n(u);
75
+ const l = require("@splunk/react-ui/usePrevious");
76
+ var u = e.n(l);
77
77
  // CONCATENATED MODULE: external "@splunk/ui-utils/focus"
78
78
  const s = require("@splunk/ui-utils/focus");
79
79
  // CONCATENATED MODULE: external "@splunk/ui-utils/style"
@@ -137,7 +137,7 @@
137
137
  }, g.apply(null, arguments);
138
138
  }
139
139
  function O(e, t) {
140
- return k(e) || P(e, t) || j(e, t) || S();
140
+ return P(e) || F(e, t) || j(e, t) || S();
141
141
  }
142
142
  function S() {
143
143
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
@@ -156,34 +156,34 @@
156
156
  }
157
157
  return n;
158
158
  }
159
- function P(e, t) {
159
+ function F(e, t) {
160
160
  var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
161
161
  if (null != r) {
162
- var n, o, i, a, u = [], l = !0, s = !1;
162
+ var n, o, i, a, l = [], u = !0, s = !1;
163
163
  try {
164
164
  if (i = (r = r.call(e)).next, 0 === t) {
165
165
  if (Object(r) !== r) return;
166
- l = !1;
167
- } else for (;!(l = (n = i.call(r)).done) && (u.push(n.value), u.length !== t); l = !0) {
166
+ u = !1;
167
+ } else for (;!(u = (n = i.call(r)).done) && (l.push(n.value), l.length !== t); u = !0) {
168
168
  }
169
169
  } catch (e) {
170
170
  s = !0, o = e;
171
171
  } finally {
172
172
  try {
173
- if (!l && null != r["return"] && (a = r["return"](), Object(a) !== a)) return;
173
+ if (!u && null != r["return"] && (a = r["return"](), Object(a) !== a)) return;
174
174
  } finally {
175
175
  if (s) throw o;
176
176
  }
177
177
  }
178
- return u;
178
+ return l;
179
179
  }
180
180
  }
181
- function k(e) {
181
+ function P(e) {
182
182
  if (Array.isArray(e)) return e;
183
183
  }
184
- function x(e, t) {
184
+ function k(e, t) {
185
185
  if (null == e) return {};
186
- var r, n, o = F(e, t);
186
+ var r, n, o = x(e, t);
187
187
  if (Object.getOwnPropertySymbols) {
188
188
  var i = Object.getOwnPropertySymbols(e);
189
189
  for (n = 0; n < i.length; n++) {
@@ -192,7 +192,7 @@
192
192
  }
193
193
  return o;
194
194
  }
195
- function F(e, t) {
195
+ function x(e, t) {
196
196
  if (null == e) return {};
197
197
  var r = {};
198
198
  for (var n in e) {
@@ -217,26 +217,26 @@
217
217
  for (var t = 1; t < arguments.length; t++) {
218
218
  var r = null != arguments[t] ? arguments[t] : {};
219
219
  t % 2 ? C(Object(r), !0).forEach((function(t) {
220
- T(e, t, r[t]);
220
+ A(e, t, r[t]);
221
221
  })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : C(Object(r)).forEach((function(t) {
222
222
  Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
223
223
  }));
224
224
  }
225
225
  return e;
226
226
  }
227
- function T(e, t, r) {
228
- return (t = E(t)) in e ? Object.defineProperty(e, t, {
227
+ function A(e, t, r) {
228
+ return (t = T(t)) in e ? Object.defineProperty(e, t, {
229
229
  value: r,
230
230
  enumerable: !0,
231
231
  configurable: !0,
232
232
  writable: !0
233
233
  }) : e[t] = r, e;
234
234
  }
235
- function E(e) {
236
- var t = A(e, "string");
235
+ function T(e) {
236
+ var t = E(e, "string");
237
237
  return "symbol" == h(t) ? t : t + "";
238
238
  }
239
- function A(e, t) {
239
+ function E(e, t) {
240
240
  if ("object" != h(e) || !e) return e;
241
241
  var r = e[Symbol.toPrimitive];
242
242
  if (void 0 !== r) {
@@ -256,6 +256,7 @@
256
256
  innerClassName: i().string,
257
257
  innerStyle: i().object,
258
258
  onAnimationEnd: i().func,
259
+ onAnimationStart: i().func,
259
260
  open: i().bool,
260
261
  outerClassName: i().string,
261
262
  outerId: i().string,
@@ -293,7 +294,7 @@
293
294
  var a = {
294
295
  value: n ? 0 : o
295
296
  };
296
- var u = {
297
+ var l = {
297
298
  precision: 1
298
299
  };
299
300
  // Only use precision when not using transform, otherwise transform animation will break
@@ -301,7 +302,7 @@
301
302
  if (r === "expandWidth" || r === "expandHeight" || r === "none") {
302
303
  return {
303
304
  to: i,
304
- config: u
305
+ config: l
305
306
  };
306
307
  }
307
308
  // Slide transitions require a valid value, render without transition first.
@@ -313,14 +314,14 @@
313
314
  return {
314
315
  to: i,
315
316
  from: a,
316
- config: u
317
+ config: l
317
318
  };
318
319
  }
319
320
  // The top and left directions require an additional transform of their inner content to match the outer dimension animation.
320
321
  // This is needed to achieve a clipping effect from the outer div, rather than the consumer providing their own.
321
- var l = r === "slideFromTop" ? "Y" : "X";
322
- var s = "translate".concat(l, "(").concat(n ? 0 : -o, "px)");
323
- var c = "translate".concat(l, "(").concat(n ? -o : 0, "px)");
322
+ var u = r === "slideFromTop" ? "Y" : "X";
323
+ var s = "translate".concat(u, "(").concat(n ? 0 : -o, "px)");
324
+ var c = "translate".concat(u, "(").concat(n ? -o : 0, "px)");
324
325
  return {
325
326
  to: N({
326
327
  transform: s
@@ -330,7 +331,7 @@
330
331
  }, a)
331
332
  };
332
333
  };
333
- var _ = function e(t) {
334
+ var R = function e(t) {
334
335
  var r = t.animation, n = t.el, o = t.takeFocusProp;
335
336
  var i = 0;
336
337
  if (n) {
@@ -353,90 +354,97 @@
353
354
  }
354
355
  return i;
355
356
  };
356
- var R = {};
357
+ var _ = {};
357
358
  var W = {};
358
359
  function D(e) {
359
- var t = e.animation, o = t === void 0 ? "expandHeight" : t, i = e.animateOnMount, u = e.children, f = e.className, d = e.elementRef, m = e.id, p = e.innerClassName, h = e.innerStyle, S = h === void 0 ? R : h, j = e.onAnimationEnd, w = e.open, P = e.outerClassName, k = e.outerId, F = e.outerStyle, C = F === void 0 ? W : F, E = e.renderChildrenWhenCollapsed, A = e.retainFocus, I = e.takeFocus, D = x(e, [ "animation", "animateOnMount", "children", "className", "elementRef", "id", "innerClassName", "innerStyle", "onAnimationEnd", "open", "outerClassName", "outerId", "outerStyle", "renderChildrenWhenCollapsed", "retainFocus", "takeFocus" ]);
360
+ var t = e.animation, o = t === void 0 ? "expandHeight" : t, i = e.animateOnMount, l = e.children, f = e.className, d = e.elementRef, m = e.id, p = e.innerClassName, h = e.innerStyle, S = h === void 0 ? _ : h, j = e.onAnimationEnd, w = e.onAnimationStart, F = e.open, P = e.outerClassName, x = e.outerId, C = e.outerStyle, T = C === void 0 ? W : C, E = e.renderChildrenWhenCollapsed, I = e.retainFocus, D = e.takeFocus, H = k(e, [ "animation", "animateOnMount", "children", "className", "elementRef", "id", "innerClassName", "innerStyle", "onAnimationEnd", "onAnimationStart", "open", "outerClassName", "outerId", "outerStyle", "renderChildrenWhenCollapsed", "retainFocus", "takeFocus" ]);
360
361
  // @docs-props-type TransitionOpenPropsBase
361
- var H = l()(w);
362
- var L = (0, r.useRef)(true);
363
- var $ = (0, r.useState)(i ? w : false), B = O($, 2), K = B[0], U = B[1];
364
- var X = (0, r.useState)(null), Y = O(X, 2), z = Y[0], G = Y[1];
365
- var J = (0, r.useState)(0), Q = O(J, 2), V = Q[0], Z = Q[1];
362
+ var L = u()(F);
363
+ var B = (0, r.useRef)(true);
364
+ var $ = (0, r.useState)(i ? F : false), K = O($, 2), U = K[0], X = K[1];
365
+ var Y = (0, r.useState)(null), z = O(Y, 2), G = z[0], J = z[1];
366
+ var Q = (0, r.useState)(0), V = O(Q, 2), Z = V[0], ee = V[1];
366
367
  (0, r.useEffect)((function() {
367
368
  // prevOpen starts undefined, and we don't want to make the comparison in that situation
368
- if (H !== undefined && w !== H) {
369
- U(true);
369
+ if (L !== undefined && F !== L) {
370
+ X(true);
370
371
  }
371
- }), [ w, H ]);
372
+ }), [ F, L ]);
372
373
  // equivalent to componentDidMount and componentWillUnmount
373
374
  (0, r.useEffect)((function() {
374
375
  // we need to set this to true on every mount because React.StrictMode will call the effect twice
375
376
  // and we need to ensure that allowAnimationUpdates is true while the component is mounted
376
- L.current = true;
377
+ B.current = true;
377
378
  return function() {
378
- L.current = false;
379
+ B.current = false;
379
380
  };
380
381
  }), []);
381
- var ee = (0, r.useCallback)((function(e) {
382
- G(e);
383
- Z(_({
382
+ var te = (0, r.useCallback)((function(e) {
383
+ J(e);
384
+ ee(R({
384
385
  animation: o,
385
386
  el: e,
386
- takeFocusProp: I
387
+ takeFocusProp: D
387
388
  }));
388
389
  b(d, e);
389
- }), [ o, I, d ]);
390
- var te = (0, r.useCallback)((function() {
391
- if (L.current) {
392
- U(false);
390
+ }), [ o, D, d ]);
391
+ var re = (0, r.useCallback)((function() {
392
+ w === null || w === void 0 ? void 0 : w();
393
+ }), [ w ]);
394
+ var ne = (0, r.useCallback)((function() {
395
+ if (B.current) {
396
+ X(false);
393
397
  }
394
398
  j === null || j === void 0 ? void 0 : j();
395
399
  }), [ j ]);
396
- var re = (0, r.useCallback)((function(e) {
397
- if (z) {
398
- (0, s.handleTab)(z, e);
400
+ var oe = (0, r.useCallback)((function(e) {
401
+ if (G) {
402
+ (0, s.handleTab)(G, e);
399
403
  }
400
- }), [ z ]);
401
- var ne = (0, a.useAnimation)(N(N({}, M({
404
+ }), [ G ]);
405
+ var ie = (0, a.useAnimation)(N(N({}, M({
402
406
  animation: o,
403
- open: w,
404
- value: V
407
+ open: F,
408
+ value: Z
405
409
  })), {}, {
406
410
  immediate: o === "none",
407
- onRest: te
408
- })), oe = ne.value, ie = ne.transform;
409
- var ae;
410
- if (K || E) {
411
- ae = q(o);
411
+ onRest: ne,
412
+ onStart: re
413
+ })), ae = ie.value, le = ie.transform;
414
+ var ue;
415
+ var se = [ "slideFromTop", "slideFromRight", "slideFromBottom", "slideFromLeft" ].includes(o);
416
+ /* to avoid setting and unsetting dimension which causes flickering
417
+ we always set the dimension if it is a slide animation
418
+ else only set it when animating || renderChildrenWhenCollapsed */ if (se || U || E) {
419
+ ue = q(o);
412
420
  }
413
421
  // if renderChildrenWhenCollapsed is true, we hide the content by setting the height of the wrapper to 0
414
- var ue = E && !w && !K ? 0 : oe;
415
- var le = (0, r.useMemo)((function() {
416
- return N(N({}, C), ae && T({}, ae, ue));
417
- }), [ ae, ue, C ]);
418
- var se = (0, r.useMemo)((function() {
422
+ var ce = E && !F && !U ? 0 : ae;
423
+ var fe = (0, r.useMemo)((function() {
424
+ return N(N({}, T), ue && A({}, ue, ce));
425
+ }), [ ue, ce, T ]);
426
+ var de = (0, r.useMemo)((function() {
419
427
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
420
428
  return N(N({}, S), {}, {
421
- transform: ie
429
+ transform: le
422
430
  });
423
- }), [ S, ie ]);
431
+ }), [ S, le ]);
424
432
 
425
433
  return n().createElement(v, {
426
- $hideOverflow: !w || K || false,
434
+ $hideOverflow: !F || U || false,
427
435
  className: (0, c.toClassName)(f, P),
428
- style: le,
429
- id: k
430
- }, (w || K || E) && n().createElement(y, g({
436
+ style: fe,
437
+ id: x
438
+ }, (F || U || E) && n().createElement(y, g({
431
439
  "data-test": "transition-open"
432
- }, D, {
433
- ref: ee,
440
+ }, H, {
441
+ ref: te,
434
442
  tabIndex: -1,
435
443
  className: p,
436
444
  id: m,
437
- onKeyDown: A ? re : undefined,
438
- style: se
439
- }), u));
445
+ onKeyDown: I ? oe : undefined,
446
+ style: de
447
+ }), l));
440
448
  }
441
449
  D.propTypes = I;
442
450
  /* harmony default export */ const H = D;
@@ -1,53 +1,100 @@
1
1
  services:
2
- prisma-storybook:
3
- build:
4
- context: .
5
- dockerfile: ../../infra/visual-tests/Dockerfile.storybook
6
- args:
7
- port: 6007
8
- storybookfolder: storybook-static-visual-prisma
9
- workdir: /react-ui
10
- command: npx http-server storybook-static-visual-prisma --port 6007
11
- ports:
12
- - "6007:6007"
13
- enterprise-storybook:
14
- build:
15
- context: .
16
- dockerfile: ../../infra/visual-tests/Dockerfile.storybook
17
- args:
18
- port: 6008
19
- storybookfolder: storybook-static-visual-enterprise
20
- workdir: /react-ui
21
- command: npx http-server storybook-static-visual-enterprise --port 6008
22
- ports:
23
- - "6008:6008"
24
- prisma-visual-test:
25
- build:
26
- context: .
27
- dockerfile: ../../infra/visual-tests/Dockerfile.visual
28
- args:
29
- workdir: /react-ui
30
- env_file:
31
- - ./.storybook-visual/config/.env.visual
32
- working_dir: /react-ui
33
- volumes:
34
- - "./src:/react-ui/src"
35
- - "./test-reports:/react-ui/test-reports"
36
- depends_on:
37
- - prisma-storybook
38
- command: /bin/sh -c "npx wait-on http://prisma-storybook:6007 && yarn cache clean && yarn test-storybook -c .storybook-visual --browsers $${STORYBOOK_BROWSER} $${STORYBOOK_UPDATE_SNAPSHOT} $${STORYBOOK_MAX_WORKERS} --url http://prisma-storybook:6007 --no-index-json"
39
- enterprise-visual-test:
40
- build:
41
- context: .
42
- dockerfile: ../../infra/visual-tests/Dockerfile.visual
43
- args:
44
- workdir: /react-ui
45
- env_file:
46
- - ./.storybook-visual/config/.env.visual
47
- working_dir: /react-ui
48
- volumes:
49
- - "./src:/react-ui/src"
50
- - "./test-reports:/react-ui/test-reports"
51
- depends_on:
52
- - enterprise-storybook
53
- command: /bin/sh -c "npx wait-on http://enterprise-storybook:6008 && yarn cache clean && yarn test-storybook -c .storybook-visual --browsers $${STORYBOOK_BROWSER} $${STORYBOOK_UPDATE_SNAPSHOT} $${STORYBOOK_MAX_WORKERS} --url http://enterprise-storybook:6008 --no-index-json"
2
+ prisma-storybook:
3
+ build:
4
+ context: .
5
+ dockerfile: ../../infra/visual-tests/Dockerfile.storybook
6
+ args:
7
+ port: 6007
8
+ storybookfolder: storybook-static-visual-prisma
9
+ workdir: /react-ui
10
+ command: npx http-server storybook-static-visual-prisma --port 6007
11
+ ports:
12
+ - '6007:6007'
13
+ enterprise-storybook:
14
+ build:
15
+ context: .
16
+ dockerfile: ../../infra/visual-tests/Dockerfile.storybook
17
+ args:
18
+ port: 6008
19
+ storybookfolder: storybook-static-visual-enterprise
20
+ workdir: /react-ui
21
+ command: npx http-server storybook-static-visual-enterprise --port 6008
22
+ ports:
23
+ - '6008:6008'
24
+ splunk-magnetic-storybook:
25
+ build:
26
+ context: .
27
+ dockerfile: ../../infra/visual-tests/Dockerfile.storybook
28
+ args:
29
+ port: 6009
30
+ storybookfolder: storybook-static-visual-splunk-magnetic
31
+ workdir: /react-ui
32
+ command: npx http-server storybook-static-visual-splunk-magnetic --port 6009
33
+ ports:
34
+ - '6009:6009'
35
+ prisma-visual-test:
36
+ build:
37
+ context: .
38
+ dockerfile: ../../infra/visual-tests/Dockerfile.visual
39
+ args:
40
+ workdir: /react-ui
41
+ env_file:
42
+ - ./.storybook-visual/config/.env.visual
43
+ environment:
44
+ - JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1
45
+ - JOB_BROWSER=${JOB_BROWSER}
46
+ working_dir: /react-ui
47
+ volumes:
48
+ - './src:/react-ui/src'
49
+ - './test-reports:/react-ui/test-reports'
50
+ # TODO(SUI-8236): can remove once webpack.test.config.js imports of infra/.config.js are removed as this won't be needed any longer (verify with no cache docker build something else didn't start using it though)
51
+ - '../../infra/.config.js:/infra/.config.js:ro'
52
+ - '../../infra/storybook/utils.js:/infra/storybook/utils.js:ro'
53
+ - '../../infra/visual-tests/orphaned-snapshot-check-reporter.js:/infra/visual-tests/orphaned-snapshot-check-reporter.js:ro'
54
+ depends_on:
55
+ - prisma-storybook
56
+ command: /bin/sh -c "npx wait-on http://prisma-storybook:6007 && yarn cache clean && yarn test-storybook -c .storybook-visual --browsers $${STORYBOOK_BROWSER} $${STORYBOOK_UPDATE_SNAPSHOT} $${STORYBOOK_MAX_WORKERS} --url http://prisma-storybook:6007 --no-index-json"
57
+ enterprise-visual-test:
58
+ build:
59
+ context: .
60
+ dockerfile: ../../infra/visual-tests/Dockerfile.visual
61
+ args:
62
+ workdir: /react-ui
63
+ env_file:
64
+ - ./.storybook-visual/config/.env.visual
65
+ environment:
66
+ - JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1
67
+ - JOB_BROWSER=${JOB_BROWSER}
68
+ working_dir: /react-ui
69
+ volumes:
70
+ - './src:/react-ui/src'
71
+ - './test-reports:/react-ui/test-reports'
72
+ # TODO(SUI-8236): can remove once webpack.test.config.js imports of infra/.config.js are removed as this won't be needed any longer (verify with no cache docker build something else didn't start using it though)
73
+ - '../../infra/.config.js:/infra/.config.js:ro'
74
+ - '../../infra/storybook/utils.js:/infra/storybook/utils.js:ro'
75
+ - '../../infra/visual-tests/orphaned-snapshot-check-reporter.js:/infra/visual-tests/orphaned-snapshot-check-reporter.js:ro'
76
+ depends_on:
77
+ - enterprise-storybook
78
+ command: /bin/sh -c "npx wait-on http://enterprise-storybook:6008 && yarn cache clean && yarn test-storybook -c .storybook-visual --browsers $${STORYBOOK_BROWSER} $${STORYBOOK_UPDATE_SNAPSHOT} $${STORYBOOK_MAX_WORKERS} --url http://enterprise-storybook:6008 --no-index-json"
79
+ splunk-magnetic-visual-test:
80
+ build:
81
+ context: .
82
+ dockerfile: ../../infra/visual-tests/Dockerfile.visual
83
+ args:
84
+ workdir: /react-ui
85
+ env_file:
86
+ - ./.storybook-visual/config/.env.visual
87
+ environment:
88
+ - JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1
89
+ - JOB_BROWSER=${JOB_BROWSER}
90
+ working_dir: /react-ui
91
+ volumes:
92
+ - './src:/react-ui/src'
93
+ - './test-reports:/react-ui/test-reports'
94
+ # TODO(SUI-8236): can remove once webpack.test.config.js imports of infra/.config.js are removed as this won't be needed any longer (verify with no cache docker build something else didn't start using it though)
95
+ - '../../infra/.config.js:/infra/.config.js:ro'
96
+ - '../../infra/storybook/utils.js:/infra/storybook/utils.js:ro'
97
+ - '../../infra/visual-tests/orphaned-snapshot-check-reporter.js:/infra/visual-tests/orphaned-snapshot-check-reporter.js:ro'
98
+ depends_on:
99
+ - splunk-magnetic-storybook
100
+ command: /bin/sh -c "npx wait-on http://splunk-magnetic-storybook:6009 && yarn cache clean && yarn test-storybook -c .storybook-visual --browsers $${STORYBOOK_BROWSER} $${STORYBOOK_UPDATE_SNAPSHOT} $${STORYBOOK_MAX_WORKERS} --url http://splunk-magnetic-storybook:6009 --no-index-json"
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@splunk/react-ui",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "description": "Library of React components that implement the Splunk design language",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Splunk Inc.",
7
7
  "scripts": {
8
8
  "build": "cross-env NODE_ENV=production webpack && yarn types:build",
9
9
  "docs": "NODE_ENV=production webpack --config docs.gen.webpack.config.js",
10
+ "docs:llm": "NODE_ENV=production webpack --config docs-llm.gen.webpack.config.js",
10
11
  "docs:publish": "eval $(splunk-docs-package docs) && artifact-ci publish generic $DOCS_GEN_OUTPUT_NAME $DOCS_GEN_REMOTE_PATH",
11
12
  "docs:publish:external": "eval $(splunk-docs-package docs-external --suffix=public) && artifact-ci publish generic $DOCS_GEN_OUTPUT_NAME $DOCS_GEN_REMOTE_PATH",
12
13
  "docs:start": "INTERNAL=true webpack serve --config docs.gen.webpack.config.js",
@@ -44,16 +45,18 @@
44
45
  "@dnd-kit/sortable": "^8.0.0",
45
46
  "@dnd-kit/utilities": "^3.2.2",
46
47
  "@react-spring/web": "^9.7.5",
47
- "@splunk/react-icons": "^5.4.0",
48
- "@splunk/themes": "^1.3.0",
49
- "@splunk/ui-utils": "^1.11.0",
48
+ "@splunk/react-icons": "^5.5.0",
49
+ "@splunk/themes": "^1.4.0",
50
+ "@splunk/ui-utils": "^1.12.0",
50
51
  "decimal.js-light": "^2.5.1",
52
+ "intl-tel-input": "^25.3.2",
51
53
  "lodash": "^4.17.14",
52
54
  "moment": "^2.29.4",
53
55
  "prop-types": "^15.6.2",
54
56
  "react-markdown": "^8.0.7",
55
57
  "remark-gfm": "^1.0.0",
56
58
  "tinycolor2": "^1.4.1",
59
+ "use-sync-external-store": "^1.6.0",
57
60
  "use-typed-event-listener": "^3.0.0"
58
61
  },
59
62
  "devDependencies": {
@@ -65,7 +68,7 @@
65
68
  "@splunk/react-docs": "^1.4.0",
66
69
  "@splunk/stylelint-config": "^5.0.0",
67
70
  "@splunk/test-runner-utils": "^0.4.1",
68
- "@splunk/webpack-configs": "^7.0.2",
71
+ "@splunk/webpack-configs": "^7.0.3",
69
72
  "@storybook/addon-a11y": "^7.6.20",
70
73
  "@storybook/addon-essentials": "^7.6.20",
71
74
  "@storybook/addon-interactions": "^7.6.20",
@@ -87,6 +90,7 @@
87
90
  "@types/react-dom": "^18.2.0",
88
91
  "@types/styled-components": "^5.1.0",
89
92
  "@types/tinycolor2": "^1.4.2",
93
+ "@types/use-sync-external-store": "^1.5.0",
90
94
  "@types/webpack-env": "^1.15.2",
91
95
  "@typescript-eslint/eslint-plugin": "^8.29.1",
92
96
  "@typescript-eslint/parser": "^8.29.1",
@@ -8,92 +8,6 @@ declare module '__FONTS_IMPORT__/*' {
8
8
  export default component;
9
9
  }
10
10
 
11
- declare module '@splunk/ui-utils/color' {
12
- function expandShortHandHex<T extends string | null | undefined>(arg: T): T;
13
- function hexToRgb(hex: string): [number, number, number] | null;
14
- function isCSSColor(value: string): boolean;
15
- function isValidHexColor(value: string): boolean;
16
- function isValidRgb(value: string): boolean;
17
- function namedColorToHex(colorName: string): string | undefined;
18
-
19
- const extendedColorKeywords: string[];
20
- const extendedColorKeywordsToHex: { string: string };
21
- }
22
-
23
- declare module '@splunk/ui-utils/filter' {
24
- function keywordLocations(
25
- phrase: string,
26
- keywords: string[]
27
- ): { keyword: string; start: number; end: number }[];
28
- function stringToKeywords(filterPhrase?: string): string[];
29
- function testPhrase(phrase: string, keywords: string[]): boolean;
30
- }
31
-
32
- declare module '@splunk/ui-utils/format' {
33
- // for now, assume this is guaranteed to return a string (and not undefined, null, ...)
34
- function sprintf(...args: any[]): string;
35
- }
36
-
37
- declare module '@splunk/ui-utils/focus' {
38
- // getSortedTabbableElements returns Elements
39
- // handleTab / takeFocus both call focus() which exists only on HTMLElement/SVGElement (modern browsers), but not Element
40
- function getSortedTabbableElements(
41
- container: Element,
42
- options?: { ignoreTabIndex: boolean }
43
- ): Element[];
44
- function isTabKey(event: KeyboardEvent<Element>): boolean;
45
- function handleTab(container: Element, event: KeyboardEvent): Element | null;
46
- function takeFocus(container: Element, defaultElement?: 'first' | 'container'): Element | null;
47
- function handleFocus(
48
- key: string,
49
- actionItems: Element[],
50
- currentIndex: number,
51
- options?: {
52
- enableLoop?: boolean;
53
- orientation?: 'horizontal' | 'vertical';
54
- enableTab?: boolean;
55
- enableHomeEnd?: boolean;
56
- }
57
- ): void;
58
- }
59
-
60
- declare module '@splunk/ui-utils/i18n' {
61
- // for now, assume this is guaranteed to return a string (and not undefined, null, ...)
62
- function _(...args: any[]): string;
63
- }
64
-
65
- declare module '@splunk/ui-utils/id' {
66
- function createDOMID(prefix?: string): string;
67
- function createGUID(): string;
68
- }
69
-
70
- declare module '@splunk/ui-utils/keyboard' {
71
- function addsCharacter(event: KeyboardEvent): boolean | undefined;
72
- function keycode(event: KeyboardEvent | number | string): string;
73
- function isDecimal(event: KeyboardEvent, options?: { locale: string }): boolean;
74
- function isMinus(event: KeyboardEvent): boolean;
75
- function isNumber(event: KeyboardEvent): boolean;
76
- function isNumeric(event: KeyboardEvent, options?: { locale: string }): boolean;
77
- }
78
-
79
- declare module '@splunk/ui-utils/promise' {
80
- interface CancelablePromise<T> {
81
- cancel: () => void;
82
- promise: Promise<T>;
83
- }
84
-
85
- function makeCancelable<T>(arg: Promise<T>): CancelablePromise<T>;
86
- }
87
-
88
- declare module '@splunk/ui-utils/scroll' {
89
- export function scrollIntoViewIfNeeded(el?: HTMLElement | null): void;
90
- }
91
-
92
- declare module '@splunk/ui-utils/style' {
93
- type ClassNameArg = ClassNameArg | Record<string, unknown> | string | undefined | null;
94
- function toClassName(...args: ClassNameArg[]): string;
95
- }
96
-
97
11
  declare module '@splunk/react-docs/DocExample' {
98
12
  function getDependencyVersions(
99
13
  packageJSON: Record<string, unknown>,
@@ -50,6 +50,7 @@ module.exports = {
50
50
  : 'a11y-report.html',
51
51
  },
52
52
  ],
53
+ '../../infra/visual-tests/orphaned-snapshot-check-reporter.js',
53
54
  ],
54
55
  globals: {
55
56
  __DEV__: true,
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { AnyTheme, Interpolation, OptionalThemedProps } from '@splunk/themes';
4
+ import { ComponentProps } from '../utils/types';
5
+ interface BadgePropsBase {
6
+ /** Changes the background color. Accepts `@splunk/themes` variable or any valid `color` value. */
7
+ backgroundColor?: React.CSSProperties['color'] | Interpolation<AnyTheme, OptionalThemedProps<AnyTheme>>;
8
+ children?: never;
9
+ /** A React ref which is set to the DOM element when the component mounts and null when it unmounts. */
10
+ elementRef?: React.Ref<HTMLSpanElement>;
11
+ /** The content of the badge. */
12
+ label: string;
13
+ /** Icon before the label. */
14
+ icon?: React.ReactNode;
15
+ /** Changes the text and icon color. Accepts `@splunk/themes` variable or any valid `color` value. */
16
+ foregroundColor?: React.CSSProperties['color'] | Interpolation<AnyTheme, OptionalThemedProps<AnyTheme>>;
17
+ }
18
+ type BadgeProps = ComponentProps<BadgePropsBase, 'span'>;
19
+ declare function Badge({ backgroundColor, elementRef, label, icon, foregroundColor, ...otherProps }: BadgeProps): React.JSX.Element;
20
+ declare namespace Badge {
21
+ var propTypes: {
22
+ backgroundColor: PropTypes.Requireable<NonNullable<string | ((...args: any[]) => any) | null | undefined>>;
23
+ elementRef: PropTypes.Requireable<object>;
24
+ label: PropTypes.Validator<string>;
25
+ icon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
26
+ foregroundColor: PropTypes.Requireable<NonNullable<string | ((...args: any[]) => any) | null | undefined>>;
27
+ };
28
+ }
29
+ export default Badge;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /**
3
+ * @name Basic
4
+ */
5
+ export default function Basic(): React.JSX.Element;