@operato/dataset 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.editorconfig +29 -0
  2. package/.storybook/main.js +3 -0
  3. package/.storybook/server.mjs +8 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +75 -0
  7. package/demo/index.html +102 -0
  8. package/dist/src/grist-editor/index.d.ts +1 -0
  9. package/dist/src/grist-editor/index.js +7 -0
  10. package/dist/src/grist-editor/index.js.map +1 -0
  11. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.d.ts +11 -0
  12. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js +77 -0
  13. package/dist/src/grist-editor/ox-grist-editor-data-item-spec.js.map +1 -0
  14. package/dist/src/grist-editor/ox-popup-data-item-spec.d.ts +13 -0
  15. package/dist/src/grist-editor/ox-popup-data-item-spec.js +90 -0
  16. package/dist/src/grist-editor/ox-popup-data-item-spec.js.map +1 -0
  17. package/dist/src/index.d.ts +1 -0
  18. package/dist/src/index.js +2 -0
  19. package/dist/src/index.js.map +1 -0
  20. package/dist/src/ox-data-entry-form.d.ts +31 -0
  21. package/dist/src/ox-data-entry-form.js +83 -0
  22. package/dist/src/ox-data-entry-form.js.map +1 -0
  23. package/dist/src/ox-data-item-spec.d.ts +18 -0
  24. package/dist/src/ox-data-item-spec.js +77 -0
  25. package/dist/src/ox-data-item-spec.js.map +1 -0
  26. package/dist/src/ox-data-ooc-view.d.ts +11 -0
  27. package/dist/src/ox-data-ooc-view.js +75 -0
  28. package/dist/src/ox-data-ooc-view.js.map +1 -0
  29. package/dist/src/ox-data-sample-view.d.ts +13 -0
  30. package/dist/src/ox-data-sample-view.js +169 -0
  31. package/dist/src/ox-data-sample-view.js.map +1 -0
  32. package/dist/src/ox-data-use-case.d.ts +16 -0
  33. package/dist/src/ox-data-use-case.js +111 -0
  34. package/dist/src/ox-data-use-case.js.map +1 -0
  35. package/dist/src/types.d.ts +78 -0
  36. package/dist/src/types.js +2 -0
  37. package/dist/src/types.js.map +1 -0
  38. package/dist/tsconfig.tsbuildinfo +1 -0
  39. package/package.json +80 -0
  40. package/src/index.ts +1 -0
  41. package/src/ox-data-entry-form.ts +117 -0
  42. package/tsconfig.json +23 -0
  43. package/web-dev-server.config.mjs +27 -0
  44. 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,3 @@
