@splunk/react-ui 5.7.0 → 5.8.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 (138) hide show
  1. package/Accordion.js +6 -6
  2. package/Box.js +83 -34
  3. package/CHANGELOG.md +34 -0
  4. package/CollapsiblePanel.js +11 -11
  5. package/ComboBox.js +31 -27
  6. package/ControlGroup.js +92 -91
  7. package/DefinitionList.js +9 -9
  8. package/Drawer.d.ts +2 -0
  9. package/Drawer.js +679 -0
  10. package/DualListbox.js +1 -1
  11. package/JSONTree.js +73 -72
  12. package/Link.js +2 -2
  13. package/MIGRATION.md +10 -0
  14. package/Menu.js +338 -240
  15. package/Modal.js +127 -109
  16. package/Multiselect.js +437 -351
  17. package/Paginator.js +14 -12
  18. package/Popover.js +4 -1
  19. package/README.md +11 -0
  20. package/RadioBar.js +1 -1
  21. package/Search.js +103 -88
  22. package/Select.js +42 -40
  23. package/SelectBase.js +374 -328
  24. package/SidePanel.js +346 -167
  25. package/SlidingPanels.js +11 -11
  26. package/StepBar.js +7 -7
  27. package/Switch.js +5 -5
  28. package/Text.js +24 -24
  29. package/TextArea.js +7 -7
  30. package/TransitionOpen.js +204 -185
  31. package/docs-llm/Accordion.md +267 -0
  32. package/docs-llm/Anchor Menu.md +115 -0
  33. package/docs-llm/Anchor.md +54 -0
  34. package/docs-llm/AnimationToggle.md +254 -0
  35. package/docs-llm/Avatar.md +298 -0
  36. package/docs-llm/Badge.md +212 -0
  37. package/docs-llm/Breadcrumbs.md +306 -0
  38. package/docs-llm/Button Group.md +53 -0
  39. package/docs-llm/Button.md +361 -0
  40. package/docs-llm/Card Layout.md +286 -0
  41. package/docs-llm/Card.md +619 -0
  42. package/docs-llm/Checkbox.md +218 -0
  43. package/docs-llm/Chip.md +291 -0
  44. package/docs-llm/Clickable.md +160 -0
  45. package/docs-llm/Code.md +292 -0
  46. package/docs-llm/Collapsible Panel.md +744 -0
  47. package/docs-llm/Color.md +253 -0
  48. package/docs-llm/Column Layout.md +391 -0
  49. package/docs-llm/Combo Box.md +540 -0
  50. package/docs-llm/Control Group.md +594 -0
  51. package/docs-llm/Date.md +270 -0
  52. package/docs-llm/Definition List.md +278 -0
  53. package/docs-llm/Divider.md +216 -0
  54. package/docs-llm/Drawer.md +414 -0
  55. package/docs-llm/Dropdown.md +472 -0
  56. package/docs-llm/Dual Listbox.md +325 -0
  57. package/docs-llm/File.md +653 -0
  58. package/docs-llm/Form Rows.md +374 -0
  59. package/docs-llm/Heading.md +179 -0
  60. package/docs-llm/Image.md +109 -0
  61. package/docs-llm/JSON Tree.md +260 -0
  62. package/docs-llm/Layer.md +74 -0
  63. package/docs-llm/Layout.md +50 -0
  64. package/docs-llm/Link.md +318 -0
  65. package/docs-llm/List.md +189 -0
  66. package/docs-llm/Markdown.md +179 -0
  67. package/docs-llm/Menu.md +735 -0
  68. package/docs-llm/Message Bar.md +236 -0
  69. package/docs-llm/Message.md +248 -0
  70. package/docs-llm/Modal.md +443 -0
  71. package/docs-llm/Monogram.md +159 -0
  72. package/docs-llm/Multiselect.md +937 -0
  73. package/docs-llm/Number.md +298 -0
  74. package/docs-llm/Paginator.md +395 -0
  75. package/docs-llm/Paragraph.md +148 -0
  76. package/docs-llm/Phone Number.md +254 -0
  77. package/docs-llm/Popover.md +166 -0
  78. package/docs-llm/Progress.md +141 -0
  79. package/docs-llm/Radio Bar.md +303 -0
  80. package/docs-llm/Radio List.md +350 -0
  81. package/docs-llm/Resize.md +362 -0
  82. package/docs-llm/Screen Reader Content.md +73 -0
  83. package/docs-llm/Scroll Container Context.md +155 -0
  84. package/docs-llm/Scroll.md +152 -0
  85. package/docs-llm/Search.md +381 -0
  86. package/docs-llm/Select.md +985 -0
  87. package/docs-llm/Side Panel.md +777 -0
  88. package/docs-llm/Slider.md +339 -0
  89. package/docs-llm/Sliding Panels.md +340 -0
  90. package/docs-llm/Split Button.md +295 -0
  91. package/docs-llm/Static Content.md +90 -0
  92. package/docs-llm/Step Bar.md +292 -0
  93. package/docs-llm/Switch.md +268 -0
  94. package/docs-llm/Tab Bar.md +439 -0
  95. package/docs-llm/Tab Layout.md +398 -0
  96. package/docs-llm/Table.md +2642 -0
  97. package/docs-llm/Text Area.md +253 -0
  98. package/docs-llm/Text.md +339 -0
  99. package/docs-llm/Tooltip.md +325 -0
  100. package/docs-llm/Transition Open.md +406 -0
  101. package/docs-llm/Tree.md +586 -0
  102. package/docs-llm/Typography.md +125 -0
  103. package/docs-llm/Wait Spinner.md +121 -0
  104. package/docs-llm/llms.txt +97 -0
  105. package/package.json +6 -5
  106. package/types/src/Box/Box.d.ts +2 -10
  107. package/types/src/Drawer/Body.d.ts +17 -0
  108. package/types/src/Drawer/Drawer.d.ts +114 -0
  109. package/types/src/Drawer/DrawerContext.d.ts +11 -0
  110. package/types/src/Drawer/Footer.d.ts +25 -0
  111. package/types/src/Drawer/Header.d.ts +41 -0
  112. package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
  113. package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
  114. package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
  115. package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
  116. package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
  117. package/types/src/Drawer/index.d.ts +2 -0
  118. package/types/src/JSONTree/JSONTree.d.ts +12 -5
  119. package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
  120. package/types/src/Menu/Item.d.ts +2 -1
  121. package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
  122. package/types/src/Modal/Modal.d.ts +1 -2
  123. package/types/src/Select/Option.d.ts +6 -3
  124. package/types/src/Select/Select.d.ts +8 -5
  125. package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
  126. package/types/src/SelectBase/OptionBase.d.ts +6 -3
  127. package/types/src/SelectBase/SelectBase.d.ts +8 -3
  128. package/types/src/SidePanel/SidePanel.d.ts +43 -2
  129. package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
  130. package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
  131. package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
  132. package/types/src/useKeyPress/index.d.ts +9 -2
  133. package/types/src/useOnClickOutside/index.d.ts +2 -0
  134. package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
  135. package/useKeyPress.js +23 -18
  136. package/useOnClickOutside.d.ts +2 -0
  137. package/useOnClickOutside.js +79 -0
  138. package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
