@leav/ui 1.10.0 → 1.11.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.
Files changed (139) hide show
  1. package/dist/_gqlTypes/index.d.ts +14 -1
  2. package/dist/_gqlTypes/index.js +39 -15
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/_utils/index.d.ts +0 -1
  5. package/dist/_utils/index.js +0 -3
  6. package/dist/_utils/index.js.map +1 -1
  7. package/dist/components/Explorer/_queries/useExplorerCountData.js +3 -4
  8. package/dist/components/Explorer/_queries/useExplorerCountData.js.map +1 -1
  9. package/dist/components/Filters/filter-items/CommonFilterItem.js +8 -6
  10. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  11. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +6 -1
  12. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
  13. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +11 -19
  14. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
  15. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js +27 -18
  16. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
  17. package/dist/components/Notifications/InitNotificationsSubscription.d.ts +4 -2
  18. package/dist/components/Notifications/InitNotificationsSubscription.js.map +1 -1
  19. package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +1 -0
  20. package/dist/components/RecordEdition/EditRecord/EditRecord.js +2 -26
  21. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  22. package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js +2 -2
  23. package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js.map +1 -1
  24. package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +1 -19
  25. package/dist/components/RecordEdition/EditRecordContent/_types.js +0 -5
  26. package/dist/components/RecordEdition/EditRecordContent/_types.js.map +1 -1
  27. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.d.ts +0 -3
  28. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js.map +1 -1
  29. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
  30. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  31. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.d.ts +1 -2
  32. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js +7 -9
  33. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js.map +1 -1
  34. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +2 -33
  35. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
  36. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js +11 -0
  37. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js.map +1 -1
  38. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.d.ts +1 -0
  39. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js +4 -20
  40. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js.map +1 -1
  41. package/dist/components/RecordHistory/RecordHistory.d.ts +1 -0
  42. package/dist/components/RecordHistory/RecordHistory.js +3 -3
  43. package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
  44. package/dist/components/RecordHistory/RecordHistoryGoUpButton.d.ts +1 -0
  45. package/dist/components/RecordHistory/RecordHistoryGoUpButton.js +3 -3
  46. package/dist/components/RecordHistory/RecordHistoryGoUpButton.js.map +1 -1
  47. package/dist/components/RecordHistory/RecordHistoryLogEntry.js +7 -5
  48. package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
  49. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js +38 -14
  50. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js.map +1 -1
  51. package/dist/components/RecordHistory/_types.d.ts +2 -2
  52. package/dist/components/RecordHistory/_types.js.map +1 -1
  53. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.d.ts +2 -1
  54. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js +32 -4
  55. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js.map +1 -1
  56. package/dist/locales/en/shared.json +3 -31
  57. package/dist/locales/fr/shared.json +3 -31
  58. package/package.json +5 -5
  59. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.d.ts +0 -3
  60. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js +0 -2
  61. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js.map +0 -1
  62. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.d.ts +0 -1
  63. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js +0 -5
  64. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js.map +0 -1
  65. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.d.ts +0 -1
  66. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js +0 -5
  67. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js.map +0 -1
  68. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.d.ts +0 -7
  69. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js +0 -20
  70. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js.map +0 -1
  71. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.d.ts +0 -11
  72. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js +0 -35
  73. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js.map +0 -1
  74. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.d.ts +0 -2
  75. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js +0 -6
  76. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js.map +0 -1
  77. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.d.ts +0 -52
  78. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js +0 -144
  79. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js.map +0 -1
  80. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.d.ts +0 -9
  81. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js +0 -19
  82. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js.map +0 -1
  83. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.d.ts +0 -2
  84. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js +0 -6
  85. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js.map +0 -1
  86. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.d.ts +0 -5
  87. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js +0 -21
  88. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js.map +0 -1
  89. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.d.ts +0 -2
  90. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js +0 -6
  91. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js.map +0 -1
  92. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.d.ts +0 -6
  93. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js +0 -14
  94. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js.map +0 -1
  95. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.d.ts +0 -2
  96. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js +0 -6
  97. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js.map +0 -1
  98. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.d.ts +0 -9
  99. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js +0 -28
  100. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js.map +0 -1
  101. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.d.ts +0 -2
  102. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js +0 -6
  103. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js.map +0 -1
  104. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.d.ts +0 -6
  105. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js +0 -25
  106. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js.map +0 -1
  107. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.d.ts +0 -2
  108. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js +0 -6
  109. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js.map +0 -1
  110. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.d.ts +0 -7
  111. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js +0 -33
  112. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js.map +0 -1
  113. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.d.ts +0 -2
  114. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js +0 -6
  115. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js.map +0 -1
  116. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.d.ts +0 -2
  117. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js +0 -13
  118. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js.map +0 -1
  119. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.d.ts +0 -2
  120. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js +0 -6
  121. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js.map +0 -1
  122. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.d.ts +0 -10
  123. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js +0 -24
  124. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js.map +0 -1
  125. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.d.ts +0 -2
  126. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js +0 -6
  127. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js.map +0 -1
  128. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.d.ts +0 -13
  129. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +0 -41
  130. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +0 -1
  131. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.d.ts +0 -2
  132. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js +0 -6
  133. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js.map +0 -1
  134. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.d.ts +0 -8
  135. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js +0 -34
  136. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js.map +0 -1
  137. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.d.ts +0 -2
  138. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js +0 -6
  139. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js.map +0 -1
