@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.
Files changed (73) hide show
  1. package/components/Filename/Filename.js +2 -2
  2. package/components/Filename/styles.d.ts +4 -0
  3. package/components/Filename/styles.js +4 -1
  4. package/components/Stepper/StepButton/StepButton.d.ts +7 -1
  5. package/components/Stepper/StepButton/StepButton.js +4 -2
  6. package/components/Stepper/StepButton/styles.d.ts +2 -1
  7. package/components/Stepper/StepIcon/StepIcon.d.ts +6 -2
  8. package/components/Stepper/StepIcon/StepIcon.js +11 -7
  9. package/components/Stepper/StepIcon/styles.js +1 -0
  10. package/components/Stepper/StepLabel/StepLabel.d.ts +7 -1
  11. package/components/Stepper/StepLabel/StepLabel.js +2 -2
  12. package/components/Stepper/constants.d.ts +1 -0
  13. package/components/Stepper/constants.js +1 -0
  14. package/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.d.ts +2 -0
  15. package/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.js +10 -0
  16. package/hook-form/FormFilters/AllFiltersButton/index.d.ts +1 -0
  17. package/hook-form/FormFilters/AllFiltersButton/index.js +1 -0
  18. package/hook-form/FormFilters/AllFiltersButton/styles.d.ts +19 -0
  19. package/hook-form/FormFilters/AllFiltersButton/styles.js +53 -0
  20. package/hook-form/FormFilters/AllFiltersButton/types.d.ts +8 -0
  21. package/hook-form/FormFilters/AllFiltersButton/types.js +1 -0
  22. package/hook-form/FormFilters/AllFiltersButton/useLogic/index.d.ts +1 -0
  23. package/hook-form/FormFilters/AllFiltersButton/useLogic/index.js +1 -0
  24. package/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.d.ts +6 -0
  25. package/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.js +33 -0
  26. package/hook-form/FormFilters/FormFilters.js +5 -6
  27. package/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.d.ts +1 -1
  28. package/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.js +4 -7
  29. package/hook-form/FormFilters/constants.d.ts +0 -1
  30. package/hook-form/FormFilters/constants.js +0 -1
  31. package/hook-form/FormFilters/styles.d.ts +0 -18
  32. package/hook-form/FormFilters/styles.js +0 -51
  33. package/hook-form/FormFilters/types.d.ts +7 -16
  34. package/hook-form/FormFilters/useLogic/useLogic.d.ts +5 -6
  35. package/hook-form/FormFilters/useLogic/useLogic.js +7 -95
  36. package/hook-form/FormFiltersSearchField/FormFiltersSearchField.js +1 -1
  37. package/node/components/Filename/Filename.js +1 -1
  38. package/node/components/Filename/styles.d.ts +4 -0
  39. package/node/components/Filename/styles.js +5 -2
  40. package/node/components/Stepper/StepButton/StepButton.d.ts +7 -1
  41. package/node/components/Stepper/StepButton/StepButton.js +4 -2
  42. package/node/components/Stepper/StepButton/styles.d.ts +2 -1
  43. package/node/components/Stepper/StepIcon/StepIcon.d.ts +6 -2
  44. package/node/components/Stepper/StepIcon/StepIcon.js +11 -7
  45. package/node/components/Stepper/StepIcon/styles.js +1 -0
  46. package/node/components/Stepper/StepLabel/StepLabel.d.ts +7 -1
  47. package/node/components/Stepper/StepLabel/StepLabel.js +2 -2
  48. package/node/components/Stepper/constants.d.ts +1 -0
  49. package/node/components/Stepper/constants.js +1 -0
  50. package/node/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.d.ts +2 -0
  51. package/node/hook-form/FormFilters/AllFiltersButton/AllFiltersButton.js +14 -0
  52. package/node/hook-form/FormFilters/AllFiltersButton/index.d.ts +1 -0
  53. package/node/hook-form/FormFilters/AllFiltersButton/index.js +5 -0
  54. package/node/hook-form/FormFilters/AllFiltersButton/styles.d.ts +19 -0
  55. package/node/hook-form/FormFilters/AllFiltersButton/styles.js +56 -0
  56. package/node/hook-form/FormFilters/AllFiltersButton/types.d.ts +8 -0
  57. package/node/hook-form/FormFilters/AllFiltersButton/types.js +2 -0
  58. package/node/hook-form/FormFilters/AllFiltersButton/useLogic/index.d.ts +1 -0
  59. package/node/hook-form/FormFilters/AllFiltersButton/useLogic/index.js +17 -0
  60. package/node/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.d.ts +6 -0
  61. package/node/hook-form/FormFilters/AllFiltersButton/useLogic/useLogic.js +37 -0
  62. package/node/hook-form/FormFilters/FormFilters.js +3 -4
  63. package/node/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.d.ts +1 -1
  64. package/node/hook-form/FormFilters/FormFiltersDialog/useLogic/useLogic.js +4 -7
  65. package/node/hook-form/FormFilters/constants.d.ts +0 -1
  66. package/node/hook-form/FormFilters/constants.js +0 -1
  67. package/node/hook-form/FormFilters/styles.d.ts +0 -18
  68. package/node/hook-form/FormFilters/styles.js +1 -52
  69. package/node/hook-form/FormFilters/types.d.ts +7 -16
  70. package/node/hook-form/FormFilters/useLogic/useLogic.d.ts +5 -6
  71. package/node/hook-form/FormFilters/useLogic/useLogic.js +6 -94
  72. package/node/hook-form/FormFiltersSearchField/FormFiltersSearchField.js +1 -1
  73. package/package.json +1 -1
