@automattic/jetpack-components 0.45.6 → 0.45.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Components package releases.
4
4
 
5
+ ## [0.45.7] - 2023-12-13
6
+ ### Added
7
+ - Added `className` prop to RecordMeterBar component [#34182]
8
+
5
9
  ## [0.45.6] - 2023-12-11
6
10
  ### Fixed
7
11
  - Fixed resizing of the performance history graph. [#34185]
@@ -898,6 +902,7 @@
898
902
  ### Changed
899
903
  - Update node version requirement to 14.16.1
900
904
 
905
+ [0.45.7]: https://github.com/Automattic/jetpack-components/compare/0.45.6...0.45.7
901
906
  [0.45.6]: https://github.com/Automattic/jetpack-components/compare/0.45.5...0.45.6
902
907
  [0.45.5]: https://github.com/Automattic/jetpack-components/compare/0.45.4...0.45.5
903
908
  [0.45.4]: https://github.com/Automattic/jetpack-components/compare/0.45.3...0.45.4
@@ -1,4 +1,5 @@
1
1
  import { __ } from '@wordpress/i18n';
2
+ import classNames from 'classnames';
2
3
  import React, { useMemo } from 'react';
3
4
  import numberFormat from '../number-format';
4
5
 
@@ -36,6 +37,26 @@ export type RecordMeterBarProps = {
36
37
  * The sort style for legend item. If not provided, it defaults to no sorting.
37
38
  */
38
39
  sortByCount?: 'ascending' | 'descending';
40
+ /**
41
+ * Additional class name to be added to the component
42
+ */
43
+ className?: string;
44
+ /**
45
+ * Table caption
46
+ */
47
+ tableCaption?: string;
48
+ /**
49
+ * Title/label for the legend
50
+ */
51
+ legendTitle?: string;
52
+ /**
53
+ * Recorc type label for screen readers
54
+ */
55
+ recordTypeLabel?: string;
56
+ /**
57
+ * Record count label for screen readers
58
+ */
59
+ recordCountLabel?: string;
39
60
  };
40
61
 
41
62
  /**
@@ -49,6 +70,11 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
49
70
  items = [],
50
71
  showLegendLabelBeforeCount = false,
51
72
  sortByCount,
73
+ className,
74
+ tableCaption,
75
+ legendTitle,
76
+ recordTypeLabel,
77
+ recordCountLabel,
52
78
  } ) => {
53
79
  const total = useMemo( () => {
54
80
  // If total count is not given, then compute it from items' count
@@ -71,7 +97,7 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
71
97
  }, [ items, sortByCount ] );
72
98
 
73
99
  return (
74
- <div className="record-meter-bar">
100
+ <div className={ classNames( 'record-meter-bar', className ) }>
75
101
  <div className="record-meter-bar__items" aria-hidden="true">
76
102
  { itemsToRender.map( ( { count, label, backgroundColor } ) => {
77
103
  const widthPercent = ( ( count / total ) * 100 ).toPrecision( 2 );
@@ -81,6 +107,7 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
81
107
  } ) }
82
108
  </div>
83
109
  <div className="record-meter-bar__legend" aria-hidden="true">
110
+ { legendTitle && <div className="record-meter-bar__legend--title">{ legendTitle }</div> }
84
111
  <ul className="record-meter-bar__legend--items">
85
112
  { itemsToRender.map( ( { count, label, backgroundColor } ) => {
86
113
  const formattedCount = numberFormat( count );
@@ -112,11 +139,11 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
112
139
  </ul>
113
140
  </div>
114
141
  <table className="screen-reader-text">
115
- <caption>{ __( 'Summary of the records', 'jetpack' ) }</caption>
142
+ <caption>{ tableCaption || __( 'Summary of the records', 'jetpack' ) }</caption>
116
143
  <tbody>
117
144
  <tr>
118
- <th scope="col">{ __( 'Record type', 'jetpack' ) }</th>
119
- <th scope="col">{ __( 'Record count', 'jetpack' ) }</th>
145
+ <th scope="col">{ recordTypeLabel || __( 'Record type', 'jetpack' ) }</th>
146
+ <th scope="col">{ recordCountLabel || __( 'Record count', 'jetpack' ) }</th>
120
147
  </tr>
121
148
  { itemsToRender.map( ( { label, count } ) => {
122
149
  return (
@@ -142,7 +142,7 @@ const ThemeProvider: React.FC< ThemeProviderProps > = ( {
142
142
 
143
143
  // Do not wrap when the DOM element target is defined.
144
144
  if ( targetDom ) {
145
- return children;
145
+ return <>{ children }</>;
146
146
  }
147
147
 
148
148
  return <div ref={ themeWrapperRef }>{ children }</div>;
@@ -12,7 +12,7 @@ export type ThemeProviderProps = {
12
12
  /**
13
13
  * Content
14
14
  */
15
- children?: React.ReactElement;
15
+ children?: React.ReactNode;
16
16
  /**
17
17
  * Inser global/reset styles
18
18
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-components",
3
- "version": "0.45.6",
3
+ "version": "0.45.7",
4
4
  "description": "Jetpack Components Package",
5
5
  "author": "Automattic",
6
6
  "license": "GPL-2.0-or-later",