@arquimedes.co/eureka-forms 3.0.47-test → 3.0.48-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/@Types/Condition.d.ts +6 -4
  2. package/dist/@Types/ErkValue.d.ts +16 -0
  3. package/dist/@Types/ErkValue.js +1 -0
  4. package/dist/@Types/Form.d.ts +1 -0
  5. package/dist/@Types/FormStep.d.ts +8 -1
  6. package/dist/@Types/User.d.ts +13 -0
  7. package/dist/@Types/User.js +1 -0
  8. package/dist/App/App.js +1 -1
  9. package/dist/App/AppFunctions.js +8 -3
  10. package/dist/App/AppHooks.js +20 -1
  11. package/dist/Form/Form.js +6 -2
  12. package/dist/Form/Form.module.css +48 -39
  13. package/dist/FormSteps/ApiSelectorStep/MaterialApiSelectorStep/MaterialApiSelectorStep.js +8 -4
  14. package/dist/FormSteps/CBRStepMapper.js +1 -1
  15. package/dist/FormSteps/ClassifierSelectorStep/MaterialClassifierSelectorStep/MaterialClassifierSelectorStep.js +2 -2
  16. package/dist/FormSteps/EntityValueStep/MaterialEntityValuePickerStep/MaterialEntityValuePickerStep.js +52 -4
  17. package/dist/FormSteps/StepFunctions.js +6 -9
  18. package/dist/FormSteps/StepFunctions.test.js +3 -3
  19. package/dist/FormSteps/TitleStep/MaterialTitleStep/MaterialTitleStep.js +2 -1
  20. package/dist/Icons/EmailIcon.d.ts +3 -0
  21. package/dist/Icons/EmailIcon.js +7 -0
  22. package/dist/Icons/Entities/SchoolIcon.d.ts +3 -0
  23. package/dist/Icons/Entities/SchoolIcon.js +7 -0
  24. package/dist/Icons/GroupIcon.d.ts +3 -0
  25. package/dist/Icons/GroupIcon.js +7 -0
  26. package/dist/Icons/LockedIcon.d.ts +3 -0
  27. package/dist/Icons/LockedIcon.js +7 -0
  28. package/dist/Login/Login.module.css +135 -0
  29. package/dist/Login/LoginLayout.module.css +68 -0
  30. package/dist/Login/LoginPage.d.ts +10 -0
  31. package/dist/Login/LoginPage.js +101 -0
  32. package/dist/Login/LoginTextField.d.ts +14 -0
  33. package/dist/Login/LoginTextField.js +29 -0
  34. package/dist/Services/ApiSelectorService.d.ts +366 -0
  35. package/dist/Services/ApiSelectorService.js +173 -0
  36. package/dist/Services/ApiSelectorService.test.d.ts +1 -0
  37. package/dist/Services/ApiSelectorService.test.js +87 -0
  38. package/dist/Services/DraftService.js +4 -1
  39. package/dist/Services/IntegrationService.d.ts +21 -0
  40. package/dist/Services/IntegrationService.js +22 -0
  41. package/dist/Services/UserService.d.ts +10 -0
  42. package/dist/Services/UserService.js +21 -0
  43. package/dist/Shared/ErkSelect/ErkSelect.d.ts +2 -2
  44. package/dist/Shared/InputIcon/InputIcon.js +6 -0
  45. package/dist/Shared/Navbar/Navbar.d.ts +2 -1
  46. package/dist/Shared/Navbar/Navbar.js +22 -3
  47. package/dist/Shared/Navbar/Navbar.module.css +22 -8
  48. package/dist/Shared/SmartDraftRenderer/LinkDecorator.d.ts +14 -0
  49. package/dist/Shared/SmartDraftRenderer/LinkDecorator.js +48 -0
  50. package/dist/Shared/SmartDraftRenderer/SmartDraftRenderer.js +8 -2
  51. package/dist/States/GlobalSlice.d.ts +4 -1
  52. package/dist/States/GlobalSlice.js +8 -1
  53. package/dist/constants/ErkIconTypes.d.ts +3 -1
  54. package/dist/constants/ErkIconTypes.js +2 -0
  55. package/dist/constants/ErkValueTypes.d.ts +6 -0
  56. package/dist/constants/ErkValueTypes.js +7 -0
  57. package/dist/constants/FormStepTypes.d.ts +2 -1
  58. package/dist/constants/FormStepTypes.js +1 -0
  59. package/dist/hooks.d.ts +3 -0
  60. package/dist/hooks.js +17 -1
  61. package/package.json +9 -2
@@ -0,0 +1,22 @@
1
+ import { RootApi } from '../Utils/_api';
2
+ import axiosInstance from '../Utils/AxiosAPI';
3
+ import widgetInstance from '../Utils/AxiosWidget';
4
+ export const IntegrationsApi = RootApi.injectEndpoints({
5
+ endpoints: (build) => ({
6
+ fetchFilterIntegration: build.query({
7
+ queryFn: async ({ idForm, idIntegration, payload }, { getState }) => {
8
+ const idOrganization = getState().forms[idForm].global.idOrganization;
9
+ let response;
10
+ if (idOrganization) {
11
+ response = await widgetInstance.post(`/form/integrations/${idIntegration}?idOrganization=${idOrganization}`, payload, { timeout: 120000 });
12
+ }
13
+ else {
14
+ response = await axiosInstance.post(`/form/integrations/${idIntegration}`, payload, {
15
+ timeout: 120000,
16
+ });
17
+ }
18
+ return { data: response.data };
19
+ },
20
+ }),
21
+ }),
22
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Function that handles the app's login
3
+ * @param credentials {email, password} of the user
4
+ * @returns an array with the users Token and RefreshToken
5
+ */
6
+ export declare const login: (apiKey: string, credentials: Record<string, string>) => Promise<string>;
7
+ /**
8
+ * Function that indicates to the server to delete the refresh token
9
+ */
10
+ export declare const logout: (apiKey: string) => Promise<void>;
@@ -0,0 +1,21 @@
1
+ import axiosInstance from '../Utils/AxiosAPI';
2
+ /**
3
+ * Function that handles the app's login
4
+ * @param credentials {email, password} of the user
5
+ * @returns an array with the users Token and RefreshToken
6
+ */
7
+ export const login = async (apiKey, credentials) => {
8
+ const response = await axiosInstance.post(`forms/${apiKey}/auth`, credentials);
9
+ return response?.data;
10
+ };
11
+ /**
12
+ * Function that indicates to the server to delete the refresh token
13
+ */
14
+ export const logout = async (apiKey) => {
15
+ await axiosInstance.delete(`forms/${apiKey}/auth`, {
16
+ headers: {
17
+ Authorization: 'Bearer ' + localStorage.getItem('refreshToken'),
18
+ },
19
+ timeout: 5000,
20
+ });
21
+ };
@@ -5,12 +5,12 @@ export interface SelectorStyleProps {
5
5
  readOnly?: boolean;
6
6
  }
7
7
  export declare const StyledSelect: import("@emotion/styled").StyledComponent<(import("@mui/material").FilledSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").StandardSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>) | (import("@mui/material").OutlinedSelectProps & import("@mui/material").BaseSelectProps<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>), {}, {}>;
8
- export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
8
+ export declare const StyledInputLabel: import("@emotion/styled").StyledComponent<import("@mui/material").InputLabelOwnProps & Pick<import("@mui/material").FormLabelOwnProps, "color" | "filled"> & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "required" | "size" | "color" | "children" | "className" | "style" | "classes" | "error" | "disabled" | "sx" | "margin" | "filled" | "variant" | "focused" | "disableAnimation" | "shrink"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
9
9
  component?: React.ElementType | undefined;
10
10
  } & {
11
11
  open: boolean;
12
12
  }, {}, {}>;
13
- export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "required" | "children" | "className" | "style" | "classes" | "disabled" | "sx" | "margin" | "error" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
13
+ export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("@mui/material").FormHelperTextOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, "required" | "children" | "className" | "style" | "classes" | "error" | "disabled" | "sx" | "margin" | "filled" | "variant" | "focused"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
14
14
  component?: React.ElementType | undefined;
15
15
  }, {}, {}>;
16
16
  export type ErkSelectValue<Type extends string | number, Multiple, Clearable> = Multiple extends true ? Type[] : Clearable extends true ? Type | undefined : Type;
@@ -9,8 +9,10 @@ import DocumentIcon from '../../Icons/DocumentIcon';
9
9
  import CheckListIcon from '../../Icons/Entities/CheckListIcon';
10
10
  import GenericEntityIcon from '../../Icons/Entities/GenericEntityIcon';
11
11
  import HandShakeIcon from '../../Icons/Entities/HandshakeIcon';
12
+ import SchoolIcon from '../../Icons/Entities/SchoolIcon';
12
13
  import SupplierIcon from '../../Icons/Entities/SupplierIcon';
13
14
  import WorkIcon from '../../Icons/Entities/WorkIcon';
15
+ import GroupIcon from '../../Icons/GroupIcon';
14
16
  import LocationIcon from '../../Icons/LocationIcon';
15
17
  import PersonIcon from '../../Icons/PersonIcon';
16
18
  function InputIcon({ icon, ...others }) {
@@ -37,6 +39,10 @@ function InputIcon({ icon, ...others }) {
37
39
  return _jsx(CalendarIcon, { size: 23, ...others });
38
40
  case ErkIconTypes.WORK:
39
41
  return _jsx(WorkIcon, { size: 23, ...others });
42
+ case ErkIconTypes.SCHOOL:
43
+ return _jsx(SchoolIcon, { size: 23, ...others });
44
+ case ErkIconTypes.GROUP:
45
+ return _jsx(GroupIcon, { size: 23, ...others });
40
46
  case ErkIconTypes.LOCATION:
41
47
  return _jsx(LocationIcon, { size: 23, ...others });
42
48
  case ErkIconTypes.GENERIC:
@@ -1,8 +1,9 @@
1
1
  interface NavBarProps {
2
+ apiKey?: string;
2
3
  /** Url of the current logo of the current organization */
3
4
  logo?: string;
4
5
  /** The color of the navbar */
5
6
  color?: string;
6
7
  }
7
- declare function Navbar({ logo, color }: NavBarProps): JSX.Element;
8
+ declare function Navbar({ logo, color, apiKey }: NavBarProps): JSX.Element;
8
9
  export default Navbar;
@@ -1,6 +1,25 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
2
3
  import styles from './Navbar.module.css';
3
- function Navbar({ logo, color }) {
4
- return (_jsx("div", { className: styles.navContainer, style: { backgroundColor: color }, children: _jsx("img", { src: logo, alt: "Organization Logo", className: styles.navImage }) }));
4
+ import { IconButton, Avatar, Menu, MenuItem } from '@mui/material';
5
+ import { logout } from '../../Services/UserService';
6
+ import { useAppSelector } from '../../hooks';
7
+ function Navbar({ logo, color, apiKey }) {
8
+ const [anchorEl, setAnchorEl] = useState(null);
9
+ const user = useAppSelector((state) => state.global.user);
10
+ const handleLogout = async () => {
11
+ setAnchorEl(null);
12
+ if (apiKey) {
13
+ try {
14
+ await logout(apiKey);
15
+ }
16
+ catch (err) {
17
+ console.error(err);
18
+ }
19
+ }
20
+ localStorage.removeItem('token');
21
+ window.location.reload();
22
+ };
23
+ return (_jsxs("div", { className: styles.navContainer, style: { backgroundColor: color }, children: [_jsx("img", { src: logo, alt: "Organization Logo", className: styles.navImage }), user && apiKey && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.navBarAvatar, children: _jsx(IconButton, { style: { width: 42, height: 42, padding: 0, margin: 'auto' }, "aria-label": "Mi Perfil", "aria-haspopup": "true", onClick: (event) => setAnchorEl(event.currentTarget), children: _jsx(Avatar, { style: { fontSize: '40px' }, alt: user?.name ?? user?.email }) }) }), _jsx(Menu, { id: "simple-menu", anchorEl: anchorEl, anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'right' }, open: Boolean(anchorEl), onClose: () => setAnchorEl(null), children: _jsx(MenuItem, { onClick: () => void handleLogout(), children: "Cerrar sesi\u00F3n" }) })] }))] }));
5
24
  }