@@ -3,30 +3,12 @@ export declare const Wrapper: import("@emotion/styled/dist/declarations/src/type
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<HTMLDivElement>, HTMLDivElement>, {}>;
6
- export declare const AllFiltersButtonWrapper: 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<HTMLDivElement>, HTMLDivElement>, {}>;
10
6
  export declare const MainFiltersWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
11
7
  theme?: import("@emotion/react").Theme | undefined;
12
8
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
13
9
  } & {
14
10
  columns?: string | undefined;
15
11
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
16
- export declare const StyledBadge: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../..").WithoutEmotionSpecific<import("@mui/material/Badge").BadgeProps>, "color"> & {
17
- color: import("../../components/Badge").BadgeColor;
18
- withBorder?: boolean | undefined;
19
- variantColor?: import("../../components/Badge").BadgeVariantsColor | undefined;
20
- } & {
21
- theme?: import("@emotion/react").Theme | undefined;
22
- }, {}, {}>;
23
- 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"> & {
24
- color: import("../../components/Counter/types").CounterColor;
25
- variant?: import("../../components/Counter/types").CounterVariants | undefined;
26
- content?: number | undefined;
27
- } & {
28
- theme?: import("@emotion/react").Theme | undefined;
29
- }, {}, {}>;
30
12
  export declare const SubmitButtonWrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
31
13
  theme?: import("@emotion/react").Theme | undefined;
32
14
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubmitButtonWrapper = exports.StyledCounter = exports.StyledBadge = exports.MainFiltersWrapper = exports.AllFiltersButtonWrapper = exports.Wrapper = void 0;
4
- const Badge_1 = require("@mui/material/Badge");
3
+ exports.SubmitButtonWrapper = exports.MainFiltersWrapper = exports.Wrapper = void 0;
5
4
  const FormLabel_1 = require("@mui/material/FormLabel");
6
5
  const InputBase_1 = require("@mui/material/InputBase");
7
- const Badge_2 = require("../../components/Badge");
8
- const Counter_1 = require("../../components/Counter");
9
6
  const styled_1 = require("../../components/styled");
10
7
  const constants_1 = require("./constants");
11
8
  exports.Wrapper = styled_1.styled.div `
@@ -35,41 +32,6 @@ exports.Wrapper = styled_1.styled.div `
35
32
  }
36
33
  }
37
34
  `;
38
- exports.AllFiltersButtonWrapper = styled_1.styled.div `
39
- display: none;
40
-
41
- white-space: nowrap;
42
-
43
- &.${constants_1.formFiltersClassnames.showAllFiltersButtonOnDesktop} {
44
- display: flex;
45
- }
46
-
47
- ${({ theme }) => theme.breakpoints.down('sm')} {
48
- margin-right: 0;
49
- &.${constants_1.formFiltersClassnames.showAllFiltersButtonOnMobile} {
50
- display: flex;
51
- }
52
-
53
- &.${constants_1.formFiltersClassnames.withoutSearch} {
54
- width: 100%;
55
-
56
- .${constants_1.formFiltersClassnames.allFiltersButton} {
57
- width: 100%;
58
- }
59
- }
60
-
61
- &.${constants_1.formFiltersClassnames.withSearch} {
62
- .${constants_1.formFiltersClassnames.allFiltersButton} {
63
- display: unset;
64
- gap: 0;
65
-
66
- padding: 8px;
67
-
68
- font-size: 0;
69
- }
70
- }
71
- }
72
- `;
73
35
  exports.MainFiltersWrapper = styled_1.styled.div `
