@operato/attribute 7.1.31 → 7.1.33

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@operato/attribute",
3
3
  "description": "WebApplication attribute supporting components following open-wc recommendations",
4
4
  "author": "heartyoh",
5
- "version": "7.1.31",
5
+ "version": "7.1.33",
6
6
  "main": "dist/src/index.js",
7
7
  "module": "dist/src/index.js",
8
8
  "exports": {
@@ -58,16 +58,16 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@material/web": "^2.0.0",
61
- "@operato/data-grist": "^7.1.31",
62
- "@operato/graphql": "^7.1.1",
63
- "@operato/grist-editor": "^7.1.31",
64
- "@operato/i18n": "^7.1.1",
65
- "@operato/input": "^7.1.30",
66
- "@operato/popup": "^7.1.30",
67
- "@operato/property-editor": "^7.1.31",
68
- "@operato/shell": "^7.1.30",
69
- "@operato/styles": "^7.1.27",
70
- "@operato/utils": "^7.1.1",
61
+ "@operato/data-grist": "^7.1.33",
62
+ "@operato/graphql": "^7.1.32",
63
+ "@operato/grist-editor": "^7.1.33",
64
+ "@operato/i18n": "^7.1.32",
65
+ "@operato/input": "^7.1.32",
66
+ "@operato/popup": "^7.1.32",
67
+ "@operato/property-editor": "^7.1.33",
68
+ "@operato/shell": "^7.1.32",
69
+ "@operato/styles": "^7.1.32",
70
+ "@operato/utils": "^7.1.32",
71
71
  "lit": "^3.1.2"
72
72
  },
73
73
  "devDependencies": {
@@ -102,5 +102,5 @@
102
102
  "prettier --write"
103
103
  ]
104
104
  },
105
- "gitHead": "c22b92c8fc82a72d6503aa7107df33aab985155a"
105
+ "gitHead": "be435a2464e7777dfd201fb86af731ee92e45a65"
106
106
  }
