@pingux/astro 1.2.1 → 1.3.2-alpha.0

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.js +8 -2
  3. package/lib/cjs/components/AccordionGridItem/AccordionGridItemBody.js +5 -2
  4. package/lib/cjs/components/AccordionGridItem/AccordionGridItemHeader.js +8 -3
  5. package/lib/cjs/components/ArrayField/ArrayField.js +213 -0
  6. package/lib/cjs/components/ArrayField/ArrayField.stories.js +223 -0
  7. package/lib/cjs/components/ArrayField/ArrayField.test.js +208 -0
  8. package/lib/cjs/components/ArrayField/ArrayFieldDeleteButton.js +61 -0
  9. package/lib/cjs/components/ArrayField/index.js +27 -0
  10. package/lib/cjs/components/CheckboxField/CheckboxField.js +4 -1
  11. package/lib/cjs/components/CodeView/CodeView.js +3 -3
  12. package/lib/cjs/components/Input/Input.js +3 -11
  13. package/lib/cjs/components/Input/Input.test.js +14 -2
  14. package/lib/cjs/components/ListView/ListView.stories.js +3 -0
  15. package/lib/cjs/components/Loader/Loader.stories.js +3 -3
  16. package/lib/cjs/components/Modal/Modal.js +3 -0
  17. package/lib/cjs/components/Modal/Modal.stories.js +11 -66
  18. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +20 -10
  19. package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +74 -0
  20. package/lib/cjs/components/NavBar/NavBar.js +30 -4
  21. package/lib/cjs/components/NavBar/NavBar.stories.js +70 -463
  22. package/lib/cjs/components/NavBar/NavBar.test.js +51 -1
  23. package/lib/cjs/components/NavBarSection/NavBarItem.js +137 -0
  24. package/lib/cjs/components/NavBarSection/NavBarItemButton.js +96 -0
  25. package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +1 -1
  26. package/lib/cjs/components/NavBarSection/NavBarItemLink.js +98 -0
  27. package/lib/cjs/components/NavBarSection/NavBarSection.js +10 -8
  28. package/lib/cjs/components/NavBarSection/index.js +28 -1
  29. package/lib/cjs/components/NumberField/NumberField.js +30 -10
  30. package/lib/cjs/components/NumberField/NumberField.test.js +7 -0
  31. package/lib/cjs/components/PageHeader/PageHeader.js +3 -0
  32. package/lib/cjs/components/PageHeader/PageHeader.stories.js +6 -1
  33. package/lib/cjs/components/RadioGroupField/RadioGroupField.js +9 -5
  34. package/lib/cjs/components/SelectField/SelectField.stories.js +3 -55
  35. package/lib/cjs/components/SelectFieldBase/SelectFieldBase.js +8 -1
  36. package/lib/cjs/components/Tabs/Tabs.stories.js +1 -15
  37. package/lib/cjs/context/NavBarContext/index.js +20 -0
  38. package/lib/cjs/hooks/index.js +9 -0
  39. package/lib/cjs/hooks/useField/useField.js +2 -2
  40. package/lib/cjs/hooks/useNavBarPress/index.js +18 -0
  41. package/lib/cjs/hooks/useNavBarPress/useNavBarPress.js +38 -0
  42. package/lib/cjs/hooks/useNavBarPress/useNavBarPress.test.js +42 -0
  43. package/lib/cjs/index.js +80 -58
  44. package/lib/cjs/styles/forms/checkbox.js +0 -1
  45. package/lib/cjs/styles/forms/input.js +1 -1
  46. package/lib/cjs/styles/forms/label.js +3 -0
  47. package/lib/cjs/styles/forms/radio.js +1 -1
  48. package/lib/cjs/styles/forms/switch.js +3 -1
  49. package/lib/cjs/styles/variants/accordion.js +39 -7
  50. package/lib/cjs/styles/variants/boxes.js +5 -25
  51. package/lib/cjs/styles/variants/buttons.js +7 -1
  52. package/lib/cjs/styles/variants/codeView.js +91 -0
  53. package/lib/cjs/styles/variants/navBar.js +68 -0
  54. package/lib/cjs/styles/variants/separator.js +2 -1
  55. package/lib/cjs/styles/variants/text.js +3 -1
  56. package/lib/cjs/styles/variants/variants.js +3 -0
  57. package/lib/components/AccordionGridGroup/AccordionGridGroup.js +7 -2
  58. package/lib/components/AccordionGridItem/AccordionGridItemBody.js +4 -2
  59. package/lib/components/AccordionGridItem/AccordionGridItemHeader.js +9 -4
  60. package/lib/components/ArrayField/ArrayField.js +179 -0
  61. package/lib/components/ArrayField/ArrayField.stories.js +196 -0
  62. package/lib/components/ArrayField/ArrayField.test.js +185 -0
  63. package/lib/components/ArrayField/ArrayFieldDeleteButton.js +43 -0
  64. package/lib/components/ArrayField/index.js +2 -0
  65. package/lib/components/CheckboxField/CheckboxField.js +4 -1
  66. package/lib/components/CodeView/CodeView.js +2 -2
  67. package/lib/components/Input/Input.js +2 -10
  68. package/lib/components/Input/Input.test.js +11 -2
  69. package/lib/components/ListView/ListView.stories.js +3 -0
  70. package/lib/components/Loader/Loader.stories.js +1 -1
  71. package/lib/components/Modal/Modal.js +4 -1
  72. package/lib/components/Modal/Modal.stories.js +10 -59
  73. package/lib/components/MultivaluesField/MultivaluesField.js +19 -9
  74. package/lib/components/MultivaluesField/MultivaluesField.test.js +52 -0
  75. package/lib/components/NavBar/NavBar.js +25 -4
  76. package/lib/components/NavBar/NavBar.stories.js +71 -462
  77. package/lib/components/NavBar/NavBar.test.js +39 -2
  78. package/lib/components/NavBarSection/NavBarItem.js +111 -0
  79. package/lib/components/NavBarSection/NavBarItemButton.js +69 -0
  80. package/lib/components/NavBarSection/NavBarItemHeader.js +1 -1
  81. package/lib/components/NavBarSection/NavBarItemLink.js +71 -0
  82. package/lib/components/NavBarSection/NavBarSection.js +9 -8
  83. package/lib/components/NavBarSection/index.js +4 -1
  84. package/lib/components/NumberField/NumberField.js +32 -12
  85. package/lib/components/NumberField/NumberField.test.js +5 -0
  86. package/lib/components/PageHeader/PageHeader.js +2 -0
  87. package/lib/components/PageHeader/PageHeader.stories.js +5 -1
  88. package/lib/components/RadioGroupField/RadioGroupField.js +9 -5
  89. package/lib/components/SelectField/SelectField.stories.js +2 -50
  90. package/lib/components/SelectFieldBase/SelectFieldBase.js +8 -1
  91. package/lib/components/Tabs/Tabs.stories.js +0 -11
  92. package/lib/context/NavBarContext/index.js +5 -0
  93. package/lib/hooks/index.js +1 -0
  94. package/lib/hooks/useField/useField.js +2 -2
  95. package/lib/hooks/useNavBarPress/index.js +1 -0
  96. package/lib/hooks/useNavBarPress/useNavBarPress.js +27 -0
  97. package/lib/hooks/useNavBarPress/useNavBarPress.test.js +36 -0
  98. package/lib/index.js +2 -0
  99. package/lib/styles/forms/checkbox.js +0 -1
  100. package/lib/styles/forms/input.js +1 -1
  101. package/lib/styles/forms/label.js +3 -0
  102. package/lib/styles/forms/radio.js +1 -1
  103. package/lib/styles/forms/switch.js +3 -1
  104. package/lib/styles/variants/accordion.js +26 -5
  105. package/lib/styles/variants/boxes.js +5 -25
  106. package/lib/styles/variants/buttons.js +7 -1
  107. package/lib/styles/variants/codeView.js +91 -0
  108. package/lib/styles/variants/navBar.js +46 -0
  109. package/lib/styles/variants/separator.js +2 -1
  110. package/lib/styles/variants/text.js +3 -1
  111. package/lib/styles/variants/variants.js +2 -0
  112. package/package.json +3 -1
  113. package/lib/cjs/layouts/ListLayout.stories.js +0 -895
  114. package/lib/cjs/layouts/SchemaFormLayout.stories.js +0 -139
  115. package/lib/cjs/recipes/ArrayField.stories.js +0 -169
  116. package/lib/layouts/ListLayout.stories.js +0 -866
  117. package/lib/layouts/SchemaFormLayout.stories.js +0 -107
  118. package/lib/recipes/ArrayField.stories.js +0 -134
