agentleFS
bkjain655bkjain655/agent-skills/skills/specialized-form-inputs/SKILL.md

specialized-form-inputs

Skill0 starsChanged 3 months agoMITView on GitHub

Implements specialized form inputs for webapps: currency/amount fields with sliders, date of birth pickers, calendar date pickers, month/year selectors, and locale-aware formatting. Use when building money inputs, datepickers, DOB fields, or numeric inputs with UX beyond plain text fields.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer 3-select (year / month / day) when:

    line 57
  2. Very specific:

    Use date-fns for format/parse.

    line 93
  3. Distinctive:

    Always validate in Zod schema and show inline field errors

    line 103

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Specialized Form Inputs

Currency / amount input

Pattern: text field + optional slider + stepper buttons. Store numbers in state, format for display.

Utils (lib/amount-utils.ts)

export function parseAmountInput(raw: string): number {
  const cleaned = raw.replace(/[^\d.]/g, "");
  const n = parseFloat(cleaned);
  return Number.isFinite(n) ? n : 0;
}

export function formatAmountForEditing(n: number): string {
  return n.toLocaleString("en-IN", { maximumFractionDigits: 0 }); // swap locale
}

export function formatAmountCompact(n: number): string {
  if (n >= 1_00_00_000) return `₹${(n / 1_00_00_000).toFixed(1)}Cr`;
  if (n >= 1_00_000) return `₹${(n / 1_00_000).toFixed(1)}L`;
  return formatAmountForEditing(n);
}

export function clampAmount(n: number, min: number, max: number) {
  return Math.min(max, Math.max(min, n));
}

export function getSliderMaxForValue(value: number): number {
  const tiers = [1_00_000, 10_00_000, 50_00_000, 1_00_00_000, 5_00_00_000];
  return tiers.find((t) => value <= t) ?? tiers[tiers.length - 1];
}

Component behavior

  • Display mode: formatted string; empty when 0
  • Edit mode: raw draft on focus; parse + clamp on blur
  • Slider: dynamic max from getSliderMaxForValue
  • Steppers: ± preset increments (1K, 10K, 1L, etc.)
  • Optional compact prop for dense wizard layouts

Pass tooltip from centralized help copy.

Date of birth (select-based)

Prefer 3-select (year / month / day) when:

  • Mobile UX matters more than calendar UX
  • You want decade-grouped years without a heavy date lib

Store ISO string YYYY-MM-DD or undefined until complete.

export function toDateOfBirth(y?: number, m?: number, d?: number): string | undefined {
  if (!y || !m || !d) return undefined;
  return `${y}-${String(m).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
}

export function getDaysInMonth(year: number, month: number): number {
  return new Date(year, month, 0).getDate();
}

export function calculateAge(iso?: string): number | undefined { /* ... */ }

Clamp day when month/year changes. Show confirmation chip: formatted date + computed age.

Calendar date picker (shadcn)

For general dates (appointments, deadlines):

<Popover>
  <PopoverTrigger asChild>
    <Button variant="outline">{date ? format(date, "PPP") : "Pick a date"}</Button>
  </PopoverTrigger>
  <PopoverContent className="w-auto p-0">
    <Calendar mode="single" selected={date} onSelect={setDate} initialFocus />
  </PopoverContent>
</Popover>

Use date-fns for format/parse. Disable past/future via disabled prop on Calendar.

Month + year only

Two selects side by side; store { month: number; year: number }. Useful for goals, EMI start dates.

Validation

  • DOB: min/max age, valid calendar date (Feb 29 handling)
  • Amount: non-negative, optional max; reject NaN on parse
  • Always validate in Zod schema and show inline field errors

Locale / currency config

Centralize in one module:

export const MONEY = { locale: "en-IN", currency: "INR", symbol: "₹" } as const;

Swap per product/market without touching every component.

Related skills

  • shadcn-ui-setup — Form, Calendar, Select primitives
  • vitest-unit-testing — test parse/format utils
  • multi-step-wizard-flow — wizard step forms using these inputs

Anti-patterns

  • Storing formatted strings ("₹1,50,000") in app state
  • <input type="number"> for currency (bad UX on mobile, spinner quirks)
  • Native <input type="date"> when brand consistency matters (Safari/Chrome differ)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.