@openmrs/esm-form-engine-lib 2.1.0-pre.1478 → 2.1.0-pre.1497

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.
@@ -1 +1 @@
1
- var _openmrs_esm_form_engine_lib;(()=>{"use strict";var e,r,t,n,o,i,a,l,s,u,f,p,d,c,h,m,v,g,b={8008:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(901),t.e(501),t.e(72),t.e(385),t.e(572)]).then((()=>()=>t(8572)))},o=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),i=(e,r)=>{if(t.S){var n="default",o=t.S[n];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>o,init:()=>i})}},y={};function w(e){var r=y[e];if(void 0!==r)return r.exports;var t=y[e]={id:e,loaded:!1,exports:{}};return b[e].call(t.exports,t,t.exports,w),t.loaded=!0,t.exports}w.m=b,w.c=y,w.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return w.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,w.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);w.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var a=2&n&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,w.d(o,i),o},w.d=(e,r)=>{for(var t in r)w.o(r,t)&&!w.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},w.f={},w.e=e=>Promise.all(Object.keys(w.f).reduce(((r,t)=>(w.f[t](e,r),r)),[])),w.u=e=>e+".js",w.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),w.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@openmrs/esm-form-engine-lib:",w.l=(e,r,o,i)=>{if(t[e])t[e].push(r);else{var a,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var f=s[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){a=f;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,w.nc&&a.setAttribute("nonce",w.nc),a.setAttribute("data-webpack",n+o),a.src=e),t[e]=[r];var p=(r,n)=>{a.onerror=a.onload=null,clearTimeout(d);var o=t[e];if(delete t[e],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),l&&document.head.appendChild(a)}},w.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},w.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{w.S={};var e={},r={};w.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];w.o(w.S,t)||(w.S[t]={});var i=w.S[t],a="@openmrs/esm-form-engine-lib",l=(e,r,t,n)=>{var o=i[e]=i[e]||{},l=o[r];(!l||!l.loaded&&(!n!=!l.eager?n:a>l.from))&&(o[r]={get:t,from:a,eager:!!n})},s=[];return"default"===t&&(l("@openmrs/esm-framework","5.7.3-pre.2161",(()=>Promise.all([w.e(151),w.e(72),w.e(766)]).then((()=>()=>w(5151))))),l("@openmrs/esm-patient-common-lib","8.1.1-pre.5183",(()=>Promise.all([w.e(617),w.e(901),w.e(72),w.e(465),w.e(385),w.e(70)]).then((()=>()=>w(8617))))),l("dayjs","1.11.11",(()=>w.e(353).then((()=>()=>w(4353))))),l("i18next","23.11.4",(()=>w.e(635).then((()=>()=>w(2635))))),l("react-i18next","11.18.6",(()=>Promise.all([w.e(422),w.e(72)]).then((()=>()=>w(4422))))),l("react","18.3.1",(()=>w.e(540).then((()=>()=>w(6540))))),l("swr/_internal","2.2.5",(()=>Promise.all([w.e(993),w.e(72)]).then((()=>()=>w(4993))))),l("swr/immutable","2.2.5",(()=>Promise.all([w.e(225),w.e(72),w.e(465)]).then((()=>()=>w(4225))))),l("swr/infinite","2.2.5",(()=>Promise.all([w.e(41),w.e(72),w.e(465)]).then((()=>()=>w(3041)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;w.g.importScripts&&(e=w.g.location+"");var r=w.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),w.p=e})(),o=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},i=(e,r)=>{e=o(e),r=o(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],i=(typeof n)[0];if(t>=r.length)return"u"==i;var a=r[t],l=(typeof a)[0];if(i!=l)return"o"==i&&"n"==l||"s"==l||"u"==i;if("o"!=i&&"u"!=i&&n!=a)return n<a;t++}},a=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,o=1;o<e.length;o++)n--,t+="u"==(typeof(l=e[o]))[0]?"-":(n>0?".":"")+(n=2,l);return t}var i=[];for(o=1;o<e.length;o++){var l=e[o];i.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?i.pop()+" "+i.pop():a(l))}return s();function s(){return i.pop().replace(/^\((.+)\)$/,"$1")}},l=(e,r)=>{if(0 in e){r=o(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var i=0,a=1,s=!0;;a++,i++){var u,f,p=a<e.length?(typeof e[a])[0]:"";if(i>=r.length||"o"==(f=(typeof(u=r[i]))[0]))return!s||("u"==p?a>t&&!n:""==p!=n);if("u"==f){if(!s||"u"!=p)return!1}else if(s)if(p==f)if(a<=t){if(u!=e[a])return!1}else{if(n?u>e[a]:u<e[a])return!1;u!=e[a]&&(s=!1)}else if("s"!=p&&"n"!=p){if(n||a<=t)return!1;s=!1,a--}else{if(a<=t||f<p!=n)return!1;s=!1}else"s"!=p&&"n"!=p&&(s=!1,a--)}}var d=[],c=d.pop.bind(d);for(i=1;i<e.length;i++){var h=e[i];d.push(1==h?c()|c():2==h?c()&c():h?l(h,r):!c())}return!!c()},s=(e,r)=>{var t=e[r];return Object.keys(t).reduce(((e,r)=>!e||!t[e].loaded&&i(e,r)?r:e),0)},u=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+a(n)+")",f=(e,r,t,n)=>{var o=s(e,t);return l(n,o)||p(u(e,t,o,n)),d(e[t][o])},p=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},d=e=>(e.loaded=1,e.get()),c=(e=>function(r,t,n,o){var i=w.I(r);return i&&i.then?i.then(e.bind(e,r,w.S[r],t,n,o)):e(0,w.S[r],t,n,o)})(((e,r,t,n,o)=>r&&w.o(r,t)?f(r,0,t,n):o())),h={},m={6072:()=>c("default","react",[1,18],(()=>w.e(540).then((()=>()=>w(6540))))),6766:()=>c("default","i18next",[1,23],(()=>w.e(635).then((()=>()=>w(2635))))),8465:()=>c("default","swr/_internal",[1,2],(()=>w.e(993).then((()=>()=>w(4993))))),3941:()=>c("default","react-i18next",[1,11],(()=>w.e(422).then((()=>()=>w(4422))))),5972:()=>c("default","@openmrs/esm-framework",[1,5],(()=>Promise.all([w.e(151),w.e(766)]).then((()=>()=>w(5151))))),6656:()=>c("default","@openmrs/esm-patient-common-lib",[1,8],(()=>Promise.all([w.e(617),w.e(465)]).then((()=>()=>w(8617))))),4209:()=>c("default","swr/immutable",[1,2],(()=>Promise.all([w.e(225),w.e(465)]).then((()=>()=>w(4225))))),231:()=>c("default","dayjs",[1,1],(()=>w.e(353).then((()=>()=>w(4353))))),6339:()=>c("default","swr/infinite",[1,2],(()=>Promise.all([w.e(41),w.e(465)]).then((()=>()=>w(3041)))))},v={70:[4209],72:[6072],385:[3941,5972,6656],465:[8465],572:[231,4209,6339],766:[6766]},g={},w.f.consumes=(e,r)=>{w.o(v,e)&&v[e].forEach((e=>{if(w.o(h,e))return r.push(h[e]);if(!g[e]){var t=r=>{h[e]=0,w.m[e]=t=>{delete w.c[e],t.exports=r()}};g[e]=!0;var n=r=>{delete h[e],w.m[e]=t=>{throw delete w.c[e],r}};try{var o=m[e]();o.then?r.push(h[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}}))},(()=>{var e={719:0};w.f.j=(r,t)=>{var n=w.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(385|465|72|766)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var i=w.p+w.u(r),a=new Error;w.l(i,(t=>{if(w.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;a.message="Loading chunk "+r+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,o,[i,a,l]=t,s=0;if(i.some((r=>0!==e[r]))){for(n in a)w.o(a,n)&&(w.m[n]=a[n]);l&&l(w)}for(r&&r(t);s<i.length;s++)o=i[s],w.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_openmrs_esm_form_engine_lib=globalThis.webpackChunk_openmrs_esm_form_engine_lib||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),w.nc=void 0;var _=w(8008);_openmrs_esm_form_engine_lib=_})();
1
+ var _openmrs_esm_form_engine_lib;(()=>{"use strict";var e,r,t,n,o,i,a,l,s,u,f,p,d,c,h,m,v,g,b={8008:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(901),t.e(501),t.e(72),t.e(385),t.e(572)]).then((()=>()=>t(8572)))},o=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),i=(e,r)=>{if(t.S){var n="default",o=t.S[n];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>o,init:()=>i})}},y={};function w(e){var r=y[e];if(void 0!==r)return r.exports;var t=y[e]={id:e,loaded:!1,exports:{}};return b[e].call(t.exports,t,t.exports,w),t.loaded=!0,t.exports}w.m=b,w.c=y,w.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return w.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,w.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);w.r(o);var i={};e=e||[null,r({}),r([]),r(r)];for(var a=2&n&&t;"object"==typeof a&&!~e.indexOf(a);a=r(a))Object.getOwnPropertyNames(a).forEach((e=>i[e]=()=>t[e]));return i.default=()=>t,w.d(o,i),o},w.d=(e,r)=>{for(var t in r)w.o(r,t)&&!w.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},w.f={},w.e=e=>Promise.all(Object.keys(w.f).reduce(((r,t)=>(w.f[t](e,r),r)),[])),w.u=e=>e+".js",w.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),w.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@openmrs/esm-form-engine-lib:",w.l=(e,r,o,i)=>{if(t[e])t[e].push(r);else{var a,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var f=s[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){a=f;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,w.nc&&a.setAttribute("nonce",w.nc),a.setAttribute("data-webpack",n+o),a.src=e),t[e]=[r];var p=(r,n)=>{a.onerror=a.onload=null,clearTimeout(d);var o=t[e];if(delete t[e],a.parentNode&&a.parentNode.removeChild(a),o&&o.forEach((e=>e(n))),r)return r(n)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),l&&document.head.appendChild(a)}},w.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},w.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{w.S={};var e={},r={};w.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];w.o(w.S,t)||(w.S[t]={});var i=w.S[t],a="@openmrs/esm-form-engine-lib",l=(e,r,t,n)=>{var o=i[e]=i[e]||{},l=o[r];(!l||!l.loaded&&(!n!=!l.eager?n:a>l.from))&&(o[r]={get:t,from:a,eager:!!n})},s=[];return"default"===t&&(l("@openmrs/esm-framework","5.8.2-pre.2368",(()=>Promise.all([w.e(151),w.e(72),w.e(766)]).then((()=>()=>w(5151))))),l("@openmrs/esm-patient-common-lib","8.1.1-pre.5183",(()=>Promise.all([w.e(617),w.e(901),w.e(72),w.e(465),w.e(385),w.e(70)]).then((()=>()=>w(8617))))),l("dayjs","1.11.11",(()=>w.e(353).then((()=>()=>w(4353))))),l("i18next","23.11.4",(()=>w.e(635).then((()=>()=>w(2635))))),l("react-i18next","11.18.6",(()=>Promise.all([w.e(422),w.e(72)]).then((()=>()=>w(4422))))),l("react","18.3.1",(()=>w.e(540).then((()=>()=>w(6540))))),l("swr/_internal","2.2.5",(()=>Promise.all([w.e(993),w.e(72)]).then((()=>()=>w(4993))))),l("swr/immutable","2.2.5",(()=>Promise.all([w.e(225),w.e(72),w.e(465)]).then((()=>()=>w(4225))))),l("swr/infinite","2.2.5",(()=>Promise.all([w.e(41),w.e(72),w.e(465)]).then((()=>()=>w(3041)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;w.g.importScripts&&(e=w.g.location+"");var r=w.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),w.p=e})(),o=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},i=(e,r)=>{e=o(e),r=o(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],i=(typeof n)[0];if(t>=r.length)return"u"==i;var a=r[t],l=(typeof a)[0];if(i!=l)return"o"==i&&"n"==l||"s"==l||"u"==i;if("o"!=i&&"u"!=i&&n!=a)return n<a;t++}},a=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,o=1;o<e.length;o++)n--,t+="u"==(typeof(l=e[o]))[0]?"-":(n>0?".":"")+(n=2,l);return t}var i=[];for(o=1;o<e.length;o++){var l=e[o];i.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?i.pop()+" "+i.pop():a(l))}return s();function s(){return i.pop().replace(/^\((.+)\)$/,"$1")}},l=(e,r)=>{if(0 in e){r=o(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var i=0,a=1,s=!0;;a++,i++){var u,f,p=a<e.length?(typeof e[a])[0]:"";if(i>=r.length||"o"==(f=(typeof(u=r[i]))[0]))return!s||("u"==p?a>t&&!n:""==p!=n);if("u"==f){if(!s||"u"!=p)return!1}else if(s)if(p==f)if(a<=t){if(u!=e[a])return!1}else{if(n?u>e[a]:u<e[a])return!1;u!=e[a]&&(s=!1)}else if("s"!=p&&"n"!=p){if(n||a<=t)return!1;s=!1,a--}else{if(a<=t||f<p!=n)return!1;s=!1}else"s"!=p&&"n"!=p&&(s=!1,a--)}}var d=[],c=d.pop.bind(d);for(i=1;i<e.length;i++){var h=e[i];d.push(1==h?c()|c():2==h?c()&c():h?l(h,r):!c())}return!!c()},s=(e,r)=>{var t=e[r];return Object.keys(t).reduce(((e,r)=>!e||!t[e].loaded&&i(e,r)?r:e),0)},u=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+a(n)+")",f=(e,r,t,n)=>{var o=s(e,t);return l(n,o)||p(u(e,t,o,n)),d(e[t][o])},p=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},d=e=>(e.loaded=1,e.get()),c=(e=>function(r,t,n,o){var i=w.I(r);return i&&i.then?i.then(e.bind(e,r,w.S[r],t,n,o)):e(0,w.S[r],t,n,o)})(((e,r,t,n,o)=>r&&w.o(r,t)?f(r,0,t,n):o())),h={},m={6072:()=>c("default","react",[1,18],(()=>w.e(540).then((()=>()=>w(6540))))),6766:()=>c("default","i18next",[1,23],(()=>w.e(635).then((()=>()=>w(2635))))),8465:()=>c("default","swr/_internal",[1,2],(()=>w.e(993).then((()=>()=>w(4993))))),3941:()=>c("default","react-i18next",[1,11],(()=>w.e(422).then((()=>()=>w(4422))))),5972:()=>c("default","@openmrs/esm-framework",[1,5],(()=>Promise.all([w.e(151),w.e(766)]).then((()=>()=>w(5151))))),6656:()=>c("default","@openmrs/esm-patient-common-lib",[1,8],(()=>Promise.all([w.e(617),w.e(465)]).then((()=>()=>w(8617))))),4209:()=>c("default","swr/immutable",[1,2],(()=>Promise.all([w.e(225),w.e(465)]).then((()=>()=>w(4225))))),231:()=>c("default","dayjs",[1,1],(()=>w.e(353).then((()=>()=>w(4353))))),6339:()=>c("default","swr/infinite",[1,2],(()=>Promise.all([w.e(41),w.e(465)]).then((()=>()=>w(3041)))))},v={70:[4209],72:[6072],385:[3941,5972,6656],465:[8465],572:[231,4209,6339],766:[6766]},g={},w.f.consumes=(e,r)=>{w.o(v,e)&&v[e].forEach((e=>{if(w.o(h,e))return r.push(h[e]);if(!g[e]){var t=r=>{h[e]=0,w.m[e]=t=>{delete w.c[e],t.exports=r()}};g[e]=!0;var n=r=>{delete h[e],w.m[e]=t=>{throw delete w.c[e],r}};try{var o=m[e]();o.then?r.push(h[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}}))},(()=>{var e={719:0};w.f.j=(r,t)=>{var n=w.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(/^(385|465|72|766)$/.test(r))e[r]=0;else{var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var i=w.p+w.u(r),a=new Error;w.l(i,(t=>{if(w.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;a.message="Loading chunk "+r+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}}),"chunk-"+r,r)}};var r=(r,t)=>{var n,o,[i,a,l]=t,s=0;if(i.some((r=>0!==e[r]))){for(n in a)w.o(a,n)&&(w.m[n]=a[n]);l&&l(w)}for(r&&r(t);s<i.length;s++)o=i[s],w.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_openmrs_esm_form_engine_lib=globalThis.webpackChunk_openmrs_esm_form_engine_lib||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),w.nc=void 0;var _=w(8008);_openmrs_esm_form_engine_lib=_})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "2.1.0-pre.1478",
3
+ "version": "2.1.0-pre.1497",
4
4
  "description": "React Form Engine for O3",
