@leav/ui 1.12.0-a0a98764 → 1.12.0-a3cb7513

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 (115) hide show
  1. package/dist/__mocks__/utils.d.ts +3 -0
  2. package/dist/__mocks__/utils.js +2 -0
  3. package/dist/__mocks__/utils.js.map +1 -0
  4. package/dist/_gqlTypes/index.d.ts +325 -59
  5. package/dist/_gqlTypes/index.js +249 -46
  6. package/dist/_gqlTypes/index.js.map +1 -1
  7. package/dist/components/Explorer/DataView.js +31 -14
  8. package/dist/components/Explorer/DataView.js.map +1 -1
  9. package/dist/components/Explorer/_constants.d.ts +0 -1
  10. package/dist/components/Explorer/_constants.js +0 -1
  11. package/dist/components/Explorer/_constants.js.map +1 -1
  12. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +5 -9
  13. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
  14. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +4 -9
  15. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +3 -11
  16. package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
  17. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -8
  18. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +26 -13
  19. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
  20. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.d.ts +7 -0
  21. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js +30 -0
  22. package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js.map +1 -0
  23. package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +23 -0
  24. package/dist/components/Explorer/actions-mass/edit-attribute/_types.js +2 -0
  25. package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -0
  26. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.d.ts +4 -0
  27. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +46 -0
  28. package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -0
  29. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +12 -0
  30. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +24 -0
  31. package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +1 -0
  32. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +13 -0
  33. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +28 -0
  34. package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +1 -0
  35. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
  36. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
  37. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
  38. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
  39. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +8 -2
  40. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -80
  41. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
  42. package/dist/components/Explorer/actions-mass/useMassActions.js +30 -19
  43. package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
  44. package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
  45. package/dist/components/Explorer/conditionsHelper.js.map +1 -1
  46. package/dist/components/Filters/conditionsHelper.d.ts +2 -1
  47. package/dist/components/Filters/conditionsHelper.js.map +1 -1
  48. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  49. package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
  50. package/dist/components/Filters/useTransformFilters.js.map +1 -1
  51. package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
  52. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  53. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
  54. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
  55. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
  56. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
  57. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
  58. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
  59. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  60. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
  61. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map +1 -1
  62. package/dist/constants.d.ts +1 -0
  63. package/dist/constants.js +1 -0
  64. package/dist/constants.js.map +1 -1
  65. package/dist/hooks/index.d.ts +4 -0
  66. package/dist/hooks/index.js +4 -0
  67. package/dist/hooks/index.js.map +1 -1
  68. package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
  69. package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
  70. package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
  71. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
  72. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
  73. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
  74. package/dist/hooks/useConfirmModal/index.d.ts +1 -0
  75. package/dist/hooks/useConfirmModal/index.js +5 -0
  76. package/dist/hooks/useConfirmModal/index.js.map +1 -0
  77. package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
  78. package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
  79. package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
  80. package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
  81. package/dist/hooks/useGetRecordIdCard/index.js +5 -0
  82. package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
  83. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
  84. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
  85. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
  86. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
  87. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
  88. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
  89. package/dist/hooks/useIFrameMessenger/types.d.ts +5 -2
  90. package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
  91. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +10 -2
  92. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +21 -9
  93. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
  94. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
  95. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
  96. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
  97. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
  98. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
  99. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
  100. package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
  101. package/dist/locales/en/shared.json +6 -4
  102. package/dist/locales/fr/shared.json +8 -6
  103. package/package.json +9 -9
  104. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +0 -8
  105. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +0 -40
  106. package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +0 -1
  107. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +0 -17
  108. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +0 -42
  109. package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +0 -1
  110. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +0 -5
  111. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +0 -20
  112. package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +0 -1
  113. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +0 -12
  114. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +0 -30
  115. package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +0 -1
@@ -5,8 +5,16 @@ import { useCallback, useContext, useEffect, useRef, useState } from 'react';
5
5
  import { LangContext } from '../../contexts';
6
6
  import { encodeMessage, decodeMessage, getExposedMethods, initClientHandlers } from './messageHandlers';
7
7
  /**
8
- * This is the core of `useIFrameMessenger`. Should be used for top-level apps, such as **app-studio**.
9
- * For client apps (apps that need to consume the messenger), please use the `useIFrameMessengerClient`
8
+ * Core hook of the IFrameMessenger system. Registers a single `window.addEventListener('message')`
9
+ * and manages a registry of connected child frames.
10
+ *
11
+ * **Usage:**
12
+ * - Top-level apps (e.g. app-studio): use via `IFrameMessengerProvider` which calls this hook once as a singleton.
13
+ * - Client apps (child iframes): use `useIFrameMessengerClient` instead.
14
+ *
15
+ * **`onMessageReceived` option:** when provided, all non-system messages are delegated to this callback
16
+ * instead of being handled locally. Used by `IFrameMessengerProvider` to route messages to the correct
17
+ * per-iframe handlers without registering multiple listeners.
10
18
  */
