@operato/app 1.0.0-alpha.2 → 1.0.0-alpha.22

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 (48) hide show
  1. package/@types/global/index.d.ts +2 -0
  2. package/CHANGELOG.md +176 -0
  3. package/demo/data-grist-test.html +456 -0
  4. package/dist/src/grist/code-editor.js +8 -3
  5. package/dist/src/grist/code-editor.js.map +1 -1
  6. package/dist/src/grist/index.js +2 -0
  7. package/dist/src/grist/index.js.map +1 -1
  8. package/dist/src/grist/object-editor.d.ts +1 -1
  9. package/dist/src/grist/object-editor.js +1 -1
  10. package/dist/src/grist/object-editor.js.map +1 -1
  11. package/dist/src/grist/parameters-editor-builder.d.ts +4 -0
  12. package/dist/src/grist/parameters-editor-builder.js +118 -0
  13. package/dist/src/grist/parameters-editor-builder.js.map +1 -0
  14. package/dist/src/grist/parameters-editor-popup.d.ts +13 -0
  15. package/dist/src/grist/parameters-editor-popup.js +111 -0
  16. package/dist/src/grist/parameters-editor-popup.js.map +1 -0
  17. package/dist/src/grist/parameters-editor.d.ts +19 -0
  18. package/dist/src/grist/parameters-editor.js +105 -0
  19. package/dist/src/grist/parameters-editor.js.map +1 -0
  20. package/dist/src/input/ox-input-background-pattern.d.ts +31 -0
  21. package/dist/src/input/ox-input-background-pattern.js +150 -0
  22. package/dist/src/input/ox-input-background-pattern.js.map +1 -0
  23. package/dist/src/input/ox-input-fill-style.d.ts +41 -0
  24. package/dist/src/input/ox-input-fill-style.js +325 -0
  25. package/dist/src/input/ox-input-fill-style.js.map +1 -0
  26. package/dist/src/input/ox-input-graphql.d.ts +36 -0
  27. package/dist/src/input/ox-input-graphql.js +161 -0
  28. package/dist/src/input/ox-input-graphql.js.map +1 -0
  29. package/dist/src/property-editor/index.d.ts +24 -0
  30. package/dist/src/property-editor/index.js +58 -0
  31. package/dist/src/property-editor/index.js.map +1 -0
  32. package/dist/src/property-editor/ox-property-editor-graphql.d.ts +5 -0
  33. package/dist/src/property-editor/ox-property-editor-graphql.js +15 -0
  34. package/dist/src/property-editor/ox-property-editor-graphql.js.map +1 -0
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +30 -12
  37. package/src/grist/code-editor.ts +2 -3
  38. package/src/grist/index.ts +2 -0
  39. package/src/grist/object-editor.ts +1 -1
  40. package/src/grist/parameters-editor-builder.ts +128 -0
  41. package/src/grist/parameters-editor-popup.ts +106 -0
  42. package/src/grist/parameters-editor.ts +112 -0
  43. package/src/input/ox-input-background-pattern.ts +166 -0
  44. package/src/input/ox-input-fill-style.ts +359 -0
  45. package/src/input/ox-input-graphql.ts +169 -0
  46. package/src/property-editor/index.ts +59 -0
  47. package/src/property-editor/ox-property-editor-graphql.ts +12 -0
  48. package/yarn-error.log +17112 -0
@@ -2,8 +2,10 @@ import { registerEditor, registerRenderer } from '@operato/data-grist';
2
2
  import { CodeEditor } from './code-editor';
3
3
  import { IdInput } from './id-input.js';
4
4
  import { IdRenderer } from './id-renderer.js';
5
+ import { ObjectEditor } from './object-editor';
5
6
  /* register grist renderer/editor for id */
6
7
  registerEditor('id', IdInput);
8
+ registerEditor('object', ObjectEditor);
7
9
  registerEditor('code', CodeEditor);
