@uniformdev/design-system 19.134.3-alpha.10 → 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 CHANGED
@@ -17061,6 +17061,7 @@ var MediaCard = ({
17061
17061
  menuItems,
17062
17062
  sideSection: sideSection2,
17063
17063
  onClick,
17064
+ buttonType,
17064
17065
  ...cardProps
17065
17066
  }) => {
17066
17067
  const onStopPropogation = useCallback7((e) => {
@@ -17068,7 +17069,7 @@ var MediaCard = ({
17068
17069
  }, []);
17069
17070
  const hasMenuItems = Array.isArray(menuItems) ? menuItems.length > 0 : Boolean(menuItems);
17070
17071
  return /* @__PURE__ */ jsxs62(Card, { css: cardBase, ...cardProps, onClick, "data-testid": "card-item", children: [
17071
- /* @__PURE__ */ jsx93("button", { tabIndex: -1, css: coverWrapper, children: cover }),
17072
+ /* @__PURE__ */ jsx93("button", { tabIndex: -1, css: coverWrapper, type: buttonType, children: cover }),
17072
17073
  /* @__PURE__ */ jsx93("div", { css: contentWrapper, children: /* @__PURE__ */ jsxs62(HorizontalRhythm, { gap: "sm", justify: "space-between", align: "center", css: { width: "100%" }, children: [
17073
17074
  /* @__PURE__ */ jsxs62(VerticalRhythm, { gap: "0", align: "flex-start", css: { flex: 1, minWidth: 0 }, children: [
17074
17075
  /* @__PURE__ */ jsxs62(HorizontalRhythm, { gap: "xs", align: "center", css: { maxWidth: "100%" }, children: [
@@ -20713,8 +20714,8 @@ var FilterButton2 = ({
20713
20714
  };
20714
20715
 
20715
20716
  // src/components/SearchAndFilter/FilterControls.tsx
20716
- import { useEffect as useEffect18, useState as useState17 } from "react";
20717
- import { useDebounce as useDebounce2, useEffectOnce } from "react-use";
20717
+ import { useEffect as useEffect19, useState as useState18 } from "react";
20718
+ import { useDebounce as useDebounce3, useEffectOnce } from "react-use";
20718
20719
 
20719
20720
  // src/components/SearchAndFilter/hooks/useSearchAndFilter.tsx
20720
20721
  import {
@@ -20722,231 +20723,14 @@ import {
20722
20723
  useCallback as useCallback10,
20723
20724
  useContext as useContext7,
20724
20725
  useDeferredValue as useDeferredValue2,
20725
- useEffect as useEffect17,
20726
+ useEffect as useEffect18,
20726
20727
  useMemo as useMemo6,
20727
- useState as useState16
20728
+ useState as useState17
20728
20729
  } from "react";
20729
- import { jsx as jsx119 } from "@emotion/react/jsx-runtime";
20730
- var SearchAndFilterContext = createContext6({
20731
- searchTerm: "",
20732
- setSearchTerm: () => {
20733
- },
20734
- filterVisibility: void 0,
20735
- setFilterVisibility: () => {
20736
- },
20737
- filters: [],
20738
- setFilters: () => {
20739
- },
20740
- handleAddFilter: () => {
20741
- },
20742
- handleResetFilters: () => {
20743
- },
20744
- handleDeleteFilter: () => {
20745
- },
20746
- setSortBy: () => {
20747
- },
20748
- sortByValue: "",
20749
- filterOptions: [],
20750
- sortOptions: [],
20751
- validFilterQuery: [],
20752
- totalResults: 0
20753
- });
20754
- var SearchAndFilterProvider = ({
20755
- filters,
20756
- filterOptions,
20757
- sortOptions,
20758
- defaultSortByValue,
20759
- filterMode: filterMode3 = void 0,
20760
- onSearchChange,
20761
- onChange,
20762
- onSortChange,
20763
- resetFilterValues = [],
20764
- totalResults,
20765
- children
20766
- }) => {
20767
- const [searchTerm, setSearchTerm] = useState16("");
20768
- const deferredSearchTerm = useDeferredValue2(searchTerm);
20769
- const [filterVisibility, setFilterVisibility] = useState16(filterMode3);
20770
- const [sortByValue, setSortByValue] = useState16(defaultSortByValue);
20771
- const handleSearchTerm = useCallback10(
20772
- (term) => {
20773
- setSearchTerm(term);
20774
- onSearchChange == null ? void 0 : onSearchChange(term);
20775
- },
20776
- [setSearchTerm, onSearchChange]
20777
- );
20778
- const handleOnSortChange = useCallback10(
20779
- (sort) => {
20780
- setSortByValue(sort);
20781
- onSortChange(sort);
20782
- },
20783
- [onSortChange]
20784
- );
20785
- const handleToggleFilterVisibilty = useCallback10(
20786
- (mode) => setFilterVisibility(mode),
20787
- [setFilterVisibility]
20788
- );
20789
- const handleAddFilter = useCallback10(() => {
20790
- onChange([...filters, { field: "", operator: "", value: "" }]);
20791
- }, [filters, onChange]);
20792
- const handleResetFilters = useCallback10(() => {
20793
- onChange(resetFilterValues);
20794
- }, [onChange, resetFilterValues]);
20795
- const handleDeleteFilter = useCallback10(
20796
- (index) => {
20797
- const remainingFilters = filters.filter((_, i) => i !== index);
20798
- onChange(remainingFilters);
20799
- },
20800
- [filters, onChange]
20801
- );
20802
- const validFilterQuery = useMemo6(() => {
20803
- const hasValidFilters = filters.every((f) => f.field && f.operator && f.value);
20804
- if (hasValidFilters) {
20805
- return filters;
20806
- }
20807
- }, [filters]);
20808
- useEffect17(() => {
20809
- if (filterVisibility) {
20810
- const handleEscKeyFilterClose = (e) => {
20811
- if (e.key === "Escape") {
20812
- setFilterVisibility(void 0);
20813
- }
20814
- };
20815
- document.addEventListener("keydown", (e) => handleEscKeyFilterClose(e));
20816
- return () => {
20817
- document.removeEventListener("keydown", (e) => handleEscKeyFilterClose(e));
20818
- };
20819
- }
20820
- }, [filterVisibility]);
20821
- return /* @__PURE__ */ jsx119(
20822
- SearchAndFilterContext.Provider,
20823
- {
20824
- value: {
20825
- searchTerm: deferredSearchTerm,
20826
- setSearchTerm: (e) => handleSearchTerm(e),
20827
- setSortBy: (e) => handleOnSortChange(e),
20828
- sortByValue,
20829
- filterVisibility,
20830
- setFilterVisibility: (e) => handleToggleFilterVisibilty(e),
20831
- filters,
20832
- setFilters: (e) => onChange(e),
20833
- handleAddFilter,
20834
- handleResetFilters,
20835
- handleDeleteFilter,
20836
- filterOptions,
20837
- sortOptions,
20838
- validFilterQuery,
20839
- totalResults
20840
- },
20841
- children: /* @__PURE__ */ jsx119(VerticalRhythm, { children })
20842
- }
20843
- );
20844
- };
20845
- var useSearchAndFilter = () => {
20846
- const value = useContext7(SearchAndFilterContext);
20847
- return { ...value };
20848
- };
20849
-
20850
- // src/components/SearchAndFilter/FilterControls.tsx
20851
- import { Fragment as Fragment19, jsx as jsx120, jsxs as jsxs81 } from "@emotion/react/jsx-runtime";
20852
- var FilterControls = ({
20853
- children,
20854
- defaultSortByValue,
20855
- hideSearchInput
20856
- }) => {
20857
- var _a, _b, _c;
20858
- const {
20859
- setFilterVisibility,
20860
- filterVisibility,
20861
- setSearchTerm,
20862
- validFilterQuery,
20863
- searchTerm,
20864
- sortByValue,
20865
- filterOptions
20866
- } = useSearchAndFilter();
20867
- const [initialSortValue, setInitialSortValue] = useState17(sortByValue);
20868
- const [localeSearchTerm, setLocaleSearchTerm] = useState17("");
20869
- const [userHasChangedSortByValue, setUserHasChangedSortByValue] = useState17(false);
20870
- useDebounce2(
20871
- () => {
20872
- setSearchTerm(localeSearchTerm);
20873
- },
20874
- 300,
20875
- [localeSearchTerm, searchTerm]
20876
- );
20877
- useEffect18(() => {
20878
- if (searchTerm === "") {
20879
- setLocaleSearchTerm("");
20880
- }
20881
- }, [searchTerm]);
20882
- const handleFilterToggle = (mode) => {
20883
- if (filterVisibility === "filters" && mode === "filters" || filterVisibility === "sort" && mode === "sort") {
20884
- return setFilterVisibility(void 0);
20885
- }
20886
- return setFilterVisibility(mode);
20887
- };
20888
- const sortValue = (sortByValue != null ? sortByValue : defaultSortByValue).split("_");
20889
- const sortDirection = sortValue == null ? void 0 : sortValue.pop();
20890
- const sortField = sortValue == null ? void 0 : sortValue.join("_");
20891
- const sortOn = sortField.startsWith("fields.") ? "contentTypeFields" : "metadata";
20892
- 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;
20893
- const sortByIcon = userHasChangedSortByValue ? sortDirection === "ASC" ? "arrow-up" : "arrow-down" : "sort-az";
20894
- useEffectOnce(() => {
20895
- setInitialSortValue(sortByValue);
20896
- });
20897
- useEffect18(() => {
20898
- if (initialSortValue !== sortByValue) {
20899
- setUserHasChangedSortByValue(true);
20900
- }
20901
- }, [initialSortValue, sortByValue]);
20902
- return /* @__PURE__ */ jsxs81(Fragment19, { children: [
20903
- /* @__PURE__ */ jsx120(
20904
- FilterButton2,
20905
- {
20906
- "aria-controls": "search-and-filter-options",
20907
- "aria-label": "filter options",
20908
- "aria-haspopup": "true",
20909
- "aria-expanded": filterVisibility === "filters",
20910
- filterCount: validFilterQuery == null ? void 0 : validFilterQuery.length,
20911
- onClick: () => handleFilterToggle("filters"),
20912
- dataTestId: "filters-button"
20913
- }
20914
- ),
20915
- /* @__PURE__ */ jsx120(
20916
- FilterButton2,
20917
- {
20918
- "aria-controls": "search-and-filter-sortBy",
20919
- "aria-label": "sort by options",
20920
- "aria-haspopup": "true",
20921
- text: !userHasChangedSortByValue ? "Sort" : sortByValueLabel,
20922
- icon: sortByIcon,
20923
- "aria-expanded": filterVisibility === "sort",
20924
- hasSelectedValue: sortByValue !== "",
20925
- onClick: () => handleFilterToggle("sort"),
20926
- dataTestId: "sort-by-button"
20927
- }
20928
- ),
20929
- hideSearchInput ? null : /* @__PURE__ */ jsx120(
20930
- InputKeywordSearch,
20931
- {
20932
- placeholder: "Search...",
20933
- onSearchTextChanged: (e) => setLocaleSearchTerm(e),
20934
- value: localeSearchTerm,
20935
- compact: true,
20936
- rounded: true,
20937
- css: SearchInput
20938
- }
20939
- ),
20940
- children
20941
- ] });
20942
- };
20943
-
20944
- // src/components/SearchAndFilter/FilterItem.tsx
20945
- import { useMemo as useMemo7 } from "react";
20946
20730
 
20947
20731
  // src/components/SearchAndFilter/FilterEditor.tsx
20948
- import { useEffect as useEffect19, useState as useState18 } from "react";
20949
- import { useDebounce as useDebounce3 } from "react-use";
20732
+ import { useEffect as useEffect17, useState as useState16 } from "react";
20733
+ import { useDebounce as useDebounce2 } from "react-use";
20950
20734
 
20951
20735
  // src/components/Validation/StatusBullet.styles.ts
20952
20736
  import { css as css93 } from "@emotion/react";
@@ -21028,7 +20812,7 @@ var StatusDeleted = css93`
21028
20812
  `;
21029
20813
 
21030
20814
  // src/components/Validation/StatusBullet.tsx
21031
- import { jsx as jsx121 } from "@emotion/react/jsx-runtime";
20815
+ import { jsx as jsx119 } from "@emotion/react/jsx-runtime";
21032
20816
  var StatusBullet = ({
21033
20817
  status,
21034
20818
  hideText = false,
@@ -21048,7 +20832,7 @@ var StatusBullet = ({
21048
20832
  Deleted: StatusDeleted
21049
20833
  };
21050
20834
  const statusSize = size === "base" ? StatusBulletBase : StatusBulletSmall;
21051
- return /* @__PURE__ */ jsx121(
20835
+ return /* @__PURE__ */ jsx119(
21052
20836
  "span",
21053
20837
  {
21054
20838
  role: "status",
@@ -21061,7 +20845,7 @@ var StatusBullet = ({
21061
20845
  };
21062
20846
 
21063
20847
  // src/components/SearchAndFilter/FilterEditor.tsx
21064
- import { Fragment as Fragment20, jsx as jsx122, jsxs as jsxs82 } from "@emotion/react/jsx-runtime";
20848
+ import { Fragment as Fragment19, jsx as jsx120, jsxs as jsxs81 } from "@emotion/react/jsx-runtime";
21065
20849
  var readOnlyAttributes = {
21066
20850
  isSearchable: false,
21067
20851
  menuIsOpen: false,
@@ -21070,13 +20854,13 @@ var readOnlyAttributes = {
21070
20854
  var FilterMultiChoiceEditor = ({
21071
20855
  value,
21072
20856
  options,
21073
- isDisabled,
20857
+ disabled: disabled2,
21074
20858
  readOnly,
21075
20859
  valueTestId,
21076
20860
  ...props
21077
20861
  }) => {
21078
20862
  const readOnlyProps = readOnly ? readOnlyAttributes : {};
21079
- return /* @__PURE__ */ jsx122("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx122(
20863
+ return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
21080
20864
  InputComboBox,
21081
20865
  {
21082
20866
  ...props,
@@ -21084,12 +20868,12 @@ var FilterMultiChoiceEditor = ({
21084
20868
  options,
21085
20869
  isMulti: true,
21086
20870
  isClearable: true,
21087
- isDisabled,
20871
+ isDisabled: disabled2,
21088
20872
  onChange: (e) => {
21089
20873
  var _a;
21090
- return props.onChange((_a = e.map((item) => item.value)) != null ? _a : []);
20874
+ return props.onChange((_a = e == null ? void 0 : e.map((option) => option.value)) != null ? _a : []);
21091
20875
  },
21092
- value,
20876
+ value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
21093
20877
  "aria-readonly": readOnly,
21094
20878
  styles: {
21095
20879
  menu(base) {
@@ -21106,13 +20890,13 @@ var FilterMultiChoiceEditor = ({
21106
20890
  var FilterSingleChoiceEditor = ({
21107
20891
  options,
21108
20892
  value,
21109
- isDisabled,
20893
+ disabled: disabled2,
21110
20894
  readOnly,
21111
20895
  onChange,
21112
20896
  valueTestId
21113
20897
  }) => {
21114
20898
  const readOnlyProps = readOnly ? readOnlyAttributes : {};
21115
- return /* @__PURE__ */ jsx122("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx122(
20899
+ return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
21116
20900
  InputComboBox,
21117
20901
  {
21118
20902
  placeholder: "Type to search...",
@@ -21122,8 +20906,8 @@ var FilterSingleChoiceEditor = ({
21122
20906
  var _a;
21123
20907
  return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
21124
20908
  },
21125
- isDisabled,
21126
- value,
20909
+ isDisabled: disabled2,
20910
+ value: options == null ? void 0 : options.find((option) => option.value === value),
21127
20911
  "aria-readonly": readOnly,
21128
20912
  styles: {
21129
20913
  menu(base) {
@@ -21138,18 +20922,18 @@ var FilterSingleChoiceEditor = ({
21138
20922
  ) });
21139
20923
  };
21140
20924
  var CustomOptions = ({ label, value }) => {
21141
- return /* @__PURE__ */ jsx122(StatusBullet, { status: label, message: value });
20925
+ return /* @__PURE__ */ jsx120(StatusBullet, { status: label, message: value });
21142
20926
  };
21143
20927
  var StatusMultiEditor = ({
21144
20928
  options,
21145
20929
  value,
21146
- isDisabled,
20930
+ disabled: disabled2,
21147
20931
  readOnly,
21148
20932
  onChange,
21149
20933
  valueTestId
21150
20934
  }) => {
21151
20935
  const readOnlyProps = readOnly ? readOnlyAttributes : {};
21152
- return /* @__PURE__ */ jsx122("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx122(
20936
+ return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
21153
20937
  InputComboBox,
21154
20938
  {
21155
20939
  options,
@@ -21159,8 +20943,8 @@ var StatusMultiEditor = ({
21159
20943
  return onChange((_a = e.map((item) => item.value)) != null ? _a : []);
21160
20944
  },
21161
20945
  formatOptionLabel: CustomOptions,
21162
- value,
21163
- isDisabled,
20946
+ value: options == null ? void 0 : options.filter((option) => value == null ? void 0 : value.includes(option.value)),
20947
+ isDisabled: disabled2,
21164
20948
  styles: {
21165
20949
  menu(base) {
21166
20950
  return {
@@ -21176,13 +20960,13 @@ var StatusMultiEditor = ({
21176
20960
  var StatusSingleEditor = ({
21177
20961
  options,
21178
20962
  value,
21179
- isDisabled,
20963
+ disabled: disabled2,
21180
20964
  readOnly,
21181
20965
  onChange,
21182
20966
  valueTestId
21183
20967
  }) => {
21184
20968
  const readOnlyProps = readOnly ? readOnlyAttributes : {};
21185
- return /* @__PURE__ */ jsx122("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx122(
20969
+ return /* @__PURE__ */ jsx120("div", { "data-testid": valueTestId, children: /* @__PURE__ */ jsx120(
21186
20970
  InputComboBox,
21187
20971
  {
21188
20972
  options,
@@ -21191,8 +20975,8 @@ var StatusSingleEditor = ({
21191
20975
  return onChange((_a = e == null ? void 0 : e.value) != null ? _a : "");
21192
20976
  },
21193
20977
  formatOptionLabel: CustomOptions,
21194
- value,
21195
- isDisabled,
20978
+ value: options == null ? void 0 : options.find((option) => option.value === value),
20979
+ isDisabled: disabled2,
21196
20980
  styles: {
21197
20981
  menu(base) {
21198
20982
  return {
@@ -21205,9 +20989,15 @@ var StatusSingleEditor = ({
21205
20989
  }
21206
20990
  ) });
21207
20991
  };
21208
- var TextEditor = ({ onChange, ariaLabel, value, readOnly, valueTestId }) => {
21209
- useDebounce3(() => onChange, 500, [value]);
21210
- return /* @__PURE__ */ jsx122(
20992
+ var TextEditor = ({
20993
+ onChange,
20994
+ ariaLabel,
20995
+ value,
20996
+ readOnly,
20997
+ valueTestId
20998
+ }) => {
20999
+ useDebounce2(() => onChange, 500, [value]);
21000
+ return /* @__PURE__ */ jsx120(
21211
21001
  Input,
21212
21002
  {
21213
21003
  showLabel: false,
@@ -21228,10 +21018,10 @@ var NumberRangeEditor = ({
21228
21018
  readOnly,
21229
21019
  valueTestId
21230
21020
  }) => {
21231
- const [minValue, setMinValue] = useState18("");
21232
- const [maxValue, setMaxValue] = useState18("");
21233
- const [error, setError] = useState18("");
21234
- useEffect19(() => {
21021
+ const [minValue, setMinValue] = useState16("");
21022
+ const [maxValue, setMaxValue] = useState16("");
21023
+ const [error, setError] = useState16("");
21024
+ useEffect17(() => {
21235
21025
  if (!maxValue && !minValue) {
21236
21026
  return;
21237
21027
  }
@@ -21250,9 +21040,9 @@ var NumberRangeEditor = ({
21250
21040
  setError("");
21251
21041
  onChange([minValue, maxValue]);
21252
21042
  }, [maxValue, minValue, setError]);
21253
- return /* @__PURE__ */ jsxs82(Fragment20, { children: [
21254
- /* @__PURE__ */ jsxs82("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
21255
- /* @__PURE__ */ jsx122(
21043
+ return /* @__PURE__ */ jsxs81(Fragment19, { children: [
21044
+ /* @__PURE__ */ jsxs81("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
21045
+ /* @__PURE__ */ jsx120(
21256
21046
  Input,
21257
21047
  {
21258
21048
  label: `${ariaLabel}-min`,
@@ -21267,7 +21057,7 @@ var NumberRangeEditor = ({
21267
21057
  readOnly
21268
21058
  }
21269
21059
  ),
21270
- /* @__PURE__ */ jsx122(
21060
+ /* @__PURE__ */ jsx120(
21271
21061
  Input,
21272
21062
  {
21273
21063
  type: "number",
@@ -21283,7 +21073,7 @@ var NumberRangeEditor = ({
21283
21073
  }
21284
21074
  )
21285
21075
  ] }),
21286
- /* @__PURE__ */ jsx122(ErrorContainer, { errorMessage: error })
21076
+ /* @__PURE__ */ jsx120(ErrorContainer, { errorMessage: error })
21287
21077
  ] });
21288
21078
  };
21289
21079
  var NumberEditor = ({
@@ -21294,7 +21084,7 @@ var NumberEditor = ({
21294
21084
  readOnly,
21295
21085
  valueTestId
21296
21086
  }) => {
21297
- return /* @__PURE__ */ jsx122(
21087
+ return /* @__PURE__ */ jsx120(
21298
21088
  Input,
21299
21089
  {
21300
21090
  label: ariaLabel,
@@ -21317,7 +21107,7 @@ var DateEditor = ({
21317
21107
  readOnly,
21318
21108
  valueTestId
21319
21109
  }) => {
21320
- return /* @__PURE__ */ jsx122(
21110
+ return /* @__PURE__ */ jsx120(
21321
21111
  Input,
21322
21112
  {
21323
21113
  type: "date",
@@ -21339,10 +21129,10 @@ var DateRangeEditor = ({
21339
21129
  readOnly,
21340
21130
  valueTestId
21341
21131
  }) => {
21342
- const [minDateValue, setMinDateValue] = useState18(value ? value[0] : "");
21343
- const [maxDateValue, setMaxDateValue] = useState18(value ? value[1] : "");
21344
- const [error, setError] = useState18("");
21345
- useEffect19(() => {
21132
+ const [minDateValue, setMinDateValue] = useState16(value ? value[0] : "");
21133
+ const [maxDateValue, setMaxDateValue] = useState16(value ? value[1] : "");
21134
+ const [error, setError] = useState16("");
21135
+ useEffect17(() => {
21346
21136
  if (!minDateValue || !maxDateValue) {
21347
21137
  return;
21348
21138
  }
@@ -21373,9 +21163,9 @@ var DateRangeEditor = ({
21373
21163
  setError("");
21374
21164
  onChange([minDateValue, maxDateValue]);
21375
21165
  }, [minDateValue, maxDateValue, setError]);
21376
- return /* @__PURE__ */ jsxs82(Fragment20, { children: [
21377
- /* @__PURE__ */ jsxs82("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
21378
- /* @__PURE__ */ jsx122(
21166
+ return /* @__PURE__ */ jsxs81(Fragment19, { children: [
21167
+ /* @__PURE__ */ jsxs81("div", { css: twoColumnGrid, "data-testid": valueTestId, children: [
21168
+ /* @__PURE__ */ jsx120(
21379
21169
  Input,
21380
21170
  {
21381
21171
  label: `${ariaLabel}-min-date`,
@@ -21388,7 +21178,7 @@ var DateRangeEditor = ({
21388
21178
  readOnly
21389
21179
  }
21390
21180
  ),
21391
- /* @__PURE__ */ jsx122(
21181
+ /* @__PURE__ */ jsx120(
21392
21182
  Input,
21393
21183
  {
21394
21184
  label: `${ariaLabel}-max-date`,
@@ -21402,18 +21192,19 @@ var DateRangeEditor = ({
21402
21192
  }
21403
21193
  )
21404
21194
  ] }),
21405
- /* @__PURE__ */ jsx122(ErrorContainer, { errorMessage: error })
21195
+ /* @__PURE__ */ jsx120(ErrorContainer, { errorMessage: error })
21406
21196
  ] });
21407
21197
  };
21408
21198
  var FilterEditorRenderer = ({ editorType, ...props }) => {
21409
- const Editor = filterMapper[editorType];
21199
+ const { filterMapper: contextFilterMapper } = useSearchAndFilter();
21200
+ const Editor = contextFilterMapper == null ? void 0 : contextFilterMapper[editorType];
21410
21201
  if (!Editor) {
21411
21202
  return null;
21412
21203
  }
21413
21204
  if (editorType === "empty") {
21414
21205
  return null;
21415
21206
  }
21416
- return /* @__PURE__ */ jsx122(Editor, { ...props, disabled: props.isDisabled });
21207
+ return /* @__PURE__ */ jsx120(Editor, { ...props });
21417
21208
  };
21418
21209
  var filterMapper = {
21419
21210
  multiChoice: FilterMultiChoiceEditor,
@@ -21428,14 +21219,14 @@ var filterMapper = {
21428
21219
  empty: null
21429
21220
  };
21430
21221
  var ErrorContainer = ({ errorMessage }) => {
21431
- return /* @__PURE__ */ jsx122(
21222
+ return /* @__PURE__ */ jsx120(
21432
21223
  "div",
21433
21224
  {
21434
21225
  css: {
21435
21226
  gridColumn: "span 6",
21436
21227
  order: 6
21437
21228
  },
21438
- children: /* @__PURE__ */ jsx122(FieldMessage, { errorMessage })
21229
+ children: /* @__PURE__ */ jsx120(FieldMessage, { errorMessage })
21439
21230
  }
21440
21231
  );
21441
21232
  };
@@ -21445,6 +21236,228 @@ var twoColumnGrid = {
21445
21236
  gap: "var(--spacing-sm);"
21446
21237
  };
21447
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
+
21448
21461
  // src/components/SearchAndFilter/FilterMenu.tsx
21449
21462
  import React24, { useEffect as useEffect20 } from "react";
21450
21463
  import { jsx as jsx123, jsxs as jsxs83 } from "@emotion/react/jsx-runtime";
@@ -21515,7 +21528,7 @@ var FilterItem = ({
21515
21528
  const operatorLabel = filters[index].operator !== "" ? `operator ${filters[index].operator}` : "unknown operator";
21516
21529
  const metaDataLabel = filters[index].value !== "" ? `value ${filters[index].value}` : "unknown value";
21517
21530
  const metaDataPossibleOptions = (_b = (_a = operatorOptions.find((op) => filters[index].operator === op.value)) == null ? void 0 : _a.editorType) != null ? _b : "singleChoice";
21518
- const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly } = useMemo7(() => {
21531
+ const { selectedFieldValue, selectedOperatorValue, selectedMetaValue, readOnly, bindable } = useMemo7(() => {
21519
21532
  var _a2;
21520
21533
  const currentSelectedFilter = filterOptions.find((item) => {
21521
21534
  var _a3;
@@ -21528,19 +21541,14 @@ var FilterItem = ({
21528
21541
  const selectedOperatorValue2 = operatorOptions == null ? void 0 : operatorOptions.find((item) => {
21529
21542
  return filters[index].operator === item.value;
21530
21543
  });
21531
- const selectedMetaValue2 = valueOptions.filter((item) => {
21532
- if (Array.isArray(filters[index].value) && item.value) {
21533
- return filters[index].value.includes(item.value);
21534
- }
21535
- return filters[index].value === item.value;
21536
- });
21537
21544
  return {
21538
21545
  selectedFieldValue: selectedFieldValue2,
21539
21546
  selectedOperatorValue: selectedOperatorValue2 != null ? selectedOperatorValue2 : void 0,
21540
- selectedMetaValue: selectedMetaValue2.length > 0 ? selectedMetaValue2 : filters[index].value,
21541
- readOnly: isCurrentFieldReadOnly
21547
+ selectedMetaValue: filters[index].value,
21548
+ readOnly: isCurrentFieldReadOnly,
21549
+ bindable: selectedFieldValue2 == null ? void 0 : selectedFieldValue2.bindable
21542
21550
  };
21543
- }, [filters, filterOptions, index, operatorOptions, valueOptions]);
21551
+ }, [filters, filterOptions, index, operatorOptions]);
21544
21552
  const readOnlyProps = readOnly ? {
21545
21553
  "aria-readonly": true,
21546
21554
  isSearchable: false,
@@ -21607,7 +21615,8 @@ var FilterItem = ({
21607
21615
  options: valueOptions,
21608
21616
  onChange: (e) => onValueChange(e != null ? e : ""),
21609
21617
  readOnly,
21610
- isDisabled: !filters[index].operator,
21618
+ bindable,
21619
+ disabled: !filters[index].operator,
21611
21620
  value: selectedMetaValue,
21612
21621
  valueTestId: "filter-value"
21613
21622
  }
@@ -21881,6 +21890,7 @@ var SegmentedControl = ({
21881
21890
  {
21882
21891
  css: [segmentedControlStyles, orientation === "vertical" ? segmentedControlVerticalStyles : void 0],
21883
21892
  ...props,
21893
+ "data-testid": "segmented-control",
21884
21894
  children: options.map((option, index) => {
21885
21895
  var _a;
21886
21896
  if (!option) {
@@ -22046,6 +22056,7 @@ var SearchAndFilter = ({
22046
22056
  viewSwitchControls,
22047
22057
  resultsContainerView = /* @__PURE__ */ jsx129(SearchAndFilterResultContainer, {}),
22048
22058
  children = /* @__PURE__ */ jsx129(FilterModeView, {}),
22059
+ filterMapper: filterMapper2 = filterMapper,
22049
22060
  onChange,
22050
22061
  onSearchChange,
22051
22062
  onSortChange,
@@ -22065,6 +22076,7 @@ var SearchAndFilter = ({
22065
22076
  onSortChange,
22066
22077
  totalResults,
22067
22078
  resetFilterValues,
22079
+ filterMapper: filterMapper2,
22068
22080
  children: /* @__PURE__ */ jsxs88(VerticalRhythm, { css: SearchAndFilterContainer, "data-testid": "search-and-filter", children: [
22069
22081
  /* @__PURE__ */ jsxs88("div", { css: SearchAndFilterOutterControlWrapper(viewSwitchControls ? "1fr auto" : "1fr"), children: [
22070
22082
  /* @__PURE__ */ jsx129(
@@ -22700,6 +22712,8 @@ export {
22700
22712
  CurrentDrawerContext,
22701
22713
  DATE_OPERATORS,
22702
22714
  DashedBox,
22715
+ DateEditor,
22716
+ DateRangeEditor,
22703
22717
  DateTimePicker,
22704
22718
  DateTimePickerVariant,
22705
22719
  DebouncedInputKeywordSearch,
@@ -22715,9 +22729,12 @@ export {
22715
22729
  Fieldset,
22716
22730
  FilterButton2 as FilterButton,
22717
22731
  FilterControls,
22732
+ FilterEditorRenderer,
22718
22733
  FilterItem,
22719
22734
  FilterItems,
22720
22735
  FilterMenu,
22736
+ FilterMultiChoiceEditor,
22737
+ FilterSingleChoiceEditor,
22721
22738
  Heading,
22722
22739
  HexModalBackground,
22723
22740
  HorizontalRhythm,
@@ -22764,6 +22781,8 @@ export {
22764
22781
  ModalDialog,
22765
22782
  MultilineChip,
22766
22783
  NUMBER_OPERATORS,
22784
+ NumberEditor,
22785
+ NumberRangeEditor,
22767
22786
  PageHeaderSection,
22768
22787
  Pagination,
22769
22788
  Paragraph,
@@ -22816,6 +22835,8 @@ export {
22816
22835
  ShortcutRevealer,
22817
22836
  Skeleton,
22818
22837
  StatusBullet,
22838
+ StatusMultiEditor,
22839
+ StatusSingleEditor,
22819
22840
  SuccessMessage,
22820
22841
  Switch,
22821
22842
  TAKEOVER_STACK_ID,
@@ -22832,6 +22853,7 @@ export {
22832
22853
  TableRow,
22833
22854
  Tabs,
22834
22855
  TakeoverDrawerRenderer,
22856
+ TextEditor,
22835
22857
  Textarea,
22836
22858
  Theme,
22837
22859
  Tile2 as Tile,
@@ -22876,6 +22898,7 @@ export {
22876
22898
  fadeInRtl,
22877
22899
  fadeInTop,
22878
22900
  fadeOutBottom,
22901
+ filterMapper,
22879
22902
  fullWidthScreenIcon,
22880
22903
  getDrawerAttributes,
22881
22904
  getParentPath,