@carto/meridian-ds 2.1.1 → 2.2.0-alpha-filter-dropdown.5

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 (50) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/{Alert-yL5uEg4Z.js → Link-D5fKicEY.js} +129 -129
  3. package/dist/{Alert-oGAW_syG.cjs → Link-_lzRY1Ay.cjs} +129 -129
  4. package/dist/{MenuItem-CyIdh2wX.cjs → MenuItem-YpFpuljU.cjs} +4 -3
  5. package/dist/{MenuItem-C8x-GasJ.js → MenuItem-badiQq9A.js} +4 -3
  6. package/dist/{TablePaginationActions-BWer8cmX.js → TablePaginationActions-CCDi-BO-.js} +6 -6
  7. package/dist/{TablePaginationActions-MwqZJoRm.cjs → TablePaginationActions-D2K26kdR.cjs} +6 -6
  8. package/dist/components/index.cjs +977 -690
  9. package/dist/components/index.js +944 -657
  10. package/dist/theme/index.cjs +2 -2
  11. package/dist/theme/index.js +3 -3
  12. package/dist/types/components/atoms/Copy/CopiableComponent.d.ts +4 -0
  13. package/dist/types/components/atoms/Copy/CopiableComponent.d.ts.map +1 -0
  14. package/dist/types/components/atoms/Copy/CopiableInputText.d.ts +18 -0
  15. package/dist/types/components/atoms/Copy/CopiableInputText.d.ts.map +1 -0
  16. package/dist/types/components/atoms/Copy/copyString.d.ts.map +1 -0
  17. package/dist/types/components/{molecules → atoms}/Copy/index.d.ts +2 -1
  18. package/dist/types/components/atoms/Copy/index.d.ts.map +1 -0
  19. package/dist/types/components/{molecules/Copy/CopiableComponent.d.ts → atoms/Copy/types.d.ts} +11 -5
  20. package/dist/types/components/atoms/Copy/types.d.ts.map +1 -0
  21. package/dist/types/components/atoms/Copy/useCopyValue.d.ts.map +1 -0
  22. package/dist/types/components/atoms/index.d.ts +2 -0
  23. package/dist/types/components/atoms/index.d.ts.map +1 -1
  24. package/dist/types/components/molecules/FilterDropdown/FilterDropdown.d.ts +6 -0
  25. package/dist/types/components/molecules/FilterDropdown/FilterDropdown.d.ts.map +1 -0
  26. package/dist/types/components/molecules/FilterDropdown/FilterDropdownMenuItem.d.ts +3 -0
  27. package/dist/types/components/molecules/FilterDropdown/FilterDropdownMenuItem.d.ts.map +1 -0
  28. package/dist/types/components/molecules/FilterDropdown/index.d.ts +4 -0
  29. package/dist/types/components/molecules/FilterDropdown/index.d.ts.map +1 -0
  30. package/dist/types/components/molecules/FilterDropdown/types.d.ts +55 -0
  31. package/dist/types/components/molecules/FilterDropdown/types.d.ts.map +1 -0
  32. package/dist/types/components/molecules/Menu/MenuItem.d.ts.map +1 -1
  33. package/dist/types/components/molecules/index.d.ts +2 -2
  34. package/dist/types/components/molecules/index.d.ts.map +1 -1
  35. package/dist/types/components/organisms/CodeArea/CodeAreaHeader.d.ts.map +1 -1
  36. package/dist/types/components/organisms/Dialog/types.d.ts +1 -1
  37. package/dist/types/components/organisms/Dialog/types.d.ts.map +1 -1
  38. package/dist/types/localization/en.d.ts +2 -2
  39. package/dist/types/localization/es.d.ts +2 -2
  40. package/dist/types/localization/id.d.ts +2 -2
  41. package/dist/types/localization/index.d.ts +6 -6
  42. package/dist/widgets/index.cjs +8 -8
  43. package/dist/widgets/index.js +2 -2
  44. package/package.json +1 -1
  45. package/dist/types/components/molecules/Copy/CopiableComponent.d.ts.map +0 -1
  46. package/dist/types/components/molecules/Copy/copyString.d.ts.map +0 -1
  47. package/dist/types/components/molecules/Copy/index.d.ts.map +0 -1
  48. package/dist/types/components/molecules/Copy/useCopyValue.d.ts.map +0 -1
  49. /package/dist/types/components/{molecules → atoms}/Copy/copyString.d.ts +0 -0
  50. /package/dist/types/components/{molecules → atoms}/Copy/useCopyValue.d.ts +0 -0
@@ -1,16 +1,16 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import React, { forwardRef, useState, useRef, useEffect, useMemo, createElement, Fragment as Fragment$1, useCallback, useImperativeHandle } from "react";
3
3
  import { useIntl } from "react-intl";
4
- import { styled, Box, Button as Button$1, CircularProgress, Popper, Grow, Paper, ClickAwayListener, MenuList as MenuList$1, MenuItem, ButtonGroup as ButtonGroup$1, TextField, InputAdornment, IconButton, Tooltip, Select, FormControl, InputLabel, FormHelperText, ToggleButtonGroup as ToggleButtonGroup$1, Menu as Menu$2, Link, Checkbox, ListItemText, Autocomplete as Autocomplete$1, Divider, ListItemIcon, createFilterOptions, Accordion, AccordionSummary, AccordionDetails, Avatar as Avatar$1, Snackbar as Snackbar$1, Portal, Fade, Slide, alpha, useTheme, Toolbar, AppBar as AppBar$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, Chip, DialogContent as DialogContent$1, DialogActions as DialogActions$1 } from "@mui/material";
5
- import { OpenInNewOutlined, VisibilityOffOutlined, VisibilityOutlined, Cancel, AddCircleOutlineOutlined, ContentCopyOutlined, CloseOutlined, MenuOutlined, HelpOutline, TodayOutlined, MoreVertOutlined, ErrorOutline, Check } from "@mui/icons-material";
6
- import { u as useImperativeIntl, T as Typography, c as ICON_SIZE_SMALL, f as MENU_ITEM_SIZE_EXTENDED, e as MENU_ITEM_SIZE_DENSE, d as MENU_LIST_MAX_SIZE, M as MENU_ITEM_SIZE_DEFAULT, N as NOTIFICATION_DURATION_IN_MS, A as APPBAR_SIZE } from "../TablePaginationActions-BWer8cmX.js";
7
- import { a } from "../TablePaginationActions-BWer8cmX.js";
8
- import { S as ScreenReaderOnly, I as IconButton$1, A as Alert$1 } from "../Alert-yL5uEg4Z.js";
9
- import { L } from "../Alert-yL5uEg4Z.js";
4
+ import { styled, Menu as Menu$2, MenuList as MenuList$1, Link, Checkbox, Select, MenuItem as MenuItem$1, FormControl, Box, InputLabel, FormHelperText, InputAdornment, IconButton, ListItemText, Tooltip, TextField, CircularProgress, Button as Button$1, Autocomplete as Autocomplete$1, Divider, ListItemIcon, createFilterOptions, useMediaQuery, Accordion, AccordionSummary, AccordionDetails, Avatar as Avatar$1, Snackbar as Snackbar$1, Portal, Fade, Slide, Popper, Grow, Paper, ClickAwayListener, ButtonGroup as ButtonGroup$1, ToggleButtonGroup as ToggleButtonGroup$1, alpha, useTheme, Toolbar, AppBar as AppBar$1, Dialog as Dialog$1, DialogTitle as DialogTitle$1, Chip, DialogContent as DialogContent$1, DialogActions as DialogActions$1 } from "@mui/material";
5
+ import { Cancel, AddCircleOutlineOutlined, CloseOutlined, ContentCopyOutlined, VisibilityOutlined, VisibilityOffOutlined, OpenInNewOutlined, MenuOutlined, HelpOutline, TodayOutlined, MoreVertOutlined, ErrorOutline, Check } from "@mui/icons-material";
6
+ import { f as MENU_ITEM_SIZE_EXTENDED, u as useImperativeIntl, T as Typography, e as MENU_ITEM_SIZE_DENSE, d as MENU_LIST_MAX_SIZE, M as MENU_ITEM_SIZE_DEFAULT, c as ICON_SIZE_SMALL, N as NOTIFICATION_DURATION_IN_MS, A as APPBAR_SIZE } from "../TablePaginationActions-CCDi-BO-.js";
7
+ import { a } from "../TablePaginationActions-CCDi-BO-.js";
8
+ import { I as IconButton$1, A as Alert$1, S as ScreenReaderOnly } from "../Link-D5fKicEY.js";
9
+ import { L } from "../Link-D5fKicEY.js";
10
10
  import { A as ArrowDown } from "../ArrowDown-d6bxUL0F.js";
11
11
  import { A as ArrowUp, O as OpenDiagonallyRight, C as CloseDiagonallyRight } from "../OpenDiagonallyRight-CGdCEXlF.js";
12
12
  import "cartocolor";
13
- import { M as MenuItem$1 } from "../MenuItem-C8x-GasJ.js";
13
+ import { M as MenuItem } from "../MenuItem-badiQq9A.js";
14
14
  import { FixedSizeList } from "react-window";
15
15
  import { DatePicker as DatePicker$1 } from "@mui/x-date-pickers/DatePicker";
16
16
  import { PickersDay as PickersDay$1 } from "@mui/x-date-pickers";
@@ -41,307 +41,195 @@ import "codemirror/addon/fold/indent-fold.js";
41
41
  import "codemirror/addon/fold/markdown-fold.js";
42
42
  import "codemirror/addon/fold/comment-fold.js";
43
43
  import ClickAwayListener$1 from "@mui/material/ClickAwayListener";
44
- const IndicatorIcon = styled(Box)({
45
- position: "absolute",
46
- top: 0,
47
- left: 0,
48
- right: 0,
49
- bottom: 0,
50
- display: "flex",
51
- alignItems: "center",
52
- justifyContent: "center"
53
- });
54
- const HiddenText = styled(Box)({
55
- visibility: "hidden",
56
- pointerEvents: "none"
57
- });
58
- function _Button({
59
- children,
60
- loading,
61
- disabled,
62
- startIcon,
63
- endIcon,
64
- loadingPosition,
65
- external,
66
- showExternalIcon = true,
67
- "aria-describedby": ariaDescribedby,
68
- ...otherProps
69
- }, ref) {
70
- const intl = useIntl();
71
- const intlConfig = useImperativeIntl(intl);
72
- const defaultIconLoader = /* @__PURE__ */ jsx(CircularProgress, { size: 18, color: "inherit" });
73
- const isDefaultLoading = loading && loadingPosition === void 0;
74
- const isExternalLink = otherProps.href && external;
75
- const renderContent = () => {
76
- if (isDefaultLoading) {
77
- return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
78
- /* @__PURE__ */ jsx(IndicatorIcon, { children: defaultIconLoader }),
79
- /* @__PURE__ */ jsx(HiddenText, { children })
80
- ] });
44
+ const StyledMenu = styled(Menu$2, {
45
+ shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
46
+ })(({ extended, width, height }) => ({
47
+ ...extended && {
48
+ ".MuiMenuItem-root": {
49
+ minHeight: MENU_ITEM_SIZE_EXTENDED
81
50
  }
82
- if (isExternalLink) {
83
- return /* @__PURE__ */ jsxs(Fragment, { children: [
84
- children,
85
- /* @__PURE__ */ jsx(ScreenReaderOnly, { id: "external-hint", children: `(${intlConfig.formatMessage({
86
- id: "c4r.button.opensInNewTab"
87
- })})` })
88
- ] });
51
+ },
52
+ ...width && {
53
+ ".MuiList-root": {
54
+ width,
55
+ minWidth: width
89
56
  }
90
- return children;
91
- };
92
- const getIconForPosition = (position) => {
93
- if (isDefaultLoading) {
94
- return void 0;
57
+ },
58
+ ...height && {
59
+ ".MuiMenu-paper": {
60
+ overflow: "hidden"
61
+ },
62
+ ".MuiList-root": {
63
+ maxHeight: height
95
64
  }
96
- if (loading && loadingPosition !== void 0) {
97
- if (loadingPosition === position) {
98
- return defaultIconLoader;
65
+ }
66
+ }));
67
+ function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
68
+ return /* @__PURE__ */ jsx(
69
+ StyledMenu,
70
+ {
71
+ ...otherProps,
72
+ ref,
73
+ "data-name": "menu",
74
+ width,
75
+ height,
76
+ extended,
77
+ MenuListProps: {
78
+ ...MenuListProps,
79
+ "data-width": width,
80
+ "data-height": height,
81
+ "data-extended": extended
99
82
  }
100
- return void 0;
101
83
  }
102
- if (position === "start") {
103
- return startIcon;
104
- } else {
105
- return endIcon || (isExternalLink && showExternalIcon ? /* @__PURE__ */ jsx(OpenInNewOutlined, {}) : void 0);
84
+ );
85
+ }
86
+ const Menu$1 = forwardRef(_Menu);
87
+ const StyledMenuList = styled(MenuList$1, {
88
+ shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
89
+ })(({ extended, width, height }) => ({
90
+ ...extended && {
91
+ ".MuiMenuItem-root": {
92
+ minHeight: MENU_ITEM_SIZE_EXTENDED
106
93
  }
107
- };
94
+ },
95
+ "&.MuiList-root": {
96
+ ...width && {
97
+ width,
98
+ minWidth: width
99
+ },
100
+ ...height && {
101
+ maxHeight: height
102
+ }
103
+ }
104
+ }));
105
+ function _MenuList({ extended, width, height, ...otherProps }, ref) {
108
106
  return /* @__PURE__ */ jsx(
109
- Button$1,
107
+ StyledMenuList,
110
108
  {
111
- disabled: loading || disabled,
112
- startIcon: getIconForPosition("start"),
113
- endIcon: getIconForPosition("end"),
114
109
  ...otherProps,
115
- role: otherProps.href ? "link" : "button",
116
- ...isExternalLink && {
117
- target: "_blank",
118
- rel: "noopener noreferrer"
119
- },
120
110
  ref,
121
- "aria-describedby": isExternalLink ? "external-hint" : ariaDescribedby,
122
- children: /* @__PURE__ */ jsx(Typography, { variant: "inherit", color: "inherit", noWrap: true, component: "span", children: renderContent() })
111
+ width,
112
+ height,
113
+ extended,
114
+ "data-name": "menu-list",
115
+ "data-width": width,
116
+ "data-height": height,
117
+ "data-extended": extended
123
118
  }
124
119
  );
125
120
  }
126
- const Button = forwardRef(_Button);
127
- const ButtonGroup = styled(ButtonGroup$1)(({ theme, size }) => ({
128
- "& .MuiButton-root:last-child": {
129
- padding: 0,
130
- minWidth: size === "small" ? theme.spacing(3) : size === "large" ? theme.spacing(6) : theme.spacing(4)
121
+ const MenuList = forwardRef(_MenuList);
122
+ const StyledMenuItem$1 = styled(MenuItem)(() => ({
123
+ marginTop: "0 !important",
124
+ marginBottom: "0 !important"
125
+ }));
126
+ const LinkFilter = styled(Link)(
127
+ ({ disabled, theme }) => ({
128
+ display: "flex",
129
+ alignItems: "center",
130
+ gap: theme.spacing(1),
131
+ width: "100%",
132
+ textAlign: "initial",
133
+ ...disabled && {
134
+ pointerEvents: "none",
135
+ color: theme.palette.text.disabled
136
+ }
137
+ })
138
+ );
139
+ function _MenuItemFilter({
140
+ areAllSelected,
141
+ areAnySelected,
142
+ selectAll,
143
+ selectAllDisabled,
144
+ "aria-label": ariaLabel,
145
+ "data-testid": dataTestId
146
+ }, ref) {
147
+ const intl = useIntl();
148
+ const intlConfig = useImperativeIntl(intl);
149
+ return /* @__PURE__ */ jsx(
150
+ StyledMenuItem$1,
151
+ {
152
+ ref,
153
+ fixed: true,
154
+ "data-name": "menu-filter",
155
+ "aria-label": ariaLabel,
156
+ "data-testid": dataTestId,
157
+ children: /* @__PURE__ */ jsxs(
158
+ LinkFilter,
159
+ {
160
+ variant: "body2",
161
+ color: "textPrimary",
162
+ component: "button",
163
+ underline: "none",
164
+ disabled: !!selectAllDisabled,
165
+ onClick: selectAll,
166
+ tabIndex: 0,
167
+ children: [
168
+ /* @__PURE__ */ jsx(
169
+ Checkbox,
170
+ {
171
+ checked: areAllSelected,
172
+ indeterminate: areAnySelected && !areAllSelected,
173
+ disabled: selectAllDisabled
174
+ }
175
+ ),
176
+ intlConfig.formatMessage({ id: "c4r.form.selectAll" })
177
+ ]
178
+ }
179
+ )
180
+ }
181
+ );
182
+ }
183
+ const MenuItemFilter = forwardRef(_MenuItemFilter);
184
+ const idCounter = {};
185
+ function uniqueId(prefix = "$lodash$") {
186
+ if (!idCounter[prefix]) {
187
+ idCounter[prefix] = 0;
188
+ }
189
+ const id = ++idCounter[prefix];
190
+ if (prefix === "$lodash$") {
191
+ return `${id}`;
192
+ }
193
+ return `${prefix}${id}`;
194
+ }
195
+ const StyledSelect = styled(Select)(({ theme }) => ({
196
+ "& .MuiInputAdornment-positionStart": {
197
+ paddingLeft: theme.spacing(2),
198
+ "&.MuiInputAdornment-sizeSmall": {
199
+ paddingLeft: theme.spacing(1.5)
200
+ }
201
+ },
202
+ "& .MuiInputBase-inputAdornedStart": {
203
+ paddingLeft: "0px !important"
204
+ },
205
+ "& .MuiSelect-select .MuiMenuItem-root:hover": {
206
+ backgroundColor: "transparent"
207
+ },
208
+ "&.MuiInputBase-root .MuiSelect-select.MuiSelect-multiple": {
209
+ paddingRight: theme.spacing(7)
131
210
  }
132
211
  }));
133
- function SplitButton({
134
- options,
212
+ const PlaceholderItem = styled(MenuItem$1)(() => ({
213
+ display: "none"
214
+ }));
215
+ function _SelectField({
216
+ children,
217
+ placeholder,
218
+ size = "small",
219
+ displayEmpty,
220
+ menuProps,
221
+ inputProps,
222
+ labelId,
223
+ label,
224
+ labelSecondary,
225
+ helperText,
226
+ name,
227
+ error,
228
+ focused,
135
229
  disabled,
136
- loading,
137
- loadingPosition,
138
- onClick,
139
- variant,
140
- size,
141
- color,
142
- ...otherProps
143
- }) {
144
- var _a;
145
- const [open, setOpen] = useState(false);
146
- const anchorRef = useRef(null);
147
- const [selectedIndex, setSelectedIndex] = useState(0);
148
- const handleClick = () => {
149
- onClick(options[selectedIndex]);
150
- };
151
- const handleMenuItemClick = (_, index) => {
152
- setSelectedIndex(index);
153
- setOpen(false);
154
- };
155
- const handleToggle = () => {
156
- setOpen((prevOpen) => !prevOpen);
157
- };
158
- const handleClose = (event) => {
159
- var _a2;
160
- if ((_a2 = anchorRef.current) == null ? void 0 : _a2.contains(event.target)) {
161
- return;
162
- }
163
- setOpen(false);
164
- };
165
- return /* @__PURE__ */ jsxs(Fragment, { children: [
166
- /* @__PURE__ */ jsxs(
167
- ButtonGroup,
168
- {
169
- "data-name": "split-button",
170
- ref: anchorRef,
171
- variant,
172
- size,
173
- color,
174
- ...otherProps,
175
- children: [
176
- /* @__PURE__ */ jsx(
177
- Button,
178
- {
179
- disabled,
180
- loading,
181
- loadingPosition,
182
- onClick: handleClick,
183
- children: (_a = options[selectedIndex]) == null ? void 0 : _a.label
184
- }
185
- ),
186
- /* @__PURE__ */ jsx(Button, { disabled: loading || disabled, onClick: handleToggle, children: open ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}) })
187
- ]
188
- }
189
- ),
190
- /* @__PURE__ */ jsx(
191
- Popper,
192
- {
193
- sx: { zIndex: 1 },
194
- open,
195
- anchorEl: anchorRef.current,
196
- role: void 0,
197
- transition: true,
198
- disablePortal: true,
199
- placement: "bottom-end",
200
- children: ({ TransitionProps, placement }) => /* @__PURE__ */ jsx(
201
- Grow,
202
- {
203
- ...TransitionProps,
204
- style: {
205
- transformOrigin: placement === "bottom" ? "center top" : "center bottom"
206
- },
207
- children: /* @__PURE__ */ jsx(Paper, { elevation: 8, children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsx(MenuList$1, { autoFocusItem: true, sx: { paddingY: 1 }, children: options.map((option, index) => /* @__PURE__ */ jsx(
208
- MenuItem,
209
- {
210
- disabled: option.disabled,
211
- selected: index === selectedIndex,
212
- onClick: (event) => handleMenuItemClick(event, index),
213
- children: option.label
214
- },
215
- option.label
216
- )) }) }) })
217
- }
218
- )
219
- }
220
- )
221
- ] });
222
- }
223
- const Root$5 = styled(Box)(({ theme }) => ({
224
- display: "flex",
225
- alignItems: "center",
226
- gap: theme.spacing(0.5)
227
- }));
228
- const Indicator = styled(Typography)(({ theme }) => ({
229
- ".Mui-disabled &": {
230
- color: theme.palette.text.disabled
231
- }
232
- }));
233
- const Icon = styled(Box)(({ theme }) => ({
234
- display: "flex",
235
- svg: {
236
- width: ICON_SIZE_SMALL,
237
- height: ICON_SIZE_SMALL,
238
- fontSize: ICON_SIZE_SMALL,
239
- path: {
240
- fill: theme.palette.text.secondary,
241
- ".Mui-disabled &": {
242
- fill: theme.palette.text.disabled
243
- }
244
- }
245
- }
246
- }));
247
- function LabelWithIndicator({
248
- label,
249
- type,
250
- icon,
251
- inheritSize
252
- }) {
253
- return /* @__PURE__ */ jsxs(Root$5, { children: [
254
- label,
255
- type && /* @__PURE__ */ jsx(
256
- Indicator,
257
- {
258
- component: "span",
259
- variant: inheritSize ? "inherit" : "caption",
260
- color: "textSecondary",
261
- weight: "regular",
262
- children: type === "required" ? "(required)" : "(optional)"
263
- }
264
- ),
265
- icon && /* @__PURE__ */ jsx(Icon, { children: icon })
266
- ] });
267
- }
268
- function _PasswordField({ InputProps, size = "small", ...otherProps }, ref) {
269
- const intl = useIntl();
270
- const intlConfig = useImperativeIntl(intl);
271
- const [showPassword, setShowPassword] = useState(false);
272
- const handleClickShowPassword = () => setShowPassword(!showPassword);
273
- return /* @__PURE__ */ jsx(
274
- TextField,
275
- {
276
- ...otherProps,
277
- ref,
278
- type: showPassword ? "text" : "password",
279
- size,
280
- InputProps: {
281
- ...InputProps,
282
- endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(IconButton, { size, onClick: handleClickShowPassword, children: /* @__PURE__ */ jsx(
283
- Tooltip,
284
- {
285
- title: intlConfig.formatMessage({
286
- id: `c4r.form.${showPassword ? "hidePassword" : "showPassword"}`
287
- }),
288
- children: showPassword ? /* @__PURE__ */ jsx(VisibilityOffOutlined, {}) : /* @__PURE__ */ jsx(VisibilityOutlined, {})
289
- }
290
- ) }) })
291
- }
292
- }
293
- );
294
- }
295
- const PasswordField = forwardRef(_PasswordField);
296
- const idCounter = {};
297
- function uniqueId(prefix = "$lodash$") {
298
- if (!idCounter[prefix]) {
299
- idCounter[prefix] = 0;
300
- }
301
- const id = ++idCounter[prefix];
302
- if (prefix === "$lodash$") {
303
- return `${id}`;
304
- }
305
- return `${prefix}${id}`;
306
- }
307
- const StyledSelect = styled(Select)(({ theme }) => ({
308
- "& .MuiInputAdornment-positionStart": {
309
- paddingLeft: theme.spacing(2),
310
- "&.MuiInputAdornment-sizeSmall": {
311
- paddingLeft: theme.spacing(1.5)
312
- }
313
- },
314
- "& .MuiInputBase-inputAdornedStart": {
315
- paddingLeft: "0px !important"
316
- },
317
- "& .MuiSelect-select .MuiMenuItem-root:hover": {
318
- backgroundColor: "transparent"
319
- },
320
- "&.MuiInputBase-root .MuiSelect-select.MuiSelect-multiple": {
321
- paddingRight: theme.spacing(7)
322
- }
323
- }));
324
- const PlaceholderItem = styled(MenuItem)(() => ({
325
- display: "none"
326
- }));
327
- function _SelectField({
328
- children,
329
- placeholder,
330
- size = "small",
331
- displayEmpty,
332
- menuProps,
333
- inputProps,
334
- labelId,
335
- label,
336
- labelSecondary,
337
- helperText,
338
- name,
339
- error,
340
- focused,
341
- disabled,
342
- fullWidth,
343
- required,
344
- "aria-label": ariaLabel,
230
+ fullWidth,
231
+ required,
232
+ "aria-label": ariaLabel,
345
233
  ...otherProps
346
234
  }, ref) {
347
235
  const isSmall = size === "small";
@@ -411,236 +299,6 @@ function _SelectField({
411
299
  );
412
300
  }
413
301
  const SelectField = forwardRef(_SelectField);
414
- const StyledToggleButtonGroup = styled(ToggleButtonGroup$1, {
415
- shouldForwardProp: (prop) => prop !== "variant" && prop !== "backgroundColor"
416
- })(({ variant, backgroundColor, theme }) => ({
417
- // Variants
418
- ...variant === "contained" && {
419
- boxShadow: "none"
420
- },
421
- ...variant === "unbounded" && {
422
- boxShadow: "none",
423
- borderRadius: theme.spacing(0.5),
424
- "& .MuiDivider-root": {
425
- height: theme.spacing(4),
426
- "&.MuiToggleButtonGroup-groupedHorizontal": {
427
- height: theme.spacing(4)
428
- },
429
- "&.MuiToggleButtonGroup-groupedVertical": {
430
- height: "auto",
431
- width: theme.spacing(4),
432
- margin: `${theme.spacing(0.5, 0, 1)} !important`,
433
- borderRadius: "0 !important"
434
- }
435
- },
436
- "& .MuiToggleButton-sizeSmall": {
437
- margin: 0,
438
- "&.MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
439
- margin: 0
440
- },
441
- "& + .MuiDivider-root.MuiToggleButtonGroup-groupedHorizontal": {
442
- height: theme.spacing(3)
443
- },
444
- "& + .MuiDivider-root.MuiToggleButtonGroup-groupedVertical": {
445
- height: "auto",
446
- width: theme.spacing(3)
447
- }
448
- },
449
- ".MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
450
- margin: 0,
451
- "&:first-of-type": {
452
- marginLeft: 0
453
- },
454
- "&:not(:last-of-type)": {
455
- marginRight: theme.spacing(0.5)
456
- }
457
- },
458
- "&.MuiToggleButtonGroup-horizontal:not(.MuiDivider-root)": {
459
- ".MuiToggleButtonGroup-grouped": {
460
- margin: theme.spacing(0, 0.5)
461
- }
462
- },
463
- "&.MuiToggleButtonGroup-vertical:not(.MuiDivider-root)": {
464
- ".MuiToggleButtonGroup-grouped": {
465
- margin: theme.spacing(0, 0, 0.5),
466
- "&:not(:last-of-type)": {
467
- marginRight: 0
468
- },
469
- "&:last-of-type": {
470
- marginBottom: 0
471
- }
472
- }
473
- }
474
- },
475
- // Colors
476
- ...backgroundColor === "primary" && {
477
- backgroundColor: theme.palette.background.paper
478
- },
479
- ...backgroundColor === "secondary" && {
480
- backgroundColor: theme.palette.background.default
481
- },
482
- ...backgroundColor === "transparent" && {
483
- backgroundColor: "transparent"
484
- }
485
- }));
486
- function ToggleButtonGroup({
487
- children,
488
- variant = "floating",
489
- backgroundColor,
490
- ...rest
491
- }) {
492
- const isUnbounded = variant === "unbounded";
493
- const defaultColor = isUnbounded ? "transparent" : "primary";
494
- return /* @__PURE__ */ jsx(
495
- StyledToggleButtonGroup,
496
- {
497
- ...rest,
498
- variant,
499
- backgroundColor: backgroundColor ?? defaultColor,
500
- children
501
- }
502
- );
503
- }
504
- const StyledMenu = styled(Menu$2, {
505
- shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
506
- })(({ extended, width, height }) => ({
507
- ...extended && {
508
- ".MuiMenuItem-root": {
509
- minHeight: MENU_ITEM_SIZE_EXTENDED
510
- }
511
- },
512
- ...width && {
513
- ".MuiList-root": {
514
- width,
515
- minWidth: width
516
- }
517
- },
518
- ...height && {
519
- ".MuiMenu-paper": {
520
- overflow: "hidden"
521
- },
522
- ".MuiList-root": {
523
- maxHeight: height
524
- }
525
- }
526
- }));
527
- function _Menu({ extended, width, height, MenuListProps, ...otherProps }, ref) {
528
- return /* @__PURE__ */ jsx(
529
- StyledMenu,
530
- {
531
- ...otherProps,
532
- ref,
533
- "data-name": "menu",
534
- width,
535
- height,
536
- extended,
537
- MenuListProps: {
538
- ...MenuListProps,
539
- "data-width": width,
540
- "data-height": height,
541
- "data-extended": extended
542
- }
543
- }
544
- );
545
- }
546
- const Menu$1 = forwardRef(_Menu);
547
- const StyledMenuList = styled(MenuList$1, {
548
- shouldForwardProp: (prop) => !["extended", "width", "height"].includes(prop)
549
- })(({ extended, width, height }) => ({
550
- ...extended && {
551
- ".MuiMenuItem-root": {
552
- minHeight: MENU_ITEM_SIZE_EXTENDED
553
- }
554
- },
555
- "&.MuiList-root": {
556
- ...width && {
557
- width,
558
- minWidth: width
559
- },
560
- ...height && {
561
- maxHeight: height
562
- }
563
- }
564
- }));
565
- function _MenuList({ extended, width, height, ...otherProps }, ref) {
566
- return /* @__PURE__ */ jsx(
567
- StyledMenuList,
568
- {
569
- ...otherProps,
570
- ref,
571
- width,
572
- height,
573
- extended,
574
- "data-name": "menu-list",
575
- "data-width": width,
576
- "data-height": height,
577
- "data-extended": extended
578
- }
579
- );
580
- }
581
- const MenuList = forwardRef(_MenuList);
582
- const StyledMenuItem$1 = styled(MenuItem$1)(() => ({
583
- marginTop: "0 !important",
584
- marginBottom: "0 !important"
585
- }));
586
- const LinkFilter = styled(Link)(
587
- ({ disabled, theme }) => ({
588
- display: "flex",
589
- alignItems: "center",
590
- gap: theme.spacing(1),
591
- width: "100%",
592
- textAlign: "initial",
593
- ...disabled && {
594
- pointerEvents: "none",
595
- color: theme.palette.text.disabled
596
- }
597
- })
598
- );
599
- function _MenuItemFilter({
600
- areAllSelected,
601
- areAnySelected,
602
- selectAll,
603
- selectAllDisabled,
604
- "aria-label": ariaLabel,
605
- "data-testid": dataTestId
606
- }, ref) {
607
- const intl = useIntl();
608
- const intlConfig = useImperativeIntl(intl);
609
- return /* @__PURE__ */ jsx(
610
- StyledMenuItem$1,
611
- {
612
- ref,
613
- fixed: true,
614
- "data-name": "menu-filter",
615
- "aria-label": ariaLabel,
616
- "data-testid": dataTestId,
617
- children: /* @__PURE__ */ jsxs(
618
- LinkFilter,
619
- {
620
- variant: "body2",
621
- color: "textPrimary",
622
- component: "button",
623
- underline: "none",
624
- disabled: !!selectAllDisabled,
625
- onClick: selectAll,
626
- tabIndex: 0,
627
- children: [
628
- /* @__PURE__ */ jsx(
629
- Checkbox,
630
- {
631
- checked: areAllSelected,
632
- indeterminate: areAnySelected && !areAllSelected,
633
- disabled: selectAllDisabled
634
- }
635
- ),
636
- intlConfig.formatMessage({ id: "c4r.form.selectAll" })
637
- ]
638
- }
639
- )
640
- }
641
- );
642
- }
643
- const MenuItemFilter = forwardRef(_MenuItemFilter);
644
302
  function useMultipleSelectField({
645
303
  selectedOptions,
646
304
  options,
@@ -702,7 +360,7 @@ function useMultipleSelectField({
702
360
  unselectAll
703
361
  };
704
362
  }
705
- const StyledMenuItem = styled(MenuItem)(({ theme }) => ({
363
+ const StyledMenuItem = styled(MenuItem$1)(({ theme }) => ({
706
364
  "&.Mui-disabled": {
707
365
  pointerEvents: "auto",
708
366
  "&:hover": {
@@ -1290,7 +948,7 @@ function useAutocompleteRenderOption() {
1290
948
  const { key, ...otherProps } = props;
1291
949
  if (isAutocompleteListGroupHeader(option)) {
1292
950
  return /* @__PURE__ */ createElement(
1293
- MenuItem$1,
951
+ MenuItem,
1294
952
  {
1295
953
  ...otherProps,
1296
954
  subtitle: true,
@@ -1332,7 +990,7 @@ function useAutocompleteRenderOption() {
1332
990
  return /* @__PURE__ */ jsx(Fragment$1, { children: divider ? /* @__PURE__ */ jsx(Divider, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
1333
991
  inputValue && /* @__PURE__ */ jsx(Divider, {}),
1334
992
  /* @__PURE__ */ jsxs(
1335
- MenuItem$1,
993
+ MenuItem,
1336
994
  {
1337
995
  ...otherProps,
1338
996
  ...!isPrimitiveOptionType && {
@@ -1871,96 +1529,183 @@ function useAutocomplete({
1871
1529
  getOptionLabel: internalGetOptionLabel
1872
1530
  };
1873
1531
  }
1874
- const _CopiableComponent = ({
1875
- children,
1876
- disabled,
1532
+ const FilterDropdownMenuItem = ({
1533
+ item,
1534
+ selectedValue,
1535
+ dense,
1536
+ extended,
1537
+ onItemChange
1538
+ }) => {
1539
+ const {
1540
+ id,
1541
+ label,
1542
+ description,
1543
+ startAdornment,
1544
+ endAdornment,
1545
+ tooltipLabel,
1546
+ tooltipPlacement,
1547
+ disabled,
1548
+ "aria-label": ariaLabel,
1549
+ hidden,
1550
+ destructive,
1551
+ subtitle,
1552
+ divider,
1553
+ fixed,
1554
+ selected
1555
+ } = item;
1556
+ const menuItemId = `filter-dropdown-item-${id}`;
1557
+ const isSelected = selected || (selectedValue == null ? void 0 : selectedValue.id) === id;
1558
+ if (hidden) return null;
1559
+ return /* @__PURE__ */ jsx(Tooltip, { title: tooltipLabel, placement: tooltipPlacement, children: /* @__PURE__ */ jsxs(
1560
+ MenuItem,
1561
+ {
1562
+ onClick: disabled ? void 0 : (event) => onItemChange(item, event),
1563
+ selected: isSelected,
1564
+ dense,
1565
+ extended,
1566
+ disabled,
1567
+ destructive,
1568
+ subtitle,
1569
+ divider,
1570
+ fixed,
1571
+ "aria-label": ariaLabel,
1572
+ "aria-labelledby": menuItemId,
1573
+ "aria-selected": isSelected,
1574
+ children: [
1575
+ startAdornment && /* @__PURE__ */ jsx(ListItemIcon, { children: startAdornment }),
1576
+ /* @__PURE__ */ jsx(ListItemText, { id: menuItemId, primary: label, secondary: description }),
1577
+ endAdornment && /* @__PURE__ */ jsx(ListItemIcon, { children: endAdornment })
1578
+ ]
1579
+ }
1580
+ ) }, id);
1581
+ };
1582
+ const ButtonWrapper = styled(Box, {
1583
+ shouldForwardProp: (prop) => prop !== "isOpen" && prop !== "buttonColor"
1584
+ })(({ isOpen, theme, buttonColor }) => ({
1585
+ display: "flex",
1586
+ alignItems: "center",
1587
+ justifyContent: "center",
1588
+ ...isOpen && {
1589
+ "& .MuiButtonBase-root": {
1590
+ backgroundColor: theme.palette.action.hover
1591
+ }
1592
+ },
1593
+ ...buttonColor === "secondary" && {
1594
+ "& button": {
1595
+ color: theme.palette.text.secondary
1596
+ }
1597
+ }
1598
+ }));
1599
+ function _FilterDropdown({
1600
+ menuItems,
1601
+ onClickItem,
1877
1602
  value,
1878
- onCopied,
1879
- copyText = "c4r.button.copy",
1880
- copiedText = "c4r.notifications.copiedToClipboard",
1881
- button,
1882
- buttonLabel,
1883
- buttonProps,
1884
- ariaLabel,
1885
- dataTestId,
1886
- tooltipPlacement = "top",
1603
+ defaultValue = menuItems[0],
1604
+ menuTitle,
1605
+ disabled,
1606
+ icon,
1607
+ label,
1608
+ buttonSize,
1609
+ buttonColor = "primary",
1610
+ dense = false,
1611
+ extended = false,
1612
+ "aria-label": ariaLabel,
1613
+ responsive,
1614
+ tooltipLabel,
1615
+ tooltipPlacement,
1616
+ slotProps,
1617
+ MenuListProps,
1887
1618
  ...props
1888
- }, ref) => {
1889
- const intl = useIntl();
1890
- const intlConfig = useImperativeIntl(intl);
1891
- const [open, setOpen] = useState(false);
1892
- const { copy } = useCopyValue(copyText, copiedText);
1893
- const handleClick = (e) => {
1894
- e.preventDefault();
1895
- copy(value).then(() => {
1896
- onCopied == null ? void 0 : onCopied();
1897
- setOpen(true);
1898
- }).catch(console.error);
1619
+ }, ref) {
1620
+ const [selected_, setSelected] = useState(defaultValue || void 0);
1621
+ const [anchorEl, setAnchorEl] = useState(null);
1622
+ const isOpen = !!anchorEl;
1623
+ const selected = value ?? selected_;
1624
+ const isTablet = useMediaQuery((theme) => theme.breakpoints.down("lg"));
1625
+ const isIcon = Boolean(icon) && (!responsive || isTablet);
1626
+ const menuLabel = label || (selected == null ? void 0 : selected.alternativeLabel) || (selected == null ? void 0 : selected.label) || "Select an option";
1627
+ const [buttonId] = useState(() => `filter-dropdown-button-${uniqueId()}`);
1628
+ const [menuId] = useState(() => `filter-dropdown-menu-${uniqueId()}`);
1629
+ const handleOpen = (event) => {
1630
+ setAnchorEl(event.currentTarget);
1631
+ };
1632
+ const handleClose = () => {
1633
+ setAnchorEl(null);
1634
+ };
1635
+ const handleChange = (item, event) => {
1636
+ setSelected(item);
1637
+ onClickItem(item, event);
1638
+ handleClose();
1639
+ };
1640
+ const commonButtonProps = {
1641
+ onClick: handleOpen,
1642
+ disabled,
1643
+ size: buttonSize,
1644
+ color: "default",
1645
+ "aria-label": ariaLabel,
1646
+ id: buttonId,
1647
+ "aria-controls": isOpen ? menuId : void 0,
1648
+ "aria-haspopup": !disabled,
1649
+ "aria-expanded": isOpen
1899
1650
  };
1900
1651
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1901
- /* @__PURE__ */ jsx(
1902
- Tooltip,
1652
+ /* @__PURE__ */ jsx(Tooltip, { title: tooltipLabel, placement: tooltipPlacement, children: /* @__PURE__ */ jsx(ButtonWrapper, { isOpen, buttonColor, ref, children: isIcon ? /* @__PURE__ */ jsx(IconButton$1, { ...commonButtonProps, icon }) : /* @__PURE__ */ jsx(
1653
+ Button,
1903
1654
  {
1904
- title: intlConfig.formatMessage({ id: copyText }),
1905
- leaveDelay: 0,
1906
- placement: tooltipPlacement,
1907
- children: /* @__PURE__ */ jsxs(
1908
- Box,
1909
- {
1910
- ...props,
1911
- sx: { cursor: disabled ? void 0 : "pointer" },
1912
- onClick: handleClick,
1913
- "data-name": "copiable",
1914
- ref,
1915
- children: [
1916
- children,
1917
- button && /* @__PURE__ */ jsx(
1918
- IconButton$1,
1919
- {
1920
- ...buttonProps,
1921
- disabled,
1922
- icon: /* @__PURE__ */ jsx(ContentCopyOutlined, {}),
1923
- "data-testid": dataTestId,
1924
- "aria-label": ariaLabel || buttonLabel,
1925
- sx: {
1926
- display: "flex"
1927
- }
1928
- }
1929
- )
1930
- ]
1931
- }
1932
- )
1655
+ ...commonButtonProps,
1656
+ endIcon: isOpen ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}),
1657
+ children: menuLabel
1933
1658
  }
1934
- ),
1935
- /* @__PURE__ */ jsx(
1936
- Snackbar,
1659
+ ) }) }),
1660
+ /* @__PURE__ */ jsxs(
1661
+ Menu$1,
1937
1662
  {
1938
- open,
1939
- autoWidth: true,
1940
- closeable: false,
1941
- autoHideDuration: 4e3,
1942
- onClose: () => setOpen(false),
1943
- children: intlConfig.formatMessage({ id: copiedText })
1663
+ id: menuId,
1664
+ transformOrigin: { vertical: "top", horizontal: "right" },
1665
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
1666
+ ...props,
1667
+ anchorEl,
1668
+ open: isOpen,
1669
+ onClose: handleClose,
1670
+ keepMounted: true,
1671
+ slotProps: {
1672
+ ...slotProps,
1673
+ paper: {
1674
+ "data-name": "filter-dropdown",
1675
+ "data-dense": dense,
1676
+ ...slotProps == null ? void 0 : slotProps.paper
1677
+ }
1678
+ },
1679
+ MenuListProps: {
1680
+ "aria-labelledby": buttonId,
1681
+ autoFocus: true,
1682
+ // To allow keyboard navigation
1683
+ ...MenuListProps
1684
+ },
1685
+ children: [
1686
+ menuTitle && /* @__PURE__ */ jsx(MenuItem, { subtitle: true, children: menuTitle }),
1687
+ menuItems.map((item) => {
1688
+ const { id } = item;
1689
+ return /* @__PURE__ */ jsx(
1690
+ FilterDropdownMenuItem,
1691
+ {
1692
+ item,
1693
+ selectedValue: selected,
1694
+ dense,
1695
+ extended,
1696
+ onItemChange: handleChange
1697
+ },
1698
+ id
1699
+ );
1700
+ })
1701
+ ]
1944
1702
  }
1945
1703
  )
1946
1704
  ] });
1947
- };
1948
- const CopiableComponent = forwardRef(_CopiableComponent);
1949
- async function copyString(value) {
1950
- return await navigator.clipboard.writeText(value);
1951
1705
  }
1952
- const useCopyValue = (msg = "c4r.button.copy", copiedMsg = "c4r.notifications.copiedToClipboard") => {
1953
- const [message, setMessage] = useState(msg);
1954
- const copy = async (text) => {
1955
- await copyString(text);
1956
- setMessage(copiedMsg);
1957
- setTimeout(() => setMessage(msg), 1e3);
1958
- };
1959
- return {
1960
- message,
1961
- copy
1962
- };
1963
- };
1706
+ const FilterDropdown = forwardRef(
1707
+ _FilterDropdown
1708
+ );
1964
1709
  const AccordionContainer = styled("div", {
1965
1710
  shouldForwardProp: (prop) => prop !== "variant"
1966
1711
  })(({ variant, theme }) => ({
@@ -2314,71 +2059,610 @@ const TagRoot = styled("div", {
2314
2059
  }
2315
2060
  }
2316
2061
  };
2317
- });
2318
- const TagIcon = styled("div")(({ theme }) => ({
2062
+ });
2063
+ const TagIcon = styled("div")(({ theme }) => ({
2064
+ display: "flex",
2065
+ justifyContent: "center",
2066
+ alignItems: "center",
2067
+ "& svg": {
2068
+ width: theme.spacing(ICON_SIZE_SMALL),
2069
+ height: theme.spacing(ICON_SIZE_SMALL),
2070
+ "& g": {
2071
+ fill: "currentColor"
2072
+ }
2073
+ }
2074
+ }));
2075
+ const TagLabel = styled("div", {
2076
+ shouldForwardProp: (prop) => !["type"].includes(prop)
2077
+ })(({ type, theme }) => ({
2078
+ display: "flex",
2079
+ alignItems: "center",
2080
+ paddingTop: type === "code" ? theme.spacing(0.25) : void 0
2081
+ }));
2082
+ function _Tag({
2083
+ label,
2084
+ color = "primary",
2085
+ variant = "filled",
2086
+ icon,
2087
+ type = "default",
2088
+ typographyProps,
2089
+ noWrap = true,
2090
+ disabled,
2091
+ ...otherProps
2092
+ }, ref) {
2093
+ const typeCode = type === "code";
2094
+ return /* @__PURE__ */ jsxs(
2095
+ TagRoot,
2096
+ {
2097
+ ref,
2098
+ className: "CartoTag-root",
2099
+ color,
2100
+ variant,
2101
+ disabled,
2102
+ "aria-disabled": disabled,
2103
+ "data-color": color,
2104
+ "data-variant": variant,
2105
+ "data-type": type,
2106
+ "data-name": "tag",
2107
+ ...otherProps,
2108
+ children: [
2109
+ icon && /* @__PURE__ */ jsx(TagIcon, { children: icon }),
2110
+ /* @__PURE__ */ jsx(TagLabel, { type, children: /* @__PURE__ */ jsx(
2111
+ Typography,
2112
+ {
2113
+ component: "span",
2114
+ color: "inherit",
2115
+ variant: typeCode ? "code3" : "caption",
2116
+ weight: typeCode ? "strong" : "medium",
2117
+ noWrap,
2118
+ ...typographyProps,
2119
+ children: label
2120
+ }
2121
+ ) })
2122
+ ]
2123
+ }
2124
+ );
2125
+ }
2126
+ const Tag = forwardRef(_Tag);
2127
+ const _CopiableComponent = ({
2128
+ children,
2129
+ disabled,
2130
+ value,
2131
+ onCopied,
2132
+ copyText,
2133
+ copiedText,
2134
+ button,
2135
+ buttonLabel,
2136
+ buttonProps,
2137
+ ariaLabel,
2138
+ dataTestId,
2139
+ tooltipPlacement = "top",
2140
+ ...props
2141
+ }, ref) => {
2142
+ const [open, setOpen] = useState(false);
2143
+ const intl = useIntl();
2144
+ const intlConfig = useImperativeIntl(intl);
2145
+ const copyTooltipText = copyText || intlConfig.formatMessage({ id: "c4r.button.copy" });
2146
+ const copySuccessMessage = copiedText || intlConfig.formatMessage({
2147
+ id: "c4r.notifications.copiedToClipboard"
2148
+ });
2149
+ const { copy } = useCopyValue(copyTooltipText, copySuccessMessage);
2150
+ const handleClick = (e) => {
2151
+ e.preventDefault();
2152
+ copy(value).then(() => {
2153
+ onCopied == null ? void 0 : onCopied();
2154
+ setOpen(true);
2155
+ }).catch(console.error);
2156
+ };
2157
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2158
+ /* @__PURE__ */ jsx(
2159
+ Tooltip,
2160
+ {
2161
+ title: copyTooltipText,
2162
+ leaveDelay: 0,
2163
+ placement: tooltipPlacement,
2164
+ children: /* @__PURE__ */ jsxs(
2165
+ Box,
2166
+ {
2167
+ ...props,
2168
+ sx: { cursor: disabled ? void 0 : "pointer" },
2169
+ onClick: handleClick,
2170
+ "data-name": "copiable",
2171
+ ref,
2172
+ children: [
2173
+ children,
2174
+ button && /* @__PURE__ */ jsx(
2175
+ IconButton$1,
2176
+ {
2177
+ ...buttonProps,
2178
+ disabled,
2179
+ icon: /* @__PURE__ */ jsx(ContentCopyOutlined, {}),
2180
+ "data-testid": dataTestId,
2181
+ "aria-label": ariaLabel || buttonLabel || copyTooltipText,
2182
+ sx: {
2183
+ display: "flex"
2184
+ }
2185
+ }
2186
+ )
2187
+ ]
2188
+ }
2189
+ )
2190
+ }
2191
+ ),
2192
+ /* @__PURE__ */ jsx(
2193
+ Snackbar,
2194
+ {
2195
+ open,
2196
+ autoWidth: true,
2197
+ closeable: false,
2198
+ autoHideDuration: 4e3,
2199
+ onClose: () => setOpen(false),
2200
+ children: copySuccessMessage
2201
+ }
2202
+ )
2203
+ ] });
2204
+ };
2205
+ const CopiableComponent = forwardRef(_CopiableComponent);
2206
+ const StyledTextField = styled(TextField, {
2207
+ shouldForwardProp: (prop) => !["isInputFocused"].includes(prop)
2208
+ })(({ isInputFocused }) => ({
2209
+ "& input": {
2210
+ pointerEvents: isInputFocused ? "auto" : "none"
2211
+ // Disable pointer events when not focused https://issues.chromium.org/issues/41245282
2212
+ }
2213
+ }));
2214
+ const AdornmentWrapper = styled(Box, {
2215
+ shouldForwardProp: (prop) => !["size", "variant"].includes(prop)
2216
+ })(({ variant, size, theme }) => ({
2217
+ width: theme.spacing(3),
2218
+ ...variant === "standard" ? {
2219
+ marginLeft: theme.spacing(-0.25)
2220
+ } : {
2221
+ marginRight: theme.spacing(-1)
2222
+ },
2223
+ ...size === "medium" && {
2224
+ width: theme.spacing(4),
2225
+ ...variant === "standard" ? {
2226
+ marginLeft: theme.spacing(-0.5)
2227
+ } : {
2228
+ marginLeft: theme.spacing(1)
2229
+ }
2230
+ }
2231
+ }));
2232
+ function _CopiableInputText({
2233
+ value,
2234
+ variant,
2235
+ InputProps,
2236
+ extraEndAdornment,
2237
+ onCopied,
2238
+ password,
2239
+ size = "small",
2240
+ onFocus,
2241
+ onBlur,
2242
+ ...rest
2243
+ }, ref) {
2244
+ const intl = useIntl();
2245
+ const intlConfig = useImperativeIntl(intl);
2246
+ const [showText, setShowText] = useState(false);
2247
+ const [isInputFocused, setIsInputFocused] = useState(false);
2248
+ const inputType = !password ? "text" : showText ? "text" : "password";
2249
+ const showTextLabel = intlConfig.formatMessage({
2250
+ id: showText ? "c4r.button.hide" : "c4r.button.show"
2251
+ });
2252
+ const handleFocus = (event) => {
2253
+ setIsInputFocused(true);
2254
+ onFocus == null ? void 0 : onFocus(event);
2255
+ };
2256
+ const handleBlur = (event) => {
2257
+ setIsInputFocused(false);
2258
+ onBlur == null ? void 0 : onBlur(event);
2259
+ };
2260
+ const passwordAdornment = /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
2261
+ IconButton$1,
2262
+ {
2263
+ edge: variant !== "standard" ? "end" : void 0,
2264
+ onClick: () => setShowText(!showText),
2265
+ size,
2266
+ icon: showText ? /* @__PURE__ */ jsx(VisibilityOutlined, {}) : /* @__PURE__ */ jsx(VisibilityOffOutlined, {}),
2267
+ tooltip: showTextLabel,
2268
+ "aria-label": showTextLabel
2269
+ }
2270
+ ) });
2271
+ return /* @__PURE__ */ jsx(
2272
+ StyledTextField,
2273
+ {
2274
+ ...rest,
2275
+ isInputFocused,
2276
+ size,
2277
+ value,
2278
+ variant,
2279
+ InputProps: {
2280
+ readOnly: true,
2281
+ onFocus: handleFocus,
2282
+ onBlur: handleBlur,
2283
+ endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
2284
+ password ? passwordAdornment : extraEndAdornment,
2285
+ /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(AdornmentWrapper, { size, variant, children: /* @__PURE__ */ jsx(
2286
+ CopiableComponent,
2287
+ {
2288
+ value,
2289
+ onCopied,
2290
+ button: true,
2291
+ buttonProps: {
2292
+ size
2293
+ }
2294
+ }
2295
+ ) }) })
2296
+ ] }),
2297
+ ...variant === "filled" && {
2298
+ disableUnderline: true
2299
+ },
2300
+ ...InputProps
2301
+ },
2302
+ type: inputType,
2303
+ "data-name": "copiable-input-text",
2304
+ ref
2305
+ }
2306
+ );
2307
+ }
2308
+ const CopiableInputText = forwardRef(_CopiableInputText);
2309
+ async function copyString(value) {
2310
+ return await navigator.clipboard.writeText(value);
2311
+ }
2312
+ const useCopyValue = (msg = "c4r.button.copy", copiedMsg = "c4r.notifications.copiedToClipboard") => {
2313
+ const [message, setMessage] = useState(msg);
2314
+ const copy = async (text) => {
2315
+ await copyString(text);
2316
+ setMessage(copiedMsg);
2317
+ setTimeout(() => setMessage(msg), 1e3);
2318
+ };
2319
+ return {
2320
+ message,
2321
+ copy
2322
+ };
2323
+ };
2324
+ const IndicatorIcon = styled(Box)({
2325
+ position: "absolute",
2326
+ top: 0,
2327
+ left: 0,
2328
+ right: 0,
2329
+ bottom: 0,
2330
+ display: "flex",
2331
+ alignItems: "center",
2332
+ justifyContent: "center"
2333
+ });
2334
+ const HiddenText = styled(Box)({
2335
+ visibility: "hidden",
2336
+ pointerEvents: "none"
2337
+ });
2338
+ function _Button({
2339
+ children,
2340
+ loading,
2341
+ disabled,
2342
+ startIcon,
2343
+ endIcon,
2344
+ loadingPosition,
2345
+ external,
2346
+ showExternalIcon = true,
2347
+ "aria-describedby": ariaDescribedby,
2348
+ ...otherProps
2349
+ }, ref) {
2350
+ const intl = useIntl();
2351
+ const intlConfig = useImperativeIntl(intl);
2352
+ const defaultIconLoader = /* @__PURE__ */ jsx(CircularProgress, { size: 18, color: "inherit" });
2353
+ const isDefaultLoading = loading && loadingPosition === void 0;
2354
+ const isExternalLink = otherProps.href && external;
2355
+ const renderContent = () => {
2356
+ if (isDefaultLoading) {
2357
+ return /* @__PURE__ */ jsxs(Box, { sx: { position: "relative" }, children: [
2358
+ /* @__PURE__ */ jsx(IndicatorIcon, { children: defaultIconLoader }),
2359
+ /* @__PURE__ */ jsx(HiddenText, { children })
2360
+ ] });
2361
+ }
2362
+ if (isExternalLink) {
2363
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2364
+ children,
2365
+ /* @__PURE__ */ jsx(ScreenReaderOnly, { id: "external-hint", children: `(${intlConfig.formatMessage({
2366
+ id: "c4r.button.opensInNewTab"
2367
+ })})` })
2368
+ ] });
2369
+ }
2370
+ return children;
2371
+ };
2372
+ const getIconForPosition = (position) => {
2373
+ if (isDefaultLoading) {
2374
+ return void 0;
2375
+ }
2376
+ if (loading && loadingPosition !== void 0) {
2377
+ if (loadingPosition === position) {
2378
+ return defaultIconLoader;
2379
+ }
2380
+ return void 0;
2381
+ }
2382
+ if (position === "start") {
2383
+ return startIcon;
2384
+ } else {
2385
+ return endIcon || (isExternalLink && showExternalIcon ? /* @__PURE__ */ jsx(OpenInNewOutlined, {}) : void 0);
2386
+ }
2387
+ };
2388
+ return /* @__PURE__ */ jsx(
2389
+ Button$1,
2390
+ {
2391
+ disabled: loading || disabled,
2392
+ startIcon: getIconForPosition("start"),
2393
+ endIcon: getIconForPosition("end"),
2394
+ ...otherProps,
2395
+ role: otherProps.href ? "link" : "button",
2396
+ ...isExternalLink && {
2397
+ target: "_blank",
2398
+ rel: "noopener noreferrer"
2399
+ },
2400
+ ref,
2401
+ "aria-describedby": isExternalLink ? "external-hint" : ariaDescribedby,
2402
+ children: /* @__PURE__ */ jsx(Typography, { variant: "inherit", color: "inherit", noWrap: true, component: "span", children: renderContent() })
2403
+ }
2404
+ );
2405
+ }
2406
+ const Button = forwardRef(_Button);
2407
+ const ButtonGroup = styled(ButtonGroup$1)(({ theme, size }) => ({
2408
+ "& .MuiButton-root:last-child": {
2409
+ padding: 0,
2410
+ minWidth: size === "small" ? theme.spacing(3) : size === "large" ? theme.spacing(6) : theme.spacing(4)
2411
+ }
2412
+ }));
2413
+ function SplitButton({
2414
+ options,
2415
+ disabled,
2416
+ loading,
2417
+ loadingPosition,
2418
+ onClick,
2419
+ variant,
2420
+ size,
2421
+ color,
2422
+ ...otherProps
2423
+ }) {
2424
+ var _a;
2425
+ const [open, setOpen] = useState(false);
2426
+ const anchorRef = useRef(null);
2427
+ const [selectedIndex, setSelectedIndex] = useState(0);
2428
+ const handleClick = () => {
2429
+ onClick(options[selectedIndex]);
2430
+ };
2431
+ const handleMenuItemClick = (_, index) => {
2432
+ setSelectedIndex(index);
2433
+ setOpen(false);
2434
+ };
2435
+ const handleToggle = () => {
2436
+ setOpen((prevOpen) => !prevOpen);
2437
+ };
2438
+ const handleClose = (event) => {
2439
+ var _a2;
2440
+ if ((_a2 = anchorRef.current) == null ? void 0 : _a2.contains(event.target)) {
2441
+ return;
2442
+ }
2443
+ setOpen(false);
2444
+ };
2445
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2446
+ /* @__PURE__ */ jsxs(
2447
+ ButtonGroup,
2448
+ {
2449
+ "data-name": "split-button",
2450
+ ref: anchorRef,
2451
+ variant,
2452
+ size,
2453
+ color,
2454
+ ...otherProps,
2455
+ children: [
2456
+ /* @__PURE__ */ jsx(
2457
+ Button,
2458
+ {
2459
+ disabled,
2460
+ loading,
2461
+ loadingPosition,
2462
+ onClick: handleClick,
2463
+ children: (_a = options[selectedIndex]) == null ? void 0 : _a.label
2464
+ }
2465
+ ),
2466
+ /* @__PURE__ */ jsx(Button, { disabled: loading || disabled, onClick: handleToggle, children: open ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}) })
2467
+ ]
2468
+ }
2469
+ ),
2470
+ /* @__PURE__ */ jsx(
2471
+ Popper,
2472
+ {
2473
+ sx: { zIndex: 1 },
2474
+ open,
2475
+ anchorEl: anchorRef.current,
2476
+ role: void 0,
2477
+ transition: true,
2478
+ disablePortal: true,
2479
+ placement: "bottom-end",
2480
+ children: ({ TransitionProps, placement }) => /* @__PURE__ */ jsx(
2481
+ Grow,
2482
+ {
2483
+ ...TransitionProps,
2484
+ style: {
2485
+ transformOrigin: placement === "bottom" ? "center top" : "center bottom"
2486
+ },
2487
+ children: /* @__PURE__ */ jsx(Paper, { elevation: 8, children: /* @__PURE__ */ jsx(ClickAwayListener, { onClickAway: handleClose, children: /* @__PURE__ */ jsx(MenuList$1, { autoFocusItem: true, sx: { paddingY: 1 }, children: options.map((option, index) => /* @__PURE__ */ jsx(
2488
+ MenuItem$1,
2489
+ {
2490
+ disabled: option.disabled,
2491
+ selected: index === selectedIndex,
2492
+ onClick: (event) => handleMenuItemClick(event, index),
2493
+ children: option.label
2494
+ },
2495
+ option.label
2496
+ )) }) }) })
2497
+ }
2498
+ )
2499
+ }
2500
+ )
2501
+ ] });
2502
+ }
2503
+ const Root$5 = styled(Box)(({ theme }) => ({
2319
2504
  display: "flex",
2320
- justifyContent: "center",
2321
2505
  alignItems: "center",
2322
- "& svg": {
2323
- width: theme.spacing(ICON_SIZE_SMALL),
2324
- height: theme.spacing(ICON_SIZE_SMALL),
2325
- "& g": {
2326
- fill: "currentColor"
2327
- }
2506
+ gap: theme.spacing(0.5)
2507
+ }));
2508
+ const Indicator = styled(Typography)(({ theme }) => ({
2509
+ ".Mui-disabled &": {
2510
+ color: theme.palette.text.disabled
2328
2511
  }
2329
2512
  }));
2330
- const TagLabel = styled("div", {
2331
- shouldForwardProp: (prop) => !["type"].includes(prop)
2332
- })(({ type, theme }) => ({
2513
+ const Icon = styled(Box)(({ theme }) => ({
2333
2514
  display: "flex",
2334
- alignItems: "center",
2335
- paddingTop: type === "code" ? theme.spacing(0.25) : void 0
2515
+ svg: {
2516
+ width: ICON_SIZE_SMALL,
2517
+ height: ICON_SIZE_SMALL,
2518
+ fontSize: ICON_SIZE_SMALL,
2519
+ path: {
2520
+ fill: theme.palette.text.secondary,
2521
+ ".Mui-disabled &": {
2522
+ fill: theme.palette.text.disabled
2523
+ }
2524
+ }
2525
+ }
2336
2526
  }));
2337
- function _Tag({
2527
+ function LabelWithIndicator({
2338
2528
  label,
2339
- color = "primary",
2340
- variant = "filled",
2529
+ type,
2341
2530
  icon,
2342
- type = "default",
2343
- typographyProps,
2344
- noWrap = true,
2345
- disabled,
2346
- ...otherProps
2347
- }, ref) {
2348
- const typeCode = type === "code";
2349
- return /* @__PURE__ */ jsxs(
2350
- TagRoot,
2531
+ inheritSize
2532
+ }) {
2533
+ return /* @__PURE__ */ jsxs(Root$5, { children: [
2534
+ label,
2535
+ type && /* @__PURE__ */ jsx(
2536
+ Indicator,
2537
+ {
2538
+ component: "span",
2539
+ variant: inheritSize ? "inherit" : "caption",
2540
+ color: "textSecondary",
2541
+ weight: "regular",
2542
+ children: type === "required" ? "(required)" : "(optional)"
2543
+ }
2544
+ ),
2545
+ icon && /* @__PURE__ */ jsx(Icon, { children: icon })
2546
+ ] });
2547
+ }
2548
+ function _PasswordField({ InputProps, size = "small", ...otherProps }, ref) {
2549
+ const intl = useIntl();
2550
+ const intlConfig = useImperativeIntl(intl);
2551
+ const [showPassword, setShowPassword] = useState(false);
2552
+ const handleClickShowPassword = () => setShowPassword(!showPassword);
2553
+ return /* @__PURE__ */ jsx(
2554
+ TextField,
2351
2555
  {
2352
- ref,
2353
- className: "CartoTag-root",
2354
- color,
2355
- variant,
2356
- disabled,
2357
- "aria-disabled": disabled,
2358
- "data-color": color,
2359
- "data-variant": variant,
2360
- "data-type": type,
2361
- "data-name": "tag",
2362
2556
  ...otherProps,
2363
- children: [
2364
- icon && /* @__PURE__ */ jsx(TagIcon, { children: icon }),
2365
- /* @__PURE__ */ jsx(TagLabel, { type, children: /* @__PURE__ */ jsx(
2366
- Typography,
2557
+ ref,
2558
+ type: showPassword ? "text" : "password",
2559
+ size,
2560
+ InputProps: {
2561
+ ...InputProps,
2562
+ endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(IconButton, { size, onClick: handleClickShowPassword, children: /* @__PURE__ */ jsx(
2563
+ Tooltip,
2367
2564
  {
2368
- component: "span",
2369
- color: "inherit",
2370
- variant: typeCode ? "code3" : "caption",
2371
- weight: typeCode ? "strong" : "medium",
2372
- noWrap,
2373
- ...typographyProps,
2374
- children: label
2565
+ title: intlConfig.formatMessage({
2566
+ id: `c4r.form.${showPassword ? "hidePassword" : "showPassword"}`
2567
+ }),
2568
+ children: showPassword ? /* @__PURE__ */ jsx(VisibilityOffOutlined, {}) : /* @__PURE__ */ jsx(VisibilityOutlined, {})
2375
2569
  }
2376
- ) })
2377
- ]
2570
+ ) }) })
2571
+ }
2572
+ }
2573
+ );
2574
+ }
2575
+ const PasswordField = forwardRef(_PasswordField);
2576
+ const StyledToggleButtonGroup = styled(ToggleButtonGroup$1, {
2577
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "backgroundColor"
2578
+ })(({ variant, backgroundColor, theme }) => ({
2579
+ // Variants
2580
+ ...variant === "contained" && {
2581
+ boxShadow: "none"
2582
+ },
2583
+ ...variant === "unbounded" && {
2584
+ boxShadow: "none",
2585
+ borderRadius: theme.spacing(0.5),
2586
+ "& .MuiDivider-root": {
2587
+ height: theme.spacing(4),
2588
+ "&.MuiToggleButtonGroup-groupedHorizontal": {
2589
+ height: theme.spacing(4)
2590
+ },
2591
+ "&.MuiToggleButtonGroup-groupedVertical": {
2592
+ height: "auto",
2593
+ width: theme.spacing(4),
2594
+ margin: `${theme.spacing(0.5, 0, 1)} !important`,
2595
+ borderRadius: "0 !important"
2596
+ }
2597
+ },
2598
+ "& .MuiToggleButton-sizeSmall": {
2599
+ margin: 0,
2600
+ "&.MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
2601
+ margin: 0
2602
+ },
2603
+ "& + .MuiDivider-root.MuiToggleButtonGroup-groupedHorizontal": {
2604
+ height: theme.spacing(3)
2605
+ },
2606
+ "& + .MuiDivider-root.MuiToggleButtonGroup-groupedVertical": {
2607
+ height: "auto",
2608
+ width: theme.spacing(3)
2609
+ }
2610
+ },
2611
+ ".MuiToggleButtonGroup-grouped:not(.MuiDivider-root)": {
2612
+ margin: 0,
2613
+ "&:first-of-type": {
2614
+ marginLeft: 0
2615
+ },
2616
+ "&:not(:last-of-type)": {
2617
+ marginRight: theme.spacing(0.5)
2618
+ }
2619
+ },
2620
+ "&.MuiToggleButtonGroup-horizontal:not(.MuiDivider-root)": {
2621
+ ".MuiToggleButtonGroup-grouped": {
2622
+ margin: theme.spacing(0, 0.5)
2623
+ }
2624
+ },
2625
+ "&.MuiToggleButtonGroup-vertical:not(.MuiDivider-root)": {
2626
+ ".MuiToggleButtonGroup-grouped": {
2627
+ margin: theme.spacing(0, 0, 0.5),
2628
+ "&:not(:last-of-type)": {
2629
+ marginRight: 0
2630
+ },
2631
+ "&:last-of-type": {
2632
+ marginBottom: 0
2633
+ }
2634
+ }
2635
+ }
2636
+ },
2637
+ // Colors
2638
+ ...backgroundColor === "primary" && {
2639
+ backgroundColor: theme.palette.background.paper
2640
+ },
2641
+ ...backgroundColor === "secondary" && {
2642
+ backgroundColor: theme.palette.background.default
2643
+ },
2644
+ ...backgroundColor === "transparent" && {
2645
+ backgroundColor: "transparent"
2646
+ }
2647
+ }));
2648
+ function ToggleButtonGroup({
2649
+ children,
2650
+ variant = "floating",
2651
+ backgroundColor,
2652
+ ...rest
2653
+ }) {
2654
+ const isUnbounded = variant === "unbounded";
2655
+ const defaultColor = isUnbounded ? "transparent" : "primary";
2656
+ return /* @__PURE__ */ jsx(
2657
+ StyledToggleButtonGroup,
2658
+ {
2659
+ ...rest,
2660
+ variant,
2661
+ backgroundColor: backgroundColor ?? defaultColor,
2662
+ children
2378
2663
  }
2379
2664
  );
2380
2665
  }
2381
- const Tag = forwardRef(_Tag);
2382
2666
  const Menu = styled("div")(({ theme }) => ({
2383
2667
  display: "flex",
2384
2668
  alignItems: "center",
@@ -3450,11 +3734,11 @@ function CodeAreaHeader({
3450
3734
  transformOrigin: { vertical: "top", horizontal: "right" },
3451
3735
  anchorOrigin: { vertical: "bottom", horizontal: "right" },
3452
3736
  children: [
3453
- /* @__PURE__ */ jsxs(MenuItem$1, { onClick: handleCopy, disabled, id: "copy", children: [
3737
+ /* @__PURE__ */ jsxs(MenuItem, { onClick: handleCopy, disabled, id: "copy", children: [
3454
3738
  /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(ContentCopyOutlined, {}) }),
3455
3739
  /* @__PURE__ */ jsx(ListItemText, { children: intlConfig.formatMessage({ id: `c4r.button.copy` }) })
3456
3740
  ] }),
3457
- /* @__PURE__ */ jsxs(MenuItem$1, { onClick: onClickExpand, disabled, id: "expand", children: [
3741
+ /* @__PURE__ */ jsxs(MenuItem, { onClick: onClickExpand, disabled, id: "expand", children: [
3458
3742
  /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(OpenDiagonallyRight, {}) }),
3459
3743
  /* @__PURE__ */ jsx(ListItemText, { children: intlConfig.formatMessage({ id: `c4r.button.expand` }) })
3460
3744
  ] })
@@ -5109,6 +5393,7 @@ export {
5109
5393
  CodeAreaInput,
5110
5394
  CodeAreaMarkTextPattern,
5111
5395
  CopiableComponent,
5396
+ CopiableInputText,
5112
5397
  CreatableAutocomplete,
5113
5398
  DatePicker,
5114
5399
  DateRangePicker,
@@ -5123,11 +5408,13 @@ export {
5123
5408
  DialogHeader,
5124
5409
  DialogPaper,
5125
5410
  DialogStepper,
5411
+ FilterDropdown,
5412
+ FilterDropdownMenuItem,
5126
5413
  IconButton$1 as IconButton,
5127
5414
  LabelWithIndicator,
5128
5415
  L as Link,
5129
5416
  Menu$1 as Menu,
5130
- MenuItem$1 as MenuItem,
5417
+ MenuItem,
5131
5418
  MenuItemFilter,
5132
5419
  MenuList,
5133
5420
  MultipleAutocomplete,