@operato/data-grist 2.0.0-alpha.0 → 2.0.0-alpha.3

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 +24 -0
  2. package/dist/src/configure/column-builder.js +5 -5
  3. package/dist/src/configure/column-builder.js.map +1 -1
  4. package/dist/src/configure/zero-config.js +3 -1
  5. package/dist/src/configure/zero-config.js.map +1 -1
  6. package/dist/src/data-card/data-card-field.js +1 -1
  7. package/dist/src/data-card/data-card-field.js.map +1 -1
  8. package/dist/src/data-grid/data-grid-accum-field.d.ts +1 -0
  9. package/dist/src/data-grid/data-grid-accum-field.js +8 -0
  10. package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
  11. package/dist/src/data-grid/data-grid-body.js +24 -3
  12. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  13. package/dist/src/data-grid/data-grid-field.d.ts +1 -0
  14. package/dist/src/data-grid/data-grid-field.js +5 -0
  15. package/dist/src/data-grid/data-grid-field.js.map +1 -1
  16. package/dist/src/data-grid/event-handlers/data-grid-body-click-handler.js +2 -2
  17. package/dist/src/data-grid/event-handlers/data-grid-body-click-handler.js.map +1 -1
  18. package/dist/src/data-grid/event-handlers/data-grid-body-contextmenu-handler.d.ts +7 -0
  19. package/dist/src/data-grid/event-handlers/data-grid-body-contextmenu-handler.js +25 -0
  20. package/dist/src/data-grid/event-handlers/data-grid-body-contextmenu-handler.js.map +1 -0
  21. package/dist/src/data-grid/event-handlers/data-grid-body-dblclick-handler.js +2 -2
  22. package/dist/src/data-grid/event-handlers/data-grid-body-dblclick-handler.js.map +1 -1
  23. package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler.js +2 -2
  24. package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler.js.map +1 -1
  25. package/dist/src/data-list/data-list-field.js +1 -1
  26. package/dist/src/data-list/data-list-field.js.map +1 -1
  27. package/dist/src/data-manipulator.d.ts +7 -3
  28. package/dist/src/data-manipulator.js +86 -18
  29. package/dist/src/data-manipulator.js.map +1 -1
  30. package/dist/src/editors/ox-grist-editor-tree.d.ts +6 -0
  31. package/dist/src/editors/ox-grist-editor-tree.js +27 -0
  32. package/dist/src/editors/ox-grist-editor-tree.js.map +1 -0
  33. package/dist/src/editors/ox-grist-editor.d.ts +1 -0
  34. package/dist/src/editors/ox-grist-editor.js +3 -0
  35. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  36. package/dist/src/editors/ox-input-tree.d.ts +20 -0
  37. package/dist/src/editors/ox-input-tree.js +221 -0
  38. package/dist/src/editors/ox-input-tree.js.map +1 -0
  39. package/dist/src/editors/registry.js +3 -1
  40. package/dist/src/editors/registry.js.map +1 -1
  41. package/dist/src/filters/filters-form.js +1 -1
  42. package/dist/src/filters/filters-form.js.map +1 -1
  43. package/dist/src/handlers/contextmenu-tree-mutation.d.ts +3 -0
  44. package/dist/src/handlers/contextmenu-tree-mutation.js +82 -0
  45. package/dist/src/handlers/contextmenu-tree-mutation.js.map +1 -0
  46. package/dist/src/handlers/registry.js +3 -1
  47. package/dist/src/handlers/registry.js.map +1 -1
  48. package/dist/src/renderers/ox-grist-renderer-tree.d.ts +1 -0
  49. package/dist/src/renderers/ox-grist-renderer-tree.js +6 -3
  50. package/dist/src/renderers/ox-grist-renderer-tree.js.map +1 -1
  51. package/dist/src/types.d.ts +437 -6
  52. package/dist/src/types.js +9 -0
  53. package/dist/src/types.js.map +1 -1
  54. package/dist/stories/tree-column-with-checkbox.stories.js +8 -3
  55. package/dist/stories/tree-column-with-checkbox.stories.js.map +1 -1
  56. package/dist/stories/tree-column.stories.js +8 -3
  57. package/dist/stories/tree-column.stories.js.map +1 -1
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/docs/gutter/gutter.md +7 -0
  60. package/package.json +4 -4
  61. package/src/configure/column-builder.ts +4 -4
  62. package/src/configure/zero-config.ts +3 -1
  63. package/src/data-card/data-card-field.ts +1 -1
  64. package/src/data-grid/data-grid-accum-field.ts +7 -0
  65. package/src/data-grid/data-grid-body.ts +30 -3
  66. package/src/data-grid/data-grid-field.ts +6 -0
  67. package/src/data-grid/event-handlers/data-grid-body-click-handler.ts +2 -2
  68. package/src/data-grid/event-handlers/data-grid-body-contextmenu-handler.ts +32 -0
  69. package/src/data-grid/event-handlers/data-grid-body-dblclick-handler.ts +2 -2
  70. package/src/data-grid/event-handlers/data-grid-body-focus-change-handler.ts +2 -2
  71. package/src/data-list/data-list-field.ts +1 -1
  72. package/src/data-manipulator.ts +109 -22
  73. package/src/editors/ox-grist-editor-tree.ts +27 -0
  74. package/src/editors/ox-grist-editor.ts +4 -0
  75. package/src/editors/ox-input-tree.ts +226 -0
  76. package/src/editors/registry.ts +3 -1
  77. package/src/filters/filters-form.ts +1 -1
  78. package/src/handlers/contextmenu-tree-mutation.ts +98 -0
  79. package/src/handlers/registry.ts +3 -1
  80. package/src/renderers/ox-grist-renderer-tree.ts +7 -3
  81. package/src/types.ts +446 -6
  82. package/stories/tree-column-with-checkbox.stories.ts +8 -3
  83. package/stories/tree-column.stories.ts +8 -3
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,23 +193,62 @@ 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,
111
237
  column?: ColumnConfig,
