@cutting/svg 4.50.1 → 4.51.0

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,15 +1,14 @@
1
- @cutting/svg:build: cache hit, replaying output a612d829c0c309c1
2
- @cutting/svg:build:
3
- @cutting/svg:build: > @cutting/svg@4.50.1 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
4
- @cutting/svg:build: > NODE_ENV=production devtools rollup
5
- @cutting/svg:build:
6
- @cutting/svg:build: DEBUG using tsconfig.dist.json
7
- @cutting/svg:build: START using input file index.ts for @cutting/svg
8
- @cutting/svg:build:
9
- @cutting/svg:build: INFO Generating @cutting/svg bundle.
10
- @cutting/svg:build: INFO writing index.min.js for @cutting/svg
11
- @cutting/svg:build: INFO preserveModules is false
12
- @cutting/svg:build: INFO writing index.js for @cutting/svg
13
- @cutting/svg:build: DEBUG copying assets to /home/runner/work/cuttingedge/cuttingedge/packages/svg/dist
14
- @cutting/svg:build: DONE finished building
15
- @cutting/svg:build:
1
+
2
+ > @cutting/svg@4.51.0 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
3
+ > NODE_ENV=production devtools rollup
4
+
5
+ DEBUG using tsconfig.dist.json
6
+ START using input file index.ts for @cutting/svg
7
+
8
+ INFO Generating @cutting/svg bundle.
9
+ INFO writing index.min.js for @cutting/svg
10
+ INFO preserveModules is false
11
+ INFO writing index.js for @cutting/svg
12
+ DEBUG copying assets to /home/runner/work/cuttingedge/cuttingedge/packages/svg/dist
13
+ DONE finished building
14
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @cutting/svg
2
2
 
3
+ ## 4.51.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 907b7c62: bump versions
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [907b7c62]
12
+ - @cutting/react-abortable-fetch@0.34.0
13
+ - @cutting/use-get-parent-size@1.25.0
14
+ - @cutting/util@4.56.0
15
+
16
+ ## 4.50.2
17
+
18
+ ### Patch Changes
19
+
20
+ - dbc72c3b: add tangent
21
+ - Updated dependencies [dbc72c3b]
22
+ - @cutting/util@4.55.1
23
+ - @cutting/use-get-parent-size@1.24.2
24
+ - @cutting/react-abortable-fetch@0.33.1
25
+
3
26
  ## 4.50.1
4
27
 
