@operato/dataset 10.29.78 → 10.29.79
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 +9 -0
- package/dist/src/ox-checklist-entry-form.d.ts +1 -0
- package/dist/src/ox-checklist-entry-form.js +3 -6
- package/dist/src/ox-checklist-entry-form.js.map +1 -1
- package/dist/src/ox-data-entry-form.d.ts +1 -0
- package/dist/src/ox-data-entry-form.js +2 -6
- package/dist/src/ox-data-entry-form.js.map +1 -1
- package/dist/src/ox-data-input-factory.d.ts +1 -0
- package/dist/src/ox-data-input-factory.js +2 -6
- package/dist/src/ox-data-input-factory.js.map +1 -1
- package/dist/test/date-item.test.d.ts +2 -0
- package/dist/test/date-item.test.js +49 -0
- package/dist/test/date-item.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/test/date-item.test.ts +55 -0
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
|
+
### [10.29.79](https://github.com/hatiolab/operato/compare/v10.29.78...v10.29.79) (2026-11-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* **dataset,attribute:** date items and attributes are ox-input-date ([b1cb75a](https://github.com/hatiolab/operato/commit/b1cb75abd125261ec0d8d603b1a1d3d16e723fb1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
### [10.29.78](https://github.com/hatiolab/operato/compare/v10.29.77...v10.29.78) (2026-11-10)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @operato/dataset
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
+
import '@operato/input/ox-input-date.js';
|
|
2
3
|
import '@material/web/icon/icon.js';
|
|
3
4
|
import '@operato/context/ox-context-page-toolbar.js';
|
|
4
5
|
import '@operato/board/ox-board-viewer.js';
|
|
@@ -181,12 +182,7 @@ let OxChecklistEntryForm = class OxChecklistEntryForm extends LitElement {
|
|
|
181
182
|
return html ` <input type="number" name=${tag} value=${value} />`;
|
|
182
183
|
case 'date':
|
|
183
184
|
return html `
|
|
184
|
-
<input
|
|
185
|
-
type="date"
|
|
186
|
-
name=${tag}
|
|
187
|
-
value=${value}
|
|
188
|
-
@click=${(e) => e.currentTarget.showPicker()}
|
|
189
|
-
/>
|
|
185
|
+
<ox-input-date type="date" name=${tag} .value=${value !== null && value !== void 0 ? value : ''}></ox-input-date>
|
|
190
186
|
`;
|
|
191
187
|
case 'datetime':
|
|
192
188
|
return html `
|
|
@@ -295,6 +291,7 @@ OxChecklistEntryForm.styles = [
|
|
|
295
291
|
}
|
|
296
292
|
|
|
297
293
|
input,
|
|
294
|
+
ox-input-date,
|
|
298
295
|
select {
|
|
299
296
|
background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));
|
|
300
297
|
color: var(--input-field-color, var(--md-sys-color-on-surface));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-checklist-entry-form.js","sourceRoot":"","sources":["../../src/ox-checklist-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,6CAA6C,CAAA;AACpD,OAAO,mCAAmC,CAAA;AAC1C,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AAGzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAgB,MAAM,mBAAmB,CAAA;AAIzE,OAAO,EAAE,OAAO,EAAY,MAAM,eAAe,CAAA;AAEjD,OAAO,EA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AC,CAAC,aAAkC,CAAC,UAAU,EAAE;;SAE5E,CAAA;YAEH,KAAK,MAAM;gBACT,OAAO,IAAI,CAAA,uBAAuB,GAAG,oBAAoB,KAAK,mBAAmB,CAAA;YAEnF,KAAK,OAAO;gBACV,OAAO,IAAI,CAAA,wBAAwB,GAAG,WAAW,KAAK,oBAAoB,CAAA;YAE5E,KAAK,OAAO;gBACV,OAAO,IAAI,CAAA,wBAAwB,GAAG,WAAW,KAAK,oBAAoB,CAAA;YAE5E,KAAK,OAAO;gBACV,OAAO,IAAI,CAAA,wBAAwB,GAAG,WAAW,KAAK,oBAAoB,CAAA;YAE5E,KAAK,WAAW;gBACd,OAAO,IAAI,CAAA,4BAA4B,GAAG,UAAU,KAAK,wBAAwB,CAAA;YAEnF,KAAK,QAAQ,CAAC;YACd;gBACE,OAAO,IAAI,CAAA,4BAA4B,GAAG,UAAU,KAAK,IAAI,EAAE,KAAK,CAAA;QACxE,CAAC;IACH,CAAC;;AA3VM,2BAAM,GAAG;IACd,eAAe;IACf,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyFF;CACF,AA5FY,CA4FZ;AAU2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA+B;AAxG/C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CA6VhC","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/context/ox-context-page-toolbar.js'\nimport '@operato/board/ox-board-viewer.js'\nimport '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-signature.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { DataItem, DataSample, DataSet } from './types'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { PageView } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\n@customElement('ox-checklist-entry-form')\nexport class OxChecklistEntryForm extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n --signature-min-width: 100px;\n --signature-min-height: 60px;\n overflow: auto;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n text-transform: capitalize;\n }\n table {\n border-collapse: collapse;\n margin-bottom: var(--spacing-medium);\n }\n th {\n padding: var(--th-padding);\n border-top: var(--th-border-top);\n border-bottom: var(--td-border-bottom);\n text-transform: var(--th-text-transform);\n font: var(--th-font);\n color: var(--th-color);\n text-align: left;\n white-space: nowrap;\n }\n th[item] {\n min-width: 100px;\n }\n th[value] {\n min-width: 100px;\n }\n thead tr {\n background-color: var(--md-sys-color-primary-container);\n }\n tbody tr {\n background-color: var(--md-sys-color-background);\n }\n tbody tr:hover {\n background-color: var(--tr-background-hover-color);\n }\n tr[ooc],\n tr[oos] {\n background-color: #fefbdf;\n }\n td {\n border: var(--td-border-line);\n padding: var(--td-padding);\n font: var(--td-font);\n color: var(--td-color);\n }\n td[name] {\n font-weight: bold;\n }\n td md-icon {\n color: var(--md-sys-color-error);\n }\n div[element] {\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 flex: 1;\n }\n\n input,\n select {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\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 `\n ]\n\n get context() {\n return {\n title: i18next.t('title.checklist entry page'),\n help: 'dataset/checklist-entry-page',\n toolbar: false\n }\n }\n\n @property({ type: Object }) dataSet?: DataSet\n @property({ type: Object }) value?: { [tag: string]: any }\n\n render() {\n return html` ${this.buildInputs()} `\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 buildValue(): { [tag: string]: any } {\n return this.extractValuesFromInputs()\n }\n\n private extractValuesFromInputs(): { [tag: string]: any } {\n return (this.dataSet?.dataItems || []).reduce(\n (values, dataItem) => {\n const { tag, type } = dataItem\n const editors = Array.from(this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>)\n\n if (editors.length > 0) {\n values[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return values\n },\n {} as { [tag: string]: any }\n )\n }\n\n buildInputs() {\n const dataItems = this.dataSet?.dataItems || []\n const groupItems = dataItems?.filter(i => i.group)\n const nonGroupItems = dataItems?.filter(i => !i.group)\n\n let nameColspan = 1\n nameColspan += groupItems.length > 0 ? 1 : 0\n nameColspan += groupItems.some(i => i.subgroup) ? 1 : 0\n\n return html`\n <form class=\"checklist\" @change=${this.onChange}>\n <table>\n <thead>\n <tr>\n <th colspan=${nameColspan} item>${i18next.t('field.item')}</th>\n <th value>${i18next.t('field.value')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.buildGroupInputs(groupItems, nameColspan)} ${this.buildNonGroupInputs(nonGroupItems, nameColspan)}\n </tbody>\n </table>\n </form>\n `\n }\n\n buildGroupInputs(items: DataItem[], nameColspan: number) {\n let isSubgroupExist = items.some(i => i.subgroup)\n let renderedGroups: { group: string; subgroup?: string | undefined }[] = []\n\n return html`\n ${items.map(item => {\n const { name, tag, type, quota = 1, options = {}, unit, group, subgroup } = item\n const value = this.value?.[tag] === undefined ? [] : this.value?.[tag]\n\n let groupTd = null\n if (!this.isGroupRendered(renderedGroups, group)) {\n groupTd = html`<td rowspan=\"${this.groupItemNums(items, group)}\">${group}</td>`\n renderedGroups.push({ group })\n }\n\n let subgroupTd = null\n if (subgroup && !this.isGroupRendered(renderedGroups, group, subgroup)) {\n subgroupTd = html`<td rowspan=\"${this.groupItemNums(items, group, subgroup)}\">${subgroup}</td>`\n renderedGroups.push({ group, subgroup })\n }\n\n return html`\n <tr>\n ${groupTd} ${subgroupTd}\n <td colspan=${isSubgroupExist && !subgroup ? 2 : 1}>${name}</td>\n <td>\n <div elements>\n ${Array.from({ length: quota || 1 }, (_, idx) =>\n this.createInputElement(\n type,\n tag,\n Array.isArray(value) ? value[idx] : idx === 0 ? value : undefined,\n options,\n idx\n )\n )}\n </div>\n </td>\n </tr>\n `\n })}\n `\n }\n\n buildNonGroupInputs(items: DataItem[], nameColspan: number) {\n return html`\n ${items.map(item => {\n const { name, tag, type, quota = 1, options = {}, unit } = item\n const value = this.value?.[tag] === undefined ? [] : this.value?.[tag]\n\n return html`\n <tr>\n <td name colspan=${nameColspan}>${name}</td>\n <td>\n <div element>\n ${Array.from({ length: quota || 1 }, (_, idx) =>\n this.createInputElement(\n type,\n tag,\n Array.isArray(value) ? value[idx] : idx === 0 ? value : undefined,\n options,\n idx\n )\n )}\n </div>\n </td>\n </tr>\n `\n })}\n `\n }\n\n isGroupRendered(renderedGroups: { group: string; subgroup?: string }[], group: string, subgroup?: string) {\n if (subgroup) {\n return renderedGroups.some(groupInfo => groupInfo.group === group && groupInfo.subgroup === subgroup)\n } else {\n return renderedGroups.some(groupInfo => groupInfo.group === group)\n }\n }\n\n groupItemNums(items: DataItem[], group: string, subgroup?: string) {\n let nums = 0\n\n if (subgroup) {\n items.forEach(i => {\n if (i.group === group && i.subgroup === subgroup) {\n nums += 1\n }\n })\n } else {\n items.forEach(i => {\n if (i.group === group) {\n nums += 1\n }\n })\n }\n\n return nums\n }\n\n createInputElement(type: string, tag: string, value: any, options: any, idx: number) {\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n <option value=\"\"></option>\n ${(options.options || []).map(\n (option: any) =>\n html`<option value=${option.value} ?selected=${option.value === value}>${option.text}</option>`\n )}\n </select>`\n\n case 'radio':\n return html`<div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const inputHidden = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n inputHidden.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n\n ${(options.options || []).map(\n (option: any) =>\n html`<label>\n <input\n type=\"radio\"\n name=${'$' + tag + '-' + idx}\n .value=${option.value}\n ?checked=${option.value === value}\n />\n ${option.text}\n </label>`\n )}\n </div>`\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${value} />`\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${value} />`\n\n case 'date':\n return html`\n <input\n type=\"date\"\n name=${tag}\n value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />\n `\n\n case 'datetime':\n return html`\n <input\n type=\"datetime-local\"\n name=${tag}\n value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />\n `\n\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`\n\n case 'image':\n return html`<ox-input-image name=${tag} .value=${value}></ox-input-image>`\n\n case 'video':\n return html`<ox-input-video name=${tag} .value=${value}></ox-input-video>`\n\n case 'audio':\n return html`<ox-input-audio name=${tag} .value=${value}></ox-input-audio>`\n\n case 'signature':\n return html`<ox-input-signature name=${tag} value=${value}></ox-input-signature>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${value || ''} />`\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-checklist-entry-form.js","sourceRoot":"","sources":["../../src/ox-checklist-entry-form.ts"],"names":[],"mappings":";AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,4BAA4B,CAAA;AACnC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,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA+B;AAzG/C,oBAAoB;IADhC,aAAa,CAAC,yBAAyB,CAAC;GAC5B,oBAAoB,CAyVhC","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@material/web/icon/icon.js'\nimport '@operato/context/ox-context-page-toolbar.js'\nimport '@operato/board/ox-board-viewer.js'\nimport '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-signature.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\n\nimport { DataItem, DataSample, DataSet } from './types'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { PageView } from '@operato/shell'\nimport { ScrollbarStyles } from '@operato/styles'\n\n@customElement('ox-checklist-entry-form')\nexport class OxChecklistEntryForm extends LitElement {\n static styles = [\n ScrollbarStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n\n --signature-min-width: 100px;\n --signature-min-height: 60px;\n overflow: auto;\n }\n\n form {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n }\n h2 {\n margin: var(--title-margin);\n font: var(--title-font);\n color: var(--title-text-color);\n text-transform: capitalize;\n }\n table {\n border-collapse: collapse;\n margin-bottom: var(--spacing-medium);\n }\n th {\n padding: var(--th-padding);\n border-top: var(--th-border-top);\n border-bottom: var(--td-border-bottom);\n text-transform: var(--th-text-transform);\n font: var(--th-font);\n color: var(--th-color);\n text-align: left;\n white-space: nowrap;\n }\n th[item] {\n min-width: 100px;\n }\n th[value] {\n min-width: 100px;\n }\n thead tr {\n background-color: var(--md-sys-color-primary-container);\n }\n tbody tr {\n background-color: var(--md-sys-color-background);\n }\n tbody tr:hover {\n background-color: var(--tr-background-hover-color);\n }\n tr[ooc],\n tr[oos] {\n background-color: #fefbdf;\n }\n td {\n border: var(--td-border-line);\n padding: var(--td-padding);\n font: var(--td-font);\n color: var(--td-color);\n }\n td[name] {\n font-weight: bold;\n }\n td md-icon {\n color: var(--md-sys-color-error);\n }\n div[element] {\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 flex: 1;\n }\n\n input,\n ox-input-date,\n select {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\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 `\n ]\n\n get context() {\n return {\n title: i18next.t('title.checklist entry page'),\n help: 'dataset/checklist-entry-page',\n toolbar: false\n }\n }\n\n @property({ type: Object }) dataSet?: DataSet\n @property({ type: Object }) value?: { [tag: string]: any }\n\n render() {\n return html` ${this.buildInputs()} `\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 buildValue(): { [tag: string]: any } {\n return this.extractValuesFromInputs()\n }\n\n private extractValuesFromInputs(): { [tag: string]: any } {\n return (this.dataSet?.dataItems || []).reduce(\n (values, dataItem) => {\n const { tag, type } = dataItem\n const editors = Array.from(this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>)\n\n if (editors.length > 0) {\n values[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return values\n },\n {} as { [tag: string]: any }\n )\n }\n\n buildInputs() {\n const dataItems = this.dataSet?.dataItems || []\n const groupItems = dataItems?.filter(i => i.group)\n const nonGroupItems = dataItems?.filter(i => !i.group)\n\n let nameColspan = 1\n nameColspan += groupItems.length > 0 ? 1 : 0\n nameColspan += groupItems.some(i => i.subgroup) ? 1 : 0\n\n return html`\n <form class=\"checklist\" @change=${this.onChange}>\n <table>\n <thead>\n <tr>\n <th colspan=${nameColspan} item>${i18next.t('field.item')}</th>\n <th value>${i18next.t('field.value')}</th>\n </tr>\n </thead>\n <tbody>\n ${this.buildGroupInputs(groupItems, nameColspan)} ${this.buildNonGroupInputs(nonGroupItems, nameColspan)}\n </tbody>\n </table>\n </form>\n `\n }\n\n buildGroupInputs(items: DataItem[], nameColspan: number) {\n let isSubgroupExist = items.some(i => i.subgroup)\n let renderedGroups: { group: string; subgroup?: string | undefined }[] = []\n\n return html`\n ${items.map(item => {\n const { name, tag, type, quota = 1, options = {}, unit, group, subgroup } = item\n const value = this.value?.[tag] === undefined ? [] : this.value?.[tag]\n\n let groupTd = null\n if (!this.isGroupRendered(renderedGroups, group)) {\n groupTd = html`<td rowspan=\"${this.groupItemNums(items, group)}\">${group}</td>`\n renderedGroups.push({ group })\n }\n\n let subgroupTd = null\n if (subgroup && !this.isGroupRendered(renderedGroups, group, subgroup)) {\n subgroupTd = html`<td rowspan=\"${this.groupItemNums(items, group, subgroup)}\">${subgroup}</td>`\n renderedGroups.push({ group, subgroup })\n }\n\n return html`\n <tr>\n ${groupTd} ${subgroupTd}\n <td colspan=${isSubgroupExist && !subgroup ? 2 : 1}>${name}</td>\n <td>\n <div elements>\n ${Array.from({ length: quota || 1 }, (_, idx) =>\n this.createInputElement(\n type,\n tag,\n Array.isArray(value) ? value[idx] : idx === 0 ? value : undefined,\n options,\n idx\n )\n )}\n </div>\n </td>\n </tr>\n `\n })}\n `\n }\n\n buildNonGroupInputs(items: DataItem[], nameColspan: number) {\n return html`\n ${items.map(item => {\n const { name, tag, type, quota = 1, options = {}, unit } = item\n const value = this.value?.[tag] === undefined ? [] : this.value?.[tag]\n\n return html`\n <tr>\n <td name colspan=${nameColspan}>${name}</td>\n <td>\n <div element>\n ${Array.from({ length: quota || 1 }, (_, idx) =>\n this.createInputElement(\n type,\n tag,\n Array.isArray(value) ? value[idx] : idx === 0 ? value : undefined,\n options,\n idx\n )\n )}\n </div>\n </td>\n </tr>\n `\n })}\n `\n }\n\n isGroupRendered(renderedGroups: { group: string; subgroup?: string }[], group: string, subgroup?: string) {\n if (subgroup) {\n return renderedGroups.some(groupInfo => groupInfo.group === group && groupInfo.subgroup === subgroup)\n } else {\n return renderedGroups.some(groupInfo => groupInfo.group === group)\n }\n }\n\n groupItemNums(items: DataItem[], group: string, subgroup?: string) {\n let nums = 0\n\n if (subgroup) {\n items.forEach(i => {\n if (i.group === group && i.subgroup === subgroup) {\n nums += 1\n }\n })\n } else {\n items.forEach(i => {\n if (i.group === group) {\n nums += 1\n }\n })\n }\n\n return nums\n }\n\n createInputElement(type: string, tag: string, value: any, options: any, idx: number) {\n switch (type) {\n case 'select':\n return html` <select .name=${tag}>\n <option value=\"\"></option>\n ${(options.options || []).map(\n (option: any) =>\n html`<option value=${option.value} ?selected=${option.value === value}>${option.text}</option>`\n )}\n </select>`\n\n case 'radio':\n return html`<div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const inputHidden = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n inputHidden.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n\n ${(options.options || []).map(\n (option: any) =>\n html`<label>\n <input\n type=\"radio\"\n name=${'$' + tag + '-' + idx}\n .value=${option.value}\n ?checked=${option.value === value}\n />\n ${option.text}\n </label>`\n )}\n </div>`\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${value} />`\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${value} />`\n\n case 'date':\n return html`\n <ox-input-date type=\"date\" name=${tag} .value=${value ?? ''}></ox-input-date>\n `\n\n case 'datetime':\n return html`\n <input\n type=\"datetime-local\"\n name=${tag}\n value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />\n `\n\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`\n\n case 'image':\n return html`<ox-input-image name=${tag} .value=${value}></ox-input-image>`\n\n case 'video':\n return html`<ox-input-video name=${tag} .value=${value}></ox-input-video>`\n\n case 'audio':\n return html`<ox-input-audio name=${tag} .value=${value}></ox-input-audio>`\n\n case 'signature':\n return html`<ox-input-signature name=${tag} value=${value}></ox-input-signature>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${value || ''} />`\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
+
import '@operato/input/ox-input-date.js';
|
|
2
3
|
import '@operato/input/ox-input-file.js';
|
|
3
4
|
import '@operato/input/ox-input-image.js';
|
|
4
5
|
import '@operato/input/ox-input-video.js';
|
|
@@ -102,12 +103,7 @@ let OxDataEntryForm = class OxDataEntryForm extends LitElement {
|
|
|
102
103
|
case 'number':
|
|
103
104
|
return html ` <input type="number" name=${tag} value=${v} />`;
|
|
104
105
|
case 'date':
|
|
105
|
-
return html ` <input
|
|
106
|
-
type="date"
|
|
107
|
-
name=${tag}
|
|
108
|
-
value=${v}
|
|
109
|
-
@click=${(e) => e.currentTarget.showPicker()}
|
|
110
|
-
/>`;
|
|
106
|
+
return html ` <ox-input-date type="date" name=${tag} .value=${v !== null && v !== void 0 ? v : ''}></ox-input-date>`;
|
|
111
107
|
case 'datetime':
|
|
112
108
|
return html ` <input
|
|
113
109
|
type="datetime-local"
|
|
@@ -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;AACxC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;A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3B","sourcesContent":["import '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\nimport '@operato/input/ox-input-signature.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 } from './types.js'\nimport { OxDataEntrySubgroupForm } from './ox-data-entry-subgroup-form.js'\nimport { OxDataInputFactory } from './ox-data-input-factory.js'\n\n@customElement('ox-data-entry-form')\nexport class OxDataEntryForm extends LitElement {\n static styles = css`\n :host {\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 display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n\n form > div[label] {\n display: grid;\n grid-template-rows: auto 1fr;\n grid-template-columns: 1fr 5fr;\n grid-template-areas: 'name description' 'empty inputs';\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--spacing-medium);\n }\n\n div[name] {\n grid-area: name;\n font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-align: right;\n }\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 md-icon {\n font-size: 0.9rem;\n }\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 flex: 1;\n }\n }\n\n div[subgroup] {\n grid-column: 1 / 3;\n grid-row: 2;\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`\n <form @change=${this.onChange}>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildInputs()}\n </form>\n `\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(): TemplateResult[] {\n const dataItems = this.dataSet?.dataItems.filter(item => item.active) || []\n const groupedItems = this.groupDataItemsByGroup(dataItems)\n\n const renderedGroups = new Set<string>()\n\n return dataItems.flatMap(dataItem => {\n if (dataItem.group) {\n if (renderedGroups.has(dataItem.group)) return []\n\n renderedGroups.add(dataItem.group)\n return this.buildInputsForSubgroup(dataItem.group, groupedItems[dataItem.group])\n }\n\n return this.buildInputsForNonGrouped([dataItem])\n })\n }\n\n private buildInputsForSubgroup(subgroup: string, dataItems: DataItem[]): TemplateResult {\n const subgroupValues = dataItems.reduce(\n (values, item) => {\n values[item.tag] = this.value?.[item.tag]\n return values\n },\n {} as { [tag: string]: any }\n )\n\n return html`\n <div label>\n <div name>${subgroup}</div>\n <div subgroup>\n <ox-data-entry-subgroup-form\n .subgroup=${subgroup}\n .dataItems=${dataItems}\n .value=${subgroupValues}\n @change=${this.onChange}\n ></ox-data-entry-subgroup-form>\n </div>\n </div>\n `\n }\n\n private buildInputsForNonGrouped(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\n case 'radio':\n return html`<div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const inputHidden = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n inputHidden.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n\n ${(options.options || []).map(\n option =>\n html`<label>\n <input\n type=\"radio\"\n name=${'$' + tag + '-' + idx}\n .value=${option.value}\n ?checked=${option.value === v}\n />\n ${option.text}\n </label>`\n )}\n </div>`\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${v} />`\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${v} />`\n\n case 'date':\n return html` <input\n type=\"date\"\n name=${tag}\n value=${v}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n\n case 'datetime':\n return html` <input\n type=\"datetime-local\"\n name=${tag}\n value=${v}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${v}></ox-input-file>`\n\n case 'signature':\n return html`<ox-input-signature name=${tag} value=${v}></ox-input-signature>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${v} />`\n }\n })\n\n return html` <div label>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description><md-icon>info</md-icon> ${description}</div>\n <div elements>${elements}</div>\n </div>`\n })\n }\n\n private buildValue(): { [tag: string]: any } {\n const nonGroupValues = this.extractValuesFromInputs()\n return Array.from(this.subgroups).reduce(\n (values, subgroup) => ({ ...values, ...subgroup.buildValue() }),\n nonGroupValues\n )\n }\n\n private extractValuesFromInputs(): { [tag: string]: any } {\n return (this.dataSet?.dataItems.filter(item => !item.group) || []).reduce(\n (values, dataItem) => {\n const { tag, type } = dataItem\n const editors = Array.from(this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>)\n\n if (editors.length > 0) {\n values[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return values\n },\n {} as { [tag: string]: any }\n )\n }\n\n private groupDataItemsByGroup(dataItems: DataItem[]): { [group: string]: DataItem[] } {\n return dataItems.reduce(\n (groups, item) => {\n if (item.group) {\n ;(groups[item.group] = groups[item.group] || []).push(item)\n }\n return groups\n },\n {} as { [group: string]: DataItem[] }\n )\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,iCAAiC,CAAA;AACxC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAO9D,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QA0FG,aAAQ,GAAG,CAAC,CAAQ,EAAE,EAAE;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,IAAI,CAAC,KAAK;aACnB,CAAC,CACH,CAAA;QACH,CAAC,CAAA;IA+JH,CAAC;IAnLC,MAAM;;QACJ,OAAO,IAAI,CAAA;sBACO,IAAI,CAAC,QAAQ;cACrB,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,KAAI,EAAE;cACxB,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,WAAW,KAAI,EAAE;UACnC,IAAI,CAAC,WA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CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC7D,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC,EACD,EAAqC,CACtC,CAAA;IACH,CAAC;;AAjQM,sBAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwElB,AAxEY,CAwEZ;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;AA9E7E,eAAe;IAD3B,aAAa,CAAC,oBAAoB,CAAC;GACvB,eAAe,CAmQ3B","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\nimport '@operato/input/ox-input-signature.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 } from './types.js'\nimport { OxDataEntrySubgroupForm } from './ox-data-entry-subgroup-form.js'\nimport { OxDataInputFactory } from './ox-data-input-factory.js'\n\n@customElement('ox-data-entry-form')\nexport class OxDataEntryForm extends LitElement {\n static styles = css`\n :host {\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 display: flex;\n flex-direction: column;\n overflow: hidden;\n }\n\n form > div[label] {\n display: grid;\n grid-template-rows: auto 1fr;\n grid-template-columns: 1fr 5fr;\n grid-template-areas: 'name description' 'empty inputs';\n grid-gap: 9px;\n align-items: center;\n margin-bottom: var(--spacing-medium);\n }\n\n div[name] {\n grid-area: name;\n font: var(--label-font);\n color: var(--label-color, var(--md-sys-color-on-surface));\n text-align: right;\n }\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 md-icon {\n font-size: 0.9rem;\n }\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 flex: 1;\n }\n }\n\n div[subgroup] {\n grid-column: 1 / 3;\n grid-row: 2;\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`\n <form @change=${this.onChange}>\n <h2>${this.dataSet?.name || ''}</h2>\n <h3>${this.dataSet?.description || ''}</h3>\n ${this.buildInputs()}\n </form>\n `\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(): TemplateResult[] {\n const dataItems = this.dataSet?.dataItems.filter(item => item.active) || []\n const groupedItems = this.groupDataItemsByGroup(dataItems)\n\n const renderedGroups = new Set<string>()\n\n return dataItems.flatMap(dataItem => {\n if (dataItem.group) {\n if (renderedGroups.has(dataItem.group)) return []\n\n renderedGroups.add(dataItem.group)\n return this.buildInputsForSubgroup(dataItem.group, groupedItems[dataItem.group])\n }\n\n return this.buildInputsForNonGrouped([dataItem])\n })\n }\n\n private buildInputsForSubgroup(subgroup: string, dataItems: DataItem[]): TemplateResult {\n const subgroupValues = dataItems.reduce(\n (values, item) => {\n values[item.tag] = this.value?.[item.tag]\n return values\n },\n {} as { [tag: string]: any }\n )\n\n return html`\n <div label>\n <div name>${subgroup}</div>\n <div subgroup>\n <ox-data-entry-subgroup-form\n .subgroup=${subgroup}\n .dataItems=${dataItems}\n .value=${subgroupValues}\n @change=${this.onChange}\n ></ox-data-entry-subgroup-form>\n </div>\n </div>\n `\n }\n\n private buildInputsForNonGrouped(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\n case 'radio':\n return html`<div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const inputHidden = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n inputHidden.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n\n ${(options.options || []).map(\n option =>\n html`<label>\n <input\n type=\"radio\"\n name=${'$' + tag + '-' + idx}\n .value=${option.value}\n ?checked=${option.value === v}\n />\n ${option.text}\n </label>`\n )}\n </div>`\n\n case 'boolean':\n return html` <input type=\"checkbox\" name=${tag} .checked=${v} />`\n\n case 'number':\n return html` <input type=\"number\" name=${tag} value=${v} />`\n\n case 'date':\n return html` <ox-input-date type=\"date\" name=${tag} .value=${v ?? ''}></ox-input-date>`\n\n case 'datetime':\n return html` <input\n type=\"datetime-local\"\n name=${tag}\n value=${v}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${v}></ox-input-file>`\n\n case 'signature':\n return html`<ox-input-signature name=${tag} value=${v}></ox-input-signature>`\n\n case 'string':\n default:\n return html` <input type=\"text\" name=${tag} value=${v} />`\n }\n })\n\n return html` <div label>\n <div name>${name}${unit ? `(${unit})` : ''}</div>\n <div description><md-icon>info</md-icon> ${description}</div>\n <div elements>${elements}</div>\n </div>`\n })\n }\n\n private buildValue(): { [tag: string]: any } {\n const nonGroupValues = this.extractValuesFromInputs()\n return Array.from(this.subgroups).reduce(\n (values, subgroup) => ({ ...values, ...subgroup.buildValue() }),\n nonGroupValues\n )\n }\n\n private extractValuesFromInputs(): { [tag: string]: any } {\n return (this.dataSet?.dataItems.filter(item => !item.group) || []).reduce(\n (values, dataItem) => {\n const { tag, type } = dataItem\n const editors = Array.from(this.renderRoot.querySelectorAll(`[name=${tag}]`) as NodeListOf<HTMLInputElement>)\n\n if (editors.length > 0) {\n values[tag] = editors.map(editor => (type === 'boolean' ? editor.checked : editor.value))\n }\n\n return values\n },\n {} as { [tag: string]: any }\n )\n }\n\n private groupDataItemsByGroup(dataItems: DataItem[]): { [group: string]: DataItem[] } {\n return dataItems.reduce(\n (groups, item) => {\n if (item.group) {\n ;(groups[item.group] = groups[item.group] || []).push(item)\n }\n return groups\n },\n {} as { [group: string]: DataItem[] }\n )\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@operato/input/ox-input-date.js';
|
|
1
2
|
import '@operato/input/ox-input-file.js';
|
|
2
3
|
import '@operato/input/ox-input-signature.js';
|
|
3
4
|
import '@operato/input/ox-input-image.js';
|
|
@@ -30,12 +31,7 @@ export class OxDataInputFactory {
|
|
|
30
31
|
case 'number':
|
|
31
32
|
return html `<input type="number" name=${tag} .value=${value} />`;
|
|
32
33
|
case 'date':
|
|
33
|
-
return html `<input
|
|
34
|
-
type="date"
|
|
35
|
-
name=${tag}
|
|
36
|
-
.value=${value}
|
|
37
|
-
@click=${(e) => e.currentTarget.showPicker()}
|
|
38
|
-
/>`;
|
|
34
|
+
return html `<ox-input-date type="date" name=${tag} .value=${value !== null && value !== void 0 ? value : ''}></ox-input-date>`;
|
|
39
35
|
case 'datetime':
|
|
40
36
|
return html `<input
|
|
41
37
|
type="datetime-local"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-data-input-factory.js","sourceRoot":"","sources":["../../src/ox-data-input-factory.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,qDAAqD;AAErD,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAY,EAAE,GAAW,EAAE,KAAU,EAAE,UAAe,EAAE,EAAE,MAAc,CAAC;QACjG,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YAC/C,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;YACnD,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAA,+BAA+B,GAAG,aAAa,KAAK,KAAK,CAAA;YACtE,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAA,6BAA6B,GAAG,WAAW,KAAK,KAAK,CAAA;YAClE,KAAK,MAAM;gBACT,OAAO,IAAI,CAAA;;iBAEF,GAAG;mBACD,KAAK;mBACL,CAAC,CAAQ,EAAE,EAAE,CAAE,CAAC,CAAC,aAAkC,CAAC,UAAU,EAAE;WACxE,CAAA;YACL,KAAK,UAAU;gBACb,OAAO,IAAI,CA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ChB,KAAK,OAAO;gBACV,OAAO,OAAO,CAAA;YAChB,KAAK,WAAW;gBACd,OAAO,WAAW,CAAA;YACpB,KAAK,QAAQ;gBACX,OAAO,MAAM,CAAA;YACf;gBACE,OAAO,IAAI,CAAA;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,IAAY,EAAE,UAAe,EAAE;QAC1D,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ,CAAC;YACd,KAAK,OAAO;gBACV,OAAO;oBACL,OAAO,EAAE;wBACP,EAAE;wBACF,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAC1C,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CACxE;qBACF;iBACF,CAAA;YACH,KAAK,SAAS;gBACZ,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;YAC5B,KAAK,QAAQ;gBACX,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3B,KAAK,MAAM;gBACT,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;YAC3B;gBACE,OAAO,EAAE,CAAA;QACb,CAAC;IACH,CAAC;CACF","sourcesContent":["import '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-signature.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\n// import '@operato/app/ox-filter-resource-object.js'\n\nimport { html, TemplateResult } from 'lit'\n\n/**\n * OxDataInputFactory\n * A factory class that dynamically generates input elements based on different data types.\n */\nexport class OxDataInputFactory {\n /**\n * Creates an input element based on the specified type.\n * @param type - The type of input (e.g., text, number, date, select, etc.)\n * @param tag - The name attribute for the input field\n * @param value - The current value of the input field\n * @param options - Additional options (used for select, radio, etc.)\n * @param idx - Index for multiple input fields\n * @returns TemplateResult - A Lit template result for rendering\n */\n static createInputElement(type: string, tag: string, value: any, options: any = {}, idx: number = 0): TemplateResult {\n switch (type) {\n case 'select':\n return this.createSelect(tag, value, options)\n case 'radio':\n return this.createRadio(tag, value, options, idx)\n case 'boolean':\n return html`<input type=\"checkbox\" name=${tag} .checked=${value} />`\n case 'number':\n return html`<input type=\"number\" name=${tag} .value=${value} />`\n case 'date':\n return html`<input\n type=\"date\"\n name=${tag}\n .value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n case 'datetime':\n return html`<input\n type=\"datetime-local\"\n name=${tag}\n .value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`\n case 'image':\n return html`<ox-input-image name=${tag} .value=${value}></ox-input-image>`\n case 'video':\n return html`<ox-input-video name=${tag} .value=${value}></ox-input-video>`\n case 'audio':\n return html`<ox-input-audio name=${tag} .value=${value}></ox-input-audio>`\n case 'signature':\n return html`<ox-input-signature name=${tag} .value=${value}></ox-input-signature>`\n case 'employee':\n return this.createEmployee(tag, value, options)\n case 'string':\n default:\n return html`<input type=\"text\" name=${tag} .value=${value || ''} />`\n }\n }\n\n /**\n * Creates a select dropdown element.\n * @param tag - The name attribute for the select element\n * @param value - The currently selected value\n * @param options - The available options for the dropdown\n * @returns TemplateResult - A Lit template result for rendering\n */\n private static createSelect(tag: string, value: any, options: any): TemplateResult {\n return html`\n <select name=${tag}>\n <option value=\"\"></option>\n ${options.options?.map(\n (option: any) => html`\n <option value=${option.value} ?selected=${option.value === value}>${option.text}</option>\n `\n )}\n </select>\n `\n }\n\n /**\n * Creates a radio button group.\n * @param tag - The name attribute for the radio group\n * @param value - The currently selected value\n * @param options - The available radio options\n * @param idx - Index for multiple radio groups\n * @returns TemplateResult - A Lit template result for rendering\n */\n private static createRadio(tag: string, value: any, options: any, idx: number): TemplateResult {\n return html`\n <div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const hiddenInput = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n hiddenInput.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n ${options.options?.map(\n (option: any) => html`\n <label>\n <input type=\"radio\" name=${`${tag}-${idx}`} value=${option.value} ?checked=${option.value === value} />\n ${option.text}\n </label>\n `\n )}\n </div>\n `\n }\n\n /**\n * Creates a filter resource object element.\n * @param tag - The name attribute for the input field\n * @param value - The current value of the input field\n * @param options - Additional options\n * @returns TemplateResult - A Lit template result for\n */\n private static createEmployee(tag: string, value: any, options: any): TemplateResult {\n return html``\n // return html`<ox-filter-resource-object\n // .name=${tag}\n // .value=${value}\n // .confirmCallback=${confirmCallback.bind(this)}\n // .queryName=${'employees'}\n // .columns=${columns}\n // .pagination=${pagination}\n // .list=${list}\n // .basicArgs=${basicArgs}\n // .valueField=${valueField}\n // ></ox-filter-resource-object>`\n }\n\n /**\n * Maps form input types to Grist-compatible column types.\n * Ensures `OxDataEntrySubgroupForm` properly maps UI components to Grist.\n */\n static mapGristType(type: string): string {\n switch (type) {\n case 'radio':\n case 'select':\n return 'select' // Convert radio to select for Grist\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'date':\n return 'date'\n case 'datetime':\n return 'datetime'\n case 'file':\n return 'file'\n case 'image':\n return 'image'\n case 'video':\n return 'video'\n case 'audio':\n return 'audio'\n case 'signature':\n return 'signature'\n case 'string':\n return 'text'\n default:\n return type\n }\n }\n\n /**\n * Retrieves additional record options for Grist columns.\n */\n static getGristRecordOptions(type: string, options: any = {}): any {\n switch (type) {\n case 'select':\n case 'radio':\n return {\n options: [\n '',\n ...(options.options || []).map((opt: any) =>\n typeof opt === 'string' ? opt : { display: opt.text, value: opt.value }\n )\n ]\n }\n case 'boolean':\n return { align: 'center' }\n case 'number':\n return { align: 'right' }\n case 'file':\n return { multiple: true }\n default:\n return {}\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-data-input-factory.js","sourceRoot":"","sources":["../../src/ox-data-input-factory.ts"],"names":[],"mappings":"AAAA,OAAO,iCAAiC,CAAA;AACxC,OAAO,iCAAiC,CAAA;AACxC,OAAO,sCAAsC,CAAA;AAC7C,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,OAAO,kCAAkC,CAAA;AACzC,qDAAqD;AAErD,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAY,EAAE,GAAW,EAAE,KAAU,EAAE,UAAe,EAAE,EAAE,MAAc,CAAC;QACjG,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YAC/C,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;YACnD,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAA,+BAA+B,GAAG,aAAa,KAAK,KAAK,CAAA;YACtE,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAA,6BAA6B,GAAG,WAAW,KAAK,KAAK,CAAA;YAClE,KAAK,MAAM;gBACT,OAAO,IAAI,CAAA,mCAAmC,GAAG,WAAW,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,mBAAmB,CAAA;YAC5F,KAAK,UAAU;gBACb,OAAO,IAAI,CAAA;;iBAEF,GAAG;mBACD,KAAK;mBACL,CAAC,CAAQ,EAAE,EAAE,CAAE,CAAC,CAAC,aAAkC,CAAC,UAAU,EAAE;WACxE,CAAA;YACL,KAAK,MAAM;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E,OAAO,IAAI,CAAA;QACf,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,IAAY,EAAE,UAAe,EAAE;QAC1D,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ,CAAC;YACd,KAAK,OAAO;gBACV,OAAO;oBACL,OAAO,EAAE;wBACP,EAAE;wBACF,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAC1C,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CACxE;qBACF;iBACF,CAAA;YACH,KAAK,SAAS;gBACZ,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;YAC5B,KAAK,QAAQ;gBACX,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3B,KAAK,MAAM;gBACT,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;YAC3B;gBACE,OAAO,EAAE,CAAA;QACb,CAAC;IACH,CAAC;CACF","sourcesContent":["import '@operato/input/ox-input-date.js'\nimport '@operato/input/ox-input-file.js'\nimport '@operato/input/ox-input-signature.js'\nimport '@operato/input/ox-input-image.js'\nimport '@operato/input/ox-input-video.js'\nimport '@operato/input/ox-input-audio.js'\n// import '@operato/app/ox-filter-resource-object.js'\n\nimport { html, TemplateResult } from 'lit'\n\n/**\n * OxDataInputFactory\n * A factory class that dynamically generates input elements based on different data types.\n */\nexport class OxDataInputFactory {\n /**\n * Creates an input element based on the specified type.\n * @param type - The type of input (e.g., text, number, date, select, etc.)\n * @param tag - The name attribute for the input field\n * @param value - The current value of the input field\n * @param options - Additional options (used for select, radio, etc.)\n * @param idx - Index for multiple input fields\n * @returns TemplateResult - A Lit template result for rendering\n */\n static createInputElement(type: string, tag: string, value: any, options: any = {}, idx: number = 0): TemplateResult {\n switch (type) {\n case 'select':\n return this.createSelect(tag, value, options)\n case 'radio':\n return this.createRadio(tag, value, options, idx)\n case 'boolean':\n return html`<input type=\"checkbox\" name=${tag} .checked=${value} />`\n case 'number':\n return html`<input type=\"number\" name=${tag} .value=${value} />`\n case 'date':\n return html`<ox-input-date type=\"date\" name=${tag} .value=${value ?? ''}></ox-input-date>`\n case 'datetime':\n return html`<input\n type=\"datetime-local\"\n name=${tag}\n .value=${value}\n @click=${(e: Event) => (e.currentTarget as HTMLInputElement).showPicker()}\n />`\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`\n case 'image':\n return html`<ox-input-image name=${tag} .value=${value}></ox-input-image>`\n case 'video':\n return html`<ox-input-video name=${tag} .value=${value}></ox-input-video>`\n case 'audio':\n return html`<ox-input-audio name=${tag} .value=${value}></ox-input-audio>`\n case 'signature':\n return html`<ox-input-signature name=${tag} .value=${value}></ox-input-signature>`\n case 'employee':\n return this.createEmployee(tag, value, options)\n case 'string':\n default:\n return html`<input type=\"text\" name=${tag} .value=${value || ''} />`\n }\n }\n\n /**\n * Creates a select dropdown element.\n * @param tag - The name attribute for the select element\n * @param value - The currently selected value\n * @param options - The available options for the dropdown\n * @returns TemplateResult - A Lit template result for rendering\n */\n private static createSelect(tag: string, value: any, options: any): TemplateResult {\n return html`\n <select name=${tag}>\n <option value=\"\"></option>\n ${options.options?.map(\n (option: any) => html`\n <option value=${option.value} ?selected=${option.value === value}>${option.text}</option>\n `\n )}\n </select>\n `\n }\n\n /**\n * Creates a radio button group.\n * @param tag - The name attribute for the radio group\n * @param value - The currently selected value\n * @param options - The available radio options\n * @param idx - Index for multiple radio groups\n * @returns TemplateResult - A Lit template result for rendering\n */\n private static createRadio(tag: string, value: any, options: any, idx: number): TemplateResult {\n return html`\n <div\n @change=${(e: Event) => {\n const div = e.currentTarget as HTMLElement\n const hiddenInput = div.querySelector(`input[name=\"${tag}\"]`) as HTMLInputElement\n hiddenInput.value = (e.target as HTMLInputElement).value\n }}\n >\n <input type=\"hidden\" name=${tag} />\n ${options.options?.map(\n (option: any) => html`\n <label>\n <input type=\"radio\" name=${`${tag}-${idx}`} value=${option.value} ?checked=${option.value === value} />\n ${option.text}\n </label>\n `\n )}\n </div>\n `\n }\n\n /**\n * Creates a filter resource object element.\n * @param tag - The name attribute for the input field\n * @param value - The current value of the input field\n * @param options - Additional options\n * @returns TemplateResult - A Lit template result for\n */\n private static createEmployee(tag: string, value: any, options: any): TemplateResult {\n return html``\n // return html`<ox-filter-resource-object\n // .name=${tag}\n // .value=${value}\n // .confirmCallback=${confirmCallback.bind(this)}\n // .queryName=${'employees'}\n // .columns=${columns}\n // .pagination=${pagination}\n // .list=${list}\n // .basicArgs=${basicArgs}\n // .valueField=${valueField}\n // ></ox-filter-resource-object>`\n }\n\n /**\n * Maps form input types to Grist-compatible column types.\n * Ensures `OxDataEntrySubgroupForm` properly maps UI components to Grist.\n */\n static mapGristType(type: string): string {\n switch (type) {\n case 'radio':\n case 'select':\n return 'select' // Convert radio to select for Grist\n case 'boolean':\n return 'boolean'\n case 'number':\n return 'number'\n case 'date':\n return 'date'\n case 'datetime':\n return 'datetime'\n case 'file':\n return 'file'\n case 'image':\n return 'image'\n case 'video':\n return 'video'\n case 'audio':\n return 'audio'\n case 'signature':\n return 'signature'\n case 'string':\n return 'text'\n default:\n return type\n }\n }\n\n /**\n * Retrieves additional record options for Grist columns.\n */\n static getGristRecordOptions(type: string, options: any = {}): any {\n switch (type) {\n case 'select':\n case 'radio':\n return {\n options: [\n '',\n ...(options.options || []).map((opt: any) =>\n typeof opt === 'string' ? opt : { display: opt.text, value: opt.value }\n )\n ]\n }\n case 'boolean':\n return { align: 'center' }\n case 'number':\n return { align: 'right' }\n case 'file':\n return { multiple: true }\n default:\n return {}\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { expect, fixture, oneEvent } from '@open-wc/testing';
|
|
2
|
+
import { sendKeys } from '@web/test-runner-commands';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { i18next } from '@operato/i18n';
|
|
5
|
+
import { OxInputDate } from '@operato/input/ox-input-date.js';
|
|
6
|
+
import '../src/ox-data-entry-form.js';
|
|
7
|
+
import '../src/ox-checklist-entry-form.js';
|
|
8
|
+
/* A date item of a data set is entered in the one field for days (ox-input-date); what is typed is the item's value. */
|
|
9
|
+
describe('a date item', () => {
|
|
10
|
+
const touchQuery = OxInputDate.touchQuery;
|
|
11
|
+
let previousLanguage;
|
|
12
|
+
before(async () => {
|
|
13
|
+
OxInputDate.touchQuery = 'not all';
|
|
14
|
+
previousLanguage = i18next.language;
|
|
15
|
+
await i18next.changeLanguage('ko');
|
|
16
|
+
});
|
|
17
|
+
after(async () => {
|
|
18
|
+
OxInputDate.touchQuery = touchQuery;
|
|
19
|
+
/* The language is kept in the browser's storage; the next test file must not start in Korean. */
|
|
20
|
+
await i18next.changeLanguage(previousLanguage);
|
|
21
|
+
});
|
|
22
|
+
const dataSet = {
|
|
23
|
+
name: 'inspection',
|
|
24
|
+
description: '',
|
|
25
|
+
dataItems: [{ name: 'checked on', tag: 'checkedOn', type: 'date', active: true, quota: 1, options: {} }]
|
|
26
|
+
};
|
|
27
|
+
it('is entered in the field and read into the form\'s value', async () => {
|
|
28
|
+
const form = await fixture(html `<ox-data-entry-form .dataSet=${dataSet} .value=${{ checkedOn: '2026-01-01' }}></ox-data-entry-form>`);
|
|
29
|
+
const field = form.renderRoot.querySelector('ox-input-date[name="checkedOn"]');
|
|
30
|
+
expect(field, 'no day field').to.exist;
|
|
31
|
+
await field.updateComplete;
|
|
32
|
+
const input = field.renderRoot.querySelector('input');
|
|
33
|
+
expect(input.value).to.equal('2026-01-01');
|
|
34
|
+
input.focus();
|
|
35
|
+
input.select();
|
|
36
|
+
setTimeout(async () => {
|
|
37
|
+
await sendKeys({ type: '1110' });
|
|
38
|
+
await sendKeys({ press: 'Enter' });
|
|
39
|
+
});
|
|
40
|
+
const { detail } = await oneEvent(form, 'change');
|
|
41
|
+
expect(detail.checkedOn).to.deep.equal(['2026-11-10']);
|
|
42
|
+
});
|
|
43
|
+
it('is the same field in a checklist', async () => {
|
|
44
|
+
const form = await fixture(html `<ox-checklist-entry-form .dataSet=${dataSet}></ox-checklist-entry-form>`);
|
|
45
|
+
expect(form.renderRoot.querySelector('ox-input-date[name="checkedOn"]'), 'no day field').to.exist;
|
|
46
|
+
expect(form.renderRoot.querySelector('input[type="date"]')).to.not.exist;
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=date-item.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-item.test.js","sourceRoot":"","sources":["../../test/date-item.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAE7D,OAAO,8BAA8B,CAAA;AACrC,OAAO,mCAAmC,CAAA;AAE1C,wHAAwH;AACxH,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAA;IACzC,IAAI,gBAAwB,CAAA;IAC5B,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,WAAW,CAAC,UAAU,GAAG,SAAS,CAAA;QAClC,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAA;QACnC,MAAM,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IACF,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,WAAW,CAAC,UAAU,GAAG,UA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AAE,QAAQ,CAAC,CAAA;QACjD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAM,IAAI,CAAA,qCAAqC,OAAO,6BAA6B,CAAC,CAAA;QAC9G,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,iCAAiC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK,CAAA;QACjG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAA;IAC1E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, oneEvent } from '@open-wc/testing'\nimport { sendKeys } from '@web/test-runner-commands'\nimport { html } from 'lit'\n\nimport { i18next } from '@operato/i18n'\nimport { OxInputDate } from '@operato/input/ox-input-date.js'\n\nimport '../src/ox-data-entry-form.js'\nimport '../src/ox-checklist-entry-form.js'\n\n/* A date item of a data set is entered in the one field for days (ox-input-date); what is typed is the item's value. */\ndescribe('a date item', () => {\n const touchQuery = OxInputDate.touchQuery\n let previousLanguage: string\n before(async () => {\n OxInputDate.touchQuery = 'not all'\n previousLanguage = i18next.language\n await i18next.changeLanguage('ko')\n })\n after(async () => {\n OxInputDate.touchQuery = touchQuery\n /* The language is kept in the browser's storage; the next test file must not start in Korean. */\n await i18next.changeLanguage(previousLanguage)\n })\n\n const dataSet = {\n name: 'inspection',\n description: '',\n dataItems: [{ name: 'checked on', tag: 'checkedOn', type: 'date', active: true, quota: 1, options: {} }]\n } as any\n\n it('is entered in the field and read into the form\\'s value', async () => {\n const form = await fixture<any>(html`<ox-data-entry-form .dataSet=${dataSet} .value=${{ checkedOn: '2026-01-01' }}></ox-data-entry-form>`)\n const field = form.renderRoot.querySelector('ox-input-date[name=\"checkedOn\"]') as OxInputDate\n expect(field, 'no day field').to.exist\n await field.updateComplete\n const input = field.renderRoot.querySelector('input') as HTMLInputElement\n expect(input.value).to.equal('2026-01-01')\n\n input.focus()\n input.select()\n setTimeout(async () => {\n await sendKeys({ type: '1110' })\n await sendKeys({ press: 'Enter' })\n })\n const { detail } = await oneEvent(form, 'change')\n expect(detail.checkedOn).to.deep.equal(['2026-11-10'])\n })\n\n it('is the same field in a checklist', async () => {\n const form = await fixture<any>(html`<ox-checklist-entry-form .dataSet=${dataSet}></ox-checklist-entry-form>`)\n expect(form.renderRoot.querySelector('ox-input-date[name=\"checkedOn\"]'), 'no day field').to.exist\n expect(form.renderRoot.querySelector('input[type=\"date\"]')).to.not.exist\n })\n})\n"]}
|