/
row-selections.stories.tsx
84 lines (79 loc) 路 2.69 KB
/
row-selections.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from "react";
import { DataEditorAll as DataEditor } from "../../data-editor-all.js";
import { type RowMarkerOptions } from "../../data-editor/data-editor.js";
import {
BeautifulWrapper,
Description,
PropName,
useMockDataGenerator,
defaultProps,
} from "../../data-editor/stories/utils.js";
import { SimpleThemeWrapper } from "../../stories/story-utils.js";
export default {
title: "Glide-Data-Grid/DataEditor Demos",
decorators: [
(Story: React.ComponentType) => (
<SimpleThemeWrapper>
<BeautifulWrapper
title="Row selections"
description={
<Description>
You can enable row selections by setting <PropName>rowSelect</PropName> prop to{" "}
<PropName>multi</PropName> for multi-selection or <PropName>single</PropName> for
single-selection. The row marker behavior and appearance can be controlled by setting the{" "}
<PropName>rowMarkers</PropName> prop.
</Description>
}>
<Story />
</BeautifulWrapper>
</SimpleThemeWrapper>
),
],
};
interface RowSelectionsProps {
rowSelect: "none" | "single" | "multi";
rowSelectionMode: "auto" | "multi";
rowMarkersKind: RowMarkerOptions["kind"];
rowMarkersCheckboxStyle: RowMarkerOptions["checkboxStyle"];
}
export const RowSelections: React.FC<RowSelectionsProps> = p => {
const { cols, getCellContent } = useMockDataGenerator(30);
return (
<DataEditor
{...defaultProps}
rowSelect={p.rowSelect}
rowSelectionMode={p.rowSelectionMode}
getCellContent={getCellContent}
rowMarkers={{
kind: p.rowMarkersKind,
checkboxStyle: p.rowMarkersCheckboxStyle,
}}
columns={cols}
rows={400}
/>
);
};
(RowSelections as any).args = {
rowSelect: "single",
rowSelectionMode: "auto",
rowMarkersKind: "checkbox-visible",
rowMarkersCheckboxStyle: "circle",
};
(RowSelections as any).argTypes = {
rowSelect: {
control: { type: "select" },
options: ["none", "single", "multi"],
},
rowSelectionMode: {
control: { type: "select" },
options: ["auto", "multi"],
},
rowMarkersKind: {
control: { type: "select" },
options: ["both", "checkbox", "number", "none", "clickable-number", "checkbox-visible"],
},
rowMarkersCheckboxStyle: {
control: { type: "select" },
options: ["square", "circle"],
},
};