@cutting/svg 4.32.0 → 4.34.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.
@@ -1,6 +1,6 @@
1
- @cutting/svg:build: cache hit, replaying output 8026d1b55afa770c
1
+ @cutting/svg:build: cache hit, replaying output efba4b9a1e9ae7ea
2
2
  @cutting/svg:build:
3
- @cutting/svg:build: > @cutting/svg@4.32.0 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
3
+ @cutting/svg:build: > @cutting/svg@4.34.0 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
4
4
  @cutting/svg:build: > NODE_ENV=production cutting rollup
5
5
  @cutting/svg:build:
6
6
  @cutting/svg:build: DEBUG using tsconfig.dist.json
@@ -11,12 +11,12 @@
11
11
  @cutting/svg:build: INFO writing svg.cjs.development.js for @cutting/svg
12
12
  @cutting/svg:build: INFO writing svg.cjs.production.min.js for @cutting/svg
13
13
  @cutting/svg:build: INFO writing index.js for @cutting/svg
14
- @cutting/svg:build: INFO writing index.js for @cutting/svg
15
14
  @cutting/svg:build: No name was provided for external module 'react/jsx-runtime' in output.globals – guessing 'jsxRuntime'
16
15
  @cutting/svg:build: No name was provided for external module '@babel/runtime/helpers/slicedToArray' in output.globals – guessing '_slicedToArray'
17
16
  @cutting/svg:build: No name was provided for external module '@babel/runtime/helpers/objectSpread2' in output.globals – guessing '_objectSpread'
18
17
  @cutting/svg:build: No name was provided for external module '@babel/runtime/helpers/objectWithoutProperties' in output.globals – guessing '_objectWithoutProperties'
19
18
  @cutting/svg:build: No name was provided for external module '@cutting/use-get-parent-size' in output.globals – guessing 'useGetParentSize'
20
19
  @cutting/svg:build: No name was provided for external module 'classnames' in output.globals – guessing 'cx'
20
+ @cutting/svg:build: INFO writing index.js for @cutting/svg
21
21
  @cutting/svg:build: DONE finished building
22
22
  @cutting/svg:build:
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @cutting/svg
2
2
 
3
+ ## 4.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8c139b38: rename elementRef parentRef
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [8c139b38]
12
+ - @cutting/use-get-parent-size@1.8.0
13
+
14
+ ## 4.33.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 96855ac9: rename elementRef parentRef
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [96855ac9]
23
+ - @cutting/use-get-parent-size@1.7.0
24
+
25
+ ## 4.32.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 0f3d2133: changesets fixes
30
+ - Updated dependencies [0f3d2133]
31
+ - @cutting/use-get-parent-size@1.6.11
32
+ - @cutting/util@4.31.1
33
+
3
34
  ## 4.32.0
4
35
 
5
36
  ### Minor Changes
package/README.md CHANGED
@@ -18,7 +18,7 @@ A react component that will resize and scale to the dimensions of the supplied r
18
18
 
19
19
  ![svg document resizing to scale when using the ParentsizeSVG component](./img/sizer.gif)
20
20
 
21
- The `ParentsizeSVG` component takes an `elementRef` prop that should point to a valid HTML DOM element.
21
+ The `ParentsizeSVG` component takes an `parentRef` prop that should point to a valid HTML DOM element.
22
22
 
23
23
  ## usage
24
24
 
Binary file
package/demo/App.tsx CHANGED
@@ -9,7 +9,7 @@ export function App(): JSX.Element {
9
9
  return (
10
10
  <ApplicationLayout heading="@cutting/svg" className={cuttingTheme}>
11
11
  <div className={styles.container} ref={ref}>
12
- <ParentsizeSVG elementRef={ref} options={{ debounceDelay: 10 }}>
12
+ <ParentsizeSVG parentRef={ref} options={{ debounceDelay: 10 }}>
13
13
  <rect
14
14
  x="0"
15
15
  y="0"
@@ -3,13 +3,13 @@ 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
5
  export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
6
- elementRef: RefObject<E>;
6
+ parentRef: RefObject<E>;
7
7
  style?: CSSProperties;
8
8
  align?: Align;
9
9
  scale?: number;
10
10
  options?: Partial<UseParentSizeOptions>;
11
11
  } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
12
12
  export declare const DefaultStyle: CSSProperties;
13
- export declare function ParentsizeSVG<E extends HTMLElement>({ elementRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
13
+ export declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
14
14
  export {};
15
15
  //# sourceMappingURL=ParentsizeSVG.d.ts.map
@@ -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,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,MAA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E,GAAG,WAAW,EAAO,EACpD,GAAG,IAAI,EACR,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAwB/D"}
@@ -17,18 +17,6 @@ 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
- (function() {
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
20
  function ResponsiveSVG(_ref) {
33
21
  var height = _ref.height,
34
22
  width = _ref.width,
@@ -65,7 +53,7 @@ function ResponsiveSVG(_ref) {
65
53
  }
66
54
 
67
55
  var _excluded$2 = ["debounceDelay"],
68
- _excluded2 = ["elementRef", "children", "style", "scale", "align", "options"];
56
+ _excluded2 = ["parentRef", "children", "style", "scale", "align", "options"];
69
57
  var DefaultStyle = {
70
58
  display: 'flex',
71
59
  flexDirection: 'column',
@@ -75,7 +63,7 @@ var DefaultStyle = {
75
63
  overflow: 'hidden'
76
64
  };
77
65
  function ParentsizeSVG(_ref) {
78
- var elementRef = _ref.elementRef,
66
+ var parentRef = _ref.parentRef,
79
67
  children = _ref.children,
80
68
  _ref$style = _ref.style,
81
69
  style = _ref$style === void 0 ? DefaultStyle : _ref$style,
@@ -91,14 +79,14 @@ function ParentsizeSVG(_ref) {
91
79
  optionsRest = _objectWithoutProperties__default["default"](_ref$options, _excluded$2),
92
80
  rest = _objectWithoutProperties__default["default"](_ref, _excluded2);
93
81
 
94
- var _useParentSize = useGetParentSize.useParentSize(elementRef, _objectSpread__default["default"]({
82
+ var _useParentSize = useGetParentSize.useParentSize(parentRef, _objectSpread__default["default"]({
95
83
  debounceDelay: debounceDelay
96
84
  }, optionsRest)),
97
85
  width = _useParentSize.width,
98
86
  height = _useParentSize.height;
99
87
 
100
88
  react.useEffect(function () {
101
- if (!elementRef.current) {
89
+ if (!parentRef.current) {
102
90
  return;
103
91
  }
104
92
 
@@ -108,9 +96,9 @@ function ParentsizeSVG(_ref) {
108
96
  value = _Object$entries$_i[1];
109
97
 
110
98
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
- elementRef.current.style[key] = value;
99
+ parentRef.current.style[key] = value;
112
100
  }
113
- }, [elementRef, style]);
101
+ }, [parentRef, style]);
114
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,
@@ -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 { 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,CAQ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AAE,CAAA;AAAX,GAKkC,GAAA,OAAA;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
+ {"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 parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, 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","parentRef","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,IAAAA,MAOmB,QAPnBA,MAOmB;AAAA,MANnBC,KAMmB,QANnBA,KAMmB;AAAA,MALnBC,QAKmB,QALnBA,QAKmB;AAAA,MAAA,WAAA,GAAA,IAAA,CAJnBC,MAImB;AAAA,MAJnBA,MAImB,GAJV,WAAA,KAAA,KAAA,CAAA,GAAA;AAAEC,IAAAA,CAAC,EAAE,CAAL;AAAQC,IAAAA,CAAC,EAAE,CAAA;AAAX,GAIU,GAAA,WAAA;AAAA,MAAA,qBAAA,GAAA,IAAA,CAHnBC,mBAGmB;AAAA,MAHnBA,mBAGmB,sCAHG,eAGH,GAAA,qBAAA;AAAA,MAFnBC,QAEmB,QAFnBA,QAEmB;AAAA,MADnBC,SACmB,QADnBA,SACmB,CAAA;AACnB,EAAA,IAAMC,MAAM,GAAGR,KAAK,GAAGD,MAAvB,CAAA;AAEA,EAAMU,IAAAA,cAAc,GAAGC,IAAI,CAACC,IAAL,CAAUX,KAAK,GAAGQ,MAAlB,CAAvB,CAAA;AAEA,EACEI,OAAAA,cAAA,CAAA,KAAA,EAAA;AAAA,IAAA,eAAA,EACgB,uBADhB;AAEEC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE,UADL;AAELC,MAAAA,QAAQ,EAAE,SAFL;AAGLhB,MAAAA,MAAM,EAAE,KAAA;AAHH,KAFT;AAMGE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AAH,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"),n=require("@babel/runtime/helpers/objectWithoutProperties"),i=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),u=o(n),d=o(a);function f(r){var t=r.width,n=r.children,i=r.origin,s=void 0===i?{x:0,y:0}:i,a=r.preserveAspectRatio,o=void 0===a?"xMaxYMid meet":a,l=r.innerRef,c=r.className,u=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(u),ref:l,children:n})})}!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=["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,n=void 0===t?0:t,i=r.x,s=void 0===i?0:i,a=r.transform,o=r.className,l=r.children,f=r.innerRef,v=u.default(r,h);return e.jsx("g",c.default(c.default({ref:f,className:d.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(n,")")},v),{},{children:l}))},exports.Line=function(r){var t=r.from,n=void 0===t?{x:0,y:0}:t,i=r.to,s=void 0===i?{x:1,y:1}:i,a=r.fill,o=void 0===a?"transparent":a,l=r.className,f=r.innerRef,v=u.default(r,y),x=n.x===s.x||n.y===s.y;return e.jsx("line",c.default({ref:f,className:d.default("visx-line",l),x1:n.x,y1:n.y,x2:s.x,y2:s.y,fill:o,shapeRendering:x?"crispEdges":"auto"},v))},exports.ParentsizeSVG=function(r){var t=r.elementRef,n=r.children,a=r.style,o=void 0===a?p:a,d=r.scale,h=void 0===d?1:d,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=u.default(g,v),N=u.default(r,x),w=s.useParentSize(t,c.default({debounceDelay:j},R)),q=w.width,D=w.height;i.useEffect((function(){if(t.current)for(var e=0,r=Object.entries(o);e<r.length;e++){var n=l.default(r[e],2);t.current.style[n[0]]=n[1]}}),[t,o]);var M="center"===m?"translate(".concat(q/2,",").concat(D/2-20,") scale(").concat(h,")"):"translate(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:n})}))},exports.ResponsiveSVG=f;
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"),a=require("react"),n=require("@cutting/use-get-parent-size"),s=require("classnames");function l(e){return e&&e.__esModule?e:{default:e}}var o=l(r),c=l(t),d=l(i),u=l(s);function f(r){var t=r.width,i=r.children,a=r.origin,n=void 0===a?{x:0,y:0}:a,s=r.preserveAspectRatio,l=void 0===s?"xMaxYMid meet":s,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:l,viewBox:"".concat(n.x," ").concat(n.y," ").concat(t," ").concat(d),ref:o,children:i})})}var v=["debounceDelay"],x=["parentRef","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"],y=["from","to","fill","className","innerRef"];exports.Group=function(r){var t=r.y,i=void 0===t?0:t,a=r.x,n=void 0===a?0:a,s=r.transform,l=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",l),transform:s||"translate(".concat(n,", ").concat(i,")")},v),{},{children:o}))},exports.Line=function(r){var t=r.from,i=void 0===t?{x:0,y:0}:t,a=r.to,n=void 0===a?{x:1,y:1}:a,s=r.fill,l=void 0===s?"transparent":s,o=r.className,f=r.innerRef,v=d.default(r,y),x=i.x===n.x||i.y===n.y;return e.jsx("line",c.default({ref:f,className:u.default("visx-line",o),x1:i.x,y1:i.y,x2:n.x,y2:n.y,fill:l,shapeRendering:x?"crispEdges":"auto"},v))},exports.ParentsizeSVG=function(r){var t=r.parentRef,i=r.children,s=r.style,l=void 0===s?h:s,u=r.scale,p=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),w=d.default(r,x),N=n.useParentSize(t,c.default({debounceDelay:j},R)),q=N.width,M=N.height;a.useEffect((function(){if(t.current)for(var e=0,r=Object.entries(l);e<r.length;e++){var i=o.default(r[e],2);t.current.style[i[0]]=i[1]}}),[t,l]);var S="center"===m?"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 { 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":"+aAmBgB,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,kRC/BImB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXT,SAAU,gICPN,SAQOlB,GAAA,IA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,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"}
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 parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, 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","parentRef","_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":"+aAmBgB,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,2FC/BImB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXT,SAAU,gICPN,SAQOlB,GAAA,IAAA4B,EAAA5B,EAPXO,EAAAA,aAAI,EAOOqB,EAAAC,EAAA7B,EANXM,EAAAA,aAAI,EAMOuB,EALXC,IAAAA,UACAnB,IAAAA,UACAR,IAAAA,SACAO,IAAAA,SACGqB,EACQC,EAAA,QAAAhC,EAAAiC,GAETlB,OAAAA,MAAA,IAAAmB,EAAA,QAAAA,UAAA,CACEb,IAAKX,EACLC,UAAWwB,EAAAA,QAAG,aAAcxB,GAC5BmB,UAAWA,GAA0BxB,aAAAA,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AAOC,QAAQpD,GAAQiD,EAAAC,EAAAG,OAAAJ,IAAA,CAA7C,IAAAK,EAAAC,EAAA,QAAAL,EAAAD,GAAA,GAEHhB,EAAUe,QAAQhD,MAFfsD,EAAA,IAAAA,EAAA,MAIJ,CAACrB,EAAWjC,IAEf,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"}
@@ -3,13 +3,13 @@ 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
5
  export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
6
- elementRef: RefObject<E>;
6
+ parentRef: RefObject<E>;
7
7
  style?: CSSProperties;
8
8
  align?: Align;
9
9
  scale?: number;
10
10
  options?: Partial<UseParentSizeOptions>;
11
11
  } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
12
12
  export declare const DefaultStyle: CSSProperties;
13
- export declare function ParentsizeSVG<E extends HTMLElement>({ elementRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
13
+ export declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
14
14
  export {};
15
15
  //# sourceMappingURL=ParentsizeSVG.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA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AAE,MAAM,gCAAgC,CAAC;AAGzE,aAAK,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE/B,oBAAY,kBAAkB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACpE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,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,SAAS,EACT,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"}
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 t from"@babel/runtime/helpers/esm/objectSpread2";import i from"@babel/runtime/helpers/esm/objectWithoutProperties";import{useEffect as n}from"react";import{useParentSize as o}from"@cutting/use-get-parent-size";import s from"classnames";function a(r){var t=r.width,i=r.children,n=r.origin,o=void 0===n?{x:0,y:0}:n,s=r.preserveAspectRatio,a=void 0===s?"xMaxYMid meet":s,c=r.innerRef,l=r.className,f=Math.ceil(t/(t/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:a,viewBox:"".concat(o.x," ").concat(o.y," ").concat(t," ").concat(f),ref:c,children:i})})}!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=["debounceDelay"],l=["elementRef","children","style","scale","align","options"],f={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function v(s){var v=s.elementRef,d=s.children,m=s.style,p=void 0===m?f: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=i(g,c),w=i(s,l),j=o(v,t({debounceDelay:N},R)),D=j.width,O=j.height;n((function(){if(v.current)for(var e=0,t=Object.entries(p);e<t.length;e++){var i=r(t[e],2);v.current.style[i[0]]=i[1]}}),[v,p]);var A="center"===y?"translate(".concat(D/2,",").concat(O/2-20,") scale(").concat(u,")"):"translate(0,0) scale(".concat(u,")");return e(a,t(t({width:D,height:O},w),{},{children:e("g",{transform:A,children:d})}))}var d=["y","x","transform","className","children","innerRef"];function m(r){var n=r.y,o=void 0===n?0:n,a=r.x,c=void 0===a?0:a,l=r.transform,f=r.className,v=r.children,m=r.innerRef,p=i(r,d);return e("g",t(t({ref:m,className:s("visx-group",f),transform:l||"translate(".concat(c,", ").concat(o,")")},p),{},{children:v}))}var p=["from","to","fill","className","innerRef"];function h(r){var n=r.from,o=void 0===n?{x:0,y:0}:n,a=r.to,c=void 0===a?{x:1,y:1}:a,l=r.fill,f=void 0===l?"transparent":l,v=r.className,d=r.innerRef,m=i(r,p),h=o.x===c.x||o.y===c.y;return e("line",t({ref:d,className:s("visx-line",v),x1:o.x,y1:o.y,x2:c.x,y2:c.y,fill:f,shapeRendering:h?"crispEdges":"auto"},m))}export{m as Group,h as Line,v as ParentsizeSVG,a as ResponsiveSVG};
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,s=r.innerRef,l=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:l,preserveAspectRatio:c,viewBox:"".concat(o.x," ").concat(o.y," ").concat(i," ").concat(f),ref:s,children:t})})}var s=["debounceDelay"],l=["parentRef","children","style","scale","align","options"],f={display:"flex",flexDirection:"column",flexGrow:1,flexShrink:1,flexBasis:"0%",overflow:"hidden"};function d(a){var d=a.parentRef,m=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,s),N=t(a,l),j=o(d,i({debounceDelay:R},w)),D=j.width,A=j.height;n((function(){if(d.current)for(var e=0,i=Object.entries(h);e<i.length;e++){var t=r(i[e],2);d.current.style[t[0]]=t[1]}}),[d,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:m})}))}var m=["y","x","transform","className","children","innerRef"];function v(r){var n=r.y,o=void 0===n?0:n,c=r.x,s=void 0===c?0:c,l=r.transform,f=r.className,d=r.children,v=r.innerRef,h=t(r,m);return e("g",i(i({ref:v,className:a("visx-group",f),transform:l||"translate(".concat(s,", ").concat(o,")")},h),{},{children:d}))}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,s=void 0===c?{x:1,y:1}:c,l=r.fill,f=void 0===l?"transparent":l,d=r.className,m=r.innerRef,v=t(r,h),p=o.x===s.x||o.y===s.y;return e("line",i({ref:m,className:a("visx-line",d),x1:o.x,y1:o.y,x2:s.x,y2:s.y,fill:f,shapeRendering:p?"crispEdges":"auto"},v))}export{v as Group,p as Line,d as ParentsizeSVG,c as ResponsiveSVG};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } 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,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,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B,KAMEjB,OAAAA,EAAChB,OAAcG,MAAOA,EAAOD,OAAQA,GAAYyC,OAAIvC,SACnDY,EAAG,IAAA,CAAAwC,UAAWA,WAAYpD,qECvC1B,SAAUqD,EAQHxD,GAAA,IAAAyD,EAAAzD,EAPXO,EAAAA,aAAI,EAOOkD,EAAAC,EAAA1D,EANXM,EAAAA,aAAI,EAMOoD,EALXH,IAAAA,UACA5C,IAAAA,UACAR,IAAAA,SACAO,IAAAA,SACGiD,EACQnB,EAAAxC,EAAAyC,GAET1B,OAAAA,EAAA,IAAA8B,EAAAA,EAAA,CACExB,IAAKX,EACLC,UAAWiD,EAAG,aAAcjD,GAC5B4C,UAAWA,GAA0BjD,aAAAA,OAAAA,eAAMC,EAAvB,MAChBoD,GAJN,GAAA,CAIexD,SAEZA,gECnBS0D,EAOyB7D,GAAA,IAAA8D,EAAA9D,EANvC+D,KAAAA,OAAO,IAAAD,EAAA,CAAExD,EAAG,EAAGC,EAAG,GAMqBuD,EAAAE,EAAAhE,EALvCiE,GAAAA,OAAK,IAAAD,EAAA,CAAE1D,EAAG,EAAGC,EAAG,GAKuByD,EAAAE,EAAAlE,EAJvCmE,KAAAA,aAAO,cAIgCD,EAHvCvD,IAAAA,UACAD,IAAAA,SACGiD,EACoCnB,EAAAxC,EAAAyC,GACjC2B,EAAgBL,EAAKzD,IAAM2D,EAAG3D,GAAKyD,EAAKxD,IAAM0D,EAAG1D,EAGrDQ,OAAAA,EACE,OAAA8B,EAAA,CAAAxB,IAAKX,EACLC,UAAWiD,EAAG,YAAajD,GAC3B0D,GAAIN,EAAKzD,EACTgE,GAAIP,EAAKxD,EACTgE,GAAIN,EAAG3D,EACPkE,GAAIP,EAAG1D,EACP4D,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CT"}
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 parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, 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","parentRef","_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,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,EAAA,MAAA,CAAA,gBACgB,wBACdC,MAAO,CACLC,SAAU,WACVC,SAAU,UACVjB,OAAQ,OACTE,SAEDY,SACEC,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,2FC/BImB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,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IAAKX,EACLC,UAAWiD,EAAG,aAAcjD,GAC5B4C,UAAWA,GAA0BjD,aAAAA,OAAAA,eAAMC,EAAvB,MAChBoD,GAJN,GAAA,CAIexD,SAEZA,gECnBS0D,EAOyB7D,GAAA,IAAA8D,EAAA9D,EANvC+D,KAAAA,OAAO,IAAAD,EAAA,CAAExD,EAAG,EAAGC,EAAG,GAMqBuD,EAAAE,EAAAhE,EALvCiE,GAAAA,OAAK,IAAAD,EAAA,CAAE1D,EAAG,EAAGC,EAAG,GAKuByD,EAAAE,EAAAlE,EAJvCmE,KAAAA,aAAO,cAIgCD,EAHvCvD,IAAAA,UACAD,IAAAA,SACGiD,EACoCnB,EAAAxC,EAAAyC,GACjC2B,EAAgBL,EAAKzD,IAAM2D,EAAG3D,GAAKyD,EAAKxD,IAAM0D,EAAG1D,EAGrDQ,OAAAA,EACE,OAAA8B,EAAA,CAAAxB,IAAKX,EACLC,UAAWiD,EAAG,YAAajD,GAC3B0D,GAAIN,EAAKzD,EACTgE,GAAIP,EAAKxD,EACTgE,GAAIN,EAAG3D,EACPkE,GAAIP,EAAG1D,EACP4D,KAAMA,EACNM,eAAgBL,EAAgB,aAAe,QAC3CT"}
@@ -3,13 +3,13 @@ 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
5
  export declare type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
6
- elementRef: RefObject<E>;
6
+ parentRef: RefObject<E>;
7
7
  style?: CSSProperties;
8
8
  align?: Align;
9
9
  scale?: number;
10
10
  options?: Partial<UseParentSizeOptions>;
11
11
  } & Partial<Omit<ResponsiveSVGProps, 'innerRef' | 'height' | 'height'>>;
12
12
  export declare const DefaultStyle: CSSProperties;
13
- export declare function ParentsizeSVG<E extends HTMLElement>({ elementRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
13
+ export declare function ParentsizeSVG<E extends HTMLElement>({ parentRef, children, style, scale, align, options: { debounceDelay, ...optionsRest }, ...rest }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null;
14
14
  export {};
15
15
  //# sourceMappingURL=ParentsizeSVG.d.ts.map
@@ -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,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
+ {"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,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,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,SAAS,EACT,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"}
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,a,o){"use strict";function c(e){return e&&e.__esModule?e:{default:e}}var l=c(r),u=c(i),d=c(n),f=c(o);function p(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,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:l,preserveAspectRatio:o,viewBox:"".concat(s.x," ").concat(s.y," ").concat(r," ").concat(u),ref:c,children:i})})}!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=["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,p=d.default(e,m);return t.jsx("g",u.default(u.default({ref:l,className:f.default("visx-group",o),transform:a||"translate(".concat(s,", ").concat(i,")")},p),{},{children:c}))},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,p=d.default(e,b),v=i.x===s.x||i.y===s.y;return t.jsx("line",u.default({ref:l,className:f.default("visx-line",c),x1:i.x,y1:i.y,x2:s.x,y2:s.y,fill:o,shapeRendering:v?"crispEdges":"auto"},p))},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=d.default(y,v),N=d.default(e,h),w=a.useParentSize(r,u.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,")"):"translate(0,0) scale(".concat(f,")");return t.jsx(p,u.default(u.default({width:S,height:q},N),{},{children:t.jsx("g",{transform:P,children:i})}))},e.ResponsiveSVG=p}));
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 p=["debounceDelay"],v=["parentRef","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),p=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:p?"crispEdges":"auto"},h))},e.ParentsizeSVG=function(e){var r=e.parentRef,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,p),w=d.default(e,v),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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } 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,UACV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GAAIP,EAAGjC,EACPyC,GAAIR,EAAGhC,EACPkC,KAAMA,EACNO,eAAgBN,EAAgB,aAAe,QAC3CX,qBFPM,SAQ2B/B,GAPzCiD,IAAAA,IAAAA,WACA9C,IAAAA,SAMyC+C,EAAAlD,EALzCgB,MAAAA,aAAQM,EAKiC4B,EAAAC,EAAAnD,EAJzCoD,MAAAA,aAAQ,EAIiCD,EAAAE,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"}
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 parentRef: 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 parentRef,\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(parentRef, { debounceDelay, ...optionsRest });\n\n useEffect(() => {\n if (!parentRef.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 parentRef.current.style[key as any] = value;\n }\n }, [parentRef, 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","parentRef","_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,2FC/BImB,EAA8B,CACzCC,QAAS,OACTC,cAAe,SACfC,SAAU,EACVC,WAAY,EACZC,UAAW,KACXT,SAAU,0HCP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AEyCC,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,CAAcwB,cAAAA,GAAkBC,IAA/DzD,IAAAA,MAAOD,IAAAA,OAEf8D,EAAAA,WAAU,WACR,GAAKd,EAAUe,QAIf,IAAA,IAAAC,EAAA,EAAAC,EAA2BC,OAAOC,QAAQpD,GAAQiD,EAAAC,EAAAG,OAAAJ,IAAA,CAA7C,IAAAK,EAAAC,EAAA,QAAAL,EAAAD,GAAA,GAEHhB,EAAUe,QAAQhD,MAFfsD,EAAA,IAAAA,EAAA,MAIJ,CAACrB,EAAWjC,IAEf,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.32.0",
3
+ "version": "4.34.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dagda1/cuttingedge.git"
@@ -15,18 +15,18 @@
15
15
  "types": "dist/esm/index.d.ts",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@cutting/use-get-parent-size": "1.6.10",
19
- "@cutting/util": "4.31.0",
18
+ "@cutting/use-get-parent-size": "workspace:*",
19
+ "@cutting/util": "workspace:*",
20
20
  "classnames": "^2.3.1",
21
21
  "resize-observer-polyfill": "^1.5.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/runtime": "7.17.8",
25
- "@cutting/component-library": "5.5.0",
26
- "@cutting/devtools": "4.31.8",
27
- "@cutting/eslint-config": "4.29.0",
28
- "@cutting/tsconfig": "4.26.4",
29
- "@cutting/useful-types": "4.25.9",
25
+ "@cutting/component-library": "workspace:*",
26
+ "@cutting/devtools": "workspace:*",
27
+ "@cutting/eslint-config": "workspace:*",
28
+ "@cutting/tsconfig": "workspace:*",
29
+ "@cutting/useful-types": "workspace:*",
30
30
  "@jest/globals": "27.5.1",
31
31
  "@testing-library/jest-dom": "5.16.2",
32
32
  "@testing-library/react": "^12.1.4",
@@ -42,6 +42,14 @@
42
42
  "react": ">= 17.x.x",
43
43
  "react-dom": ">= 17.x.x"
44
44
  },
45
+ "scripts": {
46
+ "build": "NODE_ENV=production cutting rollup",
47
+ "lint": "eslint ./src/**/*.{ts,tsx} --fix",
48
+ "start": "PORT=8888 NODE_ENV=development cutting devserver-start",
49
+ "test": "NODE_ENV=test cutting test",
50
+ "test:ci": "CI=true pnpm test",
51
+ "prepack": "pnpm build"
52
+ },
45
53
  "volta": {
46
54
  "extends": "../../package.json"
47
55
  },
@@ -56,13 +64,5 @@
56
64
  "dist/esm/index.d.ts"
57
65
  ]
58
66
  }
59
- },
60
- "scripts": {
61
- "build": "NODE_ENV=production cutting rollup",
62
- "lint": "eslint ./src/**/*.{ts,tsx} --fix",
63
- "start": "PORT=8888 NODE_ENV=development cutting devserver-start",
64
- "test": "NODE_ENV=test cutting test",
65
- "test:ci": "CI=true pnpm test"
66
- },
67
- "readme": "# @cutting/svg - reusable svg components for SVG documents\n[![npm version](https://img.shields.io/npm/v/@cutting/svg.svg)](https://www.npmjs.com/package/@cutting/svg)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](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![svg document resizing to scale when using the ParentsizeSVG component](./img/sizer.gif)\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```"
68
- }
67
+ }
68
+ }
@@ -10,7 +10,7 @@ function TestEr(props: Partial<ParentsizeSVGProps>) {
10
10
  useParentSize(ref);
11
11
 
12
12
  return (
13
- <ParentsizeSVG {...props} elementRef={ref}>
13
+ <ParentsizeSVG {...props} parentRef={ref}>
14
14
  <rect x="20%" y="20%" width="200px" height="200px" rx="20" />
15
15
  </ParentsizeSVG>
16
16
  );
@@ -8,7 +8,7 @@ import { ResponsiveSVG } from '../ResponsiveSVG/ResponsiveSVG';
8
8
  type Align = 'none' | 'center';
9
9
 
10
10
  export type ParentsizeSVGProps<E extends HTMLElement = HTMLElement> = {
11
- elementRef: RefObject<E>;
11
+ parentRef: RefObject<E>;
12
12
  style?: CSSProperties;
13
13
  align?: Align;
14
14
  scale?: number;
@@ -25,7 +25,7 @@ export const DefaultStyle: CSSProperties = {
25
25
  } as const;
26
26
 
27
27
  export function ParentsizeSVG<E extends HTMLElement>({
28
- elementRef,
28
+ parentRef,
29
29
  children,
30
30
  style = DefaultStyle,
31
31
  scale = 1,
@@ -33,18 +33,18 @@ export function ParentsizeSVG<E extends HTMLElement>({
33
33
  options: { debounceDelay = 50, ...optionsRest } = {},
34
34
  ...rest
35
35
  }: PropsWithChildren<ParentsizeSVGProps<E>>): JSX.Element | null {
36
- const { width, height } = useParentSize(elementRef, { debounceDelay, ...optionsRest });
36
+ const { width, height } = useParentSize(parentRef, { debounceDelay, ...optionsRest });
37
37
 
38
38
  useEffect(() => {
39
- if (!elementRef.current) {
39
+ if (!parentRef.current) {
40
40
  return;
41
41
  }
42
42
 
43
43
  for (const [key, value] of Object.entries(style)) {
44
44
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- elementRef.current.style[key as any] = value;
45
+ parentRef.current.style[key as any] = value;
46
46
  }
47
- }, [elementRef, style]);
47
+ }, [parentRef, style]);
48
48
 
49
49
  const transform =
50
50
  align === 'center'