@icure/form 2.0.11 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/cache/@babel-runtime-npm-7.28.6-f40c99aeef-42d8a868c2.zip +0 -0
- package/.yarn/cache/@icure-api-npm-5.3.18-99d397b97c-0da319f009.zip +0 -0
- package/.yarn/cache/@icure-motss-app-datepicker-npm-6.0.0-rc.40-ca1da7abbb-9bbe2bed34.zip +0 -0
- package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.5.1-3b3c832bd1-22c404c481.zip +0 -0
- package/.yarn/cache/@lit-reactive-element-npm-1.6.3-4828441e51-79b58631c3.zip +0 -0
- package/.yarn/cache/@lit-reactive-element-npm-2.1.2-2c713bebce-e0ed931b9c.zip +0 -0
- package/.yarn/cache/@lit-task-npm-1.0.3-48f265b3e9-790b6a2603.zip +0 -0
- package/.yarn/cache/@material-animation-npm-14.0.0-canary.53b3cad2f.0-06a813cdea-9b5190654c.zip +0 -0
- package/.yarn/cache/@material-base-npm-14.0.0-canary.53b3cad2f.0-d195c1fdc4-9f4928d115.zip +0 -0
- package/.yarn/cache/@material-button-npm-14.0.0-canary.53b3cad2f.0-d4b070f508-873295c56a.zip +0 -0
- package/.yarn/cache/@material-density-npm-14.0.0-canary.53b3cad2f.0-48c1f65059-a23f00edfe.zip +0 -0
- package/.yarn/cache/@material-dialog-npm-14.0.0-canary.53b3cad2f.0-96168fa294-c1a498b81a.zip +0 -0
- package/.yarn/cache/@material-dom-npm-14.0.0-canary.53b3cad2f.0-ac009dc871-f5817f76dd.zip +0 -0
- package/.yarn/cache/@material-elevation-npm-14.0.0-canary.53b3cad2f.0-3312f06793-2f8945c7b6.zip +0 -0
- package/.yarn/cache/@material-feature-targeting-npm-14.0.0-canary.53b3cad2f.0-a919042d50-e7a1ed68f9.zip +0 -0
- package/.yarn/cache/@material-floating-label-npm-14.0.0-canary.53b3cad2f.0-eb8f330f2f-5295dc481d.zip +0 -0
- package/.yarn/cache/@material-focus-ring-npm-14.0.0-canary.53b3cad2f.0-b22f851a2e-92273b1247.zip +0 -0
- package/.yarn/cache/@material-icon-button-npm-14.0.0-canary.53b3cad2f.0-e158d26048-19b51665f2.zip +0 -0
- package/.yarn/cache/@material-line-ripple-npm-14.0.0-canary.53b3cad2f.0-d089468db9-6518961487.zip +0 -0
- package/.yarn/cache/@material-list-npm-14.0.0-canary.53b3cad2f.0-df9ce05084-6c977f518d.zip +0 -0
- package/.yarn/cache/@material-menu-npm-14.0.0-canary.53b3cad2f.0-9489b592c8-71b6a1f4dd.zip +0 -0
- package/.yarn/cache/@material-menu-surface-npm-14.0.0-canary.53b3cad2f.0-52212f38f4-ad48e168ca.zip +0 -0
- package/.yarn/cache/@material-mwc-base-npm-0.27.0-79caf3ef2b-07af17edfc.zip +0 -0
- package/.yarn/cache/@material-mwc-button-npm-0.27.0-4b85f2b26f-2ef5cc0951.zip +0 -0
- package/.yarn/cache/@material-mwc-checkbox-npm-0.27.0-e837031d8e-ba53a6ea8c.zip +0 -0
- package/.yarn/cache/@material-mwc-dialog-npm-0.27.0-77c6071543-ffab528e8e.zip +0 -0
- package/.yarn/cache/@material-mwc-floating-label-npm-0.27.0-80e62b22c0-fbbf4f2e42.zip +0 -0
- package/.yarn/cache/@material-mwc-icon-button-npm-0.27.0-41f82f135b-7315c0735b.zip +0 -0
- package/.yarn/cache/@material-mwc-icon-npm-0.27.0-98c9e8509f-6dfa5115d5.zip +0 -0
- package/.yarn/cache/@material-mwc-line-ripple-npm-0.27.0-e6704221e0-6862ede0f4.zip +0 -0
- package/.yarn/cache/@material-mwc-list-npm-0.27.0-5344fc9de4-6c2ae4f1c6.zip +0 -0
- package/.yarn/cache/@material-mwc-menu-npm-0.27.0-7c2bb47797-126f733659.zip +0 -0
- package/.yarn/cache/@material-mwc-notched-outline-npm-0.27.0-0e0d1c4d5f-2739032f76.zip +0 -0
- package/.yarn/cache/@material-mwc-radio-npm-0.27.0-aa2098a280-0b0a0a6b99.zip +0 -0
- package/.yarn/cache/@material-mwc-ripple-npm-0.27.0-ed37672f08-9cd73fdfe4.zip +0 -0
- package/.yarn/cache/@material-mwc-textfield-npm-0.27.0-dabd704f55-978c893aca.zip +0 -0
- package/.yarn/cache/@material-notched-outline-npm-14.0.0-canary.53b3cad2f.0-ecacde98db-1a9f8db4d8.zip +0 -0
- package/.yarn/cache/@material-radio-npm-14.0.0-canary.53b3cad2f.0-c50de64d41-898554f2b3.zip +0 -0
- package/.yarn/cache/@material-ripple-npm-14.0.0-canary.53b3cad2f.0-49060bfe7e-08b71917e2.zip +0 -0
- package/.yarn/cache/@material-rtl-npm-14.0.0-canary.53b3cad2f.0-daca794b76-3c1b8b48c6.zip +0 -0
- package/.yarn/cache/@material-shape-npm-14.0.0-canary.53b3cad2f.0-5bcff722a6-6ad9b020c0.zip +0 -0
- package/.yarn/cache/@material-textfield-npm-14.0.0-canary.53b3cad2f.0-4414808dda-7072e3c9df.zip +0 -0
- package/.yarn/cache/@material-theme-npm-14.0.0-canary.53b3cad2f.0-9a24e7b046-fd44e92917.zip +0 -0
- package/.yarn/cache/@material-tokens-npm-14.0.0-canary.53b3cad2f.0-f1c87523da-efa909f861.zip +0 -0
- package/.yarn/cache/@material-touch-target-npm-14.0.0-canary.53b3cad2f.0-fa6a2d0875-dbc13cbe7a.zip +0 -0
- package/.yarn/cache/@material-typography-npm-14.0.0-canary.53b3cad2f.0-f4a58946f1-fa2671df40.zip +0 -0
- package/.yarn/cache/@types-linkify-it-npm-5.0.0-576a16b976-ec98e03aa8.zip +0 -0
- package/.yarn/cache/@types-markdown-it-npm-14.1.2-d0c4e12c49-ad66e0b377.zip +0 -0
- package/.yarn/cache/@types-mdurl-npm-2.0.0-2f4116c0b0-78746e96c6.zip +0 -0
- package/.yarn/cache/@types-trusted-types-npm-2.0.7-a07fc44f59-8e4202766a.zip +0 -0
- package/.yarn/cache/@webcomponents-webcomponentsjs-npm-2.8.0-36c07db4d2-186373c030.zip +0 -0
- package/.yarn/cache/argparse-npm-2.0.1-faff7999e6-83644b5649.zip +0 -0
- package/.yarn/cache/big-integer-npm-1.6.52-4bec75720c-6e86885787.zip +0 -0
- package/.yarn/cache/blocking-elements-npm-0.1.1-423f51c76e-9a34084405.zip +0 -0
- package/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip +0 -0
- package/.yarn/cache/entities-npm-4.5.0-7cdb83b832-853f8ebd5b.zip +0 -0
- package/.yarn/cache/fast-deep-equal-npm-3.1.3-790edcfcf5-e21a9d8d84.zip +0 -0
- package/.yarn/cache/libphonenumber-js-npm-1.12.34-cd35ce8e26-e4bb10ba42.zip +0 -0
- package/.yarn/cache/linkify-it-npm-5.0.0-adb5f9c96f-b0b86cadaf.zip +0 -0
- package/.yarn/cache/lit-element-npm-3.3.3-2f9f9e38c0-29a596fa55.zip +0 -0
- package/.yarn/cache/lit-element-npm-4.2.2-70d4af2233-554254b87c.zip +0 -0
- package/.yarn/cache/lit-html-npm-2.8.0-82f88d6ebf-2d70df0724.zip +0 -0
- package/.yarn/cache/lit-html-npm-3.3.2-4a3e00215f-7fe23502ca.zip +0 -0
- package/.yarn/cache/lit-npm-2.8.0-92bb1333a4-2480e733f7.zip +0 -0
- package/.yarn/cache/lit-npm-3.3.2-7dea58471e-2136d4beac.zip +0 -0
- package/.yarn/cache/lodash-npm-4.17.21-6382451519-eb835a2e51.zip +0 -0
- package/.yarn/cache/markdown-it-npm-14.1.0-e337d75bfe-07296b45eb.zip +0 -0
- package/.yarn/cache/mdurl-npm-2.0.0-3259713daf-880bc289ef.zip +0 -0
- package/.yarn/cache/moment-npm-2.30.1-1c51a5c631-859236bab1.zip +0 -0
- package/.yarn/cache/orderedmap-npm-2.1.1-64b8a0684f-082cf970b0.zip +0 -0
- package/.yarn/cache/prosemirror-commands-npm-1.7.1-5b2afb6640-2316c40ea2.zip +0 -0
- package/.yarn/cache/prosemirror-history-npm-1.5.0-e639d02880-6afb0e1d17.zip +0 -0
- package/.yarn/cache/prosemirror-keymap-npm-1.2.3-0e7e0c8195-0a2eed2771.zip +0 -0
- package/.yarn/cache/prosemirror-markdown-npm-1.13.2-6e2f179fd8-ce9fcb3b13.zip +0 -0
- package/.yarn/cache/prosemirror-model-npm-1.25.4-e7ee2df3df-ab5aa609df.zip +0 -0
- package/.yarn/cache/prosemirror-schema-basic-npm-1.2.4-8f943ded01-10ed022990.zip +0 -0
- package/.yarn/cache/prosemirror-schema-list-npm-1.5.1-7b138c5fed-6c7041e5b8.zip +0 -0
- package/.yarn/cache/prosemirror-state-npm-1.4.4-8b7e3a396c-1b5dba46c2.zip +0 -0
- package/.yarn/cache/prosemirror-transform-npm-1.10.5-5b3b4f5f61-6f5921e53a.zip +0 -0
- package/.yarn/cache/prosemirror-view-npm-1.41.5-39b37df338-ee47e9091a.zip +0 -0
- package/.yarn/cache/punycode.js-npm-2.3.1-9084ecbbf5-13466d7ed5.zip +0 -0
- package/.yarn/cache/rope-sequence-npm-1.3.4-3b09587e5f-95cca2f99a.zip +0 -0
- package/.yarn/cache/text-encoding-npm-0.7.0-ff0c4af052-b6109a843f.zip +0 -0
- package/.yarn/cache/tslib-npm-2.8.1-66590b21b8-e4aba30e63.zip +0 -0
- package/.yarn/cache/uc.micro-npm-2.1.0-c45282c865-3719735824.zip +0 -0
- package/.yarn/cache/uuid-encoder-npm-1.2.0-6a9a810c6d-dd06230f08.zip +0 -0
- package/.yarn/cache/uuid-npm-8.3.2-eca0baba53-5575a8a75c.zip +0 -0
- package/.yarn/cache/uuid-npm-9.0.1-39a8442bc6-39931f6da7.zip +0 -0
- package/.yarn/cache/w3c-keyname-npm-2.2.8-66d7d5317a-95bafa4c04.zip +0 -0
- package/.yarn/cache/wicg-inert-npm-3.1.3-38590e83f2-45b3cfec63.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/components/common/field-with-options.d.ts +2 -2
- package/components/common/field-with-options.js +8 -5
- package/components/common/field-with-options.js.map +1 -1
- package/components/common/field.d.ts +10 -3
- package/components/common/field.js +46 -21
- package/components/common/field.js.map +1 -1
- package/components/common/index.js +17 -1
- package/components/common/index.js.map +1 -1
- package/components/common/metadata-buttons-bar.d.ts +2 -1
- package/components/common/metadata-buttons-bar.js +113 -77
- package/components/common/metadata-buttons-bar.js.map +1 -1
- package/components/common/styles/paths.d.ts +1 -0
- package/components/common/styles/paths.js +41 -25
- package/components/common/styles/paths.js.map +1 -1
- package/components/common/utils.js +21 -11
- package/components/common/utils.js.map +1 -1
- package/components/icure-button/index.d.ts +1 -1
- package/components/icure-button/index.js +73 -29
- package/components/icure-button/index.js.map +1 -1
- package/components/icure-button-group/index.d.ts +5 -3
- package/components/icure-button-group/index.js +101 -61
- package/components/icure-button-group/index.js.map +1 -1
- package/components/icure-date-picker/index.d.ts +6 -3
- package/components/icure-date-picker/index.js +87 -43
- package/components/icure-date-picker/index.js.map +1 -1
- package/components/icure-dropdown-field/index.d.ts +5 -2
- package/components/icure-dropdown-field/index.js +82 -38
- package/components/icure-dropdown-field/index.js.map +1 -1
- package/components/icure-form/fields/button/button.js +17 -13
- package/components/icure-form/fields/button/button.js.map +1 -1
- package/components/icure-form/fields/button/index.js +17 -1
- package/components/icure-form/fields/button/index.js.map +1 -1
- package/components/icure-form/fields/button-group/checkbox.d.ts +2 -1
- package/components/icure-form/fields/button-group/checkbox.js +15 -11
- package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
- package/components/icure-form/fields/button-group/index.js +18 -2
- package/components/icure-form/fields/button-group/index.js.map +1 -1
- package/components/icure-form/fields/button-group/radio-button.d.ts +2 -1
- package/components/icure-form/fields/button-group/radio-button.js +15 -11
- package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-picker.d.ts +2 -1
- package/components/icure-form/fields/date-picker/date-picker.js +13 -9
- package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/date-time-picker.d.ts +2 -1
- package/components/icure-form/fields/date-picker/date-time-picker.js +13 -9
- package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
- package/components/icure-form/fields/date-picker/index.js +19 -3
- package/components/icure-form/fields/date-picker/index.js.map +1 -1
- package/components/icure-form/fields/date-picker/time-picker.d.ts +2 -1
- package/components/icure-form/fields/date-picker/time-picker.js +13 -9
- package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
- package/components/icure-form/fields/dropdown/dropdown-field.d.ts +1 -1
- package/components/icure-form/fields/dropdown/dropdown-field.js +15 -11
- package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
- package/components/icure-form/fields/dropdown/index.js +17 -1
- package/components/icure-form/fields/dropdown/index.js.map +1 -1
- package/components/icure-form/fields/index.js +26 -10
- package/components/icure-form/fields/index.js.map +1 -1
- package/components/icure-form/fields/items-list-field/index.js +17 -1
- package/components/icure-form/fields/items-list-field/index.js.map +1 -1
- package/components/icure-form/fields/items-list-field/items-list-field.d.ts +2 -1
- package/components/icure-form/fields/items-list-field/items-list-field.js +12 -8
- package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -1
- package/components/icure-form/fields/label/index.js +17 -1
- package/components/icure-form/fields/label/index.js.map +1 -1
- package/components/icure-form/fields/label/label.js +15 -11
- package/components/icure-form/fields/label/label.js.map +1 -1
- package/components/icure-form/fields/measure-field/index.js +17 -1
- package/components/icure-form/fields/measure-field/index.js.map +1 -1
- package/components/icure-form/fields/measure-field/measure-field.d.ts +2 -1
- package/components/icure-form/fields/measure-field/measure-field.js +14 -9
- package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
- package/components/icure-form/fields/number-field/index.js +17 -1
- package/components/icure-form/fields/number-field/index.js.map +1 -1
- package/components/icure-form/fields/number-field/number-field.d.ts +2 -1
- package/components/icure-form/fields/number-field/number-field.js +14 -9
- package/components/icure-form/fields/number-field/number-field.js.map +1 -1
- package/components/icure-form/fields/text-field/index.js +17 -1
- package/components/icure-form/fields/text-field/index.js.map +1 -1
- package/components/icure-form/fields/text-field/text-field.d.ts +2 -1
- package/components/icure-form/fields/text-field/text-field.js +26 -21
- package/components/icure-form/fields/text-field/text-field.js.map +1 -1
- package/components/icure-form/fields/token-field/index.js +17 -1
- package/components/icure-form/fields/token-field/index.js.map +1 -1
- package/components/icure-form/fields/token-field/token-field.d.ts +2 -1
- package/components/icure-form/fields/token-field/token-field.js +13 -9
- package/components/icure-form/fields/token-field/token-field.js.map +1 -1
- package/components/icure-form/fields/utils/index.js +13 -5
- package/components/icure-form/fields/utils/index.js.map +1 -1
- package/components/icure-form/index.d.ts +6 -2
- package/components/icure-form/index.js +138 -44
- package/components/icure-form/index.js.map +1 -1
- package/components/icure-form/renderer/form/form-selection-button.js +67 -27
- package/components/icure-form/renderer/form/form-selection-button.js.map +1 -1
- package/components/icure-form/renderer/form/form.js +264 -219
- package/components/icure-form/renderer/form/form.js.map +1 -1
- package/components/icure-form/renderer/index.d.ts +1 -1
- package/components/icure-form/renderer/index.js +2 -1
- package/components/icure-form/renderer/index.js.map +1 -1
- package/components/icure-label/index.js +70 -26
- package/components/icure-label/index.js.map +1 -1
- package/components/icure-text-field/index.d.ts +8 -2
- package/components/icure-text-field/index.js +309 -145
- package/components/icure-text-field/index.js.map +1 -1
- package/components/icure-text-field/plugin/caret-fix-plugin.js +7 -3
- package/components/icure-text-field/plugin/caret-fix-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/has-content-class-plugin.js +7 -3
- package/components/icure-text-field/plugin/has-content-class-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/mask-plugin.js +11 -7
- package/components/icure-text-field/plugin/mask-plugin.js.map +1 -1
- package/components/icure-text-field/plugin/regexp-plugin.js +9 -5
- package/components/icure-text-field/plugin/regexp-plugin.js.map +1 -1
- package/components/icure-text-field/prosemirror-commands.js +14 -10
- package/components/icure-text-field/prosemirror-commands.js.map +1 -1
- package/components/icure-text-field/prosemirror-utils.js +4 -1
- package/components/icure-text-field/prosemirror-utils.js.map +1 -1
- package/components/icure-text-field/schema/common-marks.js +7 -3
- package/components/icure-text-field/schema/common-marks.js.map +1 -1
- package/components/icure-text-field/schema/date-time-schema.js +8 -3
- package/components/icure-text-field/schema/date-time-schema.js.map +1 -1
- package/components/icure-text-field/schema/decimal-schema.js +4 -1
- package/components/icure-text-field/schema/decimal-schema.js.map +1 -1
- package/components/icure-text-field/schema/index.js +20 -17
- package/components/icure-text-field/schema/index.js.map +1 -1
- package/components/icure-text-field/schema/items-list-schema.js +6 -3
- package/components/icure-text-field/schema/items-list-schema.js.map +1 -1
- package/components/icure-text-field/schema/markdown-schema.js +10 -28
- package/components/icure-text-field/schema/markdown-schema.js.map +1 -1
- package/components/icure-text-field/schema/measure-schema.js +12 -6
- package/components/icure-text-field/schema/measure-schema.js.map +1 -1
- package/components/icure-text-field/schema/token-schema.js +8 -5
- package/components/icure-text-field/schema/token-schema.js.map +1 -1
- package/components/icure-text-field/schema/utils.js +6 -2
- package/components/icure-text-field/schema/utils.js.map +1 -1
- package/components/icure-text-field/selection-companion.js +5 -1
- package/components/icure-text-field/selection-companion.js.map +1 -1
- package/components/icure-text-field/suggestion-palette.js +10 -3
- package/components/icure-text-field/suggestion-palette.js.map +1 -1
- package/components/index.js +21 -5
- package/components/index.js.map +1 -1
- package/components/model/index.js +46 -22
- package/components/model/index.js.map +1 -1
- package/components/themes/default/index.js +32 -30
- package/components/themes/default/index.js.map +1 -1
- package/components/themes/icure-blue/index.js +104 -47
- package/components/themes/icure-blue/index.js.map +1 -1
- package/components/themes/kendo/index.js +55 -49
- package/components/themes/kendo/index.js.map +1 -1
- package/conversion/ckmeans-grouping.js +10 -3
- package/conversion/ckmeans-grouping.js.map +1 -1
- package/conversion/ckmeans.js +3 -1
- package/conversion/ckmeans.js.map +1 -1
- package/conversion/icure-convert.js +21 -18
- package/conversion/icure-convert.js.map +1 -1
- package/generic/index.js +17 -1
- package/generic/index.js.map +1 -1
- package/generic/model.d.ts +5 -4
- package/generic/model.js +2 -1
- package/generic/model.js.map +1 -1
- package/icure/form-values-container.d.ts +21 -13
- package/icure/form-values-container.js +265 -163
- package/icure/form-values-container.js.map +1 -1
- package/icure/icure-utils.js +21 -10
- package/icure/icure-utils.js.map +1 -1
- package/icure/index.js +18 -2
- package/icure/index.js.map +1 -1
- package/icure/model.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +19 -1
- package/index.js.map +1 -1
- package/package.json +16 -13
- package/utils/code-utils.js +19 -11
- package/utils/code-utils.js.map +1 -1
- package/utils/dates.js +20 -9
- package/utils/dates.js.map +1 -1
- package/utils/fields-values-provider.d.ts +1 -1
- package/utils/fields-values-provider.js +28 -11
- package/utils/fields-values-provider.js.map +1 -1
- package/utils/interpreter.d.ts +2 -3
- package/utils/interpreter.js +16 -3
- package/utils/interpreter.js.map +1 -1
- package/utils/languages.js +8 -3
- package/utils/languages.js.map +1 -1
- package/utils/markdown.js +11 -6
- package/utils/markdown.js.map +1 -1
- package/utils/no-lodash.js +8 -3
- package/utils/no-lodash.js.map +1 -1
- package/utils/primitive.d.ts +1 -1
- package/utils/primitive.js +16 -11
- package/utils/primitive.js.map +1 -1
- package/utils/form-value-container.d.ts +0 -3
- package/utils/form-value-container.js +0 -30
- package/utils/form-value-container.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,15 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
9
|
});
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ContactFormValuesContainer = exports.BridgedFormValuesContainer = void 0;
|
|
13
|
+
const api_1 = require("@icure/api");
|
|
14
|
+
const no_lodash_1 = require("../utils/no-lodash");
|
|
15
|
+
const icure_utils_1 = require("./icure-utils");
|
|
16
|
+
const primitive_1 = require("../utils/primitive");
|
|
17
|
+
const dates_1 = require("../utils/dates");
|
|
18
|
+
const uuid_1 = require("uuid");
|
|
19
|
+
const code_utils_1 = require("../utils/code-utils");
|
|
17
20
|
function notify(l, fvc) {
|
|
18
|
-
//console.log('Notifying', l, fvc.toString())
|
|
19
21
|
l(fvc);
|
|
20
22
|
}
|
|
21
23
|
/** This class is a bridge between the ICure API and the generic FormValuesContainer interface.
|
|
@@ -37,23 +39,24 @@ function notify(l, fvc) {
|
|
|
37
39
|
*
|
|
38
40
|
* This class is fairly generic and can be used as an inspiration or subclassed for other bridges
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
class BridgedFormValuesContainer {
|
|
41
43
|
toString() {
|
|
42
44
|
return `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Creates an instance of BridgedFormValuesContainer.
|
|
46
48
|
* @param responsible The id of the data owner responsible for the creation of the values
|
|
47
|
-
* @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
|
|
48
49
|
* @param contactFormValuesContainer The wrapped ContactFormValuesContainer
|
|
49
50
|
* @param interpreter A function that can interpret formulas
|
|
51
|
+
* @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
|
|
52
|
+
* @param initialValuesProvider A lambda that provides the initial values of the form
|
|
50
53
|
* @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId
|
|
51
54
|
* @param validatorsProvider A function that provides the validators for a given anchorId and templateId
|
|
52
55
|
* @param language The language in which the values are displayed
|
|
53
56
|
* @param changeListeners The listeners that will be notified when the values change
|
|
54
|
-
* @param
|
|
57
|
+
* @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
|
|
55
58
|
*/
|
|
56
|
-
constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = []) {
|
|
59
|
+
constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = [], interpreterContext = {}) {
|
|
57
60
|
this.responsible = responsible;
|
|
58
61
|
this.interpreter = interpreter;
|
|
59
62
|
this.initialValuesProvider = initialValuesProvider;
|
|
@@ -61,22 +64,28 @@ export class BridgedFormValuesContainer {
|
|
|
61
64
|
this.validatorsProvider = validatorsProvider;
|
|
62
65
|
this.language = language;
|
|
63
66
|
this.changeListeners = changeListeners;
|
|
64
|
-
this.
|
|
67
|
+
this.interpreterContext = interpreterContext;
|
|
68
|
+
this._id = (0, uuid_1.v4)();
|
|
65
69
|
console.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`);
|
|
66
70
|
//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
|
|
67
71
|
this.contactFormValuesContainer = contactFormValuesContainer;
|
|
68
|
-
this.mutateAndNotify = (newContactFormValuesContainer) => {
|
|
72
|
+
this.mutateAndNotify = (newContactFormValuesContainer) => __awaiter(this, void 0, void 0, function* () {
|
|
69
73
|
newContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify);
|
|
70
|
-
const newBridgedFormValueContainer = new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, this.changeListeners);
|
|
74
|
+
const newBridgedFormValueContainer = yield new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, this.changeListeners, this.interpreterContext).init();
|
|
71
75
|
this.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer));
|
|
72
76
|
return newBridgedFormValueContainer;
|
|
73
|
-
};
|
|
77
|
+
});
|
|
74
78
|
this.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify);
|
|
75
79
|
this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
}
|
|
81
|
+
init() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
if (this.contactFormValuesContainer.mustBeInitialised()) {
|
|
84
|
+
yield this.computeInitialValues();
|
|
85
|
+
}
|
|
86
|
+
yield this.computeDependentValues();
|
|
87
|
+
return this;
|
|
88
|
+
});
|
|
80
89
|
}
|
|
81
90
|
getLabel() {
|
|
82
91
|
return this.contactFormValuesContainer.getLabel();
|
|
@@ -93,6 +102,13 @@ export class BridgedFormValuesContainer {
|
|
|
93
102
|
unregisterChangeListener(listener) {
|
|
94
103
|
this.changeListeners = this.changeListeners.filter((l) => l !== listener);
|
|
95
104
|
}
|
|
105
|
+
getDefaultValue(label) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
var _a;
|
|
108
|
+
const formula = (_a = this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).find(({ metadata }) => metadata.label === label)) === null || _a === void 0 ? void 0 : _a.formula;
|
|
109
|
+
return formula ? this.convertRawValue(yield this.compute(formula)) : undefined;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
96
112
|
getValues(revisionsFilter) {
|
|
97
113
|
return Object.entries(this.contactFormValuesContainer.getValues((id, history) => revisionsFilter(id, history
|
|
98
114
|
.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)
|
|
@@ -104,7 +120,7 @@ export class BridgedFormValuesContainer {
|
|
|
104
120
|
value: {
|
|
105
121
|
label: sm.label,
|
|
106
122
|
owner: sm.responsible,
|
|
107
|
-
tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(codeStubToCode),
|
|
123
|
+
tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(icure_utils_1.codeStubToCode),
|
|
108
124
|
valueDate: sm.valueDate,
|
|
109
125
|
},
|
|
110
126
|
});
|
|
@@ -116,10 +132,10 @@ export class BridgedFormValuesContainer {
|
|
|
116
132
|
modified,
|
|
117
133
|
value: {
|
|
118
134
|
content: Object.entries((_a = s.content) !== null && _a !== void 0 ? _a : {}).reduce((acc, [lng, cnt]) => {
|
|
119
|
-
const converted = contentToPrimitiveType(lng, cnt);
|
|
135
|
+
const converted = (0, icure_utils_1.contentToPrimitiveType)(lng, cnt);
|
|
120
136
|
return converted ? Object.assign(Object.assign({}, acc), { [lng]: converted }) : acc;
|
|
121
137
|
}, {}),
|
|
122
|
-
codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(codeStubToCode),
|
|
138
|
+
codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(icure_utils_1.codeStubToCode),
|
|
123
139
|
},
|
|
124
140
|
});
|
|
125
141
|
}) });
|
|
@@ -136,75 +152,114 @@ export class BridgedFormValuesContainer {
|
|
|
136
152
|
tags: s.tags,
|
|
137
153
|
discordantMetadata: () => {
|
|
138
154
|
var _a, _b;
|
|
139
|
-
return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = anyDateToDate(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = anyDateToDate(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
|
|
155
|
+
return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = (0, dates_1.anyDateToDate)(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = (0, dates_1.anyDateToDate)(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
|
|
140
156
|
},
|
|
141
157
|
},
|
|
142
158
|
})) })), {});
|
|
143
159
|
}
|
|
160
|
+
convertRawValue(rawValue) {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
if (rawValue && typeof rawValue === 'object' && 'content' in rawValue) {
|
|
163
|
+
return rawValue;
|
|
164
|
+
}
|
|
165
|
+
if (Array.isArray(rawValue)) {
|
|
166
|
+
return rawValue.reduce((acc, it, idx) => {
|
|
167
|
+
var _a, _b, _c, _d, _e;
|
|
168
|
+
const fv = this.convertRawValue(it);
|
|
169
|
+
if (fv === undefined) {
|
|
170
|
+
return acc;
|
|
171
|
+
}
|
|
172
|
+
acc.codes = [...((_a = fv.codes) !== null && _a !== void 0 ? _a : []), ...((_b = acc.codes) !== null && _b !== void 0 ? _b : [])];
|
|
173
|
+
acc.content['*'] = ((_c = fv.content['*']) === null || _c === void 0 ? void 0 : _c.value)
|
|
174
|
+
? Object.assign(Object.assign({}, acc.content['*']), { [(_e = ((_d = fv.codes) !== null && _d !== void 0 ? _d : [])[0].id) !== null && _e !== void 0 ? _e : idx.toString()]: fv.content['*'].value }) : acc.content['*'];
|
|
175
|
+
return acc;
|
|
176
|
+
}, { content: { '*': { type: 'compound', value: {} } } });
|
|
177
|
+
}
|
|
178
|
+
if (typeof rawValue === 'number') {
|
|
179
|
+
return { content: { '*': { type: 'number', value: rawValue } } };
|
|
180
|
+
}
|
|
181
|
+
if (typeof rawValue === 'string') {
|
|
182
|
+
return { content: { '*': { type: 'string', value: rawValue } } };
|
|
183
|
+
}
|
|
184
|
+
if (typeof rawValue === 'boolean') {
|
|
185
|
+
return { content: { '*': { type: 'boolean', value: rawValue } } };
|
|
186
|
+
}
|
|
187
|
+
if (rawValue instanceof Date) {
|
|
188
|
+
return { content: { '*': { type: 'timestamp', value: (0, dates_1.dateToFuzzyDate)(rawValue) } } };
|
|
189
|
+
}
|
|
190
|
+
if (rawValue && typeof rawValue === 'object' && 'unit' in rawValue && 'value' in rawValue && typeof rawValue.value === 'number') {
|
|
191
|
+
return { content: { '*': { type: 'measure', value: rawValue.value, unit: (_b = (_a = rawValue.unit) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' } } };
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
144
195
|
//This method mutates the BridgedFormValuesContainer but can only be called from the constructor
|
|
145
196
|
computeInitialValues() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
if (this.contactFormValuesContainer.rootForm.formTemplateId) {
|
|
199
|
+
yield Promise.all(this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
|
|
200
|
+
var _b;
|
|
201
|
+
try {
|
|
202
|
+
const currentValue = this.getValues(revisionsFilter);
|
|
203
|
+
if (!currentValue || !Object.keys(currentValue).length) {
|
|
204
|
+
const newValue = this.convertRawValue((yield this.compute(formula)));
|
|
205
|
+
if (newValue !== undefined) {
|
|
206
|
+
const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
|
|
207
|
+
if (newValue && !newValue.content[lng] && newValue.content['*']) {
|
|
208
|
+
newValue.content[lng] = newValue.content['*'];
|
|
209
|
+
}
|
|
210
|
+
if (newValue) {
|
|
211
|
+
delete newValue.content['*'];
|
|
212
|
+
}
|
|
213
|
+
setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc) => {
|
|
214
|
+
const currentContact = this.contactFormValuesContainer.currentContact;
|
|
215
|
+
this.contactFormValuesContainer = fvc;
|
|
216
|
+
if (this.contact === currentContact) {
|
|
217
|
+
this.contact = fvc.currentContact;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
catch (e) {
|
|
224
|
+
console.log(`Error while computing formula : ${formula}`, e);
|
|
225
|
+
}
|
|
226
|
+
})));
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
//This method mutates the BridgedFormValuesContainer but can only be called from the constructor
|
|
231
|
+
computeDependentValues() {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
if (this.contactFormValuesContainer.rootForm.formTemplateId) {
|
|
234
|
+
yield Promise.all(this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
|
|
235
|
+
var _b;
|
|
236
|
+
try {
|
|
237
|
+
const currentValue = this.getValues(revisionsFilter);
|
|
238
|
+
const newValue = this.convertRawValue((yield this.compute(formula)));
|
|
239
|
+
if (newValue !== undefined || currentValue != undefined) {
|
|
240
|
+
const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
|
|
155
241
|
if (newValue && !newValue.content[lng] && newValue.content['*']) {
|
|
156
242
|
newValue.content[lng] = newValue.content['*'];
|
|
157
243
|
}
|
|
158
244
|
if (newValue) {
|
|
159
245
|
delete newValue.content['*'];
|
|
160
246
|
}
|
|
161
|
-
|
|
247
|
+
const interceptor = (fvc) => {
|
|
162
248
|
const currentContact = this.contactFormValuesContainer.currentContact;
|
|
163
249
|
this.contactFormValuesContainer = fvc;
|
|
164
250
|
if (this.contact === currentContact) {
|
|
165
251
|
this.contact = fvc.currentContact;
|
|
166
252
|
}
|
|
167
|
-
}
|
|
253
|
+
};
|
|
254
|
+
setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, interceptor);
|
|
168
255
|
}
|
|
169
256
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
console.log(`Error while computing formula : ${formula}`, e);
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
//This method mutates the BridgedFormValuesContainer but can only be called from the constructor
|
|
178
|
-
computeDependentValues() {
|
|
179
|
-
if (this.contactFormValuesContainer.rootForm.formTemplateId) {
|
|
180
|
-
this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {
|
|
181
|
-
var _a;
|
|
182
|
-
try {
|
|
183
|
-
const currentValue = this.getValues(revisionsFilter);
|
|
184
|
-
const newValue = this.compute(formula);
|
|
185
|
-
if (newValue !== undefined || currentValue != undefined) {
|
|
186
|
-
const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
|
|
187
|
-
if (newValue && !newValue.content[lng] && newValue.content['*']) {
|
|
188
|
-
newValue.content[lng] = newValue.content['*'];
|
|
189
|
-
}
|
|
190
|
-
if (newValue) {
|
|
191
|
-
delete newValue.content['*'];
|
|
192
|
-
}
|
|
193
|
-
const interceptor = (fvc) => {
|
|
194
|
-
const currentContact = this.contactFormValuesContainer.currentContact;
|
|
195
|
-
this.contactFormValuesContainer = fvc;
|
|
196
|
-
if (this.contact === currentContact) {
|
|
197
|
-
this.contact = fvc.currentContact;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, interceptor);
|
|
257
|
+
catch (e) {
|
|
258
|
+
console.log(`Error while computing formula : ${formula}`, e);
|
|
201
259
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
260
|
+
})));
|
|
261
|
+
}
|
|
262
|
+
});
|
|
208
263
|
}
|
|
209
264
|
setValue(label, language, fv, id, metadata) {
|
|
210
265
|
setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata);
|
|
@@ -224,76 +279,111 @@ export class BridgedFormValuesContainer {
|
|
|
224
279
|
return this.getValues((id, history) => { var _a, _b, _c; return (((_b = (_a = history === null || history === void 0 ? void 0 : history[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.label) && key === history[0].value.label ? [(_c = history === null || history === void 0 ? void 0 : history[0]) === null || _c === void 0 ? void 0 : _c.revision] : []); });
|
|
225
280
|
}
|
|
226
281
|
compute(formula, sandbox) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
|
|
235
|
-
return primitive && parsePrimitive(primitive);
|
|
236
|
-
};
|
|
237
|
-
const log = console.log;
|
|
238
|
-
const native = {
|
|
239
|
-
parseInt: parseInt,
|
|
240
|
-
parseFloat: parseFloat,
|
|
241
|
-
Date: Date,
|
|
242
|
-
Math: Math,
|
|
243
|
-
Number: Number,
|
|
244
|
-
String: String,
|
|
245
|
-
Boolean: Boolean,
|
|
246
|
-
Array: Array,
|
|
247
|
-
Object: Object,
|
|
248
|
-
parseContent,
|
|
249
|
-
validate: {
|
|
250
|
-
notBlank: (self, label) => {
|
|
251
|
-
var _a, _b, _c;
|
|
252
|
-
const value = parseContent((_b = (_a = self[label]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content);
|
|
253
|
-
return !!((_c = value === null || value === void 0 ? void 0 : value.trim()) === null || _c === void 0 ? void 0 : _c.length);
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
log,
|
|
257
|
-
};
|
|
258
|
-
const proxy = new Proxy({}, {
|
|
259
|
-
has: (target, key) => { var _a; return !!native[key] || key === 'self' || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
|
|
260
|
-
get: (target, key) => {
|
|
261
|
-
if (key === 'undefined') {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
var _a;
|
|
284
|
+
// noinspection JSUnusedGlobalSymbols
|
|
285
|
+
const parseContent = (content, toString = false) => {
|
|
286
|
+
var _a, _b;
|
|
287
|
+
if (!content) {
|
|
262
288
|
return undefined;
|
|
263
289
|
}
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
290
|
+
const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
|
|
291
|
+
return primitive && (0, primitive_1.parsePrimitive)(primitive, toString);
|
|
292
|
+
};
|
|
293
|
+
const text = (item) => {
|
|
294
|
+
if (!item) {
|
|
295
|
+
return undefined;
|
|
267
296
|
}
|
|
268
|
-
|
|
269
|
-
|
|
297
|
+
const items = Array.isArray(item) ? item : [item];
|
|
298
|
+
return items
|
|
299
|
+
.map((it) => { var _a; return (_a = parseContent(it.content, true)) === null || _a === void 0 ? void 0 : _a.toString(); })
|
|
300
|
+
.filter((it) => !!it)
|
|
301
|
+
.join(', ');
|
|
302
|
+
};
|
|
303
|
+
const log = console.log;
|
|
304
|
+
const native = {
|
|
305
|
+
parseInt: parseInt,
|
|
306
|
+
parseFloat: parseFloat,
|
|
307
|
+
Date: Date,
|
|
308
|
+
Math: Math,
|
|
309
|
+
Number: Number,
|
|
310
|
+
String: String,
|
|
311
|
+
Boolean: Boolean,
|
|
312
|
+
Array: Array,
|
|
313
|
+
Object: Object,
|
|
314
|
+
hasOption: (it, option) => { var _a; return it && ((_a = it.codes) === null || _a === void 0 ? void 0 : _a.some((c) => { var _a, _b; return c.id === option || ((_b = (_a = c.id) === null || _a === void 0 ? void 0 : _a.split('|')) === null || _b === void 0 ? void 0 : _b[1]) === option; })); },
|
|
315
|
+
score: (it) => {
|
|
316
|
+
var _a;
|
|
317
|
+
return it
|
|
318
|
+
? ((_a = it.codes) !== null && _a !== void 0 ? _a : []).reduce((acc, c) => {
|
|
319
|
+
var _a, _b, _c;
|
|
320
|
+
try {
|
|
321
|
+
return acc + parseInt((_c = (_b = (_a = c.id) === null || _a === void 0 ? void 0 : _a.split('|')) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : '0');
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
return acc;
|
|
325
|
+
}
|
|
326
|
+
}, 0)
|
|
327
|
+
: 0;
|
|
328
|
+
},
|
|
329
|
+
parseContent,
|
|
330
|
+
validate: {
|
|
331
|
+
notBlank: (self, label) => {
|
|
332
|
+
var _a, _b, _c;
|
|
333
|
+
const value = parseContent((_b = (_a = self[label]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content);
|
|
334
|
+
return !!((_c = value === null || value === void 0 ? void 0 : value.trim()) === null || _c === void 0 ? void 0 : _c.length);
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
text,
|
|
338
|
+
log,
|
|
339
|
+
Promise,
|
|
340
|
+
};
|
|
341
|
+
const proxy = new Proxy({}, {
|
|
342
|
+
has: (target, key) => { var _a; return !!native[key] || key === 'self' || !!this.interpreterContext[key] || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
|
|
343
|
+
get: (target, key) => {
|
|
344
|
+
if (key === 'undefined') {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
const nativeValue = native[key];
|
|
348
|
+
if (!!nativeValue) {
|
|
349
|
+
return nativeValue;
|
|
350
|
+
}
|
|
351
|
+
return key === 'self' ? proxy : this.interpreterContext[key] ? this.interpreterContext[key]() : Object.values(this.getVersionedValuesForKey(key)).map((v) => { var _a; return (_a = v[0]) === null || _a === void 0 ? void 0 : _a.value; });
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
|
|
270
355
|
});
|
|
271
|
-
return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
|
|
272
356
|
}
|
|
273
357
|
getChildren() {
|
|
274
|
-
|
|
275
|
-
.getChildren()
|
|
276
|
-
.
|
|
277
|
-
|
|
278
|
-
|
|
358
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
const children = yield Promise.all((yield this.contactFormValuesContainer.getChildren()).map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, [], this.interpreterContext).init()));
|
|
360
|
+
console.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider);
|
|
361
|
+
return children;
|
|
362
|
+
});
|
|
279
363
|
}
|
|
280
364
|
getValidationErrors() {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
return
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
+
if (this.contactFormValuesContainer.rootForm.formTemplateId) {
|
|
367
|
+
// noinspection ES6MissingAwait
|
|
368
|
+
return yield this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).reduce((resPromise_1, _a) => __awaiter(this, [resPromise_1, _a], void 0, function* (resPromise, { metadata, validators }) {
|
|
369
|
+
return yield validators.reduce((resPromise_2, _a) => __awaiter(this, [resPromise_2, _a], void 0, function* (resPromise, { validation, message }) {
|
|
370
|
+
const res = yield resPromise;
|
|
371
|
+
try {
|
|
372
|
+
if (!(yield this.compute(validation))) {
|
|
373
|
+
res.push([metadata, message]);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (e) {
|
|
377
|
+
console.log(`Error while computing validation : ${validation}`, e);
|
|
378
|
+
}
|
|
379
|
+
return res;
|
|
380
|
+
}), resPromise);
|
|
381
|
+
}), Promise.resolve([]));
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return [];
|
|
385
|
+
}
|
|
386
|
+
});
|
|
297
387
|
}
|
|
298
388
|
addChild(anchorId, templateId, label) {
|
|
299
389
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -310,6 +400,7 @@ export class BridgedFormValuesContainer {
|
|
|
310
400
|
return this;
|
|
311
401
|
}
|
|
312
402
|
}
|
|
403
|
+
exports.BridgedFormValuesContainer = BridgedFormValuesContainer;
|
|
313
404
|
/**
|
|
314
405
|
* This class is a form values container that uses a hierarchy of forms as a data source. The actual values are extracted from the services of the contacts.
|
|
315
406
|
* The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.
|
|
@@ -318,7 +409,7 @@ export class BridgedFormValuesContainer {
|
|
|
318
409
|
* Each ContactFormValuesContainer has a reference to its `rootForm`.
|
|
319
410
|
* The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.
|
|
320
411
|
*/
|
|
321
|
-
|
|
412
|
+
class ContactFormValuesContainer {
|
|
322
413
|
toString() {
|
|
323
414
|
return `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`;
|
|
324
415
|
}
|
|
@@ -343,7 +434,7 @@ export class ContactFormValuesContainer {
|
|
|
343
434
|
return [this.rootForm].concat(this.children.flatMap((c) => c.allForms()));
|
|
344
435
|
}
|
|
345
436
|
constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, formRecycler, changeListeners = [], initialised = true) {
|
|
346
|
-
this._id =
|
|
437
|
+
this._id = (0, uuid_1.v4)();
|
|
347
438
|
this._initialised = false;
|
|
348
439
|
console.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`);
|
|
349
440
|
if (contactsHistory.includes(currentContact)) {
|
|
@@ -351,13 +442,26 @@ export class ContactFormValuesContainer {
|
|
|
351
442
|
}
|
|
352
443
|
this.rootForm = rootForm;
|
|
353
444
|
this.currentContact = currentContact;
|
|
354
|
-
this.contactsHistory = sortedBy(contactsHistory, 'created', 'desc');
|
|
445
|
+
this.contactsHistory = (0, no_lodash_1.sortedBy)(contactsHistory, 'created', 'desc');
|
|
355
446
|
this.children = children;
|
|
356
447
|
this.serviceFactory = serviceFactory;
|
|
357
448
|
this.formFactory = formFactory;
|
|
358
449
|
this.formRecycler = formRecycler;
|
|
359
450
|
this.changeListeners = changeListeners;
|
|
360
451
|
this._initialised = initialised;
|
|
452
|
+
this.indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {
|
|
453
|
+
var _a, _b, _c;
|
|
454
|
+
const services = (_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
|
|
455
|
+
var _a, _b;
|
|
456
|
+
return s.id
|
|
457
|
+
? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
|
|
458
|
+
revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null,
|
|
459
|
+
modified: ctc.created,
|
|
460
|
+
value: s,
|
|
461
|
+
}) }) : acc;
|
|
462
|
+
}, acc)) !== null && _c !== void 0 ? _c : acc;
|
|
463
|
+
return services;
|
|
464
|
+
}, {});
|
|
361
465
|
this.synchronise();
|
|
362
466
|
}
|
|
363
467
|
synchronise() {
|
|
@@ -404,10 +508,17 @@ export class ContactFormValuesContainer {
|
|
|
404
508
|
this.changeListeners = this.changeListeners.filter((l) => l !== listener);
|
|
405
509
|
}
|
|
406
510
|
getChildren() {
|
|
407
|
-
return this
|
|
511
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
512
|
+
return this.children;
|
|
513
|
+
});
|
|
408
514
|
}
|
|
409
515
|
getValidationErrors() {
|
|
410
|
-
|
|
516
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
517
|
+
throw new Error('Validation not supported at contact level');
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
getDefaultValue() {
|
|
521
|
+
return Promise.resolve(undefined);
|
|
411
522
|
}
|
|
412
523
|
getValues(revisionsFilter) {
|
|
413
524
|
return Object.entries(this.getServicesInHistory(revisionsFilter)).reduce((acc, [id, history]) => history.length
|
|
@@ -447,11 +558,11 @@ export class ContactFormValuesContainer {
|
|
|
447
558
|
(meta.valueDate && service.valueDate !== meta.valueDate) ||
|
|
448
559
|
(meta.codes && service.codes !== meta.codes) ||
|
|
449
560
|
(meta.tags && service.tags !== meta.tags)) {
|
|
450
|
-
const newService = new Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
561
|
+
const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
451
562
|
meta.responsible && (newService.responsible = meta.responsible);
|
|
452
563
|
meta.valueDate && (newService.valueDate = meta.valueDate);
|
|
453
|
-
meta.codes && (newService.codes = normalizeCodes(meta.codes));
|
|
454
|
-
meta.tags && (newService.tags = normalizeCodes(meta.tags));
|
|
564
|
+
meta.codes && (newService.codes = (0, code_utils_1.normalizeCodes)(meta.codes));
|
|
565
|
+
meta.tags && (newService.tags = (0, code_utils_1.normalizeCodes)(meta.tags));
|
|
455
566
|
const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => (s.id === service.id ? newService : s)) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
|
|
456
567
|
this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
|
|
457
568
|
}
|
|
@@ -464,9 +575,9 @@ export class ContactFormValuesContainer {
|
|
|
464
575
|
}
|
|
465
576
|
console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
|
|
466
577
|
const newContent = (_c = value === null || value === void 0 ? void 0 : value.content) === null || _c === void 0 ? void 0 : _c[language];
|
|
467
|
-
const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? normalizeCodes(value.codes) : [];
|
|
468
|
-
if (!isContentEqual((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !areCodesEqual(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
|
|
469
|
-
const newService = new Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
578
|
+
const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? (0, code_utils_1.normalizeCodes)(value.codes) : [];
|
|
579
|
+
if (!(0, icure_utils_1.isContentEqual)((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !(0, icure_utils_1.areCodesEqual)(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
|
|
580
|
+
const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
470
581
|
const newContents = newContent
|
|
471
582
|
? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
|
|
472
583
|
if (!newContent) {
|
|
@@ -494,7 +605,7 @@ export class ContactFormValuesContainer {
|
|
|
494
605
|
if (metadata) {
|
|
495
606
|
newService.responsible = (_m = metadata.responsible) !== null && _m !== void 0 ? _m : newService.responsible;
|
|
496
607
|
newService.valueDate = (_o = metadata.valueDate) !== null && _o !== void 0 ? _o : newService.valueDate;
|
|
497
|
-
newService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags;
|
|
608
|
+
newService.tags = metadata.tags ? (0, code_utils_1.normalizeCodes)(metadata.tags) : newService.tags;
|
|
498
609
|
newService.label = (_p = metadata.label) !== null && _p !== void 0 ? _p : newService.label;
|
|
499
610
|
}
|
|
500
611
|
newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_q = this.currentContact.subContacts) !== null && _q !== void 0 ? _q : []).some((sc) => sc.formId === this.rootForm.id)
|
|
@@ -520,13 +631,15 @@ export class ContactFormValuesContainer {
|
|
|
520
631
|
const service = this.getServiceInCurrentContact(serviceId);
|
|
521
632
|
if (service) {
|
|
522
633
|
const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => s.id === serviceId
|
|
523
|
-
? new Service(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
|
|
634
|
+
? new api_1.Service(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
|
|
524
635
|
: s) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
|
|
525
636
|
this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
|
|
526
637
|
}
|
|
527
638
|
}
|
|
528
639
|
compute() {
|
|
529
|
-
|
|
640
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
641
|
+
throw new Error('Compute not supported at contact level');
|
|
642
|
+
});
|
|
530
643
|
}
|
|
531
644
|
/** returns all services in history that match a selector
|
|
532
645
|
*
|
|
@@ -534,20 +647,8 @@ export class ContactFormValuesContainer {
|
|
|
534
647
|
* @param revisionsFilter
|
|
535
648
|
*/
|
|
536
649
|
getServicesInHistory(revisionsFilter) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
const services = (_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
|
|
540
|
-
var _a, _b;
|
|
541
|
-
return s.id
|
|
542
|
-
? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
|
|
543
|
-
revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null,
|
|
544
|
-
modified: ctc.created,
|
|
545
|
-
value: s,
|
|
546
|
-
}) }) : acc;
|
|
547
|
-
}, acc)) !== null && _c !== void 0 ? _c : acc;
|
|
548
|
-
return services;
|
|
549
|
-
}, {}); //index services in history by id
|
|
550
|
-
return Object.entries(indexedServices)
|
|
650
|
+
//index services in history by id
|
|
651
|
+
return Object.entries(this.indexedServices)
|
|
551
652
|
.map(([id, history]) => {
|
|
552
653
|
const keptRevisions = revisionsFilter(id, history.map(({ revision, modified, value: s }) => {
|
|
553
654
|
var _a, _b;
|
|
@@ -591,6 +692,7 @@ export class ContactFormValuesContainer {
|
|
|
591
692
|
});
|
|
592
693
|
}
|
|
593
694
|
}
|
|
695
|
+
exports.ContactFormValuesContainer = ContactFormValuesContainer;
|
|
594
696
|
const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata, changeListenersOverrider) => {
|
|
595
697
|
var _a, _b;
|
|
596
698
|
const value = fv === null || fv === void 0 ? void 0 : fv.content[language];
|
|
@@ -599,7 +701,7 @@ const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, met
|
|
|
599
701
|
codes: (_a = fv === null || fv === void 0 ? void 0 : fv.codes) !== null && _a !== void 0 ? _a : [],
|
|
600
702
|
content: value
|
|
601
703
|
? {
|
|
602
|
-
[language]: primitiveTypeToContent(language, value),
|
|
704
|
+
[language]: (0, icure_utils_1.primitiveTypeToContent)(language, value),
|
|
603
705
|
}
|
|
604
706
|
: undefined,
|
|
605
707
|
}, id, metadata
|