@cutting/svg 4.52.0 → 4.52.1

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,5 +1,5 @@
1
1
 
2
- > @cutting/svg@4.52.0 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
2
+ > @cutting/svg@4.52.1 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
3
3
  > NODE_ENV=production devtools rollup
4
4
 
5
5
  DEBUG using tsconfig.dist.json
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @cutting/svg
2
2
 
3
+ ## 4.52.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7405910f: fix use-get-parentsize constant resizing problem
8
+ - Updated dependencies [7405910f]
9
+ - @cutting/react-abortable-fetch@0.35.1
10
+ - @cutting/use-get-parent-size@1.26.1
11
+ - @cutting/util@4.57.1
12
+
3
13
  ## 4.52.0
4
14
 
5
15
  ### Minor Changes
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useEffect as r}from"react";import{useParentSize as t}from"@cutting/use-get-parent-size";import n from"classnames";function i({height:r,width:t,children:n,origin:i={x:0,y:0},preserveAspectRatio:s="xMaxYMid meet",innerRef:l,className:o,...a}){const c=Math.ceil(t/(t/r));return e("div",{"data-testid":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:e("svg",{style:{overflow:"visible"},className:o,preserveAspectRatio:s,viewBox:`${i.x} ${i.y} ${t} ${c}`,ref:l,...a,children:n})})}const s={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function l({parentRef:n,children:l,style:o=s,scale:a=1,align:c="none",options:{debounceDelay:f=50,...x}={},...h}){const{width:d,height:m}=t(n,{debounceDelay:f,...x});return r((()=>{if(n.current)for(const[e,r]of Object.entries(o))n.current.style[e]=r}),[n,o]),e(i,{width:d,height:m,...h,children:e("g",{transform:"center"===c?`translate(${d/2},${m/2-20}) scale(${a})`:`translate(0,0) scale(${a})`,children:l})})}function o({y:r=0,x:t=0,transform:i,className:s,children:l,innerRef:o,...a}){return e("g",{ref:o,className:n("visx-group",s),transform:i||`translate(${t}, ${r})`,...a,children:l})}function a({from:r={x:0,y:0},to:t={x:1,y:1},fill:i="transparent",className:s,innerRef:l,...o}){const a=r.x===t.x||r.y===t.y;return e("line",{ref:l,className:n("visx-line",s),x1:r.x,y1:r.y,x2:t.x,y2:t.y,fill:i,shapeRendering:a?"crispEdges":"auto",...o})}export{o as Group,a as Line,l as ParentsizeSVG,i as ResponsiveSVG};
1
+ import{jsx as e}from"react/jsx-runtime";import{useEffect as r}from"react";import{useParentSize as t}from"@cutting/use-get-parent-size";import n from"classnames";function i({height:r,width:t,children:n,origin:i={x:0,y:0},preserveAspectRatio:s="xMaxYMid meet",innerRef:l,className:o,...a}){const c=Math.ceil(t/(0===r?1:t/r));return e("div",{"data-testid":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:e("svg",{style:{overflow:"visible"},className:o,preserveAspectRatio:s,viewBox:`${i.x} ${i.y} ${t} ${c}`,ref:l,...a,children:n})})}const s={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function l({parentRef:n,children:l,style:o=s,scale:a=1,align:c="none",options:{debounceDelay:f=50,...x}={},...h}){const{width:d,height:m}=t(n,{debounceDelay:f,...x});return r((()=>{if(n.current)for(const[e,r]of Object.entries(o))n.current.style[e]=r}),[n,o]),e(i,{width:d,height:m,...h,children:e("g",{transform:"center"===c?`translate(${d/2},${m/2-20}) scale(${a})`:`translate(0,0) scale(${a})`,children:l})})}function o({y:r=0,x:t=0,transform:i,className:s,children:l,innerRef:o,...a}){return e("g",{ref:o,className:n("visx-group",s),transform:i||`translate(${t}, ${r})`,...a,children:l})}function a({from:r={x:0,y:0},to:t={x:1,y:1},fill:i="transparent",className:s,innerRef:l,...o}){const a=r.x===t.x||r.y===t.y;return e("line",{ref:l,className:n("visx-line",s),x1:r.x,y1:r.y,x2:t.x,y2:t.y,fill:i,shapeRendering:a?"crispEdges":"auto",...o})}export{o as Group,a as Line,l as ParentsizeSVG,i as ResponsiveSVG};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +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 { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio, SVGAttributes } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport type ResponsiveSVGProps = SVGAttributes<{\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}>;\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n ...props\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-testid=\"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 {...props}\n >\n {children}\n </svg>\n </div>\n );\n}\n","import type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG.js';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useEffect } from 'react';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {\n parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, style]);\n\n const transform =\n align === 'center'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(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 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 function Group({\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 cx from 'classnames';\nimport type { 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 function Line({\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","height","width","children","origin","x","y","preserveAspectRatio","innerRef","className","props","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","parentRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","key","value","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"iKAmBgB,SAAAA,GAAcC,OAC5BA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,OACRA,EAAS,CAAEC,EAAG,EAAGC,EAAG,GAAGC,oBACvBA,EAAsB,gBAAeC,SACrCA,EAAQC,UACRA,KACGC,IAEH,MAEMC,EAAiBC,KAAKC,KAAKX,GAFlBA,EAAQD,IAIvB,OACEa,EAAA,MAAA,CAAA,cACc,wBACZC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVhB,OAAQ,OACTE,SAEDW,SACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,QAAS,GAAGd,EAAOC,KAAKD,EAAOE,KAAKJ,KAASS,IAC7CQ,IAAKX,K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AAWmC,EAAG,YAAanC,GAC3ByC,GAAIJ,EAAKzC,EACT8C,GAAIL,EAAKxC,EACT8C,GAAIL,EAAG1C,EACPgD,GAAIN,EAAGzC,EACP0C,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,UAC3CN,GAGV"}
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 { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio, SVGAttributes } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport type ResponsiveSVGProps = SVGAttributes<{\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}>;\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n ...props\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = height === 0 ? 1 : width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-testid=\"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 {...props}\n >\n {children}\n </svg>\n </div>\n );\n}\n","import type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG.js';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useEffect } from 'react';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {\n parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, style]);\n\n const transform =\n align === 'center'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(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 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 function Group({\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 cx from 'classnames';\nimport type { 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 function Line({\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","height","width","children","origin","x","y","preserveAspectRatio","innerRef","className","props","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","parentRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","key","value","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"iKAmBgB,SAAAA,GAAcC,OAC5BA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,OACRA,EAAS,CAAEC,EAAG,EAAGC,EAAG,GAAGC,oBACvBA,EAAsB,gBAAeC,SACrCA,EAAQC,UACRA,KACGC,IAEH,MAEMC,EAAiBC,KAAKC,KAAKX,GAFP,IAAXD,EAAe,EAAIC,EAAQD,IAI1C,OACEa,EAAA,MAAA,CAAA,cACc,wBACZC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVhB,OAAQ,OACTE,SAEDW,SACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,QAAS,GAAGd,EAAOC,KAAKD,EAAOE,KAAKJ,KA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CAAAK,IAAKX,EACLC,UAAWmC,EAAG,YAAanC,GAC3ByC,GAAIJ,EAAKzC,EACT8C,GAAIL,EAAKxC,EACT8C,GAAIL,EAAG1C,EACPgD,GAAIN,EAAGzC,EACP0C,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,UAC3CN,GAGV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutting/svg",
3
- "version": "4.52.0",
3
+ "version": "4.52.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
@@ -13,25 +13,25 @@
13
13
  "dependencies": {
14
14
  "classnames": "^2.3.2",
15
15
  "resize-observer-polyfill": "^1.5.1",
16
- "@cutting/react-abortable-fetch": "0.35.0",
17
- "@cutting/use-get-parent-size": "1.26.0",
18
- "@cutting/util": "4.57.0"
16
+ "@cutting/react-abortable-fetch": "0.35.1",
17
+ "@cutting/use-get-parent-size": "1.26.1",
18
+ "@cutting/util": "4.57.1"
19
19
  },
20
20
  "devDependencies": {
21
- "@testing-library/react": "^13.4.0",
21
+ "@testing-library/react": "^14.0.0",
22
22
  "@testing-library/user-event": "14.4.3",
23
- "@types/react": "18.0.26",
24
- "@types/react-dom": "18.0.10",
25
- "@vanilla-extract/css": "^1.9.2",
23
+ "@types/react": "18.0.28",
24
+ "@types/react-dom": "18.0.11",
25
+ "@vanilla-extract/css": "^1.9.5",
26
26
  "@vanilla-extract/sprinkles": "1.5.1",
27
27
  "assert-ts": "0.3.4",
28
- "eslint": "8.30.0",
28
+ "eslint": "8.34.0",
29
29
  "react": "18.2.0",
30
30
  "react-dom": "18.2.0",
31
- "typescript": "4.9.4",
32
- "@cutting/component-library": "5.34.0",
31
+ "typescript": "4.9.5",
32
+ "@cutting/component-library": "5.36.2",
33
33
  "@cutting/devtools": "4.62.0",
34
- "@cutting/eslint-config": "4.43.0",
34
+ "@cutting/eslint-config": "4.43.1",
35
35
  "@cutting/tsconfig": "4.39.0",
36
36
  "@cutting/useful-types": "4.39.0"
37
37
  },
@@ -24,7 +24,7 @@ describe('useParentSize', () => {
24
24
 
25
25
  const svg = document.querySelector('svg') as SVGElement;
26
26
 
27
- expect(svg.getAttribute('viewBox')).toBe('0 0 1 1');
27
+ expect(svg.getAttribute('viewBox')).toBe('0 0 0 0');
28
28
 
29
29
  screen.getByTestId('cutting-svg-container');
30
30
  });
@@ -42,6 +42,6 @@ describe('useParentSize', () => {
42
42
 
43
43
  const svg = document.querySelector('svg') as SVGElement;
44
44
 
45
- expect(svg.querySelector('g') as SVGGElement).toHaveAttribute('transform', 'translate(0.5,-19.5) scale(1)');
45
+ expect(svg.querySelector('g') as SVGGElement).toHaveAttribute('transform', 'translate(0,-20) scale(1)');
46
46
  });
47
47
  });
@@ -27,7 +27,7 @@ export function ResponsiveSVG({
27
27
  className,
28
28
  ...props
29
29
  }: ResponsiveSVGProps): JSX.Element {
30
- const aspect = width / height;
30
+ const aspect = height === 0 ? 1 : width / height;
31
31
 
32
32
  const adjustedHeight = Math.ceil(width / aspect);
33
33
 
@@ -1,86 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { render, fireEvent } from '@testing-library/react';
3
- import { useParentSize } from '@cutting/use-get-parent-size';
4
- import { useRef } from 'react';
5
- import type { ResponsiveSVGProps } from './ResponsiveSVG.js';
6
- import { ResponsiveSVG } from './ResponsiveSVG.js';
7
-
8
- import ResizeObserver from 'resize-observer-polyfill';
9
-
10
- vi.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: vi.fn(), disconnect: vi.fn(), unobserve: vi.fn() };
18
- });
19
- };
20
-
21
- type TestResponsiveSVGProps = Omit<ResponsiveSVGProps, 'width' | 'height' | 'children'>;
22
-
23
- function TestEr(props: TestResponsiveSVGProps = {} as ResponsiveSVGProps): JSX.Element {
24
- const ref = useRef<HTMLDivElement>(null);
25
- const { width, height } = useParentSize(ref);
26
-
27
- return (
28
- <div ref={ref}>
29
- <ResponsiveSVG height={height} width={width} {...props}>
30
- <rect x="20%" y="20%" width="200px" height="200px" rx="20" />
31
- </ResponsiveSVG>
32
- </div>
33
- );
34
- }
35
-
36
- const wrap = (props: TestResponsiveSVGProps = {} as ResponsiveSVGProps): ReturnType<typeof render> =>
37
- render(<TestEr {...props} />);
38
-
39
- class FakeMouseEvent extends MouseEvent {
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- constructor(type: string, values: any) {
42
- const { pageX, pageY, offsetX, offsetY, x, y, ...mouseValues } = values;
43
- super(type, mouseValues);
44
-
45
- Object.assign(this, {
46
- offsetX: offsetX || 0,
47
- offsetY: offsetY || 0,
48
- pageX: pageX || 0,
49
- pageY: pageY || 0,
50
- x: x || 0,
51
- y: y || 0,
52
- });
53
- }
54
- }
55
-
56
- describe('ResponsiveSVG', () => {
57
- it('should pass intrinsic props straight through', () => {
58
- const mouseMoveHandler = vi.fn();
59
-
60
- const { container } = wrap({ onMouseMove: mouseMoveHandler });
61
-
62
- fireEvent.mouseMove(
63
- container.querySelector('svg'),
64
- new FakeMouseEvent('mousemove', {
65
- bubbles: true,
66
- pageX: 350,
67
- pageY: 125,
68
- }),
69
- );
70
-
71
- expect(mouseMoveHandler).toHaveBeenCalled();
72
- });
73
- });
74
-
75
- // describe.skip('useParentSize', () => {
76
- // it('should set the svg viewBox attribute', () => {
77
- // resize(200, 200);
78
- // wrap();
79
-
80
- // const svg = document.querySelector('svg') as SVGElement;
81
-
82
- // expect(svg.getAttribute('viewBox')).toBe('0 0 200 200');
83
-
84
- // screen.getByTestId('cutting-svg-container');
85
- // });
86
- // });