@astral/ui 4.29.0 → 4.31.0
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/components/Filename/Filename.js +2 -2
- package/components/Filename/styles.d.ts +4 -0
- package/components/Filename/styles.js +4 -1
- package/components/Stepper/StepButton/StepButton.d.ts +7 -1
- package/components/Stepper/StepButton/StepButton.js +4 -2
- package/components/Stepper/StepButton/styles.d.ts +2 -1
- package/components/Stepper/StepIcon/StepIcon.d.ts +6 -2
- package/components/Stepper/StepIcon/StepIcon.js +11 -7
- package/components/Stepper/StepIcon/styles.js +1 -0
- package/components/Stepper/StepLabel/StepLabel.d.ts +7 -1
- package/components/Stepper/StepLabel/StepLabel.js +2 -2
- package/components/Stepper/constants.d.ts +1 -0
- package/components/Stepper/constants.js +1 -0
- package/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.d.ts +2 -0
- package/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.js +10 -0
- package/hook-form/FormFilters/AllFiltersButton/index.d.ts +1 -0
- package/hook-form/FormFilters/AllFiltersButton/index.js +1 -0
- package/hook-form/FormFilters/AllFiltersButton/styles.d.ts +19 -0
- package/hook-form/FormFilters/AllFiltersButton/styles.js +53 -0
- package/hook-form/FormFilters/AllFiltersButton/types.d.ts +8 -0
- package/hook-form/FormFilters/AllFiltersButton/types.js +1 -0
- package/hook-form/FormFilters/AllFiltersButton/useLogic/index.d.ts +1 -0
- package/hook-form/FormFilters/AllFiltersButton/useLogic/index.js +1 -0
- package/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.d.ts +6 -0
- package/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.js +33 -0
- package/hook-form/FormFilters/FormFilters.js +5 -6
- package/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.d.ts +1 -1
- package/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.js +4 -7
- package/hook-form/FormFilters/constants.d.ts +0 -1
- package/hook-form/FormFilters/constants.js +0 -1
- package/hook-form/FormFilters/styles.d.ts +0 -18
- package/hook-form/FormFilters/styles.js +0 -51
- package/hook-form/FormFilters/types.d.ts +7 -16
- package/hook-form/FormFilters/useLogic/useLogic.d.ts +5 -6
- package/hook-form/FormFilters/useLogic/useLogic.js +7 -95
- package/hook-form/FormFiltersSearchField/FormFiltersSearchField.js +1 -1
- package/node/components/Filename/Filename.js +1 -1
- package/node/components/Filename/styles.d.ts +4 -0
- package/node/components/Filename/styles.js +5 -2
- package/node/components/Stepper/StepButton/StepButton.d.ts +7 -1
- package/node/components/Stepper/StepButton/StepButton.js +4 -2
- package/node/components/Stepper/StepButton/styles.d.ts +2 -1
- package/node/components/Stepper/StepIcon/StepIcon.d.ts +6 -2
- package/node/components/Stepper/StepIcon/StepIcon.js +11 -7
- package/node/components/Stepper/StepIcon/styles.js +1 -0
- package/node/components/Stepper/StepLabel/StepLabel.d.ts +7 -1
- package/node/components/Stepper/StepLabel/StepLabel.js +2 -2
- package/node/components/Stepper/constants.d.ts +1 -0
- package/node/components/Stepper/constants.js +1 -0
- package/node/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.d.ts +2 -0
- package/node/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.js +14 -0
- package/node/hook-form/FormFilters/AllFiltersButton/index.d.ts +1 -0
- package/node/hook-form/FormFilters/AllFiltersButton/index.js +5 -0
- package/node/hook-form/FormFilters/AllFiltersButton/styles.d.ts +19 -0
- package/node/hook-form/FormFilters/AllFiltersButton/styles.js +56 -0
- package/node/hook-form/FormFilters/AllFiltersButton/types.d.ts +8 -0
- package/node/hook-form/FormFilters/AllFiltersButton/types.js +2 -0
- package/node/hook-form/FormFilters/AllFiltersButton/useLogic/index.d.ts +1 -0
- package/node/hook-form/FormFilters/AllFiltersButton/useLogic/index.js +17 -0
- package/node/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.d.ts +6 -0
- package/node/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.js +37 -0
- package/node/hook-form/FormFilters/FormFilters.js +3 -4
- package/node/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.d.ts +1 -1
- package/node/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.js +4 -7
- package/node/hook-form/FormFilters/constants.d.ts +0 -1
- package/node/hook-form/FormFilters/constants.js +0 -1
- package/node/hook-form/FormFilters/styles.d.ts +0 -18
- package/node/hook-form/FormFilters/styles.js +1 -52
- package/node/hook-form/FormFilters/types.d.ts +7 -16
- package/node/hook-form/FormFilters/useLogic/useLogic.d.ts +5 -6
- package/node/hook-form/FormFilters/useLogic/useLogic.js +6 -94
- package/node/hook-form/FormFiltersSearchField/FormFiltersSearchField.js +1 -1
- package/package.json +1 -1
|
@@ -1,120 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { useWatch } from 'react-hook-form';
|
|
4
|
-
import { checkIsDeepEqual } from '../../../components/utils/checkIsDeepEqual';
|
|
5
|
-
import { classNames } from '../../../components/utils/classNames';
|
|
6
|
-
import { FORM_FILTERS_SEARCH_FIELD_ID } from '../../FormFiltersSearchField/constants';
|
|
7
|
-
import { useForm } from '../../useForm';
|
|
8
|
-
import { formFiltersClassnames } from '../constants';
|
|
9
|
-
import { useFirstMountAfterLoading } from './hooks';
|
|
10
|
-
export const useLogic = ({ validationSchema, values, onChange, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }) => {
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export const useLogic = ({ form, onSubmit, validationSchema, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }) => {
|
|
11
3
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
12
|
-
const isFirstMount = useFirstMountAfterLoading(isLoading);
|
|
13
4
|
const onOpenModal = () => {
|
|
14
5
|
setIsModalOpen(true);
|
|
15
6
|
};
|
|
16
|
-
const headerForm = useForm({
|
|
17
|
-
validationSchema,
|
|
18
|
-
defaultValues: values,
|
|
19
|
-
});
|
|
20
|
-
const headerFormValues = useWatch({
|
|
21
|
-
control: headerForm.control,
|
|
22
|
-
});
|
|
23
|
-
// Ref для хранения debounced функции, чтобы можно было её отменить
|
|
24
|
-
const debouncedOnChangeRef = useRef(null);
|
|
25
|
-
// Ref для отслеживания внешнего reset (чтобы не вызывать onChange при внешнем reset)
|
|
26
|
-
const isExternalResetRef = useRef(false);
|
|
27
|
-
// Ref для хранения предыдущих внешних values (для сравнения)
|
|
28
|
-
const previousValuesRef = useRef(values);
|
|
29
|
-
// Отменяет предыдущий debounced вызов onChange, если он есть
|
|
30
|
-
const clearPreviousDebouncedOnChange = () => {
|
|
31
|
-
if (debouncedOnChangeRef.current) {
|
|
32
|
-
debouncedOnChangeRef.current.clear();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const hasSubmitButton = Boolean(submitButton);
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
// Если есть submitButton, не вызываем onChange при изменении значений
|
|
38
|
-
if (hasSubmitButton || isLoading || isFirstMount) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
clearPreviousDebouncedOnChange();
|
|
42
|
-
// Пропускаем onChange если это внешний reset
|
|
43
|
-
if (isExternalResetRef.current) {
|
|
44
|
-
isExternalResetRef.current = false;
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// Создаем новый debounced вызов
|
|
48
|
-
const debouncedOnChange = debounce(() => {
|
|
49
|
-
onChange(headerFormValues);
|
|
50
|
-
}, 300);
|
|
51
|
-
debouncedOnChangeRef.current = debouncedOnChange;
|
|
52
|
-
debouncedOnChange();
|
|
53
|
-
return () => {
|
|
54
|
-
debouncedOnChange.clear();
|
|
55
|
-
};
|
|
56
|
-
}, [headerFormValues, onChange, hasSubmitButton, isLoading]);
|
|
57
|
-
const searchName = document
|
|
58
|
-
.getElementById(FORM_FILTERS_SEARCH_FIELD_ID)
|
|
59
|
-
?.getAttribute('name') || '';
|
|
60
|
-
// Исключаем поиск из счетчика фильтров
|
|
61
|
-
const counter = Object.values(headerFormValues).filter(Boolean).length -
|
|
62
|
-
(headerFormValues[searchName] ? 1 : 0);
|
|
63
|
-
const setFiltersValues = (newValues) => headerForm.reset(newValues);
|
|
64
|
-
// Функция отправки формы на SubmitButton. Приводит к вызову onChange без debounce.
|
|
65
|
-
const onSubmit = (submittedValues) => {
|
|
66
|
-
clearPreviousDebouncedOnChange();
|
|
67
|
-
onChange?.(submittedValues);
|
|
68
|
-
};
|
|
69
7
|
// Функция отправки формы на кнопку "Применить" в модальном окне
|
|
70
8
|
const onSubmitModal = (submittedValues) => {
|
|
71
|
-
|
|
72
|
-
onSubmit(submittedValues);
|
|
9
|
+
form.reset(submittedValues);
|
|
73
10
|
};
|
|
74
|
-
// Синхронизация внешних values с формой
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
if (isFirstMount) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// Сравниваем значения, чтобы избежать лишних reset
|
|
80
|
-
const valuesChanged = !checkIsDeepEqual(previousValuesRef.current, values);
|
|
81
|
-
if (!valuesChanged) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
clearPreviousDebouncedOnChange();
|
|
85
|
-
isExternalResetRef.current = true;
|
|
86
|
-
previousValuesRef.current = values;
|
|
87
|
-
setFiltersValues(values);
|
|
88
|
-
}, [values, headerForm]);
|
|
89
|
-
const allFiltersButtonClassName = useMemo(() => {
|
|
90
|
-
return classNames({
|
|
91
|
-
[formFiltersClassnames.showAllFiltersButtonOnDesktop]: Boolean(secondaryFilters),
|
|
92
|
-
[formFiltersClassnames.showAllFiltersButtonOnMobile]: Boolean(mainFilters) || Boolean(secondaryFilters),
|
|
93
|
-
[formFiltersClassnames.withSearch]: Boolean(searchField),
|
|
94
|
-
[formFiltersClassnames.withoutSearch]: !searchField,
|
|
95
|
-
});
|
|
96
|
-
}, [mainFilters, secondaryFilters, searchField]);
|
|
97
11
|
const dialogProps = {
|
|
98
12
|
validationSchema,
|
|
99
|
-
|
|
13
|
+
form,
|
|
100
14
|
mainFilters,
|
|
101
15
|
secondaryFilters,
|
|
102
|
-
defaultValues: headerFormValues,
|
|
103
16
|
onSubmit: onSubmitModal,
|
|
104
17
|
isModalOpen,
|
|
105
18
|
setIsModalOpen,
|
|
106
19
|
};
|
|
107
20
|
return {
|
|
108
|
-
|
|
21
|
+
form,
|
|
22
|
+
onSubmit,
|
|
109
23
|
searchField,
|
|
110
24
|
mainFilters,
|
|
25
|
+
secondaryFilters,
|
|
111
26
|
submitButton,
|
|
112
|
-
counter,
|
|
113
|
-
onSubmit,
|
|
114
27
|
onOpenModal,
|
|
115
28
|
dialogProps,
|
|
116
29
|
mainFiltersColumns,
|
|
117
30
|
isLoading,
|
|
118
|
-
allFiltersButtonClassName,
|
|
119
31
|
};
|
|
120
32
|
};
|
|
@@ -12,6 +12,6 @@ function FormFiltersSearchFieldInner({ width, ...props }, ref) {
|
|
|
12
12
|
...props,
|
|
13
13
|
defaultValue: props.defaultValue || '',
|
|
14
14
|
});
|
|
15
|
-
return (_jsx(Wrapper, { "$width": width, children: _jsx(SearchField, { ...fieldProps, ref: ref, inputProps: { id: FORM_FILTERS_SEARCH_FIELD_ID } }) }));
|
|
15
|
+
return (_jsx(Wrapper, { "$width": width, children: _jsx(SearchField, { ...fieldProps, ref: ref, inputProps: { id: FORM_FILTERS_SEARCH_FIELD_ID }, fullWidth: true }) }));
|
|
16
16
|
}
|
|
17
17
|
export const FormFiltersSearchField = forwardRefWithGeneric(FormFiltersSearchFieldInner);
|
|
@@ -17,5 +17,5 @@ exports.Filename = (0, react_1.forwardRef)((props, forwardedRef) => {
|
|
|
17
17
|
const hidePersonalDataClassname = (0, personalDataSecurity_1.useHidePersonalData)({
|
|
18
18
|
isEnabled: isHidePersonalData,
|
|
19
19
|
});
|
|
20
|
-
return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: isOverflowed && children, disableInteractive: true, ...tooltipProps, className: (0, classNames_1.classNames)(tooltipProps?.className, hidePersonalDataClassname), children: (0, jsx_runtime_1.jsxs)(styles_1.StyledTypography, { "$align": align, variant: variant, className: (0, classNames_1.classNames)(className, hidePersonalDataClassname), ...restProps, children: [(0, jsx_runtime_1.jsx)(styles_1.FileBaseName, { ...baseNameProps }), (0, jsx_runtime_1.jsx)(
|
|
20
|
+
return ((0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: isOverflowed && children, disableInteractive: true, ...tooltipProps, className: (0, classNames_1.classNames)(tooltipProps?.className, hidePersonalDataClassname), children: (0, jsx_runtime_1.jsxs)(styles_1.StyledTypography, { "$align": align, variant: variant, className: (0, classNames_1.classNames)(className, hidePersonalDataClassname), ...restProps, children: [(0, jsx_runtime_1.jsx)(styles_1.FileBaseName, { ...baseNameProps }), (0, jsx_runtime_1.jsx)(styles_1.FileSuffix, { children: suffixWithExtension })] }) }));
|
|
21
21
|
});
|
|
@@ -3,6 +3,10 @@ export declare const FileBaseName: import("@emotion/styled/dist/declarations/src
|
|
|
3
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
4
4
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
5
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
6
|
+
export declare const FileSuffix: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
7
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
8
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
9
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
6
10
|
export declare const StyledTypography: import("@emotion/styled/dist/declarations/src/types").StyledComponent<import("../Typography/types").TypographyPropsBase & {
|
|
7
11
|
color?: import("../Typography").TypographyColor | undefined;
|
|
8
12
|
variant?: import("../Typography").TypographyVariant | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StyledTypography = exports.FileBaseName = void 0;
|
|
3
|
+
exports.StyledTypography = exports.FileSuffix = exports.FileBaseName = void 0;
|
|
4
4
|
const styled_1 = require("../styled");
|
|
5
5
|
const Typography_1 = require("../Typography");
|
|
6
6
|
exports.FileBaseName = styled_1.styled.span `
|
|
@@ -9,7 +9,10 @@ exports.FileBaseName = styled_1.styled.span `
|
|
|
9
9
|
max-width: 100%;
|
|
10
10
|
|
|
11
11
|
text-overflow: ellipsis;
|
|
12
|
-
white-space: nowrap;
|
|
12
|
+
white-space: preserve nowrap;
|
|
13
|
+
`;
|
|
14
|
+
exports.FileSuffix = styled_1.styled.span `
|
|
15
|
+
white-space: pre;
|
|
13
16
|
`;
|
|
14
17
|
exports.StyledTypography = (0, styled_1.styled)(Typography_1.Typography, {
|
|
15
18
|
shouldForwardProp: (prop) => !['$align'].includes(prop),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { StepLabelProps as MuiStepLabelProps } from '@mui/material/StepLabel';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
2
3
|
import type { WithoutEmotionSpecific } from '../../types/WithoutEmotionSpecific';
|
|
4
|
+
import { type StepIconProps } from '../StepIcon';
|
|
3
5
|
export type StepButtonProps = {
|
|
4
6
|
/**
|
|
5
7
|
* Если true, текущий шаг будет отображен как активный
|
|
@@ -9,5 +11,9 @@ export type StepButtonProps = {
|
|
|
9
11
|
* Функция, вызываемая при клике на элемент
|
|
10
12
|
*/
|
|
11
13
|
onClick: () => void;
|
|
12
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Кастомный компонент иконки
|
|
16
|
+
*/
|
|
17
|
+
icon?: (props: Omit<StepIconProps, 'icon'>) => ReactNode;
|
|
18
|
+
} & Omit<WithoutEmotionSpecific<MuiStepLabelProps>, 'icon'>;
|
|
13
19
|
export declare const StepButton: (props: StepButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,8 +7,10 @@ const constants_1 = require("../constants");
|
|
|
7
7
|
const StepIcon_1 = require("../StepIcon");
|
|
8
8
|
const styles_1 = require("./styles");
|
|
9
9
|
const StepButton = (props) => {
|
|
10
|
-
const { isSelected, onClick, ...restProps } = props;
|
|
11
|
-
const stepIconRender = (0, react_1.useCallback)(({ active, completed, error
|
|
10
|
+
const { isSelected, onClick, icon: Icon, ...restProps } = props;
|
|
11
|
+
const stepIconRender = (0, react_1.useCallback)(({ active, completed, error }) => {
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(StepIcon_1.StepIcon, { icon: Icon, isSelected: isSelected, active: active, completed: completed, error: error }));
|
|
13
|
+
}, [isSelected, Icon]);
|
|
12
14
|
return ((0, jsx_runtime_1.jsx)(styles_1.Button, { onClick: onClick, tabIndex: 1, className: constants_1.stepperClassnames.stepButton, children: (0, jsx_runtime_1.jsx)(styles_1.StyledStepLabel, { StepIconComponent: stepIconRender, ...restProps }) }));
|
|
13
15
|
};
|
|
14
16
|
exports.StepButton = StepButton;
|
|
@@ -5,6 +5,7 @@ export declare const Button: import("@emotion/styled/dist/declarations/src/types
|
|
|
5
5
|
}, import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {}>;
|
|
6
6
|
export declare const StyledStepLabel: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
7
7
|
isSelected?: boolean | undefined;
|
|
8
|
-
|
|
8
|
+
icon?: ((props: Omit<import("../StepIcon").StepIconProps, "icon">) => import("react").ReactNode) | undefined;
|
|
9
|
+
} & Omit<import("../..").WithoutEmotionSpecific<import("@mui/material/StepLabel").StepLabelProps>, "icon"> & {
|
|
9
10
|
theme?: import("@emotion/react").Theme | undefined;
|
|
10
11
|
}, {}, {}>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { StepIconProps as MuiStepIconProps } from '@mui/material/StepIcon';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
3
|
import { type WithoutEmotionSpecific } from '../../types/WithoutEmotionSpecific';
|
|
4
4
|
export type StepIconProps = {
|
|
5
5
|
/**
|
|
6
6
|
* Является ли шаг в состоянии select
|
|
7
7
|
*/
|
|
8
8
|
isSelected?: boolean;
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Кастомный компонент иконки
|
|
11
|
+
*/
|
|
12
|
+
icon?: (props: Omit<StepIconProps, 'icon'>) => ReactNode;
|
|
13
|
+
} & Omit<WithoutEmotionSpecific<MuiStepIconProps>, 'icon'>;
|
|
10
14
|
export declare const StepIcon: import("react").MemoExoticComponent<(props: StepIconProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -3,23 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StepIcon = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
const styles_1 = require("./styles");
|
|
7
8
|
exports.StepIcon = (0, react_1.memo)((props) => {
|
|
8
|
-
const { active, completed, error, isSelected } = props;
|
|
9
|
+
const { active, completed, error, isSelected, icon: Icon } = props;
|
|
10
|
+
if (Icon) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(Icon, { active: active, completed: completed, error: error, isSelected: isSelected, className: constants_1.stepperClassnames.stepIcon }));
|
|
12
|
+
}
|
|
9
13
|
if (completed && error && isSelected) {
|
|
10
|
-
return (0, jsx_runtime_1.jsx)(styles_1.SelectIcon, { "$isError": true });
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(styles_1.SelectIcon, { "$isError": true, className: constants_1.stepperClassnames.stepIcon });
|
|
11
15
|
}
|
|
12
16
|
if (completed && isSelected) {
|
|
13
|
-
return (0, jsx_runtime_1.jsx)(styles_1.SelectIcon, {});
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(styles_1.SelectIcon, { className: constants_1.stepperClassnames.stepIcon });
|
|
14
18
|
}
|
|
15
19
|
if (error) {
|
|
16
|
-
return (0, jsx_runtime_1.jsx)(styles_1.ErrorIcon, {});
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(styles_1.ErrorIcon, { className: constants_1.stepperClassnames.stepIcon });
|
|
17
21
|
}
|
|
18
22
|
if (completed) {
|
|
19
|
-
return (0, jsx_runtime_1.jsx)(styles_1.SuccessIcon, {});
|
|
23
|
+
return (0, jsx_runtime_1.jsx)(styles_1.SuccessIcon, { className: constants_1.stepperClassnames.stepIcon });
|
|
20
24
|
}
|
|
21
25
|
if (active) {
|
|
22
|
-
return (0, jsx_runtime_1.jsx)(styles_1.ActiveIcon, {
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(styles_1.ActiveIcon, { className: constants_1.stepperClassnames.stepIcon });
|
|
23
27
|
}
|
|
24
|
-
return (0, jsx_runtime_1.jsx)(styles_1.DefaultIcon, {});
|
|
28
|
+
return (0, jsx_runtime_1.jsx)(styles_1.DefaultIcon, { className: constants_1.stepperClassnames.stepIcon });
|
|
25
29
|
});
|
|
@@ -32,4 +32,5 @@ exports.DefaultIcon = (0, styled_1.styled)(StepDefaultFillMd_1.StepDefaultFillMd
|
|
|
32
32
|
`;
|
|
33
33
|
exports.ActiveIcon = (0, styled_1.styled)(StepDefaultFillMd_1.StepDefaultFillMd) `
|
|
34
34
|
${({ theme }) => iconsSize(theme)};
|
|
35
|
+
color: ${({ theme }) => theme.palette.primary[800]};
|
|
35
36
|
`;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { StepLabelProps as MuiStepLabelProps } from '@mui/material/StepLabel';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
2
3
|
import { type WithoutEmotionSpecific } from '../../types/WithoutEmotionSpecific';
|
|
4
|
+
import { type StepIconProps } from '../StepIcon';
|
|
3
5
|
export type StepProps = {
|
|
4
6
|
/**
|
|
5
7
|
* Является ли шаг в состоянии select
|
|
6
8
|
*/
|
|
7
9
|
isSelected?: boolean;
|
|
8
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Кастомный компонент иконки
|
|
12
|
+
*/
|
|
13
|
+
icon?: (props: Omit<StepIconProps, 'icon'>) => ReactNode;
|
|
14
|
+
} & Omit<WithoutEmotionSpecific<MuiStepLabelProps>, 'icon'>;
|
|
9
15
|
export declare const StepLabel: (props: StepProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,8 +9,8 @@ const StepLabel_1 = __importDefault(require("@mui/material/StepLabel"));
|
|
|
9
9
|
const react_1 = require("react");
|
|
10
10
|
const StepIcon_1 = require("../StepIcon");
|
|
11
11
|
const StepLabel = (props) => {
|
|
12
|
-
const { isSelected, ...restProps } = props;
|
|
13
|
-
const stepIconRender = (0, react_1.useCallback)(({ active, completed, error
|
|
12
|
+
const { isSelected, icon: Icon, ...restProps } = props;
|
|
13
|
+
const stepIconRender = (0, react_1.useCallback)(({ active, completed, error }) => ((0, jsx_runtime_1.jsx)(StepIcon_1.StepIcon, { icon: Icon, isSelected: isSelected, active: active, completed: completed, error: error })), [isSelected]);
|
|
14
14
|
return (0, jsx_runtime_1.jsx)(StepLabel_1.default, { StepIconComponent: stepIconRender, ...restProps });
|
|
15
15
|
};
|
|
16
16
|
exports.StepLabel = StepLabel;
|
|
@@ -4,4 +4,5 @@ exports.stepperClassnames = void 0;
|
|
|
4
4
|
const createUIKitClassname_1 = require("../utils/createUIKitClassname");
|
|
5
5
|
exports.stepperClassnames = {
|
|
6
6
|
stepButton: (0, createUIKitClassname_1.createUIKitClassname)('stepper_stepButton'),
|
|
7
|
+
stepIcon: (0, createUIKitClassname_1.createUIKitClassname)('stepper_stepIcon'),
|
|
7
8
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllFiltersButton = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Button_1 = require("../../../components/Button");
|
|
6
|
+
const Filter2OutlineMd_1 = require("../../../icons/Filter2OutlineMd");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const styles_1 = require("./styles");
|
|
9
|
+
const useLogic_1 = require("./useLogic");
|
|
10
|
+
const AllFiltersButton = (props) => {
|
|
11
|
+
const { allFiltersButtonClassName, counter, onOpenModal } = (0, useLogic_1.useLogic)(props);
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.AllFiltersButtonWrapper, { className: allFiltersButtonClassName, children: (0, jsx_runtime_1.jsx)(styles_1.StyledBadge, { color: "error", badgeContent: counter, variant: "dot", children: (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onOpenModal, variant: "outlined", color: "grey", startIcon: (0, jsx_runtime_1.jsx)(Filter2OutlineMd_1.Filter2OutlineMd, {}), endIcon: counter ? (0, jsx_runtime_1.jsx)(styles_1.StyledCounter, { color: "error", content: counter }) : null, className: constants_1.formFiltersClassnames.allFiltersButton, children: "\u0412\u0441\u0435 \u0444\u0438\u043B\u044C\u0442\u0440\u044B" }) }) }));
|
|
13
|
+
};
|
|
14
|
+
exports.AllFiltersButton = AllFiltersButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AllFiltersButton } from './AllFiltersButton';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllFiltersButton = void 0;
|
|
4
|
+
var AllFiltersButton_1 = require("./AllFiltersButton");
|
|
5
|
+
Object.defineProperty(exports, "AllFiltersButton", { enumerable: true, get: function () { return AllFiltersButton_1.AllFiltersButton; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const AllFiltersButtonWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
export declare const StyledBadge: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../..").WithoutEmotionSpecific<import("@mui/material/Badge").BadgeProps>, "color"> & {
|
|
7
|
+
color: import("../../../components/Badge").BadgeColor;
|
|
8
|
+
withBorder?: boolean | undefined;
|
|
9
|
+
variantColor?: import("../../../components/Badge").BadgeVariantsColor | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
12
|
+
}, {}, {}>;
|
|
13
|
+
export declare const StyledCounter: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../..").WithoutEmotionSpecific<import("@mui/material/Badge").BadgeProps>, "content" | "color" | "children" | "variant" | "invisible" | "anchorOrigin" | "badgeContent" | "overlap" | "withBorder"> & {
|
|
14
|
+
color: import("../../../components/Counter/types").CounterColor;
|
|
15
|
+
variant?: import("../../../components/Counter/types").CounterVariants | undefined;
|
|
16
|
+
content?: number | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
19
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StyledCounter = exports.StyledBadge = exports.AllFiltersButtonWrapper = void 0;
|
|
4
|
+
const Badge_1 = require("@mui/material/Badge");
|
|
5
|
+
const Badge_2 = require("../../../components/Badge");
|
|
6
|
+
const Counter_1 = require("../../../components/Counter");
|
|
7
|
+
const styled_1 = require("../../../components/styled");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
exports.AllFiltersButtonWrapper = styled_1.styled.div `
|
|
10
|
+
display: none;
|
|
11
|
+
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
|
|
14
|
+
&.${constants_1.formFiltersClassnames.showAllFiltersButtonOnDesktop} {
|
|
15
|
+
display: flex;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
19
|
+
margin-right: 0;
|
|
20
|
+
&.${constants_1.formFiltersClassnames.showAllFiltersButtonOnMobile} {
|
|
21
|
+
display: flex;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.${constants_1.formFiltersClassnames.withoutSearch} {
|
|
25
|
+
width: 100%;
|
|
26
|
+
|
|
27
|
+
.${constants_1.formFiltersClassnames.allFiltersButton} {
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.${constants_1.formFiltersClassnames.withSearch} {
|
|
33
|
+
.${constants_1.formFiltersClassnames.allFiltersButton} {
|
|
34
|
+
display: unset;
|
|
35
|
+
gap: 0;
|
|
36
|
+
|
|
37
|
+
padding: 8px;
|
|
38
|
+
|
|
39
|
+
font-size: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
exports.StyledBadge = (0, styled_1.styled)(Badge_2.Badge) `
|
|
45
|
+
width: 100%;
|
|
46
|
+
.${Badge_1.badgeClasses.dot} {
|
|
47
|
+
${({ theme }) => theme.breakpoints.up('sm')} {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
exports.StyledCounter = (0, styled_1.styled)(Counter_1.Counter) `
|
|
53
|
+
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UseFormReturn } from 'react-hook-form';
|
|
2
|
+
export type AllFiltersButtonProps<TFieldValues extends Record<string, unknown>> = {
|
|
3
|
+
form: UseFormReturn<TFieldValues>;
|
|
4
|
+
onOpenModal: () => void;
|
|
5
|
+
hasMainFilters: boolean;
|
|
6
|
+
hasSecondaryFilters: boolean;
|
|
7
|
+
hasSearch: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useLogic"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AllFiltersButtonProps } from '../types';
|
|
2
|
+
export declare const useLogic: <TFieldValues extends Record<string, unknown>>({ form, onOpenModal, hasMainFilters, hasSecondaryFilters, hasSearch, }: AllFiltersButtonProps<TFieldValues>) => {
|
|
3
|
+
allFiltersButtonClassName: string;
|
|
4
|
+
counter: number;
|
|
5
|
+
onOpenModal: () => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogic = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
6
|
+
const classNames_1 = require("../../../../components/utils/classNames");
|
|
7
|
+
const constants_1 = require("../../../FormFiltersSearchField/constants");
|
|
8
|
+
const constants_2 = require("../../constants");
|
|
9
|
+
const useLogic = ({ form, onOpenModal, hasMainFilters, hasSecondaryFilters, hasSearch, }) => {
|
|
10
|
+
const formValues = (0, react_hook_form_1.useWatch)({
|
|
11
|
+
control: form.control,
|
|
12
|
+
});
|
|
13
|
+
const [searchName, setSearchName] = (0, react_1.useState)('');
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const searchFieldName = document
|
|
16
|
+
.getElementById(constants_1.FORM_FILTERS_SEARCH_FIELD_ID)
|
|
17
|
+
?.getAttribute('name') || '';
|
|
18
|
+
setSearchName(searchFieldName);
|
|
19
|
+
}, [hasSearch]);
|
|
20
|
+
// Исключаем поиск из счетчика фильтров
|
|
21
|
+
const counter = Object.values(formValues || {}).filter(Boolean).length -
|
|
22
|
+
(formValues?.[searchName] ? 1 : 0);
|
|
23
|
+
const allFiltersButtonClassName = (0, react_1.useMemo)(() => {
|
|
24
|
+
return (0, classNames_1.classNames)({
|
|
25
|
+
[constants_2.formFiltersClassnames.showAllFiltersButtonOnDesktop]: hasSecondaryFilters,
|
|
26
|
+
[constants_2.formFiltersClassnames.showAllFiltersButtonOnMobile]: hasMainFilters || hasSecondaryFilters,
|
|
27
|
+
[constants_2.formFiltersClassnames.withSearch]: hasSearch,
|
|
28
|
+
[constants_2.formFiltersClassnames.withoutSearch]: !hasSearch,
|
|
29
|
+
});
|
|
30
|
+
}, [hasMainFilters, hasSecondaryFilters, hasSearch]);
|
|
31
|
+
return {
|
|
32
|
+
allFiltersButtonClassName,
|
|
33
|
+
counter,
|
|
34
|
+
onOpenModal,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.useLogic = useLogic;
|
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormFilters = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const Button_1 = require("../../components/Button");
|
|
6
|
-
const Filter2OutlineMd_1 = require("../../icons/Filter2OutlineMd");
|
|
7
5
|
const Form_1 = require("../Form");
|
|
8
6
|
const FormControlProvider_1 = require("../FormControlProvider");
|
|
7
|
+
const AllFiltersButton_1 = require("./AllFiltersButton");
|
|
9
8
|
const constants_1 = require("./constants");
|
|
10
9
|
const FormFiltersDialog_1 = require("./FormFiltersDialog");
|
|
11
10
|
const FormFiltersSkeleton_1 = require("./FormFiltersSkeleton");
|
|
@@ -15,10 +14,10 @@ const useLogic_1 = require("./useLogic");
|
|
|
15
14
|
* Компонент для отображения фильтров формы
|
|
16
15
|
*/
|
|
17
16
|
const FormFilters = (props) => {
|
|
18
|
-
const {
|
|
17
|
+
const { form, onSubmit, searchField: SearchField, mainFilters: MainFilters, submitButton: SubmitButton, secondaryFilters: SecondaryFilters, onOpenModal, dialogProps, mainFiltersColumns, isLoading, } = (0, useLogic_1.useLogic)(props);
|
|
19
18
|
if (isLoading) {
|
|
20
19
|
return (0, jsx_runtime_1.jsx)(FormFiltersSkeleton_1.FormFiltersSkeleton, {});
|
|
21
20
|
}
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(Form_1.Form, { name: "form", form: form, onSubmit: form.handleSubmit(onSubmit || (() => undefined)), children: [(0, jsx_runtime_1.jsx)(FormControlProvider_1.FormControlProvider, { size: "small", hideHelperText: true, children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [SearchField && (0, jsx_runtime_1.jsx)(SearchField, { control: form.control }), (0, jsx_runtime_1.jsx)(AllFiltersButton_1.AllFiltersButton, { form: form, onOpenModal: onOpenModal, hasMainFilters: Boolean(MainFilters), hasSecondaryFilters: Boolean(SecondaryFilters), hasSearch: Boolean(SearchField) }), (0, jsx_runtime_1.jsx)(styles_1.MainFiltersWrapper, { columns: mainFiltersColumns, children: MainFilters && ((0, jsx_runtime_1.jsx)(MainFilters, { control: form.control, isModal: false })) }), SubmitButton && ((0, jsx_runtime_1.jsx)(styles_1.SubmitButtonWrapper, { children: (0, jsx_runtime_1.jsx)(SubmitButton, { size: "medium", className: constants_1.formFiltersClassnames.submitButton }) }))] }) }), (0, jsx_runtime_1.jsx)(FormFiltersDialog_1.FormFiltersDialog, { ...dialogProps })] }));
|
|
23
22
|
};
|
|
24
23
|
exports.FormFilters = FormFilters;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type FormFiltersDialogProps } from '../types';
|
|
3
|
-
export declare const useLogic: <TFieldValues extends Record<string, unknown>>({ validationSchema,
|
|
3
|
+
export declare const useLogic: <TFieldValues extends Record<string, unknown>>({ validationSchema, mainFilters, secondaryFilters, isModalOpen, setIsModalOpen, onSubmit, form, }: FormFiltersDialogProps<TFieldValues>) => {
|
|
4
4
|
modalForm: import("react-hook-form").UseFormReturn<TFieldValues, any>;
|
|
5
5
|
onCloseModal: () => void;
|
|
6
6
|
onResetModal: () => void;
|
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useForm_1 = require("../../../useForm");
|
|
6
|
-
const useLogic = ({ validationSchema,
|
|
6
|
+
const useLogic = ({ validationSchema, mainFilters, secondaryFilters, isModalOpen, setIsModalOpen, onSubmit, form, }) => {
|
|
7
7
|
const modalForm = (0, useForm_1.useForm)({
|
|
8
8
|
validationSchema,
|
|
9
|
-
defaultValues:
|
|
9
|
+
defaultValues: form.getValues(),
|
|
10
10
|
});
|
|
11
11
|
const onCloseModal = () => {
|
|
12
12
|
setIsModalOpen(false);
|
|
13
13
|
modalForm.reset();
|
|
14
14
|
};
|
|
15
15
|
const onResetModal = () => {
|
|
16
|
-
modalForm.reset(
|
|
16
|
+
modalForm.reset(form.getValues());
|
|
17
17
|
};
|
|
18
18
|
const onSubmitModal = (submittedValues) => {
|
|
19
19
|
onSubmit(submittedValues);
|
|
@@ -21,13 +21,10 @@ const useLogic = ({ validationSchema, values, mainFilters, secondaryFilters, isM
|
|
|
21
21
|
};
|
|
22
22
|
const isResetButtonDisabled = !modalForm.formState.isDirty;
|
|
23
23
|
(0, react_1.useEffect)(() => {
|
|
24
|
-
if (isModalOpen
|
|
24
|
+
if (isModalOpen) {
|
|
25
25
|
onResetModal();
|
|
26
26
|
}
|
|
27
27
|
}, [isModalOpen]);
|
|
28
|
-
(0, react_1.useEffect)(() => {
|
|
29
|
-
modalForm.reset(values);
|
|
30
|
-
}, [values]);
|
|
31
28
|
return {
|
|
32
29
|
modalForm,
|
|
33
30
|
onCloseModal,
|
|
@@ -4,7 +4,6 @@ exports.formFiltersClassnames = void 0;
|
|
|
4
4
|
const createUIKitClassname_1 = require("../../components/utils/createUIKitClassname");
|
|
5
5
|
exports.formFiltersClassnames = {
|
|
6
6
|
modalFilters: (0, createUIKitClassname_1.createUIKitClassname)('form-filters__modal-filters'),
|
|
7
|
-
pageHeaderFilters: (0, createUIKitClassname_1.createUIKitClassname)('form-filters__page-header-filters'),
|
|
8
7
|
submitButton: (0, createUIKitClassname_1.createUIKitClassname)('form-filters__submit-button'),
|
|
9
8
|
allFiltersButton: (0, createUIKitClassname_1.createUIKitClassname)('form-filters__all-filters-button'),
|
|
10
9
|
showAllFiltersButtonOnDesktop: (0, createUIKitClassname_1.createUIKitClassname)('form-filters_show-all-filters-button_desktop'),
|