@bynder/compact-view 5.1.4 → 5.2.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/App.d.ts +3 -1
- package/App.js +60 -56
- package/App.js.map +1 -1
- package/AssetFilter.js +80 -100
- package/AssetFilter.js.map +1 -1
- package/AssetFilterContext.js.map +1 -1
- package/{Autocomplete.js → Autocomplete_new.js} +41 -41
- package/Autocomplete_new.js.map +1 -0
- package/ConfigContext.js.map +1 -1
- package/FileSelector.js +138 -111
- package/FileSelector.js.map +1 -1
- package/Option_new.js +50 -0
- package/Option_new.js.map +1 -0
- package/SmartFilterSelect_new.js +86 -0
- package/SmartFilterSelect_new.js.map +1 -0
- package/Smartfilters_new.js +190 -0
- package/Smartfilters_new.js.map +1 -0
- package/api/getFilterOptions.d.ts +9 -0
- package/api/getFilters.d.ts +1 -1
- package/api/getFilters_new.d.ts +7 -0
- package/api/index.d.ts +1 -1
- package/api/types/getFilters_new.d.ts +56 -0
- package/app-config/ConfigContext.d.ts +1 -1
- package/app-config/appConfig.type.d.ts +2 -0
- package/{autocomplete2.js → autocomplete.js} +1 -1
- package/autocomplete.js.map +1 -0
- package/filter/filters/smartfilters/Metaproperties/Autocomplete_new.d.ts +15 -0
- package/filter/filters/smartfilters/Metaproperties/Option_new.d.ts +13 -0
- package/filter/filters/smartfilters/Metaproperties/SmartFilterSelect_new.d.ts +13 -0
- package/filter/filters/smartfilters/Smartfilters_new.d.ts +7 -0
- package/filterAssets.js +14 -12
- package/filterAssets.js.map +1 -1
- package/getCollections.js +4 -3
- package/getCollections.js.map +1 -1
- package/getFilterOptions.js +57 -0
- package/getFilterOptions.js.map +1 -0
- package/getFilters.js +33 -32
- package/getFilters.js.map +1 -1
- package/getFilters_new.js +73 -0
- package/getFilters_new.js.map +1 -0
- package/getLimitedUseThumbnails.js +26 -0
- package/getLimitedUseThumbnails.js.map +1 -0
- package/handlers.js +3 -7
- package/handlers.js.map +1 -1
- package/index3.js +44 -24
- package/index3.js.map +1 -1
- package/package.json +1 -1
- package/utils/getLimitedUseThumbnails.d.ts +2 -0
- package/Autocomplete.js.map +0 -1
- package/Option.js +0 -50
- package/Option.js.map +0 -1
- package/SmartFilterSelect.js +0 -91
- package/SmartFilterSelect.js.map +0 -1
- package/Smartfilters.js +0 -186
- package/Smartfilters.js.map +0 -1
- package/autocomplete2.js.map +0 -1
- package/filterEmptyMetaproperties.js +0 -11
- package/filterEmptyMetaproperties.js.map +0 -1
- package/getInitialFilters.js +0 -51
- package/getInitialFilters.js.map +0 -1
- package/getMetapropertiesOptions.js +0 -31
- package/getMetapropertiesOptions.js.map +0 -1
package/App.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface Props {
|
|
|
14
14
|
onSuccess?: (assets: unknown[], additionalInformation: {
|
|
15
15
|
selectedFile?: File;
|
|
16
16
|
}) => void;
|
|
17
|
+
defaultImageDerivativeName?: string;
|
|
18
|
+
defaultVideoDerivativeName?: string;
|
|
17
19
|
theme?: Theme;
|
|
18
20
|
hideExternalAccess?: boolean;
|
|
19
21
|
selectedAssets?: string[];
|
|
@@ -24,4 +26,4 @@ export interface Props {
|
|
|
24
26
|
noCache?: boolean;
|
|
25
27
|
selectAllOption?: boolean;
|
|
26
28
|
}
|
|
27
|
-
export declare function App({ assetFieldSelection, assetFilter, assetTypes, defaultSearchTerm, language, mode, onSuccess, theme, hideExternalAccess, selectedAssets, hideLimitedUse, isContainerMode, __shouldAddOriginal__, hideSwitch, noCache, selectAllOption, }: Props): React.JSX.Element;
|
|
29
|
+
export declare function App({ assetFieldSelection, assetFilter, assetTypes, defaultSearchTerm, language, mode, onSuccess, defaultImageDerivativeName, defaultVideoDerivativeName, theme, hideExternalAccess, selectedAssets, hideLimitedUse, isContainerMode, __shouldAddOriginal__, hideSwitch, noCache, selectAllOption, }: Props): React.JSX.Element;
|
package/App.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { jsx as e, jsxs as s, Fragment as
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { BrowserClient as
|
|
4
|
-
import { CollectionsView as
|
|
5
|
-
import { CollectionView as
|
|
6
|
-
import { ConfigProvider as
|
|
7
|
-
import { AssetFilter as
|
|
8
|
-
import { useLocalization as
|
|
9
|
-
import { ShadowRoot as
|
|
10
|
-
import { AssetFilterProvider as
|
|
11
|
-
import { SelectionProvider as
|
|
12
|
-
import { ThemeStyles as
|
|
13
|
-
import { Toolbar as
|
|
14
|
-
import { AssetsView as
|
|
15
|
-
import { SelectionFooter as
|
|
16
|
-
import { Shield as
|
|
17
|
-
import { Dat as
|
|
1
|
+
import { jsx as e, jsxs as s, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as V } from "react";
|
|
3
|
+
import { BrowserClient as D, makeFetchTransport as E, defaultStackParser as I, Hub as T } from "@sentry/browser";
|
|
4
|
+
import { CollectionsView as k } from "./CollectionsView.js";
|
|
5
|
+
import { CollectionView as y } from "./CollectionView.js";
|
|
6
|
+
import { ConfigProvider as M, useConfig as O } from "./ConfigContext.js";
|
|
7
|
+
import { AssetFilter as R } from "./AssetFilter.js";
|
|
8
|
+
import { useLocalization as U } from "./index2.js";
|
|
9
|
+
import { ShadowRoot as x } from "./ShadowRoot.js";
|
|
10
|
+
import { AssetFilterProvider as j } from "./AssetFilterContext.js";
|
|
11
|
+
import { SelectionProvider as H } from "./SelectionContext.js";
|
|
12
|
+
import { ThemeStyles as N } from "./Theming.js";
|
|
13
|
+
import { Toolbar as z } from "./Toolbar.js";
|
|
14
|
+
import { AssetsView as B } from "./AssetsView.js";
|
|
15
|
+
import { SelectionFooter as G } from "./SelectionFooter.js";
|
|
16
|
+
import { Shield as L } from "./Shield.js";
|
|
17
|
+
import { Dat as _ } from "./Dat.js";
|
|
18
18
|
import "./DatDropdownItem.js";
|
|
19
|
-
import { useRouterSelectors as
|
|
20
|
-
import { useSearchStore as
|
|
21
|
-
import { useDat as
|
|
19
|
+
import { useRouterSelectors as q } from "./useRouterStore.js";
|
|
20
|
+
import { useSearchStore as J, useClearCollectionOnPageChange as K } from "./useSearchStore.js";
|
|
21
|
+
import { useDat as Q } from "./useDatStore.js";
|
|
22
22
|
let n;
|
|
23
|
-
n = new
|
|
23
|
+
n = new D({
|
|
24
24
|
dsn: "https://dd74b64cc05845468f0c3654b458da29@sentry10.bynder.cloud/464",
|
|
25
25
|
autoSessionTracking: !0,
|
|
26
26
|
tracesSampleRate: 1,
|
|
27
27
|
integrations: [],
|
|
28
|
-
stackParser:
|
|
29
|
-
transport:
|
|
30
|
-
}), new
|
|
31
|
-
function
|
|
28
|
+
stackParser: I,
|
|
29
|
+
transport: E
|
|
30
|
+
}), new T(n);
|
|
31
|
+
function Se({
|
|
32
32
|
assetFieldSelection: o,
|
|
33
33
|
assetFilter: r,
|
|
34
34
|
assetTypes: a = ["IMAGE", "AUDIO", "VIDEO", "DOCUMENT", "ARCHIVE"],
|
|
@@ -37,53 +37,57 @@ function he({
|
|
|
37
37
|
mode: p = "MultiSelect",
|
|
38
38
|
// eslint-disable-next-line no-console
|
|
39
39
|
onSuccess: f = (t, { selectedFile: i }) => console.log(t, i),
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
defaultImageDerivativeName: d,
|
|
41
|
+
defaultVideoDerivativeName: u,
|
|
42
|
+
theme: h,
|
|
43
|
+
hideExternalAccess: g,
|
|
44
|
+
selectedAssets: S,
|
|
45
|
+
hideLimitedUse: C,
|
|
46
|
+
isContainerMode: w = !1,
|
|
47
|
+
__shouldAddOriginal__: v,
|
|
48
|
+
hideSwitch: A = !1,
|
|
49
|
+
noCache: P = !1,
|
|
50
|
+
selectAllOption: b = !1
|
|
49
51
|
}) {
|
|
50
|
-
|
|
51
|
-
const { setSearch: t } =
|
|
52
|
+
U(c);
|
|
53
|
+
const { setSearch: t } = J(), { datUrl: i } = Q(), m = {
|
|
52
54
|
assetFieldSelection: o,
|
|
53
55
|
assetFilter: r,
|
|
54
56
|
assetTypes: a,
|
|
55
57
|
language: c,
|
|
56
58
|
onSuccess: f,
|
|
59
|
+
defaultImageDerivativeName: d,
|
|
60
|
+
defaultVideoDerivativeName: u,
|
|
57
61
|
selectionMode: p,
|
|
58
|
-
theme:
|
|
59
|
-
hideExternalAccess:
|
|
60
|
-
__shouldAddOriginal__:
|
|
61
|
-
hideSwitch:
|
|
62
|
-
noCache:
|
|
63
|
-
selectAllOption:
|
|
62
|
+
theme: h,
|
|
63
|
+
hideExternalAccess: g,
|
|
64
|
+
__shouldAddOriginal__: v,
|
|
65
|
+
hideSwitch: A,
|
|
66
|
+
noCache: P,
|
|
67
|
+
selectAllOption: b
|
|
64
68
|
};
|
|
65
|
-
return
|
|
69
|
+
return V(() => {
|
|
66
70
|
t("assets", l ?? "");
|
|
67
|
-
}, [l, t]), /* @__PURE__ */ e(
|
|
68
|
-
/* @__PURE__ */ e(
|
|
71
|
+
}, [l, t]), /* @__PURE__ */ e(L, { sentryClient: n, children: /* @__PURE__ */ e(x, { isContainerMode: w, children: /* @__PURE__ */ e(j, { hideLimitedUse: C, predefinedFilter: r, children: /* @__PURE__ */ e(M, { value: m, children: /* @__PURE__ */ s(H, { preselectedAssetIds: S ?? [], children: [
|
|
72
|
+
/* @__PURE__ */ e(N, { theme: m.theme }),
|
|
69
73
|
/* @__PURE__ */ s("div", { className: "cv-root cv-container", children: [
|
|
70
|
-
/* @__PURE__ */ e(H, {}),
|
|
71
|
-
/* @__PURE__ */ e(K, {}),
|
|
72
74
|
/* @__PURE__ */ e(z, {}),
|
|
73
|
-
|
|
75
|
+
/* @__PURE__ */ e(W, {}),
|
|
76
|
+
/* @__PURE__ */ e(G, {}),
|
|
77
|
+
i && /* @__PURE__ */ e(_, {})
|
|
74
78
|
] })
|
|
75
79
|
] }) }) }) }) });
|
|
76
80
|
}
|
|
77
|
-
function
|
|
78
|
-
const o =
|
|
79
|
-
return
|
|
80
|
-
o.page !== "collections" && (r === void 0 || r && r.showToolbar) && /* @__PURE__ */ e(
|
|
81
|
-
o.page === "assets" && /* @__PURE__ */ e(
|
|
82
|
-
o.page === "collections" && /* @__PURE__ */ e(
|
|
83
|
-
o.page === "collection" && /* @__PURE__ */ e(
|
|
81
|
+
function W() {
|
|
82
|
+
const o = q.use.page(), { assetFilter: r } = O();
|
|
83
|
+
return K(o), /* @__PURE__ */ s(F, { children: [
|
|
84
|
+
o.page !== "collections" && (r === void 0 || r && r.showToolbar) && /* @__PURE__ */ e(R, {}),
|
|
85
|
+
o.page === "assets" && /* @__PURE__ */ e(B, {}),
|
|
86
|
+
o.page === "collections" && /* @__PURE__ */ e(k, {}),
|
|
87
|
+
o.page === "collection" && /* @__PURE__ */ e(y, { collection: o.collection })
|
|
84
88
|
] });
|
|
85
89
|
}
|
|
86
90
|
export {
|
|
87
|
-
|
|
91
|
+
Se as App
|
|
88
92
|
};
|
|
89
93
|
//# sourceMappingURL=App.js.map
|
package/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","sources":["../../src/App.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { BrowserClient, defaultStackParser, makeFetchTransport, Hub } from '@sentry/browser';\nimport { AssetFilterJson } from './filter/assetFilter.type';\nimport { AssetType } from './views/asset/asset.type';\nimport { CollectionsView } from './views/collections/CollectionsView';\nimport { CollectionView } from './views/collection/CollectionView';\nimport { ConfigProvider, useConfig } from './app-config/ConfigContext';\nimport { SelectionMode } from './app-config/appConfig.type';\nimport { AssetFilter } from './filter/AssetFilter';\nimport { useLocalization } from './localization';\nimport { ShadowRoot } from './style/shadowroot/ShadowRoot';\nimport { AssetFilterProvider } from './filter/AssetFilterContext';\nimport { SelectionProvider } from './select/SelectionContext';\nimport { Theme, ThemeStyles } from './style/Theming';\nimport { Toolbar } from './toolbar/Toolbar';\nimport { File } from './select/file.type';\nimport { AssetsView } from './views/asset/AssetsView';\nimport { SelectionFooter } from './select/SelectionFooter';\nimport { Shield } from './error-handling/Shield';\nimport { Dat } from './Dat';\nimport { useRouterSelectors } from './store/useRouterStore';\nimport { useClearCollectionOnPageChange, useSearchStore } from './store/useSearchStore';\nimport { useDat } from './store/useDatStore';\n\nlet sentryClient;\n\n// Initialize Sentry on production\nif (process.env.NODE_ENV === 'production') {\n\tsentryClient = new BrowserClient({\n\t\tdsn: 'https://dd74b64cc05845468f0c3654b458da29@sentry10.bynder.cloud/464',\n\t\tautoSessionTracking: true,\n\t\ttracesSampleRate: 1.0,\n\t\tintegrations: [],\n\t\tstackParser: defaultStackParser,\n\t\ttransport: makeFetchTransport,\n\t});\n\tnew Hub(sentryClient);\n}\n\nexport interface Props {\n\tassetFieldSelection?: string;\n\tassetFilter?: AssetFilterJson;\n\tassetTypes?: AssetType[];\n\tdefaultSearchTerm?: string;\n\tlanguage?: string;\n\tmode?: SelectionMode;\n\tonSuccess?: (assets: unknown[], additionalInformation: { selectedFile?: File }) => void;\n\ttheme?: Theme;\n\thideExternalAccess?: boolean;\n\tselectedAssets?: string[];\n\thideLimitedUse?: boolean;\n\tisContainerMode?: boolean;\n\t__shouldAddOriginal__?: boolean;\n\thideSwitch?: boolean;\n\tnoCache?: boolean;\n\tselectAllOption?: boolean;\n}\n\nexport function App({\n\tassetFieldSelection,\n\tassetFilter,\n\tassetTypes = ['IMAGE', 'AUDIO', 'VIDEO', 'DOCUMENT', 'ARCHIVE'],\n\tdefaultSearchTerm,\n\tlanguage = 'en_US',\n\tmode = 'MultiSelect',\n\t// eslint-disable-next-line no-console\n\tonSuccess = (assets, { selectedFile }) => console.log(assets, selectedFile),\n\ttheme,\n\thideExternalAccess,\n\tselectedAssets,\n\thideLimitedUse,\n\tisContainerMode = false,\n\t__shouldAddOriginal__,\n\thideSwitch = false,\n\tnoCache = false,\n\tselectAllOption = false,\n}: Props) {\n\tuseLocalization(language);\n\tconst { setSearch } = useSearchStore();\n\tconst { datUrl } = useDat();\n\n\tconst config = {\n\t\tassetFieldSelection,\n\t\tassetFilter,\n\t\tassetTypes,\n\t\tlanguage,\n\t\tonSuccess,\n\t\tselectionMode: mode,\n\t\ttheme,\n\t\thideExternalAccess,\n\t\t__shouldAddOriginal__,\n\t\thideSwitch,\n\t\tnoCache,\n\t\tselectAllOption,\n\t};\n\n\tuseEffect(() => {\n\t\tsetSearch('assets', defaultSearchTerm ?? '');\n\t}, [defaultSearchTerm, setSearch]);\n\n\treturn (\n\t\t<Shield sentryClient={sentryClient}>\n\t\t\t<ShadowRoot isContainerMode={isContainerMode}>\n\t\t\t\t<AssetFilterProvider hideLimitedUse={hideLimitedUse} predefinedFilter={assetFilter}>\n\t\t\t\t\t<ConfigProvider value={config}>\n\t\t\t\t\t\t<SelectionProvider preselectedAssetIds={selectedAssets ?? []}>\n\t\t\t\t\t\t\t<ThemeStyles theme={config.theme} />\n\t\t\t\t\t\t\t<div className=\"cv-root cv-container\">\n\t\t\t\t\t\t\t\t<Toolbar />\n\t\t\t\t\t\t\t\t<CurrentPageView />\n\t\t\t\t\t\t\t\t<SelectionFooter />\n\n\t\t\t\t\t\t\t\t{datUrl && <Dat />}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</SelectionProvider>\n\t\t\t\t\t</ConfigProvider>\n\t\t\t\t</AssetFilterProvider>\n\t\t\t</ShadowRoot>\n\t\t</Shield>\n\t);\n}\n\n// eslint-disable-next-line react/no-multi-comp\nfunction CurrentPageView() {\n\tconst page = useRouterSelectors.use.page();\n\tconst { assetFilter } = useConfig();\n\n\t// Clear collection search state on page change\n\tuseClearCollectionOnPageChange(page);\n\n\treturn (\n\t\t<>\n\t\t\t{page.page !== 'collections' &&\n\t\t\t\t(assetFilter === undefined || (assetFilter && assetFilter.showToolbar)) && (\n\t\t\t\t\t<AssetFilter />\n\t\t\t\t)}\n\n\t\t\t{page.page === 'assets' && <AssetsView />}\n\t\t\t{page.page === 'collections' && <CollectionsView />}\n\t\t\t{page.page === 'collection' && <CollectionView collection={page.collection} />}\n\t\t</>\n\t);\n}\n"],"names":["sentryClient","BrowserClient","defaultStackParser","makeFetchTransport","Hub","App","assetFieldSelection","assetFilter","assetTypes","defaultSearchTerm","language","mode","onSuccess","assets","selectedFile","theme","hideExternalAccess","selectedAssets","hideLimitedUse","isContainerMode","__shouldAddOriginal__","hideSwitch","noCache","selectAllOption","useLocalization","setSearch","useSearchStore","datUrl","useDat","config","useEffect","jsx","Shield","ShadowRoot","AssetFilterProvider","ConfigProvider","jsxs","SelectionProvider","ThemeStyles","Toolbar","CurrentPageView","SelectionFooter","Dat","page","useRouterSelectors","useConfig","useClearCollectionOnPageChange","Fragment","AssetFilter","AssetsView","CollectionsView","CollectionView"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,IAAIA;AAIHA,IAAe,IAAIC,EAAc;AAAA,EAChC,KAAK;AAAA,EACL,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,cAAc,CAAA;AAAA,EACd,aAAaC;AAAA,EACb,WAAWC;AAAA,CACX,GACD,IAAIC,EAAIJ,CAAY;
|
|
1
|
+
{"version":3,"file":"App.js","sources":["../../src/App.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\n\nimport { BrowserClient, defaultStackParser, makeFetchTransport, Hub } from '@sentry/browser';\nimport { AssetFilterJson } from './filter/assetFilter.type';\nimport { AssetType } from './views/asset/asset.type';\nimport { CollectionsView } from './views/collections/CollectionsView';\nimport { CollectionView } from './views/collection/CollectionView';\nimport { ConfigProvider, useConfig } from './app-config/ConfigContext';\nimport { SelectionMode } from './app-config/appConfig.type';\nimport { AssetFilter } from './filter/AssetFilter';\nimport { useLocalization } from './localization';\nimport { ShadowRoot } from './style/shadowroot/ShadowRoot';\nimport { AssetFilterProvider } from './filter/AssetFilterContext';\nimport { SelectionProvider } from './select/SelectionContext';\nimport { Theme, ThemeStyles } from './style/Theming';\nimport { Toolbar } from './toolbar/Toolbar';\nimport { File } from './select/file.type';\nimport { AssetsView } from './views/asset/AssetsView';\nimport { SelectionFooter } from './select/SelectionFooter';\nimport { Shield } from './error-handling/Shield';\nimport { Dat } from './Dat';\nimport { useRouterSelectors } from './store/useRouterStore';\nimport { useClearCollectionOnPageChange, useSearchStore } from './store/useSearchStore';\nimport { useDat } from './store/useDatStore';\n\nlet sentryClient;\n\n// Initialize Sentry on production\nif (process.env.NODE_ENV === 'production') {\n\tsentryClient = new BrowserClient({\n\t\tdsn: 'https://dd74b64cc05845468f0c3654b458da29@sentry10.bynder.cloud/464',\n\t\tautoSessionTracking: true,\n\t\ttracesSampleRate: 1.0,\n\t\tintegrations: [],\n\t\tstackParser: defaultStackParser,\n\t\ttransport: makeFetchTransport,\n\t});\n\tnew Hub(sentryClient);\n}\n\nexport interface Props {\n\tassetFieldSelection?: string;\n\tassetFilter?: AssetFilterJson;\n\tassetTypes?: AssetType[];\n\tdefaultSearchTerm?: string;\n\tlanguage?: string;\n\tmode?: SelectionMode;\n\tonSuccess?: (assets: unknown[], additionalInformation: { selectedFile?: File }) => void;\n\tdefaultImageDerivativeName?: string;\n\tdefaultVideoDerivativeName?: string;\n\ttheme?: Theme;\n\thideExternalAccess?: boolean;\n\tselectedAssets?: string[];\n\thideLimitedUse?: boolean;\n\tisContainerMode?: boolean;\n\t__shouldAddOriginal__?: boolean;\n\thideSwitch?: boolean;\n\tnoCache?: boolean;\n\tselectAllOption?: boolean;\n}\n\nexport function App({\n\tassetFieldSelection,\n\tassetFilter,\n\tassetTypes = ['IMAGE', 'AUDIO', 'VIDEO', 'DOCUMENT', 'ARCHIVE'],\n\tdefaultSearchTerm,\n\tlanguage = 'en_US',\n\tmode = 'MultiSelect',\n\t// eslint-disable-next-line no-console\n\tonSuccess = (assets, { selectedFile }) => console.log(assets, selectedFile),\n\tdefaultImageDerivativeName,\n\tdefaultVideoDerivativeName,\n\ttheme,\n\thideExternalAccess,\n\tselectedAssets,\n\thideLimitedUse,\n\tisContainerMode = false,\n\t__shouldAddOriginal__,\n\thideSwitch = false,\n\tnoCache = false,\n\tselectAllOption = false,\n}: Props) {\n\tuseLocalization(language);\n\tconst { setSearch } = useSearchStore();\n\tconst { datUrl } = useDat();\n\n\tconst config = {\n\t\tassetFieldSelection,\n\t\tassetFilter,\n\t\tassetTypes,\n\t\tlanguage,\n\t\tonSuccess,\n\t\tdefaultImageDerivativeName,\n\t\tdefaultVideoDerivativeName,\n\t\tselectionMode: mode,\n\t\ttheme,\n\t\thideExternalAccess,\n\t\t__shouldAddOriginal__,\n\t\thideSwitch,\n\t\tnoCache,\n\t\tselectAllOption,\n\t};\n\n\tuseEffect(() => {\n\t\tsetSearch('assets', defaultSearchTerm ?? '');\n\t}, [defaultSearchTerm, setSearch]);\n\n\treturn (\n\t\t<Shield sentryClient={sentryClient}>\n\t\t\t<ShadowRoot isContainerMode={isContainerMode}>\n\t\t\t\t<AssetFilterProvider hideLimitedUse={hideLimitedUse} predefinedFilter={assetFilter}>\n\t\t\t\t\t<ConfigProvider value={config}>\n\t\t\t\t\t\t<SelectionProvider preselectedAssetIds={selectedAssets ?? []}>\n\t\t\t\t\t\t\t<ThemeStyles theme={config.theme} />\n\t\t\t\t\t\t\t<div className=\"cv-root cv-container\">\n\t\t\t\t\t\t\t\t<Toolbar />\n\t\t\t\t\t\t\t\t<CurrentPageView />\n\t\t\t\t\t\t\t\t<SelectionFooter />\n\n\t\t\t\t\t\t\t\t{datUrl && <Dat />}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</SelectionProvider>\n\t\t\t\t\t</ConfigProvider>\n\t\t\t\t</AssetFilterProvider>\n\t\t\t</ShadowRoot>\n\t\t</Shield>\n\t);\n}\n\n// eslint-disable-next-line react/no-multi-comp\nfunction CurrentPageView() {\n\tconst page = useRouterSelectors.use.page();\n\tconst { assetFilter } = useConfig();\n\n\t// Clear collection search state on page change\n\tuseClearCollectionOnPageChange(page);\n\n\treturn (\n\t\t<>\n\t\t\t{page.page !== 'collections' &&\n\t\t\t\t(assetFilter === undefined || (assetFilter && assetFilter.showToolbar)) && (\n\t\t\t\t\t<AssetFilter />\n\t\t\t\t)}\n\n\t\t\t{page.page === 'assets' && <AssetsView />}\n\t\t\t{page.page === 'collections' && <CollectionsView />}\n\t\t\t{page.page === 'collection' && <CollectionView collection={page.collection} />}\n\t\t</>\n\t);\n}\n"],"names":["sentryClient","BrowserClient","defaultStackParser","makeFetchTransport","Hub","App","assetFieldSelection","assetFilter","assetTypes","defaultSearchTerm","language","mode","onSuccess","assets","selectedFile","defaultImageDerivativeName","defaultVideoDerivativeName","theme","hideExternalAccess","selectedAssets","hideLimitedUse","isContainerMode","__shouldAddOriginal__","hideSwitch","noCache","selectAllOption","useLocalization","setSearch","useSearchStore","datUrl","useDat","config","useEffect","jsx","Shield","ShadowRoot","AssetFilterProvider","ConfigProvider","jsxs","SelectionProvider","ThemeStyles","Toolbar","CurrentPageView","SelectionFooter","Dat","page","useRouterSelectors","useConfig","useClearCollectionOnPageChange","Fragment","AssetFilter","AssetsView","CollectionsView","CollectionView"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,IAAIA;AAIHA,IAAe,IAAIC,EAAc;AAAA,EAChC,KAAK;AAAA,EACL,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,cAAc,CAAA;AAAA,EACd,aAAaC;AAAA,EACb,WAAWC;AAAA,CACX,GACD,IAAIC,EAAIJ,CAAY;AAwBd,SAASK,GAAI;AAAA,EACnB,qBAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC,IAAa,CAAC,SAAS,SAAS,SAAS,YAAY,SAAS;AAAA,EAC9D,mBAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA;AAAA,EAEP,WAAAC,IAAY,CAACC,GAAQ,EAAE,cAAAC,QAAmB,QAAQ,IAAID,GAAQC,CAAY;AAAA,EAC1E,4BAAAC;AAAA,EACA,4BAAAC;AAAA,EACA,OAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAA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B;AAC1B,QAAMG,IAAOC,EAAmB,IAAI,KAAA,GAC9B,EAAE,aAAAvC,EAAA,IAAgBwC,EAAA;AAGxB,SAAAC,EAA+BH,CAAI,GAGlC,gBAAAP,EAAAW,GAAA,EACE,UAAA;AAAA,IAAAJ,EAAK,SAAS,kBACbtC,MAAgB,UAAcA,KAAeA,EAAY,kCACxD2C,GAAA,CAAA,CAAY;AAAA,IAGdL,EAAK,SAAS,YAAY,gBAAAZ,EAACkB,GAAA,CAAA,CAAW;AAAA,IACtCN,EAAK,SAAS,iBAAiB,gBAAAZ,EAACmB,GAAA,CAAA,CAAgB;AAAA,IAChDP,EAAK,SAAS,kCAAiBQ,GAAA,EAAe,YAAYR,EAAK,WAAA,CAAY;AAAA,EAAA,GAC7E;AAEF;"}
|
package/AssetFilter.js
CHANGED
|
@@ -1,144 +1,124 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { styled as
|
|
4
|
-
import { token as
|
|
5
|
-
import { IconMultiSelect as
|
|
6
|
-
import { useRouterSelectors as
|
|
7
|
-
import { useAssetFilter as
|
|
8
|
-
import { useLocalization as
|
|
9
|
-
import { useConfig as
|
|
10
|
-
import { useGetFilters as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { getAssetCounts as
|
|
19
|
-
import { Smartfilter as
|
|
20
|
-
import { useSearchStateByPage as
|
|
21
|
-
import { useSimilaritySearchStore as
|
|
22
|
-
function
|
|
23
|
-
const s =
|
|
24
|
-
assetTypes:
|
|
25
|
-
language:
|
|
26
|
-
assetFilter:
|
|
27
|
-
noCache:
|
|
28
|
-
selectionMode:
|
|
29
|
-
selectAllOption:
|
|
30
|
-
} =
|
|
31
|
-
|
|
32
|
-
const [
|
|
33
|
-
isSelected:
|
|
34
|
-
isNLSSelected:
|
|
35
|
-
NLSSearchText:
|
|
36
|
-
} =
|
|
1
|
+
import { jsx as e, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useEffect as C } from "react";
|
|
3
|
+
import { styled as p } from "styled-components";
|
|
4
|
+
import { token as F, Button as L } from "@bynder/design-system";
|
|
5
|
+
import { IconMultiSelect as B, IconRectangle as E } from "@bynder/icons";
|
|
6
|
+
import { useRouterSelectors as H } from "./useRouterStore.js";
|
|
7
|
+
import { useAssetFilter as R } from "./AssetFilterContext.js";
|
|
8
|
+
import { useLocalization as U } from "./index2.js";
|
|
9
|
+
import { useConfig as V } from "./ConfigContext.js";
|
|
10
|
+
import { useGetFilters as W } from "./getFilters.js";
|
|
11
|
+
import { useGetFilters as q } from "./getFilters_new.js";
|
|
12
|
+
import { Skeleton as f } from "./Skeleton.js";
|
|
13
|
+
import { HorizontalScroll as J } from "./HorizontalScroll.js";
|
|
14
|
+
import { Tags as K } from "./Tags.js";
|
|
15
|
+
import { Advanced as Q } from "./Advanced.js";
|
|
16
|
+
import { useSelection as X } from "./SelectionContext.js";
|
|
17
|
+
import { useAuth as Y } from "./LoginContext.js";
|
|
18
|
+
import { getAssetCounts as Z } from "./getAssetCounts.js";
|
|
19
|
+
import { Smartfilter as _ } from "./Smartfilters_new.js";
|
|
20
|
+
import { useSearchStateByPage as ee } from "./useSearchStore.js";
|
|
21
|
+
import { useSimilaritySearchStore as te } from "./useSimilaritySearchStore.js";
|
|
22
|
+
function Te() {
|
|
23
|
+
const s = R(), t = H.use.page(), { value: i } = ee("assets"), {
|
|
24
|
+
assetTypes: l,
|
|
25
|
+
language: g,
|
|
26
|
+
assetFilter: x,
|
|
27
|
+
noCache: S,
|
|
28
|
+
selectionMode: w,
|
|
29
|
+
selectAllOption: T
|
|
30
|
+
} = V(), { clear: I, selectAll: b } = X(), N = Y(), [h, P] = u(t.page);
|
|
31
|
+
U(g);
|
|
32
|
+
const [j, A] = u(!1), {
|
|
33
|
+
isSelected: z,
|
|
34
|
+
isNLSSelected: D,
|
|
35
|
+
NLSSearchText: G
|
|
36
|
+
} = te(), [M, y] = u(!1), { data: n, isLoading: v } = W(
|
|
37
37
|
{
|
|
38
38
|
filter: s,
|
|
39
|
-
searchTerm:
|
|
40
|
-
allAssetTypes:
|
|
41
|
-
language:
|
|
42
|
-
predefinedFilter:
|
|
39
|
+
searchTerm: i || null,
|
|
40
|
+
allAssetTypes: l,
|
|
41
|
+
language: g,
|
|
42
|
+
predefinedFilter: x,
|
|
43
43
|
collectionId: t.page === "collection" ? t.collection.id : null
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
if (
|
|
48
|
-
(async () => {
|
|
49
|
-
v(!0);
|
|
50
|
-
try {
|
|
51
|
-
const { filters: d, metaproperties: o } = await se({
|
|
52
|
-
auth: h
|
|
53
|
-
});
|
|
54
|
-
F(d), $(o);
|
|
55
|
-
} catch {
|
|
56
|
-
F([]);
|
|
57
|
-
} finally {
|
|
58
|
-
v(!1);
|
|
59
|
-
}
|
|
60
|
-
})();
|
|
61
|
-
}, []), p(() => (t.page !== y && (j(t.page), s.clear()), () => {
|
|
45
|
+
S
|
|
46
|
+
), { data: r } = q(S);
|
|
47
|
+
if (C(() => (t.page !== h && (P(t.page), s.clear()), () => {
|
|
62
48
|
s.clear();
|
|
63
|
-
}), [
|
|
64
|
-
let
|
|
49
|
+
}), [h, t.page]), C(() => {
|
|
50
|
+
let o = !1;
|
|
65
51
|
return (async () => {
|
|
66
|
-
|
|
52
|
+
y(!0);
|
|
67
53
|
try {
|
|
68
|
-
const
|
|
69
|
-
auth:
|
|
54
|
+
const d = await Z({
|
|
55
|
+
auth: N,
|
|
70
56
|
filter: {
|
|
71
|
-
searchTerm:
|
|
72
|
-
assetTypes:
|
|
57
|
+
searchTerm: i,
|
|
58
|
+
assetTypes: l,
|
|
73
59
|
collectionId: t.page === "collection" ? t.collection.id : void 0,
|
|
74
60
|
tagNames: s.tags,
|
|
75
61
|
isLimitedUse: s.isLimited,
|
|
76
62
|
metaproperties: s.selectedSmartfilterOptions
|
|
77
63
|
}
|
|
78
64
|
});
|
|
79
|
-
|
|
80
|
-
} catch (
|
|
81
|
-
|
|
65
|
+
o || s.setActiveFiltersState(d);
|
|
66
|
+
} catch (d) {
|
|
67
|
+
o || console.error("Error fetching asset counts:", d);
|
|
82
68
|
} finally {
|
|
83
|
-
|
|
69
|
+
o || y(!1);
|
|
84
70
|
}
|
|
85
71
|
})(), () => {
|
|
86
|
-
|
|
72
|
+
o = !0;
|
|
87
73
|
};
|
|
88
|
-
}, [s.tags,
|
|
89
|
-
return /* @__PURE__ */ e(
|
|
90
|
-
const { tags:
|
|
91
|
-
|
|
74
|
+
}, [s.tags, i, l, t.page, s.selectedSmartfilterOptions]), n.tag === "Failure" || !n.value || r.tag === "Failure" || r.tag === "Loading" || !r.value || M)
|
|
75
|
+
return /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(se, {}) });
|
|
76
|
+
const { tags: a, count: O } = n.value.searchAssets, { value: c } = r, $ = j ? /* @__PURE__ */ e(
|
|
77
|
+
L,
|
|
92
78
|
{
|
|
93
79
|
onClick: () => {
|
|
94
|
-
|
|
80
|
+
I(), A(!1);
|
|
95
81
|
},
|
|
96
|
-
icon: /* @__PURE__ */ e(
|
|
82
|
+
icon: /* @__PURE__ */ e(B, {}),
|
|
97
83
|
title: "",
|
|
98
84
|
variant: "secondary",
|
|
99
85
|
"data-testid": "deselect-all"
|
|
100
86
|
}
|
|
101
87
|
) : /* @__PURE__ */ e(
|
|
102
|
-
|
|
88
|
+
L,
|
|
103
89
|
{
|
|
104
90
|
onClick: () => {
|
|
105
|
-
|
|
91
|
+
b(), A(!0);
|
|
106
92
|
},
|
|
107
|
-
icon: /* @__PURE__ */ e(
|
|
93
|
+
icon: /* @__PURE__ */ e(E, {}),
|
|
108
94
|
title: "",
|
|
109
95
|
variant: "secondary",
|
|
110
96
|
"data-testid": "select-all"
|
|
111
97
|
}
|
|
112
98
|
);
|
|
113
|
-
return
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
smartfilters: a,
|
|
119
|
-
metaproperties: R
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
f && f.nodes.length > 0 && /* @__PURE__ */ e(Z, { tags: f.nodes, isLoading: L }),
|
|
123
|
-
/* @__PURE__ */ e(_, { isLoading: L, count: D.assetType })
|
|
99
|
+
return z || D && G ? null : /* @__PURE__ */ m(k, { "data-testid": "filter-nav", children: [
|
|
100
|
+
/* @__PURE__ */ m(J, { children: [
|
|
101
|
+
c && c.filters.length > 0 && /* @__PURE__ */ e(_, { filterData: c }),
|
|
102
|
+
a && a.nodes.length > 0 && /* @__PURE__ */ e(K, { tags: a.nodes, isLoading: v }),
|
|
103
|
+
/* @__PURE__ */ e(Q, { isLoading: v, count: O.assetType })
|
|
124
104
|
] }),
|
|
125
|
-
/* @__PURE__ */ e(
|
|
105
|
+
/* @__PURE__ */ e(re, { children: w === "MultiSelect" && T && t.page === "assets" && $ })
|
|
126
106
|
] });
|
|
127
107
|
}
|
|
128
|
-
function
|
|
129
|
-
return /* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */ e(
|
|
131
|
-
/* @__PURE__ */ e(
|
|
132
|
-
/* @__PURE__ */ e(
|
|
108
|
+
function se() {
|
|
109
|
+
return /* @__PURE__ */ m(oe, { children: [
|
|
110
|
+
/* @__PURE__ */ e(f, { width: 100 }),
|
|
111
|
+
/* @__PURE__ */ e(f, { width: 80 }),
|
|
112
|
+
/* @__PURE__ */ e(f, { width: 110 })
|
|
133
113
|
] });
|
|
134
114
|
}
|
|
135
|
-
const
|
|
115
|
+
const k = p.nav`
|
|
136
116
|
display: flex;
|
|
137
117
|
justify-content: space-between;
|
|
138
118
|
background-color: #fff;
|
|
139
|
-
padding: ${
|
|
119
|
+
padding: ${F.spacing3} ${F.spacing4};
|
|
140
120
|
z-index: 20;
|
|
141
|
-
`,
|
|
121
|
+
`, re = p.div`
|
|
142
122
|
display: flex;
|
|
143
123
|
align-items: center;
|
|
144
124
|
|
|
@@ -148,11 +128,11 @@ const I = g.nav`
|
|
|
148
128
|
border: none;
|
|
149
129
|
padding: 0;
|
|
150
130
|
}
|
|
151
|
-
`,
|
|
131
|
+
`, oe = p.div`
|
|
152
132
|
display: inline-flex;
|
|
153
133
|
align-items: center;
|
|
154
134
|
`;
|
|
155
135
|
export {
|
|
156
|
-
|
|
136
|
+
Te as AssetFilter
|
|
157
137
|
};
|
|
158
138
|
//# sourceMappingURL=AssetFilter.js.map
|
package/AssetFilter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetFilter.js","sources":["../../src/filter/AssetFilter.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { styled } from 'styled-components';\nimport { Button, token } from '@bynder/design-system';\nimport { IconMultiSelect, IconRectangle } from '@bynder/icons';\nimport { useRouterSelectors } from '@src/store/useRouterStore';\nimport { useAssetFilter } from './AssetFilterContext';\nimport { useLocalization } from '../localization';\nimport { useConfig } from '../app-config/ConfigContext';\nimport { useGetFilters } from '../api/getFilters';\nimport { Skeleton } from '../common/components/Skeleton';\nimport { HorizontalScroll } from '../common/components/HorizontalScroll';\nimport { Tags } from './filters/tags/Tags';\nimport { Advanced } from './filters/advanced/Advanced';\nimport { useSelection } from '@src/select/SelectionContext';\nimport { useAuth } from '@src/login/LoginContext';\nimport { getInitialFilters } from '../api/rest/getInitialFilters';\nimport { getAssetCounts } from '../api/rest/getAssetCounts';\nimport { Smartfilter, SmartfilterMetaproperty } from '@src/api/rest/types';\nimport { Smartfilter as SmartfilterComponent } from './filters/smartfilters/Smartfilters';\nimport { useSearchStateByPage } from '@src/store/useSearchStore';\nimport { useSimilaritySearchStore } from '@src/store/useSimilaritySearchStore';\n\nexport function AssetFilter() {\n\tconst filter = useAssetFilter();\n\tconst page = useRouterSelectors.use.page();\n\tconst { value: searchValue } = useSearchStateByPage('assets');\n\tconst {\n\t\tassetTypes,\n\t\tlanguage,\n\t\tassetFilter: predefinedFilter,\n\t\tnoCache,\n\t\tselectionMode,\n\t\tselectAllOption,\n\t} = useConfig();\n\tconst { clear: clearSelection, selectAll } = useSelection();\n\tconst auth = useAuth();\n\n\tconst [currentPage, setCurrentPage] = useState(page.page);\n\tuseLocalization(language);\n\tconst [isAllSelected, setIsAllSelected] = useState(false);\n\tconst {\n\t\tisSelected: isSimilaritySearchSelected,\n\t\tisNLSSelected,\n\t\tNLSSearchText,\n\t} = useSimilaritySearchStore();\n\tconst [isSmartfiltersLoading, setIsSmartfiltersLoading] = useState(false);\n\tconst [isAssetCountsLoading, setIsAssetCountsLoading] = useState(false);\n\tconst [smartfilters, setSmartfilters] = useState<Smartfilter[]>();\n\tconst [metaproperties, setMetaproperties] = useState<\n\t\tRecord<string, Record<string, SmartfilterMetaproperty>>\n\t>({});\n\n\tconst { data, isLoading } = useGetFilters(\n\t\t{\n\t\t\tfilter,\n\t\t\tsearchTerm: searchValue || null,\n\t\t\tallAssetTypes: assetTypes,\n\t\t\tlanguage,\n\t\t\tpredefinedFilter,\n\t\t\tcollectionId: page.page === 'collection' ? page.collection.id : null,\n\t\t},\n\t\tnoCache,\n\t);\n\tuseEffect(() => {\n\t\tconst requestFilters = async () => {\n\t\t\tsetIsSmartfiltersLoading(true);\n\n\t\t\ttry {\n\t\t\t\tconst { filters, metaproperties: fetchedMetaproperties } = await getInitialFilters({\n\t\t\t\t\tauth,\n\t\t\t\t});\n\t\t\t\tsetSmartfilters(filters);\n\t\t\t\tsetMetaproperties(fetchedMetaproperties);\n\t\t\t} catch (error) {\n\t\t\t\tsetSmartfilters([]);\n\t\t\t} finally {\n\t\t\t\tsetIsSmartfiltersLoading(false);\n\t\t\t}\n\t\t};\n\n\t\trequestFilters();\n\t}, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tuseEffect(() => {\n\t\tif (page.page !== currentPage) {\n\t\t\tsetCurrentPage(page.page);\n\t\t\tfilter.clear();\n\t\t}\n\n\t\treturn () => {\n\t\t\tfilter.clear();\n\t\t};\n\t}, [currentPage, page.page]); // eslint-disable-line react-hooks/exhaustive-deps\n\t// filter is not a dependency because it's a context value\n\t// we do not need to re-run the effect when the filter context value changes\n\n\tuseEffect(() => {\n\t\tlet isCancelled = false;\n\n\t\tconst fetchAssetCounts = async () => {\n\t\t\tsetIsAssetCountsLoading(true);\n\n\t\t\ttry {\n\t\t\t\tconst response = await getAssetCounts({\n\t\t\t\t\tauth,\n\t\t\t\t\tfilter: {\n\t\t\t\t\t\tsearchTerm: searchValue,\n\t\t\t\t\t\tassetTypes,\n\t\t\t\t\t\tcollectionId: page.page === 'collection' ? page.collection.id : undefined,\n\t\t\t\t\t\ttagNames: filter.tags,\n\t\t\t\t\t\tisLimitedUse: filter.isLimited,\n\t\t\t\t\t\tmetaproperties: filter.selectedSmartfilterOptions,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tfilter.setActiveFiltersState(response);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tconsole.error('Error fetching asset counts:', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tsetIsAssetCountsLoading(false);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfetchAssetCounts();\n\n\t\treturn () => {\n\t\t\tisCancelled = true;\n\t\t};\n\t}, [filter.tags, searchValue, assetTypes, page.page, filter.selectedSmartfilterOptions]); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tif (data.tag === 'Failure' || !data.value || isSmartfiltersLoading || isAssetCountsLoading) {\n\t\treturn (\n\t\t\t<NavParent>\n\t\t\t\t<SkeletonFilters />\n\t\t\t</NavParent>\n\t\t);\n\t}\n\n\tconst { tags, count } = data.value.searchAssets;\n\n\tconst selectAllHandler = (() => {\n\t\tif (isAllSelected) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tclearSelection();\n\t\t\t\t\t\tsetIsAllSelected(false);\n\t\t\t\t\t}}\n\t\t\t\t\ticon={<IconMultiSelect />}\n\t\t\t\t\ttitle=\"\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tdata-testid=\"deselect-all\"\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tonClick={() => {\n\t\t\t\t\tselectAll();\n\t\t\t\t\tsetIsAllSelected(true);\n\t\t\t\t}}\n\t\t\t\ticon={<IconRectangle />}\n\t\t\t\ttitle=\"\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tdata-testid=\"select-all\"\n\t\t\t/>\n\t\t);\n\t})();\n\n\tif (isSimilaritySearchSelected || (isNLSSelected && NLSSearchText)) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<NavParent data-testid=\"filter-nav\">\n\t\t\t<HorizontalScroll>\n\t\t\t\t{smartfilters && smartfilters.length > 0 && (\n\t\t\t\t\t<SmartfilterComponent\n\t\t\t\t\t\tsmartfilters={smartfilters}\n\t\t\t\t\t\tmetaproperties={metaproperties}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t{tags && tags.nodes.length > 0 && <Tags tags={tags.nodes} isLoading={isLoading} />}\n\t\t\t\t<Advanced isLoading={isLoading} count={count.assetType} />\n\t\t\t</HorizontalScroll>\n\n\t\t\t<AssetFilterDropdownContainer>\n\t\t\t\t{selectionMode === 'MultiSelect' &&\n\t\t\t\t\tselectAllOption &&\n\t\t\t\t\tpage.page === 'assets' &&\n\t\t\t\t\tselectAllHandler}\n\t\t\t</AssetFilterDropdownContainer>\n\t\t</NavParent>\n\t);\n}\n\n// eslint-disable-next-line react/no-multi-comp\nfunction SkeletonFilters() {\n\treturn (\n\t\t<SkeletonWrapper>\n\t\t\t<Skeleton width={100} />\n\t\t\t<Skeleton width={80} />\n\t\t\t<Skeleton width={110} />\n\t\t</SkeletonWrapper>\n\t);\n}\n\nconst NavParent = styled.nav`\n\tdisplay: flex;\n\tjustify-content: space-between;\n\tbackground-color: #fff;\n\tpadding: ${token.spacing3} ${token.spacing4};\n\tz-index: 20;\n`;\n\nconst AssetFilterDropdownContainer = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\n\tbutton {\n\t\theight: initial;\n\t\tbackground-color: transparent;\n\t\tborder: none;\n\t\tpadding: 0;\n\t}\n`;\n\nconst SkeletonWrapper = styled.div`\n\tdisplay: inline-flex;\n\talign-items: center;\n`;\n"],"names":["AssetFilter","filter","useAssetFilter","page","useRouterSelectors","searchValue","useSearchStateByPage","assetTypes","language","predefinedFilter","noCache","selectionMode","selectAllOption","useConfig","clearSelection","selectAll","useSelection","auth","useAuth","currentPage","setCurrentPage","useState","useLocalization","isAllSelected","setIsAllSelected","isSimilaritySearchSelected","isNLSSelected","NLSSearchText","useSimilaritySearchStore","isSmartfiltersLoading","setIsSmartfiltersLoading","isAssetCountsLoading","setIsAssetCountsLoading","smartfilters","setSmartfilters","metaproperties","setMetaproperties","data","isLoading","useGetFilters","useEffect","filters","fetchedMetaproperties","getInitialFilters","isCancelled","response","getAssetCounts","error","jsx","NavParent","SkeletonFilters","tags","count","selectAllHandler","Button","IconMultiSelect","IconRectangle","jsxs","HorizontalScroll","SmartfilterComponent","Tags","Advanced","AssetFilterDropdownContainer","SkeletonWrapper","Skeleton","styled","token"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBO,SAASA,KAAc;AAC7B,QAAMC,IAASC,EAAA,GACTC,IAAOC,EAAmB,IAAI,KAAA,GAC9B,EAAE,OAAOC,MAAgBC,GAAqB,QAAQ,GACtD;AAAA,IACL,YAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAaC;AAAA,IACb,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,iBAAAC;AAAA,EAAA,IACGC,EAAA,GACE,EAAE,OAAOC,GAAgB,WAAAC,EAAA,IAAcC,GAAA,GACvC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ssetFilter.js","sources":["../../src/filter/AssetFilter.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\n\nimport { styled } from 'styled-components';\nimport { Button, token } from '@bynder/design-system';\nimport { IconMultiSelect, IconRectangle } from '@bynder/icons';\nimport { useRouterSelectors } from '@src/store/useRouterStore';\nimport { useAssetFilter } from './AssetFilterContext';\nimport { useLocalization } from '../localization';\nimport { useConfig } from '../app-config/ConfigContext';\nimport { useGetFilters } from '../api/getFilters';\nimport { useGetFilters as useNewFilters } from '../api/getFilters_new';\nimport { Skeleton } from '../common/components/Skeleton';\nimport { HorizontalScroll } from '../common/components/HorizontalScroll';\nimport { Tags } from './filters/tags/Tags';\nimport { Advanced } from './filters/advanced/Advanced';\nimport { useSelection } from '@src/select/SelectionContext';\nimport { useAuth } from '@src/login/LoginContext';\nimport { getAssetCounts } from '../api/rest/getAssetCounts';\nimport { Smartfilter as SmartfilterComponentNew } from './filters/smartfilters/Smartfilters_new';\nimport { useSearchStateByPage } from '@src/store/useSearchStore';\nimport { useSimilaritySearchStore } from '@src/store/useSimilaritySearchStore';\n\nexport function AssetFilter() {\n\tconst filter = useAssetFilter();\n\tconst page = useRouterSelectors.use.page();\n\tconst { value: searchValue } = useSearchStateByPage('assets');\n\tconst {\n\t\tassetTypes,\n\t\tlanguage,\n\t\tassetFilter: predefinedFilter,\n\t\tnoCache,\n\t\tselectionMode,\n\t\tselectAllOption,\n\t} = useConfig();\n\tconst { clear: clearSelection, selectAll } = useSelection();\n\tconst auth = useAuth();\n\n\tconst [currentPage, setCurrentPage] = useState(page.page);\n\tuseLocalization(language);\n\tconst [isAllSelected, setIsAllSelected] = useState(false);\n\tconst {\n\t\tisSelected: isSimilaritySearchSelected,\n\t\tisNLSSelected,\n\t\tNLSSearchText,\n\t} = useSimilaritySearchStore();\n\tconst [isAssetCountsLoading, setIsAssetCountsLoading] = useState(false);\n\n\tconst { data, isLoading } = useGetFilters(\n\t\t{\n\t\t\tfilter,\n\t\t\tsearchTerm: searchValue || null,\n\t\t\tallAssetTypes: assetTypes,\n\t\t\tlanguage,\n\t\t\tpredefinedFilter,\n\t\t\tcollectionId: page.page === 'collection' ? page.collection.id : null,\n\t\t},\n\t\tnoCache,\n\t);\n\n\tconst { data: newData } = useNewFilters(noCache);\n\n\tuseEffect(() => {\n\t\tif (page.page !== currentPage) {\n\t\t\tsetCurrentPage(page.page);\n\t\t\tfilter.clear();\n\t\t}\n\n\t\treturn () => {\n\t\t\tfilter.clear();\n\t\t};\n\t}, [currentPage, page.page]); // eslint-disable-line react-hooks/exhaustive-deps\n\t// filter is not a dependency because it's a context value\n\t// we do not need to re-run the effect when the filter context value changes\n\n\tuseEffect(() => {\n\t\tlet isCancelled = false;\n\n\t\tconst fetchAssetCounts = async () => {\n\t\t\tsetIsAssetCountsLoading(true);\n\n\t\t\ttry {\n\t\t\t\tconst response = await getAssetCounts({\n\t\t\t\t\tauth,\n\t\t\t\t\tfilter: {\n\t\t\t\t\t\tsearchTerm: searchValue,\n\t\t\t\t\t\tassetTypes,\n\t\t\t\t\t\tcollectionId: page.page === 'collection' ? page.collection.id : undefined,\n\t\t\t\t\t\ttagNames: filter.tags,\n\t\t\t\t\t\tisLimitedUse: filter.isLimited,\n\t\t\t\t\t\tmetaproperties: filter.selectedSmartfilterOptions,\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tfilter.setActiveFiltersState(response);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tconsole.error('Error fetching asset counts:', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (!isCancelled) {\n\t\t\t\t\tsetIsAssetCountsLoading(false);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfetchAssetCounts();\n\n\t\treturn () => {\n\t\t\tisCancelled = true;\n\t\t};\n\t}, [filter.tags, searchValue, assetTypes, page.page, filter.selectedSmartfilterOptions]); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tif (\n\t\tdata.tag === 'Failure' ||\n\t\t!data.value ||\n\t\tnewData.tag === 'Failure' ||\n\t\tnewData.tag === 'Loading' ||\n\t\t!newData.value ||\n\t\tisAssetCountsLoading\n\t) {\n\t\treturn (\n\t\t\t<NavParent>\n\t\t\t\t<SkeletonFilters />\n\t\t\t</NavParent>\n\t\t);\n\t}\n\n\tconst { tags, count } = data.value.searchAssets;\n\tconst { value: filterData } = newData;\n\n\tconst selectAllHandler = (() => {\n\t\tif (isAllSelected) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tclearSelection();\n\t\t\t\t\t\tsetIsAllSelected(false);\n\t\t\t\t\t}}\n\t\t\t\t\ticon={<IconMultiSelect />}\n\t\t\t\t\ttitle=\"\"\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tdata-testid=\"deselect-all\"\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tonClick={() => {\n\t\t\t\t\tselectAll();\n\t\t\t\t\tsetIsAllSelected(true);\n\t\t\t\t}}\n\t\t\t\ticon={<IconRectangle />}\n\t\t\t\ttitle=\"\"\n\t\t\t\tvariant=\"secondary\"\n\t\t\t\tdata-testid=\"select-all\"\n\t\t\t/>\n\t\t);\n\t})();\n\n\tif (isSimilaritySearchSelected || (isNLSSelected && NLSSearchText)) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<NavParent data-testid=\"filter-nav\">\n\t\t\t<HorizontalScroll>\n\t\t\t\t{filterData && filterData.filters.length > 0 && (\n\t\t\t\t\t<SmartfilterComponentNew filterData={filterData} />\n\t\t\t\t)}\n\t\t\t\t{tags && tags.nodes.length > 0 && <Tags tags={tags.nodes} isLoading={isLoading} />}\n\t\t\t\t<Advanced isLoading={isLoading} count={count.assetType} />\n\t\t\t</HorizontalScroll>\n\n\t\t\t<AssetFilterDropdownContainer>\n\t\t\t\t{selectionMode === 'MultiSelect' &&\n\t\t\t\t\tselectAllOption &&\n\t\t\t\t\tpage.page === 'assets' &&\n\t\t\t\t\tselectAllHandler}\n\t\t\t</AssetFilterDropdownContainer>\n\t\t</NavParent>\n\t);\n}\n\n// eslint-disable-next-line react/no-multi-comp\nfunction SkeletonFilters() {\n\treturn (\n\t\t<SkeletonWrapper>\n\t\t\t<Skeleton width={100} />\n\t\t\t<Skeleton width={80} />\n\t\t\t<Skeleton width={110} />\n\t\t</SkeletonWrapper>\n\t);\n}\n\nconst NavParent = styled.nav`\n\tdisplay: flex;\n\tjustify-content: space-between;\n\tbackground-color: #fff;\n\tpadding: ${token.spacing3} ${token.spacing4};\n\tz-index: 20;\n`;\n\nconst AssetFilterDropdownContainer = styled.div`\n\tdisplay: flex;\n\talign-items: center;\n\n\tbutton {\n\t\theight: initial;\n\t\tbackground-color: transparent;\n\t\tborder: none;\n\t\tpadding: 0;\n\t}\n`;\n\nconst SkeletonWrapper = styled.div`\n\tdisplay: inline-flex;\n\talign-items: center;\n`;\n"],"names":["AssetFilter","filter","useAssetFilter","page","useRouterSelectors","searchValue","useSearchStateByPage","assetTypes","language","predefinedFilter","noCache","selectionMode","selectAllOption","useConfig","clearSelection","selectAll","useSelection","auth","useAuth","currentPage","setCurrentPage","useState","useLocalization","isAllSelected","setIsAllSelected","isSimilaritySearchSelected","isNLSSelected","NLSSearchText","useSimilaritySearchStore","isAssetCountsLoading","setIsAssetCountsLoading","data","isLoading","useGetFilters","newData","useNewFilters","useEffect","isCancelled","response","getAssetCounts","error","jsx","NavParent","SkeletonFilters","tags","count","filterData","selectAllHandler","Button","IconMultiSelect","IconRectangle","jsxs","HorizontalScroll","SmartfilterComponentNew","Tags","Advanced","AssetFilterDropdownContainer","SkeletonWrapper","Skeleton","styled","token"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBO,SAASA,KAAc;AAC7B,QAAMC,IAASC,EAAA,GACTC,IAAOC,EAAmB,IAAI,KAAA,GAC9B,EAAE,OAAO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BAAAwB,EAACT,GAAA,EAAU,eAAY,cACtB,UAAA;AAAA,IAAA,gBAAAS,EAACC,GAAA,EACC,UAAA;AAAA,MAAAN,KAAcA,EAAW,QAAQ,SAAS,KAC1C,gBAAAL,EAACY,KAAwB,YAAAP,GAAwB;AAAA,MAEjDF,KAAQA,EAAK,MAAM,SAAS,uBAAMU,GAAA,EAAK,MAAMV,EAAK,OAAO,WAAAZ,EAAA,CAAsB;AAAA,MAChF,gBAAAS,EAACc,GAAA,EAAS,WAAAvB,GAAsB,OAAOa,EAAM,UAAA,CAAW;AAAA,IAAA,GACzD;AAAA,IAEA,gBAAAJ,EAACe,MACC,UAAA7C,MAAkB,iBAClBC,KACAT,EAAK,SAAS,YACd4C,EAAA,CACF;AAAA,EAAA,GACD;AAEF;AAGA,SAASJ,KAAkB;AAC1B,2BACEc,IAAA,EACA,UAAA;AAAA,IAAA,gBAAAhB,EAACiB,GAAA,EAAS,OAAO,IAAA,CAAK;AAAA,IACtB,gBAAAjB,EAACiB,GAAA,EAAS,OAAO,GAAA,CAAI;AAAA,IACrB,gBAAAjB,EAACiB,GAAA,EAAS,OAAO,IAAA,CAAK;AAAA,EAAA,GACvB;AAEF;AAEA,MAAMhB,IAAYiB,EAAO;AAAA;AAAA;AAAA;AAAA,YAIbC,EAAM,QAAQ,IAAIA,EAAM,QAAQ;AAAA;AAAA,GAItCJ,KAA+BG,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAYtCF,KAAkBE,EAAO;AAAA;AAAA;AAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetFilterContext.js","sources":["../../src/filter/AssetFilterContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useMemo, useEffect } from 'react';\nimport { AssetType } from '../views/asset/asset.type';\nimport { MetapropertyOptionType as MetapropertyOption } from './filters/metaproperty/MetapropertyOption';\nimport { AssetFilterJson } from '@src/filter/assetFilter.type';\nimport {\n\tAutcompleteResponseOption,\n\tSmartfilterOption,\n\tAutocompleteOption,\n\tSmartfilterSelectedOptionType,\n\tselectedSmartfilterOptionsType,\n\tAssetCountType,\n} from '@src/api/rest/types';\n\nexport interface Filter {\n\tassetTypes: AssetType[];\n\tmetaproperties: MetapropertyOption[];\n\tmetapropertyIds?: string[];\n\ttags: string[];\n\tisLimited?: boolean;\n\tisDropdownActive?: boolean;\n\tselectedSmartfilterOptions?: selectedSmartfilterOptionsType;\n\texistingFilters?: Record<string, Record<string, number>> | null;\n}\n\ninterface Actions {\n\taddAssetType: (assetType: AssetType) => void;\n\tremoveAssetType: (assetType: AssetType) => void;\n\taddMetaproperty: (metaproperty: MetapropertyOption) => void;\n\tremoveMetaproperty: (metaproperty: MetapropertyOption) => void;\n\tsetPredefinedMetaproperties: (metaproperties: Record<string, MetapropertyOption>) => void;\n\taddTag: (tag: string) => void;\n\tremoveTag: (tag: string) => void;\n\tclear: () => void;\n\tsetDropdownState: (active: boolean) => void;\n\tselectSmartfilterOption: (\n\t\tmetapropertyName: string,\n\t\toption: SmartfilterOption | AutcompleteResponseOption,\n\t\tisMultifilter?: boolean,\n\t) => void;\n\tremoveSmartfilterOption: (metapropertyName: string, optionId: string) => void;\n\tsetActiveFiltersState: (count: AssetCountType) => void;\n}\n\ntype MetapropertyMapType = Record<string, MetapropertyOption>;\n\nexport const AssetFilterContext = createContext<(Filter & Actions) | null>(null);\n\nexport function AssetFilterProvider({\n\tchildren,\n\thideLimitedUse = false,\n\tpredefinedFilter,\n}: {\n\tchildren: React.ReactNode;\n\thideLimitedUse?: boolean;\n\tpredefinedFilter?: AssetFilterJson;\n}) {\n\tconst [assetTypes, setAssetTypes] = useState<AssetType[]>(\n\t\tpredefinedFilter?.predefinedAssetType ? [...predefinedFilter?.predefinedAssetType] : [],\n\t);\n\tconst [metapropertyIds, setMetapropertyIds] = useState<string[]>([]);\n\tconst [isDropdownActive, setIsDropdownActive] = useState<boolean>(false);\n\tconst [tags, setTags] = useState<string[]>(\n\t\tpredefinedFilter?.predefinedTagNames ? [...predefinedFilter.predefinedTagNames] : [],\n\t);\n\tconst [isLimited, setIsLimited] = useState<boolean | undefined>();\n\tconst [metapropertyMap, setMetapropertyMap] = useState<MetapropertyMapType>({});\n\tconst [selectedSmartfilterOptions, setSelectedSmartfilterOptions] = useState<\n\t\tRecord<string, Record<string, SmartfilterSelectedOptionType>>\n\t>({});\n\tconst [existingFilters, setExistingFilters] = useState<Record<\n\t\tstring,\n\t\tRecord<string, number>\n\t> | null>(null);\n\n\tuseEffect(() => {\n\t\t// If hideLimitedUse is false, we want to display all assets and we don't\n\t\t// filter on isLimited. If hideLimitedUse is true we want to hide limited\n\t\t// assets, so we filter by setting isLimited to false.\n\t\tsetIsLimited(hideLimitedUse ? false : undefined);\n\t}, [hideLimitedUse]);\n\n\tuseEffect(() => {\n\t\tsetPredefinedMetaproperties();\n\t}, [predefinedFilter?.predefinedMetapropertiesOptions]); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tfunction addAssetType(assetType: AssetType) {\n\t\tsetAssetTypes((prevAssetTypes) => addToSet(prevAssetTypes, assetType));\n\t}\n\n\tfunction removeAssetType(assetType: AssetType) {\n\t\tif (\n\t\t\tpredefinedFilter?.showToolbar &&\n\t\t\tpredefinedFilter.predefinedAssetType?.includes(assetType)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAssetTypes((prevAssetTypes) => removeFromSet(prevAssetTypes, assetType));\n\t}\n\n\tfunction addMetaproperty(metaproperty: MetapropertyOption) {\n\t\tsetMetapropertyIds((prevMetapropertyIds) => addToSet(prevMetapropertyIds, metaproperty.id));\n\t\tsetMetapropertyMap((prevMetaproperties) => ({\n\t\t\t...prevMetaproperties,\n\t\t\t[metaproperty.id]: metaproperty,\n\t\t}));\n\t}\n\n\tfunction removeMetaproperty(metaproperty: MetapropertyOption) {\n\t\tsetMetapropertyIds((prevMetapropertyIds) =>\n\t\t\tremoveFromSet(prevMetapropertyIds, metaproperty.id),\n\t\t);\n\t\tsetMetapropertyMap((prevMetaproperties) => {\n\t\t\tconst { [metaproperty.id]: removed, ...remaining } = prevMetaproperties;\n\n\t\t\treturn remaining;\n\t\t});\n\t}\n\n\tfunction setPredefinedMetaproperties() {\n\t\tif (predefinedFilter?.predefinedMetapropertiesOptions) {\n\t\t\tsetSelectedSmartfilterOptions(() => {\n\t\t\t\treturn Object.entries(\n\t\t\t\t\tpredefinedFilter.predefinedMetapropertiesOptions || {},\n\t\t\t\t).reduce((acc, [key, value]) => {\n\t\t\t\t\tacc[key] = {};\n\t\t\t\t\tObject.entries(value).forEach(([name, id]) => {\n\t\t\t\t\t\tacc[key][id] = {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t\t\tmetapropertyName: key,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {});\n\t\t\t});\n\t\t}\n\t}\n\n\tfunction addTag(tag: string) {\n\t\tsetTags((prevTags) => addToSet(prevTags, tag));\n\t}\n\n\tfunction removeTag(tag: string) {\n\t\tif (predefinedFilter?.showToolbar && predefinedFilter.predefinedTagNames?.includes(tag)) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetTags((prevTags) => removeFromSet(prevTags, tag));\n\t}\n\n\tfunction selectSmartfilterOption(\n\t\tmetapropertyName: string,\n\t\toption: SmartfilterOption | AutocompleteOption,\n\t\tisMultifilter?: boolean,\n\t) {\n\t\tconst selectedOption: SmartfilterSelectedOptionType = {\n\t\t\tid: option.id,\n\t\t\tlabel: option.label,\n\t\t\tmetapropertyName,\n\t\t};\n\n\t\tsetSelectedSmartfilterOptions((prevOptions) => {\n\t\t\tconst currentSelections = prevOptions[metapropertyName] || {};\n\t\t\tconst isAlreadySelected = !!currentSelections[option.id];\n\n\t\t\tif (isMultifilter) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: isAlreadySelected\n\t\t\t\t\t\t? // Remove if already selected\n\t\t\t\t\t\t Object.fromEntries(\n\t\t\t\t\t\t\t\tObject.entries(currentSelections).filter(\n\t\t\t\t\t\t\t\t\t([key]) => key !== option.id,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: // Add if not selected already\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t...currentSelections,\n\t\t\t\t\t\t\t\t[option.id]: selectedOption,\n\t\t\t\t\t\t },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// For single selection:\n\t\t\t// Remove selection if already present\n\t\t\tif (isAlreadySelected) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: {},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Otherwise add the new selection\n\t\t\treturn {\n\t\t\t\t...prevOptions,\n\t\t\t\t[metapropertyName]: {\n\t\t\t\t\t[option.id]: selectedOption,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tfunction removeSmartfilterOption(metapropertyName: string, optionId: string) {\n\t\tsetSelectedSmartfilterOptions((prevOptions) => {\n\t\t\tconst { [metapropertyName]: removed, ...remaining } = prevOptions;\n\n\t\t\tconst { [optionId]: removedOption, ...remainingOptions } = removed || {};\n\n\t\t\tif (remainingOptions && Object.keys(remainingOptions).length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: remainingOptions,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn remaining;\n\t\t});\n\t}\n\n\tfunction setActiveFiltersState(count: AssetCountType) {\n\t\tconst activeMetaproperties = count.count;\n\t\tconst nonEmptyMetaproperties = Object.entries(activeMetaproperties || {})\n\t\t\t.filter(\n\t\t\t\t([key, value]) =>\n\t\t\t\t\tkey.startsWith('property') && value && Object.keys(value).length > 0,\n\t\t\t)\n\t\t\t.reduce((acc, [key, value]) => {\n\t\t\t\tacc[key.replace('property_', '')] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\n\t\tsetExistingFilters(nonEmptyMetaproperties);\n\t}\n\n\tfunction clear() {\n\t\tsetAssetTypes(\n\t\t\tpredefinedFilter?.showToolbar && predefinedFilter?.predefinedAssetType\n\t\t\t\t? [...predefinedFilter.predefinedAssetType]\n\t\t\t\t: [],\n\t\t);\n\n\t\tsetTags(\n\t\t\tpredefinedFilter?.showToolbar && predefinedFilter?.predefinedTagNames\n\t\t\t\t? [...predefinedFilter.predefinedTagNames]\n\t\t\t\t: [],\n\t\t);\n\n\t\tsetSelectedSmartfilterOptions({});\n\t\tsetExistingFilters(null);\n\t}\n\n\tconst metaproperties = metapropertyIds.map((id) => metapropertyMap[id]);\n\n\t// This function is used to set the state of the dropdown\n\t// so we can re-render the content in order to set the ref\n\t// which we need for scrolling. Wihout this, the ref is not\n\t// set and we can't scroll unless we click a metaproperty which\n\t// causes a re-render.\n\tfunction setDropdownState(state: boolean) {\n\t\tsetIsDropdownActive(state);\n\t}\n\n\tconst assetFilterContext = useMemo(\n\t\t() => ({\n\t\t\tassetTypes,\n\t\t\tmetaproperties,\n\t\t\tmetapropertyIds,\n\t\t\ttags,\n\t\t\tisLimited,\n\t\t\taddAssetType,\n\t\t\tremoveAssetType,\n\t\t\taddMetaproperty,\n\t\t\tremoveMetaproperty,\n\t\t\tsetPredefinedMetaproperties,\n\t\t\taddTag,\n\t\t\tremoveTag,\n\t\t\tclear,\n\t\t\tsetDropdownState,\n\t\t\tisDropdownActive,\n\t\t\tselectSmartfilterOption,\n\t\t\tremoveSmartfilterOption,\n\t\t\tselectedSmartfilterOptions,\n\t\t\tsetActiveFiltersState,\n\t\t\texistingFilters,\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[assetTypes, metaproperties, tags, isLimited, metapropertyIds, selectedSmartfilterOptions],\n\t);\n\n\treturn (\n\t\t<AssetFilterContext.Provider value={assetFilterContext}>\n\t\t\t{children}\n\t\t</AssetFilterContext.Provider>\n\t);\n}\n\nfunction addToSet<T>(set: T[], value: T) {\n\treturn set.includes(value) ? set : [...set, value];\n}\n\nfunction removeFromSet<T>(set: T[], value: T) {\n\treturn set.filter((prevValue) => prevValue !== value);\n}\n\nexport function keepPredefinedMetapropertiesInMap(\n\tmetapropertyMap: MetapropertyMapType,\n\tpredefinedMetaproperties: string[],\n) {\n\treturn predefinedMetaproperties.reduce((acc, id) => {\n\t\tif (metapropertyMap[id]) {\n\t\t\tacc[id] = metapropertyMap[id];\n\t\t}\n\n\t\treturn acc;\n\t}, {});\n}\n\nexport function useAssetFilter() {\n\tconst context = useContext(AssetFilterContext);\n\n\tif (context === null) {\n\t\tthrow new Error('useAssetFilter must be used with a AssetFilterProvider');\n\t}\n\n\treturn context;\n}\n"],"names":["AssetFilterContext","createContext","AssetFilterProvider","children","hideLimitedUse","predefinedFilter","assetTypes","setAssetTypes","useState","metapropertyIds","setMetapropertyIds","isDropdownActive","setIsDropdownActive","tags","setTags","isLimited","setIsLimited","metapropertyMap","setMetapropertyMap","selectedSmartfilterOptions","setSelectedSmartfilterOptions","existingFilters","setExistingFilters","useEffect","setPredefinedMetaproperties","addAssetType","assetType","prevAssetTypes","addToSet","removeAssetType","removeFromSet","addMetaproperty","metaproperty","prevMetapropertyIds","prevMetaproperties","removeMetaproperty","removed","remaining","acc","key","value","name","id","addTag","tag","prevTags","removeTag","selectSmartfilterOption","metapropertyName","option","isMultifilter","selectedOption","prevOptions","currentSelections","isAlreadySelected","removeSmartfilterOption","optionId","removedOption","remainingOptions","setActiveFiltersState","count","activeMetaproperties","nonEmptyMetaproperties","clear","metaproperties","setDropdownState","state","assetFilterContext","useMemo","set","prevValue","useAssetFilter","context","useContext"],"mappings":";;AA6CO,MAAMA,IAAqBC,EAAyC,IAAI;AAExE,SAASC,EAAoB;AAAA,EACnC,UAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC;AACD,GAIG;AACF,QAAM,CAACC,GAAYC,CAAa,IAAI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AeO,SAAS+B,IAAiB;AAChC,QAAMC,IAAUC,EAAWzE,CAAkB;AAE7C,MAAIwE,MAAY;AACf,UAAM,IAAI,MAAM,wDAAwD;AAGzE,SAAOA;AACR;"}
|
|
1
|
+
{"version":3,"file":"AssetFilterContext.js","sources":["../../src/filter/AssetFilterContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useState, useMemo, useEffect } from 'react';\nimport { AssetType } from '../views/asset/asset.type';\nimport { MetapropertyOptionType as MetapropertyOption } from './filters/metaproperty/MetapropertyOption';\nimport { AssetFilterJson } from '@src/filter/assetFilter.type';\nimport {\n\tAutcompleteResponseOption,\n\tSmartfilterOption,\n\tAutocompleteOption,\n\tSmartfilterSelectedOptionType,\n\tselectedSmartfilterOptionsType,\n\tAssetCountType,\n} from '@src/api/rest/types';\nimport { MetapropertyOption as MetapropertyOptionType } from '@src/api/types/getFilters_new';\n\nexport interface Filter {\n\tassetTypes: AssetType[];\n\tmetaproperties: MetapropertyOption[];\n\tmetapropertyIds?: string[];\n\ttags: string[];\n\tisLimited?: boolean;\n\tisDropdownActive?: boolean;\n\tselectedSmartfilterOptions?: selectedSmartfilterOptionsType;\n\texistingFilters?: Record<string, Record<string, number>> | null;\n}\n\ninterface Actions {\n\taddAssetType: (assetType: AssetType) => void;\n\tremoveAssetType: (assetType: AssetType) => void;\n\taddMetaproperty: (metaproperty: MetapropertyOption) => void;\n\tremoveMetaproperty: (metaproperty: MetapropertyOption) => void;\n\tsetPredefinedMetaproperties: (metaproperties: Record<string, MetapropertyOption>) => void;\n\taddTag: (tag: string) => void;\n\tremoveTag: (tag: string) => void;\n\tclear: () => void;\n\tsetDropdownState: (active: boolean) => void;\n\tselectSmartfilterOption: (\n\t\tmetapropertyName: string,\n\t\toption: SmartfilterOption | AutcompleteResponseOption,\n\t\tisMultifilter?: boolean,\n\t) => void;\n\tremoveSmartfilterOption: (metapropertyName: string, optionId: string) => void;\n\tsetActiveFiltersState: (count: AssetCountType) => void;\n}\n\ntype MetapropertyMapType = Record<string, MetapropertyOption>;\n\nexport const AssetFilterContext = createContext<(Filter & Actions) | null>(null);\n\nexport function AssetFilterProvider({\n\tchildren,\n\thideLimitedUse = false,\n\tpredefinedFilter,\n}: {\n\tchildren: React.ReactNode;\n\thideLimitedUse?: boolean;\n\tpredefinedFilter?: AssetFilterJson;\n}) {\n\tconst [assetTypes, setAssetTypes] = useState<AssetType[]>(\n\t\tpredefinedFilter?.predefinedAssetType ? [...predefinedFilter?.predefinedAssetType] : [],\n\t);\n\tconst [metapropertyIds, setMetapropertyIds] = useState<string[]>([]);\n\tconst [isDropdownActive, setIsDropdownActive] = useState<boolean>(false);\n\tconst [tags, setTags] = useState<string[]>(\n\t\tpredefinedFilter?.predefinedTagNames ? [...predefinedFilter.predefinedTagNames] : [],\n\t);\n\tconst [isLimited, setIsLimited] = useState<boolean | undefined>();\n\tconst [metapropertyMap, setMetapropertyMap] = useState<MetapropertyMapType>({});\n\tconst [selectedSmartfilterOptions, setSelectedSmartfilterOptions] = useState<\n\t\tRecord<string, Record<string, SmartfilterSelectedOptionType>>\n\t>({});\n\tconst [existingFilters, setExistingFilters] = useState<Record<\n\t\tstring,\n\t\tRecord<string, number>\n\t> | null>(null);\n\n\tuseEffect(() => {\n\t\t// If hideLimitedUse is false, we want to display all assets and we don't\n\t\t// filter on isLimited. If hideLimitedUse is true we want to hide limited\n\t\t// assets, so we filter by setting isLimited to false.\n\t\tsetIsLimited(hideLimitedUse ? false : undefined);\n\t}, [hideLimitedUse]);\n\n\tuseEffect(() => {\n\t\tsetPredefinedMetaproperties();\n\t}, [predefinedFilter?.predefinedMetapropertiesOptions]); // eslint-disable-line react-hooks/exhaustive-deps\n\n\tfunction addAssetType(assetType: AssetType) {\n\t\tsetAssetTypes((prevAssetTypes) => addToSet(prevAssetTypes, assetType));\n\t}\n\n\tfunction removeAssetType(assetType: AssetType) {\n\t\tif (\n\t\t\tpredefinedFilter?.showToolbar &&\n\t\t\tpredefinedFilter.predefinedAssetType?.includes(assetType)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAssetTypes((prevAssetTypes) => removeFromSet(prevAssetTypes, assetType));\n\t}\n\n\tfunction addMetaproperty(metaproperty: MetapropertyOption) {\n\t\tsetMetapropertyIds((prevMetapropertyIds) => addToSet(prevMetapropertyIds, metaproperty.id));\n\t\tsetMetapropertyMap((prevMetaproperties) => ({\n\t\t\t...prevMetaproperties,\n\t\t\t[metaproperty.id]: metaproperty,\n\t\t}));\n\t}\n\n\tfunction removeMetaproperty(metaproperty: MetapropertyOption) {\n\t\tsetMetapropertyIds((prevMetapropertyIds) =>\n\t\t\tremoveFromSet(prevMetapropertyIds, metaproperty.id),\n\t\t);\n\t\tsetMetapropertyMap((prevMetaproperties) => {\n\t\t\tconst { [metaproperty.id]: removed, ...remaining } = prevMetaproperties;\n\n\t\t\treturn remaining;\n\t\t});\n\t}\n\n\tfunction setPredefinedMetaproperties() {\n\t\tif (predefinedFilter?.predefinedMetapropertiesOptions) {\n\t\t\tsetSelectedSmartfilterOptions(() => {\n\t\t\t\treturn Object.entries(\n\t\t\t\t\tpredefinedFilter.predefinedMetapropertiesOptions || {},\n\t\t\t\t).reduce((acc, [key, value]) => {\n\t\t\t\t\tacc[key] = {};\n\t\t\t\t\tObject.entries(value).forEach(([name, id]) => {\n\t\t\t\t\t\tacc[key][id] = {\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t\t\tmetapropertyName: key,\n\t\t\t\t\t\t};\n\t\t\t\t\t});\n\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {});\n\t\t\t});\n\t\t}\n\t}\n\n\tfunction addTag(tag: string) {\n\t\tsetTags((prevTags) => addToSet(prevTags, tag));\n\t}\n\n\tfunction removeTag(tag: string) {\n\t\tif (predefinedFilter?.showToolbar && predefinedFilter.predefinedTagNames?.includes(tag)) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetTags((prevTags) => removeFromSet(prevTags, tag));\n\t}\n\n\tfunction selectSmartfilterOption(\n\t\tmetapropertyName: string,\n\t\toption: MetapropertyOptionType | AutocompleteOption,\n\t\tisMultifilter?: boolean,\n\t) {\n\t\tconst selectedOption: SmartfilterSelectedOptionType = {\n\t\t\tid: option.id,\n\t\t\tlabel: option.label,\n\t\t\tmetapropertyName,\n\t\t};\n\n\t\tsetSelectedSmartfilterOptions((prevOptions) => {\n\t\t\tconst currentSelections = prevOptions[metapropertyName] || {};\n\t\t\tconst isAlreadySelected = !!currentSelections[option.id];\n\n\t\t\tif (isMultifilter) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: isAlreadySelected\n\t\t\t\t\t\t? // Remove if already selected\n\t\t\t\t\t\t Object.fromEntries(\n\t\t\t\t\t\t\t\tObject.entries(currentSelections).filter(\n\t\t\t\t\t\t\t\t\t([key]) => key !== option.id,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: // Add if not selected already\n\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t...currentSelections,\n\t\t\t\t\t\t\t\t[option.id]: selectedOption,\n\t\t\t\t\t\t },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// For single selection:\n\t\t\t// Remove selection if already present\n\t\t\tif (isAlreadySelected) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: {},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Otherwise add the new selection\n\t\t\treturn {\n\t\t\t\t...prevOptions,\n\t\t\t\t[metapropertyName]: {\n\t\t\t\t\t[option.id]: selectedOption,\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\t}\n\n\tfunction removeSmartfilterOption(metapropertyName: string, optionId: string) {\n\t\tsetSelectedSmartfilterOptions((prevOptions) => {\n\t\t\tconst { [metapropertyName]: removed, ...remaining } = prevOptions;\n\n\t\t\tconst { [optionId]: removedOption, ...remainingOptions } = removed || {};\n\n\t\t\tif (remainingOptions && Object.keys(remainingOptions).length > 0) {\n\t\t\t\treturn {\n\t\t\t\t\t...prevOptions,\n\t\t\t\t\t[metapropertyName]: remainingOptions,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn remaining;\n\t\t});\n\t}\n\n\tfunction setActiveFiltersState(count: AssetCountType) {\n\t\tconst activeMetaproperties = count.count;\n\t\tconst nonEmptyMetaproperties = Object.entries(activeMetaproperties || {})\n\t\t\t.filter(\n\t\t\t\t([key, value]) =>\n\t\t\t\t\tkey.startsWith('property') && value && Object.keys(value).length > 0,\n\t\t\t)\n\t\t\t.reduce((acc, [key, value]) => {\n\t\t\t\tacc[key.replace('property_', '')] = value;\n\n\t\t\t\treturn acc;\n\t\t\t}, {});\n\n\t\tsetExistingFilters(nonEmptyMetaproperties);\n\t}\n\n\tfunction clear() {\n\t\tsetAssetTypes(\n\t\t\tpredefinedFilter?.showToolbar && predefinedFilter?.predefinedAssetType\n\t\t\t\t? [...predefinedFilter.predefinedAssetType]\n\t\t\t\t: [],\n\t\t);\n\n\t\tsetTags(\n\t\t\tpredefinedFilter?.showToolbar && predefinedFilter?.predefinedTagNames\n\t\t\t\t? [...predefinedFilter.predefinedTagNames]\n\t\t\t\t: [],\n\t\t);\n\n\t\tsetSelectedSmartfilterOptions({});\n\t\tsetExistingFilters(null);\n\t}\n\n\tconst metaproperties = metapropertyIds.map((id) => metapropertyMap[id]);\n\n\t// This function is used to set the state of the dropdown\n\t// so we can re-render the content in order to set the ref\n\t// which we need for scrolling. Wihout this, the ref is not\n\t// set and we can't scroll unless we click a metaproperty which\n\t// causes a re-render.\n\tfunction setDropdownState(state: boolean) {\n\t\tsetIsDropdownActive(state);\n\t}\n\n\tconst assetFilterContext = useMemo(\n\t\t() => ({\n\t\t\tassetTypes,\n\t\t\tmetaproperties,\n\t\t\tmetapropertyIds,\n\t\t\ttags,\n\t\t\tisLimited,\n\t\t\taddAssetType,\n\t\t\tremoveAssetType,\n\t\t\taddMetaproperty,\n\t\t\tremoveMetaproperty,\n\t\t\tsetPredefinedMetaproperties,\n\t\t\taddTag,\n\t\t\tremoveTag,\n\t\t\tclear,\n\t\t\tsetDropdownState,\n\t\t\tisDropdownActive,\n\t\t\tselectSmartfilterOption,\n\t\t\tremoveSmartfilterOption,\n\t\t\tselectedSmartfilterOptions,\n\t\t\tsetActiveFiltersState,\n\t\t\texistingFilters,\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[assetTypes, metaproperties, tags, isLimited, metapropertyIds, selectedSmartfilterOptions],\n\t);\n\n\treturn (\n\t\t<AssetFilterContext.Provider value={assetFilterContext}>\n\t\t\t{children}\n\t\t</AssetFilterContext.Provider>\n\t);\n}\n\nfunction addToSet<T>(set: T[], value: T) {\n\treturn set.includes(value) ? set : [...set, value];\n}\n\nfunction removeFromSet<T>(set: T[], value: T) {\n\treturn set.filter((prevValue) => prevValue !== value);\n}\n\nexport function keepPredefinedMetapropertiesInMap(\n\tmetapropertyMap: MetapropertyMapType,\n\tpredefinedMetaproperties: string[],\n) {\n\treturn predefinedMetaproperties.reduce((acc, id) => {\n\t\tif (metapropertyMap[id]) {\n\t\t\tacc[id] = metapropertyMap[id];\n\t\t}\n\n\t\treturn acc;\n\t}, {});\n}\n\nexport function useAssetFilter() {\n\tconst context = useContext(AssetFilterContext);\n\n\tif (context === null) {\n\t\tthrow new Error('useAssetFilter must be used with a AssetFilterProvider');\n\t}\n\n\treturn context;\n}\n"],"names":["AssetFilterContext","createContext","AssetFilterProvider","children","hideLimitedUse","predefinedFilter","assetTypes","setAssetTypes","useState","metapropertyIds","setMetapropertyIds","isDropdownActive","setIsDropdownActive","tags","setTags","isLimited","setIsLimited","metapropertyMap","setMetapropertyMap","selectedSmartfilterOptions","setSelectedSmartfilterOptions","existingFilters","setExistingFilters","useEffect","setPredefinedMetaproperties","addAssetType","assetType","prevAssetTypes","addToSet","removeAssetType","removeFromSet","addMetaproperty","metaproperty","prevMetapropertyIds","prevMetaproperties","removeMetaproperty","removed","remaining","acc","key","value","name","id","addTag","tag","prevTags","removeTag","selectSmartfilterOption","metapropertyName","option","isMultifilter","selectedOption","prevOptions","currentSelections","isAlreadySelected","removeSmartfilterOption","optionId","removedOption","remainingOptions","setActiveFiltersState","count","activeMetaproperties","nonEmptyMetaproperties","clear","metaproperties","setDropdownState","state","assetFilterContext","useMemo","set","prevValue","useAssetFilter","context","useContext"],"mappings":";;AA8CO,MAAMA,IAAqBC,EAAyC,IAAI;AAExE,SAASC,EAAoB;AAAA,EACnC,UAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC;AACD,GAIG;AACF,QAAM,CAACC,GAAYC,CAAa,IAAIC;AAAA,IACnCH,GAAkB,sBAAsB,CAAC,GAAGA,GAAkB,mBAAmB,IAAI,CAAA;AAAA,EAAC,GAEjF,CAACI,GAAiBC,CAAkB,IAAIF,EAAmB,CAAA,CAAE,GAC7D,CAACG,GAAkBC,CAAmB,IAAIJ,EAAkB,EAAK,GACjE,CAACK,GAAMC,CAAO,IAAIN;AAAA,IACvBH,GAAkB,qBAAqB,CAAC,GAAGA,EAAiB,kBAAkB,IAAI,CAAA;AAAA,EAAC,GAE9E,CAACU,GAAWC,CAAY,IAAIR,EAAA,GAC5B,CAACS,GAAiBC,CAAkB,IAAIV,EAA8B,CAAA,CAAE,GACxE,CAACW,GAA4BC,CAA6B,IAAIZ,EAElE,CAAA,CAAE,GACE,CAACa,GAAiBC,CAAkB,IAAId,EAGpC,IAAI;AAEd,EAAAe,EAAU,MAAM;AAIf,IAAAP,EAAaZ,IAAiB,KAAQ,MAAS;AAAA,EAChD,GAAG,CAACA,CAAc,CAAC,GAEnBmB,EAAU,MAAM;AACf,IAAAC,EAAA;AAAA,EACD,GAAG,CAACnB,GAAkB,+BAA+B,CAAC;AAEtD,WAASoB,EAAaC,GAAsB;AAC3C,IAAAnB,EAAc,CAACoB,MAAmBC,EAASD,GAAgBD,CAAS,CAAC;AAAA,EACtE;AAEA,WAASG,EAA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