6
25
  export default Navbar;
@@ -1,8 +1,22 @@
1
- .navContainer {
2
- height: 60px;
3
- display: flex;
4
- }
5
- .navImage {
6
- height: 40px;
7
- margin: auto 0 auto 15px;
8
- }
1
+ .navContainer {
2
+ height: 60px;
3
+ display: flex;
4
+ }
5
+ .navImage {
6
+ height: 40px;
7
+ margin: auto 0 auto 15px;
8
+ }
9
+
10
+ .navBarAvatar {
11
+ height: 60px;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ margin-left: auto;
16
+ margin-right: 15px;
17
+ }
18
+
19
+ .navBarAvatarIcon {
20
+ width: 100px;
21
+ height: 100px;
22
+ }
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { ContentBlock, ContentState } from 'draft-js';
3
+ export interface LinkComponentProps {
4
+ children: React.ReactNode;
5
+ contentState: ContentState;
6
+ entityKey?: string;
7
+ decoratedText: string;
8
+ }
9
+ export declare function LinkComponent({ children, decoratedText }: LinkComponentProps): JSX.Element;
10
+ export declare function findLinkEntities(contentBlock: ContentBlock, callback: (start: number, end: number) => void): void;
11
+ export declare const linkDecorator: {
12
+ strategy: typeof findLinkEntities;
13
+ component: typeof LinkComponent;
14
+ };
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export function LinkComponent({ children, decoratedText }) {
3
+ // Add protocol if missing
4
+ const getHref = (url) => {
5
+ if (url.startsWith('http://') || url.startsWith('https://')) {
6
+ return url;
7
+ }
8
+ return `https://${url}`;
9
+ };
10
+ const handleClick = (e) => {
11
+ e.preventDefault();
12
+ window.open(getHref(decoratedText), '_blank', 'noopener,noreferrer');
13
+ };
14
+ return (_jsx("a", { href: getHref(decoratedText), onClick: handleClick, style: {
15
+ color: '#1976d2',
16
+ textDecoration: 'underline',
17
+ cursor: 'pointer',
18
+ }, target: "_blank", rel: "noopener noreferrer", children: children }));
19
+ }
20
+ export function findLinkEntities(contentBlock, callback) {
21
+ try {
22
+ const text = contentBlock.getText();
23
+ // Return early if no text
24
+ if (!text)
25
+ return;
26
+ // Create a new regex instance for each call to avoid state issues
27
+ const urlRegex = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/g;
28
+ let matchArr;
29
+ let start;
30
+ while ((matchArr = urlRegex.exec(text)) !== null) {
31
+ start = matchArr.index;
32
+ callback(start, start + matchArr[0].length);
33
+ // Prevent infinite loop if regex doesn't advance
34
+ if (matchArr.index === urlRegex.lastIndex) {
35
+ urlRegex.lastIndex++;
36
+ }
37
+ }
38
+ }
39
+ catch (error) {
40
+ // Fail silently to avoid breaking the editor
41
+ // eslint-disable-next-line no-console
42
+ console.warn('LinkDecorator: Error finding link entities:', error);
43
+ }
44
+ }
45
+ export const linkDecorator = {
46
+ strategy: findLinkEntities,
47
+ component: LinkComponent,
48
+ };
@@ -6,6 +6,7 @@ import { Editor } from 'react-draft-wysiwyg';
6
6
  import { produce } from 'immer';
