@czi-sds/mcp 0.16.0 → 0.17.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/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 +262 -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/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/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,122 @@
|
|
|
1
|
+
# CellBasic
|
|
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/CellBasic/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { CellBasic } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### Default CellBasic
|
|
18
|
+
|
|
19
|
+
This example demonstrates the minimum required props for rendering a CellBasic component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultCellBasic**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { CellBasic } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<table>
|
|
30
|
+
<tbody>
|
|
31
|
+
<tr>
|
|
32
|
+
<CellBasic
|
|
33
|
+
primaryText="Primary Text"
|
|
34
|
+
secondaryText="Secondary Text"
|
|
35
|
+
/>
|
|
36
|
+
</tr>
|
|
37
|
+
</tbody>
|
|
38
|
+
</table>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default App;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
table {
|
|
48
|
+
border: dashed 1px #eee;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### CellBasic with Icon and Text Wrap
|
|
53
|
+
|
|
54
|
+
This example highlights a CellBasic component featuring an SDS icon and lengthy texts for Primary, Secondary, and Tertiary content, all thoughtfully wrapped for optimal presentation.
|
|
55
|
+
|
|
56
|
+
**Example: CellBasicWithIconAndTextWrap**
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { CellBasic, Icon } from "@czi-sds/components";
|
|
60
|
+
|
|
61
|
+
function App() {
|
|
62
|
+
const TableCellStyle = {
|
|
63
|
+
maxWidth: 160,
|
|
64
|
+
width: 160,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className="app">
|
|
69
|
+
<table>
|
|
70
|
+
<tbody>
|
|
71
|
+
<tr>
|
|
72
|
+
<CellBasic
|
|
73
|
+
primaryText="Primary Text that is longer than expected."
|
|
74
|
+
secondaryText="Secondary Text that is londer than expected."
|
|
75
|
+
tertiaryText="Tertiary Text that is lonegrt than expected."
|
|
76
|
+
icon={<Icon sdsIcon="Bacteria" sdsSize="l" color="yellow" />}
|
|
77
|
+
style={TableCellStyle}
|
|
78
|
+
tooltipProps={{
|
|
79
|
+
placement: "right",
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
</tr>
|
|
83
|
+
</tbody>
|
|
84
|
+
</table>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default App;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Props
|
|
93
|
+
|
|
94
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
95
|
+
|
|
96
|
+
| Name | Type | Default | Description |
|
|
97
|
+
| -------------------------------- | ----------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `as` | `React.ElementType` | `"td"` | The element the cell renders as. Use `"th"` for a row header cell inside `tbody`. |
|
|
99
|
+
| `extraRightPadding` | `number` | `0` | Extra pixels of right padding, added only when `horizontalAlign` is `"right"`. Useful for leaving room for a scrollbar or a pinned column edge. |
|
|
100
|
+
| `horizontalAlign` | `"left"` \| `"right"` | `"left"` | Horizontal alignment of cell content. There is no `"center"`. Use CellComponent if a cell needs centered content. |
|
|
101
|
+
| `icon` | `React.ReactElement<CustomSVGProps>` | - | Places an icon to the left of the cell text. Expects an SDS Icon or another SVG element. |
|
|
102
|
+
| `link` | `string` | - | Wraps the cell content in an anchor pointing here. The text keeps the cell's own color rather than link styling. |
|
|
103
|
+
| `linkComponent` | `React.ElementType` | - | The component the link renders as, for routers that supply their own link (React Router's Link, for example). |
|
|
104
|
+
| `linkProps` | `React.AnchorHTMLAttributes<HTMLAnchorElement>` | - | Props passed to the anchor rendered by `link`. |
|
|
105
|
+
| `iconVerticalAlign` | `"top"` \| `"center"` \| `"bottom"` | `"top"` | Vertical alignment of the icon component. |
|
|
106
|
+
| `primaryText` | `string` | - | Primary text value. |
|
|
107
|
+
| `primaryTextWrapLineCount` | `number` | `3` | Number of text wrap lines for primary text. |
|
|
108
|
+
| `primaryTextComponentSlotBottom` | `ReactNode` | `null` | Component slot below primary text. This will only show if there is no secondary or tertiary text. Remove the default values of secondary and tertiary text to see this in action. |
|
|
109
|
+
| `primaryTextComponentSlotRight` | `ReactNode` | `null` | Component slot to the right of primary text |
|
|
110
|
+
| `secondaryText` | `string` | - | Secondary Text. |
|
|
111
|
+
| `secondaryTextWrapLineCount` | `number` | `1` | Number of text wrap lines for secondary text. |
|
|
112
|
+
| `tertiaryText` | `string` | - | Tertiary Text. |
|
|
113
|
+
| `tertiaryTextWrapLineCount` | `number` | `1` | Number of text wrap lines for tertiary text. |
|
|
114
|
+
| `shouldShowTooltipOnHover` | `boolean` | `true` | When `true` the cell is wrapped in a Tooltip whose title is `primaryText` and whose subtitle is `secondaryText`. Turn it off for cells whose text is already fully visible, otherwise every cell in the table has a tooltip. |
|
|
115
|
+
| `shouldShowUnderlineOnHover` | `boolean` | `false` | Underlines `primaryText` on hover. Inside a PreComposedTable the underline also appears when any cell in the row is hovered. |
|
|
116
|
+
| `shouldTextWrap` | `boolean` | `true` | When `true`, each text clamps to its wrap line count. When `false`, text stays on one line and truncates with an ellipsis instead. |
|
|
117
|
+
| `tabularNums` | `boolean` | `false` | Renders digits at a fixed width so numbers line up column to column. Worth turning on for any numeric column. |
|
|
118
|
+
| `tooltipProps` | `Partial<TooltipProps>` | - | Passed to the Tooltip, and overrides the defaults the cell sets (title, subtitle, arrow, dark style, no leave delay). |
|
|
119
|
+
| `verticalAlign` | `"top"` \| `"center"` \| `"bottom"` | `"top"` | Vertical alignment of the cell content. |
|
|
120
|
+
| `width` | `string` \| `number` | - | Lands on the rendered cell as the HTML `width` attribute, so a number is read as pixels. Browsers treat it as the width of the whole column, and take it as a minimum rather than a promise. |
|
|
121
|
+
|
|
122
|
+
Anything else you pass, such as `colSpan`, `style` or a data attribute, lands on the rendered `td`.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CellComponent
|
|
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/CellComponent/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { CellComponent } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default CellComponent**
|
|
18
|
+
|
|
19
|
+
This example demonstrates the minimum required props for rendering a CellComponent component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultCellComponent**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { CellComponent, InputToggle } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<table>
|
|
30
|
+
<tbody>
|
|
31
|
+
<tr>
|
|
32
|
+
<CellComponent>
|
|
33
|
+
<InputToggle />
|
|
34
|
+
</CellComponent>
|
|
35
|
+
</tr>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default App;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
table {
|
|
47
|
+
border: dashed 1px #eee;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Props
|
|
52
|
+
|
|
53
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
54
|
+
|
|
55
|
+
| Name | Type | Default | Description |
|
|
56
|
+
| ----------------- | ----------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `as` | `React.ElementType` | `"td"` | The element the cell renders as. |
|
|
58
|
+
| `children` | `React.ReactNode` | - | The cell's content. Unlike CellBasic, which takes text through `primaryText`, this cell renders whatever you put inside it. |
|
|
59
|
+
| `horizontalAlign` | `"left"` \| `"center"` \| `"right"` | `"left"` | Specifies the horizontal alignment of the cell content. |
|
|
60
|
+
| `verticalAlign` | `"top"` \| `"center"` \| `"bottom"` | `"top"` | Specifies the vertical alignment of the cell content. |
|
|
61
|
+
| `width` | `string` \| `number` | - | Lands on the rendered cell as the HTML `width` attribute, so a number is read as pixels. Browsers treat it as the width of the whole column, and take it as a minimum rather than a promise. |
|
|
62
|
+
|
|
63
|
+
Anything else you pass, such as `colSpan`, `width`, `onClick` or a data attribute, lands on the rendered `td`. The cell also carries the class name `cell-component`, which TableRow uses to switch off pointer events inside a disabled row.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# CellHeader
|
|
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/CellHeader/index.tsx).
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
**React TypeScript**
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { CellHeader } from "@czi-sds/components";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Code examples
|
|
16
|
+
|
|
17
|
+
### **Default CellHeader**
|
|
18
|
+
|
|
19
|
+
This example demonstrates the minimum required props for rendering a CellHeader component.
|
|
20
|
+
|
|
21
|
+
**Example: DefaultCellHeader**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { CellHeader } from "@czi-sds/components";
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<div className="app">
|
|
29
|
+
<table>
|
|
30
|
+
<thead>
|
|
31
|
+
<tr>
|
|
32
|
+
<CellHeader>Header</CellHeader>
|
|
33
|
+
</tr>
|
|
34
|
+
</thead>
|
|
35
|
+
</table>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default App;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
table {
|
|
45
|
+
border: dashed 1px #eee;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### **Sortable CellHeader**
|
|
50
|
+
|
|
51
|
+
A header only looks sortable once `hover` is set: without it the cell draws no chevron and shows no tooltip, whatever the other sorting props say. Sorting itself is yours to wire up through `onClick`, with `active` marking the column being sorted and `direction` choosing which way the chevron points.
|
|
52
|
+
|
|
53
|
+
**Example: SortableCellHeader**
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// `hover` is what makes a header sortable-looking: without it the cell draws no
|
|
57
|
+
// chevron and shows no tooltip, however the other sorting props are set. The
|
|
58
|
+
// three headers below differ only in that, and in which one is `active`.
|
|
59
|
+
|
|
60
|
+
import { CellHeader } from "@czi-sds/components";
|
|
61
|
+
import { useState } from "react";
|
|
62
|
+
|
|
63
|
+
type Direction = "asc" | "desc";
|
|
64
|
+
|
|
65
|
+
function App() {
|
|
66
|
+
const [sortedBy, setSortedBy] = useState("Gene");
|
|
67
|
+
const [direction, setDirection] = useState<Direction>("desc");
|
|
68
|
+
|
|
69
|
+
function sortBy(column: string) {
|
|
70
|
+
if (column === sortedBy) {
|
|
71
|
+
setDirection(direction === "asc" ? "desc" : "asc");
|
|
72
|
+
} else {
|
|
73
|
+
setSortedBy(column);
|
|
74
|
+
setDirection("desc");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div className="app">
|
|
80
|
+
<table>
|
|
81
|
+
<thead>
|
|
82
|
+
<tr>
|
|
83
|
+
{["Gene", "Organism"].map((column) => (
|
|
84
|
+
<CellHeader
|
|
85
|
+
active={column === sortedBy}
|
|
86
|
+
direction={direction}
|
|
87
|
+
hover
|
|
88
|
+
key={column}
|
|
89
|
+
onClick={() => sortBy(column)}
|
|
90
|
+
shouldShowTooltipOnHover
|
|
91
|
+
tooltipText={`Sort by ${column.toLowerCase()}`}
|
|
92
|
+
>
|
|
93
|
+
{column}
|
|
94
|
+
</CellHeader>
|
|
95
|
+
))}
|
|
96
|
+
<CellHeader hideSortIcon>Notes</CellHeader>
|
|
97
|
+
</tr>
|
|
98
|
+
</thead>
|
|
99
|
+
</table>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default App;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Props
|
|
108
|
+
|
|
109
|
+
Any custom SDS props and MUI props required for implementation are found on the table below. See the MUI documentation for additional optional props.
|
|
110
|
+
|
|
111
|
+
| Name | Type | Default | Description |
|
|
112
|
+
| -------------------------- | ----------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
113
|
+
| `active` | `boolean` | `false` | Marks this column as the one currently sorted: the label and chevron take the accent color. It does not sort anything on its own. |
|
|
114
|
+
| `as` | `React.ElementType` | `"th"` | The element the header cell renders as. |
|
|
115
|
+
| `children` | `React.ReactNode` | - | Required. A string or number is wrapped in the header's own text styling; anything else is rendered as given. |
|
|
116
|
+
| `direction` | `"asc"` \| `"desc"` | `"desc"` | Which chevron to draw: up for `"asc"`, down for `"desc"`. It also sets the icon's `aria-label`. Exported as `CellHeaderDirection`. |
|
|
117
|
+
| `hideSortIcon` | `boolean` | `false` | Leaves the chevron out for columns that cannot be sorted. An active header keeps its chevron even with this set. |
|
|
118
|
+
| `horizontalAlign` | `"left"` \| `"center"` \| `"right"` | `"left"` | Horizontally aligns the label and its chevron. |
|
|
119
|
+
| `hover` | `boolean` | `false` | Makes the header interactive: it takes a pointer cursor, reacts to hover, renders the sort chevron and allows the tooltip. A header left at the default draws no chevron and shows no tooltip even if the other sorting props are set, so set this on every sortable column. |
|
|
120
|
+
| `onClick` | `React.MouseEventHandler` | - | Where sorting is actually wired up: with TanStack Table, pass `column.getToggleSortingHandler()`. |
|
|
121
|
+
| `shouldShowTooltipOnHover` | `boolean` | `false` | Wraps the header in a Tooltip. It only takes effect while `hover` is also `true`. |
|
|
122
|
+
| `shouldTruncate` | `boolean` | `false` | Keeps a long label on one line and truncates it with an ellipsis instead of wrapping. |
|
|
123
|
+
| `tooltipText` | `string` | `""` | The tooltip's title. |
|
|
124
|
+
| `tooltipSubtitle` | `string` | - | A second line below the tooltip's title. |
|
|
125
|
+
| `width` | `string` \| `number` | - | Lands on the rendered cell as the HTML `width` attribute, so a number is read as pixels. Browsers treat it as the width of the whole column, and take it as a minimum rather than a promise. |
|
|
126
|
+
| `tooltipProps` | `Partial<TooltipProps>` | - | Passed to the Tooltip, and overrides the defaults the header sets (arrow, top-start placement, dark style). |
|
|
127
|
+
|
|
128
|
+
Anything else you pass, such as `colSpan`, `scope` or a data attribute, lands on the rendered `th`.
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# ComplexFilter
|
|
2
|
+
|
|
3
|
+
> **ComplexFilter is a Dropdown that shows what it filtered.** It is the Dropdown arrangement with one addition: each selection is listed beneath the trigger as a tag that can be removed on its own, so an applied filter stays visible next to the results it narrowed. Use plain Dropdown when the selection does not need to be shown that way, and see the Dropdowns overview for the rest of the family.
|
|
4
|
+
|
|
5
|
+
## Source Code
|
|
6
|
+
|
|
7
|
+
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/ComplexFilter/index.tsx).
|
|
8
|
+
|
|
9
|
+
## Import
|
|
10
|
+
|
|
11
|
+
**React TypeScript**
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { ComplexFilter } from "@czi-sds/components";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Code Examples
|
|
18
|
+
|
|
19
|
+
### Default ComplexFilter
|
|
20
|
+
|
|
21
|
+
This examples demonstrates the minimum props needed to render a ComplexFilter.
|
|
22
|
+
|
|
23
|
+
**Example: DefaultComplexFilter**
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { ComplexFilter, DefaultAutocompleteOption } from "@czi-sds/components";
|
|
27
|
+
|
|
28
|
+
const MENU_ITEMS: DefaultAutocompleteOption[] = [
|
|
29
|
+
{
|
|
30
|
+
name: "Fruit: Apple",
|
|
31
|
+
section: "Fruit",
|
|
32
|
+
count: 10,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "Fruit: Cherry",
|
|
36
|
+
section: "Fruit",
|
|
37
|
+
count: 150,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "Fruit: Orange",
|
|
41
|
+
section: "Fruit",
|
|
42
|
+
count: 15,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "Vegetable: Carrot",
|
|
46
|
+
section: "Vegetable",
|
|
47
|
+
count: 34,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "Vegetable: Kale",
|
|
51
|
+
section: "Vegetable",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Vegetable: Lettuce",
|
|
55
|
+
section: "Vegetable",
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
function App() {
|
|
60
|
+
return (
|
|
61
|
+
<div className="app">
|
|
62
|
+
<ComplexFilter
|
|
63
|
+
label="Filter Label"
|
|
64
|
+
onChange={() => {}}
|
|
65
|
+
options={MENU_ITEMS}
|
|
66
|
+
InputDropdownProps={{
|
|
67
|
+
sdsStyle: "square",
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default App;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Multi select ComplexFilter with Search
|
|
78
|
+
|
|
79
|
+
This example showcases a ComplexFilter component featuring InputSearch for filtering menu items. Users have the flexibility to select multiple options to refine their selections.
|
|
80
|
+
|
|
81
|
+
**Example: MultiSelectComplexFilterWithSearch**
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { ComplexFilter, DefaultAutocompleteOption } from "@czi-sds/components";
|
|
85
|
+
|
|
86
|
+
const MENU_ITEMS: DefaultAutocompleteOption[] = [
|
|
87
|
+
{
|
|
88
|
+
name: "Fruit: Apple",
|
|
89
|
+
section: "Fruit",
|
|
90
|
+
count: 10,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "Fruit: Cherry",
|
|
94
|
+
section: "Fruit",
|
|
95
|
+
count: 150,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "Fruit: Orange",
|
|
99
|
+
section: "Fruit",
|
|
100
|
+
count: 15,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: "Vegetable: Carrot",
|
|
104
|
+
section: "Vegetable",
|
|
105
|
+
count: 34,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: "Vegetable: Kale",
|
|
109
|
+
section: "Vegetable",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "Vegetable: Lettuce",
|
|
113
|
+
section: "Vegetable",
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
function App() {
|
|
118
|
+
return (
|
|
119
|
+
<div className="app">
|
|
120
|
+
<ComplexFilter
|
|
121
|
+
label="Filter Label"
|
|
122
|
+
onChange={() => {}}
|
|
123
|
+
options={MENU_ITEMS}
|
|
124
|
+
DropdownMenuProps={{
|
|
125
|
+
groupBy: (option: DefaultAutocompleteOption) =>
|
|
126
|
+
option.section as string,
|
|
127
|
+
}}
|
|
128
|
+
InputDropdownProps={{
|
|
129
|
+
sdsStyle: "square",
|
|
130
|
+
}}
|
|
131
|
+
multiple
|
|
132
|
+
search
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export default App;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### ComplexFilter with realtime selection changes
|
|
142
|
+
|
|
143
|
+
This example showcases the functionality that enables the dropdown selections to be instantly reflected in the tags in real-time. This is achieved by utilizing the `isTriggerChangeOnOptionClick` prop.
|
|
144
|
+
|
|
145
|
+
**Example: ComplexFilterWithRealtimeSelectionChanges**
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
import { ComplexFilter, DefaultAutocompleteOption } from "@czi-sds/components";
|
|
149
|
+
|
|
150
|
+
const MENU_ITEMS: DefaultAutocompleteOption[] = [
|
|
151
|
+
{
|
|
152
|
+
name: "Fruit: Apple",
|
|
153
|
+
section: "Fruit",
|
|
154
|
+
count: 10,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "Fruit: Cherry",
|
|
158
|
+
section: "Fruit",
|
|
159
|
+
count: 150,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "Fruit: Orange",
|
|
163
|
+
section: "Fruit",
|
|
164
|
+
count: 15,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "Vegetable: Carrot",
|
|
168
|
+
section: "Vegetable",
|
|
169
|
+
count: 34,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "Vegetable: Kale",
|
|
173
|
+
section: "Vegetable",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "Vegetable: Lettuce",
|
|
177
|
+
section: "Vegetable",
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
function App() {
|
|
182
|
+
return (
|
|
183
|
+
<div className="app">
|
|
184
|
+
<ComplexFilter
|
|
185
|
+
label="Filter Label"
|
|
186
|
+
onChange={() => {}}
|
|
187
|
+
options={MENU_ITEMS}
|
|
188
|
+
DropdownMenuProps={{
|
|
189
|
+
groupBy: (option: DefaultAutocompleteOption) =>
|
|
190
|
+
option.section as string,
|
|
191
|
+
}}
|
|
192
|
+
InputDropdownProps={{
|
|
193
|
+
sdsStyle: "square",
|
|
194
|
+
width: "280px",
|
|
195
|
+
}}
|
|
196
|
+
multiple
|
|
197
|
+
search
|
|
198
|
+
isTriggerChangeOnOptionClick
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default App;
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### ComplexFilter that closes on blur
|
|
208
|
+
|
|
209
|
+
A single select puts its menu away as soon as something is chosen, but a multi select has no such moment and holds the menu open even when a click lands outside it. `closeOnBlur` gives it one: a click anywhere else closes the menu, keeping whatever had been selected by then. The prop is ignored while the Apply and Cancel buttons are showing, those being that menu's own way out, so the filter here uses `isTriggerChangeOnOptionClick` instead and applies each selection as it is made.
|
|
210
|
+
|
|
211
|
+
**Example: ComplexFilterThatClosesOnBlur**
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
import { ComplexFilter, DefaultAutocompleteOption } from "@czi-sds/components";
|
|
215
|
+
|
|
216
|
+
const MENU_ITEMS: DefaultAutocompleteOption[] = [
|
|
217
|
+
{
|
|
218
|
+
name: "Fruit: Apple",
|
|
219
|
+
section: "Fruit",
|
|
220
|
+
count: 10,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "Fruit: Cherry",
|
|
224
|
+
section: "Fruit",
|
|
225
|
+
count: 150,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "Fruit: Orange",
|
|
229
|
+
section: "Fruit",
|
|
230
|
+
count: 15,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "Vegetable: Carrot",
|
|
234
|
+
section: "Vegetable",
|
|
235
|
+
count: 34,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "Vegetable: Kale",
|
|
239
|
+
section: "Vegetable",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "Vegetable: Lettuce",
|
|
243
|
+
section: "Vegetable",
|
|
244
|
+
},
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
function App() {
|
|
248
|
+
return (
|
|
249
|
+
<div className="app">
|
|
250
|
+
<ComplexFilter
|
|
251
|
+
label="Filter Label"
|
|
252
|
+
onChange={() => {}}
|
|
253
|
+
options={MENU_ITEMS}
|
|
254
|
+
InputDropdownProps={{
|
|
255
|
+
sdsStyle: "square",
|
|
256
|
+
}}
|
|
257
|
+
multiple
|
|
258
|
+
isTriggerChangeOnOptionClick
|
|
259
|
+
closeOnBlur
|
|
260
|
+
/>
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export default App;
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## SDS vs MUI
|
|
269
|
+
|
|
270
|
+
The ComplexFilter is not directly based on any MUI component, but it does use the SDS Dropdown component, which in turn is ultimately based on [MUI's Autocomplete component](https://mui.com/material-ui/react-autocomplete/). As such, props that are available to either SDS's Dropdown and / or MUI's Autocomplete can be passed to ComplexFilter as such:
|
|
271
|
+
|
|
272
|
+
- `DropdownMenuProps`: use this prop to pass MUIAutocomplete-specific props to ComplexFilter
|
|
273
|
+
|
|
274
|
+
- `InputDropdownProps`: use this prop to pass SDS InputDropdown-specific props to ComplexFilter
|
|
275
|
+
|
|
276
|
+
## Props
|
|
277
|
+
|
|
278
|
+
Any custom SDS props and MUI props required for implementation are found in the table below. See the MUI documentation for additional optional props.
|
|
279
|
+
|
|
280
|
+
| Name | Type | Default | Description |
|
|
281
|
+
| ------------------------------ | ----------------------------------------------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
282
|
+
| `buttonPosition` | `"left" \| "right"` | `"right"` | Which side of the menu footer the Apply and Cancel buttons sit on. It only applies alongside `buttons`. |
|
|
283
|
+
| `buttons` | `boolean` | `false` | Puts Apply and Cancel buttons at the foot of the menu, so selections take effect only once Apply is pressed. |
|
|
284
|
+
| `closeOnBlur` | `boolean` | `false` | Closes the filter when a click lands outside it, which it otherwise does not do. It is ignored while the Apply and Cancel buttons are showing, which is a multi select that has not been given `isTriggerChangeOnOptionClick`. The default follows `buttons`, so a filter given `buttons={false}` closes on blur without being asked. |
|
|
285
|
+
| `isTriggerChangeOnOptionClick` | `boolean` | `false` | Determines whether changes are triggered in real-time upon clicking an option |
|
|
286
|
+
| `keepSearchOnSelect` | `boolean` | | Maintains a search input when a user selects an option (only if multiple selections are allowed via the `multiple` prop; otherwise the dropdown closes upon selection) |
|
|
287
|
+
| `label` | `ReactNode` | `""` | Sets the label of filter, shown both when closed and open |
|
|
288
|
+
| `multiple` | `boolean` | `false` | Defines whether multiple selections or can be made from the filter simultaneously or only one |
|
|
289
|
+
| `onChange` | `function` | - | Function to set what happens when a new value is set via the filter |
|
|
290
|
+
| `options` | `AutocompleteSingleColumnOption<T>[]` \| `AutocompleteMultiColumnOption<T>[]` | - | The items to filter by. Passing the multi-column shape lays the menu out in named columns instead of one list. |
|
|
291
|
+
| `search` | `boolean` | `false` | Provides a search bar at the top of the filter from which users can narrow the list of menu items |
|
|
292
|
+
| `value` | `T \| T[] \| null` | - | The selected option or options. Leaving it out lets the filter keep track of the selection itself, and passing it makes the filter controlled: the tags and menu then only change when a new value comes back in. |
|
|
293
|
+
| `DropdownMenuProps` | `Partial<DropdownMenuProps>` | - | Passed straight to the menu, and with it to MUI's Autocomplete underneath. |
|
|
294
|
+
| `InputDropdownProps` | `Partial<InputDropdownProps>` | `{ sdsStyle: "minimal" }` | Passed straight to the InputDropdown that opens the filter. Note that supplying it replaces the default, so a filter that should stay minimal needs `sdsStyle` passed again alongside whatever else it sets. |
|