@@ -27,7 +27,6 @@ import { FocusScope } from '@react-aria/focus';
27
27
  import { useListState } from '@react-stately/list';
28
28
  import { DismissButton, useOverlayPosition } from '@react-aria/overlays';
29
29
  import { useLayoutEffect, useResizeObserver } from '@react-aria/utils';
30
- import { v4 as uuid } from 'uuid';
31
30
  import { Chip, Icon, IconButton, PopoverContainer, ScrollBox, TextField } from '../..';
32
31
  import ListBox from '../ListBox';
33
32
  import { isIterableProp } from '../../utils/devUtils/props/isIterable';
@@ -52,6 +51,7 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
52
51
  disabledKeys = _props$disabledKeys === void 0 ? [] : _props$disabledKeys,
53
52
  hasAutoFocus = props.hasAutoFocus,
54
53
  hasNoStatusIndicator = props.hasNoStatusIndicator,
54
+ customInputProps = props.inputProps,
55
55
  isDisabled = props.isDisabled,
56
56
  isNotFlippable = props.isNotFlippable,
57
57
  isReadOnly = props.isReadOnly,
@@ -219,13 +219,17 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
219
219
  } else if (hasCustomValue) {
220
220
  var _context3;
221
221
 
222
- var name = e.target.value;
223
- var id = uuid();
224
- selectionManager.toggleSelection(id);
222
+ var _key2 = e.target.value;
223
+
224
+ if (state.selectionManager.isSelected(_key2)) {
225
+ return;
226
+ }
227
+
228
+ selectionManager.toggleSelection(_key2);
225
229
  setCustomItems(_concatInstanceProperty(_context3 = []).call(_context3, customItems, [{
226
- id: id,
227
- key: id,
228
- name: name
230
+ id: _key2,
231
+ key: _key2,
232
+ name: _key2
229
233
  }]));
230
234
  setFilterString('');
231
235
  }
