@primer/components 31.2.0-rc.85bcb6e0 → 31.2.0-rc.881e6b2d
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/CHANGELOG.md +11 -1
- package/dist/browser.esm.js +620 -618
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +188 -186
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +354 -0
- package/docs/content/StateLabel.md +5 -4
- package/docs/content/getting-started.md +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/components/hero.js +1 -3
- package/docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js +1 -1
- package/docs/src/@primer/gatsby-theme-doctocat/live-code-scope.js +17 -0
- package/lib/ActionList2/Description.d.ts +12 -0
- package/lib/ActionList2/Description.js +53 -0
- package/lib/ActionList2/Divider.d.ts +5 -0
- package/lib/ActionList2/Divider.js +35 -0
- package/lib/ActionList2/Group.d.ts +11 -0
- package/lib/ActionList2/Group.js +57 -0
- package/lib/ActionList2/Header.d.ts +26 -0
- package/lib/ActionList2/Header.js +55 -0
- package/lib/ActionList2/Item.d.ts +63 -0
- package/lib/ActionList2/Item.js +244 -0
- package/lib/ActionList2/LinkItem.d.ts +17 -0
- package/lib/ActionList2/LinkItem.js +57 -0
- package/lib/ActionList2/List.d.ts +26 -0
- package/lib/ActionList2/List.js +59 -0
- package/lib/ActionList2/Selection.d.ts +5 -0
- package/lib/ActionList2/Selection.js +70 -0
- package/lib/ActionList2/Visuals.d.ts +9 -0
- package/lib/ActionList2/Visuals.js +90 -0
- package/lib/ActionList2/index.d.ts +36 -0
- package/lib/ActionList2/index.js +47 -0
- package/lib/StateLabel.d.ts +1 -1
- package/lib/StateLabel.js +6 -1
- package/lib/_TextInputWrapper.js +2 -2
- package/lib/__tests__/ActionList2.test.d.ts +1 -0
- package/lib/__tests__/ActionList2.test.js +53 -0
- package/lib/__tests__/AnchoredOverlay.test.js +4 -2
- package/lib/__tests__/TextInputWithTokens.test.js +1 -10
- package/lib/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib/__tests__/utils/createSlots.test.js +75 -0
- package/lib/stories/ActionList2.stories.js +907 -0
- package/lib/stories/TextInput.stories.js +144 -0
- package/lib/sx.d.ts +2 -0
- package/lib/sx.js +8 -0
- package/lib/theme-preval.js +81 -2
- package/lib/unreleased.d.ts +7 -0
- package/lib/unreleased.js +18 -0
- package/lib/utils/create-slots.d.ts +17 -0
- package/lib/utils/create-slots.js +105 -0
- package/lib/utils/testing.d.ts +14 -1
- package/lib/utils/use-force-update.d.ts +1 -0
- package/lib/utils/use-force-update.js +19 -0
- package/lib-esm/ActionList2/Description.d.ts +12 -0
- package/lib-esm/ActionList2/Description.js +37 -0
- package/lib-esm/ActionList2/Divider.d.ts +5 -0
- package/lib-esm/ActionList2/Divider.js +23 -0
- package/lib-esm/ActionList2/Group.d.ts +11 -0
- package/lib-esm/ActionList2/Group.js +40 -0
- package/lib-esm/ActionList2/Header.d.ts +26 -0
- package/lib-esm/ActionList2/Header.js +44 -0
- package/lib-esm/ActionList2/Item.d.ts +63 -0
- package/lib-esm/ActionList2/Item.js +210 -0
- package/lib-esm/ActionList2/LinkItem.d.ts +17 -0
- package/lib-esm/ActionList2/LinkItem.js +43 -0
- package/lib-esm/ActionList2/List.d.ts +26 -0
- package/lib-esm/ActionList2/List.js +37 -0
- package/lib-esm/ActionList2/Selection.d.ts +5 -0
- package/lib-esm/ActionList2/Selection.js +52 -0
- package/lib-esm/ActionList2/Visuals.d.ts +9 -0
- package/lib-esm/ActionList2/Visuals.js +68 -0
- package/lib-esm/ActionList2/index.d.ts +36 -0
- package/lib-esm/ActionList2/index.js +33 -0
- package/lib-esm/StateLabel.d.ts +1 -1
- package/lib-esm/StateLabel.js +7 -2
- package/lib-esm/_TextInputWrapper.js +2 -2
- package/lib-esm/__tests__/ActionList2.test.d.ts +1 -0
- package/lib-esm/__tests__/ActionList2.test.js +41 -0
- package/lib-esm/__tests__/AnchoredOverlay.test.js +4 -2
- package/lib-esm/__tests__/TextInputWithTokens.test.js +1 -10
- package/lib-esm/__tests__/utils/createSlots.test.d.ts +1 -0
- package/lib-esm/__tests__/utils/createSlots.test.js +67 -0
- package/lib-esm/stories/ActionList2.stories.js +796 -0
- package/lib-esm/stories/TextInput.stories.js +117 -0
- package/lib-esm/sx.d.ts +2 -0
- package/lib-esm/sx.js +3 -1
- package/lib-esm/theme-preval.js +81 -2
- package/lib-esm/unreleased.d.ts +7 -0
- package/lib-esm/unreleased.js +8 -0
- package/lib-esm/utils/create-slots.d.ts +17 -0
- package/lib-esm/utils/create-slots.js +84 -0
- package/lib-esm/utils/testing.d.ts +14 -1
- package/lib-esm/utils/use-force-update.d.ts +1 -0
- package/lib-esm/utils/use-force-update.js +6 -0
- package/migrating.md +1 -1
- package/package-lock.json +153 -14
- package/package.json +6 -4
- package/src/ActionList2/Description.tsx +49 -0
- package/src/ActionList2/Divider.tsx +24 -0
- package/src/ActionList2/Group.tsx +34 -0
- package/src/ActionList2/Header.tsx +58 -0
- package/src/ActionList2/Item.tsx +245 -0
- package/src/ActionList2/LinkItem.tsx +49 -0
- package/src/ActionList2/List.tsx +55 -0
- package/src/ActionList2/Selection.tsx +40 -0
- package/src/ActionList2/Visuals.tsx +76 -0
- package/src/ActionList2/index.ts +39 -0
- package/src/StateLabel.tsx +14 -2
- package/src/_TextInputWrapper.tsx +7 -0
- package/src/__tests__/ActionList2.test.tsx +47 -0
- package/src/__tests__/AnchoredOverlay.test.tsx +2 -2
- package/src/__tests__/TextInputWithTokens.test.tsx +0 -10
- package/src/__tests__/__snapshots__/ActionList2.test.tsx.snap +14 -0
- package/src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap +35 -135
- package/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/CircleBadge.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/CircleOcticon.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/Dialog.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/DropdownMenu.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/SelectMenu.test.tsx.snap +4 -0
- package/src/__tests__/__snapshots__/SelectPanel.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/StateLabel.test.tsx.snap +13 -6
- package/src/__tests__/__snapshots__/StyledOcticon.test.tsx.snap +1 -0
- package/src/__tests__/__snapshots__/TextInputWithTokens.test.tsx.snap +66 -0
- package/src/__tests__/__snapshots__/Token.test.tsx.snap +17 -0
- package/src/__tests__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
- package/src/__tests__/utils/createSlots.test.tsx +74 -0
- package/src/stories/ActionList2.stories.tsx +1288 -0
- package/src/stories/TextInput.stories.tsx +113 -0
- package/src/sx.ts +3 -0
- package/src/theme-preval.js +1 -0
- package/src/unreleased.ts +9 -0
- package/src/utils/create-slots.tsx +96 -0
- package/src/utils/use-force-update.ts +7 -0
- package/stats.html +1 -1
@@ -0,0 +1,90 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.TrailingVisual = exports.LeadingVisual = exports.LeadingVisualContainer = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _Box = _interopRequireDefault(require("../Box"));
|
11
|
+
|
12
|
+
var _sx = require("../sx");
|
13
|
+
|
14
|
+
var _constants = require("../constants");
|
15
|
+
|
16
|
+
var _Item = require("./Item");
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
|
+
|
20
|
+
function _extends() { _extends = Object.assign || 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); }
|
21
|
+
|
22
|
+
const LeadingVisualContainer = ({
|
23
|
+
sx = {},
|
24
|
+
...props
|
25
|
+
}) => {
|
26
|
+
return /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
27
|
+
as: "span",
|
28
|
+
sx: (0, _sx.merge)({
|
29
|
+
height: _Item.TEXT_ROW_HEIGHT,
|
30
|
+
// match height of text row
|
31
|
+
minWidth: (0, _constants.get)('space.3'),
|
32
|
+
maxWidth: _Item.TEXT_ROW_HEIGHT,
|
33
|
+
// square (same as height)
|
34
|
+
display: 'flex',
|
35
|
+
justifyContent: 'center',
|
36
|
+
alignItems: 'center',
|
37
|
+
flexShrink: 0,
|
38
|
+
marginRight: 2
|
39
|
+
}, sx)
|
40
|
+
}, props));
|
41
|
+
};
|
42
|
+
|
43
|
+
exports.LeadingVisualContainer = LeadingVisualContainer;
|
44
|
+
LeadingVisualContainer.displayName = "LeadingVisualContainer";
|
45
|
+
|
46
|
+
const LeadingVisual = ({
|
47
|
+
sx = {},
|
48
|
+
...props
|
49
|
+
}) => {
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
51
|
+
name: "LeadingVisual"
|
52
|
+
}, ({
|
53
|
+
variant,
|
54
|
+
disabled
|
55
|
+
}) => /*#__PURE__*/_react.default.createElement(LeadingVisualContainer, _extends({
|
56
|
+
sx: (0, _sx.merge)({
|
57
|
+
color: (0, _Item.getVariantStyles)(variant, disabled).iconColor,
|
58
|
+
svg: {
|
59
|
+
fontSize: 0
|
60
|
+
}
|
61
|
+
}, sx)
|
62
|
+
}, props), props.children));
|
63
|
+
};
|
64
|
+
|
65
|
+
exports.LeadingVisual = LeadingVisual;
|
66
|
+
LeadingVisual.displayName = "LeadingVisual";
|
67
|
+
|
68
|
+
const TrailingVisual = ({
|
69
|
+
sx = {},
|
70
|
+
...props
|
71
|
+
}) => {
|
72
|
+
return /*#__PURE__*/_react.default.createElement(_Item.Slot, {
|
73
|
+
name: "TrailingVisual"
|
74
|
+
}, ({
|
75
|
+
variant,
|
76
|
+
disabled
|
77
|
+
}) => /*#__PURE__*/_react.default.createElement(_Box.default, _extends({
|
78
|
+
as: "span",
|
79
|
+
sx: (0, _sx.merge)({
|
80
|
+
height: '20px',
|
81
|
+
// match height of text row
|
82
|
+
flexShrink: 0,
|
83
|
+
color: (0, _Item.getVariantStyles)(variant, disabled).annotationColor,
|
84
|
+
marginLeft: 2
|
85
|
+
}, sx)
|
86
|
+
}, props), props.children));
|
87
|
+
};
|
88
|
+
|
89
|
+
exports.TrailingVisual = TrailingVisual;
|
90
|
+
TrailingVisual.displayName = "TrailingVisual";
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import { Divider } from './Divider';
|
3
|
+
export type { ListProps as ActionListProps } from './List';
|
4
|
+
export type { GroupProps } from './Group';
|
5
|
+
export type { ItemProps } from './Item';
|
6
|
+
export type { DescriptionProps } from './Description';
|
7
|
+
export type { LeadingVisualProps, TrailingVisualProps } from './Visuals';
|
8
|
+
/**
|
9
|
+
* Collection of list-related components.
|
10
|
+
*/
|
11
|
+
export declare const ActionList: import("@radix-ui/react-polymorphic").ForwardRefComponent<"ul", import("./List").ListProps> & {
|
12
|
+
/** Collects related `Items` in an `ActionList`. */
|
13
|
+
Group: import("react").FC<import("./Group").GroupProps>;
|
14
|
+
/** An actionable or selectable `Item` */
|
15
|
+
Item: import("@radix-ui/react-polymorphic").ForwardRefComponent<"li", import("./Item").ItemProps>;
|
16
|
+
/** A `Item` that renders a full-size anchor inside ListItem */
|
17
|
+
LinkItem: import("@radix-ui/react-polymorphic").ForwardRefComponent<"a", Pick<import("./Item").ItemProps, "children" | "sx"> & {
|
18
|
+
download?: string | undefined;
|
19
|
+
href?: string | undefined;
|
20
|
+
hrefLang?: string | undefined;
|
21
|
+
media?: string | undefined;
|
22
|
+
ping?: string | undefined;
|
23
|
+
rel?: string | undefined;
|
24
|
+
target?: string | undefined;
|
25
|
+
type?: string | undefined;
|
26
|
+
referrerPolicy?: import("react").HTMLAttributeReferrerPolicy | undefined;
|
27
|
+
}>;
|
28
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
29
|
+
Divider: typeof Divider;
|
30
|
+
/** Secondary text which provides additional information about an `Item`. */
|
31
|
+
Description: import("react").FC<import("./Description").DescriptionProps>;
|
32
|
+
/** Icon (or similar) positioned before `Item` text. */
|
33
|
+
LeadingVisual: import("react").FC<import("../sx").SxProp & import("react").HTMLAttributes<HTMLSpanElement>>;
|
34
|
+
/** Icon (or similar) positioned after `Item` text. */
|
35
|
+
TrailingVisual: import("react").FC<import("../sx").SxProp & import("react").HTMLAttributes<HTMLSpanElement>>;
|
36
|
+
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.ActionList = void 0;
|
7
|
+
|
8
|
+
var _List = require("./List");
|
9
|
+
|
10
|
+
var _Group = require("./Group");
|
11
|
+
|
12
|
+
var _Item = require("./Item");
|
13
|
+
|
14
|
+
var _LinkItem = require("./LinkItem");
|
15
|
+
|
16
|
+
var _Divider = require("./Divider");
|
17
|
+
|
18
|
+
var _Description = require("./Description");
|
19
|
+
|
20
|
+
var _Visuals = require("./Visuals");
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Collection of list-related components.
|
24
|
+
*/
|
25
|
+
const ActionList = Object.assign(_List.List, {
|
26
|
+
/** Collects related `Items` in an `ActionList`. */
|
27
|
+
Group: _Group.Group,
|
28
|
+
|
29
|
+
/** An actionable or selectable `Item` */
|
30
|
+
Item: _Item.Item,
|
31
|
+
|
32
|
+
/** A `Item` that renders a full-size anchor inside ListItem */
|
33
|
+
LinkItem: _LinkItem.LinkItem,
|
34
|
+
|
35
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
36
|
+
Divider: _Divider.Divider,
|
37
|
+
|
38
|
+
/** Secondary text which provides additional information about an `Item`. */
|
39
|
+
Description: _Description.Description,
|
40
|
+
|
41
|
+
/** Icon (or similar) positioned before `Item` text. */
|
42
|
+
LeadingVisual: _Visuals.LeadingVisual,
|
43
|
+
|
44
|
+
/** Icon (or similar) positioned after `Item` text. */
|
45
|
+
TrailingVisual: _Visuals.TrailingVisual
|
46
|
+
});
|
47
|
+
exports.ActionList = ActionList;
|
package/lib/StateLabel.d.ts
CHANGED
@@ -4,7 +4,7 @@ import { SxProp } from './sx';
|
|
4
4
|
import { ComponentProps } from './utils/types';
|
5
5
|
declare const StateLabelBase: import("styled-components").StyledComponent<"span", any, {
|
6
6
|
variant?: "small" | "normal" | undefined;
|
7
|
-
status?: "issueClosed" | "pullClosed" | "pullMerged" | "issueOpened" | "pullOpened" | "draft" | undefined;
|
7
|
+
status?: "issueClosed" | "pullClosed" | "pullMerged" | "issueOpened" | "pullOpened" | "draft" | "issueDraft" | undefined;
|
8
8
|
} & SystemCommonProps & SxProp, never>;
|
9
9
|
export declare type StateLabelProps = ComponentProps<typeof StateLabelBase>;
|
10
10
|
declare function StateLabel({ children, status, variant: variantProp, ...rest }: StateLabelProps): JSX.Element;
|
package/lib/StateLabel.js
CHANGED
@@ -29,7 +29,8 @@ const octiconMap = {
|
|
29
29
|
issueClosed: _octiconsReact.IssueClosedIcon,
|
30
30
|
pullClosed: _octiconsReact.GitPullRequestIcon,
|
31
31
|
pullMerged: _octiconsReact.GitMergeIcon,
|
32
|
-
draft: _octiconsReact.GitPullRequestIcon
|
32
|
+
draft: _octiconsReact.GitPullRequestIcon,
|
33
|
+
issueDraft: _octiconsReact.IssueDraftIcon
|
33
34
|
};
|
34
35
|
const colorVariants = (0, _styledSystem.variant)({
|
35
36
|
prop: 'status',
|
@@ -57,6 +58,10 @@ const colorVariants = (0, _styledSystem.variant)({
|
|
57
58
|
draft: {
|
58
59
|
backgroundColor: 'neutral.emphasis',
|
59
60
|
color: 'fg.onEmphasis'
|
61
|
+
},
|
62
|
+
issueDraft: {
|
63
|
+
backgroundColor: 'neutral.emphasis',
|
64
|
+
color: 'fg.onEmphasis'
|
60
65
|
}
|
61
66
|
}
|
62
67
|
});
|
package/lib/_TextInputWrapper.js
CHANGED
@@ -39,13 +39,13 @@ const sizeVariants = (0, _styledSystem.variant)({
|
|
39
39
|
const TextInputWrapper = _styledComponents.default.span.withConfig({
|
40
40
|
displayName: "_TextInputWrapper__TextInputWrapper",
|
41
41
|
componentId: "sc-5vfcis-0"
|
42
|
-
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
42
|
+
})(["display:inline-flex;align-items:stretch;min-height:34px;font-size:", ";line-height:20px;color:", ";vertical-align:middle;background-repeat:no-repeat;background-position:right 8px center;border:1px solid ", ";border-radius:", ";outline:none;box-shadow:", ";cursor:text;", " .TextInput-icon{align-self:center;color:", ";margin:0 ", ";flex-shrink:0;}&:focus-within{border-color:", ";box-shadow:", ";}", " ", " ", " ", " @media (min-width:", "){font-size:", ";}", " ", " ", " ", " ", ";"], (0, _constants.get)('fontSizes.1'), (0, _constants.get)('colors.fg.default'), (0, _constants.get)('colors.border.default'), (0, _constants.get)('radii.2'), (0, _constants.get)('shadows.primer.shadow.inset'), props => {
|
43
43
|
if (props.hasIcon) {
|
44
44
|
return (0, _styledComponents.css)(["padding:0;"]);
|
45
45
|
} else {
|
46
46
|
return (0, _styledComponents.css)(["padding:6px 12px;"]);
|
47
47
|
}
|
48
|
-
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
48
|
+
}, (0, _constants.get)('colors.fg.muted'), (0, _constants.get)('space.2'), (0, _constants.get)('colors.accent.emphasis'), (0, _constants.get)('shadows.primer.shadow.focus'), props => props.contrast && (0, _styledComponents.css)(["background-color:", ";"], (0, _constants.get)('colors.canvas.inset')), props => props.disabled && (0, _styledComponents.css)(["color:", ";background-color:", ";border-color:", ";"], (0, _constants.get)('colors.primer.fg.disabled'), (0, _constants.get)('colors.input.disabledBg'), (0, _constants.get)('colors.border.default')), props => props.block && (0, _styledComponents.css)(["display:block;width:100%;"]), props => props.block && props.hasIcon && (0, _styledComponents.css)(["display:flex;"]), (0, _constants.get)('breakpoints.1'), (0, _constants.get)('fontSizes.1'), _styledSystem.width, _styledSystem.minWidth, _styledSystem.maxWidth, sizeVariants, _sx.default);
|
49
49
|
|
50
50
|
var _default = TextInputWrapper;
|
51
51
|
exports.default = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'babel-polyfill';
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _react = require("@testing-library/react");
|
4
|
+
|
5
|
+
require("babel-polyfill");
|
6
|
+
|
7
|
+
var _jestAxe = require("jest-axe");
|
8
|
+
|
9
|
+
var _react2 = _interopRequireDefault(require("react"));
|
10
|
+
|
11
|
+
var _theme = _interopRequireDefault(require("../theme"));
|
12
|
+
|
13
|
+
var _ActionList = require("../ActionList2");
|
14
|
+
|
15
|
+
var _testing = require("../utils/testing");
|
16
|
+
|
17
|
+
var _ = require("..");
|
18
|
+
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
|
+
|
21
|
+
expect.extend(_jestAxe.toHaveNoViolations);
|
22
|
+
|
23
|
+
function SimpleActionList() {
|
24
|
+
return /*#__PURE__*/_react2.default.createElement(_.ThemeProvider, {
|
25
|
+
theme: _theme.default
|
26
|
+
}, /*#__PURE__*/_react2.default.createElement(_.SSRProvider, null, /*#__PURE__*/_react2.default.createElement(_.BaseStyles, null, /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList, null, /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "New file"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Divider, null), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "Copy link"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, null, "Edit file"), /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList.Item, {
|
27
|
+
variant: "danger"
|
28
|
+
}, "Delete file")))));
|
29
|
+
}
|
30
|
+
|
31
|
+
SimpleActionList.displayName = "SimpleActionList";
|
32
|
+
describe('ActionList', () => {
|
33
|
+
(0, _testing.behavesAsComponent)({
|
34
|
+
Component: _ActionList.ActionList,
|
35
|
+
options: {
|
36
|
+
skipAs: true,
|
37
|
+
skipSx: true
|
38
|
+
},
|
39
|
+
toRender: () => /*#__PURE__*/_react2.default.createElement(_ActionList.ActionList, null)
|
40
|
+
});
|
41
|
+
(0, _testing.checkExports)('ActionList2', {
|
42
|
+
default: undefined,
|
43
|
+
ActionList: _ActionList.ActionList
|
44
|
+
});
|
45
|
+
it('should have no axe violations', async () => {
|
46
|
+
const {
|
47
|
+
container
|
48
|
+
} = (0, _react.render)( /*#__PURE__*/_react2.default.createElement(SimpleActionList, null));
|
49
|
+
const results = await (0, _jestAxe.axe)(container);
|
50
|
+
expect(results).toHaveNoViolations();
|
51
|
+
(0, _react.cleanup)();
|
52
|
+
});
|
53
|
+
});
|
@@ -152,9 +152,11 @@ describe('AnchoredOverlay', () => {
|
|
152
152
|
expect(mockCloseCallback).toHaveBeenCalledWith('escape');
|
153
153
|
});
|
154
154
|
it('should render consistently when open', () => {
|
155
|
-
const
|
155
|
+
const {
|
156
|
+
container
|
157
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(AnchoredOverlayTestComponent, {
|
156
158
|
initiallyOpen: true
|
157
159
|
}));
|
158
|
-
expect(
|
160
|
+
expect(container).toMatchSnapshot();
|
159
161
|
});
|
160
162
|
});
|
@@ -58,16 +58,7 @@ const LabelledTextInputWithTokens = ({
|
|
58
58
|
tokens: tokens,
|
59
59
|
onTokenRemove: onTokenRemove,
|
60
60
|
id: "tokenInput"
|
61
|
-
}, rest)));
|
62
|
-
// it('should have no axe violations', async () => {
|
63
|
-
// const onRemoveMock = jest.fn()
|
64
|
-
// const {container} = HTMLRender(<LabelledTextInputWithTokens tokens={mockTokens} onTokenRemove={onRemoveMock} />)
|
65
|
-
// const results = await axe(container)
|
66
|
-
// expect(results).toHaveNoViolations()
|
67
|
-
// cleanup()
|
68
|
-
// })
|
69
|
-
// })
|
70
|
-
|
61
|
+
}, rest)));
|
71
62
|
|
72
63
|
jest.useFakeTimers();
|
73
64
|
describe('TextInputWithTokens', () => {
|
@@ -0,0 +1 @@
|
|
1
|
+
import 'babel-polyfill';
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
4
|
+
|
5
|
+
require("babel-polyfill");
|
6
|
+
|
7
|
+
var _react2 = require("@testing-library/react");
|
8
|
+
|
9
|
+
var _createSlots = _interopRequireDefault(require("../../utils/create-slots"));
|
10
|
+
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
+
|
13
|
+
// setup a component with slots
|
14
|
+
const {
|
15
|
+
Slots,
|
16
|
+
Slot
|
17
|
+
} = (0, _createSlots.default)(['One', 'Two', 'Three']);
|
18
|
+
|
19
|
+
const ComponentWithSlots = ({
|
20
|
+
salutation,
|
21
|
+
children
|
22
|
+
}) => {
|
23
|
+
return /*#__PURE__*/_react.default.createElement(Slots, {
|
24
|
+
context: {
|
25
|
+
salutation
|
26
|
+
}
|
27
|
+
}, slots => /*#__PURE__*/_react.default.createElement("div", null, slots.One, /*#__PURE__*/_react.default.createElement("span", null, children, " ", slots.Two, " ", slots.Three)));
|
28
|
+
};
|
29
|
+
|
30
|
+
ComponentWithSlots.displayName = "ComponentWithSlots";
|
31
|
+
|
32
|
+
const SlotItem1 = ({
|
33
|
+
children
|
34
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
35
|
+
name: "One"
|
36
|
+
}, children);
|
37
|
+
|
38
|
+
SlotItem1.displayName = "SlotItem1";
|
39
|
+
|
40
|
+
const SlotItem2 = ({
|
41
|
+
children
|
42
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
43
|
+
name: "Two"
|
44
|
+
}, children);
|
45
|
+
|
46
|
+
SlotItem2.displayName = "SlotItem2";
|
47
|
+
|
48
|
+
const SlotItem3 = ({
|
49
|
+
children
|
50
|
+
}) => /*#__PURE__*/_react.default.createElement(Slot, {
|
51
|
+
name: "Three"
|
52
|
+
}, context => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, context.salutation, " ", children));
|
53
|
+
|
54
|
+
SlotItem3.displayName = "SlotItem3";
|
55
|
+
describe('ComponentWithSlots', () => {
|
56
|
+
it('renders all slots', async () => {
|
57
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, /*#__PURE__*/_react.default.createElement(SlotItem1, null, "first"), /*#__PURE__*/_react.default.createElement(SlotItem2, null, "second"), "free form"));
|
58
|
+
await (0, _react2.waitFor)(() => component.getByText('first'));
|
59
|
+
expect(component.container).toMatchSnapshot();
|
60
|
+
});
|
61
|
+
it('renders without any slots', async () => {
|
62
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, "free form"));
|
63
|
+
expect(component.container).toMatchSnapshot();
|
64
|
+
});
|
65
|
+
it('renders with just one slot', async () => {
|
66
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, null, /*#__PURE__*/_react.default.createElement(SlotItem1, null, "first"), "free form"));
|
67
|
+
expect(component.container).toMatchSnapshot();
|
68
|
+
});
|
69
|
+
it('renders with context passed to children', async () => {
|
70
|
+
const component = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(ComponentWithSlots, {
|
71
|
+
salutation: "hi"
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(SlotItem3, null, "third"), "free form"));
|
73
|
+
expect(component.container).toMatchSnapshot();
|
74
|
+
});
|
75
|
+
});
|