@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,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
- }
@@ -1,85 +0,0 @@
1
- import gql from 'graphql-tag'
2
- import { css, html } from 'lit'
3
- import { client, gqlContext } from '@operato/graphql'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxGristRenderer } from '@operato/data-grist'
7
-
8
- type CommonCodeDetail = {
9
- name: string
10
- description: string
11
- rank: number
12
- }
13
-
14
- @customElement('ox-grist-renderer-resource-code')
15
- export class OxGristRendererResourceCode extends OxGristRenderer {
16
- static styles = css`
17
- :host {
18
- display: block;
19
- position: relative;
20
-
21
- width: 100%;
22
- }
23
-
24
- span {
25
- text-overflow: ellipsis;
26
- display: block;
27
- overflow: hidden;
28
- }
29
- `
30
-
31
- async connectedCallback() {
32
- var { codeName, codes } = this.column.record || {}
33
-
34
- if (!codes && codeName) {
35
- let response = await client.query({
36
- query: gql`
37
- query CommonCode($name: String!) {
38
- commonCode(name: $name) {
39
- details {
40
- name
41
- description
42
- rank
43
- }
44
- }
45
- }
46
- `,
47
- variables: {
48
- name: codeName
49
- }
50
- })
51
-
52
- var commonCode = response?.data?.commonCode
53
-
54
- this.column.record.codes = [{ name: '', description: '' }].concat(
55
- (commonCode?.details || []).sort(function (a: CommonCodeDetail, b: CommonCodeDetail) {
56
- return a.rank - b.rank
57
- })
58
- )
59
- }
60
-
61
- super.connectedCallback()
62
- }
63
-
64
- get rendererTemplate() {
65
- if (!this.value) {
66
- return html``
67
- }
68
-
69
- var { codes, renderDispOpt = 'name' } = this.column.record || {}
70
-
71
- if (codes) {
72
- for (let idx = 0; idx < codes.length; idx++) {
73
- let code = codes[idx]
74
-
75
- if (code.name == this.value) {
76
- return html`<span data-reactive-tooltip
77
- >${code.name == '' ? '' : renderDispOpt.replace('name', code.description).replace('code', code.name)}</span
78
- > `
79
- }
80
- }
81
- }
82
-
83
- return html`<span data-reactive-tooltip>${this.value}</span> `
84
- }
85
- }
@@ -1,17 +0,0 @@
1
- import { html } from 'lit'
2
-
3
- import { FieldRenderer } from '@operato/data-grist'
4
-
5
- export const OxGristRendererResourceId: FieldRenderer = (value, column, record, rowIndex, field) => {
6
- if (!value) {
7
- return ''
8
- }
9
-
10
- const { nameField = 'name', descriptionField = 'description' } = column.record.options || {}
11
-
12
- const name = value[nameField] || ''
13
- const description = value[descriptionField] || ''
14
- const suffix = description ? `(${description})` : ''
15
-
16
- return html`<span>${name}${suffix}</span> `
17
- }
@@ -1,26 +0,0 @@
1
- import { html } from 'lit-html'
2
-
3
- import { FieldRenderer } from '@operato/data-grist'
4
-
5
- export const OxGristRendererResourceObject: FieldRenderer = (value, column, record, rowIndex, field) => {
6
- if (!value) {
7
- return ''
8
- }
9
-
10
- var { nameField = 'name', descriptionField = 'description' } = column.record.options || {}
11
- var name, description
12
-
13
- if (typeof nameField === 'function') {
14
- name = nameField(value)
15
- } else {
16
- name = value[nameField]
17
- }
18
-
19
- if (typeof descriptionField === 'function') {
20
- description = descriptionField(value)
21
- } else {
22
- description = value[descriptionField] && `(${value[descriptionField]})`
23
- }
24
-
25
- return html`<span>${name || ''}${description || ''}</span> `
26
- }
@@ -1,69 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/input/ox-input-code.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, property } from 'lit/decorators.js'
6
-
7
- import { i18next } from '@operato/i18n'
8
- import { closePopup } from '@operato/popup'
9
- import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
10
-
11
- @customElement('ox-popup-code-input')
12
- export class OxPopupCodeInput extends LitElement {
13
- static styles = [
14
- CommonHeaderStyles,
15
- ScrollbarStyles,
16
- css`
17
- :host {
18
- display: flex;
19
- flex-direction: column;
20
-
21
- background-color: var(--md-sys-color-surface);
22
-
23
- width: var(--overlay-center-normal-width, 50%);
24
- height: var(--overlay-center-normal-height, 50%);
25
- }
26
-
27
- ox-input-code {
28
- flex: 1;
29
- overflow-y: auto;
30
- margin: var(--spacing-small);
31
- }
32
- `
33
- ]
34
-
35
- @property({ type: Object }) value: any
36
- @property({ type: String }) mode: string = 'javascript'
37
- @property({ type: Object }) confirmCallback!: (newval: any) => void
38
- @property({ type: String }) language?: string = 'javascript'
39
-
40
- render() {
41
- return html`
42
- <ox-input-code .value=${this.value} @change=${this.onChange.bind(this)} .language=${this.language}>
43
- </ox-input-code>
44
-
45
- <div class="footer">
46
- <div filler></div>
47
- <button @click=${this.onCancel.bind(this)} danger>
48
- <md-icon>cancel</md-icon>${i18next.t('button.cancel')}
49
- </button>
50
- <button @click=${this.onConfirm.bind(this)} done><md-icon>done</md-icon>${i18next.t('button.confirm')}</button>
51
- </div>
52
- `
53
- }
54
-
55
- private onChange(e: CustomEvent) {
56
- e.stopPropagation()
57
-
58
- this.value = e.detail
59
- }
60
-
61
- private onCancel(e: Event) {
62
- closePopup(this)
63
- }
64
-
65
- private onConfirm(e: Event) {
66
- this.confirmCallback && this.confirmCallback(this.value)
67
- closePopup(this)
68
- }
69
- }
@@ -1,93 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/input/ox-input-privilege.js'
3
-
4
- import gql from 'graphql-tag'
5
- import { css, html, LitElement, PropertyValueMap } from 'lit'
6
- import { customElement, property, state } from 'lit/decorators.js'
7
-
8
- import { i18next } from '@operato/i18n'
9
- import { closePopup } from '@operato/popup'
10
- import { CommonHeaderStyles, ScrollbarStyles } from '@operato/styles'
11
- import { client } from '@operato/graphql'
12
-
13
- @customElement('ox-popup-privilege-input')
14
- export class OxPopupPrivilegeInput extends LitElement {
15
- static styles = [
16
- CommonHeaderStyles,
17
- ScrollbarStyles,
18
- css`
19
- :host {
20
- display: flex;
21
- flex-direction: column;
22
-
23
- background-color: var(--md-sys-color-surface);
24
-
25
- width: var(--overlay-center-normal-width, 50%);
26
- height: var(--overlay-center-normal-height, 50%);
27
- }
28
-
29
- ox-input-privilege {
30
- flex: 1;
31
- overflow-y: auto;
32
- }
33
- `
34
- ]
35
-
36
- @property({ type: Object }) value?: { category: string; privilege: string; owner: boolean; super: boolean } | null
37
-
38
- @property({ type: Object }) confirmCallback!: (newval: any) => void
39
-
40
- @state() privileges: { privilege: string; category: string; description: string }[] = []
41
-
42
- render() {
43
- return html`
44
- <ox-input-privilege .value=${this.value} .privileges=${this.privileges} @change=${this.onChange.bind(this)}>
45
- </ox-input-privilege>
46
-
47
- <div class="footer">
48
- <button @click=${this.onReset.bind(this)}><md-icon>restart_alt</md-icon>${i18next.t('button.reset')}</button>
49
- <div filler></div>
50
- <button @click=${this.onCancel.bind(this)}><md-icon>cancel</md-icon>${i18next.t('button.cancel')}</button>
51
- <button @click=${this.onConfirm.bind(this)} done><md-icon>done</md-icon>${i18next.t('button.confirm')}</button>
52
- </div>
53
- `
54
- }
55
-
56
- async firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): Promise<void> {
57
- const response = await client.query({
58
- query: gql`
59
- query privileges {
60
- privileges {
61
- items {
62
- privilege
63
- category
64
- description
65
- }
66
- total
67
- }
68
- }
69
- `
70
- })
71
-
72
- this.privileges = response.data.privileges.items
73
- }
74
-
75
- private onChange(e: CustomEvent) {
76
- e.stopPropagation()
77
-
78
- this.value = e.detail
79
- }
80
-
81
- private onReset(e: Event) {
82
- this.value = null
83
- }
84
-
85
- private onCancel(e: Event) {
86
- closePopup(this)
87
- }
88
-
89
- private onConfirm(e: Event) {
90
- this.confirmCallback && this.confirmCallback(this.value)
91
- closePopup(this)
92
- }
93
- }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './input/index.js'
2
- export * from './property-editor/index.js'
3
- export * from './grist-editor/index.js'
4
- export * from './filter-renderer/index.js'
@@ -1,3 +0,0 @@
1
- export * from './ox-input-background-pattern.js'
2
- export * from './ox-input-fill-style.js'
3
- export * from './ox-input-graphql.js'
@@ -1,196 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@operato/i18n/ox-i18n.js'
6
- import '@operato/input/ox-input-color.js'
7
- import '@operato/attachment/ox-attachment-selector.js'
8
-
9
- import { css, html } from 'lit'
10
- import { customElement, property } from 'lit/decorators.js'
11
-
12
- import { OxFormField } from '@operato/input'
13
-
14
- export type BackgroundPatternOption = {
15
- image?: HTMLImageElement | string
16
- color?: string
17
- align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
18
- offsetX?: number
19
- offsetY?: number
20
- width?: number
21
- height?: number
22
- fitPattern?: boolean
23
- noRepeat?: boolean
24
- }
25
-
26
- /**
27
- * 컴포넌트의 fill pattern을 편집하는 element
28
- *
29
- * Example:
30
- * <ox-input-background-pattern
31
- * @change="${e => { this.pattern = e.target.value }}"
32
- * .value=${this.pattern}"
33
- * ></ox-input-background-pattern>
34
- */
35
-
36
- @customElement('ox-input-background-pattern')
37
- export class OxInputBackgroundPattern extends OxFormField {
38
- static styles = css`
39
- :host,
40
- .grid-10 {
41
- display: grid;
42
- grid-template-columns: repeat(10, 1fr);
43
- grid-gap: 5px;
44
- grid-auto-rows: minmax(24px, auto);
45
-
46
- align-items: center;
47
- }
48
-
49
- * {
50
- align-self: stretch;
51
- }
52
-
53
- label {
54
- grid-column: span 2;
55
- text-align: right;
56
- text-transform: capitalize;
57
-
58
- align-self: center;
59
- }
60
-
61
- .grid-10 {
62
- grid-column: span 10;
63
- }
64
-
65
- select,
66
- input,
67
- [custom-editor] {
68
- grid-column: span 8;
69
- }
70
-
71
- select {
72
- height: 100%;
73
- border: 1px solid rgba(0, 0, 0, 0.2);
74
- }
75
-
76
- input[type='checkbox'] {
77
- grid-column: 3 / 4;
78
- align-self: center;
79
- }
80
-
81
- input[type='checkbox'] ~ label {
82
- grid-column: span 7;
83
- text-align: left;
84
- }
85
-
86
- .grid-10 > input[type='number'] {
87
- grid-column: span 3;
88
- border: 1px solid rgba(0, 0, 0, 0.2);
89
- }
90
-
91
- .grid-10 > label {
92
- grid-column: span 2;
93
- text-align: right;
94
- }
95
-
96
- .grid-10 > .icon-only-label {
97
- grid-column: span 2;
98
-
99
- background: var(--url-icon-properties-label) no-repeat;
100
- float: left;
101
- margin: 0;
102
- align-self: stretch;
103
- }
104
-
105
- .icon-only-label.color {
106
- background-position: 100% -500px;
107
- }
108
-
109
- .grid-10 > ox-input-color {
110
- grid-column: span 8;
111
- }
112
- `
113
-
114
- @property({ type: Object }) value?: BackgroundPatternOption
115
-
116
- render() {
117
- const value = this.value || ({} as BackgroundPatternOption)
118
-
119
- return html`
120
- <label> <ox-i18n msgid="label.image">image</ox-i18n> </label>
121
-
122
- <ox-attachment-selector
123
- value-key="image"
124
- .value=${value.image || ''}
125
- .properties=${{
126
- category: 'image'
127
- }}
128
- custom-editor
129
- ></ox-attachment-selector>
130
-
131
- <label> <ox-i18n msgid="label.align">align</ox-i18n> </label>
132
-
133
- <select value-key="align" class="select-content" .value=${value.align}>
134
- <option value="left-top">Left Top</option>
135
- <option value="top">Center Top</option>
136
- <option value="right-top">Right Top</option>
137
- <option value="left">Left Center</option>
138
- <option value="center">Center Center</option>
139
- <option value="right">Right Center</option>
140
- <option value="left-bottom">Left Bottom</option>
141
- <option value="bottom">Center Bottom</option>
142
- <option value="right-bottom">Right Bottom</option>
143
- </select>
144
-
145
- <div class="grid-10">
146
- <label> <ox-i18n msgid="label.offset-x">offsetX</ox-i18n> </label>
147
- <input type="number" value-key="offsetX" .value=${value.offsetX} />
148
-
149
- <label> <ox-i18n msgid="label.offset-y">offsetY</ox-i18n> </label>
150
- <input type="number" value-key="offsetY" .value=${value.offsetY} />
151
-
152
- <label> <ox-i18n msgid="label.width">width</ox-i18n> </label>
153
- <input type="number" value-key="width" .value=${value.width} />
154
-
155
- <label> <ox-i18n msgid="label.height">height</ox-i18n> </label>
156
- <input type="number" value-key="height" .value=${value.height} />
157
- </div>
158
-
159
- <div class="grid-10">
160
- <label class="icon-only-label color"></label>
161
- <ox-input-color value-key="color" .value=${value.color}> </ox-input-color>
162
- </div>
163
-
164
- <div class="grid-10">
165
- <input value-key="fitPattern" type="checkbox" .checked=${value.fitPattern} required />
166
- <label> <ox-i18n msgid="label.fit">fit</ox-i18n> </label>
167
- </div>
168
-
169
- <div class="grid-10">
170
- <input value-key="noRepeat" type="checkbox" .checked=${value.noRepeat} required />
171
- <label> <ox-i18n msgid="label.no-repeat">no repeat</ox-i18n> </label>
172
- </div>
173
- `
174
- }
175
-
176
- firstUpdated() {
177
- this.renderRoot.addEventListener('change', this._onChange.bind(this))
178
- }
179
-
180
- _onChange(e: Event) {
181
- var element = e.target as HTMLInputElement
182
- var key = element.getAttribute('value-key')
183
- var value: any = element.value
184
-
185
- if (key === 'fitPattern' || key === 'noRepeat') {
186
- value = element.checked
187
- }
188
-
189
- this.value = {
190
- ...this.value,
191
- [key!]: value
192
- }
193
-
194
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
195
- }
196
- }