@@ -319,7 +323,7 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
319
323
  onDismiss: close
320
324
  }));
321
325
 
322
- var inputProps = {
326
+ var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
323
327
  controlProps: {
324
328
  'aria-expanded': isOpen,
325
329
  role: 'combobox'
@@ -335,7 +339,8 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
335
339
  ref: inputRef,
336
340
  variant: 'forms.input.multivaluesWrapper'
337
341
  }
338
- };
342
+ });
343
+
339
344
  return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(TextField, _extends({
340
345
  onBlur: function onBlur(e) {
341
346
  setIsOpen(false);
@@ -385,6 +390,11 @@ MultivaluesField.propTypes = {
385
390
  /** Whether the field has a status indicator. */
386
391
  hasNoStatusIndicator: PropTypes.bool,
387
392
 
393
+ /**
394
+ * Props that get passed as-is to the underlying TextField element
395
+ */
396
+ inputProps: PropTypes.shape({}),
397
+
388
398
  /** Whether the input is disabled. */
389
399
  isDisabled: PropTypes.bool,
390
400
 
@@ -212,6 +212,58 @@ test('changing the input value and hitting enter creates new value in non-restri
212
212
  var chipContainer = chip.parentElement;
213
213
  expect(chipContainer).toHaveAttribute('role', 'presentation');
214
214
  });
215
+ test('in non-restrictive mode "onSelectionChange" returns entered keys', function () {
216
+ var onSelectionChange = jest.fn();
217
+ getComponent({
218
+ mode: 'non-restrictive',
219
+ onSelectionChange: onSelectionChange
220
+ });
221
+ var input = screen.getByRole('combobox');
222
+ var value = 'custom';
223
+ userEvent.type(input, value);
224
+ userEvent.type(input, '{enter}');
225
+ var chip = screen.queryByText(value);
226
+ expect(chip).toBeInTheDocument();
227
+ expect(onSelectionChange).toBeCalledTimes(1);
228
+ expect(onSelectionChange.mock.calls[0][0].has(value)).toBeTruthy();
229
+ });
230
+ test('in non-restrictive mode the same value cannot be applied twice', function () {
231
+ var onSelectionChange = jest.fn();
232
+ getComponent({
233
+ mode: 'non-restrictive',
234
+ onSelectionChange: onSelectionChange
235
+ });
236
+ var input = screen.getByRole('combobox');
237
+ var value = 'custom';
238
+ userEvent.type(input, value);
239
+ userEvent.type(input, '{enter}');
240
+ var chip = screen.queryByText(value);
241
+ expect(chip).toBeInTheDocument();
242
+ expect(input).toHaveValue('');
243
+ userEvent.type(input, value);
244
+ userEvent.type(input, '{enter}');
245
+ expect(input).toHaveValue(value);
246
+ expect(onSelectionChange).toBeCalledTimes(1);
247
+ });
248
+ test('in non-restrictive mode the value that was already selected using the list cannot be applied', function () {
249
+ var onSelectionChange = jest.fn();
250
+ getComponent({
251
+ mode: 'non-restrictive',
252
+ onSelectionChange: onSelectionChange
253
+ });
254
+ var input = screen.getByRole('combobox');
255
+ input.focus();
256
+ var listbox = screen.getByRole('listbox');
257
+ var options = within(listbox).getAllByRole('option');
258
+ var firstOption = options[0];
259
+ firstOption.click();
260
+ expect(onSelectionChange.mock.calls[0][0].has(items[0].name)).toBeTruthy();
261
+ onSelectionChange.mockClear();
262
+ userEvent.type(input, items[0].name);
263
+ userEvent.type(input, '{enter}');
264
+ expect(input).toHaveValue(items[0].name);
265
+ expect(onSelectionChange).not.toBeCalled();
266
+ });
215
267
  test('options can be focused via keyboard', function () {
216
268
  getComponent();
217
269
  var input = screen.getByRole('combobox');
@@ -1,4 +1,7 @@
1
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
2
+ import React, { useState } from 'react';
3
+ import { NavBarContext } from '../../context/NavBarContext';
4
+ import { isIterableProp } from '../../utils/devUtils/props/isIterable';
2
5
  import Box from '../Box/Box';
3
6
  /**
4
7
  * Composed component that spreads children.
@@ -14,11 +17,29 @@ import Box from '../Box/Box';
14
17
  import { jsx as ___EmotionJSX } from "@emotion/react";
15
18
 
16
19
  var NavBar = function NavBar(props) {
17
- return ___EmotionJSX(Box, {
18
- variant: "boxes.navBar",
20
+ var defaultSelectedKeys = props.defaultSelectedKeys;
21
+
22
+ var _useState = useState(defaultSelectedKeys),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ selectedKeys = _useState2[0],
25
+ setSelectedKeys = _useState2[1];
26
+
27
+ return ___EmotionJSX(NavBarContext.Provider, {
28
+ value: {
29
+ selectedKeys: selectedKeys,
30
+ setSelectedKeys: setSelectedKeys
31
+ }
32
+ }, ___EmotionJSX(Box, {
33
+ variant: "navBar.container",
19
34
  role: "navigation",
20
35
  as: "nav"
21
- }, props.children);
36
+ }, props.children));
22
37
  };
23
38
 
39
+ NavBar.propTypes = {
40
+ defaultSelectedKeys: isIterableProp
41
+ };
42
+ NavBar.defaultProps = {
43
+ defaultSelectedKeys: []
44
+ };
24
45
  export default NavBar;