5
5
  "browser": "dist/openmrs-esm-form-engine-lib.js",
6
6
  "main": "src/index.ts",
@@ -118,6 +118,7 @@ const DateField: React.FC<FormFieldInputProps> = ({ field, value: dateValue, err
118
118
  disabled={field.datePickerFormat === 'timer' ? field.isDisabled : !dateValue ? true : false}
119
119
  invalid={errors.length > 0}
120
120
  invalidText={errors[0]?.message}
121
+ readOnly={isTrue(field.readonly)}
121
122
  warning={warnings.length > 0}
122
123
  warningText={warnings[0]?.message}
123
124
  value={
@@ -25,6 +25,7 @@ const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
25
25
  label: answer.label,
26
26
  key: index,
27
27
  disabled: answer.disable?.isDisabled,
28
+ readonly: isTrue(field.readonly),
28
29
  }));
29
30
 
30
31
  const initiallySelectedQuestionItems = useMemo(() => {
@@ -110,10 +111,10 @@ const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
110
111
  invalidText={errors[0]?.message}
111
112
  warn={warnings.length > 0}
112
113
  warnText={warnings[0]?.message}
113
- readOnly={field.readonly}
114
+ readOnly={isTrue(field.readonly)}
114
115
  />
115
116
  ) : (
116
- <CheckboxGroup legendText={label} name={field.id}>
117
+ <CheckboxGroup legendText={label} name={field.id} readOnly={isTrue(field.readonly)}>
117
118
  {field.questionOptions.answers?.map((value, index) => {
118
119
  return (
119
120
  <Checkbox
@@ -129,6 +130,7 @@ const MultiSelect: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
129
130
  checked={initiallyCheckedQuestionItems.some((item) => item === value.concept)}
130
131
  onBlur={onblur}
131
132
  disabled={value.disable?.isDisabled}
133
+ readOnly={isTrue(field.readonly)}
132
134
  />
133
135
  );
134
136
  })}
@@ -65,7 +65,7 @@ const NumberField: React.FC<FormFieldInputProps> = ({ field, value, errors, warn
65
65
  hideSteppers={true}
66
66
  onWheel={(e) => e.target.blur()}
67
67
  disabled={field.isDisabled}
68
- readOnly={field.readonly}
68
+ readOnly={isTrue(field.readonly)}
69
69
  className={classNames(styles.controlWidthConstrained, styles.boldedLabel)}
70
70
  warn={warnings.length > 0}
71
71
  warnText={warnings[0]?.message}
@@ -42,6 +42,7 @@ const Radio: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
42
42
  name={field.id}
43
43
  valueSelected={value}
44
44
  onChange={handleChange}
45
+ readOnly={isTrue(field.readonly)}
45
46
  orientation={field.questionOptions?.orientation || 'vertical'}>
46
47
  {field.questionOptions.answers
47
48
  .filter((answer) => !answer.isHidden)
@@ -69,7 +69,7 @@ const Dropdown: React.FC<FormFieldInputProps> = ({ field, value, errors, warning
69
69
  selectedItem={isEmpty(value) ? NullSelectOption : value}
70
70
  onChange={handleChange}
71
71
  disabled={field.isDisabled}
72
- readOnly={field.readonly}
72
+ readOnly={isTrue(field.readonly)}
73
73
  invalid={errors.length > 0}
74
74
  invalidText={errors[0]?.message}
75
75
  warn={warnings.length > 0}
@@ -48,7 +48,7 @@ const TextArea: React.FC<FormFieldInputProps> = ({ field, value, errors, warning
48
48
  value={value || ''}
49
49
  rows={field.questionOptions.rows || 4}
50
50
  disabled={field.isDisabled}
51
- readOnly={field.readonly}
51
+ readOnly={isTrue(field.readonly)}
52
52
  invalid={errors.length > 0}
53
53
  invalidText={errors[0]?.message}
54
54
  warn={warnings.length > 0}
@@ -56,7 +56,7 @@ const Toggle: React.FC<FormFieldInputProps> = ({ field, value, errors, warnings,
56
56
  onToggle={handleChange}
57
57
  toggled={!!value}
58
58
  disabled={field.isDisabled}
59
- readOnly={field.readonly}
59
+ readOnly={isTrue(field.readonly)}
60
60
  />
61
61
  </div>
62
62
  )
@@ -154,7 +154,7 @@ const UiSelectExtended: React.FC<FormFieldInputProps> = ({ field, errors, warnin
154
154
  setFieldValue(selectedItem?.uuid);
155
155
  }}
156
156
  disabled={field.isDisabled}
157
- readOnly={field.readonly}
157
+ readOnly={isTrue(field.readonly)}
158
158
  invalid={errors.length > 0}
159
159
  invalidText={errors.length && errors[0].message}
160
160
  onInputChange={(value) => {
@@ -4,6 +4,7 @@ import { showSnackbar } from '@openmrs/esm-framework';
4
4
  import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib';
5
5
  import { Button } from '@carbon/react';
6
6
  import { type FormFieldInputProps } from '../../../types';
7
+ import { isTrue } from '../../../utils/boolean-utils';
7
8
  import styles from './workspace-launcher.scss';
8
9
 
9
10
  const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
@@ -27,7 +28,7 @@ const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
27
28
  <div>
28
29
  <div className={styles.label}>{t(field.label)}</div>
29
30
  <div className={styles.workspaceButton}>
30
- <Button onClick={handleLaunchWorkspace}>{field.questionOptions?.buttonLabel ?? t('launchWorkspace')}</Button>
31
+ <Button disabled={isTrue(field.readonly)} onClick={handleLaunchWorkspace}>{field.questionOptions?.buttonLabel ?? t('launchWorkspace')}</Button>
31
32
  </div>
32
33
  </div>
33
34
  )
@@ -0,0 +1,331 @@
1
+ import dayjs from 'dayjs';
2
+ import { CommonExpressionHelpers } from './common-expression-helpers';
3
+
4
+ describe('CommonExpressionHelpers', () => {
5
+ let helpers: CommonExpressionHelpers;
6
+ const mockPatient = { birthDate: '1990-01-01', sex: 'male' };
7
+ const mockFields = [];
8
+ const mockFieldValues = {};
9
+ const mockFieldKeys = [];
10
+
11
+ beforeEach(() => {
12
+ helpers = new CommonExpressionHelpers(null, mockPatient, mockFields, mockFieldValues, mockFieldKeys);
13
+ });
14
+
15
+ describe('isEmpty', () => {
16
+ it('should return true if value is empty, null or undefined', () => {
17
+ let val = '';
18
+
19
+ expect(helpers.isEmpty(val)).toBe(true);
20
+
21
+ val = 'test';
22
+ expect(helpers.isEmpty(val)).toBe(false);
23
+
24
+ val = null;
25
+ expect(helpers.isEmpty(val)).toBe(true);
26
+
27
+ val = undefined;
28
+ expect(helpers.isEmpty(val)).toBe(true);
29
+ });
30
+ });
31
+
32
+ describe('today', () => {
33
+ it("should return today's date", () => {
34
+ const today = helpers.today();
35
+ expect(today).toBeInstanceOf(Date);
36
+ expect(today.toDateString()).toBe(new Date().toDateString());
37
+ });
38
+ });
39
+
40
+ describe('includes', () => {
41
+ it('should return true if the collection includes the value', () => {
42
+ const collection = [1, 2, 3];
43
+ const value = 2;
44
+ expect(helpers.includes(collection, value)).toBe(true);
45
+ });
46
+
47
+ it('should return false if the collection does not include the value', () => {
48
+ const collection = [1, 2, 3];
49
+ const value = 4;
50
+ expect(helpers.includes(collection, value)).toBe(false);
51
+ });
52
+ });
53
+
54
+ describe('isDateBefore', () => {
55
+ it('should return true if the left date is before the right date', () => {
56
+ const left = new Date('2021-01-01');
57
+ const right = '2021-12-31';
58
+ expect(helpers.isDateBefore(left, right)).toBe(true);
59
+ });
60
+
61
+ it('should return false if the left date is not before the right date', () => {
62
+ const left = new Date('2021-12-31');
63
+ const right = '2021-01-01';
64
+ expect(helpers.isDateBefore(left, right)).toBe(false);
65
+ });
66
+ });
67
+
68
+ describe('isDateAfter', () => {
69
+ it('should return true if the selected date is after the calculated date', () => {
70
+ const selectedDate = new Date('2022-01-01');
71
+ const baseDate = new Date('2021-01-01');
72
+ const duration = 1;
73
+ const timePeriod = 'years';
74
+ expect(helpers.isDateAfter(selectedDate, baseDate, duration, timePeriod)).toBe(true);
75
+ });
76
+
77
+ it('should return false if the selected date is not after the calculated date', () => {
78
+ const selectedDate = new Date('2021-01-01');
79
+ const baseDate = new Date('2022-01-01');
80
+ const duration = 1;
81
+ const timePeriod = 'years';
82
+ expect(helpers.isDateAfter(selectedDate, baseDate, duration, timePeriod)).toBe(false);
83
+ });
84
+ });
85
+
86
+ describe('useFieldValue', () => {
87
+ it('should return the field value if the key exists', () => {
88
+ helpers.allFieldValues = { question1: 'value1' };
89
+ helpers.allFieldsKeys = ['question1'];
90
+ expect(helpers.useFieldValue('question1')).toBe('value1');
91
+ });
92
+
93
+ it('should return null if the key does not exist', () => {
94
+ expect(helpers.useFieldValue('question2')).toBe(null);
95
+ });
96
+ });
97
+
98
+ describe('doesNotMatchExpression', () => {
99
+ it('should return true if the value does not match the regex', () => {
100
+ const regex = '^abc$';
101
+ const value = 'def';
102
+ expect(helpers.doesNotMatchExpression(regex, value)).toBe(true);
103
+ });
104
+
105
+ it('should return false if the value matches the regex', () => {
106
+ const regex = '^abc$';
107
+ const value = 'abc';
108
+ expect(helpers.doesNotMatchExpression(regex, value)).toBe(false);
109
+ });
110
+ });
111
+
112
+ describe('calcBMI', () => {
113
+ it('should return the correct BMI value', () => {
114
+ const height = 180;
115
+ const weight = 75;
116
+ expect(helpers.calcBMI(height, weight)).toBeCloseTo(23.1, 1);
117
+ });
118
+
119
+ it('should return null if height or weight is not provided', () => {
120
+ expect(helpers.calcBMI(null, 75)).toBe(null);
121
+ expect(helpers.calcBMI(180, null)).toBe(null);
122
+ });
123
+ });
124
+
125
+ describe('calcEDD', () => {
126
+ it('should return the expected date of delivery', () => {
127
+ const lmp = new Date('2021-01-01');
128
+ const expectedEDD = new Date('2021-10-08');
129
+ expect(helpers.calcEDD(lmp)).toEqual(expectedEDD);
130
+ });
131
+
132
+ it('should return null if lmp is not provided', () => {
133
+ expect(helpers.calcEDD(null)).toBe(null);
134
+ });
135
+ });
136
+
137
+ describe('calcMonthsOnART', () => {
138
+ it('should return the correct number of months on ART', () => {
139
+ const artStartDate = new Date('2020-01-01');
140
+ const today = new Date();
141
+ const monthsOnART = Math.floor((today.getTime() - artStartDate.getTime()) / (1000 * 60 * 60 * 24 * 30));
142
+ expect(helpers.calcMonthsOnART(artStartDate)).toBe(monthsOnART);
143
+ });
144
+
145
+ it('should return null if artStartDate is not provided', () => {
146
+ expect(helpers.calcMonthsOnART(null)).toBe(null);
147
+ });
148
+ });
149
+
150
+ describe('calcViralLoadStatus', () => {
151
+ it('should return the correct viral load status', () => {
152
+ expect(helpers.calcViralLoadStatus(100)).toBe('a6768be6-c08e-464d-8f53-5f4229508e54');
153
+ expect(helpers.calcViralLoadStatus(50)).toBe('5d5e42cc-acc4-4069-b3a8-7163e0db5d96');
154
+ });
155
+
156
+ it('should return null if viralLoadCount is not provided', () => {
157
+ expect(helpers.calcViralLoadStatus(null)).toBe(null);
158
+ });
159
+ });
160
+
161
+ describe('calcNextVisitDate', () => {
162
+ it('should return the correct next visit date', () => {
163
+ const followupDate = new Date('2021-01-01');
164
+ const arvDispensedInDays = 30;
165
+ const expectedNextVisitDate = new Date('2021-01-31');
166
+ expect(helpers.calcNextVisitDate(followupDate, arvDispensedInDays)).toEqual(expectedNextVisitDate);
167
+ });
168
+
169
+ it('should return null if followupDate or arvDispensedInDays is not provided', () => {
170
+ expect(helpers.calcNextVisitDate(null, 30)).toBe(null);
171
+ expect(helpers.calcNextVisitDate(new Date('2021-01-01'), null)).toBe(null);
172
+ });
173
+ });
174
+
175
+ describe('calcTreatmentEndDate', () => {
176
+ it('should return the correct treatment end date', () => {
177
+ const followupDate = new Date('2021-01-01');
178
+ const arvDispensedInDays = 30;
179
+ const patientStatus = '160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
180
+ const expectedTreatmentEndDate = new Date('2021-03-02');
181
+ expect(helpers.calcTreatmentEndDate(followupDate, arvDispensedInDays, patientStatus)).toEqual(
182
+ expectedTreatmentEndDate,
183
+ );
184
+ });
185
+
186
+ it('should return null if followupDate, arvDispensedInDays, or patientStatus is not provided', () => {
187
+ expect(helpers.calcTreatmentEndDate(null, 30, '160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')).toBe(null);
188
+ expect(helpers.calcTreatmentEndDate(new Date('2021-01-01'), null, '160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')).toBe(
189
+ null,
190
+ );
191
+ expect(helpers.calcTreatmentEndDate(new Date('2021-01-01'), 30, null)).toBe(null);
192
+ });
193
+ });
194
+
195
+ describe('calcAgeBasedOnDate', () => {
196
+ it('should return the correct age based on the date provided', () => {
197
+ const dateValue = '2021-01-01';
198
+ const expectedAge = 31;
199
+ expect(helpers.calcAgeBasedOnDate(dateValue)).toBe(expectedAge);
200
+ });
201
+
202
+ it('should return the correct age based on the current date if no date is provided', () => {
203
+ const currentYear = new Date().getFullYear();
204
+ const birthYear = new Date(mockPatient.birthDate).getFullYear();
205
+ const expectedAge = currentYear - birthYear;
206
+ expect(helpers.calcAgeBasedOnDate()).toBe(expectedAge);
207
+ });
208
+ });
209
+
210
+ describe('arrayContains', () => {
211
+ it('should return true if the array contains all members', () => {
212
+ const array = [1, 2, 3];
213
+ const members = [1, 2];
214
+ expect(helpers.arrayContains(array, members)).toBe(true);
215
+ });
216
+
217
+ it('should return false if the array does not contain all members', () => {
218
+ const array = [1, 2, 3];
219
+ const members = [1, 4];
220
+ expect(helpers.arrayContains(array, members)).toBe(false);
221
+ });
222
+ });
223
+
224
+ describe('arrayContainsAny', () => {
225
+ it('should return true if the array contains any of the members', () => {
226
+ const array = [1, 2, 3];
227
+ const members = [1, 4];
228
+ expect(helpers.arrayContainsAny(array, members)).toBe(true);
229
+ });
230
+
231
+ it('should return false if the array does not contain any of the members', () => {
232
+ const array = [1, 2, 3];
233
+ const members = [4, 5];
234
+ expect(helpers.arrayContainsAny(array, members)).toBe(false);
235
+ });
236
+ });
237
+
238
+ describe('parseDate', () => {
239
+ it('returns a Date object', () => {
240
+ const result = helpers.parseDate('2023-04-13');
241
+ expect(result instanceof Date).toBe(true);
242
+ });
243
+
244
+ it('uses default format and offset values when passed as null arguments', () => {
245
+ const result = helpers.parseDate('2023-04-13T01:23:45.678Z');
246
+ expect(result.toISOString()).toEqual('2023-04-13T01:23:45.678Z');
247
+ });
248
+ });
249
+
250
+ describe('formatDate', () => {
251
+ it('should return a formatted date string', () => {
252
+ const dateValue = '2022-11-21';
253
+ const formattedDate = helpers.formatDate(dateValue, 'DD/MM/YYYY');
254
+ expect(formattedDate).toBe('21/11/2022');
255
+ });
256
+
257
+ it('defaults to openmrs locale format if no format is passed', () => {
258
+ const formattedDate = helpers.formatDate('2023-04-13T01:23:45.678Z');
259
+ expect(formattedDate).toEqual('13-Apr-2023');
260
+ });
261
+
262
+ it('should throw an error if the value is not a valid date', () => {
263
+ const invalidDateString = 'not a valid date';
264
+ expect(() => {
265
+ helpers.formatDate(invalidDateString);
266
+ }).toThrow('DateFormatException: value passed is not a valid date');
267
+ });
268
+ });
269
+
270
+ describe('extractRepeatingGroupValues', () => {
271
+ it('should return the values of the specified key from the array of objects', () => {
272
+ const array = [{ key1: 'value1' }, { key1: 'value2' }];
273
+ const key = 'key1';
274
+ expect(helpers.extractRepeatingGroupValues(key, array)).toEqual(['value1', 'value2']);
275
+ });
276
+
277
+ it('returns an empty array if the input array is empty', () => {
278
+ const emptyArray = [];
279
+ const values = helpers.extractRepeatingGroupValues('someKey', emptyArray);
280
+ expect(values).toEqual([]);
281
+ });
282
+ });
283
+
284
+ describe('calcGravida', () => {
285
+ it('should return the correct gravida value', () => {
286
+ const parityTerm = 2;
287
+ const parityAbortion = 1;
288
+ expect(helpers.calcGravida(parityTerm, parityAbortion)).toBe(3);
289
+ });
290
+
291
+ it('should throw an error if either input is not a valid number', () => {
292
+ expect(() => {
293
+ helpers.calcGravida('invalid', 1);
294
+ }).toThrow('Both inputs must be valid numbers.');
295
+ });
296
+ });
297
+
298
+ describe('calcTimeDifference', () => {
299
+ it('should return the correct time difference in days', () => {
300
+ const obsDate = dayjs().subtract(5, 'days');
301
+ expect(helpers.calcTimeDifference(obsDate, 'd')).toBe(5);
302
+ });
303
+
304
+ it('should return the correct time difference in weeks', () => {
305
+ const obsDate = dayjs().subtract(2, 'weeks');
306
+ expect(helpers.calcTimeDifference(obsDate, 'w')).toBe(2);
307
+ });
308
+
309
+ it('should return the correct time difference in months', () => {
310
+ const obsDate = dayjs().subtract(3, 'months');
311
+ expect(helpers.calcTimeDifference(obsDate, 'm')).toBe(3);
312
+ });
313
+
314
+ it('should return the correct time difference in years', () => {
315
+ const obsDate = dayjs().subtract(1, 'year');
316
+ expect(helpers.calcTimeDifference(obsDate, 'y')).toBe(1);
317
+ });
318
+
319
+ it('should return "0" if obsDate is not provided', () => {
320
+ expect(helpers.calcTimeDifference(null, 'd')).toBe('0');
321
+ });
322
+ });
323
+
324
+ describe('resolve', () => {
325
+ it('should resolve the promise', async () => {
326
+ const promise = Promise.resolve('resolved value');
327
+ const result = await helpers.resolve(promise);
328
+ expect(result).toBe('resolved value');
329
+ });
330
+ });
331
+ });
@@ -12,6 +12,7 @@ import { isEmpty as isValueEmpty } from '../validators/form-validator';
12
12
  import * as apiFunctions from '../api';
13
13
  import { getZRefByGenderAndAge } from './zscore-service';
14
14
  import { ConceptFalse, ConceptTrue } from '../constants';
15
+ import { formatDate, parseDate } from '@openmrs/esm-framework';
15
16
 
16
17
  export class CommonExpressionHelpers {
17
18
  node: FormNode = null;
@@ -73,8 +74,7 @@ export class CommonExpressionHelpers {
73
74
  default:
74
75
  break;
75
76
  }
76
-
77
- return selectedDate.getTime() > calculatedDate.getTime();
77
+ return selectedDate.getTime() >= calculatedDate.getTime();
78
78
  };
79
79
 
80
80
  addWeeksToDate = (date: Date, weeks: number) => {
@@ -125,6 +125,12 @@ export class CommonExpressionHelpers {
125
125
  };
126
126
 
127
127
  calcMonthsOnART = (artStartDate: Date) => {
128
+ if (artStartDate == null) return null;
129
+
130
+ if (!(artStartDate instanceof Date)) {
131
+ throw new Error('DateFormatException: value passed is not a valid date');
132
+ }
133
+
128
134
  let today = new Date();
129
135
  let resultMonthsOnART: number;
130
136
  let artInDays = Math.round((today.getTime() - artStartDate.getTime?.()) / 86400000);
@@ -238,18 +244,21 @@ export class CommonExpressionHelpers {
238
244
  return false;
239
245
  };
240
246
 
241
- formatDate = (value: ConstructorParameters<typeof Date>[0], format?: string | null, offset?: string | null) => {
242
- format = format ?? 'yyyy-MM-dd';
243
- offset = offset ?? '+0300';
247
+ parseDate = (dateString: string) => {
248
+ return parseDate(dateString);
249
+ };
244
250
 
251
+ formatDate = (value: ConstructorParameters<typeof Date>[0], format?: string) => {
245
252
  if (!(value instanceof Date)) {
246
253
  value = new Date(value);
247
- if (value === null || value === undefined) {
248
- throw new Error('DateFormatException: value passed ' + 'is not a valid date');
254
+ if (value === null || value === undefined || isNaN(value.getTime())) {
255
+ throw new Error('DateFormatException: value passed is not a valid date');
249
256
  }
250
257
  }
251
-
252
- return value;
258
+ if (format) {
259
+ return dayjs(value).format(format);
260
+ }
261
+ return formatDate(value);
253
262
  };
254
263
 
255
264
  extractRepeatingGroupValues = (key: string | number | symbol, array: Record<string | number | symbol, unknown>[]) => {
@@ -274,114 +274,3 @@ describe('Common expression runner - checkReferenceToResolvedFragment', () => {
274
274
  expect(result).toEqual(expected);
275
275
  });
276
276
  });
277
-
278
- describe('Common expression runner - validate helper functions', () => {
279
- const allFields = JSON.parse(JSON.stringify(testFields));
280
- const allFieldsKeys = allFields.map((f) => f.id);
281
- let valuesMap = {
282
- linkedToCare: '',
283
- patientIdentificationNumber: '',
284
- htsProviderRemarks: '',
285
- referredToPreventionServices: [],
286
- bodyTemperature: 0,
287
- };
288
-
289
- const users = [
290
- { id: 1, name: 'Alice', age: 25 },
291
- { id: 2, name: 'Bob', age: 30 },
292
- { id: 3, name: 'Charlie', age: 35 },
293
- ];
294
-
295
- afterEach(() => {
296
- // teardown
297
- valuesMap = {
298
- linkedToCare: '',
299
- patientIdentificationNumber: '',
300
- htsProviderRemarks: '',
301
- referredToPreventionServices: [],
302
- bodyTemperature: 0,
303
- };
304
- allFields.forEach((field) => {
305
- field.fieldDependents = undefined;
306
- });
307
- });
308
- const helper = new CommonExpressionHelpers(
309
- { value: allFields[1], type: 'field' },
310
- {},
311
- allFields,
312
- valuesMap,
313
- allFieldsKeys,
314
- );
315
-
316
- it('should return true if value is empty, null or undefined', () => {
317
- let val = '';
318
-
319
- expect(helper.isEmpty(val)).toBe(true);
320
-
321
- val = 'test';
322
- expect(helper.isEmpty(val)).toBe(false);
323
-
324
- val = null;
325
- expect(helper.isEmpty(val)).toBe(true);
326
-
327
- val = undefined;
328
- expect(helper.isEmpty(val)).toBe(true);
329
- });
330
-
331
- it('should return true if array contains items', () => {
332
- const arr = [1, 2, 3, 4];
333
-
334
- let members = [1, 4];
335
-
336
- let result = helper.arrayContains(arr, members);
337
- expect(result).toBe(true);
338
-
339
- members = [4, 7, 8, 9, 0, 6];
340
- result = helper.arrayContains(arr, members);
341
- expect(result).toBe(false);
342
- });
343
-
344
- it('should return true if array contains atleast one item', () => {
345
- const arr = [1, 2, 3, 4];
346
-
347
- let members = [1, 4, 7, 8, 9, 0, 6];
348
-
349
- let result = helper.arrayContainsAny(arr, members);
350
- expect(result).toBe(true);
351
-
352
- members = [7, 8, 9, 0, 6];
353
- result = helper.arrayContainsAny(arr, members);
354
- expect(result).toBe(false);
355
- });
356
-
357
- it('should evaluate values against regular expressions(Regex)', () => {
358
- const regex = '[A-Za-z0-9]+-123456';
359
-
360
- let result = helper.doesNotMatchExpression(regex, 'RandomID');
361
- expect(result).toBe(true);
362
-
363
- result = helper.doesNotMatchExpression(regex, 'REC12345-123456');
364
- expect(result).toBe(false);
365
- });
366
-
367
- it('returns an array of values for a given key', () => {
368
- const ages = helper.extractRepeatingGroupValues('age', users);
369
- expect(ages).toEqual([25, 30, 35]);
370
- });
371
-
372
- it('returns an empty array if the input array is empty', () => {
373
- const emptyArray = [];
374
- const values = helper.extractRepeatingGroupValues('someKey', emptyArray);
375
- expect(values).toEqual([]);
376
- });
377
-
378
- it('returns a Date object', () => {
379
- const result = helper.formatDate('2023-04-13', 'yyyy-MM-dd', '+0300');
380
- expect(result instanceof Date).toBe(true);
381
- });
382
-
383
- it('uses default format and offset values when passed as null arguments', () => {
384
- const result = helper.formatDate('2023-04-13T01:23:45.678Z', null, null);
385
- expect(result.toISOString()).toEqual('2023-04-13T01:23:45.678Z');
386
- });
387
- });
package/tsconfig.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "jsx": "react",
7
7
  "skipLibCheck": true,
8
8
  "moduleResolution": "node",
9
- "lib": ["dom", "es5", "scripthost", "es2015", "es2015.promise", "es2016.array.include", "es2018", "es2020"],
9
+ "lib": ["dom", "es5", "scripthost", "es2015", "es2015.promise", "es2016.array.include", "es2018", "es2020", "es2022"],
10
10
  "resolveJsonModule": true,
11
11
  "noEmit": true,
12
12
  "target": "esnext",