@splunk/react-ui 4.45.0 → 4.47.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splunk/react-ui",
3
- "version": "4.45.0",
3
+ "version": "4.47.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.",
@@ -45,7 +45,7 @@
45
45
  "@dnd-kit/sortable": "^8.0.0",
46
46
  "@dnd-kit/utilities": "^3.2.2",
47
47
  "@splunk/react-icons": "^4.14.0",
48
- "@splunk/themes": "^0.24.0",
48
+ "@splunk/themes": "^0.25.0",
49
49
  "@splunk/ui-utils": "^1.8.0",
50
50
  "commonmark": "^0.30.0",
51
51
  "commonmark-react-renderer": "^4.3.2",
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ComponentProps } from '../utils/types';
4
- type CodeSupportedLanguages = 'bash' | 'clike' | 'css' | 'html' | 'json' | 'javascript' | 'js' | 'jsx' | 'typescript' | 'ts' | 'tsx' | 'markup' | 'mathml' | 'plain' | 'plaintext' | 'splunk-spl' | 'svg' | 'text' | 'txt' | 'xml' | 'yaml' | 'yml';
4
+ type CodeSupportedLanguages = 'bash' | 'clike' | 'css' | 'html' | 'json' | 'javascript' | 'js' | 'jsx' | 'typescript' | 'ts' | 'tsx' | 'markup' | 'mathml' | 'plain' | 'plaintext' | 'splunk-spl' | 'sql' | 'svg' | 'text' | 'txt' | 'xml' | 'yaml' | 'yml';
5
5
  interface CodePropsBase {
6
6
  /**
7
7
  * A React ref which is set to the DOM element when the component mounts and null when it unmounts.
@@ -3,7 +3,10 @@ import PropTypes from 'prop-types';
3
3
  import { JSONElement } from './JSONTree';
4
4
  import { TreeItemPropsBase } from '../Tree';
5
5
  import { ComponentProps } from '../utils/types';
6
- export type ExpandLinkHandler = (data: {
6
+ export type ExpandLinkRenderer = (params: {
7
+ onToggleExpansion: (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>, data?: {
8
+ treeItemId?: string;
9
+ }) => void;
7
10
  open: boolean;
8
11
  withTooltip: boolean;
9
12
  expandLinkRef: React.RefObject<HTMLButtonElement>;
@@ -20,7 +23,7 @@ interface JSONTreeItemPropsBase extends TreeItemPropsBase {
20
23
  properties?: string[];
21
24
  propertyDataPath: string;
22
25
  propertyElement?: JSX.Element | undefined;
23
- renderExpandLink?: ExpandLinkHandler;
26
+ renderExpandLink?: ExpandLinkRenderer;
24
27
  representation?: JSX.Element | JSX.Element[];
25
28
  value?: JSONElement;
26
29
  }
@@ -71,6 +71,10 @@ interface HeadCellPropsBase {
71
71
  * The `sortKey` is passed in the data object to the `onSort` callback, if provided.
72
72
  */
73
73
  sortKey?: string;
74
+ /**
75
+ * Content to show in a tooltip.
76
+ */
77
+ tooltip?: React.ReactNode;
74
78
  /**
75
79
  * Truncate the text in the label. `truncate=false` is not compatible with `Table`'s
76
80
  * `onRequestResize`.
@@ -12,6 +12,7 @@ interface HeadInnerPropsBase {
12
12
  elementRef?: React.Ref<HTMLButtonElement | HTMLDivElement>;
13
13
  focusWithin?: boolean;
14
14
  hasActionsHead?: boolean;
15
+ hasTooltip?: boolean;
15
16
  id?: string;
16
17
  index?: number;
17
18
  isMenu?: boolean;
@@ -27,7 +28,7 @@ interface HeadInnerPropsBase {
27
28
  variant?: 'toggleAll' | 'info' | 'actions';
28
29
  }
29
30
  type HeadInnerProps = ComponentProps<HeadInnerPropsBase, 'span'>;
30
- declare function HeadInner({ index, clickable, columnId, elementRef, focusWithin, id, width: widthProp, onDragEnd, onAutosizeColumn, align, label, hasActionsHead, isMenu, onDragStart, onRequestResize, resizable, sortDir, truncate, variant, ...otherProps }: HeadInnerProps): JSX.Element;
31
+ declare function HeadInner({ index, clickable, columnId, elementRef, focusWithin, id, width: widthProp, onDragEnd, onAutosizeColumn, align, label, hasActionsHead, hasTooltip, isMenu, onDragStart, onRequestResize, resizable, sortDir, truncate, variant, ...otherProps }: HeadInnerProps): JSX.Element;
31
32
  declare namespace HeadInner {
32
33
  var propTypes: {
33
34
  align: PropTypes.Requireable<string>;
@@ -36,6 +37,7 @@ declare namespace HeadInner {
36
37
  elementRef: PropTypes.Requireable<object>;
37
38
  focusWithin: PropTypes.Requireable<boolean>;
38
39
  hasActionsHead: PropTypes.Requireable<boolean>;
40
+ hasTooltip: PropTypes.Requireable<boolean>;
39
41
  id: PropTypes.Requireable<string>;
40
42
  index: PropTypes.Requireable<number>;
41
43
  isMenu: PropTypes.Requireable<boolean>;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { ComponentProps } from '../utils/types';
4
+ interface TreeItemPropsBase {
5
+ /** A unique `id` for this item and used by `Tree` to keep track of the focused item. */
6
+ id: string;
7
+ /** Should contain `Tree.Item`s, can also include other elements to display in between tree items. */
8
+ children?: React.ReactNode;
9
+ /** Content to show on the `Tree.Item`. */
10
+ content?: React.ReactNode;
11
+ /**
12
+ * @private Custom indent to show before `Tree.Item` content.
13
+ */
14
+ customIndent?: React.ReactNode;
15
+ /**
16
+ * A React ref which is set to the DOM element when the component mounts and null when it unmounts.
17
+ */
18
+ elementRef?: React.Ref<HTMLLIElement>;
19
+ /**
20
+ * @private Used only by JSONTree - artifact from before Tree was public.
21
+ * Conventional `endAdornment` in all other cases would instead be just done by including the desired element in `content`.
22
+ * Left in for JSONTree because the need to support the endAdornment conditionally going to the end of the unordered list of children in the expanded view.
23
+ * This is required in JSONTree to handle closing bracket/braces but does not have a known use case for other Tree uses.
24
+ */
25
+ endAdornment?: React.ReactNode;
26
+ /** Expansion state of the `Tree.Item`. */
27
+ expanded?: boolean;
28
+ onFocus?: React.FocusEventHandler<HTMLLIElement>;
29
+ onKeyDown?: React.KeyboardEventHandler<HTMLLIElement>;
30
+ /** Called on expansion state change of the `Tree.Item` and should be used to maintain `expanded`. For proper keyboard accessibility this is required when a `Tree.Item` has children. */
31
+ onToggleExpansion?: TreeItemToggleExpansionHandler;
32
+ /** Called on selection state change of the `Tree.Item` and can be used to maintain optional external `Tree.Item` selection state. */
33
+ onToggleSelection?: TreeItemToggleSelectionHandler;
34
+ }
35
+ type TreeItemProps = ComponentProps<TreeItemPropsBase, 'li'>;
36
+ type TreeItemClickHandler = (event: React.MouseEvent<HTMLSpanElement>, id: string) => void;
37
+ type TreeItemKeyDownHandler = (event: React.KeyboardEvent<HTMLLIElement>, id: string, isExpanded: boolean | undefined, childrenCleaned: React.ReactElement[] | undefined | null, handleToggleExpansion: TreeItemToggleExpansionHandler) => void;
38
+ /** @public */
39
+ type TreeItemToggleExpansionHandler = (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>, data?: {
40
+ treeItemId?: string;
41
+ }) => void;
42
+ /** @public */
43
+ type TreeItemToggleSelectionHandler = (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>, data?: {
44
+ treeItemId?: string;
45
+ }) => void;
46
+ declare function Item({ id, children, content, customIndent, elementRef, endAdornment, expanded, onFocus, onKeyDown, onToggleExpansion, onToggleSelection, ...otherProps }: TreeItemProps): JSX.Element;
47
+ declare namespace Item {
48
+ var propTypes: {
49
+ id: PropTypes.Requireable<string>;
50
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
51
+ content: PropTypes.Requireable<PropTypes.ReactNodeLike>;
52
+ customIndent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
53
+ elementRef: PropTypes.Requireable<object>;
54
+ endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
55
+ expanded: PropTypes.Requireable<boolean>;
56
+ onFocus: PropTypes.Requireable<(...args: any[]) => any>;
57
+ onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
58
+ onToggleSelection: PropTypes.Requireable<(...args: any[]) => any>;
59
+ onToggleExpansion: PropTypes.Requireable<(...args: any[]) => any>;
60
+ };
61
+ }
62
+ export default Item;
63
+ export { TreeItemClickHandler, TreeItemKeyDownHandler, TreeItemPropsBase, TreeItemToggleExpansionHandler, TreeItemToggleSelectionHandler, };
@@ -1,24 +1,31 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { ComponentProps } from '../utils/types';
4
- import TreeItem from './TreeItem';
4
+ import Item from './Item';
5
5
  type RemoveNodeHandler = (id: string) => void;
