@carto/meridian-ds 2.6.0-alpha-searchfield.1 → 2.6.1-alpha-searchfield.3

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 (70) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{Alert-C1VgP3N1.js → Alert-BN993lHa.js} +7 -4
  3. package/dist/{Alert-F8G9P271.cjs → Alert-CL9Y3l7D.cjs} +7 -4
  4. package/dist/components/index.cjs +223 -89
  5. package/dist/components/index.js +225 -91
  6. package/dist/custom-icons/index.cjs +640 -556
  7. package/dist/custom-icons/index.js +640 -556
  8. package/dist/theme/index.cjs +12 -2
  9. package/dist/theme/index.js +12 -2
  10. package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts +25 -0
  11. package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts.map +1 -1
  12. package/dist/types/components/Autocomplete/CreatableAutocomplete/useCreatableAutocomplete.d.ts.map +1 -1
  13. package/dist/types/components/Autocomplete/MultipleAutocomplete/useMultipleAutocomplete.d.ts.map +1 -1
  14. package/dist/types/components/Autocomplete/types.d.ts +4 -1
  15. package/dist/types/components/Autocomplete/types.d.ts.map +1 -1
  16. package/dist/types/components/CopiableComponent/CopiableComponent.d.ts.map +1 -1
  17. package/dist/types/components/CopiableComponent/CopiableComponent.stories.d.ts +3 -0
  18. package/dist/types/components/CopiableComponent/CopiableComponent.stories.d.ts.map +1 -1
  19. package/dist/types/components/CopiableComponent/types.d.ts +8 -1
  20. package/dist/types/components/CopiableComponent/types.d.ts.map +1 -1
  21. package/dist/types/components/FilterDropdown/FilterDropdown.d.ts +1 -1
  22. package/dist/types/components/FilterDropdown/FilterDropdown.d.ts.map +1 -1
  23. package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts +48 -0
  24. package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts.map +1 -1
  25. package/dist/types/components/FilterDropdown/types.d.ts +8 -0
  26. package/dist/types/components/FilterDropdown/types.d.ts.map +1 -1
  27. package/dist/types/components/Menu/MenuItemFilter/MenuItemFilter.d.ts.map +1 -1
  28. package/dist/types/components/Menu/types.d.ts +1 -0
  29. package/dist/types/components/Menu/types.d.ts.map +1 -1
  30. package/dist/types/components/SearchField/SearchField.d.ts +1 -29
  31. package/dist/types/components/SearchField/SearchField.d.ts.map +1 -1
  32. package/dist/types/components/SearchField/SearchField.stories.d.ts +8 -0
  33. package/dist/types/components/SearchField/SearchField.stories.d.ts.map +1 -1
  34. package/dist/types/components/SearchField/SearchField.styled.d.ts +23 -0
  35. package/dist/types/components/SearchField/SearchField.styled.d.ts.map +1 -0
  36. package/dist/types/components/SearchField/SearchField.test.d.ts +2 -0
  37. package/dist/types/components/SearchField/SearchField.test.d.ts.map +1 -0
  38. package/dist/types/components/SearchField/index.d.ts +1 -1
  39. package/dist/types/components/SearchField/index.d.ts.map +1 -1
  40. package/dist/types/components/SearchField/types.d.ts +31 -0
  41. package/dist/types/components/SearchField/types.d.ts.map +1 -0
  42. package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
  43. package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts +22 -2
  44. package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts.map +1 -1
  45. package/dist/types/components/SelectField/types.d.ts +4 -0
  46. package/dist/types/components/SelectField/types.d.ts.map +1 -1
  47. package/dist/types/custom-icons/FoldersStackedOutlined.d.ts +4 -0
  48. package/dist/types/custom-icons/FoldersStackedOutlined.d.ts.map +1 -0
  49. package/dist/types/custom-icons/RedoAlt.d.ts +4 -0
  50. package/dist/types/custom-icons/RedoAlt.d.ts.map +1 -0
  51. package/dist/types/custom-icons/SelectFeature.d.ts.map +1 -1
  52. package/dist/types/custom-icons/UndoAlt.d.ts +4 -0
  53. package/dist/types/custom-icons/UndoAlt.d.ts.map +1 -0
  54. package/dist/types/custom-icons/index.d.ts +3 -0
  55. package/dist/types/custom-icons/index.d.ts.map +1 -1
  56. package/dist/types/theme/carto-theme.d.ts.map +1 -1
  57. package/dist/types/theme/components/layout.d.ts +3 -0
  58. package/dist/types/theme/components/layout.d.ts.map +1 -0
  59. package/dist/types/theme/components/navigation.d.ts.map +1 -1
  60. package/dist/types/utils/useTranslationWithFallback.d.ts +39 -0
  61. package/dist/types/utils/useTranslationWithFallback.d.ts.map +1 -0
  62. package/dist/types/utils/useTranslationWithFallback.test.d.ts +2 -0
  63. package/dist/types/utils/useTranslationWithFallback.test.d.ts.map +1 -0
  64. package/dist/widgets/index.cjs +1 -1
  65. package/dist/widgets/index.js +1 -1
  66. package/package.json +1 -1
  67. package/dist/types/utils/useTranslationFallback.d.ts +0 -20
  68. package/dist/types/utils/useTranslationFallback.d.ts.map +0 -1
  69. package/dist/types/utils/useTranslationFallback.test.d.ts +0 -2
  70. package/dist/types/utils/useTranslationFallback.test.d.ts.map +0 -1
