@mks2508/mks-ui 0.5.1 → 0.5.4
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/react-ui/index.js +8 -1
- package/dist/react-ui/primitives/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts +103 -0
- package/dist/react-ui/primitives/waapi/Gooey/Gooey.types.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts +10 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyCanvas.js +59 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/GooeyFilter.js +78 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/MorphPath.js +51 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts +87 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/gooey-utils.js +177 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts +28 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/index.js +5 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts +7 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.d.ts.map +1 -0
- package/dist/react-ui/primitives/waapi/Gooey/useMorphPath.js +47 -0
- package/dist/react-ui/primitives/waapi/index.d.ts +2 -0
- package/dist/react-ui/primitives/waapi/index.d.ts.map +1 -1
- package/dist/react-ui/primitives/waapi/index.js +6 -0
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts +26 -16
- package/dist/react-ui/ui/DataCard/DataCard.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/DataCard.styles.js +36 -74
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts +50 -70
- package/dist/react-ui/ui/DataCard/DataCard.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.d.ts +24 -93
- package/dist/react-ui/ui/DataCard/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DataCard/index.js +76 -118
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle-Cm6-VceQ.css +304 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.css +303 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.js +0 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts +35 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +67 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +138 -0
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/index.d.ts +31 -0
- package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -0
- package/dist/react-ui/ui/DynamicToggle/index.js +188 -0
- package/dist/react-ui/ui/Switch/index.js +1 -1
- package/dist/react-ui/ui/index.d.ts +1 -0
- package/dist/react-ui/ui/index.d.ts.map +1 -1
- package/dist/react-ui/ui/index.js +2 -0
- package/package.json +2 -2
- package/src/css.d.ts +1 -0
- package/src/react-ui/primitives/waapi/Gooey/Gooey.types.ts +123 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyCanvas.tsx +80 -0
- package/src/react-ui/primitives/waapi/Gooey/GooeyFilter.tsx +77 -0
- package/src/react-ui/primitives/waapi/Gooey/MorphPath.tsx +58 -0
- package/src/react-ui/primitives/waapi/Gooey/gooey-utils.ts +244 -0
- package/src/react-ui/primitives/waapi/Gooey/index.ts +50 -0
- package/src/react-ui/primitives/waapi/Gooey/useMorphPath.ts +48 -0
- package/src/react-ui/primitives/waapi/index.ts +23 -0
- package/src/react-ui/ui/DataCard/DataCard.styles.ts +45 -101
- package/src/react-ui/ui/DataCard/DataCard.types.ts +52 -73
- package/src/react-ui/ui/DataCard/index.tsx +118 -184
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.css +303 -0
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +85 -0
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +174 -0
- package/src/react-ui/ui/DynamicToggle/index.tsx +294 -0
- package/src/react-ui/ui/DynamicToggle/prototype-v7.html +615 -0
- package/src/react-ui/ui/DynamicToggle/prototype.html +419 -0
- package/src/react-ui/ui/Switch/index.tsx +1 -1
- package/src/react-ui/ui/index.ts +3 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-filter-dropdown.module-CNVWCefU.css → terminal-filter-dropdown.module-C6oDcFBS.css} +0 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-session-tabs.module-cmyJ11jP.css → terminal-session-tabs.module-D_-sgyza.css} +0 -0
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-BycNI8nU.css → morphing-popover.module-B1ftlaYj.css} +0 -0
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* DataCard — glassmorphism dashboard metric card.
|
|
5
|
+
*
|
|
6
|
+
* Features: animated numbers, corner brackets, toggle, size/variant CVA,
|
|
7
|
+
* state-based styling, slot overrides, config for animation tuning.
|
|
8
|
+
*
|
|
9
|
+
* @module @mks2508/mks-ui/react/ui/DataCard
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <DataCard variant="accent" size="default">
|
|
14
|
+
* <DataCardLabel title="Revenue" description="This month" />
|
|
15
|
+
* <DataCardValue number={45678} unit="$" />
|
|
16
|
+
* </DataCard>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
3
20
|
import * as React from 'react';
|
|
4
|
-
import { motion
|
|
21
|
+
import { motion } from 'motion/react';
|
|
5
22
|
import { cn } from '@/react-ui/lib/utils';
|
|
6
23
|
import { getStrictContext } from '@/react-ui/lib/get-strict-context';
|
|
7
|
-
import { useControlledState } from '@/react-ui/hooks/State/UseControlledState';
|
|
8
24
|
|
|
9
|
-
// Import from existing components
|
|
10
25
|
import { CornerBracket } from '@/react-ui/ui/CornerBracket';
|
|
11
26
|
import { CountingNumber } from '@/react-ui/primitives/CountingNumber';
|
|
12
27
|
import { Switch, SwitchThumb } from '@/react-ui/ui/Switch';
|
|
13
28
|
|
|
14
|
-
import { dataCardVariants, dataCardStyles, bracketVariants
|
|
29
|
+
import { dataCardVariants, dataCardStyles, bracketVariants } from './DataCard.styles';
|
|
15
30
|
import type { SlotOverrides } from '@/core/types';
|
|
16
31
|
import type {
|
|
17
32
|
IDataCardProps,
|
|
@@ -21,51 +36,35 @@ import type {
|
|
|
21
36
|
IDataCardActionsProps,
|
|
22
37
|
IDataCardBracketProps,
|
|
23
38
|
IDataCardState,
|
|
39
|
+
IDataCardConfig,
|
|
24
40
|
DataCardSlot,
|
|
25
41
|
} from './DataCard.types';
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// Context
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
30
47
|
type DataCardContextType = {
|
|
31
|
-
/** Current variant of: card. */
|
|
32
48
|
variant: IDataCardProps['variant'];
|
|
33
|
-
/** Current size of: card. */
|
|
34
49
|
size: IDataCardProps['size'];
|
|
35
|
-
/** Whether card is disabled. */
|
|
36
50
|
disabled: boolean;
|
|
37
|
-
/** Whether glass effect is enabled. */
|
|
38
51
|
glass: boolean;
|
|
39
|
-
|
|
52
|
+
config?: IDataCardConfig;
|
|
40
53
|
slots?: SlotOverrides<DataCardSlot>;
|
|
41
|
-
/** Update interaction state. */
|
|
42
|
-
setState: React.Dispatch<React.SetStateAction<IDataCardState>>;
|
|
43
54
|
};
|
|
44
55
|
|
|
45
56
|
const [DataCardProvider, useDataCard] =
|
|
46
57
|
getStrictContext<DataCardContextType>('DataCardContext');
|
|
47
58
|
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// DataCard (Root)
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
48
63
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* Features:
|
|
52
|
-
* - Slot overrides for customization
|
|
53
|
-
* - State-based styling (hover, pressed, disabled)
|
|
54
|
-
* - CVA variants (size, color variant)
|
|
55
|
-
* - asChild composition pattern
|
|
56
|
-
* - Motion/animation integration
|
|
57
|
-
* - Custom render functions
|
|
58
|
-
* - Form field integration
|
|
59
|
-
* - Icon composition
|
|
60
|
-
* - Glassmorphism effects
|
|
64
|
+
* Root card container with glassmorphism, corner brackets, and state tracking.
|
|
61
65
|
*
|
|
62
|
-
* @
|
|
63
|
-
*
|
|
64
|
-
* <DataCard variant="accent" size="default">
|
|
65
|
-
* <DataCardValue number={1234} />
|
|
66
|
-
* <DataCardToggle />
|
|
67
|
-
* </DataCard>
|
|
68
|
-
* ```
|
|
66
|
+
* @param props - {@link IDataCardProps}
|
|
67
|
+
* @returns A motion.div card with context provider
|
|
69
68
|
*/
|
|
70
69
|
function DataCard({
|
|
71
70
|
variant = 'default',
|
|
@@ -78,32 +77,20 @@ function DataCard({
|
|
|
78
77
|
slots,
|
|
79
78
|
config,
|
|
80
79
|
children,
|
|
81
|
-
...props
|
|
82
80
|
}: IDataCardProps) {
|
|
83
81
|
const [state, setState] = React.useState<IDataCardState>({
|
|
84
82
|
hovered: false,
|
|
85
83
|
pressed: false,
|
|
86
|
-
disabled
|
|
84
|
+
disabled,
|
|
87
85
|
});
|
|
88
86
|
|
|
89
87
|
const contextValue: DataCardContextType = React.useMemo(
|
|
90
|
-
() => ({ variant, size, disabled
|
|
91
|
-
[variant, size, disabled, glass, slots]
|
|
88
|
+
() => ({ variant, size, disabled, glass, config, slots }),
|
|
89
|
+
[variant, size, disabled, glass, config, slots],
|
|
92
90
|
);
|
|
93
91
|
|
|
94
|
-
const computedClassName =
|
|
95
|
-
|
|
96
|
-
return className(state);
|
|
97
|
-
}
|
|
98
|
-
return className;
|
|
99
|
-
}, [className, state]);
|
|
100
|
-
|
|
101
|
-
const computedStyle = React.useMemo(() => {
|
|
102
|
-
if (typeof style === 'function') {
|
|
103
|
-
return style(state);
|
|
104
|
-
}
|
|
105
|
-
return style;
|
|
106
|
-
}, [style, state]);
|
|
92
|
+
const computedClassName = typeof className === 'function' ? className(state) : className;
|
|
93
|
+
const computedStyle = typeof style === 'function' ? style(state) : style;
|
|
107
94
|
|
|
108
95
|
return (
|
|
109
96
|
<DataCardProvider value={contextValue}>
|
|
@@ -115,38 +102,23 @@ function DataCard({
|
|
|
115
102
|
aria-disabled={disabled || undefined}
|
|
116
103
|
className={cn(
|
|
117
104
|
dataCardVariants({ variant, size, glass }),
|
|
105
|
+
disabled && 'opacity-50 pointer-events-none',
|
|
118
106
|
slots?.root,
|
|
119
107
|
computedClassName,
|
|
120
|
-
state.hovered && dataCardStateStyles.hovered,
|
|
121
|
-
state.pressed && dataCardStateStyles.pressed,
|
|
122
|
-
disabled && dataCardStateStyles.disabled
|
|
123
108
|
)}
|
|
124
109
|
style={computedStyle}
|
|
125
|
-
onHoverStart={() => setState((
|
|
126
|
-
onHoverEnd={() => setState((
|
|
127
|
-
onTapStart={() => setState((
|
|
128
|
-
onTap={() => setState((
|
|
129
|
-
onTapCancel={() => setState((
|
|
130
|
-
{...props}
|
|
110
|
+
onHoverStart={() => setState((p) => ({ ...p, hovered: true }))}
|
|
111
|
+
onHoverEnd={() => setState((p) => ({ ...p, hovered: false }))}
|
|
112
|
+
onTapStart={() => setState((p) => ({ ...p, pressed: true }))}
|
|
113
|
+
onTap={() => setState((p) => ({ ...p, pressed: false }))}
|
|
114
|
+
onTapCancel={() => setState((p) => ({ ...p, pressed: false }))}
|
|
131
115
|
>
|
|
132
116
|
{showBrackets && (
|
|
133
117
|
<>
|
|
134
|
-
<DataCardBracket
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/>
|
|
138
|
-
<DataCardBracket
|
|
139
|
-
position="tr"
|
|
140
|
-
variant={variant === 'accent' ? 'accent' : 'default'}
|
|
141
|
-
/>
|
|
142
|
-
<DataCardBracket
|
|
143
|
-
position="bl"
|
|
144
|
-
variant={variant === 'accent' ? 'accent' : 'default'}
|
|
145
|
-
/>
|
|
146
|
-
<DataCardBracket
|
|
147
|
-
position="br"
|
|
148
|
-
variant={variant === 'accent' ? 'accent' : 'default'}
|
|
149
|
-
/>
|
|
118
|
+
<DataCardBracket position="tl" variant={variant === 'accent' ? 'accent' : 'default'} />
|
|
119
|
+
<DataCardBracket position="tr" variant={variant === 'accent' ? 'accent' : 'default'} />
|
|
120
|
+
<DataCardBracket position="bl" variant={variant === 'accent' ? 'accent' : 'default'} />
|
|
121
|
+
<DataCardBracket position="br" variant={variant === 'accent' ? 'accent' : 'default'} />
|
|
150
122
|
</>
|
|
151
123
|
)}
|
|
152
124
|
{children}
|
|
@@ -155,17 +127,15 @@ function DataCard({
|
|
|
155
127
|
);
|
|
156
128
|
}
|
|
157
129
|
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// DataCardValue
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
|
|
158
134
|
/**
|
|
159
|
-
*
|
|
135
|
+
* Animated number display with optional label and unit.
|
|
160
136
|
*
|
|
161
|
-
* @
|
|
162
|
-
*
|
|
163
|
-
* <DataCardValue
|
|
164
|
-
* number={1234}
|
|
165
|
-
* label="Active Users"
|
|
166
|
-
* unit="users"
|
|
167
|
-
* />
|
|
168
|
-
* ```
|
|
137
|
+
* @param props - {@link IDataCardValueProps}
|
|
138
|
+
* @returns Animated number with CountingNumber primitive
|
|
169
139
|
*/
|
|
170
140
|
function DataCardValue({
|
|
171
141
|
number,
|
|
@@ -174,10 +144,18 @@ function DataCardValue({
|
|
|
174
144
|
decimalPlaces = 0,
|
|
175
145
|
padStart = false,
|
|
176
146
|
}: IDataCardValueProps) {
|
|
177
|
-
const {
|
|
147
|
+
const { size, config, slots } = useDataCard();
|
|
148
|
+
|
|
149
|
+
const stiffness = config?.counterStiffness ?? 90;
|
|
150
|
+
const damping = config?.counterDamping ?? 10;
|
|
151
|
+
|
|
152
|
+
const sizeClass =
|
|
153
|
+
size === 'compact' ? 'text-3xl font-bold'
|
|
154
|
+
: size === 'spacious' ? 'text-5xl font-bold'
|
|
155
|
+
: 'text-4xl font-bold';
|
|
178
156
|
|
|
179
157
|
return (
|
|
180
|
-
<div data-slot="data-card-value" className={cn(dataCardStyles.value)}>
|
|
158
|
+
<div data-slot="data-card-value" className={cn(dataCardStyles.value, slots?.value)}>
|
|
181
159
|
{label && (
|
|
182
160
|
<span className="text-muted-foreground text-xs uppercase tracking-wider font-mono">
|
|
183
161
|
{label}
|
|
@@ -187,17 +165,8 @@ function DataCardValue({
|
|
|
187
165
|
number={number}
|
|
188
166
|
decimalPlaces={decimalPlaces}
|
|
189
167
|
padStart={padStart}
|
|
190
|
-
transition={{
|
|
191
|
-
|
|
192
|
-
damping: variant === 'accent' ? 20 : 10,
|
|
193
|
-
}}
|
|
194
|
-
className={
|
|
195
|
-
size === 'compact'
|
|
196
|
-
? 'text-3xl font-bold'
|
|
197
|
-
: size === 'spacious'
|
|
198
|
-
? 'text-5xl font-bold'
|
|
199
|
-
: 'text-4xl font-bold'
|
|
200
|
-
}
|
|
168
|
+
transition={{ stiffness, damping }}
|
|
169
|
+
className={sizeClass}
|
|
201
170
|
/>
|
|
202
171
|
{unit && (
|
|
203
172
|
<span className="text-muted-foreground text-lg ml-1">{unit}</span>
|
|
@@ -206,16 +175,15 @@ function DataCardValue({
|
|
|
206
175
|
);
|
|
207
176
|
}
|
|
208
177
|
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
// DataCardLabel
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
|
|
209
182
|
/**
|
|
210
|
-
*
|
|
183
|
+
* Title + description label.
|
|
211
184
|
*
|
|
212
|
-
* @
|
|
213
|
-
*
|
|
214
|
-
* <DataCardLabel
|
|
215
|
-
* title="Revenue"
|
|
216
|
-
* description="This month"
|
|
217
|
-
* />
|
|
218
|
-
* ```
|
|
185
|
+
* @param props - {@link IDataCardLabelProps}
|
|
186
|
+
* @returns Title and optional description text
|
|
219
187
|
*/
|
|
220
188
|
function DataCardLabel({
|
|
221
189
|
title,
|
|
@@ -228,47 +196,31 @@ function DataCardLabel({
|
|
|
228
196
|
return (
|
|
229
197
|
<div
|
|
230
198
|
data-slot="data-card-label"
|
|
231
|
-
className={cn(
|
|
232
|
-
dataCardStyles.label,
|
|
233
|
-
slots?.label,
|
|
234
|
-
className
|
|
235
|
-
)}
|
|
199
|
+
className={cn(dataCardStyles.label, slots?.label, className)}
|
|
236
200
|
{...props}
|
|
237
201
|
>
|
|
238
|
-
{title &&
|
|
239
|
-
|
|
240
|
-
)}
|
|
241
|
-
{description && (
|
|
242
|
-
<p className="text-muted-foreground text-sm">{description}</p>
|
|
243
|
-
)}
|
|
202
|
+
{title && <h3 className="text-foreground font-semibold">{title}</h3>}
|
|
203
|
+
{description && <p className="text-muted-foreground text-sm">{description}</p>}
|
|
244
204
|
</div>
|
|
245
205
|
);
|
|
246
206
|
}
|
|
247
207
|
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
// DataCardToggle
|
|
210
|
+
// ---------------------------------------------------------------------------
|
|
211
|
+
|
|
248
212
|
/**
|
|
249
|
-
*
|
|
213
|
+
* Switch toggle control inside a DataCard.
|
|
250
214
|
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* ```tsx
|
|
255
|
-
* <DataCardToggle
|
|
256
|
-
* checked={enabled}
|
|
257
|
-
* onCheckedChange={setEnabled}
|
|
258
|
-
* label="Enable notifications"
|
|
259
|
-
* checkedIcon={<BellIcon />}
|
|
260
|
-
* uncheckedIcon={<BellOffIcon />}
|
|
261
|
-
* />
|
|
262
|
-
* ```
|
|
215
|
+
* @param props - {@link IDataCardToggleProps}
|
|
216
|
+
* @returns Label + Switch toggle
|
|
263
217
|
*/
|
|
264
218
|
function DataCardToggle({
|
|
265
219
|
checked,
|
|
266
220
|
onCheckedChange,
|
|
267
|
-
checkedIcon,
|
|
268
|
-
uncheckedIcon,
|
|
269
221
|
label,
|
|
270
222
|
}: IDataCardToggleProps) {
|
|
271
|
-
const { disabled,
|
|
223
|
+
const { disabled, slots } = useDataCard();
|
|
272
224
|
|
|
273
225
|
return (
|
|
274
226
|
<div data-slot="data-card-toggle" className={cn(dataCardStyles.toggle, slots?.toggle)}>
|
|
@@ -277,29 +229,23 @@ function DataCardToggle({
|
|
|
277
229
|
checked={checked}
|
|
278
230
|
onCheckedChange={onCheckedChange}
|
|
279
231
|
disabled={disabled}
|
|
232
|
+
nativeButton
|
|
280
233
|
>
|
|
281
234
|
<SwitchThumb />
|
|
282
|
-
{checkedIcon && (
|
|
283
|
-
<div className="text-primary">{checkedIcon}</div>
|
|
284
|
-
)}
|
|
285
|
-
{!checkedIcon && (
|
|
286
|
-
<div className="text-muted-foreground">{uncheckedIcon}</div>
|
|
287
|
-
)}
|
|
288
235
|
</Switch>
|
|
289
236
|
</div>
|
|
290
237
|
);
|
|
291
238
|
}
|
|
292
239
|
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
// DataCardActions
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
|
|
293
244
|
/**
|
|
294
|
-
*
|
|
245
|
+
* Action button container.
|
|
295
246
|
*
|
|
296
|
-
* @
|
|
297
|
-
*
|
|
298
|
-
* <DataCardActions align="end">
|
|
299
|
-
* <Button size="sm">Edit</Button>
|
|
300
|
-
* <Button size="sm" variant="ghost">Delete</Button>
|
|
301
|
-
* </DataCardActions>
|
|
302
|
-
* ```
|
|
247
|
+
* @param props - {@link IDataCardActionsProps}
|
|
248
|
+
* @returns Flex container for action buttons
|
|
303
249
|
*/
|
|
304
250
|
function DataCardActions({
|
|
305
251
|
align = 'end',
|
|
@@ -307,7 +253,7 @@ function DataCardActions({
|
|
|
307
253
|
children,
|
|
308
254
|
...props
|
|
309
255
|
}: IDataCardActionsProps) {
|
|
310
|
-
const {
|
|
256
|
+
const { slots } = useDataCard();
|
|
311
257
|
|
|
312
258
|
return (
|
|
313
259
|
<div
|
|
@@ -319,7 +265,7 @@ function DataCardActions({
|
|
|
319
265
|
align === 'start' && 'justify-start',
|
|
320
266
|
align === 'end' && 'justify-end',
|
|
321
267
|
slots?.actions,
|
|
322
|
-
className
|
|
268
|
+
className,
|
|
323
269
|
)}
|
|
324
270
|
{...props}
|
|
325
271
|
>
|
|
@@ -328,54 +274,43 @@ function DataCardActions({
|
|
|
328
274
|
);
|
|
329
275
|
}
|
|
330
276
|
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
// DataCardBracket
|
|
279
|
+
// ---------------------------------------------------------------------------
|
|
280
|
+
|
|
331
281
|
/**
|
|
332
|
-
*
|
|
282
|
+
* Decorative corner bracket. Rendered directly via CornerBracket
|
|
283
|
+
* (no wrapper div — the SVG positions itself via absolute positioning).
|
|
333
284
|
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```tsx
|
|
338
|
-
* <DataCardBracket position="tl" variant="accent" />
|
|
339
|
-
* ```
|
|
285
|
+
* @param props - {@link IDataCardBracketProps}
|
|
286
|
+
* @returns CornerBracket SVG at the specified corner
|
|
340
287
|
*/
|
|
341
288
|
function DataCardBracket({
|
|
342
289
|
position,
|
|
343
290
|
variant = 'default',
|
|
344
|
-
className,
|
|
345
291
|
}: IDataCardBracketProps) {
|
|
346
|
-
const { size,
|
|
292
|
+
const { size, config } = useDataCard();
|
|
293
|
+
const animate = config?.animateBrackets ?? true;
|
|
347
294
|
|
|
348
|
-
const sizeMap = {
|
|
349
|
-
compact: 16,
|
|
350
|
-
default: 20,
|
|
351
|
-
spacious: 24,
|
|
352
|
-
} as const;
|
|
295
|
+
const sizeMap = { compact: 16, default: 20, spacious: 24 } as const;
|
|
353
296
|
|
|
354
297
|
return (
|
|
355
|
-
<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
298
|
+
<CornerBracket
|
|
299
|
+
position={position}
|
|
300
|
+
variant={variant}
|
|
301
|
+
size={sizeMap[size ?? 'default']}
|
|
302
|
+
className={cn(
|
|
303
|
+
animate && 'opacity-60 group-hover/data-card:opacity-100 transition-opacity',
|
|
304
|
+
!animate && 'opacity-50',
|
|
305
|
+
)}
|
|
306
|
+
/>
|
|
362
307
|
);
|
|
363
308
|
}
|
|
364
309
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* @returns The current DataCard context
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```tsx
|
|
373
|
-
* function MyComponent() {
|
|
374
|
-
* const { variant, size, disabled } = useDataCard();
|
|
375
|
-
* return <div>Current variant: {variant}</div>;
|
|
376
|
-
* }
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
310
|
+
// ---------------------------------------------------------------------------
|
|
311
|
+
// Exports
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
|
|
379
314
|
export { useDataCard };
|
|
380
315
|
|
|
381
316
|
export {
|
|
@@ -388,7 +323,6 @@ export {
|
|
|
388
323
|
dataCardVariants,
|
|
389
324
|
};
|
|
390
325
|
|
|
391
|
-
// Re-export types
|
|
392
326
|
export type {
|
|
393
327
|
IDataCardProps,
|
|
394
328
|
IDataCardValueProps,
|