@icure/form 1.0.5 → 1.0.9
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/{lib/components → components}/index.d.ts +0 -0
- package/{lib/components → components}/index.js +0 -0
- package/components/iqr-form/fields/datePicker.d.ts +10 -0
- package/{lib/components → components}/iqr-form/fields/datePicker.js +26 -12
- package/components/iqr-form/fields/dateTimePicker.d.ts +10 -0
- package/{lib/components → components}/iqr-form/fields/dateTimePicker.js +18 -12
- package/components/iqr-form/fields/measureField.d.ts +8 -0
- package/{lib/components → components}/iqr-form/fields/measureField.js +13 -12
- package/components/iqr-form/fields/multipleChoice.d.ts +8 -0
- package/{lib/components → components}/iqr-form/fields/multipleChoice.js +13 -12
- package/components/iqr-form/fields/numberField.d.ts +8 -0
- package/{lib/components → components}/iqr-form/fields/numberField.js +13 -12
- package/{lib/components → components}/iqr-form/fields/textfield.d.ts +0 -0
- package/components/iqr-form/fields/textfield.js +138 -0
- package/components/iqr-form/fields/timePicker.d.ts +10 -0
- package/{lib/components → components}/iqr-form/fields/timePicker.js +18 -12
- package/{lib/components → components}/iqr-form/index.d.ts +0 -0
- package/{lib/components → components}/iqr-form/index.js +30 -25
- package/{lib/components → components}/iqr-form/model/index.d.ts +36 -18
- package/{lib/components → components}/iqr-form/model/index.js +9 -4
- package/{lib/components → components}/iqr-form/renderer/cards.d.ts +1 -1
- package/components/iqr-form/renderer/cards.js +54 -0
- package/{lib/components → components}/iqr-form/renderer/form.d.ts +1 -1
- package/components/iqr-form/renderer/form.js +91 -0
- package/components/iqr-form/renderer/index.d.ts +6 -0
- package/components/iqr-form/renderer/index.js +2 -0
- package/components/iqr-form-loader/fieldsValuesProviders.d.ts +13 -0
- package/components/iqr-form-loader/fieldsValuesProviders.js +46 -0
- package/components/iqr-form-loader/formValuesContainer.d.ts +33 -0
- package/components/iqr-form-loader/formValuesContainer.js +110 -0
- package/components/iqr-form-loader/index.d.ts +3 -0
- package/components/iqr-form-loader/index.js +15 -0
- package/components/iqr-form-loader/models.d.ts +14 -0
- package/{lib/components/iqr-form/renderer/index.js → components/iqr-form-loader/models.js} +0 -0
- package/components/iqr-text-field/index.d.ts +26 -0
- package/{lib/components → components}/iqr-text-field/index.js +316 -171
- package/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +2 -0
- package/{lib/components → components}/iqr-text-field/plugin/caret-fix-plugin.js +10 -6
- package/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +2 -0
- package/{lib/components → components}/iqr-text-field/plugin/has-content-class-plugin.js +7 -5
- package/components/iqr-text-field/plugin/mask-plugin.d.ts +2 -0
- package/{lib/components → components}/iqr-text-field/plugin/mask-plugin.js +19 -12
- package/components/iqr-text-field/plugin/regexp-plugin.d.ts +2 -0
- package/{lib/components → components}/iqr-text-field/plugin/regexp-plugin.js +7 -4
- package/components/iqr-text-field/prosemirror-commands.d.ts +6 -0
- package/{lib/components → components}/iqr-text-field/prosemirror-commands.js +4 -3
- package/{lib/components → components}/iqr-text-field/prosemirror-utils.d.ts +1 -1
- package/{lib/components → components}/iqr-text-field/prosemirror-utils.js +1 -1
- package/{lib/components → components}/iqr-text-field/schema/common-marks.d.ts +1 -1
- package/components/iqr-text-field/schema/common-marks.js +93 -0
- package/{lib/components → components}/iqr-text-field/schema/date-time-schema.d.ts +0 -0
- package/{lib/components → components}/iqr-text-field/schema/date-time-schema.js +13 -13
- package/{lib/components → components}/iqr-text-field/schema/decimal-schema.d.ts +0 -0
- package/{lib/components → components}/iqr-text-field/schema/decimal-schema.js +4 -4
- package/{lib/components → components}/iqr-text-field/schema/index.d.ts +6 -6
- package/components/iqr-text-field/schema/index.js +25 -0
- package/{lib/components → components}/iqr-text-field/schema/markdown-schema.d.ts +0 -0
- package/{lib/components → components}/iqr-text-field/schema/markdown-schema.js +65 -32
- package/{lib/components → components}/iqr-text-field/schema/measure-schema.d.ts +0 -0
- package/{lib/components → components}/iqr-text-field/schema/measure-schema.js +5 -5
- package/{lib/components → components}/iqr-text-field/schema/token-schema.d.ts +0 -0
- package/{lib/components → components}/iqr-text-field/schema/token-schema.js +10 -7
- package/{lib/components → components}/iqr-text-field/schema/utils.d.ts +1 -1
- package/{lib/components → components}/iqr-text-field/schema/utils.js +2 -2
- package/{lib/components → components}/iqr-text-field/selection-companion.d.ts +2 -2
- package/{lib/components → components}/iqr-text-field/selection-companion.js +13 -12
- package/components/iqr-text-field/styles/paths.d.ts +5 -0
- package/components/iqr-text-field/styles/paths.js +36 -0
- package/{lib/components → components}/iqr-text-field/suggestion-palette.d.ts +11 -15
- package/{lib/components → components}/iqr-text-field/suggestion-palette.js +41 -24
- package/{lib/index.d.ts → index.d.ts} +0 -0
- package/{lib/index.js → index.js} +0 -0
- package/package.json +13 -47
- package/utils/icure-utils.d.ts +19 -0
- package/utils/icure-utils.js +105 -0
- package/utils/languages.d.ts +8 -0
- package/utils/languages.js +14 -0
- package/utils/no-lodash.d.ts +5 -0
- package/utils/no-lodash.js +19 -0
- package/lib/components/iqr-form/fields/datePicker.d.ts +0 -8
- package/lib/components/iqr-form/fields/dateTimePicker.d.ts +0 -8
- package/lib/components/iqr-form/fields/measureField.d.ts +0 -8
- package/lib/components/iqr-form/fields/multipleChoice.d.ts +0 -8
- package/lib/components/iqr-form/fields/numberField.d.ts +0 -8
- package/lib/components/iqr-form/fields/textfield.js +0 -86
- package/lib/components/iqr-form/fields/timePicker.d.ts +0 -8
- package/lib/components/iqr-form/renderer/cards.js +0 -44
- package/lib/components/iqr-form/renderer/form.js +0 -45
- package/lib/components/iqr-form/renderer/index.d.ts +0 -3
- package/lib/components/iqr-text-field/index.d.ts +0 -2
- package/lib/components/iqr-text-field/plugin/caret-fix-plugin.d.ts +0 -2
- package/lib/components/iqr-text-field/plugin/has-content-class-plugin.d.ts +0 -2
- package/lib/components/iqr-text-field/plugin/mask-plugin.d.ts +0 -2
- package/lib/components/iqr-text-field/plugin/regexp-plugin.d.ts +0 -2
- package/lib/components/iqr-text-field/prosemirror-commands.d.ts +0 -4
- package/lib/components/iqr-text-field/schema/common-marks.js +0 -90
- package/lib/components/iqr-text-field/schema/index.js +0 -18
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IqrTextFieldSchema } from
|
|
1
|
+
import { IqrTextFieldSchema } from '../../iqr-text-field';
|
|
2
2
|
declare type FieldType = 'textfield' | 'measure-field' | 'number-field' | 'date-picker' | 'time-picker' | 'date-time-picker' | 'multiple-choice';
|
|
3
3
|
export declare abstract class Field {
|
|
4
|
+
clazz: 'field';
|
|
4
5
|
field: string;
|
|
5
6
|
type: FieldType;
|
|
6
7
|
shortLabel?: string;
|
|
@@ -11,68 +12,85 @@ export declare abstract class Field {
|
|
|
11
12
|
tags?: string[];
|
|
12
13
|
codifications?: string[];
|
|
13
14
|
options?: {
|
|
14
|
-
[key: string]:
|
|
15
|
+
[key: string]: unknown;
|
|
15
16
|
};
|
|
17
|
+
label(): string;
|
|
16
18
|
protected constructor(type: FieldType, label: string, shortLabel?: string, rows?: number, columns?: number, grows?: boolean, schema?: IqrTextFieldSchema, tags?: string[], codifications?: string[], options?: {
|
|
17
|
-
[key: string]:
|
|
19
|
+
[key: string]: unknown;
|
|
18
20
|
});
|
|
19
|
-
static parse(json:
|
|
21
|
+
static parse(json: Field): Field;
|
|
20
22
|
}
|
|
21
23
|
export declare class TextField extends Field {
|
|
22
24
|
constructor(label: string, shortLabel?: string, rows?: number, grows?: boolean, schema?: IqrTextFieldSchema, tags?: string[], codifications?: string[], options?: {
|
|
23
|
-
[key: string]:
|
|
25
|
+
[key: string]: unknown;
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
export declare class MeasureField extends Field {
|
|
27
29
|
constructor(label: string, shortLabel?: string, tags?: string[], codifications?: string[], options?: {
|
|
28
|
-
[key: string]:
|
|
30
|
+
[key: string]: unknown;
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
export declare class NumberField extends Field {
|
|
32
34
|
constructor(label: string, shortLabel?: string, tags?: string[], codifications?: string[], options?: {
|
|
33
|
-
[key: string]:
|
|
35
|
+
[key: string]: unknown;
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
export declare class DatePicker extends Field {
|
|
37
39
|
constructor(label: string, shortLabel?: string, tags?: string[], codifications?: string[], options?: {
|
|
38
|
-
[key: string]:
|
|
40
|
+
[key: string]: unknown;
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
export declare class TimePicker extends Field {
|
|
42
44
|
constructor(label: string, shortLabel?: string, tags?: string[], codifications?: string[], options?: {
|
|
43
|
-
[key: string]:
|
|
45
|
+
[key: string]: unknown;
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
export declare class DateTimePicker extends Field {
|
|
47
49
|
constructor(label: string, shortLabel?: string, tags?: string[], codifications?: string[], options?: {
|
|
48
|
-
[key: string]:
|
|
50
|
+
[key: string]: unknown;
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
export declare class MultipleChoice extends Field {
|
|
52
54
|
constructor(label: string, shortLabel?: string, rows?: number, columns?: number, tags?: string[], codifications?: string[], options?: {
|
|
53
|
-
[key: string]:
|
|
55
|
+
[key: string]: unknown;
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
export declare class Group {
|
|
59
|
+
clazz: 'group';
|
|
57
60
|
group: string;
|
|
58
61
|
fields?: Array<Field | Group>;
|
|
59
62
|
constructor(title: string, fields: Array<Field | Group>);
|
|
60
|
-
static parse(json:
|
|
63
|
+
static parse(json: {
|
|
64
|
+
group: string;
|
|
65
|
+
fields?: Array<Field | Group>;
|
|
66
|
+
}): Group;
|
|
61
67
|
}
|
|
62
68
|
export declare class Section {
|
|
63
69
|
section: string;
|
|
64
70
|
fields: Array<Field | Group>;
|
|
65
71
|
description?: string;
|
|
66
|
-
keywords?:
|
|
67
|
-
constructor(title: string, fields: Array<Field | Group>, description?: string, keywords?:
|
|
68
|
-
static parse(json:
|
|
72
|
+
keywords?: string[];
|
|
73
|
+
constructor(title: string, fields: Array<Field | Group>, description?: string, keywords?: string[]);
|
|
74
|
+
static parse(json: {
|
|
75
|
+
section: string;
|
|
76
|
+
fields?: Array<Field | Group>;
|
|
77
|
+
groups?: Array<Field | Group>;
|
|
78
|
+
sections?: Array<Field | Group>;
|
|
79
|
+
description?: string;
|
|
80
|
+
keywords?: string[];
|
|
81
|
+
}): Section;
|
|
69
82
|
}
|
|
70
83
|
export declare class Form {
|
|
71
84
|
form: string;
|
|
72
85
|
sections: Section[];
|
|
73
86
|
description?: string;
|
|
74
|
-
keywords?:
|
|
75
|
-
constructor(title: string, sections: Section[], description?: string, keywords?:
|
|
76
|
-
static parse(json:
|
|
87
|
+
keywords?: string[];
|
|
88
|
+
constructor(title: string, sections: Section[], description?: string, keywords?: string[]);
|
|
89
|
+
static parse(json: {
|
|
90
|
+
form: string;
|
|
91
|
+
sections: Section[];
|
|
92
|
+
description?: string;
|
|
93
|
+
keywords?: string[];
|
|
94
|
+
}): Form;
|
|
77
95
|
}
|
|
78
96
|
export {};
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Form = exports.Section = exports.Group = exports.MultipleChoice = exports.DateTimePicker = exports.TimePicker = exports.DatePicker = exports.NumberField = exports.MeasureField = exports.TextField = exports.Field = void 0;
|
|
4
4
|
class Field {
|
|
5
5
|
constructor(type, label, shortLabel, rows, columns, grows, schema, tags, codifications, options) {
|
|
6
|
+
this.clazz = 'field';
|
|
6
7
|
this.field = label;
|
|
7
8
|
this.type = type;
|
|
8
9
|
this.shortLabel = shortLabel;
|
|
@@ -14,6 +15,9 @@ class Field {
|
|
|
14
15
|
this.codifications = codifications;
|
|
15
16
|
this.options = options;
|
|
16
17
|
}
|
|
18
|
+
label() {
|
|
19
|
+
return this.field;
|
|
20
|
+
}
|
|
17
21
|
static parse(json) {
|
|
18
22
|
switch (json.type) {
|
|
19
23
|
case 'textfield':
|
|
@@ -31,7 +35,7 @@ class Field {
|
|
|
31
35
|
case 'multiple-choice':
|
|
32
36
|
return new MultipleChoice(json.field, json.shortLabel, json.rows, json.columns, json.tags, json.codifications, json.options);
|
|
33
37
|
default:
|
|
34
|
-
throw Error(
|
|
38
|
+
throw Error('Invalid field type ' + json.type);
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
@@ -80,11 +84,12 @@ class MultipleChoice extends Field {
|
|
|
80
84
|
exports.MultipleChoice = MultipleChoice;
|
|
81
85
|
class Group {
|
|
82
86
|
constructor(title, fields) {
|
|
87
|
+
this.clazz = 'group';
|
|
83
88
|
this.group = title;
|
|
84
89
|
this.fields = fields;
|
|
85
90
|
}
|
|
86
91
|
static parse(json) {
|
|
87
|
-
return new Group(json.group, json.fields.map((s) => s
|
|
92
|
+
return new Group(json.group, (json.fields || []).map((s) => (s['group'] ? Group.parse(s) : Field.parse(s))));
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
95
|
exports.Group = Group;
|
|
@@ -96,7 +101,7 @@ class Section {
|
|
|
96
101
|
this.keywords = keywords;
|
|
97
102
|
}
|
|
98
103
|
static parse(json) {
|
|
99
|
-
return new Section(json.section, json.fields.map((s) => s
|
|
104
|
+
return new Section(json.section, (json.fields || json.groups || json.sections || []).map((s) => (s['group'] ? Group.parse(s) : Field.parse(s))), json.description, json.keywords);
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
107
|
exports.Section = Section;
|
|
@@ -108,7 +113,7 @@ class Form {
|
|
|
108
113
|
this.sections = sections;
|
|
109
114
|
}
|
|
110
115
|
static parse(json) {
|
|
111
|
-
return new Form(json.form, json.sections.map((s) => Section.parse(s)), json.description, json.keywords);
|
|
116
|
+
return new Form(json.form, (json.sections || []).map((s) => Section.parse(s)), json.description, json.keywords);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
exports.Form = Form;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Renderer } from
|
|
1
|
+
import { Renderer } from './index';
|
|
2
2
|
export declare const render: Renderer;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.render = void 0;
|
|
4
|
+
const lit_1 = require("lit");
|
|
5
|
+
const model_1 = require("../model");
|
|
6
|
+
const render = (form, props, formsValueContainer) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const h = function (level, content) {
|
|
9
|
+
return level === 1
|
|
10
|
+
? lit_1.html `<h1>${content}</h1>`
|
|
11
|
+
: level === 2
|
|
12
|
+
? lit_1.html `<h2>${content}</h2>`
|
|
13
|
+
: level === 3
|
|
14
|
+
? lit_1.html `<h3>${content}</h3>`
|
|
15
|
+
: level === 4
|
|
16
|
+
? lit_1.html `<h4>${content}</h4>`
|
|
17
|
+
: level === 5
|
|
18
|
+
? lit_1.html `<h5>${content}</h5>`
|
|
19
|
+
: lit_1.html `<h6>${content}</h6>`;
|
|
20
|
+
};
|
|
21
|
+
const renderFieldOrGroup = function (fg, level) {
|
|
22
|
+
var _a;
|
|
23
|
+
return fg instanceof model_1.Group
|
|
24
|
+
? lit_1.html ` <div class="group">${h(level, lit_1.html `${fg.group}`)} ${(_a = fg.fields) === null || _a === void 0 ? void 0 : _a.map((f) => renderFieldOrGroup(f, level + 1))}</div>`
|
|
25
|
+
: lit_1.html `${fg.type === 'textfield'
|
|
26
|
+
? lit_1.html `<iqr-form-textfield label="${fg.field}" multiline="${(fg.rows || 0) > 1 || fg.grows}" rows="${fg.rows || 1}" grows="${fg.grows || false}"></iqr-form-textfield>`
|
|
27
|
+
: fg.type === 'measure-field'
|
|
28
|
+
? lit_1.html `<iqr-form-measure-field label="${fg.field}"></iqr-form-measure-field>`
|
|
29
|
+
: fg.type === 'number-field'
|
|
30
|
+
? lit_1.html `<iqr-form-number-field label="${fg.field}"></iqr-form-number-field>`
|
|
31
|
+
: fg.type === 'date-picker'
|
|
32
|
+
? lit_1.html `<iqr-form-date-picker label="${fg.field}"></iqr-form-date-picker>`
|
|
33
|
+
: fg.type === 'time-picker'
|
|
34
|
+
? lit_1.html `<iqr-form-time-picker label="${fg.field}"></iqr-form-time-picker>`
|
|
35
|
+
: fg.type === 'date-time-picker'
|
|
36
|
+
? lit_1.html `<iqr-form-date-time-picker label="${fg.field}"></iqr-form-date-time-picker>`
|
|
37
|
+
: fg.type === 'multiple-choice'
|
|
38
|
+
? lit_1.html `<iqr-form-multiple-choice label="${fg.field}"></iqr-form-multiple-choice>`
|
|
39
|
+
: ''}
|
|
40
|
+
</div>`;
|
|
41
|
+
};
|
|
42
|
+
return lit_1.html `
|
|
43
|
+
<div class="iqr-form">
|
|
44
|
+
${(_a = form === null || form === void 0 ? void 0 : form.sections) === null || _a === void 0 ? void 0 : _a.map((s) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return lit_1.html `
|
|
47
|
+
<h2>${s.section}</h2>
|
|
48
|
+
${s.description ? lit_1.html `<p>${s.description}</p>` : ''} ${(_a = s.fields) === null || _a === void 0 ? void 0 : _a.map((f) => renderFieldOrGroup(f, 3))}
|
|
49
|
+
`;
|
|
50
|
+
})}
|
|
51
|
+
</div>
|
|
52
|
+
`;
|
|
53
|
+
};
|
|
54
|
+
exports.render = render;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Renderer } from
|
|
1
|
+
import { Renderer } from './index';
|
|
2
2
|
export declare const render: Renderer;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.render = void 0;
|
|
4
|
+
const lit_1 = require("lit");
|
|
5
|
+
const iqr_form_loader_1 = require("../../iqr-form-loader");
|
|
6
|
+
const valueProvider = (valuesProvider) => () => valuesProvider()[0];
|
|
7
|
+
const render = (form, props, formsValueContainer) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const h = function (level, content) {
|
|
10
|
+
return level === 1
|
|
11
|
+
? lit_1.html `<h1>${content}</h1>`
|
|
12
|
+
: level === 2
|
|
13
|
+
? lit_1.html `<h2>${content}</h2>`
|
|
14
|
+
: level === 3
|
|
15
|
+
? lit_1.html `<h3>${content}</h3>`
|
|
16
|
+
: level === 4
|
|
17
|
+
? lit_1.html `<h4>${content}</h4>`
|
|
18
|
+
: level === 5
|
|
19
|
+
? lit_1.html `<h5>${content}</h5>`
|
|
20
|
+
: lit_1.html `<h6>${content}</h6>`;
|
|
21
|
+
};
|
|
22
|
+
const renderFieldOrGroup = function (fg, level) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
24
|
+
return fg.clazz === 'group'
|
|
25
|
+
? lit_1.html ` <div class="group">${h(level, lit_1.html `${fg.group}`)} ${(_a = fg.fields) === null || _a === void 0 ? void 0 : _a.map((f) => renderFieldOrGroup(f, level + 1))}</div>`
|
|
26
|
+
: lit_1.html `${fg.type === 'textfield'
|
|
27
|
+
? lit_1.html `<iqr-form-textfield
|
|
28
|
+
labelPosition=${props.labelPosition}
|
|
29
|
+
label="${fg.field}"
|
|
30
|
+
multiline="${(fg.rows || 0) > 1 || fg.grows}"
|
|
31
|
+
rows="${fg.rows || 1}"
|
|
32
|
+
grows="${fg.grows || false}"
|
|
33
|
+
.linksProvider=${(_b = fg.options) === null || _b === void 0 ? void 0 : _b.linksProvider}
|
|
34
|
+
.suggestionProvider=${(_c = fg.options) === null || _c === void 0 ? void 0 : _c.suggestionProvider}
|
|
35
|
+
.ownersProvider=${(_d = fg.options) === null || _d === void 0 ? void 0 : _d.ownersProvider}
|
|
36
|
+
.codeColorProvider=${(_e = fg.options) === null || _e === void 0 ? void 0 : _e.codeColorProvider}
|
|
37
|
+
.linkColorProvider=${(_f = fg.options) === null || _f === void 0 ? void 0 : _f.linkColorProvider}
|
|
38
|
+
.codeContentProvider=${(_g = fg.options) === null || _g === void 0 ? void 0 : _g.codeContentProvider}
|
|
39
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.textFieldValuesProvider(formsValueContainer, fg))}"
|
|
40
|
+
.metaProvider=${formsValueContainer && iqr_form_loader_1.metaProvider(formsValueContainer, fg)}
|
|
41
|
+
.handleValueChanged=${formsValueContainer && iqr_form_loader_1.handleTextFieldValueChangedProvider(formsValueContainer)}
|
|
42
|
+
.handleMetaChanged=${formsValueContainer && iqr_form_loader_1.handleMetaChangedProvider(formsValueContainer)}
|
|
43
|
+
></iqr-form-textfield>`
|
|
44
|
+
: fg.type === 'measure-field'
|
|
45
|
+
? lit_1.html `<iqr-form-measure-field
|
|
46
|
+
labelPosition=${props.labelPosition}
|
|
47
|
+
label="${fg.field}"
|
|
48
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.measureFieldValuesProvider(formsValueContainer, fg))}"
|
|
49
|
+
></iqr-form-measure-field>`
|
|
50
|
+
: fg.type === 'number-field'
|
|
51
|
+
? lit_1.html `<iqr-form-number-field
|
|
52
|
+
labelPosition=${props.labelPosition}
|
|
53
|
+
label="${fg.field}"
|
|
54
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.numberFieldValuesProvider(formsValueContainer, fg))}"
|
|
55
|
+
></iqr-form-number-field>`
|
|
56
|
+
: fg.type === 'date-picker'
|
|
57
|
+
? lit_1.html `<iqr-form-date-picker
|
|
58
|
+
labelPosition=${props.labelPosition}
|
|
59
|
+
label="${fg.field}"
|
|
60
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.dateFieldValuesProvider(formsValueContainer, fg))}"
|
|
61
|
+
></iqr-form-date-picker>`
|
|
62
|
+
: fg.type === 'time-picker'
|
|
63
|
+
? lit_1.html `<iqr-form-time-picker
|
|
64
|
+
labelPosition=${props.labelPosition}
|
|
65
|
+
label="${fg.field}"
|
|
66
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.timeFieldValuesProvider(formsValueContainer, fg))}"
|
|
67
|
+
></iqr-form-time-picker>`
|
|
68
|
+
: fg.type === 'date-time-picker'
|
|
69
|
+
? lit_1.html `<iqr-form-date-time-picker
|
|
70
|
+
labelPosition=${props.labelPosition}
|
|
71
|
+
label="${fg.field}"
|
|
72
|
+
.valueProvider="${formsValueContainer && valueProvider(iqr_form_loader_1.dateTimeFieldValuesProvider(formsValueContainer, fg))}"
|
|
73
|
+
></iqr-form-date-time-picker>`
|
|
74
|
+
: fg.type === 'multiple-choice'
|
|
75
|
+
? lit_1.html `<iqr-form-multiple-choice labelPosition=${props.labelPosition} label="${fg.field}"></iqr-form-multiple-choice>`
|
|
76
|
+
: ''}
|
|
77
|
+
</div>`;
|
|
78
|
+
};
|
|
79
|
+
return lit_1.html `
|
|
80
|
+
<div class="iqr-form">
|
|
81
|
+
${(_a = form === null || form === void 0 ? void 0 : form.sections) === null || _a === void 0 ? void 0 : _a.map((s) => {
|
|
82
|
+
var _a;
|
|
83
|
+
return lit_1.html `
|
|
84
|
+
<h2>${s.section}</h2>
|
|
85
|
+
${s.description ? lit_1.html `<p>${s.description}</p>` : ''} ${(_a = s.fields) === null || _a === void 0 ? void 0 : _a.map((f) => renderFieldOrGroup(f, 3))}
|
|
86
|
+
`;
|
|
87
|
+
})}
|
|
88
|
+
</div>
|
|
89
|
+
`;
|
|
90
|
+
};
|
|
91
|
+
exports.render = render;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Form } from '../model';
|
|
2
|
+
import { TemplateResult } from 'lit';
|
|
3
|
+
import { FormValuesContainer } from '../../iqr-form-loader/formValuesContainer';
|
|
4
|
+
export declare type Renderer = (form: Form, props: {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}, formsValueContainer?: FormValuesContainer) => TemplateResult;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Field } from '../iqr-form/model';
|
|
2
|
+
import { Meta, VersionedMeta, VersionedValue } from '../iqr-text-field';
|
|
3
|
+
import { CodeStub } from '@icure/api';
|
|
4
|
+
import { FormValuesContainer } from './formValuesContainer';
|
|
5
|
+
export declare function numberFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
6
|
+
export declare function measureFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
7
|
+
export declare function textFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
8
|
+
export declare function dateFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
9
|
+
export declare function dateTimeFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
10
|
+
export declare function timeFieldValuesProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedValue[];
|
|
11
|
+
export declare function metaProvider(formValuesContainer: FormValuesContainer, field: Field): () => VersionedMeta[];
|
|
12
|
+
export declare function handleTextFieldValueChangedProvider(formValuesContainer: FormValuesContainer): (serviceId: string, language: string, content: string, codes: CodeStub[]) => void;
|
|
13
|
+
export declare function handleMetaChangedProvider(formValuesContainer: FormValuesContainer): (serviceId: string, meta: Meta) => void;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleMetaChangedProvider = exports.handleTextFieldValueChangedProvider = exports.metaProvider = exports.timeFieldValuesProvider = exports.dateTimeFieldValuesProvider = exports.dateFieldValuesProvider = exports.textFieldValuesProvider = exports.measureFieldValuesProvider = exports.numberFieldValuesProvider = void 0;
|
|
4
|
+
const icure_utils_1 = require("../../utils/icure-utils");
|
|
5
|
+
const api_1 = require("@icure/api");
|
|
6
|
+
function numberFieldValuesProvider(formValuesContainer, field) {
|
|
7
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => content.numberValue || content.numberValue === 0 ? new Intl.NumberFormat('fr').format(content.numberValue) : '');
|
|
8
|
+
}
|
|
9
|
+
exports.numberFieldValuesProvider = numberFieldValuesProvider;
|
|
10
|
+
function measureFieldValuesProvider(formValuesContainer, field) {
|
|
11
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => { var _a, _b, _c; return ((_a = content.measureValue) === null || _a === void 0 ? void 0 : _a.value) || ((_b = content.measureValue) === null || _b === void 0 ? void 0 : _b.value) === 0 ? `${new Intl.NumberFormat('fr').format(content.measureValue.value)} ${(_c = content.measureValue) === null || _c === void 0 ? void 0 : _c.unit}` : ''; });
|
|
12
|
+
}
|
|
13
|
+
exports.measureFieldValuesProvider = measureFieldValuesProvider;
|
|
14
|
+
function textFieldValuesProvider(formValuesContainer, field) {
|
|
15
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => content.stringValue || '');
|
|
16
|
+
}
|
|
17
|
+
exports.textFieldValuesProvider = textFieldValuesProvider;
|
|
18
|
+
function dateFieldValuesProvider(formValuesContainer, field) {
|
|
19
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => `${content.fuzzyDateValue}`.replace(/(....)(..)(..)/, '$3$2$1') || '');
|
|
20
|
+
}
|
|
21
|
+
exports.dateFieldValuesProvider = dateFieldValuesProvider;
|
|
22
|
+
function dateTimeFieldValuesProvider(formValuesContainer, field) {
|
|
23
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => `${content.fuzzyDateValue}`.replace(/(....)(..)(..)(......)/, '$3$2$1 $4') || '');
|
|
24
|
+
}
|
|
25
|
+
exports.dateTimeFieldValuesProvider = dateTimeFieldValuesProvider;
|
|
26
|
+
function timeFieldValuesProvider(formValuesContainer, field) {
|
|
27
|
+
return () => icure_utils_1.convertServicesToVersionedValues(icure_utils_1.getVersions(formValuesContainer, field), (content) => `${content.fuzzyDateValue}`);
|
|
28
|
+
}
|
|
29
|
+
exports.timeFieldValuesProvider = timeFieldValuesProvider;
|
|
30
|
+
function metaProvider(formValuesContainer, field) {
|
|
31
|
+
return () => icure_utils_1.convertServicesToVersionedMetas(icure_utils_1.getVersions(formValuesContainer, field));
|
|
32
|
+
}
|
|
33
|
+
exports.metaProvider = metaProvider;
|
|
34
|
+
function handleTextFieldValueChangedProvider(formValuesContainer) {
|
|
35
|
+
return (serviceId, language, content, codes) => formValuesContainer.setValue(serviceId, language, new api_1.Content({ stringValue: content }), codes);
|
|
36
|
+
}
|
|
37
|
+
exports.handleTextFieldValueChangedProvider = handleTextFieldValueChangedProvider;
|
|
38
|
+
function handleMetaChangedProvider(formValuesContainer) {
|
|
39
|
+
return (serviceId, meta) => {
|
|
40
|
+
if (meta.owner !== undefined)
|
|
41
|
+
formValuesContainer.setResponsible(serviceId, meta.owner === null ? null : meta.owner.id);
|
|
42
|
+
if (meta.valueDate !== undefined)
|
|
43
|
+
formValuesContainer.setValueDate(serviceId, meta.valueDate);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.handleMetaChangedProvider = handleMetaChangedProvider;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CodeStub, Contact, Content, Service } from '@icure/api';
|
|
2
|
+
import { ServicesHistory } from './models';
|
|
3
|
+
export declare function withLabel(label: string): (svc: Service) => boolean;
|
|
4
|
+
export interface FormValuesContainer {
|
|
5
|
+
copy(currentContact: Contact): FormValuesContainer;
|
|
6
|
+
getVersions(selector: (svc: Service) => boolean): ServicesHistory;
|
|
7
|
+
setValue(serviceId: string, language: string, content: Content, codes: CodeStub[]): FormValuesContainer;
|
|
8
|
+
setValueDate(serviceId: string, fuzzyDate: number | null): FormValuesContainer;
|
|
9
|
+
setAuthor(serviceId: string, author: string | null): FormValuesContainer;
|
|
10
|
+
setResponsible(serviceId: string, responsible: string | null): FormValuesContainer;
|
|
11
|
+
delete(serviceId: string): FormValuesContainer;
|
|
12
|
+
}
|
|
13
|
+
export declare class ICureFormValuesContainer implements FormValuesContainer {
|
|
14
|
+
currentContact: Contact;
|
|
15
|
+
contact: Contact;
|
|
16
|
+
contactsHistory: Contact[];
|
|
17
|
+
serviceFactory: (language: string, content: Content) => Service;
|
|
18
|
+
constructor(currentContact: Contact, contact: Contact, contactsHistory: Contact[], serviceFactory: (language: string, content: Content) => Service);
|
|
19
|
+
copy(currentContact: Contact): ICureFormValuesContainer;
|
|
20
|
+
getVersions(selector: (svc: Service) => boolean): ServicesHistory;
|
|
21
|
+
private setServiceProperty;
|
|
22
|
+
setValueDate(serviceId: string, fuzzyDate: number | null): FormValuesContainer;
|
|
23
|
+
setAuthor(serviceId: string, author: string | null): FormValuesContainer;
|
|
24
|
+
setResponsible(serviceId: string, responsible: string | null): FormValuesContainer;
|
|
25
|
+
setValue(serviceId: string, language: string, content: Content, codes: CodeStub[]): FormValuesContainer;
|
|
26
|
+
delete(serviceId: string): FormValuesContainer;
|
|
27
|
+
/** returns all services in history that match a selector
|
|
28
|
+
*
|
|
29
|
+
* @param selector a function used to select the services of interest, usually : withLabel("someLabel")
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
private getServicesInHistory;
|
|
33
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.ICureFormValuesContainer = exports.withLabel = void 0;
|
|
15
|
+
const api_1 = require("@icure/api");
|
|
16
|
+
const no_lodash_1 = require("../../utils/no-lodash");
|
|
17
|
+
const icure_utils_1 = require("../../utils/icure-utils");
|
|
18
|
+
function withLabel(label) {
|
|
19
|
+
return (svc) => svc.label === label;
|
|
20
|
+
}
|
|
21
|
+
exports.withLabel = withLabel;
|
|
22
|
+
class ICureFormValuesContainer {
|
|
23
|
+
constructor(currentContact, contact, contactsHistory, serviceFactory) {
|
|
24
|
+
if (!contactsHistory.includes(contact) && contact !== currentContact) {
|
|
25
|
+
throw new Error('Illegal argument, the history must contain the contact');
|
|
26
|
+
}
|
|
27
|
+
if (contactsHistory.includes(currentContact)) {
|
|
28
|
+
throw new Error('Illegal argument, the history must not contain the currentContact');
|
|
29
|
+
}
|
|
30
|
+
this.currentContact = currentContact;
|
|
31
|
+
this.contact = contact;
|
|
32
|
+
this.contactsHistory = no_lodash_1.sortedBy(contactsHistory, 'created', 'desc');
|
|
33
|
+
this.serviceFactory = serviceFactory;
|
|
34
|
+
}
|
|
35
|
+
copy(currentContact) {
|
|
36
|
+
return new ICureFormValuesContainer(currentContact, this.contact, this.contactsHistory, this.serviceFactory);
|
|
37
|
+
}
|
|
38
|
+
getVersions(selector) {
|
|
39
|
+
return no_lodash_1.groupBy(this.getServicesInHistory(selector).filter((swc) => +(icure_utils_1.fuzzyDate(swc.contact.created) || 0) <= +(icure_utils_1.fuzzyDate(this.contact.created) || 0)), (swc) => swc.service.id || '');
|
|
40
|
+
}
|
|
41
|
+
setServiceProperty(serviceId, newValue, getter, setter) {
|
|
42
|
+
const swcs = this.getServicesInHistory((s) => s.id === serviceId);
|
|
43
|
+
if (swcs.length) {
|
|
44
|
+
if (newValue !== getter(swcs[0].service)) {
|
|
45
|
+
return this.copy(icure_utils_1.setServices(this.currentContact, [], [setter(swcs[0].service, newValue)]));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
setValueDate(serviceId, fuzzyDate) {
|
|
56
|
+
return this.setServiceProperty(serviceId, fuzzyDate, (s) => s.valueDate, (s) => new api_1.Service(Object.assign(Object.assign({}, s), { valueDate: fuzzyDate })));
|
|
57
|
+
}
|
|
58
|
+
setAuthor(serviceId, author) {
|
|
59
|
+
return this.setServiceProperty(serviceId, author, (s) => s.author, (s) => new api_1.Service(Object.assign(Object.assign({}, s), { author })));
|
|
60
|
+
}
|
|
61
|
+
setResponsible(serviceId, responsible) {
|
|
62
|
+
return this.setServiceProperty(serviceId, responsible, (s) => s.author, (s) => new api_1.Service(Object.assign(Object.assign({}, s), { responsible })));
|
|
63
|
+
}
|
|
64
|
+
setValue(serviceId, language, content, codes) {
|
|
65
|
+
const swcs = this.getServicesInHistory((s) => s.id === serviceId);
|
|
66
|
+
if (swcs.length) {
|
|
67
|
+
const previousContent = swcs[0].service.content;
|
|
68
|
+
if (!previousContent || !icure_utils_1.isServiceContentEqual({ [language]: content }, previousContent)) {
|
|
69
|
+
// Omit end of life
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
const _a = Object.assign(Object.assign({}, swcs[0].service), { content: Object.assign(Object.assign({}, previousContent), { [language]: content }), codes: codes, modified: +new Date() }), { endOfLife } = _a, modifiedServiceValues = __rest(_a, ["endOfLife"]);
|
|
72
|
+
return this.copy(icure_utils_1.setServices(this.currentContact, [], [new api_1.Service(modifiedServiceValues)]));
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return this.copy(icure_utils_1.setServices(this.currentContact, [this.serviceFactory(language, content)], []));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
delete(serviceId) {
|
|
83
|
+
const swcs = this.getServicesInHistory((s) => s.id === serviceId);
|
|
84
|
+
if (swcs.length) {
|
|
85
|
+
//Omit end of life
|
|
86
|
+
const now = +new Date();
|
|
87
|
+
return this.copy(icure_utils_1.setServices(this.currentContact, [], [
|
|
88
|
+
new api_1.Service(Object.assign(Object.assign({}, swcs[0].service), { content: {}, modified: now, endOfLife: now })),
|
|
89
|
+
]));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return this;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** returns all services in history that match a selector
|
|
96
|
+
*
|
|
97
|
+
* @param selector a function used to select the services of interest, usually : withLabel("someLabel")
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
getServicesInHistory(selector) {
|
|
101
|
+
return [this.currentContact].concat(this.contactsHistory).flatMap((ctc) => {
|
|
102
|
+
var _a, _b;
|
|
103
|
+
return ((_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter(selector)) === null || _b === void 0 ? void 0 : _b.map((s) => ({
|
|
104
|
+
service: s,
|
|
105
|
+
contact: ctc,
|
|
106
|
+
}))) || [];
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.ICureFormValuesContainer = ICureFormValuesContainer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./models"), exports);
|
|
14
|
+
__exportStar(require("./formValuesContainer"), exports);
|
|
15
|
+
__exportStar(require("./fieldsValuesProviders"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Contact, Form, Service } from '@icure/api';
|
|
2
|
+
import { FormValuesContainer } from './formValuesContainer';
|
|
3
|
+
export declare type ServicesHistory = {
|
|
4
|
+
[id: string]: ServiceWithContact[];
|
|
5
|
+
};
|
|
6
|
+
export interface FormHierarchy {
|
|
7
|
+
form: Form;
|
|
8
|
+
formValuesContainer: FormValuesContainer;
|
|
9
|
+
children: FormHierarchy[];
|
|
10
|
+
}
|
|
11
|
+
export interface ServiceWithContact {
|
|
12
|
+
service: Service;
|
|
13
|
+
contact: Contact;
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { IqrTextFieldSchema } from './schema';
|
|
2
|
+
export { Suggestion } from './suggestion-palette';
|
|
3
|
+
export interface Meta {
|
|
4
|
+
revision: string;
|
|
5
|
+
modified?: number;
|
|
6
|
+
valueDate?: number | null;
|
|
7
|
+
owner?: {
|
|
8
|
+
id: string;
|
|
9
|
+
descr?: string;
|
|
10
|
+
} | null;
|
|
11
|
+
}
|
|
12
|
+
export interface Version {
|
|
13
|
+
revision: string;
|
|
14
|
+
modified?: number;
|
|
15
|
+
value: {
|
|
16
|
+
[language: string]: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface VersionedMeta {
|
|
20
|
+
id: string;
|
|
21
|
+
metas: Meta[];
|
|
22
|
+
}
|
|
23
|
+
export interface VersionedValue {
|
|
24
|
+
id: string;
|
|
25
|
+
versions: Version[];
|
|
26
|
+
}
|