@operato/app 8.0.0-beta.0 → 8.0.0-beta.10

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/tsconfig.tsbuildinfo +1 -1
  3. package/package.json +15 -17
  4. package/.editorconfig +0 -29
  5. package/.storybook/main.js +0 -3
  6. package/.storybook/server.mjs +0 -8
  7. package/demo/data-grist-test.html +0 -473
  8. package/demo/index.html +0 -35
  9. package/src/filter-renderer/filter-resource-select.ts +0 -133
  10. package/src/filter-renderer/index.ts +0 -6
  11. package/src/filters-form/filter-resource-code.ts +0 -11
  12. package/src/filters-form/filter-resource-object.ts +0 -11
  13. package/src/filters-form/filter-resource-select.ts +0 -130
  14. package/src/filters-form/index.ts +0 -14
  15. package/src/filters-form/ox-filter-resource-code.ts +0 -154
  16. package/src/filters-form/ox-filter-resource-object.ts +0 -224
  17. package/src/grist-editor/index.ts +0 -26
  18. package/src/grist-editor/ox-grist-editor-code.ts +0 -64
  19. package/src/grist-editor/ox-grist-editor-json.ts +0 -64
  20. package/src/grist-editor/ox-grist-editor-privilege.ts +0 -58
  21. package/src/grist-editor/ox-grist-editor-resource-code.ts +0 -30
  22. package/src/grist-editor/ox-grist-editor-resource-id.ts +0 -88
  23. package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +0 -131
  24. package/src/grist-editor/ox-grist-editor-resource-object.ts +0 -156
  25. package/src/grist-editor/ox-grist-renderer-crontab.ts +0 -18
  26. package/src/grist-editor/ox-grist-renderer-resource-code.ts +0 -85
  27. package/src/grist-editor/ox-grist-renderer-resource-id.ts +0 -17
  28. package/src/grist-editor/ox-grist-renderer-resource-object.ts +0 -26
  29. package/src/grist-editor/ox-popup-code-input.ts +0 -69
  30. package/src/grist-editor/ox-popup-privilege-input.ts +0 -93
  31. package/src/index.ts +0 -4
  32. package/src/input/index.ts +0 -3
  33. package/src/input/ox-input-background-pattern.ts +0 -196
  34. package/src/input/ox-input-fill-style.ts +0 -377
  35. package/src/input/ox-input-graphql.ts +0 -153
  36. package/src/property-editor/index.ts +0 -83
  37. package/src/property-editor/ox-property-editor-graphql.ts +0 -22
  38. package/src/property-editor/ox-property-editor-resource-object.ts +0 -148
  39. package/src/selector/ox-selector-resource-id.ts +0 -201
  40. package/src/selector/ox-selector-resource-object-legacy.ts +0 -367
  41. package/src/selector/ox-selector-resource-object.ts +0 -300
  42. package/stories/graphql-client.stories.ts +0 -73
  43. package/stories/ox-input-graphql.stories.ts +0 -70
  44. package/stories/ox-selector-resource-object.stories.ts +0 -98
  45. package/tsconfig.json +0 -24
  46. package/web-dev-server.config.mjs +0 -27
  47. package/web-test-runner.config.mjs +0 -41
