@cutting/svg 4.63.0 → 4.64.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.
Files changed (35) hide show
  1. package/dist/esm/index.d.ts +69 -5
  2. package/dist/esm/index.d.ts.map +1 -1
  3. package/dist/esm/index.js +2 -2
  4. package/dist/esm/index.js.map +1 -1
  5. package/package.json +9 -6
  6. package/.turbo/turbo-build.log +0 -11
  7. package/.watchmanconfig +0 -1
  8. package/CHANGELOG.md +0 -552
  9. package/demo/index.html +0 -17
  10. package/demo/src/App.tsx +0 -41
  11. package/demo/src/global.css.ts +0 -17
  12. package/demo/src/index.tsx +0 -21
  13. package/demo/tsconfig.json +0 -8
  14. package/dist/esm/components/Group/Group.d.ts +0 -15
  15. package/dist/esm/components/Group/Group.d.ts.map +0 -1
  16. package/dist/esm/components/Line/Line.d.ts +0 -12
  17. package/dist/esm/components/Line/Line.d.ts.map +0 -1
  18. package/dist/esm/components/ParentsizeSVG/ParentsizeSVG.d.ts +0 -13
  19. package/dist/esm/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +0 -1
  20. package/dist/esm/components/ResponsiveSVG/ResponsiveSVG.d.ts +0 -19
  21. package/dist/esm/components/ResponsiveSVG/ResponsiveSVG.d.ts.map +0 -1
  22. package/dist/esm/types/types.d.ts +0 -11
  23. package/dist/esm/types/types.d.ts.map +0 -1
  24. package/eslint.config.mjs +0 -4
  25. package/img/sizer.gif +0 -0
  26. package/src/components/Group/Group.tsx +0 -36
  27. package/src/components/Line/Line.tsx +0 -38
  28. package/src/components/ParentsizeSVG/ParentSizeSVG.test.tsx +0 -34
  29. package/src/components/ParentsizeSVG/ParentsizeSVG.tsx +0 -30
  30. package/src/components/ResponsiveSVG/ResponsiveSVG.tsx +0 -58
  31. package/src/index.ts +0 -5
  32. package/src/types/types.ts +0 -26
  33. package/tsconfig.dist.json +0 -8
  34. package/tsconfig.json +0 -8
  35. package/vite.config.ts +0 -17
