@astral/ui 4.115.1 → 4.116.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
  2. package/components/Autocomplete/Autocomplete.d.ts +1 -0
  3. package/components/Autocomplete/Autocomplete.js +2 -1
  4. package/components/Autocomplete/public.d.ts +1 -1
  5. package/components/Autocomplete/types.d.ts +8 -0
  6. package/hook-form/EditableText/EditingForm/EditingForm.js +13 -8
  7. package/hook-form/EditableText/EditingForm/styles.d.ts +12 -10
  8. package/hook-form/EditableText/EditingForm/styles.js +20 -12
  9. package/hook-form/EditableText/EditingForm/useLogic/useLogic.d.ts +1 -0
  10. package/hook-form/EditableText/EditingForm/useLogic/useLogic.js +3 -0
  11. package/hook-form/EditableText/FormIconSubmitButton/FormIconSubmitButton.d.ts +3 -0
  12. package/hook-form/EditableText/FormIconSubmitButton/FormIconSubmitButton.js +7 -0
  13. package/hook-form/EditableText/FormIconSubmitButton/index.d.ts +1 -0
  14. package/hook-form/EditableText/FormIconSubmitButton/index.js +1 -0
  15. package/node/components/AsyncAutocomplete/useLogic/useLogic.d.ts +1 -0
  16. package/node/components/Autocomplete/Autocomplete.d.ts +1 -0
  17. package/node/components/Autocomplete/Autocomplete.js +2 -1
  18. package/node/components/Autocomplete/public.d.ts +1 -1
  19. package/node/components/Autocomplete/types.d.ts +8 -0
  20. package/node/hook-form/EditableText/EditingForm/EditingForm.js +12 -7
  21. package/node/hook-form/EditableText/EditingForm/styles.d.ts +12 -10
  22. package/node/hook-form/EditableText/EditingForm/styles.js +20 -12
  23. package/node/hook-form/EditableText/EditingForm/useLogic/useLogic.d.ts +1 -0
  24. package/node/hook-form/EditableText/EditingForm/useLogic/useLogic.js +3 -0
  25. package/node/hook-form/EditableText/FormIconSubmitButton/FormIconSubmitButton.d.ts +3 -0
  26. package/node/hook-form/EditableText/FormIconSubmitButton/FormIconSubmitButton.js +11 -0
  27. package/node/hook-form/EditableText/FormIconSubmitButton/index.d.ts +1 -0
  28. package/node/hook-form/EditableText/FormIconSubmitButton/index.js +17 -0
  29. package/package.json +1 -1
@@ -306,6 +306,7 @@ export declare const useLogic: <TOptions, TMultiple extends boolean, TDisableCle
306
306
  } | undefined;
307
307
  disabledItemsFocusable?: boolean | undefined;
308
308
  disableListWrap?: boolean | undefined;
309
+ placement?: import("../../Autocomplete/types").AutocompletePlacement | undefined;
309
310
  PopperComponent?: import("react").JSXElementConstructor<import("@mui/material").PopperProps> | undefined;
310
311
  autoComplete?: boolean | undefined;
311
312
  multiple?: TMultiple | undefined;
@@ -19,4 +19,5 @@ export declare const Autocomplete: <TAutocompleteValueProps, TMultiple extends b
19
19
  clearText?: string | undefined;
20
20
  hideHelperText?: boolean | undefined;
21
21
  focusedHelperText?: string | undefined;
22
+ placement?: import("./types").AutocompletePlacement | undefined;
22
23
  } & import("react").RefAttributes<unknown>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