11
19
  export const useIFrameMessenger = (options) => {
12
20
  const registry = useRef({});
@@ -98,18 +106,22 @@ export const useIFrameMessenger = (options) => {
98
106
  dispatch(message, target);
99
107
  }
100
108
  break;
101
- case 'get-panel-config':
102
- clientHandlers({
103
- ...message,
104
- data: { ...message.data, panelId: getPanelIdFromEvent(event) },
105
- }, dispatch);
106
- break;
107
109
  default:
108
110
  if (message.type === 'change-language') {
109
111
  setLang(message.language);
110
112
  }
113
+ else if (options?.onMessageReceived) {
114
+ // Singleton mode: delegate routing to the Provider (IFrameMessengerProvider).
115
+ // The Provider resolves which iframe sent the message and calls the matching handlers.
116
+ options.onMessageReceived(event.source, message, getPanelIdFromEvent(event), dispatch, callCb, callbacksStore);
117
+ }
111
118
  else {
112
- clientHandlers(message, dispatch);
119
+ // Legacy / client mode: handle messages directly with local clientHandlers.
120
+ // get-panel-config needs panelId enriched before dispatch.
121
+ const enrichedMessage = message.type === 'get-panel-config'
122
+ ? { ...message, data: { ...message.data, panelId: getPanelIdFromEvent(event) } }
123
+ : message;
124
+ clientHandlers(enrichedMessage, dispatch);
113
125
  }
114
126
  break;
115
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useIFrameMessenger.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/useIFrameMessenger.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AASzC,OAAO,EAAC,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAItG;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CA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G,EAAE,CAAC;YACxB,qDAAqD;YACrD,QAAQ,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,EAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACH,GAAG,OAAO,CAAC,OAAO;QAClB,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 {useCallback, useContext, useEffect, useRef, useState} from 'react';\nimport {LangContext} from '_ui/contexts';\nimport {\n type AddMessageToPanelMessageHandler,\n type MessageToPanelMessageHandler,\n type Callbacks,\n type CallCbFunction,\n type IUseIFrameMessengerOptions,\n type MessageDispatcher,\n} from './types';\nimport {encodeMessage, decodeMessage, getExposedMethods, initClientHandlers} from './messageHandlers';\n\nexport {IUseIFrameMessengerOptions};\n\n/**\n * This is the core of `useIFrameMessenger`. Should be used for top-level apps, such as **app-studio**.\n * For client apps (apps that need to consume the messenger), please use the `useIFrameMessengerClient`\n */\nexport const useIFrameMessenger = (options?: IUseIFrameMessengerOptions) => {\n const registry = useRef<Record<string, Window>>({});\n const selfId = useRef(options?.id ?? window.crypto.randomUUID());\n const [isRegistered, setIsRegistered] = useState(window === window.top);\n\n const {setLang} = useContext(LangContext);\n\n const changeLangInAllFrames = (newLanguage: string) => {\n dispatch(\n {\n type: 'change-language',\n language: newLanguage,\n },\n 'all',\n );\n };\n\n const panelMessageHandlerRegistry = useRef<Record<string, MessageToPanelMessageHandler>>({});\n const addPanelMessageHandler: AddMessageToPanelMessageHandler = (\n type: string,\n handler: MessageToPanelMessageHandler,\n ) => {\n panelMessageHandlerRegistry.current[type] = handler;\n };\n\n const dispatch = useCallback<MessageDispatcher>(\n (message, frameId) => {\n if (window !== window.top) {\n window.parent.postMessage(encodeMessage({...message, __frameId: selfId.current}), '*');\n } else if (frameId && registry.current[frameId]) {\n (registry.current[frameId] as Window).postMessage(\n encodeMessage({...message, __frameId: selfId.current}),\n '*',\n );\n } else if (frameId === 'all') {\n Object.entries(registry.current).forEach(([id, frame]) => {\n if (id !== message.__frameId) {\n // DO not send the message to the sender\n frame.postMessage(encodeMessage({...message, __frameId: selfId.current}), '*');\n }\n });\n }\n },\n [registry.current],\n );\n\n const callCb = useCallback<CallCbFunction>(\n (path, data, frameId) => {\n dispatch({type: 'on-call-callback', path, data}, frameId);\n },\n [dispatch],\n );\n\n const unregister = () => {\n if (window !== window.top) {\n dispatch({type: 'unregister', id: selfId.current});\n }\n };\n\n const callbacksStore = useRef<Callbacks>({});\n const methods = useRef({\n ...getExposedMethods(callbacksStore, dispatch),\n unregister,\n changeLangInAllFrames,\n addPanelMessageHandler,\n });\n\n const getPanelIdFromEvent = (event: MessageEvent) => {\n const iFrames = window.document.getElementsByTagName('iframe');\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < iFrames.length; i++) {\n if (event.source === iFrames[i].contentWindow) {\n return iFrames[i].name;\n }\n }\n return null;\n };\n\n useEffect(() => {\n const clientHandlers = initClientHandlers(callCb, {...options, id: selfId.current}, callbacksStore);\n const onMessage = (event: MessageEvent) => {\n const message = decodeMessage(event.data);\n if (message === undefined) {\n return;\n }\n switch (message.type) {\n case 'register':\n const frames = window.frames;\n // Due to weak typing on Window, we cannot iterate directly on window.frames\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < frames.length; i++) {\n if (event.source === frames[i]) {\n registry.current[message.id] = frames[i];\n }\n }\n\n dispatch({type: 'is-registered', id: message.id}, message.id);\n break;\n case 'unregister':\n if (registry.current[message.id]) {\n delete registry.current[message.id];\n }\n break;\n case 'is-registered':\n setIsRegistered(true);\n break;\n case 'message-to-panel':\n panelMessageHandlerRegistry.current[message.data.type]?.(message.data.payload);\n if (window === window.top) {\n const target = message.data.target ?? 'all';\n dispatch(message, target);\n }\n break;\n case 'get-panel-config':\n clientHandlers(\n {\n ...message,\n data: {...message.data, panelId: getPanelIdFromEvent(event)},\n },\n dispatch,\n );\n break;\n default:\n if (message.type === 'change-language') {\n setLang(message.language);\n } else {\n clientHandlers(message, dispatch);\n }\n break;\n }\n };\n\n window.addEventListener('message', onMessage);\n\n if (window !== window.top) {\n // Register the message handler for the parent window\n dispatch({type: 'register', id: selfId.current});\n }\n\n return () => {\n window.removeEventListener('message', onMessage);\n };\n }, []);\n\n return {\n ...methods.current,\n isRegistered,\n };\n};\n"]}
1
+ {"version":3,"file":"useIFrameMessenger.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/useIFrameMessenger.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AASzC,OAAO,EAAC,aAAa,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAItG;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAoC,EAAE,EAAE;IACvE,MAAM,QAAQ,GAAG,MAAM,CAAyB,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;IAExE,MAAM,EAAC,OAAO,EAAC,GAAG,UAAU,CA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rD,QAAQ,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,EAAC,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACH,GAAG,OAAO,CAAC,OAAO;QAClB,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 {useCallback, useContext, useEffect, useRef, useState} from 'react';\nimport {LangContext} from '_ui/contexts';\nimport {\n type AddMessageToPanelMessageHandler,\n type MessageToPanelMessageHandler,\n type Callbacks,\n type CallCbFunction,\n type IUseIFrameMessengerOptions,\n type MessageDispatcher,\n} from './types';\nimport {encodeMessage, decodeMessage, getExposedMethods, initClientHandlers} from './messageHandlers';\n\nexport {IUseIFrameMessengerOptions};\n\n/**\n * Core hook of the IFrameMessenger system. Registers a single `window.addEventListener('message')`\n * and manages a registry of connected child frames.\n *\n * **Usage:**\n * - Top-level apps (e.g. app-studio): use via `IFrameMessengerProvider` which calls this hook once as a singleton.\n * - Client apps (child iframes): use `useIFrameMessengerClient` instead.\n *\n * **`onMessageReceived` option:** when provided, all non-system messages are delegated to this callback\n * instead of being handled locally. Used by `IFrameMessengerProvider` to route messages to the correct\n * per-iframe handlers without registering multiple listeners.\n */\nexport const useIFrameMessenger = (options?: IUseIFrameMessengerOptions) => {\n const registry = useRef<Record<string, Window>>({});\n const selfId = useRef(options?.id ?? window.crypto.randomUUID());\n const [isRegistered, setIsRegistered] = useState(window === window.top);\n\n const {setLang} = useContext(LangContext);\n\n const changeLangInAllFrames = (newLanguage: string) => {\n dispatch(\n {\n type: 'change-language',\n language: newLanguage,\n },\n 'all',\n );\n };\n\n const panelMessageHandlerRegistry = useRef<Record<string, MessageToPanelMessageHandler>>({});\n const addPanelMessageHandler: AddMessageToPanelMessageHandler = (\n type: string,\n handler: MessageToPanelMessageHandler,\n ) => {\n panelMessageHandlerRegistry.current[type] = handler;\n };\n\n const dispatch = useCallback<MessageDispatcher>(\n (message, frameId) => {\n if (window !== window.top) {\n window.parent.postMessage(encodeMessage({...message, __frameId: selfId.current}), '*');\n } else if (frameId && registry.current[frameId]) {\n (registry.current[frameId] as Window).postMessage(\n encodeMessage({...message, __frameId: selfId.current}),\n '*',\n );\n } else if (frameId === 'all') {\n Object.entries(registry.current).forEach(([id, frame]) => {\n if (id !== message.__frameId) {\n // DO not send the message to the sender\n frame.postMessage(encodeMessage({...message, __frameId: selfId.current}), '*');\n }\n });\n }\n },\n [registry.current],\n );\n\n const callCb = useCallback<CallCbFunction>(\n (path, data, frameId) => {\n dispatch({type: 'on-call-callback', path, data}, frameId);\n },\n [dispatch],\n );\n\n const unregister = () => {\n if (window !== window.top) {\n dispatch({type: 'unregister', id: selfId.current});\n }\n };\n\n const callbacksStore = useRef<Callbacks>({});\n const methods = useRef({\n ...getExposedMethods(callbacksStore, dispatch),\n unregister,\n changeLangInAllFrames,\n addPanelMessageHandler,\n });\n\n const getPanelIdFromEvent = (event: MessageEvent) => {\n const iFrames = window.document.getElementsByTagName('iframe');\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < iFrames.length; i++) {\n if (event.source === iFrames[i].contentWindow) {\n return iFrames[i].name;\n }\n }\n return null;\n };\n\n useEffect(() => {\n const clientHandlers = initClientHandlers(callCb, {...options, id: selfId.current}, callbacksStore);\n const onMessage = (event: MessageEvent) => {\n const message = decodeMessage(event.data);\n if (message === undefined) {\n return;\n }\n switch (message.type) {\n case 'register':\n const frames = window.frames;\n // Due to weak typing on Window, we cannot iterate directly on window.frames\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < frames.length; i++) {\n if (event.source === frames[i]) {\n registry.current[message.id] = frames[i];\n }\n }\n\n dispatch({type: 'is-registered', id: message.id}, message.id);\n break;\n case 'unregister':\n if (registry.current[message.id]) {\n delete registry.current[message.id];\n }\n break;\n case 'is-registered':\n setIsRegistered(true);\n break;\n case 'message-to-panel':\n panelMessageHandlerRegistry.current[message.data.type]?.(message.data.payload);\n if (window === window.top) {\n const target = message.data.target ?? 'all';\n dispatch(message, target);\n }\n break;\n default:\n if (message.type === 'change-language') {\n setLang(message.language);\n } else if (options?.onMessageReceived) {\n // Singleton mode: delegate routing to the Provider (IFrameMessengerProvider).\n // The Provider resolves which iframe sent the message and calls the matching handlers.\n options.onMessageReceived(\n event.source as Window,\n message,\n getPanelIdFromEvent(event),\n dispatch,\n callCb,\n callbacksStore,\n );\n } else {\n // Legacy / client mode: handle messages directly with local clientHandlers.\n // get-panel-config needs panelId enriched before dispatch.\n const enrichedMessage =\n message.type === 'get-panel-config'\n ? {...message, data: {...message.data, panelId: getPanelIdFromEvent(event)}}\n : message;\n clientHandlers(enrichedMessage, dispatch);\n }\n break;\n }\n };\n\n window.addEventListener('message', onMessage);\n\n if (window !== window.top) {\n // Register the message handler for the parent window\n dispatch({type: 'register', id: selfId.current});\n }\n\n return () => {\n window.removeEventListener('message', onMessage);\n };\n }, []);\n\n return {\n ...methods.current,\n isRegistered,\n };\n};\n"]}
@@ -0,0 +1,13 @@
1
+ import { type ReactNode } from 'react';
2
+ /**
3
+ * Singleton Provider for the IFrameMessenger system.
4
+ * Must be mounted once above all `PanelCustom` instances.
5
+ *
6
+ * Owns a single `window.addEventListener('message')` (via `useIFrameMessenger`)
7
+ * and routes incoming messages to the correct iframe's handlers using `handlersMap`.
8
+ *
9
+ * Each `PanelCustom` registers/deregisters its handlers via `useIFrameMessengerHandlers`.
10
+ */
11
+ export declare const IFrameMessengerProvider: ({ children }: {
12
+ children: ReactNode;
13
+ }) => JSX.Element;
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
3
+ // This file is released under LGPL V3
4
+ // License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
5
+ import { useCallback, useMemo, useRef } from 'react';
6
+ import { useIFrameMessenger } from './useIFrameMessenger';
7
+ import { initClientHandlers } from './messageHandlers';
8
+ import { IFrameMessengerContext } from './iFrameMessengerContext';
9
+ /**
10
+ * Singleton Provider for the IFrameMessenger system.
11
+ * Must be mounted once above all `PanelCustom` instances.
12
+ *
13
+ * Owns a single `window.addEventListener('message')` (via `useIFrameMessenger`)
14
+ * and routes incoming messages to the correct iframe's handlers using `handlersMap`.
15
+ *
16
+ * Each `PanelCustom` registers/deregisters its handlers via `useIFrameMessengerHandlers`.
17
+ */
18
+ export const IFrameMessengerProvider = ({ children }) => {
19
+ // Maps each iframe's RefObject to its set of handlers.
20
+ // Using RefObject as key (instead of Window) avoids timing issues: contentWindow
21
+ // may not be available yet when the iframe mounts and registers its handlers.
22
+ const handlersMap = useRef(new Map());
23
+ // Called by useIFrameMessenger for every non-system message.
24
+ // Finds the handlers registered for the sender iframe and dispatches the message to them.
25
+ const onMessageReceived = useCallback((senderWindow, message, panelId, dispatch, callCb, callbacksStore) => {
26
+ // event.source is null when the sender iframe was unmounted before the message
27
+ // was processed — the browser clears the reference on iframe removal.
28
+ if (!senderWindow) {
29
+ return;
30
+ }
31
+ let matchedHandlers;
32
+ for (const [ref, handlers] of handlersMap.current) {
33
+ if (ref.current?.contentWindow === senderWindow) {
34
+ matchedHandlers = handlers;
35
+ break;
36
+ }
37
+ }
38
+ // No registered handlers for this sender: either the iframe called unregisterHandlers
39
+ // before its last message was processed (race condition on unmount), or the message
40
+ // originates from an unrelated frame that passed decodeMessage validation.
41
+ if (!matchedHandlers) {
42
+ return;
43
+ }
44
+ const enrichedMessage = message.type === 'get-panel-config' ? { ...message, data: { ...message.data, panelId } } : message;
45
+ const clientHandlers = initClientHandlers(callCb, { handlers: matchedHandlers }, callbacksStore);
46
+ clientHandlers(enrichedMessage, dispatch);
47
+ }, []);
48
+ const { changeLangInAllFrames } = useIFrameMessenger({ onMessageReceived });
49
+ const registerHandlers = useCallback((iframeRef, handlers) => {
50
+ handlersMap.current.set(iframeRef, handlers);
51
+ const cleanup = () => {
52
+ handlersMap.current.delete(iframeRef);
53
+ };
54
+ return cleanup;
55
+ }, []);
56
+ const contextValue = useMemo(() => ({ registerHandlers, changeLangInAllFrames }), []);
57
+ return _jsx(IFrameMessengerContext.Provider, { value: contextValue, children: children });
58
+ };
59
+ //# sourceMappingURL=useIFrameMessengerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIFrameMessengerContext.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/useIFrameMessengerContext.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAwD,WAAW,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC1G,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAUrD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAC,QAAQ,EAAwB,EAAE,EAAE;IACzE,uDAAuD;IACvD,iFAAiF;IACjF,8EAA8E;IAC9E,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,EAAwE,CAAC,CAAC;IAE5G,6DAA6D;IAC7D,0FAA0F;IAC1F,MAAM,iBAAiB,GAAG,WAAW,CACjC,CACI,YAA2B,EAC3B,OAAgB,EAChB,OAAsB,EACtB,QAA2B,EAC3B,MAAsB,EACtB,cAA2C,EAC7C,EAAE;QACA,+EAA+E;QAC/E,sEAAsE;QACtE,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,OA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AgB,EAAE,qBAAqB,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpF,OAAO,KAAC,sBAAsB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAAmC,CAAC;AAC9G,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 MutableRefObject, type ReactNode, type RefObject, useCallback, useMemo, useRef} from 'react';\nimport {useIFrameMessenger} from './useIFrameMessenger';\nimport {initClientHandlers} from './messageHandlers';\nimport {\n type Callbacks,\n type CallCbFunction,\n type Message,\n type MessageDispatcher,\n type IUseIFrameMessengerOptions,\n type RegisterHandlers,\n type UnregisterHandlers,\n} from './types';\nimport {IFrameMessengerContext} from './iFrameMessengerContext';\n\n/**\n * Singleton Provider for the IFrameMessenger system.\n * Must be mounted once above all `PanelCustom` instances.\n *\n * Owns a single `window.addEventListener('message')` (via `useIFrameMessenger`)\n * and routes incoming messages to the correct iframe's handlers using `handlersMap`.\n *\n * Each `PanelCustom` registers/deregisters its handlers via `useIFrameMessengerHandlers`.\n */\nexport const IFrameMessengerProvider = ({children}: {children: ReactNode}) => {\n // Maps each iframe's RefObject to its set of handlers.\n // Using RefObject as key (instead of Window) avoids timing issues: contentWindow\n // may not be available yet when the iframe mounts and registers its handlers.\n const handlersMap = useRef(new Map<RefObject<HTMLIFrameElement>, IUseIFrameMessengerOptions['handlers']>());\n\n // Called by useIFrameMessenger for every non-system message.\n // Finds the handlers registered for the sender iframe and dispatches the message to them.\n const onMessageReceived = useCallback(\n (\n senderWindow: Window | null,\n message: Message,\n panelId: string | null,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n callbacksStore: MutableRefObject<Callbacks>,\n ) => {\n // event.source is null when the sender iframe was unmounted before the message\n // was processed — the browser clears the reference on iframe removal.\n if (!senderWindow) {\n return;\n }\n\n let matchedHandlers: IUseIFrameMessengerOptions['handlers'] | undefined;\n for (const [ref, handlers] of handlersMap.current) {\n if (ref.current?.contentWindow === senderWindow) {\n matchedHandlers = handlers;\n break;\n }\n }\n\n // No registered handlers for this sender: either the iframe called unregisterHandlers\n // before its last message was processed (race condition on unmount), or the message\n // originates from an unrelated frame that passed decodeMessage validation.\n if (!matchedHandlers) {\n return;\n }\n\n const enrichedMessage =\n message.type === 'get-panel-config' ? {...message, data: {...message.data, panelId}} : message;\n\n const clientHandlers = initClientHandlers(callCb, {handlers: matchedHandlers}, callbacksStore);\n clientHandlers(enrichedMessage, dispatch);\n },\n [],\n );\n\n const {changeLangInAllFrames} = useIFrameMessenger({onMessageReceived});\n\n const registerHandlers: RegisterHandlers = useCallback((iframeRef, handlers) => {\n handlersMap.current.set(iframeRef, handlers);\n\n const cleanup = () => {\n handlersMap.current.delete(iframeRef);\n };\n\n return cleanup;\n }, []);\n\n const contextValue = useMemo(() => ({registerHandlers, changeLangInAllFrames}), []);\n\n return <IFrameMessengerContext.Provider value={contextValue}>{children}</IFrameMessengerContext.Provider>;\n};\n"]}
@@ -0,0 +1,13 @@
1
+ import { type RefObject } from 'react';
2
+ import { type IUseIFrameMessengerOptions } from './types';
3
+ /**
4
+ * Per-iframe hook for `PanelCustom`. Registers the iframe's handlers into the singleton
5
+ * `IFrameMessengerProvider` and cleans them up on unmount.
6
+ *
7
+ * Returns `changeLangInFrame` which posts `change-language` directly to this specific iframe's
8
+ * `contentWindow` — intentionally NOT using the shared registry to avoid broadcasting the language
9
+ * change to all other open iframes (which would cause unintended refreshes).
10
+ */
11
+ export declare const useIFrameMessengerHandlers: (iframeRef: RefObject<HTMLIFrameElement>, handlers: IUseIFrameMessengerOptions["handlers"]) => {
12
+ changeLangInFrame: (language: string) => void;
13
+ };
@@ -0,0 +1,29 @@
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 { useCallback, useContext, useEffect } from 'react';
5
+ import { IFrameMessengerContext } from './iFrameMessengerContext';
6
+ import { encodeMessage } from './messageHandlers';
7
+ /**
8
+ * Per-iframe hook for `PanelCustom`. Registers the iframe's handlers into the singleton
9
+ * `IFrameMessengerProvider` and cleans them up on unmount.
10
+ *
11
+ * Returns `changeLangInFrame` which posts `change-language` directly to this specific iframe's
12
+ * `contentWindow` — intentionally NOT using the shared registry to avoid broadcasting the language
13
+ * change to all other open iframes (which would cause unintended refreshes).
14
+ */
15
+ export const useIFrameMessengerHandlers = (iframeRef, handlers) => {
16
+ const { registerHandlers } = useContext(IFrameMessengerContext);
17
+ // Register on mount, deregister on unmount via the returned cleanup function.
18
+ useEffect(() => registerHandlers(iframeRef, handlers), []);
19
+ // Post directly to contentWindow instead of going through the registry,
20
+ // which would broadcast to all registered iframes.
21
+ const changeLangInFrame = useCallback((language) => {
22
+ if (iframeRef.current?.contentWindow) {
23
+ const message = { type: 'change-language', language };
24
+ iframeRef.current.contentWindow.postMessage(encodeMessage(message), '*');
25
+ }
26
+ }, [iframeRef]);
27
+ return { changeLangInFrame };
28
+ };
29
+ //# sourceMappingURL=useIFrameMessengerHandlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useIFrameMessengerHandlers.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/useIFrameMessengerHandlers.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAiB,MAAM,OAAO,CAAC;AACzE,OAAO,EAAC,sBAAsB,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAGhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACtC,SAAuC,EACvC,QAAgD,EAClD,EAAE;IACA,MAAM,EAAC,gBAAgB,EAAC,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAE9D,8EAA8E;IAC9E,SAAS,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;IAE3D,wEAAwE;IACxE,mDAAmD;IACnD,MAAM,iBAAiB,GAAG,WAAW,CACjC,CAAC,QAAgB,EAAE,EAAE;QACjB,IAAI,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,CAAC;YACnC,MAAM,OAAO,GAA0B,EAAC,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAC,CAAC;YAC3E,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC,EACD,CAAC,SAAS,CAAC,CACd,CAAC;IAEF,OAAO,EAAC,iBAAiB,EAAC,CAAC;AAC/B,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 {useCallback, useContext, useEffect, type RefObject} from 'react';\nimport {IFrameMessengerContext} from './iFrameMessengerContext';\nimport {encodeMessage} from './messageHandlers';\nimport {type ChangeLanguageMessage, type IUseIFrameMessengerOptions} from './types';\n\n/**\n * Per-iframe hook for `PanelCustom`. Registers the iframe's handlers into the singleton\n * `IFrameMessengerProvider` and cleans them up on unmount.\n *\n * Returns `changeLangInFrame` which posts `change-language` directly to this specific iframe's\n * `contentWindow` — intentionally NOT using the shared registry to avoid broadcasting the language\n * change to all other open iframes (which would cause unintended refreshes).\n */\nexport const useIFrameMessengerHandlers = (\n iframeRef: RefObject<HTMLIFrameElement>,\n handlers: IUseIFrameMessengerOptions['handlers'],\n) => {\n const {registerHandlers} = useContext(IFrameMessengerContext);\n\n // Register on mount, deregister on unmount via the returned cleanup function.\n useEffect(() => registerHandlers(iframeRef, handlers), []);\n\n // Post directly to contentWindow instead of going through the registry,\n // which would broadcast to all registered iframes.\n const changeLangInFrame = useCallback(\n (language: string) => {\n if (iframeRef.current?.contentWindow) {\n const message: ChangeLanguageMessage = {type: 'change-language', language};\n iframeRef.current.contentWindow.postMessage(encodeMessage(message), '*');\n }\n },\n [iframeRef],\n );\n\n return {changeLangInFrame};\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedTranslation.js","sourceRoot":"","sources":["../../../../src/hooks/useSharedTranslation/__mocks__/useSharedTranslation.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAkB;IAC5B,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,IAAI,CAAC;KACtB;IACD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEzG,eAAe,GAAG,EAAE;IAChB,MAAM,IAAI,GAAG,EAAC,CAAC,EAAE,KAAuB,EAAE,IAAI,EAAE,QAAgB,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAE/E,OAAO,IAAI,CAAC;AAChB,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 Mockify} from '@leav/utils';\nimport {type TFunction, type i18n} from 'i18next';\n\nconst mockI18n: Mockify<i18n> = {\n language: 'fr',\n options: {\n fallbackLng: ['en'],\n },\n changeLanguage: jest.fn(),\n};\n\nconst mockT = (arg, variables) => `${[arg, ...(!!variables ? Object.values(variables) : [])].join('|')}`;\n\nexport default () => {\n const mock = {t: mockT as TFunction<any>, i18n: mockI18n as i18n, ready: true};\n\n return mock;\n};\n"]}
1
+ {"version":3,"file":"useSharedTranslation.js","sourceRoot":"","sources":["../../../../src/hooks/useSharedTranslation/__mocks__/useSharedTranslation.ts"],"names":[],"mappings":"AAMA,MAAM,QAAQ,GAAkB;IAC5B,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE;QACL,WAAW,EAAE,CAAC,IAAI,CAAC;KACtB;IACD,cAAc,EAAE,IAAI,CAAC,EAAE,EAAE;CAC5B,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAEzG,eAAe,GAAG,EAAE;IAChB,MAAM,IAAI,GAAG,EAAC,CAAC,EAAE,KAAuB,EAAE,IAAI,EAAE,QAAgB,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;IAE/E,OAAO,IAAI,CAAC;AAChB,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 Mockify} from '_ui/__mocks__/utils';\nimport {type TFunction, type i18n} from 'i18next';\n\nconst mockI18n: Mockify<i18n> = {\n language: 'fr',\n options: {\n fallbackLng: ['en'],\n },\n changeLanguage: jest.fn(),\n};\n\nconst mockT = (arg, variables) => `${[arg, ...(!!variables ? Object.values(variables) : [])].join('|')}`;\n\nexport default () => {\n const mock = {t: mockT as TFunction<any>, i18n: mockI18n as i18n, ready: true};\n\n return mock;\n};\n"]}
@@ -730,17 +730,17 @@
730
730
  "deactivate_message": "Elements deleted",
731
731
  "deactivate_description": "{{count, number}}/{{total, number}} element for which you have permissions have been deleted. Others remain unchanged.",
732
732
  "editAttribute": "Edit an attribute",
733
- "editAttribute_description_one": "{{count, number}} element will be updated.",
734
- "editAttribute_description_other": "{{total, number}} elements will be updated.",
733
+ "editAttribute_description_one": "{{count, number}} element selected",
734
+ "editAttribute_description_other": "{{count, number}} elements selected",
735
735
  "editAttribute_attribute_select_title": "Attribute to edit",
736
736
  "editAttribute_attribute_select_placeholder": "Select an attribute",
737
- "editAttribute_value_select_placeholder": "Select a value",
738
737
  "editAttribute_value_occurrences_to_edit_one": "{{count, number}} element to edit",
739
738
  "editAttribute_value_occurrences_to_edit_other": "{{count, number}} elements to edit",
740
739
  "editAttribute_value_undefined": "Undefined",
741
740
  "editAttribute_value_do_not_change": "Do not change",
742
741
  "editAttribute_submit_notification_title": "Bulk edit request",
743
- "editAttribute_submit_notification_description": "Your request to edit {{counter, number}} items has been received. You will be notified once the operation is complete.",
742
+ "editAttribute_submit_notification_description_one": "Your request to edit {{count, number}} item has been received. You will be notified once the operation is complete.",
743
+ "editAttribute_submit_notification_description_other": "Your request to edit {{count, number}} items has been received. You will be notified once the operation is complete.",
744
744
  "editAttribute_submit_error": "An error occurred while requesting a bulk edit. Please contact an administrator.",
745
745
  "export": "Export",
746
746
  "export_message": "Export request",
@@ -756,6 +756,8 @@
756
756
  "toggle_selection": {
757
757
  "select_page_one": "Select visible item ({{count, number}})",
758
758
  "select_page_other": "Select visible items ({{count, number}})",
759
+ "deselect_page_one": "Deselect visible item ({{count, number}})",
760
+ "deselect_page_other": "Deselect visible items ({{count, number}})",
759
761
  "select_all": "Select all items ({{count, number}})",
760
762
  "deselect_all": "Deselect all items"
761
763
  },
@@ -730,18 +730,18 @@
730
730
  "deactivate_message": "Élements supprimés",
731
731
  "deactivate_description": "{{count, number}}/{{total, number}} éléments pour lesquels vous disposez des permissions nécessaires ont été supprimés. Les autres éléments restent inchangés.",
732
732
  "editAttribute": "Modifier un attribut",
733
- "editAttribute_description_one": "{{count, number}} élément à modifier",
734
- "editAttribute_description_other": "{{count, number}} éléments à modifier",
733
+ "editAttribute_description_one": "{{count, number}} élément sélectionné",
734
+ "editAttribute_description_other": "{{count, number}} éléments sélectionnés",
735
735
  "editAttribute_attribute_select_title": "Attribut à modifier",
736
736
  "editAttribute_attribute_select_placeholder": "Sélectionnez un attribut",
737
- "editAttribute_value_select_placeholder": "Sélectionnez une valeur",
738
737
  "editAttribute_value_occurrences_to_edit_one": "{{count, number}} élément à traiter",
739
738
  "editAttribute_value_occurrences_to_edit_other": "{{count, number}} éléments à traiter",
740
739
  "editAttribute_value_undefined": "Non défini",
741
740
  "editAttribute_value_do_not_change": "Ne pas changer",
742
741
  "editAttribute_submit_notification_title": "Demande de modification en masse",
743
- "editAttribute_submit_notification_description": "Votre demande de modification de {{counter, number}} éléments a bien été prise en compte. Vous serez notifié une fois l'opération terminée.",
744
- "editAttribute_submit_error": "Une erreur est survenue lors de la demande d'une modification en masse. Veuillez contacter un administrateur.",
742
+ "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 lopération terminée.",
743
+ "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.",
744
+ "editAttribute_submit_error": "Une erreur est survenue lors de la demande d’une modification en masse. Veuillez contacter un administrateur.",
745
745
  "export": "Exporter",
746
746
  "export_message": "Demande d'export",
747
747
  "export_description_one": "Votre demande d’export de {{total, number}} élément a bien été prise en compte. Vous recevrez une notification dès que le fichier sera prêt.",
@@ -754,8 +754,10 @@
754
754
  "add-link": "Ajouter",
755
755
  "replace-link": "Remplacer",
756
756
  "toggle_selection": {
757
- "select_page_one": "Sélectionner l’éléments visible ({{count, number}})",
757
+ "select_page_one": "Sélectionner l’élément visible ({{count, number}})",
758
758
  "select_page_other": "Sélectionner les éléments visibles ({{count, number}})",
759
+ "deselect_page_one": "Désélectionner l’élément visible ({{count, number}})",
760
+ "deselect_page_other": "Désélectionner les éléments visibles ({{count, number}})",
759
761
  "select_all": "Tout sélectionner ({{count, number}})",
760
762
  "deselect_all": "Tout désélectionner"
761
763
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leav/ui",
3
- "version": "1.12.0-a0a98764",
3
+ "version": "1.12.0-a3cb7513",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -28,10 +28,10 @@
28
28
  "@babel/preset-env": "7.29.2",
29
29
  "@babel/preset-react": "7.28.5",
30
30
  "@graphql-codegen/add": "5.0.3",
31
- "@graphql-codegen/cli": "6.2.1",
32
- "@graphql-codegen/typescript": "5.0.9",
33
- "@graphql-codegen/typescript-operations": "5.0.9",
34
- "@graphql-codegen/typescript-react-apollo": "4.4.1",
31
+ "@graphql-codegen/cli": "6.3.1",
32
+ "@graphql-codegen/typescript": "5.0.10",
33
+ "@graphql-codegen/typescript-operations": "5.1.0",
34
+ "@graphql-codegen/typescript-react-apollo": "4.4.2",
35
35
  "@testing-library/jest-dom": "5.17.0",
36
36
  "@testing-library/react": "14.3.1",
37
37
  "@testing-library/react-hooks": "8.0.1",
@@ -42,7 +42,7 @@
42
42
  "@types/lodash.isequal": "^4",
43
43
  "@types/react": "18.2.14",
44
44
  "@types/react-dom": "18.2.6",
45
- "aristid-ds": "15.2.0-8fcc4a3",
45
+ "aristid-ds": "15.3.1-05878d4",
46
46
  "babel-jest": "29.7.0",
47
47
  "graphql": "16.13.2",
48
48
  "i18next": "22.5.1",
@@ -56,11 +56,11 @@
56
56
  "ts-jest": "29.4.9",
57
57
  "tsc-alias": "1.8.16",
58
58
  "typescript": "5.9.3",
59
- "vite": "7.3.1"
59
+ "vite": "7.3.2"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@apollo/client": ">=3.8.1",
63
- "aristid-ds": "15.2.0-8fcc4a3",
63
+ "aristid-ds": "15.3.1-05878d4",
64
64
  "i18next": ">=22.5.1",
65
65
  "react": "^18.2.0",
66
66
  "react-dom": "^18.2.0",
@@ -77,7 +77,7 @@
77
77
  "@leav/utils": "1.12.0",
78
78
  "@uidotdev/usehooks": "2.4.1",
79
79
  "dayjs": "^1.11.13",
80
- "dompurify": "3.3.3",
80
+ "dompurify": "3.4.1",
81
81
  "html-react-parser": "4.2.10",
82
82
  "i18next-resources-to-backend": "1.1.4",
83
83
  "lodash.isequal": "4.5.0",
@@ -1,8 +0,0 @@
1
- import { type FunctionComponent } from 'react';
2
- import { type ITreeAttributeNodeValue } from './useListTreeAttributeValuesHook';
3
- export declare const EditTreeAttributeValueLine: FunctionComponent<{
4
- treeNodeValues: ITreeAttributeNodeValue[];
5
- valueOccurrenceNodeId: string | null;
6
- valueOccurrenceCount: number;
7
- setAttributeMapping: (before: string | null, after: string | null) => void;
8
- }>;
@@ -1,40 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
3
- import { KitIdCard, KitSelect, KitTypography } from 'aristid-ds';
4
- import styled from 'styled-components';
5
- const DivContainer = styled.div `
6
- display: grid;
7
- align-items: center;
8
- grid-template-columns: repeat(3, 1fr);
9
- grid-column-gap: calc(var(--general-spacing-l) * 1px);
10
- `;
11
- const UNDEFINED_VALUE = '__null__';
12
- const DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';
13
- export const EditTreeAttributeValueLine = ({ treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping }) => {
14
- const { t } = useSharedTranslation();
15
- const treeNodeValueOfOccurrence = treeNodeValues.find(node => node.id === valueOccurrenceNodeId);
16
- if (!treeNodeValueOfOccurrence) {
17
- return null;
18
- }
19
- const allowedDependentValues = treeNodeValueOfOccurrence ? treeNodeValueOfOccurrence.allowedDependentValues : null;
20
- const selectOptions = treeNodeValues
21
- .filter(treeNode => treeNode.id !== valueOccurrenceNodeId)
22
- .filter(treeNode => allowedDependentValues == null || // if no allowedDependentValues, all values are allowed
23
- !!allowedDependentValues.find(dv => dv.nodeId === treeNode.id))
24
- .map(treeNode => ({
25
- label: treeNode.label,
26
- value: treeNode.id || UNDEFINED_VALUE,
27
- }));
28
- if (selectOptions.length === 0 && valueOccurrenceNodeId) {
29
- selectOptions.push({
30
- label: t('explorer.massAction.editAttribute_value_do_not_change'),
31
- value: valueOccurrenceNodeId,
32
- });
33
- }
34
- return (_jsxs(DivContainer, { children: [_jsx(KitIdCard, { title: treeNodeValueOfOccurrence.label, color: treeNodeValueOfOccurrence.color || DEFAULT_ID_CARD_COLOR }), _jsx(KitTypography.Text, { children: t('explorer.massAction.editAttribute_value_occurrences_to_edit', {
35
- count: valueOccurrenceCount,
36
- }) }), _jsx(KitSelect, { options: selectOptions, size: "middle", allowClear: false, placeholder: t('explorer.massAction.editAttribute_value_select_placeholder'), onChange: value => {
37
- setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);
38
- } })] }));
39
- };
40
- //# sourceMappingURL=EditTreeAttributeValueLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EditTreeAttributeValueLine.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAE/D,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAGvC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;CAK9B,CAAC;AAEF,MAAM,eAAe,GAAG,UAAU,CAAC;AACnC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,0BAA0B,GAKlC,CAAC,EAAC,cAAc,E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,KAAC,aAAa,CAAC,IAAI,cACd,CAAC,CAAC,6DAA6D,EAAE;oBAC9D,KAAK,EAAE,oBAAoB;iBAC9B,CAAC,GACe,EACrB,KAAC,SAAS,IACN,OAAO,EAAE,aAAa,EACtB,IAAI,EAAC,QAAQ,EACb,UAAU,EAAE,KAAK,EACjB,WAAW,EAAE,CAAC,CAAC,4DAA4D,CAAC,EAC5E,QAAQ,EAAE,KAAK,CAAC,EAAE;oBACd,mBAAmB,CAAC,qBAAqB,EAAE,KAAK,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;gBACjG,CAAC,GACH,IACS,CAClB,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 AttributeDetailsTreeAttributeFragment} from '_ui/_gqlTypes';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitIdCard, KitSelect, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\nimport styled from 'styled-components';\nimport {type ITreeAttributeNodeValue} from './useListTreeAttributeValuesHook';\n\nconst DivContainer = styled.div`\n display: grid;\n align-items: center;\n grid-template-columns: repeat(3, 1fr);\n grid-column-gap: calc(var(--general-spacing-l) * 1px);\n`;\n\nconst UNDEFINED_VALUE = '__null__';\nconst DEFAULT_ID_CARD_COLOR = 'rgba(200, 200, 200, 1)';\n\nexport const EditTreeAttributeValueLine: FunctionComponent<{\n treeNodeValues: ITreeAttributeNodeValue[];\n valueOccurrenceNodeId: string | null;\n valueOccurrenceCount: number;\n setAttributeMapping: (before: string | null, after: string | null) => void;\n}> = ({treeNodeValues, valueOccurrenceNodeId, valueOccurrenceCount, setAttributeMapping}) => {\n const {t} = useSharedTranslation();\n\n const treeNodeValueOfOccurrence = treeNodeValues.find(node => node.id === valueOccurrenceNodeId);\n if (!treeNodeValueOfOccurrence) {\n return null;\n }\n\n const allowedDependentValues = treeNodeValueOfOccurrence ? treeNodeValueOfOccurrence.allowedDependentValues : null;\n\n const selectOptions = treeNodeValues\n .filter(treeNode => treeNode.id !== valueOccurrenceNodeId)\n .filter(\n treeNode =>\n allowedDependentValues == null || // if no allowedDependentValues, all values are allowed\n !!allowedDependentValues.find(dv => dv.nodeId === treeNode.id),\n )\n .map(treeNode => ({\n label: treeNode.label,\n value: treeNode.id || UNDEFINED_VALUE,\n }));\n\n if (selectOptions.length === 0 && valueOccurrenceNodeId) {\n selectOptions.push({\n label: t('explorer.massAction.editAttribute_value_do_not_change'),\n value: valueOccurrenceNodeId,\n });\n }\n\n return (\n <DivContainer>\n <KitIdCard\n title={treeNodeValueOfOccurrence.label}\n color={treeNodeValueOfOccurrence.color || DEFAULT_ID_CARD_COLOR}\n />\n <KitTypography.Text>\n {t('explorer.massAction.editAttribute_value_occurrences_to_edit', {\n count: valueOccurrenceCount,\n })}\n </KitTypography.Text>\n <KitSelect\n options={selectOptions}\n size=\"middle\"\n allowClear={false}\n placeholder={t('explorer.massAction.editAttribute_value_select_placeholder')}\n onChange={value => {\n setAttributeMapping(valueOccurrenceNodeId, value === UNDEFINED_VALUE ? null : value || null);\n }}\n />\n </DivContainer>\n );\n};\n"]}
@@ -1,17 +0,0 @@
1
- import { type RecordFilterInput } from '../../../../_gqlTypes';
2
- export type ValuesOccurrences = {
3
- noValueCount: number;
4
- occurrences: Array<{
5
- count: number;
6
- value: {
7
- id: string;
8
- };
9
- }>;
10
- loading?: boolean;
11
- };
12
- export type ValueOccurrence = ValuesOccurrences['occurrences'][0];
13
- export declare const useCountValuesOccurrencesHook: ({ attributeId, libraryId, recordFilters, }: {
14
- attributeId?: string;
15
- libraryId: string;
16
- recordFilters: RecordFilterInput[];
17
- }) => ValuesOccurrences;
@@ -1,42 +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 { useCountValuesOccurrencesLazyQuery } from '../../../../_gqlTypes';
5
- import { useEffect, useMemo } from 'react';
6
- export const useCountValuesOccurrencesHook = ({ attributeId, libraryId, recordFilters, }) => {
7
- const [countValuesOccurrences, { data: valuesOccurrences, loading }] = useCountValuesOccurrencesLazyQuery({
8
- fetchPolicy: 'no-cache',
9
- nextFetchPolicy: 'no-cache',
10
- });
11
- useEffect(() => {
12
- if (attributeId) {
13
- countValuesOccurrences({
14
- variables: {
15
- attribute: attributeId,
16
- library: libraryId,
17
- recordFilters,
18
- },
19
- });
20
- }
21
- }, [attributeId, libraryId, recordFilters]);
22
- const noValueCount = useMemo(() => {
23
- if (!valuesOccurrences) {
24
- return 0;
25
- }
26
- return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;
27
- }, [valuesOccurrences]);
28
- const occurrences = useMemo(() => {
29
- if (!valuesOccurrences) {
30
- return [];
31
- }
32
- return (valuesOccurrences.listDistinctValues
33
- ?.filter(v => 'treeNode' in v && v.treeNode !== null)
34
- .map(v => ({ count: v.count, value: { id: v.treeNode.id } })) || []);
35
- }, [valuesOccurrences]);
36
- return {
37
- occurrences,
38
- noValueCount,
39
- loading,
40
- };
41
- };
42
- //# sourceMappingURL=useCountValuesOccurrencesHook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useCountValuesOccurrencesHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,kCAAkC,EAAC,MAAM,eAAe,CAAC;AACzF,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAQzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,EAC1C,WAAW,EACX,SAAS,E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QAAQ,CAAC,EAAE,EAAC,EAAC,CAAC,CAAC,IAAI,EAAE,CACpG,CAAC;IACN,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO;QACH,WAAW;QACX,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, useCountValuesOccurrencesLazyQuery} from '_ui/_gqlTypes';\nimport {useEffect, useMemo} from 'react';\n\nexport type ValuesOccurrences = {\n noValueCount: number;\n occurrences: Array<{count: number; value: {id: string}}>;\n loading?: boolean;\n};\nexport type ValueOccurrence = ValuesOccurrences['occurrences'][0];\nexport const useCountValuesOccurrencesHook = ({\n attributeId,\n libraryId,\n recordFilters,\n}: {\n attributeId?: string;\n libraryId: string;\n recordFilters: RecordFilterInput[];\n}): ValuesOccurrences => {\n const [countValuesOccurrences, {data: valuesOccurrences, loading}] = useCountValuesOccurrencesLazyQuery({\n fetchPolicy: 'no-cache',\n nextFetchPolicy: 'no-cache',\n });\n\n useEffect(() => {\n if (attributeId) {\n countValuesOccurrences({\n variables: {\n attribute: attributeId,\n library: libraryId,\n recordFilters,\n },\n });\n }\n }, [attributeId, libraryId, recordFilters]);\n\n const noValueCount = useMemo(() => {\n if (!valuesOccurrences) {\n return 0;\n }\n return valuesOccurrences.listDistinctValues?.find(v => !('treeNode' in v) || v.treeNode === null)?.count || 0;\n }, [valuesOccurrences]);\n\n const occurrences = useMemo(() => {\n if (!valuesOccurrences) {\n return [];\n }\n return (\n valuesOccurrences.listDistinctValues\n ?.filter(v => 'treeNode' in v && v.treeNode !== null)\n .map(v => ({count: v.count, value: {id: (v as {treeNode: {id: string}}).treeNode.id}})) || []\n );\n }, [valuesOccurrences]);\n\n return {\n occurrences,\n noValueCount,\n loading,\n };\n};\n"]}
@@ -1,5 +0,0 @@
1
- import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
2
- export type EditableAttributes = AttributeDetailsTreeAttributeFragment[];
3
- export declare const useListEditableAttributeHook: ({ libraryId }: {
4
- libraryId: string;
5
- }) => EditableAttributes;
@@ -1,20 +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 { AttributeType } from '../../../../_gqlTypes';
5
- import { useMemo } from 'react';
6
- import { useAttributeDetailsData } from '../../manage-view-settings/_shared/useAttributeDetailsData';
7
- export const useListEditableAttributeHook = ({ libraryId }) => {
8
- const { attributeDetailsById } = useAttributeDetailsData(libraryId);
9
- const treeMonoValuedAttributes = useMemo(() => Object.values(attributeDetailsById).filter(attr => {
10
- const dependenciesTreeAttributes = ('permissions_conf_dependent_values' in attr &&
11
- attr.permissions_conf_dependent_values?.dependenciesTreeAttributes) ||
12
- [];
13
- const dependentOnItself = dependenciesTreeAttributes.length === 1 && dependenciesTreeAttributes[0].id === attr.id;
14
- return (attr.type === AttributeType.tree &&
15
- !attr.multiple_values &&
16
- (dependenciesTreeAttributes.length === 0 || dependentOnItself));
17
- }), [attributeDetailsById]);
18
- return treeMonoValuedAttributes;
19
- };
20
- //# sourceMappingURL=useListEditableAttributeHook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useListEditableAttributeHook.js","sourceRoot":"","sources":["../../../../../src/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAA6C,aAAa,EAAC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAC,uBAAuB,EAAC,MAAM,4DAA4D,CAAC;AAGnG,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,EAAC,SAAS,EAAsB,EAAsB,EAAE;IACjG,MAAM,EAAC,oBAAoB,EAAC,GAAG,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,wBAAwB,GAA4C,OAAO,CAC7E,GAAG,EAAE,CACD,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QAC9C,MAAM,0BAA0B,GAC5B,CAAC,mCAAmC,IAAI,IAAI;YACxC,IAAI,CAAC,iCAAiC,EAAE,0BAA0B,CAAC;YACvE,EAAE,CAAC;QACP,MAAM,iBAAiB,GACnB,0BAA0B,CAAC,MAAM,KAAK,CAAC,IAAI,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC5F,OAAO,CACH,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI;YAChC,CAAC,IAAI,CAAC,eAAe;YACrB,CAAC,0BAA0B,CAAC,MAAM,KAAK,CAAC,IAAI,iBAAiB,CAAC,CACjE,CAAC;IACN,CAAC,CAAC,EACN,CAAC,oBAAoB,CAAC,CACzB,CAAC;IAEF,OAAO,wBAAwB,CAAC;AACpC,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 AttributeDetailsTreeAttributeFragment, AttributeType} from '_ui/_gqlTypes';\nimport {useMemo} from 'react';\nimport {useAttributeDetailsData} from '../../manage-view-settings/_shared/useAttributeDetailsData';\n\nexport type EditableAttributes = AttributeDetailsTreeAttributeFragment[];\nexport const useListEditableAttributeHook = ({libraryId}: {libraryId: string}): EditableAttributes => {\n const {attributeDetailsById} = useAttributeDetailsData(libraryId);\n const treeMonoValuedAttributes: AttributeDetailsTreeAttributeFragment[] = useMemo(\n () =>\n Object.values(attributeDetailsById).filter(attr => {\n const dependenciesTreeAttributes =\n ('permissions_conf_dependent_values' in attr &&\n attr.permissions_conf_dependent_values?.dependenciesTreeAttributes) ||\n [];\n const dependentOnItself =\n dependenciesTreeAttributes.length === 1 && dependenciesTreeAttributes[0].id === attr.id;\n return (\n attr.type === AttributeType.tree &&\n !attr.multiple_values &&\n (dependenciesTreeAttributes.length === 0 || dependentOnItself)\n );\n }),\n [attributeDetailsById],\n );\n\n return treeMonoValuedAttributes;\n};\n"]}
@@ -1,12 +0,0 @@
1
- import { type AttributeDetailsTreeAttributeFragment } from '../../../../_gqlTypes';
2
- export interface ITreeAttributeNodeValue {
3
- id: string | null;
4
- label: string;
5
- color?: string | null;
6
- allowedDependentValues?: Array<{
7
- nodeId?: string | null;
8
- }> | null;
9
- }
10
- export declare const useListTreeAttributeValuesHook: ({ treeAttribute: treeAttribute, }: {
11
- treeAttribute: AttributeDetailsTreeAttributeFragment;
12
- }) => ITreeAttributeNodeValue[];
@@ -1,30 +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 { useAttributeWithValuesForMassEditionLazyQuery } from '../../../../_gqlTypes';
5
- import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
6
- import { useEffect, useMemo } from 'react';
7
- export const useListTreeAttributeValuesHook = ({ treeAttribute: treeAttribute, }) => {
8
- const { t } = useSharedTranslation();
9
- const [loadValues, { data: treeContent }] = useAttributeWithValuesForMassEditionLazyQuery();
10
- useEffect(() => {
11
- if (!treeAttribute.linked_tree) {
12
- throw new Error('Fatal: selected attribute not found');
13
- }
14
- loadValues({
15
- fetchPolicy: 'no-cache',
16
- variables: {
17
- attributeId: treeAttribute.id,
18
- },
19
- });
20
- }, [treeAttribute]);
21
- return useMemo(() => treeContent?.attributes?.list[0]?.tree_values?.map(treeValue => ({
22
- id: treeValue.node?.id || null,
23
- label: treeValue.node?.record.whoAmI.label ||
24
- treeValue.node?.record.whoAmI.id ||
25
- t('explorer.massAction.editAttribute_value_undefined'),
26
- color: treeValue.node?.record.whoAmI.color,
27
- allowedDependentValues: treeValue.allowedDependentValues || null,
28
- })) || [], [treeContent]);
29
- };
30
- //# sourceMappingURL=useListTreeAttributeValuesHook.js.map