@operato/app 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.
Files changed (44) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.json +14 -14
  3. package/.editorconfig +0 -29
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/server.mjs +0 -8
  6. package/src/filter-renderer/filter-resource-select.ts +0 -133
  7. package/src/filter-renderer/index.ts +0 -6
  8. package/src/filters-form/filter-resource-code.ts +0 -11
  9. package/src/filters-form/filter-resource-object.ts +0 -11
  10. package/src/filters-form/filter-resource-select.ts +0 -130
  11. package/src/filters-form/index.ts +0 -14
  12. package/src/filters-form/ox-filter-resource-code.ts +0 -154
  13. package/src/filters-form/ox-filter-resource-object.ts +0 -224
  14. package/src/grist-editor/index.ts +0 -26
  15. package/src/grist-editor/ox-grist-editor-code.ts +0 -64
  16. package/src/grist-editor/ox-grist-editor-json.ts +0 -64
  17. package/src/grist-editor/ox-grist-editor-privilege.ts +0 -58
  18. package/src/grist-editor/ox-grist-editor-resource-code.ts +0 -30
  19. package/src/grist-editor/ox-grist-editor-resource-id.ts +0 -88
  20. package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +0 -131
  21. package/src/grist-editor/ox-grist-editor-resource-object.ts +0 -156
  22. package/src/grist-editor/ox-grist-renderer-crontab.ts +0 -18
  23. package/src/grist-editor/ox-grist-renderer-resource-code.ts +0 -85
  24. package/src/grist-editor/ox-grist-renderer-resource-id.ts +0 -17
  25. package/src/grist-editor/ox-grist-renderer-resource-object.ts +0 -26
  26. package/src/grist-editor/ox-popup-code-input.ts +0 -69
  27. package/src/grist-editor/ox-popup-privilege-input.ts +0 -93
  28. package/src/index.ts +0 -4
  29. package/src/input/index.ts +0 -3
  30. package/src/input/ox-input-background-pattern.ts +0 -196
  31. package/src/input/ox-input-fill-style.ts +0 -377
  32. package/src/input/ox-input-graphql.ts +0 -153
  33. package/src/property-editor/index.ts +0 -83
  34. package/src/property-editor/ox-property-editor-graphql.ts +0 -22
  35. package/src/property-editor/ox-property-editor-resource-object.ts +0 -148
  36. package/src/selector/ox-selector-resource-id.ts +0 -201
  37. package/src/selector/ox-selector-resource-object-legacy.ts +0 -367
  38. package/src/selector/ox-selector-resource-object.ts +0 -300
  39. package/stories/graphql-client.stories.ts +0 -73
  40. package/stories/ox-input-graphql.stories.ts +0 -70
  41. package/stories/ox-selector-resource-object.stories.ts +0 -98
  42. package/tsconfig.json +0 -24
  43. package/web-dev-server.config.mjs +0 -27
  44. package/web-test-runner.config.mjs +0 -41
