@automattic/vip-design-system 2.10.1 → 2.10.2
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.
- package/babel.config.js +23 -19
- package/build/declaration.d.js +0 -1
- package/build/system/Accordion/Accordion.js +28 -33
- package/build/system/Accordion/Accordion.stories.js +34 -35
- package/build/system/Accordion/Accordion.test.js +35 -34
- package/build/system/Accordion/index.js +5 -8
- package/build/system/Avatar/Avatar.js +13 -17
- package/build/system/Avatar/Avatar.stories.js +10 -12
- package/build/system/Avatar/Avatar.test.js +15 -14
- package/build/system/Avatar/index.js +4 -6
- package/build/system/Badge/Badge.js +9 -14
- package/build/system/Badge/Badge.stories.js +23 -23
- package/build/system/Badge/Badge.test.js +15 -14
- package/build/system/Badge/index.js +4 -6
- package/build/system/Box/Box.js +9 -13
- package/build/system/Box/Box.stories.js +5 -8
- package/build/system/Breadcrumbs/Breadcrumbs.js +34 -38
- package/build/system/Breadcrumbs/Breadcrumbs.stories.js +18 -21
- package/build/system/Breadcrumbs/Breadcrumbs.test.js +28 -30
- package/build/system/Breadcrumbs/styles.js +5 -9
- package/build/system/Button/Button.js +11 -17
- package/build/system/Button/Button.stories.js +34 -33
- package/build/system/Button/Button.test.js +17 -16
- package/build/system/Button/ButtonSubmit.js +12 -16
- package/build/system/Button/ButtonSubmit.stories.js +12 -16
- package/build/system/Button/ButtonSubmit.test.js +15 -14
- package/build/system/Button/index.js +5 -8
- package/build/system/Card/Card.js +12 -14
- package/build/system/Card/Card.stories.js +21 -24
- package/build/system/Card/Card.test.js +19 -18
- package/build/system/Card/index.js +4 -6
- package/build/system/Code/Code.js +19 -23
- package/build/system/Code/Code.stories.js +16 -18
- package/build/system/Code/Code.test.js +20 -19
- package/build/system/Code/index.js +4 -6
- package/build/system/Drawer/Drawer.js +25 -30
- package/build/system/Drawer/Drawer.stories.js +38 -39
- package/build/system/Drawer/Drawer.test.js +19 -18
- package/build/system/Drawer/styles.js +9 -11
- package/build/system/Dropdown/Dropdown.js +23 -26
- package/build/system/Dropdown/Dropdown.test.js +16 -18
- package/build/system/Dropdown/DropdownContent.js +14 -20
- package/build/system/Dropdown/DropdownItem.js +19 -25
- package/build/system/Dropdown/DropdownLabel.js +10 -16
- package/build/system/Dropdown/DropdownSeparator.js +10 -16
- package/build/system/Dropdown/index.js +20 -23
- package/build/system/FilterDropdown/FilterDropdown.js +23 -29
- package/build/system/FilterDropdown/FilterDropdown.stories.js +9 -11
- package/build/system/FilterDropdown/FilterDropdown.test.js +7 -10
- package/build/system/Flex/Flex.js +7 -10
- package/build/system/Flex/Flex.stories.js +6 -10
- package/build/system/Flex/index.js +4 -6
- package/build/system/Footer/Footer.d.ts +33 -0
- package/build/system/Footer/Footer.js +82 -0
- package/build/system/Footer/Footer.stories.d.ts +41 -0
- package/build/system/Footer/Footer.stories.js +53 -0
- package/build/system/Footer/Footer.test.d.ts +1 -0
- package/build/system/Footer/Footer.test.js +36 -0
- package/build/system/Form/Checkbox/Checkbox.js +14 -18
- package/build/system/Form/Checkbox/Checkbox.stories.js +47 -48
- package/build/system/Form/Checkbox/Checkbox.test.js +23 -21
- package/build/system/Form/Checkbox/styles.js +7 -10
- package/build/system/Form/Input.js +19 -18
- package/build/system/Form/Input.stories.js +16 -18
- package/build/system/Form/Input.styles.js +5 -9
- package/build/system/Form/Label.js +14 -16
- package/build/system/Form/Label.stories.js +15 -15
- package/build/system/Form/Radio/Radio.js +13 -18
- package/build/system/Form/Radio/Radio.stories.js +43 -43
- package/build/system/Form/Radio/Radio.test.js +19 -18
- package/build/system/Form/Radio/RadioOption.js +22 -23
- package/build/system/Form/Radio/styles.js +7 -10
- package/build/system/Form/RadioGroupChip.js +26 -29
- package/build/system/Form/RadioGroupChip.stories.js +12 -15
- package/build/system/Form/RadioGroupChip.test.js +12 -11
- package/build/system/Form/RequiredLabel.js +3 -7
- package/build/system/Form/Toggle.js +11 -16
- package/build/system/Form/Toggle.stories.js +25 -27
- package/build/system/Form/Toggle.test.js +12 -11
- package/build/system/Form/Validation.js +10 -12
- package/build/system/Grid/Grid.js +7 -10
- package/build/system/Grid/Grid.stories.js +6 -10
- package/build/system/Grid/index.js +4 -6
- package/build/system/Heading/Heading.js +9 -14
- package/build/system/Heading/Heading.stories.js +13 -16
- package/build/system/Hr/Hr.js +3 -7
- package/build/system/Hr/Hr.stories.js +10 -11
- package/build/system/Hr/Hr.test.js +14 -14
- package/build/system/Link/Link.js +11 -14
- package/build/system/Link/Link.stories.js +11 -14
- package/build/system/Link/index.js +4 -6
- package/build/system/LinkExternal/LinkExternal.d.ts +23 -3
- package/build/system/LinkExternal/LinkExternal.js +17 -23
- package/build/system/LinkExternal/LinkExternal.stories.d.ts +1 -8
- package/build/system/LinkExternal/LinkExternal.stories.js +4 -9
- package/build/system/LinkExternal/LinkExternal.test.js +14 -15
- package/build/system/MobileMenu/MobileMenu.js +24 -29
- package/build/system/MobileMenu/MobileMenu.stories.js +66 -67
- package/build/system/MobileMenu/MobileMenu.test.js +21 -22
- package/build/system/Nav/Nav.js +26 -32
- package/build/system/Nav/Nav.stories.js +97 -99
- package/build/system/Nav/Nav.test.js +32 -28
- package/build/system/Nav/NavItem.js +40 -45
- package/build/system/Nav/NavItemGroup.js +34 -39
- package/build/system/Nav/NavItemGroup.test.js +26 -23
- package/build/system/Nav/styles/variants/breadcrumbs.js +4 -7
- package/build/system/Nav/styles/variants/menu.js +8 -12
- package/build/system/Nav/styles/variants/menugroup.js +7 -11
- package/build/system/Nav/styles/variants/primary.js +4 -8
- package/build/system/Nav/styles/variants/tabs.js +3 -7
- package/build/system/Nav/styles/variants/toolbar.js +5 -8
- package/build/system/Nav/styles.js +26 -29
- package/build/system/NewDialog/DialogClose.js +14 -18
- package/build/system/NewDialog/DialogClose.test.js +11 -14
- package/build/system/NewDialog/DialogDescription.js +9 -15
- package/build/system/NewDialog/DialogOverlay.js +11 -13
- package/build/system/NewDialog/DialogTitle.js +7 -15
- package/build/system/NewDialog/NewDialog.js +24 -29
- package/build/system/NewDialog/index.js +7 -11
- package/build/system/NewDialog/styles.js +1 -5
- package/build/system/NewForm/Fieldset.js +13 -17
- package/build/system/NewForm/Form.js +8 -13
- package/build/system/NewForm/FormAutocomplete.js +2 -2
- package/build/system/NewForm/Legend.js +11 -15
- package/build/system/Notice/Notice.js +22 -25
- package/build/system/Notice/Notice.stories.js +41 -43
- package/build/system/Notice/index.js +5 -5
- package/build/system/Page/Page.js +4 -8
- package/build/system/Page/Page.test.js +14 -14
- package/build/system/Progress/Progress.js +21 -24
- package/build/system/Progress/Progress.stories.js +9 -15
- package/build/system/Progress/Progress.test.js +14 -13
- package/build/system/Progress/index.js +4 -6
- package/build/system/ScreenReaderText/ScreenReaderText.js +9 -9
- package/build/system/Spinner/Spinner.js +9 -14
- package/build/system/Spinner/Spinner.stories.js +6 -10
- package/build/system/Spinner/Spinner.test.js +14 -13
- package/build/system/Spinner/index.js +1 -6
- package/build/system/Table/Table.js +20 -22
- package/build/system/Table/Table.stories.js +29 -30
- package/build/system/Table/TableCell.js +9 -11
- package/build/system/Table/TableRow.js +10 -11
- package/build/system/Table/index.js +6 -10
- package/build/system/Text/Text.js +9 -14
- package/build/system/Text/Text.stories.js +24 -25
- package/build/system/Text/index.js +4 -6
- package/build/system/Toolbar/Logo.js +11 -15
- package/build/system/Toolbar/Toolbar.js +12 -17
- package/build/system/Toolbar/Toolbar.stories.js +47 -50
- package/build/system/Toolbar/Toolbar.test.js +26 -24
- package/build/system/Toolbar/ToolbarUtilNav.js +9 -16
- package/build/system/Toolbar/index.js +10 -15
- package/build/system/Tooltip/Tooltip.js +9 -14
- package/build/system/Tooltip/Tooltip.stories.js +29 -31
- package/build/system/Tooltip/index.js +5 -5
- package/build/system/Wizard/Wizard.js +11 -18
- package/build/system/Wizard/Wizard.stories.js +37 -38
- package/build/system/Wizard/WizardStep.js +26 -32
- package/build/system/Wizard/index.js +6 -7
- package/build/system/assets/a8cLogo.d.ts +2 -0
- package/build/system/assets/a8cLogo.js +39 -0
- package/build/system/theme/breakpoints.js +1 -5
- package/build/system/utils/stories/CustomLink.js +7 -13
- package/package.json +1 -1
- package/src/system/Footer/Footer.stories.tsx +46 -0
- package/src/system/Footer/Footer.test.tsx +40 -0
- package/src/system/Footer/Footer.tsx +120 -0
- package/src/system/LinkExternal/LinkExternal.tsx +27 -8
- package/src/system/NewForm/FormAutocomplete.js +2 -2
- package/src/system/assets/a8cLogo.tsx +30 -0
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.Input = void 0;
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
var _themeUi = require("theme-ui");
|
|
7
|
-
var _Input = require("./Input.styles");
|
|
8
|
-
var _ = require("../");
|
|
9
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
10
1
|
var _excluded = ["label", "forLabel", "hasError", "required", "sx", "errorMessage"];
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
2
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
/** @jsxImportSource theme-ui */
|
|
5
|
+
|
|
6
|
+
/**
|
|
14
7
|
* External dependencies
|
|
15
|
-
*/
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Input as ThemeInput } from 'theme-ui';
|
|
11
|
+
|
|
12
|
+
/**
|
|
16
13
|
* Internal dependencies
|
|
17
14
|
*/
|
|
15
|
+
import { baseControlStyle } from './Input.styles';
|
|
16
|
+
import { Validation, Label } from '../';
|
|
17
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
18
19
|
var inputStyles = _extends({
|
|
19
20
|
unset: 'all'
|
|
20
|
-
},
|
|
21
|
+
}, baseControlStyle, {
|
|
21
22
|
lineHeight: 'inherit',
|
|
22
23
|
minHeight: '36px',
|
|
23
24
|
px: 3,
|
|
@@ -26,7 +27,7 @@ var inputStyles = _extends({
|
|
|
26
27
|
mb: 2,
|
|
27
28
|
variant: 'inputs.default'
|
|
28
29
|
});
|
|
29
|
-
var Input =
|
|
30
|
+
export var Input = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
30
31
|
var label = _ref.label,
|
|
31
32
|
forLabel = _ref.forLabel,
|
|
32
33
|
_ref$hasError = _ref.hasError,
|
|
@@ -36,12 +37,12 @@ var Input = exports.Input = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
36
37
|
sx = _ref$sx === void 0 ? {} : _ref$sx,
|
|
37
38
|
errorMessage = _ref.errorMessage,
|
|
38
39
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
39
|
-
return (
|
|
40
|
-
children: [label && (
|
|
40
|
+
return _jsxs(React.Fragment, {
|
|
41
|
+
children: [label && _jsx(Label, {
|
|
41
42
|
required: required,
|
|
42
43
|
htmlFor: forLabel,
|
|
43
44
|
children: label
|
|
44
|
-
}), (
|
|
45
|
+
}), _jsx(ThemeInput, _extends({
|
|
45
46
|
ref: ref,
|
|
46
47
|
id: forLabel,
|
|
47
48
|
required: required,
|
|
@@ -50,7 +51,7 @@ var Input = exports.Input = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
50
51
|
sx: _extends({}, inputStyles, sx, hasError ? {
|
|
51
52
|
borderColor: 'input.border.error'
|
|
52
53
|
} : {})
|
|
53
|
-
}, props)), hasError && errorMessage && (
|
|
54
|
+
}, props)), hasError && errorMessage && _jsx(Validation, {
|
|
54
55
|
isValid: false,
|
|
55
56
|
describedId: forLabel,
|
|
56
57
|
children: errorMessage
|
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Default = void 0;
|
|
5
|
-
var _ = require("..");
|
|
6
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
1
|
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
8
3
|
/**
|
|
9
4
|
* Internal dependencies
|
|
10
5
|
*/
|
|
11
|
-
|
|
6
|
+
import { Form } from '..';
|
|
7
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
9
|
+
export default {
|
|
12
10
|
title: 'Form/Input'
|
|
13
11
|
};
|
|
14
|
-
var Default =
|
|
15
|
-
return (
|
|
16
|
-
children: [(
|
|
12
|
+
export var Default = function Default() {
|
|
13
|
+
return _jsxs(Form.Root, {
|
|
14
|
+
children: [_jsx(Form.Input, {
|
|
17
15
|
placeholder: "Your input here...",
|
|
18
16
|
label: "Always add a label to inputs",
|
|
19
17
|
forLabel: "input-simple"
|
|
20
|
-
}), (
|
|
18
|
+
}), _jsx("hr", {
|
|
21
19
|
sx: {
|
|
22
20
|
my: 4
|
|
23
21
|
}
|
|
24
|
-
}), (
|
|
22
|
+
}), _jsx(Form.Input, {
|
|
25
23
|
forLabel: "input-with-error",
|
|
26
24
|
label: "Error Input",
|
|
27
25
|
errorMessage: "Please type numeric characters only",
|
|
28
26
|
hasError: true
|
|
29
|
-
}), (
|
|
27
|
+
}), _jsx("hr", {
|
|
30
28
|
sx: {
|
|
31
29
|
my: 4
|
|
32
30
|
}
|
|
33
|
-
}), (
|
|
31
|
+
}), _jsx(Form.Input, {
|
|
34
32
|
forLabel: "input-with-required",
|
|
35
33
|
label: "Required",
|
|
36
34
|
required: true
|
|
37
|
-
}), (
|
|
35
|
+
}), _jsx("hr", {
|
|
38
36
|
sx: {
|
|
39
37
|
my: 4
|
|
40
38
|
}
|
|
41
|
-
}), (
|
|
39
|
+
}), _jsx(Form.Label, {
|
|
42
40
|
htmlFor: "input-with-custom-label",
|
|
43
41
|
children: "Custom Label outside the Input"
|
|
44
|
-
}), (
|
|
42
|
+
}), _jsx(Form.Input, {
|
|
45
43
|
forLabel: "input-with-custom-label",
|
|
46
44
|
required: true
|
|
47
|
-
}), (
|
|
45
|
+
}), _jsx(Form.Input, {
|
|
48
46
|
forLabel: "input-readonly",
|
|
49
47
|
readOnly: true,
|
|
50
48
|
value: "This is a readonly input"
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.inputBaseText = exports.inputBaseBackground = exports.baseControlStyle = exports.baseControlFocusStyle = exports.baseControlBorderStyle = void 0;
|
|
5
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
6
|
-
var baseControlBorderStyle =
|
|
2
|
+
export var baseControlBorderStyle = {
|
|
7
3
|
borderWidth: '1px',
|
|
8
4
|
borderStyle: 'solid',
|
|
9
5
|
borderColor: 'input.border.default'
|
|
10
6
|
};
|
|
11
7
|
// Temporary interface until we add types to the theme definition.
|
|
12
8
|
|
|
13
|
-
var inputBaseText =
|
|
14
|
-
var inputBaseBackground =
|
|
15
|
-
var baseControlFocusStyle =
|
|
9
|
+
export var inputBaseText = 'input.text.default';
|
|
10
|
+
export var inputBaseBackground = 'input.background.default';
|
|
11
|
+
export var baseControlFocusStyle = {
|
|
16
12
|
'&:focus-visible': function focusVisible(theme) {
|
|
17
13
|
return theme.outline;
|
|
18
14
|
},
|
|
@@ -20,7 +16,7 @@ var baseControlFocusStyle = exports.baseControlFocusStyle = {
|
|
|
20
16
|
return theme.outline;
|
|
21
17
|
}
|
|
22
18
|
};
|
|
23
|
-
var baseControlStyle =
|
|
19
|
+
export var baseControlStyle = _extends({}, baseControlBorderStyle, {
|
|
24
20
|
backgroundColor: inputBaseBackground,
|
|
25
21
|
color: inputBaseText,
|
|
26
22
|
borderRadius: 1,
|
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.baseLabelStyle = exports.baseLabelColor = exports.Label = void 0;
|
|
5
|
-
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
var _themeUi = require("theme-ui");
|
|
7
|
-
var _RequiredLabel = require("./RequiredLabel");
|
|
8
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
1
|
var _excluded = ["sx", "children", "required", "clickable", "as"];
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
4
|
/** @jsxImportSource theme-ui */
|
|
5
|
+
|
|
11
6
|
/**
|
|
12
7
|
* External dependencies
|
|
13
8
|
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { Box } from 'theme-ui';
|
|
11
|
+
|
|
14
12
|
/**
|
|
15
13
|
* Internal dependencies
|
|
16
14
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var baseLabelColor =
|
|
21
|
-
var baseLabelStyle =
|
|
15
|
+
import { RequiredLabel } from './RequiredLabel';
|
|
16
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
18
|
+
export var baseLabelColor = 'input.label.default';
|
|
19
|
+
export var baseLabelStyle = {
|
|
22
20
|
fontWeight: 'heading',
|
|
23
21
|
fontSize: 2,
|
|
24
22
|
lineHeight: 1.5,
|
|
25
23
|
color: baseLabelColor
|
|
26
24
|
};
|
|
27
|
-
var Label =
|
|
25
|
+
export var Label = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef) {
|
|
28
26
|
var sx = _ref.sx,
|
|
29
27
|
children = _ref.children,
|
|
30
28
|
required = _ref.required,
|
|
@@ -32,7 +30,7 @@ var Label = exports.Label = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
32
30
|
_ref$as = _ref.as,
|
|
33
31
|
as = _ref$as === void 0 ? 'label' : _ref$as,
|
|
34
32
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
35
|
-
return (
|
|
33
|
+
return _jsxs(Box, _extends({
|
|
36
34
|
as: as,
|
|
37
35
|
sx: _extends({
|
|
38
36
|
all: 'unset'
|
|
@@ -43,7 +41,7 @@ var Label = exports.Label = /*#__PURE__*/_react["default"].forwardRef(function (
|
|
|
43
41
|
}, sx),
|
|
44
42
|
ref: forwardRef
|
|
45
43
|
}, rest, {
|
|
46
|
-
children: [children, required && (
|
|
44
|
+
children: [children, required && _jsx(RequiredLabel, {})]
|
|
47
45
|
}));
|
|
48
46
|
});
|
|
49
47
|
Label.displayName = 'Label';
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/** @jsxImportSource theme-ui */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
exports["default"] = exports.Required = exports.Default = void 0;
|
|
5
|
-
var _ = require("..");
|
|
6
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /** @jsxImportSource theme-ui */ /**
|
|
4
|
+
/**
|
|
8
5
|
* Internal dependencies
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
import { Form, Label } from '..';
|
|
8
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
9
|
+
import { Fragment as _Fragment } from "theme-ui/jsx-runtime";
|
|
10
|
+
export default {
|
|
11
11
|
title: 'Form/Label'
|
|
12
12
|
};
|
|
13
13
|
var DefaultComponent = function DefaultComponent(props) {
|
|
14
|
-
return (
|
|
15
|
-
children: (
|
|
14
|
+
return _jsx(Form.Root, {
|
|
15
|
+
children: _jsx(Label, _extends({}, props, {
|
|
16
16
|
children: "Label"
|
|
17
17
|
}))
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
var Default =
|
|
21
|
-
return (
|
|
22
|
-
children: (
|
|
20
|
+
export var Default = function Default() {
|
|
21
|
+
return _jsx(_Fragment, {
|
|
22
|
+
children: _jsx(DefaultComponent, {})
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
-
var Required =
|
|
25
|
+
export var Required = function Required() {
|
|
26
26
|
var args = {
|
|
27
27
|
required: true
|
|
28
28
|
};
|
|
29
|
-
return (
|
|
30
|
-
children: (
|
|
29
|
+
return _jsx(_Fragment, {
|
|
30
|
+
children: _jsx(DefaultComponent, _extends({}, args))
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.VIP_RADIO = exports.Radio = void 0;
|
|
5
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
6
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
-
var _RadioOption = require("./RadioOption");
|
|
8
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
1
|
var _excluded = ["variant", "disabled", "defaultValue", "onChange", "name", "options", "className"];
|
|
10
|
-
/** @jsxImportSource theme-ui */
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
/** @jsxImportSource theme-ui */
|
|
5
|
+
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import React, { forwardRef } from 'react';
|
|
8
|
+
import { RadioOption } from './RadioOption';
|
|
9
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
10
|
+
export var VIP_RADIO = 'vip-radio-component';
|
|
11
|
+
var Radio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
12
|
var _ref$variant = _ref.variant,
|
|
19
13
|
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
20
14
|
_ref$disabled = _ref.disabled,
|
|
@@ -42,7 +36,7 @@ var Radio = exports.Radio = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
|
42
36
|
}
|
|
43
37
|
};
|
|
44
38
|
var renderedOptions = options.map(function (option) {
|
|
45
|
-
return (
|
|
39
|
+
return _jsx(RadioOption, {
|
|
46
40
|
variant: option != null && option.disabled ? 'disabled' : variant,
|
|
47
41
|
name: name,
|
|
48
42
|
option: option,
|
|
@@ -51,10 +45,11 @@ var Radio = exports.Radio = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
|
51
45
|
checked: "" + defaultValue === "" + (option == null ? void 0 : option.value)
|
|
52
46
|
}, option == null ? void 0 : option.id);
|
|
53
47
|
});
|
|
54
|
-
return (
|
|
48
|
+
return _jsx("div", _extends({
|
|
55
49
|
ref: ref,
|
|
56
|
-
className: (
|
|
50
|
+
className: classNames(VIP_RADIO, VIP_RADIO + "-" + name, className)
|
|
57
51
|
}, props, {
|
|
58
52
|
children: renderedOptions
|
|
59
53
|
}));
|
|
60
|
-
});
|
|
54
|
+
});
|
|
55
|
+
export { Radio };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
/** @jsxImportSource theme-ui */
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _default = exports["default"] = {
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Radio } from './Radio';
|
|
6
|
+
import { Box, Form, Heading, Link } from '../..';
|
|
7
|
+
import { Flex } from '../../Flex';
|
|
8
|
+
import { Label } from '../Label';
|
|
9
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "theme-ui/jsx-runtime";
|
|
12
|
+
export default {
|
|
13
13
|
title: 'Form/Radio',
|
|
14
|
-
component:
|
|
14
|
+
component: Radio,
|
|
15
15
|
parameters: {
|
|
16
16
|
docs: {
|
|
17
17
|
description: {
|
|
@@ -20,8 +20,8 @@ var _default = exports["default"] = {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
var Default =
|
|
24
|
-
var _useState =
|
|
23
|
+
export var Default = function Default() {
|
|
24
|
+
var _useState = useState({}),
|
|
25
25
|
checked = _useState[0],
|
|
26
26
|
setChecked = _useState[1];
|
|
27
27
|
var toggleChecked = function toggleChecked(radioName, value) {
|
|
@@ -31,16 +31,16 @@ var Default = exports.Default = function Default() {
|
|
|
31
31
|
}
|
|
32
32
|
setChecked(_extends({}, checked, (_extends2 = {}, _extends2[radioName] = value, _extends2)));
|
|
33
33
|
};
|
|
34
|
-
return (
|
|
34
|
+
return _jsxs(_Fragment, {
|
|
35
35
|
children: [['primary', 'brand'].map(function (variant) {
|
|
36
|
-
return (
|
|
37
|
-
children: [(
|
|
36
|
+
return _jsxs(Box, {
|
|
37
|
+
children: [_jsx(Heading, {
|
|
38
38
|
as: "h2",
|
|
39
39
|
sx: {
|
|
40
40
|
textTransform: 'capitalize'
|
|
41
41
|
},
|
|
42
42
|
children: variant
|
|
43
|
-
}), (
|
|
43
|
+
}), _jsx(Radio, {
|
|
44
44
|
variant: variant,
|
|
45
45
|
onChange: function onChange(_, option) {
|
|
46
46
|
return toggleChecked("the_option_" + variant, option == null ? void 0 : option.value);
|
|
@@ -58,14 +58,14 @@ var Default = exports.Default = function Default() {
|
|
|
58
58
|
}]
|
|
59
59
|
})]
|
|
60
60
|
}, variant);
|
|
61
|
-
}), (
|
|
62
|
-
children: [(
|
|
61
|
+
}), _jsxs(Box, {
|
|
62
|
+
children: [_jsx(Heading, {
|
|
63
63
|
as: "h2",
|
|
64
64
|
sx: {
|
|
65
65
|
textTransform: 'capitalize'
|
|
66
66
|
},
|
|
67
67
|
children: "disabled"
|
|
68
|
-
}), (
|
|
68
|
+
}), _jsx(Radio, {
|
|
69
69
|
disabled: true,
|
|
70
70
|
name: "the_option_",
|
|
71
71
|
defaultValue: "disabled-option-a",
|
|
@@ -82,26 +82,26 @@ var Default = exports.Default = function Default() {
|
|
|
82
82
|
})]
|
|
83
83
|
});
|
|
84
84
|
};
|
|
85
|
-
var AcessibleExamples =
|
|
86
|
-
return (
|
|
87
|
-
children: [(
|
|
88
|
-
children: ["Per recommendation, if you have a Radio button, use a Fieldset with a legend as wrapper to your options.", ' ', (
|
|
85
|
+
export var AcessibleExamples = function AcessibleExamples() {
|
|
86
|
+
return _jsxs(Form.Root, {
|
|
87
|
+
children: [_jsxs("p", {
|
|
88
|
+
children: ["Per recommendation, if you have a Radio button, use a Fieldset with a legend as wrapper to your options.", ' ', _jsx(Link, {
|
|
89
89
|
href: "https://a11y-collective.github.io/demos/en/accessible-code/form-fieldsets.html",
|
|
90
90
|
children: "Reference to Form fieldsets"
|
|
91
91
|
})]
|
|
92
|
-
}), (
|
|
93
|
-
children: [(
|
|
92
|
+
}), _jsxs(Form.Fieldset, {
|
|
93
|
+
children: [_jsx(Form.Legend, {
|
|
94
94
|
sx: {
|
|
95
95
|
mb: 0,
|
|
96
96
|
fontSize: 2,
|
|
97
97
|
fontWeight: 'bold'
|
|
98
98
|
},
|
|
99
99
|
children: "Apply the policy to these domains"
|
|
100
|
-
}), (
|
|
100
|
+
}), _jsx(Flex, {
|
|
101
101
|
sx: {
|
|
102
102
|
alignItems: 'center'
|
|
103
103
|
},
|
|
104
|
-
children: (
|
|
104
|
+
children: _jsx(Radio, {
|
|
105
105
|
name: "the_option",
|
|
106
106
|
defaultValue: "a",
|
|
107
107
|
options: [{
|
|
@@ -115,25 +115,25 @@ var AcessibleExamples = exports.AcessibleExamples = function AcessibleExamples()
|
|
|
115
115
|
}]
|
|
116
116
|
})
|
|
117
117
|
})]
|
|
118
|
-
}), (
|
|
119
|
-
children: [(
|
|
118
|
+
}), _jsxs(Form.Fieldset, {
|
|
119
|
+
children: [_jsx(Form.Legend, {
|
|
120
120
|
sx: {
|
|
121
121
|
mb: 0,
|
|
122
122
|
fontSize: 2,
|
|
123
123
|
fontWeight: 'bold'
|
|
124
124
|
},
|
|
125
125
|
children: "With a custom Label (Potential A11Y issue, if you don't build manage the label correctly)"
|
|
126
|
-
}), (
|
|
126
|
+
}), _jsx(Flex, {
|
|
127
127
|
sx: {
|
|
128
128
|
alignItems: 'center'
|
|
129
129
|
},
|
|
130
|
-
children: (
|
|
130
|
+
children: _jsx(Radio, {
|
|
131
131
|
name: "the_option_custom",
|
|
132
132
|
defaultValue: "a",
|
|
133
133
|
options: [{
|
|
134
134
|
value: 'a',
|
|
135
135
|
renderLabel: function renderLabel(commonProps, labelStyle) {
|
|
136
|
-
return (
|
|
136
|
+
return _jsx(Label, _extends({}, commonProps, {
|
|
137
137
|
className: "custom-class",
|
|
138
138
|
sx: _extends({}, labelStyle, {
|
|
139
139
|
color: 'error'
|
|
@@ -156,25 +156,25 @@ var AcessibleExamples = exports.AcessibleExamples = function AcessibleExamples()
|
|
|
156
156
|
}]
|
|
157
157
|
})
|
|
158
158
|
})]
|
|
159
|
-
}), (
|
|
159
|
+
}), _jsx("p", {
|
|
160
160
|
id: "describe-radio-all-domains-subdomains",
|
|
161
161
|
sx: {
|
|
162
162
|
mt: 2
|
|
163
163
|
},
|
|
164
164
|
children: "This is a explanation for custom option b"
|
|
165
|
-
}), (
|
|
166
|
-
children: [(
|
|
165
|
+
}), _jsxs(Form.Fieldset, {
|
|
166
|
+
children: [_jsx(Form.Legend, {
|
|
167
167
|
sx: {
|
|
168
168
|
mb: 0,
|
|
169
169
|
fontSize: 2,
|
|
170
170
|
fontWeight: 'bold'
|
|
171
171
|
},
|
|
172
172
|
children: "All disabled options"
|
|
173
|
-
}), (
|
|
173
|
+
}), _jsx(Flex, {
|
|
174
174
|
sx: {
|
|
175
175
|
alignItems: 'center'
|
|
176
176
|
},
|
|
177
|
-
children: (
|
|
177
|
+
children: _jsx(Radio, {
|
|
178
178
|
disabled: true,
|
|
179
179
|
name: "the_option_disabled",
|
|
180
180
|
defaultValue: 'a_disabled',
|
|
@@ -189,19 +189,19 @@ var AcessibleExamples = exports.AcessibleExamples = function AcessibleExamples()
|
|
|
189
189
|
}]
|
|
190
190
|
})
|
|
191
191
|
})]
|
|
192
|
-
}), (
|
|
193
|
-
children: [(
|
|
192
|
+
}), _jsxs(Form.Fieldset, {
|
|
193
|
+
children: [_jsx(Form.Legend, {
|
|
194
194
|
sx: {
|
|
195
195
|
mb: 0,
|
|
196
196
|
fontSize: 2,
|
|
197
197
|
fontWeight: 'bold'
|
|
198
198
|
},
|
|
199
199
|
children: "Only one Disabled option"
|
|
200
|
-
}), (
|
|
200
|
+
}), _jsx(Flex, {
|
|
201
201
|
sx: {
|
|
202
202
|
alignItems: 'center'
|
|
203
203
|
},
|
|
204
|
-
children: (
|
|
204
|
+
children: _jsx(Radio, {
|
|
205
205
|
name: "the_option_disabled_two",
|
|
206
206
|
defaultValue: 'a_disabled_two',
|
|
207
207
|
options: [{
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@testing-library/react");
|
|
4
|
-
var _jestAxe = require("jest-axe");
|
|
5
|
-
var _Radio = require("./Radio");
|
|
6
|
-
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
7
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
8
2
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
/**
|
|
11
6
|
* External dependencies
|
|
12
|
-
*/
|
|
7
|
+
*/
|
|
8
|
+
import { render, screen } from '@testing-library/react';
|
|
9
|
+
import { axe } from 'jest-axe';
|
|
10
|
+
|
|
11
|
+
/**
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
14
|
+
import { Radio } from './Radio';
|
|
15
|
+
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
15
16
|
describe('<Radio />', function () {
|
|
16
17
|
it('renders', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
17
18
|
var _render, container;
|
|
18
19
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
19
20
|
while (1) switch (_context.prev = _context.next) {
|
|
20
21
|
case 0:
|
|
21
|
-
_render =
|
|
22
|
+
_render = render(_jsx(Radio, {
|
|
22
23
|
disabled: true,
|
|
23
24
|
name: "the_option_",
|
|
24
25
|
defaultValue: "disabled-option-a",
|
|
@@ -32,13 +33,13 @@ describe('<Radio />', function () {
|
|
|
32
33
|
label: "I am the option B"
|
|
33
34
|
}]
|
|
34
35
|
})), container = _render.container;
|
|
35
|
-
expect(
|
|
36
|
-
expect(
|
|
36
|
+
expect(screen.getByLabelText('I am the option A')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByLabelText('I am the option B')).toBeInTheDocument();
|
|
37
38
|
|
|
38
39
|
// Check for accessibility issues
|
|
39
40
|
_context.t0 = expect;
|
|
40
41
|
_context.next = 6;
|
|
41
|
-
return
|
|
42
|
+
return axe(container);
|
|
42
43
|
case 6:
|
|
43
44
|
_context.t1 = _context.sent;
|
|
44
45
|
(0, _context.t0)(_context.t1).toHaveNoViolations();
|
|
@@ -53,7 +54,7 @@ describe('<Radio />', function () {
|
|
|
53
54
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
54
55
|
while (1) switch (_context2.prev = _context2.next) {
|
|
55
56
|
case 0:
|
|
56
|
-
_render2 =
|
|
57
|
+
_render2 = render(_jsx(Radio, {
|
|
57
58
|
disabled: true,
|
|
58
59
|
name: "the_option_",
|
|
59
60
|
defaultValue: "disabled-option-a",
|
|
@@ -62,11 +63,11 @@ describe('<Radio />', function () {
|
|
|
62
63
|
value: "disabled-option-a",
|
|
63
64
|
label: 'I am ignored',
|
|
64
65
|
renderLabel: function renderLabel(props, labelStyles) {
|
|
65
|
-
return (
|
|
66
|
+
return _jsx("label", _extends({
|
|
66
67
|
htmlFor: "disabled-option-a"
|
|
67
68
|
}, props, {
|
|
68
69
|
sx: labelStyles,
|
|
69
|
-
children: (
|
|
70
|
+
children: _jsx("span", {
|
|
70
71
|
children: "I am the custom option A"
|
|
71
72
|
})
|
|
72
73
|
}));
|
|
@@ -77,13 +78,13 @@ describe('<Radio />', function () {
|
|
|
77
78
|
label: "I am the option B"
|
|
78
79
|
}]
|
|
79
80
|
})), container = _render2.container;
|
|
80
|
-
expect(
|
|
81
|
-
expect(
|
|
81
|
+
expect(screen.getByLabelText('I am the custom option A')).toBeInTheDocument();
|
|
82
|
+
expect(screen.getByLabelText('I am the option B')).toBeInTheDocument();
|
|
82
83
|
|
|
83
84
|
// Check for accessibility issues
|
|
84
85
|
_context2.t0 = expect;
|
|
85
86
|
_context2.next = 6;
|
|
86
|
-
return
|
|
87
|
+
return axe(container);
|
|
87
88
|
case 6:
|
|
88
89
|
_context2.t1 = _context2.sent;
|
|
89
90
|
(0, _context2.t0)(_context2.t1).toHaveNoViolations();
|