@mks2508/mks-ui 0.1.0 → 0.1.2
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/components/animate-ui/primitives/animate/slot.js +35 -40
- package/dist/components/animate-ui/primitives/base/menu.d.ts +1 -1
- package/dist/components/animate-ui/primitives/base/progress.d.ts +1 -1
- package/dist/components/animate-ui/primitives/base/switch.js +86 -32
- package/dist/components/animate-ui/primitives/base/tabs.d.ts +2 -2
- package/dist/components/animate-ui/primitives/base/tabs.js +118 -39
- package/dist/components/animate-ui/primitives/effects/auto-height.d.ts +1 -1
- package/dist/components/animate-ui/primitives/effects/auto-height.js +33 -14
- package/dist/components/animate-ui/primitives/effects/highlight.js +345 -304
- package/dist/components/animate-ui/primitives/texts/counting-number.d.ts +1 -1
- package/dist/components/ui/alert-dialog.d.ts +1 -1
- package/dist/components/ui/alert-dialog.js +75 -19
- package/dist/components/ui/badge/badge.d.ts +1 -1
- package/dist/components/ui/badge/badge.js +49 -37
- package/dist/components/ui/badge/badge.styles.js +31 -36
- package/dist/components/ui/badge/index.js +2 -7
- package/dist/components/ui/button/button.d.ts +1 -1
- package/dist/components/ui/button/button.js +154 -114
- package/dist/components/ui/button/button.styles.js +41 -49
- package/dist/components/ui/button/index.js +2 -7
- package/dist/components/ui/card.js +50 -21
- package/dist/components/ui/combobox.js +143 -27
- package/dist/components/ui/devenv-bracket.js +60 -43
- package/dist/components/ui/dropdown-menu.js +118 -20
- package/dist/components/ui/field.d.ts +1 -1
- package/dist/components/ui/field.js +88 -44
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +24 -25
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/components/ui/input-group.js +67 -41
- package/dist/components/ui/input.js +16 -7
- package/dist/components/ui/label.js +13 -5
- package/dist/components/ui/morphing-popover/index.js +1 -9
- package/dist/components/ui/morphing-popover/morphing-popover.js +73 -44
- package/dist/components/ui/morphing-popover/morphing-popover.module-yxDDcJHZ.css +154 -0
- package/dist/components/ui/morphing-popover/morphing-popover.module.js +5 -0
- package/dist/components/ui/select.js +95 -16
- package/dist/components/ui/separator.js +16 -7
- package/dist/components/ui/switch.d.ts +9 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +1 -0
- package/dist/components/ui/tabs.d.ts +9 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +1 -0
- package/dist/components/ui/textarea.js +13 -5
- package/dist/hooks/use-auto-height.js +63 -72
- package/dist/hooks/use-controlled-state.js +16 -15
- package/dist/icons/index.js +36 -11
- package/dist/icons/lucide-animated/activity.js +68 -50
- package/dist/icons/lucide-animated/arrow-down-to-line.js +42 -20
- package/dist/icons/lucide-animated/arrow-up.js +38 -20
- package/dist/icons/lucide-animated/bell-electric.js +197 -53
- package/dist/icons/lucide-animated/bell.js +58 -36
- package/dist/icons/lucide-animated/bot.js +113 -53
- package/dist/icons/lucide-animated/box.js +79 -47
- package/dist/icons/lucide-animated/check.js +21 -8
- package/dist/icons/lucide-animated/circle-check.js +69 -47
- package/dist/icons/lucide-animated/delete.js +101 -45
- package/dist/icons/lucide-animated/download.js +63 -41
- package/dist/icons/lucide-animated/edit-2.js +21 -8
- package/dist/icons/lucide-animated/globe.js +29 -8
- package/dist/icons/lucide-animated/home.js +59 -41
- package/dist/icons/lucide-animated/index.js +32 -38
- package/dist/icons/lucide-animated/layers.js +25 -8
- package/dist/icons/lucide-animated/layout-panel-top.js +125 -63
- package/dist/icons/lucide-animated/list.js +75 -20
- package/dist/icons/lucide-animated/package.js +26 -8
- package/dist/icons/lucide-animated/palette.js +47 -8
- package/dist/icons/lucide-animated/plus.js +54 -38
- package/dist/icons/lucide-animated/refresh-cw.js +26 -8
- package/dist/icons/lucide-animated/rocket.js +26 -8
- package/dist/icons/lucide-animated/save.js +25 -8
- package/dist/icons/lucide-animated/search.js +73 -40
- package/dist/icons/lucide-animated/settings.js +58 -38
- package/dist/icons/lucide-animated/terminal.js +35 -4
- package/dist/icons/lucide-animated/trash-2.js +37 -8
- package/dist/icons/lucide-animated/trending-down.js +114 -78
- package/dist/icons/lucide-animated/trending-up.js +114 -78
- package/dist/icons/lucide-animated/type.js +35 -8
- package/dist/icons/lucide-animated/upload.js +30 -8
- package/dist/icons/lucide-animated/x.js +61 -39
- package/dist/index.js +56 -18
- package/dist/lib/get-strict-context.js +18 -14
- package/dist/lib/utils.js +24 -20
- package/package.json +14 -17
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/switch.tsx +9 -0
- package/src/components/ui/tabs.tsx +9 -0
- package/dist/components/animate-ui/primitives/animate/slot.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/accordion.js +0 -52
- package/dist/components/animate-ui/primitives/base/accordion.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/alert-dialog.js +0 -60
- package/dist/components/animate-ui/primitives/base/alert-dialog.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/checkbox.js +0 -41
- package/dist/components/animate-ui/primitives/base/checkbox.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/dialog.js +0 -60
- package/dist/components/animate-ui/primitives/base/dialog.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/menu.js +0 -122
- package/dist/components/animate-ui/primitives/base/menu.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/popover.js +0 -45
- package/dist/components/animate-ui/primitives/base/popover.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/progress.js +0 -27
- package/dist/components/animate-ui/primitives/base/progress.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/switch.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/tabs.js.map +0 -1
- package/dist/components/animate-ui/primitives/base/tooltip.js +0 -71
- package/dist/components/animate-ui/primitives/base/tooltip.js.map +0 -1
- package/dist/components/animate-ui/primitives/effects/auto-height.js.map +0 -1
- package/dist/components/animate-ui/primitives/effects/highlight.js.map +0 -1
- package/dist/components/animate-ui/primitives/texts/counting-number.js +0 -69
- package/dist/components/animate-ui/primitives/texts/counting-number.js.map +0 -1
- package/dist/components/ui/alert-dialog.js.map +0 -1
- package/dist/components/ui/badge/badge.js.map +0 -1
- package/dist/components/ui/badge/badge.styles.js.map +0 -1
- package/dist/components/ui/badge/badge.types.js +0 -2
- package/dist/components/ui/badge/badge.types.js.map +0 -1
- package/dist/components/ui/badge/index.js.map +0 -1
- package/dist/components/ui/button/button.js.map +0 -1
- package/dist/components/ui/button/button.styles.js.map +0 -1
- package/dist/components/ui/button/button.types.js +0 -2
- package/dist/components/ui/button/button.types.js.map +0 -1
- package/dist/components/ui/button/index.js.map +0 -1
- package/dist/components/ui/card.js.map +0 -1
- package/dist/components/ui/combobox.js.map +0 -1
- package/dist/components/ui/devenv-bracket.js.map +0 -1
- package/dist/components/ui/dropdown-menu.js.map +0 -1
- package/dist/components/ui/field.js.map +0 -1
- package/dist/components/ui/index.js.map +0 -1
- package/dist/components/ui/input-group.js.map +0 -1
- package/dist/components/ui/input.js.map +0 -1
- package/dist/components/ui/label.js.map +0 -1
- package/dist/components/ui/morphing-popover/index.js.map +0 -1
- package/dist/components/ui/morphing-popover/morphing-popover.js.map +0 -1
- package/dist/components/ui/select.js.map +0 -1
- package/dist/components/ui/separator.js.map +0 -1
- package/dist/components/ui/textarea.js.map +0 -1
- package/dist/hooks/use-auto-height.js.map +0 -1
- package/dist/hooks/use-controlled-state.js.map +0 -1
- package/dist/hooks/use-data-state.js +0 -45
- package/dist/hooks/use-data-state.js.map +0 -1
- package/dist/hooks/use-is-in-view.js +0 -15
- package/dist/hooks/use-is-in-view.js.map +0 -1
- package/dist/icons/index.js.map +0 -1
- package/dist/icons/lucide-animated/activity.js.map +0 -1
- package/dist/icons/lucide-animated/arrow-down-to-line.js.map +0 -1
- package/dist/icons/lucide-animated/arrow-up.js.map +0 -1
- package/dist/icons/lucide-animated/bell-electric.js.map +0 -1
- package/dist/icons/lucide-animated/bell.js.map +0 -1
- package/dist/icons/lucide-animated/bot.js.map +0 -1
- package/dist/icons/lucide-animated/box.js.map +0 -1
- package/dist/icons/lucide-animated/check.js.map +0 -1
- package/dist/icons/lucide-animated/circle-check.js.map +0 -1
- package/dist/icons/lucide-animated/delete.js.map +0 -1
- package/dist/icons/lucide-animated/download.js.map +0 -1
- package/dist/icons/lucide-animated/edit-2.js.map +0 -1
- package/dist/icons/lucide-animated/globe.js.map +0 -1
- package/dist/icons/lucide-animated/home.js.map +0 -1
- package/dist/icons/lucide-animated/index.js.map +0 -1
- package/dist/icons/lucide-animated/layers.js.map +0 -1
- package/dist/icons/lucide-animated/layout-panel-top.js.map +0 -1
- package/dist/icons/lucide-animated/list.js.map +0 -1
- package/dist/icons/lucide-animated/package.js.map +0 -1
- package/dist/icons/lucide-animated/palette.js.map +0 -1
- package/dist/icons/lucide-animated/plus.js.map +0 -1
- package/dist/icons/lucide-animated/refresh-cw.js.map +0 -1
- package/dist/icons/lucide-animated/rocket.js.map +0 -1
- package/dist/icons/lucide-animated/save.js.map +0 -1
- package/dist/icons/lucide-animated/search.js.map +0 -1
- package/dist/icons/lucide-animated/settings.js.map +0 -1
- package/dist/icons/lucide-animated/terminal.js.map +0 -1
- package/dist/icons/lucide-animated/trash-2.js.map +0 -1
- package/dist/icons/lucide-animated/trending-down.js.map +0 -1
- package/dist/icons/lucide-animated/trending-up.js.map +0 -1
- package/dist/icons/lucide-animated/type.js.map +0 -1
- package/dist/icons/lucide-animated/upload.js.map +0 -1
- package/dist/icons/lucide-animated/x.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/get-strict-context.js.map +0 -1
- package/dist/lib/utils.js.map +0 -1
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
|
|
3
|
+
import { cn } from "../../../../lib/utils.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { isMotionComponent, motion } from "motion/react";
|
|
7
|
+
|
|
8
|
+
//#region src/components/animate-ui/primitives/animate/slot.tsx
|
|
6
9
|
function mergeRefs(...refs) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
else {
|
|
15
|
-
ref.current = node;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
10
|
+
return (node) => {
|
|
11
|
+
refs.forEach((ref) => {
|
|
12
|
+
if (!ref) return;
|
|
13
|
+
if (typeof ref === "function") ref(node);
|
|
14
|
+
else ref.current = node;
|
|
15
|
+
});
|
|
16
|
+
};
|
|
19
17
|
}
|
|
20
18
|
function mergeProps(childProps, slotProps) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return merged;
|
|
19
|
+
const merged = {
|
|
20
|
+
...childProps,
|
|
21
|
+
...slotProps
|
|
22
|
+
};
|
|
23
|
+
if (childProps.className || slotProps.className) merged.className = cn(childProps.className, slotProps.className);
|
|
24
|
+
if (childProps.style || slotProps.style) merged.style = {
|
|
25
|
+
...childProps.style,
|
|
26
|
+
...slotProps.style
|
|
27
|
+
};
|
|
28
|
+
return merged;
|
|
32
29
|
}
|
|
33
30
|
function Slot({ children, ref, ...props }) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const { ref: childRef, ...childProps } = children.props;
|
|
43
|
-
const mergedProps = mergeProps(childProps, props);
|
|
44
|
-
return (_jsx(Base, { ...mergedProps, ref: mergeRefs(childRef, ref) }));
|
|
31
|
+
const isAlreadyMotion = typeof children.type === "object" && children.type !== null && isMotionComponent(children.type);
|
|
32
|
+
const Base = React.useMemo(() => isAlreadyMotion ? children.type : motion.create(children.type), [isAlreadyMotion, children.type]);
|
|
33
|
+
if (!React.isValidElement(children)) return null;
|
|
34
|
+
const { ref: childRef, ...childProps } = children.props;
|
|
35
|
+
return /* @__PURE__ */ jsx(Base, {
|
|
36
|
+
...mergeProps(childProps, props),
|
|
37
|
+
ref: mergeRefs(childRef, ref)
|
|
38
|
+
});
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
//#
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Slot };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Menu as MenuPrimitive } from '@base-ui-components/react/menu';
|
|
3
3
|
import { type HTMLMotionProps } from 'motion/react';
|
|
4
|
-
import { type HighlightItemProps, type HighlightProps } from '
|
|
4
|
+
import { type HighlightItemProps, type HighlightProps } from '../../../../components/animate-ui/primitives/effects/highlight';
|
|
5
5
|
type MenuActiveValueContextType = {
|
|
6
6
|
highlightedValue: string | null;
|
|
7
7
|
setHighlightedValue: (value: string | null) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Progress as ProgressPrimitives } from '@base-ui-components/react/progress';
|
|
3
|
-
import { type CountingNumberProps } from '
|
|
3
|
+
import { type CountingNumberProps } from '../../../../components/animate-ui/primitives/texts/counting-number';
|
|
4
4
|
type ProgressContextType = {
|
|
5
5
|
value: number;
|
|
6
6
|
};
|
|
@@ -1,36 +1,90 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
|
|
3
|
+
import { getStrictContext } from "../../../../lib/get-strict-context.js";
|
|
4
|
+
import { useControlledState } from "../../../../hooks/use-controlled-state.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Switch } from "@base-ui-components/react/switch";
|
|
8
|
+
import { motion } from "motion/react";
|
|
9
|
+
|
|
10
|
+
//#region src/components/animate-ui/primitives/base/switch.tsx
|
|
11
|
+
const [SwitchProvider, useSwitch] = getStrictContext("SwitchContext");
|
|
12
|
+
function Switch$1({ name, defaultChecked, checked, onCheckedChange, nativeButton, disabled, readOnly, required, inputRef, id, ...props }) {
|
|
13
|
+
const [isPressed, setIsPressed] = React.useState(false);
|
|
14
|
+
const [isChecked, setIsChecked] = useControlledState({
|
|
15
|
+
value: checked,
|
|
16
|
+
defaultValue: defaultChecked,
|
|
17
|
+
onChange: onCheckedChange
|
|
18
|
+
});
|
|
19
|
+
return /* @__PURE__ */ jsx(SwitchProvider, {
|
|
20
|
+
value: {
|
|
21
|
+
isChecked,
|
|
22
|
+
setIsChecked,
|
|
23
|
+
isPressed,
|
|
24
|
+
setIsPressed
|
|
25
|
+
},
|
|
26
|
+
children: /* @__PURE__ */ jsx(Switch.Root, {
|
|
27
|
+
name,
|
|
28
|
+
defaultChecked,
|
|
29
|
+
checked,
|
|
30
|
+
onCheckedChange: setIsChecked,
|
|
31
|
+
nativeButton,
|
|
32
|
+
disabled,
|
|
33
|
+
readOnly,
|
|
34
|
+
required,
|
|
35
|
+
inputRef,
|
|
36
|
+
id,
|
|
37
|
+
render: /* @__PURE__ */ jsx(motion.button, {
|
|
38
|
+
"data-slot": "switch",
|
|
39
|
+
whileTap: "tap",
|
|
40
|
+
initial: false,
|
|
41
|
+
onTapStart: () => setIsPressed(true),
|
|
42
|
+
onTapCancel: () => setIsPressed(false),
|
|
43
|
+
onTap: () => setIsPressed(false),
|
|
44
|
+
...props
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
});
|
|
17
48
|
}
|
|
18
|
-
function SwitchThumb({ pressedAnimation, transition = {
|
|
19
|
-
|
|
20
|
-
|
|
49
|
+
function SwitchThumb({ pressedAnimation, transition = {
|
|
50
|
+
type: "spring",
|
|
51
|
+
stiffness: 300,
|
|
52
|
+
damping: 25
|
|
53
|
+
}, ...props }) {
|
|
54
|
+
const { isPressed } = useSwitch();
|
|
55
|
+
return /* @__PURE__ */ jsx(Switch.Thumb, { render: /* @__PURE__ */ jsx(motion.div, {
|
|
56
|
+
"data-slot": "switch-thumb",
|
|
57
|
+
whileTap: "tab",
|
|
58
|
+
layout: true,
|
|
59
|
+
transition,
|
|
60
|
+
animate: isPressed ? pressedAnimation : void 0,
|
|
61
|
+
...props
|
|
62
|
+
}) });
|
|
21
63
|
}
|
|
22
|
-
function SwitchIcon({ position, transition = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
64
|
+
function SwitchIcon({ position, transition = {
|
|
65
|
+
type: "spring",
|
|
66
|
+
bounce: 0
|
|
67
|
+
}, ...props }) {
|
|
68
|
+
const { isChecked } = useSwitch();
|
|
69
|
+
const isAnimated = React.useMemo(() => {
|
|
70
|
+
if (position === "right") return !isChecked;
|
|
71
|
+
if (position === "left") return isChecked;
|
|
72
|
+
if (position === "thumb") return true;
|
|
73
|
+
return false;
|
|
74
|
+
}, [position, isChecked]);
|
|
75
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
76
|
+
"data-slot": `switch-${position}-icon`,
|
|
77
|
+
animate: isAnimated ? {
|
|
78
|
+
scale: 1,
|
|
79
|
+
opacity: 1
|
|
80
|
+
} : {
|
|
81
|
+
scale: 0,
|
|
82
|
+
opacity: 0
|
|
83
|
+
},
|
|
84
|
+
transition,
|
|
85
|
+
...props
|
|
86
|
+
});
|
|
34
87
|
}
|
|
35
|
-
|
|
36
|
-
//#
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { Switch$1 as Switch, SwitchIcon, SwitchThumb, useSwitch };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Tabs as TabsPrimitive } from '@base-ui-components/react/tabs';
|
|
3
3
|
import { type HTMLMotionProps, type Transition } from 'motion/react';
|
|
4
|
-
import { type HighlightProps, type HighlightItemProps } from '
|
|
5
|
-
import { type AutoHeightProps } from '
|
|
4
|
+
import { type HighlightProps, type HighlightItemProps } from '../../../../components/animate-ui/primitives/effects/highlight';
|
|
5
|
+
import { type AutoHeightProps } from '../../../../components/animate-ui/primitives/effects/auto-height';
|
|
6
6
|
type TabsProps = React.ComponentProps<typeof TabsPrimitive.Root>;
|
|
7
7
|
declare function Tabs(props: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
type TabsHighlightProps = Omit<HighlightProps, 'controlledItems' | 'value'>;
|
|
@@ -1,53 +1,132 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
|
|
3
|
+
import { getStrictContext } from "../../../../lib/get-strict-context.js";
|
|
4
|
+
import { useControlledState } from "../../../../hooks/use-controlled-state.js";
|
|
5
|
+
import { Highlight, HighlightItem } from "../effects/highlight.js";
|
|
6
|
+
import { AutoHeight } from "../effects/auto-height.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
10
|
+
import { Tabs } from "@base-ui-components/react/tabs";
|
|
11
|
+
|
|
12
|
+
//#region src/components/animate-ui/primitives/base/tabs.tsx
|
|
13
|
+
const [TabsProvider, useTabs] = getStrictContext("TabsContext");
|
|
14
|
+
function Tabs$1(props) {
|
|
15
|
+
const [value, setValue] = useControlledState({
|
|
16
|
+
value: props.value,
|
|
17
|
+
defaultValue: props.defaultValue,
|
|
18
|
+
onChange: props.onValueChange
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ jsx(TabsProvider, {
|
|
21
|
+
value: {
|
|
22
|
+
value,
|
|
23
|
+
setValue
|
|
24
|
+
},
|
|
25
|
+
children: /* @__PURE__ */ jsx(Tabs.Root, {
|
|
26
|
+
"data-slot": "tabs",
|
|
27
|
+
...props,
|
|
28
|
+
onValueChange: setValue
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function TabsHighlight({ transition = {
|
|
33
|
+
type: "spring",
|
|
34
|
+
stiffness: 200,
|
|
35
|
+
damping: 25
|
|
36
|
+
}, ...props }) {
|
|
37
|
+
const { value } = useTabs();
|
|
38
|
+
return /* @__PURE__ */ jsx(Highlight, {
|
|
39
|
+
"data-slot": "tabs-highlight",
|
|
40
|
+
controlledItems: true,
|
|
41
|
+
value,
|
|
42
|
+
transition,
|
|
43
|
+
click: false,
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
22
46
|
}
|
|
23
47
|
function TabsList(props) {
|
|
24
|
-
|
|
48
|
+
return /* @__PURE__ */ jsx(Tabs.List, {
|
|
49
|
+
"data-slot": "tabs-list",
|
|
50
|
+
...props
|
|
51
|
+
});
|
|
25
52
|
}
|
|
26
53
|
function TabsHighlightItem(props) {
|
|
27
|
-
|
|
54
|
+
return /* @__PURE__ */ jsx(HighlightItem, {
|
|
55
|
+
"data-slot": "tabs-highlight-item",
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
28
58
|
}
|
|
29
59
|
function TabsTab(props) {
|
|
30
|
-
|
|
60
|
+
return /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
61
|
+
"data-slot": "tabs-tab",
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
31
64
|
}
|
|
32
|
-
function TabsPanel({ value, keepMounted, transition = {
|
|
33
|
-
|
|
65
|
+
function TabsPanel({ value, keepMounted, transition = {
|
|
66
|
+
duration: .5,
|
|
67
|
+
ease: "easeInOut"
|
|
68
|
+
}, ...props }) {
|
|
69
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
70
|
+
mode: "wait",
|
|
71
|
+
children: /* @__PURE__ */ jsx(Tabs.Panel, {
|
|
72
|
+
render: /* @__PURE__ */ jsx(motion.div, {
|
|
73
|
+
"data-slot": "tabs-panel",
|
|
74
|
+
layout: true,
|
|
75
|
+
layoutDependency: value,
|
|
76
|
+
initial: {
|
|
77
|
+
opacity: 0,
|
|
78
|
+
filter: "blur(4px)"
|
|
79
|
+
},
|
|
80
|
+
animate: {
|
|
81
|
+
opacity: 1,
|
|
82
|
+
filter: "blur(0px)"
|
|
83
|
+
},
|
|
84
|
+
exit: {
|
|
85
|
+
opacity: 0,
|
|
86
|
+
filter: "blur(4px)"
|
|
87
|
+
},
|
|
88
|
+
transition,
|
|
89
|
+
...props
|
|
90
|
+
}),
|
|
91
|
+
keepMounted,
|
|
92
|
+
value
|
|
93
|
+
})
|
|
94
|
+
});
|
|
34
95
|
}
|
|
35
96
|
const defaultTransition = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
97
|
+
type: "spring",
|
|
98
|
+
stiffness: 200,
|
|
99
|
+
damping: 30
|
|
39
100
|
};
|
|
40
101
|
function isAutoMode(props) {
|
|
41
|
-
|
|
102
|
+
return !props.mode || props.mode === "auto-height";
|
|
42
103
|
}
|
|
43
104
|
function TabsPanels(props) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
105
|
+
const { value } = useTabs();
|
|
106
|
+
if (isAutoMode(props)) {
|
|
107
|
+
const { children, transition = defaultTransition, ...autoProps } = props;
|
|
108
|
+
return /* @__PURE__ */ jsx(AutoHeight, {
|
|
109
|
+
"data-slot": "tabs-panels",
|
|
110
|
+
deps: [value],
|
|
111
|
+
transition,
|
|
112
|
+
...autoProps,
|
|
113
|
+
children: /* @__PURE__ */ jsx(React.Fragment, { children }, value)
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const { children, style, transition = defaultTransition, ...layoutProps } = props;
|
|
117
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
118
|
+
"data-slot": "tabs-panels",
|
|
119
|
+
layout: "size",
|
|
120
|
+
layoutDependency: value,
|
|
121
|
+
transition: { layout: transition },
|
|
122
|
+
style: {
|
|
123
|
+
overflow: "hidden",
|
|
124
|
+
...style
|
|
125
|
+
},
|
|
126
|
+
...layoutProps,
|
|
127
|
+
children: /* @__PURE__ */ jsx(React.Fragment, { children }, value)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
export { Tabs$1 as Tabs, TabsHighlight, TabsHighlightItem, TabsList, TabsPanel, TabsPanels, TabsTab };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type HTMLMotionProps, type LegacyAnimationControls, type TargetAndTransition, type Transition } from 'motion/react';
|
|
3
|
-
import { WithAsChild } from '
|
|
3
|
+
import { WithAsChild } from '../../../../components/animate-ui/primitives/animate/slot';
|
|
4
4
|
type AutoHeightProps = WithAsChild<{
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
deps?: React.DependencyList;
|
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
|
|
3
|
+
import { useAutoHeight } from "../../../../hooks/use-auto-height.js";
|
|
4
|
+
import { Slot } from "../animate/slot.js";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { motion } from "motion/react";
|
|
8
|
+
|
|
9
|
+
//#region src/components/animate-ui/primitives/effects/auto-height.tsx
|
|
6
10
|
function AutoHeight({ children, deps = [], transition = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
type: "spring",
|
|
12
|
+
stiffness: 300,
|
|
13
|
+
damping: 30,
|
|
14
|
+
bounce: 0,
|
|
15
|
+
restDelta: .01
|
|
12
16
|
}, style, animate, asChild = false, ...props }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const { ref, height } = useAutoHeight(deps);
|
|
18
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : motion.div, {
|
|
19
|
+
style: {
|
|
20
|
+
overflow: "hidden",
|
|
21
|
+
...style
|
|
22
|
+
},
|
|
23
|
+
animate: {
|
|
24
|
+
height,
|
|
25
|
+
...animate
|
|
26
|
+
},
|
|
27
|
+
transition,
|
|
28
|
+
...props,
|
|
29
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
30
|
+
ref,
|
|
31
|
+
children
|
|
32
|
+
})
|
|
33
|
+
});
|
|
16
34
|
}
|
|
17
|
-
|
|
18
|
-
//#
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { AutoHeight };
|