@@ -1,9 +1,9 @@
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
- import { styled, Box, Button as Button$1, CircularProgress, Popper, Grow, Paper, ClickAwayListener, MenuList as MenuList$1, MenuItem, ButtonGroup as ButtonGroup$1, TextField, InputAdornment, Select, FormControl, InputLabel, FormHelperText, Link, Checkbox, IconButton as IconButton$1, ListItemText, Tooltip, ToggleButtonGroup as ToggleButtonGroup$1, Autocomplete as Autocomplete$1, Divider, ListItemIcon, createFilterOptions, alpha, useTheme, AppBar as AppBar$1, Toolbar, Dialog as Dialog$1, DialogTitle as DialogTitle$1, Chip, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Slide, Accordion, AccordionSummary, AccordionDetails, Avatar as Avatar$1, Menu as Menu$2, useMediaQuery, Snackbar as Snackbar$1, Portal, Fade } from "@mui/material";
3
+ import { styled, Box, Button as Button$1, CircularProgress, Popper, Grow, Paper, ClickAwayListener, MenuList as MenuList$1, MenuItem, ButtonGroup as ButtonGroup$1, TextField, InputAdornment, Select, FormControl, InputLabel, FormHelperText, Link, Checkbox, IconButton as IconButton$1, ListItemText, Tooltip, ToggleButtonGroup as ToggleButtonGroup$1, Autocomplete as Autocomplete$1, Divider, ListItemIcon, createFilterOptions, alpha, useTheme, AppBar as AppBar$1, Toolbar, Dialog as Dialog$1, DialogTitle as DialogTitle$1, Chip, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Slide, Accordion, AccordionSummary, AccordionDetails, Avatar as Avatar$1, Menu as Menu$2, useMediaQuery, Stack, Snackbar as Snackbar$1, Portal, Fade } from "@mui/material";
4
4
  import { OpenInNewOutlined, VisibilityOffOutlined, VisibilityOutlined, Cancel, ContentCopyOutlined, AddCircleOutlineOutlined, MenuOutlined, MoreVertOutlined, HelpOutline, ErrorOutline, CloseOutlined, Check, TodayOutlined } from "@mui/icons-material";