6
6
  type SetNodeHandler = (id: string, path?: string) => void;
7
7
  interface TreePropsBase {
8
- /** Should contain TreeItems, can also include other elements to display in between tree items. */
8
+ /** Should contain `Tree.Item`s, can also include other elements to display in between tree items. */
9
9
  children?: React.ReactNode;
10
10
  /** Removes default indent from list styles if set to false. */
11
11
  defaultIndent?: boolean;
12
+ /**
13
+ * A React ref which is set to the DOM element when the component mounts and null when it unmounts.
14
+ */
15
+ elementRef?: React.Ref<HTMLUListElement>;
12
16
  }
13
17
  type TreeProps = ComponentProps<TreePropsBase, 'ul'>;
14
- declare function Tree({ children, defaultIndent, ...otherProps }: TreeProps): JSX.Element;
18
+ /**
19
+ * Used to present a hierarchical list.
20
+ */
21
+ declare function Tree({ children, defaultIndent, elementRef, ...otherProps }: TreeProps): JSX.Element;
15
22
  declare namespace Tree {
16
23
  var propTypes: {
17
24
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
18
25
  defaultIndent: PropTypes.Requireable<boolean>;
26
+ elementRef: PropTypes.Requireable<object>;
19
27
  };
20
- var TreeItem: typeof import("./TreeItem").default;
28
+ var Item: typeof import("./Item").default;
21
29
  }
