@pingux/astro 2.37.1-alpha.2 → 2.37.1-alpha.4
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/lib/cjs/components/Checkbox/CheckboxBase.js +2 -1
- package/lib/cjs/components/NumberField/NumberField.js +5 -1
- package/lib/cjs/components/NumberField/NumberField.test.js +25 -0
- package/lib/components/Checkbox/CheckboxBase.js +2 -1
- package/lib/components/NumberField/NumberField.js +5 -1
- package/lib/components/NumberField/NumberField.test.js +25 -0
- package/package.json +1 -1
@@ -12,6 +12,7 @@ exports["default"] = void 0;
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
14
14
|
var _visuallyHidden = require("@react-aria/visually-hidden");
|
15
|
+
var _lodash = require("lodash");
|
15
16
|
var _themeUi = require("theme-ui");
|
16
17
|
var _Box = _interopRequireDefault(require("../Box"));
|
17
18
|
var _react2 = require("@emotion/react");
|
@@ -37,7 +38,7 @@ var IndeterminateCheckboxIcon = function IndeterminateCheckboxIcon(props) {
|
|
37
38
|
fill: "none",
|
38
39
|
xmlns: "http://www.w3.org/2000/svg",
|
39
40
|
"aria-labelledby": "checkbox-icon-title"
|
40
|
-
}, props), (0, _react2.jsx)("title", {
|
41
|
+
}, (0, _lodash.omit)(props, 'id', 'aria-checked')), (0, _react2.jsx)("title", {
|
41
42
|
id: "checkbox-icon-title"
|
42
43
|
}, "Indeterminate Checkbox Icon"), (0, _react2.jsx)("rect", {
|
43
44
|
x: "3.5",
|
@@ -106,6 +106,10 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
106
106
|
var helperTextId = (0, _uuid.v4)();
|
107
107
|
var updatedLabelProps = _objectSpread({}, (0, _reactAria.mergeProps)(fieldLabelProps, labelProps));
|
108
108
|
var inputPropsValue = inputProps.value || 0;
|
109
|
+
|
110
|
+
// extract numeric value in case input value use units like '4 inches' or 'USD 45.00'
|
111
|
+
// aria-valuenow accept only number value type
|
112
|
+
var inputPropsNumericValue = typeof inputPropsValue === 'string' ? inputPropsValue.match(/[-]{0,1}[\d]*[.]{0,1}[\d]+/g)[0] : inputPropsValue;
|
109
113
|
return (0, _react2.jsx)(_.Box, fieldContainerProps, (0, _react2.jsx)(_.Label, updatedLabelProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
110
114
|
variant: "forms.numberField.noDefaultArrows"
|
111
115
|
}, groupProps), (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
|
@@ -113,7 +117,7 @@ var NumberField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
113
117
|
}, fieldControlWrapperProps, {
|
114
118
|
role: "spinbutton",
|
115
119
|
"aria-valuetext": inputPropsValue,
|
116
|
-
"aria-valuenow":
|
120
|
+
"aria-valuenow": inputPropsNumericValue,
|
117
121
|
"aria-labelledby": updatedLabelProps.id
|
118
122
|
}), (0, _react2.jsx)(_.Input, (0, _extends2["default"])({
|
119
123
|
variant: "forms.input.numberField",
|
@@ -151,4 +151,29 @@ test('passing helper text should display it and correct aria attributes on input
|
|
151
151
|
expect(helper).toHaveClass("is-".concat(_statuses["default"].ERROR));
|
152
152
|
var helperTextID = helper.getAttribute('id');
|
153
153
|
expect(_testWrapper.screen.getByRole('textbox')).toHaveAttribute('aria-describedby', helperTextID);
|
154
|
+
});
|
155
|
+
test('should extract numeric value from unit format and pass it to aria-valuenow', function () {
|
156
|
+
var numericValue = 45;
|
157
|
+
getComponent({
|
158
|
+
defaultValue: numericValue,
|
159
|
+
formatOptions: {
|
160
|
+
style: 'unit',
|
161
|
+
unit: 'kilogram',
|
162
|
+
unitDisplay: 'long'
|
163
|
+
}
|
164
|
+
});
|
165
|
+
expect(_testWrapper.screen.getByRole('spinbutton')).toHaveAttribute('aria-valuenow', String(numericValue));
|
166
|
+
});
|
167
|
+
test('should extract numeric value from currency format and pass it to aria-valuenow', function () {
|
168
|
+
var numericValue = 45;
|
169
|
+
getComponent({
|
170
|
+
defaultValue: numericValue,
|
171
|
+
formatOptions: {
|
172
|
+
style: 'currency',
|
173
|
+
currency: 'EUR',
|
174
|
+
currencyDisplay: 'code',
|
175
|
+
currencySign: 'accounting'
|
176
|
+
}
|
177
|
+
});
|
178
|
+
expect(_testWrapper.screen.getByRole('spinbutton')).toHaveAttribute('aria-valuenow', String(numericValue.toFixed(2)));
|
154
179
|
});
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
4
|
+
import { omit } from 'lodash';
|
4
5
|
import { Checkbox as ThemeUICheckbox } from 'theme-ui';
|
5
6
|
import Box from '../Box';
|
6
7
|
|
@@ -26,7 +27,7 @@ var IndeterminateCheckboxIcon = function IndeterminateCheckboxIcon(props) {
|
|
26
27
|
fill: "none",
|
27
28
|
xmlns: "http://www.w3.org/2000/svg",
|
28
29
|
"aria-labelledby": "checkbox-icon-title"
|
29
|
-
}, props), ___EmotionJSX("title", {
|
30
|
+
}, omit(props, 'id', 'aria-checked')), ___EmotionJSX("title", {
|
30
31
|
id: "checkbox-icon-title"
|
31
32
|
}, "Indeterminate Checkbox Icon"), ___EmotionJSX("rect", {
|
32
33
|
x: "3.5",
|
@@ -95,6 +95,10 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
95
95
|
var helperTextId = uuid();
|
96
96
|
var updatedLabelProps = _objectSpread({}, mergeProps(fieldLabelProps, labelProps));
|
97
97
|
var inputPropsValue = inputProps.value || 0;
|
98
|
+
|
99
|
+
// extract numeric value in case input value use units like '4 inches' or 'USD 45.00'
|
100
|
+
// aria-valuenow accept only number value type
|
101
|
+
var inputPropsNumericValue = typeof inputPropsValue === 'string' ? inputPropsValue.match(/[-]{0,1}[\d]*[.]{0,1}[\d]+/g)[0] : inputPropsValue;
|
98
102
|
return ___EmotionJSX(Box, fieldContainerProps, ___EmotionJSX(Label, updatedLabelProps), ___EmotionJSX(Box, _extends({
|
99
103
|
variant: "forms.numberField.noDefaultArrows"
|
100
104
|
}, groupProps), ___EmotionJSX(Box, _extends({
|
@@ -102,7 +106,7 @@ var NumberField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
102
106
|
}, fieldControlWrapperProps, {
|
103
107
|
role: "spinbutton",
|
104
108
|
"aria-valuetext": inputPropsValue,
|
105
|
-
"aria-valuenow":
|
109
|
+
"aria-valuenow": inputPropsNumericValue,
|
106
110
|
"aria-labelledby": updatedLabelProps.id
|
107
111
|
}), ___EmotionJSX(Input, _extends({
|
108
112
|
variant: "forms.input.numberField",
|
@@ -148,4 +148,29 @@ test('passing helper text should display it and correct aria attributes on input
|
|
148
148
|
expect(helper).toHaveClass("is-".concat(statuses.ERROR));
|
149
149
|
var helperTextID = helper.getAttribute('id');
|
150
150
|
expect(screen.getByRole('textbox')).toHaveAttribute('aria-describedby', helperTextID);
|
151
|
+
});
|
152
|
+
test('should extract numeric value from unit format and pass it to aria-valuenow', function () {
|
153
|
+
var numericValue = 45;
|
154
|
+
getComponent({
|
155
|
+
defaultValue: numericValue,
|
156
|
+
formatOptions: {
|
157
|
+
style: 'unit',
|
158
|
+
unit: 'kilogram',
|
159
|
+
unitDisplay: 'long'
|
160
|
+
}
|
161
|
+
});
|
162
|
+
expect(screen.getByRole('spinbutton')).toHaveAttribute('aria-valuenow', String(numericValue));
|
163
|
+
});
|
164
|
+
test('should extract numeric value from currency format and pass it to aria-valuenow', function () {
|
165
|
+
var numericValue = 45;
|
166
|
+
getComponent({
|
167
|
+
defaultValue: numericValue,
|
168
|
+
formatOptions: {
|
169
|
+
style: 'currency',
|
170
|
+
currency: 'EUR',
|
171
|
+
currencyDisplay: 'code',
|
172
|
+
currencySign: 'accounting'
|
173
|
+
}
|
174
|
+
});
|
175
|
+
expect(screen.getByRole('spinbutton')).toHaveAttribute('aria-valuenow', String(numericValue.toFixed(2)));
|
151
176
|
});
|