@cutting/svg 4.52.2 → 4.53.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.
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @cutting/svg
|
|
2
2
|
|
|
3
|
+
## 4.53.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f80075f8: rename cuttoff to maxDifference
|
|
8
|
+
- Updated dependencies [f80075f8]
|
|
9
|
+
- @cutting/use-get-parent-size@1.26.2
|
|
10
|
+
|
|
11
|
+
## 4.53.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- ce19c98e: more responsive fixes
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- @cutting/use-get-parent-size@1.26.1
|
|
20
|
+
|
|
3
21
|
## 4.52.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/demo/src/App.tsx
CHANGED
|
@@ -4,17 +4,25 @@ import { useMemo, useRef } from 'react';
|
|
|
4
4
|
import { ApplicationLayout } from '@cutting/component-library';
|
|
5
5
|
import { ResponsiveSVG } from '../../src/components/ResponsiveSVG/ResponsiveSVG';
|
|
6
6
|
import { useParentSize } from '@cutting/use-get-parent-size';
|
|
7
|
-
import {
|
|
7
|
+
import { scalePoint } from '@visx/scale';
|
|
8
|
+
import { range } from '@cutting/util';
|
|
8
9
|
|
|
9
10
|
export function App(): JSX.Element {
|
|
10
11
|
const ref = useRef<HTMLDivElement>(null);
|
|
11
12
|
const { width, height } = useParentSize(ref);
|
|
12
13
|
|
|
13
|
-
const { radius } = useMemo(() => {
|
|
14
|
-
const xScale =
|
|
15
|
-
|
|
14
|
+
const { xScale, yScale, radius } = useMemo(() => {
|
|
15
|
+
const xScale = scalePoint({
|
|
16
|
+
domain: [...range(10)],
|
|
17
|
+
range: [0, width],
|
|
18
|
+
});
|
|
16
19
|
|
|
17
|
-
const
|
|
20
|
+
const yScale = scalePoint({
|
|
21
|
+
domain: [...range(10)],
|
|
22
|
+
range: [0, height],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const radius = yScale(5);
|
|
18
26
|
|
|
19
27
|
return { radius, xScale, yScale };
|
|
20
28
|
}, [width, height]);
|
|
@@ -23,7 +31,7 @@ export function App(): JSX.Element {
|
|
|
23
31
|
<ApplicationLayout heading="@cutting/svg" theme="salesTheme">
|
|
24
32
|
<div className={styles.container} ref={ref}>
|
|
25
33
|
<ResponsiveSVG width={width} height={height}>
|
|
26
|
-
<circle cx={
|
|
34
|
+
<circle cx={xScale(5)} cy={yScale(5)} r={radius} fill="#ffffff" />
|
|
27
35
|
</ResponsiveSVG>
|
|
28
36
|
</div>
|
|
29
37
|
</ApplicationLayout>
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useParentSize as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useParentSize as t}from"@cutting/use-get-parent-size";import i from"classnames";function r({height:t,width:i,children:r,origin:n={x:0,y:0},preserveAspectRatio:s="xMaxYMid meet",innerRef:a,className:o,...c}){const l=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:"visible",width:"100%",height:"auto"},className:o,preserveAspectRatio:s,viewBox:`${n.x} ${n.y} ${i} ${l}`,ref:a,...c,children:r})})}function n({parentRef:i,children:n,options:s,...a}){const{width:o,height:c}=t(i,s);return e(r,{width:o,height:c,...a,children:n})}function s({y:t=0,x:r=0,transform:n,className:s,children:a,innerRef:o,...c}){return e("g",{ref:o,className:i("visx-group",s),transform:n||`translate(${r}, ${t})`,...c,children:a})}function a({from:t={x:0,y:0},to:r={x:1,y:1},fill:n="transparent",className:s,innerRef:a,...o}){const c=t.x===r.x||t.y===r.y;return e("line",{ref:a,className:i("visx-line",s),x1:t.x,y1:t.y,x2:r.x,y2:r.y,fill:n,shapeRendering:c?"crispEdges":"auto",...o})}export{s as Group,a as Line,n as ParentsizeSVG,r as ResponsiveSVG};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio, SVGAttributes } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport type ResponsiveSVGProps = SVGAttributes<{\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}>;\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n ...props\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = 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: '
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio, SVGAttributes } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport type ResponsiveSVGProps = SVGAttributes<{\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}>;\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n ...props\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = height === 0 ? 1 : width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-testid=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '0px',\n }}\n >\n <svg\n style={{ overflow: 'visible', 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 { PropsWithChildren, RefObject } from 'react';\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG.js';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\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 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","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","ParentsizeSVG","parentRef","options","rest","useParentSize","Group","transform","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"+HAmBgB,SAAAA,GAAcC,OAC5BA,EAAMC,MACNA,EAAKC,SACLA,EAAQC,OACRA,EAAS,CAAEC,EAAG,EAAGC,EAAG,GAAGC,oBACvBA,EAAsB,gBAAeC,SACrCA,EAAQC,UACRA,KACGC,IAEH,MAEMC,EAAiBC,KAAKC,KAAKX,GAFP,IAAXD,EAAe,EAAIC,EAAQD,IAI1C,OACEa,EAAA,MAA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|
{
|
|
2
2
|
"name": "@cutting/svg",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.53.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dagda1/cuttingedge.git"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"classnames": "^2.3.2",
|
|
15
15
|
"resize-observer-polyfill": "^1.5.1",
|
|
16
16
|
"@cutting/react-abortable-fetch": "0.35.1",
|
|
17
|
-
"@cutting/use-get-parent-size": "1.26.
|
|
17
|
+
"@cutting/use-get-parent-size": "1.26.2",
|
|
18
18
|
"@cutting/util": "4.57.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"@types/react-dom": "18.0.11",
|
|
26
26
|
"@vanilla-extract/css": "^1.9.5",
|
|
27
27
|
"@vanilla-extract/sprinkles": "1.5.1",
|
|
28
|
+
"@visx/scale": "^3.0.0",
|
|
28
29
|
"d3-scale": "4.0.2",
|
|
29
30
|
"assert-ts": "0.3.4",
|
|
30
31
|
"eslint": "8.34.0",
|
|
31
32
|
"react": "18.2.0",
|
|
32
33
|
"react-dom": "18.2.0",
|
|
33
34
|
"typescript": "4.9.5",
|
|
34
|
-
"@cutting/component-library": "5.
|
|
35
|
+
"@cutting/component-library": "5.37.0",
|
|
35
36
|
"@cutting/devtools": "4.62.0",
|
|
36
37
|
"@cutting/eslint-config": "4.43.1",
|
|
37
38
|
"@cutting/tsconfig": "4.39.0",
|
|
@@ -37,11 +37,11 @@ export function ResponsiveSVG({
|
|
|
37
37
|
style={{
|
|
38
38
|
position: 'relative',
|
|
39
39
|
overflow: 'visible',
|
|
40
|
-
height: '
|
|
40
|
+
height: '0px',
|
|
41
41
|
}}
|
|
42
42
|
>
|
|
43
43
|
<svg
|
|
44
|
-
style={{ overflow: 'visible' }}
|
|
44
|
+
style={{ overflow: 'visible', width: '100%', height: 'auto' }}
|
|
45
45
|
className={className}
|
|
46
46
|
preserveAspectRatio={preserveAspectRatio}
|
|
47
47
|
viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}
|