@operato/input 1.0.0-alpha.10 → 1.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/assets/images/icon-properties-line-type.png +0 -0
  3. package/assets/images/icon-properties-table.png +0 -0
  4. package/demo/index-table.html +39 -0
  5. package/demo/index-value-map.html +80 -0
  6. package/demo/index-value-ranges.html +80 -0
  7. package/demo/index.html +3 -0
  8. package/dist/src/index.d.ts +6 -3
  9. package/dist/src/index.js +6 -3
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/ox-input-multiple-colors.d.ts +2 -2
  12. package/dist/src/ox-input-multiple-colors.js +2 -2
  13. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  14. package/dist/src/ox-input-table.d.ts +8 -0
  15. package/dist/src/ox-input-table.js +379 -0
  16. package/dist/src/ox-input-table.js.map +1 -0
  17. package/dist/src/ox-input-value-map.d.ts +41 -0
  18. package/dist/src/ox-input-value-map.js +278 -0
  19. package/dist/src/ox-input-value-map.js.map +1 -0
  20. package/dist/src/ox-input-value-ranges.d.ts +41 -0
  21. package/dist/src/ox-input-value-ranges.js +298 -0
  22. package/dist/src/ox-input-value-ranges.js.map +1 -0
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +12 -6
  25. package/src/index.ts +6 -3
  26. package/src/ox-input-multiple-colors.ts +2 -2
  27. package/src/ox-input-table.ts +404 -0
  28. package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +117 -88
  29. package/src/ox-input-value-ranges.ts +325 -0
  30. package/src/ox-input-background-pattern.ts.xxx +0 -163
  31. package/src/ox-input-color-gradient.ts.xxx +0 -343
  32. package/src/ox-input-fill-style.ts.xxx +0 -361
  33. package/src/ox-input-ranges.ts.ing +0 -292
