@pingux/astro 2.210.4-alpha.0 → 2.210.5

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.
@@ -32,6 +32,7 @@ function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymb
32
32
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
33
33
  var displayName = 'Button';
34
34
  var Button = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
35
+ var _sx;
35
36
  var children = props.children,
36
37
  className = props.className,
37
38
  _props$isDisabled = props.isDisabled,
@@ -107,13 +108,15 @@ var Button = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
107
108
  "aria-label": ariaLabel,
108
109
  className: classNames,
109
110
  role: "button",
110
- sx: isLoading ? {
111
+ variant: variant
112
+ }, (0, _pendoID.getPendoID)(displayName), others, {
113
+ sx: _objectSpread(_objectSpread({}, isLoading ? {
111
114
  display: 'flex',
112
115
  justifyContent: 'center',
113
- alignItems: 'center'
114
- } : {},
115
- variant: variant
116
- }, (0, _pendoID.getPendoID)(displayName), others), isLoading ? (0, _react2.jsx)("span", {
116
+ alignItems: 'center',
117
+ position: 'relative'
118
+ } : {}), (_sx = others.sx) !== null && _sx !== void 0 ? _sx : {})
119
+ }), isLoading ? (0, _react2.jsx)("span", {
117
120
  style: {
118
121
  visibility: 'hidden'
119
122
  }
@@ -144,6 +144,34 @@ test('button loading hides children and shows loader', function () {
144
144
  expect(childWrapper).not.toBeVisible();
145
145
  expect(_testWrapper.screen.getByRole('alert')).toBeInTheDocument();
146
146
  });
147
+ test('button loading with consumer sx still centers loader inside button', function () {
148
+ var textContent = "I'ma button";
149
+ getComponent({
150
+ isLoading: true,
151
+ children: textContent,
152
+ sx: {
153
+ backgroundColor: 'red'
154
+ }
155
+ });
156
+
157
+ // Loader (role="alert") is still rendered — consumer sx did not clobber the loading structure.
158
+ var loader = _testWrapper.screen.getByRole('alert');
159
+ expect(loader).toBeInTheDocument();
160
+
161
+ // Hidden children wrapper is still rendered so layout width is preserved.
162
+ var childWrapper = _testWrapper.screen.getByText(textContent);
163
+ expect(childWrapper).toBeInTheDocument();
164
+ expect(childWrapper).not.toBeVisible();
165
+
166
+ // Loading + positioning styles remain applied on top of the consumer's sx.
167
+ var button = _testWrapper.screen.getByRole('button');
168
+ expect(button).toHaveStyle({
169
+ display: 'flex',
170
+ justifyContent: 'center',
171
+ alignItems: 'center',
172
+ position: 'relative'
173
+ });
174
+ });
147
175
  test('button renders children when not loading', function () {
148
176
  var textContent = "I'ma button";
149
177
  getComponent({
@@ -556,4 +556,126 @@ test('does not render default timezones when items prop is provided', /*#__PURE_
556
556
  return _context17.stop();
557
557
  }
558
558
  }, _callee14);
559
+ })));
560
+ test('controlled selectedKey cleared to null clears the input value', function () {
561
+ var selectedKey = 'America/New York GMT-00:00';
562
+ var _getComponent = getComponent({
563
+ selectedKey: selectedKey
564
+ }),
565
+ rerender = _getComponent.rerender;
566
+ var input = _testWrapper.screen.getByRole('combobox');
567
+ expect(input).toHaveValue(selectedKey);
568
+ getComponent({
569
+ selectedKey: null
570
+ }, {
571
+ renderFn: rerender
572
+ });
573
+ expect(input).toHaveValue('');
574
+ });
575
+ test('invalid timezone id in custom items renders without throwing and shows empty time', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
576
+ var customItems, input;
577
+ return _regeneratorRuntime().wrap(function _callee15$(_context18) {
578
+ while (1) switch (_context18.prev = _context18.next) {
579
+ case 0:
580
+ customItems = [{
581
+ key: 'Invalid/Timezone GMT-00:00',
582
+ id: 'Invalid/Timezone',
583
+ label: 'Invalid Timezone',
584
+ timeZone: 'Invalid/Timezone',
585
+ gmt: 'GMT-00:00',
586
+ numericOffset: 0,
587
+ searchTags: 'GMT-00:00 INVALID/TIMEZONE'
588
+ }];
589
+ getComponent({
590
+ items: customItems
591
+ });
592
+ input = _testWrapper.screen.getByRole('combobox');
593
+ _context18.next = 5;
594
+ return _userEvent["default"].type(input, 'Invalid');
595
+ case 5:
596
+ expect(_testWrapper.screen.getByText('Invalid/Timezone')).toBeInTheDocument();
597
+ expect(_testWrapper.screen.getByText('GMT-00:00')).toBeInTheDocument();
598
+ // The catch block (source line 116) sets timeData.get(tz.id) to '' for invalid timezone ids.
599
+ // Time strings produced by toLocaleTimeString with hour12:true (the default) include AM/PM.
600
+ // GMT offsets (e.g. "GMT-00:00") do not, so this regex distinguishes the two.
601
+ expect(_testWrapper.screen.queryByText(/\d{1,2}:\d{2}\s+(AM|PM)/i)).not.toBeInTheDocument();
602
+ case 8:
603
+ case "end":
604
+ return _context18.stop();
605
+ }
606
+ }, _callee15);
607
+ })));
608
+ test('US city name search returns matching US timezone results', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
609
+ var input;
610
+ return _regeneratorRuntime().wrap(function _callee16$(_context19) {
611
+ while (1) switch (_context19.prev = _context19.next) {
612
+ case 0:
613
+ getComponent();
614
+ input = _testWrapper.screen.getByRole('combobox');
615
+ _context19.next = 4;
616
+ return _userEvent["default"].type(input, 'Los Angeles');
617
+ case 4:
618
+ expect(_testWrapper.screen.getByText('America/Los Angeles')).toBeInTheDocument();
619
+ case 5:
620
+ case "end":
621
+ return _context19.stop();
622
+ }
623
+ }, _callee16);
624
+ })));
625
+ test('locales prop is accepted and the component renders without error', function () {
626
+ getComponent({
627
+ locales: 'en-GB'
628
+ });
629
+ expect(_testWrapper.screen.getByRole('combobox')).toBeInTheDocument();
630
+ });
631
+ test('localeOptions prop is accepted and the component renders without error', function () {
632
+ getComponent({
633
+ localeOptions: {
634
+ hour12: false,
635
+ hour: '2-digit',
636
+ minute: '2-digit'
637
+ }
638
+ });
639
+ expect(_testWrapper.screen.getByRole('combobox')).toBeInTheDocument();
640
+ });
641
+ test('pressing ArrowDown opens the dropdown listbox', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
642
+ var input;
643
+ return _regeneratorRuntime().wrap(function _callee17$(_context20) {
644
+ while (1) switch (_context20.prev = _context20.next) {
645
+ case 0:
646
+ getComponent();
647
+ input = _testWrapper.screen.getByRole('combobox');
648
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
649
+ _context20.next = 5;
650
+ return _userEvent["default"].tab();
651
+ case 5:
652
+ _context20.next = 7;
653
+ return _userEvent["default"].type(input, '{arrowdown}', {
654
+ skipClick: true
655
+ });
656
+ case 7:
657
+ expect(_testWrapper.screen.getByRole('listbox')).toBeInTheDocument();
658
+ case 8:
659
+ case "end":
660
+ return _context20.stop();
661
+ }
662
+ }, _callee17);
663
+ })));
664
+ test('clicking the button opens the dropdown listbox', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
665
+ var button;
666
+ return _regeneratorRuntime().wrap(function _callee18$(_context21) {
667
+ while (1) switch (_context21.prev = _context21.next) {
668
+ case 0:
669
+ getComponent();
670
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
671
+ button = _testWrapper.screen.getByRole('button');
672
+ _context21.next = 5;
673
+ return _userEvent["default"].click(button);
674
+ case 5:
675
+ expect(_testWrapper.screen.getByRole('listbox')).toBeInTheDocument();
676
+ case 6:
677
+ case "end":
678
+ return _context21.stop();
679
+ }
680
+ }, _callee18);
559
681
  })));
@@ -22,6 +22,7 @@ import Loader from '../Loader';
22
22
  import { jsx as ___EmotionJSX } from "@emotion/react";
23
23
  var displayName = 'Button';
24
24
  var Button = /*#__PURE__*/forwardRef(function (props, ref) {
25
+ var _sx;
25
26
  var children = props.children,
26
27
  className = props.className,
27
28
  _props$isDisabled = props.isDisabled,
@@ -97,13 +98,15 @@ var Button = /*#__PURE__*/forwardRef(function (props, ref) {
97
98
  "aria-label": ariaLabel,
98
99
  className: classNames,
99
100
  role: "button",
100
- sx: isLoading ? {
101
+ variant: variant
102
+ }, getPendoID(displayName), others, {
103
+ sx: _objectSpread(_objectSpread({}, isLoading ? {
101
104
  display: 'flex',
102
105
  justifyContent: 'center',
103
- alignItems: 'center'
104
- } : {},
105
- variant: variant
106
- }, getPendoID(displayName), others), isLoading ? ___EmotionJSX("span", {
106
+ alignItems: 'center',
107
+ position: 'relative'
108
+ } : {}), (_sx = others.sx) !== null && _sx !== void 0 ? _sx : {})
109
+ }), isLoading ? ___EmotionJSX("span", {
107
110
  style: {
108
111
  visibility: 'hidden'
109
112
  }
@@ -141,6 +141,34 @@ test('button loading hides children and shows loader', function () {
141
141
  expect(childWrapper).not.toBeVisible();
142
142
  expect(screen.getByRole('alert')).toBeInTheDocument();
143
143
  });
144
+ test('button loading with consumer sx still centers loader inside button', function () {
145
+ var textContent = "I'ma button";
146
+ getComponent({
147
+ isLoading: true,
148
+ children: textContent,
149
+ sx: {
150
+ backgroundColor: 'red'
151
+ }
152
+ });
153
+
154
+ // Loader (role="alert") is still rendered — consumer sx did not clobber the loading structure.
155
+ var loader = screen.getByRole('alert');
156
+ expect(loader).toBeInTheDocument();
157
+
158
+ // Hidden children wrapper is still rendered so layout width is preserved.
159
+ var childWrapper = screen.getByText(textContent);
160
+ expect(childWrapper).toBeInTheDocument();
161
+ expect(childWrapper).not.toBeVisible();
162
+
163
+ // Loading + positioning styles remain applied on top of the consumer's sx.
164
+ var button = screen.getByRole('button');
165
+ expect(button).toHaveStyle({
166
+ display: 'flex',
167
+ justifyContent: 'center',
168
+ alignItems: 'center',
169
+ position: 'relative'
170
+ });
171
+ });
144
172
  test('button renders children when not loading', function () {
145
173
  var textContent = "I'ma button";
146
174
  getComponent({
@@ -553,4 +553,126 @@ test('does not render default timezones when items prop is provided', /*#__PURE_
553
553
  return _context17.stop();
554
554
  }
555
555
  }, _callee14);
556
+ })));
557
+ test('controlled selectedKey cleared to null clears the input value', function () {
558
+ var selectedKey = 'America/New York GMT-00:00';
559
+ var _getComponent = getComponent({
560
+ selectedKey: selectedKey
561
+ }),
562
+ rerender = _getComponent.rerender;
563
+ var input = screen.getByRole('combobox');
564
+ expect(input).toHaveValue(selectedKey);
565
+ getComponent({
566
+ selectedKey: null
567
+ }, {
568
+ renderFn: rerender
569
+ });
570
+ expect(input).toHaveValue('');
571
+ });
572
+ test('invalid timezone id in custom items renders without throwing and shows empty time', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
573
+ var customItems, input;
574
+ return _regeneratorRuntime().wrap(function _callee15$(_context18) {
575
+ while (1) switch (_context18.prev = _context18.next) {
576
+ case 0:
577
+ customItems = [{
578
+ key: 'Invalid/Timezone GMT-00:00',
579
+ id: 'Invalid/Timezone',
580
+ label: 'Invalid Timezone',
581
+ timeZone: 'Invalid/Timezone',
582
+ gmt: 'GMT-00:00',
583
+ numericOffset: 0,
584
+ searchTags: 'GMT-00:00 INVALID/TIMEZONE'
585
+ }];
586
+ getComponent({
587
+ items: customItems
588
+ });
589
+ input = screen.getByRole('combobox');
590
+ _context18.next = 5;
591
+ return userEvent.type(input, 'Invalid');
592
+ case 5:
593
+ expect(screen.getByText('Invalid/Timezone')).toBeInTheDocument();
594
+ expect(screen.getByText('GMT-00:00')).toBeInTheDocument();
595
+ // The catch block (source line 116) sets timeData.get(tz.id) to '' for invalid timezone ids.
596
+ // Time strings produced by toLocaleTimeString with hour12:true (the default) include AM/PM.
597
+ // GMT offsets (e.g. "GMT-00:00") do not, so this regex distinguishes the two.
598
+ expect(screen.queryByText(/\d{1,2}:\d{2}\s+(AM|PM)/i)).not.toBeInTheDocument();
599
+ case 8:
600
+ case "end":
601
+ return _context18.stop();
602
+ }
603
+ }, _callee15);
604
+ })));
605
+ test('US city name search returns matching US timezone results', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
606
+ var input;
607
+ return _regeneratorRuntime().wrap(function _callee16$(_context19) {
608
+ while (1) switch (_context19.prev = _context19.next) {
609
+ case 0:
610
+ getComponent();
611
+ input = screen.getByRole('combobox');
612
+ _context19.next = 4;
613
+ return userEvent.type(input, 'Los Angeles');
614
+ case 4:
615
+ expect(screen.getByText('America/Los Angeles')).toBeInTheDocument();
616
+ case 5:
617
+ case "end":
618
+ return _context19.stop();
619
+ }
620
+ }, _callee16);
621
+ })));
622
+ test('locales prop is accepted and the component renders without error', function () {
623
+ getComponent({
624
+ locales: 'en-GB'
625
+ });
626
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
627
+ });
628
+ test('localeOptions prop is accepted and the component renders without error', function () {
629
+ getComponent({
630
+ localeOptions: {
631
+ hour12: false,
632
+ hour: '2-digit',
633
+ minute: '2-digit'
634
+ }
635
+ });
636
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
637
+ });
638
+ test('pressing ArrowDown opens the dropdown listbox', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
639
+ var input;
640
+ return _regeneratorRuntime().wrap(function _callee17$(_context20) {
641
+ while (1) switch (_context20.prev = _context20.next) {
642
+ case 0:
643
+ getComponent();
644
+ input = screen.getByRole('combobox');
645
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
646
+ _context20.next = 5;
647
+ return userEvent.tab();
648
+ case 5:
649
+ _context20.next = 7;
650
+ return userEvent.type(input, '{arrowdown}', {
651
+ skipClick: true
652
+ });
653
+ case 7:
654
+ expect(screen.getByRole('listbox')).toBeInTheDocument();
655
+ case 8:
656
+ case "end":
657
+ return _context20.stop();
658
+ }
659
+ }, _callee17);
660
+ })));
661
+ test('clicking the button opens the dropdown listbox', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
662
+ var button;
663
+ return _regeneratorRuntime().wrap(function _callee18$(_context21) {
664
+ while (1) switch (_context21.prev = _context21.next) {
665
+ case 0:
666
+ getComponent();
667
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
668
+ button = screen.getByRole('button');
669
+ _context21.next = 5;
670
+ return userEvent.click(button);
671
+ case 5:
672
+ expect(screen.getByRole('listbox')).toBeInTheDocument();
673
+ case 6:
674
+ case "end":
675
+ return _context21.stop();
676
+ }
677
+ }, _callee18);
556
678
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.210.4-alpha.0",
3
+ "version": "2.210.5",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",