@savantlink/sdk 2.2.4 → 2.2.6
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/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./Badge/Badge.js"),r=require("./Button/Button.js"),t=require("./Breadcrumbs/Breadcrumbs.js"),o=require("./Drawer/Drawer.js"),s=require("./Input/Input.js"),a=require("./OTPInput/OTPInput.js"),u=require("./Modal/Modal.js"),i=require("./Pagination/Pagination.js"),p=require("./PhoneInput/PhoneInput.js"),l=require("./RadioGroup/RadioGroup.js"),n=require("./Select/Select.js"),d=require("./Spinner/Spinner.js"),x=require("./Table/Table.js"),c=require("./Tag/Tag.js"),T=require("./Textarea/Textarea.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./Badge/Badge.js"),r=require("./Button/Button.js"),t=require("./Breadcrumbs/Breadcrumbs.js"),o=require("./Drawer/Drawer.js"),s=require("./Input/Input.js"),a=require("./OTPInput/OTPInput.js"),u=require("./Modal/Modal.js"),i=require("./Pagination/Pagination.js"),p=require("./PhoneInput/PhoneInput.js"),l=require("./RadioGroup/RadioGroup.js"),n=require("./Select/Select.js"),d=require("./Spinner/Spinner.js"),x=require("./Table/Table.js"),c=require("./Tag/Tag.js"),T=require("./Textarea/Textarea.js"),m=require("./Toast/Toast.js"),f=require("./Tooltip/Tooltip.js"),g=require("./Typography/Typography.js"),j=require("./Dropdown/Dropdown.js"),q=require("./FileUpload/FileUpload.js"),I=require("./ValidationError/index.js"),E=require("./AppIcon/AppIcon.js"),S=require("./VersionUpdateNotice/VersionUpdateNotice.js"),y=require("./ImageLoader/ImageLoader.js"),P=require("./Tabs/Tabs.js"),b=require("./keypad/NumberKeypad/NumberKeypad.js"),D=require("./hooks/use-pagination.js"),L=require("./hooks/use-idle-timeout.js"),_=require("./hooks/use-debounce.js"),A=require("./hooks/use-online-status.js"),h=require("./hooks/use-screen-size.js"),V=require("./hooks/use-scroll-lock.js"),M=require("./services/number.js"),N=require("./services/format.js"),v=require("./services/query.js"),C=require("./services/error.js"),O=require("./services/collection.js"),U=require("./services/validation.js");exports.Badge=e.default,exports.Button=r.default,exports.Breadcrumbs=t.default,exports.Drawer=o.default,exports.Input=s.default,exports.OTPInput=a.default,exports.Modal=u.default,exports.Pagination=i.default,exports.PhoneInput=p.default,exports.RadioGroup=l.default,exports.Select=n.default,exports.Spinner=d.default,exports.Table=x.default,exports.Tag=c.default,exports.Textarea=T.default,exports.Toast=m.default,exports.Tooltip=f.default,exports.Typography=g.default,exports.Dropdown=j.default,exports.FileUpload=q.default,exports.ValidationError=I.default,exports.AppIcon=E.default,exports.appIcons=E.icons,exports.DEFAULT_CHECK_INTERVAL_MS=S.DEFAULT_CHECK_INTERVAL_MS,exports.VersionUpdateNotice=S.default,exports.ImageLoader=y.default,exports.Tabs=P.default,exports.useTabs=P.useTabs,exports.NumberKeypad=b.default,exports.ELLIPSIS=D.ELLIPSIS,exports.usePagination=D.usePagination,exports.DEFAULT_IDLE_TIMEOUT_MS=L.DEFAULT_IDLE_TIMEOUT_MS,exports.useIdleTimeout=L.useIdleTimeout,exports.useInactivityLogout=L.useInactivityLogout,exports.useDebounce=_.useDebounce,exports.useOnlineStatus=A.useOnlineStatus,exports.SCREEN_SIZE_BREAKPOINTS=h.SCREEN_SIZE_BREAKPOINTS,exports.useScreenSize=h.default,exports.useScrollLock=V.default,exports.calculateAmount=M.calculateAmount,exports.range=M.range,exports.currencyFormatter=N.currencyFormatter,exports.currencyFormmater=N.currencyFormmater,exports.formatCurrency=N.formatCurrency,exports.formatDate=N.formatDate,exports.formatDateTime=N.formatDateTime,exports.formatSlugToString=N.formatSlugToString,exports.formatTime=N.formatTime,exports.getRelativeTime=N.getRelativeTime,exports.getTagColor=N.getTagColor,exports.replacePlaceholder=N.replacePlaceholder,exports.titleCase=N.titleCase,exports.createQueryParams=v.createQueryParams,exports.extractErrorMessage=C.extractErrorMessage,exports.getApiErrorMessage=C.getApiErrorMessage,exports.formatArrayToOptions=O.formatArrayToOptions,exports.sortData=O.sortData,exports.isValidEmail=U.isValidEmail,exports.isValidLength=U.isValidLength,exports.isValidNuban=U.isValidNuban,exports.isValidPin=U.isValidPin;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/services/format.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const titleCase=e=>e.trim().replace(/[_-]+/g," ").replace(/\s+/g," ").toLocaleLowerCase().replace(/(^|\s)\S/g,e=>e.toLocaleUpperCase()),formatCurrency=(e,t="NGN",r="en-US",a={})=>new Intl.NumberFormat(r,Object.assign(Object.assign({minimumFractionDigits:2,maximumFractionDigits:2},a),{style:"currency",currency:t.toUpperCase()})).format(e),toValidDate=e=>{const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))throw new RangeError("Invalid date");return t},e=formatCurrency,t=formatCurrency;exports.currencyFormatter=e,exports.currencyFormmater=t,exports.formatCurrency=formatCurrency,exports.formatDate=(e,t="short",r="en-GB")=>new Intl.DateTimeFormat(r,{day:"2-digit",month:"long"===t?"long":"short",year:"numeric"}).format(toValidDate(e)),exports.formatDateTime=(e,t="en-GB",r={})=>new Intl.DateTimeFormat(t,Object.assign({day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"},r)).format(toValidDate(e)),exports.formatSlugToString=e=>titleCase(e.replace(/[-_]+/g," ")),exports.formatTime=(e,t="en-US",r={})=>new Intl.DateTimeFormat(t,Object.assign({hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},r)).format(toValidDate(e)),exports.getRelativeTime=(e,t=Date.now(),r="en")=>{const a=Math.round((toValidDate(e).getTime()-toValidDate(t).getTime())/1e3),o=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),n=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]].find(([,e])=>Math.abs(a)>=e);return n?o.format(Math.round(a/n[1]),n[0]):"just now"},exports.getTagColor={active:"success",inactive:"danger"},exports.replacePlaceholder=(e,...t)=>e.replace(/{(\d+)}/g,(e,r)=>{var a;return null!==(a=t[Number(r)])&&void 0!==a?a:e}),exports.titleCase=titleCase;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const titleCase=e=>e.trim().replace(/[_-]+/g," ").replace(/\s+/g," ").toLocaleLowerCase().replace(/(^|\s)\S/g,e=>e.toLocaleUpperCase()),formatCurrency=(e,t="NGN",r="en-US",a={})=>new Intl.NumberFormat(r,Object.assign(Object.assign({minimumFractionDigits:2,maximumFractionDigits:2,currencyDisplay:"narrowSymbol"},a),{style:"currency",currency:t.toUpperCase()})).format(e),toValidDate=e=>{const t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))throw new RangeError("Invalid date");return t},e=formatCurrency,t=formatCurrency;exports.currencyFormatter=e,exports.currencyFormmater=t,exports.formatCurrency=formatCurrency,exports.formatDate=(e,t="short",r="en-GB")=>new Intl.DateTimeFormat(r,{day:"2-digit",month:"long"===t?"long":"short",year:"numeric"}).format(toValidDate(e)),exports.formatDateTime=(e,t="en-GB",r={})=>new Intl.DateTimeFormat(t,Object.assign({day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"},r)).format(toValidDate(e)),exports.formatSlugToString=e=>titleCase(e.replace(/[-_]+/g," ")),exports.formatTime=(e,t="en-US",r={})=>new Intl.DateTimeFormat(t,Object.assign({hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},r)).format(toValidDate(e)),exports.getRelativeTime=(e,t=Date.now(),r="en")=>{const a=Math.round((toValidDate(e).getTime()-toValidDate(t).getTime())/1e3),o=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),n=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60]].find(([,e])=>Math.abs(a)>=e);return n?o.format(Math.round(a/n[1]),n[0]):"just now"},exports.getTagColor={active:"success",inactive:"danger"},exports.replacePlaceholder=(e,...t)=>e.replace(/{(\d+)}/g,(e,r)=>{var a;return null!==(a=t[Number(r)])&&void 0!==a?a:e}),exports.titleCase=titleCase;
|
|
2
2
|
//# sourceMappingURL=format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sources":["../../src/services/format.ts"],"sourcesContent":["export type DateFormat = 'short' | 'long'\nexport type DateInput = Date | string | number\n\nconst getTagColor = {\n active: 'success',\n inactive: 'danger',\n} as const\n\nconst titleCase = (value: string): string =>\n value\n .trim()\n .replace(/[_-]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .toLocaleLowerCase()\n .replace(/(^|\\s)\\S/g, (letter) => letter.toLocaleUpperCase())\n\nconst formatSlugToString = (value: string): string => titleCase(value.replace(/[-_]+/g, ' '))\n\nconst replacePlaceholder = (template: string, ...replacements: string[]): string =>\n template.replace(/{(\\d+)}/g, (match, index: string) => replacements[Number(index)] ?? match)\n\nconst formatCurrency = (\n amount: number,\n currency = 'NGN',\n locale = 'en-US',\n options: Omit<Intl.NumberFormatOptions, 'style' | 'currency'> = {}\n): string =>\n new Intl.NumberFormat(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n ...options,\n style: 'currency',\n currency: currency.toUpperCase(),\n }).format(amount)\n\nconst toValidDate = (value: DateInput): Date => {\n const date = value instanceof Date ? value : new Date(value)\n if (Number.isNaN(date.getTime())) throw new RangeError('Invalid date')\n return date\n}\n\nconst formatDate = (value: DateInput, format: DateFormat = 'short', locale = 'en-GB'): string =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: format === 'long' ? 'long' : 'short',\n year: 'numeric',\n }).format(toValidDate(value))\n\nconst formatTime = (\n value: DateInput,\n locale = 'en-US',\n options: Intl.DateTimeFormatOptions = {}\n): string =>\n new Intl.DateTimeFormat(locale, {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n ...options,\n }).format(toValidDate(value))\n\nconst formatDateTime = (\n value: DateInput,\n locale = 'en-GB',\n options: Intl.DateTimeFormatOptions = {}\n): string =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n ...options,\n }).format(toValidDate(value))\n\nconst getRelativeTime = (value: DateInput, relativeTo: DateInput = Date.now(), locale = 'en'): string => {\n const elapsedSeconds = Math.round((toValidDate(value).getTime() - toValidDate(relativeTo).getTime()) / 1000)\n const formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' })\n const units: Array<[Intl.RelativeTimeFormatUnit, number]> = [\n ['year', 31_536_000],\n ['month', 2_592_000],\n ['week', 604_800],\n ['day', 86_400],\n ['hour', 3_600],\n ['minute', 60],\n ]\n const unit = units.find(([, seconds]) => Math.abs(elapsedSeconds) >= seconds)\n return unit ? formatter.format(Math.round(elapsedSeconds / unit[1]), unit[0]) : 'just now'\n}\n\nconst currencyFormatter = formatCurrency\n// Kept for consumers already using the common misspelling.\nconst currencyFormmater = formatCurrency\n\nexport {\n currencyFormmater,\n currencyFormatter,\n formatCurrency,\n formatDate,\n formatDateTime,\n formatSlugToString,\n formatTime,\n getRelativeTime,\n getTagColor,\n replacePlaceholder,\n titleCase,\n}\n"],"names":["titleCase","value","trim","replace","toLocaleLowerCase","letter","toLocaleUpperCase","formatCurrency","amount","currency","locale","options","Intl","NumberFormat","minimumFractionDigits","maximumFractionDigits","style","toUpperCase","format","toValidDate","date","Date","Number","isNaN","getTime","RangeError","currencyFormatter","currencyFormmater","DateTimeFormat","day","month","year","hour","minute","second","hour12","relativeTo","now","elapsedSeconds","Math","round","formatter","RelativeTimeFormat","numeric","unit","find","seconds","abs","active","inactive","template","replacements","match","index"],"mappings":"0EAQMA,UAAaC,GACjBA,EACGC,OACAC,QAAQ,SAAU,KAClBA,QAAQ,OAAQ,KAChBC,oBACAD,QAAQ,YAAcE,GAAWA,EAAOC,qBAOvCC,eAAiB,CACrBC,EACAC,EAAW,MACXC,EAAS,QACTC,EAAgE,KAEhE,IAAIC,KAAKC,aAAaH,+BACpBI,sBAAuB,EACvBC,sBAAuB,
|
|
1
|
+
{"version":3,"file":"format.js","sources":["../../src/services/format.ts"],"sourcesContent":["export type DateFormat = 'short' | 'long'\nexport type DateInput = Date | string | number\n\nconst getTagColor = {\n active: 'success',\n inactive: 'danger',\n} as const\n\nconst titleCase = (value: string): string =>\n value\n .trim()\n .replace(/[_-]+/g, ' ')\n .replace(/\\s+/g, ' ')\n .toLocaleLowerCase()\n .replace(/(^|\\s)\\S/g, (letter) => letter.toLocaleUpperCase())\n\nconst formatSlugToString = (value: string): string => titleCase(value.replace(/[-_]+/g, ' '))\n\nconst replacePlaceholder = (template: string, ...replacements: string[]): string =>\n template.replace(/{(\\d+)}/g, (match, index: string) => replacements[Number(index)] ?? match)\n\nconst formatCurrency = (\n amount: number,\n currency = 'NGN',\n locale = 'en-US',\n options: Omit<Intl.NumberFormatOptions, 'style' | 'currency'> = {}\n): string =>\n new Intl.NumberFormat(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n currencyDisplay: 'narrowSymbol',\n ...options,\n style: 'currency',\n currency: currency.toUpperCase(),\n }).format(amount)\n\nconst toValidDate = (value: DateInput): Date => {\n const date = value instanceof Date ? value : new Date(value)\n if (Number.isNaN(date.getTime())) throw new RangeError('Invalid date')\n return date\n}\n\nconst formatDate = (value: DateInput, format: DateFormat = 'short', locale = 'en-GB'): string =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: format === 'long' ? 'long' : 'short',\n year: 'numeric',\n }).format(toValidDate(value))\n\nconst formatTime = (\n value: DateInput,\n locale = 'en-US',\n options: Intl.DateTimeFormatOptions = {}\n): string =>\n new Intl.DateTimeFormat(locale, {\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n hour12: false,\n ...options,\n }).format(toValidDate(value))\n\nconst formatDateTime = (\n value: DateInput,\n locale = 'en-GB',\n options: Intl.DateTimeFormatOptions = {}\n): string =>\n new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'short',\n year: 'numeric',\n hour: '2-digit',\n minute: '2-digit',\n ...options,\n }).format(toValidDate(value))\n\nconst getRelativeTime = (value: DateInput, relativeTo: DateInput = Date.now(), locale = 'en'): string => {\n const elapsedSeconds = Math.round((toValidDate(value).getTime() - toValidDate(relativeTo).getTime()) / 1000)\n const formatter = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' })\n const units: Array<[Intl.RelativeTimeFormatUnit, number]> = [\n ['year', 31_536_000],\n ['month', 2_592_000],\n ['week', 604_800],\n ['day', 86_400],\n ['hour', 3_600],\n ['minute', 60],\n ]\n const unit = units.find(([, seconds]) => Math.abs(elapsedSeconds) >= seconds)\n return unit ? formatter.format(Math.round(elapsedSeconds / unit[1]), unit[0]) : 'just now'\n}\n\nconst currencyFormatter = formatCurrency\n// Kept for consumers already using the common misspelling.\nconst currencyFormmater = formatCurrency\n\nexport {\n currencyFormmater,\n currencyFormatter,\n formatCurrency,\n formatDate,\n formatDateTime,\n formatSlugToString,\n formatTime,\n getRelativeTime,\n getTagColor,\n replacePlaceholder,\n titleCase,\n}\n"],"names":["titleCase","value","trim","replace","toLocaleLowerCase","letter","toLocaleUpperCase","formatCurrency","amount","currency","locale","options","Intl","NumberFormat","minimumFractionDigits","maximumFractionDigits","currencyDisplay","style","toUpperCase","format","toValidDate","date","Date","Number","isNaN","getTime","RangeError","currencyFormatter","currencyFormmater","DateTimeFormat","day","month","year","hour","minute","second","hour12","relativeTo","now","elapsedSeconds","Math","round","formatter","RelativeTimeFormat","numeric","unit","find","seconds","abs","active","inactive","template","replacements","match","index"],"mappings":"0EAQMA,UAAaC,GACjBA,EACGC,OACAC,QAAQ,SAAU,KAClBA,QAAQ,OAAQ,KAChBC,oBACAD,QAAQ,YAAcE,GAAWA,EAAOC,qBAOvCC,eAAiB,CACrBC,EACAC,EAAW,MACXC,EAAS,QACTC,EAAgE,KAEhE,IAAIC,KAAKC,aAAaH,+BACpBI,sBAAuB,EACvBC,sBAAuB,EACvBC,gBAAiB,gBACdL,IACHM,MAAO,WACPR,SAAUA,EAASS,iBAClBC,OAAOX,GAENY,YAAenB,IACnB,MAAMoB,EAAOpB,aAAiBqB,KAAOrB,EAAQ,IAAIqB,KAAKrB,GACtD,GAAIsB,OAAOC,MAAMH,EAAKI,WAAY,MAAM,IAAIC,WAAW,gBACvD,OAAOL,GAoDHM,EAAoBpB,eAEpBqB,EAAoBrB,gIAnDP,CAACN,EAAkBkB,EAAqB,QAAST,EAAS,UAC3E,IAAIE,KAAKiB,eAAenB,EAAQ,CAC9BoB,IAAK,UACLC,MAAkB,SAAXZ,EAAoB,OAAS,QACpCa,KAAM,YACLb,OAAOC,YAAYnB,2BAeD,CACrBA,EACAS,EAAS,QACTC,EAAsC,KAEtC,IAAIC,KAAKiB,eAAenB,iBACtBoB,IAAK,UACLC,MAAO,QACPC,KAAM,UACNC,KAAM,UACNC,OAAQ,WACLvB,IACFQ,OAAOC,YAAYnB,+BA1DIA,GAA0BD,UAAUC,EAAME,QAAQ,SAAU,yBAiCrE,CACjBF,EACAS,EAAS,QACTC,EAAsC,KAEtC,IAAIC,KAAKiB,eAAenB,iBACtBuB,KAAM,UACNC,OAAQ,UACRC,OAAQ,UACRC,QAAQ,GACLzB,IACFQ,OAAOC,YAAYnB,4BAgBA,CAACA,EAAkBoC,EAAwBf,KAAKgB,MAAO5B,EAAS,QACtF,MAAM6B,EAAiBC,KAAKC,OAAOrB,YAAYnB,GAAOwB,UAAYL,YAAYiB,GAAYZ,WAAa,KACjGiB,EAAY,IAAI9B,KAAK+B,mBAAmBjC,EAAQ,CAAEkC,QAAS,SAS3DC,EARsD,CAC1D,CAAC,OAAQ,SACT,CAAC,QAAS,QACV,CAAC,OAAQ,QACT,CAAC,MAAO,OACR,CAAC,OAAQ,MACT,CAAC,SAAU,KAEMC,KAAK,GAAIC,KAAaP,KAAKQ,IAAIT,IAAmBQ,GACrE,OAAOF,EAAOH,EAAUvB,OAAOqB,KAAKC,MAAMF,EAAiBM,EAAK,IAAKA,EAAK,IAAM,gCArF9D,CAClBI,OAAQ,UACRC,SAAU,qCAae,CAACC,KAAqBC,IAC/CD,EAAShD,QAAQ,WAAY,CAACkD,EAAOC,WAAkB,iBAAAF,EAAa7B,OAAO+B,mBAAWD"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { range } from './number';
|
|
1
|
+
export { range, calculateAmount } from './number';
|
|
2
2
|
export { currencyFormmater, currencyFormatter, formatCurrency, formatDate, formatDateTime, formatSlugToString, formatTime, getRelativeTime, getTagColor, replacePlaceholder, titleCase, } from './format';
|
|
3
3
|
export type { DateFormat, DateInput } from './format';
|
|
4
4
|
export { createQueryParams } from './query';
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { Decimal } from 'decimal.js-light';
|
|
1
2
|
declare const range: (start: number, end: number) => number[];
|
|
2
|
-
|
|
3
|
+
declare type CalculationOperator = 'add' | 'subtract' | 'multiply' | 'divide';
|
|
4
|
+
declare const calculateAmount: (firstOperand: number, secondOperand: number, operator: CalculationOperator) => Decimal;
|
|
5
|
+
export { range, calculateAmount };
|
package/dist/services/number.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.range=(e,r)=>{const t=r-e+1;return Array.from({length:t},(r,t)=>t+e)};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("decimal.js-light");exports.calculateAmount=(r,t,a)=>{const i=new e.Decimal(r),o=new e.Decimal(t);let s;switch(a){case"add":s=i.plus(o);break;case"subtract":s=i.minus(o);break;case"multiply":s=i.times(o);break;case"divide":if(o.isZero())throw new Error("Cannot divide by zero.");s=i.dividedBy(o);break;default:throw new Error(`Unsupported calculation operator: ${a}`)}return s.toDecimalPlaces(2,e.Decimal.ROUND_HALF_UP)},exports.range=(e,r)=>{const t=r-e+1;return Array.from({length:t},(r,t)=>t+e)};
|
|
2
2
|
//# sourceMappingURL=number.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sources":["../../src/services/number.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../../src/services/number.ts"],"sourcesContent":["import { Decimal } from 'decimal.js-light'\n\nconst range = (start: number, end: number) => {\n const length = end - start + 1\n return Array.from({ length }, (_: number, index: number) => index + start)\n}\n\ntype CalculationOperator = 'add' | 'subtract' | 'multiply' | 'divide'\n\nconst calculateAmount = (firstOperand: number, secondOperand: number, operator: CalculationOperator): Decimal => {\n const first = new Decimal(firstOperand)\n const second = new Decimal(secondOperand)\n\n let result: Decimal\n\n switch (operator) {\n case 'add':\n result = first.plus(second)\n break\n\n case 'subtract':\n result = first.minus(second)\n break\n\n case 'multiply':\n result = first.times(second)\n break\n\n case 'divide':\n if (second.isZero()) {\n throw new Error('Cannot divide by zero.')\n }\n\n result = first.dividedBy(second)\n break\n\n default: {\n const exhaustiveCheck: never = operator\n throw new Error(`Unsupported calculation operator: ${exhaustiveCheck}`)\n }\n }\n\n return result.toDecimalPlaces(2, Decimal.ROUND_HALF_UP)\n}\n\nexport { range, calculateAmount }\n"],"names":["firstOperand","secondOperand","operator","first","Decimal","second","result","plus","minus","times","isZero","Error","dividedBy","toDecimalPlaces","ROUND_HALF_UP","start","end","length","Array","from","_","index"],"mappings":"8HASwB,CAACA,EAAsBC,EAAuBC,KACpE,MAAMC,EAAQ,IAAIC,UAAQJ,GACpBK,EAAS,IAAID,UAAQH,GAE3B,IAAIK,EAEJ,OAAQJ,GACN,IAAK,MACHI,EAASH,EAAMI,KAAKF,GACpB,MAEF,IAAK,WACHC,EAASH,EAAMK,MAAMH,GACrB,MAEF,IAAK,WACHC,EAASH,EAAMM,MAAMJ,GACrB,MAEF,IAAK,SACH,GAAIA,EAAOK,SACT,MAAM,IAAIC,MAAM,0BAGlBL,EAASH,EAAMS,UAAUP,GACzB,MAEF,QAEE,MAAM,IAAIM,MAAM,qCADeT,KAKnC,OAAOI,EAAOO,gBAAgB,EAAGT,UAAQU,8BAxC7B,CAACC,EAAeC,KAC5B,MAAMC,EAASD,EAAMD,EAAQ,EAC7B,OAAOG,MAAMC,KAAK,CAAEF,UAAU,CAACG,EAAWC,IAAkBA,EAAQN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savantlink/sdk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "A package that contains reusable components and services for the SavantLink design system and architecture.",
|
|
5
5
|
"homepage": "https://github.com/savantlink/savantlink-sdk",
|
|
6
6
|
"repository": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"clsx": "1.2.1",
|
|
48
|
+
"decimal.js-light": "2.5.1",
|
|
48
49
|
"lucide-react": "1.27.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|