@splunk/react-ui 5.0.0 → 5.1.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 (94) hide show
  1. package/Accordion.js +59 -59
  2. package/Avatar.js +20 -20
  3. package/Breadcrumbs.js +46 -46
  4. package/Button.js +24 -24
  5. package/CHANGELOG.md +21 -2
  6. package/Calendar.js +69 -69
  7. package/Card.js +68 -68
  8. package/Chip.js +16 -16
  9. package/Clickable.js +29 -29
  10. package/Code.js +654 -519
  11. package/CollapsiblePanel.js +112 -112
  12. package/Color.js +107 -107
  13. package/ColumnLayout.js +35 -35
  14. package/ComboBox.js +190 -206
  15. package/ControlGroup.js +128 -120
  16. package/Date.js +148 -146
  17. package/DefinitionList.js +26 -26
  18. package/DualListbox.js +701 -717
  19. package/File.js +403 -403
  20. package/FormRows.js +66 -63
  21. package/Image.js +15 -15
  22. package/JSONTree.js +458 -357
  23. package/Layer.js +60 -72
  24. package/Markdown.js +66 -66
  25. package/Menu.js +44 -44
  26. package/Modal.js +49 -49
  27. package/ModalLayer.js +6 -6
  28. package/Monogram.js +16 -16
  29. package/Multiselect.js +622 -624
  30. package/Number.js +100 -100
  31. package/Paginator.js +7 -7
  32. package/Popover.js +453 -407
  33. package/Progress.js +12 -12
  34. package/Prose.js +6 -6
  35. package/RadioBar.js +180 -166
  36. package/RadioList.js +80 -79
  37. package/ResultsMenu.js +15 -15
  38. package/Scroll.js +50 -50
  39. package/Search.js +148 -164
  40. package/Select.js +668 -670
  41. package/Slider.js +30 -30
  42. package/SlidingPanels.js +24 -24
  43. package/SplitButton.js +50 -50
  44. package/StepBar.js +100 -100
  45. package/Switch.js +45 -45
  46. package/TabBar.js +196 -196
  47. package/TabLayout.js +16 -16
  48. package/Table.js +1207 -1193
  49. package/Text.js +65 -65
  50. package/TextArea.js +108 -93
  51. package/Tooltip.js +203 -197
  52. package/Tree.js +464 -366
  53. package/package.json +6 -6
  54. package/stubs-dependencies.d.ts +0 -70
  55. package/stubs-splunkui.d.ts +4 -0
  56. package/types/src/Code/Code.d.ts +17 -1
  57. package/types/src/Code/LineHighlights.d.ts +11 -0
  58. package/types/src/Code/LineNumbers.d.ts +6 -0
  59. package/types/src/Code/docs/examples/LineHighlights.d.ts +3 -0
  60. package/types/src/Code/docs/examples/LineNumbers.d.ts +3 -0
  61. package/types/src/Code/docs/examples/LineNumbersCustomStart.d.ts +3 -0
  62. package/types/src/Date/Date.d.ts +6 -1
  63. package/types/src/DefinitionList/DefinitionList.d.ts +6 -6
  64. package/types/src/FormRows/FormRows.d.ts +1 -1
  65. package/types/src/JSONTree/JSONTreeItem.d.ts +5 -2
  66. package/types/src/Markdown/Markdown.d.ts +1 -1
  67. package/types/src/Markdown/renderers/MarkdownBlockquote.d.ts +1 -1
  68. package/types/src/Markdown/renderers/MarkdownCodeBlock.d.ts +1 -1
  69. package/types/src/Markdown/renderers/index.d.ts +1 -1
  70. package/types/src/Popover/Popover.d.ts +1 -1
  71. package/types/src/RadioBar/Option.d.ts +1 -1
  72. package/types/src/RadioBar/RadioBar.d.ts +13 -6
  73. package/types/src/RadioBar/RadioBarContext.d.ts +4 -2
  74. package/types/src/RadioList/RadioList.d.ts +2 -1
  75. package/types/src/ScreenReaderContent/docs/examples/SkipLink.d.ts +3 -0
  76. package/types/src/Scroll/Inner.d.ts +1 -1
  77. package/types/src/Select/Option.d.ts +1 -1
  78. package/types/src/Select/Select.d.ts +1 -1
  79. package/types/src/Slider/docs/examples/Controlled.d.ts +1 -1
  80. package/types/src/TabLayout/Panel.d.ts +0 -1
  81. package/types/src/Table/Head.d.ts +1 -0
  82. package/types/src/Table/HeadCell.d.ts +2 -3
  83. package/types/src/Table/HeadDropdownCell.d.ts +2 -2
  84. package/types/src/Table/HeadInner.d.ts +4 -4
  85. package/types/src/Table/KeyboardSensor.d.ts +1 -1
  86. package/types/src/Table/RowDragCell.d.ts +1 -1
  87. package/types/src/Tooltip/Tooltip.d.ts +10 -5
  88. package/types/src/Tree/Item.d.ts +63 -0
  89. package/types/src/Tree/Tree.d.ts +13 -6
  90. package/types/src/Tree/TreeContext.d.ts +1 -1
  91. package/types/src/Tree/index.d.ts +1 -1
  92. package/types/src/useControlled/useControlled.d.ts +3 -1
  93. package/useControlled.js +29 -13
  94. package/types/src/Tree/TreeItem.d.ts +0 -44
