@operato/input 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 +9 -0
- package/README.md +9 -6
- package/assets/images/icon-editor-gradient-direction.png +0 -0
- package/assets/images/icon-properties-label.png +0 -0
- package/demo/index-color-gradient.html +35 -0
- package/demo/index-color-stops.html +62 -0
- package/demo/index-color.html +35 -0
- package/demo/index-multiple-colors.html +37 -0
- package/demo/index.html +4 -0
- package/dist/src/index.d.ts +15 -11
- package/dist/src/index.js +15 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-input-background-pattern.d.ts +31 -0
- package/dist/src/ox-input-background-pattern.js +147 -0
- package/dist/src/ox-input-background-pattern.js.map +1 -0
- package/dist/src/ox-input-code.d.ts +4 -4
- package/dist/src/ox-input-code.js +8 -8
- package/dist/src/ox-input-code.js.map +1 -1
- package/dist/src/ox-input-color-gradient.d.ts +26 -0
- package/dist/src/ox-input-color-gradient.js +318 -0
- package/dist/src/ox-input-color-gradient.js.map +1 -0
- package/dist/src/ox-input-color-stops.d.ts +71 -0
- package/dist/src/ox-input-color-stops.js +445 -0
- package/dist/src/ox-input-color-stops.js.map +1 -0
- package/dist/src/ox-input-color.d.ts +176 -0
- package/dist/src/ox-input-color.js +298 -0
- package/dist/src/ox-input-color.js.map +1 -0
- package/dist/src/ox-input-data.d.ts +1 -1
- package/dist/src/ox-input-data.js +1 -1
- package/dist/src/ox-input-data.js.map +1 -1
- package/dist/src/ox-input-fill-style.d.ts +42 -0
- package/dist/src/ox-input-fill-style.js +323 -0
- package/dist/src/ox-input-fill-style.js.map +1 -0
- package/dist/src/ox-input-multiple-colors.d.ts +28 -0
- package/dist/src/ox-input-multiple-colors.js +113 -0
- package/dist/src/ox-input-multiple-colors.js.map +1 -0
- package/dist/src/ox-input-scene-component-id.d.ts +11 -0
- package/dist/src/ox-input-scene-component-id.js +68 -0
- package/dist/src/ox-input-scene-component-id.js.map +1 -0
- package/dist/src/ox-input-stack.d.ts +1 -1
- package/dist/src/ox-input-stack.js +1 -1
- package/dist/src/ox-input-stack.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -7
- package/src/index.ts +15 -11
- package/src/ox-input-background-pattern.ts.xxx +163 -0
- package/src/ox-input-code.ts +9 -10
- package/src/ox-input-color-gradient.ts.xxx +343 -0
- package/src/ox-input-color-stops.ts +499 -0
- package/src/ox-input-color.ts +323 -0
- package/src/ox-input-data.ts +2 -2
- package/src/ox-input-fill-style.ts.xxx +361 -0
- package/src/ox-input-keyvalues.ts.ing +10 -10
- package/src/ox-input-multiple-colors.ts +113 -0
- package/src/ox-input-ranges.ts.ing +12 -12
- package/src/{ox-input-id.ts → ox-input-scene-component-id.ts} +1 -1
- package/src/ox-input-stack.ts +1 -1
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
@@ -0,0 +1,323 @@
|
|
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-input-color';
|
7
|
+
import './ox-input-color-gradient';
|
8
|
+
import './ox-input-background-pattern';
|
9
|
+
import { css, html } from 'lit';
|
10
|
+
import { customElement, property } from 'lit/decorators.js';
|
11
|
+
import { OxFormField } from './ox-form-field';
|
12
|
+
let OxInputColorStyle = class OxInputColorStyle extends OxFormField {
|
13
|
+
constructor() {
|
14
|
+
super(...arguments);
|
15
|
+
this._block_reset = false;
|
16
|
+
}
|
17
|
+
static { this.styles = css `
|
18
|
+
:host {
|
19
|
+
display: flex;
|
20
|
+
flex-direction: column;
|
21
|
+
}
|
22
|
+
|
23
|
+
[fill-type] {
|
24
|
+
display: flex;
|
25
|
+
margin: 0 0 14px 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
[fill-type] * {
|
29
|
+
flex: auto;
|
30
|
+
margin: 0;
|
31
|
+
text-align: left;
|
32
|
+
align-self: center;
|
33
|
+
}
|
34
|
+
|
35
|
+
.grid-10 {
|
36
|
+
display: grid;
|
37
|
+
|
38
|
+
grid-template-columns: repeat(10, 1fr);
|
39
|
+
grid-gap: 5px;
|
40
|
+
grid-auto-rows: minmax(24px, auto);
|
41
|
+
}
|
42
|
+
|
43
|
+
.grid-10 > ox-input-color {
|
44
|
+
grid-column: span 4;
|
45
|
+
}
|
46
|
+
|
47
|
+
.grid-10 > .icon-only-label {
|
48
|
+
grid-column: span 1;
|
49
|
+
|
50
|
+
background: url(/assets/images/icon-properties-label.png) no-repeat;
|
51
|
+
float: left;
|
52
|
+
margin: 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
.icon-only-label.color {
|
56
|
+
background-position: 70% -498px;
|
57
|
+
}
|
58
|
+
|
59
|
+
[editors] > :not([active]) {
|
60
|
+
display: none;
|
61
|
+
}
|
62
|
+
`; }
|
63
|
+
updated(changes) {
|
64
|
+
changes.has('value') && this._onChangedValue(this.value || {});
|
65
|
+
}
|
66
|
+
render() {
|
67
|
+
return html `
|
68
|
+
<div @change=${(e) => this._onChangedFillType(e)} fill-type>
|
69
|
+
<input
|
70
|
+
type="radio"
|
71
|
+
id="fill-type-no"
|
72
|
+
name="fill-type"
|
73
|
+
value="no"
|
74
|
+
.checked=${!this.fillType || this.fillType == 'no'}
|
75
|
+
/>
|
76
|
+
<label for="fill-type-no"><ox-i18n msgid="label.no-fill">no fill</ox-i18n></label>
|
77
|
+
<input type="radio" id="fill-type-solid" name="fill-type" value="solid" .checked=${this.fillType == 'solid'} />
|
78
|
+
<label for="fill-type-solid"><ox-i18n msgid="label.solid">solid</ox-i18n></label>
|
79
|
+
<input
|
80
|
+
type="radio"
|
81
|
+
id="fill-type-gradient"
|
82
|
+
name="fill-type"
|
83
|
+
value="gradient"
|
84
|
+
.checked=${this.fillType == 'gradient'}
|
85
|
+
/>
|
86
|
+
<label for="fill-type-gradient"><ox-i18n msgid="label.gradient">gradient</ox-i18n></label>
|
87
|
+
<input
|
88
|
+
type="radio"
|
89
|
+
id="fill-type-pattern"
|
90
|
+
name="fill-type"
|
91
|
+
value="pattern"
|
92
|
+
.checked=${this.fillType == 'pattern'}
|
93
|
+
/>
|
94
|
+
<label for="fill-type-pattern"><ox-i18n msgid="label.pattern">pattern</ox-i18n></label>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
<div editors>
|
98
|
+
<div ?active=${this.fillType == 'no'}></div>
|
99
|
+
|
100
|
+
<div class="grid-10" ?active=${this.fillType == 'solid'}>
|
101
|
+
<label class="icon-only-label color"></label>
|
102
|
+
<ox-input-color @change=${(e) => this._onChangedSolid(e)} .value=${this.solid}> </ox-input-color>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<div ?active=${this.fillType == 'gradient'}>
|
106
|
+
<ox-input-color-gradient @change=${(e) => this._onChandedGradient(e)} .value=${this.gradient}>
|
107
|
+
</ox-input-color-gradient>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div ?active=${this.fillType == 'pattern'}>
|
111
|
+
<ox-input-background-pattern @change=${(e) => this._onChangedPattern(e)} .value=${this.pattern}>
|
112
|
+
</ox-input-background-pattern>
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
`;
|
116
|
+
}
|
117
|
+
async _onChangedValue(value) {
|
118
|
+
/*
|
119
|
+
* this._block_reset의 역할은 내부 사용자 인터렉션에 의한 value의 변경시에는 각 type별 이전값을 유지하기 위함이다.
|
120
|
+
*/
|
121
|
+
await this.requestUpdate();
|
122
|
+
/* 설정 값에 따라서, 멤버 속성을 설정한다. */
|
123
|
+
if (!value) {
|
124
|
+
this.fillType = 'no';
|
125
|
+
if (!this._block_reset) {
|
126
|
+
this.solid = undefined;
|
127
|
+
this.gradient = undefined;
|
128
|
+
this.pattern = undefined;
|
129
|
+
}
|
130
|
+
this._block_reset = false;
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
switch (typeof value) {
|
134
|
+
case 'string':
|
135
|
+
this.fillType = 'solid';
|
136
|
+
this.solid = value;
|
137
|
+
if (!this._block_reset) {
|
138
|
+
this.gradient = undefined;
|
139
|
+
this.pattern = undefined;
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
case 'object':
|
143
|
+
this.fillType = value.type;
|
144
|
+
if (value.type === 'gradient') {
|
145
|
+
this.gradient = {
|
146
|
+
type: value.gradientType || 'linear',
|
147
|
+
colorStops: value.colorStops || [
|
148
|
+
{
|
149
|
+
position: 0,
|
150
|
+
color: this.solid || '#000000'
|
151
|
+
},
|
152
|
+
{
|
153
|
+
position: 1,
|
154
|
+
color: this.solid || '#FFFFFF'
|
155
|
+
}
|
156
|
+
],
|
157
|
+
rotation: Number(value.rotation) || 0,
|
158
|
+
center: value.center
|
159
|
+
};
|
160
|
+
if (!this._block_reset) {
|
161
|
+
this.pattern = undefined;
|
162
|
+
this.solid = undefined;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
else if (value.type === 'pattern') {
|
166
|
+
this.pattern = {
|
167
|
+
image: value.image,
|
168
|
+
offsetX: Number(value.offsetX) || 0,
|
169
|
+
offsetY: Number(value.offsetY) || 0,
|
170
|
+
width: Number(value.width),
|
171
|
+
height: Number(value.height),
|
172
|
+
align: value.align,
|
173
|
+
fitPattern: value.fitPattern
|
174
|
+
};
|
175
|
+
if (!this._block_reset) {
|
176
|
+
this.gradient = undefined;
|
177
|
+
this.solid = undefined;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
break;
|
181
|
+
default:
|
182
|
+
}
|
183
|
+
this._block_reset = false;
|
184
|
+
}
|
185
|
+
_onChangedFillType(e) {
|
186
|
+
const element = e.target;
|
187
|
+
this.fillType = element.value;
|
188
|
+
switch (this.fillType) {
|
189
|
+
case 'gradient':
|
190
|
+
if (!this.gradient) {
|
191
|
+
this.gradient = {
|
192
|
+
type: 'linear',
|
193
|
+
colorStops: [
|
194
|
+
{
|
195
|
+
position: 0,
|
196
|
+
color: this.solid || '#000000'
|
197
|
+
},
|
198
|
+
{
|
199
|
+
position: 1,
|
200
|
+
color: this.solid || '#FFFFFF'
|
201
|
+
}
|
202
|
+
],
|
203
|
+
rotation: 0,
|
204
|
+
center: 'center'
|
205
|
+
};
|
206
|
+
}
|
207
|
+
this.value = {
|
208
|
+
type: 'gradient',
|
209
|
+
gradientType: this.gradient.type || 'linear',
|
210
|
+
colorStops: this.gradient.colorStops || [
|
211
|
+
{
|
212
|
+
position: 0,
|
213
|
+
color: this.solid || '#000000'
|
214
|
+
},
|
215
|
+
{
|
216
|
+
position: 1,
|
217
|
+
color: this.solid || '#FFFFFF'
|
218
|
+
}
|
219
|
+
],
|
220
|
+
rotation: Number(this.gradient.rotation) || 0,
|
221
|
+
center: this.gradient.center
|
222
|
+
};
|
223
|
+
break;
|
224
|
+
case 'pattern':
|
225
|
+
if (!this.pattern)
|
226
|
+
this.pattern = {};
|
227
|
+
this.value = {
|
228
|
+
type: 'pattern',
|
229
|
+
image: this.pattern.image,
|
230
|
+
offsetX: Number(this.pattern.offsetX) || 0,
|
231
|
+
offsetY: Number(this.pattern.offsetY) || 0,
|
232
|
+
width: Number(this.pattern.width),
|
233
|
+
height: Number(this.pattern.height),
|
234
|
+
align: this.pattern.align,
|
235
|
+
fitPattern: this.pattern.fitPattern
|
236
|
+
};
|
237
|
+
break;
|
238
|
+
case 'solid':
|
239
|
+
if (!this.solid)
|
240
|
+
this.solid = '#fff';
|
241
|
+
this.value = this.solid;
|
242
|
+
break;
|
243
|
+
case 'no':
|
244
|
+
this.value = '';
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
this._block_reset = true;
|
248
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
249
|
+
}
|
250
|
+
_onChangedSolid(e) {
|
251
|
+
if (this.fillType !== 'solid')
|
252
|
+
return;
|
253
|
+
this.solid = e.target.value;
|
254
|
+
this.value = this.solid;
|
255
|
+
this._block_reset = true;
|
256
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
257
|
+
}
|
258
|
+
_onChandedGradient(e) {
|
259
|
+
/*
|
260
|
+
* TODO Gradient의 rotation은 symmetry 기능 등으로 외부에서 변경될 수도 있다.
|
261
|
+
* 이 점을 감안해서, 외부 변경에 대한 대응을 해야 한다.
|
262
|
+
*/
|
263
|
+
if (this.fillType !== 'gradient') {
|
264
|
+
return;
|
265
|
+
}
|
266
|
+
this.gradient = e.target.value;
|
267
|
+
this.value = {
|
268
|
+
type: 'gradient',
|
269
|
+
gradientType: this.gradient.type || 'linear',
|
270
|
+
colorStops: this.gradient.colorStops || [
|
271
|
+
{
|
272
|
+
position: 0,
|
273
|
+
color: this.solid || '#000000'
|
274
|
+
},
|
275
|
+
{
|
276
|
+
position: 1,
|
277
|
+
color: this.solid || '#FFFFFF'
|
278
|
+
}
|
279
|
+
],
|
280
|
+
rotation: Number(this.gradient.rotation) || 0,
|
281
|
+
center: this.gradient.center
|
282
|
+
};
|
283
|
+
this._block_reset = true;
|
284
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
285
|
+
}
|
286
|
+
_onChangedPattern(e) {
|
287
|
+
if (this.fillType !== 'pattern')
|
288
|
+
return;
|
289
|
+
this.pattern = e.target.value;
|
290
|
+
this.value = {
|
291
|
+
type: 'pattern',
|
292
|
+
image: this.pattern?.image,
|
293
|
+
offsetX: Number(this.pattern?.offsetX) || 0,
|
294
|
+
offsetY: Number(this.pattern?.offsetY) || 0,
|
295
|
+
width: Number(this.pattern?.width),
|
296
|
+
height: Number(this.pattern?.height),
|
297
|
+
align: this.pattern?.align,
|
298
|
+
fitPattern: this.pattern?.fitPattern
|
299
|
+
};
|
300
|
+
this._block_reset = true;
|
301
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
302
|
+
}
|
303
|
+
};
|
304
|
+
__decorate([
|
305
|
+
property({ type: Object })
|
306
|
+
], OxInputColorStyle.prototype, "value", void 0);
|
307
|
+
__decorate([
|
308
|
+
property({ type: String })
|
309
|
+
], OxInputColorStyle.prototype, "fillType", void 0);
|
310
|
+
__decorate([
|
311
|
+
property({ type: String })
|
312
|
+
], OxInputColorStyle.prototype, "solid", void 0);
|
313
|
+
__decorate([
|
314
|
+
property({ type: Object })
|
315
|
+
], OxInputColorStyle.prototype, "gradient", void 0);
|
316
|
+
__decorate([
|
317
|
+
property({ type: Object })
|
318
|
+
], OxInputColorStyle.prototype, "pattern", void 0);
|
319
|
+
OxInputColorStyle = __decorate([
|
320
|
+
customElement('ox-input-color-style')
|
321
|
+
], OxInputColorStyle);
|
322
|
+
export { OxInputColorStyle };
|
323
|
+
//# sourceMappingURL=ox-input-fill-style.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-fill-style.js","sourceRoot":"","sources":["../../src/ox-input-fill-style.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,0BAA0B,CAAA;AACjC,OAAO,kBAAkB,CAAA;AACzB,OAAO,2BAA2B,CAAA;AAClC,OAAO,+BAA+B,CAAA;AAItC,OAAO,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAA;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAqB7C,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,WAAW;IAAlD;;QAsDU,iBAAY,GAAY,KAAK,CAAA;IA8QvC,CAAC;aAnUQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6ClB,CAAA;IAUD,OAAO,CAAC,OAA6B;QACnC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IAChE,CAAC;IAED,MAAM;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,EAAE,CAAC;mDAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAkC;AApDlD,iBAAiB;IAD7B,aAAa,CAAC,sBAAsB,CAAC;GACzB,iBAAiB,CAoU7B;SApUY,iBAAiB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@operato/i18n/ox-i18n.js'\nimport './ox-input-color'\nimport './ox-input-color-gradient'\nimport './ox-input-background-pattern'\n\nimport { BackgroundPatternOption, OxInputBackgroundPattern } from './ox-input-background-pattern'\nimport { GradientOption, OxInputColorGradient } from './ox-input-color-gradient'\nimport { PropertyValues, css, html } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { ColorStop } from './ox-input-color-stops'\nimport { OxFormField } from './ox-form-field'\n\nexport type FillStyle =\n | {\n type?: 'no' | 'solid' | 'gradient' | 'pattern'\n gradientType?: 'linear' | 'radial'\n colorStops?: ColorStop[]\n rotation?: number\n center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'\n image?: HTMLImageElement | string\n offsetX?: number\n offsetY?: number\n width?: number\n height?: number\n align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'\n fitPattern?: boolean\n }\n | 'no'\n | string\n\n@customElement('ox-input-color-style')\nexport class OxInputColorStyle extends OxFormField {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n }\n\n [fill-type] {\n display: flex;\n margin: 0 0 14px 0;\n }\n\n [fill-type] * {\n flex: auto;\n margin: 0;\n text-align: left;\n align-self: center;\n }\n\n .grid-10 {\n display: grid;\n\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n grid-auto-rows: minmax(24px, auto);\n }\n\n .grid-10 > ox-input-color {\n grid-column: span 4;\n }\n\n .grid-10 > .icon-only-label {\n grid-column: span 1;\n\n background: url(/assets/images/icon-properties-label.png) no-repeat;\n float: left;\n margin: 0;\n }\n\n .icon-only-label.color {\n background-position: 70% -498px;\n }\n\n [editors] > :not([active]) {\n display: none;\n }\n `\n\n @property({ type: Object }) value?: FillStyle\n @property({ type: String }) fillType?: string\n @property({ type: String }) solid?: string\n @property({ type: Object }) gradient?: GradientOption\n @property({ type: Object }) pattern?: BackgroundPatternOption\n\n private _block_reset: boolean = false\n\n updated(changes: PropertyValues<this>) {\n changes.has('value') && this._onChangedValue(this.value || {})\n }\n\n render() {\n return html`\n <div @change=${(e: Event) => this._onChangedFillType(e)} fill-type>\n <input\n type=\"radio\"\n id=\"fill-type-no\"\n name=\"fill-type\"\n value=\"no\"\n .checked=${!this.fillType || this.fillType == 'no'}\n />\n <label for=\"fill-type-no\"><ox-i18n msgid=\"label.no-fill\">no fill</ox-i18n></label>\n <input type=\"radio\" id=\"fill-type-solid\" name=\"fill-type\" value=\"solid\" .checked=${this.fillType == 'solid'} />\n <label for=\"fill-type-solid\"><ox-i18n msgid=\"label.solid\">solid</ox-i18n></label>\n <input\n type=\"radio\"\n id=\"fill-type-gradient\"\n name=\"fill-type\"\n value=\"gradient\"\n .checked=${this.fillType == 'gradient'}\n />\n <label for=\"fill-type-gradient\"><ox-i18n msgid=\"label.gradient\">gradient</ox-i18n></label>\n <input\n type=\"radio\"\n id=\"fill-type-pattern\"\n name=\"fill-type\"\n value=\"pattern\"\n .checked=${this.fillType == 'pattern'}\n />\n <label for=\"fill-type-pattern\"><ox-i18n msgid=\"label.pattern\">pattern</ox-i18n></label>\n </div>\n\n <div editors>\n <div ?active=${this.fillType == 'no'}></div>\n\n <div class=\"grid-10\" ?active=${this.fillType == 'solid'}>\n <label class=\"icon-only-label color\"></label>\n <ox-input-color @change=${(e: Event) => this._onChangedSolid(e)} .value=${this.solid}> </ox-input-color>\n </div>\n\n <div ?active=${this.fillType == 'gradient'}>\n <ox-input-color-gradient @change=${(e: Event) => this._onChandedGradient(e)} .value=${this.gradient}>\n </ox-input-color-gradient>\n </div>\n\n <div ?active=${this.fillType == 'pattern'}>\n <ox-input-background-pattern @change=${(e: Event) => this._onChangedPattern(e)} .value=${this.pattern}>\n </ox-input-background-pattern>\n </div>\n </div>\n `\n }\n\n async _onChangedValue(value: FillStyle) {\n /*\n * this._block_reset의 역할은 내부 사용자 인터렉션에 의한 value의 변경시에는 각 type별 이전값을 유지하기 위함이다.\n */\n await this.requestUpdate()\n\n /* 설정 값에 따라서, 멤버 속성을 설정한다. */\n if (!value) {\n this.fillType = 'no'\n\n if (!this._block_reset) {\n this.solid = undefined\n this.gradient = undefined\n this.pattern = undefined\n }\n\n this._block_reset = false\n return\n }\n\n switch (typeof value) {\n case 'string':\n this.fillType = 'solid'\n this.solid = value\n\n if (!this._block_reset) {\n this.gradient = undefined\n this.pattern = undefined\n }\n break\n case 'object':\n this.fillType = value.type\n\n if (value.type === 'gradient') {\n this.gradient = {\n type: value.gradientType || 'linear',\n colorStops: value.colorStops || [\n {\n position: 0,\n color: this.solid || '#000000'\n },\n {\n position: 1,\n color: this.solid || '#FFFFFF'\n }\n ],\n rotation: Number(value.rotation) || 0,\n center: value.center\n }\n\n if (!this._block_reset) {\n this.pattern = undefined\n this.solid = undefined\n }\n } else if (value.type === 'pattern') {\n this.pattern = {\n image: value.image,\n offsetX: Number(value.offsetX) || 0,\n offsetY: Number(value.offsetY) || 0,\n width: Number(value.width),\n height: Number(value.height),\n align: value.align,\n fitPattern: value.fitPattern\n }\n\n if (!this._block_reset) {\n this.gradient = undefined\n this.solid = undefined\n }\n }\n\n break\n default:\n }\n\n this._block_reset = false\n }\n\n _onChangedFillType(e: Event) {\n const element = e.target as HTMLInputElement\n this.fillType = element.value\n\n switch (this.fillType) {\n case 'gradient':\n if (!this.gradient) {\n this.gradient = {\n type: 'linear',\n colorStops: [\n {\n position: 0,\n color: this.solid || '#000000'\n },\n {\n position: 1,\n color: this.solid || '#FFFFFF'\n }\n ],\n rotation: 0,\n center: 'center'\n }\n }\n\n this.value = {\n type: 'gradient',\n gradientType: this.gradient.type || 'linear',\n colorStops: this.gradient.colorStops || [\n {\n position: 0,\n color: this.solid || '#000000'\n },\n {\n position: 1,\n color: this.solid || '#FFFFFF'\n }\n ],\n rotation: Number(this.gradient.rotation) || 0,\n center: this.gradient.center\n }\n break\n\n case 'pattern':\n if (!this.pattern) this.pattern = {}\n\n this.value = {\n type: 'pattern',\n image: this.pattern.image,\n offsetX: Number(this.pattern.offsetX) || 0,\n offsetY: Number(this.pattern.offsetY) || 0,\n width: Number(this.pattern.width),\n height: Number(this.pattern.height),\n align: this.pattern.align,\n fitPattern: this.pattern.fitPattern\n }\n break\n\n case 'solid':\n if (!this.solid) this.solid = '#fff'\n this.value = this.solid\n break\n\n case 'no':\n this.value = ''\n break\n }\n\n this._block_reset = true\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _onChangedSolid(e: Event) {\n if (this.fillType !== 'solid') return\n\n this.solid = (e.target as HTMLInputElement).value\n\n this.value = this.solid\n\n this._block_reset = true\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _onChandedGradient(e: Event) {\n /*\n * TODO Gradient의 rotation은 symmetry 기능 등으로 외부에서 변경될 수도 있다.\n * 이 점을 감안해서, 외부 변경에 대한 대응을 해야 한다.\n */\n\n if (this.fillType !== 'gradient') {\n return\n }\n\n this.gradient = (e.target as OxInputColorGradient).value\n\n this.value = {\n type: 'gradient',\n gradientType: this.gradient.type || 'linear',\n colorStops: this.gradient.colorStops || [\n {\n position: 0,\n color: this.solid || '#000000'\n },\n {\n position: 1,\n color: this.solid || '#FFFFFF'\n }\n ],\n rotation: Number(this.gradient.rotation) || 0,\n center: this.gradient.center\n }\n\n this._block_reset = true\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _onChangedPattern(e: Event) {\n if (this.fillType !== 'pattern') return\n\n this.pattern = (e.target as OxInputBackgroundPattern).value\n\n this.value = {\n type: 'pattern',\n image: this.pattern?.image,\n offsetX: Number(this.pattern?.offsetX) || 0,\n offsetY: Number(this.pattern?.offsetY) || 0,\n width: Number(this.pattern?.width),\n height: Number(this.pattern?.height),\n align: this.pattern?.align,\n fitPattern: this.pattern?.fitPattern\n }\n\n this._block_reset = true\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import './ox-input-color.js';
|
5
|
+
import { OxFormField } from './ox-form-field.js';
|
6
|
+
import { OxInputColor } from './ox-input-color.js';
|
7
|
+
/**
|
8
|
+
색상 배열을 편집하는 컴포넌트이다.
|
9
|
+
|
10
|
+
새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />
|
11
|
+
색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />
|
12
|
+
|
13
|
+
Example:
|
14
|
+
|
15
|
+
<ox-input-multiple-color values=${values}>
|
16
|
+
</ox-input-multiple-color>
|
17
|
+
*/
|
18
|
+
export declare class OxInputMultipleColors extends OxFormField {
|
19
|
+
static styles: import("lit").CSSResult;
|
20
|
+
value: string[];
|
21
|
+
colorsContainer: HTMLDivElement;
|
22
|
+
colors: NodeListOf<OxInputColor>;
|
23
|
+
firstUpdated(): void;
|
24
|
+
render(): import("lit-html").TemplateResult<1>;
|
25
|
+
_onValueChanged(): void;
|
26
|
+
_appendEditorColor(): void;
|
27
|
+
_removeEditorColor(e: Event): void;
|
28
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { __decorate } from "tslib";
|
5
|
+
import './ox-input-color.js';
|
6
|
+
import { css, html } from 'lit';
|
7
|
+
import { customElement, property, query, queryAll } from 'lit/decorators.js';
|
8
|
+
import { OxFormField } from './ox-form-field.js';
|
9
|
+
/**
|
10
|
+
색상 배열을 편집하는 컴포넌트이다.
|
11
|
+
|
12
|
+
새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />
|
13
|
+
색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />
|
14
|
+
|
15
|
+
Example:
|
16
|
+
|
17
|
+
<ox-input-multiple-color values=${values}>
|
18
|
+
</ox-input-multiple-color>
|
19
|
+
*/
|
20
|
+
let OxInputMultipleColors = class OxInputMultipleColors extends OxFormField {
|
21
|
+
constructor() {
|
22
|
+
super(...arguments);
|
23
|
+
this.value = [];
|
24
|
+
}
|
25
|
+
static { this.styles = css `
|
26
|
+
:host {
|
27
|
+
display: inline-block;
|
28
|
+
}
|
29
|
+
|
30
|
+
#colors-container > div {
|
31
|
+
display: grid;
|
32
|
+
grid-template-columns: 22px 1fr 22px;
|
33
|
+
grid-gap: 5px;
|
34
|
+
align-items: center;
|
35
|
+
justify-content: left;
|
36
|
+
}
|
37
|
+
|
38
|
+
ox-input-color {
|
39
|
+
height: 25px;
|
40
|
+
width: 100%;
|
41
|
+
}
|
42
|
+
|
43
|
+
input[type='button'] {
|
44
|
+
width: 22px;
|
45
|
+
height: 25px;
|
46
|
+
border: 1px solid rgba(0, 0, 0, 0.15);
|
47
|
+
padding-top: 0px;
|
48
|
+
padding-bottom: 2px;
|
49
|
+
background-color: #f1f2f4;
|
50
|
+
color: #8f9192;
|
51
|
+
font-size: 16px;
|
52
|
+
}
|
53
|
+
`; }
|
54
|
+
firstUpdated() {
|
55
|
+
this.renderRoot.addEventListener('change', this._onValueChanged.bind(this));
|
56
|
+
}
|
57
|
+
render() {
|
58
|
+
return html `
|
59
|
+
<div id="colors-container">
|
60
|
+
${(this.value || []).map((item, index) => html `
|
61
|
+
<div>
|
62
|
+
<input type="button" value="+" @click=${() => this._appendEditorColor()} data-index=${index} />
|
63
|
+
|
64
|
+
<ox-input-color .value=${item}> </ox-input-color>
|
65
|
+
|
66
|
+
${(this.value || []).length > 1
|
67
|
+
? html `
|
68
|
+
<input
|
69
|
+
type="button"
|
70
|
+
value="-"
|
71
|
+
@click=${(e) => this._removeEditorColor(e)}
|
72
|
+
data-index=${index}
|
73
|
+
/>
|
74
|
+
`
|
75
|
+
: html ``}
|
76
|
+
</div>
|
77
|
+
`)}
|
78
|
+
</div>
|
79
|
+
`;
|
80
|
+
}
|
81
|
+
_onValueChanged() {
|
82
|
+
this.value = Array.from(this.colors).map(color => color.value);
|
83
|
+
}
|
84
|
+
_appendEditorColor() {
|
85
|
+
this.value = [...this.value, 'black'];
|
86
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
87
|
+
}
|
88
|
+
_removeEditorColor(e) {
|
89
|
+
var values = [];
|
90
|
+
for (var i = 0; i < this.value.length; i++) {
|
91
|
+
if (i == Number(e.target.dataset.index))
|
92
|
+
continue;
|
93
|
+
else
|
94
|
+
values.push(this.value[i]);
|
95
|
+
}
|
96
|
+
this.value = values;
|
97
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
98
|
+
}
|
99
|
+
};
|
100
|
+
__decorate([
|
101
|
+
property({ type: Array })
|
102
|
+
], OxInputMultipleColors.prototype, "value", void 0);
|
103
|
+
__decorate([
|
104
|
+
query('#colors-container')
|
105
|
+
], OxInputMultipleColors.prototype, "colorsContainer", void 0);
|
106
|
+
__decorate([
|
107
|
+
queryAll('ox-input-color')
|
108
|
+
], OxInputMultipleColors.prototype, "colors", void 0);
|
109
|
+
OxInputMultipleColors = __decorate([
|
110
|
+
customElement('ox-input-multiple-colors')
|
111
|
+
], OxInputMultipleColors);
|
112
|
+
export { OxInputMultipleColors };
|
113
|
+
//# sourceMappingURL=ox-input-multiple-colors.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-multiple-colors.js","sourceRoot":"","sources":["../../src/ox-input-multiple-colors.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,qBAAqB,CAAA;AAE5B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA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,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAClF,CAAC;IAED,kBAAkB,CAAC,CAAQ;QACzB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC1C,IAAI,CAAC,IAAI,MAAM,CAAE,CAAC,CAAC,MAAsB,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAQ;;gBAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;SAChC;QAED,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA;QACnB,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;AAxD4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;oDAAqB;AAEnB;IAA3B,KAAK,CAAC,mBAAmB,CAAC;8DAAiC;AAChC;IAA3B,QAAQ,CAAC,gBAAgB,CAAC;qDAAkC;AAlClD,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAuFjC;SAvFY,qBAAqB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, queryAll } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field.js'\nimport { OxInputColor } from './ox-input-color.js'\n\n/**\n색상 배열을 편집하는 컴포넌트이다.\n\n새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />\n색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />\n\nExample:\n\n <ox-input-multiple-color values=${values}>\n </ox-input-multiple-color>\n*/\n\n@customElement('ox-input-multiple-colors')\nexport class OxInputMultipleColors extends OxFormField {\n static styles = css`\n :host {\n display: inline-block;\n }\n\n #colors-container > div {\n display: grid;\n grid-template-columns: 22px 1fr 22px;\n grid-gap: 5px;\n align-items: center;\n justify-content: left;\n }\n\n ox-input-color {\n height: 25px;\n width: 100%;\n }\n\n input[type='button'] {\n width: 22px;\n height: 25px;\n border: 1px solid rgba(0, 0, 0, 0.15);\n padding-top: 0px;\n padding-bottom: 2px;\n background-color: #f1f2f4;\n color: #8f9192;\n font-size: 16px;\n }\n `\n\n @property({ type: Array }) value: string[] = []\n\n @query('#colors-container') colorsContainer!: HTMLDivElement\n @queryAll('ox-input-color') colors!: NodeListOf<OxInputColor>\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n render() {\n return html`\n <div id=\"colors-container\">\n ${(this.value || []).map(\n (item, index) => html`\n <div>\n <input type=\"button\" value=\"+\" @click=${() => this._appendEditorColor()} data-index=${index} />\n\n <ox-input-color .value=${item}> </ox-input-color>\n\n ${(this.value || []).length > 1\n ? html`\n <input\n type=\"button\"\n value=\"-\"\n @click=${(e: Event) => this._removeEditorColor(e)}\n data-index=${index}\n />\n `\n : html``}\n </div>\n `\n )}\n </div>\n `\n }\n\n _onValueChanged() {\n this.value = Array.from(this.colors).map(color => color.value!)\n }\n\n _appendEditorColor() {\n this.value = [...this.value, 'black']\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n _removeEditorColor(e: Event) {\n var values = []\n for (var i = 0; i < this.value.length; i++) {\n if (i == Number((e.target as HTMLElement).dataset.index)) continue\n else values.push(this.value[i])\n }\n\n this.value = values\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { OxFormField } from './ox-form-field';
|
2
|
+
export declare class OxInputId extends OxFormField {
|
3
|
+
static styles: import("lit").CSSResult;
|
4
|
+
property: {
|
5
|
+
component?: string;
|
6
|
+
} | null | undefined;
|
7
|
+
_ids: Array<string>;
|
8
|
+
render(): import("lit-html").TemplateResult<1>;
|
9
|
+
_onInputFocused(e: FocusEvent): void;
|
10
|
+
_onInputChanged(e: InputEvent): void;
|
11
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { __decorate } from "tslib";
|
2
|
+
import { css, html } from 'lit';
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
4
|
+
import { OxFormField } from './ox-form-field';
|
5
|
+
let OxInputId = class OxInputId extends OxFormField {
|
6
|
+
constructor() {
|
7
|
+
super(...arguments);
|
8
|
+
this._ids = [];
|
9
|
+
}
|
10
|
+
static { this.styles = css `
|
11
|
+
:host {
|
12
|
+
position: relative;
|
13
|
+
display: inline-flex;
|
14
|
+
align-items: center;
|
15
|
+
justify-content: flex-end;
|
16
|
+
}
|
17
|
+
|
18
|
+
input {
|
19
|
+
width: 100%;
|
20
|
+
height: 100%;
|
21
|
+
box-sizing: border-box;
|
22
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
23
|
+
}
|
24
|
+
`; }
|
25
|
+
render() {
|
26
|
+
const ids = this._ids || [];
|
27
|
+
return html `
|
28
|
+
<input
|
29
|
+
id="text"
|
30
|
+
type="text"
|
31
|
+
.value=${this.value || ''}
|
32
|
+
@focusin=${(e) => this._onInputFocused(e)}
|
33
|
+
@change=${(e) => this._onInputChanged(e)}
|
34
|
+
.placeholder=${this.getAttribute('placeholder') || ''}
|
35
|
+
list="ids"
|
36
|
+
/>
|
37
|
+
|
38
|
+
<datalist id="ids">${ids.map(id => html ` <option value=${id}></option> `)}</datalist>
|
39
|
+
`;
|
40
|
+
}
|
41
|
+
_onInputFocused(e) {
|
42
|
+
var { component } = this.property || {};
|
43
|
+
document.dispatchEvent(new CustomEvent('get-all-scene-component-ids', {
|
44
|
+
detail: {
|
45
|
+
component,
|
46
|
+
callback: (ids) => {
|
47
|
+
this._ids = ids;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}));
|
51
|
+
}
|
52
|
+
_onInputChanged(e) {
|
53
|
+
e.stopPropagation();
|
54
|
+
this.value = e.target.value;
|
55
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
56
|
+
}
|
57
|
+
};
|
58
|
+
__decorate([
|
59
|
+
property({ type: Object })
|
60
|
+
], OxInputId.prototype, "property", void 0);
|
61
|
+
__decorate([
|
62
|
+
state()
|
63
|
+
], OxInputId.prototype, "_ids", void 0);
|
64
|
+
OxInputId = __decorate([
|
65
|
+
customElement('ox-input-scene-component-id')
|
66
|
+
], OxInputId);
|
67
|
+
export { OxInputId };
|
68
|
+
//# sourceMappingURL=ox-input-scene-component-id.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ox-input-scene-component-id.js","sourceRoot":"","sources":["../../src/ox-input-scene-component-id.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAG7C,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,WAAW;IAA1C;;QAmBW,SAAI,GAAkB,EAAE,CAAA;IA0CnC,CAAC;aA5DQ,WAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;GAclB,CAAA;IAMD,MAAM;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,EAAE,CAAA;QAE3B,OAAO,IAAI,CAAA;;;;iBAIE,IAAI,CAAC,KAAK,IAAI,EAAE;mBACd,CAAC,CAAa,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;kBAC3C,CAAC,CAAa,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;uBACrC,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE;;;;2BAIlC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAA,kBAAkB,EAAE,aAAa,CAAC;KAC1E,CAAA;IACH,CAAC;IAED,eAAe,CAAC,CAAa;QAC3B,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;QAEvC,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,6BAA6B,EAAE;YAC7C,MAAM,EAAE;gBACN,SAAS;gBACT,QAAQ,EAAE,CAAC,GAAa,EAAE,EAAE;oBAC1B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAA;gBACjB,CAAC;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;IAED,eAAe,CAAC,CAAa;QAC3B,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB,IAAI,CAAC,KAAK,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAA;QAEjD,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;AA5C6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAoD;AAEtE;IAAR,KAAK,EAAE;uCAAyB;AAnBtB,SAAS;IADrB,aAAa,CAAC,6BAA6B,CAAC;GAChC,SAAS,CA6DrB;SA7DY,SAAS","sourcesContent":["import { css, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\n@customElement('ox-input-scene-component-id')\nexport class OxInputId extends OxFormField {\n static styles = css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n }\n\n input {\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n border: 1px solid rgba(0, 0, 0, 0.2);\n }\n `\n\n @property({ type: Object }) property: { component?: string } | null | undefined\n\n @state() _ids: Array<string> = []\n\n render() {\n const ids = this._ids || []\n\n return html`\n <input\n id=\"text\"\n type=\"text\"\n .value=${this.value || ''}\n @focusin=${(e: FocusEvent) => this._onInputFocused(e)}\n @change=${(e: InputEvent) => this._onInputChanged(e)}\n .placeholder=${this.getAttribute('placeholder') || ''}\n list=\"ids\"\n />\n\n <datalist id=\"ids\">${ids.map(id => html` <option value=${id}></option> `)}</datalist>\n `\n }\n\n _onInputFocused(e: FocusEvent) {\n var { component } = this.property || {}\n\n document.dispatchEvent(\n new CustomEvent('get-all-scene-component-ids', {\n detail: {\n component,\n callback: (ids: string[]) => {\n this._ids = ids\n }\n }\n })\n )\n }\n\n _onInputChanged(e: InputEvent) {\n e.stopPropagation()\n\n this.value = (e.target as HTMLInputElement).value\n\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n}\n"]}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
4
|
import { OxFormField } from './ox-form-field';
|
5
|
-
export
|
5
|
+
export declare class OxInputStack extends OxFormField {
|
6
6
|
static styles: import("lit").CSSResult[];
|
7
7
|
/**
|
8
8
|
* `stack`은 stack에 의해 만들어진 층의 배열을 유지한다.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ox-input-stack.js","sourceRoot":"","sources":["../../src/ox-input-stack.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAA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CAAA;QAEnB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;QAE7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QAEzB,IAAI,CAAC,aAAa,EAAE,CAAA;QAEpB,IAAI,CAAC,aAAa,EAAE,CAAA;IACtB,CAAC;CACF,CAAA;AAlF4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;2CAAiD;AArChE,YAAY;IADxB,aAAa,CAAC,gBAAgB,CAAC;GACnB,YAAY,CAuHxB;SAvHY,YAAY","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { OxFormField } from './ox-form-field'\n\n@customElement('ox-input-stack')\nexport class OxInputStack extends OxFormField {\n static styles = [\n css`\n :host {\n display: block;\n }\n\n #add-floor {\n width: 100%;\n height: 20px;\n background-color: blue;\n color: white;\n }\n\n div {\n background-color: blue;\n width: calc(100% - 40px);\n width: -webkit-calc(100% - 40px);\n min-height: 20px;\n }\n\n div[active] {\n background-color: red;\n }\n\n div button {\n position: absolute;\n right: 10px;\n width: 30px;\n min-height: 20px;\n }\n `\n ]\n\n /**\n * `stack`은 stack에 의해 만들어진 층의 배열을 유지한다.\n */\n @property({ type: Array }) stack: { name: string; active?: boolean }[] = []\n\n /**\n * `activeIndex`은 현재 active된 층의 인덱스를 유지한다.\n */\n // @property({ type: Number }) activeIndex: number = 0\n\n render() {\n const stack = [...this.stack].reverse()\n const length = stack.length\n\n return html`\n <button id=\"add-floor\" @click=${(e: Event) => this._onClickAddFloor(e)}>+</button>\n\n ${stack.map(\n (item, index) => html`\n <div floor ?active=${item.active} @click=${(e: Event) => this._onClickToActive(e)} idx=${length - index - 1}>\n ${item.name} <button @click=${(e: Event) => this._onClickRemoveFloor(e)}>-</button>\n </div>\n `\n )}\n `\n }\n\n _notifyChange() {\n this.value = this.stack\n\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: this.value,\n bubbles: true,\n composed: true\n })\n )\n }\n\n _onClickAddFloor(e: Event) {\n this.stack.push({ name: String(this.stack.length + 1) })\n this.requestUpdate()\n\n this._notifyChange()\n }\n\n _onClickToActive(e: Event) {\n const floor = (e.target as HTMLElement).closest('[floor]')\n\n if (!floor) {\n return\n }\n\n e.stopPropagation()\n\n const activeIndex = Number(floor.getAttribute('idx'))\n this.stack = this.stack.map((floor, index) => {\n return activeIndex === index\n ? {\n name: floor.name,\n active: true\n }\n : { name: floor.name }\n })\n\n this._notifyChange()\n }\n\n _onClickRemoveFloor(e: Event) {\n const floor = (e.target as HTMLElement).closest('[floor]')\n\n if (!floor) {\n return\n }\n\n e.stopPropagation()\n\n const idx = Number(floor.getAttribute('idx'))\n\n this.stack.splice(idx, 1)\n\n this.requestUpdate()\n\n this._notifyChange()\n }\n}\n"]}
|