@operato/data-grist 7.1.31 → 7.1.33
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.
- package/CHANGELOG.md +19 -0
- package/dist/src/data-grid/data-grid-field.js +4 -1
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/record-view/record-view-body.js +8 -4
- package/dist/src/record-view/record-view-body.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/data-grist-test.html +0 -468
- package/demo/favicon.ico +0 -0
- package/demo/index.html +0 -541
- package/demo/report-test.html +0 -249
- package/src/accumulator/accumulator.ts +0 -63
- package/src/configure/column-builder.ts +0 -114
- package/src/configure/config-builder.ts +0 -40
- package/src/configure/filters-option-builder.ts +0 -8
- package/src/configure/imex-option-builder.ts +0 -5
- package/src/configure/list-option-builder.ts +0 -9
- package/src/configure/rows-option-builder.ts +0 -38
- package/src/configure/tree-option-builder.ts +0 -22
- package/src/configure/zero-config.ts +0 -83
- package/src/const.ts +0 -1
- package/src/data-card/data-card-field.ts +0 -94
- package/src/data-card/data-card-gutter-menu.ts +0 -94
- package/src/data-card/data-card-gutter.ts +0 -103
- package/src/data-card/data-card.ts +0 -154
- package/src/data-card/event-handlers/record-card-click-handler.ts +0 -34
- package/src/data-card/event-handlers/record-card-dblclick-handler.ts +0 -34
- package/src/data-card/record-card.ts +0 -289
- package/src/data-consumer.ts +0 -11
- package/src/data-grid/data-grid-accum-field.ts +0 -109
- package/src/data-grid/data-grid-body-style.ts +0 -99
- package/src/data-grid/data-grid-body.ts +0 -753
- package/src/data-grid/data-grid-field.ts +0 -236
- package/src/data-grid/data-grid-footer.ts +0 -117
- package/src/data-grid/data-grid-header.ts +0 -574
- package/src/data-grid/data-grid.ts +0 -293
- package/src/data-grid/event-handlers/data-grid-body-click-handler.ts +0 -69
- package/src/data-grid/event-handlers/data-grid-body-contextmenu-handler.ts +0 -32
- package/src/data-grid/event-handlers/data-grid-body-dblclick-handler.ts +0 -42
- package/src/data-grid/event-handlers/data-grid-body-focus-change-handler.ts +0 -24
- package/src/data-grid/event-handlers/data-grid-body-keydown-handler.ts +0 -234
- package/src/data-grist.ts +0 -1233
- package/src/data-list/data-list-field.ts +0 -82
- package/src/data-list/data-list-gutter.ts +0 -108
- package/src/data-list/data-list.ts +0 -145
- package/src/data-list/event-handlers/record-partial-click-handler.ts +0 -34
- package/src/data-list/event-handlers/record-partial-dblclick-handler.ts +0 -33
- package/src/data-list/event-handlers/record-partial-long-press-handler.ts +0 -33
- package/src/data-list/record-partial.ts +0 -255
- package/src/data-manipulator.ts +0 -426
- package/src/data-provider.ts +0 -271
- package/src/data-report/data-report-body-style.ts +0 -58
- package/src/data-report/data-report-body.ts +0 -189
- package/src/data-report/data-report-component.ts +0 -138
- package/src/data-report/data-report-field.ts +0 -83
- package/src/data-report/data-report-header.ts +0 -242
- package/src/data-report/event-handlers/data-report-body-click-handler.ts +0 -38
- package/src/data-report/event-handlers/data-report-body-dblclick-handler.ts +0 -25
- package/src/data-report/event-handlers/data-report-body-keydown-handler.ts +0 -68
- package/src/data-report.ts +0 -424
- package/src/editors/index.ts +0 -4
- package/src/editors/ox-grist-editor-checkbox.ts +0 -28
- package/src/editors/ox-grist-editor-color.ts +0 -10
- package/src/editors/ox-grist-editor-date.ts +0 -10
- package/src/editors/ox-grist-editor-datetime.ts +0 -27
- package/src/editors/ox-grist-editor-email.ts +0 -10
- package/src/editors/ox-grist-editor-file.ts +0 -28
- package/src/editors/ox-grist-editor-image.ts +0 -31
- package/src/editors/ox-grist-editor-month.ts +0 -10
- package/src/editors/ox-grist-editor-multiple-select.ts +0 -57
- package/src/editors/ox-grist-editor-number.ts +0 -27
- package/src/editors/ox-grist-editor-password.ts +0 -10
- package/src/editors/ox-grist-editor-select.ts +0 -55
- package/src/editors/ox-grist-editor-tel.ts +0 -10
- package/src/editors/ox-grist-editor-text.ts +0 -14
- package/src/editors/ox-grist-editor-textarea.ts +0 -16
- package/src/editors/ox-grist-editor-time.ts +0 -10
- package/src/editors/ox-grist-editor-tree.ts +0 -27
- package/src/editors/ox-grist-editor-varname.ts +0 -36
- package/src/editors/ox-grist-editor-week.ts +0 -10
- package/src/editors/ox-grist-editor.ts +0 -207
- package/src/editors/ox-input-tree.ts +0 -226
- package/src/editors/registry.ts +0 -82
- package/src/empty-note.ts +0 -46
- package/src/filters/filter-checkbox.ts +0 -49
- package/src/filters/filter-input-barcode.ts +0 -34
- package/src/filters/filter-input.ts +0 -30
- package/src/filters/filter-range-date.ts +0 -81
- package/src/filters/filter-range-number.ts +0 -64
- package/src/filters/filter-select-buttons.ts +0 -60
- package/src/filters/filter-select.ts +0 -68
- package/src/filters/filter-styles.ts +0 -119
- package/src/filters/filters-form.ts +0 -476
- package/src/filters/index.ts +0 -10
- package/src/filters/registry.ts +0 -56
- package/src/formatters/date-formatter.ts +0 -3
- package/src/formatters/index.ts +0 -1
- package/src/formatters/number-formatter.ts +0 -3
- package/src/formatters/registry.ts +0 -30
- package/src/formatters/text-formatter.ts +0 -3
- package/src/gutters/gutter-button.ts +0 -51
- package/src/gutters/gutter-dirty.ts +0 -96
- package/src/gutters/gutter-row-selector.ts +0 -89
- package/src/gutters/gutter-sequence.ts +0 -54
- package/src/gutters/index.ts +0 -1
- package/src/gutters/registry.ts +0 -32
- package/src/handlers/contextmenu-tree-mutation.ts +0 -80
- package/src/handlers/index.ts +0 -1
- package/src/handlers/move-down.ts +0 -44
- package/src/handlers/move-up.ts +0 -44
- package/src/handlers/record-copy.ts +0 -38
- package/src/handlers/record-delete.ts +0 -30
- package/src/handlers/record-view-handler.ts +0 -27
- package/src/handlers/registry.ts +0 -42
- package/src/handlers/select-row-toggle.ts +0 -30
- package/src/handlers/select-row.ts +0 -27
- package/src/index.ts +0 -17
- package/src/personalizer/index.ts +0 -1
- package/src/personalizer/ox-grist-filter-personalizer.ts +0 -192
- package/src/personalizer/ox-grist-personalizer.ts +0 -226
- package/src/record-view/event-handlers/record-view-body-click-handler.ts +0 -33
- package/src/record-view/event-handlers/record-view-body-keydown-handler.ts +0 -26
- package/src/record-view/index.ts +0 -2
- package/src/record-view/ox-record-creator.ts +0 -289
- package/src/record-view/record-view-body.ts +0 -250
- package/src/record-view/record-view-handler.ts +0 -86
- package/src/record-view/record-view.ts +0 -122
- package/src/renderers/index.ts +0 -14
- package/src/renderers/ox-grist-renderer-boolean.ts +0 -43
- package/src/renderers/ox-grist-renderer-color.ts +0 -15
- package/src/renderers/ox-grist-renderer-date.ts +0 -62
- package/src/renderers/ox-grist-renderer-file.ts +0 -31
- package/src/renderers/ox-grist-renderer-image.ts +0 -27
- package/src/renderers/ox-grist-renderer-json5.ts +0 -36
- package/src/renderers/ox-grist-renderer-link.ts +0 -17
- package/src/renderers/ox-grist-renderer-password.ts +0 -7
- package/src/renderers/ox-grist-renderer-progress.ts +0 -45
- package/src/renderers/ox-grist-renderer-select.ts +0 -58
- package/src/renderers/ox-grist-renderer-text.ts +0 -16
- package/src/renderers/ox-grist-renderer-textarea.ts +0 -7
- package/src/renderers/ox-grist-renderer-tree.ts +0 -189
- package/src/renderers/ox-grist-renderer.ts +0 -35
- package/src/renderers/registry.ts +0 -111
- package/src/sorters/sorters-control.ts +0 -143
- package/src/types.ts +0 -813
- package/src/utils/index.ts +0 -2
- package/src/utils/list-param.ts +0 -72
- package/src/utils/supports-passive.ts +0 -13
- package/stories/accumulator-format.stories.ts +0 -276
- package/stories/barcode-input-filter.stories.ts +0 -216
- package/stories/bounded-select-filters.stories.ts +0 -333
- package/stories/bounded-select-record.stories.ts +0 -336
- package/stories/click-event-custom.stories.ts +0 -288
- package/stories/click-event.stories.ts +0 -283
- package/stories/creatable-only-column.stories.ts +0 -253
- package/stories/default-filters.stories.ts +0 -241
- package/stories/dynamic-editable.stories.ts +0 -313
- package/stories/empty-sorters.stories.ts +0 -180
- package/stories/explicit-fetch.stories.ts +0 -186
- package/stories/fixed-column.stories.ts +0 -416
- package/stories/grid-setting.stories.ts +0 -501
- package/stories/grist-modes.stories.ts +0 -451
- package/stories/group-header.stories.ts +0 -442
- package/stories/record-view.stories.ts +0 -143
- package/stories/textarea.stories.ts +0 -261
- package/stories/tree-column-with-checkbox.stories.ts +0 -297
- package/stories/tree-column.stories.ts +0 -296
- package/tsconfig.json +0 -26
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -45
package/demo/report-test.html
DELETED
@@ -1,249 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="en-GB">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8" />
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
/* box-sizing: border-box; */
|
9
|
-
margin: 0;
|
10
|
-
padding: 0;
|
11
|
-
overflow: hidden;
|
12
|
-
|
13
|
-
/* This is a font-stack that tries to use the system-default sans-serifs first */
|
14
|
-
font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
15
|
-
line-height: 1.5;
|
16
|
-
-webkit-font-smoothing: antialiased;
|
17
|
-
|
18
|
-
width: 100vw;
|
19
|
-
height: 100dvh;
|
20
|
-
|
21
|
-
display: flex;
|
22
|
-
flex-direction: column;
|
23
|
-
}
|
24
|
-
|
25
|
-
#demo {
|
26
|
-
flex: 1;
|
27
|
-
overflow: hidden;
|
28
|
-
|
29
|
-
display: flex;
|
30
|
-
flex-direction: column;
|
31
|
-
}
|
32
|
-
|
33
|
-
ox-report {
|
34
|
-
flex: 1;
|
35
|
-
}
|
36
|
-
</style>
|
37
|
-
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
38
|
-
<link
|
39
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
40
|
-
rel="stylesheet"
|
41
|
-
/>
|
42
|
-
<link
|
43
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
44
|
-
rel="stylesheet"
|
45
|
-
/>
|
46
|
-
<link
|
47
|
-
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
48
|
-
rel="stylesheet"
|
49
|
-
/>
|
50
|
-
|
51
|
-
<link href="/themes/app-theme.css" rel="stylesheet" />
|
52
|
-
<link href="/themes/oops-theme.css" rel="stylesheet" />
|
53
|
-
<link href="/themes/report-theme.css" rel="stylesheet" />
|
54
|
-
</head>
|
55
|
-
<body>
|
56
|
-
<script type="module">
|
57
|
-
import { html, render } from 'lit'
|
58
|
-
import '../dist/index.js'
|
59
|
-
|
60
|
-
const fetchHandler = async ({ page, limit, sorters = [] }) => {
|
61
|
-
var limit = 500
|
62
|
-
var total = 120993
|
63
|
-
var start = (page - 1) * limit
|
64
|
-
|
65
|
-
await new Promise(resolve => setTimeout(resolve, 1000))
|
66
|
-
|
67
|
-
return {
|
68
|
-
total,
|
69
|
-
records: Array(limit * page > total ? total % limit : limit)
|
70
|
-
.fill()
|
71
|
-
.map((item, idx) => {
|
72
|
-
return {
|
73
|
-
id: idx,
|
74
|
-
name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
|
75
|
-
description: idx % 2 ? `hatiolab manager-${start + idx + 1}` : `hatiosea manager-${start + idx + 1}`,
|
76
|
-
email: idx % 2 ? `shnam@gmail.com` : `heartyoh@gmail.com`,
|
77
|
-
active: Math.round(Math.random() * 2) % 2 ? true : false,
|
78
|
-
company: idx % 5 ? 'HatioLAB' : 'HatioSEA',
|
79
|
-
role: ['admin', 'worker', 'tester'][idx % 3],
|
80
|
-
color: idx % 2 ? `#87f018` : `#180f87`,
|
81
|
-
height: Math.round(Math.random() * 100),
|
82
|
-
weight: Math.round(Math.random() * 100),
|
83
|
-
count: Math.round(Math.random() * 100),
|
84
|
-
homepage:
|
85
|
-
idx % 2
|
86
|
-
? `http://hatiolab.com/${start + idx + 1}`
|
87
|
-
: `http://deadpool.hatiolab.com/${start + idx + 1}`,
|
88
|
-
createdAt: Date.now(),
|
89
|
-
updatedAt: Date.now()
|
90
|
-
}
|
91
|
-
})
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
const config = {
|
96
|
-
columns: [
|
97
|
-
{
|
98
|
-
type: 'string',
|
99
|
-
name: 'company',
|
100
|
-
header: 'company',
|
101
|
-
record: {
|
102
|
-
align: 'center',
|
103
|
-
options: {}
|
104
|
-
},
|
105
|
-
sortable: false,
|
106
|
-
width: 240
|
107
|
-
},
|
108
|
-
{
|
109
|
-
type: 'email',
|
110
|
-
name: 'email',
|
111
|
-
header: 'email',
|
112
|
-
record: {
|
113
|
-
align: 'center'
|
114
|
-
},
|
115
|
-
sortable: false,
|
116
|
-
width: 130
|
117
|
-
},
|
118
|
-
{
|
119
|
-
type: 'string',
|
120
|
-
name: 'id',
|
121
|
-
hidden: true
|
122
|
-
},
|
123
|
-
{
|
124
|
-
type: 'link',
|
125
|
-
name: 'name',
|
126
|
-
header: 'name',
|
127
|
-
record: {
|
128
|
-
align: 'center',
|
129
|
-
editable: true,
|
130
|
-
options: {
|
131
|
-
// href: 'http://hatiolab.com',
|
132
|
-
href: function (column, record, rowIndex) {
|
133
|
-
return record['homepage']
|
134
|
-
}
|
135
|
-
// target: '_blank'
|
136
|
-
}
|
137
|
-
},
|
138
|
-
sortable: false,
|
139
|
-
width: 120
|
140
|
-
},
|
141
|
-
{
|
142
|
-
type: 'string',
|
143
|
-
name: 'description',
|
144
|
-
header: 'description',
|
145
|
-
record: {
|
146
|
-
align: 'left'
|
147
|
-
},
|
148
|
-
width: 200,
|
149
|
-
handlers: {
|
150
|
-
dblclick: (columns, data, column, record, rowIndex) => {
|
151
|
-
alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)
|
152
|
-
}
|
153
|
-
}
|
154
|
-
},
|
155
|
-
{
|
156
|
-
type: 'boolean',
|
157
|
-
name: 'active',
|
158
|
-
header: 'active',
|
159
|
-
record: {
|
160
|
-
align: 'center'
|
161
|
-
},
|
162
|
-
handlers: {
|
163
|
-
dblclick: () => {
|
164
|
-
console.log(this.report.dirtyRecords)
|
165
|
-
}
|
166
|
-
},
|
167
|
-
sortable: false,
|
168
|
-
width: 60
|
169
|
-
},
|
170
|
-
{
|
171
|
-
type: 'string',
|
172
|
-
name: 'role',
|
173
|
-
header: 'role',
|
174
|
-
record: {
|
175
|
-
align: 'center'
|
176
|
-
},
|
177
|
-
sortable: false,
|
178
|
-
width: 120
|
179
|
-
},
|
180
|
-
{
|
181
|
-
type: 'number',
|
182
|
-
name: 'weight',
|
183
|
-
header: 'weight',
|
184
|
-
record: {},
|
185
|
-
sortable: false,
|
186
|
-
width: 50
|
187
|
-
},
|
188
|
-
{
|
189
|
-
type: 'number',
|
190
|
-
name: 'height',
|
191
|
-
header: 'height',
|
192
|
-
record: {},
|
193
|
-
sortable: false,
|
194
|
-
width: 50
|
195
|
-
},
|
196
|
-
{
|
197
|
-
type: 'number',
|
198
|
-
name: 'count',
|
199
|
-
header: 'count',
|
200
|
-
record: {},
|
201
|
-
sortable: false,
|
202
|
-
width: 50
|
203
|
-
},
|
204
|
-
{
|
205
|
-
type: 'datetime',
|
206
|
-
name: 'updatedAt',
|
207
|
-
header: 'updated_at',
|
208
|
-
record: {
|
209
|
-
align: 'center'
|
210
|
-
},
|
211
|
-
sortable: false,
|
212
|
-
width: 180
|
213
|
-
},
|
214
|
-
{
|
215
|
-
type: 'datetime',
|
216
|
-
name: 'createdAt',
|
217
|
-
header: 'created_at',
|
218
|
-
record: {
|
219
|
-
align: 'center'
|
220
|
-
},
|
221
|
-
sortable: false,
|
222
|
-
width: 180
|
223
|
-
}
|
224
|
-
],
|
225
|
-
rows: {
|
226
|
-
groups: [{ column: 'company', title: 'company total', align: 'right' }, { column: 'email' }],
|
227
|
-
totals: ['weight', 'height', 'count']
|
228
|
-
},
|
229
|
-
sorters: [
|
230
|
-
{
|
231
|
-
name: 'company',
|
232
|
-
desc: true
|
233
|
-
},
|
234
|
-
{
|
235
|
-
name: 'email'
|
236
|
-
}
|
237
|
-
]
|
238
|
-
}
|
239
|
-
|
240
|
-
render(
|
241
|
-
html` <ox-report .config=${config} .fetchHandler=${fetchHandler} auto-fetch></ox-report> `,
|
242
|
-
document.querySelector('#demo')
|
243
|
-
)
|
244
|
-
</script>
|
245
|
-
|
246
|
-
<a href="./index.html">Grist Test</a>
|
247
|
-
<div id="demo"></div>
|
248
|
-
</body>
|
249
|
-
</html>
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import { AccumulatorObject, ColumnConfig, GristData } from '../types'
|
2
|
-
|
3
|
-
function sum(data: GristData, column: ColumnConfig): number {
|
4
|
-
const name = column.name
|
5
|
-
|
6
|
-
return data.records
|
7
|
-
.filter(record => !Number.isNaN(record[name]))
|
8
|
-
.reduce((sum, record) => {
|
9
|
-
return sum + Number(record[name] || 0)
|
10
|
-
}, 0)
|
11
|
-
}
|
12
|
-
|
13
|
-
function avg(data: GristData, column: ColumnConfig): number {
|
14
|
-
const name = column.name
|
15
|
-
const effectiveRecords = data.records.filter(record => !Number.isNaN(record[name]))
|
16
|
-
|
17
|
-
return (
|
18
|
-
effectiveRecords.reduce((sum, record) => {
|
19
|
-
return sum + Number(record[name] || 0)
|
20
|
-
}, 0) / effectiveRecords.length
|
21
|
-
)
|
22
|
-
}
|
23
|
-
|
24
|
-
function count(data: GristData, column: ColumnConfig): number {
|
25
|
-
return data.records.length
|
26
|
-
}
|
27
|
-
|
28
|
-
function min(data: GristData, column: ColumnConfig): number {
|
29
|
-
const name = column.name
|
30
|
-
|
31
|
-
return Math.min.apply(
|
32
|
-
null,
|
33
|
-
data.records.filter(record => !Number.isNaN(record[name])).map(record => Number(record[name] || 0))
|
34
|
-
)
|
35
|
-
}
|
36
|
-
|
37
|
-
function max(data: GristData, column: ColumnConfig): number {
|
38
|
-
const name = column.name
|
39
|
-
|
40
|
-
return Math.max.apply(
|
41
|
-
null,
|
42
|
-
data.records.filter(record => !Number.isNaN(record[name])).map(record => Number(record[name] || 0))
|
43
|
-
)
|
44
|
-
}
|
45
|
-
|
46
|
-
const Accumulators: { [name: string]: (data: GristData, column: ColumnConfig) => string | number } = {
|
47
|
-
sum,
|
48
|
-
avg,
|
49
|
-
count,
|
50
|
-
min,
|
51
|
-
max
|
52
|
-
}
|
53
|
-
|
54
|
-
export function accumulate(data: GristData, column: ColumnConfig, accumulator: AccumulatorObject) {
|
55
|
-
accumulator = typeof accumulator === 'object' ? accumulator.type : accumulator
|
56
|
-
var func = accumulator as (data: GristData, column: ColumnConfig) => string | number
|
57
|
-
|
58
|
-
if (typeof accumulator == 'string') {
|
59
|
-
func = Accumulators[accumulator]
|
60
|
-
}
|
61
|
-
|
62
|
-
return func.call(null, data, column)
|
63
|
-
}
|
@@ -1,114 +0,0 @@
|
|
1
|
-
import { FilterConfigObject, FilterOperator } from '..'
|
2
|
-
import { NOOP } from '../const'
|
3
|
-
import { getEditor } from '../editors'
|
4
|
-
import { generateGutterColumn } from '../gutters'
|
5
|
-
import { getGristEventHandler } from '../handlers'
|
6
|
-
import { getRenderer } from '../renderers'
|
7
|
-
import { ColumnConfig } from '../types'
|
8
|
-
|
9
|
-
export const buildColumn = (column: any): ColumnConfig => {
|
10
|
-
var compiled: ColumnConfig = { ...column }
|
11
|
-
|
12
|
-
if (column.type == 'gutter') {
|
13
|
-
compiled = generateGutterColumn(column)
|
14
|
-
}
|
15
|
-
|
16
|
-
var { name, header, record, handlers, label, filter } = compiled
|
17
|
-
|
18
|
-
/* header */
|
19
|
-
|
20
|
-
if (typeof header == 'string') {
|
21
|
-
compiled.header = {
|
22
|
-
renderer: () => header
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
if (typeof compiled.header?.renderer == 'string') {
|
27
|
-
const text = compiled.header.renderer
|
28
|
-
compiled.header = {
|
29
|
-
...compiled.header,
|
30
|
-
renderer: () => text
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
/* label */
|
35
|
-
if (label) {
|
36
|
-
let type = typeof label
|
37
|
-
switch (type) {
|
38
|
-
case 'boolean':
|
39
|
-
compiled.label = {
|
40
|
-
renderer: compiled.header?.renderer || (() => name)
|
41
|
-
}
|
42
|
-
break
|
43
|
-
case 'string':
|
44
|
-
compiled.label = {
|
45
|
-
renderer: () => label
|
46
|
-
}
|
47
|
-
break
|
48
|
-
default:
|
49
|
-
compiled.label = label
|
50
|
-
}
|
51
|
-
} else {
|
52
|
-
compiled.label = false
|
53
|
-
}
|
54
|
-
|
55
|
-
/*
|
56
|
-
* record
|
57
|
-
*/
|
58
|
-
var { renderer: recordRenderer, editor, editable, classifier } = record || {}
|
59
|
-
|
60
|
-
recordRenderer = getRenderer(recordRenderer || column.type)
|
61
|
-
|
62
|
-
if (editable !== false && typeof editor !== 'function') {
|
63
|
-
editor = getEditor(column.type)
|
64
|
-
}
|
65
|
-
|
66
|
-
if (typeof classifier !== 'function') {
|
67
|
-
classifier = NOOP
|
68
|
-
}
|
69
|
-
|
70
|
-
compiled.record = {
|
71
|
-
...record,
|
72
|
-
classifier,
|
73
|
-
renderer: recordRenderer,
|
74
|
-
editor
|
75
|
-
}
|
76
|
-
|
77
|
-
/* filter */
|
78
|
-
if (filter) {
|
79
|
-
let type = typeof filter
|
80
|
-
switch (type) {
|
81
|
-
case 'boolean':
|
82
|
-
compiled.filter = {
|
83
|
-
type: column.type,
|
84
|
-
operator: 'eq'
|
85
|
-
}
|
86
|
-
break
|
87
|
-
case 'string':
|
88
|
-
compiled.filter = {
|
89
|
-
type: column.type,
|
90
|
-
operator: filter as FilterOperator
|
91
|
-
}
|
92
|
-
break
|
93
|
-
default:
|
94
|
-
compiled.filter = {
|
95
|
-
//@ts-ignore
|
96
|
-
type: column.type,
|
97
|
-
operator: 'eq',
|
98
|
-
...(filter as FilterConfigObject)
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
/* handler */
|
104
|
-
var { click, dblclick, focus, contextmenu } = handlers || {}
|
105
|
-
|
106
|
-
compiled.handlers = {
|
107
|
-
click: click && getGristEventHandler(click),
|
108
|
-
dblclick: dblclick && getGristEventHandler(dblclick),
|
109
|
-
focus: focus && getGristEventHandler(focus),
|
110
|
-
contextmenu: contextmenu && getGristEventHandler(contextmenu)
|
111
|
-
}
|
112
|
-
|
113
|
-
return compiled
|
114
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { GristConfig, ColumnConfig } from '../types'
|
2
|
-
import { buildColumn } from './column-builder'
|
3
|
-
import { buildImexOptions } from './imex-option-builder'
|
4
|
-
import { buildListOptions } from './list-option-builder'
|
5
|
-
import { buildTreeOptions } from './tree-option-builder'
|
6
|
-
import { buildRowsOptions } from './rows-option-builder'
|
7
|
-
import { buildFiltersOptions } from './filters-option-builder'
|
8
|
-
|
9
|
-
function findLastIndexWithCondition(arr: ColumnConfig[], condition: (x: ColumnConfig) => boolean) {
|
10
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
11
|
-
if (condition(arr[i])) {
|
12
|
-
return i
|
13
|
-
}
|
14
|
-
}
|
15
|
-
return -1
|
16
|
-
}
|
17
|
-
|
18
|
-
export const buildConfig = (config: any): GristConfig => {
|
19
|
-
var { columns = [], rows = {}, pagination, sorters, filters, list, tree, imex } = config
|
20
|
-
|
21
|
-
/* 마지막 fixed 컬럼 앞의 모든 컬럼의 fixed를 true로 설정한다. */
|
22
|
-
const lastFixedIndex = findLastIndexWithCondition(columns, x => !!x.fixed)
|
23
|
-
if (lastFixedIndex >= 0) {
|
24
|
-
for (let i = 0; i < lastFixedIndex; i++) {
|
25
|
-
columns[i].fixed = true
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
return {
|
30
|
-
...config,
|
31
|
-
columns: columns.map((column: any) => buildColumn(column)),
|
32
|
-
rows: buildRowsOptions(rows),
|
33
|
-
pagination,
|
34
|
-
sorters,
|
35
|
-
filters: buildFiltersOptions(filters),
|
36
|
-
list: buildListOptions(list),
|
37
|
-
tree: buildTreeOptions(tree),
|
38
|
-
imex: buildImexOptions(imex)
|
39
|
-
}
|
40
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import { NOOP } from '../const'
|
2
|
-
import { RowsConfig } from '../types'
|
3
|
-
import { getGristEventHandler } from '../handlers'
|
4
|
-
|
5
|
-
export const buildRowsOptions = (rows: any): RowsConfig => {
|
6
|
-
var {
|
7
|
-
appendable = true,
|
8
|
-
editable = true,
|
9
|
-
insertable = false,
|
10
|
-
selectable,
|
11
|
-
groups = [],
|
12
|
-
totals = [],
|
13
|
-
classifier,
|
14
|
-
accumulator
|
15
|
-
} = rows
|
16
|
-
|
17
|
-
/* handler */
|
18
|
-
var { click, dblclick, focus } = rows.handlers || {}
|
19
|
-
if (typeof classifier !== 'function') {
|
20
|
-
classifier = NOOP
|
21
|
-
}
|
22
|
-
|
23
|
-
return {
|
24
|
-
accumulator,
|
25
|
-
appendable,
|
26
|
-
editable,
|
27
|
-
insertable,
|
28
|
-
selectable,
|
29
|
-
groups,
|
30
|
-
totals,
|
31
|
-
handlers: {
|
32
|
-
click: getGristEventHandler(click),
|
33
|
-
dblclick: getGristEventHandler(dblclick),
|
34
|
-
focus: getGristEventHandler(focus)
|
35
|
-
},
|
36
|
-
classifier
|
37
|
-
}
|
38
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import { TreeConfig } from '../types'
|
2
|
-
|
3
|
-
const CollapsedAll = () => false
|
4
|
-
const ExpandedAll = () => true
|
5
|
-
|
6
|
-
export const buildTreeOptions = (tree: TreeConfig | undefined): TreeConfig => {
|
7
|
-
var { expanded = CollapsedAll } = tree || {}
|
8
|
-
|
9
|
-
switch (expanded) {
|
10
|
-
case true:
|
11
|
-
expanded = ExpandedAll
|
12
|
-
break
|
13
|
-
case false:
|
14
|
-
expanded = CollapsedAll
|
15
|
-
break
|
16
|
-
}
|
17
|
-
|
18
|
-
return {
|
19
|
-
...tree,
|
20
|
-
expanded
|
21
|
-
}
|
22
|
-
}
|
@@ -1,83 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
ColumnConfig,
|
3
|
-
FieldRenderer,
|
4
|
-
GristClassifier,
|
5
|
-
GristConfig,
|
6
|
-
GristData,
|
7
|
-
GristEventHandlerSet,
|
8
|
-
GristRecord,
|
9
|
-
GroupConfig,
|
10
|
-
LabelConfig,
|
11
|
-
ListConfig,
|
12
|
-
TreeConfig,
|
13
|
-
RowsConfig
|
14
|
-
} from '../types'
|
15
|
-
|
16
|
-
export const ZERO_CLASSIFIER: GristClassifier = (record, rowIndex) => {}
|
17
|
-
export const ZERO_FIELD_RENDERER: FieldRenderer = (value, column, record, rowIndex, owner) => {}
|
18
|
-
|
19
|
-
export const ZERO_EVENTHANDLERSET: GristEventHandlerSet = {
|
20
|
-
click: undefined,
|
21
|
-
dblclick: undefined,
|
22
|
-
focus: undefined,
|
23
|
-
contextmenu: undefined
|
24
|
-
}
|
25
|
-
export const ZERO_COLUMNS: ColumnConfig[] = []
|
26
|
-
export const ZERO_GROUPS: GroupConfig[] = []
|
27
|
-
export const ZERO_TOTALS: [] = []
|
28
|
-
export const ZERO_LABEL: LabelConfig = false
|
29
|
-
|
30
|
-
export const ZERO_COLUMN: ColumnConfig = {
|
31
|
-
type: '',
|
32
|
-
name: '',
|
33
|
-
header: {
|
34
|
-
renderer: column => {}
|
35
|
-
},
|
36
|
-
record: {
|
37
|
-
renderer: ZERO_FIELD_RENDERER,
|
38
|
-
classifier: ZERO_CLASSIFIER,
|
39
|
-
options: {}
|
40
|
-
},
|
41
|
-
handlers: ZERO_EVENTHANDLERSET,
|
42
|
-
label: ZERO_LABEL
|
43
|
-
}
|
44
|
-
|
45
|
-
export const ZERO_ROWS: RowsConfig = {
|
46
|
-
appendable: false,
|
47
|
-
insertable: false,
|
48
|
-
editable: false,
|
49
|
-
groups: ZERO_GROUPS,
|
50
|
-
totals: ZERO_TOTALS,
|
51
|
-
classifier: ZERO_CLASSIFIER,
|
52
|
-
handlers: ZERO_EVENTHANDLERSET
|
53
|
-
}
|
54
|
-
|
55
|
-
export const ZERO_LIST: ListConfig = {
|
56
|
-
fields: ['name', 'description', 'updatedAt'],
|
57
|
-
details: []
|
58
|
-
}
|
59
|
-
|
60
|
-
export const ZERO_TREE: TreeConfig = {}
|
61
|
-
|
62
|
-
export const ZERO_CONFIG: GristConfig = {
|
63
|
-
columns: ZERO_COLUMNS,
|
64
|
-
rows: ZERO_ROWS,
|
65
|
-
list: ZERO_LIST,
|
66
|
-
tree: ZERO_TREE
|
67
|
-
}
|
68
|
-
|
69
|
-
export const ZERO_RECORD: GristRecord = {}
|
70
|
-
export const ZERO_RECORDS: GristRecord[] = []
|
71
|
-
|
72
|
-
export const ZERO_DATA: GristData = {
|
73
|
-
records: ZERO_RECORDS
|
74
|
-
}
|
75
|
-
|
76
|
-
export const ZERO_PAGES = [20, 30, 50, 100]
|
77
|
-
|
78
|
-
export const ZERO_PAGINATION = {
|
79
|
-
page: 1,
|
80
|
-
limit: 20,
|
81
|
-
total: 0,
|
82
|
-
pages: ZERO_PAGES
|
83
|
-
}
|
package/src/const.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export const NOOP = function () {}
|