@operato/scene-i18n 0.0.4
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 +16 -0
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/src/editors/editor-i18n.d.ts +32 -0
- package/dist/src/editors/editor-i18n.js +165 -0
- package/dist/src/editors/editor-i18n.js.map +1 -0
- package/dist/src/editors/index.d.ts +6 -0
- package/dist/src/editors/index.js +11 -0
- package/dist/src/editors/index.js.map +1 -0
- package/dist/src/editors/property-editor-i18n.d.ts +5 -0
- package/dist/src/editors/property-editor-i18n.js +15 -0
- package/dist/src/editors/property-editor-i18n.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/label.d.ts +19 -0
- package/dist/src/label.js +44 -0
- package/dist/src/label.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/helps/scene/component/label.md +18 -0
- package/package.json +65 -0
- package/src/editors/editor-i18n.ts +175 -0
- package/src/editors/index.ts +11 -0
- package/src/editors/property-editor-i18n.ts +12 -0
- package/src/index.ts +1 -0
- package/src/label.ts +51 -0
- package/templates/index.js +3 -0
- package/templates/label.js +17 -0
- package/templates/scene-label.png +0 -0
- package/things-scene.config.js +7 -0
- package/translations/en.json +6 -0
- package/translations/ko.json +6 -0
- package/translations/ms.json +6 -0
- package/translations/zh.json +6 -0
- package/tsconfig.json +22 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### [0.0.4](https://github.com/hatiolab/things-factory/compare/v0.0.3...v0.0.4) (2021-12-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* add @operato/scene-i18n ([92d14ff](https://github.com/hatiolab/things-factory/commit/92d14ff4bcacfb920e39470cf7537ab7560844f1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### :bug: Bug Fix
|
|
15
|
+
|
|
16
|
+
* things-scene upgrade ([9e2c0b8](https://github.com/hatiolab/things-factory/commit/9e2c0b85b1aacb0a4ef656866259879a20cd5de4))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Hearty, Oh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## build
|
|
2
|
+
|
|
3
|
+
`$ yarn build`
|
|
4
|
+
|
|
5
|
+
| type | filename | for | tested |
|
|
6
|
+
| ---- | ------------------------------------------ | -------------- | ------ |
|
|
7
|
+
| UMD | things-scene-scene-i18n.js | modern browser | O |
|
|
8
|
+
| UMD | things-scene-scene-i18n-ie.js | ie 11 | O |
|
|
9
|
+
| ESM | things-scene-scene-i18n.mjs | modern browser | O |
|
|
10
|
+
|
|
11
|
+
## publish
|
|
12
|
+
|
|
13
|
+
`$ yarn publish`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { LitElement } from 'lit';
|
|
5
|
+
/**
|
|
6
|
+
multiple language editor element
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
|
|
10
|
+
<editor-i18n value=${map}>
|
|
11
|
+
</editor-i18n>
|
|
12
|
+
*/
|
|
13
|
+
export default class EditorI18n extends LitElement {
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
value: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
_inputs?: Array<HTMLInputElement>;
|
|
19
|
+
_changingNow: boolean;
|
|
20
|
+
firstUpdated(): void;
|
|
21
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
22
|
+
_onChange(e: Event): void;
|
|
23
|
+
_build(includeNewRecord?: boolean): void;
|
|
24
|
+
_toArray(map: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}): {
|
|
27
|
+
key: string;
|
|
28
|
+
value: any;
|
|
29
|
+
}[];
|
|
30
|
+
_add(): void;
|
|
31
|
+
_delete(e: MouseEvent): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import { LitElement, css, html } from 'lit';
|
|
6
|
+
import { customElement, property, queryAll, state } from 'lit/decorators.js';
|
|
7
|
+
/**
|
|
8
|
+
multiple language editor element
|
|
9
|
+
|
|
10
|
+
Example:
|
|
11
|
+
|
|
12
|
+
<editor-i18n value=${map}>
|
|
13
|
+
</editor-i18n>
|
|
14
|
+
*/
|
|
15
|
+
let EditorI18n = class EditorI18n extends LitElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.value = {};
|
|
19
|
+
this._changingNow = false;
|
|
20
|
+
}
|
|
21
|
+
firstUpdated() {
|
|
22
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this));
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return html `
|
|
26
|
+
<datalist id="language-list">
|
|
27
|
+
<option value="en">English</option>
|
|
28
|
+
<option value="ko">한국어</option>
|
|
29
|
+
<option value="zh">中文</option>
|
|
30
|
+
<option value="ms">Bahasa Malaysia</option>
|
|
31
|
+
</datalist>
|
|
32
|
+
|
|
33
|
+
${this._toArray(this.value).map(item => html `
|
|
34
|
+
<div data-record>
|
|
35
|
+
<input type="text" data-lng placeholder="language" .value=${item.key} list="language-list" />
|
|
36
|
+
<input type="text" data-term placeholder="term" .value=${item.value} />
|
|
37
|
+
<button class="record-action" @click=${(e) => this._delete(e)} tabindex="-1">x</button>
|
|
38
|
+
</div>
|
|
39
|
+
`)}
|
|
40
|
+
|
|
41
|
+
<div data-record-new>
|
|
42
|
+
<input type="text" data-lng placeholder="language" value="" list="language-list" />
|
|
43
|
+
<input type="text" data-term placeholder="term" value="" />
|
|
44
|
+
<button class="record-action" @click=${() => this._add()} tabindex="-1">+</button>
|
|
45
|
+
</div>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
_onChange(e) {
|
|
49
|
+
if (this._changingNow) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this._changingNow = true;
|
|
53
|
+
var input = e.target;
|
|
54
|
+
var value = input.value;
|
|
55
|
+
var div = input.parentElement;
|
|
56
|
+
if (div.hasAttribute('data-record')) {
|
|
57
|
+
this._build();
|
|
58
|
+
}
|
|
59
|
+
else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-term')) {
|
|
60
|
+
this._add();
|
|
61
|
+
}
|
|
62
|
+
this._changingNow = false;
|
|
63
|
+
}
|
|
64
|
+
_build(includeNewRecord) {
|
|
65
|
+
var _a;
|
|
66
|
+
if (includeNewRecord)
|
|
67
|
+
var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
|
|
68
|
+
else
|
|
69
|
+
var records = this.renderRoot.querySelectorAll('[data-record]');
|
|
70
|
+
var newmap = {};
|
|
71
|
+
for (var i = 0; i < records.length; i++) {
|
|
72
|
+
var record = records[i];
|
|
73
|
+
var key = (_a = record.querySelector('[data-lng]')) === null || _a === void 0 ? void 0 : _a.value;
|
|
74
|
+
var input = record.querySelector('[data-term]');
|
|
75
|
+
if (!input)
|
|
76
|
+
continue;
|
|
77
|
+
var value = input.value;
|
|
78
|
+
if (key) {
|
|
79
|
+
newmap[key] = value || '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
this.value = newmap;
|
|
83
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
|
|
84
|
+
}
|
|
85
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
|
86
|
+
_toArray(map) {
|
|
87
|
+
var array = [];
|
|
88
|
+
for (var key in map) {
|
|
89
|
+
array.push({
|
|
90
|
+
key: key,
|
|
91
|
+
value: map[key]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return array;
|
|
95
|
+
}
|
|
96
|
+
_add() {
|
|
97
|
+
this._build(true);
|
|
98
|
+
var inputs = this._inputs || [];
|
|
99
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
100
|
+
let input = inputs[i];
|
|
101
|
+
input.value = '';
|
|
102
|
+
}
|
|
103
|
+
inputs[0].focus();
|
|
104
|
+
}
|
|
105
|
+
_delete(e) {
|
|
106
|
+
var record = e.target.parentElement;
|
|
107
|
+
const lng = record === null || record === void 0 ? void 0 : record.querySelector('[data-lng]');
|
|
108
|
+
lng && (lng.value = '');
|
|
109
|
+
this._build();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
EditorI18n.styles = [
|
|
113
|
+
css `
|
|
114
|
+
:host {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
align-content: center;
|
|
118
|
+
|
|
119
|
+
width: 100%;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
border: 1px solid #ccc;
|
|
122
|
+
margin: 5px 0;
|
|
123
|
+
|
|
124
|
+
background-color: #ddd;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
div {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-flow: row nowrap;
|
|
130
|
+
align-items: center;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
div > * {
|
|
134
|
+
min-width: 0px;
|
|
135
|
+
min-height: 20px;
|
|
136
|
+
margin: 2px;
|
|
137
|
+
padding: 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
button {
|
|
141
|
+
width: 20px;
|
|
142
|
+
text-align: center;
|
|
143
|
+
border-radius: 50%;
|
|
144
|
+
font-size: 1em;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
input {
|
|
148
|
+
flex: 1;
|
|
149
|
+
}
|
|
150
|
+
`
|
|
151
|
+
];
|
|
152
|
+
__decorate([
|
|
153
|
+
property({ type: Object })
|
|
154
|
+
], EditorI18n.prototype, "value", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
queryAll('[data-record-new] input')
|
|
157
|
+
], EditorI18n.prototype, "_inputs", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
state()
|
|
160
|
+
], EditorI18n.prototype, "_changingNow", void 0);
|
|
161
|
+
EditorI18n = __decorate([
|
|
162
|
+
customElement('editor-i18n')
|
|
163
|
+
], EditorI18n);
|
|
164
|
+
export default EditorI18n;
|
|
165
|
+
//# sourceMappingURL=editor-i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-i18n.js","sourceRoot":"","sources":["../../../src/editors/editor-i18n.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property, queryAll, state } from 'lit/decorators.js'\n\n/**\nmultiple language editor element\n\nExample:\n\n <editor-i18n value=${map}>\n </editor-i18n>\n*/\n@customElement('editor-i18n')\nexport default class EditorI18n extends LitElement {\n static styles = [\n 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 margin: 5px 0;\n\n background-color: #ddd;\n }\n\n div {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n }\n\n div > * {\n min-width: 0px;\n min-height: 20px;\n margin: 2px;\n padding: 0;\n }\n\n button {\n width: 20px;\n text-align: center;\n border-radius: 50%;\n font-size: 1em;\n }\n\n input {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Object }) value: { [key: string]: any } = {}\n\n @queryAll('[data-record-new] input') _inputs?: Array<HTMLInputElement>\n\n @state() _changingNow: boolean = false\n\n firstUpdated() {\n this.renderRoot.addEventListener('change', this._onChange.bind(this))\n }\n\n render() {\n return html`\n <datalist id=\"language-list\">\n <option value=\"en\">English</option>\n <option value=\"ko\">한국어</option>\n <option value=\"zh\">中文</option>\n <option value=\"ms\">Bahasa Malaysia</option>\n </datalist>\n\n ${this._toArray(this.value).map(\n item => html`\n <div data-record>\n <input type=\"text\" data-lng placeholder=\"language\" .value=${item.key} list=\"language-list\" />\n <input type=\"text\" data-term placeholder=\"term\" .value=${item.value} />\n <button class=\"record-action\" @click=${(e: MouseEvent) => this._delete(e)} tabindex=\"-1\">x</button>\n </div>\n `\n )}\n\n <div data-record-new>\n <input type=\"text\" data-lng placeholder=\"language\" value=\"\" list=\"language-list\" />\n <input type=\"text\" data-term placeholder=\"term\" value=\"\" />\n <button class=\"record-action\" @click=${() => this._add()} tabindex=\"-1\">+</button>\n </div>\n `\n }\n\n _onChange(e: Event) {\n if (this._changingNow) {\n return\n }\n\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var div = input.parentElement as HTMLElement\n\n if (div.hasAttribute('data-record')) {\n this._build()\n } else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-term')) {\n this._add()\n }\n\n this._changingNow = false\n }\n\n _build(includeNewRecord?: boolean) {\n if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')\n else var records = this.renderRoot.querySelectorAll('[data-record]')\n\n var newmap: { [key: string]: string } = {}\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var key = (record.querySelector('[data-lng]') as HTMLInputElement)?.value\n var input = record.querySelector('[data-term]') as HTMLInputElement\n if (!input) continue\n\n var value = input.value\n\n if (key) {\n newmap[key] = value || ''\n }\n }\n\n this.value = newmap\n this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))\n }\n\n /* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */\n _toArray(map: { [key: string]: any }) {\n var array = []\n\n for (var key in map) {\n array.push({\n key: key,\n value: map[key]\n })\n }\n\n return array\n }\n\n _add() {\n this._build(true)\n\n var inputs = this._inputs || []\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n\n inputs[0].focus()\n }\n\n _delete(e: MouseEvent) {\n var record = (e.target as HTMLElement).parentElement\n const lng = record?.querySelector('[data-lng]') as HTMLInputElement\n lng && (lng.value = '')\n\n this._build()\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/editors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,wBAAwB,CAAA;AAE/B,eAAe;IACb;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,sBAAsB;KAChC;CACF,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport './property-editor-i18n'\n\nexport default [\n {\n type: 'i18n',\n element: 'property-editor-i18n'\n }\n]\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import './editor-i18n';
|
|
3
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
4
|
+
import { customElement } from 'lit/decorators.js';
|
|
5
|
+
import { html } from 'lit';
|
|
6
|
+
let PropertyEditorLegendStatus = class PropertyEditorLegendStatus extends OxPropertyEditor {
|
|
7
|
+
editorTemplate(props) {
|
|
8
|
+
return html ` <editor-i18n .value=${props.value} fullwidth></editor-i18n> `;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
PropertyEditorLegendStatus = __decorate([
|
|
12
|
+
customElement('property-editor-i18n')
|
|
13
|
+
], PropertyEditorLegendStatus);
|
|
14
|
+
export { PropertyEditorLegendStatus };
|
|
15
|
+
//# sourceMappingURL=property-editor-i18n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-editor-i18n.js","sourceRoot":"","sources":["../../../src/editors/property-editor-i18n.ts"],"names":[],"mappings":";AAAA,OAAO,eAAe,CAAA;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAG1B,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,gBAAgB;IAC9D,cAAc,CAAC,KAAU;QACvB,OAAO,IAAI,CAAA,wBAAwB,KAAK,CAAC,KAAK,4BAA4B,CAAA;IAC5E,CAAC;CACF,CAAA;AAJY,0BAA0B;IADtC,aAAa,CAAC,sBAAsB,CAAC;GACzB,0BAA0B,CAItC;SAJY,0BAA0B","sourcesContent":["import './editor-i18n'\n\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { customElement } from 'lit/decorators.js'\nimport { html } from 'lit'\n\n@customElement('property-editor-i18n')\nexport class PropertyEditorLegendStatus extends OxPropertyEditor {\n editorTemplate(props: any) {\n return html` <editor-i18n .value=${props.value} fullwidth></editor-i18n> `\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Label } from './label';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA","sourcesContent":["export { default as Label } from './label'\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
declare const Label_base: typeof Component;
|
|
3
|
+
export default class Label extends Label_base {
|
|
4
|
+
static get nature(): {
|
|
5
|
+
mutable: boolean;
|
|
6
|
+
resizable: boolean;
|
|
7
|
+
rotatable: boolean;
|
|
8
|
+
properties: {
|
|
9
|
+
type: string;
|
|
10
|
+
label: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}[];
|
|
13
|
+
'value-property': string;
|
|
14
|
+
help: string;
|
|
15
|
+
};
|
|
16
|
+
is3dish(): boolean;
|
|
17
|
+
get text(): any;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
const NATURE = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [
|
|
9
|
+
{
|
|
10
|
+
type: 'i18n',
|
|
11
|
+
label: 'terms',
|
|
12
|
+
name: 'terms'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'string',
|
|
16
|
+
label: 'i18n-key',
|
|
17
|
+
name: 'key'
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'string',
|
|
21
|
+
label: 'fallback',
|
|
22
|
+
name: 'fallback'
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
'value-property': 'key',
|
|
26
|
+
help: 'scene/component/label'
|
|
27
|
+
};
|
|
28
|
+
import { Component, RectPath } from '@hatiolab/things-scene';
|
|
29
|
+
import i18next from 'i18next';
|
|
30
|
+
export default class Label extends RectPath(Component) {
|
|
31
|
+
static get nature() {
|
|
32
|
+
return NATURE;
|
|
33
|
+
}
|
|
34
|
+
is3dish() {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
get text() {
|
|
38
|
+
const { key, terms = {}, fallback } = this.state;
|
|
39
|
+
const language = i18next.language;
|
|
40
|
+
return terms[language] || terms[language.substr(0, 2)] || (key && i18next.t(key)) || fallback;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
Component.register('label', Label);
|
|
44
|
+
//# sourceMappingURL=label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/label.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,KAAK;SACZ;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,UAAU;SACjB;KACF;IACD,gBAAgB,EAAE,KAAK;IACvB,IAAI,EAAE,uBAAuB;CAC9B,CAAA;AAED,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,QAAQ,CAAC,SAAS,CAAC;IACpD,MAAM,KAAK,MAAM;QACf,OAAO,MAAM,CAAA;IACf,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,IAAI;QACN,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEhD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAA;IAC/F,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nconst NATURE = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'i18n',\n label: 'terms',\n name: 'terms'\n },\n {\n type: 'string',\n label: 'i18n-key',\n name: 'key'\n },\n {\n type: 'string',\n label: 'fallback',\n name: 'fallback'\n }\n ],\n 'value-property': 'key',\n help: 'scene/component/label'\n}\n\nimport { Component, RectPath } from '@hatiolab/things-scene'\n\nimport i18next from 'i18next'\n\nexport default class Label extends RectPath(Component) {\n static get nature() {\n return NATURE\n }\n\n is3dish() {\n return true\n }\n\n get text() {\n const { key, terms = {}, fallback } = this.state\n\n const language = i18next.language\n return terms[language] || terms[language.substr(0, 2)] || (key && i18next.t(key)) || fallback\n }\n}\n\nComponent.register('label', Label)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../node_modules/@hatiolab/things-scene/things-scene.d.ts","../../../node_modules/i18next/index.d.ts","../src/label.ts","../src/index.ts","../../../node_modules/@lit/reactive-element/css-tag.d.ts","../../../node_modules/@lit/reactive-element/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/reactive-element.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/@types/trusted-types/index.d.ts","../../../node_modules/lit-html/directive.d.ts","../../../node_modules/lit-html/lit-html.d.ts","../../../node_modules/lit-element/lit-element.d.ts","../../../node_modules/lit/index.d.ts","../../../node_modules/@lit/reactive-element/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/decorators/custom-element.d.ts","../../../node_modules/@lit/reactive-element/decorators/property.d.ts","../../../node_modules/@lit/reactive-element/decorators/state.d.ts","../../../node_modules/@lit/reactive-element/decorators/event-options.d.ts","../../../node_modules/@lit/reactive-element/decorators/query.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-all.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-async.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-assigned-nodes.d.ts","../../../node_modules/lit/decorators.d.ts","../src/editors/editor-i18n.ts","../../../node_modules/@operato/property-editor/dist/src/ox-property-editor.d.ts","../../../node_modules/@operato/property-editor/dist/src/index.d.ts","../src/editors/property-editor-i18n.ts","../src/editors/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts"],"fileInfos":[{"version":"6adbf5efd0e374ff5f427a4f26a5a413e9734eee5067a0e86da69aea41910b52","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"abba1071bfd89e55e88a054b0c851ea3e8a494c340d0f3fab19eb18f6afb0c9e","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"4378fc8122ec9d1a685b01eb66c46f62aba6b239ca7228bb6483bcf8259ee493","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"d071129cba6a5f2700be09c86c07ad2791ab67d4e5ed1eb301d6746c62745ea4","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","4ddc7832014ce8dae75461c71b8e6af7281cfb2eba4d6e4c2deb6300044cf4ce","c44dfb1945045dd2d0affce0f09f4f37eb504e69e1b114b61570b94bc2625b54","cbdc8a9eebf88d7474a33b860df9bb27ba55095f218390dbd8ae1657f8898eda","1660bd87049b880d73617210c495ea19825156e43d3fbe1d633f2c9ec77cec13","0c8a56610b08f55e29ffb466cd27626ad6dbe822312a398026e82270c63088e3","1e5743b25a63fd34ffbae89adcbf248ee17db6ed08d90079ffa93803c3e80d2a","7b33ee85f2e96a51c0e3bcee47b247a24515aff37a7d8b5dfe4e18b735d37440","2fcd2d22b1f30555e785105597cd8f57ed50300e213c4f1bbca6ae149f782c38",{"version":"bb4248c7f953233ac52332088fac897d62b82be07244e551d87c5049600b6cf7","affectsGlobalScope":true},"70f04c91d3186b1b10157157887fab664968fc9b88377785a5ee42750c202c6d","06e20da1bc94df355f22ac7a9533c2488816ec4cb9134d9b160a263629a07072","c311ef8d8b159d0c268b415f78c1949498dc2d14455a9891c5b8ef84625b1e41","f07a77a7fb1d49aa2b61cb68bf712a083487acd7130d20223a83de03af0c257d","97c58f6db61d45712d91d2260994817ae2b568bbb37cc280013079b6b5d2232d","ac388c7c7a262213a3700451bc921e382a93fb27c0252c34ccf03540b4ce044b","9bdb35d0b28dcd5d8f0879bd29f0cf07b7eb48aa63be4dd44057e32fcfeb1c83","fb0107c83e2e0e75b77dacd0c3c6c3ab6844e98dce2a8f858c6f0a57c12136a6","84610cf09dee3cefc910555318f1ad7b45f1cba36905a86849324ca4fead2385","a25d1e52291791819032826af5c52987e16ffdb96e8bb69f7f1790f5ab080be6","d660961abada6b5030461f3322ef3a2e1d9fec74167574f8b590a7796cf90a72","707b4eae3d469b2f347d2083037151922f94c370a9456ebd5ac0a4fb7441c7e7","ef509d57201aa4e2e3e2b3d1fafd066a8ce68cd2caea737d539c3544f5a99a67","84c66a77a1302611ea5001dc88d10de1b5d87c6b2f30a48585495217421ce1ac","abe8e160512e2a7b4d61acca9412bc76d62044145cd189a24f8e8678ccf8b5bf","48997560f6ca5fd8b4233b69d1f9cbac88d26719e925fff493fdebb5198b675f","a1045a03e654de1219e85600f7589af7a91e4ac37e2aff114f2ceba34111d34d","f0c3a30ca322b9fb2a9615948a4066dc289e5ca57886587d544a81d99027ea0a","559ff8c1df6e22cb887bd05a4b7d10e50bbbf2a23774ca86c21e4cc1e9667660","0d5a2ee1fdfa82740e0103389b9efd6bfe145a20018a2da3c02b89666181f4d9","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"92d63add669d18ebc349efbacd88966d6f2ccdddfb1b880b2db98ae3aa7bf7c4","affectsGlobalScope":true},"ccc94049a9841fe47abe5baef6be9a38fc6228807974ae675fb15dc22531b4be",{"version":"9acfe4d1ff027015151ce81d60797b04b52bffe97ad8310bb0ec2e8fd61e1303","affectsGlobalScope":true},"95843d5cfafced8f3f8a5ce57d2335f0bcd361b9483587d12a25e4bd403b8216","afc6e96061af46bcff47246158caee7e056f5288783f2d83d6858cd25be1c565",{"version":"34f5bcac12b36d70304b73de5f5aab3bb91bd9919f984be80579ebcad03a624e","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","2f520601649a893e6a49a8851ebfcf4be8ce090dc1281c2a08a871cb04e8251f","f50c975ab7b50e25a69e3d8a3773894125b44e9698924105f23b812bf7488baf","2b8c764f856a1dd0a9a2bf23e5efddbff157de8138b0754010be561ae5fcaa90","76650408392bf49a8fbf3e2b6b302712a92d76af77b06e2da1cc8077359c4409","0af3121e68297b2247dd331c0d24dba599e50736a7517a5622d5591aae4a3122","6972fca26f6e9bd56197568d4379f99071a90766e06b4fcb5920a0130a9202be",{"version":"4a2628e95962c8ab756121faa3ac2ed348112ff7a87b5c286dd2cc3326546b4c","affectsGlobalScope":true},"80793b2277f31baa199234daed806fff0fb11491d1ebd3357e520c3558063f00","a049a59a02009fc023684fcfaf0ac526fe36c35dcc5d2b7d620c1750ba11b083","5533392c50c51b1a5c32b89f13145db929c574ef1c5949cf67a074a05ea107d9","b287b810b5035d5685f1df6e1e418f1ca452a3ed4f59fd5cc081dbf2045f0d9b","4b9a003b5c556c96784132945bb41c655ea11273b1917f5c8d0c154dd5fd20dd","a458dc78104cc80048ac24fdc02fe6dce254838094c2f25641b3f954d9721241",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"902cd98bf46e95caf4118a0733fb801e9e90eec3edaed6abdad77124afec9ca2","abc1c425b2ad6720433f40f1877abfa4223f0f3dd486c9c28c492179ca183cb6","cd4854d38f4eb5592afd98ab95ca17389a7dfe38013d9079e802d739bdbcc939","94eed4cc2f5f658d5e229ff1ccd38860bddf4233e347bf78edd2154dee1f2b99",{"version":"bd1a08e30569b0fb2f0b21035eb9b039871f68faa9b98accf847e9c878c5e0a9","affectsGlobalScope":true},"9f1069b9e2c051737b1f9b4f1baf50e4a63385a6a89c32235549ae87fc3d5492","ee18f2da7a037c6ceeb112a084e485aead9ea166980bf433474559eac1b46553","29c2706fa0cc49a2bd90c83234da33d08bb9554ecec675e91c1f85087f5a5324","0acbf26bf958f9e80c1ffa587b74749d2697b75b484062d36e103c137c562bc3","d7838022c7dab596357a9604b9c6adffe37dc34085ce0779c958ce9545bd7139","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"a7971f9fb2a32ec7788ec6cda9d7a33c02023dfe9a62db2030ad1359649d8050","c33a6ea7147af60d8e98f1ac127047f4b0d4e2ce28b8f08ff3de07ca7cc00637",{"version":"b42b47e17b8ece2424ae8039feb944c2e3ba4b262986aebd582e51efbdca93dc","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","2408611d9b4146e35d1dbd1f443ccd8e187c74614a54b80300728277529dbf11","998a3de5237518c0b3ac00a11b3b4417affb008aa20aedee52f3fdae3cb86151","ad41008ffe077206e1811fc873f4d9005b5fd7f6ab52bb6118fef600815a5cb4","d88ecca73348e7c337541c4b8b60a50aca5e87384f6b8a422fc6603c637e4c21","badae0df9a8016ac36994b0a0e7b82ba6aaa3528e175a8c3cb161e4683eec03e","c3db860bcaaaeb3bbc23f353bbda1f8ab82756c8d5e973bebb3953cb09ea68f2","235a53595bd20b0b0eeb1a29cb2887c67c48375e92f03749b2488fbd46d0b1a0","bc09393cd4cd13f69cf1366d4236fbae5359bb550f0de4e15767e9a91d63dfb1","9c266243b01545e11d2733a55ad02b4c00ecdbda99c561cd1674f96e89cdc958","c71155c05fc76ff948a4759abc1cb9feec036509f500174bc18dad4c7827a60c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"1cdb8f094b969dcc183745dc88404e2d8fcf2a858c6e7cc2441011476573238e"],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5},"fileIdsList":[[112],[47,112],[54,112],[47,54,112],[45,46,112],[65,112],[51,53,112],[69,112],[72,112],[73,78,112],[74,84,85,92,101,111,112],[74,75,84,92,112],[76,112],[77,78,85,93,112],[78,101,108,112],[79,81,84,92,112],[80,112],[81,82,112],[83,84,112],[84,112],[84,85,86,101,111,112],[84,85,86,101,112],[87,92,101,111,112],[84,85,87,88,92,101,108,111,112],[87,89,101,108,111,112],[69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118],[84,90,112],[91,111,112],[81,84,92,101,112],[93,112],[94,112],[72,95,112],[96,110,112,116],[97,112],[98,112],[84,99,112],[99,100,112,114],[84,101,102,103,112],[101,103,112],[101,102,112],[104,112],[105,112],[84,106,107,112],[106,107,112],[78,92,108,112],[109,112],[92,110,112],[73,87,98,111,112],[78,112],[101,112,113],[112,114],[112,115],[73,78,84,86,95,101,111,112,114,116],[101,112,117],[48,112],[47,51,112],[51,112],[49,50,112],[55,56,57,58,59,60,61,62,112],[47,51,52,112],[40,53,63,112],[40,67,112],[40,53,63,64,66,112],[40,43,112],[40,41,42,112]],"referencedMap":[[45,1],[54,2],[55,3],[58,4],[56,4],[60,4],[62,4],[61,4],[59,4],[57,3],[46,1],[47,5],[66,6],[65,7],[69,8],[70,8],[72,9],[73,10],[74,11],[75,12],[76,13],[77,14],[78,15],[79,16],[80,17],[81,18],[82,18],[83,19],[84,20],[85,21],[86,22],[71,1],[118,1],[87,23],[88,24],[89,25],[119,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,34],[98,35],[99,36],[100,37],[101,38],[103,39],[102,40],[104,41],[105,42],[106,43],[107,44],[108,45],[109,46],[110,47],[111,48],[112,49],[113,50],[114,51],[115,52],[116,53],[117,54],[49,55],[48,1],[42,1],[52,56],[50,57],[51,58],[63,59],[53,60],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[41,1],[64,61],[68,62],[67,63],[44,64],[43,65]],"exportedModulesMap":[[45,1],[54,2],[55,3],[58,4],[56,4],[60,4],[62,4],[61,4],[59,4],[57,3],[46,1],[47,5],[66,6],[65,7],[69,8],[70,8],[72,9],[73,10],[74,11],[75,12],[76,13],[77,14],[78,15],[79,16],[80,17],[81,18],[82,18],[83,19],[84,20],[85,21],[86,22],[71,1],[118,1],[87,23],[88,24],[89,25],[119,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,34],[98,35],[99,36],[100,37],[101,38],[103,39],[102,40],[104,41],[105,42],[106,43],[107,44],[108,45],[109,46],[110,47],[111,48],[112,49],[113,50],[114,51],[115,52],[116,53],[117,54],[49,55],[48,1],[42,1],[52,56],[50,57],[51,58],[63,59],[53,60],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[41,1],[64,61],[68,62],[67,63],[44,64],[43,65]],"semanticDiagnosticsPerFile":[45,54,55,58,56,60,62,61,59,57,46,47,66,65,69,70,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,71,118,87,88,89,119,90,91,92,93,94,95,96,97,98,99,100,101,103,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,49,48,42,52,50,51,63,53,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,41,64,68,67,44,43]},"version":"4.5.2"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# label
|
|
2
|
+
|
|
3
|
+
```label``` is a component for static labeling that can define multilingual terms.
|
|
4
|
+
|
|
5
|
+
The order of multilingual application is as follows.
|
|
6
|
+
- Among the terms, the one that corresponds to the language currently in use
|
|
7
|
+
- If the i18n key is defined, the value of the i18next multilingual definition package is applied.
|
|
8
|
+
- Finally, the value defined in fallback is applied.
|
|
9
|
+
|
|
10
|
+
## Properties
|
|
11
|
+
|
|
12
|
+
- terms
|
|
13
|
+
- User-defined multilingual term definitions.
|
|
14
|
+
- A language abbreviation is defined as a key, and a term is defined in that language.
|
|
15
|
+
- i18n key
|
|
16
|
+
- The key of i18next multilingual definition package
|
|
17
|
+
- fallback
|
|
18
|
+
- Default value
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@operato/scene-i18n",
|
|
3
|
+
"description": "i18n component for things-scene",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "heartyoh",
|
|
6
|
+
"version": "0.0.4",
|
|
7
|
+
"main": "dist/src/index.js",
|
|
8
|
+
"module": "dist/src/index.js",
|
|
9
|
+
"things-scene": true,
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"@oprato:registry": "https://registry.npmjs.org"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/hatiolab/things-factory.git",
|
|
17
|
+
"directory": "packages/scene-i18n"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"serve": "tsc && things-factory-dev",
|
|
21
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepublish": "tsc",
|
|
24
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
25
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
26
|
+
"migration": "things-factory-migration"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@operato/property-editor": "^0.2.30",
|
|
30
|
+
"i18next": "^21.5.4",
|
|
31
|
+
"lit": "^2.0.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@hatiolab/prettier-config": "^1.0.0",
|
|
35
|
+
"@hatiolab/things-scene": "^2.7.15",
|
|
36
|
+
"@operato/board": "^0.2.27",
|
|
37
|
+
"@things-factory/builder": "^4.0.6",
|
|
38
|
+
"@things-factory/operato-board": "^4.0.6",
|
|
39
|
+
"@types/chance": "^1.1.3",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
41
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
42
|
+
"@web/dev-server": "^0.1.28",
|
|
43
|
+
"concurrently": "^5.3.0",
|
|
44
|
+
"eslint": "^7.32.0",
|
|
45
|
+
"eslint-config-prettier": "^8.3.0",
|
|
46
|
+
"husky": "^4.3.8",
|
|
47
|
+
"lint-staged": "^10.5.4",
|
|
48
|
+
"prettier": "^2.4.1",
|
|
49
|
+
"tslib": "^2.3.1",
|
|
50
|
+
"typescript": "^4.5.2"
|
|
51
|
+
},
|
|
52
|
+
"prettier": "@hatiolab/prettier-config",
|
|
53
|
+
"husky": {
|
|
54
|
+
"hooks": {
|
|
55
|
+
"pre-commit": "lint-staged"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"lint-staged": {
|
|
59
|
+
"*.ts": [
|
|
60
|
+
"eslint --fix",
|
|
61
|
+
"prettier --write"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "853ccc00f65e96f0d4807400d792a76fe9ef62d1"
|
|
65
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { LitElement, css, html } from 'lit'
|
|
6
|
+
import { customElement, property, queryAll, state } from 'lit/decorators.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
multiple language editor element
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
|
|
13
|
+
<editor-i18n value=${map}>
|
|
14
|
+
</editor-i18n>
|
|
15
|
+
*/
|
|
16
|
+
@customElement('editor-i18n')
|
|
17
|
+
export default class EditorI18n extends LitElement {
|
|
18
|
+
static styles = [
|
|
19
|
+
css`
|
|
20
|
+
:host {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-content: center;
|
|
24
|
+
|
|
25
|
+
width: 100%;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
border: 1px solid #ccc;
|
|
28
|
+
margin: 5px 0;
|
|
29
|
+
|
|
30
|
+
background-color: #ddd;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
div {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-flow: row nowrap;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
div > * {
|
|
40
|
+
min-width: 0px;
|
|
41
|
+
min-height: 20px;
|
|
42
|
+
margin: 2px;
|
|
43
|
+
padding: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
button {
|
|
47
|
+
width: 20px;
|
|
48
|
+
text-align: center;
|
|
49
|
+
border-radius: 50%;
|
|
50
|
+
font-size: 1em;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
input {
|
|
54
|
+
flex: 1;
|
|
55
|
+
}
|
|
56
|
+
`
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
@property({ type: Object }) value: { [key: string]: any } = {}
|
|
60
|
+
|
|
61
|
+
@queryAll('[data-record-new] input') _inputs?: Array<HTMLInputElement>
|
|
62
|
+
|
|
63
|
+
@state() _changingNow: boolean = false
|
|
64
|
+
|
|
65
|
+
firstUpdated() {
|
|
66
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
return html`
|
|
71
|
+
<datalist id="language-list">
|
|
72
|
+
<option value="en">English</option>
|
|
73
|
+
<option value="ko">한국어</option>
|
|
74
|
+
<option value="zh">中文</option>
|
|
75
|
+
<option value="ms">Bahasa Malaysia</option>
|
|
76
|
+
</datalist>
|
|
77
|
+
|
|
78
|
+
${this._toArray(this.value).map(
|
|
79
|
+
item => html`
|
|
80
|
+
<div data-record>
|
|
81
|
+
<input type="text" data-lng placeholder="language" .value=${item.key} list="language-list" />
|
|
82
|
+
<input type="text" data-term placeholder="term" .value=${item.value} />
|
|
83
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">x</button>
|
|
84
|
+
</div>
|
|
85
|
+
`
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<div data-record-new>
|
|
89
|
+
<input type="text" data-lng placeholder="language" value="" list="language-list" />
|
|
90
|
+
<input type="text" data-term placeholder="term" value="" />
|
|
91
|
+
<button class="record-action" @click=${() => this._add()} tabindex="-1">+</button>
|
|
92
|
+
</div>
|
|
93
|
+
`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_onChange(e: Event) {
|
|
97
|
+
if (this._changingNow) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this._changingNow = true
|
|
102
|
+
|
|
103
|
+
var input = e.target as HTMLInputElement
|
|
104
|
+
var value = input.value
|
|
105
|
+
|
|
106
|
+
var div = input.parentElement as HTMLElement
|
|
107
|
+
|
|
108
|
+
if (div.hasAttribute('data-record')) {
|
|
109
|
+
this._build()
|
|
110
|
+
} else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-term')) {
|
|
111
|
+
this._add()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this._changingNow = false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
_build(includeNewRecord?: boolean) {
|
|
118
|
+
if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')
|
|
119
|
+
else var records = this.renderRoot.querySelectorAll('[data-record]')
|
|
120
|
+
|
|
121
|
+
var newmap: { [key: string]: string } = {}
|
|
122
|
+
|
|
123
|
+
for (var i = 0; i < records.length; i++) {
|
|
124
|
+
var record = records[i]
|
|
125
|
+
|
|
126
|
+
var key = (record.querySelector('[data-lng]') as HTMLInputElement)?.value
|
|
127
|
+
var input = record.querySelector('[data-term]') as HTMLInputElement
|
|
128
|
+
if (!input) continue
|
|
129
|
+
|
|
130
|
+
var value = input.value
|
|
131
|
+
|
|
132
|
+
if (key) {
|
|
133
|
+
newmap[key] = value || ''
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.value = newmap
|
|
138
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
|
142
|
+
_toArray(map: { [key: string]: any }) {
|
|
143
|
+
var array = []
|
|
144
|
+
|
|
145
|
+
for (var key in map) {
|
|
146
|
+
array.push({
|
|
147
|
+
key: key,
|
|
148
|
+
value: map[key]
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return array
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_add() {
|
|
156
|
+
this._build(true)
|
|
157
|
+
|
|
158
|
+
var inputs = this._inputs || []
|
|
159
|
+
|
|
160
|
+
for (var i = 0; i < inputs.length; i++) {
|
|
161
|
+
let input = inputs[i]
|
|
162
|
+
input.value = ''
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
inputs[0].focus()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_delete(e: MouseEvent) {
|
|
169
|
+
var record = (e.target as HTMLElement).parentElement
|
|
170
|
+
const lng = record?.querySelector('[data-lng]') as HTMLInputElement
|
|
171
|
+
lng && (lng.value = '')
|
|
172
|
+
|
|
173
|
+
this._build()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './editor-i18n'
|
|
2
|
+
|
|
3
|
+
import { OxPropertyEditor } from '@operato/property-editor'
|
|
4
|
+
import { customElement } from 'lit/decorators.js'
|
|
5
|
+
import { html } from 'lit'
|
|
6
|
+
|
|
7
|
+
@customElement('property-editor-i18n')
|
|
8
|
+
export class PropertyEditorLegendStatus extends OxPropertyEditor {
|
|
9
|
+
editorTemplate(props: any) {
|
|
10
|
+
return html` <editor-i18n .value=${props.value} fullwidth></editor-i18n> `
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Label } from './label'
|
package/src/label.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const NATURE = {
|
|
6
|
+
mutable: false,
|
|
7
|
+
resizable: true,
|
|
8
|
+
rotatable: true,
|
|
9
|
+
properties: [
|
|
10
|
+
{
|
|
11
|
+
type: 'i18n',
|
|
12
|
+
label: 'terms',
|
|
13
|
+
name: 'terms'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'string',
|
|
17
|
+
label: 'i18n-key',
|
|
18
|
+
name: 'key'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: 'string',
|
|
22
|
+
label: 'fallback',
|
|
23
|
+
name: 'fallback'
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
'value-property': 'key',
|
|
27
|
+
help: 'scene/component/label'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
import { Component, RectPath } from '@hatiolab/things-scene'
|
|
31
|
+
|
|
32
|
+
import i18next from 'i18next'
|
|
33
|
+
|
|
34
|
+
export default class Label extends RectPath(Component) {
|
|
35
|
+
static get nature() {
|
|
36
|
+
return NATURE
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
is3dish() {
|
|
40
|
+
return true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get text() {
|
|
44
|
+
const { key, terms = {}, fallback } = this.state
|
|
45
|
+
|
|
46
|
+
const language = i18next.language
|
|
47
|
+
return terms[language] || terms[language.substr(0, 2)] || (key && i18next.t(key)) || fallback
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Component.register('label', Label)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import icon from './scene-label.png'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: 'label',
|
|
5
|
+
description: 'label',
|
|
6
|
+
group: 'textAndMedia',
|
|
7
|
+
/* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */
|
|
8
|
+
icon,
|
|
9
|
+
model: {
|
|
10
|
+
type: 'label',
|
|
11
|
+
left: 10,
|
|
12
|
+
top: 10,
|
|
13
|
+
width: 100,
|
|
14
|
+
height: 20,
|
|
15
|
+
strokeStyle: 'black'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
Binary file
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"rootDir": "./",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
"incremental": true,
|
|
19
|
+
"types": ["node"]
|
|
20
|
+
},
|
|
21
|
+
"include": ["**/*.ts", "*.d.ts"]
|
|
22
|
+
}
|