reneco-advanced-input-module 0.0.1-beta.1 → 0.0.1-beta.2
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/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +6 -2
- package/www/build/index.esm.js +2 -0
- package/www/build/index.esm.js.map +1 -0
- package/www/build/loader.esm.js.map +1 -0
- package/www/build/ocr-file-uploader.voice-input-module.entry.esm.js.map +1 -0
- package/www/build/p-52e59129.entry.js +2 -0
- package/www/build/p-52e59129.entry.js.map +1 -0
- package/www/build/p-DQuL1Twl.js +2 -0
- package/www/build/p-DQuL1Twl.js.map +1 -0
- package/www/build/p-jmc2yzBp.js +3 -0
- package/www/build/p-jmc2yzBp.js.map +1 -0
- package/www/build/voice-input-module.esm.js +2 -0
- package/www/build/voice-input-module.esm.js.map +1 -0
- package/www/build/voice-input-module.js +33 -0
- package/www/host.config.json +15 -0
- package/www/index.html +922 -0
- package/.editorconfig +0 -15
- package/.prettierrc.json +0 -13
- package/api-key-inject.js +0 -46
- package/env-config.js +0 -4
- package/inject-env.js +0 -20
- package/src/components/ocr-file-uploader/ocr-file-uploader.css +0 -26
- package/src/components/ocr-file-uploader/ocr-file-uploader.tsx +0 -100
- package/src/components/ocr-file-uploader/readme.md +0 -31
- package/src/components/voice-input-module/readme.md +0 -114
- package/src/components/voice-input-module/voice-input-module.css +0 -286
- package/src/components/voice-input-module/voice-input-module.tsx +0 -778
- package/src/components.d.ts +0 -158
- package/src/index.html +0 -1015
- package/src/index.ts +0 -12
- package/src/services/audio-recorder.service.ts +0 -74
- package/src/services/llm.service.ts +0 -221
- package/src/services/speech-to-text.service.ts +0 -70
- package/src/types/form-schema.types.ts +0 -78
- package/src/types/service-providers.types.ts +0 -22
- package/src/utils/schema-converter.ts +0 -494
- package/stencil.config.ts +0 -24
- package/tsconfig.json +0 -30
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
import { FormSchema, FormField, FormSchemaFieldsOnly, FormSchemaFieldsOnlyExtended, FormFieldExtended } from '../types/form-schema.types';
|
|
2
|
-
|
|
3
|
-
export class SchemaConverter {
|
|
4
|
-
/**
|
|
5
|
-
* Convert XML form definition to JSON schema
|
|
6
|
-
*/
|
|
7
|
-
static convertXmlToJsonLegacy(xmlForm: string): FormSchema {
|
|
8
|
-
try {
|
|
9
|
-
const parser = new DOMParser();
|
|
10
|
-
const xmlDoc = parser.parseFromString(xmlForm, 'text/xml');
|
|
11
|
-
|
|
12
|
-
if (xmlDoc.querySelector('parsererror')) {
|
|
13
|
-
throw new Error('Invalid XML format');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const schema: FormSchema = {
|
|
17
|
-
schema: {}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Extract form title and description
|
|
21
|
-
const formElement = xmlDoc.querySelector('form');
|
|
22
|
-
if (formElement) {
|
|
23
|
-
schema.title = formElement.getAttribute('title') || undefined;
|
|
24
|
-
schema.description = formElement.getAttribute('description') || undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Process input fields
|
|
28
|
-
const inputs = xmlDoc.querySelectorAll('input, select, textarea');
|
|
29
|
-
inputs.forEach(input => {
|
|
30
|
-
const name = input.getAttribute('name');
|
|
31
|
-
if (!name) return;
|
|
32
|
-
|
|
33
|
-
const field: FormField = {
|
|
34
|
-
type: this.mapXmlTypeToJsonTypeLegacy(input.tagName.toLowerCase(), input.getAttribute('type')),
|
|
35
|
-
title: input.getAttribute('title') || input.getAttribute('placeholder') || name,
|
|
36
|
-
description: input.getAttribute('description') || undefined,
|
|
37
|
-
required: input.hasAttribute('required'),
|
|
38
|
-
default: input.getAttribute('value') || undefined
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Handle select options
|
|
42
|
-
if (input.tagName.toLowerCase() === 'select') {
|
|
43
|
-
const options = Array.from(input.querySelectorAll('option')).map(option =>
|
|
44
|
-
option.textContent || option.getAttribute('value') || ''
|
|
45
|
-
);
|
|
46
|
-
if (options.length > 0) {
|
|
47
|
-
field.options = options;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Handle validation attributes
|
|
52
|
-
const min = input.getAttribute('min');
|
|
53
|
-
const max = input.getAttribute('max');
|
|
54
|
-
const pattern = input.getAttribute('pattern');
|
|
55
|
-
|
|
56
|
-
if (min) field.min = parseFloat(min);
|
|
57
|
-
if (max) field.max = parseFloat(max);
|
|
58
|
-
if (pattern) field.pattern = pattern;
|
|
59
|
-
|
|
60
|
-
schema.schema[name] = field;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return schema;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
throw new Error(`XML to JSON conversion failed: ${error.message}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Convert JSON schema to XML form definition
|
|
71
|
-
*/
|
|
72
|
-
static convertJsonToXmlLegacy(jsonForm: FormSchema): string {
|
|
73
|
-
try {
|
|
74
|
-
const doc = document.implementation.createDocument('', '', null);
|
|
75
|
-
const form = doc.createElement('form');
|
|
76
|
-
|
|
77
|
-
if (jsonForm.title) {
|
|
78
|
-
form.setAttribute('title', jsonForm.title);
|
|
79
|
-
}
|
|
80
|
-
if (jsonForm.description) {
|
|
81
|
-
form.setAttribute('description', jsonForm.description);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
Object.entries(jsonForm.schema).forEach(([fieldName, field]) => {
|
|
85
|
-
// Inject default value from root if present
|
|
86
|
-
const valueFromRoot = (jsonForm as any)[fieldName];
|
|
87
|
-
const fieldWithDefault = {
|
|
88
|
-
...field,
|
|
89
|
-
default: field.default ?? valueFromRoot // field.default has priority
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const element = this.createXmlElementLegacy(doc, fieldName, fieldWithDefault);
|
|
93
|
-
if (element) {
|
|
94
|
-
form.appendChild(element);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
doc.appendChild(form);
|
|
99
|
-
|
|
100
|
-
const serializer = new XMLSerializer();
|
|
101
|
-
return serializer.serializeToString(doc);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
throw new Error(`JSON to XML conversion failed: ${error.message}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private static mapXmlTypeToJsonTypeLegacy(tagName: string, type: string | null): FormField['type'] {
|
|
108
|
-
switch (tagName) {
|
|
109
|
-
case 'select':
|
|
110
|
-
return 'select';
|
|
111
|
-
case 'textarea':
|
|
112
|
-
return 'string';
|
|
113
|
-
case 'input':
|
|
114
|
-
switch (type) {
|
|
115
|
-
case 'number':
|
|
116
|
-
case 'range':
|
|
117
|
-
return 'number';
|
|
118
|
-
case 'date':
|
|
119
|
-
case 'datetime-local':
|
|
120
|
-
case 'time':
|
|
121
|
-
return 'date';
|
|
122
|
-
case 'checkbox':
|
|
123
|
-
return 'boolean';
|
|
124
|
-
default:
|
|
125
|
-
return 'string';
|
|
126
|
-
}
|
|
127
|
-
default:
|
|
128
|
-
return 'string';
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private static createXmlElementLegacy(doc: Document, fieldName: string, field: FormField): Element | null {
|
|
133
|
-
let element: Element;
|
|
134
|
-
|
|
135
|
-
switch (field.type) {
|
|
136
|
-
case 'select':
|
|
137
|
-
element = doc.createElement('select');
|
|
138
|
-
if (field.options) {
|
|
139
|
-
field.options.forEach(option => {
|
|
140
|
-
const optionElement = doc.createElement('option');
|
|
141
|
-
optionElement.setAttribute('value', option);
|
|
142
|
-
optionElement.textContent = option;
|
|
143
|
-
// Set selected if it matches the default value
|
|
144
|
-
if (field.default !== undefined && field.default === option) {
|
|
145
|
-
optionElement.setAttribute('selected', 'true');
|
|
146
|
-
}
|
|
147
|
-
element.appendChild(optionElement);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
151
|
-
|
|
152
|
-
case 'boolean':
|
|
153
|
-
element = doc.createElement('input');
|
|
154
|
-
element.setAttribute('type', 'checkbox');
|
|
155
|
-
if (field.default === true || field.default === 'true') {
|
|
156
|
-
element.setAttribute('checked', 'true');
|
|
157
|
-
}
|
|
158
|
-
break;
|
|
159
|
-
|
|
160
|
-
case 'number':
|
|
161
|
-
element = doc.createElement('input');
|
|
162
|
-
element.setAttribute('type', 'number');
|
|
163
|
-
if (field.min !== undefined) element.setAttribute('min', field.min.toString());
|
|
164
|
-
if (field.max !== undefined) element.setAttribute('max', field.max.toString());
|
|
165
|
-
if (field.default !== undefined) element.setAttribute('value', field.default.toString());
|
|
166
|
-
break;
|
|
167
|
-
|
|
168
|
-
case 'date':
|
|
169
|
-
element = doc.createElement('input');
|
|
170
|
-
element.setAttribute('type', 'date');
|
|
171
|
-
if (field.default !== undefined) element.setAttribute('value', field.default.toString());
|
|
172
|
-
break;
|
|
173
|
-
|
|
174
|
-
default: // string, text, etc.
|
|
175
|
-
element = doc.createElement('input');
|
|
176
|
-
element.setAttribute('type', 'text');
|
|
177
|
-
if (field.default !== undefined) element.setAttribute('value', field.default.toString());
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
element.setAttribute('name', fieldName);
|
|
181
|
-
element.setAttribute('title', field.title);
|
|
182
|
-
|
|
183
|
-
if (field.description) {
|
|
184
|
-
element.setAttribute('description', field.description);
|
|
185
|
-
}
|
|
186
|
-
if (field.required) {
|
|
187
|
-
element.setAttribute('required', 'true');
|
|
188
|
-
}
|
|
189
|
-
if (field.pattern) {
|
|
190
|
-
element.setAttribute('pattern', field.pattern);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return element;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Convert new XML form definition to JSON schema
|
|
199
|
-
*/
|
|
200
|
-
static async convertXmlToJson(xmlForm: string, classificationRootURL: string = "http://localhost", lang: 'fr'|'en' = 'en'): Promise<FormSchemaFieldsOnly> {
|
|
201
|
-
try {
|
|
202
|
-
const parser = new DOMParser();
|
|
203
|
-
const xmlDoc = parser.parseFromString(xmlForm, 'text/xml');
|
|
204
|
-
|
|
205
|
-
if (xmlDoc.querySelector('parsererror')) {
|
|
206
|
-
throw new Error('Invalid XML format');
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Root Xforms element (optional)
|
|
210
|
-
const xforms = xmlDoc.querySelector('Xforms');
|
|
211
|
-
if (!xforms) throw new Error('No Xforms root element found');
|
|
212
|
-
|
|
213
|
-
const fields = xforms.querySelectorAll('Fields');
|
|
214
|
-
if (fields.length === 0) throw new Error('No Fields elements found');
|
|
215
|
-
|
|
216
|
-
const schema: FormSchemaFieldsOnly = {
|
|
217
|
-
fields: {}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
for (const fieldEl of Array.from(fields)) {
|
|
221
|
-
// Read key info
|
|
222
|
-
const name = fieldEl.querySelector('SystemName')?.textContent?.trim();
|
|
223
|
-
if (!name) return;
|
|
224
|
-
|
|
225
|
-
const helpText = fieldEl.querySelector('HelpText')?.textContent?.trim();
|
|
226
|
-
const defaultValue = fieldEl.querySelector('DefaultValue')?.textContent;
|
|
227
|
-
const enabledText = fieldEl.querySelector('Enabled')?.textContent?.trim().toLowerCase() || 'true';
|
|
228
|
-
const isEnabled = enabledText === 'true';
|
|
229
|
-
|
|
230
|
-
// keep as memory
|
|
231
|
-
const field_ID = fieldEl.querySelector('ID')?.textContent;
|
|
232
|
-
const field_TFie_PK_ID = fieldEl.querySelector('TFie_PK_ID')?.textContent;
|
|
233
|
-
const field_TVal_PK_ID = fieldEl.querySelector('TVal_PK_ID')?.textContent;
|
|
234
|
-
const field_TFIn_PK_ID = fieldEl.querySelector('TFIn_PK_ID')?.textContent;
|
|
235
|
-
const field_isForm = fieldEl.querySelector('isForm')?.textContent;
|
|
236
|
-
const field_LabelText = fieldEl.querySelector('LabelText')?.textContent;
|
|
237
|
-
const field_SystemName = fieldEl.querySelector('SystemName')?.textContent;
|
|
238
|
-
const field_CssStyle = fieldEl.querySelector('CssStyle')?.textContent;
|
|
239
|
-
const field_ControlType = fieldEl.querySelector('ControlType')?.textContent || 'TextBox';
|
|
240
|
-
const field_ValidationRequired = fieldEl.querySelector('ValidationRequired')?.textContent;
|
|
241
|
-
const field_ValidationMin = fieldEl.querySelector('ValidationMin')?.textContent;
|
|
242
|
-
const field_ValidationMax = fieldEl.querySelector('ValidationMax')?.textContent;
|
|
243
|
-
const field_Mask = fieldEl.querySelector('Mask')?.textContent;
|
|
244
|
-
const field_TypeId = fieldEl.querySelector('TypeId')?.textContent;
|
|
245
|
-
const field_Unit = fieldEl.querySelector('Unit')?.textContent;
|
|
246
|
-
const field_TFie_Fullpath = fieldEl.querySelector('TFie_Fullpath')?.textContent;
|
|
247
|
-
const field_TVal_FK_Parent_ID = fieldEl.querySelector('TVal_FK_Parent_ID')?.textContent;
|
|
248
|
-
|
|
249
|
-
const field: FormFieldExtended = {
|
|
250
|
-
type: this.mapControlTypeToJsonType(field_ControlType),
|
|
251
|
-
title: field_LabelText,
|
|
252
|
-
description: helpText,
|
|
253
|
-
required: field_ValidationRequired?.toLowerCase() === 'required',
|
|
254
|
-
default: defaultValue || undefined,
|
|
255
|
-
|
|
256
|
-
realType: field_ControlType,
|
|
257
|
-
|
|
258
|
-
Enabled: isEnabled,
|
|
259
|
-
ID: field_ID,
|
|
260
|
-
TFie_PK_ID: field_TFie_PK_ID,
|
|
261
|
-
TVal_PK_ID: field_TVal_PK_ID,
|
|
262
|
-
TFIn_PK_ID: field_TFIn_PK_ID,
|
|
263
|
-
isForm: field_isForm,
|
|
264
|
-
LabelText: field_LabelText,
|
|
265
|
-
SystemName: field_SystemName,
|
|
266
|
-
CssStyle: field_CssStyle,
|
|
267
|
-
ControlType: field_ControlType,
|
|
268
|
-
ValidationRequired: field_ValidationRequired,
|
|
269
|
-
ValidationMin: field_ValidationMin,
|
|
270
|
-
ValidationMax: field_ValidationMax,
|
|
271
|
-
Mask: field_Mask,
|
|
272
|
-
TypeId: field_TypeId,
|
|
273
|
-
Unit: field_Unit,
|
|
274
|
-
TFie_Fullpath: field_TFie_Fullpath,
|
|
275
|
-
TVal_FK_Parent_ID: field_TVal_FK_Parent_ID
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
// Handle select options
|
|
279
|
-
if (field.type.toLowerCase() === 'select') {
|
|
280
|
-
try {
|
|
281
|
-
const response = await fetch(`${classificationRootURL}/ng/api/v1/classification/getList/${field.ControlType.toLowerCase() == 'termpicker' ? "Position" : "Thesaurus"}/?StartNodeID=${field_TypeId}`);
|
|
282
|
-
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
|
283
|
-
|
|
284
|
-
const data = await response.json();
|
|
285
|
-
if (Array.isArray(data)) {
|
|
286
|
-
const options = data.map(item => ({
|
|
287
|
-
value: item.ID,
|
|
288
|
-
label: item.System_Name
|
|
289
|
-
}));
|
|
290
|
-
if (options.length > 0) {
|
|
291
|
-
field.pickerOptions = options;
|
|
292
|
-
// TODO on degage les quotes simples temporairement, a corriger
|
|
293
|
-
field.options = options.map(option => option.label.replace("'", ""));
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
console.error("Unexpected API response format:", data);
|
|
297
|
-
}
|
|
298
|
-
} catch (error) {
|
|
299
|
-
console.error("Error fetching classification data:", error);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (field_ValidationMin) field.min = parseFloat(field_ValidationMin);
|
|
304
|
-
if (field_ValidationMax) field.max = parseFloat(field_ValidationMax);
|
|
305
|
-
if (field_Mask) field.pattern = field_Mask;
|
|
306
|
-
|
|
307
|
-
// Optional: Add any other fields you want to track, e.g. min, max, pattern (not clearly in your XML)
|
|
308
|
-
// You could also add the raw ControlType for round-trip fidelity if you want
|
|
309
|
-
|
|
310
|
-
schema.fields[field_ID] = field;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
return schema;
|
|
314
|
-
} catch (error) {
|
|
315
|
-
throw new Error(`XML to JSON conversion failed: ${error.message}`);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Convert JSON schema back to your new XML form definition format
|
|
321
|
-
*/
|
|
322
|
-
static convertJsonToXml(jsonForm: FormSchemaFieldsOnlyExtended): string {
|
|
323
|
-
try {
|
|
324
|
-
const doc = document.implementation.createDocument('', '', null);
|
|
325
|
-
const xforms = doc.createElement('Xforms');
|
|
326
|
-
|
|
327
|
-
Object.entries(( (jsonForm as any).schema ? (jsonForm as any).schema : (jsonForm as any).fields )).forEach(([fieldID, field]) => {
|
|
328
|
-
const fieldEl = doc.createElement('Fields');
|
|
329
|
-
const fieldToUse = (field as FormFieldExtended);
|
|
330
|
-
|
|
331
|
-
// Set all subelements based on your XML structure
|
|
332
|
-
// ID, PK IDs etc are missing here, so omit or generate dummy
|
|
333
|
-
|
|
334
|
-
// <SystemName>
|
|
335
|
-
const systemNameEl = doc.createElement('SystemName');
|
|
336
|
-
systemNameEl.textContent = fieldToUse.SystemName;
|
|
337
|
-
fieldEl.appendChild(systemNameEl);
|
|
338
|
-
|
|
339
|
-
// <LabelText>
|
|
340
|
-
const labelEl = doc.createElement('LabelText');
|
|
341
|
-
labelEl.textContent = fieldToUse.title || fieldID;
|
|
342
|
-
fieldEl.appendChild(labelEl);
|
|
343
|
-
|
|
344
|
-
// <HelpText>
|
|
345
|
-
const helpEl = doc.createElement('HelpText');
|
|
346
|
-
helpEl.textContent = fieldToUse.description;
|
|
347
|
-
fieldEl.appendChild(helpEl);
|
|
348
|
-
|
|
349
|
-
// <ControlType>
|
|
350
|
-
const controlTypeEl = doc.createElement('ControlType');
|
|
351
|
-
controlTypeEl.textContent = fieldToUse.realType;
|
|
352
|
-
fieldEl.appendChild(controlTypeEl);
|
|
353
|
-
|
|
354
|
-
// <ValidationRequired>
|
|
355
|
-
const validationEl = doc.createElement('ValidationRequired');
|
|
356
|
-
validationEl.textContent = fieldToUse.required ? 'Required' : 'Not Required';
|
|
357
|
-
fieldEl.appendChild(validationEl);
|
|
358
|
-
|
|
359
|
-
// <DefaultValue>
|
|
360
|
-
const defaultEl = doc.createElement('DefaultValue');
|
|
361
|
-
const valueEl = doc.createElement('Value');
|
|
362
|
-
if (jsonForm[fieldID] !== undefined) {
|
|
363
|
-
defaultEl.textContent = jsonForm[fieldID].toString();
|
|
364
|
-
valueEl.textContent = jsonForm[fieldID].toString();
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
defaultEl.textContent = fieldToUse.default || fieldToUse.value;
|
|
368
|
-
valueEl.textContent = fieldToUse.value || fieldToUse.default;
|
|
369
|
-
}
|
|
370
|
-
fieldEl.appendChild(defaultEl);
|
|
371
|
-
fieldEl.appendChild(valueEl);
|
|
372
|
-
|
|
373
|
-
// <Enabled>
|
|
374
|
-
const enabledEl = doc.createElement('Enabled');
|
|
375
|
-
enabledEl.textContent = fieldToUse.Enabled === false ? 'False' : 'True';
|
|
376
|
-
fieldEl.appendChild(enabledEl);
|
|
377
|
-
|
|
378
|
-
// Add <isForm> Field to distinguish Field or Header etc
|
|
379
|
-
const isFormEl = doc.createElement('isForm');
|
|
380
|
-
isFormEl.textContent = fieldToUse.isForm;
|
|
381
|
-
fieldEl.appendChild(isFormEl);
|
|
382
|
-
|
|
383
|
-
if (fieldToUse.type === 'header') {
|
|
384
|
-
const headerEl = doc.createElement('Header');
|
|
385
|
-
headerEl.textContent = fieldToUse.title;
|
|
386
|
-
fieldEl.appendChild(headerEl);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const idEl = doc.createElement('ID');
|
|
390
|
-
idEl.textContent = fieldToUse.ID;
|
|
391
|
-
fieldEl.appendChild(idEl);
|
|
392
|
-
|
|
393
|
-
const tfiePkIdEl = doc.createElement('TFie_PK_ID');
|
|
394
|
-
tfiePkIdEl.textContent = fieldToUse.TFie_PK_ID;
|
|
395
|
-
fieldEl.appendChild(tfiePkIdEl);
|
|
396
|
-
|
|
397
|
-
const tvalPkIdEl = doc.createElement('TVal_PK_ID');
|
|
398
|
-
tvalPkIdEl.textContent = fieldToUse.TVal_PK_ID;
|
|
399
|
-
fieldEl.appendChild(tvalPkIdEl);
|
|
400
|
-
|
|
401
|
-
const tfInPkIdEl = doc.createElement('TFIn_PK_ID');
|
|
402
|
-
tfInPkIdEl.textContent = fieldToUse.TFIn_PK_ID;
|
|
403
|
-
fieldEl.appendChild(tfInPkIdEl);
|
|
404
|
-
|
|
405
|
-
const cssStyleEl = doc.createElement('CssStyle');
|
|
406
|
-
cssStyleEl.textContent = fieldToUse.CssStyle;
|
|
407
|
-
fieldEl.appendChild(cssStyleEl);
|
|
408
|
-
|
|
409
|
-
const typeIdEl = doc.createElement('TypeId');
|
|
410
|
-
typeIdEl.textContent = fieldToUse.TypeId;
|
|
411
|
-
fieldEl.appendChild(typeIdEl);
|
|
412
|
-
|
|
413
|
-
const unitEl = doc.createElement('Unit');
|
|
414
|
-
unitEl.textContent = fieldToUse.Unit;
|
|
415
|
-
fieldEl.appendChild(unitEl);
|
|
416
|
-
|
|
417
|
-
const tfieFullPathEl = doc.createElement('TFie_Fullpath');
|
|
418
|
-
tfieFullPathEl.textContent = fieldToUse.TFie_Fullpath;
|
|
419
|
-
fieldEl.appendChild(tfieFullPathEl);
|
|
420
|
-
|
|
421
|
-
const tvalFkParentIdEl = doc.createElement('TVal_FK_Parent_ID');
|
|
422
|
-
tvalFkParentIdEl.textContent = fieldToUse.TVal_FK_Parent_ID;
|
|
423
|
-
fieldEl.appendChild(tvalFkParentIdEl);
|
|
424
|
-
|
|
425
|
-
const validationMinEl = doc.createElement('ValidationMin');
|
|
426
|
-
validationMinEl.textContent = fieldToUse.ValidationMin;
|
|
427
|
-
fieldEl.appendChild(validationMinEl);
|
|
428
|
-
|
|
429
|
-
const validationMaxEl = doc.createElement('ValidationMax');
|
|
430
|
-
validationMaxEl.textContent = fieldToUse.ValidationMax;
|
|
431
|
-
fieldEl.appendChild(validationMaxEl);
|
|
432
|
-
|
|
433
|
-
const maskEl = doc.createElement('Mask');
|
|
434
|
-
maskEl.textContent = fieldToUse.Mask;
|
|
435
|
-
fieldEl.appendChild(maskEl);
|
|
436
|
-
|
|
437
|
-
// Append to Xforms root
|
|
438
|
-
xforms.appendChild(fieldEl);
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
doc.appendChild(xforms);
|
|
442
|
-
|
|
443
|
-
const serializer = new XMLSerializer();
|
|
444
|
-
return serializer.serializeToString(doc);
|
|
445
|
-
} catch (error) {
|
|
446
|
-
throw new Error(`JSON to XML conversion failed: ${error.message}`);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private static mapControlTypeToJsonType(controlType: string): FormField['type'] {
|
|
451
|
-
// Map your ControlType XML field to JSON field types
|
|
452
|
-
switch (controlType.toLowerCase()) {
|
|
453
|
-
case 'textbox':
|
|
454
|
-
case 'text':
|
|
455
|
-
return 'string';
|
|
456
|
-
case 'datepicker':
|
|
457
|
-
return 'date';
|
|
458
|
-
case 'thesauruspicker':
|
|
459
|
-
case 'thesauruspicker-ddl':
|
|
460
|
-
case 'termpicker':
|
|
461
|
-
return 'select';
|
|
462
|
-
case 'dbpicker':
|
|
463
|
-
return 'dbpicker'; // custom type if needed
|
|
464
|
-
case 'header':
|
|
465
|
-
return 'header'; // special type to handle header elements
|
|
466
|
-
case 'checkbox':
|
|
467
|
-
return 'boolean';
|
|
468
|
-
case 'realpicker':
|
|
469
|
-
return 'number';
|
|
470
|
-
default:
|
|
471
|
-
return 'string';
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// private static mapJsonTypeToControlType(type: string): string {
|
|
476
|
-
// switch (type.toLowerCase()) {
|
|
477
|
-
// case 'string':
|
|
478
|
-
// return 'TextBox';
|
|
479
|
-
// case 'date':
|
|
480
|
-
// return 'DatePicker';
|
|
481
|
-
// case 'select':
|
|
482
|
-
// return 'ThesaurusPicker';
|
|
483
|
-
// case 'dbpicker':
|
|
484
|
-
// return 'DBPicker';
|
|
485
|
-
// case 'boolean':
|
|
486
|
-
// return 'CheckBox';
|
|
487
|
-
// case 'header':
|
|
488
|
-
// return 'Header';
|
|
489
|
-
// default:
|
|
490
|
-
// return 'TextBox';
|
|
491
|
-
// }
|
|
492
|
-
// }
|
|
493
|
-
|
|
494
|
-
}
|
package/stencil.config.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Config } from '@stencil/core';
|
|
2
|
-
|
|
3
|
-
export const config: Config = {
|
|
4
|
-
namespace: 'voice-input-module',
|
|
5
|
-
outputTargets: [
|
|
6
|
-
{
|
|
7
|
-
type: 'dist',
|
|
8
|
-
esmLoaderPath: '../loader',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
type: 'dist-custom-elements',
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
type: 'docs-readme',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: 'www',
|
|
18
|
-
serviceWorker: null,
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
testing: {
|
|
22
|
-
browserHeadless: "shell",
|
|
23
|
-
},
|
|
24
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowSyntheticDefaultImports": true,
|
|
4
|
-
"allowUnreachableCode": false,
|
|
5
|
-
"declaration": false,
|
|
6
|
-
"experimentalDecorators": true,
|
|
7
|
-
"emitDecoratorMetadata": true,
|
|
8
|
-
"lib": [
|
|
9
|
-
"dom",
|
|
10
|
-
"es6",
|
|
11
|
-
"es2017"
|
|
12
|
-
],
|
|
13
|
-
"moduleResolution": "node",
|
|
14
|
-
"module": "esnext",
|
|
15
|
-
"target": "es2017",
|
|
16
|
-
"noUnusedLocals": false,
|
|
17
|
-
"noUnusedParameters": false,
|
|
18
|
-
"jsx": "react",
|
|
19
|
-
"jsxFactory": "h",
|
|
20
|
-
"strict": false,
|
|
21
|
-
"noImplicitAny": false
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"src",
|
|
25
|
-
"types/jsx.d.ts"
|
|
26
|
-
],
|
|
27
|
-
"exclude": [
|
|
28
|
-
"node_modules"
|
|
29
|
-
]
|
|
30
|
-
}
|