UNPKG

ant-design-x-vue

Version:

Craft AI-driven interfaces effortlessly

2 lines (1 loc) 10.2 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const x=require("../../theme/genStyleUtils.js"),H=require("./fileCard.js");require("vue");require("../../_util/cssinjs/StyleContext.js");require("../../_util/cssinjs/theme/ThemeCache.js");require("../../_util/warning.js");require("../../_util/cssinjs/transformers/legacyLogicalProperties.js");const $=require("../../_util/cssinjs-utils/util/statistic.js");function b(s){"@babel/helpers - typeof";return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},b(s)}function w(s,t){if(b(s)!="object"||!s)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var e=i.call(s,t);if(b(e)!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function M(s){var t=w(s,"string");return b(t)=="symbol"?t:t+""}function c(s,t,i){return(t=M(t))in s?Object.defineProperty(s,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):s[t]=i,s}const o=Math.round;function m(s,t){const i=s.replace(/^[^(]*\((.*)/,"$1").replace(/\).*/,"").match(/\d*\.?\d+%?/g)||[],e=i.map(r=>parseFloat(r));for(let r=0;r<3;r+=1)e[r]=t(e[r]||0,i[r]||"",r);return i[3]?e[3]=i[3].includes("%")?e[3]/100:e[3]:e[3]=1,e}const S=(s,t,i)=>i===0?s:s/100;function u(s,t){const i=t||255;return s>i?i:s<0?0:s}class v{constructor(t){c(this,"isValid",!0),c(this,"r",0),c(this,"g",0),c(this,"b",0),c(this,"a",1),c(this,"_h",void 0),c(this,"_s",void 0),c(this,"_l",void 0),c(this,"_v",void 0),c(this,"_max",void 0),c(this,"_min",void 0),c(this,"_brightness",void 0);function i(e){return e[0]in t&&e[1]in t&&e[2]in t}if(t)if(typeof t=="string"){let r=function(n){return e.startsWith(n)};const e=t.trim();/^#?[A-F\d]{3,8}$/i.test(e)?this.fromHexString(e):r("rgb")?this.fromRgbString(e):r("hsl")?this.fromHslString(e):(r("hsv")||r("hsb"))&&this.fromHsvString(e)}else if(t instanceof v)this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this._h=t._h,this._s=t._s,this._l=t._l,this._v=t._v;else if(i("rgb"))this.r=u(t.r),this.g=u(t.g),this.b=u(t.b),this.a=typeof t.a=="number"?u(t.a,1):1;else if(i("hsl"))this.fromHsl(t);else if(i("hsv"))this.fromHsv(t);else throw new Error("@ant-design/fast-color: unsupported input "+JSON.stringify(t))}setR(t){return this._sc("r",t)}setG(t){return this._sc("g",t)}setB(t){return this._sc("b",t)}setA(t){return this._sc("a",t,1)}setHue(t){const i=this.toHsv();return i.h=t,this._c(i)}getLuminance(){function t(n){const l=n/255;return l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4)}const i=t(this.r),e=t(this.g),r=t(this.b);return .2126*i+.7152*e+.0722*r}getHue(){if(typeof this._h>"u"){const t=this.getMax()-this.getMin();t===0?this._h=0:this._h=o(60*(this.r===this.getMax()?(this.g-this.b)/t+(this.g<this.b?6:0):this.g===this.getMax()?(this.b-this.r)/t+2:(this.r-this.g)/t+4))}return this._h}getSaturation(){if(typeof this._s>"u"){const t=this.getMax()-this.getMin();t===0?this._s=0:this._s=t/this.getMax()}return this._s}getLightness(){return typeof this._l>"u"&&(this._l=(this.getMax()+this.getMin())/510),this._l}getValue(){return typeof this._v>"u"&&(this._v=this.getMax()/255),this._v}getBrightness(){return typeof this._brightness>"u"&&(this._brightness=(this.r*299+this.g*587+this.b*114)/1e3),this._brightness}darken(t=10){const i=this.getHue(),e=this.getSaturation();let r=this.getLightness()-t/100;return r<0&&(r=0),this._c({h:i,s:e,l:r,a:this.a})}lighten(t=10){const i=this.getHue(),e=this.getSaturation();let r=this.getLightness()+t/100;return r>1&&(r=1),this._c({h:i,s:e,l:r,a:this.a})}mix(t,i=50){const e=this._c(t),r=i/100,n=g=>(e[g]-this[g])*r+this[g],l={r:o(n("r")),g:o(n("g")),b:o(n("b")),a:o(n("a")*100)/100};return this._c(l)}tint(t=10){return this.mix({r:255,g:255,b:255,a:1},t)}shade(t=10){return this.mix({r:0,g:0,b:0,a:1},t)}onBackground(t){const i=this._c(t),e=this.a+i.a*(1-this.a),r=n=>o((this[n]*this.a+i[n]*i.a*(1-this.a))/e);return this._c({r:r("r"),g:r("g"),b:r("b"),a:e})}isDark(){return this.getBrightness()<128}isLight(){return this.getBrightness()>=128}equals(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a}clone(){return this._c(this)}toHexString(){let t="#";const i=(this.r||0).toString(16);t+=i.length===2?i:"0"+i;const e=(this.g||0).toString(16);t+=e.length===2?e:"0"+e;const r=(this.b||0).toString(16);if(t+=r.length===2?r:"0"+r,typeof this.a=="number"&&this.a>=0&&this.a<1){const n=o(this.a*255).toString(16);t+=n.length===2?n:"0"+n}return t}toHsl(){return{h:this.getHue(),s:this.getSaturation(),l:this.getLightness(),a:this.a}}toHslString(){const t=this.getHue(),i=o(this.getSaturation()*100),e=o(this.getLightness()*100);return this.a!==1?`hsla(${t},${i}%,${e}%,${this.a})`:`hsl(${t},${i}%,${e}%)`}toHsv(){return{h:this.getHue(),s:this.getSaturation(),v:this.getValue(),a:this.a}}toRgb(){return{r:this.r,g:this.g,b:this.b,a:this.a}}toRgbString(){return this.a!==1?`rgba(${this.r},${this.g},${this.b},${this.a})`:`rgb(${this.r},${this.g},${this.b})`}toString(){return this.toRgbString()}_sc(t,i,e){const r=this.clone();return r[t]=u(i,e),r}_c(t){return new this.constructor(t)}getMax(){return typeof this._max>"u"&&(this._max=Math.max(this.r,this.g,this.b)),this._max}getMin(){return typeof this._min>"u"&&(this._min=Math.min(this.r,this.g,this.b)),this._min}fromHexString(t){const i=t.replace("#","");function e(r,n){return parseInt(i[r]+i[n||r],16)}i.length<6?(this.r=e(0),this.g=e(1),this.b=e(2),this.a=i[3]?e(3)/255:1):(this.r=e(0,1),this.g=e(2,3),this.b=e(4,5),this.a=i[6]?e(6,7)/255:1)}fromHsl({h:t,s:i,l:e,a:r}){if(this._h=t%360,this._s=i,this._l=e,this.a=typeof r=="number"?r:1,i<=0){const p=o(e*255);this.r=p,this.g=p,this.b=p}let n=0,l=0,g=0;const h=t/60,a=(1-Math.abs(2*e-1))*i,d=a*(1-Math.abs(h%2-1));h>=0&&h<1?(n=a,l=d):h>=1&&h<2?(n=d,l=a):h>=2&&h<3?(l=a,g=d):h>=3&&h<4?(l=d,g=a):h>=4&&h<5?(n=d,g=a):h>=5&&h<6&&(n=a,g=d);const f=e-a/2;this.r=o((n+f)*255),this.g=o((l+f)*255),this.b=o((g+f)*255)}fromHsv({h:t,s:i,v:e,a:r}){this._h=t%360,this._s=i,this._v=e,this.a=typeof r=="number"?r:1;const n=o(e*255);if(this.r=n,this.g=n,this.b=n,i<=0)return;const l=t/60,g=Math.floor(l),h=l-g,a=o(e*(1-i)*255),d=o(e*(1-i*h)*255),f=o(e*(1-i*(1-h))*255);switch(g){case 0:this.g=f,this.b=a;break;case 1:this.r=d,this.b=a;break;case 2:this.r=a,this.b=f;break;case 3:this.r=a,this.g=d;break;case 4:this.r=f,this.g=a;break;case 5:default:this.g=a,this.b=d;break}}fromHsvString(t){const i=m(t,S);this.fromHsv({h:i[0],s:i[1],v:i[2],a:i[3]})}fromHslString(t){const i=m(t,S);this.fromHsl({h:i[0],s:i[1],l:i[2],a:i[3]})}fromRgbString(t){const i=m(t,(e,r)=>r.includes("%")?o(e/100*255):e);this.r=i[0],this.g=i[1],this.b=i[2],this.a=i[3]}}const _={"&, *":{boxSizing:"border-box"}},B=s=>{const{componentCls:t,calc:i,antCls:e}=s,r=`${t}-drop-area`,n=`${t}-placeholder`;return{[r]:{position:"absolute",inset:0,zIndex:s.zIndexPopupBase,..._,"&-on-body":{position:"fixed",inset:0},"&-hide-placement":{[`${n}-inner`]:{display:"none"}},[n]:{padding:0}},"&":{[n]:{height:"100%",borderRadius:s.borderRadius,borderWidth:s.lineWidthBold,borderStyle:"dashed",borderColor:"transparent",padding:s.padding,position:"relative",backdropFilter:"blur(10px)",..._,[`${e}-upload-wrapper ${e}-upload${e}-upload-btn`]:{padding:0},[`&${n}-drag-in`]:{borderColor:s.colorPrimaryHover},[`&${n}-disabled`]:{opacity:.25,pointerEvents:"none"},[`${n}-inner`]:{gap:i(s.paddingXXS).div(2).equal()},[`${n}-icon`]:{fontSize:s.fontSizeHeading2,lineHeight:1},[`${n}-title${n}-title`]:{margin:0,fontSize:s.fontSize,lineHeight:s.lineHeight},[`${n}-description`]:{}}}}},C=s=>{const{componentCls:t,calc:i}=s,e=`${t}-list`,r=i(s.fontSize).mul(s.lineHeight).mul(2).add(s.paddingSM).add(s.paddingSM).equal();return{[t]:{position:"relative",width:"100%",..._,[e]:{display:"flex",flexWrap:"wrap",gap:s.paddingSM,fontSize:s.fontSize,lineHeight:s.lineHeight,color:s.colorText,paddingBlock:s.paddingSM,paddingInline:s.padding,width:"100%",background:s.colorBgContainer,scrollbarWidth:"none","-ms-overflow-style":"none","&::-webkit-scrollbar":{display:"none"},"&-overflow-scrollX, &-overflow-scrollY":{"&:before, &:after":{content:'""',position:"absolute",opacity:0,transition:`opacity ${s.motionDurationSlow}`,zIndex:1}},"&-overflow-ping-start:before":{opacity:1},"&-overflow-ping-end:after":{opacity:1},"&-overflow-scrollX":{overflowX:"auto",overflowY:"hidden",flexWrap:"nowrap","&:before, &:after":{insetBlock:0,width:8},"&:before":{insetInlineStart:0,background:"linear-gradient(to right, rgba(0,0,0,0.06), rgba(0,0,0,0));"},"&:after":{insetInlineEnd:0,background:"linear-gradient(to left, rgba(0,0,0,0.06), rgba(0,0,0,0));"},"&:dir(rtl)":{"&:before":{background:"linear-gradient(to left, rgba(0,0,0,0.06), rgba(0,0,0,0));"},"&:after":{background:"linear-gradient(to right, rgba(0,0,0,0.06), rgba(0,0,0,0));"}}},"&-overflow-scrollY":{overflowX:"hidden",overflowY:"auto",maxHeight:i(r).mul(3).equal(),"&:before, &:after":{insetInline:0,height:8},"&:before":{insetBlockStart:0,background:"linear-gradient(to bottom, rgba(0,0,0,0.06), rgba(0,0,0,0));"},"&:after":{insetBlockEnd:0,background:"linear-gradient(to top, rgba(0,0,0,0.06), rgba(0,0,0,0));"}},"&-upload-btn":{width:r,height:r,fontSize:s.fontSizeHeading2,color:"#999"},"&-prev-btn, &-next-btn":{position:"absolute",top:"50%",transform:"translateY(-50%)",boxShadow:s.boxShadowTertiary,opacity:0,pointerEvents:"none"},"&-prev-btn":{left:{_skip_check_:!0,value:s.padding}},"&-next-btn":{right:{_skip_check_:!0,value:s.padding}},"&:dir(ltr)":{[`&${e}-overflow-ping-start ${e}-prev-btn`]:{opacity:1,pointerEvents:"auto"},[`&${e}-overflow-ping-end ${e}-next-btn`]:{opacity:1,pointerEvents:"auto"}},"&:dir(rtl)":{[`&${e}-overflow-ping-end ${e}-prev-btn`]:{opacity:1,pointerEvents:"auto"},[`&${e}-overflow-ping-start ${e}-next-btn`]:{opacity:1,pointerEvents:"auto"}}}}}},y=s=>{const{colorBgContainer:t}=s;return{colorBgPlaceholderHover:new v(t).setA(.85).toRgbString()}},P=x.genStyleHooks("Attachments",s=>{const t=$.merge(s,{});return[B(t),C(t),H.default(t)]},y);exports.default=P;exports.prepareComponentToken=y;