mtxuilib 0.1.482 → 0.1.484
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.
|
@@ -11,5 +11,5 @@ export const DebugValue = (props) => {
|
|
|
11
11
|
}
|
|
12
12
|
return (_jsxs(Dialog, { open: open, onOpenChange: setOpen, children: [_jsx(DialogTrigger, { asChild: true, children: _jsx(MtButton, { variant: "outline", className: className, onClick: () => {
|
|
13
13
|
console.log(data);
|
|
14
|
-
}, children: title || "
|
|
14
|
+
}, children: title || "调试" }) }), _jsx(DialogContent, { className: "max-h-lvh w-full overflow-scroll ", children: _jsx("pre", { className: " text-xs", children: JSON.stringify(data, null, 2) }) })] }));
|
|
15
15
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface SliderOption<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SliderProps<T> {
|
|
6
|
+
selected: T;
|
|
7
|
+
options: SliderOption<T>[];
|
|
8
|
+
setSelected?: (selected: T) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const MtSlider: (<T>({ selected, options, setSelected }: SliderProps<T>) => import("react/jsx-runtime").JSX.Element) & {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { classNames } from "mtxuilib/lib/utils";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { cubicEasingFn } from "mtxuilib/ui/mt/utils/easings";
|
|
7
|
+
import { genericMemo } from "../../lib/react";
|
|
8
|
+
export const MtSlider = genericMemo(({ selected, options, setSelected }) => {
|
|
9
|
+
return (_jsx("div", { className: "flex items-center flex-wrap shrink-0 gap-1 bg-bolt-elements-background-depth-1 overflow-hidden rounded-full p-1", children: options.map((option) => (_jsx(SliderButton, { selected: selected === option.value, setSelected: () => setSelected?.(option.value), children: option.text }, String(option.value)))) }));
|
|
10
|
+
});
|
|
11
|
+
const SliderButton = memo(({ selected, children, setSelected }) => {
|
|
12
|
+
return (_jsxs("button", { type: "button", onClick: setSelected, className: classNames("bg-transparent text-sm px-2.5 py-0.5 rounded-full relative", selected
|
|
13
|
+
? "text-bolt-elements-item-contentAccent"
|
|
14
|
+
: "text-bolt-elements-item-contentDefault hover:text-bolt-elements-item-contentActive"), children: [_jsx("span", { className: "relative z-10", children: children }), selected && (_jsx(motion.span, { layoutId: "pill-tab", transition: { duration: 0.2, ease: cubicEasingFn }, className: "absolute inset-0 z-0 bg-bolt-elements-item-backgroundAccent rounded-full" }))] }));
|
|
15
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface SliderOption<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface SliderOptions<T> {
|
|
6
|
+
left: SliderOption<T>;
|
|
7
|
+
right: SliderOption<T>;
|
|
8
|
+
}
|
|
9
|
+
interface SliderProps<T> {
|
|
10
|
+
selected: T;
|
|
11
|
+
options: SliderOptions<T>;
|
|
12
|
+
setSelected?: (selected: T) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const MtSlider: (<T>({ selected, options, setSelected }: SliderProps<T>) => import("react/jsx-runtime").JSX.Element) & {
|
|
15
|
+
displayName?: string;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { classNames } from "mtxuilib/lib/utils";
|
|
5
|
+
import { memo } from "react";
|
|
6
|
+
import { cubicEasingFn } from "mtxuilib/ui/mt/utils/easings";
|
|
7
|
+
import { genericMemo } from "../../lib/react";
|
|
8
|
+
export const MtSlider = genericMemo(({ selected, options, setSelected }) => {
|
|
9
|
+
const isLeftSelected = selected === options.left.value;
|
|
10
|
+
return (_jsxs("div", { className: "flex items-center flex-wrap shrink-0 gap-1 bg-bolt-elements-background-depth-1 overflow-hidden rounded-full p-1", children: [_jsx(SliderButton, { selected: isLeftSelected, setSelected: () => setSelected?.(options.left.value), children: options.left.text }), _jsx(SliderButton, { selected: !isLeftSelected, setSelected: () => setSelected?.(options.right.value), children: options.right.text }), _jsx(SliderButton, { selected: !isLeftSelected, setSelected: () => setSelected?.(options.right.value), children: options.right.text }), _jsx(SliderButton, { selected: !isLeftSelected, setSelected: () => setSelected?.(options.right.value), children: options.right.text })] }));
|
|
11
|
+
});
|
|
12
|
+
const SliderButton = memo(({ selected, children, setSelected }) => {
|
|
13
|
+
return (_jsxs("button", { type: "button", onClick: setSelected, className: classNames("bg-transparent text-sm px-2.5 py-0.5 rounded-full relative", selected
|
|
14
|
+
? "text-bolt-elements-item-contentAccent"
|
|
15
|
+
: "text-bolt-elements-item-contentDefault hover:text-bolt-elements-item-contentActive"), children: [_jsx("span", { className: "relative z-10", children: children }), selected && (_jsx(motion.span, { layoutId: "pill-tab", transition: { duration: 0.2, ease: cubicEasingFn }, className: "absolute inset-0 z-0 bg-bolt-elements-item-backgroundAccent rounded-full" }))] }));
|
|
16
|
+
});
|