Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/social-use-proper-char-limits
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjuhasz committed Jan 30, 2025
2 parents 51270fa + 6d324b4 commit 3138faf
Show file tree
Hide file tree
Showing 120 changed files with 2,541 additions and 1,000 deletions.
3 changes: 3 additions & 0 deletions .phan/config.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ function make_phan_config( $dir, $options = array() ) {
case 'full-site-editing':
$stubs[] = "$root/.phan/stubs/full-site-editing-stubs.php";
break;
case 'gutenberg':
$stubs[] = "$root/.phan/stubs/gutenberg-stubs.php";
break;
case 'photon-opencv':
$stubs[] = "$root/.phan/stubs/photon-opencv-stubs.php";
break;
Expand Down
40 changes: 40 additions & 0 deletions .phan/stubs/gutenberg-stubs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Stubs automatically generated from Gutenberg 20.1.0
* using the definition file `tools/stubs/gutenberg-stub-defs.php` in the Jetpack monorepo.
*
* Do not edit this directly! Run tools/stubs/update-stubs.sh to regenerate it.
*/

/**
* Retrieves the root plugin path.
*
* @since 0.1.0
*
* @return string Root path to the gutenberg plugin.
*/
function gutenberg_dir_path()
{
}
/**
* Registers a script according to `wp_register_script`. Honors this request by
* reassigning internal dependency properties of any script handle already
* registered by that name. It does not deregister the original script, to
* avoid losing inline scripts which may have been attached.
*
* @since 4.1.0
*
* @param WP_Scripts $scripts WP_Scripts instance.
* @param string $handle Name of the script. Should be unique.
* @param string $src Full URL of the script, or path of the script relative to the WordPress root directory.
* @param array $deps Optional. An array of registered script handles this script depends on. Default empty array.
* @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL
* as a query string for cache busting purposes. If version is set to false, a version
* number is automatically added equal to current installed WordPress version.
* If set to null, no version is added.
* @param bool $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
* Default 'false'.
*/
function gutenberg_override_script($scripts, $handle, $src, $deps = array(), $ver = \false, $in_footer = \false)
{
}
12 changes: 11 additions & 1 deletion .phan/stubs/wpcom-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* `bin/teamcity-builds/jetpack-stubs/stub-defs.php` and regenerate the stubs
* by triggering the Jetpack Staging → Update WPCOM Stubs job in TeamCity.
*
* Stubs automatically generated from WordPress.com commit 25fe8874f126229252809211e216317f571c666f.
* Stubs automatically generated from WordPress.com commit 58daa278d1c6807cf18400dee1d9f45815e24fae.
*/

namespace {
Expand Down Expand Up @@ -1524,6 +1524,16 @@ function get_blog_subscriptions_aggregate_count(int $blog_id = null, $post_term_
{
}
}
namespace WPCOM\Experiments\Internal {
/**
* @param string $name
* @return \WPCOM\Experiments\Models\Experiment|null
* @throws File_Cache_Failure
*/
function get_cached_experiment_by_name(string $name): ?\WPCOM\Experiments\Models\Experiment
{
}
}
namespace WPCOM\Jetpack_AI {
class Feature_Control
{
Expand Down
47 changes: 37 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Charts: adds tests and fixes to bar chart component
35 changes: 26 additions & 9 deletions projects/js-packages/charts/src/components/bar-chart/bar-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const BarChart: FC< BarChartProps > = ( {
) => {
const coords = localPoint( event );
if ( ! coords ) return;

showTooltip( {
tooltipData: { value, xLabel, yLabel, seriesIndex },
tooltipLeft: coords.x,
Expand All @@ -58,12 +57,25 @@ const BarChart: FC< BarChartProps > = ( {
[ showTooltip ]
);

const handleMouseLeave = useCallback( () => {
hideTooltip();
}, [ hideTooltip ] );

// Check for empty data
if ( ! data?.length ) {
return <div className={ clsx( 'bar-chart-empty', styles[ 'bat-chart-empty' ] ) }>Empty...</div>;
return <div className={ clsx( styles[ 'bar-chart-empty' ] ) }>No data available</div>;
}

// Add date validation to hasInvalidData check
const hasInvalidData = data.some( series =>
series.data.some(
d =>
d.value === null ||
d.value === undefined ||
isNaN( d.value ) ||
! d.label ||
( d.date && isNaN( d.date.getTime() ) ) // Add date validation
)
);

if ( hasInvalidData ) {
return <div className={ clsx( styles[ 'bar-chart-error' ] ) }>Invalid data</div>;
}

const margins = margin;
Expand Down Expand Up @@ -102,7 +114,12 @@ const BarChart: FC< BarChartProps > = ( {
} ) );

return (
<div className={ clsx( 'bar-chart', className, styles[ 'bar-chart' ] ) }>
<div
className={ clsx( 'bar-chart', styles[ 'bar-chart' ], className ) }
data-testid="bar-chart"
role="img"
aria-label="bar chart"
>
<svg width={ width } height={ height }>
<Group left={ margins.left } top={ margins.top }>
<GridControl
Expand Down Expand Up @@ -133,7 +150,7 @@ const BarChart: FC< BarChartProps > = ( {
height={ yMax - ( yScale( d.value ) ?? 0 ) }
fill={ theme.colors[ seriesIndex % theme.colors.length ] }
onMouseMove={ withTooltips ? handleBarMouseMove : undefined }
onMouseLeave={ withTooltips ? handleMouseLeave : undefined }
onMouseLeave={ withTooltips ? hideTooltip : undefined }
/>
);
} ) }
Expand All @@ -159,7 +176,7 @@ const BarChart: FC< BarChartProps > = ( {
<Legend
items={ legendItems }
orientation={ legendOrientation }
className={ styles[ 'bar-chart-legend' ] }
className={ styles[ 'bar-chart__legend' ] }
/>
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,43 @@ export const FixedDimensions: Story = {
},
},
};

export const ErrorStates: StoryObj< typeof BarChart > = {
render: () => (
<div style={ { display: 'grid', gap: '20px' } }>
<div>
<h3>Empty Data</h3>
<div style={ { width: '400px', height: '300px' } }>
<BarChart data={ [] } />
</div>
</div>

<div>
<h3>Invalid Data</h3>
<div style={ { width: '400px', height: '300px' } }>
<BarChart
data={ [
{
label: 'Invalid Series',
data: [
{ date: new Date( 'invalid' ), value: 10, label: 'Invalid Date' },
{ date: new Date( '2024-01-02' ), value: null, label: 'Null Value' },
],
options: {},
},
] }
/>
</div>
</div>
</div>
),
};

ErrorStates.parameters = {
docs: {
description: {
story:
'Examples of how the bar chart handles various error states including empty data and invalid data.',
},
},
};
Loading

0 comments on commit 3138faf

Please sign in to comment.