@@ -0,0 +1,278 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import './ox-input-color';
6
+ import { LitElement, css, html } from 'lit';
7
+ import { customElement, property } from 'lit/decorators.js';
8
+ /**
9
+ key-value map editor element
10
+
11
+ Example:
12
+
13
+ <ox-input-value-map
14
+ value=${map}
15
+ keytype=${keytype}
16
+ valuetype=${valuetype}>
17
+ </ox-input-value-map>
18
+ */
19
+ let OxInputValueMap = class OxInputValueMap extends LitElement {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.value = {};
23
+ this.valuetype = 'string';
24
+ this.keytype = 'string';
25
+ this._changingNow = false;
26
+ }
27
+ static { this.styles = css `
28
+ :host {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-content: center;
32
+
33
+ width: 100%;
34
+ overflow: hidden;
35
+ border: 1px solid #ccc;
36
+ }
37
+
38
+ div {
39
+ display: flex;
40
+ flex-flow: row nowrap;
41
+ align-items: center;
42
+
43
+ border-bottom: 1px solid #c0c0c0;
44
+ }
45
+
46
+ div:last-child {
47
+ border-bottom: none;
48
+ }
49
+
50
+ div > * {
51
+ min-width: 0px;
52
+ margin: 2px;
53
+ padding: 0;
54
+ }
55
+
56
+ button {
57
+ width: 20px;
58
+ text-align: center;
59
+ }
60
+
61
+ input,
62
+ ox-input-color {
63
+ flex: 1;
64
+ }
65
+
66
+ ox-input-color {
67
+ --ox-input-color-input-color: {
68
+ margin: 1px;
69
+ }
70
+ --ox-input-color-input-span: {
71
+ width: 10px;
72
+ height: 10px;
73
+ }
74
+ }
75
+
76
+ input[type='checkbox'] {
77
+ width: initial;
78
+ }
79
+ `; }
80
+ firstUpdated() {
81
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
82
+ }
83
+ render() {
84
+ return html `
85
+ ${this._toArray(this.value).map(item => html `
86
+ <div data-record>
87
+ <input type="text" data-key placeholder="key" .value=${item.key} />
88
+ ${this.valuetype == 'boolean'
89
+ ? html ` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
90
+ : this.valuetype == 'color'
91
+ ? html ` <ox-input-color data-value .value=${item.value} tabindex="-1"> </ox-input-color> `
92
+ : html `
93
+ <input
94
+ type="text"
95
+ data-value
96
+ placeholder="value"
97
+ .value=${item.value}
98
+ data-value-type=${this.valuetype}
99
+ />
100
+ `} <button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">-</button>
101
+ </div>
102
+ `)}
103
+
104
+ <div data-record-new>
105
+ <input type="text" data-key placeholder="key" value="" /> ${this.valuetype == 'boolean'
106
+ ? html ` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
107
+ : this.valuetype == 'color'
108
+ ? html ` <ox-input-color data-value value="" tabindex="-1" placeholder="value"> </ox-input-color> `
109
+ : html ` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
110
+ <button class="record-action" @click=${(e) => this._add()} tabindex="-1">+</button>
111
+ </div>
112
+
113
+ <div data-record>
114
+ <input type="text" data-key data-default="" value="default" disabled /> ${this.valuetype == 'boolean'
115
+ ? html `
116
+ <input
117
+ type="checkbox"
118
+ data-value
119
+ .checked=${this.value && this.value.default}
120
+ data-value-type=${this.valuetype}
121
+ />
122
+ `
123
+ : this.valuetype == 'color'
124
+ ? html `
125
+ <ox-input-color
126
+ data-value
127
+ .value=${(this.value && this.value.default) || ''}
128
+ placeholder="value"
129
+ tabindex="-1"
130
+ >
131
+ </ox-input-color>
132
+ `
133
+ : html `
134
+ <input
135
+ type="text"
136
+ data-value
137
+ placeholder="value"
138
+ .value=${(this.value && this.value.default) || ''}
139
+ data-value-type=${this.valuetype}
140
+ />
141
+ `} <button class="record-action" @click=${() => this._sort()} tabindex="-1">&gt;</button>
142
+ </div>
143
+ `;
144
+ }
145
+ _defaultValue(type) {
146
+ switch (type || this.valuetype) {
147
+ case 'color':
148
+ return '#000000';
149
+ case 'boolean':
150
+ case 'checkbox':
151
+ return false;
152
+ default:
153
+ return '';
154
+ }
155
+ }
156
+ _onChange(e) {
157
+ if (this._changingNow) {
158
+ return;
159
+ }
160
+ this._changingNow = true;
161
+ const input = e.target;
162
+ var value;
163
+ if (input.type == 'checkbox') {
164
+ value = Boolean(input.checked);
165
+ }
166
+ else {
167
+ value = input.value;
168
+ }
169
+ const div = input.parentElement;
170
+ if (div.hasAttribute('data-record')) {
171
+ var dataList = div.querySelectorAll('[data-value]:not([hidden])');
172
+ for (var i = 0; i < dataList.length; i++) {
173
+ if (dataList[i] !== input) {
174
+ dataList[i].value = value || this._defaultValue();
175
+ }
176
+ }
177
+ }
178
+ if (div.hasAttribute('data-record')) {
179
+ this._build();
180
+ }
181
+ else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
182
+ this._add();
183
+ }
184
+ this._changingNow = false;
185
+ }
186
+ _build(includeNewRecord) {
187
+ if (includeNewRecord) {
188
+ var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
189
+ }
190
+ else {
191
+ var records = this.renderRoot.querySelectorAll('[data-record]');
192
+ }
193
+ var newmap = {};
194
+ for (var i = 0; i < records.length; i++) {
195
+ var record = records[i];
196
+ const key = record.querySelector('[data-key]').value;
197
+ const inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])');
198
+ if (!inputs || inputs.length == 0) {
199
+ continue;
200
+ }
201
+ var input = inputs[inputs.length - 1];
202
+ var value;
203
+ if (input.type == 'checkbox') {
204
+ value = Boolean(input.checked);
205
+ }
206
+ else {
207
+ value = input.value;
208
+ }
209
+ if (key) {
210
+ newmap[key] = value || this._defaultValue();
211
+ }
212
+ }
213
+ this.value = newmap;
214
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
215
+ }
216
+ /* default를 제외한 map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
217
+ _toArray(map) {
218
+ var array = [];
219
+ for (var key in map) {
220
+ if (key == 'default')
221
+ continue;
222
+ array.push({
223
+ key: key,
224
+ value: map[key]
225
+ });
226
+ }
227
+ return array;
228
+ }
229
+ _sort() {
230
+ const sorter = this.keytype === 'number'
231
+ ? function (a, b) {
232
+ return parseFloat(b.key) < parseFloat(a.key) ? 1 : -1;
233
+ }
234
+ : function (a, b) {
235
+ return b.key < a.key ? 1 : -1;
236
+ };
237
+ var map = this._toArray(this.value)
238
+ .sort(sorter)
239
+ .reduce(function (sum, i) {
240
+ sum[i.key] = i.value;
241
+ return sum;
242
+ }, {});
243
+ map.default = this.value.default;
244
+ this.value = map;
245
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
246
+ }
247
+ _add() {
248
+ this._build(true);
249
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])');
250
+ for (var i = 0; i < inputs.length; i++) {
251
+ let input = inputs[i];
252
+ if (input.type == 'checkbox')
253
+ input.checked = false;
254
+ else
255
+ input.value = this._defaultValue(input.type);
256
+ }
257
+ inputs[0].focus();
258
+ }
259
+ _delete(e) {
260
+ const record = e.target.parentElement;
261
+ record.querySelector('[data-key]').value = '';
262
+ this._build();
263
+ }
264
+ };
265
+ __decorate([
266
+ property({ type: Object })
267
+ ], OxInputValueMap.prototype, "value", void 0);
268
+ __decorate([
269
+ property({ type: String })
270
+ ], OxInputValueMap.prototype, "valuetype", void 0);
271
+ __decorate([
272
+ property({ type: String })
273
+ ], OxInputValueMap.prototype, "keytype", void 0);
274
+ OxInputValueMap = __decorate([
275
+ customElement('ox-input-value-map')
276
+ ], OxInputValueMap);
277
+ export { OxInputValueMap };
278
+ //# sourceMappingURL=ox-input-value-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-input-value-map.js","sourceRoot":"","sources":["../../src/ox-input-value-map.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAK3D;;;;;;;;;;EAUE;AAEF,IAAa,eAAe,GAA5B,M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AI,KAAK,CAAC,IAAI,IAAI,UAAU;gBAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAA;;gBAC9C,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;SAClD;QAED,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAED,OAAO,CAAC,CAAa;QACnB,MAAM,MAAM,GAAI,CAAC,CAAC,MAAsB,CAAC,aAAa,CAErD;QAAC,MAAO,CAAC,aAAa,CAAC,YAAY,CAAuB,CAAC,KAAK,GAAG,EAAE,CAAA;QAEtE,IAAI,CAAC,MAAM,EAAE,CAAA;IACf,CAAC;CACF,CAAA;AAlO6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAA8D;AAC7D;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAA4D;AAzD5E,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAyR3B;SAzRY,eAAe","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-input-color'\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\ntype ValueMap = { default?: any; [key: string]: any }\ntype ArrayedValueMap = { key: string; value: any }\n\n/**\nkey-value map editor element\n\nExample:\n\n <ox-input-value-map \n value=${map}\n keytype=${keytype}\n valuetype=${valuetype}>\n </ox-input-value-map>\n*/\n@customElement('ox-input-value-map')\nexport class OxInputValueMap extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: column;\n align-content: center;\n\n width: 100%;\n overflow: hidden;\n border: 1px solid #ccc;\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n border-bottom: 1px solid #c0c0c0;\n }\n\n div:last-child {\n border-bottom: none;\n }\n\n div > * {\n min-width: 0px;\n margin: 2px;\n padding: 0;\n }\n\n button {\n width: 20px;\n text-align: center;\n }\n\n input,\n ox-input-color {\n flex: 1;\n }\n\n ox-input-color {\n --ox-input-color-input-color: {\n margin: 1px;\n }\n --ox-input-color-input-span: {\n width: 10px;\n height: 10px;\n }\n }\n\n input[type='checkbox'] {\n width: initial;\n }\n `\n\n @property({ type: Object }) value: ValueMap = {}\n @property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | string = 'string'\n @property({ type: String }) keytype: 'string' | 'boolean' | 'color' | string = 'string'\n\n private _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n return html`\n ${this._toArray(this.value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-key placeholder=\"key\" .value=${item.key} />\n ${this.valuetype == 'boolean'\n ? html` <input type=\"checkbox\" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `\n : this.valuetype == 'color'\n ? html` <ox-input-color data-value .value=${item.value} tabindex=\"-1\"> </ox-input-color> `\n : html`\n <input\n type=\"text\"\n data-value\n placeholder=\"value\"\n .value=${item.value}\n data-value-type=${this.valuetype}\n />\n `} <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-key placeholder=\"key\" value=\"\" /> ${this.valuetype == 'boolean'\n ? html` <input type=\"checkbox\" data-value data-value-type=${this.valuetype} /> `\n : this.valuetype == 'color'\n ? html` <ox-input-color data-value value=\"\" tabindex=\"-1\" placeholder=\"value\"> </ox-input-color> `\n : html` <input type=\"text\" data-value placeholder=\"value\" value=\"\" data-value-type=${this.valuetype} /> `}\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._add()} tabindex=\"-1\">+</button>\n </div>\n\n <div data-record>\n <input type=\"text\" data-key data-default=\"\" value=\"default\" disabled /> ${this.valuetype == 'boolean'\n ? html`\n <input\n type=\"checkbox\"\n data-value\n .checked=${this.value && this.value.default}\n data-value-type=${this.valuetype}\n />\n `\n : this.valuetype == 'color'\n ? html`\n <ox-input-color\n data-value\n .value=${(this.value && this.value.default) || ''}\n placeholder=\"value\"\n tabindex=\"-1\"\n >\n </ox-input-color>\n `\n : html`\n <input\n type=\"text\"\n data-value\n placeholder=\"value\"\n .value=${(this.value && this.value.default) || ''}\n data-value-type=${this.valuetype}\n />\n `} <button class=\"record-action\" @click=${() => this._sort()} tabindex=\"-1\">&gt;</button>\n </div>\n `\n }\n\n _defaultValue(type?: 'string' | 'boolean' | 'color' | string) {\n switch (type || this.valuetype) {\n case 'color':\n return '#000000'\n case 'boolean':\n case 'checkbox':\n return false\n default:\n return ''\n }\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n const input = e.target as HTMLInputElement\n var value\n\n if (input.type == 'checkbox') {\n value = Boolean(input.checked)\n } else {\n value = input.value\n }\n\n const div = input.parentElement as HTMLDivElement\n\n if (div.hasAttribute('data-record')) {\n var dataList = div.querySelectorAll('[data-value]:not([hidden])') as NodeListOf<HTMLElement & { value: any }>\n\n for (var i = 0; i < dataList.length; i++) {\n if (dataList[i] !== input) {\n dataList[i].value = value || this._defaultValue()\n }\n }\n }\n\n if (div.hasAttribute('data-record')) {\n this._build()\n } else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) {\n var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>\n } else {\n var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>\n }\n\n var newmap: ValueMap = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n const key = (record.querySelector('[data-key]') as HTMLInputElement).value\n const inputs = record.querySelectorAll('[data-value]:not([style*=\"display: none\"])') as NodeListOf<\n HTMLInputElement & { value: any }\n >\n\n if (!inputs || inputs.length == 0) {\n continue\n }\n\n var input = inputs[inputs.length - 1]\n\n var value\n\n if (input.type == 'checkbox') {\n value = Boolean(input.checked)\n } else {\n value = input.value\n }\n\n if (key) {\n newmap[key] = value || this._defaultValue()\n }\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n /* default를 제외한 map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: ValueMap) {\n var array: ArrayedValueMap[] = []\n\n for (var key in map) {\n if (key == 'default') continue\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _sort() {\n const sorter =\n this.keytype === 'number'\n ? function (a: ArrayedValueMap, b: ArrayedValueMap) {\n return parseFloat(b.key) < parseFloat(a.key) ? 1 : -1\n }\n : function (a: ArrayedValueMap, b: ArrayedValueMap) {\n return b.key < a.key ? 1 : -1\n }\n\n var map = this._toArray(this.value)\n .sort(sorter)\n .reduce(function (sum, i) {\n sum[i.key] = i.value\n return sum\n }, {} as ValueMap)\n\n map.default = this.value.default\n\n this.value = map\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))\n }\n\n _add() {\n this._build(true)\n\n const inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement & { value: any }>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n\n if (input.type == 'checkbox') input.checked = false\n else input.value = this._defaultValue(input.type)\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n const record = (e.target as HTMLElement).parentElement\n\n ;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''\n\n this._build()\n }\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import './ox-input-color';
5
+ import { OxFormField } from './ox-form-field.js';
6
+ declare type ValueRange = {
7
+ default?: any;
8
+ [fromto: string]: any;
9
+ };
10
+ declare type ArrayedRange = {
11
+ from: any;
12
+ to: any;
13
+ value: any;
14
+ };
15
+ /**
16
+ range value editor element
17
+
18
+ Example:
19
+
20
+ <ox-input-value-ranges
21
+ .value=${range}
22
+ valuetype=${type}
23
+ </ox-input-value-ranges>
24
+ */
25
+ export declare class OxInputValueRange extends OxFormField {
26
+ static styles: import("lit").CSSResult;
27
+ value: ValueRange;
28
+ valuetype: 'string' | 'boolean' | 'color' | string;
29
+ rangetype: 'string' | 'boolean' | 'color' | string;
30
+ private _changingNow;
31
+ firstUpdated(): void;
32
+ render(): import("lit-html").TemplateResult<1>;
33
+ _defaultValue(type: 'color' | 'boolean' | 'checkbox' | string): false | "" | "#000000";
34
+ _onChange(e: Event): void;
35
+ _build(includeNewRecord?: boolean): void;
36
+ _toArray(range: ValueRange): ArrayedRange[];
37
+ _sort(): void;
38
+ _add(): void;
39
+ _delete(e: Event): void;
40
+ }
41
+ export {};
@@ -0,0 +1,298 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import './ox-input-color';
6
+ import { css, html } from 'lit';
7
+ import { customElement, property } from 'lit/decorators.js';
8
+ import { OxFormField } from './ox-form-field.js';
9
+ /**
10
+ range value editor element
11
+
12
+ Example:
13
+
14
+ <ox-input-value-ranges
15
+ .value=${range}
16
+ valuetype=${type}
17
+ </ox-input-value-ranges>
18
+ */
19
+ let OxInputValueRange = class OxInputValueRange extends OxFormField {
20
+ constructor() {
21
+ super(...arguments);
22
+ this.value = {};
23
+ this.valuetype = 'string';
24
+ this.rangetype = 'number';
25
+ this._changingNow = false;
26
+ }
27
+ static { this.styles = css `
28
+ :host {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-content: center;
32
+
33
+ width: 100%;
34
+ overflow: hidden;
35
+ border: 1px solid #ccc;
36
+ }
37
+
38
+ div {
39
+ display: flex;
40
+ flex-flow: row nowrap;
41
+ align-items: center;
42
+
43
+ border-bottom: 1px solid #c0c0c0;
44
+ }
45
+
46
+ div:last-child {
47
+ border-bottom: none;
48
+ }
49
+
50
+ div > * {
51
+ min-width: 0px;
52
+ margin: 2px;
53
+ padding: 0;
54
+ }
55
+
56
+ button {
57
+ width: 20px;
58
+ text-align: center;
59
+ }
60
+
61
+ input,
62
+ ox-input-color {
63
+ flex: 1;
64
+ }
65
+
66
+ ox-input-color {
67
+ --things-editor-color-input-color: {
68
+ margin: 2px;
69
+ }
70
+ --things-editor-color-input-span: {
71
+ width: 12px;
72
+ height: 12px;
73
+ }
74
+ }
75
+
76
+ [placeholder='value'] {
77
+ flex: 2;
78
+ }
79
+
80
+ div {
81
+ border-bottom: 1px solid #c0c0c0;
82
+ }
83
+
84
+ div:last-child {
85
+ border-bottom: none;
86
+ }
87
+
88
+ input[type='checkbox'] {
89
+ width: initial;
90
+ }
91
+ `; }
92
+ firstUpdated() {
93
+ this.renderRoot.addEventListener('change', this._onChange.bind(this));
94
+ }
95
+ render() {
96
+ return html `
97
+ ${this._toArray(this.value).map(item => html `
98
+ <div data-record>
99
+ <input type="text" data-from placeholder="<=" .value=${item.from} />
100
+ <input type="text" data-to placeholder="&gt;" .value=${item.to} />
101
+
102
+ ${this.valuetype == 'boolean'
103
+ ? html ` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
104
+ : this.valuetype == 'color'
105
+ ? html ` <ox-input-color data-value .value=${item.value}> </ox-input-color> `
106
+ : html `
107
+ <input
108
+ type="text"
109
+ data-value
110
+ placeholder="value"
111
+ .value=${item.value}
112
+ data-value-type=${this.valuetype}
113
+ />
114
+ `} <button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">-</button>
115
+ </div>
116
+ `)}
117
+
118
+ <div data-record-new>
119
+ <input type="text" data-from placeholder="<=" value="" />
120
+ <input type="text" data-to placeholder="&gt;" value="" />
121
+
122
+ ${this.valuetype == 'boolean'
123
+ ? html ` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
124
+ : this.valuetype == 'color'
125
+ ? html ` <ox-input-color data-value value="" placeholder="value"> </ox-input-color> `
126
+ : html ` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
127
+ <button class="record-action" @click=${(e) => this._add()} tabindex="-1">+</button>
128
+ </div>
129
+
130
+ <div data-record>
131
+ <input type="text" data-from data-default="" disabled value="default" />
132
+ <input type="text" data-to placeholder="&gt;" value="" hidden />
133
+
134
+ ${this.valuetype == 'boolean'
135
+ ? html `
136
+ <input
137
+ type="checkbox"
138
+ data-value
139
+ .checked=${this.value && this.value.default}
140
+ data-value-type=${this.valuetype}
141
+ />
142
+ `
143
+ : this.valuetype == 'color'
144
+ ? html `
145
+ <ox-input-color data-value .value=${(this.value && this.value.default) || ''} placeholder="value">
146
+ </ox-input-color>
147
+ `
148
+ : html `
149
+ <input
150
+ type="text"
151
+ data-value
152
+ .value=${(this.value && this.value.default) || ''}
153
+ placeholder="value"
154
+ class="default-value"
155
+ data-value-type=${this.valuetype}
156
+ />
157
+ `} <button class="record-action" @click=${(e) => this._sort()}>&gt;</button>
158
+ </div>
159
+ `;
160
+ }
161
+ _defaultValue(type) {
162
+ switch (type || this.valuetype) {
163
+ case 'color':
164
+ return '#000000';
165
+ case 'boolean':
166
+ case 'checkbox':
167
+ return false;
168
+ default:
169
+ return '';
170
+ }
171
+ }
172
+ _onChange(e) {
173
+ if (this._changingNow) {
174
+ return;
175
+ }
176
+ this._changingNow = true;
177
+ const input = e.target;
178
+ var value = input.type === 'checkbox' ? Boolean(input.checked) : input.value;
179
+ const div = input.parentElement;
180
+ if (input.hasAttribute('data-value')) {
181
+ const dataList = div.querySelectorAll('[data-value]:not([hidden])');
182
+ for (var i = 0; i < dataList.length; i++) {
183
+ if (dataList[i] !== input) {
184
+ dataList[i].value = value;
185
+ }
186
+ }
187
+ }
188
+ if (div.hasAttribute('data-record')) {
189
+ this._build();
190
+ }
191
+ else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
192
+ this._add();
193
+ }
194
+ this._changingNow = false;
195
+ }
196
+ _build(includeNewRecord) {
197
+ if (includeNewRecord) {
198
+ var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
199
+ }
200
+ else {
201
+ var records = this.renderRoot.querySelectorAll('[data-record]');
202
+ }
203
+ var newrange = {};
204
+ for (var i = 0; i < records.length; i++) {
205
+ const record = records[i];
206
+ const from = record.querySelector('[data-from]').value;
207
+ const to = record.querySelector('[data-to]').value;
208
+ const inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])');
209
+ if (!inputs || inputs.length == 0) {
210
+ continue;
211
+ }
212
+ var input = inputs[inputs.length - 1];
213
+ var value;
214
+ if (input.type == 'checkbox') {
215
+ value = Boolean(input.checked);
216
+ }
217
+ else {
218
+ value = input.value;
219
+ }
220
+ if (from) {
221
+ if (from === 'default')
222
+ newrange['default'] = value || (this.valuetype == 'color' ? '#000000' : '');
223
+ else
224
+ newrange[`${from}~${to}`] = value;
225
+ }
226
+ }
227
+ this.value = newrange;
228
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
229
+ }
230
+ /* default를 제외한 range아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
231
+ _toArray(range) {
232
+ var array = [];
233
+ for (var key in range) {
234
+ if (key == 'default') {
235
+ continue;
236
+ }
237
+ const fromto = key.split('~');
238
+ array.push({
239
+ from: fromto[0],
240
+ to: fromto[1],
241
+ value: range[key]
242
+ });
243
+ }
244
+ return array;
245
+ }
246
+ _sort() {
247
+ const sorter = this.rangetype === 'number'
248
+ ? function (a, b) {
249
+ return parseFloat(b.from) < parseFloat(a.from) ? 1 : -1;
250
+ }
251
+ : function (a, b) {
252
+ return b.from < a.from ? 1 : -1;
253
+ };
254
+ var range = this._toArray(this.value)
255
+ .sort(sorter)
256
+ .reduce(function (sum, i) {
257
+ sum[`${i.from}~${i.to}`] = i.value;
258
+ return sum;
259
+ }, {});
260
+ range.default = this.value.default;
261
+ this.value = range;
262
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }));
263
+ }
264
+ _add() {
265
+ this._build(true);
266
+ const inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])');
267
+ for (var i = 0; i < inputs.length; i++) {
268
+ let input = inputs[i];
269
+ if (input.type == 'checkbox') {
270
+ input.checked = false;
271
+ }
272
+ else {
273
+ input.value = this._defaultValue(input.type);
274
+ }
275
+ }
276
+ inputs[0].focus();
277
+ }
278
+ _delete(e) {
279
+ const record = e.target.parentElement;
280
+ const dataFrom = record.querySelector('[data-from]');
281
+ dataFrom.value = '';
282
+ this._build();
283
+ }
284
+ };
285
+ __decorate([
286
+ property({ type: Object })
287
+ ], OxInputValueRange.prototype, "value", void 0);
288
+ __decorate([
289
+ property({ type: String })
290
+ ], OxInputValueRange.prototype, "valuetype", void 0);
291
+ __decorate([
292
+ property({ type: String })
293
+ ], OxInputValueRange.prototype, "rangetype", void 0);
294
+ OxInputValueRange = __decorate([
295
+ customElement('ox-input-value-ranges')
296
+ ], OxInputValueRange);
297
+ export { OxInputValueRange };
298
+ //# sourceMappingURL=ox-input-value-ranges.js.map