react-d3-utils
Advanced tools
Comparing version 0.4.0 to 0.5.0
# Changelog | ||
## [0.5.0](https://www.github.com/zakodium/react-d3-utils/compare/v0.4.0...v0.5.0) (2022-01-31) | ||
### Features | ||
* add style prop to AlignGroup ([#21](https://www.github.com/zakodium/react-d3-utils/issues/21)) ([553369e](https://www.github.com/zakodium/react-d3-utils/commit/553369ee205011d320452f8d74656a90a1769a2c)) | ||
## [0.4.0](https://www.github.com/zakodium/react-d3-utils/compare/v0.3.0...v0.4.0) (2022-01-24) | ||
@@ -4,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { ReactNode } from 'react'; | ||
import { ReactNode, CSSProperties } from 'react'; | ||
export declare type Align = 'start' | 'middle' | 'end' | 'none'; | ||
@@ -6,2 +6,3 @@ export interface AlignGroupProps { | ||
y?: number; | ||
style?: CSSProperties; | ||
verticalAlign?: Align; | ||
@@ -8,0 +9,0 @@ horizontalAlign?: Align; |
@@ -24,8 +24,8 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
export function AlignGroup(props) { | ||
const { x = 0, y = 0, verticalAlign = 'start', horizontalAlign = 'start', children, } = props; | ||
const { x = 0, y = 0, verticalAlign = 'start', horizontalAlign = 'start', children, style = {}, } = props; | ||
const observed = useBBoxObserver(); | ||
const xPosition = useMemo(() => calculatePosition(x - observed.x, horizontalAlign, observed.width || 0, x), [x, observed.x, observed.width, horizontalAlign]); | ||
const yPosition = useMemo(() => calculatePosition(y - observed.y, verticalAlign, observed.height || 0, y), [y, observed.y, observed.height, verticalAlign]); | ||
return (_jsx("g", { ref: observed.ref, transform: `translate(${xPosition}, ${yPosition})`, children: children }, void 0)); | ||
return (_jsx("g", { style: style, ref: observed.ref, transform: `translate(${xPosition}, ${yPosition})`, children: children }, void 0)); | ||
} | ||
//# sourceMappingURL=AlignGroup.js.map |
@@ -27,8 +27,8 @@ "use strict"; | ||
function AlignGroup(props) { | ||
const { x = 0, y = 0, verticalAlign = 'start', horizontalAlign = 'start', children, } = props; | ||
const { x = 0, y = 0, verticalAlign = 'start', horizontalAlign = 'start', children, style = {}, } = props; | ||
const observed = (0, useBBoxObserver_1.useBBoxObserver)(); | ||
const xPosition = (0, react_1.useMemo)(() => calculatePosition(x - observed.x, horizontalAlign, observed.width || 0, x), [x, observed.x, observed.width, horizontalAlign]); | ||
const yPosition = (0, react_1.useMemo)(() => calculatePosition(y - observed.y, verticalAlign, observed.height || 0, y), [y, observed.y, observed.height, verticalAlign]); | ||
return ((0, jsx_runtime_1.jsx)("g", { ref: observed.ref, transform: `translate(${xPosition}, ${yPosition})`, children: children }, void 0)); | ||
return ((0, jsx_runtime_1.jsx)("g", { style: style, ref: observed.ref, transform: `translate(${xPosition}, ${yPosition})`, children: children }, void 0)); | ||
} | ||
exports.AlignGroup = AlignGroup; |
{ | ||
"name": "react-d3-utils", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Low-level utilities to build charts with React and D3", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
42741
630