@papillonarts/components 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.ts +1 -0
- package/build/primer/Alert/Alert.mdx +88 -0
- package/build/primer/Alert/Alert.prop.ts +45 -0
- package/build/primer/Alert/Alert.tsx +101 -0
- package/build/primer/Alert/__tests__/Alert.int.story.tsx +86 -0
- package/build/primer/Alert/__tests__/Alert.int.test.ts +37 -0
- package/build/primer/Alert/index.ts +2 -0
- package/build/primer/Blankslate/Blankslate.mdx +57 -0
- package/build/primer/Blankslate/Blankslate.prop.ts +26 -0
- package/build/primer/Blankslate/Blankslate.tsx +26 -0
- package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +43 -0
- package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +29 -0
- package/build/primer/Blankslate/index.ts +2 -0
- package/build/primer/Breadcrumb/Breadcrumb.mdx +23 -0
- package/build/primer/Breadcrumb/Breadcrumb.prop.ts +28 -0
- package/build/primer/Breadcrumb/Breadcrumb.tsx +57 -0
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +40 -0
- package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +40 -0
- package/build/primer/Breadcrumb/index.ts +2 -0
- package/build/primer/Button/Button.mdx +239 -0
- package/build/primer/Button/Button.prop.ts +77 -0
- package/build/primer/Button/Button.tsx +91 -0
- package/build/primer/Button/__tests__/Button.int.story.tsx +173 -0
- package/build/primer/Button/__tests__/Button.int.test.ts +191 -0
- package/build/primer/Button/index.ts +2 -0
- package/build/primer/Dropdown/Dropdown.mdx +19 -0
- package/build/primer/Dropdown/Dropdown.prop.ts +33 -0
- package/build/primer/Dropdown/Dropdown.tsx +102 -0
- package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +43 -0
- package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +53 -0
- package/build/primer/Dropdown/index.ts +2 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +5 -0
- package/build/primer/ErrorBoundary/ErrorBoundary.tsx +35 -0
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +23 -0
- package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +9 -0
- package/build/primer/ErrorBoundary/index.ts +1 -0
- package/build/primer/Form/Checkbox/Checkbox.prop.ts +34 -0
- package/build/primer/Form/Checkbox/Checkbox.tsx +40 -0
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +50 -0
- package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +23 -0
- package/build/primer/Form/Checkbox/index.ts +2 -0
- package/build/primer/Form/Input/Input.prop.ts +43 -0
- package/build/primer/Form/Input/Input.tsx +43 -0
- package/build/primer/Form/Input/__tests__/Input.int.story.tsx +54 -0
- package/build/primer/Form/Input/__tests__/Input.int.test.ts +15 -0
- package/build/primer/Form/Input/index.ts +2 -0
- package/build/primer/Form/Radio/Radio.prop.ts +30 -0
- package/build/primer/Form/Radio/Radio.tsx +38 -0
- package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +42 -0
- package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +13 -0
- package/build/primer/Form/Radio/index.ts +2 -0
- package/build/primer/Form/index.ts +19 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +21 -0
- package/build/primer/Grid/DisplayTable/DisplayTable.tsx +68 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +289 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +27 -0
- package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +9 -0
- package/build/primer/Grid/DisplayTable/index.ts +1 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +59 -0
- package/build/primer/Grid/FlexGrid/FlexGrid.tsx +274 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +289 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +146 -0
- package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +46 -0
- package/build/primer/Grid/FlexGrid/index.ts +2 -0
- package/build/primer/Grid/index.ts +9 -0
- package/build/primer/Icon/Icon.part.ts +1289 -0
- package/build/primer/Icon/Icon.prop.ts +1337 -0
- package/build/primer/Icon/Icon.tsx +49 -0
- package/build/primer/Icon/__tests__/Icon.int.story.tsx +58 -0
- package/build/primer/Icon/__tests__/Icon.int.test.ts +13 -0
- package/build/primer/Icon/index.ts +2 -0
- package/build/primer/Label/Label.mdx +13 -0
- package/build/primer/Label/Label.prop.ts +31 -0
- package/build/primer/Label/Label.tsx +27 -0
- package/build/primer/Label/__tests__/Label.int.story.tsx +19 -0
- package/build/primer/Label/__tests__/Label.int.test.ts +9 -0
- package/build/primer/Label/index.ts +1 -0
- package/build/primer/Loader/Loader.mdx +31 -0
- package/build/primer/Loader/Loader.prop.ts +16 -0
- package/build/primer/Loader/Loader.tsx +43 -0
- package/build/primer/Loader/__tests__/Loader.int.story.tsx +34 -0
- package/build/primer/Loader/__tests__/Loader.int.test.ts +21 -0
- package/build/primer/Loader/index.ts +2 -0
- package/build/primer/Navigation/Menu/Menu.prop.ts +26 -0
- package/build/primer/Navigation/Menu/Menu.tsx +42 -0
- package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +55 -0
- package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +57 -0
- package/build/primer/Navigation/Menu/index.ts +1 -0
- package/build/primer/Navigation/TabNav/TabNav.prop.ts +39 -0
- package/build/primer/Navigation/TabNav/TabNav.tsx +105 -0
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +168 -0
- package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +55 -0
- package/build/primer/Navigation/TabNav/index.ts +2 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +41 -0
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +106 -0
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +140 -0
- package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +81 -0
- package/build/primer/Navigation/UnderlineNav/index.ts +2 -0
- package/build/primer/Navigation/index.ts +12 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +53 -0
- package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +71 -0
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +48 -0
- package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +15 -0
- package/build/primer/Pagination/PreviousNext/index.ts +2 -0
- package/build/primer/Pagination/index.ts +6 -0
- package/build/primer/Popover/Popover.mdx +190 -0
- package/build/primer/Popover/Popover.prop.ts +49 -0
- package/build/primer/Popover/Popover.tsx +80 -0
- package/build/primer/Popover/__tests__/Popover.int.story.tsx +216 -0
- package/build/primer/Popover/__tests__/Popover.int.test.ts +71 -0
- package/build/primer/Popover/index.ts +2 -0
- package/build/primer/Progress/Progress.mdx +31 -0
- package/build/primer/Progress/Progress.prop.ts +16 -0
- package/build/primer/Progress/Progress.tsx +19 -0
- package/build/primer/Progress/__tests__/Progress.int.story.tsx +28 -0
- package/build/primer/Progress/__tests__/Progress.int.test.ts +17 -0
- package/build/primer/Progress/index.ts +2 -0
- package/build/primer/Select/Select.mdx +19 -0
- package/build/primer/Select/Select.prop.ts +24 -0
- package/build/primer/Select/Select.tsx +58 -0
- package/build/primer/Select/__tests__/Select.int.story.tsx +38 -0
- package/build/primer/Select/__tests__/Select.int.test.ts +42 -0
- package/build/primer/Select/index.ts +2 -0
- package/build/primer/SelectMenu/SelectMenu.mdx +13 -0
- package/build/primer/SelectMenu/SelectMenu.prop.ts +25 -0
- package/build/primer/SelectMenu/SelectMenu.tsx +68 -0
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +50 -0
- package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +56 -0
- package/build/primer/SelectMenu/index.ts +1 -0
- package/build/primer/Subhead/Subhead.mdx +20 -0
- package/build/primer/Subhead/Subhead.prop.ts +10 -0
- package/build/primer/Subhead/Subhead.tsx +15 -0
- package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +23 -0
- package/build/primer/Subhead/__tests__/Subhead.int.test.ts +13 -0
- package/build/primer/Subhead/index.ts +1 -0
- package/build/primer/Toast/Toast.prop.ts +21 -0
- package/build/primer/Toast/Toast.tsx +38 -0
- package/build/primer/Toast/__tests__/Toast.int.story.tsx +50 -0
- package/build/primer/Toast/__tests__/Toast.int.test.ts +25 -0
- package/build/primer/Toast/index.ts +2 -0
- package/build/primer/index.ts +83 -0
- package/package.json +4 -4
- package/build/index.js +0 -12
- package/build/primer/Alert/Alert.js +0 -121
- package/build/primer/Alert/Alert.prop.js +0 -38
- package/build/primer/Alert/index.js +0 -19
- package/build/primer/Blankslate/Blankslate.js +0 -31
- package/build/primer/Blankslate/Blankslate.prop.js +0 -26
- package/build/primer/Blankslate/index.js +0 -19
- package/build/primer/Breadcrumb/Breadcrumb.js +0 -74
- package/build/primer/Breadcrumb/Breadcrumb.prop.js +0 -29
- package/build/primer/Breadcrumb/index.js +0 -19
- package/build/primer/Button/Button.js +0 -99
- package/build/primer/Button/Button.prop.js +0 -67
- package/build/primer/Button/index.js +0 -49
- package/build/primer/Dropdown/Dropdown.js +0 -104
- package/build/primer/Dropdown/Dropdown.prop.js +0 -34
- package/build/primer/Dropdown/index.js +0 -19
- package/build/primer/ErrorBoundary/ErrorBoundary.js +0 -59
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +0 -11
- package/build/primer/ErrorBoundary/index.js +0 -12
- package/build/primer/Form/Checkbox/Checkbox.js +0 -49
- package/build/primer/Form/Checkbox/Checkbox.prop.js +0 -36
- package/build/primer/Form/Checkbox/index.js +0 -19
- package/build/primer/Form/Input/Input.js +0 -56
- package/build/primer/Form/Input/Input.prop.js +0 -43
- package/build/primer/Form/Input/index.js +0 -25
- package/build/primer/Form/Radio/Radio.js +0 -48
- package/build/primer/Form/Radio/Radio.prop.js +0 -34
- package/build/primer/Form/Radio/index.js +0 -19
- package/build/primer/Form/index.js +0 -24
- package/build/primer/Grid/DisplayTable/DisplayTable.js +0 -58
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +0 -18
- package/build/primer/Grid/DisplayTable/index.js +0 -12
- package/build/primer/Grid/FlexGrid/FlexGrid.js +0 -244
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +0 -49
- package/build/primer/Grid/FlexGrid/index.js +0 -25
- package/build/primer/Grid/index.js +0 -14
- package/build/primer/Icon/Icon.js +0 -70
- package/build/primer/Icon/Icon.part.js +0 -1295
- package/build/primer/Icon/Icon.prop.js +0 -689
- package/build/primer/Icon/index.js +0 -25
- package/build/primer/Label/Label.js +0 -31
- package/build/primer/Label/Label.prop.js +0 -34
- package/build/primer/Label/index.js +0 -12
- package/build/primer/Loader/Loader.js +0 -65
- package/build/primer/Loader/Loader.prop.js +0 -21
- package/build/primer/Loader/index.js +0 -19
- package/build/primer/Navigation/Menu/Menu.js +0 -70
- package/build/primer/Navigation/Menu/Menu.prop.js +0 -28
- package/build/primer/Navigation/Menu/index.js +0 -12
- package/build/primer/Navigation/TabNav/TabNav.js +0 -125
- package/build/primer/Navigation/TabNav/TabNav.prop.js +0 -36
- package/build/primer/Navigation/TabNav/index.js +0 -19
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +0 -121
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +0 -41
- package/build/primer/Navigation/UnderlineNav/index.js +0 -25
- package/build/primer/Navigation/index.js +0 -17
- package/build/primer/Pagination/PreviousNext/PreviousNext.js +0 -76
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +0 -56
- package/build/primer/Pagination/PreviousNext/index.js +0 -19
- package/build/primer/Pagination/index.js +0 -11
- package/build/primer/Popover/Popover.js +0 -63
- package/build/primer/Popover/Popover.prop.js +0 -41
- package/build/primer/Popover/index.js +0 -25
- package/build/primer/Progress/Progress.js +0 -31
- package/build/primer/Progress/Progress.prop.js +0 -21
- package/build/primer/Progress/index.js +0 -19
- package/build/primer/Select/Select.js +0 -66
- package/build/primer/Select/Select.prop.js +0 -27
- package/build/primer/Select/index.js +0 -19
- package/build/primer/SelectMenu/SelectMenu.js +0 -95
- package/build/primer/SelectMenu/SelectMenu.prop.js +0 -26
- package/build/primer/SelectMenu/index.js +0 -12
- package/build/primer/Subhead/Subhead.js +0 -27
- package/build/primer/Subhead/Subhead.prop.js +0 -16
- package/build/primer/Subhead/index.js +0 -12
- package/build/primer/Toast/Toast.js +0 -55
- package/build/primer/Toast/Toast.prop.js +0 -26
- package/build/primer/Toast/index.js +0 -19
- package/build/primer/index.js +0 -87
- /package/build/primer/Form/Checkbox/{Checkbox.md → Checkbox.mdx} +0 -0
- /package/build/primer/Form/Checkbox/__tests__/__snapshots__/{Checkbox.int.test.js.snap → Checkbox.int.test.ts.snap} +0 -0
- /package/build/primer/Form/Input/{Input.md → Input.mdx} +0 -0
- /package/build/primer/Form/Input/__tests__/__snapshots__/{Input.int.test.js.snap → Input.int.test.ts.snap} +0 -0
- /package/build/primer/Form/Radio/{Radio.md → Radio.mdx} +0 -0
- /package/build/primer/Form/Radio/__tests__/__snapshots__/{Radio.int.test.js.snap → Radio.int.test.ts.snap} +0 -0
- /package/build/primer/Grid/DisplayTable/{DisplayTable.md → DisplayTable.mdx} +0 -0
- /package/build/primer/Grid/DisplayTable/__tests__/__snapshots__/{DisplayTable.int.test.js.snap → DisplayTable.int.test.ts.snap} +0 -0
- /package/build/primer/Grid/FlexGrid/{FlexGrid.md → FlexGrid.mdx} +0 -0
- /package/build/primer/Grid/FlexGrid/__tests__/__snapshots__/{FlexGrid.int.test.js.snap → FlexGrid.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/Menu/{Menu.md → Menu.mdx} +0 -0
- /package/build/primer/Navigation/Menu/__tests__/__snapshots__/{Menu.int.test.js.snap → Menu.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/TabNav/{TabNav.md → TabNav.mdx} +0 -0
- /package/build/primer/Navigation/TabNav/__tests__/__snapshots__/{TabNav.int.test.js.snap → TabNav.int.test.ts.snap} +0 -0
- /package/build/primer/Navigation/UnderlineNav/{UnderlineNav.md → UnderlineNav.mdx} +0 -0
- /package/build/primer/Navigation/UnderlineNav/__tests__/__snapshots__/{UnderlineNav.int.test.js.snap → UnderlineNav.int.test.ts.snap} +0 -0
- /package/build/primer/Pagination/PreviousNext/{PreviousNext.md → PreviousNext.mdx} +0 -0
- /package/build/primer/Pagination/PreviousNext/__tests__/__snapshots__/{PreviousNext.int.test.js.snap → PreviousNext.int.test.ts.snap} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import { v1 as uuidv1 } from 'uuid'
|
|
3
|
+
import { getIndexItems, getIndexItemsWithSelected } from '@papillonarts/library/array'
|
|
4
|
+
import { useRef, useState } from '@papillonarts/library/hooks'
|
|
5
|
+
import utilityStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
|
|
6
|
+
import detailsStyles from '@papillonarts/css/build/primer/utilities/details.scss'
|
|
7
|
+
import { SelectMenuProps, defaultProps } from './SelectMenu.prop'
|
|
8
|
+
import styles from './SelectMenu.scss'
|
|
9
|
+
import buttonStyles from '../Button/Button.scss'
|
|
10
|
+
import { Icon, iconSize } from '../Icon'
|
|
11
|
+
|
|
12
|
+
export function SelectMenu({
|
|
13
|
+
className = defaultProps.className,
|
|
14
|
+
summary,
|
|
15
|
+
icon,
|
|
16
|
+
title = defaultProps.title,
|
|
17
|
+
ariaAttr,
|
|
18
|
+
items,
|
|
19
|
+
onClick,
|
|
20
|
+
}: SelectMenuProps) {
|
|
21
|
+
const [indexItems, setIndexItems] = useState(getIndexItems(items))
|
|
22
|
+
const { haspopup } = ariaAttr
|
|
23
|
+
const details = useRef(null)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<details ref={details} className={cx(className, detailsStyles['details-reset'], detailsStyles['details-overlay'])}>
|
|
27
|
+
<summary className={cx(buttonStyles.btn, buttonStyles['btn-outline'])} aria-haspopup={haspopup}>
|
|
28
|
+
{summary} <Icon className={cx(utilityStyles['ml-2'])} icon={icon} size={iconSize.small} />
|
|
29
|
+
</summary>
|
|
30
|
+
<div className={styles.SelectMenu}>
|
|
31
|
+
<div className={styles['SelectMenu-modal']}>
|
|
32
|
+
{title && (
|
|
33
|
+
<header className={styles['SelectMenu-header']}>
|
|
34
|
+
<h3 className={styles['SelectMenu-title']}>{title}</h3>
|
|
35
|
+
<button className={styles['SelectMenu-closeButton']} type="button" />
|
|
36
|
+
</header>
|
|
37
|
+
)}
|
|
38
|
+
<div className={styles['SelectMenu-list']}>
|
|
39
|
+
{indexItems.map((indexItem) => {
|
|
40
|
+
const { text } = indexItem
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
key={uuidv1()}
|
|
46
|
+
onClick={(e) => {
|
|
47
|
+
e.preventDefault()
|
|
48
|
+
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem)
|
|
49
|
+
setIndexItems(newIndexItems)
|
|
50
|
+
onClick({
|
|
51
|
+
ariaAttr,
|
|
52
|
+
items: newIndexItems.map((newIndexItem) => (({ text, isSelected }) => ({ text, isSelected }))(newIndexItem)), // eslint-disable-line
|
|
53
|
+
})
|
|
54
|
+
details.current.removeAttribute('open')
|
|
55
|
+
}}
|
|
56
|
+
className={styles['SelectMenu-item']}
|
|
57
|
+
role="menuitem"
|
|
58
|
+
>
|
|
59
|
+
{text}
|
|
60
|
+
</button>
|
|
61
|
+
)
|
|
62
|
+
})}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</details>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { action } from 'storybook/actions'
|
|
2
|
+
import { withTests } from '@storybook/addon-jest'
|
|
3
|
+
import { iconName } from '../../Icon/Icon.prop'
|
|
4
|
+
import results from '../../../../../../.jest-test-results.json'
|
|
5
|
+
|
|
6
|
+
const SelectMenu =
|
|
7
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
8
|
+
? require('../../../index').primer.SelectMenu
|
|
9
|
+
: require('../../../../build').primer.SelectMenu
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Primer/Molecule/SelectMenu',
|
|
13
|
+
component: SelectMenu,
|
|
14
|
+
decorators: [withTests({ results })],
|
|
15
|
+
parameters: { jest: ['SelectMenu.int.test.js'] },
|
|
16
|
+
excludeStories: ['summary', 'title', 'ariaAttr', 'items', 'custom'],
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const summary = 'Choose an item'
|
|
20
|
+
|
|
21
|
+
export const title = 'Title'
|
|
22
|
+
|
|
23
|
+
export const ariaAttr = {
|
|
24
|
+
haspopup: true,
|
|
25
|
+
current: 'page',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const items = [
|
|
29
|
+
{ text: 'Item 1', isSelected: true },
|
|
30
|
+
{ text: 'Item 2', isSelected: false },
|
|
31
|
+
{ text: 'Item 3', isSelected: false },
|
|
32
|
+
{ text: 'Item 4', isSelected: false },
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
export function custom(onClick) {
|
|
36
|
+
return <SelectMenu summary={summary} icon={iconName.ChevronDown16} title={title} ariaAttr={ariaAttr} items={items} onClick={onClick} />
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function regular() {
|
|
40
|
+
return (
|
|
41
|
+
<SelectMenu
|
|
42
|
+
summary={summary}
|
|
43
|
+
icon={iconName.ChevronDown16}
|
|
44
|
+
title={title}
|
|
45
|
+
ariaAttr={ariaAttr}
|
|
46
|
+
items={items}
|
|
47
|
+
onClick={action('onClick')}
|
|
48
|
+
/>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { items, regular } from './SelectMenu.int.story'
|
|
2
|
+
|
|
3
|
+
jest.mock('@papillonarts/library/array', () => ({
|
|
4
|
+
getIndexItems: () => {},
|
|
5
|
+
getIndexItemsWithSelected: () => {},
|
|
6
|
+
}))
|
|
7
|
+
|
|
8
|
+
jest.mock('@papillonarts/library/hooks', () => ({
|
|
9
|
+
useRef: () => {},
|
|
10
|
+
useState: () => {},
|
|
11
|
+
}))
|
|
12
|
+
|
|
13
|
+
const libraryArrayMockObject = require('@papillonarts/library/array')
|
|
14
|
+
const libraryHooksMockObject = require('@papillonarts/library/hooks')
|
|
15
|
+
|
|
16
|
+
describe('<SelectMenu />', () => {
|
|
17
|
+
let indexItemsDataObject = [
|
|
18
|
+
{ ...items[0], index: 0 },
|
|
19
|
+
{ ...items[1], index: 1 },
|
|
20
|
+
{ ...items[2], index: 2 },
|
|
21
|
+
{ ...items[3], index: 3 },
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
const newIndexItemsWithSelectedDataObject = [
|
|
25
|
+
{ ...items[0], index: 0, isSelected: true },
|
|
26
|
+
{ ...items[1], index: 1, isSelected: false },
|
|
27
|
+
{ ...items[2], index: 2, isSelected: false },
|
|
28
|
+
{ ...items[3], index: 3, isSelected: false },
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
const setIndexItemsMockFn = jest.fn((indexItems) => {
|
|
32
|
+
indexItemsDataObject = indexItems
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.spyOn(libraryArrayMockObject, 'getIndexItems').mockReturnValue(indexItemsDataObject)
|
|
37
|
+
|
|
38
|
+
jest.spyOn(libraryArrayMockObject, 'getIndexItemsWithSelected').mockReturnValue(newIndexItemsWithSelectedDataObject)
|
|
39
|
+
|
|
40
|
+
jest.spyOn(libraryHooksMockObject, 'useState').mockImplementation(() => [indexItemsDataObject, setIndexItemsMockFn])
|
|
41
|
+
|
|
42
|
+
jest.spyOn(libraryHooksMockObject, 'useRef').mockImplementation(() => ({
|
|
43
|
+
current: {
|
|
44
|
+
removeAttribute: () => {},
|
|
45
|
+
},
|
|
46
|
+
}))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
afterEach(() => jest.clearAllMocks())
|
|
50
|
+
|
|
51
|
+
describe('Render', () => {
|
|
52
|
+
test('must match regular()', () => {
|
|
53
|
+
expect(global.renderToJSON(regular())).toMatchSnapshot()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectMenu } from './SelectMenu'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Subhead
|
|
2
|
+
|
|
3
|
+
> The basic Subhead consists of a .Subhead container, which has a light gray bottom border. Use .Subhead-heading for the heading itself. It's an `<h2>` sized heading with normal font-weight.
|
|
4
|
+
> Use a heading element whenever possible as they can be used as navigation for assistive technologies, and avoid skipping levels.
|
|
5
|
+
|
|
6
|
+
# Variants
|
|
7
|
+
|
|
8
|
+
> - Plain, Spacious
|
|
9
|
+
|
|
10
|
+
## Plain
|
|
11
|
+
|
|
12
|
+
```jsx
|
|
13
|
+
<Subhead heading="Plain subhead" />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Spacious
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
<Subhead heading="Spacious subhead" isSpacious={true} />
|
|
20
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import { SubheadProps, defaultProps } from './Subhead.prop'
|
|
3
|
+
import styles from './Subhead.scss'
|
|
4
|
+
|
|
5
|
+
export function Subhead({ className = defaultProps.className, heading, isSpacious = defaultProps.isSpacious }: SubheadProps) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
className={cx(className, styles.Subhead, {
|
|
9
|
+
[styles['Subhead--spacious']]: isSpacious === true,
|
|
10
|
+
})}
|
|
11
|
+
>
|
|
12
|
+
<div className={styles['Subhead-heading']}>{heading}</div>
|
|
13
|
+
</div>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { withTests } from '@storybook/addon-jest'
|
|
2
|
+
import results from '../../../../../../.jest-test-results.json'
|
|
3
|
+
|
|
4
|
+
const Subhead =
|
|
5
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
6
|
+
? require('../../../index').primer.Subhead
|
|
7
|
+
: require('../../../../build').primer.Subhead
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Primer/Atom/Subhead',
|
|
11
|
+
component: Subhead,
|
|
12
|
+
decorators: [withTests({ results })],
|
|
13
|
+
parameters: { jest: ['Subhead.int.test.js'] },
|
|
14
|
+
excludeStories: ['custom'],
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function plain() {
|
|
18
|
+
return <Subhead heading="Plain subhead" />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function spacious() {
|
|
22
|
+
return <Subhead heading="Spacious subhead" isSpacious={true} />
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { plain, spacious } from './Subhead.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Subhead />', () => {
|
|
4
|
+
describe('Render', () => {
|
|
5
|
+
test('must match plain()', () => {
|
|
6
|
+
expect(global.renderToJSON(plain())).toMatchSnapshot()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('must match spacious()', () => {
|
|
10
|
+
expect(global.renderToJSON(spacious())).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Subhead } from './Subhead'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const toastVariant = {
|
|
2
|
+
info: 'info',
|
|
3
|
+
success: 'success',
|
|
4
|
+
warning: 'warning',
|
|
5
|
+
error: 'error',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const defaultProps = {
|
|
9
|
+
className: null,
|
|
10
|
+
variant: toastVariant.info,
|
|
11
|
+
isDismissable: false,
|
|
12
|
+
onClick: () => {},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ToastProps {
|
|
16
|
+
className?: string
|
|
17
|
+
variant?: typeof toastVariant.info | typeof toastVariant.success | typeof toastVariant.warning | typeof toastVariant.error
|
|
18
|
+
text: string
|
|
19
|
+
isDismissable?: boolean
|
|
20
|
+
onClick?: (value) => void
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import cx from 'classnames'
|
|
2
|
+
import paddingStyles from '@papillonarts/css/build/primer/utilities/padding.scss'
|
|
3
|
+
import { ToastProps, defaultProps, toastVariant } from './Toast.prop'
|
|
4
|
+
import styles from './Toast.scss'
|
|
5
|
+
import { Icon, iconName, iconSize } from '../Icon'
|
|
6
|
+
|
|
7
|
+
export function Toast({
|
|
8
|
+
className = defaultProps.className,
|
|
9
|
+
variant = defaultProps.variant,
|
|
10
|
+
text,
|
|
11
|
+
isDismissable = defaultProps.isDismissable,
|
|
12
|
+
onClick = defaultProps.onClick,
|
|
13
|
+
}: ToastProps) {
|
|
14
|
+
return (
|
|
15
|
+
<div className={cx(className, paddingStyles['p-1'])}>
|
|
16
|
+
<div
|
|
17
|
+
className={cx(styles.Toast, {
|
|
18
|
+
[styles['Toast--success']]: variant === toastVariant.success,
|
|
19
|
+
[styles['Toast--warning']]: variant === toastVariant.warning,
|
|
20
|
+
[styles['Toast--error']]: variant === toastVariant.error,
|
|
21
|
+
})}
|
|
22
|
+
>
|
|
23
|
+
<span className={styles['Toast-icon']}>
|
|
24
|
+
{variant === toastVariant.info && <Icon icon={iconName.Info16} />}
|
|
25
|
+
{variant === toastVariant.success && <Icon icon={iconName.Check16} />}
|
|
26
|
+
{variant === toastVariant.warning && <Icon icon={iconName.Alert16} />}
|
|
27
|
+
{variant === toastVariant.error && <Icon icon={iconName.Stop16} />}
|
|
28
|
+
</span>
|
|
29
|
+
<span className={styles['Toast-content']}>{text}</span>
|
|
30
|
+
{isDismissable && (
|
|
31
|
+
<button type="button" className={styles['Toast-dismissButton']} onClick={onClick}>
|
|
32
|
+
<Icon icon={iconName.X16} size={iconSize.small} />
|
|
33
|
+
</button>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { action } from 'storybook/actions'
|
|
2
|
+
import { withTests } from '@storybook/addon-jest'
|
|
3
|
+
import { toastVariant } from '../Toast.prop'
|
|
4
|
+
import results from '../../../../../../.jest-test-results.json'
|
|
5
|
+
|
|
6
|
+
const text = {
|
|
7
|
+
custom: 'Toast message goes here',
|
|
8
|
+
info: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.Aenean massa. Cum sociis natoquepenatibus et ma',
|
|
9
|
+
success: 'Success message goes here',
|
|
10
|
+
warning: 'Warning message goes here',
|
|
11
|
+
error: 'Error message goes here',
|
|
12
|
+
dismissable: 'This toast is dismissable.',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Toast =
|
|
16
|
+
process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
|
|
17
|
+
? require('../../../index').primer.Toast.Toast
|
|
18
|
+
: require('../../../../build').primer.Toast.Toast
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: 'Primer/Molecule/Toast',
|
|
22
|
+
component: Toast,
|
|
23
|
+
decorators: [withTests({ results })],
|
|
24
|
+
parameters: { jest: ['Toast.int.test.js'] },
|
|
25
|
+
excludeStories: ['custom'],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function custom(onClick) {
|
|
29
|
+
return <Toast text={text.custom} isDismissable={true} onClick={onClick} />
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function info() {
|
|
33
|
+
return <Toast variant={toastVariant.info} text={text.info} />
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function success() {
|
|
37
|
+
return <Toast variant={toastVariant.success} text={text.success} />
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function warning() {
|
|
41
|
+
return <Toast variant={toastVariant.warning} text={text.warning} />
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function error() {
|
|
45
|
+
return <Toast variant={toastVariant.error} text={text.error} />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function dismissable() {
|
|
49
|
+
return <Toast variant={toastVariant.info} text={text.dismissable} isDismissable={true} onClick={action('onClick')} />
|
|
50
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { info, success, warning, error, dismissable } from './Toast.int.story'
|
|
2
|
+
|
|
3
|
+
describe('<Button />', () => {
|
|
4
|
+
describe('Render', () => {
|
|
5
|
+
test('must match info()', () => {
|
|
6
|
+
expect(global.renderToJSON(info())).toMatchSnapshot()
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
test('must match success()', () => {
|
|
10
|
+
expect(global.renderToJSON(success())).toMatchSnapshot()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('must match warning()', () => {
|
|
14
|
+
expect(global.renderToJSON(warning())).toMatchSnapshot()
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
test('must match error()', () => {
|
|
18
|
+
expect(global.renderToJSON(error())).toMatchSnapshot()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('must match dismissable()', () => {
|
|
22
|
+
expect(global.renderToJSON(dismissable())).toMatchSnapshot()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
})
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Alert, alertVariant } from './Alert'
|
|
2
|
+
import { Breadcrumb, breadcrumbState } from './Breadcrumb'
|
|
3
|
+
import { Blankslate, blankslateVariant } from './Blankslate'
|
|
4
|
+
import { Button, buttonElement, buttonVariant, buttonSize, buttonState, iconAlignment, buttonInputType } from './Button'
|
|
5
|
+
import { Dropdown, dropdownState } from './Dropdown'
|
|
6
|
+
import { ErrorBoundary } from './ErrorBoundary'
|
|
7
|
+
import { Form } from './Form'
|
|
8
|
+
import { Grid } from './Grid'
|
|
9
|
+
import { Icon, iconName, iconSize } from './Icon'
|
|
10
|
+
import { Label } from './Label'
|
|
11
|
+
import { Loader, loaderVariant } from './Loader'
|
|
12
|
+
import { Navigation } from './Navigation'
|
|
13
|
+
import { Pagination } from './Pagination'
|
|
14
|
+
import { Popover, popoverVariant, popoverSize } from './Popover'
|
|
15
|
+
import { Progress, progressVariant } from './Progress'
|
|
16
|
+
import { Select, selectState } from './Select'
|
|
17
|
+
import { SelectMenu } from './SelectMenu'
|
|
18
|
+
import { Subhead } from './Subhead'
|
|
19
|
+
import { Toast, toastVariant } from './Toast'
|
|
20
|
+
|
|
21
|
+
import '@papillonarts/css/build/primer/index.scss'
|
|
22
|
+
|
|
23
|
+
export const primer = {
|
|
24
|
+
Alert: {
|
|
25
|
+
Alert,
|
|
26
|
+
alertVariant,
|
|
27
|
+
},
|
|
28
|
+
Breadcrumb: {
|
|
29
|
+
Breadcrumb,
|
|
30
|
+
breadcrumbState,
|
|
31
|
+
},
|
|
32
|
+
Blankslate: {
|
|
33
|
+
Blankslate,
|
|
34
|
+
blankslateVariant,
|
|
35
|
+
},
|
|
36
|
+
Button: {
|
|
37
|
+
Button,
|
|
38
|
+
buttonElement,
|
|
39
|
+
buttonVariant,
|
|
40
|
+
buttonSize,
|
|
41
|
+
buttonState,
|
|
42
|
+
iconAlignment,
|
|
43
|
+
buttonInputType,
|
|
44
|
+
},
|
|
45
|
+
Dropdown: {
|
|
46
|
+
Dropdown,
|
|
47
|
+
dropdownState,
|
|
48
|
+
},
|
|
49
|
+
ErrorBoundary,
|
|
50
|
+
Form,
|
|
51
|
+
Grid,
|
|
52
|
+
Icon: {
|
|
53
|
+
Icon,
|
|
54
|
+
iconName,
|
|
55
|
+
iconSize,
|
|
56
|
+
},
|
|
57
|
+
Label,
|
|
58
|
+
Loader: {
|
|
59
|
+
Loader,
|
|
60
|
+
loaderVariant,
|
|
61
|
+
},
|
|
62
|
+
Navigation,
|
|
63
|
+
Pagination,
|
|
64
|
+
Popover: {
|
|
65
|
+
Popover,
|
|
66
|
+
popoverVariant,
|
|
67
|
+
popoverSize,
|
|
68
|
+
},
|
|
69
|
+
Progress: {
|
|
70
|
+
Progress,
|
|
71
|
+
progressVariant,
|
|
72
|
+
},
|
|
73
|
+
Select: {
|
|
74
|
+
Select,
|
|
75
|
+
selectState,
|
|
76
|
+
},
|
|
77
|
+
SelectMenu,
|
|
78
|
+
Subhead,
|
|
79
|
+
Toast: {
|
|
80
|
+
Toast,
|
|
81
|
+
toastVariant,
|
|
82
|
+
},
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papillonarts/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Papillon Arts Components",
|
|
5
5
|
"homepage": "https://github.com/papillonarts/papillonarts/tree/master/packages/components",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"build-release": "npm run build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@papillonarts/css": "^0.
|
|
33
|
-
"@papillonarts/library": "^0.
|
|
32
|
+
"@papillonarts/css": "^0.9.0",
|
|
33
|
+
"@papillonarts/library": "^0.9.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "584fbedfbea9771d584d15adb3396feb2e9c56b6"
|
|
36
36
|
}
|
package/build/index.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.Alert = Alert;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
var _hooks = require("@papillonarts/library/hooks");
|
|
12
|
-
var _margin = _interopRequireDefault(require("@papillonarts/css/build/primer/utilities/margin.scss"));
|
|
13
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _Alert = require("./Alert.prop");
|
|
15
|
-
var _Alert2 = _interopRequireDefault(require("./Alert.scss"));
|
|
16
|
-
var _Button = _interopRequireDefault(require("../Button/Button.scss"));
|
|
17
|
-
var _Input = require("../Form/Input");
|
|
18
|
-
var _Button2 = require("../Button");
|
|
19
|
-
var _Icon = require("../Icon/Icon.prop");
|
|
20
|
-
var _Icon2 = require("../Icon");
|
|
21
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
function Alert(_ref) {
|
|
23
|
-
var _consent$action3;
|
|
24
|
-
var _ref$dataTest = _ref.dataTest,
|
|
25
|
-
dataTest = _ref$dataTest === void 0 ? _Alert.defaultProps.dataTest : _ref$dataTest,
|
|
26
|
-
_ref$className = _ref.className,
|
|
27
|
-
className = _ref$className === void 0 ? _Alert.defaultProps.className : _ref$className,
|
|
28
|
-
_ref$variant = _ref.variant,
|
|
29
|
-
variant = _ref$variant === void 0 ? _Alert.defaultProps.variant : _ref$variant,
|
|
30
|
-
children = _ref.children,
|
|
31
|
-
consent = _ref.consent;
|
|
32
|
-
var _useState = (0, _hooks.useState)(''),
|
|
33
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
34
|
-
consentValue = _useState2[0],
|
|
35
|
-
setConsentValue = _useState2[1];
|
|
36
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
37
|
-
"data-test": dataTest === null || dataTest === void 0 ? void 0 : dataTest["default"],
|
|
38
|
-
className: className,
|
|
39
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
40
|
-
className: (0, _classnames["default"])(_Alert2["default"]['flash-messages']),
|
|
41
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
42
|
-
className: (0, _classnames["default"])(_Alert2["default"].flash, (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, _Alert2["default"]['flash-warn'], variant === _Alert.alertVariant.warning), _Alert2["default"]['flash-error'], variant === _Alert.alertVariant.error), _Alert2["default"]['flash-success'], variant === _Alert.alertVariant.success), _Alert2["default"]['flash-consent'], variant === _Alert.alertVariant.consent)),
|
|
43
|
-
children: [consent && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
44
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button2.Button, {
|
|
45
|
-
dataTest: dataTest === null || dataTest === void 0 ? void 0 : dataTest.cancel,
|
|
46
|
-
className: (0, _classnames["default"])(_Button["default"].btn, _Button["default"]['btn-sm'], _Button["default"].primary, _Alert2["default"]['flash-action']),
|
|
47
|
-
text: "Cancel",
|
|
48
|
-
icon: {
|
|
49
|
-
name: _Icon.iconName.XCircleFill16,
|
|
50
|
-
alignment: _Button2.iconAlignment.left
|
|
51
|
-
},
|
|
52
|
-
variant: _Button2.buttonVariant["default"],
|
|
53
|
-
inputType: _Button2.buttonInputType.submit,
|
|
54
|
-
onClick: function onClick() {
|
|
55
|
-
var _consent$action;
|
|
56
|
-
consent === null || consent === void 0 || (_consent$action = consent.action) === null || _consent$action === void 0 || _consent$action.cancel();
|
|
57
|
-
setConsentValue('');
|
|
58
|
-
}
|
|
59
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button2.Button, {
|
|
60
|
-
dataTest: dataTest === null || dataTest === void 0 ? void 0 : dataTest.approve,
|
|
61
|
-
className: (0, _classnames["default"])(_Button["default"].btn, _Button["default"]['btn-sm'], _Button["default"].primary, _Alert2["default"]['flash-action']),
|
|
62
|
-
text: "Approve",
|
|
63
|
-
icon: {
|
|
64
|
-
name: _Icon.iconName.CheckCircleFill16,
|
|
65
|
-
alignment: _Button2.iconAlignment.left
|
|
66
|
-
},
|
|
67
|
-
variant: _Button2.buttonVariant.primary,
|
|
68
|
-
inputType: _Button2.buttonInputType.submit,
|
|
69
|
-
autoFocus: consent !== null && consent !== void 0 && consent.withInput ? false : true // eslint-disable-line
|
|
70
|
-
,
|
|
71
|
-
onClick: consent !== null && consent !== void 0 && consent.withInput ? function () {
|
|
72
|
-
if (consentValue !== '') {
|
|
73
|
-
var _consent$action2;
|
|
74
|
-
consent === null || consent === void 0 || (_consent$action2 = consent.action) === null || _consent$action2 === void 0 || _consent$action2.approve(consentValue);
|
|
75
|
-
setConsentValue('');
|
|
76
|
-
}
|
|
77
|
-
} : consent === null || consent === void 0 || (_consent$action3 = consent.action) === null || _consent$action3 === void 0 ? void 0 : _consent$action3.approve
|
|
78
|
-
})]
|
|
79
|
-
}), variant === _Alert.alertVariant.info && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
80
|
-
className: _margin["default"]['mr-2'],
|
|
81
|
-
icon: _Icon.iconName.Info16,
|
|
82
|
-
size: _Icon2.iconSize.small
|
|
83
|
-
}), variant === _Alert.alertVariant.warning && !consent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
84
|
-
className: _margin["default"]['mr-2'],
|
|
85
|
-
icon: _Icon.iconName.Alert16,
|
|
86
|
-
size: _Icon2.iconSize.small
|
|
87
|
-
}), variant === _Alert.alertVariant.warning && consent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
88
|
-
className: _margin["default"]['mr-2'],
|
|
89
|
-
icon: _Icon.iconName.Question16,
|
|
90
|
-
size: _Icon2.iconSize.small
|
|
91
|
-
}), variant === _Alert.alertVariant.error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
92
|
-
className: _margin["default"]['mr-2'],
|
|
93
|
-
icon: _Icon.iconName.XCircle16,
|
|
94
|
-
size: _Icon2.iconSize.small
|
|
95
|
-
}), variant === _Alert.alertVariant.success && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
96
|
-
className: _margin["default"]['mr-2'],
|
|
97
|
-
icon: _Icon.iconName.CheckCircle16,
|
|
98
|
-
size: _Icon2.iconSize.small
|
|
99
|
-
}), variant === _Alert.alertVariant.consent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon2.Icon, {
|
|
100
|
-
className: _margin["default"]['mr-2'],
|
|
101
|
-
icon: _Icon.iconName.Question16,
|
|
102
|
-
size: _Icon2.iconSize.small
|
|
103
|
-
}), children, (consent === null || consent === void 0 ? void 0 : consent.withInput) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.Input, {
|
|
104
|
-
dataTest: dataTest === null || dataTest === void 0 ? void 0 : dataTest.value,
|
|
105
|
-
className: _Alert2["default"]['flash-action'],
|
|
106
|
-
value: consentValue,
|
|
107
|
-
placeholder: "",
|
|
108
|
-
ariaAttr: {},
|
|
109
|
-
onChange: function onChange(event) {
|
|
110
|
-
setConsentValue(event.target.value);
|
|
111
|
-
},
|
|
112
|
-
onKeyUp: function onKeyUp(event) {
|
|
113
|
-
setConsentValue(event.target.value);
|
|
114
|
-
},
|
|
115
|
-
autoFocus: true // eslint-disable-line
|
|
116
|
-
})]
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
Alert.propTypes = _Alert.propTypes;
|