@pingux/astro 1.0.0-alpha.6 → 1.1.0-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 (113) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +5 -0
  3. package/lib/cjs/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
  4. package/lib/cjs/components/AccordionItem/AccordionItem.js +3 -1
  5. package/lib/cjs/components/Button/Button.js +5 -24
  6. package/lib/cjs/components/Button/Button.stories.js +5 -11
  7. package/lib/cjs/components/Button/Button.test.js +0 -24
  8. package/lib/cjs/components/Chip/Chip.js +26 -10
  9. package/lib/cjs/components/Chip/Chip.stories.js +44 -5
  10. package/lib/cjs/components/Chip/Chip.test.js +9 -0
  11. package/lib/cjs/components/{Panel/index.js → Chip/ChipContext.js} +8 -7
  12. package/lib/cjs/components/CopyText/CopyText.js +3 -73
  13. package/lib/cjs/components/IconButton/IconButton.js +17 -7
  14. package/lib/cjs/components/IconButton/IconButton.test.js +0 -1
  15. package/lib/cjs/components/ListItem/ListItem.stories.js +0 -2
  16. package/lib/cjs/components/ListView/ListView.js +4 -3
  17. package/lib/cjs/components/ListViewItem/ListViewItem.js +3 -6
  18. package/lib/cjs/components/MultivaluesField/MultivaluesField.js +1 -1
  19. package/lib/cjs/components/Stepper/Stepper.js +1 -0
  20. package/lib/cjs/components/Tab/Tab.js +15 -6
  21. package/lib/cjs/components/Tabs/Tabs.js +7 -1
  22. package/lib/cjs/components/Tabs/Tabs.stories.js +60 -6
  23. package/lib/cjs/components/Tabs/Tabs.test.js +78 -15
  24. package/lib/cjs/components/TextAreaField/TextAreaField.test.js +10 -0
  25. package/lib/cjs/components/TooltipTrigger/TooltipTrigger.stories.js +45 -2
  26. package/lib/cjs/{components/DropdownField → hooks/useCopyToClipboard}/index.js +2 -2
  27. package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +83 -0
  28. package/lib/cjs/hooks/useCopyToClipboard/useCopyToClipboard.test.js +79 -0
  29. package/lib/cjs/index.js +48 -136
  30. package/lib/cjs/layouts/ListLayout.stories.js +2 -1
  31. package/lib/cjs/layouts/SchemaFormLayout.stories.js +2 -21
  32. package/lib/cjs/recipes/ArrayField.stories.js +3 -3
  33. package/lib/cjs/recipes/CopyToClipboard.stories.js +45 -0
  34. package/lib/cjs/recipes/RadioButtonsWithLinks.stories.js +146 -0
  35. package/lib/cjs/styles/forms/input.js +4 -0
  36. package/lib/cjs/styles/theme.js +0 -3
  37. package/lib/cjs/styles/variants/accordion.js +7 -9
  38. package/lib/cjs/styles/variants/boxes.js +22 -19
  39. package/lib/cjs/styles/variants/buttons.js +38 -29
  40. package/lib/cjs/styles/variants/tabs.js +1 -0
  41. package/lib/cjs/styles/variants/variants.js +0 -3
  42. package/lib/components/AccordionGridGroup/AccordionGridGroup.stories.js +4 -11
  43. package/lib/components/AccordionItem/AccordionItem.js +3 -1
  44. package/lib/components/Button/Button.js +7 -24
  45. package/lib/components/Button/Button.stories.js +5 -10
  46. package/lib/components/Button/Button.test.js +0 -20
  47. package/lib/components/Chip/Chip.js +25 -10
  48. package/lib/components/Chip/Chip.stories.js +41 -5
  49. package/lib/components/Chip/Chip.test.js +9 -0
  50. package/lib/components/Chip/ChipContext.js +3 -0
  51. package/lib/components/CopyText/CopyText.js +2 -71
  52. package/lib/components/IconButton/IconButton.js +17 -9
  53. package/lib/components/IconButton/IconButton.test.js +0 -1
  54. package/lib/components/ListItem/ListItem.stories.js +0 -2
  55. package/lib/components/ListView/ListView.js +4 -3
  56. package/lib/components/ListViewItem/ListViewItem.js +3 -5
  57. package/lib/components/MultivaluesField/MultivaluesField.js +1 -1
  58. package/lib/components/Stepper/Stepper.js +1 -0
  59. package/lib/components/Tab/Tab.js +15 -6
  60. package/lib/components/Tabs/Tabs.js +7 -1
  61. package/lib/components/Tabs/Tabs.stories.js +56 -4
  62. package/lib/components/Tabs/Tabs.test.js +78 -15
  63. package/lib/components/TextAreaField/TextAreaField.test.js +8 -0
  64. package/lib/components/TooltipTrigger/TooltipTrigger.stories.js +33 -1
  65. package/lib/hooks/useCopyToClipboard/index.js +1 -0
  66. package/lib/hooks/useCopyToClipboard/useCopyToClipboard.js +69 -0
  67. package/lib/hooks/useCopyToClipboard/useCopyToClipboard.test.js +64 -0
  68. package/lib/index.js +0 -8
  69. package/lib/layouts/ListLayout.stories.js +2 -1
  70. package/lib/layouts/SchemaFormLayout.stories.js +2 -19
  71. package/lib/recipes/ArrayField.stories.js +3 -3
  72. package/lib/recipes/CopyToClipboard.stories.js +25 -0
  73. package/lib/recipes/RadioButtonsWithLinks.stories.js +120 -0
  74. package/lib/styles/forms/input.js +4 -0
  75. package/lib/styles/theme.js +0 -3
  76. package/lib/styles/variants/accordion.js +7 -9
  77. package/lib/styles/variants/boxes.js +21 -19
  78. package/lib/styles/variants/buttons.js +37 -29
  79. package/lib/styles/variants/tabs.js +1 -0
  80. package/lib/styles/variants/variants.js +0 -2
  81. package/package.json +2 -2
  82. package/lib/cjs/components/Dropdown/Dropdown.js +0 -112
  83. package/lib/cjs/components/Dropdown/Dropdown.test.js +0 -80
  84. package/lib/cjs/components/Dropdown/index.js +0 -18
  85. package/lib/cjs/components/DropdownField/DropdownField.js +0 -187
  86. package/lib/cjs/components/DropdownField/DropdownField.stories.js +0 -278
  87. package/lib/cjs/components/DropdownField/DropdownField.test.js +0 -80
  88. package/lib/cjs/components/Panel/Panel.js +0 -101
  89. package/lib/cjs/components/Panel/Panel.stories.js +0 -57
  90. package/lib/cjs/components/Panel/Panel.test.js +0 -72
  91. package/lib/cjs/components/Popover/Popover.js +0 -87
  92. package/lib/cjs/components/Popover/Popover.stories.js +0 -80
  93. package/lib/cjs/components/Popover/Popover.test.js +0 -91
  94. package/lib/cjs/components/Popover/index.js +0 -18
  95. package/lib/cjs/recipes/InputBoxWithLinkedChip.stories.js +0 -67
  96. package/lib/cjs/styles/variants/popover.js +0 -86
  97. package/lib/components/Dropdown/Dropdown.js +0 -90
  98. package/lib/components/Dropdown/Dropdown.test.js +0 -62
  99. package/lib/components/Dropdown/index.js +0 -1
  100. package/lib/components/DropdownField/DropdownField.js +0 -155
  101. package/lib/components/DropdownField/DropdownField.stories.js +0 -222
  102. package/lib/components/DropdownField/DropdownField.test.js +0 -60
  103. package/lib/components/DropdownField/index.js +0 -1
  104. package/lib/components/Panel/Panel.js +0 -71
  105. package/lib/components/Panel/Panel.stories.js +0 -35
  106. package/lib/components/Panel/Panel.test.js +0 -52
  107. package/lib/components/Panel/index.js +0 -1
  108. package/lib/components/Popover/Popover.js +0 -65
  109. package/lib/components/Popover/Popover.stories.js +0 -52
  110. package/lib/components/Popover/Popover.test.js +0 -75
  111. package/lib/components/Popover/index.js +0 -2
  112. package/lib/recipes/InputBoxWithLinkedChip.stories.js +0 -43
  113. package/lib/styles/variants/popover.js +0 -76
