regex-input
domain-ui/regex-inputFreeComponent
domain-ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/teurons/domain-ui/main/apps/web/public/r/regex-input.jsonSource
1"use client";23import type * as React from "react";4import { Input } from "@/components/ui/input";5import {6 useSimpleRegex,7 type ValidationStatusType,8} from "@/hooks/use-simple-regex";910export interface RegexInputProps extends React.ComponentProps<"input"> {11 regex: RegExp;12 onValidation?: (status: ValidationStatusType) => void;13 transformToUppercase?: boolean;14}1516export function RegexInput({17 regex,18 value,19 onChange,20 onValidation,21 defaultValue,22 transformToUppercase,23 ...props24}: RegexInputProps) {25 const { value: displayValue, onChange: handleChange } = useSimpleRegex({26 regex,27 value: value as string | undefined,28 onChange: onChange29 ? (newValue: string) => {30 const syntheticEvent = {31 target: { value: newValue },32 currentTarget: { value: newValue },33 } as React.ChangeEvent<HTMLInputElement>;34 onChange(syntheticEvent);35 }36 : undefined,37 onValidation,38 defaultValue: defaultValue as string | undefined,39 transformToUppercase,40 });4142 return <Input {...props} value={displayValue} onChange={handleChange} />;43}
What it pulls in
Other registry items
Files it writes
More from domain-ui
All 16 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| pan-inputpan-input | domain-ui | Components | Free | no deps | |
| pan-input-incrementalpan-input-incremental | domain-ui | Components | Free | no deps | |
| passport-inputpassport-input | domain-ui | Components | Free | no deps | |
| passport-input-incrementalpassport-input-incremental | domain-ui | Components | Free | no deps | |
| phone-inputphone-input | domain-ui | Components | Free | 2 deps | |
| portfolio-chartportfolio-chart | domain-ui | Components | Free | no deps | |
| regex-input-incrementalregex-input-incremental | domain-ui | Components | Free | no deps · 5 files | |
| responsive-resizable-previewresponsive-resizable-preview | domain-ui | Components | Free | no deps · 3 files |
