@leav/ui 1.7.0 → 1.8.0-73498354

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.
Files changed (122) hide show
  1. package/dist/__mocks__/common/library.d.ts +1 -0
  2. package/dist/_gqlTypes/index.d.ts +317 -113
  3. package/dist/_gqlTypes/index.js +142 -53
  4. package/dist/_gqlTypes/index.js.map +1 -1
  5. package/dist/_queries/attributes/attributeDetailsFragment.js +3 -0
  6. package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
  7. package/dist/_queries/attributes/getAttributeWithEmbeddedFields.d.ts +1 -1
  8. package/dist/_queries/libraries/libraryDetailsFragment.js +1 -0
  9. package/dist/_queries/libraries/libraryDetailsFragment.js.map +1 -1
  10. package/dist/components/AttributePicker/AttributesList/AttributesList.js +3 -7
  11. package/dist/components/AttributePicker/AttributesList/AttributesList.js.map +1 -1
  12. package/dist/components/EditLibraryModal/EditLibrary/EditLibraryAttributes/AttributesList/AttributesList.js +3 -7
  13. package/dist/components/EditLibraryModal/EditLibrary/EditLibraryAttributes/AttributesList/AttributesList.js.map +1 -1
  14. package/dist/components/Explorer/TableCell.js +9 -16
  15. package/dist/components/Explorer/TableCell.js.map +1 -1
  16. package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js +2 -2
  17. package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js.map +1 -1
  18. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +3 -0
  19. package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
  20. package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js +2 -2
  21. package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js.map +1 -1
  22. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +17 -8
  23. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
  24. package/dist/components/Filters/_types.d.ts +12 -1
  25. package/dist/components/Filters/_types.js +2 -1
  26. package/dist/components/Filters/_types.js.map +1 -1
  27. package/dist/components/Filters/context/filtersReducer.js +3 -2
  28. package/dist/components/Filters/context/filtersReducer.js.map +1 -1
  29. package/dist/components/Filters/context/useGetTreeFilters.d.ts +8 -6
  30. package/dist/components/Filters/context/useGetTreeFilters.js +41 -18
  31. package/dist/components/Filters/context/useGetTreeFilters.js.map +1 -1
  32. package/dist/components/Filters/filter-items/CommonFilterItem.js +3 -3
  33. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  34. package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js +1 -1
  35. package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js.map +1 -1
  36. package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +6 -2
  37. package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
  38. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +4 -4
  39. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
  40. package/dist/components/Filters/filter-items/filter-type/_types.d.ts +6 -1
  41. package/dist/components/Filters/filter-items/filter-type/_types.js.map +1 -1
  42. package/dist/components/Filters/filter-items/filter-type/smart-filter/SmartFilterAttributeDropdown.d.ts +2 -0
  43. package/dist/components/Filters/filter-items/filter-type/smart-filter/SmartFilterAttributeDropdown.js +106 -0
  44. package/dist/components/Filters/filter-items/filter-type/smart-filter/SmartFilterAttributeDropdown.js.map +1 -0
  45. package/dist/components/Filters/filter-items/filter-type/smart-filter/useGetSmartFilterData.d.ts +25 -0
  46. package/dist/components/Filters/filter-items/filter-type/smart-filter/useGetSmartFilterData.js +59 -0
  47. package/dist/components/Filters/filter-items/filter-type/smart-filter/useGetSmartFilterData.js.map +1 -0
  48. package/dist/components/Filters/filter-items/filter-type/smart-filter/useSmartFilerSearch.d.ts +5 -0
  49. package/dist/components/Filters/filter-items/filter-type/smart-filter/useSmartFilerSearch.js +25 -0
  50. package/dist/components/Filters/filter-items/filter-type/smart-filter/useSmartFilerSearch.js.map +1 -0
  51. package/dist/components/Filters/filter-items/filter-type/{TreeAttributeDropDown.d.ts → tree/TreeAttributeDropDown.d.ts} +1 -1
  52. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js +131 -0
  53. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js.map +1 -0
  54. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.d.ts +20 -0
  55. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js +72 -0
  56. package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js.map +1 -0
  57. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.d.ts +7 -0
  58. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js +36 -0
  59. package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js.map +1 -0
  60. package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.d.ts +2 -0
  61. package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js +14 -0
  62. package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js.map +1 -0
  63. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.d.ts +2 -0
  64. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js +15 -0
  65. package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js.map +1 -0
  66. package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.d.ts +5 -0
  67. package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js +17 -0
  68. package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js.map +1 -0
  69. package/dist/components/Filters/filter-items/{EmptyValueCheckbox.d.ts → shared/EmptyValueCheckbox.d.ts} +2 -1
  70. package/dist/components/Filters/filter-items/shared/EmptyValueCheckbox.js +20 -0
  71. package/dist/components/Filters/filter-items/shared/EmptyValueCheckbox.js.map +1 -0
  72. package/dist/components/Filters/filter-items/shared/FilterTreeNodeTitle.d.ts +5 -0
  73. package/dist/components/Filters/filter-items/shared/FilterTreeNodeTitle.js +18 -0
  74. package/dist/components/Filters/filter-items/shared/FilterTreeNodeTitle.js.map +1 -0
  75. package/dist/components/Filters/filter-items/shared/SelectAllCheckbox.d.ts +8 -0
  76. package/dist/components/Filters/filter-items/shared/SelectAllCheckbox.js +22 -0
  77. package/dist/components/Filters/filter-items/shared/SelectAllCheckbox.js.map +1 -0
  78. package/dist/components/Filters/prepareFiltersForRequest.js +10 -5
  79. package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
  80. package/dist/components/Filters/useFilters.d.ts +542 -0
  81. package/dist/components/Filters/useTransformFilters.js +3 -0
  82. package/dist/components/Filters/useTransformFilters.js.map +1 -1
  83. package/dist/components/LibraryItemsList/hooks/useSearchReducer/_types.d.ts +2 -2
  84. package/dist/components/LibraryItemsList/hooks/useSearchReducer/_types.js.map +1 -1
  85. package/dist/components/LibraryItemsList/hooks/useSearchReducer/searchReducer.d.ts +2 -2
  86. package/dist/components/LibraryItemsList/hooks/useSearchReducer/searchReducer.js.map +1 -1
  87. package/dist/components/LibraryItemsList/hooks/useSearchReducer/useSearchReducer.d.ts +1 -1
  88. package/dist/components/Notifications/hooks/useNotificationSubscription.d.ts +9 -3
  89. package/dist/components/Notifications/hooks/useNotificationSubscription.js +2 -2
  90. package/dist/components/Notifications/hooks/useNotificationSubscription.js.map +1 -1
  91. package/dist/components/RecordEdition/EditRecordContent/antdUtils.js +2 -0
  92. package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
  93. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js +4 -1
  94. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.js.map +1 -1
  95. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js +1 -1
  96. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js.map +1 -1
  97. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js +2 -0
  98. package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js.map +1 -1
  99. package/dist/components/RecordHistory/RecordHistoryLogEntry.js +10 -2
  100. package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
  101. package/dist/components/RecordHistory/_queries/recordHistoryQuery.d.ts +7 -0
  102. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js +64 -0
  103. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js.map +1 -0
  104. package/dist/components/RecordHistory/hooks/useFetchRecordHistory.js +5 -2
  105. package/dist/components/RecordHistory/hooks/useFetchRecordHistory.js.map +1 -1
  106. package/dist/components/RecordHistory/utils/extendedAttribute.d.ts +13 -0
  107. package/dist/components/RecordHistory/utils/extendedAttribute.js +40 -0
  108. package/dist/components/RecordHistory/utils/extendedAttribute.js.map +1 -0
  109. package/dist/components/SelectTreeNode/TreeNodeTitle.js +2 -2
  110. package/dist/components/SelectTreeNode/TreeNodeTitle.js.map +1 -1
  111. package/dist/hooks/useGetLibraryDetailExtendedQuery/useGetLibraryDetailExtendedQuery.d.ts +1 -1
  112. package/dist/hooks/useGetRecordUpdatesSubscription/useGetRecordUpdatesSubscription.d.ts +9 -3
  113. package/dist/hooks/useGetRecordValuesQuery/useGetRecordValuesQuery.js.map +1 -1
  114. package/dist/locales/en/shared.json +6 -2
  115. package/dist/locales/fr/shared.json +6 -2
  116. package/dist/types/records.d.ts +1 -0
  117. package/dist/types/records.js.map +1 -1
  118. package/package.json +8 -8
  119. package/dist/components/Filters/filter-items/EmptyValueCheckbox.js +0 -16
  120. package/dist/components/Filters/filter-items/EmptyValueCheckbox.js.map +0 -1
  121. package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +0 -71
  122. package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CommonFilterItem.js","sourceRoot":"","sources":["../../../../src/components/Filters/filter-items/CommonFilterItem.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,cAAc,EAAC,MAAM,4CAA4C,CAAC;AAC1E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,4BAA4B,EAAC,MAAM,uDAAuD,CAAC;AAEnG,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAE,cAAc,EAAwC,MAAM,WAAW,CAAC;AACpG,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;CAErC,CAAC;AACF,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,CAAY,EAAY,EAAE;IACjE,IAAI,MAAM,CAAC,SAAS,IAAI,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QACrE,MAAM,eAAe,GAAG,4BAA4B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1G,OAAO,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,YAAY,GAAa,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CA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AEpB,uEAAuE;IACvE,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,QAAQ,GAAG,KAAK,CAAC;QAEjB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC;YACtB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAED,OAAO,CACH,KAAC,YAAY,IACT,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,EAClC,aAAa,EAAE;YACX,SAAS,EAAE,YAAY;YACvB,cAAc,EAAE,GAAG,EAAE,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,GAAI;SACrG,GACH,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {FilterDropDown} from '../filter-items/filter-type/FilterDropDown';\nimport styled from 'styled-components';\nimport {KitFilter} from 'aristid-ds';\nimport {AttributeFormat} from '_ui/_gqlTypes';\nimport {getAttributeConditionOptions} from '../filter-items/filter-type/useConditionOptionsByType';\nimport {type TFunction} from 'i18next';\nimport {nullValueConditions} from '../conditionsHelper';\nimport {isUIFilterStandard, isUIFilterTree, type IUIFilterStandard, type UIFilter} from '../_types';\nimport {ACTIVE_ATTRIBUTE_ID} from '_ui/constants';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst FilterStyled = styled(KitFilter)`\n flex: 0 0 auto;\n`;\nconst getFilterValues = (filter: UIFilter, t: TFunction): string[] => {\n if (filter.condition && nullValueConditions.includes(filter.condition)) {\n const conditionOption = getAttributeConditionOptions(t).find(option => option.value === filter.condition);\n return [conditionOption?.label ?? ''];\n }\n\n const filterValues: string[] = filter.withEmptyValues ? [t('filters.empty-value')] : [];\n\n if (isUIFilterTree(filter)) {\n return [...filterValues, ...(filter.formattedValue ?? [])];\n }\n\n if (\n isUIFilterStandard(filter) &&\n [AttributeFormat.date, AttributeFormat.boolean].includes(filter.attribute.format)\n ) {\n return filter.formattedValue ? [...filterValues, filter.formattedValue] : filterValues;\n }\n\n if (Array.isArray(filter.value)) {\n return [...filterValues, ...filter.value];\n } else if (filter.value) {\n return [...filterValues, filter.value];\n }\n return filterValues;\n};\n\nexport interface ICommonFilterProps {\n filter: UIFilter;\n isPinned?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n}\n\nconst isActiveAttribute = (filter: UIFilter): filter is IUIFilterStandard =>\n filter.attribute.format === AttributeFormat.boolean &&\n filter.attribute.id === ACTIVE_ATTRIBUTE_ID &&\n isUIFilterStandard(filter);\n\nexport const CommonFilterItem: FunctionComponent<ICommonFilterProps> = ({\n filter,\n isPinned = false,\n readonly = false,\n disabled,\n}) => {\n const {t} = useSharedTranslation();\n\n let canReset = true;\n\n // Active attribute is a special case, we need to handle it differently\n if (isActiveAttribute(filter)) {\n canReset = false;\n\n if (!filter.value) {\n filter.value = 'true';\n filter.formattedValue = t('explorer.true');\n }\n }\n\n return (\n <FilterStyled\n disabled={disabled}\n readonly={readonly}\n expandable={!readonly}\n label={filter.attribute.label}\n values={getFilterValues(filter, t)}\n dropDownProps={{\n placement: 'bottomLeft',\n dropdownRender: () => <FilterDropDown filter={filter} canReset={canReset} canRemove={!isPinned} />,\n }}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"CommonFilterItem.js","sourceRoot":"","sources":["../../../../src/components/Filters/filter-items/CommonFilterItem.tsx"],"names":[],"mappings":";AAIA,O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,GAAG,MAAM,CAAC;YACtB,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC;IAED,OAAO,CACH,KAAC,YAAY,IACT,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,CAAC,QAAQ,EACrB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,EAC7B,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,EAClC,aAAa,EAAE;YACX,SAAS,EAAE,YAAY;YACvB,cAAc,EAAE,GAAG,EAAE,CAAC,KAAC,cAAc,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,QAAQ,GAAI;SACrG,EACD,eAAe,SACjB,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {FilterDropDown} from '../filter-items/filter-type/FilterDropDown';\nimport styled from 'styled-components';\nimport {KitFilter} from 'aristid-ds';\nimport {AttributeFormat} from '_ui/_gqlTypes';\nimport {getAttributeConditionOptions} from '../filter-items/filter-type/useConditionOptionsByType';\nimport {type TFunction} from 'i18next';\nimport {nullValueConditions} from '../conditionsHelper';\nimport {\n isUIFilterStandard,\n isUIFilterTree,\n isUIFilterWithSmartFilter,\n type IUIFilterStandard,\n type UIFilter,\n} from '../_types';\nimport {ACTIVE_ATTRIBUTE_ID} from '_ui/constants';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\n\nconst FilterStyled = styled(KitFilter)`\n flex: 0 0 auto;\n`;\nconst getFilterValues = (filter: UIFilter, t: TFunction): string[] => {\n if (filter.condition && nullValueConditions.includes(filter.condition)) {\n const conditionOption = getAttributeConditionOptions(t).find(option => option.value === filter.condition);\n return [conditionOption?.label ?? ''];\n }\n\n const filterValues: string[] = filter.withEmptyValues ? [t('filters.empty-value')] : [];\n\n if (isUIFilterTree(filter) || isUIFilterWithSmartFilter(filter)) {\n return [...filterValues, ...(filter.formattedValue ?? [])];\n }\n\n if (\n isUIFilterStandard(filter) &&\n [AttributeFormat.date, AttributeFormat.boolean].includes(filter.attribute.format)\n ) {\n return filter.formattedValue ? [...filterValues, filter.formattedValue] : filterValues;\n }\n\n if (Array.isArray(filter.value)) {\n return [...filterValues, ...filter.value];\n } else if (filter.value) {\n return [...filterValues, filter.value];\n }\n return filterValues;\n};\n\nexport interface ICommonFilterProps {\n filter: UIFilter;\n isPinned?: boolean;\n disabled?: boolean;\n readonly?: boolean;\n}\n\nconst isActiveAttribute = (filter: UIFilter): filter is IUIFilterStandard =>\n filter.attribute.format === AttributeFormat.boolean &&\n filter.attribute.id === ACTIVE_ATTRIBUTE_ID &&\n isUIFilterStandard(filter);\n\nexport const CommonFilterItem: FunctionComponent<ICommonFilterProps> = ({\n filter,\n isPinned = false,\n readonly = false,\n disabled,\n}) => {\n const {t} = useSharedTranslation();\n\n let canReset = true;\n\n // Active attribute is a special case, we need to handle it differently\n if (isActiveAttribute(filter)) {\n canReset = false;\n\n if (!filter.value) {\n filter.value = 'true';\n filter.formattedValue = t('explorer.true');\n }\n }\n\n return (\n <FilterStyled\n disabled={disabled}\n readonly={readonly}\n expandable={!readonly}\n label={filter.attribute.label}\n values={getFilterValues(filter, t)}\n dropDownProps={{\n placement: 'bottomLeft',\n dropdownRender: () => <FilterDropDown filter={filter} canReset={canReset} canRemove={!isPinned} />,\n }}\n showSingleValue\n />\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { EmptyValueCheckbox } from '../EmptyValueCheckbox';
2
+ import { EmptyValueCheckbox } from '../shared/EmptyValueCheckbox';
3
3
  export const ColorAttributeDropDown = ({ filter, onFilterChange }) => {
4
4
  const _handleOnCheckEmptyValue = (selected) => {
5
5
  onFilterChange({
@@ -1 +1 @@
1
- {"version":3,"file":"ColorAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/ColorAttributeDropDown.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,MAAM,CAAC,MAAM,sBAAsB,GAAoD,CAAC,EAAC,MAAM,EAAE,cAAc,EAAC,EAAE,EAAE;IAChH,MAAM,wBAAwB,GAAG,CAAC,QAAiB,EAAE,EAAE;QACnD,cAAc,CAAC;YACX,GAAG,MAAM;YACT,eAAe,EAAE,QAAQ;SAC5B,CAAC,CAAC;IACP,CAAC,CAAC;IACF,OAAO,KAAC,kBAAkB,IAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AACtF,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {EmptyValueCheckbox} from '../EmptyValueCheckbox';\n\nexport const ColorAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({filter, onFilterChange}) => {\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n return <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />;\n};\n"]}
1
+ {"version":3,"file":"ColorAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/ColorAttributeDropDown.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAoD,CAAC,EAAC,MAAM,EAAE,cAAc,EAAC,EAAE,EAAE;IAChH,MAAM,wBAAwB,GAAG,CAAC,QAAiB,EAAE,EAAE;QACnD,cAAc,CAAC;YACX,GAAG,MAAM;YACT,eAAe,EAAE,QAAQ;SAC5B,CAAC,CAAC;IACP,CAAC,CAAC;IACF,OAAO,KAAC,kBAAkB,IAAC,QAAQ,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;AACtF,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {EmptyValueCheckbox} from '../shared/EmptyValueCheckbox';\n\nexport const ColorAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({filter, onFilterChange}) => {\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n return <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />;\n};\n"]}
@@ -12,13 +12,17 @@ import { ExtendedAttributeDropDown } from './ExtendedAttributeDropDown';
12
12
  import { LinkAttributeDropDown } from './LinkAttributeDropdown';
13
13
  import { NumericAttributeDropDown } from './NumericAttributeDropDown';
14
14
  import { TextAttributeDropDown } from './TextAttributeDropDown';
15
- import { TreeAttributeDropDown } from './TreeAttributeDropDown';
15
+ import { TreeAttributeDropDown } from './tree/TreeAttributeDropDown';
16
16
  import { FilterValueListDropDown } from './FilterValueListDropDown';
17
- import { isUIFilterLink, isUIFilterStandard, isUIFilterThrough, isUIFilterTree, isUIFilterValueList, } from '../../_types';
17
+ import { isUIFilterLink, isUIFilterStandard, isUIFilterThrough, isUIFilterTree, isUIFilterValueList, isUIFilterWithSmartFilter, } from '../../_types';
18
+ import { SmartFilterAttributeDropdown } from './smart-filter/SmartFilterAttributeDropdown';
18
19
  export const FilterDropdownContent = ({ filter, onFilterChange, selectDropDownRef, removeThroughCondition = false }) => {
19
20
  if (isUIFilterValueList(filter)) {
20
21
  return _jsx(FilterValueListDropDown, { filter: filter, onFilterChange: onFilterChange });
21
22
  }
23
+ if (isUIFilterWithSmartFilter(filter)) {
24
+ return _jsx(SmartFilterAttributeDropdown, { filter: filter, onFilterChange: onFilterChange });
25
+ }
22
26
  if (isUIFilterStandard(filter)) {
23
27
  const commonDropDownProps = {
24
28
  filter,
@@ -1 +1 @@
1
- {"version":3,"file":"FilterDropdownContent.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/FilterDropdownContent.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,0BAA0B,EAAC,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GAEtB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,qBAAqB,GAK7B,CAAC,EAAC,MAAM,EAAE,c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,OAAO,CACH,KAAC,qBAAqB,IAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,GACtC,CACL,CAAC;IACN,CAAC;IAED,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtD,OAAO,CACH,KAAC,qBAAqB,IAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,sBAAsB,EAC9C,iBAAiB,EAAE,iBAAiB,GACtC,CACL,CAAC;IACN,CAAC;IAED,OAAO,mBAAK,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {AttributeFormat} from '_ui/_gqlTypes';\nimport {type FunctionComponent, type RefObject} from 'react';\nimport {BooleanAttributeDropDown} from './BooleanAttributeDropdown';\nimport {ColorAttributeDropDown} from './ColorAttributeDropDown';\nimport {DateAttributeDropDown} from './DateAttributeDropDown';\nimport {DateRangeAttributeDropDown} from './DateRangeAttributeDropDown';\nimport {EncryptedAttributeDropDown} from './EncryptedAttributeDropDown';\nimport {ExtendedAttributeDropDown} from './ExtendedAttributeDropDown';\nimport {LinkAttributeDropDown} from './LinkAttributeDropdown';\nimport {NumericAttributeDropDown} from './NumericAttributeDropDown';\nimport {TextAttributeDropDown} from './TextAttributeDropDown';\nimport {TreeAttributeDropDown} from './TreeAttributeDropDown';\nimport {FilterValueListDropDown} from './FilterValueListDropDown';\nimport {\n isUIFilterLink,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n type UIFilter,\n} from '../../_types';\n\nexport const FilterDropdownContent: FunctionComponent<{\n filter: UIFilter;\n onFilterChange: (filterData: UIFilter) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n removeThroughCondition?: boolean;\n}> = ({filter, onFilterChange, selectDropDownRef, removeThroughCondition = false}) => {\n if (isUIFilterValueList(filter)) {\n return <FilterValueListDropDown filter={filter} onFilterChange={onFilterChange} />;\n }\n\n if (isUIFilterStandard(filter)) {\n const commonDropDownProps = {\n filter,\n onFilterChange,\n selectDropDownRef,\n };\n const standardFormatDropdown: Record<AttributeFormat, JSX.Element> = {\n [AttributeFormat.text]: <TextAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.rich_text]: <TextAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.numeric]: <NumericAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.date]: <DateAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.boolean]: <BooleanAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.encrypted]: <EncryptedAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.extended]: <ExtendedAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.color]: <ColorAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.date_range]: <DateRangeAttributeDropDown {...commonDropDownProps} />,\n };\n return standardFormatDropdown[filter.attribute.format ?? AttributeFormat.text];\n }\n\n if (isUIFilterTree(filter)) {\n return (\n <TreeAttributeDropDown\n filter={filter}\n onFilterChange={onFilterChange}\n selectDropDownRef={selectDropDownRef}\n />\n );\n }\n\n if (isUIFilterLink(filter) || isUIFilterThrough(filter)) {\n return (\n <LinkAttributeDropDown\n filter={filter}\n onFilterChange={onFilterChange}\n removeThroughCondition={removeThroughCondition}\n selectDropDownRef={selectDropDownRef}\n />\n );\n }\n\n return <></>;\n};\n"]}
1
+ {"version":3,"file":"FilterDropdownContent.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/FilterDropdownContent.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAC,wBA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AAc,EAC9B,sBAAsB,EAAE,sBAAsB,EAC9C,iBAAiB,EAAE,iBAAiB,GACtC,CACL,CAAC;IACN,CAAC;IAED,OAAO,mBAAK,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {AttributeFormat} from '_ui/_gqlTypes';\nimport {type FunctionComponent, type RefObject} from 'react';\nimport {BooleanAttributeDropDown} from './BooleanAttributeDropdown';\nimport {ColorAttributeDropDown} from './ColorAttributeDropDown';\nimport {DateAttributeDropDown} from './DateAttributeDropDown';\nimport {DateRangeAttributeDropDown} from './DateRangeAttributeDropDown';\nimport {EncryptedAttributeDropDown} from './EncryptedAttributeDropDown';\nimport {ExtendedAttributeDropDown} from './ExtendedAttributeDropDown';\nimport {LinkAttributeDropDown} from './LinkAttributeDropdown';\nimport {NumericAttributeDropDown} from './NumericAttributeDropDown';\nimport {TextAttributeDropDown} from './TextAttributeDropDown';\nimport {TreeAttributeDropDown} from './tree/TreeAttributeDropDown';\nimport {FilterValueListDropDown} from './FilterValueListDropDown';\nimport {\n isUIFilterLink,\n isUIFilterStandard,\n isUIFilterThrough,\n isUIFilterTree,\n isUIFilterValueList,\n isUIFilterWithSmartFilter,\n type UIFilter,\n} from '../../_types';\nimport {SmartFilterAttributeDropdown} from './smart-filter/SmartFilterAttributeDropdown';\n\nexport const FilterDropdownContent: FunctionComponent<{\n filter: UIFilter;\n onFilterChange: (filterData: UIFilter) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n removeThroughCondition?: boolean;\n}> = ({filter, onFilterChange, selectDropDownRef, removeThroughCondition = false}) => {\n if (isUIFilterValueList(filter)) {\n return <FilterValueListDropDown filter={filter} onFilterChange={onFilterChange} />;\n }\n\n if (isUIFilterWithSmartFilter(filter)) {\n return <SmartFilterAttributeDropdown filter={filter} onFilterChange={onFilterChange} />;\n }\n\n if (isUIFilterStandard(filter)) {\n const commonDropDownProps = {\n filter,\n onFilterChange,\n selectDropDownRef,\n };\n const standardFormatDropdown: Record<AttributeFormat, JSX.Element> = {\n [AttributeFormat.text]: <TextAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.rich_text]: <TextAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.numeric]: <NumericAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.date]: <DateAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.boolean]: <BooleanAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.encrypted]: <EncryptedAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.extended]: <ExtendedAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.color]: <ColorAttributeDropDown {...commonDropDownProps} />,\n [AttributeFormat.date_range]: <DateRangeAttributeDropDown {...commonDropDownProps} />,\n };\n return standardFormatDropdown[filter.attribute.format ?? AttributeFormat.text];\n }\n\n if (isUIFilterTree(filter)) {\n return (\n <TreeAttributeDropDown\n filter={filter}\n onFilterChange={onFilterChange}\n selectDropDownRef={selectDropDownRef}\n />\n );\n }\n\n if (isUIFilterLink(filter) || isUIFilterThrough(filter)) {\n return (\n <LinkAttributeDropDown\n filter={filter}\n onFilterChange={onFilterChange}\n removeThroughCondition={removeThroughCondition}\n selectDropDownRef={selectDropDownRef}\n />\n );\n }\n\n return <></>;\n};\n"]}
@@ -9,8 +9,8 @@ import styled from 'styled-components';
9
9
  import { RecordFilterCondition } from '../../../../_gqlTypes';
10
10
  import { isUIFilterLinkWithValueList, isUIFilterStandardWithValueList, } from '../../_types';
11
11
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
12
- import { faCheck } from '@fortawesome/free-solid-svg-icons';
13
- import { EmptyValueCheckbox } from '../EmptyValueCheckbox';
12
+ import { faCheck, faSearch } from '@fortawesome/free-solid-svg-icons';
13
+ import { EmptyValueCheckbox } from '../shared/EmptyValueCheckbox';
14
14
  const ListDivStyled = styled.div `
15
15
  display: flex;
16
16
  flex-direction: column;
@@ -117,9 +117,9 @@ export const FilterValueListDropDown = ({ filter, onFilterChange }) => {
117
117
  _handleToggle(value);
118
118
  }
119
119
  };
120
- return (_jsxs(_Fragment, { children: [_jsx(KitInput, { value: searchText, onChange: e => setSearchText(e.target.value), placeholder: t('global.search') + '...', allowClear: true }), _jsx(EmptyValueCheckbox, { onSelect: _handleOnCheckEmptyValue, filter: filter }), filter.condition === RecordFilterCondition.EQUAL && (_jsx(ListDivStyled, { role: "group", "aria-label": String(t('explorer.filter-value')), children: filteredOptions.map(opt => {
120
+ return (_jsxs(_Fragment, { children: [_jsx(KitInput, { prefix: _jsx(FontAwesomeIcon, { icon: faSearch }), placeholder: t('global.search'), value: searchText, onChange: e => setSearchText(e.target.value), allowClear: true }), _jsx(EmptyValueCheckbox, { onSelect: _handleOnCheckEmptyValue, filter: filter }), _jsx(ListDivStyled, { role: "group", "aria-label": String(t('explorer.filter-value')), children: filteredOptions.map(opt => {
121
121
  const selected = isChecked(opt.value);
122
122
  return (_jsxs(OptionRow, { "$selected": selected, role: "button", "aria-pressed": selected, tabIndex: 0, onClick: () => _handleToggle(opt.value), onKeyDown: e => onKeyToggle(e, opt.value), children: [_jsx(Label, { children: opt.label }), _jsx(RightIcon, { "$visible": selected, icon: faCheck })] }, opt.value));
123
- }) }))] }));
123
+ }) })] }));
124
124
  };
125
125
  //# sourceMappingURL=FilterValueListDropDown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterValueListDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/FilterValueListDropDown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAA6C,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,C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EAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FunctionComponent, type KeyboardEvent, useMemo, useState} from 'react';\nimport {KitInput} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {RecordFilterCondition} from '_ui/_gqlTypes';\nimport {\n isUIFilterLinkWithValueList,\n isUIFilterStandardWithValueList,\n type IUIFilterValueList,\n type UIFilter,\n} from '../../_types';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faCheck} from '@fortawesome/free-solid-svg-icons';\nimport {EmptyValueCheckbox} from '../EmptyValueCheckbox';\n\ninterface IFilterValueListDropDownProps {\n filter: IUIFilterValueList;\n onFilterChange: (filter: UIFilter) => void;\n}\n\nconst ListDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n gap: calc(var(--general-spacing-xxs) * 1px);\n`;\n\nconst OptionRow = styled.div<{$selected: boolean}>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 calc(var(--general-spacing-xs) * 1px);\n height: 36px;\n border-radius: calc(var(--general-spacing-xs) * 1px);\n cursor: pointer;\n background: ${props => (props.$selected ? 'var(--general-utilities-main-light)' : 'transparent')};\n color: var(--general-utilities-text-primary);\n\n &:hover {\n background: var(--general-utilities-main-light);\n }\n`;\n\nconst RightIcon = styled(FontAwesomeIcon)<{$visible: boolean}>`\n color: var(--general-utilities-main-default);\n opacity: ${props => (props.$visible ? 1 : 0)};\n transition: opacity 0.12s ease-in-out;\n`;\n\nconst Label = styled.div`\n flex: 1;\n min-width: 0; /* allow flex child to shrink for ellipsis */\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nexport const FilterValueListDropDown: FunctionComponent<IFilterValueListDropDownProps> = ({filter, onFilterChange}) => {\n const {t} = useSharedTranslation();\n const [searchText, setSearchText] = useState('');\n\n const getOptionLabelText = (label: any): string => (typeof label === 'string' ? label : '');\n\n // Generate an option list for the filter dropdown to select a value\n const _createOptionListFromValueList = () => {\n let valueListFormatted: Array<{label: string; value: string}> = [];\n if (isUIFilterStandardWithValueList(filter)) {\n valueListFormatted =\n filter.attribute.valuesList?.values?.map(value => ({\n label: value,\n value,\n })) || [];\n } else if (isUIFilterLinkWithValueList(filter)) {\n valueListFormatted =\n filter.attribute.valuesList?.linkedValues?.map(value => ({\n label: value.whoAmI.label!,\n value: value.id,\n })) || [];\n }\n\n return [...valueListFormatted];\n };\n\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n\n const _handleToggle = (toggledValue: string) => {\n // remove or add the toggledValue from the filter.value\n const currentList = filter.value || [];\n const current = new Set(currentList);\n if (current.has(toggledValue)) {\n current.delete(toggledValue);\n } else {\n current.add(toggledValue);\n }\n const valuesSelected = Array.from(current);\n\n if (valuesSelected.length === 0) {\n // Clear filter when nothing selected\n onFilterChange({\n ...filter,\n value: [],\n field: (filter as any).field,\n });\n return;\n }\n\n onFilterChange({\n ...filter,\n condition: RecordFilterCondition.EQUAL,\n value: valuesSelected,\n });\n };\n\n const options = _createOptionListFromValueList();\n\n const isChecked = (optionValue: string) => {\n const set = new Set(filter.value ?? []);\n return set.has(optionValue);\n };\n\n const filteredOptions = useMemo(() => {\n if (!searchText) {\n return options;\n }\n const st = searchText.toLowerCase();\n const specials = new Set(['']);\n return options.filter(o => specials.has(o.value) || getOptionLabelText(o.label).toLowerCase().includes(st));\n }, [options, searchText]);\n\n const onKeyToggle = (e: KeyboardEvent<HTMLDivElement>, value: string) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n _handleToggle(value);\n }\n };\n\n return (\n <>\n <KitInput\n value={searchText}\n onChange={e => setSearchText(e.target.value)}\n placeholder={t('global.search') + '...'}\n allowClear\n />\n <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />\n {filter.condition === RecordFilterCondition.EQUAL && (\n <ListDivStyled role=\"group\" aria-label={String(t('explorer.filter-value'))}>\n {filteredOptions.map(opt => {\n const selected = isChecked(opt.value);\n return (\n <OptionRow\n key={opt.value}\n $selected={selected}\n role=\"button\"\n aria-pressed={selected}\n tabIndex={0}\n onClick={() => _handleToggle(opt.value)}\n onKeyDown={e => onKeyToggle(e, opt.value)}\n >\n <Label>{opt.label}</Label>\n <RightIcon $visible={selected} icon={faCheck} />\n </OptionRow>\n );\n })}\n </ListDivStyled>\n )}\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"FilterValueListDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/FilterValueListDropDown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAA6C,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACpF,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,EACH,2BAA2B,EAC3B,+BAA+B,GAGlC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAOhE,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI/B,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAsB;;;;;;;;kBAQhC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC,CAAC,aAAa,CAAC;;;;;;CAM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,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,YACrE,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBACvB,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACtC,OAAO,CACH,MAAC,SAAS,iBAEK,QAAQ,EACnB,IAAI,EAAC,QAAQ,kBACC,QAAQ,EACtB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EACvC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,aAEzC,KAAC,KAAK,cAAE,GAAG,CAAC,KAAK,GAAS,EAC1B,KAAC,SAAS,gBAAW,QAAQ,EAAE,IAAI,EAAE,OAAO,GAAI,KAT3C,GAAG,CAAC,KAAK,CAUN,CACf,CAAC;gBACN,CAAC,CAAC,GACU,IACjB,CACN,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type FunctionComponent, type KeyboardEvent, useMemo, useState} from 'react';\nimport {KitInput} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {RecordFilterCondition} from '_ui/_gqlTypes';\nimport {\n isUIFilterLinkWithValueList,\n isUIFilterStandardWithValueList,\n type IUIFilterValueList,\n type UIFilter,\n} from '../../_types';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faCheck, faSearch} from '@fortawesome/free-solid-svg-icons';\nimport {EmptyValueCheckbox} from '../shared/EmptyValueCheckbox';\n\ninterface IFilterValueListDropDownProps {\n filter: IUIFilterValueList;\n onFilterChange: (filter: UIFilter) => void;\n}\n\nconst ListDivStyled = styled.div`\n display: flex;\n flex-direction: column;\n gap: calc(var(--general-spacing-xxs) * 1px);\n`;\n\nconst OptionRow = styled.div<{$selected: boolean}>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 calc(var(--general-spacing-xs) * 1px);\n height: 36px;\n border-radius: calc(var(--general-spacing-xs) * 1px);\n cursor: pointer;\n background: ${props => (props.$selected ? 'var(--general-utilities-main-light)' : 'transparent')};\n color: var(--general-utilities-text-primary);\n\n &:hover {\n background: var(--general-utilities-main-light);\n }\n`;\n\nconst RightIcon = styled(FontAwesomeIcon)<{$visible: boolean}>`\n color: var(--general-utilities-main-default);\n opacity: ${props => (props.$visible ? 1 : 0)};\n transition: opacity 0.12s ease-in-out;\n`;\n\nconst Label = styled.div`\n flex: 1;\n min-width: 0; /* allow flex child to shrink for ellipsis */\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n`;\n\nexport const FilterValueListDropDown: FunctionComponent<IFilterValueListDropDownProps> = ({filter, onFilterChange}) => {\n const {t} = useSharedTranslation();\n const [searchText, setSearchText] = useState('');\n\n const getOptionLabelText = (label: any): string => (typeof label === 'string' ? label : '');\n\n // Generate an option list for the filter dropdown to select a value\n const _createOptionListFromValueList = () => {\n let valueListFormatted: Array<{label: string; value: string}> = [];\n if (isUIFilterStandardWithValueList(filter)) {\n valueListFormatted =\n filter.attribute.valuesList?.values?.map(value => ({\n label: value,\n value,\n })) || [];\n } else if (isUIFilterLinkWithValueList(filter)) {\n valueListFormatted =\n filter.attribute.valuesList?.linkedValues?.map(value => ({\n label: value.whoAmI.label!,\n value: value.id,\n })) || [];\n }\n\n return [...valueListFormatted];\n };\n\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n\n const _handleToggle = (toggledValue: string) => {\n // remove or add the toggledValue from the filter.value\n const currentList = filter.value || [];\n const current = new Set(currentList);\n if (current.has(toggledValue)) {\n current.delete(toggledValue);\n } else {\n current.add(toggledValue);\n }\n const valuesSelected = Array.from(current);\n\n if (valuesSelected.length === 0) {\n // Clear filter when nothing selected\n onFilterChange({\n ...filter,\n value: [],\n field: (filter as any).field,\n });\n return;\n }\n\n onFilterChange({\n ...filter,\n condition: RecordFilterCondition.EQUAL,\n value: valuesSelected,\n });\n };\n\n const options = _createOptionListFromValueList();\n\n const isChecked = (optionValue: string) => {\n const set = new Set(filter.value ?? []);\n return set.has(optionValue);\n };\n\n const filteredOptions = useMemo(() => {\n if (!searchText) {\n return options;\n }\n const st = searchText.toLowerCase();\n const specials = new Set(['']);\n return options.filter(o => specials.has(o.value) || getOptionLabelText(o.label).toLowerCase().includes(st));\n }, [options, searchText]);\n\n const onKeyToggle = (e: KeyboardEvent<HTMLDivElement>, value: string) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n _handleToggle(value);\n }\n };\n\n return (\n <>\n <KitInput\n prefix={<FontAwesomeIcon icon={faSearch} />}\n placeholder={t('global.search')}\n value={searchText}\n onChange={e => setSearchText(e.target.value)}\n allowClear\n />\n <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />\n <ListDivStyled role=\"group\" aria-label={String(t('explorer.filter-value'))}>\n {filteredOptions.map(opt => {\n const selected = isChecked(opt.value);\n return (\n <OptionRow\n key={opt.value}\n $selected={selected}\n role=\"button\"\n aria-pressed={selected}\n tabIndex={0}\n onClick={() => _handleToggle(opt.value)}\n onKeyDown={e => onKeyToggle(e, opt.value)}\n >\n <Label>{opt.label}</Label>\n <RightIcon $visible={selected} icon={faCheck} />\n </OptionRow>\n );\n })}\n </ListDivStyled>\n </>\n );\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type RefObject } from 'react';
2
- import { type IUIFilterLink, type IUIFilterStandard, type IUIFilterThrough, type IUIFilterTree } from '../../_types';
2
+ import { type IUIFilterSmartFiler, type IUIFilterLink, type IUIFilterStandard, type IUIFilterThrough, type IUIFilterTree } from '../../_types';
3
3
  export interface IFilterChildrenDropDownProps {
4
4
  filter: IUIFilterStandard;
5
5
  onFilterChange: (filterData: IUIFilterStandard) => void;
@@ -16,3 +16,8 @@ export interface IFilterChildrenTreeDropDownProps {
16
16
  onFilterChange: (filterData: IUIFilterTree) => void;
17
17
  selectDropDownRef?: RefObject<HTMLDivElement>;
18
18
  }
19
+ export interface IFilterChildrenSmartFilterDropDownProps {
20
+ filter: IUIFilterSmartFiler;
21
+ onFilterChange: (filterData: IUIFilterSmartFiler) => void;
22
+ selectDropDownRef?: RefObject<HTMLDivElement>;
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/_types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type RefObject} from 'react';\nimport {type IUIFilterLink, type IUIFilterStandard, type IUIFilterThrough, type IUIFilterTree} from '../../_types';\n\nexport interface IFilterChildrenDropDownProps {\n filter: IUIFilterStandard;\n onFilterChange: (filterData: IUIFilterStandard) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n\nexport interface IFilterChildrenLinkDropDownProps {\n filter: IUIFilterLink | IUIFilterThrough;\n onFilterChange: (filterData: IUIFilterLink | IUIFilterThrough) => void;\n removeThroughCondition: boolean;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n\nexport interface IFilterChildrenTreeDropDownProps {\n filter: IUIFilterTree;\n onFilterChange: (filterData: IUIFilterTree) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n"]}
1
+ {"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/_types.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type RefObject} from 'react';\nimport {\n type IUIFilterSmartFiler,\n type IUIFilterLink,\n type IUIFilterStandard,\n type IUIFilterThrough,\n type IUIFilterTree,\n} from '../../_types';\n\nexport interface IFilterChildrenDropDownProps {\n filter: IUIFilterStandard;\n onFilterChange: (filterData: IUIFilterStandard) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n\nexport interface IFilterChildrenLinkDropDownProps {\n filter: IUIFilterLink | IUIFilterThrough;\n onFilterChange: (filterData: IUIFilterLink | IUIFilterThrough) => void;\n removeThroughCondition: boolean;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n\nexport interface IFilterChildrenTreeDropDownProps {\n filter: IUIFilterTree;\n onFilterChange: (filterData: IUIFilterTree) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n\nexport interface IFilterChildrenSmartFilterDropDownProps {\n filter: IUIFilterSmartFiler;\n onFilterChange: (filterData: IUIFilterSmartFiler) => void;\n selectDropDownRef?: RefObject<HTMLDivElement>;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { type IFilterChildrenSmartFilterDropDownProps } from '../_types';
2
+ export declare const SmartFilterAttributeDropdown: ({ filter, onFilterChange }: IFilterChildrenSmartFilterDropDownProps) => JSX.Element;
@@ -0,0 +1,106 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { ErrorDisplay } from '../../../../../components/ErrorDisplay';
6
+ import { useFiltersContext } from '../../../../../components/Filters/useFiltersContext';
7
+ import { KitLoader, KitSpace, KitTree } from 'aristid-ds';
8
+ import { useGetSmartFilterData } from './useGetSmartFilterData';
9
+ import { useSmartFilterSearch } from './useSmartFilerSearch';
10
+ import styled from 'styled-components';
11
+ import { SelectAllCheckbox } from '../../shared/SelectAllCheckbox';
12
+ import { EmptyValueCheckbox } from '../../shared/EmptyValueCheckbox';
13
+ import { FilterTreeNodeTitle } from '../../shared/FilterTreeNodeTitle';
14
+ const DropdownContentWrapper = styled(KitSpace) `
15
+ width: 327px;
16
+ justify-content: center;
17
+ `;
18
+ const ScrollableContent = styled.div `
19
+ max-height: 182px; /* Equal to 5.5 nodes of KitTree */
20
+ overflow-y: auto;
21
+ overflow-x: hidden;
22
+ width: 100%;
23
+ `;
24
+ const KitTreeWithGhostedNodes = styled(KitTree) `
25
+ & .ant-tree-treenode:has(div[data-ghosted='true']) {
26
+ & > span {
27
+ background-color: var(--general-utilities-neutral-light) !important;
28
+
29
+ .ant-tree-checkbox-inner {
30
+ background-color: var(--general-utilities-neutral-dark) !important;
31
+ border-color: var(--general-utilities-neutral-dark) !important;
32
+ }
33
+
34
+ .ant-typography {
35
+ font-style: italic;
36
+ }
37
+ }
38
+ }
39
+ `;
40
+ export const SmartFilterAttributeDropdown = ({ filter, onFilterChange }) => {
41
+ const { filtersData } = useFiltersContext();
42
+ const selectedNodesIds = [...(filter.value ?? [])];
43
+ const { smartFilterDataToDisplay, noValueNodeData, isLoading, error } = useGetSmartFilterData({
44
+ libraryId: filtersData.libraryId,
45
+ attributeId: filter.attribute.id,
46
+ filters: filtersData.filters,
47
+ filtersOperator: filtersData.filtersOperator,
48
+ selectedValueIds: selectedNodesIds,
49
+ selectedFormattedValues: filter.formattedValue,
50
+ linkedLibraryId: filter.attribute.linkedLibrary?.id,
51
+ });
52
+ const { filteredSmartFilterData, SearchInput } = useSmartFilterSearch(smartFilterDataToDisplay);
53
+ const isFullyChecked = selectedNodesIds.length > 0 &&
54
+ selectedNodesIds.length === smartFilterDataToDisplay.length &&
55
+ filter.withEmptyValues;
56
+ const hasAnySelection = selectedNodesIds.length > 0 || filter.withEmptyValues;
57
+ const _handleOnSelect = (node, selected) => {
58
+ let newSelectedIds;
59
+ if (selected) {
60
+ newSelectedIds = [...selectedNodesIds, node.key];
61
+ }
62
+ else {
63
+ newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.key);
64
+ }
65
+ const selectedNodes = newSelectedIds
66
+ .map(nodeKey => filteredSmartFilterData.find(smartFilterNode => smartFilterNode.key === nodeKey))
67
+ .filter((selectedNode) => Boolean(selectedNode));
68
+ onFilterChange({
69
+ ...filter,
70
+ value: selectedNodes.map(selectedNode => selectedNode.recordId),
71
+ formattedValue: selectedNodes.map(selectedNode => selectedNode.title),
72
+ });
73
+ };
74
+ const _handleOnSelectAll = (isSelected) => {
75
+ const selectedNodes = isSelected ? [...smartFilterDataToDisplay] : [];
76
+ onFilterChange({
77
+ ...filter,
78
+ value: selectedNodes.map(selectedNode => selectedNode.recordId),
79
+ formattedValue: selectedNodes.map(selectedNode => selectedNode.title),
80
+ withEmptyValues: isSelected,
81
+ });
82
+ };
83
+ const _handleOnSelectEmptyValue = (selected) => {
84
+ onFilterChange({
85
+ ...filter,
86
+ withEmptyValues: selected,
87
+ });
88
+ };
89
+ if (isLoading) {
90
+ return (_jsx(DropdownContentWrapper, { align: "center", children: _jsx(KitLoader, {}) }));
91
+ }
92
+ if (error) {
93
+ return (_jsx(DropdownContentWrapper, { children: _jsx(ErrorDisplay, { message: error.message }) }));
94
+ }
95
+ return (_jsxs(DropdownContentWrapper, { direction: "vertical", size: "xs", children: [SearchInput, _jsxs(ScrollableContent, { children: [_jsx(SelectAllCheckbox, { checked: isFullyChecked, indeterminate: hasAnySelection && !isFullyChecked, onChange: _handleOnSelectAll }), _jsx(EmptyValueCheckbox, { filter: filter, onSelect: _handleOnSelectEmptyValue, count: noValueNodeData?.count ?? 0 }), _jsx(KitTreeWithGhostedNodes, { treeData: filteredSmartFilterData, selectedKeys: selectedNodesIds, checkedKeys: selectedNodesIds, checkable: true, checkStrictly: true, multiple: true, titleRender: kitTreeNode => {
96
+ const node = kitTreeNode;
97
+ return (_jsx(FilterTreeNodeTitle, { title: node.title, count: node.count ?? 0, ghosted: node.ghosted }));
98
+ }, onCheck: (_, info) => {
99
+ const node = info.node;
100
+ _handleOnSelect(node, info.checked);
101
+ }, onSelect: (_, info) => {
102
+ const node = info.node;
103
+ _handleOnSelect(node, info.selected);
104
+ } })] })] }));
105
+ };
106
+ //# sourceMappingURL=SmartFilterAttributeDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmartFilterAttributeDropdown.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/smart-filter/SmartFilterAttributeDropdown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AACxD,OAAO,EAAwB,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAErE,MAAM,sBAAsB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;;CAG9C,CAAC;AAEF,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAKnC,CAAC;AAEF,MAAM,uBAAuB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;;;;;;;;;;;;;;CAe9C,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAC,MAAM,EAAE,cAAc,EAA0C,EAAE,EAAE;IAC9G,MAAM,EAAC,WAAW,EAAC,GAAG,iBAAiB,EAAE,CAAC;IAE1C,MAAM,gBAAgB,GAA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ent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {ErrorDisplay} from '_ui/components/ErrorDisplay';\nimport {useFiltersContext} from '_ui/components/Filters/useFiltersContext';\nimport {KitLoader, KitSpace, KitTree} from 'aristid-ds';\nimport {type ISmartFilterNode, useGetSmartFilterData} from './useGetSmartFilterData';\nimport {useSmartFilterSearch} from './useSmartFilerSearch';\nimport styled from 'styled-components';\nimport {type EventDataNode} from 'antd/es/tree';\nimport {type IFilterChildrenSmartFilterDropDownProps} from '../_types';\nimport {SelectAllCheckbox} from '../../shared/SelectAllCheckbox';\nimport {EmptyValueCheckbox} from '../../shared/EmptyValueCheckbox';\nimport {FilterTreeNodeTitle} from '../../shared/FilterTreeNodeTitle';\n\nconst DropdownContentWrapper = styled(KitSpace)`\n width: 327px;\n justify-content: center;\n`;\n\nconst ScrollableContent = styled.div`\n max-height: 182px; /* Equal to 5.5 nodes of KitTree */\n overflow-y: auto;\n overflow-x: hidden;\n width: 100%;\n`;\n\nconst KitTreeWithGhostedNodes = styled(KitTree)`\n & .ant-tree-treenode:has(div[data-ghosted='true']) {\n & > span {\n background-color: var(--general-utilities-neutral-light) !important;\n\n .ant-tree-checkbox-inner {\n background-color: var(--general-utilities-neutral-dark) !important;\n border-color: var(--general-utilities-neutral-dark) !important;\n }\n\n .ant-typography {\n font-style: italic;\n }\n }\n }\n`;\n\nexport const SmartFilterAttributeDropdown = ({filter, onFilterChange}: IFilterChildrenSmartFilterDropDownProps) => {\n const {filtersData} = useFiltersContext();\n\n const selectedNodesIds = [...(filter.value ?? [])];\n\n const {smartFilterDataToDisplay, noValueNodeData, isLoading, error} = useGetSmartFilterData({\n libraryId: filtersData.libraryId,\n attributeId: filter.attribute.id,\n filters: filtersData.filters,\n filtersOperator: filtersData.filtersOperator,\n selectedValueIds: selectedNodesIds,\n selectedFormattedValues: filter.formattedValue,\n linkedLibraryId: filter.attribute.linkedLibrary?.id,\n });\n\n const {filteredSmartFilterData, SearchInput} = useSmartFilterSearch(smartFilterDataToDisplay);\n\n const isFullyChecked =\n selectedNodesIds.length > 0 &&\n selectedNodesIds.length === smartFilterDataToDisplay.length &&\n filter.withEmptyValues;\n const hasAnySelection = selectedNodesIds.length > 0 || filter.withEmptyValues;\n\n const _handleOnSelect = (node: ISmartFilterNode, selected: boolean) => {\n let newSelectedIds: string[];\n\n if (selected) {\n newSelectedIds = [...selectedNodesIds, node.key];\n } else {\n newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.key);\n }\n\n const selectedNodes = newSelectedIds\n .map(nodeKey => filteredSmartFilterData.find(smartFilterNode => smartFilterNode.key === nodeKey))\n .filter((selectedNode): selectedNode is ISmartFilterNode => Boolean(selectedNode));\n\n onFilterChange({\n ...filter,\n value: selectedNodes.map(selectedNode => selectedNode.recordId),\n formattedValue: selectedNodes.map(selectedNode => selectedNode.title),\n });\n };\n\n const _handleOnSelectAll = (isSelected: boolean) => {\n const selectedNodes = isSelected ? [...smartFilterDataToDisplay] : [];\n\n onFilterChange({\n ...filter,\n value: selectedNodes.map(selectedNode => selectedNode.recordId),\n formattedValue: selectedNodes.map(selectedNode => selectedNode.title),\n withEmptyValues: isSelected,\n });\n };\n\n const _handleOnSelectEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n\n if (isLoading) {\n return (\n <DropdownContentWrapper align=\"center\">\n <KitLoader />\n </DropdownContentWrapper>\n );\n }\n\n if (error) {\n return (\n <DropdownContentWrapper>\n <ErrorDisplay message={error.message} />\n </DropdownContentWrapper>\n );\n }\n\n return (\n <DropdownContentWrapper direction=\"vertical\" size=\"xs\">\n {SearchInput}\n <ScrollableContent>\n <SelectAllCheckbox\n checked={isFullyChecked}\n indeterminate={hasAnySelection && !isFullyChecked}\n onChange={_handleOnSelectAll}\n />\n <EmptyValueCheckbox\n filter={filter}\n onSelect={_handleOnSelectEmptyValue}\n count={noValueNodeData?.count ?? 0}\n />\n <KitTreeWithGhostedNodes\n treeData={filteredSmartFilterData}\n selectedKeys={selectedNodesIds}\n checkedKeys={selectedNodesIds}\n checkable={true}\n checkStrictly={true}\n multiple={true}\n titleRender={kitTreeNode => {\n const node = kitTreeNode as EventDataNode<ISmartFilterNode>;\n return (\n <FilterTreeNodeTitle title={node.title} count={node.count ?? 0} ghosted={node.ghosted} />\n );\n }}\n onCheck={(_, info) => {\n const node = info.node as EventDataNode<ISmartFilterNode>;\n _handleOnSelect(node, info.checked);\n }}\n onSelect={(_, info) => {\n const node = info.node as EventDataNode<ISmartFilterNode>;\n _handleOnSelect(node, info.selected);\n }}\n />\n </ScrollableContent>\n </DropdownContentWrapper>\n );\n};\n"]}
@@ -0,0 +1,25 @@
1
+ import { type IUIFilterTree, type FiltersOperator, type UIFilter } from '../../../../../components/Filters/_types';
2
+ export interface ISmartFilterNode {
3
+ title: string;
4
+ key: string;
5
+ libraryId: string;
6
+ recordId: string;
7
+ count: number;
8
+ ghosted?: boolean;
9
+ }
10
+ interface IUseGetSmartFilterDataProps {
11
+ libraryId: string;
12
+ attributeId: string;
13
+ filters: UIFilter[] | IUIFilterTree[];
14
+ filtersOperator: FiltersOperator;
15
+ selectedValueIds?: string[] | null;
16
+ selectedFormattedValues?: Array<string | null> | null;
17
+ linkedLibraryId?: string;
18
+ }
19
+ export declare const useGetSmartFilterData: ({ libraryId, attributeId, filters, filtersOperator, selectedValueIds, selectedFormattedValues, linkedLibraryId, }: IUseGetSmartFilterDataProps) => {
20
+ smartFilterDataToDisplay: ISmartFilterNode[];
21
+ noValueNodeData: ISmartFilterNode;
22
+ isLoading: boolean;
23
+ error: import("@apollo/client").ApolloError;
24
+ };
25
+ export {};
@@ -0,0 +1,59 @@
1
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
2
+ // This file is released under LGPL V3
3
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
4
+ import { useSmartFilterListValuesQuery } from '../../../../../_gqlTypes';
5
+ import { prepareFiltersForRequest } from '../../../../../components/Filters/prepareFiltersForRequest';
6
+ export const useGetSmartFilterData = ({ libraryId, attributeId, filters, filtersOperator, selectedValueIds, selectedFormattedValues, linkedLibraryId, }) => {
7
+ const filtersWithoutCurrentAttributeFilter = filters.filter(filter => filter.attribute.id !== attributeId);
8
+ const preparedFilters = prepareFiltersForRequest(filtersWithoutCurrentAttributeFilter, filtersOperator, undefined);
9
+ const { data, loading, error } = useSmartFilterListValuesQuery({
10
+ variables: {
11
+ library: libraryId,
12
+ attribute: attributeId,
13
+ recordFilters: preparedFilters ?? undefined,
14
+ },
15
+ });
16
+ const occurrences = data?.listDistinctValues;
17
+ const smartFilterData = occurrences?.length
18
+ ? occurrences
19
+ .map(({ value, count }) => value !== null
20
+ ? {
21
+ key: value.id,
22
+ title: value.whoAmI.label ?? value.whoAmI.id ?? value.id,
23
+ recordId: value.whoAmI.id,
24
+ libraryId: value.whoAmI.library.id,
25
+ count,
26
+ }
27
+ : {
28
+ key: 'no_value',
29
+ title: '',
30
+ recordId: null,
31
+ libraryId: null,
32
+ count,
33
+ })
34
+ .sort((a, b) => a.title.localeCompare(b.title, undefined, { numeric: true }))
35
+ : [];
36
+ const smartFilterDataWithoutNoValue = smartFilterData.filter(node => node.key !== 'no_value');
37
+ const noValueNodeData = smartFilterData.find(node => node.key === 'no_value');
38
+ const selectedNodeIdsNotInSmartFilterData = (selectedValueIds ?? []).filter(nodeId => !smartFilterData.some(node => node.key === nodeId));
39
+ const selectedNodesNotInSmartFilterData = selectedNodeIdsNotInSmartFilterData.map(nodeId => {
40
+ const index = selectedValueIds?.indexOf(nodeId) ?? -1;
41
+ const formattedValue = index >= 0 && selectedFormattedValues?.[index] != null ? selectedFormattedValues[index] : nodeId;
42
+ return {
43
+ key: nodeId,
44
+ recordId: nodeId,
45
+ libraryId: linkedLibraryId ?? '',
46
+ title: formattedValue ?? nodeId,
47
+ count: 0,
48
+ ghosted: true,
49
+ };
50
+ });
51
+ const smartFilterDataToDisplay = [...smartFilterDataWithoutNoValue, ...selectedNodesNotInSmartFilterData];
52
+ return {
53
+ smartFilterDataToDisplay,
54
+ noValueNodeData,
55
+ isLoading: loading,
56
+ error: error ?? null,
57
+ };
58
+ };
59
+ //# sourceMappingURL=useGetSmartFilterData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetSmartFilterData.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/smart-filter/useGetSmartFilterData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,6BAA6B,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,iDAAiD,CAAC;AAsBzF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAClC,SAAS,EACT,WAAW,EACX,OAAO,EACP,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,eAAe,GACW,EAAE,EAAE;IAC9B,MAAM,oCAAoC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;IAC3G,MAAM,eAAe,GAAG,wBAAwB,CAAC,oCAAoC,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAEnH,MAAM,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,GAAG,6BAA6B,CAAC;QACzD,SAAS,EAAE;YACP,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,WAAW;YACtB,aAAa,EAAE,eAAe,IAAI,SAAS;SAC9C;KACJ,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAI,EAAE,kBAAkB,CAAC;IAE7C,MAAM,eAAe,GAAuB,WAAW,EAAE,MAAM;QAC3D,CAAC,CAAC,WAAW;aACN,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,KAAK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,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,MAAM,cAAc,GAChB,KAAK,IAAI,CAAC,IAAI,uBAAuB,EAAE,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACrG,OAAO;YACH,GAAG,EAAE,MAAM;YACX,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,eAAe,IAAI,EAAE;YAChC,KAAK,EAAE,cAAc,IAAI,MAAM;YAC/B,KAAK,EAAE,CAAC;YACR,OAAO,EAAE,IAAI;SAChB,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,MAAM,wBAAwB,GAAG,CAAC,GAAG,6BAA6B,EAAE,GAAG,iCAAiC,CAAC,CAAC;IAE1G,OAAO;QACH,wBAAwB;QACxB,eAAe;QACf,SAAS,EAAE,OAAO;QAClB,KAAK,EAAE,KAAK,IAAI,IAAI;KACvB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSmartFilterListValuesQuery} from '_ui/_gqlTypes';\nimport {prepareFiltersForRequest} from '_ui/components/Filters/prepareFiltersForRequest';\nimport {type IUIFilterTree, type FiltersOperator, type UIFilter} from '_ui/components/Filters/_types';\n\nexport interface ISmartFilterNode {\n title: string;\n key: string;\n libraryId: string;\n recordId: string;\n count: number;\n ghosted?: boolean;\n}\n\ninterface IUseGetSmartFilterDataProps {\n libraryId: string;\n attributeId: string;\n filters: UIFilter[] | IUIFilterTree[];\n filtersOperator: FiltersOperator;\n selectedValueIds?: string[] | null;\n selectedFormattedValues?: Array<string | null> | null;\n linkedLibraryId?: string;\n}\n\nexport const useGetSmartFilterData = ({\n libraryId,\n attributeId,\n filters,\n filtersOperator,\n selectedValueIds,\n selectedFormattedValues,\n linkedLibraryId,\n}: IUseGetSmartFilterDataProps) => {\n const filtersWithoutCurrentAttributeFilter = filters.filter(filter => filter.attribute.id !== attributeId);\n const preparedFilters = prepareFiltersForRequest(filtersWithoutCurrentAttributeFilter, filtersOperator, undefined);\n\n const {data, loading, error} = useSmartFilterListValuesQuery({\n variables: {\n library: libraryId,\n attribute: attributeId,\n recordFilters: preparedFilters ?? undefined,\n },\n });\n\n const occurrences = data?.listDistinctValues;\n\n const smartFilterData: ISmartFilterNode[] = occurrences?.length\n ? occurrences\n .map(({value, count}) =>\n value !== null\n ? {\n key: value.id,\n title: value.whoAmI.label ?? value.whoAmI.id ?? value.id,\n recordId: value.whoAmI.id,\n libraryId: value.whoAmI.library.id,\n count,\n }\n : {\n key: 'no_value',\n title: '',\n recordId: null,\n libraryId: null,\n count,\n },\n )\n .sort((a, b) => a.title.localeCompare(b.title, undefined, {numeric: true}))\n : [];\n\n const smartFilterDataWithoutNoValue = smartFilterData.filter(node => node.key !== 'no_value');\n const noValueNodeData = smartFilterData.find(node => node.key === 'no_value');\n\n const selectedNodeIdsNotInSmartFilterData = (selectedValueIds ?? []).filter(\n nodeId => !smartFilterData.some(node => node.key === nodeId),\n );\n const selectedNodesNotInSmartFilterData: ISmartFilterNode[] = selectedNodeIdsNotInSmartFilterData.map(nodeId => {\n const index = selectedValueIds?.indexOf(nodeId) ?? -1;\n const formattedValue =\n index >= 0 && selectedFormattedValues?.[index] != null ? selectedFormattedValues[index] : nodeId;\n return {\n key: nodeId,\n recordId: nodeId,\n libraryId: linkedLibraryId ?? '',\n title: formattedValue ?? nodeId,\n count: 0,\n ghosted: true,\n };\n });\n\n const smartFilterDataToDisplay = [...smartFilterDataWithoutNoValue, ...selectedNodesNotInSmartFilterData];\n\n return {\n smartFilterDataToDisplay,\n noValueNodeData,\n isLoading: loading,\n error: error ?? null,\n };\n};\n"]}
@@ -0,0 +1,5 @@
1
+ import { type DataNode } from 'antd/es/tree';
2
+ export declare const useSmartFilterSearch: (smartFilterData: DataNode[]) => {
3
+ filteredSmartFilterData: DataNode[];
4
+ SearchInput: JSX.Element;
5
+ };
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { KitInput } from 'aristid-ds';
6
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7
+ import { faSearch } from '@fortawesome/free-solid-svg-icons';
8
+ import { useSharedTranslation } from '../../../../../hooks/useSharedTranslation';
9
+ import { useState } from 'react';
10
+ export const useSmartFilterSearch = (smartFilterData) => {
11
+ const { t } = useSharedTranslation();
12
+ const [searchValue, setSearchValue] = useState('');
13
+ const normalizedSearch = searchValue.trim().toLowerCase();
14
+ const filteredSmartFilterData = !normalizedSearch
15
+ ? smartFilterData
16
+ : smartFilterData.filter(node => {
17
+ const title = typeof node.title === 'string' ? node.title : '';
18
+ return title.toLowerCase().includes(normalizedSearch);
19
+ });
20
+ return {
21
+ filteredSmartFilterData,
22
+ SearchInput: (_jsx(KitInput, { prefix: _jsx(FontAwesomeIcon, { icon: faSearch }), placeholder: t('global.search'), value: searchValue, onChange: e => setSearchValue(e.target.value), allowClear: true })),
23
+ };
24
+ };
25
+ //# sourceMappingURL=useSmartFilerSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSmartFilerSearch.js","sourceRoot":"","sources":["../../../../../../src/components/Filters/filter-items/filter-type/smart-filter/useSmartFilerSearch.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,eAA2B,EAAE,EAAE;IAChE,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEnD,MAAM,gBAAgB,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE1D,MAAM,uBAAuB,GAAG,CAAC,gBAAgB;QAC7C,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,KAAK,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/D,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IAET,OAAO;QACH,uBAAuB;QACvB,WAAW,EAAE,CACT,KAAC,QAAQ,IACL,MAAM,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,QAAQ,GAAI,EAC3C,WAAW,EAAE,CAAC,CAAC,eAAe,CAAC,EAC/B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC7C,UAAU,SACZ,CACL;KACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {KitInput} from 'aristid-ds';\nimport {type DataNode} from 'antd/es/tree';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faSearch} from '@fortawesome/free-solid-svg-icons';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useState} from 'react';\n\nexport const useSmartFilterSearch = (smartFilterData: DataNode[]) => {\n const {t} = useSharedTranslation();\n const [searchValue, setSearchValue] = useState('');\n\n const normalizedSearch = searchValue.trim().toLowerCase();\n\n const filteredSmartFilterData = !normalizedSearch\n ? smartFilterData\n : smartFilterData.filter(node => {\n const title = typeof node.title === 'string' ? node.title : '';\n return title.toLowerCase().includes(normalizedSearch);\n });\n\n return {\n filteredSmartFilterData,\n SearchInput: (\n <KitInput\n prefix={<FontAwesomeIcon icon={faSearch} />}\n placeholder={t('global.search')}\n value={searchValue}\n onChange={e => setSearchValue(e.target.value)}\n allowClear\n />\n ),\n };\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  import { type FunctionComponent } from 'react';
2
- import { type IFilterChildrenTreeDropDownProps } from './_types';
2
+ import { type IFilterChildrenTreeDropDownProps } from '../_types';
3
3
  export declare const TreeAttributeDropDown: FunctionComponent<IFilterChildrenTreeDropDownProps>;