@cutting/svg 4.30.0 → 4.31.3

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.
Files changed (41) hide show
  1. package/.coverage/clover.xml +81 -0
  2. package/.coverage/coverage-final.json +5 -0
  3. package/.coverage/lcov-report/Group/Group.tsx.html +196 -0
  4. package/.coverage/lcov-report/Group/index.html +116 -0
  5. package/.coverage/lcov-report/Line/Line.tsx.html +199 -0
  6. package/.coverage/lcov-report/Line/index.html +116 -0
  7. package/.coverage/lcov-report/ParentsizeSVG/ParentsizeSVG.tsx.html +250 -0
  8. package/.coverage/lcov-report/ParentsizeSVG/index.html +116 -0
  9. package/.coverage/lcov-report/ResponsiveSVG/ResponsiveSVG.tsx.html +241 -0
  10. package/.coverage/lcov-report/ResponsiveSVG/index.html +116 -0
  11. package/.coverage/lcov-report/base.css +224 -0
  12. package/.coverage/lcov-report/block-navigation.js +87 -0
  13. package/.coverage/lcov-report/favicon.png +0 -0
  14. package/.coverage/lcov-report/index.html +161 -0
  15. package/.coverage/lcov-report/prettify.css +1 -0
  16. package/.coverage/lcov-report/prettify.js +2 -0
  17. package/.coverage/lcov-report/sort-arrow-sprite.png +0 -0
  18. package/.coverage/lcov-report/sorter.js +196 -0
  19. package/.coverage/lcov.info +130 -0
  20. package/.watchmanconfig +1 -0
  21. package/CHANGELOG.md +51 -2
  22. package/demo/App.tsx +6 -7
  23. package/demo/global.css.ts +19 -0
  24. package/demo/tsconfig.json +7 -2
  25. package/dist/cjs/svg.cjs.development.js +14 -17
  26. package/dist/cjs/svg.cjs.development.js.map +1 -1
  27. package/dist/cjs/svg.cjs.production.min.js +1 -1
  28. package/dist/cjs/svg.cjs.production.min.js.map +1 -1
  29. package/dist/esm/index.js +2 -0
  30. package/dist/esm/index.js.map +1 -0
  31. package/dist/umd/index.js +2 -0
  32. package/dist/umd/index.js.map +1 -0
  33. package/package.json +19 -17
  34. package/src/components/ResponsiveSVG/ResponsiveSVG.test.tsx +14 -2
  35. package/tsconfig.dist.json +2 -1
  36. package/tsconfig.json +2 -1
  37. package/demo/global.module.scss +0 -26
  38. package/dist/esm/svg.esm.js +0 -2
  39. package/dist/esm/svg.esm.js.map +0 -1
  40. package/dist/umd/svg.umd.js +0 -2
  41. package/dist/umd/svg.umd.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport const Group: FC<GroupProps> = ({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element => {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n};\n","import type { FC } from 'react';\nimport cx from 'classnames';\nimport { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport const Line: FC<LineProps> = ({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element => {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n};\n"],"names":["ResponsiveSVG","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"6gBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,yBACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,gBAGVC,SACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,WAEJL,uGChCIiB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,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of module?t(exports,require("react/jsx-runtime"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/objectSpread2"),require("@babel/runtime/helpers/objectWithoutProperties"),require("react"),require("@cutting/use-get-parent-size"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@babel/runtime/helpers/slicedToArray","@babel/runtime/helpers/objectSpread2","@babel/runtime/helpers/objectWithoutProperties","react","@cutting/use-get-parent-size","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@cutting/svg"]={},e.jsxRuntime,e._slicedToArray,e._objectSpread,e._objectWithoutProperties,e.React,e.useGetParentSize,e.cx)}(this,(function(e,t,r,i,n,s,a,o){"use strict";function c(e){return e&&e.__esModule?e:{default:e}}var l=c(r),d=c(i),u=c(n),f=c(o);!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var v=function(e){var r=e.width,i=e.children,n=e.origin,s=void 0===n?{x:0,y:0}:n,a=e.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,c=e.innerRef,l=e.className,d=Math.ceil(r/(r/e.height));return t.jsx("div",{"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:t.jsx("svg",{style:{overflow:"visible"},className:l,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(r," ").concat(d),ref:c,children:i},void 0)},void 0)},p=["debounceDelay"],h=["elementRef","children","style","scale","align","options"],x={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},m=["y","x","transform","className","children","innerRef"],b=["from","to","fill","className","innerRef"];e.Group=function(e){var r=e.y,i=void 0===r?0:r,n=e.x,s=void 0===n?0:n,a=e.transform,o=e.className,c=e.children,l=e.innerRef,v=u.default(e,m);return t.jsx("g",d.default(d.default({ref:l,className:f.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(i,")")},v),{},{children:c}),void 0)},e.Line=function(e){var r=e.from,i=void 0===r?{x:0,y:0}:r,n=e.to,s=void 0===n?{x:1,y:1}:n,a=e.fill,o=void 0===a?"transparent":a,c=e.className,l=e.innerRef,v=u.default(e,b),p=i.x===s.x||i.y===s.y;return t.jsx("line",d.default({ref:l,className:f.default("visx-line",c),x1:i.x,y1:i.y,x2:s.x,y2:s.y,fill:o,shapeRendering:p?"crispEdges":"auto"},v),void 0)},e.ParentsizeSVG=function(e){var r=e.elementRef,i=e.children,n=e.style,o=void 0===n?x:n,c=e.scale,f=void 0===c?1:c,m=e.align,b=void 0===m?"none":m,y=e.options,g=(y=void 0===y?{}:y).debounceDelay,j=void 0===g?50:g,R=u.default(y,p),N=u.default(e,h),w=a.useParentSize(r,d.default({debounceDelay:j},R)),S=w.width,q=w.height;s.useEffect((function(){if(r.current)for(var e=0,t=Object.entries(o);e<t.length;e++){var i=l.default(t[e],2);r.current.style[i[0]]=i[1]}}),[r,o]);var P="center"===b?"translate(".concat(S/2,",").concat(q/2-20,") scale(").concat(f,")"):"0,0) scale(".concat(f,")");return t.jsx(v,d.default(d.default({width:S,height:q},N),{},{children:t.jsx("g",{transform:P,children:i},void 0)}),void 0)},e.ResponsiveSVG=v}));
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport const Group: FC<GroupProps> = ({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element => {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n};\n","import type { FC } from 'react';\nimport cx from 'classnames';\nimport { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport const Line: FC<LineProps> = ({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element => {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n};\n"],"names":["ResponsiveSVG","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries"],"mappings":"wkCAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,6BACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,gBAGVC,aACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,WAEJL,uGChCIiB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXR,SAAU,0HCJyB,oBACnCX,EAAAA,aAAI,QACJD,EAAAA,aAAI,IACJqB,IAAAA,UACAjB,IAAAA,UACAN,IAAAA,SACAK,IAAAA,SACGmB,wBAGDb,+BACEK,IAAKX,EACLC,UAAWmB,UAAG,aAAcnB,GAC5BiB,UAAWA,uBAA0BrB,eAAMC,QACvCqB,gBAEHxB,oBCnB4B,oBACjC0B,KAAAA,aAAO,CAAExB,EAAG,EAAGC,EAAG,SAClBwB,GAAAA,aAAK,CAAEzB,EAAG,EAAGC,EAAG,SAChByB,KAAAA,aAAO,gBACPtB,IAAAA,UACAD,IAAAA,SACGmB,iBAEGK,EAAgBH,EAAKxB,IAAMyB,EAAGzB,GAAKwB,EAAKvB,IAAMwB,EAAGxB,SAGrDQ,wBACEK,IAAKX,EACLC,UAAWmB,UAAG,YAAanB,GAC3BwB,GAAIJ,EAAKxB,EACT6B,GAAIL,EAAKvB,EACT6B,GAAIL,EAAGzB,EACP+B,GAAIN,EAAGxB,EACPyB,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CL,4CFTRW,IAAAA,WACAnC,IAAAA,aACAY,MAAAA,aAAQK,QACRmB,MAAAA,aAAQ,QACRC,MAAAA,aAAQ,aACRC,wBAAkD,MAAvCC,cAAAA,aAAgB,KAAOC,iBAC/BC,mBAEuBC,gBAAcP,aAAcI,cAAAA,GAAkBC,IAAhEzC,IAAAA,MAAOW,IAAAA,OAEfiC,aAAU,cACHR,EAAWS,sBAIWC,OAAOC,QAAQlC,kBAAQ,yBAEhDuB,EAAWS,QAAQhC,oBAEpB,CAACuB,EAAYvB,QAEVW,EACM,WAAVc,sBAAkCtC,EAAQ,cAAKW,EAAS,EAAI,sBAAa0B,4BAAyBA,cAGlGzB,MAACb,uBAAcC,MAAOA,EAAOW,OAAQA,GAAY+B,gBAC/C9B,WAAGY,UAAWA,WAAYvB"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cutting/svg",
3
- "version": "4.30.0",
3
+ "version": "4.31.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
7
7
  },
8
- "module": "dist/esm/svg.esm.js",
9
- "browser": "dist/umd/svg.umd.js",
8
+ "module": "dist/esm/index.js",
9
+ "browser": "dist/umd/index.js",
10
10
  "main": "dist/cjs/index.js",
11
11
  "sideEffects": [
12
12
  "**/*.css",
@@ -15,38 +15,40 @@
15
15
  "types": "dist/esm/index.d.ts",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@cutting/util": "4.28.1",
19
- "@cutting/use-get-parent-size": "1.5.1",
18
+ "@cutting/use-get-parent-size": "1.6.3",
19
+ "@cutting/util": "4.29.3",
20
20
  "resize-observer-polyfill": "^1.5.1"
21
21
  },
22
22
  "devDependencies": {
23
- "@cutting/devtools": "4.30.2",
24
- "@cutting/testing": "4.26.1",
25
- "@cutting/eslint-config": "4.26.0",
26
- "@cutting/useful-types": "4.25.1",
27
- "@testing-library/jest-dom": "^5.11.10",
23
+ "@cutting/devtools": "4.31.3",
24
+ "@cutting/eslint-config": "4.28.2",
25
+ "@cutting/tsconfig": "4.26.1",
26
+ "@cutting/useful-types": "4.25.6",
27
+ "@testing-library/jest-dom": "^5.16.1",
28
+ "eslint": "^8.6.0",
28
29
  "react": "^17.0.2",
29
30
  "react-dom": "^17.0.2",
30
- "typescript": "^4.4.3"
31
+ "typescript": "^4.5.3"
31
32
  },
32
33
  "peerDependencies": {
33
- "react": "^17.0.2",
34
- "react-dom": "^17.0.2"
34
+ "react": ">= 17.x.x",
35
+ "react-dom": ">= 17.x.x"
35
36
  },
36
37
  "scripts": {
37
38
  "build": "NODE_ENV=development cutting rollup",
39
+ "lint": "yarn eslint ./src/**/*.{ts,tsx} --fix",
38
40
  "start": "PORT=8888 NODE_ENV=development cutting devserver-start",
39
41
  "test": "NODE_ENV=test cutting test",
40
42
  "test:ci": "CI=true yarn test",
41
- "prepublishOnly": "yarn build"
43
+ "prepack": "yarn build"
42
44
  },
43
45
  "volta": {
44
46
  "extends": "../../package.json"
45
47
  },
46
48
  "exports": {
47
- "import": "./dist/esm/svg.esm.js",
49
+ "import": "./dist/esm/index.js",
48
50
  "require": "./dist/cjs/index.js",
49
- "browser": "./dist/umd/svg.umd.js"
51
+ "browser": "./dist/umd/index.js"
50
52
  },
51
53
  "typesVersions": {
52
54
  "*": {
@@ -55,4 +57,4 @@
55
57
  ]
56
58
  }
57
59
  }
58
- }
60
+ }
@@ -1,11 +1,23 @@
1
- import { describe, it, expect } from '@jest/globals';
1
+ import { describe, it, expect, jest } from '@jest/globals';
2
2
  import type { FC } from 'react';
3
3
  import { render, screen } from '@testing-library/react';
4
- import { resize } from '@cutting/testing';
5
4
  import { useParentSize } from '@cutting/use-get-parent-size';
6
5
  import { useRef } from 'react';
7
6
  import { ResponsiveSVG } from './ResponsiveSVG';
8
7
 
8
+ import ResizeObserver from 'resize-observer-polyfill';
9
+
10
+ jest.mock('resize-observer-polyfill');
11
+
12
+ const resize = (width: number, height: number): void => {
13
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
+ // @ts-ignore
15
+ ResizeObserver.mockImplementation((cb) => {
16
+ cb([{ contentRect: { width, height } }]);
17
+ return { observe: jest.fn(), disconnect: jest.fn(), unobserve: jest.fn() };
18
+ });
19
+ };
20
+
9
21
  const TestEr: FC = () => {
10
22
  const ref = useRef<HTMLDivElement>(null);
11
23
  const { width, height } = useParentSize(ref);
@@ -9,7 +9,8 @@
9
9
  "references": [
10
10
  { "path": "../util/tsconfig.dist.json" },
11
11
  { "path": "../hooks/tsconfig.dist.json" },
12
- { "path": "../component-library/tsconfig.dist.json" }
12
+ { "path": "../component-library/tsconfig.dist.json" },
13
+ { "path": "../use-get-parent-size/tsconfig.dist.json" }
13
14
  ],
14
15
  "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
15
16
  }
package/tsconfig.json CHANGED
@@ -7,7 +7,8 @@
7
7
  "references": [
8
8
  { "path": "../util/tsconfig.dist.json" },
9
9
  { "path": "../hooks/tsconfig.dist.json" },
10
- { "path": "../component-library/tsconfig.dist.json" }
10
+ { "path": "../component-library/tsconfig.dist.json" },
11
+ { "path": "../use-get-parent-size/tsconfig.dist.json" }
11
12
  ],
12
13
  "include": ["src/**/*.ts", "src/**/*.tsx"]
13
14
  }
