@carto/ps-react-ui 6.1.0 → 6.1.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.
@@ -54,8 +54,8 @@ export interface WrapperProps {
54
54
  variant?: 'outlined' | 'elevation'
55
55
  labels?: Partial<WrapperLabels>
56
56
  /**
57
- * Icon shown at the right edge of the summary row. Accordion rotates it
58
- * 180° automatically when the wrapper expands. Default: `ExpandMoreIcon`.
57
+ * Icon shown at the right edge of the header row, rotated 180° while the
58
+ * wrapper is expanded. Default: `ExpandMoreIcon`.
59
59
  */
60
60
  expandIcon?: ComponentType<SvgIconProps>
61
61
  iconProps?: SvgIconProps
@@ -117,10 +117,23 @@ export function Wrapper({
117
117
 
118
118
  const ariaLabel = effectiveCollapsed ? _labels.expand : _labels.collapse
119
119
 
120
+ const expanded = !effectiveCollapsed
121
+ const toggle = useCallback(
122
+ () => handleAccordionToggle(null, !expanded),
123
+ [handleAccordionToggle, expanded],
124
+ )
125
+
126
+ // The header row is the Accordion's first child, which MUI treats as its
127
+ // summary slot. Only the title sits inside `<AccordionSummary>` — it
128
+ // renders as a `<button>`, and Actions / Options hold buttons of their
129
+ // own, which HTML doesn't allow inside another button. They sit next to
130
+ // it instead, followed by the chevron: a pointer shortcut for the same
131
+ // toggle, hidden from assistive tech since the summary button already
132
+ // carries it.
120
133
  return (
121
134
  <Accordion
122
135
  data-collapsed={effectiveCollapsed ? 'true' : undefined}
123
- expanded={!effectiveCollapsed}
136
+ expanded={expanded}
124
137
  onChange={handleAccordionToggle}
125
138
  disableGutters
126
139
  elevation={0}
@@ -131,41 +144,54 @@ export function Wrapper({
131
144
  ...sx,
132
145
  }}
133
146
  >
134
- {isFetching ? (
135
- <LinearProgress sx={styles.loading} color='primary' />
136
- ) : null}
137
-
138
- <AccordionSummary
139
- expandIcon={
140
- disabled ? null : <ExpandIcon fontSize='small' {...iconProps} />
141
- }
142
- aria-label={ariaLabel}
143
- aria-disabled={disabled || undefined}
144
- sx={{
145
- ...styles.summary,
146
- ...(disabled ? styles.summaryDisabled : null),
147
- }}
147
+ <Box
148
+ className='widget-wrapper-header'
149
+ sx={{ ...styles.header, ...(disabled && styles.headerNoIcon) }}
148
150
  >
149
- <SmartTooltip title={title}>
150
- {({ ref }) => (
151
- <Box sx={styles.titleCell}>
152
- <Typography
153
- ref={ref}
154
- variant='subtitle1'
155
- sx={[
156
- {
157
- textTransform: 'none',
158
- },
159
- styles.titleText,
160
- ]}
161
- >
162
- {title}
163
- </Typography>
164
- </Box>
165
- )}
166
- </SmartTooltip>
151
+ {isFetching ? (
152
+ <LinearProgress sx={styles.loading} color='primary' />
153
+ ) : null}
154
+ <AccordionSummary
155
+ // The chevron is rendered after Actions below; `null` also keeps
156
+ // a theme-level default icon out of the summary.
157
+ expandIcon={null}
158
+ aria-label={ariaLabel}
159
+ aria-disabled={disabled || undefined}
160
+ sx={{
161
+ ...styles.summary,
162
+ ...(disabled ? styles.summaryDisabled : null),
163
+ }}
164
+ >
165
+ <SmartTooltip title={title}>
166
+ {({ ref }) => (
167
+ <Box sx={styles.titleCell}>
168
+ <Typography
169
+ ref={ref}
170
+ variant='subtitle1'
171
+ sx={[
172
+ {
173
+ textTransform: 'none',
174
+ },
175
+ styles.titleText,
176
+ ]}
177
+ >
178
+ {title}
179
+ </Typography>
180
+ </Box>
181
+ )}
182
+ </SmartTooltip>
183
+ </AccordionSummary>
167
184
  {summarySlots}
168
- </AccordionSummary>
185
+ {disabled ? null : (
186
+ <Box
187
+ aria-hidden
188
+ onClick={toggle}
189
+ sx={{ ...styles.expandIcon, ...(expanded && styles.expanded) }}
190
+ >
191
+ <ExpandIcon fontSize='small' {...iconProps} />
192
+ </Box>
193
+ )}
194
+ </Box>
169
195
  <AccordionDetails sx={styles.detail}>{detailsSlots}</AccordionDetails>
170
196
  </Accordion>
171
197
  )