@m4l/components 9.3.19-BE101025-beta.2 → 9.3.19-BE241025-beta.1
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/@types/types.d.ts +1 -1
- package/components/AccountPopover/AccountPopover.js +12 -13
- package/components/AccountPopover/subcomponents/MenuPopover/MenuPopover.d.ts +1 -1
- package/components/AccountPopover/subcomponents/MenuPopover/MenuPopover.js +7 -4
- package/components/AccountPopover/subcomponents/MenuPopover/types.d.ts +1 -1
- package/components/Chip/Chip.js +9 -7
- package/components/Chip/ChipStyles.js +4 -31
- package/components/Chip/helpers.d.ts +10 -0
- package/components/Chip/helpers.js +34 -0
- package/components/Chip/types.d.ts +6 -0
- package/components/DataGrid/DataGrid.js +9 -4
- package/components/DataGrid/Datagrid.styles.js +270 -0
- package/components/DataGrid/constants.js +2 -2
- package/components/DataGrid/contexts/DataGridContext/index.js +322 -112
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +63 -4
- package/components/DataGrid/dictionary.d.ts +5 -0
- package/components/DataGrid/dictionary.js +6 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +2 -2
- package/components/DataGrid/hooks/useModalCardDetail.d.ts +6 -0
- package/components/DataGrid/hooks/useModalCardDetail.js +74 -0
- package/components/DataGrid/hooks/useProcessedColumns.d.ts +50 -0
- package/components/DataGrid/hooks/useProcessedColumns.js +44 -0
- package/components/DataGrid/icons.d.ts +7 -0
- package/components/DataGrid/icons.js +5 -1
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/slots/DataGridEnum.d.ts +22 -1
- package/components/DataGrid/slots/DataGridEnum.js +21 -0
- package/components/DataGrid/slots/DataGridSlot.d.ts +24 -0
- package/components/DataGrid/slots/DataGridSlot.js +123 -21
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.d.ts +9 -0
- package/components/DataGrid/subcomponents/Cards/hooks/useCardContent.js +91 -0
- package/components/DataGrid/subcomponents/Cards/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/Cards/index.js +40 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.d.ts +8 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardDetails/index.js +79 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardHeader/index.js +98 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.d.ts +6 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/CardRow/index.js +71 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.d.ts +20 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/IntersectCard/index.js +46 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.d.ts +17 -0
- package/components/DataGrid/subcomponents/Cards/subcomponents/LazyLoadCard/index.js +34 -0
- package/components/DataGrid/subcomponents/Cards/types.d.ts +118 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/index.js +43 -0
- package/components/DataGrid/subcomponents/CheckboxCellAdapter/types.d.ts +7 -0
- package/components/DataGrid/subcomponents/ControlNavigate/ControlNavigate.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/index.js +5 -3
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/RowsCount/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/index.js +11 -2
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.d.ts +2 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/index.js +304 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/Settings/subcomponents/ColumnsConfigCards/types.d.ts +31 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.d.ts +4 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/ViewMode/index.js +125 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettings/index.js +3 -3
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.d.ts +7 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/index.js +74 -0
- package/components/DataGrid/subcomponents/HeaderActions/subcomponents/hooks/useModalSettingsCards/types.d.ts +4 -0
- package/components/DataGrid/subcomponents/RenderContent/index.d.ts +5 -0
- package/components/DataGrid/subcomponents/RenderContent/index.js +11 -0
- package/components/DataGrid/subcomponents/Table/hooks/useHeaderMenuActions.js +2 -2
- package/components/DataGrid/subcomponents/Table/hooks/useSortColumnsRows.js +1 -1
- package/components/DataGrid/subcomponents/Table/index.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/ActionsColumn.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/DraggableHeaderRenderer.js +1 -1
- package/components/DataGrid/subcomponents/Table/subcomponents/HeaderRenderClick/HeaderRenderClick.js +1 -1
- package/components/DataGrid/subcomponents/editors/TextEditor/index.js +1 -1
- package/components/DataGrid/tests/components/CardDetails.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardHeader.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CardRow.test.d.ts +1 -0
- package/components/DataGrid/tests/components/Cards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/CheckboxCellAdapter.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ColumnsConfigCards.test.d.ts +1 -0
- package/components/DataGrid/tests/components/IntersectCard.test.d.ts +1 -0
- package/components/DataGrid/tests/components/ViewMode.test.d.ts +1 -0
- package/components/DataGrid/tests/helpers/types.d.ts +1 -0
- package/components/DataGrid/tests/helpers/useCardsViewConfig.d.ts +24 -0
- package/components/DataGrid/tests/helpers/useCustomCardExample.d.ts +7 -0
- package/components/DataGrid/tests/hooks/useCardContent.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalDetail.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useModalSettingsCards.test.d.ts +1 -0
- package/components/DataGrid/tests/hooks/useProcessedColumns.test.d.ts +1 -0
- package/components/DataGrid/types.d.ts +87 -5
- package/components/DragResizeWindowRND/DragResizeWindowRND.js +14 -10
- package/components/DragResizeWindowRND/helpers/expandingParentContainer.d.ts +1 -1
- package/components/DragResizeWindowRND/helpers/expandingParentContainer.js +24 -19
- package/components/DragResizeWindowRND/helpers/getInitialSize.d.ts +3 -3
- package/components/DragResizeWindowRND/helpers/getInitialSize.js +18 -15
- package/components/DragResizeWindowRND/helpers/shrinkingParentContainer.d.ts +1 -1
- package/components/DragResizeWindowRND/helpers/shrinkingParentContainer.js +17 -9
- package/components/DragResizeWindowRND/hooks/useRNDDimensionEffects.js +4 -1
- package/components/DragResizeWindowRND/index.d.ts +1 -0
- package/components/DragResizeWindowRND/types.d.ts +12 -2
- package/components/DynamicFilter/DynamicFilter.js +2 -1
- package/components/DynamicFilter/helpers/formatToInitialFilters.js +3 -3
- package/components/DynamicFilter/helpers/frontEndHelpers.d.ts +2 -2
- package/components/DynamicFilter/helpers/frontEndHelpers.js +31 -9
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.d.ts +2 -1
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/DynamicFilterBase.js +4 -2
- package/components/DynamicFilter/subcomponents/DynamicFilterBase/types.d.ts +3 -0
- package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/helpers.js +11 -3
- package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/helpers.js +16 -4
- package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/helpers.js +11 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectAsyncFilter/helpers.js +21 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/helpers.js +18 -8
- package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/helpers.js +5 -3
- package/components/DynamicFilter/subcomponents/PopoverFilter/PopoverFilter.js +1 -1
- package/components/DynamicFilter/types.d.ts +4 -0
- package/components/DynamicSort/DynamicSort.js +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.d.ts +2 -1
- package/components/DynamicSort/subcomponents/DynamicSortBase/DynamicSortBase.js +4 -2
- package/components/DynamicSort/subcomponents/DynamicSortBase/types.d.ts +3 -0
- package/components/DynamicSort/subcomponents/PopoverSort/PopoverSort.js +1 -1
- package/components/DynamicSort/types.d.ts +4 -0
- package/components/EditLabel/hooks/useEditLabel.d.ts +1 -0
- package/components/GridLayout/subcomponents/GridItem/index.js +2 -2
- package/components/Image/Image.js +4 -1
- package/components/LanguagePopover/LanguagePopover.js +2 -0
- package/components/MFIsolationApp/MFIsolationApp.js +1 -4
- package/components/MFIsolationApp/subcomponents/AppBarSettings/AppBarSettings.js +1 -1
- package/components/MFIsolationAppStorybook/MFIsolationAppStorybook.js +4 -20
- package/components/MFIsolationAppStorybook/types.d.ts +0 -4
- package/components/MFLoader/MFLoader.js +8 -3
- package/components/MFLoader/styles.js +1 -1
- package/components/MFLoader/types.d.ts +10 -0
- package/components/MenuActions/MenuActions.js +105 -55
- package/components/ObjectLogs/hooks/useDetailFormatter.js +1 -1
- package/components/WindowBase/WindowBase.js +3 -3
- package/components/WindowBase/WindowBase.styles.js +36 -31
- package/components/WindowBase/constants.d.ts +1 -1
- package/components/WindowBase/constants.js +2 -2
- package/components/WindowBase/index.d.ts +1 -0
- package/components/WindowBase/subcomponents/Component/index.js +2 -2
- package/components/WindowBase/subcomponents/Component/types.d.ts +2 -0
- package/components/WindowBase/subcomponents/Header/HeaderWindowBase.js +7 -7
- package/components/WindowBase/subcomponents/Header/types.d.ts +1 -1
- package/components/WindowBase/subcomponents/MicroFrontend/types.d.ts +4 -0
- package/components/WindowBase/types.d.ts +3 -3
- package/components/WindowConfirm/WindowConfirm.js +1 -1
- package/components/areas/components/AreasViewer/AreasViewer.styles.js +1 -1
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/Window.js +6 -2
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.d.ts +1 -0
- package/components/areas/components/AreasViewer/subcomponents/Area/subcomponents/Window/hooks/useWindow.js +21 -3
- package/components/areas/index.d.ts +1 -1
- package/components/areas/types.d.ts +1 -1
- package/components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js +3 -34
- package/components/formatters/DistanceToNowFormatter/dictionary.d.ts +8 -0
- package/components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.d.ts +13 -0
- package/components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.js +65 -0
- package/components/formatters/DistanceToNowFormatter/index.d.ts +1 -0
- package/components/formatters/DistanceToNowFormatter/types.d.ts +4 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.d.ts +1 -1
- package/components/hook-form/RHFAutocomplete/RHFAutocomplete.js +8 -4
- package/components/hook-form/RHFAutocomplete/constants.d.ts +1 -0
- package/components/hook-form/RHFAutocomplete/constants.js +5 -1
- package/components/hook-form/RHFAutocomplete/types.d.ts +2 -2
- package/components/hook-form/RHFAutocompleteAsync/RHFAutocompleteAsync.js +6 -4
- package/components/hook-form/RHFAutocompleteAsync/slots/RHFAutocompleteSlotsAsync.d.ts +1 -1
- package/components/hook-form/RHFAutocompleteAsync/types.d.ts +4 -0
- package/components/mui_extended/Autocomplete/Autocomplete.d.ts +4 -8
- package/components/mui_extended/Autocomplete/Autocomplete.js +11 -11
- package/components/mui_extended/Autocomplete/Autocomplete.styles.js +7 -3
- package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.d.ts +6 -0
- package/components/mui_extended/Autocomplete/RenderAdornment/RenderAdornment.js +45 -0
- package/components/mui_extended/Autocomplete/hooks/useEndAdornments.js +2 -1
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.d.ts +4 -12
- package/components/mui_extended/Autocomplete/hooks/useStartAdornments.js +72 -23
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.d.ts +0 -2
- package/components/mui_extended/Autocomplete/hooks/useValuesAndHandlers.js +0 -13
- package/components/mui_extended/Autocomplete/renderOptions/index.d.ts +4 -17
- package/components/mui_extended/Autocomplete/renderOptions/index.js +42 -5
- package/components/mui_extended/Autocomplete/renderOptions/types.d.ts +7 -0
- package/components/mui_extended/Autocomplete/types.d.ts +10 -3
- package/components/mui_extended/Button/ButtonStyles.js +15 -5
- package/components/mui_extended/ToggleIconButton/ToggleIconButton.js +6 -2
- package/components/mui_extended/ToggleIconButton/ToggleIconButton.styles.js +9 -0
- package/components/mui_extended/ToggleIconButton/types.d.ts +1 -0
- package/components/mui_extended/index.d.ts +1 -1
- package/components/popups/components/PopupsProvider/hooks/usePopups.d.ts +2 -2
- package/components/popups/components/PopupsProvider/hooks/usePopups.js +0 -1
- package/components/popups/components/PopupsViewer/PopupsViewer.js +4 -3
- package/components/popups/components/PopupsViewer/subcomponents/Popup/Popup.js +5 -2
- package/components/popups/components/PopupsViewer/subcomponents/Popup/types.d.ts +5 -0
- package/components/popups/components/PopupsViewer/types.d.ts +3 -0
- package/contexts/AppearanceComponentContext/AppearanceComponentContext.js +4 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/useDataGridPersistence/helpers.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.d.ts +2 -2
- package/hooks/useDataGridPersistence/useDataGridPersistence.js +5 -0
- package/hooks/useSizeContainer/index.d.ts +2 -1
- package/hooks/useSizeContainer/index.js +22 -13
- package/hooks/useSizeContainer/types.d.ts +6 -0
- package/hooks/useStateRef/index.d.ts +1 -1
- package/hooks/useStateRef/index.js +6 -6
- package/index.js +53 -46
- package/package.json +3 -4
- package/utils/deepShallow.d.ts +17 -0
- package/utils/deepShallow.js +76 -0
- package/utils/formatDistanceToNow/formatDistanteToNow.d.ts +2 -2
- package/utils/formatDistanceToNow/formatDistanteToNow.js +18 -2
- package/utils/formatDistanceToNow/types.d.ts +13 -0
- package/utils/index.d.ts +1 -0
- package/components/MFIsolationAppStorybook/icons.js +0 -6
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.d.ts +0 -4
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/AppBarSettings.js +0 -21
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.d.ts +0 -1
- package/components/MFIsolationAppStorybook/subcomponents/AppBarSettings/index.js +0 -1
|
@@ -11,7 +11,7 @@ import { M as MemonizedWindowBaseMicroFrontend } from "../../../../../WindowBase
|
|
|
11
11
|
import { W as WindowBaseComponent } from "../../../../../WindowBase/subcomponents/Component/index.js";
|
|
12
12
|
import { W as WindowBase } from "../../../../../WindowBase/WindowBase.js";
|
|
13
13
|
const Popup = forwardRef((props, ref) => {
|
|
14
|
-
const { popupId, containerElement, containerSize, style, onResizeStart, onResizeStop, onDragStart, onDragStop } = props;
|
|
14
|
+
const { popupId, containerElement, containerSize, style, onResizeStart, onResizeStop, onDragStart, onDragStop, loggedUser } = props;
|
|
15
15
|
const popup = usePopupsStore((state) => state.hashPopups[popupId], shallow);
|
|
16
16
|
const { bringPopupOnFront } = usePopupsStore((state) => state.popupsActions, shallow);
|
|
17
17
|
const { close } = usePopupsStore((state) => state.popupActions, shallow);
|
|
@@ -118,7 +118,7 @@ const Popup = forwardRef((props, ref) => {
|
|
|
118
118
|
isLoading: loading,
|
|
119
119
|
windowId: popupId,
|
|
120
120
|
selected,
|
|
121
|
-
|
|
121
|
+
emergeType: "popup",
|
|
122
122
|
variant: "outlined",
|
|
123
123
|
...process.env.NODE_ENV !== "production" ? {
|
|
124
124
|
[TEST_PROP_ID]: getNameDataTestId(
|
|
@@ -129,14 +129,17 @@ const Popup = forwardRef((props, ref) => {
|
|
|
129
129
|
children: winType === "microfrontend" ? /* @__PURE__ */ jsx(
|
|
130
130
|
MemonizedWindowBaseMicroFrontend,
|
|
131
131
|
{
|
|
132
|
+
emergeType: "popup",
|
|
132
133
|
moduleId,
|
|
133
134
|
dynamicMFStore,
|
|
134
135
|
windowTools,
|
|
136
|
+
loggedUser,
|
|
135
137
|
...mfProps ?? { debugPort: 0, prefix: "" }
|
|
136
138
|
}
|
|
137
139
|
) : /* @__PURE__ */ jsx(
|
|
138
140
|
WindowBaseComponent,
|
|
139
141
|
{
|
|
142
|
+
emergeType: "popup",
|
|
140
143
|
dynamicMFStore,
|
|
141
144
|
windowTools,
|
|
142
145
|
component
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
import { ContainerSize } from '../../../../../../utils/types';
|
|
3
|
+
import { AuthUserType } from '@m4l/core';
|
|
3
4
|
export type ResizeReason = 'start' | 'resize' | 'stop';
|
|
4
5
|
export interface PopupProps {
|
|
5
6
|
/**
|
|
@@ -34,4 +35,8 @@ export interface PopupProps {
|
|
|
34
35
|
* "onDragStop" Función que se ejecuta cuando se termina de arrastrar el popup
|
|
35
36
|
*/
|
|
36
37
|
onDragStop?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* "loggedUser" Usuario logueado
|
|
40
|
+
*/
|
|
41
|
+
loggedUser?: AuthUserType;
|
|
37
42
|
}
|
|
@@ -3,14 +3,17 @@ import { PopupViewerSlots } from './slots/slots';
|
|
|
3
3
|
import { POPUPS_VIEWER_KEY_COMPONENT } from './constants';
|
|
4
4
|
import { PopupStoreProps, PopupsProviderStoreState } from '../PopupsProvider/contexts/PopupsContext/types';
|
|
5
5
|
import { M4LOverridesStyleRules } from '../../../../@types/augmentations';
|
|
6
|
+
import { AuthUserType } from '@m4l/core';
|
|
6
7
|
export type PopupViewerSlotsType = keyof typeof PopupViewerSlots;
|
|
7
8
|
export type PopupsViewerProps = {
|
|
9
|
+
className?: string;
|
|
8
10
|
containerElement?: HTMLElement;
|
|
9
11
|
groupId?: string;
|
|
10
12
|
onResizeStart?: () => void;
|
|
11
13
|
onResizeStop?: () => void;
|
|
12
14
|
onDragStart?: () => void;
|
|
13
15
|
onDragStop?: () => void;
|
|
16
|
+
loggedUser?: AuthUserType;
|
|
14
17
|
};
|
|
15
18
|
export type PopupStatus = 'init' | 'closing' | 'hidden';
|
|
16
19
|
export interface PopupOwnerState extends Pick<PopupStoreProps, 'status' | 'subTitle' | 'editionInfo' | 'zIndex' | 'variant'> {
|
|
@@ -14,7 +14,10 @@ function AppearanceComponentProvider(props) {
|
|
|
14
14
|
}
|
|
15
15
|
useEffect(() => {
|
|
16
16
|
if (appearanceComponentStoreRef.current && defaultSize) {
|
|
17
|
-
appearanceComponentStoreRef.current.getState().
|
|
17
|
+
const currentStoreSize = appearanceComponentStoreRef.current.getState().defaultSize;
|
|
18
|
+
if (currentStoreSize !== defaultSize) {
|
|
19
|
+
appearanceComponentStoreRef.current.getState().actions.setDefaultSize(defaultSize);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
}, [defaultSize]);
|
|
20
23
|
return /* @__PURE__ */ jsx(AppearanceComponentContext.Provider, { value: appearanceComponentStoreRef.current, children });
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IGridConfigExtended } from '../../components/DataGrid';
|
|
2
2
|
/**
|
|
3
3
|
* Obtiene el sort de la cookie
|
|
4
4
|
*/
|
|
5
|
-
export declare const getColumnsConfigCookie: (cookie: Record<string, any> | undefined | Array<any>) =>
|
|
5
|
+
export declare const getColumnsConfigCookie: (cookie: Record<string, any> | undefined | Array<any>) => IGridConfigExtended["columnsConfig"];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UseDataGridPersistenceProps } from './types';
|
|
2
|
-
import { ChangeUserColumn,
|
|
2
|
+
import { ChangeUserColumn, IGridConfigExtended } from '../../components/DataGrid';
|
|
3
3
|
/**
|
|
4
4
|
* Hook para manejar los filtros y ordenamientos dinamicos
|
|
5
5
|
*/
|
|
6
6
|
export declare const useDataGridPersistence: (props: UseDataGridPersistenceProps) => {
|
|
7
7
|
onChangeUserColumns: (newProps: ChangeUserColumn) => void;
|
|
8
|
-
defaultUserColumns:
|
|
8
|
+
defaultUserColumns: IGridConfigExtended;
|
|
9
9
|
};
|
|
@@ -13,10 +13,15 @@ const useDataGridPersistence = (props) => {
|
|
|
13
13
|
});
|
|
14
14
|
const onChangeUserColumns = useCallback((newProps) => {
|
|
15
15
|
const { reason, userConfig } = newProps;
|
|
16
|
+
if (userConfig === void 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
16
19
|
if (reason === "columnsConfig") {
|
|
17
20
|
setCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_CONFIG}` : COOKIE_COLUMNS_CONFIG, "window", userConfig);
|
|
18
21
|
} else if (reason === "columnsWidths") {
|
|
19
22
|
setCookie(prefixCookie ? `${prefixCookie}_${COOKIE_COLUMNS_WIDTHS}` : COOKIE_COLUMNS_WIDTHS, "window", userConfig);
|
|
23
|
+
} else {
|
|
24
|
+
setCookie(prefixCookie ? `${prefixCookie}_${reason}` : reason, "window", userConfig);
|
|
20
25
|
}
|
|
21
26
|
}, [setCookie, prefixCookie]);
|
|
22
27
|
return {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ContainerSize } from '../../utils/types';
|
|
2
|
+
import { UseSizeContainerOptions } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* useSizeContainer: hook encargado de obtener el tamaño de un elemento contenedor
|
|
4
5
|
* TODO: Usar throttle para evitar llamadas innecesarias
|
|
5
6
|
* @param containerElement
|
|
6
7
|
* @returns un objeto con el ancho y alto del contenedor
|
|
7
8
|
*/
|
|
8
|
-
export declare function useSizeContainer(containerElement?: HTMLElement | undefined | null): ContainerSize | undefined;
|
|
9
|
+
export declare function useSizeContainer(containerElement?: HTMLElement | undefined | null, options?: UseSizeContainerOptions): ContainerSize | undefined;
|
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
2
|
import { T as THROTTLE_RESIZE_TIMEOUT } from "./contants.js";
|
|
3
3
|
import throttle from "lodash-es/throttle";
|
|
4
|
-
function useSizeContainer(containerElement) {
|
|
5
|
-
const
|
|
4
|
+
function useSizeContainer(containerElement, options) {
|
|
5
|
+
const { throttleTime = THROTTLE_RESIZE_TIMEOUT, excludePadding = false, leading = false, trailing = true } = options || {};
|
|
6
|
+
const [currentState, setCurrentState] = useState(void 0);
|
|
6
7
|
useEffect(() => {
|
|
7
8
|
if (!containerElement) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const setter = (size) => {
|
|
12
|
+
setCurrentState(size);
|
|
13
|
+
};
|
|
14
|
+
const throttleResize = throttle(setter, throttleTime, {
|
|
15
|
+
leading,
|
|
16
|
+
// Evento de resizing (Por defecto false)
|
|
17
|
+
trailing
|
|
14
18
|
// Incluir siempre el ultimo evento en la cola, para que no quede se quedee a la mitad de resizing
|
|
15
19
|
});
|
|
16
20
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
17
|
-
|
|
21
|
+
if (excludePadding) {
|
|
18
22
|
throttleResize({
|
|
19
|
-
containerWidth: Math.round(
|
|
20
|
-
containerHeight: Math.round(
|
|
23
|
+
containerWidth: Math.round(containerElement.clientWidth),
|
|
24
|
+
containerHeight: Math.round(containerElement.clientHeight)
|
|
21
25
|
});
|
|
26
|
+
} else {
|
|
27
|
+
for (const entry of entries) {
|
|
28
|
+
throttleResize({
|
|
29
|
+
containerWidth: Math.round(entry.contentRect.width),
|
|
30
|
+
containerHeight: Math.round(entry.contentRect.height)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
});
|
|
24
|
-
|
|
25
|
-
resizeObserver.observe(containerElement);
|
|
26
|
-
}
|
|
35
|
+
resizeObserver.observe(containerElement);
|
|
27
36
|
return () => {
|
|
28
37
|
if (containerElement) {
|
|
29
38
|
resizeObserver.unobserve(containerElement);
|
|
30
39
|
}
|
|
31
40
|
};
|
|
32
|
-
}, [containerElement]);
|
|
41
|
+
}, [containerElement, excludePadding, leading, throttleTime, trailing]);
|
|
33
42
|
return currentState;
|
|
34
43
|
}
|
|
35
44
|
export {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @param initialValue
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare function useStateRef<T>(initialValue: T | null): [T | null, (node: T | null) => void];
|
|
8
|
+
export declare function useStateRef<T extends HTMLElement | null>(initialValue: T | null): [T | null, (node: T | null) => void];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useState, useRef } from "react";
|
|
1
|
+
import { useState, useRef, useCallback } from "react";
|
|
2
2
|
function useStateRef(initialValue) {
|
|
3
3
|
const [refState, setRefState] = useState(initialValue);
|
|
4
4
|
const nodeRef = useRef(null);
|
|
5
|
-
const ref = (
|
|
6
|
-
if (nodeRef.current !==
|
|
7
|
-
nodeRef.current =
|
|
8
|
-
setRefState(
|
|
5
|
+
const ref = useCallback((current) => {
|
|
6
|
+
if (current && nodeRef.current !== current) {
|
|
7
|
+
nodeRef.current = current;
|
|
8
|
+
setRefState(current);
|
|
9
9
|
}
|
|
10
|
-
};
|
|
10
|
+
}, []);
|
|
11
11
|
return [refState, ref];
|
|
12
12
|
}
|
|
13
13
|
export {
|
package/index.js
CHANGED
|
@@ -35,7 +35,7 @@ import { D as D2 } from "./components/DataGrid/DataGrid.js";
|
|
|
35
35
|
import { g as g5 } from "./components/DataGrid/dictionary.js";
|
|
36
36
|
import { N, T as T2 } from "./components/DataGrid/subcomponents/editors/TextEditor/index.js";
|
|
37
37
|
import { g as g6 } from "./components/DataGrid/utils/getDataGridRowsFromSet.js";
|
|
38
|
-
import { b as b3, a as a4,
|
|
38
|
+
import { b as b3, a as a4, f } from "./components/DataGrid/constants.js";
|
|
39
39
|
import { C as C4 } from "./components/DataGrid/formatters/ColumnBooleanFormatter/formatter.js";
|
|
40
40
|
import { u as u2 } from "./components/DataGrid/formatters/ColumnBooleanFormatter/useColumnBoolean.js";
|
|
41
41
|
import { C as C5 } from "./components/DataGrid/formatters/ColumnConcatenatedValuesFormatter/formatter.js";
|
|
@@ -122,11 +122,12 @@ import { P as P5, g as g16 } from "./components/formatters/PriceFormatter/PriceF
|
|
|
122
122
|
import { C as C18 } from "./components/formatters/ChipStatusFormatter/ChipStatusFormatter.js";
|
|
123
123
|
import { g as g17 } from "./components/formatters/DistanceToNowFormatter/dictionary.js";
|
|
124
124
|
import { D as D9 } from "./components/formatters/DistanceToNowFormatter/DistanceToNowFormatter.js";
|
|
125
|
+
import { u as u13 } from "./components/formatters/DistanceToNowFormatter/hooks/useDistanceToNowFormatter.js";
|
|
125
126
|
import { g as g18 } from "./components/formatters/dictionary.js";
|
|
126
127
|
import { F as F2 } from "./components/FormContainer/FormContainer.js";
|
|
127
128
|
import { G } from "./components/GridLayout/GridLayout.js";
|
|
128
129
|
import { R as R4 } from "./components/GridLayout/subcomponents/Responsive/index.js";
|
|
129
|
-
import { c as c2, e
|
|
130
|
+
import { c as c2, e, d as d3 } from "./components/GridLayout/subcomponents/Responsive/responsiveUtils.js";
|
|
130
131
|
import { i, k } from "./components/GridLayout/utils.js";
|
|
131
132
|
import { w } from "./components/GridLayout/subcomponents/withSizeProvider/index.js";
|
|
132
133
|
import { H as H2 } from "./components/HelmetPage/index.js";
|
|
@@ -176,7 +177,7 @@ import { g as g27 } from "./components/ObjectLogs/dictionary.js";
|
|
|
176
177
|
import { O } from "./components/ObjectLogs/ObjectLogs.js";
|
|
177
178
|
import { P as P7 } from "./components/PaperForm/PaperForm.js";
|
|
178
179
|
import { P as P8 } from "./components/PDFViewer/PDFViewer.js";
|
|
179
|
-
import { u as
|
|
180
|
+
import { u as u14 } from "./components/popups/components/PopupsProvider/hooks/usePopupsStore.js";
|
|
180
181
|
import { a as a10, P as P9 } from "./components/popups/components/PopupsProvider/contexts/PopupsContext/PopupsContext.js";
|
|
181
182
|
import { P as P10 } from "./components/popups/components/PopupsViewer/PopupsViewer.js";
|
|
182
183
|
import { P as P11 } from "./components/PrintingSystem/PrintingSystem.js";
|
|
@@ -186,8 +187,8 @@ import { S as S9 } from "./components/SideBar/SideBar.js";
|
|
|
186
187
|
import { T as T17 } from "./components/ToastContainer/ToastContainer.js";
|
|
187
188
|
import { T as T18 } from "./components/ToastContainer/subcomponents/ToastMessage/ToastMessage.js";
|
|
188
189
|
import { W as W2 } from "./components/WindowBase/WindowBase.js";
|
|
189
|
-
import { u as
|
|
190
|
-
import { u as
|
|
190
|
+
import { u as u15 } from "./components/WindowBase/hooks/useWindowToolsMF/index.js";
|
|
191
|
+
import { u as u16, a as a11 } from "./components/WindowBase/hooks/useDynamicMFParameters/index.js";
|
|
191
192
|
import { M as M7, W as W3, a as a12 } from "./components/WindowBase/contexts/WindowToolsMFContext/WindowToolsMFContext.js";
|
|
192
193
|
import { c as c3 } from "./components/WindowBase/contexts/DynamicMFParmsContext/store.js";
|
|
193
194
|
import { D as D10, a as a13, M as M8 } from "./components/WindowBase/contexts/DynamicMFParmsContext/DynamicMFParmsContext.js";
|
|
@@ -196,7 +197,7 @@ import { a as a14, g as g28 } from "./components/ModalDialog/dictionary.js";
|
|
|
196
197
|
import { M as M9 } from "./components/ModalDialog/ModalDialog.js";
|
|
197
198
|
import { S as S10 } from "./components/SettingsLayout/SettingsLayout.js";
|
|
198
199
|
import { P as P13 } from "./components/Pager/Pager.js";
|
|
199
|
-
import { u as
|
|
200
|
+
import { u as u17 } from "./components/Stepper/hooks/useStepper/index.js";
|
|
200
201
|
import { S as S11 } from "./components/Stepper/Stepper.js";
|
|
201
202
|
import { S as S12 } from "./components/Stepper/subcomponents/StepperContent/index.js";
|
|
202
203
|
import { S as S13 } from "./components/Stepper/subcomponents/StepperContent/subcomponents/Step/index.js";
|
|
@@ -207,28 +208,29 @@ import { S as S17 } from "./components/Stepper/subcomponents/StepperButtons/Step
|
|
|
207
208
|
import { S as S18 } from "./components/Stepper/subcomponents/StepperButtons/StepperPrevButton/index.js";
|
|
208
209
|
import { S as S19 } from "./components/Stepper/subcomponents/StepperButtons/StepperCancelButton/index.js";
|
|
209
210
|
import { S as S20 } from "./components/Stepper/subcomponents/StepperButtons/StepperSubmitButton/index.js";
|
|
210
|
-
import { e as
|
|
211
|
+
import { e as e2 } from "./components/Stepper/helpers/evaluateVisibilityStepCondition/index.js";
|
|
211
212
|
import { g as g29 } from "./components/Stepper/dictionary.js";
|
|
212
|
-
import { F as F3, R as R23, u as
|
|
213
|
+
import { F as F3, R as R23, u as u18 } from "./components/hook-form/RHFormContext/index.js";
|
|
213
214
|
import { g as g30 } from "./components/hook-form/RHFormContext/dictionary.js";
|
|
214
|
-
import { u as
|
|
215
|
+
import { u as u19 } from "./contexts/AppearanceComponentContext/useAppearanceComponentStore.js";
|
|
215
216
|
import { A as A16 } from "./contexts/AppearanceComponentContext/AppearanceComponentContext.js";
|
|
216
217
|
import { a as a15, M as M10 } from "./contexts/ModalContext/index.js";
|
|
217
|
-
import { u as
|
|
218
|
-
import { u as
|
|
219
|
-
import { u as
|
|
218
|
+
import { u as u20 } from "./hooks/useFormAddEdit/index.js";
|
|
219
|
+
import { u as u21 } from "./hooks/useModal/index.js";
|
|
220
|
+
import { u as u22 } from "./hooks/useTab/index.js";
|
|
220
221
|
import { g as g31 } from "./hooks/useFormAddEdit/dictionary.js";
|
|
221
|
-
import { u as
|
|
222
|
-
import { u as
|
|
223
|
-
import { u as
|
|
224
|
-
import { u as
|
|
225
|
-
import { u as
|
|
222
|
+
import { u as u23 } from "./hooks/useFormFocus/index.js";
|
|
223
|
+
import { u as u24 } from "./hooks/useInterval/index.js";
|
|
224
|
+
import { u as u25 } from "./hooks/useComponentSize/useComponentSize.js";
|
|
225
|
+
import { u as u26 } from "./hooks/useFormReadyForUpdate/index.js";
|
|
226
|
+
import { u as u27 } from "./hooks/useStateRef/index.js";
|
|
226
227
|
import { S as S21 } from "./hooks/useSvgColor/constants.js";
|
|
227
|
-
import { u as
|
|
228
|
-
import { u as
|
|
229
|
-
import { u as
|
|
230
|
-
import { u as
|
|
231
|
-
import { u as
|
|
228
|
+
import { u as u28 } from "./hooks/useSvgColor/useSvgColor.js";
|
|
229
|
+
import { u as u29 } from "./hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js";
|
|
230
|
+
import { u as u30 } from "./hooks/useDataGridPersistence/useDataGridPersistence.js";
|
|
231
|
+
import { u as u31 } from "./hooks/usePopoverContainer/usePopoverContainer.js";
|
|
232
|
+
import { u as u32 } from "./hooks/useIsVisible/useIsVisible.js";
|
|
233
|
+
import { u as u33 } from "./hooks/useSizeContainer/index.js";
|
|
232
234
|
import { c as c4 } from "./utils/capitalizeFirstLetter.js";
|
|
233
235
|
import { i as i2 } from "./utils/isValidDate.js";
|
|
234
236
|
import { g as g32 } from "./utils/getComponentUtilityClass.js";
|
|
@@ -238,9 +240,10 @@ import { g as g35 } from "./utils/getIconColor.js";
|
|
|
238
240
|
import { a as a16, g as g36 } from "./utils/getSizeStyles/getSizeStyles.js";
|
|
239
241
|
import { O as O2 } from "./utils/ObjectQueue.js";
|
|
240
242
|
import { g as g37, a as a17 } from "./utils/getComponentSlotRoot.js";
|
|
241
|
-
import { f } from "./utils/formatDistanceToNow/formatDistanteToNow.js";
|
|
243
|
+
import { f as f2 } from "./utils/formatDistanceToNow/formatDistanteToNow.js";
|
|
242
244
|
import { g as g38 } from "./utils/getValidDate.js";
|
|
243
245
|
import { g as g39 } from "./utils/getNullGuard.js";
|
|
246
|
+
import { c as c5, d as d4 } from "./utils/deepShallow.js";
|
|
244
247
|
import { g as g40 } from "./helpers/getStepsAndValidationSchema/getStepsAndValidationSchema.js";
|
|
245
248
|
export {
|
|
246
249
|
A7 as AREAS_DICCTIONARY,
|
|
@@ -287,7 +290,7 @@ export {
|
|
|
287
290
|
C3 as ContainerFlow,
|
|
288
291
|
b3 as DATAGRID_ROW_HEADER_HEIGHTS,
|
|
289
292
|
a4 as DATAGRID_ROW_HEIGHTS,
|
|
290
|
-
|
|
293
|
+
f as DATAGRID_SEMANTIC_WIDTHS,
|
|
291
294
|
D as DICTIONARY,
|
|
292
295
|
D2 as DataGrid,
|
|
293
296
|
D8 as DateFormatter,
|
|
@@ -427,15 +430,17 @@ export {
|
|
|
427
430
|
W3 as WindowToolsMFContext,
|
|
428
431
|
a12 as WindowToolsMFProvider,
|
|
429
432
|
c2 as addLayoutItemToBreakPointIfNoExists,
|
|
430
|
-
|
|
433
|
+
e as addLayoutItemToBreakPoints,
|
|
431
434
|
c4 as capitalizeFirstLetter,
|
|
432
435
|
d3 as cloneLayouts,
|
|
436
|
+
c5 as createCustomDeepShallow,
|
|
433
437
|
c3 as createDynamicMFStore,
|
|
434
438
|
c as createToaster,
|
|
439
|
+
d4 as deepShallow,
|
|
435
440
|
d as defaultCommonActionsDictionary,
|
|
436
441
|
d2 as dragResizeWindowRNDClasses,
|
|
437
|
-
|
|
438
|
-
|
|
442
|
+
e2 as evaluateVisibilityStepCondition,
|
|
443
|
+
f2 as formatDistanceToNow,
|
|
439
444
|
g as getAccountPopoverDictionary,
|
|
440
445
|
g2 as getAppBarDictionary,
|
|
441
446
|
b2 as getAreasComponentsDictionary,
|
|
@@ -488,7 +493,7 @@ export {
|
|
|
488
493
|
r as rhfPeriodStyles,
|
|
489
494
|
t as toggleButtonStyles,
|
|
490
495
|
t2 as toggleIconButtonStyles,
|
|
491
|
-
|
|
496
|
+
u19 as useAppearanceComponentStore,
|
|
492
497
|
u as useAreasStore,
|
|
493
498
|
u2 as useColumnBoolean,
|
|
494
499
|
u11 as useColumnChipStatus,
|
|
@@ -500,26 +505,28 @@ export {
|
|
|
500
505
|
u8 as useColumnPrice,
|
|
501
506
|
u9 as useColumnSetCheck,
|
|
502
507
|
u10 as useColumnUncertanity,
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
+
u25 as useComponentSize,
|
|
509
|
+
u18 as useCustomForm,
|
|
510
|
+
u30 as useDataGridPersistence,
|
|
511
|
+
u13 as useDistanceToNowFormatter,
|
|
512
|
+
u29 as useDynamicFilterAndSort,
|
|
513
|
+
u16 as useDynamicMFParameters,
|
|
508
514
|
a11 as useDynamicMFParametersStore,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
515
|
+
u20 as useFormAddEdit,
|
|
516
|
+
u23 as useFormFocus,
|
|
517
|
+
u26 as useFormReadyForUpdate,
|
|
512
518
|
u12 as useFormatPeriod,
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
519
|
+
u24 as useInterval,
|
|
520
|
+
u32 as useIsVisible,
|
|
521
|
+
u21 as useModal,
|
|
522
|
+
u31 as usePopoverContainer,
|
|
523
|
+
u14 as usePopupsStore,
|
|
524
|
+
u33 as useSizeContainer,
|
|
525
|
+
u27 as useStateRef,
|
|
526
|
+
u17 as useStepper,
|
|
527
|
+
u28 as useSvgColor,
|
|
528
|
+
u22 as useTab,
|
|
529
|
+
u15 as useWindowToolsMF,
|
|
523
530
|
v2 as varBounce,
|
|
524
531
|
v3 as varContainer,
|
|
525
532
|
v as varFade,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/components",
|
|
3
|
-
"version": "9.3.19-
|
|
3
|
+
"version": "9.3.19-BE241025-beta.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"description": "M4L Components",
|
|
6
6
|
"lint-staged": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@googlemaps/js-api-loader": "^1.16.6",
|
|
12
12
|
"@hookform/resolvers": "2.9.11",
|
|
13
13
|
"@m4l/core": "^2.0.0",
|
|
14
|
-
"@m4l/graphics": "7.
|
|
15
|
-
"@m4l/styles": "7.1.34-
|
|
14
|
+
"@m4l/graphics": "7.2.0-BE171025-beta.1",
|
|
15
|
+
"@m4l/styles": "7.1.34-BE171025-beta.1",
|
|
16
16
|
"@mui/lab": "5.0.0-alpha.173",
|
|
17
17
|
"@mui/material": "5.16.7",
|
|
18
18
|
"@mui/x-date-pickers": "6.20.2",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"react-helmet-async": "^2.0.5",
|
|
44
44
|
"react-hook-form": "^7.33.1",
|
|
45
45
|
"react-intersection-observer": "^9.4.0",
|
|
46
|
-
"react-leaflet": "^4.2.1",
|
|
47
46
|
"react-resizable": "^3.0.4",
|
|
48
47
|
"react-resizable-panels": "^2.1.8",
|
|
49
48
|
"react-rnd": "^10.5.2",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type DeepShallowOptions = {
|
|
2
|
+
maxDepth?: number;
|
|
3
|
+
ignoreTypes?: Array<string>;
|
|
4
|
+
compareArrays?: boolean;
|
|
5
|
+
compareObjects?: boolean;
|
|
6
|
+
customComparers?: Record<string, (a: any, b: any) => boolean>;
|
|
7
|
+
log?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Comparador con profundidad
|
|
11
|
+
*/
|
|
12
|
+
export declare const deepShallow: <T>(objA: T, objB: T, depth?: number, options?: DeepShallowOptions) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Crea una función de comparación profunda con opciones personalizadas
|
|
15
|
+
*/
|
|
16
|
+
export declare const createCustomDeepShallow: <T>(options?: DeepShallowOptions) => (objA: T, objB: T, depth?: number) => boolean;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const deepShallow = (objA, objB, depth = 0, options) => {
|
|
2
|
+
const {
|
|
3
|
+
maxDepth = 10,
|
|
4
|
+
ignoreTypes = ["function"],
|
|
5
|
+
compareArrays = true,
|
|
6
|
+
compareObjects = true,
|
|
7
|
+
customComparers = {},
|
|
8
|
+
log = false
|
|
9
|
+
} = options || {};
|
|
10
|
+
if (log && process.env.NODE_ENV === "development" && depth === 0) {
|
|
11
|
+
console.log("deepShallow**", objA, objB, depth);
|
|
12
|
+
}
|
|
13
|
+
if (depth >= maxDepth) {
|
|
14
|
+
return Object.is(objA, objB);
|
|
15
|
+
}
|
|
16
|
+
if (objA === objB) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (objA == null || objB == null) {
|
|
20
|
+
return objA === objB;
|
|
21
|
+
}
|
|
22
|
+
if (typeof objA !== "object" || typeof objB !== "object") {
|
|
23
|
+
return objA === objB;
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(objA) && Array.isArray(objB)) {
|
|
26
|
+
if (!compareArrays) {
|
|
27
|
+
return Object.is(objA, objB);
|
|
28
|
+
}
|
|
29
|
+
if (objA.length !== objB.length) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
for (let i = 0; i < objA.length; i++) {
|
|
33
|
+
if (!deepShallow(objA[i], objB[i], depth + 1, options)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(objA) || Array.isArray(objB)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!compareObjects) {
|
|
43
|
+
return Object.is(objA, objB);
|
|
44
|
+
}
|
|
45
|
+
const keysA = Object.keys(objA);
|
|
46
|
+
const keysB = Object.keys(objB);
|
|
47
|
+
if (keysA.length !== keysB.length) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
51
|
+
const key = keysA[i];
|
|
52
|
+
const valueA = objA[key];
|
|
53
|
+
const valueB = objB[key];
|
|
54
|
+
if (ignoreTypes.includes(typeof valueA)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const valueType = typeof valueA;
|
|
58
|
+
if (customComparers[valueType]) {
|
|
59
|
+
if (!customComparers[valueType](valueA, valueB)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!deepShallow(valueA, valueB, depth + 1, options)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
const createCustomDeepShallow = (options) => {
|
|
71
|
+
return (objA, objB, depth = 0) => deepShallow(objA, objB, depth, options);
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
createCustomDeepShallow as c,
|
|
75
|
+
deepShallow as d
|
|
76
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PresentationTimeType, FormatDistanteToNowDictionary } from './types';
|
|
1
|
+
import { PresentationTimeType, FormatDistanteToNowDictionary, FormatDistanceToNowReturn } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* TODO: Documentar
|
|
4
4
|
*/
|
|
5
|
-
export declare const formatDistanceToNow: (type: PresentationTimeType, date: Date, dictionary: FormatDistanteToNowDictionary) =>
|
|
5
|
+
export declare const formatDistanceToNow: (type: PresentationTimeType, date: Date, dictionary: FormatDistanteToNowDictionary) => FormatDistanceToNowReturn;
|
|
@@ -9,7 +9,7 @@ const replaceValues = (label, ...values) => {
|
|
|
9
9
|
};
|
|
10
10
|
const formatDistanceToNow = (type, date, dictionary) => {
|
|
11
11
|
if (!(date instanceof Date)) {
|
|
12
|
-
return "No date";
|
|
12
|
+
return { time: "No date", value: "", unit: "" };
|
|
13
13
|
}
|
|
14
14
|
const now = /* @__PURE__ */ new Date();
|
|
15
15
|
const diff = now.getTime() - date.getTime();
|
|
@@ -19,6 +19,8 @@ const formatDistanceToNow = (type, date, dictionary) => {
|
|
|
19
19
|
const days = Math.floor(hours / 24);
|
|
20
20
|
const months = Math.floor(days / 30);
|
|
21
21
|
const years = Math.floor(months / 12);
|
|
22
|
+
let value;
|
|
23
|
+
let unit;
|
|
22
24
|
let timeElaped = "";
|
|
23
25
|
const unitYears = years > 1 ? dictionary.label_unit_time_years : dictionary.label_unit_time_year;
|
|
24
26
|
const unitMonths = months % 12 > 1 ? dictionary.label_unit_time_months : dictionary.label_unit_time_month;
|
|
@@ -32,6 +34,8 @@ const formatDistanceToNow = (type, date, dictionary) => {
|
|
|
32
34
|
} else if (type === "future") {
|
|
33
35
|
label = dictionary.label_sentence_future_others;
|
|
34
36
|
}
|
|
37
|
+
const separatorTime = ":";
|
|
38
|
+
const separatorDate = "-";
|
|
35
39
|
if (seconds < 60) {
|
|
36
40
|
if (type === "past") {
|
|
37
41
|
timeElaped = replaceValues(dictionary.label_sentence_past_seconds, seconds + "", unitSeconds);
|
|
@@ -48,34 +52,46 @@ const formatDistanceToNow = (type, date, dictionary) => {
|
|
|
48
52
|
unitSeconds
|
|
49
53
|
);
|
|
50
54
|
}
|
|
55
|
+
value = seconds.toString().padStart(2, "0") + "";
|
|
56
|
+
unit = dictionary.label_unit_time_seconds_short;
|
|
51
57
|
} else if (minutes < 60) {
|
|
52
58
|
timeElaped = replaceValues(label, `${minutes}`, unitMinutes);
|
|
59
|
+
value = minutes.toString().padStart(2, "0") + ":" + (seconds % 60).toString().padStart(2, "0");
|
|
60
|
+
unit = dictionary.label_unit_time_minutes_short + dictionary.label_separator_time + dictionary.label_unit_time_seconds_short;
|
|
53
61
|
} else if (hours < 24) {
|
|
54
62
|
if (minutes % 60 > 0) {
|
|
55
63
|
timeElaped = replaceValues(label, `${hours} ${unitHours} ${minutes % 60} ${unitMinutes}`, "");
|
|
56
64
|
} else {
|
|
57
65
|
timeElaped = replaceValues(label, `${hours} ${unitHours}`, "");
|
|
58
66
|
}
|
|
67
|
+
value = hours.toString().padStart(2, "0") + ":" + (minutes % 60).toString().padStart(2, "0");
|
|
68
|
+
unit = dictionary.label_unit_time_hours_short + separatorTime + dictionary.label_unit_time_minutes_short;
|
|
59
69
|
} else if (days < 30) {
|
|
60
70
|
if (hours % 24 > 0) {
|
|
61
71
|
timeElaped = replaceValues(label, `${days} ${unitDays} ${hours % 24} ${unitHours}`, "");
|
|
62
72
|
} else {
|
|
63
73
|
timeElaped = replaceValues(label, `${days} ${unitDays}`, "");
|
|
64
74
|
}
|
|
75
|
+
value = days.toString().padStart(2, "0") + " " + (hours % 24).toString().padStart(2, "0");
|
|
76
|
+
unit = dictionary.label_unit_time_days_short + " " + dictionary.label_unit_time_hours_short;
|
|
65
77
|
} else if (months < 12) {
|
|
66
78
|
if (days % 30 > 0) {
|
|
67
79
|
timeElaped = replaceValues(label, `${months} ${unitMonths} ${days % 30} ${unitDays}`, "");
|
|
68
80
|
} else {
|
|
69
81
|
timeElaped = replaceValues(label, `${months} ${unitMonths}`, "");
|
|
70
82
|
}
|
|
83
|
+
value = months.toString().padStart(2, "0") + separatorDate + (days % 30).toString().padStart(2, "0");
|
|
84
|
+
unit = dictionary.label_unit_time_months_short + separatorDate + dictionary.label_unit_time_days_short;
|
|
71
85
|
} else {
|
|
72
86
|
if (months % 12 > 0) {
|
|
73
87
|
timeElaped = replaceValues(label, `${years} ${unitYears} ${months % 12} ${unitMonths}`, "");
|
|
74
88
|
} else {
|
|
75
89
|
timeElaped = replaceValues(label, `${years} ${unitYears}`, "");
|
|
76
90
|
}
|
|
91
|
+
value = years.toString().padStart(2, "0") + separatorDate + (months % 12).toString().padStart(2, "0");
|
|
92
|
+
unit = dictionary.label_unit_time_years_short + separatorDate + dictionary.label_unit_time_months_short;
|
|
77
93
|
}
|
|
78
|
-
return timeElaped;
|
|
94
|
+
return { time: timeElaped, value, unit };
|
|
79
95
|
};
|
|
80
96
|
export {
|
|
81
97
|
formatDistanceToNow as f
|