@operato/data-grist 8.0.0-beta.0 → 8.0.0-beta.1
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 +9 -0
- package/package.json +10 -10
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- 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 -298
- 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 -85
- package/src/data-grid/data-grid-body.ts +0 -765
- package/src/data-grid/data-grid-field.ts +0 -227
- package/src/data-grid/data-grid-footer.ts +0 -119
- package/src/data-grid/data-grid-header.ts +0 -578
- 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 -264
- 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 -257
- 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 -287
- 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/CHANGELOG.md
CHANGED
@@ -3,6 +3,15 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
|
7
|
+
|
8
|
+
|
9
|
+
### :bug: Bug Fix
|
10
|
+
|
11
|
+
* missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
|
12
|
+
|
13
|
+
|
14
|
+
|
6
15
|
## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
|
7
16
|
|
8
17
|
**Note:** Version bump only for package @operato/data-grist
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@operato/data-grist",
|
3
|
-
"version": "8.0.0-beta.
|
3
|
+
"version": "8.0.0-beta.1",
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
5
5
|
"author": "heartyoh",
|
6
6
|
"main": "dist/index.js",
|
@@ -62,14 +62,14 @@
|
|
62
62
|
},
|
63
63
|
"dependencies": {
|
64
64
|
"@material/web": "^2.0.0",
|
65
|
-
"@operato/headroom": "^8.0.0-beta.
|
66
|
-
"@operato/input": "^8.0.0-beta.
|
67
|
-
"@operato/p13n": "^8.0.0-beta.
|
68
|
-
"@operato/popup": "^8.0.0-beta.
|
69
|
-
"@operato/pull-to-refresh": "^8.0.0-beta.
|
70
|
-
"@operato/styles": "^8.0.0-beta.
|
71
|
-
"@operato/time-calculator": "^8.0.0-beta.
|
72
|
-
"@operato/utils": "^8.0.0-beta.
|
65
|
+
"@operato/headroom": "^8.0.0-beta.1",
|
66
|
+
"@operato/input": "^8.0.0-beta.1",
|
67
|
+
"@operato/p13n": "^8.0.0-beta.1",
|
68
|
+
"@operato/popup": "^8.0.0-beta.1",
|
69
|
+
"@operato/pull-to-refresh": "^8.0.0-beta.1",
|
70
|
+
"@operato/styles": "^8.0.0-beta.1",
|
71
|
+
"@operato/time-calculator": "^8.0.0-beta.1",
|
72
|
+
"@operato/utils": "^8.0.0-beta.1",
|
73
73
|
"i18next": "^23.11.5",
|
74
74
|
"json5": "^2.2.0",
|
75
75
|
"lit": "^3.1.2",
|
@@ -108,5 +108,5 @@
|
|
108
108
|
"prettier --write"
|
109
109
|
]
|
110
110
|
},
|
111
|
-
"gitHead": "
|
111
|
+
"gitHead": "d5b28a2e9deb632c0dc80132f6a7196dd6fe4220"
|
112
112
|
}
|
package/.storybook/main.js
DELETED
package/.storybook/preview.js
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
import { i18next } from '@operato/i18n'
|
2
|
-
|
3
|
-
export const globalTypes = {
|
4
|
-
locale: {
|
5
|
-
name: 'Locale',
|
6
|
-
description: 'Internationalization locale',
|
7
|
-
toolbar: {
|
8
|
-
icon: 'globe',
|
9
|
-
items: [
|
10
|
-
{ value: 'en', right: '🇺🇸', title: 'English' },
|
11
|
-
{ value: 'ko', right: '🇰🇷', title: '한국어' },
|
12
|
-
{ value: 'zh', right: '🇨🇳', title: '中文' },
|
13
|
-
{ value: 'ja', right: '🇯🇵', title: '日本語' },
|
14
|
-
{ value: 'ms', right: '🇲🇾', title: 'Bahasa Melayu' }
|
15
|
-
],
|
16
|
-
showName: true
|
17
|
-
}
|
18
|
-
},
|
19
|
-
theme: {
|
20
|
-
name: 'Theme',
|
21
|
-
description: 'Global theme for components',
|
22
|
-
toolbar: {
|
23
|
-
icon: 'paintbrush',
|
24
|
-
items: [
|
25
|
-
{ value: 'light', title: 'Light' },
|
26
|
-
{ value: 'dark', title: 'Dark' }
|
27
|
-
],
|
28
|
-
showName: true
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
export const decorators = [
|
34
|
-
(Story, context) => {
|
35
|
-
const { locale, theme } = context.globals
|
36
|
-
|
37
|
-
if (locale) {
|
38
|
-
i18next.changeLanguage(locale)
|
39
|
-
}
|
40
|
-
|
41
|
-
// Set the theme class for the document
|
42
|
-
if (theme === 'dark') {
|
43
|
-
document.documentElement.classList.add('dark')
|
44
|
-
document.documentElement.classList.remove('light')
|
45
|
-
} else {
|
46
|
-
document.documentElement.classList.add('light')
|
47
|
-
document.documentElement.classList.remove('dark')
|
48
|
-
}
|
49
|
-
|
50
|
-
return Story()
|
51
|
-
}
|
52
|
-
]
|
package/.storybook/server.mjs
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import { storybookPlugin } from '@web/dev-server-storybook';
|
2
|
-
import baseConfig from '../web-dev-server.config.mjs';
|
3
|
-
|
4
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
5
|
-
...baseConfig,
|
6
|
-
open: '/',
|
7
|
-
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
8
|
-
});
|
@@ -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 () {}
|
@@ -1,94 +0,0 @@
|
|
1
|
-
import { css, html, LitElement, TemplateResult } from 'lit'
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
3
|
-
|
4
|
-
import { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config'
|
5
|
-
import { ColumnConfig, GristRecord } from '../types'
|
6
|
-
|
7
|
-
@customElement('ox-card-field')
|
8
|
-
export class DataCardField extends LitElement {
|
9
|
-
static styles = [
|
10
|
-
css`
|
11
|
-
:host {
|
12
|
-
display: flex;
|
13
|
-
align-items: center;
|
14
|
-
justify-content: flex-start;
|
15
|
-
position: relative;
|
16
|
-
|
17
|
-
white-space: nowrap;
|
18
|
-
|
19
|
-
font: inherit;
|
20
|
-
}
|
21
|
-
|
22
|
-
:host([thumbnail]) {
|
23
|
-
flex-direction: column;
|
24
|
-
justify-content: center;
|
25
|
-
}
|
26
|
-
|
27
|
-
:host([thumbnail]) > * {
|
28
|
-
object-fit: contain;
|
29
|
-
max-width: 100%;
|
30
|
-
max-height: 100%;
|
31
|
-
}
|
32
|
-
|
33
|
-
:host > * {
|
34
|
-
margin: var(--spacing-none);
|
35
|
-
|
36
|
-
overflow: hidden;
|
37
|
-
|
38
|
-
text-overflow: ellipsis;
|
39
|
-
text-align: left;
|
40
|
-
}
|
41
|
-
|
42
|
-
:host > *[center] {
|
43
|
-
flex: none;
|
44
|
-
margin: var(--spacing-none) auto;
|
45
|
-
}
|
46
|
-
|
47
|
-
:host([name]) label {
|
48
|
-
display: none;
|
49
|
-
}
|
50
|
-
|
51
|
-
label {
|
52
|
-
flex: none;
|
53
|
-
width: 33%;
|
54
|
-
padding-bottom: 2px;
|
55
|
-
font: var(--data-card-item-etc-label-font);
|
56
|
-
text-transform: capitalize;
|
57
|
-
}
|
58
|
-
|
59
|
-
:host([name]) > span,
|
60
|
-
label + a {
|
61
|
-
display: block;
|
62
|
-
min-width: 100%;
|
63
|
-
}
|
64
|
-
|
65
|
-
@media only screen and (max-width: 460px) {
|
66
|
-
*[center] {
|
67
|
-
margin: initial;
|
68
|
-
}
|
69
|
-
}
|
70
|
-
`
|
71
|
-
]
|
72
|
-
|
73
|
-
@property({ attribute: true }) align?: string
|
74
|
-
@property({ type: Object }) record: GristRecord = ZERO_RECORD
|
75
|
-
@property({ type: Object }) column: ColumnConfig = ZERO_COLUMN
|
76
|
-
@property({ type: Number }) rowIndex: number = -1
|
77
|
-
@property({ type: Object }) value?: object
|
78
|
-
|
79
|
-
render(): TemplateResult {
|
80
|
-
var { value, column, record, rowIndex } = this
|
81
|
-
|
82
|
-
var {
|
83
|
-
label,
|
84
|
-
record: { renderer: recordRenderer }
|
85
|
-
} = column
|
86
|
-
|
87
|
-
if (typeof label == 'object') {
|
88
|
-
let { renderer: labelRenderer } = label
|
89
|
-
return html`<label>${labelRenderer(column)}</label>${recordRenderer(value, column, record, rowIndex, this)}`
|
90
|
-
} else {
|
91
|
-
return html`${recordRenderer(value, column, record, rowIndex, this)}`
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}
|