@astral/ui 4.21.3 → 4.22.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.
@@ -1,13 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Paper } from '../../Paper';
3
2
  import { Tooltip } from '../../Tooltip';
4
3
  import { getInertProps } from '../../utils/getInertProps';
5
4
  import { CardActionContextProvider } from './CardActionContext';
6
5
  import { SecondaryActionButton } from './SecondaryActionButton';
7
- import { CardHeader, HeaderWrapper, StyledDivider, Wrapper } from './styles';
6
+ import { CardHeader, HeaderWrapper, StyledDivider, StyledPaper, Wrapper, } from './styles';
8
7
  import { useLogic } from './useLogic';
9
8
  export const Card = (props) => {
10
9
  const { handleActionClick } = useLogic(props);
11
10
  const { isDisabled, mainActions: MainActions, content, header, disabledReason, secondaryActions, } = props;
12
- return (_jsx(CardActionContextProvider, { onActionClick: handleActionClick, isDisabledCard: isDisabled, children: _jsx(Tooltip, { title: isDisabled && disabledReason, withoutContainer: !isDisabled, placement: "top", componentsProps: { popper: { disablePortal: true } }, children: _jsx(Paper, { variant: "outlined", ...getInertProps(isDisabled), children: _jsxs(Wrapper, { children: [header && (_jsxs(_Fragment, { children: [_jsxs(CardHeader, { children: [_jsx(HeaderWrapper, { children: header }), secondaryActions && (_jsx(SecondaryActionButton, { renderActions: secondaryActions }))] }), _jsx(StyledDivider, {})] })), content, MainActions && _jsx(MainActions, {})] }) }) }) }));
11
+ return (_jsx(CardActionContextProvider, { onActionClick: handleActionClick, isDisabledCard: isDisabled, children: _jsx(Tooltip, { title: isDisabled && disabledReason, withoutContainer: !isDisabled, placement: "top", componentsProps: { popper: { disablePortal: true } }, children: _jsx(StyledPaper, { variant: "outlined", ...getInertProps(isDisabled), children: _jsxs(Wrapper, { children: [header && (_jsxs(_Fragment, { children: [_jsxs(CardHeader, { children: [_jsx(HeaderWrapper, { children: header }), secondaryActions && (_jsx(SecondaryActionButton, { renderActions: secondaryActions }))] }), _jsx(StyledDivider, {})] })), content, MainActions && _jsx(MainActions, {})] }) }) }) }));
13
12
  };
@@ -14,3 +14,6 @@ export declare const HeaderWrapper: import("../../styled").StyledComponent<{
14
14
  theme?: import("@emotion/react").Theme | undefined;
15
15
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
16
16
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
17
+ export declare const StyledPaper: import("../../styled").StyledComponent<Omit<import("../../Paper").PaperProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
18
+ theme?: import("@emotion/react").Theme | undefined;
19
+ }, {}, {}>;
@@ -1,6 +1,11 @@
1
1
  import { Divider } from '../../Divider';
2
+ import { Paper } from '../../Paper';
2
3
  import { styled } from '../../styled';
3
4
  export const Wrapper = styled.div `
5
+ display: flex;
6
+ flex-direction: column;
7
+
8
+ height: 100%;
4
9
  padding: ${({ theme }) => theme.spacing(4, 5)};
5
10
 
6
11
  ${({ theme }) => theme.breakpoints.down('sm')} {
@@ -20,3 +25,6 @@ export const HeaderWrapper = styled.div `
20
25
  overflow: hidden;
21
26
  flex: 1;
22
27
  `;
28
+ export const StyledPaper = styled(Paper) `
29
+ height: 100%;
30
+ `;
@@ -5,5 +5,6 @@ export const Wrapper = styled.div `
5
5
  grid-auto-flow: column;
6
6
  gap: ${({ theme }) => theme.spacing(3)};
7
7
 
8
+ margin-top: auto;
8
9
  padding-top: ${({ theme }) => theme.spacing(6)};
