@icure/form 2.0.1 → 2.0.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.
Binary file
@@ -1134,10 +1134,11 @@ class IcureDatePickerField extends common_1.Field {
1134
1134
  document.removeEventListener('click', this._handleClickOutside.bind(this));
1135
1135
  }
1136
1136
  getValueFromProvider() {
1137
- var _a, _b, _c, _d, _e;
1137
+ var _a, _b, _c, _d, _e, _f;
1138
1138
  const [, versions] = (0, utils_2.extractSingleValue)((_a = this.valueProvider) === null || _a === void 0 ? void 0 : _a.call(this));
1139
1139
  if (versions) {
1140
- const valueForLanguage = (_e = (_d = (_c = (_b = versions[0]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d[this.language()]) !== null && _e !== void 0 ? _e : '';
1140
+ const content = (_c = (_b = versions[0]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.content;
1141
+ const valueForLanguage = (_f = (_e = (_d = content === null || content === void 0 ? void 0 : content[this.language()]) !== null && _d !== void 0 ? _d : content === null || content === void 0 ? void 0 : content[this.defaultLanguage]) !== null && _e !== void 0 ? _e : content === null || content === void 0 ? void 0 : content['*']) !== null && _f !== void 0 ? _f : content === null || content === void 0 ? void 0 : content[Object.keys(content)[0]];
1141
1142
  if (valueForLanguage && (valueForLanguage.type === 'timestamp' || valueForLanguage.type === 'datetime') && valueForLanguage.value) {
1142
1143
  const date = (0, dates_1.anyDateToDate)(valueForLanguage.value);
1143
1144
  return date ? (0, date_fns_1.format)(date, 'dd/MM/yyyy') : '';
@@ -1181,7 +1182,7 @@ class IcureDatePickerField extends common_1.Field {
1181
1182
  const fuzzyDateValue = parseInt(parts[0]) * 10000 + parseInt(parts[1]) * 100 + parseInt(parts[2]);
1182
1183
  const [valueId] = (_b = this.getValueFromProvider()) !== null && _b !== void 0 ? _b : '';
1183
1184
  (_c = this.handleValueChanged) === null || _c === void 0 ? void 0 : _c.call(this, this.label, this.language(), {
1184
- content: { [this.language()]: { type: 'timestamp', value: fuzzyDateValue } },
1185
+ content: { [this.language()]: { type: 'datetime', value: fuzzyDateValue } },
1185
1186
  }, valueId);
1186
1187
  }
1187
1188
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tmp/components/icure-date-picker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAmE;AACnE,2CAAgD;AAChD,qDAAmD;AACnD,0BAAuB;AAEvB,6DAAwD;AACxD,mFAA6E;AAC7E,sCAAiC;AACjC,kDAAkD;AAClD,sDAA+D;AAC/D,uCAAiC;AACjC,aAAa;AACb,6BAA0B;AAC1B,MAAM,OAAO,GAAG,IAAA,SAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAEjG,MAAM,CAAC,OAAO,CAAC,GAAG,MAAA,IAAI,CAAC,oBAAoB,EAAE,mCAAI,EAAE,CAAA;YACnD,MAAA,IAAI,CAAC,kBAAkB,qDACtB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EAAE,EACf;gBACC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;aAC5E,EACD,OAAO,CACP,CAAA;QACF,CAAC;IACF,CAAC;IAEM,WAAW;QACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC9C,OAAM;QACP,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAA;IACjD,CAAC;CACD;AA7FD,oDA6FC;AA3FY;IAAX,IAAA,wBAAQ,GAAE;;yDAAiB;AAET;IAAlB,IAAA,qBAAK,GAAE;;+DAAoC","sourcesContent":["import { CSSResultGroup, html, nothing, TemplateResult } from 'lit'\nimport { generateLabels } from '../common/utils'\nimport { property, state } from 'lit/decorators.js'\nimport 'app-datepicker'\nimport { CustomEventDetail } from 'app-datepicker/dist/typings'\nimport { MAX_DATE } from 'app-datepicker/dist/constants'\nimport { toResolvedDate } from 'app-datepicker/dist/helpers/to-resolved-date'\nimport { Field } from '../common'\nimport { datePicto } from '../common/styles/paths'\nimport { extractSingleValue } from '../icure-form/fields/utils'\nimport { format } from 'date-fns'\n// @ts-ignore\nimport { css } from 'lit';\nconst baseCss = css`@charset \"UTF-8\";\n:host {\n --bg-color-1: #f44336;\n}\n\n.ProseMirror {\n position: relative;\n width: 100%;\n word-wrap: break-word;\n white-space: pre-wrap;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n padding: 6px 8px 2px 8px;\n line-height: 1.2;\n color: #274768;\n font-size: 14px;\n font-weight: 400;\n outline: none;\n}\n.ProseMirror p:last-child,\n.ProseMirror h1:last-child,\n.ProseMirror h2:last-child,\n.ProseMirror h3:last-child,\n.ProseMirror h4:last-child,\n.ProseMirror h5:last-child,\n.ProseMirror h6:last-child {\n margin-bottom: 2px;\n}\n.ProseMirror p {\n margin-bottom: 1em;\n}\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n.ProseMirror li {\n position: relative;\n}\n.ProseMirror ul,\n.ProseMirror ol {\n padding-left: 30px;\n}\n.ProseMirror blockquote {\n padding-left: 1em;\n border-left: 3px solid #eee;\n margin-left: 0;\n margin-right: 0;\n}\n\n.ProseMirror-hideselection {\n caret-color: transparent;\n}\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-selectednode {\n outline: 2px solid #8cf;\n}\n\n/* Make sure li selections wrap around markers */\nli.ProseMirror-selectednode {\n outline: none;\n}\nli.ProseMirror-selectednode :after {\n content: \"\";\n position: absolute;\n left: -32px;\n right: -2px;\n top: -2px;\n bottom: -2px;\n border: 2px solid #8cf;\n pointer-events: none;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n/* Add space around the hr to make clicking it easier */\n.ProseMirror-example-setup-style hr {\n padding: 2px 10px;\n border: none;\n margin: 1em 0;\n}\n.ProseMirror-example-setup-style hr:after {\n content: \"\";\n display: block;\n height: 1px;\n background: silver;\n line-height: 2px;\n}\n\n.ProseMirror-example-setup-style img {\n cursor: default;\n}\n\n.ProseMirror-prompt {\n background: white;\n padding: 5px 10px 5px 15px;\n border: 1px solid silver;\n position: fixed;\n border-radius: 3px;\n z-index: 11;\n box-shadow: -0.5px 2px 5px rgba(0, 0, 0, 0.2);\n}\n.ProseMirror-prompt h5 {\n margin: 0;\n font-weight: normal;\n font-size: 100%;\n color: #444;\n}\n.ProseMirror-prompt input[type=text],\n.ProseMirror-prompt textarea {\n background: #eee;\n border: none;\n outline: none;\n}\n.ProseMirror-prompt input[type=text] {\n padding: 0 4px;\n}\n\n.ProseMirror-prompt-close {\n position: absolute;\n left: 2px;\n top: 1px;\n color: #666;\n border: none;\n background: transparent;\n padding: 0;\n}\n.ProseMirror-prompt-close:after {\n content: \"✕\";\n font-size: 12px;\n}\n\n.ProseMirror-invalid {\n background: #ffc;\n border: 1px solid #cc7;\n border-radius: 4px;\n padding: 5px 10px;\n position: absolute;\n min-width: 10em;\n}\n\n.ProseMirror-prompt-buttons {\n margin-top: 5px;\n display: none;\n}\n\n#editor,\n.editor {\n color: rgb(101, 101, 101);\n background-clip: padding-box;\n border-radius: 4px;\n border: 2px solid rgba(0, 0, 0, 0.2);\n padding: 5px 0;\n display: flex;\n align-items: flex-end;\n}\n\n.icure-input {\n background: #edf2f7;\n border-radius: 8px;\n border: none;\n min-height: 28px;\n height: auto;\n display: flex;\n flex-flow: row nowrap;\n align-items: flex-start;\n justify-content: space-between;\n}\n\n#editor {\n background: transparent;\n border: none;\n padding: 0;\n flex-grow: 1;\n display: flex;\n align-items: stretch;\n}\n#editor.tokens-list .ProseMirror, #editor.styled-tokens-list .ProseMirror {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: flex-start;\n}\n#editor.tokens-list .ProseMirror li, #editor.styled-tokens-list .ProseMirror li {\n display: flex;\n flex-direction: row;\n border-radius: 8px;\n padding: 2px 4px;\n margin-right: 2px;\n background-color: #dadada;\n border-color: rgba(42, 61, 108, 0.44);\n min-height: 20px;\n}\n#editor.tokens-list .ProseMirror li span, #editor.styled-tokens-list .ProseMirror li span {\n display: inline-block;\n min-height: 18px;\n}\n#editor.tokens-list .ProseMirror li span br, #editor.styled-tokens-list .ProseMirror li span br {\n display: none;\n}\n#editor.items-list .ProseMirror {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n align-items: flex-start;\n gap: 6px;\n}\n#editor.items-list .ProseMirror li {\n list-style-type: none;\n width: 100%;\n padding-bottom: 4px;\n border-bottom: 1px dotted rgba(128, 128, 128, 0.5098039216);\n}\n#editor.items-list .ProseMirror li:last-child {\n border-bottom: none;\n}\n\n#content {\n position: relative;\n padding: 0;\n}\n\n* {\n font-family: \"Roboto\", Helvetica, sans-serif;\n}\n\np {\n margin-top: 0;\n}\n\nh3 {\n color: #274768;\n margin-top: 0;\n}\n\n.icure-input-metadata-container {\n display: flex;\n}\n.icure-input-metadata-container .icure-metadata-container {\n display: flex;\n flex-grow: 1;\n padding: 0 4px;\n border: 1px solid #DDE3E7;\n border-left: none;\n border-radius: 0 6px 6px 0;\n outline: 0;\n box-sizing: border-box;\n}\n.icure-input-metadata-container .icure-metadata-container__validationError {\n border-color: red;\n}\n\n.extra {\n min-width: 20px;\n width: auto;\n height: 20px;\n transition: all 0.24s cubic-bezier(0.42, 0.01, 1, 0.62);\n}\n.extra:hover .info {\n display: none;\n}\n.extra:hover .buttons-container .menu-container .btn {\n animation: slideIn 0.24s ease-in forwards;\n pointer-events: none;\n display: unset !important;\n}\n.extra.forced .info, .extra.forced .extra .info.hidden {\n opacity: 0 !important;\n z-index: 0 !important;\n display: none;\n}\n.extra.forced .buttons-container .btn {\n opacity: 1 !important;\n display: unset !important;\n}\n.extra.forced:hover .buttons-container .menu-container .btn {\n animation: none;\n pointer-events: all;\n}\n.extra--metadataButtonsBar {\n height: 100%;\n display: flex;\n align-items: center;\n padding: 0 4px;\n}\n.extra .info {\n color: #809ab4;\n font-size: 15px;\n width: 100%;\n height: auto;\n overflow: hidden;\n pointer-events: none;\n text-align: center;\n}\n.extra .info span {\n font-weight: 700;\n}\n.extra .info.hidden {\n display: none;\n}\n.extra .buttons-container {\n display: flex;\n height: 20px;\n width: auto;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-end;\n transition: all 0.24s cubic-bezier(0.14, 0.69, 0.87, 0.54);\n z-index: 1000;\n}\n.extra .buttons-container .btn {\n border: none;\n background: transparent;\n position: relative;\n top: 0;\n display: none;\n opacity: 0;\n cursor: pointer;\n height: 20px;\n margin-left: 4px;\n margin-right: 4px;\n padding: 0;\n}\n.extra .buttons-container .btn svg {\n width: 15px;\n height: 15px;\n}\n.extra .buttons-container .btn svg path {\n fill: #809ab4;\n}\n.extra .buttons-container .btn.forced {\n opacity: 1 !important;\n display: unset !important;\n}\n.extra .buttons-container .btn.forced svg path {\n fill: crimson !important;\n}\n.extra .buttons-container .btn:focus, .extra .buttons-container .btn:focus-within {\n border: none;\n outline: none;\n}\n.extra .buttons-container .btn:hover svg path {\n fill: #274768;\n}\n.extra .buttons-container .menu-container .btn:hover::before {\n content: \"\";\n display: block;\n border-color: #274768 transparent transparent transparent;\n border-style: solid;\n border-width: 4px;\n position: absolute;\n top: -6px;\n}\n.extra .buttons-container .menu-container .btn:hover::after {\n content: attr(data-content);\n position: absolute;\n top: -21px;\n height: 16px;\n left: 50%;\n transform: translateX(-50%);\n border-radius: 8px;\n background: #274768;\n color: white;\n display: flex;\n flex-flow: row wrap;\n align-items: center;\n text-transform: capitalize;\n white-space: nowrap;\n padding: 0 12px;\n font-size: 12px;\n line-height: 0;\n}\n.extra .buttons-container .menu-container:last-child .btn {\n margin-right: 0;\n}\n\n@keyframes slideIn {\n 0% {\n top: 0;\n opacity: 0;\n pointer-events: none;\n }\n 100% {\n top: 0;\n opacity: 1;\n pointer-events: all;\n }\n}\n.menu-container {\n display: flex;\n align-items: center;\n height: fit-content;\n}\n.menu-container .item {\n height: 30px;\n width: 100%;\n background: transparent;\n border-radius: 4px;\n font-size: 14px;\n color: #274768;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n box-shadow: none;\n border: none;\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n}\n.menu-container .item.existing {\n background-color: #BFE8EA;\n}\n.menu-container .item.selected {\n color: white;\n background-color: #084B83;\n}\n.menu-container .item:hover {\n background: #DCE7F2;\n color: #274768;\n font-weight: 500;\n border-radius: 4px;\n}\n\n.value-date-menu {\n width: unset !important;\n}\n\n.menu {\n display: flex;\n flex-direction: column;\n gap: 2px;\n position: absolute;\n top: 32px;\n right: -12px;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n border-radius: 8px;\n padding: 8px;\n width: 220px;\n min-height: 120px;\n max-height: 320px;\n overflow-y: scroll;\n}\n.menu .input-container {\n background: #edf2f7;\n border-radius: 4px;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n height: 32px;\n margin-bottom: 4px;\n padding: 0 4px;\n}\n.menu .input-container:hover {\n box-shadow: 0 0 0 3px rgba(40, 151, 255, 0.2);\n}\n.menu .input-container:focus-within {\n box-shadow: 0 0 0 3px rgba(40, 151, 255, 0.2), 0 0 0 1px rgb(40, 151, 255);\n}\n.menu .input-container input {\n background: transparent;\n border: none;\n flex-grow: 1;\n height: 100%;\n}\n.menu .input-container input:focus {\n background: transparent;\n border: none;\n outline: none;\n}\n\n.menu-trigger:focus .menu {\n display: flex;\n}\n\nspan {\n position: relative;\n z-index: 1;\n}\nspan.date {\n margin-right: 1px;\n}\nspan.time {\n margin-left: 1px;\n}\nspan.measure {\n display: inline-block;\n margin-right: 1px;\n}\nspan.unit {\n margin-left: 1px;\n display: inline-block;\n}\nspan[data-content]:hover::after {\n position: absolute;\n content: attr(data-content);\n background: #274768;\n color: #ffffff;\n font-size: 9px;\n line-height: 12px;\n top: -12px;\n left: 0px;\n padding: 0px 2px;\n}\nspan[data-content]::before {\n position: absolute;\n content: \"\";\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: -1;\n opacity: 0.3;\n}\n\n.masked {\n display: none;\n}\n\n.companion {\n position: absolute;\n width: 15px;\n background-color: hsl(194, 100%, 50%);\n color: white;\n z-index: 20;\n padding: 0;\n text-align: center;\n font-size: 14px;\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border-radius: 0 2px 2px 0;\n}\n.companion:hover {\n font-weight: 700;\n background: hsl(202, 100%, 50%);\n}\n\n*::selection {\n background-color: hsla(194, 100%, 50%, 0.2);\n}\n\n.suggestion-palette {\n position: absolute;\n z-index: 20;\n max-width: 380px;\n font-size: 11px;\n overflow: hidden;\n text-overflow: ellipsis;\n padding: 4px;\n border: none;\n border-radius: 8px;\n background: white;\n box-shadow: 0 1.1px 1.1px rgba(0, 0, 0, 0.022), 0 2.7px 2.7px rgba(0, 0, 0, 0.032), 0 5px 5px rgba(0, 0, 0, 0.04), 0 8.9px 8.9px rgba(0, 0, 0, 0.048), 0 16.7px 16.7px rgba(0, 0, 0, 0.058), 0 40px 40px rgba(0, 0, 0, 0.08);\n}\n.suggestion-palette ul {\n white-space: nowrap;\n list-style-type: none;\n margin: 0;\n padding: 0;\n}\n.suggestion-palette ul li:not(:first-child) svg.tab-icn,\n.suggestion-palette ul li:not(.focused) svg.return-icn, .suggestion-palette ul.focused li:first-child svg.tab-icn {\n height: 0;\n width: 0;\n transform: scale(0);\n opacity: 0;\n}\n.suggestion-palette ul li {\n padding: 0 8px;\n font-size: 11px;\n height: 20px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-radius: 4px;\n color: rgb(39, 71, 104);\n}\n.suggestion-palette ul li.focused {\n background-color: rgb(237, 242, 247);\n}\n.suggestion-palette ul li.focused svg.return-icn {\n animation: growIn 0.24s ease-in forwards;\n}\n.suggestion-palette ul li svg {\n height: 12px;\n width: 12px;\n border-radius: 4px;\n transform-origin: center center;\n}\n.suggestion-palette ul li svg path {\n fill: rgb(128, 154, 180);\n}\n\n@keyframes growIn {\n 0% {\n transform: scale(0.5);\n }\n 90% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n }\n}\nspan.code-count-1::after,\nspan.code-count-1::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n}\n\nspan.code-count-2::after,\nspan.code-count-2::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n /* STRIPES */\n /*background: repeating-linear-gradient(*/\n /*\t45deg,*/\n /*\tvar(--bg-code-color-1),*/\n /*\tvar(--bg-code-color-1) 10px,*/\n /*\tvar(--bg-code-color-2) 10px,*/\n /*\tvar(--bg-code-color-2) 20px*/\n /*);*/\n /* PAS STRIPES */\n background: linear-gradient(90deg, var(--bg-code-color-1) 0%, var(--bg-code-color-2) 100%);\n}\n\nspan.code-count-3::after,\nspan.code-count-3::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n /* STRIPES */\n background: repeating-linear-gradient(45deg, var(--bg-code-color-1), var(--bg-code-color-1) 10px, var(--bg-code-color-2) 10px, var(--bg-code-color-2) 20px);\n /* PAS STRIPES */\n /* background: linear-gradient(90deg, var(--bg-code-color-1) 0%, var(--bg-code-color-2) 100%);*/\n}\n\n.selected-option {\n padding: 2px;\n margin-right: 5px;\n}\n\n.options {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n width: auto;\n min-width: 100%;\n overflow-y: auto;\n max-height: 280px;\n padding: 2px;\n border-radius: 6px;\n}\n.options--subformView {\n top: 46px;\n min-width: unset;\n left: unset;\n right: 0;\n}\n\n.date-picker {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n width: 260px;\n overflow-y: auto;\n max-height: 280px;\n}\n\napp-date-picker {\n --app-primary: #084B83;\n --app-hover: #5b7da2;\n --app-selected-hover: #5b7da2;\n}\n\n.option {\n height: 28px;\n min-height: 28px;\n width: 100%;\n background: transparent;\n border-radius: 4px;\n font-size: 14px;\n color: #545454;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n box-shadow: none;\n border: none;\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n padding: 4px 8px;\n -webkit-user-select: none; /* Safari */\n -ms-user-select: none; /* IE 10 and IE 11 */\n user-select: none; /* Standard syntax */\n cursor: pointer;\n}\n.option:hover {\n color: #656565;\n background-color: #ededed;\n}\n\n.select-arrow {\n border: none;\n background: 0px 0px;\n position: relative;\n top: 0px;\n opacity: 0.5;\n cursor: pointer;\n height: 20px;\n width: 10px;\n margin-left: 4px;\n margin-right: 4px;\n padding: 0px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n position: relative;\n}\n\n.group {\n align-items: end;\n display: grid;\n}\n\n.subform {\n display: grid;\n position: relative;\n padding: 8px;\n border-radius: 6px;\n background-color: #e7f0fd;\n gap: 12px;\n}\n.subform__heading {\n display: flex;\n justify-content: space-between;\n align-items: center;\n height: auto;\n}\n.subform__heading__title {\n padding: 0;\n margin: 0;\n}\n.subform__addBtn, .subform__removeBtn {\n cursor: pointer;\n background-color: #084B83;\n color: white;\n height: 32px;\n padding: 0 16px;\n border-radius: 6px;\n border: none;\n outline: none;\n}\n.subform__addBtn:hover, .subform__removeBtn:hover {\n background-color: #3D87C5;\n}\n.subform__removeBtn {\n justify-self: end;\n border: 1px solid #DDE3E7;\n background-color: #FCFCFD;\n color: #084B83;\n}\n.subform__removeBtn:hover {\n background-color: #F2F2F2;\n}\n.subform__child {\n display: grid;\n grid-template-rows: auto;\n gap: 8px;\n padding: 8px;\n border-radius: 6px;\n background: white;\n border: 1px solid #3D87C5;\n}\n.subform__child__title {\n padding: 12px !important;\n border-radius: 6px;\n margin: 0;\n background-color: #BFE8EA;\n}\n.subform__child .subform {\n background: unset;\n margin: 0;\n padding: 0;\n}\n\n.icure-form {\n background-color: rgba(0, 0, 0, 0);\n display: grid;\n gap: 16px 6px;\n grid-template-columns: repeat(24, 1fr);\n}\n.icure-form hr {\n display: block;\n margin-top: 20px;\n border-top: 1px solid rgba(8, 75, 131, 0.13);\n margin-bottom: 20px;\n}\n.icure-form h2 {\n font-size: 14.4px;\n font-weight: 700;\n color: #084B83;\n padding: 2px;\n}\n.icure-form h3 {\n font-size: 13.2px;\n font-weight: 500;\n color: #084B83;\n padding: 6px;\n}\n.icure-form .group.bordered {\n background: #f6f6f6;\n border-radius: 12px;\n}\n\n.icure-form-field {\n display: grid;\n align-items: flex-start;\n}\n\n.error {\n color: red;\n font-size: 12px;\n margin-top: 4px;\n}\n\n.icure-text-field .icure-label-extra, .icure-button-group .icure-label-extra {\n display: flex;\n width: 100%;\n gap: 12px;\n}\n.icure-text-field .icure-label, .icure-button-group .icure-label {\n z-index: 1;\n pointer-events: none;\n line-height: 1.4em;\n cursor: text;\n font-size: 12px;\n left: 9px;\n color: #084B83;\n align-items: center;\n height: 28px;\n max-width: 85%;\n min-width: 0;\n}\n.icure-text-field .icure-label.float, .icure-button-group .icure-label.float {\n display: flex;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.icure-text-field {\n position: relative;\n width: 100%;\n}\n.icure-text-field > .icure-label {\n transition: transform 0.2s ease-out, color 0.2s ease-out;\n}\n.icure-text-field > .icure-input {\n flex: 1 1 auto;\n width: auto;\n}\n.icure-text-field > .icure-label.side {\n position: relative;\n}\n.icure-text-field > .icure-label.side.left {\n order: -1;\n margin-right: 1em;\n}\n.icure-text-field > .icure-label.side.right {\n order: 1;\n margin-left: 1em;\n}\n.icure-text-field .icure-input,\n.icure-text-field .input-container {\n padding: 8px;\n width: 100%;\n box-sizing: border-box;\n border-width: 1px;\n border-style: solid;\n border-color: #DDE3E7;\n border-radius: 2px;\n box-sizing: border-box;\n outline: 0;\n font: inherit;\n font-size: 14px;\n line-height: 1.4em;\n display: flex;\n align-items: center;\n vertical-align: middle;\n position: relative;\n -webkit-appearance: none;\n background-color: #ffffff;\n color: #000000;\n}\n.icure-text-field .icure-input__validationError,\n.icure-text-field .input-container__validationError {\n border-color: red;\n}\n.icure-text-field .icure-input__withMetadata,\n.icure-text-field .input-container__withMetadata {\n border-radius: 6px 0 0 6px;\n}\n.icure-text-field .icure-input:focus, .icure-text-field .icure-input:focus-within,\n.icure-text-field .input-container:focus,\n.icure-text-field .input-container:focus-within {\n box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.06);\n}\n.icure-text-field .icure-input:hover,\n.icure-text-field .input-container:hover {\n border-color: rgba(0, 0, 0, 0.15);\n box-shadow: none;\n}\n.icure-text-field .icure-input:hover:focus, .icure-text-field .icure-input:hover:focus-within,\n.icure-text-field .input-container:hover:focus,\n.icure-text-field .input-container:hover:focus-within {\n box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.06);\n}\n.icure-text-field .icure-input .ProseMirror,\n.icure-text-field .input-container .ProseMirror {\n padding: 0;\n font-size: 14px;\n line-height: 1.4em;\n color: #000000;\n}\n.icure-text-field .icure-input .ProseMirror .date,\n.icure-text-field .input-container .ProseMirror .date {\n padding: 1px;\n}\n.icure-text-field .icure-input .ProseMirror .time,\n.icure-text-field .input-container .ProseMirror .time {\n padding: 1px;\n}\n.icure-text-field .icure-input .ProseMirror:focus .focused,\n.icure-text-field .input-container .ProseMirror:focus .focused {\n background-color: rgba(0, 0, 0, 0.05);\n border-radius: 3px;\n border-color: rgba(0, 0, 0, 0.1);\n}\n.icure-text-field .icure-input > svg,\n.icure-text-field .input-container > svg {\n opacity: 0.5;\n}\n.icure-text-field .icure-input > svg path,\n.icure-text-field .input-container > svg path {\n fill: #656565;\n}\n.icure-text-field .icure-input .extra,\n.icure-text-field .input-container .extra {\n height: 20px;\n}\n.icure-text-field .icure-input .extra > .info,\n.icure-text-field .input-container .extra > .info {\n color: #656565;\n opacity: 0.5;\n}\n.icure-text-field .icure-input .extra .btn svg path,\n.icure-text-field .input-container .extra .btn svg path {\n fill: #656565;\n opacity: 0.5;\n}\n.icure-text-field .icure-input .extra .btn svg path:hover,\n.icure-text-field .input-container .extra .btn svg path:hover {\n fill: #656565;\n opacity: 1;\n}\n\ninput[type=radio] {\n margin-top: -1px;\n vertical-align: middle;\n}\n\n.icure-checkbox:checked {\n accent-color: #06a070;\n}\n\n.icure-button {\n display: flex;\n height: 32px;\n padding: 0 16px;\n background-color: #084B83;\n color: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n font-weight: normal;\n}\n.icure-button:hover {\n background-color: #3D87C5;\n}\n\n.icure-button-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.icure-button-group > div {\n display: grid;\n}\n.icure-button-group > div > div {\n display: flex;\n align-items: center;\n}\n.icure-button-group > div > div > .icure-button-group-label {\n z-index: 1;\n line-height: 1.4em;\n cursor: text;\n font-size: 12px;\n top: calc(1.4em + 1px);\n left: 9px;\n transition: transform 0.2s ease-out, color 0.2s ease-out;\n color: #084B83;\n display: flex;\n align-items: center;\n height: 28px;\n max-width: 85%;\n min-width: 0;\n}\n.icure-button-group > div > div > .icure-button-group-label > span {\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n padding-right: 8px;\n}\n.icure-button-group > .icure-input {\n flex: 1 1 auto;\n width: auto;\n}\n.icure-button-group > .icure-label {\n transform: translate(0, 0) scale(1);\n}\n.icure-button-group > .icure-label.above, .icure-button-group.has-content > .icure-label, .icure-button-group:focus > .icure-label, .icure-button-group:focus-within > .icure-label {\n font-weight: 500;\n height: 1.4em;\n}` \nimport { anyDateToDate } from '../../utils/dates'\n\nexport class IcureDatePickerField extends Field {\n\t//TODO: support different date formats\n\t@property() placeholder = ''\n\n\t@state() protected displayDatePicker = false\n\n\tstatic get styles(): CSSResultGroup[] {\n\t\treturn [baseCss]\n\t}\n\n\t_handleClickOutside(event: MouseEvent): void {\n\t\tif (!event.composedPath().includes(this)) {\n\t\t\tthis.displayDatePicker = false\n\t\t\tevent.stopPropagation()\n\t\t}\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback()\n\t\tdocument.addEventListener('click', this._handleClickOutside.bind(this))\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback()\n\t\tdocument.removeEventListener('click', this._handleClickOutside.bind(this))\n\t}\n\n\tgetValueFromProvider(): string | undefined {\n\t\tconst [, versions] = extractSingleValue(this.valueProvider?.())\n\t\tif (versions) {\n\t\t\tconst valueForLanguage = versions[0]?.value?.content?.[this.language()] ?? ''\n\t\t\tif (valueForLanguage && (valueForLanguage.type === 'timestamp' || valueForLanguage.type === 'datetime') && valueForLanguage.value) {\n\t\t\t\tconst date = anyDateToDate(valueForLanguage.value)\n\t\t\t\treturn date ? format(date, 'dd/MM/yyyy') : ''\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t}\n\n\trender(): TemplateResult {\n\t\tif (!this.visible) {\n\t\t\treturn html``\n\t\t}\n\n\t\tconst value = this.getValueFromProvider()\n\t\tconst validationError = this.validationErrorsProvider?.()?.length\n\n\t\treturn html` <div id=\"root\" class=\"icure-text-field ${value && value != '' ? 'has-content' : ''}\" data-placeholder=\"${this.placeholder}\">\n\t\t\t${this.displayedLabels ? generateLabels(this.displayedLabels, this.language(), this.translate ? this.translationProvider : undefined) : nothing}\n\t\t\t<div class=\"icure-input ${validationError && 'icure-input__validationError'}\" @click=\"${this.togglePopup}\" id=\"test\">\n\t\t\t\t<div id=\"editor\">${value}</div>\n\t\t\t\t<div id=\"extra\" class=${'extra forced'}>\n\t\t\t\t\t<button class=\"btn select-arrow\">${datePicto}</button>\n\t\t\t\t\t${this.displayDatePicker\n\t\t\t\t\t\t? html`<div id=\"menu\" class=\"date-picker\" @click=\"${(event: Event) => event.stopPropagation()}\">\n\t\t\t\t\t\t\t\t<app-date-picker\n\t\t\t\t\t\t\t\t\tlocale=\"${this.selectedLanguage ?? this.defaultLanguage ?? 'en'}\"\n\t\t\t\t\t\t\t\t\tstyle=\"\"\n\t\t\t\t\t\t\t\t\tmax=\"${MAX_DATE}\"\n\t\t\t\t\t\t\t\t\tmin=\"${toResolvedDate('1900-01-01')}\"\n\t\t\t\t\t\t\t\t\t@date-updated=\"${this.dateUpdated}\"\n\t\t\t\t\t\t\t\t></app-date-picker>\n\t\t\t\t\t\t </div>`\n\t\t\t\t\t\t: ''}\n\t\t\t\t</div>\n\t\t\t\t<div class=\"error\">${this.validationErrorsProvider?.().map(([, error]) => html`<div>${this.translationProvider?.(this.language(), error)}</div>`)}</div>\n\t\t\t</div>\n\t\t</div>`\n\t}\n\n\tpublic dateUpdated(date: CustomEventDetail['date-updated']): void {\n\t\tconst parts = date.detail.value?.split('-')\n\t\tif (parts && parts.length === 3) {\n\t\t\tconst fuzzyDateValue = parseInt(parts[0]) * 10000 + parseInt(parts[1]) * 100 + parseInt(parts[2])\n\n\t\t\tconst [valueId] = this.getValueFromProvider() ?? ''\n\t\t\tthis.handleValueChanged?.(\n\t\t\t\tthis.label,\n\t\t\t\tthis.language(),\n\t\t\t\t{\n\t\t\t\t\tcontent: { [this.language()]: { type: 'timestamp', value: fuzzyDateValue } },\n\t\t\t\t},\n\t\t\t\tvalueId,\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic togglePopup(): void {\n\t\tif (this.readonly && !this.displayDatePicker) {\n\t\t\treturn\n\t\t}\n\t\tthis.displayDatePicker = !this.displayDatePicker\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tmp/components/icure-date-picker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAmE;AACnE,2CAAgD;AAChD,qDAAmD;AACnD,0BAAuB;AAEvB,6DAAwD;AACxD,mFAA6E;AAC7E,sCAAiC;AACjC,kDAAkD;AAClD,sDAA+D;AAC/D,uCAAiC;AACjC,aAAa;AACb,6BAA0B;AAC1B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BAAkB,qDACtB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EAAE,EACf;gBACC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;aAC3E,EACD,OAAO,CACP,CAAA;QACF,CAAC;IACF,CAAC;IAEM,WAAW;QACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC9C,OAAM;QACP,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAA;IACjD,CAAC;CACD;AA9FD,oDA8FC;AA5FY;IAAX,IAAA,wBAAQ,GAAE;;yDAAiB;AAET;IAAlB,IAAA,qBAAK,GAAE;;+DAAoC","sourcesContent":["import { CSSResultGroup, html, nothing, TemplateResult } from 'lit'\nimport { generateLabels } from '../common/utils'\nimport { property, state } from 'lit/decorators.js'\nimport 'app-datepicker'\nimport { CustomEventDetail } from 'app-datepicker/dist/typings'\nimport { MAX_DATE } from 'app-datepicker/dist/constants'\nimport { toResolvedDate } from 'app-datepicker/dist/helpers/to-resolved-date'\nimport { Field } from '../common'\nimport { datePicto } from '../common/styles/paths'\nimport { extractSingleValue } from '../icure-form/fields/utils'\nimport { format } from 'date-fns'\n// @ts-ignore\nimport { css } from 'lit';\nconst baseCss = css`@charset \"UTF-8\";\n:host {\n --bg-color-1: #f44336;\n}\n\n.ProseMirror {\n position: relative;\n width: 100%;\n word-wrap: break-word;\n white-space: pre-wrap;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n padding: 6px 8px 2px 8px;\n line-height: 1.2;\n color: #274768;\n font-size: 14px;\n font-weight: 400;\n outline: none;\n}\n.ProseMirror p:last-child,\n.ProseMirror h1:last-child,\n.ProseMirror h2:last-child,\n.ProseMirror h3:last-child,\n.ProseMirror h4:last-child,\n.ProseMirror h5:last-child,\n.ProseMirror h6:last-child {\n margin-bottom: 2px;\n}\n.ProseMirror p {\n margin-bottom: 1em;\n}\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n.ProseMirror li {\n position: relative;\n}\n.ProseMirror ul,\n.ProseMirror ol {\n padding-left: 30px;\n}\n.ProseMirror blockquote {\n padding-left: 1em;\n border-left: 3px solid #eee;\n margin-left: 0;\n margin-right: 0;\n}\n\n.ProseMirror-hideselection {\n caret-color: transparent;\n}\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-selectednode {\n outline: 2px solid #8cf;\n}\n\n/* Make sure li selections wrap around markers */\nli.ProseMirror-selectednode {\n outline: none;\n}\nli.ProseMirror-selectednode :after {\n content: \"\";\n position: absolute;\n left: -32px;\n right: -2px;\n top: -2px;\n bottom: -2px;\n border: 2px solid #8cf;\n pointer-events: none;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n/* Add space around the hr to make clicking it easier */\n.ProseMirror-example-setup-style hr {\n padding: 2px 10px;\n border: none;\n margin: 1em 0;\n}\n.ProseMirror-example-setup-style hr:after {\n content: \"\";\n display: block;\n height: 1px;\n background: silver;\n line-height: 2px;\n}\n\n.ProseMirror-example-setup-style img {\n cursor: default;\n}\n\n.ProseMirror-prompt {\n background: white;\n padding: 5px 10px 5px 15px;\n border: 1px solid silver;\n position: fixed;\n border-radius: 3px;\n z-index: 11;\n box-shadow: -0.5px 2px 5px rgba(0, 0, 0, 0.2);\n}\n.ProseMirror-prompt h5 {\n margin: 0;\n font-weight: normal;\n font-size: 100%;\n color: #444;\n}\n.ProseMirror-prompt input[type=text],\n.ProseMirror-prompt textarea {\n background: #eee;\n border: none;\n outline: none;\n}\n.ProseMirror-prompt input[type=text] {\n padding: 0 4px;\n}\n\n.ProseMirror-prompt-close {\n position: absolute;\n left: 2px;\n top: 1px;\n color: #666;\n border: none;\n background: transparent;\n padding: 0;\n}\n.ProseMirror-prompt-close:after {\n content: \"✕\";\n font-size: 12px;\n}\n\n.ProseMirror-invalid {\n background: #ffc;\n border: 1px solid #cc7;\n border-radius: 4px;\n padding: 5px 10px;\n position: absolute;\n min-width: 10em;\n}\n\n.ProseMirror-prompt-buttons {\n margin-top: 5px;\n display: none;\n}\n\n#editor,\n.editor {\n color: rgb(101, 101, 101);\n background-clip: padding-box;\n border-radius: 4px;\n border: 2px solid rgba(0, 0, 0, 0.2);\n padding: 5px 0;\n display: flex;\n align-items: flex-end;\n}\n\n.icure-input {\n background: #edf2f7;\n border-radius: 8px;\n border: none;\n min-height: 28px;\n height: auto;\n display: flex;\n flex-flow: row nowrap;\n align-items: flex-start;\n justify-content: space-between;\n}\n\n#editor {\n background: transparent;\n border: none;\n padding: 0;\n flex-grow: 1;\n display: flex;\n align-items: stretch;\n}\n#editor.tokens-list .ProseMirror, #editor.styled-tokens-list .ProseMirror {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: flex-start;\n}\n#editor.tokens-list .ProseMirror li, #editor.styled-tokens-list .ProseMirror li {\n display: flex;\n flex-direction: row;\n border-radius: 8px;\n padding: 2px 4px;\n margin-right: 2px;\n background-color: #dadada;\n border-color: rgba(42, 61, 108, 0.44);\n min-height: 20px;\n}\n#editor.tokens-list .ProseMirror li span, #editor.styled-tokens-list .ProseMirror li span {\n display: inline-block;\n min-height: 18px;\n}\n#editor.tokens-list .ProseMirror li span br, #editor.styled-tokens-list .ProseMirror li span br {\n display: none;\n}\n#editor.items-list .ProseMirror {\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n align-items: flex-start;\n gap: 6px;\n}\n#editor.items-list .ProseMirror li {\n list-style-type: none;\n width: 100%;\n padding-bottom: 4px;\n border-bottom: 1px dotted rgba(128, 128, 128, 0.5098039216);\n}\n#editor.items-list .ProseMirror li:last-child {\n border-bottom: none;\n}\n\n#content {\n position: relative;\n padding: 0;\n}\n\n* {\n font-family: \"Roboto\", Helvetica, sans-serif;\n}\n\np {\n margin-top: 0;\n}\n\nh3 {\n color: #274768;\n margin-top: 0;\n}\n\n.icure-input-metadata-container {\n display: flex;\n}\n.icure-input-metadata-container .icure-metadata-container {\n display: flex;\n flex-grow: 1;\n padding: 0 4px;\n border: 1px solid #DDE3E7;\n border-left: none;\n border-radius: 0 6px 6px 0;\n outline: 0;\n box-sizing: border-box;\n}\n.icure-input-metadata-container .icure-metadata-container__validationError {\n border-color: red;\n}\n\n.extra {\n min-width: 20px;\n width: auto;\n height: 20px;\n transition: all 0.24s cubic-bezier(0.42, 0.01, 1, 0.62);\n}\n.extra:hover .info {\n display: none;\n}\n.extra:hover .buttons-container .menu-container .btn {\n animation: slideIn 0.24s ease-in forwards;\n pointer-events: none;\n display: unset !important;\n}\n.extra.forced .info, .extra.forced .extra .info.hidden {\n opacity: 0 !important;\n z-index: 0 !important;\n display: none;\n}\n.extra.forced .buttons-container .btn {\n opacity: 1 !important;\n display: unset !important;\n}\n.extra.forced:hover .buttons-container .menu-container .btn {\n animation: none;\n pointer-events: all;\n}\n.extra--metadataButtonsBar {\n height: 100%;\n display: flex;\n align-items: center;\n padding: 0 4px;\n}\n.extra .info {\n color: #809ab4;\n font-size: 15px;\n width: 100%;\n height: auto;\n overflow: hidden;\n pointer-events: none;\n text-align: center;\n}\n.extra .info span {\n font-weight: 700;\n}\n.extra .info.hidden {\n display: none;\n}\n.extra .buttons-container {\n display: flex;\n height: 20px;\n width: auto;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-end;\n transition: all 0.24s cubic-bezier(0.14, 0.69, 0.87, 0.54);\n z-index: 1000;\n}\n.extra .buttons-container .btn {\n border: none;\n background: transparent;\n position: relative;\n top: 0;\n display: none;\n opacity: 0;\n cursor: pointer;\n height: 20px;\n margin-left: 4px;\n margin-right: 4px;\n padding: 0;\n}\n.extra .buttons-container .btn svg {\n width: 15px;\n height: 15px;\n}\n.extra .buttons-container .btn svg path {\n fill: #809ab4;\n}\n.extra .buttons-container .btn.forced {\n opacity: 1 !important;\n display: unset !important;\n}\n.extra .buttons-container .btn.forced svg path {\n fill: crimson !important;\n}\n.extra .buttons-container .btn:focus, .extra .buttons-container .btn:focus-within {\n border: none;\n outline: none;\n}\n.extra .buttons-container .btn:hover svg path {\n fill: #274768;\n}\n.extra .buttons-container .menu-container .btn:hover::before {\n content: \"\";\n display: block;\n border-color: #274768 transparent transparent transparent;\n border-style: solid;\n border-width: 4px;\n position: absolute;\n top: -6px;\n}\n.extra .buttons-container .menu-container .btn:hover::after {\n content: attr(data-content);\n position: absolute;\n top: -21px;\n height: 16px;\n left: 50%;\n transform: translateX(-50%);\n border-radius: 8px;\n background: #274768;\n color: white;\n display: flex;\n flex-flow: row wrap;\n align-items: center;\n text-transform: capitalize;\n white-space: nowrap;\n padding: 0 12px;\n font-size: 12px;\n line-height: 0;\n}\n.extra .buttons-container .menu-container:last-child .btn {\n margin-right: 0;\n}\n\n@keyframes slideIn {\n 0% {\n top: 0;\n opacity: 0;\n pointer-events: none;\n }\n 100% {\n top: 0;\n opacity: 1;\n pointer-events: all;\n }\n}\n.menu-container {\n display: flex;\n align-items: center;\n height: fit-content;\n}\n.menu-container .item {\n height: 30px;\n width: 100%;\n background: transparent;\n border-radius: 4px;\n font-size: 14px;\n color: #274768;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n box-shadow: none;\n border: none;\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n}\n.menu-container .item.existing {\n background-color: #BFE8EA;\n}\n.menu-container .item.selected {\n color: white;\n background-color: #084B83;\n}\n.menu-container .item:hover {\n background: #DCE7F2;\n color: #274768;\n font-weight: 500;\n border-radius: 4px;\n}\n\n.value-date-menu {\n width: unset !important;\n}\n\n.menu {\n display: flex;\n flex-direction: column;\n gap: 2px;\n position: absolute;\n top: 32px;\n right: -12px;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n border-radius: 8px;\n padding: 8px;\n width: 220px;\n min-height: 120px;\n max-height: 320px;\n overflow-y: scroll;\n}\n.menu .input-container {\n background: #edf2f7;\n border-radius: 4px;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n height: 32px;\n margin-bottom: 4px;\n padding: 0 4px;\n}\n.menu .input-container:hover {\n box-shadow: 0 0 0 3px rgba(40, 151, 255, 0.2);\n}\n.menu .input-container:focus-within {\n box-shadow: 0 0 0 3px rgba(40, 151, 255, 0.2), 0 0 0 1px rgb(40, 151, 255);\n}\n.menu .input-container input {\n background: transparent;\n border: none;\n flex-grow: 1;\n height: 100%;\n}\n.menu .input-container input:focus {\n background: transparent;\n border: none;\n outline: none;\n}\n\n.menu-trigger:focus .menu {\n display: flex;\n}\n\nspan {\n position: relative;\n z-index: 1;\n}\nspan.date {\n margin-right: 1px;\n}\nspan.time {\n margin-left: 1px;\n}\nspan.measure {\n display: inline-block;\n margin-right: 1px;\n}\nspan.unit {\n margin-left: 1px;\n display: inline-block;\n}\nspan[data-content]:hover::after {\n position: absolute;\n content: attr(data-content);\n background: #274768;\n color: #ffffff;\n font-size: 9px;\n line-height: 12px;\n top: -12px;\n left: 0px;\n padding: 0px 2px;\n}\nspan[data-content]::before {\n position: absolute;\n content: \"\";\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: -1;\n opacity: 0.3;\n}\n\n.masked {\n display: none;\n}\n\n.companion {\n position: absolute;\n width: 15px;\n background-color: hsl(194, 100%, 50%);\n color: white;\n z-index: 20;\n padding: 0;\n text-align: center;\n font-size: 14px;\n font-weight: 500;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n border-radius: 0 2px 2px 0;\n}\n.companion:hover {\n font-weight: 700;\n background: hsl(202, 100%, 50%);\n}\n\n*::selection {\n background-color: hsla(194, 100%, 50%, 0.2);\n}\n\n.suggestion-palette {\n position: absolute;\n z-index: 20;\n max-width: 380px;\n font-size: 11px;\n overflow: hidden;\n text-overflow: ellipsis;\n padding: 4px;\n border: none;\n border-radius: 8px;\n background: white;\n box-shadow: 0 1.1px 1.1px rgba(0, 0, 0, 0.022), 0 2.7px 2.7px rgba(0, 0, 0, 0.032), 0 5px 5px rgba(0, 0, 0, 0.04), 0 8.9px 8.9px rgba(0, 0, 0, 0.048), 0 16.7px 16.7px rgba(0, 0, 0, 0.058), 0 40px 40px rgba(0, 0, 0, 0.08);\n}\n.suggestion-palette ul {\n white-space: nowrap;\n list-style-type: none;\n margin: 0;\n padding: 0;\n}\n.suggestion-palette ul li:not(:first-child) svg.tab-icn,\n.suggestion-palette ul li:not(.focused) svg.return-icn, .suggestion-palette ul.focused li:first-child svg.tab-icn {\n height: 0;\n width: 0;\n transform: scale(0);\n opacity: 0;\n}\n.suggestion-palette ul li {\n padding: 0 8px;\n font-size: 11px;\n height: 20px;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-radius: 4px;\n color: rgb(39, 71, 104);\n}\n.suggestion-palette ul li.focused {\n background-color: rgb(237, 242, 247);\n}\n.suggestion-palette ul li.focused svg.return-icn {\n animation: growIn 0.24s ease-in forwards;\n}\n.suggestion-palette ul li svg {\n height: 12px;\n width: 12px;\n border-radius: 4px;\n transform-origin: center center;\n}\n.suggestion-palette ul li svg path {\n fill: rgb(128, 154, 180);\n}\n\n@keyframes growIn {\n 0% {\n transform: scale(0.5);\n }\n 90% {\n transform: scale(1.1);\n }\n 100% {\n transform: scale(1);\n }\n}\nspan.code-count-1::after,\nspan.code-count-1::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n}\n\nspan.code-count-2::after,\nspan.code-count-2::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n /* STRIPES */\n /*background: repeating-linear-gradient(*/\n /*\t45deg,*/\n /*\tvar(--bg-code-color-1),*/\n /*\tvar(--bg-code-color-1) 10px,*/\n /*\tvar(--bg-code-color-2) 10px,*/\n /*\tvar(--bg-code-color-2) 20px*/\n /*);*/\n /* PAS STRIPES */\n background: linear-gradient(90deg, var(--bg-code-color-1) 0%, var(--bg-code-color-2) 100%);\n}\n\nspan.code-count-3::after,\nspan.code-count-3::before {\n background: var(--bg-code-color-1);\n color: var(--text-code-color-1);\n /* STRIPES */\n background: repeating-linear-gradient(45deg, var(--bg-code-color-1), var(--bg-code-color-1) 10px, var(--bg-code-color-2) 10px, var(--bg-code-color-2) 20px);\n /* PAS STRIPES */\n /* background: linear-gradient(90deg, var(--bg-code-color-1) 0%, var(--bg-code-color-2) 100%);*/\n}\n\n.selected-option {\n padding: 2px;\n margin-right: 5px;\n}\n\n.options {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n width: auto;\n min-width: 100%;\n overflow-y: auto;\n max-height: 280px;\n padding: 2px;\n border-radius: 6px;\n}\n.options--subformView {\n top: 46px;\n min-width: unset;\n left: unset;\n right: 0;\n}\n\n.date-picker {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n position: absolute;\n top: calc(100% + 6px);\n left: 0;\n z-index: 2;\n background: #fff;\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n width: 260px;\n overflow-y: auto;\n max-height: 280px;\n}\n\napp-date-picker {\n --app-primary: #084B83;\n --app-hover: #5b7da2;\n --app-selected-hover: #5b7da2;\n}\n\n.option {\n height: 28px;\n min-height: 28px;\n width: 100%;\n background: transparent;\n border-radius: 4px;\n font-size: 14px;\n color: #545454;\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n justify-content: flex-start;\n box-shadow: none;\n border: none;\n white-space: nowrap;\n overflow-x: hidden;\n text-overflow: ellipsis;\n padding: 4px 8px;\n -webkit-user-select: none; /* Safari */\n -ms-user-select: none; /* IE 10 and IE 11 */\n user-select: none; /* Standard syntax */\n cursor: pointer;\n}\n.option:hover {\n color: #656565;\n background-color: #ededed;\n}\n\n.select-arrow {\n border: none;\n background: 0px 0px;\n position: relative;\n top: 0px;\n opacity: 0.5;\n cursor: pointer;\n height: 20px;\n width: 10px;\n margin-left: 4px;\n margin-right: 4px;\n padding: 0px;\n}\n\n.hidden {\n display: none;\n}\n\n.container {\n position: relative;\n}\n\n.group {\n align-items: end;\n display: grid;\n}\n\n.subform {\n display: grid;\n position: relative;\n padding: 8px;\n border-radius: 6px;\n background-color: #e7f0fd;\n gap: 12px;\n}\n.subform__heading {\n display: flex;\n justify-content: space-between;\n align-items: center;\n height: auto;\n}\n.subform__heading__title {\n padding: 0;\n margin: 0;\n}\n.subform__addBtn, .subform__removeBtn {\n cursor: pointer;\n background-color: #084B83;\n color: white;\n height: 32px;\n padding: 0 16px;\n border-radius: 6px;\n border: none;\n outline: none;\n}\n.subform__addBtn:hover, .subform__removeBtn:hover {\n background-color: #3D87C5;\n}\n.subform__removeBtn {\n justify-self: end;\n border: 1px solid #DDE3E7;\n background-color: #FCFCFD;\n color: #084B83;\n}\n.subform__removeBtn:hover {\n background-color: #F2F2F2;\n}\n.subform__child {\n display: grid;\n grid-template-rows: auto;\n gap: 8px;\n padding: 8px;\n border-radius: 6px;\n background: white;\n border: 1px solid #3D87C5;\n}\n.subform__child__title {\n padding: 12px !important;\n border-radius: 6px;\n margin: 0;\n background-color: #BFE8EA;\n}\n.subform__child .subform {\n background: unset;\n margin: 0;\n padding: 0;\n}\n\n.icure-form {\n background-color: rgba(0, 0, 0, 0);\n display: grid;\n gap: 16px 6px;\n grid-template-columns: repeat(24, 1fr);\n}\n.icure-form hr {\n display: block;\n margin-top: 20px;\n border-top: 1px solid rgba(8, 75, 131, 0.13);\n margin-bottom: 20px;\n}\n.icure-form h2 {\n font-size: 14.4px;\n font-weight: 700;\n color: #084B83;\n padding: 2px;\n}\n.icure-form h3 {\n font-size: 13.2px;\n font-weight: 500;\n color: #084B83;\n padding: 6px;\n}\n.icure-form .group.bordered {\n background: #f6f6f6;\n border-radius: 12px;\n}\n\n.icure-form-field {\n display: grid;\n align-items: flex-start;\n}\n\n.error {\n color: red;\n font-size: 12px;\n margin-top: 4px;\n}\n\n.icure-text-field .icure-label-extra, .icure-button-group .icure-label-extra {\n display: flex;\n width: 100%;\n gap: 12px;\n}\n.icure-text-field .icure-label, .icure-button-group .icure-label {\n z-index: 1;\n pointer-events: none;\n line-height: 1.4em;\n cursor: text;\n font-size: 12px;\n left: 9px;\n color: #084B83;\n align-items: center;\n height: 28px;\n max-width: 85%;\n min-width: 0;\n}\n.icure-text-field .icure-label.float, .icure-button-group .icure-label.float {\n display: flex;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n}\n\n.icure-text-field {\n position: relative;\n width: 100%;\n}\n.icure-text-field > .icure-label {\n transition: transform 0.2s ease-out, color 0.2s ease-out;\n}\n.icure-text-field > .icure-input {\n flex: 1 1 auto;\n width: auto;\n}\n.icure-text-field > .icure-label.side {\n position: relative;\n}\n.icure-text-field > .icure-label.side.left {\n order: -1;\n margin-right: 1em;\n}\n.icure-text-field > .icure-label.side.right {\n order: 1;\n margin-left: 1em;\n}\n.icure-text-field .icure-input,\n.icure-text-field .input-container {\n padding: 8px;\n width: 100%;\n box-sizing: border-box;\n border-width: 1px;\n border-style: solid;\n border-color: #DDE3E7;\n border-radius: 2px;\n box-sizing: border-box;\n outline: 0;\n font: inherit;\n font-size: 14px;\n line-height: 1.4em;\n display: flex;\n align-items: center;\n vertical-align: middle;\n position: relative;\n -webkit-appearance: none;\n background-color: #ffffff;\n color: #000000;\n}\n.icure-text-field .icure-input__validationError,\n.icure-text-field .input-container__validationError {\n border-color: red;\n}\n.icure-text-field .icure-input__withMetadata,\n.icure-text-field .input-container__withMetadata {\n border-radius: 6px 0 0 6px;\n}\n.icure-text-field .icure-input:focus, .icure-text-field .icure-input:focus-within,\n.icure-text-field .input-container:focus,\n.icure-text-field .input-container:focus-within {\n box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.06);\n}\n.icure-text-field .icure-input:hover,\n.icure-text-field .input-container:hover {\n border-color: rgba(0, 0, 0, 0.15);\n box-shadow: none;\n}\n.icure-text-field .icure-input:hover:focus, .icure-text-field .icure-input:hover:focus-within,\n.icure-text-field .input-container:hover:focus,\n.icure-text-field .input-container:hover:focus-within {\n box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.06);\n}\n.icure-text-field .icure-input .ProseMirror,\n.icure-text-field .input-container .ProseMirror {\n padding: 0;\n font-size: 14px;\n line-height: 1.4em;\n color: #000000;\n}\n.icure-text-field .icure-input .ProseMirror .date,\n.icure-text-field .input-container .ProseMirror .date {\n padding: 1px;\n}\n.icure-text-field .icure-input .ProseMirror .time,\n.icure-text-field .input-container .ProseMirror .time {\n padding: 1px;\n}\n.icure-text-field .icure-input .ProseMirror:focus .focused,\n.icure-text-field .input-container .ProseMirror:focus .focused {\n background-color: rgba(0, 0, 0, 0.05);\n border-radius: 3px;\n border-color: rgba(0, 0, 0, 0.1);\n}\n.icure-text-field .icure-input > svg,\n.icure-text-field .input-container > svg {\n opacity: 0.5;\n}\n.icure-text-field .icure-input > svg path,\n.icure-text-field .input-container > svg path {\n fill: #656565;\n}\n.icure-text-field .icure-input .extra,\n.icure-text-field .input-container .extra {\n height: 20px;\n}\n.icure-text-field .icure-input .extra > .info,\n.icure-text-field .input-container .extra > .info {\n color: #656565;\n opacity: 0.5;\n}\n.icure-text-field .icure-input .extra .btn svg path,\n.icure-text-field .input-container .extra .btn svg path {\n fill: #656565;\n opacity: 0.5;\n}\n.icure-text-field .icure-input .extra .btn svg path:hover,\n.icure-text-field .input-container .extra .btn svg path:hover {\n fill: #656565;\n opacity: 1;\n}\n\ninput[type=radio] {\n margin-top: -1px;\n vertical-align: middle;\n}\n\n.icure-checkbox:checked {\n accent-color: #06a070;\n}\n\n.icure-button {\n display: flex;\n height: 32px;\n padding: 0 16px;\n background-color: #084B83;\n color: white;\n border-radius: 6px;\n cursor: pointer;\n font-size: 14px;\n font-weight: normal;\n}\n.icure-button:hover {\n background-color: #3D87C5;\n}\n\n.icure-button-group {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.icure-button-group > div {\n display: grid;\n}\n.icure-button-group > div > div {\n display: flex;\n align-items: center;\n}\n.icure-button-group > div > div > .icure-button-group-label {\n z-index: 1;\n line-height: 1.4em;\n cursor: text;\n font-size: 12px;\n top: calc(1.4em + 1px);\n left: 9px;\n transition: transform 0.2s ease-out, color 0.2s ease-out;\n color: #084B83;\n display: flex;\n align-items: center;\n height: 28px;\n max-width: 85%;\n min-width: 0;\n}\n.icure-button-group > div > div > .icure-button-group-label > span {\n display: block;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n padding-right: 8px;\n}\n.icure-button-group > .icure-input {\n flex: 1 1 auto;\n width: auto;\n}\n.icure-button-group > .icure-label {\n transform: translate(0, 0) scale(1);\n}\n.icure-button-group > .icure-label.above, .icure-button-group.has-content > .icure-label, .icure-button-group:focus > .icure-label, .icure-button-group:focus-within > .icure-label {\n font-weight: 500;\n height: 1.4em;\n}` \nimport { anyDateToDate } from '../../utils/dates'\n\nexport class IcureDatePickerField extends Field {\n\t//TODO: support different date formats\n\t@property() placeholder = ''\n\n\t@state() protected displayDatePicker = false\n\n\tstatic get styles(): CSSResultGroup[] {\n\t\treturn [baseCss]\n\t}\n\n\t_handleClickOutside(event: MouseEvent): void {\n\t\tif (!event.composedPath().includes(this)) {\n\t\t\tthis.displayDatePicker = false\n\t\t\tevent.stopPropagation()\n\t\t}\n\t}\n\n\tconnectedCallback() {\n\t\tsuper.connectedCallback()\n\t\tdocument.addEventListener('click', this._handleClickOutside.bind(this))\n\t}\n\n\tdisconnectedCallback() {\n\t\tsuper.disconnectedCallback()\n\t\tdocument.removeEventListener('click', this._handleClickOutside.bind(this))\n\t}\n\n\tgetValueFromProvider(): string | undefined {\n\t\tconst [, versions] = extractSingleValue(this.valueProvider?.())\n\t\tif (versions) {\n\t\t\tconst content = versions[0]?.value?.content\n\t\t\tconst valueForLanguage = content?.[this.language()] ?? content?.[this.defaultLanguage] ?? content?.['*'] ?? content?.[Object.keys(content)[0]]\n\t\t\tif (valueForLanguage && (valueForLanguage.type === 'timestamp' || valueForLanguage.type === 'datetime') && valueForLanguage.value) {\n\t\t\t\tconst date = anyDateToDate(valueForLanguage.value)\n\t\t\t\treturn date ? format(date, 'dd/MM/yyyy') : ''\n\t\t\t}\n\t\t}\n\t\treturn undefined\n\t}\n\n\trender(): TemplateResult {\n\t\tif (!this.visible) {\n\t\t\treturn html``\n\t\t}\n\n\t\tconst value = this.getValueFromProvider()\n\t\tconst validationError = this.validationErrorsProvider?.()?.length\n\n\t\treturn html` <div id=\"root\" class=\"icure-text-field ${value && value != '' ? 'has-content' : ''}\" data-placeholder=\"${this.placeholder}\">\n\t\t\t${this.displayedLabels ? generateLabels(this.displayedLabels, this.language(), this.translate ? this.translationProvider : undefined) : nothing}\n\t\t\t<div class=\"icure-input ${validationError && 'icure-input__validationError'}\" @click=\"${this.togglePopup}\" id=\"test\">\n\t\t\t\t<div id=\"editor\">${value}</div>\n\t\t\t\t<div id=\"extra\" class=${'extra forced'}>\n\t\t\t\t\t<button class=\"btn select-arrow\">${datePicto}</button>\n\t\t\t\t\t${this.displayDatePicker\n\t\t\t\t\t\t? html`<div id=\"menu\" class=\"date-picker\" @click=\"${(event: Event) => event.stopPropagation()}\">\n\t\t\t\t\t\t\t\t<app-date-picker\n\t\t\t\t\t\t\t\t\tlocale=\"${this.selectedLanguage ?? this.defaultLanguage ?? 'en'}\"\n\t\t\t\t\t\t\t\t\tstyle=\"\"\n\t\t\t\t\t\t\t\t\tmax=\"${MAX_DATE}\"\n\t\t\t\t\t\t\t\t\tmin=\"${toResolvedDate('1900-01-01')}\"\n\t\t\t\t\t\t\t\t\t@date-updated=\"${this.dateUpdated}\"\n\t\t\t\t\t\t\t\t></app-date-picker>\n\t\t\t\t\t\t </div>`\n\t\t\t\t\t\t: ''}\n\t\t\t\t</div>\n\t\t\t\t<div class=\"error\">${this.validationErrorsProvider?.().map(([, error]) => html`<div>${this.translationProvider?.(this.language(), error)}</div>`)}</div>\n\t\t\t</div>\n\t\t</div>`\n\t}\n\n\tpublic dateUpdated(date: CustomEventDetail['date-updated']): void {\n\t\tconst parts = date.detail.value?.split('-')\n\t\tif (parts && parts.length === 3) {\n\t\t\tconst fuzzyDateValue = parseInt(parts[0]) * 10000 + parseInt(parts[1]) * 100 + parseInt(parts[2])\n\n\t\t\tconst [valueId] = this.getValueFromProvider() ?? ''\n\t\t\tthis.handleValueChanged?.(\n\t\t\t\tthis.label,\n\t\t\t\tthis.language(),\n\t\t\t\t{\n\t\t\t\t\tcontent: { [this.language()]: { type: 'datetime', value: fuzzyDateValue } },\n\t\t\t\t},\n\t\t\t\tvalueId,\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic togglePopup(): void {\n\t\tif (this.readonly && !this.displayDatePicker) {\n\t\t\treturn\n\t\t}\n\t\tthis.displayDatePicker = !this.displayDatePicker\n\t}\n}\n"]}
@@ -49,8 +49,13 @@ export declare class BridgedFormValuesContainer implements FormValuesContainer<F
49
49
  constructor(responsible: string, contactFormValuesContainer: ContactFormValuesContainer, interpreter?: (<T, S extends {
50
50
  [key: string]: unknown;
51
51
  [key: symbol]: unknown;
52
- }>(formula: string, sandbox: S) => T | undefined) | undefined, contact?: Contact, initialValuesProvider?: (fvc: BridgedFormValuesContainer, anchorId?: string, templateId?: string) => [FieldValue, FieldMetadata][], dependentValuesProvider?: (anchorId: string | undefined, templateId: string | undefined) => {
52
+ }>(formula: string, sandbox: S) => T | undefined) | undefined, contact?: Contact, initialValuesProvider?: (anchorId?: string, templateId?: string) => {
53
53
  metadata: FieldMetadata;
54
+ revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[];
55
+ formula: string;
56
+ }[], dependentValuesProvider?: (anchorId: string | undefined, templateId: string | undefined) => {
57
+ metadata: FieldMetadata;
58
+ revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[];
54
59
  formula: string;
55
60
  }[], validatorsProvider?: (anchorId: string | undefined, templateId: string) => {
56
61
  metadata: FieldMetadata;
@@ -63,7 +68,7 @@ export declare class BridgedFormValuesContainer implements FormValuesContainer<F
63
68
  unregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void;
64
69
  getValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue>;
65
70
  getMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata>;
66
- private forceValues;
71
+ private computeInitialValues;
67
72
  private computeDependentValues;
68
73
  setValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void;
69
74
  setMetadata(meta: FieldMetadata, id?: string | undefined): void;
@@ -16,6 +16,7 @@ const icure_utils_1 = require("./icure-utils");
16
16
  const primitive_1 = require("../utils/primitive");
17
17
  const dates_1 = require("../utils/dates");
18
18
  const uuid_1 = require("uuid");
19
+ const code_utils_1 = require("../utils/code-utils");
19
20
  function notify(l, fvc) {
20
21
  //console.log('Notifying', l, fvc.toString())
21
22
  l(fvc);
@@ -56,7 +57,6 @@ class BridgedFormValuesContainer {
56
57
  * @param initialValuesProvider A lambda that provides the initial values of the form
57
58
  */
58
59
  constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = []) {
59
- var _a, _b, _c, _d;
60
60
  this.responsible = responsible;
61
61
  this.interpreter = interpreter;
62
62
  this.initialValuesProvider = initialValuesProvider;
@@ -77,7 +77,7 @@ class BridgedFormValuesContainer {
77
77
  this.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify);
78
78
  this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
79
79
  if (this.contactFormValuesContainer.mustBeInitialised()) {
80
- this.forceValues(initialValuesProvider(this, (_b = (_a = this.contactFormValuesContainer) === null || _a === void 0 ? void 0 : _a.rootForm) === null || _b === void 0 ? void 0 : _b.descr, (_d = (_c = this.contactFormValuesContainer) === null || _c === void 0 ? void 0 : _c.rootForm) === null || _d === void 0 ? void 0 : _d.formTemplateId));
80
+ this.computeInitialValues();
81
81
  }
82
82
  this.computeDependentValues();
83
83
  }
@@ -145,24 +145,45 @@ class BridgedFormValuesContainer {
145
145
  })) })), {});
146
146
  }
147
147
  //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
148
- forceValues(fieldValues) {
149
- fieldValues.forEach(([value, metadata]) => {
150
- setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, this.language, value, undefined, metadata, (fvc) => {
151
- const currentContact = this.contactFormValuesContainer.currentContact;
152
- this.contactFormValuesContainer = fvc;
153
- if (this.contact === currentContact) {
154
- this.contact = fvc.currentContact;
148
+ computeInitialValues() {
149
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
150
+ this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {
151
+ var _a;
152
+ try {
153
+ const currentValue = this.getValues(revisionsFilter);
154
+ if (!currentValue || !Object.keys(currentValue).length) {
155
+ const newValue = this.compute(formula);
156
+ if (newValue !== undefined) {
157
+ const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
158
+ if (newValue && !newValue.content[lng] && newValue.content['*']) {
159
+ newValue.content[lng] = newValue.content['*'];
160
+ }
161
+ if (newValue) {
162
+ delete newValue.content['*'];
163
+ }
164
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc) => {
165
+ const currentContact = this.contactFormValuesContainer.currentContact;
166
+ this.contactFormValuesContainer = fvc;
167
+ if (this.contact === currentContact) {
168
+ this.contact = fvc.currentContact;
169
+ }
170
+ });
171
+ }
172
+ }
173
+ }
174
+ catch (e) {
175
+ console.log(`Error while computing formula : ${formula}`, e);
155
176
  }
156
177
  });
157
- });
178
+ }
158
179
  }
159
180
  //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
160
181
  computeDependentValues() {
161
182
  if (this.contactFormValuesContainer.rootForm.formTemplateId) {
162
- this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, formula }) => {
183
+ this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {
163
184
  var _a;
164
185
  try {
165
- const currentValue = this.getVersionedValuesForKey(metadata.label);
186
+ const currentValue = this.getValues(revisionsFilter);
166
187
  const newValue = this.compute(formula);
167
188
  if (newValue !== undefined || currentValue != undefined) {
168
189
  const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
@@ -414,22 +435,22 @@ class ContactFormValuesContainer {
414
435
  const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
415
436
  meta.responsible && (newService.responsible = meta.responsible);
416
437
  meta.valueDate && (newService.valueDate = meta.valueDate);
417
- meta.codes && (newService.codes = meta.codes);
418
- meta.tags && (newService.tags = meta.tags);
438
+ meta.codes && (newService.codes = (0, code_utils_1.normalizeCodes)(meta.codes));
439
+ meta.tags && (newService.tags = (0, code_utils_1.normalizeCodes)(meta.tags));
419
440
  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.changeListeners);
420
441
  this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
421
442
  }
422
443
  }
423
444
  setValue(label, language, value, id, metadata, changeListenersOverrider) {
424
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
445
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
425
446
  const service = (id && ((_b = (_a = this.getServicesInHistory((sid, history) => (sid === id ? history.map((x) => x.revision) : []))[id]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.value)) || this.serviceFactory(label, id);
426
447
  if (!service.id) {
427
448
  throw new Error('Service id must be defined');
428
449
  }
429
450
  console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
430
451
  const newContent = (_c = value === null || value === void 0 ? void 0 : value.content) === null || _c === void 0 ? void 0 : _c[language];
431
- const newCodes = (_d = value === null || value === void 0 ? void 0 : value.codes) !== null && _d !== void 0 ? _d : [];
432
- if (!(0, icure_utils_1.isContentEqual)((_e = service.content) === null || _e === void 0 ? void 0 : _e[language], newContent) || (newCodes && !(0, icure_utils_1.areCodesEqual)(newCodes, (_f = service.codes) !== null && _f !== void 0 ? _f : []))) {
452
+ const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? (0, code_utils_1.normalizeCodes)(value.codes) : [];
453
+ 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 : []))) {
433
454
  const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
434
455
  const newContents = newContent ? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
435
456
  if (!newContent) {
@@ -437,22 +458,22 @@ class ContactFormValuesContainer {
437
458
  }
438
459
  let newCurrentContact;
439
460
  if (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {
440
- newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_g = this.currentContact.services) !== null && _g !== void 0 ? _g : []).some((s) => s.id === service.id)
441
- ? ((_h = this.currentContact.services) !== null && _h !== void 0 ? _h : []).filter((s) => s.id !== service.id)
442
- : [...((_j = this.currentContact.services) !== null && _j !== void 0 ? _j : [])] });
461
+ newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_f = this.currentContact.services) !== null && _f !== void 0 ? _f : []).some((s) => s.id === service.id)
462
+ ? ((_g = this.currentContact.services) !== null && _g !== void 0 ? _g : []).filter((s) => s.id !== service.id)
463
+ : [...((_h = this.currentContact.services) !== null && _h !== void 0 ? _h : [])] });
443
464
  }