8
10
  registerRenderer('id', IdRenderer);
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,2CAA2C;AAC3C,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAC7B,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAElC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { CodeEditor } from './code-editor'\nimport { IdInput } from './id-input.js'\nimport { IdRenderer } from './id-renderer.js'\n\n/* register grist renderer/editor for id */\nregisterEditor('id', IdInput)\nregisterEditor('code', CodeEditor)\n\nregisterRenderer('id', IdRenderer)\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,2CAA2C;AAC3C,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AAC7B,cAAc,CAAC,QAAQ,EAAE,YAAmB,CAAC,CAAA;AAC7C,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAElC,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { CodeEditor } from './code-editor'\nimport { IdInput } from './id-input.js'\nimport { IdRenderer } from './id-renderer.js'\nimport { ObjectEditor } from './object-editor'\n\n/* register grist renderer/editor for id */\nregisterEditor('id', IdInput)\nregisterEditor('object', ObjectEditor as any)\nregisterEditor('code', CodeEditor)\n\nregisterRenderer('id', IdRenderer)\n"]}
@@ -1,5 +1,5 @@
1
1
  import '@material/mwc-icon';
2
- import '../../elements/object-selector';
2
+ import './object-selector.js';
3
3
  import { ColumnConfig, GristRecord } from '@operato/data-grist';
4
4
  import { LitElement, TemplateResult } from 'lit';