@@ -19,7 +19,7 @@ import { checkIsFocusedHelperOption } from './utils';
19
19
  const AutocompleteInner = (props, ref) => {
20
20
  const { isValueEmpty, isPopperVisible, autocompleteProps } = useLogic(props);
21
21
  const inputBaseRef = useRef(null);
22
- const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = _jsx(Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps, hideHelperText = false, focusedHelperText, loading, value, onChange, ...restProps } = props;
22
+ const { required, success, error, label, getOptionLabel, helperText, inputRef, multiple, size = 'medium', placeholder = DEFAULT_PLACEHOLDER, overflowOption, closeText = 'Закрыть', openText = 'Открыть', clearText = 'Очистить', loadingText = _jsx(Loader, {}), isLoadedDataError, loadedDataError, noOptionsText, autoHighlight, renderInput: externalRenderInput, renderTags: externalRenderTags, renderOption: externalRenderOption, inputProps, hideHelperText = false, focusedHelperText, loading, value, onChange, placement = 'bottom', ...restProps } = props;
23
23
  const renderInput = useCallback((inputParams) => {
24
24
  const createStartAdornment = () => {
25
25
  if (!multiple || !Array.isArray(value)) {
@@ -120,6 +120,7 @@ const AutocompleteInner = (props, ref) => {
120
120
  return (_jsx(StyledAutocomplete, { ...restProps, ref: ref, size: size, clearText: clearText, closeText: !loading ? closeText : '', openText: !loading ? openText : '', loadingText: loadingText, multiple: multiple, disableCloseOnSelect: multiple, clearIcon: _jsx(CrossOutlineMd, {}), loading: loading, popupIcon: loading ? _jsx(Loader, { color: "primary", size: "small" }) : _jsx(DownOutlineMd, {}), forcePopupIcon: true, slotProps: {
121
121
  popper: {
122
122
  component: renderPopper,
123
+ placement,
123
124
  },
124
125
  }, renderInput: renderInput, renderTags: renderTags, renderOption: renderOption, value: value, ...autocompleteProps }));
125
126
  };
@@ -1,2 +1,2 @@
1
1
  export * from './Autocomplete';
2
- export type { AutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteSize, } from './types';
2
+ export type { AutocompletePlacement, AutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteSize, } from './types';
@@ -6,6 +6,10 @@ import type { WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
6
6
  export type { AutocompleteOwnerState, AutocompleteProps as MuiAutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteRenderInputParams, AutocompleteRenderOptionState, } from '@mui/material/Autocomplete';
7
7
  export type { PopperProps } from '@mui/material/Popper';
8
8
  export type AutocompleteSize = 'small' | 'medium';
9
+ /**
10
+ * Направление открытия списка относительно поля
11
+ */
12
+ export type AutocompletePlacement = 'bottom' | 'top';
9
13
  export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean> = Omit<WithoutEmotionSpecific<MuiAutocompleteProps<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>>, 'size' | 'renderInput' | 'noOptionsText' | 'closeText' | 'openText' | 'clearText'> & Pick<TextFieldProps, 'error' | 'success' | 'helperText' | 'label' | 'required' | 'inputRef' | 'placeholder' | 'inputProps'> & {
10
14
  renderInput?: (props: TextFieldProps & Omit<AutocompleteRenderInputParams, 'size'>) => ReactNode;
11
15
  size?: AutocompleteSize;
@@ -52,4 +56,8 @@ export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean
52
56
  * Текст подсказки в popover при фокусе
53
57
  */
54
58
  focusedHelperText?: string;
59
+ /**
60
+ * Направление открытия списка относительно поля.
61
+ */
62
+ placement?: AutocompletePlacement;
55
63
  };
@@ -1,18 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconButton } from '../../../components/IconButton';
3
+ import { CheckOutlineMd } from '../../../icons/CheckOutlineMd';
4
+ import { CrossOutlineMd } from '../../../icons/CrossOutlineMd';
2
5
  import { Form } from '../../Form';
3
6
  import { FormSubmitButton } from '../../FormSubmitButton';
4
7
  import { FormTextField } from '../../FormTextField';
5
8
  import { FIELD_NAME } from '../constants';
6
- import { CancelButton, Description, FormFooter, Wrapper } from './styles';
9
+ import { FormIconSubmitButton } from '../FormIconSubmitButton';
10
+ import { Actions, Description, FieldContainer, FieldRow, FormFooter, Wrapper, } from './styles';
7
11
  import { useLogic } from './useLogic';
8
12
  // biome-ignore lint/complexity/noUselessTypeConstraint: Фикс типизация в тестах
9
13
  export const EditingForm = (props) => {
10
- const { formProps } = useLogic(props);
14
+ const { formProps, isMobile } = useLogic(props);
11
15
  const { componentField = (fieldProps) => _jsx(FormTextField, { ...fieldProps }), onClose, } = props;
12
- return (_jsx(Wrapper, { children: _jsxs(Form, { ...formProps, children: [_jsx(Description, { children: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043D\u043E\u0432\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u00AB\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C\u00BB" }), componentField?.({
13
- name: FIELD_NAME,
14
- control: formProps.form.control,
15
- fullWidth: true,
16
- autoFocus: true,
17
- }), _jsxs(FormFooter, { children: [_jsx(CancelButton, { variant: "text", onClick: onClose, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), _jsx(FormSubmitButton, { children: "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C" })] })] }) }));
16
+ const formFieldProps = {
17
+ name: FIELD_NAME,
18
+ control: formProps.form.control,
19
+ fullWidth: true,
20
+ autoFocus: true,
21
+ };
22
+ return (_jsx(Wrapper, { children: _jsxs(Form, { ...formProps, children: [_jsx(Description, { children: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043D\u043E\u0432\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u00AB\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C\u00BB" }), _jsxs(FieldRow, { children: [_jsx(FieldContainer, { children: componentField(formFieldProps) }), !isMobile && (_jsxs(Actions, { children: [_jsx(FormIconSubmitButton, { variant: "outlined", size: "large", color: "success", "aria-label": "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C", children: _jsx(CheckOutlineMd, {}) }), _jsx(IconButton, { variant: "outlined", size: "large", color: "grey", "aria-label": "\u041E\u0442\u043C\u0435\u043D\u0430", onClick: onClose, children: _jsx(CrossOutlineMd, {}) })] }))] }), isMobile && (_jsx(FormFooter, { children: _jsx(FormSubmitButton, { children: "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C" }) }))] }) }));
18
23
  };
@@ -14,17 +14,19 @@ export declare const Description: import("../../../components/styled").StyledCom
14
14
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
15
15
  theme?: import("@emotion/react").Theme | undefined;
16
16
  }, {}, {}>;
17
+ export declare const FieldRow: import("../../../components/styled").StyledComponent<{
18
+ theme?: import("@emotion/react").Theme | undefined;
19
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
20
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
21
+ export declare const FieldContainer: import("../../../components/styled").StyledComponent<{
22
+ theme?: import("@emotion/react").Theme | undefined;
23
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
24
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
25
+ export declare const Actions: import("../../../components/styled").StyledComponent<{
26
+ theme?: import("@emotion/react").Theme | undefined;
27
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
28
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
17
29
  export declare const FormFooter: import("../../../components/styled").StyledComponent<{
18
30
  theme?: import("@emotion/react").Theme | undefined;
19
31
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
20
32
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
21
- export declare const CancelButton: import("../../../components/styled").StyledComponent<Omit<import("../../..").WithoutEmotionSpecific<import("@mui/material").ButtonProps>, "color" | "component" | "size" | "variant" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple"> & {
22
- variant?: "light" | "link" | "text" | "contained" | "outlined" | undefined;
23
- loading?: boolean | undefined;
24
- color?: "primary" | "success" | "warning" | "error" | "grey" | undefined;
25
- component?: import("react").ElementType | undefined;
26
- selected?: boolean | undefined;
27
- size?: "large" | "medium" | undefined;
28
- } & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ""> & import("react").RefAttributes<HTMLButtonElement> & {
29
- theme?: import("@emotion/react").Theme | undefined;
30
- }, {}, {}>;
@@ -1,4 +1,4 @@
1
- import { Button, buttonClasses } from '../../../components/Button';
1
+ import { buttonClasses } from '../../../components/Button';
2
2
  import { styled } from '../../../components/styled';
3
3
  import { Typography } from '../../../components/Typography';
4
4
  export const Wrapper = styled.div `
@@ -16,22 +16,30 @@ export const Description = styled(Typography) `
16
16
  display: none;
17
17
  }
18
18
  `;
19
+ export const FieldRow = styled.div `
20
+ display: flex;
21
+ gap: ${({ theme }) => theme.spacing(5)};
22
+ align-items: flex-start;
23
+ `;
24
+ export const FieldContainer = styled.div `
25
+ flex: 1;
26
+
27
+ min-width: 0;
28
+ `;
29
+ export const Actions = styled.div `
30
+ display: flex;
31
+ flex-shrink: 0;
32
+ gap: ${({ theme }) => theme.spacing(2)};
33
+ `;
19
34
  export const FormFooter = styled.footer `
20
35
  display: flex;
21
36
  gap: ${({ theme }) => theme.spacing(3)};
22
37
  justify-content: end;
23
38
 
24
- ${({ theme }) => theme.breakpoints.down('mobile')} {
25
- padding-top: ${({ theme }) => theme.spacing(4)};
39
+ padding-top: ${({ theme }) => theme.spacing(4)};
26
40
 
27
- & .${buttonClasses.root} {
28
- width: 100%;
29
- height: 48px;
30
- }
31
- }
32
- `;
33
- export const CancelButton = styled(Button) `
34
- ${({ theme }) => theme.breakpoints.down('mobile')} {
35
- display: none;
41
+ & .${buttonClasses.root} {
42
+ width: 100%;
43
+ height: 48px;
36
44
  }
37
45
  `;
@@ -7,5 +7,6 @@ export declare const useLogic: <TValue>({ initialValue, children, validate, onCl
7
7
  form: import("react-hook-form").UseFormReturn<FormValues, any>;
8
8
  onSubmit: (e?: import("react").BaseSyntheticEvent<object, any, any> | undefined) => Promise<void | undefined>;
9
9
  };
10
+ isMobile: boolean;
10
11
  };
11
12
  export {};
@@ -1,4 +1,5 @@
1
1
  import { useMemo } from 'react';
2
+ import { useViewportType } from '../../../../components/useViewportType';
2
3
  import { useForm } from '../../../useForm';
3
4
  import { FIELD_NAME } from '../../constants';
4
5
  export const useLogic = ({ initialValue, children, validate, onClose, onSubmit, }) => {
@@ -45,10 +46,12 @@ export const useLogic = ({ initialValue, children, validate, onClose, onSubmit,
45
46
  return onSubmit(fieldValue);
46
47
  }
47
48
  };
49
+ const { isMobile } = useViewportType();
48
50
  return {
49
51
  formProps: {
50
52
  form,
51
53
  onSubmit: form.handleSubmit(handleSubmit),
52
54
  },
55
+ isMobile,
53
56
  };
54
57
  };
@@ -0,0 +1,3 @@
1
+ import { type IconButtonProps } from '../../../components/IconButton';
2
+ export type FormIconSubmitButtonProps = Omit<IconButtonProps, 'type'>;
3
+ export declare const FormIconSubmitButton: ({ children, loading, ...props }: FormIconSubmitButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { IconButton, } from '../../../components/IconButton';
3
+ import { useFormContext } from '../../useFormContext';
4
+ export const FormIconSubmitButton = ({ children, loading, ...props }) => {
5
+ const { formState } = useFormContext();
6
+ return (_jsx(IconButton, { type: "submit", loading: loading || formState?.isSubmitting, ...props, children: children }));
7
+ };
@@ -0,0 +1 @@
1
+ export * from './FormIconSubmitButton';
@@ -0,0 +1 @@
1
+ export * from './FormIconSubmitButton';
@@ -306,6 +306,7 @@ export declare const useLogic: <TOptions, TMultiple extends boolean, TDisableCle
306
306
  } | undefined;
307
307
  disabledItemsFocusable?: boolean | undefined;
308
308
  disableListWrap?: boolean | undefined;
309
+ placement?: import("../../Autocomplete/types").AutocompletePlacement | undefined;
309
310
  PopperComponent?: import("react").JSXElementConstructor<import("@mui/material").PopperProps> | undefined;
310
311
  autoComplete?: boolean | undefined;
311
312
  multiple?: TMultiple | undefined;
@@ -19,4 +19,5 @@ export declare const Autocomplete: <TAutocompleteValueProps, TMultiple extends b
19
19
  clearText?: string | undefined;
20
20
  hideHelperText?: boolean | undefined;
21
21
  focusedHelperText?: string | undefined;
22
+ placement?: import("./types").AutocompletePlacement | undefined;
22
23
  } & import("react").RefAttributes<unknown>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
@@ -25,7 +25,7 @@ const utils_1 = require("./utils");
25
25
  const AutocompleteInner = (props, ref) => {
26
26
  const { isValueEmpty, isPopperVisible, autocompleteProps } = (0, useLogic_1.useLogic)(props);
27
27
  const inputBaseRef = (0, react_1.useRef)(null);
28
- 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, focusedHelperText, loading, value, onChange, ...restProps } = props;
28
+ 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, focusedHelperText, loading, value, onChange, placement = 'bottom', ...restProps } = props;
29
29
  const renderInput = (0, react_1.useCallback)((inputParams) => {
30
30
  const createStartAdornment = () => {
31
31
  if (!multiple || !Array.isArray(value)) {
@@ -126,6 +126,7 @@ const AutocompleteInner = (props, ref) => {
126
126
  return ((0, jsx_runtime_1.jsx)(styles_1.StyledAutocomplete, { ...restProps, ref: ref, size: size, clearText: clearText, closeText: !loading ? closeText : '', openText: !loading ? openText : '', loadingText: loadingText, multiple: multiple, disableCloseOnSelect: multiple, clearIcon: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}), loading: loading, popupIcon: loading ? (0, jsx_runtime_1.jsx)(Loader_1.Loader, { color: "primary", size: "small" }) : (0, jsx_runtime_1.jsx)(DownOutlineMd_1.DownOutlineMd, {}), forcePopupIcon: true, slotProps: {
127
127
  popper: {
128
128
  component: renderPopper,
129
+ placement,
129
130
  },
130
131
  }, renderInput: renderInput, renderTags: renderTags, renderOption: renderOption, value: value, ...autocompleteProps }));
131
132
  };
@@ -1,2 +1,2 @@
1
1
  export * from './Autocomplete';
2
- export type { AutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteSize, } from './types';
2
+ export type { AutocompletePlacement, AutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteSize, } from './types';
@@ -6,6 +6,10 @@ import type { WithoutEmotionSpecific } from '../types/WithoutEmotionSpecific';
6
6
  export type { AutocompleteOwnerState, AutocompleteProps as MuiAutocompleteProps, AutocompleteRenderGetTagProps, AutocompleteRenderInputParams, AutocompleteRenderOptionState, } from '@mui/material/Autocomplete';
7
7
  export type { PopperProps } from '@mui/material/Popper';
8
8
  export type AutocompleteSize = 'small' | 'medium';
9
+ /**
10
+ * Направление открытия списка относительно поля
11
+ */
12
+ export type AutocompletePlacement = 'bottom' | 'top';
9
13
  export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean, TDisableClearable extends boolean, TFreeSolo extends boolean> = Omit<WithoutEmotionSpecific<MuiAutocompleteProps<TAutocompleteValueProps, TMultiple, TDisableClearable, TFreeSolo>>, 'size' | 'renderInput' | 'noOptionsText' | 'closeText' | 'openText' | 'clearText'> & Pick<TextFieldProps, 'error' | 'success' | 'helperText' | 'label' | 'required' | 'inputRef' | 'placeholder' | 'inputProps'> & {
10
14
  renderInput?: (props: TextFieldProps & Omit<AutocompleteRenderInputParams, 'size'>) => ReactNode;
11
15
  size?: AutocompleteSize;
@@ -52,4 +56,8 @@ export type AutocompleteProps<TAutocompleteValueProps, TMultiple extends boolean
52
56
  * Текст подсказки в popover при фокусе
53
57
  */
54
58
  focusedHelperText?: string;
59
+ /**
60
+ * Направление открытия списка относительно поля.
61
+ */
62
+ placement?: AutocompletePlacement;
55
63
  };
@@ -2,21 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EditingForm = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const IconButton_1 = require("../../../components/IconButton");
6
+ const CheckOutlineMd_1 = require("../../../icons/CheckOutlineMd");
7
+ const CrossOutlineMd_1 = require("../../../icons/CrossOutlineMd");
5
8
  const Form_1 = require("../../Form");
6
9
  const FormSubmitButton_1 = require("../../FormSubmitButton");
7
10
  const FormTextField_1 = require("../../FormTextField");
8
11
  const constants_1 = require("../constants");
12
+ const FormIconSubmitButton_1 = require("../FormIconSubmitButton");
9
13
  const styles_1 = require("./styles");
10
14
  const useLogic_1 = require("./useLogic");
11
15
  // biome-ignore lint/complexity/noUselessTypeConstraint: Фикс типизация в тестах
12
16
  const EditingForm = (props) => {
13
- const { formProps } = (0, useLogic_1.useLogic)(props);
17
+ const { formProps, isMobile } = (0, useLogic_1.useLogic)(props);
14
18
  const { componentField = (fieldProps) => (0, jsx_runtime_1.jsx)(FormTextField_1.FormTextField, { ...fieldProps }), onClose, } = props;
15
- return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { children: (0, jsx_runtime_1.jsxs)(Form_1.Form, { ...formProps, children: [(0, jsx_runtime_1.jsx)(styles_1.Description, { children: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043D\u043E\u0432\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u00AB\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C\u00BB" }), componentField?.({
16
- name: constants_1.FIELD_NAME,
17
- control: formProps.form.control,
18
- fullWidth: true,
19
- autoFocus: true,
20
- }), (0, jsx_runtime_1.jsxs)(styles_1.FormFooter, { children: [(0, jsx_runtime_1.jsx)(styles_1.CancelButton, { variant: "text", onClick: onClose, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), (0, jsx_runtime_1.jsx)(FormSubmitButton_1.FormSubmitButton, { children: "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C" })] })] }) }));
19
+ const formFieldProps = {
20
+ name: constants_1.FIELD_NAME,
21
+ control: formProps.form.control,
22
+ fullWidth: true,
23
+ autoFocus: true,
24
+ };
25
+ return ((0, jsx_runtime_1.jsx)(styles_1.Wrapper, { children: (0, jsx_runtime_1.jsxs)(Form_1.Form, { ...formProps, children: [(0, jsx_runtime_1.jsx)(styles_1.Description, { children: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043D\u043E\u0432\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \u00AB\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C\u00BB" }), (0, jsx_runtime_1.jsxs)(styles_1.FieldRow, { children: [(0, jsx_runtime_1.jsx)(styles_1.FieldContainer, { children: componentField(formFieldProps) }), !isMobile && ((0, jsx_runtime_1.jsxs)(styles_1.Actions, { children: [(0, jsx_runtime_1.jsx)(FormIconSubmitButton_1.FormIconSubmitButton, { variant: "outlined", size: "large", color: "success", "aria-label": "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C", children: (0, jsx_runtime_1.jsx)(CheckOutlineMd_1.CheckOutlineMd, {}) }), (0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { variant: "outlined", size: "large", color: "grey", "aria-label": "\u041E\u0442\u043C\u0435\u043D\u0430", onClick: onClose, children: (0, jsx_runtime_1.jsx)(CrossOutlineMd_1.CrossOutlineMd, {}) })] }))] }), isMobile && ((0, jsx_runtime_1.jsx)(styles_1.FormFooter, { children: (0, jsx_runtime_1.jsx)(FormSubmitButton_1.FormSubmitButton, { children: "\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C" }) }))] }) }));
21
26
  };
22
27
  exports.EditingForm = EditingForm;
@@ -14,17 +14,19 @@ export declare const Description: import("@emotion/styled/dist/declarations/src/
14
14
  } & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLSpanElement> & {
15
15
  theme?: import("@emotion/react").Theme | undefined;
16
16
  }, {}, {}>;
17
+ export declare const FieldRow: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
18
+ theme?: import("@emotion/react").Theme | undefined;
19
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
20
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
21
+ export declare const FieldContainer: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
22
+ theme?: import("@emotion/react").Theme | undefined;
23
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
24
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
25
+ export declare const Actions: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
26
+ theme?: import("@emotion/react").Theme | undefined;
27
+ as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
28
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
17
29
  export declare const FormFooter: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
18
30
  theme?: import("@emotion/react").Theme | undefined;
19
31
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
20
32
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
21
- export declare const CancelButton: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../..").WithoutEmotionSpecific<import("@mui/material").ButtonProps>, "color" | "component" | "size" | "variant" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple"> & {
22
- variant?: "light" | "link" | "text" | "contained" | "outlined" | undefined;
23
- loading?: boolean | undefined;
24
- color?: "primary" | "success" | "warning" | "error" | "grey" | undefined;
25
- component?: import("react").ElementType | undefined;
26
- selected?: boolean | undefined;
27
- size?: "large" | "medium" | undefined;
28
- } & Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, ""> & import("react").RefAttributes<HTMLButtonElement> & {
29
- theme?: import("@emotion/react").Theme | undefined;
30
- }, {}, {}>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CancelButton = exports.FormFooter = exports.Description = exports.Wrapper = void 0;
3
+ exports.FormFooter = exports.Actions = exports.FieldContainer = exports.FieldRow = exports.Description = exports.Wrapper = void 0;
4
4
  const Button_1 = require("../../../components/Button");
5
5
  const styled_1 = require("../../../components/styled");
6
6
  const Typography_1 = require("../../../components/Typography");
@@ -19,22 +19,30 @@ exports.Description = (0, styled_1.styled)(Typography_1.Typography) `
19
19
  display: none;
20
20
  }
21
21
  `;
22
+ exports.FieldRow = styled_1.styled.div `
23
+ display: flex;
24
+ gap: ${({ theme }) => theme.spacing(5)};
25
+ align-items: flex-start;
26
+ `;
27
+ exports.FieldContainer = styled_1.styled.div `
28
+ flex: 1;
29
+
30
+ min-width: 0;
31
+ `;
32
+ exports.Actions = styled_1.styled.div `
33
+ display: flex;
34
+ flex-shrink: 0;
35
+ gap: ${({ theme }) => theme.spacing(2)};
36
+ `;
22
37
  exports.FormFooter = styled_1.styled.footer `
23
38
  display: flex;
24
39
  gap: ${({ theme }) => theme.spacing(3)};
25
40
  justify-content: end;
26
41
 
27
- ${({ theme }) => theme.breakpoints.down('mobile')} {
28
- padding-top: ${({ theme }) => theme.spacing(4)};
42
+ padding-top: ${({ theme }) => theme.spacing(4)};
29
43
 
30
- & .${Button_1.buttonClasses.root} {
31
- width: 100%;
32
- height: 48px;
33
- }
34
- }
35
- `;
36
- exports.CancelButton = (0, styled_1.styled)(Button_1.Button) `
37
- ${({ theme }) => theme.breakpoints.down('mobile')} {
38
- display: none;
44
+ & .${Button_1.buttonClasses.root} {
45
+ width: 100%;
46
+ height: 48px;
39
47
  }
40
48
  `;
@@ -7,5 +7,6 @@ export declare const useLogic: <TValue>({ initialValue, children, validate, onCl
7
7
  form: import("react-hook-form").UseFormReturn<FormValues, any>;
8
8
  onSubmit: (e?: import("react").BaseSyntheticEvent<object, any, any> | undefined) => Promise<void | undefined>;
9
9
  };
10
+ isMobile: boolean;
10
11
  };
11
12
  export {};
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLogic = void 0;
4
4
  const react_1 = require("react");
5
+ const useViewportType_1 = require("../../../../components/useViewportType");
5
6
  const useForm_1 = require("../../../useForm");
6
7
  const constants_1 = require("../../constants");
7
8
  const useLogic = ({ initialValue, children, validate, onClose, onSubmit, }) => {
@@ -48,11 +49,13 @@ const useLogic = ({ initialValue, children, validate, onClose, onSubmit, }) => {
48
49
  return onSubmit(fieldValue);
49
50
  }
50
51
  };
52
+ const { isMobile } = (0, useViewportType_1.useViewportType)();
51
53
  return {
52
54
  formProps: {
53
55
  form,
54
56
  onSubmit: form.handleSubmit(handleSubmit),
55
57
  },
58
+ isMobile,
56
59
  };
57
60
  };
58
61
  exports.useLogic = useLogic;
@@ -0,0 +1,3 @@
1
+ import { type IconButtonProps } from '../../../components/IconButton';
2
+ export type FormIconSubmitButtonProps = Omit<IconButtonProps, 'type'>;
3
+ export declare const FormIconSubmitButton: ({ children, loading, ...props }: FormIconSubmitButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormIconSubmitButton = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const IconButton_1 = require("../../../components/IconButton");
6
+ const useFormContext_1 = require("../../useFormContext");
7
+ const FormIconSubmitButton = ({ children, loading, ...props }) => {
8
+ const { formState } = (0, useFormContext_1.useFormContext)();
9
+ return ((0, jsx_runtime_1.jsx)(IconButton_1.IconButton, { type: "submit", loading: loading || formState?.isSubmitting, ...props, children: children }));
10
+ };
11
+ exports.FormIconSubmitButton = FormIconSubmitButton;
@@ -0,0 +1 @@
1
+ export * from './FormIconSubmitButton';
@@ -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("./FormIconSubmitButton"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.115.1",
3
+ "version": "4.116.1",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {