@uniformdev/design-system 19.134.0 → 19.134.3-alpha.28
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/dist/esm/index.js +354 -289
- package/dist/index.d.mts +124 -8
- package/dist/index.d.ts +124 -8
- package/dist/index.js +376 -300
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -11852,7 +11852,7 @@ function isMenuSeparator(child) {
|
|
|
11852
11852
|
|
|
11853
11853
|
// src/components/Menu/Menu.styles.ts
|
|
11854
11854
|
import { css as css26 } from "@emotion/react";
|
|
11855
|
-
var menuStyles = css26`
|
|
11855
|
+
var menuStyles = (maxMenuHeight) => css26`
|
|
11856
11856
|
box-shadow: var(--shadow-base);
|
|
11857
11857
|
border-radius: var(--rounded-base);
|
|
11858
11858
|
background: var(--gray-50);
|
|
@@ -11862,10 +11862,21 @@ var menuStyles = css26`
|
|
|
11862
11862
|
outline: none;
|
|
11863
11863
|
position: relative;
|
|
11864
11864
|
z-index: var(--z-50);
|
|
11865
|
-
|
|
11866
11865
|
&:focus {
|
|
11867
11866
|
outline: none;
|
|
11868
11867
|
}
|
|
11868
|
+
|
|
11869
|
+
// resolves uni-2997 for smaller screens not being able to access large menus
|
|
11870
|
+
// the code was removed in https://github.com/uniformdev/platform/commit/0067e6c87aaf29147c656949bbf49d632d3e89dc#diff-84f70b10af4d4ec4f57c535e3c44b04c30ce95ac337ce21db9f1ffd8393a846d
|
|
11871
|
+
// but we need to keep it for the Menu component if the menu is larger than the screen
|
|
11872
|
+
${maxMenuHeight ? `
|
|
11873
|
+
overflow-x: hidden;
|
|
11874
|
+
overflow-y: auto;
|
|
11875
|
+
height: min(${maxMenuHeight}, var(--popover-available-height));
|
|
11876
|
+
scroll-snap-align: start;
|
|
11877
|
+
scroll-snap-stop: always;
|
|
11878
|
+
${scrollbarStyles}
|
|
11879
|
+
` : ""}
|
|
11869
11880
|
`;
|
|
11870
11881
|
|
|
11871
11882
|
// src/components/Menu/Menu.tsx
|
|
@@ -11881,6 +11892,7 @@ var Menu = React8.forwardRef(function Menu2({
|
|
|
11881
11892
|
disableAutoSeparatorManagement,
|
|
11882
11893
|
menuItemsContainerCssClasses,
|
|
11883
11894
|
testId,
|
|
11895
|
+
maxMenuHeight,
|
|
11884
11896
|
...props
|
|
11885
11897
|
}, ref) {
|
|
11886
11898
|
const placementOverride = legacyPlacements.includes(placement) ? void 0 : placement;
|
|
@@ -11895,7 +11907,7 @@ var Menu = React8.forwardRef(function Menu2({
|
|
|
11895
11907
|
shift: menu.parent ? -4 : 0,
|
|
11896
11908
|
...props,
|
|
11897
11909
|
css: [
|
|
11898
|
-
menuStyles,
|
|
11910
|
+
menuStyles(maxMenuHeight),
|
|
11899
11911
|
typeof menuItemsContainerCssClasses === "object" ? menuItemsContainerCssClasses : void 0
|
|
11900
11912
|
],
|
|
11901
11913
|
className: typeof menuItemsContainerCssClasses === "string" ? menuItemsContainerCssClasses : "",
|
|
@@ -12146,6 +12158,7 @@ var ButtonWithMenu = ({
|
|
|
12146
12158
|
size = "lg",
|
|
12147
12159
|
menuContainerCssClasses,
|
|
12148
12160
|
withoutPortal = false,
|
|
12161
|
+
maxMenuHeight,
|
|
12149
12162
|
...buttonProps
|
|
12150
12163
|
}) => {
|
|
12151
12164
|
const buttonTheme = {
|
|
@@ -12204,6 +12217,7 @@ var ButtonWithMenu = ({
|
|
|
12204
12217
|
placement,
|
|
12205
12218
|
menuTrigger: clickableButton,
|
|
12206
12219
|
menuItemsContainerCssClasses: menuContainerCssClasses,
|
|
12220
|
+
maxMenuHeight,
|
|
12207
12221
|
children
|
|
12208
12222
|
}
|
|
12209
12223
|
)
|
|
@@ -12215,6 +12229,7 @@ var ButtonWithMenu = ({
|
|
|
12215
12229
|
menuTrigger: dropdownButton,
|
|
12216
12230
|
menuItemsContainerCssClasses: menuContainerCssClasses,
|
|
12217
12231
|
portal: withoutPortal,
|
|
12232
|
+
maxMenuHeight,
|
|
12218
12233
|
children
|
|
12219
12234
|
}
|
|
12220
12235
|
) })
|
|
@@ -17046,6 +17061,7 @@ var MediaCard = ({
|
|
|
17046
17061
|
menuItems,
|
|
17047
17062
|
sideSection: sideSection2,
|
|
17048
17063
|
onClick,
|
|
17064
|
+
buttonType,
|
|
17049
17065
|
...cardProps
|
|
17050
17066
|
}) => {
|
|
17051
17067
|
const onStopPropogation = useCallback7((e) => {
|
|
@@ -17053,7 +17069,7 @@ var MediaCard = ({
|
|
|
17053
17069
|
}, []);
|
|
17054
17070
|
const hasMenuItems = Array.isArray(menuItems) ? menuItems.length > 0 : Boolean(menuItems);
|
|
17055
17071
|
return /* @__PURE__ */ jsxs62(Card, { css: cardBase, ...cardProps, onClick, "data-testid": "card-item", children: [
|
|
17056
|
-
/* @__PURE__ */ jsx93("button", { tabIndex: -1, css: coverWrapper, children: cover }),
|
|
17072
|
+
/* @__PURE__ */ jsx93("button", { tabIndex: -1, css: coverWrapper, type: buttonType, children: cover }),
|
|
17057
17073
|
/* @__PURE__ */ jsx93("div", { css: contentWrapper, children: /* @__PURE__ */ jsxs62(HorizontalRhythm, { gap: "sm", justify: "space-between", align: "center", css: { width: "100%" }, children: [
|
|
17058
17074
|
/* @__PURE__ */ jsxs62(VerticalRhythm, { gap: "0", align: "flex-start", css: { flex: 1, minWidth: 0 }, children: [
|
|
17059
17075
|
/* @__PURE__ */ jsxs62(HorizontalRhythm, { gap: "xs", align: "center", css: { maxWidth: "100%" }, children: [
|
|
@@ -20463,6 +20479,18 @@ var ConditionalFilterRow = css92`
|
|
|
20463
20479
|
|
|
20464
20480
|
${cq("380px")} {
|
|
20465
20481
|
align-items: center;
|
|
20482
|
+
|
|
20483
|
+
&:after {
|
|
20484
|
+
content: '';
|
|
20485
|
+
display: block;
|
|
20486
|
+
height: 1px;
|
|
20487
|
+
background: var(--gray-300);
|
|
20488
|
+
width: calc(100% - var(--spacing-base));
|
|
20489
|
+
margin-left: var(--spacing-base);
|
|
20490
|
+
}
|
|
20491
|
+
&:last-of-type:after {
|
|
20492
|
+
display: none;
|
|
20493
|
+
}
|
|
20466
20494
|
}
|
|
20467
20495
|
|
|
20468
20496
|
&:first-of-type {
|
|
@@ -20470,6 +20498,12 @@ var ConditionalFilterRow = css92`
|
|
|
20470
20498
|
grid-template-columns: 50px 1fr;
|
|
20471
20499
|
}
|
|
20472
20500
|
|
|
20501
|
+
${cq("580px")} {
|
|
20502
|
+
&:after {
|
|
20503
|
+
display: none;
|
|
20504
|
+
}
|
|
20505
|
+
}
|
|
20506
|
+
|
|
20473
20507
|
@media (prefers-reduced-motion: no-preference) {
|
|
20474
20508
|
animation: ${fadeInLtr} var(--duration-fast) var(--timing-ease-out);
|
|
20475
20509
|
}
|
|
@@ -20477,15 +20511,24 @@ var ConditionalFilterRow = css92`
|
|
|
20477
20511
|
var ConditionalInputRow = css92`
|
|
20478
20512
|
display: flex;
|
|
20479
20513
|
gap: var(--spacing-sm);
|
|
20480
|
-
flex-
|
|
20514
|
+
flex-wrap: wrap;
|
|
20481
20515
|
|
|
20482
20516
|
${cq("380px")} {
|
|
20483
|
-
|
|
20484
|
-
|
|
20517
|
+
& > div:nth-child(-n + 2) {
|
|
20518
|
+
width: calc(50% - var(--spacing-sm));
|
|
20519
|
+
}
|
|
20520
|
+
|
|
20521
|
+
& > div:nth-child(n + 3) {
|
|
20522
|
+
width: calc(100% - 48px);
|
|
20523
|
+
}
|
|
20485
20524
|
}
|
|
20486
20525
|
${cq("580px")} {
|
|
20487
20526
|
display: grid;
|
|
20488
20527
|
grid-template-columns: 200px 160px 1fr 32px;
|
|
20528
|
+
|
|
20529
|
+
& > div:nth-child(n) {
|
|
20530
|
+
width: auto;
|
|
20531
|
+
}
|
|
20489
20532
|
}
|
|
20490
20533
|
`;
|
|
20491
20534
|
var SearchInput = css92`
|
|
@@ -20671,8 +20714,8 @@ var FilterButton2 = ({
|
|
|
20671
20714
|
};
|
|
20672
20715
|
|
|
20673
20716
|
// src/components/SearchAndFilter/FilterControls.tsx
|
|
20674
|
-
import { useEffect as
|
|
20675
|
-
import { useDebounce as
|
|
20717
|
+
import { useEffect as useEffect19, useState as useState18 } from "react";
|
|
20718
|
+
import { useDebounce as useDebounce3, useEffectOnce } from "react-use";
|
|
20676
20719
|
|
|
20677
20720
|
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
20678
20721
|
import {
|
|
@@ -20680,231 +20723,14 @@ import {
|
|
|
20680
20723
|
useCallback as useCallback10,
|
|
20681
20724
|
useContext as useContext7,
|
|
20682
20725
|
useDeferredValue as useDeferredValue2,
|
|
20683
|
-
useEffect as
|
|
20726
|
+
useEffect as useEffect18,
|
|
20684
20727
|
useMemo as useMemo6,
|
|
20685
|
-
useState as
|
|
20728
|
+
useState as useState17
|
|
20686
20729
|
} from "react";
|
|
20687
|
-
import { jsx as jsx119 } from "@emotion/react/jsx-runtime";
|
|
20688
|
-
var SearchAndFilterContext = createContext6({
|
|
20689
|
-
searchTerm: "",
|
|
20690
|
-
setSearchTerm: () => {
|
|
20691
|
-
},
|
|
20692
|
-
filterVisibility: void 0,
|
|
20693
|
-
setFilterVisibility: () => {
|
|
20694
|
-
},
|
|
20695
|
-
filters: [],
|
|
20696
|
-
setFilters: () => {
|
|
20697
|
-
},
|
|
20698
|
-
handleAddFilter: () => {
|
|
20699
|
-
},
|
|
20700
|
-
handleResetFilters: () => {
|
|
20701
|
-
},
|
|
20702
|
-
handleDeleteFilter: () => {
|
|
20703
|
-
},
|
|
20704
|
-
setSortBy: () => {
|
|
20705
|
-
},
|
|
20706
|
-
sortByValue: "",
|
|
20707
|
-
filterOptions: [],
|
|
20708
|
-
sortOptions: [],
|
|
20709
|
-
validFilterQuery: [],
|
|
20710
|
-
totalResults: 0
|
|
20711
|
-
});
|
|
20712
|
-
var SearchAndFilterProvider = ({
|
|
20713
|
-
filters,
|
|
20714
|
-
filterOptions,
|
|
20715
|
-
sortOptions,
|
|
20716
|
-
defaultSortByValue,
|
|
20717
|
-
filterMode: filterMode3 = void 0,
|
|
20718
|
-
onSearchChange,
|
|
20719
|
-
onChange,
|
|
20720
|
-
onSortChange,
|
|
20721
|
-
resetFilterValues = [],
|
|
20722
|
-
totalResults,
|
|
20723
|
-
children
|
|
20724
|
-
}) => {
|
|
20725
|
-
const [searchTerm, setSearchTerm] = useState16("");
|
|
20726
|
-
const deferredSearchTerm = useDeferredValue2(searchTerm);
|
|
20727
|
-
const [filterVisibility, setFilterVisibility] = useState16(filterMode3);
|
|
20728
|
-
const [sortByValue, setSortByValue] = useState16(defaultSortByValue);
|
|
20729
|
-
const handleSearchTerm = useCallback10(
|
|
20730
|
-
(term) => {
|
|
20731
|
-
setSearchTerm(term);
|
|
20732
|
-
onSearchChange == null ? void 0 : onSearchChange(term);
|
|
20733
|
-
},
|
|
20734
|
-
[setSearchTerm, onSearchChange]
|
|
20735
|
-
);
|
|
20736
|
-
const handleOnSortChange = useCallback10(
|
|
20737
|
-
(sort) => {
|
|
20738
|
-
setSortByValue(sort);
|
|
20739
|
-
onSortChange(sort);
|
|
20740
|
-
},
|
|
20741
|
-
[onSortChange]
|
|
20742
|
-
);
|
|
20743
|
-
const handleToggleFilterVisibilty = useCallback10(
|
|
20744
|
-
(mode) => setFilterVisibility(mode),
|
|
20745
|
-
[setFilterVisibility]
|
|
20746
|
-
);
|
|
20747
|
-
const handleAddFilter = useCallback10(() => {
|
|
20748
|
-
onChange([...filters, { field: "", operator: "", value: "" }]);
|
|
20749
|
-
}, [filters, onChange]);
|
|
20750
|
-
const handleResetFilters = useCallback10(() => {
|
|
20751
|
-
onChange(resetFilterValues);
|
|
20752
|
-
}, [onChange, resetFilterValues]);
|
|
20753
|
-
const handleDeleteFilter = useCallback10(
|
|
20754
|
-
(index) => {
|
|
20755
|
-
const remainingFilters = filters.filter((_, i) => i !== index);
|
|
20756
|
-
onChange(remainingFilters);
|
|
20757
|
-
},
|
|
20758
|
-
[filters, onChange]
|
|
20759
|
-
);
|
|
20760
|
-
const validFilterQuery = useMemo6(() => {
|
|
20761
|
-
const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
|
|
20762
|
-
if (hasValidFilters) {
|
|
20763
|
-
return filters;
|
|
20764
|
-
}
|
|
20765
|
-
}, [filters]);
|
|
20766
|
-
useEffect17(() => {
|
|
20767
|
-
if (filterVisibility) {
|
|
20768
|
-
const handleEscKeyFilterClose = (e) => {
|
|
20769
|
-
if (e.key === "Escape") {
|
|
20770
|
-
setFilterVisibility(void 0);
|
|
20771
|
-
}
|
|
20772
|
-
};
|
|
20773
|
-
document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
20774
|
-
return () => {
|
|
20775
|
-
document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
20776
|
-
};
|
|
20777
|
-
}
|
|
20778
|
-
}, [filterVisibility]);
|
|
20779
|
-
return /* @__PURE__ */ jsx119(
|
|
20780
|
-
SearchAndFilterContext.Provider,
|
|
20781
|
-
{
|
|
20782
|
-
value: {
|
|
20783
|
-
searchTerm: deferredSearchTerm,
|
|
20784
|
-
setSearchTerm: (e) => handleSearchTerm(e),
|
|
20785
|
-
setSortBy: (e) => handleOnSortChange(e),
|
|
20786
|
-
sortByValue,
|
|
20787
|
-
filterVisibility,
|
|
20788
|
-
setFilterVisibility: (e) => handleToggleFilterVisibilty(e),
|
|
20789
|
-
filters,
|
|
20790
|
-
setFilters: (e) => onChange(e),
|
|
20791
|
-
handleAddFilter,
|
|
20792
|
-
handleResetFilters,
|
|
20793
|
-
handleDeleteFilter,
|
|
20794
|
-
filterOptions,
|
|
20795
|
-
sortOptions,
|
|
20796
|
-
validFilterQuery,
|
|
20797
|
-
totalResults
|
|
20798
|
-
},
|
|
20799
|
-
children: /* @__PURE__ */ jsx119(VerticalRhythm, { children })
|
|
20800
|
-
}
|
|
20801
|
-
);
|
|
20802
|
-
};
|
|
20803
|
-
var useSearchAndFilter = () => {
|
|
20804
|
-
const value = useContext7(SearchAndFilterContext);
|
|
20805
|
-
return { ...value };
|
|
20806
|
-
};
|
|
20807
|
-
|
|
20808
|
-
// src/components/SearchAndFilter/FilterControls.tsx
|
|
20809
|
-
import { Fragment as Fragment19, jsx as jsx120, jsxs as jsxs81 } from "@emotion/react/jsx-runtime";
|
|
20810
|
-
var FilterControls = ({
|
|
20811
|
-
children,
|
|
20812
|
-
defaultSortByValue,
|
|
20813
|
-
hideSearchInput
|
|
20814
|
-
}) => {
|
|
20815
|
-
var _a, _b, _c;
|
|
20816
|
-
const {
|
|
20817
|
-
setFilterVisibility,
|
|
20818
|
-
filterVisibility,
|
|
20819
|
-
setSearchTerm,
|
|
20820
|
-
validFilterQuery,
|
|
20821
|
-
searchTerm,
|
|
20822
|
-
sortByValue,
|
|
20823
|
-
filterOptions
|
|
20824
|
-
} = useSearchAndFilter();
|
|
20825
|
-
const [initialSortValue, setInitialSortValue] = useState17(sortByValue);
|
|
20826
|
-
const [localeSearchTerm, setLocaleSearchTerm] = useState17("");
|
|
20827
|
-
const [userHasChangedSortByValue, setUserHasChangedSortByValue] = useState17(false);
|
|
20828
|
-
useDebounce2(
|
|
20829
|
-
() => {
|
|
20830
|
-
setSearchTerm(localeSearchTerm);
|
|
20831
|
-
},
|
|
20832
|
-
300,
|
|
20833
|
-
[localeSearchTerm, searchTerm]
|
|
20834
|
-
);
|
|
20835
|
-
useEffect18(() => {
|
|
20836
|
-
if (searchTerm === "") {
|
|
20837
|
-
setLocaleSearchTerm("");
|
|
20838
|
-
}
|
|
20839
|
-
}, [searchTerm]);
|
|
20840
|
-
const handleFilterToggle = (mode) => {
|
|
20841
|
-
if (filterVisibility === "filters" && mode === "filters" || filterVisibility === "sort" && mode === "sort") {
|
|
20842
|
-
return setFilterVisibility(void 0);
|
|
20843
|
-
}
|
|
20844
|
-
return setFilterVisibility(mode);
|
|
20845
|
-
};
|
|
20846
|
-
const sortValue = (sortByValue != null ? sortByValue : defaultSortByValue).split("_");
|
|
20847
|
-
const sortDirection = sortValue == null ? void 0 : sortValue.pop();
|
|
20848
|
-
const sortField = sortValue == null ? void 0 : sortValue.join("_");
|
|
20849
|
-
const sortOn = sortField.startsWith("fields.") ? "contentTypeFields" : "metadata";
|
|
20850
|
-
const sortByValueLabel = (_c = (_b = (_a = filterOptions == null ? void 0 : filterOptions.find((op) => op.value === sortOn)) == null ? void 0 : _a.options) == null ? void 0 : _b.find((f) => f.value === sortField)) == null ? void 0 : _c.label;
|
|
20851
|
-
const sortByIcon = userHasChangedSortByValue ? sortDirection === "ASC" ? "arrow-up" : "arrow-down" : "sort-az";
|
|
20852
|
-
useEffectOnce(() => {
|
|
20853
|
-
setInitialSortValue(sortByValue);
|
|
20854
|
-
});
|
|
20855
|
-
useEffect18(() => {
|
|
20856
|
-
if (initialSortValue !== sortByValue) {
|
|
20857
|
-
setUserHasChangedSortByValue(true);
|
|
20858
|
-
}
|
|
20859
|
-
}, [initialSortValue, sortByValue]);
|
|
20860
|
-
return /* @__PURE__ */ jsxs81(Fragment19, { children: [
|
|
20861
|
-
/* @__PURE__ */ jsx120(
|
|
20862
|
-
FilterButton2,
|
|
20863
|
-
{
|
|
20864
|
-
"aria-controls": "search-and-filter-options",
|
|
20865
|
-
"aria-label": "filter options",
|
|
20866
|
-
"aria-haspopup": "true",
|
|
20867
|
-
"aria-expanded": filterVisibility === "filters",
|
|
20868
|
-
filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
|
|
20869
|
-
onClick: () => handleFilterToggle("filters"),
|
|
20870
|
-
dataTestId: "filters-button"
|
|
20871
|
-
}
|
|
20872
|
-
),
|
|
20873
|
-
/* @__PURE__ */ jsx120(
|
|
20874
|
-
FilterButton2,
|
|
20875
|
-
{
|
|
20876
|
-
"aria-controls": "search-and-filter-sortBy",
|
|
20877
|
-
"aria-label": "sort by options",
|
|
20878
|
-
"aria-haspopup": "true",
|
|
20879
|
-
text: !userHasChangedSortByValue ? "Sort" : sortByValueLabel,
|
|
20880
|
-
icon: sortByIcon,
|
|
20881
|
-
"aria-expanded": filterVisibility === "sort",
|
|
20882
|
-
hasSelectedValue: sortByValue !== "",
|
|
20883
|
-
onClick: () => handleFilterToggle("sort"),
|
|
20884
|
-
dataTestId: "sort-by-button"
|
|
20885
|
-
}
|
|
20886
|
-
),
|
|
20887
|
-
hideSearchInput ? null : /* @__PURE__ */ jsx120(
|
|
20888
|
-
InputKeywordSearch,
|
|
20889
|
-
{
|
|
20890
|
-
placeholder: "Search...",
|
|
20891
|
-
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
20892
|
-
value: localeSearchTerm,
|
|
20893
|
-
compact: true,
|
|
20894
|
-
rounded: true,
|
|
20895
|
-
css: SearchInput
|
|
20896
|
-
}
|
|
20897
|
-
),
|
|
20898
|
-
children
|
|
20899
|
-
] });
|
|
20900
|
-
};
|
|
20901
|
-
|
|
20902
|
-
// src/components/SearchAndFilter/FilterItem.tsx
|
|
20903
|
-
import { useMemo as useMemo7 } from "react";
|
|
20904
20730
|
|
|
20905
20731
|
// src/components/SearchAndFilter/FilterEditor.tsx
|
|
20906
|
-
import { useEffect as
|
|
20907
|
-
import { useDebounce as
|
|
20732
|
+
import { useEffect as useEffect17, useState as useState16 } from "react";
|
|
20733
|
+
import { useDebounce as useDebounce2 } from "react-use";
|
|
20908
20734
|
|
|
20909
20735
|
// src/components/Validation/StatusBullet.styles.ts
|
|
20910
20736
|
import { css as css93 } from "@emotion/react";
|
|
@@ -20986,7 +20812,7 @@ var StatusDeleted = css93`
|
|
|
20986
20812
|
`;
|
|
20987
20813
|
|
|
20988
20814
|
// src/components/Validation/StatusBullet.tsx
|
|
20989
|
-
import { jsx as
|
|
20815
|
+
import { jsx as jsx119 } from "@emotion/react/jsx-runtime";
|
|
20990
20816
|
var StatusBullet = ({
|
|
20991
20817
|
status,
|
|
20992
20818
|
hideText = false,
|
|
@@ -21006,7 +20832,7 @@ var StatusBullet = ({
|
|
|
21006
20832
|
Deleted: StatusDeleted
|
|
21007
20833
|
};
|
|
21008
20834
|
const statusSize = size === "base" ? StatusBulletBase : StatusBulletSmall;
|
|
21009
|
-
return /* @__PURE__ */
|
|
20835
|
+
return /* @__PURE__ */ jsx119(
|
|
21010
20836
|
"span",
|
|
21011
20837
|
{
|
|
21012
20838
|
role: "status",
|
|
@@ -21019,7 +20845,7 @@ var StatusBullet = ({
|
|
|
21019
20845
|
};
|
|
21020
20846
|
|
|
21021
20847
|
// src/components/SearchAndFilter/FilterEditor.tsx
|
|
21022
|
-
import { Fragment as
|
|
20848
|
+
import { Fragment as Fragment19, jsx as jsx120, jsxs as jsxs81 } from "@emotion/react/jsx-runtime";
|
|
21023
20849
|
var readOnlyAttributes = {
|
|
21024
20850
|
isSearchable: false,
|
|
21025
20851
|
menuIsOpen: false,
|
|
@@ -21028,13 +20854,13 @@ var readOnlyAttributes = {
|
|
|
21028
20854
|
var FilterMultiChoiceEditor = ({
|
|
21029
20855
|
value,
|
|
21030
20856
|
options,
|
|
21031
|
-
|
|
20857
|
+
disabled: disabled2,
|
|
21032
20858
|
readOnly,
|
|
21033
20859
|
valueTestId,
|
|
21034
20860
|
...props
|
|
21035
20861
|
}) => {
|
|
21036
20862
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
21037
|
-
return /* @__PURE__ */
|
|
20863
|
+
return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
|
|
21038
20864
|
InputComboBox,
|
|
21039
20865
|
{
|
|
21040
20866
|
...props,
|
|
@@ -21042,12 +20868,12 @@ var FilterMultiChoiceEditor = ({
|
|
|
21042
20868
|
options,
|
|
21043
20869
|
isMulti: true,
|
|
21044
20870
|
isClearable: true,
|
|
21045
|
-
isDisabled,
|
|
20871
|
+
isDisabled: disabled2,
|
|
21046
20872
|
onChange: (e) => {
|
|
21047
20873
|
var _a;
|
|
21048
|
-
return props.onChange((_a = e.map((
|
|
20874
|
+
return props.onChange((_a = e == null ? void 0 : e.map((option) => option.value)) != null ? _a : []);
|
|
21049
20875
|
},
|
|
21050
|
-
value,
|
|
20876
|
+
value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
|
|
21051
20877
|
"aria-readonly": readOnly,
|
|
21052
20878
|
styles: {
|
|
21053
20879
|
menu(base) {
|
|
@@ -21064,13 +20890,13 @@ var FilterMultiChoiceEditor = ({
|
|
|
21064
20890
|
var FilterSingleChoiceEditor = ({
|
|
21065
20891
|
options,
|
|
21066
20892
|
value,
|
|
21067
|
-
|
|
20893
|
+
disabled: disabled2,
|
|
21068
20894
|
readOnly,
|
|
21069
20895
|
onChange,
|
|
21070
20896
|
valueTestId
|
|
21071
20897
|
}) => {
|
|
21072
20898
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
21073
|
-
return /* @__PURE__ */
|
|
20899
|
+
return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
|
|
21074
20900
|
InputComboBox,
|
|
21075
20901
|
{
|
|
21076
20902
|
placeholder: "Type to search...",
|
|
@@ -21080,8 +20906,8 @@ var FilterSingleChoiceEditor = ({
|
|
|
21080
20906
|
var _a;
|
|
21081
20907
|
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
21082
20908
|
},
|
|
21083
|
-
isDisabled,
|
|
21084
|
-
value,
|
|
20909
|
+
isDisabled: disabled2,
|
|
20910
|
+
value: options == null ? void 0 : options.find((option) => option.value === value),
|
|
21085
20911
|
"aria-readonly": readOnly,
|
|
21086
20912
|
styles: {
|
|
21087
20913
|
menu(base) {
|
|
@@ -21096,18 +20922,18 @@ var FilterSingleChoiceEditor = ({
|
|
|
21096
20922
|
) });
|
|
21097
20923
|
};
|
|
21098
20924
|
var CustomOptions = ({ label, value }) => {
|
|
21099
|
-
return /* @__PURE__ */
|
|
20925
|
+
return /* @__PURE__ */ jsx120(StatusBullet, { status: label, message: value });
|
|
21100
20926
|
};
|
|
21101
20927
|
var StatusMultiEditor = ({
|
|
21102
20928
|
options,
|
|
21103
20929
|
value,
|
|
21104
|
-
|
|
20930
|
+
disabled: disabled2,
|
|
21105
20931
|
readOnly,
|
|
21106
20932
|
onChange,
|
|
21107
20933
|
valueTestId
|
|
21108
20934
|
}) => {
|
|
21109
20935
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
21110
|
-
return /* @__PURE__ */
|
|
20936
|
+
return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
|
|
21111
20937
|
InputComboBox,
|
|
21112
20938
|
{
|
|
21113
20939
|
options,
|
|
@@ -21117,8 +20943,8 @@ var StatusMultiEditor = ({
|
|
|
21117
20943
|
return onChange((_a = e.map((item) => item.value)) != null ? _a : []);
|
|
21118
20944
|
},
|
|
21119
20945
|
formatOptionLabel: CustomOptions,
|
|
21120
|
-
value,
|
|
21121
|
-
isDisabled,
|
|
20946
|
+
value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
|
|
20947
|
+
isDisabled: disabled2,
|
|
21122
20948
|
styles: {
|
|
21123
20949
|
menu(base) {
|
|
21124
20950
|
return {
|
|
@@ -21134,13 +20960,13 @@ var StatusMultiEditor = ({
|
|
|
21134
20960
|
var StatusSingleEditor = ({
|
|
21135
20961
|
options,
|
|
21136
20962
|
value,
|
|
21137
|
-
|
|
20963
|
+
disabled: disabled2,
|
|
21138
20964
|
readOnly,
|
|
21139
20965
|
onChange,
|
|
21140
20966
|
valueTestId
|
|
21141
20967
|
}) => {
|
|
21142
20968
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
21143
|
-
return /* @__PURE__ */
|
|
20969
|
+
return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
|
|
21144
20970
|
InputComboBox,
|
|
21145
20971
|
{
|
|
21146
20972
|
options,
|
|
@@ -21149,8 +20975,8 @@ var StatusSingleEditor = ({
|
|
|
21149
20975
|
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
21150
20976
|
},
|
|
21151
20977
|
formatOptionLabel: CustomOptions,
|
|
21152
|
-
value,
|
|
21153
|
-
isDisabled,
|
|
20978
|
+
value: options == null ? void 0 : options.find((option) => option.value === value),
|
|
20979
|
+
isDisabled: disabled2,
|
|
21154
20980
|
styles: {
|
|
21155
20981
|
menu(base) {
|
|
21156
20982
|
return {
|
|
@@ -21163,9 +20989,15 @@ var StatusSingleEditor = ({
|
|
|
21163
20989
|
}
|
|
21164
20990
|
) });
|
|
21165
20991
|
};
|
|
21166
|
-
var TextEditor = ({
|
|
21167
|
-
|
|
21168
|
-
|
|
20992
|
+
var TextEditor = ({
|
|
20993
|
+
onChange,
|
|
20994
|
+
ariaLabel,
|
|
20995
|
+
value,
|
|
20996
|
+
readOnly,
|
|
20997
|
+
valueTestId
|
|
20998
|
+
}) => {
|
|
20999
|
+
useDebounce2(() => onChange, 500, [value]);
|
|
21000
|
+
return /* @__PURE__ */ jsx120(
|
|
21169
21001
|
Input,
|
|
21170
21002
|
{
|
|
21171
21003
|
showLabel: false,
|
|
@@ -21186,10 +21018,10 @@ var NumberRangeEditor = ({
|
|
|
21186
21018
|
readOnly,
|
|
21187
21019
|
valueTestId
|
|
21188
21020
|
}) => {
|
|
21189
|
-
const [minValue, setMinValue] =
|
|
21190
|
-
const [maxValue, setMaxValue] =
|
|
21191
|
-
const [error, setError] =
|
|
21192
|
-
|
|
21021
|
+
const [minValue, setMinValue] = useState16("");
|
|
21022
|
+
const [maxValue, setMaxValue] = useState16("");
|
|
21023
|
+
const [error, setError] = useState16("");
|
|
21024
|
+
useEffect17(() => {
|
|
21193
21025
|
if (!maxValue && !minValue) {
|
|
21194
21026
|
return;
|
|
21195
21027
|
}
|
|
@@ -21208,9 +21040,9 @@ var NumberRangeEditor = ({
|
|
|
21208
21040
|
setError("");
|
|
21209
21041
|
onChange([minValue, maxValue]);
|
|
21210
21042
|
}, [maxValue, minValue, setError]);
|
|
21211
|
-
return /* @__PURE__ */
|
|
21212
|
-
/* @__PURE__ */
|
|
21213
|
-
/* @__PURE__ */
|
|
21043
|
+
return /* @__PURE__ */ jsxs81(Fragment19, { children: [
|
|
21044
|
+
/* @__PURE__ */ jsxs81("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
21045
|
+
/* @__PURE__ */ jsx120(
|
|
21214
21046
|
Input,
|
|
21215
21047
|
{
|
|
21216
21048
|
label: `${ariaLabel}-min`,
|
|
@@ -21225,7 +21057,7 @@ var NumberRangeEditor = ({
|
|
|
21225
21057
|
readOnly
|
|
21226
21058
|
}
|
|
21227
21059
|
),
|
|
21228
|
-
/* @__PURE__ */
|
|
21060
|
+
/* @__PURE__ */ jsx120(
|
|
21229
21061
|
Input,
|
|
21230
21062
|
{
|
|
21231
21063
|
type: "number",
|
|
@@ -21241,7 +21073,7 @@ var NumberRangeEditor = ({
|
|
|
21241
21073
|
}
|
|
21242
21074
|
)
|
|
21243
21075
|
] }),
|
|
21244
|
-
/* @__PURE__ */
|
|
21076
|
+
/* @__PURE__ */ jsx120(ErrorContainer, { errorMessage: error })
|
|
21245
21077
|
] });
|
|
21246
21078
|
};
|
|
21247
21079
|
var NumberEditor = ({
|
|
@@ -21252,7 +21084,7 @@ var NumberEditor = ({
|
|
|
21252
21084
|
readOnly,
|
|
21253
21085
|
valueTestId
|
|
21254
21086
|
}) => {
|
|
21255
|
-
return /* @__PURE__ */
|
|
21087
|
+
return /* @__PURE__ */ jsx120(
|
|
21256
21088
|
Input,
|
|
21257
21089
|
{
|
|
21258
21090
|
label: ariaLabel,
|
|
@@ -21275,7 +21107,7 @@ var DateEditor = ({
|
|
|
21275
21107
|
readOnly,
|
|
21276
21108
|
valueTestId
|
|
21277
21109
|
}) => {
|
|
21278
|
-
return /* @__PURE__ */
|
|
21110
|
+
return /* @__PURE__ */ jsx120(
|
|
21279
21111
|
Input,
|
|
21280
21112
|
{
|
|
21281
21113
|
type: "date",
|
|
@@ -21297,10 +21129,10 @@ var DateRangeEditor = ({
|
|
|
21297
21129
|
readOnly,
|
|
21298
21130
|
valueTestId
|
|
21299
21131
|
}) => {
|
|
21300
|
-
const [minDateValue, setMinDateValue] =
|
|
21301
|
-
const [maxDateValue, setMaxDateValue] =
|
|
21302
|
-
const [error, setError] =
|
|
21303
|
-
|
|
21132
|
+
const [minDateValue, setMinDateValue] = useState16(value ? value[0] : "");
|
|
21133
|
+
const [maxDateValue, setMaxDateValue] = useState16(value ? value[1] : "");
|
|
21134
|
+
const [error, setError] = useState16("");
|
|
21135
|
+
useEffect17(() => {
|
|
21304
21136
|
if (!minDateValue || !maxDateValue) {
|
|
21305
21137
|
return;
|
|
21306
21138
|
}
|
|
@@ -21331,9 +21163,9 @@ var DateRangeEditor = ({
|
|
|
21331
21163
|
setError("");
|
|
21332
21164
|
onChange([minDateValue, maxDateValue]);
|
|
21333
21165
|
}, [minDateValue, maxDateValue, setError]);
|
|
21334
|
-
return /* @__PURE__ */
|
|
21335
|
-
/* @__PURE__ */
|
|
21336
|
-
/* @__PURE__ */
|
|
21166
|
+
return /* @__PURE__ */ jsxs81(Fragment19, { children: [
|
|
21167
|
+
/* @__PURE__ */ jsxs81("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
21168
|
+
/* @__PURE__ */ jsx120(
|
|
21337
21169
|
Input,
|
|
21338
21170
|
{
|
|
21339
21171
|
label: `${ariaLabel}-min-date`,
|
|
@@ -21346,7 +21178,7 @@ var DateRangeEditor = ({
|
|
|
21346
21178
|
readOnly
|
|
21347
21179
|
}
|
|
21348
21180
|
),
|
|
21349
|
-
/* @__PURE__ */
|
|
21181
|
+
/* @__PURE__ */ jsx120(
|
|
21350
21182
|
Input,
|
|
21351
21183
|
{
|
|
21352
21184
|
label: `${ariaLabel}-max-date`,
|
|
@@ -21360,18 +21192,19 @@ var DateRangeEditor = ({
|
|
|
21360
21192
|
}
|
|
21361
21193
|
)
|
|
21362
21194
|
] }),
|
|
21363
|
-
/* @__PURE__ */
|
|
21195
|
+
/* @__PURE__ */ jsx120(ErrorContainer, { errorMessage: error })
|
|
21364
21196
|
] });
|
|
21365
21197
|
};
|
|
21366
21198
|
var FilterEditorRenderer = ({ editorType, ...props }) => {
|
|
21367
|
-
const
|
|
21199
|
+
const { filterMapper: contextFilterMapper } = useSearchAndFilter();
|
|
21200
|
+
const Editor = contextFilterMapper == null ? void 0 : contextFilterMapper[editorType];
|
|
21368
21201
|
if (!Editor) {
|
|
21369
21202
|
return null;
|
|
21370
21203
|
}
|
|
21371
21204
|
if (editorType === "empty") {
|
|
21372
21205
|
return null;
|
|
21373
21206
|
}
|
|
21374
|
-
return /* @__PURE__ */
|
|
21207
|
+
return /* @__PURE__ */ jsx120(Editor, { ...props });
|
|
21375
21208
|
};
|
|
21376
21209
|
var filterMapper = {
|
|
21377
21210
|
multiChoice: FilterMultiChoiceEditor,
|
|
@@ -21386,14 +21219,14 @@ var filterMapper = {
|
|
|
21386
21219
|
empty: null
|
|
21387
21220
|
};
|
|
21388
21221
|
var ErrorContainer = ({ errorMessage }) => {
|
|
21389
|
-
return /* @__PURE__ */
|
|
21222
|
+
return /* @__PURE__ */ jsx120(
|
|
21390
21223
|
"div",
|
|
21391
21224
|
{
|
|
21392
21225
|
css: {
|
|
21393
21226
|
gridColumn: "span 6",
|
|
21394
21227
|
order: 6
|
|
21395
21228
|
},
|
|
21396
|
-
children: /* @__PURE__ */
|
|
21229
|
+
children: /* @__PURE__ */ jsx120(FieldMessage, { errorMessage })
|
|
21397
21230
|
}
|
|
21398
21231
|
);
|
|
21399
21232
|
};
|
|
@@ -21403,6 +21236,228 @@ var twoColumnGrid = {
|
|
|
21403
21236
|
gap: "var(--spacing-sm);"
|
|
21404
21237
|
};
|
|
21405
21238
|
|
|
21239
|
+
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
21240
|
+
import { jsx as jsx121 } from "@emotion/react/jsx-runtime";
|
|
21241
|
+
var SearchAndFilterContext = createContext6({
|
|
21242
|
+
searchTerm: "",
|
|
21243
|
+
setSearchTerm: () => {
|
|
21244
|
+
},
|
|
21245
|
+
filterVisibility: void 0,
|
|
21246
|
+
setFilterVisibility: () => {
|
|
21247
|
+
},
|
|
21248
|
+
filters: [],
|
|
21249
|
+
setFilters: () => {
|
|
21250
|
+
},
|
|
21251
|
+
handleAddFilter: () => {
|
|
21252
|
+
},
|
|
21253
|
+
handleResetFilters: () => {
|
|
21254
|
+
},
|
|
21255
|
+
handleDeleteFilter: () => {
|
|
21256
|
+
},
|
|
21257
|
+
setSortBy: () => {
|
|
21258
|
+
},
|
|
21259
|
+
sortByValue: "",
|
|
21260
|
+
filterOptions: [],
|
|
21261
|
+
sortOptions: [],
|
|
21262
|
+
validFilterQuery: [],
|
|
21263
|
+
filterMapper: {},
|
|
21264
|
+
totalResults: 0
|
|
21265
|
+
});
|
|
21266
|
+
var SearchAndFilterProvider = ({
|
|
21267
|
+
filters,
|
|
21268
|
+
filterOptions,
|
|
21269
|
+
sortOptions,
|
|
21270
|
+
defaultSortByValue,
|
|
21271
|
+
filterMode: filterMode3 = void 0,
|
|
21272
|
+
onSearchChange,
|
|
21273
|
+
onChange,
|
|
21274
|
+
onSortChange,
|
|
21275
|
+
resetFilterValues = [],
|
|
21276
|
+
totalResults,
|
|
21277
|
+
filterMapper: filterMapper2 = filterMapper,
|
|
21278
|
+
children
|
|
21279
|
+
}) => {
|
|
21280
|
+
const [searchTerm, setSearchTerm] = useState17("");
|
|
21281
|
+
const deferredSearchTerm = useDeferredValue2(searchTerm);
|
|
21282
|
+
const [filterVisibility, setFilterVisibility] = useState17(filterMode3);
|
|
21283
|
+
const [sortByValue, setSortByValue] = useState17(defaultSortByValue);
|
|
21284
|
+
const handleSearchTerm = useCallback10(
|
|
21285
|
+
(term) => {
|
|
21286
|
+
setSearchTerm(term);
|
|
21287
|
+
onSearchChange == null ? void 0 : onSearchChange(term);
|
|
21288
|
+
},
|
|
21289
|
+
[setSearchTerm, onSearchChange]
|
|
21290
|
+
);
|
|
21291
|
+
const handleOnSortChange = useCallback10(
|
|
21292
|
+
(sort) => {
|
|
21293
|
+
setSortByValue(sort);
|
|
21294
|
+
onSortChange(sort);
|
|
21295
|
+
},
|
|
21296
|
+
[onSortChange]
|
|
21297
|
+
);
|
|
21298
|
+
const handleToggleFilterVisibilty = useCallback10(
|
|
21299
|
+
(mode) => setFilterVisibility(mode),
|
|
21300
|
+
[setFilterVisibility]
|
|
21301
|
+
);
|
|
21302
|
+
const handleAddFilter = useCallback10(() => {
|
|
21303
|
+
onChange([...filters, { field: "", operator: "", value: "" }]);
|
|
21304
|
+
}, [filters, onChange]);
|
|
21305
|
+
const handleResetFilters = useCallback10(() => {
|
|
21306
|
+
onChange(resetFilterValues);
|
|
21307
|
+
}, [onChange, resetFilterValues]);
|
|
21308
|
+
const handleDeleteFilter = useCallback10(
|
|
21309
|
+
(index) => {
|
|
21310
|
+
const remainingFilters = filters.filter((_, i) => i !== index);
|
|
21311
|
+
onChange(remainingFilters);
|
|
21312
|
+
},
|
|
21313
|
+
[filters, onChange]
|
|
21314
|
+
);
|
|
21315
|
+
const validFilterQuery = useMemo6(() => {
|
|
21316
|
+
const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
|
|
21317
|
+
if (hasValidFilters) {
|
|
21318
|
+
return filters;
|
|
21319
|
+
}
|
|
21320
|
+
}, [filters]);
|
|
21321
|
+
useEffect18(() => {
|
|
21322
|
+
if (filterVisibility) {
|
|
21323
|
+
const handleEscKeyFilterClose = (e) => {
|
|
21324
|
+
if (e.key === "Escape") {
|
|
21325
|
+
setFilterVisibility(void 0);
|
|
21326
|
+
}
|
|
21327
|
+
};
|
|
21328
|
+
document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
21329
|
+
return () => {
|
|
21330
|
+
document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
21331
|
+
};
|
|
21332
|
+
}
|
|
21333
|
+
}, [filterVisibility]);
|
|
21334
|
+
return /* @__PURE__ */ jsx121(
|
|
21335
|
+
SearchAndFilterContext.Provider,
|
|
21336
|
+
{
|
|
21337
|
+
value: {
|
|
21338
|
+
searchTerm: deferredSearchTerm,
|
|
21339
|
+
setSearchTerm: (e) => handleSearchTerm(e),
|
|
21340
|
+
setSortBy: (e) => handleOnSortChange(e),
|
|
21341
|
+
sortByValue,
|
|
21342
|
+
filterVisibility,
|
|
21343
|
+
setFilterVisibility: (e) => handleToggleFilterVisibilty(e),
|
|
21344
|
+
filters,
|
|
21345
|
+
setFilters: (e) => onChange(e),
|
|
21346
|
+
handleAddFilter,
|
|
21347
|
+
handleResetFilters,
|
|
21348
|
+
handleDeleteFilter,
|
|
21349
|
+
filterOptions,
|
|
21350
|
+
sortOptions,
|
|
21351
|
+
validFilterQuery,
|
|
21352
|
+
totalResults,
|
|
21353
|
+
filterMapper: filterMapper2
|
|
21354
|
+
},
|
|
21355
|
+
children: /* @__PURE__ */ jsx121(VerticalRhythm, { children })
|
|
21356
|
+
}
|
|
21357
|
+
);
|
|
21358
|
+
};
|
|
21359
|
+
var useSearchAndFilter = () => {
|
|
21360
|
+
const value = useContext7(SearchAndFilterContext);
|
|
21361
|
+
return { ...value };
|
|
21362
|
+
};
|
|
21363
|
+
|
|
21364
|
+
// src/components/SearchAndFilter/FilterControls.tsx
|
|
21365
|
+
import { Fragment as Fragment20, jsx as jsx122, jsxs as jsxs82 } from "@emotion/react/jsx-runtime";
|
|
21366
|
+
var FilterControls = ({
|
|
21367
|
+
children,
|
|
21368
|
+
defaultSortByValue,
|
|
21369
|
+
hideSearchInput
|
|
21370
|
+
}) => {
|
|
21371
|
+
var _a, _b, _c;
|
|
21372
|
+
const {
|
|
21373
|
+
setFilterVisibility,
|
|
21374
|
+
filterVisibility,
|
|
21375
|
+
setSearchTerm,
|
|
21376
|
+
validFilterQuery,
|
|
21377
|
+
searchTerm,
|
|
21378
|
+
sortByValue,
|
|
21379
|
+
filterOptions
|
|
21380
|
+
} = useSearchAndFilter();
|
|
21381
|
+
const [initialSortValue, setInitialSortValue] = useState18(sortByValue);
|
|
21382
|
+
const [localeSearchTerm, setLocaleSearchTerm] = useState18("");
|
|
21383
|
+
const [userHasChangedSortByValue, setUserHasChangedSortByValue] = useState18(false);
|
|
21384
|
+
useDebounce3(
|
|
21385
|
+
() => {
|
|
21386
|
+
setSearchTerm(localeSearchTerm);
|
|
21387
|
+
},
|
|
21388
|
+
300,
|
|
21389
|
+
[localeSearchTerm, searchTerm]
|
|
21390
|
+
);
|
|
21391
|
+
useEffect19(() => {
|
|
21392
|
+
if (searchTerm === "") {
|
|
21393
|
+
setLocaleSearchTerm("");
|
|
21394
|
+
}
|
|
21395
|
+
}, [searchTerm]);
|
|
21396
|
+
const handleFilterToggle = (mode) => {
|
|
21397
|
+
if (filterVisibility === "filters" && mode === "filters" || filterVisibility === "sort" && mode === "sort") {
|
|
21398
|
+
return setFilterVisibility(void 0);
|
|
21399
|
+
}
|
|
21400
|
+
return setFilterVisibility(mode);
|
|
21401
|
+
};
|
|
21402
|
+
const sortValue = (sortByValue != null ? sortByValue : defaultSortByValue).split("_");
|
|
21403
|
+
const sortDirection = sortValue == null ? void 0 : sortValue.pop();
|
|
21404
|
+
const sortField = sortValue == null ? void 0 : sortValue.join("_");
|
|
21405
|
+
const sortOn = sortField.startsWith("fields.") ? "contentTypeFields" : "metadata";
|
|
21406
|
+
const sortByValueLabel = (_c = (_b = (_a = filterOptions == null ? void 0 : filterOptions.find((op) => op.value === sortOn)) == null ? void 0 : _a.options) == null ? void 0 : _b.find((f) => f.value === sortField)) == null ? void 0 : _c.label;
|
|
21407
|
+
const sortByIcon = userHasChangedSortByValue ? sortDirection === "ASC" ? "arrow-up" : "arrow-down" : "sort-az";
|
|
21408
|
+
useEffectOnce(() => {
|
|
21409
|
+
setInitialSortValue(sortByValue);
|
|
21410
|
+
});
|
|
21411
|
+
useEffect19(() => {
|
|
21412
|
+
if (initialSortValue !== sortByValue) {
|
|
21413
|
+
setUserHasChangedSortByValue(true);
|
|
21414
|
+
}
|
|
21415
|
+
}, [initialSortValue, sortByValue]);
|
|
21416
|
+
return /* @__PURE__ */ jsxs82(Fragment20, { children: [
|
|
21417
|
+
/* @__PURE__ */ jsx122(
|
|
21418
|
+
FilterButton2,
|
|
21419
|
+
{
|
|
21420
|
+
"aria-controls": "search-and-filter-options",
|
|
21421
|
+
"aria-label": "filter options",
|
|
21422
|
+
"aria-haspopup": "true",
|
|
21423
|
+
"aria-expanded": filterVisibility === "filters",
|
|
21424
|
+
filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
|
|
21425
|
+
onClick: () => handleFilterToggle("filters"),
|
|
21426
|
+
dataTestId: "filters-button"
|
|
21427
|
+
}
|
|
21428
|
+
),
|
|
21429
|
+
/* @__PURE__ */ jsx122(
|
|
21430
|
+
FilterButton2,
|
|
21431
|
+
{
|
|
21432
|
+
"aria-controls": "search-and-filter-sortBy",
|
|
21433
|
+
"aria-label": "sort by options",
|
|
21434
|
+
"aria-haspopup": "true",
|
|
21435
|
+
text: !userHasChangedSortByValue ? "Sort" : sortByValueLabel,
|
|
21436
|
+
icon: sortByIcon,
|
|
21437
|
+
"aria-expanded": filterVisibility === "sort",
|
|
21438
|
+
hasSelectedValue: sortByValue !== "",
|
|
21439
|
+
onClick: () => handleFilterToggle("sort"),
|
|
21440
|
+
dataTestId: "sort-by-button"
|
|
21441
|
+
}
|
|
21442
|
+
),
|
|
21443
|
+
hideSearchInput ? null : /* @__PURE__ */ jsx122(
|
|
21444
|
+
InputKeywordSearch,
|
|
21445
|
+
{
|
|
21446
|
+
placeholder: "Search...",
|
|
21447
|
+
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
21448
|
+
value: localeSearchTerm,
|
|
21449
|
+
compact: true,
|
|
21450
|
+
rounded: true,
|
|
21451
|
+
css: SearchInput
|
|
21452
|
+
}
|
|
21453
|
+
),
|
|
21454
|
+
children
|
|
21455
|
+
] });
|
|
21456
|
+
};
|
|
21457
|
+
|
|
21458
|
+
// src/components/SearchAndFilter/FilterItem.tsx
|
|
21459
|
+
import { useMemo as useMemo7 } from "react";
|
|
21460
|
+
|
|
21406
21461
|
// src/components/SearchAndFilter/FilterMenu.tsx
|
|
21407
21462
|
import React24, { useEffect as useEffect20 } from "react";
|
|
21408
21463
|
import { jsx as jsx123, jsxs as jsxs83 } from "@emotion/react/jsx-runtime";
|
|
@@ -21473,7 +21528,7 @@ var FilterItem = ({
|
|
|
21473
21528
|
const operatorLabel = filters[index].operator !== "" ? `operator ${filters[index].operator}` : "unknown operator";
|
|
21474
21529
|
const metaDataLabel = filters[index].value !== "" ? `value ${filters[index].value}` : "unknown value";
|
|
21475
21530
|
const metaDataPossibleOptions = (_b = (_a = operatorOptions.find((op) => filters[index].operator === op.value)) == null ? void 0 : _a.editorType) != null ? _b : "singleChoice";
|
|
21476
|
-
const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly } = useMemo7(() => {
|
|
21531
|
+
const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly, bindable } = useMemo7(() => {
|
|
21477
21532
|
var _a2;
|
|
21478
21533
|
const currentSelectedFilter = filterOptions.find((item) => {
|
|
21479
21534
|
var _a3;
|
|
@@ -21486,19 +21541,14 @@ var FilterItem = ({
|
|
|
21486
21541
|
const selectedOperatorValue2 = operatorOptions == null ? void 0 : operatorOptions.find((item) => {
|
|
21487
21542
|
return filters[index].operator === item.value;
|
|
21488
21543
|
});
|
|
21489
|
-
const selectedMetaValue2 = valueOptions.filter((item) => {
|
|
21490
|
-
if (Array.isArray(filters[index].value) && item.value) {
|
|
21491
|
-
return filters[index].value.includes(item.value);
|
|
21492
|
-
}
|
|
21493
|
-
return filters[index].value === item.value;
|
|
21494
|
-
});
|
|
21495
21544
|
return {
|
|
21496
21545
|
selectedFieldValue: selectedFieldValue2,
|
|
21497
21546
|
selectedOperatorValue: selectedOperatorValue2 != null ? selectedOperatorValue2 : void 0,
|
|
21498
|
-
selectedMetaValue:
|
|
21499
|
-
readOnly: isCurrentFieldReadOnly
|
|
21547
|
+
selectedMetaValue: filters[index].value,
|
|
21548
|
+
readOnly: isCurrentFieldReadOnly,
|
|
21549
|
+
bindable: selectedFieldValue2 == null ? void 0 : selectedFieldValue2.bindable
|
|
21500
21550
|
};
|
|
21501
|
-
}, [filters, filterOptions, index, operatorOptions
|
|
21551
|
+
}, [filters, filterOptions, index, operatorOptions]);
|
|
21502
21552
|
const readOnlyProps = readOnly ? {
|
|
21503
21553
|
"aria-readonly": true,
|
|
21504
21554
|
isSearchable: false,
|
|
@@ -21565,7 +21615,8 @@ var FilterItem = ({
|
|
|
21565
21615
|
options: valueOptions,
|
|
21566
21616
|
onChange: (e) => onValueChange(e != null ? e : ""),
|
|
21567
21617
|
readOnly,
|
|
21568
|
-
|
|
21618
|
+
bindable,
|
|
21619
|
+
disabled: !filters[index].operator,
|
|
21569
21620
|
value: selectedMetaValue,
|
|
21570
21621
|
valueTestId: "filter-value"
|
|
21571
21622
|
}
|
|
@@ -21839,6 +21890,7 @@ var SegmentedControl = ({
|
|
|
21839
21890
|
{
|
|
21840
21891
|
css: [segmentedControlStyles, orientation === "vertical" ? segmentedControlVerticalStyles : void 0],
|
|
21841
21892
|
...props,
|
|
21893
|
+
"data-testid": "segmented-control",
|
|
21842
21894
|
children: options.map((option, index) => {
|
|
21843
21895
|
var _a;
|
|
21844
21896
|
if (!option) {
|
|
@@ -22004,6 +22056,7 @@ var SearchAndFilter = ({
|
|
|
22004
22056
|
viewSwitchControls,
|
|
22005
22057
|
resultsContainerView = /* @__PURE__ */ jsx129(SearchAndFilterResultContainer, {}),
|
|
22006
22058
|
children = /* @__PURE__ */ jsx129(FilterModeView, {}),
|
|
22059
|
+
filterMapper: filterMapper2 = filterMapper,
|
|
22007
22060
|
onChange,
|
|
22008
22061
|
onSearchChange,
|
|
22009
22062
|
onSortChange,
|
|
@@ -22023,6 +22076,7 @@ var SearchAndFilter = ({
|
|
|
22023
22076
|
onSortChange,
|
|
22024
22077
|
totalResults,
|
|
22025
22078
|
resetFilterValues,
|
|
22079
|
+
filterMapper: filterMapper2,
|
|
22026
22080
|
children: /* @__PURE__ */ jsxs88(VerticalRhythm, { css: SearchAndFilterContainer, "data-testid": "search-and-filter", children: [
|
|
22027
22081
|
/* @__PURE__ */ jsxs88("div", { css: SearchAndFilterOutterControlWrapper(viewSwitchControls ? "1fr auto" : "1fr"), children: [
|
|
22028
22082
|
/* @__PURE__ */ jsx129(
|
|
@@ -22658,6 +22712,8 @@ export {
|
|
|
22658
22712
|
CurrentDrawerContext,
|
|
22659
22713
|
DATE_OPERATORS,
|
|
22660
22714
|
DashedBox,
|
|
22715
|
+
DateEditor,
|
|
22716
|
+
DateRangeEditor,
|
|
22661
22717
|
DateTimePicker,
|
|
22662
22718
|
DateTimePickerVariant,
|
|
22663
22719
|
DebouncedInputKeywordSearch,
|
|
@@ -22673,9 +22729,12 @@ export {
|
|
|
22673
22729
|
Fieldset,
|
|
22674
22730
|
FilterButton2 as FilterButton,
|
|
22675
22731
|
FilterControls,
|
|
22732
|
+
FilterEditorRenderer,
|
|
22676
22733
|
FilterItem,
|
|
22677
22734
|
FilterItems,
|
|
22678
22735
|
FilterMenu,
|
|
22736
|
+
FilterMultiChoiceEditor,
|
|
22737
|
+
FilterSingleChoiceEditor,
|
|
22679
22738
|
Heading,
|
|
22680
22739
|
HexModalBackground,
|
|
22681
22740
|
HorizontalRhythm,
|
|
@@ -22722,6 +22781,8 @@ export {
|
|
|
22722
22781
|
ModalDialog,
|
|
22723
22782
|
MultilineChip,
|
|
22724
22783
|
NUMBER_OPERATORS,
|
|
22784
|
+
NumberEditor,
|
|
22785
|
+
NumberRangeEditor,
|
|
22725
22786
|
PageHeaderSection,
|
|
22726
22787
|
Pagination,
|
|
22727
22788
|
Paragraph,
|
|
@@ -22774,6 +22835,8 @@ export {
|
|
|
22774
22835
|
ShortcutRevealer,
|
|
22775
22836
|
Skeleton,
|
|
22776
22837
|
StatusBullet,
|
|
22838
|
+
StatusMultiEditor,
|
|
22839
|
+
StatusSingleEditor,
|
|
22777
22840
|
SuccessMessage,
|
|
22778
22841
|
Switch,
|
|
22779
22842
|
TAKEOVER_STACK_ID,
|
|
@@ -22790,6 +22853,7 @@ export {
|
|
|
22790
22853
|
TableRow,
|
|
22791
22854
|
Tabs,
|
|
22792
22855
|
TakeoverDrawerRenderer,
|
|
22856
|
+
TextEditor,
|
|
22793
22857
|
Textarea,
|
|
22794
22858
|
Theme,
|
|
22795
22859
|
Tile2 as Tile,
|
|
@@ -22834,6 +22898,7 @@ export {
|
|
|
22834
22898
|
fadeInRtl,
|
|
22835
22899
|
fadeInTop,
|
|
22836
22900
|
fadeOutBottom,
|
|
22901
|
+
filterMapper,
|
|
22837
22902
|
fullWidthScreenIcon,
|
|
22838
22903
|
getDrawerAttributes,
|
|
22839
22904
|
getParentPath,
|