package/.editorconfig DELETED
@@ -1,29 +0,0 @@
1
- # EditorConfig helps developers define and maintain consistent
2
- # coding styles between different editors and IDEs
3
- # editorconfig.org
4
-
5
- root = true
6
-
7
-
8
- [*]
9
-
10
- # Change these settings to your own preference
11
- indent_style = space
12
- indent_size = 2
13
-
14
- # We recommend you to keep these unchanged
15
- end_of_line = lf
16
- charset = utf-8
17
- trim_trailing_whitespace = true
18
- insert_final_newline = true
19
-
20
- [*.md]
21
- trim_trailing_whitespace = false
22
-
23
- [*.json]
24
- indent_size = 2
25
-
26
- [*.{html,js,md}]
27
- block_comment_start = /**
28
- block_comment = *
29
- block_comment_end = */
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
- };
@@ -1,8 +0,0 @@
1
- import { storybookPlugin } from '@web/dev-server-storybook';
2
- import baseConfig from '../web-dev-server.config.mjs';
3
-
4
- export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
5
- ...baseConfig,
6
- open: '/',
7
- plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
8
- });
@@ -1,10 +0,0 @@
1
- import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'
2
-
3
- import { OxGristEditorAttributes } from './ox-grist-editor-attributes'
4
-
5
- /* register grist renderer/editor for id */
6
- registerEditor('attributes', OxGristEditorAttributes)
7
-
8
- registerRenderer('attributes', OxGristRendererJson5)
9
-
10
- export * from './ox-grist-editor-attributes'
@@ -1,93 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import './ox-popup-attributes.js'
6
-
7
- import { html } from 'lit'
8
- import { customElement } from 'lit/decorators.js'
9
- import { cloneDeep } from 'lodash-es'
10
-
11
- import { OxGristEditor } from '@operato/data-grist'
12
- import { i18next } from '@operato/i18n'
13
- import { openPopup, PopupHandle } from '@operato/popup'
14
-
15
- @customElement('ox-grist-editor-attributes')
16
- export class OxGristEditorAttributes extends OxGristEditor {
17
- private popup?: PopupHandle
18
-
19
- get editorTemplate() {
20
- const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value
21
- return html`<div tabindex="0">${value || ''}</div> `
22
- }
23
-
24
- _onclick(e: Event): void {
25
- e.stopPropagation()
26
- this.openPopup()
27
- }
28
-
29
- _onkeydown(e: KeyboardEvent): void {
30
- const key = e.key
31
- if (key == 'Enter') {
32
- e.stopPropagation()
33
- this.openPopup()
34
- }
35
- }
36
-
37
- async openPopup() {
38
- if (this.popup) {
39
- delete this.popup
40
- }
41
-
42
- var { options } = this.column.record
43
-
44
- if (typeof options === 'function') {
45
- options = await options.call(this, this.value, this.column, this.record, this.row, this.field)
46
- }
47
-
48
- const { name, help, objectified = false, attributeSet } = options
49
-
50
- const confirmCallback = (newval: any) => {
51
- this.dispatchEvent(
52
- new CustomEvent('field-change', {
53
- bubbles: true,
54
- composed: true,
55
- detail: {
56
- before: this.value,
57
- after: !objectified ? JSON.stringify(newval) : newval,
58
- record: this.record,
59
- column: this.column,
60
- row: this.row
61
- }
62
- })
63
- )
64
- }
65
-
66
- try {
67
- var value: any =
68
- !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {})
69
- } catch (e) {
70
- var value: any = {}
71
- }
72
-
73
- /*
74
- 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
75
- layout의 구성에 변화가 발생하면, 다시 render된다.
76
- 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
77
- 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
78
- 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
79
- 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
80
- */
81
- var template = html`
82
- <ox-popup-attributes .value=${value} .attributeSet=${attributeSet} .confirmCallback=${confirmCallback}>
83
- </ox-popup-attributes>
84
- `
85
-
86
- this.popup = openPopup(template, {
87
- backdrop: true,
88
- size: 'large',
89
- title: `${name?.toUpperCase() || ''} ${i18next.t('field.attributes')}`,
90
- help
91
- })
92
- }
93
- }
@@ -1,93 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '../ox-attribute-form.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
- import { AttributeSet } from '../types.js'
12
-
13
- @customElement('ox-popup-attributes')
14
- export class OxPopupAttributes 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-attribute-form {
30
- flex: 1;
31
- overflow-y: auto;
32
- padding: var(--spacing-large);
33
- }
34
-
35
- span {
36
- flex: 1;
37
-
38
- display: flex;
39
- align-items: center;
40
- justify-content: center;
41
-
42
- color: var(--md-sys-color-on-primary-container);
43
- }
44
- `
45
- ]
46
-
47
- @property({ type: Object }) value: any
48
- @property({ type: Object }) attributeSet?: AttributeSet
49
- @property({ type: Object }) confirmCallback!: (newval: any) => void
50
-
51
- render() {
52
- var attributeSet = this.attributeSet || {}
53
-
54
- return html`
55
- <ox-attribute-form .value=${this.value} .attributeSet=${attributeSet} @change=${this.onChange.bind(this)}>
56
- </ox-attribute-form>
57
-
58
- <div class="footer">
59
- <div filler></div>
60
- <button @click=${this.onCancel.bind(this)} danger>
61
- <md-icon>cancel</md-icon>${i18next.t('button.cancel')}
62
- </button>
63
- <button @click=${this.onConfirm.bind(this)} done><md-icon>done</md-icon>${i18next.t('button.confirm')}</button>
64
- </div>
65
- `
66
- }
67
-
68
- private onChange(e: CustomEvent) {
69
- e.stopPropagation()
70
-
71
- /*
72
- 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
73
- layout의 구성에 변화가 발생하면, 다시 render된다.
74
- 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
75
- 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
76
- 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
77
- 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
78
- (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
79
- =>
80
- 이런 이유로, Object.assign(...)을 사용하였다.
81
- */
82
- this.value = e.detail
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 +0,0 @@
1
- export * from './types.js'
@@ -1,216 +0,0 @@
1
- import '@operato/input/ox-input-file.js'
2
-
3
- import { css, html, LitElement } from 'lit'
4
- import { customElement, property } from 'lit/decorators.js'
5
-
6
- import { AttributeSet } from './types.js'
7
-
8
- @customElement('ox-attribute-form')
9
- export class OxAttributeForm extends LitElement {
10
- static styles = css`
11
- :host {
12
- display: flex;
13
- flex-direction: row;
14
- --item-description-font: normal 0.8rem/1rem var(--theme-font);
15
- --item-description-color: var(--page-description-color);
16
- }
17
-
18
- h2 {
19
- margin: var(--title-margin);
20
- font: var(--title-font);
21
- color: var(--title-text-color);
22
- text-transform: capitalize;
23
- text-align: center;
24
- }
25
-
26
- h3 {
27
- margin: var(--page-description-margin);
28
- font: var(--page-description-font);
29
- color: var(--page-description-color);
30
- text-transform: capitalize;
31
- text-align: center;
32
- }
33
-
34
- form {
35
- flex: 1;
36
-
37
- display: flex;
38
- flex-direction: column;
39
- }
40
-
41
- label {
42
- display: grid;
43
-
44
- grid-template-rows: auto 1fr;
45
- grid-template-columns: 1fr 5fr;
46
- grid-template-areas: 'name description' 'empty inputs';
47
-
48
- grid-gap: 9px;
49
- align-items: center;
50
- margin-bottom: var(--spacing-medium);
51
- }
52
-
53
- label:nth-child(odd) {
54
- background-color: var(--md-sys-color-background);
55
- padding: var(--padding-default) 0;
56
- }
57
-
58
- div[name] {
59
- grid-area: name;
60
- font: var(--label-font);
61
- color: var(--label-color, var(--md-sys-color-on-surface));
62
- text-align: right;
63
- }
64
-
65
- div[description] {
66
- grid-area: description;
67
- opacity: 0.7;
68
- font: var(--item-description-font);
69
- color: var(--item-description-color);
70
- text-align: left;
71
- }
72
-
73
- div[description] * {
74
- vertical-align: middle;
75
- }
76
-
77
- div[description] md-icon {
78
- font-size: 0.9rem;
79
- }
80
-
81
- div[elements] {
82
- grid-area: inputs;
83
- display: flex;
84
- flex-direction: row;
85
- flex-wrap: wrap;
86
- gap: 10px;
87
- padding-right: var(--padding-default);
88
- }
89
-
90
- div[elements] * {
91
- flex: 1;
92
- }
93
-
94
- div[elements] input,
95
- div[elements] select {
96
- border: var(--input-field-border);
97
- border-radius: var(--input-field-border-radius);
98
- padding: var(--input-field-padding);
99
- font: var(--input-field-font);
100
- }
101
-
102
- @media only screen and (max-width: 460px) {
103
- label {
104
- display: grid;
105
-
106
- grid-template-rows: auto auto 1fr;
107
- grid-template-columns: 1fr;
108
- grid-template-areas: 'name' 'description' 'inputs';
109
-
110
- grid-gap: 9px;
111
- align-items: center;
112
- margin-bottom: var(--spacing-medium);
113
- }
114
-
115
- div[name] {
116
- text-align: left;
117
- }
118
- }
119
- `
120
-
121
- @property({ type: Object }) attributeSet?: AttributeSet
122
- @property({ type: Object }) value?: { [tag: string]: any }
123
-
124
- render() {
125
- return html` <form @change=${(e: Event) => this.onChange(e)}>
126
- <h2>${this.attributeSet?.entity || ''}</h2>
127
- <h3>${this.attributeSet?.description || ''}</h3>
128
- ${this.buildInputs()}
129
- </form>`
130
- }
131
-
132
- private onChange(e: Event) {
133
- this.value = this.buildValue()
134
-
135
- this.dispatchEvent(
136
- new CustomEvent('change', {
137
- bubbles: true,
138
- composed: true,
139
- detail: this.value
140
- })
141
- )
142
- }
143
-
144
- private buildInputs() {
145
- const items = (this.attributeSet?.items || []).filter(item => item.active)
146
-
147
- return (items || []).map(item => {
148
- const { name, description, tag, type, options = {} } = item
149
-
150
- const value = this.value && this.value[tag]
151
-
152
- switch (type) {
153
- case 'select':
154
- var element = html` <select .name=${tag}>
155
- <option value=""></option>
156
- ${(options.options || []).map(
157
- option => html`<option value=${option.value} ?selected=${option.value === value}>${option.text}</option>`
158
- )}
159
- </select>`
160
- break
161
-
162
- case 'boolean':
163
- var element = html` <input type="checkbox" name=${tag} .checked=${value} />`
164
- break
165
-
166
- case 'number':
167
- var element = html` <input type="number" name=${tag} value=${value} />`
168
- break
169
-
170
- case 'date':
171
- var element = html` <input type="date" name=${tag} value=${value} />`
172
- break
173
-
174
- case 'datetime':
175
- var element = html` <input type="datetime-local" name=${tag} value=${value} />`
176
- break
177
-
178
- case 'file':
179
- var element = html`<ox-input-file
180
- name=${tag}
181
- label="Attach Files"
182
- accept="*/*"
183
- multiple="true"
184
- hide-filelist
185
- ></ox-input-file>`
186
-
187
- case 'string':
188
- default:
189
- var element = html` <input type="text" name=${tag} value=${value} />`
190
- }
191
-
192
- return html` <label .title=${description}>
193
- <div name>${name}</div>
194
- <div description><md-icon>info</md-icon> ${description}</div>
195
- <div elements>${element}</div>
196
- </label>`
197
- })
198
- }
199
-
200
- private buildValue() {
201
- const items = this.attributeSet!.items
202
-
203
- return (items || []).reduce(
204
- (sum, item) => {
205
- const { tag, type } = item
206
-
207
- const editor = this.renderRoot.querySelector(`[name=${tag}]`) as HTMLInputElement
208
-
209
- sum[tag] = type === 'boolean' ? editor.checked : editor.value
210
-
211
- return sum
212
- },
213
- {} as { [tag: string]: any }
214
- )
215
- }
216
- }
@@ -1,188 +0,0 @@
1
- import '@operato/input/ox-input-file.js'
2
-
3
- import { css, html, LitElement } from 'lit'
4
- import { customElement, property } from 'lit/decorators.js'
5
- import { ScrollbarStyles } from '@operato/styles'
6
-
7
- import { AttributeSet } from './types.js'
8
-
9
- @customElement('ox-attribute-view')
10
- export class OxAttributeView extends LitElement {
11
- static styles = [
12
- ScrollbarStyles,
13
- css`
14
- :host {
15
- display: flex;
16
- flex-direction: row;
17
-
18
- --item-description-font: normal 0.8rem/1rem var(--theme-font);
19
- --item-description-color: var(--page-description-color);
20
- }
21
-
22
- h2 {
23
- margin: var(--title-margin);
24
- font: var(--title-font);
25
- color: var(--title-text-color);
26
- text-transform: capitalize;
27
- text-align: center;
28
- }
29
-
30
- h3 {
31
- margin: var(--page-description-margin);
32
- font: var(--page-description-font);
33
- color: var(--page-description-color);
34
- text-transform: capitalize;
35
- text-align: center;
36
- }
37
-
38
- form {
39
- flex: 1;
40
-
41
- display: flex;
42
- flex-direction: column;
43
-
44
- overflow-y: auto;
45
- padding: var(--padding-default);
46
- }
47
-
48
- label {
49
- display: grid;
50
-
51
- grid-template-rows: auto 1fr;
52
- grid-template-columns: 1fr 5fr;
53
- grid-template-areas: 'name description' 'empty inputs';
54
-
55
- grid-gap: 9px;
56
- align-items: center;
57
- margin-bottom: var(--spacing-medium);
58
- }
59
-
60
- label:nth-child(odd) {
61
- background-color: var(--md-sys-color-background);
62
- padding: var(--padding-default) 0;
63
- }
64
-
65
- div[name] {
66
- grid-area: name;
67
- font: var(--label-font);
68
- color: var(--label-color, var(--md-sys-color-on-surface));
69
- text-align: right;
70
- }
71
-
72
- div[description] {
73
- grid-area: description;
74
- opacity: 0.7;
75
- font: var(--item-description-font);
76
- color: var(--item-description-color);
77
- text-align: left;
78
- }
79
-
80
- div[description] * {
81
- vertical-align: middle;
82
- }
83
-
84
- div[description] md-icon {
85
- font-size: 0.9rem;
86
- }
87
-
88
- div[elements] {
89
- grid-area: inputs;
90
- display: flex;
91
- flex-direction: row;
92
- flex-wrap: wrap;
93
- gap: 10px;
94
- padding-right: var(--padding-default);
95
- }
96
-
97
- div[elements] * {
98
- flex: 1;
99
- }
100
-
101
- div[elements] input,
102
- div[elements] select {
103
- border: var(--input-field-border);
104
- border-radius: var(--input-field-border-radius);
105
- padding: var(--input-field-padding);
106
- font: var(--input-field-font);
107
- }
108
-
109
- @media only screen and (max-width: 460px) {
110
- label {
111
- display: grid;
112
-
113
- grid-template-rows: auto auto 1fr;
114
- grid-template-columns: 1fr;
115
- grid-template-areas: 'name' 'description' 'inputs';
116
-
117
- grid-gap: 9px;
118
- align-items: center;
119
- margin-bottom: var(--spacing-medium);
120
- }
121
-
122
- div[name] {
123
- text-align: left;
124
- }
125
- }
126
- `
127
- ]
128
-
129
- @property({ type: Object }) attributeSet?: AttributeSet
130
- @property({ type: Object }) value?: { [tag: string]: any }
131
-
132
- render() {
133
- return html`<form>
134
- <h2>${this.attributeSet?.entity || ''}</h2>
135
- <h3>${this.attributeSet?.description || ''}</h3>
136
- ${this.buildEntryViews()}
137
- </form> `
138
- }
139
-
140
- private buildEntryViews() {
141
- const items = (this.attributeSet?.items || []).filter(item => item.active)
142
-
143
- return (items || []).map(item => {
144
- const { name, description, tag, type, options = {} } = item
145
-
146
- const value = this.value && this.value[tag]
147
-
148
- switch (type) {
149
- case 'select':
150
- var element = html` <select .name=${tag} disabled>
151
- <option value=""></option>
152
- ${(options.options || []).map(
153
- option => html`<option value=${option.value} ?selected=${option.value === value}>${option.text}</option>`
154
- )}
155
- </select>`
156
- break
157
-
158
- case 'boolean':
159
- var element = html` <input type="checkbox" name=${tag} .checked=${value} disabled />`
160
- break
161
-
162
- case 'number':
163
- var element = html` <input type="number" name=${tag} value=${value} disabled />`
164
- break
165
-
166
- case 'file':
167
- var element = html`<ox-input-file
168
- name=${tag}
169
- label="Attach Files"
170
- accept="*/*"
171
- multiple="true"
172
- hide-filelist
173
- disabled
174
- ></ox-input-file>`
175
-
176
- case 'string':
177
- default:
178
- var element = html` <input type="text" name=${tag} value=${value} disabled />`
179
- }
180
-
181
- return html` <label .title=${description}>
182
- <div name>${name}</div>
183
- <div description><md-icon>info</md-icon> ${description}</div>
184
- <div elements>${element}</div>
185
- </label>`
186
- })
187
- }
188
- }