@loadsmart/loadsmart-ui 5.10.1 → 5.11.1
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/dist/components/Calendar/Calendar.stories.d.ts +2 -7
- package/dist/components/Calendar/Date.helper.d.ts +47 -12
- package/dist/components/Dropdown/Dropdown.stories.d.ts +4 -1
- package/dist/components/Loaders/LoadingBar.stories.d.ts +1 -1
- package/dist/index.js +445 -295
- package/dist/index.js.map +1 -1
- package/dist/testing/SelectEvent/SelectEvent.d.ts +2 -0
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/tests/generator.d.ts +35 -0
- package/dist/tests/renderer.d.ts +10 -0
- package/package.json +8 -7
- package/src/common/CloseButton/CloseButton.tsx +11 -7
- package/src/common/SelectionWrapper.tsx +7 -7
- package/src/components/Accordion/Accordion.stories.tsx +1 -1
- package/src/components/Accordion/Accordion.test.tsx +2 -2
- package/src/components/Accordion/Accordion.tsx +28 -22
- package/src/components/Banner/Banner.test.tsx +2 -2
- package/src/components/Banner/Banner.tsx +2 -2
- package/src/components/Breadcrumbs/Breadbrumbs.test.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumb.tsx +3 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Button/Button.test.tsx +2 -2
- package/src/components/Button/Button.tsx +20 -17
- package/src/components/Calendar/Calendar.stories.tsx +4 -2
- package/src/components/Calendar/Calendar.test.tsx +3 -3
- package/src/components/Calendar/Calendar.tsx +8 -4
- package/src/components/Calendar/Date.helper.test.ts +463 -15
- package/src/components/Calendar/Date.helper.ts +106 -45
- package/src/components/Calendar/PickerModeToggle.tsx +6 -3
- package/src/components/Calendar/Pickers/DayPicker.test.tsx +2 -2
- package/src/components/Calendar/Pickers/DayPicker.tsx +1 -1
- package/src/components/Calendar/Pickers/MonthPicker.test.tsx +2 -2
- package/src/components/Calendar/Pickers/MonthPicker.tsx +1 -1
- package/src/components/Calendar/Pickers/PickerButton.tsx +39 -29
- package/src/components/Calendar/Pickers/YearPicker.test.tsx +9 -7
- package/src/components/Calendar/Pickers/YearPicker.tsx +1 -1
- package/src/components/Card/Card.stories.tsx +1 -1
- package/src/components/Card/Card.test.tsx +2 -2
- package/src/components/Card/Card.tsx +9 -6
- package/src/components/Card/CardTitle.tsx +3 -4
- package/src/components/Checkbox/Checkbox.test.tsx +2 -2
- package/src/components/Checkbox/Checkbox.tsx +26 -14
- package/src/components/DatePicker/DatePicker.test.tsx +2 -2
- package/src/components/DatePicker/DateRangePicker.stories.tsx +6 -1
- package/src/components/DatePicker/DateRangePicker.test.tsx +2 -2
- package/src/components/Dialog/Dialog.test.tsx +2 -2
- package/src/components/Dialog/Dialog.tsx +5 -5
- package/src/components/DragDropFile/components/DropZone.test.tsx +1 -1
- package/src/components/DragDropFile/styles.tsx +11 -6
- package/src/components/Drawer/Drawer.test.tsx +1 -1
- package/src/components/Drawer/Drawer.tsx +6 -6
- package/src/components/Dropdown/Dropdown.stories.tsx +10 -5
- package/src/components/Dropdown/Dropdown.test.tsx +14 -16
- package/src/components/Dropdown/DropdownMenu.tsx +28 -15
- package/src/components/Dropdown/DropdownTrigger.tsx +34 -24
- package/src/components/EmptyState/EmptyState.test.tsx +1 -1
- package/src/components/ErrorMessage/ErrorMessage.test.tsx +1 -1
- package/src/components/HighlightMatch/HighlightMatch.test.tsx +1 -1
- package/src/components/HighlightMatch/HighlightMatch.tsx +1 -2
- package/src/components/IconFactory/IconFactory.test.tsx +2 -2
- package/src/components/Label/Label.test.tsx +2 -2
- package/src/components/Label/Label.tsx +3 -3
- package/src/components/Link/Link.test.tsx +2 -2
- package/src/components/Link/Link.tsx +13 -9
- package/src/components/Loaders/LoadingBar.stories.tsx +2 -2
- package/src/components/Loaders/LoadingBar.test.tsx +1 -1
- package/src/components/Loaders/LoadingBar.tsx +2 -2
- package/src/components/Loaders/LoadingDots.test.tsx +1 -1
- package/src/components/Loaders/Spinner.test.tsx +2 -2
- package/src/components/Modal/Modal.test.tsx +2 -2
- package/src/components/Modal/Modal.tsx +12 -7
- package/src/components/Pagination/Pagination.test.tsx +1 -1
- package/src/components/Popover/Popover.test.tsx +2 -2
- package/src/components/ProgressBar/ProgressBar.test.tsx +1 -1
- package/src/components/ProgressBar/ProgressBar.tsx +6 -4
- package/src/components/Radio/Radio.test.tsx +2 -2
- package/src/components/Radio/Radio.tsx +19 -11
- package/src/components/Section/Section.test.tsx +2 -2
- package/src/components/Section/Section.tsx +8 -6
- package/src/components/Section/Sections.stories.tsx +1 -1
- package/src/components/Select/Select.fixtures.ts +1 -1
- package/src/components/Select/Select.stories.tsx +2 -2
- package/src/components/Select/Select.test.tsx +162 -155
- package/src/components/Select/SelectEmpty.tsx +5 -4
- package/src/components/Select/SelectTrigger.tsx +11 -6
- package/src/components/Select/useSelect.helpers.test.ts +1 -1
- package/src/components/SideNavigation/Logo/Logo.test.tsx +2 -2
- package/src/components/SideNavigation/Menu/Menu.test.tsx +2 -2
- package/src/components/SideNavigation/Menu/Menu.tsx +3 -3
- package/src/components/SideNavigation/Menu/MenuBaseItem.tsx +5 -4
- package/src/components/SideNavigation/Menu/MenuExpandable.tsx +3 -2
- package/src/components/SideNavigation/Separator/Separator.test.tsx +1 -1
- package/src/components/SideNavigation/SideNavigation.test.tsx +2 -2
- package/src/components/Steps/ProgressSteps/ProgressStep.tsx +39 -31
- package/src/components/Steps/Steps.fixtures.ts +1 -1
- package/src/components/Steps/Steps.test.tsx +2 -2
- package/src/components/Steps/useStep.test.tsx +1 -1
- package/src/components/Switch/Switch.test.tsx +1 -1
- package/src/components/Switch/Switch.tsx +18 -6
- package/src/components/Table/Table.fixtures.ts +1 -1
- package/src/components/Table/Table.test.tsx +1 -1
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/TablePagination/TablePagination.test.tsx +1 -1
- package/src/components/Tabs/Tabs.test.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +32 -26
- package/src/components/Tag/Tag.stories.tsx +1 -1
- package/src/components/Tag/Tag.test.tsx +2 -2
- package/src/components/Tag/Tag.tsx +44 -35
- package/src/components/Text/Text.test.tsx +2 -2
- package/src/components/TextField/TextField.test.tsx +1 -1
- package/src/components/TextField/TextField.tsx +22 -15
- package/src/components/Textarea/Textarea.test.tsx +1 -1
- package/src/components/Textarea/Textarea.tsx +22 -17
- package/src/components/Toast/Toast.test.tsx +2 -2
- package/src/components/Toast/Toast.tsx +3 -3
- package/src/components/ToggleGroup/Toggle.test.tsx +2 -2
- package/src/components/ToggleGroup/Toggle.tsx +7 -7
- package/src/components/ToggleGroup/ToggleGroup.stories.tsx +14 -12
- package/src/components/ToggleGroup/ToggleGroup.test.tsx +2 -2
- package/src/components/Tooltip/Tooltip.test.tsx +2 -2
- package/src/components/Tooltip/Tooltip.tsx +22 -20
- package/src/components/TopNavigation/Logo/Logo.test.tsx +2 -2
- package/src/components/TopNavigation/Menu/Menu.test.tsx +1 -1
- package/src/components/TopNavigation/Menu/MenuItemDropdown.tsx +1 -1
- package/src/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +1 -1
- package/src/hooks/useClickOutside/useClickOutside.test.tsx +1 -1
- package/src/hooks/useDidMount/useDidMount.test.tsx +1 -1
- package/src/hooks/useFocusTrap/useFocusTrap.test.tsx +1 -1
- package/src/hooks/useFocusWithin/useFocusWithin.test.tsx +1 -1
- package/src/hooks/useHeightExpansionToggler/useHeightExpansionToggler.test.tsx +1 -1
- package/src/hooks/useSelectable/SelectableStrategy.test.ts +1 -1
- package/src/hooks/useSelectable/useSelectable.test.ts +1 -1
- package/src/styles/font.tsx +3 -3
- package/src/testing/SelectEvent/SelectEvent.test.tsx +2 -2
- package/src/testing/SelectEvent/SelectEvent.ts +87 -45
- package/src/tests/generator.ts +127 -0
- package/src/tests/renderer.tsx +39 -0
- package/src/tools/conditional.test.ts +1 -1
- package/src/utils/toolset/interleave.test.ts +1 -1
|
@@ -21,32 +21,45 @@ export interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement>, Se
|
|
|
21
21
|
const Check = styled(Icon)<SelectionStyleProps>`
|
|
22
22
|
position: absolute;
|
|
23
23
|
top: 50%;
|
|
24
|
+
|
|
24
25
|
left: 50%;
|
|
25
|
-
|
|
26
|
+
|
|
26
27
|
transform: translate(-50%, -50%);
|
|
28
|
+
|
|
29
|
+
pointer-events: none;
|
|
27
30
|
`
|
|
28
31
|
|
|
29
32
|
const Selector = styled.input<SelectionStyleProps>`
|
|
33
|
+
${transition()}
|
|
34
|
+
|
|
30
35
|
display: inline-flex;
|
|
31
36
|
flex-flow: row nowrap;
|
|
32
37
|
align-items: center;
|
|
33
|
-
|
|
34
|
-
height: ${token('checkbox-selector-size')};
|
|
35
|
-
color: white;
|
|
38
|
+
|
|
36
39
|
cursor: pointer;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
appearance: none;
|
|
42
|
+
|
|
43
|
+
outline: none;
|
|
44
|
+
|
|
45
|
+
color: white;
|
|
46
|
+
|
|
47
|
+
height: ${token('checkbox-selector-size')};
|
|
48
|
+
width: ${token('checkbox-selector-size')};
|
|
49
|
+
|
|
50
|
+
border-radius: ${token('checkbox-selector-border-radius')};
|
|
51
|
+
border-width: ${token('button-border-width')};
|
|
52
|
+
border-style: solid;
|
|
53
|
+
|
|
41
54
|
border-color: ${conditional({
|
|
42
55
|
'checkbox-selector-border-color': whenProps({ scheme: 'light' }),
|
|
43
56
|
'checkbox-dark-selector-border-color': whenProps({ scheme: 'dark' }),
|
|
44
57
|
})};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
|
|
59
|
+
background: ${conditional({
|
|
60
|
+
'checkbox-selector-background': whenProps({ scheme: 'light' }),
|
|
61
|
+
'checkbox-dark-selector-background': whenProps({ scheme: 'dark' }),
|
|
62
|
+
})};
|
|
50
63
|
|
|
51
64
|
:checked {
|
|
52
65
|
background-color: ${token('checkbox-selector-checked-background')};
|
|
@@ -116,7 +129,6 @@ const Selector = styled.input<SelectionStyleProps>`
|
|
|
116
129
|
|
|
117
130
|
box-shadow: ${token('checkbox-selector-outline')};
|
|
118
131
|
`}
|
|
119
|
-
${transition()}
|
|
120
132
|
`
|
|
121
133
|
|
|
122
134
|
function Checkbox({
|
|
@@ -7,8 +7,8 @@ import { formatter } from './DatePicker'
|
|
|
7
7
|
import { MonthHelper } from '../Calendar'
|
|
8
8
|
import * as stories from './DatePicker.stories'
|
|
9
9
|
import DateHelper, { TODAY } from '../Calendar/Date.helper'
|
|
10
|
-
import generator from '
|
|
11
|
-
import renderer, { screen, fire } from '
|
|
10
|
+
import generator from '../../tests/generator'
|
|
11
|
+
import renderer, { screen, fire } from '../../tests/renderer'
|
|
12
12
|
|
|
13
13
|
import type { DatePickerProps } from './DatePicker.types'
|
|
14
14
|
import type { CalendarMonthAlias } from '../Calendar'
|
|
@@ -6,6 +6,7 @@ import DateRangePicker from './DateRangePicker'
|
|
|
6
6
|
|
|
7
7
|
import type { Story, Meta } from '@storybook/react/types-6-0'
|
|
8
8
|
import type { DateRangePickerProps } from './DatePicker.types'
|
|
9
|
+
import type { useCalendarProps } from 'components/Calendar'
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
title: 'Components/Date/DateRangePicker',
|
|
@@ -53,13 +54,15 @@ export const Playground: Story<DateRangePickerProps> = (args: DateRangePickerPro
|
|
|
53
54
|
)
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
Playground.bind({})
|
|
58
|
+
|
|
56
59
|
Playground.args = {
|
|
57
60
|
id: 'playground-date-range-picker',
|
|
58
61
|
name: 'playground-date-range-picker',
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export const WithValue: Story<DateRangePickerProps> = (args: DateRangePickerProps) => {
|
|
62
|
-
const [value, setValue] = useState([
|
|
65
|
+
const [value, setValue] = useState<useCalendarProps['selected']>([
|
|
63
66
|
DateHelper('December 17, 1995').toString(),
|
|
64
67
|
DateHelper('December 22, 1995').toString(),
|
|
65
68
|
])
|
|
@@ -82,6 +85,8 @@ export const WithValue: Story<DateRangePickerProps> = (args: DateRangePickerProp
|
|
|
82
85
|
)
|
|
83
86
|
}
|
|
84
87
|
|
|
88
|
+
WithValue.bind({})
|
|
89
|
+
|
|
85
90
|
WithValue.args = {
|
|
86
91
|
id: 'with-value-date-range-picker',
|
|
87
92
|
name: 'with-value-date-range-picker',
|
|
@@ -7,8 +7,8 @@ import { DateRangePickerEvent } from '../../testing/DatePickerEvent'
|
|
|
7
7
|
import { formatter } from './DateRangePicker'
|
|
8
8
|
import * as stories from './DateRangePicker.stories'
|
|
9
9
|
import DateHelper, { TODAY } from '../Calendar/Date.helper'
|
|
10
|
-
import generator from '
|
|
11
|
-
import renderer, { screen, fire } from '
|
|
10
|
+
import generator from '../../tests/generator'
|
|
11
|
+
import renderer, { screen, fire } from '../../tests/renderer'
|
|
12
12
|
|
|
13
13
|
import type { DateRangePickerProps } from './DatePicker.types'
|
|
14
14
|
import type { CalendarDate, CalendarMonthAlias } from '../Calendar'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { Fragment } from 'react'
|
|
2
2
|
|
|
3
3
|
import Dialog from './Dialog'
|
|
4
|
-
import generator from '
|
|
5
|
-
import renderer, { screen } from '
|
|
4
|
+
import generator from '../../tests/generator'
|
|
5
|
+
import renderer, { screen } from '../../tests/renderer'
|
|
6
6
|
import type { DialogProps } from './Dialog'
|
|
7
7
|
|
|
8
8
|
const setup = (props: DialogProps) => renderer(<Dialog {...props} />).render()
|
|
@@ -23,11 +23,11 @@ export interface DialogProps extends WithScaleProps {
|
|
|
23
23
|
|
|
24
24
|
const Header = styled.h1`
|
|
25
25
|
padding-bottom: ${token('space-s')};
|
|
26
|
-
font-size: ${token('font-size-2')};
|
|
27
|
-
font-weight: ${token('font-weight-bold')};
|
|
28
|
-
line-height: ${token('font-height-2')};
|
|
29
26
|
|
|
30
27
|
color: ${token('dialog-header-color')};
|
|
28
|
+
font-weight: ${token('font-weight-bold')};
|
|
29
|
+
font-size: ${token('font-size-2')};
|
|
30
|
+
line-height: ${token('font-height-2')};
|
|
31
31
|
text-align: center;
|
|
32
32
|
|
|
33
33
|
border-bottom: 1px solid ${token('dialog-header-border-color')};
|
|
@@ -35,10 +35,10 @@ const Header = styled.h1`
|
|
|
35
35
|
const Body = styled.div`
|
|
36
36
|
margin-top: ${token('space-l')};
|
|
37
37
|
margin-bottom: ${token('space-l')};
|
|
38
|
-
font-size: ${token('font-size-4')};
|
|
39
|
-
line-height: ${token('font-height-3')};
|
|
40
38
|
|
|
41
39
|
color: ${token('dialog-body-font-color')};
|
|
40
|
+
font-size: ${token('font-size-4')};
|
|
41
|
+
line-height: ${token('font-height-3')};
|
|
42
42
|
text-align: center;
|
|
43
43
|
`
|
|
44
44
|
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { screen } from '@testing-library/react'
|
|
3
3
|
import userEvent from '@testing-library/user-event'
|
|
4
4
|
|
|
5
|
-
import generator from '
|
|
5
|
+
import generator from '../../../tests/generator'
|
|
6
6
|
import { renderWithDragDropFileProvider, DragDropFileEvent } from '../../../testing'
|
|
7
7
|
|
|
8
8
|
import type { DropZoneProps } from '../types'
|
|
@@ -29,31 +29,36 @@ export const DragDropFileWrapper = styled(Stack)<{ withFileList: boolean }>`
|
|
|
29
29
|
export const DropZoneWrapper = styled((props: StackProps) => <Stack as="label" {...props} />)<
|
|
30
30
|
Pick<DropZoneProps, 'disabled' | 'error'>
|
|
31
31
|
>`
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
${transition({ property: 'border-color, box-shadow, opacity' })}
|
|
33
|
+
|
|
34
34
|
cursor: pointer;
|
|
35
|
+
|
|
35
36
|
background-color: ${getToken('color-neutral-white')};
|
|
37
|
+
border-radius: ${getToken('border-radius-s')};
|
|
38
|
+
border: 2px dashed;
|
|
36
39
|
border-color: ${conditional({
|
|
37
40
|
'color-neutral-light': whenProps({ error: false }),
|
|
38
41
|
'color-danger': whenProps({ disabled: false, error: true }),
|
|
39
42
|
})};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
padding: ${getToken('space-l')} ${getToken('space-3xl')};
|
|
45
|
+
|
|
46
|
+
text-align: center;
|
|
43
47
|
|
|
44
48
|
${hoverable`
|
|
45
49
|
border-color: ${conditional({
|
|
46
50
|
'color-accent': whenProps({ disabled: false, error: false }),
|
|
47
51
|
})};
|
|
48
52
|
`}
|
|
53
|
+
|
|
49
54
|
${focusable`
|
|
50
55
|
border-color: ${conditional({
|
|
51
56
|
'color-accent': whenProps({ disabled: false, error: false }),
|
|
52
57
|
})};
|
|
53
58
|
box-shadow: ${getToken('shadow-glow-primary')};
|
|
54
59
|
`}
|
|
60
|
+
|
|
55
61
|
${disableable()}
|
|
56
|
-
${transition({ property: 'border-color, box-shadow, opacity' })}
|
|
57
62
|
`
|
|
58
63
|
|
|
59
64
|
export const HiddenInput = styled.input`
|
|
@@ -29,12 +29,12 @@ const StyledAside = styled.aside<Pick<DrawerProps, 'open'>>`
|
|
|
29
29
|
width: 100%;
|
|
30
30
|
height: 100%;
|
|
31
31
|
|
|
32
|
+
background: ${token('modal-overlay-background')};
|
|
33
|
+
|
|
32
34
|
visibility: ${conditional({
|
|
33
35
|
visible: whenProps({ open: true }),
|
|
34
36
|
hidden: whenProps({ open: false }),
|
|
35
37
|
})};
|
|
36
|
-
|
|
37
|
-
background: ${token('modal-overlay-background')};
|
|
38
38
|
`
|
|
39
39
|
|
|
40
40
|
const CloseButton = styled(DefaultCloseButton)`
|
|
@@ -81,15 +81,15 @@ const StyledHeader = styled.header`
|
|
|
81
81
|
justify-content: center;
|
|
82
82
|
|
|
83
83
|
padding: ${token('space-xl')};
|
|
84
|
-
font-size: ${token('font-size-2')};
|
|
85
|
-
font-weight: ${token('font-weight-bold')};
|
|
86
84
|
|
|
87
85
|
color: ${token('color-neutral-darker')};
|
|
86
|
+
font-weight: ${token('font-weight-bold')};
|
|
87
|
+
font-size: ${token('font-size-2')};
|
|
88
88
|
text-align: center;
|
|
89
89
|
|
|
90
90
|
border-bottom-color: ${token('color-neutral-light')};
|
|
91
|
-
border-bottom-style: solid;
|
|
92
91
|
border-bottom-width: 1px;
|
|
92
|
+
border-bottom-style: solid;
|
|
93
93
|
`
|
|
94
94
|
|
|
95
95
|
const StyledBody = styled.div`
|
|
@@ -108,8 +108,8 @@ const StyledFooter = styled.footer`
|
|
|
108
108
|
padding: ${token('space-xl')};
|
|
109
109
|
|
|
110
110
|
border-top-color: ${token('color-neutral-light')};
|
|
111
|
-
border-top-style: solid;
|
|
112
111
|
border-top-width: 1px;
|
|
112
|
+
border-top-style: solid;
|
|
113
113
|
`
|
|
114
114
|
|
|
115
115
|
export interface DrawerHeaderProps {
|
|
@@ -28,9 +28,12 @@ export default {
|
|
|
28
28
|
},
|
|
29
29
|
} as Meta
|
|
30
30
|
|
|
31
|
-
type DropdownStoryProps = DropdownProps &
|
|
31
|
+
export type DropdownStoryProps = DropdownProps & {
|
|
32
|
+
align?: DropdownMenuProps['align']
|
|
33
|
+
outlined?: DropdownTriggerProps['outlined']
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
export const Playground: Story<DropdownStoryProps> = (args
|
|
36
|
+
export const Playground: Story<DropdownStoryProps> = (args) => {
|
|
34
37
|
const [message, setMessage] = useState('')
|
|
35
38
|
|
|
36
39
|
return (
|
|
@@ -58,13 +61,15 @@ export const Playground: Story<DropdownStoryProps> = (args: DropdownStoryProps)
|
|
|
58
61
|
)
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
Playground.bind({})
|
|
65
|
+
|
|
61
66
|
Playground.args = {
|
|
62
67
|
disabled: false,
|
|
63
68
|
align: 'start',
|
|
64
69
|
outlined: true,
|
|
65
70
|
}
|
|
66
71
|
|
|
67
|
-
export const WithSections: Story<DropdownStoryProps> = (args
|
|
72
|
+
export const WithSections: Story<DropdownStoryProps> = (args) => {
|
|
68
73
|
const [message, setMessage] = useState('')
|
|
69
74
|
|
|
70
75
|
return (
|
|
@@ -111,7 +116,7 @@ WithSections.args = {
|
|
|
111
116
|
outlined: true,
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
export const Extended: Story<DropdownStoryProps> = (args
|
|
119
|
+
export const Extended: Story<DropdownStoryProps> = (args) => {
|
|
115
120
|
const [message, setMessage] = useState('')
|
|
116
121
|
|
|
117
122
|
return (
|
|
@@ -185,7 +190,7 @@ function InputTrigger() {
|
|
|
185
190
|
)
|
|
186
191
|
}
|
|
187
192
|
|
|
188
|
-
export const CustomTrigger: Story<DropdownStoryProps> = (args
|
|
193
|
+
export const CustomTrigger: Story<DropdownStoryProps> = (args) => {
|
|
189
194
|
const [message, setMessage] = useState('')
|
|
190
195
|
|
|
191
196
|
function renderMenu() {
|
|
@@ -3,20 +3,18 @@ import { composeStories } from '@storybook/testing-react'
|
|
|
3
3
|
|
|
4
4
|
import { ACTIONS, PROFILE_ACTIONS, SUBSCRIPTION_ACTIONS } from './Dropdown.fixtures'
|
|
5
5
|
import * as stories from './Dropdown.stories'
|
|
6
|
-
import generator from '
|
|
7
|
-
import renderer, { screen, user, waitFor } from '
|
|
8
|
-
|
|
9
|
-
import type { DropdownProps } from './Dropdown.types'
|
|
6
|
+
import generator from '../../tests/generator'
|
|
7
|
+
import renderer, { screen, user, waitFor } from '../../tests/renderer'
|
|
10
8
|
|
|
11
9
|
const { Playground, WithSections, Extended } = composeStories(stories)
|
|
12
10
|
|
|
13
11
|
describe('Dropdown', () => {
|
|
14
12
|
describe('Generic', () => {
|
|
15
|
-
const setup = (overrides
|
|
13
|
+
const setup = (overrides?: stories.DropdownStoryProps) =>
|
|
16
14
|
renderer(<Playground {...overrides} />).render()
|
|
17
15
|
|
|
18
16
|
it('starts collapsed', () => {
|
|
19
|
-
setup(
|
|
17
|
+
setup()
|
|
20
18
|
|
|
21
19
|
screen.getByText('Actions')
|
|
22
20
|
|
|
@@ -26,7 +24,7 @@ describe('Dropdown', () => {
|
|
|
26
24
|
})
|
|
27
25
|
|
|
28
26
|
it('renders all options when expanded', () => {
|
|
29
|
-
setup(
|
|
27
|
+
setup()
|
|
30
28
|
|
|
31
29
|
user.click(screen.getByText('Actions'))
|
|
32
30
|
|
|
@@ -36,7 +34,7 @@ describe('Dropdown', () => {
|
|
|
36
34
|
})
|
|
37
35
|
|
|
38
36
|
it('performs option click and collapses', async () => {
|
|
39
|
-
setup(
|
|
37
|
+
setup()
|
|
40
38
|
|
|
41
39
|
user.click(screen.getByText('Actions'))
|
|
42
40
|
|
|
@@ -64,11 +62,11 @@ describe('Dropdown', () => {
|
|
|
64
62
|
})
|
|
65
63
|
|
|
66
64
|
describe('With Sections', () => {
|
|
67
|
-
const setup = (overrides
|
|
65
|
+
const setup = (overrides?: stories.DropdownStoryProps) =>
|
|
68
66
|
renderer(<WithSections {...overrides} />).render()
|
|
69
67
|
|
|
70
68
|
it('starts collapsed', () => {
|
|
71
|
-
setup(
|
|
69
|
+
setup()
|
|
72
70
|
|
|
73
71
|
screen.getByText('Sections')
|
|
74
72
|
|
|
@@ -78,7 +76,7 @@ describe('Dropdown', () => {
|
|
|
78
76
|
})
|
|
79
77
|
|
|
80
78
|
it('renders all sections and their options when expanded', async () => {
|
|
81
|
-
setup(
|
|
79
|
+
setup()
|
|
82
80
|
|
|
83
81
|
user.click(screen.getByText('Sections'))
|
|
84
82
|
|
|
@@ -100,7 +98,7 @@ describe('Dropdown', () => {
|
|
|
100
98
|
it('performs option click and collapses', async () => {
|
|
101
99
|
const SECTION_ACTIONS = [...PROFILE_ACTIONS, ...SUBSCRIPTION_ACTIONS]
|
|
102
100
|
|
|
103
|
-
setup(
|
|
101
|
+
setup()
|
|
104
102
|
|
|
105
103
|
user.click(screen.getByText('Sections'))
|
|
106
104
|
|
|
@@ -120,11 +118,11 @@ describe('Dropdown', () => {
|
|
|
120
118
|
})
|
|
121
119
|
|
|
122
120
|
describe('With Header and Footer', () => {
|
|
123
|
-
const setup = (overrides
|
|
121
|
+
const setup = (overrides?: stories.DropdownStoryProps) =>
|
|
124
122
|
renderer(<Extended {...overrides} />).render()
|
|
125
123
|
|
|
126
124
|
it('starts collapsed', () => {
|
|
127
|
-
setup(
|
|
125
|
+
setup()
|
|
128
126
|
|
|
129
127
|
screen.getByText('With Header & Footer')
|
|
130
128
|
|
|
@@ -134,7 +132,7 @@ describe('Dropdown', () => {
|
|
|
134
132
|
})
|
|
135
133
|
|
|
136
134
|
it('renders header, footer, and options when expanded', async () => {
|
|
137
|
-
setup(
|
|
135
|
+
setup()
|
|
138
136
|
|
|
139
137
|
user.click(screen.getByText('With Header & Footer'))
|
|
140
138
|
|
|
@@ -150,7 +148,7 @@ describe('Dropdown', () => {
|
|
|
150
148
|
})
|
|
151
149
|
|
|
152
150
|
it('performs option click and collapses', async () => {
|
|
153
|
-
setup(
|
|
151
|
+
setup()
|
|
154
152
|
|
|
155
153
|
user.click(screen.getByText('With Header & Footer'))
|
|
156
154
|
|
|
@@ -66,32 +66,42 @@ const Children = styled.span`
|
|
|
66
66
|
`
|
|
67
67
|
|
|
68
68
|
const DropdownItemWrapper = styled.button`
|
|
69
|
+
${transition()}
|
|
70
|
+
|
|
69
71
|
display: inline-flex;
|
|
70
|
-
flex: 1 0;
|
|
71
|
-
align-items: center;
|
|
72
72
|
justify-content: flex-start;
|
|
73
|
-
|
|
74
|
-
padding: 0 ${token('space-s')};
|
|
75
|
-
margin: 0 ${token('space-s')};
|
|
76
|
-
font-size: ${token('font-size-4')};
|
|
77
|
-
color: ${token('color-neutral-darker')};
|
|
78
|
-
cursor: pointer;
|
|
79
|
-
background: ${token('color-neutral-white')};
|
|
80
|
-
border: none;
|
|
81
|
-
border-radius: ${token('border-radius-s')};
|
|
73
|
+
align-items: center;
|
|
82
74
|
|
|
83
75
|
${font({
|
|
84
76
|
height: 'font-height-3',
|
|
85
77
|
weight: 'font-weight-medium',
|
|
86
78
|
})}
|
|
79
|
+
font-size: ${token('font-size-4')};
|
|
80
|
+
|
|
81
|
+
min-height: 36px;
|
|
82
|
+
flex: 1 0;
|
|
83
|
+
|
|
84
|
+
border: none;
|
|
85
|
+
border-radius: ${token('border-radius-s')};
|
|
86
|
+
background: ${token('color-neutral-white')};
|
|
87
|
+
|
|
88
|
+
color: ${token('color-neutral-darker')};
|
|
89
|
+
|
|
90
|
+
padding: 0 ${token('space-s')};
|
|
91
|
+
|
|
92
|
+
margin: 0 ${token('space-s')};
|
|
93
|
+
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
|
|
87
96
|
${hoverable`
|
|
88
97
|
background: ${token('color-neutral-lighter')};
|
|
89
98
|
`}
|
|
99
|
+
|
|
90
100
|
${focusable`
|
|
91
101
|
background: ${token('color-neutral-lighter')};
|
|
92
102
|
`}
|
|
103
|
+
|
|
93
104
|
${disableable()}
|
|
94
|
-
${transition()}
|
|
95
105
|
|
|
96
106
|
${Children} {
|
|
97
107
|
flex: 1 0 auto;
|
|
@@ -114,14 +124,17 @@ const DropdownItemWrapper = styled.button`
|
|
|
114
124
|
|
|
115
125
|
const DropdownSectionHeader = styled.strong`
|
|
116
126
|
display: flex;
|
|
117
|
-
align-items: center;
|
|
118
127
|
justify-content: flex-start;
|
|
119
|
-
|
|
120
|
-
|
|
128
|
+
align-items: center;
|
|
129
|
+
|
|
121
130
|
${font({
|
|
122
131
|
height: 'font-height-3',
|
|
123
132
|
weight: 'font-weight-bold',
|
|
124
133
|
})}
|
|
134
|
+
|
|
135
|
+
font-size: ${token('font-size-4')};
|
|
136
|
+
|
|
137
|
+
margin: 0 ${token('space-s')};
|
|
125
138
|
`
|
|
126
139
|
|
|
127
140
|
const DropdownSectionWrapper = styled.div`
|
|
@@ -57,15 +57,19 @@ const TriggerButton = styled(
|
|
|
57
57
|
SelectorButton as React.ForwardRefExoticComponent<TriggerButtonProps>
|
|
58
58
|
).attrs(triggerButtonAttrs)`
|
|
59
59
|
flex: 1;
|
|
60
|
+
|
|
60
61
|
justify-content: flex-start;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
|
|
63
|
+
border: none;
|
|
64
|
+
|
|
64
65
|
text-transform: ${conditional({
|
|
65
66
|
capitalize: whenProps({ outlined: false, variant: 'tertiary' }),
|
|
66
67
|
uppercase: whenProps({ outlined: true }),
|
|
67
68
|
})};
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
font-weight: ${conditional({
|
|
71
|
+
'font-weight-regular': whenProps({ outlined: false }),
|
|
72
|
+
})};
|
|
69
73
|
|
|
70
74
|
${hoverable`
|
|
71
75
|
border-color: ${conditional({
|
|
@@ -113,17 +117,17 @@ const TriggerButton = styled(
|
|
|
113
117
|
overflow: hidden;
|
|
114
118
|
|
|
115
119
|
font-weight: ${token('font-weight-bold')};
|
|
116
|
-
pointer-events: none;
|
|
117
120
|
|
|
118
121
|
visibility: hidden;
|
|
119
122
|
|
|
120
|
-
/* @REVIEW: since this is a span descendant of a button
|
|
121
|
-
I'm using the direct value of children the solution inside Link
|
|
123
|
+
/* @REVIEW: since this is a span descendant of a button
|
|
124
|
+
I'm using the direct value of children the solution inside Link
|
|
122
125
|
relies on data-text attribute */
|
|
123
126
|
|
|
124
127
|
content: '${children}';
|
|
125
128
|
content: '${children}' / '';
|
|
126
129
|
user-select: none;
|
|
130
|
+
pointer-events: none;
|
|
127
131
|
|
|
128
132
|
@media speech {
|
|
129
133
|
display: none;
|
|
@@ -135,29 +139,33 @@ const TriggerButton = styled(
|
|
|
135
139
|
`
|
|
136
140
|
|
|
137
141
|
const DropdownTriggerWrapper = styled.div<DropdownTriggerWrapperProps>`
|
|
142
|
+
${transition()}
|
|
143
|
+
|
|
144
|
+
${font({
|
|
145
|
+
height: 'font-height-3',
|
|
146
|
+
weight: 'font-weight-medium',
|
|
147
|
+
})}
|
|
148
|
+
|
|
138
149
|
display: flex;
|
|
139
|
-
flex: 1;
|
|
140
|
-
align-items: center;
|
|
141
150
|
justify-content: flex-start;
|
|
151
|
+
align-items: center;
|
|
142
152
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
color: ${token('color-neutral-darker')};
|
|
153
|
+
border-radius: ${token('button-border-radius')};
|
|
154
|
+
border-width: ${token('button-border-width')};
|
|
155
|
+
border-style: solid;
|
|
147
156
|
border-color: ${conditional({
|
|
148
157
|
'button-secondary-border-color': whenProps({ scheme: 'light', $outlined: true }),
|
|
149
158
|
'button-secondary-dark-border-color': whenProps({ scheme: 'dark', $outlined: true }),
|
|
150
159
|
'color-transparent': whenProps({ $outlined: false }),
|
|
151
160
|
})};
|
|
152
|
-
border-style: solid;
|
|
153
|
-
border-width: ${token('button-border-width')};
|
|
154
|
-
border-radius: ${token('button-border-radius')};
|
|
155
161
|
|
|
156
|
-
${
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
font-size: ${token('font-size-4')};
|
|
163
|
+
|
|
164
|
+
color: ${token('color-neutral-darker')};
|
|
165
|
+
|
|
166
|
+
height: 36px;
|
|
167
|
+
flex: 1;
|
|
168
|
+
|
|
161
169
|
${hoverable`
|
|
162
170
|
border-color: ${conditional({
|
|
163
171
|
'button-secondary-border-color--hover': whenProps({ scheme: 'light', $outlined: true }),
|
|
@@ -205,11 +213,13 @@ const DropdownTriggerWrapper = styled.div<DropdownTriggerWrapperProps>`
|
|
|
205
213
|
`
|
|
206
214
|
|
|
207
215
|
const TriggerHandle = styled(BaseButton)`
|
|
208
|
-
|
|
216
|
+
${focusable()}
|
|
217
|
+
|
|
209
218
|
background: ${token('color-transparent')};
|
|
210
|
-
border: none;
|
|
211
219
|
border-radius: 0 ${token('border-radius-s')} ${token('border-radius-s')} 0;
|
|
212
|
-
|
|
220
|
+
border: none;
|
|
221
|
+
|
|
222
|
+
height: calc(100% - 2px);
|
|
213
223
|
`
|
|
214
224
|
|
|
215
225
|
const RotatableIcon = styled(DefaultIcon)<{ $rotate: boolean }>`
|
|
@@ -4,7 +4,7 @@ import { composeStories } from '@storybook/testing-react'
|
|
|
4
4
|
import userEvent from '@testing-library/user-event'
|
|
5
5
|
|
|
6
6
|
import * as stories from './EmptyState.stories'
|
|
7
|
-
import renderer, { screen } from '
|
|
7
|
+
import renderer, { screen } from '../../tests/renderer'
|
|
8
8
|
|
|
9
9
|
import type { EmptyStateProps } from './EmptyState.types'
|
|
10
10
|
import {
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { composeStories } from '@storybook/testing-react'
|
|
3
3
|
|
|
4
4
|
import * as stories from './HighlightMatch.stories'
|
|
5
|
-
import renderer, { screen } from '
|
|
5
|
+
import renderer, { screen } from '../../tests/renderer'
|
|
6
6
|
import type { HighlightMatchProps } from './HighlightMatch'
|
|
7
7
|
|
|
8
8
|
const { Playground } = composeStories(stories)
|
|
@@ -3,8 +3,8 @@ import { composeStories } from '@storybook/testing-react'
|
|
|
3
3
|
|
|
4
4
|
import { icons } from './IconFactory.fixtures'
|
|
5
5
|
import * as stories from './IconFactory.stories'
|
|
6
|
-
import generator from '
|
|
7
|
-
import renderer, { screen } from '
|
|
6
|
+
import generator from '../../tests/generator'
|
|
7
|
+
import renderer, { screen } from '../../tests/renderer'
|
|
8
8
|
|
|
9
9
|
import type { IconProps } from './IconFactory'
|
|
10
10
|
|