@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.
- package/CHANGELOG.md +19 -0
- package/dist/src/data-grid/data-grid-body-style.js +2 -2
- package/dist/src/data-grid/data-grid-body-style.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/dist/src/record-view/record-creator.d.ts +0 -17
- package/dist/src/record-view/record-creator.js +0 -148
- package/dist/src/record-view/record-creator.js.map +0 -1
- 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/yarn-error.log +0 -16971
@@ -1,31 +0,0 @@
|
|
1
|
-
import '@operato/input/ox-input-image.js'
|
2
|
-
|
3
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
4
|
-
import { customElement } from 'lit/decorators.js'
|
5
|
-
import { html } from 'lit'
|
6
|
-
|
7
|
-
@customElement('ox-grist-editor-image')
|
8
|
-
export class OxGristEditorImage extends OxGristEditor {
|
9
|
-
get editorTemplate() {
|
10
|
-
return html` <ox-input-image .value=${this.value}></ox-input-image> `
|
11
|
-
}
|
12
|
-
|
13
|
-
_onchange(e: Event) {
|
14
|
-
e.stopPropagation()
|
15
|
-
|
16
|
-
const input = e.target as HTMLInputElement
|
17
|
-
|
18
|
-
// value가 image file object인지, image url인지 확인
|
19
|
-
if (input.files?.[0]) {
|
20
|
-
this._dirtyValue = this.formatFromEditor(input.files[0])
|
21
|
-
} else {
|
22
|
-
this._dirtyValue = this.formatFromEditor(input.value)
|
23
|
-
}
|
24
|
-
|
25
|
-
this._onfocusout()
|
26
|
-
}
|
27
|
-
|
28
|
-
formatFromEditor(value: any) {
|
29
|
-
return value
|
30
|
-
}
|
31
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-month')
|
6
|
-
export class OxGristEditorMonth extends OxGristEditor {
|
7
|
-
get editorTemplate() {
|
8
|
-
return html` <input type="month" .value=${this.value} /> `
|
9
|
-
}
|
10
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import '@operato/input/ox-select.js'
|
2
|
-
import '@operato/input/ox-checkbox.js'
|
3
|
-
import '@operato/popup/ox-popup-list.js'
|
4
|
-
|
5
|
-
import { html, css } from 'lit'
|
6
|
-
import { customElement } from 'lit/decorators.js'
|
7
|
-
|
8
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
9
|
-
|
10
|
-
@customElement('ox-grist-editor-multiple-select')
|
11
|
-
export class OxGristEditorMultipleSelect extends OxGristEditor {
|
12
|
-
static styles = [
|
13
|
-
...OxGristEditor.styles,
|
14
|
-
css`
|
15
|
-
:host {
|
16
|
-
overflow: visible;
|
17
|
-
}
|
18
|
-
`
|
19
|
-
]
|
20
|
-
|
21
|
-
get editorTemplate() {
|
22
|
-
var rowOptionField = this.record[this.column.record.rowOptionField || '']
|
23
|
-
var { options = [] } = rowOptionField ? rowOptionField : this.column.record
|
24
|
-
|
25
|
-
if (typeof options == 'function') {
|
26
|
-
options = options.call(null, this.value, this.column, this.record, this.rowIndex, this.field) || []
|
27
|
-
}
|
28
|
-
|
29
|
-
options = options.map((option: any) => {
|
30
|
-
switch (typeof option) {
|
31
|
-
case 'string':
|
32
|
-
return {
|
33
|
-
display: option,
|
34
|
-
value: option
|
35
|
-
}
|
36
|
-
case 'object':
|
37
|
-
return {
|
38
|
-
display: option.display,
|
39
|
-
value: option.value
|
40
|
-
}
|
41
|
-
default:
|
42
|
-
return option
|
43
|
-
}
|
44
|
-
})
|
45
|
-
|
46
|
-
return html`
|
47
|
-
<ox-select .value=${this.value} style="width: 100%;">
|
48
|
-
<ox-popup-list multiple attr-selected="checked">
|
49
|
-
${options.map(
|
50
|
-
(option: { display: string; value: string }) =>
|
51
|
-
html` <ox-checkbox option value=${option.value}>${option.display}</ox-checkbox> `
|
52
|
-
)}
|
53
|
-
</ox-popup-list>
|
54
|
-
</ox-select>
|
55
|
-
`
|
56
|
-
}
|
57
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
import { parseToNumberOrNull } from '@operato/utils'
|
5
|
-
|
6
|
-
@customElement('ox-grist-editor-number')
|
7
|
-
export class OxGristEditorNumber extends OxGristEditor {
|
8
|
-
get inlineEditable() {
|
9
|
-
return true
|
10
|
-
}
|
11
|
-
|
12
|
-
formatFromEditor(value: any) {
|
13
|
-
const parsed = parseToNumberOrNull(value) ?? null
|
14
|
-
|
15
|
-
if (parsed !== null && this.column.type == 'integer') {
|
16
|
-
return Math.floor(parsed)
|
17
|
-
}
|
18
|
-
|
19
|
-
return parsed
|
20
|
-
}
|
21
|
-
|
22
|
-
get editorTemplate() {
|
23
|
-
var { min = -Infinity, max = Infinity } = this.column.record.options || {}
|
24
|
-
|
25
|
-
return html` <input type="number" .value=${this.value} .min=${Number(min)} .max=${Number(max)} /> `
|
26
|
-
}
|
27
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-password')
|
6
|
-
export class OxGristEditorPassword extends OxGristEditor {
|
7
|
-
get editorTemplate() {
|
8
|
-
return html` <input type="password" .value=${this.value} /> `
|
9
|
-
}
|
10
|
-
}
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import { html } from 'lit'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { until } from 'lit/directives/until.js'
|
4
|
-
|
5
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
6
|
-
import { SelectOption, SelectOptionObject } from '../types.js'
|
7
|
-
|
8
|
-
function buildOptions(options: SelectOption[], value: any) {
|
9
|
-
const selectOptionObjects = options.map(option => {
|
10
|
-
switch (typeof option) {
|
11
|
-
case 'string':
|
12
|
-
return {
|
13
|
-
display: option,
|
14
|
-
value: option
|
15
|
-
}
|
16
|
-
case 'object':
|
17
|
-
return {
|
18
|
-
display: option.display || option.name,
|
19
|
-
value: option.value
|
20
|
-
}
|
21
|
-
default:
|
22
|
-
return option
|
23
|
-
}
|
24
|
-
}) as SelectOptionObject[]
|
25
|
-
|
26
|
-
return html`
|
27
|
-
<select>
|
28
|
-
${selectOptionObjects.map(
|
29
|
-
(option: any) => html`
|
30
|
-
<option ?selected=${option.value == value} value=${option.value}>${option.display}</option>
|
31
|
-
`
|
32
|
-
)}
|
33
|
-
</select>
|
34
|
-
`
|
35
|
-
}
|
36
|
-
|
37
|
-
@customElement('ox-grist-editor-select')
|
38
|
-
export class OxGristEditorSelect extends OxGristEditor {
|
39
|
-
get editorTemplate() {
|
40
|
-
var rowOptionField = this.record[this.column.record.rowOptionField || '']
|
41
|
-
var { options = [] } = rowOptionField ? rowOptionField : this.column.record
|
42
|
-
|
43
|
-
if (typeof options == 'function') {
|
44
|
-
options = options.call(null, this.value, this.column, this.record, this.rowIndex, this.field)
|
45
|
-
|
46
|
-
if (options instanceof Promise) {
|
47
|
-
return html`${until(options.then(options => buildOptions(options, this.value)))}`
|
48
|
-
} else {
|
49
|
-
return buildOptions((options || []) as SelectOption[], this.value)
|
50
|
-
}
|
51
|
-
} else {
|
52
|
-
return buildOptions((options || []) as SelectOption[], this.value)
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-tel')
|
6
|
-
export class OxGristEditorTel extends OxGristEditor {
|
7
|
-
get editorTemplate() {
|
8
|
-
return html` <input type="tel" .value=${this.value} /> `
|
9
|
-
}
|
10
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-text')
|
6
|
-
export class OxGristEditorText extends OxGristEditor {
|
7
|
-
get inlineEditable() {
|
8
|
-
return true
|
9
|
-
}
|
10
|
-
|
11
|
-
get editorTemplate() {
|
12
|
-
return html` <input type="text" .value=${this.value} /> `
|
13
|
-
}
|
14
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import '@operato/input/ox-input-textarea.js'
|
2
|
-
|
3
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
4
|
-
import { customElement } from 'lit/decorators.js'
|
5
|
-
import { html } from 'lit'
|
6
|
-
|
7
|
-
@customElement('ox-grist-editor-textarea')
|
8
|
-
export class OxGristEditorTextarea extends OxGristEditor {
|
9
|
-
get inlineEditable() {
|
10
|
-
return true
|
11
|
-
}
|
12
|
-
|
13
|
-
get editorTemplate() {
|
14
|
-
return html` <ox-input-textarea .value=${this.value}></ox-input-textarea> `
|
15
|
-
}
|
16
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-time')
|
6
|
-
export class OxGristEditorTime extends OxGristEditor {
|
7
|
-
get editorTemplate() {
|
8
|
-
return html` <input type="time" .value=${this.value} /> `
|
9
|
-
}
|
10
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import './ox-input-tree'
|
2
|
-
|
3
|
-
import { html, css } from 'lit'
|
4
|
-
import { customElement, query } from 'lit/decorators.js'
|
5
|
-
|
6
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
7
|
-
|
8
|
-
@customElement('ox-grist-editor-tree')
|
9
|
-
export class OxGristEditorTree extends OxGristEditor {
|
10
|
-
static styles = [
|
11
|
-
css`
|
12
|
-
:host {
|
13
|
-
flex: 1;
|
14
|
-
}
|
15
|
-
|
16
|
-
ox-input-tree {
|
17
|
-
flex: 1;
|
18
|
-
}
|
19
|
-
`
|
20
|
-
]
|
21
|
-
|
22
|
-
get editorTemplate() {
|
23
|
-
var { selectable } = this.column.record.options || {}
|
24
|
-
|
25
|
-
return html`<ox-input-tree .value=${this.value} .record=${this.record} ?selectable=${selectable}></ox-input-tree>`
|
26
|
-
}
|
27
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-varname')
|
6
|
-
export class OxGristEditorVarname extends OxGristEditor {
|
7
|
-
get inlineEditable() {
|
8
|
-
return true
|
9
|
-
}
|
10
|
-
|
11
|
-
get editorTemplate() {
|
12
|
-
return html`
|
13
|
-
<input
|
14
|
-
type="text"
|
15
|
-
.value=${this.value}
|
16
|
-
@input=${this.handleInput}
|
17
|
-
pattern="^[A-Za-z_][A-Za-z0-9_]*$"
|
18
|
-
title="Variable names must start with a letter or underscore and contain only letters, numbers, or underscores."
|
19
|
-
/>
|
20
|
-
`
|
21
|
-
}
|
22
|
-
|
23
|
-
handleInput(event: KeyboardEvent) {
|
24
|
-
const input = event.target as HTMLInputElement
|
25
|
-
const regex = /^[A-Za-z_][A-Za-z0-9_]*$/
|
26
|
-
|
27
|
-
// Only allow valid characters as the user types
|
28
|
-
if (!regex.test(input.value)) {
|
29
|
-
// Keep only valid characters and start with a letter or underscore
|
30
|
-
input.value = input.value.replace(/[^A-Za-z0-9_]/g, '').replace(/^[^A-Za-z_]+/, '')
|
31
|
-
}
|
32
|
-
|
33
|
-
// Update the component's internal value state
|
34
|
-
this.value = input.value
|
35
|
-
}
|
36
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { OxGristEditor } from './ox-grist-editor.js'
|
2
|
-
import { customElement } from 'lit/decorators.js'
|
3
|
-
import { html } from 'lit'
|
4
|
-
|
5
|
-
@customElement('ox-grist-editor-week')
|
6
|
-
export class OxGristEditorWeek extends OxGristEditor {
|
7
|
-
get editorTemplate() {
|
8
|
-
return html` <input type="week" .value=${this.value} /> `
|
9
|
-
}
|
10
|
-
}
|
@@ -1,207 +0,0 @@
|
|
1
|
-
import { css, html, LitElement, PropertyValues } from 'lit'
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
3
|
-
|
4
|
-
import { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config'
|
5
|
-
import { DataGridField } from '../data-grid/data-grid-field'
|
6
|
-
import { ColumnConfig, GristRecord } from '../types'
|
7
|
-
import { getDefaultValue } from '@operato/time-calculator'
|
8
|
-
|
9
|
-
const STYLE = css`
|
10
|
-
:host {
|
11
|
-
display: flex;
|
12
|
-
|
13
|
-
align-items: center;
|
14
|
-
|
15
|
-
width: 100%;
|
16
|
-
height: 100%;
|
17
|
-
|
18
|
-
border: 0;
|
19
|
-
background-color: transparent;
|
20
|
-
|
21
|
-
overflow: hidden;
|
22
|
-
justify-content: var(--data-grid-field-justify-content, flex-start);
|
23
|
-
}
|
24
|
-
|
25
|
-
:host > * {
|
26
|
-
display: flex;
|
27
|
-
|
28
|
-
width: 100%;
|
29
|
-
height: 100%;
|
30
|
-
|
31
|
-
border: 0;
|
32
|
-
background-color: transparent;
|
33
|
-
|
34
|
-
box-sizing: border-box;
|
35
|
-
|
36
|
-
align-items: center;
|
37
|
-
}
|
38
|
-
|
39
|
-
:host > style {
|
40
|
-
display: none;
|
41
|
-
}
|
42
|
-
|
43
|
-
:host > input {
|
44
|
-
color: var(--md-sys-color-on-background);
|
45
|
-
}
|
46
|
-
|
47
|
-
:host > input[type='checkbox'] {
|
48
|
-
width: initial;
|
49
|
-
margin: 0;
|
50
|
-
}
|
51
|
-
*:focus {
|
52
|
-
outline: none;
|
53
|
-
}
|
54
|
-
|
55
|
-
input[type='file'] {
|
56
|
-
opacity: 0%;
|
57
|
-
}
|
58
|
-
|
59
|
-
@media screen and (max-width: 460px) {
|
60
|
-
:host > * {
|
61
|
-
border: initial;
|
62
|
-
background-color: initial;
|
63
|
-
}
|
64
|
-
|
65
|
-
*:focus {
|
66
|
-
outline: none;
|
67
|
-
}
|
68
|
-
|
69
|
-
input,
|
70
|
-
select,
|
71
|
-
textarea {
|
72
|
-
font-size: 16px;
|
73
|
-
}
|
74
|
-
}
|
75
|
-
`
|
76
|
-
|
77
|
-
@customElement('ox-grist-editor')
|
78
|
-
export class OxGristEditor extends LitElement {
|
79
|
-
static styles = [STYLE]
|
80
|
-
|
81
|
-
@property({ type: Object }) value?: any
|
82
|
-
@property({ type: Object }) column: ColumnConfig = ZERO_COLUMN
|
83
|
-
@property({ type: Object }) record: GristRecord = ZERO_RECORD
|
84
|
-
@property({ type: Number }) rowIndex?: number
|
85
|
-
@property({ type: Object }) field?: DataGridField
|
86
|
-
@property({ type: Number }) row?: number
|
87
|
-
|
88
|
-
protected _dirtyValue?: any
|
89
|
-
|
90
|
-
render() {
|
91
|
-
return this.editorTemplate
|
92
|
-
}
|
93
|
-
|
94
|
-
get editor(): HTMLElement | null {
|
95
|
-
return this.renderRoot.firstElementChild as HTMLElement
|
96
|
-
}
|
97
|
-
|
98
|
-
get inlineEditable() {
|
99
|
-
return false
|
100
|
-
}
|
101
|
-
|
102
|
-
async firstUpdated() {
|
103
|
-
this.renderRoot.addEventListener('change', this._onchange.bind(this))
|
104
|
-
this.renderRoot.addEventListener('focusout', this._onfocusout.bind(this))
|
105
|
-
this.addEventListener('click', this._onclick.bind(this))
|
106
|
-
this.addEventListener('dblclick', this._ondblclick.bind(this))
|
107
|
-
this.addEventListener('keydown', this._onkeydown.bind(this))
|
108
|
-
|
109
|
-
/* editor mode 인 경우의 마우스 움직임이, grist-body의 이벤트 처리에 의해서 에디터를 리셋시킬 수 있으므로, 이벤트 전파를 막는다. */
|
110
|
-
this.addEventListener('mousedown', (e: Event) => e.stopPropagation())
|
111
|
-
this.addEventListener('mousemove', (e: Event) => e.stopPropagation())
|
112
|
-
this.addEventListener('mouseup', (e: Event) => e.stopPropagation())
|
113
|
-
|
114
|
-
const { name = '' } = this.column
|
115
|
-
const { align, defaultValue } = this.column.record
|
116
|
-
|
117
|
-
if (align) {
|
118
|
-
this.style.textAlign = align
|
119
|
-
this.style.textAlignLast = align /* for select */
|
120
|
-
}
|
121
|
-
|
122
|
-
var currentValue = this.record[name]
|
123
|
-
|
124
|
-
if (typeof currentValue == 'undefined' && defaultValue) {
|
125
|
-
currentValue = getDefaultValue(defaultValue, this.record)
|
126
|
-
}
|
127
|
-
|
128
|
-
this.value = this._dirtyValue = this.formatForEditor(currentValue)
|
129
|
-
|
130
|
-
// 입력을 위한 키를 누르면서 편집모드가 될때는 누른 키가 처음에 입력되도록, enter 같은 것을 눌러서 편집모드가 되면 현재 값으로 편집모드 전환
|
131
|
-
const valueWith = this.inlineEditable && this.field?.valueWith
|
132
|
-
this.value = this._dirtyValue = valueWith ? this.formatFromEditor(valueWith) : this.formatForEditor(currentValue)
|
133
|
-
|
134
|
-
requestAnimationFrame(() => {
|
135
|
-
this.focus()
|
136
|
-
!valueWith && this.select()
|
137
|
-
})
|
138
|
-
}
|
139
|
-
|
140
|
-
select() {
|
141
|
-
const editor = this.editor
|
142
|
-
if ((editor as HTMLInputElement)?.select) {
|
143
|
-
return (editor as HTMLInputElement).select()
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
focus() {
|
148
|
-
const editor = this.editor
|
149
|
-
if (editor) {
|
150
|
-
editor.focus()
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
formatForEditor(value: any): any {
|
155
|
-
return value == null ? '' : value
|
156
|
-
}
|
157
|
-
|
158
|
-
formatFromEditor(value: any): any {
|
159
|
-
return value
|
160
|
-
}
|
161
|
-
|
162
|
-
_onfocusout() {
|
163
|
-
// paste시 field-change는 Body에서 하므로 X
|
164
|
-
if (this.field?.isWorking === true) return
|
165
|
-
|
166
|
-
const { name = '' } = this.column
|
167
|
-
var currentValue = this.record[name] || ''
|
168
|
-
|
169
|
-
if (this._dirtyValue !== currentValue) {
|
170
|
-
this.dispatchEvent(
|
171
|
-
new CustomEvent('field-change', {
|
172
|
-
bubbles: true,
|
173
|
-
composed: true,
|
174
|
-
detail: {
|
175
|
-
before: currentValue,
|
176
|
-
after: this._dirtyValue,
|
177
|
-
column: this.column,
|
178
|
-
record: this.record,
|
179
|
-
row: this.row
|
180
|
-
}
|
181
|
-
})
|
182
|
-
)
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
_onchange(e: Event): void {
|
187
|
-
e.stopPropagation()
|
188
|
-
|
189
|
-
const value = (e.target as any)?.value
|
190
|
-
|
191
|
-
this._dirtyValue = this.formatFromEditor(value)
|
192
|
-
}
|
193
|
-
|
194
|
-
_onkeydown(e: Event): void {}
|
195
|
-
|
196
|
-
_onclick(e: Event): void {
|
197
|
-
e.stopPropagation()
|
198
|
-
}
|
199
|
-
|
200
|
-
_ondblclick(e: Event): void {
|
201
|
-
e.stopPropagation()
|
202
|
-
}
|
203
|
-
|
204
|
-
get editorTemplate() {
|
205
|
-
return html``
|
206
|
-
}
|
207
|
-
}
|