@operato/dataset 1.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +75 -0
- package/demo/index.html +102 -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-data-entry-form.d.ts +31 -0
- package/dist/src/ox-data-entry-form.js +83 -0
- package/dist/src/ox-data-entry-form.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +80 -0
- package/src/index.ts +1 -0
- package/src/ox-data-entry-form.ts +117 -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.0.0-alpha.1](https://github.com/hatiolab/operato/compare/v0.4.3...v1.0.0-alpha.1) (2022-03-09)
|
|
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`
|
package/demo/index.html
ADDED
|
@@ -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-data-entry-form';
|
|
@@ -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":"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","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 @@
|
|
|
1
|
+
{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/@lit/reactive-element/css-tag.d.ts","../../../node_modules/@lit/reactive-element/reactive-controller.d.ts","../../../node_modules/@lit/reactive-element/reactive-element.d.ts","../../../node_modules/@types/trusted-types/lib/index.d.ts","../../../node_modules/@types/trusted-types/index.d.ts","../../../node_modules/lit-html/directive.d.ts","../../../node_modules/lit-html/lit-html.d.ts","../../../node_modules/lit-element/lit-element.d.ts","../../../node_modules/lit/index.d.ts","../../../node_modules/@lit/reactive-element/decorators/base.d.ts","../../../node_modules/@lit/reactive-element/decorators/custom-element.d.ts","../../../node_modules/@lit/reactive-element/decorators/property.d.ts","../../../node_modules/@lit/reactive-element/decorators/state.d.ts","../../../node_modules/@lit/reactive-element/decorators/event-options.d.ts","../../../node_modules/@lit/reactive-element/decorators/query.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-all.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-async.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-assigned-nodes.d.ts","../../../node_modules/@lit/reactive-element/decorators/query-assigned-elements.d.ts","../../../node_modules/lit/decorators.d.ts","../src/ox-data-entry-form.ts","../src/index.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/mocha/index.d.ts"],"fileInfos":[{"version":"3ac1b83264055b28c0165688fda6dfcc39001e9e7828f649299101c23ad0a0c3","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",{"version":"72704b10d97777e15f1a581b73f88273037ef752d2e50b72287bd0a90af64fe6","affectsGlobalScope":true},{"version":"d8996609230d17e90484a2dd58f22668f9a05a3bfe00bfb1d6271171e54a31fb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"5075b36ab861c8c0c45377cb8c96270d7c65f0eeaf105d53fac6850da61f1027","affectsGlobalScope":true},{"version":"10bbdc1981b8d9310ee75bfac28ee0477bb2353e8529da8cff7cb26c409cb5e8","affectsGlobalScope":true},"12f4cfe2fe60b810c3174537bc2ddb20c1067b7768643d12cb1266fd183afb75","6e2c5a9358c2be6791713f778c3af2d3357b8665d881e22f50b3aa861a2a9717","1e5743b25a63fd34ffbae89adcbf248ee17db6ed08d90079ffa93803c3e80d2a","13bb750b495c48fd60d7b5e09f65d4a7b010ab7e09a8943a6d54511e7d184f84","2fcd2d22b1f30555e785105597cd8f57ed50300e213c4f1bbca6ae149f782c38",{"version":"bb4248c7f953233ac52332088fac897d62b82be07244e551d87c5049600b6cf7","affectsGlobalScope":true},"70f04c91d3186b1b10157157887fab664968fc9b88377785a5ee42750c202c6d","f690af1a7043e58fce8c672df5e1d1e27bad7459b81143af991db7c5427a0785","eba7cf33380cc3a3cf614faf67300e14d0bdff9ea6c5cd6f4b040b1756a48ab1","f07a77a7fb1d49aa2b61cb68bf712a083487acd7130d20223a83de03af0c257d","97c58f6db61d45712d91d2260994817ae2b568bbb37cc280013079b6b5d2232d","ac388c7c7a262213a3700451bc921e382a93fb27c0252c34ccf03540b4ce044b","1da789e534bc558808021dd64abf33a91a68e422bbf28aeec236bd74df640401","fb0107c83e2e0e75b77dacd0c3c6c3ab6844e98dce2a8f858c6f0a57c12136a6","0a478dcb6e6bd8a5d871165659c79cee7b8c3b7a87289118d22e1a04d171e252","a25d1e52291791819032826af5c52987e16ffdb96e8bb69f7f1790f5ab080be6","d660961abada6b5030461f3322ef3a2e1d9fec74167574f8b590a7796cf90a72","707b4eae3d469b2f347d2083037151922f94c370a9456ebd5ac0a4fb7441c7e7","4bcb813ea56182beaaab1e8274524eb9f1449b0d8e79efc4a0399de09e43f816","c784eab1cf838d9d6527bce3d9f2d373145606666b68f7610291a7adf6e6bda9","f0380f581cb015778c0fe51e95b5b7f6dae237280654558469b2486c1572268a","44c86bcca0e63e86dc18447346f831f9357b4eab27630e888b4002828005debb","ce721cb3eefd816b0b2d5488e0e7d2ef3442f990d77249a29833c2b280f1b46d","0cba3a5d7b81356222594442753cf90dd2892e5ccfe1d262aaca6896ba6c1380","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"c2ab70bbc7a24c42a790890739dd8a0ba9d2e15038b40dff8163a97a5d148c00","affectsGlobalScope":true},"422dbb183fdced59425ca072c8bd09efaa77ce4e2ab928ec0d8a1ce062d2a45a",{"version":"712ba0d43b44d144dfd01593f61af6e2e21cfae83e834d297643e7973e55ed61","affectsGlobalScope":true},"1dab5ab6bcf11de47ab9db295df8c4f1d92ffa750e8f095e88c71ce4c3299628","f71f46ccd5a90566f0a37b25b23bc4684381ab2180bdf6733f4e6624474e1894",{"version":"54e65985a3ee3cec182e6a555e20974ea936fc8b8d1738c14e8ed8a42bd921d4","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","98a3ebfa494b46265634a73459050befba5da8fdc6ca0ef9b7269421780f4ff3","34e5de87d983bc6aefef8b17658556e3157003e8d9555d3cb098c6bef0b5fbc8","cc0b61316c4f37393f1f9595e93b673f4184e9d07f4c127165a490ec4a928668","f27371653aded82b2b160f7a7033fb4a5b1534b6f6081ef7be1468f0f15327d3","c762cd6754b13a461c54b59d0ae0ab7aeef3c292c6cf889873f786ee4d8e75c9","f4ea7d5df644785bd9fbf419930cbaec118f0d8b4160037d2339b8e23c059e79",{"version":"bfea28e6162ed21a0aeed181b623dcf250aa79abf49e24a6b7e012655af36d81","affectsGlobalScope":true},"7a5459efa09ea82088234e6533a203d528c594b01787fb90fba148885a36e8b6","ae97e20f2e10dbeec193d6a2f9cd9a367a1e293e7d6b33b68bacea166afd7792","10d4796a130577d57003a77b95d8723530bbec84718e364aa2129fa8ffba0378","ad41bb744149e92adb06eb953da195115620a3f2ad48e7d3ae04d10762dae197","bf73c576885408d4a176f44a9035d798827cc5020d58284cb18d7573430d9022","7ae078ca42a670445ae0c6a97c029cb83d143d62abd1730efb33f68f0b2c0e82",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"5d0a9ea09d990b5788f867f1c79d4878f86f7384cb7dab38eecbf22f9efd063d","12eea70b5e11e924bb0543aea5eadc16ced318aa26001b453b0d561c2fd0bd1e","08777cd9318d294646b121838574e1dd7acbb22c21a03df84e1f2c87b1ad47f2","08a90bcdc717df3d50a2ce178d966a8c353fd23e5c392fd3594a6e39d9bb6304",{"version":"4cd4cff679c9b3d9239fd7bf70293ca4594583767526916af8e5d5a47d0219c7","affectsGlobalScope":true},"2a12d2da5ac4c4979401a3f6eaafa874747a37c365e4bc18aa2b171ae134d21b","002b837927b53f3714308ecd96f72ee8a053b8aeb28213d8ec6de23ed1608b66","1dc9c847473bb47279e398b22c740c83ea37a5c88bf66629666e3cf4c5b9f99c","a9e4a5a24bf2c44de4c98274975a1a705a0abbaad04df3557c2d3cd8b1727949","00fa7ce8bc8acc560dc341bbfdf37840a8c59e6a67c9bfa3fa5f36254df35db2","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","5f0ed51db151c2cdc4fa3bb0f44ce6066912ad001b607a34e65a96c52eb76248",{"version":"3345c276cab0e76dda86c0fb79104ff915a4580ba0f3e440870e183b1baec476","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","e383ff72aabf294913f8c346f5da1445ae6ad525836d28efd52cbadc01a361a6","f52fbf64c7e480271a9096763c4882d356b05cab05bf56a64e68a95313cd2ce2","59bdb65f28d7ce52ccfc906e9aaf422f8b8534b2d21c32a27d7819be5ad81df7",{"version":"3a2da34079a2567161c1359316a32e712404b56566c45332ac9dcee015ecce9f","affectsGlobalScope":true},"28a2e7383fd898c386ffdcacedf0ec0845e5d1a86b5a43f25b86bc315f556b79","3aff9c8c36192e46a84afe7b926136d520487155154ab9ba982a8b544ea8fc95","a880cf8d85af2e4189c709b0fea613741649c0e40fffb4360ec70762563d5de0","85bbf436a15bbeda4db888be3062d47f99c66fd05d7c50f0f6473a9151b6a070","9f9c49c95ecd25e0cb2587751925976cf64fd184714cb11e213749c80cf0f927","f0c75c08a71f9212c93a719a25fb0320d53f2e50ca89a812640e08f8ad8c408c",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"9cafe917bf667f1027b2bb62e2de454ecd2119c80873ad76fc41d941089753b8",{"version":"5f186a758a616c107c70e8918db4630d063bd782f22e6e0b17573b125765b40b","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./","rootDir":"..","sourceMap":true,"strict":true,"target":5,"useDefineForClassFields":false},"fileIdsList":[[106],[43,106],[50,106],[43,50,106],[43,50,58,106],[41,42,106],[63,106],[66,106],[67,72,106],[68,78,79,86,95,105,106],[68,69,78,86,106],[70,106],[71,72,79,87,106],[72,95,102,106],[73,75,78,86,106],[74,106],[75,76,106],[77,78,106],[78,106],[78,79,80,95,105,106],[78,79,80,95,106],[81,86,95,105,106],[78,79,81,82,86,95,102,105,106],[81,83,95,102,105,106],[63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112],[78,84,106],[85,105,106],[75,78,86,95,106],[87,106],[88,106],[66,89,106],[90,104,106,110],[91,106],[92,106],[78,93,106],[93,94,106,108],[78,95,96,97,106],[95,97,106],[95,96,106],[98,106],[99,106],[78,100,101,106],[100,101,106],[72,86,95,102,106],[103,106],[86,104,106],[67,81,92,105,106],[72,106],[95,106,107],[106,108],[106,109],[67,72,78,80,89,95,105,106,108,110],[95,106,111],[44,106],[43,47,106],[47,106],[45,46,106],[51,52,53,54,55,56,57,58,59,106],[43,47,48,106],[40,61,106],[40,49,60,106]],"referencedMap":[[41,1],[50,2],[51,3],[54,4],[52,4],[56,4],[59,5],[58,1],[57,4],[55,4],[53,3],[42,1],[43,6],[114,1],[63,7],[64,7],[66,8],[67,9],[68,10],[69,11],[70,12],[71,13],[72,14],[73,15],[74,16],[75,17],[76,17],[77,18],[78,19],[79,20],[80,21],[65,1],[112,1],[81,22],[82,23],[83,24],[113,25],[84,26],[85,27],[86,28],[87,29],[88,30],[89,31],[90,32],[91,33],[92,34],[93,35],[94,36],[95,37],[97,38],[96,39],[98,40],[99,41],[100,42],[101,43],[102,44],[103,45],[104,46],[105,47],[106,48],[107,49],[108,50],[109,51],[110,52],[111,53],[45,54],[44,1],[48,55],[46,56],[47,57],[60,58],[49,59],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[62,60],[61,61]],"exportedModulesMap":[[41,1],[50,2],[51,3],[54,4],[52,4],[56,4],[59,5],[58,1],[57,4],[55,4],[53,3],[42,1],[43,6],[114,1],[63,7],[64,7],[66,8],[67,9],[68,10],[69,11],[70,12],[71,13],[72,14],[73,15],[74,16],[75,17],[76,17],[77,18],[78,19],[79,20],[80,21],[65,1],[112,1],[81,22],[82,23],[83,24],[113,25],[84,26],[85,27],[86,28],[87,29],[88,30],[89,31],[90,32],[91,33],[92,34],[93,35],[94,36],[95,37],[97,38],[96,39],[98,40],[99,41],[100,42],[101,43],[102,44],[103,45],[104,46],[105,47],[106,48],[107,49],[108,50],[109,51],[110,52],[111,53],[45,54],[44,1],[48,55],[46,56],[47,57],[60,58],[49,59],[40,1],[8,1],[10,1],[9,1],[2,1],[11,1],[12,1],[13,1],[14,1],[15,1],[16,1],[17,1],[18,1],[3,1],[4,1],[22,1],[19,1],[20,1],[21,1],[23,1],[24,1],[25,1],[5,1],[26,1],[27,1],[28,1],[29,1],[6,1],[30,1],[31,1],[32,1],[33,1],[7,1],[38,1],[34,1],[35,1],[36,1],[37,1],[1,1],[39,1],[62,60],[61,61]],"semanticDiagnosticsPerFile":[41,50,51,54,52,56,59,58,57,55,53,42,43,114,63,64,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,65,112,81,82,83,113,84,85,86,87,88,89,90,91,92,93,94,95,97,96,98,99,100,101,102,103,104,105,106,107,108,109,110,111,45,44,48,46,47,60,49,40,8,10,9,2,11,12,13,14,15,16,17,18,3,4,22,19,20,21,23,24,25,5,26,27,28,29,6,30,31,32,33,7,38,34,35,36,37,1,39,62,61]},"version":"4.6.2"}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@operato/dataset",
|
|
3
|
+
"description": "WebApplication dataset supporting components following open-wc recommendations",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "heartyoh",
|
|
6
|
+
"version": "1.0.0-alpha.1",
|
|
7
|
+
"main": "dist/src/index.js",
|
|
8
|
+
"module": "dist/src/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/src/index.js",
|
|
11
|
+
"./ox-data-entry-form.js": "./dist/src/ox-data-entry-form.js"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"@operato:registry": "https://registry.npmjs.org"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/hatiolab/operato.git",
|
|
20
|
+
"directory": "webcomponents/dataset"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"analyze": "cem analyze --litelement",
|
|
24
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
25
|
+
"build": "tsc && npm run analyze -- --exclude dist",
|
|
26
|
+
"prepublish": "tsc && npm run analyze -- --exclude dist",
|
|
27
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
28
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
29
|
+
"test": "tsc && wtr --coverage",
|
|
30
|
+
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
|
|
31
|
+
"storybook": "tsc && npm run analyze -- --exclude dist && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds -c .storybook/server.mjs\"",
|
|
32
|
+
"storybook:build": "tsc && npm run analyze -- --exclude dist && build-storybook"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@material/mwc-button": "^0.25.3",
|
|
36
|
+
"@material/mwc-icon": "^0.25.3",
|
|
37
|
+
"@material/mwc-icon-button": "^0.25.3",
|
|
38
|
+
"@operato/graphql": "^1.0.0-alpha.1",
|
|
39
|
+
"@operato/i18n": "^1.0.0-alpha.1",
|
|
40
|
+
"@operato/layout": "^1.0.0-alpha.1",
|
|
41
|
+
"@operato/property-editor": "^1.0.0-alpha.1",
|
|
42
|
+
"@operato/shell": "^1.0.0-alpha.1",
|
|
43
|
+
"@operato/styles": "^1.0.0-alpha.1",
|
|
44
|
+
"@operato/utils": "^1.0.0-alpha.1",
|
|
45
|
+
"lit": "^2.2.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@custom-elements-manifest/analyzer": "^0.4.17",
|
|
49
|
+
"@hatiolab/prettier-config": "^1.0.0",
|
|
50
|
+
"@open-wc/eslint-config": "^4.3.0",
|
|
51
|
+
"@open-wc/testing": "^3.0.4",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
53
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
54
|
+
"@web/dev-server": "^0.1.29",
|
|
55
|
+
"@web/dev-server-storybook": "next",
|
|
56
|
+
"@web/test-runner": "next",
|
|
57
|
+
"concurrently": "^5.3.0",
|
|
58
|
+
"eslint": "^7.32.0",
|
|
59
|
+
"eslint-config-prettier": "^8.3.0",
|
|
60
|
+
"husky": "^4.3.8",
|
|
61
|
+
"lint-staged": "^10.5.4",
|
|
62
|
+
"prettier": "^2.4.1",
|
|
63
|
+
"tslib": "^2.3.1",
|
|
64
|
+
"typescript": "^4.5.2"
|
|
65
|
+
},
|
|
66
|
+
"customElements": "custom-elements.json",
|
|
67
|
+
"prettier": "@hatiolab/prettier-config",
|
|
68
|
+
"husky": {
|
|
69
|
+
"hooks": {
|
|
70
|
+
"pre-commit": "lint-staged"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*.ts": [
|
|
75
|
+
"eslint --fix",
|
|
76
|
+
"prettier --write"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"gitHead": "c1e9c1dc58feb942d69a2f8392358accb2860184"
|
|
80
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ox-data-entry-form'
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit'
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
3
|
+
|
|
4
|
+
type SelectOption = { [display: string]: string }
|
|
5
|
+
type SelectOptions = SelectOption[]
|
|
6
|
+
|
|
7
|
+
export type DataItem = {
|
|
8
|
+
name: string
|
|
9
|
+
description: string
|
|
10
|
+
sequence: number
|
|
11
|
+
tag: string
|
|
12
|
+
type: string
|
|
13
|
+
options: SelectOptions
|
|
14
|
+
quota: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type DataSet = {
|
|
18
|
+
name: string
|
|
19
|
+
description: string
|
|
20
|
+
dataItems: DataItem[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@customElement('ox-data-entry-form')
|
|
24
|
+
export class OxDataEntryForm extends LitElement {
|
|
25
|
+
static styles = css`
|
|
26
|
+
:host {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
form {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
@property({ type: Object }) dataSet?: DataSet
|
|
38
|
+
@property({ type: Object }) value?: { [tag: string]: any }
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
return html`<form @change=${(e: Event) => this.onChange(e)}>${this.buildInputs()}</form>`
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private onChange(e: Event) {
|
|
45
|
+
const value = this.buildValue()
|
|
46
|
+
|
|
47
|
+
this.dispatchEvent(
|
|
48
|
+
new CustomEvent('change', {
|
|
49
|
+
bubbles: true,
|
|
50
|
+
composed: true,
|
|
51
|
+
detail: value
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private buildInputs() {
|
|
57
|
+
const dataItems = this.dataSet!.dataItems
|
|
58
|
+
|
|
59
|
+
return (dataItems || []).map(dataItem => {
|
|
60
|
+
const { name, description, tag, type, quota = 1, options = [] } = dataItem
|
|
61
|
+
|
|
62
|
+
const samples = new Array(quota).fill(0)
|
|
63
|
+
const value = this.value?.[tag]
|
|
64
|
+
|
|
65
|
+
const elements = samples.map((_, idx) => {
|
|
66
|
+
const v = quota <= 1 ? value : value instanceof Array && value[idx]
|
|
67
|
+
|
|
68
|
+
switch (type) {
|
|
69
|
+
case 'select':
|
|
70
|
+
return html` <select .name=${tag}>
|
|
71
|
+
${options.map(
|
|
72
|
+
option => html`<option value=${option.value} ?selected=${option.value === v}>${option.display}</option>`
|
|
73
|
+
)}
|
|
74
|
+
</select>`
|
|
75
|
+
break
|
|
76
|
+
|
|
77
|
+
case 'boolean':
|
|
78
|
+
return html` <input type="checkbox" name=${tag} .checked=${v} />`
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
case 'number':
|
|
82
|
+
return html` <input type="number" name=${tag} value=${v} />`
|
|
83
|
+
break
|
|
84
|
+
|
|
85
|
+
case 'string':
|
|
86
|
+
default:
|
|
87
|
+
return html` <input type="string" name=${tag} value=${v} />`
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return html`<label .title=${description}>${name}${elements}</label>`
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private buildValue() {
|
|
96
|
+
const dataItems = this.dataSet!.dataItems
|
|
97
|
+
|
|
98
|
+
return (dataItems || []).reduce((sum, dataItem) => {
|
|
99
|
+
const { tag, quota, type } = dataItem
|
|
100
|
+
|
|
101
|
+
const editors = Array.prototype.slice.call(
|
|
102
|
+
this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>
|
|
103
|
+
) as HTMLInputElement[]
|
|
104
|
+
|
|
105
|
+
if (editors.length > 0) {
|
|
106
|
+
sum[tag] =
|
|
107
|
+
editors.length > 1
|
|
108
|
+
? editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))
|
|
109
|
+
: type === 'boolean'
|
|
110
|
+
? editors[0].checked
|
|
111
|
+
: editors[0].value
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return sum
|
|
115
|
+
}, {} as { [tag: string]: any })
|
|
116
|
+
}
|
|
117
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"useDefineForClassFields": false,
|
|
13
|
+
"importHelpers": true,
|
|
14
|
+
"outDir": "dist",
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"inlineSources": true,
|
|
17
|
+
"rootDir": "./",
|
|
18
|
+
"declaration": true,
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"types": ["node", "mocha"]
|
|
21
|
+
},
|
|
22
|
+
"include": ["**/*.ts"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
+
|
|
3
|
+
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
+
const hmr = process.argv.includes('--hmr');
|
|
5
|
+
|
|
6
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
+
open: '/demo/',
|
|
8
|
+
/** Use regular watch mode if HMR is not enabled. */
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
/** Resolve bare module imports */
|
|
11
|
+
nodeResolve: {
|
|
12
|
+
exportConditions: ['browser', 'development'],
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
16
|
+
// esbuildTarget: 'auto'
|
|
17
|
+
|
|
18
|
+
/** Set appIndex to enable SPA routing */
|
|
19
|
+
// appIndex: 'demo/index.html',
|
|
20
|
+
|
|
21
|
+
plugins: [
|
|
22
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
23
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// See documentation for all available options
|
|
27
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
+
|
|
3
|
+
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
+
|
|
5
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
+
/** Test files to run */
|
|
7
|
+
files: 'dist/test/**/*.test.js',
|
|
8
|
+
|
|
9
|
+
/** Resolve bare module imports */
|
|
10
|
+
nodeResolve: {
|
|
11
|
+
exportConditions: ['browser', 'development'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/** Filter out lit dev mode logs */
|
|
15
|
+
filterBrowserLogs(log) {
|
|
16
|
+
for (const arg of log.args) {
|
|
17
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
+
// esbuildTarget: 'auto',
|
|
26
|
+
|
|
27
|
+
/** Amount of browsers to run concurrently */
|
|
28
|
+
// concurrentBrowsers: 2,
|
|
29
|
+
|
|
30
|
+
/** Amount of test files per browser to test concurrently */
|
|
31
|
+
// concurrency: 1,
|
|
32
|
+
|
|
33
|
+
/** Browsers to run tests on */
|
|
34
|
+
// browsers: [
|
|
35
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
+
// ],
|
|
39
|
+
|
|
40
|
+
// See documentation for all available options
|
|
41
|
+
});
|