5
28
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- declare type GroupOnlyProps = {
1
+ type GroupOnlyProps = {
2
2
  /** Top offset applied to `<g/>`. */
3
3
  y?: number;
4
4
  /** Left offset applied to `<g/>`. */
@@ -9,7 +9,7 @@ declare type GroupOnlyProps = {
9
9
  children?: React.ReactNode;
10
10
  innerRef?: React.Ref<SVGGElement>;
11
11
  };
12
- declare type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
12
+ type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
13
13
  export declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
14
14
  export {};
15
15
  //# sourceMappingURL=Group.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"AAEA,aAAK,cAAc,GAAG;IACpB,oCAAoC;IACpC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,aAAK,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAE3F,wBAAgB,KAAK,CAAC,EACpB,CAAK,EACL,CAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAW1B"}
1
+ {"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"AAEA,KAAK,cAAc,GAAG;IACpB,oCAAoC;IACpC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,KAAK,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAE3F,wBAAgB,KAAK,CAAC,EACpB,CAAK,EACL,CAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAW1B"}
@@ -1,5 +1,5 @@
1
1
  import type { AddSVGProps, Point } from '../../types/types';
2
- export declare type LineProps = {
2
+ export type LineProps = {
3
3
  className?: string;
4
4
  innerRef?: React.Ref<SVGLineElement>;
5
5
  fill?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,oBAAY,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,wBAAgB,IAAI,CAAC,EACnB,IAAqB,EACrB,EAAmB,EACnB,IAAoB,EACpB,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgBtD"}
1
+ {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,wBAAgB,IAAI,CAAC,EACnB,IAAqB,EACrB,EAAmB,EACnB,IAAoB,EACpB,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgBtD"}
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties, PropsWithChildren, RefObject } from 'react';
2
2
  import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG.js';
3
3
  import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
4
- declare type Align = 'none' | 'center';
5
- export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
4
+ type Align = 'none' | 'center';
5
+ export type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
6
6
  parentRef: RefObject<E>;
7
7
  style?: CSSProperties;
8
8
  align?: Align;
@@ -1 +1 @@
1
- {"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAKzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAOjB,CAAC;AAEX,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,SAAS,EACT,QAAQ,EACR,KAAoB,EACpB,KAAS,EACT,KAAc,EACd,OAAO,EAAE,EAAE,aAAkB,EAAE,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
1
+ {"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAKzE,KAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAOjB,CAAC;AAEX,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,SAAS,EACT,QAAQ,EACR,KAAoB,EACpB,KAAS,EACT,KAAc,EACd,OAAO,EAAE,EAAE,aAAkB,EAAE,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
@@ -1,10 +1,10 @@
1
1
  import type { ReactNode, Ref } from 'react';
2
- import type { PreserveAspectRatio } from '../../types/types';
2
+ import type { PreserveAspectRatio, SVGAttributes } from '../../types/types';
3
3
  export interface Point {
4
4
  x: number;
5
5
  y: number;
6
6
  }
7
- export interface ResponsiveSVGProps {
7
+ export type ResponsiveSVGProps = SVGAttributes<{
8
8
  width: number;
9
9
  height: number;
10
10
  origin?: Point;
@@ -13,6 +13,6 @@ export interface ResponsiveSVGProps {
13
13
  className?: string;
14
14
  hide?: boolean;
15
15
  children: ReactNode;
16
- }
17
- export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, }: ResponsiveSVGProps): JSX.Element;
16
+ }>;
17
+ export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, ...props }: ResponsiveSVGProps): JSX.Element;
18
18
  //# sourceMappingURL=ResponsiveSVG.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAyBlC"}
1
+ {"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC,CAAC;AAEH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CA0BlC"}
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}){const a=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} ${a}`,ref:l,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/(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 } 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 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}: 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 >\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","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,IAEA,MAEMC,EAAiBC,KAAKC,KAAKV,GAFlBA,EAAQD,IAIvB,OACEY,EAAA,MAAA,CAAA,cACc,wBACZC,MAAO,CACLC,SAAU,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,cAAatC,UACpBA,EAASD,SACTA,KACGkC,IAEH,MAAMM,EAAgBH,EAAKxC,IAAMyC,EAAGzC,GAAKwC,EAAKvC,IAAMwC,EAAGxC,EAEvD,OACEO,EACE,OAAA,CAAAK,IAAKV,EACLC,UAAWkC,EAAG,YAAalC,GAC3BwC,GAAIJ,EAAKxC,EACT6C,GAAIL,EAAKvC,EACT6C,GAAIL,EAAGzC,EACP+C,GAAIN,EAAGxC,EACPyC,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 = 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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pBA,EAASD,SACTA,KACGmC,IAEH,MAAMM,EAAgBH,EAAKzC,IAAM0C,EAAG1C,GAAKyC,EAAKxC,IAAMyC,EAAGzC,EAEvD,OACEQ,EACE,OAAA,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"}
@@ -1,9 +1,11 @@
1
- export declare type PreserveAspectRatioAlignment = 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax';
2
- export declare type MeetOrSlice = 'meet' | 'slice';
3
- export declare type PreserveAspectRatio = `${PreserveAspectRatioAlignment} ${MeetOrSlice}`;
4
- export declare type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
1
+ import type { SVGAttributes as SvgAttributes } from 'react';
2
+ export type PreserveAspectRatioAlignment = 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax';
3
+ export type MeetOrSlice = 'meet' | 'slice';
4
+ export type PreserveAspectRatio = `${PreserveAspectRatioAlignment} ${MeetOrSlice}`;
5
+ export type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
5
6
  export interface Point {
6
7
  x: number;
7
8
  y: number;
8
9
  }
10
+ export type SVGAttributes<T> = T & Omit<SvgAttributes<SVGSVGElement>, 'origin' | 'viewBox' | 'preserveAspectRatio' | 'children '>;
9
11
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,oBA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AAS,GAAG,qBAAqB,GAAG,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutting/svg",
3
- "version": "4.50.1",
3
+ "version": "4.51.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
@@ -11,28 +11,29 @@
11
11
  "types": "dist/esm/index.d.ts",
12
12
  "license": "MIT",
13
13
  "dependencies": {
14
- "@cutting/react-abortable-fetch": "0.33.0",
15
- "@cutting/use-get-parent-size": "1.24.1",
16
- "@cutting/util": "4.55.0",
17
14
  "classnames": "^2.3.2",
18
- "resize-observer-polyfill": "^1.5.1"
15
+ "resize-observer-polyfill": "^1.5.1",
16
+ "@cutting/react-abortable-fetch": "0.34.0",
17
+ "@cutting/use-get-parent-size": "1.25.0",
18
+ "@cutting/util": "4.56.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@cutting/component-library": "5.31.1",
22
- "@cutting/devtools": "4.60.0",
23
- "@cutting/eslint-config": "4.42.0",
24
- "@cutting/tsconfig": "4.38.0",
25
- "@cutting/useful-types": "4.38.0",
26
21
  "@testing-library/react": "^13.4.0",
27
- "@types/react": "18.0.21",
28
- "@types/react-dom": "18.0.6",
29
- "@vanilla-extract/css": "^1.9.1",
30
- "@vanilla-extract/sprinkles": "1.5.0",
22
+ "@testing-library/user-event": "14.4.3",
23
+ "@types/react": "18.0.26",
24
+ "@types/react-dom": "18.0.9",
25
+ "@vanilla-extract/css": "^1.9.2",
26
+ "@vanilla-extract/sprinkles": "1.5.1",
31
27
  "assert-ts": "0.3.4",
32
- "eslint": "8.24.0",
28
+ "eslint": "8.29.0",
33
29
  "react": "18.2.0",
34
30
  "react-dom": "18.2.0",
35
- "typescript": "4.8.4"
31
+ "typescript": "4.9.4",
32
+ "@cutting/component-library": "5.33.0",
33
+ "@cutting/devtools": "4.61.0",
34
+ "@cutting/eslint-config": "4.42.0",
35
+ "@cutting/tsconfig": "4.38.0",
36
+ "@cutting/useful-types": "4.38.0"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "react": ">= 18.x.x",
@@ -1,9 +1,9 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { render, screen } from '@testing-library/react';
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { render, fireEvent } from '@testing-library/react';
3
3
  import { useParentSize } from '@cutting/use-get-parent-size';
4
4
  import { useRef } from 'react';
5
+ import type { ResponsiveSVGProps } from './ResponsiveSVG.js';
5
6
  import { ResponsiveSVG } from './ResponsiveSVG.js';
6
- import { vi } from 'vitest';
7
7
 
8
8
  import ResizeObserver from 'resize-observer-polyfill';
9
9
 
@@ -18,30 +18,69 @@ const resize = (width: number, height: number): void => {
18
18
  });
19
19
  };
20
20
 
21
- function TestEr(): JSX.Element {
21
+ type TestResponsiveSVGProps = Omit<ResponsiveSVGProps, 'width' | 'height' | 'children'>;
22
+
23
+ function TestEr(props: TestResponsiveSVGProps = {} as ResponsiveSVGProps): JSX.Element {
22
24
  const ref = useRef<HTMLDivElement>(null);
23
25
  const { width, height } = useParentSize(ref);
24
26
 
25
27
  return (
26
28
  <div ref={ref}>
27
- <ResponsiveSVG height={height} width={width}>
29
+ <ResponsiveSVG height={height} width={width} {...props}>
28
30
  <rect x="20%" y="20%" width="200px" height="200px" rx="20" />
29
31
  </ResponsiveSVG>
30
32
  </div>
31
33
  );
32
34
  }
33
35
 
34
- const wrap = () => render(<TestEr />);
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
+ }
35
55
 
36
- describe.skip('useParentSize', () => {
37
- it('should set the svg viewBox attribute', () => {
38
- resize(200, 200);
39
- wrap();
56
+ describe('ResponsiveSVG', () => {
57
+ it('should pass intrinsic props straight through', () => {
58
+ const mouseMoveHandler = vi.fn();
40
59
 
41
- const svg = document.querySelector('svg') as SVGElement;
60
+ const { container } = wrap({ onMouseMove: mouseMoveHandler });
42
61
 
43
- expect(svg.getAttribute('viewBox')).toBe('0 0 200 200');
62
+ fireEvent.mouseMove(
63
+ container.querySelector('svg'),
64
+ new FakeMouseEvent('mousemove', {
65
+ bubbles: true,
66
+ pageX: 350,
67
+ pageY: 125,
68
+ }),
69
+ );
44
70
 
45
- screen.getByTestId('cutting-svg-container');
71
+ expect(mouseMoveHandler).toHaveBeenCalled();
46
72
  });
47
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
+ // });
@@ -1,12 +1,12 @@
1
1
  import type { ReactNode, Ref } from 'react';
2
- import type { PreserveAspectRatio } from '../../types/types';
2
+ import type { PreserveAspectRatio, SVGAttributes } from '../../types/types';
3
3
 
4
4
  export interface Point {
5
5
  x: number;
6
6
  y: number;
7
7
  }
8
8
 
9
- export interface ResponsiveSVGProps {
9
+ export type ResponsiveSVGProps = SVGAttributes<{
10
10
  width: number;
11
11
  height: number;
12
12
  origin?: Point;
@@ -15,7 +15,7 @@ export interface ResponsiveSVGProps {
15
15
  className?: string;
16
16
  hide?: boolean;
17
17
  children: ReactNode;
18
- }
18
+ }>;
19
19
 
20
20
  export function ResponsiveSVG({
21
21
  height,
@@ -25,6 +25,7 @@ export function ResponsiveSVG({
25
25
  preserveAspectRatio = 'xMaxYMid meet',
26
26
  innerRef,
27
27
  className,
28
+ ...props
28
29
  }: ResponsiveSVGProps): JSX.Element {
29
30
  const aspect = width / height;
30
31
 
@@ -45,6 +46,7 @@ export function ResponsiveSVG({
45
46
  preserveAspectRatio={preserveAspectRatio}
46
47
  viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}
47
48
  ref={innerRef}
49
+ {...props}
48
50
  >
49
51
  {children}
50
52
  </svg>
@@ -1,3 +1,5 @@
1
+ import type { SVGAttributes as SvgAttributes } from 'react';
2
+
1
3
  export type PreserveAspectRatioAlignment =
2
4
  | 'xMinYMin'
3
5
  | 'xMidYMin'
@@ -19,3 +21,6 @@ export interface Point {
19
21
  x: number;
20
22
  y: number;
21
23
  }
24
+
25
+ export type SVGAttributes<T> = T &
26
+ Omit<SvgAttributes<SVGSVGElement>, 'origin' | 'viewBox' | 'preserveAspectRatio' | 'children '>;