7
7
  import CustomContext from '../../Contexts/CustomContext';
8
8
  import { FormDecoratorsStrategy, FormDecorator } from './FormDecorator';
9
+ import { linkDecorator } from './LinkDecorator';
9
10
  import { skipToken } from '@reduxjs/toolkit/query';
10
11
  import { useAppSelector } from '../../hooks';
11
12
  import { IdFormContext } from '../../Contexts/FormContext';
@@ -44,13 +45,18 @@ function cleanUpDraftParams(draft) {
44
45
  for (const block of draft.blocks) {
45
46
  for (const entity of block.entityRanges) {
46
47
  const { offset, length } = entity;
47
- //Change text into spaces
48
- block.text = block.text.replace(block.text.substring(offset, offset + length), ' '.repeat(length));
48
+ // Blank the parameter in place by code point: draft offsets count an
49
+ // emoji as one, so a positional splice keeps every later offset aligned
50
+ // (a value-based replace would also blank the wrong text on collisions).
51
+ const chars = [...block.text];
52
+ chars.splice(offset, length, ...' '.repeat(length));
53
+ block.text = chars.join('');
49
54
  }
50
55
  }
51
56
  });
52
57
  }
53
58
  const customDecorators = [
59
+ linkDecorator,
54
60
  {
55
61
  strategy: FormDecoratorsStrategy,
56
62
  component: FormDecorator,
@@ -3,6 +3,7 @@ import { type Reducer } from '@reduxjs/toolkit';
3
3
  import { SiteState } from './SiteSlice';
4
4
  import { EurekaDraft } from '../@Types/Draft/Draft';
5
5
  import { CountryCode } from 'libphonenumber-js';
6
+ import { User } from '../@Types/User';
6
7
  export interface GlobalState {
7
8
  apiKey?: string;
8
9
  idOrganization: string;
@@ -20,6 +21,8 @@ export interface GlobalState {
20
21
  partial: boolean;
21
22
  internal: boolean;
22
23
  loaded: boolean;
24
+ /** Current User */
25
+ user: User | null | undefined;
23
26
  }
24
27
  interface GlobalSliceAPI {
25
28
  reducer: Reducer<GlobalState>;
@@ -27,6 +30,6 @@ interface GlobalSliceAPI {
27
30
  name: string;
28
31
  reducerPath: string;
29
32
  }
30
- export declare const reset: import("@reduxjs/toolkit").ActionCreatorWithPayload<Omit<GlobalState, "loaded"> & SiteState, "global/reset">;
33
+ export declare const reset: import("@reduxjs/toolkit").ActionCreatorWithPayload<Omit<GlobalState, "loaded"> & SiteState, "global/reset">, setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<User | null, "global/setUser">;
31
34
  export declare const GlobalSlice: GlobalSliceAPI;
32
35
  export default GlobalSlice;
@@ -15,6 +15,7 @@ const initialState = {
15
15
  partial: false,
16
16
  internal: false,
17
17
  loaded: false,
18
+ user: undefined,
18
19
  };
19
20
  const _GlobalSlice = createSlice({
20
21
  name: 'global',
@@ -23,8 +24,14 @@ const _GlobalSlice = createSlice({
23
24
  reset: (state, action) => {
24
25
  return { ...state, ...action.payload, loaded: true };
25
26
  },
27
+ setUser: (state, action) => {
28
+ state.user = action.payload;
29
+ if (action.payload?._id) {
30
+ state.idCurrentAgent = action.payload._id;
31
+ }
32
+ },
26
33
  },
27
34
  });
28
- export const { reset } = _GlobalSlice.actions;
35
+ export const { reset, setUser } = _GlobalSlice.actions;
29
36
  export const GlobalSlice = _GlobalSlice;
30
37
  export default GlobalSlice;
@@ -11,5 +11,7 @@ export declare enum ErkIconTypes {
11
11
  GENERIC = "GENERIC",
12
12
  LOCATION = "LOCATION",
13
13
  CALENDAR = "CALENDAR",
14
- WORK = "WORK"
14
+ WORK = "WORK",
15
+ SCHOOL = "SCHOOL",
16
+ GROUP = "GROUP"
15
17
  }
@@ -13,4 +13,6 @@ export var ErkIconTypes;
13
13
  ErkIconTypes["LOCATION"] = "LOCATION";
14
14
  ErkIconTypes["CALENDAR"] = "CALENDAR";
15
15
  ErkIconTypes["WORK"] = "WORK";
16
+ ErkIconTypes["SCHOOL"] = "SCHOOL";
17
+ ErkIconTypes["GROUP"] = "GROUP";
16
18
  })(ErkIconTypes || (ErkIconTypes = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum ErkValueTypes {
2
+ DRAFT = "DRAFT",
3
+ STEP = "STEP",
4
+ BOOLEAN = "BOOLEAN"
5
+ }
6
+ export default ErkValueTypes;
@@ -0,0 +1,7 @@
1
+ export var ErkValueTypes;
2
+ (function (ErkValueTypes) {
3
+ ErkValueTypes["DRAFT"] = "DRAFT";
4
+ ErkValueTypes["STEP"] = "STEP";
5
+ ErkValueTypes["BOOLEAN"] = "BOOLEAN";
6
+ })(ErkValueTypes || (ErkValueTypes = {}));
7
+ export default ErkValueTypes;
@@ -58,7 +58,8 @@ export declare enum MapperStyleTypes {
58
58
  export declare enum EntityValueDataTypes {
59
59
  STEP = "STEP",
60
60
  VALUE = "VALUE",
61
- CURRENT_AGENT = "CURRENT_AGENT"
61
+ CURRENT_AGENT = "CURRENT_AGENT",
62
+ INTEGRATION = "INTEGRATION"
62
63
  }
63
64
  export declare enum ApiSelectorParamTypes {
64
65
  STEP = "STEP",
@@ -69,6 +69,7 @@ export var EntityValueDataTypes;
69
69
  EntityValueDataTypes["STEP"] = "STEP";
70
70
  EntityValueDataTypes["VALUE"] = "VALUE";
71
71
  EntityValueDataTypes["CURRENT_AGENT"] = "CURRENT_AGENT";
72
+ EntityValueDataTypes["INTEGRATION"] = "INTEGRATION";
72
73
  })(EntityValueDataTypes || (EntityValueDataTypes = {}));
73
74
  export var ApiSelectorParamTypes;
74
75
  (function (ApiSelectorParamTypes) {
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import type { TypedUseSelectorHook } from 'react-redux';
2
2
  import { type RootState, type AppDispatch } from './Utils/store';
3
+ import { ThunkAction } from '@reduxjs/toolkit';
4
+ import { QueryActionCreatorResult, QueryDefinition, ResultTypeFrom } from '@reduxjs/toolkit/query';
3
5
  export declare const useAppDispatch: () => AppDispatch;
4
6
  export declare const useAppSelector: TypedUseSelectorHook<RootState>;
5
7
  export declare const selectBreakPoint: (state: RootState) => number;
8
+ export declare function useApiSubscribe(): <D extends QueryDefinition<any, any, any, any>>(subscription: ThunkAction<QueryActionCreatorResult<D>, any, any, any>) => Promise<ResultTypeFrom<D> | undefined>;
package/dist/hooks.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createDispatchHook, createSelectorHook } from 'react-redux';
2
2
  import { defaultRootState } from './Utils/store';
3
- import { useContext } from 'react';
3
+ import { useCallback, useContext, useEffect, useRef } from 'react';
4
4
  import { IdFormContext } from './Contexts/FormContext';
5
5
  import { StoreContext } from './Utils/StoreContext';
6
6
  const useSelector = createSelectorHook(StoreContext);
@@ -20,3 +20,19 @@ export const useAppSelector = (selector, options) => {
20
20
  return useSelector((state) => selector(state.forms[idForm] ?? defaultRootState), options);
21
21
  };
22
22
  export const selectBreakPoint = (state) => state.widthStats.currentBreakPoint;
23
+ export function useApiSubscribe() {
24
+ const dispatch = useAppDispatch();
25
+ const subscriptions = useRef([]);
26
+ useEffect(() => {
27
+ const subs = subscriptions.current;
28
+ return () => {
29
+ subs.forEach((unsubscribe) => unsubscribe());
30
+ };
31
+ }, []);
32
+ const subscribe = useCallback(async (subscription) => {
33
+ const result = dispatch(subscription);
34
+ result.unsubscribe();
35
+ return (await result).data;
36
+ }, [dispatch]);
37
+ return subscribe;
38
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arquimedes.co/eureka-forms",
3
3
  "repository": "git://github.com/Arquimede5/Eureka-Forms.git",
4
- "version":"3.0.47-test",
4
+ "version":"3.0.48-test",
5
5
  "scripts": {
6
6
  "watch": "tsgo --noEmit --watch --project tsconfig.app.json",
7
7
  "start": "vite",
@@ -21,6 +21,7 @@
21
21
  "date-fns": "4.1.0",
22
22
  "draft-js": "0.11.7",
23
23
  "i18n-iso-countries": "7.14.0",
24
+ "jwt-decode": "4.0.0",
24
25
  "libphonenumber-js": "1.12.42",
25
26
  "logrocket": "12.1.1",
26
27
  "nanoid": "5.1.11",
@@ -111,5 +112,11 @@
111
112
  "main": "./dist/index.lib.js",
112
113
  "files": [
113
114
  "/dist"
114
- ]
115
+ ],
116
+ "allowScripts": {
117
+ "@mui/x-telemetry@9.2.0": true,
118
+ "core-js@3.49.0": true,
119
+ "cypress@15.7.1": true,
120
+ "esbuild@0.27.7": true
121
+ }
115
122
  }