@automattic/jetpack-components 0.45.6 → 0.45.8
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 +10 -0
- package/components/record-meter-bar/index.tsx +31 -4
- package/components/theme-provider/index.tsx +1 -1
- package/components/theme-provider/types.ts +1 -1
- package/components/toggle-control/index.tsx +6 -0
- package/components/toggle-control/styles.module.scss +18 -7
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Components package releases.
|
|
4
4
|
|
|
5
|
+
## [0.45.8] - 2023-12-19
|
|
6
|
+
### Changed
|
|
7
|
+
- Updated package dependencies. [#34694, #34696]
|
|
8
|
+
|
|
9
|
+
## [0.45.7] - 2023-12-13
|
|
10
|
+
### Added
|
|
11
|
+
- Added `className` prop to RecordMeterBar component [#34182]
|
|
12
|
+
|
|
5
13
|
## [0.45.6] - 2023-12-11
|
|
6
14
|
### Fixed
|
|
7
15
|
- Fixed resizing of the performance history graph. [#34185]
|
|
@@ -898,6 +906,8 @@
|
|
|
898
906
|
### Changed
|
|
899
907
|
- Update node version requirement to 14.16.1
|
|
900
908
|
|
|
909
|
+
[0.45.8]: https://github.com/Automattic/jetpack-components/compare/0.45.7...0.45.8
|
|
910
|
+
[0.45.7]: https://github.com/Automattic/jetpack-components/compare/0.45.6...0.45.7
|
|
901
911
|
[0.45.6]: https://github.com/Automattic/jetpack-components/compare/0.45.5...0.45.6
|
|
902
912
|
[0.45.5]: https://github.com/Automattic/jetpack-components/compare/0.45.4...0.45.5
|
|
903
913
|
[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=
|
|
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>;
|
|
@@ -22,6 +22,9 @@ interface ToggleControlProps {
|
|
|
22
22
|
/** The label for the toggle. */
|
|
23
23
|
label?: React.ReactNode;
|
|
24
24
|
|
|
25
|
+
/** The size of the toggle. */
|
|
26
|
+
size?: 'small' | 'normal';
|
|
27
|
+
|
|
25
28
|
/** A callback function invoked when the toggle is clicked. */
|
|
26
29
|
onChange: ( value: boolean ) => void;
|
|
27
30
|
}
|
|
@@ -33,6 +36,7 @@ const ToggleControl: React.FC< ToggleControlProps > = ( {
|
|
|
33
36
|
help,
|
|
34
37
|
toggling,
|
|
35
38
|
label,
|
|
39
|
+
size = 'normal',
|
|
36
40
|
onChange,
|
|
37
41
|
} ) => {
|
|
38
42
|
const showChecked =
|
|
@@ -55,6 +59,8 @@ const ToggleControl: React.FC< ToggleControlProps > = ( {
|
|
|
55
59
|
checked={ showChecked }
|
|
56
60
|
className={ classNames( styles.toggle, className, {
|
|
57
61
|
[ styles[ 'is-toggling' ] ]: toggling,
|
|
62
|
+
[ styles[ 'is-small' ] ]: size === 'small',
|
|
63
|
+
[ styles[ 'no-label' ] ]: ! label,
|
|
58
64
|
} ) }
|
|
59
65
|
disabled={ disabled }
|
|
60
66
|
help={ help }
|
|
@@ -3,30 +3,41 @@
|
|
|
3
3
|
/// Overrides the @wordpress/components ToggleControl component.
|
|
4
4
|
/// @link https://github.com/WordPress/gutenberg/tree/trunk/packages/components/src/form-toggle
|
|
5
5
|
.toggle {
|
|
6
|
+
--base-width: 8px;
|
|
7
|
+
|
|
8
|
+
&.is-small {
|
|
9
|
+
--base-width: 6px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.no-label :global(.components-toggle-control__label) {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
:global {
|
|
7
17
|
.components-form-toggle {
|
|
8
18
|
--wp-admin-theme-color: var( --jp-green-40 );
|
|
9
19
|
|
|
20
|
+
|
|
10
21
|
&__input:focus + .components-form-toggle__track {
|
|
11
22
|
box-shadow: 0 0 0 2px var( --jp-white ), 0 0 0 4px var( --jp-green-50 );
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
.components-form-toggle__track {
|
|
15
|
-
width:
|
|
16
|
-
height:
|
|
26
|
+
width: calc( var(--base-width) * 6 );
|
|
27
|
+
height: calc( var(--base-width) * 3 );
|
|
17
28
|
border-radius: 12px;
|
|
18
29
|
border-width: 2px;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
32
|
.components-form-toggle__thumb {
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
24
|
-
top:
|
|
25
|
-
left:
|
|
33
|
+
width: calc(var(--base-width) * 2);
|
|
34
|
+
height: calc(var(--base-width) * 2);
|
|
35
|
+
top: calc(var(--base-width) / 2);
|
|
36
|
+
left: calc(var(--base-width) / 2);
|
|
26
37
|
}
|
|
27
38
|
|
|
28
39
|
&.is-checked .components-form-toggle__thumb {
|
|
29
|
-
transform: translateX(
|
|
40
|
+
transform: translateX( calc( var(--base-width) * 3 ) );
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-components",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.8",
|
|
4
4
|
"description": "Jetpack Components Package",
|
|
5
5
|
"author": "Automattic",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@babel/core": "7.23.5",
|
|
39
39
|
"@babel/preset-react": "7.23.3",
|
|
40
40
|
"@jest/globals": "29.4.3",
|
|
41
|
-
"@storybook/addon-actions": "7.
|
|
42
|
-
"@storybook/blocks": "7.
|
|
43
|
-
"@storybook/react": "7.
|
|
44
|
-
"@testing-library/dom": "
|
|
45
|
-
"@testing-library/react": "
|
|
41
|
+
"@storybook/addon-actions": "7.6.5",
|
|
42
|
+
"@storybook/blocks": "7.6.5",
|
|
43
|
+
"@storybook/react": "7.6.5",
|
|
44
|
+
"@testing-library/dom": "9.3.3",
|
|
45
|
+
"@testing-library/react": "14.1.2",
|
|
46
46
|
"@testing-library/user-event": "14.5.1",
|
|
47
47
|
"@types/jest": "29.5.10",
|
|
48
48
|
"@types/qrcode.react": "1.0.4",
|