myoperator-ui 0.0.216-beta.3 → 0.0.216-beta.5
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/index.js +19 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2367,7 +2367,16 @@ export { Switch, switchVariants };
|
|
|
2367
2367
|
files: [
|
|
2368
2368
|
{
|
|
2369
2369
|
name: "text-field.tsx",
|
|
2370
|
-
content: prefixTailwindClasses(`import
|
|
2370
|
+
content: prefixTailwindClasses(`import {
|
|
2371
|
+
forwardRef,
|
|
2372
|
+
useRef,
|
|
2373
|
+
useCallback,
|
|
2374
|
+
useState,
|
|
2375
|
+
useId,
|
|
2376
|
+
type ChangeEvent,
|
|
2377
|
+
type ReactNode,
|
|
2378
|
+
type ComponentProps,
|
|
2379
|
+
} from "react";
|
|
2371
2380
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
2372
2381
|
import { Loader2, X } from "lucide-react";
|
|
2373
2382
|
|
|
@@ -2435,7 +2444,7 @@ const textFieldInputVariants = cva(
|
|
|
2435
2444
|
*/
|
|
2436
2445
|
export interface TextFieldProps
|
|
2437
2446
|
extends
|
|
2438
|
-
Omit<
|
|
2447
|
+
Omit<ComponentProps<"input">, "size">,
|
|
2439
2448
|
VariantProps<typeof textFieldInputVariants> {
|
|
2440
2449
|
/** Size of the text field \u2014 \`default\` (42px) or \`sm\` (36px, compact) */
|
|
2441
2450
|
size?: "default" | "sm";
|
|
@@ -2448,9 +2457,9 @@ export interface TextFieldProps
|
|
|
2448
2457
|
/** Error message - shows error state with red styling */
|
|
2449
2458
|
error?: string;
|
|
2450
2459
|
/** Icon displayed on the left inside the input */
|
|
2451
|
-
leftIcon?:
|
|
2460
|
+
leftIcon?: ReactNode;
|
|
2452
2461
|
/** Icon displayed on the right inside the input */
|
|
2453
|
-
rightIcon?:
|
|
2462
|
+
rightIcon?: ReactNode;
|
|
2454
2463
|
/** Text prefix inside input (e.g., "https://") */
|
|
2455
2464
|
prefix?: string;
|
|
2456
2465
|
/** Text suffix inside input (e.g., ".com") */
|
|
@@ -2471,7 +2480,7 @@ export interface TextFieldProps
|
|
|
2471
2480
|
inputContainerClassName?: string;
|
|
2472
2481
|
}
|
|
2473
2482
|
|
|
2474
|
-
const TextField =
|
|
2483
|
+
const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
|
|
2475
2484
|
(
|
|
2476
2485
|
{
|
|
2477
2486
|
className,
|
|
@@ -2505,8 +2514,8 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
2505
2514
|
ref
|
|
2506
2515
|
) => {
|
|
2507
2516
|
// Internal ref for programmatic control (e.g., clearable)
|
|
2508
|
-
const internalRef =
|
|
2509
|
-
const mergedRef =
|
|
2517
|
+
const internalRef = useRef<HTMLInputElement>(null);
|
|
2518
|
+
const mergedRef = useCallback(
|
|
2510
2519
|
(node: HTMLInputElement | null) => {
|
|
2511
2520
|
internalRef.current = node;
|
|
2512
2521
|
if (typeof ref === "function") ref(node);
|
|
@@ -2516,7 +2525,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
2516
2525
|
);
|
|
2517
2526
|
|
|
2518
2527
|
// Internal state for character count in uncontrolled mode
|
|
2519
|
-
const [internalValue, setInternalValue] =
|
|
2528
|
+
const [internalValue, setInternalValue] = useState(
|
|
2520
2529
|
defaultValue ?? ""
|
|
2521
2530
|
);
|
|
2522
2531
|
|
|
@@ -2528,7 +2537,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
2528
2537
|
const derivedState = error ? "error" : (state ?? "default");
|
|
2529
2538
|
|
|
2530
2539
|
// Handle change for both controlled and uncontrolled
|
|
2531
|
-
const handleChange = (e:
|
|
2540
|
+
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
2532
2541
|
if (!isControlled) {
|
|
2533
2542
|
setInternalValue(e.target.value);
|
|
2534
2543
|
}
|
|
@@ -2555,7 +2564,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
2555
2564
|
const charCount = String(currentValue).length;
|
|
2556
2565
|
|
|
2557
2566
|
// Generate unique IDs for accessibility
|
|
2558
|
-
const generatedId =
|
|
2567
|
+
const generatedId = useId();
|
|
2559
2568
|
const inputId = id || generatedId;
|
|
2560
2569
|
const helperId = \`\${inputId}-helper\`;
|
|
2561
2570
|
const errorId = \`\${inputId}-error\`;
|