@pingux/astro 2.57.0-alpha.5 → 2.57.0-alpha.7

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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ListLayout } from '@react-stately/layout';
2
+ import { ListLayout } from 'listbox-layout';
3
3
  import { ListBoxProps } from '../../types';
4
4
  export declare const collectionTypes: {
5
5
  ITEM: string;
@@ -25,8 +25,8 @@ var _react = _interopRequireWildcard(require("react"));
25
25
  var _reactAria = require("react-aria");
26
26
  var _i18n = require("@react-aria/i18n");
27
27
  var _listbox = require("@react-aria/listbox");
28
- var _virtualizer = require("@react-aria/virtualizer");
29
- var _layout = require("@react-stately/layout");
28
+ var _listboxLayout = require("listbox-layout");
29
+ var _listboxVirtualizer = require("listbox-virtualizer");
30
30
  var _hooks = require("../../hooks");
31
31
  var _Loader = _interopRequireDefault(require("../Loader"));
32
32
  var _index = require("./index");
@@ -50,7 +50,7 @@ function useListBoxLayout(state) {
50
50
  sensitivity: 'base'
51
51
  });
52
52
  var layout = (0, _react.useMemo)(function () {
53
- return new _layout.ListLayout({
53
+ return new _listboxLayout.ListLayout({
54
54
  estimatedRowHeight: 41,
55
55
  estimatedHeadingHeight: 26,
56
56
  padding: 4,
@@ -145,7 +145,7 @@ var ListBox = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
145
145
  return c.viewType === 'item';
146
146
  })));
147
147
  }
148
- return (0, _react2.jsx)(_virtualizer.VirtualizerItem, {
148
+ return (0, _react2.jsx)(_listboxVirtualizer.VirtualizerItem, {
149
149
  key: reusableView.key,
150
150
  reusableView: reusableView,
151
151
  parent: parent
@@ -153,7 +153,7 @@ var ListBox = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
153
153
  };
154
154
  return (0, _react2.jsx)(_ListBoxContext.ListBoxContext.Provider, {
155
155
  value: state
156
- }, (0, _react2.jsx)(_virtualizer.Virtualizer, (0, _extends2["default"])({}, (0, _reactAria.mergeProps)(listBoxProps, others), {
156
+ }, (0, _react2.jsx)(_listboxVirtualizer.Virtualizer, (0, _extends2["default"])({}, (0, _reactAria.mergeProps)(listBoxProps, others), {
157
157
  autoFocus: hasAutoFocus,
158
158
  style: {
159
159
  outline: 'none'
@@ -255,17 +255,17 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
255
255
  selectionManager.toggleSelection(selectionManager.focusedKey);
256
256
  setFilterString('');
257
257
  }
258
- } else if (hasCustomValue && filteredItems.length === 1) {
259
- selectTheOnlyFilteredItem();
260
- } else if (!hasCustomValue) {
261
- setFilterString('');
262
- close();
263
- } else if (hasCustomValue) {
258
+ } else if (hasCustomValue && !selectionManager.focusedKey) {
264
259
  var _key = e.target.value;
265
260
  if (_key === '') {
266
261
  return;
267
262
  }
268
263
  addNewBadgeFromInput(e.target.value);
264
+ } else if (hasCustomValue && filteredItems.length === 1) {
265
+ selectTheOnlyFilteredItem();
266
+ } else if (!hasCustomValue) {
267
+ setFilterString('');
268
+ close();
269
269
  }
270
270
  break;
271
271
  }
@@ -703,6 +703,36 @@ test('should clear the input text onBlur and enter when a single filter result i
703
703
  });
704
704
  expect(input).toHaveValue('');
705
705
  });
706
+ test('in non-restrictive mode the partial string values should be accepted', function () {
707
+ var itemsWithDuplicatePartialString = [{
708
+ id: 1,
709
+ name: 'echo:read',
710
+ key: 'echo:read'
711
+ }, {
712
+ id: 2,
713
+ name: 'echo:write',
714
+ key: 'echo:write'
715
+ }, {
716
+ id: 3,
717
+ name: 'echo:delete',
718
+ key: 'echo:delete'
719
+ }];
720
+ getComponent({
721
+ mode: 'non-restrictive',
722
+ items: itemsWithDuplicatePartialString
723
+ });
724
+ var input = _testWrapper.screen.getByRole('combobox');
725
+ expect(input).toHaveValue('');
726
+ var value = 'echo:r';
727
+ _userEvent["default"].type(input, value);
728
+ _userEvent["default"].type(input, '{enter}');
729
+ expect(input).toHaveValue('');
730
+ expect(_testWrapper.screen.queryByText(value)).toBeInTheDocument();
731
+ _userEvent["default"].type(input, value);
732
+ _userEvent["default"].type(input, '{enter}');
733
+ expect(input).not.toHaveValue('');
734
+ expect(input).toHaveValue(value);
735
+ });
706
736
 
707
737
  // Needs to be added to each components test file
708
738
  (0, _universalComponentTest.universalComponentTests)({
@@ -17,8 +17,8 @@ import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
17
17
  import { mergeProps } from 'react-aria';
18
18
  import { useCollator } from '@react-aria/i18n';
19
19
  import { useListBox } from '@react-aria/listbox';
20
- import { Virtualizer, VirtualizerItem } from '@react-aria/virtualizer';
21
- import { ListLayout } from '@react-stately/layout';
20
+ import { ListLayout } from 'listbox-layout';
21
+ import { Virtualizer, VirtualizerItem } from 'listbox-virtualizer';
22
22
  import { useLocalOrForwardRef } from '../../hooks';
23
23
  import Loader from '../Loader';
24
24
  import { Option } from './index';
@@ -243,17 +243,17 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
243
243
  selectionManager.toggleSelection(selectionManager.focusedKey);
244
244
  setFilterString('');
245
245
  }
246
- } else if (hasCustomValue && filteredItems.length === 1) {
247
- selectTheOnlyFilteredItem();
248
- } else if (!hasCustomValue) {
249
- setFilterString('');
250
- close();
251
- } else if (hasCustomValue) {
246
+ } else if (hasCustomValue && !selectionManager.focusedKey) {
252
247
  var _key = e.target.value;
253
248
  if (_key === '') {
254
249
  return;
255
250
  }
256
251
  addNewBadgeFromInput(e.target.value);
252
+ } else if (hasCustomValue && filteredItems.length === 1) {
253
+ selectTheOnlyFilteredItem();
254
+ } else if (!hasCustomValue) {
255
+ setFilterString('');
256
+ close();
257
257
  }
258
258
  break;
259
259
  }
@@ -700,6 +700,36 @@ test('should clear the input text onBlur and enter when a single filter result i
700
700
  });
701
701
  expect(input).toHaveValue('');
702
702
  });
703
+ test('in non-restrictive mode the partial string values should be accepted', function () {
704
+ var itemsWithDuplicatePartialString = [{
705
+ id: 1,
706
+ name: 'echo:read',
707
+ key: 'echo:read'
708
+ }, {
709
+ id: 2,
710
+ name: 'echo:write',
711
+ key: 'echo:write'
712
+ }, {
713
+ id: 3,
714
+ name: 'echo:delete',
715
+ key: 'echo:delete'
716
+ }];
717
+ getComponent({
718
+ mode: 'non-restrictive',
719
+ items: itemsWithDuplicatePartialString
720
+ });
721
+ var input = screen.getByRole('combobox');
722
+ expect(input).toHaveValue('');
723
+ var value = 'echo:r';
724
+ userEvent.type(input, value);
725
+ userEvent.type(input, '{enter}');
726
+ expect(input).toHaveValue('');
727
+ expect(screen.queryByText(value)).toBeInTheDocument();
728
+ userEvent.type(input, value);
729
+ userEvent.type(input, '{enter}');
730
+ expect(input).not.toHaveValue('');
731
+ expect(input).toHaveValue(value);
732
+ });
703
733
 
704
734
  // Needs to be added to each components test file
705
735
  universalComponentTests({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.57.0-alpha.5",
3
+ "version": "2.57.0-alpha.7",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",
@@ -105,6 +105,8 @@
105
105
  "classnames": "^2.2.6",
106
106
  "countries-list": "^2.6.1",
107
107
  "emotion-normalize": "^11.0.1",
108
+ "listbox-layout": "npm:@react-stately/layout@3.9.0",
109
+ "listbox-virtualizer": "npm:@react-aria/virtualizer@3.6.0",
108
110
  "lodash": "^4.17.21",
109
111
  "moment": "^2.29.4",
110
112
  "pluralize": "^8.0.0",