@operato/grist-editor 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -0
- package/.storybook/main.js +3 -0
- package/.storybook/server.mjs +8 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/demo/data-grist-test.html +456 -0
- package/demo/index.html +33 -0
- package/dist/src/code/code-editor.d.ts +6 -0
- package/dist/src/code/code-editor.js +50 -0
- package/dist/src/code/code-editor.js.map +1 -0
- package/dist/src/code/index.d.ts +1 -0
- package/dist/src/code/index.js +5 -0
- package/dist/src/code/index.js.map +1 -0
- package/dist/src/id/id-input.d.ts +19 -0
- package/dist/src/id/id-input.js +119 -0
- package/dist/src/id/id-input.js.map +1 -0
- package/dist/src/id/id-renderer.d.ts +2 -0
- package/dist/src/id/id-renderer.js +9 -0
- package/dist/src/id/id-renderer.js.map +1 -0
- package/dist/src/id/id-selector.d.ts +23 -0
- package/dist/src/id/id-selector.js +197 -0
- package/dist/src/id/id-selector.js.map +1 -0
- package/dist/src/id/index.d.ts +1 -0
- package/dist/src/id/index.js +7 -0
- package/dist/src/id/index.js.map +1 -0
- package/dist/src/index.d.ts +0 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/object/index.d.ts +1 -0
- package/dist/src/object/index.js +6 -0
- package/dist/src/object/index.js.map +1 -0
- package/dist/src/object/object-editor.d.ts +18 -0
- package/dist/src/object/object-editor.js +152 -0
- package/dist/src/object/object-editor.js.map +1 -0
- package/dist/src/object/object-selector.d.ts +38 -0
- package/dist/src/object/object-selector.js +338 -0
- package/dist/src/object/object-selector.js.map +1 -0
- package/dist/src/parameters/index.d.ts +1 -0
- package/dist/src/parameters/index.js +6 -0
- package/dist/src/parameters/index.js.map +1 -0
- package/dist/src/parameters/parameters-editor-builder.d.ts +4 -0
- package/dist/src/parameters/parameters-editor-builder.js +119 -0
- package/dist/src/parameters/parameters-editor-builder.js.map +1 -0
- package/dist/src/parameters/parameters-editor-popup.d.ts +13 -0
- package/dist/src/parameters/parameters-editor-popup.js +111 -0
- package/dist/src/parameters/parameters-editor-popup.js.map +1 -0
- package/dist/src/parameters/parameters-editor.d.ts +18 -0
- package/dist/src/parameters/parameters-editor.js +106 -0
- package/dist/src/parameters/parameters-editor.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +87 -0
- package/src/code/code-editor.ts +78 -0
- package/src/code/index.ts +6 -0
- package/src/id/id-input.ts +135 -0
- package/src/id/id-renderer.ts +12 -0
- package/src/id/id-selector.ts +189 -0
- package/src/id/index.ts +8 -0
- package/src/index.ts +0 -0
- package/src/object/index.ts +8 -0
- package/src/object/object-editor.ts +162 -0
- package/src/object/object-selector.ts +346 -0
- package/src/parameters/index.ts +8 -0
- package/src/parameters/parameters-editor-builder.ts +130 -0
- package/src/parameters/parameters-editor-popup.ts +106 -0
- package/src/parameters/parameters-editor.ts +112 -0
- package/tsconfig.json +23 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +41 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import '@things-factory/modeller-ui';
|
|
6
|
+
import { LitElement, html } from 'lit';
|
|
7
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
|
8
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
9
|
+
import { connect } from 'pwa-helpers/connect-mixin';
|
|
10
|
+
import { store } from '@operato/shell';
|
|
11
|
+
/**
|
|
12
|
+
모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
|
|
13
|
+
|
|
14
|
+
Example:
|
|
15
|
+
|
|
16
|
+
<ox-parameters-editor-builder value="{{value}}">
|
|
17
|
+
<label>Center X</label>
|
|
18
|
+
<input type="number" .value="${value.cx}">
|
|
19
|
+
<label>Width</label>
|
|
20
|
+
<input type="number" .value="${value.width}">
|
|
21
|
+
</ox-parameters-editor-builder>
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_VALUE = {
|
|
24
|
+
legend: '',
|
|
25
|
+
number: 0,
|
|
26
|
+
angle: 0,
|
|
27
|
+
string: '',
|
|
28
|
+
text: '',
|
|
29
|
+
textarea: '',
|
|
30
|
+
checkbox: false,
|
|
31
|
+
select: '',
|
|
32
|
+
color: '#000000',
|
|
33
|
+
'solidcolor-stops': null,
|
|
34
|
+
'gradientcolor-stops': null,
|
|
35
|
+
'gltf-selector': '',
|
|
36
|
+
'image-selector': '',
|
|
37
|
+
multiplecolor: null,
|
|
38
|
+
editortable: null,
|
|
39
|
+
imageselector: '',
|
|
40
|
+
options: null,
|
|
41
|
+
date: null
|
|
42
|
+
};
|
|
43
|
+
let ParametersEditorBuilder = class ParametersEditorBuilder extends connect(store)(LitElement) {
|
|
44
|
+
render() {
|
|
45
|
+
return html `<slot></slot>`;
|
|
46
|
+
}
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
this.addEventListener('change', this._onValueChanged.bind(this));
|
|
49
|
+
}
|
|
50
|
+
updated(changes) {
|
|
51
|
+
changes.has('props') && this._onPropsChanged(this.props);
|
|
52
|
+
changes.has('value') && this._setValues();
|
|
53
|
+
}
|
|
54
|
+
_onPropsChanged(props) {
|
|
55
|
+
this.textContent = '';
|
|
56
|
+
(props || []).forEach(prop => {
|
|
57
|
+
let elementType = OxPropertyEditor.getEditor(prop.type);
|
|
58
|
+
if (!elementType) {
|
|
59
|
+
console.warn('Property Editor not defined', prop.type);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let element = document.createElement(elementType);
|
|
63
|
+
element.label = prop.label;
|
|
64
|
+
element.type = prop.type;
|
|
65
|
+
element.placeholder = prop.placeholder;
|
|
66
|
+
element.host = this.host;
|
|
67
|
+
// element.context = this.context
|
|
68
|
+
element.setAttribute('name', prop.name);
|
|
69
|
+
if (prop.observe) {
|
|
70
|
+
element.observe = prop.observe;
|
|
71
|
+
}
|
|
72
|
+
element.property = prop.property;
|
|
73
|
+
element.setAttribute('property-editor', '');
|
|
74
|
+
this.appendChild(element);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
_setValues() {
|
|
78
|
+
var value = this.value || {};
|
|
79
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
80
|
+
const editor = propertyEditor;
|
|
81
|
+
let name = editor.getAttribute('name');
|
|
82
|
+
editor.value = value[name] === undefined ? DEFAULT_VALUE[editor.type] : value[name];
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
_getValues() {
|
|
86
|
+
var value = {};
|
|
87
|
+
Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
|
|
88
|
+
const editor = propertyEditor;
|
|
89
|
+
let name = editor.getAttribute('name');
|
|
90
|
+
value[name] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value;
|
|
91
|
+
});
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
_onValueChanged(e) {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
var prop = e.target;
|
|
97
|
+
if (!prop || !prop.hasAttribute('property-editor')) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.dispatchEvent(new CustomEvent('property-change', {
|
|
101
|
+
bubbles: true,
|
|
102
|
+
composed: true,
|
|
103
|
+
detail: this._getValues()
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: Object })
|
|
109
|
+
], ParametersEditorBuilder.prototype, "value", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Array })
|
|
112
|
+
], ParametersEditorBuilder.prototype, "props", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Object })
|
|
115
|
+
], ParametersEditorBuilder.prototype, "host", void 0);
|
|
116
|
+
ParametersEditorBuilder = __decorate([
|
|
117
|
+
customElement('ox-parameters-editor-builder')
|
|
118
|
+
], ParametersEditorBuilder);
|
|
119
|
+
//# sourceMappingURL=parameters-editor-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-editor-builder.js","sourceRoot":"","sources":["../../../src/parameters/parameters-editor-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,6BAA6B,CAAA;AAEpC,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC;;;;;;;;;;;EAWE;AAEF,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,EAAE;IACV,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,SAAS;IAChB,kBAAkB,EAAE,IAAI;IACxB,qBAAqB,EAAE,IAAI;IAC3B,eAAe,EAAE,EAAE;IACnB,gBAAgB,EAAE,EAAE;IACpB,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,IAAI;CACJ,CAAA;AAGR,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,OAAO,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;IAK9D,MAAM;QACJ,OAAO,IAAI,CAAA,eAAe,CAAA;IAC5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IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE;YAClD,OAAM;SACP;QAED,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,iBAAiB,EAAE;YACjC,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE;SAC1B,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AAhF6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAW;AACX;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;sDAAuB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAU;AAHjC,uBAAuB;IAD5B,aAAa,CAAC,8BAA8B,CAAC;GACxC,uBAAuB,CAiF5B","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport '@things-factory/modeller-ui'\n\nimport { LitElement, PropertyValues, html } from 'lit'\nimport { OxPropertyEditor, PropertySpec } from '@operato/property-editor'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { connect } from 'pwa-helpers/connect-mixin'\nimport { store } from '@operato/shell'\n\n/**\n모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.\n\nExample:\n\n <ox-parameters-editor-builder value=\"{{value}}\">\n <label>Center X</label>\n <input type=\"number\" .value=\"${value.cx}\">\n <label>Width</label>\n <input type=\"number\" .value=\"${value.width}\">\n </ox-parameters-editor-builder>\n*/\n\nconst DEFAULT_VALUE = {\n legend: '',\n number: 0,\n angle: 0,\n string: '',\n text: '',\n textarea: '',\n checkbox: false,\n select: '',\n color: '#000000',\n 'solidcolor-stops': null,\n 'gradientcolor-stops': null,\n 'gltf-selector': '',\n 'image-selector': '',\n multiplecolor: null,\n editortable: null,\n imageselector: '',\n options: null,\n date: null\n} as any\n\n@customElement('ox-parameters-editor-builder')\nclass ParametersEditorBuilder extends connect(store)(LitElement) {\n @property({ type: Object }) value: any\n @property({ type: Array }) props?: PropertySpec[]\n @property({ type: Object }) host: any\n\n render() {\n return html`<slot></slot>`\n }\n\n firstUpdated() {\n this.addEventListener('change', this._onValueChanged.bind(this))\n }\n\n updated(changes: PropertyValues<this>) {\n changes.has('props') && this._onPropsChanged(this.props)\n changes.has('value') && this._setValues()\n }\n\n _onPropsChanged(props: PropertySpec[] | undefined) {\n this.textContent = ''\n ;(props || []).forEach(prop => {\n let elementType = OxPropertyEditor.getEditor(prop.type)\n if (!elementType) {\n console.warn('Property Editor not defined', prop.type)\n return\n }\n let element = document.createElement(elementType) as OxPropertyEditor\n\n element.label = prop.label\n element.type = prop.type\n element.placeholder = prop.placeholder\n element.host = this.host\n // element.context = this.context\n element.setAttribute('name', prop.name)\n\n if (prop.observe) {\n element.observe = prop.observe\n }\n element.property = prop.property\n element.setAttribute('property-editor', '')\n\n this.appendChild(element)\n })\n }\n\n _setValues() {\n var value = this.value || {}\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n editor.value = value[name!] === undefined ? DEFAULT_VALUE[editor.type] : value[name!]\n })\n }\n\n _getValues() {\n var value = {} as any\n Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {\n const editor = propertyEditor as OxPropertyEditor\n let name = editor.getAttribute('name')\n value[name!] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value\n })\n\n return value\n }\n\n _onValueChanged(e: Event) {\n e.stopPropagation()\n var prop = e.target as HTMLElement\n\n if (!prop || !prop.hasAttribute('property-editor')) {\n return\n }\n\n this.dispatchEvent(\n new CustomEvent('property-change', {\n bubbles: true,\n composed: true,\n detail: this._getValues()\n })\n )\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class ParametersEditorPopup extends LitElement {
|
|
3
|
+
static styles: import("lit").CSSResult[];
|
|
4
|
+
value: any;
|
|
5
|
+
props: any;
|
|
6
|
+
host: any;
|
|
7
|
+
context: any;
|
|
8
|
+
confirmCallback: (newval: any) => void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
private onChange;
|
|
11
|
+
private onCancel;
|
|
12
|
+
private onConfirm;
|
|
13
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, css, html } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
5
|
+
import { i18next } from '@operato/i18n';
|
|
6
|
+
let ParametersEditorPopup = class ParametersEditorPopup extends LitElement {
|
|
7
|
+
render() {
|
|
8
|
+
var props = this.props instanceof Array ? this.props : [];
|
|
9
|
+
return html `
|
|
10
|
+
${props.length > 0
|
|
11
|
+
? html `
|
|
12
|
+
<ox-parameters-editor-builder
|
|
13
|
+
.value=${this.value}
|
|
14
|
+
.props=${props}
|
|
15
|
+
.host=${this.host}
|
|
16
|
+
.context=${this.context}
|
|
17
|
+
@property-change=${this.onChange.bind(this)}
|
|
18
|
+
>
|
|
19
|
+
</ox-parameters-editor-builder>
|
|
20
|
+
`
|
|
21
|
+
: html ` <span><i18n-msg msgid="text.no properties to set"></i18n-msg></span> `}
|
|
22
|
+
|
|
23
|
+
<div class="button-container">
|
|
24
|
+
<mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
25
|
+
<mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
26
|
+
</div>
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
onChange(e) {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
/*
|
|
32
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
33
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
34
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
35
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
36
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
37
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
38
|
+
(이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
|
|
39
|
+
=>
|
|
40
|
+
이런 이유로, Object.assign(...)을 사용하였다.
|
|
41
|
+
*/
|
|
42
|
+
if (!this.value) {
|
|
43
|
+
this.value = {};
|
|
44
|
+
}
|
|
45
|
+
for (let key in this.value) {
|
|
46
|
+
delete this.value[key];
|
|
47
|
+
}
|
|
48
|
+
Object.assign(this.value, e.detail);
|
|
49
|
+
}
|
|
50
|
+
onCancel(e) {
|
|
51
|
+
history.back();
|
|
52
|
+
}
|
|
53
|
+
onConfirm(e) {
|
|
54
|
+
this.confirmCallback && this.confirmCallback(this.value);
|
|
55
|
+
history.back();
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
ParametersEditorPopup.styles = [
|
|
59
|
+
ScrollbarStyles,
|
|
60
|
+
css `
|
|
61
|
+
:host {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
|
|
65
|
+
background-color: #fff;
|
|
66
|
+
|
|
67
|
+
width: var(--overlay-center-normal-width, 50%);
|
|
68
|
+
height: var(--overlay-center-normal-height, 50%);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
ox-parameters-editor-builder {
|
|
72
|
+
flex: 1;
|
|
73
|
+
overflow-y: auto;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
span {
|
|
77
|
+
flex: 1;
|
|
78
|
+
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
82
|
+
|
|
83
|
+
color: var(--primary-color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.button-container {
|
|
87
|
+
display: flex;
|
|
88
|
+
margin-left: auto;
|
|
89
|
+
}
|
|
90
|
+
`
|
|
91
|
+
];
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: Object })
|
|
94
|
+
], ParametersEditorPopup.prototype, "value", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: Object })
|
|
97
|
+
], ParametersEditorPopup.prototype, "props", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: Object })
|
|
100
|
+
], ParametersEditorPopup.prototype, "host", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: Object })
|
|
103
|
+
], ParametersEditorPopup.prototype, "context", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Object })
|
|
106
|
+
], ParametersEditorPopup.prototype, "confirmCallback", void 0);
|
|
107
|
+
ParametersEditorPopup = __decorate([
|
|
108
|
+
customElement('ox-parameters-editor-popup')
|
|
109
|
+
], ParametersEditorPopup);
|
|
110
|
+
export { ParametersEditorPopup };
|
|
111
|
+
//# sourceMappingURL=parameters-editor-popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-editor-popup.js","sourceRoot":"","sources":["../../../src/parameters/parameters-editor-popup.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,qBAAqB,GAAlC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CAAA;QACxD,OAAO,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC;CACF,CAAA;AAjGQ,4BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAU;AACT;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAa;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAwC;AAxCxD,qBAAqB;IADjC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,qBAAqB,CAkGjC;SAlGY,qBAAqB","sourcesContent":["import { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-parameters-editor-popup')\nexport class ParametersEditorPopup extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n background-color: #fff;\n\n width: var(--overlay-center-normal-width, 50%);\n height: var(--overlay-center-normal-height, 50%);\n }\n\n ox-parameters-editor-builder {\n flex: 1;\n overflow-y: auto;\n }\n\n span {\n flex: 1;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n color: var(--primary-color);\n }\n\n .button-container {\n display: flex;\n margin-left: auto;\n }\n `\n ]\n\n @property({ type: Object }) value: any\n @property({ type: Object }) props: any\n @property({ type: Object }) host: any\n @property({ type: Object }) context: any\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var props = this.props instanceof Array ? this.props : []\n\n return html`\n ${props.length > 0\n ? html`\n <ox-parameters-editor-builder\n .value=${this.value}\n .props=${props}\n .host=${this.host}\n .context=${this.context}\n @property-change=${this.onChange.bind(this)}\n >\n </ox-parameters-editor-builder>\n `\n : html` <span><i18n-msg msgid=\"text.no properties to set\"></i18n-msg></span> `}\n\n <div class=\"button-container\">\n <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>\n <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>\n </div>\n `\n }\n\n private onChange(e: CustomEvent) {\n e.stopPropagation()\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)\n => \n 이런 이유로, Object.assign(...)을 사용하였다.\n */\n if (!this.value) {\n this.value = {}\n }\n\n for (let key in this.value) {\n delete this.value[key]\n }\n Object.assign(this.value, e.detail)\n }\n\n private onCancel(e: Event) {\n history.back()\n }\n\n private onConfirm(e: Event) {\n this.confirmCallback && this.confirmCallback(this.value)\n history.back()\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './parameters-editor-builder.js';
|
|
5
|
+
import './parameters-editor-popup.js';
|
|
6
|
+
import { ColumnConfig, GristRecord, InputEditor } from '@operato/data-grist';
|
|
7
|
+
export declare class ParametersEditor extends InputEditor {
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
value: any;
|
|
10
|
+
column: ColumnConfig;
|
|
11
|
+
record: GristRecord;
|
|
12
|
+
row: number;
|
|
13
|
+
field: any;
|
|
14
|
+
private popup?;
|
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
firstUpdated(): Promise<void>;
|
|
17
|
+
openSelector(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './parameters-editor-builder.js';
|
|
6
|
+
import './parameters-editor-popup.js';
|
|
7
|
+
import { InputEditor } from '@operato/data-grist';
|
|
8
|
+
import { css, html } from 'lit';
|
|
9
|
+
import { openPopup } from '@operato/layout';
|
|
10
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
11
|
+
import { i18next } from '@operato/i18n';
|
|
12
|
+
let ParametersEditor = class ParametersEditor extends InputEditor {
|
|
13
|
+
render() {
|
|
14
|
+
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
15
|
+
return html ` ${value || ''} `;
|
|
16
|
+
}
|
|
17
|
+
async firstUpdated() {
|
|
18
|
+
await this.updateComplete;
|
|
19
|
+
this.renderRoot.addEventListener('click', e => {
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
this.openSelector();
|
|
22
|
+
});
|
|
23
|
+
this.openSelector();
|
|
24
|
+
}
|
|
25
|
+
async openSelector() {
|
|
26
|
+
if (this.popup) {
|
|
27
|
+
delete this.popup;
|
|
28
|
+
}
|
|
29
|
+
var { options } = this.column.record;
|
|
30
|
+
if (typeof options === 'function') {
|
|
31
|
+
options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
|
|
32
|
+
}
|
|
33
|
+
const { name, help, spec, context, objectified = false } = options;
|
|
34
|
+
const confirmCallback = (newval) => {
|
|
35
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
36
|
+
bubbles: true,
|
|
37
|
+
composed: true,
|
|
38
|
+
detail: {
|
|
39
|
+
before: this.value,
|
|
40
|
+
after: !objectified ? JSON.stringify(newval) : newval,
|
|
41
|
+
record: this.record,
|
|
42
|
+
column: this.column,
|
|
43
|
+
row: this.row
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
var value = {};
|
|
52
|
+
}
|
|
53
|
+
/*
|
|
54
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
55
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
56
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
57
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
58
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
59
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
60
|
+
*/
|
|
61
|
+
var template = html `
|
|
62
|
+
<ox-parameters-editor-popup
|
|
63
|
+
.value=${value}
|
|
64
|
+
.props=${spec}
|
|
65
|
+
.host=${this.record}
|
|
66
|
+
.context=${context}
|
|
67
|
+
.confirmCallback=${confirmCallback}
|
|
68
|
+
>
|
|
69
|
+
</ox-parameters-editor-popup>
|
|
70
|
+
`;
|
|
71
|
+
this.popup = openPopup(template, {
|
|
72
|
+
backdrop: true,
|
|
73
|
+
size: 'large',
|
|
74
|
+
title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.params')}`,
|
|
75
|
+
help
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
ParametersEditor.styles = css `
|
|
80
|
+
:host {
|
|
81
|
+
color: black;
|
|
82
|
+
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
}
|
|
86
|
+
`;
|
|
87
|
+
__decorate([
|
|
88
|
+
property({ type: Object })
|
|
89
|
+
], ParametersEditor.prototype, "value", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: Object })
|
|
92
|
+
], ParametersEditor.prototype, "column", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ type: Object })
|
|
95
|
+
], ParametersEditor.prototype, "record", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ type: Number })
|
|
98
|
+
], ParametersEditor.prototype, "row", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Object })
|
|
101
|
+
], ParametersEditor.prototype, "field", void 0);
|
|
102
|
+
ParametersEditor = __decorate([
|
|
103
|
+
customElement('ox-parameters-editor')
|
|
104
|
+
], ParametersEditor);
|
|
105
|
+
export { ParametersEditor };
|
|
106
|
+
//# sourceMappingURL=parameters-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters-editor.js","sourceRoot":"","sources":["../../../src/parameters/parameters-editor.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,gCAAgC,CAAA;AACvC,OAAO,8BAA8B,CAAA;AAErC,OAAO,EAA6B,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,EAAc,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,gBAAgB,GA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gDAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAa;AACZ;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAY;AAd5B,gBAAgB;IAD5B,aAAa,CAAC,sBAAsB,CAAC;GACzB,gBAAgB,CAgG5B;SAhGY,gBAAgB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './parameters-editor-builder.js'\nimport './parameters-editor-popup.js'\n\nimport { ColumnConfig, GristRecord, InputEditor } from '@operato/data-grist'\nimport { LitElement, css, html } from 'lit'\nimport { PopupHandle, openPopup } from '@operato/layout'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-parameters-editor')\nexport class ParametersEditor extends InputEditor {\n static styles = css`\n :host {\n color: black;\n\n overflow: hidden;\n text-overflow: ellipsis;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: Object }) column!: ColumnConfig\n @property({ type: Object }) record!: GristRecord\n @property({ type: Number }) row!: number\n @property({ type: Object }) field!: any\n\n private popup?: PopupHandle\n\n render() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html` ${value || ''} `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n async openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n var { options } = this.column.record\n\n if (typeof options === 'function') {\n options = await options.call(this, this.value, this.column, this.record, this.row, this.field)\n }\n\n const { name, help, spec, context, objectified = false } = options\n\n const confirmCallback = (newval: any) => {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: !objectified ? JSON.stringify(newval) : newval,\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n try {\n var value: any = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value\n } catch (e) {\n var value: any = {}\n }\n\n /* \n 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로, \n layout의 구성에 변화가 발생하면, 다시 render된다.\n 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)\n 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,\n 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.\n 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.\n */\n var template = html`\n <ox-parameters-editor-popup\n .value=${value}\n .props=${spec}\n .host=${this.record}\n .context=${context}\n .confirmCallback=${confirmCallback}\n >\n </ox-parameters-editor-popup>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.params')}`,\n help\n })\n }\n}\n"]}
|