22
30
  export default Tree;
23
- export { TreeItem };
24
- export { RemoveNodeHandler, SetNodeHandler };
31
+ export { RemoveNodeHandler, SetNodeHandler, Item };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { RemoveNodeHandler, SetNodeHandler } from './Tree';
3
- import { TreeItemClickHandler, TreeItemKeyDownHandler } from './TreeItem';
3
+ import { TreeItemClickHandler, TreeItemKeyDownHandler } from './Item';
4
4
  export interface TreeContext {
5
5
  defaultIndent?: boolean;
6
6
  onItemKeyDown?: TreeItemKeyDownHandler;
@@ -0,0 +1 @@
1
+ export default function Basic(): JSX.Element;
@@ -0,0 +1 @@
1
+ export default function ClickableExpansion(): JSX.Element;
@@ -0,0 +1 @@
1
+ export default function ClickableExpansionWithSelection(): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  export { default } from './Tree';
2
2
  export * from './Tree';
3
- export * from './TreeItem';
3
+ export * from './Item';
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { ComponentProps } from '../utils/types';
4
- interface TreeItemPropsBase {
5
- /** A unique `id` for this item and used by `Tree` to keep track of the focused item. */
6
- id: string;
7
- /** Should contain `TreeItems`, can also include other elements to display in between tree items. */
8
- children?: React.ReactNode;
9
- /** Content to show on the TreeItem. */
10
- content?: React.ReactNode;
11
- /** Custom indent to show before TreeItem content. */
12
- customIndent?: React.ReactNode;
13
- endAdornment?: React.ReactNode;
14
- labelledBy?: string;
15
- onFocus?: React.FocusEventHandler<HTMLLIElement>;
16
- onKeyDown?: React.KeyboardEventHandler<HTMLLIElement>;
17
- onToggle?: TreeItemToggleHandler;
18
- /** Default open state of the node. */
19
- open?: boolean;
20
- /** Toggle to pass that opens/closes the node on click. */
21
- toggle?: React.ReactElement;
22
- }
23
- type TreeItemProps = ComponentProps<TreeItemPropsBase, 'li'>;
24
- type TreeItemClickHandler = (event: React.MouseEvent<HTMLSpanElement>, id: string) => void;
25
- type TreeItemKeyDownHandler = (event: React.KeyboardEvent<HTMLLIElement>, id: string, showChildren: boolean | undefined, childrenCleaned: React.ReactElement[] | undefined | null, handleToggle: TreeItemToggleHandler) => void;
26
- type TreeItemToggleHandler = (isOpen: boolean, event?: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>) => void;
27
- declare function TreeItem({ id, children, content, customIndent, endAdornment, labelledBy, onFocus, onKeyDown, onToggle, open, toggle, ...otherProps }: TreeItemProps): JSX.Element;
28
- declare namespace TreeItem {
29
- var propTypes: {
30
- id: PropTypes.Requireable<string>;
31
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
32
- content: PropTypes.Requireable<PropTypes.ReactNodeLike>;
33
- customIndent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
34
- endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
35
- labelledBy: PropTypes.Requireable<string>;
36
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
37
- onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
38
- onToggle: PropTypes.Requireable<(...args: any[]) => any>;
39
- open: PropTypes.Requireable<boolean>;
40
- toggle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
41
- };
42
- }
43
- export default TreeItem;
44
- export { TreeItemClickHandler, TreeItemKeyDownHandler, TreeItemPropsBase, TreeItemToggleHandler };