@operato/data-grist 2.0.0-alpha.2 → 2.0.0-alpha.20

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 (75) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/dist/src/accumulator/accumulator.js +4 -4
  3. package/dist/src/accumulator/accumulator.js.map +1 -1
  4. package/dist/src/configure/rows-option-builder.js +2 -1
  5. package/dist/src/configure/rows-option-builder.js.map +1 -1
  6. package/dist/src/configure/zero-config.js +1 -0
  7. package/dist/src/configure/zero-config.js.map +1 -1
  8. package/dist/src/data-card/event-handlers/record-card-click-handler.js +1 -1
  9. package/dist/src/data-card/event-handlers/record-card-click-handler.js.map +1 -1
  10. package/dist/src/data-grid/data-grid-accum-field.js +3 -2
  11. package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
  12. package/dist/src/data-grid/data-grid-body.js +3 -1
  13. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  14. package/dist/src/data-grid/data-grid-header.d.ts +1 -0
  15. package/dist/src/data-grid/data-grid-header.js +16 -14
  16. package/dist/src/data-grid/data-grid-header.js.map +1 -1
  17. package/dist/src/data-grist.d.ts +225 -3
  18. package/dist/src/data-grist.js +195 -3
  19. package/dist/src/data-grist.js.map +1 -1
  20. package/dist/src/data-list/event-handlers/record-partial-click-handler.js +1 -1
  21. package/dist/src/data-list/event-handlers/record-partial-click-handler.js.map +1 -1
  22. package/dist/src/data-manipulator.d.ts +6 -4
  23. package/dist/src/data-manipulator.js +91 -21
  24. package/dist/src/data-manipulator.js.map +1 -1
  25. package/dist/src/editors/ox-grist-editor-number.js +2 -2
  26. package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
  27. package/dist/src/editors/ox-grist-editor.js +5 -1
  28. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  29. package/dist/src/editors/ox-input-tree.js +1 -1
  30. package/dist/src/editors/ox-input-tree.js.map +1 -1
  31. package/dist/src/handlers/contextmenu-tree-mutation.js +1 -19
  32. package/dist/src/handlers/contextmenu-tree-mutation.js.map +1 -1
  33. package/dist/src/renderers/ox-grist-renderer-tree.js +1 -1
  34. package/dist/src/renderers/ox-grist-renderer-tree.js.map +1 -1
  35. package/dist/src/types.d.ts +435 -4
  36. package/dist/src/types.js +9 -0
  37. package/dist/src/types.js.map +1 -1
  38. package/dist/stories/accumulator.stories.js +10 -5
  39. package/dist/stories/accumulator.stories.js.map +1 -1
  40. package/dist/stories/dynamic-editable.stories.js +10 -0
  41. package/dist/stories/dynamic-editable.stories.js.map +1 -1
  42. package/dist/stories/fixed-column.stories.js +3 -3
  43. package/dist/stories/fixed-column.stories.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/docs/gutter/gutter.md +7 -0
  46. package/package.json +5 -5
  47. package/src/accumulator/accumulator.ts +4 -4
  48. package/src/configure/rows-option-builder.ts +11 -1
  49. package/src/configure/zero-config.ts +1 -0
  50. package/src/data-card/event-handlers/record-card-click-handler.ts +1 -1
  51. package/src/data-grid/data-grid-accum-field.ts +3 -2
  52. package/src/data-grid/data-grid-body.ts +3 -1
  53. package/src/data-grid/data-grid-header.ts +22 -18
  54. package/src/data-grist.ts +250 -3
  55. package/src/data-list/event-handlers/record-partial-click-handler.ts +1 -1
  56. package/src/data-manipulator.ts +113 -22
  57. package/src/editors/ox-grist-editor-number.ts +3 -2
  58. package/src/editors/ox-grist-editor.ts +5 -1
  59. package/src/editors/ox-input-tree.ts +1 -1
  60. package/src/handlers/contextmenu-tree-mutation.ts +1 -19
  61. package/src/renderers/ox-grist-renderer-tree.ts +1 -1
  62. package/src/types.ts +443 -4
  63. package/stories/accumulator.stories.ts +10 -5
  64. package/stories/dynamic-editable.stories.ts +10 -0
  65. package/stories/fixed-column.stories.ts +3 -3
  66. package/themes/grist-theme.css +1 -1
  67. package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.d.ts +0 -7
  68. package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.js +0 -19
  69. package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.js.map +0 -1
  70. package/dist/src/handlers/contextmenu-tree.d.ts +0 -3
  71. package/dist/src/handlers/contextmenu-tree.js +0 -30
  72. package/dist/src/handlers/contextmenu-tree.js.map +0 -1
  73. package/dist/src/handlers/move-up copy.d.ts +0 -3
  74. package/dist/src/handlers/move-up copy.js +0 -26
  75. package/dist/src/handlers/move-up copy.js.map +0 -1
