@primer/components 31.2.0-rc.50908ce9 → 31.2.0-rc.6afeaa37
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 +10 -0
- package/dist/browser.esm.js +622 -620
- package/dist/browser.esm.js.map +1 -1
- package/dist/browser.umd.js +163 -161
- package/dist/browser.umd.js.map +1 -1
- package/docs/content/ActionList2.mdx +354 -0
- 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/Overlay.js +3 -1
- package/lib/Portal/Portal.js +3 -2
- 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/hooks/useAnchoredPosition.js +3 -2
- package/lib/hooks/useCombinedRefs.d.ts +2 -2
- package/lib/hooks/useCombinedRefs.js +4 -6
- package/lib/hooks/useResizeObserver.js +2 -2
- 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/utils/useIsomorphicLayoutEffect.d.ts +3 -0
- package/lib/utils/useIsomorphicLayoutEffect.js +12 -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/Overlay.js +2 -1
- package/lib-esm/Portal/Portal.js +2 -1
- 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/hooks/useAnchoredPosition.js +2 -1
- package/lib-esm/hooks/useCombinedRefs.d.ts +2 -2
- package/lib-esm/hooks/useCombinedRefs.js +3 -2
- package/lib-esm/hooks/useResizeObserver.js +2 -2
- 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/lib-esm/utils/useIsomorphicLayoutEffect.d.ts +3 -0
- package/lib-esm/utils/useIsomorphicLayoutEffect.js +3 -0
- package/migrating.md +1 -1
- package/package-lock.json +146 -7
- package/package.json +5 -3
- 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/Overlay.tsx +2 -1
- package/src/Portal/Portal.tsx +2 -1
- 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__/utils/__snapshots__/createSlots.test.tsx.snap +55 -0
- package/src/__tests__/utils/createSlots.test.tsx +74 -0
- package/src/hooks/useAnchoredPosition.ts +2 -1
- package/src/hooks/useCombinedRefs.ts +3 -3
- package/src/hooks/useResizeObserver.ts +2 -2
- 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/src/utils/useIsomorphicLayoutEffect.ts +10 -0
- package/stats.html +1 -1
@@ -0,0 +1,49 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic'
|
3
|
+
import Link from '../Link'
|
4
|
+
import {SxProp, merge} from '../sx'
|
5
|
+
import {Item, ItemProps} from './Item'
|
6
|
+
|
7
|
+
// adopted from React.AnchorHTMLAttributes
|
8
|
+
type LinkProps = {
|
9
|
+
download?: string
|
10
|
+
href?: string
|
11
|
+
hrefLang?: string
|
12
|
+
media?: string
|
13
|
+
ping?: string
|
14
|
+
rel?: string
|
15
|
+
target?: string
|
16
|
+
type?: string
|
17
|
+
referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>['referrerPolicy']
|
18
|
+
}
|
19
|
+
|
20
|
+
// LinkItem does not support selected, variants, etc.
|
21
|
+
type LinkItemProps = Pick<ItemProps, 'children' | 'sx'> & LinkProps
|
22
|
+
|
23
|
+
export const LinkItem = React.forwardRef(({sx = {}, as: Component, ...props}, forwardedRef) => {
|
24
|
+
const styles = {
|
25
|
+
// occupy full size of Item
|
26
|
+
paddingX: 2,
|
27
|
+
paddingY: '6px', // custom value off the scale
|
28
|
+
display: 'flex',
|
29
|
+
flexGrow: 1, // full width
|
30
|
+
borderRadius: 2,
|
31
|
+
|
32
|
+
// inherit Item styles
|
33
|
+
color: 'inherit',
|
34
|
+
'&:hover': {color: 'inherit', textDecoration: 'none'}
|
35
|
+
}
|
36
|
+
|
37
|
+
return (
|
38
|
+
<Item
|
39
|
+
sx={{paddingY: 0, paddingX: 0}}
|
40
|
+
_PrivateItemWrapper={({children}) => (
|
41
|
+
<Link as={Component} sx={merge(styles, sx as SxProp)} {...props} ref={forwardedRef}>
|
42
|
+
{children}
|
43
|
+
</Link>
|
44
|
+
)}
|
45
|
+
>
|
46
|
+
{props.children}
|
47
|
+
</Item>
|
48
|
+
)
|
49
|
+
}) as PolymorphicForwardRefComponent<'a', LinkItemProps>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '@radix-ui/react-polymorphic'
|
3
|
+
import styled from 'styled-components'
|
4
|
+
import sx, {SxProp, merge} from '../sx'
|
5
|
+
import {AriaRole} from '../utils/types'
|
6
|
+
|
7
|
+
export type ListProps = {
|
8
|
+
/**
|
9
|
+
* `inset` children are offset (vertically and horizontally) from `List`’s edges, `full` children are flush (vertically and horizontally) with `List` edges
|
10
|
+
*/
|
11
|
+
variant?: 'inset' | 'full'
|
12
|
+
/**
|
13
|
+
* Whether multiple Items or a single Item can be selected.
|
14
|
+
*/
|
15
|
+
selectionVariant?: 'single' | 'multiple'
|
16
|
+
/**
|
17
|
+
* Display a divider above each `Item` in this `List` when it does not follow a `Header` or `Divider`.
|
18
|
+
*/
|
19
|
+
showDividers?: boolean
|
20
|
+
/**
|
21
|
+
* The ARIA role describing the function of `List` component. `listbox` or `menu` are a common values.
|
22
|
+
*/
|
23
|
+
role?: AriaRole
|
24
|
+
} & SxProp
|
25
|
+
|
26
|
+
type ContextProps = Omit<ListProps, 'sx'>
|
27
|
+
export const ListContext = React.createContext<ContextProps>({})
|
28
|
+
|
29
|
+
const ListBox = styled.ul<SxProp>(sx)
|
30
|
+
|
31
|
+
export const List = React.forwardRef<HTMLUListElement, ListProps>(
|
32
|
+
(
|
33
|
+
{variant = 'inset', selectionVariant, showDividers = false, sx: sxProp = {}, ...props},
|
34
|
+
forwardedRef
|
35
|
+
): JSX.Element => {
|
36
|
+
const styles = {
|
37
|
+
margin: 0,
|
38
|
+
paddingInlineStart: 0, // reset ul styles
|
39
|
+
paddingY: variant === 'inset' ? 2 : 0
|
40
|
+
}
|
41
|
+
|
42
|
+
return (
|
43
|
+
<ListBox
|
44
|
+
sx={merge(styles, sxProp as SxProp)}
|
45
|
+
aria-multiselectable={selectionVariant === 'multiple' ? true : undefined}
|
46
|
+
{...props}
|
47
|
+
ref={forwardedRef}
|
48
|
+
>
|
49
|
+
<ListContext.Provider value={{variant, selectionVariant, showDividers}}>{props.children}</ListContext.Provider>
|
50
|
+
</ListBox>
|
51
|
+
)
|
52
|
+
}
|
53
|
+
) as PolymorphicForwardRefComponent<'ul', ListProps>
|
54
|
+
|
55
|
+
List.displayName = 'ActionList'
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import {CheckIcon} from '@primer/octicons-react'
|
3
|
+
import {ListContext} from './List'
|
4
|
+
import {GroupContext} from './Group'
|
5
|
+
import {ItemProps} from './Item'
|
6
|
+
import {LeadingVisualContainer} from './Visuals'
|
7
|
+
|
8
|
+
type SelectionProps = Pick<ItemProps, 'selected' | 'disabled'>
|
9
|
+
export const Selection: React.FC<SelectionProps> = ({selected, disabled}) => {
|
10
|
+
const {selectionVariant: listSelectionVariant} = React.useContext(ListContext)
|
11
|
+
const {selectionVariant: groupSelectionVariant} = React.useContext(GroupContext)
|
12
|
+
|
13
|
+
/** selectionVariant in Group can override the selectionVariant in List root */
|
14
|
+
const selectionVariant = typeof groupSelectionVariant !== 'undefined' ? groupSelectionVariant : listSelectionVariant
|
15
|
+
|
16
|
+
// if selectionVariant is not set on List, don't show selection
|
17
|
+
if (!selectionVariant) {
|
18
|
+
// to avoid confusion, fail loudly instead of silently ignoring
|
19
|
+
if (selected)
|
20
|
+
throw new Error(
|
21
|
+
'For Item to be selected, ActionList or ActionList.Group needs to have a selectionVariant defined'
|
22
|
+
)
|
23
|
+
return null
|
24
|
+
}
|
25
|
+
|
26
|
+
if (selectionVariant === 'single') {
|
27
|
+
return <LeadingVisualContainer>{selected && <CheckIcon />}</LeadingVisualContainer>
|
28
|
+
}
|
29
|
+
|
30
|
+
/**
|
31
|
+
* selectionVariant is multiple
|
32
|
+
* readOnly is required because we are doing a one-way bind to `checked`
|
33
|
+
* aria-readonly="false" tells screen that they can still interact with the checkbox
|
34
|
+
*/
|
35
|
+
return (
|
36
|
+
<LeadingVisualContainer sx={{input: {margin: 0, pointerEvents: 'none'}}}>
|
37
|
+
<input type="checkbox" checked={selected} disabled={disabled} tabIndex={-1} readOnly aria-readonly="false" />
|
38
|
+
</LeadingVisualContainer>
|
39
|
+
)
|
40
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import Box from '../Box'
|
3
|
+
import {SxProp, merge} from '../sx'
|
4
|
+
import {get} from '../constants'
|
5
|
+
import {getVariantStyles, Slot, ItemContext, TEXT_ROW_HEIGHT} from './Item'
|
6
|
+
|
7
|
+
type VisualProps = SxProp & React.HTMLAttributes<HTMLSpanElement>
|
8
|
+
|
9
|
+
export const LeadingVisualContainer: React.FC<VisualProps> = ({sx = {}, ...props}) => {
|
10
|
+
return (
|
11
|
+
<Box
|
12
|
+
as="span"
|
13
|
+
sx={merge(
|
14
|
+
{
|
15
|
+
height: TEXT_ROW_HEIGHT, // match height of text row
|
16
|
+
minWidth: get('space.3'),
|
17
|
+
maxWidth: TEXT_ROW_HEIGHT, // square (same as height)
|
18
|
+
display: 'flex',
|
19
|
+
justifyContent: 'center',
|
20
|
+
alignItems: 'center',
|
21
|
+
flexShrink: 0,
|
22
|
+
marginRight: 2
|
23
|
+
},
|
24
|
+
sx as SxProp
|
25
|
+
)}
|
26
|
+
{...props}
|
27
|
+
/>
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
export type LeadingVisualProps = VisualProps
|
32
|
+
export const LeadingVisual: React.FC<VisualProps> = ({sx = {}, ...props}) => {
|
33
|
+
return (
|
34
|
+
<Slot name="LeadingVisual">
|
35
|
+
{({variant, disabled}: ItemContext) => (
|
36
|
+
<LeadingVisualContainer
|
37
|
+
sx={merge(
|
38
|
+
{
|
39
|
+
color: getVariantStyles(variant, disabled).iconColor,
|
40
|
+
svg: {fontSize: 0}
|
41
|
+
},
|
42
|
+
sx as SxProp
|
43
|
+
)}
|
44
|
+
{...props}
|
45
|
+
>
|
46
|
+
{props.children}
|
47
|
+
</LeadingVisualContainer>
|
48
|
+
)}
|
49
|
+
</Slot>
|
50
|
+
)
|
51
|
+
}
|
52
|
+
|
53
|
+
export type TrailingVisualProps = VisualProps
|
54
|
+
export const TrailingVisual: React.FC<VisualProps> = ({sx = {}, ...props}) => {
|
55
|
+
return (
|
56
|
+
<Slot name="TrailingVisual">
|
57
|
+
{({variant, disabled}: ItemContext) => (
|
58
|
+
<Box
|
59
|
+
as="span"
|
60
|
+
sx={merge(
|
61
|
+
{
|
62
|
+
height: '20px', // match height of text row
|
63
|
+
flexShrink: 0,
|
64
|
+
color: getVariantStyles(variant, disabled).annotationColor,
|
65
|
+
marginLeft: 2
|
66
|
+
},
|
67
|
+
sx as SxProp
|
68
|
+
)}
|
69
|
+
{...props}
|
70
|
+
>
|
71
|
+
{props.children}
|
72
|
+
</Box>
|
73
|
+
)}
|
74
|
+
</Slot>
|
75
|
+
)
|
76
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import {List} from './List'
|
2
|
+
import {Group} from './Group'
|
3
|
+
import {Item} from './Item'
|
4
|
+
import {LinkItem} from './LinkItem'
|
5
|
+
import {Divider} from './Divider'
|
6
|
+
import {Description} from './Description'
|
7
|
+
import {LeadingVisual, TrailingVisual} from './Visuals'
|
8
|
+
|
9
|
+
export type {ListProps as ActionListProps} from './List'
|
10
|
+
export type {GroupProps} from './Group'
|
11
|
+
export type {ItemProps} from './Item'
|
12
|
+
export type {DescriptionProps} from './Description'
|
13
|
+
export type {LeadingVisualProps, TrailingVisualProps} from './Visuals'
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Collection of list-related components.
|
17
|
+
*/
|
18
|
+
export const ActionList = Object.assign(List, {
|
19
|
+
/** Collects related `Items` in an `ActionList`. */
|
20
|
+
Group,
|
21
|
+
|
22
|
+
/** An actionable or selectable `Item` */
|
23
|
+
Item,
|
24
|
+
|
25
|
+
/** A `Item` that renders a full-size anchor inside ListItem */
|
26
|
+
LinkItem,
|
27
|
+
|
28
|
+
/** Visually separates `Item`s or `Group`s in an `ActionList`. */
|
29
|
+
Divider,
|
30
|
+
|
31
|
+
/** Secondary text which provides additional information about an `Item`. */
|
32
|
+
Description,
|
33
|
+
|
34
|
+
/** Icon (or similar) positioned before `Item` text. */
|
35
|
+
LeadingVisual,
|
36
|
+
|
37
|
+
/** Icon (or similar) positioned after `Item` text. */
|
38
|
+
TrailingVisual
|
39
|
+
})
|
package/src/Overlay.tsx
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import styled from 'styled-components'
|
2
|
-
import React, {ReactElement, useEffect,
|
2
|
+
import React, {ReactElement, useEffect, useRef} from 'react'
|
3
3
|
import {get, COMMON, SystemPositionProps, SystemCommonProps} from './constants'
|
4
4
|
import {ComponentProps} from './utils/types'
|
5
|
+
import useLayoutEffect from './utils/useIsomorphicLayoutEffect'
|
5
6
|
import {useOverlay, TouchOrMouseEvent} from './hooks'
|
6
7
|
import Portal from './Portal'
|
7
8
|
import sx, {SxProp} from './sx'
|
package/src/Portal/Portal.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from 'react'
|
2
2
|
import {createPortal} from 'react-dom'
|
3
|
+
import useLayoutEffect from '../utils/useIsomorphicLayoutEffect'
|
3
4
|
|
4
5
|
const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__'
|
5
6
|
const DEFAULT_PORTAL_CONTAINER_NAME = '__default__'
|
@@ -69,7 +70,7 @@ export const Portal: React.FC<PortalProps> = ({children, onMount, containerName:
|
|
69
70
|
hostElement.style.zIndex = '1'
|
70
71
|
const elementRef = React.useRef(hostElement)
|
71
72
|
|
72
|
-
|
73
|
+
useLayoutEffect(() => {
|
73
74
|
let containerName = _containerName
|
74
75
|
if (containerName === undefined) {
|
75
76
|
containerName = DEFAULT_PORTAL_CONTAINER_NAME
|
@@ -91,6 +91,13 @@ const TextInputWrapper = styled.span<StyledWrapperProps>`
|
|
91
91
|
display: block;
|
92
92
|
width: 100%;
|
93
93
|
`}
|
94
|
+
|
95
|
+
${props =>
|
96
|
+
props.block &&
|
97
|
+
props.hasIcon &&
|
98
|
+
css`
|
99
|
+
display: flex;
|
100
|
+
`}
|
94
101
|
|
95
102
|
// Ensures inputs don't zoom on mobile but are body-font size on desktop
|
96
103
|
@media (min-width: ${get('breakpoints.1')}) {
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import {cleanup, render as HTMLRender} from '@testing-library/react'
|
2
|
+
import 'babel-polyfill'
|
3
|
+
import {axe, toHaveNoViolations} from 'jest-axe'
|
4
|
+
import React from 'react'
|
5
|
+
import theme from '../theme'
|
6
|
+
import {ActionList} from '../ActionList2'
|
7
|
+
import {behavesAsComponent, checkExports} from '../utils/testing'
|
8
|
+
import {BaseStyles, ThemeProvider, SSRProvider} from '..'
|
9
|
+
expect.extend(toHaveNoViolations)
|
10
|
+
|
11
|
+
function SimpleActionList(): JSX.Element {
|
12
|
+
return (
|
13
|
+
<ThemeProvider theme={theme}>
|
14
|
+
<SSRProvider>
|
15
|
+
<BaseStyles>
|
16
|
+
<ActionList>
|
17
|
+
<ActionList.Item>New file</ActionList.Item>
|
18
|
+
<ActionList.Divider />
|
19
|
+
<ActionList.Item>Copy link</ActionList.Item>
|
20
|
+
<ActionList.Item>Edit file</ActionList.Item>
|
21
|
+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
|
22
|
+
</ActionList>
|
23
|
+
</BaseStyles>
|
24
|
+
</SSRProvider>
|
25
|
+
</ThemeProvider>
|
26
|
+
)
|
27
|
+
}
|
28
|
+
|
29
|
+
describe('ActionList', () => {
|
30
|
+
behavesAsComponent({
|
31
|
+
Component: ActionList,
|
32
|
+
options: {skipAs: true, skipSx: true},
|
33
|
+
toRender: () => <ActionList />
|
34
|
+
})
|
35
|
+
|
36
|
+
checkExports('ActionList2', {
|
37
|
+
default: undefined,
|
38
|
+
ActionList
|
39
|
+
})
|
40
|
+
|
41
|
+
it('should have no axe violations', async () => {
|
42
|
+
const {container} = HTMLRender(<SimpleActionList />)
|
43
|
+
const results = await axe(container)
|
44
|
+
expect(results).toHaveNoViolations()
|
45
|
+
cleanup()
|
46
|
+
})
|
47
|
+
})
|
@@ -144,7 +144,7 @@ describe('AnchoredOverlay', () => {
|
|
144
144
|
})
|
145
145
|
|
146
146
|
it('should render consistently when open', () => {
|
147
|
-
const
|
148
|
-
expect(
|
147
|
+
const {container} = HTMLRender(<AnchoredOverlayTestComponent initiallyOpen={true} />)
|
148
|
+
expect(container).toMatchSnapshot()
|
149
149
|
})
|
150
150
|
})
|
@@ -29,16 +29,6 @@ const LabelledTextInputWithTokens: React.FC<TextInputWithTokensProps> = ({onToke
|
|
29
29
|
</>
|
30
30
|
)
|
31
31
|
|
32
|
-
// describe('axe test', () => {
|
33
|
-
// it('should have no axe violations', async () => {
|
34
|
-
// const onRemoveMock = jest.fn()
|
35
|
-
// const {container} = HTMLRender(<LabelledTextInputWithTokens tokens={mockTokens} onTokenRemove={onRemoveMock} />)
|
36
|
-
// const results = await axe(container)
|
37
|
-
// expect(results).toHaveNoViolations()
|
38
|
-
// cleanup()
|
39
|
-
// })
|
40
|
-
// })
|
41
|
-
|
42
32
|
jest.useFakeTimers()
|
43
33
|
|
44
34
|
describe('TextInputWithTokens', () => {
|
@@ -94,9 +94,7 @@ exports[`AnchoredOverlay renders consistently 1`] = `
|
|
94
94
|
`;
|
95
95
|
|
96
96
|
exports[`AnchoredOverlay should render consistently when open 1`] = `
|
97
|
-
|
98
|
-
"asFragment": [Function],
|
99
|
-
"baseElement": .c0 {
|
97
|
+
.c0 {
|
100
98
|
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
|
101
99
|
line-height: 1.5;
|
102
100
|
color: #24292f;
|
@@ -187,146 +185,48 @@ Object {
|
|
187
185
|
outline: none;
|
188
186
|
}
|
189
187
|
|
190
|
-
<
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
</button>
|
207
|
-
<div
|
208
|
-
id="__primerPortalRoot__"
|
209
|
-
style="position: absolute; top: 0px; left: 0px;"
|
210
|
-
>
|
211
|
-
<div
|
212
|
-
style="position: relative; z-index: 1;"
|
213
|
-
>
|
214
|
-
<div
|
215
|
-
class="c2"
|
216
|
-
data-focus-trap="active"
|
217
|
-
height="auto"
|
218
|
-
role="none"
|
219
|
-
style="top: 4px; left: 0px; --styled-overlay-visibility: visible;"
|
220
|
-
width="auto"
|
221
|
-
>
|
222
|
-
<button
|
223
|
-
class="focus-visible"
|
224
|
-
data-focus-visible-added=""
|
225
|
-
tabindex="0"
|
226
|
-
type="button"
|
227
|
-
>
|
228
|
-
Focusable Child
|
229
|
-
</button>
|
230
|
-
</div>
|
231
|
-
</div>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
</div>
|
235
|
-
</body>,
|
236
|
-
"container": <div>
|
188
|
+
<div>
|
189
|
+
<div
|
190
|
+
class="c0"
|
191
|
+
color="fg.default"
|
192
|
+
data-portal-root="true"
|
193
|
+
font-family="normal"
|
194
|
+
>
|
195
|
+
<button
|
196
|
+
aria-haspopup="true"
|
197
|
+
aria-labelledby="react-aria-1"
|
198
|
+
class="c1"
|
199
|
+
id="react-aria-1"
|
200
|
+
tabindex="0"
|
201
|
+
>
|
202
|
+
Anchor Button
|
203
|
+
</button>
|
237
204
|
<div
|
238
|
-
|
239
|
-
|
240
|
-
data-portal-root="true"
|
241
|
-
font-family="normal"
|
205
|
+
id="__primerPortalRoot__"
|
206
|
+
style="position: absolute; top: 0px; left: 0px;"
|
242
207
|
>
|
243
|
-
<button
|
244
|
-
aria-haspopup="true"
|
245
|
-
aria-labelledby="react-aria-1"
|
246
|
-
class="ButtonBase-sc-181ps9o-0 Button-xjtz72-0 iRqJHc"
|
247
|
-
id="react-aria-1"
|
248
|
-
tabindex="0"
|
249
|
-
>
|
250
|
-
Anchor Button
|
251
|
-
</button>
|
252
208
|
<div
|
253
|
-
|
254
|
-
style="position: absolute; top: 0px; left: 0px;"
|
209
|
+
style="position: relative; z-index: 1;"
|
255
210
|
>
|
256
211
|
<div
|
257
|
-
|
212
|
+
class="c2"
|
213
|
+
data-focus-trap="active"
|
214
|
+
height="auto"
|
215
|
+
role="none"
|
216
|
+
style="top: 4px; left: 0px; --styled-overlay-visibility: visible;"
|
217
|
+
width="auto"
|
258
218
|
>
|
259
|
-
<
|
260
|
-
class="
|
261
|
-
data-focus-
|
262
|
-
|
263
|
-
|
264
|
-
style="top: 4px; left: 0px; --styled-overlay-visibility: visible;"
|
265
|
-
width="auto"
|
219
|
+
<button
|
220
|
+
class="focus-visible"
|
221
|
+
data-focus-visible-added=""
|
222
|
+
tabindex="0"
|
223
|
+
type="button"
|
266
224
|
>
|
267
|
-
|
268
|
-
|
269
|
-
data-focus-visible-added=""
|
270
|
-
tabindex="0"
|
271
|
-
type="button"
|
272
|
-
>
|
273
|
-
Focusable Child
|
274
|
-
</button>
|
275
|
-
</div>
|
225
|
+
Focusable Child
|
226
|
+
</button>
|
276
227
|
</div>
|
277
228
|
</div>
|
278
229
|
</div>
|
279
|
-
</div
|
280
|
-
|
281
|
-
"findAllByAltText": [Function],
|
282
|
-
"findAllByDisplayValue": [Function],
|
283
|
-
"findAllByLabelText": [Function],
|
284
|
-
"findAllByPlaceholderText": [Function],
|
285
|
-
"findAllByRole": [Function],
|
286
|
-
"findAllByTestId": [Function],
|
287
|
-
"findAllByText": [Function],
|
288
|
-
"findAllByTitle": [Function],
|
289
|
-
"findByAltText": [Function],
|
290
|
-
"findByDisplayValue": [Function],
|
291
|
-
"findByLabelText": [Function],
|
292
|
-
"findByPlaceholderText": [Function],
|
293
|
-
"findByRole": [Function],
|
294
|
-
"findByTestId": [Function],
|
295
|
-
"findByText": [Function],
|
296
|
-
"findByTitle": [Function],
|
297
|
-
"getAllByAltText": [Function],
|
298
|
-
"getAllByDisplayValue": [Function],
|
299
|
-
"getAllByLabelText": [Function],
|
300
|
-
"getAllByPlaceholderText": [Function],
|
301
|
-
"getAllByRole": [Function],
|
302
|
-
"getAllByTestId": [Function],
|
303
|
-
"getAllByText": [Function],
|
304
|
-
"getAllByTitle": [Function],
|
305
|
-
"getByAltText": [Function],
|
306
|
-
"getByDisplayValue": [Function],
|
307
|
-
"getByLabelText": [Function],
|
308
|
-
"getByPlaceholderText": [Function],
|
309
|
-
"getByRole": [Function],
|
310
|
-
"getByTestId": [Function],
|
311
|
-
"getByText": [Function],
|
312
|
-
"getByTitle": [Function],
|
313
|
-
"queryAllByAltText": [Function],
|
314
|
-
"queryAllByDisplayValue": [Function],
|
315
|
-
"queryAllByLabelText": [Function],
|
316
|
-
"queryAllByPlaceholderText": [Function],
|
317
|
-
"queryAllByRole": [Function],
|
318
|
-
"queryAllByTestId": [Function],
|
319
|
-
"queryAllByText": [Function],
|
320
|
-
"queryAllByTitle": [Function],
|
321
|
-
"queryByAltText": [Function],
|
322
|
-
"queryByDisplayValue": [Function],
|
323
|
-
"queryByLabelText": [Function],
|
324
|
-
"queryByPlaceholderText": [Function],
|
325
|
-
"queryByRole": [Function],
|
326
|
-
"queryByTestId": [Function],
|
327
|
-
"queryByText": [Function],
|
328
|
-
"queryByTitle": [Function],
|
329
|
-
"rerender": [Function],
|
330
|
-
"unmount": [Function],
|
331
|
-
}
|
230
|
+
</div>
|
231
|
+
</div>
|
332
232
|
`;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ComponentWithSlots renders all slots 1`] = `
|
4
|
+
<div>
|
5
|
+
<div>
|
6
|
+
first
|
7
|
+
<span>
|
8
|
+
free form
|
9
|
+
|
10
|
+
second
|
11
|
+
|
12
|
+
</span>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
`;
|
16
|
+
|
17
|
+
exports[`ComponentWithSlots renders with context passed to children 1`] = `
|
18
|
+
<div>
|
19
|
+
<div>
|
20
|
+
<span>
|
21
|
+
free form
|
22
|
+
|
23
|
+
|
24
|
+
hi
|
25
|
+
|
26
|
+
third
|
27
|
+
</span>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
`;
|
31
|
+
|
32
|
+
exports[`ComponentWithSlots renders with just one slot 1`] = `
|
33
|
+
<div>
|
34
|
+
<div>
|
35
|
+
first
|
36
|
+
<span>
|
37
|
+
free form
|
38
|
+
|
39
|
+
|
40
|
+
</span>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
`;
|
44
|
+
|
45
|
+
exports[`ComponentWithSlots renders without any slots 1`] = `
|
46
|
+
<div>
|
47
|
+
<div>
|
48
|
+
<span>
|
49
|
+
free form
|
50
|
+
|
51
|
+
|
52
|
+
</span>
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
`;
|