@operato/app 1.0.0-alpha.8 → 1.0.0-alpha.9

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
@@ -3,7 +3,7 @@
3
3
  "description": "WebApplication production supporting components following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "heartyoh",
6
- "version": "1.0.0-alpha.8",
6
+ "version": "1.0.0-alpha.9",
7
7
  "main": "dist/src/index.js",
8
8
  "module": "dist/src/index.js",
9
9
  "exports": {
@@ -12,8 +12,12 @@
12
12
  "./grist/id-selector.js": "./dist/src/grist/id-selector.js",
13
13
  "./grist/id-renderer.js": "./dist/src/grist/id-renderer.js",
14
14
  "./grist/object-selector.js": "./dist/src/grist/object-selector.js",
15
- "./grist/object-renderer.js": "./dist/src/grist/object-renderer.js",
16
- "./grist/code-editor.js": "./dist/src/grist/code-editor.js"
15
+ "./grist/object-editor.js": "./dist/src/grist/object-editor.js",
16
+ "./grist/code-editor.js": "./dist/src/grist/code-editor.js",
17
+ "./grist/parameters-editor.js": "./dist/src/grist/parameters-editor.js",
18
+ "./input/ox-input-background-pattern.js": "./dist/src/input/ox-input-background-pattern.js",
19
+ "./input/ox-input-color-gradient.js": "./dist/src/input/ox-input-color-gradient.js",
20
+ "./input/ox-input-fill-style.js": "./dist/src/input/ox-input-fill-style.js"
17
21
  },
18
22
  "publishConfig": {
19
23
  "access": "public",
@@ -40,15 +44,16 @@
40
44
  "@material/mwc-button": "^0.25.3",
41
45
  "@material/mwc-icon": "^0.25.3",
42
46
  "@material/mwc-icon-button": "^0.25.3",
43
- "@operato/data-grist": "^1.0.0-alpha.8",
44
- "@operato/form": "^1.0.0-alpha.8",
45
- "@operato/graphql": "^1.0.0-alpha.8",
46
- "@operato/i18n": "^1.0.0-alpha.8",
47
- "@operato/layout": "^1.0.0-alpha.8",
48
- "@operato/property-editor": "^1.0.0-alpha.8",
49
- "@operato/shell": "^1.0.0-alpha.8",
50
- "@operato/styles": "^1.0.0-alpha.8",
51
- "@operato/utils": "^1.0.0-alpha.8",
47
+ "@operato/attachment": "^1.0.0-alpha.9",
48
+ "@operato/data-grist": "^1.0.0-alpha.9",
49
+ "@operato/form": "^1.0.0-alpha.9",
50
+ "@operato/graphql": "^1.0.0-alpha.9",
51
+ "@operato/i18n": "^1.0.0-alpha.9",
52
+ "@operato/layout": "^1.0.0-alpha.9",
53
+ "@operato/property-editor": "^1.0.0-alpha.9",
54
+ "@operato/shell": "^1.0.0-alpha.9",
55
+ "@operato/styles": "^1.0.0-alpha.9",
56
+ "@operato/utils": "^1.0.0-alpha.9",
52
57
  "lit": "^2.2.0"
53
58
  },
54
59
  "devDependencies": {
@@ -83,5 +88,5 @@
83
88
  "prettier --write"
84
89
  ]
85
90
  },
86
- "gitHead": "b357f261d2d7b3a1c99b6389f8f8330bceeac8c9"
91
+ "gitHead": "fb82c87ab8b869139076c4e74c46309460b67d35"
87
92
  }
@@ -1,5 +1,5 @@
1
1
  import '@material/mwc-icon'
2
- import '../../elements/object-selector'
2
+ import './object-selector.js'
3
3
 
4
4
  import { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'
5
5
  import { LitElement, TemplateResult, css, html } from 'lit'
@@ -0,0 +1,163 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/i18n/ox-i18n.js'
6
+ import '@operato/attachment/ox-attachment-list.js'
7
+
8
+ import { css, html } from 'lit'
9
+ import { customElement, property } from 'lit/decorators.js'
10
+
11
+ import { OxFormField } from '@operato/input'
12
+
13
+ export type BackgroundPatternOption = {
14
+ image?: HTMLImageElement | string
15
+ align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
16
+ offsetX?: number
17
+ offsetY?: number
18
+ width?: number
19
+ height?: number
20
+ fitPattern?: boolean
21
+ }
22
+
23
+ /**
24
+ * 컴포넌트의 fill pattern을 편집하는 element
25
+ *
26
+ * Example:
27
+ * <ox-input-background-pattern
28
+ * @change="${e => { this.pattern = e.target.value }}"
29
+ * .value=${this.pattern}"
30
+ * ></ox-input-background-pattern>
31
+ */
32
+
33
+ @customElement('ox-input-background-pattern')
34
+ export class OxInputBackgroundPattern extends OxFormField {
35
+ static styles = css`
36
+ :host,
37
+ .grid-10 {
38
+ display: grid;
39
+ grid-template-columns: repeat(10, 1fr);
40
+ grid-gap: 5px;
41
+ grid-auto-rows: minmax(24px, auto);
42
+
43
+ align-items: center;
44
+ }
45
+
46
+ * {
47
+ align-self: stretch;
48
+ }
49
+
50
+ label {
51
+ grid-column: span 2;
52
+ text-align: right;
53
+ text-transform: capitalize;
54
+
55
+ align-self: center;
56
+ }
57
+
58
+ .grid-10 {
59
+ grid-column: span 10;
60
+ }
61
+
62
+ select,
63
+ input,
64
+ [custom-editor] {
65
+ grid-column: span 8;
66
+ }
67
+
68
+ select {
69
+ height: 100%;
70
+ border: 1px solid rgba(0, 0, 0, 0.2);
71
+ }
72
+
73
+ input[type='checkbox'] {
74
+ grid-column: 3 / 4;
75
+ align-self: center;
76
+ }
77
+
78
+ input[type='checkbox'] ~ label {
79
+ grid-column: span 7;
80
+ text-align: left;
81
+ }
82
+
83
+ .grid-10 > input[type='number'] {
84
+ grid-column: span 3;
85
+ border: 1px solid rgba(0, 0, 0, 0.2);
86
+ }
87
+
88
+ .grid-10 > label {
89
+ grid-column: span 2;
90
+ text-align: right;
91
+ }
92
+ `
93
+
94
+ @property({ type: Object }) value?: BackgroundPatternOption
95
+
96
+ render() {
97
+ const value = this.value || ({} as BackgroundPatternOption)
98
+
99
+ return html`
100
+ <label> <ox-i18n msgid="label.image" auto="">image</ox-i18n> </label>
101
+
102
+ <ox-property-editor-attachment-selector
103
+ value-key="image"
104
+ .value=${value.image || ''}
105
+ custom-editor
106
+ ></ox-property-editor-attachment-selector>
107
+
108
+ <label> <ox-i18n msgid="label.align" auto="">align</ox-i18n> </label>
109
+
110
+ <select value-key="align" class="select-content" .value=${value.align}>
111
+ <option value="left-top">Left Top</option>
112
+ <option value="top">Top</option>
113
+ <option value="right-top">Right Top</option>
114
+ <option value="left">Left</option>
115
+ <option value="center">Center</option>
116
+ <option value="right">Right</option>
117
+ <option value="left-bottom">Left Bottom</option>
118
+ <option value="bottom">Bottom</option>
119
+ <option value="right-bottom">Right Bottom</option>
120
+ </select>
121
+
122
+ <div class="grid-10">
123
+ <label> <ox-i18n msgid="label.offset-x" auto="">offsetX</ox-i18n> </label>
124
+ <input type="number" value-key="offsetX" .value=${value.offsetX} />
125
+
126
+ <label> <ox-i18n msgid="label.offset-y" auto="">offsetY</ox-i18n> </label>
127
+ <input type="number" value-key="offsetY" .value=${value.offsetY} />
128
+
129
+ <label> <ox-i18n msgid="label.width" auto="">width</ox-i18n> </label>
130
+ <input type="number" value-key="width" .value=${value.width} />
131
+
132
+ <label> <ox-i18n msgid="label.height" auto="">height</ox-i18n> </label>
133
+ <input type="number" value-key="height" .value=${value.height} />
134
+ </div>
135
+
136
+ <div class="grid-10">
137
+ <input value-key="fitPattern" type="checkbox" .checked=${value.fitPattern} required />
138
+ <label> <ox-i18n msgid="label.fit" auto="">Fit</ox-i18n> </label>
139
+ </div>
140
+ `
141
+ }
142
+
143
+ firstUpdated() {
144
+ this.renderRoot.addEventListener('change', this._onChange.bind(this))
145
+ }
146
+
147
+ _onChange(e: Event) {
148
+ var element = e.target as HTMLInputElement
149
+ var key = element.getAttribute('value-key')
150
+ var value: any = element.value
151
+
152
+ if (key == 'fitPattern') {
153
+ value = element.checked
154
+ }
155
+
156
+ this.value = {
157
+ ...this.value,
158
+ [key!]: value
159
+ }
160
+
161
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
162
+ }
163
+ }
@@ -0,0 +1,341 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/i18n/ox-i18n.js'
6
+ import '@polymer/paper-dropdown-menu/paper-dropdown-menu'
7
+ import '@polymer/paper-listbox/paper-listbox'
8
+ import '@polymer/paper-item/paper-item'
9
+ import '@operato/input/ox-input-angle.js'
10
+ import '@operato/input/ox-input-color-stops.js'
11
+
12
+ import { ColorStop, OxFormField } from '@operato/input'
13
+ import { css, html } from 'lit'
14
+ import { customElement, property } from 'lit/decorators.js'
15
+
16
+ export type GradientOption = {
17
+ type: 'linear' | 'radial'
18
+ rotation: number
19
+ direction?:
20
+ | 'left-to-right'
21
+ | 'lefttop-to-rightbottom'
22
+ | 'top-to-bottom'
23
+ | 'righttop-to-leftbottom'
24
+ | 'right-to-left'
25
+ | 'rightbottom-to-lefttop'
26
+ | 'bottom-to-top'
27
+ | 'leftbottom-to-righttop'
28
+ | 'left-to-right'
29
+ | 'center-to-corner'
30
+ center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'
31
+ colorStops?: ColorStop[]
32
+ }
33
+
34
+ @customElement('ox-input-color-gradient')
35
+ export class OxInputColorGradient extends OxFormField {
36
+ static styles = css`
37
+ :host {
38
+ display: grid;
39
+
40
+ grid-template-columns: repeat(10, 1fr);
41
+ grid-gap: 5px;
42
+ grid-auto-rows: minmax(24px, auto);
43
+
44
+ align-items: center;
45
+ }
46
+
47
+ :host > * {
48
+ align-self: stretch;
49
+ }
50
+
51
+ :host > label {
52
+ grid-column: span 2;
53
+ text-align: right;
54
+ text-transform: capitalize;
55
+ align-self: center;
56
+ }
57
+
58
+ :host > .icon-only-label {
59
+ grid-column: span 1;
60
+ }
61
+
62
+ :host > input,
63
+ :host > [editors] {
64
+ grid-column: span 8;
65
+ }
66
+
67
+ :host > select {
68
+ grid-column: span 4;
69
+ height: 100%;
70
+ border: 1px solid rgba(0, 0, 0, 0.2);
71
+ }
72
+
73
+ :host > ox-input-angle {
74
+ grid-column: span 3;
75
+ }
76
+
77
+ ox-input-color-stops {
78
+ grid-column: span 10;
79
+ }
80
+
81
+ .host > input[type='checkbox'] {
82
+ grid-column: 3 / 4;
83
+ }
84
+
85
+ .host > input[type='checkbox'] ~ label {
86
+ grid-column: span 7;
87
+ text-align: left;
88
+ }
89
+
90
+ [editors] > :not([active-selector]) {
91
+ display: none;
92
+ }
93
+
94
+ [gradient-direction] {
95
+ overflow: hidden;
96
+ max-width: 210px;
97
+ }
98
+
99
+ [gradient-direction] paper-item {
100
+ background: url(/assets/images/icon-editor-gradient-direction.png) 50% 0 no-repeat;
101
+ min-height: 32px;
102
+ padding: 3px 5px;
103
+ width: 30px;
104
+ float: left;
105
+ }
106
+
107
+ [gradient-direction] [name='lefttop-to-rightbottom'] {
108
+ background-position: 50% 4px;
109
+ }
110
+
111
+ [gradient-direction] [name='left-top'] {
112
+ background-position: 50% 4px;
113
+ }
114
+
115
+ [gradient-direction] [name='top-to-bottom'] {
116
+ background-position: 50% -46px;
117
+ }
118
+
119
+ [gradient-direction] [name='righttop-to-leftbottom'] {
120
+ background-position: 50% -96px;
121
+ }
122
+
123
+ [gradient-direction] [name='right-top'] {
124
+ background-position: 50% -96px;
125
+ }
126
+
127
+ [gradient-direction] [name='right-to-left'] {
128
+ background-position: 50% -146px;
129
+ }
130
+
131
+ [gradient-direction] [name='rightbottom-to-lefttop'] {
132
+ background-position: 50% -196px;
133
+ }
134
+
135
+ [gradient-direction] [name='right-bottom'] {
136
+ background-position: 50% -196px;
137
+ }
138
+
139
+ [gradient-direction] [name='bottom-to-top'] {
140
+ background-position: 50% -246px;
141
+ }
142
+
143
+ [gradient-direction] [name='leftbottom-to-righttop'] {
144
+ background-position: 50% -296px;
145
+ }
146
+
147
+ [gradient-direction] [name='left-bottom'] {
148
+ background-position: 50% -296px;
149
+ }
150
+
151
+ [gradient-direction] [name='left-to-right'] {
152
+ background-position: 50% -346px;
153
+ }
154
+
155
+ [gradient-direction] [name='center-to-corner'] {
156
+ background-position: 50% -396px;
157
+ }
158
+
159
+ [gradient-direction] [name='center'] {
160
+ background-position: 50% -396px;
161
+ }
162
+
163
+ [gradient-direction] paper-item[focused] {
164
+ background-color: rgba(255, 246, 143, 0.5);
165
+ }
166
+
167
+ .icon-only-label {
168
+ top: 0 !important;
169
+ width: 30px !important;
170
+ height: 24px;
171
+ background: url(/assets/images/icon-properties-label.png) no-repeat;
172
+ }
173
+
174
+ .icon-only-label.color {
175
+ background-position: 70% -198px;
176
+ }
177
+ `
178
+
179
+ @property({ type: Object }) value: GradientOption = {
180
+ type: 'linear',
181
+ direction: 'left-to-right',
182
+ rotation: 0
183
+ }
184
+
185
+ firstUpdated() {
186
+ this.renderRoot.addEventListener('change', this._onChange.bind(this))
187
+ }
188
+
189
+ _onChange(e: Event) {
190
+ var element = e.target as HTMLElement & { type: string }
191
+ var key = element.getAttribute('value-key')
192
+
193
+ if (!key) {
194
+ return
195
+ }
196
+
197
+ var value
198
+
199
+ switch (element.tagName) {
200
+ case 'INPUT':
201
+ switch (element.type) {
202
+ case 'checkbox':
203
+ value = (element as HTMLInputElement).checked
204
+ break
205
+ case 'number':
206
+ value = Number((element as HTMLInputElement).value) || 0
207
+ break
208
+ case 'text':
209
+ value = String((element as HTMLInputElement).value)
210
+ }
211
+ break
212
+
213
+ case 'PAPER-BUTTON':
214
+ value = (element as any).active
215
+ break
216
+
217
+ case 'PAPER-LISTBOX':
218
+ value = (element as any).selected
219
+ break
220
+
221
+ default:
222
+ value = (element as HTMLInputElement).value
223
+ break
224
+ }
225
+
226
+ if (key === 'rotation') {
227
+ this.value = {
228
+ ...this.value,
229
+ rotation: value,
230
+ direction: undefined
231
+ }
232
+ } else if (key === 'direction') {
233
+ if (value) {
234
+ this.value = {
235
+ ...this.value,
236
+ direction: value,
237
+ rotation: this._convertDirectionToRotation(value)
238
+ }
239
+ }
240
+ } else {
241
+ this.value = {
242
+ ...this.value,
243
+ [key]: value
244
+ }
245
+ }
246
+
247
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
248
+ }
249
+
250
+ render() {
251
+ var selector = (this.value && this.value.type) || 'linear'
252
+ var value = this.value || {}
253
+
254
+ return html`
255
+ <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
256
+ <select value-key="type" .value=${value.type || 'linear'}>
257
+ <option>linear</option>
258
+ <option>radial</option>
259
+ </select>
260
+
261
+ <label class="icon-only-label color"></label>
262
+ <ox-input-angle value-key="rotation" .value=${value.rotation || 0}> </ox-input-angle>
263
+
264
+ <label> <ox-i18n msgid="label.direction">direction</ox-i18n> </label>
265
+ <div editors>
266
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'linear'} .value=${value.direction}>
267
+ <paper-listbox
268
+ @selected-changed=${(e: Event) => this._onChange(e)}
269
+ value-key="direction"
270
+ slot="dropdown-content"
271
+ gradient-direction
272
+ .selected=${value.direction}
273
+ attr-for-selected="name"
274
+ >
275
+ <paper-item name="lefttop-to-rightbottom"></paper-item>
276
+ <paper-item name="top-to-bottom"></paper-item>
277
+ <paper-item name="righttop-to-leftbottom"></paper-item>
278
+ <paper-item name="right-to-left"></paper-item>
279
+ <paper-item name="rightbottom-to-lefttop"></paper-item>
280
+ <paper-item name="bottom-to-top"></paper-item>
281
+ <paper-item name="leftbottom-to-righttop"></paper-item>
282
+ <paper-item name="left-to-right"></paper-item>
283
+ <paper-item name="center-to-corner"></paper-item>
284
+ </paper-listbox>
285
+ </paper-dropdown-menu>
286
+
287
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'radial'} .value=${value.center}>
288
+ <paper-listbox
289
+ @selected-changed=${(e: Event) => this._onChange(e)}
290
+ value-key="center"
291
+ slot="dropdown-content"
292
+ gradient-direction
293
+ .selected=${value.center || 'center'}
294
+ attr-for-selected="name"
295
+ >
296
+ <paper-item name="center"></paper-item>
297
+ <paper-item name="left-top"></paper-item>
298
+ <paper-item name="right-top"></paper-item>
299
+ <paper-item name="right-bottom"></paper-item>
300
+ <paper-item name="left-bottom"></paper-item>
301
+ </paper-listbox>
302
+ </paper-dropdown-menu>
303
+ </div>
304
+
305
+ <ox-input-color-stops value-key="colorStops" type="gradient" .value=${value.colorStops}> </ox-input-color-stops>
306
+ `
307
+ }
308
+
309
+ _convertDirectionToRotation(direction: string): number {
310
+ var rotation
311
+ switch (direction) {
312
+ case 'lefttop-to-rightbottom':
313
+ rotation = 45
314
+ break
315
+ case 'top-to-bottom':
316
+ rotation = 90
317
+ break
318
+ case 'righttop-to-leftbottom':
319
+ rotation = 135
320
+ break
321
+ case 'right-to-left':
322
+ rotation = 180
323
+ break
324
+ case 'rightbottom-to-lefttop':
325
+ rotation = 215
326
+ break
327
+ case 'bottom-to-top':
328
+ rotation = 270
329
+ break
330
+ case 'leftbottom-to-righttop':
331
+ rotation = 315
332
+ break
333
+ case 'left-to-right':
334
+ default:
335
+ rotation = 0
336
+ break
337
+ }
338
+
339
+ return (rotation / 360) * Math.PI * 2
340
+ }
341
+ }