1
1
import type { Meta , StoryObj } from "@storybook/web-components" ;
2
2
import { html } from "lit" ;
3
- import { repeat } from "lit/directives/repeat.js" ;
4
3
5
4
import { defaultArgs , renderComponent , type RenderProps } from "./DataGrid" ;
6
5
import {
9
8
} from "./decorators/dataGridDecorator" ;
10
9
11
10
import { DataGridRowsController } from "@/components/ui/data-grid/controllers/rows" ;
11
+ import { renderRows } from "@/components/ui/data-grid/renderRows" ;
12
12
import { GridColumnType } from "@/components/ui/data-grid/types" ;
13
13
14
14
const meta = {
@@ -149,6 +149,7 @@ export const EditCells: Story = {
149
149
*
150
150
* A few helpers are included to make managing rows easier:
151
151
* - `DataGridController` to add and remove slotted rows
152
+ * - `renderRows` to render `<btrix-data-grid-row>`
152
153
* - `serializeDeep` to parse form values
153
154
*
154
155
* Open console logs to view the form value submitted in this example.
@@ -180,7 +181,7 @@ export const FormControl: Story = {
180
181
return html `
181
182
< btrix-syntax-input
182
183
name ="selector "
183
- class ="flex-1 [--sl-input-border-color:transparent ] [--sl-input-border-radius-medium:0 ] "
184
+ class ="flex-1 [--sl-input-border-radius-medium:0 ] [--sl-input-border-color:transparent ] "
184
185
value =${ item . selector || "" }
185
186
language ="css"
186
187
> </ btrix-syntax-input >
@@ -199,12 +200,14 @@ export const FormControl: Story = {
199
200
label : "Status" ,
200
201
editable : true ,
201
202
inputType : GridColumnType . Select ,
202
- renderSelectOptions ( ) {
203
- return html `
204
- < sl-option value ="Pending "> Pending</ sl-option >
205
- < sl-option value ="Approved "> Approved</ sl-option >
206
- ` ;
207
- } ,
203
+ selectOptions : [
204
+ {
205
+ value : "Pending" ,
206
+ } ,
207
+ {
208
+ value : "Approved" ,
209
+ } ,
210
+ ] ,
208
211
} ,
209
212
] ,
210
213
items : [
@@ -244,10 +247,9 @@ export const FormControl: Story = {
244
247
removeRows
245
248
editCells
246
249
>
247
- ${ repeat (
250
+ ${ renderRows (
248
251
rows ,
249
- ( [ id ] ) => id ,
250
- ( [ id , item ] ) => html `
252
+ ( { id, item } ) => html `
251
253
< btrix-data-grid-row
252
254
slot ="rows "
253
255
name ="${ formControlName } "
0 commit comments