@@ -1,80 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- exports.PopoverMenu = exports.Default = exports["default"] = void 0;
12
-
13
- var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
-
15
- var _react = _interopRequireDefault(require("react"));
16
-
17
- var _MoreVertIcon = _interopRequireDefault(require("mdi-react/MoreVertIcon"));
18
-
19
- var _addonActions = require("@storybook/addon-actions");
20
-
21
- var _Popover = _interopRequireDefault(require("../Popover/Popover"));
22
-
23
- var _Button = _interopRequireDefault(require("../Button/Button"));
24
-
25
- var _Icon = _interopRequireDefault(require("../Icon/Icon"));
26
-
27
- var _Link = _interopRequireDefault(require("../Link/Link"));
28
-
29
- var _withDeprecationWarning = _interopRequireDefault(require("../../utils/devUtils/decorators/withDeprecationWarning"));
30
-
31
- var _react2 = require("@emotion/react");
32
-
33
- // TODO: popover-deprecate Remove when popover is deprecated in 1.0.0
34
- var _default = {
35
- title: 'Deprecated/Popover',
36
- component: _Popover["default"],
37
- argTypes: {
38
- content: {
39
- control: {
40
- type: 'text'
41
- },
42
- defaultValue: 'Hi, I\'m a popover!'
43
- }
44
- },
45
- decorators: [function (Story, context) {
46
- return (0, _withDeprecationWarning["default"])(Story, context, '`Popover` will be deprecated in Astro-UI 1.0.0, use `PopoverMenu` for menus instead. Or `Tooltip` when it is available.');
47
- }]
48
- };
49
- exports["default"] = _default;
50
-
51
- var Default = function Default(_ref) {
52
- var args = (0, _extends2["default"])({}, _ref);
53
- return (0, _react2.jsx)(_Popover["default"], args, (0, _react2.jsx)(_Button["default"], null, "Hover over button"));
54
- };
55
-
56
- exports.Default = Default;
57
-
58
- var PopoverMenu = function PopoverMenu() {
59
- return (0, _react2.jsx)(_Popover["default"], {
60
- delay: [null, 500],
61
- trigger: "click",
62
- content: // Content will be replaced with Menu component which is still in development
63
- (0, _react2.jsx)(_react["default"].Fragment, null, (0, _react2.jsx)(_Link["default"], {
64
- onPress: (0, _addonActions.action)('onPress')
65
- }, "Edit"), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Link["default"], {
66
- onPress: (0, _addonActions.action)('onPress')
67
- }, "Duplicate"), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_Link["default"], {
68
- onPress: (0, _addonActions.action)('onPress')
69
- }, "Delete"), (0, _react2.jsx)("br", null)),
70
- placement: "bottom"
71
- }, (0, _react2.jsx)(_Button["default"], {
72
- variant: "icon",
73
- ml: "sm"
74
- }, (0, _react2.jsx)(_Icon["default"], {
75
- icon: _MoreVertIcon["default"],
76
- size: 20
77
- })));
78
- };
79
-
80
- exports.PopoverMenu = PopoverMenu;
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
6
-
7
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
8
-
9
- var _react = _interopRequireDefault(require("react"));
10
-
11
- var _react2 = require("@testing-library/react");
12
-
13
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
14
-
15
- var _Popover = _interopRequireDefault(require("./Popover"));
16
-
17
- var _Button = _interopRequireDefault(require("../Button/Button"));
18
-
19
- var _Link = _interopRequireDefault(require("../Link/Link"));
20
-
21
- var _testAxe = _interopRequireDefault(require("../../utils/testUtils/testAxe"));
22
-
23
- var _react3 = require("@emotion/react");
24
-
25
- // TODO: popover-deprecate Remove when popover is deprecated in 1.0.0
26
- var defaultProps = {
27
- content: (0, _react3.jsx)(_Link["default"], null, "Click Me!")
28
- };
29
-
30
- var getComponent = function getComponent() {
31
- return (0, _react2.render)((0, _react3.jsx)(_react["default"].Fragment, null, (0, _react3.jsx)(_Popover["default"], defaultProps, (0, _react3.jsx)(_Button["default"], null, "Mock Button"))));
32
- }; // Need to be added to each test file to test accessibility using axe.
33
-
34
-
35
- (0, _testAxe["default"])(getComponent); // NOTE: We must use waitFor to assert the async DOM changes that occur
36
-
37
- test('renders a popover when target is clicked', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
38
- var button, popover;
39
- return _regenerator["default"].wrap(function _callee$(_context) {
40
- while (1) {
41
- switch (_context.prev = _context.next) {
42
- case 0:
43
- getComponent();
44
- button = _react2.screen.getByRole('button');
45
- _context.next = 4;
46
- return (0, _react2.waitFor)(function () {
47
- return _userEvent["default"].click(button);
48
- });
49
-
50
- case 4:
51
- popover = _react2.screen.getByRole('tooltip');
52
- expect(popover).toBeInTheDocument();
53
-
54
- case 6:
55
- case "end":
56
- return _context.stop();
57
- }
58
- }
59
- }, _callee);
60
- })));
61
- test('it does not render a popover when the target is not clicked', function () {
62
- getComponent();
63
-
64
- var popover = _react2.screen.queryByRole('tooltip');
65
-
66
- expect(popover).not.toBeInTheDocument();
67
- });
68
- test('renders content in the popover', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
69
- var button, link;
70
- return _regenerator["default"].wrap(function _callee2$(_context2) {
71
- while (1) {
72
- switch (_context2.prev = _context2.next) {
73
- case 0:
74
- getComponent();
75
- button = _react2.screen.getByRole('button');
76
- _context2.next = 4;
77
- return (0, _react2.waitFor)(function () {
78
- return _userEvent["default"].click(button);
79
- });
80
-
81
- case 4:
82
- link = _react2.screen.getByRole('link');
83
- expect(link).toBeInTheDocument();
84
-
85
- case 6:
86
- case "end":
87
- return _context2.stop();
88
- }
89
- }
90
- }, _callee2);
91
- })));
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- _Object$defineProperty(exports, "default", {
12
- enumerable: true,
13
- get: function get() {
14
- return _Popover["default"];
15
- }
16
- });
17
-
18
- var _Popover = _interopRequireDefault(require("./Popover"));
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
-
5
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
6
-
7
- _Object$defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
-
11
- exports.Default = exports["default"] = void 0;
12
-
13
- var _react = _interopRequireDefault(require("react"));
14
-
15
- var _LinkVariantIcon = _interopRequireDefault(require("mdi-react/LinkVariantIcon"));
16
-
17
- var _Chip = _interopRequireDefault(require("../components/Chip"));
18
-
19
- var _Text = _interopRequireDefault(require("../components/Text"));
20
-
21
- var _Icon = _interopRequireDefault(require("../components/Icon"));
22
-
23
- var _Box = _interopRequireDefault(require("../components/Box"));
24
-
25
- var _Popover = _interopRequireDefault(require("../components/Popover"));
26
-
27
- var _react2 = require("@emotion/react");
28
-
29
- var _default = {
30
- title: 'Recipes/InputBoxWithLinkedChip'
31
- };
32
- exports["default"] = _default;
33
-
34
- var Default = function Default() {
35
- return (0, _react2.jsx)(_Box["default"], {
36
- variant: "forms.input.container",
37
- width: "500px"
38
- }, (0, _react2.jsx)(_Box["default"], {
39
- variant: "forms.input",
40
- height: "40px",
41
- p: "0",
42
- justifyContent: "center"
43
- }, (0, _react2.jsx)(_Popover["default"], {
44
- content: "steps.registration.formData.user",
45
- placement: "bottom"
46
- }, (0, _react2.jsx)(_Chip["default"], {
47
- ml: "md",
48
- bg: "#E5E9F8",
49
- label: (0, _react2.jsx)(_Box["default"], {
50
- isRow: true,
51
- justifyContent: "center"
52
- }, (0, _react2.jsx)(_Icon["default"], {
53
- icon: _LinkVariantIcon["default"],
54
- color: "#253746",
55
- size: 15,
56
- alignSelf: "center",
57
- mr: "xs"
58
- }), (0, _react2.jsx)(_Text["default"], {
59
- color: "#253746",
60
- sx: {
61
- textTransform: 'lowercase'
62
- }
63
- }, "user"))
64
- }))));
65
- };
66
-
67
- exports.Default = Default;
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
4
-
5
- _Object$defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
-
9
- exports["default"] = void 0;
10
- var container = {
11
- position: 'relative',
12
- backgroundColor: 'accent.20',
13
- color: 'white',
14
- borderRadius: 4,
15
- fontSize: 'md',
16
- lineHeight: 1.4,
17
- outline: 0,
18
- transitionProperty: 'transform,visibility,opacity',
19
- '&[data-animation=fade][data-state=hidden]': {
20
- opacity: 0
21
- },
22
- '&[data-placement^=top] > .tippy-arrow': {
23
- bottom: 0
24
- },
25
- '&[data-placement^=top] > .tippy-arrow:before': {
26
- bottom: -7,
27
- left: 0,
28
- borderWidth: '8px 8px 0',
29
- borderTopColor: 'initial',
30
- transformOrigin: 'center top'
31
- },
32
- '&[data-placement^=bottom] > .tippy-arrow': {
33
- top: 0
34
- },
35
- '&[data-placement^=bottom] > .tippy-arrow:before': {
36
- top: -7,
37
- left: 0,
38
- borderWidth: '0 8px 8px',
39
- borderBottomColor: 'initial',
40
- transformOrigin: 'center bottom'
41
- },
42
- '&[data-placement^=left] > .tippy-arrow': {
43
- right: 0
44
- },
45
- '&[data-placement^=left] > .tippy-arrow:before': {
46
- borderWidth: '8px 0 8px 8px',
47
- borderLeftColor: 'initial',
48
- right: -7,
49
- transformOrigin: 'center left'
50
- },
51
- '&[data-placement^=right] > .tippy-arrow': {
52
- left: 0
53
- },
54
- '&[data-placement^=right] > .tippy-arrow:before': {
55
- left: -7,
56
- borderWidth: '8px 8px 8px 0',
57
- borderRightColor: 'initial',
58
- transformOrigin: 'center right'
59
- },
60
- '&[data-inertia][data-state=visible]': {
61
- transitionTimingFunction: 'cubic-bezier(.54,1.5,.38,1.11)'
62
- }
63
- };
64
- var content = {
65
- position: 'relative',
66
- px: 'sm',
67
- py: 'xs',
68
- zIndex: 1
69
- };
70
- var arrow = {
71
- width: 16,
72
- height: 16,
73
- color: 'accent.20',
74
- '&:before': {
75
- content: '""',
76
- position: 'absolute',
77
- borderColor: 'transparent',
78
- borderStyle: 'solid'
79
- }
80
- };
81
- var _default = {
82
- arrow: arrow,
83
- container: container,
84
- content: content
85
- };
86
- exports["default"] = _default;
@@ -1,90 +0,0 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
3
- import React, { useRef, useImperativeHandle } from 'react';
4
- import PropTypes from 'prop-types';
5
- import { Select as RSelect } from '@rebass/forms';
6
- import { useFocusRing } from '@react-aria/focus';
7
- import { useStatusClasses } from '../../hooks';
8
- /**
9
- * Basic dropdown menu input.
10
- * Accepts most styling props from [styled-system](https://styled-system.com/table).
11
- * Built on top of the [Select component from Rebass Forms](https://rebassjs.org/forms/select).
12
- */
13
-
14
- import { jsx as ___EmotionJSX } from "@emotion/react";
15
- var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
- var className = props.className,
17
- children = props.children,
18
- hasNoneOption = props.hasNoneOption,
19
- hasDisabledFirstOption = props.hasDisabledFirstOption,
20
- firstLabel = props.firstLabel,
21
- noneLabel = props.noneLabel,
22
- defaultValue = props.defaultValue,
23
- value = props.value,
24
- others = _objectWithoutProperties(props, ["className", "children", "hasNoneOption", "hasDisabledFirstOption", "firstLabel", "noneLabel", "defaultValue", "value"]);
25
-
26
- var dropdownRef = useRef();
27
- /* istanbul ignore next */
28
-
29
- useImperativeHandle(ref, function () {
30
- return dropdownRef.current;
31
- });
32
-
33
- var _useFocusRing = useFocusRing(),
34
- isFocusVisible = _useFocusRing.isFocusVisible,
35
- focusProps = _useFocusRing.focusProps;
36
-
37
- var _useStatusClasses = useStatusClasses(className, {
38
- isFocused: isFocusVisible
39
- }),
40
- classNames = _useStatusClasses.classNames;
41
-
42
- return ___EmotionJSX(RSelect, _extends({
43
- ref: dropdownRef,
44
- className: classNames,
45
- defaultValue: value ? undefined : defaultValue || '',
46
- value: value
47
- }, others, focusProps), !hasNoneOption && ___EmotionJSX("option", {
48
- key: "__empty",
49
- value: "",
50
- disabled: hasDisabledFirstOption
51
- }, firstLabel), hasNoneOption && ___EmotionJSX(React.Fragment, null, ___EmotionJSX("option", {
52
- key: "__empty",
53
- value: "",
54
- disabled: hasDisabledFirstOption
55
- }, noneLabel || firstLabel), ___EmotionJSX("option", {
56
- key: "__spacer",
57
- disabled: true
58
- }, "--------")), children);
59
- });
60
- Dropdown.propTypes = {
61
- /** Displays a none option within the dropdown options */
62
- hasNoneOption: PropTypes.bool,
63
-
64
- /** Whether the first option is disabled. Useful to prevent reselection of the first option. */
65
- hasDisabledFirstOption: PropTypes.bool,
66
-
67
- /** Id of the selected element */
68
- id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
69
-
70
- /** Label for first option. */
71
- firstLabel: PropTypes.string,
72
-
73
- /** Label for none option. `firstLabel` prop can also be used. */
74
- noneLabel: PropTypes.string,
75
-
76
- /** Value of the select (controlled). */
77
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
78
-
79
- /** Default value of the select (uncontrolled). */
80
- defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
81
-
82
- /** Handler that is called when the element's selection state changes. */
83
- onChange: PropTypes.func
84
- };
85
- Dropdown.defaultProps = {
86
- hasNoneOption: false,
87
- firstLabel: 'Select an option'
88
- };
89
- Dropdown.displayName = 'Dropdown';
90
- export default Dropdown;
@@ -1,62 +0,0 @@
1
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
2
- import React from 'react';
3
- import axeTest from '../../utils/testUtils/testAxe';
4
- import { render, screen, within } from '../../utils/testUtils/testWrapper';
5
- import Dropdown from '.';
6
- import { jsx as ___EmotionJSX } from "@emotion/react";
7
- var testId = 'test-box';
8
- var defaultProps = {
9
- 'data-testid': testId
10
- };
11
-
12
- var getComponent = function getComponent() {
13
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
14
- var children = props.children;
15
- return render(___EmotionJSX(Dropdown, _extends({}, defaultProps, props), children));
16
- }; // Need to be added to each test file to test accessibility using axe.
17
-
18
-
19
- axeTest(getComponent, {
20
- // Dropdown with label provided by DropdownField
21
- rules: {
22
- 'select-name': {
23
- enabled: false
24
- }
25
- }
26
- });
27
- test('dropdown renders', function () {
28
- getComponent();
29
- var dropdown = screen.getByTestId(testId);
30
- expect(dropdown).toBeInstanceOf(HTMLSelectElement);
31
- expect(dropdown).toBeInTheDocument();
32
- });
33
- test('hasNoneOption prop renders none option', function () {
34
- getComponent({
35
- hasNoneOption: true,
36
- noneLabel: 'None'
37
- });
38
- expect(within(document).getByText('None')).toBeInTheDocument();
39
- });
40
- test('default option is first one', function () {
41
- getComponent();
42
- var firstOption = screen.getByRole('option');
43
- expect(firstOption.value).toEqual('');
44
- expect(firstOption).toHaveAttribute('selected', '');
45
- expect(firstOption).toBeEnabled();
46
- });
47
- test('default option is disabled when hasDisabledFirstOption is passed in', function () {
48
- getComponent({
49
- hasDisabledFirstOption: true
50
- });
51
- var firstOption = screen.getByRole('option');
52
- expect(firstOption.value).toEqual('');
53
- expect(firstOption).toHaveAttribute('selected', '');
54
- expect(firstOption).toBeDisabled();
55
- });
56
- test('default option is not first one when custom defaultValue is passed in', function () {
57
- getComponent({
58
- defaultValue: '1'
59
- });
60
- var firstOption = screen.getByRole('option');
61
- expect(firstOption).not.toHaveAttribute('selected', '');
62
- });
@@ -1 +0,0 @@
1
- export { default } from './Dropdown';
@@ -1,155 +0,0 @@
1
- import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
2
- import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
3
- import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
4
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
- import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
6
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
7
- import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
8
- import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
9
- import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
10
- import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
11
- import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
12
-
13
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
14
-
15
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty(_context = ownKeys(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context2; _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
-
17
- import React, { forwardRef, useRef, useImperativeHandle } from 'react';
18
- import PropTypes from 'prop-types'; // TODO: Deprecate this component in Astro-UI 1.0.0
19
-
20
- import { useDeprecationWarning, useField } from '../../hooks';
21
- import statuses from '../../utils/devUtils/constants/statuses';
22
- import Box from '../Box';
23
- import Dropdown from '../Dropdown';
24
- import FieldHelperText from '../FieldHelperText';
25
- import Label from '../Label';
26
- /**
27
- * **WARNING: Will be deprecated in Astro 1.0.0, use `SelectField` instead.**
28
- *
29
- * Combines a dropdown, label, and helper text for a complete, form-ready solution.
30
- */
31
-
32
- import { jsx as ___EmotionJSX } from "@emotion/react";
33
- var DropdownField = /*#__PURE__*/forwardRef(function (props, ref) {
34
- var children = props.children,
35
- controlProps = props.controlProps,
36
- firstLabel = props.firstLabel,
37
- hasAutoFocus = props.hasAutoFocus,
38
- hasDisabledFirstOption = props.hasDisabledFirstOption,
39
- hasNoneOption = props.hasNoneOption,
40
- helperText = props.helperText,
41
- noneLabel = props.noneLabel,
42
- status = props.status;
43
-
44
- var _useField = useField(_objectSpread({
45
- autoFocus: hasAutoFocus,
46
- controlProps: _objectSpread({
47
- firstLabel: firstLabel,
48
- hasDisabledFirstOption: hasDisabledFirstOption,
49
- hasNoneOption: hasNoneOption,
50
- noneLabel: noneLabel
51
- }, controlProps)
52
- }, props)),
53
- fieldContainerProps = _useField.fieldContainerProps,
54
- fieldControlProps = _useField.fieldControlProps,
55
- fieldLabelProps = _useField.fieldLabelProps;
56
-
57
- var dropdownRef = useRef();
58
- /* istanbul ignore next */
59
-
60
- useImperativeHandle(ref, function () {
61
- return dropdownRef.current;
62
- });
63
- useDeprecationWarning('`DropdownField` will be deprecated in Astro-UI 1.0.0, use `SelectField` instead.');
64
- return ___EmotionJSX(Box, fieldContainerProps, ___EmotionJSX(Label, fieldLabelProps), ___EmotionJSX(Box, {
65
- variant: "forms.input.container",
66
- className: fieldControlProps.className
67
- }, ___EmotionJSX(Dropdown, _extends({
68
- ref: dropdownRef
69
- }, fieldControlProps), children)), helperText && ___EmotionJSX(FieldHelperText, {
70
- status: status
71
- }, helperText));
72
- });
73
- DropdownField.propTypes = {
74
- /** The default value of the select field (uncontrolled). */
75
- defaultValue: PropTypes.string,
76
-
77
- /** The value of the select field (controlled). */
78
- value: PropTypes.string,
79
-
80
- /** Displays a none option within the dropdown options */
81
- hasNoneOption: PropTypes.bool,
82
-
83
- /** Whether the first option is disabled. Useful to prevent reselection of the first option. */
84
- hasDisabledFirstOption: PropTypes.bool,
85
-
86
- /** Label for first option. */
87
- firstLabel: PropTypes.string,
88
-
89
- /** Label for none option. `firstLabel` prop can also be used. */
90
- noneLabel: PropTypes.string,
91
-
92
- /** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
93
- id: PropTypes.string,
94
-
95
- /** Whether the Dropdown is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required). */
96
- isRequired: PropTypes.bool,
97
-
98
- /** @ignore Whether the Dropdown can be interacted
99
- * with but cannot have its selection state changed. */
100
- isReadOnly: PropTypes.bool,
101
-
102
- /** Whether the element should receive focus on render. */
103
- hasAutoFocus: PropTypes.bool,
104
-
105
- /** Whether the field has a status indicator. */
106
- hasNoStatusIndicator: PropTypes.bool,
107
-
108
- /** Text to display after the radio group label. Useful for errors or other info. */
109
- helperText: PropTypes.node,
110
-
111
- /** If present this prop will cause a help hint to render in the label of the field. */
112
- hintText: PropTypes.string,
113
-
114
- /** Determines the helper text styling. */
115
- status: PropTypes.oneOf(_Object$values(statuses)),
116
-
117
- /** Handler that is called when the element receives focus. */
118
- onFocus: PropTypes.func,
119
-
120
- /** Handler that is called when the element loses focus. */
121
- onBlur: PropTypes.func,
122
-
123
- /** Handler that is called when the element's focus status changes. */
124
- onFocusChange: PropTypes.func,
125
-
126
- /** Handler that is called when a key is pressed. */
127
- onKeyDown: PropTypes.func,
128
-
129
- /** Handler that is called when a key is released. */
130
- onKeyUp: PropTypes.func,
131
-
132
- /** Defines a string value that labels the current element. */
133
- 'aria-label': PropTypes.string,
134
-
135
- /** Identifies the element (or elements) that labels the current element. */
136
- 'aria-labelledby': PropTypes.string,
137
-
138
- /** Identifies the element (or elements) that describes the object. */
139
- 'aria-describedby': PropTypes.string,
140
-
141
- /**
142
- * Identifies the element (or elements) that provide a detailed, extended description for the
143
- * object.
144
- */
145
- 'aria-details': PropTypes.string,
146
-
147
- /** Props object that is spread directly into the select element. */
148
- controlProps: PropTypes.shape({})
149
- };
150
- DropdownField.defaultProps = {
151
- hasNoneOption: false,
152
- firstLabel: 'Select an option'
153
- };
154
- DropdownField.displayName = 'DropdownField';
155
- export default DropdownField;