@registrucentras/rc-ses-react-components 2.1.0 → 2.3.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.
Files changed (35) hide show
  1. package/dist/components/common/AdvancedList/components/AdvancedListItem/index.d.ts +3 -0
  2. package/dist/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.d.ts +31 -0
  3. package/dist/components/common/AdvancedList/components/AdvancedListItemShell/index.d.ts +11 -0
  4. package/dist/components/form/inputs/Select/Select.utils.d.ts +9 -0
  5. package/dist/components/form/inputs/Select/components/OptionCheckbox.d.ts +5 -0
  6. package/dist/components/form/inputs/Select/index.d.ts +18 -8
  7. package/dist/components/overlays/BottomSheet/index.d.ts +17 -0
  8. package/dist/components/overlays/BottomSheet/useSwipeToDismiss.d.ts +17 -0
  9. package/dist/library/index.d.ts +4 -2
  10. package/dist/library/types.d.ts +4 -0
  11. package/dist/registrucentras-rc-ses-react-components.cjs +1 -1
  12. package/dist/registrucentras-rc-ses-react-components.js +3004 -2437
  13. package/package.json +1 -1
  14. package/src/components/common/AdvancedList/components/AdvancedListItem/index.tsx +4 -0
  15. package/src/components/common/AdvancedList/components/AdvancedListItemShell/AdvancedListItemShell.types.ts +35 -0
  16. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.test.tsx +350 -0
  17. package/src/components/common/AdvancedList/components/AdvancedListItemShell/index.tsx +247 -0
  18. package/src/components/form/inputs/Select/Select.utils.ts +24 -0
  19. package/src/components/form/inputs/Select/components/OptionCheckbox.tsx +46 -0
  20. package/src/components/form/inputs/Select/index.test.tsx +127 -0
  21. package/src/components/form/inputs/Select/index.tsx +426 -181
  22. package/src/components/overlays/BottomSheet/index.test.tsx +256 -0
  23. package/src/components/overlays/BottomSheet/index.tsx +242 -0
  24. package/src/components/overlays/BottomSheet/useSwipeToDismiss.test.ts +295 -0
  25. package/src/components/overlays/BottomSheet/useSwipeToDismiss.ts +138 -0
  26. package/src/i18n/namespaces/input/en.json +11 -0
  27. package/src/i18n/namespaces/input/lt.json +11 -0
  28. package/src/library/index.ts +4 -1
  29. package/src/library/types.ts +12 -0
  30. package/src/stories/atoms/Select.stories.tsx +33 -5
  31. package/src/stories/organisms/AdvancedListItem.stories.tsx +1 -1
  32. package/src/stories/organisms/AdvancedListItemShell.stories.tsx +866 -0
  33. package/src/stories/organisms/BottomSheet.stories.tsx +291 -0
  34. package/src/theme/light/MuiAutocomplete.ts +43 -19
  35. package/src/theme/light/MuiTypography.tsx +24 -24
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@registrucentras/rc-ses-react-components",
3
3
  "author": "VĮ REGISTRŲ CENTRAS",
4
- "version": "2.1.0",
4
+ "version": "2.3.0",
5
5
  "description": "RC SES React komponentų biblioteka",
6
6
  "type": "module",
7
7
  "private": false,
@@ -44,6 +44,10 @@ const INTERACTIVE_TRAILING_TYPES = new Set([
44
44
  'stepper',
45
45
  ])
46
46
 
47
+ /**
48
+ * @deprecated Use `RcSesAdvancedListItemShell` instead. Will be removed in a future major release.
49
+ */
50
+
47
51
  const AdvancedListItem = ({
48
52
  title,
49
53
  label,
@@ -0,0 +1,35 @@
1
+ import { ReactNode } from 'react'
2
+
3
+ export type AdvancedListItemShellState = 'rest' | 'selected' | 'disabled' | 'error'
4
+
5
+ /**
6
+ * `card` - bordered, rounded container (the default).
7
+ * `row` - flush row within a list: no border/radius, just a bottom divider.
8
+ */
9
+ export type AdvancedListItemShellContainer = 'card' | 'row'
10
+
11
+ export interface AdvancedListItemShellTestIds {
12
+ root?: string
13
+ leading?: string
14
+ content?: string
15
+ trailing?: string
16
+ expanded?: string
17
+ }
18
+
19
+ export interface AdvancedListItemShellProps {
20
+ /** Optional leading slot (e.g. checkbox, radio, avatar, icon). Empty => not rendered. */
21
+ leading?: ReactNode
22
+ /** Required main content slot (title, subtitle, meta, etc.). */
23
+ content: ReactNode
24
+ /** Optional trailing slot (e.g. actions, status, price). Empty => not rendered. */
25
+ trailing?: ReactNode
26
+ /** Optional expandable slot content, shown/hidden via `isExpanded`. */
27
+ expanded?: ReactNode
28
+ isExpanded?: boolean
29
+ state?: AdvancedListItemShellState
30
+ /** Visual container style. Defaults to `card`. */
31
+ container?: AdvancedListItemShellContainer
32
+ onClick?: () => void
33
+ className?: string
34
+ testIds?: AdvancedListItemShellTestIds
35
+ }
@@ -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
+ }
@@ -0,0 +1,24 @@
1
+ import { Option } from './Select.types'
2
+
3
+ export const dropdownSearchFieldValue = '__dropdown-search-field__'
4
+ export const dropdownSelectAllValue = '__dropdown-select-all__'
5
+ export const dropdownGroupOptionPrefix = '__dropdown-group__:'
6
+
7
+ export const isGroupOptionValue = (value: string) =>
8
+ value.startsWith(dropdownGroupOptionPrefix)
9
+
10
+ export const groupNameFromOptionValue = (value: string) =>
11
+ value.slice(dropdownGroupOptionPrefix.length)
12
+
13
+ export const dropdownGroupOptionValue = (groupName: string) =>
14
+ `${dropdownGroupOptionPrefix}${groupName}`
15
+
16
+ export const isInternalOptionValue = (value: string) =>
17
+ value === dropdownSearchFieldValue ||
18
+ value === dropdownSelectAllValue ||
19
+ isGroupOptionValue(value)
20
+
21
+ export const dropdownSearchFieldOption: Option = {
22
+ label: '',
23
+ value: dropdownSearchFieldValue,
24
+ }