@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.
- package/CHANGELOG.md +8 -0
- package/dist/{Alert-C1VgP3N1.js → Alert-BN993lHa.js} +7 -4
- package/dist/{Alert-F8G9P271.cjs → Alert-CL9Y3l7D.cjs} +7 -4
- package/dist/components/index.cjs +223 -89
- package/dist/components/index.js +225 -91
- package/dist/custom-icons/index.cjs +640 -556
- package/dist/custom-icons/index.js +640 -556
- package/dist/theme/index.cjs +12 -2
- package/dist/theme/index.js +12 -2
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts +25 -0
- package/dist/types/components/Autocomplete/CreatableAutocomplete/CreatableAutocomplete.stories.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/CreatableAutocomplete/useCreatableAutocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/MultipleAutocomplete/useMultipleAutocomplete.d.ts.map +1 -1
- package/dist/types/components/Autocomplete/types.d.ts +4 -1
- package/dist/types/components/Autocomplete/types.d.ts.map +1 -1
- package/dist/types/components/CopiableComponent/CopiableComponent.d.ts.map +1 -1
- package/dist/types/components/CopiableComponent/CopiableComponent.stories.d.ts +3 -0
- package/dist/types/components/CopiableComponent/CopiableComponent.stories.d.ts.map +1 -1
- package/dist/types/components/CopiableComponent/types.d.ts +8 -1
- package/dist/types/components/CopiableComponent/types.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdown.d.ts +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdown.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts +48 -0
- package/dist/types/components/FilterDropdown/FilterDropdown.stories.d.ts.map +1 -1
- package/dist/types/components/FilterDropdown/types.d.ts +8 -0
- package/dist/types/components/FilterDropdown/types.d.ts.map +1 -1
- package/dist/types/components/Menu/MenuItemFilter/MenuItemFilter.d.ts.map +1 -1
- package/dist/types/components/Menu/types.d.ts +1 -0
- package/dist/types/components/Menu/types.d.ts.map +1 -1
- package/dist/types/components/SearchField/SearchField.d.ts +1 -29
- package/dist/types/components/SearchField/SearchField.d.ts.map +1 -1
- package/dist/types/components/SearchField/SearchField.stories.d.ts +8 -0
- package/dist/types/components/SearchField/SearchField.stories.d.ts.map +1 -1
- package/dist/types/components/SearchField/SearchField.styled.d.ts +23 -0
- package/dist/types/components/SearchField/SearchField.styled.d.ts.map +1 -0
- package/dist/types/components/SearchField/SearchField.test.d.ts +2 -0
- package/dist/types/components/SearchField/SearchField.test.d.ts.map +1 -0
- package/dist/types/components/SearchField/index.d.ts +1 -1
- package/dist/types/components/SearchField/index.d.ts.map +1 -1
- package/dist/types/components/SearchField/types.d.ts +31 -0
- package/dist/types/components/SearchField/types.d.ts.map +1 -0
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.d.ts.map +1 -1
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts +22 -2
- package/dist/types/components/SelectField/MultipleSelectField/MultipleSelectField.stories.d.ts.map +1 -1
- package/dist/types/components/SelectField/types.d.ts +4 -0
- package/dist/types/components/SelectField/types.d.ts.map +1 -1
- package/dist/types/custom-icons/FoldersStackedOutlined.d.ts +4 -0
- package/dist/types/custom-icons/FoldersStackedOutlined.d.ts.map +1 -0
- package/dist/types/custom-icons/RedoAlt.d.ts +4 -0
- package/dist/types/custom-icons/RedoAlt.d.ts.map +1 -0
- package/dist/types/custom-icons/SelectFeature.d.ts.map +1 -1
- package/dist/types/custom-icons/UndoAlt.d.ts +4 -0
- package/dist/types/custom-icons/UndoAlt.d.ts.map +1 -0
- package/dist/types/custom-icons/index.d.ts +3 -0
- package/dist/types/custom-icons/index.d.ts.map +1 -1
- package/dist/types/theme/carto-theme.d.ts.map +1 -1
- package/dist/types/theme/components/layout.d.ts +3 -0
- package/dist/types/theme/components/layout.d.ts.map +1 -0
- package/dist/types/theme/components/navigation.d.ts.map +1 -1
- package/dist/types/utils/useTranslationWithFallback.d.ts +39 -0
- package/dist/types/utils/useTranslationWithFallback.d.ts.map +1 -0
- package/dist/types/utils/useTranslationWithFallback.test.d.ts +2 -0
- package/dist/types/utils/useTranslationWithFallback.test.d.ts.map +1 -0
- package/dist/widgets/index.cjs +1 -1
- package/dist/widgets/index.js +1 -1
- package/package.json +1 -1
- package/dist/types/utils/useTranslationFallback.d.ts +0 -20
- package/dist/types/utils/useTranslationFallback.d.ts.map +0 -1
- package/dist/types/utils/useTranslationFallback.test.d.ts +0 -2
- package/dist/types/utils/useTranslationFallback.test.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
5
|
- New SearchField component [#308](https://github.com/CartoDB/meridian-ds/pull/308)
|
|
6
|
+
- Improve translations handling in Meridian (part 1) [#304](https://github.com/CartoDB/meridian-ds/pull/304)
|
|
7
|
+
- FilterDropdown: improve customization [#312](https://github.com/CartoDB/meridian-ds/pull/312)
|
|
8
|
+
- CopiableComponent: improve customization [#311](https://github.com/CartoDB/meridian-ds/pull/311)
|
|
6
9
|
|
|
7
10
|
## 2.0
|
|
8
11
|
|
|
12
|
+
### 2.6.1
|
|
13
|
+
|
|
14
|
+
- Custom Icons: FoldersStackedOutlined,RedoAlt,UndoAlt [#317](https://github.com/CartoDB/meridian-ds/pull/317)
|
|
15
|
+
- Tabs: remove box-shadow in vertical mode[#302](https://github.com/CartoDB/meridian-ds/pull/302)
|
|
16
|
+
|
|
9
17
|
### 2.6.0
|
|
10
18
|
|
|
11
19
|
- New EllipsisWithTooltip component [#299](https://github.com/CartoDB/meridian-ds/pull/299)
|
|
@@ -16,13 +16,16 @@ const ScreenReaderOnly = styled("span")(() => ({
|
|
|
16
16
|
whiteSpace: "nowrap",
|
|
17
17
|
border: 0
|
|
18
18
|
}));
|
|
19
|
-
function
|
|
19
|
+
function useTranslationWithFallback(translationKey, customText, intlValues) {
|
|
20
20
|
const intl = useIntl();
|
|
21
21
|
const intlConfig = useImperativeIntl(intl);
|
|
22
22
|
if (customText !== void 0 && customText !== null) {
|
|
23
23
|
return customText;
|
|
24
24
|
}
|
|
25
|
-
return intlConfig.formatMessage(
|
|
25
|
+
return intlConfig.formatMessage(
|
|
26
|
+
{ id: translationKey },
|
|
27
|
+
intlValues
|
|
28
|
+
);
|
|
26
29
|
}
|
|
27
30
|
const StyledLink = styled(Link$1)(() => ({
|
|
28
31
|
display: "inline-block"
|
|
@@ -82,7 +85,7 @@ function _Link({
|
|
|
82
85
|
"aria-describedby": ariaDescribedby,
|
|
83
86
|
...otherProps
|
|
84
87
|
}, ref) {
|
|
85
|
-
const screenReaderTextValue =
|
|
88
|
+
const screenReaderTextValue = useTranslationWithFallback(
|
|
86
89
|
"c4r.button.opensInNewTab",
|
|
87
90
|
screenReaderText
|
|
88
91
|
);
|
|
@@ -242,5 +245,5 @@ export {
|
|
|
242
245
|
Alert as A,
|
|
243
246
|
Link as L,
|
|
244
247
|
ScreenReaderOnly as S,
|
|
245
|
-
|
|
248
|
+
useTranslationWithFallback as u
|
|
246
249
|
};
|
|
@@ -17,13 +17,16 @@ const ScreenReaderOnly = material.styled("span")(() => ({
|
|
|
17
17
|
whiteSpace: "nowrap",
|
|
18
18
|
border: 0
|
|
19
19
|
}));
|
|
20
|
-
function
|
|
20
|
+
function useTranslationWithFallback(translationKey, customText, intlValues) {
|
|
21
21
|
const intl = reactIntl.useIntl();
|
|
22
22
|
const intlConfig = cssUtils.useImperativeIntl(intl);
|
|
23
23
|
if (customText !== void 0 && customText !== null) {
|
|
24
24
|
return customText;
|
|
25
25
|
}
|
|
26
|
-
return intlConfig.formatMessage(
|
|
26
|
+
return intlConfig.formatMessage(
|
|
27
|
+
{ id: translationKey },
|
|
28
|
+
intlValues
|
|
29
|
+
);
|
|
27
30
|
}
|
|
28
31
|
const StyledLink = material.styled(material.Link)(() => ({
|
|
29
32
|
display: "inline-block"
|
|
@@ -83,7 +86,7 @@ function _Link({
|
|
|
83
86
|
"aria-describedby": ariaDescribedby,
|
|
84
87
|
...otherProps
|
|
85
88
|
}, ref) {
|
|
86
|
-
const screenReaderTextValue =
|
|
89
|
+
const screenReaderTextValue = useTranslationWithFallback(
|
|
87
90
|
"c4r.button.opensInNewTab",
|
|
88
91
|
screenReaderText
|
|
89
92
|
);
|
|
@@ -242,4 +245,4 @@ const Alert = React.forwardRef(_Alert);
|
|
|
242
245
|
exports.Alert = Alert;
|
|
243
246
|
exports.Link = Link;
|
|
244
247
|
exports.ScreenReaderOnly = ScreenReaderOnly;
|
|
245
|
-
exports.
|
|
248
|
+
exports.useTranslationWithFallback = useTranslationWithFallback;
|
|
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const material = require("@mui/material");
|
|
6
6
|
const iconsMaterial = require("@mui/icons-material");
|
|
7
|
-
const Alert$1 = require("../Alert-
|
|
7
|
+
const Alert$1 = require("../Alert-CL9Y3l7D.cjs");
|
|
8
8
|
const cssUtils = require("../css-utils-CqIN_t7x.cjs");
|
|
9
9
|
const ArrowDown = require("../ArrowDown-DJ0vhbsw.cjs");
|
|
10
10
|
const OpenDiagonallyRight = require("../OpenDiagonallyRight-CpL4ROwg.cjs");
|
|
@@ -70,7 +70,7 @@ function _Button({
|
|
|
70
70
|
"aria-describedby": ariaDescribedby,
|
|
71
71
|
...otherProps
|
|
72
72
|
}, ref) {
|
|
73
|
-
const screenReaderTextValue = Alert$1.
|
|
73
|
+
const screenReaderTextValue = Alert$1.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
|
|
530
|
-
|
|
530
|
+
const selectAllLabel = Alert$1.useTranslationWithFallback(
|
|
531
|
+
"c4r.form.selectAll",
|
|
532
|
+
selectAllText
|
|
533
|
+
);
|
|
531
534
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
532
535
|
StyledMenuItem$1,
|
|
533
536
|
{
|
|
@@ -555,7 +558,7 @@ function _MenuItemFilter({
|
|
|
555
558
|
disabled: selectAllDisabled
|
|
556
559
|
}
|
|
557
560
|
),
|
|
558
|
-
|
|
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
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
628
|
+
const allSelectedLabel = Alert$1.useTranslationWithFallback(
|
|
629
|
+
"c4r.form.allSelected",
|
|
630
|
+
allSelectedText
|
|
631
|
+
);
|
|
632
|
+
const noneSelectedLabel = Alert$1.useTranslationWithFallback(
|
|
633
|
+
"c4r.form.noneSelected",
|
|
634
|
+
noneSelectedText
|
|
635
|
+
);
|
|
636
|
+
const selectedLabel = Alert$1.useTranslationWithFallback(
|
|
637
|
+
"c4r.form.selected",
|
|
638
|
+
selectedText
|
|
639
|
+
);
|
|
640
|
+
const counterText = `${currentOptions.length} ${selectedLabel}`;
|
|
626
641
|
const renderValue = React.useMemo(() => {
|
|
627
642
|
if (areAllSelected) {
|
|
628
643
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -632,7 +647,7 @@ function _MultipleSelectField({
|
|
|
632
647
|
variant: isSmall ? "body2" : "body1",
|
|
633
648
|
color: "textPrimary",
|
|
634
649
|
ml: paddingSize,
|
|
635
|
-
children:
|
|
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 ??
|
|
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] = React.useState(false);
|
|
@@ -893,6 +913,7 @@ const _CopiableComponent = ({
|
|
|
893
913
|
setOpen(true);
|
|
894
914
|
}).catch(console.error);
|
|
895
915
|
};
|
|
916
|
+
const copyIcon = buttonIcon ?? /* @__PURE__ */ jsxRuntime.jsx(iconsMaterial.ContentCopyOutlined, {});
|
|
896
917
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
897
918
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
898
919
|
material.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__ */ jsxRuntime.jsxs(
|
|
904
926
|
material.Box,
|
|
905
927
|
{
|
|
@@ -915,7 +937,7 @@ const _CopiableComponent = ({
|
|
|
915
937
|
{
|
|
916
938
|
...buttonProps,
|
|
917
939
|
disabled,
|
|
918
|
-
icon:
|
|
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__ */ jsxRuntime.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 = reactIntl.useIntl();
|
|
1278
|
-
const intlConfig = cssUtils.useImperativeIntl(intl);
|
|
1279
1300
|
const filter = material.createFilterOptions();
|
|
1280
1301
|
const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
|
|
1302
|
+
const addLabel = Alert$1.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 = `${
|
|
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 = reactIntl.useIntl();
|
|
1343
|
-
const intlConfig = cssUtils.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] = React.useState(
|
|
1347
1366
|
Array.isArray(value) ? value : value ? [value] : []
|
|
1348
1367
|
);
|
|
1349
1368
|
const { renderOption: autocompleteRenderOption } = useAutocompleteRenderOption();
|
|
1369
|
+
const defaultCounterText = Alert$1.useTranslationWithFallback(
|
|
1370
|
+
"c4r.form.selected",
|
|
1371
|
+
counterText
|
|
1372
|
+
);
|
|
1373
|
+
const defaultAllSelectedText = Alert$1.useTranslationWithFallback(
|
|
1374
|
+
"c4r.form.allSelected",
|
|
1375
|
+
allSelectedText
|
|
1376
|
+
);
|
|
1350
1377
|
React.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__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4893
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4894
|
-
|
|
4923
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4924
|
+
material.Tooltip,
|
|
4895
4925
|
{
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4926
|
+
title: tooltipLabel,
|
|
4927
|
+
placement: tooltipPlacement,
|
|
4928
|
+
...tooltipProps,
|
|
4929
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ButtonWrapper, { isOpen, buttonColor, ref, children: isIcon ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4930
|
+
cssUtils.IconButton,
|
|
4931
|
+
{
|
|
4932
|
+
...commonButtonProps,
|
|
4933
|
+
icon,
|
|
4934
|
+
...iconButtonProps
|
|
4935
|
+
}
|
|
4936
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
4937
|
+
Button,
|
|
4938
|
+
{
|
|
4939
|
+
...commonButtonProps,
|
|
4940
|
+
endIcon: isOpen ? /* @__PURE__ */ jsxRuntime.jsx(OpenDiagonallyRight.ArrowUp, {}) : /* @__PURE__ */ jsxRuntime.jsx(ArrowDown.ArrowDown, {}),
|
|
4941
|
+
...buttonProps,
|
|
4942
|
+
children: menuLabel
|
|
4943
|
+
}
|
|
4944
|
+
) })
|
|
4899
4945
|
}
|
|
4900
|
-
)
|
|
4946
|
+
),
|
|
4901
4947
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4902
4948
|
Menu,
|
|
4903
4949
|
{
|
|
@@ -4960,64 +5006,115 @@ const SearchIcon = material.styled(Search.Search, {
|
|
|
4960
5006
|
}
|
|
4961
5007
|
})
|
|
4962
5008
|
);
|
|
4963
|
-
const
|
|
4964
|
-
|
|
4965
|
-
cursor: "pointer"
|
|
5009
|
+
const CancelSearchIcon = material.styled(iconsMaterial.Cancel)(({ theme }) => ({
|
|
5010
|
+
color: `${theme.palette.text.hint} !important`
|
|
4966
5011
|
}));
|
|
4967
|
-
const
|
|
5012
|
+
const LoadingSearchIcon = material.styled(material.CircularProgress)(({ theme }) => ({
|
|
4968
5013
|
svg: {
|
|
4969
5014
|
color: theme.palette.primary.main
|
|
4970
5015
|
}
|
|
4971
5016
|
}));
|
|
4972
|
-
const
|
|
4973
|
-
shouldForwardProp: (prop) => prop !== "minimized" && prop !== "
|
|
5017
|
+
const SearchInputAdornment = material.styled(material.InputAdornment, {
|
|
5018
|
+
shouldForwardProp: (prop) => prop !== "minimized" && prop !== "expanded"
|
|
4974
5019
|
})(
|
|
4975
|
-
({ theme,
|
|
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 = material.styled(material.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
|
-
|
|
4982
|
-
|
|
4983
|
-
"
|
|
4984
|
-
|
|
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
|
-
"
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
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
|
-
|
|
4993
|
-
|
|
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
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
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:
|
|
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
|
-
|
|
5136
|
+
clearButtonLabel,
|
|
5039
5137
|
...otherProps
|
|
5040
5138
|
}, ref) {
|
|
5041
5139
|
const [isInputFocused, setIsInputFocused] = React.useState(false);
|
|
5042
|
-
const
|
|
5140
|
+
const clearButtonLabelValue = Alert$1.useTranslationWithFallback(
|
|
5043
5141
|
"c4r.button.clear",
|
|
5044
|
-
|
|
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__ */ jsxRuntime.jsx(
|
|
5163
|
+
SearchInputAdornment,
|
|
5164
|
+
{
|
|
5165
|
+
position: "end",
|
|
5166
|
+
expanded: Boolean(endAdornment && showClearButton),
|
|
5167
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5168
|
+
material.Stack,
|
|
5169
|
+
{
|
|
5170
|
+
direction: "row",
|
|
5171
|
+
spacing: 1,
|
|
5172
|
+
sx: {
|
|
5173
|
+
alignItems: "center"
|
|
5174
|
+
},
|
|
5175
|
+
children: [
|
|
5176
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSearchIcon, { size: cssUtils.ICON_SIZE_MEDIUM }) : !disabled && showClearButton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5177
|
+
cssUtils.IconButton,
|
|
5178
|
+
{
|
|
5179
|
+
icon: /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
|
|
5076
|
-
endAdornment:
|
|
5077
|
-
cssUtils.IconButton,
|
|
5078
|
-
{
|
|
5079
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(CancelIcon, {}),
|
|
5080
|
-
onClick: handleClearText,
|
|
5081
|
-
size,
|
|
5082
|
-
color: "default",
|
|
5083
|
-
disabled,
|
|
5084
|
-
tooltip: clearTextLabelValue
|
|
5085
|
-
}
|
|
5086
|
-
) : void 0 }),
|
|
5213
|
+
startAdornment: /* @__PURE__ */ jsxRuntime.jsx(SearchInputAdornment, { position: "start", minimized, children: /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { display: "inline-flex", ml: minimized ? -0.75 : 0 }, children: loading && minimized ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSearchIcon, { size: cssUtils.ICON_SIZE_MEDIUM }) : startAdornment || /* @__PURE__ */ jsxRuntime.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
|