package/src/types.ts CHANGED
@@ -12,6 +12,18 @@ import { OxGristEditor } from './editors'
12
12
  import { QueryFilter } from './filters'
13
13
  import { OxGristRenderer } from './renderers/ox-grist-renderer'
14
14
 
15
+ /**
16
+ * Configuration object for defining the structure and behavior of a Grist table.
17
+ *
18
+ * @typedef {Object} GristConfig
19
+ * @property {ColumnConfig[]} columns - An array of column configurations.
20
+ * @property {RowsConfig} rows - Configuration for rows and their behavior.
21
+ * @property {ListConfig} list - Configuration for the list view.
22
+ * @property {TreeConfig} tree - Configuration for tree-related settings.
23
+ * @property {PaginationConfig} [pagination] - Configuration for pagination settings (optional).
24
+ * @property {SortersConfig} [sorters] - Configuration for sorting settings (optional).
25
+ * @property {FiltersConfig} [filters] - Configuration for filtering settings (optional).
26
+ */
15
27
  export type GristConfig = {
16
28
  columns: ColumnConfig[]
17
29
  rows: RowsConfig
@@ -22,8 +34,29 @@ export type GristConfig = {
22
34
  filters?: FiltersConfig
23
35
  }
24
36
 
37
+ /**
38
+ * Configuration object for specifying sorting options.
39
+ *
40
+ * @typedef {Object} SorterConfig
41
+ * @property {string} name - The name of the sorting option.
42
+ * @property {boolean} [desc] - Optional. Indicates whether the sorting is in descending order (optional).
43
+ */
25
44
  export type SorterConfig = { name: string; desc?: boolean }
45
+
46
+ /**
47
+ * Configuration array for specifying multiple sorting options.
48
+ *
49
+ * @typedef {SorterConfig[]} SortersConfig
50
+ */
26
51
  export type SortersConfig = SorterConfig[]
52
+
53
+ /**
54
+ * Enumeration of filter operators used to define filter conditions.
55
+ *
56
+ * @typedef {'search' | 'eq' | 'between' | 'gte' | 'lte' | 'is_not_true' | 'in' | 'like' | 'i_like' | 'noteq' |
57
+ * 'is_empty_num_id' | 'is_blank' | 'is_present' | 'is_not_false' | 'is_true' | 'is_false' | 'is_not_null' |
58
+ * 'is_null' | 'notin_with_null' | 'notin' | 'gt' | 'lt' | 'i_nlike' | 'nlike'} FilterOperator
59
+ */
27
60
  export type FilterOperator =
28
61
  | 'search'
29
62
  | 'eq'
@@ -50,6 +83,16 @@ export type FilterOperator =
50
83
  | 'i_nlike'
51
84
  | 'nlike'
52
85
 
86
+ /**
87
+ * Configuration object for specifying filter conditions.
88
+ *
89
+ * @typedef {Object} FilterConfigObject
90
+ * @property {string} type - The type of the filter condition.
91
+ * @property {FilterOperator} [operator] - The filter operator used to compare values (optional).
92
+ * @property {Object} [options] - Additional options or parameters for the filter condition (optional).
93
+ * @property {string|number|boolean|string[]|number[]|undefined} [value] - The value to compare with in the filter condition (optional).
94
+ * @property {string} [label] - The label to display for the filter condition (optional).
95
+ */
53
96
  export type FilterConfigObject = {
54
97
  type: string
55
98
  operator?: FilterOperator
@@ -57,8 +100,31 @@ export type FilterConfigObject = {
57
100
  value?: string | number | boolean | string[] | number[] | undefined
58
101
  label?: string
59
102
  }
103
+
104
+ /**
105
+ * Configuration option for specifying filter conditions.
106
+ *
107
+ * The `FilterConfig` type can take one of the following forms:
108
+ * - A `FilterConfigObject` representing a specific filter condition.
109
+ * - A `FilterOperator` representing a predefined filter operator.
110
+ * - A boolean value to enable or disable filtering for a specific column.
111
+ *
112
+ * @typedef {Object|FilterOperator|boolean} FilterConfig
113
+ */
60
114
  export type FilterConfig = FilterConfigObject | FilterOperator | boolean
61
115
 
116
+ /**
117
+ * Represents a filter condition with the following properties:
118
+ *
119
+ * - `name`: The name of the column or field being filtered.
120
+ * - `operator`: The filter operator used for comparison.
121
+ * - `value`: The value or values to compare against.
122
+ *
123
+ * @typedef {Object} FilterValue
124
+ * @property {string} name - The name of the column or field.
125
+ * @property {FilterOperator} operator - The filter operator.
126
+ * @property {string|number|boolean|string[]|number[]|undefined} value - The value(s) to compare.
127
+ */
62
128
  export type FilterValue = {
63
129
  name: string
64
130
  operator: FilterOperator
@@ -67,14 +133,23 @@ export type FilterValue = {
67
133
 
68
134
  /**
69
135
  * Configuration options for filters.
136
+ *
137
+ * @typedef {Object} FiltersConfig
138
+ * @property {boolean} [header] - Specifies whether to provide filtering functionality in the header.
70
139
  */
71
140
  export type FiltersConfig = {
72
- /**
73
- * Specifies whether to provide filtering functionality in the header.
74
- */
75
141
  header?: boolean
76
142
  }
77
143
 
144
+ /**
145
+ * Configuration options for pagination.
146
+ *
147
+ * @typedef {Object} PaginationConfig
148
+ * @property {number} [page] - The current page number.
149
+ * @property {number} [limit] - The maximum number of records to display per page.
150
+ * @property {number[]} [pages] - An array of available page numbers.
151
+ * @property {boolean} [infinite] - Specifies whether to use infinite scrolling for pagination.
152
+ */
78
153
  export type PaginationConfig = {
79
154
  page?: number
80
155
  limit?: number
@@ -82,12 +157,33 @@ export type PaginationConfig = {
82
157
  infinite?: boolean
83
158
  }
84
159
 
160
+ /**
161
+ * Option to specify the inheritance behavior for including data from parent domains.
162
+ *
163
+ * - 'None': Do not include data from the parent domain.
164
+ * - 'Include': Include data from the parent domain along with current domain data.
165
+ * - 'Only': Include data only from the parent domain, excluding current domain data.
166
+ *
167
+ * @enum {string}
168
+ */
85
169
  export enum InheritedValueType {
86
170
  None = 'None',
87
171
  Include = 'Include',
88
172
  Only = 'Only'
89
173
  }
90
174
 
175
+ /**
176
+ * Configuration options for fetching data from a data source.
177
+ *
178
+ * @typedef {Object} FetchOption
179
+ * @property {number} [page] - The page number to retrieve.
180
+ * @property {number} [limit] - The maximum number of records to retrieve per page.
181
+ * @property {SortersConfig} [sorters] - An array of sorting configurations for data. Only one of these options needs to be set.
182
+ * @property {SortersConfig} [sortings] - An array of sorting configurations for data. Only one of these options needs to be set.
183
+ * @property {QueryFilter[]} [filters] - An array of filtering criteria.
184
+ * @property {InheritedValueType} [inherited] - Specifies the inheritance behavior for including data from parent domains.
185
+ * @property {object} [options] - Additional options for customizing data fetching behavior.
186
+ */
91
187
  export type FetchOption = {
92
188
  page?: number
93
189
  limit?: number
@@ -97,14 +193,44 @@ export type FetchOption = {
97
193
  inherited?: InheritedValueType
98
194
  options?: object
99
195
  }
196
+
197
+ /**
198
+ * Represents the result of a data fetching operation.
199
+ *
200
+ * @typedef {Object} FetchResult
201
+ * @property {number} [page] - The page number of the fetched data.
202
+ * @property {number} [limit] - The maximum number of records per page.
203
+ * @property {number} total - The total number of records in the data source.
204
+ * @property {GristRecord[]} records - An array of fetched data records.
205
+ */
100
206
  export type FetchResult = {
101
207
  page?: number
102
208
  limit?: number
103
209
  total: number
104
210
  records: GristRecord[]
105
211
  } | void
212
+
213
+ /**
214
+ * A function that handles data fetching operations.
215
+ *
216
+ * @param param - The fetch options specifying how data should be retrieved.
217
+ * @returns A promise that resolves to a `FetchResult`.
218
+ */
106
219
  export type FetchHandler = (param: FetchOption) => Promise<FetchResult>
107
220
 
221
+ /**
222
+ * Represents a Grist event handler function.
223
+ *
224
+ * @typedef {Function} GristEventHandler
225
+ * @param {ColumnConfig[]} columns - An array of column configurations.
226
+ * @param {GristData} [data] - The Grist data associated with the event.
227
+ * @param {ColumnConfig} [column] - The column configuration related to the event (if applicable).
228
+ * @param {GristRecord} [record] - The Grist record related to the event (if applicable).
229
+ * @param {number} [rowIndex] - The index of the row related to the event (if applicable).
230
+ * @param {any} [target] - The target element or object related to the event (if applicable).
231
+ * @param {Event} [e] - The event object (if applicable).
232
+ * @returns {void}
233
+ */
108
234
  export type GristEventHandler = (
109
235
  columns: ColumnConfig[],
110
236
  data?: GristData,
@@ -115,6 +241,14 @@ export type GristEventHandler = (
115
241
  e?: Event
116
242
  ) => void
117
243
 
244
+ /**
245
+ * Represents an accumulator function for data aggregation and accumulation.
246
+ *
247
+ * @typedef {string|'sum'|'avg'|'count'|'min'|'max'|Function} AccumulatorFunc
248
+ * @param {GristData} data - The Grist data for aggregation.
249
+ * @param {ColumnConfig} column - The column configuration for aggregation.
250
+ * @returns {string|number} - The aggregated result.
251
+ */
118
252
  export type AccumulatorFunc =
119
253
  | 'sum'
120
254
  | 'avg'
@@ -123,6 +257,27 @@ export type AccumulatorFunc =
123
257
  | 'max'
124
258
  | ((data: GristData, column: ColumnConfig) => string | number)
125
259
 
260
+ /**
261
+ * Type representing an accumulator function or configuration object.
262
+ *
263
+ * An accumulator is used for data aggregation and accumulation purposes. It can be either
264
+ * a predefined accumulator function (e.g., 'sum', 'avg', 'count', etc.) or a configuration
265
+ * object specifying the type of accumulator and labeling options.
266
+ *
267
+ * @typedef {AccumulatorFunc|{type: AccumulatorFunc, tag?: boolean}} AccumulatorObject
268
+ * @property {AccumulatorFunc} [type] - The type of accumulator function or predefined function name.
269
+ * @property {boolean} [tag] - An option for adding a label to represent the result of an aggregation function. This label is added in front of the aggregated value.
270
+ *
271
+ * @example
272
+ * // Using a predefined accumulator function:
273
+ * const accumulator: AccumulatorObject = 'sum'; // Represents a 'sum' accumulator.
274
+ *
275
+ * // Using an accumulator configuration object:
276
+ * const accumulatorConfig: AccumulatorObject = {
277
+ * type: 'avg', // Specifies the type of accumulator ('avg' for average).
278
+ * tag: true, // Option for adding a label to represent the result of an aggregation function. This label is added in front of the aggregated value.
279
+ * };
280
+ */
126
281
  export type AccumulatorObject =
127
282
  | AccumulatorFunc
128
283
  | {
@@ -130,10 +285,45 @@ export type AccumulatorObject =
130
285
  tag?: boolean
131
286
  }
132
287
 
288
+ /**
289
+ * Type representing column configuration information.
290
+ *
291
+ * @typedef {object} ColumnConfig
292
+ * @property {string} type - Represents the data type of the column (e.g., 'text', 'number', 'date', 'gutter', etc.).
293
+ * @property {string} name - Represents the name of the column.
294
+ * @property {('button'|'sequence'|'row-selector'|'dirty')} [gutterName] - If the column type is 'gutter', specifies the name of one of the registered gutters (only set when the type is 'gutter').
295
+ * @property {boolean} [fixed] - In case of a grid type column, specifies whether the column's position should be fixed and unaffected by horizontal scrolling (optional).
296
+ * @property {HeaderConfig} header - Object representing the header configuration of the column.
297
+ * @property {RecordConfig} record - Object representing the record configuration of the column.
298
+ * @property {GristEventHandlerSet} handlers - Object representing the Grist event handler settings.
299
+ * @property {LabelConfig} label - Object representing the label configuration of the column. This property is used to represent the label of the column's information in list mode, card mode, and when displaying the column in a filter form (ox-filters-form).
300
+ * @property {boolean} [hidden] - Indicates whether the column is hidden or not (optional).
301
+ * @property {boolean} [sortable] - Indicates whether the column is sortable or not (optional). If this setting is true, the header provides the ability to toggle the sorting direction.
302
+ * @property {boolean} [resizable] - Indicates whether the column is resizable or not (optional). This setting determines whether the column's width can be adjusted.
303
+ * @property {(number|string|ColumnWidthCallback)} [width] - Represents the width of the column (e.g., 100, '50%', or a callback function to calculate width).
304
+ * @property {boolean} [forList] - Indicates whether the column is intended for display in list mode (optional, applicable only to gutter type columns).
305
+ * @property {boolean} [forCard] - Indicates whether the column is intended for display in card mode (optional, applicable only to gutter type columns).
306
+ * @property {ValidationCallback} [validation] - Callback function for column validation (optional). This function validates whether the value of the column is valid when edited.
307
+ * @property {AccumulatorObject} [accumulator] - Object used for accumulating values of the column (optional, applicable only in grid mode). It specifies a function to automatically aggregate the values of the column for all records. The aggregated result is displayed in a row below the last record (accumulation record).
308
+ * @property {FilterConfig} [filter] - Object representing the filter configuration of the column.
309
+ * @property {(ImexConfig|boolean)} [imex] - Object or boolean value representing the configuration for importing and exporting column data.
310
+ * @property {boolean} [multiple] - Indicates whether the column allows multiple selections or not (optional).
311
+ * @property {boolean} [rowCount] - Indicates whether the column shows the row count or not (optional).
312
+ */
133
313
  export type ColumnConfig = {
134
314
  type: string
135
315
  name: string
136
- gutterName?: string
316
+ /**
317
+ * "gutter" 타입의 컬럼인 경우, 등록된 gutter들 중의 하나의 이름을 명시합니다(type이 gutter인 경우에만 설정합니다).
318
+ * (e.g., 'button', 'sequence', 'row-selector', 'dirty', etc)
319
+ *
320
+ * "Gutter"는 테이블 형태에서 각 행의 왼쪽 또는 오른쪽에 위치한 추가적인 열(column)을 가리킵니다.
321
+ * 이 열은 주로 각 행(row)을 식별하거나 특정 작업을 수행하기 위한 버튼 또는 링크와 같은 요소를 표시하는 데 사용됩니다.
322
+ * Gutter 열은 주로 데이터 행에 대한 조작 또는 행의 상태를 나타내는 데 사용됩니다.
323
+ * 예를 들어, 테이블에서 각 행이 특정 작업을 수행하는 버튼을 포함할 때, 이러한 버튼이 Gutter 열에 배치될 수 있습니다.
324
+ * 또한 Gutter 열은 행을 선택하거나 행의 상태를 나타내는 체크박스를 포함할 수도 있습니다.
325
+ */
326
+ gutterName?: 'button' | 'sequence' | 'row-selector' | 'dirty'
137
327
  fixed?: boolean
138
328
  header: HeaderConfig
139
329
  record: RecordConfig
@@ -144,6 +334,7 @@ export type ColumnConfig = {
144
334
  resizable?: boolean
145
335
  width?: number | string | ColumnWidthCallback
146
336
  forList?: boolean
337
+ forCard?: boolean
147
338
  validation?: ValidationCallback
148
339
  accumulator?: AccumulatorObject
149
340
  filter?: FilterConfig
@@ -152,8 +343,40 @@ export type ColumnConfig = {
152
343
  rowCount?: boolean
153
344
  }
154
345
 
346
+ /**
347
+ * Callback function type for column validation.
348
+ *
349
+ * This function is used to validate whether the value of a column is valid when edited.
350
+ *
351
+ * @callback ValidationCallback
352
+ * @param {any} after - The new value of the column after editing.
353
+ * @param {any} before - The previous value of the column before editing.
354
+ * @param {GristRecord} record - The record being edited.
355
+ * @param {ColumnConfig} column - The configuration of the column being edited.
356
+ * @returns {boolean} - Returns `true` if the value is valid, `false` otherwise.
357
+ */
155
358
  export type ValidationCallback = (after: any, before: any, record: GristRecord, column: ColumnConfig) => boolean
156
359
 
360
+ /**
361
+ * Configuration options for column labels.
362
+ *
363
+ * The label for a column can be customized using various options.
364
+ *
365
+ * @typedef {string|boolean|Object} LabelConfig
366
+ * @property {LabelRenderer} [renderer] - A custom renderer function for the column label.
367
+ *
368
+ * @example
369
+ * // Using a string as a label:
370
+ * const label: LabelConfig = "Column Label"; // Sets the label as "Column Label".
371
+ *
372
+ * // Using a boolean to determine label visibility:
373
+ * const label: LabelConfig = true; // Shows the default label based on the header configuration.
374
+ *
375
+ * // Using a custom renderer function for the label:
376
+ * const label: LabelConfig = {
377
+ * renderer: customLabelRenderer, // Specifies a custom renderer function.
378
+ * };
379
+ */
157
380
  export type LabelConfig =
158
381
  | string
159
382
  | boolean
@@ -161,19 +384,68 @@ export type LabelConfig =
161
384
  renderer: LabelRenderer
162
385
  }
163
386
 
387
+ /**
388
+ * Custom label renderer function for generating column labels.
389
+ *
390
+ * @callback LabelRenderer
391
+ * @param {ColumnConfig} column - The column configuration object for which the label is being generated.
392
+ * @returns {void}
393
+ */
164
394
  export type LabelRenderer = (column: ColumnConfig) => void
165
395
 
396
+ /**
397
+ * Custom callback function for calculating column width.
398
+ *
399
+ * @callback ColumnWidthCallback
400
+ * @param {ColumnConfig} column - The column configuration object for which the width is being calculated.
401
+ * @returns {string} - The calculated width as a string (e.g., '100', '50%').
402
+ */
166
403
  export type ColumnWidthCallback = (column: ColumnConfig) => string
167
404
 
405
+ /**
406
+ * Configuration for defining the header of a column.
407
+ *
408
+ * @typedef {Object} HeaderConfig
409
+ * @property {HeaderRenderer} renderer - The function used to render the column header.
410
+ * @property {string} [style] - Optional CSS style for the column header.
411
+ * @property {string} [group] - Optional group identifier for the column header.
412
+ * @property {string} [groupStyle] - Optional CSS style for the header group.
413
+ */
168
414
  export type HeaderConfig = {
169
415
  renderer: HeaderRenderer
170
416
  style?: string
171
417
  group?: string
172
418
  groupStyle?: string
173
419
  }
420
+
421
+ /**
422
+ * Function type for rendering column headers.
423
+ *
424
+ * @callback HeaderRenderer
425
+ * @param {ColumnConfig} column - The column configuration object.
426
+ * @returns {*} - The rendered header content.
427
+ */
174
428
  export type HeaderRenderer = (column: ColumnConfig) => any
175
429
 
430
+ /**
431
+ * Function type for generating values.
432
+ *
433
+ * @callback ValueGeneratorFn
434
+ * @param {...any} args - The arguments used for generating a value.
435
+ * @returns {*} - The generated value.
436
+ */
176
437
  export type ValueGeneratorFn = (...args: any[]) => any
438
+
439
+ /**
440
+ * Configuration for specifying default values for fields in a record.
441
+ * Default values can be set using predefined value generator functions or custom user-defined functions.
442
+ * This configuration allows you to define the default value generation method and any additional parameters.
443
+ *
444
+ * @typedef {Object|Function} DefaultValueFnConfig
445
+ * @property {string} [name] - The name of the default value function to be used for the column.
446
+ * @property {any[]} [params] - The parameters to be passed to the default value function.
447
+ * @property {Function} [Function] - A custom user-defined function for generating default values.
448
+ */
177
449
  export type DefaultValueFnConfig =
178
450
  | {
179
451
  /**
@@ -188,6 +460,24 @@ export type DefaultValueFnConfig =
188
460
  }
189
461
  | Function
190
462
 
463
+ /**
464
+ * Configuration for defining fields within a record.
465
+ * Each field can have various settings such as rendering, editing, alignment, etc.
466
+ * The 'defaultValue' property is used to specify the default value generation method and parameters.
467
+ *
468
+ * @typedef {Object} RecordConfig
469
+ * @property {FieldRenderer} renderer - The rendering function for the field.
470
+ * @property {FieldEditor|undefined} [editor] - The editing function for the field (optional).
471
+ * @property {boolean|Function} [editable] - Specifies if the field is editable. It can be a boolean or a function (optional).
472
+ * @property {boolean} [mandatory] - Specifies if the field is mandatory (optional).
473
+ * @property {GristClassifier} classifier - A classifier function for the field.
474
+ * @property {'left'|'right'|'center'} [align] - The alignment of the field's content (optional).
475
+ * @property {*} options - Additional options for the field.
476
+ * @property {string|undefined} [rowOptionField] - The name of a field for row-level options associated with this field (optional).
477
+ * @property {DefaultValueFnConfig|undefined} [defaultValue] - Configuration for specifying the default value for the field.
478
+ * It can be a predefined value generator function or a custom user-defined function (optional).
479
+ * @property {Object.<string, *>|undefined} [extended] - Additional extended properties that can be added as needed for specific field configurations (optional).
480
+ */
191
481
  export type RecordConfig = {
192
482
  renderer: FieldRenderer
193
483
  editor?: FieldEditor
@@ -201,6 +491,17 @@ export type RecordConfig = {
201
491
  [extended: string]: any
202
492
  }
203
493
 
494
+ /**
495
+ * A function type used for rendering the content of a field in various components.
496
+ *
497
+ * @callback FieldRenderer
498
+ * @param {*} value - The value of the field to be rendered.
499
+ * @param {ColumnConfig} column - The configuration of the column to which the field belongs.
500
+ * @param {GristRecord} record - The record object containing the field's data.
501
+ * @param {number} rowIndex - The index of the row to which the field belongs.
502
+ * @param {DataGridField|RecordCard|DataCardGutter|DataCardField|DataListGutter|DataListField|RecordPartial|DataReportField|Element} owner - The component or element that owns the field.
503
+ * @returns {OxGristRenderer|TemplateResult|string|void} - The rendered content, which can be of different types depending on the implementation.
504
+ */
204
505
  export type FieldRenderer = (
205
506
  value: any,
206
507
  column: ColumnConfig,
@@ -217,6 +518,18 @@ export type FieldRenderer = (
217
518
  | DataReportField
218
519
  | Element
219
520
  ) => OxGristRenderer | TemplateResult | string | void
521
+
522
+ /**
523
+ * A function type used for defining a custom editor for a field in a data grid.
524
+ *
525
+ * @callback FieldEditor
526
+ * @param {*} value - The current value of the field.
527
+ * @param {ColumnConfig} column - The configuration of the column to which the field belongs.
528
+ * @param {GristRecord} record - The record object containing the field's data.
529
+ * @param {number} rowIndex - The index of the row to which the field belongs.
530
+ * @param {DataGridField} field - The data grid field that owns the editor.
531
+ * @returns {OxGristEditor} - The custom editor component.
532
+ */
220
533
  export type FieldEditor = (
221
534
  value: any,
222
535
  column: ColumnConfig,
@@ -225,12 +538,30 @@ export type FieldEditor = (
225
538
  field: DataGridField
226
539
  ) => OxGristEditor
227
540
 
541
+ /**
542
+ * A function type used for rendering the filter select options in a filter form.
543
+ *
544
+ * @callback FilterSelectRenderer
545
+ * @param {ColumnConfig} column - The configuration of the column for which the filter is being rendered.
546
+ * @param {(string|number|boolean|string[]|number[]|any|undefined)} value - The current value of the filter.
547
+ * @param {Element} owner - The DOM element that owns the filter select renderer.
548
+ * @returns {(TemplateResult|string|void)} - The rendered filter select options as a Lit HTML template result, a string, or nothing.
549
+ */
228
550
  export type FilterSelectRenderer = (
229
551
  column: ColumnConfig,
230
552
  value: string | number | boolean | string[] | number[] | any | undefined,
231
553
  owner: Element
232
554
  ) => TemplateResult | string | void
233
555
 
556
+ /**
557
+ * An object representing a set of event handler functions for various events in Grist.
558
+ *
559
+ * @typedef {Object} GristEventHandlerSet
560
+ * @property {GristEventHandler} [click] - The click event handler function.
561
+ * @property {GristEventHandler} [dblclick] - The double-click event handler function.
562
+ * @property {GristEventHandler} [focus] - The focus event handler function.
563
+ * @property {GristEventHandler} [contextmenu] - The context menu event handler function.
564
+ */
234
565
  export type GristEventHandlerSet = {
235
566
  click?: GristEventHandler
236
567
  dblclick?: GristEventHandler
@@ -238,17 +569,41 @@ export type GristEventHandlerSet = {
238
569
  contextmenu?: GristEventHandler
239
570
  }
240
571
 
572
+ /**
573
+ * Configuration options for defining how records are displayed in list mode in a Grist.
574
+ *
575
+ * @typedef {Object} ListConfig
576
+ * @property {string} [thumbnail] - The name of the field to use as a thumbnail image for records in list mode.
577
+ * @property {string[]} fields - An array of field names to display in the list mode.
578
+ * @property {string[]} details - An array of field names to display as additional details in the list mode.
579
+ */
241
580
  export type ListConfig = {
242
581
  thumbnail?: string
243
582
  fields: string[]
244
583
  details: string[]
245
584
  }
246
585
 
586
+ /**
587
+ * Configuration options for managing tree-like structures in a Grist table.
588
+ *
589
+ * @typedef {Object} TreeConfig
590
+ * @property {string} [childrenProperty] - The property name that specifies the children of a record.
591
+ * @property {boolean | Function} [expanded] - Specifies whether tree nodes are initially expanded or a function to determine the initial expansion state for a given record.
592
+ */
247
593
  export type TreeConfig = {
248
594
  childrenProperty?: string
249
595
  expanded?: boolean | ((x: GristRecord) => boolean)
250
596
  }
251
597
 
598
+ /**
599
+ * Configuration options for importing and exporting column data.
600
+ *
601
+ * @typedef {Object} ImexConfig
602
+ * @property {string} header - The header text for the column in import/export settings.
603
+ * @property {string} key - The key or identifier for the column in import/export settings.
604
+ * @property {number} width - The width of the column in import/export settings.
605
+ * @property {string} type - The data type of the column in import/export settings.
606
+ */
252
607
  export type ImexConfig = {
253
608
  header: string
254
609
  key: string
@@ -256,9 +611,23 @@ export type ImexConfig = {
256
611
  type: string
257
612
  }
258
613
 
614
+ /**
615
+ * Configuration options for defining rows within a Grist table or view.
616
+ *
617
+ * @typedef {Object} RowsConfig
618
+ * @property {boolean} [accumulator] - Specifies whether an accumulator row should be displayed.
619
+ * @property {boolean} appendable - Indicates whether new rows can be appended to the table.
620
+ * @property {boolean} insertable - Indicates whether new rows can be inserted into the table.
621
+ * @property {RowSelectableConfig} [selectable] - Configuration for row selection options.
622
+ * @property {GroupConfig[]} groups - An array of group configuration options.
623
+ * @property {string[]} totals - An array of field names for which totals should be calculated and displayed.
624
+ * @property {GristClassifier} classifier - A function that classifies rows based on their attributes.
625
+ * @property {GristEventHandlerSet} handlers - An object containing event handler functions for various row-level events.
626
+ */
259
627
  export type RowsConfig = {
260
628
  accumulator?: boolean
261
629
  appendable: boolean
630
+ editable: boolean
262
631
  insertable: boolean
263
632
  selectable?: RowSelectableConfig
264
633
  groups: GroupConfig[]
@@ -267,11 +636,38 @@ export type RowsConfig = {
267
636
  handlers: GristEventHandlerSet
268
637
  }
269
638
 
639
+ /**
640
+ * A function used to classify and style individual records in a Grist table.
641
+ *
642
+ * @typedef {Function} GristClassifier
643
+ *
644
+ * @param {GristRecord} record - The record to be classified.
645
+ * @param {number} rowIndex - The index of the row in the table.
646
+ *
647
+ * @returns {Object|void} An object containing classification properties or `void`.
648
+ * - `emphasized` (optional): A boolean, string, or array of strings indicating the emphasis style.
649
+ * - Additional properties can be added as needed for custom styling.
650
+ */
270
651
  export type GristClassifier = (
271
652
  record: GristRecord,
272
653
  rowIndex: number
273
654
  ) => { emphasized?: boolean | string | string[]; [key: string]: any } | void
274
655
 
656
+ /**
657
+ * Configuration options for defining group headers in a Grist table.
658
+ *
659
+ * @typedef {Object} GroupConfig
660
+ *
661
+ * @property {string} align - The alignment of the group header ('left', 'center', or 'right').
662
+ * @property {ColumnConfig} [titleColumn] - The column configuration used as the title of the group (optional).
663
+ * @property {string} title - The title of the group.
664
+ * @property {string} [value] - A value associated with the group (optional).
665
+ * @property {string} [groupName] - The name of the group (optional).
666
+ * @property {number} [row] - The row index where the group header should appear (optional).
667
+ * @property {string|number} column - The column name or index where the group header should appear.
668
+ * @property {number} rowspan - The number of rows the group header should span.
669
+ * @property {number} [colspan] - The number of columns the group header should span (optional).
670
+ */
275
671
  export type GroupConfig = {
276
672
  align: string
277
673
  titleColumn?: ColumnConfig
@@ -284,10 +680,36 @@ export type GroupConfig = {
284
680
  colspan?: number
285
681
  }
286
682
 
683
+ /**
684
+ * Configuration options for specifying row selectability in a Grist table.
685
+ *
686
+ * @typedef {Object} RowSelectableConfig
687
+ *
688
+ * @property {boolean} [multiple] - Indicates whether multiple rows can be selected (optional).
689
+ */
287
690
  export type RowSelectableConfig = {
288
691
  multiple?: boolean
289
692
  }
290
693
 
694
+ /**
695
+ * Represents a data record in Grist.
696
+ *
697
+ * @typedef {Object} GristRecord
698
+ * @property {string} [id] - The unique identifier for the record.
699
+ * @property {string} [name] - The name or label associated with the record.
700
+ * @property {GristRecord[]} [children] - An array of child records, if applicable.
701
+ * @property {number} [__seq__] - A numeric sequence identifier for the record.
702
+ * @property {string} [__dirty__] - Indicates if the record is dirty (changed).
703
+ * @property {boolean} [__selected__] - Indicates if the record is selected.
704
+ * @property {object[]} [__changes__] - An array of changes made to the record.
705
+ * @property {object} [__dirtyfields__] - An object representing dirty (changed) fields in the record.
706
+ * @property {any} [__origin__] - The original data or source of the record.
707
+ * @property {boolean} [__collapsed__] - Indicates if the record is collapsed (e.g., in a tree view).
708
+ * @property {number} [__depth__] - The depth or level of the record in a hierarchical structure.
709
+ * @property {'checked' | 'half-checked' | 'unchecked'} [__check_in_tree__] - Indicates the check state of the record in a tree view.
710
+ * @property {GristRecord[]} [__children__] - An array of child records in a tree view.
711
+ * @property {any} [key] - Additional custom properties specific to the record.
712
+ */
291
713
  export type GristRecord = {
292
714
  id?: string
293
715
  name?: string
@@ -305,6 +727,16 @@ export type GristRecord = {
305
727
  [key: string]: any
306
728
  }
307
729
 
730
+ /**
731
+ * Represents a set of data retrieved from a Grist table.
732
+ *
733
+ * @typedef {Object} GristData
734
+ *
735
+ * @property {number} [page] - The page number of the retrieved data (optional).
736
+ * @property {number} [total] - The total number of records in the data source (optional).
737
+ * @property {number} [limit] - The maximum number of records per page (optional).
738
+ * @property {GristRecord[]} records - An array of fetched data records.
739
+ */
308
740
  export type GristData = {
309
741
  page?: number
310
742
  total?: number
@@ -312,4 +744,11 @@ export type GristData = {
312
744
  records: GristRecord[]
313
745
  }
314
746
 
747
+ /**
748
+ * A function that determines whether a Grist record should be selected or not.
749
+ *
750
+ * @callback GristSelectFunction
751
+ * @param {GristRecord} record - The Grist record to evaluate.
752
+ * @returns {boolean} - `true` if the record should be selected, `false` otherwise.
753
+ */
315
754
  export type GristSelectFunction = (record: GristRecord) => boolean