hplx-feature-library 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PediatricsCalculator/index.js +1 -1
- package/dist/{PediatricsCalculatorTable-B_PUGW3o.js → PediatricsCalculatorTable-6R2ojFlz.js} +1 -1
- package/dist/{PediatricsCalculatorTable-DfJysOex.cjs → PediatricsCalculatorTable-BMIyRcXO.cjs} +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/{PediatricsCalculatorTable-B_PUGW3o.js → PediatricsCalculatorTable-6R2ojFlz.js}
RENAMED
|
@@ -11280,7 +11280,7 @@ const py = /* @__PURE__ */ bh(aj), oj = (t) => {
|
|
|
11280
11280
|
return /* @__PURE__ */ Y.jsxs("div", { className: "hfl-border-1 hfl-border-Gray-200", children: [
|
|
11281
11281
|
/* @__PURE__ */ Y.jsx("div", { className: "table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50", children: Ny.map((S) => /* @__PURE__ */ Y.jsx(We, { variant: "Medium", type: "Text sm", className: "hfl-text-Blue_gray-600", children: S }, S)) }),
|
|
11282
11282
|
/* @__PURE__ */ Y.jsxs(oy.Provider, { value: H, children: [
|
|
11283
|
-
/* @__PURE__ */ Y.jsx("div", { className: "table-body", children: t.length === 0 ? /* @__PURE__ */ Y.jsx(We, { variant: "Medium", type: "Text sm", className: "hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3", children: "No medicines added" }) : t.map((S) => /* @__PURE__ */ Y.jsx(
|
|
11283
|
+
/* @__PURE__ */ Y.jsx("div", { className: "table-body", children: !t || t.length === 0 ? /* @__PURE__ */ Y.jsx(We, { variant: "Medium", type: "Text sm", className: "hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3", children: "No medicines added" }) : t.map((S) => /* @__PURE__ */ Y.jsx(
|
|
11284
11284
|
z1,
|
|
11285
11285
|
{
|
|
11286
11286
|
rowData: j[S.rowId]?.formData || S,
|
package/dist/{PediatricsCalculatorTable-DfJysOex.cjs → PediatricsCalculatorTable-BMIyRcXO.cjs}
RENAMED
|
@@ -121,4 +121,4 @@ doc.body (`+u+`):
|
|
|
121
121
|
`+n:"")+`
|
|
122
122
|
|
|
123
123
|
The above lifecycles should be removed. Learn more about this warning here:
|
|
124
|
-
https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStateFromProps=="function"&&(r.componentWillMount=ny,r.componentWillReceiveProps=ay),typeof r.getSnapshotBeforeUpdate=="function"){if(typeof r.componentDidUpdate!="function")throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");r.componentWillUpdate=oy;var i=r.componentDidUpdate;r.componentDidUpdate=function(u,c,f){var d=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:f;i.call(this,u,c,d)}}return t}const H1=Object.freeze(Object.defineProperty({__proto__:null,polyfill:U1},Symbol.toStringTag,{value:"Module"})),B1=_y(H1);var uh;function q1(){if(uh)return br;uh=1,Object.defineProperty(br,"__esModule",{value:!0}),br.bodyOpenClassName=br.portalClassName=void 0;var t=Object.assign||function(F){for(var D=1;D<arguments.length;D++){var T=arguments[D];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(F[C]=T[C])}return F},r=function(){function F(D,T){for(var C=0;C<T.length;C++){var S=T[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(D,S.key,S)}}return function(D,T,C){return T&&F(D.prototype,T),C&&F(D,C),D}}(),a=le,e=g(a),n=Oa,o=g(n),s=Gl(),i=g(s),l=Y1(),u=g(l),c=ty(),f=m(c),d=Gu(),p=g(d),h=B1;function m(F){if(F&&F.__esModule)return F;var D={};if(F!=null)for(var T in F)Object.prototype.hasOwnProperty.call(F,T)&&(D[T]=F[T]);return D.default=F,D}function g(F){return F&&F.__esModule?F:{default:F}}function E(F,D){if(!(F instanceof D))throw new TypeError("Cannot call a class as a function")}function j(F,D){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:F}function _(F,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);F.prototype=Object.create(D&&D.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(F,D):F.__proto__=D)}var k=br.portalClassName="ReactModalPortal",b=br.bodyOpenClassName="ReactModal__Body--open",v=d.canUseDOM&&o.default.createPortal!==void 0,M=function(D){return document.createElement(D)},H=function(){return v?o.default.createPortal:o.default.unstable_renderSubtreeIntoContainer};function X(F){return F()}var Q=function(F){_(D,F);function D(){var T,C,S,U;E(this,D);for(var O=arguments.length,V=Array(O),ee=0;ee<O;ee++)V[ee]=arguments[ee];return U=(C=(S=j(this,(T=D.__proto__||Object.getPrototypeOf(D)).call.apply(T,[this].concat(V))),S),S.removePortal=function(){!v&&o.default.unmountComponentAtNode(S.node);var N=X(S.props.parentSelector);N&&N.contains(S.node)?N.removeChild(S.node):console.warn('React-Modal: "parentSelector" prop did not returned any DOM element. Make sure that the parent element is unmounted to avoid any memory leaks.')},S.portalRef=function(N){S.portal=N},S.renderPortal=function(N){var B=H(),J=B(S,e.default.createElement(u.default,t({defaultStyles:D.defaultStyles},N)),S.node);S.portalRef(J)},C),j(S,U)}return r(D,[{key:"componentDidMount",value:function(){if(d.canUseDOM){v||(this.node=M("div")),this.node.className=this.props.portalClassName;var C=X(this.props.parentSelector);C.appendChild(this.node),!v&&this.renderPortal(this.props)}}},{key:"getSnapshotBeforeUpdate",value:function(C){var S=X(C.parentSelector),U=X(this.props.parentSelector);return{prevParent:S,nextParent:U}}},{key:"componentDidUpdate",value:function(C,S,U){if(d.canUseDOM){var O=this.props,V=O.isOpen,ee=O.portalClassName;C.portalClassName!==ee&&(this.node.className=ee);var N=U.prevParent,B=U.nextParent;B!==N&&(N.removeChild(this.node),B.appendChild(this.node)),!(!C.isOpen&&!V)&&!v&&this.renderPortal(this.props)}}},{key:"componentWillUnmount",value:function(){if(!(!d.canUseDOM||!this.node||!this.portal)){var C=this.portal.state,S=Date.now(),U=C.isOpen&&this.props.closeTimeoutMS&&(C.closesAt||S+this.props.closeTimeoutMS);U?(C.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal,U-S)):this.removePortal()}}},{key:"render",value:function(){if(!d.canUseDOM||!v)return null;!this.node&&v&&(this.node=M("div"));var C=H();return C(e.default.createElement(u.default,t({ref:this.portalRef,defaultStyles:D.defaultStyles},this.props)),this.node)}}],[{key:"setAppElement",value:function(C){f.setElement(C)}}]),D}(a.Component);return Q.propTypes={isOpen:i.default.bool.isRequired,style:i.default.shape({content:i.default.object,overlay:i.default.object}),portalClassName:i.default.string,bodyOpenClassName:i.default.string,htmlOpenClassName:i.default.string,className:i.default.oneOfType([i.default.string,i.default.shape({base:i.default.string.isRequired,afterOpen:i.default.string.isRequired,beforeClose:i.default.string.isRequired})]),overlayClassName:i.default.oneOfType([i.default.string,i.default.shape({base:i.default.string.isRequired,afterOpen:i.default.string.isRequired,beforeClose:i.default.string.isRequired})]),appElement:i.default.oneOfType([i.default.instanceOf(p.default),i.default.instanceOf(d.SafeHTMLCollection),i.default.instanceOf(d.SafeNodeList),i.default.arrayOf(i.default.instanceOf(p.default))]),onAfterOpen:i.default.func,onRequestClose:i.default.func,closeTimeoutMS:i.default.number,ariaHideApp:i.default.bool,shouldFocusAfterRender:i.default.bool,shouldCloseOnOverlayClick:i.default.bool,shouldReturnFocusAfterClose:i.default.bool,preventScroll:i.default.bool,parentSelector:i.default.func,aria:i.default.object,data:i.default.object,role:i.default.string,contentLabel:i.default.string,shouldCloseOnEsc:i.default.bool,overlayRef:i.default.func,contentRef:i.default.func,id:i.default.string,overlayElement:i.default.func,contentElement:i.default.func},Q.defaultProps={isOpen:!1,portalClassName:k,bodyOpenClassName:b,role:"dialog",ariaHideApp:!0,closeTimeoutMS:0,shouldFocusAfterRender:!0,shouldCloseOnEsc:!0,shouldCloseOnOverlayClick:!0,shouldReturnFocusAfterClose:!0,preventScroll:!1,parentSelector:function(){return document.body},overlayElement:function(D,T){return e.default.createElement("div",D,T)},contentElement:function(D,T){return e.default.createElement("div",D,T)}},Q.defaultStyles={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.75)"},content:{position:"absolute",top:"40px",left:"40px",right:"40px",bottom:"40px",border:"1px solid #ccc",background:"#fff",overflow:"auto",WebkitOverflowScrolling:"touch",borderRadius:"4px",outline:"none",padding:"20px"}},(0,h.polyfill)(Q),process.env.NODE_ENV!=="production"&&(Q.setCreateHTMLElement=function(F){return M=F}),br.default=Q,br}var ch;function z1(){return ch||(ch=1,function(t,r){Object.defineProperty(r,"__esModule",{value:!0});var a=q1(),e=n(a);function n(o){return o&&o.__esModule?o:{default:o}}r.default=e.default,t.exports=r.default}(fo,fo.exports)),fo.exports}var $1=z1();const iy=dh($1),K1=t=>{const{openState:r,closePopupCallback:a,headingIconFile:e,headingText:n,subHeadingText:o,positiveButtonText:s,negativeButtonText:i,classNamePositiveBtn:l,classNameNegativeBtn:u,positiveActionCallback:c,negativeActionCallback:f}=t;return Y.jsxs(iy,{isOpen:r,onRequestClose:a,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",position:"fixed",alignContent:"center",justifyContent:"center",zIndex:1030,display:r?"block":"none"},content:{zIndex:1030,padding:"24px",maxWidth:"750px",maxHeight:"600px",width:"400px",height:"fit-content",margin:"auto",borderRadius:"12px",overflow:"unset",display:r?"block":"none"}},children:[e=="warning"&&Y.jsx("div",{className:"hfl-hx_warning hfl-mb-4 hfl-flex hfl-h-12 hfl-w-12 hfl-items-center hfl-justify-center hfl-rounded-full hfl-border-8 hfl-border-Warning-50 hfl-bg-Warning-100 hfl-text-Warning-600",children:Y.jsx("i",{className:"hx_warning hfl-text-5"})}),Y.jsx(Ye,{variant:"Medium",type:"Text xl",className:"hfl-mt-5 hfl-text-Gray-900",children:n}),o&&Y.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-mt-1 hfl-text-Gray-500 ",children:o}),Y.jsxs("div",{className:"hfl-mt-4 hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[i&&Y.jsx(da,{size:"md",textField:i,hierarchy:"Primary",className:u||"",onClick:f,"data-qa":"negative-action"}),s&&Y.jsx(da,{size:"md",textField:s,hierarchy:"Secondary",className:l||"",onClick:c,"data-qa":"positive-action"})]})]})},V1=[{medicine_id:"med_001",medicine_name:"Paracetamol 650mg",generic_name:"Paracetamol",type:"Tablet",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:650,dose_mg_kg:15,frequency:"3(TDS)",pedia_dosage:"1-1-1",max_mg_dose:1e3,max_mg_day:4e3}},{medicine_id:"med_002",medicine_name:"Amoxiclav Dry Syrup",generic_name:"Amoxicillin & Clavulanic Acid",type:"Syrup",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:228.5,dose_mg_kg:25,frequency:"2(BD)",pedia_dosage:"1-0-1",max_mg_dose:500,max_mg_day:1e3}},{medicine_id:"med_003",medicine_name:"Ceftriaxone 1g IV",generic_name:"Ceftriaxone",type:"Injection",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:1e3,dose_mg_kg:80,frequency:"1(OD)",pedia_dosage:"1-0-0",max_mg_dose:2e3,max_mg_day:4e3}},{medicine_id:"med_004",medicine_name:"Ibuprofen Suspension",generic_name:"Ibuprofen",type:"Syrup",calculation_type:xt.E_CalculationType.MlKg,calculation_fields:{multiplier:.5,dose_ml_kg:5,frequency:"3(TDS)",max_ml_dose:10,max_ml_day:40,pedia_dosage:"1-1-1"}}],G1=({open:t,onCancel:r,onSave:a,rowMedicineData:e,getMedicineOptions:n})=>{const[o,s]=le.useState(V1),[i,l]=le.useState(""),[u,c]=le.useState([]),f=async p=>{const m=(await n(p.label)).find(g=>g.medicine_id.toString()===p.value);m&&!o.some(g=>g.medicine_id===m.medicine_id)&&s(g=>[...g,m])},d=p=>{s(h=>h.filter(m=>m.medicine_id!==p))};return le.useEffect(()=>{(async()=>{if(!i){c([]);return}const m=(await n(i)).map(g=>({label:g.medicine_name,value:g.medicine_id.toString()}));c(m)})()},[i,n]),Y.jsxs(iy,{isOpen:t,onRequestClose:r,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",zIndex:1030},content:{zIndex:1031,maxWidth:"600px",maxHeight:"50vh",height:"auto",margin:"auto",borderRadius:"12px",padding:"0px",display:"flex",flexDirection:"column"}},children:[Y.jsx(Ye,{variant:"Bold",type:"Text lg",className:"hfl-text-White hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-2",children:"Please select medicine to copy"}),Y.jsxs("div",{className:"hfl-px-6 hfl-py-5 hfl-flex hfl-flex-col hfl-gap-6 hfl-overflow-y-auto hfl-flex-1",children:[Y.jsx(it,{inputValue:i,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:l,onChangeHandler:f,options:u,placeholder:"Search for medicines"}),Y.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:o.map(p=>Y.jsxs("div",{className:"hfl-flex hfl-items-center hfl-bg-Gray-100 hfl-px-2 hfl-py-0.5 hfl-rounded-md hfl-gap-1",children:[Y.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:p.medicine_name}),Y.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>d(p.medicine_id),children:Y.jsx("i",{className:"hx_close"})})]},p.medicine_id))})]}),Y.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-2.5 hfl-bg-Gray-50 hfl-px-7 hfl-py-3 hfl-border-t hfl-border-Gray-200",children:[Y.jsx(da,{size:"md",textField:"Cancel",onClick:r,hierarchy:"Secondary-Grey"}),Y.jsx(da,{size:"md",textField:"Save",onClick:()=>a(e,o),className:"hfl-bg-Primary-600 hfl-text-White",hierarchy:"Primary"})]})]})},Q1=({data:t,variant:r,externallyTriggeredEditRowIds:a=[],externallyTriggeredEditMode:e=!1,getMedicineOptions:n,onRowChange:o,onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,onSaveRow:u,externalSaveTrigger:c,setSearchDisabled:f})=>{const[d,p]=le.useState(null),[h,m]=le.useState(!1),[g,E]=le.useState(),[j,_]=le.useState({});le.useEffect(()=>{_(D=>{const T={...D};return t.forEach(C=>{T[C.rowId]?T[C.rowId]={...T[C.rowId],formData:{...T[C.rowId].formData,...C}}:T[C.rowId]={formData:C,isEditing:!1}}),T})},[t]);const k=(D,T)=>{_(C=>({...C,[D]:{...C[D],formData:{...C[D].formData,...T}}}))},b=le.useCallback((D,T)=>{_(C=>{const S={...C,[D]:{...C[D],isEditing:T}},U=Object.values(S).some(O=>O.isEditing);return f?.(U),S})},[f]),v=le.useCallback(async()=>{const T=Object.entries(j).filter(([,{formData:C,isEditing:S}])=>S&&C.medicine_name).map(([,{formData:C}])=>C);if(T.length!==0)try{await u?.(T),_(C=>{const S={...C};for(const U of T)S[U.rowId]={...S[U.rowId],isEditing:!1};return f?.(!1),S})}catch(C){console.error("Bulk save failed",C)}},[u,j,f]);le.useEffect(()=>{c&&v().finally(()=>{f?.(!1)})},[c,v,f]);const H={variant:r,externallyTriggeredEditMode:e,externallyTriggeredEditRowIds:a,getMedicineOptions:n,onRowChange:D=>{k(D.rowId,D),o(D)},onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,setRowToDelete:p,openPopupForRow:D=>{E(D),m(!0)}},X=async()=>{if(d)try{s?.(d)}catch(D){console.error("Delete failed",D)}finally{p(null)}},Q=()=>{p(null)},F=le.useCallback(async D=>{await u?.([D]),b(D.rowId,!1)},[u,b]);return Y.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[Y.jsx("div",{className:"table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50",children:xt.C_Table_Column_Name.map(D=>Y.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:D},D))}),Y.jsxs(Jv.Provider,{value:H,children:[Y.jsx("div",{className:"table-body",children:t.length===0?Y.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3",children:"No medicines added"}):t.map(D=>Y.jsx(R1,{rowData:j[D.rowId]?.formData||D,isEditing:j[D.rowId]?.isEditing||!1,setFormData:T=>k(D.rowId,T),setIsEditing:T=>b(D.rowId,T),onSaveRow:F},D.rowId))}),Y.jsx(K1,{headingText:"Delete Medicine",subHeadingText:"Are you sure you want to delete this medicine?",openState:!!d,positiveButtonText:"Delete",negativeButtonText:"Cancel",positiveActionCallback:X,negativeActionCallback:Q,classNameNegativeBtn:"hfl-bg-Blue-600",classNamePositiveBtn:"hfl-bg-Error-500 hover:hfl-bg-Error-700 hfl-text-White",closePopupCallback:Q}),Y.jsx(G1,{open:h,onCancel:()=>m(!1),onSave:(D,T)=>{try{i?.(D,T)}catch(C){console.error("Error copying medicines:",C)}finally{m(!1)}},rowMedicineData:g,getMedicineOptions:n})]})]})};exports.PediatricsCalculatorTable=Q1;
|
|
124
|
+
https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof t.getDerivedStateFromProps=="function"&&(r.componentWillMount=ny,r.componentWillReceiveProps=ay),typeof r.getSnapshotBeforeUpdate=="function"){if(typeof r.componentDidUpdate!="function")throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");r.componentWillUpdate=oy;var i=r.componentDidUpdate;r.componentDidUpdate=function(u,c,f){var d=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:f;i.call(this,u,c,d)}}return t}const H1=Object.freeze(Object.defineProperty({__proto__:null,polyfill:U1},Symbol.toStringTag,{value:"Module"})),B1=_y(H1);var uh;function q1(){if(uh)return br;uh=1,Object.defineProperty(br,"__esModule",{value:!0}),br.bodyOpenClassName=br.portalClassName=void 0;var t=Object.assign||function(F){for(var D=1;D<arguments.length;D++){var T=arguments[D];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(F[C]=T[C])}return F},r=function(){function F(D,T){for(var C=0;C<T.length;C++){var S=T[C];S.enumerable=S.enumerable||!1,S.configurable=!0,"value"in S&&(S.writable=!0),Object.defineProperty(D,S.key,S)}}return function(D,T,C){return T&&F(D.prototype,T),C&&F(D,C),D}}(),a=le,e=g(a),n=Oa,o=g(n),s=Gl(),i=g(s),l=Y1(),u=g(l),c=ty(),f=m(c),d=Gu(),p=g(d),h=B1;function m(F){if(F&&F.__esModule)return F;var D={};if(F!=null)for(var T in F)Object.prototype.hasOwnProperty.call(F,T)&&(D[T]=F[T]);return D.default=F,D}function g(F){return F&&F.__esModule?F:{default:F}}function E(F,D){if(!(F instanceof D))throw new TypeError("Cannot call a class as a function")}function j(F,D){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:F}function _(F,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);F.prototype=Object.create(D&&D.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(F,D):F.__proto__=D)}var k=br.portalClassName="ReactModalPortal",b=br.bodyOpenClassName="ReactModal__Body--open",v=d.canUseDOM&&o.default.createPortal!==void 0,M=function(D){return document.createElement(D)},H=function(){return v?o.default.createPortal:o.default.unstable_renderSubtreeIntoContainer};function X(F){return F()}var Q=function(F){_(D,F);function D(){var T,C,S,U;E(this,D);for(var O=arguments.length,V=Array(O),ee=0;ee<O;ee++)V[ee]=arguments[ee];return U=(C=(S=j(this,(T=D.__proto__||Object.getPrototypeOf(D)).call.apply(T,[this].concat(V))),S),S.removePortal=function(){!v&&o.default.unmountComponentAtNode(S.node);var N=X(S.props.parentSelector);N&&N.contains(S.node)?N.removeChild(S.node):console.warn('React-Modal: "parentSelector" prop did not returned any DOM element. Make sure that the parent element is unmounted to avoid any memory leaks.')},S.portalRef=function(N){S.portal=N},S.renderPortal=function(N){var B=H(),J=B(S,e.default.createElement(u.default,t({defaultStyles:D.defaultStyles},N)),S.node);S.portalRef(J)},C),j(S,U)}return r(D,[{key:"componentDidMount",value:function(){if(d.canUseDOM){v||(this.node=M("div")),this.node.className=this.props.portalClassName;var C=X(this.props.parentSelector);C.appendChild(this.node),!v&&this.renderPortal(this.props)}}},{key:"getSnapshotBeforeUpdate",value:function(C){var S=X(C.parentSelector),U=X(this.props.parentSelector);return{prevParent:S,nextParent:U}}},{key:"componentDidUpdate",value:function(C,S,U){if(d.canUseDOM){var O=this.props,V=O.isOpen,ee=O.portalClassName;C.portalClassName!==ee&&(this.node.className=ee);var N=U.prevParent,B=U.nextParent;B!==N&&(N.removeChild(this.node),B.appendChild(this.node)),!(!C.isOpen&&!V)&&!v&&this.renderPortal(this.props)}}},{key:"componentWillUnmount",value:function(){if(!(!d.canUseDOM||!this.node||!this.portal)){var C=this.portal.state,S=Date.now(),U=C.isOpen&&this.props.closeTimeoutMS&&(C.closesAt||S+this.props.closeTimeoutMS);U?(C.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal,U-S)):this.removePortal()}}},{key:"render",value:function(){if(!d.canUseDOM||!v)return null;!this.node&&v&&(this.node=M("div"));var C=H();return C(e.default.createElement(u.default,t({ref:this.portalRef,defaultStyles:D.defaultStyles},this.props)),this.node)}}],[{key:"setAppElement",value:function(C){f.setElement(C)}}]),D}(a.Component);return Q.propTypes={isOpen:i.default.bool.isRequired,style:i.default.shape({content:i.default.object,overlay:i.default.object}),portalClassName:i.default.string,bodyOpenClassName:i.default.string,htmlOpenClassName:i.default.string,className:i.default.oneOfType([i.default.string,i.default.shape({base:i.default.string.isRequired,afterOpen:i.default.string.isRequired,beforeClose:i.default.string.isRequired})]),overlayClassName:i.default.oneOfType([i.default.string,i.default.shape({base:i.default.string.isRequired,afterOpen:i.default.string.isRequired,beforeClose:i.default.string.isRequired})]),appElement:i.default.oneOfType([i.default.instanceOf(p.default),i.default.instanceOf(d.SafeHTMLCollection),i.default.instanceOf(d.SafeNodeList),i.default.arrayOf(i.default.instanceOf(p.default))]),onAfterOpen:i.default.func,onRequestClose:i.default.func,closeTimeoutMS:i.default.number,ariaHideApp:i.default.bool,shouldFocusAfterRender:i.default.bool,shouldCloseOnOverlayClick:i.default.bool,shouldReturnFocusAfterClose:i.default.bool,preventScroll:i.default.bool,parentSelector:i.default.func,aria:i.default.object,data:i.default.object,role:i.default.string,contentLabel:i.default.string,shouldCloseOnEsc:i.default.bool,overlayRef:i.default.func,contentRef:i.default.func,id:i.default.string,overlayElement:i.default.func,contentElement:i.default.func},Q.defaultProps={isOpen:!1,portalClassName:k,bodyOpenClassName:b,role:"dialog",ariaHideApp:!0,closeTimeoutMS:0,shouldFocusAfterRender:!0,shouldCloseOnEsc:!0,shouldCloseOnOverlayClick:!0,shouldReturnFocusAfterClose:!0,preventScroll:!1,parentSelector:function(){return document.body},overlayElement:function(D,T){return e.default.createElement("div",D,T)},contentElement:function(D,T){return e.default.createElement("div",D,T)}},Q.defaultStyles={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.75)"},content:{position:"absolute",top:"40px",left:"40px",right:"40px",bottom:"40px",border:"1px solid #ccc",background:"#fff",overflow:"auto",WebkitOverflowScrolling:"touch",borderRadius:"4px",outline:"none",padding:"20px"}},(0,h.polyfill)(Q),process.env.NODE_ENV!=="production"&&(Q.setCreateHTMLElement=function(F){return M=F}),br.default=Q,br}var ch;function z1(){return ch||(ch=1,function(t,r){Object.defineProperty(r,"__esModule",{value:!0});var a=q1(),e=n(a);function n(o){return o&&o.__esModule?o:{default:o}}r.default=e.default,t.exports=r.default}(fo,fo.exports)),fo.exports}var $1=z1();const iy=dh($1),K1=t=>{const{openState:r,closePopupCallback:a,headingIconFile:e,headingText:n,subHeadingText:o,positiveButtonText:s,negativeButtonText:i,classNamePositiveBtn:l,classNameNegativeBtn:u,positiveActionCallback:c,negativeActionCallback:f}=t;return Y.jsxs(iy,{isOpen:r,onRequestClose:a,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",position:"fixed",alignContent:"center",justifyContent:"center",zIndex:1030,display:r?"block":"none"},content:{zIndex:1030,padding:"24px",maxWidth:"750px",maxHeight:"600px",width:"400px",height:"fit-content",margin:"auto",borderRadius:"12px",overflow:"unset",display:r?"block":"none"}},children:[e=="warning"&&Y.jsx("div",{className:"hfl-hx_warning hfl-mb-4 hfl-flex hfl-h-12 hfl-w-12 hfl-items-center hfl-justify-center hfl-rounded-full hfl-border-8 hfl-border-Warning-50 hfl-bg-Warning-100 hfl-text-Warning-600",children:Y.jsx("i",{className:"hx_warning hfl-text-5"})}),Y.jsx(Ye,{variant:"Medium",type:"Text xl",className:"hfl-mt-5 hfl-text-Gray-900",children:n}),o&&Y.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-mt-1 hfl-text-Gray-500 ",children:o}),Y.jsxs("div",{className:"hfl-mt-4 hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[i&&Y.jsx(da,{size:"md",textField:i,hierarchy:"Primary",className:u||"",onClick:f,"data-qa":"negative-action"}),s&&Y.jsx(da,{size:"md",textField:s,hierarchy:"Secondary",className:l||"",onClick:c,"data-qa":"positive-action"})]})]})},V1=[{medicine_id:"med_001",medicine_name:"Paracetamol 650mg",generic_name:"Paracetamol",type:"Tablet",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:650,dose_mg_kg:15,frequency:"3(TDS)",pedia_dosage:"1-1-1",max_mg_dose:1e3,max_mg_day:4e3}},{medicine_id:"med_002",medicine_name:"Amoxiclav Dry Syrup",generic_name:"Amoxicillin & Clavulanic Acid",type:"Syrup",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:228.5,dose_mg_kg:25,frequency:"2(BD)",pedia_dosage:"1-0-1",max_mg_dose:500,max_mg_day:1e3}},{medicine_id:"med_003",medicine_name:"Ceftriaxone 1g IV",generic_name:"Ceftriaxone",type:"Injection",calculation_type:xt.E_CalculationType.MgKgDose,calculation_fields:{drug_strength:1e3,dose_mg_kg:80,frequency:"1(OD)",pedia_dosage:"1-0-0",max_mg_dose:2e3,max_mg_day:4e3}},{medicine_id:"med_004",medicine_name:"Ibuprofen Suspension",generic_name:"Ibuprofen",type:"Syrup",calculation_type:xt.E_CalculationType.MlKg,calculation_fields:{multiplier:.5,dose_ml_kg:5,frequency:"3(TDS)",max_ml_dose:10,max_ml_day:40,pedia_dosage:"1-1-1"}}],G1=({open:t,onCancel:r,onSave:a,rowMedicineData:e,getMedicineOptions:n})=>{const[o,s]=le.useState(V1),[i,l]=le.useState(""),[u,c]=le.useState([]),f=async p=>{const m=(await n(p.label)).find(g=>g.medicine_id.toString()===p.value);m&&!o.some(g=>g.medicine_id===m.medicine_id)&&s(g=>[...g,m])},d=p=>{s(h=>h.filter(m=>m.medicine_id!==p))};return le.useEffect(()=>{(async()=>{if(!i){c([]);return}const m=(await n(i)).map(g=>({label:g.medicine_name,value:g.medicine_id.toString()}));c(m)})()},[i,n]),Y.jsxs(iy,{isOpen:t,onRequestClose:r,shouldCloseOnOverlayClick:!1,style:{overlay:{backgroundColor:"rgba(52, 64, 84, 0.5)",zIndex:1030},content:{zIndex:1031,maxWidth:"600px",maxHeight:"50vh",height:"auto",margin:"auto",borderRadius:"12px",padding:"0px",display:"flex",flexDirection:"column"}},children:[Y.jsx(Ye,{variant:"Bold",type:"Text lg",className:"hfl-text-White hfl-bg-gradient_primary_600_500_90 hfl-px-6 hfl-py-2",children:"Please select medicine to copy"}),Y.jsxs("div",{className:"hfl-px-6 hfl-py-5 hfl-flex hfl-flex-col hfl-gap-6 hfl-overflow-y-auto hfl-flex-1",children:[Y.jsx(it,{inputValue:i,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:l,onChangeHandler:f,options:u,placeholder:"Search for medicines"}),Y.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:o.map(p=>Y.jsxs("div",{className:"hfl-flex hfl-items-center hfl-bg-Gray-100 hfl-px-2 hfl-py-0.5 hfl-rounded-md hfl-gap-1",children:[Y.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:p.medicine_name}),Y.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>d(p.medicine_id),children:Y.jsx("i",{className:"hx_close"})})]},p.medicine_id))})]}),Y.jsxs("div",{className:"hfl-flex hfl-justify-end hfl-gap-2.5 hfl-bg-Gray-50 hfl-px-7 hfl-py-3 hfl-border-t hfl-border-Gray-200",children:[Y.jsx(da,{size:"md",textField:"Cancel",onClick:r,hierarchy:"Secondary-Grey"}),Y.jsx(da,{size:"md",textField:"Save",onClick:()=>a(e,o),className:"hfl-bg-Primary-600 hfl-text-White",hierarchy:"Primary"})]})]})},Q1=({data:t,variant:r,externallyTriggeredEditRowIds:a=[],externallyTriggeredEditMode:e=!1,getMedicineOptions:n,onRowChange:o,onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,onSaveRow:u,externalSaveTrigger:c,setSearchDisabled:f})=>{const[d,p]=le.useState(null),[h,m]=le.useState(!1),[g,E]=le.useState(),[j,_]=le.useState({});le.useEffect(()=>{_(D=>{const T={...D};return t.forEach(C=>{T[C.rowId]?T[C.rowId]={...T[C.rowId],formData:{...T[C.rowId].formData,...C}}:T[C.rowId]={formData:C,isEditing:!1}}),T})},[t]);const k=(D,T)=>{_(C=>({...C,[D]:{...C[D],formData:{...C[D].formData,...T}}}))},b=le.useCallback((D,T)=>{_(C=>{const S={...C,[D]:{...C[D],isEditing:T}},U=Object.values(S).some(O=>O.isEditing);return f?.(U),S})},[f]),v=le.useCallback(async()=>{const T=Object.entries(j).filter(([,{formData:C,isEditing:S}])=>S&&C.medicine_name).map(([,{formData:C}])=>C);if(T.length!==0)try{await u?.(T),_(C=>{const S={...C};for(const U of T)S[U.rowId]={...S[U.rowId],isEditing:!1};return f?.(!1),S})}catch(C){console.error("Bulk save failed",C)}},[u,j,f]);le.useEffect(()=>{c&&v().finally(()=>{f?.(!1)})},[c,v,f]);const H={variant:r,externallyTriggeredEditMode:e,externallyTriggeredEditRowIds:a,getMedicineOptions:n,onRowChange:D=>{k(D.rowId,D),o(D)},onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,setRowToDelete:p,openPopupForRow:D=>{E(D),m(!0)}},X=async()=>{if(d)try{s?.(d)}catch(D){console.error("Delete failed",D)}finally{p(null)}},Q=()=>{p(null)},F=le.useCallback(async D=>{await u?.([D]),b(D.rowId,!1)},[u,b]);return Y.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[Y.jsx("div",{className:"table-header hfl-grid hfl-grid-cols-[1.36fr_1.36fr_1.02fr_1.25fr_2.27fr_1.36fr_1.36fr] hfl-gap-2 hfl-py-2 hfl-px-2 hfl-font-bold hfl-border-b-1 hfl-border-Gray-200 hfl-bg-Blue_gray-50",children:xt.C_Table_Column_Name.map(D=>Y.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:D},D))}),Y.jsxs(Jv.Provider,{value:H,children:[Y.jsx("div",{className:"table-body",children:!t||t.length===0?Y.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600 hfl-px-2 hfl-py-3",children:"No medicines added"}):t.map(D=>Y.jsx(R1,{rowData:j[D.rowId]?.formData||D,isEditing:j[D.rowId]?.isEditing||!1,setFormData:T=>k(D.rowId,T),setIsEditing:T=>b(D.rowId,T),onSaveRow:F},D.rowId))}),Y.jsx(K1,{headingText:"Delete Medicine",subHeadingText:"Are you sure you want to delete this medicine?",openState:!!d,positiveButtonText:"Delete",negativeButtonText:"Cancel",positiveActionCallback:X,negativeActionCallback:Q,classNameNegativeBtn:"hfl-bg-Blue-600",classNamePositiveBtn:"hfl-bg-Error-500 hover:hfl-bg-Error-700 hfl-text-White",closePopupCallback:Q}),Y.jsx(G1,{open:h,onCancel:()=>m(!1),onSave:(D,T)=>{try{i?.(D,T)}catch(C){console.error("Error copying medicines:",C)}finally{m(!1)}},rowMedicineData:g,getMedicineOptions:n})]})]})};exports.PediatricsCalculatorTable=Q1;
|
package/dist/index.js
CHANGED