tp-react-elements-dev 1.3.0 → 1.4.1

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/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # Getting Started with Create React App
2
-
3
- This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
-
5
- ## Available Scripts
6
-
7
- In the project directory, you can run:
8
-
9
- ### `npm start`
10
-
11
- Runs the app in the development mode.\
12
- Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
-
14
- The page will reload if you make edits.\
15
- You will also see any lint errors in the console.
16
-
17
- ### `npm test`
18
-
19
- Launches the test runner in the interactive watch mode.\
20
- See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
-
22
- ### `npm run build`
23
-
24
- Builds the app for production to the `build` folder.\
25
- It correctly bundles React in production mode and optimizes the build for the best performance.
26
-
27
- The build is minified and the filenames include the hashes.\
28
- Your app is ready to be deployed!
29
-
30
- See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
-
32
- ### `npm run eject`
33
-
34
- **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
-
36
- If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
-
38
- Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
-
40
- You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
-
42
- ## Learn More
43
-
44
- You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
-
46
- To learn React, check out the [React documentation](https://reactjs.org/).
1
+ # Getting Started with Create React App
2
+
3
+ This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4
+
5
+ ## Available Scripts
6
+
7
+ In the project directory, you can run:
8
+
9
+ ### `npm start`
10
+
11
+ Runs the app in the development mode.\
12
+ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13
+
14
+ The page will reload if you make edits.\
15
+ You will also see any lint errors in the console.
16
+
17
+ ### `npm test`
18
+
19
+ Launches the test runner in the interactive watch mode.\
20
+ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21
+
22
+ ### `npm run build`
23
+
24
+ Builds the app for production to the `build` folder.\
25
+ It correctly bundles React in production mode and optimizes the build for the best performance.
26
+
27
+ The build is minified and the filenames include the hashes.\
28
+ Your app is ready to be deployed!
29
+
30
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31
+
32
+ ### `npm run eject`
33
+
34
+ **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35
+
36
+ If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37
+
38
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39
+
40
+ You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41
+
42
+ ## Learn More
43
+
44
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45
+
46
+ To learn React, check out the [React documentation](https://reactjs.org/).
@@ -2,6 +2,7 @@ export interface SessionTimeOutProps {
2
2
  sessionTime: string;
3
3
  handleSubmitSession: () => void;
4
4
  onSessionExpire: () => void;
5
+ handleSessionCancel: () => void;
5
6
  }
6
- declare const SessionTimeOut: ({ sessionTime, handleSubmitSession, onSessionExpire, }: SessionTimeOutProps) => import("react/jsx-runtime").JSX.Element;
7
+ declare const SessionTimeOut: ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel }: SessionTimeOutProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export default SessionTimeOut;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as RenderForm } from "./components/Form/FormRenderWrapper";
2
2
  export { default as useFormValidatingContext } from "./components/Form/FormConstants";
3
3
  export { default as DeleteField } from "./components/DeleteComponent/DeleteField";
4
+ export { default as SessionTimeoutField } from "./components/SessionTimeOut/SessionTimeOut";
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React$1 from 'react';
2
- import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useRef, useEffect } from 'react';
2
+ import React__default, { forwardRef, useContext, Children, isValidElement, cloneElement, useState, useRef, useEffect, createContext, useMemo, useCallback } from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
4
  import ReactDOM__default from 'react-dom';
5
5
 
@@ -43451,7 +43451,7 @@ var functionPlugin = function functionPlugin() {
43451
43451
  };
43452
43452
  };
43453
43453
 
43454
- var at = '@global';
43454
+ var at$1 = '@global';
43455
43455
  var atPrefix = '@global ';
43456
43456
 
43457
43457
  var GlobalContainerRule =
