ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
2 lines (1 loc) • 1.62 kB
JavaScript
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./calculator.js"),u="CALC_UNIT",f=new RegExp(u,"g");function l(r){return typeof r=="number"?`${r}${u}`:r}class s extends h.default{constructor(t,i){super(),this.result="";const e=typeof t;this.unitlessCssVar=i,t instanceof s?this.result=`(${t.result})`:e==="number"?this.result=l(t):e==="string"&&(this.result=t)}add(t){return t instanceof s?this.result=`${this.result} + ${t.getResult()}`:(typeof t=="number"||typeof t=="string")&&(this.result=`${this.result} + ${l(t)}`),this.lowPriority=!0,this}sub(t){return t instanceof s?this.result=`${this.result} - ${t.getResult()}`:(typeof t=="number"||typeof t=="string")&&(this.result=`${this.result} - ${l(t)}`),this.lowPriority=!0,this}mul(t){return this.lowPriority&&(this.result=`(${this.result})`),t instanceof s?this.result=`${this.result} * ${t.getResult(!0)}`:(typeof t=="number"||typeof t=="string")&&(this.result=`${this.result} * ${t}`),this.lowPriority=!1,this}div(t){return this.lowPriority&&(this.result=`(${this.result})`),t instanceof s?this.result=`${this.result} / ${t.getResult(!0)}`:(typeof t=="number"||typeof t=="string")&&(this.result=`${this.result} / ${t}`),this.lowPriority=!1,this}getResult(t){return this.lowPriority||t?`(${this.result})`:this.result}equal(t){const{unit:i}=t||{};let e=!0;return typeof i=="boolean"?e=i:Array.from(this.unitlessCssVar).some(o=>this.result.includes(o))&&(e=!1),this.result=this.result.replace(f,e?"px":""),typeof this.lowPriority<"u"?`calc(${this.result})`:this.result}}exports.default=s;