@operato/attachment 1.0.0-alpha.9 → 1.0.0-beta.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.
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@material/mwc-icon'
6
+ import './ox-attachment-list.js'
7
+
8
+ import { LitElement, css, html } from 'lit'
9
+ import { PopupHandle, openPopup } from '@operato/layout'
10
+ import { customElement, property } from 'lit/decorators.js'
11
+
12
+ import { i18next } from '@operato/i18n'
13
+
14
+ @customElement('ox-attachment-selector')
15
+ export class OxPropertyEditorAttachmentSelector extends LitElement {
16
+ static styles = [
17
+ css`
18
+ :host {
19
+ position: relative;
20
+ display: inline-block;
21
+ }
22
+
23
+ input[type='text'] {
24
+ box-sizing: border-box;
25
+ width: 100%;
26
+ height: 100%;
27
+ border: 1px solid rgba(0, 0, 0, 0.2);
28
+ }
29
+
30
+ mwc-icon {
31
+ position: absolute;
32
+ top: 0;
33
+ right: 3px;
34
+ }
35
+ `
36
+ ]
37
+
38
+ @property({ type: String }) value: string = ''
39
+ @property({ type: Object }) properties: any
40
+
41
+ private popup?: PopupHandle
42
+
43
+ render() {
44
+ return html`
45
+ <input
46
+ id="text"
47
+ type="text"
48
+ .value=${this.value || ''}
49
+ @change=${(e: KeyboardEvent) => this._onInputChanged(e)}
50
+ />
51
+
52
+ <mwc-icon @click=${() => this.openSelector()}>${this.getIconByCategory()}</mwc-icon>
53
+ `
54
+ }
55
+
56
+ getIconByCategory() {
57
+ var { category } = this.properties || {}
58
+ switch (category) {
59
+ case 'audio':
60
+ return 'library_music'
61
+ case 'video':
62
+ return 'video_library'
63
+ case 'image':
64
+ return 'image'
65
+ case 'text':
66
+ case 'application':
67
+ default:
68
+ return 'attachment'
69
+ }
70
+ }
71
+
72
+ _onInputChanged(e: KeyboardEvent) {
73
+ this.value = (e.target as HTMLInputElement).value
74
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
75
+ }
76
+
77
+ openSelector() {
78
+ if (this.popup) {
79
+ delete this.popup
80
+ }
81
+
82
+ /*
83
+ * 기존 설정된 이미지가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
84
+ * 주의. value는 object일 수도 있고, string일 수도 있다.
85
+ * string인 경우에는 해당 보드의 id로 해석한다.
86
+ */
87
+ var value = this.value || {}
88
+ var { category = 'application' } = this.properties || {}
89
+
90
+ var template = html`
91
+ <ox-attachment-list
92
+ .creatable=${true}
93
+ .category=${category}
94
+ @attachment-selected=${async (e: CustomEvent) => {
95
+ var attachment = e.detail.attachment
96
+ this.value = `/attachment/${attachment.path}`
97
+
98
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
99
+
100
+ this.popup && this.popup.close()
101
+ }}
102
+ ></ox-attachment-list>
103
+ `
104
+
105
+ this.popup = openPopup(template, {
106
+ backdrop: true,
107
+ size: 'large',
108
+ title: i18next.t('title.select attachment')
109
+ })
110
+ }
111
+ }
@@ -1,112 +1,14 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import '@material/mwc-icon'
6
- import './ox-attachment-list.js'
7
-
8
- import { PopupHandle, openPopup } from '@operato/layout'
9
- import { css, html } from 'lit'
10
- import { customElement, property, query } from 'lit/decorators.js'
1
+ import './ox-attachment-selector'
11
2
 
12
3
  import { OxPropertyEditor } from '@operato/property-editor'
13
- import { i18next } from '@operato/i18n'
4
+ import { customElement } from 'lit/decorators.js'
5
+ import { html } from 'lit'
14
6
 
15
7
  @customElement('ox-property-editor-attachment-selector')
