@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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
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
+ ## [1.0.0-alpha.9](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2022-03-12)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * settled concept for input, property-editor, grist-editor, so on ([0c9e1d0](https://github.com/hatiolab/operato/commit/0c9e1d054c7aef5d965868242cf471667af7a3c3))
12
+
13
+
14
+
6
15
  ## [1.0.0-alpha.8](https://github.com/hatiolab/operato/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2022-03-11)
7
16
 
8
17
  **Note:** Version bump only for package @operato/app
@@ -1,5 +1,5 @@
1
1
  import '@material/mwc-icon';
2
- import '../../elements/object-selector';
2
+ import './object-selector.js';
3
3
  import { ColumnConfig, GristRecord } from '@operato/data-grist';
4
4
  import { LitElement, TemplateResult } from 'lit';
5
5
  export declare class ObjectEditor extends LitElement {
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import '@material/mwc-icon';
3
- import '../../elements/object-selector';
3
+ import './object-selector.js';
4
4
  import { ZERO_COLUMN, ZERO_RECORD } from '@operato/data-grist';
5
5
  import { LitElement, css, html } from 'lit';
6
6
  import { openPopup } from '@operato/layout';
@@ -1 +1 @@
1
- {"version":3,"file":"object-editor.js","sourceRoot":"","sources":["../../../src/grist/object-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAwC,WAAW,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE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AAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA7IQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAoC;AACnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAkC;AACjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAa;AArC7B,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA8IxB;SA9IY,YAAY","sourcesContent":["import '@material/mwc-icon'\nimport '../../elements/object-selector'\n\nimport { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'\nimport { LitElement, TemplateResult, css, html } from 'lit'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-object-editor')\nexport class ObjectEditor extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n justify-content: inherit;\n }\n\n span {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n\n mwc-icon {\n width: 20px;\n font-size: 1.5em;\n margin-left: auto;\n }\n `\n\n @property({ type: Object }) value: { [prop: string]: any } = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) row?: number\n\n private popup?: PopupHandle\n private template?: TemplateResult\n\n render() {\n var value = this.value || {}\n\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var name, description\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`\n ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n this.template = ((this.column.record || {}).options || {}).template\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback = (selected: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: {\n ...(this.column.record.options.select || [])\n .map((field: any) => field.name)\n .reduce((obj: { [field: string]: any }, fieldName: string) => {\n return (obj = {\n ...obj,\n [fieldName]: selected[fieldName]\n })\n }, {} as { [field: string]: any }),\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n },\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value[valueField]\n }\n\n var template =\n this.template ||\n html`\n <object-selector\n .value=${actualValue}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .select=${this.column.record.options.select}\n .list=${this.column.record.options.list}\n .basicArgs=${this.column.record.options.basicArgs}\n .valueField=${this.column.record.options.valueField}\n ></object-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n }\n}\n"]}
1
+ {"version":3,"file":"object-editor.js","sourceRoot":"","sources":["../../../src/grist/object-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAwC,WAAW,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAkC8B,UAAK,GAA4B,EAAE,CAAA;QACnC,WAAM,GAAiB,WAAW,CAAA;QAClC,WAAM,GAAgB,WAAW,CAAA;IA0G/D,CAAC;IApGC,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAE5B,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;QAC/F,IAAI,IAAI,EAAE,WAAW,CAAA;QACrB,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;YACnC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;SACxB;aAAM;YACL,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAA;SACxB;QAED,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;YAC1C,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;SACtC;aAAM;YACL,WAAW,GAAG,KAAK,CAAC,gB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I,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;kBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;uBAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;wBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU;;OAEtD,CAAA;QAEH,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA7IQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAoC;AACnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAkC;AACjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAa;AArC7B,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA8IxB;SA9IY,YAAY","sourcesContent":["import '@material/mwc-icon'\nimport './object-selector.js'\n\nimport { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'\nimport { LitElement, TemplateResult, css, html } from 'lit'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-object-editor')\nexport class ObjectEditor extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n justify-content: inherit;\n }\n\n span {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n\n mwc-icon {\n width: 20px;\n font-size: 1.5em;\n margin-left: auto;\n }\n `\n\n @property({ type: Object }) value: { [prop: string]: any } = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) row?: number\n\n private popup?: PopupHandle\n private template?: TemplateResult\n\n render() {\n var value = this.value || {}\n\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var name, description\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`\n ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n this.template = ((this.column.record || {}).options || {}).template\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback = (selected: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: {\n ...(this.column.record.options.select || [])\n .map((field: any) => field.name)\n .reduce((obj: { [field: string]: any }, fieldName: string) => {\n return (obj = {\n ...obj,\n [fieldName]: selected[fieldName]\n })\n }, {} as { [field: string]: any }),\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n },\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value[valueField]\n }\n\n var template =\n this.template ||\n html`\n <object-selector\n .value=${actualValue}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .select=${this.column.record.options.select}\n .list=${this.column.record.options.list}\n .basicArgs=${this.column.record.options.basicArgs}\n .valueField=${this.column.record.options.valueField}\n ></object-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n }\n}\n"]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@operato/i18n/ox-i18n.js';
5
+ import '@operato/attachment/ox-attachment-list.js';
6
+ import { OxFormField } from '@operato/input';
7
+ export declare type BackgroundPatternOption = {
8
+ image?: HTMLImageElement | string;
9
+ align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom';
10
+ offsetX?: number;
11
+ offsetY?: number;
12
+ width?: number;
13
+ height?: number;
14
+ fitPattern?: boolean;
15
+ };
16
+ /**
17
+ * 컴포넌트의 fill pattern을 편집하는 element
18
+ *
19
+ * Example:
20
+ * <ox-input-background-pattern
21
+ * @change="${e => { this.pattern = e.target.value }}"
22
+ * .value=${this.pattern}"
23
+ * ></ox-input-background-pattern>
24
+ */
25
+ export declare class OxInputBackgroundPattern extends OxFormField {
26
+ static styles: import("lit").CSSResult;
27
+ value?: BackgroundPatternOption;
28
+ render(): import("lit-html").TemplateResult<1>;
29
+ firstUpdated(): void;
30
+ _onChange(e: Event): void;
31
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import '@operato/i18n/ox-i18n.js';
6
+ import '@operato/attachment/ox-attachment-list.js';
7
+ import { css, html } from 'lit';
8
+ import { customElement, property } from 'lit/decorators.js';
9
+ import { OxFormField } from '@operato/input';
10
+ /**
11
+ * 컴포넌트의 fill pattern을 편집하는 element
12
+ *
13
+ * Example:
14
+ * <ox-input-background-pattern
15
+ * @change="${e => { this.pattern = e.target.value }}"
16
+ * .value=${this.pattern}"
17
+ * ></ox-input-background-pattern>
18
+ */
19
+ let OxInputBackgroundPattern = class OxInputBackgroundPattern extends OxFormField {
20
+ render() {
21
+ const value = this.value || {};
22
+ return html `
23
+ <label> <ox-i18n msgid="label.image" auto="">image</ox-i18n> </label>
24
+
25
+ <ox-property-editor-attachment-selector
26
+ value-key="image"
27
+ .value=${value.image || ''}
28
+ custom-editor
29
+ ></ox-property-editor-attachment-selector>
30
+
31
+ <label> <ox-i18n msgid="label.align" auto="">align</ox-i18n> </label>
32
+
33
+ <select value-key="align" class="select-content" .value=${value.align}>
34
+ <option value="left-top">Left Top</option>
35
+ <option value="top">Top</option>
36
+ <option value="right-top">Right Top</option>
37
+ <option value="left">Left</option>
38
+ <option value="center">Center</option>
39
+ <option value="right">Right</option>
40
+ <option value="left-bottom">Left Bottom</option>
41
+ <option value="bottom">Bottom</option>
42
+ <option value="right-bottom">Right Bottom</option>
43
+ </select>
44
+
45
+ <div class="grid-10">
46
+ <label> <ox-i18n msgid="label.offset-x" auto="">offsetX</ox-i18n> </label>
47
+ <input type="number" value-key="offsetX" .value=${value.offsetX} />
48
+
49
+ <label> <ox-i18n msgid="label.offset-y" auto="">offsetY</ox-i18n> </label>
50
+ <input type="number" value-key="offsetY" .value=${value.offsetY} />
51
+
52
+ <label> <ox-i18n msgid="label.width" auto="">width</ox-i18n> </label>
53
+ <input type="number" value-key="width" .value=${value.width} />
54
+
55
+ <label> <ox-i18n msgid="label.height" auto="">height</ox-i18n> </label>
56
+ <input type="number" value-key="height" .value=${value.height} />
57
+ </div>
58
+
59
+ <div class="grid-10">
60
+ <input value-key="fitPattern" type="checkbox" .checked=${value.fitPattern} required />
61
+ <label> <ox-i18n msgid="label.fit" auto="">Fit</ox-i18n> </label>
62
+ </div>
63
+ `;
64
+ }
65
+ firstUpdated() {
66
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
67
+ }
68
+ _onChange(e) {
69
+ var element = e.target;
70
+ var key = element.getAttribute('value-key');
71
+ var value = element.value;
72
+ if (key == 'fitPattern') {
73
+ value = element.checked;
74
+ }
75
+ this.value = {
76
+ ...this.value,
77
+ [key]: value
78
+ };
79
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
80
+ }
81
+ };
82
+ OxInputBackgroundPattern.styles = css `
83
+ :host,
84
+ .grid-10 {
85
+ display: grid;
86
+ grid-template-columns: repeat(10, 1fr);
87
+ grid-gap: 5px;
88
+ grid-auto-rows: minmax(24px, auto);
89
+
90
+ align-items: center;
91
+ }
92
+
93
+ * {
94
+ align-self: stretch;
95
+ }
96
+
97
+ label {
98
+ grid-column: span 2;
99
+ text-align: right;
100
+ text-transform: capitalize;
101
+
102
+ align-self: center;
103
+ }
104
+
105
+ .grid-10 {
106
+ grid-column: span 10;
107
+ }
108
+
109
+ select,
110
+ input,
111
+ [custom-editor] {
112
+ grid-column: span 8;
113
+ }
114
+
115
+ select {
116
+ height: 100%;
117
+ border: 1px solid rgba(0, 0, 0, 0.2);
118
+ }
119
+
120
+ input[type='checkbox'] {
121
+ grid-column: 3 / 4;
122
+ align-self: center;
123
+ }
124
+
125
+ input[type='checkbox'] ~ label {
126
+ grid-column: span 7;
127
+ text-align: left;
128
+ }
129
+
130
+ .grid-10 > input[type='number'] {
131
+ grid-column: span 3;
132
+ border: 1px solid rgba(0, 0, 0, 0.2);
133
+ }
134
+
135
+ .grid-10 > label {
136
+ grid-column: span 2;
137
+ text-align: right;
138
+ }
139
+ `;
140
+ __decorate([
141
+ property({ type: Object })
142
+ ], OxInputBackgroundPattern.prototype, "value", void 0);
143
+ OxInputBackgroundPattern = __decorate([
144
+ customElement('ox-input-background-pattern')
145
+ ], OxInputBackgroundPattern);
146
+ export { OxInputBackgroundPattern };
147
+ //# sourceMappingURL=ox-input-background-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-background-pattern.js","sourceRoot":"","sources":["../../../src/input/ox-input-background-pattern.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,0BAA0B,CAAA;AACjC,OAAO,2CAA2C,CAAA;AAElD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAY5C;;;;;;;;GAQG;AAGH,IAAa,wBAAwB,GAArC,MAAa,wBAAyB,SAAQ,WAAW;IA8DvD,MAAM;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAK,EAA8B,CAAA;QAE3D,OAAO,IAAI,CAAA;;;;;iBAKE,KAAK,CAAC,KAAK,IAAI,EAAE;;;;;;gEAM8B,KAAK,CAAC,KAAK;;;;;;;;;;;;;;0DAcjB,KAAK,CAAC,OAAO;;;0DAGb,KAAK,CAAC,OAAO;;;wDAGf,KAAK,CAAC,KAAK;;;yDAGV,KAAK,CAAC,MAAM;;;;iEAIJ,KAAK,CAAC,UAAU;;;KAG5E,CAAA;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,SAAS,CAAC,CAAQ;QAChB,IAAI,OAAO,GAAG,CAAC,CAAC,MAA0B,CAAA;QAC1C,IAAI,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;QAC3C,IAAI,KAAK,GAAQ,OAAO,CAAC,KAAK,CAAA;QAE9B,IAAI,GAAG,IAAI,YAAY,EAAE;YACvB,KAAK,GAAG,OAAO,CAAC,OAAO,CAAA;SACxB;QAED,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,IAAI,CAAC,KAAK;YACb,CAAC,GAAI,CAAC,EAAE,KAAK;SACd,CAAA;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;CACF,CAAA;AAhIQ,+BAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAgC;AA5DhD,wBAAwB;IADpC,aAAa,CAAC,6BAA6B,CAAC;GAChC,wBAAwB,CAiIpC;SAjIY,wBAAwB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@operato/i18n/ox-i18n.js'\nimport '@operato/attachment/ox-attachment-list.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from '@operato/input'\n\nexport type BackgroundPatternOption = {\n image?: HTMLImageElement | string\n align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'\n offsetX?: number\n offsetY?: number\n width?: number\n height?: number\n fitPattern?: boolean\n}\n\n/**\n * 컴포넌트의 fill pattern을 편집하는 element\n *\n * Example:\n * <ox-input-background-pattern\n * @change=\"${e => { this.pattern = e.target.value }}\"\n * .value=${this.pattern}\"\n * ></ox-input-background-pattern>\n */\n\n@customElement('ox-input-background-pattern')\nexport class OxInputBackgroundPattern extends OxFormField {\n static styles = css`\n :host,\n .grid-10 {\n display: grid;\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 * {\n align-self: stretch;\n }\n\n label {\n grid-column: span 2;\n text-align: right;\n text-transform: capitalize;\n\n align-self: center;\n }\n\n .grid-10 {\n grid-column: span 10;\n }\n\n select,\n input,\n [custom-editor] {\n grid-column: span 8;\n }\n\n select {\n height: 100%;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n\n input[type='checkbox'] {\n grid-column: 3 / 4;\n align-self: center;\n }\n\n input[type='checkbox'] ~ label {\n grid-column: span 7;\n text-align: left;\n }\n\n .grid-10 > input[type='number'] {\n grid-column: span 3;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n\n .grid-10 > label {\n grid-column: span 2;\n text-align: right;\n }\n `\n\n @property({ type: Object }) value?: BackgroundPatternOption\n\n render() {\n const value = this.value || ({} as BackgroundPatternOption)\n\n return html`\n <label> <ox-i18n msgid=\"label.image\" auto=\"\">image</ox-i18n> </label>\n\n <ox-property-editor-attachment-selector\n value-key=\"image\"\n .value=${value.image || ''}\n custom-editor\n ></ox-property-editor-attachment-selector>\n\n <label> <ox-i18n msgid=\"label.align\" auto=\"\">align</ox-i18n> </label>\n\n <select value-key=\"align\" class=\"select-content\" .value=${value.align}>\n <option value=\"left-top\">Left Top</option>\n <option value=\"top\">Top</option>\n <option value=\"right-top\">Right Top</option>\n <option value=\"left\">Left</option>\n <option value=\"center\">Center</option>\n <option value=\"right\">Right</option>\n <option value=\"left-bottom\">Left Bottom</option>\n <option value=\"bottom\">Bottom</option>\n <option value=\"right-bottom\">Right Bottom</option>\n </select>\n\n <div class=\"grid-10\">\n <label> <ox-i18n msgid=\"label.offset-x\" auto=\"\">offsetX</ox-i18n> </label>\n <input type=\"number\" value-key=\"offsetX\" .value=${value.offsetX} />\n\n <label> <ox-i18n msgid=\"label.offset-y\" auto=\"\">offsetY</ox-i18n> </label>\n <input type=\"number\" value-key=\"offsetY\" .value=${value.offsetY} />\n\n <label> <ox-i18n msgid=\"label.width\" auto=\"\">width</ox-i18n> </label>\n <input type=\"number\" value-key=\"width\" .value=${value.width} />\n\n <label> <ox-i18n msgid=\"label.height\" auto=\"\">height</ox-i18n> </label>\n <input type=\"number\" value-key=\"height\" .value=${value.height} />\n </div>\n\n <div class=\"grid-10\">\n <input value-key=\"fitPattern\" type=\"checkbox\" .checked=${value.fitPattern} required />\n <label> <ox-i18n msgid=\"label.fit\" auto=\"\">Fit</ox-i18n> </label>\n </div>\n `\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 HTMLInputElement\n var key = element.getAttribute('value-key')\n var value: any = element.value\n\n if (key == 'fitPattern') {\n value = element.checked\n }\n\n this.value = {\n ...this.value,\n [key!]: value\n }\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@operato/i18n/ox-i18n.js';
5
+ import '@polymer/paper-dropdown-menu/paper-dropdown-menu';
6
+ import '@polymer/paper-listbox/paper-listbox';
7
+ import '@polymer/paper-item/paper-item';
8
+ import '@operato/input/ox-input-angle.js';
9
+ import '@operato/input/ox-input-color-stops.js';
10
+ import { ColorStop, OxFormField } from '@operato/input';
11
+ export declare type GradientOption = {
12
+ type: 'linear' | 'radial';
13
+ rotation: number;
14
+ direction?: 'left-to-right' | 'lefttop-to-rightbottom' | 'top-to-bottom' | 'righttop-to-leftbottom' | 'right-to-left' | 'rightbottom-to-lefttop' | 'bottom-to-top' | 'leftbottom-to-righttop' | 'left-to-right' | 'center-to-corner';
15
+ center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom';
16
+ colorStops?: ColorStop[];
17
+ };
18
+ export declare class OxInputColorGradient extends OxFormField {
19
+ static styles: import("lit").CSSResult;
20
+ value: GradientOption;
21
+ firstUpdated(): void;
22
+ _onChange(e: Event): void;
23
+ render(): import("lit-html").TemplateResult<1>;
24
+ _convertDirectionToRotation(direction: string): number;
25
+ }
@@ -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,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,WAAW;IAArD;;QAgJ8B,UAAK,GAAmB;YAClD,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,eAAe;YAC1B,QAAQ,EAAE,CAAC;SACZ,CAAA;IA8JH,CAAC;IA5JC,YAAY;QACV,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,SAAS,CAAC,CAAQ;QAChB,IAAI,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AK,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"]}