1
- import { action } from '@storybook/addon-actions' ;
2
- import { array , boolean , number , object , select , text } from '@storybook/addon-knobs' ;
3
1
import '@ui5/webcomponents-icons/dist/icons/delete' ;
4
2
import '@ui5/webcomponents-icons/dist/icons/edit' ;
5
3
import '@ui5/webcomponents-icons/dist/icons/settings' ;
@@ -16,6 +14,7 @@ import { FlexBoxJustifyContent } from '@ui5/webcomponents-react/lib/FlexBoxJusti
16
14
import React from 'react' ;
17
15
import generateData from './demo/generateData' ;
18
16
import mdx from './AnalyticalTable.mdx' ;
17
+ import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes' ;
19
18
20
19
const columns = [
21
20
{
@@ -83,7 +82,7 @@ const columns = [
83
82
const data = generateData ( 10_000 ) ;
84
83
const dataTree = generateData ( 20 , true ) ;
85
84
86
- export const defaultTable = ( ) => {
85
+ export const defaultTable = ( props ) => {
87
86
return (
88
87
< div style = { { display : 'flex' , flexDirection : 'column' } } >
89
88
< AnalyticalTable
@@ -95,69 +94,57 @@ export const defaultTable = () => {
95
94
}
96
95
data = { data }
97
96
columns = { columns }
98
- loading = { boolean ( 'loading' , false ) }
99
- busyIndicatorEnabled = { boolean ( 'busyIndicatorEnabled' , true ) }
100
- alternateRowColor = { boolean ( 'alternateRowColor' , false ) }
101
- sortable = { boolean ( 'sortable' , true ) }
102
- filterable = { boolean ( 'filterable' , true ) }
103
- visibleRows = { number ( 'visibleRows' , 15 ) }
104
- minRows = { number ( 'minRows' , 5 ) }
105
- groupable = { boolean ( 'groupable' , true ) }
106
- selectionMode = { select < TableSelectionMode > (
107
- 'selectionMode' ,
108
- TableSelectionMode ,
109
- TableSelectionMode . SINGLE_SELECT
110
- ) }
111
- scaleWidthMode = { select < TableScaleWidthMode > ( 'scaleWidthMode' , TableScaleWidthMode , TableScaleWidthMode . Default ) }
112
- onRowSelected = { action ( 'onRowSelected' ) }
113
- onSort = { action ( 'onSort' ) }
114
- onGroup = { action ( 'onGroup' ) }
115
- onRowExpandChange = { action ( 'onRowExpandChange' ) }
116
- groupBy = { array ( 'groupBy' , [ ] ) }
117
- rowHeight = { number ( 'rowHeight' , 44 ) }
118
- selectedRowIds = { object ( 'selectedRowIds' , { 3 : true } ) }
119
- onColumnsReordered = { action ( 'onColumnsReordered' ) }
120
- withRowHighlight = { boolean ( 'withRowHighlight' , true ) }
121
- highlightField = { text ( 'highlightField' , 'status' ) }
122
- infiniteScroll = { boolean ( 'infiniteScroll' , true ) }
123
- infiniteScrollThreshold = { number ( 'infiniteScrollThreshold' , 20 ) }
124
- onLoadMore = { action ( 'onLoadMore' ) }
125
- selectionBehavior = { select < TableSelectionBehavior > (
126
- 'selectionBehavior' ,
127
- TableSelectionBehavior ,
128
- TableSelectionBehavior . ROW
129
- ) }
97
+ loading = { props . loading }
98
+ busyIndicatorEnabled = { props . busyIndicatorEnabled }
99
+ alternateRowColor = { props . alternateRowColor }
100
+ sortable = { props . sortable }
101
+ filterable = { props . filterable }
102
+ visibleRows = { props . visibleRows }
103
+ minRows = { props . minRows }
104
+ groupable = { props . groupable }
105
+ selectionMode = { props . selectionMode }
106
+ scaleWidthMode = { props . scaleWidthMode }
107
+ onRowSelected = { props . onRowSelected }
108
+ onSort = { props . onSort }
109
+ onGroup = { props . onGroup }
110
+ onRowExpandChange = { props . onRowExpandChange }
111
+ groupBy = { props . groupBy }
112
+ rowHeight = { props . rowHeight }
113
+ selectedRowIds = { props . selectedRowIds }
114
+ onColumnsReordered = { props . onColumnsReordered }
115
+ withRowHighlight = { props . withRowHighlight }
116
+ highlightField = { props . highlightField }
117
+ infiniteScroll = { props . infiniteScroll }
118
+ infiniteScrollThreshold = { props . infiniteScrollThreshold }
119
+ onLoadMore = { props . onLoadMore }
120
+ selectionBehavior = { props . selectionBehavior }
130
121
/>
131
122
</ div >
132
123
) ;
133
124
} ;
134
125
135
126
defaultTable . storyName = 'Default' ;
136
127
137
- export const treeTable = ( ) => {
128
+ export const treeTable = ( props ) => {
138
129
return (
139
130
< AnalyticalTable
140
131
title = "Table Title"
141
132
data = { dataTree }
142
133
columns = { columns }
143
- loading = { boolean ( 'loading' , false ) }
144
- busyIndicatorEnabled = { boolean ( 'busyIndicatorEnabled' , true ) }
145
- sortable = { boolean ( 'sortable' , true ) }
146
- filterable = { boolean ( 'filterable' , true ) }
147
- visibleRows = { number ( 'visibleRows' , 15 ) }
148
- minRows = { number ( 'minRows' , 5 ) }
149
- selectionMode = { select < TableSelectionMode > ( 'selectionMode' , TableSelectionMode , TableSelectionMode . MULTI_SELECT ) }
150
- onRowSelected = { action ( 'onRowSelected' ) }
151
- onSort = { action ( 'onSort' ) }
152
- onRowExpandChange = { action ( 'onRowExpandChange' ) }
153
- subRowsKey = { text ( 'subRowsKey' , 'subRows' ) }
154
- selectedRowIds = { object ( 'selectedRowIds' , { 3 : true } ) }
155
- selectionBehavior = { select < TableSelectionBehavior > (
156
- 'selectionBehavior' ,
157
- TableSelectionBehavior ,
158
- TableSelectionBehavior . ROW
159
- ) }
160
- isTreeTable = { boolean ( 'isTreeTable' , true ) }
134
+ loading = { props . loading }
135
+ busyIndicatorEnabled = { props . busyIndicatorEnabled }
136
+ sortable = { props . sortable }
137
+ filterable = { props . filterable }
138
+ visibleRows = { props . visibleRows }
139
+ minRows = { props . minRows }
140
+ selectionMode = { props . selectionMode }
141
+ onRowSelected = { props . onRowSelected }
142
+ onSort = { props . onSort }
143
+ onRowExpandChange = { props . onRowExpandChange }
144
+ subRowsKey = { props . subRowsKey }
145
+ selectedRowIds = { props . selectedRowIds }
146
+ selectionBehavior = { props . selectionBehavior }
147
+ isTreeTable = { props . isTreeTable }
161
148
/>
162
149
) ;
163
150
} ;
@@ -170,5 +157,30 @@ export default {
170
157
docs : {
171
158
page : mdx
172
159
}
160
+ } ,
161
+ argTypes : {
162
+ ...createSelectArgTypes ( { scaleWidthMode : TableScaleWidthMode } ) ,
163
+ ...createSelectArgTypes ( { selectionMode : TableSelectionMode } ) ,
164
+ ...createSelectArgTypes ( { selectionBehavior : TableSelectionBehavior } )
165
+ } ,
166
+ args : {
167
+ busyIndicatorEnabled : true ,
168
+ sortable : true ,
169
+ filterable : true ,
170
+ visibleRows : 15 ,
171
+ minRows : 5 ,
172
+ groupable : true ,
173
+ groupBy : [ ] ,
174
+ rowHeight : 44 ,
175
+ selectedRowIds : { 3 : true } ,
176
+ withRowHighlight : true ,
177
+ highlightField : 'status' ,
178
+ infiniteScroll : true ,
179
+ infiniteScrollThreshold : 20 ,
180
+ subRowsKey : 'subRows' ,
181
+ isTreeTable : true ,
182
+ scaleWidthMode : TableScaleWidthMode . Default ,
183
+ selectionMode : TableSelectionMode . SINGLE_SELECT ,
184
+ selectionBehavior : TableSelectionBehavior . ROW
173
185
}
174
186
} ;
0 commit comments