@splunk/react-ui 5.7.1 → 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 +29 -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 +188 -169
  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,218 @@
1
+ # Checkbox
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of Checkbox component
7
+
8
+
9
+ <Message appearance="fill" type="info">
10
+ <div>All data entry components should be wrapped in a <Link to="ControlGroup">Control Group</Link> to provide a label, error states, and help or error text, ensuring an accessible experience for all users.</div>
11
+ </Message>
12
+
13
+ ## When to use this component
14
+ Checkbox lets users select one or more options from a list. Use it for simple, binary choices where multiple selections are allowed.
15
+
16
+ - When users need to select multiple items independently (e.g., filter options, preferences)
17
+ - When you want to present a list of options that aren't mutually exclusive
18
+ - In forms where several related options can be enabled together
19
+
20
+ ## When to use another component
21
+ - If selecting a single option from a set of two or more that are mutually exclusive and don't map to a boolean relationship (such as on/off) use `Radio List` or `Radio Bar`
22
+ - If multiple options can be selected from a long list of items, use `Multiselect`
23
+ - If there's a binary choice for enabling a setting, like on/off, true/false, enable/disable, or activate/deactivate, use `Switch` with `appearance="toggle"`
24
+ - If there are multiple options, space conservation is important, and only one option can be selected at a time use a `Select` or `Combobox`
25
+
26
+ ```mermaid
27
+ graph TD
28
+ accDescr: Decision tree that guides on when to use the Checkbox component or something else
29
+ A(Can the user select more than 1 option?)
30
+ A -- Yes --- B(Are there fewer than 5 options and you don't need to conserve space?)
31
+ B -- Yes --- C(Checkbox group)
32
+ B -- No --- D(Multiselect)
33
+ A -- No --- E("Do the options have a boolean (Ex. on/off) relationship?")
34
+ E -- Yes --- F(Toggle)
35
+ E -- No --- G(Are there fewer than 5 options and you don't need to conserve space?)
36
+ G -- Yes --- H(Radio List or Radio Bar)
37
+ G -- No --- I(Select or ComboBox)
38
+ ```
39
+
40
+ ### Check out
41
+ - [RadioList][1]
42
+ - [RadioBar][2]
43
+ - [Multiselect][3]
44
+ - [Switch][4]
45
+ - [Select][5]
46
+ - [ComboBox][6]
47
+
48
+ ## Usage
49
+
50
+ ### Group related options
51
+
52
+ Present checkboxes together for related choices. Grouping improves clarity and helps users scan options quickly.
53
+
54
+ > Image: The first example with heart eyes emoji shows grouped checkboxes with clear labels. The second example with grimacing emoji shows scattered checkboxes that are hard to scan.
55
+
56
+
57
+ ### Consistent labeling in groups
58
+
59
+ Ensure labeling is consistent in checkbox groups so users can easily distinguish between the items.
60
+
61
+ > Image: Examples of a group of three checkboxes. The checkboxes in the heart eyes example have the labels,
62
+
63
+
64
+ ## Content
65
+
66
+ ### Labels
67
+
68
+ Keep labels concise by using one to three words. Apply sentence-style capitalization and ensure each label clearly describes the option’s function.
69
+
70
+ > Image: The first example with heart eyes emoji shows concise, clear labels. The second example with grimacing emoji shows labels that are too long or vague.
71
+
72
+
73
+
74
+ [1]: ./RadioList
75
+ [2]: ./RadioBar
76
+ [3]: ./Multiselect
77
+ [4]: ./Switch
78
+ [5]: ./Select
79
+ [6]: ./ComboBox
80
+
81
+ ## Examples
82
+
83
+
84
+ ### Controlled
85
+
86
+ Checkbox can be controlled using the checked prop and an onChange callback.
87
+
88
+ ```typescript
89
+ import React, { useState } from 'react';
90
+
91
+ import Checkbox, { CheckboxChangeHandler } from '@splunk/react-ui/Checkbox';
92
+
93
+
94
+ const Basic = () => {
95
+ const [checkedTandC, setCheckedTandC] = useState<boolean>(true);
96
+ const [checkedEmail, setCheckedEmail] = useState<boolean>(false);
97
+
98
+ const handleEmailChange: CheckboxChangeHandler = (e, { checked: newChecked }) => {
99
+ setCheckedEmail(newChecked);
100
+ };
101
+
102
+ const handleTandCChange: CheckboxChangeHandler = (e, { checked: newChecked }) => {
103
+ setCheckedTandC(newChecked);
104
+ };
105
+
106
+ return (
107
+ <>
108
+ <Checkbox checked={checkedTandC} onChange={handleTandCChange}>
109
+ I accept the terms and conditions
110
+ </Checkbox>
111
+ <Checkbox checked={checkedEmail} onChange={handleEmailChange}>
112
+ Send me email updates
113
+ </Checkbox>
114
+ </>
115
+ );
116
+ };
117
+
118
+ export default Basic;
119
+ ```
120
+
121
+
122
+
123
+ ### Uncontrolled
124
+
125
+ Checkbox can also used as an uncontrolled component, using defaultChecked to set the initial checked state.
126
+
127
+ ```typescript
128
+ import React from 'react';
129
+
130
+ import Checkbox from '@splunk/react-ui/Checkbox';
131
+
132
+
133
+ const Uncontrolled = () => {
134
+ return (
135
+ <>
136
+ <Checkbox defaultChecked>I accept the terms and conditions</Checkbox>
137
+ <Checkbox>Send me email updates</Checkbox>
138
+ </>
139
+ );
140
+ };
141
+
142
+ export default Uncontrolled;
143
+ ```
144
+
145
+
146
+
147
+ ### Disabled
148
+
149
+ ```typescript
150
+ import React from 'react';
151
+
152
+ import Checkbox from '@splunk/react-ui/Checkbox';
153
+
154
+
155
+ const Disabled = () => {
156
+ return <Checkbox disabled>This option is disabled</Checkbox>;
157
+ };
158
+
159
+ export default Disabled;
160
+ ```
161
+
162
+
163
+
164
+ ### Error
165
+
166
+ ```typescript
167
+ import React, { useState } from 'react';
168
+
169
+ import Checkbox, { CheckboxChangeHandler } from '@splunk/react-ui/Checkbox';
170
+
171
+
172
+ function CheckboxError() {
173
+ const [checked, setChecked] = useState<boolean>();
174
+
175
+ const handleChange: CheckboxChangeHandler = (e, { checked: newChecked }) => {
176
+ setChecked(newChecked);
177
+ };
178
+
179
+ return (
180
+ <Checkbox checked={checked} error={!checked} onChange={handleChange}>
181
+ I accept the terms and conditions
182
+ </Checkbox>
183
+ );
184
+ }
185
+
186
+ export default CheckboxError;
187
+ ```
188
+
189
+
190
+
191
+
192
+ ## API
193
+
194
+
195
+ ### Checkbox API
196
+
197
+ #### Props
198
+
199
+ | Name | Type | Required | Default | Description |
200
+ |------|------|------|------|------|
201
+ | checked | boolean \| 'indeterminate' | no | | Setting this value makes the component controlled. If set, the onChange callback is required. A setting of "indeterminate" is considered unchecked for the purposes of form submission. |
202
+ | children | React.ReactNode | no | | The content to display inside the checkbox label. |
203
+ | defaultChecked | boolean | no | | Set this property instead of checked to make the component uncontrolled. |
204
+ | describedBy | string | no | | The id of the description. When placed in a ControlGroup, this is automatically set to the ControlGroup's help component. |
205
+ | disabled | boolean | no | | |
206
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts, and null when it unmounts. |
207
+ | error | boolean | no | | Mark the component as having an error. |
208
+ | inert | boolean | no | | |
209
+ | inputRef | React.Ref<HTMLInputElement> | no | | A React ref which is set to the input element when the component mounts and null when it unmounts. |
210
+ | labelledBy | string | no | | The id of the label. When placed in a ControlGroup, this is automatically set to the ControlGroup's label. |
211
+ | name | string | no | | The name is returned with onChange events, which can be used to identify the control when multiple controls share an onChange callback. |
212
+ | onChange | ( event: React.ChangeEvent<HTMLInputElement>, data: { checked: boolean; name?: string; value?: string; } ) => void | no | | Fires when the checked state changes. |
213
+ | value | string | no | | Returned by the onChange handler and submitted during form submission if the checkbox is checked. This defaults to "on" if the input is checked. |
214
+
215
+
216
+
217
+
218
+
@@ -0,0 +1,291 @@
1
+ # Chip
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a group of three Chips.
7
+
8
+
9
+ ## When to use this component
10
+ - When you need to represent a large number of items in a limited amount of space. Ideal for use in list or grid format.
11
+
12
+ ## When to use another component
13
+ - `Chip` is limited in hierarchical affordances, such as key-value pairs or sub categories. Using a `List` or `DefinitionList` can provide a more organized representation of a collection of items.
14
+ - Interactivity of `Chip` is limited, `Multiselect` provides a structured experience for selecting one or more options from a set.
15
+ - Due to the compact design, Chips can be difficult to discover. If the information represents a status change that is evoked by user action, consider including `Message` or `MessageBar`.
16
+
17
+ ```mermaid
18
+ graph TD
19
+ accDescr: Decision tree that guides on when to use the Chip component or something else
20
+ A(Can each item in the group be represented with only a 1-3 word label?) -- Yes --- B(Is a robust interactive experience needed, including actions such as searching and scrolling?)
21
+ B -- Yes --- C(Multiselect)
22
+ B -- No --- D(Chip)
23
+ A -- No --- E(List or Definition List)
24
+ ```
25
+
26
+ ### Check out
27
+ - [Button][1]
28
+ - [Link][2]
29
+ - [Multiselect][3]
30
+
31
+ ## Usage
32
+
33
+ ### Grouping
34
+ A Chip works best in a group. Using a single Chip often loses the benefits of Chips, which is representing a large number of items in a limited amount of space.
35
+
36
+ > Image: Example with two modals. The first modal example with heart eyes emoji has a group of three Chips. The second example with a grimacing emoji only displays a single Chip.
37
+
38
+
39
+ ### Removable Chips
40
+ When a `Chip` is removable, it’s best to allow users to also be able to add `Chip` back.
41
+
42
+ > Image: Examples of a group of two removable Chips. The example with the heart eyes includes an add button, where users can add more Chips. The second example with a grimacing emoji shows no way to add more Chips.
43
+
44
+
45
+ ### Consistent interactions
46
+ Keep interactions consistent across the group.
47
+
48
+ > Image: Examples of two Chips. The first example with heart eyes shows two removable Chips. The second example with a grimacing face shows one Chip that is removable and one Chip that isn
49
+
50
+
51
+ ### Group organization
52
+ To improve scannability, a Chip group should flow like words in a paragraph, rather than a vertical list.
53
+
54
+ > Image: Example of a group of three Chips. The first example with heart eyes shows the group aligned horizontally. The second example with a grimacing face the group aligned vertically.
55
+
56
+
57
+ ### Large groups
58
+ When space is limited, such as in a table, the Chip group may overflow the space. A label like ‘3 more Chips’ makes this screen reader accessible. It is also important to provide a detailed view where users can view the entire Chip group.
59
+
60
+ > Image: Example of Chips within a table with 3 columns; Name, Groups, which includes the Chips, and Status. In the modal with the heart eyes, there is two chips and a plus two Chip which on hover, displayed a third Chip that do not fit in the column. The modal with a grimacing face does not have the plus two Chip, resulting in the third chip running into the next column, cutting off the name of the Chip.
61
+
62
+
63
+ ## Content
64
+
65
+ ### Write concise labels: 1-3 words
66
+
67
+ > Image: Examples of chip label length. The first example with heart eyes emoji has a chip with a label the reads
68
+
69
+
70
+ ### Label overflow
71
+ While one to two words (20-25 characters) is recommended for Chip labels, there might be instances when text needs to be longer. Truncation can be considered if characters go outside this limit, but make sure the Chip's content can be viewed in it's entirety with a `Tooltip`.
72
+
73
+ > Image: Examples of chip label overflow. The first example with heart eyes has a chip that is hovered with a truncated label that reads
74
+
75
+
76
+ ### Use sentence-style capitalization
77
+
78
+ > Image: Examples of sentence-style for Chip labels. The first example with heart eyes emoji has a Chip with a label using sentence-style capitalization that reads
79
+
80
+
81
+ ### Label metadata
82
+ Ensure labeling is consistent across chips so users can easily distinguish between the list items.
83
+
84
+ > Image: Examples of a group of three chips. The chips in the heart eyes example have the labels,
85
+
86
+
87
+ ### Appropriate icons
88
+ Use icons that relate to the labeling, enhancing comparability across the group.
89
+
90
+ > Image: Examples of two chips. The first example with heart eyes shows one chip with the label,
91
+
92
+
93
+ ### Follow color contrast guidelines
94
+ When using custom colors, ensure you are following the WCAG guideline of a contrast ratio &gt= 4.5:1 between text and background. [SC 1.4.3][4]
95
+
96
+ > Image: Examples of three chips with different custom background colours. In the first example with heart eyes, the chip labels are dark and abide by the 4.5 to 1 contrast guidelines. In the second example with the grimacing face, the chip labels are lighter and similar to the background colours, breaking the contrast guidelines.
97
+
98
+
99
+ [1]: ./Button
100
+ [2]: ./Link
101
+ [3]: ./Multiselect
102
+ [4]: https://www.w3.org/TR/WCAG21/#contrast-minimum
103
+
104
+ ## Examples
105
+
106
+
107
+ ### Appearance
108
+
109
+ ```typescript
110
+ import React from 'react';
111
+
112
+ import Chip from '@splunk/react-ui/Chip';
113
+ import Layout from '@splunk/react-ui/Layout';
114
+
115
+
116
+ function Appearance() {
117
+ return (
118
+ <Layout>
119
+ <Chip>default</Chip>
120
+ <Chip appearance="outline">outline</Chip>
121
+ <Chip appearance="info">info</Chip>
122
+ <Chip appearance="success">success</Chip>
123
+ <Chip appearance="warning">warning</Chip>
124
+ <Chip appearance="error">error</Chip>
125
+ </Layout>
126
+ );
127
+ }
128
+
129
+ export default Appearance;
130
+ ```
131
+
132
+
133
+
134
+ ### Custom colors
135
+
136
+ When using custom colors, ensure you are following the WCAG guideline of a contrast ratio >= 4.5:1 between text and background.
137
+
138
+ ```typescript
139
+ import React from 'react';
140
+
141
+ import Chip from '@splunk/react-ui/Chip';
142
+ import Layout from '@splunk/react-ui/Layout';
143
+
144
+
145
+ function CustomColors() {
146
+ return (
147
+ <Layout>
148
+ <Chip foregroundColor="#400000" backgroundColor="#aeb6bf">
149
+ Chart area
150
+ </Chip>
151
+ <Chip foregroundColor="#45b39d" backgroundColor="#004444">
152
+ Chart area
153
+ </Chip>
154
+ <Chip foregroundColor="#4d1b7b" backgroundColor="#c79dd7">
155
+ Chart area
156
+ </Chip>
157
+ </Layout>
158
+ );
159
+ }
160
+
161
+ export default CustomColors;
162
+ ```
163
+
164
+
165
+
166
+ ### With icons
167
+
168
+ ```typescript
169
+ import React from 'react';
170
+
171
+ import ChartArea from '@splunk/react-icons/ChartArea';
172
+ import ChartColumn from '@splunk/react-icons/ChartColumn';
173
+ import ChartLine from '@splunk/react-icons/ChartLine';
174
+ import Chip from '@splunk/react-ui/Chip';
175
+ import Layout from '@splunk/react-ui/Layout';
176
+
177
+
178
+ function Icon() {
179
+ return (
180
+ <Layout>
181
+ <Chip icon={<ChartArea />}>Chart area</Chip>
182
+ <Chip icon={<ChartColumn />}>Chart column</Chip>
183
+ <Chip icon={<ChartLine />}>Line chart</Chip>
184
+ </Layout>
185
+ );
186
+ }
187
+
188
+ export default Icon;
189
+ ```
190
+
191
+
192
+
193
+ ### Removable
194
+
195
+ ```typescript
196
+ import React from 'react';
197
+
198
+ import Chip from '@splunk/react-ui/Chip';
199
+
200
+
201
+ function Removable() {
202
+ return <Chip onRequestRemove={() => {}}>Removable</Chip>;
203
+ }
204
+
205
+ export default Removable;
206
+ ```
207
+
208
+
209
+
210
+ ### Removable with non-string children
211
+
212
+ The descriptive label for a Chip can be overridden by applying an aria-label attribute. This is necessary if passing children that are not of type string.
213
+
214
+ ```typescript
215
+ import React from 'react';
216
+
217
+ import Chip from '@splunk/react-ui/Chip';
218
+ import Typography from '@splunk/react-ui/Typography';
219
+
220
+
221
+ const RemovableWithNonStringChildren = () => (
222
+ <Chip onRequestRemove={() => {}} aria-label="Remove Bar chart">
223
+ <Typography as="span" variant="body">
224
+ Bar chart{' '}
225
+ <Typography as="span" variant="smallBody">
226
+ with custom colors
227
+ </Typography>
228
+ </Typography>
229
+ </Chip>
230
+ );
231
+
232
+ export default RemovableWithNonStringChildren;
233
+ ```
234
+
235
+
236
+
237
+ ### disabled
238
+
239
+ ```typescript
240
+ import React from 'react';
241
+
242
+ import Chip from '@splunk/react-ui/Chip';
243
+ import Layout from '@splunk/react-ui/Layout';
244
+
245
+
246
+ function Disabled() {
247
+ return (
248
+ <Layout>
249
+ <Chip disabled>Disabled</Chip>
250
+ <Chip disabled onRequestRemove={() => {}}>
251
+ Disabled
252
+ </Chip>
253
+ </Layout>
254
+ );
255
+ }
256
+
257
+ export default Disabled;
258
+ ```
259
+
260
+
261
+
262
+
263
+ ## API
264
+
265
+
266
+ ### Chip API
267
+
268
+ #### Props
269
+
270
+ | Name | Type | Required | Default | Description |
271
+ |------|------|------|------|------|
272
+ | appearance | 'info' \| 'success' \| 'warning' \| 'error' \| 'outline' | no | | Sets the severity or type of this `Chip`. Setting this prop causes the `backgroundColor` prop to be ignored. |
273
+ | backgroundColor | string | no | | Changes the background color of the `Chip`. Hexadecimal colors and valid color names are allowed, such as `#ffffff` or `white`. If the `appearance` prop is set, this prop is ignored. |
274
+ | children | React.ReactNode | yes | | |
275
+ | disabled | boolean | no | | Disables the `Chip`. |
276
+ | elementRef | React.Ref<HTMLButtonElement \| HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
277
+ | foregroundColor | string | no | | Changes the text and icon color of the `Chip`. Hexadecimal colors and valid color names are allowed, such as `#ffffff` or `white`. |
278
+ | icon | React.ReactNode | no | | The icon to show before the label. See the Icon component for more information. |
279
+ | onRequestRemove | ChipRequestRemoveHandler | no | | Includes a remove button if callback is set. |
280
+ | value | any | no | | Includes this value in `onRequestRemove` callbacks. |
281
+
282
+ #### Types
283
+
284
+ | Name | Type | Description |
285
+ |------|------|------|
286
+ | ChipRequestRemoveHandler | ( event: React.MouseEvent<HTMLButtonElement>, data: { value?: any } // eslint-disable-line @typescript-eslint/no-explicit-any ) => void | |
287
+
288
+
289
+
290
+
291
+
@@ -0,0 +1,160 @@
1
+ # Clickable
2
+
3
+ ## Examples
4
+
5
+
6
+ ### Basic
7
+
8
+ ```typescript
9
+ import React from 'react';
10
+
11
+ import Clickable from '@splunk/react-ui/Clickable';
12
+
13
+ // eslint-disable-next-line no-alert
14
+
15
+ const handleOnClick = () => window.alert('You clicked me');
16
+
17
+ function Basic() {
18
+ return (
19
+ <>
20
+ <Clickable onClick={handleOnClick}>Alert Button</Clickable>
21
+ <br />
22
+ <br />
23
+ <Clickable to="Select">Link to Select component</Clickable>
24
+ <br />
25
+ <br />
26
+ <Clickable to="Select" disabled>
27
+ Disabled link to Select component
28
+ </Clickable>
29
+ <br />
30
+ <br />
31
+ <Clickable to="http://duckduckgo.com" openInNewContext>
32
+ External Link (new tab/window)
33
+ </Clickable>
34
+ </>
35
+ );
36
+ }
37
+
38
+ export default Basic;
39
+ ```
40
+
41
+
42
+
43
+ ### Disabled
44
+
45
+ Prevents user from activating the component and adds disabled styling. If set to dimmed, the component is able to receive focus. If set to disabled, the component is unable to receive focus (as a result of setting the html disabled attribute). The default behavior when disabled={true} is "dimmed".
46
+
47
+ ```typescript
48
+ import React from 'react';
49
+
50
+ import Clickable from '@splunk/react-ui/Clickable';
51
+
52
+
53
+ function Disabled() {
54
+ return (
55
+ <>
56
+ <Clickable to="Select" disabled>
57
+ Select component
58
+ </Clickable>
59
+ <br />
60
+ <Clickable to="Select" disabled="disabled">
61
+ Select component
62
+ </Clickable>
63
+ </>
64
+ );
65
+ }
66
+
67
+ export default Disabled;
68
+ ```
69
+
70
+
71
+
72
+ ### NavigationProvider
73
+
74
+ ```typescript
75
+ import React from 'react';
76
+
77
+ import Clickable, {
78
+ isInternalLink,
79
+ NavigationProvider,
80
+ NavigationProviderClickHandler,
81
+ } from '@splunk/react-ui/Clickable';
82
+
83
+
84
+ const handleClick: NavigationProviderClickHandler = (e, { openInNewContext, to }) => {
85
+ if (!openInNewContext && isInternalLink(to)) {
86
+ e.preventDefault();
87
+ window.alert(`In NavigationProvider click handler, to: ${to}`); // eslint-disable-line no-alert
88
+ }
89
+ };
90
+
91
+ function NavigationProviderExample() {
92
+ return (
93
+ <NavigationProvider onClick={handleClick}>
94
+ <Clickable to="Select">Link to Select component</Clickable>
95
+ <br />
96
+ <br />
97
+ <Clickable to="Select" openInNewContext>
98
+ Link to Select component (new tab/window)
99
+ </Clickable>
100
+ <br />
101
+ <br />
102
+ <Clickable to="http://duckduckgo.com" openInNewContext>
103
+ External Link (new tab/window)
104
+ </Clickable>
105
+ </NavigationProvider>
106
+ );
107
+ }
108
+
109
+ export default NavigationProviderExample;
110
+ ```
111
+
112
+
113
+
114
+
115
+ ## API
116
+
117
+
118
+ ### Clickable API
119
+
120
+ `Clickable` renders as a `button` element, or as an `a` element if the `to` prop is set
121
+ and the `disabled` prop is `false`. This is called link mode.
122
+
123
+ #### Props
124
+
125
+ | Name | Type | Required | Default | Description |
126
+ |------|------|------|------|------|
127
+ | children | React.ReactNode | no | | |
128
+ | disabled | boolean \| 'dimmed' \| 'disabled' | no | | Prevents user from activating the component and adds disabled styling. If set to `dimmed`, the component is able to receive focus. If set to `disabled`, the component is unable to receive focus (as a result of setting the html `disabled` attribute). The default behavior when `disabled={true}` is `dimmed`. |
129
+ | elementRef | React.Ref<HTMLButtonElement \| HTMLAnchorElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. `HTMLAnchorElement` in link mode, `HTMLButtonElement` otherwise. |
130
+ | navigationLabel | string | no | | The text representation of the navigational link. This should be provided if child content is not a string. Ignored if not in link mode. |
131
+ | onClick | React.MouseEventHandler<HTMLButtonElement \| HTMLAnchorElement> | no | | The onClick event handler is ignored if Ctrl or meta keys are pressed, which allows the link to open in a new context. |
132
+ | openInNewContext | boolean | no | | To open the link in a new window, set openInNewContext to `true`. Ignored if not in link mode. |
133
+ | to | string | no | | A URL for a link. If set, an `a` element is used instead of a `button` element (link mode). |
134
+
135
+
136
+
137
+ ### NavigationProvider API
138
+
139
+ Used to provide an override for the `onClick` for links for single page applications so that
140
+ internal links can navigate without a page reload.
141
+
142
+ #### Props
143
+
144
+ | Name | Type | Required | Default | Description |
145
+ |------|------|------|------|------|
146
+ | children | React.ReactNode | no | | |
147
+ | onClick | NavigationProviderClickHandler | no | | An `onClick` handler to use when a link is clicked if no other `onClick` handler is supplied. The function takes the event and an options argument with `to` and `openInNewContext` |
148
+ | onLinkClick | NavigationProviderClickHandler | no | | Triggers when a link is clicked, even if the link has its own `onClick` handler. The function takes the event and an options argument with `to` and `openInNewContext` |
149
+ | transformUrl | ( url: string, data: { isInternal?: boolean; isRootRelative?: boolean; } ) => string | no | | If set, all links that use the NavigationProvider's context will be transformed using this function. |
150
+
151
+ #### Types
152
+
153
+ | Name | Type | Description |
154
+ |------|------|------|
155
+ | NavigationProviderClickHandler | ( event: React.MouseEvent<HTMLAnchorElement>, data: { openInNewContext?: boolean; to: string; originalTo: string; label?: string; } ) => void | |
156
+
157
+
158
+
159
+
160
+