@splunk/react-ui 4.28.0 → 4.28.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Change Log
2
2
  ============
3
3
 
4
+ 4.28.1 - March 21, 2024
5
+ ----------
6
+ Bug Fixes:
7
+ * Fixed `CollapsiblePanel` not calling its `onRequestOpen` and `onRequestClose` callbacks (SUI-6146).
8
+ * Fixed documentation issues and discrepancies between the `onChange` callbacks of `CollapsiblePanel` and `SingleOpenPanelGroup` (SUI-6145).
9
+ * `CollapsiblePanel` and `SingleOpenPanelGroup` will both always provide the `panelId` to their `onChange` callback.
10
+ * `CollapsiblePanel` and `SingleOpenPanelGroup` will both provide an `action="open"|"closed"` value to the `onChange` callback.
11
+
4
12
  4.28.0 - March 20, 2024
5
13
  ----------
6
14
  New Features:
@@ -97,8 +97,8 @@
97
97
  const C = require("@splunk/react-ui/ButtonSimple");
98
98
  var x = e.n(C);
99
99
  // CONCATENATED MODULE: external "@splunk/react-ui/Clickable"
100
- const S = require("@splunk/react-ui/Clickable");
101
- var O = e.n(S);
100
+ const O = require("@splunk/react-ui/Clickable");
101
+ var S = e.n(O);
102
102
  // CONCATENATED MODULE: external "@splunk/themes"
103
103
  const I = require("@splunk/themes");
104
104
  // CONCATENATED MODULE: external "@splunk/react-icons/ChevronRight"
@@ -196,7 +196,7 @@
196
196
  displayName: "CollapsiblePanelStyles__StyledToggleButton",
197
197
  componentId: "sc-1phikbp-4"
198
198
  })([ "flex:0 auto;padding:0;", "" ], N);
