@registrucentras/rc-ses-react-components 2.2.0 → 2.4.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/dist/assets/icons/createIcon.d.ts +18 -0
- package/dist/assets/icons/phosphorIcons.d.ts +217 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +3 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.d.ts +31 -0
- package/dist/components/common/AdvancedList/components/AdvancedListItemShell/index.d.ts +11 -0
- package/dist/library/icons.d.ts +2 -48
- package/dist/library/index.d.ts +2 -1
- package/dist/library/types.d.ts +2 -0
- package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
- package/dist/registrucentras-rc-ses-react-components.js +3031 -3240
- package/package.json +1 -1
- package/src/assets/icons/createIcon.test.tsx +49 -0
- package/src/assets/icons/createIcon.tsx +49 -0
- package/src/assets/icons/phosphorIcons.ts +160 -0
- package/src/components/common/Accordion/index.tsx +1 -1
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemLeading.tsx +1 -3
- package/src/components/common/AdvancedList/components/AdvancedListItem/components/AdvancedListItemTrailing.tsx +6 -4
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.test.tsx +5 -3
- package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +4 -0
- package/src/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.ts +35 -0
- package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +350 -0
- package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +247 -0
- package/src/components/common/Alert/index.tsx +1 -1
- package/src/components/common/Badge/index.tsx +1 -2
- package/src/components/common/Button/ButtonWithPopover.tsx +1 -2
- package/src/components/common/DataPagination/index.tsx +1 -2
- package/src/components/common/IconWithSquareBackground/index.test.tsx +1 -1
- package/src/components/common/ServiceLinks/ServiceLinkItem/index.tsx +1 -1
- package/src/components/common/Snackbar/index.tsx +1 -1
- package/src/components/common/StepCard/StepCardFooter/index.tsx +5 -3
- package/src/components/common/Tooltip/index.tsx +1 -1
- package/src/components/form/inputs/CheckboxFormControl.tsx +1 -2
- package/src/components/form/inputs/Datepicker/components/RcSesDatepickerCalendarHeader.tsx +6 -4
- package/src/components/form/inputs/Datepicker/index.tsx +1 -2
- package/src/components/form/inputs/FileDropzone.tsx +1 -2
- package/src/components/form/inputs/FileUpload.tsx +1 -1
- package/src/components/form/inputs/NumberStepper.tsx +1 -2
- package/src/components/form/inputs/PhoneInputFormControl/components/AutocompleteInput.tsx +1 -1
- package/src/components/form/inputs/PhoneInputFormControl/index.tsx +1 -1
- package/src/components/form/inputs/SearchInput/index.tsx +1 -2
- package/src/components/form/inputs/SearchableField.tsx +1 -2
- package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +1 -1
- package/src/components/form/inputs/Select/index.tsx +1 -2
- package/src/components/form/inputs/SimpleCheckbox.tsx +1 -2
- package/src/components/layout/ServiceFormActions.tsx +1 -2
- package/src/components/layout/ServiceFormContainer/AccordionFormContainer/components/AccordionCollapseControls.tsx +1 -2
- package/src/components/layout/ServiceWizardStepper/components/CustomStepIcon.tsx +1 -2
- package/src/components/layout/ServiceWizardStepper/components/HorizontalStepperButton.tsx +1 -2
- package/src/components/overlays/BottomSheet/index.tsx +1 -1
- package/src/components/overlays/Modal/index.tsx +6 -4
- package/src/library/icons.ts +3 -100
- package/src/library/index.ts +2 -1
- package/src/library/types.ts +10 -0
- package/src/stories/atoms/Button.stories.tsx +1 -1
- package/src/stories/atoms/IconWithCircularBackground.stories.tsx +1 -1
- package/src/stories/atoms/IconWithSquareBackground.stories.tsx +1 -1
- package/src/stories/atoms/Icons.stories.tsx +40 -38
- package/src/stories/molecules/Card.stories.tsx +5 -3
- package/src/stories/molecules/CardShell.stories.tsx +1 -1
- package/src/stories/molecules/ImageCard.stories.tsx +1 -1
- package/src/stories/molecules/ListWithIcons.stories.tsx +1 -2
- package/src/stories/molecules/TitleBlock.stories.tsx +6 -3
- package/src/stories/organisms/AdvancedList.stories.tsx +6 -4
- package/src/stories/organisms/AdvancedListItem.stories.tsx +2 -4
- package/src/stories/organisms/AdvancedListItemShell.stories.tsx +865 -0
- package/src/stories/organisms/SelectableCardList.stories.tsx +1 -3
- package/src/stories/organisms/ServiceLinks.stories.tsx +1 -1
- package/src/theme/light/MuiAccordionSummary.tsx +1 -1
- package/src/theme/light/MuiAlert.tsx +7 -5
- package/src/theme/light/MuiTypography.tsx +24 -24
- package/dist/assets/icons/ArrowLeftIcon.d.ts +0 -3
- package/dist/assets/icons/ArrowRightIcon.d.ts +0 -3
- package/dist/assets/icons/ArrowsClockwiseIcon.d.ts +0 -3
- package/dist/assets/icons/BarcodeIcon.d.ts +0 -3
- package/dist/assets/icons/CalendarBlankIcon.d.ts +0 -3
- package/dist/assets/icons/CaretDoubleLeftBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretDoubleRightBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretDownBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretDownFill.d.ts +0 -3
- package/dist/assets/icons/CaretDownIcon.d.ts +0 -3
- package/dist/assets/icons/CaretLeftBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretLeftIcon.d.ts +0 -3
- package/dist/assets/icons/CaretRightBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretUpBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CaretUpIcon.d.ts +0 -3
- package/dist/assets/icons/CheckBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CheckCircleFillIcon.d.ts +0 -3
- package/dist/assets/icons/CheckIcon.d.ts +0 -3
- package/dist/assets/icons/CheckUncheckedBoldIcon.d.ts +0 -3
- package/dist/assets/icons/CircleFilledIcon.d.ts +0 -3
- package/dist/assets/icons/CloseIcon.d.ts +0 -3
- package/dist/assets/icons/CollapseChevronsIcon.d.ts +0 -3
- package/dist/assets/icons/CopyIcon.d.ts +0 -3
- package/dist/assets/icons/ExpandChevronsIcon.d.ts +0 -3
- package/dist/assets/icons/InfoFillIcon.d.ts +0 -3
- package/dist/assets/icons/ListIcon.d.ts +0 -3
- package/dist/assets/icons/MagnifyingGlassIcon.d.ts +0 -3
- package/dist/assets/icons/MapPinAreaIcon.d.ts +0 -3
- package/dist/assets/icons/MinusBoldIcon.d.ts +0 -3
- package/dist/assets/icons/MinusIcon.d.ts +0 -3
- package/dist/assets/icons/NotePencilIcon.d.ts +0 -3
- package/dist/assets/icons/PencilSimpleLineIcon.d.ts +0 -3
- package/dist/assets/icons/PlusBoldIcon.d.ts +0 -3
- package/dist/assets/icons/PlusIcon.d.ts +0 -3
- package/dist/assets/icons/QuestionFillIcon.d.ts +0 -3
- package/dist/assets/icons/QuestionIcon.d.ts +0 -3
- package/dist/assets/icons/ScalesIcon.d.ts +0 -3
- package/dist/assets/icons/ScrollIcon.d.ts +0 -3
- package/dist/assets/icons/ShoppingCartIcon.d.ts +0 -3
- package/dist/assets/icons/SpinnerGapBoldIcon.d.ts +0 -3
- package/dist/assets/icons/TrashIcon.d.ts +0 -3
- package/dist/assets/icons/UploadSimpleIcon.d.ts +0 -3
- package/dist/assets/icons/UserIcon.d.ts +0 -3
- package/dist/assets/icons/WarningCircleIcon.d.ts +0 -3
- package/dist/assets/icons/WarningDiamondFillIcon.d.ts +0 -3
- package/dist/assets/icons/WarningFillIcon.d.ts +0 -3
- package/dist/assets/icons/XCircleFillIcon.d.ts +0 -3
- package/src/assets/icons/ArrowLeftIcon.tsx +0 -16
- package/src/assets/icons/ArrowRightIcon.tsx +0 -17
- package/src/assets/icons/ArrowsClockwiseIcon.tsx +0 -16
- package/src/assets/icons/BarcodeIcon.tsx +0 -9
- package/src/assets/icons/CalendarBlankIcon.tsx +0 -9
- package/src/assets/icons/CaretDoubleLeftBoldIcon.tsx +0 -22
- package/src/assets/icons/CaretDoubleRightBoldIcon.tsx +0 -22
- package/src/assets/icons/CaretDownBoldIcon.tsx +0 -17
- package/src/assets/icons/CaretDownFill.tsx +0 -17
- package/src/assets/icons/CaretDownIcon.tsx +0 -9
- package/src/assets/icons/CaretLeftBoldIcon.tsx +0 -17
- package/src/assets/icons/CaretLeftIcon.tsx +0 -9
- package/src/assets/icons/CaretRightBoldIcon.tsx +0 -17
- package/src/assets/icons/CaretUpBoldIcon.tsx +0 -17
- package/src/assets/icons/CaretUpIcon.tsx +0 -9
- package/src/assets/icons/CheckBoldIcon.tsx +0 -17
- package/src/assets/icons/CheckCircleFillIcon.tsx +0 -23
- package/src/assets/icons/CheckIcon.tsx +0 -23
- package/src/assets/icons/CheckUncheckedBoldIcon.tsx +0 -9
- package/src/assets/icons/CircleFilledIcon.tsx +0 -11
- package/src/assets/icons/CloseIcon.tsx +0 -9
- package/src/assets/icons/CollapseChevronsIcon.tsx +0 -17
- package/src/assets/icons/CopyIcon.tsx +0 -23
- package/src/assets/icons/ExpandChevronsIcon.tsx +0 -17
- package/src/assets/icons/InfoFillIcon.tsx +0 -17
- package/src/assets/icons/ListIcon.tsx +0 -17
- package/src/assets/icons/MagnifyingGlassIcon.tsx +0 -9
- package/src/assets/icons/MapPinAreaIcon.tsx +0 -9
- package/src/assets/icons/MinusBoldIcon.tsx +0 -11
- package/src/assets/icons/MinusIcon.tsx +0 -9
- package/src/assets/icons/NotePencilIcon.tsx +0 -9
- package/src/assets/icons/PencilSimpleLineIcon.tsx +0 -23
- package/src/assets/icons/PlusBoldIcon.tsx +0 -11
- package/src/assets/icons/PlusIcon.tsx +0 -9
- package/src/assets/icons/QuestionFillIcon.tsx +0 -23
- package/src/assets/icons/QuestionIcon.tsx +0 -9
- package/src/assets/icons/ScalesIcon.tsx +0 -9
- package/src/assets/icons/ScrollIcon.tsx +0 -9
- package/src/assets/icons/ShoppingCartIcon.tsx +0 -16
- package/src/assets/icons/SpinnerGapBoldIcon.tsx +0 -17
- package/src/assets/icons/TrashIcon.tsx +0 -23
- package/src/assets/icons/UploadSimpleIcon.tsx +0 -9
- package/src/assets/icons/UserIcon.tsx +0 -17
- package/src/assets/icons/WarningCircleIcon.tsx +0 -22
- package/src/assets/icons/WarningDiamondFillIcon.tsx +0 -17
- package/src/assets/icons/WarningFillIcon.tsx +0 -22
- package/src/assets/icons/XCircleFillIcon.tsx +0 -17
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import AdvancedListItemShell from '.'
|
|
5
|
+
|
|
6
|
+
describe('AdvancedListItemShell', () => {
|
|
7
|
+
it('renders the required content slot', () => {
|
|
8
|
+
render(<AdvancedListItemShell content={<span>Content</span>} />)
|
|
9
|
+
|
|
10
|
+
expect(screen.getByText('Content')).toBeInTheDocument()
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('omits leading/trailing/expanded regions when not provided', () => {
|
|
14
|
+
render(
|
|
15
|
+
<AdvancedListItemShell
|
|
16
|
+
content={<span>Content</span>}
|
|
17
|
+
testIds={{
|
|
18
|
+
root: 'root',
|
|
19
|
+
leading: 'leading',
|
|
20
|
+
trailing: 'trailing',
|
|
21
|
+
expanded: 'expanded',
|
|
22
|
+
}}
|
|
23
|
+
/>,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
expect(screen.queryByTestId('leading')).not.toBeInTheDocument()
|
|
27
|
+
expect(screen.queryByTestId('trailing')).not.toBeInTheDocument()
|
|
28
|
+
expect(screen.queryByTestId('expanded')).not.toBeInTheDocument()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('renders as a bordered/rounded card by default', () => {
|
|
32
|
+
render(
|
|
33
|
+
<AdvancedListItemShell content={<span>Content</span>} testIds={{ root: 'root' }} />,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const root = screen.getByTestId('root')
|
|
37
|
+
expect(root).toHaveStyle({ borderRadius: '0.5rem' })
|
|
38
|
+
expect(root.style.border).not.toBe('none')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('exposes aria-expanded/aria-controls on the root when it is the toggle (clickable + has an expanded slot)', () => {
|
|
42
|
+
render(
|
|
43
|
+
<AdvancedListItemShell
|
|
44
|
+
content={<span>Content</span>}
|
|
45
|
+
expanded={<span>Details</span>}
|
|
46
|
+
isExpanded
|
|
47
|
+
onClick={vi.fn()}
|
|
48
|
+
testIds={{ root: 'root' }}
|
|
49
|
+
/>,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const root = screen.getByTestId('root')
|
|
53
|
+
expect(root).toHaveAttribute('aria-expanded', 'true')
|
|
54
|
+
expect(root).toHaveAttribute('aria-controls')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('does not expose aria-expanded/aria-controls on the root when there is no onClick', () => {
|
|
58
|
+
render(
|
|
59
|
+
<AdvancedListItemShell
|
|
60
|
+
content={<span>Content</span>}
|
|
61
|
+
expanded={<span>Details</span>}
|
|
62
|
+
isExpanded
|
|
63
|
+
testIds={{ root: 'root' }}
|
|
64
|
+
/>,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const root = screen.getByTestId('root')
|
|
68
|
+
expect(root).not.toHaveAttribute('aria-expanded')
|
|
69
|
+
expect(root).not.toHaveAttribute('aria-controls')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('renders as a flush row with no border/radius when container="row"', () => {
|
|
73
|
+
render(
|
|
74
|
+
<AdvancedListItemShell
|
|
75
|
+
content={<span>Content</span>}
|
|
76
|
+
container='row'
|
|
77
|
+
testIds={{ root: 'root' }}
|
|
78
|
+
/>,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const root = screen.getByTestId('root')
|
|
82
|
+
expect(root).toHaveStyle({ borderRadius: '0px' })
|
|
83
|
+
expect(root).toHaveStyle({ borderBottomWidth: '0.0625rem' })
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('renders leading and trailing slots when provided', () => {
|
|
87
|
+
render(
|
|
88
|
+
<AdvancedListItemShell
|
|
89
|
+
leading={<span>Leading</span>}
|
|
90
|
+
content={<span>Content</span>}
|
|
91
|
+
trailing={<span>Trailing</span>}
|
|
92
|
+
testIds={{ leading: 'leading', trailing: 'trailing' }}
|
|
93
|
+
/>,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
expect(screen.getByTestId('leading')).toHaveTextContent('Leading')
|
|
97
|
+
expect(screen.getByTestId('trailing')).toHaveTextContent('Trailing')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('does not render a falsy leading/trailing slot', () => {
|
|
101
|
+
render(
|
|
102
|
+
<AdvancedListItemShell
|
|
103
|
+
leading={false}
|
|
104
|
+
content={<span>Content</span>}
|
|
105
|
+
trailing={null}
|
|
106
|
+
testIds={{ leading: 'leading', trailing: 'trailing' }}
|
|
107
|
+
/>,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
expect(screen.queryByTestId('leading')).not.toBeInTheDocument()
|
|
111
|
+
expect(screen.queryByTestId('trailing')).not.toBeInTheDocument()
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('keeps the expanded slot content stable while toggling isExpanded', () => {
|
|
115
|
+
const { rerender } = render(
|
|
116
|
+
<AdvancedListItemShell
|
|
117
|
+
content={<span>Content</span>}
|
|
118
|
+
expanded={<span>Expanded content</span>}
|
|
119
|
+
isExpanded={false}
|
|
120
|
+
testIds={{ expanded: 'expanded' }}
|
|
121
|
+
/>,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
expect(screen.getByTestId('expanded')).toBeInTheDocument()
|
|
125
|
+
expect(screen.getByText('Expanded content')).toBeInTheDocument()
|
|
126
|
+
|
|
127
|
+
rerender(
|
|
128
|
+
<AdvancedListItemShell
|
|
129
|
+
content={<span>Content</span>}
|
|
130
|
+
expanded={<span>Expanded content</span>}
|
|
131
|
+
isExpanded
|
|
132
|
+
testIds={{ expanded: 'expanded' }}
|
|
133
|
+
/>,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
expect(screen.getByText('Expanded content')).toBeInTheDocument()
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('calls onClick when the root is clicked and not disabled', () => {
|
|
140
|
+
const onClick = vi.fn()
|
|
141
|
+
render(
|
|
142
|
+
<AdvancedListItemShell
|
|
143
|
+
content={<span>Content</span>}
|
|
144
|
+
onClick={onClick}
|
|
145
|
+
testIds={{ root: 'root' }}
|
|
146
|
+
/>,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
fireEvent.click(screen.getByTestId('root'))
|
|
150
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
it('does not call onClick when a click originates from an interactive control inside a slot', () => {
|
|
154
|
+
const onClick = vi.fn()
|
|
155
|
+
const onDelete = vi.fn()
|
|
156
|
+
render(
|
|
157
|
+
<AdvancedListItemShell
|
|
158
|
+
content={<span>Content</span>}
|
|
159
|
+
onClick={onClick}
|
|
160
|
+
trailing={
|
|
161
|
+
<button type='button' onClick={onDelete}>
|
|
162
|
+
Delete
|
|
163
|
+
</button>
|
|
164
|
+
}
|
|
165
|
+
/>,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
fireEvent.click(screen.getByText('Delete'))
|
|
169
|
+
expect(onDelete).toHaveBeenCalledTimes(1)
|
|
170
|
+
expect(onClick).not.toHaveBeenCalled()
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('calls onClick when the content of an expandable row is clicked', () => {
|
|
174
|
+
const onClick = vi.fn()
|
|
175
|
+
render(
|
|
176
|
+
<AdvancedListItemShell
|
|
177
|
+
content={<span>Content</span>}
|
|
178
|
+
expanded={<span>Details</span>}
|
|
179
|
+
onClick={onClick}
|
|
180
|
+
/>,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
fireEvent.click(screen.getByText('Content'))
|
|
184
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('does not call onClick when a click lands inside a nested role="button" element', () => {
|
|
188
|
+
const onClick = vi.fn()
|
|
189
|
+
render(
|
|
190
|
+
<AdvancedListItemShell
|
|
191
|
+
content={<span>Content</span>}
|
|
192
|
+
onClick={onClick}
|
|
193
|
+
trailing={
|
|
194
|
+
<div role='button' tabIndex={0}>
|
|
195
|
+
<span>Chip label</span>
|
|
196
|
+
</div>
|
|
197
|
+
}
|
|
198
|
+
/>,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
fireEvent.click(screen.getByText('Chip label'))
|
|
202
|
+
expect(onClick).not.toHaveBeenCalled()
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('does not expose role="button" on the root, even when clickable', () => {
|
|
206
|
+
render(
|
|
207
|
+
<AdvancedListItemShell
|
|
208
|
+
content={<span>Content</span>}
|
|
209
|
+
onClick={vi.fn()}
|
|
210
|
+
testIds={{ root: 'root' }}
|
|
211
|
+
/>,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
expect(screen.getByTestId('root')).not.toHaveAttribute('role', 'button')
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('does not put the root in the tab order', () => {
|
|
218
|
+
render(
|
|
219
|
+
<AdvancedListItemShell
|
|
220
|
+
content={<span>Content</span>}
|
|
221
|
+
onClick={vi.fn()}
|
|
222
|
+
testIds={{ root: 'root' }}
|
|
223
|
+
/>,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
expect(screen.getByTestId('root')).toHaveAttribute('tabIndex', '-1')
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it('exposes role="button" and aria-expanded for expandable clickable items', () => {
|
|
230
|
+
render(
|
|
231
|
+
<AdvancedListItemShell
|
|
232
|
+
content={<span>Content</span>}
|
|
233
|
+
expanded={<span>Details</span>}
|
|
234
|
+
onClick={vi.fn()}
|
|
235
|
+
testIds={{ root: 'root' }}
|
|
236
|
+
/>,
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
const root = screen.getByTestId('root')
|
|
240
|
+
expect(root).toHaveAttribute('role', 'button')
|
|
241
|
+
expect(root).toHaveAttribute('aria-expanded', 'false')
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('updates aria-expanded when expanded', () => {
|
|
245
|
+
render(
|
|
246
|
+
<AdvancedListItemShell
|
|
247
|
+
content={<span>Content</span>}
|
|
248
|
+
expanded={<span>Details</span>}
|
|
249
|
+
isExpanded
|
|
250
|
+
onClick={vi.fn()}
|
|
251
|
+
testIds={{ root: 'root' }}
|
|
252
|
+
/>,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
const root = screen.getByTestId('root')
|
|
256
|
+
expect(root).toHaveAttribute('aria-expanded', 'true')
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it('does not expose role or aria-expanded for non-expandable items', () => {
|
|
260
|
+
render(
|
|
261
|
+
<AdvancedListItemShell
|
|
262
|
+
content={<span>Content</span>}
|
|
263
|
+
onClick={vi.fn()}
|
|
264
|
+
testIds={{ root: 'root' }}
|
|
265
|
+
/>,
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
const root = screen.getByTestId('root')
|
|
269
|
+
expect(root).not.toHaveAttribute('role')
|
|
270
|
+
expect(root).not.toHaveAttribute('aria-expanded')
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
it('does not call onClick when state is disabled', () => {
|
|
274
|
+
const onClick = vi.fn()
|
|
275
|
+
render(
|
|
276
|
+
<AdvancedListItemShell
|
|
277
|
+
content={<span>Content</span>}
|
|
278
|
+
onClick={onClick}
|
|
279
|
+
state='disabled'
|
|
280
|
+
testIds={{ root: 'root' }}
|
|
281
|
+
/>,
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
fireEvent.click(screen.getByTestId('root'))
|
|
285
|
+
expect(onClick).not.toHaveBeenCalled()
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it('makes slot controls unreachable via Tab when disabled', () => {
|
|
289
|
+
render(
|
|
290
|
+
<AdvancedListItemShell
|
|
291
|
+
content={<span>Content</span>}
|
|
292
|
+
trailing={<button type='button'>Delete</button>}
|
|
293
|
+
state='disabled'
|
|
294
|
+
testIds={{ root: 'root' }}
|
|
295
|
+
/>,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
const root = screen.getByTestId('root')
|
|
299
|
+
expect(root).toHaveAttribute('inert')
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
it('makes the collapsed expanded slot inert and removes inert when expanded', () => {
|
|
303
|
+
const { rerender } = render(
|
|
304
|
+
<AdvancedListItemShell
|
|
305
|
+
content={<span>Content</span>}
|
|
306
|
+
expanded={<button type='button'>Details</button>}
|
|
307
|
+
isExpanded={false}
|
|
308
|
+
testIds={{ expanded: 'expanded' }}
|
|
309
|
+
/>,
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
expect(screen.getByTestId('expanded')).toHaveAttribute('inert')
|
|
313
|
+
|
|
314
|
+
rerender(
|
|
315
|
+
<AdvancedListItemShell
|
|
316
|
+
content={<span>Content</span>}
|
|
317
|
+
expanded={<button type='button'>Details</button>}
|
|
318
|
+
isExpanded
|
|
319
|
+
testIds={{ expanded: 'expanded' }}
|
|
320
|
+
/>,
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
expect(screen.getByTestId('expanded')).not.toHaveAttribute('inert')
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
it('returns focus to the root when the expanded slot collapses while focus is inside it', () => {
|
|
327
|
+
const { rerender } = render(
|
|
328
|
+
<AdvancedListItemShell
|
|
329
|
+
content={<span>Content</span>}
|
|
330
|
+
expanded={<button type='button'>Details</button>}
|
|
331
|
+
isExpanded
|
|
332
|
+
testIds={{ root: 'root' }}
|
|
333
|
+
/>,
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
screen.getByText('Details').focus()
|
|
337
|
+
expect(screen.getByText('Details')).toHaveFocus()
|
|
338
|
+
|
|
339
|
+
rerender(
|
|
340
|
+
<AdvancedListItemShell
|
|
341
|
+
content={<span>Content</span>}
|
|
342
|
+
expanded={<button type='button'>Details</button>}
|
|
343
|
+
isExpanded={false}
|
|
344
|
+
testIds={{ root: 'root' }}
|
|
345
|
+
/>,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
expect(screen.getByTestId('root')).toHaveFocus()
|
|
349
|
+
})
|
|
350
|
+
})
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { Box, Collapse, Stack } from '@mui/material'
|
|
2
|
+
import { ReactNode, useEffect, useId, useRef } from 'react'
|
|
3
|
+
|
|
4
|
+
import motion from '@/theme/motion'
|
|
5
|
+
import palette from '@/theme/palette'
|
|
6
|
+
|
|
7
|
+
import usePrefersReducedMotion from '../AdvancedListItem/hooks/usePrefersReducedMotion'
|
|
8
|
+
import {
|
|
9
|
+
AdvancedListItemShellContainer,
|
|
10
|
+
AdvancedListItemShellProps,
|
|
11
|
+
AdvancedListItemShellState,
|
|
12
|
+
AdvancedListItemShellTestIds,
|
|
13
|
+
} from './AdvancedListItemShell.types'
|
|
14
|
+
|
|
15
|
+
const BORDER_RADIUS = '0.5rem'
|
|
16
|
+
const BORDER_WIDTH = '0.0625rem'
|
|
17
|
+
const FOCUS_RING_WIDTH = '0.0625rem'
|
|
18
|
+
|
|
19
|
+
const STATE_BORDER_COLOR: Record<AdvancedListItemShellState, string> = {
|
|
20
|
+
rest: palette.grey[200],
|
|
21
|
+
selected: palette.primary.main,
|
|
22
|
+
disabled: palette.grey[200],
|
|
23
|
+
error: palette.error.main,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// A conditional slot renders as false rather than as nothing, so false is absent
|
|
27
|
+
const hasSlot = (node: ReactNode) => node !== undefined && node !== null && node !== false
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Slot-based shell (Leading, Content, Trailing, Expanded).
|
|
31
|
+
* Content is required; Leading/Trailing/Expanded are omitted from the DOM
|
|
32
|
+
* entirely when not provided. Slot content is opaque to the shell and stays
|
|
33
|
+
* stable across `state`/`isExpanded` changes — new content variations are
|
|
34
|
+
* composed as slot content, not new boolean/variant props.
|
|
35
|
+
*/
|
|
36
|
+
const AdvancedListItemShell = ({
|
|
37
|
+
leading,
|
|
38
|
+
content,
|
|
39
|
+
trailing,
|
|
40
|
+
expanded,
|
|
41
|
+
isExpanded = false,
|
|
42
|
+
state = 'rest',
|
|
43
|
+
container = 'card',
|
|
44
|
+
onClick,
|
|
45
|
+
className,
|
|
46
|
+
testIds,
|
|
47
|
+
}: AdvancedListItemShellProps) => {
|
|
48
|
+
const isDisabled = state === 'disabled'
|
|
49
|
+
const isClickable = !!onClick && !isDisabled
|
|
50
|
+
const isExpandable = hasSlot(expanded)
|
|
51
|
+
const isRow = container === 'row'
|
|
52
|
+
|
|
53
|
+
const hasLeading = hasSlot(leading)
|
|
54
|
+
const hasTrailing = hasSlot(trailing)
|
|
55
|
+
|
|
56
|
+
const rootRef = useRef<HTMLDivElement>(null)
|
|
57
|
+
const prefersReducedMotion = usePrefersReducedMotion()
|
|
58
|
+
|
|
59
|
+
const expandedId = useId()
|
|
60
|
+
|
|
61
|
+
const borderColor = STATE_BORDER_COLOR[state]
|
|
62
|
+
const backgroundColor = state === 'selected' ? palette.primary[50] : undefined
|
|
63
|
+
const focusRingShadow = `0 0 0 ${FOCUS_RING_WIDTH} ${palette.primary.main}`
|
|
64
|
+
const transitionTiming = `${motion.duration.standard}ms ${motion.easing.standard}`
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (isDisabled) {
|
|
68
|
+
rootRef.current?.setAttribute('inert', '')
|
|
69
|
+
} else {
|
|
70
|
+
rootRef.current?.removeAttribute('inert')
|
|
71
|
+
}
|
|
72
|
+
}, [isDisabled])
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!isExpandable) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const expandedElement = rootRef.current?.querySelector(`[id="${expandedId}"]`)
|
|
80
|
+
if (!expandedElement) {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (isExpanded) {
|
|
85
|
+
expandedElement.removeAttribute('inert')
|
|
86
|
+
} else {
|
|
87
|
+
// When collapsing, if focus is inside the expanded content, move it to root
|
|
88
|
+
if (expandedElement.contains(document.activeElement)) {
|
|
89
|
+
rootRef.current?.focus()
|
|
90
|
+
}
|
|
91
|
+
expandedElement.setAttribute('inert', '')
|
|
92
|
+
}
|
|
93
|
+
}, [isExpanded, isExpandable, expandedId])
|
|
94
|
+
|
|
95
|
+
const handleRootClick = (event: React.MouseEvent) => {
|
|
96
|
+
if (!isClickable) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const target = event.target as HTMLElement
|
|
101
|
+
|
|
102
|
+
// Skip clicks on interactive elements that have their own handlers. The root itself
|
|
103
|
+
// is role="button" in expandable rows, so it is excluded.
|
|
104
|
+
const control = target.closest('button, a, input, select, textarea, [role="button"]')
|
|
105
|
+
if (control && control !== rootRef.current) {
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Skip clicks inside the expanded content area to prevent collapsing when clicking details
|
|
110
|
+
const expandedElement = rootRef.current?.querySelector(`[id="${expandedId}"]`)
|
|
111
|
+
if (isExpanded && expandedElement?.contains(target)) {
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onClick()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const handleRootKeyDown = (event: React.KeyboardEvent) => {
|
|
119
|
+
if (!isClickable || !isExpandable) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Only handle keyboard events directly on the root, not on nested elements
|
|
124
|
+
if (event.target !== event.currentTarget) {
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
129
|
+
event.preventDefault()
|
|
130
|
+
onClick()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Box
|
|
136
|
+
ref={rootRef}
|
|
137
|
+
role={isClickable && isExpandable ? 'button' : undefined}
|
|
138
|
+
tabIndex={isClickable && isExpandable ? 0 : -1}
|
|
139
|
+
onClick={isClickable ? handleRootClick : undefined}
|
|
140
|
+
onKeyDown={isClickable && isExpandable ? handleRootKeyDown : undefined}
|
|
141
|
+
aria-disabled={isDisabled || undefined}
|
|
142
|
+
aria-expanded={isClickable && isExpandable ? isExpanded : undefined}
|
|
143
|
+
aria-controls={isClickable && isExpandable ? expandedId : undefined}
|
|
144
|
+
className={className}
|
|
145
|
+
data-testid={testIds?.root}
|
|
146
|
+
sx={{
|
|
147
|
+
display: 'flex',
|
|
148
|
+
flexDirection: 'column',
|
|
149
|
+
width: '100%',
|
|
150
|
+
boxSizing: 'border-box',
|
|
151
|
+
border:
|
|
152
|
+
isRow && (state === 'rest' || state === 'disabled')
|
|
153
|
+
? 'none'
|
|
154
|
+
: `${BORDER_WIDTH} solid`,
|
|
155
|
+
borderColor:
|
|
156
|
+
isRow && (state === 'rest' || state === 'disabled') ? undefined : borderColor,
|
|
157
|
+
borderBottom:
|
|
158
|
+
isRow && state === 'rest' ? `${BORDER_WIDTH} solid ${borderColor}` : undefined,
|
|
159
|
+
backgroundColor,
|
|
160
|
+
borderRadius: isRow ? '0px' : BORDER_RADIUS,
|
|
161
|
+
padding: '0.5rem 0.75rem',
|
|
162
|
+
opacity: isDisabled ? 0.5 : 1,
|
|
163
|
+
pointerEvents: isDisabled ? 'none' : 'auto',
|
|
164
|
+
cursor: isClickable ? 'pointer' : 'default',
|
|
165
|
+
boxShadow: state === 'selected' ? focusRingShadow : 'none',
|
|
166
|
+
transition: prefersReducedMotion
|
|
167
|
+
? 'none'
|
|
168
|
+
: `border-color ${transitionTiming}, box-shadow ${transitionTiming}, border-radius ${transitionTiming}`,
|
|
169
|
+
'&:hover':
|
|
170
|
+
isClickable && state !== 'selected'
|
|
171
|
+
? {
|
|
172
|
+
backgroundColor: palette.grey[100],
|
|
173
|
+
}
|
|
174
|
+
: undefined,
|
|
175
|
+
'&:has(:focus-visible), &:focus-visible': !isDisabled
|
|
176
|
+
? { borderColor: palette.primary.main, boxShadow: focusRingShadow }
|
|
177
|
+
: undefined,
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
<Stack
|
|
181
|
+
direction='row'
|
|
182
|
+
sx={{
|
|
183
|
+
alignItems: 'center',
|
|
184
|
+
flexWrap: { xs: 'wrap', md: 'nowrap' },
|
|
185
|
+
gap: '0.75rem',
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
{hasLeading && (
|
|
189
|
+
<Box data-testid={testIds?.leading} sx={{ alignSelf: 'center', flexShrink: 0 }}>
|
|
190
|
+
{leading}
|
|
191
|
+
</Box>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
<Box
|
|
195
|
+
data-testid={testIds?.content}
|
|
196
|
+
sx={{
|
|
197
|
+
display: 'flex',
|
|
198
|
+
flexDirection: 'column',
|
|
199
|
+
flex: '1 1 0%',
|
|
200
|
+
minWidth: 0,
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
{content}
|
|
204
|
+
</Box>
|
|
205
|
+
|
|
206
|
+
{hasTrailing && (
|
|
207
|
+
<Box
|
|
208
|
+
data-testid={testIds?.trailing}
|
|
209
|
+
sx={{ alignSelf: 'center', flexShrink: 0 }}
|
|
210
|
+
>
|
|
211
|
+
{trailing}
|
|
212
|
+
</Box>
|
|
213
|
+
)}
|
|
214
|
+
</Stack>
|
|
215
|
+
|
|
216
|
+
{isExpandable && (
|
|
217
|
+
<Collapse
|
|
218
|
+
in={isExpanded}
|
|
219
|
+
timeout={prefersReducedMotion ? 0 : motion.duration.standard}
|
|
220
|
+
easing={motion.easing.standard}
|
|
221
|
+
>
|
|
222
|
+
<Box
|
|
223
|
+
id={expandedId}
|
|
224
|
+
data-testid={testIds?.expanded}
|
|
225
|
+
sx={{
|
|
226
|
+
margin: '1.25rem 0.75rem',
|
|
227
|
+
backgroundColor: palette.grey[50],
|
|
228
|
+
borderRadius: BORDER_RADIUS,
|
|
229
|
+
border: `${BORDER_WIDTH} solid ${palette.grey[200]}`,
|
|
230
|
+
padding: '0.75rem',
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
{expanded}
|
|
234
|
+
</Box>
|
|
235
|
+
</Collapse>
|
|
236
|
+
)}
|
|
237
|
+
</Box>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default AdvancedListItemShell
|
|
242
|
+
export type {
|
|
243
|
+
AdvancedListItemShellContainer,
|
|
244
|
+
AdvancedListItemShellProps,
|
|
245
|
+
AdvancedListItemShellState,
|
|
246
|
+
AdvancedListItemShellTestIds,
|
|
247
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@mui/material'
|
|
9
9
|
import { useTranslation } from 'react-i18next'
|
|
10
10
|
|
|
11
|
-
import CloseIcon from '@/assets/icons/
|
|
11
|
+
import { CloseIcon } from '@/assets/icons/phosphorIcons'
|
|
12
12
|
|
|
13
13
|
type Props = Omit<MuiAlertProps, 'onClose'> & {
|
|
14
14
|
container?: boolean | ContainerProps
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Box } from '@mui/material'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
|
|
4
|
-
import CircleFilledIcon from '@/assets/icons/
|
|
5
|
-
import CloseIcon from '@/assets/icons/CloseIcon'
|
|
4
|
+
import { CircleFilledIcon, CloseIcon } from '@/assets/icons/phosphorIcons'
|
|
6
5
|
import { common, error, grey, primary, secondary, warning } from '@/theme/palette'
|
|
7
6
|
|
|
8
7
|
export interface RcSesBadgeProps {
|
|
@@ -3,8 +3,7 @@ import { PopoverProps } from '@mui/material/Popover'
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { useTranslation } from 'react-i18next'
|
|
5
5
|
|
|
6
|
-
import QuestionFillIcon from '@/assets/icons/
|
|
7
|
-
import QuestionIcon from '@/assets/icons/QuestionIcon'
|
|
6
|
+
import { QuestionFillIcon, QuestionIcon } from '@/assets/icons/phosphorIcons'
|
|
8
7
|
import palette from '@/theme/palette'
|
|
9
8
|
|
|
10
9
|
import RcSesButton from '.'
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Box, Pagination, useMediaQuery, useTheme } from '@mui/material'
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import ArrowLeftIcon from '@/assets/icons/
|
|
5
|
-
import ArrowRightIcon from '@/assets/icons/ArrowRightIcon'
|
|
4
|
+
import { ArrowLeftIcon, ArrowRightIcon } from '@/assets/icons/phosphorIcons'
|
|
6
5
|
|
|
7
6
|
import DataPaginationSkeleton from './components/DataPaginationSkeleton'
|
|
8
7
|
import PaginationButton from './components/PaginationButton'
|
|
@@ -4,7 +4,7 @@ import { render } from '@testing-library/react'
|
|
|
4
4
|
import { type ReactElement } from 'react'
|
|
5
5
|
import { describe, expect, test } from 'vitest'
|
|
6
6
|
|
|
7
|
-
import InfoFillIcon from '@/assets/icons/
|
|
7
|
+
import { InfoFillIcon } from '@/assets/icons/phosphorIcons'
|
|
8
8
|
import theme from '@/theme/light'
|
|
9
9
|
|
|
10
10
|
import RcSesIconWithSquareBackground from '.'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Box, Skeleton, Stack, Typography } from '@mui/material'
|
|
2
2
|
import { ElementType } from 'react'
|
|
3
3
|
|
|
4
|
-
import ArrowRightIcon from '@/assets/icons/
|
|
4
|
+
import { ArrowRightIcon } from '@/assets/icons/phosphorIcons'
|
|
5
5
|
import { subcard } from '@/theme/cards'
|
|
6
6
|
import palette from '@/theme/palette'
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { useLayoutEffect, useRef, useState } from 'react'
|
|
10
10
|
import { useTranslation } from 'react-i18next'
|
|
11
11
|
|
|
12
|
-
import CloseIcon from '@/assets/icons/
|
|
12
|
+
import { CloseIcon } from '@/assets/icons/phosphorIcons'
|
|
13
13
|
import { grey } from '@/theme/palette'
|
|
14
14
|
|
|
15
15
|
import RcSesButton from '../Button'
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Box, Button, Typography } from '@mui/material'
|
|
2
2
|
import { useTranslation } from 'react-i18next'
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
ArrowLeftIcon,
|
|
6
|
+
ArrowRightIcon,
|
|
7
|
+
ShoppingCartIcon,
|
|
8
|
+
} from '@/assets/icons/phosphorIcons'
|
|
7
9
|
import RcSesCardFooter from '@/components/common/CardShell/CardFooter'
|
|
8
10
|
import { typography } from '@/theme/light/MuiTypography'
|
|
9
11
|
|
|
@@ -4,7 +4,7 @@ import { useForkRef } from '@mui/material/utils'
|
|
|
4
4
|
import React from 'react'
|
|
5
5
|
import { useTranslation } from 'react-i18next'
|
|
6
6
|
|
|
7
|
-
import QuestionIcon from '@/assets/icons/
|
|
7
|
+
import { QuestionIcon } from '@/assets/icons/phosphorIcons'
|
|
8
8
|
|
|
9
9
|
export type RcSesTooltipProps = {
|
|
10
10
|
title: string
|