@vetc-miniapp/ui-react 0.0.24 → 0.0.25
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/dist/bridge.d.ts +11 -0
- package/dist/bridge.js +20 -0
- package/dist/components/app.d.ts +6 -0
- package/dist/components/app.js +34 -0
- package/dist/components/avatar/Avatar.d.ts +21 -0
- package/dist/components/avatar/Avatar.js +33 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/bottom-sheet/BottomSheet.d.ts +19 -0
- package/dist/components/bottom-sheet/BottomSheet.js +70 -0
- package/dist/components/bottom-sheet/index.js +1 -0
- package/dist/components/button/Button.d.ts +32 -0
- package/dist/components/button/Button.js +165 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +28 -0
- package/dist/components/button-group/ButtonGroup.js +21 -0
- package/dist/components/button-group/index.js +1 -0
- package/dist/components/card/Card.d.ts +18 -0
- package/dist/components/card/Card.js +35 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +41 -0
- package/dist/components/checkbox/Checkbox.js +94 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/chip/Chip.d.ts +24 -0
- package/dist/components/chip/Chip.js +83 -0
- package/dist/components/chip/index.js +1 -0
- package/dist/components/dialog/Dialog.d.ts +19 -0
- package/dist/components/dialog/Dialog.js +51 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/divider/Divider.d.ts +16 -0
- package/dist/components/divider/Divider.js +18 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/input/Input.d.ts +40 -0
- package/dist/components/input/Input.js +51 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/list/List.d.ts +31 -0
- package/dist/components/list/List.js +72 -0
- package/dist/components/list/index.js +1 -0
- package/dist/components/loading/Loading.d.ts +28 -0
- package/dist/components/loading/Loading.js +33 -0
- package/dist/components/loading/index.js +1 -0
- package/dist/components/modal/Modal.d.ts +38 -0
- package/dist/components/modal/Modal.js +50 -0
- package/dist/components/modal/index.js +1 -0
- package/dist/components/navigation-bar/NavigationBar.d.ts +44 -0
- package/dist/components/navigation-bar/NavigationBar.js +70 -0
- package/dist/components/navigation-bar/index.js +1 -0
- package/dist/components/radio/Radio.d.ts +40 -0
- package/dist/components/radio/Radio.js +88 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/select/Select.d.ts +29 -0
- package/dist/components/select/Select.js +30 -0
- package/dist/components/select/index.js +1 -0
- package/dist/components/switch/Switch.d.ts +23 -0
- package/dist/components/switch/Switch.js +81 -0
- package/dist/components/switch/index.js +1 -0
- package/dist/components/tab-bar/TabBar.d.ts +28 -0
- package/dist/components/tab-bar/TabBar.js +60 -0
- package/dist/components/tab-bar/index.js +1 -0
- package/dist/components/textarea/Textarea.d.ts +31 -0
- package/dist/components/textarea/Textarea.js +33 -0
- package/dist/components/textarea/index.js +1 -0
- package/dist/components/toast/Toast.d.ts +41 -0
- package/dist/components/toast/Toast.js +61 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/typography/Typography.d.ts +45 -0
- package/dist/components/typography/Typography.js +143 -0
- package/dist/components/typography/index.js +1 -0
- package/dist/hooks/use-app-pause.d.ts +6 -0
- package/dist/hooks/use-app-pause.js +29 -0
- package/dist/hooks/use-app-resume.d.ts +6 -0
- package/dist/hooks/use-app-resume.js +28 -0
- package/{src/ui-react/hooks/use-app-state.ts → dist/hooks/use-app-state.d.ts} +0 -1
- package/dist/hooks/use-app-state.js +1 -0
- package/dist/hooks/use-did-hide.d.ts +6 -0
- package/dist/hooks/use-did-hide.js +21 -0
- package/dist/hooks/use-did-show.d.ts +6 -0
- package/dist/hooks/use-did-show.js +21 -0
- package/dist/hooks/use-listener-scan-qr.d.ts +21 -0
- package/dist/hooks/use-listener-scan-qr.js +29 -0
- package/dist/hooks/use-navigate.d.ts +8 -0
- package/dist/hooks/use-navigate.js +23 -0
- package/dist/hooks/use-tap-app-bar.d.ts +6 -0
- package/dist/hooks/use-tap-app-bar.js +21 -0
- package/{src/ui-react/index.ts → dist/index.d.ts} +1 -30
- package/dist/index.js +41 -0
- package/dist/styles/VETCProvider.d.ts +114 -0
- package/dist/styles/VETCProvider.js +124 -0
- package/{src/ui-react → dist}/styles/tokens.css +22 -1
- package/dist/tokens/colors.d.ts +127 -0
- package/dist/tokens/colors.js +75 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/spacing.d.ts +56 -0
- package/dist/tokens/spacing.js +56 -0
- package/dist/tokens/typography.d.ts +121 -0
- package/dist/tokens/typography.js +57 -0
- package/dist/types/app.d.ts +21 -0
- package/dist/types/app.js +1 -0
- package/package.json +13 -7
- package/src/dist/ui-react/index.js +0 -2
- package/src/dist/ui-react/index.js.LICENSE.txt +0 -11
- package/src/ui-react/bridge.js +0 -36
- package/src/ui-react/bridge.ts +0 -48
- package/src/ui-react/components/app.d.ts +0 -7
- package/src/ui-react/components/app.jsx +0 -80
- package/src/ui-react/components/app.tsx +0 -42
- package/src/ui-react/components/app1.js +0 -101
- package/src/ui-react/components/avatar/Avatar.tsx +0 -88
- package/src/ui-react/components/bottom-sheet/BottomSheet.tsx +0 -149
- package/src/ui-react/components/button/Button.tsx +0 -246
- package/src/ui-react/components/button-group/ButtonGroup.tsx +0 -108
- package/src/ui-react/components/card/Card.tsx +0 -77
- package/src/ui-react/components/checkbox/Checkbox.tsx +0 -232
- package/src/ui-react/components/chip/Chip.tsx +0 -137
- package/src/ui-react/components/dialog/Dialog.tsx +0 -135
- package/src/ui-react/components/divider/Divider.tsx +0 -54
- package/src/ui-react/components/input/Input.tsx +0 -195
- package/src/ui-react/components/list/List.tsx +0 -180
- package/src/ui-react/components/loading/Loading.tsx +0 -121
- package/src/ui-react/components/modal/Modal.tsx +0 -116
- package/src/ui-react/components/navigation-bar/NavigationBar.tsx +0 -188
- package/src/ui-react/components/radio/Radio.tsx +0 -216
- package/src/ui-react/components/select/Select.tsx +0 -109
- package/src/ui-react/components/switch/Switch.tsx +0 -164
- package/src/ui-react/components/tab-bar/TabBar.tsx +0 -137
- package/src/ui-react/components/textarea/Textarea.tsx +0 -109
- package/src/ui-react/components/toast/Toast.ts +0 -98
- package/src/ui-react/components/typography/Typography.tsx +0 -201
- package/src/ui-react/hooks/use-app-pause.js +0 -35
- package/src/ui-react/hooks/use-app-pause.ts +0 -33
- package/src/ui-react/hooks/use-app-resume.js +0 -37
- package/src/ui-react/hooks/use-app-resume.ts +0 -32
- package/src/ui-react/hooks/use-app-state.js +0 -35
- package/src/ui-react/hooks/use-did-hide.js +0 -25
- package/src/ui-react/hooks/use-did-hide.ts +0 -34
- package/src/ui-react/hooks/use-did-show.js +0 -26
- package/src/ui-react/hooks/use-did-show.ts +0 -34
- package/src/ui-react/hooks/use-listener-scan-qr.js +0 -33
- package/src/ui-react/hooks/use-listener-scan-qr.ts +0 -52
- package/src/ui-react/hooks/use-navigate.js +0 -15
- package/src/ui-react/hooks/use-navigate.ts +0 -41
- package/src/ui-react/hooks/use-tap-app-bar.js +0 -26
- package/src/ui-react/hooks/use-tap-app-bar.ts +0 -34
- package/src/ui-react/index.js +0 -9
- package/src/ui-react/styles/VETCProvider.tsx +0 -152
- package/src/ui-react/tokens/colors.ts +0 -91
- package/src/ui-react/tokens/spacing.ts +0 -59
- package/src/ui-react/tokens/typography.ts +0 -63
- package/src/ui-react/tokens_vetc.json +0 -1517
- package/src/ui-react/types/app.js +0 -30
- package/src/ui-react/types/app.ts +0 -32
- /package/{src/ui-react/components/avatar/index.ts → dist/components/avatar/index.d.ts} +0 -0
- /package/{src/ui-react/components/bottom-sheet/index.ts → dist/components/bottom-sheet/index.d.ts} +0 -0
- /package/{src/ui-react/components/button/index.ts → dist/components/button/index.d.ts} +0 -0
- /package/{src/ui-react/components/button-group/index.ts → dist/components/button-group/index.d.ts} +0 -0
- /package/{src/ui-react/components/card/index.ts → dist/components/card/index.d.ts} +0 -0
- /package/{src/ui-react/components/checkbox/index.ts → dist/components/checkbox/index.d.ts} +0 -0
- /package/{src/ui-react/components/chip/index.ts → dist/components/chip/index.d.ts} +0 -0
- /package/{src/ui-react/components/dialog/index.ts → dist/components/dialog/index.d.ts} +0 -0
- /package/{src/ui-react/components/divider/index.ts → dist/components/divider/index.d.ts} +0 -0
- /package/{src/ui-react/components/input/index.ts → dist/components/input/index.d.ts} +0 -0
- /package/{src/ui-react/components/list/index.ts → dist/components/list/index.d.ts} +0 -0
- /package/{src/ui-react/components/loading/index.ts → dist/components/loading/index.d.ts} +0 -0
- /package/{src/ui-react/components/modal/index.ts → dist/components/modal/index.d.ts} +0 -0
- /package/{src/ui-react/components/navigation-bar/index.ts → dist/components/navigation-bar/index.d.ts} +0 -0
- /package/{src/ui-react/components/radio/index.ts → dist/components/radio/index.d.ts} +0 -0
- /package/{src/ui-react/components/select/index.ts → dist/components/select/index.d.ts} +0 -0
- /package/{src/ui-react/components/switch/index.ts → dist/components/switch/index.d.ts} +0 -0
- /package/{src/ui-react/components/tab-bar/index.ts → dist/components/tab-bar/index.d.ts} +0 -0
- /package/{src/ui-react/components/textarea/index.ts → dist/components/textarea/index.d.ts} +0 -0
- /package/{src/ui-react/components/toast/index.ts → dist/components/toast/index.d.ts} +0 -0
- /package/{src/ui-react/components/typography/index.ts → dist/components/typography/index.d.ts} +0 -0
- /package/{src/ui-react/tokens/index.ts → dist/tokens/index.d.ts} +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Modal as AntModal } from 'antd';
|
|
3
|
+
/** Shared button style for modal actions */
|
|
4
|
+
const modalBtnStyle = {
|
|
5
|
+
height: 'var(--vetc-btn-height-lg)',
|
|
6
|
+
borderRadius: 'var(--vetc-btn-radius-lg)',
|
|
7
|
+
fontWeight: 'var(--vetc-btn-font-weight)',
|
|
8
|
+
fontSize: 'var(--vetc-btn-font-size-lg)',
|
|
9
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
10
|
+
};
|
|
11
|
+
export function Modal({ open, title, children, footer, okText = 'Xác nhận', cancelText = 'Hủy', okDisabled = false, okLoading = false, okDanger = false, onOk, onCancel, maskClosable = true, closable = true, width, className = '', style, id, }) {
|
|
12
|
+
return (_jsx(AntModal, { open: open, title: title, okText: okText, cancelText: cancelText, okButtonProps: {
|
|
13
|
+
disabled: okDisabled,
|
|
14
|
+
loading: okLoading,
|
|
15
|
+
danger: okDanger,
|
|
16
|
+
style: modalBtnStyle,
|
|
17
|
+
}, cancelButtonProps: { style: modalBtnStyle }, footer: footer === null ? null : footer, onOk: onOk, onCancel: onCancel, maskClosable: maskClosable, closable: closable, width: width ?? 'var(--vetc-modal-width)', centered: true, className: `vetc-modal ${className}`, style: { fontFamily: 'var(--vetc-font-family)', ...style }, styles: {
|
|
18
|
+
header: {
|
|
19
|
+
padding: `var(--vetc-modal-padding) var(--vetc-modal-padding) 0`,
|
|
20
|
+
borderBottom: 'none',
|
|
21
|
+
},
|
|
22
|
+
body: {
|
|
23
|
+
padding: `var(--vetc-space-8) var(--vetc-modal-padding) var(--vetc-modal-padding)`,
|
|
24
|
+
},
|
|
25
|
+
footer: {
|
|
26
|
+
padding: `0 var(--vetc-modal-padding) var(--vetc-modal-padding)`,
|
|
27
|
+
borderTop: 'none',
|
|
28
|
+
},
|
|
29
|
+
mask: { backgroundColor: 'var(--vetc-modal-overlay)' },
|
|
30
|
+
}, children: children }));
|
|
31
|
+
}
|
|
32
|
+
// ── Confirm hook ──────────────────────────────────────────────────────────────
|
|
33
|
+
export function useConfirm() {
|
|
34
|
+
const confirm = (opts) => {
|
|
35
|
+
AntModal.confirm({
|
|
36
|
+
title: opts.title,
|
|
37
|
+
content: opts.content,
|
|
38
|
+
okText: opts.okText ?? 'Xác nhận',
|
|
39
|
+
cancelText: opts.cancelText ?? 'Hủy',
|
|
40
|
+
okButtonProps: { danger: opts.okDanger, style: { ...modalBtnStyle, height: 40 } },
|
|
41
|
+
cancelButtonProps: { style: { ...modalBtnStyle, height: 40 } },
|
|
42
|
+
centered: true,
|
|
43
|
+
onOk: opts.onOk,
|
|
44
|
+
onCancel: opts.onCancel,
|
|
45
|
+
styles: { mask: { backgroundColor: 'var(--vetc-modal-overlay)' } },
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return { confirm };
|
|
49
|
+
}
|
|
50
|
+
export default Modal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Modal, useConfirm } from './Modal';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC NavigationBar — Top navigation bar
|
|
3
|
+
* Figma: h=56px, title=20px/semibold, icon-btn=32px, padding-x=8px
|
|
4
|
+
* Variants: back button, close button, action buttons (max 2 right)
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
export interface NavigationBarAction {
|
|
8
|
+
icon: React.ReactNode;
|
|
9
|
+
label?: string;
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
id?: string;
|
|
13
|
+
}
|
|
14
|
+
export type NavigationBarLeadingType = 'back' | 'close' | 'none';
|
|
15
|
+
export interface NavigationBarProps {
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
/** Leading left button type */
|
|
18
|
+
leading?: NavigationBarLeadingType;
|
|
19
|
+
/** Custom back/close icon (overrides default) */
|
|
20
|
+
leadingIcon?: React.ReactNode;
|
|
21
|
+
onLeadingPress?: () => void;
|
|
22
|
+
/** Max 2 action buttons on right */
|
|
23
|
+
actions?: NavigationBarAction[];
|
|
24
|
+
/** Fully custom left slot (overrides leading) */
|
|
25
|
+
leftSlot?: React.ReactNode;
|
|
26
|
+
/** Fully custom right slot (overrides actions) */
|
|
27
|
+
rightSlot?: React.ReactNode;
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
divider?: boolean;
|
|
30
|
+
transparent?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
style?: React.CSSProperties;
|
|
33
|
+
id?: string;
|
|
34
|
+
/** @deprecated use leading="back" + onLeadingPress */
|
|
35
|
+
showBack?: boolean;
|
|
36
|
+
/** @deprecated use leadingIcon */
|
|
37
|
+
backIcon?: React.ReactNode;
|
|
38
|
+
/** @deprecated use onLeadingPress */
|
|
39
|
+
onBack?: () => void;
|
|
40
|
+
left?: React.ReactNode;
|
|
41
|
+
right?: React.ReactNode;
|
|
42
|
+
}
|
|
43
|
+
export declare function NavigationBar({ title, leading, leadingIcon, onLeadingPress, actions, leftSlot, rightSlot, backgroundColor, divider, transparent, className, style, id, showBack, backIcon, onBack, left, right, }: NavigationBarProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export default NavigationBar;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function BackIcon() {
|
|
3
|
+
return (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M15 19L8 12L15 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
4
|
+
}
|
|
5
|
+
function CloseIcon() {
|
|
6
|
+
return (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 6L6 18M6 6L18 18", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }));
|
|
7
|
+
}
|
|
8
|
+
const iconBtnStyle = {
|
|
9
|
+
background: 'none',
|
|
10
|
+
border: 'none',
|
|
11
|
+
cursor: 'pointer',
|
|
12
|
+
width: 'var(--vetc-nav-icon-btn-size)',
|
|
13
|
+
height: 'var(--vetc-nav-icon-btn-size)',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
borderRadius: 'var(--vetc-radius-pill)',
|
|
18
|
+
color: 'var(--vetc-nav-icon-color)',
|
|
19
|
+
flexShrink: 0,
|
|
20
|
+
padding: 0,
|
|
21
|
+
transition: 'background-color var(--vetc-transition-fast)',
|
|
22
|
+
};
|
|
23
|
+
export function NavigationBar({ title, leading = 'none', leadingIcon, onLeadingPress, actions = [], leftSlot, rightSlot, backgroundColor, divider = true, transparent = false, className = '', style, id,
|
|
24
|
+
// deprecated props
|
|
25
|
+
showBack, backIcon, onBack, left, right, }) {
|
|
26
|
+
// Backward compat
|
|
27
|
+
const resolvedLeading = showBack ? 'back' : leading;
|
|
28
|
+
const resolvedLeadingIcon = leadingIcon ?? backIcon;
|
|
29
|
+
const resolvedOnLeading = onLeadingPress ?? onBack;
|
|
30
|
+
const renderLeadingButton = () => {
|
|
31
|
+
if (leftSlot !== undefined || left !== undefined)
|
|
32
|
+
return leftSlot ?? left;
|
|
33
|
+
if (resolvedLeading === 'none')
|
|
34
|
+
return null;
|
|
35
|
+
const icon = resolvedLeadingIcon ?? (resolvedLeading === 'close' ? _jsx(CloseIcon, {}) : _jsx(BackIcon, {}));
|
|
36
|
+
const label = resolvedLeading === 'close' ? 'Đóng' : 'Quay lại';
|
|
37
|
+
return (_jsx("button", { onClick: resolvedOnLeading, style: iconBtnStyle, "aria-label": label, children: icon }));
|
|
38
|
+
};
|
|
39
|
+
return (_jsxs("header", { id: id, className: `vetc-nav-bar ${className}`, style: {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
height: 'var(--vetc-nav-height)',
|
|
43
|
+
padding: `0 var(--vetc-nav-padding-x)`,
|
|
44
|
+
backgroundColor: transparent ? 'transparent' : (backgroundColor ?? 'var(--vetc-nav-bg)'),
|
|
45
|
+
borderBottom: divider && !transparent ? `1px solid var(--vetc-nav-border)` : 'none',
|
|
46
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
47
|
+
position: 'relative',
|
|
48
|
+
...style,
|
|
49
|
+
}, children: [_jsx("div", { style: { display: 'flex', alignItems: 'center', minWidth: 'var(--vetc-nav-icon-btn-size)', zIndex: 1 }, children: renderLeadingButton() }), title && (_jsx("div", { style: {
|
|
50
|
+
position: 'absolute',
|
|
51
|
+
left: 0,
|
|
52
|
+
right: 0,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
pointerEvents: 'none',
|
|
57
|
+
}, children: _jsx("span", { style: {
|
|
58
|
+
fontSize: 'var(--vetc-nav-title-size)',
|
|
59
|
+
fontWeight: 'var(--vetc-nav-title-weight)',
|
|
60
|
+
color: 'var(--vetc-nav-title-color)',
|
|
61
|
+
lineHeight: 'var(--vetc-line-height-normal)',
|
|
62
|
+
maxWidth: '60%',
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
textOverflow: 'ellipsis',
|
|
65
|
+
whiteSpace: 'nowrap',
|
|
66
|
+
}, children: title }) })), _jsx("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--vetc-space-4)', marginLeft: 'auto', zIndex: 1 }, children: rightSlot !== undefined || right !== undefined
|
|
67
|
+
? (rightSlot ?? right)
|
|
68
|
+
: actions.slice(0, 2).map((action, i) => (_jsx("button", { id: action.id, onClick: action.onClick, disabled: action.disabled, "aria-label": action.label, style: { ...iconBtnStyle, opacity: action.disabled ? 0.4 : 1 }, children: action.icon }, i))) })] }));
|
|
69
|
+
}
|
|
70
|
+
export default NavigationBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NavigationBar } from './NavigationBar';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC Radio & RadioGroup
|
|
3
|
+
* Figma: size=20px, states: default/hover/selected/disabled
|
|
4
|
+
* variant: neutral (gray-90) | brand (green-40)
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
export type RadioVariant = 'neutral' | 'brand';
|
|
8
|
+
export interface RadioProps {
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
checked?: boolean;
|
|
12
|
+
defaultChecked?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
variant?: RadioVariant;
|
|
15
|
+
onChange?: (checked: boolean) => void;
|
|
16
|
+
value?: any;
|
|
17
|
+
id?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
}
|
|
21
|
+
export declare function Radio({ label, description, checked, defaultChecked, disabled, variant, onChange, value, id, className, style, }: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export interface RadioOption {
|
|
23
|
+
label: React.ReactNode;
|
|
24
|
+
description?: React.ReactNode;
|
|
25
|
+
value: any;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface RadioGroupProps {
|
|
29
|
+
options: RadioOption[];
|
|
30
|
+
value?: any;
|
|
31
|
+
defaultValue?: any;
|
|
32
|
+
direction?: 'horizontal' | 'vertical';
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
variant?: RadioVariant;
|
|
35
|
+
onChange?: (value: any) => void;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: React.CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
export declare function RadioGroup({ options, value, defaultValue, direction, disabled, variant, onChange, className, style, }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export default Radio;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* VETC Radio & RadioGroup
|
|
4
|
+
* Figma: size=20px, states: default/hover/selected/disabled
|
|
5
|
+
* variant: neutral (gray-90) | brand (green-40)
|
|
6
|
+
*/
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
export function Radio({ label, description, checked, defaultChecked = false, disabled = false, variant = 'brand', onChange, value, id, className = '', style, }) {
|
|
9
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
10
|
+
const [hovered, setHovered] = useState(false);
|
|
11
|
+
const isControlled = checked !== undefined;
|
|
12
|
+
const isChecked = isControlled ? checked : internalChecked;
|
|
13
|
+
const handleChange = () => {
|
|
14
|
+
if (disabled || isChecked)
|
|
15
|
+
return;
|
|
16
|
+
if (!isControlled)
|
|
17
|
+
setInternalChecked(true);
|
|
18
|
+
onChange?.(true);
|
|
19
|
+
};
|
|
20
|
+
const accentColor = variant === 'brand'
|
|
21
|
+
? 'var(--vetc-color-brand)'
|
|
22
|
+
: 'var(--vetc-gray-90)';
|
|
23
|
+
const accentHover = variant === 'brand'
|
|
24
|
+
? 'var(--vetc-color-brand-hover)'
|
|
25
|
+
: 'var(--vetc-gray-70)';
|
|
26
|
+
const ringColor = disabled
|
|
27
|
+
? 'var(--vetc-color-border-disabled)'
|
|
28
|
+
: isChecked
|
|
29
|
+
? (hovered ? accentHover : accentColor)
|
|
30
|
+
: (hovered ? accentColor : 'var(--vetc-color-border)');
|
|
31
|
+
const dotColor = disabled ? 'var(--vetc-color-text-disabled)' : accentColor;
|
|
32
|
+
return (_jsxs("label", { htmlFor: id, className: `vetc-radio ${className}`, onMouseEnter: () => !disabled && setHovered(true), onMouseLeave: () => setHovered(false), style: {
|
|
33
|
+
display: 'inline-flex',
|
|
34
|
+
alignItems: description ? 'flex-start' : 'center',
|
|
35
|
+
gap: 'var(--vetc-space-12)',
|
|
36
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
37
|
+
userSelect: 'none',
|
|
38
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
39
|
+
...style,
|
|
40
|
+
}, children: [_jsx("input", { id: id, type: "radio", checked: isChecked, disabled: disabled, value: value, onChange: handleChange, style: { position: 'absolute', opacity: 0, width: 0, height: 0, pointerEvents: 'none' } }), _jsx("span", { "aria-hidden": "true", style: {
|
|
41
|
+
width: '20px',
|
|
42
|
+
height: '20px',
|
|
43
|
+
flexShrink: 0,
|
|
44
|
+
borderRadius: '50%',
|
|
45
|
+
border: `1.5px solid ${ringColor}`,
|
|
46
|
+
backgroundColor: 'transparent',
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
transition: 'border-color var(--vetc-transition-fast)',
|
|
51
|
+
marginTop: description ? '2px' : 0,
|
|
52
|
+
}, children: isChecked && (_jsx("span", { style: {
|
|
53
|
+
width: '8px',
|
|
54
|
+
height: '8px',
|
|
55
|
+
borderRadius: '50%',
|
|
56
|
+
backgroundColor: dotColor,
|
|
57
|
+
flexShrink: 0,
|
|
58
|
+
} })) }), (label || description) && (_jsxs("span", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--vetc-space-2)' }, children: [label && (_jsx("span", { style: {
|
|
59
|
+
fontSize: 'var(--vetc-font-size-base)',
|
|
60
|
+
fontWeight: 'var(--vetc-font-weight-regular)',
|
|
61
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
62
|
+
color: disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-primary)',
|
|
63
|
+
}, children: label })), description && (_jsx("span", { style: {
|
|
64
|
+
fontSize: 'var(--vetc-font-size-sm)',
|
|
65
|
+
fontWeight: 'var(--vetc-font-weight-regular)',
|
|
66
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
67
|
+
color: disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-secondary)',
|
|
68
|
+
}, children: description }))] }))] }));
|
|
69
|
+
}
|
|
70
|
+
export function RadioGroup({ options, value, defaultValue, direction = 'vertical', disabled = false, variant = 'brand', onChange, className = '', style, }) {
|
|
71
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
72
|
+
const isControlled = value !== undefined;
|
|
73
|
+
const currentValue = isControlled ? value : internalValue;
|
|
74
|
+
const handleChange = (optValue) => {
|
|
75
|
+
if (!isControlled)
|
|
76
|
+
setInternalValue(optValue);
|
|
77
|
+
onChange?.(optValue);
|
|
78
|
+
};
|
|
79
|
+
return (_jsx("div", { role: "radiogroup", className: `vetc-radio-group ${className}`, style: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
flexDirection: direction === 'vertical' ? 'column' : 'row',
|
|
82
|
+
flexWrap: direction === 'horizontal' ? 'wrap' : undefined,
|
|
83
|
+
gap: direction === 'vertical' ? 'var(--vetc-space-12)' : 'var(--vetc-space-16)',
|
|
84
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
85
|
+
...style,
|
|
86
|
+
}, children: options.map((opt) => (_jsx(Radio, { label: opt.label, description: opt.description, checked: currentValue === opt.value, disabled: opt.disabled ?? disabled, variant: variant, value: opt.value, onChange: () => handleChange(opt.value) }, String(opt.value)))) }));
|
|
87
|
+
}
|
|
88
|
+
export default Radio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Radio, RadioGroup } from './Radio';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC Select — tokenized
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { DefaultOptionType } from 'antd/es/select';
|
|
6
|
+
export type SelectOption = DefaultOptionType;
|
|
7
|
+
export interface SelectProps {
|
|
8
|
+
label?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
value?: string | string[] | number | number[];
|
|
11
|
+
defaultValue?: string | string[] | number | number[];
|
|
12
|
+
options?: SelectOption[];
|
|
13
|
+
helperText?: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
multiple?: boolean;
|
|
17
|
+
searchable?: boolean;
|
|
18
|
+
allowClear?: boolean;
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
onChange?: (value: any, option: any) => void;
|
|
21
|
+
onSearch?: (value: string) => void;
|
|
22
|
+
id?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
popupMatchSelectWidth?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function Select({ label, placeholder, value, defaultValue, options, helperText, error, disabled, multiple, searchable, allowClear, loading, onChange, onSearch, id, className, style, required, popupMatchSelectWidth, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export default Select;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Select as AntSelect } from 'antd';
|
|
3
|
+
export function Select({ label, placeholder, value, defaultValue, options = [], helperText, error, disabled = false, multiple = false, searchable = false, allowClear = false, loading = false, onChange, onSearch, id, className = '', style, required = false, popupMatchSelectWidth = true, }) {
|
|
4
|
+
const hasError = !!error;
|
|
5
|
+
const helperMsg = error ?? helperText;
|
|
6
|
+
const helperColor = hasError
|
|
7
|
+
? 'var(--vetc-input-helper-color-error)'
|
|
8
|
+
: 'var(--vetc-input-helper-color)';
|
|
9
|
+
return (_jsxs("div", { className: `vetc-select-wrapper ${className}`, style: { display: 'flex', flexDirection: 'column', gap: 'var(--vetc-input-gap)', ...style }, children: [label && (_jsxs("label", { htmlFor: id, style: {
|
|
10
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
11
|
+
fontSize: 'var(--vetc-input-label-font-size)',
|
|
12
|
+
fontWeight: 'var(--vetc-input-label-font-weight)',
|
|
13
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
14
|
+
color: disabled
|
|
15
|
+
? 'var(--vetc-color-text-disabled)'
|
|
16
|
+
: 'var(--vetc-input-label-color)',
|
|
17
|
+
display: 'block',
|
|
18
|
+
}, children: [label, required && (_jsx("span", { style: { color: 'var(--vetc-color-negative)', marginLeft: 'var(--vetc-space-2)' }, children: "*" }))] })), _jsx(AntSelect, { id: id, value: value, defaultValue: defaultValue, placeholder: placeholder, options: options, disabled: disabled, mode: multiple ? 'multiple' : undefined, showSearch: searchable, allowClear: allowClear, loading: loading, status: hasError ? 'error' : undefined, onChange: onChange, onSearch: onSearch, popupMatchSelectWidth: popupMatchSelectWidth, style: {
|
|
19
|
+
height: 'var(--vetc-input-height)',
|
|
20
|
+
width: '100%',
|
|
21
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
22
|
+
fontSize: 'var(--vetc-input-font-size)',
|
|
23
|
+
} }), helperMsg && (_jsx("span", { style: {
|
|
24
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
25
|
+
fontSize: 'var(--vetc-input-helper-font-size)',
|
|
26
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
27
|
+
color: helperColor,
|
|
28
|
+
}, children: helperMsg }))] }));
|
|
29
|
+
}
|
|
30
|
+
export default Select;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Select } from './Select';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC Switch
|
|
3
|
+
* Figma: w=52px h=32px, thumb=28px, ON=brand-green, OFF=gray-30
|
|
4
|
+
* variant: neutral (gray-90 on) | brand (green-40 on)
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
export type SwitchVariant = 'neutral' | 'brand';
|
|
8
|
+
export interface SwitchProps {
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
labelPosition?: 'left' | 'right';
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
defaultChecked?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
variant?: SwitchVariant;
|
|
17
|
+
onChange?: (checked: boolean) => void;
|
|
18
|
+
id?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: React.CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
export declare function Switch({ label, description, labelPosition, checked, defaultChecked, disabled, loading, variant, onChange, id, className, style, }: SwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Switch;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* VETC Switch
|
|
4
|
+
* Figma: w=52px h=32px, thumb=28px, ON=brand-green, OFF=gray-30
|
|
5
|
+
* variant: neutral (gray-90 on) | brand (green-40 on)
|
|
6
|
+
*/
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
export function Switch({ label, description, labelPosition = 'right', checked, defaultChecked = false, disabled = false, loading = false, variant = 'brand', onChange, id, className = '', style, }) {
|
|
9
|
+
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
10
|
+
const isControlled = checked !== undefined;
|
|
11
|
+
const isChecked = isControlled ? checked : internalChecked;
|
|
12
|
+
const isDisabled = disabled || loading;
|
|
13
|
+
const handleToggle = () => {
|
|
14
|
+
if (isDisabled)
|
|
15
|
+
return;
|
|
16
|
+
const next = !isChecked;
|
|
17
|
+
if (!isControlled)
|
|
18
|
+
setInternalChecked(next);
|
|
19
|
+
onChange?.(next);
|
|
20
|
+
};
|
|
21
|
+
const onColor = variant === 'brand'
|
|
22
|
+
? 'var(--vetc-switch-on-bg)'
|
|
23
|
+
: 'var(--vetc-gray-90)';
|
|
24
|
+
const trackBg = isDisabled
|
|
25
|
+
? 'var(--vetc-color-bg-disabled)'
|
|
26
|
+
: isChecked
|
|
27
|
+
? onColor
|
|
28
|
+
: 'var(--vetc-switch-off-bg)';
|
|
29
|
+
const thumbLeft = isChecked ? 'calc(100% - 30px)' : '2px';
|
|
30
|
+
const switchEl = (_jsxs("button", { id: id, type: "button", role: "switch", "aria-checked": isChecked, disabled: isDisabled, onClick: handleToggle, className: `vetc-switch ${className}`, style: {
|
|
31
|
+
position: 'relative',
|
|
32
|
+
display: 'inline-flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
width: 'var(--vetc-switch-width)',
|
|
35
|
+
height: 'var(--vetc-switch-height)',
|
|
36
|
+
borderRadius: 'var(--vetc-radius-pill)',
|
|
37
|
+
backgroundColor: trackBg,
|
|
38
|
+
border: 'none',
|
|
39
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
40
|
+
padding: 0,
|
|
41
|
+
flexShrink: 0,
|
|
42
|
+
transition: 'background-color var(--vetc-transition-fast)',
|
|
43
|
+
outline: 'none',
|
|
44
|
+
...(label || description ? {} : style),
|
|
45
|
+
}, children: [_jsx("span", { style: {
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
left: thumbLeft,
|
|
48
|
+
width: 'var(--vetc-switch-thumb-size)',
|
|
49
|
+
height: 'var(--vetc-switch-thumb-size)',
|
|
50
|
+
borderRadius: '50%',
|
|
51
|
+
backgroundColor: isDisabled ? 'var(--vetc-gray-20)' : 'var(--vetc-white)',
|
|
52
|
+
boxShadow: '0 1px 4px rgba(0,0,0,0.25)',
|
|
53
|
+
transition: 'left var(--vetc-transition-fast)',
|
|
54
|
+
display: 'flex',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
}, children: loading && (_jsxs("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", style: { animation: 'vetc-btn-spin 0.6s linear infinite' }, "aria-hidden": "true", children: [_jsx("circle", { cx: "6", cy: "6", r: "4", stroke: "var(--vetc-gray-30)", strokeWidth: "1.5" }), _jsx("path", { d: "M6 2a4 4 0 014 4", stroke: "var(--vetc-color-brand)", strokeWidth: "1.5", strokeLinecap: "round" })] })) }), _jsx("style", { children: `@keyframes vetc-btn-spin { to { transform: rotate(360deg); } }` })] }));
|
|
58
|
+
if (!label && !description)
|
|
59
|
+
return switchEl;
|
|
60
|
+
const labelBlock = (_jsxs("span", { style: { display: 'flex', flexDirection: 'column', gap: 'var(--vetc-space-2)', flex: 1 }, children: [label && (_jsx("span", { style: {
|
|
61
|
+
fontSize: 'var(--vetc-font-size-base)',
|
|
62
|
+
fontWeight: 'var(--vetc-font-weight-regular)',
|
|
63
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
64
|
+
color: isDisabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-primary)',
|
|
65
|
+
}, children: label })), description && (_jsx("span", { style: {
|
|
66
|
+
fontSize: 'var(--vetc-font-size-sm)',
|
|
67
|
+
fontWeight: 'var(--vetc-font-weight-regular)',
|
|
68
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
69
|
+
color: isDisabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-secondary)',
|
|
70
|
+
}, children: description }))] }));
|
|
71
|
+
return (_jsx("div", { style: {
|
|
72
|
+
display: 'flex',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
gap: 'var(--vetc-space-12)',
|
|
75
|
+
flexDirection: labelPosition === 'left' ? 'row-reverse' : 'row',
|
|
76
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
77
|
+
cursor: isDisabled ? 'not-allowed' : 'pointer',
|
|
78
|
+
...style,
|
|
79
|
+
}, onClick: handleToggle, children: labelPosition === 'right' ? (_jsxs(_Fragment, { children: [switchEl, labelBlock] })) : (_jsxs(_Fragment, { children: [labelBlock, switchEl] })) }));
|
|
80
|
+
}
|
|
81
|
+
export default Switch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch } from './Switch';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC TabBar (Bottom Navigation)
|
|
3
|
+
* Figma: h=56px, label=12px/semibold, icon=24px
|
|
4
|
+
* variant: neutral (gray-90 active) | brand (green-40 active)
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
export interface TabBarItem {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
icon: React.ReactNode;
|
|
11
|
+
activeIcon?: React.ReactNode;
|
|
12
|
+
badge?: number | string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type TabBarVariant = 'neutral' | 'brand';
|
|
16
|
+
export interface TabBarProps {
|
|
17
|
+
items: TabBarItem[];
|
|
18
|
+
activeKey?: string;
|
|
19
|
+
onChange?: (key: string) => void;
|
|
20
|
+
variant?: TabBarVariant;
|
|
21
|
+
backgroundColor?: string;
|
|
22
|
+
divider?: boolean;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
id?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function TabBar({ items, activeKey, onChange, variant, backgroundColor, divider, className, style, id, }: TabBarProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export default TabBar;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function TabBar({ items, activeKey, onChange, variant = 'brand', backgroundColor, divider = true, className = '', style, id, }) {
|
|
3
|
+
const activeColor = variant === 'brand'
|
|
4
|
+
? 'var(--vetc-tab-color-active)'
|
|
5
|
+
: 'var(--vetc-color-text-primary)';
|
|
6
|
+
return (_jsx("nav", { id: id, className: `vetc-tab-bar ${className}`, style: {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
alignItems: 'stretch',
|
|
9
|
+
height: 'var(--vetc-tab-height)',
|
|
10
|
+
backgroundColor: backgroundColor ?? 'var(--vetc-tab-bg)',
|
|
11
|
+
borderTop: divider ? `1px solid var(--vetc-tab-border)` : 'none',
|
|
12
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
13
|
+
...style,
|
|
14
|
+
}, children: items.map((item) => {
|
|
15
|
+
const isActive = item.key === activeKey;
|
|
16
|
+
const color = item.disabled
|
|
17
|
+
? 'var(--vetc-tab-color-disabled)'
|
|
18
|
+
: isActive
|
|
19
|
+
? activeColor
|
|
20
|
+
: 'var(--vetc-tab-color-inactive)';
|
|
21
|
+
return (_jsxs("button", { disabled: item.disabled, onClick: () => !item.disabled && onChange?.(item.key), "aria-current": isActive ? 'page' : undefined, "aria-label": item.label, className: `vetc-tab-bar__item${isActive ? ' vetc-tab-bar__item--active' : ''}`, style: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
display: 'flex',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
alignItems: 'center',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
gap: 'var(--vetc-space-2)',
|
|
28
|
+
background: 'none',
|
|
29
|
+
border: 'none',
|
|
30
|
+
cursor: item.disabled ? 'not-allowed' : 'pointer',
|
|
31
|
+
padding: `var(--vetc-space-6) 0`,
|
|
32
|
+
position: 'relative',
|
|
33
|
+
opacity: item.disabled ? 0.5 : 1,
|
|
34
|
+
transition: `color var(--vetc-transition-fast)`,
|
|
35
|
+
color,
|
|
36
|
+
}, children: [_jsxs("div", { style: { position: 'relative', display: 'inline-flex' }, children: [_jsx("span", { style: { color, display: 'flex', fontSize: '24px', lineHeight: 1 }, children: isActive && item.activeIcon ? item.activeIcon : item.icon }), item.badge !== undefined && (_jsx("span", { style: {
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
top: 'calc(-1 * var(--vetc-space-4))',
|
|
39
|
+
right: 'calc(-1 * var(--vetc-space-8))',
|
|
40
|
+
minWidth: 'var(--vetc-tab-badge-size)',
|
|
41
|
+
height: 'var(--vetc-tab-badge-size)',
|
|
42
|
+
backgroundColor: 'var(--vetc-tab-badge-bg)',
|
|
43
|
+
borderRadius: 'var(--vetc-radius-pill)',
|
|
44
|
+
fontSize: 'var(--vetc-tab-badge-font-size)',
|
|
45
|
+
fontWeight: 'var(--vetc-font-weight-semibold)',
|
|
46
|
+
color: 'var(--vetc-tab-badge-text)',
|
|
47
|
+
display: 'flex',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
padding: `0 var(--vetc-space-4)`,
|
|
51
|
+
lineHeight: 1,
|
|
52
|
+
}, children: item.badge }))] }), _jsx("span", { style: {
|
|
53
|
+
fontSize: 'var(--vetc-tab-label-size)',
|
|
54
|
+
fontWeight: 'var(--vetc-tab-label-weight)',
|
|
55
|
+
color,
|
|
56
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
57
|
+
}, children: item.label })] }, item.key));
|
|
58
|
+
}) }));
|
|
59
|
+
}
|
|
60
|
+
export default TabBar;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TabBar } from './TabBar';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VETC Textarea — tokenized
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export interface TextareaProps {
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
helperText?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
showCount?: boolean;
|
|
16
|
+
rows?: number;
|
|
17
|
+
autoSize?: boolean | {
|
|
18
|
+
minRows?: number;
|
|
19
|
+
maxRows?: number;
|
|
20
|
+
};
|
|
21
|
+
onChange?: (value: string) => void;
|
|
22
|
+
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
|
23
|
+
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
|
24
|
+
id?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: React.CSSProperties;
|
|
28
|
+
required?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function Textarea({ label, placeholder, value, defaultValue, helperText, error, disabled, readOnly, maxLength, showCount, rows, autoSize, onChange, onFocus, onBlur, id, name, className, style, required, }: TextareaProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export default Textarea;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input as AntInput } from 'antd';
|
|
3
|
+
const { TextArea: AntTextArea } = AntInput;
|
|
4
|
+
function FieldLabel({ htmlFor, required, disabled, children }) {
|
|
5
|
+
return (_jsxs("label", { htmlFor: htmlFor, style: {
|
|
6
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
7
|
+
fontSize: 'var(--vetc-input-label-font-size)',
|
|
8
|
+
fontWeight: 'var(--vetc-input-label-font-weight)',
|
|
9
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
10
|
+
color: disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-input-label-color)',
|
|
11
|
+
display: 'block',
|
|
12
|
+
}, children: [children, required && _jsx("span", { style: { color: 'var(--vetc-color-negative)', marginLeft: 'var(--vetc-space-2)' }, children: "*" })] }));
|
|
13
|
+
}
|
|
14
|
+
export function Textarea({ label, placeholder, value, defaultValue, helperText, error, disabled = false, readOnly = false, maxLength, showCount = false, rows = 4, autoSize, onChange, onFocus, onBlur, id, name, className = '', style, required = false, }) {
|
|
15
|
+
const hasError = !!error;
|
|
16
|
+
const helperMsg = error ?? helperText;
|
|
17
|
+
const helperColor = hasError
|
|
18
|
+
? 'var(--vetc-input-helper-color-error)'
|
|
19
|
+
: 'var(--vetc-input-helper-color)';
|
|
20
|
+
return (_jsxs("div", { className: `vetc-textarea-wrapper ${className}`, style: { display: 'flex', flexDirection: 'column', gap: 'var(--vetc-input-gap)', ...style }, children: [label && _jsx(FieldLabel, { htmlFor: id, required: required, disabled: disabled, children: label }), _jsx(AntTextArea, { id: id, name: name, value: value, defaultValue: defaultValue, placeholder: placeholder, disabled: disabled, readOnly: readOnly, maxLength: maxLength, showCount: showCount, rows: rows, autoSize: autoSize, status: hasError ? 'error' : undefined, onChange: (e) => onChange?.(e.target.value), onFocus: onFocus, onBlur: onBlur, style: {
|
|
21
|
+
borderRadius: 'var(--vetc-input-radius)',
|
|
22
|
+
padding: 'var(--vetc-input-padding-x)',
|
|
23
|
+
fontSize: 'var(--vetc-input-font-size)',
|
|
24
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
25
|
+
resize: 'vertical',
|
|
26
|
+
} }), helperMsg && (_jsx("span", { style: {
|
|
27
|
+
fontFamily: 'var(--vetc-font-family)',
|
|
28
|
+
fontSize: 'var(--vetc-input-helper-font-size)',
|
|
29
|
+
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
30
|
+
color: helperColor,
|
|
31
|
+
}, children: helperMsg }))] }));
|
|
32
|
+
}
|
|
33
|
+
export default Textarea;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Textarea } from './Textarea';
|