@operato/dataset 1.5.56 → 1.6.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.6.0](https://github.com/hatiolab/operato/compare/v1.5.56...v1.6.0) (2023-12-10)
7
+
8
+
9
+ ### :rocket: New Features
10
+
11
+ * fix: support 'subgroup' concept for dataset-item (ox-data-entfy-form) ([1ec0dfe](https://github.com/hatiolab/operato/commit/1ec0dfe4e2c31d3c87bdce0174ce0f46f928c0aa))
12
+
13
+
14
+
6
15
  ### [1.5.56](https://github.com/hatiolab/operato/compare/v1.5.55...v1.5.56) (2023-12-09)
7
16
 
8
17
 
@@ -1,14 +1,20 @@
1
1
  import '@operato/input/ox-input-file.js';
2
- import { LitElement } from 'lit';
2
+ import './ox-data-entry-subgroup-form.js';
3
+ import { LitElement, TemplateResult } from 'lit';
3
4
  import { DataSet } from './types.js';
5
+ import { OxDataEntrySubgroupForm } from './ox-data-entry-subgroup-form.js';
4
6
  export declare class OxDataEntryForm extends LitElement {
5
7
  static styles: import("lit").CSSResult;
6
8
  dataSet?: DataSet;
7
9
  value?: {
8
10
  [tag: string]: any;
9
11
  };
10
- render(): import("lit").TemplateResult<1>;
12
+ subgroups: NodeListOf<OxDataEntrySubgroupForm>;
13
+ render(): TemplateResult<1>;
11
14
  private onChange;
12
15
  private buildInputs;
16
+ private buildInputs4Subgroup;
17
+ private buildInputs4NonGrouped;
13
18
  private buildValue;
19
+ private groupDataItemsByGroup;
14
20
  }
@@ -1,7 +1,8 @@
1
1
  import { __decorate } from "tslib";
2
2
  import '@operato/input/ox-input-file.js';
3
+ import './ox-data-entry-subgroup-form.js';
3
4
  import { css, html, LitElement } from 'lit';
4
- import { customElement, property } from 'lit/decorators.js';
5
+ import { customElement, property, queryAll } from 'lit/decorators.js';
5
6
  let OxDataEntryForm = class OxDataEntryForm extends LitElement {
6
7
  render() {
7
8
  var _a, _b;
@@ -21,7 +22,34 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
21
22
  }
22
23
  buildInputs() {
23
24
  var _a;
24
- const dataItems = (_a = this.dataSet) === null || _a === void 0 ? void 0 : _a.dataItems.filter(item => item.active);
25
+ const dataItems = ((_a = this.dataSet) === null || _a === void 0 ? void 0 : _a.dataItems.filter(item => item.active)) || [];
26
+ const nonGroupDataItems = dataItems.filter(dataItem => !dataItem.group);
27
+ const dataItemSubgroups = Object.entries(this.groupDataItemsByGroup(dataItems)).map(([subgroup, dataItems]) => {
28
+ const tags = dataItems.map(dataItem => dataItem.tag);
29
+ const value = tags.reduce((partial, key) => {
30
+ var _a;
31
+ partial[key] = (_a = this.value) === null || _a === void 0 ? void 0 : _a[key];
32
+ return partial;
33
+ }, {});
34
+ return this.buildInputs4Subgroup(subgroup, dataItems, value);
35
+ });
36
+ return [...this.buildInputs4NonGrouped(nonGroupDataItems), ...dataItemSubgroups];
37
+ }
38
+ buildInputs4Subgroup(subgroup, dataItems, value) {
39
+ return html `
40
+ <label>
41
+ <div name>${subgroup}</div>
42
+ <div subgroup>
43
+ <ox-data-entry-subgroup-form
44
+ .subgroup=${subgroup}
45
+ .dataItems=${dataItems}
46
+ .value=${value}
47
+ ></ox-data-entry-subgroup-form>
48
+ </div>
49
+ </label>
50
+ `;
51
+ }
52
+ buildInputs4NonGrouped(dataItems) {
25
53
  return (dataItems || []).map(dataItem => {
26
54
  const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem;
27
55
  const samples = new Array(quota).fill(0);
@@ -63,7 +91,8 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
63
91
  }
64
92
  buildValue() {
65
93
  const dataItems = this.dataSet.dataItems;
66
- return (dataItems || []).reduce((sum, dataItem) => {
94
+ const nonGroupDataItems = dataItems.filter(dataItem => !dataItem.group);
95
+ const nonGroupValue = (nonGroupDataItems || []).reduce((sum, dataItem) => {
67
96
  const { tag, type } = dataItem;
68
97
  const editors = Array.prototype.slice.call(this.renderRoot.querySelectorAll(`[name=${tag}]`));
69
98
  if (editors.length > 0) {
@@ -71,6 +100,25 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
71
100
  }
72
101
  return sum;
73
102
  }, {});
103
+ return Array.from(this.subgroups).reduce((value, subgroup) => {
104
+ return {
105
+ ...value,
106
+ ...subgroup.buildValue()
107
+ };
108
+ }, nonGroupValue || {});
109
+ }
110
+ groupDataItemsByGroup(dataItems) {
111
+ const groupedDataItems = {};
112
+ for (const dataItem of dataItems) {
113
+ const { group } = dataItem;
114
+ if (group) {
115
+ if (!groupedDataItems[group]) {
116
+ groupedDataItems[group] = [];
117
+ }
118
+ groupedDataItems[group].push(dataItem);
119
+ }
120
+ }
121
+ return groupedDataItems;
74
122
  }
75
123
  };
76
124
  OxDataEntryForm.styles = css `
@@ -88,6 +136,7 @@ OxDataEntryForm.styles = css `
88
136
  text-transform: capitalize;
89
137
  text-align: center;
90
138
  }
139
+
91
140
  h3 {
92
141
  margin: var(--page-description-margin);
93
142
  font: var(--page-description-font);
@@ -102,6 +151,7 @@ OxDataEntryForm.styles = css `
102
151
  display: flex;
103
152
  flex-direction: column;
104
153
  }
154
+
105
155
  label {
106
156
  display: grid;
107
157
 
@@ -113,6 +163,7 @@ OxDataEntryForm.styles = css `
113
163
  align-items: center;
114
164
  margin-bottom: var(--margin-default);
115
165
  }
166
+
116
167
  label:nth-child(odd) {
117
168
  background-color: var(--main-section-background-color);
118
169
  padding: var(--padding-default) 0;
@@ -131,13 +182,16 @@ OxDataEntryForm.styles = css `
131
182
  color: var(--item-description-color);
132
183
  text-align: left;
133
184
  }
185
+
134
186
  div[description] * {
135
187
  vertical-align: middle;
136
188
  }
189
+
137
190
  div[description] mwc-icon {
138
191
  margin-top: -3px;
139
192
  font-size: 0.9rem;
140
193
  }
194
+
141
195
  div[elements] {
142
196
  grid-area: inputs;
143
197
  display: flex;
@@ -146,9 +200,11 @@ OxDataEntryForm.styles = css `
146
200
  gap: 10px;
147
201
  padding-right: var(--padding-default);
148
202
  }
203
+
149
204
  div[elements] * {
150
205
  flex: 1;
151
206
  }
207
+
152
208
  div[elements] input,
153
209
  div[elements] select {
154
210
  border: var(--input-field-border);
@@ -157,6 +213,11 @@ OxDataEntryForm.styles = css `
157
213
  font: var(--input-field-font);
158
214
  }
159
215
 
216
+ div[subgroup] {
217
+ grid-column: 1 / 3;
218
+ grid-row: 2;
219
+ }
220
+
160
221
  @media only screen and (max-width: 460px) {
161
222
  label {
162
223
  display: grid;
@@ -181,6 +242,9 @@ __decorate([
181
242
  __decorate([
182
243
  property({ type: Object })
183
244
  ], OxDataEntryForm.prototype, "value", void 0);
245
+ __decorate([
246
+ queryAll('ox-data-entry-subgroup-form')
247
+ ], OxDataEntryForm.prototype, "subgroups", void 0);
184
248
  OxDataEntryForm = __decorate([
185
249
  customElement('ox-data-entry-form')
186
250
  ], OxDataEntryForm);
@@ -1 +1 @@
1
- {"version":3,"file":"ox-data-entry-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAKpD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IA2G7C,MAAM;;QACJ,OAAO,IAAI,CAAA,kBAAkB,CAAC,CAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,KAAI,EAAE;YACxB,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,KAAI,EAAE;QACnC,IAAI,CAAC,WAAW,EAAE;YACd,CAAA;IACV,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AAC,SAAS,CAAC,KAAK,CAAC,IAAI,CACxC,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,GAAG,GAAG,CAAiC,CAC5D,CAAA;YAEvB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,GAAG,CAAC,GAAG,CAAC,GAAG,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,CAAA;YACxF,CAAC;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,EAA4B,CAAC,CAAA;IAClC,CAAC;;AArMM,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqGlB,AArGY,CAqGZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAA+B;AAzG/C,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAuM3B","sourcesContent":["import '@operato/input/ox-input-file.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { DataSet } from './types.js'\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 --item-description-font: normal 0.8rem/1rem var(--theme-font);\n --item-description-color: var(--page-description-color);\n }\n\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n text-transform: capitalize;\n text-align: center;\n }\n h3 {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n text-transform: capitalize;\n text-align: center;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\n label {\n display: grid;\n\n grid-template-rows: auto 1fr;\n grid-template-columns: 1fr 5fr;\n grid-template-areas: 'name description' 'empty inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n label:nth-child(odd) {\n background-color: var(--main-section-background-color);\n padding: var(--padding-default) 0;\n }\n\n div[name] {\n grid-area: name;\n font: var(--label-font);\n color: var(--label-color);\n text-align: right;\n }\n div[description] {\n grid-area: description;\n opacity: 0.7;\n font: var(--item-description-font);\n color: var(--item-description-color);\n text-align: left;\n }\n div[description] * {\n vertical-align: middle;\n }\n div[description] mwc-icon {\n margin-top: -3px;\n font-size: 0.9rem;\n }\n div[elements] {\n grid-area: inputs;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 10px;\n padding-right: var(--padding-default);\n }\n div[elements] * {\n flex: 1;\n }\n div[elements] input,\n div[elements] select {\n border: var(--input-field-border);\n border-radius: var(--input-field-border-radius);\n padding: var(--input-field-padding);\n font: var(--input-field-font);\n }\n\n @media only screen and (max-width: 460px) {\n label {\n display: grid;\n\n grid-template-rows: auto auto 1fr;\n grid-template-columns: 1fr;\n grid-template-areas: 'name' 'description' 'inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n\n div[name] {\n text-align: left;\n }\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)}>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildInputs()}\n </form>`\n }\n\n private onChange(e: Event) {\n this.value = this.buildValue()\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n\n private buildInputs() {\n const dataItems = this.dataSet?.dataItems.filter(item => item.active)\n\n return (dataItems || []).map(dataItem => {\n const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem\n\n const samples = new Array(quota).fill(0)\n const value = this.value && this.value[tag]\n\n const elements = samples.map((_, idx) => {\n const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined\n\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n <option value=\"\"></option>\n ${(options.options || []).map(\n option => html`<option value=${option.value} ?selected=${option.value === v}>${option.text}</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 'date':\n return html` <input type=\"date\" name=${tag} value=${v} />`\n break\n\n case 'datetime':\n return html` <input type=\"datetime-local\" name=${tag} value=${v} />`\n break\n\n case 'file':\n return html`<ox-input-file name=${tag} label=\"Attach Files\" accept=\"*/*\" multiple=\"true\"></ox-input-file>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${v} />`\n }\n })\n\n return html` <label .title=${description}>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description><mwc-icon>info_outline</mwc-icon> ${description}</div>\n <div elements>${elements}</div>\n </label>`\n })\n }\n\n private buildValue() {\n const dataItems = this.dataSet!.dataItems\n\n return (dataItems || []).reduce((sum, dataItem) => {\n const { tag, 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] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return sum\n }, {} as { [tag: string]: any })\n }\n}\n"]}
1
+ {"version":3,"file":"ox-data-entry-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,U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GAAG,QAAQ,CAAA;YAE1B,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC7B,gBAAgB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;gBAC9B,CAAC;gBAED,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;QAED,OAAO,gBAAgB,CAAA;IACzB,CAAC;;AA3QM,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkHlB,AAlHY,CAkHZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAA+B;AAEjB;IAAxC,QAAQ,CAAC,6BAA6B,CAAC;kDAAgD;AAxH7E,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CA6Q3B","sourcesContent":["import '@operato/input/ox-input-file.js'\nimport './ox-data-entry-subgroup-form.js'\n\nimport { css, html, LitElement, TemplateResult } from 'lit'\nimport { customElement, property, queryAll } from 'lit/decorators.js'\n\nimport { DataSet, DataItem, DataSample } from './types.js'\nimport { OxDataEntrySubgroupForm } from './ox-data-entry-subgroup-form.js'\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 --item-description-font: normal 0.8rem/1rem var(--theme-font);\n --item-description-color: var(--page-description-color);\n }\n\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n text-transform: capitalize;\n text-align: center;\n }\n\n h3 {\n margin: var(--page-description-margin);\n font: var(--page-description-font);\n color: var(--page-description-color);\n text-transform: capitalize;\n text-align: center;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\n\n label {\n display: grid;\n\n grid-template-rows: auto 1fr;\n grid-template-columns: 1fr 5fr;\n grid-template-areas: 'name description' 'empty inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n\n label:nth-child(odd) {\n background-color: var(--main-section-background-color);\n padding: var(--padding-default) 0;\n }\n\n div[name] {\n grid-area: name;\n font: var(--label-font);\n color: var(--label-color);\n text-align: right;\n }\n div[description] {\n grid-area: description;\n opacity: 0.7;\n font: var(--item-description-font);\n color: var(--item-description-color);\n text-align: left;\n }\n\n div[description] * {\n vertical-align: middle;\n }\n\n div[description] mwc-icon {\n margin-top: -3px;\n font-size: 0.9rem;\n }\n\n div[elements] {\n grid-area: inputs;\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n gap: 10px;\n padding-right: var(--padding-default);\n }\n\n div[elements] * {\n flex: 1;\n }\n\n div[elements] input,\n div[elements] select {\n border: var(--input-field-border);\n border-radius: var(--input-field-border-radius);\n padding: var(--input-field-padding);\n font: var(--input-field-font);\n }\n\n div[subgroup] {\n grid-column: 1 / 3;\n grid-row: 2;\n }\n\n @media only screen and (max-width: 460px) {\n label {\n display: grid;\n\n grid-template-rows: auto auto 1fr;\n grid-template-columns: 1fr;\n grid-template-areas: 'name' 'description' 'inputs';\n\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--margin-default);\n }\n\n div[name] {\n text-align: left;\n }\n }\n `\n\n @property({ type: Object }) dataSet?: DataSet\n @property({ type: Object }) value?: { [tag: string]: any }\n\n @queryAll('ox-data-entry-subgroup-form') subgroups!: NodeListOf<OxDataEntrySubgroupForm>\n\n render() {\n return html` <form @change=${(e: Event) => this.onChange(e)}>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildInputs()}\n </form>`\n }\n\n private onChange(e: Event) {\n this.value = this.buildValue()\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: this.value\n })\n )\n }\n\n private buildInputs() {\n const dataItems = this.dataSet?.dataItems.filter(item => item.active) || []\n const nonGroupDataItems = dataItems.filter(dataItem => !dataItem.group)\n const dataItemSubgroups = Object.entries(this.groupDataItemsByGroup(dataItems)).map(([subgroup, dataItems]) => {\n const tags = dataItems.map(dataItem => dataItem.tag)\n const value = tags.reduce((partial, key) => {\n partial[key] = this.value?.[key]\n return partial\n }, {} as any)\n\n return this.buildInputs4Subgroup(subgroup, dataItems, value)\n })\n\n return [...this.buildInputs4NonGrouped(nonGroupDataItems), ...dataItemSubgroups]\n }\n\n private buildInputs4Subgroup(subgroup: string, dataItems: DataItem[], value: { [tag: string]: any }): TemplateResult {\n return html`\n <label>\n <div name>${subgroup}</div>\n <div subgroup>\n <ox-data-entry-subgroup-form\n .subgroup=${subgroup}\n .dataItems=${dataItems}\n .value=${value}\n ></ox-data-entry-subgroup-form>\n </div>\n </label>\n `\n }\n\n private buildInputs4NonGrouped(dataItems: DataItem[]): TemplateResult[] {\n return (dataItems || []).map(dataItem => {\n const { name, description, tag, type, quota = 1, options = {}, unit } = dataItem\n\n const samples = new Array(quota).fill(0)\n const value = this.value && this.value[tag]\n\n const elements = samples.map((_, idx) => {\n const v = value instanceof Array ? value[idx] : idx === 0 ? value : undefined\n\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n <option value=\"\"></option>\n ${(options.options || []).map(\n option => html`<option value=${option.value} ?selected=${option.value === v}>${option.text}</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 'date':\n return html` <input type=\"date\" name=${tag} value=${v} />`\n break\n\n case 'datetime':\n return html` <input type=\"datetime-local\" name=${tag} value=${v} />`\n break\n\n case 'file':\n return html`<ox-input-file name=${tag} label=\"Attach Files\" accept=\"*/*\" multiple=\"true\"></ox-input-file>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${v} />`\n }\n })\n\n return html` <label .title=${description}>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description><mwc-icon>info_outline</mwc-icon> ${description}</div>\n <div elements>${elements}</div>\n </label>`\n })\n }\n\n private buildValue() {\n const dataItems = this.dataSet!.dataItems\n const nonGroupDataItems = dataItems.filter(dataItem => !dataItem.group)\n\n const nonGroupValue = (nonGroupDataItems || []).reduce((sum, dataItem) => {\n const { tag, 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] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return sum\n }, {} as { [tag: string]: any })\n\n return Array.from(this.subgroups).reduce((value, subgroup) => {\n return {\n ...value,\n ...subgroup.buildValue()\n }\n }, nonGroupValue || {})\n }\n\n private groupDataItemsByGroup(dataItems: DataItem[]): { [group: string]: DataItem[] } {\n const groupedDataItems: { [group: string]: DataItem[] } = {}\n\n for (const dataItem of dataItems) {\n const { group } = dataItem\n\n if (group) {\n if (!groupedDataItems[group]) {\n groupedDataItems[group] = []\n }\n\n groupedDataItems[group].push(dataItem)\n }\n }\n\n return groupedDataItems\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import '@operato/input/ox-input-file.js';
2
+ import '@operato/data-grist/ox-grist.js';
3
+ import { LitElement } from 'lit';
4
+ import { DataItem } from './types.js';
5
+ import { DataGrist, FetchOption } from '@operato/data-grist';
6
+ export declare class OxDataEntrySubgroupForm extends LitElement {
7
+ static styles: import("lit").CSSResult[];
8
+ subgroup?: string;
9
+ dataItems?: DataItem[];
10
+ value?: {
11
+ [tag: string]: any;
12
+ };
13
+ gristConfig: {
14
+ list: {
15
+ fields: string[];
16
+ };
17
+ columns: any[];
18
+ rows: {
19
+ appendable: boolean;
20
+ };
21
+ pagination: {
22
+ infinite: boolean;
23
+ };
24
+ };
25
+ grist: DataGrist;
26
+ render(): import("lit").TemplateResult<1>;
27
+ private buildGristConfiguration;
28
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
29
+ total: number;
30
+ records: any[];
31
+ }>;
32
+ buildValue(): any;
33
+ }
@@ -0,0 +1,139 @@
1
+ import { __decorate } from "tslib";
2
+ import '@operato/input/ox-input-file.js';
3
+ import '@operato/data-grist/ox-grist.js';
4
+ import { css, html, LitElement } from 'lit';
5
+ import { customElement, property, state, query } from 'lit/decorators.js';
6
+ import { ScrollbarStyles } from '@operato/styles';
7
+ import { isMobileDevice } from '@operato/utils';
8
+ let OxDataEntrySubgroupForm = class OxDataEntrySubgroupForm extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.gristConfig = this.buildGristConfiguration();
12
+ }
13
+ render() {
14
+ return html `
15
+ <ox-grist
16
+ .mode=${isMobileDevice() ? 'LIST' : 'GRID'}
17
+ .config=${this.buildGristConfiguration()}
18
+ .fetchHandler=${this.fetchHandler.bind(this)}
19
+ >
20
+ </ox-grist>
21
+ `;
22
+ }
23
+ buildGristConfiguration() {
24
+ const columns = (this.dataItems || []).map(dataItem => {
25
+ const { name, description, tag, type, options = {}, unit } = dataItem;
26
+ const columnConfig = {
27
+ type,
28
+ name: tag,
29
+ header: `${name}${unit ? ` (${unit})` : ''}`,
30
+ record: {
31
+ editable: true
32
+ },
33
+ width: 200
34
+ };
35
+ switch (type) {
36
+ case 'select':
37
+ columnConfig.record.options = [
38
+ '',
39
+ ...(options.options || []).map((option) => {
40
+ if (typeof option == 'string') {
41
+ return option;
42
+ }
43
+ const { display, text, value } = option || {};
44
+ return {
45
+ display: display || text,
46
+ value
47
+ };
48
+ })
49
+ ];
50
+ return columnConfig;
51
+ case 'boolean':
52
+ columnConfig.record.align = 'center';
53
+ return columnConfig;
54
+ case 'number':
55
+ columnConfig.record.align = 'right';
56
+ return columnConfig;
57
+ case 'date':
58
+ return columnConfig;
59
+ case 'datetime':
60
+ return columnConfig;
61
+ case 'file':
62
+ return columnConfig;
63
+ case 'string':
64
+ return columnConfig;
65
+ default:
66
+ return columnConfig;
67
+ }
68
+ });
69
+ return {
70
+ list: { fields: ['name', 'data'] },
71
+ columns: [{ type: 'gutter', gutterName: 'sequence' }, ...columns],
72
+ rows: {
73
+ appendable: true
74
+ },
75
+ pagination: { infinite: true }
76
+ };
77
+ }
78
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
79
+ const length = Object.entries(this.value || {}).reduce((max, [tag, value]) => {
80
+ return Math.max(max, Array.isArray(value) ? value.length : 1);
81
+ }, 0);
82
+ const tags = (this.dataItems || []).map(dataItem => dataItem.tag);
83
+ const records = Array.from({ length }, (_, index) => index).map(index => {
84
+ return tags.reduce((partial, tag) => {
85
+ var _a;
86
+ const v = (_a = this.value) === null || _a === void 0 ? void 0 : _a[tag];
87
+ partial[tag] = Array.isArray(v) ? v[index] : index == 0 ? v : undefined;
88
+ return partial;
89
+ }, {});
90
+ });
91
+ return {
92
+ total: records.length || 0,
93
+ records: records
94
+ };
95
+ }
96
+ buildValue() {
97
+ const records = this.grist._data.records || [];
98
+ const tags = (this.dataItems || []).map(dataItem => dataItem.tag);
99
+ return tags.reduce((partial, tag) => {
100
+ partial[tag] = Array.from({ length: records.length }, (_, index) => index).map(index => {
101
+ const record = records[index];
102
+ return record === null || record === void 0 ? void 0 : record[tag];
103
+ });
104
+ return partial;
105
+ }, {});
106
+ }
107
+ };
108
+ OxDataEntrySubgroupForm.styles = [
109
+ ScrollbarStyles,
110
+ css `
111
+ :host {
112
+ display: flex;
113
+ flex-direction: column;
114
+
115
+ width: 100%;
116
+ min-height: 100px;
117
+ }
118
+ `
119
+ ];
120
+ __decorate([
121
+ property({ type: String })
122
+ ], OxDataEntrySubgroupForm.prototype, "subgroup", void 0);
123
+ __decorate([
124
+ property({ type: Array })
125
+ ], OxDataEntrySubgroupForm.prototype, "dataItems", void 0);
126
+ __decorate([
127
+ property({ type: Object })
128
+ ], OxDataEntrySubgroupForm.prototype, "value", void 0);
129
+ __decorate([
130
+ state()
131
+ ], OxDataEntrySubgroupForm.prototype, "gristConfig", void 0);
132
+ __decorate([
133
+ query('ox-grist')
134
+ ], OxDataEntrySubgroupForm.prototype, "grist", void 0);
135
+ OxDataEntrySubgroupForm = __decorate([
136
+ customElement('ox-data-entry-subgroup-form')
137
+ ], OxDataEntrySubgroupForm);
138
+ export { OxDataEntrySubgroupForm };
139
+ //# sourceMappingURL=ox-data-entry-subgroup-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ox-data-entry-subgroup-form.js","sourceRoot":"","sources":["../../src/ox-data-entry-subgroup-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAMxC,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAU;IAAhD;;QAkBI,gBAAW,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;IAiHvD,CAAC;IA9GC,MAAM;QACJ,OAAO,IAAI,CAAA;;gBAEC,cAAc,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;kBAChC,IAAI,CAAC,uBAAuB,EAAE;wBACxB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;;;KAG/C,CAAA;IACH,CAAC;IAEO,uBAAuB;QAC7B,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,SAAS,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AAO,OAAO,CAAA;QAChB,CAAC,EAAE,EAAS,CAAC,CAAA;IACf,CAAC;;AAjIM,8BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;KAQF;CACF,AAXY,CAWZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAkB;AAClB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;0DAAuB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAA+B;AAEjD;IAAR,KAAK,EAAE;4DAA6C;AAClC;IAAlB,KAAK,CAAC,UAAU,CAAC;sDAAkB;AAnBzB,uBAAuB;IADnC,aAAa,CAAC,6BAA6B,CAAC;GAChC,uBAAuB,CAmInC","sourcesContent":["import '@operato/input/ox-input-file.js'\nimport '@operato/data-grist/ox-grist.js'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, state, query } from 'lit/decorators.js'\n\nimport { ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice } from '@operato/utils'\n\nimport { DataItem } from './types.js'\nimport { DataGrist, FetchOption } from '@operato/data-grist'\n\n@customElement('ox-data-entry-subgroup-form')\nexport class OxDataEntrySubgroupForm extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n width: 100%;\n min-height: 100px;\n }\n `\n ]\n\n @property({ type: String }) subgroup?: string\n @property({ type: Array }) dataItems?: DataItem[]\n @property({ type: Object }) value?: { [tag: string]: any }\n\n @state() gristConfig = this.buildGristConfiguration()\n @query('ox-grist') grist!: DataGrist\n\n render() {\n return html`\n <ox-grist\n .mode=${isMobileDevice() ? 'LIST' : 'GRID'}\n .config=${this.buildGristConfiguration()}\n .fetchHandler=${this.fetchHandler.bind(this)}\n >\n </ox-grist>\n `\n }\n\n private buildGristConfiguration() {\n const columns = (this.dataItems || []).map(dataItem => {\n const { name, description, tag, type, options = {}, unit } = dataItem\n const columnConfig = {\n type,\n name: tag,\n header: `${name}${unit ? ` (${unit})` : ''}`,\n record: {\n editable: true\n },\n width: 200\n } as any\n\n switch (type) {\n case 'select':\n columnConfig.record.options = [\n '',\n ...(options.options || []).map((option: any) => {\n if (typeof option == 'string') {\n return option\n }\n const { display, text, value } = option || {}\n\n return {\n display: display || text,\n value\n }\n })\n ]\n return columnConfig\n\n case 'boolean':\n columnConfig.record.align = 'center'\n return columnConfig\n\n case 'number':\n columnConfig.record.align = 'right'\n return columnConfig\n\n case 'date':\n return columnConfig\n\n case 'datetime':\n return columnConfig\n\n case 'file':\n return columnConfig\n\n case 'string':\n return columnConfig\n\n default:\n return columnConfig\n }\n })\n\n return {\n list: { fields: ['name', 'data'] },\n columns: [{ type: 'gutter', gutterName: 'sequence' }, ...columns],\n rows: {\n appendable: true\n },\n pagination: { infinite: true }\n }\n }\n\n async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {\n const length = Object.entries(this.value || {}).reduce((max, [tag, value]) => {\n return Math.max(max, Array.isArray(value) ? value.length : 1)\n }, 0)\n\n const tags = (this.dataItems || []).map(dataItem => dataItem.tag)\n\n const records = Array.from({ length }, (_, index) => index).map(index => {\n return tags.reduce((partial, tag) => {\n const v = this.value?.[tag]\n partial[tag] = Array.isArray(v) ? v[index] : index == 0 ? v : undefined\n return partial\n }, {} as any)\n })\n\n return {\n total: records.length || 0,\n records: records\n }\n }\n\n public buildValue() {\n const records = this.grist._data.records || []\n const tags = (this.dataItems || []).map(dataItem => dataItem.tag)\n\n return tags.reduce((partial, tag) => {\n partial[tag] = Array.from({ length: records.length }, (_, index) => index).map(index => {\n const record = records[index]\n return record?.[tag]\n })\n return partial\n }, {} as any)\n }\n}\n"]}
@@ -18,6 +18,7 @@ const dataSet = {
18
18
  description: '창고 온도는 섭씨 0도 이하로 유지되어야 합니다.',
19
19
  sequence: 1,
20
20
  tag: 'temp',
21
+ group: '측정데이타',
21
22
  type: 'number',
22
23
  quota: 1,
23
24
  active: true,
@@ -40,6 +41,7 @@ const dataSet = {
40
41
  description: '창고 습도는 30% 이하로 유지되어야 합니다.',
41
42
  sequence: 2,
42
43
  tag: 'humid',
44
+ group: '측정데이타',
43
45
  type: 'number',
44
46
  quota: 5,
45
47
  active: true,
@@ -62,6 +64,7 @@ const dataSet = {
62
64
  description: '육안 검사는 포장전 30분 내로 실행되어야 합니다.',
63
65
  sequence: 3,
64
66
  tag: 'inspection',
67
+ group: '측정데이타',
65
68
  type: 'boolean',
66
69
  quota: 3,
67
70
  active: true,
@@ -81,6 +84,7 @@ const dataSet = {
81
84
  description: '품평은 최우수/우수/보통/미달을 포함하여 간단히 평가.',
82
85
  sequence: 4,
83
86
  tag: 'evaluation',
87
+ group: '측정데이타',
84
88
  type: 'select',
85
89
  options: {
86
90
  options: [
@@ -137,6 +141,9 @@ const Template = ({}) => html `
137
141
  body {
138
142
  }
139
143
  </style>
144
+ <link href="/themes/app-theme.css" rel="stylesheet" />
145
+ <link href="/themes/oops-theme.css" rel="stylesheet" />
146
+ <link href="/themes/grist-theme.css" rel="stylesheet" />
140
147
 
141
148
  <ox-data-entry-form
142
149
  .dataSet=${dataSet}
@@ -1 +1 @@
1
- {"version":3,"file":"ox-data-entry-form.stories.js","sourceRoot":"","sources":["../../stories/ox-data-entry-form.stories.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AACtB,OAAO,8BAA8B,CAAA;AACrC,OAAO,oBAAoB,CAAA,CAAC,0BAA0B;AACtD,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C,eAAe;IACb,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,oBAAoB;IAC/B,QAAQ,EAAE,EAAE;CACb,CAAA;AAUD,MAAM,OAAO,GAAG;IACd,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,KAAK;IACd,SAAS,EAAE;QACT;Y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,GAAoB,CAAC,EAAY,EAAE,EAAE,CACjD,IAAI,CAAA;;;;;;;;;iBASW,OAAO;eACT,KAAK;gBACJ,CAAC,CAAc,EAAE,EAAE;IAC3B,KAAK,GAAG,CAAC,CAAC,MAAM,CAAA;IAChB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AAC9B,CAAC;;GAEJ,CAAA;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA","sourcesContent":["import '@operato/i18n'\nimport '../src/ox-data-entry-form.js'\nimport '../src/usecase/ccp' /* register usecase CCP */\nimport '@material/mwc-icon'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-data-entry-form',\n component: 'ox-data-entry-form',\n argTypes: {}\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {}\n\nconst dataSet = {\n name: 'sample',\n description: 'sample description',\n useCase: 'CCP',\n dataItems: [\n {\n name: '창고 온도',\n description: '창고 온도는 섭씨 0도 이하로 유지되어야 합니다.',\n sequence: 1,\n tag: 'temp',\n type: 'number',\n quota: 1,\n active: true,\n unit: '℃',\n spec: {\n CCP: {\n criticalLimits: {\n minimum: 100,\n maximum: 200\n },\n targetLimits: {\n minimum: 120,\n maximum: 180\n }\n }\n }\n },\n {\n name: '창고 습도',\n description: '창고 습도는 30% 이하로 유지되어야 합니다.',\n sequence: 2,\n tag: 'humid',\n type: 'number',\n quota: 5,\n active: true,\n unit: '%',\n spec: {\n CCP: {\n criticalLimits: {\n minimum: 10,\n maximum: 50\n },\n targetLimits: {\n minimum: 20,\n maximum: 40\n }\n }\n }\n },\n {\n name: '육안 검사',\n description: '육안 검사는 포장전 30분 내로 실행되어야 합니다.',\n sequence: 3,\n tag: 'inspection',\n type: 'boolean',\n quota: 3,\n active: true,\n spec: {\n CCP: {\n criticalLimits: {\n acceptables: true\n },\n targetLimits: {\n acceptables: true\n }\n }\n }\n },\n {\n name: '품평',\n description: '품평은 최우수/우수/보통/미달을 포함하여 간단히 평가.',\n sequence: 4,\n tag: 'evaluation',\n type: 'select',\n options: {\n options: [\n { text: '최우수', value: '최우수' },\n { text: '우수', value: '우수' },\n { text: '보통', value: '보통' },\n { text: '미달', value: '미달' }\n ]\n },\n quota: 3,\n active: true,\n spec: {\n CCP: {\n criticalLimits: {\n acceptables: ['최우수', '우수', '보통']\n },\n targetLimits: {\n acceptables: ['최우수', '우수']\n }\n }\n }\n },\n {\n name: '코멘트',\n description: '특이사항을 기록함.',\n sequence: 4,\n tag: 'comment',\n type: 'string',\n quota: 1,\n active: true\n },\n {\n name: '첨부파일',\n description: '참조 첨부 파일.',\n sequence: 4,\n tag: 'attachment',\n type: 'file',\n quota: 1,\n active: true\n }\n ]\n}\nvar value = {\n temp: 1000,\n humid: [20, 23, 21, 26, 27],\n inspection: [true, false, true],\n evaluation: ['최우수', '보통', '우수'],\n comment: '이것이 코멘트입니다.'\n}\n\nconst Template: Story<ArgTypes> = ({}: ArgTypes) =>\n html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n\n <ox-data-entry-form\n .dataSet=${dataSet}\n .value=${value}\n @change=${(e: CustomEvent) => {\n value = e.detail\n console.log('change', value)\n }}\n ></ox-data-entry-form>\n `\n\nexport const Regular = Template.bind({})\nRegular.args = {}\n"]}
1
+ {"version":3,"file":"ox-data-entry-form.stories.js","sourceRoot":"","sources":["../../stories/ox-data-entry-form.stories.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AACtB,OAAO,8BAA8B,CAAA;AACrC,OAAO,oBAAoB,CAAA,CAAC,0BAA0B;AACtD,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,I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,MAAM,EAAE,IAAI;SACb;KACF;CACF,CAAA;AACD,IAAI,KAAK,GAAG;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;IAC3B,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC;IAC/B,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;IAC/B,OAAO,EAAE,aAAa;CACvB,CAAA;AAED,MAAM,QAAQ,GAAoB,CAAC,EAAY,EAAE,EAAE,CACjD,IAAI,CAAA;;;;;;;;;;;;iBAYW,OAAO;eACT,KAAK;gBACJ,CAAC,CAAc,EAAE,EAAE;IAC3B,KAAK,GAAG,CAAC,CAAC,MAAM,CAAA;IAChB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AAC9B,CAAC;;GAEJ,CAAA;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAA","sourcesContent":["import '@operato/i18n'\nimport '../src/ox-data-entry-form.js'\nimport '../src/usecase/ccp' /* register usecase CCP */\nimport '@material/mwc-icon'\n\nimport { html, TemplateResult } from 'lit'\n\nexport default {\n title: 'ox-data-entry-form',\n component: 'ox-data-entry-form',\n argTypes: {}\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {}\n\nconst dataSet = {\n name: 'sample',\n description: 'sample description',\n useCase: 'CCP',\n dataItems: [\n {\n name: '창고 온도',\n description: '창고 온도는 섭씨 0도 이하로 유지되어야 합니다.',\n sequence: 1,\n tag: 'temp',\n group: '측정데이타',\n type: 'number',\n quota: 1,\n active: true,\n unit: '℃',\n spec: {\n CCP: {\n criticalLimits: {\n minimum: 100,\n maximum: 200\n },\n targetLimits: {\n minimum: 120,\n maximum: 180\n }\n }\n }\n },\n {\n name: '창고 습도',\n description: '창고 습도는 30% 이하로 유지되어야 합니다.',\n sequence: 2,\n tag: 'humid',\n group: '측정데이타',\n type: 'number',\n quota: 5,\n active: true,\n unit: '%',\n spec: {\n CCP: {\n criticalLimits: {\n minimum: 10,\n maximum: 50\n },\n targetLimits: {\n minimum: 20,\n maximum: 40\n }\n }\n }\n },\n {\n name: '육안 검사',\n description: '육안 검사는 포장전 30분 내로 실행되어야 합니다.',\n sequence: 3,\n tag: 'inspection',\n group: '측정데이타',\n type: 'boolean',\n quota: 3,\n active: true,\n spec: {\n CCP: {\n criticalLimits: {\n acceptables: true\n },\n targetLimits: {\n acceptables: true\n }\n }\n }\n },\n {\n name: '품평',\n description: '품평은 최우수/우수/보통/미달을 포함하여 간단히 평가.',\n sequence: 4,\n tag: 'evaluation',\n group: '측정데이타',\n type: 'select',\n options: {\n options: [\n { text: '최우수', value: '최우수' },\n { text: '우수', value: '우수' },\n { text: '보통', value: '보통' },\n { text: '미달', value: '미달' }\n ]\n },\n quota: 3,\n active: true,\n spec: {\n CCP: {\n criticalLimits: {\n acceptables: ['최우수', '우수', '보통']\n },\n targetLimits: {\n acceptables: ['최우수', '우수']\n }\n }\n }\n },\n {\n name: '코멘트',\n description: '특이사항을 기록함.',\n sequence: 4,\n tag: 'comment',\n type: 'string',\n quota: 1,\n active: true\n },\n {\n name: '첨부파일',\n description: '참조 첨부 파일.',\n sequence: 4,\n tag: 'attachment',\n type: 'file',\n quota: 1,\n active: true\n }\n ]\n}\nvar value = {\n temp: 1000,\n humid: [20, 23, 21, 26, 27],\n inspection: [true, false, true],\n evaluation: ['최우수', '보통', '우수'],\n comment: '이것이 코멘트입니다.'\n}\n\nconst Template: Story<ArgTypes> = ({}: ArgTypes) =>\n html`\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\" rel=\"stylesheet\" />\n <style>\n body {\n }\n </style>\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"/themes/oops-theme.css\" rel=\"stylesheet\" />\n <link href=\"/themes/grist-theme.css\" rel=\"stylesheet\" />\n\n <ox-data-entry-form\n .dataSet=${dataSet}\n .value=${value}\n @change=${(e: CustomEvent) => {\n value = e.detail\n console.log('change', value)\n }}\n ></ox-data-entry-form>\n `\n\nexport const Regular = Template.bind({})\nRegular.args = {}\n"]}