@scbt-ecom/ui 0.179.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.
@@ -1,2 +1,2 @@
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};
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.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, 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,EAAiBC,KACbD,EAAQ,MAAM,2BAA2B,GAAK,CAAA,GAC7B,OAAQE,GAAY,EAAEA,KAAWD,EAAU,EAElE,OAAS,EACrB,GAIFD,EAGIG,EAAkB,CAACH,EAAiBC,IAA2C,CAC1F,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
+ {"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"}
@@ -1,2 +1,2 @@
1
- import{jsxs as r,jsx as e}from"react/jsx-runtime";import{formatValueToRenderInfoItem as c}from"../../../model/utils.js";import{cn as d}from"../../../../../shared/utils/cn.js";import{Popover as p}from"../../../../../shared/ui/popover/Popover.js";import{Icon as f}from"../../../../../shared/ui/icon/Icon.js";import{pushToDlTooltip as u}from"../../../../../shared/dataLayers/utils.js";const I=({hint:o,value:l,label:t,mode:i,prefix:s,fontSize:m=18,color:a="dark",accent:n=!1})=>r("div",{className:"flex items-center justify-between gap-4",children:[r("div",{className:"flex items-center gap-2",children:[e("p",{className:"desk-body-regular-l text-color-dark",children:t}),o&&e(p,{triggerProps:{onPointerDown:()=>u({title:t,placement:"calculator"})},withCloseBtn:!1,triggerElement:e(f,{className:"size-5 text-icon-blue-grey-600",name:"info/helpCircle"}),children:e("p",{children:o})})]}),r("span",{style:{fontSize:`${m}px`},className:d("desk-body-medium-l text-color-dark",{"[&&]:desk-title-bold-s":n,"text-color-primary-default":a==="blue"}),children:[s," ",c(i,l)]})]});export{I as InfoListItem};
1
+ import{jsxs as r,jsx as e}from"react/jsx-runtime";import{formatValueToRenderInfoItem as c}from"../../../model/utils.js";import{cn as d}from"../../../../../shared/utils/cn.js";import{Popover as p}from"../../../../../shared/ui/popover/Popover.js";import{Icon as f}from"../../../../../shared/ui/icon/Icon.js";import{pushToDlTooltip as u}from"../../../../../shared/dataLayers/utils.js";const I=({hint:o,value:l,label:t,mode:i,prefix:s,fontSize:m="18",color:a="dark",accent:n=!1})=>r("div",{className:"flex items-center justify-between gap-4",children:[r("div",{className:"flex items-center gap-2",children:[e("p",{className:"desk-body-regular-l text-color-dark",children:t}),o&&e(p,{triggerProps:{onPointerDown:()=>u({title:t,placement:"calculator"})},withCloseBtn:!1,triggerElement:e(f,{className:"size-5 text-icon-blue-grey-600",name:"info/helpCircle"}),children:e("p",{children:o})})]}),r("span",{style:{fontSize:`${m}px`},className:d("desk-body-medium-l text-color-dark",{"[&&]:desk-title-bold-s":n,"text-color-primary-default":a==="blue"}),children:[s," ",c(i,l)]})]});export{I as InfoListItem};
2
2
  //# sourceMappingURL=InfoListItem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InfoListItem.js","sources":["../../../../../../../lib/widgets/calculator/ui/calculatorInfo/ui/InfoListItem.tsx"],"sourcesContent":["import { pushToDlTooltip } from '$/shared/dataLayers'\nimport { Icon, Popover } from '$/shared/ui'\nimport { cn } from '$/shared/utils'\nimport { type CalculatorSuffix, formatValueToRenderInfoItem } from '$/widgets/calculator/model'\n\nexport type InfoListItemMode = CalculatorSuffix | 'text'\nexport type InfoListItemColor = 'dark' | 'blue'\nexport type InfoListItemValue = string\n\nexport interface InfoListItemProps {\n label: string\n mode: InfoListItemMode\n hint?: string\n accent?: boolean\n color?: InfoListItemColor\n isFormula: boolean\n value: InfoListItemValue\n prefix?: string\n fontSize?: number\n}\n\nexport const InfoListItem = ({\n hint,\n value,\n label,\n mode,\n prefix,\n fontSize = 18,\n color = 'dark',\n accent = false\n}: InfoListItemProps) => {\n return (\n <div className='flex items-center justify-between gap-4'>\n <div className='flex items-center gap-2'>\n <p className='desk-body-regular-l text-color-dark'>{label}</p>\n {hint && (\n <Popover\n triggerProps={{\n onPointerDown: () => pushToDlTooltip({ title: label, placement: 'calculator' })\n }}\n withCloseBtn={false}\n triggerElement={<Icon className='size-5 text-icon-blue-grey-600' name='info/helpCircle' />}\n >\n <p>{hint}</p>\n </Popover>\n )}\n </div>\n <span\n style={{ fontSize: `${fontSize}px` }}\n className={cn('desk-body-medium-l text-color-dark', {\n '[&&]:desk-title-bold-s': accent,\n 'text-color-primary-default': color === 'blue'\n })}\n >\n {prefix} {formatValueToRenderInfoItem(mode, value)}\n </span>\n </div>\n )\n}\n"],"names":["InfoListItem","hint","value","label","mode","prefix","fontSize","color","accent","jsxs","jsx","Popover","pushToDlTooltip","Icon","cn","formatValueToRenderInfoItem"],"mappings":"8XAqBO,MAAMA,EAAe,CAAC,CAC3B,KAAAC,EACA,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,GACX,MAAAC,EAAQ,OACR,OAAAC,EAAS,EACX,IAEIC,EAAC,MAAA,CAAI,UAAU,0CACb,SAAA,CAAAA,EAAC,MAAA,CAAI,UAAU,0BACb,SAAA,CAAAC,EAAC,IAAA,CAAE,UAAU,sCAAuC,SAAAP,EAAM,EACzDF,GACCS,EAACC,EAAA,CACC,aAAc,CACZ,cAAe,IAAMC,EAAgB,CAAE,MAAOT,EAAO,UAAW,aAAc,CAAA,EAEhF,aAAc,GACd,eAAgBO,EAACG,EAAA,CAAK,UAAU,iCAAiC,KAAK,kBAAkB,EAExF,SAAAH,EAAC,KAAG,SAAAT,CAAA,CAAK,CAAA,CAAA,CACX,EAEJ,EACAQ,EAAC,OAAA,CACC,MAAO,CAAE,SAAU,GAAGH,CAAQ,IAAA,EAC9B,UAAWQ,EAAG,qCAAsC,CAClD,yBAA0BN,EAC1B,6BAA8BD,IAAU,MAAA,CACzC,EAEA,SAAA,CAAAF,EAAO,IAAEU,EAA4BX,EAAMF,CAAK,CAAA,CAAA,CAAA,CACnD,EACF"}