@@ -1,26 +0,0 @@
1
- $label-default-color: #fff;
2
-
3
- @import '../node_modules/@cutting/component-library/dist/styles/_index.scss';
4
- :global #root {
5
- border: 1px solid green;
6
- }
7
-
8
-
9
- .container {
10
- border: 1px solid yellow;
11
- background: grey;
12
- color: white;
13
- font-weight: bold;
14
- overflow: hidden;
15
- resize: auto;
16
- width: 50%;
17
- height: 50%;
18
- font-weight: bold;
19
- justify-content: center;
20
- align-items: center;
21
- margin: 0 auto;
22
- }
23
-
24
- svg {
25
- border: 1px solid royalblue;
26
- }
@@ -1,2 +0,0 @@
1
- import{jsx as e}from"react/jsx-runtime";import i from"@babel/runtime/helpers/esm/slicedToArray";import r from"@babel/runtime/helpers/esm/objectSpread2";import n from"@babel/runtime/helpers/esm/objectWithoutProperties";import{useEffect as t}from"react";import{useParentSize as o}from"@cutting/use-get-parent-size";import s from"classnames";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var c=function(i){var r=i.width,n=i.children,t=i.origin,o=void 0===t?{x:0,y:0}:t,s=i.preserveAspectRatio,c=void 0===s?"xMaxYMid meet":s,a=i.innerRef,l=i.className,d=Math.ceil(r/(r/i.height));return e("div",Object.assign({"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"}},{children:e("svg",Object.assign({style:{overflow:"visible"},className:l,preserveAspectRatio:c,viewBox:"".concat(o.x," ").concat(o.y," ").concat(r," ").concat(d),ref:a},{children:n}),void 0)}),void 0)},a=["debounceDelay"],l=["elementRef","children","style","scale","align","options"],d={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function v(s){var v=s.elementRef,f=s.children,m=s.style,p=void 0===m?d:m,h=s.scale,u=void 0===h?1:h,g=s.align,x=void 0===g?"none":g,b=s.options,y=(b=void 0===b?{}:b).debounceDelay,j=void 0===y?50:y,N=n(b,a),O=n(s,l),R=o(v,r({debounceDelay:j},N)),w=R.width,D=R.height;t((function(){if(v.current)for(var e=0,r=Object.entries(p);e<r.length;e++){var n=i(r[e],2);v.current.style[n[0]]=n[1]}}),[v,p]);var A="center"===x?"translate(".concat(w/2,",").concat(D/2-20,") scale(").concat(u,")"):"0,0) scale(".concat(u,")");return e(c,Object.assign({width:w,height:D},O,{children:e("g",Object.assign({transform:A},{children:f}),void 0)}),void 0)}var f=["y","x","transform","className","children","innerRef"],m=function(i){var r=i.y,t=void 0===r?0:r,o=i.x,c=void 0===o?0:o,a=i.transform,l=i.className,d=i.children,v=i.innerRef,m=n(i,f);return e("g",Object.assign({ref:v,className:s("visx-group",l),transform:a||"translate(".concat(c,", ").concat(t,")")},m,{children:d}),void 0)},p=["from","to","fill","className","innerRef"],h=function(i){var r=i.from,t=void 0===r?{x:0,y:0}:r,o=i.to,c=void 0===o?{x:1,y:1}:o,a=i.fill,l=void 0===a?"transparent":a,d=i.className,v=i.innerRef,f=n(i,p),m=t.x===c.x||t.y===c.y;return e("line",Object.assign({ref:v,className:s("visx-line",d),x1:t.x,y1:t.y,x2:c.x,y2:c.y,fill:l,shapeRendering:m?"crispEdges":"auto"},f),void 0)};export{m as Group,h as Line,v as ParentsizeSVG,c as ResponsiveSVG};
2
- //# sourceMappingURL=svg.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg.esm.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport const Group: FC<GroupProps> = ({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element => {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n};\n","import type { FC } from 'react';\nimport cx from 'classnames';\nimport { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport const Line: FC<LineProps> = ({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element => {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n};\n"],"names":["ResponsiveSVG","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"6gBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,uCACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,kBAGVC,uBACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAO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xC,EACP8C,GAAIN,EAAGvC,EACPwC,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CN"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/objectSpread2"),require("@babel/runtime/helpers/objectWithoutProperties"),require("react"),require("@cutting/use-get-parent-size"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@babel/runtime/helpers/slicedToArray","@babel/runtime/helpers/objectSpread2","@babel/runtime/helpers/objectWithoutProperties","react","@cutting/use-get-parent-size","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@cutting/svg"]={},e.jsxRuntime,e._slicedToArray,e._objectSpread,e._objectWithoutProperties,e.React,e.useGetParentSize,e.cx)}(this,(function(e,t,i,r,n,s,a,o){"use strict";function c(e){return e&&e.__esModule?e:{default:e}}var l=c(i),d=c(r),u=c(n),f=c(o);!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var v=function(e){var i=e.width,r=e.children,n=e.origin,s=void 0===n?{x:0,y:0}:n,a=e.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,c=e.innerRef,l=e.className,d=Math.ceil(i/(i/e.height));return t.jsx("div",Object.assign({"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"}},{children:t.jsx("svg",Object.assign({style:{overflow:"visible"},className:l,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(i," ").concat(d),ref:c},{children:r}),void 0)}),void 0)},p=["debounceDelay"],h=["elementRef","children","style","scale","align","options"],b={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},x=["y","x","transform","className","children","innerRef"],g=["from","to","fill","className","innerRef"];e.Group=function(e){var i=e.y,r=void 0===i?0:i,n=e.x,s=void 0===n?0:n,a=e.transform,o=e.className,c=e.children,l=e.innerRef,d=u.default(e,x);return t.jsx("g",Object.assign({ref:l,className:f.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(r,")")},d,{children:c}),void 0)},e.Line=function(e){var i=e.from,r=void 0===i?{x:0,y:0}:i,n=e.to,s=void 0===n?{x:1,y:1}:n,a=e.fill,o=void 0===a?"transparent":a,c=e.className,l=e.innerRef,d=u.default(e,g),v=r.x===s.x||r.y===s.y;return t.jsx("line",Object.assign({ref:l,className:f.default("visx-line",c),x1:r.x,y1:r.y,x2:s.x,y2:s.y,fill:o,shapeRendering:v?"crispEdges":"auto"},d),void 0)},e.ParentsizeSVG=function(e){var i=e.elementRef,r=e.children,n=e.style,o=void 0===n?b:n,c=e.scale,f=void 0===c?1:c,x=e.align,g=void 0===x?"none":x,m=e.options,y=(m=void 0===m?{}:m).debounceDelay,j=void 0===y?50:y,R=u.default(m,p),N=u.default(e,h),O=a.useParentSize(i,d.default({debounceDelay:j},R)),w=O.width,S=O.height;s.useEffect((function(){if(i.current)for(var e=0,t=Object.entries(o);e<t.length;e++){var r=l.default(t[e],2);i.current.style[r[0]]=r[1]}}),[i,o]);var q="center"===g?"translate(".concat(w/2,",").concat(S/2-20,") scale(").concat(f,")"):"0,0) scale(".concat(f,")");return t.jsx(v,Object.assign({width:w,height:S},N,{children:t.jsx("g",Object.assign({transform:q},{children:r}),void 0)}),void 0)},e.ResponsiveSVG=v}));
2
- //# sourceMappingURL=svg.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svg.umd.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport const Group: FC<GroupProps> = ({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element => {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n};\n","import type { FC } from 'react';\nimport cx from 'classnames';\nimport { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport const Line: FC<LineProps> = ({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element => {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n};\n"],"names":["ResponsiveSVG","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries"],"mappings":"wkCAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,2CACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,kBAGVC,2BACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,aAEJL,yGChCIiB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXR,SAAU,0HCJyB,oBACnCX,EAAAA,aAAI,QACJD,EAAAA,aAAI,IACJqB,IAAAA,UACAjB,IAAAA,UACAN,IAAAA,SACAK,IAAAA,SACGmB,wBAGDb,yBACEK,IAAKX,EACLC,UAAWmB,UAAG,aAAcnB,GAC5BiB,UAAWA,uBAA0BrB,eAAMC,QACvCqB,YAEHxB,oBCnB4B,oBACjC0B,KAAAA,aAAO,CAAExB,EAAG,EAAGC,EAAG,SAClBwB,GAAAA,aAAK,CAAEzB,EAAG,EAAGC,EAAG,SAChByB,KAAAA,aAAO,gBACPtB,IAAAA,UACAD,IAAAA,SACGmB,iBAEGK,EAAgBH,EAAKxB,IAAMyB,EAAGzB,GAAKwB,EAAKvB,IAAMwB,EAAGxB,SAGrDQ,4BACEK,IAAKX,EACLC,UAAWmB,UAAG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