@operato/data-grist 0.3.17 → 0.3.21
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 +38 -0
- package/custom-elements.json +343 -336
- package/demo/data-grist-test.html +142 -85
- package/demo/index.html +60 -95
- package/dist/src/configure/column-builder.js +26 -2
- package/dist/src/configure/column-builder.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.js +5 -3
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-grist.js +5 -0
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/filters/filter-checkbox.js +2 -2
- package/dist/src/filters/filter-checkbox.js.map +1 -1
- package/dist/src/filters/filter-input.js +1 -1
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.js +1 -1
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.js +1 -1
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/filters/filter-select.js +2 -2
- package/dist/src/filters/filter-select.js.map +1 -1
- package/dist/src/filters/filters-form.d.ts +9 -5
- package/dist/src/filters/filters-form.js +63 -15
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/record-view/record-view-body.js +4 -2
- package/dist/src/record-view/record-view-body.js.map +1 -1
- package/dist/src/sorters/sorters-control.js +22 -8
- package/dist/src/sorters/sorters-control.js.map +1 -1
- package/dist/src/types.d.ts +6 -3
- package/dist/src/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/configure/column-builder.ts +29 -3
- package/src/data-grid/data-grid-header.ts +7 -5
- package/src/data-grist.ts +8 -0
- package/src/filters/filter-checkbox.ts +3 -2
- package/src/filters/filter-input.ts +3 -3
- package/src/filters/filter-range-date.ts +3 -3
- package/src/filters/filter-range-number.ts +3 -3
- package/src/filters/filter-select.ts +3 -2
- package/src/filters/filters-form.ts +77 -41
- package/src/record-view/record-view-body.ts +4 -2
- package/src/sorters/sorters-control.ts +22 -8
- package/src/types.ts +33 -30
- package/dist/src/editors/image-editor.d.ts +0 -9
- package/dist/src/editors/image-editor.js +0 -53
- package/dist/src/editors/image-editor.js.map +0 -1
- package/dist/src/editors/input-editors copy.d.ts +0 -75
- package/dist/src/editors/input-editors copy.js +0 -373
- package/dist/src/editors/input-editors copy.js.map +0 -1
- package/dist/src/record-view/record-creator copy.d.ts +0 -13
- package/dist/src/record-view/record-creator copy.js +0 -90
- package/dist/src/record-view/record-creator copy.js.map +0 -1
- package/dist/src/record-view/record-creator-backup.d.ts +0 -13
- package/dist/src/record-view/record-creator-backup.js +0 -90
- package/dist/src/record-view/record-creator-backup.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html'
|
|
2
2
|
|
|
3
|
-
import { FilterSelectRenderer } from '../types'
|
|
3
|
+
import { FilterConfigObject, FilterSelectRenderer } from '../types'
|
|
4
4
|
|
|
5
5
|
export const FilterCheckbox: FilterSelectRenderer = (column, owner) => {
|
|
6
|
-
const
|
|
6
|
+
const filter = column.filter as FilterConfigObject
|
|
7
|
+
const options = filter?.options
|
|
7
8
|
|
|
8
9
|
return html`
|
|
9
10
|
<input
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html'
|
|
2
2
|
|
|
3
|
-
import { FilterSelectRenderer } from '../types'
|
|
3
|
+
import { FilterConfigObject, FilterSelectRenderer } from '../types'
|
|
4
4
|
|
|
5
5
|
export const FilterInput: FilterSelectRenderer = (column, owner) => {
|
|
6
|
-
const filter = column.filter
|
|
7
|
-
const type =
|
|
6
|
+
const filter = column.filter as FilterConfigObject
|
|
7
|
+
const type = filter?.type || column.type
|
|
8
8
|
|
|
9
9
|
return html` <input type=${type} name="${column.name}" /> `
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html'
|
|
2
2
|
|
|
3
|
-
import { FilterSelectRenderer } from '../types'
|
|
3
|
+
import { FilterConfigObject, FilterSelectRenderer } from '../types'
|
|
4
4
|
|
|
5
5
|
export const FilterRangeDate: FilterSelectRenderer = (column, owner) => {
|
|
6
|
-
const filter = column.filter
|
|
7
|
-
var type =
|
|
6
|
+
const filter = column.filter as FilterConfigObject
|
|
7
|
+
var type = filter?.type || column.type
|
|
8
8
|
if (type === 'datetime') {
|
|
9
9
|
type = 'datetime-local'
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html } from 'lit-html'
|
|
2
2
|
|
|
3
|
-
import { FilterSelectRenderer } from '../types'
|
|
3
|
+
import { FilterConfigObject, FilterSelectRenderer } from '../types'
|
|
4
4
|
|
|
5
5
|
export const FilterRangeNumber: FilterSelectRenderer = (column, owner) => {
|
|
6
|
-
const filter = column.filter
|
|
7
|
-
const type =
|
|
6
|
+
const filter = column.filter as FilterConfigObject
|
|
7
|
+
const type = filter?.type || column.type
|
|
8
8
|
|
|
9
9
|
return html`
|
|
10
10
|
<input name="${column.name}" type="number" placeholder="minimum" /> ~
|
|
@@ -2,10 +2,11 @@ import '@operato/input/ox-checkbox.js'
|
|
|
2
2
|
|
|
3
3
|
import { html } from 'lit-html'
|
|
4
4
|
|
|
5
|
-
import { FilterSelectRenderer } from '../types'
|
|
5
|
+
import { FilterConfigObject, FilterSelectRenderer } from '../types'
|
|
6
6
|
|
|
7
7
|
export const FilterSelect: FilterSelectRenderer = (column, owner) => {
|
|
8
|
-
const
|
|
8
|
+
const filter = column.filter as FilterConfigObject
|
|
9
|
+
const options = filter?.options || []
|
|
9
10
|
|
|
10
11
|
return html`
|
|
11
12
|
${options?.map((option: string) => html` <ox-checkbox option value=${option}>${option}</ox-checkbox> `)}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import '@operato/input/ox-checkbox.js'
|
|
2
2
|
import '@operato/input/ox-select.js'
|
|
3
3
|
import '@operato/popup/ox-popup-list.js'
|
|
4
|
+
import '@operato/input/ox-input-search.js'
|
|
4
5
|
|
|
5
|
-
import { css, html, LitElement, TemplateResult } from 'lit'
|
|
6
|
-
import { customElement,
|
|
6
|
+
import { css, html, LitElement, PropertyValues, TemplateResult } from 'lit'
|
|
7
|
+
import { customElement, queryAsync, state } from 'lit/decorators.js'
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { FilterConfigObject } from '..'
|
|
10
|
+
import { DataGrist } from '../data-grist'
|
|
11
|
+
import { ColumnConfig, FilterOperator, GristConfig } from '../types'
|
|
10
12
|
import { FilterStyles } from './filter-styles'
|
|
11
13
|
import { getFilterRenderer } from './registry'
|
|
12
14
|
|
|
@@ -14,30 +16,7 @@ export type QueryFilterRangeValue = [from: number, to: number]
|
|
|
14
16
|
|
|
15
17
|
export type QueryFilter = {
|
|
16
18
|
name: string
|
|
17
|
-
operator
|
|
18
|
-
| 'eq'
|
|
19
|
-
| 'between'
|
|
20
|
-
| 'gte'
|
|
21
|
-
| 'lte'
|
|
22
|
-
| 'is_not_true'
|
|
23
|
-
| 'in'
|
|
24
|
-
| 'like'
|
|
25
|
-
| 'i_like'
|
|
26
|
-
| 'noteq'
|
|
27
|
-
| 'is_empty_num_id'
|
|
28
|
-
| 'is_blank'
|
|
29
|
-
| 'is_present'
|
|
30
|
-
| 'is_not_false'
|
|
31
|
-
| 'is_true'
|
|
32
|
-
| 'is_false'
|
|
33
|
-
| 'is_not_null'
|
|
34
|
-
| 'is_null'
|
|
35
|
-
| 'notin_with_null'
|
|
36
|
-
| 'notin'
|
|
37
|
-
| 'gt'
|
|
38
|
-
| 'lt'
|
|
39
|
-
| 'i_nlike'
|
|
40
|
-
| 'nlike'
|
|
19
|
+
operator: FilterOperator
|
|
41
20
|
value: any
|
|
42
21
|
}
|
|
43
22
|
|
|
@@ -61,16 +40,57 @@ export class FiltersForm extends LitElement {
|
|
|
61
40
|
`
|
|
62
41
|
]
|
|
63
42
|
|
|
64
|
-
@
|
|
65
|
-
@property({ type: String }) defaultOperator: string = 'eq'
|
|
66
|
-
@query('form') form!: HTMLFormElement
|
|
43
|
+
@state() config!: GristConfig
|
|
67
44
|
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
@state() filterColumns: ColumnConfig[] = []
|
|
46
|
+
@state() searchColumns: ColumnConfig[] = []
|
|
47
|
+
|
|
48
|
+
@queryAsync('form') form!: HTMLFormElement
|
|
49
|
+
|
|
50
|
+
connectedCallback(): void {
|
|
51
|
+
super.connectedCallback()
|
|
52
|
+
|
|
53
|
+
const grist = this.closest('ox-grist') as DataGrist
|
|
54
|
+
|
|
55
|
+
if (grist) {
|
|
56
|
+
this.config = grist.compiledConfig
|
|
57
|
+
grist.addEventListener('config-change', (e: Event) => {
|
|
58
|
+
this.config = (e as CustomEvent).detail
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
this.renderRoot.addEventListener('change', async (e: Event) => {
|
|
62
|
+
e.stopPropagation()
|
|
63
|
+
|
|
64
|
+
this.dispatchEvent(
|
|
65
|
+
new CustomEvent('change', {
|
|
66
|
+
bubbles: true,
|
|
67
|
+
composed: true,
|
|
68
|
+
detail: await this.getQueryFilters()
|
|
69
|
+
})
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
}
|
|
70
74
|
|
|
75
|
+
updated(changes: PropertyValues<this>) {
|
|
76
|
+
if (changes.has('config')) {
|
|
77
|
+
const filters = this.config.columns.filter(columnConfig => !!columnConfig.filter)
|
|
78
|
+
this.filterColumns = filters.filter((columnConfig: ColumnConfig) => {
|
|
79
|
+
const filter = columnConfig.filter as FilterConfigObject
|
|
80
|
+
return filter!.operator !== 'search'
|
|
81
|
+
})
|
|
82
|
+
this.searchColumns = filters.filter(columnConfig => {
|
|
83
|
+
const filter = columnConfig.filter as FilterConfigObject
|
|
84
|
+
return filter!.operator === 'search'
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
render(): TemplateResult {
|
|
71
90
|
return html`
|
|
72
91
|
<form>
|
|
73
|
-
${
|
|
92
|
+
${this.searchColumns.length === 0 ? html`` : html` <ox-input-search name="search"></ox-input-search> `}
|
|
93
|
+
${this.filterColumns.map((column: ColumnConfig) => {
|
|
74
94
|
const { name, label, filter } = column
|
|
75
95
|
const placeholder =
|
|
76
96
|
typeof label === 'string'
|
|
@@ -81,8 +101,8 @@ export class FiltersForm extends LitElement {
|
|
|
81
101
|
? label.renderer()
|
|
82
102
|
: name
|
|
83
103
|
|
|
84
|
-
const type =
|
|
85
|
-
const idx =
|
|
104
|
+
const type = (filter as FilterConfigObject).type
|
|
105
|
+
const idx = (filter as FilterConfigObject).operator === 'between' ? 1 : 0
|
|
86
106
|
const renderer = getFilterRenderer(type)[idx]
|
|
87
107
|
|
|
88
108
|
if (!renderer) {
|
|
@@ -103,14 +123,14 @@ export class FiltersForm extends LitElement {
|
|
|
103
123
|
`
|
|
104
124
|
}
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
async getQueryFilters(): Promise<QueryFilter[]> {
|
|
127
|
+
const formData = new FormData(await this.form)
|
|
128
|
+
const search: string | undefined = formData.get('search')?.toString()
|
|
108
129
|
|
|
109
|
-
|
|
110
|
-
.filter(columnConfig => columnConfig.filter)
|
|
130
|
+
var filters = this.filterColumns
|
|
111
131
|
.map((column: ColumnConfig) => {
|
|
112
132
|
const { name, filter } = column
|
|
113
|
-
const operator =
|
|
133
|
+
const operator = (filter as FilterConfigObject).operator
|
|
114
134
|
|
|
115
135
|
var value = formData.getAll(name)
|
|
116
136
|
if (value.length == 0) {
|
|
@@ -128,5 +148,21 @@ export class FiltersForm extends LitElement {
|
|
|
128
148
|
}
|
|
129
149
|
})
|
|
130
150
|
.filter(result => result !== undefined) as QueryFilter[]
|
|
151
|
+
|
|
152
|
+
if (search) {
|
|
153
|
+
filters = filters.concat(
|
|
154
|
+
this.searchColumns.map((column: ColumnConfig) => {
|
|
155
|
+
const { name } = column
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
name,
|
|
159
|
+
operator: 'search',
|
|
160
|
+
value: `%${search}%`
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return filters
|
|
131
167
|
}
|
|
132
168
|
}
|
|
@@ -85,11 +85,13 @@ export class RecordViewBody extends LitElement {
|
|
|
85
85
|
|
|
86
86
|
return html`
|
|
87
87
|
${columns.map(column => {
|
|
88
|
-
let { editable } = column.record
|
|
88
|
+
let { editable, mandatory } = column.record
|
|
89
89
|
let dirtyFields = record['__dirtyfields__'] || {}
|
|
90
90
|
|
|
91
91
|
return html`
|
|
92
|
-
<label ?editable=${editable}
|
|
92
|
+
<label ?editable=${editable}
|
|
93
|
+
><span>${mandatory ? '*' : ''}${this._renderLabel(column)}</span> <mwc-icon>edit</mwc-icon></label
|
|
94
|
+
>
|
|
93
95
|
<ox-grid-field
|
|
94
96
|
.rowIndex=${rowIndex}
|
|
95
97
|
.column=${column}
|
|
@@ -9,7 +9,21 @@ export class SortersControl extends LitElement {
|
|
|
9
9
|
static styles = [
|
|
10
10
|
css`
|
|
11
11
|
:host {
|
|
12
|
-
display:
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[option] {
|
|
18
|
+
flex: 1;
|
|
19
|
+
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[option] > span {
|
|
26
|
+
margin-right: auto;
|
|
13
27
|
}
|
|
14
28
|
`
|
|
15
29
|
]
|
|
@@ -24,9 +38,12 @@ export class SortersControl extends LitElement {
|
|
|
24
38
|
const grist = this.closest('ox-grist') as DataGrist
|
|
25
39
|
|
|
26
40
|
if (grist) {
|
|
27
|
-
this.config = grist.
|
|
41
|
+
this.config = grist.compiledConfig
|
|
42
|
+
grist.addEventListener('config-change', (e: Event) => {
|
|
43
|
+
this.config = (e as CustomEvent).detail
|
|
44
|
+
})
|
|
28
45
|
|
|
29
|
-
|
|
46
|
+
grist.addEventListener('sorters-change', e => {
|
|
30
47
|
this.sorters = (e as CustomEvent).detail as SorterConfig[]
|
|
31
48
|
})
|
|
32
49
|
}
|
|
@@ -36,10 +53,7 @@ export class SortersControl extends LitElement {
|
|
|
36
53
|
if (changes.has('config')) {
|
|
37
54
|
const sorters = this.config.sorters || []
|
|
38
55
|
|
|
39
|
-
this.columns =
|
|
40
|
-
.map(({ name }) => this.config.columns.find(column => column.name === name))
|
|
41
|
-
.filter(column => !!column) as ColumnConfig[]
|
|
42
|
-
|
|
56
|
+
this.columns = this.config.columns.filter(column => column.sortable)
|
|
43
57
|
this.sorters = this.config.sorters || []
|
|
44
58
|
}
|
|
45
59
|
}
|
|
@@ -66,7 +80,7 @@ export class SortersControl extends LitElement {
|
|
|
66
80
|
this.onChangeSort(name)
|
|
67
81
|
}}
|
|
68
82
|
>
|
|
69
|
-
|
|
83
|
+
<span>${column.header.renderer.call(this, column)}</span>
|
|
70
84
|
${desc === null
|
|
71
85
|
? html``
|
|
72
86
|
: html`
|
package/src/types.ts
CHANGED
|
@@ -19,36 +19,38 @@ export type GristConfig = {
|
|
|
19
19
|
|
|
20
20
|
export type SorterConfig = { name: string; desc?: boolean }
|
|
21
21
|
export type SortersConfig = SorterConfig[]
|
|
22
|
-
export type
|
|
23
|
-
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
22
|
+
export type FilterOperator =
|
|
23
|
+
| 'search'
|
|
24
|
+
| 'eq'
|
|
25
|
+
| 'between'
|
|
26
|
+
| 'gte'
|
|
27
|
+
| 'lte'
|
|
28
|
+
| 'is_not_true'
|
|
29
|
+
| 'in'
|
|
30
|
+
| 'like'
|
|
31
|
+
| 'i_like'
|
|
32
|
+
| 'noteq'
|
|
33
|
+
| 'is_empty_num_id'
|
|
34
|
+
| 'is_blank'
|
|
35
|
+
| 'is_present'
|
|
36
|
+
| 'is_not_false'
|
|
37
|
+
| 'is_true'
|
|
38
|
+
| 'is_false'
|
|
39
|
+
| 'is_not_null'
|
|
40
|
+
| 'is_null'
|
|
41
|
+
| 'notin_with_null'
|
|
42
|
+
| 'notin'
|
|
43
|
+
| 'gt'
|
|
44
|
+
| 'lt'
|
|
45
|
+
| 'i_nlike'
|
|
46
|
+
| 'nlike'
|
|
47
|
+
|
|
48
|
+
export type FilterConfigObject = {
|
|
49
|
+
type: string
|
|
50
|
+
operator?: FilterOperator
|
|
51
|
+
options?: { [key: string]: any }
|
|
52
|
+
}
|
|
53
|
+
export type FilterConfig = FilterConfigObject | FilterOperator | boolean
|
|
52
54
|
|
|
53
55
|
export type PaginationConfig = {
|
|
54
56
|
page?: number
|
|
@@ -115,6 +117,7 @@ export type RecordConfig = {
|
|
|
115
117
|
renderer: FieldRenderer
|
|
116
118
|
editor?: FieldEditor
|
|
117
119
|
editable?: boolean
|
|
120
|
+
mandatory?: boolean
|
|
118
121
|
classifier: GristClassifier
|
|
119
122
|
align?: 'left' | 'right' | 'center'
|
|
120
123
|
options: { [key: string]: any }
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import '@operato/input/ox-input-image.js';
|
|
2
|
-
import { InputEditor } from './input-editors';
|
|
3
|
-
export declare class ImageInput extends InputEditor {
|
|
4
|
-
imageInput: HTMLElement;
|
|
5
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
6
|
-
focus(): void;
|
|
7
|
-
_onchange(e: Event): void;
|
|
8
|
-
formatFromEditor(e: Event): string | File;
|
|
9
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import '@operato/input/ox-input-image.js';
|
|
3
|
-
import { html } from 'lit';
|
|
4
|
-
import { customElement, query } from 'lit/decorators.js';
|
|
5
|
-
import { InputEditor } from './input-editors';
|
|
6
|
-
let ImageInput = class ImageInput extends InputEditor {
|
|
7
|
-
get editorTemplate() {
|
|
8
|
-
return html ` <ox-input-image .value=${this.value}></ox-input-image> `;
|
|
9
|
-
// return html`${this.value
|
|
10
|
-
// ? html`<span
|
|
11
|
-
// ><button
|
|
12
|
-
// @click=${() => {
|
|
13
|
-
// this.imageInput.dispatchEvent(
|
|
14
|
-
// new Event('change', {
|
|
15
|
-
// bubbles: true
|
|
16
|
-
// })
|
|
17
|
-
// )
|
|
18
|
-
// }}
|
|
19
|
-
// >
|
|
20
|
-
// X</button
|
|
21
|
-
// >${this.value.name || this.value}</span
|
|
22
|
-
// >`
|
|
23
|
-
// : ''} <input type="file" accept="image/*" /> `
|
|
24
|
-
}
|
|
25
|
-
focus() {
|
|
26
|
-
if (!this.value)
|
|
27
|
-
this.imageInput.click();
|
|
28
|
-
}
|
|
29
|
-
_onchange(e) {
|
|
30
|
-
e.stopPropagation();
|
|
31
|
-
this._dirtyValue = this.formatFromEditor(e);
|
|
32
|
-
this._onfocusout();
|
|
33
|
-
}
|
|
34
|
-
formatFromEditor(e) {
|
|
35
|
-
var _a;
|
|
36
|
-
// value가 image file object인지, image url인지 확인
|
|
37
|
-
const input = e.target;
|
|
38
|
-
if ((_a = input.files) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
39
|
-
return input.files[0];
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return input.value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
__decorate([
|
|
47
|
-
query('input[type=file]')
|
|
48
|
-
], ImageInput.prototype, "imageInput", void 0);
|
|
49
|
-
ImageInput = __decorate([
|
|
50
|
-
customElement('ox-image-input')
|
|
51
|
-
], ImageInput);
|
|
52
|
-
export { ImageInput };
|
|
53
|
-
//# sourceMappingURL=image-editor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-editor.js","sourceRoot":"","sources":["../../../src/editors/image-editor.ts"],"names":[],"mappings":";AAAA,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,WAAW;IAGzC,IAAI,cAAc;QAChB,OAAO,IAAI,CAAA,2BAA2B,IAAI,CAAC,KAAK,qBAAqB,CAAA;QACrE,2BAA2B;QAC3B,mBAAmB;QACnB,mBAAmB;QACnB,6BAA6B;QAC7B,6CAA6C;QAC7C,sCAAsC;QACtC,gCAAgC;QAChC,mBAAmB;QACnB,gBAAgB;QAChB,eAAe;QACf,YAAY;QACZ,sBAAsB;QACtB,kDAAkD;QAClD,WAAW;QACX,qDAAqD;IACvD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;IAED,SAAS,CAAC,CAAQ;QAChB,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC3C,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;IAED,gBAAgB,CAAC,CAAQ;;QACvB,6CAA6C;QAC7C,MAAM,KAAK,GAAG,CAAC,CAAC,MAA0B,CAAA;QAC1C,IAAI,MAAA,KAAK,CAAC,KAAK,0CAAG,CAAC,CAAC,EAAE;YACpB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;SACtB;aAAM;YACL,OAAO,KAAK,CAAC,KAAK,CAAA;SACnB;IACH,CAAC;CACF,CAAA;AAxC4B;IAA1B,KAAK,CAAC,kBAAkB,CAAC;8CAAyB;AADxC,UAAU;IADtB,aAAa,CAAC,gBAAgB,CAAC;GACnB,UAAU,CAyCtB;SAzCY,UAAU","sourcesContent":["import '@operato/input/ox-input-image.js'\n\nimport { html } from 'lit'\nimport { customElement, query } from 'lit/decorators.js'\n\nimport { InputEditor } from './input-editors'\n\n@customElement('ox-image-input')\nexport class ImageInput extends InputEditor {\n @query('input[type=file]') imageInput!: HTMLElement\n\n get editorTemplate() {\n return html` <ox-input-image .value=${this.value}></ox-input-image> `\n // return html`${this.value\n // ? html`<span\n // ><button\n // @click=${() => {\n // this.imageInput.dispatchEvent(\n // new Event('change', {\n // bubbles: true\n // })\n // )\n // }}\n // >\n // X</button\n // >${this.value.name || this.value}</span\n // >`\n // : ''} <input type=\"file\" accept=\"image/*\" /> `\n }\n\n focus() {\n if (!this.value) this.imageInput.click()\n }\n\n _onchange(e: Event) {\n e.stopPropagation()\n this._dirtyValue = this.formatFromEditor(e)\n this._onfocusout()\n }\n\n formatFromEditor(e: Event) {\n // value가 image file object인지, image url인지 확인\n const input = e.target as HTMLInputElement\n if (input.files?.[0]) {\n return input.files[0]\n } else {\n return input.value\n }\n }\n}\n"]}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { DataGridField } from '../data-grid/data-grid-field';
|
|
3
|
-
import { ColumnConfig, GristRecord } from '../types';
|
|
4
|
-
export declare class InputEditor extends LitElement {
|
|
5
|
-
static styles: import("lit").CSSResult;
|
|
6
|
-
value?: any;
|
|
7
|
-
column: ColumnConfig;
|
|
8
|
-
record: GristRecord;
|
|
9
|
-
rowIndex?: number;
|
|
10
|
-
field?: DataGridField;
|
|
11
|
-
row?: number;
|
|
12
|
-
protected _dirtyValue?: any;
|
|
13
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
14
|
-
get editor(): HTMLElement | null;
|
|
15
|
-
firstUpdated(): Promise<void>;
|
|
16
|
-
select(): void;
|
|
17
|
-
focus(): void;
|
|
18
|
-
formatForEditor(value: any): any;
|
|
19
|
-
formatFromEditor(e: Event): any;
|
|
20
|
-
_onfocusout(): void;
|
|
21
|
-
_onchange(e: Event): void;
|
|
22
|
-
_onclick(e: Event): void;
|
|
23
|
-
_ondblclick(e: Event): void;
|
|
24
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
25
|
-
}
|
|
26
|
-
export declare class TextInput extends InputEditor {
|
|
27
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
28
|
-
}
|
|
29
|
-
export declare class EmailInput extends InputEditor {
|
|
30
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
31
|
-
}
|
|
32
|
-
export declare class TelInput extends InputEditor {
|
|
33
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
34
|
-
}
|
|
35
|
-
export declare class NumberInput extends InputEditor {
|
|
36
|
-
formatFromEditor(e: Event): number;
|
|
37
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
38
|
-
}
|
|
39
|
-
export declare class PasswordInput extends InputEditor {
|
|
40
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
41
|
-
}
|
|
42
|
-
export declare class DateInput extends InputEditor {
|
|
43
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
44
|
-
}
|
|
45
|
-
export declare class MonthInput extends InputEditor {
|
|
46
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
47
|
-
}
|
|
48
|
-
export declare class WeekInput extends InputEditor {
|
|
49
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
50
|
-
}
|
|
51
|
-
export declare class TimeInput extends InputEditor {
|
|
52
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
53
|
-
}
|
|
54
|
-
export declare class DateTimeInput extends InputEditor {
|
|
55
|
-
formatForEditor(timestamp: any): string;
|
|
56
|
-
formatFromEditor(e: Event): number;
|
|
57
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
58
|
-
}
|
|
59
|
-
export declare class ColorInput extends InputEditor {
|
|
60
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
61
|
-
}
|
|
62
|
-
export declare class CheckboxInput extends InputEditor {
|
|
63
|
-
formatFromEditor(e: Event): boolean;
|
|
64
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
65
|
-
}
|
|
66
|
-
export declare class ImageInput extends InputEditor {
|
|
67
|
-
imageInput: HTMLElement;
|
|
68
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
69
|
-
focus(): void;
|
|
70
|
-
_onchange(e: Event): void;
|
|
71
|
-
formatFromEditor(e: Event): string | File;
|
|
72
|
-
}
|
|
73
|
-
export declare class Select extends InputEditor {
|
|
74
|
-
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
75
|
-
}
|