@de-kit/st-ui 0.0.0-stage → 0.1.0
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 +73 -2
- package/dist/_virtual/_rolldown/runtime.cjs +22 -0
- package/dist/components/button/button.cjs +49 -0
- package/dist/components/button/button.cjs.map +1 -0
- package/dist/components/button/button.d.cts +21 -0
- package/dist/components/button/button.d.ts +21 -0
- package/dist/components/button/button.js +47 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.module.scss +95 -0
- package/dist/components/button/index.d.cts +2 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/checkbox/checkbox.cjs +29 -0
- package/dist/components/checkbox/checkbox.cjs.map +1 -0
- package/dist/components/checkbox/checkbox.d.cts +8 -0
- package/dist/components/checkbox/checkbox.d.ts +8 -0
- package/dist/components/checkbox/checkbox.js +27 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox.module.scss +110 -0
- package/dist/components/checkbox/index.d.cts +2 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/input/index.d.cts +2 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/input.cjs +20 -0
- package/dist/components/input/input.cjs.map +1 -0
- package/dist/components/input/input.d.cts +7 -0
- package/dist/components/input/input.d.ts +7 -0
- package/dist/components/input/input.js +18 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/input.module.scss +66 -0
- package/dist/components/radio/index.d.cts +2 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.cjs +29 -0
- package/dist/components/radio/radio.cjs.map +1 -0
- package/dist/components/radio/radio.d.cts +7 -0
- package/dist/components/radio/radio.d.ts +7 -0
- package/dist/components/radio/radio.js +27 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio/radio.module.scss +108 -0
- package/dist/components/spinner/index.d.cts +2 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/spinner.cjs +56 -0
- package/dist/components/spinner/spinner.cjs.map +1 -0
- package/dist/components/spinner/spinner.d.cts +13 -0
- package/dist/components/spinner/spinner.d.ts +13 -0
- package/dist/components/spinner/spinner.js +54 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/spinner/spinner.module.scss +12 -0
- package/dist/components/textarea/index.d.cts +2 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea.cjs +30 -0
- package/dist/components/textarea/textarea.cjs.map +1 -0
- package/dist/components/textarea/textarea.d.cts +9 -0
- package/dist/components/textarea/textarea.d.ts +9 -0
- package/dist/components/textarea/textarea.js +28 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/textarea/textarea.module.scss +60 -0
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7 -0
- package/dist/lib/cn.cjs +25 -0
- package/dist/lib/cn.cjs.map +1 -0
- package/dist/lib/cn.js +24 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/styles/global.scss +195 -0
- package/dist/styles/mixins.scss +188 -0
- package/dist/styles/vars.scss +39 -0
- package/package.json +91 -3
package/README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @de-kit/st-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React-компоненты splittest. Стили — SCSS-модули, токены скопированы из `splittest-frontend/src/app/styles`. Tailwind нет.
|
|
4
|
+
|
|
5
|
+
## Подключение
|
|
6
|
+
|
|
7
|
+
В CRA (sass уже стоит):
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import '@de-kit/st-ui/global.scss';
|
|
11
|
+
import {
|
|
12
|
+
Button,
|
|
13
|
+
Input,
|
|
14
|
+
TextArea,
|
|
15
|
+
CheckboxInput,
|
|
16
|
+
RadioInput,
|
|
17
|
+
Spinner,
|
|
18
|
+
} from '@de-kit/st-ui';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`global.scss` — база приложения (body, заголовки, таблицы, `.wrapper`). В чужой странице его не подключать. Шрифт Inter библиотека не везёт, его по-прежнему грузит фронтенд.
|
|
22
|
+
|
|
23
|
+
Свои экраны могут брать те же переменные:
|
|
24
|
+
|
|
25
|
+
```scss
|
|
26
|
+
@import '@de-kit/st-ui/vars.scss';
|
|
27
|
+
@import '@de-kit/st-ui/mixins.scss';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Компонентный css собирает sass-loader приложения: js импортирует `*.module.scss`, классы хешируются на стороне хоста.
|
|
31
|
+
|
|
32
|
+
## Кнопка
|
|
33
|
+
|
|
34
|
+
Пропсы как в `shared/components/button`, без `react-router`.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Button onClick={save}>Сохранить</Button>
|
|
38
|
+
<Button outline>Отмена</Button>
|
|
39
|
+
<Button transparent disabled>Скрыть</Button>
|
|
40
|
+
<Button href="/prices">Тарифы</Button>
|
|
41
|
+
<Button fullWidth>Дальше</Button>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Prop | По умолчанию | |
|
|
45
|
+
| ---------------------------------------------------------- | ------------ | ------------------------------------------ |
|
|
46
|
+
| `transparent` / `outline` / `empty` / `link` / `nopadding` | `false` | варианты из `index.module.scss` приложения |
|
|
47
|
+
| `withIcon` | `true` | как в приложении: левый паддинг под иконку |
|
|
48
|
+
| `fullWidth` | `false` | `width: 100%` |
|
|
49
|
+
| `href` | — | рендер `<a>`, не `<Link>` |
|
|
50
|
+
|
|
51
|
+
`link` — это `font-weight: 400`, не тип элемента.
|
|
52
|
+
|
|
53
|
+
## Остальные
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Input recommended />
|
|
57
|
+
<Input error />
|
|
58
|
+
<TextArea maxLength={200} />
|
|
59
|
+
<TextArea maxLength={200} hideCounter />
|
|
60
|
+
<CheckboxInput title="18-24" />
|
|
61
|
+
<RadioInput name="age" title="18–24" />
|
|
62
|
+
<Spinner position="top" />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`hideCounter` заменяет опечатку `noMaxMoty`. `CheckboxInput` сам ставит `id`, если его не передали. Дефис в `title` чекбокса по-прежнему меняется на тире.
|
|
66
|
+
|
|
67
|
+
## Разработка
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm install
|
|
71
|
+
pnpm dev # Storybook, :6006
|
|
72
|
+
pnpm test
|
|
73
|
+
pnpm build # dist: js + d.ts + scss рядом с модулями
|
|
74
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_cn = require("../../lib/cn.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let src_components_button_button_module_scss = require("./button.module.scss");
|
|
5
|
+
src_components_button_button_module_scss = require_runtime.__toESM(src_components_button_button_module_scss, 1);
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
// src/components/button/button.tsx
|
|
8
|
+
const styleKeys = [
|
|
9
|
+
"outline",
|
|
10
|
+
"withIcon",
|
|
11
|
+
"fullWidth",
|
|
12
|
+
"link",
|
|
13
|
+
"className"
|
|
14
|
+
];
|
|
15
|
+
const getClassName = ({ withIcon = true, outline, className, fullWidth = false, link = false, disabled }) => require_cn.cn(src_components_button_button_module_scss.default.button, className, require_cn.when(outline, src_components_button_button_module_scss.default.outline), require_cn.when(withIcon, src_components_button_button_module_scss.default.withIcon), require_cn.when(fullWidth, src_components_button_button_module_scss.default.fullWidth), require_cn.when(link, src_components_button_button_module_scss.default.link), require_cn.when(disabled, src_components_button_button_module_scss.default.disabled));
|
|
16
|
+
const omitStyleProps = (props) => {
|
|
17
|
+
const next = {};
|
|
18
|
+
const skipped = new Set(styleKeys);
|
|
19
|
+
for (const [key, value] of Object.entries(props)) if (!skipped.has(key)) next[key] = value;
|
|
20
|
+
return next;
|
|
21
|
+
};
|
|
22
|
+
const Button = (0, react.forwardRef)(function Button(props, ref) {
|
|
23
|
+
const className = getClassName(props);
|
|
24
|
+
const { children, href, ...domProps } = omitStyleProps(props);
|
|
25
|
+
if (typeof href === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
26
|
+
ref,
|
|
27
|
+
href,
|
|
28
|
+
className,
|
|
29
|
+
...domProps,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
const { type = "button", disabled, onClick, ...buttonProps } = domProps;
|
|
33
|
+
const handleClick = (event) => {
|
|
34
|
+
if (disabled) return;
|
|
35
|
+
onClick?.(event);
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
38
|
+
ref,
|
|
39
|
+
className,
|
|
40
|
+
type,
|
|
41
|
+
disabled,
|
|
42
|
+
onClick: handleClick,
|
|
43
|
+
...buttonProps,
|
|
44
|
+
children
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
exports.Button = Button;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.cjs","names":["cn","styles","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 styles from './button.module.scss';\n\ninterface ButtonStyleProps {\n outline?: boolean;\n /** В приложении по умолчанию true: левый паддинг под иконку. */\n withIcon?: boolean;\n fullWidth?: boolean;\n /** Визуальный вес ссылки (font-weight: 400), не тип элемента. */\n link?: 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 = [\n 'outline',\n 'withIcon',\n 'fullWidth',\n 'link',\n 'className',\n] as const;\n\nconst getClassName = ({\n withIcon = true,\n outline,\n className,\n fullWidth = false,\n link = false,\n disabled,\n}: ButtonStyleProps & { disabled?: boolean }) =>\n cn(\n styles.button,\n className,\n when(outline, styles.outline),\n when(withIcon, styles.withIcon),\n when(fullWidth, styles.fullWidth),\n when(link, styles.link),\n when(disabled, styles.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;CAChB;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gBAAgB,EACpB,WAAW,MACX,SACA,WACA,YAAY,OACZ,OAAO,OACP,eAEAA,WAAAA,GACEC,yCAAAA,QAAO,QACP,WACAC,WAAAA,KAAK,SAASD,yCAAAA,QAAO,OAAO,GAC5BC,WAAAA,KAAK,UAAUD,yCAAAA,QAAO,QAAQ,GAC9BC,WAAAA,KAAK,WAAWD,yCAAAA,QAAO,SAAS,GAChCC,WAAAA,KAAK,MAAMD,yCAAAA,QAAO,IAAI,GACtBC,WAAAA,KAAK,UAAUD,yCAAAA,QAAO,QAAQ,CAChC;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,GAASE,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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
interface ButtonStyleProps {
|
|
3
|
+
outline?: boolean;
|
|
4
|
+
/** В приложении по умолчанию true: левый паддинг под иконку. */
|
|
5
|
+
withIcon?: boolean;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
/** Визуальный вес ссылки (font-weight: 400), не тип элемента. */
|
|
8
|
+
link?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, ButtonStyleProps {
|
|
13
|
+
href?: undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface ButtonLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>, ButtonStyleProps {
|
|
16
|
+
href: string;
|
|
17
|
+
}
|
|
18
|
+
export type ButtonComponentProps = ButtonProps | ButtonLinkProps;
|
|
19
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonComponentProps & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=button.d.cts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from "react";
|
|
2
|
+
interface ButtonStyleProps {
|
|
3
|
+
outline?: boolean;
|
|
4
|
+
/** В приложении по умолчанию true: левый паддинг под иконку. */
|
|
5
|
+
withIcon?: boolean;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
/** Визуальный вес ссылки (font-weight: 400), не тип элемента. */
|
|
8
|
+
link?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, ButtonStyleProps {
|
|
13
|
+
href?: undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface ButtonLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>, ButtonStyleProps {
|
|
16
|
+
href: string;
|
|
17
|
+
}
|
|
18
|
+
export type ButtonComponentProps = ButtonProps | ButtonLinkProps;
|
|
19
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonComponentProps & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cn, when } from "../../lib/cn.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import styles from "./button.module.scss";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/button/button.tsx
|
|
6
|
+
const styleKeys = [
|
|
7
|
+
"outline",
|
|
8
|
+
"withIcon",
|
|
9
|
+
"fullWidth",
|
|
10
|
+
"link",
|
|
11
|
+
"className"
|
|
12
|
+
];
|
|
13
|
+
const getClassName = ({ withIcon = true, outline, className, fullWidth = false, link = false, disabled }) => cn(styles.button, className, when(outline, styles.outline), when(withIcon, styles.withIcon), when(fullWidth, styles.fullWidth), when(link, styles.link), when(disabled, styles.disabled));
|
|
14
|
+
const omitStyleProps = (props) => {
|
|
15
|
+
const next = {};
|
|
16
|
+
const skipped = new Set(styleKeys);
|
|
17
|
+
for (const [key, value] of Object.entries(props)) if (!skipped.has(key)) next[key] = value;
|
|
18
|
+
return next;
|
|
19
|
+
};
|
|
20
|
+
const Button = forwardRef(function Button(props, ref) {
|
|
21
|
+
const className = getClassName(props);
|
|
22
|
+
const { children, href, ...domProps } = omitStyleProps(props);
|
|
23
|
+
if (typeof href === "string") return /* @__PURE__ */ jsx("a", {
|
|
24
|
+
ref,
|
|
25
|
+
href,
|
|
26
|
+
className,
|
|
27
|
+
...domProps,
|
|
28
|
+
children
|
|
29
|
+
});
|
|
30
|
+
const { type = "button", disabled, onClick, ...buttonProps } = domProps;
|
|
31
|
+
const handleClick = (event) => {
|
|
32
|
+
if (disabled) return;
|
|
33
|
+
onClick?.(event);
|
|
34
|
+
};
|
|
35
|
+
return /* @__PURE__ */ jsx("button", {
|
|
36
|
+
ref,
|
|
37
|
+
className,
|
|
38
|
+
type,
|
|
39
|
+
disabled,
|
|
40
|
+
onClick: handleClick,
|
|
41
|
+
...buttonProps,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
export { Button };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +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 styles from './button.module.scss';\n\ninterface ButtonStyleProps {\n outline?: boolean;\n /** В приложении по умолчанию true: левый паддинг под иконку. */\n withIcon?: boolean;\n fullWidth?: boolean;\n /** Визуальный вес ссылки (font-weight: 400), не тип элемента. */\n link?: 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 = [\n 'outline',\n 'withIcon',\n 'fullWidth',\n 'link',\n 'className',\n] as const;\n\nconst getClassName = ({\n withIcon = true,\n outline,\n className,\n fullWidth = false,\n link = false,\n disabled,\n}: ButtonStyleProps & { disabled?: boolean }) =>\n cn(\n styles.button,\n className,\n when(outline, styles.outline),\n when(withIcon, styles.withIcon),\n when(fullWidth, styles.fullWidth),\n when(link, styles.link),\n when(disabled, styles.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;CAChB;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,gBAAgB,EACpB,WAAW,MACX,SACA,WACA,YAAY,OACZ,OAAO,OACP,eAEA,GACE,OAAO,QACP,WACA,KAAK,SAAS,OAAO,OAAO,GAC5B,KAAK,UAAU,OAAO,QAAQ,GAC9B,KAAK,WAAW,OAAO,SAAS,GAChC,KAAK,MAAM,OAAO,IAAI,GACtB,KAAK,UAAU,OAAO,QAAQ,CAChC;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"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
@import '../../styles/vars.scss';
|
|
2
|
+
|
|
3
|
+
.button {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
width: fit-content;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
padding: 10px 18px;
|
|
9
|
+
border-radius: 30px;
|
|
10
|
+
font-size: 14px;
|
|
11
|
+
line-height: 20px;
|
|
12
|
+
background-color: $colorBlack;
|
|
13
|
+
color: $colorWhite;
|
|
14
|
+
fill: $colorWhite;
|
|
15
|
+
font-weight: bold;
|
|
16
|
+
font-family: $mainFontName;
|
|
17
|
+
border: 2px solid $colorBlack;
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
transition: none;
|
|
21
|
+
gap: 5px;
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
|
|
24
|
+
&.active,
|
|
25
|
+
&.disabled,
|
|
26
|
+
&:active,
|
|
27
|
+
&:disabled {
|
|
28
|
+
background-color: $colorGray;
|
|
29
|
+
color: $colorGrayIcon;
|
|
30
|
+
fill: $colorGrayIcon;
|
|
31
|
+
border-color: $colorGray;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.disabled,
|
|
35
|
+
&:disabled {
|
|
36
|
+
cursor: default;
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
user-select: none;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.outline {
|
|
43
|
+
background-color: transparent;
|
|
44
|
+
color: $colorBlack;
|
|
45
|
+
fill: $colorBlack;
|
|
46
|
+
max-height: 40px;
|
|
47
|
+
border: 2px solid $colorBlack;
|
|
48
|
+
|
|
49
|
+
&:disabled {
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
border: 2px solid $colorBlack;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.fullWidth {
|
|
56
|
+
width: 100%;
|
|
57
|
+
text-align: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.withIcon {
|
|
62
|
+
padding: 8px 18px 8px 14px;
|
|
63
|
+
gap: 5px;
|
|
64
|
+
text-align: left;
|
|
65
|
+
|
|
66
|
+
.icon {
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.link {
|
|
72
|
+
border: none;
|
|
73
|
+
background-color: transparent;
|
|
74
|
+
color: $colorBlack;
|
|
75
|
+
fill: $colorBlack;
|
|
76
|
+
border-radius: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
|
|
79
|
+
&:active,
|
|
80
|
+
&:disabled {
|
|
81
|
+
background-color: transparent;
|
|
82
|
+
color: rgba(0, 0, 0, 0.5);
|
|
83
|
+
fill: rgba(0, 0, 0, 0.5);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.disabled {
|
|
88
|
+
background-color: $colorGray;
|
|
89
|
+
color: $colorGrayIcon;
|
|
90
|
+
fill: $colorGrayIcon;
|
|
91
|
+
border-color: $colorGray;
|
|
92
|
+
cursor: default;
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
user-select: none;
|
|
95
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_cn = require("../../lib/cn.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let src_components_checkbox_checkbox_module_scss = require("./checkbox.module.scss");
|
|
6
|
+
src_components_checkbox_checkbox_module_scss = require_runtime.__toESM(src_components_checkbox_checkbox_module_scss, 1);
|
|
7
|
+
// src/components/checkbox/checkbox.tsx
|
|
8
|
+
const CheckboxInput = (0, react.forwardRef)(function CheckboxInput({ className, id, title, hide, disabled, withCursor = true, ...props }, ref) {
|
|
9
|
+
const autoId = (0, react.useId)();
|
|
10
|
+
const inputId = id ?? autoId;
|
|
11
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12
|
+
className: require_cn.cn(src_components_checkbox_checkbox_module_scss.default.checkbox, className, require_cn.when(hide, src_components_checkbox_checkbox_module_scss.default.hide)),
|
|
13
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
14
|
+
ref,
|
|
15
|
+
type: "checkbox",
|
|
16
|
+
id: inputId,
|
|
17
|
+
disabled,
|
|
18
|
+
className: require_cn.cn(src_components_checkbox_checkbox_module_scss.default.input, require_cn.when(!withCursor, src_components_checkbox_checkbox_module_scss.default.noEvents)),
|
|
19
|
+
...props
|
|
20
|
+
}), title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
21
|
+
className: src_components_checkbox_checkbox_module_scss.default.label,
|
|
22
|
+
htmlFor: inputId,
|
|
23
|
+
children: title.replaceAll("-", "–")
|
|
24
|
+
}) : null]
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
exports.CheckboxInput = CheckboxInput;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=checkbox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.cjs","names":["forwardRef","useId","cn","styles","when"],"sources":["../../../src/components/checkbox/checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, type InputHTMLAttributes } from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport styles from './checkbox.module.scss';\n\nexport interface CheckboxInputProps extends InputHTMLAttributes<HTMLInputElement> {\n title?: string;\n hide?: boolean;\n withCursor?: boolean;\n}\n\nexport const CheckboxInput = forwardRef<HTMLInputElement, CheckboxInputProps>(\n function CheckboxInput(\n { className, id, title, hide, disabled, withCursor = true, ...props },\n ref,\n ) {\n const autoId = useId();\n const inputId = id ?? autoId;\n\n return (\n <div className={cn(styles.checkbox, className, when(hide, styles.hide))}>\n <input\n ref={ref}\n type=\"checkbox\"\n id={inputId}\n disabled={disabled}\n className={cn(styles.input, when(!withCursor, styles.noEvents))}\n {...props}\n />\n {title ? (\n <label className={styles.label} htmlFor={inputId}>\n {title.replaceAll('-', '–')}\n </label>\n ) : null}\n </div>\n );\n },\n);\n"],"mappings":";;;;;;;AAWA,MAAa,iBAAA,GAAgBA,MAAAA,WAAAA,CAC3B,SAAS,cACP,EAAE,WAAW,IAAI,OAAO,MAAM,UAAU,aAAa,MAAM,GAAG,SAC9D,KACA;CACA,MAAM,UAAA,GAASC,MAAAA,MAAAA,CAAM;CACrB,MAAM,UAAU,MAAM;CAEtB,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAWC,WAAAA,GAAGC,6CAAAA,QAAO,UAAU,WAAWC,WAAAA,KAAK,MAAMD,6CAAAA,QAAO,IAAI,CAAC;EAAtE,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GACO;GACL,MAAK;GACL,IAAI;GACM;GACV,WAAWD,WAAAA,GAAGC,6CAAAA,QAAO,OAAOC,WAAAA,KAAK,CAAC,YAAYD,6CAAAA,QAAO,QAAQ,CAAC;GAC9D,GAAI;EACL,CAAA,GACA,QACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GAAO,WAAWA,6CAAAA,QAAO;GAAO,SAAS;GACtC,UAAA,MAAM,WAAW,KAAK,GAAG;EACrB,CAAA,IACL,IACD;;AAET,CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
export interface CheckboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
title?: string;
|
|
4
|
+
hide?: boolean;
|
|
5
|
+
withCursor?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const CheckboxInput: import("react").ForwardRefExoticComponent<CheckboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
//# sourceMappingURL=checkbox.d.cts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
export interface CheckboxInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
title?: string;
|
|
4
|
+
hide?: boolean;
|
|
5
|
+
withCursor?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const CheckboxInput: import("react").ForwardRefExoticComponent<CheckboxInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cn, when } from "../../lib/cn.js";
|
|
2
|
+
import { forwardRef, useId } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import styles from "./checkbox.module.scss";
|
|
5
|
+
// src/components/checkbox/checkbox.tsx
|
|
6
|
+
const CheckboxInput = forwardRef(function CheckboxInput({ className, id, title, hide, disabled, withCursor = true, ...props }, ref) {
|
|
7
|
+
const autoId = useId();
|
|
8
|
+
const inputId = id ?? autoId;
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
10
|
+
className: cn(styles.checkbox, className, when(hide, styles.hide)),
|
|
11
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
12
|
+
ref,
|
|
13
|
+
type: "checkbox",
|
|
14
|
+
id: inputId,
|
|
15
|
+
disabled,
|
|
16
|
+
className: cn(styles.input, when(!withCursor, styles.noEvents)),
|
|
17
|
+
...props
|
|
18
|
+
}), title ? /* @__PURE__ */ jsx("label", {
|
|
19
|
+
className: styles.label,
|
|
20
|
+
htmlFor: inputId,
|
|
21
|
+
children: title.replaceAll("-", "–")
|
|
22
|
+
}) : null]
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
export { CheckboxInput };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","names":[],"sources":["../../../src/components/checkbox/checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, type InputHTMLAttributes } from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport styles from './checkbox.module.scss';\n\nexport interface CheckboxInputProps extends InputHTMLAttributes<HTMLInputElement> {\n title?: string;\n hide?: boolean;\n withCursor?: boolean;\n}\n\nexport const CheckboxInput = forwardRef<HTMLInputElement, CheckboxInputProps>(\n function CheckboxInput(\n { className, id, title, hide, disabled, withCursor = true, ...props },\n ref,\n ) {\n const autoId = useId();\n const inputId = id ?? autoId;\n\n return (\n <div className={cn(styles.checkbox, className, when(hide, styles.hide))}>\n <input\n ref={ref}\n type=\"checkbox\"\n id={inputId}\n disabled={disabled}\n className={cn(styles.input, when(!withCursor, styles.noEvents))}\n {...props}\n />\n {title ? (\n <label className={styles.label} htmlFor={inputId}>\n {title.replaceAll('-', '–')}\n </label>\n ) : null}\n </div>\n );\n },\n);\n"],"mappings":";;;;;AAWA,MAAa,gBAAgB,WAC3B,SAAS,cACP,EAAE,WAAW,IAAI,OAAO,MAAM,UAAU,aAAa,MAAM,GAAG,SAC9D,KACA;CACA,MAAM,SAAS,MAAM;CACrB,MAAM,UAAU,MAAM;CAEtB,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,OAAO,UAAU,WAAW,KAAK,MAAM,OAAO,IAAI,CAAC;EAAtE,UAAA,CACE,oBAAC,SAAD;GACO;GACL,MAAK;GACL,IAAI;GACM;GACV,WAAW,GAAG,OAAO,OAAO,KAAK,CAAC,YAAY,OAAO,QAAQ,CAAC;GAC9D,GAAI;EACL,CAAA,GACA,QACC,oBAAC,SAAD;GAAO,WAAW,OAAO;GAAO,SAAS;GACtC,UAAA,MAAM,WAAW,KAAK,GAAG;EACrB,CAAA,IACL,IACD;;AAET,CACF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
@import '../../styles/vars.scss';
|
|
2
|
+
|
|
3
|
+
@function get-check-icon($color: 'fff') {
|
|
4
|
+
@return url("data:image/svg+xml,%3Csvg fill='%23#{$color}' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='20px' height='20px'%3E%3Cpath d='M15.71,6.29c-0.39-0.39-1.02-0.39-1.41,0c-0.31,0.31-3.76,3.76-5.29,5.29c-0.81-0.81-2.01-2.01-2.29-2.29c-0.39-0.39-1.02-0.39-1.41,0c-0.39,0.39-0.39,1.02,0,1.41c0.39,0.39,2.61,2.61,3,3c0.39,0.39,1.02,0.39,1.41,0c0.39-0.39,5.61-5.61,6-6C16.1,7.32,16.1,6.68,15.71,6.29z'/%3E%3C/svg%3E");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.checkbox {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: flex-start;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.hide {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.label {
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
line-height: 20px;
|
|
19
|
+
display: inline-block;
|
|
20
|
+
vertical-align: top;
|
|
21
|
+
padding-left: 5px;
|
|
22
|
+
user-select: none;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.input {
|
|
27
|
+
--active: #000;
|
|
28
|
+
--active-inner: #fff;
|
|
29
|
+
--border: #e5e5e5;
|
|
30
|
+
--border-hover: #000;
|
|
31
|
+
--background: #fff;
|
|
32
|
+
--disabled: #e5e5e5;
|
|
33
|
+
--disabled-inner: #e5e5e5;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
appearance: none;
|
|
36
|
+
width: 20px;
|
|
37
|
+
height: 20px;
|
|
38
|
+
outline: none;
|
|
39
|
+
display: inline-block;
|
|
40
|
+
vertical-align: top;
|
|
41
|
+
position: relative;
|
|
42
|
+
margin: 0;
|
|
43
|
+
flex-shrink: 0;
|
|
44
|
+
border: 1px solid var(--bc, var(--border));
|
|
45
|
+
background: var(--b, var(--background));
|
|
46
|
+
border-radius: 5px;
|
|
47
|
+
transition:
|
|
48
|
+
background 0.3s,
|
|
49
|
+
border-color 0.3s,
|
|
50
|
+
box-shadow 0.2s;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
&::after {
|
|
54
|
+
content: '';
|
|
55
|
+
display: block;
|
|
56
|
+
left: 0;
|
|
57
|
+
top: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
bottom: 0;
|
|
60
|
+
position: absolute;
|
|
61
|
+
transition: opacity var(--d-o, 0.2s);
|
|
62
|
+
opacity: var(--o, 0);
|
|
63
|
+
background-position: center;
|
|
64
|
+
background-image: get-check-icon();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:required:not(:hover):not(:checked):not(:disabled) {
|
|
68
|
+
border: 1px solid $colorRed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:checked {
|
|
72
|
+
--b: var(--active);
|
|
73
|
+
--bc: var(--active);
|
|
74
|
+
--o: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:hover:not(:checked):not(:disabled) {
|
|
78
|
+
border-width: 2px;
|
|
79
|
+
--bc: var(--active);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&:focus {
|
|
83
|
+
border-color: var(--border-hover);
|
|
84
|
+
border-width: 2px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&:disabled {
|
|
88
|
+
--b: var(--disabled);
|
|
89
|
+
border: 1px solid var(--disabled);
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
opacity: 1;
|
|
92
|
+
|
|
93
|
+
&:checked {
|
|
94
|
+
--b: var(--disabled-inner);
|
|
95
|
+
|
|
96
|
+
&::after {
|
|
97
|
+
background-image: get-check-icon('727272');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
& + .label {
|
|
102
|
+
color: $colorGrayTwo;
|
|
103
|
+
cursor: not-allowed;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.noEvents {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_cn = require("../../lib/cn.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let src_components_input_input_module_scss = require("./input.module.scss");
|
|
6
|
+
src_components_input_input_module_scss = require_runtime.__toESM(src_components_input_input_module_scss, 1);
|
|
7
|
+
// src/components/input/input.tsx
|
|
8
|
+
const Input = (0, react.forwardRef)(function Input({ type = "text", recommended, error, className, disabled, ...props }, ref) {
|
|
9
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
10
|
+
ref,
|
|
11
|
+
type,
|
|
12
|
+
disabled,
|
|
13
|
+
"aria-invalid": error || void 0,
|
|
14
|
+
className: require_cn.cn(src_components_input_input_module_scss.default.input, className, require_cn.when(recommended, src_components_input_input_module_scss.default["input--recommended"]), require_cn.when(error, src_components_input_input_module_scss.default["input--error"])),
|
|
15
|
+
...props
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
exports.Input = Input;
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.cjs","names":["forwardRef","cn","styles","when"],"sources":["../../../src/components/input/input.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes } from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport styles from './input.module.scss';\n\nexport interface InputProps extends InputHTMLAttributes<HTMLInputElement> {\n recommended?: boolean;\n error?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { type = 'text', recommended, error, className, disabled, ...props },\n ref,\n) {\n return (\n <input\n ref={ref}\n type={type}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={cn(\n styles.input,\n className,\n when(recommended, styles['input--recommended']),\n when(error, styles['input--error']),\n )}\n {...props}\n />\n );\n});\n"],"mappings":";;;;;;;AAUA,MAAa,SAAA,GAAQA,MAAAA,WAAAA,CAAyC,SAAS,MACrE,EAAE,OAAO,QAAQ,aAAa,OAAO,WAAW,UAAU,GAAG,SAC7D,KACA;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;EACO;EACC;EACI;EACV,gBAAc,SAAS,KAAA;EACvB,WAAWC,WAAAA,GACTC,uCAAAA,QAAO,OACP,WACAC,WAAAA,KAAK,aAAaD,uCAAAA,QAAO,qBAAqB,GAC9CC,WAAAA,KAAK,OAAOD,uCAAAA,QAAO,eAAe,CACpC;EACA,GAAI;CACL,CAAA;AAEL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
recommended?: boolean;
|
|
4
|
+
error?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
7
|
+
//# sourceMappingURL=input.d.cts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from "react";
|
|
2
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
3
|
+
recommended?: boolean;
|
|
4
|
+
error?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
7
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cn, when } from "../../lib/cn.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import styles from "./input.module.scss";
|
|
5
|
+
// src/components/input/input.tsx
|
|
6
|
+
const Input = forwardRef(function Input({ type = "text", recommended, error, className, disabled, ...props }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx("input", {
|
|
8
|
+
ref,
|
|
9
|
+
type,
|
|
10
|
+
disabled,
|
|
11
|
+
"aria-invalid": error || void 0,
|
|
12
|
+
className: cn(styles.input, className, when(recommended, styles["input--recommended"]), when(error, styles["input--error"])),
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
export { Input };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../src/components/input/input.tsx"],"sourcesContent":["import { forwardRef, type InputHTMLAttributes } from 'react';\n\nimport { cn, when } from '../../lib/cn';\nimport styles from './input.module.scss';\n\nexport interface InputProps extends InputHTMLAttributes<HTMLInputElement> {\n recommended?: boolean;\n error?: boolean;\n}\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(function Input(\n { type = 'text', recommended, error, className, disabled, ...props },\n ref,\n) {\n return (\n <input\n ref={ref}\n type={type}\n disabled={disabled}\n aria-invalid={error || undefined}\n className={cn(\n styles.input,\n className,\n when(recommended, styles['input--recommended']),\n when(error, styles['input--error']),\n )}\n {...props}\n />\n );\n});\n"],"mappings":";;;;;AAUA,MAAa,QAAQ,WAAyC,SAAS,MACrE,EAAE,OAAO,QAAQ,aAAa,OAAO,WAAW,UAAU,GAAG,SAC7D,KACA;CACA,OACE,oBAAC,SAAD;EACO;EACC;EACI;EACV,gBAAc,SAAS,KAAA;EACvB,WAAW,GACT,OAAO,OACP,WACA,KAAK,aAAa,OAAO,qBAAqB,GAC9C,KAAK,OAAO,OAAO,eAAe,CACpC;EACA,GAAI;CACL,CAAA;AAEL,CAAC"}
|