@astral/ui 4.0.0-alpha.32 → 4.0.0-alpha.33

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.
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { InputGroupProps } from './types';
3
+ export declare const InputGroup: ({ children, columns }: InputGroupProps) => JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { InputsWrapper } from './styles';
3
+ import { useLogic } from './useLogic';
4
+ export const InputGroup = ({ children, columns }) => {
5
+ const { gridColumnTemplate } = useLogic({ children, columns });
6
+ return (_jsx(InputsWrapper, { "$columnsTemplate": gridColumnTemplate(), children: children }));
7
+ };
@@ -0,0 +1,2 @@
1
+ export * from './InputGroup';
2
+ export type { InputGroupProps } from './types';
@@ -0,0 +1 @@
1
+ export * from './InputGroup';
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const InputsWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ } & {
6
+ $columnsTemplate: string;
7
+ }, import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {}>;
@@ -0,0 +1,88 @@
1
+ import { formControlClasses, inputBaseClasses } from '@mui/material';
2
+ import { styled } from '../styles';
3
+ export const InputsWrapper = styled.fieldset `
4
+ display: grid;
5
+ grid-template-columns: ${({ $columnsTemplate }) => $columnsTemplate};
6
+
7
+ margin-inline: 0;
8
+ padding: 0;
9
+
10
+ border: unset;
11
+
12
+ & .${formControlClasses.root} {
13
+ width: 100%;
14
+
15
+ .${inputBaseClasses.root} {
16
+ position: relative;
17
+ z-index: 2;
18
+
19
+ border-radius: 0;
20
+
21
+ &.${inputBaseClasses.focused} {
22
+ z-index: 4;
23
+ }
24
+ }
25
+ }
26
+
27
+ /* Скругления только крайних инпутов */
28
+ & > :first-child .${inputBaseClasses.root} {
29
+ border-top-left-radius: ${({ theme }) => theme.shape.medium};
30
+ border-bottom-left-radius: ${({ theme }) => theme.shape.medium};
31
+
32
+ &.${inputBaseClasses.disabled} {
33
+ z-index: 1;
34
+
35
+ &::after {
36
+ content: '';
37
+
38
+ position: absolute;
39
+ right: 0;
40
+
41
+ width: 1px;
42
+ height: 100%;
43
+
44
+ background-color: ${({ theme }) => theme.palette.grey[500]};
45
+ }
46
+ }
47
+ }
48
+
49
+ & > :last-child .${inputBaseClasses.root} {
50
+ border-top-right-radius: ${({ theme }) => theme.shape.medium};
51
+ border-bottom-right-radius: ${({ theme }) => theme.shape.medium};
52
+ }
53
+
54
+ & > :not(:first-child) .${inputBaseClasses.root} {
55
+ &.${inputBaseClasses.disabled} {
56
+ z-index: 1;
57
+
58
+
59
+ &::after {
60
+ content: '';
61
+
62
+ position: absolute;
63
+ left: 0;
64
+
65
+ width: 1px;
66
+ height: 100%;
67
+
68
+ background-color: ${({ theme }) => theme.palette.grey[500]};
69
+ }
70
+ }
71
+
72
+ }
73
+
74
+ & > :not(:last-child) .${inputBaseClasses.root} {
75
+ width: auto;
76
+ margin-right: -2px;
77
+
78
+ &:hover {
79
+ z-index: 3;
80
+
81
+ &.${inputBaseClasses.disabled} {
82
+ z-index: 1;
83
+ }
84
+ }
85
+ }
86
+
87
+
88
+ `;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ export type InputGroupProps = {
3
+ children: ReactNode;
4
+ /**
5
+ * Определяет шаблон колонок для grid группы инпутов
6
+ * @example
7
+ * columns={['300px', '1fr', '30%]}
8
+ */
9
+ columns?: string[];
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,6 @@
1
+ import type { InputGroupProps } from '../types';
2
+ type UseLogicParams = InputGroupProps;
3
+ export declare const useLogic: ({ children, columns }: UseLogicParams) => {
4
+ gridColumnTemplate: () => string;
5
+ };
6
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Children } from 'react';
2
+ export const useLogic = ({ children, columns }) => {
3
+ const gridColumnTemplate = () => {
4
+ if (columns) {
5
+ return columns.join(' ');
6
+ }
7
+ const childrenCount = Children.count(children);
8
+ return `repeat(${childrenCount}, 1fr)`;
9
+ };
10
+ return { gridColumnTemplate };
11
+ };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { InputGroupProps } from './types';
3
+ export declare const InputGroup: ({ children, columns }: InputGroupProps) => JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputGroup = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const styles_1 = require("./styles");
6
+ const useLogic_1 = require("./useLogic");
7
+ const InputGroup = ({ children, columns }) => {
8
+ const { gridColumnTemplate } = (0, useLogic_1.useLogic)({ children, columns });
9
+ return ((0, jsx_runtime_1.jsx)(styles_1.InputsWrapper, { "$columnsTemplate": gridColumnTemplate(), children: children }));
10
+ };
11
+ exports.InputGroup = InputGroup;
@@ -0,0 +1,2 @@
1
+ export * from './InputGroup';
2
+ export type { InputGroupProps } from './types';
@@ -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("./InputGroup"), exports);
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const InputsWrapper: import("@emotion/styled").StyledComponent<{
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ } & {
6
+ $columnsTemplate: string;
7
+ }, import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {}>;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputsWrapper = void 0;
4
+ const material_1 = require("@mui/material");
5
+ const styles_1 = require("../styles");
6
+ exports.InputsWrapper = styles_1.styled.fieldset `
7
+ display: grid;
8
+ grid-template-columns: ${({ $columnsTemplate }) => $columnsTemplate};
9
+
10
+ margin-inline: 0;
11
+ padding: 0;
12
+
13
+ border: unset;
14
+
15
+ & .${material_1.formControlClasses.root} {
16
+ width: 100%;
17
+
18
+ .${material_1.inputBaseClasses.root} {
19
+ position: relative;
20
+ z-index: 2;
21
+
22
+ border-radius: 0;
23
+
24
+ &.${material_1.inputBaseClasses.focused} {
25
+ z-index: 4;
26
+ }
27
+ }
28
+ }
29
+
30
+ /* Скругления только крайних инпутов */
31
+ & > :first-child .${material_1.inputBaseClasses.root} {
32
+ border-top-left-radius: ${({ theme }) => theme.shape.medium};
33
+ border-bottom-left-radius: ${({ theme }) => theme.shape.medium};
34
+
35
+ &.${material_1.inputBaseClasses.disabled} {
36
+ z-index: 1;
37
+
38
+ &::after {
39
+ content: '';
40
+
41
+ position: absolute;
42
+ right: 0;
43
+
44
+ width: 1px;
45
+ height: 100%;
46
+
47
+ background-color: ${({ theme }) => theme.palette.grey[500]};
48
+ }
49
+ }
50
+ }
51
+
52
+ & > :last-child .${material_1.inputBaseClasses.root} {
53
+ border-top-right-radius: ${({ theme }) => theme.shape.medium};
54
+ border-bottom-right-radius: ${({ theme }) => theme.shape.medium};
55
+ }
56
+
57
+ & > :not(:first-child) .${material_1.inputBaseClasses.root} {
58
+ &.${material_1.inputBaseClasses.disabled} {
59
+ z-index: 1;
60
+
61
+
62
+ &::after {
63
+ content: '';
64
+
65
+ position: absolute;
66
+ left: 0;
67
+
68
+ width: 1px;
69
+ height: 100%;
70
+
71
+ background-color: ${({ theme }) => theme.palette.grey[500]};
72
+ }
73
+ }
74
+
75
+ }
76
+
77
+ & > :not(:last-child) .${material_1.inputBaseClasses.root} {
78
+ width: auto;
79
+ margin-right: -2px;
80
+
81
+ &:hover {
82
+ z-index: 3;
83
+
84
+ &.${material_1.inputBaseClasses.disabled} {
85
+ z-index: 1;
86
+ }
87
+ }
88
+ }
89
+
90
+
91
+ `;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ export type InputGroupProps = {
3
+ children: ReactNode;
4
+ /**
5
+ * Определяет шаблон колонок для grid группы инпутов
6
+ * @example
7
+ * columns={['300px', '1fr', '30%]}
8
+ */
9
+ columns?: string[];
10
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './useLogic';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useLogic"), exports);
@@ -0,0 +1,6 @@
1
+ import type { InputGroupProps } from '../types';
2
+ type UseLogicParams = InputGroupProps;
3
+ export declare const useLogic: ({ children, columns }: UseLogicParams) => {
4
+ gridColumnTemplate: () => string;
5
+ };
6
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLogic = void 0;
4
+ const react_1 = require("react");
5
+ const useLogic = ({ children, columns }) => {
6
+ const gridColumnTemplate = () => {
7
+ if (columns) {
8
+ return columns.join(' ');
9
+ }
10
+ const childrenCount = react_1.Children.count(children);
11
+ return `repeat(${childrenCount}, 1fr)`;
12
+ };
13
+ return { gridColumnTemplate };
14
+ };
15
+ exports.useLogic = useLogic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astral/ui",
3
- "version": "4.0.0-alpha.32",
3
+ "version": "4.0.0-alpha.33",
4
4
  "browser": "./index.js",
5
5
  "main": "./node/index.js",
6
6
  "dependencies": {