@operato/app 0.4.2 → 1.0.0-alpha.10

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 +96 -0
  2. package/demo/data-grist-test.html +456 -0
  3. package/dist/src/grist/code-editor.d.ts +6 -0
  4. package/dist/src/grist/code-editor.js +50 -0
  5. package/dist/src/grist/code-editor.js.map +1 -0
  6. package/dist/src/grist/id-selector.js +1 -1
  7. package/dist/src/grist/id-selector.js.map +1 -1
  8. package/dist/src/grist/index.js +4 -0
  9. package/dist/src/grist/index.js.map +1 -1
  10. package/dist/src/grist/object-editor.d.ts +18 -0
  11. package/dist/src/grist/object-editor.js +152 -0
  12. package/dist/src/grist/object-editor.js.map +1 -0
  13. package/dist/src/grist/object-selector.d.ts +38 -0
  14. package/dist/src/grist/object-selector.js +338 -0
  15. package/dist/src/grist/object-selector.js.map +1 -0
  16. package/dist/src/grist/parameters-editor-builder.d.ts +4 -0
  17. package/dist/src/grist/parameters-editor-builder.js +119 -0
  18. package/dist/src/grist/parameters-editor-builder.js.map +1 -0
  19. package/dist/src/grist/parameters-editor-popup.d.ts +13 -0
  20. package/dist/src/grist/parameters-editor-popup.js +111 -0
  21. package/dist/src/grist/parameters-editor-popup.js.map +1 -0
  22. package/dist/src/grist/parameters-editor.d.ts +19 -0
  23. package/dist/src/grist/parameters-editor.js +105 -0
  24. package/dist/src/grist/parameters-editor.js.map +1 -0
  25. package/dist/src/input/ox-input-background-pattern.d.ts +31 -0
  26. package/dist/src/input/ox-input-background-pattern.js +147 -0
  27. package/dist/src/input/ox-input-background-pattern.js.map +1 -0
  28. package/dist/src/input/ox-input-color-gradient.d.ts +25 -0
  29. package/dist/src/input/ox-input-color-gradient.js +318 -0
  30. package/dist/src/input/ox-input-color-gradient.js.map +1 -0
  31. package/dist/src/input/ox-input-fill-style.d.ts +42 -0
  32. package/dist/src/input/ox-input-fill-style.js +325 -0
  33. package/dist/src/input/ox-input-fill-style.js.map +1 -0
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/package.json +22 -11
  36. package/src/grist/code-editor.ts +78 -0
  37. package/src/grist/id-selector.ts +2 -10
  38. package/src/grist/index.ts +4 -0
  39. package/src/grist/object-editor.ts +154 -0
  40. package/src/grist/object-selector.ts +346 -0
  41. package/src/grist/parameters-editor-builder.ts +130 -0
  42. package/src/grist/parameters-editor-popup.ts +106 -0
  43. package/src/grist/parameters-editor.ts +112 -0
  44. package/src/input/ox-input-background-pattern.ts +163 -0
  45. package/src/input/ox-input-color-gradient.ts +341 -0
  46. package/src/input/ox-input-fill-style.ts +360 -0
