@astral/ui 4.0.0-alpha.34 → 4.0.0-alpha.35
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/AddressAutocomplete/AddressAutocomplete.d.ts +2 -2
- package/components/AsyncAutocomplete/useLogic/useLogic.d.ts +2 -0
- package/components/AsyncAutocomplete/useLogic/useLogic.js +2 -1
- package/components/Autocomplete/Autocomplete.d.ts +8 -0
- package/components/Autocomplete/Autocomplete.js +7 -3
- package/components/CheckboxField/styles.d.ts +1 -0
- package/components/CheckboxField/styles.js +2 -2
- package/components/CodeField/styles.d.ts +1 -0
- package/components/DashboardLayout/Sidebar/Sidebar.js +2 -2
- package/components/DashboardLayout/Sidebar/styles.d.ts +6 -0
- package/components/DashboardLayout/Sidebar/styles.js +15 -8
- package/components/DatePicker/DatePicker.d.ts +8 -0
- package/components/DatePicker/DatePicker.js +2 -2
- package/components/DatePicker/styles.d.ts +1 -0
- package/components/DateRangePicker/DateRangePicker.js +3 -3
- package/components/DateRangePicker/styles.d.ts +1 -0
- package/components/EmailOrPhoneField/useLogic/useLogic.d.ts +1 -0
- package/components/FormHelperText/FormHelperText.d.ts +2 -1
- package/components/FormHelperText/FormHelperText.js +4 -1
- package/components/PageLayout/PageHeader/HeaderContent/styles.js +1 -1
- package/components/PageLayout/PageLayoutContainer/PageLayoutContainer.js +2 -2
- package/components/PageLayout/PageLayoutContainer/styles.d.ts +6 -0
- package/components/PageLayout/PageLayoutContainer/styles.js +8 -2
- package/components/Paper/Paper.d.ts +5 -1
- package/components/Paper/Paper.js +15 -3
- package/components/Paper/styles.d.ts +15 -0
- package/components/Paper/styles.js +9 -0
- package/components/SearchField/useLogic/useLogic.d.ts +1 -0
- package/components/Select/Select.d.ts +2 -2
- package/components/Select/Select.js +1 -1
- package/components/Select/styles.js +1 -1
- package/components/TextField/TextField.d.ts +5 -2
- package/components/TextField/TextField.js +9 -4
- package/components/TextField/constants.d.ts +3 -0
- package/components/TextField/constants.js +4 -0
- package/components/TextField/styles.d.ts +5 -0
- package/components/TextField/styles.js +16 -0
- package/components/TreeAutocomplete/OptionsModal/OptionsModal.js +2 -2
- package/components/TreeLikeAutocomplete/OptionsModal/OptionsModal.js +2 -2
- package/components/theme/components/MuiAutocomplete.js +21 -3
- package/components/theme/components/MuiFormHelperText.js +1 -1
- package/hook-form/EditableText/EditingForm/useLogic/useLogic.js +1 -1
- package/hook-form/hooks/useForm/index.d.ts +1 -0
- package/hook-form/hooks/useForm/types.d.ts +23 -0
- package/hook-form/hooks/useForm/types.js +1 -0
- package/hook-form/hooks/useForm/useForm.d.ts +3 -31
- package/hook-form/hooks/useForm/useForm.js +6 -3
- package/hook-form/hooks/useFormFieldErrorProps/useFormFieldErrorProps.d.ts +1 -2
- package/hook-form/hooks/useFormFieldProps/useFormFieldProps.d.ts +9 -13
- package/hook-form/hooks/useFormFieldProps/useFormFieldProps.js +3 -3
- package/hook-form/hooks/useFormInputProps/useFormInputProps.d.ts +1 -1
- package/hook-form/hooks/useFormWizard/useFormWizard.js +1 -4
- package/hook-form/index.d.ts +1 -0
- package/hook-form/index.js +1 -0
- package/hook-form/react-hook-form-resolver/index.d.ts +1 -0
- package/hook-form/react-hook-form-resolver/index.js +1 -0
- package/hook-form/react-hook-form-resolver/resolver/index.d.ts +1 -0
- package/hook-form/react-hook-form-resolver/resolver/index.js +1 -0
- package/hook-form/react-hook-form-resolver/resolver/resolver.d.ts +40 -0
- package/hook-form/react-hook-form-resolver/resolver/resolver.js +69 -0
- package/hook-form/react-hook-form-resolver/utils/index.d.ts +1 -0
- package/hook-form/react-hook-form-resolver/utils/index.js +1 -0
- package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/index.d.ts +1 -0
- package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/index.js +1 -0
- package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.d.ts +5 -0
- package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.js +24 -0
- package/node/components/AddressAutocomplete/AddressAutocomplete.d.ts +2 -2
- package/node/components/AsyncAutocomplete/useLogic/useLogic.d.ts +2 -0
- package/node/components/AsyncAutocomplete/useLogic/useLogic.js +2 -1
- package/node/components/Autocomplete/Autocomplete.d.ts +8 -0
- package/node/components/Autocomplete/Autocomplete.js +7 -3
- package/node/components/CheckboxField/styles.d.ts +1 -0
- package/node/components/CheckboxField/styles.js +2 -2
- package/node/components/CodeField/styles.d.ts +1 -0
- package/node/components/DashboardLayout/Sidebar/Sidebar.js +1 -1
- package/node/components/DashboardLayout/Sidebar/styles.d.ts +6 -0
- package/node/components/DashboardLayout/Sidebar/styles.js +16 -9
- package/node/components/DatePicker/DatePicker.d.ts +8 -0
- package/node/components/DatePicker/DatePicker.js +2 -2
- package/node/components/DatePicker/styles.d.ts +1 -0
- package/node/components/DateRangePicker/DateRangePicker.js +3 -3
- package/node/components/DateRangePicker/styles.d.ts +1 -0
- package/node/components/EmailOrPhoneField/useLogic/useLogic.d.ts +1 -0
- package/node/components/FormHelperText/FormHelperText.d.ts +2 -1
- package/node/components/FormHelperText/FormHelperText.js +4 -1
- package/node/components/PageLayout/PageHeader/HeaderContent/styles.js +1 -1
- package/node/components/PageLayout/PageLayoutContainer/PageLayoutContainer.js +1 -1
- package/node/components/PageLayout/PageLayoutContainer/styles.d.ts +6 -0
- package/node/components/PageLayout/PageLayoutContainer/styles.js +9 -3
- package/node/components/Paper/Paper.d.ts +5 -1
- package/node/components/Paper/Paper.js +15 -3
- package/node/components/Paper/styles.d.ts +15 -0
- package/node/components/Paper/styles.js +12 -0
- package/node/components/SearchField/useLogic/useLogic.d.ts +1 -0
- package/node/components/Select/Select.d.ts +2 -2
- package/node/components/Select/Select.js +1 -1
- package/node/components/Select/styles.js +1 -1
- package/node/components/TextField/TextField.d.ts +5 -2
- package/node/components/TextField/TextField.js +9 -4
- package/node/components/TextField/constants.d.ts +3 -0
- package/node/components/TextField/constants.js +7 -0
- package/node/components/TextField/styles.d.ts +5 -0
- package/node/components/TextField/styles.js +19 -0
- package/node/components/TreeAutocomplete/OptionsModal/OptionsModal.js +2 -2
- package/node/components/TreeLikeAutocomplete/OptionsModal/OptionsModal.js +2 -2
- package/node/components/theme/components/MuiAutocomplete.js +21 -3
- package/node/components/theme/components/MuiFormHelperText.js +1 -1
- package/node/hook-form/EditableText/EditingForm/useLogic/useLogic.js +1 -1
- package/node/hook-form/hooks/useForm/index.d.ts +1 -0
- package/node/hook-form/hooks/useForm/types.d.ts +23 -0
- package/node/hook-form/hooks/useForm/types.js +2 -0
- package/node/hook-form/hooks/useForm/useForm.d.ts +3 -31
- package/node/hook-form/hooks/useForm/useForm.js +5 -2
- package/node/hook-form/hooks/useFormFieldErrorProps/useFormFieldErrorProps.d.ts +1 -2
- package/node/hook-form/hooks/useFormFieldProps/useFormFieldProps.d.ts +9 -13
- package/node/hook-form/hooks/useFormInputProps/useFormInputProps.d.ts +1 -1
- package/node/hook-form/hooks/useFormWizard/useFormWizard.js +1 -4
- package/node/hook-form/index.d.ts +1 -0
- package/node/hook-form/index.js +3 -1
- package/node/hook-form/react-hook-form-resolver/index.d.ts +1 -0
- package/node/hook-form/react-hook-form-resolver/index.js +5 -0
- package/node/hook-form/react-hook-form-resolver/resolver/index.d.ts +1 -0
- package/node/{components/ScrollWrapper → hook-form/react-hook-form-resolver/resolver}/index.js +1 -1
- package/node/hook-form/react-hook-form-resolver/resolver/resolver.d.ts +40 -0
- package/node/hook-form/react-hook-form-resolver/resolver/resolver.js +73 -0
- package/node/hook-form/react-hook-form-resolver/utils/index.d.ts +1 -0
- package/node/hook-form/react-hook-form-resolver/utils/index.js +17 -0
- package/node/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/index.d.ts +1 -0
- package/node/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/index.js +17 -0
- package/node/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.d.ts +5 -0
- package/node/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.js +28 -0
- package/package.json +5 -3
- package/components/ScrollWrapper/ScrollWrapper.d.ts +0 -7
- package/components/ScrollWrapper/ScrollWrapper.js +0 -3
- package/components/ScrollWrapper/index.d.ts +0 -1
- package/components/ScrollWrapper/index.js +0 -1
- package/components/ScrollWrapper/styles.d.ts +0 -7
- package/components/ScrollWrapper/styles.js +0 -7
- package/node/components/ScrollWrapper/ScrollWrapper.d.ts +0 -7
- package/node/components/ScrollWrapper/ScrollWrapper.js +0 -7
- package/node/components/ScrollWrapper/index.d.ts +0 -1
- package/node/components/ScrollWrapper/styles.d.ts +0 -7
- package/node/components/ScrollWrapper/styles.js +0 -10
|
@@ -13,7 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { Button } from '../../Button';
|
|
14
14
|
import { Dialog } from '../../Dialog';
|
|
15
15
|
import { DialogActions } from '../../DialogActions';
|
|
16
|
-
import {
|
|
16
|
+
import { Paper } from '../../Paper';
|
|
17
17
|
import { SearchField } from '../../SearchField';
|
|
18
18
|
import { TreeLikeList } from '../../TreeLikeList';
|
|
19
19
|
import { ErrorMessage } from './ErrorMessage';
|
|
@@ -36,5 +36,5 @@ export const OptionsModal = (props) => {
|
|
|
36
36
|
}
|
|
37
37
|
return (_jsx(TreeLikeList, Object.assign({ isConfirmChildrenSelection: isConfirmChildrenSelection }, treeProps, treeLikeListProps)));
|
|
38
38
|
};
|
|
39
|
-
return (_jsxs(Dialog, Object.assign({}, externalDialogProps, { disableRestoreFocus: true, open: isOpen }, modalProps, { children: [_jsxs(StyledDialogContent, { children: [_jsx(SearchField, Object.assign({ fullWidth: true }, searchFieldProps)), _jsx(
|
|
39
|
+
return (_jsxs(Dialog, Object.assign({}, externalDialogProps, { disableRestoreFocus: true, open: isOpen }, modalProps, { children: [_jsxs(StyledDialogContent, { children: [_jsx(SearchField, Object.assign({ fullWidth: true }, searchFieldProps)), _jsx(Paper, { variant: "outlined", children: _jsx(TreeListWrapper, { children: renderComponent() }) })] }), _jsxs(DialogActions, { children: [_jsx(Button, Object.assign({ variant: "text" }, cancelButtonProps, { children: "\u041E\u0442\u043C\u0435\u043D\u0430" })), _jsx(Button, Object.assign({}, confirmButtonProps, { children: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C" }))] })] })));
|
|
40
40
|
};
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
+
import { autocompleteClasses } from '@mui/material';
|
|
1
2
|
import { AutocompleteSizes } from '../../Autocomplete/enums';
|
|
2
3
|
export const MuiAutocomplete = {
|
|
3
4
|
styleOverrides: {
|
|
5
|
+
root({ theme }) {
|
|
6
|
+
return {
|
|
7
|
+
[`&.${autocompleteClasses.hasPopupIcon}.${autocompleteClasses.hasClearIcon}`]: {
|
|
8
|
+
[`.${autocompleteClasses.inputRoot}`]: {
|
|
9
|
+
paddingRight: `${theme.spacing(14)}`,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
},
|
|
4
14
|
inputRoot({ theme, ownerState: { size } }) {
|
|
5
15
|
return {
|
|
6
16
|
paddingTop: `${theme.spacing(1)} !important`,
|
|
7
17
|
paddingBottom: `${theme.spacing(1)} !important`,
|
|
8
|
-
paddingLeft: `${theme.spacing(
|
|
18
|
+
paddingLeft: `${theme.spacing(3)} !important`,
|
|
9
19
|
minHeight: size === AutocompleteSizes.small ? '32px' : '40px',
|
|
10
20
|
};
|
|
11
21
|
},
|
|
12
|
-
input(
|
|
22
|
+
input() {
|
|
13
23
|
return {
|
|
14
24
|
padding: '0 !important',
|
|
15
|
-
paddingLeft: `${theme.spacing(1)} !important`,
|
|
16
25
|
};
|
|
17
26
|
},
|
|
18
27
|
popupIndicator({ theme }) {
|
|
@@ -28,6 +37,7 @@ export const MuiAutocomplete = {
|
|
|
28
37
|
top: 'unset',
|
|
29
38
|
gap: theme.spacing(1),
|
|
30
39
|
color: theme.palette.grey[800],
|
|
40
|
+
marginRight: `${theme.spacing(1)} !important`,
|
|
31
41
|
};
|
|
32
42
|
},
|
|
33
43
|
paper({ theme }) {
|
|
@@ -59,5 +69,13 @@ export const MuiAutocomplete = {
|
|
|
59
69
|
height: '64px',
|
|
60
70
|
};
|
|
61
71
|
},
|
|
72
|
+
tagSizeMedium({ theme }) {
|
|
73
|
+
return {
|
|
74
|
+
margin: `${theme.microSpacing(0, 1)}`,
|
|
75
|
+
':first-of-type': {
|
|
76
|
+
marginLeft: 0,
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
},
|
|
62
80
|
},
|
|
63
81
|
};
|
|
@@ -3,8 +3,8 @@ export const MuiFormHelperText = {
|
|
|
3
3
|
root({ theme }) {
|
|
4
4
|
return {
|
|
5
5
|
display: 'flex',
|
|
6
|
-
minHeight: theme.typography.caption.lineHeight,
|
|
7
6
|
fontSize: theme.typography.caption.fontSize,
|
|
7
|
+
minHeight: theme.typography.caption.lineHeight,
|
|
8
8
|
margin: theme.spacing(1, 0, 0),
|
|
9
9
|
color: theme.palette.grey[600],
|
|
10
10
|
lineHeight: theme.typography.caption.lineHeight,
|
|
@@ -22,7 +22,7 @@ export const useLogic = ({ initialValue, children, validate, onClose, onSubmit,
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
|
-
values:
|
|
25
|
+
values: {},
|
|
26
26
|
errors: {
|
|
27
27
|
[FIELD_NAME]: {
|
|
28
28
|
message: validationResult === null || validationResult === void 0 ? void 0 : validationResult.message,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ObjectAsyncGuard, ObjectGuard } from '@astral/validations';
|
|
2
|
+
import type { UseFormProps as UseFormPropsRHForm, UseFormReturn } from 'react-hook-form';
|
|
3
|
+
import type { FieldValues } from '../../types';
|
|
4
|
+
export type UseFormProps<TFieldValues extends FieldValues = FieldValues, TContext = any> = UseFormPropsRHForm<TFieldValues, TContext> & {
|
|
5
|
+
/**
|
|
6
|
+
* Схема валидации из @astral/validations
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const validationSchema = object<FormValues>({
|
|
11
|
+
* lastName: string(),
|
|
12
|
+
* name: string(),
|
|
13
|
+
* patronymic: optional(string()),
|
|
14
|
+
* phone: string(mobilePhone()),
|
|
15
|
+
* email: string(email()),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const form = useForm<FormValues>({ validationSchema });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
validationSchema?: ObjectGuard<TFieldValues> | ObjectAsyncGuard<TFieldValues>;
|
|
22
|
+
};
|
|
23
|
+
export type { UseFormReturn };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { FieldValues } from '../../types';
|
|
2
|
+
import type { UseFormProps, UseFormReturn } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Custom hook to manage the entire form.
|
|
5
5
|
*
|
|
@@ -29,32 +29,4 @@ import { type FieldValues } from '../../types';
|
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
export declare const useForm: <TFieldValues extends FieldValues = FieldValues, TContext = any>({ mode, ...params }?:
|
|
33
|
-
mode: "all" | "onChange" | "onBlur" | "onSubmit" | "onTouched";
|
|
34
|
-
disabled: boolean;
|
|
35
|
-
reValidateMode: "onChange" | "onBlur" | "onSubmit";
|
|
36
|
-
defaultValues: ((payload?: unknown) => Promise<TFieldValues>) | import("react-hook-form").DefaultValues<TFieldValues>;
|
|
37
|
-
values: TFieldValues;
|
|
38
|
-
errors: import("react-hook-form").FieldErrors<TFieldValues>;
|
|
39
|
-
resetOptions: Partial<{
|
|
40
|
-
keepDirtyValues: boolean;
|
|
41
|
-
keepErrors: boolean;
|
|
42
|
-
keepDirty: boolean;
|
|
43
|
-
keepValues: boolean;
|
|
44
|
-
keepDefaultValues: boolean;
|
|
45
|
-
keepIsSubmitted: boolean;
|
|
46
|
-
keepIsSubmitSuccessful: boolean;
|
|
47
|
-
keepTouched: boolean;
|
|
48
|
-
keepIsValid: boolean;
|
|
49
|
-
keepSubmitCount: boolean;
|
|
50
|
-
}> | undefined;
|
|
51
|
-
resolver: import("react-hook-form").Resolver<TFieldValues, TContext>;
|
|
52
|
-
context: TContext;
|
|
53
|
-
shouldFocusError: boolean;
|
|
54
|
-
shouldUnregister: boolean;
|
|
55
|
-
shouldUseNativeValidation: boolean;
|
|
56
|
-
progressive: boolean;
|
|
57
|
-
criteriaMode: import("react-hook-form").CriteriaMode;
|
|
58
|
-
delayError: number;
|
|
59
|
-
}>) => UseFormReturn<TFieldValues, TContext>;
|
|
60
|
-
export type { UseFormProps, UseFormReturn };
|
|
32
|
+
export declare const useForm: <TFieldValues extends FieldValues = FieldValues, TContext = any>({ mode, validationSchema, resolver: propsResolver, ...params }?: UseFormProps<TFieldValues, TContext>) => UseFormReturn<TFieldValues, TContext>;
|
|
@@ -9,7 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { useForm as useRHForm
|
|
12
|
+
import { useForm as useRHForm } from 'react-hook-form';
|
|
13
|
+
import { resolver as hookFormResolver } from '../../react-hook-form-resolver';
|
|
13
14
|
/**
|
|
14
15
|
* Custom hook to manage the entire form.
|
|
15
16
|
*
|
|
@@ -40,6 +41,8 @@ import { useForm as useRHForm, } from 'react-hook-form';
|
|
|
40
41
|
* ```
|
|
41
42
|
*/
|
|
42
43
|
export const useForm = (_a = {}) => {
|
|
43
|
-
var { mode = 'onBlur' } = _a, params = __rest(_a, ["mode"]);
|
|
44
|
-
|
|
44
|
+
var { mode = 'onBlur', validationSchema, resolver: propsResolver } = _a, params = __rest(_a, ["mode", "validationSchema", "resolver"]);
|
|
45
|
+
const resolver = propsResolver !== null && propsResolver !== void 0 ? propsResolver : (validationSchema && hookFormResolver(validationSchema));
|
|
46
|
+
return useRHForm(Object.assign(Object.assign({}, params), { resolver,
|
|
47
|
+
mode }));
|
|
45
48
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type ControllerFieldState } from 'react-hook-form';
|
|
2
2
|
import { type TextFieldProps } from '../../../components/TextField';
|
|
3
|
-
type UseFormFieldErrorPropsReturn = Pick<TextFieldProps, 'error' | 'helperText'>;
|
|
3
|
+
export type UseFormFieldErrorPropsReturn = Pick<TextFieldProps, 'error' | 'helperText'>;
|
|
4
4
|
/**
|
|
5
5
|
* хук предназначен для предоставления пропсов для отображения ошибки field
|
|
6
6
|
*/
|
|
7
7
|
export declare const useFormFieldErrorProps: (fieldState: Pick<ControllerFieldState, 'error'>) => UseFormFieldErrorPropsReturn;
|
|
8
|
-
export {};
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type ControllerRenderProps, type Path } from 'react-hook-form';
|
|
2
3
|
import { type FieldValues, type WithFormFieldProps } from '../../types';
|
|
4
|
+
import { type UseFormFieldErrorPropsReturn } from '../useFormFieldErrorProps';
|
|
5
|
+
import { type UseFormInputReturn } from '../useFormInputProps';
|
|
3
6
|
export type UseFormFieldProps<TFormFieldProps extends object, TFieldValues extends FieldValues> = WithFormFieldProps<TFormFieldProps, TFieldValues>;
|
|
7
|
+
type UseFormFieldPropsReturn<TFormFieldProps extends object, TFieldValues extends FieldValues> = ControllerRenderProps<TFieldValues, Path<TFieldValues>> & UseFormInputReturn<UseFormFieldProps<TFormFieldProps, TFieldValues>, TFieldValues> & UseFormFieldErrorPropsReturn & {
|
|
8
|
+
inputRef: RefObject<HTMLInputElement>;
|
|
9
|
+
};
|
|
4
10
|
/**
|
|
5
11
|
* хук предназначен для получения пропсов при инициализации нового поля в RHF
|
|
6
12
|
*/
|
|
7
|
-
export declare const useFormFieldProps: <TFormFieldProps extends object, TFieldValues extends FieldValues>(props: UseFormFieldProps<TFormFieldProps, TFieldValues>) =>
|
|
8
|
-
|
|
9
|
-
onBlur: import("react-hook-form").Noop;
|
|
10
|
-
value: import("react-hook-form").PathValue<TFieldValues, import("react-hook-form").Path<TFieldValues>>;
|
|
11
|
-
disabled?: boolean | undefined;
|
|
12
|
-
name: import("react-hook-form").Path<TFieldValues>;
|
|
13
|
-
ref: import("react-hook-form").RefCallBack;
|
|
14
|
-
} & ("disabled" | Exclude<Exclude<Exclude<keyof TFormFieldProps, "error" | "name">, "error" | "name">, "defaultValue" | "name" | "control" | "shouldUnregister"> extends infer T extends keyof (Omit<UseFormFieldProps<TFormFieldProps, TFieldValues>, "error" | "name"> & Omit<import("react-hook-form").UseControllerProps<TFieldValues>, "rules">) ? { [P in T]: (Omit<UseFormFieldProps<TFormFieldProps, TFieldValues>, "error" | "name"> & Omit<import("react-hook-form").UseControllerProps<TFieldValues>, "rules">)[P]; } : never) & {
|
|
15
|
-
inputRef: import("react").RefObject<any>;
|
|
16
|
-
error?: boolean | undefined;
|
|
17
|
-
helperText?: import("react").ReactNode;
|
|
18
|
-
};
|
|
13
|
+
export declare const useFormFieldProps: <TFormFieldProps extends object, TFieldValues extends FieldValues>(props: UseFormFieldProps<TFormFieldProps, TFieldValues>) => UseFormFieldPropsReturn<TFormFieldProps, TFieldValues>;
|
|
14
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useController } from 'react-hook-form';
|
|
1
|
+
import { useController, } from 'react-hook-form';
|
|
2
2
|
import { useForwardedRef } from '../../../components/hooks';
|
|
3
|
-
import { useFormFieldErrorProps } from '../useFormFieldErrorProps';
|
|
4
|
-
import { useFormInputProps } from '../useFormInputProps';
|
|
3
|
+
import { useFormFieldErrorProps, } from '../useFormFieldErrorProps';
|
|
4
|
+
import { useFormInputProps, } from '../useFormInputProps';
|
|
5
5
|
/**
|
|
6
6
|
* хук предназначен для получения пропсов при инициализации нового поля в RHF
|
|
7
7
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FieldValues } from 'react-hook-form';
|
|
2
2
|
import { type WithFormFieldProps } from '../../types';
|
|
3
3
|
type UseFormInputProps<TFormFieldProps extends object, TFieldValues extends FieldValues> = WithFormFieldProps<TFormFieldProps, TFieldValues>;
|
|
4
|
-
type UseFormInputReturn<TFormFieldProps extends object, TFieldValues extends FieldValues> = Omit<UseFormInputProps<TFormFieldProps, TFieldValues>, 'control' | 'defaultValue' | 'name' | 'shouldUnregister'>;
|
|
4
|
+
export type UseFormInputReturn<TFormFieldProps extends object, TFieldValues extends FieldValues> = Omit<UseFormInputProps<TFormFieldProps, TFieldValues>, 'control' | 'defaultValue' | 'name' | 'shouldUnregister'>;
|
|
5
5
|
/**
|
|
6
6
|
* хук предназначен для получения props input'а без системных props RHF, таких как: control.
|
|
7
7
|
* Это необходимо для того, чтобы лишние props не попадали в DOM-дерево
|
|
@@ -9,7 +9,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import { resolver } from '@astral/validations-react-hook-form-resolver';
|
|
13
12
|
import { useContext, useMemo, useRef, useState } from 'react';
|
|
14
13
|
import { ConfigContext } from '../../../components/ConfigProvider';
|
|
15
14
|
import { useForm } from '../useForm';
|
|
@@ -47,9 +46,7 @@ export const useFormWizard = ({ initialStepId, defaultValues, isDisabled, steps,
|
|
|
47
46
|
const form = useForm({
|
|
48
47
|
defaultValues,
|
|
49
48
|
disabled: isDisabled,
|
|
50
|
-
|
|
51
|
-
? resolver(validationSchemaForStep)
|
|
52
|
-
: undefined,
|
|
49
|
+
validationSchema: validationSchemaForStep,
|
|
53
50
|
});
|
|
54
51
|
const indexStep = useMemo(() => currentStepId
|
|
55
52
|
? visibleSteps.findIndex((step) => Object.is(step.id, currentStepId))
|
package/hook-form/index.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ export { FormTreeLikeAutocomplete, type FormTreeLikeAutocompleteProps, type Form
|
|
|
28
28
|
export { FormWizard, type FormWizardProps, type WizardStep, type WizardStepId, } from './FormWizard';
|
|
29
29
|
export { FormPageLayout, type FormPageLayoutProps, FormWizardPageLayout, type FormWizardPageLayoutProps, formPageContentClassnames, formPageLayoutClassnames, } from './formLayouts';
|
|
30
30
|
export { type UseFormProps, type UseFormReturn, type UseFormWizardParams, type UseFormWizardResult, useForm, useFormContext, useFormFieldErrorProps, useFormFieldProps, useFormState, useFormWatchFields, useFormWizard, } from './hooks';
|
|
31
|
+
export { resolver as formValidationResolver } from './react-hook-form-resolver';
|
|
31
32
|
export * from './types';
|
package/hook-form/index.js
CHANGED
|
@@ -29,4 +29,5 @@ export { FormWizard, } from './FormWizard';
|
|
|
29
29
|
export { FormPageLayout, FormWizardPageLayout, formPageContentClassnames, formPageLayoutClassnames, } from './formLayouts';
|
|
30
30
|
// нельзя экспортить через * потому, что есть пересечение с export * from 'react-hook-form';
|
|
31
31
|
export { useForm, useFormContext, useFormFieldErrorProps, useFormFieldProps, useFormState, useFormWatchFields, useFormWizard, } from './hooks';
|
|
32
|
+
export { resolver as formValidationResolver } from './react-hook-form-resolver';
|
|
32
33
|
export * from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolver } from './resolver';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { resolver } from './resolver';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolver';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './resolver';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ObjectAsyncGuard, type ObjectGuard } from '@astral/validations';
|
|
2
|
+
import { type FieldValues, type Resolver } from 'react-hook-form';
|
|
3
|
+
/**
|
|
4
|
+
* Позволяет выполнять object или objectAsync валидацию для формы react-hook-form
|
|
5
|
+
* @param validateBySchema
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* type Values = { info: { name: string } };
|
|
9
|
+
*
|
|
10
|
+
* const validationSchema = object<Values>({
|
|
11
|
+
* info: object<Values['info']>({
|
|
12
|
+
* name: string(),
|
|
13
|
+
* }),
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const TestForm = () => {
|
|
17
|
+
* const { register, handleSubmit, formState } = useForm<Values>({
|
|
18
|
+
* resolver: resolver<Values>(validationSchema),
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <form onSubmit={handleSubmit(() => {})}>
|
|
23
|
+
* <input {...register('info.name')} />
|
|
24
|
+
* {formState.errors.info?.name && (
|
|
25
|
+
* <>
|
|
26
|
+
* <p>{formState.errors.info.name.message}</p>
|
|
27
|
+
* <p>{formState.errors.info.name.type}</p>
|
|
28
|
+
* </>
|
|
29
|
+
* )}
|
|
30
|
+
* <button type="submit">submit</button>
|
|
31
|
+
* </form>
|
|
32
|
+
* );
|
|
33
|
+
* };
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const resolver: <TFieldValues extends FieldValues = FieldValues>(validateBySchema: import("@astral/validations/core").IGuard<{}, {
|
|
37
|
+
isPartial?: boolean | undefined;
|
|
38
|
+
}> | import("@astral/validations/core").IAsyncGuard<{}, {
|
|
39
|
+
isPartial?: boolean | undefined;
|
|
40
|
+
}>) => Resolver<TFieldValues>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { toPlainError, } from '@astral/validations';
|
|
11
|
+
import { get, } from 'react-hook-form';
|
|
12
|
+
import { validateFieldsNatively } from '../utils';
|
|
13
|
+
/**
|
|
14
|
+
* Позволяет выполнять object или objectAsync валидацию для формы react-hook-form
|
|
15
|
+
* @param validateBySchema
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* type Values = { info: { name: string } };
|
|
19
|
+
*
|
|
20
|
+
* const validationSchema = object<Values>({
|
|
21
|
+
* info: object<Values['info']>({
|
|
22
|
+
* name: string(),
|
|
23
|
+
* }),
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const TestForm = () => {
|
|
27
|
+
* const { register, handleSubmit, formState } = useForm<Values>({
|
|
28
|
+
* resolver: resolver<Values>(validationSchema),
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <form onSubmit={handleSubmit(() => {})}>
|
|
33
|
+
* <input {...register('info.name')} />
|
|
34
|
+
* {formState.errors.info?.name && (
|
|
35
|
+
* <>
|
|
36
|
+
* <p>{formState.errors.info.name.message}</p>
|
|
37
|
+
* <p>{formState.errors.info.name.type}</p>
|
|
38
|
+
* </>
|
|
39
|
+
* )}
|
|
40
|
+
* <button type="submit">submit</button>
|
|
41
|
+
* </form>
|
|
42
|
+
* );
|
|
43
|
+
* };
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export const resolver = (validateBySchema) => (values, _, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const validationResult = yield validateBySchema(values);
|
|
48
|
+
if (validationResult) {
|
|
49
|
+
const resolverError = toPlainError(validationResult, (err, { path }) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return {
|
|
52
|
+
message: err.message,
|
|
53
|
+
type: err.cause.code,
|
|
54
|
+
types: err.cause.errors
|
|
55
|
+
? Object.fromEntries(err.cause.errors.map((error) => [
|
|
56
|
+
error.cause.code,
|
|
57
|
+
error.message,
|
|
58
|
+
]))
|
|
59
|
+
: undefined,
|
|
60
|
+
ref: (_a = get(options.fields, path)) === null || _a === void 0 ? void 0 : _a.ref,
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
return { values: {}, errors: resolverError };
|
|
64
|
+
}
|
|
65
|
+
if (options.shouldUseNativeValidation) {
|
|
66
|
+
validateFieldsNatively({}, options);
|
|
67
|
+
}
|
|
68
|
+
return { errors: {}, values };
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validateFieldsNatively';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validateFieldsNatively';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validateFieldsNatively';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validateFieldsNatively';
|
package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type FieldErrors, type FieldValues, type ResolverOptions } from 'react-hook-form';
|
|
2
|
+
/**
|
|
3
|
+
* Native validation (web only)
|
|
4
|
+
*/
|
|
5
|
+
export declare const validateFieldsNatively: <TFieldValues extends FieldValues>(errors: FieldErrors, options: ResolverOptions<TFieldValues>) => void;
|
package/hook-form/react-hook-form-resolver/utils/validateFieldsNatively/validateFieldsNatively.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Скопировано из https://github.com/react-hook-form/resolvers/blob/master/src/validateFieldsNatively.ts
|
|
2
|
+
// Причина копирования: в @hookform/resolvers react-hook-form указан как peerDep с крышкой. Из-за этого происходит рассинхрон с @astral/form
|
|
3
|
+
import { get, } from 'react-hook-form';
|
|
4
|
+
const setCustomValidity = (ref, fieldPath, errors) => {
|
|
5
|
+
if (ref && 'reportValidity' in ref) {
|
|
6
|
+
const error = get(errors, fieldPath);
|
|
7
|
+
ref.setCustomValidity((error === null || error === void 0 ? void 0 : error.message) || '');
|
|
8
|
+
ref.reportValidity();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Native validation (web only)
|
|
13
|
+
*/
|
|
14
|
+
export const validateFieldsNatively = (errors, options) => {
|
|
15
|
+
for (const fieldPath in options.fields) {
|
|
16
|
+
const field = options.fields[fieldPath];
|
|
17
|
+
if ((field === null || field === void 0 ? void 0 : field.ref) && 'reportValidity' in field.ref) {
|
|
18
|
+
setCustomValidity(field.ref, fieldPath, errors);
|
|
19
|
+
}
|
|
20
|
+
else if (field.refs) {
|
|
21
|
+
field.refs.forEach((ref) => setCustomValidity(ref, fieldPath, errors));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -4,7 +4,7 @@ export type Address = {
|
|
|
4
4
|
addressString: string;
|
|
5
5
|
};
|
|
6
6
|
export type AddressAutocompleteValue<TOptions extends Address = Address> = TOptions;
|
|
7
|
-
export type AddressAutocompleteProps<TOptions extends Address = AddressAutocompleteValue> = Pick<AsyncAutocompleteProps<TOptions, false, false, boolean>, 'className' | 'ref' | 'id' | 'placeholder' | 'onClose' | 'onOpen' | 'open' | 'disablePortal' | 'loadingText' | 'noOptionsText' | 'readOnly' | 'renderOption' | 'autoHighlight' | 'getOptionDisabled' | 'label' | 'helperText' | 'inputRef' | 'size' | 'isDisabled' | 'isLoading' | 'isFullWidth' | 'isError' | 'isSuccess' | 'isRequired' | 'fetchDelayMs' | 'minSymbolsToFetch' | 'fetchOptions' | 'onInputChange' | 'role' | 'defaultValue'> & {
|
|
7
|
+
export type AddressAutocompleteProps<TOptions extends Address = AddressAutocompleteValue> = Pick<AsyncAutocompleteProps<TOptions, false, false, boolean>, 'className' | 'ref' | 'id' | 'placeholder' | 'onClose' | 'onOpen' | 'open' | 'disablePortal' | 'loadingText' | 'noOptionsText' | 'readOnly' | 'renderOption' | 'autoHighlight' | 'getOptionDisabled' | 'label' | 'helperText' | 'inputRef' | 'size' | 'isDisabled' | 'isLoading' | 'isFullWidth' | 'isError' | 'isSuccess' | 'isRequired' | 'fetchDelayMs' | 'minSymbolsToFetch' | 'fetchOptions' | 'onInputChange' | 'role' | 'defaultValue' | 'hideHelperText'> & {
|
|
8
8
|
/**
|
|
9
9
|
* Значение для autocomplete
|
|
10
10
|
*/
|
|
@@ -23,7 +23,7 @@ export type AddressAutocompleteProps<TOptions extends Address = AddressAutocompl
|
|
|
23
23
|
*/
|
|
24
24
|
isHidePersonalData?: boolean;
|
|
25
25
|
};
|
|
26
|
-
export declare const AddressAutocomplete: <TOptions extends Address = Address>(props: Pick<AsyncAutocompleteProps<TOptions, false, false, boolean>, "label" | "size" | "defaultValue" | "className" | "id" | "placeholder" | "role" | "ref" | "open" | "onClose" | "readOnly" | "disablePortal" | "inputRef" | "onOpen" | "loadingText" | "noOptionsText" | "renderOption" | "autoHighlight" | "getOptionDisabled" | "onInputChange" | "helperText" | "isDisabled" | "isError" | "fetchOptions" | "fetchDelayMs" | "minSymbolsToFetch" | "isFullWidth" | "isSuccess" | "isLoading" | "isRequired"> & {
|
|
26
|
+
export declare const AddressAutocomplete: <TOptions extends Address = Address>(props: Pick<AsyncAutocompleteProps<TOptions, false, false, boolean>, "label" | "size" | "defaultValue" | "className" | "id" | "placeholder" | "role" | "ref" | "open" | "onClose" | "readOnly" | "disablePortal" | "inputRef" | "onOpen" | "loadingText" | "noOptionsText" | "renderOption" | "autoHighlight" | "getOptionDisabled" | "onInputChange" | "hideHelperText" | "helperText" | "isDisabled" | "isError" | "fetchOptions" | "fetchDelayMs" | "minSymbolsToFetch" | "isFullWidth" | "isSuccess" | "isLoading" | "isRequired"> & {
|
|
27
27
|
/**
|
|
28
28
|
* Значение для autocomplete
|
|
29
29
|
*/
|
|
@@ -315,6 +315,7 @@ export declare const useLogic: <TOptions, TMultiple extends boolean, TDisableCle
|
|
|
315
315
|
endAdornment?: import("react").ReactNode;
|
|
316
316
|
maxLength?: number | undefined;
|
|
317
317
|
trimmed?: boolean | undefined;
|
|
318
|
+
hideHelperText?: boolean | undefined;
|
|
318
319
|
} & Omit<import("@mui/material").AutocompleteRenderInputParams, "size">) => import("react").ReactNode) | undefined;
|
|
319
320
|
renderOption?: ((props: import("react").HTMLAttributes<HTMLLIElement>, option: TOptions, state: import("@mui/material").AutocompleteRenderOptionState) => import("react").ReactNode) | undefined;
|
|
320
321
|
renderTags?: ((value: TOptions[], getTagProps: import("@mui/material").AutocompleteRenderGetTagProps, ownerState: import("@mui/material").AutocompleteOwnerState<TOptions, TMultiple, TDisableClearable, TFreeSolo, "div">) => import("react").ReactNode) | undefined;
|
|
@@ -339,6 +340,7 @@ export declare const useLogic: <TOptions, TMultiple extends boolean, TDisableCle
|
|
|
339
340
|
onHighlightChange?: ((event: SyntheticEvent<Element, Event>, option: TOptions | null, reason: import("@mui/material").AutocompleteHighlightChangeReason) => void) | undefined;
|
|
340
341
|
openOnFocus?: boolean | undefined;
|
|
341
342
|
selectOnFocus?: boolean | undefined;
|
|
343
|
+
hideHelperText?: boolean | undefined;
|
|
342
344
|
helperText?: import("react").ReactNode;
|
|
343
345
|
loadedDataError?: string | undefined;
|
|
344
346
|
overflowOption?: import("../..").OverflowedElementProps | undefined;
|
|
@@ -46,7 +46,8 @@ const useLogic = (_a) => {
|
|
|
46
46
|
});
|
|
47
47
|
}, fetchDelayMs), [fetchOptions, fetchDelayMs]);
|
|
48
48
|
const handleInputChange = (event, search, reason) => {
|
|
49
|
-
if (
|
|
49
|
+
if ((minSymbolsToFetch > 0 && !search) ||
|
|
50
|
+
search.length < minSymbolsToFetch) {
|
|
50
51
|
if (debouncedFetchOptions.isPending) {
|
|
51
52
|
debouncedFetchOptions.clear();
|
|
52
53
|
}
|
|
@@ -43,6 +43,10 @@ export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean
|
|
|
43
43
|
* @default Очистить
|
|
44
44
|
*/
|
|
45
45
|
clearText?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Включает/отключает резервирование места под helperText
|
|
48
|
+
*/
|
|
49
|
+
hideHelperText?: boolean;
|
|
46
50
|
};
|
|
47
51
|
export declare const Autocomplete: <TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean>(props: Omit<WithoutEmotionSpecific<MuiAutocompleteProps<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo, "div">>, "size" | "clearText" | "closeText" | "noOptionsText" | "openText" | "renderInput"> & Pick<TextFieldProps, "label" | "error" | "success" | "placeholder" | "required" | "inputProps" | "inputRef" | "helperText"> & {
|
|
48
52
|
renderInput?: ((props: TextFieldProps & Omit<AutocompleteRenderInputParams, 'size'>) => ReactNode) | undefined;
|
|
@@ -82,4 +86,8 @@ export declare const Autocomplete: <TAutocompleteValueProps, TMultiple extends b
|
|
|
82
86
|
* @default Очистить
|
|
83
87
|
*/
|
|
84
88
|
clearText?: string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Включает/отключает резервирование места под helperText
|
|
91
|
+
*/
|
|
92
|
+
hideHelperText?: boolean | undefined;
|
|
85
93
|
} & import("react").RefAttributes<unknown>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
|
|
@@ -22,19 +22,22 @@ const Loader_1 = require("../Loader");
|
|
|
22
22
|
const OverflowTypography_1 = require("../OverflowTypography");
|
|
23
23
|
const Tag_1 = require("../Tag");
|
|
24
24
|
const TextField_1 = require("../TextField");
|
|
25
|
+
const utils_1 = require("../utils");
|
|
25
26
|
const constants_1 = require("./constants");
|
|
26
27
|
const styles_1 = require("./styles");
|
|
27
28
|
const useLogic_1 = require("./useLogic");
|
|
28
29
|
const AutocompleteInner = (props, ref) => {
|
|
29
30
|
const { isValueEmpty, isPopperVisible, autocompleteProps } = (0, useLogic_1.useLogic)(props);
|
|
30
|
-
const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = constants_1.DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps } = props, restProps = __rest(props, ["required", "success", "error", "label", "getOptionLabel", "helperText", "inputRef", "multiple", "size", "placeholder", "overflowOption", "closeText", "openText", "clearText", "loadingText", "isLoadedDataError", "loadedDataError", "noOptionsText", "autoHighlight", "renderInput", "renderTags", "renderOption", "inputProps"]);
|
|
31
|
+
const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = constants_1.DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = (0, jsx_runtime_1.jsx)(Loader_1.Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps, hideHelperText = false } = props, restProps = __rest(props, ["required", "success", "error", "label", "getOptionLabel", "helperText", "inputRef", "multiple", "size", "placeholder", "overflowOption", "closeText", "openText", "clearText", "loadingText", "isLoadedDataError", "loadedDataError", "noOptionsText", "autoHighlight", "renderInput", "renderTags", "renderOption", "inputProps", "hideHelperText"]);
|
|
31
32
|
const renderInput = (0, react_1.useCallback)((inputParams) => {
|
|
32
|
-
|
|
33
|
+
var _a;
|
|
34
|
+
const generalInputParams = Object.assign(Object.assign({}, inputParams), { inputProps: Object.assign(Object.assign({}, inputParams.inputProps), { className: (0, utils_1.classNames)((_a = inputParams === null || inputParams === void 0 ? void 0 : inputParams.inputProps) === null || _a === void 0 ? void 0 : _a.className, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className) }), inputRef,
|
|
33
35
|
required, placeholder: isValueEmpty ? placeholder : '', label,
|
|
34
36
|
success,
|
|
35
37
|
error,
|
|
36
38
|
helperText,
|
|
37
|
-
size
|
|
39
|
+
size,
|
|
40
|
+
hideHelperText });
|
|
38
41
|
if (externalRenderInput) {
|
|
39
42
|
return externalRenderInput(generalInputParams);
|
|
40
43
|
}
|
|
@@ -50,6 +53,7 @@ const AutocompleteInner = (props, ref) => {
|
|
|
50
53
|
error,
|
|
51
54
|
helperText,
|
|
52
55
|
size,
|
|
56
|
+
hideHelperText,
|
|
53
57
|
]);
|
|
54
58
|
const renderOption = (0, react_1.useCallback)((optionProps, option, optionState) => {
|
|
55
59
|
if (externalRenderOption) {
|
|
@@ -4,6 +4,7 @@ export declare const StyledFormControlledLabel: import("@emotion/styled").Styled
|
|
|
4
4
|
export declare const StyledFormHelperText: import("@emotion/styled").StyledComponent<import("..").WithoutEmotionSpecific<import("@mui/material").FormHelperTextProps> & {
|
|
5
5
|
success?: boolean | undefined;
|
|
6
6
|
error?: boolean | undefined;
|
|
7
|
+
hideHelperText?: boolean | undefined;
|
|
7
8
|
} & {
|
|
8
9
|
theme?: import("@emotion/react").Theme | undefined;
|
|
9
10
|
}, {}, {}>;
|
|
@@ -18,9 +18,9 @@ exports.StyledFormControlledLabel = (0, styles_1.styled)(FormControlLabel_1.Form
|
|
|
18
18
|
}
|
|
19
19
|
`;
|
|
20
20
|
exports.StyledFormHelperText = (0, styles_1.styled)(FormHelperText_1.FormHelperText) `
|
|
21
|
-
|
|
21
|
+
padding-left: ${({ theme }) => theme.spacing(7)};
|
|
22
22
|
|
|
23
23
|
${({ theme }) => theme.breakpoints.down('sm')} {
|
|
24
|
-
|
|
24
|
+
padding-left: ${({ theme }) => theme.spacing(9)};
|
|
25
25
|
}
|
|
26
26
|
`;
|
|
@@ -35,6 +35,7 @@ export declare const FieldLabel: import("@emotion/styled").StyledComponent<{
|
|
|
35
35
|
export declare const StyledHelperText: import("@emotion/styled").StyledComponent<import("..").WithoutEmotionSpecific<import("@mui/material").FormHelperTextProps> & {
|
|
36
36
|
success?: boolean | undefined;
|
|
37
37
|
error?: boolean | undefined;
|
|
38
|
+
hideHelperText?: boolean | undefined;
|
|
38
39
|
} & {
|
|
39
40
|
theme?: import("@emotion/react").Theme | undefined;
|
|
40
41
|
}, {}, {}>;
|
|
@@ -19,5 +19,5 @@ exports.Sidebar = (0, react_1.forwardRef)((props, ref) => {
|
|
|
19
19
|
if (isLoading) {
|
|
20
20
|
return (0, jsx_runtime_1.jsx)(SidebarSkeleton_1.SidebarSkeleton, {});
|
|
21
21
|
}
|
|
22
|
-
return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, children: (0, jsx_runtime_1.
|
|
22
|
+
return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, children: (0, jsx_runtime_1.jsx)(styles_1.SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: (0, utils_1.classNames)(className, constants_1.dashboardLayoutSidebarClassnames.root), onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, inert: isMobile && !isPinned ? '' : undefined, children: (0, jsx_runtime_1.jsxs)(styles_1.StyledPaper, { variant: "outlined", children: [(0, jsx_runtime_1.jsxs)(styles_1.SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && (0, jsx_runtime_1.jsx)(styles_1.SidebarHeader, { children: header }), (0, jsx_runtime_1.jsx)(SidebarNav_1.SidebarNav, { menu: (0, jsx_runtime_1.jsx)(NavMenu_1.NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), (0, jsx_runtime_1.jsx)(styles_1.Footer, { children: (0, jsx_runtime_1.jsx)(PinButton_1.PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
|
|
23
23
|
});
|