hplx-feature-library 1.0.13 → 1.0.15
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/components/PediatricsCalculatorTable.d.ts +4 -4
- package/dist/PediatricsCalculator/components/PediatricsCalculatorTableContext.d.ts +2 -2
- package/dist/PediatricsCalculator/index.js +1 -1
- package/dist/{PediatricsCalculatorTable-Iwsy2iBg.js → PediatricsCalculatorTable-Dw1Jfx0N.js} +9 -10
- package/dist/{PediatricsCalculatorTable-DOjZ2cML.cjs → PediatricsCalculatorTable-UMuvuTbQ.cjs} +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -6,11 +6,11 @@ interface PediatricsCalculatorTableProps {
|
|
|
6
6
|
externallyTriggeredEditMode?: boolean;
|
|
7
7
|
getMedicineOptions?: (searchTerm: string) => Promise<I_Medicine[]>;
|
|
8
8
|
onRowChange?: (updatedRow: IMedicineViewData) => void;
|
|
9
|
-
onRowDelete?: (rowId: string) =>
|
|
10
|
-
onRowCopy?: (clickedRow: IMedicineViewData, selectedMedicines: I_Medicine[]) =>
|
|
9
|
+
onRowDelete?: (rowId: string) => Promise<boolean>;
|
|
10
|
+
onRowCopy?: (clickedRow: IMedicineViewData, selectedMedicines: I_Medicine[]) => Promise<boolean>;
|
|
11
11
|
onPrescriptionAction?: (rowId: string, action: string) => void;
|
|
12
|
-
onSaveRow?: (row: IMedicineViewData[]) => Promise<
|
|
13
|
-
externalSaveTrigger?: boolean
|
|
12
|
+
onSaveRow?: (row: IMedicineViewData[]) => Promise<boolean>;
|
|
13
|
+
externalSaveTrigger?: () => Promise<boolean>;
|
|
14
14
|
setSearchDisabled?: (disabled: boolean) => void;
|
|
15
15
|
}
|
|
16
16
|
declare const PediatricsCalculatorTable: ({ data, variant, externallyTriggeredEditRowIds, externallyTriggeredEditMode, getMedicineOptions, onRowChange, onRowDelete, onRowCopy, onPrescriptionAction, onSaveRow, externalSaveTrigger, setSearchDisabled, }: PediatricsCalculatorTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,8 +5,8 @@ export interface IPediatricsCalculatorTableContext {
|
|
|
5
5
|
externallyTriggeredEditRowIds?: string[];
|
|
6
6
|
getMedicineOptions?: (searchTerm: string) => Promise<I_Medicine[]>;
|
|
7
7
|
onRowChange?: (updatedRow: IMedicineViewData) => void;
|
|
8
|
-
onRowDelete?: (rowId: string) =>
|
|
9
|
-
onRowCopy?: (clickedRow: IMedicineViewData, selectedMedicines: I_Medicine[]) =>
|
|
8
|
+
onRowDelete?: (rowId: string) => Promise<boolean>;
|
|
9
|
+
onRowCopy?: (clickedRow: IMedicineViewData, selectedMedicines: I_Medicine[]) => Promise<boolean>;
|
|
10
10
|
onPrescriptionAction?: (rowId: string, action: string) => void;
|
|
11
11
|
setRowToDelete?: (id: string | null) => void;
|
|
12
12
|
openPopupForRow?: (row: IMedicineViewData) => void;
|
package/dist/{PediatricsCalculatorTable-Iwsy2iBg.js → PediatricsCalculatorTable-Dw1Jfx0N.js}
RENAMED
|
@@ -11175,10 +11175,8 @@ const dy = /* @__PURE__ */ gh(aj), oj = (t) => {
|
|
|
11175
11175
|
}
|
|
11176
11176
|
}, [u, j, f]);
|
|
11177
11177
|
en(() => {
|
|
11178
|
-
c &&
|
|
11179
|
-
|
|
11180
|
-
});
|
|
11181
|
-
}, [c, v, f]);
|
|
11178
|
+
c && (async () => await c() && await v())();
|
|
11179
|
+
}, [c, v]);
|
|
11182
11180
|
const Y = {
|
|
11183
11181
|
variant: r,
|
|
11184
11182
|
externallyTriggeredEditMode: e,
|
|
@@ -11197,7 +11195,10 @@ const dy = /* @__PURE__ */ gh(aj), oj = (t) => {
|
|
|
11197
11195
|
}, X = async () => {
|
|
11198
11196
|
if (d)
|
|
11199
11197
|
try {
|
|
11200
|
-
s?.(d)
|
|
11198
|
+
if (!await s?.(d)) {
|
|
11199
|
+
console.error("Row deletion failed");
|
|
11200
|
+
return;
|
|
11201
|
+
}
|
|
11201
11202
|
} catch (_) {
|
|
11202
11203
|
console.error("Delete failed", _);
|
|
11203
11204
|
} finally {
|
|
@@ -11207,7 +11208,7 @@ const dy = /* @__PURE__ */ gh(aj), oj = (t) => {
|
|
|
11207
11208
|
p(null);
|
|
11208
11209
|
}, F = Kr(
|
|
11209
11210
|
async (_) => {
|
|
11210
|
-
await u?.([_])
|
|
11211
|
+
await u?.([_]) ? g(_.rowId, !1) : console.error("Row save failed");
|
|
11211
11212
|
},
|
|
11212
11213
|
[u, g]
|
|
11213
11214
|
);
|
|
@@ -11245,13 +11246,11 @@ const dy = /* @__PURE__ */ gh(aj), oj = (t) => {
|
|
|
11245
11246
|
{
|
|
11246
11247
|
open: h,
|
|
11247
11248
|
onCancel: () => m(!1),
|
|
11248
|
-
onSave: (_, T) => {
|
|
11249
|
+
onSave: async (_, T) => {
|
|
11249
11250
|
try {
|
|
11250
|
-
i?.(_, T);
|
|
11251
|
+
await i?.(_, T) && m(!1);
|
|
11251
11252
|
} catch (C) {
|
|
11252
11253
|
console.error("Error copying medicines:", C);
|
|
11253
|
-
} finally {
|
|
11254
|
-
m(!1);
|
|
11255
11254
|
}
|
|
11256
11255
|
},
|
|
11257
11256
|
rowMedicineData: b,
|
package/dist/{PediatricsCalculatorTable-DOjZ2cML.cjs → PediatricsCalculatorTable-UMuvuTbQ.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=Sy(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 _=1;_<arguments.length;_++){var T=arguments[_];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(F[C]=T[C])}return F},r=function(){function F(_,T){for(var C=0;C<T.length;C++){var D=T[C];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}return function(_,T,C){return T&&F(_.prototype,T),C&&F(_,C),_}}(),a=le,e=b(a),n=Oa,o=b(n),s=Gl(),i=b(s),l=Y1(),u=b(l),c=ty(),f=m(c),d=Gu(),p=b(d),h=B1;function m(F){if(F&&F.__esModule)return F;var _={};if(F!=null)for(var T in F)Object.prototype.hasOwnProperty.call(F,T)&&(_[T]=F[T]);return _.default=F,_}function b(F){return F&&F.__esModule?F:{default:F}}function M(F,_){if(!(F instanceof _))throw new TypeError("Cannot call a class as a function")}function j(F,_){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:F}function S(F,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);F.prototype=Object.create(_&&_.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(F,_):F.__proto__=_)}var k=br.portalClassName="ReactModalPortal",g=br.bodyOpenClassName="ReactModal__Body--open",v=d.canUseDOM&&o.default.createPortal!==void 0,E=function(_){return document.createElement(_)},Y=function(){return v?o.default.createPortal:o.default.unstable_renderSubtreeIntoContainer};function X(F){return F()}var Q=function(F){S(_,F);function _(){var T,C,D,H;M(this,_);for(var O=arguments.length,K=Array(O),ee=0;ee<O;ee++)K[ee]=arguments[ee];return H=(C=(D=j(this,(T=_.__proto__||Object.getPrototypeOf(_)).call.apply(T,[this].concat(K))),D),D.removePortal=function(){!v&&o.default.unmountComponentAtNode(D.node);var N=X(D.props.parentSelector);N&&N.contains(D.node)?N.removeChild(D.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.')},D.portalRef=function(N){D.portal=N},D.renderPortal=function(N){var B=Y(),J=B(D,e.default.createElement(u.default,t({defaultStyles:_.defaultStyles},N)),D.node);D.portalRef(J)},C),j(D,H)}return r(_,[{key:"componentDidMount",value:function(){if(d.canUseDOM){v||(this.node=E("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 D=X(C.parentSelector),H=X(this.props.parentSelector);return{prevParent:D,nextParent:H}}},{key:"componentDidUpdate",value:function(C,D,H){if(d.canUseDOM){var O=this.props,K=O.isOpen,ee=O.portalClassName;C.portalClassName!==ee&&(this.node.className=ee);var N=H.prevParent,B=H.nextParent;B!==N&&(N.removeChild(this.node),B.appendChild(this.node)),!(!C.isOpen&&!K)&&!v&&this.renderPortal(this.props)}}},{key:"componentWillUnmount",value:function(){if(!(!d.canUseDOM||!this.node||!this.portal)){var C=this.portal.state,D=Date.now(),H=C.isOpen&&this.props.closeTimeoutMS&&(C.closesAt||D+this.props.closeTimeoutMS);H?(C.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal,H-D)):this.removePortal()}}},{key:"render",value:function(){if(!d.canUseDOM||!v)return null;!this.node&&v&&(this.node=E("div"));var C=Y();return C(e.default.createElement(u.default,t({ref:this.portalRef,defaultStyles:_.defaultStyles},this.props)),this.node)}}],[{key:"setAppElement",value:function(C){f.setElement(C)}}]),_}(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:g,role:"dialog",ariaHideApp:!0,closeTimeoutMS:0,shouldFocusAfterRender:!0,shouldCloseOnEsc:!0,shouldCloseOnOverlayClick:!0,shouldReturnFocusAfterClose:!0,preventScroll:!1,parentSelector:function(){return document.body},overlayElement:function(_,T){return e.default.createElement("div",_,T)},contentElement:function(_,T){return e.default.createElement("div",_,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 E=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),V1=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 U.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"&&U.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:U.jsx("i",{className:"hx_warning hfl-text-5"})}),U.jsx(Ye,{variant:"Medium",type:"Text xl",className:"hfl-mt-5 hfl-text-Gray-900",children:n}),o&&U.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-mt-1 hfl-text-Gray-500 ",children:o}),U.jsxs("div",{className:"hfl-mt-4 hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[i&&U.jsx(da,{size:"md",textField:i,hierarchy:"Primary",className:u||"",onClick:f,"data-qa":"negative-action"}),s&&U.jsx(da,{size:"md",textField:s,hierarchy:"Secondary",className:l||"",onClick:c,"data-qa":"positive-action"})]})]})},K1=({open:t,onCancel:r,onSave:a,rowMedicineData:e,getMedicineOptions:n})=>{const[o,s]=le.useState([]),[i,l]=le.useState(""),[u,c]=le.useState([]),f=p=>{const h=p.value;h&&!o.some(m=>m.medicine_id===h.medicine_id)&&s(m=>[...m,h])},d=p=>{s(h=>h.filter(m=>m.medicine_id!==p))};return le.useEffect(()=>{t&&(async()=>{const m=(await n?.(i))?.map(b=>({label:b.medicine_name,value:b}));c(m||[])})()},[i,n,t]),U.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:[U.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"}),U.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:[U.jsx(it,{inputValue:i,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:l,onChangeHandler:f,options:u,placeholder:"Search for medicines"}),U.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:o.map(p=>U.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:[U.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:p.medicine_name}),U.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>d(p.medicine_id),children:U.jsx("i",{className:"hx_close"})})]},p.medicine_id))})]}),U.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:[U.jsx(da,{size:"md",textField:"Cancel",onClick:r,hierarchy:"Secondary-Grey"}),U.jsx(da,{size:"md",textField:"Save",onClick:()=>a(e,o),className:"hfl-bg-Primary-600 hfl-text-White",hierarchy:"Primary"})]})]})},G1=({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),[b,M]=le.useState(),[j,S]=le.useState({});le.useEffect(()=>{S(_=>{const T={..._};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=(_,T)=>{S(C=>({...C,[_]:{...C[_],formData:{...C[_].formData,...T}}}))},g=le.useCallback((_,T)=>{S(C=>{const D={...C,[_]:{...C[_],isEditing:T}},H=Object.values(D).some(O=>O.isEditing);return f?.(H),D})},[f]),v=le.useCallback(async()=>{const T=Object.entries(j).filter(([,{formData:C,isEditing:D}])=>D&&C.medicine_name).map(([,{formData:C}])=>C);if(T.length!==0)try{await u?.(T),S(C=>{const D={...C};for(const H of T)D[H.rowId]={...D[H.rowId],isEditing:!1};return f?.(!1),D})}catch(C){console.error("Bulk save failed",C)}},[u,j,f]);le.useEffect(()=>{c&&v().finally(()=>{f?.(!1)})},[c,v,f]);const Y={variant:r,externallyTriggeredEditMode:e,externallyTriggeredEditRowIds:a,getMedicineOptions:n,onRowChange:_=>{k(_.rowId,_),o?.(_)},onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,setRowToDelete:p,openPopupForRow:_=>{M(_),m(!0)}},X=async()=>{if(d)try{s?.(d)}catch(_){console.error("Delete failed",_)}finally{p(null)}},Q=()=>{p(null)},F=le.useCallback(async _=>{await u?.([_]),g(_.rowId,!1)},[u,g]);return U.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[U.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(_=>U.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:_},_))}),U.jsxs(Jv.Provider,{value:Y,children:[U.jsx("div",{className:"table-body",children:!t||t.length===0?U.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(_=>U.jsx(R1,{rowData:j[_.rowId]?.formData||_,isEditing:j[_.rowId]?.isEditing||!1,setFormData:T=>k(_.rowId,T),setIsEditing:T=>g(_.rowId,T),onSaveRow:F},_.rowId))}),U.jsx(V1,{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}),U.jsx(K1,{open:h,onCancel:()=>m(!1),onSave:(_,T)=>{try{i?.(_,T)}catch(C){console.error("Error copying medicines:",C)}finally{m(!1)}},rowMedicineData:b,getMedicineOptions:n})]})]})};exports.PediatricsCalculatorTable=G1;
|
|
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=Sy(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 _=1;_<arguments.length;_++){var T=arguments[_];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(F[C]=T[C])}return F},r=function(){function F(_,T){for(var C=0;C<T.length;C++){var D=T[C];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}return function(_,T,C){return T&&F(_.prototype,T),C&&F(_,C),_}}(),a=le,e=b(a),n=Oa,o=b(n),s=Gl(),i=b(s),l=Y1(),u=b(l),c=ty(),f=m(c),d=Gu(),p=b(d),h=B1;function m(F){if(F&&F.__esModule)return F;var _={};if(F!=null)for(var T in F)Object.prototype.hasOwnProperty.call(F,T)&&(_[T]=F[T]);return _.default=F,_}function b(F){return F&&F.__esModule?F:{default:F}}function M(F,_){if(!(F instanceof _))throw new TypeError("Cannot call a class as a function")}function j(F,_){if(!F)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return _&&(typeof _=="object"||typeof _=="function")?_:F}function S(F,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof _);F.prototype=Object.create(_&&_.prototype,{constructor:{value:F,enumerable:!1,writable:!0,configurable:!0}}),_&&(Object.setPrototypeOf?Object.setPrototypeOf(F,_):F.__proto__=_)}var k=br.portalClassName="ReactModalPortal",g=br.bodyOpenClassName="ReactModal__Body--open",v=d.canUseDOM&&o.default.createPortal!==void 0,E=function(_){return document.createElement(_)},Y=function(){return v?o.default.createPortal:o.default.unstable_renderSubtreeIntoContainer};function X(F){return F()}var Q=function(F){S(_,F);function _(){var T,C,D,H;M(this,_);for(var O=arguments.length,K=Array(O),ee=0;ee<O;ee++)K[ee]=arguments[ee];return H=(C=(D=j(this,(T=_.__proto__||Object.getPrototypeOf(_)).call.apply(T,[this].concat(K))),D),D.removePortal=function(){!v&&o.default.unmountComponentAtNode(D.node);var N=X(D.props.parentSelector);N&&N.contains(D.node)?N.removeChild(D.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.')},D.portalRef=function(N){D.portal=N},D.renderPortal=function(N){var B=Y(),J=B(D,e.default.createElement(u.default,t({defaultStyles:_.defaultStyles},N)),D.node);D.portalRef(J)},C),j(D,H)}return r(_,[{key:"componentDidMount",value:function(){if(d.canUseDOM){v||(this.node=E("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 D=X(C.parentSelector),H=X(this.props.parentSelector);return{prevParent:D,nextParent:H}}},{key:"componentDidUpdate",value:function(C,D,H){if(d.canUseDOM){var O=this.props,K=O.isOpen,ee=O.portalClassName;C.portalClassName!==ee&&(this.node.className=ee);var N=H.prevParent,B=H.nextParent;B!==N&&(N.removeChild(this.node),B.appendChild(this.node)),!(!C.isOpen&&!K)&&!v&&this.renderPortal(this.props)}}},{key:"componentWillUnmount",value:function(){if(!(!d.canUseDOM||!this.node||!this.portal)){var C=this.portal.state,D=Date.now(),H=C.isOpen&&this.props.closeTimeoutMS&&(C.closesAt||D+this.props.closeTimeoutMS);H?(C.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal,H-D)):this.removePortal()}}},{key:"render",value:function(){if(!d.canUseDOM||!v)return null;!this.node&&v&&(this.node=E("div"));var C=Y();return C(e.default.createElement(u.default,t({ref:this.portalRef,defaultStyles:_.defaultStyles},this.props)),this.node)}}],[{key:"setAppElement",value:function(C){f.setElement(C)}}]),_}(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:g,role:"dialog",ariaHideApp:!0,closeTimeoutMS:0,shouldFocusAfterRender:!0,shouldCloseOnEsc:!0,shouldCloseOnOverlayClick:!0,shouldReturnFocusAfterClose:!0,preventScroll:!1,parentSelector:function(){return document.body},overlayElement:function(_,T){return e.default.createElement("div",_,T)},contentElement:function(_,T){return e.default.createElement("div",_,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 E=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),V1=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 U.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"&&U.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:U.jsx("i",{className:"hx_warning hfl-text-5"})}),U.jsx(Ye,{variant:"Medium",type:"Text xl",className:"hfl-mt-5 hfl-text-Gray-900",children:n}),o&&U.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-mt-1 hfl-text-Gray-500 ",children:o}),U.jsxs("div",{className:"hfl-mt-4 hfl-flex hfl-items-center hfl-justify-center hfl-gap-4",children:[i&&U.jsx(da,{size:"md",textField:i,hierarchy:"Primary",className:u||"",onClick:f,"data-qa":"negative-action"}),s&&U.jsx(da,{size:"md",textField:s,hierarchy:"Secondary",className:l||"",onClick:c,"data-qa":"positive-action"})]})]})},K1=({open:t,onCancel:r,onSave:a,rowMedicineData:e,getMedicineOptions:n})=>{const[o,s]=le.useState([]),[i,l]=le.useState(""),[u,c]=le.useState([]),f=p=>{const h=p.value;h&&!o.some(m=>m.medicine_id===h.medicine_id)&&s(m=>[...m,h])},d=p=>{s(h=>h.filter(m=>m.medicine_id!==p))};return le.useEffect(()=>{t&&(async()=>{const m=(await n?.(i))?.map(b=>({label:b.medicine_name,value:b}));c(m||[])})()},[i,n,t]),U.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:[U.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"}),U.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:[U.jsx(it,{inputValue:i,showInput:!0,isSearchable:!0,disableInputAutoSize:!0,inputChangeHandler:l,onChangeHandler:f,options:u,placeholder:"Search for medicines"}),U.jsx("div",{className:"hfl-flex hfl-flex-wrap hfl-gap-2",children:o.map(p=>U.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:[U.jsx(Ye,{variant:"Regular",type:"Text sm",className:"hfl-text-nowrap",children:p.medicine_name}),U.jsx("button",{className:"hfl-text-Blue_gray-800",onClick:()=>d(p.medicine_id),children:U.jsx("i",{className:"hx_close"})})]},p.medicine_id))})]}),U.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:[U.jsx(da,{size:"md",textField:"Cancel",onClick:r,hierarchy:"Secondary-Grey"}),U.jsx(da,{size:"md",textField:"Save",onClick:()=>a(e,o),className:"hfl-bg-Primary-600 hfl-text-White",hierarchy:"Primary"})]})]})},G1=({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),[b,M]=le.useState(),[j,S]=le.useState({});le.useEffect(()=>{S(_=>{const T={..._};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=(_,T)=>{S(C=>({...C,[_]:{...C[_],formData:{...C[_].formData,...T}}}))},g=le.useCallback((_,T)=>{S(C=>{const D={...C,[_]:{...C[_],isEditing:T}},H=Object.values(D).some(O=>O.isEditing);return f?.(H),D})},[f]),v=le.useCallback(async()=>{const T=Object.entries(j).filter(([,{formData:C,isEditing:D}])=>D&&C.medicine_name).map(([,{formData:C}])=>C);if(T.length!==0)try{await u?.(T),S(C=>{const D={...C};for(const H of T)D[H.rowId]={...D[H.rowId],isEditing:!1};return f?.(!1),D})}catch(C){console.error("Bulk save failed",C)}},[u,j,f]);le.useEffect(()=>{c&&(async()=>await c()&&await v())()},[c,v]);const Y={variant:r,externallyTriggeredEditMode:e,externallyTriggeredEditRowIds:a,getMedicineOptions:n,onRowChange:_=>{k(_.rowId,_),o?.(_)},onRowDelete:s,onRowCopy:i,onPrescriptionAction:l,setRowToDelete:p,openPopupForRow:_=>{M(_),m(!0)}},X=async()=>{if(d)try{if(!await s?.(d)){console.error("Row deletion failed");return}}catch(_){console.error("Delete failed",_)}finally{p(null)}},Q=()=>{p(null)},F=le.useCallback(async _=>{await u?.([_])?g(_.rowId,!1):console.error("Row save failed")},[u,g]);return U.jsxs("div",{className:"hfl-border-1 hfl-border-Gray-200",children:[U.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(_=>U.jsx(Ye,{variant:"Medium",type:"Text sm",className:"hfl-text-Blue_gray-600",children:_},_))}),U.jsxs(Jv.Provider,{value:Y,children:[U.jsx("div",{className:"table-body",children:!t||t.length===0?U.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(_=>U.jsx(R1,{rowData:j[_.rowId]?.formData||_,isEditing:j[_.rowId]?.isEditing||!1,setFormData:T=>k(_.rowId,T),setIsEditing:T=>g(_.rowId,T),onSaveRow:F},_.rowId))}),U.jsx(V1,{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}),U.jsx(K1,{open:h,onCancel:()=>m(!1),onSave:async(_,T)=>{try{await i?.(_,T)&&m(!1)}catch(C){console.error("Error copying medicines:",C)}},rowMedicineData:b,getMedicineOptions:n})]})]})};exports.PediatricsCalculatorTable=G1;
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isValidFloatInput: (val: string) => boolean;
|