@automattic/jetpack-components 0.72.6 → 0.73.1
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 +13 -0
- package/build/components/boost-score-graph/uplot-line-chart.js +2 -2
- package/build/components/pricing-card/index.js +1 -1
- package/build/components/product-price/price.js +1 -1
- package/build/components/record-meter-bar/index.js +2 -2
- package/build/components/stat-card/index.js +3 -6
- package/build/index.d.ts +0 -1
- package/build/index.js +0 -1
- package/components/boost-score-graph/uplot-line-chart.tsx +2 -2
- package/components/pricing-card/index.tsx +2 -2
- package/components/product-price/price.tsx +1 -1
- package/components/record-meter-bar/index.tsx +2 -2
- package/components/stat-card/index.tsx +3 -6
- package/index.ts +0 -1
- package/package.json +4 -3
- package/build/components/number-format/index.d.ts +0 -9
- package/build/components/number-format/index.js +0 -13
- package/components/number-format/README.md +0 -25
- package/components/number-format/index.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Components package releases.
|
|
4
4
|
|
|
5
|
+
## [0.73.1] - 2025-05-19
|
|
6
|
+
### Changed
|
|
7
|
+
- Update dependencies.
|
|
8
|
+
|
|
9
|
+
## [0.73.0] - 2025-05-12
|
|
10
|
+
### Changed
|
|
11
|
+
- Use `formatCurrency()` and `getCurrencyObject()` functions from the `@automattic/number-formatters` package. [#42796]
|
|
12
|
+
|
|
13
|
+
### Removed
|
|
14
|
+
- Remove the `numberFormat()` function. This is a breaking change; use the `@automattic/number-formatters` package instead. [#42864]
|
|
15
|
+
|
|
5
16
|
## [0.72.6] - 2025-05-05
|
|
6
17
|
### Changed
|
|
7
18
|
- Update package dependencies. [#43320] [#43326]
|
|
@@ -1385,6 +1396,8 @@
|
|
|
1385
1396
|
### Changed
|
|
1386
1397
|
- Update node version requirement to 14.16.1
|
|
1387
1398
|
|
|
1399
|
+
[0.73.1]: https://github.com/Automattic/jetpack-components/compare/0.73.0...0.73.1
|
|
1400
|
+
[0.73.0]: https://github.com/Automattic/jetpack-components/compare/0.72.6...0.73.0
|
|
1388
1401
|
[0.72.6]: https://github.com/Automattic/jetpack-components/compare/0.72.5...0.72.6
|
|
1389
1402
|
[0.72.5]: https://github.com/Automattic/jetpack-components/compare/0.72.4...0.72.5
|
|
1390
1403
|
[0.72.4]: https://github.com/Automattic/jetpack-components/compare/0.72.3...0.72.4
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatNumber } from '@automattic/number-formatters';
|
|
2
3
|
import { __ } from '@wordpress/i18n';
|
|
3
4
|
import { useMemo, useRef, useCallback } from 'react';
|
|
4
5
|
import uPlot from 'uplot';
|
|
5
6
|
import UplotReact from 'uplot-react';
|
|
6
7
|
import { getUserLocale } from "../../lib/locale/index.js";
|
|
7
|
-
import numberFormat from "../number-format/index.js";
|
|
8
8
|
import { annotationsPlugin } from "./annotations-plugin.js";
|
|
9
9
|
import { dayHighlightPlugin } from "./day-highlight-plugin.js";
|
|
10
10
|
import getDateFormat from "./get-date-format.js";
|
|
@@ -45,7 +45,7 @@ function createSerieInfo(label, score) {
|
|
|
45
45
|
if (!rawValue) {
|
|
46
46
|
return '-';
|
|
47
47
|
}
|
|
48
|
-
return
|
|
48
|
+
return formatNumber(rawValue);
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { getCurrencyObject } from '@automattic/
|
|
2
|
+
import { getCurrencyObject } from '@automattic/number-formatters';
|
|
3
3
|
import { Button } from '@wordpress/components';
|
|
4
4
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
5
5
|
import { LoadingPlaceholder } from '@automattic/jetpack-components';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getCurrencyObject } from '@automattic/
|
|
2
|
+
import { getCurrencyObject } from '@automattic/number-formatters';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import Text from "../text/index.js";
|
|
5
5
|
import styles from './style.module.scss';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { formatNumber } from '@automattic/number-formatters';
|
|
2
3
|
import { __ } from '@wordpress/i18n';
|
|
3
4
|
import clsx from 'clsx';
|
|
4
5
|
import { useMemo } from 'react';
|
|
5
|
-
import numberFormat from "../number-format/index.js";
|
|
6
6
|
import './style.scss';
|
|
7
7
|
/**
|
|
8
8
|
* Generate Record Meter bar
|
|
@@ -31,7 +31,7 @@ const RecordMeterBar = ({ totalCount, items = [], showLegendLabelBeforeCount = f
|
|
|
31
31
|
const widthPercent = ((count / total) * 100).toPrecision(2);
|
|
32
32
|
return (_jsx("div", { style: { backgroundColor, flexBasis: `${widthPercent}%` } }, label));
|
|
33
33
|
}) }), _jsxs("div", { className: "record-meter-bar__legend", "aria-hidden": "true", children: [legendTitle && _jsx("div", { className: "record-meter-bar__legend--title", children: legendTitle }), _jsx("ul", { className: "record-meter-bar__legend--items", children: itemsToRender.map(({ count, label, backgroundColor }) => {
|
|
34
|
-
const formattedCount =
|
|
34
|
+
const formattedCount = formatNumber(count);
|
|
35
35
|
return (_jsxs("li", { className: "record-meter-bar__legend--item", children: [_jsx("div", { className: "record-meter-bar__legend--item-circle", style: { backgroundColor } }), !showLegendLabelBeforeCount && (_jsxs("span", { children: [_jsx("span", { className: "record-meter-bar__legend--item-count", children: formattedCount }), _jsx("span", { className: "record-meter-bar__legend--item-label", children: label })] })), showLegendLabelBeforeCount && (_jsxs("span", { children: [_jsx("span", { className: "record-meter-bar__legend--item-label record-meter-bar__legend--item-label-first", children: label }), _jsxs("span", { className: "record-meter-bar__legend--item-count", children: ["(", formattedCount, ")"] })] }))] }, label));
|
|
36
36
|
}) })] }), _jsxs("table", { className: "screen-reader-text", children: [_jsx("caption", { children: tableCaption || __('Summary of the records', 'jetpack-components') }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("th", { scope: "col", children: recordTypeLabel || __('Record type', 'jetpack-components') }), _jsx("th", { scope: "col", children: recordCountLabel || __('Record count', 'jetpack-components') })] }), itemsToRender.map(({ label, count }) => {
|
|
37
37
|
return (_jsxs("tr", { children: [_jsx("td", { children: label }), _jsx("td", { children: count })] }, label));
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
|
+
import { formatNumber, formatNumberCompact } from '@automattic/number-formatters';
|
|
5
6
|
import { Tooltip } from '@wordpress/components';
|
|
6
7
|
import clsx from 'clsx';
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
|
-
import numberFormat from "../number-format/index.js";
|
|
11
11
|
import Text from "../text/index.js";
|
|
12
12
|
import styles from './style.module.scss';
|
|
13
13
|
/**
|
|
@@ -17,11 +17,8 @@ import styles from './style.module.scss';
|
|
|
17
17
|
* @return {React.ReactNode} - StatCard react component.
|
|
18
18
|
*/
|
|
19
19
|
const StatCard = ({ className, hideValue, icon, label, value, variant = 'square', }) => {
|
|
20
|
-
const formattedValue =
|
|
21
|
-
const compactValue =
|
|
22
|
-
notation: 'compact',
|
|
23
|
-
compactDisplay: 'short',
|
|
24
|
-
});
|
|
20
|
+
const formattedValue = formatNumber(value);
|
|
21
|
+
const compactValue = formatNumberCompact(value);
|
|
25
22
|
return (_jsxs("div", { className: clsx(className, styles.wrapper, styles[variant]), children: [_jsx("div", { className: clsx(styles.icon), children: icon }), _jsxs("div", { className: clsx(styles.info), children: [_jsx(Text, { className: styles.label, children: label }), variant === 'square' ? (_jsx(Tooltip, { text: formattedValue, placement: "top", children: _jsx(Text, { variant: "headline-small", className: clsx(styles.value), children: hideValue ? '-' : compactValue }) })) : (_jsx(Text, { variant: "title-medium-semi-bold", className: clsx(styles.value), children: hideValue ? '-' : formattedValue }))] })] }));
|
|
26
23
|
};
|
|
27
24
|
export default StatCard;
|
package/build/index.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ export { default as ThemeProvider } from './components/theme-provider/index.tsx'
|
|
|
31
31
|
export { default as Text, H2, H3, Title } from './components/text/index.tsx';
|
|
32
32
|
export { default as ToggleControl } from './components/toggle-control/index.tsx';
|
|
33
33
|
export { default as NumberControl } from './components/number-control/index.jsx';
|
|
34
|
-
export { default as numberFormat } from './components/number-format/index.ts';
|
|
35
34
|
export { default as QRCode } from './components/qr-code/index.tsx';
|
|
36
35
|
export { default as Button } from './components/button/index.tsx';
|
|
37
36
|
export type { ButtonProps } from './components/button/types.ts';
|
package/build/index.js
CHANGED
|
@@ -46,7 +46,6 @@ export { default as ThemeProvider } from "./components/theme-provider/index.js";
|
|
|
46
46
|
export { default as Text, H2, H3, Title } from "./components/text/index.js";
|
|
47
47
|
export { default as ToggleControl } from "./components/toggle-control/index.js";
|
|
48
48
|
export { default as NumberControl } from './components/number-control/index.jsx';
|
|
49
|
-
export { default as numberFormat } from "./components/number-format/index.js";
|
|
50
49
|
export { default as QRCode } from "./components/qr-code/index.js";
|
|
51
50
|
export { default as Button } from "./components/button/index.js";
|
|
52
51
|
export { default as LoadingPlaceholder } from "./components/loading-placeholder/index.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { formatNumber } from '@automattic/number-formatters';
|
|
1
2
|
import { __ } from '@wordpress/i18n';
|
|
2
3
|
import React, { useMemo, useRef, useCallback } from 'react';
|
|
3
4
|
import uPlot from 'uplot';
|
|
4
5
|
import UplotReact from 'uplot-react';
|
|
5
6
|
import { getUserLocale } from '../../lib/locale/index.ts';
|
|
6
|
-
import numberFormat from '../number-format/index.ts';
|
|
7
7
|
import { annotationsPlugin } from './annotations-plugin.ts';
|
|
8
8
|
import { dayHighlightPlugin } from './day-highlight-plugin.ts';
|
|
9
9
|
import getDateFormat from './get-date-format.ts';
|
|
@@ -68,7 +68,7 @@ function createSerieInfo( label: string, score ) {
|
|
|
68
68
|
return '-';
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
return
|
|
71
|
+
return formatNumber( rawValue );
|
|
72
72
|
},
|
|
73
73
|
};
|
|
74
74
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getCurrencyObject } from '@automattic/
|
|
1
|
+
import { getCurrencyObject } from '@automattic/number-formatters';
|
|
2
2
|
import { Button } from '@wordpress/components';
|
|
3
3
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
4
4
|
import { LoadingPlaceholder } from '@automattic/jetpack-components';
|
|
5
5
|
import TermsOfService from '../terms-of-service/index.tsx';
|
|
6
6
|
import type { PricingCardProps } from './types.ts';
|
|
7
|
-
import type { CurrencyObject } from '@automattic/
|
|
7
|
+
import type { CurrencyObject } from '@automattic/number-formatters';
|
|
8
8
|
import type React from 'react';
|
|
9
9
|
|
|
10
10
|
import './style.scss';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { formatNumber } from '@automattic/number-formatters';
|
|
1
2
|
import { __ } from '@wordpress/i18n';
|
|
2
3
|
import clsx from 'clsx';
|
|
3
4
|
import React, { useMemo } from 'react';
|
|
4
|
-
import numberFormat from '../number-format/index.ts';
|
|
5
5
|
|
|
6
6
|
import './style.scss';
|
|
7
7
|
|
|
@@ -110,7 +110,7 @@ const RecordMeterBar: React.FC< RecordMeterBarProps > = ( {
|
|
|
110
110
|
{ legendTitle && <div className="record-meter-bar__legend--title">{ legendTitle }</div> }
|
|
111
111
|
<ul className="record-meter-bar__legend--items">
|
|
112
112
|
{ itemsToRender.map( ( { count, label, backgroundColor } ) => {
|
|
113
|
-
const formattedCount =
|
|
113
|
+
const formattedCount = formatNumber( count );
|
|
114
114
|
return (
|
|
115
115
|
<li key={ label } className="record-meter-bar__legend--item">
|
|
116
116
|
<div
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { formatNumber, formatNumberCompact } from '@automattic/number-formatters';
|
|
4
5
|
import { Tooltip } from '@wordpress/components';
|
|
5
6
|
import clsx from 'clsx';
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
9
|
-
import numberFormat from '../number-format/index.ts';
|
|
10
10
|
import Text from '../text/index.tsx';
|
|
11
11
|
import styles from './style.module.scss';
|
|
12
12
|
import { StatCardProps } from './types.ts';
|
|
@@ -26,11 +26,8 @@ const StatCard = ( {
|
|
|
26
26
|
value,
|
|
27
27
|
variant = 'square',
|
|
28
28
|
}: StatCardProps ) => {
|
|
29
|
-
const formattedValue =
|
|
30
|
-
const compactValue =
|
|
31
|
-
notation: 'compact',
|
|
32
|
-
compactDisplay: 'short',
|
|
33
|
-
} );
|
|
29
|
+
const formattedValue = formatNumber( value );
|
|
30
|
+
const compactValue = formatNumberCompact( value );
|
|
34
31
|
|
|
35
32
|
return (
|
|
36
33
|
<div className={ clsx( className, styles.wrapper, styles[ variant ] ) }>
|
package/index.ts
CHANGED
|
@@ -47,7 +47,6 @@ export { default as ThemeProvider } from './components/theme-provider/index.tsx'
|
|
|
47
47
|
export { default as Text, H2, H3, Title } from './components/text/index.tsx';
|
|
48
48
|
export { default as ToggleControl } from './components/toggle-control/index.tsx';
|
|
49
49
|
export { default as NumberControl } from './components/number-control/index.jsx';
|
|
50
|
-
export { default as numberFormat } from './components/number-format/index.ts';
|
|
51
50
|
export { default as QRCode } from './components/qr-code/index.tsx';
|
|
52
51
|
export { default as Button } from './components/button/index.tsx';
|
|
53
52
|
export type { ButtonProps } from './components/button/types.ts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.73.1",
|
|
4
4
|
"description": "Jetpack Components Package",
|
|
5
5
|
"author": "Automattic",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@automattic/jetpack-boost-score-api": "^0.1.64",
|
|
19
19
|
"@automattic/jetpack-api": "^0.20.2",
|
|
20
20
|
"@automattic/jetpack-script-data": "^0.4.1",
|
|
21
|
+
"@automattic/number-formatters": "^1.0.2",
|
|
21
22
|
"@babel/runtime": "^7",
|
|
22
23
|
"@wordpress/browserslist-config": "6.22.0",
|
|
23
24
|
"@wordpress/components": "29.8.0",
|
|
@@ -32,12 +33,12 @@
|
|
|
32
33
|
"prop-types": "^15.7.2",
|
|
33
34
|
"qrcode.react": "4.2.0",
|
|
34
35
|
"react-slider": "2.0.5",
|
|
35
|
-
"social-logos": "^3.
|
|
36
|
+
"social-logos": "^3.2.0",
|
|
36
37
|
"uplot": "1.6.31",
|
|
37
38
|
"uplot-react": "1.1.4"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@automattic/jetpack-base-styles": "^0.7.
|
|
41
|
+
"@automattic/jetpack-base-styles": "^0.7.4",
|
|
41
42
|
"@babel/core": "7.26.10",
|
|
42
43
|
"@babel/preset-react": "7.26.3",
|
|
43
44
|
"@jest/globals": "29.7.0",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a number using the locale in use by the user viewing the page.
|
|
3
|
-
*
|
|
4
|
-
* @param {number} number - The number to format.
|
|
5
|
-
* @param {Intl.NumberFormatOptions} options - The format options
|
|
6
|
-
* @return {string} Formatted number.
|
|
7
|
-
*/
|
|
8
|
-
declare const numberFormat: (number: number, options?: Intl.NumberFormatOptions) => string;
|
|
9
|
-
export default numberFormat;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getUserLocale } from "../../lib/locale/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Format a number using the locale in use by the user viewing the page.
|
|
4
|
-
*
|
|
5
|
-
* @param {number} number - The number to format.
|
|
6
|
-
* @param {Intl.NumberFormatOptions} options - The format options
|
|
7
|
-
* @return {string} Formatted number.
|
|
8
|
-
*/
|
|
9
|
-
const numberFormat = (number, options = {}) => {
|
|
10
|
-
const locale = getUserLocale();
|
|
11
|
-
return new Intl.NumberFormat(locale, options).format(number);
|
|
12
|
-
};
|
|
13
|
-
export default numberFormat;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
numberFormat
|
|
2
|
-
=========
|
|
3
|
-
|
|
4
|
-
This utility function can be used to format numbers so they are displayed in the format expected for a specific locale.
|
|
5
|
-
|
|
6
|
-
For example, a large number such as `123456` would be displayed as `123,456` in US English, and as `123 456` in FR French.
|
|
7
|
-
|
|
8
|
-
The function relies on `Intl.NumberFormat` to format the numbers, based on the locale information available in WordPress, or based on the browser locale as a fallback.
|
|
9
|
-
|
|
10
|
-
## General Usage:
|
|
11
|
-
|
|
12
|
-
```js
|
|
13
|
-
import { numberFormat } from '@automattic/jetpack-components';
|
|
14
|
-
|
|
15
|
-
render() {
|
|
16
|
-
const number = '123456';
|
|
17
|
-
const options = {
|
|
18
|
-
notation: 'compact',
|
|
19
|
-
compactDisplay: 'short',
|
|
20
|
-
};
|
|
21
|
-
return (
|
|
22
|
-
<>{ numberFormat( number ) }</> // 123K
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getUserLocale } from '../../lib/locale/index.ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Format a number using the locale in use by the user viewing the page.
|
|
5
|
-
*
|
|
6
|
-
* @param {number} number - The number to format.
|
|
7
|
-
* @param {Intl.NumberFormatOptions} options - The format options
|
|
8
|
-
* @return {string} Formatted number.
|
|
9
|
-
*/
|
|
10
|
-
const numberFormat = ( number: number, options: Intl.NumberFormatOptions = {} ): string => {
|
|
11
|
-
const locale = getUserLocale();
|
|
12
|
-
|
|
13
|
-
return new Intl.NumberFormat( locale, options ).format( number );
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default numberFormat;
|