@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
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Checkbox & CheckboxGroup
|
|
3
|
-
* Figma: size=20px, touch-area=48px, states: default/hover/pressed/selected/indeterminate/disabled
|
|
4
|
-
* variant: neutral (gray-90) | brand (green-40)
|
|
5
|
-
*/
|
|
6
|
-
import React, { useState } from 'react';
|
|
7
|
-
|
|
8
|
-
export type CheckboxVariant = 'neutral' | 'brand';
|
|
9
|
-
|
|
10
|
-
export interface CheckboxProps {
|
|
11
|
-
label?: React.ReactNode;
|
|
12
|
-
description?: React.ReactNode;
|
|
13
|
-
checked?: boolean;
|
|
14
|
-
defaultChecked?: boolean;
|
|
15
|
-
indeterminate?: boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
variant?: CheckboxVariant;
|
|
18
|
-
onChange?: (checked: boolean) => void;
|
|
19
|
-
value?: any;
|
|
20
|
-
id?: string;
|
|
21
|
-
className?: string;
|
|
22
|
-
style?: React.CSSProperties;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const CheckIcon = () => (
|
|
26
|
-
<svg width="12" height="9" viewBox="0 0 12 9" fill="none" aria-hidden="true">
|
|
27
|
-
<path d="M1 4L4.5 7.5L11 1" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
|
|
28
|
-
</svg>
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const IndeterminateIcon = () => (
|
|
32
|
-
<svg width="10" height="2" viewBox="0 0 10 2" fill="none" aria-hidden="true">
|
|
33
|
-
<path d="M1 1H9" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
|
|
34
|
-
</svg>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export function Checkbox({
|
|
38
|
-
label,
|
|
39
|
-
description,
|
|
40
|
-
checked,
|
|
41
|
-
defaultChecked = false,
|
|
42
|
-
indeterminate = false,
|
|
43
|
-
disabled = false,
|
|
44
|
-
variant = 'brand',
|
|
45
|
-
onChange,
|
|
46
|
-
value,
|
|
47
|
-
id,
|
|
48
|
-
className = '',
|
|
49
|
-
style,
|
|
50
|
-
}: CheckboxProps) {
|
|
51
|
-
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
52
|
-
const [hovered, setHovered] = useState(false);
|
|
53
|
-
|
|
54
|
-
const isControlled = checked !== undefined;
|
|
55
|
-
const isChecked = isControlled ? checked : internalChecked;
|
|
56
|
-
const isActive = isChecked || indeterminate;
|
|
57
|
-
|
|
58
|
-
const handleChange = () => {
|
|
59
|
-
if (disabled) return;
|
|
60
|
-
const next = !isChecked;
|
|
61
|
-
if (!isControlled) setInternalChecked(next);
|
|
62
|
-
onChange?.(next);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const accentColor = variant === 'brand'
|
|
66
|
-
? 'var(--vetc-color-brand)'
|
|
67
|
-
: 'var(--vetc-gray-90)';
|
|
68
|
-
const accentHover = variant === 'brand'
|
|
69
|
-
? 'var(--vetc-color-brand-hover)'
|
|
70
|
-
: 'var(--vetc-gray-70)';
|
|
71
|
-
|
|
72
|
-
let boxBg = 'transparent';
|
|
73
|
-
let boxBorder = disabled ? 'var(--vetc-color-border-disabled)' : hovered ? accentColor : 'var(--vetc-color-border)';
|
|
74
|
-
let iconColor = 'var(--vetc-white)';
|
|
75
|
-
|
|
76
|
-
if (isActive) {
|
|
77
|
-
boxBg = disabled ? 'var(--vetc-color-bg-disabled)' : accentColor;
|
|
78
|
-
boxBorder = disabled ? 'var(--vetc-color-border-disabled)' : hovered ? accentHover : accentColor;
|
|
79
|
-
iconColor = disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-white)';
|
|
80
|
-
if (disabled) boxBg = 'var(--vetc-color-bg-disabled)';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<label
|
|
85
|
-
htmlFor={id}
|
|
86
|
-
className={`vetc-checkbox ${className}`}
|
|
87
|
-
onMouseEnter={() => !disabled && setHovered(true)}
|
|
88
|
-
onMouseLeave={() => setHovered(false)}
|
|
89
|
-
style={{
|
|
90
|
-
display: 'inline-flex',
|
|
91
|
-
alignItems: description ? 'flex-start' : 'center',
|
|
92
|
-
gap: 'var(--vetc-space-12)',
|
|
93
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
94
|
-
userSelect: 'none',
|
|
95
|
-
fontFamily: 'var(--vetc-font-family)',
|
|
96
|
-
...style,
|
|
97
|
-
}}
|
|
98
|
-
>
|
|
99
|
-
<input
|
|
100
|
-
id={id}
|
|
101
|
-
type="checkbox"
|
|
102
|
-
checked={isChecked}
|
|
103
|
-
disabled={disabled}
|
|
104
|
-
value={value}
|
|
105
|
-
onChange={handleChange}
|
|
106
|
-
style={{ position: 'absolute', opacity: 0, width: 0, height: 0, pointerEvents: 'none' }}
|
|
107
|
-
aria-checked={indeterminate ? 'mixed' : isChecked}
|
|
108
|
-
/>
|
|
109
|
-
|
|
110
|
-
{/* Visual box */}
|
|
111
|
-
<span
|
|
112
|
-
aria-hidden="true"
|
|
113
|
-
style={{
|
|
114
|
-
width: '20px',
|
|
115
|
-
height: '20px',
|
|
116
|
-
flexShrink: 0,
|
|
117
|
-
borderRadius: 'var(--vetc-radius-xs)',
|
|
118
|
-
border: `1.5px solid ${boxBorder}`,
|
|
119
|
-
backgroundColor: boxBg,
|
|
120
|
-
display: 'flex',
|
|
121
|
-
alignItems: 'center',
|
|
122
|
-
justifyContent: 'center',
|
|
123
|
-
transition: 'background-color var(--vetc-transition-fast), border-color var(--vetc-transition-fast)',
|
|
124
|
-
color: iconColor,
|
|
125
|
-
marginTop: description ? '2px' : 0,
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
{isChecked && !indeterminate && <CheckIcon />}
|
|
129
|
-
{indeterminate && <IndeterminateIcon />}
|
|
130
|
-
</span>
|
|
131
|
-
|
|
132
|
-
{/* Label + description */}
|
|
133
|
-
{(label || description) && (
|
|
134
|
-
<span style={{ display: 'flex', flexDirection: 'column', gap: 'var(--vetc-space-2)' }}>
|
|
135
|
-
{label && (
|
|
136
|
-
<span style={{
|
|
137
|
-
fontSize: 'var(--vetc-font-size-base)',
|
|
138
|
-
fontWeight: 'var(--vetc-font-weight-regular)' as any,
|
|
139
|
-
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
140
|
-
color: disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-primary)',
|
|
141
|
-
}}>
|
|
142
|
-
{label}
|
|
143
|
-
</span>
|
|
144
|
-
)}
|
|
145
|
-
{description && (
|
|
146
|
-
<span style={{
|
|
147
|
-
fontSize: 'var(--vetc-font-size-sm)',
|
|
148
|
-
fontWeight: 'var(--vetc-font-weight-regular)' as any,
|
|
149
|
-
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
150
|
-
color: disabled ? 'var(--vetc-color-text-disabled)' : 'var(--vetc-color-text-secondary)',
|
|
151
|
-
}}>
|
|
152
|
-
{description}
|
|
153
|
-
</span>
|
|
154
|
-
)}
|
|
155
|
-
</span>
|
|
156
|
-
)}
|
|
157
|
-
</label>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// ── CheckboxGroup ─────────────────────────────────────────────────────────────
|
|
162
|
-
export interface CheckboxOption {
|
|
163
|
-
label: React.ReactNode;
|
|
164
|
-
description?: React.ReactNode;
|
|
165
|
-
value: any;
|
|
166
|
-
disabled?: boolean;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface CheckboxGroupProps {
|
|
170
|
-
options: CheckboxOption[];
|
|
171
|
-
value?: any[];
|
|
172
|
-
defaultValue?: any[];
|
|
173
|
-
direction?: 'horizontal' | 'vertical';
|
|
174
|
-
disabled?: boolean;
|
|
175
|
-
variant?: CheckboxVariant;
|
|
176
|
-
onChange?: (values: any[]) => void;
|
|
177
|
-
className?: string;
|
|
178
|
-
style?: React.CSSProperties;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export function CheckboxGroup({
|
|
182
|
-
options,
|
|
183
|
-
value,
|
|
184
|
-
defaultValue = [],
|
|
185
|
-
direction = 'vertical',
|
|
186
|
-
disabled = false,
|
|
187
|
-
variant = 'brand',
|
|
188
|
-
onChange,
|
|
189
|
-
className = '',
|
|
190
|
-
style,
|
|
191
|
-
}: CheckboxGroupProps) {
|
|
192
|
-
const [internalValue, setInternalValue] = useState<any[]>(defaultValue);
|
|
193
|
-
const isControlled = value !== undefined;
|
|
194
|
-
const currentValue = isControlled ? value! : internalValue;
|
|
195
|
-
|
|
196
|
-
const handleChange = (optValue: any, checked: boolean) => {
|
|
197
|
-
const next = checked
|
|
198
|
-
? [...currentValue, optValue]
|
|
199
|
-
: currentValue.filter((v) => v !== optValue);
|
|
200
|
-
if (!isControlled) setInternalValue(next);
|
|
201
|
-
onChange?.(next);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
return (
|
|
205
|
-
<div
|
|
206
|
-
className={`vetc-checkbox-group ${className}`}
|
|
207
|
-
style={{
|
|
208
|
-
display: 'flex',
|
|
209
|
-
flexDirection: direction === 'vertical' ? 'column' : 'row',
|
|
210
|
-
flexWrap: direction === 'horizontal' ? 'wrap' : undefined,
|
|
211
|
-
gap: direction === 'vertical' ? 'var(--vetc-space-12)' : 'var(--vetc-space-16)',
|
|
212
|
-
fontFamily: 'var(--vetc-font-family)',
|
|
213
|
-
...style,
|
|
214
|
-
}}
|
|
215
|
-
>
|
|
216
|
-
{options.map((opt) => (
|
|
217
|
-
<Checkbox
|
|
218
|
-
key={String(opt.value)}
|
|
219
|
-
label={opt.label}
|
|
220
|
-
description={opt.description}
|
|
221
|
-
checked={currentValue.includes(opt.value)}
|
|
222
|
-
disabled={opt.disabled ?? disabled}
|
|
223
|
-
variant={variant}
|
|
224
|
-
value={opt.value}
|
|
225
|
-
onChange={(chk) => handleChange(opt.value, chk)}
|
|
226
|
-
/>
|
|
227
|
-
))}
|
|
228
|
-
</div>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export default Checkbox;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Chip / Tag — tokenized
|
|
3
|
-
* Figma: Chip page (7 types × 3 styles)
|
|
4
|
-
*/
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { Tag as AntTag } from 'antd';
|
|
7
|
-
|
|
8
|
-
export type ChipStyle = 'filled' | 'outlined' | 'tinted';
|
|
9
|
-
export type ChipType = 'default' | 'brand' | 'positive' | 'negative' | 'warning' | 'info';
|
|
10
|
-
export type ChipShape = 'pill' | 'rounded';
|
|
11
|
-
|
|
12
|
-
// Map type → CSS vars (from tokens.css --vetc-chip-*)
|
|
13
|
-
const typeVarMap: Record<ChipType, { bg: string; border: string; text: string; filledBg: string }> = {
|
|
14
|
-
default: {
|
|
15
|
-
bg: 'var(--vetc-chip-default-bg)',
|
|
16
|
-
border: 'var(--vetc-chip-default-border)',
|
|
17
|
-
text: 'var(--vetc-chip-default-text)',
|
|
18
|
-
filledBg: 'var(--vetc-chip-default-filled-bg)',
|
|
19
|
-
},
|
|
20
|
-
brand: {
|
|
21
|
-
bg: 'var(--vetc-chip-brand-bg)',
|
|
22
|
-
border: 'var(--vetc-chip-brand-border)',
|
|
23
|
-
text: 'var(--vetc-chip-brand-text)',
|
|
24
|
-
filledBg: 'var(--vetc-chip-brand-filled-bg)',
|
|
25
|
-
},
|
|
26
|
-
positive: {
|
|
27
|
-
bg: 'var(--vetc-chip-positive-bg)',
|
|
28
|
-
border: 'var(--vetc-chip-positive-border)',
|
|
29
|
-
text: 'var(--vetc-chip-positive-text)',
|
|
30
|
-
filledBg: 'var(--vetc-chip-positive-filled-bg)',
|
|
31
|
-
},
|
|
32
|
-
negative: {
|
|
33
|
-
bg: 'var(--vetc-chip-negative-bg)',
|
|
34
|
-
border: 'var(--vetc-chip-negative-border)',
|
|
35
|
-
text: 'var(--vetc-chip-negative-text)',
|
|
36
|
-
filledBg: 'var(--vetc-chip-negative-filled-bg)',
|
|
37
|
-
},
|
|
38
|
-
warning: {
|
|
39
|
-
bg: 'var(--vetc-chip-warning-bg)',
|
|
40
|
-
border: 'var(--vetc-chip-warning-border)',
|
|
41
|
-
text: 'var(--vetc-chip-warning-text)',
|
|
42
|
-
filledBg: 'var(--vetc-chip-warning-filled-bg)',
|
|
43
|
-
},
|
|
44
|
-
info: {
|
|
45
|
-
bg: 'var(--vetc-chip-info-bg)',
|
|
46
|
-
border: 'var(--vetc-chip-info-border)',
|
|
47
|
-
text: 'var(--vetc-chip-info-text)',
|
|
48
|
-
filledBg: 'var(--vetc-chip-info-filled-bg)',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export interface ChipProps {
|
|
53
|
-
style?: ChipStyle;
|
|
54
|
-
type?: ChipType;
|
|
55
|
-
shape?: ChipShape;
|
|
56
|
-
size?: 'md' | 'sm';
|
|
57
|
-
icon?: React.ReactNode;
|
|
58
|
-
closable?: boolean;
|
|
59
|
-
onClose?: () => void;
|
|
60
|
-
onClick?: () => void;
|
|
61
|
-
children?: React.ReactNode;
|
|
62
|
-
className?: string;
|
|
63
|
-
css?: React.CSSProperties;
|
|
64
|
-
id?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function Chip({
|
|
68
|
-
style = 'tinted',
|
|
69
|
-
type = 'default',
|
|
70
|
-
shape = 'pill',
|
|
71
|
-
size = 'md',
|
|
72
|
-
icon,
|
|
73
|
-
closable = false,
|
|
74
|
-
onClose,
|
|
75
|
-
onClick,
|
|
76
|
-
children,
|
|
77
|
-
className = '',
|
|
78
|
-
css,
|
|
79
|
-
id,
|
|
80
|
-
}: ChipProps) {
|
|
81
|
-
const vars = typeVarMap[type];
|
|
82
|
-
|
|
83
|
-
const height = size === 'md' ? 'var(--vetc-chip-height-md)' : 'var(--vetc-chip-height-sm)';
|
|
84
|
-
const paddingX = size === 'md' ? 'var(--vetc-chip-padding-x-md)' : 'var(--vetc-chip-padding-x-sm)';
|
|
85
|
-
const fontSize = size === 'md' ? 'var(--vetc-chip-font-size-md)' : 'var(--vetc-chip-font-size-sm)';
|
|
86
|
-
const fontWeight = 'var(--vetc-chip-font-weight)';
|
|
87
|
-
const borderRadius = shape === 'pill' ? 'var(--vetc-chip-radius-pill)' : 'var(--vetc-chip-radius-rounded)';
|
|
88
|
-
|
|
89
|
-
let bg = vars.bg;
|
|
90
|
-
let border = `1px solid ${vars.border}`;
|
|
91
|
-
let textColor = vars.text;
|
|
92
|
-
|
|
93
|
-
if (style === 'filled') {
|
|
94
|
-
bg = vars.filledBg;
|
|
95
|
-
border = 'none';
|
|
96
|
-
textColor = 'var(--vetc-white)';
|
|
97
|
-
} else if (style === 'outlined') {
|
|
98
|
-
bg = 'transparent';
|
|
99
|
-
border = `1px solid ${vars.border}`;
|
|
100
|
-
textColor = vars.text;
|
|
101
|
-
}
|
|
102
|
-
// tinted: bg + border (default)
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<AntTag
|
|
106
|
-
id={id}
|
|
107
|
-
closable={closable}
|
|
108
|
-
onClose={(e) => { e.preventDefault(); onClose?.(); }}
|
|
109
|
-
onClick={onClick}
|
|
110
|
-
icon={icon}
|
|
111
|
-
className={`vetc-chip vetc-chip--${style} vetc-chip--${type} ${className}`}
|
|
112
|
-
style={{
|
|
113
|
-
display: 'inline-flex',
|
|
114
|
-
alignItems: 'center',
|
|
115
|
-
height,
|
|
116
|
-
padding: `0 ${paddingX}`,
|
|
117
|
-
borderRadius,
|
|
118
|
-
background: bg,
|
|
119
|
-
border,
|
|
120
|
-
color: textColor,
|
|
121
|
-
fontSize,
|
|
122
|
-
fontWeight: fontWeight as any,
|
|
123
|
-
fontFamily: 'var(--vetc-font-family)',
|
|
124
|
-
cursor: onClick ? 'pointer' : 'default',
|
|
125
|
-
userSelect: 'none',
|
|
126
|
-
lineHeight: 1,
|
|
127
|
-
gap: 'var(--vetc-space-4)',
|
|
128
|
-
transition: 'var(--vetc-transition-fast)',
|
|
129
|
-
...css,
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
{children}
|
|
133
|
-
</AntTag>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export default Chip;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
import { Button } from '../button';
|
|
4
|
-
|
|
5
|
-
export interface DialogProps {
|
|
6
|
-
open: boolean;
|
|
7
|
-
/** Optional image URL shown at the top of the dialog */
|
|
8
|
-
image?: string;
|
|
9
|
-
title?: React.ReactNode;
|
|
10
|
-
description?: React.ReactNode;
|
|
11
|
-
okText?: string;
|
|
12
|
-
cancelText?: string;
|
|
13
|
-
okDisabled?: boolean;
|
|
14
|
-
okLoading?: boolean;
|
|
15
|
-
okDanger?: boolean;
|
|
16
|
-
onOk?: () => void;
|
|
17
|
-
onCancel?: () => void;
|
|
18
|
-
/** Close dialog when clicking outside (default: true) */
|
|
19
|
-
maskClosable?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function Dialog({
|
|
23
|
-
open,
|
|
24
|
-
image,
|
|
25
|
-
title,
|
|
26
|
-
description,
|
|
27
|
-
okText = 'Xác nhận',
|
|
28
|
-
cancelText = 'Hủy',
|
|
29
|
-
okDisabled = false,
|
|
30
|
-
okLoading = false,
|
|
31
|
-
okDanger = false,
|
|
32
|
-
onOk,
|
|
33
|
-
onCancel,
|
|
34
|
-
maskClosable = true,
|
|
35
|
-
}: DialogProps) {
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (open) document.body.style.overflow = 'hidden';
|
|
38
|
-
else document.body.style.overflow = '';
|
|
39
|
-
return () => { document.body.style.overflow = ''; };
|
|
40
|
-
}, [open]);
|
|
41
|
-
|
|
42
|
-
if (!open) return null;
|
|
43
|
-
|
|
44
|
-
const hasContent = title || description;
|
|
45
|
-
|
|
46
|
-
return createPortal(
|
|
47
|
-
<div
|
|
48
|
-
style={{
|
|
49
|
-
position: 'fixed',
|
|
50
|
-
inset: 0,
|
|
51
|
-
backgroundColor: 'var(--vetc-dialog-overlay)',
|
|
52
|
-
display: 'flex',
|
|
53
|
-
alignItems: 'center',
|
|
54
|
-
justifyContent: 'center',
|
|
55
|
-
zIndex: 1000,
|
|
56
|
-
padding: '0 var(--vetc-space-24)',
|
|
57
|
-
}}
|
|
58
|
-
onClick={maskClosable ? onCancel : undefined}
|
|
59
|
-
>
|
|
60
|
-
<div
|
|
61
|
-
style={{
|
|
62
|
-
width: '100%',
|
|
63
|
-
maxWidth: 'var(--vetc-dialog-width)',
|
|
64
|
-
backgroundColor: 'var(--vetc-dialog-bg)',
|
|
65
|
-
borderRadius: 'var(--vetc-dialog-radius)',
|
|
66
|
-
overflow: 'hidden',
|
|
67
|
-
boxShadow: 'var(--vetc-shadow-lg)',
|
|
68
|
-
fontFamily: 'var(--vetc-font-family)',
|
|
69
|
-
}}
|
|
70
|
-
onClick={e => e.stopPropagation()}
|
|
71
|
-
>
|
|
72
|
-
{image && (
|
|
73
|
-
<div style={{ width: '100%', height: 'var(--vetc-dialog-image-height)', overflow: 'hidden', flexShrink: 0 }}>
|
|
74
|
-
<img
|
|
75
|
-
src={image}
|
|
76
|
-
alt=""
|
|
77
|
-
style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }}
|
|
78
|
-
/>
|
|
79
|
-
</div>
|
|
80
|
-
)}
|
|
81
|
-
|
|
82
|
-
{hasContent && (
|
|
83
|
-
<div style={{ padding: 'var(--vetc-dialog-padding)' }}>
|
|
84
|
-
{title && (
|
|
85
|
-
<div style={{
|
|
86
|
-
fontSize: 'var(--vetc-dialog-title-size)',
|
|
87
|
-
fontWeight: 'var(--vetc-dialog-title-weight)',
|
|
88
|
-
color: 'var(--vetc-color-text-primary)',
|
|
89
|
-
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
90
|
-
marginBottom: description ? 'var(--vetc-space-8)' : 0,
|
|
91
|
-
}}>
|
|
92
|
-
{title}
|
|
93
|
-
</div>
|
|
94
|
-
)}
|
|
95
|
-
{description && (
|
|
96
|
-
<div style={{
|
|
97
|
-
fontSize: 'var(--vetc-dialog-desc-size)',
|
|
98
|
-
color: 'var(--vetc-dialog-desc-color)',
|
|
99
|
-
lineHeight: 'var(--vetc-line-height-relaxed)',
|
|
100
|
-
}}>
|
|
101
|
-
{description}
|
|
102
|
-
</div>
|
|
103
|
-
)}
|
|
104
|
-
</div>
|
|
105
|
-
)}
|
|
106
|
-
|
|
107
|
-
<div style={{
|
|
108
|
-
display: 'flex',
|
|
109
|
-
gap: 'var(--vetc-dialog-btn-gap)',
|
|
110
|
-
padding: hasContent
|
|
111
|
-
? `0 var(--vetc-dialog-padding) var(--vetc-dialog-padding)`
|
|
112
|
-
: 'var(--vetc-dialog-padding)',
|
|
113
|
-
}}>
|
|
114
|
-
{onCancel && (
|
|
115
|
-
<Button block style="outlined" variant="neutral" onClick={onCancel}>
|
|
116
|
-
{cancelText}
|
|
117
|
-
</Button>
|
|
118
|
-
)}
|
|
119
|
-
<Button
|
|
120
|
-
block
|
|
121
|
-
style={okDanger ? 'danger' : 'filled'}
|
|
122
|
-
loading={okLoading}
|
|
123
|
-
disabled={okDisabled}
|
|
124
|
-
onClick={onOk}
|
|
125
|
-
>
|
|
126
|
-
{okText}
|
|
127
|
-
</Button>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
</div>,
|
|
131
|
-
document.body,
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export default Dialog;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VETC Divider — tokenized
|
|
3
|
-
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { Divider as AntDivider } from 'antd';
|
|
6
|
-
|
|
7
|
-
export interface DividerProps {
|
|
8
|
-
orientation?: 'horizontal' | 'vertical';
|
|
9
|
-
label?: React.ReactNode;
|
|
10
|
-
labelAlign?: 'left' | 'center' | 'right';
|
|
11
|
-
thickness?: number;
|
|
12
|
-
color?: string;
|
|
13
|
-
margin?: string;
|
|
14
|
-
className?: string;
|
|
15
|
-
style?: React.CSSProperties;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function Divider({
|
|
19
|
-
orientation = 'horizontal',
|
|
20
|
-
label,
|
|
21
|
-
labelAlign = 'center',
|
|
22
|
-
thickness = 1,
|
|
23
|
-
color,
|
|
24
|
-
margin,
|
|
25
|
-
className = '',
|
|
26
|
-
style,
|
|
27
|
-
}: DividerProps) {
|
|
28
|
-
const isVertical = orientation === 'vertical';
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<AntDivider
|
|
32
|
-
type={isVertical ? 'vertical' : 'horizontal'}
|
|
33
|
-
orientationMargin={labelAlign !== 'center' ? 0 : undefined}
|
|
34
|
-
orientation={labelAlign !== 'center' ? labelAlign as any : undefined}
|
|
35
|
-
className={`vetc-divider ${className}`}
|
|
36
|
-
style={{
|
|
37
|
-
borderColor: color ?? 'var(--vetc-divider-color)',
|
|
38
|
-
borderTopWidth: !isVertical ? thickness : undefined,
|
|
39
|
-
borderLeftWidth: isVertical ? thickness : undefined,
|
|
40
|
-
margin: margin ?? (isVertical
|
|
41
|
-
? `0 var(--vetc-divider-margin-v)`
|
|
42
|
-
: `var(--vetc-divider-margin-h) 0`),
|
|
43
|
-
fontFamily: 'var(--vetc-font-family)',
|
|
44
|
-
fontSize: 'var(--vetc-divider-label-size)',
|
|
45
|
-
color: 'var(--vetc-divider-label-color)',
|
|
46
|
-
...style,
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
{label}
|
|
50
|
-
</AntDivider>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default Divider;
|