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

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 (46) hide show
  1. package/CHANGELOG.md +18 -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/demo/data-grist-test.html +0 -473
  7. package/demo/index.html +0 -35
  8. package/src/filter-renderer/filter-resource-select.ts +0 -133
  9. package/src/filter-renderer/index.ts +0 -6
  10. package/src/filters-form/filter-resource-code.ts +0 -11
  11. package/src/filters-form/filter-resource-object.ts +0 -11
  12. package/src/filters-form/filter-resource-select.ts +0 -130
  13. package/src/filters-form/index.ts +0 -14
  14. package/src/filters-form/ox-filter-resource-code.ts +0 -154
  15. package/src/filters-form/ox-filter-resource-object.ts +0 -224
  16. package/src/grist-editor/index.ts +0 -26
  17. package/src/grist-editor/ox-grist-editor-code.ts +0 -64
  18. package/src/grist-editor/ox-grist-editor-json.ts +0 -64
  19. package/src/grist-editor/ox-grist-editor-privilege.ts +0 -58
  20. package/src/grist-editor/ox-grist-editor-resource-code.ts +0 -30
  21. package/src/grist-editor/ox-grist-editor-resource-id.ts +0 -88
  22. package/src/grist-editor/ox-grist-editor-resource-object-legacy.ts +0 -131
  23. package/src/grist-editor/ox-grist-editor-resource-object.ts +0 -156
  24. package/src/grist-editor/ox-grist-renderer-crontab.ts +0 -18
  25. package/src/grist-editor/ox-grist-renderer-resource-code.ts +0 -85
  26. package/src/grist-editor/ox-grist-renderer-resource-id.ts +0 -17
  27. package/src/grist-editor/ox-grist-renderer-resource-object.ts +0 -26
  28. package/src/grist-editor/ox-popup-code-input.ts +0 -69
  29. package/src/grist-editor/ox-popup-privilege-input.ts +0 -93
  30. package/src/index.ts +0 -4
  31. package/src/input/index.ts +0 -3
  32. package/src/input/ox-input-background-pattern.ts +0 -196
  33. package/src/input/ox-input-fill-style.ts +0 -377
  34. package/src/input/ox-input-graphql.ts +0 -153
  35. package/src/property-editor/index.ts +0 -83
  36. package/src/property-editor/ox-property-editor-graphql.ts +0 -22
  37. package/src/property-editor/ox-property-editor-resource-object.ts +0 -148
  38. package/src/selector/ox-selector-resource-id.ts +0 -201
  39. package/src/selector/ox-selector-resource-object-legacy.ts +0 -367
  40. package/src/selector/ox-selector-resource-object.ts +0 -300
  41. package/stories/graphql-client.stories.ts +0 -73
  42. package/stories/ox-input-graphql.stories.ts +0 -70
  43. package/stories/ox-selector-resource-object.stories.ts +0 -98
  44. package/tsconfig.json +0 -24
  45. package/web-dev-server.config.mjs +0 -27
  46. package/web-test-runner.config.mjs +0 -41
