@icure/form 2.1.1 → 2.1.3
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/.yarn/cache/{libphonenumber-js-npm-1.12.36-92f3728071-f39b5ed57b.zip → libphonenumber-js-npm-1.12.38-a5180a8a02-2a2eeb122d.zip} +0 -0
- package/.yarn/cache/{markdown-it-npm-14.1.0-e337d75bfe-07296b45eb.zip → markdown-it-npm-14.1.1-45c173274d-d6d55865c6.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/components/common/field.d.ts +14 -2
- package/components/common/field.js +95 -2
- package/components/common/field.js.map +1 -1
- package/components/common/utils.js +11 -1
- package/components/common/utils.js.map +1 -1
- package/components/icure-form/fields/button-group/checkbox.js +3 -4
- package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
- package/components/icure-form/fields/button-group/radio-button.js +3 -4
- package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-picker.js +3 -4
- package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-time-picker.js +3 -4
- package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/time-picker.js +3 -4
- package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
- package/components/icure-form/fields/dropdown/dropdown-field.js +3 -4
- package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
- package/components/icure-form/fields/measure-field/measure-field.js +3 -4
- package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
- package/components/icure-form/fields/number-field/number-field.js +3 -4
- package/components/icure-form/fields/number-field/number-field.js.map +1 -1
- package/components/icure-form/fields/text-field/text-field.js +3 -4
- package/components/icure-form/fields/text-field/text-field.js.map +1 -1
- package/components/icure-form/fields/utils/index.d.ts +0 -5
- package/components/icure-form/fields/utils/index.js +1 -12
- package/components/icure-form/fields/utils/index.js.map +1 -1
- package/components/icure-form/index.js +14 -10
- package/components/icure-form/index.js.map +1 -1
- package/components/icure-form/renderer/form/form.js +6 -4
- package/components/icure-form/renderer/form/form.js.map +1 -1
- package/components/icure-text-field/index.js +0 -2
- package/components/icure-text-field/index.js.map +1 -1
- package/components/icure-text-field/schema/measure-schema.js +0 -1
- package/components/icure-text-field/schema/measure-schema.js.map +1 -1
- package/components/model/index.d.ts +16 -16
- package/components/model/index.js +34 -30
- package/components/model/index.js.map +1 -1
- package/generic/model.d.ts +10 -5
- package/generic/model.js.map +1 -1
- package/icure/form-values-container.d.ts +24 -18
- package/icure/form-values-container.js +310 -115
- package/icure/form-values-container.js.map +1 -1
- package/icure/icure-utils.js +48 -18
- package/icure/icure-utils.js.map +1 -1
- package/package.json +1 -1
- package/utils/fields-values-provider.d.ts +1 -1
- package/utils/fields-values-provider.js +6 -4
- package/utils/fields-values-provider.js.map +1 -1
package/generic/model.js.map
CHANGED
|
@@ -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
|
|
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 { Contact, Form, Form as ICureForm, Service } from '@icure/api';
|
|
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<
|
|
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;
|
|
76
|
+
registerChangeListener(listener: (newValue: BridgedFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
|
|
77
|
+
unregisterChangeListener(listener: (newValue: BridgedFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
|
|
73
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
|
|
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;
|
|
@@ -102,11 +106,12 @@ export declare class ContactFormValuesContainer implements FormValuesContainer<S
|
|
|
102
106
|
currentContact: Contact;
|
|
103
107
|
contactsHistory: Contact[];
|
|
104
108
|
children: ContactFormValuesContainer[];
|
|
109
|
+
anchorId?: string;
|
|
105
110
|
serviceFactory: (label: string, serviceId?: string) => Service;
|
|
106
111
|
formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>;
|
|
107
112
|
formRecycler: (formId: string) => Promise<void>;
|
|
108
|
-
changeListeners: ((newValue: ContactFormValuesContainer) => void)[];
|
|
109
|
-
|
|
113
|
+
changeListeners: ((newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void)[];
|
|
114
|
+
_id: string;
|
|
110
115
|
private _initialised;
|
|
111
116
|
private indexedServices;
|
|
112
117
|
toString(): string;
|
|
@@ -119,23 +124,24 @@ export declare class ContactFormValuesContainer implements FormValuesContainer<S
|
|
|
119
124
|
* Returns a contact that combines the content of the contact in this form with the content of all contents stored in the children
|
|
120
125
|
*/
|
|
121
126
|
allForms(): Form[];
|
|
122
|
-
constructor(rootForm: ICureForm, currentContact: Contact, contactsHistory: Contact[], serviceFactory: (label: string, serviceId?: string) => Service, children: ContactFormValuesContainer[], formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[], initialised?: boolean);
|
|
127
|
+
constructor(rootForm: ICureForm, currentContact: Contact, contactsHistory: Contact[], serviceFactory: (label: string, serviceId?: string) => Service, children: ContactFormValuesContainer[], formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void)[], anchorId?: string, initialised?: boolean);
|
|
123
128
|
synchronise(): this;
|
|
124
|
-
registerChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer): void;
|
|
129
|
+
registerChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer, anchorId: string): void;
|
|
125
130
|
static fromFormsHierarchy(rootForm: ICureForm, currentContact: Contact, contactsHistory: Contact[], serviceFactory: (label: string, serviceId?: string) => Service, formChildrenProvider: (parentId: string | undefined) => Promise<ICureForm[]>, formFactory: (parentId: string, anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>, formRecycler: (formId: string) => Promise<void>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[]): Promise<ContactFormValuesContainer>;
|
|
126
131
|
getLabel(): string;
|
|
127
132
|
getFormId(): string | undefined;
|
|
128
|
-
registerChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
|
|
129
|
-
unregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
|
|
133
|
+
registerChangeListener(listener: (newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
|
|
134
|
+
unregisterChangeListener(listener: (newValue: ContactFormValuesContainer, changedKeys: string[] | null, force: boolean) => void): void;
|
|
130
135
|
getChildren(): Promise<ContactFormValuesContainer[]>;
|
|
131
|
-
getValidationErrors(): Promise<[FieldMetadata, string][]
|
|
136
|
+
getValidationErrors(): Promise<[FieldMetadata, string] | null>[];
|
|
132
137
|
getDefaultValueProvider(): (() => Promise<FieldValue | undefined>) | undefined;
|
|
133
138
|
getValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service>;
|
|
134
139
|
getMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata>;
|
|
135
140
|
setMetadata(meta: ServiceMetadata, id?: string): void;
|
|
136
|
-
setValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void;
|
|
141
|
+
setValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer, changedKeys: string[] | null) => void): void;
|
|
137
142
|
delete(serviceId: string): void;
|
|
138
|
-
|
|
143
|
+
toMarkdownTable(): string;
|
|
144
|
+
compute<T>(): Promise<ComputationResult<T>>;
|
|
139
145
|
/** returns all services in history that match a selector
|
|
140
146
|
*
|
|
141
147
|
* @private
|