BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/base/mask-input

mask-input

diceui-base/mask-input
FreeComponent

diceui/base publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/mask-input.json

Source

ui/mask-input.tsxraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/mask-input.json · first 6 KB
1"use client";
2
3import { mergeProps } from "@base-ui/react/merge-props";
4import { useRender } from "@base-ui/react/use-render";
5import * as React from "react";
6import { cn } from "@/lib/utils";
7import { useComposedRefs } from "@/registry/bases/base/lib/compose-refs";
8
9const PAST_YEARS_LIMIT = 120;
10const FUTURE_YEARS_LIMIT = 10;
11const DEFAULT_CURRENCY = "USD";
12const DEFAULT_LOCALE = "en-US";
13
14const NUMERIC_MASK_PATTERNS =
15 /^(phone|zipCode|zipCodeExtended|ssn|ein|time|date|creditCard|creditCardExpiry)$/;
16const CURRENCY_PERCENTAGE_SYMBOLS = /[€$%]/;
17
18interface CurrencySymbols {
19 currency: string;
20 decimal: string;
21 group: string;
22}
23
24const formattersCache = new Map<string, Intl.NumberFormat>();
25const currencyAtEndCache = new Map<string, boolean>();
26const currencySymbolsCache = new Map<string, CurrencySymbols>();
27const daysInMonthCache = [
28 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
29] as const;
30
31const REGEX_CACHE = {
32 digitsOnly: /^\d+$/,
33 nonDigits: /\D/g,
34 nonAlphaNumeric: /[^A-Z0-9]/gi,
35 nonNumericDot: /[^0-9.]/g,
36 nonCurrencyChars: /[^\d.,]/g,
37 hashPattern: /#/g,
38 currencyAtEnd: /\d\s*[^\d\s]+$/,
39 percentageChars: /[^\d.]/g,
40 phone: /^\d{10}$/,
41 ssn: /^\d{9}$/,
42 zipCode: /^\d{5}$/,
43 zipCodeExtended: /^\d{9}$/,
44 isbn: /^\d{13}$/,
45 ein: /^\d{9}$/,
46 time: /^\d{4}$/,
47 creditCard: /^\d{13,19}$/,
48 creditCardExpiry: /^\d{4}$/,
49 licensePlate: /^[A-Z0-9]{6}$/,
50 macAddress: /^[A-F0-9]{12}$/,
51 currencyValidation: /^\d+(\.\d{1,2})?$/,
52 ipv4Segment: /^\d{1,3}$/,
53} as const;
54
55function getCachedFormatter(
56 locale: string | undefined,
57 opts: Intl.NumberFormatOptions,
58): Intl.NumberFormat {
59 const {
60 currency,
61 minimumFractionDigits = 0,
62 maximumFractionDigits = 2,
63 } = opts;
64
65 const key = `${locale}|${currency}|${minimumFractionDigits}|${maximumFractionDigits}`;
66
67 if (!formattersCache.has(key)) {
68 try {
69 formattersCache.set(
70 key,
71 new Intl.NumberFormat(locale, {
72 style: "currency",
73 currency,
74 ...opts,
75 }),
76 );
77 } catch {
78 formattersCache.set(
79 key,
80 new Intl.NumberFormat(DEFAULT_LOCALE, {
81 style: "currency",
82 currency: DEFAULT_CURRENCY,
83 ...opts,
84 }),
85 );
86 }
87 }
88
89 const formatter = formattersCache.get(key);
90 if (!formatter) {
91 throw new Error(`Failed to create formatter for ${key}`);
92 }
93 return formatter;
94}
95
96function getCachedCurrencySymbols(opts: TransformOptions): CurrencySymbols {
97// … truncated

What it pulls in

npm packages

  • @base-ui/react

Files it writes

  • ui/mask-input.tsx
  • lib/compose-refs.ts

Facts

Registry
diceui/base
Type
registry:ui
Access
Free
Files written
2
Licence
the repository states none
First indexed
2026-08-09
Last confirmed
yesterday

Go to the source

www.diceui.com sadmann7/diceui on GitHub Raw registry item This item as JSON

More from diceui/base

All 192 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
action-baraction-bardiceui/baseComponentsFree1 dep
angle-sliderangle-sliderdiceui/baseComponentsFree1 dep · 3 files
avatar-groupavatar-groupdiceui/baseComponentsFree1 dep
badge-overflowbadge-overflowdiceui/baseComponentsFree1 dep · 2 files
bannerbannerdiceui/baseComponentsFree1 dep
circular-progresscircular-progressdiceui/baseComponentsFree1 dep
client-onlyclient-onlydiceui/baseComponentsFreeno deps
color-pickercolor-pickerdiceui/baseComponentsFree1 dep · 2 files
BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studios

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex