@cutting/svg 4.31.8 → 4.32.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 +3 -3
- package/CHANGELOG.md +29 -0
- package/README.md +1 -2
- package/demo/App.tsx +5 -5
- package/demo/global.css.ts +2 -1
- package/demo/index.tsx +1 -2
- package/dist/cjs/components/Group/Group.d.ts +1 -2
- package/dist/cjs/components/Group/Group.d.ts.map +1 -1
- package/dist/cjs/components/Line/Line.d.ts +2 -3
- package/dist/cjs/components/Line/Line.d.ts.map +1 -1
- package/dist/cjs/components/ParentsizeSVG/ParentsizeSVG.d.ts +1 -1
- package/dist/cjs/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/cjs/components/ResponsiveSVG/ResponsiveSVG.d.ts +3 -2
- package/dist/cjs/components/ResponsiveSVG/ResponsiveSVG.d.ts.map +1 -1
- package/dist/cjs/svg.cjs.development.js +13 -25
- 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/components/Group/Group.d.ts +1 -2
- package/dist/esm/components/Group/Group.d.ts.map +1 -1
- package/dist/esm/components/Line/Line.d.ts +2 -3
- package/dist/esm/components/Line/Line.d.ts.map +1 -1
- package/dist/esm/components/ParentsizeSVG/ParentsizeSVG.d.ts +1 -1
- package/dist/esm/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/esm/components/ResponsiveSVG/ResponsiveSVG.d.ts +3 -2
- package/dist/esm/components/ResponsiveSVG/ResponsiveSVG.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/components/Group/Group.d.ts +1 -2
- package/dist/umd/components/Group/Group.d.ts.map +1 -1
- package/dist/umd/components/Line/Line.d.ts +2 -3
- package/dist/umd/components/Line/Line.d.ts.map +1 -1
- package/dist/umd/components/ParentsizeSVG/ParentsizeSVG.d.ts +1 -1
- package/dist/umd/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/umd/components/ResponsiveSVG/ResponsiveSVG.d.ts +3 -2
- package/dist/umd/components/ResponsiveSVG/ResponsiveSVG.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +21 -19
- package/src/components/Group/Group.tsx +3 -4
- package/src/components/Line/Line.tsx +3 -4
- package/src/components/ParentsizeSVG/ParentSizeSVG.test.tsx +21 -5
- package/src/components/ParentsizeSVG/ParentsizeSVG.tsx +4 -2
- package/src/components/ResponsiveSVG/ResponsiveSVG.test.tsx +2 -3
- package/src/components/ResponsiveSVG/ResponsiveSVG.tsx +5 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
@cutting/svg:build: cache hit, replaying output
|
|
1
|
+
@cutting/svg:build: cache hit, replaying output f45568a3b5fc9294
|
|
2
2
|
@cutting/svg:build:
|
|
3
|
-
@cutting/svg:build: > @cutting/svg@4.
|
|
4
|
-
@cutting/svg:build: > NODE_ENV=
|
|
3
|
+
@cutting/svg:build: > @cutting/svg@4.32.1 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
|
|
4
|
+
@cutting/svg:build: > NODE_ENV=production cutting rollup
|
|
5
5
|
@cutting/svg:build:
|
|
6
6
|
@cutting/svg:build: DEBUG using tsconfig.dist.json
|
|
7
7
|
@cutting/svg:build: WARNING emptying dist /home/runner/work/cuttingedge/cuttingedge/packages/svg/dist
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @cutting/svg
|
|
2
2
|
|
|
3
|
+
## 4.32.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f3d2133: changesets fixes
|
|
8
|
+
- Updated dependencies [0f3d2133]
|
|
9
|
+
- @cutting/use-get-parent-size@1.6.11
|
|
10
|
+
- @cutting/util@4.31.1
|
|
11
|
+
|
|
12
|
+
## 4.32.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 3413251c: build in production
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [3413251c]
|
|
21
|
+
- @cutting/util@4.31.0
|
|
22
|
+
- @cutting/use-get-parent-size@1.6.10
|
|
23
|
+
|
|
24
|
+
## 4.31.9
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [e6a06fa0]
|
|
29
|
+
- @cutting/util@4.30.0
|
|
30
|
+
- @cutting/use-get-parent-size@1.6.9
|
|
31
|
+
|
|
3
32
|
## 4.31.8
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -23,11 +23,10 @@ The `ParentsizeSVG` component takes an `elementRef` prop that should point to a
|
|
|
23
23
|
## usage
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import type { FC } from 'react';
|
|
27
26
|
import { useRef } from 'react';
|
|
28
27
|
import { ParentsizeSVG } from '@cutting/svg';
|
|
29
28
|
|
|
30
|
-
export
|
|
29
|
+
export function App(): JSX.Element {
|
|
31
30
|
const ref = useRef<HTMLDivElement>(null);
|
|
32
31
|
|
|
33
32
|
return (
|
package/demo/App.tsx
CHANGED
|
@@ -11,17 +11,17 @@ export function App(): JSX.Element {
|
|
|
11
11
|
<div className={styles.container} ref={ref}>
|
|
12
12
|
<ParentsizeSVG elementRef={ref} options={{ debounceDelay: 10 }}>
|
|
13
13
|
<rect
|
|
14
|
-
x="
|
|
15
|
-
y="
|
|
14
|
+
x="0"
|
|
15
|
+
y="0"
|
|
16
16
|
width={'50%'}
|
|
17
17
|
height={'50%'}
|
|
18
|
-
rx="
|
|
18
|
+
rx="0"
|
|
19
19
|
style={{ fill: '#ff0000', stroke: '#000000', strokeWidth: '2px' }}
|
|
20
20
|
/>
|
|
21
21
|
|
|
22
22
|
<rect
|
|
23
|
-
x="
|
|
24
|
-
y="
|
|
23
|
+
x="0"
|
|
24
|
+
y="0"
|
|
25
25
|
width={'50%'}
|
|
26
26
|
height={'50%'}
|
|
27
27
|
rx="40"
|
package/demo/global.css.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { globalStyle, style } from '@vanilla-extract/css';
|
|
2
2
|
|
|
3
3
|
export const container = style({
|
|
4
|
-
border: '
|
|
4
|
+
border: '10px solid yellow',
|
|
5
5
|
background: 'grey',
|
|
6
6
|
color: 'white',
|
|
7
7
|
overflow: 'hidden',
|
|
@@ -12,6 +12,7 @@ export const container = style({
|
|
|
12
12
|
justifyContent: 'center',
|
|
13
13
|
alignItems: 'center',
|
|
14
14
|
margin: '0 auto',
|
|
15
|
+
marginBottom: '10rem',
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
globalStyle('svg', {
|
package/demo/index.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import ReactDOM from 'react-dom';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
2
|
import { App } from './App';
|
|
4
3
|
|
|
5
4
|
export const root = document.getElementById('root');
|
|
6
5
|
|
|
7
|
-
const render = (Component:
|
|
6
|
+
const render = (Component: typeof App) => {
|
|
8
7
|
ReactDOM.render(<Component />, root);
|
|
9
8
|
};
|
|
10
9
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
declare type GroupOnlyProps = {
|
|
3
2
|
/** Top offset applied to `<g/>`. */
|
|
4
3
|
y?: number;
|
|
@@ -11,6 +10,6 @@ declare type GroupOnlyProps = {
|
|
|
11
10
|
innerRef?: React.Ref<SVGGElement>;
|
|
12
11
|
};
|
|
13
12
|
declare type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
|
|
14
|
-
export declare
|
|
13
|
+
export declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
|
|
15
14
|
export {};
|
|
16
15
|
//# sourceMappingURL=Group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"AAEA,aAAK,cAAc,GAAG;IACpB,oCAAoC;IACpC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,aAAK,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAE3F,wBAAgB,KAAK,CAAC,EACpB,CAAK,EACL,CAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAW1B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Point } from '../../types/types';
|
|
1
|
+
import type { AddSVGProps, Point } from '../../types/types';
|
|
3
2
|
export declare type LineProps = {
|
|
4
3
|
className?: string;
|
|
5
4
|
innerRef?: React.Ref<SVGLineElement>;
|
|
@@ -9,5 +8,5 @@ export declare type LineProps = {
|
|
|
9
8
|
/** Ending x,y point of the line. */
|
|
10
9
|
to?: Point;
|
|
11
10
|
};
|
|
12
|
-
export declare
|
|
11
|
+
export declare function Line({ from, to, fill, className, innerRef, ...restProps }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element;
|
|
13
12
|
//# sourceMappingURL=Line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,oBAAY,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,wBAAgB,IAAI,CAAC,EACnB,IAAqB,EACrB,EAAmB,EACnB,IAAoB,EACpB,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgBtD"}
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, PropsWithChildren, RefObject } from 'react';
|
|
|
2
2
|
import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
|
|
3
3
|
import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';
|
|
4
4
|
declare type Align = 'none' | 'center';
|
|
5
|
-
export declare type ParentsizeSVGProps<E extends HTMLElement> = {
|
|
5
|
+
export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
|
|
6
6
|
elementRef: RefObject<E>;
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
align?: Align;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI;
|
|
1
|
+
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAOjB,CAAC;AAEX,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,UAAU,EACV,QAAQ,EACR,KAAoB,EACpB,KAAS,EACT,KAAc,EACd,OAAO,EAAE,EAAE,aAAkB,EAAE,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { PreserveAspectRatio } from '../../types/types';
|
|
3
3
|
export interface Point {
|
|
4
4
|
x: number;
|
|
@@ -12,6 +12,7 @@ export interface ResponsiveSVGProps {
|
|
|
12
12
|
innerRef?: Ref<SVGSVGElement>;
|
|
13
13
|
className?: string;
|
|
14
14
|
hide?: boolean;
|
|
15
|
+
children: ReactNode;
|
|
15
16
|
}
|
|
16
|
-
export declare
|
|
17
|
+
export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, }: ResponsiveSVGProps): JSX.Element;
|
|
17
18
|
//# sourceMappingURL=ResponsiveSVG.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAyBlC"}
|
|
@@ -17,19 +17,7 @@ var _objectSpread__default = /*#__PURE__*/_interopDefault(_objectSpread);
|
|
|
17
17
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
|
|
18
18
|
var cx__default = /*#__PURE__*/_interopDefault(cx);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
const env = {"NODE_ENV":"development"};
|
|
22
|
-
try {
|
|
23
|
-
if (process) {
|
|
24
|
-
process.env = Object.assign({}, process.env);
|
|
25
|
-
Object.assign(process.env, env);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
} catch (e) {} // avoid ReferenceError: process is not defined
|
|
29
|
-
globalThis.process = { env:env };
|
|
30
|
-
})();
|
|
31
|
-
|
|
32
|
-
var ResponsiveSVG = function ResponsiveSVG(_ref) {
|
|
20
|
+
function ResponsiveSVG(_ref) {
|
|
33
21
|
var height = _ref.height,
|
|
34
22
|
width = _ref.width,
|
|
35
23
|
children = _ref.children,
|
|
@@ -60,9 +48,9 @@ var ResponsiveSVG = function ResponsiveSVG(_ref) {
|
|
|
60
48
|
viewBox: "".concat(origin.x, " ").concat(origin.y, " ").concat(width, " ").concat(adjustedHeight),
|
|
61
49
|
ref: innerRef,
|
|
62
50
|
children: children
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
66
54
|
|
|
67
55
|
var _excluded$2 = ["debounceDelay"],
|
|
68
56
|
_excluded2 = ["elementRef", "children", "style", "scale", "align", "options"];
|
|
@@ -111,7 +99,7 @@ function ParentsizeSVG(_ref) {
|
|
|
111
99
|
elementRef.current.style[key] = value;
|
|
112
100
|
}
|
|
113
101
|
}, [elementRef, style]);
|
|
114
|
-
var transform = align === 'center' ? "translate(".concat(width / 2, ",").concat(height / 2 - 20, ") scale(").concat(scale, ")") : "0,0) scale(".concat(scale, ")");
|
|
102
|
+
var transform = align === 'center' ? "translate(".concat(width / 2, ",").concat(height / 2 - 20, ") scale(").concat(scale, ")") : "translate(0,0) scale(".concat(scale, ")");
|
|
115
103
|
return jsxRuntime.jsx(ResponsiveSVG, _objectSpread__default["default"](_objectSpread__default["default"]({
|
|
116
104
|
width: width,
|
|
117
105
|
height: height
|
|
@@ -119,12 +107,12 @@ function ParentsizeSVG(_ref) {
|
|
|
119
107
|
children: jsxRuntime.jsx("g", {
|
|
120
108
|
transform: transform,
|
|
121
109
|
children: children
|
|
122
|
-
}
|
|
123
|
-
})
|
|
110
|
+
})
|
|
111
|
+
}));
|
|
124
112
|
}
|
|
125
113
|
|
|
126
114
|
var _excluded$1 = ["y", "x", "transform", "className", "children", "innerRef"];
|
|
127
|
-
|
|
115
|
+
function Group(_ref) {
|
|
128
116
|
var _ref$y = _ref.y,
|
|
129
117
|
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
130
118
|
_ref$x = _ref.x,
|
|
@@ -141,11 +129,11 @@ var Group = function Group(_ref) {
|
|
|
141
129
|
transform: transform || "translate(".concat(x, ", ").concat(y, ")")
|
|
142
130
|
}, restProps), {}, {
|
|
143
131
|
children: children
|
|
144
|
-
})
|
|
145
|
-
}
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
146
134
|
|
|
147
135
|
var _excluded = ["from", "to", "fill", "className", "innerRef"];
|
|
148
|
-
|
|
136
|
+
function Line(_ref) {
|
|
149
137
|
var _ref$from = _ref.from,
|
|
150
138
|
from = _ref$from === void 0 ? {
|
|
151
139
|
x: 0,
|
|
@@ -172,8 +160,8 @@ var Line = function Line(_ref) {
|
|
|
172
160
|
y2: to.y,
|
|
173
161
|
fill: fill,
|
|
174
162
|
shapeRendering: isRectilinear ? 'crispEdges' : 'auto'
|
|
175
|
-
}, restProps)
|
|
176
|
-
}
|
|
163
|
+
}, restProps));
|
|
164
|
+
}
|
|
177
165
|
|
|
178
166
|
exports.Group = Group;
|
|
179
167
|
exports.Line = Line;
|
|
@@ -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 type { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n}\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 type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport { useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\nimport type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';\nimport { ResponsiveSVG } 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 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 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,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ACAD,gBAAAA;MACGmC;;AAEH,MAAMM,aAAa,GAAGH,IAAI,CAACzC,CAAL,KAAW0C,EAAE,CAAC1C,CAAd,IAAmByC,IAAI,CAACxC,CAAL,KAAWyC,EAAE,CAACzC,CAAvD;AAEA,SACEQ;AACEK,IAAAA,GAAG,EAAEX;AACLC,IAAAA,SAAS,EAAEmC,sBAAE,CAAC,WAAD,EAAcnC,SAAd;AACbyC,IAAAA,EAAE,EAAEJ,IAAI,CAACzC;AACT8C,IAAAA,EAAE,EAAEL,IAAI,CAACxC;AACT8C,IAAAA,EAAE,EAAEL,EAAE,CAAC1C;AACPgD,IAAAA,EAAE,EAAEN,EAAE,CAACzC;AACP0C,IAAAA,IAAI,EAAEA;AACNM,IAAAA,cAAc,EAAEL,aAAa,GAAG,YAAH,GAAkB;KAC3CN,mBAVR;AAaD;;;;;;;"}
|
|
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 { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-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 type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport { useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\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 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'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport function Group({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n}\n","import cx from 'classnames';\nimport type { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport function Line({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n}\n"],"names":["ResponsiveSVG","height","width","children","origin","x","y","preserveAspectRatio","innerRef","className","aspect","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","scale","align","options","debounceDelay","optionsRest","_objectWithoutProperties","_excluded","rest","useParentSize","_objectSpread","useEffect","current","Object","entries","_slicedToArray","key","value","transform","Group","restProps","cx","Line","from","to","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBgB,SAAAA,aAAA,CAQK,IAAA,EAAA;AAAA,EAPnBC,IAA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AA;AAAA,MAAA,SAAA,GAAA,IAAA,CAJvC8C,IAIuC;AAAA,MAJvCA,IAIuC,0BAJhC,aAIgC,GAAA,SAAA;AAAA,MAHvC3C,SAGuC,QAHvCA,SAGuC;AAAA,MAFvCD,QAEuC,QAFvCA,QAEuC;AAAA,MADpCuC,SACoC,GAAAd,4CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACvC,EAAA,IAAMoB,aAAa,GAAGH,IAAI,CAAC7C,CAAL,KAAW8C,EAAE,CAAC9C,CAAd,IAAmB6C,IAAI,CAAC5C,CAAL,KAAW6C,EAAE,CAAC7C,CAAvD,CAAA;AAEA,EACEQ,OAAAA,cACE,CAAA,MAAA,EAAAuB,iCAAA,CAAA;AAAAlB,IAAAA,GAAG,EAAEX,QAAL;AACAC,IAAAA,SAAS,EAAEuC,sBAAE,CAAC,WAAD,EAAcvC,SAAd,CADb;AAEA6C,IAAAA,EAAE,EAAEJ,IAAI,CAAC7C,CAFT;AAGAkD,IAAAA,EAAE,EAAEL,IAAI,CAAC5C,CAHT;AAIAkD,IAAAA,EAAE,EAAEL,EAAE,CAAC9C,CAJP;AAKAoD,IAAAA,EAAE,EAAEN,EAAE,CAAC7C,CALP;AAMA8C,IAAAA,IAAI,EAAEA,IANN;AAOAM,IAAAA,cAAc,EAAEL,aAAa,GAAG,YAAH,GAAkB,MAAA;AAP/C,GAAA,EAQIN,SARJ,CAFJ,CAAA,CAAA;AAaD;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
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"),
|
|
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"),a=require("@cutting/use-get-parent-size"),l=require("classnames");function s(e){return e&&e.__esModule?e:{default:e}}var o=s(r),c=s(t),d=s(i),u=s(l);function f(r){var t=r.width,i=r.children,n=r.origin,a=void 0===n?{x:0,y:0}:n,l=r.preserveAspectRatio,s=void 0===l?"xMaxYMid meet":l,o=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:s,viewBox:"".concat(a.x," ").concat(a.y," ").concat(t," ").concat(d),ref:o,children:i})})}var v=["debounceDelay"],x=["elementRef","children","style","scale","align","options"],h={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"},p=["y","x","transform","className","children","innerRef"],m=["from","to","fill","className","innerRef"];exports.Group=function(r){var t=r.y,i=void 0===t?0:t,n=r.x,a=void 0===n?0:n,l=r.transform,s=r.className,o=r.children,f=r.innerRef,v=d.default(r,p);return e.jsx("g",c.default(c.default({ref:f,className:u.default("visx-group",s),transform:l||"translate(".concat(a,", ").concat(i,")")},v),{},{children:o}))},exports.Line=function(r){var t=r.from,i=void 0===t?{x:0,y:0}:t,n=r.to,a=void 0===n?{x:1,y:1}:n,l=r.fill,s=void 0===l?"transparent":l,o=r.className,f=r.innerRef,v=d.default(r,m),x=i.x===a.x||i.y===a.y;return e.jsx("line",c.default({ref:f,className:u.default("visx-line",o),x1:i.x,y1:i.y,x2:a.x,y2:a.y,fill:s,shapeRendering:x?"crispEdges":"auto"},v))},exports.ParentsizeSVG=function(r){var t=r.elementRef,i=r.children,l=r.style,s=void 0===l?h:l,u=r.scale,p=void 0===u?1:u,m=r.align,y=void 0===m?"none":m,g=r.options,b=(g=void 0===g?{}:g).debounceDelay,j=void 0===b?50:b,R=d.default(g,v),w=d.default(r,x),N=a.useParentSize(t,c.default({debounceDelay:j},R)),q=N.width,M=N.height;n.useEffect((function(){if(t.current)for(var e=0,r=Object.entries(s);e<r.length;e++){var i=o.default(r[e],2);t.current.style[i[0]]=i[1]}}),[t,s]);var S="center"===y?"translate(".concat(q/2,",").concat(M/2-20,") scale(").concat(p,")"):"translate(0,0) scale(".concat(p,")");return e.jsx(f,c.default(c.default({width:q,height:M},w),{},{children:e.jsx("g",{transform:S,children:i})}))},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 {
|
|
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 { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-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 type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport { useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\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 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'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport function Group({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n}\n","import cx from 'classnames';\nimport type { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport function Line({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n}\n"],"names":["ResponsiveSVG","_ref","height","width","children","_ref$origin","origin","x","y","_ref$preserveAspectRa","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","concat","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","_ref$y","_ref$x","transform","restProps","_objectWithoutProperties","_excluded","_objectSpread","cx","_ref$from","from","_ref$to","to","_ref$fill","fill","isRectilinear","jsx","x1","y1","x2","y2","shapeRendering","elementRef","_ref$style","_ref$scale","scale","_ref$align","align","_ref$options","options","_ref$options$debounce","debounceDelay","optionsRest","rest","_excluded2","useParentSize","useEffect","current","_i","_Object$entries","Object","entries","length","_Object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,aAAAlC,OACiBlB,EAAQ,cAAKD,EAAS,EAAI,sBAAamD,EADxD,KAAA,wBAAAhC,OAE4BgC,EAH9B,KAMErC,OAAAA,MAAChB,uBAAcG,MAAOA,EAAOD,OAAQA,GAAY2D,OAAIzD,SACnDY,EAAG4B,IAAA,IAAA,CAAAb,UAAWA,WAAY3B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
declare type GroupOnlyProps = {
|
|
3
2
|
/** Top offset applied to `<g/>`. */
|
|
4
3
|
y?: number;
|
|
@@ -11,6 +10,6 @@ declare type GroupOnlyProps = {
|
|
|
11
10
|
innerRef?: React.Ref<SVGGElement>;
|
|
12
11
|
};
|
|
13
12
|
declare type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
|
|
14
|
-
export declare
|
|
13
|
+
export declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
|
|
15
14
|
export {};
|
|
16
15
|
//# sourceMappingURL=Group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"AAEA,aAAK,cAAc,GAAG;IACpB,oCAAoC;IACpC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,aAAK,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAE3F,wBAAgB,KAAK,CAAC,EACpB,CAAK,EACL,CAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAW1B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Point } from '../../types/types';
|
|
1
|
+
import type { AddSVGProps, Point } from '../../types/types';
|
|
3
2
|
export declare type LineProps = {
|
|
4
3
|
className?: string;
|
|
5
4
|
innerRef?: React.Ref<SVGLineElement>;
|
|
@@ -9,5 +8,5 @@ export declare type LineProps = {
|
|
|
9
8
|
/** Ending x,y point of the line. */
|
|
10
9
|
to?: Point;
|
|
11
10
|
};
|
|
12
|
-
export declare
|
|
11
|
+
export declare function Line({ from, to, fill, className, innerRef, ...restProps }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element;
|
|
13
12
|
//# sourceMappingURL=Line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,oBAAY,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,wBAAgB,IAAI,CAAC,EACnB,IAAqB,EACrB,EAAmB,EACnB,IAAoB,EACpB,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgBtD"}
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, PropsWithChildren, RefObject } from 'react';
|
|
|
2
2
|
import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
|
|
3
3
|
import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';
|
|
4
4
|
declare type Align = 'none' | 'center';
|
|
5
|
-
export declare type ParentsizeSVGProps<E extends HTMLElement> = {
|
|
5
|
+
export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
|
|
6
6
|
elementRef: RefObject<E>;
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
align?: Align;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI;
|
|
1
|
+
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAOjB,CAAC;AAEX,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,UAAU,EACV,QAAQ,EACR,KAAoB,EACpB,KAAS,EACT,KAAc,EACd,OAAO,EAAE,EAAE,aAAkB,EAAE,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { PreserveAspectRatio } from '../../types/types';
|
|
3
3
|
export interface Point {
|
|
4
4
|
x: number;
|
|
@@ -12,6 +12,7 @@ export interface ResponsiveSVGProps {
|
|
|
12
12
|
innerRef?: Ref<SVGSVGElement>;
|
|
13
13
|
className?: string;
|
|
14
14
|
hide?: boolean;
|
|
15
|
+
children: ReactNode;
|
|
15
16
|
}
|
|
16
|
-
export declare
|
|
17
|
+
export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, }: ResponsiveSVGProps): JSX.Element;
|
|
17
18
|
//# sourceMappingURL=ResponsiveSVG.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAyBlC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +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
|
|
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 t from"@babel/runtime/helpers/esm/objectWithoutProperties";import{useEffect as n}from"react";import{useParentSize as o}from"@cutting/use-get-parent-size";import a from"classnames";function c(r){var i=r.width,t=r.children,n=r.origin,o=void 0===n?{x:0,y:0}:n,a=r.preserveAspectRatio,c=void 0===a?"xMaxYMid meet":a,l=r.innerRef,s=r.className,f=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:s,preserveAspectRatio:c,viewBox:"".concat(o.x," ").concat(o.y," ").concat(i," ").concat(f),ref:l,children:t})})}var l=["debounceDelay"],s=["elementRef","children","style","scale","align","options"],f={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function m(a){var m=a.elementRef,d=a.children,v=a.style,h=void 0===v?f:v,p=a.scale,u=void 0===p?1:p,x=a.align,y=void 0===x?"none":x,g=a.options,b=(g=void 0===g?{}:g).debounceDelay,R=void 0===b?50:b,w=t(g,l),N=t(a,s),j=o(m,i({debounceDelay:R},w)),D=j.width,A=j.height;n((function(){if(m.current)for(var e=0,i=Object.entries(h);e<i.length;e++){var t=r(i[e],2);m.current.style[t[0]]=t[1]}}),[m,h]);var M="center"===y?"translate(".concat(D/2,",").concat(A/2-20,") scale(").concat(u,")"):"translate(0,0) scale(".concat(u,")");return e(c,i(i({width:D,height:A},N),{},{children:e("g",{transform:M,children:d})}))}var d=["y","x","transform","className","children","innerRef"];function v(r){var n=r.y,o=void 0===n?0:n,c=r.x,l=void 0===c?0:c,s=r.transform,f=r.className,m=r.children,v=r.innerRef,h=t(r,d);return e("g",i(i({ref:v,className:a("visx-group",f),transform:s||"translate(".concat(l,", ").concat(o,")")},h),{},{children:m}))}var h=["from","to","fill","className","innerRef"];function p(r){var n=r.from,o=void 0===n?{x:0,y:0}:n,c=r.to,l=void 0===c?{x:1,y:1}:c,s=r.fill,f=void 0===s?"transparent":s,m=r.className,d=r.innerRef,v=t(r,h),p=o.x===l.x||o.y===l.y;return e("line",i({ref:d,className:a("visx-line",m),x1:o.x,y1:o.y,x2:l.x,y2:l.y,fill:f,shapeRendering:p?"crispEdges":"auto"},v))}export{v as Group,p as Line,m as ParentsizeSVG,c 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 {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-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 type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport { useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\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 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'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport function Group({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n}\n","import cx from 'classnames';\nimport type { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport function Line({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n}\n"],"names":["ResponsiveSVG","_ref","height","width","children","_ref$origin","origin","x","y","_ref$preserveAspectRa","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","concat","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","ParentsizeSVG","elementRef","_ref$style","_ref$scale","scale","_ref$align","align","_ref$options","options","_ref$options$debounce","debounceDelay","optionsRest","_objectWithoutProperties","_excluded","rest","_excluded2","useParentSize","_objectSpread","useEffect","current","_i","_Object$entries","Object","entries","length","_Object$entries$_i","_slicedToArray","transform","Group","_ref$y","_ref$x","restProps","cx","Line","_ref$from","from","_ref$to","to","_ref$fill","fill","isRectilinear","x1","y1","x2","y2","shapeRendering"],"mappings":"mVAmBgB,SAAAA,EAQK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KxD,EACTgE,GAAIN,EAAG3D,EACPkE,GAAIP,EAAG1D,EACP4D,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
declare type GroupOnlyProps = {
|
|
3
2
|
/** Top offset applied to `<g/>`. */
|
|
4
3
|
y?: number;
|
|
@@ -11,6 +10,6 @@ declare type GroupOnlyProps = {
|
|
|
11
10
|
innerRef?: React.Ref<SVGGElement>;
|
|
12
11
|
};
|
|
13
12
|
declare type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
|
|
14
|
-
export declare
|
|
13
|
+
export declare function Group({ y, x, transform, className, children, innerRef, ...restProps }: GroupProps): JSX.Element;
|
|
15
14
|
export {};
|
|
16
15
|
//# sourceMappingURL=Group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../../src/components/Group/Group.tsx"],"names":[],"mappings":"AAEA,aAAK,cAAc,GAAG;IACpB,oCAAoC;IACpC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;CACnC,CAAC;AAEF,aAAK,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAE3F,wBAAgB,KAAK,CAAC,EACpB,CAAK,EACL,CAAK,EACL,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,UAAU,GAAG,GAAG,CAAC,OAAO,CAW1B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Point } from '../../types/types';
|
|
1
|
+
import type { AddSVGProps, Point } from '../../types/types';
|
|
3
2
|
export declare type LineProps = {
|
|
4
3
|
className?: string;
|
|
5
4
|
innerRef?: React.Ref<SVGLineElement>;
|
|
@@ -9,5 +8,5 @@ export declare type LineProps = {
|
|
|
9
8
|
/** Ending x,y point of the line. */
|
|
10
9
|
to?: Point;
|
|
11
10
|
};
|
|
12
|
-
export declare
|
|
11
|
+
export declare function Line({ from, to, fill, className, innerRef, ...restProps }: AddSVGProps<LineProps, SVGLineElement>): JSX.Element;
|
|
13
12
|
//# sourceMappingURL=Line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/components/Line/Line.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,oBAAY,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,oCAAoC;IACpC,EAAE,CAAC,EAAE,KAAK,CAAC;CACZ,CAAC;AAEF,wBAAgB,IAAI,CAAC,EACnB,IAAqB,EACrB,EAAmB,EACnB,IAAoB,EACpB,SAAS,EACT,QAAQ,EACR,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,GAAG,GAAG,CAAC,OAAO,CAgBtD"}
|
|
@@ -2,7 +2,7 @@ import type { CSSProperties, PropsWithChildren, RefObject } from 'react';
|
|
|
2
2
|
import type { UseParentSizeOptions } from '@cutting/use-get-parent-size';
|
|
3
3
|
import type { ResponsiveSVGProps } from '../ResponsiveSVG/ResponsiveSVG';
|
|
4
4
|
declare type Align = 'none' | 'center';
|
|
5
|
-
export declare type ParentsizeSVGProps<E extends HTMLElement> = {
|
|
5
|
+
export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
|
|
6
6
|
elementRef: RefObject<E>;
|
|
7
7
|
style?: CSSProperties;
|
|
8
8
|
align?: Align;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI;
|
|
1
|
+
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,EAAE,aAOjB,CAAC;AAEX,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,EACnD,UAAU,EACV,QAAQ,EACR,KAAoB,EACpB,KAAS,EACT,KAAc,EACd,OAAO,EAAE,EAAE,aAAkB,EAAE,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { PreserveAspectRatio } from '../../types/types';
|
|
3
3
|
export interface Point {
|
|
4
4
|
x: number;
|
|
@@ -12,6 +12,7 @@ export interface ResponsiveSVGProps {
|
|
|
12
12
|
innerRef?: Ref<SVGSVGElement>;
|
|
13
13
|
className?: string;
|
|
14
14
|
hide?: boolean;
|
|
15
|
+
children: ReactNode;
|
|
15
16
|
}
|
|
16
|
-
export declare
|
|
17
|
+
export declare function ResponsiveSVG({ height, width, children, origin, preserveAspectRatio, innerRef, className, }: ResponsiveSVGProps): JSX.Element;
|
|
17
18
|
//# sourceMappingURL=ResponsiveSVG.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResponsiveSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ResponsiveSVG/ResponsiveSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAuB,EACvB,mBAAqC,EACrC,QAAQ,EACR,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAyBlC"}
|
package/dist/umd/index.js
CHANGED
|
@@ -1,2 +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,
|
|
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,a,s,l){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var c=o(r),u=o(i),d=o(n),f=o(l);function h(e){var r=e.width,i=e.children,n=e.origin,a=void 0===n?{x:0,y:0}:n,s=e.preserveAspectRatio,l=void 0===s?"xMaxYMid meet":s,o=e.innerRef,c=e.className,u=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:c,preserveAspectRatio:l,viewBox:"".concat(a.x," ").concat(a.y," ").concat(r," ").concat(u),ref:o,children:i})})}var v=["debounceDelay"],p=["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"],y=["from","to","fill","className","innerRef"];e.Group=function(e){var r=e.y,i=void 0===r?0:r,n=e.x,a=void 0===n?0:n,s=e.transform,l=e.className,o=e.children,c=e.innerRef,h=d.default(e,m);return t.jsx("g",u.default(u.default({ref:c,className:f.default("visx-group",l),transform:s||"translate(".concat(a,", ").concat(i,")")},h),{},{children:o}))},e.Line=function(e){var r=e.from,i=void 0===r?{x:0,y:0}:r,n=e.to,a=void 0===n?{x:1,y:1}:n,s=e.fill,l=void 0===s?"transparent":s,o=e.className,c=e.innerRef,h=d.default(e,y),v=i.x===a.x||i.y===a.y;return t.jsx("line",u.default({ref:c,className:f.default("visx-line",o),x1:i.x,y1:i.y,x2:a.x,y2:a.y,fill:l,shapeRendering:v?"crispEdges":"auto"},h))},e.ParentsizeSVG=function(e){var r=e.elementRef,i=e.children,n=e.style,l=void 0===n?x:n,o=e.scale,f=void 0===o?1:o,m=e.align,y=void 0===m?"none":m,b=e.options,g=(b=void 0===b?{}:b).debounceDelay,j=void 0===g?50:g,R=d.default(b,v),w=d.default(e,p),N=s.useParentSize(r,u.default({debounceDelay:j},R)),S=N.width,q=N.height;a.useEffect((function(){if(r.current)for(var e=0,t=Object.entries(l);e<t.length;e++){var i=c.default(t[e],2);r.current.style[i[0]]=i[1]}}),[r,l]);var P="center"===y?"translate(".concat(S/2,",").concat(q/2-20,") scale(").concat(f,")"):"translate(0,0) scale(".concat(f,")");return t.jsx(h,u.default(u.default({width:S,height:q},w),{},{children:t.jsx("g",{transform:P,children:i})}))},e.ResponsiveSVG=h}));
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/umd/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 {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } from '../../types/types';\n\nexport interface Point {\n x: number;\n y: number;\n}\n\nexport interface ResponsiveSVGProps {\n width: number;\n height: number;\n origin?: Point;\n preserveAspectRatio?: PreserveAspectRatio;\n innerRef?: Ref<SVGSVGElement>;\n className?: string;\n hide?: boolean;\n children: ReactNode;\n}\n\nexport function ResponsiveSVG({\n height,\n width,\n children,\n origin = { x: 0, y: 0 },\n preserveAspectRatio = 'xMaxYMid meet',\n innerRef,\n className,\n}: ResponsiveSVGProps): JSX.Element {\n const aspect = width / height;\n\n const adjustedHeight = Math.ceil(width / aspect);\n\n return (\n <div\n data-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 type { CSSProperties, PropsWithChildren, RefObject } from 'react';\nimport { useEffect } from 'react';\nimport type { UseParentSizeOptions } from '@cutting/use-get-parent-size';\nimport { useParentSize } from '@cutting/use-get-parent-size';\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 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'\n ? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`\n : `translate(0,0) scale(${scale})`;\n\n return (\n <ResponsiveSVG width={width} height={height} {...rest}>\n <g transform={transform}>{children}</g>\n </ResponsiveSVG>\n );\n}\n","import cx from 'classnames';\n\ntype GroupOnlyProps = {\n /** Top offset applied to `<g/>`. */\n y?: number;\n /** Left offset applied to `<g/>`. */\n x?: number;\n /** Override `x` and `y` to provide the entire `transform` string. */\n transform?: string;\n className?: string;\n children?: React.ReactNode;\n innerRef?: React.Ref<SVGGElement>;\n};\n\ntype GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;\n\nexport function Group({\n y = 0,\n x = 0,\n transform,\n className,\n children,\n innerRef,\n ...restProps\n}: GroupProps): JSX.Element {\n return (\n <g\n ref={innerRef}\n className={cx('visx-group', className)}\n transform={transform || `translate(${x}, ${y})`}\n {...restProps}\n >\n {children}\n </g>\n );\n}\n","import cx from 'classnames';\nimport type { AddSVGProps, Point } from '../../types/types';\n\nexport type LineProps = {\n className?: string;\n innerRef?: React.Ref<SVGLineElement>;\n fill?: string;\n /** Starting x,y point of the line. */\n from?: Point;\n /** Ending x,y point of the line. */\n to?: Point;\n};\n\nexport function Line({\n from = { x: 0, y: 0 },\n to = { x: 1, y: 1 },\n fill = 'transparent',\n className,\n innerRef,\n ...restProps\n}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {\n const isRectilinear = from.x === to.x || from.y === to.y;\n\n return (\n <line\n ref={innerRef}\n className={cx('visx-line', className)}\n x1={from.x}\n y1={from.y}\n x2={to.x}\n y2={to.y}\n fill={fill}\n shapeRendering={isRectilinear ? 'crispEdges' : 'auto'}\n {...restProps}\n />\n );\n}\n"],"names":["ResponsiveSVG","_ref","height","width","children","_ref$origin","origin","x","y","_ref$preserveAspectRa","preserveAspectRatio","innerRef","className","adjustedHeight","Math","ceil","_jsx","style","position","overflow","viewBox","concat","ref","DefaultStyle","display","flexDirection","flexGrow","flexShrink","flexBasis","_ref$y","_ref$x","transform","restProps","_objectWithoutProperties","_excluded","_objectSpread","cx","_ref$from","from","_ref$to","to","_ref$fill","fill","isRectilinear","jsx","x1","y1","x2","y2","shapeRendering","elementRef","_ref$style","_ref$scale","scale","_ref$align","align","_ref$options","options","_ref$options$debounce","debounceDelay","optionsRest","rest","_excluded2","useParentSize","useEffect","current","_i","_Object$entries","Object","entries","length","_Object$entries$_i","_slicedToArray"],"mappings":"84BAmBgB,SAAAA,EAQKC,GAPnBC,IACAC,IAAAA,MACAC,IAAAA,SAKmBC,EAAAJ,EAJnBK,OAAAA,OAAS,IAAAD,EAAA,CAAEE,EAAG,EAAGC,EAAG,GAIDH,EAAAI,EAAAR,EAHnBS,oBAAAA,aAAsB,gBAGHD,EAFnBE,IAAAA,SACAC,IAAAA,UAIMC,EAAiBC,KAAKC,KAAKZ,GAFlBA,IARfD,SAaEc,OAAAA,EAAAA,IAAA,MAAA,CAAA,gBACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVjB,OAAQ,OACTE,SAEDY,aACEC,MAAO,CAAEE,SAAU,WACnBP,UAAWA,EACXF,oBAAqBA,EACrBU,QAAO,GAAAC,OAAKf,EAAOC,EAAZ,KAAAc,OAAiBf,EAAOE,EAAxB,KAAAa,OAA6BlB,EAA7B,KAAAkB,OAAsCR,GAC7CS,IAAKX,EAAQP,SAEZA,4FC/BImB,EAA8B,CACzCC,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AAE,EAAArD,EAHzCsD,MAAAA,aAAQ,OAGiCD,EAAAE,EAAAvD,EAFzCwD,QAEyCC,GAAAF,OAAA,IAAAA,EAFS,GAETA,GAF9BG,cAAAA,aAAgB,GAEcD,EAFPE,EAEO3B,EAAAA,QAAAuB,EAAAtB,GADtC2B,EACsC5B,EAAA,QAAAhC,EAAA6D,GACfC,EAAAA,EAAAA,cAAcb,EAADf,UAAA,CAAewB,cAAAA,GAAkBC,IAAhEzD,IAAAA,MAAOD,IAAAA,OAEf8D,EAAAA,WAAU,WACR,GAAKd,EAAWe,QAIhB,IAAA,IAAAC,EAAA,EAAAC,EAA2BC,OAAOC,QAAQpD,GAAQiD,EAAAC,EAAAG,OAAAJ,IAAA,CAA7C,IAAAK,EAAAC,EAAA,QAAAL,EAAAD,GAAA,GAEHhB,EAAWe,QAAQhD,MAFhBsD,EAAA,IAAAA,EAAA,MAIJ,CAACrB,EAAYjC,IAEhB,IAAMc,EACM,WAAVwB,EAAA,aAAAlC,OACiBlB,EAAQ,cAAKD,EAAS,EAAI,sBAAamD,EADxD,KAAA,wBAAAhC,OAE4BgC,EAH9B,KAMErC,OAAAA,MAAChB,uBAAcG,MAAOA,EAAOD,OAAQA,GAAY2D,OAAIzD,SACnDY,EAAG4B,IAAA,IAAA,CAAAb,UAAWA,WAAY3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cutting/svg",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.32.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dagda1/cuttingedge.git"
|
|
@@ -15,26 +15,28 @@
|
|
|
15
15
|
"types": "dist/esm/index.d.ts",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cutting/use-get-parent-size": "1.6.
|
|
19
|
-
"@cutting/util": "4.
|
|
18
|
+
"@cutting/use-get-parent-size": "1.6.11",
|
|
19
|
+
"@cutting/util": "4.31.1",
|
|
20
20
|
"classnames": "^2.3.1",
|
|
21
21
|
"resize-observer-polyfill": "^1.5.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@babel/runtime": "
|
|
25
|
-
"@cutting/component-library": "5.
|
|
26
|
-
"@cutting/devtools": "4.
|
|
27
|
-
"@cutting/eslint-config": "4.
|
|
28
|
-
"@cutting/tsconfig": "4.26.
|
|
29
|
-
"@cutting/useful-types": "4.25.
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
24
|
+
"@babel/runtime": "7.17.8",
|
|
25
|
+
"@cutting/component-library": "5.5.1",
|
|
26
|
+
"@cutting/devtools": "4.32.1",
|
|
27
|
+
"@cutting/eslint-config": "4.29.1",
|
|
28
|
+
"@cutting/tsconfig": "4.26.5",
|
|
29
|
+
"@cutting/useful-types": "4.25.10",
|
|
30
|
+
"@jest/globals": "27.5.1",
|
|
31
|
+
"@testing-library/jest-dom": "5.16.2",
|
|
32
|
+
"@testing-library/react": "^12.1.4",
|
|
33
|
+
"@vanilla-extract/babel-plugin": "1.1.5",
|
|
34
|
+
"@vanilla-extract/css": "1.6.8",
|
|
35
|
+
"@vanilla-extract/sprinkles": "1.4.0",
|
|
36
|
+
"eslint": "8.11.0",
|
|
37
|
+
"react": "17.0.2",
|
|
38
|
+
"react-dom": "17.0.2",
|
|
39
|
+
"typescript": "4.6.2"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {
|
|
40
42
|
"react": ">= 17.x.x",
|
|
@@ -56,11 +58,11 @@
|
|
|
56
58
|
}
|
|
57
59
|
},
|
|
58
60
|
"scripts": {
|
|
59
|
-
"build": "NODE_ENV=
|
|
61
|
+
"build": "NODE_ENV=production cutting rollup",
|
|
60
62
|
"lint": "eslint ./src/**/*.{ts,tsx} --fix",
|
|
61
63
|
"start": "PORT=8888 NODE_ENV=development cutting devserver-start",
|
|
62
64
|
"test": "NODE_ENV=test cutting test",
|
|
63
65
|
"test:ci": "CI=true pnpm test"
|
|
64
66
|
},
|
|
65
|
-
"readme": "# @cutting/svg - reusable svg components for SVG documents\n[](https://www.npmjs.com/package/@cutting/svg)\n[](https://github.com/prettier/prettier)\n\n## install \n\n```sh\npnpm add @cutting/svg\n\n# or\n\nnpm install @cutting/svg\n```\n\n## ParentsizeSVG\n\nA react component that will resize and scale to the dimensions of the supplied react [ref object](https://reactjs.org/docs/refs-and-the-dom.html).\n\n\n\nThe `ParentsizeSVG` component takes an `elementRef` prop that should point to a valid HTML DOM element.\n\n## usage\n\n```ts\nimport
|
|
67
|
+
"readme": "# @cutting/svg - reusable svg components for SVG documents\n[](https://www.npmjs.com/package/@cutting/svg)\n[](https://github.com/prettier/prettier)\n\n## install \n\n```sh\npnpm add @cutting/svg\n\n# or\n\nnpm install @cutting/svg\n```\n\n## ParentsizeSVG\n\nA react component that will resize and scale to the dimensions of the supplied react [ref object](https://reactjs.org/docs/refs-and-the-dom.html).\n\n\n\nThe `ParentsizeSVG` component takes an `elementRef` prop that should point to a valid HTML DOM element.\n\n## usage\n\n```ts\nimport { useRef } from 'react';\nimport { ParentsizeSVG } from '@cutting/svg';\n\nexport function App(): JSX.Element {\n const ref = useRef<HTMLDivElement>(null);\n\n return (\n <div className={styles.container} ref={ref}>\n <ParentsizeSVG ref={ref}>\n <rect\n x=\"20%\"\n y=\"20%\"\n width={'50%'}\n height={'50%'}\n rx=\"20\"\n style={{ fill: '#ff0000', stroke: '#000000', strokeWidth: '2px' }}\n />\n </ParentsizeSVG>\n </div>\n );\n};\n```"
|
|
66
68
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
import cx from 'classnames';
|
|
3
2
|
|
|
4
3
|
type GroupOnlyProps = {
|
|
@@ -15,7 +14,7 @@ type GroupOnlyProps = {
|
|
|
15
14
|
|
|
16
15
|
type GroupProps = GroupOnlyProps & Omit<React.SVGProps<SVGGElement>, keyof GroupOnlyProps>;
|
|
17
16
|
|
|
18
|
-
export
|
|
17
|
+
export function Group({
|
|
19
18
|
y = 0,
|
|
20
19
|
x = 0,
|
|
21
20
|
transform,
|
|
@@ -23,7 +22,7 @@ export const Group: FC<GroupProps> = ({
|
|
|
23
22
|
children,
|
|
24
23
|
innerRef,
|
|
25
24
|
...restProps
|
|
26
|
-
}: GroupProps): JSX.Element
|
|
25
|
+
}: GroupProps): JSX.Element {
|
|
27
26
|
return (
|
|
28
27
|
<g
|
|
29
28
|
ref={innerRef}
|
|
@@ -34,4 +33,4 @@ export const Group: FC<GroupProps> = ({
|
|
|
34
33
|
{children}
|
|
35
34
|
</g>
|
|
36
35
|
);
|
|
37
|
-
}
|
|
36
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
1
|
import cx from 'classnames';
|
|
3
2
|
import type { AddSVGProps, Point } from '../../types/types';
|
|
4
3
|
|
|
@@ -12,14 +11,14 @@ export type LineProps = {
|
|
|
12
11
|
to?: Point;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
export
|
|
14
|
+
export function Line({
|
|
16
15
|
from = { x: 0, y: 0 },
|
|
17
16
|
to = { x: 1, y: 1 },
|
|
18
17
|
fill = 'transparent',
|
|
19
18
|
className,
|
|
20
19
|
innerRef,
|
|
21
20
|
...restProps
|
|
22
|
-
}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element
|
|
21
|
+
}: AddSVGProps<LineProps, SVGLineElement>): JSX.Element {
|
|
23
22
|
const isRectilinear = from.x === to.x || from.y === to.y;
|
|
24
23
|
|
|
25
24
|
return (
|
|
@@ -35,4 +34,4 @@ export const Line: FC<LineProps> = ({
|
|
|
35
34
|
{...restProps}
|
|
36
35
|
/>
|
|
37
36
|
);
|
|
38
|
-
}
|
|
37
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { describe, it, expect } from '@jest/globals';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import { useParentSize } from '@cutting/use-get-parent-size';
|
|
5
4
|
import { useRef } from 'react';
|
|
5
|
+
import type { ParentsizeSVGProps } from './ParentsizeSVG';
|
|
6
6
|
import { ParentsizeSVG } from './ParentsizeSVG';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function TestEr(props: Partial<ParentsizeSVGProps>) {
|
|
9
9
|
const ref = useRef<HTMLDivElement>(null);
|
|
10
10
|
useParentSize(ref);
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<ParentsizeSVG elementRef={ref}>
|
|
13
|
+
<ParentsizeSVG {...props} elementRef={ref}>
|
|
14
14
|
<rect x="20%" y="20%" width="200px" height="200px" rx="20" />
|
|
15
15
|
</ParentsizeSVG>
|
|
16
16
|
);
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
-
const wrap = () => render(<TestEr />);
|
|
19
|
+
const wrap = (props: Partial<ParentsizeSVGProps> = {}) => render(<TestEr {...props} />);
|
|
20
20
|
|
|
21
21
|
describe('useParentSize', () => {
|
|
22
22
|
it('should set the svg viewBox attribute', () => {
|
|
@@ -28,4 +28,20 @@ describe('useParentSize', () => {
|
|
|
28
28
|
|
|
29
29
|
screen.getByTestId('cutting-svg-container');
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it('should render a transform attribute when not aligned', () => {
|
|
33
|
+
wrap();
|
|
34
|
+
|
|
35
|
+
const svg = document.querySelector('svg') as SVGElement;
|
|
36
|
+
|
|
37
|
+
expect(svg.querySelector('g') as SVGGElement).toHaveAttribute('transform', 'translate(0,0) scale(1)');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should render a transform attribute when aligned', () => {
|
|
41
|
+
wrap({ align: 'center' });
|
|
42
|
+
|
|
43
|
+
const svg = document.querySelector('svg') as SVGElement;
|
|
44
|
+
|
|
45
|
+
expect(svg.querySelector('g') as SVGGElement).toHaveAttribute('transform', 'translate(0.5,-19.5) scale(1)');
|
|
46
|
+
});
|
|
31
47
|
});
|
|
@@ -7,7 +7,7 @@ import { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';
|
|
|
7
7
|
|
|
8
8
|
type Align = 'none' | 'center';
|
|
9
9
|
|
|
10
|
-
export type ParentsizeSVGProps<E extends HTMLElement> = {
|
|
10
|
+
export type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
|
|
11
11
|
elementRef: RefObject<E>;
|
|
12
12
|
style?: CSSProperties;
|
|
13
13
|
align?: Align;
|
|
@@ -47,7 +47,9 @@ export function ParentsizeSVG<E extends HTMLElement>({
|
|
|
47
47
|
}, [elementRef, style]);
|
|
48
48
|
|
|
49
49
|
const transform =
|
|
50
|
-
align === 'center'
|
|
50
|
+
align === 'center'
|
|
51
|
+
? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`
|
|
52
|
+
: `translate(0,0) scale(${scale})`;
|
|
51
53
|
|
|
52
54
|
return (
|
|
53
55
|
<ResponsiveSVG width={width} height={height} {...rest}>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { describe, it, expect, jest } from '@jest/globals';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
2
|
import { render, screen } from '@testing-library/react';
|
|
4
3
|
import { useParentSize } from '@cutting/use-get-parent-size';
|
|
5
4
|
import { useRef } from 'react';
|
|
@@ -18,7 +17,7 @@ const resize = (width: number, height: number): void => {
|
|
|
18
17
|
});
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
function TestEr(): JSX.Element {
|
|
22
21
|
const ref = useRef<HTMLDivElement>(null);
|
|
23
22
|
const { width, height } = useParentSize(ref);
|
|
24
23
|
|
|
@@ -29,7 +28,7 @@ const TestEr: FC = () => {
|
|
|
29
28
|
</ResponsiveSVG>
|
|
30
29
|
</div>
|
|
31
30
|
);
|
|
32
|
-
}
|
|
31
|
+
}
|
|
33
32
|
|
|
34
33
|
const wrap = () => render(<TestEr />);
|
|
35
34
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
2
|
import type { PreserveAspectRatio } from '../../types/types';
|
|
3
3
|
|
|
4
4
|
export interface Point {
|
|
@@ -14,9 +14,10 @@ export interface ResponsiveSVGProps {
|
|
|
14
14
|
innerRef?: Ref<SVGSVGElement>;
|
|
15
15
|
className?: string;
|
|
16
16
|
hide?: boolean;
|
|
17
|
+
children: ReactNode;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export
|
|
20
|
+
export function ResponsiveSVG({
|
|
20
21
|
height,
|
|
21
22
|
width,
|
|
22
23
|
children,
|
|
@@ -24,7 +25,7 @@ export const ResponsiveSVG: FC<ResponsiveSVGProps> = ({
|
|
|
24
25
|
preserveAspectRatio = 'xMaxYMid meet',
|
|
25
26
|
innerRef,
|
|
26
27
|
className,
|
|
27
|
-
})
|
|
28
|
+
}: ResponsiveSVGProps): JSX.Element {
|
|
28
29
|
const aspect = width / height;
|
|
29
30
|
|
|
30
31
|
const adjustedHeight = Math.ceil(width / aspect);
|
|
@@ -49,4 +50,4 @@ export const ResponsiveSVG: FC<ResponsiveSVGProps> = ({
|
|
|
49
50
|
</svg>
|
|
50
51
|
</div>
|
|
51
52
|
);
|
|
52
|
-
}
|
|
53
|
+
}
|