@operato/data-grist 9.0.0-beta.7 → 9.0.0-beta.70

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +275 -0
  2. package/README.md +337 -44
  3. package/dist/src/data-grid/data-grid-body.js +30 -27
  4. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  5. package/dist/src/data-grist.d.ts +13 -1
  6. package/dist/src/data-grist.js +42 -0
  7. package/dist/src/data-grist.js.map +1 -1
  8. package/dist/src/data-report.js +4 -4
  9. package/dist/src/data-report.js.map +1 -1
  10. package/dist/src/editors/ox-grist-editor-json5.d.ts +8 -0
  11. package/dist/src/editors/ox-grist-editor-json5.js +66 -0
  12. package/dist/src/editors/ox-grist-editor-json5.js.map +1 -0
  13. package/dist/src/editors/ox-popup-code-input.d.ts +14 -0
  14. package/dist/src/editors/ox-popup-code-input.js +78 -0
  15. package/dist/src/editors/ox-popup-code-input.js.map +1 -0
  16. package/dist/src/editors/registry.js +3 -1
  17. package/dist/src/editors/registry.js.map +1 -1
  18. package/dist/src/formatters/registry.d.ts +1 -1
  19. package/dist/src/gutters/registry.d.ts +1 -1
  20. package/dist/src/handlers/registry.d.ts +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +18 -14
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.js +0 -2
  25. package/dist/index.js.map +0 -1
  26. package/dist/stories/accumulator-format.stories.d.ts +0 -41
  27. package/dist/stories/accumulator-format.stories.js +0 -237
  28. package/dist/stories/accumulator-format.stories.js.map +0 -1
  29. package/dist/stories/barcode-input-filter.stories.d.ts +0 -33
  30. package/dist/stories/barcode-input-filter.stories.js +0 -185
  31. package/dist/stories/barcode-input-filter.stories.js.map +0 -1
  32. package/dist/stories/bounded-select-filters.stories.d.ts +0 -25
  33. package/dist/stories/bounded-select-filters.stories.js +0 -283
  34. package/dist/stories/bounded-select-filters.stories.js.map +0 -1
  35. package/dist/stories/bounded-select-record.stories.d.ts +0 -25
  36. package/dist/stories/bounded-select-record.stories.js +0 -286
  37. package/dist/stories/bounded-select-record.stories.js.map +0 -1
  38. package/dist/stories/click-event-custom.stories.d.ts +0 -45
  39. package/dist/stories/click-event-custom.stories.js +0 -248
  40. package/dist/stories/click-event-custom.stories.js.map +0 -1
  41. package/dist/stories/click-event.stories.d.ts +0 -45
  42. package/dist/stories/click-event.stories.js +0 -243
  43. package/dist/stories/click-event.stories.js.map +0 -1
  44. package/dist/stories/creatable-only-column.stories.d.ts +0 -29
  45. package/dist/stories/creatable-only-column.stories.js +0 -232
  46. package/dist/stories/creatable-only-column.stories.js.map +0 -1
  47. package/dist/stories/default-filters.stories.d.ts +0 -26
  48. package/dist/stories/default-filters.stories.js +0 -219
  49. package/dist/stories/default-filters.stories.js.map +0 -1
  50. package/dist/stories/dynamic-editable.stories.d.ts +0 -25
  51. package/dist/stories/dynamic-editable.stories.js +0 -293
  52. package/dist/stories/dynamic-editable.stories.js.map +0 -1
  53. package/dist/stories/empty-sorters.stories.d.ts +0 -25
  54. package/dist/stories/empty-sorters.stories.js +0 -162
  55. package/dist/stories/empty-sorters.stories.js.map +0 -1
  56. package/dist/stories/explicit-fetch.stories.d.ts +0 -25
  57. package/dist/stories/explicit-fetch.stories.js +0 -166
  58. package/dist/stories/explicit-fetch.stories.js.map +0 -1
  59. package/dist/stories/fixed-column.stories.d.ts +0 -26
  60. package/dist/stories/fixed-column.stories.js +0 -383
  61. package/dist/stories/fixed-column.stories.js.map +0 -1
  62. package/dist/stories/grid-setting.stories.d.ts +0 -47
  63. package/dist/stories/grid-setting.stories.js +0 -453
  64. package/dist/stories/grid-setting.stories.js.map +0 -1
  65. package/dist/stories/grist-modes.stories.d.ts +0 -37
  66. package/dist/stories/grist-modes.stories.js +0 -416
  67. package/dist/stories/grist-modes.stories.js.map +0 -1
  68. package/dist/stories/group-header.stories.d.ts +0 -26
  69. package/dist/stories/group-header.stories.js +0 -410
  70. package/dist/stories/group-header.stories.js.map +0 -1
  71. package/dist/stories/record-view.stories.d.ts +0 -24
  72. package/dist/stories/record-view.stories.js +0 -125
  73. package/dist/stories/record-view.stories.js.map +0 -1
  74. package/dist/stories/textarea.stories.d.ts +0 -37
  75. package/dist/stories/textarea.stories.js +0 -229
  76. package/dist/stories/textarea.stories.js.map +0 -1
  77. package/dist/stories/tree-column-with-checkbox.stories.d.ts +0 -26
  78. package/dist/stories/tree-column-with-checkbox.stories.js +0 -267
  79. package/dist/stories/tree-column-with-checkbox.stories.js.map +0 -1
  80. package/dist/stories/tree-column.stories.d.ts +0 -26
  81. package/dist/stories/tree-column.stories.js +0 -266
  82. package/dist/stories/tree-column.stories.js.map +0 -1
  83. package/index.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,281 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [9.0.0-beta.70](https://github.com/hatiolab/operato/compare/v9.0.0-beta.69...v9.0.0-beta.70) (2025-04-23)
7
+
8
+ **Note:** Version bump only for package @operato/data-grist
9
+
10
+
11
+
12
+
13
+
14
+ ## [9.0.0-beta.67](https://github.com/hatiolab/operato/compare/v9.0.0-beta.66...v9.0.0-beta.67) (2025-04-12)
15
+
16
+
17
+ ### :bug: Bug Fix
18
+
19
+ * grid object copy error ([a3b2b91](https://github.com/hatiolab/operato/commit/a3b2b91c62dc5a0c30ec732bbd03257fa3e67879))
20
+
21
+
22
+
23
+ ## [9.0.0-beta.65](https://github.com/hatiolab/operato/compare/v9.0.0-beta.64...v9.0.0-beta.65) (2025-04-12)
24
+
25
+
26
+ ### :bug: Bug Fix
27
+
28
+ * move ox-popup-code-input from app to data-grist module ([16c0c1d](https://github.com/hatiolab/operato/commit/16c0c1d45291324cb88c9006f3903cb623ffdc40))
29
+
30
+
31
+
32
+ ## [9.0.0-beta.64](https://github.com/hatiolab/operato/compare/v9.0.0-beta.63...v9.0.0-beta.64) (2025-04-12)
33
+
34
+
35
+ ### :bug: Bug Fix
36
+
37
+ * move ox-popup-code-input from app to data-grist module ([3f4fa23](https://github.com/hatiolab/operato/commit/3f4fa233bb39ecd0fbacb0c30dde5c1da7f656be))
38
+
39
+
40
+
41
+ ## [9.0.0-beta.63](https://github.com/hatiolab/operato/compare/v9.0.0-beta.62...v9.0.0-beta.63) (2025-04-12)
42
+
43
+
44
+ ### :bug: Bug Fix
45
+
46
+ * package.json for data-grist ([126bfc8](https://github.com/hatiolab/operato/commit/126bfc8e205f44d450d75aa54b6b4ca1efc3832e))
47
+
48
+
49
+
50
+ ## [9.0.0-beta.62](https://github.com/hatiolab/operato/compare/v9.0.0-beta.61...v9.0.0-beta.62) (2025-04-12)
51
+
52
+
53
+ ### :mega: Other
54
+
55
+ * data-report property types ([4c8ac21](https://github.com/hatiolab/operato/commit/4c8ac21e25ac4c5691cbb840a01f605a0f9fda2f))
56
+
57
+
58
+
59
+ ## [9.0.0-beta.61](https://github.com/hatiolab/operato/compare/v9.0.0-beta.60...v9.0.0-beta.61) (2025-04-12)
60
+
61
+ **Note:** Version bump only for package @operato/data-grist
62
+
63
+
64
+
65
+
66
+
67
+ ## [9.0.0-beta.56](https://github.com/hatiolab/operato/compare/v9.0.0-beta.55...v9.0.0-beta.56) (2025-03-30)
68
+
69
+
70
+ ### :bug: Bug Fix
71
+
72
+ * add addRecordToTop method into ox-grist ([57851b0](https://github.com/hatiolab/operato/commit/57851b0847e8f591a059345950da39b94e8d5122))
73
+ * title for ox-grist stories and README.md ([38476a5](https://github.com/hatiolab/operato/commit/38476a5994b142f29205014aa0238a1724fd7de1))
74
+
75
+
76
+
77
+ ## [9.0.0-beta.55](https://github.com/hatiolab/operato/compare/v9.0.0-beta.54...v9.0.0-beta.55) (2025-03-05)
78
+
79
+ **Note:** Version bump only for package @operato/data-grist
80
+
81
+
82
+
83
+
84
+
85
+ ## [9.0.0-beta.54](https://github.com/hatiolab/operato/compare/v9.0.0-beta.53...v9.0.0-beta.54) (2025-03-04)
86
+
87
+ **Note:** Version bump only for package @operato/data-grist
88
+
89
+
90
+
91
+
92
+
93
+ ## [9.0.0-beta.53](https://github.com/hatiolab/operato/compare/v9.0.0-beta.52...v9.0.0-beta.53) (2025-03-04)
94
+
95
+ **Note:** Version bump only for package @operato/data-grist
96
+
97
+
98
+
99
+
100
+
101
+ ## [9.0.0-beta.52](https://github.com/hatiolab/operato/compare/v9.0.0-beta.51...v9.0.0-beta.52) (2025-03-04)
102
+
103
+ **Note:** Version bump only for package @operato/data-grist
104
+
105
+
106
+
107
+
108
+
109
+ ## [9.0.0-beta.49](https://github.com/hatiolab/operato/compare/v9.0.0-beta.48...v9.0.0-beta.49) (2025-02-14)
110
+
111
+ **Note:** Version bump only for package @operato/data-grist
112
+
113
+
114
+
115
+
116
+
117
+ ## [9.0.0-beta.48](https://github.com/hatiolab/operato/compare/v9.0.0-beta.47...v9.0.0-beta.48) (2025-02-14)
118
+
119
+ **Note:** Version bump only for package @operato/data-grist
120
+
121
+
122
+
123
+
124
+
125
+ ## [9.0.0-beta.47](https://github.com/hatiolab/operato/compare/v9.0.0-beta.46...v9.0.0-beta.47) (2025-02-14)
126
+
127
+ **Note:** Version bump only for package @operato/data-grist
128
+
129
+
130
+
131
+
132
+
133
+ ## [9.0.0-beta.41](https://github.com/hatiolab/operato/compare/v9.0.0-beta.40...v9.0.0-beta.41) (2025-02-09)
134
+
135
+ **Note:** Version bump only for package @operato/data-grist
136
+
137
+
138
+
139
+
140
+
141
+ ## [9.0.0-beta.38](https://github.com/hatiolab/operato/compare/v9.0.0-beta.37...v9.0.0-beta.38) (2025-02-02)
142
+
143
+ **Note:** Version bump only for package @operato/data-grist
144
+
145
+
146
+
147
+
148
+
149
+ ## [9.0.0-beta.37](https://github.com/hatiolab/operato/compare/v9.0.0-beta.36...v9.0.0-beta.37) (2025-02-01)
150
+
151
+ **Note:** Version bump only for package @operato/data-grist
152
+
153
+
154
+
155
+
156
+
157
+ ## [9.0.0-beta.35](https://github.com/hatiolab/operato/compare/v9.0.0-beta.34...v9.0.0-beta.35) (2025-02-01)
158
+
159
+ **Note:** Version bump only for package @operato/data-grist
160
+
161
+
162
+
163
+
164
+
165
+ ## [9.0.0-beta.34](https://github.com/hatiolab/operato/compare/v9.0.0-beta.33...v9.0.0-beta.34) (2025-01-31)
166
+
167
+ **Note:** Version bump only for package @operato/data-grist
168
+
169
+
170
+
171
+
172
+
173
+ ## [9.0.0-beta.33](https://github.com/hatiolab/operato/compare/v9.0.0-beta.32...v9.0.0-beta.33) (2025-01-31)
174
+
175
+ **Note:** Version bump only for package @operato/data-grist
176
+
177
+
178
+
179
+
180
+
181
+ ## [9.0.0-beta.32](https://github.com/hatiolab/operato/compare/v9.0.0-beta.31...v9.0.0-beta.32) (2025-01-31)
182
+
183
+ **Note:** Version bump only for package @operato/data-grist
184
+
185
+
186
+
187
+
188
+
189
+ ## [9.0.0-beta.31](https://github.com/hatiolab/operato/compare/v9.0.0-beta.30...v9.0.0-beta.31) (2025-01-31)
190
+
191
+ **Note:** Version bump only for package @operato/data-grist
192
+
193
+
194
+
195
+
196
+
197
+ ## [9.0.0-beta.29](https://github.com/hatiolab/operato/compare/v9.0.0-beta.28...v9.0.0-beta.29) (2025-01-30)
198
+
199
+ **Note:** Version bump only for package @operato/data-grist
200
+
201
+
202
+
203
+
204
+
205
+ ## [9.0.0-beta.28](https://github.com/hatiolab/operato/compare/v9.0.0-beta.27...v9.0.0-beta.28) (2025-01-28)
206
+
207
+ **Note:** Version bump only for package @operato/data-grist
208
+
209
+
210
+
211
+
212
+
213
+ ## [9.0.0-beta.21](https://github.com/hatiolab/operato/compare/v9.0.0-beta.20...v9.0.0-beta.21) (2025-01-28)
214
+
215
+ **Note:** Version bump only for package @operato/data-grist
216
+
217
+
218
+
219
+
220
+
221
+ ## [9.0.0-beta.20](https://github.com/hatiolab/operato/compare/v9.0.0-beta.19...v9.0.0-beta.20) (2025-01-27)
222
+
223
+ **Note:** Version bump only for package @operato/data-grist
224
+
225
+
226
+
227
+
228
+
229
+ ## [9.0.0-beta.18](https://github.com/hatiolab/operato/compare/v9.0.0-beta.17...v9.0.0-beta.18) (2025-01-27)
230
+
231
+ **Note:** Version bump only for package @operato/data-grist
232
+
233
+
234
+
235
+
236
+
237
+ ## [9.0.0-beta.16](https://github.com/hatiolab/operato/compare/v9.0.0-beta.15...v9.0.0-beta.16) (2025-01-27)
238
+
239
+ **Note:** Version bump only for package @operato/data-grist
240
+
241
+
242
+
243
+
244
+
245
+ ## [9.0.0-beta.15](https://github.com/hatiolab/operato/compare/v9.0.0-beta.14...v9.0.0-beta.15) (2025-01-27)
246
+
247
+ **Note:** Version bump only for package @operato/data-grist
248
+
249
+
250
+
251
+
252
+
253
+ ## [9.0.0-beta.14](https://github.com/hatiolab/operato/compare/v9.0.0-beta.13...v9.0.0-beta.14) (2025-01-27)
254
+
255
+
256
+ ### :rocket: New Features
257
+
258
+ * module property-panel ([d78e4cf](https://github.com/hatiolab/operato/commit/d78e4cf7080b95fa74e61b42094b9f3f59f1409b))
259
+
260
+
261
+
262
+ ## [9.0.0-beta.11](https://github.com/hatiolab/operato/compare/v9.0.0-beta.10...v9.0.0-beta.11) (2025-01-25)
263
+
264
+
265
+ ### :bug: Bug Fix
266
+
267
+ * tsconfig option useDefineForClassFields=false ([0d77c0a](https://github.com/hatiolab/operato/commit/0d77c0aa620282c65b3c05f8e0b559e82836b6ab))
268
+
269
+
270
+
271
+ ## [9.0.0-beta.10](https://github.com/hatiolab/operato/compare/v9.0.0-beta.9...v9.0.0-beta.10) (2025-01-25)
272
+
273
+
274
+ ### :bug: Bug Fix
275
+
276
+ * i18next@24.2.1 ([1c5920c](https://github.com/hatiolab/operato/commit/1c5920c6f77d28f07051a0a49997b9fb1dbf08bf))
277
+ * tweak tsconfig.json ([3c424b1](https://github.com/hatiolab/operato/commit/3c424b18d046f95d5619076d113d49a4b4dc9bbb))
278
+
279
+
280
+
6
281
  ## [9.0.0-beta.7](https://github.com/hatiolab/operato/compare/v9.0.0-beta.6...v9.0.0-beta.7) (2025-01-20)
7
282
 
8
283
  **Note:** Version bump only for package @operato/data-grist
package/README.md CHANGED
@@ -1,95 +1,388 @@
1
- # \<data-grist>
1
+ # Data-Grist
2
2
 
3
- This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
3
+ Data-Grist is a powerful web component for displaying and manipulating data. It can present data in Grid, List, or Card formats and provides various features such as data sorting, filtering, editing, and more.
4
+
5
+ ## Key Features
6
+
7
+ - **Multiple Display Modes**: Flexibly display the same data in grid, list, or card formats
8
+ - **Data Manipulation**: Add, modify, and delete records
9
+ - **Sorting and Filtering**: Single/multi-column sorting, various filtering options
10
+ - **Editing Capabilities**: Inline cell editing, validation
11
+ - **Pagination**: Standard paging and infinite scroll support
12
+ - **Selection**: Single/multiple record selection
13
+ - **State Tracking**: Track changed (dirty) records
14
+ - **Customization**: Support for various renderers, editors, and event handlers
15
+ - **Mobile Responsive**: Responsive design support
4
16
 
5
17
  ## Installation
6
18
 
7
19
  ```bash
8
- npm i data-grist
20
+ npm install @operato/data-grist
9
21
  ```
10
22
 
11
- ## Usage
23
+ ## Basic Usage
12
24
 
13
25
  ```html
14
26
  <script type="module">
15
- import 'data-grist/data-grist.js';
27
+ import '@operato/data-grist/ox-grist.js'
16
28
  </script>
17
29
 
18
- <data-grist></data-grist>
30
+ <ox-grist
31
+ .mode=${'GRID'}
32
+ .config=${gridConfig}
33
+ .fetchHandler=${fetchDataFunction}
34
+ ></ox-grist>
19
35
  ```
20
36
 
21
- ## Linting with ESLint, Prettier, and Types
37
+ ## Modes
22
38
 
23
- To scan the project for linting errors, run
39
+ Data-Grist supports three display modes:
24
40
 
25
- ```bash
26
- npm run lint
41
+ - **GRID**: Tabular data display (default)
42
+ - **LIST**: Mobile-friendly list format display
43
+ - **CARD**: Card format display
44
+
45
+ ```javascript
46
+ // Set mode
47
+ gristElement.mode = 'GRID' // or 'LIST', 'CARD'
27
48
  ```
28
49
 
29
- You can lint with ESLint and Prettier individually as well
50
+ ## Configuration (Config)
51
+
52
+ Data-Grist provides various configuration options.
53
+
54
+ ```javascript
55
+ const config = {
56
+ columns: [
57
+ {
58
+ type: 'string',
59
+ name: 'name',
60
+ header: 'Name',
61
+ record: {
62
+ editable: true
63
+ },
64
+ sortable: true,
65
+ width: 150
66
+ }
67
+ // More columns...
68
+ ],
69
+ rows: {
70
+ appendable: true, // Allow adding new records
71
+ editable: true, // Allow editing records
72
+ selectable: {
73
+ // Record selection settings
74
+ multiple: true // Allow multiple selections
75
+ }
76
+ },
77
+ pagination: {
78
+ infinite: false, // Use paging instead of infinite scroll
79
+ page: 1, // Starting page
80
+ limit: 20 // Records per page
81
+ }
82
+ // Additional settings...
83
+ }
84
+ ```
30
85
 
31
- ```bash
32
- npm run lint:eslint
86
+ ### Column Types
87
+
88
+ ```javascript
89
+ // String column
90
+ {
91
+ type: 'string',
92
+ name: 'firstName',
93
+ header: 'First Name'
94
+ }
95
+
96
+ // Number column
97
+ {
98
+ type: 'number',
99
+ name: 'age',
100
+ header: 'Age',
101
+ record: {
102
+ align: 'right'
103
+ }
104
+ }
105
+
106
+ // Boolean column
107
+ {
108
+ type: 'boolean',
109
+ name: 'isActive',
110
+ header: 'Active'
111
+ }
112
+
113
+ // Link column
114
+ {
115
+ type: 'link',
116
+ name: 'website',
117
+ header: 'Website',
118
+ record: {
119
+ options: {
120
+ href: (column, record) => record.url,
121
+ target: '_blank'
122
+ }
123
+ }
124
+ }
125
+
126
+ // Gutter column (row number, checkbox, button, etc.)
127
+ {
128
+ type: 'gutter',
129
+ gutterName: 'sequence' // 'row-selector', 'button', 'dirty', etc.
130
+ }
33
131
  ```
34
132
 
35
- ```bash
36
- npm run lint:prettier
133
+ ## Fetching Data
134
+
135
+ Data can be retrieved through the `fetchHandler` function.
136
+
137
+ ```javascript
138
+ const fetchHandler = async params => {
139
+ const { page, limit, sorters, filters } = params
140
+
141
+ // Fetch data from server
142
+ const response = await fetch(`/api/data?page=${page}&limit=${limit}`)
143
+ const data = await response.json()
144
+
145
+ return {
146
+ total: data.total,
147
+ records: data.items
148
+ }
149
+ }
150
+
151
+ // Configure the grist
152
+ gristElement.fetchHandler = fetchHandler
37
153
  ```
38
154
 
39
- To automatically fix many linting errors, run
155
+ ## Record Manipulation API
40
156
 
41
- ```bash
42
- npm run format
157
+ ### Adding Records
158
+
159
+ ```javascript
160
+ // Add record at the end (default)
161
+ gristElement.addRecord({
162
+ name: 'John Doe',
163
+ age: 30
164
+ })
165
+
166
+ // Add record at the top
167
+ gristElement.addRecordToTop({
168
+ name: 'Jane Smith',
169
+ age: 25
170
+ })
43
171
  ```
44
172
 
45
- You can format using ESLint and Prettier individually as well
173
+ ### Record Selection
46
174
 
47
- ```bash
48
- npm run format:eslint
175
+ ```javascript
176
+ // Get all selected records
177
+ const selectedRecords = gristElement.selected
178
+
179
+ // Set selection
180
+ gristElement.selected = [record1, record2]
181
+
182
+ // Select records using a selector function
183
+ gristElement.select(record => record.age > 30)
49
184
  ```
50
185
 
51
- ```bash
52
- npm run format:prettier
186
+ ### Tracking Changed Records
187
+
188
+ ```javascript
189
+ // Get modified records
190
+ const dirtyRecords = gristElement.dirtyRecords
191
+
192
+ // Check for changes
193
+ gristElement.checkDirties()
194
+
195
+ // Export changes as patches
196
+ const patches = gristElement.exportPatchList()
53
197
  ```
54
198
 
55
- ## Testing with Web Test Runner
199
+ ## Events
56
200
 
57
- To run the suite of Web Test Runner tests, run
201
+ Data-Grist triggers various events.
58
202
 
59
- ```bash
60
- npm run test
203
+ ```javascript
204
+ // Record selection change event
205
+ gristElement.addEventListener('select-record-change', e => {
206
+ const { records, added, removed } = e.detail
207
+ console.log('Selected records:', records)
208
+ })
209
+
210
+ // Field change event
211
+ gristElement.addEventListener('field-change', e => {
212
+ const { after, before, column, record, row } = e.detail
213
+ console.log('Changed field:', column.name, 'from', before, 'to', after)
214
+ })
215
+
216
+ // Record change event
217
+ gristElement.addEventListener('record-change', e => {
218
+ const { before, after, column, row } = e.detail
219
+ console.log('Record changed:', row)
220
+ })
61
221
  ```
62
222
 
63
- To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run
223
+ ## Advanced Features
64
224
 
65
- ```bash
66
- npm run test:watch
225
+ ### Column Accumulation Feature (Accumulator)
226
+
227
+ ```javascript
228
+ {
229
+ type: 'number',
230
+ name: 'amount',
231
+ header: 'Amount',
232
+ accumulator: 'sum' // 'avg', 'count', 'min', 'max' or custom function
233
+ }
67
234
  ```
68
235
 
69
- ## Demoing with Storybook
236
+ ### Tree Structure Data
70
237
 
71
- To run a local instance of Storybook for your component, run
238
+ ```javascript
239
+ const config = {
240
+ // ...
241
+ tree: {
242
+ childrenProperty: 'children', // Property name where child nodes are stored
243
+ expanded: true // Initial tree expansion state
244
+ }
245
+ }
246
+ ```
72
247
 
73
- ```bash
74
- npm run storybook
248
+ ### Grouped Headers
249
+
250
+ ```javascript
251
+ const config = {
252
+ columns: [
253
+ // ...
254
+ {
255
+ type: 'string',
256
+ name: 'firstName',
257
+ header: 'First Name',
258
+ group: 'personalInfo'
259
+ },
260
+ {
261
+ type: 'string',
262
+ name: 'lastName',
263
+ header: 'Last Name',
264
+ group: 'personalInfo'
265
+ }
266
+ ],
267
+ // ...
268
+ rows: {
269
+ // ...
270
+ groups: [
271
+ {
272
+ name: 'personalInfo',
273
+ title: 'Personal Information'
274
+ }
275
+ ]
276
+ }
277
+ }
75
278
  ```
76
279
 
77
- To build a production version of Storybook, run
280
+ ### User Settings Storage
281
+
282
+ ```javascript
283
+ // Configure user settings provider
284
+ gristElement.personalConfigProvider = {
285
+ async load() {
286
+ // Load saved settings
287
+ return JSON.parse(localStorage.getItem('userGristConfig'))
288
+ },
289
+ async save(preference) {
290
+ // Save user settings
291
+ localStorage.setItem('userGristConfig', JSON.stringify(preference))
292
+ }
293
+ }
294
+ ```
78
295
 
79
- ```bash
80
- npm run storybook:build
296
+ ## Styling
297
+
298
+ Data-Grist can be styled through CSS variables.
299
+
300
+ ```css
301
+ ox-grist {
302
+ --grid-header-background-color: #f5f5f5;
303
+ --grid-record-background-color: white;
304
+ --grid-record-odd-background-color: #f9f9f9;
305
+ --grid-header-color: #333;
306
+ --grid-record-hover-background-color: #e9e9e9;
307
+ }
81
308
  ```
82
309
 
83
- ## Tooling configs
310
+ ## API Reference
311
+
312
+ ### Properties
313
+
314
+ | Property | Type | Description |
315
+ | ----------------- | -------- | ------------------------------------- |
316
+ | `mode` | string | Display mode ('GRID', 'LIST', 'CARD') |
317
+ | `config` | object | Grist configuration object |
318
+ | `data` | object | Data to display |
319
+ | `selectedRecords` | array | Array of selected records |
320
+ | `explicitFetch` | boolean | Enable explicit data fetching |
321
+ | `fetchHandler` | function | Data fetching function |
322
+ | `fetchOptions` | object | Data fetching options |
323
+ | `filters` | array | Array of filters |
324
+ | `sorters` | array | Array of sorters |
325
+ | `pagination` | object | Pagination settings |
326
+
327
+ ### Methods
328
+
329
+ | Method | Description |
330
+ | ------------------------------ | ------------------------------- |
331
+ | `fetch(reset)` | Fetch data |
332
+ | `addRecord(record)` | Add a record |
333
+ | `addRecordToTop(record)` | Add a record at the top |
334
+ | `deleteSelectedRecords(dirty)` | Delete selected records |
335
+ | `cloneSelectedRecords()` | Clone selected records |
336
+ | `checkDirties()` | Check for modified records |
337
+ | `undo()` | Undo last action |
338
+ | `redo()` | Redo undone action |
339
+ | `reset()` | Reset data |
340
+ | `commit()` | Commit changes |
341
+ | `select(selector, reset)` | Select records using a function |
342
+ | `exportPatchList(options)` | Export list of change patches |
343
+ | `exportRecords(options)` | Export record data |
344
+
345
+ ## Examples
346
+
347
+ ### Basic Grid
84
348
 
85
- For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
349
+ ```html
350
+ <ox-grist
351
+ .mode=${'GRID'}
352
+ .config=${gridConfig}
353
+ .fetchHandler=${fetchData}
354
+ @record-change=${handleRecordChange}
355
+ ></ox-grist>
356
+ ```
86
357
 
87
- If you customize the configuration a lot, you can consider moving them to individual files.
358
+ ### Editable Grid
88
359
 
89
- ## Local Demo with `web-dev-server`
360
+ ```html
361
+ <ox-grist
362
+ .mode=${'GRID'}
363
+ .config=${{
364
+ columns: [/* column definitions */],
365
+ rows: {
366
+ appendable: true,
367
+ editable: true,
368
+ selectable: { multiple: true }
369
+ }
370
+ }}
371
+ .data=${{ records: initialData }}
372
+ ></ox-grist>
373
+ ```
90
374
 
91
- ```bash
92
- npm start
375
+ ### Add Row to Top Button
376
+
377
+ ```html
378
+ <button @click="${() => gristRef.addRecordToTop()}">Add Row to Top</button>
379
+ <ox-grist id="my-grist"></ox-grist>
380
+
381
+ <script>
382
+ const gristRef = document.getElementById('my-grist')
383
+ </script>
93
384
  ```
94
385
 
95
- To run a local development server that serves the basic demo located in `demo/index.html`
386
+ ## License
387
+
388
+ MIT