@leav/ui 1.12.0-3 → 1.12.0-36d55f01

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 (97) 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 +129 -33
  5. package/dist/_gqlTypes/index.js +71 -3
  6. package/dist/_gqlTypes/index.js.map +1 -1
  7. package/dist/_queries/attributes/attributeDetailsFragment.js +3 -0
  8. package/dist/_queries/attributes/attributeDetailsFragment.js.map +1 -1
  9. package/dist/components/Explorer/DataView.js +39 -11
  10. package/dist/components/Explorer/DataView.js.map +1 -1
  11. package/dist/components/Explorer/Explorer.js +3 -2
  12. package/dist/components/Explorer/Explorer.js.map +1 -1
  13. package/dist/components/Explorer/TableNameCell.js +1 -4
  14. package/dist/components/Explorer/TableNameCell.js.map +1 -1
  15. package/dist/components/Explorer/_constants.d.ts +0 -1
  16. package/dist/components/Explorer/_constants.js +0 -1
  17. package/dist/components/Explorer/_constants.js.map +1 -1
  18. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +5 -9
  19. package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
  20. package/dist/components/Explorer/actions-mass/ResultsCount.js +2 -2
  21. package/dist/components/Explorer/actions-mass/ResultsCount.js.map +1 -1
  22. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
  23. package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
  24. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
  25. package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
  26. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +14 -6
  27. package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
  28. package/dist/components/Explorer/actions-mass/useMassActions.js +12 -6
  29. package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
  30. package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
  31. package/dist/components/Explorer/conditionsHelper.js.map +1 -1
  32. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +6 -4
  33. package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
  34. package/dist/components/Filters/_types.d.ts +3 -0
  35. package/dist/components/Filters/_types.js.map +1 -1
  36. package/dist/components/Filters/conditionsHelper.d.ts +2 -1
  37. package/dist/components/Filters/conditionsHelper.js.map +1 -1
  38. package/dist/components/Filters/context/filtersReducer.js +14 -1
  39. package/dist/components/Filters/context/filtersReducer.js.map +1 -1
  40. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  41. package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
  42. package/dist/components/Filters/useFilters.d.ts +198 -0
  43. package/dist/components/Filters/useTransformFilters.js +4 -2
  44. package/dist/components/Filters/useTransformFilters.js.map +1 -1
  45. package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
  46. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  47. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
  48. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
  49. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
  50. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
  51. package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
  52. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
  53. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  54. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
  55. package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map +1 -1
  56. package/dist/constants.d.ts +1 -0
  57. package/dist/constants.js +1 -0
  58. package/dist/constants.js.map +1 -1
  59. package/dist/hooks/index.d.ts +4 -0
  60. package/dist/hooks/index.js +4 -0
  61. package/dist/hooks/index.js.map +1 -1
  62. package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
  63. package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
  64. package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
  65. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
  66. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
  67. package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
  68. package/dist/hooks/useConfirmModal/index.d.ts +1 -0
  69. package/dist/hooks/useConfirmModal/index.js +5 -0
  70. package/dist/hooks/useConfirmModal/index.js.map +1 -0
  71. package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
  72. package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
  73. package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
  74. package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
  75. package/dist/hooks/useGetRecordIdCard/index.js +5 -0
  76. package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
  77. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
  78. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
  79. package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
  80. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
  81. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
  82. package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
  83. package/dist/hooks/useIFrameMessenger/types.d.ts +5 -2
  84. package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
  85. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +10 -2
  86. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +21 -8
  87. package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
  88. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
  89. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
  90. package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
  91. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
  92. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
  93. package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
  94. package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
  95. package/dist/locales/en/shared.json +2 -0
  96. package/dist/locales/fr/shared.json +3 -1
  97. package/package.json +13 -13
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useConfirmModal/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,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\nexport {useConfirmModal} from './useConfirmModal';\n"]}
@@ -0,0 +1,7 @@
1
+ import { KitModal } from 'aristid-ds';
2
+ type KitConfirmParams = Parameters<typeof KitModal.confirm>[0];
3
+ type ConfirmModalParams = Omit<KitConfirmParams, 'type' | 'icon' | 'width' | 'cancelText' | 'title' | 'content' | 'onOk'> & Required<Pick<KitConfirmParams, 'title' | 'content' | 'onOk'>>;
4
+ export declare const useConfirmModal: () => {
5
+ openConfirmModal: ({ title, content, onOk, dangerConfirm, okText, ...rest }: ConfirmModalParams) => void;
6
+ };
7
+ export {};
@@ -0,0 +1,25 @@
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 { KitModal } from 'aristid-ds';
5
+ import { useSharedTranslation } from '../useSharedTranslation';
6
+ export const useConfirmModal = () => {
7
+ const { t } = useSharedTranslation();
8
+ const openConfirmModal = ({ title, content, onOk, dangerConfirm, okText, ...rest }) => {
9
+ KitModal.confirm({
10
+ width: '100%',
11
+ style: { content: { width: '90vw', maxWidth: '656px' } },
12
+ type: 'confirm',
13
+ icon: false,
14
+ title,
15
+ content,
16
+ okText: okText ?? t('global.confirm') ?? undefined,
17
+ cancelText: t('global.cancel') ?? undefined,
18
+ onOk,
19
+ dangerConfirm,
20
+ ...rest,
21
+ });
22
+ };
23
+ return { openConfirmModal };
24
+ };
25
+ //# sourceMappingURL=useConfirmModal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConfirmModal.js","sourceRoot":"","sources":["../../../src/hooks/useConfirmModal/useConfirmModal.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,yBAAyB,CAAC;AAU7D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAChC,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,gBAAgB,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,EAAqB,EAAE,EAAE;QACpG,QAAQ,CAAC,OAAO,CAAC;YACb,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,EAAC,OAAO,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAC,EAAC;YACpD,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,KAAK;YACX,KAAK;YACL,OAAO;YACP,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,gBAAgB,CAAC,IAAI,SAAS;YAClD,UAAU,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,SAAS;YAC3C,IAAI;YACJ,aAAa;YACb,GAAG,IAAI;SACV,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO,EAAC,gBAAgB,EAAC,CAAC;AAC9B,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 {KitModal} from 'aristid-ds';\nimport {useSharedTranslation} from '../useSharedTranslation';\n\ntype KitConfirmParams = Parameters<typeof KitModal.confirm>[0];\n\ntype ConfirmModalParams = Omit<\n KitConfirmParams,\n 'type' | 'icon' | 'width' | 'cancelText' | 'title' | 'content' | 'onOk'\n> &\n Required<Pick<KitConfirmParams, 'title' | 'content' | 'onOk'>>;\n\nexport const useConfirmModal = () => {\n const {t} = useSharedTranslation();\n\n const openConfirmModal = ({title, content, onOk, dangerConfirm, okText, ...rest}: ConfirmModalParams) => {\n KitModal.confirm({\n width: '100%',\n style: {content: {width: '90vw', maxWidth: '656px'}},\n type: 'confirm',\n icon: false,\n title,\n content,\n okText: okText ?? t('global.confirm') ?? undefined,\n cancelText: t('global.cancel') ?? undefined,\n onOk,\n dangerConfirm,\n ...rest,\n });\n };\n\n return {openConfirmModal};\n};\n"]}
@@ -0,0 +1 @@
1
+ export { useGetRecordIdCard } from './useGetRecordIdCard';
@@ -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 { useGetRecordIdCard } from './useGetRecordIdCard';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/useGetRecordIdCard/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,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 {useGetRecordIdCard} from './useGetRecordIdCard';\n"]}
@@ -0,0 +1,18 @@
1
+ export declare const useGetRecordIdCard: (recordId: string, libraryId: string) => {
2
+ data: {
3
+ id: string;
4
+ whoAmI: {
5
+ id: string;
6
+ color?: string | null;
7
+ label?: string | null;
8
+ subLabel?: string | null;
9
+ preview?: import("@leav/utils").IPreviewScalar | null;
10
+ parentContext?: Array<{
11
+ id: string;
12
+ label?: string | null;
13
+ }> | null;
14
+ };
15
+ };
16
+ loading: boolean;
17
+ error: import("@apollo/client").ApolloError;
18
+ };
@@ -0,0 +1,20 @@
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 { useGetRecordIdCardQuery } from '../../_gqlTypes';
5
+ import { NEW_RECORD_ID } from '../../index';
6
+ export const useGetRecordIdCard = (recordId, libraryId) => {
7
+ const { data, loading, error } = useGetRecordIdCardQuery({
8
+ variables: {
9
+ id: recordId,
10
+ libraryId,
11
+ },
12
+ skip: !recordId || recordId === NEW_RECORD_ID || !libraryId,
13
+ });
14
+ return {
15
+ data: data?.records?.list?.[0],
16
+ loading,
17
+ error,
18
+ };
19
+ };
20
+ //# sourceMappingURL=useGetRecordIdCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetRecordIdCard.js","sourceRoot":"","sources":["../../../src/hooks/useGetRecordIdCard/useGetRecordIdCard.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,uBAAuB,EAAC,MAAM,eAAe,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,SAAiB,EAAE,EAAE;IACtE,MAAM,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,GAAG,uBAAuB,CAAC;QACnD,SAAS,EAAE;YACP,EAAE,EAAE,QAAQ;YACZ,SAAS;SACZ;QACD,IAAI,EAAE,CAAC,QAAQ,IAAI,QAAQ,KAAK,aAAa,IAAI,CAAC,SAAS;KAC9D,CAAC,CAAC;IAEH,OAAO;QACH,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9B,OAAO;QACP,KAAK;KACR,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 {useGetRecordIdCardQuery} from '_ui/_gqlTypes';\nimport {NEW_RECORD_ID} from '_ui/index';\n\nexport const useGetRecordIdCard = (recordId: string, libraryId: string) => {\n const {data, loading, error} = useGetRecordIdCardQuery({\n variables: {\n id: recordId,\n libraryId,\n },\n skip: !recordId || recordId === NEW_RECORD_ID || !libraryId,\n });\n\n return {\n data: data?.records?.list?.[0],\n loading,\n error,\n };\n};\n"]}
@@ -0,0 +1,6 @@
1
+ import { type RegisterHandlers } from './types';
2
+ export interface IIFrameMessengerContext {
3
+ registerHandlers: RegisterHandlers;
4
+ changeLangInAllFrames: (language: string) => void;
5
+ }
6
+ export declare const IFrameMessengerContext: import("react").Context<IIFrameMessengerContext>;
@@ -0,0 +1,8 @@
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
+ // Kept in a separate file from the Provider component to satisfy the
5
+ // react-refresh/only-export-components ESLint rule (Context is not a component).
6
+ import { createContext } from 'react';
7
+ export const IFrameMessengerContext = createContext(null);
8
+ //# sourceMappingURL=iFrameMessengerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iFrameMessengerContext.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/iFrameMessengerContext.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,qEAAqE;AACrE,iFAAiF;AACjF,OAAO,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAQpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAA0B,IAAI,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\n\n// Kept in a separate file from the Provider component to satisfy the\n// react-refresh/only-export-components ESLint rule (Context is not a component).\nimport {createContext} from 'react';\nimport {type RegisterHandlers} from './types';\n\nexport interface IIFrameMessengerContext {\n registerHandlers: RegisterHandlers;\n changeLangInAllFrames: (language: string) => void;\n}\n\nexport const IFrameMessengerContext = createContext<IIFrameMessengerContext>(null);\n"]}
@@ -1,4 +1,4 @@
1
- import { type RefObject, type ComponentProps, type Key, type JSXElementConstructor } from 'react';
1
+ import { type MutableRefObject, type RefObject, type ComponentProps, type Key, type JSXElementConstructor } from 'react';
2
2
  import type * as z from 'zod/v4';
3
3
  import { type KitNotification } from 'aristid-ds';
4
4
  import { type IKitConfirmDialog } from 'aristid-ds/dist/Kit/Feedback/Modal/types';
@@ -74,6 +74,7 @@ export type NavigateToPanelMessage = IMessageBase & {
74
74
  flapLibraryId?: LibraryId;
75
75
  flapPanelId?: FlapPanelId;
76
76
  queryParams?: Record<string, string> & {
77
+ redirectUrl?: string;
77
78
  formInitialValues?: Record<string, Array<AnyPrimitive | IRecordIdentity | ITreeNodeWithRecord>>;
78
79
  };
79
80
  };
@@ -112,7 +113,6 @@ export type OpenFlapPanelMessage = IMessageBase & {
112
113
  flapRecordId: string;
113
114
  flapLibraryId: LibraryId;
114
115
  flapPanelId: FlapPanelId;
115
- redirectUrl?: string;
116
116
  };
117
117
  };
118
118
  export type CloseFlapPanelMessage = IMessageBase & {
@@ -159,9 +159,12 @@ export type CallbackFunction = (...args: never[]) => void;
159
159
  export type Callbacks = Record<string, Record<string, CallbackFunction>>;
160
160
  export type MessageToPanelMessageHandler = (data: MessageToPanelMessage['data']['payload']) => void;
161
161
  export type AddMessageToPanelMessageHandler = (type: string, handler: MessageToPanelMessageHandler) => void;
162
+ export type UnregisterHandlers = () => void;
163
+ export type RegisterHandlers = (iframeRef: RefObject<HTMLIFrameElement>, handlers: IUseIFrameMessengerOptions['handlers']) => UnregisterHandlers;
162
164
  export interface IUseIFrameMessengerOptions {
163
165
  ref?: RefObject<HTMLIFrameElement>;
164
166
  id?: string;
167
+ onMessageReceived?: (senderWindow: Window | null, message: Message, panelId: string | null, dispatch: MessageDispatcher, callCb: CallCbFunction, callbacksStore: MutableRefObject<Callbacks>) => void;
165
168
  handlers?: {
166
169
  onModalConfirm?: (data: ModalConfirmMessage['data'], id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;
167
170
  onAlert?: (data: AlertMessage['data'], id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,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 RefObject, type ComponentProps, type Key, type JSXElementConstructor} from 'react';\nimport type * as z from 'zod/v4';\nimport {type KitNotification} from 'aristid-ds';\nimport {type IKitConfirmDialog} from 'aristid-ds/dist/Kit/Feedback/Modal/types';\nimport {type ToastedAlertProps} from 'aristid-ds/dist/Kit/Feedback/Alert/types';\nimport {\n type LibraryIdSchema,\n type WhereSchema,\n type PanelIdSchema,\n type PanelSchema,\n type PanelIFrameSchema,\n type FlapPanelIdSchema,\n type attributeExplorerPanelSchema,\n type baseExplorerPanelSchema,\n} from '_ui/hooks/useIFrameMessenger/schema';\nimport {type AnyPrimitive} from '@leav/utils';\nimport {type IRecordIdentity, type ITreeNodeWithRecord} from '_ui/types';\n\nexport const packetId = '__fromIframeMessenger';\n\nexport interface IEncodedMessage {\n payload: string;\n [packetId]: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ComponentPropsWithKey<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> =\n ComponentProps<T> & {\n key?: Key;\n };\n\nexport interface IMessageBase {\n __frameId?: string;\n}\n\nexport type ModalConfirmMessage = IMessageBase & {\n type: 'modal-confirm';\n id: string;\n data: IKitConfirmDialog;\n overrides?: string[];\n};\n\nexport type AlertMessage = IMessageBase & {\n type: 'alert';\n id: string;\n data: ToastedAlertProps;\n overrides?: string[];\n};\n\nexport type NotificationMessage = IMessageBase & {\n type: 'notification';\n id: string;\n data: ComponentPropsWithKey<typeof KitNotification>;\n overrides?: string[];\n};\n\nexport type ChangeLanguageMessage = IMessageBase & {\n type: 'change-language';\n language: string;\n};\n\nexport type SimpleMessage = IMessageBase & {\n type: 'message';\n id: string;\n data: unknown;\n};\n\nexport type RegisterMessage = IMessageBase & {\n type: 'register';\n id: string;\n};\n\nexport type UnregisterMessage = IMessageBase & {\n type: 'unregister';\n id: string;\n};\n\nexport type IsRegisteredMessage = IMessageBase & {\n type: 'is-registered';\n id: string;\n};\n\nexport type Panel = z.infer<typeof PanelSchema>;\n\nexport type AttributeExplorerPanel = Panel &\n z.infer<typeof baseExplorerPanelSchema> &\n z.infer<typeof attributeExplorerPanelSchema>;\n\nexport type LibraryId = z.infer<typeof LibraryIdSchema>;\n\nexport type PanelId = z.infer<typeof PanelIdSchema>;\n\nexport type Where = z.infer<typeof WhereSchema>;\n\nexport type PanelIFrame = z.infer<typeof PanelIFrameSchema>;\n\ntype FlapPanelId = z.infer<typeof FlapPanelIdSchema>;\n\nexport type NavigateToPanelMessage = IMessageBase & {\n type: 'navigate-to-panel';\n data: {\n where: Where;\n libraryId: LibraryId;\n panelId?: PanelId;\n recordId?: string;\n flapRecordId?: string;\n flapLibraryId?: LibraryId;\n flapPanelId?: FlapPanelId;\n queryParams?: Record<string, string> & {\n formInitialValues?: Record<string, Array<AnyPrimitive | IRecordIdentity | ITreeNodeWithRecord>>;\n };\n };\n};\n\nexport type ClosePanelMessage = IMessageBase & {\n type: 'close-panel';\n data: {\n recordId: string;\n where: string;\n recordPanelId: string;\n };\n};\n\nexport type NavigateToIframeMessage = IMessageBase & {\n type: 'navigate-to-iframe';\n data: {\n panel: PanelIFrame;\n destination: {libraryId: LibraryId};\n where: Where;\n recordId: string;\n recordPanelId: string;\n };\n};\n\nexport type MessageToPanelMessage = IMessageBase & {\n type: 'message-to-panel';\n data: {\n type: string;\n target?: string;\n payload: unknown;\n };\n};\n\nexport type OpenFlapPanelMessage = IMessageBase & {\n type: 'open-flap-panel';\n data: {\n flapRecordId: string;\n flapLibraryId: LibraryId;\n flapPanelId: FlapPanelId;\n redirectUrl?: string;\n };\n};\n\nexport type CloseFlapPanelMessage = IMessageBase & {\n type: 'close-flap-panel';\n};\n\nexport type GetUrlMessage = IMessageBase & {\n type: 'get-url';\n id: string;\n data: {\n onGetUrl: (url: string) => void;\n flapParams?: {\n flapRecordId: string;\n flapLibraryId: LibraryId;\n flapPanelId: FlapPanelId;\n };\n panelParams?: {\n recordId: string;\n where: Where;\n recordPanelId: PanelId;\n };\n };\n overrides?: string[];\n};\n\nexport type GetPanelConfigMessage = IMessageBase & {\n type: 'get-panel-config';\n id: string;\n data: {\n panelId?: string;\n onGetPanelConfig: (data: PanelIFrame) => void;\n };\n overrides?: string[];\n};\n\nexport type MessageToParent =\n | ModalConfirmMessage\n | AlertMessage\n | NotificationMessage\n | SimpleMessage\n | RegisterMessage\n | UnregisterMessage\n | NavigateToPanelMessage\n | ClosePanelMessage\n | NavigateToIframeMessage\n | MessageToPanelMessage\n | OpenFlapPanelMessage\n | CloseFlapPanelMessage\n | GetUrlMessage\n | GetPanelConfigMessage;\n\nexport type MessageFromParent =\n | (IMessageBase & {\n type: 'on-call-callback';\n path: string;\n data: unknown;\n })\n | IsRegisteredMessage\n | ChangeLanguageMessage;\n\nexport type Message = MessageToParent | MessageFromParent;\n\nexport type MessageHandler<T = Message> = (message: T, dispatch: MessageDispatcher<T>) => void;\nexport type MessageDispatcher<T = Message> = (message: T, frameId?: string) => void;\n\nexport type CallCbFunction = (path: string, data: unknown, frameId: string) => void;\n\nexport type CallbackFunction = (...args: never[]) => void;\nexport type Callbacks = Record<string, Record<string, CallbackFunction>>;\n\nexport type MessageToPanelMessageHandler = (data: MessageToPanelMessage['data']['payload']) => void;\nexport type AddMessageToPanelMessageHandler = (type: string, handler: MessageToPanelMessageHandler) => void;\n\nexport interface IUseIFrameMessengerOptions {\n ref?: RefObject<HTMLIFrameElement>;\n id?: string;\n handlers?: {\n onModalConfirm?: (\n data: ModalConfirmMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onAlert?: (data: AlertMessage['data'], id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;\n onNotification?: (\n data: NotificationMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onMessage?: (data: unknown, id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;\n onNavigateToPanel?: (data: NavigateToPanelMessage['data']) => void;\n onClosePanel?: (data: ClosePanelMessage['data']) => void;\n onNavigateToIframe?: (data: NavigateToIframeMessage['data']) => void;\n onOpenFlapPanel?: (data: OpenFlapPanelMessage['data']) => void;\n onGetUrl?: (data: GetUrlMessage['data']) => void;\n onGetPanelConfig?: (\n data: GetPanelConfigMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onCloseFlapPanel?: () => void;\n };\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,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 RefObject, type ComponentProps, type Key, type JSXElementConstructor} from 'react';\nimport type * as z from 'zod/v4';\nimport {type KitNotification} from 'aristid-ds';\nimport {type IKitConfirmDialog} from 'aristid-ds/dist/Kit/Feedback/Modal/types';\nimport {type ToastedAlertProps} from 'aristid-ds/dist/Kit/Feedback/Alert/types';\nimport {\n type LibraryIdSchema,\n type WhereSchema,\n type PanelIdSchema,\n type PanelSchema,\n type PanelIFrameSchema,\n type FlapPanelIdSchema,\n type attributeExplorerPanelSchema,\n type baseExplorerPanelSchema,\n} from '_ui/hooks/useIFrameMessenger/schema';\nimport {type AnyPrimitive} from '@leav/utils';\nimport {type IRecordIdentity, type ITreeNodeWithRecord} from '_ui/types';\n\nexport const packetId = '__fromIframeMessenger';\n\nexport interface IEncodedMessage {\n payload: string;\n [packetId]: boolean;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ComponentPropsWithKey<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> =\n ComponentProps<T> & {\n key?: Key;\n };\n\nexport interface IMessageBase {\n __frameId?: string;\n}\n\nexport type ModalConfirmMessage = IMessageBase & {\n type: 'modal-confirm';\n id: string;\n data: IKitConfirmDialog;\n overrides?: string[];\n};\n\nexport type AlertMessage = IMessageBase & {\n type: 'alert';\n id: string;\n data: ToastedAlertProps;\n overrides?: string[];\n};\n\nexport type NotificationMessage = IMessageBase & {\n type: 'notification';\n id: string;\n data: ComponentPropsWithKey<typeof KitNotification>;\n overrides?: string[];\n};\n\nexport type ChangeLanguageMessage = IMessageBase & {\n type: 'change-language';\n language: string;\n};\n\nexport type SimpleMessage = IMessageBase & {\n type: 'message';\n id: string;\n data: unknown;\n};\n\nexport type RegisterMessage = IMessageBase & {\n type: 'register';\n id: string;\n};\n\nexport type UnregisterMessage = IMessageBase & {\n type: 'unregister';\n id: string;\n};\n\nexport type IsRegisteredMessage = IMessageBase & {\n type: 'is-registered';\n id: string;\n};\n\nexport type Panel = z.infer<typeof PanelSchema>;\n\nexport type AttributeExplorerPanel = Panel &\n z.infer<typeof baseExplorerPanelSchema> &\n z.infer<typeof attributeExplorerPanelSchema>;\n\nexport type LibraryId = z.infer<typeof LibraryIdSchema>;\n\nexport type PanelId = z.infer<typeof PanelIdSchema>;\n\nexport type Where = z.infer<typeof WhereSchema>;\n\nexport type PanelIFrame = z.infer<typeof PanelIFrameSchema>;\n\ntype FlapPanelId = z.infer<typeof FlapPanelIdSchema>;\n\nexport type NavigateToPanelMessage = IMessageBase & {\n type: 'navigate-to-panel';\n data: {\n where: Where;\n libraryId: LibraryId;\n panelId?: PanelId;\n recordId?: string;\n flapRecordId?: string;\n flapLibraryId?: LibraryId;\n flapPanelId?: FlapPanelId;\n queryParams?: Record<string, string> & {\n redirectUrl?: string;\n formInitialValues?: Record<string, Array<AnyPrimitive | IRecordIdentity | ITreeNodeWithRecord>>;\n };\n };\n};\n\nexport type ClosePanelMessage = IMessageBase & {\n type: 'close-panel';\n data: {\n recordId: string;\n where: string;\n recordPanelId: string;\n };\n};\n\nexport type NavigateToIframeMessage = IMessageBase & {\n type: 'navigate-to-iframe';\n data: {\n panel: PanelIFrame;\n destination: {libraryId: LibraryId};\n where: Where;\n recordId: string;\n recordPanelId: string;\n };\n};\n\nexport type MessageToPanelMessage = IMessageBase & {\n type: 'message-to-panel';\n data: {\n type: string;\n target?: string;\n payload: unknown;\n };\n};\n\nexport type OpenFlapPanelMessage = IMessageBase & {\n type: 'open-flap-panel';\n data: {\n flapRecordId: string;\n flapLibraryId: LibraryId;\n flapPanelId: FlapPanelId;\n };\n};\n\nexport type CloseFlapPanelMessage = IMessageBase & {\n type: 'close-flap-panel';\n};\n\nexport type GetUrlMessage = IMessageBase & {\n type: 'get-url';\n id: string;\n data: {\n onGetUrl: (url: string) => void;\n flapParams?: {\n flapRecordId: string;\n flapLibraryId: LibraryId;\n flapPanelId: FlapPanelId;\n };\n panelParams?: {\n recordId: string;\n where: Where;\n recordPanelId: PanelId;\n };\n };\n overrides?: string[];\n};\n\nexport type GetPanelConfigMessage = IMessageBase & {\n type: 'get-panel-config';\n id: string;\n data: {\n panelId?: string;\n onGetPanelConfig: (data: PanelIFrame) => void;\n };\n overrides?: string[];\n};\n\nexport type MessageToParent =\n | ModalConfirmMessage\n | AlertMessage\n | NotificationMessage\n | SimpleMessage\n | RegisterMessage\n | UnregisterMessage\n | NavigateToPanelMessage\n | ClosePanelMessage\n | NavigateToIframeMessage\n | MessageToPanelMessage\n | OpenFlapPanelMessage\n | CloseFlapPanelMessage\n | GetUrlMessage\n | GetPanelConfigMessage;\n\nexport type MessageFromParent =\n | (IMessageBase & {\n type: 'on-call-callback';\n path: string;\n data: unknown;\n })\n | IsRegisteredMessage\n | ChangeLanguageMessage;\n\nexport type Message = MessageToParent | MessageFromParent;\n\nexport type MessageHandler<T = Message> = (message: T, dispatch: MessageDispatcher<T>) => void;\nexport type MessageDispatcher<T = Message> = (message: T, frameId?: string) => void;\n\nexport type CallCbFunction = (path: string, data: unknown, frameId: string) => void;\n\nexport type CallbackFunction = (...args: never[]) => void;\nexport type Callbacks = Record<string, Record<string, CallbackFunction>>;\n\nexport type MessageToPanelMessageHandler = (data: MessageToPanelMessage['data']['payload']) => void;\nexport type AddMessageToPanelMessageHandler = (type: string, handler: MessageToPanelMessageHandler) => void;\n\nexport type UnregisterHandlers = () => void;\nexport type RegisterHandlers = (\n iframeRef: RefObject<HTMLIFrameElement>,\n handlers: IUseIFrameMessengerOptions['handlers'],\n) => UnregisterHandlers;\n\nexport interface IUseIFrameMessengerOptions {\n ref?: RefObject<HTMLIFrameElement>;\n id?: string;\n onMessageReceived?: (\n senderWindow: Window | null,\n message: Message,\n panelId: string | null,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n callbacksStore: MutableRefObject<Callbacks>,\n ) => void;\n handlers?: {\n onModalConfirm?: (\n data: ModalConfirmMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onAlert?: (data: AlertMessage['data'], id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;\n onNotification?: (\n data: NotificationMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onMessage?: (data: unknown, id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;\n onNavigateToPanel?: (data: NavigateToPanelMessage['data']) => void;\n onClosePanel?: (data: ClosePanelMessage['data']) => void;\n onNavigateToIframe?: (data: NavigateToIframeMessage['data']) => void;\n onOpenFlapPanel?: (data: OpenFlapPanelMessage['data']) => void;\n onGetUrl?: (data: GetUrlMessage['data']) => void;\n onGetPanelConfig?: (\n data: GetPanelConfigMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onCloseFlapPanel?: () => void;\n };\n}\n"]}
@@ -1,8 +1,16 @@
1
1
  import { type AddMessageToPanelMessageHandler, type IUseIFrameMessengerOptions } from './types';
2
2
  export { IUseIFrameMessengerOptions };
3
3
  /**
4
- * This is the core of `useIFrameMessenger`. Should be used for top-level apps, such as **app-studio**.
5
- * For client apps (apps that need to consume the messenger), please use the `useIFrameMessengerClient`
4
+ * Core hook of the IFrameMessenger system. Registers a single `window.addEventListener('message')`
5
+ * and manages a registry of connected child frames.
6
+ *
7
+ * **Usage:**
8
+ * - Top-level apps (e.g. app-studio): use via `IFrameMessengerProvider` which calls this hook once as a singleton.
9
+ * - Client apps (child iframes): use `useIFrameMessengerClient` instead.
10
+ *
11
+ * **`onMessageReceived` option:** when provided, all non-system messages are delegated to this callback
12
+ * instead of being handled locally. Used by `IFrameMessengerProvider` to route messages to the correct
13
+ * per-iframe handlers without registering multiple listeners.
6
14
  */
7
15
  export declare const useIFrameMessenger: (options?: IUseIFrameMessengerOptions) => {
8
16
  isRegistered: boolean;
@@ -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,17 +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
109
  default:
107
110
  if (message.type === 'change-language') {
108
111
  setLang(message.language);
109
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
+ }
110
118
  else {
111
- 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);
112
125
  }
113
126
  break;
114
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,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,CAAC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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 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,CAAC,WAAW,CAAC,CAAC;IAE1C,MAAM,qBAAqB,GAAG,CAAC,WAAmB,EAAE,EAAE;QAClD,QAAQ,CACJ;YACI,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE,WAAW;SACxB,EACD,KAAK,CACR,CAAC;IACN,CAAC,CAAC;IAEF,MAAM,2BAA2B,GAAG,MAAM,CAA+C,EAAE,CAAC,CAAC;IAC7F,MAAM,sBAAsB,GAAoC,CAC5D,IAAY,EACZ,OAAqC,EACvC,EAAE;QACA,2BAA2B,CAAC,OAAO,CAAC,IAAI,CAA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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,OAAO;QACX,CAAC;QAED,IAAI,eAAmE,CAAC;QACxE,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YAChD,IAAI,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,YAAY,EAAE,CAAC;gBAC9C,eAAe,GAAG,QAAQ,CAAC;gBAC3B,MAAM;YACV,CAAC;QACL,CAAC;QAED,sFAAsF;QACtF,oFAAoF;QACpF,2EAA2E;QAC3E,IAAI,CAAC,eAAe,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QAED,MAAM,eAAe,GACjB,OAAO,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,EAAC,GAAG,OAAO,CAAC,IAAI,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAEnG,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAE,eAAe,EAAC,EAAE,cAAc,CAAC,CAAC;QAC/F,cAAc,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC,EACD,EAAE,CACL,CAAC;IAEF,MAAM,EAAC,qBAAqB,EAAC,GAAG,kBAAkB,CAAC,EAAC,iBAAiB,EAAC,CAAC,CAAC;IAExE,MAAM,gBAAgB,GAAqB,WAAW,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;QAC3E,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAE7C,MAAM,OAAO,GAAG,GAAG,EAAE;YACjB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF,OAAO,OAAO,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAC,gBAAgB,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"]}
@@ -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
  },
@@ -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-3",
3
+ "version": "1.12.0-36d55f01",
4
4
  "description": "Shared React components and hooks",
5
5
  "scripts": {
6
6
  "prepublishOnly": "yarn build",
@@ -24,14 +24,14 @@
24
24
  "license": "LGPL3",
25
25
  "repository": "https://github.com/leav-solutions/leav-engine",
26
26
  "devDependencies": {
27
- "@apollo/client": "3.14.0",
28
- "@babel/preset-env": "7.29.0",
27
+ "@apollo/client": "3.14.1",
28
+ "@babel/preset-env": "7.29.2",
29
29
  "@babel/preset-react": "7.28.5",
30
30
  "@graphql-codegen/add": "5.0.3",
31
31
  "@graphql-codegen/cli": "6.2.1",
32
- "@graphql-codegen/typescript": "5.0.9",
32
+ "@graphql-codegen/typescript": "5.0.10",
33
33
  "@graphql-codegen/typescript-operations": "5.0.9",
34
- "@graphql-codegen/typescript-react-apollo": "4.4.1",
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,25 +42,25 @@
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-e049fb9",
45
+ "aristid-ds": "15.3.1-886678",
46
46
  "babel-jest": "29.7.0",
47
- "graphql": "16.12.0",
47
+ "graphql": "16.13.2",
48
48
  "i18next": "22.5.1",
49
49
  "jest": "29.7.0",
50
50
  "jest-environment-jsdom": "29.7.0",
51
- "jest-styled-components": "7.3.1",
51
+ "jest-styled-components": "7.4.0",
52
52
  "react": "18.2.0",
53
53
  "react-dom": "18.2.0",
54
54
  "react-i18next": "12",
55
55
  "react-router-dom": "6.22.0",
56
- "ts-jest": "29.4.6",
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-e049fb9",
63
+ "aristid-ds": "15.3.1-637817c",
64
64
  "i18next": ">=22.5.1",
65
65
  "react": "^18.2.0",
66
66
  "react-dom": "^18.2.0",
@@ -74,10 +74,10 @@
74
74
  "@dnd-kit/core": "6.3.1",
75
75
  "@dnd-kit/sortable": "8.0.0",
76
76
  "@dnd-kit/utilities": "3.2.2",
77
- "@leav/utils": "1.12.0-3",
77
+ "@leav/utils": "1.12.0",
78
78
  "@uidotdev/usehooks": "2.4.1",
79
79
  "dayjs": "^1.11.13",
80
- "dompurify": "3.3.2",
80
+ "dompurify": "3.4.0",
81
81
  "html-react-parser": "4.2.10",
82
82
  "i18next-resources-to-backend": "1.1.4",
83
83
  "lodash.isequal": "4.5.0",