@pingux/astro 2.4.1-alpha.0 → 2.4.1-alpha.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.
@@ -548,6 +548,17 @@ test('dateField should handle autofocus when deleting segments ', function () {
|
|
548
548
|
}
|
549
549
|
expect(hiddenInput).toHaveValue('');
|
550
550
|
});
|
551
|
+
test('should add the correct number of padded 0 to year, month and day', function () {
|
552
|
+
getComponent({
|
553
|
+
defaultValue: '0009-08-02'
|
554
|
+
});
|
555
|
+
expect(_testWrapper.screen.queryByTestId('date-field')).toHaveValue('0009-08-02');
|
556
|
+
_userEvent["default"].click(_testWrapper.screen.queryByRole('button'));
|
557
|
+
var dateButtons = _testWrapper.screen.queryAllByRole('button');
|
558
|
+
expect(dateButtons[5]).toHaveAttribute('aria-label', 'Saturday, August 1, 9');
|
559
|
+
_userEvent["default"].click(dateButtons[5]);
|
560
|
+
expect(_testWrapper.screen.queryByTestId('date-field')).toHaveValue('0009-08-01');
|
561
|
+
});
|
551
562
|
test('should have no accessibility violations', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
552
563
|
var _getComponent, container, results;
|
553
564
|
return _regeneratorRuntime().wrap(function _callee3$(_context10) {
|
@@ -10,6 +10,7 @@ _Object$defineProperty(exports, "__esModule", {
|
|
10
10
|
});
|
11
11
|
exports["default"] = void 0;
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
13
|
+
var _padStart = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/pad-start"));
|
13
14
|
var _react = _interopRequireWildcard(require("react"));
|
14
15
|
var _reactAria = require("react-aria");
|
15
16
|
var _datepicker = require("@react-aria/datepicker");
|
@@ -36,7 +37,7 @@ var DateSegment = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
36
37
|
segmentProps = _useDateSegment.segmentProps;
|
37
38
|
|
38
39
|
/**
|
39
|
-
* Handler to autofocus segments when using
|
40
|
+
* Handler to autofocus segments when using delete key
|
40
41
|
*/
|
41
42
|
var focusManager = (0, _reactAria.useFocusManager)();
|
42
43
|
var handleKeyEvents = (0, _react.useCallback)(function (e) {
|
@@ -49,7 +50,7 @@ var DateSegment = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
49
50
|
variant: "forms.datePicker.segment",
|
50
51
|
onKeyUp: handleKeyEvents,
|
51
52
|
onPaste: handlePaste
|
52
|
-
}), text === '/' ? '-' : text);
|
53
|
+
}), text === '/' ? '-' : (0, _padStart["default"])(text).call(text, segment.type === 'year' ? 4 : 2, 0));
|
53
54
|
});
|
54
55
|
DateSegment.propTypes = {
|
55
56
|
/** slot for input that indicates each date segment */
|
@@ -57,7 +58,8 @@ DateSegment.propTypes = {
|
|
57
58
|
isPlaceholder: _propTypes["default"].bool,
|
58
59
|
text: _propTypes["default"].string,
|
59
60
|
placeholder: _propTypes["default"].string,
|
60
|
-
value: _propTypes["default"].number
|
61
|
+
value: _propTypes["default"].number,
|
62
|
+
type: _propTypes["default"].string
|
61
63
|
}),
|
62
64
|
/** state returned by useDateField */
|
63
65
|
state: _propTypes["default"].shape({}),
|
@@ -541,6 +541,17 @@ test('dateField should handle autofocus when deleting segments ', function () {
|
|
541
541
|
}
|
542
542
|
expect(hiddenInput).toHaveValue('');
|
543
543
|
});
|
544
|
+
test('should add the correct number of padded 0 to year, month and day', function () {
|
545
|
+
getComponent({
|
546
|
+
defaultValue: '0009-08-02'
|
547
|
+
});
|
548
|
+
expect(screen.queryByTestId('date-field')).toHaveValue('0009-08-02');
|
549
|
+
userEvent.click(screen.queryByRole('button'));
|
550
|
+
var dateButtons = screen.queryAllByRole('button');
|
551
|
+
expect(dateButtons[5]).toHaveAttribute('aria-label', 'Saturday, August 1, 9');
|
552
|
+
userEvent.click(dateButtons[5]);
|
553
|
+
expect(screen.queryByTestId('date-field')).toHaveValue('0009-08-01');
|
554
|
+
});
|
544
555
|
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
545
556
|
var _getComponent, container, results;
|
546
557
|
return _regeneratorRuntime().wrap(function _callee3$(_context10) {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
|
+
import _padStartInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/pad-start";
|
2
3
|
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
3
4
|
import { useFocusManager } from 'react-aria';
|
4
5
|
import { useDateSegment } from '@react-aria/datepicker';
|
@@ -24,7 +25,7 @@ var DateSegment = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
24
25
|
segmentProps = _useDateSegment.segmentProps;
|
25
26
|
|
26
27
|
/**
|
27
|
-
* Handler to autofocus segments when using
|
28
|
+
* Handler to autofocus segments when using delete key
|
28
29
|
*/
|
29
30
|
var focusManager = useFocusManager();
|
30
31
|
var handleKeyEvents = useCallback(function (e) {
|
@@ -37,7 +38,7 @@ var DateSegment = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
37
38
|
variant: "forms.datePicker.segment",
|
38
39
|
onKeyUp: handleKeyEvents,
|
39
40
|
onPaste: handlePaste
|
40
|
-
}), text === '/' ? '-' : text);
|
41
|
+
}), text === '/' ? '-' : _padStartInstanceProperty(text).call(text, segment.type === 'year' ? 4 : 2, 0));
|
41
42
|
});
|
42
43
|
DateSegment.propTypes = {
|
43
44
|
/** slot for input that indicates each date segment */
|
@@ -45,7 +46,8 @@ DateSegment.propTypes = {
|
|
45
46
|
isPlaceholder: PropTypes.bool,
|
46
47
|
text: PropTypes.string,
|
47
48
|
placeholder: PropTypes.string,
|
48
|
-
value: PropTypes.number
|
49
|
+
value: PropTypes.number,
|
50
|
+
type: PropTypes.string
|
49
51
|
}),
|
50
52
|
/** state returned by useDateField */
|
51
53
|
state: PropTypes.shape({}),
|