@de-kit/st-ui 0.1.1 → 0.1.2
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/README.md +11 -9
- package/dist/components/button/button.cjs +3 -4
- package/dist/components/button/button.cjs.map +1 -1
- package/dist/components/button/button.d.cts +4 -5
- package/dist/components/button/button.d.ts +4 -5
- package/dist/components/button/button.js +3 -4
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/button.scss +13 -12
- package/dist/components/button/index.d.cts +2 -2
- package/dist/components/button/index.d.ts +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,20 +35,22 @@ import {
|
|
|
35
35
|
|
|
36
36
|
```tsx
|
|
37
37
|
<Button onClick={save}>Сохранить</Button>
|
|
38
|
-
<Button outline>Отмена</Button>
|
|
39
|
-
<Button
|
|
38
|
+
<Button variant="outline">Отмена</Button>
|
|
39
|
+
<Button variant="link" disabled>Скрыть</Button>
|
|
40
40
|
<Button href="/prices">Тарифы</Button>
|
|
41
|
+
<Button size="sm">Маленькая</Button>
|
|
42
|
+
<Button size="lg">Крупная</Button>
|
|
41
43
|
<Button fullWidth>Дальше</Button>
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
| Prop
|
|
45
|
-
|
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `fullWidth`
|
|
49
|
-
| `href`
|
|
46
|
+
| Prop | По умолчанию | |
|
|
47
|
+
| ----------- | ------------ | -------------------------------------------------- |
|
|
48
|
+
| `variant` | `default` | `default` заливка, `outline` обводка, `link` текст |
|
|
49
|
+
| `size` | `md` | `sm` компактная, `md` обычная, `lg` крупная |
|
|
50
|
+
| `fullWidth` | `false` | ширина 100%, не зависит от `size` |
|
|
51
|
+
| `href` | — | рендер `<a>`, не `<Link>` |
|
|
50
52
|
|
|
51
|
-
`link` — это `font-weight: 400
|
|
53
|
+
`variant="link"` — это вид кнопки (`font-weight: 400`), не тип элемента. Ссылка — отдельный проп `href`.
|
|
52
54
|
|
|
53
55
|
## Остальные
|
|
54
56
|
|
|
@@ -4,13 +4,12 @@ require("./button.scss");
|
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
// src/components/button/button.tsx
|
|
6
6
|
const styleKeys = [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"variant",
|
|
8
|
+
"size",
|
|
9
9
|
"fullWidth",
|
|
10
|
-
"link",
|
|
11
10
|
"className"
|
|
12
11
|
];
|
|
13
|
-
const getClassName = ({
|
|
12
|
+
const getClassName = ({ variant = "default", size = "md", fullWidth = false, className, disabled }) => require_cn.cn("button", className, `button--${variant}`, `button--${size}`, require_cn.when(fullWidth, "button--full-width"), require_cn.when(disabled, "button--disabled"));
|
|
14
13
|
const omitStyleProps = (props) => {
|
|
15
14
|
const next = {};
|
|
16
15
|
const skipped = new Set(styleKeys);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.cjs","names":["cn","when","forwardRef"],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport './button.scss';\n\
|
|
1
|
+
{"version":3,"file":"button.cjs","names":["cn","when","forwardRef"],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport './button.scss';\n\nexport type ButtonVariant = 'default' | 'outline' | 'link';\nexport type ButtonSize = 'sm' | 'md' | 'lg';\n\ninterface ButtonStyleProps {\n variant?: ButtonVariant;\n size?: ButtonSize;\n fullWidth?: boolean;\n className?: string;\n children?: ReactNode;\n}\n\nexport interface ButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement>, ButtonStyleProps {\n href?: undefined;\n}\n\nexport interface ButtonLinkProps\n extends\n Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,\n ButtonStyleProps {\n href: string;\n}\n\nexport type ButtonComponentProps = ButtonProps | ButtonLinkProps;\n\nconst styleKeys = ['variant', 'size', 'fullWidth', 'className'] as const;\n\nconst getClassName = ({\n variant = 'default',\n size = 'md',\n fullWidth = false,\n className,\n disabled,\n}: ButtonStyleProps & { disabled?: boolean }) =>\n cn(\n 'button',\n className,\n `button--${variant}`,\n `button--${size}`,\n when(fullWidth, 'button--full-width'),\n when(disabled, 'button--disabled'),\n );\n\nconst omitStyleProps = <T extends ButtonStyleProps>(\n props: T,\n): Omit<T, (typeof styleKeys)[number]> => {\n const next: Record<string, unknown> = {};\n const skipped = new Set<string>(styleKeys);\n\n for (const [key, value] of Object.entries(props)) {\n if (!skipped.has(key)) next[key] = value;\n }\n\n return next as Omit<T, (typeof styleKeys)[number]>;\n};\n\nexport const Button = forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n ButtonComponentProps\n>(function Button(props, ref) {\n const className = getClassName(props);\n const { children, href, ...domProps } = omitStyleProps(props);\n\n if (typeof href === 'string') {\n return (\n <a\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n className={className}\n {...(domProps as AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {children}\n </a>\n );\n }\n\n const {\n type = 'button',\n disabled,\n onClick,\n ...buttonProps\n } = domProps as ButtonHTMLAttributes<HTMLButtonElement>;\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (disabled) return;\n onClick?.(event);\n };\n\n return (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n className={className}\n type={type}\n disabled={disabled}\n onClick={handleClick}\n {...buttonProps}\n >\n {children}\n </button>\n );\n});\n"],"mappings":";;;;;AAqCA,MAAM,YAAY;CAAC;CAAW;CAAQ;CAAa;AAAW;AAE9D,MAAM,gBAAgB,EACpB,UAAU,WACV,OAAO,MACP,YAAY,OACZ,WACA,eAEAA,WAAAA,GACE,UACA,WACA,WAAW,WACX,WAAW,QACXC,WAAAA,KAAK,WAAW,oBAAoB,GACpCA,WAAAA,KAAK,UAAU,kBAAkB,CACnC;AAEF,MAAM,kBACJ,UACwC;CACxC,MAAM,OAAgC,CAAC;CACvC,MAAM,UAAU,IAAI,IAAY,SAAS;CAEzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,IAAI,CAAC,QAAQ,IAAI,GAAG,GAAG,KAAK,OAAO;CAGrC,OAAO;AACT;AAEA,MAAa,UAAA,GAASC,MAAAA,WAAAA,CAGpB,SAAS,OAAO,OAAO,KAAK;CAC5B,MAAM,YAAY,aAAa,KAAK;CACpC,MAAM,EAAE,UAAU,MAAM,GAAG,aAAa,eAAe,KAAK;CAE5D,IAAI,OAAO,SAAS,UAClB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EACO;EACC;EACK;EACX,GAAK;EAEJ;CACA,CAAA;CAIP,MAAM,EACJ,OAAO,UACP,UACA,SACA,GAAG,gBACD;CAEJ,MAAM,eAAoD,UAAS;EACjE,IAAI,UAAU;EACd,UAAU,KAAK;CACjB;CAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;EACO;EACM;EACL;EACI;EACV,SAAS;EACT,GAAI;EAEH;CACK,CAAA;AAEZ,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type ButtonVariant = 'default' | 'outline' | 'link';
|
|
3
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
2
4
|
interface ButtonStyleProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
withIcon?: boolean;
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: ButtonSize;
|
|
6
7
|
fullWidth?: boolean;
|
|
7
|
-
/** Визуальный вес ссылки (font-weight: 400), не тип элемента. */
|
|
8
|
-
link?: boolean;
|
|
9
8
|
className?: string;
|
|
10
9
|
children?: ReactNode;
|
|
11
10
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type ButtonVariant = 'default' | 'outline' | 'link';
|
|
3
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
2
4
|
interface ButtonStyleProps {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
withIcon?: boolean;
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: ButtonSize;
|
|
6
7
|
fullWidth?: boolean;
|
|
7
|
-
/** Визуальный вес ссылки (font-weight: 400), не тип элемента. */
|
|
8
|
-
link?: boolean;
|
|
9
8
|
className?: string;
|
|
10
9
|
children?: ReactNode;
|
|
11
10
|
}
|
|
@@ -4,13 +4,12 @@ import "./button.scss";
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
// src/components/button/button.tsx
|
|
6
6
|
const styleKeys = [
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"variant",
|
|
8
|
+
"size",
|
|
9
9
|
"fullWidth",
|
|
10
|
-
"link",
|
|
11
10
|
"className"
|
|
12
11
|
];
|
|
13
|
-
const getClassName = ({
|
|
12
|
+
const getClassName = ({ variant = "default", size = "md", fullWidth = false, className, disabled }) => cn("button", className, `button--${variant}`, `button--${size}`, when(fullWidth, "button--full-width"), when(disabled, "button--disabled"));
|
|
14
13
|
const omitStyleProps = (props) => {
|
|
15
14
|
const next = {};
|
|
16
15
|
const skipped = new Set(styleKeys);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport './button.scss';\n\
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type MouseEventHandler,\n type ReactNode,\n type Ref,\n} from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport './button.scss';\n\nexport type ButtonVariant = 'default' | 'outline' | 'link';\nexport type ButtonSize = 'sm' | 'md' | 'lg';\n\ninterface ButtonStyleProps {\n variant?: ButtonVariant;\n size?: ButtonSize;\n fullWidth?: boolean;\n className?: string;\n children?: ReactNode;\n}\n\nexport interface ButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement>, ButtonStyleProps {\n href?: undefined;\n}\n\nexport interface ButtonLinkProps\n extends\n Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>,\n ButtonStyleProps {\n href: string;\n}\n\nexport type ButtonComponentProps = ButtonProps | ButtonLinkProps;\n\nconst styleKeys = ['variant', 'size', 'fullWidth', 'className'] as const;\n\nconst getClassName = ({\n variant = 'default',\n size = 'md',\n fullWidth = false,\n className,\n disabled,\n}: ButtonStyleProps & { disabled?: boolean }) =>\n cn(\n 'button',\n className,\n `button--${variant}`,\n `button--${size}`,\n when(fullWidth, 'button--full-width'),\n when(disabled, 'button--disabled'),\n );\n\nconst omitStyleProps = <T extends ButtonStyleProps>(\n props: T,\n): Omit<T, (typeof styleKeys)[number]> => {\n const next: Record<string, unknown> = {};\n const skipped = new Set<string>(styleKeys);\n\n for (const [key, value] of Object.entries(props)) {\n if (!skipped.has(key)) next[key] = value;\n }\n\n return next as Omit<T, (typeof styleKeys)[number]>;\n};\n\nexport const Button = forwardRef<\n HTMLButtonElement | HTMLAnchorElement,\n ButtonComponentProps\n>(function Button(props, ref) {\n const className = getClassName(props);\n const { children, href, ...domProps } = omitStyleProps(props);\n\n if (typeof href === 'string') {\n return (\n <a\n ref={ref as Ref<HTMLAnchorElement>}\n href={href}\n className={className}\n {...(domProps as AnchorHTMLAttributes<HTMLAnchorElement>)}\n >\n {children}\n </a>\n );\n }\n\n const {\n type = 'button',\n disabled,\n onClick,\n ...buttonProps\n } = domProps as ButtonHTMLAttributes<HTMLButtonElement>;\n\n const handleClick: MouseEventHandler<HTMLButtonElement> = event => {\n if (disabled) return;\n onClick?.(event);\n };\n\n return (\n <button\n ref={ref as Ref<HTMLButtonElement>}\n className={className}\n type={type}\n disabled={disabled}\n onClick={handleClick}\n {...buttonProps}\n >\n {children}\n </button>\n );\n});\n"],"mappings":";;;;;AAqCA,MAAM,YAAY;CAAC;CAAW;CAAQ;CAAa;AAAW;AAE9D,MAAM,gBAAgB,EACpB,UAAU,WACV,OAAO,MACP,YAAY,OACZ,WACA,eAEA,GACE,UACA,WACA,WAAW,WACX,WAAW,QACX,KAAK,WAAW,oBAAoB,GACpC,KAAK,UAAU,kBAAkB,CACnC;AAEF,MAAM,kBACJ,UACwC;CACxC,MAAM,OAAgC,CAAC;CACvC,MAAM,UAAU,IAAI,IAAY,SAAS;CAEzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAC7C,IAAI,CAAC,QAAQ,IAAI,GAAG,GAAG,KAAK,OAAO;CAGrC,OAAO;AACT;AAEA,MAAa,SAAS,WAGpB,SAAS,OAAO,OAAO,KAAK;CAC5B,MAAM,YAAY,aAAa,KAAK;CACpC,MAAM,EAAE,UAAU,MAAM,GAAG,aAAa,eAAe,KAAK;CAE5D,IAAI,OAAO,SAAS,UAClB,OACE,oBAAC,KAAD;EACO;EACC;EACK;EACX,GAAK;EAEJ;CACA,CAAA;CAIP,MAAM,EACJ,OAAO,UACP,UACA,SACA,GAAG,gBACD;CAEJ,MAAM,eAAoD,UAAS;EACjE,IAAI,UAAU;EACd,UAAU,KAAK;CACjB;CAEA,OACE,oBAAC,UAAD;EACO;EACM;EACL;EACI;EACV,SAAS;EACT,GAAI;EAEH;CACK,CAAA;AAEZ,CAAC"}
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
background-color: transparent;
|
|
41
41
|
color: var(--color-black);
|
|
42
42
|
fill: var(--color-black);
|
|
43
|
-
max-height: 40px;
|
|
44
43
|
border: 2px solid var(--color-black);
|
|
45
44
|
|
|
46
45
|
&:disabled {
|
|
@@ -49,20 +48,21 @@
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
&--
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
&--sm {
|
|
52
|
+
padding: 6px 12px;
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
line-height: 16px;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
&--
|
|
59
|
-
padding:
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
&--lg {
|
|
58
|
+
padding: 14px 24px;
|
|
59
|
+
font-size: 16px;
|
|
60
|
+
line-height: 24px;
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
&--full-width {
|
|
64
|
+
width: 100%;
|
|
65
|
+
justify-content: center;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
&--link {
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
fill: var(--color-black);
|
|
73
73
|
border-radius: 0;
|
|
74
74
|
padding: 0;
|
|
75
|
+
font-weight: 400;
|
|
75
76
|
|
|
76
77
|
&:active,
|
|
77
78
|
&:disabled {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps } from "./button.cjs";
|
|
2
|
-
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps };
|
|
1
|
+
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant } from "./button.cjs";
|
|
2
|
+
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps } from "./button.js";
|
|
2
|
-
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps };
|
|
1
|
+
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant } from "./button.js";
|
|
2
|
+
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps } from "./components/button/button.cjs";
|
|
1
|
+
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant } from "./components/button/button.cjs";
|
|
2
2
|
import "./components/button/index.cjs";
|
|
3
3
|
import { CheckboxInput, CheckboxInputProps } from "./components/checkbox/checkbox.cjs";
|
|
4
4
|
import "./components/checkbox/index.cjs";
|
|
@@ -10,4 +10,4 @@ import { Spinner, SpinnerPosition, SpinnerProps } from "./components/spinner/spi
|
|
|
10
10
|
import "./components/spinner/index.cjs";
|
|
11
11
|
import { TextArea, TextAreaProps } from "./components/textarea/textarea.cjs";
|
|
12
12
|
import "./components/textarea/index.cjs";
|
|
13
|
-
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, CheckboxInput, type CheckboxInputProps, Input, type InputProps, RadioInput, type RadioInputProps, Spinner, type SpinnerPosition, type SpinnerProps, TextArea, type TextAreaProps };
|
|
13
|
+
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, CheckboxInput, type CheckboxInputProps, Input, type InputProps, RadioInput, type RadioInputProps, Spinner, type SpinnerPosition, type SpinnerProps, TextArea, type TextAreaProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps } from "./components/button/button.js";
|
|
1
|
+
import { Button, ButtonComponentProps, ButtonLinkProps, ButtonProps, ButtonSize, ButtonVariant } from "./components/button/button.js";
|
|
2
2
|
import "./components/button/index.js";
|
|
3
3
|
import { CheckboxInput, CheckboxInputProps } from "./components/checkbox/checkbox.js";
|
|
4
4
|
import "./components/checkbox/index.js";
|
|
@@ -10,4 +10,4 @@ import { Spinner, SpinnerPosition, SpinnerProps } from "./components/spinner/spi
|
|
|
10
10
|
import "./components/spinner/index.js";
|
|
11
11
|
import { TextArea, TextAreaProps } from "./components/textarea/textarea.js";
|
|
12
12
|
import "./components/textarea/index.js";
|
|
13
|
-
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, CheckboxInput, type CheckboxInputProps, Input, type InputProps, RadioInput, type RadioInputProps, Spinner, type SpinnerPosition, type SpinnerProps, TextArea, type TextAreaProps };
|
|
13
|
+
export { Button, type ButtonComponentProps, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, CheckboxInput, type CheckboxInputProps, Input, type InputProps, RadioInput, type RadioInputProps, Spinner, type SpinnerPosition, type SpinnerProps, TextArea, type TextAreaProps };
|