@operato/dataset 9.0.34 → 9.2.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,24 @@
|
|
|
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
|
+
## [9.2.0](https://github.com/hatiolab/operato/compare/v9.1.1...v9.2.0) (2025-11-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
* add media types to data entry form stories ([70a0102](https://github.com/hatiolab/operato/commit/70a01027f7b41c10c88bdbd19231205435dbd048))
|
|
12
|
+
* add video and audio input components for media upload ([433053e](https://github.com/hatiolab/operato/commit/433053ecc3d595c578c82ec56b5c5f252af42795))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [9.1.0](https://github.com/hatiolab/operato/compare/v9.0.35...v9.1.0) (2025-09-16)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @operato/dataset
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
### [9.0.34](https://github.com/hatiolab/operato/compare/v9.0.33...v9.0.34) (2025-09-15)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @operato/dataset
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import '@operato/input/ox-input-file.js';
|
|
2
2
|
import '@operato/input/ox-input-signature.js';
|
|
3
|
+
import '@operato/input/ox-input-image.js';
|
|
4
|
+
import '@operato/input/ox-input-video.js';
|
|
5
|
+
import '@operato/input/ox-input-audio.js';
|
|
3
6
|
import { TemplateResult } from 'lit';
|
|
4
7
|
/**
|
|
5
8
|
* OxDataInputFactory
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import '@operato/input/ox-input-file.js';
|
|
2
2
|
import '@operato/input/ox-input-signature.js';
|
|
3
|
+
import '@operato/input/ox-input-image.js';
|
|
4
|
+
import '@operato/input/ox-input-video.js';
|
|
5
|
+
import '@operato/input/ox-input-audio.js';
|
|
3
6
|
// import '@operato/app/ox-filter-resource-object.js'
|
|
4
7
|
import { html } from 'lit';
|
|
5
8
|
/**
|
|
@@ -32,6 +35,12 @@ export class OxDataInputFactory {
|
|
|
32
35
|
return html `<input type="datetime-local" name=${tag} .value=${value} />`;
|
|
33
36
|
case 'file':
|
|
34
37
|
return html `<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`;
|
|
38
|
+
case 'image':
|
|
39
|
+
return html `<ox-input-image name=${tag} .value=${value}></ox-input-image>`;
|
|
40
|
+
case 'video':
|
|
41
|
+
return html `<ox-input-video name=${tag} .value=${value}></ox-input-video>`;
|
|
42
|
+
case 'audio':
|
|
43
|
+
return html `<ox-input-audio name=${tag} .value=${value}></ox-input-audio>`;
|
|
35
44
|
case 'signature':
|
|
36
45
|
return html `<ox-input-signature name=${tag} .value=${value}></ox-input-signature>`;
|
|
37
46
|
case 'employee':
|
|
@@ -127,6 +136,12 @@ export class OxDataInputFactory {
|
|
|
127
136
|
return 'datetime';
|
|
128
137
|
case 'file':
|
|
129
138
|
return 'file';
|
|
139
|
+
case 'image':
|
|
140
|
+
return 'image';
|
|
141
|
+
case 'video':
|
|
142
|
+
return 'video';
|
|
143
|
+
case 'audio':
|
|
144
|
+
return 'audio';
|
|
130
145
|
case 'signature':
|
|
131
146
|
return 'signature';
|
|
132
147
|
case 'string':
|
|
@@ -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,qDAAqD;AAErD,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AAE1C;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC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AC,oCAAoC;YACtD,KAAK,SAAS;gBACZ,OAAO,SAAS,CAAA;YAClB,KAAK,QAAQ;gBACX,OAAO,QAAQ,CAAA;YACjB,KAAK,MAAM;gBACT,OAAO,MAAM,CAAA;YACf,KAAK,UAAU;gBACb,OAAO,UAAU,CAAA;YACnB,KAAK,MAAM;gBACT,OAAO,MAAM,CAAA;YACf,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'\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 type=\"date\" name=${tag} .value=${value} />`\n case 'datetime':\n return html`<input type=\"datetime-local\" name=${tag} .value=${value} />`\n case 'file':\n return html`<ox-input-file name=${tag} multiple .value=${value}></ox-input-file>`\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 '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,sCAA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AAG,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 type=\"date\" name=${tag} .value=${value} />`\n case 'datetime':\n return html`<input type=\"datetime-local\" name=${tag} .value=${value} />`\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"]}
|