@carto/ps-react-ui 6.0.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.
Files changed (142) hide show
  1. package/dist/actions-BWlS5tpP.js +1150 -0
  2. package/dist/actions-BWlS5tpP.js.map +1 -0
  3. package/dist/category-alzjKzvQ.js +839 -0
  4. package/dist/category-alzjKzvQ.js.map +1 -0
  5. package/dist/{download-Vlzn2jzb.js → download-B4sykOFm.js} +94 -83
  6. package/dist/download-B4sykOFm.js.map +1 -0
  7. package/dist/{echart-DjcbtKgi.js → echart-CV8F50gn.js} +6 -5
  8. package/dist/echart-CV8F50gn.js.map +1 -0
  9. package/dist/{formula-CdHWtepq.js → formula-DJS-JLpk.js} +10 -16
  10. package/dist/{formula-CdHWtepq.js.map → formula-DJS-JLpk.js.map} +1 -1
  11. package/dist/legend.js +34 -21
  12. package/dist/legend.js.map +1 -1
  13. package/dist/{markdown-CY-67NRE.js → markdown-Bn2nKCbn.js} +12 -18
  14. package/dist/{markdown-CY-67NRE.js.map → markdown-Bn2nKCbn.js.map} +1 -1
  15. package/dist/{range-DHQSsl2_.js → range-BpU2zBmq.js} +2 -2
  16. package/dist/{range-DHQSsl2_.js.map → range-BpU2zBmq.js.map} +1 -1
  17. package/dist/{spread-DuM5oTI1.js → spread-CQwFIwuz.js} +10 -16
  18. package/dist/{spread-DuM5oTI1.js.map → spread-CQwFIwuz.js.map} +1 -1
  19. package/dist/{stores-B8CHbgw-.js → stores-DcBOZlU3.js} +30 -24
  20. package/dist/stores-DcBOZlU3.js.map +1 -0
  21. package/dist/{table-BE4uO9pp.js → table-DEdW_fDj.js} +7 -13
  22. package/dist/{table-BE4uO9pp.js.map → table-DEdW_fDj.js.map} +1 -1
  23. package/dist/types/legend/stores/types.d.ts +4 -2
  24. package/dist/types/widgets/actions/download/csv-item.d.ts +3 -3
  25. package/dist/types/widgets/actions/download/index.d.ts +2 -1
  26. package/dist/types/widgets/actions/download/png-item.d.ts +2 -2
  27. package/dist/types/widgets/actions/download/types.d.ts +12 -1
  28. package/dist/types/widgets/actions/download/widget-download.d.ts +26 -0
  29. package/dist/types/widgets/actions/fullscreen/fullscreen.d.ts +20 -13
  30. package/dist/types/widgets/actions/index.d.ts +1 -1
  31. package/dist/types/widgets/actions/searcher/filter.d.ts +3 -2
  32. package/dist/types/widgets/actions/searcher/searcher-toggle.d.ts +3 -0
  33. package/dist/types/widgets/bar/download.d.ts +6 -20
  34. package/dist/types/widgets/category/category-ui.d.ts +9 -1
  35. package/dist/types/widgets/category/download.d.ts +5 -10
  36. package/dist/types/widgets/category/helpers.d.ts +10 -0
  37. package/dist/types/widgets/echart/style.d.ts +1 -0
  38. package/dist/types/widgets/formula/download.d.ts +5 -15
  39. package/dist/types/widgets/histogram/download.d.ts +3 -8
  40. package/dist/types/widgets/index.d.ts +1 -1
  41. package/dist/types/widgets/markdown/download.d.ts +5 -11
  42. package/dist/types/widgets/pie/download.d.ts +3 -8
  43. package/dist/types/widgets/scatterplot/download.d.ts +6 -11
  44. package/dist/types/widgets/spread/download.d.ts +6 -12
  45. package/dist/types/widgets/stores/index.d.ts +1 -1
  46. package/dist/types/widgets/stores/widget-store-registry.d.ts +14 -0
  47. package/dist/types/widgets/table/download.d.ts +7 -13
  48. package/dist/types/widgets/timeseries/download.d.ts +7 -12
  49. package/dist/types/widgets/toolbox/toolbox.d.ts +1 -1
  50. package/dist/types/widgets/wrapper/style.d.ts +31 -2
  51. package/dist/types/widgets/wrapper/widget-actions.d.ts +2 -2
  52. package/dist/types/widgets/wrapper/widget-wrapper.d.ts +2 -2
  53. package/dist/{utils-BStJWhZN.js → utils-C-eWwOhE.js} +2 -2
  54. package/dist/{utils-BStJWhZN.js.map → utils-C-eWwOhE.js.map} +1 -1
  55. package/dist/widgets/actions.js +4 -4
  56. package/dist/widgets/bar.js +11 -17
  57. package/dist/widgets/bar.js.map +1 -1
  58. package/dist/widgets/category.js +1 -1
  59. package/dist/widgets/echart.js +1 -1
  60. package/dist/widgets/formula.js +1 -1
  61. package/dist/widgets/histogram.js +14 -20
  62. package/dist/widgets/histogram.js.map +1 -1
  63. package/dist/widgets/markdown.js +1 -1
  64. package/dist/widgets/pie.js +13 -19
  65. package/dist/widgets/pie.js.map +1 -1
  66. package/dist/widgets/range.js +1 -1
  67. package/dist/widgets/scatterplot.js +13 -19
  68. package/dist/widgets/scatterplot.js.map +1 -1
  69. package/dist/widgets/spread.js +1 -1
  70. package/dist/widgets/stores.js +2 -2
  71. package/dist/widgets/table.js +1 -1
  72. package/dist/widgets/timeseries.js +16 -22
  73. package/dist/widgets/timeseries.js.map +1 -1
  74. package/dist/widgets/utils.js +1 -1
  75. package/dist/widgets.js +364 -376
  76. package/dist/widgets.js.map +1 -1
  77. package/dist/{zoom-toggle-D_VuA01l.js → zoom-toggle-MmLjMTEw.js} +2 -2
  78. package/dist/{zoom-toggle-D_VuA01l.js.map → zoom-toggle-MmLjMTEw.js.map} +1 -1
  79. package/package.json +1 -1
  80. package/src/legend/components/legend-item/legend-item-ui.test.tsx +22 -1
  81. package/src/legend/components/legend-ramp/legend-ramp-ui.tsx +22 -6
  82. package/src/legend/stores/types.ts +4 -2
  83. package/src/widgets/actions/download/csv-item.test.tsx +3 -3
  84. package/src/widgets/actions/download/csv-item.tsx +6 -6
  85. package/src/widgets/actions/download/download.tsx +5 -3
  86. package/src/widgets/actions/download/index.ts +2 -1
  87. package/src/widgets/actions/download/png-item.test.tsx +5 -3
  88. package/src/widgets/actions/download/png-item.tsx +4 -4
  89. package/src/widgets/actions/download/types.ts +15 -1
  90. package/src/widgets/actions/download/widget-download.test.ts +30 -0
  91. package/src/widgets/actions/download/widget-download.ts +41 -0
  92. package/src/widgets/actions/fullscreen/fullscreen-store.test.tsx +155 -0
  93. package/src/widgets/actions/fullscreen/fullscreen.test.tsx +39 -41
  94. package/src/widgets/actions/fullscreen/fullscreen.tsx +198 -96
  95. package/src/widgets/actions/index.ts +3 -0
  96. package/src/widgets/actions/searcher/filter.test.ts +28 -0
  97. package/src/widgets/actions/searcher/filter.ts +22 -4
  98. package/src/widgets/actions/searcher/searcher-toggle.tsx +16 -8
  99. package/src/widgets/actions/searcher/searcher.test.tsx +22 -0
  100. package/src/widgets/actions/searcher/searcher.tsx +17 -7
  101. package/src/widgets/bar/download.test.tsx +5 -3
  102. package/src/widgets/bar/download.tsx +11 -35
  103. package/src/widgets/category/category-ui.tsx +26 -14
  104. package/src/widgets/category/category.tsx +37 -2
  105. package/src/widgets/category/components/category-legend.tsx +1 -2
  106. package/src/widgets/category/download.test.ts +4 -2
  107. package/src/widgets/category/download.ts +14 -27
  108. package/src/widgets/category/helpers.test.ts +17 -0
  109. package/src/widgets/category/helpers.ts +16 -0
  110. package/src/widgets/echart/style.ts +6 -0
  111. package/src/widgets/formula/download.test.tsx +3 -1
  112. package/src/widgets/formula/download.tsx +10 -30
  113. package/src/widgets/histogram/download.test.ts +6 -4
  114. package/src/widgets/histogram/download.ts +13 -26
  115. package/src/widgets/index.ts +1 -0
  116. package/src/widgets/markdown/download.test.ts +2 -2
  117. package/src/widgets/markdown/download.tsx +11 -26
  118. package/src/widgets/pie/download.test.ts +7 -3
  119. package/src/widgets/pie/download.ts +12 -25
  120. package/src/widgets/scatterplot/download.test.ts +4 -2
  121. package/src/widgets/scatterplot/download.ts +15 -28
  122. package/src/widgets/spread/download.test.ts +3 -1
  123. package/src/widgets/spread/download.ts +13 -27
  124. package/src/widgets/stores/index.ts +2 -0
  125. package/src/widgets/stores/widget-store-registry.test.ts +25 -0
  126. package/src/widgets/stores/widget-store-registry.ts +22 -0
  127. package/src/widgets/table/download.test.ts +5 -3
  128. package/src/widgets/table/download.ts +15 -29
  129. package/src/widgets/timeseries/download.test.ts +6 -4
  130. package/src/widgets/timeseries/download.ts +16 -29
  131. package/src/widgets/toolbox/toolbox.tsx +1 -1
  132. package/src/widgets/wrapper/style.ts +38 -2
  133. package/src/widgets/wrapper/widget-actions.tsx +2 -2
  134. package/src/widgets/wrapper/widget-wrapper.test.tsx +32 -2
  135. package/src/widgets/wrapper/widget-wrapper.tsx +62 -36
  136. package/dist/actions-KsX1xdDM.js +0 -1024
  137. package/dist/actions-KsX1xdDM.js.map +0 -1
  138. package/dist/category-CsdDqDzo.js +0 -833
  139. package/dist/category-CsdDqDzo.js.map +0 -1
  140. package/dist/download-Vlzn2jzb.js.map +0 -1
  141. package/dist/echart-DjcbtKgi.js.map +0 -1
  142. package/dist/stores-B8CHbgw-.js.map +0 -1