@@ -0,0 +1,73 @@
1
+ # Screen Reader Content
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Basic
7
+
8
+ Click 'Show Code' to view the hidden Screen Reader Content.
9
+
10
+ ```typescript
11
+ import React from 'react';
12
+
13
+ import Button from '@splunk/react-ui/Button';
14
+ import ScreenReaderContent from '@splunk/react-ui/ScreenReaderContent';
15
+
16
+
17
+ function Basic() {
18
+ return (
19
+ <Button>
20
+ Learn more <ScreenReaderContent>about advanced search options</ScreenReaderContent>
21
+ </Button>
22
+ );
23
+ }
24
+
25
+ export default Basic;
26
+ ```
27
+
28
+
29
+
30
+ ### Skip-link
31
+
32
+ ```typescript
33
+ import React from 'react';
34
+
35
+ import styled from 'styled-components';
36
+
37
+ import Link from '@splunk/react-ui/Link';
38
+ import { mixins } from '@splunk/themes';
39
+
40
+ const StyledLink = styled(Link)`
41
+ ${mixins.skipLink()}
42
+ `;
43
+
44
+
45
+ function SkipLink() {
46
+ return <StyledLink to="#main">Skip navigation</StyledLink>;
47
+ }
48
+
49
+ export default SkipLink;
50
+ ```
51
+
52
+
53
+
54
+
55
+ ## API
56
+
57
+
58
+ ### ScreenReaderContent API
59
+
60
+ The screen reader text is used to wrap content that
61
+ is only accessible through screen readers.
62
+
63
+ #### Props
64
+
65
+ | Name | Type | Required | Default | Description |
66
+ |------|------|------|------|------|
67
+ | children | React.ReactNode | yes | | |
68
+ | elementRef | React.Ref<HTMLSpanElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
69
+
70
+
71
+
72
+
73
+
@@ -0,0 +1,155 @@
1
+ # Scroll Container Context
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Provider
7
+
8
+ A Dropdown inside a custom Scroll Container. The Dropdown (when open) scrolls with the custom container, not the window.
9
+
10
+ ```typescript
11
+ import React, { useCallback, useState } from 'react';
12
+
13
+ import Button from '@splunk/react-ui/Button';
14
+ import Dropdown from '@splunk/react-ui/Dropdown';
15
+ import P from '@splunk/react-ui/Paragraph';
16
+ import { ScrollContainerProvider } from '@splunk/react-ui/ScrollContainerContext';
17
+
18
+
19
+ function Provider() {
20
+ const [scrollContainer, setScrollContainer] = useState<HTMLDivElement | null>();
21
+ const scrollContainerRef = useCallback((el: HTMLDivElement | null) => {
22
+ setScrollContainer(el);
23
+ }, []);
24
+
25
+ const toggle = <Button label="Open dropdown in custom container" isMenu />;
26
+ return (
27
+ <div
28
+ ref={scrollContainerRef}
29
+ style={{
30
+ border: '1px dashed #ccc',
31
+ height: '100px',
32
+ width: '500px',
33
+ margin: '20px 20px 0px 0px',
34
+ padding: '30px 20px 10px 20px',
35
+ overflow: 'scroll',
36
+ }}
37
+ >
38
+ <ScrollContainerProvider value={scrollContainer}>
39
+ <Dropdown retainFocus toggle={toggle}>
40
+ <P style={{ padding: 20, maxWidth: 300 }}>
41
+ This dropdown is inside a custom scroll container.
42
+ </P>
43
+ </Dropdown>
44
+ <P style={{ marginTop: 20 }}>Scroll to see more content.</P>
45
+ <P>Additional content for demonstration.</P>
46
+ </ScrollContainerProvider>
47
+ </div>
48
+ );
49
+ }
50
+
51
+ export default Provider;
52
+ ```
53
+
54
+
55
+
56
+ ### measureProgress
57
+
58
+ ```typescript
59
+ import React, { useCallback, useContext, useEffect, useState } from 'react';
60
+
61
+ import P from '@splunk/react-ui/Paragraph';
62
+ import {
63
+ ScrollContainerContext,
64
+ ScrollContainerProvider,
65
+ } from '@splunk/react-ui/ScrollContainerContext';
66
+
67
+ type Container = Document | HTMLElement | Window;
68
+
69
+ function measureProgress(scrollContainer: Container): number {
70
+ const measureEl =
71
+ scrollContainer instanceof HTMLElement ? scrollContainer : document.documentElement;
72
+ const height = measureEl.scrollHeight - measureEl.clientHeight;
73
+ const elasticProgress = height === 0 ? 0 : measureEl.scrollTop / height;
74
+ const progress = Math.min(Math.max(elasticProgress, 0), 1);
75
+ return Math.round(progress * 100);
76
+ }
77
+
78
+
79
+ function ScrollProgress() {
80
+ const scrollContainer: Document | HTMLElement | Window =
81
+ useContext(ScrollContainerContext) || window;
82
+ const [progress, setProgress] = useState(0);
83
+
84
+ const updateProgress = useCallback(() => {
85
+ setProgress(measureProgress(scrollContainer));
86
+ }, [scrollContainer]);
87
+
88
+ useEffect(updateProgress, [scrollContainer, updateProgress]);
89
+
90
+ useEffect(() => {
91
+ scrollContainer.addEventListener('scroll', updateProgress);
92
+
93
+ return () => {
94
+ scrollContainer.removeEventListener('scroll', updateProgress);
95
+ };
96
+ }, [scrollContainer, updateProgress]);
97
+
98
+ return <P>Scroll progress: {progress}%</P>;
99
+ }
100
+
101
+ function Consumer() {
102
+ const [scrollContainer, setScrollContainer] = useState<HTMLDivElement | null>();
103
+ const scrollContainerRef = useCallback((el: HTMLDivElement | null) => {
104
+ setScrollContainer(el);
105
+ }, []);
106
+
107
+ return (
108
+ <>
109
+ <ScrollContainerProvider value={scrollContainer}>
110
+ <ScrollProgress />
111
+ </ScrollContainerProvider>
112
+ <div
113
+ ref={scrollContainerRef}
114
+ style={{
115
+ border: '1px dashed #ccc',
116
+ height: '100px',
117
+ width: '500px',
118
+ margin: '20px 20px 0px 0px',
119
+ padding: '30px 20px 10px 20px',
120
+ overflow: 'scroll',
121
+ }}
122
+ >
123
+ <ScrollContainerProvider value={scrollContainer}>
124
+ <P>This is the first paragraph in the scroll container.</P>
125
+ <P>This is the second paragraph in the scroll container.</P>
126
+ <P>This is the third paragraph in the scroll container.</P>
127
+ <P>This is the fourth paragraph in the scroll container.</P>
128
+ <P>This is the fifth paragraph in the scroll container.</P>
129
+ </ScrollContainerProvider>
130
+ </div>
131
+ </>
132
+ );
133
+ }
134
+
135
+ export default Consumer;
136
+ ```
137
+
138
+
139
+
140
+
141
+ ## API
142
+
143
+ import React from 'react';
144
+
145
+ import UtilAPI from '@splunk/react-docs/UtilAPI';
146
+
147
+ import docs from '!!@splunk/jsdoc-loader!@splunk/react-ui/ScrollContainerContext/ScrollContainerContext';
148
+
149
+ function DevelopSection() {
150
+ return [<UtilAPI key="ScrollContainerContext" docs={docs} />];
151
+ }
152
+
153
+ export default DevelopSection;
154
+
155
+
@@ -0,0 +1,152 @@
1
+ # Scroll
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Controlled
7
+
8
+ The controlled method must be used to set the Scroll position.
9
+
10
+ ```typescript
11
+ import React, { Component } from 'react';
12
+
13
+ import { times } from 'lodash';
14
+
15
+ import Button from '@splunk/react-ui/Button';
16
+ import Layout from '@splunk/react-ui/Layout';
17
+ import P from '@splunk/react-ui/Paragraph';
18
+ import Scroll from '@splunk/react-ui/Scroll';
19
+
20
+
21
+ class Basic extends Component<object, { top?: number }> {
22
+ private scrollEl: Element | null = null;
23
+
24
+ constructor(props: object) {
25
+ super(props);
26
+ this.state = {};
27
+ }
28
+
29
+ handleClickDown = () => {
30
+ if (this.scrollEl) {
31
+ this.setState({
32
+ top: this.scrollEl.scrollTop + 200,
33
+ });
34
+ }
35
+ };
36
+
37
+ handleClickUp = () => {
38
+ if (this.scrollEl) {
39
+ this.setState({
40
+ top: this.scrollEl.scrollTop - 200,
41
+ });
42
+ }
43
+ };
44
+
45
+ handleScrollComplete = () => {
46
+ this.setState({
47
+ top: undefined,
48
+ });
49
+ };
50
+
51
+ handleScrollElMount = (el: Element | null) => {
52
+ this.scrollEl = el;
53
+ };
54
+
55
+ render() {
56
+ const styles = {
57
+ border: '1px solid #ccc',
58
+ height: '400px',
59
+ width: '400px',
60
+ marginTop: '20px',
61
+ };
62
+
63
+ return (
64
+ <div>
65
+ <Layout>
66
+ <Button label="Scroll down" onClick={this.handleClickDown} />
67
+ <Button label="Scroll up" onClick={this.handleClickUp} />
68
+ </Layout>
69
+
70
+ <Scroll
71
+ elementRef={this.handleScrollElMount}
72
+ style={styles}
73
+ top={this.state.top}
74
+ onScrollComplete={this.handleScrollComplete}
75
+ tagName="article"
76
+ >
77
+ {times(15, (i) => (
78
+ <P key={i}>
79
+ This is a scrollable paragraph. Add more content to see the scroll
80
+ effect.
81
+ </P>
82
+ ))}
83
+ </Scroll>
84
+ </div>
85
+ );
86
+ }
87
+ }
88
+
89
+ export default Basic;
90
+ ```
91
+
92
+
93
+
94
+ ### Uncontrolled with Scroll Propagation
95
+
96
+ The uncontrolled approach is useful for stopping propagation of the Scroll. Here, scrolling with the mouse wheel over the container does not scroll the window.
97
+
98
+ ```typescript
99
+ import React from 'react';
100
+
101
+ import { times } from 'lodash';
102
+
103
+ import P from '@splunk/react-ui/Paragraph';
104
+ import Scroll from '@splunk/react-ui/Scroll';
105
+
106
+
107
+ function Uncontrolled() {
108
+ const styles = {
109
+ border: '1px solid #ccc',
110
+ height: '400px',
111
+ width: '400px',
112
+ };
113
+
114
+ return (
115
+ <Scroll stopScrollPropagation style={styles}>
116
+ {times(15, (i) => (
117
+ <P key={i}>
118
+ This is a scrollable paragraph. Add more content to see the scroll effect.
119
+ </P>
120
+ ))}
121
+ </Scroll>
122
+ );
123
+ }
124
+
125
+ export default Uncontrolled;
126
+ ```
127
+
128
+
129
+
130
+
131
+ ## API
132
+
133
+
134
+ ### Scroll API
135
+
136
+ #### Props
137
+
138
+ | Name | Type | Required | Default | Description |
139
+ |------|------|------|------|------|
140
+ | children | React.ReactNode | no | | |
141
+ | elementRef | React.Ref<Element> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
142
+ | left | number | no | | Set this to animate to a specific scroll position. Remove this property onScrollComplete to restore control to the user. |
143
+ | onScroll | React.UIEventHandler<Element> | no | | A callback for when the scroll position changes. |
144
+ | onScrollComplete | () => void | no | | A callback for when an animated update completes. Ensure the animate prop is set back to false and restore control to the user. |
145
+ | stopScrollPropagation | boolean \| 'window' | no | | Prevent mouseWheel events from scrolling the page or other containers. 'window' only stops the window from scrolling by removing the scroll bars, which has better performance but can affect layout. |
146
+ | tagName | unknown | no | 'div' | |
147
+ | top | number | no | | Set this to animate to a specific scroll position. Remove this property onScrollComplete to restore control to the user. |
148
+
149
+
150
+
151
+
152
+