@cutting/svg 4.35.0 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +12 -0
- package/{cutting-svg-4.35.0.tgz → cutting-svg-4.36.0.tgz} +0 -0
- package/dist/cjs/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/cjs/svg.cjs.development.js +0 -6
- 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/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/umd/components/ParentsizeSVG/ParentsizeSVG.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ParentsizeSVG/ParentsizeSVG.tsx +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@cutting/svg:build: cache hit, replaying output
|
|
1
|
+
@cutting/svg:build: cache hit, replaying output 0f69babcfbe6036c
|
|
2
2
|
@cutting/svg:build:
|
|
3
|
-
@cutting/svg:build: > @cutting/svg@4.
|
|
3
|
+
@cutting/svg:build: > @cutting/svg@4.36.0 build /home/runner/work/cuttingedge/cuttingedge/packages/svg
|
|
4
4
|
@cutting/svg:build: > NODE_ENV=production devtools rollup
|
|
5
5
|
@cutting/svg:build:
|
|
6
6
|
@cutting/svg:build: DEBUG using tsconfig.dist.json
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @cutting/svg
|
|
2
2
|
|
|
3
|
+
## 4.36.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 11095849: component-library fixes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [11095849]
|
|
12
|
+
- @cutting/use-get-parent-size@1.10.0
|
|
13
|
+
- @cutting/util@4.33.0
|
|
14
|
+
|
|
3
15
|
## 4.35.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
Binary file
|
|
@@ -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,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,
|
|
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"}
|
|
@@ -100,12 +100,6 @@ function ParentsizeSVG(_ref) {
|
|
|
100
100
|
}
|
|
101
101
|
}, [parentRef, style]);
|
|
102
102
|
var transform = align === 'center' ? "translate(".concat(width / 2, ",").concat(height / 2 - 20, ") scale(").concat(scale, ")") : "translate(0,0) scale(".concat(scale, ")");
|
|
103
|
-
console.dir({
|
|
104
|
-
transform: transform,
|
|
105
|
-
width: width,
|
|
106
|
-
height: height,
|
|
107
|
-
scale: scale
|
|
108
|
-
});
|
|
109
103
|
return jsxRuntime.jsx(ResponsiveSVG, _objectSpread__default["default"](_objectSpread__default["default"]({
|
|
110
104
|
width: width,
|
|
111
105
|
height: height
|
|
@@ -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 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 console.dir({ transform, width, height, scale });\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","console","dir","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,KAA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X,GAKkC,GAAA,OAAA;AAAA,MAAA,SAAA,GAAA,IAAA,CAJvCgD,IAIuC;AAAA,MAJvCA,IAIuC,0BAJhC,aAIgC,GAAA,SAAA;AAAA,MAHvC7C,SAGuC,QAHvCA,SAGuC;AAAA,MAFvCD,QAEuC,QAFvCA,QAEuC;AAAA,MADpCyC,SACoC,GAAAhB,4CAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;;AACvC,EAAA,IAAMsB,aAAa,GAAGH,IAAI,CAAC/C,CAAL,KAAWgD,EAAE,CAAChD,CAAd,IAAmB+C,IAAI,CAAC9C,CAAL,KAAW+C,EAAE,CAAC/C,CAAvD,CAAA;AAEA,EACEQ,OAAAA,cACE,CAAA,MAAA,EAAAuB,iCAAA,CAAA;AAAAlB,IAAAA,GAAG,EAAEX,QAAL;AACAC,IAAAA,SAAS,EAAEyC,sBAAE,CAAC,WAAD,EAAczC,SAAd,CADb;AAEA+C,IAAAA,EAAE,EAAEJ,IAAI,CAAC/C,CAFT;AAGAoD,IAAAA,EAAE,EAAEL,IAAI,CAAC9C,CAHT;AAIAoD,IAAAA,EAAE,EAAEL,EAAE,CAAChD,CAJP;AAKAsD,IAAAA,EAAE,EAAEN,EAAE,CAAC/C,CALP;AAMAgD,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,IAAAA,Q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B,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"),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
|
|
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 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
|
|
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,IA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,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/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 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
|
|
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
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/components/ResponsiveSVG/ResponsiveSVG.tsx","../../src/components/ParentsizeSVG/ParentsizeSVG.tsx","../../src/components/Group/Group.tsx","../../src/components/Line/Line.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { PreserveAspectRatio } 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
|
|
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,SA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AAChB,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParentsizeSVG.d.ts","sourceRoot":"","sources":["../../../../src/components/ParentsizeSVG/ParentsizeSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,K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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,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
|
|
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
|
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 { 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
|
|
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,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51
51
|
? `translate(${width / 2},${height / 2 - 20}) scale(${scale})`
|
|
52
52
|
: `translate(0,0) scale(${scale})`;
|
|
53
53
|
|
|
54
|
-
console.dir({ transform, width, height, scale });
|
|
55
54
|
return (
|
|
56
55
|
<ResponsiveSVG width={width} height={height} {...rest}>
|
|
57
56
|
<g transform={transform}>{children}</g>
|