@operato/data-grist 0.2.36 → 0.2.40
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 +36 -0
- package/custom-elements.json +13 -8
- package/dist/src/data-card/data-card-field.d.ts +2 -2
- package/dist/src/data-card/data-card-field.js +2 -2
- package/dist/src/data-card/data-card-field.js.map +1 -1
- package/dist/src/data-card/data-card.d.ts +1 -1
- package/dist/src/data-card/data-card.js +2 -8
- package/dist/src/data-card/data-card.js.map +1 -1
- package/dist/src/data-consumer.d.ts +1 -10
- package/dist/src/data-consumer.js.map +1 -1
- package/dist/src/data-grist.d.ts +4 -4
- package/dist/src/data-grist.js +21 -16
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-list/data-list-field.d.ts +2 -2
- package/dist/src/data-list/data-list-field.js +2 -2
- package/dist/src/data-list/data-list-field.js.map +1 -1
- package/dist/src/data-list/data-list.d.ts +1 -1
- package/dist/src/data-list/data-list.js +2 -8
- package/dist/src/data-list/data-list.js.map +1 -1
- package/dist/src/data-provider.js +2 -2
- package/dist/src/data-provider.js.map +1 -1
- package/dist/src/types.d.ts +15 -3
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/data-card/data-card-field.ts +5 -4
- package/src/data-card/data-card.ts +3 -9
- package/src/data-consumer.ts +1 -6
- package/src/data-grist.ts +32 -21
- package/src/data-list/data-list-field.ts +5 -4
- package/src/data-list/data-list.ts +3 -9
- package/src/data-provider.ts +4 -5
- package/src/types.ts +12 -3
package/src/data-consumer.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { GristData } from './types'
|
|
2
|
-
|
|
3
|
-
export type FetchHandler = (param?: { page?: number; limit?: number; sorters?: object[]; options?: object }) => {
|
|
4
|
-
total: number
|
|
5
|
-
records: object[]
|
|
6
|
-
}
|
|
1
|
+
import { FetchHandler, GristData } from './types'
|
|
7
2
|
|
|
8
3
|
export interface DataConsumer extends EventTarget {
|
|
9
4
|
data: any
|
package/src/data-grist.ts
CHANGED
|
@@ -3,22 +3,23 @@ import './data-list/data-list'
|
|
|
3
3
|
import './data-card/data-card'
|
|
4
4
|
import './empty-note'
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { GristConfig, GristData, GristRecord } from './types'
|
|
8
|
-
import { HeadroomStyles, ScrollbarStyles, SpinnerStyles } from '@operato/styles'
|
|
9
|
-
import { LitElement, PropertyValues, css, html } from 'lit'
|
|
10
|
-
import { ZERO_CONFIG, ZERO_DATA, ZERO_PAGINATION } from './configure/zero-config'
|
|
6
|
+
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
11
7
|
import { customElement, property, query, queryAsync, state } from 'lit/decorators.js'
|
|
8
|
+
import isEmpty from 'lodash-es/isEmpty'
|
|
9
|
+
import isEqual from 'lodash-es/isEqual'
|
|
10
|
+
|
|
11
|
+
import Headroom from '@operato/headroom'
|
|
12
|
+
import { pulltorefresh } from '@operato/pull-to-refresh'
|
|
13
|
+
import { HeadroomStyles, ScrollbarStyles, SpinnerStyles } from '@operato/styles'
|
|
12
14
|
|
|
15
|
+
import { buildConfig } from './configure/config-builder'
|
|
16
|
+
import { ZERO_CONFIG, ZERO_DATA, ZERO_PAGINATION } from './configure/zero-config'
|
|
13
17
|
import { DataCard } from './data-card/data-card'
|
|
18
|
+
import { DataConsumer } from './data-consumer'
|
|
14
19
|
import { DataGrid } from './data-grid/data-grid'
|
|
15
20
|
import { DataList } from './data-list/data-list'
|
|
16
21
|
import { DataProvider } from './data-provider'
|
|
17
|
-
import
|
|
18
|
-
import { buildConfig } from './configure/config-builder'
|
|
19
|
-
import isEmpty from 'lodash-es/isEmpty'
|
|
20
|
-
import isEqual from 'lodash-es/isEqual'
|
|
21
|
-
import { pulltorefresh } from '@operato/pull-to-refresh'
|
|
22
|
+
import { FetchHandler, GristConfig, GristData, GristRecord } from './types'
|
|
22
23
|
|
|
23
24
|
@customElement('ox-grist')
|
|
24
25
|
export class DataGrist extends LitElement implements DataConsumer {
|
|
@@ -90,9 +91,8 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
|
90
91
|
private dataProvider?: DataProvider
|
|
91
92
|
private _pulltorefreshHandle?: any
|
|
92
93
|
private _headroom?: Headroom
|
|
93
|
-
private
|
|
94
|
-
|
|
95
|
-
})
|
|
94
|
+
private orginPaddingTop?: string
|
|
95
|
+
private originMarginTop?: string
|
|
96
96
|
|
|
97
97
|
@query('slot[name=headroom]') head!: HTMLElement
|
|
98
98
|
@query('#grist') grist!: DataGrid | DataList | DataCard
|
|
@@ -104,7 +104,6 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
|
104
104
|
this.dataProvider = new DataProvider(this)
|
|
105
105
|
|
|
106
106
|
await this.updateComplete
|
|
107
|
-
this._resizeObserver.observe(this.head)
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
disconnectedCallback() {
|
|
@@ -112,7 +111,6 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
|
112
111
|
|
|
113
112
|
this.dataProvider?.dispose()
|
|
114
113
|
this._resetPullToRefresh()
|
|
115
|
-
this._resizeObserver.unobserve(this.head)
|
|
116
114
|
}
|
|
117
115
|
|
|
118
116
|
private _resetPullToRefresh() {
|
|
@@ -135,18 +133,31 @@ export class DataGrist extends LitElement implements DataConsumer {
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
private _adjustPaddingTop() {
|
|
139
|
-
this.grist.style.paddingTop = this.head.clientHeight + 'px'
|
|
140
|
-
}
|
|
141
|
-
|
|
142
136
|
private _setHeadroom() {
|
|
143
137
|
this._headroom?.destroy()
|
|
144
138
|
|
|
145
139
|
if (this.grist && this.head) {
|
|
146
|
-
this.
|
|
140
|
+
const style = getComputedStyle(this.grist)
|
|
141
|
+
|
|
142
|
+
this.orginPaddingTop = style.paddingTop || '0'
|
|
143
|
+
this.originMarginTop = style.marginTop || '0'
|
|
144
|
+
|
|
145
|
+
console.log(this.orginPaddingTop, this.originMarginTop)
|
|
147
146
|
|
|
148
147
|
this._headroom = new Headroom(this.head, {
|
|
149
|
-
scroller: this.grist
|
|
148
|
+
scroller: this.grist,
|
|
149
|
+
onTop: () => {
|
|
150
|
+
this.grist.style.paddingTop = this.orginPaddingTop!
|
|
151
|
+
|
|
152
|
+
this.originMarginTop = this.grist.style.marginTop
|
|
153
|
+
this.grist.style.marginTop = this.head.clientHeight + 'px'
|
|
154
|
+
},
|
|
155
|
+
onNotTop: () => {
|
|
156
|
+
this.grist.style.marginTop = this.originMarginTop!
|
|
157
|
+
|
|
158
|
+
this.orginPaddingTop = this.grist.style.paddingTop
|
|
159
|
+
this.grist.style.paddingTop = this.head.clientHeight + 'px'
|
|
160
|
+
}
|
|
150
161
|
})
|
|
151
162
|
this._headroom.init()
|
|
152
163
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LitElement, css, html } from 'lit'
|
|
3
|
-
import { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config'
|
|
1
|
+
import { css, html, LitElement, TemplateResult } from 'lit'
|
|
4
2
|
import { customElement, property } from 'lit/decorators.js'
|
|
5
3
|
|
|
4
|
+
import { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config'
|
|
5
|
+
import { ColumnConfig, GristRecord } from '../types'
|
|
6
|
+
|
|
6
7
|
@customElement('ox-list-field')
|
|
7
8
|
export class DataListField extends LitElement {
|
|
8
9
|
static styles = [
|
|
@@ -56,7 +57,7 @@ export class DataListField extends LitElement {
|
|
|
56
57
|
@property({ type: Number }) rowIndex: number = -1
|
|
57
58
|
@property({ type: Object }) value?: object
|
|
58
59
|
|
|
59
|
-
render() {
|
|
60
|
+
render(): TemplateResult {
|
|
60
61
|
var { value, column, record, rowIndex } = this
|
|
61
62
|
|
|
62
63
|
var {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import '@material/mwc-icon'
|
|
2
2
|
import './record-partial'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { LitElement, PropertyValues, css, html } from 'lit'
|
|
6
|
-
import { ZERO_CONFIG, ZERO_DATA } from '../configure/zero-config'
|
|
4
|
+
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
7
5
|
import { customElement, property } from 'lit/decorators.js'
|
|
8
6
|
|
|
7
|
+
import { ZERO_CONFIG, ZERO_DATA } from '../configure/zero-config'
|
|
8
|
+
import { ColumnConfig, GristConfig, GristData, GristRecord } from '../types'
|
|
9
9
|
import { dataListClickHandler } from './event-handlers/data-list-click-handler'
|
|
10
10
|
import { dataListDblclickHandler } from './event-handlers/data-list-dblclick-handler'
|
|
11
11
|
|
|
@@ -41,12 +41,6 @@ export class DataList extends LitElement {
|
|
|
41
41
|
slot {
|
|
42
42
|
width: 100%;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
slot[name='headroom'] {
|
|
46
|
-
display: flex;
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 0;
|
|
49
|
-
}
|
|
50
44
|
`
|
|
51
45
|
]
|
|
52
46
|
|
package/src/data-provider.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DataConsumer, FetchHandler } from './data-consumer'
|
|
2
|
-
import { GristRecord, SorterConfig } from './types'
|
|
3
|
-
|
|
4
1
|
import { ZERO_RECORDS } from './configure/zero-config'
|
|
2
|
+
import { DataConsumer } from './data-consumer'
|
|
3
|
+
import { FetchHandler, FetchOption, GristRecord, SorterConfig } from './types'
|
|
5
4
|
|
|
6
5
|
function EMPTY_FETCHHANDLER() {
|
|
7
6
|
return {
|
|
@@ -92,14 +91,14 @@ export class DataProvider {
|
|
|
92
91
|
|
|
93
92
|
get fetchHandler() {
|
|
94
93
|
if (!this._fetchHandlerWrap) {
|
|
95
|
-
this._fetchHandlerWrap = async (
|
|
94
|
+
this._fetchHandlerWrap = async (options: FetchOption) => {
|
|
96
95
|
if (!this._fetchHandler) {
|
|
97
96
|
return
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
try {
|
|
101
100
|
this.consumer?.showSpinner()
|
|
102
|
-
return await (this._fetchHandler || EMPTY_FETCHHANDLER)(
|
|
101
|
+
return await (this._fetchHandler || EMPTY_FETCHHANDLER)(options)
|
|
103
102
|
} finally {
|
|
104
103
|
this.consumer?.hideSpinner()
|
|
105
104
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit-html'
|
|
2
|
+
|
|
1
3
|
import { DataCardField } from './data-card/data-card-field'
|
|
2
4
|
import { DataCardGutter } from './data-card/data-card-gutter'
|
|
5
|
+
import { RecordCard } from './data-card/record-card'
|
|
3
6
|
import { DataGridField } from './data-grid/data-grid-field'
|
|
4
7
|
import { DataListField } from './data-list/data-list-field'
|
|
5
8
|
import { DataListGutter } from './data-list/data-list-gutter'
|
|
6
|
-
import { DataReportField } from './data-report/data-report-field'
|
|
7
|
-
import { RecordCard } from './data-card/record-card'
|
|
8
9
|
import { RecordPartial } from './data-list/record-partial'
|
|
9
|
-
import {
|
|
10
|
+
import { DataReportField } from './data-report/data-report-field'
|
|
10
11
|
|
|
11
12
|
export type GristConfig = {
|
|
12
13
|
columns: ColumnConfig[]
|
|
@@ -27,6 +28,14 @@ export type PaginationConfig = {
|
|
|
27
28
|
infinite?: boolean
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
export type FetchOption = { page?: number; limit?: number; sorters?: object[]; options?: object }
|
|
32
|
+
export type FetchHandler = (param: FetchOption) => {
|
|
33
|
+
page?: number
|
|
34
|
+
limit?: number
|
|
35
|
+
total: number
|
|
36
|
+
records: object[]
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
export type GristEventHandler = (
|
|
31
40
|
columns: ColumnConfig[],
|
|
32
41
|
data?: GristData,
|