@leav/ui 1.13.0-2d58210a → 1.13.0-3e5f362c

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 (42) hide show
  1. package/dist/_gqlTypes/index.d.ts +115 -39
  2. package/dist/_gqlTypes/index.js +97 -30
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/components/Explorer/actions-mass/edit-attribute/EditMonoDependencyWorkflowTreeAttribute.d.ts +8 -0
  5. package/dist/components/Explorer/actions-mass/edit-attribute/EditMonoDependencyWorkflowTreeAttribute.js +34 -0
  6. package/dist/components/Explorer/actions-mass/edit-attribute/EditMonoDependencyWorkflowTreeAttribute.js.map +1 -0
  7. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +3 -1
  8. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +12 -14
  9. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
  10. package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +15 -3
  11. package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -1
  12. package/dist/components/Explorer/actions-mass/edit-attribute/useDependencyValues.d.ts +13 -0
  13. package/dist/components/Explorer/actions-mass/edit-attribute/useDependencyValues.js +47 -0
  14. package/dist/components/Explorer/actions-mass/edit-attribute/useDependencyValues.js.map +1 -0
  15. package/dist/components/Explorer/actions-mass/edit-attribute/useEditionMappingState.d.ts +13 -0
  16. package/dist/components/Explorer/actions-mass/edit-attribute/useEditionMappingState.js +73 -0
  17. package/dist/components/Explorer/actions-mass/edit-attribute/useEditionMappingState.js.map +1 -0
  18. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +14 -17
  19. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -1
  20. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodesCandidates.d.ts +23 -0
  21. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodesCandidates.js +68 -0
  22. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodesCandidates.js.map +1 -0
  23. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +16 -50
  24. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
  25. package/dist/hooks/index.d.ts +1 -0
  26. package/dist/hooks/index.js +1 -0
  27. package/dist/hooks/index.js.map +1 -1
  28. package/dist/hooks/useDelayedLoading/index.d.ts +1 -0
  29. package/dist/hooks/useDelayedLoading/index.js +5 -0
  30. package/dist/hooks/useDelayedLoading/index.js.map +1 -0
  31. package/dist/hooks/useDelayedLoading/useDelayedLoading.d.ts +17 -0
  32. package/dist/hooks/useDelayedLoading/useDelayedLoading.js +54 -0
  33. package/dist/hooks/useDelayedLoading/useDelayedLoading.js.map +1 -0
  34. package/dist/locales/en/shared.json +1 -0
  35. package/dist/locales/fr/shared.json +1 -0
  36. package/package.json +1 -1
  37. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +0 -12
  38. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +0 -24
  39. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +0 -1
  40. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +0 -13
  41. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +0 -28
  42. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +0 -1
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  import { useEffect, useState } from 'react';
6
6
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7
7
  import { faEdit } from '@fortawesome/free-solid-svg-icons';
8
- import { KitAlert, KitEmpty, KitNotification, KitSelect, KitSpace, KitTypography } from 'aristid-ds';
8
+ import { KitAlert, KitNotification, KitSelect, KitSpace, KitTypography } from 'aristid-ds';
9
9
  import { localizedTranslation } from '@leav/utils';
10
10
  import { useSaveValueBulkMutation } from '../../../_gqlTypes';
11
11
  import { useSharedTranslation } from '../../../hooks/useSharedTranslation';
@@ -15,7 +15,8 @@ import { MASS_SELECTION_ALL } from '../_constants';
15
15
  import { EditTreeAttributeValuesMapping } from './edit-attribute/EditTreeAttributeValuesMapping';
16
16
  import { EditAttributeMassActionModal } from './edit-attribute/EditAttributeMassActionModal';
17
17
  import { useMassEditableAttributes } from './edit-attribute/useMassEditableAttributes';
18
- const EDITION_MAPPING_DEFAULT_VALUES = { count: 0, mapping: [] };
18
+ import { EditMonoDependencyWorkflowTreeAttribute } from './edit-attribute/EditMonoDependencyWorkflowTreeAttribute';
19
+ import { useEditionMappingState } from './edit-attribute/useEditionMappingState';
19
20
  export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCount, }) => {
20
21
  const { lang: availableLanguages } = useLang();
21
22
  const { t } = useSharedTranslation();
@@ -24,16 +25,23 @@ export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCo
24
25
  const [massSelectionFilters, setMassSelectionFilters] = useState([]);
25
26
  const editableAttributes = useMassEditableAttributes({ libraryId: view.libraryId });
26
27
  const [selectedAttribute, setSelectedAttribute] = useState(null);
27
- const [executeSaveValueBulk] = useSaveValueBulkMutation();
28
- const [editionMapping, setEditionMapping] = useState(EDITION_MAPPING_DEFAULT_VALUES);
28
+ const [executeSaveValueBulk] = useSaveValueBulkMutation({
29
+ update(cache) {
30
+ // Without this evict, Apollo keeps stale listDistinctValues occurrences in cache,
31
+ // preventing a re-edit of the same attribute right after a previous (partial or full) bulk edit.
32
+ cache.evict({ fieldName: 'listDistinctValues' });
33
+ cache.gc();
34
+ },
35
+ });
36
+ const { editionMapping, resetEditionMapping, applyMappingChange, applyMonoDependencyWorkflowChange } = useEditionMappingState();
29
37
  useEffect(() => {
30
- setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
38
+ resetEditionMapping();
31
39
  }, [selectedAttribute]);
32
40
  const _closeModal = () => {
33
41
  setOpenModal(false);
34
42
  setMassSelectionFilters([]);
35
43
  setSelectedAttribute(null);
36
- setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
44
+ resetEditionMapping();
37
45
  };
38
46
  const bulkCount = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;
39
47
  const _saveEditionMapping = () => {
@@ -81,7 +89,7 @@ export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCo
81
89
  callback: (_massSelectionFilter) => {
82
90
  setMassSelectionFilters(_massSelectionFilter);
83
91
  setSelectedAttribute(null);
84
- setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);
92
+ resetEditionMapping();
85
93
  setOpenModal(true);
86
94
  },
87
95
  },
