@splunk/react-ui 4.25.0 → 4.27.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 (41) hide show
  1. package/Accordion.js +195 -212
  2. package/Breadcrumbs.js +65 -42
  3. package/CHANGELOG.md +45 -4
  4. package/CollapsiblePanel.js +554 -325
  5. package/Color.js +3 -1
  6. package/ControlGroup.js +1 -0
  7. package/MIGRATION.mdx +78 -0
  8. package/Modal.js +53 -33
  9. package/Table.js +2419 -2600
  10. package/Text.js +30 -40
  11. package/TextArea.js +304 -392
  12. package/package.json +5 -3
  13. package/types/src/Accordion/Accordion.d.ts +2 -2
  14. package/types/src/Accordion/AccordionContext.d.ts +2 -3
  15. package/types/src/Breadcrumbs/Breadcrumbs.d.ts +18 -2
  16. package/types/src/Breadcrumbs/Item.d.ts +7 -1
  17. package/types/src/Breadcrumbs/docs/examples/CustomizedClick.d.ts +2 -0
  18. package/types/src/CollapsiblePanel/CollapsiblePanel.d.ts +49 -15
  19. package/types/src/CollapsiblePanel/SingleOpenPanelGroup.d.ts +62 -0
  20. package/types/src/CollapsiblePanel/SingleOpenPanelGroupContext.d.ts +9 -0
  21. package/types/src/CollapsiblePanel/docs/examples/MultiControlled.d.ts +2 -2
  22. package/types/src/CollapsiblePanel/docs/examples/SingleOpenPanelGroupControlled.d.ts +2 -0
  23. package/types/src/CollapsiblePanel/docs/examples/SingleOpenPanelGroupUncontrolled.d.ts +2 -0
  24. package/types/src/CollapsiblePanel/icons/ExpandPanel.d.ts +7 -5
  25. package/types/src/Modal/Header.d.ts +6 -5
  26. package/types/src/Modal/Modal.d.ts +9 -2
  27. package/types/src/Table/Body.d.ts +26 -22
  28. package/types/src/Table/Cell.d.ts +3 -1
  29. package/types/src/Table/Head.d.ts +2 -2
  30. package/types/src/Table/HeadCell.d.ts +2 -0
  31. package/types/src/Table/Row.d.ts +50 -17
  32. package/types/src/Table/RowDragCell.d.ts +23 -42
  33. package/types/src/Table/Table.d.ts +29 -79
  34. package/types/src/Table/Toggle.d.ts +4 -4
  35. package/types/src/TextArea/TextArea.d.ts +1 -0
  36. package/types/src/fixtures/text.d.ts +1 -0
  37. package/types/src/CollapsiblePanel/docs/examples/prisma/BasicControlled.d.ts +0 -2
  38. package/types/src/CollapsiblePanel/docs/examples/prisma/BasicUncontrolled.d.ts +0 -2
  39. package/types/src/CollapsiblePanel/docs/examples/prisma/Content.d.ts +0 -1
  40. package/types/src/CollapsiblePanel/docs/examples/prisma/MultiControlled.d.ts +0 -2
  41. package/types/src/CollapsiblePanel/docs/examples/prisma/MultiUncontrolled.d.ts +0 -2
