1 line
28 KiB
Text
1 line
28 KiB
Text
|
{"version":3,"file":"preview-Cdum89jS.js","sources":["../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../node_modules/@storybook/addon-measure/dist/preview.mjs"],"sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","import { useEffect } from 'storybook/internal/preview-api';\nimport { global } from '@storybook/global';\nimport invariant from 'tiny-invariant';\n\nfunction getDocumentWidthAndHeight(){let container=global.document.documentElement,height=Math.max(container.scrollHeight,container.offsetHeight);return {width:Math.max(container.scrollWidth,container.offsetWidth),height}}function createCanvas(){let canvas=global.document.createElement(\"canvas\");canvas.id=\"storybook-addon-measure\";let context=canvas.getContext(\"2d\");invariant(context!=null);let{width,height}=getDocumentWidthAndHeight();return setCanvasWidthAndHeight(canvas,context,{width,height}),canvas.style.position=\"absolute\",canvas.style.left=\"0\",canvas.style.top=\"0\",canvas.style.zIndex=\"2147483647\",canvas.style.pointerEvents=\"none\",global.document.body.appendChild(canvas),{canvas,context,width,height}}function setCanvasWidthAndHeight(canvas,context,{width,height}){canvas.style.width=`${width}px`,canvas.style.height=`${height}px`;let scale=global.window.devicePixelRatio;canvas.width=Math.floor(width*scale),canvas.height=Math.floor(height*scale),context.scale(scale,scale);}var state={};function init(){state.canvas||(state=createCanvas());}function clear(){state.context&&state.context.clearRect(0,0,state.width??0,state.height??0);}function draw(callback){clear(),callback(state.context);}function rescale(){invariant(state.canvas,\"Canvas should exist in the state.\"),invariant(state.context,\"Context should exist in the state.\"),setCanvasWidthAndHeight(state.canvas,state.context,{width:0,height:0});let{width,height}=getDocumentWidthAndHeight();setCanvasWidthAndHeight(state.canvas,state.context,{width,height}),state.width=width,state.height=height;}function destroy(){state.canvas&&(clear(),state.canvas.parentNode?.removeChild(state.canvas),state={});}var colors={margin:\"#f6b26b\",border:\"#ffe599\",padding:\"#93c47d\",content:\"#6fa8dc\",text:\"#232020\"},labelPadding=6;function roundedRect(context,{x,y,w,h,r}){x=x-w/2,y=y-h/2,w<2*r&&(r=w/2),h<2*r&&(r=h/2),context.beginPath(),context.moveTo(x+r,y),context.arcTo(x+w,y,x+w,y+h,r),context.arcTo(x+w,y+h,x,y+h,r),context.arcTo(x,y+h,x,y,r),context.arcTo(x,y,x+w,y,r),context.closePath();}function positionCoordinate(position,{padding,border,width,height,top,left}){let contentWidth=width-border.left-border.right-padding.left-padding.right,contentHeight=height-padding.top-padding.bottom-border.top-border.bottom,x=left+border.left+padding.left,y=top+border.top+padding.top;return position===\"top\"?x+=contentWidth/2:position===\"right\"?(x+=contentWidth,y+=contentHeight/2):position===\"bottom\"?(x+=contentWidth/2,y+=contentHeight):position===\"left\"?y+=contentHeight/2:position===\"center\"&&(x+=contentWidth/2,y+=contentHeight/2),{x,y}}function offset(type,position,{margin,border,padding},labelPaddingSize,external){let shift=dir=>0,offsetX=0,offsetY=0,locationMultiplier=external?1:.5,labelPaddingShift=external?labelPaddingSize*2:0;return type===\"padding\"?shift=dir=>padding[dir]*locationMultiplier+labelPaddingShift:type===\"border\"?shift=dir=>padding[dir]+border[dir]*locationMultiplier+labelPaddingShift:type===\"margin\"&&(shift=dir=>padding[dir]+border[dir]+margin[dir]*locationMultiplier+labelPaddingShift),position===\"top\"?offsetY=-shift(\"top\"):position===\"right\"?offsetX=shift(\"right\"):position===\"bottom\"?offsetY=shift(\"bottom\"):position===\"
|