199
- var M = h()(O()).withConfig({
199
+ var M = h()(S()).withConfig({
200
200
  displayName: "CollapsiblePanelStyles__StyledTitleClickable",
201
201
  componentId: "sc-1phikbp-5"
202
202
  })([ "width:100%;flex-shrink:0;border-bottom:0;cursor:pointer;position:relative;display:flex;transition:background-color 0.2s,border 0.2s,box-shadow 0.2s;padding:", ";color:", ";", " ", " &[disabled]{cursor:default;color:", ";}&:focus:not([disabled]),&:active:not([disabled]){color:", ";box-shadow:", ";}&:hover:not([disabled]){color:", ";background-color:", ";}" ], (0,
@@ -415,16 +415,13 @@
415
415
  return t;
416
416
  };
417
417
  var x = (0, n.useCallback)((function(e, t) {
418
- var n = t.panelId, r = t.reason;
419
- var o = C();
420
- var a = o === n ? null : n;
418
+ var n = t.panelId;
419
+ var r = C();
420
+ var o = r === n ? null : n;
421
421
  if (!d) {
422
- k(a);
422
+ k(o);
423
423
  }
424
- p === null || p === void 0 ? void 0 : p(e, {
425
- openPanelId: a,
426
- reason: r
427
- });
424
+ p === null || p === void 0 ? void 0 : p(e, t);
428
425
  }), [ u, d, g, C, p ]);
429
426
  (0, n.useEffect)((function() {
430
427
  if (false) {}
@@ -438,9 +435,9 @@
438
435
  (0, n.useEffect)((function() {
439
436
  if (false) {}
440
437
  }), [ b, o ]);
441
- var S = n.Children.toArray(t).filter(n.isValidElement);
438
+ var O = n.Children.toArray(t).filter(n.isValidElement);
442
439
  // remove false, null, 0, etc
443
- var O = (0, n.useMemo)((function() {
440
+ var S = (0, n.useMemo)((function() {
444
441
  return {
445
442
  onChange: x,
446
443
  openPanelId: d ? u : g,
@@ -453,8 +450,8 @@
453
450
  "data-test-open-panel-id": u,
454
451
  elementRef: i
455
452
  }, c().apply(void 0, [ f ].concat(Q(Object.keys(ie))))), r().createElement(V.Provider, {
456
- value: O
457
- }, S));
453
+ value: S
454
+ }, O));
458
455
  }
459
456
  le.propTypes = ie;
460
457
  /* harmony default export */ const se = le;
@@ -502,7 +499,7 @@
502
499
  var n = arguments[t] != null ? arguments[t] : {};
503
500
  if (t % 2) {
504
501
  ue(Object(n), true).forEach((function(t) {
505
- Se(e, t, n[t]);
502
+ Oe(e, t, n[t]);
506
503
  }));
507
504
  } else if (Object.getOwnPropertyDescriptors) {
508
505
  Object.defineProperties(e, Object.getOwnPropertyDescriptors(n));
@@ -595,7 +592,7 @@
595
592
  };
596
593
  return xe(e);
597
594
  }
598
- function Se(e, t, n) {
595
+ function Oe(e, t, n) {
599
596
  if (t in e) {
600
597
  Object.defineProperty(e, t, {
601
598
  value: n,
@@ -608,7 +605,7 @@
608
605
  }
609
606
  return e;
610
607
  }
611
- var Oe = {
608
+ var Se = {
612
609
  innerBodyStyles: u().object,
613
610
  children: u().node,
614
611
  defaultOpen: u().bool,
@@ -642,60 +639,54 @@
642
639
  var r;
643
640
  de(this, n);
644
641
  r = t.call(this, e);
645
- Se(ke(r), "controlledExternally", void 0);
646
- Se(ke(r), "containerId", void 0);
647
- Se(ke(r), "toggleId", void 0);
648
- Se(ke(r), "handleRequestClose", (function(e) {
642
+ Oe(ke(r), "controlledExternally", void 0);
643
+ Oe(ke(r), "containerId", void 0);
644
+ Oe(ke(r), "toggleId", void 0);
645
+ Oe(ke(r), "handleRequestClose", (function(e) {
649
646
  var t = r.props, n = t.panelId, o = t.onRequestClose;
650
647
  o === null || o === void 0 ? void 0 : o({
651
648
  event: e,
652
649
  panelId: n,
653
650
  reason: "toggleClick"
654
651
  });
655
- r.setState(fe({
656
- animating: true
657
- }, !r.isControlled() ? {
658
- open: false
659
- } : {}));
660
652
  }));
661
- Se(ke(r), "handleRequestOpen", (function(e) {
653
+ Oe(ke(r), "handleRequestOpen", (function(e) {
662
654
  var t = r.props, n = t.panelId, o = t.onRequestOpen;
663
655
  o === null || o === void 0 ? void 0 : o({
664
656
  event: e,
665
657
  panelId: n,
666
658
  reason: "toggleClick"
667
659
  });
668
- r.setState(fe({
669
- animating: true
670
- }, !r.isControlled() ? {
671
- open: true
672
- } : {}));
673
660
  }));
674
- Se(ke(r), "handleChange", (function(e) {
675
- var t = r.props, n = t.panelId, o = t.open, a = t.onChange;
676
- var i = r.isControlled() ? o : !r.state.open;
677
- a === null || a === void 0 ? void 0 : a(e, {
678
- panelId: n,
679
- reason: "toggleClick"
680
- });
661
+ Oe(ke(r), "handleChange", (function(e) {
662
+ var t, n;
663
+ var o = r.props, a = o.panelId, i = o.onChange;
664
+ var l = r.isOpen();
681
665
  if (!r.isControlled()) {
682
666
  r.setState({
683
667
  animating: true,
684
- open: i
685
- });
686
- }
687
- if (r.context.onChange) {
688
- r.context.onChange(e, {
689
- panelId: n,
690
- reason: "toggleClick"
668
+ open: !l
691
669
  });
692
670
  }
671
+ var s = l ? "close" : "open";
672
+ i === null || i === void 0 ? void 0 : i(e, {
673
+ panelId: a,
674
+ reason: "toggleClick",
675
+ action: s
676
+ });
677
+ (t = (n = r.context).onChange) === null || t === void 0 ? void 0 : t.call(n, e, {
678
+ panelId: a,
679
+ reason: "toggleClick",
680
+ action: s
681
+ });
693
682
  // Maintains backwards compatibility until the `handleRequestClose` and `handleRequestOpen` handlers are removed in SUI-5
694
- var l = r.props.open ? r.handleRequestClose : r.handleRequestOpen;
695
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
696
- l;
683
+ if (l) {
684
+ r.handleRequestClose(e);
685
+ } else {
686
+ r.handleRequestOpen(e);
687
+ }
697
688
  }));
698
- Se(ke(r), "handleAnimationEnd", (function() {
689
+ Oe(ke(r), "handleAnimationEnd", (function() {
699
690
  r.setState({
700
691
  animating: false
701
692
  });
@@ -730,6 +721,11 @@
730
721
  if (false) {}
731
722
  if (false) {}
732
723
  }
724
+ }, {
725
+ key: "isOpen",
726
+ value: function e() {
727
+ return this.isControlled() ? this.props.open : this.state.open;
728
+ }
733
729
  // Using all three handlers: `handleRequestClose` and `handleRequestOpen` and `handleChange` to test interoperability and maintain backwards compatibility until the open/close handlers are removed in SUI-5
734
730
  }, {
735
731
  key: "isControlled",
@@ -741,23 +737,13 @@
741
737
  value: function e() {
742
738
  var t = this.props, o = t.innerBodyStyles, a = t.children, i = t.description, s = t.disabled, p = t.elementRef, u = t.headingLevel, f = t.overflow, b = t.renderChildrenWhenCollapsed, v = t.title, m = t.titleWithActions, y = t.inset;
743
739
  var h = this.state.animating;
744
- var g;
745
- if (this.context.openPanelId !== undefined) {
746
- // SingleOpenPanelGroup controlled & uncontrolled
747
- /**
748
- * SingleOpenPanelGroup already takes into account if it is controlled or not in determining openPanelId
749
- * so this.context.openPanelId is used for both the controlled and uncontrolled case.
750
- */
751
- var k = this.context.openPanelId === this.props.panelId;
752
- g = k;
753
- } else if (this.isControlled()) {
754
- // CollapsiblePanel controlled
755
- g = this.props.open;
756
- } else {
757
- // CollapsiblePanel uncontrolled
758
- g = this.state.open;
759
- }
760
- var C = {
740
+ var g = this.context.openPanelId !== undefined ?
741
+ /**
742
+ * SingleOpenPanelGroup already takes into account if it is controlled or not in determining openPanelId
743
+ * so this.context.openPanelId is used for both the controlled and uncontrolled case.
744
+ */
745
+ this.context.openPanelId === this.props.panelId : this.isOpen();
746
+ var k = {
761
747
  disabled: s,
762
748
  onClick: this.handleChange,
763
749
  id: this.toggleId,
@@ -772,7 +758,7 @@
772
758
  elementRef: p
773
759
  }, c()(this.props, l()(n.propTypes))), m ? r().createElement(B, {
774
760
  $disabled: s
775
- }, r().createElement($, pe({}, C, {
761
+ }, r().createElement($, pe({}, k, {
776
762
  appearance: "pill"
777
763
  }), r().createElement(U, {
778
764
  open: !!g
@@ -786,7 +772,7 @@
786
772
  "data-test": "heading",
787
773
  role: u ? "heading" : undefined,
788
774
  "aria-level": u
789
- }, r().createElement(M, C, r().createElement(W, null, r().createElement(U, {
775
+ }, r().createElement(M, k, r().createElement(W, null, r().createElement(U, {
790
776
  open: !!g
791
777
  })), r().createElement(H, null, r().createElement("span", {
792
778
  "data-test": "title"
@@ -812,9 +798,9 @@
812
798
  } ]);
813
799
  return n;
814
800
  }(n.Component);
815
- Se(Pe, "propTypes", Oe);
816
- Se(Pe, "defaultProps", Ie);
817
- Se(Pe, "contextType", V);
801
+ Oe(Pe, "propTypes", Se);
802
+ Oe(Pe, "defaultProps", Ie);
803
+ Oe(Pe, "contextType", V);
818
804
  /* harmony default export */ const we = Pe;
819
805
  // CONCATENATED MODULE: ./src/CollapsiblePanel/index.ts
820
806
  module.exports = t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/react-ui",
3
- "version": "4.28.0",
3
+ "version": "4.28.1",
4
4
  "description": "Library of React components that implement the Splunk design language",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Splunk Inc.",
@@ -43,7 +43,7 @@
43
43
  "@dnd-kit/sortable": "7.0.2",
44
44
  "@dnd-kit/utilities": "3.2.1",
45
45
  "@splunk/react-icons": "^4.3.0",
46
- "@splunk/themes": "^0.16.4",
46
+ "@splunk/themes": "^0.17.0",
47
47
  "@splunk/ui-utils": "^1.6.0",
48
48
  "commonmark": "^0.30.0",
49
49
  "commonmark-react-renderer": "^4.3.2",
@@ -16,6 +16,7 @@ declare type CollapsiblePanelRequestOpenHandler = (data: {
16
16
  }) => void;
17
17
  /** @public */
18
18
  declare type CollapsiblePanelChangeHandler = (event: React.MouseEvent<HTMLButtonElement>, data: {
19
+ action: 'open' | 'close';
19
20
  panelId?: string | number;
20
21
  reason: 'toggleClick';
21
22
  }) => void;
@@ -66,9 +67,8 @@ interface CollapsiblePanelPropsBase {
66
67
  */
67
68
  onRequestOpen?: CollapsiblePanelRequestOpenHandler;
68
69
  /**
69
- * Invoked on a change of the open panel. Callback is passed data, such as
70
- * the `panelId` of the `CollapsiblePanel` that originated the expand request.
71
- * `panelId` is `undefined` when the open panel is collapsed.
70
+ * Invoked on a change of the open panel.
71
+ * Callback is passed the `panelId` of the `CollapsiblePanel` that originated the expand request and the `action` ("open" or "close")
72
72
  */
73
73
  onChange?: CollapsiblePanelChangeHandler;
74
74
  /**
@@ -102,7 +102,7 @@ interface CollapsiblePanelDeprecatedControlledProps extends CollapsiblePanelProp
102
102
  defaultOpen?: never;
103
103
  onRequestOpen?: CollapsiblePanelRequestOpenHandler;
104
104
  onRequestClose?: CollapsiblePanelRequestCloseHandler;
105
- onChange: never;
105
+ onChange?: never;
106
106
  open?: boolean;
107
107
  }
108
108
  interface CollapsiblePanelControlledProps extends CollapsiblePanelPropsBase {
@@ -133,6 +133,7 @@ declare class CollapsiblePanel extends Component<CollapsiblePanelProps, Collapsi
133
133
  constructor(props: Readonly<CollapsiblePanelProps>);
134
134
  componentDidMount(): void;
135
135
  componentDidUpdate(prevProps: Readonly<CollapsiblePanelProps>): void;
136
+ private isOpen;
136
137
  private handleRequestClose;
137
138
  private handleRequestOpen;
138
139
  private handleChange;
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
3
3
  import { ComponentProps } from '../utils/types';
4
4
  /** @public */
5
5
  declare type SingleOpenPanelGroupChangeHandler = (event: React.MouseEvent<HTMLButtonElement>, data: {
6
- openPanelId?: string | number | null;
6
+ action: 'open' | 'close';
7
+ panelId?: string | number;
7
8
  reason: 'toggleClick';
8
9
  }) => void;
9
10
  interface SingleOpenPanelGroupPropsBase {
@@ -26,9 +27,8 @@ interface SingleOpenPanelGroupPropsBase {
26
27
  */
27
28
  inset?: boolean;
28
29
  /**
29
- * Invoked on a change of the open panel. Callback is passed data, such as
30
- * the `panelId` of the `CollapsiblePanel` that originated the expand request.
31
- * `panelId` is `undefined` when the open panel is collapsed.
30
+ * Invoked on a change of the open panel.
31
+ * Callback is passed the `panelId` of the `CollapsiblePanel` that originated the expand request and the `action` ("open" or "close")
32
32
  */
33
33
  onChange?: SingleOpenPanelGroupChangeHandler;
34
34
  /**