gecut

payload fields

by gecut
nexload-sdk
Custom fields
v3
>=3.85.0 <4.0.0
MIT

Overview

Summary generated from the README

Provides Payload field factories with normalization hooks and React 19 admin components for Persian and Iranian applications. It covers Unicode slugs, Jalali date pickers, integer minor-unit money, and validated Iranian mobile, national code, bank card, Sheba and address fields. An optional plugin normalizes money strings submitted via REST or Local API. Requires Payload 3.85 or later and React 19, and is ESM-only.

Features

  • Unicode slug field with automatic collision suffixing and a slug generation endpoint
  • Jalali date and date range fields stored as timezone-stable ISO instants
  • Money field storing safe integer minor units with IRR, IRT or custom currencies
  • Validated Iranian mobile, landline, national code, legal ID, postal code, bank card and Sheba fields
  • Hidden indexed Persian search key field computed from source fields
  • Optional schema adapter for Zod projection via payload-schema

Use cases

  • Build Persian or bilingual admin panels with Jalali datepickers and localized validation
  • Store prices without floating-point drift using integer minor units
  • Validate Iranian national codes, phone numbers and bank details in customer collections

From the author

Production-grade semantic field factories and Admin integrations for Payload CMS.

Installation

npm i @nexload-sdk/payload-fields

3

Stars

0

Forks

0

Open Issues

Today

Last Updated

224

Weekly Downloads

v4.1.0

npm Version

532.6 KB

Unpacked Size

2

Dependencies

Repository stars

3+2 since Sep 6

Show data
Repository stars by day (UTC)
DateStars
Dec 5, 20263
Dec 4, 20263
Dec 3, 20263
Dec 2, 20263
Dec 1, 20263
Nov 30, 20263
Nov 29, 20263
Nov 28, 20263
Nov 27, 20263
Nov 26, 20263
Nov 25, 20263
Nov 24, 20263
Nov 23, 20263
Nov 22, 20263
Nov 21, 20263
Nov 20, 20263
Nov 19, 20263
Nov 18, 20263
Nov 17, 20262
Nov 16, 20262
Nov 15, 20262
Nov 14, 20262
Nov 13, 20262
Nov 12, 20262
Nov 11, 20262
Nov 10, 20262
Nov 9, 20262
Nov 8, 20262
Nov 7, 20262
Nov 6, 20262
Nov 5, 20262
Nov 4, 20262
Nov 3, 20262
Nov 2, 20262
Nov 1, 20262
Oct 31, 20262
Oct 30, 20262
Oct 29, 20262
Oct 28, 20262
Oct 27, 20262
Oct 26, 20262
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20262
Oct 21, 20262
Oct 20, 20262
Oct 19, 20262
Oct 18, 20262
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261

Shared by 8 plugins in gecut/nexload-sdk.

npm weekly downloads

79+50 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202679
Dec 4, 2026240
Dec 3, 2026238
Dec 2, 2026225
Dec 1, 2026233
Nov 30, 2026226
Nov 29, 2026213
Nov 28, 2026200
Nov 27, 202614
Nov 26, 202613
Nov 25, 202613
Nov 24, 20263
Nov 23, 20264
Nov 22, 20266
Nov 21, 20267
Nov 20, 20267
Nov 19, 20267
Nov 18, 202623
Nov 17, 202621
Nov 16, 202620
Nov 15, 202619
Nov 14, 202620
Nov 13, 202620
Nov 12, 202622
Nov 11, 20266
Nov 10, 202614
Nov 9, 202616
Nov 8, 202636
Nov 7, 202634
Nov 6, 202634
Nov 5, 202633
Nov 4, 202635
Nov 3, 202626
Nov 2, 202625
Nov 1, 20264
Oct 31, 202618
Oct 30, 202618
Oct 29, 202617
Oct 28, 202615
Oct 27, 202618
Oct 26, 202625
Oct 25, 202626
Oct 24, 202612
Oct 23, 202612
Oct 22, 202613
Oct 21, 202632
Oct 20, 202629
Oct 19, 202621
Oct 18, 202621
Oct 17, 202621
Oct 16, 202622
Oct 15, 202621
Oct 14, 20265
Oct 13, 20265
Oct 12, 202612
Oct 11, 202612
Oct 10, 202624
Oct 9, 202634
Oct 8, 202646
Oct 7, 202643
Oct 6, 202648
Oct 5, 202691
Oct 4, 2026120
Oct 3, 2026131
Oct 2, 2026134
Oct 1, 2026129
Sep 30, 2026138
Sep 29, 2026144
Sep 28, 202699
Sep 27, 202675
Sep 26, 202656
Sep 25, 202644
Sep 24, 202639
Sep 23, 202636
Sep 22, 202627
Sep 21, 202653
Sep 20, 202650
Sep 19, 202649
Sep 18, 202650
Sep 17, 202657
Sep 16, 202667
Sep 15, 202679
Sep 14, 202648
Sep 13, 202645
Sep 12, 202642
Sep 11, 202651
Sep 10, 202644
Sep 9, 202632
Sep 8, 202629
Sep 7, 202629
Sep 6, 202629