5
- import { u as useTranslationFallback, S as ScreenReaderOnly, A as Alert$1 } from "../Alert-C1VgP3N1.js";
6
- import { L } from "../Alert-C1VgP3N1.js";
5
+ import { u as useTranslationWithFallback, S as ScreenReaderOnly, A as Alert$1 } from "../Alert-BN993lHa.js";
6
+ import { L } from "../Alert-BN993lHa.js";
7
7
  import { T as Typography, c as ICON_SIZE_SMALL, u as useImperativeIntl, i as IconButton, f as MENU_ITEM_SIZE_DENSE, d as MENU_LIST_MAX_SIZE, h as MENU_ITEM_SIZE_EXTENDED, M as MENU_ITEM_SIZE_DEFAULT, A as APPBAR_SIZE, b as ICON_SIZE_MEDIUM, N as NOTIFICATION_DURATION_IN_MS, e as ellipsisStyles } from "../css-utils-hxI-qUxK.js";
8
8
  import { a } from "../css-utils-hxI-qUxK.js";
9
9
  import { A as ArrowDown } from "../ArrowDown-d6bxUL0F.js";
@@ -70,7 +70,7 @@ function _Button({
70
70
  "aria-describedby": ariaDescribedby,
71
71
  ...otherProps
72
72
  }, ref) {
73
- const screenReaderTextValue = useTranslationFallback(
73
+ const screenReaderTextValue = useTranslationWithFallback(
74
74
  "c4r.button.opensInNewTab",
75
75
  screenReaderText
76
76
  );
@@ -523,11 +523,14 @@ function _MenuItemFilter({
523
523
  areAnySelected,
524
524
  selectAll,
525
525
  selectAllDisabled,
526
+ selectAllText,
526
527
  "aria-label": ariaLabel,
527
528
  "data-testid": dataTestId
528
529
  }, ref) {
529
- const intl = useIntl();
530
- const intlConfig = useImperativeIntl(intl);
530
+ const selectAllLabel = useTranslationWithFallback(
531
+ "c4r.form.selectAll",
532
+ selectAllText
533
+ );
531
534
  return /* @__PURE__ */ jsx(
532
535
  StyledMenuItem$1,
533
536
  {
@@ -555,7 +558,7 @@ function _MenuItemFilter({
555
558
  disabled: selectAllDisabled
556
559
  }
557
560
  ),
558
- intlConfig.formatMessage({ id: "c4r.form.selectAll" })
561
+ selectAllLabel
559
562
  ]
560
563
  }
561
564
  )
@@ -602,6 +605,10 @@ function _MultipleSelectField({
602
605
  selectAllDisabled,
603
606
  tooltipPlacement,
604
607
  variant,
608
+ allSelectedText,
609
+ noneSelectedText,
610
+ selectedText,
611
+ selectAllText,
605
612
  ...props
606
613
  }, ref) {
607
614
  const {
@@ -618,11 +625,19 @@ function _MultipleSelectField({
618
625
  });
619
626
  const isSmall = size === "small";
620
627
  const paddingSize = isSmall || variant === "standard" ? 0 : 2;
621
- const intl = useIntl();
622
- const intlConfig = useImperativeIntl(intl);
623
- const counterText = `${currentOptions.length} ${intlConfig.formatMessage({
624
- id: "c4r.form.selected"
625
- })}`;
628
+ const allSelectedLabel = useTranslationWithFallback(
629
+ "c4r.form.allSelected",
630
+ allSelectedText
631
+ );
632
+ const noneSelectedLabel = useTranslationWithFallback(
633
+ "c4r.form.noneSelected",
634
+ noneSelectedText
635
+ );
636
+ const selectedLabel = useTranslationWithFallback(
637
+ "c4r.form.selected",
638
+ selectedText
639
+ );
640
+ const counterText = `${currentOptions.length} ${selectedLabel}`;
626
641
  const renderValue = useMemo(() => {
627
642
  if (areAllSelected) {
628
643
  return /* @__PURE__ */ jsx(
@@ -632,7 +647,7 @@ function _MultipleSelectField({
632
647
  variant: isSmall ? "body2" : "body1",
633
648
  color: "textPrimary",
634
649
  ml: paddingSize,
635
- children: intlConfig.formatMessage({ id: "c4r.form.allSelected" })
650
+ children: allSelectedLabel
636
651
  }
637
652
  );
638
653
  }
@@ -655,16 +670,17 @@ function _MultipleSelectField({
655
670
  variant: isSmall ? "body2" : "body1",
656
671
  color: "text.hint",
657
672
  ml: paddingSize,
658
- children: placeholder ?? intlConfig.formatMessage({ id: "c4r.form.noneSelected" })
673
+ children: placeholder ?? noneSelectedLabel
659
674
  }
660
675
  );
661
676
  }, [
662
677
  areAllSelected,
663
678
  areAnySelected,
679
+ allSelectedLabel,
664
680
  counterText,
665
681
  currentOptions,
666
- intlConfig,
667
682
  isSmall,
683
+ noneSelectedLabel,
668
684
  paddingSize,
669
685
  placeholder,
670
686
  showCounter
@@ -705,7 +721,8 @@ function _MultipleSelectField({
705
721
  areAllSelected,
706
722
  areAnySelected,
707
723
  selectAll,
708
- selectAllDisabled
724
+ selectAllDisabled,
725
+ selectAllText
709
726
  }
710
727
  )
711
728
  }
@@ -872,10 +889,13 @@ const _CopiableComponent = ({
872
889
  copiedText,
873
890
  button,
874
891
  buttonLabel,
892
+ buttonIcon,
875
893
  buttonProps,
876
894
  ariaLabel,
877
895
  dataTestId,
878
896
  tooltipPlacement = "top",
897
+ tooltipProps,
898
+ snackbarProps,
879
899
  ...props
880
900
  }, ref) => {
881
901
  const [open, setOpen] = useState(false);
@@ -893,6 +913,7 @@ const _CopiableComponent = ({
893
913
  setOpen(true);
894
914
  }).catch(console.error);
895
915
  };
916
+ const copyIcon = buttonIcon ?? /* @__PURE__ */ jsx(ContentCopyOutlined, {});
896
917
  return /* @__PURE__ */ jsxs(Fragment, { children: [
897
918
  /* @__PURE__ */ jsx(
898
919
  Tooltip,
@@ -900,6 +921,7 @@ const _CopiableComponent = ({
900
921
  title: copyTooltipText,
901
922
  leaveDelay: 0,
902
923
  placement: tooltipPlacement,
924
+ ...tooltipProps,
903
925
  children: /* @__PURE__ */ jsxs(
904
926
  Box,
905
927
  {
@@ -915,7 +937,7 @@ const _CopiableComponent = ({
915
937
  {
916
938
  ...buttonProps,
917
939
  disabled,
918
- icon: /* @__PURE__ */ jsx(ContentCopyOutlined, {}),
940
+ icon: copyIcon,
919
941
  "data-testid": dataTestId,
920
942
  "aria-label": ariaLabel || buttonLabel || copyTooltipText || intlConfig.formatMessage({ id: "c4r.button.copy" }),
921
943
  sx: {
@@ -931,10 +953,11 @@ const _CopiableComponent = ({
931
953
  /* @__PURE__ */ jsx(
932
954
  Snackbar,
933
955
  {
934
- open,
935
956
  autoWidth: true,
936
957
  closeable: false,
937
958
  autoHideDuration: 4e3,
959
+ ...snackbarProps,
960
+ open,
938
961
  onClose: () => setOpen(false),
939
962
  children: copySuccessMessage
940
963
  }
@@ -1274,10 +1297,12 @@ function useCreatableAutocomplete({
1274
1297
  newItemIcon,
1275
1298
  multiple
1276
1299
  }) {
1277
- const intl = useIntl();
1278
- const intlConfig = useImperativeIntl(intl);
1279
1300
  const filter = createFilterOptions();
1280
1301
  const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1302
+ const addLabel = useTranslationWithFallback(
1303
+ "c4r.form.add",
1304
+ typeof newItemLabel === "string" ? newItemLabel : void 0
1305
+ );
1281
1306
  const creatableFilterOptions = (options, params) => {
1282
1307
  const filtered = filter(
1283
1308
  options,
@@ -1291,10 +1316,8 @@ function useCreatableAutocomplete({
1291
1316
  let newItemText;
1292
1317
  if (typeof newItemLabel === "function") {
1293
1318
  newItemText = newItemLabel(inputValue);
1294
- } else if (newItemLabel) {
1295
- newItemText = `${newItemLabel} "${inputValue}"`;
1296
1319
  } else {
1297
- newItemText = `${intlConfig.formatMessage({ id: "c4r.form.add" })} "${inputValue}"`;
1320
+ newItemText = `${addLabel} "${inputValue}"`;
1298
1321
  }
1299
1322
  filtered.push({
1300
1323
  inputValue,
@@ -1339,14 +1362,18 @@ function useMultipleAutocomplete({
1339
1362
  counterText,
1340
1363
  allSelectedText
1341
1364
  }) {
1342
- const intl = useIntl();
1343
- const intlConfig = useImperativeIntl(intl);
1344
- const defaultCounterText = counterText || intlConfig.formatMessage({ id: "c4r.form.selected" });
1345
- const defaultAllSelectedText = allSelectedText || intlConfig.formatMessage({ id: "c4r.form.allSelected" });
1346
1365
  const [multipleValue, setMultipleValue] = useState(
1347
1366
  Array.isArray(value) ? value : value ? [value] : []
1348
1367
  );
1349
1368
  const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
1369
+ const defaultCounterText = useTranslationWithFallback(
1370
+ "c4r.form.selected",
1371
+ counterText
1372
+ );
1373
+ const defaultAllSelectedText = useTranslationWithFallback(
1374
+ "c4r.form.allSelected",
1375
+ allSelectedText
1376
+ );
1350
1377
  useEffect(() => {
1351
1378
  const newValue = Array.isArray(value) ? value : value ? [value] : [];
1352
1379
  setMultipleValue(newValue);
@@ -4853,6 +4880,9 @@ function _FilterDropdown({
4853
4880
  responsive,
4854
4881
  tooltipLabel,
4855
4882
  tooltipPlacement,
4883
+ tooltipProps,
4884
+ buttonProps,
4885
+ iconButtonProps,
4856
4886
  slotProps,
4857
4887
  MenuListProps,
4858
4888
  ...props
@@ -4890,14 +4920,30 @@ function _FilterDropdown({
4890
4920
  "data-color": buttonColor
4891
4921
  };
4892
4922
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4893
- /* @__PURE__ */ jsx(Tooltip, { title: tooltipLabel, placement: tooltipPlacement, children: /* @__PURE__ */ jsx(ButtonWrapper, { isOpen, buttonColor, ref, children: isIcon ? /* @__PURE__ */ jsx(IconButton, { ...commonButtonProps, icon }) : /* @__PURE__ */ jsx(
4894
- Button,
4923
+ /* @__PURE__ */ jsx(
4924
+ Tooltip,
4895
4925
  {
4896
- ...commonButtonProps,
4897
- endIcon: isOpen ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}),
4898
- children: menuLabel
4926
+ title: tooltipLabel,
4927
+ placement: tooltipPlacement,
4928
+ ...tooltipProps,
4929
+ children: /* @__PURE__ */ jsx(ButtonWrapper, { isOpen, buttonColor, ref, children: isIcon ? /* @__PURE__ */ jsx(
4930
+ IconButton,
4931
+ {
4932
+ ...commonButtonProps,
4933
+ icon,
4934
+ ...iconButtonProps
4935
+ }
4936
+ ) : /* @__PURE__ */ jsx(
4937
+ Button,
4938
+ {
4939
+ ...commonButtonProps,
4940
+ endIcon: isOpen ? /* @__PURE__ */ jsx(ArrowUp, {}) : /* @__PURE__ */ jsx(ArrowDown, {}),
4941
+ ...buttonProps,
4942
+ children: menuLabel
4943
+ }
4944
+ ) })
4899
4945
  }
4900
- ) }) }),
4946
+ ),
4901
4947
  /* @__PURE__ */ jsxs(
4902
4948
  Menu,
4903
4949
  {
@@ -4960,64 +5006,115 @@ const SearchIcon = styled(Search, {
4960
5006
  }
4961
5007
  })
4962
5008
  );
4963
- const CancelIcon = styled(Cancel)(({ theme }) => ({
4964
- fill: theme.palette.text.hint,
4965
- cursor: "pointer"
5009
+ const CancelSearchIcon = styled(Cancel)(({ theme }) => ({
5010
+ color: `${theme.palette.text.hint} !important`
4966
5011
  }));
4967
- const CircularProgressIcon = styled(CircularProgress)(({ theme }) => ({
5012
+ const LoadingSearchIcon = styled(CircularProgress)(({ theme }) => ({
4968
5013
  svg: {
4969
5014
  color: theme.palette.primary.main
4970
5015
  }
4971
5016
  }));
4972
- const SearchFieldBase = styled(TextField, {
4973
- shouldForwardProp: (prop) => prop !== "minimized" && prop !== "isInputFocused"
5017
+ const SearchInputAdornment = styled(InputAdornment, {
5018
+ shouldForwardProp: (prop) => prop !== "minimized" && prop !== "expanded"
4974
5019
  })(
4975
- ({ theme, disabled, minimized, isInputFocused }) => ({
5020
+ ({ theme, minimized, expanded }) => ({
5021
+ "&.MuiInputAdornment-positionEnd": {
5022
+ minWidth: theme.spacing(4),
5023
+ "&.MuiInputAdornment-sizeSmall": {
5024
+ minWidth: theme.spacing(3)
5025
+ }
5026
+ },
5027
+ "&.MuiInputAdornment-positionStart": {
5028
+ marginLeft: minimized ? theme.spacing(1.5) : void 0
5029
+ },
5030
+ ...expanded && !minimized && {
5031
+ "&.MuiInputAdornment-root": {
5032
+ minWidth: theme.spacing(8),
5033
+ "&.MuiInputAdornment-sizeSmall": {
5034
+ minWidth: theme.spacing(7)
5035
+ }
5036
+ }
5037
+ }
5038
+ })
5039
+ );
5040
+ const SearchFieldBase = styled(TextField, {
5041
+ shouldForwardProp: (prop) => prop !== "minimized" && prop !== "isInputFocused" && prop !== "emphasis"
5042
+ })(({ theme, emphasis = "filled", minimized, isInputFocused }) => ({
5043
+ "&.MuiTextField-root .MuiInputBase-root": {
5044
+ paddingRight: theme.spacing(1),
5045
+ transition: theme.transitions.create("width", {
5046
+ easing: theme.transitions.easing.easeInOut,
5047
+ duration: theme.transitions.duration.shortest
5048
+ }),
5049
+ "&.MuiInputBase-sizeSmall": {
5050
+ paddingRight: theme.spacing(0.5)
5051
+ },
5052
+ "&:before": {
5053
+ border: "none !important",
5054
+ "&:hover": {
5055
+ border: "none !important"
5056
+ }
5057
+ },
5058
+ // Input
4976
5059
  "& .MuiInputBase-input": {
4977
- cursor: disabled ? "not-allowed" : "text",
4978
5060
  pointerEvents: isInputFocused ? "auto" : "none"
4979
5061
  // Fix Chrome scroll issue https://issues.chromium.org/issues/41245282
4980
5062
  },
4981
- "&.MuiTextField-root .MuiInputBase-root": {
4982
- paddingRight: theme.spacing(1),
4983
- "&.MuiInputBase-sizeSmall": {
4984
- paddingRight: theme.spacing(0.5)
5063
+ // Error state
5064
+ "&.Mui-error": {
5065
+ "&::after": {
5066
+ borderColor: "transparent !important"
5067
+ }
5068
+ },
5069
+ ...minimized && {
5070
+ display: "flex",
5071
+ alignItems: "center",
5072
+ justifyContent: "center",
5073
+ padding: 0,
5074
+ width: theme.spacing(6),
5075
+ cursor: "pointer",
5076
+ "& .MuiInputBase-input": {
5077
+ display: "none"
4985
5078
  },
4986
- "&:before": {
4987
- border: `none !important`,
4988
- "&:hover": {
4989
- border: `none !important`
4990
- }
5079
+ "&.MuiInputBase-sizeSmall": {
5080
+ width: theme.spacing(4)
5081
+ }
5082
+ }
5083
+ },
5084
+ // Variants
5085
+ ...emphasis === "filled" && {
5086
+ "& .MuiInputBase-root": {
5087
+ backgroundColor: minimized ? "inherit !important" : void 0,
5088
+ // not disabled
5089
+ "&:not(.Mui-disabled):hover": {
5090
+ backgroundColor: `${theme.palette.action.hover} !important`
5091
+ }
5092
+ }
5093
+ },
5094
+ ...emphasis === "transparent" && {
5095
+ "& .MuiInputBase-root": {
5096
+ backgroundColor: "transparent !important",
5097
+ "&:hover": {
5098
+ backgroundColor: "transparent"
4991
5099
  },
4992
- width: minimized ? theme.spacing(4) : "100%",
4993
- transition: theme.transitions.create("width", {
4994
- easing: theme.transitions.easing.easeInOut,
4995
- duration: theme.transitions.duration.shortest
4996
- })
4997
- },
4998
- // Input Adornment
4999
- "& .MuiInputAdornment-positionStart": {
5000
- marginLeft: minimized ? theme.spacing(0.125) : void 0
5001
- },
5002
- "& .MuiInputAdornment-positionEnd": {
5003
- minWidth: theme.spacing(4),
5004
- "&.MuiInputAdornment-sizeSmall": {
5005
- minWidth: theme.spacing(3)
5100
+ "&.Mui-disabled": {
5101
+ backgroundColor: "transparent"
5006
5102
  }
5007
- },
5008
- // Variants
5009
- "& .MuiFilledInput-root": {
5010
- transition: theme.transitions.create("background-color", {
5011
- easing: theme.transitions.easing.easeInOut,
5012
- duration: theme.transitions.duration.shortest
5013
- }),
5014
- backgroundColor: `${minimized ? "inherit" : theme.palette.default.background} !important`,
5103
+ }
5104
+ },
5105
+ ...emphasis === "floating" && {
5106
+ "& .MuiInputBase-root": {
5107
+ backgroundColor: `${theme.palette.background.paper} !important`,
5108
+ boxShadow: theme.shadows[1],
5015
5109
  "&:hover": {
5016
- backgroundColor: `${disabled ? "inherit" : theme.palette.action.hover} !important`
5110
+ backgroundColor: theme.palette.background.paper
5111
+ },
5112
+ "&.Mui-disabled": {
5113
+ backgroundColor: theme.palette.background.paper
5017
5114
  }
5018
5115
  }
5019
- })
5020
- );
5116
+ }
5117
+ }));
5021
5118
  function _SearchField({
5022
5119
  value,
5023
5120
  defaultValue,
@@ -5031,17 +5128,18 @@ function _SearchField({
5031
5128
  variant = "filled",
5032
5129
  size = "small",
5033
5130
  InputProps,
5131
+ inputProps,
5034
5132
  startAdornment,
5035
5133
  endAdornment,
5036
5134
  onFocus,
5037
5135
  onBlur,
5038
- clearTextLabel,
5136
+ clearButtonLabel,
5039
5137
  ...otherProps
5040
5138
  }, ref) {
5041
5139
  const [isInputFocused, setIsInputFocused] = useState(false);
5042
- const clearTextLabelValue = useTranslationFallback(
5140
+ const clearButtonLabelValue = useTranslationWithFallback(
5043
5141
  "c4r.button.clear",
5044
- clearTextLabel
5142
+ clearButtonLabel
5045
5143
  );
5046
5144
  const handleFocus = (event) => {
5047
5145
  setIsInputFocused(true);
@@ -5055,6 +5153,45 @@ function _SearchField({
5055
5153
  onResetSearch == null ? void 0 : onResetSearch();
5056
5154
  onChange == null ? void 0 : onChange({ target: { value: "" } });
5057
5155
  };
5156
+ const getEndAdornment = () => {
5157
+ const showClearButton = !disabled && (value ?? defaultValue);
5158
+ if (minimized) {
5159
+ return void 0;
5160
+ }
5161
+ const clearButtonAriaLabel = typeof clearButtonLabelValue === "string" ? clearButtonLabelValue : String(clearButtonLabelValue);
5162
+ return /* @__PURE__ */ jsx(
5163
+ SearchInputAdornment,
5164
+ {
5165
+ position: "end",
5166
+ expanded: Boolean(endAdornment && showClearButton),
5167
+ children: /* @__PURE__ */ jsxs(
5168
+ Stack,
5169
+ {
5170
+ direction: "row",
5171
+ spacing: 1,
5172
+ sx: {
5173
+ alignItems: "center"
5174
+ },
5175
+ children: [
5176
+ loading ? /* @__PURE__ */ jsx(LoadingSearchIcon, { size: ICON_SIZE_MEDIUM }) : !disabled && showClearButton ? /* @__PURE__ */ jsx(
5177
+ IconButton,
5178
+ {
5179
+ icon: /* @__PURE__ */ jsx(CancelSearchIcon, {}),
5180
+ onClick: handleClearText,
5181
+ size,
5182
+ color: "default",
5183
+ disabled,
5184
+ tooltip: clearButtonLabelValue,
5185
+ "aria-label": clearButtonAriaLabel
5186
+ }
5187
+ ) : void 0,
5188
+ endAdornment
5189
+ ]
5190
+ }
5191
+ )
5192
+ }
5193
+ );
5194
+ };
5058
5195
  return /* @__PURE__ */ jsx(
5059
5196
  SearchFieldBase,
5060
5197
  {
@@ -5063,7 +5200,8 @@ function _SearchField({
5063
5200
  placeholder: minimized ? "" : placeholder,
5064
5201
  onChange,
5065
5202
  onClick,
5066
- variant,
5203
+ variant: "filled",
5204
+ emphasis: variant,
5067
5205
  size,
5068
5206
  focused: false,
5069
5207
  isInputFocused,
@@ -5072,20 +5210,16 @@ function _SearchField({
5072
5210
  InputProps: {
5073
5211
  onFocus: handleFocus,
5074
5212
  onBlur: handleBlur,
5075
- startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(Box, { sx: { display: "inline-flex", ml: minimized ? -0.75 : 0 }, children: loading && minimized ? /* @__PURE__ */ jsx(CircularProgressIcon, { size: ICON_SIZE_MEDIUM }) : startAdornment || /* @__PURE__ */ jsx(SearchIcon, { disabled, minimized }) }) }),
5076
- endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: loading ? /* @__PURE__ */ jsx(CircularProgressIcon, { size: ICON_SIZE_MEDIUM }) : !disabled && !minimized && (value ?? defaultValue) ? endAdornment || /* @__PURE__ */ jsx(
5077
- IconButton,
5078
- {
5079
- icon: /* @__PURE__ */ jsx(CancelIcon, {}),
5080
- onClick: handleClearText,
5081
- size,
5082
- color: "default",
5083
- disabled,
5084
- tooltip: clearTextLabelValue
5085
- }
5086
- ) : void 0 }),
5213
+ startAdornment: /* @__PURE__ */ jsx(SearchInputAdornment, { position: "start", minimized, children: /* @__PURE__ */ jsx(Box, { sx: { display: "inline-flex", ml: minimized ? -0.75 : 0 }, children: loading && minimized ? /* @__PURE__ */ jsx(LoadingSearchIcon, { size: ICON_SIZE_MEDIUM }) : startAdornment || /* @__PURE__ */ jsx(SearchIcon, { disabled, minimized }) }) }),
5214
+ endAdornment: getEndAdornment(),
5087
5215
  ...InputProps
5088
5216
  },
5217
+ inputProps: {
5218
+ role: "searchbox",
5219
+ ...inputProps
5220
+ },
5221
+ role: "search",
5222
+ "data-variant": variant,
5089
5223
  "data-name": "search-field",
5090
5224
  ref,
5091
5225
  ...otherProps