@czi-sds/mcp 0.16.0 → 0.18.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/README.md +2 -1
- package/data/component-docs/Accordion.md +291 -0
- package/data/component-docs/Autocomplete.md +525 -0
- package/data/component-docs/Banner.md +231 -0
- package/data/component-docs/Button.md +224 -0
- package/data/component-docs/ButtonDropdown.md +256 -0
- package/data/component-docs/ButtonGroup.md +320 -0
- package/data/component-docs/ButtonToggle.md +397 -0
- package/data/component-docs/Callout.md +268 -0
- package/data/component-docs/CellBasic.md +122 -0
- package/data/component-docs/CellComponent.md +63 -0
- package/data/component-docs/CellHeader.md +128 -0
- package/data/component-docs/ComplexFilter.md +294 -0
- package/data/component-docs/ContentCard.md +406 -0
- package/data/component-docs/Dialog.md +651 -0
- package/data/component-docs/Dropdown.md +155 -0
- package/data/component-docs/DropdownMenu.md +949 -0
- package/data/component-docs/HeatmapChart.md +782 -0
- package/data/component-docs/Hero.md +363 -0
- package/data/component-docs/Icon.md +283 -0
- package/data/component-docs/InputCheckbox.md +205 -0
- package/data/component-docs/InputDropdown.md +482 -0
- package/data/component-docs/InputRadio.md +173 -0
- package/data/component-docs/InputSearch.md +81 -0
- package/data/component-docs/InputSlider.md +189 -0
- package/data/component-docs/InputText.md +110 -0
- package/data/component-docs/InputToggle.md +141 -0
- package/data/component-docs/IntentMessage.md +293 -0
- package/data/component-docs/Legend.md +442 -0
- package/data/component-docs/Link.md +23 -0
- package/data/component-docs/List.md +300 -0
- package/data/component-docs/LoadingIndicator.md +198 -0
- package/data/component-docs/Menu.md +298 -0
- package/data/component-docs/MenuItem.md +100 -0
- package/data/component-docs/NavigationFooter.md +165 -0
- package/data/component-docs/NavigationHeader.md +500 -0
- package/data/component-docs/NavigationJumpTo.md +414 -0
- package/data/component-docs/Notification.md +288 -0
- package/data/component-docs/Pagination.md +67 -0
- package/data/component-docs/Panel.md +636 -0
- package/data/component-docs/Popover.md +448 -0
- package/data/component-docs/PreComposedTable.md +2947 -0
- package/data/component-docs/ProteinStructureViewer.md +1044 -0
- package/data/component-docs/SegmentedControl.md +396 -0
- package/data/component-docs/StackedBarChart.md +475 -0
- package/data/component-docs/Table.md +2000 -0
- package/data/component-docs/TableHeader.md +53 -0
- package/data/component-docs/TableRow.md +74 -0
- package/data/component-docs/Tabs.md +455 -0
- package/data/component-docs/Tag.md +647 -0
- package/data/component-docs/TagFilter.md +131 -0
- package/data/component-docs/Tooltip.md +561 -0
- package/data/component-docs/TooltipCondensed.md +203 -0
- package/data/component-docs/TooltipTable.md +145 -0
- package/data/component-docs/index.json +267 -0
- package/data/component-list.json +2 -5
- package/data/component-props/Accordion.json +31 -11
- package/data/component-props/Alert.json +3 -3
- package/data/component-props/Autocomplete.json +150 -15
- package/data/component-props/Banner.json +31 -17
- package/data/component-props/Button.json +45 -20
- package/data/component-props/ButtonDropdown.json +36 -17
- package/data/component-props/ButtonDropdownLegacy.json +11 -11
- package/data/component-props/ButtonGroup.json +32 -11
- package/data/component-props/ButtonIcon.json +10 -10
- package/data/component-props/ButtonLegacy.json +19 -19
- package/data/component-props/ButtonToggle.json +32 -19
- package/data/component-props/ButtonToggleLegacy.json +11 -11
- package/data/component-props/Callout.json +58 -17
- package/data/component-props/CellBasic.json +94 -41
- package/data/component-props/CellComponent.json +23 -7
- package/data/component-props/CellHeader.json +62 -19
- package/data/component-props/ComplexFilter.json +52 -21
- package/data/component-props/ContentCard.json +70 -47
- package/data/component-props/Dialog.json +47 -14
- package/data/component-props/Dropdown.json +68 -31
- package/data/component-props/DropdownMenu.json +128 -23
- package/data/component-props/HeatmapChart.json +88 -12
- package/data/component-props/Hero.json +80 -39
- package/data/component-props/Icon.json +20 -9
- package/data/component-props/InputCheckbox.json +36 -14
- package/data/component-props/InputDropdown.json +75 -27
- package/data/component-props/InputRadio.json +31 -13
- package/data/component-props/InputSearch.json +41 -18
- package/data/component-props/InputSlider.json +46 -19
- package/data/component-props/InputText.json +26 -19
- package/data/component-props/InputToggle.json +26 -9
- package/data/component-props/IntentMessage.json +38 -9
- package/data/component-props/Link.json +13 -7
- package/data/component-props/LoadingIndicator.json +11 -3
- package/data/component-props/MenuItem.json +38 -19
- package/data/component-props/MenuSelect.json +8 -8
- package/data/component-props/NavigationFooter.json +49 -19
- package/data/component-props/NavigationHeader.json +150 -37
- package/data/component-props/NavigationJumpTo.json +33 -7
- package/data/component-props/Notification.json +39 -21
- package/data/component-props/Pagination.json +39 -11
- package/data/component-props/Panel.json +62 -9
- package/data/component-props/Popover.json +80 -7
- package/data/component-props/PreComposedTable.json +99 -27
- package/data/component-props/ProteinStructureViewer.json +117 -0
- package/data/component-props/SegmentedControl.json +42 -3
- package/data/component-props/StackedBarChart.json +116 -42
- package/data/component-props/TableRow.json +38 -19
- package/data/component-props/Tabs.json +66 -9
- package/data/component-props/Tag.json +34 -17
- package/data/component-props/TagFilter.json +10 -3
- package/data/component-props/Tooltip.json +49 -18
- package/data/component-props/TooltipCondensed.json +18 -9
- package/data/component-props/TooltipTable.json +17 -7
- package/data/resources/{zeroheight-rules.md → documentation-rules.md} +43 -30
- package/data/resources/figma-rules.md +2 -2
- package/data/tailwind.json +20 -14
- package/dist/stdio.js +112 -208
- package/package.json +9 -5
- package/data/component-props/ButtonDropdownV2.json +0 -34
- package/data/component-props/ButtonNew.json +0 -47
- package/data/component-props/ButtonToggleV2.json +0 -44
- package/data/component-props/ButtonV2.json +0 -43
- package/data/zeroheight-cache.json +0 -10259
- package/data/zeroheight-exports/Accordion.md +0 -774
- package/data/zeroheight-exports/Banner.md +0 -691
- package/data/zeroheight-exports/Borders.md +0 -117
- package/data/zeroheight-exports/Buttons.md +0 -1854
- package/data/zeroheight-exports/Callout.md +0 -931
- package/data/zeroheight-exports/Colors.md +0 -1755
- package/data/zeroheight-exports/Content-Card.md +0 -309
- package/data/zeroheight-exports/Contributing-to-SDS.md +0 -98
- package/data/zeroheight-exports/Control-Inputs.md +0 -2818
- package/data/zeroheight-exports/Corners.md +0 -104
- package/data/zeroheight-exports/Cover-page.md +0 -3
- package/data/zeroheight-exports/Dialog.md +0 -1367
- package/data/zeroheight-exports/Downloads.md +0 -236
- package/data/zeroheight-exports/Drop-Shadows.md +0 -79
- package/data/zeroheight-exports/Dropdown-Input.md +0 -1776
- package/data/zeroheight-exports/Dropdown-Menus.md +0 -913
- package/data/zeroheight-exports/Element-Status-Tracker.md +0 -267
- package/data/zeroheight-exports/Field-Inputs.md +0 -1405
- package/data/zeroheight-exports/Filters.md +0 -1111
- package/data/zeroheight-exports/Getting-Started.md +0 -1157
- package/data/zeroheight-exports/Hero.md +0 -414
- package/data/zeroheight-exports/Icons.md +0 -2067
- package/data/zeroheight-exports/Intent.md +0 -86
- package/data/zeroheight-exports/Introduction-to-Bases.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Cells.md +0 -35
- package/data/zeroheight-exports/Introduction-to-DNA.md +0 -35
- package/data/zeroheight-exports/Introduction-to-Genes.md +0 -35
- package/data/zeroheight-exports/Introduction.md +0 -115
- package/data/zeroheight-exports/Link.md +0 -432
- package/data/zeroheight-exports/Lists.md +0 -986
- package/data/zeroheight-exports/Loading-Indicator.md +0 -41
- package/data/zeroheight-exports/Navigation.md +0 -1190
- package/data/zeroheight-exports/Notification.md +0 -1038
- package/data/zeroheight-exports/Panel.md +0 -1030
- package/data/zeroheight-exports/README.md +0 -122
- package/data/zeroheight-exports/Responsive-Design.md +0 -330
- package/data/zeroheight-exports/Search-Input.md +0 -91
- package/data/zeroheight-exports/Search.md +0 -822
- package/data/zeroheight-exports/Segmented-Control.md +0 -609
- package/data/zeroheight-exports/Spacing.md +0 -297
- package/data/zeroheight-exports/Table.md +0 -5345
- package/data/zeroheight-exports/Tabs.md +0 -1324
- package/data/zeroheight-exports/Tags.md +0 -1545
- package/data/zeroheight-exports/Text-Link.md +0 -268
- package/data/zeroheight-exports/Theming.md +0 -362
- package/data/zeroheight-exports/Tooltips.md +0 -2015
- package/data/zeroheight-exports/Typography.md +0 -800
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# InputSearch
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/InputSearch/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { InputSearch } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default InputSearch**
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the InputSearch component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultInputSearch**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { InputSearch } from "@czi-sds/components";
|
|
25
|
+
import { Box } from "@mui/material";
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
return (
|
|
29
|
+
<div className="app">
|
|
30
|
+
<Box sx={{ width: 300 }}>
|
|
31
|
+
<InputSearch id="search-input" label="search" placeholder="Search" />
|
|
32
|
+
</Box>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default App;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## SDS vs MUI
|
|
41
|
+
|
|
42
|
+
SDS's InputSearch is built on MUI's TextField component, with `type="search"`. It also has the SDS "search" icon automatically included, aligned to the right end of the field.
|
|
43
|
+
|
|
44
|
+
The following props are available to MUI's TextField component, but do not work the same way (or at all) for SDS's InputSearch component:
|
|
45
|
+
|
|
46
|
+
- `variants`: SDS's InputSearch component is not set up to support values for this prop (aside from `"outlined"`, InputSearch default), and using other values available to MUI (`"filled"`, `"standard"`) may result in unreliable outputs
|
|
47
|
+
|
|
48
|
+
- `size`: SDS's InputSearch component is not set up to support values for this prop (aside from `"small"`, InputText's default), and using other values available to MUI (`"medium"`, `"large"`) may not have reliable outputs
|
|
49
|
+
|
|
50
|
+
- `required`: SDS's InputSearch does not render the expected asterisk (\*) following the label when this prop is `true`
|
|
51
|
+
|
|
52
|
+
- `select`: SDS's InputSearch is not set up to support this boolean prop
|
|
53
|
+
|
|
54
|
+
- `hiddenLabel`: The label (`"Search"`, by default) for SDS's component is included within the search field, not outside of it, and the MUI `hiddenLabel` prop will not hide the label
|
|
55
|
+
|
|
56
|
+
The following functionality is available to both MUI's TextField component and SDS's InputText component, but SDS uses different prop names, shown below:
|
|
57
|
+
|
|
58
|
+
- `intent`: This prop is the way you can set colors for SDS's InputText, based on its error state. It takes default (default, gray), error, or warning as values. The related MUI-color-setting prop, `color`, has no effect for InputText in SDS.
|
|
59
|
+
|
|
60
|
+
SDS's InputSearch has an additional `sdsStyle` prop to help with setting SDS-specific styles, which takes `"square"` (default) or `"rounded"` as values.
|
|
61
|
+
|
|
62
|
+
## MUI Documentation
|
|
63
|
+
|
|
64
|
+
Documentation for the underlying MUI TextField component can be found [here](https://mui.com/material-ui/react-text-field/).
|
|
65
|
+
|
|
66
|
+
## Props
|
|
67
|
+
|
|
68
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
69
|
+
|
|
70
|
+
| Name | Type | Default | Description |
|
|
71
|
+
| -------------- | --------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
72
|
+
| `classes` | `object` | `{}` | Class names for the internal elements: `root`, `label`, `input`, `endAdornment`, `startAdornment`, `clearButton`, and `searchButton`. |
|
|
73
|
+
| `disabled` | `boolean` | `false` | When set to `true`, the component becomes disabled and cannot be interacted with. |
|
|
74
|
+
| `handleSubmit` | `function` | `function(value: string) => void` | This function is called when the Search icon is clicked, allowing user to handle the search operation. |
|
|
75
|
+
| `id` | `string` | - | Specifies the unique id for the input element, needed for accessibility. |
|
|
76
|
+
| `intent` | `"default"` \| `"negative"` \| `"notice"` \| `"positive"` | `"default"` | Alters the border color and visual intent of the search input. |
|
|
77
|
+
| `label` | `string` | - | Although hidden, this label is provided for accessibility purposes. |
|
|
78
|
+
| `onChange` | `function` | `function(event: React.ChangeEvent) => void` | Defines the action to be taken when the input value changes. |
|
|
79
|
+
| `placeholder` | `string` | `"Search"` | Sets the placeholder text displayed within the input element. |
|
|
80
|
+
| `sdsStyle` | `"rounded"` \| `"square"` | `"square"` | Determines the visual style of the component, with options for rounded or square design. |
|
|
81
|
+
| `value` | `string` | - | The value of the `input` element, required for a controlled component. |
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# InputSlider
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/InputSlider/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { InputSlider } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default InputSlider**
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the InputSlider component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultInputSlider**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { InputSlider } from "@czi-sds/components";
|
|
25
|
+
import { Box } from "@mui/material";
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
return (
|
|
29
|
+
<div className="app">
|
|
30
|
+
<Box sx={{ width: 200 }}>
|
|
31
|
+
<InputSlider aria-label="Label" defaultValue={50} />
|
|
32
|
+
</Box>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default App;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### InputSlider with custom Marks
|
|
41
|
+
|
|
42
|
+
This example shows an InputSlider component that features custom marks precisely positioned at 0%, 50%, and 100% of the slider's value.
|
|
43
|
+
|
|
44
|
+
**Example: InputSliderWithCustomMarks**
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { InputSlider } from "@czi-sds/components";
|
|
48
|
+
import { Box } from "@mui/material";
|
|
49
|
+
|
|
50
|
+
const generateCustomMarks = (min: number, max: number) => {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
label: min,
|
|
54
|
+
value: min,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: ((max - min) / 2 + min).toFixed(0),
|
|
58
|
+
value: (max - min) / 2 + min,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: max,
|
|
62
|
+
value: max,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function App() {
|
|
68
|
+
return (
|
|
69
|
+
<div className="app">
|
|
70
|
+
<Box sx={{ width: 200 }}>
|
|
71
|
+
<InputSlider
|
|
72
|
+
aria-label="Label"
|
|
73
|
+
defaultValue={50}
|
|
74
|
+
marks={generateCustomMarks(0, 100)}
|
|
75
|
+
min={0}
|
|
76
|
+
max={100}
|
|
77
|
+
step={5}
|
|
78
|
+
valueLabelDisplay="on"
|
|
79
|
+
/>
|
|
80
|
+
</Box>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default App;
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Range InputSlider
|
|
89
|
+
|
|
90
|
+
Passing an array of two numbers renders a range with a thumb at each end.
|
|
91
|
+
|
|
92
|
+
**Example: RangeInputSlider**
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
// An array value turns the slider into a range with two thumbs, which the
|
|
96
|
+
// component labels "Minimum value" and "Maximum value" for screen readers.
|
|
97
|
+
import { InputSlider } from "@czi-sds/components";
|
|
98
|
+
import { Box } from "@mui/material";
|
|
99
|
+
|
|
100
|
+
function App() {
|
|
101
|
+
return (
|
|
102
|
+
<div className="app">
|
|
103
|
+
<Box sx={{ width: 200 }}>
|
|
104
|
+
<InputSlider
|
|
105
|
+
defaultValue={[15, 85]}
|
|
106
|
+
min={0}
|
|
107
|
+
max={100}
|
|
108
|
+
step={5}
|
|
109
|
+
valueLabelDisplay="on"
|
|
110
|
+
/>
|
|
111
|
+
</Box>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default App;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Disabled InputSlider
|
|
120
|
+
|
|
121
|
+
A disabled slider dims the track, thumb, marks, and value label, and ignores pointer and keyboard input.
|
|
122
|
+
|
|
123
|
+
**Example: DisabledInputSlider**
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { InputSlider } from "@czi-sds/components";
|
|
127
|
+
import { Box } from "@mui/material";
|
|
128
|
+
|
|
129
|
+
function App() {
|
|
130
|
+
return (
|
|
131
|
+
<div className="app">
|
|
132
|
+
<Box sx={{ width: 200 }}>
|
|
133
|
+
<InputSlider
|
|
134
|
+
aria-label="Label"
|
|
135
|
+
defaultValue={40}
|
|
136
|
+
marks
|
|
137
|
+
step={20}
|
|
138
|
+
valueLabelDisplay="on"
|
|
139
|
+
disabled
|
|
140
|
+
/>
|
|
141
|
+
</Box>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default App;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## SDS vs MUI
|
|
150
|
+
|
|
151
|
+
The following props and options differ in how they function across MUI's Slider component versus SDS's InputSlider component:
|
|
152
|
+
|
|
153
|
+
- `orientation`: Has no effect in SDS. The component always renders horizontally, and overrides anything you pass.
|
|
154
|
+
|
|
155
|
+
- `size` and `color`: Have no effect in SDS. The rail, track, and thumb are styled from the theme.
|
|
156
|
+
|
|
157
|
+
- `aria-label` and `getAriaLabel`: SDS labels the thumbs for you. A range slider gets `"Minimum value"` and `"Maximum value"`; a single-thumb slider uses your `aria-label`, falling back to `"Slider value"`. Pass `getAriaLabel` to take over completely.
|
|
158
|
+
|
|
159
|
+
These are some of the common props that can be used for both the MUI Slider component and the SDS InputSlider component:
|
|
160
|
+
|
|
161
|
+
- `value` and `defaultValue`: A number renders one thumb. An array of two numbers renders a range with two thumbs, as in the "Range InputSlider" example below.
|
|
162
|
+
|
|
163
|
+
- `step`: Sets the step distance between selectable stops (and relatedly, if this prop is left out, the slider is continuous, rather than discrete)
|
|
164
|
+
|
|
165
|
+
- `marks`: When present and set to `true`, invokes the default marks style. When passed a rich array (of objects containing the value and the custom label to show at that value), sets marks and labels only at the positions specified by the array. See the "InputSlider with custom Marks" example below.
|
|
166
|
+
|
|
167
|
+
- `valueLabelDisplay`: This prop determines whether and when the value label is displayed, and takes the following props: `"auto"` (the value label will display when the thumb is hovered or focused), `"on"` (labels display persistently), or `"off"` (default; labels are never displayed).
|
|
168
|
+
|
|
169
|
+
## MUI Documentation
|
|
170
|
+
|
|
171
|
+
Documentation for the underlying MUI component can be found [here](https://mui.com/material-ui/react-slider/).
|
|
172
|
+
|
|
173
|
+
## Props
|
|
174
|
+
|
|
175
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
176
|
+
|
|
177
|
+
| Name | Type | Default | Description |
|
|
178
|
+
| ------------------- | ------------------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
179
|
+
| `defaultValue` | `Array<number> \| number` | - | The default value. Use when the component is not controlled. An array of two numbers renders a range slider. |
|
|
180
|
+
| `value` | `Array<number> \| number` | - | The value of the slider. Use with `onChange` to control the component. |
|
|
181
|
+
| `onChange` | `(event, value, activeThumb) => void` | - | Called as the user drags a thumb. |
|
|
182
|
+
| `disabled` | `boolean` | `false` | If `true`, the component is disabled. |
|
|
183
|
+
| `marks` | `bool \| Array<{ value, label }>` | `false` | Marks indicate predetermined values to which the user can move the slider. If `true` the marks are spaced according the value of the `step` prop. If an array, it should contain objects with `value` and an optional `label` keys. |
|
|
184
|
+
| `max` | `number` | `100` | The maximum allowed value of the slider. Should not be equal to `min`. |
|
|
185
|
+
| `min` | `number` | `0` | The minimum allowed value of the slider. Should not be equal to `max`. |
|
|
186
|
+
| `orientation` | `"horizontal"` | `"horizontal"` | Fixed by SDS. The component sets this itself, so a vertical slider is not available. |
|
|
187
|
+
| `step` | `number` | `1` | The granularity with which the slider can step through values. (A "discrete" slider.) The `min` prop serves as the origin for the valid values. We recommend `(max - min)` to be evenly divisible by the `step`. When `step` is `null`, the thumb can only be slid onto marks provided with the `marks` prop. |
|
|
188
|
+
| `valueLabelDisplay` | `"auto"` \| `"off"` \| `"on"` | `"off"` | Controls when the value label is displayed: - `"auto"` the value label will display when the thumb is hovered or focused. - `"on"` will display persistently. - `"off"` will never display. |
|
|
189
|
+
| `aria-label` | `string` | `"Slider value"` | Labels the thumb of a single-value slider. Range sliders label their two thumbs `"Minimum value"` and `"Maximum value"` instead. |
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# InputText
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/InputText/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { InputText } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **InputText – Text Field**
|
|
18
|
+
|
|
19
|
+
This component represents the text field variant of the InputText component.
|
|
20
|
+
|
|
21
|
+
**Example: InputTextTextField**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { InputText } from "@czi-sds/components";
|
|
25
|
+
import { Box } from "@mui/material";
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
return (
|
|
29
|
+
<div className="app">
|
|
30
|
+
<Box sx={{ width: 300 }}>
|
|
31
|
+
<InputText
|
|
32
|
+
id="search-input"
|
|
33
|
+
label="Label"
|
|
34
|
+
placeholder="Enter your text"
|
|
35
|
+
hideLabel
|
|
36
|
+
/>
|
|
37
|
+
</Box>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default App;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### InputText – Text Area
|
|
46
|
+
|
|
47
|
+
This component represents the text area variant of the InputText component.
|
|
48
|
+
|
|
49
|
+
**Example: InputTextTextArea**
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { InputText } from "@czi-sds/components";
|
|
53
|
+
import { Box } from "@mui/material";
|
|
54
|
+
|
|
55
|
+
function App() {
|
|
56
|
+
return (
|
|
57
|
+
<div className="app">
|
|
58
|
+
<Box sx={{ width: 300 }}>
|
|
59
|
+
<InputText
|
|
60
|
+
id="search-input"
|
|
61
|
+
label="Description"
|
|
62
|
+
placeholder="Enter your text"
|
|
63
|
+
sdsType="textArea"
|
|
64
|
+
/>
|
|
65
|
+
</Box>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default App;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## SDS vs MUI
|
|
74
|
+
|
|
75
|
+
Like SDS's InputSearch (which is also built upon the same MUI component), the following props and options do not work the same way (or at all) for SDS's InputText component even though they are available to MUI's TextField component.
|
|
76
|
+
|
|
77
|
+
- `variants`: SDS's InputText component is not set up to support values for this prop (aside from `"outlined"`, InputText's default), and using other values available to MUI (`"filled"`, `"standard"`) may result in unreliable outputs
|
|
78
|
+
|
|
79
|
+
- `size`: SDS's InputText component is not set up to support values for this prop (aside from `"small"`, InputText's default), and using other values available to MUI (`"medium"`, `"large"`) may not have reliable outputs
|
|
80
|
+
|
|
81
|
+
- `required`: SDS's InputText does not render the expected asterisk (\*) following the label when this prop is `true`
|
|
82
|
+
|
|
83
|
+
- `select`: SDS's InputText is not set up to support this boolean prop
|
|
84
|
+
|
|
85
|
+
The following functionality is available to both MUI's TextField component and SDS's InputText component, but SDS uses different prop names, shown below:
|
|
86
|
+
|
|
87
|
+
- `sdsType`: This is the SDS-equivalent of MUI's boolean `multiline` prop, and takes `"textField"` (default) or `"textArea"` as values
|
|
88
|
+
|
|
89
|
+
- `hideLabel`: This is the SDS-equivalent of the `hiddenLabel` prop used in MUI; both are boolean with the default not including them (value of `false`)
|
|
90
|
+
|
|
91
|
+
- `intent`: This prop is the way you can set colors for SDS's InputText, based on its error state. It takes default (default, gray), error, or warning as values. The related MUI-color-setting prop, `color`, has no effect for InputText in SDS.
|
|
92
|
+
|
|
93
|
+
## MUI Documentation
|
|
94
|
+
|
|
95
|
+
Documentation for the underlying MUI TextFieldcomponent can be found [here](https://mui.com/material-ui/react-text-field/).
|
|
96
|
+
|
|
97
|
+
## Props
|
|
98
|
+
|
|
99
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
100
|
+
|
|
101
|
+
| Name | Type | Default | Description |
|
|
102
|
+
| ------------- | --------------------------------------------------------- | ------------- | ------------------------------------------------------------------------------------ |
|
|
103
|
+
| `classes` | `object` | `{}` | Class names for the internal elements: `root`, `label`, and `input`. |
|
|
104
|
+
| `disabled` | `boolean` | `false` | When set to `true`, the component becomes disabled and cannot be interacted with. |
|
|
105
|
+
| `hideLabel` | `boolean` | `false` | If `true`, the label is hidden. |
|
|
106
|
+
| `id` | `string` | - | Specifies the unique id for the input element, needed for accessibility. |
|
|
107
|
+
| `intent` | `"default"` \| `"negative"` \| `"notice"` \| `"positive"` | `"default"` | Alters the border color and visual intent of the search input. |
|
|
108
|
+
| `label` | `string` | - | The label for the input element. |
|
|
109
|
+
| `placeholder` | `string` | - | Sets the placeholder text displayed within the input element. |
|
|
110
|
+
| `sdsType` | `"textField"` \| `"textArea"` | `"textField"` | Defines the type of component to render, with options for a text input or text area. |
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# InputToggle
|
|
2
|
+
|
|
3
|
+
## Source Code
|
|
4
|
+
|
|
5
|
+
The component's source code in the SDS codebase can be found [here](https://github.com/chanzuckerberg/sci-components/blob/main/packages/components/src/core/InputToggle/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { InputToggle } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default InputToggle**
|
|
18
|
+
|
|
19
|
+
This example has the minimum props needed for the InputToggle component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultInputToggle**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { InputToggle } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<InputToggle />
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default App;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### **InputToggle with customized on and off labels**
|
|
38
|
+
|
|
39
|
+
This example shows an InputToggle component with customized on and off labels, widened to fit them.
|
|
40
|
+
|
|
41
|
+
**Example: InputToggleWithCustomizedOnAndOffLabels**
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { InputToggle } from "@czi-sds/components";
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<div className="app">
|
|
49
|
+
<InputToggle onLabel="Start" offLabel="Finish" width={72} />
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default App;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### **Controlled InputToggle**
|
|
58
|
+
|
|
59
|
+
Passing `checked` hands control of the toggle to your application, which then updates it from the `onChange` handler.
|
|
60
|
+
|
|
61
|
+
**Example: ControlledInputToggle**
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// Passing `checked` makes the toggle controlled; without it the component
|
|
65
|
+
// tracks its own state.
|
|
66
|
+
import { useState } from "react";
|
|
67
|
+
import { InputToggle } from "@czi-sds/components";
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
const [checked, setChecked] = useState(true);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
className="app"
|
|
75
|
+
style={{ alignItems: "center", display: "flex", gap: "16px" }}
|
|
76
|
+
>
|
|
77
|
+
<InputToggle
|
|
78
|
+
checked={checked}
|
|
79
|
+
onChange={() => setChecked((previous) => !previous)}
|
|
80
|
+
/>
|
|
81
|
+
<span>Notifications are {checked ? "on" : "off"}</span>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default App;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### **Disabled InputToggle**
|
|
90
|
+
|
|
91
|
+
This example shows a disabled InputToggle in both its off and on states.
|
|
92
|
+
|
|
93
|
+
**Example: DisabledInputToggle**
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
import { InputToggle } from "@czi-sds/components";
|
|
97
|
+
|
|
98
|
+
function App() {
|
|
99
|
+
return (
|
|
100
|
+
<div className="app" style={{ display: "flex", gap: "16px" }}>
|
|
101
|
+
<InputToggle disabled />
|
|
102
|
+
<InputToggle checked disabled />
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default App;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## SDS vs MUI
|
|
111
|
+
|
|
112
|
+
The following props and options differ and how they function across the MUI Switch component and the SDS InputToggle component:
|
|
113
|
+
|
|
114
|
+
- `size`: Has no effect in SDS
|
|
115
|
+
|
|
116
|
+
- `color`: Has no effect in SDS
|
|
117
|
+
|
|
118
|
+
- `onLabel` and `offLabel`: These are SDS-specific props. The toggle prints one of them inside the track depending on its state, which is why it is wider than a MUI Switch. Longer words may need a larger `width`.
|
|
119
|
+
|
|
120
|
+
- `value`: Managed by SDS. The component sets it to the active label so the track can render that text, so passing your own `value` replaces the visible on/off text.
|
|
121
|
+
|
|
122
|
+
- `checked`: Optional. Without it the toggle keeps its own state; pass it (with `onChange`) to control the toggle from your application.
|
|
123
|
+
|
|
124
|
+
- The `required` prop is available for both the MUI and SDS components.
|
|
125
|
+
|
|
126
|
+
## MUI Documentation
|
|
127
|
+
|
|
128
|
+
Documentation for the underlying MUI component can be found [here](https://mui.com/material-ui/react-switch/).
|
|
129
|
+
|
|
130
|
+
## Props
|
|
131
|
+
|
|
132
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
133
|
+
|
|
134
|
+
| Name | Type | Default | Description |
|
|
135
|
+
| ---------- | ----------------- | ------- | ---------------------------------------------------------------------------------------------------- |
|
|
136
|
+
| `checked` | `boolean` | - | Controls the toggle. Omit it and the component tracks its own state internally. |
|
|
137
|
+
| `disabled` | `boolean` | `false` | If `true`, the component is disabled. |
|
|
138
|
+
| `offLabel` | `string` | `"Off"` | The text displayed within the InputToggle when it's off. |
|
|
139
|
+
| `onLabel` | `string` | `"On"` | The text displayed within the InputToggle when it's on. |
|
|
140
|
+
| `onChange` | `(event) => void` | - | Called whenever the user toggles the component, in either direction. |
|
|
141
|
+
| `width` | `number` | `62` | Controls the width of the InputToggle element, in pixels. Increase it when custom labels do not fit. |
|