@leav/ui 1.6.0-dfb71145 → 1.6.0-e751f378
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.
- package/dist/_gqlTypes/index.d.ts +889 -686
- package/dist/_gqlTypes/index.js +98 -43
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/trees/treeNodeChildrenQuery.js +2 -0
- package/dist/_queries/trees/treeNodeChildrenQuery.js.map +1 -1
- package/dist/_queries/views/viewDetailsFragment.js +1 -0
- package/dist/_queries/views/viewDetailsFragment.js.map +1 -1
- package/dist/components/AttributesSelectionList/sharedComponents.d.ts +159 -153
- package/dist/components/Explorer/Explorer.js +5 -3
- package/dist/components/Explorer/Explorer.js.map +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js +1 -1
- package/dist/components/Explorer/ExplorerFiltersAndSorts.js.map +1 -1
- package/dist/components/Explorer/TableCell.js +6 -7
- package/dist/components/Explorer/TableCell.js.map +1 -1
- package/dist/components/Explorer/TableNameCell.js +3 -2
- package/dist/components/Explorer/TableNameCell.js.map +1 -1
- package/dist/components/Explorer/_queries/useExplorerData.d.ts +7 -7
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +3 -2
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.d.ts +2 -1
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js +5 -4
- package/dist/components/Explorer/actions-item/useReplaceItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.d.ts +10 -0
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js +46 -0
- package/dist/components/Explorer/actions-mass/export/ExportProfileSelectionModal.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.d.ts +1 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js +17 -0
- package/dist/components/Explorer/actions-mass/export/content/NoProfiles.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.d.ts +8 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js +49 -0
- package/dist/components/Explorer/actions-mass/export/content/ProfilesSelection.js.map +1 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.d.ts +27 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js +48 -0
- package/dist/components/Explorer/actions-mass/export/useGetLibraryExportProfiles.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +3 -2
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +3 -2
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +3 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useExportMassAction.d.ts +7 -4
- package/dist/components/Explorer/actions-mass/useExportMassAction.js +80 -73
- package/dist/components/Explorer/actions-mass/useExportMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +3 -2
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js +3 -2
- package/dist/components/Explorer/actions-primary/useCreatePrimaryAction.js.map +1 -1
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.d.ts +2 -1
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js +5 -4
- package/dist/components/Explorer/actions-primary/useLinkPrimaryAction.js.map +1 -1
- package/dist/components/Explorer/link-item/LinkModal.d.ts +1 -0
- package/dist/components/Explorer/link-item/LinkModal.js +2 -2
- package/dist/components/Explorer/link-item/LinkModal.js.map +1 -1
- package/dist/components/Explorer/list-saved-views/SavedViews.js +4 -3
- package/dist/components/Explorer/list-saved-views/SavedViews.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js +5 -8
- package/dist/components/Explorer/manage-view-settings/_shared/ColumnItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js +3 -2
- package/dist/components/Explorer/manage-view-settings/configure-display/attributes/SelectVisibleAttributes.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js +7 -6
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterItems.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/filter-items/FilterListItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js +4 -3
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingItem.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js +3 -2
- package/dist/components/Explorer/manage-view-settings/router-menu/SettingsPanel.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/LabelViewFormModal.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js +3 -0
- package/dist/components/Explorer/manage-view-settings/save-view/prepareViewForRequest.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useCreateNewView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js +4 -3
- package/dist/components/Explorer/manage-view-settings/save-view/useDeleteView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useEditLabelView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useResetView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useShareView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js +3 -2
- package/dist/components/Explorer/manage-view-settings/save-view/useUpdateView.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js +7 -6
- package/dist/components/Explorer/manage-view-settings/sort-items/SortItems.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js +3 -2
- package/dist/components/Explorer/manage-view-settings/sort-items/SortListItem.js.map +1 -1
- package/dist/components/Filters/FiltersProvider.d.ts +2 -2
- package/dist/components/Filters/FiltersProvider.js.map +1 -1
- package/dist/components/Filters/_types.d.ts +3 -0
- package/dist/components/Filters/_types.js.map +1 -1
- package/dist/components/Filters/context/filtersReducer.js +5 -1
- package/dist/components/Filters/context/filtersReducer.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.d.ts +1 -0
- package/dist/components/Filters/filter-items/CommonFilterItem.js +28 -8
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.d.ts +8 -0
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js +16 -0
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +23 -9
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js +9 -8
- package/dist/components/Filters/filter-items/filter-type/ColorAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js +4 -3
- package/dist/components/Filters/filter-items/filter-type/FilterDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.d.ts +0 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +17 -23
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +10 -12
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js +3 -13
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/index.d.ts +1 -0
- package/dist/components/Filters/index.js +1 -0
- package/dist/components/Filters/index.js.map +1 -1
- package/dist/components/Filters/prepareFiltersForRequest.js +36 -3
- package/dist/components/Filters/prepareFiltersForRequest.js.map +1 -1
- package/dist/components/Filters/useFilters.d.ts +5 -0
- package/dist/components/Filters/useTransformFilters.js +4 -0
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersOptions.js +1 -8
- package/dist/components/LibraryItemsList/FiltersPanel/FiltersOptions.js.map +1 -1
- package/dist/components/LibraryItemsList/MenuView/MenuView.js +4 -4
- package/dist/components/LibraryItemsList/MenuView/MenuView.js.map +1 -1
- package/dist/components/LibraryItemsList/ViewPanel/View/View.js +3 -2
- package/dist/components/LibraryItemsList/ViewPanel/View/View.js.map +1 -1
- package/dist/components/Notifications/hooks/useNotificationSubscription.js +3 -2
- package/dist/components/Notifications/hooks/useNotificationSubscription.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +5 -20
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js +4 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/link-record/useLinkRecords.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/shared/ExplorerWrapper.d.ts +53 -51
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js +4 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js +9 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/TreeField.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeFieldWrapper.d.ts +53 -51
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/display-tree-node/TreeNodeItem.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.d.ts +2 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js +4 -7
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/SelectTreeNodeModal.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.d.ts +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js +2 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/TreeField/manage-tree-node-selection/useManageTreeNodeSelection.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js +3 -2
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/ComputeIndicator.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +3 -2
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js +4 -3
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesSummary/ValuesSummary.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js +3 -2
- package/dist/components/RecordEdition/EditRecordSidebar/ValuesVersions/ValuesVersions.js.map +1 -1
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.d.ts +1 -0
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js +7 -7
- package/dist/components/SelectRecordForLinkModal/SelectRecordForLinkModal.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNode.d.ts +2 -1
- package/dist/components/SelectTreeNode/SelectTreeNode.js +3 -3
- package/dist/components/SelectTreeNode/SelectTreeNode.js.map +1 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.d.ts +2 -1
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js +6 -2
- package/dist/components/SelectTreeNode/SelectTreeNodeContent.js.map +1 -1
- package/dist/components/SelectTreeNode/TreeNodeTitle.js +3 -2
- package/dist/components/SelectTreeNode/TreeNodeTitle.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.d.ts +2 -1
- package/dist/hooks/useIFrameMessenger/messageHandlers.js +8 -0
- package/dist/hooks/useIFrameMessenger/messageHandlers.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/schema.d.ts +3 -0
- package/dist/hooks/useIFrameMessenger/schema.js +1 -0
- package/dist/hooks/useIFrameMessenger/schema.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/types.d.ts +12 -2
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +1 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +15 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/hooks/useIFrameMessengerClient/iFrameMessengerClientContext.d.ts +1 -0
- package/dist/hooks/useIFrameMessengerClient/useIFrameMessengerClient.d.ts +1 -0
- package/dist/locales/en/shared.json +15 -3
- package/dist/locales/fr/shared.json +15 -3
- package/package.json +12 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageHandlers.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/messageHandlers.ts"],"names":[],"mappings":"AAIA,OAAO,EAgBH,QAAQ,GAIX,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAU,EAAE,CACtD,IAAI,CAAC,SAAS,CAAC;IACX,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAChC,CAAC,QAAQ,CAAC,EAAE,IAAI;CACnB,CAAC,CAAC;AAEP,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAuB,EAAE;IAC9D,IAAI,CAAC;QACD,MAAM,OAAO,GAAoB,IAAI,CAAC,KAAK,CAAC,GAAG,CAA+B,CAAC;QAC/E,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAY,CAAC;QAClD,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,aAA2C,EAA2B,EAAE;IACvG,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,C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AAC;IAC5C,CAAC;IACD,gBAAgB,EAAE,CAAC,IAAqC,EAAE,EAAE;QACxD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAC,CAAC,CAAC;IACnD,CAAC;IACD,cAAc,EAAE,CAAC,IAAmC,EAAE,EAAE;QACpD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAC,CAAC,CAAC;IACjD,CAAC;IACD,aAAa,EAAE,CAAC,IAAkC,EAAE,EAAE;QAClD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAC,CAAC,CAAC;IAChD,CAAC;IACD,cAAc,EAAE,GAAG,EAAE;QACjB,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC,CAAC;IAC3C,CAAC;CACJ,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} from 'react';\nimport {\n type AlertMessage,\n type CallbackFunction,\n type Callbacks,\n type CallCbFunction,\n type ClosePanelMessage,\n type IEncodedMessage,\n type IUseIFrameMessengerOptions,\n type Message,\n type MessageDispatcher,\n type MessageHandler,\n type MessageToPanelMessage,\n type ModalConfirmMessage,\n type NavigateToIframeMessage,\n type NavigateToPanelMessage,\n type NotificationMessage,\n packetId,\n type SimpleMessage,\n type OpenFlapPanelMessage,\n type CloseFlapPanelMessage,\n} from './types';\n\nexport const encodeMessage = (message: Message): string =>\n JSON.stringify({\n payload: JSON.stringify(message),\n [packetId]: true,\n });\n\nexport const decodeMessage = (raw: string): Message | undefined => {\n try {\n const decoded: IEncodedMessage = JSON.parse(raw) as unknown as IEncodedMessage;\n if (packetId in decoded && decoded[packetId] === true) {\n return JSON.parse(decoded.payload) as Message;\n }\n } catch (e) {\n return undefined;\n }\n return undefined;\n};\n\nconst getCallback = (path: string, callbacksList?: MutableRefObject<Callbacks>): CallbackFunction | null => {\n if (!callbacksList?.current) {\n return null;\n }\n const pathArray = path.split('.');\n let callback: CallbackFunction | Callbacks | Record<string, CallbackFunction> = callbacksList.current;\n pathArray.forEach(part => (callback = (callback as Callbacks | Record<string, CallbackFunction>)?.[part]));\n return typeof callback === 'function' ? callback : null;\n};\n\nconst setCallbacks = (\n id: string,\n frameId: string,\n data: unknown,\n callCb: CallCbFunction,\n overrides?: string[],\n): unknown => {\n if (!overrides) {\n return data;\n }\n\n const nextData = {...(data as Record<string, unknown>)};\n overrides.forEach((key: string) => {\n nextData[key] = (...args: unknown[]) => {\n callCb(`${id}.${key}`, args, frameId);\n };\n });\n return nextData;\n};\n\nexport const initClientHandlers: (\n callCb: CallCbFunction,\n options?: IUseIFrameMessengerOptions,\n callbacksList?: MutableRefObject<Callbacks>,\n) => MessageHandler = (callCb, options, callbacksList) => (message, dispatch) => {\n switch (message.type) {\n case 'modal-confirm':\n options?.handlers?.onModalConfirm?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as ModalConfirmMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'alert':\n options?.handlers?.onAlert?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as AlertMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'notification':\n options?.handlers?.onNotification?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as NotificationMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'message':\n options?.handlers?.onMessage?.(message.data, message.id, dispatch, callCb);\n break;\n case 'on-call-callback':\n // TODO How to know if handler can be removed from callbacksList ?\n getCallback(message.path, callbacksList)?.(...(message.data as never[]));\n break;\n case 'navigate-to-panel':\n options?.handlers?.onNavigateToPanel?.(message.data);\n break;\n case 'close-panel':\n options?.handlers?.onClosePanel?.(message.data);\n break;\n case 'navigate-to-iframe':\n options?.handlers?.onNavigateToIframe?.(message.data);\n break;\n case 'open-flap-panel':\n options?.handlers?.onOpenFlapPanel?.(message.data);\n break;\n case 'close-flap-panel':\n options?.handlers?.onCloseFlapPanel?.();\n break;\n default:\n break;\n }\n};\n\nconst storeCallbacks = (\n data: unknown,\n id: string,\n callbacksStore: MutableRefObject<Callbacks>,\n): {data: unknown; overrides: string[]} => {\n const nextData = {...(data as Record<string, unknown>)};\n const overrides: string[] = [];\n Object.entries(nextData).forEach(([key, value]) => {\n if (typeof value === 'function') {\n callbacksStore.current[id] = {\n ...callbacksStore.current[id],\n [key]: value as CallbackFunction,\n };\n overrides.push(key);\n }\n });\n return {data: nextData, overrides};\n};\n\nexport const getExposedMethods = (callbacksStore: MutableRefObject<Callbacks>, dispatch?: MessageDispatcher) => ({\n showModalConfirm: (data: ModalConfirmMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'modal-confirm', data: nextData as ModalConfirmMessage['data'], id, overrides});\n },\n showAlert: (data: AlertMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'alert', data: nextData as AlertMessage['data'], id, overrides});\n },\n showNotification: (data: NotificationMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'notification', data: nextData as NotificationMessage['data'], id, overrides});\n },\n messageToParent: (data: SimpleMessage['data']) => {\n const id = Date.now().toString();\n dispatch?.({type: 'message', data, id});\n },\n navigateToPanel: (data: NavigateToPanelMessage['data']) => {\n dispatch?.({type: 'navigate-to-panel', data});\n },\n closePanel: (data: ClosePanelMessage['data']) => {\n dispatch?.({type: 'close-panel', data});\n },\n navigateToIframe: (data: NavigateToIframeMessage['data']) => {\n dispatch?.({type: 'navigate-to-iframe', data});\n },\n messageToPanel: (data: MessageToPanelMessage['data']) => {\n dispatch?.({type: 'message-to-panel', data});\n },\n openFlapPanel: (data: OpenFlapPanelMessage['data']) => {\n dispatch?.({type: 'open-flap-panel', data});\n },\n closeFlapPanel: () => {\n dispatch?.({type: 'close-flap-panel'});\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"messageHandlers.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/messageHandlers.ts"],"names":[],"mappings":"AAIA,OAAO,EAgBH,QAAQ,GAIX,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAU,EAAE,CACtD,IAAI,CAAC,SAAS,CAAC;IACX,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAChC,CAAC,QAAQ,CAAC,EAAE,IAAI;CACnB,CAAC,CAAC;AAEP,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAuB,EAAE;IAC9D,IAAI,CAAC;QACD,MAAM,OAAO,GAAoB,IAAI,CAAC,KAAK,CAAC,GAAG,CAA+B,CAAC;QAC/E,IAAI,QAAQ,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAY,CAAC;QAClD,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,aAA2C,EAA2B,EAAE;IACvG,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAoE,aAAa,CAAC,OAAO,CAAC;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,mBAAmB,EAAE,IAAI,EAAC,CAAC,CAAC;IAClD,CAAC;IACD,UAAU,EAAE,CAAC,IAA+B,EAAE,EAAE;QAC5C,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAC,CAAC,CAAC;IAC5C,CAAC;IACD,gBAAgB,EAAE,CAAC,IAAqC,EAAE,EAAE;QACxD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAC,CAAC,CAAC;IACnD,CAAC;IACD,cAAc,EAAE,CAAC,IAAmC,EAAE,EAAE;QACpD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAC,CAAC,CAAC;IACjD,CAAC;IACD,aAAa,EAAE,CAAC,IAAkC,EAAE,EAAE;QAClD,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAC,CAAC,CAAC;IAChD,CAAC;IACD,cAAc,EAAE,GAAG,EAAE;QACjB,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAC,CAAC,CAAC;IAC3C,CAAC;IACD,cAAc,EAAE,CAAC,IAAmC,EAAE,EAAE;QACpD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QACjC,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC,GAAG,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;QAC7E,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,QAAyC,EAAE,EAAE,EAAE,SAAS,EAAC,CAAC,CAAC;IAC3G,CAAC;CACJ,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} from 'react';\nimport {\n type AlertMessage,\n type CallbackFunction,\n type Callbacks,\n type CallCbFunction,\n type ClosePanelMessage,\n type IEncodedMessage,\n type IUseIFrameMessengerOptions,\n type Message,\n type MessageDispatcher,\n type MessageHandler,\n type MessageToPanelMessage,\n type ModalConfirmMessage,\n type NavigateToIframeMessage,\n type NavigateToPanelMessage,\n type NotificationMessage,\n packetId,\n type SimpleMessage,\n type OpenFlapPanelMessage,\n type GetPanelConfigMessage,\n} from './types';\n\nexport const encodeMessage = (message: Message): string =>\n JSON.stringify({\n payload: JSON.stringify(message),\n [packetId]: true,\n });\n\nexport const decodeMessage = (raw: string): Message | undefined => {\n try {\n const decoded: IEncodedMessage = JSON.parse(raw) as unknown as IEncodedMessage;\n if (packetId in decoded && decoded[packetId] === true) {\n return JSON.parse(decoded.payload) as Message;\n }\n } catch (e) {\n return undefined;\n }\n return undefined;\n};\n\nconst getCallback = (path: string, callbacksList?: MutableRefObject<Callbacks>): CallbackFunction | null => {\n if (!callbacksList?.current) {\n return null;\n }\n const pathArray = path.split('.');\n let callback: CallbackFunction | Callbacks | Record<string, CallbackFunction> = callbacksList.current;\n pathArray.forEach(part => (callback = (callback as Callbacks | Record<string, CallbackFunction>)?.[part]));\n return typeof callback === 'function' ? callback : null;\n};\n\nconst setCallbacks = (\n id: string,\n frameId: string,\n data: unknown,\n callCb: CallCbFunction,\n overrides?: string[],\n): unknown => {\n if (!overrides) {\n return data;\n }\n\n const nextData = {...(data as Record<string, unknown>)};\n overrides.forEach((key: string) => {\n nextData[key] = (...args: unknown[]) => {\n callCb(`${id}.${key}`, args, frameId);\n };\n });\n return nextData;\n};\n\nexport const initClientHandlers: (\n callCb: CallCbFunction,\n options?: IUseIFrameMessengerOptions,\n callbacksList?: MutableRefObject<Callbacks>,\n) => MessageHandler = (callCb, options, callbacksList) => (message, dispatch) => {\n switch (message.type) {\n case 'modal-confirm':\n options?.handlers?.onModalConfirm?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as ModalConfirmMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'alert':\n options?.handlers?.onAlert?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as AlertMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'notification':\n options?.handlers?.onNotification?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as NotificationMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n case 'message':\n options?.handlers?.onMessage?.(message.data, message.id, dispatch, callCb);\n break;\n case 'on-call-callback':\n // TODO How to know if handler can be removed from callbacksList ?\n getCallback(message.path, callbacksList)?.(...(message.data as never[]));\n break;\n case 'navigate-to-panel':\n options?.handlers?.onNavigateToPanel?.(message.data);\n break;\n case 'close-panel':\n options?.handlers?.onClosePanel?.(message.data);\n break;\n case 'navigate-to-iframe':\n options?.handlers?.onNavigateToIframe?.(message.data);\n break;\n case 'open-flap-panel':\n options?.handlers?.onOpenFlapPanel?.(message.data);\n break;\n case 'close-flap-panel':\n options?.handlers?.onCloseFlapPanel?.();\n break;\n case 'get-panel-config':\n options?.handlers?.onGetPanelConfig?.(\n setCallbacks(\n message.id,\n message.__frameId,\n message.data,\n callCb,\n message.overrides,\n ) as GetPanelConfigMessage['data'],\n message.id,\n dispatch,\n callCb,\n );\n break;\n default:\n break;\n }\n};\n\nconst storeCallbacks = (\n data: unknown,\n id: string,\n callbacksStore: MutableRefObject<Callbacks>,\n): {data: unknown; overrides: string[]} => {\n const nextData = {...(data as Record<string, unknown>)};\n const overrides: string[] = [];\n Object.entries(nextData).forEach(([key, value]) => {\n if (typeof value === 'function') {\n callbacksStore.current[id] = {\n ...callbacksStore.current[id],\n [key]: value as CallbackFunction,\n };\n overrides.push(key);\n }\n });\n return {data: nextData, overrides};\n};\n\nexport const getExposedMethods = (callbacksStore: MutableRefObject<Callbacks>, dispatch?: MessageDispatcher) => ({\n showModalConfirm: (data: ModalConfirmMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'modal-confirm', data: nextData as ModalConfirmMessage['data'], id, overrides});\n },\n showAlert: (data: AlertMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'alert', data: nextData as AlertMessage['data'], id, overrides});\n },\n showNotification: (data: NotificationMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'notification', data: nextData as NotificationMessage['data'], id, overrides});\n },\n messageToParent: (data: SimpleMessage['data']) => {\n const id = Date.now().toString();\n dispatch?.({type: 'message', data, id});\n },\n navigateToPanel: (data: NavigateToPanelMessage['data']) => {\n dispatch?.({type: 'navigate-to-panel', data});\n },\n closePanel: (data: ClosePanelMessage['data']) => {\n dispatch?.({type: 'close-panel', data});\n },\n navigateToIframe: (data: NavigateToIframeMessage['data']) => {\n dispatch?.({type: 'navigate-to-iframe', data});\n },\n messageToPanel: (data: MessageToPanelMessage['data']) => {\n dispatch?.({type: 'message-to-panel', data});\n },\n openFlapPanel: (data: OpenFlapPanelMessage['data']) => {\n dispatch?.({type: 'open-flap-panel', data});\n },\n closeFlapPanel: () => {\n dispatch?.({type: 'close-flap-panel'});\n },\n getPanelConfig: (data: GetPanelConfigMessage['data']) => {\n const id = Date.now().toString();\n const {data: nextData, overrides} = storeCallbacks(data, id, callbacksStore);\n dispatch?.({type: 'get-panel-config', data: nextData as GetPanelConfigMessage['data'], id, overrides});\n },\n});\n"]}
|
|
@@ -38,6 +38,7 @@ export declare const basePanelSchema: z.ZodObject<{
|
|
|
38
38
|
export declare const iframePanelSchema: z.ZodObject<{
|
|
39
39
|
type: z.ZodLiteral<"custom">;
|
|
40
40
|
iframeSource: z.ZodString;
|
|
41
|
+
viewId: z.ZodOptional<z.ZodString>;
|
|
41
42
|
isSelfContaining: z.ZodOptional<z.ZodBoolean>;
|
|
42
43
|
}, z.core.$strip>;
|
|
43
44
|
export declare const creationPanelSchema: z.ZodObject<{
|
|
@@ -129,6 +130,7 @@ export declare const PanelSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
129
130
|
}, z.core.$strip>]>>, z.ZodObject<{
|
|
130
131
|
type: z.ZodLiteral<"custom">;
|
|
131
132
|
iframeSource: z.ZodString;
|
|
133
|
+
viewId: z.ZodOptional<z.ZodString>;
|
|
132
134
|
isSelfContaining: z.ZodOptional<z.ZodBoolean>;
|
|
133
135
|
}, z.core.$strip>, z.ZodObject<{
|
|
134
136
|
type: z.ZodLiteral<"editionForm">;
|
|
@@ -148,5 +150,6 @@ export declare const PanelIFrameSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
148
150
|
}, z.core.$strip>, z.ZodObject<{
|
|
149
151
|
type: z.ZodLiteral<"custom">;
|
|
150
152
|
iframeSource: z.ZodString;
|
|
153
|
+
viewId: z.ZodOptional<z.ZodString>;
|
|
151
154
|
isSelfContaining: z.ZodOptional<z.ZodBoolean>;
|
|
152
155
|
}, z.core.$strip>>;
|
|
@@ -49,6 +49,7 @@ export const basePanelSchema = z.object({
|
|
|
49
49
|
export const iframePanelSchema = z.object({
|
|
50
50
|
type: z.literal('custom'),
|
|
51
51
|
iframeSource: z.string(),
|
|
52
|
+
viewId: z.string().optional(),
|
|
52
53
|
isSelfContaining: z.boolean().optional(),
|
|
53
54
|
});
|
|
54
55
|
const editionPanelSchema = z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/schema.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC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,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,iBAAiB;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC1C,SAAS,EAAE,eAAe;IAC1B,aAAa,EAAE,mBAAmB,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC;AAEH,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,aAAa,EAAE,mBAAmB,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,GAAG,CACnD,CAAC,CAAC,KAAK,CAAC,CAAC,4BAA4B,EAAE,0BAA0B,CAAC,CAAC,CACtE,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAC1C,CAAC,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAC7F,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,GAAG,CAAC,iBAAiB,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 * as z from 'zod/v4';\n\nexport const FONT_AWESOME_ICON_REGEX = /^fa-/;\n\nexport const PanelIdSchema = z.string();\nexport const LanguageSchema = z.string();\nexport const LibraryIdSchema = z.string();\nexport const FontAwesomeIconSchema = z.string().regex(FONT_AWESOME_ICON_REGEX).optional();\n\nexport const WhereSchema = z.union([z.literal('popup'), z.literal('slider'), z.literal('fullpage')]);\n\nexport const FlapPanelIdSchema = z.union([z.literal('info-history'), z.literal('thread')]);\n\nexport const ExplorerPropsSchema = z.object({\n showSearch: z.boolean().optional(),\n showFilters: z.boolean().optional(),\n showSorts: z.boolean().optional(),\n freezeView: z.boolean().optional(),\n showAttributeLabels: z.boolean().optional(),\n creationFormId: z.string().optional(),\n noPagination: z.literal(true).optional(),\n showActionsLabels: z.boolean().optional(),\n defaultPrimaryActions: z.array(z.union([z.literal('create')])).optional(),\n defaultMassActions: z\n .array(z.union([z.literal('deactivate'), z.literal('export'), z.literal('editAttribute')]))\n .optional(),\n defaultActionsForItem: z\n .array(z.union([z.literal('replaceLink'), z.literal('remove'), z.literal('activate')]))\n .optional(),\n});\n\nexport const ItemActionsSchema = z\n .array(\n z.object({\n where: WhereSchema,\n what: z.literal('record'),\n targetPanelId: PanelIdSchema.optional(),\n targetFlapPanelId: FlapPanelIdSchema.optional(),\n icon: FontAwesomeIconSchema,\n label: z.record(LanguageSchema, z.string()),\n onRowClick: z.boolean().optional(),\n }),\n )\n .refine(actions => actions.reduce((acc, action) => (action.onRowClick ? acc + 1 : acc), 0) <= 1, {\n message: 'At most one action must have onRowClick set to true',\n });\n\nexport const basePanelSchema = z.object({\n id: PanelIdSchema,\n icon: FontAwesomeIconSchema,\n name: z.record(LanguageSchema, z.string()).optional(),\n isStandalone: z.boolean().optional(),\n hideInSlider: z.boolean().optional(),\n});\n\nexport const iframePanelSchema = z.object({\n type: z.literal('custom'),\n iframeSource: z.string(),\n isSelfContaining: z.boolean().optional(),\n});\n\nconst editionPanelSchema = z.object({\n type: z.literal('editionForm'),\n formId: z.string(),\n});\n\nexport const creationPanelSchema = z.object({\n type: z.literal('creationForm'),\n formId: z.string(),\n attributeSource: z.string(),\n isStandalone: z.literal(true),\n});\n\nexport const baseExplorerPanelSchema = z.object({\n type: z.literal('explorer'),\n viewId: z.string().optional(),\n actions: ItemActionsSchema,\n});\n\nexport const attributeExplorerPanelSchema = z.object({\n attributeSource: z.string(),\n deactivateOnUnlink: z.boolean().optional(),\n libraryId: LibraryIdSchema,\n explorerProps: ExplorerPropsSchema.optional(),\n});\n\nconst libraryExplorerPanelSchema = z.object({\n explorerProps: ExplorerPropsSchema.optional(),\n});\n\nconst explorerPanelSchema = baseExplorerPanelSchema.and(\n z.union([attributeExplorerPanelSchema, libraryExplorerPanelSchema]),\n);\n\nexport const PanelSchema = basePanelSchema.and(\n z.union([explorerPanelSchema, iframePanelSchema, editionPanelSchema, creationPanelSchema]),\n);\n\nexport const PanelIFrameSchema = basePanelSchema.and(iframePanelSchema);\n"]}
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/schema.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,QAAQ,EAAE,CAAC;AAE1F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAErG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAA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QAAQ,EAAE;CAChD,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,GAAG,CACnD,CAAC,CAAC,KAAK,CAAC,CAAC,4BAA4B,EAAE,0BAA0B,CAAC,CAAC,CACtE,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAC1C,CAAC,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAC7F,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,GAAG,CAAC,iBAAiB,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 * as z from 'zod/v4';\n\nexport const FONT_AWESOME_ICON_REGEX = /^fa-/;\n\nexport const PanelIdSchema = z.string();\nexport const LanguageSchema = z.string();\nexport const LibraryIdSchema = z.string();\nexport const FontAwesomeIconSchema = z.string().regex(FONT_AWESOME_ICON_REGEX).optional();\n\nexport const WhereSchema = z.union([z.literal('popup'), z.literal('slider'), z.literal('fullpage')]);\n\nexport const FlapPanelIdSchema = z.union([z.literal('info-history'), z.literal('thread')]);\n\nexport const ExplorerPropsSchema = z.object({\n showSearch: z.boolean().optional(),\n showFilters: z.boolean().optional(),\n showSorts: z.boolean().optional(),\n freezeView: z.boolean().optional(),\n showAttributeLabels: z.boolean().optional(),\n creationFormId: z.string().optional(),\n noPagination: z.literal(true).optional(),\n showActionsLabels: z.boolean().optional(),\n defaultPrimaryActions: z.array(z.union([z.literal('create')])).optional(),\n defaultMassActions: z\n .array(z.union([z.literal('deactivate'), z.literal('export'), z.literal('editAttribute')]))\n .optional(),\n defaultActionsForItem: z\n .array(z.union([z.literal('replaceLink'), z.literal('remove'), z.literal('activate')]))\n .optional(),\n});\n\nexport const ItemActionsSchema = z\n .array(\n z.object({\n where: WhereSchema,\n what: z.literal('record'),\n targetPanelId: PanelIdSchema.optional(),\n targetFlapPanelId: FlapPanelIdSchema.optional(),\n icon: FontAwesomeIconSchema,\n label: z.record(LanguageSchema, z.string()),\n onRowClick: z.boolean().optional(),\n }),\n )\n .refine(actions => actions.reduce((acc, action) => (action.onRowClick ? acc + 1 : acc), 0) <= 1, {\n message: 'At most one action must have onRowClick set to true',\n });\n\nexport const basePanelSchema = z.object({\n id: PanelIdSchema,\n icon: FontAwesomeIconSchema,\n name: z.record(LanguageSchema, z.string()).optional(),\n isStandalone: z.boolean().optional(),\n hideInSlider: z.boolean().optional(),\n});\n\nexport const iframePanelSchema = z.object({\n type: z.literal('custom'),\n iframeSource: z.string(),\n viewId: z.string().optional(),\n isSelfContaining: z.boolean().optional(),\n});\n\nconst editionPanelSchema = z.object({\n type: z.literal('editionForm'),\n formId: z.string(),\n});\n\nexport const creationPanelSchema = z.object({\n type: z.literal('creationForm'),\n formId: z.string(),\n attributeSource: z.string(),\n isStandalone: z.literal(true),\n});\n\nexport const baseExplorerPanelSchema = z.object({\n type: z.literal('explorer'),\n viewId: z.string().optional(),\n actions: ItemActionsSchema,\n});\n\nexport const attributeExplorerPanelSchema = z.object({\n attributeSource: z.string(),\n deactivateOnUnlink: z.boolean().optional(),\n libraryId: LibraryIdSchema,\n explorerProps: ExplorerPropsSchema.optional(),\n});\n\nconst libraryExplorerPanelSchema = z.object({\n explorerProps: ExplorerPropsSchema.optional(),\n});\n\nconst explorerPanelSchema = baseExplorerPanelSchema.and(\n z.union([attributeExplorerPanelSchema, libraryExplorerPanelSchema]),\n);\n\nexport const PanelSchema = basePanelSchema.and(\n z.union([explorerPanelSchema, iframePanelSchema, editionPanelSchema, creationPanelSchema]),\n);\n\nexport const PanelIFrameSchema = basePanelSchema.and(iframePanelSchema);\n"]}
|
|
@@ -55,7 +55,7 @@ export type AttributeExplorerPanel = Panel & z.infer<typeof baseExplorerPanelSch
|
|
|
55
55
|
export type LibraryId = z.infer<typeof LibraryIdSchema>;
|
|
56
56
|
export type PanelId = z.infer<typeof PanelIdSchema>;
|
|
57
57
|
export type Where = z.infer<typeof WhereSchema>;
|
|
58
|
-
type PanelIFrame = z.infer<typeof PanelIFrameSchema>;
|
|
58
|
+
export type PanelIFrame = z.infer<typeof PanelIFrameSchema>;
|
|
59
59
|
type FlapPanelId = z.infer<typeof FlapPanelIdSchema>;
|
|
60
60
|
export type NavigateToPanelMessage = IMessageBase & {
|
|
61
61
|
type: 'navigate-to-panel';
|
|
@@ -108,7 +108,16 @@ export type OpenFlapPanelMessage = IMessageBase & {
|
|
|
108
108
|
export type CloseFlapPanelMessage = IMessageBase & {
|
|
109
109
|
type: 'close-flap-panel';
|
|
110
110
|
};
|
|
111
|
-
export type
|
|
111
|
+
export type GetPanelConfigMessage = IMessageBase & {
|
|
112
|
+
type: 'get-panel-config';
|
|
113
|
+
id: string;
|
|
114
|
+
data: {
|
|
115
|
+
panelId?: string;
|
|
116
|
+
onGetPanelConfig: (data: PanelIFrame) => void;
|
|
117
|
+
};
|
|
118
|
+
overrides?: string[];
|
|
119
|
+
};
|
|
120
|
+
export type MessageToParent = ModalConfirmMessage | AlertMessage | NotificationMessage | SimpleMessage | RegisterMessage | UnregisterMessage | NavigateToPanelMessage | ClosePanelMessage | NavigateToIframeMessage | MessageToPanelMessage | OpenFlapPanelMessage | CloseFlapPanelMessage | GetPanelConfigMessage;
|
|
112
121
|
export type MessageFromParent = (IMessageBase & {
|
|
113
122
|
type: 'on-call-callback';
|
|
114
123
|
path: string;
|
|
@@ -134,6 +143,7 @@ export interface IUseIFrameMessengerOptions {
|
|
|
134
143
|
onClosePanel?: (data: ClosePanelMessage['data']) => void;
|
|
135
144
|
onNavigateToIframe?: (data: NavigateToIframeMessage['data']) => void;
|
|
136
145
|
onOpenFlapPanel?: (data: OpenFlapPanelMessage['data']) => void;
|
|
146
|
+
onGetPanelConfig?: (data: GetPanelConfigMessage['data'], id: string, dispatch: MessageDispatcher, callCb: CallCbFunction) => void;
|
|
137
147
|
onCloseFlapPanel?: () => void;
|
|
138
148
|
};
|
|
139
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/types.ts"],"names":[],"mappings":"AAmBA,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';\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 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\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/useIFrameMessenger/types.ts"],"names":[],"mappings":"AAmBA,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';\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 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 };\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 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 | GetPanelConfigMessage;\n\nexport type MessageFromParent =\n | (IMessageBase & {\n type: 'on-call-callback';\n path: string;\n data: unknown;\n })\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 onGetPanelConfig?: (\n data: GetPanelConfigMessage['data'],\n id: string,\n dispatch: MessageDispatcher,\n callCb: CallCbFunction,\n ) => void;\n onCloseFlapPanel?: () => void;\n };\n}\n"]}
|
|
@@ -18,4 +18,5 @@ export declare const useIFrameMessenger: (options?: IUseIFrameMessengerOptions)
|
|
|
18
18
|
messageToPanel: (data: import("./types").MessageToPanelMessage["data"]) => void;
|
|
19
19
|
openFlapPanel: (data: import("./types").OpenFlapPanelMessage["data"]) => void;
|
|
20
20
|
closeFlapPanel: () => void;
|
|
21
|
+
getPanelConfig: (data: import("./types").GetPanelConfigMessage["data"]) => void;
|
|
21
22
|
};
|
|
@@ -53,6 +53,16 @@ export const useIFrameMessenger = (options) => {
|
|
|
53
53
|
changeLangInAllFrames,
|
|
54
54
|
addPanelMessageHandler,
|
|
55
55
|
});
|
|
56
|
+
const getPanelIdFromEvent = (event) => {
|
|
57
|
+
const iFrames = window.document.getElementsByTagName('iframe');
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
59
|
+
for (let i = 0; i < iFrames.length; i++) {
|
|
60
|
+
if (event.source === iFrames[i].contentWindow) {
|
|
61
|
+
return iFrames[i].name;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
56
66
|
useEffect(() => {
|
|
57
67
|
const clientHandlers = initClientHandlers(callCb, { ...options, id: selfId.current }, callbacksStore);
|
|
58
68
|
const onMessage = (event) => {
|
|
@@ -83,6 +93,11 @@ export const useIFrameMessenger = (options) => {
|
|
|
83
93
|
dispatch(message, target);
|
|
84
94
|
}
|
|
85
95
|
break;
|
|
96
|
+
case 'get-panel-config':
|
|
97
|
+
clientHandlers({
|
|
98
|
+
...message,
|
|
99
|
+
data: { ...message.data, panelId: getPanelIdFromEvent(event) },
|
|
100
|
+
}, dispatch);
|
|
86
101
|
default:
|
|
87
102
|
if (message.type === 'change-language') {
|
|
88
103
|
setLang(message.language);
|
|
@@ -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,EAAC,MAAM,OAAO,CAAC;AACjE,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;IAEjE,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,MAA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AAC,CAAC;QACrD,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,OAAO,CAAC,OAAO,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useCallback, useContext, useEffect, useRef} 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\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 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 break;\n case 'unregister':\n if (registry.current[message.id]) {\n delete registry.current[message.id];\n }\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 {\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 methods.current;\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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E,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,OAAO,CAAC,OAAO,CAAC;AAC3B,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useCallback, useContext, useEffect, useRef} 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\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 break;\n case 'unregister':\n if (registry.current[message.id]) {\n delete registry.current[message.id];\n }\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 methods.current;\n};\n"]}
|
|
@@ -12,4 +12,5 @@ export declare const IframeMessengerClientContext: import("react").Context<{
|
|
|
12
12
|
messageToPanel: (data: import("../useIFrameMessenger/types").MessageToPanelMessage["data"]) => void;
|
|
13
13
|
openFlapPanel: (data: import("../useIFrameMessenger/types").OpenFlapPanelMessage["data"]) => void;
|
|
14
14
|
closeFlapPanel: () => void;
|
|
15
|
+
getPanelConfig: (data: import("../useIFrameMessenger/types").GetPanelConfigMessage["data"]) => void;
|
|
15
16
|
}>;
|
|
@@ -12,4 +12,5 @@ export declare const useIFrameMessengerClient: () => {
|
|
|
12
12
|
messageToPanel: (data: import("../useIFrameMessenger/types").MessageToPanelMessage["data"]) => void;
|
|
13
13
|
openFlapPanel: (data: import("../useIFrameMessenger/types").OpenFlapPanelMessage["data"]) => void;
|
|
14
14
|
closeFlapPanel: () => void;
|
|
15
|
+
getPanelConfig: (data: import("../useIFrameMessenger/types").GetPanelConfigMessage["data"]) => void;
|
|
15
16
|
};
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"max_length": "Max length",
|
|
38
38
|
"confirm": "Confirm",
|
|
39
39
|
"loading": "Loading",
|
|
40
|
-
"are_you_sure": "Are you sure?"
|
|
40
|
+
"are_you_sure": "Are you sure?",
|
|
41
|
+
"reset": "Reset"
|
|
41
42
|
},
|
|
42
43
|
"errors": {
|
|
43
44
|
"default_language_required": "The default language is required",
|
|
@@ -699,7 +700,6 @@
|
|
|
699
700
|
"inactive": "Inactive sorts"
|
|
700
701
|
},
|
|
701
702
|
"toolbar": "Toolbar",
|
|
702
|
-
"reset-filter": "Reset filter",
|
|
703
703
|
"reset-view": "Reset view",
|
|
704
704
|
"empty-data": "No items found.",
|
|
705
705
|
"available-attributes": "Other available attributes",
|
|
@@ -776,6 +776,17 @@
|
|
|
776
776
|
"deselect_all": "Deselect all items"
|
|
777
777
|
}
|
|
778
778
|
},
|
|
779
|
+
"export_profile_modal": {
|
|
780
|
+
"title": "Export",
|
|
781
|
+
"profile_label": "Choose an export profile",
|
|
782
|
+
"preview_label": "Preview of exported attributes",
|
|
783
|
+
"search_placeholder": "Search...",
|
|
784
|
+
"no_profiles": "No export profiles configured for this library",
|
|
785
|
+
"contact_admin": "Please contact an administrator to configure export profiles.",
|
|
786
|
+
"empty_columns": "(empty column)",
|
|
787
|
+
"export_button": "Export",
|
|
788
|
+
"error_title": "Export profile error"
|
|
789
|
+
},
|
|
779
790
|
"add-existing-item": "Add existing item",
|
|
780
791
|
"activate_item_one": "Activate this item?",
|
|
781
792
|
"activate_item_other": "Activate these items?",
|
|
@@ -792,6 +803,7 @@
|
|
|
792
803
|
"delete_link_one": "Delete this link?",
|
|
793
804
|
"delete_link_other": "Delete these links?",
|
|
794
805
|
"delete_link_description_one": "You are about to delete this link.",
|
|
795
|
-
"delete_link_description_other": "You are about to delete these links."
|
|
806
|
+
"delete_link_description_other": "You are about to delete these links.",
|
|
807
|
+
"empty_value": "Undefined"
|
|
796
808
|
}
|
|
797
809
|
}
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"max_length": "Longueur maximale",
|
|
38
38
|
"confirm": "Confirmer",
|
|
39
39
|
"loading": "Chargement",
|
|
40
|
-
"are_you_sure": "Êtes-vous sûr ?"
|
|
40
|
+
"are_you_sure": "Êtes-vous sûr ?",
|
|
41
|
+
"reset": "Réinitialiser"
|
|
41
42
|
},
|
|
42
43
|
"errors": {
|
|
43
44
|
"default_language_required": "La langue par défaut est requise",
|
|
@@ -697,7 +698,6 @@
|
|
|
697
698
|
"inactive": "Tris inactifs"
|
|
698
699
|
},
|
|
699
700
|
"toolbar": "Barre d’outils",
|
|
700
|
-
"reset-filter": "Réinitialiser le filtre",
|
|
701
701
|
"reset-view": "Réinitialiser la vue",
|
|
702
702
|
"empty-data": "Aucun élément trouvé.",
|
|
703
703
|
"sort-ascending": "Ascendant",
|
|
@@ -776,6 +776,17 @@
|
|
|
776
776
|
"deselect_all": "Tout désélectionner"
|
|
777
777
|
}
|
|
778
778
|
},
|
|
779
|
+
"export_profile_modal": {
|
|
780
|
+
"title": "Export",
|
|
781
|
+
"profile_label": "Choisir un profil d'export",
|
|
782
|
+
"preview_label": "Aperçu des attributs exportés",
|
|
783
|
+
"search_placeholder": "Rechercher...",
|
|
784
|
+
"no_profiles": "Aucun profil d'export configuré pour cette librairie",
|
|
785
|
+
"contact_admin": "Veuillez contacter un administrateur pour configurer les profils d'export.",
|
|
786
|
+
"empty_columns": "(colonne vide)",
|
|
787
|
+
"export_button": "Exporter",
|
|
788
|
+
"error_title": "Erreur de profil d'export"
|
|
789
|
+
},
|
|
779
790
|
"add-existing-item": "Ajouter un élément existant",
|
|
780
791
|
"activate_item_one": "Activer cet élément ?",
|
|
781
792
|
"activate_item_other": "Activer ces éléments ?",
|
|
@@ -792,6 +803,7 @@
|
|
|
792
803
|
"delete_link_one": "Supprimer cette liaison ?",
|
|
793
804
|
"delete_link_other": "Supprimer ces liaisons ?",
|
|
794
805
|
"delete_link_description_one": "Vous êtes sur le point de supprimer cette liaison.",
|
|
795
|
-
"delete_link_description_other": "Vous êtes sur le point de supprimer ces liaisons."
|
|
806
|
+
"delete_link_description_other": "Vous êtes sur le point de supprimer ces liaisons.",
|
|
807
|
+
"empty_value": "Non défini"
|
|
796
808
|
}
|
|
797
809
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.6.0-
|
|
3
|
+
"version": "1.6.0-e751f378",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -28,7 +28,10 @@
|
|
|
28
28
|
"@babel/preset-env": "7.28.5",
|
|
29
29
|
"@babel/preset-react": "7.28.5",
|
|
30
30
|
"@graphql-codegen/add": "5.0.3",
|
|
31
|
-
"@graphql-codegen/cli": "
|
|
31
|
+
"@graphql-codegen/cli": "6.1.0",
|
|
32
|
+
"@graphql-codegen/typescript": "5.0.7",
|
|
33
|
+
"@graphql-codegen/typescript-operations": "5.0.7",
|
|
34
|
+
"@graphql-codegen/typescript-react-apollo": "4.4.0",
|
|
32
35
|
"@testing-library/jest-dom": "5.16.5",
|
|
33
36
|
"@testing-library/react": "14.0.0",
|
|
34
37
|
"@testing-library/react-hooks": "8.0.1",
|
|
@@ -42,15 +45,13 @@
|
|
|
42
45
|
"@types/react-beautiful-dnd": "13.1.8",
|
|
43
46
|
"@types/react-dom": "18.2.6",
|
|
44
47
|
"@types/react-table": "7.7.20",
|
|
45
|
-
"
|
|
46
|
-
"aristid-ds": "14.0.0-c13d6a5",
|
|
48
|
+
"aristid-ds": "14.0.0-fd68c13",
|
|
47
49
|
"babel-jest": "29.3.1",
|
|
48
|
-
"commander": "9.5.0",
|
|
49
50
|
"graphql": "16.12.0",
|
|
50
51
|
"i18next": "22.5.1",
|
|
51
52
|
"jest": "29.0.3",
|
|
52
53
|
"jest-environment-jsdom": "29.3.1",
|
|
53
|
-
"jest-styled-components": "7.
|
|
54
|
+
"jest-styled-components": "7.2.0",
|
|
54
55
|
"react": "18.2.0",
|
|
55
56
|
"react-dom": "18.2.0",
|
|
56
57
|
"react-i18next": "12",
|
|
@@ -64,14 +65,12 @@
|
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"@ant-design/icons": ">=5.2",
|
|
66
67
|
"@apollo/client": ">=3.8.1",
|
|
67
|
-
"
|
|
68
|
-
"aristid-ds": "14.0.0-c13d6a5",
|
|
68
|
+
"aristid-ds": "14.0.0-fd68c13",
|
|
69
69
|
"dayjs": "^1.11.13",
|
|
70
70
|
"i18next": "22.5",
|
|
71
71
|
"react": "18.2.0",
|
|
72
72
|
"react-dom": "18.2.0",
|
|
73
73
|
"react-i18next": "12",
|
|
74
|
-
"react-icons": ">=4",
|
|
75
74
|
"react-router-dom": "6.22.0",
|
|
76
75
|
"styled-components": ">=5.3"
|
|
77
76
|
},
|
|
@@ -80,6 +79,10 @@
|
|
|
80
79
|
"@ckeditor/ckeditor5-react": "6.1.0",
|
|
81
80
|
"@dnd-kit/core": "6.1.0",
|
|
82
81
|
"@dnd-kit/sortable": "8.0.0",
|
|
82
|
+
"@fortawesome/fontawesome-svg-core": "7.0.1",
|
|
83
|
+
"@fortawesome/free-regular-svg-icons": "7.0.1",
|
|
84
|
+
"@fortawesome/free-solid-svg-icons": "7.0.1",
|
|
85
|
+
"@fortawesome/react-fontawesome": "3.0.2",
|
|
83
86
|
"@leav/utils": "1.6.0",
|
|
84
87
|
"@uidotdev/usehooks": "2.4.1",
|
|
85
88
|
"dompurify": "3.2.4",
|
|
@@ -88,7 +91,6 @@
|
|
|
88
91
|
"lodash.isequal": "4.5.0",
|
|
89
92
|
"object-path": "0.11.8",
|
|
90
93
|
"react-beautiful-dnd": "13.1.1",
|
|
91
|
-
"react-icons": "4.7.1",
|
|
92
94
|
"react-markdown": "5.0.3",
|
|
93
95
|
"react-table": "7.8.0",
|
|
94
96
|
"react-table-sticky": "1.1.3",
|