@icure/form 3.0.45 → 3.1.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.
Files changed (68) hide show
  1. package/.yarn/cache/{@babel-runtime-npm-7.28.4-31bc1b0001-934b0a0460.zip → @babel-runtime-npm-7.28.6-f40c99aeef-42d8a868c2.zip} +0 -0
  2. package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.5.1-3b3c832bd1-22c404c481.zip +0 -0
  3. package/.yarn/cache/@lit-reactive-element-npm-2.1.2-2c713bebce-e0ed931b9c.zip +0 -0
  4. package/.yarn/cache/{lit-element-npm-4.2.1-b5bc114ced-5925326176.zip → lit-element-npm-4.2.2-70d4af2233-554254b87c.zip} +0 -0
  5. package/.yarn/cache/lit-html-npm-3.3.2-4a3e00215f-7fe23502ca.zip +0 -0
  6. package/.yarn/cache/{lit-npm-3.3.1-8f683c51f1-fb88f1ff80.zip → lit-npm-3.3.2-7dea58471e-2136d4beac.zip} +0 -0
  7. package/.yarn/cache/prosemirror-markdown-npm-1.13.4-1a47b172bd-3306b4eca0.zip +0 -0
  8. package/.yarn/cache/prosemirror-transform-npm-1.11.0-fa260ad6f3-71989931b8.zip +0 -0
  9. package/.yarn/cache/prosemirror-view-npm-1.41.6-a9d2feed27-68f6a8bd66.zip +0 -0
  10. package/.yarn/install-state.gz +0 -0
  11. package/components/common/field.d.ts +14 -2
  12. package/components/common/field.js +95 -2
  13. package/components/common/field.js.map +1 -1
  14. package/components/common/utils.js +11 -1
  15. package/components/common/utils.js.map +1 -1
  16. package/components/icure-form/fields/button-group/checkbox.js +3 -4
  17. package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
  18. package/components/icure-form/fields/button-group/radio-button.js +3 -4
  19. package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
  20. package/components/icure-form/fields/date-picker/date-picker.js +3 -4
  21. package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
  22. package/components/icure-form/fields/date-picker/date-time-picker.js +3 -4
  23. package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
  24. package/components/icure-form/fields/date-picker/time-picker.js +3 -4
  25. package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
  26. package/components/icure-form/fields/dropdown/dropdown-field.js +3 -4
  27. package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
  28. package/components/icure-form/fields/measure-field/measure-field.js +3 -4
  29. package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
  30. package/components/icure-form/fields/number-field/number-field.js +3 -4
  31. package/components/icure-form/fields/number-field/number-field.js.map +1 -1
  32. package/components/icure-form/fields/text-field/text-field.js +3 -4
  33. package/components/icure-form/fields/text-field/text-field.js.map +1 -1
  34. package/components/icure-form/fields/utils/index.d.ts +0 -5
  35. package/components/icure-form/fields/utils/index.js +0 -8
  36. package/components/icure-form/fields/utils/index.js.map +1 -1
  37. package/components/icure-form/index.js +0 -1
  38. package/components/icure-form/index.js.map +1 -1
  39. package/components/icure-form/renderer/form/form.js +4 -4
  40. package/components/icure-form/renderer/form/form.js.map +1 -1
  41. package/components/icure-text-field/index.d.ts +3 -0
  42. package/components/icure-text-field/index.js +65 -13
  43. package/components/icure-text-field/index.js.map +1 -1
  44. package/components/icure-text-field/schema/measure-schema.js +0 -1
  45. package/components/icure-text-field/schema/measure-schema.js.map +1 -1
  46. package/components/model/index.d.ts +16 -16
  47. package/components/model/index.js +34 -30
  48. package/components/model/index.js.map +1 -1
  49. package/conversion/icure-convert.d.ts +3 -0
  50. package/conversion/icure-convert.js +161 -0
  51. package/conversion/icure-convert.js.map +1 -0
  52. package/generic/model.d.ts +11 -6
  53. package/generic/model.js.map +1 -1
  54. package/icure/form-values-container.d.ts +23 -18
  55. package/icure/form-values-container.js +208 -99
  56. package/icure/form-values-container.js.map +1 -1
  57. package/icure/icure-utils.js +47 -17
  58. package/icure/icure-utils.js.map +1 -1
  59. package/package.json +1 -1
  60. package/utils/fields-values-provider.d.ts +1 -1
  61. package/utils/fields-values-provider.js +6 -4
  62. package/utils/fields-values-provider.js.map +1 -1
  63. package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.4.0-e5ef5fbeba-e267c25576.zip +0 -0
  64. package/.yarn/cache/@lit-reactive-element-npm-2.1.1-3875228c32-b9bbc9c089.zip +0 -0
  65. package/.yarn/cache/lit-html-npm-3.3.1-e3722d4f4a-de07c66945.zip +0 -0
  66. package/.yarn/cache/prosemirror-markdown-npm-1.13.2-6e2f179fd8-ce9fcb3b13.zip +0 -0
  67. package/.yarn/cache/prosemirror-transform-npm-1.10.5-5b3b4f5f61-6f5921e53a.zip +0 -0
  68. package/.yarn/cache/prosemirror-view-npm-1.41.4-cf361fd330-b663b8c6ce.zip +0 -0