@@ -112,11 +112,41 @@ describe('<Wrapper>', () => {
112
112
  )
113
113
  const actionBtn = screen.getByTestId('action-btn')
114
114
  const bodyContent = screen.getByTestId('body-content')
115
- // The action lives inside the AccordionSummary, the body inside AccordionDetails.
116
- expect(actionBtn.closest('.MuiAccordionSummary-root')).not.toBeNull()
115
+ // The action lives in the header row, beside the summary button rather
116
+ // than inside it (a <button> can't contain another); the body lives in
117
+ // AccordionDetails.
118
+ expect(actionBtn.closest('.widget-wrapper-header')).not.toBeNull()
119
+ expect(actionBtn.closest('.MuiAccordionSummary-root')).toBeNull()
117
120
  expect(bodyContent.closest('.MuiAccordionDetails-root')).not.toBeNull()
118
121
  })
119
122
 
123
+ it('never nests a button inside another', () => {
124
+ const { container } = render(
125
+ withProvider(
126
+ 'wrap-6b',
127
+ <Wrapper title='t'>
128
+ <Actions>
129
+ <button type='button'>A</button>
130
+ </Actions>
131
+ </Wrapper>,
132
+ ),
133
+ )
134
+ expect(container.querySelector('button button')).toBeNull()
135
+ })
136
+
137
+ it('clicking the chevron toggles the wrapper', () => {
138
+ const { container } = render(
139
+ withProvider('wrap-6c', <Wrapper title='t'>body</Wrapper>),
140
+ )
141
+ const summary = screen.getByRole('button', { name: 'Collapse' })
142
+ expect(summary.getAttribute('aria-expanded')).toBe('true')
143
+ const chevron = container.querySelector(
144
+ '.widget-wrapper-header [aria-hidden]',
145
+ )
146
+ fireEvent.click(chevron!)
147
+ expect(summary.getAttribute('aria-expanded')).toBe('false')
148
+ })
149
+
120
150
  it('shows a LinearProgress at the top when the store reports isFetching', () => {
121
151
  render(
122
152
  withProvider(
@@ -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
  )