@@ -27,6 +27,8 @@ interface AnchorProps {
27
27
  interface TooltipPropsBase {
28
28
  /** @private */
29
29
  appearance?: 'normal' | 'inverted' | 'none';
30
+ /** @private Generally passed by parent component rather than added directly. */
31
+ append?: boolean;
30
32
  /**
31
33
  * Provide a node to replace the default question mark.
32
34
  * For accessibility, ensure that the child can take focus, and that it
@@ -34,10 +36,7 @@ interface TooltipPropsBase {
34
36
  * on the appropriate internal element.
35
37
  */
36
38
  children?: React.ReactNode;
37
- /**
38
- * @private
39
- *
40
- */
39
+ /** @private */
41
40
  closeWhen?: 'default' | 'notOnClick';
42
41
  /**
43
42
  * The content of the tooltip. If the content is falsy and the `open` prop
@@ -95,6 +94,8 @@ interface TooltipPropsBase {
95
94
  * The onRequestClose and onRequestOpen callbacks are usually used.
96
95
  */
97
96
  open?: boolean;
97
+ /** @private Generally passed by parent component rather than added directly. */
98
+ prepend?: boolean;
98
99
  /**
99
100
  * A function for rendering the element that the tooltip is bound to. If both `renderAnchor` and
100
101
  * `children` are passed, `children` will be ignored. The function gets as input props object
@@ -121,11 +122,13 @@ type TooltipProps = ComponentProps<TooltipPropsBase, 'span'>;
121
122
  * The Tooltip component wraps arbitrary content to be displayed when the target element is hovered
122
123
  * or focused.
123
124
  */
124
- declare function Tooltip({ appearance, children, closeDelay, closeWhen, content, contentRelationship, defaultPlacement, elementRef, inline, onRequestClose, onRequestOpen, open: openProp, openDelay, renderAnchor, ...otherProps }: TooltipProps): React.JSX.Element;
125
+ declare function Tooltip({ appearance, append, children, closeDelay, closeWhen, content, contentRelationship, defaultPlacement, elementRef, inline, onRequestClose, onRequestOpen, open: openProp, openDelay, renderAnchor, prepend, ...otherProps }: TooltipProps): React.JSX.Element;
125
126
  declare namespace Tooltip {
126
127
  var propTypes: {
127
128
  /** @private */
128
129
  appearance: PropTypes.Requireable<string>;
130
+ /** @private */
131
+ append: PropTypes.Requireable<boolean>;
129
132
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
130
133
  closeDelay: PropTypes.Requireable<number>;
131
134
  /** @private */
@@ -139,6 +142,8 @@ declare namespace Tooltip {
139
142
  onRequestOpen: PropTypes.Requireable<(...args: any[]) => any>;
140
143
  open: PropTypes.Requireable<boolean>;
141
144
  openDelay: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
145
+ /** @private */
146
+ prepend: PropTypes.Requireable<boolean>;
142
147
  renderAnchor: PropTypes.Requireable<(...args: any[]) => any>;
143
148
  };
144
149
  var possibleOpenReasons: TooltipPossibleOpenReason[];
@@ -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
+ /** Custom indent to show before `Tree.Item` content. */
12
+ customIndent?: React.ReactNode;
13
+ /**
14
+ * A React ref which is set to the DOM element when the component mounts and null when it unmounts.
15
+ */
16
+ elementRef?: React.Ref<HTMLLIElement>;
17
+ /**
18
+ * @private Used only by JSONTree - artifact from before Tree was public.
19
+ * Conventional `endAdornment` in all other cases would instead be just done by including the desired element in `content`.
20
+ * 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.
21
+ * This is required in JSONTree to handle closing bracket/braces but does not have a known use case for other Tree uses.
22
+ */
23
+ endAdornment?: React.ReactNode;
24
+ /** Expansion state of the `Tree.Item`. */
25
+ expanded?: boolean;
26
+ labelledBy?: string;
27
+ onFocus?: React.FocusEventHandler<HTMLLIElement>;
28
+ onKeyDown?: React.KeyboardEventHandler<HTMLLIElement>;
29
+ /** 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. */
30
+ onToggleExpansion?: TreeItemToggleExpansionHandler;
31
+ /** Called on selection state change of the `Tree.Item` and can be used to maintain optional external `Tree.Item` selection state. */
32
+ onToggleSelection?: TreeItemToggleSelectionHandler;
33
+ }
34
+ type TreeItemProps = ComponentProps<TreeItemPropsBase, 'li'>;
35
+ type TreeItemClickHandler = (event: React.MouseEvent<HTMLSpanElement>, id: string) => void;
36
+ type TreeItemKeyDownHandler = (event: React.KeyboardEvent<HTMLLIElement>, id: string, isExpanded: boolean | undefined, childrenCleaned: React.ReactElement[] | undefined | null, handleToggleExpansion: TreeItemToggleExpansionHandler) => void;
37
+ /** @public */
38
+ type TreeItemToggleExpansionHandler = (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>, data?: {
39
+ treeItemId?: string;
40
+ }) => void;
41
+ /** @public */
42
+ type TreeItemToggleSelectionHandler = (event: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>, data?: {
43
+ treeItemId?: string;
44
+ }) => void;
45
+ declare function Item({ id, children, content, customIndent, elementRef, endAdornment, expanded, labelledBy, onFocus, onKeyDown, onToggleExpansion, onToggleSelection, ...otherProps }: TreeItemProps): React.JSX.Element;
46
+ declare namespace Item {
47
+ var propTypes: {
48
+ id: PropTypes.Requireable<string>;
49
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
50
+ content: PropTypes.Requireable<PropTypes.ReactNodeLike>;
51
+ customIndent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
52
+ elementRef: PropTypes.Requireable<object>;
53
+ endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
54
+ expanded: PropTypes.Requireable<boolean>;
55
+ labelledBy: PropTypes.Requireable<string>;
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
+ import Item from './Item';
3
4
  import { ComponentProps } from '../utils/types';
4
- import TreeItem from './TreeItem';
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): React.JSX.Element;
18
+ /**
19
+ * Used to present a hierarchical list.
20
+ */
21
+ declare function Tree({ children, defaultIndent, elementRef, ...otherProps }: TreeProps): React.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,5 +1,5 @@
1
+ import { TreeItemClickHandler, TreeItemKeyDownHandler } from './Item';
1
2
  import { RemoveNodeHandler, SetNodeHandler } from './Tree';
2
- import { TreeItemClickHandler, TreeItemKeyDownHandler } from './TreeItem';
3
3
  export interface TreeContext {
4
4
  defaultIndent?: boolean;
5
5
  onItemKeyDown?: TreeItemKeyDownHandler;
@@ -1,3 +1,3 @@
1
1
  export { default } from './Tree';
2
2
  export * from './Tree';
3
- export * from './TreeItem';
3
+ export * from './Item';
@@ -1,4 +1,6 @@
1
1
  import { MutableRefObject } from 'react';
2
+ declare function isPrimitive(value: unknown): boolean;
3
+ declare function isAllowedType(value: unknown): boolean;
2
4
  interface DefaultValueProps {
3
5
  componentProps: {
4
6
  [key: string]: any;
@@ -19,4 +21,4 @@ interface DefaultValueProps {
19
21
  */
20
22
  declare function useControlled({ componentProps, componentName, defaultValuePropName, valuePropName, }: DefaultValueProps): MutableRefObject<boolean>['current'];
21
23
  export default useControlled;
22
- export { DefaultValueProps };
24
+ export { DefaultValueProps, isPrimitive, isAllowedType };
package/useControlled.js CHANGED
@@ -19,9 +19,9 @@
19
19
  /******/ // The require function
20
20
  /******/ function t(o) {
21
21
  /******/ // Check if module is in cache
22
- /******/ var a = r[o];
23
- /******/ if (a !== undefined) {
24
- /******/ return a.exports;
22
+ /******/ var n = r[o];
23
+ /******/ if (n !== undefined) {
24
+ /******/ return n.exports;
25
25
  /******/ }
26
26
  /******/ // Create a new module (and put it into the cache)
27
27
  /******/ var u = r[o] = {
@@ -96,14 +96,30 @@
96
96
  t.r(o);
97
97
  // EXPORTS
98
98
  t.d(o, {
99
- default: () => /* reexport */ n
99
+ default: () => /* reexport */ l,
100
+ isAllowedType: () => /* reexport */ f,
101
+ isPrimitive: () => /* reexport */ a
100
102
  });
101
103
  // EXTERNAL MODULE: external "react"
102
104
  var e = t(9497);
105
+ // CONCATENATED MODULE: external "lodash/isEqual"
106
+ const r = require("lodash/isEqual");
103
107
  // EXTERNAL MODULE: external "lodash/has"
104
- var r = t(5919);
105
- var a = t.n(r);
108
+ var n = t(5919);
109
+ var u = t.n(n);
106
110
  // CONCATENATED MODULE: ./src/useControlled/useControlled.tsx
111
+ function a(e) {
112
+ return e === null || e === undefined || typeof e === "boolean" || typeof e === "string" || typeof e === "number";
113
+ }
114
+ function f(e) {
115
+ if (a(e)) {
116
+ return true;
117
+ }
118
+ if (Array.isArray(e)) {
119
+ return e.every(a);
120
+ }
121
+ return false;
122
+ }
107
123
  /**
108
124
  * This is a private component not intended for use outside @splunk/react-ui
109
125
  *
@@ -113,21 +129,21 @@
113
129
  * are not happening.
114
130
  *
115
131
  * Return the controlled state of the component.
116
- */
117
- function u(r) {
118
- var t = r.componentProps, o = r.componentName, u = o === void 0 ? "this component" : o, n = r.defaultValuePropName, f = n === void 0 ? "defaultValue" : n, i = r.valuePropName, l = i === void 0 ? "value" : i;
119
- var s = (0, e.useRef)(a()(t, l));
132
+ */ function i(r) {
133
+ var t = r.componentProps, o = r.componentName, n = o === void 0 ? "this component" : o, a = r.defaultValuePropName, f = a === void 0 ? "defaultValue" : a, i = r.valuePropName, l = i === void 0 ? "value" : i;
134
+ var s = (0, e.useRef)(u()(t, l));
120
135
  var d = (0, e.useRef)(t[f]);
121
136
  (0, e.useEffect)((function() {
122
137
  if (false) {}
123
- }), [ u, t, f, l ]);
138
+ }), [ n, t, f, l ]);
124
139
  (0, e.useEffect)((function() {
125
140
  if (false) {}
126
141
  if (false) {}
127
- }), [ u, t, f, l ]);
142
+ if (false) {}
143
+ }), [ n, t, f, l ]);
128
144
  return s.current;
129
145
  }
130
- /* harmony default export */ const n = u;
146
+ /* harmony default export */ const l = i;
131
147
  }) // CONCATENATED MODULE: ./src/useControlled/index.ts
132
148
  ();
133
149
  module.exports = o;
@@ -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): React.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 };