@@ -1,300 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/data-grist'
3
-
4
- import gql from 'graphql-tag'
5
- import { css, html, LitElement, PropertyValues } from 'lit'
6
- import { customElement, property, query } from 'lit/decorators.js'
7
-
8
- import {
9
- DataGrist,
10
- FetchHandler,
11
- GristData,
12
- GristEventHandler,
13
- GristRecord,
14
- ZERO_DATA,
15
- InheritedValueType
16
- } from '@operato/data-grist'
17
- import { client, gqlContext } from '@operato/graphql'
18
- import { i18next } from '@operato/i18n'
19
- import { closePopup } from '@operato/popup'
20
- import { adjustFilters, isMobileDevice } from '@operato/utils'
21
- import { ButtonContainerStyles, CommonHeaderStyles } from '@operato/styles'
22
-
23
- @customElement('ox-selector-resource-object')
24
- export class OxSelectorResourceObject extends LitElement {
25
- static styles = [
26
- CommonHeaderStyles,
27
- css`
28
- :host {
29
- display: flex;
30
- flex-direction: column;
31
-
32
- background-color: var(--md-sys-color-surface);
33
-
34
- width: var(--overlay-center-normal-width, 50%);
35
- height: var(--overlay-center-normal-height, 50%);
36
- }
37
-
38
- ox-grist {
39
- flex: 1;
40
- }
41
-
42
- .header {
43
- grid-template-areas: 'filters actions';
44
- }
45
-
46
- [filler] {
47
- margin-left: auto;
48
- }
49
- `
50
- ]
51
-
52
- @property({ type: String }) value?: string
53
- @property({ type: Object }) config: any
54
- @property({ type: Object }) data: GristData = ZERO_DATA
55
- @property({ type: String }) queryName!: string
56
- @property({ type: Object }) basicArgs: any
57
- @property({ type: String }) inherited?: InheritedValueType = InheritedValueType.Include
58
- @property({ type: Object }) confirmCallback?: (record?: Partial<GristRecord>) => void
59
- @property({ type: Array }) selectedRecords: GristRecord[] = []
60
-
61
- @property({ type: Array }) searchFields: any
62
- @property({ type: Array }) columns: {
63
- type: string
64
- name: string
65
- header: string
66
- subFields?: string[]
67
- hidden: boolean
68
- queryName: string
69
- width: number
70
- }[] = []
71
- @property({ type: Object }) pagination?: {
72
- limit: number
73
- pages: number[]
74
- }
75
- @property({ type: Object }) list: any
76
- @property({ type: String }) valueField: string | ((item: any) => any) = 'id'
77
-
78
- @query('ox-grist') grist!: DataGrist
79
-
80
- render() {
81
- return html`
82
- <ox-grist
83
- .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
84
- .config=${this.config}
85
- .data=${this.data}
86
- .fetchHandler=${this.fetchHandler.bind(this)}
87
- .selectedRecords=${this.selectedRecords}
88
- >
89
- <div class="header" slot="headroom">
90
- <div class="filters">
91
- <ox-filters-form autofocus without-search></ox-filters-form>
92
- </div>
93
- </div>
94
- </ox-grist>
95
-
96
- <div class="footer">
97
- <button @click=${this.onEmpty.bind(this)}>
98
- <md-icon>check_box_outline_blank</md-icon>${i18next.t('button.empty')}
99
- </button>
100
-
101
- <div filler></div>
102
-
103
- <button @click=${this.onCancel.bind(this)}><md-icon>cancel</md-icon>${i18next.t('button.cancel')}</button>
104
- <button @click=${this.onConfirm.bind(this)} done><md-icon>done</md-icon>${i18next.t('button.confirm')}</button>
105
- </div>
106
- `
107
- }
108
-
109
- searchText(value: string) {
110
- this.grist.searchText = value
111
- }
112
-
113
- toggleFilter() {
114
- this.grist.toggleHeadroom()
115
- }
116
-
117
- onEmpty() {
118
- this.confirmCallback && this.confirmCallback()
119
- closePopup(this)
120
- }
121
-
122
- onCancel() {
123
- closePopup(this)
124
- }
125
-
126
- onConfirm() {
127
- this.confirmCallback && this.confirmCallback(this.selected)
128
- closePopup(this)
129
- }
130
-
131
- fetchHandler: FetchHandler = async ({ filters = [], page, limit, sortings = [], inherited }) => {
132
- if (this.basicArgs?.filters) {
133
- filters = adjustFilters(filters, this.basicArgs.filters)
134
- }
135
- const pagination = { page, limit }
136
-
137
- const response = await client.query({
138
- query: gql`
139
- query($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!], $inherited: InheritedValueType) {
140
- fetch: ${
141
- this.queryName
142
- } (filters: $filters, pagination: $pagination, sortings: $sortings, inherited: $inherited) {
143
- ${this.getQueryFields()}
144
- }
145
- }
146
- `,
147
- variables: {
148
- filters,
149
- pagination,
150
- sortings,
151
- inherited: inherited || this.inherited
152
- },
153
- context: gqlContext()
154
- })
155
-
156
- if (!response.errors) {
157
- const records = response.data.fetch.items.map((item: any) => {
158
- let rowValue
159
-
160
- if (this.valueField && typeof this.valueField === 'function') {
161
- rowValue = this.valueField(item)
162
- } else if (this.valueField) {
163
- rowValue = item[this.valueField]
164
- } else {
165
- rowValue = item.id
166
- }
167
-
168
- if (this.value && this.value === rowValue) {
169
- this.selectedRecords = [item]
170
- item['__selected__'] = true
171
- }
172
-
173
- return item
174
- })
175
- const total = response.data.fetch.total
176
-
177
- return {
178
- records,
179
- total,
180
- limit,
181
- page
182
- }
183
- }
184
- }
185
-
186
- async firstUpdated() {
187
- const config = {
188
- list: this.list,
189
- columns: [
190
- {
191
- type: 'gutter',
192
- gutterName: 'sequence'
193
- },
194
- {
195
- type: 'gutter',
196
- gutterName: 'row-selector',
197
- multiple: false
198
- }
199
- ],
200
- rows: {
201
- selectable: {
202
- multiple: false
203
- },
204
- handlers: {
205
- click: 'select-row',
206
- dblclick: ((columns, data, column, record, rowIndex, field) => {
207
- this.onConfirm()
208
- }) as GristEventHandler
209
- },
210
- appendable: false
211
- },
212
- pagination: this.pagination
213
- }
214
-
215
- const columns = this.columns || [
216
- {
217
- type: 'string',
218
- name: 'id',
219
- header: i18next.t('field.id'),
220
- hidden: true
221
- },
222
- {
223
- type: 'string',
224
- name: 'name',
225
- header: i18next.t('field.name'),
226
- record: {
227
- align: 'left'
228
- },
229
- sortable: true,
230
- filter: 'search',
231
- width: 160
232
- },
233
- {
234
- type: 'string',
235
- name: 'description',
236
- header: i18next.t('field.description'),
237
- record: {
238
- align: 'left'
239
- },
240
- sortable: true,
241
- filter: 'search',
242
- width: 300
243
- }
244
- ]
245
-
246
- this.config = {
247
- ...config,
248
- columns: [
249
- ...config.columns,
250
- ...columns.map(selectField => {
251
- return {
252
- ...selectField,
253
- type: selectField.type || 'string',
254
- width: selectField.width || 160,
255
- header: selectField.header || i18next.t(`field.${selectField.name}`)
256
- }
257
- })
258
- ]
259
- }
260
-
261
- requestAnimationFrame(() => {
262
- /* start with hidden headroom */
263
- this.grist.hideHeadroom()
264
- })
265
- }
266
-
267
- getQueryFields() {
268
- if (this.columns && this.columns.length > 0) {
269
- return `items {
270
- ${this.columns.map(selectField => {
271
- return selectField.type === 'object'
272
- ? `${selectField.name} { ${
273
- selectField.subFields && selectField.subFields.length > 0
274
- ? selectField.subFields.join(' ')
275
- : `id name description`
276
- } }`
277
- : `${selectField.name}`
278
- })}
279
- }
280
- total`
281
- } else {
282
- return `
283
- items {
284
- id
285
- name
286
- description
287
- }
288
- total
289
- `
290
- }
291
- }
292
-
293
- get selected() {
294
- var grist = this.renderRoot.querySelector('ox-grist') as DataGrist
295
-
296
- var selected = grist.selected
297
-
298
- return selected && selected.length > 0 ? selected[0] : undefined
299
- }
300
- }
@@ -1,73 +0,0 @@
1
- import { setClientLink, createMockLink } from '@operato/graphql/graphql-env.js'
2
- import '@operato/graphql/graphql-client.js'
3
- import '../src/input/ox-input-graphql.js'
4
-
5
- // TODO cm6-graphql에서 사용하는 nullthrows 관련 모듈 오류로 스토리북 테스트가 안됨.
6
-
7
- import { html, TemplateResult } from 'lit'
8
-
9
- setClientLink(
10
- createMockLink({
11
- request: {
12
- query: ''
13
- },
14
- result: {
15
- data: {
16
- viewer: null
17
- }
18
- }
19
- })
20
- )
21
-
22
- export default {
23
- title: 'graphql-client',
24
- component: 'graphql-client',
25
- argTypes: {
26
- value: { control: 'text' },
27
- name: { control: 'text' }
28
- }
29
- }
30
-
31
- interface Story<T> {
32
- (args: T): TemplateResult
33
- args?: Partial<T>
34
- argTypes?: Record<string, unknown>
35
- }
36
-
37
- interface ArgTypes {
38
- name?: string
39
- value?: string
40
- }
41
-
42
- const Template: Story<ArgTypes> = ({ name = 'code', value = '' }: ArgTypes) => html`
43
- <style>
44
- body {
45
- }
46
- </style>
47
-
48
- <ox-input-graphql
49
- @change=${(e: Event) => {
50
- console.log((e.target as HTMLInputElement).value)
51
- }}
52
- name=${name}
53
- .value=${value}
54
- >
55
- </ox-input-graphql>
56
- `
57
-
58
- export const Regular = Template.bind({})
59
- Regular.args = {
60
- name: 'code',
61
- value: `
62
- query privileges {
63
- privileges {
64
- items {
65
- privilege
66
- category
67
- description
68
- }
69
- total
70
- }
71
- }
72
- `
73
- }
@@ -1,70 +0,0 @@
1
- import '../src/input/ox-input-graphql.js'
2
-
3
- import { html, TemplateResult } from 'lit'
4
-
5
- export default {
6
- title: 'ox-input-graphql',
7
- component: 'ox-input-graphql',
8
- argTypes: {
9
- value: { control: 'text' },
10
- name: { control: 'text' }
11
- }
12
- }
13
-
14
- interface Story<T> {
15
- (args: T): TemplateResult
16
- args?: Partial<T>
17
- argTypes?: Record<string, unknown>
18
- }
19
-
20
- interface ArgTypes {
21
- name?: string
22
- value?: string
23
- }
24
-
25
- const Template: Story<ArgTypes> = ({ name = 'code', value = '' }: ArgTypes) => html`
26
- <link href="/themes/app-theme.css" rel="stylesheet" />
27
- <link
28
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
29
- rel="stylesheet"
30
- />
31
- <link
32
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
33
- rel="stylesheet"
34
- />
35
- <link
36
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
37
- rel="stylesheet"
38
- />
39
-
40
- <style>
41
- body {
42
- }
43
- </style>
44
-
45
- <ox-input-graphql
46
- @change=${(e: Event) => {
47
- console.log((e.target as HTMLInputElement).value)
48
- }}
49
- name=${name}
50
- .value=${value}
51
- >
52
- </ox-input-graphql>
53
- `
54
-
55
- export const Regular = Template.bind({})
56
- Regular.args = {
57
- name: 'code',
58
- value: `
59
- query privileges {
60
- privileges {
61
- items {
62
- privilege
63
- category
64
- description
65
- }
66
- total
67
- }
68
- }
69
- `
70
- }
@@ -1,98 +0,0 @@
1
- import { html, TemplateResult } from 'lit'
2
- import { ifDefined } from 'lit/directives/if-defined.js'
3
-
4
- import { setClientLink, createMockLink } from '@operato/graphql/graphql-env.js'
5
- import '../src/selector/ox-selector-resource-object'
6
-
7
- setClientLink(
8
- createMockLink({
9
- request: {
10
- query: ''
11
- },
12
- result: {
13
- data: {
14
- viewer: null
15
- }
16
- }
17
- })
18
- )
19
-
20
- export default {
21
- title: 'ox-selector-resource-object',
22
- component: 'ox-selector-resource-object',
23
- argTypes: {
24
- queryName: { control: 'string' },
25
- value: { control: 'string' },
26
- valueField: { control: 'string' }
27
- }
28
- }
29
-
30
- interface Story<T> {
31
- (args: T): TemplateResult
32
- args?: Partial<T>
33
- argTypes?: Record<string, unknown>
34
- }
35
-
36
- interface ArgTypes {
37
- queryName: string
38
- value?: string
39
- valueField?: string
40
- }
41
-
42
- const Template: Story<ArgTypes> = ({ value = '', queryName, valueField }: ArgTypes) => html`
43
- <style>
44
- body {
45
- }
46
- </style>
47
-
48
- <script>
49
- const select = ['name', 'description']
50
- </script>
51
-
52
- <ox-selector-resource-object
53
- @change=${(e: Event) => {
54
- console.log((e.target as HTMLInputElement).value)
55
- }}
56
- name=${name}
57
- value=${ifDefined(value)}
58
- valueField=${ifDefined(valueField)}
59
- .queryName=${queryName}
60
- .confirmCallback=${(record: any) => console.log('confirm', record)}
61
- .columns=${[
62
- {
63
- type: 'string',
64
- name: 'id',
65
- header: 'id',
66
- hidden: true,
67
- width: 100,
68
- queryName: ''
69
- },
70
- {
71
- type: 'string',
72
- name: 'name',
73
- header: 'name',
74
- hidden: false,
75
- width: 150,
76
- queryName: ''
77
- },
78
- {
79
- type: 'string',
80
- name: 'description',
81
- header: 'description',
82
- hidden: false,
83
- width: 150,
84
- queryName: ''
85
- }
86
- ]}
87
- .list=${['name', 'description']}
88
- .basicArgs=${''}
89
- >
90
- </ox-selector-resource-object>
91
- `
92
-
93
- export const Regular = Template.bind({})
94
- Regular.args = {
95
- value: '',
96
- queryName: 'entity',
97
- valueField: 'id'
98
- }
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
- "noEmitOnError": true,
7
- "lib": ["es2017", "dom"],
8
- "strict": true,
9
- "esModuleInterop": false,
10
- "allowSyntheticDefaultImports": true,
11
- "experimentalDecorators": true,
12
- "useDefineForClassFields": false,
13
- "importHelpers": true,
14
- "outDir": "dist",
15
- "sourceMap": true,
16
- "inlineSources": true,
17
- "rootDir": "./",
18
- "declaration": true,
19
- "incremental": true,
20
- "skipLibCheck": true,
21
- "types": ["node", "mocha"]
22
- },
23
- "include": ["**/*.ts"]
24
- }
@@ -1,27 +0,0 @@
1
- // import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
2
-
3
- /** Use Hot Module replacement by adding --hmr to the start command */
4
- const hmr = process.argv.includes('--hmr');
5
-
6
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
7
- open: '/demo/',
8
- /** Use regular watch mode if HMR is not enabled. */
9
- watch: !hmr,
10
- /** Resolve bare module imports */
11
- nodeResolve: {
12
- exportConditions: ['browser', 'development'],
13
- },
14
-
15
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
16
- // esbuildTarget: 'auto'
17
-
18
- /** Set appIndex to enable SPA routing */
19
- // appIndex: 'demo/index.html',
20
-
21
- plugins: [
22
- /** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
23
- // hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
24
- ],
25
-
26
- // See documentation for all available options
27
- });
@@ -1,41 +0,0 @@
1
- // import { playwrightLauncher } from '@web/test-runner-playwright';
2
-
3
- const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
4
-
5
- export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
6
- /** Test files to run */
7
- files: 'dist/test/**/*.test.js',
8
-
9
- /** Resolve bare module imports */
10
- nodeResolve: {
11
- exportConditions: ['browser', 'development'],
12
- },
13
-
14
- /** Filter out lit dev mode logs */
15
- filterBrowserLogs(log) {
16
- for (const arg of log.args) {
17
- if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
18
- return false;
19
- }
20
- }
21
- return true;
22
- },
23
-
24
- /** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
25
- // esbuildTarget: 'auto',
26
-
27
- /** Amount of browsers to run concurrently */
28
- // concurrentBrowsers: 2,
29
-
30
- /** Amount of test files per browser to test concurrently */
31
- // concurrency: 1,
32
-
33
- /** Browsers to run tests on */
34
- // browsers: [
35
- // playwrightLauncher({ product: 'chromium' }),
36
- // playwrightLauncher({ product: 'firefox' }),
37
- // playwrightLauncher({ product: 'webkit' }),
38
- // ],
39
-
40
- // See documentation for all available options
41
- });