112
238
  record?: GristRecord,
113
239
  rowIndex?: number,
114
- target?: any
240
+ target?: any,
241
+ e?: Event
115
242
  ) => void
116
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
+ */
117
252
  export type AccumulatorFunc =
118
253
  | 'sum'
119
254
  | 'avg'
@@ -122,6 +257,27 @@ export type AccumulatorFunc =
122
257
  | 'max'
123
258
  | ((data: GristData, column: ColumnConfig) => string | number)
124
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
+ */
125
281
  export type AccumulatorObject =
126
282
  | AccumulatorFunc
127
283
  | {
@@ -129,10 +285,45 @@ export type AccumulatorObject =
129
285
  tag?: boolean
130
286
  }
131
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
+ */
132
313
  export type ColumnConfig = {
133
314
  type: string
134
315
  name: string
135
- 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'
136
327
  fixed?: boolean
137
328
  header: HeaderConfig
138
329
  record: RecordConfig
@@ -143,6 +334,7 @@ export type ColumnConfig = {
143
334
  resizable?: boolean
144
335
  width?: number | string | ColumnWidthCallback
145
336
  forList?: boolean
337
+ forCard?: boolean
146
338
  validation?: ValidationCallback
147
339
  accumulator?: AccumulatorObject
148
340
  filter?: FilterConfig
@@ -151,8 +343,40 @@ export type ColumnConfig = {
151
343
  rowCount?: boolean
152
344
  }
153
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
+ */
154
358
  export type ValidationCallback = (after: any, before: any, record: GristRecord, column: ColumnConfig) => boolean
155
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
+ */
156
380
  export type LabelConfig =
157
381
  | string
158
382
  | boolean
@@ -160,19 +384,68 @@ export type LabelConfig =
160
384
  renderer: LabelRenderer
161
385
  }
162
386
 
163
- export type LabelRenderer = () => void
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
+ */
394
+ export type LabelRenderer = (column: ColumnConfig) => void
164
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
+ */
165
403
  export type ColumnWidthCallback = (column: ColumnConfig) => string
166
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
+ */
167
414
  export type HeaderConfig = {
168
415
  renderer: HeaderRenderer
169
416
  style?: string
170
417
  group?: string
171
418
  groupStyle?: string
172
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
+ */
173
428
  export type HeaderRenderer = (column: ColumnConfig) => any
174
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
+ */
175
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
+ */
176
449
  export type DefaultValueFnConfig =
177
450
  | {
178
451
  /**
@@ -187,6 +460,24 @@ export type DefaultValueFnConfig =
187
460
  }
188
461
  | Function
189
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
+ */
190
481
  export type RecordConfig = {
191
482
  renderer: FieldRenderer
192
483
  editor?: FieldEditor
@@ -200,6 +491,17 @@ export type RecordConfig = {
200
491
  [extended: string]: any
201
492
  }
202
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
+ */
203
505
  export type FieldRenderer = (
204
506
  value: any,
205
507
  column: ColumnConfig,
@@ -216,6 +518,18 @@ export type FieldRenderer = (
216
518
  | DataReportField
217
519
  | Element
218
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
+ */
219
533
  export type FieldEditor = (
220
534
  value: any,
221
535
  column: ColumnConfig,
@@ -224,29 +538,72 @@ export type FieldEditor = (
224
538
  field: DataGridField
225
539
  ) => OxGristEditor
226
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
+ */
227
550
  export type FilterSelectRenderer = (
228
551
  column: ColumnConfig,
229
552
  value: string | number | boolean | string[] | number[] | any | undefined,
230
553
  owner: Element
231
554
  ) => TemplateResult | string | void
232
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
+ */
233
565
  export type GristEventHandlerSet = {
234
566
  click?: GristEventHandler
235
567
  dblclick?: GristEventHandler
236
568
  focus?: GristEventHandler
569
+ contextmenu?: GristEventHandler
237
570
  }
238
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
+ */
239
580
  export type ListConfig = {
240
581
  thumbnail?: string
241
582
  fields: string[]
242
583
  details: string[]
243
584
  }
244
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
+ */
245
593
  export type TreeConfig = {
246
594
  childrenProperty?: string
247
595
  expanded?: boolean | ((x: GristRecord) => boolean)
248
596
  }
249
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
+ */
250
607
  export type ImexConfig = {
251
608
  header: string
252
609
  key: string
@@ -254,6 +611,19 @@ export type ImexConfig = {
254
611
  type: string
255
612
  }
256
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
+ */
257
627
  export type RowsConfig = {
258
628
  accumulator?: boolean
259
629
  appendable: boolean
@@ -265,11 +635,38 @@ export type RowsConfig = {
265
635
  handlers: GristEventHandlerSet
266
636
  }
267
637
 
638
+ /**
639
+ * A function used to classify and style individual records in a Grist table.
640
+ *
641
+ * @typedef {Function} GristClassifier
642
+ *
643
+ * @param {GristRecord} record - The record to be classified.
644
+ * @param {number} rowIndex - The index of the row in the table.
645
+ *
646
+ * @returns {Object|void} An object containing classification properties or `void`.
647
+ * - `emphasized` (optional): A boolean, string, or array of strings indicating the emphasis style.
648
+ * - Additional properties can be added as needed for custom styling.
649
+ */
268
650
  export type GristClassifier = (
269
651
  record: GristRecord,
270
652
  rowIndex: number
271
653
  ) => { emphasized?: boolean | string | string[]; [key: string]: any } | void
272
654
 
655
+ /**
656
+ * Configuration options for defining group headers in a Grist table.
657
+ *
658
+ * @typedef {Object} GroupConfig
659
+ *
660
+ * @property {string} align - The alignment of the group header ('left', 'center', or 'right').
661
+ * @property {ColumnConfig} [titleColumn] - The column configuration used as the title of the group (optional).
662
+ * @property {string} title - The title of the group.
663
+ * @property {string} [value] - A value associated with the group (optional).
664
+ * @property {string} [groupName] - The name of the group (optional).
665
+ * @property {number} [row] - The row index where the group header should appear (optional).
666
+ * @property {string|number} column - The column name or index where the group header should appear.
667
+ * @property {number} rowspan - The number of rows the group header should span.
668
+ * @property {number} [colspan] - The number of columns the group header should span (optional).
669
+ */
273
670
  export type GroupConfig = {
274
671
  align: string
275
672
  titleColumn?: ColumnConfig
@@ -282,10 +679,36 @@ export type GroupConfig = {
282
679
  colspan?: number
283
680
  }
284
681
 
682
+ /**
683
+ * Configuration options for specifying row selectability in a Grist table.
684
+ *
685
+ * @typedef {Object} RowSelectableConfig
686
+ *
687
+ * @property {boolean} [multiple] - Indicates whether multiple rows can be selected (optional).
688
+ */
285
689
  export type RowSelectableConfig = {
286
690
  multiple?: boolean
287
691
  }
288
692
 
693
+ /**
694
+ * Represents a data record in Grist.
695
+ *
696
+ * @typedef {Object} GristRecord
697
+ * @property {string} [id] - The unique identifier for the record.
698
+ * @property {string} [name] - The name or label associated with the record.
699
+ * @property {GristRecord[]} [children] - An array of child records, if applicable.
700
+ * @property {number} [__seq__] - A numeric sequence identifier for the record.
701
+ * @property {string} [__dirty__] - Indicates if the record is dirty (changed).
702
+ * @property {boolean} [__selected__] - Indicates if the record is selected.
703
+ * @property {object[]} [__changes__] - An array of changes made to the record.
704
+ * @property {object} [__dirtyfields__] - An object representing dirty (changed) fields in the record.
705
+ * @property {any} [__origin__] - The original data or source of the record.
706
+ * @property {boolean} [__collapsed__] - Indicates if the record is collapsed (e.g., in a tree view).
707
+ * @property {number} [__depth__] - The depth or level of the record in a hierarchical structure.
708
+ * @property {'checked' | 'half-checked' | 'unchecked'} [__check_in_tree__] - Indicates the check state of the record in a tree view.
709
+ * @property {GristRecord[]} [__children__] - An array of child records in a tree view.
710
+ * @property {any} [key] - Additional custom properties specific to the record.
711
+ */
289
712
  export type GristRecord = {
290
713
  id?: string
291
714
  name?: string
@@ -303,6 +726,16 @@ export type GristRecord = {
303
726
  [key: string]: any
304
727
  }
305
728
 
729
+ /**
730
+ * Represents a set of data retrieved from a Grist table.
731
+ *
732
+ * @typedef {Object} GristData
733
+ *
734
+ * @property {number} [page] - The page number of the retrieved data (optional).
735
+ * @property {number} [total] - The total number of records in the data source (optional).
736
+ * @property {number} [limit] - The maximum number of records per page (optional).
737
+ * @property {GristRecord[]} records - An array of fetched data records.
738
+ */
306
739
  export type GristData = {
307
740
  page?: number
308
741
  total?: number
@@ -310,4 +743,11 @@ export type GristData = {
310
743
  records: GristRecord[]
311
744
  }
312
745
 
746
+ /**
747
+ * A function that determines whether a Grist record should be selected or not.
748
+ *
749
+ * @callback GristSelectFunction
750
+ * @param {GristRecord} record - The Grist record to evaluate.
751
+ * @returns {boolean} - `true` if the record should be selected, `false` otherwise.
752
+ */
313
753
  export type GristSelectFunction = (record: GristRecord) => boolean