@operato/data-grist 7.1.30 → 7.1.32

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