@@ -1,6 +1,70 @@
1
- export { Group } from './components/Group/Group';
2
- export { Line } from './components/Line/Line';
3
- export { ParentsizeSVG } from './components/ParentsizeSVG/ParentsizeSVG';
4
- export { ResponsiveSVG } from './components/ResponsiveSVG/ResponsiveSVG';
5
- export type { Point } from './types/types';
1
+ import { UseParentSizeOptions } from "@cutting/use-get-parent-size";
2
+ import { PropsWithChildren, ReactNode, Ref, RefObject, SVGAttributes } from "react";
3
+ //#region src/components/Group/Group.d.ts
4
+ type GroupOnlyProps = {
5
+ /** Top offset applied to `<g/>`. */
6
+ y?: number;
7
+ /** Left offset applied to `<g/>`. */
8
+ x?: number;
9
+ /** Override `x` and `y` to provide the entire `transform` string. */
10
+ transform?: string;
11
+ className?: string;
12
+ children?: React.ReactNode;
13
+ innerRef?: React.Ref<SVGGElement>;
14
+ };
15
+ type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
16
+ declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
17
+ //#endregion
18
+ //#region src/types/types.d.ts
19
+ type PreserveAspectRatioAlignment = 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax';
20
+ type MeetOrSlice = 'meet' | 'slice';
21
+ type PreserveAspectRatio = `${PreserveAspectRatioAlignment} ${MeetOrSlice}` | 'none';
22
+ type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
23
+ interface Point {
24
+ x: number;
25
+ y: number;
26
+ }
27
+ type SVGAttributes$1<T> = T & Omit<SVGAttributes<SVGSVGElement>, 'origin' | 'viewBox' | 'preserveAspectRatio' | 'children '>;
28
+ //#endregion
29
+ //#region src/components/Line/Line.d.ts
30
+ type LineProps = {
31
+ className?: string;
32
+ innerRef?: React.Ref<SVGLineElement>;
33
+ fill?: string;
34
+ /** Starting x,y point of the line. */
35
+ from?: Point;
36
+ /** Ending x,y point of the line. */
37
+ to?: Point;
38
+ };
39
+ declare function Line({ from, to, fill, className, innerRef, ...restProps }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element;
40
+ //#endregion
41
+ //#region src/components/ResponsiveSVG/ResponsiveSVG.d.ts
42
+ interface Point$1 {
43
+ x: number;
44
+ y: number;
45
+ }
46
+ type ResponsiveSVGProps = SVGAttributes$1<{
47
+ width?: number;
48
+ height?: number;
49
+ origin?: Point$1;
50
+ preserveAspectRatio?: PreserveAspectRatio;
51
+ innerRef?: Ref<SVGSVGElement>;
52
+ className?: string;
53
+ hide?: boolean;
54
+ children: ReactNode;
55
+ overflow?: 'hidden' | 'visible';
56
+ }>;
57
+ declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, overflow, ...props }: ResponsiveSVGProps): JSX.Element;
58
+ //#endregion
59
+ //#region src/components/ParentsizeSVG/ParentsizeSVG.d.ts
60
+ type Align = 'none' | 'center';
61
+ type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
62
+ parentRef: RefObject<E>;
63
+ align?: Align;
64
+ scale?: number;
65
+ options?: Partial<UseParentSizeOptions>;
66
+ } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
67
+ declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, options, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
68
+ //#endregion
69
+ export { Group, Line, ParentsizeSVG, type Point, ResponsiveSVG };
6
70
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/components/Group/Group.tsx","../../src/types/types.ts","../../src/components/Line/Line.tsx","../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"mappings":";;;KAEK;;EAEH;;EAEA;;EAEA;EACA;EACA,WAAW,MAAM;EACjB,WAAW,MAAM,IAAI;;KAGlB,aAAa,iBAAiB,KAAK,MAAM,SAAS,oBAAoB;iBAE3D,QACd,GACA,GACA,WACA,WACA,UACA,aACG,aACF,aAAa,IAAI;;;KCtBR;KAGA;KAEA,yBAAyB,gCAAgC;KAEzD,YAAY,OAAO,gBAAgB,cAAc,QAAQ,KAAK,MAAM,SAAS,gBAAgB;UAExF;EACf;EACA;;KAGU,gBAAc,KAAK,IAC7B,KAAK,cAAc;;;KCbT;EACV;EACA,WAAW,MAAM,IAAI;EACrB;;EAEA,OAAO;;EAEP,KAAK;;iBAGS,OACd,MACA,IACA,MACA,WACA,aACG,aACF,YAAY,WAAW,kBAAkB,IAAI;;;UCjB/B;EACf;EACA;;KAGU,qBAAqB;EAC/B;EACA;EACA,SAAS;EACT,sBAAsB;EACtB,WAAW,IAAI;EACf;EACA;EACA,UAAU;EACV;;iBAGc,gBACd,QACA,OACA,UACA,QACA,qBACA,UACA,WACA,aACG,SACF,qBAAqB,IAAI;;;KCxBvB;KAEO,mBAAmB,UAAU,cAAc;EACrD,WAAW,UAAU;EACrB,QAAQ;EACR;EACA,UAAU,QAAQ;IAChB,QAAQ,KAAK;iBAED,cAAc,UAAU,eACtC,WACA,UACA,YACG,QACF,kBAAkB,mBAAmB,MAAM,IAAI"}
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{jsx as e}from"react/jsx-runtime";import t from"classnames";import{useParentSize as i}from"@cutting/use-get-parent-size";function r({y:i=0,x:r=0,transform:n,className:s,children:o,innerRef:a,...l}){return e("g",{ref:a,className:t("visx-group",s),transform:n||`translate(${r}, ${i})`,...l,children:o})}function n({from:i={x:0,y:0},to:r={x:1,y:1},fill:n="transparent",className:s,innerRef:o,...a}){const l=i.x===r.x||i.y===r.y;return e("line",{ref:o,className:t("visx-line",s),x1:i.x,y1:i.y,x2:r.x,y2:r.y,fill:n,shapeRendering:l?"crispEdges":"auto",...a})}function s({height:t=0,width:i=0,children:r,origin:n={x:0,y:0},preserveAspectRatio:s="xMaxYMid meet",innerRef:o,className:a,overflow:l="visible",...c}){const h=Math.ceil(i/(0===t?1:i/t));return e("div",{"data-testid":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"0px"},children:e("svg",{style:{overflow:l,width:"100%",height:"auto"},className:a,preserveAspectRatio:s,viewBox:`${n.x} ${n.y} ${i} ${h}`,ref:o,...c,children:r})})}function o({parentRef:t,children:r,options:n,...o}){const{width:a,height:l}=i(t,n);return e(s,{width:a,height:l,...o,children:r})}export{r as Group,n as Line,o as ParentsizeSVG,s as ResponsiveSVG};
2
- //# sourceMappingURL=index.js.map
1
+ import e from"classnames";import{jsx as t}from"react/jsx-runtime";import{useParentSize as n}from"@cutting/use-get-parent-size";function r({y:n=0,x:r=0,transform:i,className:a,children:o,innerRef:s,...c}){return t(`g`,{ref:s,className:e(`visx-group`,a),transform:i||`translate(${r}, ${n})`,...c,children:o})}function i({from:n={x:0,y:0},to:r={x:1,y:1},fill:i=`transparent`,className:a,innerRef:o,...s}){let c=n.x===r.x||n.y===r.y;return t(`line`,{ref:o,className:e(`visx-line`,a),x1:n.x,y1:n.y,x2:r.x,y2:r.y,fill:i,shapeRendering:c?`crispEdges`:`auto`,...s})}function a({height:e=0,width:n=0,children:r,origin:i={x:0,y:0},preserveAspectRatio:a=`xMaxYMid meet`,innerRef:o,className:s,overflow:c=`visible`,...l}){let u=e===0?1:n/e,d=Math.ceil(n/u);return t(`div`,{"data-testid":`cutting-svg-container`,style:{position:`relative`,overflow:`visible`,height:`0px`},children:t(`svg`,{style:{overflow:c,width:`100%`,height:`auto`},className:s,preserveAspectRatio:a,viewBox:`${i.x} ${i.y} ${n} ${d}`,ref:o,...l,children:r})})}function o({parentRef:e,children:r,options:i,...o}){let{width:s,height:c}=n(e,i);return t(a,{width:s,height:c,...o,children:r})}export{r as Group,i as Line,o as ParentsizeSVG,a as ResponsiveSVG};
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx","../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"sourcesContent":["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';\n\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","import type { ReactNode, Ref } from 'react';\n\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 overflow?: 'hidden' | 'visible';\n}>;\n\nexport function ResponsiveSVG({\n height = 0,\n width = 0,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n overflow = 'visible',\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: '0px',\n }}\n >\n <svg\n style={{ overflow, width: '100%', height: 'auto' }}\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 { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport type { PropsWithChildren, RefObject } from 'react';\n\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\nimport { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {\n parentRef: RefObject<E>;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n parentRef,\n children,\n options,\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(parentRef, options);\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n {children}\n </ResponsiveSVG>\n );\n}\n"],"names":["Group","y","x","transform","className","children","innerRef","restProps","_jsx","ref","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","ResponsiveSVG","height","width","origin","preserveAspectRatio","overflow","props","adjustedHeight","Math","ceil","style","position","viewBox","ParentsizeSVG","parentRef","options","rest","useParentSize"],"mappings":"+HAgBM,SAAUA,GAAMC,EACpBA,EAAI,EAACC,EACLA,EAAI,EAACC,UACLA,EAASC,UACTA,EAASC,SACTA,EAAQC,SACRA,KACGC,IAEH,OACEC,EAAA,IAAA,CACEC,IAAKH,EACLF,UAAWM,EAAG,aAAcN,GAC5BD,UAAWA,GAAa,aAAaD,MAAMD,QACvCM,EAASF,SAEZA,GAGP,UCrBgBM,GAAKC,KACnBA,EAAO,CAAEV,EAAG,EAAGD,EAAG,GAAGY,GACrBA,EAAK,CAAEX,EAAG,EAAGD,EAAG,GAAGa,KACnBA,EAAO,cAAaV,UACpBA,EAASE,SACTA,KACGC,IAEH,MAAMQ,EAAgBH,EAAKV,IAAMW,EAAGX,GAAKU,EAAKX,IAAMY,EAAGZ,EAEvD,OACEO,EAAA,OAAA,CACEC,IAAKH,EACLF,UAAWM,EAAG,YAAaN,GAC3BY,GAAIJ,EAAKV,EACTe,GAAIL,EAAKX,EACTiB,GAAIL,EAAGX,EACPiB,GAAIN,EAAGZ,EACPa,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,UAC3CR,GAGV,UChBgBc,GAAcC,OAC5BA,EAAS,EAACC,MACVA,EAAQ,EAAClB,SACTA,EAAQmB,OACRA,EAAS,CAAEtB,EAAG,EAAGD,EAAG,GAAGwB,oBACvBA,EAAsB,gBAAenB,SACrCA,EAAQF,UACRA,EAASsB,SACTA,EAAW,aACRC,IAEH,MAEMC,EAAiBC,KAAKC,KAAKP,GAFP,IAAXD,EAAe,EAAIC,EAAQD,IAI1C,OACEd,EAAA,MAAA,CAAA,cACc,wBACZuB,MAAO,CACLC,SAAU,WACVN,SAAU,UACVJ,OAAQ,OACTjB,SAEDG,EAAA,MAAA,CACEuB,MAAO,CAAEL,WAAUH,MAAO,OAAQD,OAAQ,QAC1ClB,UAAWA,EACXqB,oBAAqBA,EACrBQ,QAAS,GAAGT,EAAOtB,KAAKsB,EAAOvB,KAAKsB,KAASK,IAC7CnB,IAAKH,KACDqB,WAEHtB,KAIT,CCzCM,SAAU6B,GAAqCC,UACnDA,EAAS9B,SACTA,EAAQ+B,QACRA,KACGC,IAEH,MAAMd,MAAEA,EAAKD,OAAEA,GAAWgB,EAAcH,EAAWC,GAEnD,OACE5B,EAACa,EAAa,CAACE,MAAOA,EAAOD,OAAQA,KAAYe,WAC9ChC,GAGP"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx","../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"sourcesContent":["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';\n\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","import type { ReactNode, Ref } from 'react';\n\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 overflow?: 'hidden' | 'visible';\n}>;\n\nexport function ResponsiveSVG({\n height = 0,\n width = 0,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n overflow = 'visible',\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: '0px',\n }}\n >\n <svg\n style={{ overflow, width: '100%', height: 'auto' }}\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 { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport type { PropsWithChildren, RefObject } from 'react';\n\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\nimport { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {\n parentRef: RefObject<E>;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n parentRef,\n children,\n options,\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(parentRef, options);\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n {children}\n </ResponsiveSVG>\n );\n}\n"],"mappings":"+HAgBA,SAAgB,EAAM,CACpB,IAAI,EACJ,IAAI,EACJ,YACA,YACA,WACA,WACA,GAAG,GACuB,CAC1B,OACE,EAAC,IAAD,CACE,IAAK,EACL,UAAW,EAAG,aAAc,CAAS,EACrC,UAAW,GAAa,aAAa,EAAE,IAAI,EAAE,GAC7C,GAAI,EAEH,UACA,CAAA,CAEP,CCrBA,SAAgB,EAAK,CACnB,OAAO,CAAE,EAAG,EAAG,EAAG,CAAE,EACpB,KAAK,CAAE,EAAG,EAAG,EAAG,CAAE,EAClB,OAAO,cACP,YACA,WACA,GAAG,GACmD,CACtD,IAAM,EAAgB,EAAK,IAAM,EAAG,GAAK,EAAK,IAAM,EAAG,EAEvD,OACE,EAAC,OAAD,CACE,IAAK,EACL,UAAW,EAAG,YAAa,CAAS,EACpC,GAAI,EAAK,EACT,GAAI,EAAK,EACT,GAAI,EAAG,EACP,GAAI,EAAG,EACD,OACN,eAAgB,EAAgB,aAAe,OAC/C,GAAI,CACL,CAAA,CAEL,CChBA,SAAgB,EAAc,CAC5B,SAAS,EACT,QAAQ,EACR,WACA,SAAS,CAAE,EAAG,EAAG,EAAG,CAAE,EACtB,sBAAsB,gBACtB,WACA,YACA,WAAW,UACX,GAAG,GAC+B,CAClC,IAAM,EAAS,IAAW,EAAI,EAAI,EAAQ,EAEpC,EAAiB,KAAK,KAAK,EAAQ,CAAM,EAE/C,OACE,EAAC,MAAD,CACE,cAAY,wBACZ,MAAO,CACL,SAAU,WACV,SAAU,UACV,OAAQ,KACV,EAEA,SAAA,EAAC,MAAD,CACE,MAAO,CAAE,WAAU,MAAO,OAAQ,OAAQ,MAAO,EACtC,YACU,sBACrB,QAAS,GAAG,EAAO,EAAE,GAAG,EAAO,EAAE,GAAG,EAAM,GAAG,IAC7C,IAAK,EACL,GAAI,EAEH,UACE,CAAA,CACF,CAAA,CAET,CCzCA,SAAgB,EAAqC,CACnD,YACA,WACA,UACA,GAAG,GAC4D,CAC/D,GAAM,CAAE,QAAO,UAAW,EAAc,EAAW,CAAO,EAE1D,OACE,EAAC,EAAD,CAAsB,QAAe,SAAQ,GAAI,EAC9C,UACY,CAAA,CAEnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cutting/svg",
3
- "version": "4.63.0",
3
+ "version": "4.64.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
@@ -9,11 +9,14 @@
9
9
  "type": "module",
