@operato/attribute 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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.0.0-beta.2](https://github.com/hatiolab/operato/compare/v8.0.0-beta.1...v8.0.0-beta.2) (2025-01-08)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * typo .npmignore ([d9c0c8c](https://github.com/hatiolab/operato/commit/d9c0c8c79abc688c3c2cfb6c37fcb689483a5977))
12
+
13
+
14
+
15
+ ## [8.0.0-beta.1](https://github.com/hatiolab/operato/compare/v8.0.0-beta.0...v8.0.0-beta.1) (2025-01-08)
16
+
17
+
18
+ ### :bug: Bug Fix
19
+
20
+ * missing .npmignore ([be05985](https://github.com/hatiolab/operato/commit/be05985abfae4af53501f718dd52932099f7fbcb))
21
+
22
+
23
+
6
24
  ## [8.0.0-beta.0](https://github.com/hatiolab/operato/compare/v8.0.0-alpha.56...v8.0.0-beta.0) (2025-01-07)
7
25
 
8
26
  **Note:** Version bump only for package @operato/attribute
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": "8.0.0-beta.0",
5
+ "version": "8.0.0-beta.2",
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": "^8.0.0-beta.0",
62
- "@operato/graphql": "^8.0.0-beta.0",
63
- "@operato/grist-editor": "^8.0.0-beta.0",
64
- "@operato/i18n": "^8.0.0-beta.0",
65
- "@operato/input": "^8.0.0-beta.0",
66
- "@operato/popup": "^8.0.0-beta.0",
67
- "@operato/property-editor": "^8.0.0-beta.0",
68
- "@operato/shell": "^8.0.0-beta.0",
69
- "@operato/styles": "^8.0.0-beta.0",
70
- "@operato/utils": "^8.0.0-beta.0",
61
+ "@operato/data-grist": "^8.0.0-beta.2",
62
+ "@operato/graphql": "^8.0.0-beta.2",
63
+ "@operato/grist-editor": "^8.0.0-beta.2",
64
+ "@operato/i18n": "^8.0.0-beta.2",
65
+ "@operato/input": "^8.0.0-beta.2",
66
+ "@operato/popup": "^8.0.0-beta.2",
67
+ "@operato/property-editor": "^8.0.0-beta.2",
68
+ "@operato/shell": "^8.0.0-beta.2",
69
+ "@operato/styles": "^8.0.0-beta.2",
70
+ "@operato/utils": "^8.0.0-beta.2",
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": "c4e9cc245659d050a9ffd66542083a6daad4bcb9"
105
+ "gitHead": "ee1b5124995accb99272d3b5854f3df1d8746dda"
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
- }
package/src/types.ts DELETED
@@ -1,23 +0,0 @@
1
- export type SelectOption = { text: string; value: string }
2
- export type SelectOptions = SelectOption[]
3
-
4
- export type TypeOptions = {
5
- options?: SelectOptions
6
- [prop: string]: any
7
- }
8
-
9
- export type AttributeItem = {
10
- name: string
11
- description: string
12
- tag: string
13
- type: string
14
- active: boolean
15
- hidden: boolean
16
- options: TypeOptions
17
- }
18
-
19
- export type AttributeSet = {
20
- entity: string
21
- description: string
22
- items: AttributeItem[]
23
- }
@@ -1,105 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/i18n'
3
- import '../src/ox-attribute-form.js'
4
-
5
- import { html, TemplateResult } from 'lit'
6
-
7
- export default {
8
- title: 'ox-attribute-form',
9
- component: 'ox-attribute-form',
10
- argTypes: {}
11
- }
12
-
13
- interface Story<T> {
14
- (args: T): TemplateResult
15
- args?: Partial<T>
16
- argTypes?: Record<string, unknown>
17
- }
18
-
19
- interface ArgTypes {}
20
-
21
- const attributeSet = {
22
- entity: 'Domain',
23
- description: 'Attributes for Domain Entity',
24
- items: [
25
- {
26
- name: '등록정보',
27
- description: '회사 등록 정보',
28
- tag: 'brn',
29
- type: 'text',
30
- active: true,
31
- hidden: false
32
- },
33
- {
34
- name: '주소',
35
- description: '회사 주소',
36
- tag: 'address',
37
- type: 'text',
38
- active: true,
39
- hidden: false
40
- },
41
- {
42
- name: '신용도',
43
- description: '회사의 신용도',
44
- tag: 'credit',
45
- type: 'select',
46
- options: {
47
- options: [
48
- { text: '최우수', value: '최우수' },
49
- { text: '우수', value: '우수' },
50
- { text: '보통', value: '보통' },
51
- { text: '미달', value: '미달' }
52
- ]
53
- },
54
- active: true,
55
- hidden: false
56
- },
57
- {
58
- name: '정보파일',
59
- description: '참조 첨부 파일.',
60
- tag: 'file',
61
- type: 'file',
62
- active: true,
63
- hidden: false
64
- }
65
- ]
66
- }
67
-
68
- var value = {
69
- brn: '1234567890-1234-1',
70
- address: '경기도 성남시 분당구.',
71
- credit: '최우수'
72
- }
73
-
74
- const Template: Story<ArgTypes> = ({}: ArgTypes) => html`
75
- <link href="/themes/app-theme.css" rel="stylesheet" />
76
- <link
77
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
78
- rel="stylesheet"
79
- />
80
- <link
81
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
82
- rel="stylesheet"
83
- />
84
- <link
85
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
86
- rel="stylesheet"
87
- />
88
-
89
- <style>
90
- body {
91
- }
92
- </style>
93
-
94
- <ox-attribute-form
95
- .attributeSet=${attributeSet}
96
- .value=${value}
97
- @change=${(e: CustomEvent) => {
98
- value = e.detail
99
- console.log('change', value)
100
- }}
101
- ></ox-attribute-form>
102
- `
103
-
104
- export const Regular = Template.bind({})
105
- Regular.args = {}
@@ -1,98 +0,0 @@
1
- import '@operato/i18n'
2
- import '../src/ox-attribute-view.js'
3
- import '@material/web/icon/icon.js'
4
-
5
- import { html, TemplateResult } from 'lit'
6
-
7
- export default {
8
- title: 'ox-attribute-view',
9
- component: 'ox-attribute-view',
10
- argTypes: {}
11
- }
12
-
13
- interface Story<T> {
14
- (args: T): TemplateResult
15
- args?: Partial<T>
16
- argTypes?: Record<string, unknown>
17
- }
18
-
19
- interface ArgTypes {}
20
-
21
- const attributeSet = {
22
- entity: 'Domain',
23
- description: 'Attributes for Domain Entity',
24
- items: [
25
- {
26
- name: '등록정보',
27
- description: '회사 등록 정보',
28
- tag: 'brn',
29
- type: 'text',
30
- active: true,
31
- hidden: false
32
- },
33
- {
34
- name: '주소',
35
- description: '회사 주소',
36
- tag: 'address',
37
- type: 'text',
38
- active: true,
39
- hidden: false
40
- },
41
- {
42
- name: '신용도',
43
- description: '회사의 신용도',
44
- tag: 'credit',
45
- type: 'select',
46
- options: {
47
- options: [
48
- { text: '최우수', value: '최우수' },
49
- { text: '우수', value: '우수' },
50
- { text: '보통', value: '보통' },
51
- { text: '미달', value: '미달' }
52
- ]
53
- },
54
- active: true,
55
- hidden: false
56
- },
57
- {
58
- name: '정보파일',
59
- description: '참조 첨부 파일.',
60
- tag: 'file',
61
- type: 'file',
62
- active: true,
63
- hidden: false
64
- }
65
- ]
66
- }
67
-
68
- var value = {
69
- brn: '1234567890-1234-1',
70
- address: '경기도 성남시 분당구.',
71
- credit: '최우수'
72
- }
73
-
74
- const Template: Story<ArgTypes> = ({}: ArgTypes) => html`
75
- <link href="/themes/app-theme.css" rel="stylesheet" />
76
- <link
77
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
78
- rel="stylesheet"
79
- />
80
- <link
81
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
82
- rel="stylesheet"
83
- />
84
- <link
85
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
86
- rel="stylesheet"
87
- />
88
-
89
- <style>
90
- body {
91
- }
92
- </style>
93
-
94
- <ox-attribute-view .attributeSet=${attributeSet} .value=${value}></ox-attribute-view>
95
- `
96
-
97
- export const Regular = Template.bind({})
98
- Regular.args = {}
@@ -1,338 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/property-editor/ox-property-editor-checkbox.js'
3
- import '@operato/property-editor/ox-property-editor-number.js'
4
- import '@operato/property-editor/ox-property-editor-string.js'
5
- import '@operato/property-editor/ox-property-editor-options.js'
6
- import '@operato/property-editor/ox-properties-dynamic-view.js'
7
- import '@operato/data-grist/ox-filters-form.js'
8
- import '@operato/data-grist/ox-sorters-control.js'
9
- import '@operato/grist-editor' /* regiester grist editors */
10
- /* set grist-editors */
11
- import '../src/grist-editor/index.js'
12
-
13
- import { css, html, LitElement, TemplateResult } from 'lit'
14
- import { state } from 'lit/decorators.js'
15
-
16
- import { FetchOption, GristRecord } from '@operato/data-grist'
17
- // import { OxGristEditorCrontab } from '@operato/grist-editor/ox-grist-editor-crontab.js'
18
- // import { OxGristEditorParameters } from '@operato/grist-editor/ox-grist-editor-parameters.js'
19
- // import { OxGristEditorPartitionKeys } from '@operato/grist-editor/ox-grist-editor-partition-keys.js'
20
- // // import { OxGristRendererCrontab } from '@operato/grist-editor/ox-grist-renderer-crontab.js'
21
- // import { OxGristEditorValueMap } from '@operato/grist-editor/ox-grist-editor-value-map.js'
22
- import { i18next } from '@operato/i18n'
23
- import { OxPropertyEditor } from '@operato/property-editor'
24
- import { CommonGristStyles } from '@operato/styles'
25
-
26
- OxPropertyEditor.register({
27
- number: 'ox-property-editor-number',
28
- string: 'ox-property-editor-string',
29
- boolean: 'ox-property-editor-checkbox',
30
- options: 'ox-property-editor-options'
31
- })
32
-
33
- // registerEditor('parameters', OxGristEditorParameters)
34
- // registerEditor('crontab', OxGristEditorCrontab)
35
- // registerEditor('value-map', OxGristEditorValueMap)
36
- // registerEditor('partition-keys', OxGristEditorPartitionKeys)
37
-
38
- const fetchHandler = async ({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) => {
39
- var total = 10
40
- var start = (page - 1) * limit
41
-
42
- return {
43
- total,
44
- records: Array(limit * page > total ? total % limit : limit)
45
- .fill('')
46
- .map((item, idx) => {
47
- return {
48
- id: idx,
49
- entity: `entity-${start + idx + 1}`,
50
- description: `description-${start + idx + 1}`,
51
- attributes: {
52
- brn: '1234567890-1234-1',
53
- address: '경기도 성남시 분당구.',
54
- credit: '최우수'
55
- }
56
- }
57
- })
58
- }
59
- }
60
-
61
- class GristDemo extends LitElement {
62
- static styles = [
63
- CommonGristStyles,
64
- css`
65
- :host {
66
- display: flex;
67
- flex-direction: column;
68
- }
69
-
70
- #tailer {
71
- display: flex;
72
- flex-direction: row;
73
- margin: 0 var(--spacing-medium);
74
- }
75
-
76
- #tailer a {
77
- padding: 0 var(--padding-default) 0 var(--padding-default);
78
- margin: 0 var(--spacing-small);
79
- border-right: 1px solid rgba(0, 0, 0, 0.1);
80
- font-size: var(--fontsize-default);
81
- color: var(--md-sys-color-on-primary-container);
82
- }
83
- `
84
- ]
85
-
86
- @state() mode: String = 'CARD'
87
-
88
- get grist() {
89
- return this.renderRoot.querySelector('ox-grist')
90
- }
91
-
92
- config: any = {
93
- list: { fields: ['name', 'description', 'active'] },
94
- columns: [
95
- { type: 'gutter', gutterName: 'row-selector', multiple: true },
96
- {
97
- type: 'gutter',
98
- gutterName: 'button',
99
- icon: 'add',
100
- handlers: {
101
- click: 'record-copy'
102
- }
103
- },
104
- { type: 'gutter', gutterName: 'sequence' },
105
- {
106
- type: 'gutter',
107
- gutterName: 'button',
108
- icon: 'arrow_upward',
109
- handlers: {
110
- click: 'move-up'
111
- }
112
- },
113
- {
114
- type: 'gutter',
115
- gutterName: 'button',
116
- icon: 'arrow_downward',
117
- handlers: {
118
- click: 'move-down'
119
- }
120
- },
121
- {
122
- type: 'string',
123
- name: 'id',
124
- hidden: true
125
- },
126
- {
127
- type: 'string',
128
- name: 'entity',
129
- header: i18next.t('field.entity'),
130
- record: {
131
- editable: true
132
- },
133
- width: 140
134
- },
135
- {
136
- type: 'string',
137
- name: 'description',
138
- header: i18next.t('field.description'),
139
- record: {
140
- editable: true
141
- },
142
- width: 180
143
- },
144
- {
145
- type: 'select',
146
- name: 'type',
147
- header: i18next.t('field.type'),
148
- record: {
149
- options: ['', 'number', 'text', 'select', 'boolean', 'file'],
150
- editable: true
151
- },
152
- width: 120
153
- },
154
- {
155
- type: 'attributes',
156
- name: 'attributes',
157
- header: i18next.t('field.attributes'),
158
- record: {
159
- editable: true,
160
- options: {
161
- attributeSet: {
162
- entity: 'Domain',
163
- description: 'Attributes for Domain Entity',
164
- items: [
165
- {
166
- name: '등록정보',
167
- description: '회사 등록 정보',
168
- tag: 'brn',
169
- type: 'text',
170
- active: true,
171
- hidden: false
172
- },
173
- {
174
- name: '주소',
175
- description: '회사 주소',
176
- tag: 'address',
177
- type: 'text',
178
- active: true,
179
- hidden: false
180
- },
181
- {
182
- name: '신용도',
183
- description: '회사의 신용도',
184
- tag: 'credit',
185
- type: 'select',
186
- options: {
187
- options: [
188
- { text: '최우수', value: '최우수' },
189
- { text: '우수', value: '우수' },
190
- { text: '보통', value: '보통' },
191
- { text: '미달', value: '미달' }
192
- ]
193
- },
194
- active: true,
195
- hidden: false
196
- },
197
- {
198
- name: '정보파일',
199
- description: '참조 첨부 파일.',
200
- tag: 'file',
201
- type: 'file',
202
- active: true,
203
- hidden: false
204
- }
205
- ]
206
- }
207
- }
208
- },
209
- width: 200
210
- }
211
- ],
212
- rows: {
213
- selectable: {
214
- multiple: true
215
- }
216
- },
217
- pagination: {
218
- infinite: true
219
- },
220
- sorters: [
221
- {
222
- name: 'sequence'
223
- }
224
- ]
225
- }
226
-
227
- render() {
228
- const mode = this.mode || 'CARD'
229
-
230
- return html`
231
- <ox-grist .config=${this.config} .mode=${mode} auto-fetch .fetchHandler=${fetchHandler}>
232
- <div id="filters" slot="headroom">
233
- <ox-filters-form @filters-change=${(e: CustomEvent) => console.log('changed', e.detail)}></ox-filters-form>
234
- </div>
235
-
236
- <div slot="headroom" id="headroom">
237
- <div id="modes">
238
- <md-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>view_list</md-icon>
239
- <md-icon @click=${() => (this.mode = 'LIST')} ?active=${mode == 'LIST'}>menu</md-icon>
240
- <md-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</md-icon>
241
- </div>
242
- </div>
243
- </ox-grist>
244
- `
245
- }
246
- }
247
-
248
- customElements.define('ox-attributes', GristDemo)
249
-
250
- export default {
251
- title: 'ox-grist-editor-attributes',
252
- component: 'ox-grist-editor-attributes',
253
- argTypes: {}
254
- }
255
-
256
- interface Story<T> {
257
- (args: T): TemplateResult
258
- args?: Partial<T>
259
- argTypes?: Record<string, unknown>
260
- }
261
-
262
- interface ArgTypes {}
263
-
264
- const Template: Story<ArgTypes> = ({}: ArgTypes) => html`
265
- <link
266
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
267
- rel="stylesheet"
268
- />
269
- <link
270
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
271
- rel="stylesheet"
272
- />
273
- <link
274
- href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
275
- rel="stylesheet"
276
- />
277
-
278
- <link href="/themes/app-theme.css" rel="stylesheet" />
279
- <link href="/themes/oops-theme.css" rel="stylesheet" />
280
- <link href="/themes/grist-theme.css" rel="stylesheet" />
281
-
282
- <style>
283
- [slot='headroom'] {
284
- display: flex;
285
- flex-direction: row;
286
- align-items: center;
287
- padding: var(--padding-default) var(--spacing-large);
288
- background-color: var(--md-sys-color-surface);
289
- box-shadow: var(--box-shadow);
290
-
291
- --md-icon-size: 24px;
292
- }
293
- #sorters md-icon,
294
- #modes md-icon {
295
- --md-icon-size: 18px;
296
- }
297
- #sorters {
298
- margin-left: auto;
299
- margin-right: var(--spacing-medium);
300
- padding-left: var(--spacing-small);
301
- border-bottom: var(--border-dim-color);
302
- position: relative;
303
- color: var(--md-sys-color-on-secondary-container);
304
- font-size: var(--fontsize-default);
305
- user-select: none;
306
- }
307
-
308
- #sorters > * {
309
- padding: var(--spacing-small);
310
- vertical-align: middle;
311
- }
312
-
313
- #filters {
314
- display: flex;
315
- justify-content: center;
316
- align-items: center;
317
- }
318
-
319
- #filters * {
320
- margin-right: var(--spacing-medium);
321
- }
322
-
323
- @media only screen and (max-width: 460px) {
324
- #filters {
325
- flex-direction: column;
326
- }
327
-
328
- #modes {
329
- display: none;
330
- }
331
- }
332
- </style>
333
-
334
- <ox-attributes mode="LIST"></ox-attributes>
335
- `
336
-
337
- export const Regular = Template.bind({})
338
- Regular.args = {}
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
- });