16
- export class OxPropertyEditorAttachmentSelector extends OxPropertyEditor {
17
- static styles = [
18
- css`
19
- :host {
20
- position: relative;
21
- display: inline-block;
22
- }
23
-
24
- input[type='text'] {
25
- box-sizing: border-box;
26
- width: 100%;
27
- height: 100%;
28
- border: 1px solid rgba(0, 0, 0, 0.2);
29
- }
30
-
31
- mwc-icon {
32
- position: absolute;
33
- top: 0;
34
- right: 3px;
35
- }
36
- `
37
- ]
38
-
39
- @property({ type: String }) value: string = ''
40
- @property({ type: Object }) properties: any
41
-
42
- private popup?: PopupHandle
43
-
44
- render() {
8
+ class OxPropertyEditorAttachmentSelector extends OxPropertyEditor {
9
+ editorTemplate() {
45
10
  return html`
46
- <input
47
- id="text"
48
- type="text"
49
- .value=${this.value || ''}
50
- @change=${(e: KeyboardEvent) => this._onInputChanged(e)}
51
- />
52
-
53
- <mwc-icon @click=${() => this.openSelector()}>${this.getIconByCategory()}</mwc-icon>
11
+ <ox-attachment-selector id="editor" .value=${this.value} .properties=${this.property}></ox-attachment-selector>
54
12
  `
55
13
  }
56
-
57
- getIconByCategory() {
58
- var { category } = this.properties || {}
59
- switch (category) {
60
- case 'audio':
61
- return 'library_music'
62
- case 'video':
63
- return 'video_library'
64
- case 'image':
65
- return 'image'
66
- case 'text':
67
- case 'application':
68
- default:
69
- return 'attachment'
70
- }
71
- }
72
-
73
- _onInputChanged(e: KeyboardEvent) {
74
- this.value = (e.target as HTMLInputElement).value
75
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
76
- }
77
-
78
- openSelector() {
79
- if (this.popup) {
80
- delete this.popup
81
- }
82
-
83
- /*
84
- * 기존 설정된 이미지가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
85
- * 주의. value는 object일 수도 있고, string일 수도 있다.
86
- * string인 경우에는 해당 보드의 id로 해석한다.
87
- */
88
- var value = this.value || {}
89
- var { category = 'application' } = this.properties || {}
90
-
91
- var template = html`
92
- <ox-attachment-list
93
- .creatable=${true}
94
- .category=${category}
95
- @attachment-selected=${async (e: CustomEvent) => {
96
- var attachment = e.detail.attachment
97
- this.value = `/attachment/${attachment.path}`
98
-
99
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
100
-
101
- this.popup && this.popup.close()
102
- }}
103
- ></ox-attachment-list>
104
- `
105
-
106
- this.popup = openPopup(template, {
107
- backdrop: true,
108
- size: 'large',
109
- title: i18next.t('title.select attachment')
110
- })
111
- }
112
14
  }
@@ -0,0 +1,21 @@
1
+ import './ox-attachment-selector'
2
+
3
+ import { OxPropertyEditor } from '@operato/property-editor'
4
+ import { customElement } from 'lit/decorators.js'
5
+ import { html } from 'lit'
6
+
7
+ @customElement('ox-property-editor-image-selector')
8
+ class OxPropertyEditorImageSelector extends OxPropertyEditor {
9
+ editorTemplate() {
10
+ return html`
11
+ <ox-attachment-selector
12
+ id="editor"
13
+ .value=${this.value}
14
+ .properties=${{
15
+ ...this.property,
16
+ category: 'image'
17
+ }}
18
+ ></ox-attachment-selector>
19
+ `
20
+ }
21
+ }
@@ -1,31 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import '@operato/i18n/ox-i18n.js';
5
- import './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
- }
@@ -1,147 +0,0 @@
1
- /**
2
- * @license Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { __decorate } from "tslib";
5
- import '@operato/i18n/ox-i18n.js';
6
- import './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
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-input-background-pattern.js","sourceRoot":"","sources":["../../src/ox-input-background-pattern.ts"],"names":[],"mappings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AI,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 './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"]}
@@ -1,25 +0,0 @@
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
- }