9
10
  `;
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from 'react';
2
+ export type FormControlContextProps = {
3
+ /**
4
+ * Размер элементов формы
5
+ */
6
+ size?: 'small' | 'medium';
7
+ /**
8
+ * Включает/отключает резервирование места под helperText
9
+ */
10
+ hideHelperText?: boolean;
11
+ };
12
+ export type FormControlProviderProps = Partial<FormControlContextProps> & {
13
+ children: ReactNode;
14
+ };
15
+ /**
16
+ * Контекст для управления состоянием и конфигурацией элементов формы.
17
+ */
18
+ export declare const FormControlContext: import("react").Context<FormControlContextProps | undefined>;
19
+ /**
20
+ * Провайдер контекста для группы элементов формы.
21
+ * Оборачивает группу элементов предоставляет им общую конфигурацию.
22
+ */
23
+ export declare const FormControlProvider: ({ children, size, hideHelperText, }: FormControlProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext } from 'react';
3
+ /**
4
+ * Контекст для управления состоянием и конфигурацией элементов формы.
5
+ */
6
+ export const FormControlContext = createContext(undefined);
7
+ /**
8
+ * Провайдер контекста для группы элементов формы.
9
+ * Оборачивает группу элементов предоставляет им общую конфигурацию.
10
+ */
11
+ export const FormControlProvider = ({ children, size, hideHelperText, }) => {
12
+ return (_jsx(FormControlContext.Provider, { value: { size, hideHelperText }, children: children }));
13
+ };
@@ -0,0 +1 @@
1
+ export * from './FormControlProvider';
@@ -0,0 +1 @@
1
+ export * from './FormControlProvider';
@@ -1,5 +1,7 @@
1
+ import { useContext } from 'react';
1
2
  import { useController, } from 'react-hook-form';
2
3
  import { useForwardedRef } from '../../components/useForwardedRef';
4
+ import { FormControlContext } from '../FormControlProvider';
3
5
  import { useFormFieldErrorProps, } from '../useFormFieldErrorProps';
4
6
  import { useFormInputProps, } from '../useFormInputProps';
5
7
  /**
@@ -11,9 +13,11 @@ export const useFormFieldProps = (props) => {
11
13
  disabled: undefined,
12
14
  });
13
15
  const ref = useForwardedRef(field.ref);
16
+ const contextProps = useContext(FormControlContext);
14
17
  const inputProps = useFormInputProps(props);
15
18
  const errorProps = useFormFieldErrorProps(fieldState);
16
19
  return {
20
+ ...contextProps,
17
21
  ...field,
18
22
  ...inputProps,
19
23
  ...errorProps,
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Card = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const Paper_1 = require("../../Paper");
6
5
  const Tooltip_1 = require("../../Tooltip");
7
6
  const getInertProps_1 = require("../../utils/getInertProps");
8
7
  const CardActionContext_1 = require("./CardActionContext");
@@ -12,6 +11,6 @@ const useLogic_1 = require("./useLogic");
12
11
  const Card = (props) => {
13
12
  const { handleActionClick } = (0, useLogic_1.useLogic)(props);
14
13
  const { isDisabled, mainActions: MainActions, content, header, disabledReason, secondaryActions, } = props;
15
- return ((0, jsx_runtime_1.jsx)(CardActionContext_1.CardActionContextProvider, { onActionClick: handleActionClick, isDisabledCard: isDisabled, children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: isDisabled && disabledReason, withoutContainer: !isDisabled, placement: "top", componentsProps: { popper: { disablePortal: true } }, children: (0, jsx_runtime_1.jsx)(Paper_1.Paper, { variant: "outlined", ...(0, getInertProps_1.getInertProps)(isDisabled), children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [header && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(styles_1.CardHeader, { children: [(0, jsx_runtime_1.jsx)(styles_1.HeaderWrapper, { children: header }), secondaryActions && ((0, jsx_runtime_1.jsx)(SecondaryActionButton_1.SecondaryActionButton, { renderActions: secondaryActions }))] }), (0, jsx_runtime_1.jsx)(styles_1.StyledDivider, {})] })), content, MainActions && (0, jsx_runtime_1.jsx)(MainActions, {})] }) }) }) }));
14
+ return ((0, jsx_runtime_1.jsx)(CardActionContext_1.CardActionContextProvider, { onActionClick: handleActionClick, isDisabledCard: isDisabled, children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, { title: isDisabled && disabledReason, withoutContainer: !isDisabled, placement: "top", componentsProps: { popper: { disablePortal: true } }, children: (0, jsx_runtime_1.jsx)(styles_1.StyledPaper, { variant: "outlined", ...(0, getInertProps_1.getInertProps)(isDisabled), children: (0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { children: [header && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(styles_1.CardHeader, { children: [(0, jsx_runtime_1.jsx)(styles_1.HeaderWrapper, { children: header }), secondaryActions && ((0, jsx_runtime_1.jsx)(SecondaryActionButton_1.SecondaryActionButton, { renderActions: secondaryActions }))] }), (0, jsx_runtime_1.jsx)(styles_1.StyledDivider, {})] })), content, MainActions && (0, jsx_runtime_1.jsx)(MainActions, {})] }) }) }) }));
16
15
  };
17
16
  exports.Card = Card;
@@ -14,3 +14,6 @@ export declare const HeaderWrapper: import("@emotion/styled/dist/declarations/sr
14
14
  theme?: import("@emotion/react").Theme | undefined;
15
15
  as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
16
16
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
17
+ export declare const StyledPaper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<Omit<import("../../Paper").PaperProps, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
18
+ theme?: import("@emotion/react").Theme | undefined;
19
+ }, {}, {}>;
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HeaderWrapper = exports.CardHeader = exports.StyledDivider = exports.Wrapper = void 0;
3
+ exports.StyledPaper = exports.HeaderWrapper = exports.CardHeader = exports.StyledDivider = exports.Wrapper = void 0;
4
4
  const Divider_1 = require("../../Divider");
5
+ const Paper_1 = require("../../Paper");
5
6
  const styled_1 = require("../../styled");
6
7
  exports.Wrapper = styled_1.styled.div `
