@leav/ui 1.12.0-a0a98764 → 1.12.0-a3cb7513
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__mocks__/utils.d.ts +3 -0
- package/dist/__mocks__/utils.js +2 -0
- package/dist/__mocks__/utils.js.map +1 -0
- package/dist/_gqlTypes/index.d.ts +325 -59
- package/dist/_gqlTypes/index.js +249 -46
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/components/Explorer/DataView.js +31 -14
- package/dist/components/Explorer/DataView.js.map +1 -1
- package/dist/components/Explorer/_constants.d.ts +0 -1
- package/dist/components/Explorer/_constants.js +0 -1
- package/dist/components/Explorer/_constants.js.map +1 -1
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js +5 -9
- package/dist/components/Explorer/actions-item/useEditStatusItemAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.d.ts +4 -9
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js +3 -11
- package/dist/components/Explorer/actions-mass/edit-attribute/EditAttributeMassActionModal.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.d.ts +8 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js +26 -13
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValuesMapping.js.map +1 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.d.ts +7 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js +30 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/TreeNodeRemap.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.d.ts +23 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js +2 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/_types.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.d.ts +4 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js +46 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useMassEditableAttributes.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.d.ts +12 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js +24 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useTreeNodeRemapping.js.map +1 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.d.ts +13 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js +28 -0
- package/dist/components/Explorer/actions-mass/edit-attribute/useValuesDistribution.js.map +1 -0
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js +6 -10
- package/dist/components/Explorer/actions-mass/useDeactivateMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js +5 -8
- package/dist/components/Explorer/actions-mass/useDeleteLinkValues.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.d.ts +8 -2
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js +104 -80
- package/dist/components/Explorer/actions-mass/useEditAttributeMassAction.js.map +1 -1
- package/dist/components/Explorer/actions-mass/useMassActions.js +30 -19
- package/dist/components/Explorer/actions-mass/useMassActions.js.map +1 -1
- package/dist/components/Explorer/conditionsHelper.d.ts +2 -1
- package/dist/components/Explorer/conditionsHelper.js.map +1 -1
- package/dist/components/Filters/conditionsHelper.d.ts +2 -1
- package/dist/components/Filters/conditionsHelper.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/useConditionOptionsByType.js.map +1 -1
- package/dist/components/Filters/useTransformFilters.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +8 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.d.ts +1 -4
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js +5 -9
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js +4 -8
- package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js +4 -8
- package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.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/index.d.ts +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useConfirmModal/__mocks__/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js +5 -0
- package/dist/hooks/useConfirmModal/__mocks__/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.d.ts +3 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js +7 -0
- package/dist/hooks/useConfirmModal/__mocks__/useConfirmModal.js.map +1 -0
- package/dist/hooks/useConfirmModal/index.d.ts +1 -0
- package/dist/hooks/useConfirmModal/index.js +5 -0
- package/dist/hooks/useConfirmModal/index.js.map +1 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.d.ts +7 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js +25 -0
- package/dist/hooks/useConfirmModal/useConfirmModal.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/index.d.ts +1 -0
- package/dist/hooks/useGetRecordIdCard/index.js +5 -0
- package/dist/hooks/useGetRecordIdCard/index.js.map +1 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.d.ts +18 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js +20 -0
- package/dist/hooks/useGetRecordIdCard/useGetRecordIdCard.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.d.ts +6 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js +8 -0
- package/dist/hooks/useIFrameMessenger/iFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/types.d.ts +5 -2
- package/dist/hooks/useIFrameMessenger/types.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.d.ts +10 -2
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js +21 -9
- package/dist/hooks/useIFrameMessenger/useIFrameMessenger.js.map +1 -1
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js +59 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerContext.js.map +1 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.d.ts +13 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js +29 -0
- package/dist/hooks/useIFrameMessenger/useIFrameMessengerHandlers.js.map +1 -0
- package/dist/hooks/useSharedTranslation/__mocks__/useSharedTranslation.js.map +1 -1
- package/dist/locales/en/shared.json +6 -4
- package/dist/locales/fr/shared.json +8 -6
- package/package.json +9 -9
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.d.ts +0 -8
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js +0 -40
- package/dist/components/Explorer/actions-mass/edit-attribute/EditTreeAttributeValueLine.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.d.ts +0 -17
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js +0 -42
- package/dist/components/Explorer/actions-mass/edit-attribute/useCountValuesOccurrencesHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.d.ts +0 -5
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js +0 -20
- package/dist/components/Explorer/actions-mass/edit-attribute/useListEditableAttributeHook.js.map +0 -1
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.d.ts +0 -12
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js +0 -30
- package/dist/components/Explorer/actions-mass/edit-attribute/useListTreeAttributeValuesHook.js.map +0 -1
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
import { BREAK_TWO_LINES } from '../../../../../../../components/Explorer/_constants';
|
|
5
4
|
import { APICallStatus } from '../../../../../../../components/RecordEdition/EditRecordContent/_types';
|
|
6
5
|
import { useSharedTranslation } from '../../../../../../../hooks/useSharedTranslation';
|
|
7
|
-
import {
|
|
6
|
+
import { useConfirmModal } from '../../../../../../../hooks/useConfirmModal/useConfirmModal';
|
|
7
|
+
import { BREAK_TWO_LINES } from '../../../../../../../constants';
|
|
8
|
+
import { AntForm } from 'aristid-ds';
|
|
8
9
|
export const useUnlinkRecord = ({ attribute, backendValues, isReadOnly, setBackendValues, onValueDelete, }) => {
|
|
9
10
|
const { t } = useSharedTranslation();
|
|
11
|
+
const { openConfirmModal } = useConfirmModal();
|
|
10
12
|
const antdForm = AntForm.useFormInstance();
|
|
11
13
|
const handleUnlinkRecord = async (idValue) => {
|
|
12
14
|
const deleteRes = await onValueDelete({ id_value: idValue }, attribute.id);
|
|
@@ -25,15 +27,9 @@ export const useUnlinkRecord = ({ attribute, backendValues, isReadOnly, setBacke
|
|
|
25
27
|
const canUnlinkRecord = !isReadOnly && (!attribute.required || (attribute.required && backendValues.length > 1));
|
|
26
28
|
return {
|
|
27
29
|
canUnlinkRecord,
|
|
28
|
-
unlinkRecord: (idValue) =>
|
|
29
|
-
width: '100%',
|
|
30
|
-
style: { content: { width: '90vw', maxWidth: '656px' } },
|
|
31
|
-
type: 'confirm',
|
|
32
|
-
icon: false,
|
|
30
|
+
unlinkRecord: (idValue) => openConfirmModal({
|
|
33
31
|
title: t('record_edition.delete_link'),
|
|
34
32
|
content: t('record_edition.delete_link_description') + BREAK_TWO_LINES + t('global.are_you_sure'),
|
|
35
|
-
okText: t('global.confirm') ?? undefined,
|
|
36
|
-
cancelText: t('global.cancel') ?? undefined,
|
|
37
33
|
onOk: async () => {
|
|
38
34
|
await handleUnlinkRecord(idValue);
|
|
39
35
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnlinkRecord.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"useUnlinkRecord.js","sourceRoot":"","sources":["../../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/unlink-record/useUnlinkRecord.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,aAAa,EAAuB,MAAM,uDAAuD,CAAC;AAG1G,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAUnC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,CAAC,wCAAwC,CAAC,GAAG,eAAe,GAAG,CAAC,CAAC,qBAAqB,CAAC;YACjG,IAAI,EAAE,KAAK,IAAI,EAAE;gBACb,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACtC,CAAC;SACJ,CAAC;KACT,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 {APICallStatus, type DeleteValueFunc} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {type RecordFormAttributeLinkAttributeFragment} from '_ui/_gqlTypes';\nimport {type RecordFormElementsValueLinkValue} from '_ui/hooks/useGetRecordForm';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useConfirmModal} from '_ui/hooks/useConfirmModal/useConfirmModal';\nimport {BREAK_TWO_LINES} from '_ui/constants';\nimport {AntForm} from 'aristid-ds';\nimport {type Dispatch, type SetStateAction} from 'react';\n\ninterface IUseUnlinkRecordProps {\n attribute: RecordFormAttributeLinkAttributeFragment;\n backendValues: RecordFormElementsValueLinkValue[];\n isReadOnly: boolean;\n setBackendValues: Dispatch<SetStateAction<RecordFormElementsValueLinkValue[]>>;\n onValueDelete: DeleteValueFunc;\n}\nexport const useUnlinkRecord = ({\n attribute,\n backendValues,\n isReadOnly,\n setBackendValues,\n onValueDelete,\n}: IUseUnlinkRecordProps) => {\n const {t} = useSharedTranslation();\n const {openConfirmModal} = useConfirmModal();\n const antdForm = AntForm.useFormInstance();\n\n const handleUnlinkRecord = async (idValue: string) => {\n const deleteRes = await onValueDelete({id_value: idValue}, attribute.id);\n\n if (deleteRes.status === APICallStatus.SUCCESS) {\n setBackendValues(previousBackendValues =>\n previousBackendValues.filter(backendValue => backendValue.id_value !== idValue),\n );\n }\n\n if (deleteRes.status === APICallStatus.ERROR) {\n antdForm.setFields([\n {\n name: attribute.id,\n errors: [deleteRes.error],\n },\n ]);\n }\n };\n\n const canUnlinkRecord = !isReadOnly && (!attribute.required || (attribute.required && backendValues.length > 1));\n\n return {\n canUnlinkRecord,\n unlinkRecord: (idValue: string) =>\n openConfirmModal({\n title: t('record_edition.delete_link'),\n content: t('record_edition.delete_link_description') + BREAK_TWO_LINES + t('global.are_you_sure'),\n onOk: async () => {\n await handleUnlinkRecord(idValue);\n },\n }),\n };\n};\n"]}
|
package/dist/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.js
CHANGED
|
@@ -3,20 +3,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
5
|
import { useSharedTranslation } from '../../../../../hooks/useSharedTranslation';
|
|
6
|
-
import {
|
|
6
|
+
import { useConfirmModal } from '../../../../../hooks/useConfirmModal';
|
|
7
|
+
import { KitButton } from 'aristid-ds';
|
|
7
8
|
export const DeleteAllValuesButton = ({ handleDelete, disabled, danger, }) => {
|
|
8
9
|
const { t } = useSharedTranslation();
|
|
10
|
+
const { openConfirmModal } = useConfirmModal();
|
|
9
11
|
const _confirmDeleteAllValues = () => {
|
|
10
|
-
|
|
12
|
+
openConfirmModal({
|
|
11
13
|
title: t('record_edition.delete_all_values'),
|
|
12
14
|
content: t('record_edition.delete_all_values_confirm'),
|
|
13
|
-
icon: false,
|
|
14
|
-
showSecondaryCta: true,
|
|
15
|
-
showCloseIcon: false,
|
|
16
15
|
dangerConfirm: true,
|
|
17
|
-
type: 'confirm',
|
|
18
|
-
okText: t('global.confirm'),
|
|
19
|
-
cancelText: t('global.cancel'),
|
|
20
16
|
onOk: handleDelete,
|
|
21
17
|
});
|
|
22
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteAllValuesButton.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"DeleteAllValuesButton.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/shared/DeleteAllValuesButton.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AASrC,MAAM,CAAC,MAAM,qBAAqB,GAAmD,CAAC,EAClF,YAAY,EACZ,QAAQ,EACR,MAAM,GACT,EAAE,EAAE;IACD,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,gBAAgB,EAAC,GAAG,eAAe,EAAE,CAAC;IAE7C,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACjC,gBAAgB,CAAC;YACb,KAAK,EAAE,CAAC,CAAC,kCAAkC,CAAC;YAC5C,OAAO,EAAE,CAAC,CAAC,0CAA0C,CAAC;YACtD,aAAa,EAAE,IAAI;YACnB,IAAI,EAAE,YAAY;SACrB,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,SAAS,IAAC,IAAI,EAAC,UAAU,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YACnG,CAAC,CAAC,2BAA2B,CAAC,GACvB,CACf,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useConfirmModal} from '_ui/hooks/useConfirmModal';\nimport {KitButton} from 'aristid-ds';\nimport {type FunctionComponent} from 'react';\n\ninterface IDeleteAllValuesButtonProps {\n handleDelete: () => void;\n disabled?: boolean;\n danger?: boolean;\n}\n\nexport const DeleteAllValuesButton: FunctionComponent<IDeleteAllValuesButtonProps> = ({\n handleDelete,\n disabled,\n danger,\n}) => {\n const {t} = useSharedTranslation();\n const {openConfirmModal} = useConfirmModal();\n\n const _confirmDeleteAllValues = () => {\n openConfirmModal({\n title: t('record_edition.delete_all_values'),\n content: t('record_edition.delete_all_values_confirm'),\n dangerConfirm: true,\n onOk: handleDelete,\n });\n };\n\n return (\n <KitButton type=\"tertiary\" size=\"s\" onClick={_confirmDeleteAllValues} disabled={disabled} danger={danger}>\n {t('record_edition.delete_all')}\n </KitButton>\n );\n};\n"]}
|
|
@@ -135,7 +135,7 @@ export const EditRecordModal = ({ className, open, record, creationFormId, editi
|
|
|
135
135
|
};
|
|
136
136
|
const displayedSubmitButtons = useGetSubmitButtons(submitButtons, formElementId.current, isCreation, _handleClickSubmit, _handleClose);
|
|
137
137
|
return (_jsxs(KitModalStyled, { appElement: document.getElementById('root'), className: className, height: autoHeight ? 'auto' : MODAL_HEIGHT, maxHeight: autoHeight ? MODAL_HEIGHT : undefined, width: MODAL_WIDTH, isOpen: open, close: _handleClose, title: _jsxs(KitSpace, { children: [_jsx(KitTypography.Title, { level: "h2", style: { margin: 0 }, children: modalTitle }), _jsx("div", { id: EDIT_RECORD_MODAL_HEADER_CONTAINER_BUTTONS })] }), footer: _jsx(KitSpace, { children: [
|
|
138
|
-
_jsx(KitButton, { "aria-label": closeButtonLabel, icon: _jsx(FontAwesomeIcon, { icon: faXmark }), onClick: _handleClose, children: closeButtonLabel }, "close"),
|
|
138
|
+
_jsx(KitButton, { "aria-label": closeButtonLabel, size: "m", icon: _jsx(FontAwesomeIcon, { icon: faXmark }), onClick: _handleClose, children: closeButtonLabel }, "close"),
|
|
139
139
|
...displayedSubmitButtons,
|
|
140
140
|
] }), closeIcon: _jsx(FontAwesomeIcon, { icon: faXmark }), showCloseIcon: true, destroyOnClose: true, children: [isError && _jsx(ErrorComponent, {}), !isReady && _jsx(KitLoader, {}), isReady && (_jsx(EditRecord, { antdForm: antdForm, isFormCreationMode: isCreation, formId: formId, formElementId: formElementId.current, record: currentRecord, library: library, scrollAllRecordSummary: true, onCreate: _handleCreate, valuesVersion: valuesVersion, showSidebar: showSidebar, enableSidebar: enableSidebar, withInfoButton: withInfoButton }))] }));
|
|
141
141
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditRecordModal.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordModal/EditRecordModal.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAA8B,uBAAuB,EAAE,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAE1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAC,0CAA0C,EAAC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cAAc,KAAG,EAC7B,CAAC,OAAO,IAAI,KAAC,SAAS,KAAG,EACzB,OAAO,IAAI,CACR,KAAC,UAAU,IACP,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,UAAU,EAC9B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,CAAC,OAAO,EACpC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,EAChB,sBAAsB,QACtB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAChC,CACL,IACY,CACpB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useEffect, useRef, useState} from 'react';\nimport {KitButton, KitLoader, KitModal, KitSpace, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IValueVersion} from '_ui/types';\nimport {type RecordIdentityFragment, useCreateRecordMutation, usePurgeRecordMutation} from '_ui/_gqlTypes';\nimport {EditRecord} from '../EditRecord';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faXmark} from '@fortawesome/free-solid-svg-icons';\nimport {type PossibleSubmitButtons, type SubmitButtonsName} from '../_types';\nimport {useGetSubmitButtons} from '../hooks/useGetSubmitButtons';\nimport {useForm} from 'antd/lib/form/Form';\nimport {useCreateCancelConfirm} from '../hooks/useCreateCancelConfirm';\nimport {EDIT_RECORD_MODAL_HEADER_CONTAINER_BUTTONS} from '../constants';\nimport {useGetInitialRecordValues} from '../EditRecordPage/getInitialRecordValues';\nimport {ErrorComponent} from '../EditRecordPage/ErrorComponent';\n\nexport interface IEditRecordModalProps {\n className?: string;\n open: boolean;\n record: RecordIdentityFragment['whoAmI'] | null;\n creationFormId?: string;\n editionFormId?: string;\n library: string;\n onClose: () => void;\n onCreate?: (newRecord: RecordIdentityFragment['whoAmI']) => void; // Called after submitting via the \"create\" button\n onCreateAndEdit?: (newRecord: RecordIdentityFragment['whoAmI']) => void; // Called after submitting via the \"create and edit\" button\n submitButtons?: PossibleSubmitButtons;\n withInfoButton?: boolean;\n valuesVersion?: IValueVersion;\n showSidebar?: boolean;\n enableSidebar?: boolean;\n autoHeight?: boolean;\n}\n\nconst MODAL_HEIGHT = '80vh';\nconst MODAL_WIDTH = '90vw';\nconst MODAL_MAX_WIDTH = '656px';\nconst MODAL_WITH_SIDEBAR_MAX_WIDTH = '900px';\n\nconst KitModalStyled = styled(KitModal)`\n && {\n & > div {\n max-width: ${MODAL_MAX_WIDTH};\n\n &:has(#edit_record_sidebar) {\n max-width: ${MODAL_WITH_SIDEBAR_MAX_WIDTH};\n }\n\n .kit-modal-header {\n border-bottom: 1px solid var(--general-utilities-border);\n\n .kit-modal-title {\n padding-right: calc(var(--general-spacing-xs) * 1px);\n\n .ant-space {\n width: 100%;\n justify-content: space-between;\n }\n }\n }\n\n .kit-modal-content-wrapper {\n padding: 0;\n\n .kit-modal-content {\n height: 100%;\n\n & > div {\n height: 100%;\n }\n }\n }\n }\n }\n`;\n\nexport const EditRecordModal: FunctionComponent<IEditRecordModalProps> = ({\n className,\n open,\n record,\n creationFormId,\n editionFormId,\n library,\n onClose,\n onCreate,\n onCreateAndEdit,\n valuesVersion,\n showSidebar,\n enableSidebar,\n submitButtons = ['create'],\n withInfoButton = true,\n autoHeight = false,\n}) => {\n const {t} = useSharedTranslation();\n const [antdForm] = useForm();\n const [currentRecord, setCurrentRecord] = useState<RecordIdentityFragment['whoAmI'] | null>(record);\n const clickedSubmitButton = useRef<SubmitButtonsName | null>(null);\n const [createRecord] = useCreateRecordMutation();\n const [purgeRecordMutation] = usePurgeRecordMutation();\n\n const formElementId = useRef(window.crypto.randomUUID());\n const [isCreation, setIsCreation] = useState(!record);\n const [isReady, setIsReady] = useState(!!record);\n const [isError, setIsError] = useState(false);\n const [formId, setFormId] = useState<string>(\n isCreation ? (creationFormId ?? 'creation') : (editionFormId ?? 'edition'),\n );\n const closeButtonLabel = isCreation ? t('global.cancel') : t('global.close');\n const modalTitle =\n currentRecord?.label && currentRecord.label.trim() ? currentRecord.label : t('record_edition.new_record');\n\n useEffect(() => {\n const createEmptyRecordFunction = async () => {\n const values = useGetInitialRecordValues();\n const {data} = await createRecord({\n variables: {\n library,\n skipActivate: true,\n data: {values},\n },\n });\n\n const recordId = data?.createRecord.record?.id;\n setCurrentRecord(data?.createRecord.record.whoAmI ?? null);\n if (!recordId) {\n setIsError(true);\n return;\n }\n\n setIsReady(true);\n };\n\n if (open && isCreation && !currentRecord) {\n createEmptyRecordFunction();\n }\n }, [open, currentRecord]);\n\n const _handleClickSubmit = (button: SubmitButtonsName) => {\n clickedSubmitButton.current = button;\n };\n\n const _purgeRecordOnCreationCancel = () =>\n purgeRecordMutation({\n errorPolicy: 'ignore',\n variables: {\n libraryId: currentRecord?.library?.id,\n recordId: currentRecord?.id,\n },\n });\n\n const _closeAfterConfirm = async () => {\n if (currentRecord?.id && currentRecord?.library?.id) {\n _purgeRecordOnCreationCancel();\n }\n return onClose();\n };\n\n const showCancelConfirm = useCreateCancelConfirm(_closeAfterConfirm);\n\n const _handleCreate = (newRecord: RecordIdentityFragment['whoAmI']) => {\n setCurrentRecord(newRecord);\n\n if (onCreateAndEdit && clickedSubmitButton.current === 'createAndEdit') {\n setFormId(editionFormId ?? 'edition');\n setIsCreation(false);\n onCreateAndEdit(newRecord);\n return;\n }\n\n if (onCreate && clickedSubmitButton.current === 'create') {\n onCreate(newRecord);\n return;\n }\n };\n\n const _handleClose = () => {\n if (isCreation) {\n if (antdForm.isFieldsTouched()) {\n return showCancelConfirm();\n } else {\n _purgeRecordOnCreationCancel();\n }\n }\n return onClose();\n };\n\n const displayedSubmitButtons = useGetSubmitButtons(\n submitButtons,\n formElementId.current,\n isCreation,\n _handleClickSubmit,\n _handleClose,\n );\n\n return (\n <KitModalStyled\n appElement={document.getElementById('root')}\n className={className}\n height={autoHeight ? 'auto' : MODAL_HEIGHT}\n maxHeight={autoHeight ? MODAL_HEIGHT : undefined}\n width={MODAL_WIDTH}\n isOpen={open}\n close={_handleClose}\n title={\n <KitSpace>\n <KitTypography.Title level=\"h2\" style={{margin: 0}}>\n {modalTitle}\n </KitTypography.Title>\n <div id={EDIT_RECORD_MODAL_HEADER_CONTAINER_BUTTONS} />\n </KitSpace>\n }\n footer={\n <KitSpace>\n {[\n <KitButton\n aria-label={closeButtonLabel}\n key=\"close\"\n icon={<FontAwesomeIcon icon={faXmark} />}\n onClick={_handleClose}\n >\n {closeButtonLabel}\n </KitButton>,\n ...displayedSubmitButtons,\n ]}\n </KitSpace>\n }\n closeIcon={<FontAwesomeIcon icon={faXmark} />}\n showCloseIcon\n destroyOnClose\n >\n {isError && <ErrorComponent />}\n {!isReady && <KitLoader />}\n {isReady && (\n <EditRecord\n antdForm={antdForm}\n isFormCreationMode={isCreation}\n formId={formId}\n formElementId={formElementId.current}\n record={currentRecord}\n library={library}\n scrollAllRecordSummary\n onCreate={_handleCreate}\n valuesVersion={valuesVersion}\n showSidebar={showSidebar}\n enableSidebar={enableSidebar}\n withInfoButton={withInfoButton}\n />\n )}\n </KitModalStyled>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"EditRecordModal.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordModal/EditRecordModal.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnF,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,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C,IAAI,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,CAAC,EAAC,YAC7C,UAAU,GACO,EACtB,cAAK,EAAE,EAAE,0CAA0C,GAAI,IAChD,EAEf,MAAM,EACF,KAAC,QAAQ,cACJ;gBACG,KAAC,SAAS,kBACM,gBAAgB,EAE5B,IAAI,EAAC,GAAG,EACR,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,OAAO,GAAI,EACxC,OAAO,EAAE,YAAY,YAEpB,gBAAgB,IALb,OAAO,CAMH;gBACZ,GAAG,sBAAsB;aAC5B,GACM,EAEf,SAAS,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,OAAO,GAAI,EAC7C,aAAa,QACb,cAAc,mBAEb,OAAO,IAAI,KAAC,cAAc,KAAG,EAC7B,CAAC,OAAO,IAAI,KAAC,SAAS,KAAG,EACzB,OAAO,IAAI,CACR,KAAC,UAAU,IACP,QAAQ,EAAE,QAAQ,EAClB,kBAAkB,EAAE,UAAU,EAC9B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,CAAC,OAAO,EACpC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,EAChB,sBAAsB,QACtB,QAAQ,EAAE,aAAa,EACvB,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,GAChC,CACL,IACY,CACpB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useEffect, useRef, useState} from 'react';\nimport {KitButton, KitLoader, KitModal, KitSpace, KitTypography} from 'aristid-ds';\nimport styled from 'styled-components';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IValueVersion} from '_ui/types';\nimport {type RecordIdentityFragment, useCreateRecordMutation, usePurgeRecordMutation} from '_ui/_gqlTypes';\nimport {EditRecord} from '../EditRecord';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faXmark} from '@fortawesome/free-solid-svg-icons';\nimport {type PossibleSubmitButtons, type SubmitButtonsName} from '../_types';\nimport {useGetSubmitButtons} from '../hooks/useGetSubmitButtons';\nimport {useForm} from 'antd/lib/form/Form';\nimport {useCreateCancelConfirm} from '../hooks/useCreateCancelConfirm';\nimport {EDIT_RECORD_MODAL_HEADER_CONTAINER_BUTTONS} from '../constants';\nimport {useGetInitialRecordValues} from '../EditRecordPage/getInitialRecordValues';\nimport {ErrorComponent} from '../EditRecordPage/ErrorComponent';\n\nexport interface IEditRecordModalProps {\n className?: string;\n open: boolean;\n record: RecordIdentityFragment['whoAmI'] | null;\n creationFormId?: string;\n editionFormId?: string;\n library: string;\n onClose: () => void;\n onCreate?: (newRecord: RecordIdentityFragment['whoAmI']) => void; // Called after submitting via the \"create\" button\n onCreateAndEdit?: (newRecord: RecordIdentityFragment['whoAmI']) => void; // Called after submitting via the \"create and edit\" button\n submitButtons?: PossibleSubmitButtons;\n withInfoButton?: boolean;\n valuesVersion?: IValueVersion;\n showSidebar?: boolean;\n enableSidebar?: boolean;\n autoHeight?: boolean;\n}\n\nconst MODAL_HEIGHT = '80vh';\nconst MODAL_WIDTH = '90vw';\nconst MODAL_MAX_WIDTH = '656px';\nconst MODAL_WITH_SIDEBAR_MAX_WIDTH = '900px';\n\nconst KitModalStyled = styled(KitModal)`\n && {\n & > div {\n max-width: ${MODAL_MAX_WIDTH};\n\n &:has(#edit_record_sidebar) {\n max-width: ${MODAL_WITH_SIDEBAR_MAX_WIDTH};\n }\n\n .kit-modal-header {\n border-bottom: 1px solid var(--general-utilities-border);\n\n .kit-modal-title {\n padding-right: calc(var(--general-spacing-xs) * 1px);\n\n .ant-space {\n width: 100%;\n justify-content: space-between;\n }\n }\n }\n\n .kit-modal-content-wrapper {\n padding: 0;\n\n .kit-modal-content {\n height: 100%;\n\n & > div {\n height: 100%;\n }\n }\n }\n }\n }\n`;\n\nexport const EditRecordModal: FunctionComponent<IEditRecordModalProps> = ({\n className,\n open,\n record,\n creationFormId,\n editionFormId,\n library,\n onClose,\n onCreate,\n onCreateAndEdit,\n valuesVersion,\n showSidebar,\n enableSidebar,\n submitButtons = ['create'],\n withInfoButton = true,\n autoHeight = false,\n}) => {\n const {t} = useSharedTranslation();\n const [antdForm] = useForm();\n const [currentRecord, setCurrentRecord] = useState<RecordIdentityFragment['whoAmI'] | null>(record);\n const clickedSubmitButton = useRef<SubmitButtonsName | null>(null);\n const [createRecord] = useCreateRecordMutation();\n const [purgeRecordMutation] = usePurgeRecordMutation();\n\n const formElementId = useRef(window.crypto.randomUUID());\n const [isCreation, setIsCreation] = useState(!record);\n const [isReady, setIsReady] = useState(!!record);\n const [isError, setIsError] = useState(false);\n const [formId, setFormId] = useState<string>(\n isCreation ? (creationFormId ?? 'creation') : (editionFormId ?? 'edition'),\n );\n const closeButtonLabel = isCreation ? t('global.cancel') : t('global.close');\n const modalTitle =\n currentRecord?.label && currentRecord.label.trim() ? currentRecord.label : t('record_edition.new_record');\n\n useEffect(() => {\n const createEmptyRecordFunction = async () => {\n const values = useGetInitialRecordValues();\n const {data} = await createRecord({\n variables: {\n library,\n skipActivate: true,\n data: {values},\n },\n });\n\n const recordId = data?.createRecord.record?.id;\n setCurrentRecord(data?.createRecord.record.whoAmI ?? null);\n if (!recordId) {\n setIsError(true);\n return;\n }\n\n setIsReady(true);\n };\n\n if (open && isCreation && !currentRecord) {\n createEmptyRecordFunction();\n }\n }, [open, currentRecord]);\n\n const _handleClickSubmit = (button: SubmitButtonsName) => {\n clickedSubmitButton.current = button;\n };\n\n const _purgeRecordOnCreationCancel = () =>\n purgeRecordMutation({\n errorPolicy: 'ignore',\n variables: {\n libraryId: currentRecord?.library?.id,\n recordId: currentRecord?.id,\n },\n });\n\n const _closeAfterConfirm = async () => {\n if (currentRecord?.id && currentRecord?.library?.id) {\n _purgeRecordOnCreationCancel();\n }\n return onClose();\n };\n\n const showCancelConfirm = useCreateCancelConfirm(_closeAfterConfirm);\n\n const _handleCreate = (newRecord: RecordIdentityFragment['whoAmI']) => {\n setCurrentRecord(newRecord);\n\n if (onCreateAndEdit && clickedSubmitButton.current === 'createAndEdit') {\n setFormId(editionFormId ?? 'edition');\n setIsCreation(false);\n onCreateAndEdit(newRecord);\n return;\n }\n\n if (onCreate && clickedSubmitButton.current === 'create') {\n onCreate(newRecord);\n return;\n }\n };\n\n const _handleClose = () => {\n if (isCreation) {\n if (antdForm.isFieldsTouched()) {\n return showCancelConfirm();\n } else {\n _purgeRecordOnCreationCancel();\n }\n }\n return onClose();\n };\n\n const displayedSubmitButtons = useGetSubmitButtons(\n submitButtons,\n formElementId.current,\n isCreation,\n _handleClickSubmit,\n _handleClose,\n );\n\n return (\n <KitModalStyled\n appElement={document.getElementById('root')}\n className={className}\n height={autoHeight ? 'auto' : MODAL_HEIGHT}\n maxHeight={autoHeight ? MODAL_HEIGHT : undefined}\n width={MODAL_WIDTH}\n isOpen={open}\n close={_handleClose}\n title={\n <KitSpace>\n <KitTypography.Title level=\"h2\" style={{margin: 0}}>\n {modalTitle}\n </KitTypography.Title>\n <div id={EDIT_RECORD_MODAL_HEADER_CONTAINER_BUTTONS} />\n </KitSpace>\n }\n footer={\n <KitSpace>\n {[\n <KitButton\n aria-label={closeButtonLabel}\n key=\"close\"\n size=\"m\"\n icon={<FontAwesomeIcon icon={faXmark} />}\n onClick={_handleClose}\n >\n {closeButtonLabel}\n </KitButton>,\n ...displayedSubmitButtons,\n ]}\n </KitSpace>\n }\n closeIcon={<FontAwesomeIcon icon={faXmark} />}\n showCloseIcon\n destroyOnClose\n >\n {isError && <ErrorComponent />}\n {!isReady && <KitLoader />}\n {isReady && (\n <EditRecord\n antdForm={antdForm}\n isFormCreationMode={isCreation}\n formId={formId}\n formElementId={formElementId.current}\n record={currentRecord}\n library={library}\n scrollAllRecordSummary\n onCreate={_handleCreate}\n valuesVersion={valuesVersion}\n showSidebar={showSidebar}\n enableSidebar={enableSidebar}\n withInfoButton={withInfoButton}\n />\n )}\n </KitModalStyled>\n );\n};\n"]}
|
package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js
CHANGED
|
@@ -2,22 +2,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
|
-
import {
|
|
5
|
+
import { KitSpace, KitTypography } from 'aristid-ds';
|
|
6
6
|
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
7
|
+
import { useConfirmModal } from '../../../../hooks/useConfirmModal';
|
|
7
8
|
export const useCreateCancelConfirm = onConfirm => {
|
|
8
9
|
const { t } = useSharedTranslation();
|
|
10
|
+
const { openConfirmModal } = useConfirmModal();
|
|
9
11
|
const confirmContent = (_jsxs(KitSpace, { direction: "vertical", children: [_jsx("span", { children: t('record_edition.cancel_confirm_modal_content') }), _jsx(KitTypography.Text, { weight: "medium", children: t('record_edition.cancel_confirm_modal_question') })] }));
|
|
10
12
|
return () => {
|
|
11
|
-
|
|
13
|
+
openConfirmModal({
|
|
12
14
|
title: t('record_edition.cancel_confirm_modal_title'),
|
|
13
15
|
content: confirmContent,
|
|
14
|
-
icon: false,
|
|
15
|
-
showSecondaryCta: true,
|
|
16
|
-
showCloseIcon: false,
|
|
17
16
|
dangerConfirm: true,
|
|
18
|
-
type: 'confirm',
|
|
19
|
-
okText: t('global.confirm'),
|
|
20
|
-
cancelText: t('global.cancel'),
|
|
21
17
|
onOk: onConfirm,
|
|
22
18
|
});
|
|
23
19
|
};
|
package/dist/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCreateCancelConfirm.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"useCreateCancelConfirm.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/hooks/useCreateCancelConfirm/useCreateCancelConfirm.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAI1D,MAAM,CAAC,MAAM,sBAAsB,GAA+B,SAAS,CAAC,EAAE;IAC1E,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,gBAAgB,EAAC,GAAG,eAAe,EAAE,CAAC;IAE7C,MAAM,cAAc,GAAG,CACnB,MAAC,QAAQ,IAAC,SAAS,EAAC,UAAU,aAC1B,yBAAO,CAAC,CAAC,6CAA6C,CAAC,GAAQ,EAC/D,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,QAAQ,YAAE,CAAC,CAAC,8CAA8C,CAAC,GAAsB,IACrG,CACd,CAAC;IAEF,OAAO,GAAG,EAAE;QACR,gBAAgB,CAAC;YACb,KAAK,EAAE,CAAC,CAAC,2CAA2C,CAAC;YACrD,OAAO,EAAE,cAAc;YACvB,aAAa,EAAE,IAAI;YACnB,IAAI,EAAE,SAAS;SAClB,CAAC,CAAC;IACP,CAAC,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 {KitSpace, KitTypography} from 'aristid-ds';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {useConfirmModal} from '_ui/hooks/useConfirmModal';\n\nexport type UseCreateCancelConfirmHook = (onConfirm: () => void) => () => void;\n\nexport const useCreateCancelConfirm: UseCreateCancelConfirmHook = onConfirm => {\n const {t} = useSharedTranslation();\n const {openConfirmModal} = useConfirmModal();\n\n const confirmContent = (\n <KitSpace direction=\"vertical\">\n <span>{t('record_edition.cancel_confirm_modal_content')}</span>\n <KitTypography.Text weight=\"medium\">{t('record_edition.cancel_confirm_modal_question')}</KitTypography.Text>\n </KitSpace>\n );\n\n return () => {\n openConfirmModal({\n title: t('record_edition.cancel_confirm_modal_title'),\n content: confirmContent,\n dangerConfirm: true,\n onOk: onConfirm,\n });\n };\n};\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -43,3 +43,4 @@ export declare const LINK_FIELD_ID_PREFIX = "linkfield-";
|
|
|
43
43
|
export declare const TREE_FIELD_ID_PREFIX = "treefield-";
|
|
44
44
|
export declare const SUBMIT_BUTTONS_PORTAL = "submit_buttons_portal";
|
|
45
45
|
export declare const NEW_RECORD_ID = "newRecord";
|
|
46
|
+
export declare const BREAK_TWO_LINES = "\n\n";
|
package/dist/constants.js
CHANGED
|
@@ -54,4 +54,5 @@ export const LINK_FIELD_ID_PREFIX = 'linkfield-';
|
|
|
54
54
|
export const TREE_FIELD_ID_PREFIX = 'treefield-';
|
|
55
55
|
export const SUBMIT_BUTTONS_PORTAL = 'submit_buttons_portal';
|
|
56
56
|
export const NEW_RECORD_ID = 'newRecord';
|
|
57
|
+
export const BREAK_TWO_LINES = '\n\n';
|
|
57
58
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;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,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,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// Copyright LEAV Solutions 2017\n// This file is released under LGPL V3\nimport {AttributeFormat, AttributeType} from './_gqlTypes';\n\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nexport enum PreviewSize {\n TINY = 'tiny',\n SMALL = 'small',\n MEDIUM = 'medium',\n BIG = 'big',\n}\n\nexport const ACTIVE_ATTRIBUTE_ID = 'active';\n\nexport const tagColorByAttributeType: {[key in AttributeType]: [border: string, background: string]} = {\n [AttributeType.simple]: ['purple', '#ffe5ff'],\n [AttributeType.simple_link]: ['blue', '#e5e5ff'],\n [AttributeType.advanced]: ['orange', '#fff6e5'],\n [AttributeType.advanced_link]: ['#d4380d', '#fde4dd'],\n [AttributeType.tree]: ['green', '#e5ffe5'],\n};\n\nexport const tagColorByAttributeFormat: {[key in AttributeFormat]: [border: string, background: string]} = {\n [AttributeFormat.boolean]: ['gold', '#fff099'],\n [AttributeFormat.date]: ['blue', '#e5e5ff'],\n [AttributeFormat.date_range]: ['#1d39c4', '#e9ecfc'],\n [AttributeFormat.encrypted]: ['red', '#ffe5e5'],\n [AttributeFormat.extended]: ['magenta', '#ffe5e5'],\n [AttributeFormat.numeric]: ['orange', '#fff6e5'],\n [AttributeFormat.text]: ['green', '#e5ffe5'],\n [AttributeFormat.color]: ['purple', '#ffe5ff'],\n [AttributeFormat.rich_text]: ['#d4380d', '#fde4dd'],\n};\n\nexport enum ErrorDisplayTypes {\n ERROR = 'error',\n PERMISSION_ERROR = 'permission_error',\n PAGE_NOT_FOUND = 'page_not_found_error',\n}\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n interface Window {\n __dynamic_base__?: string;\n __global_base_url__?: string;\n __bugsnag_api_key__?: string;\n __bugsnag_app_version__?: string;\n __bugsnag_release_stage__?: string;\n }\n}\n\nexport const defaultPaginationPageSize = 20;\n\nexport const GLOBAL_BASE_URL = window.__global_base_url__ || '';\n\nexport const PREFIX_USER_VIEWS_ORDER_KEY = 'user_views_order_';\nexport const PREFIX_SHARED_VIEWS_ORDER_KEY = 'shared_views_order_';\n\nexport const TOOLTIP_DEFAULT_DELAY_IN_SECONDS = 0.5;\n\nexport const INFO_NOTIFICATION_DURATION = 5_000;\nexport const ERROR_NOTIFICATION_DURATION = 5_000;\nexport const SUCCESS_NOTIFICATION_DURATION = 5_000;\nexport const SUBSCRIPTION_NOTIFICATION_DURATION = 10_000;\n\nexport const SUCCESS_ALERT_DURATION = 3_000;\nexport const ERROR_ALERT_DURATION = 5_000;\n\nexport const EDIT_RECORD_SIDEBAR_ID = 'edit_record_sidebar';\n\nexport const STANDARD_FIELD_ID_PREFIX = 'standardfield-';\n\nexport const LINK_FIELD_ID_PREFIX = 'linkfield-';\n\nexport const TREE_FIELD_ID_PREFIX = 'treefield-';\n\nexport const SUBMIT_BUTTONS_PORTAL = 'submit_buttons_portal';\nexport const NEW_RECORD_ID = 'newRecord';\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,gCAAgC;AAChC,sCAAsC;AACtC,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAE3D,sEAAsE;AACtE,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,0BAAW,CAAA;AACf,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAmE;IACnG,CAAC,aAAa,CAAC,M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,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAE5C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,mBAAmB,IAAI,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAC/D,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AAEnE,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAEpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAK,CAAC;AAChD,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAK,CAAC;AACjD,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAK,CAAC;AACnD,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAM,CAAC;AAEzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAK,CAAC;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAC7D,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,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// Copyright LEAV Solutions 2017\n// This file is released under LGPL V3\nimport {AttributeFormat, AttributeType} from './_gqlTypes';\n\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nexport enum PreviewSize {\n TINY = 'tiny',\n SMALL = 'small',\n MEDIUM = 'medium',\n BIG = 'big',\n}\n\nexport const ACTIVE_ATTRIBUTE_ID = 'active';\n\nexport const tagColorByAttributeType: {[key in AttributeType]: [border: string, background: string]} = {\n [AttributeType.simple]: ['purple', '#ffe5ff'],\n [AttributeType.simple_link]: ['blue', '#e5e5ff'],\n [AttributeType.advanced]: ['orange', '#fff6e5'],\n [AttributeType.advanced_link]: ['#d4380d', '#fde4dd'],\n [AttributeType.tree]: ['green', '#e5ffe5'],\n};\n\nexport const tagColorByAttributeFormat: {[key in AttributeFormat]: [border: string, background: string]} = {\n [AttributeFormat.boolean]: ['gold', '#fff099'],\n [AttributeFormat.date]: ['blue', '#e5e5ff'],\n [AttributeFormat.date_range]: ['#1d39c4', '#e9ecfc'],\n [AttributeFormat.encrypted]: ['red', '#ffe5e5'],\n [AttributeFormat.extended]: ['magenta', '#ffe5e5'],\n [AttributeFormat.numeric]: ['orange', '#fff6e5'],\n [AttributeFormat.text]: ['green', '#e5ffe5'],\n [AttributeFormat.color]: ['purple', '#ffe5ff'],\n [AttributeFormat.rich_text]: ['#d4380d', '#fde4dd'],\n};\n\nexport enum ErrorDisplayTypes {\n ERROR = 'error',\n PERMISSION_ERROR = 'permission_error',\n PAGE_NOT_FOUND = 'page_not_found_error',\n}\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n interface Window {\n __dynamic_base__?: string;\n __global_base_url__?: string;\n __bugsnag_api_key__?: string;\n __bugsnag_app_version__?: string;\n __bugsnag_release_stage__?: string;\n }\n}\n\nexport const defaultPaginationPageSize = 20;\n\nexport const GLOBAL_BASE_URL = window.__global_base_url__ || '';\n\nexport const PREFIX_USER_VIEWS_ORDER_KEY = 'user_views_order_';\nexport const PREFIX_SHARED_VIEWS_ORDER_KEY = 'shared_views_order_';\n\nexport const TOOLTIP_DEFAULT_DELAY_IN_SECONDS = 0.5;\n\nexport const INFO_NOTIFICATION_DURATION = 5_000;\nexport const ERROR_NOTIFICATION_DURATION = 5_000;\nexport const SUCCESS_NOTIFICATION_DURATION = 5_000;\nexport const SUBSCRIPTION_NOTIFICATION_DURATION = 10_000;\n\nexport const SUCCESS_ALERT_DURATION = 3_000;\nexport const ERROR_ALERT_DURATION = 5_000;\n\nexport const EDIT_RECORD_SIDEBAR_ID = 'edit_record_sidebar';\n\nexport const STANDARD_FIELD_ID_PREFIX = 'standardfield-';\n\nexport const LINK_FIELD_ID_PREFIX = 'linkfield-';\n\nexport const TREE_FIELD_ID_PREFIX = 'treefield-';\n\nexport const SUBMIT_BUTTONS_PORTAL = 'submit_buttons_portal';\nexport const NEW_RECORD_ID = 'newRecord';\n\nexport const BREAK_TWO_LINES = '\\n\\n';\n"]}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -16,3 +16,7 @@ export { useIFrameMessenger } from './useIFrameMessenger/useIFrameMessenger';
|
|
|
16
16
|
export { useIFrameMessengerClient } from './useIFrameMessengerClient/useIFrameMessengerClient';
|
|
17
17
|
export { IFrameMessengerClient } from './useIFrameMessengerClient/IFrameMessengerClient';
|
|
18
18
|
export { creationPanelSchema } from './useIFrameMessenger/schema';
|
|
19
|
+
export { useIFrameMessengerHandlers } from './useIFrameMessenger/useIFrameMessengerHandlers';
|
|
20
|
+
export { IFrameMessengerProvider } from './useIFrameMessenger/useIFrameMessengerContext';
|
|
21
|
+
export { useGetRecordIdCard } from './useGetRecordIdCard';
|
|
22
|
+
export { useConfirmModal } from './useConfirmModal';
|
package/dist/hooks/index.js
CHANGED
|
@@ -19,4 +19,8 @@ export { useIFrameMessenger } from './useIFrameMessenger/useIFrameMessenger';
|
|
|
19
19
|
export { useIFrameMessengerClient } from './useIFrameMessengerClient/useIFrameMessengerClient';
|
|
20
20
|
export { IFrameMessengerClient } from './useIFrameMessengerClient/IFrameMessengerClient';
|
|
21
21
|
export { creationPanelSchema } from './useIFrameMessenger/schema';
|
|
22
|
+
export { useIFrameMessengerHandlers } from './useIFrameMessenger/useIFrameMessengerHandlers';
|
|
23
|
+
export { IFrameMessengerProvider } from './useIFrameMessenger/useIFrameMessengerContext';
|
|
24
|
+
export { useGetRecordIdCard } from './useGetRecordIdCard';
|
|
25
|
+
export { useConfirmModal } from './useConfirmModal';
|
|
22
26
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,+BAA+B,EAAC,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,6BAA6B,EAAC,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAC,wBAAwB,EAAC,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAC,qBAAqB,EAAC,MAAM,kDAAkD,CAAC;AACvF,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\n\nexport {useSaveApplicationMutation} from '../_gqlTypes';\nexport {useAntdLocale} from './useAntdLocale';\nexport {default as useAppLang} from './useAppLang';\nexport {default as useAuth} from './useAuth';\nexport {default as useGetRecordForm} from './useGetRecordForm';\nexport {useGetRecordUpdatesSubscription} from './useGetRecordUpdatesSubscription';\nexport {default as useLang} from './useLang';\nexport {default as useLocalStorage} from './useLocalStorage';\nexport {default as useRecordsConsultationHistory} from './useRecordsConsultationHistory';\nexport {useRefreshFieldValues} from './useRefreshFieldValues';\nexport {default as useLoginChecker} from './useLoginChecker';\nexport {default as useRedirectToLogin} from './useRedirectToLogin';\nexport {useUser} from './useUser';\nexport {useValuesCacheUpdate} from './useValuesCacheUpdate';\nexport {useIFrameMessenger} from './useIFrameMessenger/useIFrameMessenger';\nexport {useIFrameMessengerClient} from './useIFrameMessengerClient/useIFrameMessengerClient';\nexport {IFrameMessengerClient} from './useIFrameMessengerClient/IFrameMessengerClient';\nexport {creationPanelSchema} from './useIFrameMessenger/schema';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AAEtE,OAAO,EAAC,0BAA0B,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,+BAA+B,EAAC,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,6BAA6B,EAAC,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAC,wBAAwB,EAAC,MAAM,qDAAqD,CAAC;AAC7F,OAAO,EAAC,qBAAqB,EAAC,MAAM,kDAAkD,CAAC;AACvF,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,0BAA0B,EAAC,MAAM,iDAAiD,CAAC;AAC3F,OAAO,EAAC,uBAAuB,EAAC,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\n\nexport {useSaveApplicationMutation} from '../_gqlTypes';\nexport {useAntdLocale} from './useAntdLocale';\nexport {default as useAppLang} from './useAppLang';\nexport {default as useAuth} from './useAuth';\nexport {default as useGetRecordForm} from './useGetRecordForm';\nexport {useGetRecordUpdatesSubscription} from './useGetRecordUpdatesSubscription';\nexport {default as useLang} from './useLang';\nexport {default as useLocalStorage} from './useLocalStorage';\nexport {default as useRecordsConsultationHistory} from './useRecordsConsultationHistory';\nexport {useRefreshFieldValues} from './useRefreshFieldValues';\nexport {default as useLoginChecker} from './useLoginChecker';\nexport {default as useRedirectToLogin} from './useRedirectToLogin';\nexport {useUser} from './useUser';\nexport {useValuesCacheUpdate} from './useValuesCacheUpdate';\nexport {useIFrameMessenger} from './useIFrameMessenger/useIFrameMessenger';\nexport {useIFrameMessengerClient} from './useIFrameMessengerClient/useIFrameMessengerClient';\nexport {IFrameMessengerClient} from './useIFrameMessengerClient/IFrameMessengerClient';\nexport {creationPanelSchema} from './useIFrameMessenger/schema';\nexport {useIFrameMessengerHandlers} from './useIFrameMessenger/useIFrameMessengerHandlers';\nexport {IFrameMessengerProvider} from './useIFrameMessenger/useIFrameMessengerContext';\nexport {useGetRecordIdCard} from './useGetRecordIdCard';\nexport {useConfirmModal} from './useConfirmModal';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useConfirmModal } from './useConfirmModal';
|
|
@@ -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 { useConfirmModal } from './useConfirmModal';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/useConfirmModal/__mocks__/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
|
+
// 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 const useConfirmModal = () => ({
|
|
5
|
+
openConfirmModal: jest.fn(),
|
|
6
|
+
});
|
|
7
|
+
//# sourceMappingURL=useConfirmModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfirmModal.js","sourceRoot":"","sources":["../../../../src/hooks/useConfirmModal/__mocks__/useConfirmModal.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC;IAClC,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE;CAC9B,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\nexport const useConfirmModal = () => ({\n openConfirmModal: jest.fn(),\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useConfirmModal } from './useConfirmModal';
|
|
@@ -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 { useConfirmModal } from './useConfirmModal';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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
|
|
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
|
-
*
|
|
5
|
-
*
|
|
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;
|