@@ -91,49 +99,7 @@ export const useEditAttributeMassAction = ({ isEnabled, store: { view }, totalCo
91
99
  })), onChange: (attributeId) => {
92
100
  setSelectedAttribute(editableAttributes.find(attribute => attribute.id === attributeId));
93
101
  } })] }), selectedAttribute != null &&
94
- (selectedAttribute.hasEmptyDependency ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: ({ before, after, occurrenceCount }) => {
95
- setEditionMapping(before === after
96
- ? {
97
- count: editionMapping.count - occurrenceCount,
98
- mapping: [
99
- {
100
- values: (editionMapping.mapping[0]?.values ?? []).filter(value => value.before !== before),
101
- },
102
- ],
103
- }
104
- : {
105
- count: editionMapping.count + occurrenceCount,
106
- mapping: [
107
- {
108
- values: (editionMapping.mapping[0]?.values ?? [])
109
- .filter(value => value.before !== before)
110
- .concat([{ before, after }]),
111
- },
112
- ],
113
- });
114
- } })) : selectedAttribute.isSimpleWorkflow ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: ({ before, after, occurrenceCount }) => {
115
- setEditionMapping(before === after
116
- ? {
117
- count: editionMapping.count - occurrenceCount,
118
- mapping: [
119
- {
120
- values: (editionMapping.mapping[0]?.values ?? []).filter(value => value.before !== before),
121
- },
122
- ],
123
- }
124
- : {
125
- count: editionMapping.count + occurrenceCount,
126
- mapping: [
127
- {
128
- values: (editionMapping.mapping[0]?.values ?? [])
129
- .filter(value => value.before !== before)
130
- .concat([{ before, after }]),
131
- },
132
- ],
133
- });
134
- } })) : selectedAttribute.isMonoDependencyWorkflow ? (
135
- /* TODO: */
136
- _jsx(KitEmpty, { description: "WIP" })) : null)] })),
102
+ (selectedAttribute.hasEmptyDependency ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: applyMappingChange })) : selectedAttribute.isSimpleWorkflow ? (_jsx(EditTreeAttributeValuesMapping, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: applyMappingChange })) : selectedAttribute.isMonoDependencyWorkflow ? (_jsx(EditMonoDependencyWorkflowTreeAttribute, { libraryId: view.libraryId, attribute: selectedAttribute, massSelectionFilters: massSelectionFilters, setAttributeMapping: applyMonoDependencyWorkflowChange })) : null)] })),
137
103
  };
138
104
  };
139
105
  //# sourceMappingURL=useEditAttributeMassAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEditAttributeMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useEditAttributeMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MA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AK,GAAG,CACjC,CAAC,CAAC,CAAC,IAAI,CAAC,IACc,CAClC;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 {useEffect, useState} from 'react';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faEdit} from '@fortawesome/free-solid-svg-icons';\nimport {KitAlert, KitEmpty, KitNotification, KitSelect, KitSpace, KitTypography} from 'aristid-ds';\nimport {localizedTranslation} from '@leav/utils';\nimport {type RecordFilterInput, type SaveValueBulkMappingInput, useSaveValueBulkMutation} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {useLang} from '_ui/hooks';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type FeatureHook} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {EditTreeAttributeValuesMapping} from './edit-attribute/EditTreeAttributeValuesMapping';\nimport {EditAttributeMassActionModal} from './edit-attribute/EditAttributeMassActionModal';\nimport {useMassEditableAttributes} from './edit-attribute/useMassEditableAttributes';\nimport {type MassEditableAttribute} from './edit-attribute/_types';\n\nconst EDITION_MAPPING_DEFAULT_VALUES = {count: 0, mapping: []};\n\nexport const useEditAttributeMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n}>) => {\n const {lang: availableLanguages} = useLang();\n const {t} = useSharedTranslation();\n\n const [openModal, setOpenModal] = useState(false);\n\n // Represent the current selection, used to apply modifications to correct records\n const [massSelectionFilters, setMassSelectionFilters] = useState<RecordFilterInput[]>([]);\n\n const editableAttributes = useMassEditableAttributes({libraryId: view.libraryId});\n\n const [selectedAttribute, setSelectedAttribute] = useState<MassEditableAttribute | null>(null);\n const [executeSaveValueBulk] = useSaveValueBulkMutation();\n const [editionMapping, setEditionMapping] = useState<{count: number; mapping: SaveValueBulkMappingInput[]}>(\n EDITION_MAPPING_DEFAULT_VALUES,\n );\n useEffect(() => {\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n }, [selectedAttribute]);\n\n const _closeModal = () => {\n setOpenModal(false);\n setMassSelectionFilters([]);\n setSelectedAttribute(null);\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n };\n\n const bulkCount = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n\n const _saveEditionMapping = () => {\n if (!selectedAttribute || editionMapping.count === 0) {\n return;\n }\n\n executeSaveValueBulk({\n variables: {\n libraryId: view.libraryId,\n recordsFilters: massSelectionFilters,\n attributeId: selectedAttribute.id,\n mapping: editionMapping.mapping,\n },\n }).catch(() => {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.editAttribute_submit_error'),\n closable: true,\n });\n });\n\n _closeModal();\n\n KitNotification.info({\n message: t('explorer.massAction.editAttribute_submit_notification_title'),\n description:\n t('explorer.massAction.editAttribute_submit_notification_description', {\n count: editionMapping.count,\n }) ?? undefined,\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n };\n\n // TODO: https://aristid.atlassian.net/browse/LEAVC-830\n if (!isEnabled || editableAttributes.length === 0) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n return {\n editAttributeMassAction: {\n label: t('explorer.massAction.editAttribute'),\n icon: <FontAwesomeIcon icon={faEdit} />,\n deselectAll: false,\n callback: (_massSelectionFilter: RecordFilterInput[]) => {\n setMassSelectionFilters(_massSelectionFilter);\n setSelectedAttribute(null);\n setEditionMapping(EDITION_MAPPING_DEFAULT_VALUES);\n setOpenModal(true);\n },\n },\n editAttributeMassActionModal: (\n <EditAttributeMassActionModal\n isOpen={openModal}\n bulkCount={bulkCount}\n onOkButtonClick={_saveEditionMapping}\n onCancelButtonClick={_closeModal}\n >\n <KitSpace direction=\"vertical\" size=\"xxs\" style={{width: '100%'}}>\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_attribute_select_title')}\n </KitTypography.Text>\n <KitSelect\n size=\"large\"\n allowClear={false}\n placeholder={t('explorer.massAction.editAttribute_attribute_select_placeholder')}\n options={editableAttributes.map(attribute => ({\n label: localizedTranslation(attribute.label, availableLanguages),\n value: attribute.id,\n }))}\n onChange={(attributeId: string) => {\n setSelectedAttribute(editableAttributes.find(attribute => attribute.id === attributeId)!);\n }}\n />\n </KitSpace>\n {selectedAttribute != null &&\n (selectedAttribute.hasEmptyDependency ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={({before, after, occurrenceCount}) => {\n setEditionMapping(\n before === after\n ? {\n count: editionMapping.count - occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? []).filter(\n value => value.before !== before,\n ),\n },\n ],\n }\n : {\n count: editionMapping.count + occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? [])\n .filter(value => value.before !== before)\n .concat([{before, after}]),\n },\n ],\n },\n );\n }}\n />\n ) : selectedAttribute.isSimpleWorkflow ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={({before, after, occurrenceCount}) => {\n setEditionMapping(\n before === after\n ? {\n count: editionMapping.count - occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? []).filter(\n value => value.before !== before,\n ),\n },\n ],\n }\n : {\n count: editionMapping.count + occurrenceCount,\n mapping: [\n {\n values: (editionMapping.mapping[0]?.values ?? [])\n .filter(value => value.before !== before)\n .concat([{before, after}]),\n },\n ],\n },\n );\n }}\n />\n ) : selectedAttribute.isMonoDependencyWorkflow ? (\n /* TODO: */\n <KitEmpty description=\"WIP\" />\n ) : null)}\n </EditAttributeMassActionModal>\n ),\n };\n};\n"]}
1
+ {"version":3,"file":"useEditAttributeMassAction.js","sourceRoot":"","sources":["../../../../src/components/Explorer/actions-mass/useEditAttributeMassAction.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACzF,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAyB,wBAAwB,EAAC,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAGjD,OAAO,EAAC,8BAA8B,EAAC,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAC,4BAA4B,EAAC,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAC,yBAAyB,EAAC,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAC,uCAAuC,EAAC,MAAM,0DAA0D,CAAC;AAEjH,OAAO,EAAC,sBAAsB,EAAC,MAAM,yCAAyC,CAAC;AAE/E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EACvC,SAAS,EACT,KAAK,EAAE,EAAC,IAAI,EAAC,EACb,UAAU,GAMZ,EAAE,EAAE;IACF,MAAM,EA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iBAAiB,EAC5B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,kBAAkB,GACzC,CACL,CAAC,CAAC,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CACrC,KAAC,8BAA8B,IAC3B,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,SAAS,EAAE,iBAAiB,EAC5B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,kBAAkB,GACzC,CACL,CAAC,CAAC,CAAC,iBAAiB,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAC7C,KAAC,uCAAuC,IACpC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,SAAS,EAAE,iBAAiB,EAC5B,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,iCAAiC,GACxD,CACL,CAAC,CAAC,CAAC,IAAI,CAAC,IACc,CAClC;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 {useEffect, useState} from 'react';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faEdit} from '@fortawesome/free-solid-svg-icons';\nimport {KitAlert, KitNotification, KitSelect, KitSpace, KitTypography} from 'aristid-ds';\nimport {localizedTranslation} from '@leav/utils';\nimport {type RecordFilterInput, useSaveValueBulkMutation} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {ERROR_ALERT_DURATION, INFO_NOTIFICATION_DURATION} from '_ui/constants';\nimport {useLang} from '_ui/hooks';\nimport {MASS_SELECTION_ALL} from '../_constants';\nimport {type FeatureHook} from '../_types';\nimport {type IViewSettingsState} from '../manage-view-settings';\nimport {EditTreeAttributeValuesMapping} from './edit-attribute/EditTreeAttributeValuesMapping';\nimport {EditAttributeMassActionModal} from './edit-attribute/EditAttributeMassActionModal';\nimport {useMassEditableAttributes} from './edit-attribute/useMassEditableAttributes';\nimport {EditMonoDependencyWorkflowTreeAttribute} from './edit-attribute/EditMonoDependencyWorkflowTreeAttribute';\nimport {type MassEditableAttribute} from './edit-attribute/_types';\nimport {useEditionMappingState} from './edit-attribute/useEditionMappingState';\n\nexport const useEditAttributeMassAction = ({\n isEnabled,\n store: {view},\n totalCount,\n}: FeatureHook<{\n store: {\n view: IViewSettingsState;\n };\n totalCount: number;\n}>) => {\n const {lang: availableLanguages} = useLang();\n const {t} = useSharedTranslation();\n\n const [openModal, setOpenModal] = useState(false);\n\n // Represent the current selection, used to apply modifications to correct records\n const [massSelectionFilters, setMassSelectionFilters] = useState<RecordFilterInput[]>([]);\n\n const editableAttributes = useMassEditableAttributes({libraryId: view.libraryId});\n\n const [selectedAttribute, setSelectedAttribute] = useState<MassEditableAttribute | null>(null);\n const [executeSaveValueBulk] = useSaveValueBulkMutation({\n update(cache) {\n // Without this evict, Apollo keeps stale listDistinctValues occurrences in cache,\n // preventing a re-edit of the same attribute right after a previous (partial or full) bulk edit.\n cache.evict({fieldName: 'listDistinctValues'});\n cache.gc();\n },\n });\n const {editionMapping, resetEditionMapping, applyMappingChange, applyMonoDependencyWorkflowChange} =\n useEditionMappingState();\n\n useEffect(() => {\n resetEditionMapping();\n }, [selectedAttribute]);\n\n const _closeModal = () => {\n setOpenModal(false);\n setMassSelectionFilters([]);\n setSelectedAttribute(null);\n resetEditionMapping();\n };\n\n const bulkCount = view.massSelection === MASS_SELECTION_ALL ? totalCount : view.massSelection.length;\n\n const _saveEditionMapping = () => {\n if (!selectedAttribute || editionMapping.count === 0) {\n return;\n }\n\n executeSaveValueBulk({\n variables: {\n libraryId: view.libraryId,\n recordsFilters: massSelectionFilters,\n attributeId: selectedAttribute.id,\n mapping: editionMapping.mapping,\n },\n }).catch(() => {\n KitAlert.error({\n showIcon: true,\n duration: ERROR_ALERT_DURATION,\n message: t('error.error_occurred'),\n description: t('explorer.massAction.editAttribute_submit_error'),\n closable: true,\n });\n });\n\n _closeModal();\n\n KitNotification.info({\n message: t('explorer.massAction.editAttribute_submit_notification_title'),\n description:\n t('explorer.massAction.editAttribute_submit_notification_description', {\n count: editionMapping.count,\n }) ?? undefined,\n duration: INFO_NOTIFICATION_DURATION,\n closable: true,\n });\n };\n\n // TODO: https://aristid.atlassian.net/browse/LEAVC-830\n if (!isEnabled || editableAttributes.length === 0) {\n return {\n editAttributeMassAction: null,\n editAttributeMassActionModal: null,\n };\n }\n\n return {\n editAttributeMassAction: {\n label: t('explorer.massAction.editAttribute'),\n icon: <FontAwesomeIcon icon={faEdit} />,\n deselectAll: false,\n callback: (_massSelectionFilter: RecordFilterInput[]) => {\n setMassSelectionFilters(_massSelectionFilter);\n setSelectedAttribute(null);\n resetEditionMapping();\n setOpenModal(true);\n },\n },\n editAttributeMassActionModal: (\n <EditAttributeMassActionModal\n isOpen={openModal}\n bulkCount={bulkCount}\n onOkButtonClick={_saveEditionMapping}\n onCancelButtonClick={_closeModal}\n >\n <KitSpace direction=\"vertical\" size=\"xxs\" style={{width: '100%'}}>\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_attribute_select_title')}\n </KitTypography.Text>\n <KitSelect\n size=\"large\"\n allowClear={false}\n placeholder={t('explorer.massAction.editAttribute_attribute_select_placeholder')}\n options={editableAttributes.map(attribute => ({\n label: localizedTranslation(attribute.label, availableLanguages),\n value: attribute.id,\n }))}\n onChange={(attributeId: string) => {\n setSelectedAttribute(editableAttributes.find(attribute => attribute.id === attributeId)!);\n }}\n />\n </KitSpace>\n {selectedAttribute != null &&\n (selectedAttribute.hasEmptyDependency ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={applyMappingChange}\n />\n ) : selectedAttribute.isSimpleWorkflow ? (\n <EditTreeAttributeValuesMapping\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={applyMappingChange}\n />\n ) : selectedAttribute.isMonoDependencyWorkflow ? (\n <EditMonoDependencyWorkflowTreeAttribute\n libraryId={view.libraryId}\n attribute={selectedAttribute}\n massSelectionFilters={massSelectionFilters}\n setAttributeMapping={applyMonoDependencyWorkflowChange}\n />\n ) : null)}\n </EditAttributeMassActionModal>\n ),\n };\n};\n"]}
@@ -20,3 +20,4 @@ export { useIFrameMessengerHandlers } from './useIFrameMessenger/useIFrameMessen
20
20
  export { IFrameMessengerProvider } from './useIFrameMessenger/useIFrameMessengerContext';
21
21
  export { useGetRecordIdCard } from './useGetRecordIdCard';
22
22
  export { useConfirmModal } from './useConfirmModal';
23
+ export { useDelayedLoading } from './useDelayedLoading';
@@ -23,4 +23,5 @@ export { useIFrameMessengerHandlers } from './useIFrameMessenger/useIFrameMessen
23
23
  export { IFrameMessengerProvider } from './useIFrameMessenger/useIFrameMessengerContext';
24
24
  export { useGetRecordIdCard } from './useGetRecordIdCard';
25
25
  export { useConfirmModal } from './useConfirmModal';
26
+ export { useDelayedLoading } from './useDelayedLoading';
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,+BAA+B,EAAC,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,6BAA6B,EAAC,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAC,wBAAwB,EAAC,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAC,qBAAqB,EAAC,MAAM,kDAAkD,CAAC;AACvF,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,0BAA0B,EAAC,MAAM,iDAAiD,CAAC;AAC3F,OAAO,EAAC,uBAAuB,EAAC,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,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\n\nexport {useSaveApplicationMutation} from '../_gqlTypes';\nexport {useAntdLocale} from './useAntdLocale';\nexport {default as useAppLang} from './useAppLang';\nexport {default as useAuth} from './useAuth';\nexport {default as useGetRecordForm} from './useGetRecordForm';\nexport {useGetRecordUpdatesSubscription} from './useGetRecordUpdatesSubscription';\nexport {default as useLang} from './useLang';\nexport {default as useLocalStorage} from './useLocalStorage';\nexport {default as useRecordsConsultationHistory} from './useRecordsConsultationHistory';\nexport {useRefreshFieldValues} from './useRefreshFieldValues';\nexport {default as useLoginChecker} from './useLoginChecker';\nexport {default as useRedirectToLogin} from './useRedirectToLogin';\nexport {useUser} from './useUser';\nexport {useValuesCacheUpdate} from './useValuesCacheUpdate';\nexport {useIFrameMessenger} from './useIFrameMessenger/useIFrameMessenger';\nexport {useIFrameMessengerClient} from './useIFrameMessengerClient/useIFrameMessengerClient';\nexport {IFrameMessengerClient} from './useIFrameMessengerClient/IFrameMessengerClient';\nexport {creationPanelSchema} from './useIFrameMessenger/schema';\nexport {useIFrameMessengerHandlers} from './useIFrameMessenger/useIFrameMessengerHandlers';\nexport {IFrameMessengerProvider} from './useIFrameMessenger/useIFrameMessengerContext';\nexport {useGetRecordIdCard} from './useGetRecordIdCard';\nexport {useConfirmModal} from './useConfirmModal';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,+BAA+B,EAAC,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,6BAA6B,EAAC,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAC,wBAAwB,EAAC,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAC,qBAAqB,EAAC,MAAM,kDAAkD,CAAC;AACvF,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,0BAA0B,EAAC,MAAM,iDAAiD,CAAC;AAC3F,OAAO,EAAC,uBAAuB,EAAC,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,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\n\nexport {useSaveApplicationMutation} from '../_gqlTypes';\nexport {useAntdLocale} from './useAntdLocale';\nexport {default as useAppLang} from './useAppLang';\nexport {default as useAuth} from './useAuth';\nexport {default as useGetRecordForm} from './useGetRecordForm';\nexport {useGetRecordUpdatesSubscription} from './useGetRecordUpdatesSubscription';\nexport {default as useLang} from './useLang';\nexport {default as useLocalStorage} from './useLocalStorage';\nexport {default as useRecordsConsultationHistory} from './useRecordsConsultationHistory';\nexport {useRefreshFieldValues} from './useRefreshFieldValues';\nexport {default as useLoginChecker} from './useLoginChecker';\nexport {default as useRedirectToLogin} from './useRedirectToLogin';\nexport {useUser} from './useUser';\nexport {useValuesCacheUpdate} from './useValuesCacheUpdate';\nexport {useIFrameMessenger} from './useIFrameMessenger/useIFrameMessenger';\nexport {useIFrameMessengerClient} from './useIFrameMessengerClient/useIFrameMessengerClient';\nexport {IFrameMessengerClient} from './useIFrameMessengerClient/IFrameMessengerClient';\nexport {creationPanelSchema} from './useIFrameMessenger/schema';\nexport {useIFrameMessengerHandlers} from './useIFrameMessenger/useIFrameMessengerHandlers';\nexport {IFrameMessengerProvider} from './useIFrameMessenger/useIFrameMessengerContext';\nexport {useGetRecordIdCard} from './useGetRecordIdCard';\nexport {useConfirmModal} from './useConfirmModal';\nexport {useDelayedLoading} from './useDelayedLoading';\n"]}
@@ -0,0 +1 @@
1
+ export * from './useDelayedLoading';
@@ -0,0 +1,5 @@
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
+ export * from './useDelayedLoading';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useDelayedLoading/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,cAAc,qBAAqB,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\nexport * from './useDelayedLoading';\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Prevents loader flickering by applying two UX rules:
3
+ *
4
+ * 1. **Show delay (200 ms)** — if loading ends before 200 ms, the loader is never shown.
5
+ * Avoids a flash for fast requests.
6
+ *
7
+ * 2. **Minimum display duration (300 ms)** — once the loader has appeared,
8
+ * it stays visible for at least 300 ms. Avoids a jarring disappearance for slightly slow requests.
9
+ *
10
+ * @param loading - raw loading state (e.g. `queryResult.loading`)
11
+ * @returns `true` only when the loader should be rendered
12
+ *
13
+ * @example
14
+ * const isLoaderVisible = useDelayedLoading(loading);
15
+ * return isLoaderVisible ? <KitLoader /> : <Content />;
16
+ */
17
+ export declare const useDelayedLoading: (loading: boolean) => boolean;
@@ -0,0 +1,54 @@
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 { useEffect, useRef, useState } from 'react';
5
+ const LOADER_SHOW_DELAY_MS = 200;
6
+ const LOADER_MIN_DURATION_MS = 300;
7
+ /**
8
+ * Prevents loader flickering by applying two UX rules:
9
+ *
10
+ * 1. **Show delay (200 ms)** — if loading ends before 200 ms, the loader is never shown.
11
+ * Avoids a flash for fast requests.
12
+ *
13
+ * 2. **Minimum display duration (300 ms)** — once the loader has appeared,
14
+ * it stays visible for at least 300 ms. Avoids a jarring disappearance for slightly slow requests.
15
+ *
16
+ * @param loading - raw loading state (e.g. `queryResult.loading`)
17
+ * @returns `true` only when the loader should be rendered
18
+ *
19
+ * @example
20
+ * const isLoaderVisible = useDelayedLoading(loading);
21
+ * return isLoaderVisible ? <KitLoader /> : <Content />;
22
+ */
23
+ export const useDelayedLoading = (loading) => {
24
+ const loadingStartRef = useRef(null);
25
+ const [isLoaderVisible, setIsLoaderVisible] = useState(false);
26
+ useEffect(() => {
27
+ if (!loading) {
28
+ if (loadingStartRef.current === null) {
29
+ return;
30
+ }
31
+ const elapsed = Date.now() - loadingStartRef.current;
32
+ const loaderHasBeenShown = elapsed >= LOADER_SHOW_DELAY_MS;
33
+ if (!loaderHasBeenShown) {
34
+ loadingStartRef.current = null;
35
+ return;
36
+ }
37
+ const remaining = LOADER_SHOW_DELAY_MS + LOADER_MIN_DURATION_MS - elapsed;
38
+ loadingStartRef.current = null;
39
+ if (remaining <= 0) {
40
+ setIsLoaderVisible(false);
41
+ }
42
+ else {
43
+ const timer = setTimeout(() => setIsLoaderVisible(false), remaining);
44
+ return () => clearTimeout(timer);
45
+ }
46
+ return;
47
+ }
48
+ loadingStartRef.current = Date.now();
49
+ const showTimer = setTimeout(() => setIsLoaderVisible(true), LOADER_SHOW_DELAY_MS);
50
+ return () => clearTimeout(showTimer);
51
+ }, [loading]);
52
+ return isLoaderVisible;
53
+ };
54
+ //# sourceMappingURL=useDelayedLoading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDelayedLoading.js","sourceRoot":"","sources":["../../../src/hooks/useDelayedLoading/useDelayedLoading.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAElD,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAW,EAAE;IAC3D,MAAM,eAAe,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,IAAI,eAAe,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBACnC,OAAO;YACX,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC;YACrD,MAAM,kBAAkB,GAAG,OAAO,IAAI,oBAAoB,CAAC;YAE3D,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACtB,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;gBAC/B,OAAO;YACX,CAAC;YAED,MAAM,SAAS,GAAG,oBAAoB,GAAG,sBAAsB,GAAG,OAAO,CAAC;YAC1E,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;YAE/B,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;gBACjB,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACJ,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;gBACrE,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;YACD,OAAO;QACX,CAAC;QAED,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAErC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAC;QACnF,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,eAAe,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 {useEffect, useRef, useState} from 'react';\n\nconst LOADER_SHOW_DELAY_MS = 200;\nconst LOADER_MIN_DURATION_MS = 300;\n\n/**\n * Prevents loader flickering by applying two UX rules:\n *\n * 1. **Show delay (200 ms)** — if loading ends before 200 ms, the loader is never shown.\n * Avoids a flash for fast requests.\n *\n * 2. **Minimum display duration (300 ms)** — once the loader has appeared,\n * it stays visible for at least 300 ms. Avoids a jarring disappearance for slightly slow requests.\n *\n * @param loading - raw loading state (e.g. `queryResult.loading`)\n * @returns `true` only when the loader should be rendered\n *\n * @example\n * const isLoaderVisible = useDelayedLoading(loading);\n * return isLoaderVisible ? <KitLoader /> : <Content />;\n */\nexport const useDelayedLoading = (loading: boolean): boolean => {\n const loadingStartRef = useRef<number | null>(null);\n const [isLoaderVisible, setIsLoaderVisible] = useState(false);\n\n useEffect(() => {\n if (!loading) {\n if (loadingStartRef.current === null) {\n return;\n }\n const elapsed = Date.now() - loadingStartRef.current;\n const loaderHasBeenShown = elapsed >= LOADER_SHOW_DELAY_MS;\n\n if (!loaderHasBeenShown) {\n loadingStartRef.current = null;\n return;\n }\n\n const remaining = LOADER_SHOW_DELAY_MS + LOADER_MIN_DURATION_MS - elapsed;\n loadingStartRef.current = null;\n\n if (remaining <= 0) {\n setIsLoaderVisible(false);\n } else {\n const timer = setTimeout(() => setIsLoaderVisible(false), remaining);\n return () => clearTimeout(timer);\n }\n return;\n }\n\n loadingStartRef.current = Date.now();\n\n const showTimer = setTimeout(() => setIsLoaderVisible(true), LOADER_SHOW_DELAY_MS);\n return () => clearTimeout(showTimer);\n }, [loading]);\n\n return isLoaderVisible;\n};\n"]}
@@ -741,6 +741,7 @@
741
741
  "editAttribute_value_occurrences_to_edit_other": "{{count, number}} elements to edit",
742
742
  "editAttribute_value_undefined": "Undefined",
743
743
  "editAttribute_value_do_not_change": "Do not change",
744
+ "editAttribute_mono_dependency_workflow_notice": "The elements are grouped by type. Select the new desired value for each group.",
744
745
  "editAttribute_submit_notification_title": "Bulk edit request",
745
746
  "editAttribute_submit_notification_description_one": "Your request to edit {{count, number}} item has been received. You will be notified once the operation is complete.",
746
747
  "editAttribute_submit_notification_description_other": "Your request to edit {{count, number}} items has been received. You will be notified once the operation is complete.",
@@ -741,6 +741,7 @@
741
741
  "editAttribute_value_occurrences_to_edit_other": "{{count, number}} éléments à traiter",
742
742
  "editAttribute_value_undefined": "Non défini",
743
743
  "editAttribute_value_do_not_change": "Ne pas changer",
744
+ "editAttribute_mono_dependency_workflow_notice": "Les éléments sont regroupés par type. Sélectionnez la nouvelle valeur souhaitée pour chaque groupe.",
744
745
  "editAttribute_submit_notification_title": "Demande de modification en masse",
745
746
  "editAttribute_submit_notification_description_one": "Votre demande de modification de {{count, number}} élément a bien été prise en compte. Vous serez notifié une fois l’opération terminée.",
746
747
  "editAttribute_submit_notification_description_other": "Votre demande de modification de {{count, number}} éléments a bien été prise en compte. Vous serez notifié une fois l’opération terminée.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.13.0-2d58210a",
3
+ "version": "1.13.0-3e5f362c",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -1,12 +0,0 @@
1
- import { type MassEditTreeNode } from './_types';
2
- export declare const useTreeNodeRemapping: ({ distribution, editableNodes, }: {
3
- distribution: Array<{
4
- count: number;
5
- treeNodeId: string;
6
- }>;
7
- editableNodes: MassEditTreeNode[];
8
- }) => Array<{
9
- currentNode: MassEditTreeNode;
10
- occurrenceCount: number;
11
- candidateNodes: MassEditTreeNode[];
12
- }>;
@@ -1,24 +0,0 @@
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 { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
5
- export const useTreeNodeRemapping = ({ distribution, editableNodes, }) => {
6
- const { t } = useSharedTranslation();
7
- return distribution.map(occurrence => {
8
- const currentNode = editableNodes.find(({ id }) => id === occurrence.treeNodeId);
9
- const filteredCandidates = editableNodes
10
- .filter(({ id }) => id !== currentNode.id)
11
- .filter(candidate => currentNode.allowedDependentNodeIds &&
12
- (currentNode.allowedDependentNodeIds.length === 0 ||
13
- currentNode.allowedDependentNodeIds.includes(candidate.id)));
14
- return {
15
- currentNode,
16
- occurrenceCount: occurrence.count,
17
- candidateNodes: [
18
- { id: occurrence.treeNodeId, label: t('explorer.massAction.editAttribute_value_do_not_change') },
19
- ...filteredCandidates,
20
- ],
21
- };
22
- });
23
- };
24
- //# sourceMappingURL=useTreeNodeRemapping.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTreeNodeRemapping.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAGpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACjC,YAAY,EACZ,aAAa,GAIhB,EAIE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,UAAU,CAAE,CAAC;QAEhF,MAAM,kBAAkB,GAAG,aAAa;aACnC,MAAM,CAAC,CAAC,EAAC,EAAE,EAAC,EAAE,EAAE,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE,CAAC;aACvC,MAAM,CACH,SAAS,CAAC,EAAE,CACR,WAAW,CAAC,uBAAuB;YACnC,CAAC,WAAW,CAAC,uBAAuB,CAAC,MAAM,KAAK,CAAC;gBAC7C,WAAW,CAAC,uBAAuB,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAG,CAAC,CAAC,CACvE,CAAC;QAEN,OAAO;YACH,WAAW;YACX,eAAe,EAAE,UAAU,CAAC,KAAK;YACjC,cAAc,EAAE;gBACZ,EAAC,EAAE,EAAE,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,uDAAuD,CAAC,EAAC;gBAC9F,GAAG,kBAAkB;aACxB;SACJ,CAAC;IACN,CAAC,CAAC,CAAC;AACP,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 MassEditTreeNode} from './_types';\n\nexport const useTreeNodeRemapping = ({\n distribution,\n editableNodes,\n}: {\n distribution: Array<{count: number; treeNodeId: string}>;\n editableNodes: MassEditTreeNode[];\n}): Array<{\n currentNode: MassEditTreeNode;\n occurrenceCount: number;\n candidateNodes: MassEditTreeNode[];\n}> => {\n const {t} = useSharedTranslation();\n\n return distribution.map(occurrence => {\n const currentNode = editableNodes.find(({id}) => id === occurrence.treeNodeId)!;\n\n const filteredCandidates = editableNodes\n .filter(({id}) => id !== currentNode.id)\n .filter(\n candidate =>\n currentNode.allowedDependentNodeIds &&\n (currentNode.allowedDependentNodeIds.length === 0 ||\n currentNode.allowedDependentNodeIds.includes(candidate.id!)),\n );\n\n return {\n currentNode,\n occurrenceCount: occurrence.count,\n candidateNodes: [\n {id: occurrence.treeNodeId, label: t('explorer.massAction.editAttribute_value_do_not_change')},\n ...filteredCandidates,\n ],\n };\n });\n};\n"]}
@@ -1,13 +0,0 @@
1
- import { type RecordFilterInput } from '../../../../_gqlTypes';
2
- export declare const useValuesDistribution: ({ attributeId, libraryId, recordFilters, }: {
3
- attributeId: string;
4
- libraryId: string;
5
- recordFilters: RecordFilterInput[];
6
- }) => {
7
- noValueCount: number;
8
- distribution: Array<{
9
- count: number;
10
- treeNodeId: string;
11
- }>;
12
- loading: boolean;
13
- };
@@ -1,28 +0,0 @@
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 { useValuesOccurrencesQuery } from '../../../../_gqlTypes';
5
- export const useValuesDistribution = ({ attributeId, libraryId, recordFilters, }) => {
6
- const { data: valuesOccurrences, loading } = useValuesOccurrencesQuery({
7
- variables: {
8
- attributeId,
9
- libraryId,
10
- recordFilters,
11
- },
12
- });
13
- const noValueCount = valuesOccurrences?.listDistinctValues?.find(treeOccurrence => !('treeNode' in treeOccurrence && treeOccurrence.treeNode))?.count ?? 0;
14
- const distribution = valuesOccurrences?.listDistinctValues
15
- ?.map(treeOccurrence => 'treeNode' in treeOccurrence && treeOccurrence.treeNode
16
- ? {
17
- count: treeOccurrence.count,
18
- treeNodeId: treeOccurrence.treeNode.id,
19
- }
20
- : null)
21
- .filter(Boolean) ?? [];
22
- return {
23
- distribution,
24
- noValueCount,
25
- loading,
26
- };
27
- };
28
- //# sourceMappingURL=useValuesDistribution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useValuesDistribution.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,yBAAyB,EAAC,MAAM,eAAe,CAAC;AAEhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAClC,WAAW,EACX,SAAS,EACT,aAAa,GAKhB,EAOC,EAAE;IACA,MAAM,EAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAC,GAAG,yBAAyB,CAAC;QACjE,SAAS,EAAE;YACP,WAAW;YACX,SAAS;YACT,aAAa;SAChB;KACJ,CAAC,CAAC;IAEH,MAAM,YAAY,GACd,iBAAiB,EAAE,kBAAkB,EAAE,IAAI,CACvC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ,CAAC,CAC/E,EAAE,KAAK,IAAI,CAAC,CAAC;IAElB,MAAM,YAAY,GACd,iBAAiB,EAAE,kBAAkB;QACjC,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,CACnB,UAAU,IAAI,cAAc,IAAI,cAAc,CAAC,QAAQ;QACnD,CAAC,CAAC;YACI,KAAK,EAAE,cAAc,CAAC,KAAK;YAC3B,UAAU,EAAE,cAAc,CAAC,QAAQ,CAAC,EAAE;SACzC;QACH,CAAC,CAAC,IAAI,CACb;SACA,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAE/B,OAAO;QACH,YAAY;QACZ,YAAY;QACZ,OAAO;KACV,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, useValuesOccurrencesQuery} from '_ui/_gqlTypes';\n\nexport const useValuesDistribution = ({\n attributeId,\n libraryId,\n recordFilters,\n}: {\n attributeId: string;\n libraryId: string;\n recordFilters: RecordFilterInput[];\n}): {\n noValueCount: number;\n distribution: Array<{\n count: number;\n treeNodeId: string;\n }>;\n loading: boolean;\n} => {\n const {data: valuesOccurrences, loading} = useValuesOccurrencesQuery({\n variables: {\n attributeId,\n libraryId,\n recordFilters,\n },\n });\n\n const noValueCount =\n valuesOccurrences?.listDistinctValues?.find(\n treeOccurrence => !('treeNode' in treeOccurrence && treeOccurrence.treeNode),\n )?.count ?? 0;\n\n const distribution =\n valuesOccurrences?.listDistinctValues\n ?.map(treeOccurrence =>\n 'treeNode' in treeOccurrence && treeOccurrence.treeNode\n ? {\n count: treeOccurrence.count,\n treeNodeId: treeOccurrence.treeNode.id,\n }\n : null,\n )\n .filter(Boolean) ?? [];\n\n return {\n distribution,\n noValueCount,\n loading,\n };\n};\n"]}