@operato/attribute 8.0.0-alpha.9 → 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.
@@ -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 = {}