444
465
  else {
445
466
  newService.content = newContents;
446
467
  newService.codes = newCodes;
447
468
  if (metadata) {
448
- newService.responsible = (_k = metadata.responsible) !== null && _k !== void 0 ? _k : newService.responsible;
449
- newService.valueDate = (_l = metadata.valueDate) !== null && _l !== void 0 ? _l : newService.valueDate;
450
- newService.tags = (_m = metadata.tags) !== null && _m !== void 0 ? _m : newService.tags;
451
- newService.label = (_o = metadata.label) !== null && _o !== void 0 ? _o : newService.label;
469
+ newService.responsible = (_j = metadata.responsible) !== null && _j !== void 0 ? _j : newService.responsible;
470
+ newService.valueDate = (_k = metadata.valueDate) !== null && _k !== void 0 ? _k : newService.valueDate;
471
+ newService.tags = metadata.tags ? (0, code_utils_1.normalizeCodes)(metadata.tags) : newService.tags;
472
+ newService.label = (_l = metadata.label) !== null && _l !== void 0 ? _l : newService.label;
452
473
  }
453
- newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_p = this.currentContact.services) !== null && _p !== void 0 ? _p : []).some((s) => s.id === service.id)
454
- ? ((_q = this.currentContact.services) !== null && _q !== void 0 ? _q : []).map((s) => (s.id === service.id ? newService : s))
455
- : [...((_r = this.currentContact.services) !== null && _r !== void 0 ? _r : []), newService] });
474
+ newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_m = this.currentContact.services) !== null && _m !== void 0 ? _m : []).some((s) => s.id === service.id)
475
+ ? ((_o = this.currentContact.services) !== null && _o !== void 0 ? _o : []).map((s) => (s.id === service.id ? newService : s))
476
+ : [...((_p = this.currentContact.services) !== null && _p !== void 0 ? _p : []), newService] });
456
477
  }