@@ -0,0 +1,3 @@
1
+ import { FormLayout } from '@icure/api';
2
+ import { Form } from '../components/model';
3
+ export declare function convertLegacy(form: FormLayout, formsLibrary: FormLayout[]): Form;
@@ -0,0 +1,161 @@
1
+ import { Button, CheckBox, DatePicker, DateTimePicker, DropdownField, Form, ItemsListField, MeasureField, NumberField, Section, Subform, TextField, TokenField, } from '../components/model';
2
+ import { cluster } from './ckmeans-grouping';
3
+ export function convertLegacy(form, formsLibrary) {
4
+ var _a, _b;
5
+ const TOTAL_COLUMNS = 24;
6
+ const makeTextField = (formData, width, height) => { var _a; return new TextField((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
7
+ const makeItemsListField = (formData, width, height) => { var _a; return new ItemsListField((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
8
+ const makeTokenField = (formData, width, height) => { var _a; return new TokenField((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
9
+ const makeCheckBox = (formData, width, height) => { var _a, _b; return new CheckBox((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, options: { [(_b = formData.label) !== null && _b !== void 0 ? _b : '']: formData.label }, span: width, rowSpan: height > 1 ? height : undefined }); };
10
+ const makeMeasureField = (formData, width, height) => { var _a; return new MeasureField((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
11
+ const makeNumberField = (formData, width, height) => { var _a; return new NumberField((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
12
+ const makeDateTimeField = (formData, width, height) => {
13
+ var _a, _b, _c;
14
+ return ((_a = formData.editor) === null || _a === void 0 ? void 0 : _a.displayTime)
15
+ ? new DateTimePicker((_b = formData.name) !== null && _b !== void 0 ? _b : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })
16
+ : new DatePicker((_c = formData.name) !== null && _c !== void 0 ? _c : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined });
17
+ };
18
+ const makeDropdownField = (formData, width, height) => {
19
+ var _a, _b, _c;
20
+ return new DropdownField((_a = formData.name) !== null && _a !== void 0 ? _a : '', {
21
+ shortLabel: formData.label,
22
+ span: width,
23
+ options: ((_b = formData.editor) === null || _b === void 0 ? void 0 : _b.menuOptions)
24
+ ? (_c = formData.editor) === null || _c === void 0 ? void 0 : _c.menuOptions.reduce((acc, v) => (Object.assign(Object.assign({}, acc), { [`LEGACY|${v}|1`]: v })), {})
25
+ : undefined,
26
+ });
27
+ };
28
+ const makeSubForm = (formData, width, height) => {
29
+ var _a, _b, _c;
30
+ const subForms = (_b = (_a = formData.editor) === null || _a === void 0 ? void 0 : _a.optionalFormGuids) === null || _b === void 0 ? void 0 : _b.map((guid) => {
31
+ const subForm = formsLibrary.find((it) => it.guid === guid);
32
+ if (!subForm) {
33
+ throw new Error(`Cannot find subform ${guid}`);
34
+ }
35
+ return convertLegacy(subForm, formsLibrary);
36
+ });
37
+ return new Subform((_c = formData.name) !== null && _c !== void 0 ? _c : '', subForms.reduce((acc, sf) => (Object.assign(Object.assign({}, acc), { [sf.form]: sf })), {}), {
38
+ shortLabel: formData.label,
39
+ span: width,
40
+ rowSpan: height,
41
+ });
42
+ };
43
+ const makeActionButton = (formData, width, height) => { var _a; return new Button((_a = formData.name) !== null && _a !== void 0 ? _a : '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined }); };
44
+ // noinspection UnnecessaryLocalVariableJS
45
+ const translated = new Form((_a = (form.group ? `${form.group}/${form.name}` : form.name)) !== null && _a !== void 0 ? _a : 'Unknown', ((_b = form.sections) !== null && _b !== void 0 ? _b : []).map((section) => {
46
+ var _a, _b, _c, _d, _e, _f, _g;
47
+ const fld = ((_a = section.formColumns) !== null && _a !== void 0 ? _a : []).flatMap((column) => { var _a; return (_a = column.formDataList) !== null && _a !== void 0 ? _a : []; });
48
+ const sortedList = fld.sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = a.editor) === null || _a === void 0 ? void 0 : _a.top) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = b.editor) === null || _c === void 0 ? void 0 : _c.top) !== null && _d !== void 0 ? _d : 0); });
49
+ const rowClusters = cluster(fld.map((f) => { var _a, _b; return (_b = (_a = f.editor) === null || _a === void 0 ? void 0 : _a.top) !== null && _b !== void 0 ? _b : 0; }), 5, 16);
50
+ const rows = rowClusters.clusters;
51
+ const intraCentroids = rowClusters.centroids.map((v, idx, centroids) => (idx > 0 ? v - centroids[idx - 1] : 0)).filter((x) => x > 0);
52
+ const meanHeightWithOutliers = intraCentroids.reduce((sum, v) => v + sum, 0) / intraCentroids.length;
53
+ const intraCentroidsWithoutOutliers = intraCentroids.filter((x) => x < meanHeightWithOutliers * 2);
54
+ const meanHeight = intraCentroidsWithoutOutliers.reduce((sum, v) => v + sum, 0) / intraCentroidsWithoutOutliers.length;
55
+ const formDataClusters = sortedList
56
+ .reduce((cs, fd) => {
57
+ cs[rows.findIndex((c) => { var _a, _b; return c.includes((_b = (_a = fd.editor) === null || _a === void 0 ? void 0 : _a.top) !== null && _b !== void 0 ? _b : 0); })].push(fd);
58
+ return cs;
59
+ }, new Array(rows.length).fill(null).map(() => []))
60
+ .map((c) => c.sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = a.editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = b.editor) === null || _c === void 0 ? void 0 : _c.left) !== null && _d !== void 0 ? _d : 0); }));
61
+ const leftMostField = sortedList.filter((f) => !f.subForm).reduce((a, b) => { var _a, _b, _c, _d; return (((_b = (_a = a.editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) < ((_d = (_c = b.editor) === null || _c === void 0 ? void 0 : _c.left) !== null && _d !== void 0 ? _d : 0) ? a : b); });
62
+ const rightMostField = sortedList
63
+ .filter((f) => !f.subForm)
64
+ .reduce((a, b) => { var _a, _b, _c, _d, _e, _f, _g, _h; return (((_b = (_a = a.editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = a.editor) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 0) < ((_f = (_e = b.editor) === null || _e === void 0 ? void 0 : _e.left) !== null && _f !== void 0 ? _f : 0) + ((_h = (_g = b.editor) === null || _g === void 0 ? void 0 : _g.width) !== null && _h !== void 0 ? _h : 0) ? b : a); });
65
+ const leftSide = (_c = (_b = leftMostField.editor) === null || _b === void 0 ? void 0 : _b.left) !== null && _c !== void 0 ? _c : 0;
66
+ const formWidth = ((_e = (_d = rightMostField === null || rightMostField === void 0 ? void 0 : rightMostField.editor) === null || _d === void 0 ? void 0 : _d.left) !== null && _e !== void 0 ? _e : 0) + ((_g = (_f = rightMostField === null || rightMostField === void 0 ? void 0 : rightMostField.editor) === null || _f === void 0 ? void 0 : _f.width) !== null && _g !== void 0 ? _g : 1024) - leftSide;
67
+ const interColumnsDistance = formWidth / TOTAL_COLUMNS;
68
+ const columns = cluster(fld.map((f) => { var _a, _b, _c, _d; return ((_b = (_a = f.editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = f.editor) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 0) - leftSide; }), formWidth / (TOTAL_COLUMNS * 2), Math.ceil((formWidth !== null && formWidth !== void 0 ? formWidth : 1024) / (TOTAL_COLUMNS * 4)), Math.max(Math.min(TOTAL_COLUMNS, fld.length / 2), 1));
69
+ const columnsWidth = columns.centroids.map((v, idx, t) => { var _a; return v - ((_a = t[idx - 1]) !== null && _a !== void 0 ? _a : 0); });
70
+ const acc = columnsWidth.map(() => 1);
71
+ while (acc.reduce((s, v) => s + v, 0) < TOTAL_COLUMNS) {
72
+ const idx = acc.reduce((s, size, idx) => {
73
+ const diff = size * interColumnsDistance - columnsWidth[idx];
74
+ return diff < 0 && -diff > s[1] ? [idx, -diff] : s;
75
+ }, [undefined, 0]);
76
+ const selected = idx[0];
77
+ if (selected === undefined) {
78
+ break;
79
+ }
80
+ acc[selected]++;
81
+ }
82
+ // noinspection UnnecessaryLocalVariableJS
83
+ const columnsRoundedWidth = acc;
84
+ const columnsAccumulatedWidth = columnsRoundedWidth.reduce((acc, v) => { var _a; return [...acc, ((_a = acc[acc.length - 1]) !== null && _a !== void 0 ? _a : 0) + v]; }, []);
85
+ const columnsAccumulatedWidthWithInterColumns = columnsAccumulatedWidth.map((v) => v * interColumnsDistance);
86
+ return new Section('Main', formDataClusters.flatMap((formDataRow) => {
87
+ const cols = formDataRow
88
+ .map((formData) => {
89
+ return columnsAccumulatedWidth[columnsAccumulatedWidthWithInterColumns.reduce(([idx, min], x, n) => {
90
+ var _a, _b, _c, _d;
91
+ const right = ((_b = (_a = formData.editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = formData.editor) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 0) - leftSide;
92
+ return Math.abs(x - right) < min ? [n, Math.abs(x - right)] : [idx, min];
93
+ }, [0, 99999])[0]];
94
+ })
95
+ .map((x, idx, cols) => {
96
+ var _a, _b;
97
+ //Try to solve inverted positions in columns by adding or removing one column
98
+ const prev = (_a = cols[idx - 1]) !== null && _a !== void 0 ? _a : 0;
99
+ const next = (_b = cols[idx + 1]) !== null && _b !== void 0 ? _b : TOTAL_COLUMNS;
100
+ return x > prev + 1 && x >= next - 1 ? x - 1 : x === prev ? x + 1 : x;
101
+ });
102
+ const subRows = cols.reduce((acc, v, idx, cols) => {
103
+ var _a;
104
+ if (idx === 0) {
105
+ return [[[idx, v]]];
106
+ }
107
+ let row = 0;
108
+ while (row < acc.length && acc[row][acc[row].length - 1][1] > v) {
109
+ row++;
110
+ }
111
+ ;
112
+ ((_a = acc[row]) !== null && _a !== void 0 ? _a : (acc[row] = [])).push([idx, v]);
113
+ return acc;
114
+ }, []);
115
+ return subRows.flatMap((subRow) => {
116
+ const acc = subRow.map((x) => x[1]);
117
+ while (acc[acc.length - 1] < TOTAL_COLUMNS) {
118
+ const idx = acc.reduce(([minIdx, min], size, idx, columns) => {
119
+ const scenario = columns.map((x, cidx) => (cidx === idx ? x + 1 : x));
120
+ const penalty = scenario.reduce((acc, v) => {
121
+ var _a, _b, _c, _d;
122
+ const right = ((_b = (_a = formDataRow[subRow[idx][0]].editor) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = formDataRow[subRow[idx][0]].editor) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 0) - leftSide;
123
+ return acc + Math.abs(v * interColumnsDistance - right);
124
+ }, 0);
125
+ return penalty < min ? [idx, penalty] : [minIdx, min];
126
+ }, [undefined, 999999]);
127
+ const selected = idx[0];
128
+ if (selected === undefined) {
129
+ break;
130
+ }
131
+ for (let i = selected; i < acc.length; i++) {
132
+ acc[i]++;
133
+ }
134
+ }
135
+ const expandedCols = acc;
136
+ let idx = 0;
137
+ return subRow
138
+ .map(([idx]) => formDataRow[idx])
139
+ .map((formData, index) => {
140
+ var _a, _b, _c, _d, _e, _f;
141
+ const width = expandedCols[index] - idx;
142
+ idx += width;
143
+ return (_d = (_a = {
144
+ StringEditor: makeTextField,
145
+ CheckBoxEditor: makeCheckBox,
146
+ MeasureEditor: makeMeasureField,
147
+ NumberEditor: makeNumberField,
148
+ PopupMenuEditor: makeDropdownField,
149
+ DateTimeEditor: makeDateTimeField,
150
+ StringTableEditor: makeItemsListField,
151
+ TokenFieldEditor: makeTokenField,
152
+ SubFormEditor: makeSubForm,
153
+ ActionButton: makeActionButton,
154
+ })[(_c = (_b = formData.editor) === null || _b === void 0 ? void 0 : _b.key) !== null && _c !== void 0 ? _c : '']) === null || _d === void 0 ? void 0 : _d.call(_a, formData, width, Math.max(1, Math.floor(((_f = (_e = formData.editor) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : 0) / meanHeight)));
155
+ });
156
+ });
157
+ }));
158
+ }), form.guid);
159
+ return translated;
160
+ }
161
+ //# sourceMappingURL=icure-convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icure-convert.js","sourceRoot":"","sources":["../../tmp/conversion/icure-convert.ts"],"names":[],"mappings":"AACA,OAAO,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,cAAc,EACd,aAAa,EAEb,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,OAAO,EACP,OAAO,EACP,SAAS,EACT,UAAU,GACV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,YAA0B;;IACzE,MAAM,aAAa,GAAG,EAAE,CAAA;IACxB,MAAM,aAAa,GAAG,CAAC,QAAwB,EAAE,KAAa,EAAE,MAAc,EAAE,EAAE,WACjF,OAAA,IAAI,SAAS,CAAC,MAAA,QAAQ,CAAC,IAAI,mCAA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CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CACF,CAAA;IACF,CAAC,CAAC,EACF,IAAI,CAAC,IAAI,CACT,CAAA;IACD,OAAO,UAAU,CAAA;AAClB,CAAC","sourcesContent":["import { FormLayout } from '@icure/api'\nimport {\n\tButton,\n\tCheckBox,\n\tDatePicker,\n\tDateTimePicker,\n\tDropdownField,\n\tField,\n\tForm,\n\tItemsListField,\n\tMeasureField,\n\tNumberField,\n\tSection,\n\tSubform,\n\tTextField,\n\tTokenField,\n} from '../components/model'\nimport { FormLayoutData } from '@icure/api/icc-api/model/FormLayoutData'\nimport { cluster } from './ckmeans-grouping'\n\nexport function convertLegacy(form: FormLayout, formsLibrary: FormLayout[]): Form {\n\tconst TOTAL_COLUMNS = 24\n\tconst makeTextField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew TextField(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeItemsListField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew ItemsListField(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeTokenField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew TokenField(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeCheckBox = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew CheckBox(formData.name ?? '', { shortLabel: formData.label, options: { [formData.label ?? '']: formData.label }, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeMeasureField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew MeasureField(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeNumberField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew NumberField(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\tconst makeDateTimeField = (formData: FormLayoutData, width: number, height: number) =>\n\t\t(formData.editor as any)?.displayTime\n\t\t\t? new DateTimePicker(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\t\t\t: new DatePicker(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\n\tconst makeDropdownField = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew DropdownField(formData.name ?? '', {\n\t\t\tshortLabel: formData.label,\n\t\t\tspan: width,\n\t\t\toptions: (formData.editor as any)?.menuOptions\n\t\t\t\t? (formData.editor as any)?.menuOptions.reduce(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tacc: {\n\t\t\t\t\t\t\t\t[key: string]: unknown\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tv: string,\n\t\t\t\t\t\t) => ({ ...acc, [`LEGACY|${v}|1`]: v }),\n\t\t\t\t\t\t{},\n\t\t\t\t )\n\t\t\t\t: undefined,\n\t\t})\n\n\tconst makeSubForm = (formData: FormLayoutData, width: number, height: number) => {\n\t\tconst subForms = ((formData.editor as any)?.optionalFormGuids as string[])?.map((guid: string) => {\n\t\t\tconst subForm = formsLibrary.find((it) => it.guid === guid)\n\t\t\tif (!subForm) {\n\t\t\t\tthrow new Error(`Cannot find subform ${guid}`)\n\t\t\t}\n\t\t\treturn convertLegacy(subForm as FormLayout, formsLibrary)\n\t\t})\n\t\treturn new Subform(\n\t\t\tformData.name ?? '',\n\t\t\tsubForms.reduce((acc, sf) => ({ ...acc, [sf.form]: sf }), {}),\n\t\t\t{\n\t\t\t\tshortLabel: formData.label,\n\t\t\t\tspan: width,\n\t\t\t\trowSpan: height,\n\t\t\t},\n\t\t)\n\t}\n\n\tconst makeActionButton = (formData: FormLayoutData, width: number, height: number) =>\n\t\tnew Button(formData.name ?? '', { shortLabel: formData.label, span: width, rowSpan: height > 1 ? height : undefined })\n\n\t// noinspection UnnecessaryLocalVariableJS\n\tconst translated = new Form(\n\t\t(form.group ? `${form.group}/${form.name}` : form.name) ?? 'Unknown',\n\t\t(form.sections ?? []).map((section) => {\n\t\t\tconst fld = (section.formColumns ?? []).flatMap((column) => column.formDataList ?? [])\n\t\t\tconst sortedList = fld.sort((a, b) => (a.editor?.top ?? 0) - (b.editor?.top ?? 0))\n\n\t\t\tconst rowClusters = cluster(\n\t\t\t\tfld.map((f) => f.editor?.top ?? 0),\n\t\t\t\t5,\n\t\t\t\t16,\n\t\t\t)\n\t\t\tconst rows = rowClusters.clusters\n\n\t\t\tconst intraCentroids = rowClusters.centroids.map((v, idx, centroids) => (idx > 0 ? v - centroids[idx - 1] : 0)).filter((x) => x > 0)\n\t\t\tconst meanHeightWithOutliers = intraCentroids.reduce((sum, v) => v + sum, 0) / intraCentroids.length\n\t\t\tconst intraCentroidsWithoutOutliers = intraCentroids.filter((x) => x < meanHeightWithOutliers * 2)\n\t\t\tconst meanHeight = intraCentroidsWithoutOutliers.reduce((sum, v) => v + sum, 0) / intraCentroidsWithoutOutliers.length\n\n\t\t\tconst formDataClusters = sortedList\n\t\t\t\t.reduce(\n\t\t\t\t\t(cs, fd) => {\n\t\t\t\t\t\tcs[rows.findIndex((c) => c.includes(fd.editor?.top ?? 0))].push(fd)\n\t\t\t\t\t\treturn cs\n\t\t\t\t\t},\n\t\t\t\t\tnew Array(rows.length).fill(null).map(() => [] as FormLayoutData[]),\n\t\t\t\t)\n\t\t\t\t.map((c) => c.sort((a, b) => (a.editor?.left ?? 0) - (b.editor?.left ?? 0)))\n\n\t\t\tconst leftMostField = sortedList.filter((f) => !f.subForm).reduce((a, b) => ((a.editor?.left ?? 0) < (b.editor?.left ?? 0) ? a : b))\n\t\t\tconst rightMostField = sortedList\n\t\t\t\t.filter((f) => !f.subForm)\n\t\t\t\t.reduce((a, b) => ((a.editor?.left ?? 0) + (a.editor?.width ?? 0) < (b.editor?.left ?? 0) + (b.editor?.width ?? 0) ? b : a))\n\n\t\t\tconst leftSide = leftMostField.editor?.left ?? 0\n\t\t\tconst formWidth = (rightMostField?.editor?.left ?? 0) + (rightMostField?.editor?.width ?? 1024) - leftSide\n\t\t\tconst interColumnsDistance = formWidth / TOTAL_COLUMNS\n\t\t\tconst columns = cluster(\n\t\t\t\tfld.map((f) => (f.editor?.left ?? 0) + (f.editor?.width ?? 0) - leftSide),\n\t\t\t\tformWidth / (TOTAL_COLUMNS * 2),\n\t\t\t\tMath.ceil((formWidth ?? 1024) / (TOTAL_COLUMNS * 4)),\n\t\t\t\tMath.max(Math.min(TOTAL_COLUMNS, fld.length / 2), 1),\n\t\t\t)\n\t\t\tconst columnsWidth = columns.centroids.map((v, idx, t) => v - (t[idx - 1] ?? 0))\n\n\t\t\tconst acc = columnsWidth.map(() => 1)\n\t\t\twhile (acc.reduce((s, v) => s + v, 0) < TOTAL_COLUMNS) {\n\t\t\t\tconst idx = acc.reduce(\n\t\t\t\t\t(s: [number | undefined, number], size: number, idx: number): [number | undefined, number] => {\n\t\t\t\t\t\tconst diff = size * interColumnsDistance - columnsWidth[idx]\n\t\t\t\t\t\treturn diff < 0 && -diff > s[1] ? [idx, -diff] : s\n\t\t\t\t\t},\n\t\t\t\t\t[undefined, 0],\n\t\t\t\t)\n\t\t\t\tconst selected = idx[0]\n\t\t\t\tif (selected === undefined) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tacc[selected]++\n\t\t\t}\n\t\t\t// noinspection UnnecessaryLocalVariableJS\n\t\t\tconst columnsRoundedWidth = acc\n\n\t\t\tconst columnsAccumulatedWidth = columnsRoundedWidth.reduce((acc, v) => [...acc, (acc[acc.length - 1] ?? 0) + v], [])\n\t\t\tconst columnsAccumulatedWidthWithInterColumns = columnsAccumulatedWidth.map((v) => v * interColumnsDistance)\n\n\t\t\treturn new Section(\n\t\t\t\t'Main',\n\t\t\t\tformDataClusters.flatMap((formDataRow: FormLayoutData[]) => {\n\t\t\t\t\tconst cols = formDataRow\n\t\t\t\t\t\t.map((formData: FormLayoutData) => {\n\t\t\t\t\t\t\treturn columnsAccumulatedWidth[\n\t\t\t\t\t\t\t\tcolumnsAccumulatedWidthWithInterColumns.reduce(\n\t\t\t\t\t\t\t\t\t([idx, min]: [number, number], x, n) => {\n\t\t\t\t\t\t\t\t\t\tconst right = (formData.editor?.left ?? 0) + (formData.editor?.width ?? 0) - leftSide\n\t\t\t\t\t\t\t\t\t\treturn Math.abs(x - right) < min ? [n, Math.abs(x - right)] : [idx, min]\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t[0, 99999],\n\t\t\t\t\t\t\t\t)[0]\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.map((x, idx, cols) => {\n\t\t\t\t\t\t\t//Try to solve inverted positions in columns by adding or removing one column\n\t\t\t\t\t\t\tconst prev = cols[idx - 1] ?? 0\n\t\t\t\t\t\t\tconst next = cols[idx + 1] ?? TOTAL_COLUMNS\n\t\t\t\t\t\t\treturn x > prev + 1 && x >= next - 1 ? x - 1 : x === prev ? x + 1 : x\n\t\t\t\t\t\t})\n\t\t\t\t\tconst subRows = cols.reduce((acc, v, idx, cols) => {\n\t\t\t\t\t\tif (idx === 0) {\n\t\t\t\t\t\t\treturn [[[idx, v]]]\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlet row = 0\n\t\t\t\t\t\twhile (row < acc.length && acc[row][acc[row].length - 1][1] > v) {\n\t\t\t\t\t\t\trow++\n\t\t\t\t\t\t}\n\t\t\t\t\t\t;(acc[row] ?? (acc[row] = [])).push([idx, v] as [number, number])\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, [] as [number, number][][])\n\n\t\t\t\t\treturn subRows.flatMap((subRow) => {\n\t\t\t\t\t\tconst acc = subRow.map((x) => x[1])\n\t\t\t\t\t\twhile (acc[acc.length - 1] < TOTAL_COLUMNS) {\n\t\t\t\t\t\t\tconst idx = acc.reduce(\n\t\t\t\t\t\t\t\t([minIdx, min]: [number | undefined, number], size: number, idx: number, columns: number[]): [number | undefined, number] => {\n\t\t\t\t\t\t\t\t\tconst scenario = columns.map((x, cidx) => (cidx === idx ? x + 1 : x))\n\t\t\t\t\t\t\t\t\tconst penalty = scenario.reduce((acc, v) => {\n\t\t\t\t\t\t\t\t\t\tconst right = (formDataRow[subRow[idx][0]].editor?.left ?? 0) + (formDataRow[subRow[idx][0]].editor?.width ?? 0) - leftSide\n\t\t\t\t\t\t\t\t\t\treturn acc + Math.abs(v * interColumnsDistance - right)\n\t\t\t\t\t\t\t\t\t}, 0)\n\t\t\t\t\t\t\t\t\treturn penalty < min ? [idx, penalty] : [minIdx, min]\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t[undefined, 999999],\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tconst selected = idx[0]\n\t\t\t\t\t\t\tif (selected === undefined) {\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfor (let i = selected; i < acc.length; i++) {\n\t\t\t\t\t\t\t\tacc[i]++\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst expandedCols = acc\n\t\t\t\t\t\tlet idx = 0\n\t\t\t\t\t\treturn subRow\n\t\t\t\t\t\t\t.map(([idx]) => formDataRow[idx])\n\t\t\t\t\t\t\t.map((formData: FormLayoutData, index) => {\n\t\t\t\t\t\t\t\tconst width = expandedCols[index] - idx\n\t\t\t\t\t\t\t\tidx += width\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tStringEditor: makeTextField,\n\t\t\t\t\t\t\t\t\t\tCheckBoxEditor: makeCheckBox,\n\t\t\t\t\t\t\t\t\t\tMeasureEditor: makeMeasureField,\n\t\t\t\t\t\t\t\t\t\tNumberEditor: makeNumberField,\n\t\t\t\t\t\t\t\t\t\tPopupMenuEditor: makeDropdownField,\n\t\t\t\t\t\t\t\t\t\tDateTimeEditor: makeDateTimeField,\n\t\t\t\t\t\t\t\t\t\tStringTableEditor: makeItemsListField,\n\t\t\t\t\t\t\t\t\t\tTokenFieldEditor: makeTokenField,\n\t\t\t\t\t\t\t\t\t\tSubFormEditor: makeSubForm,\n\t\t\t\t\t\t\t\t\t\tActionButton: makeActionButton,\n\t\t\t\t\t\t\t\t\t} as { [key: string]: (fd: FormLayoutData, w: number, h: number) => Field | Subform }\n\t\t\t\t\t\t\t\t)[formData.editor?.key ?? '']?.(formData, width, Math.max(1, Math.floor((formData.editor?.height ?? 0) / meanHeight)))\n\t\t\t\t\t\t\t})\n\t\t\t\t\t})\n\t\t\t\t}),\n\t\t\t)\n\t\t}),\n\t\tform.guid,\n\t)\n\treturn translated\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { FieldMetadata, FieldValue } from '../components/model';
2
2
  /**
3
3
  * VersionedData is a structure that contains the values of a form, organized by id and version.
4
+ * Versions are ordered most recent first.
4
5
  */
5
6
  export interface VersionedData<T> {
6
7
  [id: string]: Version<T>[];
@@ -50,21 +51,21 @@ export type ID = string;
50
51
  export interface FormValuesContainer<Value, Metadata> {
51
52
  compute<T, S extends {
52
53
  [key: string | symbol]: unknown;
53
- }>(formula: string, sandbox?: S): Promise<T | undefined>;
54
+ }>(formula: string, sandbox?: S): Promise<ComputationResult<T>>;
54
55
  getLabel(): string;
55
56
  getFormId(): string | undefined;
56
- getDefaultValue(label: string): Promise<FieldValue | undefined>;
57
+ getDefaultValueProvider(label: string): (() => Promise<FieldValue | undefined>) | undefined;
57
58
  getValues(revisionsFilter: (id: string, history: Version<Metadata>[]) => (string | null)[]): VersionedData<Value>;
58
59
  getMetadata(id: string, revisions: (string | null)[]): VersionedData<Metadata>;
59
60
  getChildren(): Promise<FormValuesContainer<Value, Metadata>[]>;
60
- getValidationErrors(): Promise<[FieldMetadata, string][]>;
61
- setValue(label: string, language: string, data?: Value, id?: string, metadata?: Metadata, changeListenersOverrider?: (fvc: FormValuesContainer<Value, Metadata>) => void): void;
61
+ getValidationErrors(): Promise<[FieldMetadata, string] | null>[];
62
+ setValue(label: string, language: string, data?: Value, id?: string, metadata?: Metadata, changeListenersOverrider?: (fvc: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null) => void): void;
62
63
  setMetadata(metadata: Metadata, id?: string): void;
63
64
  delete(serviceId: string): void;
64
65
  addChild(anchorId: string, templateId: string, label: string): Promise<void>;
65
66
  removeChild(container: FormValuesContainer<Value, Metadata>): Promise<void>;
66
- registerChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void;
67
- unregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void;
67
+ registerChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null, force: boolean) => void): void;
68
+ unregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null, force: boolean) => void): void;
68
69
  synchronise(): FormValuesContainer<Value, Metadata>;
69
70
  }
70
71
  /**
@@ -83,3 +84,7 @@ export type Suggestion = {
83
84
  [lng: string]: string;
84
85
  };
85
86
  };
87
+ export interface ComputationResult<T> {
88
+ value: T | undefined;
89
+ dependencies: string[];
90
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../tmp/generic/model.ts"],"names":[],"mappings":"","sourcesContent":["import { FieldMetadata, FieldValue } from '../components/model'\n\n/**\n * VersionedData is a structure that contains the values of a form, organized by id and version.\n */\nexport interface VersionedData<T> {\n\t[id: string]: Version<T>[]\n}\n\n/**\n * Version is a structure that contains a value, a revision number and a modification timestamp used to sort the versions.\n */\nexport interface Version<T> {\n\trevision: string | null //null means that the version is not saved yet\n\tmodified?: number\n\tvalue: T\n}\n\nexport type ID = string\n/**\n * FormValuesContainer is a readonly structure that provides and handle the values of a form.\n * It is a tree structure where each node is a FormValuesContainer with the same Value and Metadata types.\n *\n * The following methods are provided and must be implemented by the concrete class:\n * - `compute(formula: string, sandbox?: S): T?` : computes a formula based on the values of the form, inside a provided sandbox. If no sandbox is provided, the default sandbox is used.\n * - `getLabel(): string` : returns the label of the form values container (used to display the title of the form in hierarchical contexts)\n * - `getFormId(): string?` : returns the id of the form values container\n * - `getValues(revisionsFilter: Lambda): VersionedData<Value>` : obtains the values to be displayed in the form, using a filter\n * \t\t\tto select the desired versioned data that are to be displayed in a specific field.\n * - `getMetadata(id: string, revisions: (string | null)[]): VersionedData<Metadata>` : obtains the metadata of a specific value, for the specified revisions.\n * - `getValidationErrors(): [FieldMetadata, string][]`: returns the validation errors of the form values container for the values that are currently stored in it.\n * - `getChildren(): FormValuesContainer<Value, Metadata>[]` : returns the children of the form values container\n * - `setValue(label: string, language: string, data?: Value, id?: string, metadata?: Metadata): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, ID>` :\n * \t\t\tmodifies the value associated to a field in the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container along with the modified value.\n * - `setMetadata(label: string, metadata: Metadata, id?: string): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, ID>` :\n * \t\t\tmodifies the metadata associated to a value in the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container along with the modified metadata.\n * - `delete(valueId: string): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, void>` :\n * \t\t\tdeletes a value from the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container without the deleted value.\n * - `addChild(anchorId: string, templateId: string, label: string): Promise<FormValuesContainerMutation<...>, FormValuesContainer<...>>>`:\n * \t\t\tadds a child to the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container with the added child.\n * - `removeChild(container: FormValuesContainer<Value, Metadata>): Promise<FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, void>>` :\n * \t\t\tremoves a child from the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container without the removed child.\n * - `registerChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void` :\n * \t\t\tregisters a listener that will be called whenever the form values container is modified.\n * - `unregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void` : unregisters a listener that was previously registered.\n *\n */\nexport interface FormValuesContainer<Value, Metadata> {\n\t//information retrieval\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): Promise<T | undefined>\n\tgetLabel(): string\n\tgetFormId(): string | undefined\n\tgetDefaultValue(label: string): Promise<FieldValue | undefined>\n\tgetValues(revisionsFilter: (id: string, history: Version<Metadata>[]) => (string | null)[]): VersionedData<Value>\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<Metadata>\n\tgetChildren(): Promise<FormValuesContainer<Value, Metadata>[]>\n\tgetValidationErrors(): Promise<[FieldMetadata, string][]>\n\t//modification\n\tsetValue(label: string, language: string, data?: Value, id?: string, metadata?: Metadata, changeListenersOverrider?: (fvc: FormValuesContainer<Value, Metadata>) => void): void\n\tsetMetadata(metadata: Metadata, id?: string): void\n\tdelete(serviceId: string): void\n\t//hierarchy\n\taddChild(anchorId: string, templateId: string, label: string): Promise<void>\n\tremoveChild(container: FormValuesContainer<Value, Metadata>): Promise<void>\n\t//listeners\n\tregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void\n\tunregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void\n\n\tsynchronise(): FormValuesContainer<Value, Metadata>\n}\n\n/**\n * FormValuesContainerMutation is a structure that wraps a new form values container along with the modified value.\n */\nexport interface FormValuesContainerMutation<Value, Metadata, FVC extends FormValuesContainer<Value, Metadata>, Result> {\n\tresult: Result\n\tformValuesContainer: FVC\n}\n\nexport type Suggestion = { id: string; code?: string; text: string; terms: string[]; label: { [lng: string]: string } }\n"]}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../tmp/generic/model.ts"],"names":[],"mappings":"","sourcesContent":["import { FieldMetadata, FieldValue } from '../components/model'\n\n/**\n * VersionedData is a structure that contains the values of a form, organized by id and version.\n * Versions are ordered most recent first.\n */\nexport interface VersionedData<T> {\n\t[id: string]: Version<T>[]\n}\n\n/**\n * Version is a structure that contains a value, a revision number and a modification timestamp used to sort the versions.\n */\nexport interface Version<T> {\n\trevision: string | null //null means that the version is not saved yet\n\tmodified?: number\n\tvalue: T\n}\n\nexport type ID = string\n/**\n * FormValuesContainer is a readonly structure that provides and handle the values of a form.\n * It is a tree structure where each node is a FormValuesContainer with the same Value and Metadata types.\n *\n * The following methods are provided and must be implemented by the concrete class:\n * - `compute(formula: string, sandbox?: S): T?` : computes a formula based on the values of the form, inside a provided sandbox. If no sandbox is provided, the default sandbox is used.\n * - `getLabel(): string` : returns the label of the form values container (used to display the title of the form in hierarchical contexts)\n * - `getFormId(): string?` : returns the id of the form values container\n * - `getValues(revisionsFilter: Lambda): VersionedData<Value>` : obtains the values to be displayed in the form, using a filter\n * \t\t\tto select the desired versioned data that are to be displayed in a specific field.\n * - `getMetadata(id: string, revisions: (string | null)[]): VersionedData<Metadata>` : obtains the metadata of a specific value, for the specified revisions.\n * - `getValidationErrors(): [FieldMetadata, string][]`: returns the validation errors of the form values container for the values that are currently stored in it.\n * - `getChildren(): FormValuesContainer<Value, Metadata>[]` : returns the children of the form values container\n * - `setValue(label: string, language: string, data?: Value, id?: string, metadata?: Metadata): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, ID>` :\n * \t\t\tmodifies the value associated to a field in the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container along with the modified value.\n * - `setMetadata(label: string, metadata: Metadata, id?: string): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, ID>` :\n * \t\t\tmodifies the metadata associated to a value in the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container along with the modified metadata.\n * - `delete(valueId: string): FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, void>` :\n * \t\t\tdeletes a value from the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container without the deleted value.\n * - `addChild(anchorId: string, templateId: string, label: string): Promise<FormValuesContainerMutation<...>, FormValuesContainer<...>>>`:\n * \t\t\tadds a child to the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container with the added child.\n * - `removeChild(container: FormValuesContainer<Value, Metadata>): Promise<FormValuesContainerMutation<Value, Metadata, FormValuesContainer<Value, Metadata>, void>>` :\n * \t\t\tremoves a child from the form values container. As a form values container is immutable, this method returns a mutation wrapping\n * \t\t\ta new form values container without the removed child.\n * - `registerChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void` :\n * \t\t\tregisters a listener that will be called whenever the form values container is modified.\n * - `unregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>) => void): void` : unregisters a listener that was previously registered.\n *\n */\nexport interface FormValuesContainer<Value, Metadata> {\n\t//information retrieval\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): Promise<ComputationResult<T>>\n\tgetLabel(): string\n\tgetFormId(): string | undefined\n\tgetDefaultValueProvider(label: string): (() => Promise<FieldValue | undefined>) | undefined\n\tgetValues(revisionsFilter: (id: string, history: Version<Metadata>[]) => (string | null)[]): VersionedData<Value>\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<Metadata>\n\tgetChildren(): Promise<FormValuesContainer<Value, Metadata>[]>\n\tgetValidationErrors(): Promise<[FieldMetadata, string] | null>[]\n\t//modification\n\tsetValue(\n\t\tlabel: string,\n\t\tlanguage: string,\n\t\tdata?: Value,\n\t\tid?: string,\n\t\tmetadata?: Metadata,\n\t\tchangeListenersOverrider?: (fvc: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null) => void,\n\t): void\n\tsetMetadata(metadata: Metadata, id?: string): void\n\tdelete(serviceId: string): void\n\t//hierarchy\n\taddChild(anchorId: string, templateId: string, label: string): Promise<void>\n\tremoveChild(container: FormValuesContainer<Value, Metadata>): Promise<void>\n\t//listeners\n\tregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null, force: boolean) => void): void\n\tunregisterChangeListener(listener: (newValue: FormValuesContainer<Value, Metadata>, changedKeys: string[] | null, force: boolean) => void): void\n\n\tsynchronise(): FormValuesContainer<Value, Metadata>\n}\n\n/**\n * FormValuesContainerMutation is a structure that wraps a new form values container along with the modified value.\n */\nexport interface FormValuesContainerMutation<Value, Metadata, FVC extends FormValuesContainer<Value, Metadata>, Result> {\n\tresult: Result\n\tformValuesContainer: FVC\n}\n\nexport type Suggestion = { id: string; code?: string; text: string; terms: string[]; label: { [lng: string]: string } }\n\nexport interface ComputationResult<T> {\n\tvalue: T | undefined\n\tdependencies: string[]\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { DecryptedContact, DecryptedForm as CardinalForm, DecryptedService } from '@icure/cardinal-sdk';
2
- import { FormValuesContainer, Version, VersionedData } from '../generic';
2
+ import { ComputationResult, FormValuesContainer, Version, VersionedData } from '../generic';
3
3
  import { ServiceMetadata } from './model';
4
4
  import { FieldMetadata, FieldValue, Validator } from '../components/model';
5
5
  /** This class is a bridge between the ICure API and the generic FormValuesContainer interface.
@@ -30,10 +30,12 @@ export declare class BridgedFormValuesContainer implements FormValuesContainer<F
30
30
  private language;
31
31
  private changeListeners;
32
32
  private interpreterContext;
33
+ private dependenciesCache;
33
34
  private contact;
34
35
  private contactFormValuesContainer;
35
36
  private _id;
36
37
  private readonly mutateAndNotify;
38
+ private dependentValuesComputationIteration?;
37
39
  toString(): string;
38
40
  /**
39
41
  * Creates an instance of BridgedFormValuesContainer.
@@ -47,6 +49,7 @@ export declare class BridgedFormValuesContainer implements FormValuesContainer<F
47
49
  * @param language The language in which the values are displayed
48
50
  * @param changeListeners The listeners that will be notified when the values change
49
51
  * @param interpreterContext A map with keys that are the names of the variables and values that are the functions that return the values of the variables
52
+ * @param dependenciesCache
50
53
  */
51
54
  constructor(responsible: string, contactFormValuesContainer: ContactFormValuesContainer, interpreter?: (<T, S extends {
52
55
  [key: string | symbol]: unknown;
@@ -61,30 +64,31 @@ export declare class BridgedFormValuesContainer implements FormValuesContainer<F
61
64
  }[], validatorsProvider?: (anchorId: string | undefined, templateId: string) => {
62
65
  metadata: FieldMetadata;
63
66
  validators: Validator[];
64
- }[], language?: string, changeListeners?: ((newValue: BridgedFormValuesContainer) => void)[], interpreterContext?: {
67
+ }[], language?: string, changeListeners?: ((newValue: BridgedFormValuesContainer, changedKeys: string[] | null, force: boolean) => void)[], interpreterContext?: {
65
68
  [variable: string]: () => unknown;
69
+ }, dependenciesCache?: {
70
+ [formula: string]: string[];
66
71
  });
67
- init(): Promise<this>;
72
+ init(changedKeys?: string[] | null, pendingComputationIteration?: Promise<[string | undefined, FieldMetadata, string, FieldValue | undefined][]>): Promise<BridgedFormValuesContainer>;
68
73
  getLabel(): string;
69
74
  getFormId(): string | undefined;
70
75
  getContactFormValuesContainer(): ContactFormValuesContainer;
71
- registerChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void;
72
- unregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void;
73
- getDefaultValue(label: string): Promise<FieldValue | undefined>;
76
+ registerChangeListener(listener: (newValue: BridgedFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
77
+ unregisterChangeListener(listener: (newValue: BridgedFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
78
+ getDefaultValueProvider(label: string): (() => Promise<FieldValue | undefined>) | undefined;
74
79
  getValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue>;
75
80
  getMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata>;
76
81
  private convertRawValue;
77
82
  private computeInitialValues;
78
83
  private computeDependentValues;
84
+ private quietlyApplyChangesOnContactFormValueContainer;
79
85
  setValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void;
80
86
  setMetadata(meta: FieldMetadata, id?: string | undefined): void;
81
87
  delete(serviceId: string): void;
82
88
  private getVersionedValuesForKey;
83
- compute<T, S extends {
84
- [key: string | symbol]: unknown;
85
- }>(formula: string, sandbox?: S): Promise<T | undefined>;
89
+ compute<T>(formula: string): Promise<ComputationResult<T>>;
86
90
  getChildren(): Promise<FormValuesContainer<FieldValue, FieldMetadata>[]>;
87
- getValidationErrors(): Promise<[FieldMetadata, string][]>;
91
+ getValidationErrors(): Promise<[FieldMetadata, string] | null>[];
88
92
  addChild(anchorId: string, templateId: string, label: string): Promise<void>;
89
93
  removeChild(container: BridgedFormValuesContainer): Promise<void>;
90
94
  synchronise(): this;
@@ -105,7 +109,7 @@ export declare class ContactFormValuesContainer implements FormValuesContainer<D
105
109
  serviceFactory: (label: string, serviceId?: string) => DecryptedService;
106
110
  formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>;
107
111
  formRecycler: (formId: string) => Promise<void>;
108
- changeListeners: ((newValue: ContactFormValuesContainer) => void)[];
112
+ changeListeners: ((newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void)[];
109
113
  private _id;
110
114
  private _initialised;
111
115
  private indexedServices;
@@ -119,23 +123,24 @@ export declare class ContactFormValuesContainer implements FormValuesContainer<D
119
123
  * Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children
120
124
  */
121
125
  allForms(): CardinalForm[];
122
- constructor(rootForm: CardinalForm, currentContact: DecryptedContact, contactsHistory: DecryptedContact[], serviceFactory: (label: string, serviceId?: string) => DecryptedService, children: ContactFormValuesContainer[], formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[], initialised?: boolean);
126
+ constructor(rootForm: CardinalForm, currentContact: DecryptedContact, contactsHistory: DecryptedContact[], serviceFactory: (label: string, serviceId?: string) => DecryptedService, children: ContactFormValuesContainer[], formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void)[], initialised?: boolean);
123
127
  synchronise(): this;
124
128
  registerChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer): void;
125
129
  static fromFormsHierarchy(rootForm: CardinalForm, currentContact: DecryptedContact, contactsHistory: DecryptedContact[], serviceFactory: (label: string, serviceId?: string) => DecryptedService, formChildrenProvider: (parentId: string | undefined) => Promise<CardinalForm[]>, formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<CardinalForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[]): Promise<ContactFormValuesContainer>;
126
130
  getLabel(): string;
127
131
  getFormId(): string | undefined;
128
- registerChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
129
- unregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
132
+ registerChangeListener(listener: (newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
133
+ unregisterChangeListener(listener: (newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
130
134
  getChildren(): Promise<ContactFormValuesContainer[]>;
131
- getValidationErrors(): Promise<[FieldMetadata, string][]>;
132
- getDefaultValue(): Promise<FieldValue | undefined>;
135
+ getValidationErrors(): Promise<[FieldMetadata, string] | null>[];
136
+ getDefaultValueProvider(): (() => Promise<FieldValue | undefined>) | undefined;
133
137
  getValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<DecryptedService>;
134
138
  getMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata>;
135
139
  setMetadata(meta: ServiceMetadata, id?: string): void;
136
- setValue(label: string, language: string, value?: DecryptedService, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void;
140
+ setValue(label: string, language: string, value?: DecryptedService, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer, changedKeys: string[] | null) => void): void;
137
141
  delete(serviceId: string): void;
138
- compute<T>(): Promise<T | undefined>;
142
+ toMarkdownTable(): string;
143
+ compute<T>(): Promise<ComputationResult<T>>;
139
144
  /** returns all services in history that match a selector
140
145
  *
141
146
  * @private