@scbt-ecom/ui 0.180.0 → 0.181.0
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/lib/widgets/calculator/model/helpers.js +1 -1
- package/dist/lib/widgets/calculator/model/helpers.js.map +1 -1
- package/dist/lib/widgets/calculator/ui/calculatorInfo/ui/CalculatedBlock.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/types/lib/widgets/calculator/model/helpers.d.ts +1 -1
- package/dist/types/lib/widgets/calculator/ui/calculatorInfo/ui/CalculatedBlock.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TypeGuards as u}from"../../../shared/utils/typeGuards.js";const c=(r,e)=>(r
|
|
1
|
+
import{TypeGuards as u}from"../../../shared/utils/typeGuards.js";const c=(r,e)=>(r?.match(/[a-zA-Z_$][a-zA-Z0-9_$]*/g)||[]).filter(t=>!(t in e)).length>0?"":r,m=(r,e)=>{const a=Object.entries(e).map(([s,l])=>[s,u.isNil(l)?"1":l]),n=a.map(([s])=>s),t=a.map(([,s])=>s),o=c(r,Object.fromEntries(a)),i=new Function(...n,`return ${o};`)(...t.map(Number));return Number.isNaN(Number(i))?"0":i.toString()},v=(r,e)=>r?.map(a=>({...a,value:a?.isFormula?m(a.value,e):a.value}));export{m as evaluateFormula,v as formatInfoList};
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../../../../lib/widgets/calculator/model/helpers.ts"],"sourcesContent":["import type { InfoListItemProps } from '../ui'\nimport type { CalculatorVariables } from './types'\nimport { TypeGuards } from '$/shared/utils'\n\nconst validateFormula = (formula: string, variables: CalculatorVariables) => {\n const variablesInFormula = formula
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../../../../lib/widgets/calculator/model/helpers.ts"],"sourcesContent":["import type { InfoListItemProps } from '../ui'\nimport type { CalculatorVariables } from './types'\nimport { TypeGuards } from '$/shared/utils'\n\nconst validateFormula = (formula: string | undefined, variables: CalculatorVariables) => {\n const variablesInFormula = formula?.match(/[a-zA-Z_$][a-zA-Z0-9_$]*/g) || []\n const missingVariables = variablesInFormula.filter((varName) => !(varName in variables))\n\n if (missingVariables.length > 0) {\n return ''\n // throw new Error(`Отсутствуют переменные для калькулятора: ${missingVariables.join(', ')}`) 12 + 14 / select1\n }\n\n return formula\n}\n\nexport const evaluateFormula = (formula: string | undefined, variables: CalculatorVariables): string => {\n const entries = Object.entries(variables).map(([key, value]) => [key, !TypeGuards.isNil(value) ? value : '1'])\n\n const variablesKeys = entries.map(([key]) => key)\n const variablesValues = entries.map(([, value]) => value)\n\n const validatedFormula = validateFormula(formula, Object.fromEntries(entries))\n const replaceVariables = new Function(...variablesKeys, `return ${validatedFormula};`)\n\n const replaceResult: number = replaceVariables(...variablesValues.map(Number))\n\n if (Number.isNaN(Number(replaceResult))) {\n return '0'\n }\n\n return replaceResult.toString()\n}\n\nexport const formatInfoList = (list: InfoListItemProps[], variables: CalculatorVariables): InfoListItemProps[] => {\n return list?.map((item) => {\n return {\n ...item,\n value: item?.isFormula ? evaluateFormula(item.value, variables) : item.value\n }\n })\n}\n"],"names":["validateFormula","formula","variables","varName","evaluateFormula","entries","key","value","TypeGuards","variablesKeys","variablesValues","validatedFormula","replaceResult","formatInfoList","list","item"],"mappings":"iEAIA,MAAMA,EAAkB,CAACC,EAA6BC,KACzBD,GAAS,MAAM,2BAA2B,GAAK,CAAA,GAC9B,OAAQE,GAAY,EAAEA,KAAWD,EAAU,EAElE,OAAS,EACrB,GAIFD,EAGIG,EAAkB,CAACH,EAA6BC,IAA2C,CACtG,MAAMG,EAAU,OAAO,QAAQH,CAAS,EAAE,IAAI,CAAC,CAACI,EAAKC,CAAK,IAAM,CAACD,EAAME,EAAW,MAAMD,CAAK,EAAY,IAARA,CAAW,CAAC,EAEvGE,EAAgBJ,EAAQ,IAAI,CAAC,CAACC,CAAG,IAAMA,CAAG,EAC1CI,EAAkBL,EAAQ,IAAI,CAAC,CAAA,CAAGE,CAAK,IAAMA,CAAK,EAElDI,EAAmBX,EAAgBC,EAAS,OAAO,YAAYI,CAAO,CAAC,EAGvEO,EAFmB,IAAI,SAAS,GAAGH,EAAe,UAAUE,CAAgB,GAAG,EAEtC,GAAGD,EAAgB,IAAI,MAAM,CAAC,EAE7E,OAAI,OAAO,MAAM,OAAOE,CAAa,CAAC,EAC7B,IAGFA,EAAc,SAAA,CACvB,EAEaC,EAAiB,CAACC,EAA2BZ,IACjDY,GAAM,IAAKC,IACT,CACL,GAAGA,EACH,MAAOA,GAAM,UAAYX,EAAgBW,EAAK,MAAOb,CAAS,EAAIa,EAAK,KAAA,EAE1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalculatedBlock.js","sources":["../../../../../../../lib/widgets/calculator/ui/calculatorInfo/ui/CalculatedBlock.tsx"],"sourcesContent":["import { cn } from '$/shared/utils'\nimport { type CalculatorRootValue, type CalculatorSuffix, formatWithIntl } from '$/widgets/calculator/model'\n\nexport type CalculatedBlockClasses = {\n wrapper?: string\n description?: string\n value?: string\n}\n\nexport interface CalculatedBlockProps {\n rootDescription: string\n rootValue: CalculatorRootValue\n isFormula: boolean\n suffix: CalculatorSuffix\n classes?: CalculatedBlockClasses\n showCalculatedBlock?: boolean\n}\n\nexport const CalculatedBlock = ({ rootDescription, rootValue, suffix, classes }: CalculatedBlockProps) => {\n return (\n <div className={cn('mb-6 flex items-center justify-between gap-6', classes?.wrapper)}>\n <p className={cn('desk-body-regular-l text-color-dark', classes?.description)}>{rootDescription}</p>\n <div className={cn('desk-title-bold-l flex items-center gap-1 text-color-dark mobile:mob-title-bold-l', classes?.value)}>\n {formatWithIntl(suffix, Number(rootValue))}\n </div>\n </div>\n )\n}\n"],"names":["CalculatedBlock","rootDescription","rootValue","suffix","classes","cn","jsx","formatWithIntl"],"mappings":"kKAkBO,MAAMA,EAAkB,CAAC,CAAE,gBAAAC,EAAiB,UAAAC,EAAW,OAAAC,EAAQ,QAAAC,OAEjE,MAAA,CAAI,UAAWC,EAAG,+CAAgDD,GAAS,OAAO,EACjF,SAAA,CAAAE,EAAC,KAAE,UAAWD,EAAG,sCAAuCD,GAAS,WAAW,EAAI,SAAAH,EAAgB,EAChGK,EAAC,MAAA,CAAI,UAAWD,EAAG,oFAAqFD,GAAS,KAAK,EACnH,SAAAG,EAAeJ,EAAQ,OAAOD,CAAS,CAAC,CAAA,CAC3C,CAAA,EACF"}
|
|
1
|
+
{"version":3,"file":"CalculatedBlock.js","sources":["../../../../../../../lib/widgets/calculator/ui/calculatorInfo/ui/CalculatedBlock.tsx"],"sourcesContent":["import { cn } from '$/shared/utils'\nimport { type CalculatorRootValue, type CalculatorSuffix, formatWithIntl } from '$/widgets/calculator/model'\n\nexport type CalculatedBlockClasses = {\n wrapper?: string\n description?: string\n value?: string\n}\n\nexport interface CalculatedBlockProps {\n rootDescription: string\n rootValue: CalculatorRootValue | undefined\n isFormula: boolean\n suffix: CalculatorSuffix\n classes?: CalculatedBlockClasses\n showCalculatedBlock?: boolean\n}\n\nexport const CalculatedBlock = ({ rootDescription, rootValue, suffix, classes }: CalculatedBlockProps) => {\n return (\n <div className={cn('mb-6 flex items-center justify-between gap-6', classes?.wrapper)}>\n <p className={cn('desk-body-regular-l text-color-dark', classes?.description)}>{rootDescription}</p>\n <div className={cn('desk-title-bold-l flex items-center gap-1 text-color-dark mobile:mob-title-bold-l', classes?.value)}>\n {formatWithIntl(suffix, Number(rootValue))}\n </div>\n </div>\n )\n}\n"],"names":["CalculatedBlock","rootDescription","rootValue","suffix","classes","cn","jsx","formatWithIntl"],"mappings":"kKAkBO,MAAMA,EAAkB,CAAC,CAAE,gBAAAC,EAAiB,UAAAC,EAAW,OAAAC,EAAQ,QAAAC,OAEjE,MAAA,CAAI,UAAWC,EAAG,+CAAgDD,GAAS,OAAO,EACjF,SAAA,CAAAE,EAAC,KAAE,UAAWD,EAAG,sCAAuCD,GAAS,WAAW,EAAI,SAAAH,EAAgB,EAChGK,EAAC,MAAA,CAAI,UAAWD,EAAG,oFAAqFD,GAAS,KAAK,EACnH,SAAAG,EAAeJ,EAAQ,OAAOD,CAAS,CAAC,CAAA,CAC3C,CAAA,EACF"}
|