@uniformdev/design-system 19.134.3-alpha.28 → 19.135.0
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 +282 -303
- package/dist/index.d.mts +6 -111
- package/dist/index.d.ts +6 -111
- package/dist/index.js +293 -325
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1371,8 +1371,6 @@ __export(src_exports, {
|
|
|
1371
1371
|
CurrentDrawerContext: () => CurrentDrawerContext,
|
|
1372
1372
|
DATE_OPERATORS: () => DATE_OPERATORS,
|
|
1373
1373
|
DashedBox: () => DashedBox,
|
|
1374
|
-
DateEditor: () => DateEditor,
|
|
1375
|
-
DateRangeEditor: () => DateRangeEditor,
|
|
1376
1374
|
DateTimePicker: () => DateTimePicker,
|
|
1377
1375
|
DateTimePickerVariant: () => DateTimePickerVariant,
|
|
1378
1376
|
DebouncedInputKeywordSearch: () => DebouncedInputKeywordSearch,
|
|
@@ -1388,12 +1386,9 @@ __export(src_exports, {
|
|
|
1388
1386
|
Fieldset: () => Fieldset,
|
|
1389
1387
|
FilterButton: () => FilterButton2,
|
|
1390
1388
|
FilterControls: () => FilterControls,
|
|
1391
|
-
FilterEditorRenderer: () => FilterEditorRenderer,
|
|
1392
1389
|
FilterItem: () => FilterItem,
|
|
1393
1390
|
FilterItems: () => FilterItems,
|
|
1394
1391
|
FilterMenu: () => FilterMenu,
|
|
1395
|
-
FilterMultiChoiceEditor: () => FilterMultiChoiceEditor,
|
|
1396
|
-
FilterSingleChoiceEditor: () => FilterSingleChoiceEditor,
|
|
1397
1392
|
Heading: () => Heading,
|
|
1398
1393
|
HexModalBackground: () => HexModalBackground,
|
|
1399
1394
|
HorizontalRhythm: () => HorizontalRhythm,
|
|
@@ -1440,8 +1435,6 @@ __export(src_exports, {
|
|
|
1440
1435
|
ModalDialog: () => ModalDialog,
|
|
1441
1436
|
MultilineChip: () => MultilineChip,
|
|
1442
1437
|
NUMBER_OPERATORS: () => NUMBER_OPERATORS,
|
|
1443
|
-
NumberEditor: () => NumberEditor,
|
|
1444
|
-
NumberRangeEditor: () => NumberRangeEditor,
|
|
1445
1438
|
PageHeaderSection: () => PageHeaderSection,
|
|
1446
1439
|
Pagination: () => Pagination,
|
|
1447
1440
|
Paragraph: () => Paragraph,
|
|
@@ -1494,8 +1487,6 @@ __export(src_exports, {
|
|
|
1494
1487
|
ShortcutRevealer: () => ShortcutRevealer,
|
|
1495
1488
|
Skeleton: () => Skeleton,
|
|
1496
1489
|
StatusBullet: () => StatusBullet,
|
|
1497
|
-
StatusMultiEditor: () => StatusMultiEditor,
|
|
1498
|
-
StatusSingleEditor: () => StatusSingleEditor,
|
|
1499
1490
|
SuccessMessage: () => SuccessMessage,
|
|
1500
1491
|
Switch: () => Switch,
|
|
1501
1492
|
TAKEOVER_STACK_ID: () => TAKEOVER_STACK_ID,
|
|
@@ -1512,7 +1503,6 @@ __export(src_exports, {
|
|
|
1512
1503
|
TableRow: () => TableRow,
|
|
1513
1504
|
Tabs: () => Tabs,
|
|
1514
1505
|
TakeoverDrawerRenderer: () => TakeoverDrawerRenderer,
|
|
1515
|
-
TextEditor: () => TextEditor,
|
|
1516
1506
|
Textarea: () => Textarea,
|
|
1517
1507
|
Theme: () => Theme,
|
|
1518
1508
|
Tile: () => Tile2,
|
|
@@ -1557,7 +1547,6 @@ __export(src_exports, {
|
|
|
1557
1547
|
fadeInRtl: () => fadeInRtl,
|
|
1558
1548
|
fadeInTop: () => fadeInTop,
|
|
1559
1549
|
fadeOutBottom: () => fadeOutBottom,
|
|
1560
|
-
filterMapper: () => filterMapper,
|
|
1561
1550
|
fullWidthScreenIcon: () => fullWidthScreenIcon,
|
|
1562
1551
|
getDrawerAttributes: () => getDrawerAttributes,
|
|
1563
1552
|
getParentPath: () => getParentPath,
|
|
@@ -22563,25 +22552,243 @@ var FilterButton2 = ({
|
|
|
22563
22552
|
|
|
22564
22553
|
// src/components/SearchAndFilter/FilterControls.tsx
|
|
22565
22554
|
init_emotion_jsx_shim();
|
|
22566
|
-
var
|
|
22567
|
-
var
|
|
22555
|
+
var import_react141 = require("react");
|
|
22556
|
+
var import_react_use3 = require("react-use");
|
|
22568
22557
|
|
|
22569
22558
|
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
22570
22559
|
init_emotion_jsx_shim();
|
|
22571
|
-
var
|
|
22560
|
+
var import_react140 = require("react");
|
|
22561
|
+
var import_jsx_runtime119 = require("@emotion/react/jsx-runtime");
|
|
22562
|
+
var SearchAndFilterContext = (0, import_react140.createContext)({
|
|
22563
|
+
searchTerm: "",
|
|
22564
|
+
setSearchTerm: () => {
|
|
22565
|
+
},
|
|
22566
|
+
filterVisibility: void 0,
|
|
22567
|
+
setFilterVisibility: () => {
|
|
22568
|
+
},
|
|
22569
|
+
filters: [],
|
|
22570
|
+
setFilters: () => {
|
|
22571
|
+
},
|
|
22572
|
+
handleAddFilter: () => {
|
|
22573
|
+
},
|
|
22574
|
+
handleResetFilters: () => {
|
|
22575
|
+
},
|
|
22576
|
+
handleDeleteFilter: () => {
|
|
22577
|
+
},
|
|
22578
|
+
setSortBy: () => {
|
|
22579
|
+
},
|
|
22580
|
+
sortByValue: "",
|
|
22581
|
+
filterOptions: [],
|
|
22582
|
+
sortOptions: [],
|
|
22583
|
+
validFilterQuery: [],
|
|
22584
|
+
totalResults: 0
|
|
22585
|
+
});
|
|
22586
|
+
var SearchAndFilterProvider = ({
|
|
22587
|
+
filters,
|
|
22588
|
+
filterOptions,
|
|
22589
|
+
sortOptions,
|
|
22590
|
+
defaultSortByValue,
|
|
22591
|
+
filterMode: filterMode3 = void 0,
|
|
22592
|
+
onSearchChange,
|
|
22593
|
+
onChange,
|
|
22594
|
+
onSortChange,
|
|
22595
|
+
resetFilterValues = [],
|
|
22596
|
+
totalResults,
|
|
22597
|
+
children
|
|
22598
|
+
}) => {
|
|
22599
|
+
const [searchTerm, setSearchTerm] = (0, import_react140.useState)("");
|
|
22600
|
+
const deferredSearchTerm = (0, import_react140.useDeferredValue)(searchTerm);
|
|
22601
|
+
const [filterVisibility, setFilterVisibility] = (0, import_react140.useState)(filterMode3);
|
|
22602
|
+
const [sortByValue, setSortByValue] = (0, import_react140.useState)(defaultSortByValue);
|
|
22603
|
+
const handleSearchTerm = (0, import_react140.useCallback)(
|
|
22604
|
+
(term) => {
|
|
22605
|
+
setSearchTerm(term);
|
|
22606
|
+
onSearchChange == null ? void 0 : onSearchChange(term);
|
|
22607
|
+
},
|
|
22608
|
+
[setSearchTerm, onSearchChange]
|
|
22609
|
+
);
|
|
22610
|
+
const handleOnSortChange = (0, import_react140.useCallback)(
|
|
22611
|
+
(sort) => {
|
|
22612
|
+
setSortByValue(sort);
|
|
22613
|
+
onSortChange(sort);
|
|
22614
|
+
},
|
|
22615
|
+
[onSortChange]
|
|
22616
|
+
);
|
|
22617
|
+
const handleToggleFilterVisibilty = (0, import_react140.useCallback)(
|
|
22618
|
+
(mode) => setFilterVisibility(mode),
|
|
22619
|
+
[setFilterVisibility]
|
|
22620
|
+
);
|
|
22621
|
+
const handleAddFilter = (0, import_react140.useCallback)(() => {
|
|
22622
|
+
onChange([...filters, { field: "", operator: "", value: "" }]);
|
|
22623
|
+
}, [filters, onChange]);
|
|
22624
|
+
const handleResetFilters = (0, import_react140.useCallback)(() => {
|
|
22625
|
+
onChange(resetFilterValues);
|
|
22626
|
+
}, [onChange, resetFilterValues]);
|
|
22627
|
+
const handleDeleteFilter = (0, import_react140.useCallback)(
|
|
22628
|
+
(index) => {
|
|
22629
|
+
const remainingFilters = filters.filter((_, i) => i !== index);
|
|
22630
|
+
onChange(remainingFilters);
|
|
22631
|
+
},
|
|
22632
|
+
[filters, onChange]
|
|
22633
|
+
);
|
|
22634
|
+
const validFilterQuery = (0, import_react140.useMemo)(() => {
|
|
22635
|
+
const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
|
|
22636
|
+
if (hasValidFilters) {
|
|
22637
|
+
return filters;
|
|
22638
|
+
}
|
|
22639
|
+
}, [filters]);
|
|
22640
|
+
(0, import_react140.useEffect)(() => {
|
|
22641
|
+
if (filterVisibility) {
|
|
22642
|
+
const handleEscKeyFilterClose = (e) => {
|
|
22643
|
+
if (e.key === "Escape") {
|
|
22644
|
+
setFilterVisibility(void 0);
|
|
22645
|
+
}
|
|
22646
|
+
};
|
|
22647
|
+
document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
22648
|
+
return () => {
|
|
22649
|
+
document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
22650
|
+
};
|
|
22651
|
+
}
|
|
22652
|
+
}, [filterVisibility]);
|
|
22653
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
22654
|
+
SearchAndFilterContext.Provider,
|
|
22655
|
+
{
|
|
22656
|
+
value: {
|
|
22657
|
+
searchTerm: deferredSearchTerm,
|
|
22658
|
+
setSearchTerm: (e) => handleSearchTerm(e),
|
|
22659
|
+
setSortBy: (e) => handleOnSortChange(e),
|
|
22660
|
+
sortByValue,
|
|
22661
|
+
filterVisibility,
|
|
22662
|
+
setFilterVisibility: (e) => handleToggleFilterVisibilty(e),
|
|
22663
|
+
filters,
|
|
22664
|
+
setFilters: (e) => onChange(e),
|
|
22665
|
+
handleAddFilter,
|
|
22666
|
+
handleResetFilters,
|
|
22667
|
+
handleDeleteFilter,
|
|
22668
|
+
filterOptions,
|
|
22669
|
+
sortOptions,
|
|
22670
|
+
validFilterQuery,
|
|
22671
|
+
totalResults
|
|
22672
|
+
},
|
|
22673
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(VerticalRhythm, { children })
|
|
22674
|
+
}
|
|
22675
|
+
);
|
|
22676
|
+
};
|
|
22677
|
+
var useSearchAndFilter = () => {
|
|
22678
|
+
const value = (0, import_react140.useContext)(SearchAndFilterContext);
|
|
22679
|
+
return { ...value };
|
|
22680
|
+
};
|
|
22681
|
+
|
|
22682
|
+
// src/components/SearchAndFilter/FilterControls.tsx
|
|
22683
|
+
var import_jsx_runtime120 = require("@emotion/react/jsx-runtime");
|
|
22684
|
+
var FilterControls = ({
|
|
22685
|
+
children,
|
|
22686
|
+
defaultSortByValue,
|
|
22687
|
+
hideSearchInput
|
|
22688
|
+
}) => {
|
|
22689
|
+
var _a, _b, _c;
|
|
22690
|
+
const {
|
|
22691
|
+
setFilterVisibility,
|
|
22692
|
+
filterVisibility,
|
|
22693
|
+
setSearchTerm,
|
|
22694
|
+
validFilterQuery,
|
|
22695
|
+
searchTerm,
|
|
22696
|
+
sortByValue,
|
|
22697
|
+
filterOptions
|
|
22698
|
+
} = useSearchAndFilter();
|
|
22699
|
+
const [initialSortValue, setInitialSortValue] = (0, import_react141.useState)(sortByValue);
|
|
22700
|
+
const [localeSearchTerm, setLocaleSearchTerm] = (0, import_react141.useState)("");
|
|
22701
|
+
const [userHasChangedSortByValue, setUserHasChangedSortByValue] = (0, import_react141.useState)(false);
|
|
22702
|
+
(0, import_react_use3.useDebounce)(
|
|
22703
|
+
() => {
|
|
22704
|
+
setSearchTerm(localeSearchTerm);
|
|
22705
|
+
},
|
|
22706
|
+
300,
|
|
22707
|
+
[localeSearchTerm, searchTerm]
|
|
22708
|
+
);
|
|
22709
|
+
(0, import_react141.useEffect)(() => {
|
|
22710
|
+
if (searchTerm === "") {
|
|
22711
|
+
setLocaleSearchTerm("");
|
|
22712
|
+
}
|
|
22713
|
+
}, [searchTerm]);
|
|
22714
|
+
const handleFilterToggle = (mode) => {
|
|
22715
|
+
if (filterVisibility === "filters" && mode === "filters" || filterVisibility === "sort" && mode === "sort") {
|
|
22716
|
+
return setFilterVisibility(void 0);
|
|
22717
|
+
}
|
|
22718
|
+
return setFilterVisibility(mode);
|
|
22719
|
+
};
|
|
22720
|
+
const sortValue = (sortByValue != null ? sortByValue : defaultSortByValue).split("_");
|
|
22721
|
+
const sortDirection = sortValue == null ? void 0 : sortValue.pop();
|
|
22722
|
+
const sortField = sortValue == null ? void 0 : sortValue.join("_");
|
|
22723
|
+
const sortOn = sortField.startsWith("fields.") ? "contentTypeFields" : "metadata";
|
|
22724
|
+
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;
|
|
22725
|
+
const sortByIcon = userHasChangedSortByValue ? sortDirection === "ASC" ? "arrow-up" : "arrow-down" : "sort-az";
|
|
22726
|
+
(0, import_react_use3.useEffectOnce)(() => {
|
|
22727
|
+
setInitialSortValue(sortByValue);
|
|
22728
|
+
});
|
|
22729
|
+
(0, import_react141.useEffect)(() => {
|
|
22730
|
+
if (initialSortValue !== sortByValue) {
|
|
22731
|
+
setUserHasChangedSortByValue(true);
|
|
22732
|
+
}
|
|
22733
|
+
}, [initialSortValue, sortByValue]);
|
|
22734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(import_jsx_runtime120.Fragment, { children: [
|
|
22735
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
22736
|
+
FilterButton2,
|
|
22737
|
+
{
|
|
22738
|
+
"aria-controls": "search-and-filter-options",
|
|
22739
|
+
"aria-label": "filter options",
|
|
22740
|
+
"aria-haspopup": "true",
|
|
22741
|
+
"aria-expanded": filterVisibility === "filters",
|
|
22742
|
+
filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
|
|
22743
|
+
onClick: () => handleFilterToggle("filters"),
|
|
22744
|
+
dataTestId: "filters-button"
|
|
22745
|
+
}
|
|
22746
|
+
),
|
|
22747
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
22748
|
+
FilterButton2,
|
|
22749
|
+
{
|
|
22750
|
+
"aria-controls": "search-and-filter-sortBy",
|
|
22751
|
+
"aria-label": "sort by options",
|
|
22752
|
+
"aria-haspopup": "true",
|
|
22753
|
+
text: !userHasChangedSortByValue ? "Sort" : sortByValueLabel,
|
|
22754
|
+
icon: sortByIcon,
|
|
22755
|
+
"aria-expanded": filterVisibility === "sort",
|
|
22756
|
+
hasSelectedValue: sortByValue !== "",
|
|
22757
|
+
onClick: () => handleFilterToggle("sort"),
|
|
22758
|
+
dataTestId: "sort-by-button"
|
|
22759
|
+
}
|
|
22760
|
+
),
|
|
22761
|
+
hideSearchInput ? null : /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
22762
|
+
InputKeywordSearch,
|
|
22763
|
+
{
|
|
22764
|
+
placeholder: "Search...",
|
|
22765
|
+
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
22766
|
+
value: localeSearchTerm,
|
|
22767
|
+
compact: true,
|
|
22768
|
+
rounded: true,
|
|
22769
|
+
css: SearchInput
|
|
22770
|
+
}
|
|
22771
|
+
),
|
|
22772
|
+
children
|
|
22773
|
+
] });
|
|
22774
|
+
};
|
|
22775
|
+
|
|
22776
|
+
// src/components/SearchAndFilter/FilterItem.tsx
|
|
22777
|
+
init_emotion_jsx_shim();
|
|
22778
|
+
var import_react145 = require("react");
|
|
22572
22779
|
|
|
22573
22780
|
// src/components/SearchAndFilter/FilterEditor.tsx
|
|
22574
22781
|
init_emotion_jsx_shim();
|
|
22575
|
-
var
|
|
22576
|
-
var
|
|
22782
|
+
var import_react143 = require("react");
|
|
22783
|
+
var import_react_use4 = require("react-use");
|
|
22577
22784
|
|
|
22578
22785
|
// src/components/Validation/StatusBullet.tsx
|
|
22579
22786
|
init_emotion_jsx_shim();
|
|
22580
22787
|
|
|
22581
22788
|
// src/components/Validation/StatusBullet.styles.ts
|
|
22582
22789
|
init_emotion_jsx_shim();
|
|
22583
|
-
var
|
|
22584
|
-
var StatusBulletContainer =
|
|
22790
|
+
var import_react142 = require("@emotion/react");
|
|
22791
|
+
var StatusBulletContainer = import_react142.css`
|
|
22585
22792
|
align-items: center;
|
|
22586
22793
|
align-self: center;
|
|
22587
22794
|
color: var(--gray-500);
|
|
@@ -22598,33 +22805,33 @@ var StatusBulletContainer = import_react140.css`
|
|
|
22598
22805
|
display: block;
|
|
22599
22806
|
}
|
|
22600
22807
|
`;
|
|
22601
|
-
var StatusBulletBase =
|
|
22808
|
+
var StatusBulletBase = import_react142.css`
|
|
22602
22809
|
font-size: var(--fs-sm);
|
|
22603
22810
|
&:before {
|
|
22604
22811
|
width: var(--fs-xs);
|
|
22605
22812
|
height: var(--fs-xs);
|
|
22606
22813
|
}
|
|
22607
22814
|
`;
|
|
22608
|
-
var StatusBulletSmall =
|
|
22815
|
+
var StatusBulletSmall = import_react142.css`
|
|
22609
22816
|
font-size: var(--fs-xs);
|
|
22610
22817
|
&:before {
|
|
22611
22818
|
width: var(--fs-xxs);
|
|
22612
22819
|
height: var(--fs-xxs);
|
|
22613
22820
|
}
|
|
22614
22821
|
`;
|
|
22615
|
-
var StatusDraft =
|
|
22822
|
+
var StatusDraft = import_react142.css`
|
|
22616
22823
|
&:before {
|
|
22617
22824
|
background: var(--white);
|
|
22618
22825
|
box-shadow: inset 0 0 0 0.125rem var(--primary-action-default);
|
|
22619
22826
|
}
|
|
22620
22827
|
`;
|
|
22621
|
-
var StatusModified =
|
|
22828
|
+
var StatusModified = import_react142.css`
|
|
22622
22829
|
&:before {
|
|
22623
22830
|
background: linear-gradient(to right, var(--white) 50%, var(--primary-action-default) 50% 100%);
|
|
22624
22831
|
box-shadow: inset 0 0 0 0.125rem var(--primary-action-default);
|
|
22625
22832
|
}
|
|
22626
22833
|
`;
|
|
22627
|
-
var StatusError =
|
|
22834
|
+
var StatusError = import_react142.css`
|
|
22628
22835
|
color: var(--error);
|
|
22629
22836
|
&:before {
|
|
22630
22837
|
/* TODO: replace this with an svg icon */
|
|
@@ -22637,29 +22844,29 @@ var StatusError = import_react140.css`
|
|
|
22637
22844
|
);
|
|
22638
22845
|
}
|
|
22639
22846
|
`;
|
|
22640
|
-
var StatusPublished =
|
|
22847
|
+
var StatusPublished = import_react142.css`
|
|
22641
22848
|
&:before {
|
|
22642
22849
|
background: var(--primary-action-default);
|
|
22643
22850
|
}
|
|
22644
22851
|
`;
|
|
22645
|
-
var StatusOrphan =
|
|
22852
|
+
var StatusOrphan = import_react142.css`
|
|
22646
22853
|
&:before {
|
|
22647
22854
|
background: var(--brand-secondary-5);
|
|
22648
22855
|
}
|
|
22649
22856
|
`;
|
|
22650
|
-
var StatusUnknown =
|
|
22857
|
+
var StatusUnknown = import_react142.css`
|
|
22651
22858
|
&:before {
|
|
22652
22859
|
background: var(--gray-800);
|
|
22653
22860
|
}
|
|
22654
22861
|
`;
|
|
22655
|
-
var StatusDeleted =
|
|
22862
|
+
var StatusDeleted = import_react142.css`
|
|
22656
22863
|
&:before {
|
|
22657
22864
|
background: var(--error);
|
|
22658
22865
|
}
|
|
22659
22866
|
`;
|
|
22660
22867
|
|
|
22661
22868
|
// src/components/Validation/StatusBullet.tsx
|
|
22662
|
-
var
|
|
22869
|
+
var import_jsx_runtime121 = require("@emotion/react/jsx-runtime");
|
|
22663
22870
|
var StatusBullet = ({
|
|
22664
22871
|
status,
|
|
22665
22872
|
hideText = false,
|
|
@@ -22679,7 +22886,7 @@ var StatusBullet = ({
|
|
|
22679
22886
|
Deleted: StatusDeleted
|
|
22680
22887
|
};
|
|
22681
22888
|
const statusSize = size === "base" ? StatusBulletBase : StatusBulletSmall;
|
|
22682
|
-
return /* @__PURE__ */ (0,
|
|
22889
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
22683
22890
|
"span",
|
|
22684
22891
|
{
|
|
22685
22892
|
role: "status",
|
|
@@ -22692,7 +22899,7 @@ var StatusBullet = ({
|
|
|
22692
22899
|
};
|
|
22693
22900
|
|
|
22694
22901
|
// src/components/SearchAndFilter/FilterEditor.tsx
|
|
22695
|
-
var
|
|
22902
|
+
var import_jsx_runtime122 = require("@emotion/react/jsx-runtime");
|
|
22696
22903
|
var readOnlyAttributes = {
|
|
22697
22904
|
isSearchable: false,
|
|
22698
22905
|
menuIsOpen: false,
|
|
@@ -22701,13 +22908,13 @@ var readOnlyAttributes = {
|
|
|
22701
22908
|
var FilterMultiChoiceEditor = ({
|
|
22702
22909
|
value,
|
|
22703
22910
|
options,
|
|
22704
|
-
|
|
22911
|
+
isDisabled,
|
|
22705
22912
|
readOnly,
|
|
22706
22913
|
valueTestId,
|
|
22707
22914
|
...props
|
|
22708
22915
|
}) => {
|
|
22709
22916
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
22710
|
-
return /* @__PURE__ */ (0,
|
|
22917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { "data-testid": valueTestId, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22711
22918
|
InputComboBox,
|
|
22712
22919
|
{
|
|
22713
22920
|
...props,
|
|
@@ -22715,12 +22922,12 @@ var FilterMultiChoiceEditor = ({
|
|
|
22715
22922
|
options,
|
|
22716
22923
|
isMulti: true,
|
|
22717
22924
|
isClearable: true,
|
|
22718
|
-
isDisabled
|
|
22925
|
+
isDisabled,
|
|
22719
22926
|
onChange: (e) => {
|
|
22720
22927
|
var _a;
|
|
22721
|
-
return props.onChange((_a = e
|
|
22928
|
+
return props.onChange((_a = e.map((item) => item.value)) != null ? _a : []);
|
|
22722
22929
|
},
|
|
22723
|
-
value
|
|
22930
|
+
value,
|
|
22724
22931
|
"aria-readonly": readOnly,
|
|
22725
22932
|
styles: {
|
|
22726
22933
|
menu(base) {
|
|
@@ -22737,13 +22944,13 @@ var FilterMultiChoiceEditor = ({
|
|
|
22737
22944
|
var FilterSingleChoiceEditor = ({
|
|
22738
22945
|
options,
|
|
22739
22946
|
value,
|
|
22740
|
-
|
|
22947
|
+
isDisabled,
|
|
22741
22948
|
readOnly,
|
|
22742
22949
|
onChange,
|
|
22743
22950
|
valueTestId
|
|
22744
22951
|
}) => {
|
|
22745
22952
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
22746
|
-
return /* @__PURE__ */ (0,
|
|
22953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { "data-testid": valueTestId, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22747
22954
|
InputComboBox,
|
|
22748
22955
|
{
|
|
22749
22956
|
placeholder: "Type to search...",
|
|
@@ -22753,8 +22960,8 @@ var FilterSingleChoiceEditor = ({
|
|
|
22753
22960
|
var _a;
|
|
22754
22961
|
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
22755
22962
|
},
|
|
22756
|
-
isDisabled
|
|
22757
|
-
value
|
|
22963
|
+
isDisabled,
|
|
22964
|
+
value,
|
|
22758
22965
|
"aria-readonly": readOnly,
|
|
22759
22966
|
styles: {
|
|
22760
22967
|
menu(base) {
|
|
@@ -22769,18 +22976,18 @@ var FilterSingleChoiceEditor = ({
|
|
|
22769
22976
|
) });
|
|
22770
22977
|
};
|
|
22771
22978
|
var CustomOptions = ({ label, value }) => {
|
|
22772
|
-
return /* @__PURE__ */ (0,
|
|
22979
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(StatusBullet, { status: label, message: value });
|
|
22773
22980
|
};
|
|
22774
22981
|
var StatusMultiEditor = ({
|
|
22775
22982
|
options,
|
|
22776
22983
|
value,
|
|
22777
|
-
|
|
22984
|
+
isDisabled,
|
|
22778
22985
|
readOnly,
|
|
22779
22986
|
onChange,
|
|
22780
22987
|
valueTestId
|
|
22781
22988
|
}) => {
|
|
22782
22989
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
22783
|
-
return /* @__PURE__ */ (0,
|
|
22990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { "data-testid": valueTestId, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22784
22991
|
InputComboBox,
|
|
22785
22992
|
{
|
|
22786
22993
|
options,
|
|
@@ -22790,8 +22997,8 @@ var StatusMultiEditor = ({
|
|
|
22790
22997
|
return onChange((_a = e.map((item) => item.value)) != null ? _a : []);
|
|
22791
22998
|
},
|
|
22792
22999
|
formatOptionLabel: CustomOptions,
|
|
22793
|
-
value
|
|
22794
|
-
isDisabled
|
|
23000
|
+
value,
|
|
23001
|
+
isDisabled,
|
|
22795
23002
|
styles: {
|
|
22796
23003
|
menu(base) {
|
|
22797
23004
|
return {
|
|
@@ -22807,13 +23014,13 @@ var StatusMultiEditor = ({
|
|
|
22807
23014
|
var StatusSingleEditor = ({
|
|
22808
23015
|
options,
|
|
22809
23016
|
value,
|
|
22810
|
-
|
|
23017
|
+
isDisabled,
|
|
22811
23018
|
readOnly,
|
|
22812
23019
|
onChange,
|
|
22813
23020
|
valueTestId
|
|
22814
23021
|
}) => {
|
|
22815
23022
|
const readOnlyProps = readOnly ? readOnlyAttributes : {};
|
|
22816
|
-
return /* @__PURE__ */ (0,
|
|
23023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { "data-testid": valueTestId, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22817
23024
|
InputComboBox,
|
|
22818
23025
|
{
|
|
22819
23026
|
options,
|
|
@@ -22822,8 +23029,8 @@ var StatusSingleEditor = ({
|
|
|
22822
23029
|
return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
|
|
22823
23030
|
},
|
|
22824
23031
|
formatOptionLabel: CustomOptions,
|
|
22825
|
-
value
|
|
22826
|
-
isDisabled
|
|
23032
|
+
value,
|
|
23033
|
+
isDisabled,
|
|
22827
23034
|
styles: {
|
|
22828
23035
|
menu(base) {
|
|
22829
23036
|
return {
|
|
@@ -22836,15 +23043,9 @@ var StatusSingleEditor = ({
|
|
|
22836
23043
|
}
|
|
22837
23044
|
) });
|
|
22838
23045
|
};
|
|
22839
|
-
var TextEditor = ({
|
|
22840
|
-
onChange,
|
|
22841
|
-
|
|
22842
|
-
value,
|
|
22843
|
-
readOnly,
|
|
22844
|
-
valueTestId
|
|
22845
|
-
}) => {
|
|
22846
|
-
(0, import_react_use3.useDebounce)(() => onChange, 500, [value]);
|
|
22847
|
-
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
23046
|
+
var TextEditor = ({ onChange, ariaLabel, value, readOnly, valueTestId }) => {
|
|
23047
|
+
(0, import_react_use4.useDebounce)(() => onChange, 500, [value]);
|
|
23048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22848
23049
|
Input,
|
|
22849
23050
|
{
|
|
22850
23051
|
showLabel: false,
|
|
@@ -22865,10 +23066,10 @@ var NumberRangeEditor = ({
|
|
|
22865
23066
|
readOnly,
|
|
22866
23067
|
valueTestId
|
|
22867
23068
|
}) => {
|
|
22868
|
-
const [minValue, setMinValue] = (0,
|
|
22869
|
-
const [maxValue, setMaxValue] = (0,
|
|
22870
|
-
const [error, setError] = (0,
|
|
22871
|
-
(0,
|
|
23069
|
+
const [minValue, setMinValue] = (0, import_react143.useState)("");
|
|
23070
|
+
const [maxValue, setMaxValue] = (0, import_react143.useState)("");
|
|
23071
|
+
const [error, setError] = (0, import_react143.useState)("");
|
|
23072
|
+
(0, import_react143.useEffect)(() => {
|
|
22872
23073
|
if (!maxValue && !minValue) {
|
|
22873
23074
|
return;
|
|
22874
23075
|
}
|
|
@@ -22887,9 +23088,9 @@ var NumberRangeEditor = ({
|
|
|
22887
23088
|
setError("");
|
|
22888
23089
|
onChange([minValue, maxValue]);
|
|
22889
23090
|
}, [maxValue, minValue, setError]);
|
|
22890
|
-
return /* @__PURE__ */ (0,
|
|
22891
|
-
/* @__PURE__ */ (0,
|
|
22892
|
-
/* @__PURE__ */ (0,
|
|
23091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_jsx_runtime122.Fragment, { children: [
|
|
23092
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
23093
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22893
23094
|
Input,
|
|
22894
23095
|
{
|
|
22895
23096
|
label: `${ariaLabel}-min`,
|
|
@@ -22904,7 +23105,7 @@ var NumberRangeEditor = ({
|
|
|
22904
23105
|
readOnly
|
|
22905
23106
|
}
|
|
22906
23107
|
),
|
|
22907
|
-
/* @__PURE__ */ (0,
|
|
23108
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22908
23109
|
Input,
|
|
22909
23110
|
{
|
|
22910
23111
|
type: "number",
|
|
@@ -22920,7 +23121,7 @@ var NumberRangeEditor = ({
|
|
|
22920
23121
|
}
|
|
22921
23122
|
)
|
|
22922
23123
|
] }),
|
|
22923
|
-
/* @__PURE__ */ (0,
|
|
23124
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ErrorContainer, { errorMessage: error })
|
|
22924
23125
|
] });
|
|
22925
23126
|
};
|
|
22926
23127
|
var NumberEditor = ({
|
|
@@ -22931,7 +23132,7 @@ var NumberEditor = ({
|
|
|
22931
23132
|
readOnly,
|
|
22932
23133
|
valueTestId
|
|
22933
23134
|
}) => {
|
|
22934
|
-
return /* @__PURE__ */ (0,
|
|
23135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22935
23136
|
Input,
|
|
22936
23137
|
{
|
|
22937
23138
|
label: ariaLabel,
|
|
@@ -22954,7 +23155,7 @@ var DateEditor = ({
|
|
|
22954
23155
|
readOnly,
|
|
22955
23156
|
valueTestId
|
|
22956
23157
|
}) => {
|
|
22957
|
-
return /* @__PURE__ */ (0,
|
|
23158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
22958
23159
|
Input,
|
|
22959
23160
|
{
|
|
22960
23161
|
type: "date",
|
|
@@ -22976,10 +23177,10 @@ var DateRangeEditor = ({
|
|
|
22976
23177
|
readOnly,
|
|
22977
23178
|
valueTestId
|
|
22978
23179
|
}) => {
|
|
22979
|
-
const [minDateValue, setMinDateValue] = (0,
|
|
22980
|
-
const [maxDateValue, setMaxDateValue] = (0,
|
|
22981
|
-
const [error, setError] = (0,
|
|
22982
|
-
(0,
|
|
23180
|
+
const [minDateValue, setMinDateValue] = (0, import_react143.useState)(value ? value[0] : "");
|
|
23181
|
+
const [maxDateValue, setMaxDateValue] = (0, import_react143.useState)(value ? value[1] : "");
|
|
23182
|
+
const [error, setError] = (0, import_react143.useState)("");
|
|
23183
|
+
(0, import_react143.useEffect)(() => {
|
|
22983
23184
|
if (!minDateValue || !maxDateValue) {
|
|
22984
23185
|
return;
|
|
22985
23186
|
}
|
|
@@ -23010,9 +23211,9 @@ var DateRangeEditor = ({
|
|
|
23010
23211
|
setError("");
|
|
23011
23212
|
onChange([minDateValue, maxDateValue]);
|
|
23012
23213
|
}, [minDateValue, maxDateValue, setError]);
|
|
23013
|
-
return /* @__PURE__ */ (0,
|
|
23014
|
-
/* @__PURE__ */ (0,
|
|
23015
|
-
/* @__PURE__ */ (0,
|
|
23214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_jsx_runtime122.Fragment, { children: [
|
|
23215
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
|
|
23216
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23016
23217
|
Input,
|
|
23017
23218
|
{
|
|
23018
23219
|
label: `${ariaLabel}-min-date`,
|
|
@@ -23025,7 +23226,7 @@ var DateRangeEditor = ({
|
|
|
23025
23226
|
readOnly
|
|
23026
23227
|
}
|
|
23027
23228
|
),
|
|
23028
|
-
/* @__PURE__ */ (0,
|
|
23229
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23029
23230
|
Input,
|
|
23030
23231
|
{
|
|
23031
23232
|
label: `${ariaLabel}-max-date`,
|
|
@@ -23039,19 +23240,18 @@ var DateRangeEditor = ({
|
|
|
23039
23240
|
}
|
|
23040
23241
|
)
|
|
23041
23242
|
] }),
|
|
23042
|
-
/* @__PURE__ */ (0,
|
|
23243
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(ErrorContainer, { errorMessage: error })
|
|
23043
23244
|
] });
|
|
23044
23245
|
};
|
|
23045
23246
|
var FilterEditorRenderer = ({ editorType, ...props }) => {
|
|
23046
|
-
const
|
|
23047
|
-
const Editor = contextFilterMapper == null ? void 0 : contextFilterMapper[editorType];
|
|
23247
|
+
const Editor = filterMapper[editorType];
|
|
23048
23248
|
if (!Editor) {
|
|
23049
23249
|
return null;
|
|
23050
23250
|
}
|
|
23051
23251
|
if (editorType === "empty") {
|
|
23052
23252
|
return null;
|
|
23053
23253
|
}
|
|
23054
|
-
return /* @__PURE__ */ (0,
|
|
23254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Editor, { ...props, disabled: props.isDisabled });
|
|
23055
23255
|
};
|
|
23056
23256
|
var filterMapper = {
|
|
23057
23257
|
multiChoice: FilterMultiChoiceEditor,
|
|
@@ -23066,14 +23266,14 @@ var filterMapper = {
|
|
|
23066
23266
|
empty: null
|
|
23067
23267
|
};
|
|
23068
23268
|
var ErrorContainer = ({ errorMessage }) => {
|
|
23069
|
-
return /* @__PURE__ */ (0,
|
|
23269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23070
23270
|
"div",
|
|
23071
23271
|
{
|
|
23072
23272
|
css: {
|
|
23073
23273
|
gridColumn: "span 6",
|
|
23074
23274
|
order: 6
|
|
23075
23275
|
},
|
|
23076
|
-
children: /* @__PURE__ */ (0,
|
|
23276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(FieldMessage, { errorMessage })
|
|
23077
23277
|
}
|
|
23078
23278
|
);
|
|
23079
23279
|
};
|
|
@@ -23083,229 +23283,6 @@ var twoColumnGrid = {
|
|
|
23083
23283
|
gap: "var(--spacing-sm);"
|
|
23084
23284
|
};
|
|
23085
23285
|
|
|
23086
|
-
// src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
|
|
23087
|
-
var import_jsx_runtime121 = require("@emotion/react/jsx-runtime");
|
|
23088
|
-
var SearchAndFilterContext = (0, import_react142.createContext)({
|
|
23089
|
-
searchTerm: "",
|
|
23090
|
-
setSearchTerm: () => {
|
|
23091
|
-
},
|
|
23092
|
-
filterVisibility: void 0,
|
|
23093
|
-
setFilterVisibility: () => {
|
|
23094
|
-
},
|
|
23095
|
-
filters: [],
|
|
23096
|
-
setFilters: () => {
|
|
23097
|
-
},
|
|
23098
|
-
handleAddFilter: () => {
|
|
23099
|
-
},
|
|
23100
|
-
handleResetFilters: () => {
|
|
23101
|
-
},
|
|
23102
|
-
handleDeleteFilter: () => {
|
|
23103
|
-
},
|
|
23104
|
-
setSortBy: () => {
|
|
23105
|
-
},
|
|
23106
|
-
sortByValue: "",
|
|
23107
|
-
filterOptions: [],
|
|
23108
|
-
sortOptions: [],
|
|
23109
|
-
validFilterQuery: [],
|
|
23110
|
-
filterMapper: {},
|
|
23111
|
-
totalResults: 0
|
|
23112
|
-
});
|
|
23113
|
-
var SearchAndFilterProvider = ({
|
|
23114
|
-
filters,
|
|
23115
|
-
filterOptions,
|
|
23116
|
-
sortOptions,
|
|
23117
|
-
defaultSortByValue,
|
|
23118
|
-
filterMode: filterMode3 = void 0,
|
|
23119
|
-
onSearchChange,
|
|
23120
|
-
onChange,
|
|
23121
|
-
onSortChange,
|
|
23122
|
-
resetFilterValues = [],
|
|
23123
|
-
totalResults,
|
|
23124
|
-
filterMapper: filterMapper2 = filterMapper,
|
|
23125
|
-
children
|
|
23126
|
-
}) => {
|
|
23127
|
-
const [searchTerm, setSearchTerm] = (0, import_react142.useState)("");
|
|
23128
|
-
const deferredSearchTerm = (0, import_react142.useDeferredValue)(searchTerm);
|
|
23129
|
-
const [filterVisibility, setFilterVisibility] = (0, import_react142.useState)(filterMode3);
|
|
23130
|
-
const [sortByValue, setSortByValue] = (0, import_react142.useState)(defaultSortByValue);
|
|
23131
|
-
const handleSearchTerm = (0, import_react142.useCallback)(
|
|
23132
|
-
(term) => {
|
|
23133
|
-
setSearchTerm(term);
|
|
23134
|
-
onSearchChange == null ? void 0 : onSearchChange(term);
|
|
23135
|
-
},
|
|
23136
|
-
[setSearchTerm, onSearchChange]
|
|
23137
|
-
);
|
|
23138
|
-
const handleOnSortChange = (0, import_react142.useCallback)(
|
|
23139
|
-
(sort) => {
|
|
23140
|
-
setSortByValue(sort);
|
|
23141
|
-
onSortChange(sort);
|
|
23142
|
-
},
|
|
23143
|
-
[onSortChange]
|
|
23144
|
-
);
|
|
23145
|
-
const handleToggleFilterVisibilty = (0, import_react142.useCallback)(
|
|
23146
|
-
(mode) => setFilterVisibility(mode),
|
|
23147
|
-
[setFilterVisibility]
|
|
23148
|
-
);
|
|
23149
|
-
const handleAddFilter = (0, import_react142.useCallback)(() => {
|
|
23150
|
-
onChange([...filters, { field: "", operator: "", value: "" }]);
|
|
23151
|
-
}, [filters, onChange]);
|
|
23152
|
-
const handleResetFilters = (0, import_react142.useCallback)(() => {
|
|
23153
|
-
onChange(resetFilterValues);
|
|
23154
|
-
}, [onChange, resetFilterValues]);
|
|
23155
|
-
const handleDeleteFilter = (0, import_react142.useCallback)(
|
|
23156
|
-
(index) => {
|
|
23157
|
-
const remainingFilters = filters.filter((_, i) => i !== index);
|
|
23158
|
-
onChange(remainingFilters);
|
|
23159
|
-
},
|
|
23160
|
-
[filters, onChange]
|
|
23161
|
-
);
|
|
23162
|
-
const validFilterQuery = (0, import_react142.useMemo)(() => {
|
|
23163
|
-
const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
|
|
23164
|
-
if (hasValidFilters) {
|
|
23165
|
-
return filters;
|
|
23166
|
-
}
|
|
23167
|
-
}, [filters]);
|
|
23168
|
-
(0, import_react142.useEffect)(() => {
|
|
23169
|
-
if (filterVisibility) {
|
|
23170
|
-
const handleEscKeyFilterClose = (e) => {
|
|
23171
|
-
if (e.key === "Escape") {
|
|
23172
|
-
setFilterVisibility(void 0);
|
|
23173
|
-
}
|
|
23174
|
-
};
|
|
23175
|
-
document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
23176
|
-
return () => {
|
|
23177
|
-
document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
|
|
23178
|
-
};
|
|
23179
|
-
}
|
|
23180
|
-
}, [filterVisibility]);
|
|
23181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
23182
|
-
SearchAndFilterContext.Provider,
|
|
23183
|
-
{
|
|
23184
|
-
value: {
|
|
23185
|
-
searchTerm: deferredSearchTerm,
|
|
23186
|
-
setSearchTerm: (e) => handleSearchTerm(e),
|
|
23187
|
-
setSortBy: (e) => handleOnSortChange(e),
|
|
23188
|
-
sortByValue,
|
|
23189
|
-
filterVisibility,
|
|
23190
|
-
setFilterVisibility: (e) => handleToggleFilterVisibilty(e),
|
|
23191
|
-
filters,
|
|
23192
|
-
setFilters: (e) => onChange(e),
|
|
23193
|
-
handleAddFilter,
|
|
23194
|
-
handleResetFilters,
|
|
23195
|
-
handleDeleteFilter,
|
|
23196
|
-
filterOptions,
|
|
23197
|
-
sortOptions,
|
|
23198
|
-
validFilterQuery,
|
|
23199
|
-
totalResults,
|
|
23200
|
-
filterMapper: filterMapper2
|
|
23201
|
-
},
|
|
23202
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(VerticalRhythm, { children })
|
|
23203
|
-
}
|
|
23204
|
-
);
|
|
23205
|
-
};
|
|
23206
|
-
var useSearchAndFilter = () => {
|
|
23207
|
-
const value = (0, import_react142.useContext)(SearchAndFilterContext);
|
|
23208
|
-
return { ...value };
|
|
23209
|
-
};
|
|
23210
|
-
|
|
23211
|
-
// src/components/SearchAndFilter/FilterControls.tsx
|
|
23212
|
-
var import_jsx_runtime122 = require("@emotion/react/jsx-runtime");
|
|
23213
|
-
var FilterControls = ({
|
|
23214
|
-
children,
|
|
23215
|
-
defaultSortByValue,
|
|
23216
|
-
hideSearchInput
|
|
23217
|
-
}) => {
|
|
23218
|
-
var _a, _b, _c;
|
|
23219
|
-
const {
|
|
23220
|
-
setFilterVisibility,
|
|
23221
|
-
filterVisibility,
|
|
23222
|
-
setSearchTerm,
|
|
23223
|
-
validFilterQuery,
|
|
23224
|
-
searchTerm,
|
|
23225
|
-
sortByValue,
|
|
23226
|
-
filterOptions
|
|
23227
|
-
} = useSearchAndFilter();
|
|
23228
|
-
const [initialSortValue, setInitialSortValue] = (0, import_react143.useState)(sortByValue);
|
|
23229
|
-
const [localeSearchTerm, setLocaleSearchTerm] = (0, import_react143.useState)("");
|
|
23230
|
-
const [userHasChangedSortByValue, setUserHasChangedSortByValue] = (0, import_react143.useState)(false);
|
|
23231
|
-
(0, import_react_use4.useDebounce)(
|
|
23232
|
-
() => {
|
|
23233
|
-
setSearchTerm(localeSearchTerm);
|
|
23234
|
-
},
|
|
23235
|
-
300,
|
|
23236
|
-
[localeSearchTerm, searchTerm]
|
|
23237
|
-
);
|
|
23238
|
-
(0, import_react143.useEffect)(() => {
|
|
23239
|
-
if (searchTerm === "") {
|
|
23240
|
-
setLocaleSearchTerm("");
|
|
23241
|
-
}
|
|
23242
|
-
}, [searchTerm]);
|
|
23243
|
-
const handleFilterToggle = (mode) => {
|
|
23244
|
-
if (filterVisibility === "filters" && mode === "filters" || filterVisibility === "sort" && mode === "sort") {
|
|
23245
|
-
return setFilterVisibility(void 0);
|
|
23246
|
-
}
|
|
23247
|
-
return setFilterVisibility(mode);
|
|
23248
|
-
};
|
|
23249
|
-
const sortValue = (sortByValue != null ? sortByValue : defaultSortByValue).split("_");
|
|
23250
|
-
const sortDirection = sortValue == null ? void 0 : sortValue.pop();
|
|
23251
|
-
const sortField = sortValue == null ? void 0 : sortValue.join("_");
|
|
23252
|
-
const sortOn = sortField.startsWith("fields.") ? "contentTypeFields" : "metadata";
|
|
23253
|
-
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;
|
|
23254
|
-
const sortByIcon = userHasChangedSortByValue ? sortDirection === "ASC" ? "arrow-up" : "arrow-down" : "sort-az";
|
|
23255
|
-
(0, import_react_use4.useEffectOnce)(() => {
|
|
23256
|
-
setInitialSortValue(sortByValue);
|
|
23257
|
-
});
|
|
23258
|
-
(0, import_react143.useEffect)(() => {
|
|
23259
|
-
if (initialSortValue !== sortByValue) {
|
|
23260
|
-
setUserHasChangedSortByValue(true);
|
|
23261
|
-
}
|
|
23262
|
-
}, [initialSortValue, sortByValue]);
|
|
23263
|
-
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_jsx_runtime122.Fragment, { children: [
|
|
23264
|
-
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23265
|
-
FilterButton2,
|
|
23266
|
-
{
|
|
23267
|
-
"aria-controls": "search-and-filter-options",
|
|
23268
|
-
"aria-label": "filter options",
|
|
23269
|
-
"aria-haspopup": "true",
|
|
23270
|
-
"aria-expanded": filterVisibility === "filters",
|
|
23271
|
-
filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
|
|
23272
|
-
onClick: () => handleFilterToggle("filters"),
|
|
23273
|
-
dataTestId: "filters-button"
|
|
23274
|
-
}
|
|
23275
|
-
),
|
|
23276
|
-
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23277
|
-
FilterButton2,
|
|
23278
|
-
{
|
|
23279
|
-
"aria-controls": "search-and-filter-sortBy",
|
|
23280
|
-
"aria-label": "sort by options",
|
|
23281
|
-
"aria-haspopup": "true",
|
|
23282
|
-
text: !userHasChangedSortByValue ? "Sort" : sortByValueLabel,
|
|
23283
|
-
icon: sortByIcon,
|
|
23284
|
-
"aria-expanded": filterVisibility === "sort",
|
|
23285
|
-
hasSelectedValue: sortByValue !== "",
|
|
23286
|
-
onClick: () => handleFilterToggle("sort"),
|
|
23287
|
-
dataTestId: "sort-by-button"
|
|
23288
|
-
}
|
|
23289
|
-
),
|
|
23290
|
-
hideSearchInput ? null : /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
23291
|
-
InputKeywordSearch,
|
|
23292
|
-
{
|
|
23293
|
-
placeholder: "Search...",
|
|
23294
|
-
onSearchTextChanged: (e) => setLocaleSearchTerm(e),
|
|
23295
|
-
value: localeSearchTerm,
|
|
23296
|
-
compact: true,
|
|
23297
|
-
rounded: true,
|
|
23298
|
-
css: SearchInput
|
|
23299
|
-
}
|
|
23300
|
-
),
|
|
23301
|
-
children
|
|
23302
|
-
] });
|
|
23303
|
-
};
|
|
23304
|
-
|
|
23305
|
-
// src/components/SearchAndFilter/FilterItem.tsx
|
|
23306
|
-
init_emotion_jsx_shim();
|
|
23307
|
-
var import_react145 = require("react");
|
|
23308
|
-
|
|
23309
23286
|
// src/components/SearchAndFilter/FilterMenu.tsx
|
|
23310
23287
|
init_emotion_jsx_shim();
|
|
23311
23288
|
var import_react144 = __toESM(require("react"));
|
|
@@ -23377,7 +23354,7 @@ var FilterItem = ({
|
|
|
23377
23354
|
const operatorLabel = filters[index].operator !== "" ? `operator ${filters[index].operator}` : "unknown operator";
|
|
23378
23355
|
const metaDataLabel = filters[index].value !== "" ? `value ${filters[index].value}` : "unknown value";
|
|
23379
23356
|
const metaDataPossibleOptions = (_b = (_a = operatorOptions.find((op) => filters[index].operator === op.value)) == null ? void 0 : _a.editorType) != null ? _b : "singleChoice";
|
|
23380
|
-
const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly
|
|
23357
|
+
const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly } = (0, import_react145.useMemo)(() => {
|
|
23381
23358
|
var _a2;
|
|
23382
23359
|
const currentSelectedFilter = filterOptions.find((item) => {
|
|
23383
23360
|
var _a3;
|
|
@@ -23390,14 +23367,19 @@ var FilterItem = ({
|
|
|
23390
23367
|
const selectedOperatorValue2 = operatorOptions == null ? void 0 : operatorOptions.find((item) => {
|
|
23391
23368
|
return filters[index].operator === item.value;
|
|
23392
23369
|
});
|
|
23370
|
+
const selectedMetaValue2 = valueOptions.filter((item) => {
|
|
23371
|
+
if (Array.isArray(filters[index].value) && item.value) {
|
|
23372
|
+
return filters[index].value.includes(item.value);
|
|
23373
|
+
}
|
|
23374
|
+
return filters[index].value === item.value;
|
|
23375
|
+
});
|
|
23393
23376
|
return {
|
|
23394
23377
|
selectedFieldValue: selectedFieldValue2,
|
|
23395
23378
|
selectedOperatorValue: selectedOperatorValue2 != null ? selectedOperatorValue2 : void 0,
|
|
23396
|
-
selectedMetaValue: filters[index].value,
|
|
23397
|
-
readOnly: isCurrentFieldReadOnly
|
|
23398
|
-
bindable: selectedFieldValue2 == null ? void 0 : selectedFieldValue2.bindable
|
|
23379
|
+
selectedMetaValue: selectedMetaValue2.length > 0 ? selectedMetaValue2 : filters[index].value,
|
|
23380
|
+
readOnly: isCurrentFieldReadOnly
|
|
23399
23381
|
};
|
|
23400
|
-
}, [filters, filterOptions, index, operatorOptions]);
|
|
23382
|
+
}, [filters, filterOptions, index, operatorOptions, valueOptions]);
|
|
23401
23383
|
const readOnlyProps = readOnly ? {
|
|
23402
23384
|
"aria-readonly": true,
|
|
23403
23385
|
isSearchable: false,
|
|
@@ -23464,8 +23446,7 @@ var FilterItem = ({
|
|
|
23464
23446
|
options: valueOptions,
|
|
23465
23447
|
onChange: (e) => onValueChange(e != null ? e : ""),
|
|
23466
23448
|
readOnly,
|
|
23467
|
-
|
|
23468
|
-
disabled: !filters[index].operator,
|
|
23449
|
+
isDisabled: !filters[index].operator,
|
|
23469
23450
|
value: selectedMetaValue,
|
|
23470
23451
|
valueTestId: "filter-value"
|
|
23471
23452
|
}
|
|
@@ -23917,7 +23898,6 @@ var SearchAndFilter = ({
|
|
|
23917
23898
|
viewSwitchControls,
|
|
23918
23899
|
resultsContainerView = /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(SearchAndFilterResultContainer, {}),
|
|
23919
23900
|
children = /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(FilterModeView, {}),
|
|
23920
|
-
filterMapper: filterMapper2 = filterMapper,
|
|
23921
23901
|
onChange,
|
|
23922
23902
|
onSearchChange,
|
|
23923
23903
|
onSortChange,
|
|
@@ -23937,7 +23917,6 @@ var SearchAndFilter = ({
|
|
|
23937
23917
|
onSortChange,
|
|
23938
23918
|
totalResults,
|
|
23939
23919
|
resetFilterValues,
|
|
23940
|
-
filterMapper: filterMapper2,
|
|
23941
23920
|
children: /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(VerticalRhythm, { css: SearchAndFilterContainer, "data-testid": "search-and-filter", children: [
|
|
23942
23921
|
/* @__PURE__ */ (0, import_jsx_runtime129.jsxs)("div", { css: SearchAndFilterOutterControlWrapper(viewSwitchControls ? "1fr auto" : "1fr"), children: [
|
|
23943
23922
|
/* @__PURE__ */ (0, import_jsx_runtime129.jsx)(
|
|
@@ -24581,8 +24560,6 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24581
24560
|
CurrentDrawerContext,
|
|
24582
24561
|
DATE_OPERATORS,
|
|
24583
24562
|
DashedBox,
|
|
24584
|
-
DateEditor,
|
|
24585
|
-
DateRangeEditor,
|
|
24586
24563
|
DateTimePicker,
|
|
24587
24564
|
DateTimePickerVariant,
|
|
24588
24565
|
DebouncedInputKeywordSearch,
|
|
@@ -24598,12 +24575,9 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24598
24575
|
Fieldset,
|
|
24599
24576
|
FilterButton,
|
|
24600
24577
|
FilterControls,
|
|
24601
|
-
FilterEditorRenderer,
|
|
24602
24578
|
FilterItem,
|
|
24603
24579
|
FilterItems,
|
|
24604
24580
|
FilterMenu,
|
|
24605
|
-
FilterMultiChoiceEditor,
|
|
24606
|
-
FilterSingleChoiceEditor,
|
|
24607
24581
|
Heading,
|
|
24608
24582
|
HexModalBackground,
|
|
24609
24583
|
HorizontalRhythm,
|
|
@@ -24650,8 +24624,6 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24650
24624
|
ModalDialog,
|
|
24651
24625
|
MultilineChip,
|
|
24652
24626
|
NUMBER_OPERATORS,
|
|
24653
|
-
NumberEditor,
|
|
24654
|
-
NumberRangeEditor,
|
|
24655
24627
|
PageHeaderSection,
|
|
24656
24628
|
Pagination,
|
|
24657
24629
|
Paragraph,
|
|
@@ -24704,8 +24676,6 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24704
24676
|
ShortcutRevealer,
|
|
24705
24677
|
Skeleton,
|
|
24706
24678
|
StatusBullet,
|
|
24707
|
-
StatusMultiEditor,
|
|
24708
|
-
StatusSingleEditor,
|
|
24709
24679
|
SuccessMessage,
|
|
24710
24680
|
Switch,
|
|
24711
24681
|
TAKEOVER_STACK_ID,
|
|
@@ -24722,7 +24692,6 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24722
24692
|
TableRow,
|
|
24723
24693
|
Tabs,
|
|
24724
24694
|
TakeoverDrawerRenderer,
|
|
24725
|
-
TextEditor,
|
|
24726
24695
|
Textarea,
|
|
24727
24696
|
Theme,
|
|
24728
24697
|
Tile,
|
|
@@ -24767,7 +24736,6 @@ var ToastContainer = ({ limit = 4 }) => {
|
|
|
24767
24736
|
fadeInRtl,
|
|
24768
24737
|
fadeInTop,
|
|
24769
24738
|
fadeOutBottom,
|
|
24770
|
-
filterMapper,
|
|
24771
24739
|
fullWidthScreenIcon,
|
|
24772
24740
|
getDrawerAttributes,
|
|
24773
24741
|
getParentPath,
|