@@ -1,26 +0,0 @@
1
- import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'
2
-
3
- import { OxGristEditorJson } from './ox-grist-editor-json.js'
4
- import { OxGristEditorCode } from './ox-grist-editor-code.js'
5
- import { OxGristEditorResourceCode } from './ox-grist-editor-resource-code.js'
6
- import { OxGristEditorResourceId } from './ox-grist-editor-resource-id.js'
7
- import { OxGristEditorResourceObject } from './ox-grist-editor-resource-object.js'
8
- import { OxGristRendererCrontab } from './ox-grist-renderer-crontab'
9
- import { OxGristRendererResourceId } from './ox-grist-renderer-resource-id.js'
10
- import { OxGristRendererResourceCode } from './ox-grist-renderer-resource-code.js'
11
- import { OxGristRendererResourceObject } from './ox-grist-renderer-resource-object.js'
12
-
13
- /* register grist renderer/editor for id */
14
- registerEditor('resource-id', OxGristEditorResourceId)
15
- registerEditor('resource-code', OxGristEditorResourceCode)
16
- registerEditor('resource-object', OxGristEditorResourceObject)
17
- registerEditor('json', OxGristEditorJson)
18
- registerEditor('template', OxGristEditorCode)
19
-
20
- registerRenderer('resource-id', OxGristRendererResourceId)
21
- registerRenderer('resource-code', OxGristRendererResourceId)
22
- registerRenderer('resource-object', OxGristRendererResourceObject)
23
- registerRenderer('parameters', OxGristRendererJson5)
24
- registerRenderer('value-map', OxGristRendererJson5)
25
- registerRenderer('partition-keys', OxGristRendererJson5)
26
- registerRenderer('crontab', OxGristRendererCrontab)
@@ -1,64 +0,0 @@
1
- import './ox-popup-code-input.js'
2
-
3
- import { html } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxGristEditor } from '@operato/data-grist'
7
- import { i18next } from '@operato/i18n'
8
- import { openPopup } from '@operato/layout'
9
-
10
- @customElement('ox-grist-editor-code')
11
- export class OxGristEditorCode extends OxGristEditor {
12
- get editorTemplate() {
13
- return html` <div tabindex="0">${this.value || ''}</div> `
14
- }
15
-
16
- _onclick(e: Event): void {
17
- e.stopPropagation()
18
- this.showEditorPopup()
19
- }
20
-
21
- _onkeydown(e: KeyboardEvent): void {
22
- const key = e.key
23
- if (key == 'Enter') {
24
- e.stopPropagation()
25
- this.showEditorPopup()
26
- }
27
- }
28
-
29
- showEditorPopup() {
30
- var { mode, language = 'javascript' } = this.column.record?.options || {}
31
-
32
- var change = (value: string) => {
33
- this.dispatchEvent(
34
- new CustomEvent('field-change', {
35
- bubbles: true,
36
- composed: true,
37
- detail: {
38
- before: this.value,
39
- after: value,
40
- column: this.column,
41
- record: this.record,
42
- row: this.row
43
- }
44
- })
45
- )
46
- }
47
-
48
- var popup = openPopup(
49
- html`
50
- <ox-popup-code-input
51
- .value=${this.value}
52
- mode=${mode}
53
- .confirmCallback=${change.bind(this)}
54
- language=${language}
55
- ></ox-popup-code-input>
56
- `,
57
- {
58
- backdrop: true,
59
- title: i18next.t('title.edit code'),
60
- help: 'data-grist/grist-editor/code'
61
- }
62
- )
63
- }
64
- }
@@ -1,64 +0,0 @@
1
- import './ox-popup-code-input.js'
2
-
3
- import { OxGristEditor } from '@operato/data-grist'
4
- import { customElement } from 'lit/decorators.js'
5
- import { html } from 'lit'
6
- import { i18next } from '@operato/i18n'
7
- import { openPopup } from '@operato/layout'
8
-
9
- @customElement('ox-grist-editor-json')
10
- export class OxGristEditorJson extends OxGristEditor {
11
- get editorTemplate() {
12
- return html` <div tabindex="0">${this.value || ''}</div> `
13
- }
14
-
15
- _onclick(e: Event): void {
16
- e.stopPropagation()
17
- this.showEditorPopup()
18
- }
19
-
20
- _onkeydown(e: KeyboardEvent): void {
21
- const key = e.key
22
- if (key == 'Enter') {
23
- e.stopPropagation()
24
- this.showEditorPopup()
25
- }
26
- }
27
-
28
- showEditorPopup() {
29
- var change = (value: string) => {
30
- this.dispatchEvent(
31
- new CustomEvent('change', {
32
- bubbles: true,
33
- composed: true,
34
- detail: {
35
- before: this.value,
36
- after: value,
37
- column: this.column,
38
- record: this.record,
39
- row: this.row
40
- }
41
- })
42
- )
43
- }
44
-
45
- var popup = openPopup(
46
- html`
47
- <ox-popup-code-input
48
- .value=${this.value}
49
- mode="javascript"
50
- @change=${(e: CustomEvent) => {
51
- change(e.detail.value)
52
- popup.close()
53
- }}
54
- lanugage="json"
55
- ></ox-popup-code-input>
56
- `,
57
- {
58
- backdrop: true,
59
- title: i18next.t('title.edit json'),
60
- help: 'data-grist/grist-editor/json'
61
- }
62
- )
63
- }
64
- }
@@ -1,58 +0,0 @@
1
- import './ox-popup-privilege-input.js'
2
-
3
- import { html } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxGristEditor } from '@operato/data-grist'
7
- import { i18next } from '@operato/i18n'
8
- import { openPopup } from '@operato/layout'
9
-
10
- @customElement('ox-grist-editor-privilege')
11
- export class OxGristEditorPrivilege extends OxGristEditor {
12
- get editorTemplate() {
13
- return html` <div tabindex="0">...</div> `
14
- }
15
-
16
- _onclick(e: Event): void {
17
- e.stopPropagation()
18
- this.showEditorPopup()
19
- }
20
-
21
- _onkeydown(e: KeyboardEvent): void {
22
- const key = e.key
23
- if (key == 'Enter') {
24
- e.stopPropagation()
25
- this.showEditorPopup()
26
- }
27
- }
28
-
29
- showEditorPopup() {
30
- var change = (value: string) => {
31
- this.dispatchEvent(
32
- new CustomEvent('field-change', {
33
- bubbles: true,
34
- composed: true,
35
- detail: {
36
- before: this.value,
37
- after: value,
38
- column: this.column,
39
- record: this.record,
40
- row: this.row
41
- }
42
- })
43
- )
44
- }
45
-
46
- var popup = openPopup(
47
- html`
48
- <ox-popup-privilege-input .value=${this.value} .confirmCallback=${change.bind(this)}></ox-popup-privilege-input>
49
- `,
50
- {
51
- backdrop: true,
52
- title: i18next.t('title.edit privilege'),
53
- size: 'medium',
54
- help: 'data-grist/grist-editor/privilege'
55
- }
56
- )
57
- }
58
- }
@@ -1,30 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import { OxGristEditor, RecordConfig } from '@operato/data-grist'
3
-
4
- import { customElement } from 'lit/decorators.js'
5
- import { html } from 'lit'
6
-
7
- type CommonCodeDetail = {
8
- name: string
9
- description: string
10
- rank: number
11
- }
12
-
13
- @customElement('ox-grist-editor-resource-code')
14
- export class OxGristEditorResourceCode extends OxGristEditor {
15
- get editorTemplate() {
16
- var { codes, selectDispOpt = 'code-name' } = this.column.record || {}
17
-
18
- return html`
19
- <select>
20
- ${(codes || []).map(
21
- (code: CommonCodeDetail) => html`
22
- <option ?selected=${code.name == this.value} value=${code.name}>
23
- ${code.name == '' ? '' : selectDispOpt.replace('name', code.description).replace('code', code.name)}
24
- </option>
25
- `
26
- )}
27
- </select>
28
- `
29
- }
30
- }
@@ -1,88 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '../selector/ox-selector-resource-id.js'
3
-
4
- import { html } from 'lit'
5
- import { customElement } from 'lit/decorators.js'
6
-
7
- import { GristRecord, OxGristEditor } from '@operato/data-grist'
8
- import { openPopup, PopupHandle } from '@operato/layout'
9
-
10
- @customElement('ox-grist-editor-resource-id')
11
- export class OxGristEditorResourceId extends OxGristEditor {
12
- private popup?: PopupHandle
13
-
14
- render() {
15
- var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
16
- var value = this.value
17
-
18
- return html`
19
- ${!value
20
- ? html`<span tabindex="0"></span>`
21
- : html` <span tabindex="0">${value[nameField]} (${value[descriptionField]})</span> `}
22
- <md-icon>arrow_drop_down</md-icon>
23
- `
24
- }
25
-
26
- _onclick(e: Event): void {
27
- e.stopPropagation()
28
- this.openSelector()
29
- }
30
-
31
- _onkeydown(e: KeyboardEvent): void {
32
- const key = e.key
33
- if (key == 'Enter') {
34
- e.stopPropagation()
35
- this.openSelector()
36
- }
37
- }
38
-
39
- openSelector() {
40
- if (this.popup) {
41
- delete this.popup
42
- }
43
-
44
- const confirmCallback: (record?: GristRecord) => void = selected => {
45
- if (!selected) {
46
- return
47
- }
48
-
49
- var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
50
-
51
- this.dispatchEvent(
52
- new CustomEvent('field-change', {
53
- bubbles: true,
54
- composed: true,
55
- detail: {
56
- before: this.value,
57
- after: selected
58
- ? {
59
- [idField]: selected[idField],
60
- [nameField]: selected[nameField],
61
- [descriptionField]: selected[descriptionField]
62
- }
63
- : null,
64
- record: this.record,
65
- column: this.column,
66
- row: this.row
67
- }
68
- })
69
- )
70
- }
71
-
72
- var value = this.value || {}
73
- var template = html`
74
- <ox-selector-resource-id
75
- .value=${value.id}
76
- .confirmCallback=${confirmCallback.bind(this)}
77
- .queryName=${this.column.record.options.queryName}
78
- .basicArgs=${this.column.record.options.basicArgs}
79
- ></ox-selector-resource-id>
80
- `
81
-
82
- this.popup = openPopup(template, {
83
- backdrop: true,
84
- size: 'large',
85
- title: 'select item'
86
- })
87
- }
88
- }
@@ -1,131 +0,0 @@
1
- import '../selector/ox-selector-resource-object-legacy.js'
2
-
3
- import { html, TemplateResult } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxGristEditor } from '@operato/data-grist'
7
- import { i18next } from '@operato/i18n'
8
- import { openPopup, PopupHandle } from '@operato/layout'
9
-
10
- @customElement('ox-grist-editor-resource-object-legacy')
11
- export class OxGristEditorResourceObjectLegacy extends OxGristEditor {
12
- private popup?: PopupHandle
13
- private template?: TemplateResult
14
-
15
- get editorTemplate() {
16
- var value = this.value || {}
17
-
18
- var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
19
- var name, description
20
- if (typeof nameField === 'function') {
21
- name = nameField(value)
22
- } else {
23
- name = value[nameField]
24
- }
25
-
26
- if (typeof descriptionField === 'function') {
27
- description = descriptionField(value)
28
- } else {
29
- description = value[descriptionField] && `(${value[descriptionField]})`
30
- }
31
-
32
- return html`
33
- ${!value
34
- ? html`<span tabindex="0"></span>`
35
- : html` <span tabindex="0" style="flex:1">${name || ''}${description || ''}</span> `}
36
- `
37
- }
38
-
39
- async firstUpdated() {
40
- super.firstUpdated()
41
- this.template = ((this.column.record || {}).options || {}).template
42
- }
43
-
44
- _onclick(e: Event): void {
45
- e.stopPropagation()
46
- this.openSelector()
47
- }
48
-
49
- _onkeydown(e: KeyboardEvent): void {
50
- const key = e.key
51
- if (key == 'Enter') {
52
- e.stopPropagation()
53
- this.openSelector()
54
- }
55
- }
56
-
57
- openSelector() {
58
- if (this.popup) {
59
- delete this.popup
60
- }
61
-
62
- var {
63
- idField = 'id',
64
- nameField = 'name',
65
- descriptionField = 'description',
66
- valueField = 'id',
67
- queryName,
68
- basicArgs,
69
- select,
70
- list
71
- } = this.column.record.options || {}
72
-
73
- const confirmCallback = (selected?: { [field: string]: any }) => {
74
- this.dispatchEvent(
75
- new CustomEvent('field-change', {
76
- bubbles: true,
77
- composed: true,
78
- detail: {
79
- before: this.value,
80
- after: selected
81
- ? {
82
- ...(this.column.record.options.select || [])
83
- .map((field: any) => field.name)
84
- .reduce((obj: { [field: string]: any }, fieldName: string) => {
85
- return (obj = {
86
- ...obj,
87
- [fieldName]: selected[fieldName]
88
- })
89
- }, {} as { [field: string]: any }),
90
- [idField]: selected[idField],
91
- [nameField]: selected[nameField],
92
- [descriptionField]: selected[descriptionField]
93
- }
94
- : null,
95
- record: this.record,
96
- column: this.column,
97
- row: this.row
98
- }
99
- })
100
- )
101
- }
102
-
103
- var value = this.value || {}
104
- var actualValue
105
- if (typeof valueField === 'function') {
106
- actualValue = valueField(value)
107
- } else {
108
- actualValue = value[valueField]
109
- }
110
-
111
- var template =
112
- this.template ||
113
- html`
114
- <ox-selector-resource-object-legacy
115
- .value=${actualValue}
116
- .confirmCallback=${confirmCallback.bind(this)}
117
- .queryName=${queryName}
118
- .select=${select}
119
- .list=${list}
120
- .basicArgs=${basicArgs}
121
- .valueField=${valueField}
122
- ></ox-selector-resource-object-legacy>
123
- `
124
-
125
- this.popup = openPopup(template, {
126
- backdrop: true,
127
- size: 'large',
128
- title: i18next.t('title.select_item')
129
- })
130
- }
131
- }
@@ -1,156 +0,0 @@
1
- import '../selector/ox-selector-resource-object.js'
2
-
3
- import { html, TemplateResult } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxGristEditor } from '@operato/data-grist'
7
- import { i18next } from '@operato/i18n'
8
- import { openPopup, PopupHandle } from '@operato/layout'
9
-
10
- @customElement('ox-grist-editor-resource-object')
11
- export class OxGristEditorResourceObject extends OxGristEditor {
12
- private popup?: PopupHandle
13
- private template?: TemplateResult
14
-
15
- get editorTemplate() {
16
- var value = this.value || {}
17
-
18
- var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
19
- var name, description
20
- if (typeof nameField === 'function') {
21
- name = nameField(value)
22
- } else {
23
- name = value[nameField]
24
- }
25
-
26
- if (typeof descriptionField === 'function') {
27
- description = descriptionField(value)
28
- } else {
29
- description = value[descriptionField] && `(${value[descriptionField]})`
30
- }
31
-
32
- return html`
33
- ${!value
34
- ? html`<span tabindex="0"></span>`
35
- : html` <span tabindex="0" style="flex:1">${name || ''}${description || ''}</span> `}
36
- `
37
- }
38
-
39
- async firstUpdated() {
40
- super.firstUpdated()
41
- this.template = ((this.column.record || {}).options || {}).template
42
- }
43
-
44
- _onclick(e: Event): void {
45
- e.stopPropagation()
46
- this.openSelector()
47
- }
48
-
49
- _onkeydown(e: KeyboardEvent): void {
50
- const key = e.key
51
- if (key == 'Enter') {
52
- e.stopPropagation()
53
- this.openSelector()
54
- }
55
- }
56
-
57
- openSelector() {
58
- if (this.popup) {
59
- delete this.popup
60
- }
61
-
62
- var {
63
- title = '',
64
- idField = 'id',
65
- nameField = 'name',
66
- descriptionField = 'description',
67
- valueField = 'id',
68
- queryName,
69
- basicArgs,
70
- select,
71
- columns,
72
- pagination,
73
- list
74
- } = this.column.record.options || {}
75
-
76
- if (!queryName) {
77
- console.warn('queryName is empty')
78
- return
79
- }
80
-
81
- /* select options is only for compatability, it might be able to be deprecated. */
82
- columns = columns || select
83
-
84
- const confirmCallback = (selected?: { [field: string]: any }) => {
85
- this.dispatchEvent(
86
- new CustomEvent('field-change', {
87
- bubbles: true,
88
- composed: true,
89
- detail: {
90
- before: this.value,
91
- after: selected
92
- ? {
93
- ...(columns || [])
94
- .map((field: any) => field.name)
95
- .reduce((obj: { [field: string]: any }, fieldName: string) => {
96
- return (obj = {
97
- ...obj,
98
- [fieldName]: selected[fieldName]
99
- })
100
- }, {} as { [field: string]: any }),
101
- [idField]: selected[idField],
102
- [nameField]: selected[nameField],
103
- [descriptionField]: selected[descriptionField]
104
- }
105
- : null,
106
- record: this.record,
107
- column: this.column,
108
- row: this.row
109
- }
110
- })
111
- )
112
- }
113
-
114
- var value = this.value || {}
115
- var actualValue
116
- if (typeof valueField === 'function') {
117
- actualValue = valueField(value)
118
- } else {
119
- actualValue = value[valueField]
120
- }
121
-
122
- var template =
123
- this.template ||
124
- html`
125
- <ox-selector-resource-object
126
- .value=${actualValue}
127
- .confirmCallback=${confirmCallback.bind(this)}
128
- .queryName=${queryName}
129
- .columns=${columns}
130
- .pagination=${pagination}
131
- .list=${list}
132
- .basicArgs=${basicArgs}
133
- .valueField=${valueField}
134
- ></ox-selector-resource-object>
135
- `
136
-
137
- this.popup = openPopup(template, {
138
- backdrop: true,
139
- size: 'large',
140
- search: {
141
- autofocus: true,
142
- placeholder: title || i18next.t('title.select_item'),
143
- handler: (instance: any, value: any) => {
144
- /* instance: template instance */
145
- instance.searchText(value)
146
- }
147
- },
148
- filter: {
149
- handler: (instance: any) => {
150
- /* instance: template instance */
151
- instance.toggleFilter()
152
- }
153
- }
154
- })
155
- }
156
- }
@@ -1,18 +0,0 @@
1
- import cronstrue from 'cronstrue/i18n'
2
- import i18next from 'i18next'
3
- import { html } from 'lit'
4
-
5
- import { FieldRenderer } from '@operato/data-grist'
6
-
7
- export const OxGristRendererCrontab: FieldRenderer = (value, column, record, rowIndex, field) => {
8
- let text = ''
9
-
10
- try {
11
- const language = (i18next.language || 'en').substring(0, 2)
12
- text = !value ? '' : cronstrue.toString(value, { locale: language || 'en' })
13
- } catch (e) {
14
- console.error(e)
15
- }
16
-
17
- return html`<span data-reactive-tooltip>${text}</span>`
18
- }