1
+ {"version":3,"file":"InfoListItem.js","sources":["../../../../../../../lib/widgets/calculator/ui/calculatorInfo/ui/InfoListItem.tsx"],"sourcesContent":["import { pushToDlTooltip } from '$/shared/dataLayers'\nimport { Icon, Popover } from '$/shared/ui'\nimport { cn } from '$/shared/utils'\nimport { type CalculatorSuffix, formatValueToRenderInfoItem } from '$/widgets/calculator/model'\n\nexport type InfoListItemMode = CalculatorSuffix | 'text'\nexport type InfoListItemColor = 'dark' | 'blue'\nexport type InfoListItemValue = string\n\nexport interface InfoListItemProps {\n label: string\n mode: InfoListItemMode\n hint?: string\n accent?: boolean\n color?: InfoListItemColor\n isFormula: boolean\n value: InfoListItemValue\n prefix?: string\n fontSize?: string\n}\n\nexport const InfoListItem = ({\n hint,\n value,\n label,\n mode,\n prefix,\n fontSize = '18',\n color = 'dark',\n accent = false\n}: InfoListItemProps) => {\n return (\n <div className='flex items-center justify-between gap-4'>\n <div className='flex items-center gap-2'>\n <p className='desk-body-regular-l text-color-dark'>{label}</p>\n {hint && (\n <Popover\n triggerProps={{\n onPointerDown: () => pushToDlTooltip({ title: label, placement: 'calculator' })\n }}\n withCloseBtn={false}\n triggerElement={<Icon className='size-5 text-icon-blue-grey-600' name='info/helpCircle' />}\n >\n <p>{hint}</p>\n </Popover>\n )}\n </div>\n <span\n style={{ fontSize: `${fontSize}px` }}\n className={cn('desk-body-medium-l text-color-dark', {\n '[&&]:desk-title-bold-s': accent,\n 'text-color-primary-default': color === 'blue'\n })}\n >\n {prefix} {formatValueToRenderInfoItem(mode, value)}\n </span>\n </div>\n )\n}\n"],"names":["InfoListItem","hint","value","label","mode","prefix","fontSize","color","accent","jsxs","jsx","Popover","pushToDlTooltip","Icon","cn","formatValueToRenderInfoItem"],"mappings":"8XAqBO,MAAMA,EAAe,CAAC,CAC3B,KAAAC,EACA,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,KACX,MAAAC,EAAQ,OACR,OAAAC,EAAS,EACX,IAEIC,EAAC,MAAA,CAAI,UAAU,0CACb,SAAA,CAAAA,EAAC,MAAA,CAAI,UAAU,0BACb,SAAA,CAAAC,EAAC,IAAA,CAAE,UAAU,sCAAuC,SAAAP,EAAM,EACzDF,GACCS,EAACC,EAAA,CACC,aAAc,CACZ,cAAe,IAAMC,EAAgB,CAAE,MAAOT,EAAO,UAAW,aAAc,CAAA,EAEhF,aAAc,GACd,eAAgBO,EAACG,EAAA,CAAK,UAAU,iCAAiC,KAAK,kBAAkB,EAExF,SAAAH,EAAC,KAAG,SAAAT,CAAA,CAAK,CAAA,CAAA,CACX,EAEJ,EACAQ,EAAC,OAAA,CACC,MAAO,CAAE,SAAU,GAAGH,CAAQ,IAAA,EAC9B,UAAWQ,EAAG,qCAAsC,CAClD,yBAA0BN,EAC1B,6BAA8BD,IAAU,MAAA,CACzC,EAEA,SAAA,CAAAF,EAAO,IAAEU,EAA4BX,EAAMF,CAAK,CAAA,CAAA,CAAA,CACnD,EACF"}