@@ -1,224 +0,0 @@
1
- import '../selector/ox-selector-resource-object.js'
2
-
3
- import { css, html } from 'lit'
4
- import { customElement, property, state } from 'lit/decorators.js'
5
-
6
- import { i18next } from '@operato/i18n'
7
- import { openPopup, PopupHandle } from '@operato/layout'
8
- import { OxFormField } from '@operato/input'
9
-
10
- @customElement('ox-filter-resource-object')
11
- export class OxFilterResourceObject extends OxFormField {
12
- static styles = [
13
- css`
14
- :host {
15
- display: block;
16
- position: relative;
17
- border-bottom: 1px solid rgba(0, 0, 0, 0.15);
18
- min-width: 100px;
19
-
20
- --ox-select-padding: var(--spacing-tiny);
21
- --ox-select-font: var(--input-font);
22
- --ox-select-color: var(--input-color, var(--md-sys-color-on-surface-variant));
23
- --ox-select-icon-color: var(--theme-primary-text-color, var(--md-sys-color-on-surface-variant));
24
- --ox-select-icon-hover-color: var(--md-sys-color-on-primary-container, #3c3938);
25
- }
26
-
27
- div {
28
- width: 100%;
29
- box-sizing: border-box;
30
-
31
- display: flex;
32
- flex-direction: row;
33
- align-items: center;
34
- justify-content: center;
35
- cursor: pointer;
36
- padding: var(--ox-select-padding);
37
- font: var(--ox-select-font);
38
- color: var(--ox-select-color);
39
- }
40
-
41
- span {
42
- flex: 1;
43
- overflow: hidden;
44
- text-overflow: ellipsis;
45
- white-space: nowrap;
46
- gap: 4px;
47
- }
48
-
49
- md-icon {
50
- --md-icon-size: 16px;
51
- display: block;
52
- text-align: right;
53
- color: var(--ox-select-icon-color);
54
- opacity: 0.7;
55
- }
56
-
57
- div:hover md-icon {
58
- color: var(--md-sys-color-on-primary-container);
59
- }
60
- `
61
- ]
62
-
63
- @property({ type: Object }) column: any
64
- @property({ type: String }) value?: string
65
-
66
- @state() resourceObject?: any
67
-
68
- private popup?: PopupHandle
69
-
70
- render() {
71
- var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}
72
-
73
- var value = this.resourceObject || {}
74
- var name, description
75
-
76
- if (typeof nameField === 'function') {
77
- name = nameField(value)
78
- } else {
79
- name = value[nameField]
80
- }
81
-
82
- if (typeof descriptionField === 'function') {
83
- description = descriptionField(value)
84
- } else {
85
- description = value[descriptionField] && `(${value[descriptionField]})`
86
- }
87
-
88
- return html`
89
- <div @click=${this._onclick} @keydown=${this._onkeydown}>
90
- <span tabindex="0" style="flex:1">${name || ''}${(description && `(${description})`) || ''}</span>
91
- <md-icon>search</md-icon>
92
- </div>
93
- `
94
- }
95
-
96
- _onclick(e: Event): void {
97
- e.stopPropagation()
98
- this.openSelector()
99
- }
100
-
101
- _onkeydown(e: KeyboardEvent): void {
102
- const key = e.key
103
- if (key == 'Enter') {
104
- e.stopPropagation()
105
- this.openSelector()
106
- }
107
- }
108
-
109
- openSelector() {
110
- if (this.popup) {
111
- delete this.popup
112
- }
113
-
114
- var {
115
- title = '',
116
- idField = 'id',
117
- nameField = 'name',
118
- descriptionField = 'description',
119
- valueField = 'id',
120
- queryName,
121
- basicArgs,
122
- select,
123
- columns,
124
- pagination,
125
- list
126
- } = this.column.record.options || {}
127
-
128
- if (!queryName) {
129
- console.warn('queryName is empty')
130
- return
131
- }
132
-
133
- /* select options is only for compatability, it might be able to be deprecated. */
134
- columns = columns || select
135
-
136
- const confirmCallback = (selected?: { [field: string]: any }) => {
137
- // this.department = selected
138
- // ? {
139
- // id: selected.id,
140
- // controlNo: selected.controlNo,
141
- // name: selected.name,
142
- // description: selected.description
143
- // }
144
- // : null
145
-
146
- // this.value = this.department?.name
147
-
148
- // this.dispatchEvent(
149
- // new CustomEvent('change', {
150
- // bubbles: true,
151
- // composed: true,
152
- // detail: this.value
153
- // })
154
- // )
155
-
156
- this.resourceObject = selected
157
- ? {
158
- ...(columns || [])
159
- .map((field: any) => field.name)
160
- .reduce(
161
- (obj: { [field: string]: any }, fieldName: string) => {
162
- return (obj = {
163
- ...obj,
164
- [fieldName]: selected[fieldName]
165
- })
166
- },
167
- {} as { [field: string]: any }
168
- ),
169
- [idField]: selected[idField],
170
- [nameField]: selected[nameField],
171
- [descriptionField]: selected[descriptionField]
172
- }
173
- : null
174
-
175
- this.value = this.resourceObject?.[nameField]
176
-
177
- this.dispatchEvent(
178
- new CustomEvent('change', {
179
- detail: this.value
180
- })
181
- )
182
- }
183
-
184
- var value = this.resourceObject || {}
185
- var actualValue
186
- if (typeof valueField === 'function') {
187
- actualValue = valueField(value)
188
- } else {
189
- actualValue = value[valueField]
190
- }
191
-
192
- var template = html`
193
- <ox-selector-resource-object
194
- .value=${actualValue}
195
- .confirmCallback=${confirmCallback.bind(this)}
196
- .queryName=${queryName}
197
- .columns=${columns}
198
- .pagination=${pagination}
199
- .list=${list}
200
- .basicArgs=${basicArgs}
201
- .valueField=${valueField}
202
- ></ox-selector-resource-object>
203
- `
204
-
205
- this.popup = openPopup(template, {
206
- backdrop: true,
207
- size: 'large',
208
- search: {
209
- autofocus: true,
210
- placeholder: title || i18next.t('title.select_item'),
211
- handler: (instance: any, value: any) => {
212
- /* instance: template instance */
213
- instance.searchText(value)
214
- }
215
- },
216
- filter: {
217
- handler: (instance: any) => {
218
- /* instance: template instance */
219
- instance.toggleFilter()
220
- }
221
- }
222
- })
223
- }
224
- }
@@ -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
- }