@bynder/compact-view 5.1.3 → 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/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 +4 -2
- package/App.js +93 -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 +138 -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_new.js +148 -0
- package/Autocomplete_new.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 +266 -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_new.js +50 -0
- package/Option_new.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_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/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/getFilterOptions.d.ts +9 -0
- package/api/getFilters.d.ts +2 -2
- package/api/getFilters_new.d.ts +7 -0
- package/api/getSimilarityAssets.d.ts +1 -1
- package/api/index.d.ts +3 -3
- 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/api/types/getFilters_new.d.ts +56 -0
- package/app-config/ConfigContext.d.ts +4 -5
- package/app-config/appConfig.type.d.ts +2 -0
- 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/autocomplete.js +25 -0
- package/autocomplete.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/Autocomplete_new.d.ts +15 -0
- package/filter/filters/smartfilters/Metaproperties/Option.d.ts +2 -2
- package/filter/filters/smartfilters/Metaproperties/Option_new.d.ts +13 -0
- package/filter/filters/smartfilters/Metaproperties/SmartFilterSelect.d.ts +2 -2
- package/filter/filters/smartfilters/Metaproperties/SmartFilterSelect_new.d.ts +13 -0
- package/filter/filters/smartfilters/Smartfilters.d.ts +2 -2
- package/filter/filters/smartfilters/Smartfilters_new.d.ts +7 -0
- package/filter/filters/tags/TagItem.d.ts +1 -1
- package/filter/filters/tags/Tags.d.ts +1 -1
- package/filterAssets.js +177 -0
- package/filterAssets.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 +79 -0
- package/getCollections.js.map +1 -0
- package/getFilterOptions.js +57 -0
- package/getFilterOptions.js.map +1 -0
- package/getFilters.js +85 -0
- package/getFilters.js.map +1 -0
- 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/getSimilarityAssets.js +141 -0
- package/getSimilarityAssets.js.map +1 -0
- package/handlers.js +7 -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 +56 -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/getLimitedUseThumbnails.d.ts +2 -0
- 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
package/AssetCard.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetCard.js","sources":["../../src/views/asset/asset-card/AssetCard.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\nimport { Badge, Card, token, TruncatedText } from '@bynder/design-system';\nimport { useConfig } from '../../../app-config/ConfigContext';\nimport { Asset, TextMetapropertiesType } from '../asset.type';\nimport { getExtension, getStatusText, getThumbnail } from './utils';\nimport { MetapropertyType } from '../../../filter/filters/metaproperty/MetapropertyFilterContent';\nimport { __ } from '../../../localization';\nimport { Theme } from '../../../style/Theming';\nimport { ContextAction } from './ContextAction';\nimport { AssetCardMetaproperties } from './AssetCardMetaproperties';\nimport { useDat } from '@src/store/useDatStore';\n\ninterface Props {\n\tclassName?: string;\n\tfadeIn?: boolean;\n\tasset: Asset;\n\tisSelected: boolean;\n\tonClick?: (asset: Asset, event: React.MouseEvent) => void;\n\tisOutlined: boolean;\n\tchildren?: React.ReactNode;\n\tisSilimilaritySearchEnabled: boolean;\n\tonSimilaritySearch: (selectedAsset: string[]) => void;\n}\n\nexport function AssetCard({\n\tclassName,\n\tfadeIn = true,\n\tasset,\n\tisSelected,\n\tisOutlined,\n\tonClick,\n\tchildren = null,\n\tisSilimilaritySearchEnabled = false,\n\tonSimilaritySearch,\n}: Props) {\n\tconst [metapropertiesToDisplay, setMetapropertiesToDisplay] = useState<MetapropertyType[]>();\n\tconst [textMetapropertiesToDisplay, setTextMetapropertiesToDisplay] =\n\t\tuseState<TextMetapropertiesType[]>();\n\tconst { openDat, setTransformation } = useDat();\n\n\tconst { theme } = useConfig();\n\n\tconst statusText = getStatusText(asset);\n\tconst extension = getExtension(asset);\n\n\tuseEffect(() => {\n\t\tconst filteredMetaProps = asset.metaproperties?.nodes.filter(\n\t\t\t(prop) => prop.showInGridView || prop.showInListView,\n\t\t);\n\t\tsetMetapropertiesToDisplay(filteredMetaProps);\n\t}, [asset.metaproperties]);\n\n\tuseEffect(() => {\n\t\tconst filteredTextMetaProps = asset.textMetaproperties?.filter(\n\t\t\t(prop) => prop.showInGridView || prop.showInListView,\n\t\t);\n\t\tsetTextMetapropertiesToDisplay(filteredTextMetaProps);\n\t}, [asset.textMetaproperties]);\n\n\tconst handleClick = (e: React.MouseEvent) => {\n\t\tif (onClick !== undefined) {\n\t\t\te.stopPropagation();\n\t\t\tsetTransformation();\n\t\t\tonClick(asset, e);\n\t\t}\n\t};\n\n\tconst handleSimilaritySearchClick = (event: React.MouseEvent) => {\n\t\tevent.stopPropagation();\n\t\tonSimilaritySearch([asset.databaseId ? asset.databaseId : asset.id]);\n\t};\n\n\treturn (\n\t\t<Container\n\t\t\tid={asset.id}\n\t\t\t$theme={theme}\n\t\t\t$isOutlined={(isSelected || isOutlined) && theme?.colorPrimary !== undefined}\n\t\t\t$fadeIn={fadeIn}\n\t\t\tclassName={className}\n\t\t\tdata-drag-select-id={asset.id}\n\t\t>\n\t\t\t<Card\n\t\t\t\tcontextAction={\n\t\t\t\t\t<ContextAction\n\t\t\t\t\t\ttransformBaseUrl={asset.files?.transformBaseUrl?.url}\n\t\t\t\t\t\tportalUrl={asset.url}\n\t\t\t\t\t\tonOpenDAT={() => {\n\t\t\t\t\t\t\topenDat(asset.files?.transformBaseUrl?.url, asset, asset.name);\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tselectButtonAriaLabel={isSelected ? __('Deselect') : __('Select')}\n\t\t\t\tonSelect={handleClick}\n\t\t\t\tonClick={handleClick}\n\t\t\t\tisSelected={isSelected}\n\t\t\t\taria-selected={isSelected}\n\t\t\t\tdata-testid=\"asset-card\"\n\t\t\t>\n\t\t\t\t{/* Image */}\n\t\t\t\t<Card.Frame\n\t\t\t\t\ticon={\n\t\t\t\t\t\tstatusText ? (\n\t\t\t\t\t\t\t<TruncatedBadgeWrapper $limitWidth={!!extension}>\n\t\t\t\t\t\t\t\t<Badge color=\"black-alpha\" data-testid=\"asset-tag\">\n\t\t\t\t\t\t\t\t\t<TruncatedText>{statusText}</TruncatedText>\n\t\t\t\t\t\t\t\t</Badge>\n\t\t\t\t\t\t\t</TruncatedBadgeWrapper>\n\t\t\t\t\t\t) : undefined\n\t\t\t\t\t}\n\t\t\t\t\tdata-testid=\"asset-type\"\n\t\t\t\t\tbadge={extension}\n\t\t\t\t>\n\t\t\t\t\t<Card.Images>\n\t\t\t\t\t\t{getThumbnail(asset) && (\n\t\t\t\t\t\t\t<Card.Img\n\t\t\t\t\t\t\t\tsrc={getThumbnail(asset)}\n\t\t\t\t\t\t\t\talt={asset.name}\n\t\t\t\t\t\t\t\tcontentResize=\"fit\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Card.Images>\n\t\t\t\t\t{isSilimilaritySearchEnabled && asset.__typename === 'Image' && (\n\t\t\t\t\t\t<SimilarityButtonWrapper\n\t\t\t\t\t\t\tonClick={handleSimilaritySearchClick}\n\t\t\t\t\t\t\tdata-testid=\"similarity-search-indicator\"\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\taria-label=\"similarity-search-button\"\n\t\t\t\t\t\t\tclassName=\"showSimilarButton\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Badge isSmall>{__('Show similar')}</Badge>\n\t\t\t\t\t\t</SimilarityButtonWrapper>\n\t\t\t\t\t)}\n\t\t\t\t</Card.Frame>\n\t\t\t\t{children}\n\t\t\t\t{/* Name */}\n\t\t\t\t{/* In case of problems with shadow dom and design-system tooltip,\n\t\t\t\t behavior was changed to simulate old BynderDAM expanding card*/}\n\t\t\t\t<AssestName data-testid=\"asset-name\">{asset.name}</AssestName>\n\t\t\t\t{/* Metaproperties */}\n\t\t\t\t<AssetCardMetaproperties\n\t\t\t\t\tmetaproperties={metapropertiesToDisplay}\n\t\t\t\t\ttextMetaproperties={textMetapropertiesToDisplay}\n\t\t\t\t/>\n\t\t\t</Card>\n\t\t</Container>\n\t);\n}\n\ninterface ContainerProps {\n\t$theme?: Theme;\n\t$isOutlined: boolean;\n\t$fadeIn: boolean;\n}\n\nconst Container = styled.div<ContainerProps>`\n\tmargin: ${token.spacing3};\n\twidth: 224px;\n\talign-self: flex-start;\n\tposition: relative;\n\t${(p) => (p.$fadeIn ? `animation: var(--fade-in-down);` : '')}\n\n\t--userComponentCardSelectedColor: ${({ $theme }: ContainerProps) => $theme?.colorButtonPrimary};\n\t--userComponentCardSelectedColorHover: ${({ $theme }: ContainerProps) =>\n\t\t$theme?.colorButtonPrimaryHover};\n\t--userComponentCardSelectedColorActive: ${({ $theme }: ContainerProps) =>\n\t\t$theme?.colorButtonPrimaryActive};\n\n\t.showSimilarButton {\n\t\tdisplay: none;\n\t}\n\n\t&:hover .showSimilarButton {\n\t\tdisplay: block;\n\t}\n`;\n\nconst TruncatedBadgeWrapper = styled.div<{ $limitWidth: boolean }>`\n\t${(p) => p.$limitWidth && 'max-width: 142px;'}\n\tmargin-top: ${token.spacing2};\n`;\n\nconst AssestName = styled.p`\n\twidth: auto;\n\tmax-width: 100%;\n\theight: auto;\n\tline-height: 20px;\n\tmin-height: 20px;\n\tmax-height: 20px;\n\tpadding: 0 ${token.spacing5};\n\tmargin: ${token.spacing3} 0;\n\ttransition: all 200ms ease;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\twhite-space: nowrap;\n\tbox-sizing: content-box;\n\n\t&:hover {\n\t\tmax-height: 80px;\n\t\tword-break: break-all;\n\t\twhite-space: normal;\n\t}\n`;\n\nconst SimilarityButtonWrapper = styled.button`\n\tbackground: none;\n\tborder: none;\n\tpadding: 0;\n\tmargin: 0;\n\tfont: inherit;\n\tcolor: inherit;\n\tcursor: pointer;\n\toutline: none;\n\ttext-align: inherit;\n\n\tposition: absolute;\n\tbottom: ${token.spacing4};\n\tleft: ${token.spacing4};\n\tz-index: 1;\n`;\n"],"names":["AssetCard","className","fadeIn","asset","isSelected","isOutlined","onClick","children","isSilimilaritySearchEnabled","onSimilaritySearch","metapropertiesToDisplay","setMetapropertiesToDisplay","useState","textMetapropertiesToDisplay","setTextMetapropertiesToDisplay","openDat","setTransformation","useDat","theme","useConfig","statusText","getStatusText","extension","getExtension","useEffect","filteredMetaProps","prop","filteredTextMetaProps","handleClick","e","handleSimilaritySearchClick","event","jsx","Container","jsxs","Card","ContextAction","__","TruncatedBadgeWrapper","Badge","TruncatedText","getThumbnail","SimilarityButtonWrapper","AssestName","AssetCardMetaproperties","styled","token","p","$theme"],"mappings":";;;;;;;;;;AA0BO,SAASA,EAAU;AAAA,EACzB,WAAAC;AAAA,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
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,138 @@
|
|
|
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
|
+
{
|
|
38
|
+
filter: s,
|
|
39
|
+
searchTerm: i || null,
|
|
40
|
+
allAssetTypes: l,
|
|
41
|
+
language: g,
|
|
42
|
+
predefinedFilter: x,
|
|
43
|
+
collectionId: t.page === "collection" ? t.collection.id : null
|
|
44
|
+
},
|
|
45
|
+
S
|
|
46
|
+
), { data: r } = q(S);
|
|
47
|
+
if (C(() => (t.page !== h && (P(t.page), s.clear()), () => {
|
|
48
|
+
s.clear();
|
|
49
|
+
}), [h, t.page]), C(() => {
|
|
50
|
+
let o = !1;
|
|
51
|
+
return (async () => {
|
|
52
|
+
y(!0);
|
|
53
|
+
try {
|
|
54
|
+
const d = await Z({
|
|
55
|
+
auth: N,
|
|
56
|
+
filter: {
|
|
57
|
+
searchTerm: i,
|
|
58
|
+
assetTypes: l,
|
|
59
|
+
collectionId: t.page === "collection" ? t.collection.id : void 0,
|
|
60
|
+
tagNames: s.tags,
|
|
61
|
+
isLimitedUse: s.isLimited,
|
|
62
|
+
metaproperties: s.selectedSmartfilterOptions
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
o || s.setActiveFiltersState(d);
|
|
66
|
+
} catch (d) {
|
|
67
|
+
o || console.error("Error fetching asset counts:", d);
|
|
68
|
+
} finally {
|
|
69
|
+
o || y(!1);
|
|
70
|
+
}
|
|
71
|
+
})(), () => {
|
|
72
|
+
o = !0;
|
|
73
|
+
};
|
|
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,
|
|
78
|
+
{
|
|
79
|
+
onClick: () => {
|
|
80
|
+
I(), A(!1);
|
|
81
|
+
},
|
|
82
|
+
icon: /* @__PURE__ */ e(B, {}),
|
|
83
|
+
title: "",
|
|
84
|
+
variant: "secondary",
|
|
85
|
+
"data-testid": "deselect-all"
|
|
86
|
+
}
|
|
87
|
+
) : /* @__PURE__ */ e(
|
|
88
|
+
L,
|
|
89
|
+
{
|
|
90
|
+
onClick: () => {
|
|
91
|
+
b(), A(!0);
|
|
92
|
+
},
|
|
93
|
+
icon: /* @__PURE__ */ e(E, {}),
|
|
94
|
+
title: "",
|
|
95
|
+
variant: "secondary",
|
|
96
|
+
"data-testid": "select-all"
|
|
97
|
+
}
|
|
98
|
+
);
|
|
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 })
|
|
104
|
+
] }),
|
|
105
|
+
/* @__PURE__ */ e(re, { children: w === "MultiSelect" && T && t.page === "assets" && $ })
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
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 })
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
115
|
+
const k = p.nav`
|
|
116
|
+
display: flex;
|
|
117
|
+
justify-content: space-between;
|
|
118
|
+
background-color: #fff;
|
|
119
|
+
padding: ${F.spacing3} ${F.spacing4};
|
|
120
|
+
z-index: 20;
|
|
121
|
+
`, re = p.div`
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
|
|
125
|
+
button {
|
|
126
|
+
height: initial;
|
|
127
|
+
background-color: transparent;
|
|
128
|
+
border: none;
|
|
129
|
+
padding: 0;
|
|
130
|
+
}
|
|
131
|
+
`, oe = p.div`
|
|
132
|
+
display: inline-flex;
|
|
133
|
+
align-items: center;
|
|
134
|
+
`;
|
|
135
|
+
export {
|
|
136
|
+
Te as AssetFilter
|
|
137
|
+
};
|
|
138
|
+
//# 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 { 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,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,EAAA,GACvCC,IAAOC,EAAA,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;AAAA,IACA,eAAAC;AAAA,EAAA,IACGC,GAAA,GACE,CAACC,GAAsBC,CAAuB,IAAIT,EAAS,EAAK,GAEhE,EAAE,MAAAU,GAAM,WAAAC,EAAA,IAAcC;AAAA,IAC3B;AAAA,MACC,QAAAhC;AAAA,MACA,YAAYI,KAAe;AAAA,MAC3B,eAAeE;AAAA,MACf,UAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,cAAcN,EAAK,SAAS,eAAeA,EAAK,WAAW,KAAK;AAAA,IAAA;AAAA,IAEjEO;AAA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hB,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;"}
|
|
@@ -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';\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,I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;AACzC,IAAAtD,EAAoBsD,CAAK;AAAA,EAC1B;AAEA,QAAMC,IAAqBC;AAAA,IAC1B,OAAO;AAAA,MACN,YAAA9D;AAAA,MACA,gBAAA0D;AAAA,MACA,iBAAAvD;AAAA,MACA,MAAAI;AAAA,MACA,WAAAE;AAAA,MACA,cAAAU;AAAA,MACA,iBAAAI;AAAA,MACA,iBAAAE;AAAA,MACA,oBAAAI;AAAA,MACA,6BAAAX;AAAA,MACA,QAAAmB;AAAA,MACA,WAAAG;AAAA,MACA,OAAAiB;AAAA,MACA,kBAAAE;AAAA,MACA,kBAAAtD;AAAA,MACA,yBAAAoC;AAAA,MACA,yBAAAQ;AAAA,MACA,4BAAApC;AAAA,MACA,uBAAAwC;AAAA,MACA,iBAAAtC;AAAA,IAAA;AAAA;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
|