package/Color.js CHANGED
@@ -331,7 +331,9 @@
331
331
  var le = j().ul.withConfig({
332
332
  displayName: "PaletteStyles__StyledSwatches",
333
333
  componentId: "qgv9v9-1"
334
- })([ "", ";margin-bottom:", ";" ], P.mixins.reset("block"), P.variables.spacingQuarter);
334
+ })([ "", ";", "" ], P.mixins.reset("block"), (0, P.pick)({
335
+ enterprise: (0, I.css)([ "margin-bottom:", ";" ], P.variables.spacingQuarter)
336
+ }));
335
337
  var ie = j().li.withConfig({
336
338
  displayName: "PaletteStyles__StyledSwatch",
337
339
  componentId: "qgv9v9-2"
package/ControlGroup.js CHANGED
@@ -677,6 +677,7 @@
677
677
 
678
678
  return n().createElement(O, E({
679
679
  "data-test": "control-group",
680
+ "data-test-required": m,
680
681
  $error: Q
681
682
  }, B), n().createElement(T.Provider, {
682
683
  value: this.getContextValue()
package/MIGRATION.mdx CHANGED
@@ -5,6 +5,84 @@ import Table from '@splunk/react-ui/Table';
5
5
 
6
6
  This document lists migration guidance for new features and breaking changes.
7
7
 
8
+ ## 4.27.0
9
+
10
+ ### New `SingleOpenPanelGroup` API for `CollapsiblePanel`
11
+
12
+ #### Change
13
+ A new API, `SingleOpenPanelGroup`, has been added to `CollapsiblePanel`.
14
+
15
+ #### Context
16
+ `Accordion` and `CollapsiblePanel` have similar style and behavior. Their only behavioral difference was that `Accordion` would only allow one panel to be open at a time, whereas `CollapsiblePanel` would allow multiple panels to be open at a time.
17
+
18
+ Although they looked and behaved similarly, the APIs of `Accordion` and `CollapsiblePanel` were inconsistent. `inset` was supported in `Accordion` but not `CollapsiblePanel`; while actions were supported in `CollapsiblePanel` but not `Accordion`. Lastly, the components had different numbers of event handlers with different signatures.
19
+
20
+ These differences could lead to confusion on which component to use. It could also lead to using one component for a certain feature and then adding custom code to duplicate the functionality from the other component.
21
+
22
+ Given these behavioral and technical differences, `Accordion` will be deprecated in the next major version and `CollapsiblePanel` will support all the features of `Accordion` through its `SingleOpenPanelGroup` API. You will still be able to use `Accordion` in the next major version, but we recommend following the migration steps below at your earliest convenience.
23
+
24
+ #### Migration steps
25
+ Replace usage of `Accordion` with the `SingleOpenPanelGroup` component exported from `CollapsiblePanel`. See the `SingleOpenPanelGroup` examples in `CollapsiblePanel`'s documentation.
26
+
27
+ ### Deprecated `onRequestClose` and `onRequestOpen` callbacks and added new `onChange` callback for `CollapsiblePanel`
28
+
29
+ #### Change
30
+ `CollapsiblePanel`'s `onRequestClose` and `onRequestOpen` callbacks have been deprecated and will be removed in the next major version. A new callback `onChange` has been added to `CollapsiblePanel`.
31
+
32
+ #### Context
33
+ An `onChange` callback is more consistent with other components in `@splunk/react-ui`.
34
+
35
+ #### Migration steps
36
+ Replace `onRequestClose` and `onRequestOpen` callbacks with the new `onChange` callback when using a controlled `CollapsiblePanel`. See the Controlled example in `CollapsiblePanel`'s documentation.
37
+
38
+ ## 4.26.0
39
+
40
+ ### New `returnFocus` prop for `Modal`
41
+
42
+ #### Change
43
+ A new prop, `returnFocus`, has been added to `Modal`. `returnFocus` is optional for backwards compatibility but will be required in the next major version.
44
+
45
+ #### Context
46
+ Failing to return focus back to the invoking element (or another logical place) is a WCAG violation. Currently,
47
+ developers must remember to manually return focus. The `returnFocus` prop will be required in the next major version
48
+ and ensure focus is returned back to the invoking element.
49
+
50
+ #### Migration steps
51
+ Previously it was required to add code to manually return focus in `onRequestClose` for the `Modal` and `Modal.Header`.
52
+ This code can now be removed and replaced by passing the invoking element's ref to the new `returnFocus` prop on `Modal`.
53
+
54
+ For example, this code snippet:
55
+ ```jsx
56
+ const handleRequestClose = () => {
57
+ setOpen(false);
58
+ modalToggle?.current?.focus();
59
+ };
60
+
61
+ return (
62
+ <>
63
+ <Button onClick={handleRequestOpen} ref={modalToggle} label="Open modal" />
64
+ <Modal onRequestClose={handleRequestClose} open={open}>
65
+ <Modal.Body>Just a basic Modal.</Modal.Body>
66
+ </Modal>
67
+ </>
68
+ );
69
+ ```
70
+ can be converted to this code:
71
+ ```jsx
72
+ const handleRequestClose = () => {
73
+ setOpen(false);
74
+ };
75
+
76
+ return (
77
+ <>
78
+ <Button onClick={handleRequestOpen} ref={modalToggle} label="Open modal" />
79
+ <Modal returnFocus={modalToggle} onRequestClose={handleRequestClose} open={open}>
80
+ <Modal.Body>Just a basic Modal.</Modal.Body>
81
+ </Modal>
82
+ </>
83
+ );
84
+ ```
85
+
8
86
  ## 4.23.0
9
87
 
10
88
  ### Deprecated `JSONTree`'s `expandChildren="withShiftModifier"` value
package/Modal.js CHANGED
@@ -105,8 +105,7 @@
105
105
  var j = x()(S()).withConfig({
106
106
  displayName: "BodyStyles__StyledBox",
107
107
  componentId: "lv54z7-0"
108
- })([ "background-color:", ";", " flex:0 1 auto;overflow:auto;@media all and (-ms-high-contrast:none){*::-ms-backdrop,&{max-height:calc(100vh - 180px);}}" ], (0,
109
- w.pick)({
108
+ })([ "background-color:", ";", " flex:0 1 auto;overflow:auto;" ], (0, w.pick)({
110
109
  enterprise: w.variables.backgroundColor,
111
110
  prisma: w.variables.backgroundColorDialog
112
111
  }), (0, w.pick)({
@@ -208,12 +207,12 @@
208
207
  }
209
208
  return r;
210
209
  }
211
- var D = {
210
+ var F = {
212
211
  children: i().node
213
212
  };
214
213
  /**
215
214
  * A styled container for `Modal` body content.
216
- */ function F(e) {
215
+ */ function D(e) {
217
216
  var t = e.children, o = T(e, [ "children" ]);
218
217
  // @docs-props-type BodyPropsBase
219
218
  var i = (0, r.useState)(), a = I(i, 2), l = a[0], c = a[1];
@@ -229,8 +228,8 @@
229
228
  value: l
230
229
  }, t));
231
230
  }
232
- F.propTypes = D;
233
- /* harmony default export */ const R = F;
231
+ D.propTypes = F;
232
+ /* harmony default export */ const R = D;
234
233
  // CONCATENATED MODULE: external "@splunk/react-ui/Divider"
235
234
  const A = require("@splunk/react-ui/Divider");
236
235
  var B = e.n(A);
@@ -320,7 +319,7 @@
320
319
  var J = x()(S()).withConfig({
321
320
  displayName: "HeaderStyles__StyledBox",
322
321
  componentId: "sc-1y722ut-0"
323
- })([ "", ";flex:0 0 auto;position:relative;min-height:", ";background-color:", ";padding:", ";align-items:center;padding-right:", ";" ], w.mixins.reset("flex"), (0,
322
+ })([ "", ";flex:0 0 auto;position:relative;min-height:", ";background-color:", ";padding:", ";align-items:flex-start;padding-right:", ";" ], w.mixins.reset("flex"), (0,
324
323
  w.pick)({
325
324
  enterprise: "30px",
326
325
  prisma: {
@@ -349,7 +348,7 @@
349
348
  var Q = x().div.withConfig({
350
349
  displayName: "HeaderStyles__StyledTitleWrapper",
351
350
  componentId: "sc-1y722ut-1"
352
- })([ "", ";flex-direction:column;" ], w.mixins.reset("flex"));
351
+ })([ "", ";flex-direction:column;align-self:center;" ], w.mixins.reset("flex"));
353
352
  var Y = x().div.withConfig({
354
353
  displayName: "HeaderStyles__StyledIcon",
355
354
  componentId: "sc-1y722ut-2"
@@ -364,15 +363,25 @@
364
363
  var Z = x().div.withConfig({
365
364
  displayName: "HeaderStyles__StyledTitle",
366
365
  componentId: "sc-1y722ut-3"
367
- })([ "", ";font-size:20px;margin:0;overflow-wrap:break-word;font-weight:", ";color:", ";", "" ], w.mixins.reset("block"), w.variables.fontWeightSemiBold, w.variables.contentColorActive, (0,
366
+ })([ "", ";", " margin:0;overflow-wrap:break-word;" ], w.mixins.reset("block"), (0,
368
367
  w.pick)({
369
- enterprise: (0, g.css)([ "line-height:22px;" ]),
370
- prisma: (0, g.css)([ "line-height:24px;" ])
368
+ enterprise: (0, g.css)([ "", "" ], w.mixins.typography({
369
+ size: 20,
370
+ weight: "semiBold",
371
+ color: "active",
372
+ lineHeight: 22
373
+ })),
374
+ prisma: (0, g.css)([ "", "" ], w.mixins.typography({
375
+ size: 20,
376
+ weight: "semiBold",
377
+ color: "active",
378
+ lineHeight: 24
379
+ }))
371
380
  }));
372
381
  var ee = x().div.withConfig({
373
382
  displayName: "HeaderStyles__StyledSubtitle",
374
383
  componentId: "sc-1y722ut-4"
375
- })([ "", ";font-size:14px;overflow-wrap:break-word;line-height:", ";" ], w.mixins.reset("block"), w.variables.lineHeight);
384
+ })([ "", ";overflow-wrap:break-word;" ], w.mixins.reset("block"));
376
385
  var te = x().div.withConfig({
377
386
  displayName: "HeaderStyles__StyledButtonsWrapper",
378
387
  componentId: "sc-1y722ut-5"
@@ -681,20 +690,21 @@
681
690
  }
682
691
  return e;
683
692
  }
684
- /** @public */ var qe = {
693
+ var qe = {
685
694
  children: i().node,
686
695
  divider: i().oneOf([ "header", "footer", "both", "none" ]),
687
696
  elementRef: i().oneOfType([ i().func, i().object ]),
688
697
  initialFocus: i().oneOfType([ i().object, i().oneOf([ "first", "container" ]) ]),
689
698
  onRequestClose: i().func,
690
- open: i().bool
699
+ open: i().bool,
700
+ returnFocus: i().oneOfType([ i().func, i().object ])
691
701
  };
692
- var De = {
702
+ var Fe = {
693
703
  divider: "both",
694
704
  initialFocus: "first",
695
705
  open: false
696
706
  };
697
- var Fe = function(e) {
707
+ var De = function(e) {
698
708
  ke(o, e);
699
709
  var t = Ce(o);
700
710
  // @docs-props-type ModalPropsBase
@@ -723,36 +733,46 @@
723
733
  top: 0
724
734
  };
725
735
  }));
726
- Te(_e(i), "handleInitialFocus", (function() {
727
- var e = i.props, t = e.initialFocus, r = e.open;
728
- if (r) {
736
+ Te(_e(i), "handleFocus", (function(e) {
737
+ var t = i.props, r = t.initialFocus, n = t.open;
738
+ if (n) {
729
739
  i.initialFocusTimeoutId = l()((function() {
730
740
  var e;
731
741
  // not using the takeFocus() util here because it
732
742
  // doesn't work for all values of "initialFocus"
733
743
  // and it has a nested defer() call, which we want to avoid
734
- if (i.initialFocus !== t) {
735
- if (t === "first") {
744
+ if (i.initialFocus !== r) {
745
+ if (r === "first") {
736
746
  if (i.el) {
737
747
  /* eslint-disable prefer-destructuring */
738
748
  /* prefer-desturucting leads to harder-to-read syntax in this case */
739
749
  e = (0, m.getSortedTabbableElements)(i.el)[0];
740
750
  /* eslint-enable prefer-destructuring */ }
741
- } else if (t === "container") {
751
+ } else if (r === "container") {
742
752
  e = i.el;
743
- } else if (Oe(t) === "object") {
744
- e = t;
753
+ } else if (Oe(r) === "object") {
754
+ e = r;
745
755
  }
746
756
  // Typescript isn't happy with optional chaining here
747
757
  if (e != null && "focus" in e) {
748
758
  e.focus();
749
759
  }
750
- i.initialFocus = t;
760
+ i.initialFocus = r;
751
761
  }
752
762
  }));
753
763
  } else {
754
764
  i.initialFocus = null;
755
765
  clearTimeout(i.initialFocusTimeoutId);
766
+ if (e) {
767
+ /**
768
+ * We return focus to the invoking element here instead of in `handleRequestClose` because users can
769
+ * close the modal by updating the value of the `open` prop without calling `onRequestClose`
770
+ */
771
+ l()((function() {
772
+ var e, t, r;
773
+ (e = i.props.returnFocus) === null || e === void 0 ? void 0 : (t = e.current) === null || t === void 0 ? void 0 : (r = t.focus) === null || r === void 0 ? void 0 : r.call(t);
774
+ }));
775
+ }
756
776
  }
757
777
  }));
758
778
  Te(_e(i), "handleModalMount", (function(e) {
@@ -817,7 +837,7 @@
817
837
  je(o, [ {
818
838
  key: "componentDidMount",
819
839
  value: function e() {
820
- this.handleInitialFocus();
840
+ this.handleFocus();
821
841
  }
822
842
  }, {
823
843
  key: "componentDidUpdate",
@@ -828,7 +848,7 @@
828
848
  // so that focus won't jump around if "initialFocus" changes
829
849
  clearTimeout(this.initialFocusTimeoutId);
830
850
  }
831
- this.handleInitialFocus();
851
+ this.handleFocus(t.open);
832
852
  }
833
853
  }, {
834
854
  key: "render",
@@ -845,12 +865,12 @@
845
865
  } ]);
846
866
  return o;
847
867
  }(r.Component);
848
- Te(Fe, "propTypes", qe);
849
- Te(Fe, "defaultProps", De);
850
- Te(Fe, "Header", ce);
851
- Te(Fe, "Body", R);
852
- Te(Fe, "Footer", V);
853
- /* harmony default export */ const Re = Fe;
868
+ Te(De, "propTypes", qe);
869
+ Te(De, "defaultProps", Fe);
870
+ Te(De, "Header", ce);
871
+ Te(De, "Body", R);
872
+ Te(De, "Footer", V);
873
+ /* harmony default export */ const Re = De;
854
874
  // CONCATENATED MODULE: ./src/Modal/index.ts
855
875
  module.exports = t;
856
876
  /******/})();