@@ -14,7 +14,6 @@ export declare const extractPermissionFromQuery: (queryResult: ReturnType<typeof
14
14
  export declare const getPreviewSize: (size?: PreviewSize, simplistic?: boolean) => "1.2rem" | "3.5rem" | "6rem" | "2.5rem" | "1.7rem" | "2rem";
15
15
  export declare const setDateToUTCNoon: (date: dayjs.Dayjs) => dayjs.Dayjs;
16
16
  export declare const getTreeRecordKey: (record: RecordIdentityFragment) => string;
17
- export declare const getValueVersionLabel: (version: IValueVersion) => string;
18
17
  export declare const stringifyDateRangeValue: (value: IDateRangeValue, t: TFunction) => string;
19
18
  /**
20
19
  * Cloning gql template tag because some apollo tools like query validation and codegen won't be happy if we use
@@ -44,9 +44,6 @@ export const getPreviewSize = (size, simplistic = false) => {
44
44
  };
45
45
  export const setDateToUTCNoon = (date) => date.set('hour', 12).set('minute', 0).set('second', 0).set('millisecond', 0);
46
46
  export const getTreeRecordKey = (record) => `${record.whoAmI.library.id}/${record.id}`;
47
- export const getValueVersionLabel = (version) => Object.values(version ?? {})
48
- .map(v => v.label)
49
- .join(' / ');
50
47
  export const stringifyDateRangeValue = (value, t) => t('record_edition.date_range_value', {
51
48
  ...value,
52
49
  interpolation: { escapeValue: false },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/_utils/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAuB,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAoB,MAAM,aAAa,CAAC;AAG9G,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAI1C,OAAO,EACH,eAAe,EACf,aAAa,GAQhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAiB,EAAE,CACjG,OAAO,EAAE,MAAM,CAAC,CAAC,GAAkB,EAAE,KAAK,EAAE,EAAE;IAC1C,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG;QAChB,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QACrB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK;KAC5C,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,CAAC,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAsB,EAAuB,EAAE,CACrF,OAAO;IACH,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,EAAE,CAAC,CAAC,IAAI;QACd,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,IAAI;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,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzG,OAAO,eAAe,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC3C,CAAC,CAAC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,cAAc,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAW,EAAE,UAAkB,EAAE,QAAgB,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC/C,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 {gql} from '@apollo/client';\nimport {type IDateRangeValue, isTypeLink, objectToNameValueArray, omit, type WithTypename} from '@leav/utils';\nimport {type TFunction} from 'i18next';\nimport {type SyntheticEvent} from 'react';\nimport {PreviewSize} from '_ui/constants';\nimport {type IAttribute} from '_ui/types/search';\nimport {type IValueVersion} from '_ui/types/values';\nimport {type IView} from '_ui/types/views';\nimport {\n AttributeFormat,\n AttributeType,\n type PermissionsActions,\n type RecordFilterInput,\n type RecordIdentityFragment,\n type useIsAllowedQuery,\n type ValueDetailsFragment,\n type ValueVersionInput,\n type ViewDetailsFragment,\n} from '_ui/_gqlTypes';\nimport {getFiltersFromRequest} from './getFiltersFromRequest';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\n\ndayjs.extend(utc);\n\nexport const arrayValueVersionToObject = (version: ValueDetailsFragment['version']): IValueVersion =>\n version?.reduce((acc: IValueVersion, value) => {\n acc[value.treeId] = {\n id: value.treeNode.id,\n label: value.treeNode.record.whoAmI.label,\n };\n\n return acc;\n }, {});\n\nexport const objectValueVersionToArray = (version: IValueVersion): ValueVersionInput[] =>\n version\n ? objectToNameValueArray(version).map(v => ({\n treeId: v.name,\n treeNodeId: v?.value?.id ?? null,\n }))\n : null;\n\nexport const extractPermissionFromQuery = (\n queryResult: ReturnType<typeof useIsAllowedQuery>,\n action: PermissionsActions,\n fallbackPermission = false,\n): boolean =>\n !queryResult.loading && !queryResult.error\n ? (queryResult.data?.isAllowed?.find(permission => permission.name === action)?.allowed ?? fallbackPermission)\n : fallbackPermission;\n\nexport const getPreviewSize = (size?: PreviewSize, simplistic = false) => {\n if (simplistic) {\n return '1.2rem';\n }\n\n switch (size) {\n case PreviewSize.MEDIUM:\n return '3.5rem';\n case PreviewSize.BIG:\n return '6rem';\n case PreviewSize.SMALL:\n return '2.5rem';\n case PreviewSize.TINY:\n return '1.7rem';\n default:\n return '2rem';\n }\n};\n\nexport const setDateToUTCNoon = (date: dayjs.Dayjs): dayjs.Dayjs =>\n date.set('hour', 12).set('minute', 0).set('second', 0).set('millisecond', 0);\n\nexport const getTreeRecordKey = (record: RecordIdentityFragment): string => `${record.whoAmI.library.id}/${record.id}`;\n\nexport const getValueVersionLabel = (version: IValueVersion) =>\n Object.values(version ?? {})\n .map(v => v.label)\n .join(' / ');\n\nexport const stringifyDateRangeValue = (value: IDateRangeValue, t: TFunction): string =>\n t('record_edition.date_range_value', {\n ...value,\n interpolation: {escapeValue: false},\n });\n\n/**\n * Cloning gql template tag because some apollo tools like query validation and codegen won't be happy if we use\n * interpolation in template strings. With a different tag name, the query won't be parsed by these tools\n * thus they won't complain about it.\n * It works exactly the same at runtime.\n */\nexport const gqlUnchecked = gql;\n\nexport const getPropertyCacheFieldName = (attributeId: string): string => `property({\"attribute\":\"${attributeId}\"})`;\n\n/**\n * Prepare view coming from the server to be used in the app\n */\nexport const prepareView = (\n view: WithTypename<ViewDetailsFragment>,\n attributes: IAttribute[],\n libraryId: string,\n userId: string,\n): IView => {\n const viewFilters: RecordFilterInput[] = (view?.filters ?? []).map(filter => ({\n ...filter,\n treeId: filter.tree?.id,\n }));\n\n const viewValuesVersions = (view?.valuesVersions ?? []).map(version => ({\n ...version,\n treeNode: {\n ...version.treeNode,\n title: version.treeNode.record.whoAmI.label,\n },\n }));\n\n return {\n ...omit(view, 'created_by', '__typename'),\n owner: view.created_by.id === userId,\n filters: getFiltersFromRequest(viewFilters, libraryId, attributes),\n sort: (view.sort ?? []).map(s => ({\n field: s.field,\n order: s.order,\n })),\n display: omit(view.display, '__typename') as ViewDetailsFragment['display'],\n valuesVersions: viewValuesVersions.reduce((versions: IValueVersion, version): IValueVersion => {\n versions[version.treeId] = {\n id: version.treeNode.id,\n label: version.treeNode.record.whoAmI.label,\n };\n\n return versions;\n }, {}),\n attributes: (view.attributes ?? []).map(attr => attr.id),\n };\n};\nexport const getAttributeFromKey = (key: string, library: string, attributes: IAttribute[]): IAttribute | undefined => {\n const splitKey = key.split('.');\n\n // Get root attribute by first key part\n const rootAttribute = attributes.find(attr => attr.library === library && attr.id === splitKey[0]);\n\n if (!rootAttribute) {\n return;\n }\n\n if (rootAttribute.type === AttributeType.simple || rootAttribute.type === AttributeType.advanced) {\n return rootAttribute;\n }\n\n if (isTypeLink(rootAttribute.type)) {\n if (splitKey[1]) {\n const linkedAttribute = attributes.find(\n attr => attr.library === rootAttribute?.linkedLibrary?.id && attr.id === splitKey[1],\n );\n\n return {...linkedAttribute, parentAttribute: {...rootAttribute, format: AttributeFormat.text}};\n }\n\n return rootAttribute;\n }\n\n if (rootAttribute.type === AttributeType.tree) {\n const [, libraryId, linkedTreeAttribute] = splitKey;\n\n if (!libraryId && !linkedTreeAttribute) {\n // Only root attribute => search on tree\n return {...rootAttribute, format: AttributeFormat.text};\n } else if (libraryId && !linkedTreeAttribute) {\n return rootAttribute;\n }\n\n const linkedAttribute = attributes.find(attr => attr.library === splitKey[1] && attr.id === splitKey[2]);\n\n return linkedAttribute;\n }\n};\n\nexport const stopEvent = (e: SyntheticEvent) => {\n e.stopPropagation();\n e.preventDefault();\n};\n\nexport const reorder = (list: any[], startIndex: number, endIndex: number) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n result.splice(endIndex, 0, removed);\n\n return result.filter(element => !!element);\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/_utils/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,GAAG,EAAC,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAuB,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAoB,MAAM,aAAa,CAAC;AAG9G,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAI1C,OAAO,EACH,eAAe,EACf,aAAa,GAQhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAiB,EAAE,CACjG,OAAO,EAAE,MAAM,CAAC,CAAC,GAAkB,EAAE,KAAK,EAAE,EAAE;IAC1C,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG;QAChB,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;QACrB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK;KAC5C,CAAC;IAEF,O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AG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAEzG,OAAO,eAAe,CAAC;IAC3B,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAiB,EAAE,EAAE;IAC3C,CAAC,CAAC,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,cAAc,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAW,EAAE,UAAkB,EAAE,QAAgB,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC/C,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 {gql} from '@apollo/client';\nimport {type IDateRangeValue, isTypeLink, objectToNameValueArray, omit, type WithTypename} from '@leav/utils';\nimport {type TFunction} from 'i18next';\nimport {type SyntheticEvent} from 'react';\nimport {PreviewSize} from '_ui/constants';\nimport {type IAttribute} from '_ui/types/search';\nimport {type IValueVersion} from '_ui/types/values';\nimport {type IView} from '_ui/types/views';\nimport {\n AttributeFormat,\n AttributeType,\n type PermissionsActions,\n type RecordFilterInput,\n type RecordIdentityFragment,\n type useIsAllowedQuery,\n type ValueDetailsFragment,\n type ValueVersionInput,\n type ViewDetailsFragment,\n} from '_ui/_gqlTypes';\nimport {getFiltersFromRequest} from './getFiltersFromRequest';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\n\ndayjs.extend(utc);\n\nexport const arrayValueVersionToObject = (version: ValueDetailsFragment['version']): IValueVersion =>\n version?.reduce((acc: IValueVersion, value) => {\n acc[value.treeId] = {\n id: value.treeNode.id,\n label: value.treeNode.record.whoAmI.label,\n };\n\n return acc;\n }, {});\n\nexport const objectValueVersionToArray = (version: IValueVersion): ValueVersionInput[] =>\n version\n ? objectToNameValueArray(version).map(v => ({\n treeId: v.name,\n treeNodeId: v?.value?.id ?? null,\n }))\n : null;\n\nexport const extractPermissionFromQuery = (\n queryResult: ReturnType<typeof useIsAllowedQuery>,\n action: PermissionsActions,\n fallbackPermission = false,\n): boolean =>\n !queryResult.loading && !queryResult.error\n ? (queryResult.data?.isAllowed?.find(permission => permission.name === action)?.allowed ?? fallbackPermission)\n : fallbackPermission;\n\nexport const getPreviewSize = (size?: PreviewSize, simplistic = false) => {\n if (simplistic) {\n return '1.2rem';\n }\n\n switch (size) {\n case PreviewSize.MEDIUM:\n return '3.5rem';\n case PreviewSize.BIG:\n return '6rem';\n case PreviewSize.SMALL:\n return '2.5rem';\n case PreviewSize.TINY:\n return '1.7rem';\n default:\n return '2rem';\n }\n};\n\nexport const setDateToUTCNoon = (date: dayjs.Dayjs): dayjs.Dayjs =>\n date.set('hour', 12).set('minute', 0).set('second', 0).set('millisecond', 0);\n\nexport const getTreeRecordKey = (record: RecordIdentityFragment): string => `${record.whoAmI.library.id}/${record.id}`;\n\nexport const stringifyDateRangeValue = (value: IDateRangeValue, t: TFunction): string =>\n t('record_edition.date_range_value', {\n ...value,\n interpolation: {escapeValue: false},\n });\n\n/**\n * Cloning gql template tag because some apollo tools like query validation and codegen won't be happy if we use\n * interpolation in template strings. With a different tag name, the query won't be parsed by these tools\n * thus they won't complain about it.\n * It works exactly the same at runtime.\n */\nexport const gqlUnchecked = gql;\n\nexport const getPropertyCacheFieldName = (attributeId: string): string => `property({\"attribute\":\"${attributeId}\"})`;\n\n/**\n * Prepare view coming from the server to be used in the app\n */\nexport const prepareView = (\n view: WithTypename<ViewDetailsFragment>,\n attributes: IAttribute[],\n libraryId: string,\n userId: string,\n): IView => {\n const viewFilters: RecordFilterInput[] = (view?.filters ?? []).map(filter => ({\n ...filter,\n treeId: filter.tree?.id,\n }));\n\n const viewValuesVersions = (view?.valuesVersions ?? []).map(version => ({\n ...version,\n treeNode: {\n ...version.treeNode,\n title: version.treeNode.record.whoAmI.label,\n },\n }));\n\n return {\n ...omit(view, 'created_by', '__typename'),\n owner: view.created_by.id === userId,\n filters: getFiltersFromRequest(viewFilters, libraryId, attributes),\n sort: (view.sort ?? []).map(s => ({\n field: s.field,\n order: s.order,\n })),\n display: omit(view.display, '__typename') as ViewDetailsFragment['display'],\n valuesVersions: viewValuesVersions.reduce((versions: IValueVersion, version): IValueVersion => {\n versions[version.treeId] = {\n id: version.treeNode.id,\n label: version.treeNode.record.whoAmI.label,\n };\n\n return versions;\n }, {}),\n attributes: (view.attributes ?? []).map(attr => attr.id),\n };\n};\nexport const getAttributeFromKey = (key: string, library: string, attributes: IAttribute[]): IAttribute | undefined => {\n const splitKey = key.split('.');\n\n // Get root attribute by first key part\n const rootAttribute = attributes.find(attr => attr.library === library && attr.id === splitKey[0]);\n\n if (!rootAttribute) {\n return;\n }\n\n if (rootAttribute.type === AttributeType.simple || rootAttribute.type === AttributeType.advanced) {\n return rootAttribute;\n }\n\n if (isTypeLink(rootAttribute.type)) {\n if (splitKey[1]) {\n const linkedAttribute = attributes.find(\n attr => attr.library === rootAttribute?.linkedLibrary?.id && attr.id === splitKey[1],\n );\n\n return {...linkedAttribute, parentAttribute: {...rootAttribute, format: AttributeFormat.text}};\n }\n\n return rootAttribute;\n }\n\n if (rootAttribute.type === AttributeType.tree) {\n const [, libraryId, linkedTreeAttribute] = splitKey;\n\n if (!libraryId && !linkedTreeAttribute) {\n // Only root attribute => search on tree\n return {...rootAttribute, format: AttributeFormat.text};\n } else if (libraryId && !linkedTreeAttribute) {\n return rootAttribute;\n }\n\n const linkedAttribute = attributes.find(attr => attr.library === splitKey[1] && attr.id === splitKey[2]);\n\n return linkedAttribute;\n }\n};\n\nexport const stopEvent = (e: SyntheticEvent) => {\n e.stopPropagation();\n e.preventDefault();\n};\n\nexport const reorder = (list: any[], startIndex: number, endIndex: number) => {\n const result = Array.from(list);\n const [removed] = result.splice(startIndex, 1);\n result.splice(endIndex, 0, removed);\n\n return result.filter(element => !!element);\n};\n"]}
@@ -6,15 +6,14 @@ import { prepareFiltersForRequest } from '../../../components/Filters';
6
6
  import { useMemo } from 'react';
7
7
  export const useExplorerCountData = ({ entrypoint, libraryId, defaultFilters, filters, skip, }) => {
8
8
  const isLibrary = entrypoint.type === 'library';
9
- const activeFilters = prepareFiltersForRequest(filters.filter(f => f.field === 'active'));
10
- const defaultPreparedFilters = prepareFiltersForRequest(defaultFilters);
11
- const appliedFilters = [...activeFilters, ...defaultPreparedFilters];
9
+ const activeFilter = filters.find(f => f.field === 'active');
10
+ const preparedFilters = prepareFiltersForRequest(activeFilter ? [...defaultFilters, activeFilter] : defaultFilters);
12
11
  const { data: countData, refetch: refetchCount } = useExplorerLibraryCountDataQuery({
13
12
  fetchPolicy: 'network-only',
14
13
  skip: skip || !isLibrary,
15
14
  variables: {
16
15
  libraryId,
17
- filters: appliedFilters,
16
+ filters: preparedFilters,
18
17
  },
19
18
  });
20
19
  const memoizedCountData = useMemo(() => countData?.records?.totalCount ?? 0, [countData]);
@@ -1 +1 @@
1
- {"version":3,"file":"useExplorerCountData.js","sourceRoot":"","sources":["../../../../src/components/Explorer/_queries/useExplorerCountData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,gCAAgC,EAAC,MAAM,eAAe,CAAC;AACvF,OAAO,EAAgB,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,EACP,IAAI,GAOP,EAAE,EAAE;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC;IAChD,MAAM,aAAa,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;IAC1F,MAAM,sBAAsB,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAAC;IAExE,MAAM,cAAc,GAAwB,CAAC,GAAG,aAAa,EAAE,GAAG,sBAAsB,CAAC,CAAC;IAE1F,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAC,GAAG,gCAAgC,CAAC;QAC9E,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,IAAI,IAAI,CAAC,SAAS;QACxB,SAAS,EAAE;YACP,SAAS;YACT,OAAO,EAAE,cAAc;SAC1B;KACJ,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAE1F,OAAO;QACH,SAAS,EAAE,iBAAiB;QAC5B,YAAY;KACf,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 RecordFilterInput, useExplorerLibraryCountDataQuery} from '_ui/_gqlTypes';\nimport {type UIFilter, prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type Entrypoint} from '../_types';\nimport {useMemo} from 'react';\n\nexport const useExplorerCountData = ({\n entrypoint,\n libraryId,\n defaultFilters,\n filters,\n skip,\n}: {\n entrypoint: Entrypoint;\n libraryId: string;\n defaultFilters: UIFilter[];\n filters: UIFilter[];\n skip?: boolean;\n}) => {\n const isLibrary = entrypoint.type === 'library';\n const activeFilters = prepareFiltersForRequest(filters.filter(f => f.field === 'active'));\n const defaultPreparedFilters = prepareFiltersForRequest(defaultFilters);\n\n const appliedFilters: RecordFilterInput[] = [...activeFilters, ...defaultPreparedFilters];\n\n const {data: countData, refetch: refetchCount} = useExplorerLibraryCountDataQuery({\n fetchPolicy: 'network-only',\n skip: skip || !isLibrary,\n variables: {\n libraryId,\n filters: appliedFilters,\n },\n });\n\n const memoizedCountData = useMemo(() => countData?.records?.totalCount ?? 0, [countData]);\n\n return {\n countData: memoizedCountData,\n refetchCount,\n };\n};\n"]}
1
+ {"version":3,"file":"useExplorerCountData.js","sourceRoot":"","sources":["../../../../src/components/Explorer/_queries/useExplorerCountData.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,gCAAgC,EAAC,MAAM,eAAe,CAAC;AACvF,OAAO,EAAgB,wBAAwB,EAAC,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,UAAU,EACV,SAAS,EACT,cAAc,EACd,OAAO,EACP,IAAI,GAOP,EAAE,EAAE;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC;IAChD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;IAC7D,MAAM,eAAe,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAEpH,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAC,GAAG,gCAAgC,CAAC;QAC9E,WAAW,EAAE,cAAc;QAC3B,IAAI,EAAE,IAAI,IAAI,CAAC,SAAS;QACxB,SAAS,EAAE;YACP,SAAS;YACT,OAAO,EAAE,eAAe;SAC3B;KACJ,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAE1F,OAAO;QACH,SAAS,EAAE,iBAAiB;QAC5B,YAAY;KACf,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 RecordFilterInput, useExplorerLibraryCountDataQuery} from '_ui/_gqlTypes';\nimport {type UIFilter, prepareFiltersForRequest} from '_ui/components/Filters';\nimport {type Entrypoint} from '../_types';\nimport {useMemo} from 'react';\n\nexport const useExplorerCountData = ({\n entrypoint,\n libraryId,\n defaultFilters,\n filters,\n skip,\n}: {\n entrypoint: Entrypoint;\n libraryId: string;\n defaultFilters: UIFilter[];\n filters: UIFilter[];\n skip?: boolean;\n}) => {\n const isLibrary = entrypoint.type === 'library';\n const activeFilter = filters.find(f => f.field === 'active');\n const preparedFilters = prepareFiltersForRequest(activeFilter ? [...defaultFilters, activeFilter] : defaultFilters);\n\n const {data: countData, refetch: refetchCount} = useExplorerLibraryCountDataQuery({\n fetchPolicy: 'network-only',\n skip: skip || !isLibrary,\n variables: {\n libraryId,\n filters: preparedFilters,\n },\n });\n\n const memoizedCountData = useMemo(() => countData?.records?.totalCount ?? 0, [countData]);\n\n return {\n countData: memoizedCountData,\n refetchCount,\n };\n};\n"]}
@@ -24,13 +24,15 @@ const getFilterValues = (filter, t) => {
24
24
  [AttributeFormat.date, AttributeFormat.boolean].includes(filter.attribute.format)) {
25
25
  return filter.formattedValue ? [...filterValues, filter.formattedValue] : filterValues;
26
26
  }
27
- if (Array.isArray(filter.value)) {
28
- return [...filterValues, ...filter.value];
27
+ const valuesList = filter.attribute.valuesList;
28
+ if (!valuesList || !('linkedValues' in valuesList) || !filter.value) {
29
+ return filterValues;
29
30
  }
30
- else if (filter.value) {
31
- return [...filterValues, filter.value];
32
- }
33
- return filterValues;
31
+ const valuesFilter = Array.isArray(filter.value) ? filter.value : [filter.value];
32
+ const labels = (valuesList.linkedValues ?? [])
33
+ .filter(val => valuesFilter.includes(val?.id))
34
+ .map(val => val?.whoAmI?.label ?? '');
35
+ return [...filterValues, ...labels];
34
36
  };
35
37
  const isActiveAttribute = (filter) => filter.attribute.format === AttributeFormat.boolean &&
36
38
  filter.attribute.id === ACTIVE_ATTRIBUTE_ID &&
@@ -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,EACH,kBAAkB,EAClB,cAAc,EACd,yBAAyB,GAG5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;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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
+ {"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,EACH,kBAAkB,EAClB,cAAc,EACd,yBAAyB,GAG5B,MAAM,WAAW,CAAC;AACnB,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,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AAE,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 const valuesList = filter.attribute.valuesList;\n if (!valuesList || !('linkedValues' in valuesList) || !filter.value) {\n return filterValues;\n }\n\n const valuesFilter = Array.isArray(filter.value) ? filter.value : [filter.value];\n const labels = (valuesList.linkedValues ?? [])\n .filter(val => valuesFilter.includes(val?.id))\n .map(val => val?.whoAmI?.label ?? '');\n return [...filterValues, ...labels];\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"]}
@@ -10,6 +10,11 @@ const TreeNodeTitleContainer = styled.div `
10
10
  align-items: center;
11
11
  justify-content: space-between;
12
12
  `;
13
+ const KitTreeStyled = styled(KitTree) `
14
+ .ant-tree-title {
15
+ width: 100% !important;
16
+ }
17
+ `;
13
18
  const CheckIcon = styled(FontAwesomeIcon) `
14
19
  color: var(--general-utilities-text-blue);
15
20
  font-size: calc(var(--general-typography-fontSize7) * 1px);
@@ -44,6 +49,6 @@ export const BooleanAttributeDropDown = ({ filter, onFilterChange }) => {
44
49
  },
45
50
  ];
46
51
  const TreeNodeTitle = ({ node }) => (_jsxs(TreeNodeTitleContainer, { children: [_jsx(KitTypography.Text, { size: "fontSize5", children: node.title }), node.key === filter.value && _jsx(CheckIcon, { icon: faCheck })] }));
47
- return (_jsx(KitTree, { treeData: valuesOptions, selectedKeys: [filter.value], titleRender: node => _jsx(TreeNodeTitle, { node: node }), onSelect: _onSelectionChanged }));
52
+ return (_jsx(KitTreeStyled, { treeData: valuesOptions, selectedKeys: [filter.value], titleRender: node => _jsx(TreeNodeTitle, { node: node }), onSelect: _onSelectionChanged }));
48
53
  };
49
54
  //# sourceMappingURL=BooleanAttributeDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BooleanAttributeDropdown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,OAAO,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAClD,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIxC,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;;;CAGxC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAoD,CAAC,EAAC,MAAM,EAAE,cAAc,EAAC,EAAE,EAAE;IAClH,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,mBAAmB,GAA+C,MAAM,CAAC,EAAE;QAC7E,MAAM,KAAK,GAAG,MA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E,mBAAmB,GAC/B,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 ComponentProps, type FunctionComponent} from 'react';\nimport {KitTree, KitTypography} from 'aristid-ds';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {type ITreeMapElement} from '_ui/components/SelectTreeNode/_types';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faCheck} from '@fortawesome/free-solid-svg-icons';\nimport styled from 'styled-components';\n\nconst TreeNodeTitleContainer = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n\nconst CheckIcon = styled(FontAwesomeIcon)`\n color: var(--general-utilities-text-blue);\n font-size: calc(var(--general-typography-fontSize7) * 1px);\n`;\n\nexport const BooleanAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({filter, onFilterChange}) => {\n const {t} = useSharedTranslation();\n\n const _onSelectionChanged: ComponentProps<typeof KitTree>['onSelect'] = values => {\n const value = values[0] ? String(values[0]) : undefined;\n\n const filterData =\n value === undefined\n ? {\n ...filter,\n condition: null,\n value: null,\n formattedValue: undefined,\n }\n : {\n ...filter,\n condition: AttributeConditionFilter.EQUAL,\n value,\n formattedValue: value === 'true' ? t('explorer.true') : t('explorer.false'),\n };\n\n onFilterChange(filterData);\n };\n\n const valuesOptions = [\n {\n title: t('explorer.true'),\n key: 'true',\n },\n {\n title: t('explorer.false'),\n key: 'false',\n },\n ];\n\n const TreeNodeTitle = ({node}: {node: ITreeMapElement}) => (\n <TreeNodeTitleContainer>\n <KitTypography.Text size=\"fontSize5\">{node.title}</KitTypography.Text>\n {node.key === filter.value && <CheckIcon icon={faCheck} />}\n </TreeNodeTitleContainer>\n );\n\n return (\n <KitTree\n treeData={valuesOptions}\n selectedKeys={[filter.value]}\n titleRender={node => <TreeNodeTitle node={node as ITreeMapElement} />}\n onSelect={_onSelectionChanged}\n />\n );\n};\n"]}
1
+ {"version":3,"file":"BooleanAttributeDropdown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,OAAO,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAClD,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAC1D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIxC,CAAC;AAEF,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;;;;CAIpC,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;;;CAGxC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAoD,CAAC,EAAC,MAAM,EAAE,cAAc,EAAC,EAAE,EAAE;IAClH,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,mBAAmB,GAA+C,MAAM,CAAC,EAAE;QAC7E,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAExD,MAAM,UAAU,GACZ,KAAK,KAAK,SAAS;YACf,CAAC,CAAC;gBACI,GAAG,MAAM;gBACT,SAAS,EAAE,IAAI;gBACf,KAAK,EAAE,IAAI;gBACX,cAAc,EAAE,SAAS;aAC5B;YACH,CAAC,CAAC;gBACI,GAAG,MAAM;gBACT,SAAS,EAAE,wBAAwB,CAAC,KAAK;gBACzC,KAAK;gBACL,cAAc,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;aAC9E,CAAC;QAEZ,cAAc,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG;QAClB;YACI,KAAK,EAAE,CAAC,CAAC,eAAe,CAAC;YACzB,GAAG,EAAE,MAAM;SACd;QACD;YACI,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC;YAC1B,GAAG,EAAE,OAAO;SACf;KACJ,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,EAAC,IAAI,EAA0B,EAAE,EAAE,CAAC,CACvD,MAAC,sBAAsB,eACnB,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAAE,IAAI,CAAC,KAAK,GAAsB,EACrE,IAAI,CAAC,GAAG,KAAK,MAAM,CAAC,KAAK,IAAI,KAAC,SAAS,IAAC,IAAI,EAAE,OAAO,GAAI,IACrC,CAC5B,CAAC;IAEF,OAAO,CACH,KAAC,aAAa,IACV,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5B,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,KAAC,aAAa,IAAC,IAAI,EAAE,IAAuB,GAAI,EACrE,QAAQ,EAAE,mBAAmB,GAC/B,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 ComponentProps, type FunctionComponent} from 'react';\nimport {KitTree, KitTypography} from 'aristid-ds';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {type ITreeMapElement} from '_ui/components/SelectTreeNode/_types';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faCheck} from '@fortawesome/free-solid-svg-icons';\nimport styled from 'styled-components';\n\nconst TreeNodeTitleContainer = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\n\nconst KitTreeStyled = styled(KitTree)`\n .ant-tree-title {\n width: 100% !important;\n }\n`;\n\nconst CheckIcon = styled(FontAwesomeIcon)`\n color: var(--general-utilities-text-blue);\n font-size: calc(var(--general-typography-fontSize7) * 1px);\n`;\n\nexport const BooleanAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({filter, onFilterChange}) => {\n const {t} = useSharedTranslation();\n\n const _onSelectionChanged: ComponentProps<typeof KitTree>['onSelect'] = values => {\n const value = values[0] ? String(values[0]) : undefined;\n\n const filterData =\n value === undefined\n ? {\n ...filter,\n condition: null,\n value: null,\n formattedValue: undefined,\n }\n : {\n ...filter,\n condition: AttributeConditionFilter.EQUAL,\n value,\n formattedValue: value === 'true' ? t('explorer.true') : t('explorer.false'),\n };\n\n onFilterChange(filterData);\n };\n\n const valuesOptions = [\n {\n title: t('explorer.true'),\n key: 'true',\n },\n {\n title: t('explorer.false'),\n key: 'false',\n },\n ];\n\n const TreeNodeTitle = ({node}: {node: ITreeMapElement}) => (\n <TreeNodeTitleContainer>\n <KitTypography.Text size=\"fontSize5\">{node.title}</KitTypography.Text>\n {node.key === filter.value && <CheckIcon icon={faCheck} />}\n </TreeNodeTitleContainer>\n );\n\n return (\n <KitTreeStyled\n treeData={valuesOptions}\n selectedKeys={[filter.value]}\n titleRender={node => <TreeNodeTitle node={node as ITreeMapElement} />}\n onSelect={_onSelectionChanged}\n />\n );\n};\n"]}
@@ -1,15 +1,15 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
5
  import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
6
6
  import { useMemo, useState } from 'react';
7
- import { KitInput } from 'aristid-ds';
7
+ import { KitCheckbox, KitInput } from 'aristid-ds';
8
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, faSearch } from '@fortawesome/free-solid-svg-icons';
12
+ import { faSearch } from '@fortawesome/free-solid-svg-icons';
13
13
  import { EmptyValueCheckbox } from '../shared/EmptyValueCheckbox';
14
14
  const ListDivStyled = styled.div `
15
15
  display: flex;
@@ -20,29 +20,17 @@ const OptionRow = styled.div `
20
20
  display: flex;
21
21
  align-items: center;
22
22
  justify-content: space-between;
23
- padding: 0 calc(var(--general-spacing-xs) * 1px);
23
+ padding: 0 calc(var(--general-spacing-s) * 1px);
24
24
  height: 36px;
25
+ border: 1px solid transparent;
25
26
  border-radius: calc(var(--general-spacing-xs) * 1px);
26
27
  cursor: pointer;
27
28
  background: ${props => (props.$selected ? 'var(--general-utilities-main-light)' : 'transparent')};
28
29
  color: var(--general-utilities-text-primary);
29
-
30
30
  &:hover {
31
- background: var(--general-utilities-main-light);
31
+ border: 1px solid var(--general-utilities-main-default);
32
32
  }
33
33
  `;
34
- const RightIcon = styled(FontAwesomeIcon) `
35
- color: var(--general-utilities-main-default);
36
- opacity: ${props => (props.$visible ? 1 : 0)};
37
- transition: opacity 0.12s ease-in-out;
38
- `;
39
- const Label = styled.div `
40
- flex: 1;
41
- min-width: 0; /* allow flex child to shrink for ellipsis */
42
- overflow: hidden;
43
- white-space: nowrap;
44
- text-overflow: ellipsis;
45
- `;
46
34
  export const FilterValueListDropDown = ({ filter, onFilterChange }) => {
47
35
  const { t } = useSharedTranslation();
48
36
  const [searchText, setSearchText] = useState('');
@@ -117,9 +105,13 @@ export const FilterValueListDropDown = ({ filter, onFilterChange }) => {
117
105
  _handleToggle(value);
118
106
  }
119
107
  };
108
+ const onClickOptionRow = (e, value) => {
109
+ e.preventDefault();
110
+ _handleToggle(value);
111
+ };
120
112
  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
113
  const selected = isChecked(opt.value);
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));
114
+ return (_jsx(OptionRow, { "$selected": selected, role: "button", "aria-pressed": selected, tabIndex: 0, onClick: e => onClickOptionRow(e, opt.value), onKeyDown: e => onKeyToggle(e, opt.value), children: _jsx(KitCheckbox, { checked: selected, "aria-label": opt.label, children: opt.label }) }, opt.value));
123
115
  }) })] }));
124
116
  };
125
117
  //# 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,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BACN,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
+ {"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,EAA8D,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACrG,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACjD,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,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAC3D,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;;;;;;;;;kBAShC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAA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AC,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,KAAC,SAAS,iBAEK,QAAQ,EACnB,IAAI,EAAC,QAAQ,kBACC,QAAQ,EACtB,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,EAC5C,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,YAEzC,KAAC,WAAW,IAAC,OAAO,EAAE,QAAQ,gBAAc,GAAG,CAAC,KAAK,YAChD,GAAG,CAAC,KAAK,GACA,IAVT,GAAG,CAAC,KAAK,CAWN,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, type MouseEvent, useMemo, useState} from 'react';\nimport {KitCheckbox, 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 {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-s) * 1px);\n height: 36px;\n border: 1px solid transparent;\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 &:hover {\n border: 1px solid var(--general-utilities-main-default);\n }\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<HTMLElement>, value: string) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n _handleToggle(value);\n }\n };\n\n const onClickOptionRow = (e: MouseEvent<HTMLDivElement>, value: string) => {\n e.preventDefault();\n _handleToggle(value);\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={e => onClickOptionRow(e, opt.value)}\n onKeyDown={e => onKeyToggle(e, opt.value)}\n >\n <KitCheckbox checked={selected} aria-label={opt.label}>\n {opt.label}\n </KitCheckbox>\n </OptionRow>\n );\n })}\n </ListDivStyled>\n </>\n );\n};\n"]}
@@ -2,41 +2,50 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
3
  // This file is released under LGPL V3
4
4
  // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
- import { useEffect, useState } from 'react';
5
+ import { useEffect, useRef, useState } from 'react';
6
6
  import styled from 'styled-components';
7
7
  import { KitInput, KitSelect } from 'aristid-ds';
8
8
  import { AttributeConditionFilter } from '../../../../types';
9
9
  import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
10
10
  import { useConditionsOptionsByType } from './useConditionOptionsByType';
11
- import { useDebouncedValue } from '../../../../hooks/useDebouncedValue';
12
11
  const InputStyled = styled(KitInput) `
13
12
  width: 100%;
14
13
  `;
14
+ const DEBOUNCE_DELAY = 300;
15
+ const MIN_SEARCH_LENGTH = 3;
15
16
  export const TextAttributeDropDown = ({ filter, onFilterChange, selectDropDownRef, }) => {
16
17
  const { t } = useSharedTranslation();
17
18
  const { conditionOptionsByType } = useConditionsOptionsByType(filter);
18
- const [inputValue, setInputValue] = useState(filter.value || '');
19
- const debouncedInputValue = useDebouncedValue(inputValue, 300);
19
+ // Local state drives the input display, decoupled from filter.value which only updates after MIN_SEARCH_LENGTH chars
20
+ const [inputValue, setInputValue] = useState(filter.value ?? '');
21
+ // Ref to the pending debounce timer so we can cancel it on external resets
22
+ const debounceTimerRef = useRef(null);
20
23
  useEffect(() => {
21
- setInputValue(filter.value || '');
22
- }, [filter.value]);
23
- // Only apply onFilterChange when the input is empty or there are more than 2 characters
24
- useEffect(() => {
25
- const valueToApply = debouncedInputValue;
26
- if (valueToApply.length === 0 && filter.value !== null) {
27
- onFilterChange({ ...filter, value: null });
28
- return;
29
- }
30
- if (valueToApply.length >= 3 && filter.value !== valueToApply) {
31
- onFilterChange({ ...filter, value: valueToApply });
24
+ // When filter.value is reset externally (e.g. RESET_FILTER), cancel any pending debounce first
25
+ // to prevent it from dispatching a stale value that would overwrite the reset
26
+ if (debounceTimerRef.current) {
27
+ clearTimeout(debounceTimerRef.current);
32
28
  }
33
- }, [debouncedInputValue, onFilterChange, filter]);
29
+ setInputValue(filter.value ?? '');
30
+ }, [filter.value]);
34
31
  const _onConditionChanged = condition => {
35
32
  onFilterChange({ ...filter, condition });
36
33
  };
37
34
  const _onInputChanged = event => {
38
- const newInputValue = event.target.value;
39
- setInputValue(newInputValue);
35
+ const newValue = event.target.value;
36
+ setInputValue(newValue);
37
+ if (debounceTimerRef.current) {
38
+ clearTimeout(debounceTimerRef.current);
39
+ }
40
+ if (newValue.length === 0) {
41
+ onFilterChange({ ...filter, value: null });
42
+ return;
43
+ }
44
+ if (newValue.length >= MIN_SEARCH_LENGTH) {
45
+ debounceTimerRef.current = setTimeout(() => {
46
+ onFilterChange({ ...filter, value: newValue });
47
+ }, DEBOUNCE_DELAY);
48
+ }
40
49
  };
41
50
  const showSearch = filter.condition !== AttributeConditionFilter.IS_EMPTY &&
42
51
  filter.condition !== AttributeConditionFilter.IS_NOT_EMPTY;
@@ -1 +1 @@
1
- {"version":3,"file":"TextAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TextAttributeDropDown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8C,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAE9D,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;CAEnC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAoD,CAAC,EACnF,MAAM,EACN,cAAc,EACd,iBAAiB,GACpB,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,EAAC,sBAAsB,EAAC,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACpE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,IA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O,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,gBACxD,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,GACpD,EACD,UAAU,IAAI,CACX,KAAC,WAAW,IACR,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAC/C,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,eAAe,GAC3B,CACL,IACF,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 {type ComponentProps, type FunctionComponent, useEffect, useState} from 'react';\nimport styled from 'styled-components';\nimport {KitInput, KitSelect} from 'aristid-ds';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {useConditionsOptionsByType} from './useConditionOptionsByType';\nimport {useDebouncedValue} from '_ui/hooks/useDebouncedValue';\n\nconst InputStyled = styled(KitInput)`\n width: 100%;\n`;\n\nexport const TextAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({\n filter,\n onFilterChange,\n selectDropDownRef,\n}) => {\n const {t} = useSharedTranslation();\n\n const {conditionOptionsByType} = useConditionsOptionsByType(filter);\n const [inputValue, setInputValue] = useState(filter.value || '');\n const debouncedInputValue = useDebouncedValue(inputValue, 300);\n\n useEffect(() => {\n setInputValue(filter.value || '');\n }, [filter.value]);\n\n // Only apply onFilterChange when the input is empty or there are more than 2 characters\n useEffect(() => {\n const valueToApply = debouncedInputValue;\n\n if (valueToApply.length === 0 && filter.value !== null) {\n onFilterChange({...filter, value: null});\n return;\n }\n\n if (valueToApply.length >= 3 && filter.value !== valueToApply) {\n onFilterChange({...filter, value: valueToApply});\n }\n }, [debouncedInputValue, onFilterChange, filter]);\n\n const _onConditionChanged: ComponentProps<typeof KitSelect>['onChange'] = condition => {\n onFilterChange({...filter, condition});\n };\n\n const _onInputChanged: ComponentProps<typeof KitInput>['onChange'] = event => {\n const newInputValue = event.target.value;\n setInputValue(newInputValue);\n };\n\n const showSearch =\n filter.condition !== AttributeConditionFilter.IS_EMPTY &&\n filter.condition !== AttributeConditionFilter.IS_NOT_EMPTY;\n\n return (\n <>\n <KitSelect\n options={conditionOptionsByType}\n onChange={_onConditionChanged}\n value={filter.condition}\n getPopupContainer={() => selectDropDownRef?.current ?? document.body}\n aria-label={String(t('explorer.filter-condition'))}\n />\n {showSearch && (\n <InputStyled\n placeholder={String(t('explorer.type-a-value'))}\n value={inputValue}\n onChange={_onInputChanged}\n />\n )}\n </>\n );\n};\n"]}
1
+ {"version":3,"file":"TextAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/filter-items/filter-type/TextAttributeDropDown.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA8C,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/F,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,wBAAwB,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAEvE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;;CAEnC,CAAC;AAEF,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,MAAM,CAAC,MA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AAI,QAAQ,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACvC,gBAAgB,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBACvC,cAAc,CAAC,EAAC,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAC,CAAC,CAAC;YACjD,CAAC,EAAE,cAAc,CAAC,CAAC;QACvB,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,UAAU,GACZ,MAAM,CAAC,SAAS,KAAK,wBAAwB,CAAC,QAAQ;QACtD,MAAM,CAAC,SAAS,KAAK,wBAAwB,CAAC,YAAY,CAAC;IAE/D,OAAO,CACH,8BACI,KAAC,SAAS,IACN,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,MAAM,CAAC,SAAS,EACvB,iBAAiB,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,gBACxD,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,GACpD,EACD,UAAU,IAAI,CACX,KAAC,WAAW,IACR,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAC/C,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,eAAe,GAC3B,CACL,IACF,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 {type ComponentProps, type FunctionComponent, useEffect, useRef, useState} from 'react';\nimport styled from 'styled-components';\nimport {KitInput, KitSelect} from 'aristid-ds';\nimport {AttributeConditionFilter} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IFilterChildrenDropDownProps} from './_types';\nimport {useConditionsOptionsByType} from './useConditionOptionsByType';\n\nconst InputStyled = styled(KitInput)`\n width: 100%;\n`;\n\nconst DEBOUNCE_DELAY = 300;\nconst MIN_SEARCH_LENGTH = 3;\n\nexport const TextAttributeDropDown: FunctionComponent<IFilterChildrenDropDownProps> = ({\n filter,\n onFilterChange,\n selectDropDownRef,\n}) => {\n const {t} = useSharedTranslation();\n const {conditionOptionsByType} = useConditionsOptionsByType(filter);\n // Local state drives the input display, decoupled from filter.value which only updates after MIN_SEARCH_LENGTH chars\n const [inputValue, setInputValue] = useState(filter.value ?? '');\n // Ref to the pending debounce timer so we can cancel it on external resets\n const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n // When filter.value is reset externally (e.g. RESET_FILTER), cancel any pending debounce first\n // to prevent it from dispatching a stale value that would overwrite the reset\n if (debounceTimerRef.current) {\n clearTimeout(debounceTimerRef.current);\n }\n setInputValue(filter.value ?? '');\n }, [filter.value]);\n\n const _onConditionChanged: ComponentProps<typeof KitSelect>['onChange'] = condition => {\n onFilterChange({...filter, condition});\n };\n\n const _onInputChanged: ComponentProps<typeof KitInput>['onChange'] = event => {\n const newValue = event.target.value;\n setInputValue(newValue);\n\n if (debounceTimerRef.current) {\n clearTimeout(debounceTimerRef.current);\n }\n\n if (newValue.length === 0) {\n onFilterChange({...filter, value: null});\n return;\n }\n\n if (newValue.length >= MIN_SEARCH_LENGTH) {\n debounceTimerRef.current = setTimeout(() => {\n onFilterChange({...filter, value: newValue});\n }, DEBOUNCE_DELAY);\n }\n };\n\n const showSearch =\n filter.condition !== AttributeConditionFilter.IS_EMPTY &&\n filter.condition !== AttributeConditionFilter.IS_NOT_EMPTY;\n\n return (\n <>\n <KitSelect\n options={conditionOptionsByType}\n onChange={_onConditionChanged}\n value={filter.condition}\n getPopupContainer={() => selectDropDownRef?.current ?? document.body}\n aria-label={String(t('explorer.filter-condition'))}\n />\n {showSearch && (\n <InputStyled\n placeholder={String(t('explorer.type-a-value'))}\n value={inputValue}\n onChange={_onInputChanged}\n />\n )}\n </>\n );\n};\n"]}
@@ -1,2 +1,4 @@
1
- import { type FunctionComponent } from 'react';
2
- export declare const InitNotificationsSubscription: FunctionComponent;
1
+ import { type ReactNode } from 'react';
2
+ export declare const InitNotificationsSubscription: ({ children }: {
3
+ children: ReactNode;
4
+ }) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"InitNotificationsSubscription.js","sourceRoot":"","sources":["../../../src/components/Notifications/InitNotificationsSubscription.tsx"],"names":[],"mappings":";AAIA,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAE/E,MAAM,CAAC,MAAM,6BAA6B,GAAsB,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAE;IAC3E,4BAA4B,EAAE,CAAC;IAE/B,OAAO,4BAAG,QAAQ,GAAI,CAAC;AAC3B,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 useNotificationsSubscription from './hooks/useNotificationSubscription';\n\nexport const InitNotificationsSubscription: FunctionComponent = ({children}) => {\n useNotificationsSubscription();\n\n return <>{children}</>;\n};\n"]}
1
+ {"version":3,"file":"InitNotificationsSubscription.js","sourceRoot":"","sources":["../../../src/components/Notifications/InitNotificationsSubscription.tsx"],"names":[],"mappings":";AAIA,OAAO,4BAA4B,MAAM,qCAAqC,CAAC;AAE/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAAC,QAAQ,EAAwB,EAAE,EAAE;IAC/E,4BAA4B,EAAE,CAAC;IAE/B,OAAO,4BAAG,QAAQ,GAAI,CAAC;AAC3B,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 ReactNode} from 'react';\nimport useNotificationsSubscription from './hooks/useNotificationSubscription';\n\nexport const InitNotificationsSubscription = ({children}: {children: ReactNode}) => {\n useNotificationsSubscription();\n\n return <>{children}</>;\n};\n"]}
@@ -13,6 +13,7 @@ interface IEditRecordProps {
13
13
  onCreate?: (newRecord: RecordIdentityFragment['whoAmI']) => void;
14
14
  valuesVersion?: IValueVersion;
15
15
  showSidebar?: boolean;
16
+ scrollAllRecordSummary?: boolean;
16
17
  enableSidebar?: boolean;
17
18
  sidebarContainer?: HTMLElement;
18
19
  forceDisableSidebarInAppStudio?: boolean;
@@ -34,7 +34,7 @@ const Content = styled.div `
34
34
  overflow-y: scroll;
35
35
  border-right: ${props => props.$shouldUseLayoutWithSidebar ? '1px solid var(--general-utilities-border)' : 'none'};
36
36
  `;
37
- export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId, record, library: libraryId, onCreate, valuesVersion, enableSidebar = false, showSidebar = false, sidebarContainer, forceDisableSidebarInAppStudio = false, containerStyle, withInfoButton, removePadding = false, }) => {
37
+ export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId, record, library: libraryId, onCreate, valuesVersion, enableSidebar = false, showSidebar = false, scrollAllRecordSummary = false, sidebarContainer, forceDisableSidebarInAppStudio = false, containerStyle, withInfoButton, removePadding = false, }) => {
38
38
  const [state, dispatch] = useReducer(editRecordReducer, {
39
39
  ...initialState,
40
40
  record,
@@ -98,30 +98,6 @@ export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId
98
98
  }
99
99
  return savableValue;
100
100
  }), version, true);
101
- const _handleMetadataSubmit = (value, attribute, metadata) => {
102
- let valueContent;
103
- switch (attribute.type) {
104
- case AttributeType.simple:
105
- case AttributeType.advanced:
106
- valueContent = value.raw_payload;
107
- break;
108
- case AttributeType.advanced_link:
109
- case AttributeType.simple_link:
110
- valueContent = value.linkValue;
111
- break;
112
- case AttributeType.tree:
113
- valueContent = value.treeValue;
114
- break;
115
- }
116
- return _handleValueSubmit([
117
- {
118
- idValue: value.id_value,
119
- attribute,
120
- value: valueContent,
121
- metadata,
122
- },
123
- ], null);
124
- };
125
101
  /**
126
102
  * Submit the whole record: create record and batch save all stored values
127
103
  */
@@ -162,6 +138,6 @@ export const EditRecord = ({ antdForm, formId, isFormCreationMode, formElementId
162
138
  return saveValues(record, valuesToSave, version, true);
163
139
  };
164
140
  const shouldUseLayoutWithSidebar = state.enableSidebar && state.isOpenSidebar && sidebarContainer === undefined && !forceDisableSidebarInAppStudio;
165
- return (_jsx(ErrorBoundary, { children: _jsx(EditRecordReducerContext.Provider, { value: { state, dispatch }, children: _jsxs(Container, { "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, style: containerStyle, children: [_jsx(EditRecordButtons, {}), _jsx(Content, { className: "edit-record-content-container", "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, "$removePadding": removePadding, children: permissionsLoading ? (_jsx(EditRecordSkeleton, { rows: 5 })) : canEdit ? (_jsx(EditRecordContent, { antdForm: antdForm, formId: formId, isFormCreationMode: isFormCreationMode, formElementId: formElementId, record: record, library: libraryId, onRecordSubmit: _handleRecordSubmit, onValueSubmit: _handleValueSubmit, onValueDelete: deleteValue, onDeleteMultipleValues: _handleDeleteAllValues, readonly: isReadOnly })) : (_jsx(ErrorDisplay, { type: ErrorDisplayTypes.PERMISSION_ERROR, showActionButton: false })) }), !forceDisableSidebarInAppStudio && (_jsx(EditRecordSidebar, { onMetadataSubmit: _handleMetadataSubmit, sidebarContainer: sidebarContainer }))] }) }) }));
141
+ return (_jsx(ErrorBoundary, { children: _jsx(EditRecordReducerContext.Provider, { value: { state, dispatch }, children: _jsxs(Container, { "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, style: containerStyle, children: [_jsx(EditRecordButtons, {}), _jsx(Content, { className: "edit-record-content-container", "$shouldUseLayoutWithSidebar": shouldUseLayoutWithSidebar, "$removePadding": removePadding, children: permissionsLoading ? (_jsx(EditRecordSkeleton, { rows: 5 })) : canEdit ? (_jsx(EditRecordContent, { antdForm: antdForm, formId: formId, isFormCreationMode: isFormCreationMode, formElementId: formElementId, record: record, library: libraryId, onRecordSubmit: _handleRecordSubmit, onValueSubmit: _handleValueSubmit, onValueDelete: deleteValue, onDeleteMultipleValues: _handleDeleteAllValues, readonly: isReadOnly })) : (_jsx(ErrorDisplay, { type: ErrorDisplayTypes.PERMISSION_ERROR, showActionButton: false })) }), !forceDisableSidebarInAppStudio && (_jsx(EditRecordSidebar, { sidebarContainer: sidebarContainer, scrollAllRecordSummary: scrollAllRecordSummary }))] }) }) }));
166
142
  };
167
143
  //# sourceMappingURL=EditRecord.js.map