10
10
  "sideEffects": false,
11
11
  "types": "dist/esm/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
12
15
  "license": "MIT",
13
16
  "dependencies": {
14
- "@cutting/assert": "0.6.1",
15
- "@cutting/use-get-parent-size": "2.10.0",
16
- "@cutting/util": "4.65.1"
17
+ "@cutting/assert": "0.7.1",
18
+ "@cutting/use-get-parent-size": "2.11.1",
19
+ "@cutting/util": "4.66.1"
17
20
  },
18
21
  "devDependencies": {
19
22
  "@testing-library/dom": "10.4.1",
@@ -24,7 +27,7 @@
24
27
  "d3-scale": "4.0.2",
25
28
  "react": "19.2.7",
26
29
  "react-dom": "19.2.7",
27
- "@cutting/component-library": "5.51.0"
30
+ "@cutting/component-library": "5.52.1"
28
31
  },
29
32
  "peerDependencies": {
30
33
  "@visx/scale": "4.0.0",
@@ -42,7 +45,7 @@
42
45
  },
43
46
  "scripts": {
44
47
  "start": "pnpm vite --host --port 9000 -l=info --clearScreen=false",
45
- "build": "NODE_ENV=production devtools rollup",
48
+ "build": "NODE_ENV=production devtools rolldown",
46
49
  "lint": "eslint ./src/**/*.{ts,tsx} --fix",
47
50
  "test": "NODE_ENV=test vitest",
48
51
  "test:ci": "CI=true pnpm test"
@@ -1,11 +0,0 @@
1
- $ NODE_ENV=production devtools rollup
2
- DEBUG using tsconfig.dist.json
3
- START using input file index.ts for @cutting/svg
4
-
5
- INFO Generating @cutting/svg bundle.
6
- INFO writing index.min for @cutting/svg
7
- INFO preserveModules is false
8
- INFO writing index.js for @cutting/svg
9
- DEBUG copying assets to /home/runner/work/cuttingedge/cuttingedge/packages/svg/dist
10
- DONE finished building
11
-
package/.watchmanconfig DELETED
@@ -1 +0,0 @@
1
- {}
package/CHANGELOG.md DELETED
@@ -1,552 +0,0 @@
1
- # @cutting/svg
2
-
3
- ## 4.63.0
4
-
5
- ### Minor Changes
6
-
7
- - c702763: upgrade @visx to 4
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [c702763]
12
- - @cutting/use-get-parent-size@2.10.0
13
-
14
- ## 4.62.1
15
-
16
- ### Patch Changes
17
-
18
- - 88e84cb: add changeset for patch version bump to update react and related dependencies across all packages
19
- - Updated dependencies [88e84cb]
20
- - @cutting/use-get-parent-size@2.9.1
21
- - @cutting/assert@0.6.1
22
- - @cutting/util@4.65.1
23
-
24
- ## 4.62.0
25
-
26
- ### Minor Changes
27
-
28
- - d91afd0: bump
29
-
30
- ### Patch Changes
31
-
32
- - Updated dependencies [d91afd0]
33
- - @cutting/assert@0.6.0
34
- - @cutting/use-get-parent-size@2.9.0
35
- - @cutting/util@4.65.0
36
-
37
- ## 4.61.0
38
-
39
- ### Minor Changes
40
-
41
- - 98caae6: upgrade to typescript 6.0
42
-
43
- ### Patch Changes
44
-
45
- - Updated dependencies [98caae6]
46
- - @cutting/use-get-parent-size@2.8.0
47
- - @cutting/assert@0.5.0
48
- - @cutting/util@4.64.0
49
-
50
- ## 4.61.0
51
-
52
- ### Minor Changes
53
-
54
- - af733ed: again again again
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [af733ed]
59
- - @cutting/assert@0.5.0
60
- - @cutting/use-get-parent-size@2.8.0
61
- - @cutting/util@4.64.0
62
-
63
- ## 4.61.0
64
-
65
- ### Minor Changes
66
-
67
- - 510343b: revert
68
-
69
- ### Patch Changes
70
-
71
- - Updated dependencies [510343b]
72
- - @cutting/use-get-parent-size@2.8.0
73
- - @cutting/assert@0.5.0
74
- - @cutting/util@4.64.0
75
-
76
- ## 4.61.0
77
-
78
- ### Minor Changes
79
-
80
- - 54f4b15: again
81
- - 958b9fa: again
82
- - de29d47: cu
83
- - 5108680: again
84
- - bf42836: upgrade react to 19.2.3
85
- - cf8b2f2: shit
86
-
87
- ### Patch Changes
88
-
89
- - Updated dependencies [54f4b15]
90
- - Updated dependencies [958b9fa]
91
- - Updated dependencies [de29d47]
92
- - Updated dependencies [5108680]
93
- - Updated dependencies [bf42836]
94
- - Updated dependencies [cf8b2f2]
95
- - @cutting/assert@0.5.0
96
- - @cutting/use-get-parent-size@2.8.0
97
- - @cutting/util@4.64.0
98
-
99
- ## 4.60.0
100
-
101
- ### Minor Changes
102
-
103
- - c69a4bb: update react to 19.2.0
104
-
105
- ### Patch Changes
106
-
107
- - Updated dependencies [c69a4bb]
108
- - @cutting/assert@0.4.0
109
- - @cutting/use-get-parent-size@2.7.0
110
- - @cutting/util@4.63.0
111
-
112
- ## 4.59.0
113
-
114
- ### Minor Changes
115
-
116
- - 8e62b3f: cunt
117
-
118
- ### Patch Changes
119
-
120
- - Updated dependencies [8e62b3f]
121
- - @cutting/assert@0.3.0
122
- - @cutting/use-get-parent-size@2.6.0
123
- - @cutting/util@4.62.0
124
-
125
- ## 4.58.0
126
-
127
- ### Minor Changes
128
-
129
- - b3a8f90: bump react to 17.1.1
130
- - 10a1082: update
131
-
132
- ### Patch Changes
133
-
134
- - Updated dependencies [b3a8f90]
135
- - Updated dependencies [10a1082]
136
- - @cutting/use-get-parent-size@2.5.0
137
- - @cutting/assert@0.2.0
138
- - @cutting/util@4.61.0
139
-
140
- ## 4.57.0
141
-
142
- ### Minor Changes
143
-
144
- - 7b27210: react 19.1.0
145
-
146
- ### Patch Changes
147
-
148
- - Updated dependencies [7b27210]
149
- - @cutting/use-get-parent-size@2.4.0
150
-
151
- ## 4.56.0
152
-
153
- ### Minor Changes
154
-
155
- - fac6b45: introduce new jsx.d.ts to @cutting/useful-types
156
-
157
- ### Patch Changes
158
-
159
- - Updated dependencies [fac6b45]
160
- - @cutting/use-get-parent-size@2.3.0
161
-
162
- ## 4.55.0
163
-
164
- ### Minor Changes
165
-
166
- - 27b80a8: update react to 19
167
-
168
- ### Patch Changes
169
-
170
- - Updated dependencies [27b80a8]
171
- - @cutting/use-get-parent-size@2.2.0
172
- - @cutting/util@4.60.0
173
-
174
- ## 4.54.23
175
-
176
- ### Patch Changes
177
-
178
- - 0f6945d: upgrade pnpm to 9.4.0
179
- - Updated dependencies [0f6945d]
180
- - @cutting/use-get-parent-size@2.1.16
181
-
182
- ## 4.54.22
183
-
184
- ### Patch Changes
185
-
186
- - 86c6bb0: update pnpm to 9.2.0
187
- - Updated dependencies [86c6bb0]
188
- - @cutting/use-get-parent-size@2.1.15
189
-
190
- ## 4.54.21
191
-
192
- ### Patch Changes
193
-
194
- - 857cd84: update all dependencies
195
- - Updated dependencies [857cd84]
196
- - @cutting/use-get-parent-size@2.1.14
197
-
198
- ## 4.54.20
199
-
200
- ### Patch Changes
201
-
202
- - 6000f90: upgrade to pnpm 9.1.0
203
- - Updated dependencies [6000f90]
204
- - @cutting/use-get-parent-size@2.1.13
205
-
206
- ## 4.54.19
207
-
208
- ### Patch Changes
209
-
210
- - f8374ed: update dependencies and pnpm to 8.15.7
211
- - Updated dependencies [f8374ed]
212
- - @cutting/use-get-parent-size@2.1.12
213
- - @cutting/util@4.59.2
214
-
215
- ## 4.54.18
216
-
217
- ### Patch Changes
218
-
219
- - df504df: update pnpm to 8.15.5
220
- - Updated dependencies [df504df]
221
- - @cutting/use-get-parent-size@2.1.11
222
- - @cutting/util@4.59.1
223
-
224
- ## 4.54.17
225
-
226
- ### Patch Changes
227
-
228
- - Updated dependencies [dddd0a0]
229
- - @cutting/util@4.59.0
230
- - @cutting/use-get-parent-size@2.1.10
231
-
232
- ## 4.54.16
233
-
234
- ### Patch Changes
235
-
236
- - 2fb3912: update dependencies
237
- - Updated dependencies [2fb3912]
238
- - @cutting/use-get-parent-size@2.1.10
239
- - @cutting/util@4.58.9
240
-
241
- ## 4.54.15
242
-
243
- ### Patch Changes
244
-
245
- - 2f5abbc: update to pnpm 8.15.4
246
- - Updated dependencies [2f5abbc]
247
- - @cutting/use-get-parent-size@2.1.9
248
- - @cutting/util@4.58.8
249
-
250
- ## 4.54.14
251
-
252
- ### Patch Changes
253
-
254
- - @cutting/use-get-parent-size@2.1.8
255
- - @cutting/util@4.58.7
256
-
257
- ## 4.54.13
258
-
259
- ### Patch Changes
260
-
261
- - 165f0cf: add .js to imports
262
- - Updated dependencies [165f0cf]
263
- - @cutting/use-get-parent-size@2.1.7
264
- - @cutting/util@4.58.6
265
-
266
- ## 4.54.12
267
-
268
- ### Patch Changes
269
-
270
- - 00126046: bump everything
271
- - Updated dependencies [00126046]
272
- - @cutting/react-abortable-fetch@0.36.5
273
- - @cutting/use-get-parent-size@2.1.6
274
- - @cutting/util@4.58.5
275
-
276
- ## 4.54.11
277
-
278
- ### Patch Changes
279
-
280
- - 9d181d61: update major dependencies
281
- - Updated dependencies [9d181d61]
282
- - @cutting/react-abortable-fetch@0.36.4
283
- - @cutting/use-get-parent-size@2.1.5
284
- - @cutting/util@4.58.4
285
-
286
- ## 4.54.10
287
-
288
- ### Patch Changes
289
-
290
- - bab1082d: make ResponsiveSVG overflow prop
291
-
292
- ## 4.54.9
293
-
294
- ### Patch Changes
295
-
296
- - Updated dependencies [45397d9a]
297
- - @cutting/react-abortable-fetch@0.36.3
298
- - @cutting/use-get-parent-size@2.1.4
299
- - @cutting/util@4.58.3
300
-
301
- ## 4.54.8
302
-
303
- ### Patch Changes
304
-
305
- - Updated dependencies [7058f9e4]
306
- - @cutting/use-get-parent-size@2.1.3
307
-
308
- ## 4.54.7
309
-
310
- ### Patch Changes
311
-
312
- - Updated dependencies [0f482989]
313
- - @cutting/use-get-parent-size@2.1.2
314
-
315
- ## 4.54.6
316
-
317
- ### Patch Changes
318
-
319
- - Updated dependencies [f0d92534]
320
- - @cutting/use-get-parent-size@2.1.1
321
-
322
- ## 4.54.5
323
-
324
- ### Patch Changes
325
-
326
- - Updated dependencies [406f9e7e]
327
- - @cutting/use-get-parent-size@2.1.0
328
-
329
- ## 4.54.4
330
-
331
- ### Patch Changes
332
-
333
- - e2d4179f: update dependencies
334
- - Updated dependencies [e2d4179f]
335
- - @cutting/react-abortable-fetch@0.36.2
336
- - @cutting/use-get-parent-size@2.0.2
337
- - @cutting/util@4.58.2
338
-
339
- ## 4.54.3
340
-
341
- ### Patch Changes
342
-
343
- - 79c7b329: return whole DOMRect
344
- - Updated dependencies [79c7b329]
345
- - @cutting/use-get-parent-size@2.0.1
346
-
347
- ## 4.54.2
348
-
349
- ### Patch Changes
350
-
351
- - Updated dependencies [f369fc43]
352
- - @cutting/use-get-parent-size@2.0.0
353
-
354
- ## 4.54.1
355
-
356
- ### Patch Changes
357
-
358
- - Updated dependencies [b743bae4]
359
- - @cutting/util@4.58.1
360
- - @cutting/react-abortable-fetch@0.36.1
361
- - @cutting/use-get-parent-size@1.27.1
362
-
363
- ## 4.54.0
364
-
365
- ### Minor Changes
366
-
367
- - 2cbd4b74: bump all dependencies, pnpm and update renovate
368
-
369
- ### Patch Changes
370
-
371
- - Updated dependencies [2cbd4b74]
372
- - @cutting/use-get-parent-size@1.27.0
373
- - @cutting/react-abortable-fetch@0.36.0
374
- - @cutting/util@4.58.0
375
-
376
- ## 4.53.1
377
-
378
- ### Patch Changes
379
-
380
- - f80075f8: rename cuttoff to maxDifference
381
- - Updated dependencies [f80075f8]
382
- - @cutting/use-get-parent-size@1.26.2
383
-
384
- ## 4.53.0
385
-
386
- ### Minor Changes
387
-
388
- - ce19c98e: more responsive fixes
389
-
390
- ### Patch Changes
391
-
392
- - @cutting/use-get-parent-size@1.26.1
393
-
394
- ## 4.52.2
395
-
396
- ### Patch Changes
397
-
398
- - 90d6df6f: better layout for ApplicationLayout
399
- - @cutting/use-get-parent-size@1.26.1
400
-
401
- ## 4.52.1
402
-
403
- ### Patch Changes
404
-
405
- - 7405910f: fix use-get-parentsize constant resizing problem
406
- - Updated dependencies [7405910f]
407
- - @cutting/react-abortable-fetch@0.35.1
408
- - @cutting/use-get-parent-size@1.26.1
409
- - @cutting/util@4.57.1
410
-
411
- ## 4.52.0
412
-
413
- ### Minor Changes
414
-
415
- - f429be7a: upgrade to node 18
416
-
417
- ### Patch Changes
418
-
419
- - Updated dependencies [f429be7a]
420
- - @cutting/react-abortable-fetch@0.35.0
421
- - @cutting/use-get-parent-size@1.26.0
422
- - @cutting/util@4.57.0
423
-
424
- ## 4.51.0
425
-
426
- ### Minor Changes
427
-
428
- - 907b7c62: bump versions
429
-
430
- ### Patch Changes
431
-
432
- - Updated dependencies [907b7c62]
433
- - @cutting/react-abortable-fetch@0.34.0
434
- - @cutting/use-get-parent-size@1.25.0
435
- - @cutting/util@4.56.0
436
-
437
- ## 4.50.2
438
-
439
- ### Patch Changes
440
-
441
- - dbc72c3b: add tangent
442
- - Updated dependencies [dbc72c3b]
443
- - @cutting/util@4.55.1
444
- - @cutting/use-get-parent-size@1.24.2
445
- - @cutting/react-abortable-fetch@0.33.1
446
-
447
- ## 4.50.1
448
-
449
- ### Patch Changes
450
-
451
- - @cutting/use-get-parent-size@1.24.1
452
-
453
- ## 4.50.0
454
-
455
- ### Minor Changes
456
-
457
- - 6927f7bd: remove babel completely
458
-
459
- ### Patch Changes
460
-
461
- - Updated dependencies [6927f7bd]
462
- - @cutting/react-abortable-fetch@0.33.0
463
- - @cutting/use-get-parent-size@1.24.0
464
- - @cutting/util@4.55.0
465
-
466
- ## 4.49.0
467
-
468
- ### Minor Changes
469
-
470
- - 3c3e166a: replace flex with css grid for main layouts
471
-
472
- ### Patch Changes
473
-
474
- - Updated dependencies [3c3e166a]
475
- - @cutting/react-abortable-fetch@0.32.0
476
- - @cutting/use-get-parent-size@1.23.0
477
- - @cutting/util@4.54.0
478
-
479
- ## 4.48.0
480
-
481
- ### Minor Changes
482
-
483
- - 6d9b0d40: remove @vanilla-extract/babel-plugin
484
-
485
- ### Patch Changes
486
-
487
- - Updated dependencies [6d9b0d40]
488
- - @cutting/react-abortable-fetch@0.31.0
489
- - @cutting/use-get-parent-size@1.22.0
490
- - @cutting/util@4.54.0
491
-
492
- ## 4.47.0
493
-
494
- ### Minor Changes
495
-
496
- - 7100e435: kill webpack
497
-
498
- ### Patch Changes
499
-
500
- - Updated dependencies [7100e435]
501
- - @cutting/react-abortable-fetch@0.30.0
502
- - @cutting/use-get-parent-size@1.21.0
503
- - @cutting/util@4.53.0
504
-
505
- ## 4.46.0
506
-
507
- ### Minor Changes
508
-
509
- - d0f474b0: Release new esm versions of packages
510
-
511
- ### Patch Changes
512
-
513
- - Updated dependencies [d0f474b0]
514
- - @cutting/use-get-parent-size@1.20.0
515
- - @cutting/util@4.52.0
516
-
517
- ## 4.45.3
518
-
519
- ### Patch Changes
520
-
521
- - Updated dependencies [1781542e]
522
- - @cutting/util@4.51.0
523
- - @cutting/use-get-parent-size@1.19.3
524
-
525
- ## 4.45.2
526
-
527
- ### Patch Changes
528
-
529
- - Updated dependencies [f732b2a7]
530
- - @cutting/util@4.50.2
531
- - @cutting/use-get-parent-size@1.19.2
532
-
533
- ## 4.45.1
534
-
535
- ### Patch Changes
536
-
537
- - afb80318: bump
538
- - Updated dependencies [afb80318]
539
- - @cutting/use-get-parent-size@1.19.1
540
- - @cutting/util@4.50.1
541
-
542
- ## 4.45.0
543
-
544
- ### Minor Changes
545
-
546
- - a38ea904: reset changelogs
547
-
548
- ### Patch Changes
549
-
550
- - Updated dependencies [a38ea904]
551
- - @cutting/use-get-parent-size@1.19.0
552
- - @cutting/util@4.50.0
package/demo/index.html DELETED
@@ -1,17 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
7
- <meta name="theme-color" content="#000000">
8
- <link rel="shortcut icon" href="/favicon.ico">
9
- <title>@cutting/svg</title>
10
- </head>
11
-
12
- <body>
13
- <div id="root"></div>
14
- <script type="module" src="src/index.tsx"></script>
15
- </body>
16
-
17
- </html>
package/demo/src/App.tsx DELETED
@@ -1,41 +0,0 @@
1
- import '@cutting/component-library/styles.css';
2
-
3
- import { ApplicationLayout } from '@cutting/component-library';
4
- import { useParentSize } from '@cutting/use-get-parent-size';
5
- import { range } from '@cutting/util';
6
- import { scalePoint } from '@visx/scale';
7
- import { useMemo, useRef } from 'react';
8
-
9
- import { ResponsiveSVG } from '../../src/components/ResponsiveSVG/ResponsiveSVG';
10
- import * as styles from './global.css';
11
-
12
- export function App(): JSX.Element {
13
- const ref = useRef<HTMLDivElement>(null);
14
- const { width = 1, height = 1 } = useParentSize(ref);
15
-
16
- const { xScale, yScale, radius } = useMemo(() => {
17
- const xScale = scalePoint({
18
- domain: [...range(10)],
19
- range: [0, width],
20
- });
21
-
22
- const yScale = scalePoint({
23
- domain: [...range(10)],
24
- range: [0, height],
25
- });
26
-
27
- const radius = yScale(5);
28
-
29
- return { radius, xScale, yScale };
30
- }, [width, height]);
31
-
32
- return (
33
- <ApplicationLayout heading="@cutting/svg" theme="salesTheme">
34
- <div className={styles.container} ref={ref}>
35
- <ResponsiveSVG width={width} height={height}>
36
- <circle cx={xScale(5)} cy={yScale(5)} r={radius} fill="#ffffff" />
37
- </ResponsiveSVG>
38
- </div>
39
- </ApplicationLayout>
40
- );
41
- }
@@ -1,17 +0,0 @@
1
- import { globalStyle, style } from '@vanilla-extract/css';
2
-
3
- export const container = style({
4
- background: 'grey',
5
- color: 'white',
6
- resize: 'both',
7
- width: '100%',
8
- height: '100%',
9
- });
10
-
11
- globalStyle('svg', {
12
- border: '1px solid royalblue;',
13
- });
14
-
15
- globalStyle('circle', {
16
- stroke: '#000000',
17
- });
@@ -1,21 +0,0 @@
1
- import { assert } from '@cutting/assert';
2
- import type { FunctionComponent } from 'react';
3
- import { createRoot } from 'react-dom/client';
4
-
5
- import { App } from './App';
6
-
7
- export const container = document.getElementById('root');
8
-
9
- assert(!!container, `no container found for #root`);
10
-
11
- const root = createRoot(container);
12
-
13
- const render = (Component: FunctionComponent) => {
14
- root.render(<Component />);
15
- };
16
-
17
- render(App);
18
-
19
- if (import.meta.hot) {
20
- import.meta.hot.accept('./App', () => import('./App').then((m) => render(m.App)));
21
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src"
5
- },
6
- "include": ["src/**/*.ts", "src/**/*.tsx"],
7
- "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
8
- }
@@ -1,15 +0,0 @@
1
- type GroupOnlyProps = {
2
- /** Top offset applied to `<g/>`. */
3
- y?: number;
4
- /** Left offset applied to `<g/>`. */
5
- x?: number;
6
- /** Override `x` and `y` to provide the entire `transform` string. */
7
- transform?: string;
8
- className?: string;
9
- children?: React.ReactNode;
10
- innerRef?: React.Ref<SVGGElement>;
11
- };
12
- type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
13
- export declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
14
- export {};
15
- //# sourceMappingURL=Group.d.ts.map
@@ -1 +0,0 @@
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,12 +0,0 @@
1
- import type { AddSVGProps, Point } from '../../types/types';
2
- export type LineProps = {
3
- className?: string;
4
- innerRef?: React.Ref<SVGLineElement>;
5
- fill?: string;
6
- /** Starting x,y point of the line. */
7
- from?: Point;
8
- /** Ending x,y point of the line. */
9
- to?: Point;
10
- };
11
- export declare function Line({ from, to, fill, className, innerRef, ...restProps }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element;
12
- //# sourceMappingURL=Line.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AAEA,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,13 +0,0 @@
1
- import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
2
- import type { PropsWithChildren, RefObject } from 'react';
3
- import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';
4
- type Align = 'none' | 'center';
5
- export type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
6
- parentRef: RefObject<E>;
7
- align?: Align;
8
- scale?: number;
9
- options?: Partial<UseParentSizeOptions>;
10
- } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
11
- export declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, options, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
12
- export {};
13
- //# sourceMappingURL=ParentsizeSVG.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,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,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,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,SAAS,EACT,QAAQ,EACR,OAAO,EACP,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAQ/D"}
@@ -1,19 +0,0 @@
1
- import type { ReactNode, Ref } from 'react';
2
- import type { PreserveAspectRatio, SVGAttributes } from '../../types/types';
3
- export interface Point {
4
- x: number;
5
- y: number;
6
- }
7
- export type ResponsiveSVGProps = SVGAttributes<{
8
- width?: number;
9
- height?: number;
10
- origin?: Point;
11
- preserveAspectRatio?: PreserveAspectRatio;
12
- innerRef?: Ref<SVGSVGElement>;
13
- className?: string;
14
- hide?: boolean;
15
- children: ReactNode;
16
- overflow?: 'hidden' | 'visible';
17
- }>;
18
- export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, overflow, ...props }: ResponsiveSVGProps): JSX.Element;
19
- //# sourceMappingURL=ResponsiveSVG.d.ts.map
@@ -1 +0,0 @@
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;AAE5C,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,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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;IACpB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACjC,CAAC,CAAC;AAEH,wBAAgB,aAAa,CAAC,EAC5B,MAAU,EACV,KAAS,EACT,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,EACT,QAAoB,EACpB,GAAG,KAAK,EACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CA0BlC"}
@@ -1,11 +0,0 @@
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}` | 'none';
5
- export type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
6
- export interface Point {
7
- x: number;
8
- y: number;
9
- }
10
- export type SVGAttributes<T> = T & Omit<SvgAttributes<SVGSVGElement>, 'origin' | 'viewBox' | 'preserveAspectRatio' | 'children '>;
11
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC;AAE5D,MAAM,MAAM,4BAA4B,GACpC,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AAEf,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG,GAAG,4BAA4B,IAAI,WAAW,EAAE,GAAG,MAAM,CAAC;AAE5F,MAAM,MAAM,WAAW,CAAC,KAAK,EAAE,OAAO,SAAS,UAAU,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,CAAC,CAAC;AAEhH,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,GAC9B,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,qBAAqB,GAAG,WAAW,CAAC,CAAC"}
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import defaultConfig from '@cutting/eslint-config/react'
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default [...defaultConfig]
package/img/sizer.gif DELETED
Binary file
@@ -1,36 +0,0 @@
1
- import cx from 'classnames';
2
-
3
- type GroupOnlyProps = {
4
- /** Top offset applied to `<g/>`. */
5
- y?: number;
6
- /** Left offset applied to `<g/>`. */
7
- x?: number;
8
- /** Override `x` and `y` to provide the entire `transform` string. */
9
- transform?: string;
10
- className?: string;
11
- children?: React.ReactNode;
12
- innerRef?: React.Ref<SVGGElement>;
13
- };
14
-
15
- type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
16
-
17
- export function Group({
18
- y = 0,
19
- x = 0,
20
- transform,
21
- className,
22
- children,
23
- innerRef,
24
- ...restProps
25
- }: GroupProps): JSX.Element {
26
- return (
27
- <g
28
- ref={innerRef}
29
- className={cx('visx-group', className)}
30
- transform={transform || `translate(${x}, ${y})`}
31
- {...restProps}
32
- >
33
- {children}
34
- </g>
35
- );
36
- }
@@ -1,38 +0,0 @@
1
- import cx from 'classnames';
2
-
3
- import type { AddSVGProps, Point } from '../../types/types';
4
-
5
- export type LineProps = {
6
- className?: string;
7
- innerRef?: React.Ref<SVGLineElement>;
8
- fill?: string;
9
- /** Starting x,y point of the line. */
10
- from?: Point;
11
- /** Ending x,y point of the line. */
12
- to?: Point;
13
- };
14
-
15
- export function Line({
16
- from = { x: 0, y: 0 },
17
- to = { x: 1, y: 1 },
18
- fill = 'transparent',
19
- className,
20
- innerRef,
21
- ...restProps
22
- }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {
23
- const isRectilinear = from.x === to.x || from.y === to.y;
24
-
25
- return (
26
- <line
27
- ref={innerRef}
28
- className={cx('visx-line', className)}
29
- x1={from.x}
30
- y1={from.y}
31
- x2={to.x}
32
- y2={to.y}
33
- fill={fill}
34
- shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}
35
- {...restProps}
36
- />
37
- );
38
- }
@@ -1,34 +0,0 @@
1
- import { useParentSize } from '@cutting/use-get-parent-size';
2
- import { render, screen } from '@testing-library/react';
3
- import { useRef } from 'react';
4
- import { describe, expect, it } from 'vitest';
5
-
6
- import type { ParentsizeSVGProps } from './ParentsizeSVG';
7
- import { ParentsizeSVG } from './ParentsizeSVG';
8
-
9
- function TestEr(props: Partial<ParentsizeSVGProps>) {
10
- const ref = useRef<HTMLDivElement>(null);
11
- useParentSize(ref);
12
-
13
- return (
14
- <div ref={ref} style={{ width: '100vw', height: '100vh' }}>
15
- <ParentsizeSVG {...props} parentRef={ref}>
16
- <rect x="20%" y="20%" width="200px" height="200px" rx="20" />
17
- </ParentsizeSVG>
18
- </div>
19
- );
20
- }
21
-
22
- const wrap = (props: Partial<ParentsizeSVGProps> = {}) => render(<TestEr {...props} />);
23
-
24
- describe.skip('useParentSize', () => {
25
- it('should set the svg viewBox attribute', () => {
26
- wrap();
27
-
28
- const svg = document.querySelector('svg') as SVGElement;
29
-
30
- expect(svg.getAttribute('viewBox')).toBe('0 0 0 0');
31
-
32
- screen.getByTestId('cutting-svg-container');
33
- });
34
- });
@@ -1,30 +0,0 @@
1
- import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
2
- import { useParentSize } from '@cutting/use-get-parent-size';
3
- import type { PropsWithChildren, RefObject } from 'react';
4
-
5
- import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';
6
- import { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';
7
-
8
- type Align = 'none' | 'center';
9
-
10
- export type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
11
- parentRef: RefObject<E>;
12
- align?: Align;
13
- scale?: number;
14
- options?: Partial<UseParentSizeOptions>;
15
- } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
16
-
17
- export function ParentsizeSVG<E extends HTMLElement>({
18
- parentRef,
19
- children,
20
- options,
21
- ...rest
22
- }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {
23
- const { width, height } = useParentSize(parentRef, options);
24
-
25
- return (
26
- <ResponsiveSVG width={width} height={height} {...rest}>
27
- {children}
28
- </ResponsiveSVG>
29
- );
30
- }
@@ -1,58 +0,0 @@
1
- import type { ReactNode, Ref } from 'react';
2
-
3
- import type { PreserveAspectRatio, SVGAttributes } from '../../types/types';
4
-
5
- export interface Point {
6
- x: number;
7
- y: number;
8
- }
9
-
10
- export type ResponsiveSVGProps = SVGAttributes<{
11
- width?: number;
12
- height?: number;
13
- origin?: Point;
14
- preserveAspectRatio?: PreserveAspectRatio;
15
- innerRef?: Ref<SVGSVGElement>;
16
- className?: string;
17
- hide?: boolean;
18
- children: ReactNode;
19
- overflow?: 'hidden' | 'visible';
20
- }>;
21
-
22
- export function ResponsiveSVG({
23
- height = 0,
24
- width = 0,
25
- children,
26
- origin = { x: 0, y: 0 },
27
- preserveAspectRatio = 'xMaxYMid meet',
28
- innerRef,
29
- className,
30
- overflow = 'visible',
31
- ...props
32
- }: ResponsiveSVGProps): JSX.Element {
33
- const aspect = height === 0 ? 1 : width / height;
34
-
35
- const adjustedHeight = Math.ceil(width / aspect);
36
-
37
- return (
38
- <div
39
- data-testid="cutting-svg-container"
40
- style={{
41
- position: 'relative',
42
- overflow: 'visible',
43
- height: '0px',
44
- }}
45
- >
46
- <svg
47
- style={{ overflow, width: '100%', height: 'auto' }}
48
- className={className}
49
- preserveAspectRatio={preserveAspectRatio}
50
- viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}
51
- ref={innerRef}
52
- {...props}
53
- >
54
- {children}
55
- </svg>
56
- </div>
57
- );
58
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export { Group } from './components/Group/Group';
2
- export { Line } from './components/Line/Line';
3
- export { ParentsizeSVG } from './components/ParentsizeSVG/ParentsizeSVG';
4
- export { ResponsiveSVG } from './components/ResponsiveSVG/ResponsiveSVG';
5
- export type { Point } from './types/types';
@@ -1,26 +0,0 @@
1
- import type { SVGAttributes as SvgAttributes } from 'react';
2
-
3
- export type PreserveAspectRatioAlignment =
4
- | 'xMinYMin'
5
- | 'xMidYMin'
6
- | 'xMaxYMin'
7
- | 'xMinYMid'
8
- | 'xMidYMid'
9
- | 'xMaxYMid'
10
- | 'xMinYMax'
11
- | 'xMidYMax'
12
- | 'xMaxYMax';
13
-
14
- export type MeetOrSlice = 'meet' | 'slice';
15
-
16
- export type PreserveAspectRatio = `${PreserveAspectRatioAlignment} ${MeetOrSlice}` | 'none';
17
-
18
- export type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
19
-
20
- export interface Point {
21
- x: number;
22
- y: number;
23
- }
24
-
25
- export type SVGAttributes<T> = T &
26
- Omit<SvgAttributes<SVGSVGElement>, 'origin' | 'viewBox' | 'preserveAspectRatio' | 'children '>;
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "noEmit": false
6
- },
7
- "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx", "demo"]
8
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig-base.json",
3
- "compilerOptions": {
4
- "rootDirs": ["src", "demo"],
5
- "noEmit": true
6
- },
7
- "include": ["src/**/*.ts", "src/**/*.tsx", "demo"]
8
- }
package/vite.config.ts DELETED
@@ -1,17 +0,0 @@
1
- import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
2
- import react from '@vitejs/plugin-react';
3
- import { defineConfig } from 'vitest/config';
4
-
5
- const isTest = process.env.NODE_ENV === 'test';
6
-
7
- // https://vitejs.dev/config/
8
- export default defineConfig({
9
- root: isTest ? '.' : 'demo',
10
- plugins: [vanillaExtractPlugin(), react()],
11
- test: {
12
- globals: true,
13
- environment: 'jsdom',
14
- setupFiles: '@cutting/devtools/setuptests',
15
- css: true,
16
- },
17
- });