457
478
  const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, newCurrentContact, this.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)), this.serviceFactory, this.children, this.formFactory, this.changeListeners);
458
479
  changeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
@@ -1 +1 @@
1
- {"version":3,"file":"form-values-container.js","sourceRoot":"","sources":["../../tmp/icure/form-values-container.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAgE;AAChE,kDAA6C;AAI7C,+CAA6H;AAC7H,kDAAmD;AACnD,0CAA8C;AAC9C,+BAAmC;AAEnC,SAAS,MAAM,CAAkB,CAAsD,EAAE,GAAyC;IACjI,6CAA6C;IAC7C,CAAC,CAAC,GAAG,CAAC,CAAA;AACP,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,0BAA0B;IAKtC,QAAQ;QACP,OAAO,WAAW,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAA;IAC3I,CAAC;IAED;;;;;;;;;;;OAWG;IACH,YACS,WAAmB,EAC3B,0BAAsD,EAC9C,WAQU,EAClB,OAAiB,EACT,wBAAoI,GAAG,EAAE,CAAC,EAAE,EAC5I,0BAA4I,GAAG,EAAE,CAAC,EAAE,EACpJ,qBAAmI,GAAG,EAAE,CAAC,EAAE,EAC3I,WAAW,IAAI,EACf,kBAAsE,EAAE;;QAhBxE,gBAAW,GAAX,WAAW,CAAQ;QAEnB,gBAAW,GAAX,WAAW,CAQD;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,CAAC,CAAC,EAAE,6BAA6B,CAAC,CAAC,CAAA;QAC9E,CAAC;KAAA;CACD;AAnWD,gEAmWC;AAED,MAAM,oCAAoC,GAAG,CAC5C,IAAgC,EAChC,KAAa,EACb,QAAgB,EAChB,EAAe,EACf,EAAW,EACX,QAAwB,EACxB,wBAAoE,EACnE,EAAE;;IACH,MAAM,KAAK,GAAG,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnC,IAAI,CAAC,QAAQ,CACZ,KAAK,EACL,QAAQ,EACR;QACC,EAAE,EAAE,EAAE;QACN,KAAK,EAAE,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,KAAK,mCAAI,EAAE;QACtB,OAAO,EAAE,KAAK;YACb,CAAC,CAAC;gBACA,CAAC,QAAQ,CAAC,EAAE,IAAA,oCAAsB,EAAC,QAAQ,EAAE,KAAK,CAAC;aAClD;YACH,CAAC,CAAC,SAAS;KACZ,EACD,EAAE,EACF,QAAQ;QACP,CAAC,CAAC;YACA,KAAK,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,mCAAI,KAAK;YAC/B,WAAW,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC5B,SAAS,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS;YAC9B,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;SACnB;QACH,CAAC,CAAC,SAAS,EACZ,wBAAwB,CACxB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { Contact, Form as ICureForm, Service } from '@icure/api'\nimport { sortedBy } from '../utils/no-lodash'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\nimport { ServiceMetadata } from './model'\nimport { FieldMetadata, FieldValue, PrimitiveType, Validator } from '../components/model'\nimport { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils'\nimport { parsePrimitive } from '../utils/primitive'\nimport { anyDateToDate } from '../utils/dates'\nimport { v4 as uuidv4 } from 'uuid'\n\nfunction notify<Value, Metadata>(l: (fvc: FormValuesContainer<Value, Metadata>) => void, fvc: FormValuesContainer<Value, Metadata>) {\n\t//console.log('Notifying', l, fvc.toString())\n\tl(fvc)\n}\n\n/** This class is a bridge between the ICure API and the generic FormValuesContainer interface.\n * It wraps around a ContactFormValuesContainer and provides a series of services:\n * - It computes dependent values when the form is created\n * - It broadcasts changes from the wrapped ContactFormValuesContainer to its listeners\n * - It provides a way to compute formulas in a sandboxed environment\n * - It bridges the setValues and setMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the FieldValue to a Service\n * \t\t- converting the FieldMetadata to a ServiceMetadata\n * - It bridges the getValues and getMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the Service to a FieldValue\n * \t\t- converting the ServiceMetadata to a FieldMetadata\n * - It lazily creates bridges the children by\n * - lazily creating BridgedFormValuesContainer when the children of the wrapped ContactFormValuesContainer are accessed\n * - creating a new ContactFormValuesContainer and wrapping it in a BridgedFormValuesContainer when a child is added\n *\n * The icure-form typically accepts a BridgedFormValuesContainer as a prop and uses it to interact with the form.\n *\n * This class is fairly generic and can be used as an inspiration or subclassed for other bridges\n */\nexport class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {\n\tprivate contact: Contact\n\tprivate contactFormValuesContainer: ContactFormValuesContainer\n\tprivate _id: string = uuidv4()\n\tprivate mutateAndNotify: (newContactFormValuesContainer: ContactFormValuesContainer) => BridgedFormValuesContainer\n\ttoString(): string {\n\t\treturn `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`\n\t}\n\n\t/**\n\t * Creates an instance of BridgedFormValuesContainer.\n\t * @param responsible The id of the data owner responsible for the creation of the values\n\t * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\t * @param contactFormValuesContainer The wrapped ContactFormValuesContainer\n\t * @param interpreter A function that can interpret formulas\n\t * @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId\n\t * @param validatorsProvider A function that provides the validators for a given anchorId and templateId\n\t * @param language The language in which the values are displayed\n\t * @param changeListeners The listeners that will be notified when the values change\n\t * @param initialValuesProvider A lambda that provides the initial values of the form\n\t */\n\tconstructor(\n\t\tprivate responsible: string,\n\t\tcontactFormValuesContainer: ContactFormValuesContainer,\n\t\tprivate interpreter?: <\n\t\t\tT,\n\t\t\tS extends {\n\t\t\t\t[key: string | symbol]: unknown\n\t\t\t},\n\t\t>(\n\t\t\tformula: string,\n\t\t\tsandbox: S,\n\t\t) => T | undefined,\n\t\tcontact?: Contact,\n\t\tprivate initialValuesProvider: (fvc: BridgedFormValuesContainer, anchorId?: string, templateId?: string) => [FieldValue, FieldMetadata][] = () => [],\n\t\tprivate dependentValuesProvider: (anchorId: string | undefined, templateId: string | undefined) => { metadata: FieldMetadata; formula: string }[] = () => [],\n\t\tprivate validatorsProvider: (anchorId: string | undefined, templateId: string) => { metadata: FieldMetadata; validators: Validator[] }[] = () => [],\n\t\tprivate language = 'en',\n\t\tprivate changeListeners: ((newValue: BridgedFormValuesContainer) => void)[] = [],\n\t) {\n\t\tconsole.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`)\n\t\t//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values\n\t\tthis.contactFormValuesContainer = contactFormValuesContainer\n\t\tthis.mutateAndNotify = (newContactFormValuesContainer: ContactFormValuesContainer) => {\n\t\t\tnewContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify)\n\t\t\tconst newBridgedFormValueContainer = new BridgedFormValuesContainer(\n\t\t\t\tthis.responsible,\n\t\t\t\tnewContactFormValuesContainer,\n\t\t\t\tthis.interpreter,\n\t\t\t\tthis.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact,\n\t\t\t\tthis.initialValuesProvider,\n\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\tthis.validatorsProvider,\n\t\t\t\tthis.language,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer))\n\t\t\treturn newBridgedFormValueContainer\n\t\t}\n\t\tthis.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify)\n\t\tthis.contact = contact ?? contactFormValuesContainer.currentContact\n\t\tif (this.contactFormValuesContainer.mustBeInitialised()) {\n\t\t\tthis.forceValues(initialValuesProvider(this, this.contactFormValuesContainer?.rootForm?.descr, this.contactFormValuesContainer?.rootForm?.formTemplateId))\n\t\t}\n\t\tthis.computeDependentValues()\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.contactFormValuesContainer.getLabel()\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.contactFormValuesContainer.getFormId()\n\t}\n\n\tgetContactFormValuesContainer() {\n\t\treturn this.contactFormValuesContainer\n\t}\n\n\tregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue> {\n\t\treturn Object.entries(\n\t\t\tthis.contactFormValuesContainer.getValues((id, history) =>\n\t\t\t\trevisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory\n\t\t\t\t\t\t.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)\n\t\t\t\t\t\t.map(({ revision, modified, value: sm }) => ({\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tmodified,\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tlabel: sm.label,\n\t\t\t\t\t\t\t\towner: sm.responsible,\n\t\t\t\t\t\t\t\ttags: sm.tags?.map(codeStubToCode),\n\t\t\t\t\t\t\t\tvalueDate: sm.valueDate,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t),\n\t\t).reduce((acc, [id, history]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontent: Object.entries(s.content ?? {}).reduce((acc, [lng, cnt]) => {\n\t\t\t\t\t\t\tconst converted = contentToPrimitiveType(lng, cnt)\n\t\t\t\t\t\t\treturn converted ? { ...acc, [lng]: converted } : acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\tcodes: s.codes?.map(codeStubToCode),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}\n\t\t}, {} as VersionedData<FieldValue>)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata> {\n\t\treturn Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce(\n\t\t\t(acc, [id, history]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tlabel: s.label,\n\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\tdiscordantMetadata: () => ({\n\t\t\t\t\t\t\t...(s.responsible !== this.responsible ? { owner: this.responsible } : {}),\n\t\t\t\t\t\t\t...(Math.abs(+(anyDateToDate(s.valueDate) ?? 0) - +(anyDateToDate(this.contact.created) ?? 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}),\n\t\t\t{},\n\t\t)\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate forceValues(fieldValues: [FieldValue, FieldMetadata][]) {\n\t\tfieldValues.forEach(([value, metadata]) => {\n\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, this.language, value, undefined, metadata, (fvc: ContactFormValuesContainer) => {\n\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t}\n\t\t\t})\n\t\t})\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeDependentValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getVersionedValuesForKey(metadata.label)\n\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\tif (newValue !== undefined || currentValue != undefined) {\n\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsetValueOnContactFormValuesContainer(\n\t\t\t\t\t\t\tthis.contactFormValuesContainer,\n\t\t\t\t\t\t\tmetadata.label,\n\t\t\t\t\t\t\tlng,\n\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\tObject.keys(currentValue ?? {})[0],\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\t(fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void {\n\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata)\n\t}\n\n\tsetMetadata(meta: FieldMetadata, id?: string | undefined): void {\n\t\tthis.contactFormValuesContainer.setMetadata(\n\t\t\t{\n\t\t\t\tlabel: meta.label,\n\t\t\t\tresponsible: meta.owner,\n\t\t\t\tvalueDate: meta.valueDate,\n\t\t\t\ttags: meta.tags,\n\t\t\t},\n\t\t\tid,\n\t\t)\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tthis.contactFormValuesContainer.delete(serviceId)\n\t}\n\n\tprivate getVersionedValuesForKey(key: string | symbol) {\n\t\treturn this.getValues((id, history) => (history?.[0]?.value?.label && key === history[0].value.label ? [history?.[0]?.revision] : []))\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined {\n\t\t// noinspection JSUnusedGlobalSymbols\n\t\tconst parseContent = (content?: { [key: string]: PrimitiveType }) => {\n\t\t\tif (!content) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst primitive = content[this.language] ?? content['*'] ?? content[Object.keys(content)[0]]\n\t\t\treturn primitive && parsePrimitive(primitive)\n\t\t}\n\t\tconst log = console.log\n\t\tconst native = {\n\t\t\tparseInt: parseInt,\n\t\t\tparseFloat: parseFloat,\n\t\t\tDate: Date,\n\t\t\tMath: Math,\n\t\t\tNumber: Number,\n\t\t\tString: String,\n\t\t\tBoolean: Boolean,\n\t\t\tArray: Array,\n\t\t\tObject: Object,\n\t\t\tparseContent,\n\t\t\tvalidate: {\n\t\t\t\tnotBlank: (self: any, label: string) => {\n\t\t\t\t\tconst value = parseContent((self[label as any] as any)?.[0]?.content)\n\t\t\t\t\treturn !!(value as any)?.trim()?.length\n\t\t\t\t},\n\t\t\t},\n\t\t\tlog,\n\t\t} as { [key: string]: any }\n\t\tconst proxy: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => !!native[key as string] || key === 'self' || Object.keys(this.getVersionedValuesForKey(key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => {\n\t\t\t\tif (key === 'undefined') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst nativeValue = native[key as string]\n\t\t\t\tif (!!nativeValue) {\n\t\t\t\t\treturn nativeValue\n\t\t\t\t}\n\t\t\t\treturn key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => v[0]?.value)\n\t\t\t},\n\t\t})\n\t\treturn this.interpreter?.(formula, sandbox ?? proxy)\n\t}\n\n\tgetChildren(): FormValuesContainer<FieldValue, FieldMetadata>[] {\n\t\tconst children = this.contactFormValuesContainer\n\t\t\t.getChildren()\n\t\t\t.map(\n\t\t\t\t(fvc) =>\n\t\t\t\t\tnew BridgedFormValuesContainer(\n\t\t\t\t\t\tthis.responsible,\n\t\t\t\t\t\tfvc,\n\t\t\t\t\t\tthis.interpreter,\n\t\t\t\t\t\tthis.contact,\n\t\t\t\t\t\tthis.initialValuesProvider,\n\t\t\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\t\t\tthis.validatorsProvider,\n\t\t\t\t\t\tthis.language,\n\t\t\t\t\t\t[],\n\t\t\t\t\t),\n\t\t\t)\n\t\tconsole.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider)\n\t\treturn children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\treturn this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).flatMap(\n\t\t\t\t({ metadata, validators }) =>\n\t\t\t\t\tvalidators\n\t\t\t\t\t\t.map(({ validation, message }) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn this.compute(validation) ? undefined : [metadata, message]\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.log(`Error while computing validation : ${validation}`, e)\n\t\t\t\t\t\t\t\treturn undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((x) => !!x) as [FieldMetadata, string][],\n\t\t\t)\n\t\t} else {\n\t\t\treturn []\n\t\t}\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tawait this.contactFormValuesContainer.addChild(anchorId, templateId, label)\n\t}\n\n\tasync removeChild(container: BridgedFormValuesContainer): Promise<void> {\n\t\tawait this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer)\n\t}\n\n\tsynchronise() {\n\t\tthis.contactFormValuesContainer.synchronise()\n\t\treturn this\n\t}\n}\n\n/**\n * 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.\n * The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.\n * The `contactsHistory` is used to provide the full history of the services.\n * The hierarchy of ContactFormValuesContainer has to be maintained by the manager of the instances of this class (typically the BridgedFormValuesContainer).\n * Each ContactFormValuesContainer has a reference to its `rootForm`.\n * The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.\n */\nexport class ContactFormValuesContainer implements FormValuesContainer<Service, ServiceMetadata> {\n\trootForm: ICureForm\n\tcurrentContact: Contact //The contact of the moment, used to record new modifications\n\tcontactsHistory: Contact[] //Must be sorted (most recent first), contains all the contacts linked to this form\n\tchildren: ContactFormValuesContainer[] //Direct children of the ContactFormValuesContainer\n\tserviceFactory: (label: string, serviceId?: string) => Service\n\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>\n\n\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[]\n\tprivate _id: string = uuidv4()\n\tprivate _initialised = false\n\n\ttoString(): string {\n\t\treturn `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`\n\t}\n\n\tmustBeInitialised() {\n\t\treturn !this._initialised\n\t}\n\n\tconstructor(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tchildren: ContactFormValuesContainer[],\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t\tinitialised = true,\n\t) {\n\t\tconsole.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`)\n\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.rootForm = rootForm\n\t\tthis.currentContact = currentContact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.children = children\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.formFactory = formFactory\n\t\tthis.changeListeners = changeListeners\n\t\tthis._initialised = initialised\n\n\t\tthis.synchronise()\n\t}\n\n\tsynchronise() {\n\t\tthis.children.forEach((childFVC) => {\n\t\t\tthis.registerChildFormValuesContainer(childFVC.synchronise())\n\t\t})\n\t\treturn this\n\t}\n\n\t//Make sure that when a child is changed, a new version of this is created with the updated child\n\tregisterChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer) {\n\t\tchildFormValueContainer.changeListeners = [\n\t\t\t(newValue) => {\n\t\t\t\tconsole.log(`Child ${newValue._id} ${childFormValueContainer.rootForm.formTemplateId} changed, updating parent ${this._id} ${this.rootForm.formTemplateId}`)\n\t\t\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\t\tthis.rootForm,\n\t\t\t\t\tthis.currentContact,\n\t\t\t\t\tthis.contactsHistory,\n\t\t\t\t\tthis.serviceFactory,\n\t\t\t\t\tthis.children.map((c) => {\n\t\t\t\t\t\treturn c.rootForm.id === childFormValueContainer.rootForm.id ? newValue : c\n\t\t\t\t\t}),\n\t\t\t\t\tthis.formFactory,\n\t\t\t\t)\n\t\t\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t\t\t},\n\t\t]\n\t}\n\n\tstatic async fromFormsHierarchy(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tformChildrenProvider: (parentId: string) => Promise<ICureForm[]>,\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t): Promise<ContactFormValuesContainer> {\n\t\tconst contactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\trootForm,\n\t\t\tcurrentContact,\n\t\t\tcontactsHistory,\n\t\t\tserviceFactory,\n\t\t\trootForm.id\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait formChildrenProvider(rootForm.id)\n\t\t\t\t\t\t).map(\n\t\t\t\t\t\t\tasync (f) =>\n\t\t\t\t\t\t\t\t// eslint-disable-next-line max-len\n\t\t\t\t\t\t\t\tawait ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory),\n\t\t\t\t\t\t),\n\t\t\t\t )\n\t\t\t\t: [],\n\t\t\tformFactory,\n\t\t\tchangeListeners,\n\t\t\tfalse,\n\t\t)\n\t\tcontactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC))\n\n\t\treturn contactFormValuesContainer\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.rootForm.descr ?? ''\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.rootForm?.formTemplateId\n\t}\n\n\tregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetChildren(): ContactFormValuesContainer[] {\n\t\treturn this.children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tthrow new Error('Validation not supported at contact level')\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\treturn Object.entries(this.getServicesInHistory(revisionsFilter)).reduce(\n\t\t\t(acc, [id, history]) =>\n\t\t\t\thistory.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t[id]: [...history].sort((a, b) => (b?.modified || +new Date()) - (a?.modified || +new Date())),\n\t\t\t\t\t }\n\t\t\t\t\t: acc,\n\t\t\t{},\n\t\t)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata> {\n\t\treturn [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\t(ctc.services ?? [])\n\t\t\t\t\t\t.filter((s) => s.id === id)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\t\tmodified: s.modified,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: s.label ?? s.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\t\tacc,\n\t\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as { [id: string]: Version<ServiceMetadata>[] },\n\t\t\t) //index services in history by id\n\t}\n\n\tsetMetadata(meta: ServiceMetadata, id?: string): void {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(meta.label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tif (\n\t\t\t(meta.responsible && service.responsible !== meta.responsible) ||\n\t\t\t(meta.valueDate && service.valueDate !== meta.valueDate) ||\n\t\t\t(meta.codes && service.codes !== meta.codes) ||\n\t\t\t(meta.tags && service.tags !== meta.tags)\n\t\t) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tmeta.responsible && (newService.responsible = meta.responsible)\n\t\t\tmeta.valueDate && (newService.valueDate = meta.valueDate)\n\t\t\tmeta.codes && (newService.codes = meta.codes)\n\t\t\tmeta.tags && (newService.tags = meta.tags)\n\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === service.id ? newService : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void {\n\t\tconst service =\n\t\t\t(id && this.getServicesInHistory((sid: string, history) => (sid === id ? history.map((x) => x.revision) : []))[id]?.[0]?.value) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tconsole.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)\n\t\tconst newContent = value?.content?.[language]\n\t\tconst newCodes = value?.codes ?? []\n\t\tif (!isContentEqual(service.content?.[language], newContent) || (newCodes && !areCodesEqual(newCodes, service.codes ?? []))) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tconst newContents = newContent ? { ...(service.content || {}), [language]: newContent } : { ...(service.content || {}) }\n\t\t\tif (!newContent) {\n\t\t\t\tdelete newContents[language]\n\t\t\t}\n\n\t\t\tlet newCurrentContact: Contact\n\t\t\tif (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).filter((s) => s.id !== service.id)\n\t\t\t\t\t\t: [...(this.currentContact.services ?? [])],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewService.content = newContents\n\t\t\t\tnewService.codes = newCodes\n\n\t\t\t\tif (metadata) {\n\t\t\t\t\tnewService.responsible = metadata.responsible ?? newService.responsible\n\t\t\t\t\tnewService.valueDate = metadata.valueDate ?? newService.valueDate\n\t\t\t\t\tnewService.tags = metadata.tags ?? newService.tags\n\t\t\t\t\tnewService.label = metadata.label ?? newService.label\n\t\t\t\t}\n\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).map((s) => (s.id === service.id ? newService : s))\n\t\t\t\t\t\t: [...(this.currentContact.services ?? []), newService],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tnewCurrentContact,\n\t\t\t\tthis.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)),\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tchangeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tconst service = this.getServiceInCurrentContact(serviceId)\n\t\tif (service) {\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === serviceId ? new Service({ ...service, endOfLife: Date.now() }) : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tcompute<T>(): T | undefined {\n\t\tthrow new Error('Compute not supported at contact level')\n\t}\n\n\t/** returns all services in history that match a selector\n\t *\n\t * @private\n\t * @param revisionsFilter\n\t */\n\tprivate getServicesInHistory(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\tconst indexedServices = [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\tctc.services?.reduce(\n\t\t\t\t\t\t(acc, s) => (s.id ? { ...acc, [s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({ revision: ctc.rev ?? null, modified: ctc.created, value: s }) } : acc),\n\t\t\t\t\t\tacc,\n\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as VersionedData<Service>,\n\t\t\t) //index services in history by id\n\t\treturn Object.entries(indexedServices)\n\t\t\t.map(([id, history]) => {\n\t\t\t\tconst keptRevisions = revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tmodified,\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tlabel: s.label ?? s.id ?? '',\n\t\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\tcodes: s.codes,\n\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t\treturn [id, history.filter(({ revision }) => keptRevisions.includes(revision))] as [string, Version<Service>[]]\n\t\t\t})\n\t\t\t.reduce((acc, [id, history]) => ({ ...acc, [id]: history }), {})\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tconst newForm = await this.formFactory(anchorId, templateId, label)\n\t\tconst childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, [], false)\n\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\t[...this.children, childFVC],\n\t\t\tthis.formFactory,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tnewContactFormValuesContainer.registerChildFormValuesContainer(childFVC)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n\n\tprivate getServiceInCurrentContact(id: string): Service | undefined {\n\t\tconst service = (this.currentContact.services || [])?.find((s) => s.id === id)\n\t\treturn service ?? undefined\n\t}\n\n\tasync removeChild(container: ContactFormValuesContainer): Promise<void> {\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\tthis.children.filter((c) => c.rootForm.id !== container.rootForm.id),\n\t\t\tthis.formFactory,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n}\n\nconst setValueOnContactFormValuesContainer = (\n\tcfvc: ContactFormValuesContainer,\n\tlabel: string,\n\tlanguage: string,\n\tfv?: FieldValue,\n\tid?: string,\n\tmetadata?: FieldMetadata,\n\tchangeListenersOverrider?: (fvc: ContactFormValuesContainer) => void,\n) => {\n\tconst value = fv?.content[language]\n\tcfvc.setValue(\n\t\tlabel,\n\t\tlanguage,\n\t\t{\n\t\t\tid: id,\n\t\t\tcodes: fv?.codes ?? [],\n\t\t\tcontent: value\n\t\t\t\t? {\n\t\t\t\t\t\t[language]: primitiveTypeToContent(language, value),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t},\n\t\tid,\n\t\tmetadata\n\t\t\t? {\n\t\t\t\t\tlabel: metadata?.label ?? label,\n\t\t\t\t\tresponsible: metadata?.owner,\n\t\t\t\t\tvalueDate: metadata?.valueDate,\n\t\t\t\t\ttags: metadata?.tags,\n\t\t\t }\n\t\t\t: undefined,\n\t\tchangeListenersOverrider,\n\t)\n}\n"]}
1
+ {"version":3,"file":"form-values-container.js","sourceRoot":"","sources":["../../tmp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ACH,CAAC,CAAC,SAAS;KACZ,EACD,EAAE,EACF,QAAQ;QACP,CAAC,CAAC;YACA,KAAK,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,mCAAI,KAAK;YAC/B,WAAW,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK;YAC5B,SAAS,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,SAAS;YAC9B,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI;SACnB;QACH,CAAC,CAAC,SAAS,EACZ,wBAAwB,CACxB,CAAA;AACF,CAAC,CAAA","sourcesContent":["import { Contact, Form as ICureForm, Service } from '@icure/api'\nimport { sortedBy } from '../utils/no-lodash'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\nimport { ServiceMetadata } from './model'\nimport { FieldMetadata, FieldValue, PrimitiveType, Validator } from '../components/model'\nimport { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils'\nimport { parsePrimitive } from '../utils/primitive'\nimport { anyDateToDate } from '../utils/dates'\nimport { v4 as uuidv4 } from 'uuid'\nimport { normalizeCodes } from '../utils/code-utils'\n\nfunction notify<Value, Metadata>(l: (fvc: FormValuesContainer<Value, Metadata>) => void, fvc: FormValuesContainer<Value, Metadata>) {\n\t//console.log('Notifying', l, fvc.toString())\n\tl(fvc)\n}\n\n/** This class is a bridge between the ICure API and the generic FormValuesContainer interface.\n * It wraps around a ContactFormValuesContainer and provides a series of services:\n * - It computes dependent values when the form is created\n * - It broadcasts changes from the wrapped ContactFormValuesContainer to its listeners\n * - It provides a way to compute formulas in a sandboxed environment\n * - It bridges the setValues and setMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the FieldValue to a Service\n * \t\t- converting the FieldMetadata to a ServiceMetadata\n * - It bridges the getValues and getMetadata methods with the wrapped ContactFormValuesContainer by\n * \t\t- converting the Service to a FieldValue\n * \t\t- converting the ServiceMetadata to a FieldMetadata\n * - It lazily creates bridges the children by\n * - lazily creating BridgedFormValuesContainer when the children of the wrapped ContactFormValuesContainer are accessed\n * - creating a new ContactFormValuesContainer and wrapping it in a BridgedFormValuesContainer when a child is added\n *\n * The icure-form typically accepts a BridgedFormValuesContainer as a prop and uses it to interact with the form.\n *\n * This class is fairly generic and can be used as an inspiration or subclassed for other bridges\n */\nexport class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {\n\tprivate contact: Contact\n\tprivate contactFormValuesContainer: ContactFormValuesContainer\n\tprivate _id: string = uuidv4()\n\tprivate mutateAndNotify: (newContactFormValuesContainer: ContactFormValuesContainer) => BridgedFormValuesContainer\n\ttoString(): string {\n\t\treturn `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`\n\t}\n\n\t/**\n\t * Creates an instance of BridgedFormValuesContainer.\n\t * @param responsible The id of the data owner responsible for the creation of the values\n\t * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\t * @param contactFormValuesContainer The wrapped ContactFormValuesContainer\n\t * @param interpreter A function that can interpret formulas\n\t * @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId\n\t * @param validatorsProvider A function that provides the validators for a given anchorId and templateId\n\t * @param language The language in which the values are displayed\n\t * @param changeListeners The listeners that will be notified when the values change\n\t * @param initialValuesProvider A lambda that provides the initial values of the form\n\t */\n\tconstructor(\n\t\tprivate responsible: string,\n\t\tcontactFormValuesContainer: ContactFormValuesContainer,\n\t\tprivate interpreter?: <\n\t\t\tT,\n\t\t\tS extends {\n\t\t\t\t[key: string | symbol]: unknown\n\t\t\t},\n\t\t>(\n\t\t\tformula: string,\n\t\t\tsandbox: S,\n\t\t) => T | undefined,\n\t\tcontact?: Contact,\n\t\tprivate initialValuesProvider: (\n\t\t\tanchorId?: string,\n\t\t\ttemplateId?: string,\n\t\t) => { metadata: FieldMetadata; revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]; formula: string }[] = () => [],\n\t\tprivate dependentValuesProvider: (\n\t\t\tanchorId: string | undefined,\n\t\t\ttemplateId: string | undefined,\n\t\t) => { metadata: FieldMetadata; revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]; formula: string }[] = () => [],\n\t\tprivate validatorsProvider: (anchorId: string | undefined, templateId: string) => { metadata: FieldMetadata; validators: Validator[] }[] = () => [],\n\t\tprivate language = 'en',\n\t\tprivate changeListeners: ((newValue: BridgedFormValuesContainer) => void)[] = [],\n\t) {\n\t\tconsole.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`)\n\t\t//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values\n\t\tthis.contactFormValuesContainer = contactFormValuesContainer\n\t\tthis.mutateAndNotify = (newContactFormValuesContainer: ContactFormValuesContainer) => {\n\t\t\tnewContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify)\n\t\t\tconst newBridgedFormValueContainer = new BridgedFormValuesContainer(\n\t\t\t\tthis.responsible,\n\t\t\t\tnewContactFormValuesContainer,\n\t\t\t\tthis.interpreter,\n\t\t\t\tthis.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact,\n\t\t\t\tthis.initialValuesProvider,\n\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\tthis.validatorsProvider,\n\t\t\t\tthis.language,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer))\n\t\t\treturn newBridgedFormValueContainer\n\t\t}\n\t\tthis.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify)\n\t\tthis.contact = contact ?? contactFormValuesContainer.currentContact\n\t\tif (this.contactFormValuesContainer.mustBeInitialised()) {\n\t\t\tthis.computeInitialValues()\n\t\t}\n\t\tthis.computeDependentValues()\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.contactFormValuesContainer.getLabel()\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.contactFormValuesContainer.getFormId()\n\t}\n\n\tgetContactFormValuesContainer() {\n\t\treturn this.contactFormValuesContainer\n\t}\n\n\tregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue> {\n\t\treturn Object.entries(\n\t\t\tthis.contactFormValuesContainer.getValues((id, history) =>\n\t\t\t\trevisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory\n\t\t\t\t\t\t.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)\n\t\t\t\t\t\t.map(({ revision, modified, value: sm }) => ({\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tmodified,\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tlabel: sm.label,\n\t\t\t\t\t\t\t\towner: sm.responsible,\n\t\t\t\t\t\t\t\ttags: sm.tags?.map(codeStubToCode),\n\t\t\t\t\t\t\t\tvalueDate: sm.valueDate,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t),\n\t\t).reduce((acc, [id, history]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontent: Object.entries(s.content ?? {}).reduce((acc, [lng, cnt]) => {\n\t\t\t\t\t\t\tconst converted = contentToPrimitiveType(lng, cnt)\n\t\t\t\t\t\t\treturn converted ? { ...acc, [lng]: converted } : acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\tcodes: s.codes?.map(codeStubToCode),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}\n\t\t}, {} as VersionedData<FieldValue>)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata> {\n\t\treturn Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce(\n\t\t\t(acc, [id, history]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tlabel: s.label,\n\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\tdiscordantMetadata: () => ({\n\t\t\t\t\t\t\t...(s.responsible !== this.responsible ? { owner: this.responsible } : {}),\n\t\t\t\t\t\t\t...(Math.abs(+(anyDateToDate(s.valueDate) ?? 0) - +(anyDateToDate(this.contact.created) ?? 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {}),\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}),\n\t\t\t{},\n\t\t)\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeInitialValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(\n\t\t\t\t({ metadata, revisionsFilter, formula }) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\t\tif (!currentValue || !Object.keys(currentValue).length) {\n\t\t\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\t\t\tif (newValue !== undefined) {\n\t\t\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeDependentValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(\n\t\t\t\t({ metadata, revisionsFilter, formula }) => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst currentValue = this.getValues(revisionsFilter)\n\t\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\t\tif (newValue !== undefined || currentValue != undefined) {\n\t\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsetValueOnContactFormValuesContainer(\n\t\t\t\t\t\t\t\tthis.contactFormValuesContainer,\n\t\t\t\t\t\t\t\tmetadata.label,\n\t\t\t\t\t\t\t\tlng,\n\t\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\t\tObject.keys(currentValue ?? {})[0],\n\t\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t\t\t(fvc: ContactFormValuesContainer) => {\n\t\t\t\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t\t\t\tthis.contactFormValuesContainer = fvc\n\t\t\t\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\t\t\t\tthis.contact = fvc.currentContact\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): void {\n\t\tsetValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata)\n\t}\n\n\tsetMetadata(meta: FieldMetadata, id?: string | undefined): void {\n\t\tthis.contactFormValuesContainer.setMetadata(\n\t\t\t{\n\t\t\t\tlabel: meta.label,\n\t\t\t\tresponsible: meta.owner,\n\t\t\t\tvalueDate: meta.valueDate,\n\t\t\t\ttags: meta.tags,\n\t\t\t},\n\t\t\tid,\n\t\t)\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tthis.contactFormValuesContainer.delete(serviceId)\n\t}\n\n\tprivate getVersionedValuesForKey(key: string | symbol) {\n\t\treturn this.getValues((id, history) => (history?.[0]?.value?.label && key === history[0].value.label ? [history?.[0]?.revision] : []))\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined {\n\t\t// noinspection JSUnusedGlobalSymbols\n\t\tconst parseContent = (content?: { [key: string]: PrimitiveType }) => {\n\t\t\tif (!content) {\n\t\t\t\treturn undefined\n\t\t\t}\n\t\t\tconst primitive = content[this.language] ?? content['*'] ?? content[Object.keys(content)[0]]\n\t\t\treturn primitive && parsePrimitive(primitive)\n\t\t}\n\t\tconst log = console.log\n\t\tconst native = {\n\t\t\tparseInt: parseInt,\n\t\t\tparseFloat: parseFloat,\n\t\t\tDate: Date,\n\t\t\tMath: Math,\n\t\t\tNumber: Number,\n\t\t\tString: String,\n\t\t\tBoolean: Boolean,\n\t\t\tArray: Array,\n\t\t\tObject: Object,\n\t\t\tparseContent,\n\t\t\tvalidate: {\n\t\t\t\tnotBlank: (self: any, label: string) => {\n\t\t\t\t\tconst value = parseContent((self[label as any] as any)?.[0]?.content)\n\t\t\t\t\treturn !!(value as any)?.trim()?.length\n\t\t\t\t},\n\t\t\t},\n\t\t\tlog,\n\t\t} as { [key: string]: any }\n\t\tconst proxy: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => !!native[key as string] || key === 'self' || Object.keys(this.getVersionedValuesForKey(key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => {\n\t\t\t\tif (key === 'undefined') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst nativeValue = native[key as string]\n\t\t\t\tif (!!nativeValue) {\n\t\t\t\t\treturn nativeValue\n\t\t\t\t}\n\t\t\t\treturn key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => v[0]?.value)\n\t\t\t},\n\t\t})\n\t\treturn this.interpreter?.(formula, sandbox ?? proxy)\n\t}\n\n\tgetChildren(): FormValuesContainer<FieldValue, FieldMetadata>[] {\n\t\tconst children = this.contactFormValuesContainer\n\t\t\t.getChildren()\n\t\t\t.map(\n\t\t\t\t(fvc) =>\n\t\t\t\t\tnew BridgedFormValuesContainer(\n\t\t\t\t\t\tthis.responsible,\n\t\t\t\t\t\tfvc,\n\t\t\t\t\t\tthis.interpreter,\n\t\t\t\t\t\tthis.contact,\n\t\t\t\t\t\tthis.initialValuesProvider,\n\t\t\t\t\t\tthis.dependentValuesProvider,\n\t\t\t\t\t\tthis.validatorsProvider,\n\t\t\t\t\t\tthis.language,\n\t\t\t\t\t\t[],\n\t\t\t\t\t),\n\t\t\t)\n\t\tconsole.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider)\n\t\treturn children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\treturn this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).flatMap(\n\t\t\t\t({ metadata, validators }) =>\n\t\t\t\t\tvalidators\n\t\t\t\t\t\t.map(({ validation, message }) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn this.compute(validation) ? undefined : [metadata, message]\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.log(`Error while computing validation : ${validation}`, e)\n\t\t\t\t\t\t\t\treturn undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((x) => !!x) as [FieldMetadata, string][],\n\t\t\t)\n\t\t} else {\n\t\t\treturn []\n\t\t}\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tawait this.contactFormValuesContainer.addChild(anchorId, templateId, label)\n\t}\n\n\tasync removeChild(container: BridgedFormValuesContainer): Promise<void> {\n\t\tawait this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer)\n\t}\n\n\tsynchronise() {\n\t\tthis.contactFormValuesContainer.synchronise()\n\t\treturn this\n\t}\n}\n\n/**\n * 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.\n * The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.\n * The `contactsHistory` is used to provide the full history of the services.\n * The hierarchy of ContactFormValuesContainer has to be maintained by the manager of the instances of this class (typically the BridgedFormValuesContainer).\n * Each ContactFormValuesContainer has a reference to its `rootForm`.\n * The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.\n */\nexport class ContactFormValuesContainer implements FormValuesContainer<Service, ServiceMetadata> {\n\trootForm: ICureForm\n\tcurrentContact: Contact //The contact of the moment, used to record new modifications\n\tcontactsHistory: Contact[] //Must be sorted (most recent first), contains all the contacts linked to this form\n\tchildren: ContactFormValuesContainer[] //Direct children of the ContactFormValuesContainer\n\tserviceFactory: (label: string, serviceId?: string) => Service\n\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>\n\n\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[]\n\tprivate _id: string = uuidv4()\n\tprivate _initialised = false\n\n\ttoString(): string {\n\t\treturn `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`\n\t}\n\n\tmustBeInitialised() {\n\t\treturn !this._initialised\n\t}\n\n\tconstructor(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tchildren: ContactFormValuesContainer[],\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t\tinitialised = true,\n\t) {\n\t\tconsole.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`)\n\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.rootForm = rootForm\n\t\tthis.currentContact = currentContact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.children = children\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.formFactory = formFactory\n\t\tthis.changeListeners = changeListeners\n\t\tthis._initialised = initialised\n\n\t\tthis.synchronise()\n\t}\n\n\tsynchronise() {\n\t\tthis.children.forEach((childFVC) => {\n\t\t\tthis.registerChildFormValuesContainer(childFVC.synchronise())\n\t\t})\n\t\treturn this\n\t}\n\n\t//Make sure that when a child is changed, a new version of this is created with the updated child\n\tregisterChildFormValuesContainer(childFormValueContainer: ContactFormValuesContainer) {\n\t\tchildFormValueContainer.changeListeners = [\n\t\t\t(newValue) => {\n\t\t\t\tconsole.log(`Child ${newValue._id} ${childFormValueContainer.rootForm.formTemplateId} changed, updating parent ${this._id} ${this.rootForm.formTemplateId}`)\n\t\t\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\t\tthis.rootForm,\n\t\t\t\t\tthis.currentContact,\n\t\t\t\t\tthis.contactsHistory,\n\t\t\t\t\tthis.serviceFactory,\n\t\t\t\t\tthis.children.map((c) => {\n\t\t\t\t\t\treturn c.rootForm.id === childFormValueContainer.rootForm.id ? newValue : c\n\t\t\t\t\t}),\n\t\t\t\t\tthis.formFactory,\n\t\t\t\t)\n\t\t\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t\t\t},\n\t\t]\n\t}\n\n\tstatic async fromFormsHierarchy(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tformChildrenProvider: (parentId: string) => Promise<ICureForm[]>,\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t): Promise<ContactFormValuesContainer> {\n\t\tconst contactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\trootForm,\n\t\t\tcurrentContact,\n\t\t\tcontactsHistory,\n\t\t\tserviceFactory,\n\t\t\trootForm.id\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait formChildrenProvider(rootForm.id)\n\t\t\t\t\t\t).map(\n\t\t\t\t\t\t\tasync (f) =>\n\t\t\t\t\t\t\t\t// eslint-disable-next-line max-len\n\t\t\t\t\t\t\t\tawait ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory),\n\t\t\t\t\t\t),\n\t\t\t\t )\n\t\t\t\t: [],\n\t\t\tformFactory,\n\t\t\tchangeListeners,\n\t\t\tfalse,\n\t\t)\n\t\tcontactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC))\n\n\t\treturn contactFormValuesContainer\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.rootForm.descr ?? ''\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.rootForm?.formTemplateId\n\t}\n\n\tregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetChildren(): ContactFormValuesContainer[] {\n\t\treturn this.children\n\t}\n\n\tgetValidationErrors(): [FieldMetadata, string][] {\n\t\tthrow new Error('Validation not supported at contact level')\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\treturn Object.entries(this.getServicesInHistory(revisionsFilter)).reduce(\n\t\t\t(acc, [id, history]) =>\n\t\t\t\thistory.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t[id]: [...history].sort((a, b) => (b?.modified || +new Date()) - (a?.modified || +new Date())),\n\t\t\t\t\t }\n\t\t\t\t\t: acc,\n\t\t\t{},\n\t\t)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata> {\n\t\treturn [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\t(ctc.services ?? [])\n\t\t\t\t\t\t.filter((s) => s.id === id)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\t\tmodified: s.modified,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: s.label ?? s.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\t\tacc,\n\t\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as { [id: string]: Version<ServiceMetadata>[] },\n\t\t\t) //index services in history by id\n\t}\n\n\tsetMetadata(meta: ServiceMetadata, id?: string): void {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(meta.label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tif (\n\t\t\t(meta.responsible && service.responsible !== meta.responsible) ||\n\t\t\t(meta.valueDate && service.valueDate !== meta.valueDate) ||\n\t\t\t(meta.codes && service.codes !== meta.codes) ||\n\t\t\t(meta.tags && service.tags !== meta.tags)\n\t\t) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tmeta.responsible && (newService.responsible = meta.responsible)\n\t\t\tmeta.valueDate && (newService.valueDate = meta.valueDate)\n\t\t\tmeta.codes && (newService.codes = normalizeCodes(meta.codes))\n\t\t\tmeta.tags && (newService.tags = normalizeCodes(meta.tags))\n\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === service.id ? newService : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tsetValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata, changeListenersOverrider?: (fvc: ContactFormValuesContainer) => void): void {\n\t\tconst service =\n\t\t\t(id && this.getServicesInHistory((sid: string, history) => (sid === id ? history.map((x) => x.revision) : []))[id]?.[0]?.value) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tconsole.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)\n\t\tconst newContent = value?.content?.[language]\n\t\tconst newCodes = value?.codes ? normalizeCodes(value.codes) : []\n\t\tif (!isContentEqual(service.content?.[language], newContent) || (newCodes && !areCodesEqual(newCodes, service.codes ?? []))) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tconst newContents = newContent ? { ...(service.content || {}), [language]: newContent } : { ...(service.content || {}) }\n\t\t\tif (!newContent) {\n\t\t\t\tdelete newContents[language]\n\t\t\t}\n\n\t\t\tlet newCurrentContact: Contact\n\t\t\tif (!Object.entries(newContents).filter(([, cnt]) => cnt !== undefined).length) {\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).filter((s) => s.id !== service.id)\n\t\t\t\t\t\t: [...(this.currentContact.services ?? [])],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewService.content = newContents\n\t\t\t\tnewService.codes = newCodes\n\n\t\t\t\tif (metadata) {\n\t\t\t\t\tnewService.responsible = metadata.responsible ?? newService.responsible\n\t\t\t\t\tnewService.valueDate = metadata.valueDate ?? newService.valueDate\n\t\t\t\t\tnewService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags\n\t\t\t\t\tnewService.label = metadata.label ?? newService.label\n\t\t\t\t}\n\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).map((s) => (s.id === service.id ? newService : s))\n\t\t\t\t\t\t: [...(this.currentContact.services ?? []), newService],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tnewCurrentContact,\n\t\t\t\tthis.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)),\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tchangeListenersOverrider ? changeListenersOverrider(newFormValuesContainer) : this.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tdelete(serviceId: string): void {\n\t\tconst service = this.getServiceInCurrentContact(serviceId)\n\t\tif (service) {\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === serviceId ? new Service({ ...service, endOfLife: Date.now() }) : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => notify(l, newFormValuesContainer))\n\t\t}\n\t}\n\n\tcompute<T>(): T | undefined {\n\t\tthrow new Error('Compute not supported at contact level')\n\t}\n\n\t/** returns all services in history that match a selector\n\t *\n\t * @private\n\t * @param revisionsFilter\n\t */\n\tprivate getServicesInHistory(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\tconst indexedServices = [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\tctc.services?.reduce(\n\t\t\t\t\t\t(acc, s) => (s.id ? { ...acc, [s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({ revision: ctc.rev ?? null, modified: ctc.created, value: s }) } : acc),\n\t\t\t\t\t\tacc,\n\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as VersionedData<Service>,\n\t\t\t) //index services in history by id\n\t\treturn Object.entries(indexedServices)\n\t\t\t.map(([id, history]) => {\n\t\t\t\tconst keptRevisions = revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tmodified,\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tlabel: s.label ?? s.id ?? '',\n\t\t\t\t\t\t\towner: s.responsible,\n\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\tcodes: s.codes,\n\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t\treturn [id, history.filter(({ revision }) => keptRevisions.includes(revision))] as [string, Version<Service>[]]\n\t\t\t})\n\t\t\t.reduce((acc, [id, history]) => ({ ...acc, [id]: history }), {})\n\t}\n\n\tasync addChild(anchorId: string, templateId: string, label: string): Promise<void> {\n\t\tconst newForm = await this.formFactory(anchorId, templateId, label)\n\t\tconst childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory, [], false)\n\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\t[...this.children, childFVC],\n\t\t\tthis.formFactory,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tnewContactFormValuesContainer.registerChildFormValuesContainer(childFVC)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n\n\tprivate getServiceInCurrentContact(id: string): Service | undefined {\n\t\tconst service = (this.currentContact.services || [])?.find((s) => s.id === id)\n\t\treturn service ?? undefined\n\t}\n\n\tasync removeChild(container: ContactFormValuesContainer): Promise<void> {\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\tthis.children.filter((c) => c.rootForm.id !== container.rootForm.id),\n\t\t\tthis.formFactory,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => notify(l, newContactFormValuesContainer))\n\t}\n}\n\nconst setValueOnContactFormValuesContainer = (\n\tcfvc: ContactFormValuesContainer,\n\tlabel: string,\n\tlanguage: string,\n\tfv?: FieldValue,\n\tid?: string,\n\tmetadata?: FieldMetadata,\n\tchangeListenersOverrider?: (fvc: ContactFormValuesContainer) => void,\n) => {\n\tconst value = fv?.content[language]\n\tcfvc.setValue(\n\t\tlabel,\n\t\tlanguage,\n\t\t{\n\t\t\tid: id,\n\t\t\tcodes: fv?.codes ?? [],\n\t\t\tcontent: value\n\t\t\t\t? {\n\t\t\t\t\t\t[language]: primitiveTypeToContent(language, value),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t},\n\t\tid,\n\t\tmetadata\n\t\t\t? {\n\t\t\t\t\tlabel: metadata?.label ?? label,\n\t\t\t\t\tresponsible: metadata?.owner,\n\t\t\t\t\tvalueDate: metadata?.valueDate,\n\t\t\t\t\ttags: metadata?.tags,\n\t\t\t }\n\t\t\t: undefined,\n\t\tchangeListenersOverrider,\n\t)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icure/form",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  import { Code, Field, SortOptions } from '../components/model';
2
2
  import { Suggestion } from '../generic';
3
+ import { CodeStub } from '@icure/api';
3
4
  /**
4
5
  * Maps the options defined in a field into a list of codes
5
6
  *
@@ -11,3 +12,4 @@ export declare const optionMapper: (language: string, field: Field, translationP
11
12
  export declare const sortCodes: (codes: Code[], language: string, sortOptions?: SortOptions) => Code[];
12
13
  export declare const sortSuggestions: (codes: (Code | Suggestion)[], language: string, sortOptions?: SortOptions) => Suggestion[];
13
14
  export declare const filterAndSortOptionsFromFieldDefinition: (language: string, fg: Field, translationProvider: ((language: string, text: string) => string) | undefined, terms?: string[]) => Promise<Code[]>;
15
+ export declare const normalizeCodes: (codes: CodeStub[]) => CodeStub[];
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterAndSortOptionsFromFieldDefinition = exports.sortSuggestions = exports.sortCodes = exports.optionMapper = void 0;
3
+ exports.normalizeCodes = exports.filterAndSortOptionsFromFieldDefinition = exports.sortSuggestions = exports.sortCodes = exports.optionMapper = void 0;
4
4
  const utils_1 = require("../components/common/utils");
5
+ const api_1 = require("@icure/api");
5
6
  /**
6
7
  * Maps the options defined in a field into a list of codes
7
8
  *
@@ -31,4 +32,6 @@ const sortSuggestions = (codes, language, sortOptions) => ((sortOptions === null
31
32
  exports.sortSuggestions = sortSuggestions;
32
33
  const filterAndSortOptionsFromFieldDefinition = (language, fg, translationProvider, terms) => Promise.resolve((0, exports.sortCodes)((0, exports.optionMapper)(language, fg, translationProvider).filter((x) => (terms !== null && terms !== void 0 ? terms : []).map((st) => st.toLowerCase()).every((st) => x.label[language].toLowerCase().includes(st))), language, fg.sortOptions));
33
34
  exports.filterAndSortOptionsFromFieldDefinition = filterAndSortOptionsFromFieldDefinition;
35
+ const normalizeCodes = (codes) => codes.map((c) => (0, api_1.normalizeCode)(c));
36
+ exports.normalizeCodes = normalizeCodes;
34
37
  //# sourceMappingURL=code-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-utils.js","sourceRoot":"","sources":["../../tmp/utils/code-utils.ts"],"names":[],"mappings":";;;AACA,sDAA8H;AAG9H;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,KAAY,EAAE,mBAAgE,EAAU,EAAE;;IACxI,OAAA,MAAM,CAAC,IAAI,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;;QACnD,MAAM,IAAI,GAAW,MAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAG,SAAS,CAAY,mCAAI,EAAE,CAAA;QAClE,OAAO;YACN,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;SACvF,CAAA;IACF,CAAC,CAA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AAC,WAAW,CACd,CACD,CAAA;AAZW,QAAA,uCAAuC,2CAYlD","sourcesContent":["import { Code, Field, SortOptions } from '../components/model'\nimport { defaultCodePromoter, defaultCodesComparator, makePromoter, naturalCodesComparator } from '../components/common/utils'\nimport { Suggestion } from '../generic'\n\n/**\n * Maps the options defined in a field into a list of codes\n *\n * @param language\n * @param field\n * @param translationProvider\n */\nexport const optionMapper = (language: string, field: Field, translationProvider?: (language: string, text: string) => string): Code[] =>\n\tObject.keys(field?.options ?? []).map((optionKey) => {\n\t\tconst text: string = (field?.options?.[optionKey] as string) ?? ''\n\t\treturn {\n\t\t\tid: optionKey,\n\t\t\tlabel: { [language]: translationProvider ? translationProvider(language, text) : text },\n\t\t}\n\t})\n\nexport const sortCodes = (codes: Code[], language: string, sortOptions?: SortOptions) =>\n\tsortOptions?.sort && sortOptions?.sort !== 'natural'\n\t\t? codes.sort(defaultCodesComparator(language, sortOptions?.sort === 'asc', sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t\t: codes.sort(naturalCodesComparator(sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\nexport const sortSuggestions = (codes: (Code | Suggestion)[], language: string, sortOptions?: SortOptions): Suggestion[] =>\n\t(sortOptions?.sort && sortOptions?.sort !== 'natural'\n\t\t? codes.sort(defaultCodesComparator(language, sortOptions?.sort === 'asc', sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t\t: codes.sort(naturalCodesComparator(sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t).map((c) => ({ id: c.id, label: c.label, text: c.label[language] ?? '', terms: [] }))\n\nexport const filterAndSortOptionsFromFieldDefinition = (\n\tlanguage: string,\n\tfg: Field,\n\ttranslationProvider: ((language: string, text: string) => string) | undefined,\n\tterms?: string[],\n) =>\n\tPromise.resolve(\n\t\tsortCodes(\n\t\t\toptionMapper(language, fg, translationProvider).filter((x) => (terms ?? []).map((st) => st.toLowerCase()).every((st) => x.label[language].toLowerCase().includes(st))),\n\t\t\tlanguage,\n\t\t\tfg.sortOptions,\n\t\t),\n\t)\n"]}
1
+ {"version":3,"file":"code-utils.js","sourceRoot":"","sources":["../../tmp/utils/code-utils.ts"],"names":[],"mappings":";;;AACA,sDAA8H;AAE9H,oCAAoD;AAEpD;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,KAAY,EAAE,mBAAgE,EAAU,EAAE;;IACxI,OAAA,MAAM,CAAC,IAAI,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;;QACnD,MAAM,IAAI,GAAW,MAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAG,SAAS,CAAY,mCAAI,EAAE,CAAA;QAClE,OAAO;YACN,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;SACvF,CAAA;IACF,CAAC,CAAC,CAAA;CAAA,CAAA;AAPU,QAAA,YAAY,gBAOtB;AAEI,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAE,WAAyB,EAAE,EAAE,CACvF,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,KAAI,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,MAAK,SAAS;IACnD,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,EAAC,QAAQ,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,MAAK,KAAK,EAAE,CAAA,WAAW,aA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AC,CAAC,CAAC,EAAE,EAAE,WAAC,OAAA,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,MAAA,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,mCAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA,EAAA,CAAC,CAAA;AAJ1E,QAAA,eAAe,mBAI2D;AAEhF,MAAM,uCAAuC,GAAG,CACtD,QAAgB,EAChB,EAAS,EACT,mBAA6E,EAC7E,KAAgB,EACf,EAAE,CACH,OAAO,CAAC,OAAO,CACd,IAAA,iBAAS,EACR,IAAA,oBAAY,EAAC,QAAQ,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EACtK,QAAQ,EACR,EAAE,CAAC,WAAW,CACd,CACD,CAAA;AAZW,QAAA,uCAAuC,2CAYlD;AAEK,MAAM,cAAc,GAAG,CAAC,KAAiB,EAAc,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,mBAAa,EAAC,CAAC,CAAC,CAAC,CAAA;AAAtF,QAAA,cAAc,kBAAwE","sourcesContent":["import { Code, Field, SortOptions } from '../components/model'\nimport { defaultCodePromoter, defaultCodesComparator, makePromoter, naturalCodesComparator } from '../components/common/utils'\nimport { Suggestion } from '../generic'\nimport { CodeStub, normalizeCode } from '@icure/api'\n\n/**\n * Maps the options defined in a field into a list of codes\n *\n * @param language\n * @param field\n * @param translationProvider\n */\nexport const optionMapper = (language: string, field: Field, translationProvider?: (language: string, text: string) => string): Code[] =>\n\tObject.keys(field?.options ?? []).map((optionKey) => {\n\t\tconst text: string = (field?.options?.[optionKey] as string) ?? ''\n\t\treturn {\n\t\t\tid: optionKey,\n\t\t\tlabel: { [language]: translationProvider ? translationProvider(language, text) : text },\n\t\t}\n\t})\n\nexport const sortCodes = (codes: Code[], language: string, sortOptions?: SortOptions) =>\n\tsortOptions?.sort && sortOptions?.sort !== 'natural'\n\t\t? codes.sort(defaultCodesComparator(language, sortOptions?.sort === 'asc', sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t\t: codes.sort(naturalCodesComparator(sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\nexport const sortSuggestions = (codes: (Code | Suggestion)[], language: string, sortOptions?: SortOptions): Suggestion[] =>\n\t(sortOptions?.sort && sortOptions?.sort !== 'natural'\n\t\t? codes.sort(defaultCodesComparator(language, sortOptions?.sort === 'asc', sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t\t: codes.sort(naturalCodesComparator(sortOptions?.promotions ? makePromoter(sortOptions.promotions.split(/ ?, ?/)) : defaultCodePromoter))\n\t).map((c) => ({ id: c.id, label: c.label, text: c.label[language] ?? '', terms: [] }))\n\nexport const filterAndSortOptionsFromFieldDefinition = (\n\tlanguage: string,\n\tfg: Field,\n\ttranslationProvider: ((language: string, text: string) => string) | undefined,\n\tterms?: string[],\n) =>\n\tPromise.resolve(\n\t\tsortCodes(\n\t\t\toptionMapper(language, fg, translationProvider).filter((x) => (terms ?? []).map((st) => st.toLowerCase()).every((st) => x.label[language].toLowerCase().includes(st))),\n\t\t\tlanguage,\n\t\t\tfg.sortOptions,\n\t\t),\n\t)\n\nexport const normalizeCodes = (codes: CodeStub[]): CodeStub[] => codes.map((c) => normalizeCode(c))\n"]}
@@ -1,5 +1,6 @@
1
1
  import { Field, FieldMetadata, FieldValue } from '../components/model';
2
- import { FormValuesContainer, VersionedData } from '../generic';
2
+ import { FormValuesContainer, Version, VersionedData } from '../generic';
3
+ export declare function getRevisionsFilter(field: Field): (id: string, history: Version<FieldMetadata>[]) => string[];
3
4
  export declare const fieldValuesProvider: (formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, field: Field) => (() => VersionedData<FieldValue>);
4
5
  export declare function makeMetadata(field: Field, owner?: string, index?: number): {
5
6
  label: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleMetadataChangedProvider = exports.handleValueChangedProvider = exports.getValidationError = exports.makeMetadata = exports.fieldValuesProvider = void 0;
3
+ exports.handleMetadataChangedProvider = exports.handleValueChangedProvider = exports.getValidationError = exports.makeMetadata = exports.fieldValuesProvider = exports.getRevisionsFilter = void 0;
4
4
  const dates_1 = require("./dates");
5
5
  function getRevisionsFilter(field) {
6
6
  return (id, history) => history
@@ -8,6 +8,7 @@ function getRevisionsFilter(field) {
8
8
  .map((fmd) => fmd.revision)
9
9
  .filter((r) => r !== undefined); //null is used as a new revision indicator
10
10
  }
11
+ exports.getRevisionsFilter = getRevisionsFilter;
11
12
  const fieldValuesProvider = (formValuesContainer, field) => () => formValuesContainer.getValues(getRevisionsFilter(field));
12
13
  exports.fieldValuesProvider = fieldValuesProvider;
13
14
  function makeMetadata(field, owner, index) {
@@ -1 +1 @@
1
- {"version":3,"file":"fields-values-provider.js","sourceRoot":"","sources":["../../tmp/utils/fields-values-provider.ts"],"names":[],"mappings":";;;AAGA,mCAAyC;AAEzC,SAAS,kBAAkB,CAAC,KAAY;IACvC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,CACtB,OAAO;SACL,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,eAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CA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AC9B,CAAC,mBAAoE,EAAE,KAAa,EAAqC,EAAE,CAC3H,GAAG,EAAE;;IACJ,MAAM,UAAU,GAAG,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,mBAAmB,EAAE,mCAAI,EAAE,CAAA;IACnE,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,MAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,EAAE,CAAA,CAAC,CAAA;AAC5E,CAAC,CAAA;AALW,QAAA,kBAAkB,sBAK7B;AAEK,MAAM,0BAA0B,GAAG,CAAC,mBAAoE,EAAE,KAAa,EAAE,KAAc,EAAE,EAAE;IACjJ,OAAO,CAAC,KAAa,EAAE,QAAgB,EAAE,KAAkB,EAAE,EAAW,EAAE,EAAE;QAC3E,IAAI,mBAAmB,EAAE,CAAC;YACzB,mBAAmB,CAAC,QAAQ,CAC3B,KAAK,EACL,QAAQ,EACR,KAAK,EACL,EAAE,EACF,CAAC,EAAE,IAAI,KAAK,CAAC,wFAAwF;gBACpG,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC;gBAC5B,CAAC,CAAC,SAAS,CACZ,CAAA;QACF,CAAC;IACF,CAAC,CAAA;AACF,CAAC,CAAA;AAdY,QAAA,0BAA0B,8BActC;AAEM,MAAM,6BAA6B,GAAG,CAAC,mBAAoE,EAAE,EAAE;IACrH,OAAO,CAAC,QAAuB,EAAE,EAAW,EAAE,EAAE;QAC/C,IAAI,mBAAmB,EAAE,CAAC;YACzB,mBAAmB,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAC9C,CAAC;IACF,CAAC,CAAA;AACF,CAAC,CAAA;AANY,QAAA,6BAA6B,iCAMzC","sourcesContent":["import { Field, FieldMetadata, FieldValue } from '../components/model'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\n\nimport { dateToFuzzyDate } from './dates'\n\nfunction getRevisionsFilter(field: Field): (id: string, history: Version<FieldMetadata>[]) => string[] {\n\treturn (id, history) =>\n\t\thistory\n\t\t\t.filter((fmd) => (field.tags?.length ? field.tags.every((t) => fmd?.value?.tags?.some((tt) => tt.id === t)) : fmd?.value?.label === field.label()))\n\t\t\t.map((fmd) => fmd.revision)\n\t\t\t.filter((r) => r !== undefined) as string[] //null is used as a new revision indicator\n}\n\nexport const fieldValuesProvider =\n\t(formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, field: Field): (() => VersionedData<FieldValue>) =>\n\t() =>\n\t\tformValuesContainer.getValues(getRevisionsFilter(field))\n\nexport function makeMetadata(field: Field, owner?: string, index?: number) {\n\treturn {\n\t\tlabel: field.label(),\n\t\tvalueDate: dateToFuzzyDate(new Date()),\n\t\towner: owner,\n\t\tindex: index,\n\t\ttags: field.tags?.map((t) => ({\n\t\t\tid: t,\n\t\t\tlabel: {},\n\t\t})),\n\t}\n}\n\nexport const getValidationError =\n\t(formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field): (() => [FieldMetadata, string][]) =>\n\t() => {\n\t\tconst validators = formsValueContainer?.getValidationErrors() ?? []\n\t\treturn validators.filter(([metadata]) => metadata.label === field?.label())\n\t}\n\nexport const handleValueChangedProvider = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field, owner?: string) => {\n\treturn (label: string, language: string, value?: FieldValue, id?: string) => {\n\t\tif (formsValueContainer) {\n\t\t\tformsValueContainer.setValue(\n\t\t\t\tlabel,\n\t\t\t\tlanguage,\n\t\t\t\tvalue,\n\t\t\t\tid,\n\t\t\t\t!id && field // If the id is not set, we are creating a new value. In this case, we set the metadata.\n\t\t\t\t\t? makeMetadata(field, owner)\n\t\t\t\t\t: undefined,\n\t\t\t)\n\t\t}\n\t}\n}\n\nexport const handleMetadataChangedProvider = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>) => {\n\treturn (metadata: FieldMetadata, id?: string) => {\n\t\tif (formsValueContainer) {\n\t\t\tformsValueContainer.setMetadata(metadata, id)\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"fields-values-provider.js","sourceRoot":"","sources":["../../tmp/utils/fields-values-provider.ts"],"names":[],"mappings":";;;AAGA,mCAAyC;AAEzC,SAAgB,kBAAkB,CAAC,KAAY;IAC9C,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,CACtB,OAAO;SACL,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,eAAC,OAAA,CAAC,CAAA,MAAA,KAAK,CAAC,IAAI,0CAAE,MAAM,EAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,eAAC,OAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,0CAAE,IAAI,0CAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA,EAAA,CAAC,CAAC,CAAC,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,0CAAE,KAAK,MAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA,EAAA,CAAC;SAClJ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC;SAC1B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAa,CAAA,CAAC,0CAA0C;AACzF,CAAC;AAND,gDAMC;AAEM,MAAM,mBAAmB,GAC/B,CAAC,mBAAmE,EAAE,KAAY,EAAqC,EAAE,CACzH,GAAG,EAAE,CACJ,mBAAmB,CAAC,SAAS,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAA;AAH7C,QAAA,mBAAmB,uBAG0B;AAE1D,SAAgB,YAAY,CAAC,KAAY,EAAE,KAAc,EAAE,KAAc;;IACxE,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B,8BActC;AAEM,MAAM,6BAA6B,GAAG,CAAC,mBAAoE,EAAE,EAAE;IACrH,OAAO,CAAC,QAAuB,EAAE,EAAW,EAAE,EAAE;QAC/C,IAAI,mBAAmB,EAAE,CAAC;YACzB,mBAAmB,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;QAC9C,CAAC;IACF,CAAC,CAAA;AACF,CAAC,CAAA;AANY,QAAA,6BAA6B,iCAMzC","sourcesContent":["import { Field, FieldMetadata, FieldValue } from '../components/model'\nimport { FormValuesContainer, Version, VersionedData } from '../generic'\n\nimport { dateToFuzzyDate } from './dates'\n\nexport function getRevisionsFilter(field: Field): (id: string, history: Version<FieldMetadata>[]) => string[] {\n\treturn (id, history) =>\n\t\thistory\n\t\t\t.filter((fmd) => (field.tags?.length ? field.tags.every((t) => fmd?.value?.tags?.some((tt) => tt.id === t)) : fmd?.value?.label === field.label()))\n\t\t\t.map((fmd) => fmd.revision)\n\t\t\t.filter((r) => r !== undefined) as string[] //null is used as a new revision indicator\n}\n\nexport const fieldValuesProvider =\n\t(formValuesContainer: FormValuesContainer<FieldValue, FieldMetadata>, field: Field): (() => VersionedData<FieldValue>) =>\n\t() =>\n\t\tformValuesContainer.getValues(getRevisionsFilter(field))\n\nexport function makeMetadata(field: Field, owner?: string, index?: number) {\n\treturn {\n\t\tlabel: field.label(),\n\t\tvalueDate: dateToFuzzyDate(new Date()),\n\t\towner: owner,\n\t\tindex: index,\n\t\ttags: field.tags?.map((t) => ({\n\t\t\tid: t,\n\t\t\tlabel: {},\n\t\t})),\n\t}\n}\n\nexport const getValidationError =\n\t(formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field): (() => [FieldMetadata, string][]) =>\n\t() => {\n\t\tconst validators = formsValueContainer?.getValidationErrors() ?? []\n\t\treturn validators.filter(([metadata]) => metadata.label === field?.label())\n\t}\n\nexport const handleValueChangedProvider = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>, field?: Field, owner?: string) => {\n\treturn (label: string, language: string, value?: FieldValue, id?: string) => {\n\t\tif (formsValueContainer) {\n\t\t\tformsValueContainer.setValue(\n\t\t\t\tlabel,\n\t\t\t\tlanguage,\n\t\t\t\tvalue,\n\t\t\t\tid,\n\t\t\t\t!id && field // If the id is not set, we are creating a new value. In this case, we set the metadata.\n\t\t\t\t\t? makeMetadata(field, owner)\n\t\t\t\t\t: undefined,\n\t\t\t)\n\t\t}\n\t}\n}\n\nexport const handleMetadataChangedProvider = (formsValueContainer?: FormValuesContainer<FieldValue, FieldMetadata>) => {\n\treturn (metadata: FieldMetadata, id?: string) => {\n\t\tif (formsValueContainer) {\n\t\t\tformsValueContainer.setMetadata(metadata, id)\n\t\t}\n\t}\n}\n"]}