5
5
  export declare class ObjectEditor extends LitElement {
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import '@material/mwc-icon';
3
- import '../../elements/object-selector';
3
+ import './object-selector.js';
4
4
  import { ZERO_COLUMN, ZERO_RECORD } from '@operato/data-grist';
5
5
  import { LitElement, css, html } from 'lit';
6
6
  import { openPopup } from '@operato/layout';
@@ -1 +1 @@
1
- {"version":3,"file":"object-editor.js","sourceRoot":"","sources":["../../../src/grist/object-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,gCAAgC,CAAA;AAEvC,OAAO,EAAwC,WAAW,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,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,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAkC8B,UAAK,GAA4B,EAAE,CAAA;QACnC,WAAM,GAAiB,WAAW,CAAA;QAClC,WAAM,GAAgB,WAAW,CAAA;IA0G/D,CAAC;IApGC,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAE5B,IAAI,EAAE,SAAS,GAAG,MAAM,EAAE,gBAAgB,GAAG,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;QAC/F,IAAI,IAAI,EAAE,WAAW,CAAA;QACrB,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;YACnC,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;SACxB;aAAM;YACL,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAA;SACxB;QAED,IAAI,OAAO,gBA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AW;6BACD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;uBAChC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;oBACvC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;kBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI;uBAC1B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS;wBACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU;;OAEtD,CAAA;QAEH,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA7IQ,mBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAoC;AACnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAkC;AACjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAa;AArC7B,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA8IxB;SA9IY,YAAY","sourcesContent":["import '@material/mwc-icon'\nimport '../../elements/object-selector'\n\nimport { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'\nimport { LitElement, TemplateResult, 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-object-editor')\nexport class ObjectEditor extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n justify-content: inherit;\n }\n\n span {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n\n mwc-icon {\n width: 20px;\n font-size: 1.5em;\n margin-left: auto;\n }\n `\n\n @property({ type: Object }) value: { [prop: string]: any } = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) row?: number\n\n private popup?: PopupHandle\n private template?: TemplateResult\n\n render() {\n var value = this.value || {}\n\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var name, description\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`\n ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n this.template = ((this.column.record || {}).options || {}).template\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback = (selected: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: {\n ...(this.column.record.options.select || [])\n .map((field: any) => field.name)\n .reduce((obj: { [field: string]: any }, fieldName: string) => {\n return (obj = {\n ...obj,\n [fieldName]: selected[fieldName]\n })\n }, {} as { [field: string]: any }),\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n },\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value[valueField]\n }\n\n var template =\n this.template ||\n html`\n <object-selector\n .value=${actualValue}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .select=${this.column.record.options.select}\n .list=${this.column.record.options.list}\n .basicArgs=${this.column.record.options.basicArgs}\n .valueField=${this.column.record.options.valueField}\n ></object-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n }\n}\n"]}
1
+ {"version":3,"file":"object-editor.js","sourceRoot":"","sources":["../../../src/grist/object-editor.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAC3B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAwC,WAAW,EAAe,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,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,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAkC8B,UAAK,GAA4B,EAAE,CAAA;QACnC,WAAM,GAAiB,WAAW,CAAA;QAClC,WAAM,GAAgB,WAAW,CAAA;IA0G/D,CAAC;IApGC,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAA;QAE5B,IAA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EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAa;AArC7B,YAAY;IADxB,aAAa,CAAC,kBAAkB,CAAC;GACrB,YAAY,CA8IxB;SA9IY,YAAY","sourcesContent":["import '@material/mwc-icon'\nimport './object-selector.js'\n\nimport { ColumnConfig, GristData, GristRecord, ZERO_COLUMN, ZERO_CONFIG, ZERO_RECORD } from '@operato/data-grist'\nimport { LitElement, TemplateResult, 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-object-editor')\nexport class ObjectEditor extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n\n padding: 7px 0px;\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n justify-content: inherit;\n }\n\n span {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n\n mwc-icon {\n width: 20px;\n font-size: 1.5em;\n margin-left: auto;\n }\n `\n\n @property({ type: Object }) value: { [prop: string]: any } = {}\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) row?: number\n\n private popup?: PopupHandle\n private template?: TemplateResult\n\n render() {\n var value = this.value || {}\n\n var { nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n var name, description\n if (typeof nameField === 'function') {\n name = nameField(value)\n } else {\n name = value[nameField]\n }\n\n if (typeof descriptionField === 'function') {\n description = descriptionField(value)\n } else {\n description = value[descriptionField] && `(${value[descriptionField]})`\n }\n\n return html`\n ${!value ? html`` : html` <span>${name || ''}${description || ''}</span> `}\n <mwc-icon>arrow_drop_down</mwc-icon>\n `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n this.template = ((this.column.record || {}).options || {}).template\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n const confirmCallback = (selected: { [field: string]: any }) => {\n var { idField = 'id', nameField = 'name', descriptionField = 'description' } = this.column.record.options || {}\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: {\n ...(this.column.record.options.select || [])\n .map((field: any) => field.name)\n .reduce((obj: { [field: string]: any }, fieldName: string) => {\n return (obj = {\n ...obj,\n [fieldName]: selected[fieldName]\n })\n }, {} as { [field: string]: any }),\n [idField]: selected[idField],\n [nameField]: selected[nameField],\n [descriptionField]: selected[descriptionField]\n },\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n }\n\n var value = this.value || {}\n var valueField: string | ((item: any) => any) = this.column.record.options.valueField || 'id'\n var actualValue\n if (typeof valueField === 'function') {\n actualValue = valueField(value)\n } else {\n actualValue = value[valueField]\n }\n\n var template =\n this.template ||\n html`\n <object-selector\n .value=${actualValue}\n .confirmCallback=${confirmCallback.bind(this)}\n .queryName=${this.column.record.options.queryName}\n .select=${this.column.record.options.select}\n .list=${this.column.record.options.list}\n .basicArgs=${this.column.record.options.basicArgs}\n .valueField=${this.column.record.options.valueField}\n ></object-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select_item')\n })\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ export {};
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import { LitElement, html } from 'lit';
6
+ import { OxPropertyEditor } from '@operato/property-editor';
7
+ import { customElement, property } from 'lit/decorators.js';
8
+ import { connect } from 'pwa-helpers/connect-mixin';
9
+ import { store } from '@operato/shell';
10
+ /**
11
+ 모든 에디터들은 change 이벤트를 지원해야 한다. 또한, 모든 에디터들은 value속성에 값을 가져야 한다.
12
+
13
+ Example:
14
+
15
+ <ox-parameters-editor-builder value="{{value}}">
16
+ <label>Center X</label>
17
+ <input type="number" .value="${value.cx}">
18
+ <label>Width</label>
19
+ <input type="number" .value="${value.width}">
20
+ </ox-parameters-editor-builder>
21
+ */
22
+ const DEFAULT_VALUE = {
23
+ legend: '',
24
+ number: 0,
25
+ angle: 0,
26
+ string: '',
27
+ text: '',
28
+ textarea: '',
29
+ checkbox: false,
30
+ select: '',
31
+ color: '#000000',
32
+ 'solidcolor-stops': null,
33
+ 'gradientcolor-stops': null,
34
+ 'gltf-selector': '',
35
+ 'image-selector': '',
36
+ multiplecolor: null,
37
+ editortable: null,
38
+ imageselector: '',
39
+ options: null,
40
+ date: null
41
+ };
42
+ let ParametersEditorBuilder = class ParametersEditorBuilder extends connect(store)(LitElement) {
43
+ render() {
44
+ return html `<slot></slot>`;
45
+ }
46
+ firstUpdated() {
47
+ this.addEventListener('change', this._onValueChanged.bind(this));
48
+ }
49
+ updated(changes) {
50
+ changes.has('props') && this._onPropsChanged(this.props);
51
+ changes.has('value') && this._setValues();
52
+ }
53
+ _onPropsChanged(props) {
54
+ this.textContent = '';
55
+ (props || []).forEach(prop => {
56
+ let elementType = OxPropertyEditor.getEditor(prop.type);
57
+ if (!elementType) {
58
+ console.warn('Property Editor not defined', prop.type);
59
+ return;
60
+ }
61
+ let element = document.createElement(elementType);
62
+ element.label = prop.label;
63
+ element.type = prop.type;
64
+ element.placeholder = prop.placeholder;
65
+ element.host = this.host;
66
+ // element.context = this.context
67
+ element.setAttribute('name', prop.name);
68
+ if (prop.observe) {
69
+ element.observe = prop.observe;
70
+ }
71
+ element.property = prop.property;
72
+ element.setAttribute('property-editor', '');
73
+ this.appendChild(element);
74
+ });
75
+ }
76
+ _setValues() {
77
+ var value = this.value || {};
78
+ Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
79
+ const editor = propertyEditor;
80
+ let name = editor.getAttribute('name');
81
+ editor.value = value[name] === undefined ? DEFAULT_VALUE[editor.type] : value[name];
82
+ });
83
+ }
84
+ _getValues() {
85
+ var value = {};
86
+ Array.from(this.querySelectorAll('[name]')).forEach(propertyEditor => {
87
+ const editor = propertyEditor;
88
+ let name = editor.getAttribute('name');
89
+ value[name] = editor.value === undefined ? DEFAULT_VALUE[editor.type] : editor.value;
90
+ });
91
+ return value;
92
+ }
93
+ _onValueChanged(e) {
94
+ e.stopPropagation();
95
+ var prop = e.target;
96
+ if (!prop || !prop.hasAttribute('property-editor')) {
97
+ return;
98
+ }
99
+ this.dispatchEvent(new CustomEvent('property-change', {
100
+ bubbles: true,
101
+ composed: true,
102
+ detail: this._getValues()
103
+ }));
104
+ }
105
+ };
106
+ __decorate([
107
+ property({ type: Object })
108
+ ], ParametersEditorBuilder.prototype, "value", void 0);
109
+ __decorate([
110
+ property({ type: Array })
111
+ ], ParametersEditorBuilder.prototype, "props", void 0);
112
+ __decorate([
113
+ property({ type: Object })
114
+ ], ParametersEditorBuilder.prototype, "host", void 0);
115
+ ParametersEditorBuilder = __decorate([
116
+ customElement('ox-parameters-editor-builder')
117
+ ], ParametersEditorBuilder);
118
+ //# sourceMappingURL=parameters-editor-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters-editor-builder.js","sourceRoot":"","sources":["../../../src/grist/parameters-editor-builder.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,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,E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K,GAAG,EAAS,CAAA;QACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;YACnE,MAAM,MAAM,GAAG,cAAkC,CAAA;YACjD,IAAI,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;YACtC,KAAK,CAAC,IAAK,CAAC,GAAG,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAA;QACvF,CAAC,CAAC,CAAA;QAEF,OAAO,KAAK,CAAA;IACd,CAAC;IAED,eAAe,CAAC,CAAQ;QACtB,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,IAAI,IAAI,GAAG,CAAC,CAAC,MAAqB,CAAA;QAElC,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 { 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/grist/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,MAAa,qBAAsB,SAAQ,UAAU;IA0CnD,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;QAEzD,OAAO,IAAI,CAAA;QACP,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,CAAC,CAAC,IAAI,CAAA;;uBAES,IAAI,CAAC,KAAK;uBACV,KAAK;sBACN,IAAI,CAAC,IAAI;yBACN,IAAI,CAAC,OAAO;iCACJ,IAAI,CAAC,Q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E,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,19 @@
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 } from '@operato/data-grist';
7
+ import { LitElement } from 'lit';
8
+ export declare class ParametersEditor extends LitElement {
9
+ static styles: import("lit").CSSResult;
10
+ value: any;
11
+ column: ColumnConfig;
12
+ record: GristRecord;
13
+ row: number;
14
+ field: any;
15
+ private popup?;
16
+ render(): import("lit-html").TemplateResult<1>;
17
+ firstUpdated(): Promise<void>;
18
+ openSelector(): Promise<void>;
19
+ }
@@ -0,0 +1,105 @@
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 { LitElement, css, html } from 'lit';
8
+ import { openPopup } from '@operato/layout';
9
+ import { customElement, property } from 'lit/decorators.js';
10
+ import { i18next } from '@operato/i18n';
11
+ let ParametersEditor = class ParametersEditor extends LitElement {
12
+ render() {
13
+ const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
14
+ return html ` ${value || ''} `;
15
+ }
16
+ async firstUpdated() {
17
+ await this.updateComplete;
18
+ this.renderRoot.addEventListener('click', e => {
19
+ e.stopPropagation();
20
+ this.openSelector();
21
+ });
22
+ this.openSelector();
23
+ }
24
+ async openSelector() {
25
+ if (this.popup) {
26
+ delete this.popup;
27
+ }
28
+ var { options } = this.column.record;
29
+ if (typeof options === 'function') {
30
+ options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
31
+ }
32
+ const { name, help, spec, context, objectified = false } = options;
33
+ const confirmCallback = (newval) => {
34
+ this.dispatchEvent(new CustomEvent('field-change', {
35
+ bubbles: true,
36
+ composed: true,
37
+ detail: {
38
+ before: this.value,
39
+ after: !objectified ? JSON.stringify(newval) : newval,
40
+ record: this.record,
41
+ column: this.column,
42
+ row: this.row
43
+ }
44
+ }));
45
+ };
46
+ try {
47
+ var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : this.value;
48
+ }
49
+ catch (e) {
50
+ var value = {};
51
+ }
52
+ /*
53
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
54
+ layout의 구성에 변화가 발생하면, 다시 render된다.
55
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
56
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
57
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
58
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
59
+ */
60
+ var template = html `
61
+ <ox-parameters-editor-popup
62
+ .value=${value}
63
+ .props=${spec}
64
+ .host=${this.record}
65
+ .context=${context}
66
+ .confirmCallback=${confirmCallback}
67
+ >
68
+ </ox-parameters-editor-popup>
69
+ `;
70
+ this.popup = openPopup(template, {
71
+ backdrop: true,
72
+ size: 'large',
73
+ title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.params')}`,
74
+ help
75
+ });
76
+ }
77
+ };
78
+ ParametersEditor.styles = css `
79
+ :host {
80
+ color: black;
81
+
82
+ overflow: hidden;
83
+ text-overflow: ellipsis;
84
+ }
85
+ `;
86
+ __decorate([
87
+ property({ type: Object })
88
+ ], ParametersEditor.prototype, "value", void 0);
89
+ __decorate([
90
+ property({ type: Object })
91
+ ], ParametersEditor.prototype, "column", void 0);
92
+ __decorate([
93
+ property({ type: Object })
94
+ ], ParametersEditor.prototype, "record", void 0);
95
+ __decorate([
96
+ property({ type: Number })
97
+ ], ParametersEditor.prototype, "row", void 0);
98
+ __decorate([
99
+ property({ type: Object })
100
+ ], ParametersEditor.prototype, "field", void 0);
101
+ ParametersEditor = __decorate([
102
+ customElement('ox-parameters-editor')
103
+ ], ParametersEditor);
104
+ export { ParametersEditor };
105
+ //# sourceMappingURL=parameters-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters-editor.js","sourceRoot":"","sources":["../../../src/grist/parameters-editor.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,gCAAgC,CAAA;AACvC,OAAO,8BAA8B,CAAA;AAGrC,OAAO,EAAE,UAAU,EAAE,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,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAkB9C,MAAM;QACJ,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK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AAQ,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 } 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 LitElement {\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"]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import '@operato/i18n/ox-i18n.js';
5
+ import '@operato/attachment/ox-attachment-selector.js';
6
+ import { OxFormField } from '@operato/input';
7
+ export declare type BackgroundPatternOption = {
8
+ image?: HTMLImageElement | string;
9
+ align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom';
10
+ offsetX?: number;
11
+ offsetY?: number;
12
+ width?: number;
13
+ height?: number;
14
+ fitPattern?: boolean;
15
+ };
16
+ /**
17
+ * 컴포넌트의 fill pattern을 편집하는 element
18
+ *
19
+ * Example:
20
+ * <ox-input-background-pattern
21
+ * @change="${e => { this.pattern = e.target.value }}"
22
+ * .value=${this.pattern}"
23
+ * ></ox-input-background-pattern>
24
+ */
25
+ export declare class OxInputBackgroundPattern extends OxFormField {
26
+ static styles: import("lit").CSSResult;
27
+ value?: BackgroundPatternOption;
28
+ render(): import("lit-html").TemplateResult<1>;
29
+ firstUpdated(): void;
30
+ _onChange(e: Event): void;
31
+ }