@@ -0,0 +1,318 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
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
+ import { OxFormField } from '@operato/input';
12
+ import { css, html } from 'lit';
13
+ import { customElement, property } from 'lit/decorators.js';
14
+ let OxInputColorGradient = class OxInputColorGradient extends OxFormField {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.value = {
18
+ type: 'linear',
19
+ direction: 'left-to-right',
20
+ rotation: 0
21
+ };
22
+ }
23
+ firstUpdated() {
24
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
25
+ }
26
+ _onChange(e) {
27
+ var element = e.target;
28
+ var key = element.getAttribute('value-key');
29
+ if (!key) {
30
+ return;
31
+ }
32
+ var value;
33
+ switch (element.tagName) {
34
+ case 'INPUT':
35
+ switch (element.type) {
36
+ case 'checkbox':
37
+ value = element.checked;
38
+ break;
39
+ case 'number':
40
+ value = Number(element.value) || 0;
41
+ break;
42
+ case 'text':
43
+ value = String(element.value);
44
+ }
45
+ break;
46
+ case 'PAPER-BUTTON':
47
+ value = element.active;
48
+ break;
49
+ case 'PAPER-LISTBOX':
50
+ value = element.selected;
51
+ break;
52
+ default:
53
+ value = element.value;
54
+ break;
55
+ }
56
+ if (key === 'rotation') {
57
+ this.value = {
58
+ ...this.value,
59
+ rotation: value,
60
+ direction: undefined
61
+ };
62
+ }
63
+ else if (key === 'direction') {
64
+ if (value) {
65
+ this.value = {
66
+ ...this.value,
67
+ direction: value,
68
+ rotation: this._convertDirectionToRotation(value)
69
+ };
70
+ }
71
+ }
72
+ else {
73
+ this.value = {
74
+ ...this.value,
75
+ [key]: value
76
+ };
77
+ }
78
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
79
+ }
80
+ render() {
81
+ var selector = (this.value && this.value.type) || 'linear';
82
+ var value = this.value || {};
83
+ return html `
84
+ <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
85
+ <select value-key="type" .value=${value.type || 'linear'}>
86
+ <option>linear</option>
87
+ <option>radial</option>
88
+ </select>
89
+
90
+ <label class="icon-only-label color"></label>
91
+ <ox-input-angle value-key="rotation" .value=${value.rotation || 0}> </ox-input-angle>
92
+
93
+ <label> <ox-i18n msgid="label.direction">direction</ox-i18n> </label>
94
+ <div editors>
95
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'linear'} .value=${value.direction}>
96
+ <paper-listbox
97
+ @selected-changed=${(e) => this._onChange(e)}
98
+ value-key="direction"
99
+ slot="dropdown-content"
100
+ gradient-direction
101
+ .selected=${value.direction}
102
+ attr-for-selected="name"
103
+ >
104
+ <paper-item name="lefttop-to-rightbottom"></paper-item>
105
+ <paper-item name="top-to-bottom"></paper-item>
106
+ <paper-item name="righttop-to-leftbottom"></paper-item>
107
+ <paper-item name="right-to-left"></paper-item>
108
+ <paper-item name="rightbottom-to-lefttop"></paper-item>
109
+ <paper-item name="bottom-to-top"></paper-item>
110
+ <paper-item name="leftbottom-to-righttop"></paper-item>
111
+ <paper-item name="left-to-right"></paper-item>
112
+ <paper-item name="center-to-corner"></paper-item>
113
+ </paper-listbox>
114
+ </paper-dropdown-menu>
115
+
116
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'radial'} .value=${value.center}>
117
+ <paper-listbox
118
+ @selected-changed=${(e) => this._onChange(e)}
119
+ value-key="center"
120
+ slot="dropdown-content"
121
+ gradient-direction
122
+ .selected=${value.center || 'center'}
123
+ attr-for-selected="name"
124
+ >
125
+ <paper-item name="center"></paper-item>
126
+ <paper-item name="left-top"></paper-item>
127
+ <paper-item name="right-top"></paper-item>
128
+ <paper-item name="right-bottom"></paper-item>
129
+ <paper-item name="left-bottom"></paper-item>
130
+ </paper-listbox>
131
+ </paper-dropdown-menu>
132
+ </div>
133
+
134
+ <ox-input-color-stops value-key="colorStops" type="gradient" .value=${value.colorStops}> </ox-input-color-stops>
135
+ `;
136
+ }
137
+ _convertDirectionToRotation(direction) {
138
+ var rotation;
139
+ switch (direction) {
140
+ case 'lefttop-to-rightbottom':
141
+ rotation = 45;
142
+ break;
143
+ case 'top-to-bottom':
144
+ rotation = 90;
145
+ break;
146
+ case 'righttop-to-leftbottom':
147
+ rotation = 135;
148
+ break;
149
+ case 'right-to-left':
150
+ rotation = 180;
151
+ break;
152
+ case 'rightbottom-to-lefttop':
153
+ rotation = 215;
154
+ break;
155
+ case 'bottom-to-top':
156
+ rotation = 270;
157
+ break;
158
+ case 'leftbottom-to-righttop':
159
+ rotation = 315;
160
+ break;
161
+ case 'left-to-right':
162
+ default:
163
+ rotation = 0;
164
+ break;
165
+ }
166
+ return (rotation / 360) * Math.PI * 2;
167
+ }
168
+ };
169
+ OxInputColorGradient.styles = css `
170
+ :host {
171
+ display: grid;
172
+
173
+ grid-template-columns: repeat(10, 1fr);
174
+ grid-gap: 5px;
175
+ grid-auto-rows: minmax(24px, auto);
176
+
177
+ align-items: center;
178
+ }
179
+
180
+ :host > * {
181
+ align-self: stretch;
182
+ }
183
+
184
+ :host > label {
185
+ grid-column: span 2;
186
+ text-align: right;
187
+ text-transform: capitalize;
188
+ align-self: center;
189
+ }
190
+
191
+ :host > .icon-only-label {
192
+ grid-column: span 1;
193
+ }
194
+
195
+ :host > input,
196
+ :host > [editors] {
197
+ grid-column: span 8;
198
+ }
199
+
200
+ :host > select {
201
+ grid-column: span 4;
202
+ height: 100%;
203
+ border: 1px solid rgba(0, 0, 0, 0.2);
204
+ }
205
+
206
+ :host > ox-input-angle {
207
+ grid-column: span 3;
208
+ }
209
+
210
+ ox-input-color-stops {
211
+ grid-column: span 10;
212
+ }
213
+
214
+ .host > input[type='checkbox'] {
215
+ grid-column: 3 / 4;
216
+ }
217
+
218
+ .host > input[type='checkbox'] ~ label {
219
+ grid-column: span 7;
220
+ text-align: left;
221
+ }
222
+
223
+ [editors] > :not([active-selector]) {
224
+ display: none;
225
+ }
226
+
227
+ [gradient-direction] {
228
+ overflow: hidden;
229
+ max-width: 210px;
230
+ }
231
+
232
+ [gradient-direction] paper-item {
233
+ background: url(/assets/images/icon-editor-gradient-direction.png) 50% 0 no-repeat;
234
+ min-height: 32px;
235
+ padding: 3px 5px;
236
+ width: 30px;
237
+ float: left;
238
+ }
239
+
240
+ [gradient-direction] [name='lefttop-to-rightbottom'] {
241
+ background-position: 50% 4px;
242
+ }
243
+
244
+ [gradient-direction] [name='left-top'] {
245
+ background-position: 50% 4px;
246
+ }
247
+
248
+ [gradient-direction] [name='top-to-bottom'] {
249
+ background-position: 50% -46px;
250
+ }
251
+
252
+ [gradient-direction] [name='righttop-to-leftbottom'] {
253
+ background-position: 50% -96px;
254
+ }
255
+
256
+ [gradient-direction] [name='right-top'] {
257
+ background-position: 50% -96px;
258
+ }
259
+
260
+ [gradient-direction] [name='right-to-left'] {
261
+ background-position: 50% -146px;
262
+ }
263
+
264
+ [gradient-direction] [name='rightbottom-to-lefttop'] {
265
+ background-position: 50% -196px;
266
+ }
267
+
268
+ [gradient-direction] [name='right-bottom'] {
269
+ background-position: 50% -196px;
270
+ }
271
+
272
+ [gradient-direction] [name='bottom-to-top'] {
273
+ background-position: 50% -246px;
274
+ }
275
+
276
+ [gradient-direction] [name='leftbottom-to-righttop'] {
277
+ background-position: 50% -296px;
278
+ }
279
+
280
+ [gradient-direction] [name='left-bottom'] {
281
+ background-position: 50% -296px;
282
+ }
283
+
284
+ [gradient-direction] [name='left-to-right'] {
285
+ background-position: 50% -346px;
286
+ }
287
+
288
+ [gradient-direction] [name='center-to-corner'] {
289
+ background-position: 50% -396px;
290
+ }
291
+
292
+ [gradient-direction] [name='center'] {
293
+ background-position: 50% -396px;
294
+ }
295
+
296
+ [gradient-direction] paper-item[focused] {
297
+ background-color: rgba(255, 246, 143, 0.5);
298
+ }
299
+
300
+ .icon-only-label {
301
+ top: 0 !important;
302
+ width: 30px !important;
303
+ height: 24px;
304
+ background: url(/assets/images/icon-properties-label.png) no-repeat;
305
+ }
306
+
307
+ .icon-only-label.color {
308
+ background-position: 70% -198px;
309
+ }
310
+ `;
311
+ __decorate([
312
+ property({ type: Object })
313
+ ], OxInputColorGradient.prototype, "value", void 0);
314
+ OxInputColorGradient = __decorate([
315
+ customElement('ox-input-color-gradient')
316
+ ], OxInputColorGradient);
317
+ export { OxInputColorGradient };
318
+ //# sourceMappingURL=ox-input-color-gradient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-color-gradient.js","sourceRoot":"","sources":["../../../src/input/ox-input-color-gradient.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,0BAA0B,CAAA;AACjC,OAAO,kDAAkD,CAAA;AACzD,OAAO,sCAAsC,CAAA;AAC7C,OAAO,gCAAgC,CAAA;AACvC,OAAO,kCAAkC,CAAA;AACzC,OAAO,wCAAwC,CAAA;AAE/C,OAAO,EAAa,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAqB3D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F,CAAA;IACH,CAAC;IAED,2BAA2B,CAAC,SAAiB;QAC3C,IAAI,QAAQ,CAAA;QACZ,QAAQ,SAAS,EAAE;YACjB,KAAK,wBAAwB;gBAC3B,QAAQ,GAAG,EAAE,CAAA;gBACb,MAAK;YACP,KAAK,eAAe;gBAClB,QAAQ,GAAG,EAAE,CAAA;gBACb,MAAK;YACP,KAAK,wBAAwB;gBAC3B,QAAQ,GAAG,GAAG,CAAA;gBACd,MAAK;YACP,KAAK,eAAe;gBAClB,QAAQ,GAAG,GAAG,CAAA;gBACd,MAAK;YACP,KAAK,wBAAwB;gBAC3B,QAAQ,GAAG,GAAG,CAAA;gBACd,MAAK;YACP,KAAK,eAAe;gBAClB,QAAQ,GAAG,GAAG,CAAA;gBACd,MAAK;YACP,KAAK,wBAAwB;gBAC3B,QAAQ,GAAG,GAAG,CAAA;gBACd,MAAK;YACP,KAAK,eAAe,CAAC;YACrB;gBACE,QAAQ,GAAG,CAAC,CAAA;gBACZ,MAAK;SACR;QAED,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IACvC,CAAC;CACF,CAAA;AAjTQ,2BAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6IlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAI1B;AApJU,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAkThC;SAlTY,oBAAoB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@operato/i18n/ox-i18n.js'\nimport '@polymer/paper-dropdown-menu/paper-dropdown-menu'\nimport '@polymer/paper-listbox/paper-listbox'\nimport '@polymer/paper-item/paper-item'\nimport '@operato/input/ox-input-angle.js'\nimport '@operato/input/ox-input-color-stops.js'\n\nimport { ColorStop, OxFormField } from '@operato/input'\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nexport type GradientOption = {\n type: 'linear' | 'radial'\n rotation: number\n direction?:\n | 'left-to-right'\n | 'lefttop-to-rightbottom'\n | 'top-to-bottom'\n | 'righttop-to-leftbottom'\n | 'right-to-left'\n | 'rightbottom-to-lefttop'\n | 'bottom-to-top'\n | 'leftbottom-to-righttop'\n | 'left-to-right'\n | 'center-to-corner'\n center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'\n colorStops?: ColorStop[]\n}\n\n@customElement('ox-input-color-gradient')\nexport class OxInputColorGradient extends OxFormField {\n static styles = css`\n :host {\n display: grid;\n\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n\n align-items: center;\n }\n\n :host > * {\n align-self: stretch;\n }\n\n :host > label {\n grid-column: span 2;\n text-align: right;\n text-transform: capitalize;\n align-self: center;\n }\n\n :host > .icon-only-label {\n grid-column: span 1;\n }\n\n :host > input,\n :host > [editors] {\n grid-column: span 8;\n }\n\n :host > select {\n grid-column: span 4;\n height: 100%;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n\n :host > ox-input-angle {\n grid-column: span 3;\n }\n\n ox-input-color-stops {\n grid-column: span 10;\n }\n\n .host > input[type='checkbox'] {\n grid-column: 3 / 4;\n }\n\n .host > input[type='checkbox'] ~ label {\n grid-column: span 7;\n text-align: left;\n }\n\n [editors] > :not([active-selector]) {\n display: none;\n }\n\n [gradient-direction] {\n overflow: hidden;\n max-width: 210px;\n }\n\n [gradient-direction] paper-item {\n background: url(/assets/images/icon-editor-gradient-direction.png) 50% 0 no-repeat;\n min-height: 32px;\n padding: 3px 5px;\n width: 30px;\n float: left;\n }\n\n [gradient-direction] [name='lefttop-to-rightbottom'] {\n background-position: 50% 4px;\n }\n\n [gradient-direction] [name='left-top'] {\n background-position: 50% 4px;\n }\n\n [gradient-direction] [name='top-to-bottom'] {\n background-position: 50% -46px;\n }\n\n [gradient-direction] [name='righttop-to-leftbottom'] {\n background-position: 50% -96px;\n }\n\n [gradient-direction] [name='right-top'] {\n background-position: 50% -96px;\n }\n\n [gradient-direction] [name='right-to-left'] {\n background-position: 50% -146px;\n }\n\n [gradient-direction] [name='rightbottom-to-lefttop'] {\n background-position: 50% -196px;\n }\n\n [gradient-direction] [name='right-bottom'] {\n background-position: 50% -196px;\n }\n\n [gradient-direction] [name='bottom-to-top'] {\n background-position: 50% -246px;\n }\n\n [gradient-direction] [name='leftbottom-to-righttop'] {\n background-position: 50% -296px;\n }\n\n [gradient-direction] [name='left-bottom'] {\n background-position: 50% -296px;\n }\n\n [gradient-direction] [name='left-to-right'] {\n background-position: 50% -346px;\n }\n\n [gradient-direction] [name='center-to-corner'] {\n background-position: 50% -396px;\n }\n\n [gradient-direction] [name='center'] {\n background-position: 50% -396px;\n }\n\n [gradient-direction] paper-item[focused] {\n background-color: rgba(255, 246, 143, 0.5);\n }\n\n .icon-only-label {\n top: 0 !important;\n width: 30px !important;\n height: 24px;\n background: url(/assets/images/icon-properties-label.png) no-repeat;\n }\n\n .icon-only-label.color {\n background-position: 70% -198px;\n }\n `\n\n @property({ type: Object }) value: GradientOption = {\n type: 'linear',\n direction: 'left-to-right',\n rotation: 0\n }\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n _onChange(e: Event) {\n var element = e.target as HTMLElement & { type: string }\n var key = element.getAttribute('value-key')\n\n if (!key) {\n return\n }\n\n var value\n\n switch (element.tagName) {\n case 'INPUT':\n switch (element.type) {\n case 'checkbox':\n value = (element as HTMLInputElement).checked\n break\n case 'number':\n value = Number((element as HTMLInputElement).value) || 0\n break\n case 'text':\n value = String((element as HTMLInputElement).value)\n }\n break\n\n case 'PAPER-BUTTON':\n value = (element as any).active\n break\n\n case 'PAPER-LISTBOX':\n value = (element as any).selected\n break\n\n default:\n value = (element as HTMLInputElement).value\n break\n }\n\n if (key === 'rotation') {\n this.value = {\n ...this.value,\n rotation: value,\n direction: undefined\n }\n } else if (key === 'direction') {\n if (value) {\n this.value = {\n ...this.value,\n direction: value,\n rotation: this._convertDirectionToRotation(value)\n }\n }\n } else {\n this.value = {\n ...this.value,\n [key]: value\n }\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n render() {\n var selector = (this.value && this.value.type) || 'linear'\n var value = this.value || {}\n\n return html`\n <label> <ox-i18n msgid=\"label.type\">type</ox-i18n> </label>\n <select value-key=\"type\" .value=${value.type || 'linear'}>\n <option>linear</option>\n <option>radial</option>\n </select>\n\n <label class=\"icon-only-label color\"></label>\n <ox-input-angle value-key=\"rotation\" .value=${value.rotation || 0}> </ox-input-angle>\n\n <label> <ox-i18n msgid=\"label.direction\">direction</ox-i18n> </label>\n <div editors>\n <paper-dropdown-menu no-label-float=\"true\" ?active-selector=${selector == 'linear'} .value=${value.direction}>\n <paper-listbox\n @selected-changed=${(e: Event) => this._onChange(e)}\n value-key=\"direction\"\n slot=\"dropdown-content\"\n gradient-direction\n .selected=${value.direction}\n attr-for-selected=\"name\"\n >\n <paper-item name=\"lefttop-to-rightbottom\"></paper-item>\n <paper-item name=\"top-to-bottom\"></paper-item>\n <paper-item name=\"righttop-to-leftbottom\"></paper-item>\n <paper-item name=\"right-to-left\"></paper-item>\n <paper-item name=\"rightbottom-to-lefttop\"></paper-item>\n <paper-item name=\"bottom-to-top\"></paper-item>\n <paper-item name=\"leftbottom-to-righttop\"></paper-item>\n <paper-item name=\"left-to-right\"></paper-item>\n <paper-item name=\"center-to-corner\"></paper-item>\n </paper-listbox>\n </paper-dropdown-menu>\n\n <paper-dropdown-menu no-label-float=\"true\" ?active-selector=${selector == 'radial'} .value=${value.center}>\n <paper-listbox\n @selected-changed=${(e: Event) => this._onChange(e)}\n value-key=\"center\"\n slot=\"dropdown-content\"\n gradient-direction\n .selected=${value.center || 'center'}\n attr-for-selected=\"name\"\n >\n <paper-item name=\"center\"></paper-item>\n <paper-item name=\"left-top\"></paper-item>\n <paper-item name=\"right-top\"></paper-item>\n <paper-item name=\"right-bottom\"></paper-item>\n <paper-item name=\"left-bottom\"></paper-item>\n </paper-listbox>\n </paper-dropdown-menu>\n </div>\n\n <ox-input-color-stops value-key=\"colorStops\" type=\"gradient\" .value=${value.colorStops}> </ox-input-color-stops>\n `\n }\n\n _convertDirectionToRotation(direction: string): number {\n var rotation\n switch (direction) {\n case 'lefttop-to-rightbottom':\n rotation = 45\n break\n case 'top-to-bottom':\n rotation = 90\n break\n case 'righttop-to-leftbottom':\n rotation = 135\n break\n case 'right-to-left':\n rotation = 180\n break\n case 'rightbottom-to-lefttop':\n rotation = 215\n break\n case 'bottom-to-top':\n rotation = 270\n break\n case 'leftbottom-to-righttop':\n rotation = 315\n break\n case 'left-to-right':\n default:\n rotation = 0\n break\n }\n\n return (rotation / 360) * Math.PI * 2\n }\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@operato/i18n/ox-i18n.js';
5
+ import '@operato/input/ox-input-color.js';
6
+ import '@operato/input/ox-input-color-stops.js';
7
+ import './ox-input-color-gradient.js';
8
+ import './ox-input-background-pattern.js';
9
+ import { BackgroundPatternOption } from './ox-input-background-pattern.js';
10
+ import { ColorStop, OxFormField } from '@operato/input';
11
+ import { GradientOption } from './ox-input-color-gradient.js';
12
+ import { PropertyValues } from 'lit';
13
+ export declare type FillStyle = {
14
+ type?: 'no' | 'solid' | 'gradient' | 'pattern';
15
+ gradientType?: 'linear' | 'radial';
16
+ colorStops?: ColorStop[];
17
+ rotation?: number;
18
+ center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom';
19
+ image?: HTMLImageElement | string;
20
+ offsetX?: number;
21
+ offsetY?: number;
22
+ width?: number;
23
+ height?: number;
24
+ align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom';
25
+ fitPattern?: boolean;
26
+ } | 'no' | string;
27
+ export declare class OxInputColorStyle extends OxFormField {
28
+ static styles: import("lit").CSSResult;
29
+ value?: FillStyle;
30
+ fillType?: string;
31
+ solid?: string;
32
+ gradient?: GradientOption;
33
+ pattern?: BackgroundPatternOption;
34
+ private _block_reset;
35
+ updated(changes: PropertyValues<this>): void;
36
+ render(): import("lit-html").TemplateResult<1>;
37
+ _onChangedValue(value: FillStyle): Promise<void>;
38
+ _onChangedFillType(e: Event): void;
39
+ _onChangedSolid(e: Event): void;
40
+ _onChandedGradient(e: Event): void;
41
+ _onChangedPattern(e: Event): void;
42
+ }