@@ -43459,7 +43459,7 @@ var GlobalContainerRule =
43459
43459
  function () {
43460
43460
  function GlobalContainerRule(key, styles, options) {
43461
43461
  this.type = 'global';
43462
- this.at = at;
43462
+ this.at = at$1;
43463
43463
  this.isProcessed = false;
43464
43464
  this.key = key;
43465
43465
  this.options = options;
@@ -43528,7 +43528,7 @@ var GlobalPrefixedRule =
43528
43528
  function () {
43529
43529
  function GlobalPrefixedRule(key, style, options) {
43530
43530
  this.type = 'global';
43531
- this.at = at;
43531
+ this.at = at$1;
43532
43532
  this.isProcessed = false;
43533
43533
  this.key = key;
43534
43534
  this.options = options;
@@ -43564,7 +43564,7 @@ function addScope(selector, scope) {
43564
43564
  function handleNestedGlobalContainerRule(rule, sheet) {
43565
43565
  var options = rule.options,
43566
43566
  style = rule.style;
43567
- var rules = style ? style[at] : null;
43567
+ var rules = style ? style[at$1] : null;
43568
43568
  if (!rules) return;
43569
43569
 
43570
43570
  for (var name in rules) {
@@ -43573,7 +43573,7 @@ function handleNestedGlobalContainerRule(rule, sheet) {
43573
43573
  }));
43574
43574
  }
43575
43575
 
43576
- delete style[at];
43576
+ delete style[at$1];
43577
43577
  }
43578
43578
 
43579
43579
  function handlePrefixedGlobalRule(rule, sheet) {
@@ -43581,8 +43581,8 @@ function handlePrefixedGlobalRule(rule, sheet) {
43581
43581
  style = rule.style;
43582
43582
 
43583
43583
  for (var prop in style) {
43584
- if (prop[0] !== '@' || prop.substr(0, at.length) !== at) continue;
43585
- var selector = addScope(prop.substr(at.length), rule.selector);
43584
+ if (prop[0] !== '@' || prop.substr(0, at$1.length) !== at$1) continue;
43585
+ var selector = addScope(prop.substr(at$1.length), rule.selector);
43586
43586
  sheet.addRule(selector, style[prop], _extends$1({}, options, {
43587
43587
  selector: selector
43588
43588
  }));
@@ -43598,7 +43598,7 @@ function jssGlobal() {
43598
43598
  function onCreateRule(name, styles, options) {
43599
43599
  if (!name) return null;
43600
43600
 
43601
- if (name === at) {
43601
+ if (name === at$1) {
43602
43602
  return new GlobalContainerRule(name, styles, options);
43603
43603
  }
43604
43604
 
@@ -53657,5 +53657,64 @@ const DeleteField = ({ onClickFn, tooltip = "Delete", text }) => {
53657
53657
  }, text: text })] }));
53658
53658
  };
53659
53659
 
53660
- export { DeleteField, FormRenderWrapper as RenderForm, useFormValidatingContext };
53660
+ var Et=Object.create;var Ye=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var Lt=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Pt=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of gt(e))!wt.call(n,o)&&o!==r&&Ye(n,o,{get:()=>e[o],enumerable:!(i=bt(e,o))||i.enumerable});return n};var St=(n,e,r)=>(r=n!=null?Et(yt(n)):{},Pt(!n||!n.__esModule?Ye(r,"default",{value:n,enumerable:!0}):r,n));var je=Lt((he,Je)=>{(function(n,e){typeof he=="object"&&typeof Je<"u"?e(he):typeof define=="function"&&define.amd?define(["exports"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.fastUniqueNumbers={}));})(he,function(n){var e=function(l){return function(p){var f=l(p);return p.add(f),f}},r=function(l){return function(p,f){return l.set(p,f),f}},i=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,u=o*2,g=function(l,p){return function(f){var B=p.get(f),y=B===void 0?f.size:B<u?B+1:0;if(!f.has(y))return l(f,y);if(f.size<o){for(;f.has(y);)y=Math.floor(Math.random()*u);return l(f,y)}if(f.size>i)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;f.has(y);)y=Math.floor(Math.random()*i);return l(f,y)}},O=new WeakMap,W=r(O),m=g(W,O),a=e(m);n.addUniqueNumber=a,n.generateUniqueNumber=m;});});St(je());var M=(typeof window>"u"?"undefined":typeof window)=="object";var I={setTimeout:M?setTimeout.bind(window):setTimeout,clearTimeout:M?clearTimeout.bind(window):clearTimeout,setInterval:M?setInterval.bind(window):setInterval,clearInterval:M?clearInterval.bind(window):clearInterval};function it(n){I.setTimeout=n.setTimeout,I.clearTimeout=n.clearTimeout,I.setInterval=n.setInterval,I.clearInterval=n.clearInterval;}var Q={},Ae=class{name;closed=!1;mc=new MessageChannel;constructor(e){this.name=e,Q[e]=Q[e]||[],Q[e].push(this),this.mc.port1.start(),this.mc.port2.start(),this.onStorage=this.onStorage.bind(this),window.addEventListener("storage",this.onStorage);}onStorage(e){if(e.storageArea!==window.localStorage||e.key.substring(0,this.name.length)!==this.name||e.newValue===null)return;let r=JSON.parse(e.newValue);this.mc.port2.postMessage(r);}postMessage(e){if(this.closed)throw new Error("InvalidStateError");let r=JSON.stringify(e),i=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(i,r),I.setTimeout(()=>{window.localStorage.removeItem(i);},500),Q[this.name].forEach(o=>{o!==this&&o.mc.port2.postMessage(JSON.parse(r));});}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=Q[this.name].indexOf(this);Q[this.name].splice(e,1);}get onmessage(){return this.mc.port1.onmessage}set onmessage(e){this.mc.port1.onmessage=e;}get onmessageerror(){return this.mc.port1.onmessageerror}set onmessageerror(e){this.mc.port1.onmessageerror=e;}addEventListener(e,r){return this.mc.port1.addEventListener(e,r)}removeEventListener(e,r){return this.mc.port1.removeEventListener(e,r)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},st=typeof window>"u"?void 0:typeof window.BroadcastChannel=="function"?window.BroadcastChannel:Ae;function ot(n=0){return new Promise(e=>I.setTimeout(e,n))}function Te(){return Math.random().toString(36).substring(2)}var Ie=class{options;channel;token=Te();isLeader=!1;isDead=!1;isApplying=!1;reApply=!1;intervals=[];listeners=[];deferred;constructor(e,r){this.channel=e,this.options=r,this.apply=this.apply.bind(this),this.awaitLeadership=this.awaitLeadership.bind(this),this.sendAction=this.sendAction.bind(this);}async apply(){if(this.isLeader||this.isDead)return !1;if(this.isApplying)return this.reApply=!0,!1;this.isApplying=!0;let e=!1,r=i=>{let{token:o,action:u}=i.data;o!==this.token&&(u===0&&o>this.token&&(e=!0),u===1&&(e=!0));};this.channel.addEventListener("message",r);try{return this.sendAction(0),await ot(this.options.responseTime),this.channel.removeEventListener("message",r),this.isApplying=!1,e?this.reApply?this.apply():!1:(this.assumeLead(),!0)}catch{return !1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,r=null;return new Promise(i=>{let o=()=>{if(e)return;e=!0;try{I.clearInterval(r);}catch{}let g=this.intervals.indexOf(r);g>=0&&this.intervals.splice(g,1),this.channel.removeEventListener("message",u),i();};r=I.setInterval(()=>{this.apply().then(()=>{this.isLeader&&o();});},this.options.fallbackInterval),this.intervals.push(r);let u=g=>{let{action:O}=g.data;O===2&&this.apply().then(()=>{this.isLeader&&o();});};this.channel.addEventListener("message",u);})}sendAction(e){this.channel.postMessage({action:e,token:this.token});}assumeLead(){this.isLeader=!0;let e=r=>{let{action:i}=r.data;i===0&&this.sendAction(1);};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(1)}waitForLeadership(){return this.deferred?this.deferred:(this.deferred=this.awaitLeadership(),this.deferred)}close(){if(!this.isDead){this.isDead=!0,this.isLeader=!1,this.sendAction(2);try{this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>I.clearInterval(e));}catch{}}}};var Ee=class{channel;options;elector;token=Te();registry=new Map;allIdle=!1;isLastActive=!1;constructor(e){let{channelName:r}=e;if(this.options=e,this.channel=new st(r),this.registry.set(this.token,1),e.leaderElection){let i={fallbackInterval:2e3,responseTime:100};this.elector=new Ie(this.channel,i),this.elector.waitForLeadership();}this.channel.addEventListener("message",i=>{let{action:o,token:u,data:g}=i.data;switch(o){case 3:this.registry.set(u,2);break;case 4:this.registry.delete(u);break;case 5:this.idle(u);break;case 6:this.active(u);break;case 7:this.prompt(u);break;case 8:this.start(u);break;case 9:this.reset(u);break;case 10:this.activate(u);break;case 11:this.pause(u);break;case 12:this.resume(u);break;case 13:this.options.onMessage(g);break}}),this.send(3);}get isLeader(){if(!this.elector)throw new Error('\u274C Leader election is not enabled. To Enable it set the "leaderElection" property to true.');return this.elector.isLeader}prompt(e=this.token){this.registry.set(e,0);let r=[...this.registry.values()].every(i=>i===0);e===this.token&&this.send(7),r&&this.options.onPrompt();}idle(e=this.token){this.registry.set(e,2);let r=[...this.registry.values()].every(i=>i===2);e===this.token&&this.send(5),!this.allIdle&&r&&(this.allIdle=!0,this.options.onIdle());}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let r=[...this.registry.values()].some(i=>i===1);e===this.token&&this.send(6),r&&this.options.onActive(),this.isLastActive=e===this.token;}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(8):this.options.start(!0),this.isLastActive=e===this.token;}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(9):this.options.reset(!0),this.isLastActive=e===this.token;}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(10):this.options.activate(!0),this.isLastActive=e===this.token;}pause(e=this.token){e===this.token?this.send(11):this.options.pause(!0);}resume(e=this.token){e===this.token?this.send(12):this.options.resume(!0);}message(e){try{this.channel.postMessage({action:13,token:this.token,data:e});}catch{}}send(e){try{this.channel.postMessage({action:e,token:this.token});}catch{}}close(){this.options.leaderElection&&this.elector.close(),this.send(4),this.channel.close();}};var at=M?document:null,xe=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange","focus"];function ct(n,e){let r;function i(...o){r&&clearTimeout(r),r=setTimeout(()=>{n(...o),r=null;},e);}return i.cancel=function(){clearTimeout(r);},i}function be(n,e){let r=0;return function(...i){let o=new Date().getTime();if(!(o-r<e))return r=o,n(...i)}}var v=()=>Date.now();var Z=2147483647;function se({timeout:n=1e3*60*20,promptTimeout:e=0,promptBeforeIdle:r=0,element:i=at,events:o=xe,timers:u=void 0,immediateEvents:g=[],onPresenceChange:O=()=>{},onPrompt:W=()=>{},onIdle:m=()=>{},onActive:a=()=>{},onAction:d=()=>{},onMessage:l=()=>{},debounce:p=0,throttle:f=0,eventsThrottle:B=200,startOnMount:y=!0,startManually:D=!1,stopOnIdle:ce=!1,crossTab:j=!1,name:Oe="idle-timer",syncTimers:ee=0,leaderElection:Ce=!1,disabled:C=!1}={}){let De=useRef(v()),ue=useRef(v()),w=useRef(null),R=useRef(null),F=useRef(0),te=useRef(0),N=useRef(0),S=useRef(0),h=useRef(!1),E=useRef(!1),H=useRef(!1),_=useRef(!0),re=useRef(!1),U=useRef(null),s=useRef(null),k=useRef(n),G=useRef(0);useEffect(()=>{if(e&&console.warn("\u26A0\uFE0F IdleTimer -- The `promptTimeout` property has been deprecated in favor of `promptBeforeIdle`. It will be removed in the next major release."),r&&e)throw new Error("\u274C Both promptTimeout and promptBeforeIdle can not be set. The promptTimeout property will be deprecated in a future version.");if(n>=Z)throw new Error(`\u274C The value for the timeout property must fit in a 32 bit signed integer, ${Z}.`);if(e>=Z)throw new Error(`\u274C The value for the promptTimeout property must fit in a 32 bit signed integer, ${Z}.`);if(r>=Z)throw new Error(`\u274C The value for the promptBeforeIdle property must fit in a 32 bit signed integer, ${Z}.`);if(r>=n)throw new Error(`\u274C The value for the promptBeforeIdle property must be less than the timeout property, ${n}.`);if(r?(k.current=n-r,G.current=r):(k.current=n,G.current=e),!_.current){if(D||C)return;h.current&&(X.current(null,L),s.current&&s.current.active()),J();}},[n,e,r,D,C]);let Ne=useRef(ce);useEffect(()=>{Ne.current=ce;},[ce]);let He=useRef(g),ne=useRef(i),ye=useRef([...new Set([...o,...g]).values()]),A=useRef(C);useEffect(()=>{A.current=C,!_.current&&(C?fe():D||J());},[C]);let ie=useRef(O);useEffect(()=>{ie.current=O;},[O]);let le=useRef(W);useEffect(()=>{le.current=W;},[W]);let me=useRef(m);useEffect(()=>{me.current=m;},[m]);let X=useRef(a);useEffect(()=>{X.current=a;},[a]);let de=useRef(d);useEffect(()=>{de.current=d;},[d]);let z=useRef(l);useEffect(()=>{z.current=l;},[l]);let q=useMemo(()=>{let t=(P,K)=>de.current(P,K);return p>0?ct(t,p):f>0?be(t,f):t},[f,p]),_e=useRef();useEffect(()=>{j&&ee&&(_e.current=be(()=>{s.current.active();},ee));},[j,ee]);let x=()=>{U.current!==null&&(I.clearTimeout(U.current),U.current=null);},$=(t,P=!0)=>{x(),U.current=I.setTimeout(Le,t||k.current),P&&(R.current=v());},Ue=t=>{!E.current&&!h.current&&(le.current(t,L),ie.current({type:"active",prompted:!0},L)),S.current=0,N.current=v(),E.current=!0,$(G.current,!1);},Fe=()=>{x(),h.current||(me.current(null,L),ie.current({type:"idle"},L)),h.current=!0,w.current=v(),Ne.current?Y():E.current&&(N.current=0,E.current=!1);},we=t=>{x(),(h.current||E.current)&&(X.current(t,L),ie.current({type:"active",prompted:!1},L)),E.current=!1,N.current=0,h.current=!1,F.current+=v()-w.current,te.current+=v()-w.current,V(),$();},Le=t=>{if(!h.current){q.cancel&&q.cancel();let K=v()-R.current;if(!(k.current+G.current<K)&&G.current>0&&!E.current){s.current?s.current.prompt():Ue(t);return}s.current?s.current.idle():Fe();return}s.current?s.current.active():we(t);},Pe=t=>{if(!y&&!R.current&&(R.current=v(),X.current(null,L)),q(t,L),E.current)return;if(x(),!h.current&&He.current.includes(t.type)){Le(t);return}let P=v()-R.current;if(h.current&&!ce||!h.current&&P>=k.current){Le(t);return}H.current=!1,S.current=0,N.current=0,$(),j&&ee&&_e.current();},pe=useRef(Pe);useEffect(()=>{let t=re.current;t&&Y(),B>0?pe.current=be(Pe,B):pe.current=Pe,t&&V();},[B,f,p,de,j,ee]);let V=()=>{M&&ne.current&&(re.current||(ye.current.forEach(t=>{ne.current.addEventListener(t,pe.current,{capture:!0,passive:!0});}),re.current=!0));},Y=(t=!1)=>{M&&ne.current&&(re.current||t)&&(ye.current.forEach(P=>{ne.current.removeEventListener(P,pe.current,{capture:!0});}),re.current=!1);},J=useCallback(t=>A.current?!1:(x(),V(),h.current=!1,E.current=!1,H.current=!1,S.current=0,N.current=0,s.current&&!t&&s.current.start(),$(),!0),[U,h,A,k,s]),Se=useCallback(t=>A.current?!1:(x(),V(),ue.current=v(),F.current+=v()-w.current,te.current+=v()-w.current,F.current=0,h.current=!1,E.current=!1,H.current=!1,S.current=0,N.current=0,s.current&&!t&&s.current.reset(),D||$(),!0),[U,h,k,D,A,s]),Ve=useCallback(t=>A.current?!1:(x(),V(),(h.current||E.current)&&we(),h.current=!1,E.current=!1,H.current=!1,S.current=0,N.current=0,ue.current=v(),s.current&&!t&&s.current.activate(),$(),!0),[U,h,E,A,k,s]),fe=useCallback((t=!1)=>A.current||H.current?!1:(S.current=We(),H.current=!0,Y(),x(),s.current&&!t&&s.current.pause(),!0),[U,A,s]),Me=useCallback((t=!1)=>A.current||!H.current?!1:(H.current=!1,E.current||V(),h.current||$(S.current),N.current&&(N.current=v()),s.current&&!t&&s.current.resume(),!0),[U,k,A,S,s]),ut=useCallback((t,P)=>(s.current?(P&&z.current(t,L),s.current.message(t)):P&&z.current(t,L),!0),[l]),lt=useCallback(()=>h.current,[h]),mt=useCallback(()=>E.current,[E]),dt=useCallback(()=>s.current?s.current.isLeader:null,[s]),pt=useCallback(()=>s.current?s.current.isLastActive:null,[s]),ft=useCallback(()=>s.current?s.current.token:null,[s]),We=useCallback(()=>{if(H.current)return S.current;let t=S.current?S.current:G.current+k.current,P=R.current?v()-R.current:0,K=Math.floor(t-P);return K<0?0:Math.abs(K)},[k,G,E,S,R]),Be=useCallback(()=>Math.round(v()-ue.current),[ue]),Ge=useCallback(()=>Math.round(v()-De.current),[De]),ht=useCallback(()=>w.current?new Date(w.current):null,[w]),vt=useCallback(()=>R.current?new Date(R.current):null,[R]),qe=useCallback(()=>h.current?Math.round(v()-w.current+F.current):Math.round(F.current),[w,F]),$e=useCallback(()=>h.current?Math.round(v()-w.current+te.current):Math.round(te.current),[w,te]),Tt=useCallback(()=>{let t=Math.round(Be()-qe());return t>=0?t:0},[w,F]),It=useCallback(()=>{let t=Math.round(Ge()-$e());return t>=0?t:0},[w,F]);useEffect(()=>{if(p>0&&f>0)throw new Error("\u274C onAction can either be throttled or debounced, not both.");u&&it(u);let t=()=>{s.current&&s.current.close(),q.cancel&&q.cancel(),x(),Y(!0);};return M&&window.addEventListener("beforeunload",t),()=>{M&&window.removeEventListener("beforeunload",t),s.current&&s.current.close(),q.cancel&&q.cancel(),x(),Y(!0);}},[]),useEffect(()=>{s.current&&s.current.close(),j?s.current=new Ee({channelName:Oe,leaderElection:Ce,onPrompt:()=>{Ue();},onIdle:()=>{Fe();},onActive:()=>{we();},onMessage:t=>{z.current(t,L);},start:J,reset:Se,activate:Ve,pause:fe,resume:Me}):s.current=null;},[j,Oe,Ce,le,me,X,z,J,Se,fe,Me]),useEffect(()=>{_.current||(x(),Y(!0)),!(D||C)&&(y?J():V());},[D,y,C,_]),useEffect(()=>{if(!_.current){let t=[...new Set([...o,...g]).values()];if(Y(),ye.current=t,ne.current=i,He.current=g,D||C)return;y?J():V();}},[i,JSON.stringify(o),JSON.stringify(g),_,C,D,y]),useEffect(()=>{_.current&&(_.current=!1);},[_]);let L={message:ut,start:J,reset:Se,activate:Ve,pause:fe,resume:Me,isIdle:lt,isPrompted:mt,isLeader:dt,isLastActiveTab:pt,getTabId:ft,getRemainingTime:We,getElapsedTime:Be,getTotalElapsedTime:Ge,getLastIdleTime:ht,getLastActiveTime:vt,getIdleTime:qe,getTotalIdleTime:$e,getActiveTime:Tt,getTotalActiveTime:It,setOnPresenceChange:t=>{O=t,ie.current=t;},setOnPrompt:t=>{W=t,le.current=t;},setOnIdle:t=>{m=t,me.current=t;},setOnActive:t=>{a=t,X.current=t;},setOnAction:t=>{d=t,de.current=t;},setOnMessage:t=>{l=t,z.current=t;}};return L}var ge=createContext(null);ge.Consumer;
53661
+
53662
+ const secondsToMMSS = (totalSeconds) => {
53663
+ const minutes = Math.floor(totalSeconds / 60);
53664
+ const seconds = Math.floor(totalSeconds % 60);
53665
+ const formattedMinutes = String(minutes).padStart(2, "0");
53666
+ const formattedSeconds = String(seconds).padStart(2, "0");
53667
+ return `${formattedMinutes}:${formattedSeconds}`;
53668
+ };
53669
+ const promptBeforeValue = 120000;
53670
+ const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel }) => {
53671
+ const [openConfirmModal, setOpenConfirmModal] = useState(false);
53672
+ const expiryDetails = sessionTime;
53673
+ const providedTimestamp = new Date(expiryDetails).getTime();
53674
+ const currentTimestamp = new Date().getTime();
53675
+ const remainingTime = providedTimestamp - currentTimestamp;
53676
+ const timeout = remainingTime;
53677
+ const promptBeforeIdle = Math.min(promptBeforeValue, timeout - 1000);
53678
+ const [remainingTimeInSeconds, setRemainingTimeInSeconds] = useState(Math.ceil(timeout / 1000));
53679
+ const [formattedRemainingTime, setFormattedRemainingTime] = useState(secondsToMMSS(Math.ceil(timeout / 1000)));
53680
+ const onIdle = () => {
53681
+ if (sessionTime) {
53682
+ onSessionExpire();
53683
+ }
53684
+ };
53685
+ const handleSubmit = () => {
53686
+ handleSubmitSession();
53687
+ handleCancel();
53688
+ };
53689
+ const handleCancel = () => {
53690
+ handleSessionCancel();
53691
+ setOpenConfirmModal(false);
53692
+ };
53693
+ const onPrompt = () => {
53694
+ setOpenConfirmModal(true);
53695
+ };
53696
+ const { getRemainingTime, activate } = se({
53697
+ onIdle,
53698
+ onPrompt,
53699
+ promptBeforeIdle,
53700
+ timeout,
53701
+ throttle: 1000, // Adjust throttle to reduce delays
53702
+ });
53703
+ useEffect(() => {
53704
+ const interval = setInterval(() => {
53705
+ const remainingSeconds = Math.ceil(getRemainingTime() / 1000);
53706
+ setRemainingTimeInSeconds(promptBeforeIdle !== promptBeforeValue ? remainingSeconds : 0);
53707
+ const formattedTime = secondsToMMSS(remainingSeconds);
53708
+ setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "00:00");
53709
+ }, 1000); // Adjust interval to 1000 ms
53710
+ return () => {
53711
+ clearInterval(interval);
53712
+ };
53713
+ }, [promptBeforeIdle, getRemainingTime]);
53714
+ const sessionMessage = `Your session will expire in ${formattedRemainingTime} seconds. Do you want to extend the session?`;
53715
+ console.log(promptBeforeIdle, 'promptBeforeIdle');
53716
+ return (jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: jsxRuntimeExports.jsx(ConfirmationDialog, { openConfirmDialog: openConfirmModal, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: sessionMessage }) }));
53717
+ };
53718
+
53719
+ export { DeleteField, FormRenderWrapper as RenderForm, SessionTimeOut as SessionTimeoutField, useFormValidatingContext };
53661
53720
  //# sourceMappingURL=index.esm.js.map