@operato/attribute 1.2.41
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 +11 -0
- package/README.md +75 -0
- package/dist/src/grist-editor/index.d.ts +1 -0
- package/dist/src/grist-editor/index.js +7 -0
- package/dist/src/grist-editor/index.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-attribute.d.ts +12 -0
- package/dist/src/grist-editor/ox-grist-editor-attribute.js +81 -0
- package/dist/src/grist-editor/ox-grist-editor-attribute.js.map +1 -0
- package/dist/src/grist-editor/ox-grist-editor-attributes.d.ts +12 -0
- package/dist/src/grist-editor/ox-grist-editor-attributes.js +81 -0
- package/dist/src/grist-editor/ox-grist-editor-attributes.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-attribute.d.ts +13 -0
- package/dist/src/grist-editor/ox-popup-attribute.js +92 -0
- package/dist/src/grist-editor/ox-popup-attribute.js.map +1 -0
- package/dist/src/grist-editor/ox-popup-attributes.d.ts +13 -0
- package/dist/src/grist-editor/ox-popup-attributes.js +92 -0
- package/dist/src/grist-editor/ox-popup-attributes.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/ox-attribute-form.d.ts +14 -0
- package/dist/src/ox-attribute-form.js +199 -0
- package/dist/src/ox-attribute-form.js.map +1 -0
- package/dist/src/ox-attribute-view.d.ts +12 -0
- package/dist/src/ox-attribute-view.js +176 -0
- package/dist/src/ox-attribute-view.js.map +1 -0
- package/dist/src/types.d.ts +23 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/stories/ox-attribute-form.stories.d.ts +18 -0
- package/dist/stories/ox-attribute-form.stories.js +80 -0
- package/dist/stories/ox-attribute-form.stories.js.map +1 -0
- package/dist/stories/ox-attribute-view.stories.d.ts +18 -0
- package/dist/stories/ox-attribute-view.stories.js +73 -0
- package/dist/stories/ox-attribute-view.stories.js.map +1 -0
- package/dist/stories/ox-grist-editor-attribute.stories.d.ts +25 -0
- package/dist/stories/ox-grist-editor-attribute.stories.js +310 -0
- package/dist/stories/ox-grist-editor-attribute.stories.js.map +1 -0
- package/dist/stories/ox-grist-editor-attributes.stories.d.ts +25 -0
- package/dist/stories/ox-grist-editor-attributes.stories.js +310 -0
- package/dist/stories/ox-grist-editor-attributes.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +106 -0
- package/src/grist-editor/index.ts +10 -0
- package/src/grist-editor/ox-grist-editor-attributes.ts +94 -0
- package/src/grist-editor/ox-popup-attributes.ts +93 -0
- package/src/index.ts +1 -0
- package/src/ox-attribute-form.ts +218 -0
- package/src/ox-attribute-view.ts +182 -0
- package/src/types.ts +23 -0
- package/stories/ox-attribute-form.stories.ts +94 -0
- package/stories/ox-attribute-view.stories.ts +87 -0
- package/stories/ox-grist-editor-attributes.stories.ts +328 -0
- package/themes/app-theme.css +142 -0
- package/themes/form-theme.css +75 -0
- package/themes/grist-theme.css +194 -0
- package/themes/oops-theme.css +26 -0
- package/themes/report-theme.css +47 -0
- package/translations/en.json +4 -0
- package/translations/ko.json +4 -0
- package/translations/ms.json +4 -0
- package/translations/zh.json +1 -0
- package/tsconfig.json +23 -0
- package/web-dev-server.config.mjs +27 -0
- package/web-test-runner.config.mjs +41 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
|
2
|
+
# coding styles between different editors and IDEs
|
|
3
|
+
# editorconfig.org
|
|
4
|
+
|
|
5
|
+
root = true
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
|
|
10
|
+
# Change these settings to your own preference
|
|
11
|
+
indent_style = space
|
|
12
|
+
indent_size = 2
|
|
13
|
+
|
|
14
|
+
# We recommend you to keep these unchanged
|
|
15
|
+
end_of_line = lf
|
|
16
|
+
charset = utf-8
|
|
17
|
+
trim_trailing_whitespace = true
|
|
18
|
+
insert_final_newline = true
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[*.json]
|
|
24
|
+
indent_size = 2
|
|
25
|
+
|
|
26
|
+
[*.{html,js,md}]
|
|
27
|
+
block_comment_start = /**
|
|
28
|
+
block_comment = *
|
|
29
|
+
block_comment_end = */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { storybookPlugin } from '@web/dev-server-storybook';
|
|
2
|
+
import baseConfig from '../web-dev-server.config.mjs';
|
|
3
|
+
|
|
4
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
open: '/',
|
|
7
|
+
plugins: [storybookPlugin({ type: 'web-components' }), ...baseConfig.plugins],
|
|
8
|
+
});
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
### [1.2.41](https://github.com/hatiolab/operato/compare/v1.2.40...v1.2.41) (2023-05-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* add @operato/attribute module ([6f3fe9e](https://github.com/hatiolab/operato/commit/6f3fe9eca4a98e439f3dfecfb2b3ea6acbf4e1f8))
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# \<mini-app>
|
|
2
|
+
|
|
3
|
+
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i mini-app
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script type="module">
|
|
15
|
+
import 'mini-app/mini-app.js'
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<mini-app></mini-app>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Linting and formatting
|
|
22
|
+
|
|
23
|
+
To scan the project for linting and formatting errors, run
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run lint
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To automatically fix linting and formatting errors, run
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run format
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Testing with Web Test Runner
|
|
36
|
+
|
|
37
|
+
To execute a single test run:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run test
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To run the tests in interactive watch mode run:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run test:watch
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Demoing with Storybook
|
|
50
|
+
|
|
51
|
+
To run a local instance of Storybook for your component, run
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm run storybook
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To build a production version of Storybook, run
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run storybook:build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Tooling configs
|
|
64
|
+
|
|
65
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
66
|
+
|
|
67
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
68
|
+
|
|
69
|
+
## Local Demo with `web-dev-server`
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm start
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To run a local development server that serves the basic demo located in `demo/index.html`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ox-grist-editor-attributes';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist';
|
|
2
|
+
import { OxGristEditorAttribute } from './ox-grist-editor-attributes';
|
|
3
|
+
/* register grist renderer/editor for id */
|
|
4
|
+
registerEditor('attributes', OxGristEditorAttribute);
|
|
5
|
+
registerRenderer('attributes', OxGristRendererJson5);
|
|
6
|
+
export * from './ox-grist-editor-attributes';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/grist-editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE,2CAA2C;AAC3C,cAAc,CAAC,YAAY,EAAE,sBAAsB,CAAC,CAAA;AAEpD,gBAAgB,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAA;AAEpD,cAAc,8BAA8B,CAAA","sourcesContent":["import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { OxGristEditorAttribute } from './ox-grist-editor-attributes'\n\n/* register grist renderer/editor for id */\nregisterEditor('attributes', OxGristEditorAttribute)\n\nregisterRenderer('attributes', OxGristRendererJson5)\n\nexport * from './ox-grist-editor-attributes'\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-popup-attribute.js';
|
|
5
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
6
|
+
export declare class OxGristEditorAttribute extends OxGristEditor {
|
|
7
|
+
private popup?;
|
|
8
|
+
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
9
|
+
_onclick(e: Event): void;
|
|
10
|
+
_onkeydown(e: KeyboardEvent): void;
|
|
11
|
+
openPopup(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './ox-popup-attribute.js';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { cloneDeep } from 'lodash-es';
|
|
9
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
10
|
+
import { i18next } from '@operato/i18n';
|
|
11
|
+
import { openPopup } from '@operato/popup';
|
|
12
|
+
let OxGristEditorAttribute = class OxGristEditorAttribute extends OxGristEditor {
|
|
13
|
+
get editorTemplate() {
|
|
14
|
+
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
15
|
+
return html `<div tabindex="0">${value || ''}</div> `;
|
|
16
|
+
}
|
|
17
|
+
_onclick(e) {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
this.openPopup();
|
|
20
|
+
}
|
|
21
|
+
_onkeydown(e) {
|
|
22
|
+
const key = e.key;
|
|
23
|
+
if (key == 'Enter') {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
this.openPopup();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async openPopup() {
|
|
29
|
+
if (this.popup) {
|
|
30
|
+
delete this.popup;
|
|
31
|
+
}
|
|
32
|
+
var { options } = this.column.record;
|
|
33
|
+
var { attributeSet } = options || {};
|
|
34
|
+
if (typeof options === 'function') {
|
|
35
|
+
options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
|
|
36
|
+
}
|
|
37
|
+
const { name, help, objectified = false } = options;
|
|
38
|
+
const confirmCallback = (newval) => {
|
|
39
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
40
|
+
bubbles: true,
|
|
41
|
+
composed: true,
|
|
42
|
+
detail: {
|
|
43
|
+
before: this.value,
|
|
44
|
+
after: !objectified ? JSON.stringify(newval) : newval,
|
|
45
|
+
record: this.record,
|
|
46
|
+
column: this.column,
|
|
47
|
+
row: this.row
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
var value = {};
|
|
56
|
+
}
|
|
57
|
+
/*
|
|
58
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
59
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
60
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
61
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
62
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
63
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
64
|
+
*/
|
|
65
|
+
var template = html `
|
|
66
|
+
<ox-popup-attribute .value=${value} .attributeSet=${attributeSet} .confirmCallback=${confirmCallback}>
|
|
67
|
+
</ox-popup-attribute>
|
|
68
|
+
`;
|
|
69
|
+
this.popup = openPopup(template, {
|
|
70
|
+
backdrop: true,
|
|
71
|
+
size: 'large',
|
|
72
|
+
title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.attributes')}`,
|
|
73
|
+
help
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
OxGristEditorAttribute = __decorate([
|
|
78
|
+
customElement('ox-grist-editor-attribute')
|
|
79
|
+
], OxGristEditorAttribute);
|
|
80
|
+
export { OxGristEditorAttribute };
|
|
81
|
+
//# sourceMappingURL=ox-grist-editor-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-attribute.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-attribute.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAe,MAAM,gBAAgB,CAAA;AAGvD,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,aAAa;IAGvD,IAAI,cAAc;QAChB,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;QACtF,OAAO,IAAI,CAAA,qBAAqB,KAAK,IAAI,EAAE,SAAS,CAAA;IACtD,CAAC;IAED,QAAQ,CAAC,CAAQ;QACf,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IAED,UAAU,CAAC,CAAgB;QACzB,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;QACjB,IAAI,GAAG,IAAI,OAAO,EAAE;YAClB,CAAC,CAAC,eAAe,EAAE,CAAA;YACnB,IAAI,CAAC,SAAS,EAAE,CAAA;SACjB;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,IAAI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AAO,CAAC,EAAE;YACV,IAAI,KAAK,GAAQ,EAAE,CAAA;SACpB;QAED;;;;;;;UAOE;QACF,IAAI,QAAQ,GAAG,IAAI,CAAA;mCACY,KAAK,kBAAkB,YAAY,qBAAqB,eAAe;;KAErG,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE,KAAI,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE;YACtE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA9EY,sBAAsB;IADlC,aAAa,CAAC,2BAA2B,CAAC;GAC9B,sBAAsB,CA8ElC;SA9EY,sBAAsB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-attribute.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { cloneDeep } from 'lodash-es'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup, PopupHandle } from '@operato/popup'\n\n@customElement('ox-grist-editor-attribute')\nexport class OxGristEditorAttribute extends OxGristEditor {\n private popup?: PopupHandle\n\n get editorTemplate() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html`<div tabindex=\"0\">${value || ''}</div> `\n }\n\n _onclick(e: Event): void {\n e.stopPropagation()\n this.openPopup()\n }\n\n _onkeydown(e: KeyboardEvent): void {\n const key = e.key\n if (key == 'Enter') {\n e.stopPropagation()\n this.openPopup()\n }\n }\n\n async openPopup() {\n if (this.popup) {\n delete this.popup\n }\n\n var { options } = this.column.record\n var { attributeSet } = options || {}\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, 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 =\n !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(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-popup-attribute .value=${value} .attributeSet=${attributeSet} .confirmCallback=${confirmCallback}>\n </ox-popup-attribute>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.attributes')}`,\n help\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import './ox-popup-attributes.js';
|
|
5
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
6
|
+
export declare class OxGristEditorAttribute extends OxGristEditor {
|
|
7
|
+
private popup?;
|
|
8
|
+
get editorTemplate(): import("lit-html").TemplateResult<1>;
|
|
9
|
+
_onclick(e: Event): void;
|
|
10
|
+
_onkeydown(e: KeyboardEvent): void;
|
|
11
|
+
openPopup(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { __decorate } from "tslib";
|
|
5
|
+
import './ox-popup-attributes.js';
|
|
6
|
+
import { html } from 'lit';
|
|
7
|
+
import { customElement } from 'lit/decorators.js';
|
|
8
|
+
import { cloneDeep } from 'lodash-es';
|
|
9
|
+
import { OxGristEditor } from '@operato/data-grist';
|
|
10
|
+
import { i18next } from '@operato/i18n';
|
|
11
|
+
import { openPopup } from '@operato/popup';
|
|
12
|
+
let OxGristEditorAttribute = class OxGristEditorAttribute extends OxGristEditor {
|
|
13
|
+
get editorTemplate() {
|
|
14
|
+
const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value;
|
|
15
|
+
return html `<div tabindex="0">${value || ''}</div> `;
|
|
16
|
+
}
|
|
17
|
+
_onclick(e) {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
this.openPopup();
|
|
20
|
+
}
|
|
21
|
+
_onkeydown(e) {
|
|
22
|
+
const key = e.key;
|
|
23
|
+
if (key == 'Enter') {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
this.openPopup();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async openPopup() {
|
|
29
|
+
if (this.popup) {
|
|
30
|
+
delete this.popup;
|
|
31
|
+
}
|
|
32
|
+
var { options } = this.column.record;
|
|
33
|
+
var { attributeSet } = options || {};
|
|
34
|
+
if (typeof options === 'function') {
|
|
35
|
+
options = await options.call(this, this.value, this.column, this.record, this.row, this.field);
|
|
36
|
+
}
|
|
37
|
+
const { name, help, objectified = false } = options;
|
|
38
|
+
const confirmCallback = (newval) => {
|
|
39
|
+
this.dispatchEvent(new CustomEvent('field-change', {
|
|
40
|
+
bubbles: true,
|
|
41
|
+
composed: true,
|
|
42
|
+
detail: {
|
|
43
|
+
before: this.value,
|
|
44
|
+
after: !objectified ? JSON.stringify(newval) : newval,
|
|
45
|
+
record: this.record,
|
|
46
|
+
column: this.column,
|
|
47
|
+
row: this.row
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
var value = !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(this.value || {});
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
var value = {};
|
|
56
|
+
}
|
|
57
|
+
/*
|
|
58
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
59
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
60
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
61
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
62
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
63
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
64
|
+
*/
|
|
65
|
+
var template = html `
|
|
66
|
+
<ox-popup-attributes .value=${value} .attributeSet=${attributeSet} .confirmCallback=${confirmCallback}>
|
|
67
|
+
</ox-popup-attributes>
|
|
68
|
+
`;
|
|
69
|
+
this.popup = openPopup(template, {
|
|
70
|
+
backdrop: true,
|
|
71
|
+
size: 'large',
|
|
72
|
+
title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.attributes')}`,
|
|
73
|
+
help
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
OxGristEditorAttribute = __decorate([
|
|
78
|
+
customElement('ox-grist-editor-attributes')
|
|
79
|
+
], OxGristEditorAttribute);
|
|
80
|
+
export { OxGristEditorAttribute };
|
|
81
|
+
//# sourceMappingURL=ox-grist-editor-attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-grist-editor-attributes.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-attributes.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAe,MAAM,gBAAgB,CAAA;AAGvD,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,aAAa;IAGvD,IAAI,cAAc;QAChB,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;QACtF,OAAO,IAAI,CAAA,qBAAqB,KAAK,IAAI,EAAE,SAAS,CAAA;IACtD,CAAC;IAED,QAAQ,CAAC,CAAQ;QACf,CAAC,CAAC,eAAe,EAAE,CAAA;QACnB,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IAED,UAAU,CAAC,CAAgB;QACzB,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,CAAA;QACjB,IAAI,GAAG,IAAI,OAAO,EAAE;YAClB,CAAC,CAAC,eAAe,EAAE,CAAA;YACnB,IAAI,CAAC,SAAS,EAAE,CAAA;SACjB;IACH,CAAC;IAED,KAAK,CAAC,SAAS;QACb,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,KAAK,CAAA;SAClB;QAED,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;QAC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YAAY,qBAAqB,eAAe;;KAEtG,CAAA;QAED,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE,KAAI,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE;YACtE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA9EY,sBAAsB;IADlC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,sBAAsB,CA8ElC;SA9EY,sBAAsB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-attributes.js'\n\nimport { html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { cloneDeep } from 'lodash-es'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup, PopupHandle } from '@operato/popup'\n\n@customElement('ox-grist-editor-attributes')\nexport class OxGristEditorAttribute extends OxGristEditor {\n private popup?: PopupHandle\n\n get editorTemplate() {\n const value = typeof this.value === 'object' ? JSON.stringify(this.value) : this.value\n return html`<div tabindex=\"0\">${value || ''}</div> `\n }\n\n _onclick(e: Event): void {\n e.stopPropagation()\n this.openPopup()\n }\n\n _onkeydown(e: KeyboardEvent): void {\n const key = e.key\n if (key == 'Enter') {\n e.stopPropagation()\n this.openPopup()\n }\n }\n\n async openPopup() {\n if (this.popup) {\n delete this.popup\n }\n\n var { options } = this.column.record\n var { attributeSet } = options || {}\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, 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 =\n !objectified && typeof this.value === 'string' ? JSON.parse(this.value) : cloneDeep(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-popup-attributes .value=${value} .attributeSet=${attributeSet} .confirmCallback=${confirmCallback}>\n </ox-popup-attributes>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.attributes')}`,\n help\n })\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../ox-attribute-form.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { AttributeSet } from '../types.js';
|
|
4
|
+
export declare class OxPopupAttribute extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
value: any;
|
|
7
|
+
attributeSet?: AttributeSet;
|
|
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,92 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '../ox-attribute-form.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { i18next } from '@operato/i18n';
|
|
6
|
+
import { closePopup } from '@operato/popup';
|
|
7
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
8
|
+
let OxPopupAttribute = class OxPopupAttribute extends LitElement {
|
|
9
|
+
render() {
|
|
10
|
+
var attributeSet = this.attributeSet || {};
|
|
11
|
+
return html `
|
|
12
|
+
<ox-attribute-form .value=${this.value} .attributeSet=${attributeSet} @change=${this.onChange.bind(this)}>
|
|
13
|
+
</ox-attribute-form>
|
|
14
|
+
|
|
15
|
+
<div class="button-container">
|
|
16
|
+
<mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
17
|
+
<mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
onChange(e) {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
/*
|
|
24
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
25
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
26
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
27
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
28
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
29
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
30
|
+
(이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
|
|
31
|
+
=>
|
|
32
|
+
이런 이유로, Object.assign(...)을 사용하였다.
|
|
33
|
+
*/
|
|
34
|
+
this.value = e.detail;
|
|
35
|
+
}
|
|
36
|
+
onCancel(e) {
|
|
37
|
+
closePopup(this);
|
|
38
|
+
}
|
|
39
|
+
onConfirm(e) {
|
|
40
|
+
this.confirmCallback && this.confirmCallback(this.value);
|
|
41
|
+
closePopup(this);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
OxPopupAttribute.styles = [
|
|
45
|
+
ScrollbarStyles,
|
|
46
|
+
css `
|
|
47
|
+
:host {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
|
|
51
|
+
background-color: #fff;
|
|
52
|
+
|
|
53
|
+
width: var(--overlay-center-normal-width, 50%);
|
|
54
|
+
height: var(--overlay-center-normal-height, 50%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ox-data-item-spec {
|
|
58
|
+
flex: 1;
|
|
59
|
+
overflow-y: auto;
|
|
60
|
+
padding: var(--padding-wide);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
span {
|
|
64
|
+
flex: 1;
|
|
65
|
+
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
|
|
70
|
+
color: var(--primary-color);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.button-container {
|
|
74
|
+
display: flex;
|
|
75
|
+
margin-left: auto;
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
];
|
|
79
|
+
__decorate([
|
|
80
|
+
property({ type: Object })
|
|
81
|
+
], OxPopupAttribute.prototype, "value", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
property({ type: Object })
|
|
84
|
+
], OxPopupAttribute.prototype, "attributeSet", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
property({ type: Object })
|
|
87
|
+
], OxPopupAttribute.prototype, "confirmCallback", void 0);
|
|
88
|
+
OxPopupAttribute = __decorate([
|
|
89
|
+
customElement('ox-popup-attribute')
|
|
90
|
+
], OxPopupAttribute);
|
|
91
|
+
export { OxPopupAttribute };
|
|
92
|
+
//# sourceMappingURL=ox-popup-attribute.js.map
|
|
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AAK,CAAC,CAAA;QACxD,UAAU,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC;;AA9EM,uBAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BF;CACF,AAlCY,CAkCZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAwC;AAvCxD,gBAAgB;IAD5B,aAAa,CAAC,oBAAoB,CAAC;GACvB,gBAAgB,CAgF5B;SAhFY,gBAAgB","sourcesContent":["import '../ox-attribute-form.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { closePopup } from '@operato/popup'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { AttributeSet } from '../types.js'\n\n@customElement('ox-popup-attribute')\nexport class OxPopupAttribute 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-data-item-spec {\n flex: 1;\n overflow-y: auto;\n padding: var(--padding-wide);\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 }) attributeSet?: AttributeSet\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var attributeSet = this.attributeSet || {}\n\n return html`\n <ox-attribute-form .value=${this.value} .attributeSet=${attributeSet} @change=${this.onChange.bind(this)}>\n </ox-attribute-form>\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 this.value = e.detail\n }\n\n private onCancel(e: Event) {\n closePopup(this)\n }\n\n private onConfirm(e: Event) {\n this.confirmCallback && this.confirmCallback(this.value)\n closePopup(this)\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../ox-attribute-form.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { AttributeSet } from '../types.js';
|
|
4
|
+
export declare class OxPopupAttributes extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
value: any;
|
|
7
|
+
attributeSet?: AttributeSet;
|
|
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,92 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '../ox-attribute-form.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
5
|
+
import { i18next } from '@operato/i18n';
|
|
6
|
+
import { closePopup } from '@operato/popup';
|
|
7
|
+
import { ScrollbarStyles } from '@operato/styles';
|
|
8
|
+
let OxPopupAttributes = class OxPopupAttributes extends LitElement {
|
|
9
|
+
render() {
|
|
10
|
+
var attributeSet = this.attributeSet || {};
|
|
11
|
+
return html `
|
|
12
|
+
<ox-attribute-form .value=${this.value} .attributeSet=${attributeSet} @change=${this.onChange.bind(this)}>
|
|
13
|
+
</ox-attribute-form>
|
|
14
|
+
|
|
15
|
+
<div class="button-container">
|
|
16
|
+
<mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
|
|
17
|
+
<mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
|
|
18
|
+
</div>
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
onChange(e) {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
/*
|
|
24
|
+
주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
|
|
25
|
+
layout의 구성에 변화가 발생하면, 다시 render된다.
|
|
26
|
+
이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
|
|
27
|
+
이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
|
|
28
|
+
만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
|
|
29
|
+
따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
|
|
30
|
+
(이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
|
|
31
|
+
=>
|
|
32
|
+
이런 이유로, Object.assign(...)을 사용하였다.
|
|
33
|
+
*/
|
|
34
|
+
this.value = e.detail;
|
|
35
|
+
}
|
|
36
|
+
onCancel(e) {
|
|
37
|
+
closePopup(this);
|
|
38
|
+
}
|
|
39
|
+
onConfirm(e) {
|
|
40
|
+
this.confirmCallback && this.confirmCallback(this.value);
|
|
41
|
+
closePopup(this);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
OxPopupAttributes.styles = [
|
|
45
|
+
ScrollbarStyles,
|
|
46
|
+
css `
|
|
47
|
+
:host {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
|
|
51
|
+
background-color: #fff;
|
|
52
|
+
|
|
53
|
+
width: var(--overlay-center-normal-width, 50%);
|
|
54
|
+
height: var(--overlay-center-normal-height, 50%);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ox-data-item-spec {
|
|
58
|
+
flex: 1;
|
|
59
|
+
overflow-y: auto;
|
|
60
|
+
padding: var(--padding-wide);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
span {
|
|
64
|
+
flex: 1;
|
|
65
|
+
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
|
|
70
|
+
color: var(--primary-color);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.button-container {
|
|
74
|
+
display: flex;
|
|
75
|
+
margin-left: auto;
|
|
76
|
+
}
|
|
77
|
+
`
|
|
78
|
+
];
|
|
79
|
+
__decorate([
|
|
80
|
+
property({ type: Object })
|
|
81
|
+
], OxPopupAttributes.prototype, "value", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
property({ type: Object })
|
|
84
|
+
], OxPopupAttributes.prototype, "attributeSet", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
property({ type: Object })
|
|
87
|
+
], OxPopupAttributes.prototype, "confirmCallback", void 0);
|
|
88
|
+
OxPopupAttributes = __decorate([
|
|
89
|
+
customElement('ox-popup-attributes')
|
|
90
|
+
], OxPopupAttributes);
|
|
91
|
+
export { OxPopupAttributes };
|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e,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxD,UAAU,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC;;AA9EM,wBAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+BF;CACF,AAlCY,CAkCZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAwC;AAvCxD,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAgF7B;SAhFY,iBAAiB","sourcesContent":["import '../ox-attribute-form.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { i18next } from '@operato/i18n'\nimport { closePopup } from '@operato/popup'\nimport { ScrollbarStyles } from '@operato/styles'\n\nimport { AttributeSet } from '../types.js'\n\n@customElement('ox-popup-attributes')\nexport class OxPopupAttributes 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-data-item-spec {\n flex: 1;\n overflow-y: auto;\n padding: var(--padding-wide);\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 }) attributeSet?: AttributeSet\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var attributeSet = this.attributeSet || {}\n\n return html`\n <ox-attribute-form .value=${this.value} .attributeSet=${attributeSet} @change=${this.onChange.bind(this)}>\n </ox-attribute-form>\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 this.value = e.detail\n }\n\n private onCancel(e: Event) {\n closePopup(this)\n }\n\n private onConfirm(e: Event) {\n this.confirmCallback && this.confirmCallback(this.value)\n closePopup(this)\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA","sourcesContent":["export * from './types.js'\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@operato/input/ox-input-file.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import { AttributeSet } from './types.js';
|
|
4
|
+
export declare class OxAttributeForm extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
attributeSet?: AttributeSet;
|
|
7
|
+
value?: {
|
|
8
|
+
[tag: string]: any;
|
|
9
|
+
};
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
private onChange;
|
|
12
|
+
private buildInputs;
|
|
13
|
+
private buildValue;
|
|
14
|
+
}
|