8
+ display: flex;
9
+ flex-direction: column;
10
+
11
+ height: 100%;
7
12
  padding: ${({ theme }) => theme.spacing(4, 5)};
8
13
 
9
14
  ${({ theme }) => theme.breakpoints.down('sm')} {
@@ -23,3 +28,6 @@ exports.HeaderWrapper = styled_1.styled.div `
23
28
  overflow: hidden;
24
29
  flex: 1;
25
30
  `;
31
+ exports.StyledPaper = (0, styled_1.styled)(Paper_1.Paper) `
32
+ height: 100%;
33
+ `;
@@ -8,5 +8,6 @@ exports.Wrapper = styled_1.styled.div `
8
8
  grid-auto-flow: column;
9
9
  gap: ${({ theme }) => theme.spacing(3)};
10
10
 
11
+ margin-top: auto;
11
12
  padding-top: ${({ theme }) => theme.spacing(6)};
12
13
  `;
@@ -0,0 +1,23 @@
1
+ import { type ReactNode } from 'react';
2
+ export type FormControlContextProps = {
3
+ /**
4
+ * Размер элементов формы
5
+ */
6
+ size?: 'small' | 'medium';
7
+ /**
8
+ * Включает/отключает резервирование места под helperText
9
+ */
10
+ hideHelperText?: boolean;
11
+ };
12
+ export type FormControlProviderProps = Partial<FormControlContextProps> & {
13
+ children: ReactNode;
14
+ };
15
+ /**
16
+ * Контекст для управления состоянием и конфигурацией элементов формы.
17
+ */
18
+ export declare const FormControlContext: import("react").Context<FormControlContextProps | undefined>;
19
+ /**
20
+ * Провайдер контекста для группы элементов формы.
21
+ * Оборачивает группу элементов предоставляет им общую конфигурацию.
22
+ */
23
+ export declare const FormControlProvider: ({ children, size, hideHelperText, }: FormControlProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormControlProvider = exports.FormControlContext = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ /**
7
+ * Контекст для управления состоянием и конфигурацией элементов формы.
8
+ */
9
+ exports.FormControlContext = (0, react_1.createContext)(undefined);
10
+ /**
11
+ * Провайдер контекста для группы элементов формы.
12
+ * Оборачивает группу элементов предоставляет им общую конфигурацию.
13
+ */
14
+ const FormControlProvider = ({ children, size, hideHelperText, }) => {
15
+ return ((0, jsx_runtime_1.jsx)(exports.FormControlContext.Provider, { value: { size, hideHelperText }, children: children }));
16
+ };
17
+ exports.FormControlProvider = FormControlProvider;
@@ -0,0 +1 @@
1
+ export * from './FormControlProvider';
@@ -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("./FormControlProvider"), exports);
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useFormFieldProps = void 0;
4
+ const react_1 = require("react");
4
5
  const react_hook_form_1 = require("react-hook-form");
5
6
  const useForwardedRef_1 = require("../../components/useForwardedRef");
7
+ const FormControlProvider_1 = require("../FormControlProvider");
6
8
  const useFormFieldErrorProps_1 = require("../useFormFieldErrorProps");
7
9
  const useFormInputProps_1 = require("../useFormInputProps");
8
10
  /**
@@ -14,9 +16,11 @@ const useFormFieldProps = (props) => {
14
16
  disabled: undefined,
15
17
  });
16
18
  const ref = (0, useForwardedRef_1.useForwardedRef)(field.ref);
19
+ const contextProps = (0, react_1.useContext)(FormControlProvider_1.FormControlContext);
17
20
  const inputProps = (0, useFormInputProps_1.useFormInputProps)(props);
18
21
  const errorProps = (0, useFormFieldErrorProps_1.useFormFieldErrorProps)(fieldState);
19
22
  return {
23
+ ...contextProps,
20
24
  ...field,
21
25
  ...inputProps,
22
26
  ...errorProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.21.3",
3
+ "version": "4.22.1",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {