From 661c57bf2429651b9d7eac7da68435c3bc7025af Mon Sep 17 00:00:00 2001 From: Kavitha Date: Mon, 29 Jan 2024 10:58:07 -0500 Subject: [PATCH 1/5] pass newBaseProps in events.ts --- .../victory-core/src/victory-util/events.ts | 16 ++++----- stories/victory-area.stories.tsx | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/packages/victory-core/src/victory-util/events.ts b/packages/victory-core/src/victory-util/events.ts index 434ff8e95..0f7fab2f8 100644 --- a/packages/victory-core/src/victory-util/events.ts +++ b/packages/victory-core/src/victory-util/events.ts @@ -165,13 +165,13 @@ export function getScopedEvents( return "parent"; } if (eventReturn.eventKey === "all") { - return baseProps[childName] - ? without(keys(baseProps[childName]), "parent") - : without(keys(baseProps), "parent"); + return newBaseProps[childName] + ? without(keys(newBaseProps[childName]), "parent") + : without(keys(newBaseProps), "parent"); } else if (eventReturn.eventKey === undefined && eventKey === "parent") { - return baseProps[childName] - ? keys(baseProps[childName]) - : keys(baseProps); + return newBaseProps[childName] + ? keys(newBaseProps[childName]) + : keys(newBaseProps); } return eventReturn.eventKey !== undefined ? eventReturn.eventKey @@ -195,7 +195,7 @@ export function getScopedEvents( ); const mutatedProps = eventReturn.mutation( assign({}, mutationTargetProps, mutationTargetState), - baseProps, + newBaseProps, ); const childState = baseState[childName] || {}; @@ -238,7 +238,7 @@ export function getScopedEvents( // returns an entire mutated state for all children const allChildNames = - childNames === "all" ? without(keys(baseProps), "parent") : childNames; + childNames === "all" ? without(keys(newBaseProps), "parent") : childNames; return Array.isArray(allChildNames) ? allChildNames.reduce((memo, childName) => { return assign(memo, getReturnByChild(childName)); diff --git a/stories/victory-area.stories.tsx b/stories/victory-area.stories.tsx index 82804b0ec..4d5f5bd87 100644 --- a/stories/victory-area.stories.tsx +++ b/stories/victory-area.stories.tsx @@ -516,3 +516,37 @@ export const DisableInlineStyles = () => { ); }; + +export const events = () => { + return ( +
+

Click Me

+ + { + return [ + { + eventKey: "all", + target: "data", + mutation: (props) => { + const fill = props.style && props.style.fill; + console.log(fill) + return fill === "black" ? null : { style: { fill: "black" } }; + } + } + ]; + } + } + }]} + data={getData(5)} + /> + +
+ ); +}; \ No newline at end of file From 7e23ab15f35360c2902d5005300a6ced42504313 Mon Sep 17 00:00:00 2001 From: Kavitha Date: Mon, 29 Jan 2024 10:59:08 -0500 Subject: [PATCH 2/5] remove console.log --- stories/victory-area.stories.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/stories/victory-area.stories.tsx b/stories/victory-area.stories.tsx index 4d5f5bd87..100521137 100644 --- a/stories/victory-area.stories.tsx +++ b/stories/victory-area.stories.tsx @@ -536,7 +536,6 @@ export const events = () => { target: "data", mutation: (props) => { const fill = props.style && props.style.fill; - console.log(fill) return fill === "black" ? null : { style: { fill: "black" } }; } } From c7264ad52a9a70b8845f3db265a053689758fc7e Mon Sep 17 00:00:00 2001 From: Kavitha Date: Mon, 29 Jan 2024 11:06:15 -0500 Subject: [PATCH 3/5] fix format --- stories/victory-area.stories.tsx | 42 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/stories/victory-area.stories.tsx b/stories/victory-area.stories.tsx index 100521137..be35284da 100644 --- a/stories/victory-area.stories.tsx +++ b/stories/victory-area.stories.tsx @@ -524,28 +524,32 @@ export const events = () => { { - return [ - { - eventKey: "all", - target: "data", - mutation: (props) => { - const fill = props.style && props.style.fill; - return fill === "black" ? null : { style: { fill: "black" } }; - } - } - ]; - } - } - }]} + events={[ + { + target: "data", + eventHandlers: { + onClick: () => { + return [ + { + eventKey: "all", + target: "data", + mutation: (props) => { + const fill = props.style && props.style.fill; + return fill === "black" + ? null + : { style: { fill: "black" } }; + }, + }, + ]; + }, + }, + }, + ]} data={getData(5)} /> ); -}; \ No newline at end of file +}; From 254cb6be4b9d5d9ec7cf3a3ffd7122b9b8608415 Mon Sep 17 00:00:00 2001 From: Kavitha Date: Mon, 29 Jan 2024 11:09:54 -0500 Subject: [PATCH 4/5] add victory line events story --- stories/victory-line.stories.tsx | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/stories/victory-line.stories.tsx b/stories/victory-line.stories.tsx index bc3b8a2e0..d0a092748 100644 --- a/stories/victory-line.stories.tsx +++ b/stories/victory-line.stories.tsx @@ -508,3 +508,36 @@ export const DisableInlineStyles = () => { ); }; + +export const Events = () => { + return ( + + { + return [ + { + target: "data", + eventKey: "all", + mutation: ({ style }) => { + return style.stroke === "black" + ? null + : { style: { stroke: "black", strokeWidth: 5 } }; + }, + }, + ]; + }, + }, + }, + ]} + data={getData(5, "seed-1")} + /> + + ); +}; From e9b68147f004ac19c794f1d4780d0f0710d2bff2 Mon Sep 17 00:00:00 2001 From: Kavitha Date: Mon, 29 Jan 2024 11:28:13 -0500 Subject: [PATCH 5/5] fix typo --- stories/victory-area.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stories/victory-area.stories.tsx b/stories/victory-area.stories.tsx index be35284da..30c0c7529 100644 --- a/stories/victory-area.stories.tsx +++ b/stories/victory-area.stories.tsx @@ -517,7 +517,7 @@ export const DisableInlineStyles = () => { ); }; -export const events = () => { +export const Events = () => { return (

Click Me