74
36
  display: grid;
75
37
  grid-auto-flow: column;
@@ -82,19 +44,6 @@ exports.MainFiltersWrapper = styled_1.styled.div `
82
44
  display: none;
83
45
  }
84
46
  `;
85
- exports.StyledBadge = (0, styled_1.styled)(Badge_2.Badge) `
86
- width: 100%;
87
- .${Badge_1.badgeClasses.dot} {
88
- ${({ theme }) => theme.breakpoints.up('sm')} {
89
- display: none;
90
- }
91
- }
92
- `;
93
- exports.StyledCounter = (0, styled_1.styled)(Counter_1.Counter) `
94
- ${({ theme }) => theme.breakpoints.down('sm')} {
95
- display: none;
96
- }
97
- `;
98
47
  exports.SubmitButtonWrapper = styled_1.styled.div `
99
48
  white-space: nowrap;
100
49
 
@@ -1,45 +1,36 @@
1
1
  import { type ObjectAsyncGuard, type ObjectGuard } from '@astral/validations';
2
2
  import { type ReactNode } from 'react';
3
- import { type Control } from 'react-hook-form';
3
+ import { type Control, type UseFormReturn } from 'react-hook-form';
4
4
  import type { ButtonProps } from '../../components/Button';
5
5
  type InputsProps<TFieldValues extends Record<string, unknown>> = {
6
6
  control: Control<TFieldValues>;
7
7
  };
8
8
  export type FormFiltersProps<TFieldValues extends Record<string, unknown>> = {
9
+ form: UseFormReturn<TFieldValues>;
10
+ onSubmit?: (values: TFieldValues) => void;
9
11
  /**
10
12
  * Схема валидации из @astral/validations
11
13
  */
12
14
  validationSchema?: ObjectGuard<TFieldValues> | ObjectAsyncGuard<TFieldValues>;
13
- /**
14
- * Значения фильтров
15
- */
16
- values?: TFieldValues;
17
- /**
18
- * Callback вызываемый при изменении значений фильтров. Вызывается с debounce (300ms)
19
- */
20
- onChange: (values: TFieldValues) => void;
21
15
  /**
22
16
  * Поле поиска
23
17
  *
24
18
  * @example
25
19
  * ```ts
26
20
  * <FormFilters
27
- * SearchField={(props) => <FormFiltersSearchField {...props} placeholder="Поиск..." />}
21
+ * SearchField={({control}) => <FormFiltersSearchField control={control} placeholder="Поиск..." />}
28
22
  * />
29
23
  * ```
30
24
  */
31
- searchField?: (props: InputsProps<TFieldValues> & {
32
- fullWidth?: boolean;
33
- }) => ReactNode;
25
+ searchField?: (props: InputsProps<TFieldValues>) => ReactNode;
34
26
  /**
35
27
  * Основные фильтры
36
28
  *
37
29
  * @example
38
30
  * ```ts
39
31
  * <FormFilters
