*:first-child]:pl-3 [&>*:only-child]:!px-3",
33 | fluent && "focus-indicator",
34 | className,
35 | )}
36 | />
37 | );
38 | }
39 | export const InputButtonCNs =
40 | "inline-flex py-[3px] h-fit items-center justify-center rounded-sm bg-transparent px-2 text-foreground/60 hover:bg-foreground/10 active:opacity-80";
41 |
42 | export const InputButtonVisibility = {
43 | onEmpty: "only-empty",
44 | onText: "only-text",
45 | onFocus: "only-focus",
46 | };
47 |
48 | export function InputButton({
49 | className,
50 | icon,
51 | tabIndex,
52 | ...p
53 | }: Omit
, "children"> & {
54 | icon: React.ReactNode;
55 | }) {
56 | return (
57 |
66 | );
67 | }
68 |
69 | export function getCurrentInput(
70 | e: React.MouseEvent | React.KeyboardEvent,
71 | ) {
72 | return e.currentTarget
73 | .closest("[data-input-wrapper]")
74 | ?.querySelector("input") as HTMLInputElement | undefined;
75 | }
76 |
77 | const Input = React.forwardRef(
78 | (
79 | { className, children, pClassName, pStyle, type, toolBtns, ...props },
80 | ref,
81 | ) => {
82 | return (
83 |
88 |
94 | {toolBtns}
95 | {children}
96 |
97 | );
98 | },
99 | );
100 | Input.displayName = "Input";
101 |
102 | const FluentInput = React.forwardRef(
103 | ({ children, ...p }, ref) => {
104 | const innerRef = React.useRef(null);
105 |
106 | React.useImperativeHandle(ref, () => innerRef.current!);
107 |
108 | const clear = () => {
109 | if (innerRef.current) {
110 | innerRef.current.value = "";
111 | innerRef.current.focus();
112 | }
113 | };
114 |
115 | return (
116 |
117 | {true && ( // children
118 |
119 | } />
120 | } />
121 | {children}
122 |
123 | )}
124 |
125 | );
126 | },
127 | );
128 |
129 | FluentInput.displayName = "FluentInput";
130 |
131 | const TextArea = React.forwardRef(
132 | ({ className, pClassName, ...props }, ref) => {
133 | return (
134 |
135 |
140 |
141 | );
142 | },
143 | );
144 | TextArea.displayName = "TextArea";
145 |
146 | export { Input, TextArea, FluentInput };
147 |
--------------------------------------------------------------------------------
/src/components/fluentui/slider.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "@/lib/utils";
2 | import React, { useEffect, useRef, useState } from "react";
3 | // import type { IntRange } from "type-fest";
4 | import { composeEventHandlers } from "@radix-ui/primitive";
5 |
6 | type SliderProps = {
7 | min?: number;
8 | max?: number;
9 | initialValue?: number;
10 | onValueChange?: (value: number) => void;
11 | onProgressChange?: (percentage: number) => void;
12 | value?: number;
13 | } & Omit, "min" | "max">;
14 |
15 | export default function Slider({
16 | initialValue = 10,
17 | min = 0,
18 | max = 100,
19 | className,
20 | onChange,
21 | onValueChange,
22 | onProgressChange,
23 | value: userValue,
24 | }: SliderProps) {
25 | const [value, setValue] = useState(initialValue);
26 | const relValue = userValue ?? value;
27 | const percentage = useRef((relValue - min) / (max - min));
28 |
29 | useEffect(() => {
30 | onValueChange?.(relValue);
31 | percentage.current = (relValue - min) / (max - min);
32 | onProgressChange?.(percentage.current);
33 | }, [relValue]);
34 |
35 | return (
36 | console.log(e.currentTarget.value)}
42 | style={{ "--slider-progress": `${percentage.current}%` }}
43 | onChange={composeEventHandlers(
44 | onChange,
45 | (e) => {
46 | if (userValue != undefined) return;
47 | const newValue = Number(e.target.value);
48 | setValue(newValue);
49 | },
50 | { checkForDefaultPrevented: true },
51 | )}
52 | className={cn("fluent-slider outline-none", className)}
53 | />
54 | );
55 | }
56 |
--------------------------------------------------------------------------------
/src/components/iframe.tsx:
--------------------------------------------------------------------------------
1 | import { cn } from "@/lib/utils";
2 | import React, { useState } from "react";
3 | import Loader, { Bar } from "./loader";
4 |
5 | function Iframe({
6 | className,
7 | icon,
8 | ...p
9 | }: React.ComponentProps<"iframe"> & { icon?: string }) {
10 | const [isLoading, setIsLoading] = useState(true);
11 | return (
12 | <>
13 |