Each point is npm's rolling 7-day download count.

Health Score

75/100Excellent

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1086380959-payload-fields.svg)](https://payloaddirectory.dev/plugins/1086380959-payload-fields)
HTML
<a href="https://payloaddirectory.dev/plugins/1086380959-payload-fields"><img src="https://payloaddirectory.dev/badge/1086380959-payload-fields.svg" alt="Payload Directory"></a>
Updated Dec 5, 2026Created Oct 30, 2025Published Dec 3, 2026

README

@nexload-sdk/payload-fields

Semantic Payload CMS field factories and Admin UI components for Unicode slugs, Jalali dates, integer money, and Iranian identity fields.

Documentation · API reference

npm version License: MIT Module: ESM Runtime: Node | Payload 3 | React 19

[!IMPORTANT] Version 4.0.0 is pending in .changeset/: the package is now ESM-only targeting Payload >=3.85.0 <4.0.0 (React 19), slugs are unique by default, validation messages adapt to fa vs other locales, and ./schema adds @nexload-sdk/payload-schema integration.

Table of contents

Overview

@nexload-sdk/payload-fields provides production-ready Payload CMS field factories, beforeValidate normalization hooks, and React 19 Admin UI components tailored for Persian and Iranian applications. It solves percent-encoded Unicode slugs, Gregorian-only admin datepickers, floating-point currency rounding, and repeated validation logic for Iranian mobile numbers, national codes, bank cards, Sheba/IBANs, and addresses. It is for Payload 3 teams building Persian or bilingual admin panels.

What it is not:

  • Not a general schema compiler (pair with @nexload-sdk/payload-schema via ./schema for Zod projection).
  • Not a Lexical editor preset (use @nexload-sdk/payload-editor).
  • Not an admin localization or logger preset (use @nexload-sdk/payload-preset).

Philosophy

  • Canonical storage, localized display: Slugs, phone numbers, national codes, and money are normalized to clean canonical values on write and formatted for humans in the Admin UI.
  • Integer-only money: moneyField stores safe integer minor units (IRR, IRT, or a custom { code, label, fractionDigits } currency definition) to eliminate floating-point drift.
  • Timezone-stable Jalali dates: dayOnly and monthOnly dates store canonical noon (12:00:00) in timeZone (Asia/Tehran by default) so dates do not shift across browser timezones.
  • Explicit server/client isolation: Field factories run in Node/Payload config while "use client" Admin components live behind ./admin/* subpaths.

Install

pnpm add @nexload-sdk/payload-fields
# or
npm install @nexload-sdk/payload-fields
# or
yarn add @nexload-sdk/payload-fields
# or
bun add @nexload-sdk/payload-fields

For optional @nexload-sdk/payload-fields/schema support:

pnpm add @nexload-sdk/payload-schema zod
PackageRangeRequired / Optional
payload>=3.85.0 <4.0.0Required
@payloadcms/ui>=3.85.0 <4.0.0Required
react^19.0.1 || ^19.1.2 || ^19.2.1Required
react-dom^19.0.1 || ^19.1.2 || ^19.2.1Required
@nexload-sdk/payload-schema>=2.0.0 <4.0.0Optional (for ./schema)
zod>=4.1.0 <5.0.0Optional (for ./schema)

Quick start

import {
  iranAddressField,
  iranMobileField,
  jalaliDateField,
  jalaliDateRangeField,
  moneyField,
  nationalCodeField,
  payloadFieldsPlugin,
  slugField,
} from "@nexload-sdk/payload-fields";
import type { CollectionConfig } from "payload";

export const Customers: CollectionConfig = {
  slug: "customers",
  fields: [
    { name: "name", type: "text", required: true },
    ...slugField({ source: "name" }),
    jalaliDateField({ name: "birthDate", pickerAppearance: "dayOnly" }),
    jalaliDateRangeField({ start: "subscriptionStart", end: "subscriptionEnd" }),
    moneyField({ name: "credit", currency: "IRT", minMinorUnits: 0 }),
    iranMobileField({ name: "mobile", required: true }),
    nationalCodeField({ name: "nationalCode" }),
    iranAddressField({ recipient: false }),
  ],
};

Register payloadFieldsPlugin() in payload.config.ts if clients submit money as formatted strings or use custom slug generators.

Usage

Field catalog

FactoryStored TypeCanonical ValueAdmin Component
slugField(options)text + checkboxURL-safe Unicode slug ("کتاب", "کتاب-2")SlugFieldComponent
jalaliDateField(options)dateISO 8601 UTC instantJalaliDateFieldComponent + JalaliDateCell
jalaliDateRangeField(options)row (startsAt, endsAt)Two ISO 8601 instants (endsAt >= startsAt)JalaliDateFieldComponent + JalaliDateCell
withJalaliTimestamps(fields, options)adds virtual text fieldsVirtual createdAtJalali / updatedAtJalaliStandard read-only input
moneyField(options)numberSafe integer minor unitsMoneyFieldComponent + MoneyCell
iranMobileField(options)text09XXXXXXXXX (default) or +989XXXXXXXXX with storage: "e164"ValidatedTextFieldComponent + FormattedCell
iranLandlineField(options)text0XXXXXXXXXXValidatedTextFieldComponent + FormattedCell
nationalCodeField(options)text10-digit national code with checksum validationValidatedTextFieldComponent + FormattedCell
legalIdField(options)text11-digit legal entity ID with checksum validationValidatedTextFieldComponent + FormattedCell
postalCodeField(options)text10-digit postal codeValidatedTextFieldComponent + FormattedCell
bankCardField(options)text16-digit Luhn-checked cardValidatedTextFieldComponent + FormattedCell
shebaField(options)text26-char IBAN (IR...) with ISO 7064 validationValidatedTextFieldComponent + FormattedCell
ltrTextField(options)textRaw text with nexload-ltr class and optional monospace stylingStandard LTR text input
sortOrderField(options)numberNon-negative integer (default 0)Sidebar number input
iranAddressField(options)groupProvince, city, line, postalCode, recipientNative group with 31 provinces
searchKeyField(options)textNormalized Persian search key (toSearchIndexText of sources)Hidden, read-only, indexed

Schema adapter (@nexload-sdk/payload-fields/schema)

Use schemaFields to define entities with @nexload-sdk/payload-schema and derive both Payload fields and Zod schemas:

import { defineEntity } from "@nexload-sdk/payload-schema";
import { schemaFields } from "@nexload-sdk/payload-fields/schema";

export const customerEntity = defineEntity({
  name: "Customer",
  fields: {
    mobile: schemaFields.iranMobile(),
    nationalCode: schemaFields.nationalCode(),
    price: schemaFields.money({ currency: "IRT" }),
    birthDate: schemaFields.jalaliDate({ nullable: true }),
    ...schemaFields.slug({ source: "name" }),
  },
});

Persian search keys (searchKeyField)

searchKeyField({ name, sources, localized? }) creates a hidden, read-only, indexed text field whose beforeChange hook computes toSearchIndexText from the configured sources (reading siblingData when the source key is present — so explicit null clears it — and falling back to previousSiblingDoc when absent so partial updates keep the key, while overwriting any client-supplied value). Because it resolves against siblingData / previousSiblingDoc (falling back to originalDoc only at the top level), it works at the top level or inside a group, array, named tab, or block.

import { toSearchQuery } from "@nexload-sdk/persian/text";
import { searchKeyField } from "@nexload-sdk/payload-fields/search";

// Collection config
fields: [
  { name: "title", type: "text" },
  { name: "sku", type: "text" },
  searchKeyField({ name: "searchKey", sources: ["title", "sku"] }),
];

// Querying with Payload Local API
const q = toSearchQuery(userInput);
if (q) {
  where.and.push({ searchKey: { like: q } });
}

[!NOTE] Limitations:

  • Localization: When localized: true is set on searchKeyField, a change to a non-localized source field refreshes the search key only for the request locale. Keep all sources localized, or re-save each locale when a non-localized source changes.
  • Sibling beforeChange hooks: Payload runs sibling field beforeChange hooks concurrently, so searchKeyField reads each source's incoming value, not the value after that source's own beforeChange hook. The key is normalized by toSearchIndexText (letters, digits, diacritics, whitespace), so trimming or Persian normalization in the source does not matter; any other transform of a source must run in beforeValidate so the key sees the final value.
PostgreSQL pg_trgm + GIN migration

Payload index: true creates a B-tree index, which does not accelerate %word% substring ILIKE queries. In PostgreSQL, add a pg_trgm GIN index in a Payload migration (Payload runs migrations inside a transaction, so do not use CONCURRENTLY inside a migration):

CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE INDEX IF NOT EXISTS products_search_key_trgm_idx
  ON products USING gin (search_key gin_trgm_ops);

For large tables in production, create the index with CREATE INDEX CONCURRENTLY IF NOT EXISTS ... via psql outside Payload migrations to avoid blocking writes.

Backfill workflow (expand, migrate, verify)
  1. Expand: Deploy the collection with searchKeyField(...) and run migrations so new writes populate searchKey.
  2. Migrate: Backfill existing rows in bounded, restartable batches per locale (e.g. payload.find + payload.update with depth: 0) so the beforeChange hook computes keys without locking the table.
  3. Verify: Check that no active rows have a missing or stale searchKey, then switch search reads to query searchKey.

[!NOTE] SQLite caveat: toSearchQuery escapes \, %, and _ with \. PostgreSQL uses \ as its default LIKE/ILIKE escape character, so wildcards match literally. SQLite has no default ESCAPE character, so the literal-wildcard guarantee is Postgres-only. On SQLite, a query containing %, _ or \ will not match when escaped, so SQLite users pass toSearchQuery(userInput, { escape: false }) (accepting that those characters then act as wildcards).

API

SubpathKey exportsSummary
@nexload-sdk/payload-fieldsAll field factories, withJalaliTimestamps, payloadFieldsPlugin, PAYLOAD_FIELDS_PLUGIN_ORDER, IRR, IRT, resolveCurrency, parseMoneyToMinorUnits, formatMoney, formatJalaliDate, toStoredJalaliInstant, and option typesMain server/config entry
@nexload-sdk/payload-fields/slugslugField, formatSlug, SlugFieldOptions, SlugFieldResultStandalone slug factory & formatter
@nexload-sdk/payload-fields/searchsearchKeyField, SearchKeyFieldOptionsHidden indexed Persian search key field
@nexload-sdk/payload-fields/datejalaliDateField, jalaliDateRangeField, withJalaliTimestamps, toStoredJalaliInstant, formatJalaliDateStandalone Jalali date utilities
@nexload-sdk/payload-fields/moneymoneyField, IRR, IRT, resolveCurrency, parseMoneyToMinorUnits, formatMoneyStandalone money field & helpers
@nexload-sdk/payload-fields/schemaschemaFields@nexload-sdk/payload-schema adapter
@nexload-sdk/payload-fields/admin/slug-fieldSlugFieldComponentAdmin slug field UI
@nexload-sdk/payload-fields/admin/jalali-date-fieldJalaliDateFieldComponentAdmin Jalali datepicker UI
@nexload-sdk/payload-fields/admin/jalali-date-cellJalaliDateCellList cell for Jalali dates
@nexload-sdk/payload-fields/admin/money-fieldMoneyFieldComponentAdmin formatted money input
@nexload-sdk/payload-fields/admin/money-cellMoneyCellList cell for money values
@nexload-sdk/payload-fields/admin/validated-text-fieldValidatedTextFieldComponentAdmin input for Iranian text fields
@nexload-sdk/payload-fields/admin/formatted-cellFormattedCellList cell for Iranian text fields

Configuration

payloadFieldsPlugin(options) accepts:

OptionTypeDefaultDescription
slugGeneratorsRecord<string, SlugGenerator>undefinedNamed async slug generators invoked by the plugin's slug endpoint
generateSlugAccessSlugGenerationAccessundefinedAccess predicate { req } => boolean | Promise<boolean> for slug generation

The plugin sets slug: "nexload-fields" and order: 900 (PAYLOAD_FIELDS_PLUGIN_ORDER).

Runtime and compatibility

  • Module format: ESM-only (type: "module").
  • Runtime: Field factories and payloadFieldsPlugin run in Node.js / Payload config. Admin components under ./admin/* are React 19 "use client" components.
  • Payload version: payload and @payloadcms/ui >=3.85.0 <4.0.0 with React 19.
  • Bilingual validation: Errors follow req.i18n.language / useTranslation() (fa* receives Persian; all other locales receive English).

Caveats

[!CAUTION] payloadFieldsPlugin() is required when money values are submitted via REST or Local API as strings (such as "۱۲۳٬۴۵۶" or "123456"). Payload core runs parseFloat() on number fields before field hooks run, which strips or corrupts Persian digits and separators; the plugin's beforeOperation hook normalizes strings to safe integers first. Plain numeric values work without the plugin. The hook is registered on collections and globals and normalizes money fields in blocks referenced by slug from config.blocks.

[!WARNING] slugField is unique by default (unique: true), but automatic collision suffixing (-2, -3) only runs for top-level slug fields. For slugs nested inside arrays, groups, or named tabs, pass unique: false (otherwise database unique errors apply instead of suffixes).

[!NOTE] iranAddressField and jalaliDateRangeField are not included in @nexload-sdk/payload-fields/schema in 4.0. Also, the plugin only sees collections and globals that exist when it runs. If another plugin with order >= 900 adds money fields, place it before payloadFieldsPlugin() when it uses order 900, or give it an order below 900.

Migration

From 3.x to 4.0

  1. ESM-only & Payload 3.85+: Package is strictly ESM-only and requires payload / @payloadcms/ui >=3.85.0 <4.0.0 and React 19.
  2. Monorepo path: Moved from packages/refactoring/payload-fields to packages/payload-fields.
  3. Unique slugs: Resolve existing duplicate top-level slugs in your database before migrating, or pass unique: false.
  4. Jalali storage: dayOnly and monthOnly dates store canonical noon in timeZone (Asia/Tehran by default).
  5. Bilingual messages: Non-fa admin locales now receive English validation messages instead of Persian.
  6. Money strings: Add payloadFieldsPlugin() if clients send money as strings.
  7. Import map: Run pnpm payload generate:importmap after upgrading to refresh Admin component paths.
  • persian — Core Persian/Iranian normalization and validation primitives
  • payload-schema — Canonical entity definitions used by ./schema
  • payload-preset — Composed preset that includes payloadFieldsPlugin()

Agent skills

This package ships agent skills that match its version. After install they are at node_modules/@nexload-sdk/payload-fields/skills/:

  • payload-fields-core — skills/payload-fields-core/SKILL.md
  • payload-fields-iranian-fields — skills/payload-fields-iranian-fields/SKILL.md
  • payload-fields-jalali-date — skills/payload-fields-jalali-date/SKILL.md
  • payload-fields-money — skills/payload-fields-money/SKILL.md
  • payload-fields-slug — skills/payload-fields-slug/SKILL.md

Point your coding agent at them from AGENTS.md, or install from the repository with npx skills add gecut/nexload-sdk --skill <name>.

License

MIT

Similar plugins