@algoux/standard-ranklist-renderer-component-core 0.6.1 → 0.6.3
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 +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +13 -7
- package/dist/ranklist.d.ts +3 -2
- package/dist/types.d.ts +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npm i -S @algoux/standard-ranklist-renderer-component-core
|
|
|
16
16
|
- `srkSupportedVersions`
|
|
17
17
|
- `StaticRanklist`
|
|
18
18
|
- `UserClickPayload`
|
|
19
|
+
- `ProblemClickPayload`
|
|
19
20
|
- `SolutionClickPayload`
|
|
20
21
|
|
|
21
22
|
## Usage
|
|
@@ -23,4 +24,4 @@ npm i -S @algoux/standard-ranklist-renderer-component-core
|
|
|
23
24
|
```ts
|
|
24
25
|
import { caniuse } from '@algoux/standard-ranklist-renderer-component-core';
|
|
25
26
|
import { convertToStaticRanklist } from '@algoux/standard-ranklist-utils';
|
|
26
|
-
```
|
|
27
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var le=require("color"),c=require("@algoux/standard-ranklist-utils"),ce=require("semver");function z(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var B=z(le),se=z(ce);const U={[c.EnumTheme.light]:"#ffffff",[c.EnumTheme.dark]:"#191919"},ae=["FB","AC","?","NOUT","CE","UKE",null];function ue(e,t,r){if(typeof r=="function")return r(e,t);if(e.startsWith("//"))return e;const o=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(o){const n=o[1].toLowerCase();return n==="http"||n==="https"||n==="data"?e:(console.warn(`unsupported protocol "${n}" in srk asset url:`,e),"")}return console.warn("unsupported srk asset url:",e),""}function de(e,t,r=180){const{backgroundColor:o}=c.resolveStyle(e||{}),n=o[t]||U[t],i=B.default(n).string(),l=B.default(n).alpha(.27).string();return`linear-gradient(${r}deg, ${i} 0%, ${i} 10%, ${l} 10%, transparent 100%)`}function fe(e,t){return typeof e.style=="string"?{className:`srk-preset-marker-${e.style}`}:e.style?{style:{backgroundColor:c.resolveStyle(e.style).backgroundColor[t]}}:{}}function me(e){switch(e){case"FB":return{label:"First Blood",className:"srk-preset-result-fb"};case"AC":return{label:"Accepted",className:"srk-preset-result-ac"};case"RJ":return{label:"Rejected",className:"srk-preset-result-rj"};case"?":return{label:"Frozen",className:"srk-preset-result-fz"};case"WA":return{label:"Wrong Answer",className:"srk-preset-result-rj"};case"PE":return{label:"Presentation Error",className:"srk-preset-result-rj"};case"TLE":return{label:"Time Limit Exceeded",className:"srk-preset-result-rj"};case"MLE":return{label:"Memory Limit Exceeded",className:"srk-preset-result-rj"};case"OLE":return{label:"Output Limit Exceeded",className:"srk-preset-result-rj"};case"RTE":return{label:"Runtime Error",className:"srk-preset-result-rj"};case"NOUT":return{label:"No Output"};case"CE":return{label:"Compile Error"};case"UKE":return{label:"Unknown Error"};case null:return{label:"--"};default:return{label:e}}}function X(e){return`${e.tries}/${e.time?c.formatTimeDuration(e.time,"min",Math.floor):"-"}`}function g(e){return(e==null?void 0:e.result)==="AC"||(e==null?void 0:e.result)==="FB"}function K(e){return(e==null?void 0:e.result)==="RJ"||(e==null?void 0:e.result)==="?"}function v(e){return(e==null?void 0:e.tries)||0}function H(e,t){const r=ke(t),o=e.solutions||[];for(let n=o.length-1;n>=0;n-=1){const i=o[n];if(!r.includes(i.result))return i}}function f(e,t){if(!e)return"-";const r=we(e,t);if(r==="ms"){const n=Math.floor(c.formatTimeDuration(e,"ms")),i=Math.floor(n/1e3);return`${F(i)}.${b(n%1e3,3)}`}if(r==="s")return F(Math.floor(c.formatTimeDuration(e,"s")));const o=Math.floor(c.formatTimeDuration(e,"min"));return`${Math.floor(o/60)}:${b(o%60,2)}`}function ge(e,t,r="classic"){if(!e.result)return{};if(r==="classic"){if(g(e)){const o=X(e);return typeof e.score=="number"?{score:e.score,scoreDetails:o}:{primary:o}}return{primary:typeof e.tries=="number"?String(e.tries):""}}if(g(e)){const o=Math.max((e.tries||0)-1,0);if(r==="detailed")return{primary:f(e.time,t),secondary:o>0?`(-${o})`:""};const n=o>0?`+${o}`:"+";return r==="compact"?{primary:n,secondary:f(e.time,t)}:{primary:n}}if(K(e)){const o=e.tries||0,n=`-${o}`;if(r==="detailed")return{primary:"",secondary:o>0?`(-${o})`:""};if(r==="compact"&&o>0){const i=H(e,t);if(i)return{primary:n,secondary:f(i.time,t)}}return{primary:n}}return{}}function pe(e){const t=e.statuses.reduce((r,o)=>{if(!g(o))return r;const n=v(o);return{wrong:r.wrong+Math.max(n-1,0),submitted:r.submitted+n}},{wrong:0,submitted:0});return!t.submitted||!t.wrong?"0%":`${Math.floor(t.wrong/t.submitted*100)}%`}function ye(e){const t=e.rows.length;return e.problems.map((r,o)=>{const n={participantCount:t,accepted:0,tried:0,submitted:0,dirt:0,dirtSubmitted:0};return e.rows.forEach(i=>{const l=i.statuses[o],u=v(l);u>0&&(n.tried+=1,n.submitted+=u),g(l)&&(n.accepted+=1,n.dirt+=Math.max(u-1,0),n.dirtSubmitted+=u,l.time&&((!n.firstAcceptedTime||N(l.time,n.firstAcceptedTime)<0)&&(n.firstAcceptedTime=l.time),(!n.lastAcceptedTime||N(l.time,n.lastAcceptedTime)>0)&&(n.lastAcceptedTime=l.time)))}),n})}function be(e,t){return!e.firstAcceptedTime||!e.lastAcceptedTime?"-":`${f(e.firstAcceptedTime,t)} / ${f(e.lastAcceptedTime,t)}`}function he(e){return e?String(Math.floor(c.formatTimeDuration(e,"min"))):"-"}function Te(e,t){return t<=0?"(-)":`(${Math.floor(e/t*100)}%)`}function Me(e){const t=V(e);return t===void 0?"-":W(t)}function Se(e,t){const r=e.statuses.reduce((o,n,i)=>{if(!g(n))return o;const l=V(t[i]);return l!==void 0&&o.push(l),o},[]);return r.length?W(r.reduce((o,n)=>o+n,0)/r.length):"0.00"}function Pe(e,t){return`Solutions of ${c.numberToAlphabet(e)} (${c.resolveText(t.name)})`}function Ae(e){return c.secToTimeStr(c.formatTimeDuration(e.time,"s"))}function ve(e){return e.some(t=>{var r;return Boolean((r=t.score)==null?void 0:r.time)})}function we(e,t){const r=t.sorter;return(r==null?void 0:r.algorithm)==="ICPC"&&r.config.timePrecision?r.config.timePrecision:e[1]}function ke(e){const t=e.sorter;return(t==null?void 0:t.algorithm)==="ICPC"&&t.config.noPenaltyResults?t.config.noPenaltyResults:ae}function V(e){if(!(!e||e.participantCount<=0))return(e.participantCount-e.accepted)/e.participantCount}function W(e){return e.toFixed(2)}function N(e,t){return c.formatTimeDuration(e,"ms")-c.formatTimeDuration(t,"ms")}function F(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return`${t}:${b(r,2)}:${b(o,2)}`}function b(e,t){const r=String(Math.trunc(Math.abs(e)));return r.length>=t?r:`${"0".repeat(t-r.length)}${r}`}function J(e){return c.formatTimeDuration(e.duration,"min")}function Re(e,t,r=0){const o=new Date(e.startAt).getTime(),n=t-r;return Math.min(Math.max(Math.floor((n-o)/6e4),0),J(e))}function xe(e,t,r=0){const n=new Date(e.startAt).getTime()+c.formatTimeDuration(e.duration,"ms");return t-r>=n}function Ee(e){const t={};for(let r=0;r<=e;++r)t[r]="";return t}function Ce(e,t,r,o,n){const{contest:i}=e,l=new Date(i.startAt).getTime(),u=l+c.formatTimeDuration(i.duration,"ms"),I=i.frozenDuration?c.formatTimeDuration(i.frozenDuration,"ms"):0,O=t-r,d=u-l,p=d?1-I/d:1,S=Math.min(Math.max(O-l,0),d),ee=d-S,te=u-I,re=d?S/d*100:0,_=d?Math.max(Math.min(O,te)-l,0)/d*100:0,oe=Math.min(100,p?_/p:0),ne=re-_,ie=Math.min(100,1-p?ne/(1-p):0),P=o*60*1e3,$=d-P;return{elapsed:n?P:S,remaining:n?$:ee,frozenBreakpoint:p,normalInnerPercent:oe,frozenInnerPercent:ie,timeTravelElapsed:P,timeTravelRemaining:$,supportRegen:c.canRegenerateRanklist(e)}}const q=">=0.3.0 <=0.3.12";function De(e){return se.default.satisfies(e,q)}const Le=280,Ie="srk-animated-modal-root",M="srk-scrolling-effect";let y=null,a=null,j=!1,m=0,w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,A=1,s=[],Y=!1;function Oe(e){var r,o;if(e.key!=="Escape")return;const t=s[s.length-1];!t||((r=t.onEscape)==null||r.call(t,e),(o=e.stopImmediatePropagation)==null||o.call(e),e.stopPropagation())}function _e(){typeof document=="undefined"||Y||(document.addEventListener("keydown",Oe),Y=!0)}function $e(){typeof document=="undefined"||j||(document.addEventListener("mousedown",e=>{a={x:e.clientX,y:e.clientY}},!0),document.addEventListener("touchstart",e=>{const t=e.touches[0]||e.changedTouches[0];!t||(a={x:t.clientX,y:t.clientY})},{capture:!0,passive:!0}),j=!0)}function Z(e,t,r){y={x:e,y:t,timestamp:Date.now(),source:r==null?void 0:r.source,context:r==null?void 0:r.context}}function Be(e,t){Z(e.clientX,e.clientY,t)}function G(e=500){return!y||Date.now()-y.timestamp>e?null:y}function Ne(){return a}function Fe(e){if(typeof window=="undefined"||!e)return{origin:{x:0,y:0},source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:null,fallbackPoint:{x:0,y:0}};const t=e.getBoundingClientRect(),r={x:t.width/2,y:Math.min(t.height*.22,96)},o=G();return o?{origin:{x:o.x-t.left,y:o.y-t.top},source:"explicit-trigger",explicitTriggerPoint:o,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:a?{origin:{x:a.x-t.left,y:a.y-t.top},source:"global-pointer",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:{origin:r,source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:null,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}}function je(){return typeof document=="undefined"?null:document.activeElement instanceof HTMLElement?document.activeElement:null}function Q(e){try{e.focus({preventScroll:!0})}catch{e.focus()}}function Ye(e,t={}){if(typeof document=="undefined"||!e)return null;_e();const r=s.find(l=>l.dialogElement===e);if(r)return r.onEscape=t.onEscape,r.id;const o=e.hasAttribute("tabindex"),n=e.getAttribute("tabindex");o||e.setAttribute("tabindex","-1");const i={id:A,dialogElement:e,restoreElement:je(),hadTabIndex:o,previousTabIndex:n,onEscape:t.onEscape};return A+=1,s.push(i),Q(e),i.id}function ze(e){var l;if(typeof document=="undefined"||e==null)return;const t=s.findIndex(u=>u.id===e);if(t===-1)return;const[r]=s.splice(t,1);if(r.hadTabIndex?r.previousTabIndex===null?r.dialogElement.removeAttribute("tabindex"):r.dialogElement.setAttribute("tabindex",r.previousTabIndex):r.dialogElement.removeAttribute("tabindex"),!(t===s.length))return;const n=s[s.length-1],i=(l=r.restoreElement)!=null&&l.isConnected?r.restoreElement:n==null?void 0:n.dialogElement;i&&Q(i)}function Ue(e){var t;return e==null?!1:((t=s[s.length-1])==null?void 0:t.id)===e}function Xe(){typeof document!="undefined"&&(m===0&&(h=window.scrollX,T=window.scrollY,w=document.body.style.overflow,k=document.body.style.overflowX,R=document.body.style.overflowY,x=document.body.style.position,E=document.body.style.top,C=document.body.style.left,D=document.body.style.right,L=document.body.style.width,document.body.classList.add(M),document.body.style.overflow="hidden",document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",document.body.style.position="fixed",document.body.style.top=`-${T}px`,document.body.style.left=`-${h}px`,document.body.style.right="0",document.body.style.width="100%"),m+=1)}function Ke(){if(!(typeof document=="undefined"||m===0)&&(m-=1,m===0&&(document.body.classList.remove(M),document.body.style.overflow=w,document.body.style.overflowX=k,document.body.style.overflowY=R,document.body.style.position=x,document.body.style.top=E,document.body.style.left=C,document.body.style.right=D,document.body.style.width=L,!(typeof navigator!="undefined"&&/jsdom/i.test(navigator.userAgent))&&typeof window.scrollTo=="function")))try{window.scrollTo(h,T)}catch{}}function He(){y=null,a=null,m=0,A=1,s=[],w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,typeof document!="undefined"&&(document.body.classList.remove(M),document.body.style.overflow="",document.body.style.overflowX="",document.body.style.overflowY="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="")}Object.defineProperty(exports,"convertToStaticRanklist",{enumerable:!0,get:function(){return c.convertToStaticRanklist}});exports.MODAL_ANIMATION_DURATION_MS=Le;exports.SRK_ANIMATED_MODAL_ROOT_CLASS=Ie;exports.SRK_SCROLL_LOCK_BODY_CLASS=M;exports.buildSliderMarks=Ee;exports.calculateDirtPercentage=pe;exports.calculateProblemStatisticsFooter=ye;exports.calculateSEValue=Se;exports.caniuse=De;exports.captureModalTriggerPointFromMouseEvent=Be;exports.defaultBackgroundColor=U;exports.ensureModalInteractionTracker=$e;exports.formatProblemStatisticsAcceptedMinute=he;exports.formatProblemStatisticsAcceptedRange=be;exports.formatProblemStatisticsAverageHardness=Me;exports.formatProblemStatisticsPercent=Te;exports.formatRanklistStatusTime=f;exports.formatSolutionTimestamp=Ae;exports.getAcceptedStatusDetails=X;exports.getLastModalInteractionPoint=Ne;exports.getLastPenaltySolution=H;exports.getMarkerPresentation=fe;exports.getProblemHeaderBackgroundImage=de;exports.getProgressDurationMinutes=J;exports.getProgressMaxAvailableMinutes=Re;exports.getProgressMetrics=Ce;exports.getRankProblemStatusCellPresentation=ge;exports.getRankProblemStatusTries=v;exports.getRecentModalTriggerPoint=G;exports.getSolutionModalTitle=Pe;exports.getSolutionResultMeta=me;exports.isAcceptedRankProblemStatus=g;exports.isProgressEnded=xe;exports.isRejectedRankProblemStatus=K;exports.isTopModalFocusScope=Ue;exports.lockModalBodyScroll=Xe;exports.registerModalFocusScope=Ye;exports.resetModalInteractionStateForTests=He;exports.resolveModalTransformOrigin=Fe;exports.resolveSrkAssetUrl=ue;exports.setModalTriggerPoint=Z;exports.shouldShowTimeColumn=ve;exports.srkSupportedVersions=q;exports.unlockModalBodyScroll=Ke;exports.unregisterModalFocusScope=ze;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var le=require("color"),s=require("@algoux/standard-ranklist-utils"),se=require("semver");function z(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var N=z(le),ce=z(se);const U={[s.EnumTheme.light]:"#ffffff",[s.EnumTheme.dark]:"#191919"},ae=["FB","AC","?","NOUT","CE","UKE",null];function ue(e,t,r){if(typeof r=="function")return r(e,t);if(e.startsWith("//"))return e;const o=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(o){const n=o[1].toLowerCase();return n==="http"||n==="https"||n==="data"?e:(console.warn(`unsupported protocol "${n}" in srk asset url:`,e),"")}return console.warn("unsupported srk asset url:",e),""}function de(e,t,r=180){const{backgroundColor:o}=s.resolveStyle(e||{}),n=o[t]||U[t],i=N.default(n).string(),l=N.default(n).alpha(.27).string();return`linear-gradient(${r}deg, ${i} 0%, ${i} 10%, ${l} 10%, transparent 100%)`}function fe(e,t){return typeof e.style=="string"?{className:`srk-preset-marker-${e.style}`}:e.style?{style:{backgroundColor:s.resolveStyle(e.style).backgroundColor[t]}}:{}}function me(e,t){const r=s.resolveText(e.name,t);return e.role?`${r} (${e.role})`:r}function ge(e){switch(e){case"FB":return{label:"First Blood",className:"srk-preset-result-fb"};case"AC":return{label:"Accepted",className:"srk-preset-result-ac"};case"RJ":return{label:"Rejected",className:"srk-preset-result-rj"};case"?":return{label:"Frozen",className:"srk-preset-result-fz"};case"WA":return{label:"Wrong Answer",className:"srk-preset-result-rj"};case"PE":return{label:"Presentation Error",className:"srk-preset-result-rj"};case"TLE":return{label:"Time Limit Exceeded",className:"srk-preset-result-rj"};case"MLE":return{label:"Memory Limit Exceeded",className:"srk-preset-result-rj"};case"OLE":return{label:"Output Limit Exceeded",className:"srk-preset-result-rj"};case"IDLE":return{label:"Idleness Limit Exceeded",className:"srk-preset-result-rj"};case"RTE":return{label:"Runtime Error",className:"srk-preset-result-rj"};case"NOUT":return{label:"No Output"};case"CE":return{label:"Compile Error"};case"UKE":return{label:"Unknown Error"};case null:return{label:"--"};default:return{label:e}}}function X(e){return`${e.tries}/${e.time?s.formatTimeDuration(e.time,"min",Math.floor):"-"}`}function g(e){return(e==null?void 0:e.result)==="AC"||(e==null?void 0:e.result)==="FB"}function K(e){return(e==null?void 0:e.result)==="RJ"||(e==null?void 0:e.result)==="?"}function v(e){return(e==null?void 0:e.tries)||0}function H(e,t){const r=Re(t),o=e.solutions||[];for(let n=o.length-1;n>=0;n-=1){const i=o[n];if(!r.includes(i.result))return i}}function f(e,t){if(!e)return"-";const r=ke(e,t);if(r==="ms"){const n=Math.floor(s.formatTimeDuration(e,"ms")),i=Math.floor(n/1e3);return`${F(i)}.${b(n%1e3,3)}`}if(r==="s")return F(Math.floor(s.formatTimeDuration(e,"s")));const o=Math.floor(s.formatTimeDuration(e,"min"));return`${Math.floor(o/60)}:${b(o%60,2)}`}function pe(e,t,r="classic"){if(!e.result)return{};if(r==="classic"){if(g(e)){const o=X(e);return typeof e.score=="number"?{score:e.score,scoreDetails:o}:{primary:o}}return{primary:typeof e.tries=="number"?String(e.tries):""}}if(g(e)){const o=Math.max((e.tries||0)-1,0);if(r==="detailed")return{primary:f(e.time,t),secondary:o>0?`(-${o})`:""};const n=o>0?`+${o}`:"+";return r==="compact"?{primary:n,secondary:f(e.time,t)}:{primary:n}}if(K(e)){const o=e.tries||0,n=`-${o}`;if(r==="detailed")return{primary:"",secondary:o>0?`(-${o})`:""};if(r==="compact"&&o>0){const i=H(e,t);if(i)return{primary:n,secondary:f(i.time,t)}}return{primary:n}}return{}}function ye(e){const t=e.statuses.reduce((r,o)=>{if(!g(o))return r;const n=v(o);return{wrong:r.wrong+Math.max(n-1,0),submitted:r.submitted+n}},{wrong:0,submitted:0});return!t.submitted||!t.wrong?"0%":`${Math.floor(t.wrong/t.submitted*100)}%`}function be(e){const t=e.rows.length;return e.problems.map((r,o)=>{const n={participantCount:t,accepted:0,attempted:0,submitted:0,dirt:0,dirtSubmitted:0};return e.rows.forEach(i=>{const l=i.statuses[o],u=v(l);u>0&&(n.attempted+=1,n.submitted+=u),g(l)&&(n.accepted+=1,n.dirt+=Math.max(u-1,0),n.dirtSubmitted+=u,l.time&&((!n.firstAcceptedTime||B(l.time,n.firstAcceptedTime)<0)&&(n.firstAcceptedTime=l.time),(!n.lastAcceptedTime||B(l.time,n.lastAcceptedTime)>0)&&(n.lastAcceptedTime=l.time)))}),n})}function he(e,t){return!e.firstAcceptedTime||!e.lastAcceptedTime?"-":`${f(e.firstAcceptedTime,t)} / ${f(e.lastAcceptedTime,t)}`}function Te(e){return e?String(Math.floor(s.formatTimeDuration(e,"min"))):"-"}function Me(e,t){return t<=0?"(-)":`(${Math.floor(e/t*100)}%)`}function Se(e){const t=V(e);return t===void 0?"-":W(t)}function Pe(e,t){const r=e.statuses.reduce((o,n,i)=>{if(!g(n))return o;const l=V(t[i]);return l!==void 0&&o.push(l),o},[]);return r.length?W(r.reduce((o,n)=>o+n,0)/r.length):"0.00"}function Ae(e,t,r){return`Solutions of ${s.numberToAlphabet(e)} (${s.resolveText(t.name,r)})`}function ve(e){return s.secToTimeStr(s.formatTimeDuration(e.time,"s"))}function we(e){return e.some(t=>{var r;return Boolean((r=t.score)==null?void 0:r.time)})}function ke(e,t){const r=t.sorter;return(r==null?void 0:r.algorithm)==="ICPC"&&r.config.timePrecision?r.config.timePrecision:e[1]}function Re(e){const t=e.sorter;return(t==null?void 0:t.algorithm)==="ICPC"&&t.config.noPenaltyResults?t.config.noPenaltyResults:ae}function V(e){if(!(!e||e.participantCount<=0))return(e.participantCount-e.accepted)/e.participantCount}function W(e){return e.toFixed(2)}function B(e,t){return s.formatTimeDuration(e,"ms")-s.formatTimeDuration(t,"ms")}function F(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return`${t}:${b(r,2)}:${b(o,2)}`}function b(e,t){const r=String(Math.trunc(Math.abs(e)));return r.length>=t?r:`${"0".repeat(t-r.length)}${r}`}function J(e){return s.formatTimeDuration(e.duration,"min")}function xe(e,t,r=0){const o=new Date(e.startAt).getTime(),n=t-r;return Math.min(Math.max(Math.floor((n-o)/6e4),0),J(e))}function Ee(e,t,r=0){const n=new Date(e.startAt).getTime()+s.formatTimeDuration(e.duration,"ms");return t-r>=n}function Ce(e){const t={};for(let r=0;r<=e;++r)t[r]="";return t}function De(e,t,r,o,n){const{contest:i}=e,l=new Date(i.startAt).getTime(),u=l+s.formatTimeDuration(i.duration,"ms"),I=i.frozenDuration?s.formatTimeDuration(i.frozenDuration,"ms"):0,$=t-r,d=u-l,p=d?1-I/d:1,S=Math.min(Math.max($-l,0),d),ee=d-S,te=u-I,re=d?S/d*100:0,O=d?Math.max(Math.min($,te)-l,0)/d*100:0,oe=Math.min(100,p?O/p:0),ne=re-O,ie=Math.min(100,1-p?ne/(1-p):0),P=o*60*1e3,_=d-P;return{elapsed:n?P:S,remaining:n?_:ee,frozenBreakpoint:p,normalInnerPercent:oe,frozenInnerPercent:ie,timeTravelElapsed:P,timeTravelRemaining:_,supportRegen:s.canRegenerateRanklist(e)}}const q=">=0.3.0 <=0.3.13";function Le(e){return ce.default.satisfies(e,q)}const Ie=280,$e="srk-animated-modal-root",M="srk-scrolling-effect";let y=null,a=null,j=!1,m=0,w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,A=1,c=[],Y=!1;function Oe(e){var r,o;if(e.key!=="Escape")return;const t=c[c.length-1];!t||((r=t.onEscape)==null||r.call(t,e),(o=e.stopImmediatePropagation)==null||o.call(e),e.stopPropagation())}function _e(){typeof document=="undefined"||Y||(document.addEventListener("keydown",Oe),Y=!0)}function Ne(){typeof document=="undefined"||j||(document.addEventListener("mousedown",e=>{a={x:e.clientX,y:e.clientY}},!0),document.addEventListener("touchstart",e=>{const t=e.touches[0]||e.changedTouches[0];!t||(a={x:t.clientX,y:t.clientY})},{capture:!0,passive:!0}),j=!0)}function Z(e,t,r){y={x:e,y:t,timestamp:Date.now(),source:r==null?void 0:r.source,context:r==null?void 0:r.context}}function Be(e,t){Z(e.clientX,e.clientY,t)}function G(e=500){return!y||Date.now()-y.timestamp>e?null:y}function Fe(){return a}function je(e){if(typeof window=="undefined"||!e)return{origin:{x:0,y:0},source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:null,fallbackPoint:{x:0,y:0}};const t=e.getBoundingClientRect(),r={x:t.width/2,y:Math.min(t.height*.22,96)},o=G();return o?{origin:{x:o.x-t.left,y:o.y-t.top},source:"explicit-trigger",explicitTriggerPoint:o,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:a?{origin:{x:a.x-t.left,y:a.y-t.top},source:"global-pointer",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:{origin:r,source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:null,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}}function Ye(){return typeof document=="undefined"?null:document.activeElement instanceof HTMLElement?document.activeElement:null}function Q(e){try{e.focus({preventScroll:!0})}catch{e.focus()}}function ze(e,t={}){if(typeof document=="undefined"||!e)return null;_e();const r=c.find(l=>l.dialogElement===e);if(r)return r.onEscape=t.onEscape,r.id;const o=e.hasAttribute("tabindex"),n=e.getAttribute("tabindex");o||e.setAttribute("tabindex","-1");const i={id:A,dialogElement:e,restoreElement:Ye(),hadTabIndex:o,previousTabIndex:n,onEscape:t.onEscape};return A+=1,c.push(i),Q(e),i.id}function Ue(e){var l;if(typeof document=="undefined"||e==null)return;const t=c.findIndex(u=>u.id===e);if(t===-1)return;const[r]=c.splice(t,1);if(r.hadTabIndex?r.previousTabIndex===null?r.dialogElement.removeAttribute("tabindex"):r.dialogElement.setAttribute("tabindex",r.previousTabIndex):r.dialogElement.removeAttribute("tabindex"),!(t===c.length))return;const n=c[c.length-1],i=(l=r.restoreElement)!=null&&l.isConnected?r.restoreElement:n==null?void 0:n.dialogElement;i&&Q(i)}function Xe(e){var t;return e==null?!1:((t=c[c.length-1])==null?void 0:t.id)===e}function Ke(){typeof document!="undefined"&&(m===0&&(h=window.scrollX,T=window.scrollY,w=document.body.style.overflow,k=document.body.style.overflowX,R=document.body.style.overflowY,x=document.body.style.position,E=document.body.style.top,C=document.body.style.left,D=document.body.style.right,L=document.body.style.width,document.body.classList.add(M),document.body.style.overflow="hidden",document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",document.body.style.position="fixed",document.body.style.top=`-${T}px`,document.body.style.left=`-${h}px`,document.body.style.right="0",document.body.style.width="100%"),m+=1)}function He(){if(!(typeof document=="undefined"||m===0)&&(m-=1,m===0&&(document.body.classList.remove(M),document.body.style.overflow=w,document.body.style.overflowX=k,document.body.style.overflowY=R,document.body.style.position=x,document.body.style.top=E,document.body.style.left=C,document.body.style.right=D,document.body.style.width=L,!(typeof navigator!="undefined"&&/jsdom/i.test(navigator.userAgent))&&typeof window.scrollTo=="function")))try{window.scrollTo(h,T)}catch{}}function Ve(){y=null,a=null,m=0,A=1,c=[],w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,typeof document!="undefined"&&(document.body.classList.remove(M),document.body.style.overflow="",document.body.style.overflowX="",document.body.style.overflowY="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="")}Object.defineProperty(exports,"convertToStaticRanklist",{enumerable:!0,get:function(){return s.convertToStaticRanklist}});exports.MODAL_ANIMATION_DURATION_MS=Ie;exports.SRK_ANIMATED_MODAL_ROOT_CLASS=$e;exports.SRK_SCROLL_LOCK_BODY_CLASS=M;exports.buildSliderMarks=Ce;exports.calculateDirtPercentage=ye;exports.calculateProblemStatisticsFooter=be;exports.calculateSEValue=Pe;exports.caniuse=Le;exports.captureModalTriggerPointFromMouseEvent=Be;exports.defaultBackgroundColor=U;exports.ensureModalInteractionTracker=Ne;exports.formatProblemStatisticsAcceptedMinute=Te;exports.formatProblemStatisticsAcceptedRange=he;exports.formatProblemStatisticsAverageHardness=Se;exports.formatProblemStatisticsPercent=Me;exports.formatRanklistStatusTime=f;exports.formatSolutionTimestamp=ve;exports.formatTeamMemberName=me;exports.getAcceptedStatusDetails=X;exports.getLastModalInteractionPoint=Fe;exports.getLastPenaltySolution=H;exports.getMarkerPresentation=fe;exports.getProblemHeaderBackgroundImage=de;exports.getProgressDurationMinutes=J;exports.getProgressMaxAvailableMinutes=xe;exports.getProgressMetrics=De;exports.getRankProblemStatusCellPresentation=pe;exports.getRankProblemStatusTries=v;exports.getRecentModalTriggerPoint=G;exports.getSolutionModalTitle=Ae;exports.getSolutionResultMeta=ge;exports.isAcceptedRankProblemStatus=g;exports.isProgressEnded=Ee;exports.isRejectedRankProblemStatus=K;exports.isTopModalFocusScope=Xe;exports.lockModalBodyScroll=Ke;exports.registerModalFocusScope=ze;exports.resetModalInteractionStateForTests=Ve;exports.resolveModalTransformOrigin=je;exports.resolveSrkAssetUrl=ue;exports.setModalTriggerPoint=Z;exports.shouldShowTimeColumn=we;exports.srkSupportedVersions=q;exports.unlockModalBodyScroll=He;exports.unregisterModalFocusScope=Ue;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Color from "color";
|
|
2
|
-
import { EnumTheme, resolveStyle, formatTimeDuration, numberToAlphabet,
|
|
2
|
+
import { EnumTheme, resolveStyle, resolveText, formatTimeDuration, numberToAlphabet, secToTimeStr, canRegenerateRanklist } from "@algoux/standard-ranklist-utils";
|
|
3
3
|
export { convertToStaticRanklist } from "@algoux/standard-ranklist-utils";
|
|
4
4
|
import semver from "semver";
|
|
5
5
|
const defaultBackgroundColor = {
|
|
@@ -46,6 +46,10 @@ function getMarkerPresentation(marker, theme) {
|
|
|
46
46
|
}
|
|
47
47
|
return {};
|
|
48
48
|
}
|
|
49
|
+
function formatTeamMemberName(member, languages) {
|
|
50
|
+
const name = resolveText(member.name, languages);
|
|
51
|
+
return member.role ? `${name} (${member.role})` : name;
|
|
52
|
+
}
|
|
49
53
|
function getSolutionResultMeta(result) {
|
|
50
54
|
switch (result) {
|
|
51
55
|
case "FB":
|
|
@@ -66,6 +70,8 @@ function getSolutionResultMeta(result) {
|
|
|
66
70
|
return { label: "Memory Limit Exceeded", className: "srk-preset-result-rj" };
|
|
67
71
|
case "OLE":
|
|
68
72
|
return { label: "Output Limit Exceeded", className: "srk-preset-result-rj" };
|
|
73
|
+
case "IDLE":
|
|
74
|
+
return { label: "Idleness Limit Exceeded", className: "srk-preset-result-rj" };
|
|
69
75
|
case "RTE":
|
|
70
76
|
return { label: "Runtime Error", className: "srk-preset-result-rj" };
|
|
71
77
|
case "NOUT":
|
|
@@ -199,7 +205,7 @@ function calculateProblemStatisticsFooter(ranklist) {
|
|
|
199
205
|
const stat = {
|
|
200
206
|
participantCount,
|
|
201
207
|
accepted: 0,
|
|
202
|
-
|
|
208
|
+
attempted: 0,
|
|
203
209
|
submitted: 0,
|
|
204
210
|
dirt: 0,
|
|
205
211
|
dirtSubmitted: 0
|
|
@@ -208,7 +214,7 @@ function calculateProblemStatisticsFooter(ranklist) {
|
|
|
208
214
|
const status = row.statuses[problemIndex];
|
|
209
215
|
const tries = getRankProblemStatusTries(status);
|
|
210
216
|
if (tries > 0) {
|
|
211
|
-
stat.
|
|
217
|
+
stat.attempted += 1;
|
|
212
218
|
stat.submitted += tries;
|
|
213
219
|
}
|
|
214
220
|
if (!isAcceptedRankProblemStatus(status)) {
|
|
@@ -271,8 +277,8 @@ function calculateSEValue(row, problemStatistics) {
|
|
|
271
277
|
}
|
|
272
278
|
return formatAverageHardnessValue(values.reduce((sum, value) => sum + value, 0) / values.length);
|
|
273
279
|
}
|
|
274
|
-
function getSolutionModalTitle(problemIndex, user) {
|
|
275
|
-
return `Solutions of ${numberToAlphabet(problemIndex)} (${resolveText(user.name)})`;
|
|
280
|
+
function getSolutionModalTitle(problemIndex, user, languages) {
|
|
281
|
+
return `Solutions of ${numberToAlphabet(problemIndex)} (${resolveText(user.name, languages)})`;
|
|
276
282
|
}
|
|
277
283
|
function formatSolutionTimestamp(solution) {
|
|
278
284
|
return secToTimeStr(formatTimeDuration(solution.time, "s"));
|
|
@@ -369,7 +375,7 @@ function getProgressMetrics(data, localTime, td, timeTravelCurrentValue, inTimeM
|
|
|
369
375
|
supportRegen: canRegenerateRanklist(data)
|
|
370
376
|
};
|
|
371
377
|
}
|
|
372
|
-
const srkSupportedVersions = ">=0.3.0 <=0.3.
|
|
378
|
+
const srkSupportedVersions = ">=0.3.0 <=0.3.13";
|
|
373
379
|
function caniuse(version) {
|
|
374
380
|
return semver.satisfies(version, srkSupportedVersions);
|
|
375
381
|
}
|
|
@@ -676,4 +682,4 @@ function resetModalInteractionStateForTests() {
|
|
|
676
682
|
document.body.style.width = "";
|
|
677
683
|
}
|
|
678
684
|
}
|
|
679
|
-
export { MODAL_ANIMATION_DURATION_MS, SRK_ANIMATED_MODAL_ROOT_CLASS, SRK_SCROLL_LOCK_BODY_CLASS, buildSliderMarks, calculateDirtPercentage, calculateProblemStatisticsFooter, calculateSEValue, caniuse, captureModalTriggerPointFromMouseEvent, defaultBackgroundColor, ensureModalInteractionTracker, formatProblemStatisticsAcceptedMinute, formatProblemStatisticsAcceptedRange, formatProblemStatisticsAverageHardness, formatProblemStatisticsPercent, formatRanklistStatusTime, formatSolutionTimestamp, getAcceptedStatusDetails, getLastModalInteractionPoint, getLastPenaltySolution, getMarkerPresentation, getProblemHeaderBackgroundImage, getProgressDurationMinutes, getProgressMaxAvailableMinutes, getProgressMetrics, getRankProblemStatusCellPresentation, getRankProblemStatusTries, getRecentModalTriggerPoint, getSolutionModalTitle, getSolutionResultMeta, isAcceptedRankProblemStatus, isProgressEnded, isRejectedRankProblemStatus, isTopModalFocusScope, lockModalBodyScroll, registerModalFocusScope, resetModalInteractionStateForTests, resolveModalTransformOrigin, resolveSrkAssetUrl, setModalTriggerPoint, shouldShowTimeColumn, srkSupportedVersions, unlockModalBodyScroll, unregisterModalFocusScope };
|
|
685
|
+
export { MODAL_ANIMATION_DURATION_MS, SRK_ANIMATED_MODAL_ROOT_CLASS, SRK_SCROLL_LOCK_BODY_CLASS, buildSliderMarks, calculateDirtPercentage, calculateProblemStatisticsFooter, calculateSEValue, caniuse, captureModalTriggerPointFromMouseEvent, defaultBackgroundColor, ensureModalInteractionTracker, formatProblemStatisticsAcceptedMinute, formatProblemStatisticsAcceptedRange, formatProblemStatisticsAverageHardness, formatProblemStatisticsPercent, formatRanklistStatusTime, formatSolutionTimestamp, formatTeamMemberName, getAcceptedStatusDetails, getLastModalInteractionPoint, getLastPenaltySolution, getMarkerPresentation, getProblemHeaderBackgroundImage, getProgressDurationMinutes, getProgressMaxAvailableMinutes, getProgressMetrics, getRankProblemStatusCellPresentation, getRankProblemStatusTries, getRecentModalTriggerPoint, getSolutionModalTitle, getSolutionResultMeta, isAcceptedRankProblemStatus, isProgressEnded, isRejectedRankProblemStatus, isTopModalFocusScope, lockModalBodyScroll, registerModalFocusScope, resetModalInteractionStateForTests, resolveModalTransformOrigin, resolveSrkAssetUrl, setModalTriggerPoint, shouldShowTimeColumn, srkSupportedVersions, unlockModalBodyScroll, unregisterModalFocusScope };
|
package/dist/ranklist.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface RanklistColumnTitles {
|
|
|
26
26
|
export interface ProblemStatisticsFooter {
|
|
27
27
|
participantCount: number;
|
|
28
28
|
accepted: number;
|
|
29
|
-
|
|
29
|
+
attempted: number;
|
|
30
30
|
submitted: number;
|
|
31
31
|
dirt: number;
|
|
32
32
|
dirtSubmitted: number;
|
|
@@ -42,6 +42,7 @@ export interface RanklistStatusCellPresentation {
|
|
|
42
42
|
export declare function resolveSrkAssetUrl(url: string, field: string, formatter?: (url: string, field: string) => string): string;
|
|
43
43
|
export declare function getProblemHeaderBackgroundImage(style: srk.Style | undefined, theme: EnumTheme, gradientDirection?: number): string;
|
|
44
44
|
export declare function getMarkerPresentation(marker: srk.Marker, theme: EnumTheme): MarkerPresentation;
|
|
45
|
+
export declare function formatTeamMemberName(member: srk.ExternalUser, languages?: readonly string[]): string;
|
|
45
46
|
export declare function getSolutionResultMeta(result: srk.Solution['result']): SolutionResultMeta;
|
|
46
47
|
export declare function getAcceptedStatusDetails(status: srk.RankProblemStatus): string;
|
|
47
48
|
export declare function isAcceptedRankProblemStatus(status: srk.RankProblemStatus | undefined): boolean;
|
|
@@ -57,6 +58,6 @@ export declare function formatProblemStatisticsAcceptedMinute(time: srk.TimeDura
|
|
|
57
58
|
export declare function formatProblemStatisticsPercent(numerator: number, denominator: number): string;
|
|
58
59
|
export declare function formatProblemStatisticsAverageHardness(stat: ProblemStatisticsFooter): string;
|
|
59
60
|
export declare function calculateSEValue(row: Pick<StaticRanklistRow, 'statuses'>, problemStatistics: ProblemStatisticsFooter[]): string;
|
|
60
|
-
export declare function getSolutionModalTitle(problemIndex: number, user: srk.User): string;
|
|
61
|
+
export declare function getSolutionModalTitle(problemIndex: number, user: srk.User, languages?: readonly string[]): string;
|
|
61
62
|
export declare function formatSolutionTimestamp(solution: srk.Solution): string;
|
|
62
63
|
export declare function shouldShowTimeColumn(rows: srk.RanklistRow[]): boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface UserClickPayload {
|
|
|
20
20
|
rowIndex: number;
|
|
21
21
|
ranklist: StaticRanklist;
|
|
22
22
|
}
|
|
23
|
+
export interface ProblemClickPayload {
|
|
24
|
+
problem: srk.Problem;
|
|
25
|
+
problemIndex: number;
|
|
26
|
+
ranklist: StaticRanklist;
|
|
27
|
+
}
|
|
23
28
|
export interface SolutionClickPayload {
|
|
24
29
|
user: srk.User;
|
|
25
30
|
row: StaticRanklistRow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algoux/standard-ranklist-renderer-component-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Core helpers and shared types for Standard Ranklist Renderer Component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/algoux/standard-ranklist-renderer-component",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"registry": "https://registry.npmjs.org/"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@algoux/standard-ranklist-utils": "^0.
|
|
32
|
+
"@algoux/standard-ranklist-utils": "^0.3.1",
|
|
33
33
|
"color": "^4.2.3",
|
|
34
34
|
"semver": "^7.3.7"
|
|
35
35
|
},
|