@cutting/svg 4.30.1 → 4.31.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.
- package/CHANGELOG.md +12 -0
- package/demo/App.tsx +6 -7
- package/demo/global.css.ts +19 -0
- package/demo/tsconfig.json +7 -2
- package/dist/cjs/svg.cjs.development.js +14 -17
- package/dist/cjs/svg.cjs.development.js.map +1 -1
- package/dist/cjs/svg.cjs.production.min.js +1 -1
- package/dist/cjs/svg.cjs.production.min.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/umd/index.js +2 -0
- package/dist/umd/index.js.map +1 -0
- package/package.json +14 -13
- package/demo/global.module.scss +0 -26
- package/dist/esm/svg.esm.js +0 -2
- package/dist/esm/svg.esm.js.map +0 -1
- package/dist/umd/svg.umd.js +0 -2
- package/dist/umd/svg.umd.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @cutting/svg
|
|
2
2
|
|
|
3
|
+
## 4.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7edd9a89: upgrade to typescript 4.5
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7edd9a89]
|
|
12
|
+
- @cutting/use-get-parent-size@1.6.0
|
|
13
|
+
- @cutting/util@4.29.0
|
|
14
|
+
|
|
3
15
|
## 4.30.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/demo/App.tsx
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import '@cutting/component-library/styles.css';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
2
|
import { useRef } from 'react';
|
|
4
|
-
import { ApplicationLayout } from '@cutting/component-library';
|
|
3
|
+
import { ApplicationLayout, cuttingTheme } from '@cutting/component-library';
|
|
5
4
|
import { ParentsizeSVG } from '../src/components/ParentsizeSVG/ParentsizeSVG';
|
|
6
5
|
|
|
7
|
-
import styles from './global.
|
|
6
|
+
import * as styles from './global.css';
|
|
8
7
|
|
|
9
|
-
export
|
|
8
|
+
export function App(): JSX.Element {
|
|
10
9
|
const ref = useRef<HTMLDivElement>(null);
|
|
11
10
|
return (
|
|
12
|
-
<ApplicationLayout heading="@cutting/svg">
|
|
11
|
+
<ApplicationLayout heading="@cutting/svg" className={cuttingTheme}>
|
|
13
12
|
<div className={styles.container} ref={ref}>
|
|
14
|
-
<ParentsizeSVG elementRef={ref} options={{ debounceDelay:
|
|
13
|
+
<ParentsizeSVG elementRef={ref} options={{ debounceDelay: 10 }}>
|
|
15
14
|
<rect
|
|
16
15
|
x="20%"
|
|
17
16
|
y="20%"
|
|
@@ -33,4 +32,4 @@ export const App: FC = () => {
|
|
|
33
32
|
</div>
|
|
34
33
|
</ApplicationLayout>
|
|
35
34
|
);
|
|
36
|
-
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
|
+
|
|
3
|
+
export const container = style({
|
|
4
|
+
border: '1px solid yellow',
|
|
5
|
+
background: 'grey',
|
|
6
|
+
color: 'white',
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
resize: 'both',
|
|
9
|
+
width: '50%',
|
|
10
|
+
height: '50%',
|
|
11
|
+
fontWeight: 'bold',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
margin: '0 auto',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
globalStyle('svg', {
|
|
18
|
+
border: '1px solid royalblue;',
|
|
19
|
+
});
|
package/demo/tsconfig.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"target": "
|
|
5
|
-
"module": "
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"module": "ESNext",
|
|
6
6
|
"outDir": "dist",
|
|
7
7
|
"rootDir": "."
|
|
8
8
|
},
|
|
9
|
+
"references": [
|
|
10
|
+
{ "path": "../tsconfig.dist.json" },
|
|
11
|
+
{ "path": "../../hooks/tsconfig.dist.json" },
|
|
12
|
+
{ "path": "../../util/tsconfig.dist.json" }
|
|
13
|
+
],
|
|
9
14
|
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
10
15
|
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"],
|
|
11
16
|
}
|
|
@@ -44,26 +44,24 @@ var ResponsiveSVG = function ResponsiveSVG(_ref) {
|
|
|
44
44
|
className = _ref.className;
|
|
45
45
|
var aspect = width / height;
|
|
46
46
|
var adjustedHeight = Math.ceil(width / aspect);
|
|
47
|
-
return jsxRuntime.jsx("div",
|
|
47
|
+
return jsxRuntime.jsx("div", {
|
|
48
48
|
"data-selector": "cutting-svg-container",
|
|
49
49
|
style: {
|
|
50
50
|
position: 'relative',
|
|
51
51
|
overflow: 'visible',
|
|
52
52
|
height: '1px'
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
children: jsxRuntime.jsx("svg", Object.assign({
|
|
53
|
+
},
|
|
54
|
+
children: jsxRuntime.jsx("svg", {
|
|
56
55
|
style: {
|
|
57
56
|
overflow: 'visible'
|
|
58
57
|
},
|
|
59
58
|
className: className,
|
|
60
59
|
preserveAspectRatio: preserveAspectRatio,
|
|
61
60
|
viewBox: "".concat(origin.x, " ").concat(origin.y, " ").concat(width, " ").concat(adjustedHeight),
|
|
62
|
-
ref: innerRef
|
|
63
|
-
}, {
|
|
61
|
+
ref: innerRef,
|
|
64
62
|
children: children
|
|
65
|
-
}
|
|
66
|
-
}
|
|
63
|
+
}, void 0)
|
|
64
|
+
}, void 0);
|
|
67
65
|
};
|
|
68
66
|
|
|
69
67
|
var _excluded$2 = ["debounceDelay"],
|
|
@@ -114,15 +112,14 @@ function ParentsizeSVG(_ref) {
|
|
|
114
112
|
}
|
|
115
113
|
}, [elementRef, style]);
|
|
116
114
|
var transform = align === 'center' ? "translate(".concat(width / 2, ",").concat(height / 2 - 20, ") scale(").concat(scale, ")") : "0,0) scale(".concat(scale, ")");
|
|
117
|
-
return jsxRuntime.jsx(ResponsiveSVG,
|
|
115
|
+
return jsxRuntime.jsx(ResponsiveSVG, _objectSpread__default["default"](_objectSpread__default["default"]({
|
|
118
116
|
width: width,
|
|
119
117
|
height: height
|
|
120
|
-
}, rest, {
|
|
121
|
-
children: jsxRuntime.jsx("g",
|
|
122
|
-
transform: transform
|
|
123
|
-
}, {
|
|
118
|
+
}, rest), {}, {
|
|
119
|
+
children: jsxRuntime.jsx("g", {
|
|
120
|
+
transform: transform,
|
|
124
121
|
children: children
|
|
125
|
-
}
|
|
122
|
+
}, void 0)
|
|
126
123
|
}), void 0);
|
|
127
124
|
}
|
|
128
125
|
|
|
@@ -138,11 +135,11 @@ var Group = function Group(_ref) {
|
|
|
138
135
|
innerRef = _ref.innerRef,
|
|
139
136
|
restProps = _objectWithoutProperties__default["default"](_ref, _excluded$1);
|
|
140
137
|
|
|
141
|
-
return jsxRuntime.jsx("g",
|
|
138
|
+
return jsxRuntime.jsx("g", _objectSpread__default["default"](_objectSpread__default["default"]({
|
|
142
139
|
ref: innerRef,
|
|
143
140
|
className: cx__default["default"]('visx-group', className),
|
|
144
141
|
transform: transform || "translate(".concat(x, ", ").concat(y, ")")
|
|
145
|
-
}, restProps, {
|
|
142
|
+
}, restProps), {}, {
|
|
146
143
|
children: children
|
|
147
144
|
}), void 0);
|
|
148
145
|
};
|
|
@@ -166,7 +163,7 @@ var Line = function Line(_ref) {
|
|
|
166
163
|
restProps = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
167
164
|
|
|
168
165
|
var isRectilinear = from.x === to.x || from.y === to.y;
|
|
169
|
-
return jsxRuntime.jsx("line",
|
|
166
|
+
return jsxRuntime.jsx("line", _objectSpread__default["default"]({
|
|
170
167
|
ref: innerRef,
|
|
171
168
|
className: cx__default["default"]('visx-line', className),
|
|
172
169
|
x1: from.x,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.cjs.development.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","aspect","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","key","value","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,aAAa,GAA2B,SAAxCA,aAAwC;MACnDC,cAAAA;MACAC,aAAAA;MACAC,gBAAAA;yBACAC;MAAAA,kCAAS;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE;AAAX;mCACTC;MAAAA,yDAAsB;MACtBC,gBAAAA;MACAC,iBAAAA;AAEA,MAAMC,MAAM,GAAGR,KAAK,GAAGD,MAAvB;AAEA,MAAMU,cAAc,GAAGC,IAAI,CAACC,IAAL,CAAUX,KAAK,GAAGQ,MAAlB,CAAvB;AAEA,SACEI;qBACgB;AACdC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE,UADL;AAELC,MAAAA,QAAQ,EAAE,SAFL;AAGLhB,MAAAA,MAAM,EAAE;AAHH
|
|
1
|
+
{"version":3,"file":"svg.cjs.development.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","aspect","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","key","value","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkBaA,aAAa,GAA2B,SAAxCA,aAAwC;MACnDC,cAAAA;MACAC,aAAAA;MACAC,gBAAAA;yBACAC;MAAAA,kCAAS;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE;AAAX;mCACTC;MAAAA,yDAAsB;MACtBC,gBAAAA;MACAC,iBAAAA;AAEA,MAAMC,MAAM,GAAGR,KAAK,GAAGD,MAAvB;AAEA,MAAMU,cAAc,GAAGC,IAAI,CAACC,IAAL,CAAUX,KAAK,GAAGQ,MAAlB,CAAvB;AAEA,SACEI;qBACgB;AACdC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE,UADL;AAELC,MAAAA,QAAQ,EAAE,SAFL;AAGLhB,MAAAA,MAAM,EAAE;AAHH;cAMPa;AACEC,MAAAA,KAAK,EAAE;AAAEE,QAAAA,QAAQ,EAAE;AAAZ;AACPR,MAAAA,SAAS,EAAEA;AACXF,MAAAA,mBAAmB,EAAEA;AACrBW,MAAAA,OAAO,YAAKd,MAAM,CAACC,CAAZ,cAAiBD,MAAM,CAACE,CAAxB,cAA6BJ,KAA7B,cAAsCS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ineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/objectSpread2"),i=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("react"),s=require("@cutting/use-get-parent-size"),a=require("classnames");function o(e){return e&&e.__esModule?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/objectSpread2"),i=require("@babel/runtime/helpers/objectWithoutProperties"),n=require("react"),s=require("@cutting/use-get-parent-size"),a=require("classnames");function o(e){return e&&e.__esModule?e:{default:e}}var l=o(r),c=o(t),d=o(i),u=o(a);!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var f=function(r){var t=r.width,i=r.children,n=r.origin,s=void 0===n?{x:0,y:0}:n,a=r.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,l=r.innerRef,c=r.className,d=Math.ceil(t/(t/r.height));return e.jsx("div",{"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:e.jsx("svg",{style:{overflow:"visible"},className:c,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(t," ").concat(d),ref:l,children:i},void 0)},void 0)},v=["debounceDelay"],x=["elementRef","children","style","scale","align","options"],p={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},h=["y","x","transform","className","children","innerRef"],y=["from","to","fill","className","innerRef"];exports.Group=function(r){var t=r.y,i=void 0===t?0:t,n=r.x,s=void 0===n?0:n,a=r.transform,o=r.className,l=r.children,f=r.innerRef,v=d.default(r,h);return e.jsx("g",c.default(c.default({ref:f,className:u.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(i,")")},v),{},{children:l}),void 0)},exports.Line=function(r){var t=r.from,i=void 0===t?{x:0,y:0}:t,n=r.to,s=void 0===n?{x:1,y:1}:n,a=r.fill,o=void 0===a?"transparent":a,l=r.className,f=r.innerRef,v=d.default(r,y),x=i.x===s.x||i.y===s.y;return e.jsx("line",c.default({ref:f,className:u.default("visx-line",l),x1:i.x,y1:i.y,x2:s.x,y2:s.y,fill:o,shapeRendering:x?"crispEdges":"auto"},v),void 0)},exports.ParentsizeSVG=function(r){var t=r.elementRef,i=r.children,a=r.style,o=void 0===a?p:a,u=r.scale,h=void 0===u?1:u,y=r.align,m=void 0===y?"none":y,g=r.options,b=(g=void 0===g?{}:g).debounceDelay,j=void 0===b?50:b,R=d.default(g,v),N=d.default(r,x),w=s.useParentSize(t,c.default({debounceDelay:j},R)),q=w.width,D=w.height;n.useEffect((function(){if(t.current)for(var e=0,r=Object.entries(o);e<r.length;e++){var i=l.default(r[e],2);t.current.style[i[0]]=i[1]}}),[t,o]);var M="center"===m?"translate(".concat(q/2,",").concat(D/2-20,") scale(").concat(h,")"):"0,0) scale(".concat(h,")");return e.jsx(f,c.default(c.default({width:q,height:D},N),{},{children:e.jsx("g",{transform:M,children:i},void 0)}),void 0)},exports.ResponsiveSVG=f;
|
|
2
2
|
//# sourceMappingURL=svg.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.cjs.production.min.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries"],"mappings":"ymBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,
|
|
1
|
+
{"version":3,"file":"svg.cjs.production.min.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries"],"mappings":"ymBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,6BACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,gBAGVC,aACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,WAE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WAAYvB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r from"@babel/runtime/helpers/esm/slicedToArray";import i from"@babel/runtime/helpers/esm/objectSpread2";import o from"@babel/runtime/helpers/esm/objectWithoutProperties";import{useEffect as n}from"react";import{useParentSize as t}from"@cutting/use-get-parent-size";import s from"classnames";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var c=function(r){var i=r.width,o=r.children,n=r.origin,t=void 0===n?{x:0,y:0}:n,s=r.preserveAspectRatio,c=void 0===s?"xMaxYMid meet":s,a=r.innerRef,l=r.className,d=Math.ceil(i/(i/r.height));return e("div",{"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:e("svg",{style:{overflow:"visible"},className:l,preserveAspectRatio:c,viewBox:"".concat(t.x," ").concat(t.y," ").concat(i," ").concat(d),ref:a,children:o},void 0)},void 0)},a=["debounceDelay"],l=["elementRef","children","style","scale","align","options"],d={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function v(s){var v=s.elementRef,f=s.children,m=s.style,p=void 0===m?d:m,h=s.scale,u=void 0===h?1:h,x=s.align,y=void 0===x?"none":x,g=s.options,b=(g=void 0===g?{}:g).debounceDelay,N=void 0===b?50:b,R=o(g,a),w=o(s,l),j=t(v,i({debounceDelay:N},R)),D=j.width,O=j.height;n((function(){if(v.current)for(var e=0,i=Object.entries(p);e<i.length;e++){var o=r(i[e],2);v.current.style[o[0]]=o[1]}}),[v,p]);var A="center"===y?"translate(".concat(D/2,",").concat(O/2-20,") scale(").concat(u,")"):"0,0) scale(".concat(u,")");return e(c,i(i({width:D,height:O},w),{},{children:e("g",{transform:A,children:f},void 0)}),void 0)}var f=["y","x","transform","className","children","innerRef"],m=function(r){var n=r.y,t=void 0===n?0:n,c=r.x,a=void 0===c?0:c,l=r.transform,d=r.className,v=r.children,m=r.innerRef,p=o(r,f);return e("g",i(i({ref:m,className:s("visx-group",d),transform:l||"translate(".concat(a,", ").concat(t,")")},p),{},{children:v}),void 0)},p=["from","to","fill","className","innerRef"],h=function(r){var n=r.from,t=void 0===n?{x:0,y:0}:n,c=r.to,a=void 0===c?{x:1,y:1}:c,l=r.fill,d=void 0===l?"transparent":l,v=r.className,f=r.innerRef,m=o(r,p),h=t.x===a.x||t.y===a.y;return e("line",i({ref:f,className:s("visx-line",v),x1:t.x,y1:t.y,x2:a.x,y2:a.y,fill:d,shapeRendering:h?"crispEdges":"auto"},m),void 0)};export{m as Group,h as Line,v as ParentsizeSVG,c as ResponsiveSVG};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"6gBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,yBACgB,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AMuC,EAAGvC,SAGrDQ,YACEK,IAAKX,EACLC,UAAWiC,EAAG,YAAajC,GAC3BuC,GAAIJ,EAAKvC,EACT4C,GAAIL,EAAKtC,EACT4C,GAAIL,EAAGxC,EACP8C,GAAIN,EAAGvC,EACPwC,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CN"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/objectSpread2"),require("@babel/runtime/helpers/objectWithoutProperties"),require("react"),require("@cutting/use-get-parent-size"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@babel/runtime/helpers/slicedToArray","@babel/runtime/helpers/objectSpread2","@babel/runtime/helpers/objectWithoutProperties","react","@cutting/use-get-parent-size","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@cutting/svg"]={},e.jsxRuntime,e._slicedToArray,e._objectSpread,e._objectWithoutProperties,e.React,e.useGetParentSize,e.cx)}(this,(function(e,t,r,i,n,s,a,o){"use strict";function c(e){return e&&e.__esModule?e:{default:e}}var l=c(r),d=c(i),u=c(n),f=c(o);!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var v=function(e){var r=e.width,i=e.children,n=e.origin,s=void 0===n?{x:0,y:0}:n,a=e.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,c=e.innerRef,l=e.className,d=Math.ceil(r/(r/e.height));return t.jsx("div",{"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"},children:t.jsx("svg",{style:{overflow:"visible"},className:l,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(r," ").concat(d),ref:c,children:i},void 0)},void 0)},p=["debounceDelay"],h=["elementRef","children","style","scale","align","options"],x={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},m=["y","x","transform","className","children","innerRef"],b=["from","to","fill","className","innerRef"];e.Group=function(e){var r=e.y,i=void 0===r?0:r,n=e.x,s=void 0===n?0:n,a=e.transform,o=e.className,c=e.children,l=e.innerRef,v=u.default(e,m);return t.jsx("g",d.default(d.default({ref:l,className:f.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(i,")")},v),{},{children:c}),void 0)},e.Line=function(e){var r=e.from,i=void 0===r?{x:0,y:0}:r,n=e.to,s=void 0===n?{x:1,y:1}:n,a=e.fill,o=void 0===a?"transparent":a,c=e.className,l=e.innerRef,v=u.default(e,b),p=i.x===s.x||i.y===s.y;return t.jsx("line",d.default({ref:l,className:f.default("visx-line",c),x1:i.x,y1:i.y,x2:s.x,y2:s.y,fill:o,shapeRendering:p?"crispEdges":"auto"},v),void 0)},e.ParentsizeSVG=function(e){var r=e.elementRef,i=e.children,n=e.style,o=void 0===n?x:n,c=e.scale,f=void 0===c?1:c,m=e.align,b=void 0===m?"none":m,y=e.options,g=(y=void 0===y?{}:y).debounceDelay,j=void 0===g?50:g,R=u.default(y,p),N=u.default(e,h),w=a.useParentSize(r,d.default({debounceDelay:j},R)),S=w.width,q=w.height;s.useEffect((function(){if(r.current)for(var e=0,t=Object.entries(o);e<t.length;e++){var i=l.default(t[e],2);r.current.style[i[0]]=i[1]}}),[r,o]);var P="center"===b?"translate(".concat(S/2,",").concat(q/2-20,") scale(").concat(f,")"):"0,0) scale(".concat(f,")");return t.jsx(v,d.default(d.default({width:S,height:q},N),{},{children:t.jsx("g",{transform:P,children:i},void 0)}),void 0)},e.ResponsiveSVG=v}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries"],"mappings":"wkCAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,6BACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,gBAGVC,aACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,WAEJL,uGChCIiB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXR,SAAU,0HCJyB,oBACnCX,EAAAA,aAAI,QACJD,EAAAA,aAAI,IACJqB,IAAAA,UACAjB,IAAAA,UACAN,IAAAA,SACAK,IAAAA,SACGmB,wBAGDb,+BACEK,IAAKX,EACLC,UAAWmB,UAAG,aAAcnB,GAC5BiB,UAAWA,uBAA0BrB,eAAMC,QACvCqB,gBAEHxB,oBCnB4B,oBACjC0B,KAAAA,aAAO,CAAExB,EAAG,EAAGC,EAAG,SAClBwB,GAAAA,aAAK,CAAEzB,EAAG,EAAGC,EAAG,SAChByB,KAAAA,aAAO,gBACPtB,IAAAA,UACAD,IAAAA,SACGmB,iBAEGK,EAAgBH,EAAKxB,IAAMyB,EAAGzB,GAAKwB,EAAKvB,IAAMwB,EAAGxB,SAGrDQ,wBACEK,IAAKX,EACLC,UAAWmB,UAAG,YAAanB,GAC3BwB,GAAIJ,EAAKxB,EACT6B,GAAIL,EAAKvB,EACT6B,GAAIL,EAAGzB,EACP+B,GAAIN,EAAGxB,EACPyB,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CL,4CFTRW,IAAAA,WACAnC,IAAAA,aACAY,MAAAA,aAAQK,QACRmB,MAAAA,aAAQ,QACRC,MAAAA,aAAQ,aACRC,wBAAkD,MAAvCC,cAAAA,aAAgB,KAAOC,iBAC/BC,mBAEuBC,gBAAcP,aAAcI,cAAAA,GAAkBC,IAAhEzC,IAAAA,MAAOW,IAAAA,OAEfiC,aAAU,cACHR,EAAWS,sBAIWC,OAAOC,QAAQlC,kBAAQ,yBAEhDuB,EAAWS,QAAQhC,oBAEpB,CAACuB,EAAYvB,QAEVW,EACM,WAAVc,sBAAkCtC,EAAQ,cAAKW,EAAS,EAAI,sBAAa0B,4BAAyBA,cAGlGzB,MAACb,uBAAcC,MAAOA,EAAOW,OAAQA,GAAY+B,gBAC/C9B,WAAGY,UAAWA,WAAYvB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cutting/svg",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dagda1/cuttingedge.git"
|
|
7
7
|
},
|
|
8
|
-
"module": "dist/esm/
|
|
9
|
-
"browser": "dist/umd/
|
|
8
|
+
"module": "dist/esm/index.js",
|
|
9
|
+
"browser": "dist/umd/index.js",
|
|
10
10
|
"main": "dist/cjs/index.js",
|
|
11
11
|
"sideEffects": [
|
|
12
12
|
"**/*.css",
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"types": "dist/esm/index.d.ts",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cutting/
|
|
19
|
-
"@cutting/
|
|
18
|
+
"@cutting/use-get-parent-size": "1.6.0",
|
|
19
|
+
"@cutting/util": "4.29.0",
|
|
20
20
|
"resize-observer-polyfill": "^1.5.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@cutting/devtools": "4.
|
|
24
|
-
"@cutting/
|
|
25
|
-
"@cutting/
|
|
26
|
-
"@cutting/useful-types": "4.25.2",
|
|
23
|
+
"@cutting/devtools": "4.31.0",
|
|
24
|
+
"@cutting/eslint-config": "4.28.0",
|
|
25
|
+
"@cutting/testing": "4.27.0",
|
|
27
26
|
"@testing-library/jest-dom": "^5.11.10",
|
|
27
|
+
"eslint": "^8.2.0",
|
|
28
28
|
"react": "^17.0.2",
|
|
29
29
|
"react-dom": "^17.0.2",
|
|
30
|
-
"typescript": "^4.
|
|
30
|
+
"typescript": "^4.5.2"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"react": "^17.0.2",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "NODE_ENV=development cutting rollup",
|
|
38
|
+
"lint": "yarn eslint ./src/**/*.{ts,tsx} --fix",
|
|
38
39
|
"start": "PORT=8888 NODE_ENV=development cutting devserver-start",
|
|
39
40
|
"test": "NODE_ENV=test cutting test",
|
|
40
41
|
"test:ci": "CI=true yarn test",
|
|
@@ -44,9 +45,9 @@
|
|
|
44
45
|
"extends": "../../package.json"
|
|
45
46
|
},
|
|
46
47
|
"exports": {
|
|
47
|
-
"import": "./dist/esm/
|
|
48
|
+
"import": "./dist/esm/index.js",
|
|
48
49
|
"require": "./dist/cjs/index.js",
|
|
49
|
-
"browser": "./dist/umd/
|
|
50
|
+
"browser": "./dist/umd/index.js"
|
|
50
51
|
},
|
|
51
52
|
"typesVersions": {
|
|
52
53
|
"*": {
|
|
@@ -55,4 +56,4 @@
|
|
|
55
56
|
]
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
}
|
|
59
|
+
}
|
package/demo/global.module.scss
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
$label-default-color: #fff;
|
|
2
|
-
|
|
3
|
-
@import '../node_modules/@cutting/component-library/dist/styles/_index.scss';
|
|
4
|
-
:global #root {
|
|
5
|
-
border: 1px solid green;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.container {
|
|
10
|
-
border: 1px solid yellow;
|
|
11
|
-
background: grey;
|
|
12
|
-
color: white;
|
|
13
|
-
font-weight: bold;
|
|
14
|
-
overflow: hidden;
|
|
15
|
-
resize: auto;
|
|
16
|
-
width: 50%;
|
|
17
|
-
height: 50%;
|
|
18
|
-
font-weight: bold;
|
|
19
|
-
justify-content: center;
|
|
20
|
-
align-items: center;
|
|
21
|
-
margin: 0 auto;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
svg {
|
|
25
|
-
border: 1px solid royalblue;
|
|
26
|
-
}
|
package/dist/esm/svg.esm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import i from"@babel/runtime/helpers/esm/slicedToArray";import r from"@babel/runtime/helpers/esm/objectSpread2";import n from"@babel/runtime/helpers/esm/objectWithoutProperties";import{useEffect as t}from"react";import{useParentSize as o}from"@cutting/use-get-parent-size";import s from"classnames";!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var c=function(i){var r=i.width,n=i.children,t=i.origin,o=void 0===t?{x:0,y:0}:t,s=i.preserveAspectRatio,c=void 0===s?"xMaxYMid meet":s,a=i.innerRef,l=i.className,d=Math.ceil(r/(r/i.height));return e("div",Object.assign({"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"}},{children:e("svg",Object.assign({style:{overflow:"visible"},className:l,preserveAspectRatio:c,viewBox:"".concat(o.x," ").concat(o.y," ").concat(r," ").concat(d),ref:a},{children:n}),void 0)}),void 0)},a=["debounceDelay"],l=["elementRef","children","style","scale","align","options"],d={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function v(s){var v=s.elementRef,f=s.children,m=s.style,p=void 0===m?d:m,h=s.scale,u=void 0===h?1:h,g=s.align,x=void 0===g?"none":g,b=s.options,y=(b=void 0===b?{}:b).debounceDelay,j=void 0===y?50:y,N=n(b,a),O=n(s,l),R=o(v,r({debounceDelay:j},N)),w=R.width,D=R.height;t((function(){if(v.current)for(var e=0,r=Object.entries(p);e<r.length;e++){var n=i(r[e],2);v.current.style[n[0]]=n[1]}}),[v,p]);var A="center"===x?"translate(".concat(w/2,",").concat(D/2-20,") scale(").concat(u,")"):"0,0) scale(".concat(u,")");return e(c,Object.assign({width:w,height:D},O,{children:e("g",Object.assign({transform:A},{children:f}),void 0)}),void 0)}var f=["y","x","transform","className","children","innerRef"],m=function(i){var r=i.y,t=void 0===r?0:r,o=i.x,c=void 0===o?0:o,a=i.transform,l=i.className,d=i.children,v=i.innerRef,m=n(i,f);return e("g",Object.assign({ref:v,className:s("visx-group",l),transform:a||"translate(".concat(c,", ").concat(t,")")},m,{children:d}),void 0)},p=["from","to","fill","className","innerRef"],h=function(i){var r=i.from,t=void 0===r?{x:0,y:0}:r,o=i.to,c=void 0===o?{x:1,y:1}:o,a=i.fill,l=void 0===a?"transparent":a,d=i.className,v=i.innerRef,f=n(i,p),m=t.x===c.x||t.y===c.y;return e("line",Object.assign({ref:v,className:s("visx-line",d),x1:t.x,y1:t.y,x2:c.x,y2:c.y,fill:l,shapeRendering:m?"crispEdges":"auto"},f),void 0)};export{m as Group,h as Line,v as ParentsizeSVG,c as ResponsiveSVG};
|
|
2
|
-
//# sourceMappingURL=svg.esm.js.map
|
package/dist/esm/svg.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svg.esm.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","rest","useParentSize","useEffect","current","Object","entries","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"6gBAkBaA,EAAwC,gBAEnDC,IAAAA,MACAC,IAAAA,aACAC,OAAAA,aAAS,CAAEC,EAAG,EAAGC,EAAG,SACpBC,oBAAAA,aAAsB,kBACtBC,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKV,GAFlBA,IARfW,gBAaEC,uCACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVJ,OAAQ,kBAGVC,uBACEC,MAAO,CAAEE,SAAU,WACnBR,UAAWA,EACXF,oBAAqBA,EACrBW,kBAAYd,EAAOC,cAAKD,EAAOE,cAAKJ,cAASQ,GAC7CS,IAAKX,aAEJL,yGChCIiB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXR,SAAU,mBAGIS,SACdC,IAAAA,WACAxB,IAAAA,aACAY,MAAAA,aAAQK,QACRQ,MAAAA,aAAQ,QACRC,MAAAA,aAAQ,aACRC,wBAAkD,MAAvCC,cAAAA,aAAgB,KAAOC,SAC/BC,WAEuBC,EAAcP,KAAcI,cAAAA,GAAkBC,IAAhE9B,IAAAA,MAAOW,IAAAA,OAEfsB,GAAU,cACHR,EAAWS,sBAIWC,OAAOC,QAAQvB,kBAAQ,iBAEhDY,EAAWS,QAAQrB,oBAEpB,CAACY,EAAYZ,QAEVwB,EACM,WAAVV,sBAAkC3B,EAAQ,cAAKW,EAAS,EAAI,sBAAae,4BAAyBA,cAGlGd,EAACb,iBAAcC,MAAOA,EAAOW,OAAQA,GAAYoB,YAC/CnB,qBAAGyB,UAAWA,aAAYpC,oFClCnBqC,EAAwB,oBACnClC,EAAAA,aAAI,QACJD,EAAAA,aAAI,IACJkC,IAAAA,UACA9B,IAAAA,UACAN,IAAAA,SACAK,IAAAA,SACGiC,gBAGD3B,qBACEK,IAAKX,EACLC,UAAWiC,EAAG,aAAcjC,GAC5B8B,UAAWA,uBAA0BlC,eAAMC,QACvCmC,YAEHtC,2DCnBMwC,EAAsB,oBACjCC,KAAAA,aAAO,CAAEvC,EAAG,EAAGC,EAAG,SAClBuC,GAAAA,aAAK,CAAExC,EAAG,EAAGC,EAAG,SAChBwC,KAAAA,aAAO,gBACPrC,IAAAA,UACAD,IAAAA,SACGiC,SAEGM,EAAgBH,EAAKvC,IAAMwC,EAAGxC,GAAKuC,EAAKtC,IAAMuC,EAAGvC,SAGrDQ,wBACEK,IAAKX,EACLC,UAAWiC,EAAG,YAAajC,GAC3BuC,GAAIJ,EAAKvC,EACT4C,GAAIL,EAAKtC,EACT4C,GAAIL,EAAGxC,EACP8C,GAAIN,EAAGvC,EACPwC,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CN"}
|
package/dist/umd/svg.umd.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/objectSpread2"),require("@babel/runtime/helpers/objectWithoutProperties"),require("react"),require("@cutting/use-get-parent-size"),require("classnames")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","@babel/runtime/helpers/slicedToArray","@babel/runtime/helpers/objectSpread2","@babel/runtime/helpers/objectWithoutProperties","react","@cutting/use-get-parent-size","classnames"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@cutting/svg"]={},e.jsxRuntime,e._slicedToArray,e._objectSpread,e._objectWithoutProperties,e.React,e.useGetParentSize,e.cx)}(this,(function(e,t,i,r,n,s,a,o){"use strict";function c(e){return e&&e.__esModule?e:{default:e}}var l=c(i),d=c(r),u=c(n),f=c(o);!function(){const e={NODE_ENV:"production"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,e)}catch(e){}globalThis.process={env:e}}();var v=function(e){var i=e.width,r=e.children,n=e.origin,s=void 0===n?{x:0,y:0}:n,a=e.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,c=e.innerRef,l=e.className,d=Math.ceil(i/(i/e.height));return t.jsx("div",Object.assign({"data-selector":"cutting-svg-container",style:{position:"relative",overflow:"visible",height:"1px"}},{children:t.jsx("svg",Object.assign({style:{overflow:"visible"},className:l,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(i," ").concat(d),ref:c},{children:r}),void 0)}),void 0)},p=["debounceDelay"],h=["elementRef","children","style","scale","align","options"],b={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},x=["y","x","transform","className","children","innerRef"],g=["from","to","fill","className","innerRef"];e.Group=function(e){var i=e.y,r=void 0===i?0:i,n=e.x,s=void 0===n?0:n,a=e.transform,o=e.className,c=e.children,l=e.innerRef,d=u.default(e,x);return t.jsx("g",Object.assign({ref:l,className:f.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(r,")")},d,{children:c}),void 0)},e.Line=function(e){var i=e.from,r=void 0===i?{x:0,y:0}:i,n=e.to,s=void 0===n?{x:1,y:1}:n,a=e.fill,o=void 0===a?"transparent":a,c=e.className,l=e.innerRef,d=u.default(e,g),v=r.x===s.x||r.y===s.y;return t.jsx("line",Object.assign({ref:l,className:f.default("visx-line",c),x1:r.x,y1:r.y,x2:s.x,y2:s.y,fill:o,shapeRendering:v?"crispEdges":"auto"},d),void 0)},e.ParentsizeSVG=function(e){var i=e.elementRef,r=e.children,n=e.style,o=void 0===n?b:n,c=e.scale,f=void 0===c?1:c,x=e.align,g=void 0===x?"none":x,m=e.options,y=(m=void 0===m?{}:m).debounceDelay,j=void 0===y?50:y,R=u.default(m,p),N=u.default(e,h),O=a.useParentSize(i,d.default({debounceDelay:j},R)),w=O.width,S=O.height;s.useEffect((function(){if(i.current)for(var e=0,t=Object.entries(o);e<t.length;e++){var r=l.default(t[e],2);i.current.style[r[0]]=r[1]}}),[i,o]);var q="center"===g?"translate(".concat(w/2,",").concat(S/2-20,") scale(").concat(f,")"):"0,0) scale(".concat(f,")");return t.jsx(v,Object.assign({width:w,height:S},N,{children:t.jsx("g",Object.assign({transform:q},{children:r}),void 0)}),void 0)},e.ResponsiveSVG=v}));
|
|
2
|
-
//# sourceMappingURL=svg.umd.js.map
|
package/dist/umd/svg.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"svg.umd.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 { FC, Ref } from 'react';\nimport { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\n\nexport const ResponsiveSVG: FC<ResponsiveSVGProps> = ({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}) => {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-selector=\"cutting-svg-container\"\n style={{\n position: 'relative',\n overflow: 'visible',\n height: '1px',\n }}\n >\n <svg\n style={{ overflow: 'visible' }}\n className={className}\n preserveAspectRatio={preserveAspectRatio}\n viewBox={`${origin.x} ${origin.y} ${width} ${adjustedHeight}`}\n ref={innerRef}\n >\n {children}\n </svg>\n </div>\n );\n};\n","import { CSSProperties, PropsWithChildren, RefObject, useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport { ResponsiveSVG, ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\n\ntype Align = 'none' | 'center';\n\nexport type ParentsizeSVGProps<E extends HTMLElement> = {\n elementRef: RefObject<E>;\n style?: CSSProperties;\n align?: Align;\n scale?: number;\n options?: Partial<UseParentSizeOptions>;\n} & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;\n\nexport const DefaultStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'column',\n flexGrow: 1,\n flexShrink: 1,\n flexBasis: '0%',\n overflow: 'hidden',\n} as const;\n\nexport function ParentsizeSVG<E extends HTMLElement>({\n elementRef,\n children,\n style = DefaultStyle,\n scale = 1,\n align = 'none',\n options: { debounceDelay = 50, ...optionsRest } = {},\n ...rest\n}: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {\n const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n\n for (const [key, value] of Object.entries(style)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n elementRef.current.style[key as any] = value;\n }\n }, [elementRef, style]);\n\n const transform =\n align === 'center' ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})` : `0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import type { FC } from 'react';\nimport 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 const Group: FC<GroupProps> = ({\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 type { FC } from 'react';\nimport cx from 'classnames';\nimport { 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 const Line: FC<LineProps> = ({\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","width","children","origin","x","y","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","height","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","transform","restProps","cx","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering","elementRef","scale","align","options","debounceDelay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