40
- * MainFilters={({ control, isModal, ...props }) =>
32
+ * MainFilters={({ control, isModal }) =>
41
33
  * <FormTextField
42
- * {...props}
43
34
  * control={control}
44
35
  * name="name"
45
36
  * label="Название"
@@ -57,7 +48,7 @@ export type FormFiltersProps<TFieldValues extends Record<string, unknown>> = {
57
48
  * @example
58
49
  * ```ts
59
50
  * <FormFilters
60
- * SecondaryFilters={({ control, ...props }) => <FormTextField {...props} control={control} placeholder="Введите название" />}
51
+ * SecondaryFilters={({ control }) => <FormTextField control={control} name="name" label="Название" placeholder="Введите название" />}
61
52
  * />
62
53
  * ```
63
54
  */
@@ -1,18 +1,17 @@
1
- import { type UseFormReturn } from '../../useForm';
1
+ import { type UseFormReturn } from 'react-hook-form';
2
2
  import { type FormFiltersDialogProps } from '../FormFiltersDialog/types';
3
3
  import { type FormFiltersProps } from '../types';
4
4
  type UseLogicReturn<TFieldValues extends Record<string, unknown>> = {
5
- headerForm: UseFormReturn<TFieldValues>;
5
+ form: UseFormReturn<TFieldValues>;
6
+ onSubmit?: (values: TFieldValues) => void;
6
7
  searchField: FormFiltersProps<TFieldValues>['searchField'];
7
8
  mainFilters: FormFiltersProps<TFieldValues>['mainFilters'];
8
9
  submitButton: FormFiltersProps<TFieldValues>['submitButton'];
9
- counter: number;
10
- onSubmit: (submittedValues: TFieldValues) => void;
10
+ secondaryFilters: FormFiltersProps<TFieldValues>['secondaryFilters'];
11
11
  onOpenModal: () => void;
12
12
  dialogProps: FormFiltersDialogProps<TFieldValues>;
13
13
  mainFiltersColumns?: string;
14
14
  isLoading?: boolean;
15
- allFiltersButtonClassName: string;
16
15
  };
17
- export declare const useLogic: <TFieldValues extends Record<string, unknown>>({ validationSchema, values, onChange, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }: FormFiltersProps<TFieldValues>) => UseLogicReturn<TFieldValues>;
16
+ export declare const useLogic: <TFieldValues extends Record<string, unknown>>({ form, onSubmit, validationSchema, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }: FormFiltersProps<TFieldValues>) => UseLogicReturn<TFieldValues>;
18
17
  export {};
@@ -1,124 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
- const debounce_1 = require("@astral/utils/debounce");
5
4
  const react_1 = require("react");
6
- const react_hook_form_1 = require("react-hook-form");
7
- const checkIsDeepEqual_1 = require("../../../components/utils/checkIsDeepEqual");
8
- const classNames_1 = require("../../../components/utils/classNames");
9
- const constants_1 = require("../../FormFiltersSearchField/constants");
10
- const useForm_1 = require("../../useForm");
11
- const constants_2 = require("../constants");
12
- const hooks_1 = require("./hooks");
13
- const useLogic = ({ validationSchema, values, onChange, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }) => {
5
+ const useLogic = ({ form, onSubmit, validationSchema, searchField, mainFilters, secondaryFilters, submitButton, mainFiltersColumns, isLoading, }) => {
14
6
  const [isModalOpen, setIsModalOpen] = (0, react_1.useState)(false);
15
- const isFirstMount = (0, hooks_1.useFirstMountAfterLoading)(isLoading);
16
7
  const onOpenModal = () => {
17
8
  setIsModalOpen(true);
18
9
  };
19
- const headerForm = (0, useForm_1.useForm)({
20
- validationSchema,
21
- defaultValues: values,
22
- });
23
- const headerFormValues = (0, react_hook_form_1.useWatch)({
24
- control: headerForm.control,
25
- });
26
- // Ref для хранения debounced функции, чтобы можно было её отменить
27
- const debouncedOnChangeRef = (0, react_1.useRef)(null);
28
- // Ref для отслеживания внешнего reset (чтобы не вызывать onChange при внешнем reset)
29
- const isExternalResetRef = (0, react_1.useRef)(false);
30
- // Ref для хранения предыдущих внешних values (для сравнения)
31
- const previousValuesRef = (0, react_1.useRef)(values);
32
- // Отменяет предыдущий debounced вызов onChange, если он есть
33
- const clearPreviousDebouncedOnChange = () => {
34
- if (debouncedOnChangeRef.current) {
35
- debouncedOnChangeRef.current.clear();
36
- }
37
- };
38
- const hasSubmitButton = Boolean(submitButton);
39
- (0, react_1.useEffect)(() => {
40
- // Если есть submitButton, не вызываем onChange при изменении значений
41
- if (hasSubmitButton || isLoading || isFirstMount) {
42
- return;
43
- }
44
- clearPreviousDebouncedOnChange();
45
- // Пропускаем onChange если это внешний reset
46
- if (isExternalResetRef.current) {
47
- isExternalResetRef.current = false;
48
- return;
49
- }
50
- // Создаем новый debounced вызов
51
- const debouncedOnChange = (0, debounce_1.debounce)(() => {
52
- onChange(headerFormValues);
53
- }, 300);
54
- debouncedOnChangeRef.current = debouncedOnChange;
55
- debouncedOnChange();
56
- return () => {
57
- debouncedOnChange.clear();
58
- };
59
- }, [headerFormValues, onChange, hasSubmitButton, isLoading]);
60
- const searchName = document
61
- .getElementById(constants_1.FORM_FILTERS_SEARCH_FIELD_ID)
62
- ?.getAttribute('name') || '';
63
- // Исключаем поиск из счетчика фильтров
64
- const counter = Object.values(headerFormValues).filter(Boolean).length -
65
- (headerFormValues[searchName] ? 1 : 0);
66
- const setFiltersValues = (newValues) => headerForm.reset(newValues);
67
- // Функция отправки формы на SubmitButton. Приводит к вызову onChange без debounce.
68
- const onSubmit = (submittedValues) => {
69
- clearPreviousDebouncedOnChange();
70
- onChange?.(submittedValues);
71
- };
72
10
  // Функция отправки формы на кнопку "Применить" в модальном окне
73
11
  const onSubmitModal = (submittedValues) => {
74
- setFiltersValues(submittedValues);
75
- onSubmit(submittedValues);
12
+ form.reset(submittedValues);
76
13
  };
77
- // Синхронизация внешних values с формой
78
- (0, react_1.useEffect)(() => {
79
- if (isFirstMount) {
80
- return;
81
- }
82
- // Сравниваем значения, чтобы избежать лишних reset
83
- const valuesChanged = !(0, checkIsDeepEqual_1.checkIsDeepEqual)(previousValuesRef.current, values);
84
- if (!valuesChanged) {
85
- return;
86
- }
87
- clearPreviousDebouncedOnChange();
88
- isExternalResetRef.current = true;
89
- previousValuesRef.current = values;
90
- setFiltersValues(values);
91
- }, [values, headerForm]);
92
- const allFiltersButtonClassName = (0, react_1.useMemo)(() => {
93
- return (0, classNames_1.classNames)({
94
- [constants_2.formFiltersClassnames.showAllFiltersButtonOnDesktop]: Boolean(secondaryFilters),
95
- [constants_2.formFiltersClassnames.showAllFiltersButtonOnMobile]: Boolean(mainFilters) || Boolean(secondaryFilters),
96
- [constants_2.formFiltersClassnames.withSearch]: Boolean(searchField),
97
- [constants_2.formFiltersClassnames.withoutSearch]: !searchField,
98
- });
99
- }, [mainFilters, secondaryFilters, searchField]);
100
14
  const dialogProps = {
101
15
  validationSchema,
102
- values,
16
+ form,
103
17
  mainFilters,
104
18
  secondaryFilters,
105
- defaultValues: headerFormValues,
106
19
  onSubmit: onSubmitModal,
107
20
  isModalOpen,
108
21
  setIsModalOpen,
109
22
  };
110
23
  return {
111
- headerForm,
24
+ form,
25
+ onSubmit,
112
26
  searchField,
113
27
  mainFilters,
28
+ secondaryFilters,
114
29
  submitButton,
115
- counter,
116
- onSubmit,
117
30
  onOpenModal,
118
31
  dialogProps,
119
32
  mainFiltersColumns,
120
33
  isLoading,
121
- allFiltersButtonClassName,
122
34
  };
123
35
  };
124
36
  exports.useLogic = useLogic;
@@ -15,6 +15,6 @@ function FormFiltersSearchFieldInner({ width, ...props }, ref) {
15
15
  ...props,
16
16
  defaultValue: props.defaultValue || '',
17
17
  });
18
- return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$width": width, children: (0, jsx_runtime_1.jsx)(SearchField_1.SearchField, { ...fieldProps, ref: ref, inputProps: { id: constants_1.FORM_FILTERS_SEARCH_FIELD_ID } }) }));
18
+ return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$width": width, children: (0, jsx_runtime_1.jsx)(SearchField_1.SearchField, { ...fieldProps, ref: ref, inputProps: { id: constants_1.FORM_FILTERS_SEARCH_FIELD_ID }, fullWidth: true }) }));
19
19
  }
20
20
  exports.FormFiltersSearchField = (0, forwardRefWithGeneric_1.forwardRefWithGeneric)(FormFiltersSearchFieldInner);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.29.0",
3
+ "version": "4.31.0",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {