@cutting/svg 4.64.0 → 4.65.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.
@@ -0,0 +1,70 @@
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
+ export 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
+ export 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
+ export 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
+ export declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, options, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
68
+ //#endregion
69
+ export type { Point };
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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;wBAE3D,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;;wBAGS,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;;wBAGc,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;wBAED,cAAc,UAAU,eACtC,WACA,UACA,YACG,QACF,kBAAkB,mBAAmB,MAAM,IAAI"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
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.64.0",
3
+ "version": "4.65.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
@@ -9,29 +9,32 @@
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.7.0",
15
- "@cutting/use-get-parent-size": "2.11.0",
16
- "@cutting/util": "4.66.0"
17
+ "@cutting/assert": "0.7.1",
18
+ "@cutting/use-get-parent-size": "2.12.0",
19
+ "@cutting/util": "4.66.1"
17
20
  },
18
21
  "devDependencies": {
19
22
  "@testing-library/dom": "10.4.1",
20
- "@testing-library/react": "16.3.2",
21
- "@testing-library/user-event": "14.6.1",
23
+ "@testing-library/react": "16.3.3",
24
+ "@testing-library/user-event": "14.6.7",
22
25
  "@visx/scale": "4.0.0",
23
26
  "classnames": "2.5.1",
24
27
  "d3-scale": "4.0.2",
25
- "react": "19.2.7",
26
- "react-dom": "19.2.7",
27
- "@cutting/component-library": "5.52.0"
28
+ "react": "19.2.8",
29
+ "react-dom": "19.2.8",
30
+ "@cutting/component-library": "5.53.0"
28
31
  },
29
32
  "peerDependencies": {
30
33
  "@visx/scale": "4.0.0",
31
34
  "classnames": "2.5.1",
32
35
  "d3-scale": "4.0.2",
33
- "react": "19.2.7",
34
- "react-dom": "19.2.7"
36
+ "react": "19.2.8",
37
+ "react-dom": "19.2.8"
35
38
  },
36
39
  "volta": {
37
40
  "extends": "../../package.json"
package/.watchmanconfig DELETED
@@ -1 +0,0 @@
1
- {}
package/CHANGELOG.md DELETED
@@ -1,565 +0,0 @@
1
- # @cutting/svg
2
-
3
- ## 4.64.0
4
-
5
- ### Minor Changes
6
-
7
- - 5dd8f8f: upgrade pnpm to 11.15.1 and dependency upgrade apart from typescript 7 (pinned at 6.0.3 until typescript-eslint supports the TS 7.1 API), migrate the devtools bundler from rollup to rolldown: declarations now come from rolldown-plugin-dts and minification from rolldown instead of terser, and packages type-check with tsc --noEmit before bundling
8
-
9
- ### Patch Changes
10
-
11
- - Updated dependencies [5dd8f8f]
12
- - @cutting/use-get-parent-size@2.11.0
13
- - @cutting/assert@0.7.0
14
- - @cutting/util@4.66.0
15
-
16
- ## 4.63.0
17
-
18
- ### Minor Changes
19
-
20
- - c702763: upgrade @visx to 4
21
-
22
- ### Patch Changes
23
-
24
- - Updated dependencies [c702763]
25
- - @cutting/use-get-parent-size@2.10.0
26
-
27
- ## 4.62.1
28
-
29
- ### Patch Changes
30
-
31
- - 88e84cb: add changeset for patch version bump to update react and related dependencies across all packages
32
- - Updated dependencies [88e84cb]
33
- - @cutting/use-get-parent-size@2.9.1
34
- - @cutting/assert@0.6.1
35
- - @cutting/util@4.65.1
36
-
37
- ## 4.62.0
38
-
39
- ### Minor Changes
40
-
41
- - d91afd0: bump
42
-
43
- ### Patch Changes
44
-
45
- - Updated dependencies [d91afd0]
46
- - @cutting/assert@0.6.0
47
- - @cutting/use-get-parent-size@2.9.0
48
- - @cutting/util@4.65.0
49
-
50
- ## 4.61.0
51
-
52
- ### Minor Changes
53
-
54
- - 98caae6: upgrade to typescript 6.0
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [98caae6]
59
- - @cutting/use-get-parent-size@2.8.0
60
- - @cutting/assert@0.5.0
61
- - @cutting/util@4.64.0
62
-
63
- ## 4.61.0
64
-
65
- ### Minor Changes
66
-
67
- - af733ed: again again again
68
-
69
- ### Patch Changes
70
-
71
- - Updated dependencies [af733ed]
72
- - @cutting/assert@0.5.0
73
- - @cutting/use-get-parent-size@2.8.0
74
- - @cutting/util@4.64.0
75
-
76
- ## 4.61.0
77
-
78
- ### Minor Changes
79
-
80
- - 510343b: revert
81
-
82
- ### Patch Changes
83
-
84
- - Updated dependencies [510343b]
85
- - @cutting/use-get-parent-size@2.8.0
86
- - @cutting/assert@0.5.0
87
- - @cutting/util@4.64.0
88
-
89
- ## 4.61.0
90
-
91
- ### Minor Changes
92
-
93
- - 54f4b15: again
94
- - 958b9fa: again
95
- - de29d47: cu
96
- - 5108680: again
97
- - bf42836: upgrade react to 19.2.3
98
- - cf8b2f2: shit
99
-
100
- ### Patch Changes
101
-
102
- - Updated dependencies [54f4b15]
103
- - Updated dependencies [958b9fa]
104
- - Updated dependencies [de29d47]
105
- - Updated dependencies [5108680]
106
- - Updated dependencies [bf42836]
107
- - Updated dependencies [cf8b2f2]
108
- - @cutting/assert@0.5.0
109
- - @cutting/use-get-parent-size@2.8.0
110
- - @cutting/util@4.64.0
111
-
112
- ## 4.60.0
113
-
114
- ### Minor Changes
115
-
116
- - c69a4bb: update react to 19.2.0
117
-
118
- ### Patch Changes
119
-
120
- - Updated dependencies [c69a4bb]
121
- - @cutting/assert@0.4.0
122
- - @cutting/use-get-parent-size@2.7.0
123
- - @cutting/util@4.63.0
124
-
125
- ## 4.59.0
126
-
127
- ### Minor Changes
128
-
129
- - 8e62b3f: cunt
130
-
131
- ### Patch Changes
132
-
133
- - Updated dependencies [8e62b3f]
134
- - @cutting/assert@0.3.0
135
- - @cutting/use-get-parent-size@2.6.0
136
- - @cutting/util@4.62.0
137
-
138
- ## 4.58.0
139
-
140
- ### Minor Changes
141
-
142
- - b3a8f90: bump react to 17.1.1
143
- - 10a1082: update
144
-
145
- ### Patch Changes
146
-
147
- - Updated dependencies [b3a8f90]
148
- - Updated dependencies [10a1082]
149
- - @cutting/use-get-parent-size@2.5.0
150
- - @cutting/assert@0.2.0
151
- - @cutting/util@4.61.0
152
-
153
- ## 4.57.0
154
-
155
- ### Minor Changes
156
-
157
- - 7b27210: react 19.1.0
158
-
159
- ### Patch Changes
160
-
161
- - Updated dependencies [7b27210]
162
- - @cutting/use-get-parent-size@2.4.0
163
-
164
- ## 4.56.0
165
-
166
- ### Minor Changes
167
-
168
- - fac6b45: introduce new jsx.d.ts to @cutting/useful-types
169
-
170
- ### Patch Changes
171
-
172
- - Updated dependencies [fac6b45]
173
- - @cutting/use-get-parent-size@2.3.0
174
-
175
- ## 4.55.0
176
-
177
- ### Minor Changes
178
-
179
- - 27b80a8: update react to 19
180
-
181
- ### Patch Changes
182
-
183
- - Updated dependencies [27b80a8]
184
- - @cutting/use-get-parent-size@2.2.0
185
- - @cutting/util@4.60.0
186
-
187
- ## 4.54.23
188
-
189
- ### Patch Changes
190
-
191
- - 0f6945d: upgrade pnpm to 9.4.0
192
- - Updated dependencies [0f6945d]
193
- - @cutting/use-get-parent-size@2.1.16
194
-
195
- ## 4.54.22
196
-
197
- ### Patch Changes
198
-
199
- - 86c6bb0: update pnpm to 9.2.0
200
- - Updated dependencies [86c6bb0]
201
- - @cutting/use-get-parent-size@2.1.15
202
-
203
- ## 4.54.21
204
-
205
- ### Patch Changes
206
-
207
- - 857cd84: update all dependencies
208
- - Updated dependencies [857cd84]
209
- - @cutting/use-get-parent-size@2.1.14
210
-
211
- ## 4.54.20
212
-
213
- ### Patch Changes
214
-
215
- - 6000f90: upgrade to pnpm 9.1.0
216
- - Updated dependencies [6000f90]
217
- - @cutting/use-get-parent-size@2.1.13
218
-
219
- ## 4.54.19
220
-
221
- ### Patch Changes
222
-
223
- - f8374ed: update dependencies and pnpm to 8.15.7
224
- - Updated dependencies [f8374ed]
225
- - @cutting/use-get-parent-size@2.1.12
226
- - @cutting/util@4.59.2
227
-
228
- ## 4.54.18
229
-
230
- ### Patch Changes
231
-
232
- - df504df: update pnpm to 8.15.5
233
- - Updated dependencies [df504df]
234
- - @cutting/use-get-parent-size@2.1.11
235
- - @cutting/util@4.59.1
236
-
237
- ## 4.54.17
238
-
239
- ### Patch Changes
240
-
241
- - Updated dependencies [dddd0a0]
242
- - @cutting/util@4.59.0
243
- - @cutting/use-get-parent-size@2.1.10
244
-
245
- ## 4.54.16
246
-
247
- ### Patch Changes
248
-
249
- - 2fb3912: update dependencies
250
- - Updated dependencies [2fb3912]
251
- - @cutting/use-get-parent-size@2.1.10
252
- - @cutting/util@4.58.9
253
-
254
- ## 4.54.15
255
-
256
- ### Patch Changes
257
-
258
- - 2f5abbc: update to pnpm 8.15.4
259
- - Updated dependencies [2f5abbc]
260
- - @cutting/use-get-parent-size@2.1.9
261
- - @cutting/util@4.58.8
262
-
263
- ## 4.54.14
264
-
265
- ### Patch Changes
266
-
267
- - @cutting/use-get-parent-size@2.1.8
268
- - @cutting/util@4.58.7
269
-
270
- ## 4.54.13
271
-
272
- ### Patch Changes
273
-
274
- - 165f0cf: add .js to imports
275
- - Updated dependencies [165f0cf]
276
- - @cutting/use-get-parent-size@2.1.7
277
- - @cutting/util@4.58.6
278
-
279
- ## 4.54.12
280
-
281
- ### Patch Changes
282
-
283
- - 00126046: bump everything
284
- - Updated dependencies [00126046]
285
- - @cutting/react-abortable-fetch@0.36.5
286
- - @cutting/use-get-parent-size@2.1.6
287
- - @cutting/util@4.58.5
288
-
289
- ## 4.54.11
290
-
291
- ### Patch Changes
292
-
293
- - 9d181d61: update major dependencies
294
- - Updated dependencies [9d181d61]
295
- - @cutting/react-abortable-fetch@0.36.4
296
- - @cutting/use-get-parent-size@2.1.5
297
- - @cutting/util@4.58.4
298
-
299
- ## 4.54.10
300
-
301
- ### Patch Changes
302
-
303
- - bab1082d: make ResponsiveSVG overflow prop
304
-
305
- ## 4.54.9
306
-
307
- ### Patch Changes
308
-
309
- - Updated dependencies [45397d9a]
310
- - @cutting/react-abortable-fetch@0.36.3
311
- - @cutting/use-get-parent-size@2.1.4
312
- - @cutting/util@4.58.3
313
-
314
- ## 4.54.8
315
-
316
- ### Patch Changes
317
-
318
- - Updated dependencies [7058f9e4]
319
- - @cutting/use-get-parent-size@2.1.3
320
-
321
- ## 4.54.7
322
-
323
- ### Patch Changes
324
-
325
- - Updated dependencies [0f482989]
326
- - @cutting/use-get-parent-size@2.1.2
327
-
328
- ## 4.54.6
329
-
330
- ### Patch Changes
331
-
332
- - Updated dependencies [f0d92534]
333
- - @cutting/use-get-parent-size@2.1.1
334
-
335
- ## 4.54.5
336
-
337
- ### Patch Changes
338
-
339
- - Updated dependencies [406f9e7e]
340
- - @cutting/use-get-parent-size@2.1.0
341
-
342
- ## 4.54.4
343
-
344
- ### Patch Changes
345
-
346
- - e2d4179f: update dependencies
347
- - Updated dependencies [e2d4179f]
348
- - @cutting/react-abortable-fetch@0.36.2
349
- - @cutting/use-get-parent-size@2.0.2
350
- - @cutting/util@4.58.2
351
-
352
- ## 4.54.3
353
-
354
- ### Patch Changes
355
-
356
- - 79c7b329: return whole DOMRect
357
- - Updated dependencies [79c7b329]
358
- - @cutting/use-get-parent-size@2.0.1
359
-
360
- ## 4.54.2
361
-
362
- ### Patch Changes
363
-
364
- - Updated dependencies [f369fc43]
365
- - @cutting/use-get-parent-size@2.0.0
366
-
367
- ## 4.54.1
368
-
369
- ### Patch Changes
370
-
371
- - Updated dependencies [b743bae4]
372
- - @cutting/util@4.58.1
373
- - @cutting/react-abortable-fetch@0.36.1
374
- - @cutting/use-get-parent-size@1.27.1
375
-
376
- ## 4.54.0
377
-
378
- ### Minor Changes
379
-
380
- - 2cbd4b74: bump all dependencies, pnpm and update renovate
381
-
382
- ### Patch Changes
383
-
384
- - Updated dependencies [2cbd4b74]
385
- - @cutting/use-get-parent-size@1.27.0
386
- - @cutting/react-abortable-fetch@0.36.0
387
- - @cutting/util@4.58.0
388
-
389
- ## 4.53.1
390
-
391
- ### Patch Changes
392
-
393
- - f80075f8: rename cuttoff to maxDifference
394
- - Updated dependencies [f80075f8]
395
- - @cutting/use-get-parent-size@1.26.2
396
-
397
- ## 4.53.0
398
-
399
- ### Minor Changes
400
-
401
- - ce19c98e: more responsive fixes
402
-
403
- ### Patch Changes
404
-
405
- - @cutting/use-get-parent-size@1.26.1
406
-
407
- ## 4.52.2
408
-
409
- ### Patch Changes
410
-
411
- - 90d6df6f: better layout for ApplicationLayout
412
- - @cutting/use-get-parent-size@1.26.1
413
-
414
- ## 4.52.1
415
-
416
- ### Patch Changes
417
-
418
- - 7405910f: fix use-get-parentsize constant resizing problem
419
- - Updated dependencies [7405910f]
420
- - @cutting/react-abortable-fetch@0.35.1
421
- - @cutting/use-get-parent-size@1.26.1
422
- - @cutting/util@4.57.1
423
-
424
- ## 4.52.0
425
-
426
- ### Minor Changes
427
-
428
- - f429be7a: upgrade to node 18
429
-
430
- ### Patch Changes
431
-
432
- - Updated dependencies [f429be7a]
433
- - @cutting/react-abortable-fetch@0.35.0
434
- - @cutting/use-get-parent-size@1.26.0
435
- - @cutting/util@4.57.0
436
-
437
- ## 4.51.0
438
-
439
- ### Minor Changes
440
-
441
- - 907b7c62: bump versions
442
-
443
- ### Patch Changes
444
-
445
- - Updated dependencies [907b7c62]
446
- - @cutting/react-abortable-fetch@0.34.0
447
- - @cutting/use-get-parent-size@1.25.0
448
- - @cutting/util@4.56.0
449
-
450
- ## 4.50.2
451
-
452
- ### Patch Changes
453
-
454
- - dbc72c3b: add tangent
455
- - Updated dependencies [dbc72c3b]
456
- - @cutting/util@4.55.1
457
- - @cutting/use-get-parent-size@1.24.2
458
- - @cutting/react-abortable-fetch@0.33.1
459
-
460
- ## 4.50.1
461
-
462
- ### Patch Changes
463
-
464
- - @cutting/use-get-parent-size@1.24.1
465
-
466
- ## 4.50.0
467
-
468
- ### Minor Changes
469
-
470
- - 6927f7bd: remove babel completely
471
-
472
- ### Patch Changes
473
-
474
- - Updated dependencies [6927f7bd]
475
- - @cutting/react-abortable-fetch@0.33.0
476
- - @cutting/use-get-parent-size@1.24.0
477
- - @cutting/util@4.55.0
478
-
479
- ## 4.49.0
480
-
481
- ### Minor Changes
482
-
483
- - 3c3e166a: replace flex with css grid for main layouts
484
-
485
- ### Patch Changes
486
-
487
- - Updated dependencies [3c3e166a]
488
- - @cutting/react-abortable-fetch@0.32.0
489
- - @cutting/use-get-parent-size@1.23.0
490
- - @cutting/util@4.54.0
491
-
492
- ## 4.48.0
493
-
494
- ### Minor Changes
495
-
496
- - 6d9b0d40: remove @vanilla-extract/babel-plugin
497
-
498
- ### Patch Changes
499
-
500
- - Updated dependencies [6d9b0d40]
501
- - @cutting/react-abortable-fetch@0.31.0
502
- - @cutting/use-get-parent-size@1.22.0
503
- - @cutting/util@4.54.0
504
-
505
- ## 4.47.0
506
-
507
- ### Minor Changes
508
-
509
- - 7100e435: kill webpack
510
-
511
- ### Patch Changes
512
-
513
- - Updated dependencies [7100e435]
514
- - @cutting/react-abortable-fetch@0.30.0
515
- - @cutting/use-get-parent-size@1.21.0
516
- - @cutting/util@4.53.0
517
-
518
- ## 4.46.0
519
-
520
- ### Minor Changes
521
-
522
- - d0f474b0: Release new esm versions of packages
523
-
524
- ### Patch Changes
525
-
526
- - Updated dependencies [d0f474b0]
527
- - @cutting/use-get-parent-size@1.20.0
528
- - @cutting/util@4.52.0
529
-
530
- ## 4.45.3
531
-
532
- ### Patch Changes
533
-
534
- - Updated dependencies [1781542e]
535
- - @cutting/util@4.51.0
536
- - @cutting/use-get-parent-size@1.19.3
537
-
538
- ## 4.45.2
539
-
540
- ### Patch Changes
541
-
542
- - Updated dependencies [f732b2a7]
543
- - @cutting/util@4.50.2
544
- - @cutting/use-get-parent-size@1.19.2
545
-
546
- ## 4.45.1
547
-
548
- ### Patch Changes
549
-
550
- - afb80318: bump
551
- - Updated dependencies [afb80318]
552
- - @cutting/use-get-parent-size@1.19.1
553
- - @cutting/util@4.50.1
554
-
555
- ## 4.45.0
556
-
557
- ### Minor Changes
558
-
559
- - a38ea904: reset changelogs
560
-
561
- ### Patch Changes
562
-
563
- - Updated dependencies [a38ea904]
564
- - @cutting/use-get-parent-size@1.19.0
565
- - @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
- }
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,18 +0,0 @@
1
- import type { SVGAttributes as SvgAttributes } from 'react';
2
-
3
- export type PreserveAspectRatioAlignment =
4
- 'xMinYMin' | 'xMidYMin' | 'xMaxYMin' | 'xMinYMid' | 'xMidYMid' | 'xMaxYMid' | 'xMinYMax' | 'xMidYMax' | 'xMaxYMax';
5
-
6
- export type MeetOrSlice = 'meet' | 'slice';
7
-
8
- export type PreserveAspectRatio = `${PreserveAspectRatioAlignment} ${MeetOrSlice}` | 'none';
9
-
10
- export type AddSVGProps<Props, Element extends SVGElement> = Props & Omit<React.SVGProps<Element>, keyof Props>;
11
-
12
- export interface Point {
13
- x: number;
14
- y: number;
15
- }
16
-
17
- export type SVGAttributes<T> = T &
18
- 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
- });