@bynder/compact-view 5.1.3 → 5.1.4
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/ActiveFilter.js +33 -0
- package/ActiveFilter.js.map +1 -0
- package/ActiveFilters.js +81 -0
- package/ActiveFilters.js.map +1 -0
- package/AddMedia.js +90 -0
- package/AddMedia.js.map +1 -0
- package/Advanced.js +66 -0
- package/Advanced.js.map +1 -0
- package/App.d.ts +1 -1
- package/App.js +89 -0
- package/App.js.map +1 -0
- package/AssetCard.js +172 -0
- package/AssetCard.js.map +1 -0
- package/AssetCardMetaproperties.js +47 -0
- package/AssetCardMetaproperties.js.map +1 -0
- package/AssetFilter.js +158 -0
- package/AssetFilter.js.map +1 -0
- package/AssetFilterContext.js +162 -0
- package/AssetFilterContext.js.map +1 -0
- package/AssetItem.js +40 -0
- package/AssetItem.js.map +1 -0
- package/AssetList.js +158 -0
- package/AssetList.js.map +1 -0
- package/AssetTypeItem.js +34 -0
- package/AssetTypeItem.js.map +1 -0
- package/AssetsView.js +61 -0
- package/AssetsView.js.map +1 -0
- package/Autocomplete.js +148 -0
- package/Autocomplete.js.map +1 -0
- package/ButtonAction.js +14 -0
- package/ButtonAction.js.map +1 -0
- package/CardSkeleton.js +31 -0
- package/CardSkeleton.js.map +1 -0
- package/Checkbox.styles.js +38 -0
- package/Checkbox.styles.js.map +1 -0
- package/Chip.js +43 -0
- package/Chip.js.map +1 -0
- package/CollectionCard.js +56 -0
- package/CollectionCard.js.map +1 -0
- package/CollectionItem.js +41 -0
- package/CollectionItem.js.map +1 -0
- package/CollectionList.js +53 -0
- package/CollectionList.js.map +1 -0
- package/CollectionView.js +73 -0
- package/CollectionView.js.map +1 -0
- package/CollectionsView.js +58 -0
- package/CollectionsView.js.map +1 -0
- package/ConfigContext.js +18 -0
- package/ConfigContext.js.map +1 -0
- package/ConnectButton.js +20 -0
- package/ConnectButton.js.map +1 -0
- package/Container.js +52 -0
- package/Container.js.map +1 -0
- package/ContextAction.js +42 -0
- package/ContextAction.js.map +1 -0
- package/Dat/Dat.d.ts +2 -12
- package/Dat/DatDropdownItem.d.ts +1 -1
- package/Dat/index.d.ts +0 -1
- package/Dat.js +90 -0
- package/Dat.js.map +1 -0
- package/DatDropdownItem.js +47 -0
- package/DatDropdownItem.js.map +1 -0
- package/DesignSystemContext.js +12 -0
- package/DesignSystemContext.js.map +1 -0
- package/DirectionSelect.js +43 -0
- package/DirectionSelect.js.map +1 -0
- package/DocumentIcon.js +69 -0
- package/DocumentIcon.js.map +1 -0
- package/DomainInput.js +39 -0
- package/DomainInput.js.map +1 -0
- package/DragSelect.js +144 -0
- package/DragSelect.js.map +1 -0
- package/Dropdown.js +72 -0
- package/Dropdown.js.map +1 -0
- package/DropdownContent.js +59 -0
- package/DropdownContent.js.map +1 -0
- package/DropdownListItem.js +52 -0
- package/DropdownListItem.js.map +1 -0
- package/ErrorIcon.js +48 -0
- package/ErrorIcon.js.map +1 -0
- package/ErrorMessage.js +40 -0
- package/ErrorMessage.js.map +1 -0
- package/FieldSelect.js +74 -0
- package/FieldSelect.js.map +1 -0
- package/FileSelector.js +239 -0
- package/FileSelector.js.map +1 -0
- package/Header.js +42 -0
- package/Header.js.map +1 -0
- package/HorizontalScroll.js +51 -0
- package/HorizontalScroll.js.map +1 -0
- package/InfiniteScroll.js +26 -0
- package/InfiniteScroll.js.map +1 -0
- package/LeftArrow.js +31 -0
- package/LeftArrow.js.map +1 -0
- package/LoginComponent.js +32 -0
- package/LoginComponent.js.map +1 -0
- package/LoginContext.js +85 -0
- package/LoginContext.js.map +1 -0
- package/MetapropertyFilterContent.js +25 -0
- package/MetapropertyFilterContent.js.map +1 -0
- package/MetapropertyOption.js +24 -0
- package/MetapropertyOption.js.map +1 -0
- package/Modal.js +48 -0
- package/Modal.js.map +1 -0
- package/NoResults.js +51 -0
- package/NoResults.js.map +1 -0
- package/Oops.js +54 -0
- package/Oops.js.map +1 -0
- package/Option.js +50 -0
- package/Option.js.map +1 -0
- package/RefreshingSpinner.js +22 -0
- package/RefreshingSpinner.js.map +1 -0
- package/ReportModal.js +51 -0
- package/ReportModal.js.map +1 -0
- package/RightArrow.js +31 -0
- package/RightArrow.js.map +1 -0
- package/RootElementContext.js +12 -0
- package/RootElementContext.js.map +1 -0
- package/SearchInput.js +76 -0
- package/SearchInput.js.map +1 -0
- package/SelectedItemContainer.js +44 -0
- package/SelectedItemContainer.js.map +1 -0
- package/SelectedItems.js +27 -0
- package/SelectedItems.js.map +1 -0
- package/SelectionContext.js +144 -0
- package/SelectionContext.js.map +1 -0
- package/SelectionFooter.js +65 -0
- package/SelectionFooter.js.map +1 -0
- package/ShadowRoot.js +11 -0
- package/ShadowRoot.js.map +1 -0
- package/ShadowRootInternal.js +78 -0
- package/ShadowRootInternal.js.map +1 -0
- package/Shield.js +25 -0
- package/Shield.js.map +1 -0
- package/Skeleton.js +43 -0
- package/Skeleton.js.map +1 -0
- package/SmartFilterContent.js +11 -0
- package/SmartFilterContent.js.map +1 -0
- package/SmartFilterSelect.js +91 -0
- package/SmartFilterSelect.js.map +1 -0
- package/Smartfilters.js +186 -0
- package/Smartfilters.js.map +1 -0
- package/Spinner.js +32 -0
- package/Spinner.js.map +1 -0
- package/StatefulAssetList.js +100 -0
- package/StatefulAssetList.js.map +1 -0
- package/Styles.css.js +5 -0
- package/Styles.css.js.map +1 -0
- package/SwitchNLS.js +80 -0
- package/SwitchNLS.js.map +1 -0
- package/TagItem.js +38 -0
- package/TagItem.js.map +1 -0
- package/Tags.js +48 -0
- package/Tags.js.map +1 -0
- package/Theming.js +30 -0
- package/Theming.js.map +1 -0
- package/Toolbar.js +53 -0
- package/Toolbar.js.map +1 -0
- package/Tooltip.js +81 -0
- package/Tooltip.js.map +1 -0
- package/ViewSwitch.js +45 -0
- package/ViewSwitch.js.map +1 -0
- package/api/filterAssets.d.ts +1 -1
- package/api/getCollections.d.ts +1 -1
- package/api/getFilters.d.ts +1 -1
- package/api/getSimilarityAssets.d.ts +1 -1
- package/api/index.d.ts +2 -2
- package/api/rest/autocomplete.d.ts +1 -1
- package/api/rest/getAssetCounts.d.ts +2 -2
- package/api/rest/getInitialFilters.d.ts +2 -2
- package/api/rest/getMetapropertiesOptions.d.ts +1 -1
- package/app-config/ConfigContext.d.ts +3 -4
- package/app-config/appConfig.type.guard.d.ts +1 -1
- package/asset.type.js +31 -0
- package/asset.type.js.map +1 -0
- package/asyncDebounce.js +14 -0
- package/asyncDebounce.js.map +1 -0
- package/auth.js +35 -0
- package/auth.js.map +1 -0
- package/autocomplete2.js +25 -0
- package/autocomplete2.js.map +1 -0
- package/base64Converter.js +15 -0
- package/base64Converter.js.map +1 -0
- package/chunk.js +10 -0
- package/chunk.js.map +1 -0
- package/class.js +7 -0
- package/class.js.map +1 -0
- package/combineFilters.js +9 -0
- package/combineFilters.js.map +1 -0
- package/combineMetaproperties.js +25 -0
- package/combineMetaproperties.js.map +1 -0
- package/common/components/CardSkeleton.d.ts +1 -1
- package/common/components/Checkbox.styles.d.ts +4 -4
- package/common/components/Chip.d.ts +1 -1
- package/common/components/DocumentIcon.d.ts +1 -1
- package/common/components/DragSelect.d.ts +1 -1
- package/common/components/HorizontalScroll.d.ts +1 -1
- package/common/components/InfiniteScroll.d.ts +1 -1
- package/common/components/LeftArrow.d.ts +1 -1
- package/common/components/Modal.d.ts +1 -1
- package/common/components/NoResults.d.ts +1 -1
- package/common/components/RightArrow.d.ts +1 -1
- package/common/components/Skeleton.d.ts +1 -1
- package/common/components/Spinner.d.ts +1 -1
- package/common/components/Tooltip.d.ts +1 -1
- package/common/components/dropdown/Dropdown.d.ts +1 -1
- package/common/components/dropdown/DropdownContent.d.ts +1 -1
- package/common/components/dropdown/DropdownListItem.d.ts +1 -1
- package/common/hooks/useClickOutside.d.ts +1 -1
- package/constants.js +15 -0
- package/constants.js.map +1 -0
- package/createSelectors.js +11 -0
- package/createSelectors.js.map +1 -0
- package/crypto.js +21 -0
- package/crypto.js.map +1 -0
- package/error-handling/ErrorIcon.d.ts +1 -1
- package/error-handling/ErrorMessage.d.ts +1 -1
- package/error-handling/Oops.d.ts +1 -1
- package/error-handling/ReportModal.d.ts +1 -1
- package/error-handling/Shield.d.ts +1 -1
- package/filter/AssetFilter.d.ts +1 -1
- package/filter/AssetFilterContext.d.ts +3 -3
- package/filter/active-filters/ActiveFilter.d.ts +1 -1
- package/filter/active-filters/ActiveFilters.d.ts +1 -1
- package/filter/filters/advanced/Advanced.d.ts +1 -1
- package/filter/filters/advanced/AssetTypeItem.d.ts +1 -1
- package/filter/filters/metaproperty/Metaproperty.d.ts +1 -1
- package/filter/filters/metaproperty/MetapropertyFilterContent.d.ts +1 -1
- package/filter/filters/metaproperty/MetapropertyOption.d.ts +1 -1
- package/filter/filters/metaproperty/SmartFilterContent.d.ts +1 -1
- package/filter/filters/smartfilters/Metaproperties/Autocomplete.d.ts +3 -3
- package/filter/filters/smartfilters/Metaproperties/Option.d.ts +2 -2
- package/filter/filters/smartfilters/Metaproperties/SmartFilterSelect.d.ts +2 -2
- package/filter/filters/smartfilters/Smartfilters.d.ts +2 -2
- package/filter/filters/tags/TagItem.d.ts +1 -1
- package/filter/filters/tags/Tags.d.ts +1 -1
- package/filterAssets.js +175 -0
- package/filterAssets.js.map +1 -0
- package/filterEmptyMetaproperties.js +11 -0
- package/filterEmptyMetaproperties.js.map +1 -0
- package/getAsset.js +70 -0
- package/getAsset.js.map +1 -0
- package/getAssetCounts.js +27 -0
- package/getAssetCounts.js.map +1 -0
- package/getAssets.js +137 -0
- package/getAssets.js.map +1 -0
- package/getCollections.js +78 -0
- package/getCollections.js.map +1 -0
- package/getFilters.js +84 -0
- package/getFilters.js.map +1 -0
- package/getInitialFilters.js +51 -0
- package/getInitialFilters.js.map +1 -0
- package/getMetapropertiesOptions.js +31 -0
- package/getMetapropertiesOptions.js.map +1 -0
- package/getSimilarityAssets.js +141 -0
- package/getSimilarityAssets.js.map +1 -0
- package/handlers.js +11 -0
- package/handlers.js.map +1 -0
- package/helpers.js +7 -0
- package/helpers.js.map +1 -0
- package/index.js +9 -1162
- package/index.js.map +1 -0
- package/index2.js +18 -0
- package/index2.js.map +1 -0
- package/index3.js +36 -0
- package/index3.js.map +1 -0
- package/index4.js +20 -0
- package/index4.js.map +1 -0
- package/logger.js +7 -0
- package/logger.js.map +1 -0
- package/login/LoginComponent.d.ts +1 -1
- package/login/LoginContext.d.ts +1 -1
- package/login/components/ConnectButton.d.ts +1 -1
- package/login/components/Container.d.ts +1 -1
- package/login/components/DomainInput.d.ts +1 -1
- package/login/components/Header.d.ts +1 -1
- package/login/components/RefreshingSpinner.d.ts +1 -1
- package/loginwindow.js +84 -0
- package/loginwindow.js.map +1 -0
- package/normalizeResponse.js +31 -0
- package/normalizeResponse.js.map +1 -0
- package/oauth2.js +87 -0
- package/oauth2.js.map +1 -0
- package/order/DirectionSelect.d.ts +1 -1
- package/order/FieldSelect.d.ts +2 -2
- package/package.json +2 -9
- package/result.type.js +25 -0
- package/result.type.js.map +1 -0
- package/router/RouterContext.d.ts +1 -1
- package/search/SearchInput.d.ts +1 -1
- package/search/SwitchNLS.d.ts +1 -1
- package/search/index.d.ts +0 -2
- package/select/FileSelector.d.ts +1 -1
- package/select/SelectionContext.d.ts +1 -1
- package/select/SelectionFooter.d.ts +1 -1
- package/select/add-media/AddMedia.d.ts +1 -1
- package/select/add-media/ButtonAction.d.ts +1 -1
- package/select/current-selection/AssetItem.d.ts +1 -1
- package/select/current-selection/CollectionItem.d.ts +1 -1
- package/select/current-selection/SelectedItemContainer.d.ts +1 -1
- package/select/current-selection/SelectedItems.d.ts +1 -1
- package/store/useDatStore.d.ts +73 -0
- package/store/useOrderingStore.d.ts +2 -2
- package/store/useRouterStore.d.ts +4 -4
- package/store/useSearchStore.d.ts +69 -0
- package/store/useSimilaritySearchStore.d.ts +67 -0
- package/style/DesignSystemContext.d.ts +1 -1
- package/style/RootElementContext.d.ts +1 -1
- package/style/Theming.d.ts +1 -1
- package/style/shadowroot/ShadowRoot.d.ts +1 -1
- package/style/shadowroot/ShadowRootInternal.d.ts +1 -1
- package/text.js +9 -0
- package/text.js.map +1 -0
- package/toolbar/Toolbar.d.ts +1 -1
- package/toolbar/ViewSwitch.d.ts +1 -1
- package/trimMetapropertyValue.js +6 -0
- package/trimMetapropertyValue.js.map +1 -0
- package/url.js +7 -0
- package/url.js.map +1 -0
- package/useAccountDomain.js +33 -0
- package/useAccountDomain.js.map +1 -0
- package/useAuthInformation.js +42 -0
- package/useAuthInformation.js.map +1 -0
- package/useClickOutside.js +16 -0
- package/useClickOutside.js.map +1 -0
- package/useDatStore.js +62 -0
- package/useDatStore.js.map +1 -0
- package/useDimensions.js +31 -0
- package/useDimensions.js.map +1 -0
- package/useOrderingStore.js +27 -0
- package/useOrderingStore.js.map +1 -0
- package/useRouterStore.js +21 -0
- package/useRouterStore.js.map +1 -0
- package/useSearchStore.js +49 -0
- package/useSearchStore.js.map +1 -0
- package/useSimilaritySearchStore.js +28 -0
- package/useSimilaritySearchStore.js.map +1 -0
- package/utils/base64Converter.d.ts +1 -1
- package/utils/combineFilters.d.ts +1 -1
- package/utils/combineMetaproperties.d.ts +2 -2
- package/utils/filterEmptyMetaproperties.d.ts +1 -1
- package/utils/getMetaPropertiesForFilter.d.ts +1 -1
- package/utils/normalizeResponse.d.ts +1 -1
- package/utils.js +49 -0
- package/utils.js.map +1 -0
- package/utils2.js +51 -0
- package/utils2.js.map +1 -0
- package/views/asset/AssetList.d.ts +5 -3
- package/views/asset/AssetsView.d.ts +1 -1
- package/views/asset/StatefulAssetList.d.ts +2 -2
- package/views/asset/asset-card/AssetCard.d.ts +1 -1
- package/views/asset/asset-card/AssetCardMetaproperties.d.ts +3 -3
- package/views/asset/asset-card/ContextAction.d.ts +1 -1
- package/views/collection/CollectionView.d.ts +1 -1
- package/views/collections/CollectionCard.d.ts +1 -1
- package/views/collections/CollectionList.d.ts +1 -1
- package/views/collections/CollectionsView.d.ts +1 -1
- package/Dat/DatContext.d.ts +0 -12
- package/__tests__/utils/index.d.ts +0 -116
- package/api/__tests__/testMocks/mocks.d.ts +0 -14
- package/api/__tests__/utils.d.ts +0 -10
- package/common/components/__mocks__/Tooltip.d.ts +0 -6
- package/common/components/__tests__/utils.d.ts +0 -34
- package/error-handling/__tests__/utils.d.ts +0 -56
- package/filter/__tests__/utils.d.ts +0 -13
- package/index.mjs +0 -1163
- package/login/__tests__/mocks.d.ts +0 -1
- package/login/__tests__/utils.d.ts +0 -41
- package/search/SearchContext.d.ts +0 -25
- package/search/SimilaritySearchContext.d.ts +0 -21
- package/search/__mocks__/SimilaritySearchContext.d.ts +0 -5
- package/select/__tests__/utils.d.ts +0 -11
- package/style/shadowroot/__mocks__/ShadowRoot.d.ts +0 -4
- package/utils/__mocks__/logger.d.ts +0 -4
- package/views/asset/__tests__/utils.d.ts +0 -7
- package/views/collections/__tests__/utils.d.ts +0 -5
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import r from "styled-components";
|
|
3
|
+
import { token as l, Card as a } from "@bynder/design-system";
|
|
4
|
+
import { combineMetaproperties as c } from "./combineMetaproperties.js";
|
|
5
|
+
import { trimMetapropertyValue as m } from "./trimMetapropertyValue.js";
|
|
6
|
+
const b = ({ metaproperties: p, textMetaproperties: d }) => {
|
|
7
|
+
const i = c(p, d);
|
|
8
|
+
return i?.length ? /* @__PURE__ */ e(a.AdditionalInfo, { children: /* @__PURE__ */ e(f, { children: i.map(({ label: t, value: o }) => {
|
|
9
|
+
const s = m(o);
|
|
10
|
+
return /* @__PURE__ */ n(x, { "data-testid": "asset-card-metaproperty", children: [
|
|
11
|
+
/* @__PURE__ */ n(h, { children: [
|
|
12
|
+
t,
|
|
13
|
+
":"
|
|
14
|
+
] }),
|
|
15
|
+
/* @__PURE__ */ e(w, { title: o, children: s })
|
|
16
|
+
] }, t);
|
|
17
|
+
}) }) }) : null;
|
|
18
|
+
}, f = r.dl`
|
|
19
|
+
color: rgba(0, 34, 51, 0.5);
|
|
20
|
+
font-size: ${l.fontSize75};
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
grid-row-gap: 1px;
|
|
24
|
+
row-gap: 1px;
|
|
25
|
+
margin: 0;
|
|
26
|
+
`, x = r.div`
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-wrap: wrap;
|
|
29
|
+
`, h = r.dt`
|
|
30
|
+
color: rgba(0, 34, 51, 0.3);
|
|
31
|
+
padding-right: 4px;
|
|
32
|
+
margin: 0;
|
|
33
|
+
width: 100%;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
`, w = r.dd`
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
margin: 0;
|
|
40
|
+
width: 100%;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
`;
|
|
44
|
+
export {
|
|
45
|
+
b as AssetCardMetaproperties
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=AssetCardMetaproperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetCardMetaproperties.js","sources":["../../src/views/asset/asset-card/AssetCardMetaproperties.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { Card, token } from '@bynder/design-system';\nimport { MetapropertyType } from '@src/filter/filters/metaproperty/MetapropertyFilterContent';\nimport { TextMetapropertiesType } from '@src/views/asset/asset.type';\nimport { combineMetaproperties } from '@src/utils/combineMetaproperties';\nimport { trimMetapropertyValue } from '@src/utils/trimMetapropertyValue';\n\ninterface Props {\n\tmetaproperties?: MetapropertyType[];\n\ttextMetaproperties?: TextMetapropertiesType[];\n}\n\nexport const AssetCardMetaproperties = ({ metaproperties, textMetaproperties }: Props) => {\n\tconst combinedProperties = combineMetaproperties(metaproperties, textMetaproperties);\n\n\treturn combinedProperties?.length ? (\n\t\t<Card.AdditionalInfo>\n\t\t\t<DescriptionList>\n\t\t\t\t{combinedProperties.map(({ label, value }) => {\n\t\t\t\t\tconst trimmedValue = trimMetapropertyValue(value);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<DescriptionWrapper key={label} data-testid=\"asset-card-metaproperty\">\n\t\t\t\t\t\t\t<DescriptionTerm>{label}:</DescriptionTerm>\n\t\t\t\t\t\t\t<DescriptionDefinition title={value}>\n\t\t\t\t\t\t\t\t{trimmedValue}\n\t\t\t\t\t\t\t</DescriptionDefinition>\n\t\t\t\t\t\t</DescriptionWrapper>\n\t\t\t\t\t);\n\t\t\t\t})}\n\t\t\t</DescriptionList>\n\t\t</Card.AdditionalInfo>\n\t) : null;\n};\n\nconst DescriptionList = styled.dl`\n\tcolor: rgba(0, 34, 51, 0.5);\n\tfont-size: ${token.fontSize75};\n\tdisplay: flex;\n\tflex-direction: column;\n\tgrid-row-gap: 1px;\n\trow-gap: 1px;\n\tmargin: 0;\n`;\n\nconst DescriptionWrapper = styled.div`\n\tdisplay: flex;\n\tflex-wrap: wrap;\n`;\n\nconst DescriptionTerm = styled.dt`\n\tcolor: rgba(0, 34, 51, 0.3);\n\tpadding-right: 4px;\n\tmargin: 0;\n\twidth: 100%;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n`;\n\nconst DescriptionDefinition = styled.dd`\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\tmargin: 0;\n\twidth: 100%;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n`;\n"],"names":["AssetCardMetaproperties","metaproperties","textMetaproperties","combinedProperties","combineMetaproperties","jsx","Card","DescriptionList","label","value","trimmedValue","trimMetapropertyValue","jsxs","DescriptionWrapper","DescriptionTerm","DescriptionDefinition","styled","token"],"mappings":";;;;;AAaO,MAAMA,IAA0B,CAAC,EAAE,gBAAAC,GAAgB,oBAAAC,QAAgC;AACzF,QAAMC,IAAqBC,EAAsBH,GAAgBC,CAAkB;AAEnF,SAAOC,GAAoB,SAC1B,gBAAAE,EAACC,EAAK,gBAAL,EACA,UAAA,gBAAAD,EAACE,GAAA,EACC,UAAAJ,EAAmB,IAAI,CAAC,EAAE,OAAAK,GAAO,OAAAC,QAAY;AAC7C,UAAMC,IAAeC,EAAsBF,CAAK;AAEhD,WACC,gBAAAG,EAACC,GAAA,EAA+B,eAAY,2BAC3C,UAAA;AAAA,MAAA,gBAAAD,EAACE,GAAA,EAAiB,UAAA;AAAA,QAAAN;AAAA,QAAM;AAAA,MAAA,GAAC;AAAA,MACzB,gBAAAH,EAACU,GAAA,EAAsB,OAAON,GAC5B,UAAAC,EAAA,CACF;AAAA,IAAA,EAAA,GAJwBF,CAKzB;AAAA,EAEF,CAAC,EAAA,CACF,EAAA,CACD,IACG;AACL,GAEMD,IAAkBS,EAAO;AAAA;AAAA,cAEjBC,EAAM,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAQxBJ,IAAqBG,EAAO;AAAA;AAAA;AAAA,GAK5BF,IAAkBE,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GASzBD,IAAwBC,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
package/AssetFilter.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r, useEffect as p } from "react";
|
|
3
|
+
import { styled as g } from "styled-components";
|
|
4
|
+
import { token as k, Button as x } from "@bynder/design-system";
|
|
5
|
+
import { IconMultiSelect as U, IconRectangle as V } from "@bynder/icons";
|
|
6
|
+
import { useRouterSelectors as W } from "./useRouterStore.js";
|
|
7
|
+
import { useAssetFilter as J } from "./AssetFilterContext.js";
|
|
8
|
+
import { useLocalization as K } from "./index2.js";
|
|
9
|
+
import { useConfig as Q } from "./ConfigContext.js";
|
|
10
|
+
import { useGetFilters as X } from "./getFilters.js";
|
|
11
|
+
import { Skeleton as m } from "./Skeleton.js";
|
|
12
|
+
import { HorizontalScroll as Y } from "./HorizontalScroll.js";
|
|
13
|
+
import { Tags as Z } from "./Tags.js";
|
|
14
|
+
import { Advanced as _ } from "./Advanced.js";
|
|
15
|
+
import { useSelection as ee } from "./SelectionContext.js";
|
|
16
|
+
import { useAuth as te } from "./LoginContext.js";
|
|
17
|
+
import { getInitialFilters as se } from "./getInitialFilters.js";
|
|
18
|
+
import { getAssetCounts as re } from "./getAssetCounts.js";
|
|
19
|
+
import { Smartfilter as ie } from "./Smartfilters.js";
|
|
20
|
+
import { useSearchStateByPage as oe } from "./useSearchStore.js";
|
|
21
|
+
import { useSimilaritySearchStore as le } from "./useSimilaritySearchStore.js";
|
|
22
|
+
function Ne() {
|
|
23
|
+
const s = J(), t = W.use.page(), { value: l } = oe("assets"), {
|
|
24
|
+
assetTypes: n,
|
|
25
|
+
language: S,
|
|
26
|
+
assetFilter: w,
|
|
27
|
+
noCache: T,
|
|
28
|
+
selectionMode: b,
|
|
29
|
+
selectAllOption: M
|
|
30
|
+
} = Q(), { clear: N, selectAll: P } = ee(), h = te(), [y, j] = r(t.page);
|
|
31
|
+
K(S);
|
|
32
|
+
const [z, A] = r(!1), {
|
|
33
|
+
isSelected: O,
|
|
34
|
+
isNLSSelected: q,
|
|
35
|
+
NLSSearchText: B
|
|
36
|
+
} = le(), [E, v] = r(!1), [H, C] = r(!1), [a, F] = r(), [R, $] = r({}), { data: c, isLoading: L } = X(
|
|
37
|
+
{
|
|
38
|
+
filter: s,
|
|
39
|
+
searchTerm: l || null,
|
|
40
|
+
allAssetTypes: n,
|
|
41
|
+
language: S,
|
|
42
|
+
predefinedFilter: w,
|
|
43
|
+
collectionId: t.page === "collection" ? t.collection.id : null
|
|
44
|
+
},
|
|
45
|
+
T
|
|
46
|
+
);
|
|
47
|
+
if (p(() => {
|
|
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()), () => {
|
|
62
|
+
s.clear();
|
|
63
|
+
}), [y, t.page]), p(() => {
|
|
64
|
+
let i = !1;
|
|
65
|
+
return (async () => {
|
|
66
|
+
C(!0);
|
|
67
|
+
try {
|
|
68
|
+
const o = await re({
|
|
69
|
+
auth: h,
|
|
70
|
+
filter: {
|
|
71
|
+
searchTerm: l,
|
|
72
|
+
assetTypes: n,
|
|
73
|
+
collectionId: t.page === "collection" ? t.collection.id : void 0,
|
|
74
|
+
tagNames: s.tags,
|
|
75
|
+
isLimitedUse: s.isLimited,
|
|
76
|
+
metaproperties: s.selectedSmartfilterOptions
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
i || s.setActiveFiltersState(o);
|
|
80
|
+
} catch (o) {
|
|
81
|
+
i || console.error("Error fetching asset counts:", o);
|
|
82
|
+
} finally {
|
|
83
|
+
i || C(!1);
|
|
84
|
+
}
|
|
85
|
+
})(), () => {
|
|
86
|
+
i = !0;
|
|
87
|
+
};
|
|
88
|
+
}, [s.tags, l, n, t.page, s.selectedSmartfilterOptions]), c.tag === "Failure" || !c.value || E || H)
|
|
89
|
+
return /* @__PURE__ */ e(I, { children: /* @__PURE__ */ e(ne, {}) });
|
|
90
|
+
const { tags: f, count: D } = c.value.searchAssets, G = z ? /* @__PURE__ */ e(
|
|
91
|
+
x,
|
|
92
|
+
{
|
|
93
|
+
onClick: () => {
|
|
94
|
+
N(), A(!1);
|
|
95
|
+
},
|
|
96
|
+
icon: /* @__PURE__ */ e(U, {}),
|
|
97
|
+
title: "",
|
|
98
|
+
variant: "secondary",
|
|
99
|
+
"data-testid": "deselect-all"
|
|
100
|
+
}
|
|
101
|
+
) : /* @__PURE__ */ e(
|
|
102
|
+
x,
|
|
103
|
+
{
|
|
104
|
+
onClick: () => {
|
|
105
|
+
P(), A(!0);
|
|
106
|
+
},
|
|
107
|
+
icon: /* @__PURE__ */ e(V, {}),
|
|
108
|
+
title: "",
|
|
109
|
+
variant: "secondary",
|
|
110
|
+
"data-testid": "select-all"
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
return O || q && B ? null : /* @__PURE__ */ u(I, { "data-testid": "filter-nav", children: [
|
|
114
|
+
/* @__PURE__ */ u(Y, { children: [
|
|
115
|
+
a && a.length > 0 && /* @__PURE__ */ e(
|
|
116
|
+
ie,
|
|
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 })
|
|
124
|
+
] }),
|
|
125
|
+
/* @__PURE__ */ e(ae, { children: b === "MultiSelect" && M && t.page === "assets" && G })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
function ne() {
|
|
129
|
+
return /* @__PURE__ */ u(ce, { children: [
|
|
130
|
+
/* @__PURE__ */ e(m, { width: 100 }),
|
|
131
|
+
/* @__PURE__ */ e(m, { width: 80 }),
|
|
132
|
+
/* @__PURE__ */ e(m, { width: 110 })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
const I = g.nav`
|
|
136
|
+
display: flex;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
background-color: #fff;
|
|
139
|
+
padding: ${k.spacing3} ${k.spacing4};
|
|
140
|
+
z-index: 20;
|
|
141
|
+
`, ae = g.div`
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
|
|
145
|
+
button {
|
|
146
|
+
height: initial;
|
|
147
|
+
background-color: transparent;
|
|
148
|
+
border: none;
|
|
149
|
+
padding: 0;
|
|
150
|
+
}
|
|
151
|
+
`, ce = g.div`
|
|
152
|
+
display: inline-flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
`;
|
|
155
|
+
export {
|
|
156
|
+
Ne as AssetFilter
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=AssetFilter.js.map
|
|
@@ -0,0 +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,GACvCC,IAAOC,GAAA,GAEP,CAACC,GAAaC,CAAc,IAAIC,EAASlB,EAAK,IAAI;AACxD,EAAAmB,EAAgBd,CAAQ;AACxB,QAAM,CAACe,GAAeC,CAAgB,IAAIH,EAAS,EAAK,GAClD;AAAA,IACL,YAAYI;AAAA,IACZ,eAAAC;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,EAACR,GAAA,EAAU,eAAY,cACtB,UAAA;AAAA,IAAA,gBAAAQ,EAACC,GAAA,EACC,UAAA;AAAA,MAAAzB,KAAgBA,EAAa,SAAS,KACtC,gBAAAe;AAAA,QAACW;AAAAA,QAAA;AAAA,UACA,cAAA1B;AAAA,UACA,gBAAAE;AAAA,QAAA;AAAA,MAAA;AAAA,MAGDgB,KAAQA,EAAK,MAAM,SAAS,uBAAMS,GAAA,EAAK,MAAMT,EAAK,OAAO,WAAAb,EAAA,CAAsB;AAAA,MAChF,gBAAAU,EAACa,GAAA,EAAS,WAAAvB,GAAsB,OAAOc,EAAM,UAAA,CAAW;AAAA,IAAA,GACzD;AAAA,IAEA,gBAAAJ,EAACc,MACC,UAAAnD,MAAkB,iBAClBC,KACAT,EAAK,SAAS,YACdkD,EAAA,CACF;AAAA,EAAA,GACD;AAEF;AAGA,SAASH,KAAkB;AAC1B,2BACEa,IAAA,EACA,UAAA;AAAA,IAAA,gBAAAf,EAACgB,GAAA,EAAS,OAAO,IAAA,CAAK;AAAA,IACtB,gBAAAhB,EAACgB,GAAA,EAAS,OAAO,GAAA,CAAI;AAAA,IACrB,gBAAAhB,EAACgB,GAAA,EAAS,OAAO,IAAA,CAAK;AAAA,EAAA,GACvB;AAEF;AAEA,MAAMf,IAAYgB,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;"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as R } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as V, useContext as X, useState as c, useEffect as x, useMemo as Y } from "react";
|
|
3
|
+
const j = V(null);
|
|
4
|
+
function U({
|
|
5
|
+
children: o,
|
|
6
|
+
hideLimitedUse: u = !1,
|
|
7
|
+
predefinedFilter: s
|
|
8
|
+
}) {
|
|
9
|
+
const [b, l] = c(
|
|
10
|
+
s?.predefinedAssetType ? [...s?.predefinedAssetType] : []
|
|
11
|
+
), [p, g] = c([]), [E, C] = c(!1), [M, m] = c(
|
|
12
|
+
s?.predefinedTagNames ? [...s.predefinedTagNames] : []
|
|
13
|
+
), [O, I] = c(), [P, S] = c({}), [v, d] = c({}), [D, y] = c(null);
|
|
14
|
+
x(() => {
|
|
15
|
+
I(u ? !1 : void 0);
|
|
16
|
+
}, [u]), x(() => {
|
|
17
|
+
w();
|
|
18
|
+
}, [s?.predefinedMetapropertiesOptions]);
|
|
19
|
+
function L(e) {
|
|
20
|
+
l((t) => T(t, e));
|
|
21
|
+
}
|
|
22
|
+
function N(e) {
|
|
23
|
+
s?.showToolbar && s.predefinedAssetType?.includes(e) || l((t) => A(t, e));
|
|
24
|
+
}
|
|
25
|
+
function W(e) {
|
|
26
|
+
g((t) => T(t, e.id)), S((t) => ({
|
|
27
|
+
...t,
|
|
28
|
+
[e.id]: e
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function _(e) {
|
|
32
|
+
g(
|
|
33
|
+
(t) => A(t, e.id)
|
|
34
|
+
), S((t) => {
|
|
35
|
+
const { [e.id]: i, ...r } = t;
|
|
36
|
+
return r;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function w() {
|
|
40
|
+
s?.predefinedMetapropertiesOptions && d(() => Object.entries(
|
|
41
|
+
s.predefinedMetapropertiesOptions || {}
|
|
42
|
+
).reduce((e, [t, i]) => (e[t] = {}, Object.entries(i).forEach(([r, n]) => {
|
|
43
|
+
e[t][n] = {
|
|
44
|
+
id: n,
|
|
45
|
+
label: r,
|
|
46
|
+
metapropertyName: t
|
|
47
|
+
};
|
|
48
|
+
}), e), {}));
|
|
49
|
+
}
|
|
50
|
+
function k(e) {
|
|
51
|
+
m((t) => T(t, e));
|
|
52
|
+
}
|
|
53
|
+
function q(e) {
|
|
54
|
+
s?.showToolbar && s.predefinedTagNames?.includes(e) || m((t) => A(t, e));
|
|
55
|
+
}
|
|
56
|
+
function z(e, t, i) {
|
|
57
|
+
const r = {
|
|
58
|
+
id: t.id,
|
|
59
|
+
label: t.label,
|
|
60
|
+
metapropertyName: e
|
|
61
|
+
};
|
|
62
|
+
d((n) => {
|
|
63
|
+
const a = n[e] || {}, f = !!a[t.id];
|
|
64
|
+
return i ? {
|
|
65
|
+
...n,
|
|
66
|
+
[e]: f ? (
|
|
67
|
+
// Remove if already selected
|
|
68
|
+
Object.fromEntries(
|
|
69
|
+
Object.entries(a).filter(
|
|
70
|
+
([Q]) => Q !== t.id
|
|
71
|
+
)
|
|
72
|
+
)
|
|
73
|
+
) : (
|
|
74
|
+
// Add if not selected already
|
|
75
|
+
{
|
|
76
|
+
...a,
|
|
77
|
+
[t.id]: r
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
} : f ? {
|
|
81
|
+
...n,
|
|
82
|
+
[e]: {}
|
|
83
|
+
} : {
|
|
84
|
+
...n,
|
|
85
|
+
[e]: {
|
|
86
|
+
[t.id]: r
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function B(e, t) {
|
|
92
|
+
d((i) => {
|
|
93
|
+
const { [e]: r, ...n } = i, { [t]: a, ...f } = r || {};
|
|
94
|
+
return f && Object.keys(f).length > 0 ? {
|
|
95
|
+
...i,
|
|
96
|
+
[e]: f
|
|
97
|
+
} : n;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function G(e) {
|
|
101
|
+
const t = e.count, i = Object.entries(t || {}).filter(
|
|
102
|
+
([r, n]) => r.startsWith("property") && n && Object.keys(n).length > 0
|
|
103
|
+
).reduce((r, [n, a]) => (r[n.replace("property_", "")] = a, r), {});
|
|
104
|
+
y(i);
|
|
105
|
+
}
|
|
106
|
+
function H() {
|
|
107
|
+
l(
|
|
108
|
+
s?.showToolbar && s?.predefinedAssetType ? [...s.predefinedAssetType] : []
|
|
109
|
+
), m(
|
|
110
|
+
s?.showToolbar && s?.predefinedTagNames ? [...s.predefinedTagNames] : []
|
|
111
|
+
), d({}), y(null);
|
|
112
|
+
}
|
|
113
|
+
const h = p.map((e) => P[e]);
|
|
114
|
+
function J(e) {
|
|
115
|
+
C(e);
|
|
116
|
+
}
|
|
117
|
+
const K = Y(
|
|
118
|
+
() => ({
|
|
119
|
+
assetTypes: b,
|
|
120
|
+
metaproperties: h,
|
|
121
|
+
metapropertyIds: p,
|
|
122
|
+
tags: M,
|
|
123
|
+
isLimited: O,
|
|
124
|
+
addAssetType: L,
|
|
125
|
+
removeAssetType: N,
|
|
126
|
+
addMetaproperty: W,
|
|
127
|
+
removeMetaproperty: _,
|
|
128
|
+
setPredefinedMetaproperties: w,
|
|
129
|
+
addTag: k,
|
|
130
|
+
removeTag: q,
|
|
131
|
+
clear: H,
|
|
132
|
+
setDropdownState: J,
|
|
133
|
+
isDropdownActive: E,
|
|
134
|
+
selectSmartfilterOption: z,
|
|
135
|
+
removeSmartfilterOption: B,
|
|
136
|
+
selectedSmartfilterOptions: v,
|
|
137
|
+
setActiveFiltersState: G,
|
|
138
|
+
existingFilters: D
|
|
139
|
+
}),
|
|
140
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
141
|
+
[b, h, M, O, p, v]
|
|
142
|
+
);
|
|
143
|
+
return /* @__PURE__ */ R(j.Provider, { value: K, children: o });
|
|
144
|
+
}
|
|
145
|
+
function T(o, u) {
|
|
146
|
+
return o.includes(u) ? o : [...o, u];
|
|
147
|
+
}
|
|
148
|
+
function A(o, u) {
|
|
149
|
+
return o.filter((s) => s !== u);
|
|
150
|
+
}
|
|
151
|
+
function F() {
|
|
152
|
+
const o = X(j);
|
|
153
|
+
if (o === null)
|
|
154
|
+
throw new Error("useAssetFilter must be used with a AssetFilterProvider");
|
|
155
|
+
return o;
|
|
156
|
+
}
|
|
157
|
+
export {
|
|
158
|
+
j as AssetFilterContext,
|
|
159
|
+
U as AssetFilterProvider,
|
|
160
|
+
F as useAssetFilter
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=AssetFilterContext.js.map
|
|
@@ -0,0 +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,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,EAAgBH,GAAsB;AAC9C,IACCrB,GAAkB,eAClBA,EAAiB,qBAAqB,S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AAAA,IAGD,CAACf,GAAY0D,GAAgBnD,GAAME,GAAWN,GAAiBU,CAA0B;AAAA,EAAA;AAG1F,2BACEnB,EAAmB,UAAnB,EAA4B,OAAOmE,GAClC,UAAAhE,GACF;AAEF;AAEA,SAASyB,EAAYyC,GAAU7B,GAAU;AACxC,SAAO6B,EAAI,SAAS7B,CAAK,IAAI6B,IAAM,CAAC,GAAGA,GAAK7B,CAAK;AAClD;AAEA,SAASV,EAAiBuC,GAAU7B,GAAU;AAC7C,SAAO6B,EAAI,OAAO,CAACC,MAAcA,MAAc9B,CAAK;AACrD;AAeO,SAAS+B,IAAiB;AAChC,QAAMC,IAAUC,EAAWzE,CAAkB;AAE7C,MAAIwE,MAAY;AACf,UAAM,IAAI,MAAM,wDAAwD;AAGzE,SAAOA;AACR;"}
|
package/AssetItem.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import i from "styled-components";
|
|
3
|
+
import { token as n, Thumbnail as s } from "@bynder/design-system";
|
|
4
|
+
import { getExtension as o, getThumbnail as l } from "./utils.js";
|
|
5
|
+
import { useSelection as a } from "./SelectionContext.js";
|
|
6
|
+
import { SelectedItemContainer as p } from "./SelectedItemContainer.js";
|
|
7
|
+
function A({ asset: e }) {
|
|
8
|
+
const r = a();
|
|
9
|
+
return /* @__PURE__ */ m(
|
|
10
|
+
p,
|
|
11
|
+
{
|
|
12
|
+
title: e.name,
|
|
13
|
+
onRemove: () => r.toggleAssets([e]),
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ t(c, { children: /* @__PURE__ */ t(s, { variant: "preview", imageUrl: l(e), size: "m" }) }),
|
|
16
|
+
/* @__PURE__ */ t(g, { children: e.name }),
|
|
17
|
+
o(e) && /* @__PURE__ */ t(h, { children: o(e) })
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
const c = i.div`
|
|
23
|
+
margin-right: ${n.spacing4};
|
|
24
|
+
max-width: 40px;
|
|
25
|
+
`, g = i.span`
|
|
26
|
+
width: 160px;
|
|
27
|
+
margin-right: ${n.spacing3};
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
text-overflow: ellipsis;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
`, h = i.span`
|
|
32
|
+
flex-grow: 1;
|
|
33
|
+
color: rgba(0, 34, 51, 0.5);
|
|
34
|
+
font-size: ${n.fontSize75};
|
|
35
|
+
text-align: right;
|
|
36
|
+
`;
|
|
37
|
+
export {
|
|
38
|
+
A as AssetItem
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=AssetItem.js.map
|
package/AssetItem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetItem.js","sources":["../../src/select/current-selection/AssetItem.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport { Thumbnail, token } from '@bynder/design-system';\n\nimport { getExtension, getThumbnail } from '../../views/asset/asset-card/utils';\nimport { Asset } from '../../views/asset/asset.type';\nimport { useSelection } from '../SelectionContext';\nimport { SelectedItemContainer } from './SelectedItemContainer';\n\nexport function AssetItem({ asset }: { asset: Asset }) {\n\tconst selectionState = useSelection();\n\n\treturn (\n\t\t<SelectedItemContainer\n\t\t\ttitle={asset.name}\n\t\t\tonRemove={() => selectionState.toggleAssets([asset])}\n\t\t>\n\t\t\t<AssetThumbnailWrapper>\n\t\t\t\t<Thumbnail variant=\"preview\" imageUrl={getThumbnail(asset)} size=\"m\" />\n\t\t\t</AssetThumbnailWrapper>\n\n\t\t\t<AssetName>{asset.name}</AssetName>\n\n\t\t\t{getExtension(asset) && <AssetExtensionName>{getExtension(asset)}</AssetExtensionName>}\n\t\t</SelectedItemContainer>\n\t);\n}\n\nconst AssetThumbnailWrapper = styled.div`\n\tmargin-right: ${token.spacing4};\n\tmax-width: 40px;\n`;\n\nconst AssetName = styled.span`\n\twidth: 160px;\n\tmargin-right: ${token.spacing3};\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n`;\n\nconst AssetExtensionName = styled.span`\n\tflex-grow: 1;\n\tcolor: rgba(0, 34, 51, 0.5);\n\tfont-size: ${token.fontSize75};\n\ttext-align: right;\n`;\n"],"names":["AssetItem","asset","selectionState","useSelection","jsxs","SelectedItemContainer","jsx","AssetThumbnailWrapper","Thumbnail","getThumbnail","AssetName","getExtension","AssetExtensionName","styled","token"],"mappings":";;;;;;AASO,SAASA,EAAU,EAAE,OAAAC,KAA2B;AACtD,QAAMC,IAAiBC,EAAA;AAEvB,SACC,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACA,OAAOJ,EAAM;AAAA,MACb,UAAU,MAAMC,EAAe,aAAa,CAACD,CAAK,CAAC;AAAA,MAEnD,UAAA;AAAA,QAAA,gBAAAK,EAACC,GAAA,EACA,UAAA,gBAAAD,EAACE,GAAA,EAAU,SAAQ,WAAU,UAAUC,EAAaR,CAAK,GAAG,MAAK,IAAA,CAAI,GACtE;AAAA,QAEA,gBAAAK,EAACI,GAAA,EAAW,UAAAT,EAAM,KAAA,CAAK;AAAA,QAEtBU,EAAaV,CAAK,uBAAMW,GAAA,EAAoB,UAAAD,EAAaV,CAAK,EAAA,CAAE;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGpE;AAEA,MAAMM,IAAwBM,EAAO;AAAA,iBACpBC,EAAM,QAAQ;AAAA;AAAA,GAIzBJ,IAAYG,EAAO;AAAA;AAAA,iBAERC,EAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,GAMzBF,IAAqBC,EAAO;AAAA;AAAA;AAAA,cAGpBC,EAAM,UAAU;AAAA;AAAA;"}
|
package/AssetList.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsxs as I, jsx as s, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as w, useState as P, useEffect as J } from "react";
|
|
3
|
+
import { styled as Q } from "styled-components";
|
|
4
|
+
import { AssetCard as U } from "./AssetCard.js";
|
|
5
|
+
import { CardSkeleton as V } from "./CardSkeleton.js";
|
|
6
|
+
import { DragSelect as X } from "./DragSelect.js";
|
|
7
|
+
import { useDimensions as Y } from "./useDimensions.js";
|
|
8
|
+
import { InfiniteScroll as Z } from "./InfiniteScroll.js";
|
|
9
|
+
import { useSelection as $ } from "./SelectionContext.js";
|
|
10
|
+
import { useSimilaritySearchStore as T } from "./useSimilaritySearchStore.js";
|
|
11
|
+
import { useSimilarityAssets as ee } from "./getSimilarityAssets.js";
|
|
12
|
+
function he({
|
|
13
|
+
assets: e,
|
|
14
|
+
count: l,
|
|
15
|
+
hasNextPage: m = !1,
|
|
16
|
+
isLoading: h = !1,
|
|
17
|
+
loadMore: c = () => {
|
|
18
|
+
},
|
|
19
|
+
onSelect: o = () => {
|
|
20
|
+
},
|
|
21
|
+
onToggle: d = () => {
|
|
22
|
+
},
|
|
23
|
+
emptyStateElement: g = null,
|
|
24
|
+
selectedAssetIds: a = [],
|
|
25
|
+
selectionMode: u = "MultiSelect",
|
|
26
|
+
theme: S,
|
|
27
|
+
children: k = null
|
|
28
|
+
}) {
|
|
29
|
+
const x = w(null), { dimensions: B } = Y(x.current), [f, v] = P([]), [M, D] = P("inactive"), { clear: R } = $(), {
|
|
30
|
+
setIsEnabled: b,
|
|
31
|
+
isEnabled: H,
|
|
32
|
+
setIsSelected: W
|
|
33
|
+
} = T(), { resetData: j, search: y } = ee(), [C, E] = ie(l, B), A = w(!1);
|
|
34
|
+
J(() => {
|
|
35
|
+
!A.current && e.value && e.value.length > 0 && (A.current = !0, (async () => {
|
|
36
|
+
if (e.value && e.value.length > 0) {
|
|
37
|
+
const t = e.value.find((n) => n.__typename === "Image") || e.value[0], r = await y([t.databaseId]);
|
|
38
|
+
b(r || !1);
|
|
39
|
+
}
|
|
40
|
+
})());
|
|
41
|
+
}, [e.value, y, b]);
|
|
42
|
+
const z = (i) => {
|
|
43
|
+
j(), W(!0), R(), y(i);
|
|
44
|
+
};
|
|
45
|
+
function _(i) {
|
|
46
|
+
if (!(e.tag === "Loading" && !e.value))
|
|
47
|
+
return e.value?.find((t) => i === t.id);
|
|
48
|
+
}
|
|
49
|
+
function F(i) {
|
|
50
|
+
v((t) => [...t, ...i]);
|
|
51
|
+
}
|
|
52
|
+
function K(i) {
|
|
53
|
+
v(
|
|
54
|
+
(t) => t.filter((r) => !i.includes(r))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function N(i) {
|
|
58
|
+
D(i);
|
|
59
|
+
}
|
|
60
|
+
function O(i) {
|
|
61
|
+
if (D("inactive"), f.length) {
|
|
62
|
+
const t = [];
|
|
63
|
+
f.forEach((r) => {
|
|
64
|
+
const n = _(r);
|
|
65
|
+
n && t.push(n);
|
|
66
|
+
}), i === "inverse" ? d(t) : o(t), v([]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function L(i) {
|
|
70
|
+
return M === "inverse" && a.includes(i.id) && f.includes(i.id) ? !1 : a.includes(i.id) || f.includes(i.id);
|
|
71
|
+
}
|
|
72
|
+
function q(i, t) {
|
|
73
|
+
if (t.shiftKey && u === "MultiSelect" && e.value?.length) {
|
|
74
|
+
const r = e.value.findIndex((p) => p.id === i.id);
|
|
75
|
+
let n = e.value?.findIndex(
|
|
76
|
+
(p) => p.id === a[a.length - 1]
|
|
77
|
+
);
|
|
78
|
+
n === -1 && (n = 0), n < r ? o(e.value?.slice(n, r + 1)) : o(e.value.slice(r, n + 1));
|
|
79
|
+
} else
|
|
80
|
+
d([i]);
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ I(
|
|
83
|
+
te,
|
|
84
|
+
{
|
|
85
|
+
ref: x,
|
|
86
|
+
"data-drag-select-container": !0,
|
|
87
|
+
"data-testid": "asset-list-container",
|
|
88
|
+
children: [
|
|
89
|
+
k,
|
|
90
|
+
/* @__PURE__ */ I("div", { className: "card-list", role: "listbox", children: [
|
|
91
|
+
e.tag === "Loading" && !e.value && /* @__PURE__ */ s(V, { rows: C, columns: E }),
|
|
92
|
+
e.tag === "Loaded" && e.value.length === 0 && g,
|
|
93
|
+
(e.tag === "Loading" && e.value || e.tag === "Loaded") && /* @__PURE__ */ I(G, { children: [
|
|
94
|
+
u === "MultiSelect" && /* @__PURE__ */ s(
|
|
95
|
+
X,
|
|
96
|
+
{
|
|
97
|
+
dragContainer: "[data-drag-select-container]",
|
|
98
|
+
selectionBoxCustomAttr: {
|
|
99
|
+
style: {
|
|
100
|
+
zIndex: 1e6,
|
|
101
|
+
borderColor: S?.colorPrimary,
|
|
102
|
+
borderWidth: "2px",
|
|
103
|
+
borderRadius: "5px",
|
|
104
|
+
color: "rgba(0, 34, 51, 0.8)"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
onSelect: F,
|
|
108
|
+
onDeselect: K,
|
|
109
|
+
onDragStart: N,
|
|
110
|
+
onDragEnd: O
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ s(
|
|
114
|
+
Z,
|
|
115
|
+
{
|
|
116
|
+
hasNextPage: m,
|
|
117
|
+
isLoading: h,
|
|
118
|
+
loadMore: c,
|
|
119
|
+
children: e.value?.map((i, t) => /* @__PURE__ */ s(
|
|
120
|
+
U,
|
|
121
|
+
{
|
|
122
|
+
isSilimilaritySearchEnabled: H,
|
|
123
|
+
isSelected: L(i),
|
|
124
|
+
isOutlined: L(i),
|
|
125
|
+
asset: i,
|
|
126
|
+
fadeIn: t >= C * E,
|
|
127
|
+
onClick: (r, n) => q(r, n),
|
|
128
|
+
onSimilaritySearch: z
|
|
129
|
+
},
|
|
130
|
+
i.id
|
|
131
|
+
))
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] })
|
|
135
|
+
] })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function ie(e, l) {
|
|
141
|
+
if (e !== void 0)
|
|
142
|
+
return [1, e];
|
|
143
|
+
if (!l)
|
|
144
|
+
return [0, 0];
|
|
145
|
+
const m = 192, h = 172, c = 8, o = 8, d = m + 2 * c, g = h + 2 * c, a = 2 * o, u = Math.ceil(l.height / g), S = Math.round((l.width - a) / d);
|
|
146
|
+
return [u, S];
|
|
147
|
+
}
|
|
148
|
+
const te = Q.div`
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
flex-grow: 1;
|
|
152
|
+
overflow-y: auto;
|
|
153
|
+
`;
|
|
154
|
+
export {
|
|
155
|
+
he as AssetList,
|
|
156
|
+
ie as calculateAssetsInDimensions
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=AssetList.js.map
|