@mks2508/mks-ui 0.5.2 → 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 -3
- 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 +20 -8
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.styles.js +55 -27
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts +63 -14
- package/dist/react-ui/ui/DynamicToggle/DynamicToggle.types.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.d.ts +22 -20
- package/dist/react-ui/ui/DynamicToggle/index.d.ts.map +1 -1
- package/dist/react-ui/ui/DynamicToggle/index.js +115 -96
- package/dist/react-ui/ui/Switch/index.js +1 -1
- package/dist/react-ui/ui/index.js +2 -2
- 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 +244 -91
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.styles.ts +60 -40
- package/src/react-ui/ui/DynamicToggle/DynamicToggle.types.ts +95 -14
- package/src/react-ui/ui/DynamicToggle/index.tsx +150 -96
- 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/dist/react-ui/blocks/Terminal/panel/{terminal-filter-dropdown.module-DAcl_XQZ.css → terminal-filter-dropdown.module-C6oDcFBS.css} +0 -0
- /package/dist/react-ui/blocks/Terminal/panel/{terminal-session-tabs.module-DNAop5e3.css → terminal-session-tabs.module-D_-sgyza.css} +0 -0
- /package/dist/react-ui/components/MorphingPopover/{morphing-popover.module-BJrjXisF.css → morphing-popover.module-B1ftlaYj.css} +0 -0
|
@@ -1,127 +1,58 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import { dataCardVariants } from './DataCard.styles';
|
|
3
2
|
import type { SlotOverrides } from '../../../core/types';
|
|
4
|
-
import type { IDataCardProps, IDataCardValueProps, IDataCardLabelProps, IDataCardToggleProps, IDataCardActionsProps, IDataCardBracketProps,
|
|
5
|
-
/**
|
|
6
|
-
* Context type for DataCard state management.
|
|
7
|
-
*/
|
|
3
|
+
import type { IDataCardProps, IDataCardValueProps, IDataCardLabelProps, IDataCardToggleProps, IDataCardActionsProps, IDataCardBracketProps, IDataCardConfig, DataCardSlot } from './DataCard.types';
|
|
8
4
|
type DataCardContextType = {
|
|
9
|
-
/** Current variant of: card. */
|
|
10
5
|
variant: IDataCardProps['variant'];
|
|
11
|
-
/** Current size of: card. */
|
|
12
6
|
size: IDataCardProps['size'];
|
|
13
|
-
/** Whether card is disabled. */
|
|
14
7
|
disabled: boolean;
|
|
15
|
-
/** Whether glass effect is enabled. */
|
|
16
8
|
glass: boolean;
|
|
17
|
-
|
|
9
|
+
config?: IDataCardConfig;
|
|
18
10
|
slots?: SlotOverrides<DataCardSlot>;
|
|
19
|
-
/** Update interaction state. */
|
|
20
|
-
setState: React.Dispatch<React.SetStateAction<IDataCardState>>;
|
|
21
11
|
};
|
|
22
12
|
declare const useDataCard: () => DataCardContextType;
|
|
23
13
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Features:
|
|
27
|
-
* - Slot overrides for customization
|
|
28
|
-
* - State-based styling (hover, pressed, disabled)
|
|
29
|
-
* - CVA variants (size, color variant)
|
|
30
|
-
* - asChild composition pattern
|
|
31
|
-
* - Motion/animation integration
|
|
32
|
-
* - Custom render functions
|
|
33
|
-
* - Form field integration
|
|
34
|
-
* - Icon composition
|
|
35
|
-
* - Glassmorphism effects
|
|
14
|
+
* Root card container with glassmorphism, corner brackets, and state tracking.
|
|
36
15
|
*
|
|
37
|
-
* @
|
|
38
|
-
*
|
|
39
|
-
* <DataCard variant="accent" size="default">
|
|
40
|
-
* <DataCardValue number={1234} />
|
|
41
|
-
* <DataCardToggle />
|
|
42
|
-
* </DataCard>
|
|
43
|
-
* ```
|
|
16
|
+
* @param props - {@link IDataCardProps}
|
|
17
|
+
* @returns A motion.div card with context provider
|
|
44
18
|
*/
|
|
45
|
-
declare function DataCard({ variant, size, disabled, glass, showBrackets, className, style, slots, config, children,
|
|
19
|
+
declare function DataCard({ variant, size, disabled, glass, showBrackets, className, style, slots, config, children, }: IDataCardProps): import("react/jsx-runtime").JSX.Element;
|
|
46
20
|
/**
|
|
47
|
-
*
|
|
21
|
+
* Animated number display with optional label and unit.
|
|
48
22
|
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
-
* <DataCardValue
|
|
52
|
-
* number={1234}
|
|
53
|
-
* label="Active Users"
|
|
54
|
-
* unit="users"
|
|
55
|
-
* />
|
|
56
|
-
* ```
|
|
23
|
+
* @param props - {@link IDataCardValueProps}
|
|
24
|
+
* @returns Animated number with CountingNumber primitive
|
|
57
25
|
*/
|
|
58
26
|
declare function DataCardValue({ number, label, unit, decimalPlaces, padStart, }: IDataCardValueProps): import("react/jsx-runtime").JSX.Element;
|
|
59
27
|
/**
|
|
60
|
-
*
|
|
28
|
+
* Title + description label.
|
|
61
29
|
*
|
|
62
|
-
* @
|
|
63
|
-
*
|
|
64
|
-
* <DataCardLabel
|
|
65
|
-
* title="Revenue"
|
|
66
|
-
* description="This month"
|
|
67
|
-
* />
|
|
68
|
-
* ```
|
|
30
|
+
* @param props - {@link IDataCardLabelProps}
|
|
31
|
+
* @returns Title and optional description text
|
|
69
32
|
*/
|
|
70
33
|
declare function DataCardLabel({ title, description, className, ...props }: IDataCardLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
71
34
|
/**
|
|
72
|
-
*
|
|
35
|
+
* Switch toggle control inside a DataCard.
|
|
73
36
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```tsx
|
|
78
|
-
* <DataCardToggle
|
|
79
|
-
* checked={enabled}
|
|
80
|
-
* onCheckedChange={setEnabled}
|
|
81
|
-
* label="Enable notifications"
|
|
82
|
-
* checkedIcon={<BellIcon />}
|
|
83
|
-
* uncheckedIcon={<BellOffIcon />}
|
|
84
|
-
* />
|
|
85
|
-
* ```
|
|
37
|
+
* @param props - {@link IDataCardToggleProps}
|
|
38
|
+
* @returns Label + Switch toggle
|
|
86
39
|
*/
|
|
87
|
-
declare function DataCardToggle({ checked, onCheckedChange,
|
|
40
|
+
declare function DataCardToggle({ checked, onCheckedChange, label, }: IDataCardToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
88
41
|
/**
|
|
89
|
-
*
|
|
42
|
+
* Action button container.
|
|
90
43
|
*
|
|
91
|
-
* @
|
|
92
|
-
*
|
|
93
|
-
* <DataCardActions align="end">
|
|
94
|
-
* <Button size="sm">Edit</Button>
|
|
95
|
-
* <Button size="sm" variant="ghost">Delete</Button>
|
|
96
|
-
* </DataCardActions>
|
|
97
|
-
* ```
|
|
44
|
+
* @param props - {@link IDataCardActionsProps}
|
|
45
|
+
* @returns Flex container for action buttons
|
|
98
46
|
*/
|
|
99
47
|
declare function DataCardActions({ align, className, children, ...props }: IDataCardActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
100
48
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Wraps CornerBracket with motion animations.
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```tsx
|
|
107
|
-
* <DataCardBracket position="tl" variant="accent" />
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
declare function DataCardBracket({ position, variant, className, }: IDataCardBracketProps): import("react/jsx-runtime").JSX.Element;
|
|
111
|
-
/**
|
|
112
|
-
* Hook to access DataCard context.
|
|
113
|
-
* Must be used within DataCard provider.
|
|
114
|
-
*
|
|
115
|
-
* @returns The current DataCard context
|
|
49
|
+
* Decorative corner bracket. Rendered directly via CornerBracket
|
|
50
|
+
* (no wrapper div — the SVG positions itself via absolute positioning).
|
|
116
51
|
*
|
|
117
|
-
* @
|
|
118
|
-
*
|
|
119
|
-
* function MyComponent() {
|
|
120
|
-
* const { variant, size, disabled } = useDataCard();
|
|
121
|
-
* return <div>Current variant: {variant}</div>;
|
|
122
|
-
* }
|
|
123
|
-
* ```
|
|
52
|
+
* @param props - {@link IDataCardBracketProps}
|
|
53
|
+
* @returns CornerBracket SVG at the specified corner
|
|
124
54
|
*/
|
|
55
|
+
declare function DataCardBracket({ position, variant, }: IDataCardBracketProps): import("react/jsx-runtime").JSX.Element;
|
|
125
56
|
export { useDataCard };
|
|
126
57
|
export { DataCard, DataCardValue, DataCardLabel, DataCardToggle, DataCardActions, DataCardBracket, dataCardVariants, };
|
|
127
58
|
export type { IDataCardProps, IDataCardValueProps, IDataCardLabelProps, IDataCardToggleProps, IDataCardActionsProps, IDataCardBracketProps, IDataCardState, IDataCardConfig, DataCardVariant, DataCardSize, DataCardSlot, } from './DataCard.types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/DataCard/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react-ui/ui/DataCard/index.tsx"],"names":[],"mappings":"AA4BA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EAErB,eAAe,EACf,YAAY,EACb,MAAM,kBAAkB,CAAC;AAM1B,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACrC,CAAC;AAEF,QAAA,MAAyB,WAAW,2BACsB,CAAC;AAM3D;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,EAChB,OAAmB,EACnB,IAAgB,EAChB,QAAgB,EAChB,KAAY,EACZ,YAAmB,EACnB,SAAS,EACT,KAAK,EACL,KAAK,EACL,MAAM,EACN,QAAQ,GACT,EAAE,cAAc,2CAgDhB;AAMD;;;;;GAKG;AACH,iBAAS,aAAa,CAAC,EACrB,MAAM,EACN,KAAK,EACL,IAAI,EACJ,aAAiB,EACjB,QAAgB,GACjB,EAAE,mBAAmB,2CA8BrB;AAMD;;;;;GAKG;AACH,iBAAS,aAAa,CAAC,EACrB,KAAK,EACL,WAAW,EACX,SAAS,EACT,GAAG,KAAK,EACT,EAAE,mBAAmB,2CAarB;AAMD;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,EACtB,OAAO,EACP,eAAe,EACf,KAAK,GACN,EAAE,oBAAoB,2CAgBtB;AAMD;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,EACvB,KAAa,EACb,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,qBAAqB,2CAoBvB;AAMD;;;;;;GAMG;AACH,iBAAS,eAAe,CAAC,EACvB,QAAQ,EACR,OAAmB,GACpB,EAAE,qBAAqB,2CAiBvB;AAMD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,OAAO,EACL,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,GACjB,CAAC;AAEF,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -5,63 +5,58 @@ import { CountingNumber } from "../../primitives/CountingNumber/index.js";
|
|
|
5
5
|
import { getStrictContext } from "../../lib/get-strict-context.js";
|
|
6
6
|
import { Switch, SwitchThumb } from "../Switch/index.js";
|
|
7
7
|
import { CornerBracket } from "../CornerBracket/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { dataCardStyles, dataCardVariants } from "./DataCard.styles.js";
|
|
9
9
|
import * as React$1 from "react";
|
|
10
10
|
import { motion } from "motion/react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
|
|
13
13
|
//#region src/react-ui/ui/DataCard/index.tsx
|
|
14
|
-
const [DataCardProvider, useDataCard] = getStrictContext("DataCardContext");
|
|
15
14
|
/**
|
|
16
|
-
* DataCard —
|
|
15
|
+
* DataCard — glassmorphism dashboard metric card.
|
|
16
|
+
*
|
|
17
|
+
* Features: animated numbers, corner brackets, toggle, size/variant CVA,
|
|
18
|
+
* state-based styling, slot overrides, config for animation tuning.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
* - Slot overrides for customization
|
|
20
|
-
* - State-based styling (hover, pressed, disabled)
|
|
21
|
-
* - CVA variants (size, color variant)
|
|
22
|
-
* - asChild composition pattern
|
|
23
|
-
* - Motion/animation integration
|
|
24
|
-
* - Custom render functions
|
|
25
|
-
* - Form field integration
|
|
26
|
-
* - Icon composition
|
|
27
|
-
* - Glassmorphism effects
|
|
20
|
+
* @module @mks2508/mks-ui/react/ui/DataCard
|
|
28
21
|
*
|
|
29
22
|
* @example
|
|
30
23
|
* ```tsx
|
|
31
24
|
* <DataCard variant="accent" size="default">
|
|
32
|
-
* <
|
|
33
|
-
* <
|
|
25
|
+
* <DataCardLabel title="Revenue" description="This month" />
|
|
26
|
+
* <DataCardValue number={45678} unit="$" />
|
|
34
27
|
* </DataCard>
|
|
35
28
|
* ```
|
|
36
29
|
*/
|
|
37
|
-
|
|
30
|
+
const [DataCardProvider, useDataCard] = getStrictContext("DataCardContext");
|
|
31
|
+
/**
|
|
32
|
+
* Root card container with glassmorphism, corner brackets, and state tracking.
|
|
33
|
+
*
|
|
34
|
+
* @param props - {@link IDataCardProps}
|
|
35
|
+
* @returns A motion.div card with context provider
|
|
36
|
+
*/
|
|
37
|
+
function DataCard({ variant = "default", size = "default", disabled = false, glass = true, showBrackets = true, className, style, slots, config, children }) {
|
|
38
38
|
const [state, setState] = React$1.useState({
|
|
39
39
|
hovered: false,
|
|
40
40
|
pressed: false,
|
|
41
|
-
disabled
|
|
41
|
+
disabled
|
|
42
42
|
});
|
|
43
43
|
const contextValue = React$1.useMemo(() => ({
|
|
44
44
|
variant,
|
|
45
45
|
size,
|
|
46
|
-
disabled
|
|
46
|
+
disabled,
|
|
47
47
|
glass,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
config,
|
|
49
|
+
slots
|
|
50
50
|
}), [
|
|
51
51
|
variant,
|
|
52
52
|
size,
|
|
53
53
|
disabled,
|
|
54
54
|
glass,
|
|
55
|
+
config,
|
|
55
56
|
slots
|
|
56
57
|
]);
|
|
57
|
-
const computedClassName =
|
|
58
|
-
|
|
59
|
-
return className;
|
|
60
|
-
}, [className, state]);
|
|
61
|
-
const computedStyle = React$1.useMemo(() => {
|
|
62
|
-
if (typeof style === "function") return style(state);
|
|
63
|
-
return style;
|
|
64
|
-
}, [style, state]);
|
|
58
|
+
const computedClassName = typeof className === "function" ? className(state) : className;
|
|
59
|
+
const computedStyle = typeof style === "function" ? style(state) : style;
|
|
65
60
|
return /* @__PURE__ */ jsx(DataCardProvider, {
|
|
66
61
|
value: contextValue,
|
|
67
62
|
children: /* @__PURE__ */ jsxs(motion.div, {
|
|
@@ -74,29 +69,28 @@ function DataCard({ variant = "default", size = "default", disabled = false, gla
|
|
|
74
69
|
variant,
|
|
75
70
|
size,
|
|
76
71
|
glass
|
|
77
|
-
}),
|
|
72
|
+
}), disabled && "opacity-50 pointer-events-none", slots?.root, computedClassName),
|
|
78
73
|
style: computedStyle,
|
|
79
|
-
onHoverStart: () => setState((
|
|
80
|
-
...
|
|
74
|
+
onHoverStart: () => setState((p) => ({
|
|
75
|
+
...p,
|
|
81
76
|
hovered: true
|
|
82
77
|
})),
|
|
83
|
-
onHoverEnd: () => setState((
|
|
84
|
-
...
|
|
78
|
+
onHoverEnd: () => setState((p) => ({
|
|
79
|
+
...p,
|
|
85
80
|
hovered: false
|
|
86
81
|
})),
|
|
87
|
-
onTapStart: () => setState((
|
|
88
|
-
...
|
|
82
|
+
onTapStart: () => setState((p) => ({
|
|
83
|
+
...p,
|
|
89
84
|
pressed: true
|
|
90
85
|
})),
|
|
91
|
-
onTap: () => setState((
|
|
92
|
-
...
|
|
86
|
+
onTap: () => setState((p) => ({
|
|
87
|
+
...p,
|
|
93
88
|
pressed: false
|
|
94
89
|
})),
|
|
95
|
-
onTapCancel: () => setState((
|
|
96
|
-
...
|
|
90
|
+
onTapCancel: () => setState((p) => ({
|
|
91
|
+
...p,
|
|
97
92
|
pressed: false
|
|
98
93
|
})),
|
|
99
|
-
...props,
|
|
100
94
|
children: [showBrackets && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
101
95
|
/* @__PURE__ */ jsx(DataCardBracket, {
|
|
102
96
|
position: "tl",
|
|
@@ -119,22 +113,19 @@ function DataCard({ variant = "default", size = "default", disabled = false, gla
|
|
|
119
113
|
});
|
|
120
114
|
}
|
|
121
115
|
/**
|
|
122
|
-
*
|
|
116
|
+
* Animated number display with optional label and unit.
|
|
123
117
|
*
|
|
124
|
-
* @
|
|
125
|
-
*
|
|
126
|
-
* <DataCardValue
|
|
127
|
-
* number={1234}
|
|
128
|
-
* label="Active Users"
|
|
129
|
-
* unit="users"
|
|
130
|
-
* />
|
|
131
|
-
* ```
|
|
118
|
+
* @param props - {@link IDataCardValueProps}
|
|
119
|
+
* @returns Animated number with CountingNumber primitive
|
|
132
120
|
*/
|
|
133
121
|
function DataCardValue({ number, label, unit, decimalPlaces = 0, padStart = false }) {
|
|
134
|
-
const {
|
|
122
|
+
const { size, config, slots } = useDataCard();
|
|
123
|
+
const stiffness = config?.counterStiffness ?? 90;
|
|
124
|
+
const damping = config?.counterDamping ?? 10;
|
|
125
|
+
const sizeClass = size === "compact" ? "text-3xl font-bold" : size === "spacious" ? "text-5xl font-bold" : "text-4xl font-bold";
|
|
135
126
|
return /* @__PURE__ */ jsxs("div", {
|
|
136
127
|
"data-slot": "data-card-value",
|
|
137
|
-
className: cn(dataCardStyles.value),
|
|
128
|
+
className: cn(dataCardStyles.value, slots?.value),
|
|
138
129
|
children: [
|
|
139
130
|
label && /* @__PURE__ */ jsx("span", {
|
|
140
131
|
className: "text-muted-foreground text-xs uppercase tracking-wider font-mono",
|
|
@@ -145,10 +136,10 @@ function DataCardValue({ number, label, unit, decimalPlaces = 0, padStart = fals
|
|
|
145
136
|
decimalPlaces,
|
|
146
137
|
padStart,
|
|
147
138
|
transition: {
|
|
148
|
-
stiffness
|
|
149
|
-
damping
|
|
139
|
+
stiffness,
|
|
140
|
+
damping
|
|
150
141
|
},
|
|
151
|
-
className:
|
|
142
|
+
className: sizeClass
|
|
152
143
|
}),
|
|
153
144
|
unit && /* @__PURE__ */ jsx("span", {
|
|
154
145
|
className: "text-muted-foreground text-lg ml-1",
|
|
@@ -158,15 +149,10 @@ function DataCardValue({ number, label, unit, decimalPlaces = 0, padStart = fals
|
|
|
158
149
|
});
|
|
159
150
|
}
|
|
160
151
|
/**
|
|
161
|
-
*
|
|
152
|
+
* Title + description label.
|
|
162
153
|
*
|
|
163
|
-
* @
|
|
164
|
-
*
|
|
165
|
-
* <DataCardLabel
|
|
166
|
-
* title="Revenue"
|
|
167
|
-
* description="This month"
|
|
168
|
-
* />
|
|
169
|
-
* ```
|
|
154
|
+
* @param props - {@link IDataCardLabelProps}
|
|
155
|
+
* @returns Title and optional description text
|
|
170
156
|
*/
|
|
171
157
|
function DataCardLabel({ title, description, className, ...props }) {
|
|
172
158
|
const { slots } = useDataCard();
|
|
@@ -184,60 +170,36 @@ function DataCardLabel({ title, description, className, ...props }) {
|
|
|
184
170
|
});
|
|
185
171
|
}
|
|
186
172
|
/**
|
|
187
|
-
*
|
|
173
|
+
* Switch toggle control inside a DataCard.
|
|
188
174
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```tsx
|
|
193
|
-
* <DataCardToggle
|
|
194
|
-
* checked={enabled}
|
|
195
|
-
* onCheckedChange={setEnabled}
|
|
196
|
-
* label="Enable notifications"
|
|
197
|
-
* checkedIcon={<BellIcon />}
|
|
198
|
-
* uncheckedIcon={<BellOffIcon />}
|
|
199
|
-
* />
|
|
200
|
-
* ```
|
|
175
|
+
* @param props - {@link IDataCardToggleProps}
|
|
176
|
+
* @returns Label + Switch toggle
|
|
201
177
|
*/
|
|
202
|
-
function DataCardToggle({ checked, onCheckedChange,
|
|
203
|
-
const { disabled,
|
|
178
|
+
function DataCardToggle({ checked, onCheckedChange, label }) {
|
|
179
|
+
const { disabled, slots } = useDataCard();
|
|
204
180
|
return /* @__PURE__ */ jsxs("div", {
|
|
205
181
|
"data-slot": "data-card-toggle",
|
|
206
182
|
className: cn(dataCardStyles.toggle, slots?.toggle),
|
|
207
183
|
children: [label && /* @__PURE__ */ jsx("span", {
|
|
208
184
|
className: "text-sm text-muted-foreground",
|
|
209
185
|
children: label
|
|
210
|
-
}), /* @__PURE__ */
|
|
186
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
211
187
|
checked,
|
|
212
188
|
onCheckedChange,
|
|
213
189
|
disabled,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
checkedIcon && /* @__PURE__ */ jsx("div", {
|
|
217
|
-
className: "text-primary",
|
|
218
|
-
children: checkedIcon
|
|
219
|
-
}),
|
|
220
|
-
!checkedIcon && /* @__PURE__ */ jsx("div", {
|
|
221
|
-
className: "text-muted-foreground",
|
|
222
|
-
children: uncheckedIcon
|
|
223
|
-
})
|
|
224
|
-
]
|
|
190
|
+
nativeButton: true,
|
|
191
|
+
children: /* @__PURE__ */ jsx(SwitchThumb, {})
|
|
225
192
|
})]
|
|
226
193
|
});
|
|
227
194
|
}
|
|
228
195
|
/**
|
|
229
|
-
*
|
|
196
|
+
* Action button container.
|
|
230
197
|
*
|
|
231
|
-
* @
|
|
232
|
-
*
|
|
233
|
-
* <DataCardActions align="end">
|
|
234
|
-
* <Button size="sm">Edit</Button>
|
|
235
|
-
* <Button size="sm" variant="ghost">Delete</Button>
|
|
236
|
-
* </DataCardActions>
|
|
237
|
-
* ```
|
|
198
|
+
* @param props - {@link IDataCardActionsProps}
|
|
199
|
+
* @returns Flex container for action buttons
|
|
238
200
|
*/
|
|
239
201
|
function DataCardActions({ align = "end", className, children, ...props }) {
|
|
240
|
-
const {
|
|
202
|
+
const { slots } = useDataCard();
|
|
241
203
|
return /* @__PURE__ */ jsx("div", {
|
|
242
204
|
"data-slot": "data-card-actions",
|
|
243
205
|
"data-align": align,
|
|
@@ -247,28 +209,24 @@ function DataCardActions({ align = "end", className, children, ...props }) {
|
|
|
247
209
|
});
|
|
248
210
|
}
|
|
249
211
|
/**
|
|
250
|
-
*
|
|
212
|
+
* Decorative corner bracket. Rendered directly via CornerBracket
|
|
213
|
+
* (no wrapper div — the SVG positions itself via absolute positioning).
|
|
251
214
|
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```tsx
|
|
256
|
-
* <DataCardBracket position="tl" variant="accent" />
|
|
257
|
-
* ```
|
|
215
|
+
* @param props - {@link IDataCardBracketProps}
|
|
216
|
+
* @returns CornerBracket SVG at the specified corner
|
|
258
217
|
*/
|
|
259
|
-
function DataCardBracket({ position, variant = "default"
|
|
260
|
-
const { size,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
})
|
|
218
|
+
function DataCardBracket({ position, variant = "default" }) {
|
|
219
|
+
const { size, config } = useDataCard();
|
|
220
|
+
const animate = config?.animateBrackets ?? true;
|
|
221
|
+
return /* @__PURE__ */ jsx(CornerBracket, {
|
|
222
|
+
position,
|
|
223
|
+
variant,
|
|
224
|
+
size: {
|
|
225
|
+
compact: 16,
|
|
226
|
+
default: 20,
|
|
227
|
+
spacious: 24
|
|
228
|
+
}[size ?? "default"],
|
|
229
|
+
className: cn(animate && "opacity-60 group-hover/data-card:opacity-100 transition-opacity", !animate && "opacity-50")
|
|
272
230
|
});
|
|
273
231
|
}
|
|
274
232
|
|