1
+ module.exports = {
2
+ stories: ['../dist/stories/**/*.stories.{js,md,mdx}'],
3
+ };
@@ -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
+ ### [0.4.4](https://github.com/hatiolab/operato/compare/v0.4.3...v0.4.4) (2022-04-22)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * webcomponent dataset module ([832bbe7](https://github.com/hatiolab/operato/commit/832bbe7980082d798f37c0582ad13c0fa05be886))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) hatiolab.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,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,102 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <style>
6
+ body {
7
+ background: #fafafa;
8
+ --ox-checkbox-size: 12px;
9
+ }
10
+
11
+ #demo {
12
+ position: relative;
13
+ height: 300px;
14
+ background-color: lightgray;
15
+ vertical-align: middle;
16
+ }
17
+ </style>
18
+ <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
19
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
20
+ </head>
21
+ <body>
22
+ <div id="demo"></div>
23
+
24
+ <script type="module">
25
+ import { html, render } from 'lit'
26
+ import '../dist/src/ox-data-entry-form.js'
27
+
28
+ const parent = document.querySelector('#demo')
29
+ const dataSet = {
30
+ name: 'sample',
31
+ description: 'sample description',
32
+ dataItems: [
33
+ {
34
+ name: '창고 온도',
35
+ description: '창고 온도는 섭씨 0도 이하로 유지되어야 합니다.',
36
+ sequence: 1,
37
+ tag: 'temp',
38
+ type: 'number',
39
+ quota: 1
40
+ },
41
+ {
42
+ name: '창고 습도',
43
+ description: '창고 습도는 30% 이하로 유지되어야 합니다.',
44
+ sequence: 2,
45
+ tag: 'humid',
46
+ type: 'number',
47
+ quota: 5
48
+ },
49
+ {
50
+ name: '육안 검사',
51
+ description: '육안 검사는 포장전 30분 내로 실행되어야 합니다.',
52
+ sequence: 3,
53
+ tag: 'inspection',
54
+ type: 'boolean',
55
+ quota: 3
56
+ },
57
+ {
58
+ name: '품평',
59
+ description: '품평은 최우수/우수/보통/미달을 포함하여 간단히 평가.',
60
+ sequence: 4,
61
+ tag: 'evaluation',
62
+ type: 'select',
63
+ options: [
64
+ { display: '최우수', value: '최우수' },
65
+ { display: '우수', value: '우수' },
66
+ { display: '보통', value: '보통' },
67
+ { display: '미달', value: '미달' }
68
+ ],
69
+ quota: 3
70
+ },
71
+ {
72
+ name: '코멘트',
73
+ description: '특이사항을 기록함.',
74
+ sequence: 4,
75
+ tag: 'comment',
76
+ type: 'string',
77
+ quota: 1
78
+ }
79
+ ]
80
+ }
81
+
82
+ var value = {
83
+ temp: 1000,
84
+ humid: [20, 23, 21, 26, 27],
85
+ inspection: [true, false, true],
86
+ evaluation: ['최우수', '보통', '우수']
87
+ }
88
+
89
+ render(
90
+ html`<ox-data-entry-form
91
+ .dataSet=${dataSet}
92
+ .value=${value}
93
+ @change=${e => {
94
+ value = e.detail
95
+ console.log('change', value)
96
+ }}
97
+ ></ox-data-entry-form>`,
98
+ parent
99
+ )
100
+ </script>
101
+ </body>
102
+ </html>
@@ -0,0 +1 @@
1
+ export * from './ox-grist-editor-data-item-spec';
@@ -0,0 +1,7 @@
1
+ import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist';
2
+ import { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec';
3
+ /* register grist renderer/editor for id */
4
+ registerEditor('data-item-spec', OxGristEditorDataItemSpec);
5
+ registerRenderer('data-item-spec', OxGristRendererJson5);
6
+ export * from './ox-grist-editor-data-item-spec';
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,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AAE5E,2CAA2C;AAC3C,cAAc,CAAC,gBAAgB,EAAE,yBAAyB,CAAC,CAAA;AAE3D,gBAAgB,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;AAExD,cAAc,kCAAkC,CAAA","sourcesContent":["import { OxGristRendererJson5, registerEditor, registerRenderer } from '@operato/data-grist'\n\nimport { OxGristEditorDataItemSpec } from './ox-grist-editor-data-item-spec'\n\n/* register grist renderer/editor for id */\nregisterEditor('data-item-spec', OxGristEditorDataItemSpec)\n\nregisterRenderer('data-item-spec', OxGristRendererJson5)\n\nexport * from './ox-grist-editor-data-item-spec'\n"]}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import './ox-popup-data-item-spec.js';
5
+ import { OxGristEditor } from '@operato/data-grist';
6
+ export declare class OxGristEditorDataItemSpec extends OxGristEditor {
7
+ private popup?;
8
+ get editorTemplate(): import("lit-html").TemplateResult<1>;
9
+ firstUpdated(): Promise<void>;
10
+ openSelector(): Promise<void>;
11
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+ import { __decorate } from "tslib";
5
+ import './ox-popup-data-item-spec.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/layout';
12
+ let OxGristEditorDataItemSpec = class OxGristEditorDataItemSpec extends OxGristEditor {
13
+ get editorTemplate() {
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, 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) : cloneDeep(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-popup-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>
63
+ </ox-popup-data-item-spec>
64
+ `;
65
+ this.popup = openPopup(template, {
66
+ backdrop: true,
67
+ size: 'large',
68
+ title: `${(name === null || name === void 0 ? void 0 : name.toUpperCase()) || ''} ${i18next.t('field.spec')}`,
69
+ help
70
+ });
71
+ }
72
+ };
73
+ OxGristEditorDataItemSpec = __decorate([
74
+ customElement('ox-grist-editor-data-item-spec')
75
+ ], OxGristEditorDataItemSpec);
76
+ export { OxGristEditorDataItemSpec };
77
+ //# sourceMappingURL=ox-grist-editor-data-item-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-grist-editor-data-item-spec.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-grist-editor-data-item-spec.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,8BAA8B,CAAA;AAErC,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,iBAAiB,CAAA;AAGxD,IAAa,yBAAyB,GAAtC,MAAa,yBAA0B,SAAQ,aAAa;IAG1D,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,IAAI,KAAK,IAAI,EAAE,GAAG,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,cAAc,CAAA;QAEzB,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;YACrD,CAAC,CAAC,eAAe,EAAE,CAAA;YAEnB,IAAI,CAAC,YAAY,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;QAEF,IA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CAAA;SACxG;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,KAAK,GAAQ,EAAE,CAAA;SACpB;QAED;;;;;;;UAOE;QACF,IAAI,QAAQ,GAAG,IAAI,CAAA;wCACiB,KAAK,cAAc,IAAI,CAAC,MAAM,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,YAAY,CAAC,EAAE;YAChE,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AA5EY,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CA4ErC;SA5EY,yBAAyB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport './ox-popup-data-item-spec.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/layout'\n\n@customElement('ox-grist-editor-data-item-spec')\nexport class OxGristEditorDataItemSpec 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` ${value || ''} `\n }\n\n async firstUpdated() {\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', (e: Event) => {\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, 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-data-item-spec .value=${value} .dataItem=${this.record} .confirmCallback=${confirmCallback}>\n </ox-popup-data-item-spec>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: `${name?.toUpperCase() || ''} ${i18next.t('field.spec')}`,\n help\n })\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import '../ox-data-item-spec.js';
2
+ import { LitElement } from 'lit';
3
+ import { DataItem } from '../types.js';
4
+ export declare class OxPopupDataItemSpec extends LitElement {
5
+ static styles: import("lit").CSSResult[];
6
+ value: any;
7
+ dataItem?: DataItem;
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,90 @@
1
+ import { __decorate } from "tslib";
2
+ import '../ox-data-item-spec.js';
3
+ import { LitElement, css, html } from 'lit';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { ScrollbarStyles } from '@operato/styles';
6
+ import { i18next } from '@operato/i18n';
7
+ let OxPopupDataItemSpec = class OxPopupDataItemSpec extends LitElement {
8
+ render() {
9
+ var dataItem = this.dataItem || {};
10
+ return html `
11
+ <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>
12
+ </ox-data-item-spec>
13
+
14
+ <div class="button-container">
15
+ <mwc-button @click=${this.onCancel.bind(this)}>${i18next.t('button.cancel')}</mwc-button>
16
+ <mwc-button @click=${this.onConfirm.bind(this)}>${i18next.t('button.confirm')}</mwc-button>
17
+ </div>
18
+ `;
19
+ }
20
+ onChange(e) {
21
+ e.stopPropagation();
22
+ /*
23
+ 주의 : 이 팝업 템플릿은 layout 모듈에 의해서 render 되므로,
24
+ layout의 구성에 변화가 발생하면, 다시 render된다.
25
+ 이 팝업이 떠 있는 상태에서, 또 다른 팝업이 뜨는 경우도 layout 구성의 변화를 야기한다. (overlay의 갯수의 증가)
26
+ 이 경우 value, options, confirmCallback 등 클로져를 사용한 것들이 초기 바인딩된 값으로 다시 바인딩되게 되는데,
27
+ 만약, 템플릿 내부에서 이들 속성의 레퍼런스가 변화했다면, 원래 상태로 되돌아가는 현상이 발생하게 된다.
28
+ 따라서, 가급적 이들 속성의 레퍼런스를 변화시키지 않는 것이 좋다.
29
+ (이 팝업 클래스를 템플릿으로 사용한 곳의 코드를 참조하세요.)
30
+ =>
31
+ 이런 이유로, Object.assign(...)을 사용하였다.
32
+ */
33
+ this.value = e.detail;
34
+ }
35
+ onCancel(e) {
36
+ history.back();
37
+ }
38
+ onConfirm(e) {
39
+ this.confirmCallback && this.confirmCallback(this.value);
40
+ history.back();
41
+ }
42
+ };
43
+ OxPopupDataItemSpec.styles = [
44
+ ScrollbarStyles,
45
+ css `
46
+ :host {
47
+ display: flex;
48
+ flex-direction: column;
49
+
50
+ background-color: #fff;
51
+
52
+ width: var(--overlay-center-normal-width, 50%);
53
+ height: var(--overlay-center-normal-height, 50%);
54
+ }
55
+
56
+ ox-data-item-spec {
57
+ flex: 1;
58
+ overflow-y: auto;
59
+ }
60
+
61
+ span {
62
+ flex: 1;
63
+
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: center;
67
+
68
+ color: var(--primary-color);
69
+ }
70
+
71
+ .button-container {
72
+ display: flex;
73
+ margin-left: auto;
74
+ }
75
+ `
76
+ ];
77
+ __decorate([
78
+ property({ type: Object })
79
+ ], OxPopupDataItemSpec.prototype, "value", void 0);
80
+ __decorate([
81
+ property({ type: Object })
82
+ ], OxPopupDataItemSpec.prototype, "dataItem", void 0);
83
+ __decorate([
84
+ property({ type: Object })
85
+ ], OxPopupDataItemSpec.prototype, "confirmCallback", void 0);
86
+ OxPopupDataItemSpec = __decorate([
87
+ customElement('ox-popup-data-item-spec')
88
+ ], OxPopupDataItemSpec);
89
+ export { OxPopupDataItemSpec };
90
+ //# sourceMappingURL=ox-popup-data-item-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-popup-data-item-spec.js","sourceRoot":"","sources":["../../../src/grist-editor/ox-popup-data-item-spec.ts"],"names":[],"mappings":";AAAA,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAG3D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,UAAU;IAwCjD,MAAM;QACJ,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;QAElC,OAAO,IAAI,CAAA;kCACmB,IAAI,CAAC,KAAK,cAAc,QAAQ,YAAY,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;;;;6BAIzE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;6BACtD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;;KAEhF,CAAA;IACH,CAAC;IAEO,QAAQ,CAAC,CAAc;QAC7B,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB;;;;;;;;;;UAUE;QACF,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAA;IACvB,CAAC;IAEO,QAAQ,CAAC,CAAQ;QACvB,OAAO,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC;IAEO,SAAS,CAAC,CAAQ;QACxB,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxD,OAAO,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC;CACF,CAAA;AA9EQ,0BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAoB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAwC;AAtCxD,mBAAmB;IAD/B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,mBAAmB,CA+E/B;SA/EY,mBAAmB","sourcesContent":["import '../ox-data-item-spec.js'\n\nimport { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { DataItem } from '../types.js'\nimport { ScrollbarStyles } from '@operato/styles'\nimport { i18next } from '@operato/i18n'\n\n@customElement('ox-popup-data-item-spec')\nexport class OxPopupDataItemSpec 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 }\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 }) dataItem?: DataItem\n @property({ type: Object }) confirmCallback!: (newval: any) => void\n\n render() {\n var dataItem = this.dataItem || {}\n\n return html`\n <ox-data-item-spec .value=${this.value} .dataItem=${dataItem} @change=${this.onChange.bind(this)}>\n </ox-data-item-spec>\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 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 @@
1
+ export * from './ox-data-entry-form';
@@ -0,0 +1,2 @@
1
+ export * from './ox-data-entry-form';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA","sourcesContent":["export * from './ox-data-entry-form'\n"]}
@@ -0,0 +1,31 @@
1
+ import { LitElement } from 'lit';
2
+ declare type SelectOption = {
3
+ [display: string]: string;
4
+ };
5
+ declare type SelectOptions = SelectOption[];
6
+ export declare type DataItem = {
7
+ name: string;
8
+ description: string;
9
+ sequence: number;
10
+ tag: string;
11
+ type: string;
12
+ options: SelectOptions;
13
+ quota: number;
14
+ };
15
+ export declare type DataSet = {
16
+ name: string;
17
+ description: string;
18
+ dataItems: DataItem[];
19
+ };
20
+ export declare class OxDataEntryForm extends LitElement {
21
+ static styles: import("lit").CSSResult;
22
+ dataSet?: DataSet;
23
+ value?: {
24
+ [tag: string]: any;
25
+ };
26
+ render(): import("lit-html").TemplateResult<1>;
27
+ private onChange;
28
+ private buildInputs;
29
+ private buildValue;
30
+ }
31
+ export {};
@@ -0,0 +1,83 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, css, html } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
5
+ render() {
6
+ return html `<form @change=${(e) => this.onChange(e)}>${this.buildInputs()}</form>`;
7
+ }
8
+ onChange(e) {
9
+ const value = this.buildValue();
10
+ this.dispatchEvent(new CustomEvent('change', {
11
+ bubbles: true,
12
+ composed: true,
13
+ detail: value
14
+ }));
15
+ }
16
+ buildInputs() {
17
+ const dataItems = this.dataSet.dataItems;
18
+ return (dataItems || []).map(dataItem => {
19
+ var _a;
20
+ const { name, description, tag, type, quota = 1, options = [] } = dataItem;
21
+ const samples = new Array(quota).fill(0);
22
+ const value = (_a = this.value) === null || _a === void 0 ? void 0 : _a[tag];
23
+ const elements = samples.map((_, idx) => {
24
+ const v = quota <= 1 ? value : value instanceof Array && value[idx];
25
+ switch (type) {
26
+ case 'select':
27
+ return html ` <select .name=${tag}>
28
+ ${options.map(option => html `<option value=${option.value} ?selected=${option.value === v}>${option.display}</option>`)}
29
+ </select>`;
30
+ break;
31
+ case 'boolean':
32
+ return html ` <input type="checkbox" name=${tag} .checked=${v} />`;
33
+ break;
34
+ case 'number':
35
+ return html ` <input type="number" name=${tag} value=${v} />`;
36
+ break;
37
+ case 'string':
38
+ default:
39
+ return html ` <input type="string" name=${tag} value=${v} />`;
40
+ }
41
+ });
42
+ return html `<label .title=${description}>${name}${elements}</label>`;
43
+ });
44
+ }
45
+ buildValue() {
46
+ const dataItems = this.dataSet.dataItems;
47
+ return (dataItems || []).reduce((sum, dataItem) => {
48
+ const { tag, quota, type } = dataItem;
49
+ const editors = Array.prototype.slice.call(this.renderRoot.querySelectorAll(`[name=${tag}]`));
50
+ if (editors.length > 0) {
51
+ sum[tag] =
52
+ editors.length > 1
53
+ ? editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))
54
+ : type === 'boolean'
55
+ ? editors[0].checked
56
+ : editors[0].value;
57
+ }
58
+ return sum;
59
+ }, {});
60
+ }
61
+ };
62
+ OxDataEntryForm.styles = css `
63
+ :host {
64
+ display: flex;
65
+ flex-direction: row;
66
+ }
67
+
68
+ form {
69
+ display: flex;
70
+ flex-direction: column;
71
+ }
72
+ `;
73
+ __decorate([
74
+ property({ type: Object })
75
+ ], OxDataEntryForm.prototype, "dataSet", void 0);
76
+ __decorate([
77
+ property({ type: Object })
78
+ ], OxDataEntryForm.prototype, "value", void 0);
79
+ OxDataEntryForm = __decorate([
80
+ customElement('ox-data-entry-form')
81
+ ], OxDataEntryForm);
82
+ export { OxDataEntryForm };
83
+ //# sourceMappingURL=ox-data-entry-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-data-entry-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-form.ts"],"names":[],"mappings":";AAAA,O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;oBACN,OAAO,CAAC,MAAM,GAAG,CAAC;wBAChB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC7E,CAAC,CAAC,IAAI,KAAK,SAAS;4BACpB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO;4BACpB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;aACvB;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA4B,CAAC,CAAA;IAClC,CAAC;CACF,CAAA;AA5FQ,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;GAUlB,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAA+B;AAd/C,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CA6F3B;SA7FY,eAAe","sourcesContent":["import { LitElement, css, html } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\ntype SelectOption = { [display: string]: string }\ntype SelectOptions = SelectOption[]\n\nexport type DataItem = {\n name: string\n description: string\n sequence: number\n tag: string\n type: string\n options: SelectOptions\n quota: number\n}\n\nexport type DataSet = {\n name: string\n description: string\n dataItems: DataItem[]\n}\n\n@customElement('ox-data-entry-form')\nexport class OxDataEntryForm extends LitElement {\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n }\n\n form {\n display: flex;\n flex-direction: column;\n }\n `\n\n @property({ type: Object }) dataSet?: DataSet\n @property({ type: Object }) value?: { [tag: string]: any }\n\n render() {\n return html`<form @change=${(e: Event) => this.onChange(e)}>${this.buildInputs()}</form>`\n }\n\n private onChange(e: Event) {\n const value = this.buildValue()\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: value\n })\n )\n }\n\n private buildInputs() {\n const dataItems = this.dataSet!.dataItems\n\n return (dataItems || []).map(dataItem => {\n const { name, description, tag, type, quota = 1, options = [] } = dataItem\n\n const samples = new Array(quota).fill(0)\n const value = this.value?.[tag]\n\n const elements = samples.map((_, idx) => {\n const v = quota <= 1 ? value : value instanceof Array && value[idx]\n\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n ${options.map(\n option => html`<option value=${option.value} ?selected=${option.value === v}>${option.display}</option>`\n )}\n </select>`\n break\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${v} />`\n break\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${v} />`\n break\n\n case 'string':\n default:\n return html` <input type=\"string\" name=${tag} value=${v} />`\n }\n })\n\n return html`<label .title=${description}>${name}${elements}</label>`\n })\n }\n\n private buildValue() {\n const dataItems = this.dataSet!.dataItems\n\n return (dataItems || []).reduce((sum, dataItem) => {\n const { tag, quota, type } = dataItem\n\n const editors = Array.prototype.slice.call(\n this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>\n ) as HTMLInputElement[]\n\n if (editors.length > 0) {\n sum[tag] =\n editors.length > 1\n ? editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n : type === 'boolean'\n ? editors[0].checked\n : editors[0].value\n }\n\n return sum\n }, {} as { [tag: string]: any })\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import '@operato/property-editor/ox-properties-dynamic-view.js';
2
+ import { LitElement, PropertyValues } from 'lit';
3
+ import { DataItem, DataItemSpecSet } from './types.js';
4
+ export declare class OxDataItemSpec extends LitElement {
5
+ static styles: import("lit").CSSResult;
6
+ value?: {
7
+ [specSetName: string]: any;
8
+ };
9
+ dataItem?: DataItem;
10
+ dataItemSpecSets: DataItemSpecSet[];
11
+ specSetViews: NodeListOf<HTMLElement & {
12
+ value: any;
13
+ }>;
14
+ render(): import("lit-html").TemplateResult<1>;
15
+ updated(changes: PropertyValues<this>): void;
16
+ private onChange;
17
+ private buildValue;
18
+ }