@nexload-sdk/payload-fields 2.0.1 → 4.0.0
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/README.md +182 -55
- package/dist/address/index.d.ts +13 -0
- package/dist/address/index.d.ts.map +1 -0
- package/dist/admin/formatted-cell.d.ts +6 -0
- package/dist/admin/formatted-cell.d.ts.map +1 -0
- package/dist/admin/formatted-cell.js +18 -0
- package/dist/admin/formatted-cell.js.map +7 -0
- package/dist/admin/jalali-date-cell.d.ts +6 -0
- package/dist/admin/jalali-date-cell.d.ts.map +1 -0
- package/dist/admin/jalali-date-cell.js +27 -0
- package/dist/admin/jalali-date-cell.js.map +7 -0
- package/dist/admin/jalali-date-field.d.ts +12 -0
- package/dist/admin/jalali-date-field.d.ts.map +1 -0
- package/dist/admin/jalali-date-field.js +250 -0
- package/dist/admin/jalali-date-field.js.map +7 -0
- package/dist/admin/money-cell.d.ts +10 -0
- package/dist/admin/money-cell.d.ts.map +1 -0
- package/dist/admin/money-cell.js +124 -0
- package/dist/admin/money-cell.js.map +7 -0
- package/dist/admin/money-field.d.ts +11 -0
- package/dist/admin/money-field.d.ts.map +1 -0
- package/dist/admin/money-field.js +183 -0
- package/dist/admin/money-field.js.map +7 -0
- package/dist/admin/slug-field.d.ts +9 -0
- package/dist/admin/slug-field.d.ts.map +1 -0
- package/dist/admin/slug-field.js +210 -0
- package/dist/admin/slug-field.js.map +7 -0
- package/dist/admin/validated-text-field.d.ts +6 -0
- package/dist/admin/validated-text-field.d.ts.map +1 -0
- package/dist/admin/validated-text-field.js +35 -0
- package/dist/admin/validated-text-field.js.map +7 -0
- package/dist/bank/index.d.ts +7 -0
- package/dist/bank/index.d.ts.map +1 -0
- package/dist/common/index.d.ts +35 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/contact/index.d.ts +9 -0
- package/dist/contact/index.d.ts.map +1 -0
- package/dist/date/format-date.d.ts +8 -1
- package/dist/date/format-date.d.ts.map +1 -1
- package/dist/date/index.d.ts +56 -4
- package/dist/date/index.d.ts.map +1 -1
- package/dist/date/index.js +258 -0
- package/dist/date/index.js.map +7 -0
- package/dist/date/picker-types.d.ts +2 -0
- package/dist/date/picker-types.d.ts.map +1 -0
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +97 -0
- package/dist/i18n/messages.js.map +7 -0
- package/dist/identity/index.d.ts +9 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1038 -0
- package/dist/index.js.map +7 -0
- package/dist/internal/protect.d.ts +7 -0
- package/dist/internal/protect.d.ts.map +1 -0
- package/dist/internal/validated-text.d.ts +24 -0
- package/dist/internal/validated-text.d.ts.map +1 -0
- package/dist/internal/validated-text.js +161 -0
- package/dist/internal/validated-text.js.map +7 -0
- package/dist/money/index.d.ts +35 -0
- package/dist/money/index.d.ts.map +1 -0
- package/dist/money/index.js +212 -0
- package/dist/money/index.js.map +7 -0
- package/dist/plugin.d.ts +17 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/schema/index.d.ts +51 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +735 -0
- package/dist/schema/index.js.map +7 -0
- package/dist/slug/format-slug.d.ts +8 -2
- package/dist/slug/format-slug.d.ts.map +1 -1
- package/dist/slug/index.d.ts +13 -5
- package/dist/slug/index.d.ts.map +1 -1
- package/dist/slug/index.js +158 -0
- package/dist/slug/index.js.map +7 -0
- package/package.json +86 -34
- package/dist/date/date-cell.cjs +0 -60
- package/dist/date/date-cell.cjs.map +0 -7
- package/dist/date/date-cell.d.ts +0 -7
- package/dist/date/date-cell.d.ts.map +0 -1
- package/dist/date/date-cell.mjs +0 -34
- package/dist/date/date-cell.mjs.map +0 -7
- package/dist/date/date-picker.cjs +0 -221
- package/dist/date/date-picker.cjs.map +0 -7
- package/dist/date/date-picker.d.ts +0 -5
- package/dist/date/date-picker.d.ts.map +0 -1
- package/dist/date/date-picker.mjs +0 -197
- package/dist/date/date-picker.mjs.map +0 -7
- package/dist/index.cjs +0 -171
- package/dist/index.cjs.map +0 -7
- package/dist/index.mjs +0 -150
- package/dist/index.mjs.map +0 -7
- package/dist/slug/slug-field.cjs +0 -246
- package/dist/slug/slug-field.cjs.map +0 -7
- package/dist/slug/slug-field.d.ts +0 -10
- package/dist/slug/slug-field.d.ts.map +0 -1
- package/dist/slug/slug-field.mjs +0 -228
- package/dist/slug/slug-field.mjs.map +0 -7
package/README.md
CHANGED
|
@@ -1,87 +1,214 @@
|
|
|
1
1
|
# @nexload-sdk/payload-fields
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Semantic Payload CMS field factories and Admin UI components for Unicode slugs, Jalali dates, integer money, and Iranian identity fields.**
|
|
4
|
+
|
|
5
|
+
[Documentation](https://gecut.github.io/nexload-sdk/packages/payload-fields/) · [API reference](https://gecut.github.io/nexload-sdk/packages/payload-fields/api/)
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@nexload-sdk/payload-fields)
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
> [!IMPORTANT]
|
|
13
|
+
> 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.
|
|
14
|
+
|
|
15
|
+
## Table of contents
|
|
16
|
+
|
|
17
|
+
- [Overview](#overview)
|
|
18
|
+
- [Philosophy](#philosophy)
|
|
19
|
+
- [Install](#install)
|
|
20
|
+
- [Quick start](#quick-start)
|
|
21
|
+
- [Usage](#usage)
|
|
22
|
+
- [API](#api)
|
|
23
|
+
- [Configuration](#configuration)
|
|
24
|
+
- [Runtime and compatibility](#runtime-and-compatibility)
|
|
25
|
+
- [Caveats](#caveats)
|
|
26
|
+
- [Migration](#migration)
|
|
27
|
+
- [Related packages](#related-packages)
|
|
28
|
+
- [License](#license)
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
`@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.
|
|
33
|
+
|
|
34
|
+
What it is not:
|
|
35
|
+
|
|
36
|
+
- Not a general schema compiler (pair with `@nexload-sdk/payload-schema` via `./schema` for Zod projection).
|
|
37
|
+
- Not a Lexical editor preset (use `@nexload-sdk/payload-editor`).
|
|
38
|
+
- Not an admin localization or logger preset (use `@nexload-sdk/payload-preset`).
|
|
39
|
+
|
|
40
|
+
## Philosophy
|
|
41
|
+
|
|
42
|
+
- **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.
|
|
43
|
+
- **Integer-only money:** `moneyField` stores safe integer minor units (`IRR`, `IRT`, or a custom `{ code, label, fractionDigits }` currency definition) to eliminate floating-point drift.
|
|
44
|
+
- **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.
|
|
45
|
+
- **Explicit server/client isolation:** Field factories run in Node/Payload config while `"use client"` Admin components live behind `./admin/*` subpaths.
|
|
4
46
|
|
|
5
47
|
## Install
|
|
6
48
|
|
|
7
49
|
```bash
|
|
8
50
|
pnpm add @nexload-sdk/payload-fields
|
|
51
|
+
# or
|
|
52
|
+
npm install @nexload-sdk/payload-fields
|
|
53
|
+
# or
|
|
54
|
+
yarn add @nexload-sdk/payload-fields
|
|
55
|
+
# or
|
|
56
|
+
bun add @nexload-sdk/payload-fields
|
|
9
57
|
```
|
|
10
58
|
|
|
11
|
-
|
|
59
|
+
For optional `@nexload-sdk/payload-fields/schema` support:
|
|
12
60
|
|
|
13
|
-
|
|
61
|
+
```bash
|
|
62
|
+
pnpm add @nexload-sdk/payload-schema zod
|
|
63
|
+
```
|
|
14
64
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
65
|
+
| Package | Range | Required / Optional |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `payload` | `>=3.85.0 <4.0.0` | Required |
|
|
68
|
+
| `@payloadcms/ui` | `>=3.85.0 <4.0.0` | Required |
|
|
69
|
+
| `react` | `^19.0.1 \|\| ^19.1.2 \|\| ^19.2.1` | Required |
|
|
70
|
+
| `react-dom` | `^19.0.1 \|\| ^19.1.2 \|\| ^19.2.1` | Required |
|
|
71
|
+
| `@nexload-sdk/payload-schema` | `>=2.0.0 <4.0.0` | Optional (for `./schema`) |
|
|
72
|
+
| `zod` | `>=4.1.0 <5.0.0` | Optional (for `./schema`) |
|
|
19
73
|
|
|
20
|
-
|
|
74
|
+
## Quick start
|
|
21
75
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
76
|
+
```ts
|
|
77
|
+
import {
|
|
78
|
+
iranAddressField,
|
|
79
|
+
iranMobileField,
|
|
80
|
+
jalaliDateField,
|
|
81
|
+
jalaliDateRangeField,
|
|
82
|
+
moneyField,
|
|
83
|
+
nationalCodeField,
|
|
84
|
+
payloadFieldsPlugin,
|
|
85
|
+
slugField,
|
|
86
|
+
} from "@nexload-sdk/payload-fields";
|
|
87
|
+
import type { CollectionConfig } from "payload";
|
|
88
|
+
|
|
89
|
+
export const Customers: CollectionConfig = {
|
|
90
|
+
slug: "customers",
|
|
91
|
+
fields: [
|
|
92
|
+
{ name: "name", type: "text", required: true },
|
|
93
|
+
...slugField({ source: "name" }),
|
|
94
|
+
jalaliDateField({ name: "birthDate", pickerAppearance: "dayOnly" }),
|
|
95
|
+
jalaliDateRangeField({ start: "subscriptionStart", end: "subscriptionEnd" }),
|
|
96
|
+
moneyField({ name: "credit", currency: "IRT", minMinorUnits: 0 }),
|
|
97
|
+
iranMobileField({ name: "mobile", required: true }),
|
|
98
|
+
nationalCodeField({ name: "nationalCode" }),
|
|
99
|
+
iranAddressField({ recipient: false }),
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
```
|
|
27
103
|
|
|
28
|
-
|
|
104
|
+
Register `payloadFieldsPlugin()` in `payload.config.ts` if clients submit money as formatted strings or use custom slug generators.
|
|
29
105
|
|
|
30
|
-
|
|
106
|
+
## Usage
|
|
31
107
|
|
|
32
|
-
|
|
33
|
-
- fixed toolbar
|
|
34
|
-
- horizontal rule
|
|
35
|
-
- upload
|
|
36
|
-
- table (experimental)
|
|
37
|
-
- relationship feature (`products`, `articles`)
|
|
108
|
+
### Field catalog
|
|
38
109
|
|
|
39
|
-
|
|
110
|
+
| Factory | Stored Type | Canonical Value | Admin Component |
|
|
111
|
+
| --- | --- | --- | --- |
|
|
112
|
+
| `slugField(options)` | `text` + `checkbox` | URL-safe Unicode slug (`"کتاب"`, `"کتاب-2"`) | `SlugFieldComponent` |
|
|
113
|
+
| `jalaliDateField(options)` | `date` | ISO 8601 UTC instant | `JalaliDateFieldComponent` + `JalaliDateCell` |
|
|
114
|
+
| `jalaliDateRangeField(options)` | `row` (`startsAt`, `endsAt`) | Two ISO 8601 instants (`endsAt >= startsAt`) | `JalaliDateFieldComponent` + `JalaliDateCell` |
|
|
115
|
+
| `withJalaliTimestamps(fields, options)` | adds virtual `text` fields | Virtual `createdAtJalali` / `updatedAtJalali` | Standard read-only input |
|
|
116
|
+
| `moneyField(options)` | `number` | Safe integer minor units | `MoneyFieldComponent` + `MoneyCell` |
|
|
117
|
+
| `iranMobileField(options)` | `text` | `09XXXXXXXXX` (default) or `+989XXXXXXXXX` with `storage: "e164"` | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
118
|
+
| `iranLandlineField(options)` | `text` | `0XXXXXXXXXX` | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
119
|
+
| `nationalCodeField(options)` | `text` | 10-digit national code with checksum validation | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
120
|
+
| `legalIdField(options)` | `text` | 11-digit legal entity ID with checksum validation | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
121
|
+
| `postalCodeField(options)` | `text` | 10-digit postal code | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
122
|
+
| `bankCardField(options)` | `text` | 16-digit Luhn-checked card | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
123
|
+
| `shebaField(options)` | `text` | 26-char IBAN (`IR...`) with ISO 7064 validation | `ValidatedTextFieldComponent` + `FormattedCell` |
|
|
124
|
+
| `ltrTextField(options)` | `text` | Raw text with `nexload-ltr` class and optional `monospace` styling | Standard LTR text input |
|
|
125
|
+
| `sortOrderField(options)` | `number` | Non-negative integer (default `0`) | Sidebar number input |
|
|
126
|
+
| `iranAddressField(options)` | `group` | Province, city, line, postalCode, recipient | Native group with 31 provinces |
|
|
40
127
|
|
|
41
|
-
|
|
42
|
-
|
|
128
|
+
### Schema adapter (`@nexload-sdk/payload-fields/schema`)
|
|
129
|
+
|
|
130
|
+
Use `schemaFields` to define entities with `@nexload-sdk/payload-schema` and derive both Payload fields and Zod schemas:
|
|
43
131
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
132
|
+
```ts
|
|
133
|
+
import { defineEntity } from "@nexload-sdk/payload-schema";
|
|
134
|
+
import { schemaFields } from "@nexload-sdk/payload-fields/schema";
|
|
135
|
+
|
|
136
|
+
export const customerEntity = defineEntity({
|
|
137
|
+
name: "Customer",
|
|
138
|
+
fields: {
|
|
139
|
+
mobile: schemaFields.iranMobile(),
|
|
140
|
+
nationalCode: schemaFields.nationalCode(),
|
|
141
|
+
price: schemaFields.money({ currency: "IRT" }),
|
|
142
|
+
birthDate: schemaFields.jalaliDate({ nullable: true }),
|
|
143
|
+
...schemaFields.slug({ source: "name" }),
|
|
144
|
+
},
|
|
145
|
+
});
|
|
49
146
|
```
|
|
50
147
|
|
|
51
|
-
##
|
|
148
|
+
## API
|
|
52
149
|
|
|
53
|
-
|
|
150
|
+
| Subpath | Key exports | Summary |
|
|
151
|
+
| --- | --- | --- |
|
|
152
|
+
| `@nexload-sdk/payload-fields` | All field factories, `withJalaliTimestamps`, `payloadFieldsPlugin`, `PAYLOAD_FIELDS_PLUGIN_ORDER`, `IRR`, `IRT`, `resolveCurrency`, `parseMoneyToMinorUnits`, `formatMoney`, `formatJalaliDate`, `toStoredJalaliInstant`, and option types | Main server/config entry |
|
|
153
|
+
| `@nexload-sdk/payload-fields/slug` | `slugField`, `formatSlug`, `SlugFieldOptions`, `SlugFieldResult` | Standalone slug factory & formatter |
|
|
154
|
+
| `@nexload-sdk/payload-fields/date` | `jalaliDateField`, `jalaliDateRangeField`, `withJalaliTimestamps`, `toStoredJalaliInstant`, `formatJalaliDate` | Standalone Jalali date utilities |
|
|
155
|
+
| `@nexload-sdk/payload-fields/money` | `moneyField`, `IRR`, `IRT`, `resolveCurrency`, `parseMoneyToMinorUnits`, `formatMoney` | Standalone money field & helpers |
|
|
156
|
+
| `@nexload-sdk/payload-fields/schema` | `schemaFields` | `@nexload-sdk/payload-schema` adapter |
|
|
157
|
+
| `@nexload-sdk/payload-fields/admin/slug-field` | `SlugFieldComponent` | Admin slug field UI |
|
|
158
|
+
| `@nexload-sdk/payload-fields/admin/jalali-date-field` | `JalaliDateFieldComponent` | Admin Jalali datepicker UI |
|
|
159
|
+
| `@nexload-sdk/payload-fields/admin/jalali-date-cell` | `JalaliDateCell` | List cell for Jalali dates |
|
|
160
|
+
| `@nexload-sdk/payload-fields/admin/money-field` | `MoneyFieldComponent` | Admin formatted money input |
|
|
161
|
+
| `@nexload-sdk/payload-fields/admin/money-cell` | `MoneyCell` | List cell for money values |
|
|
162
|
+
| `@nexload-sdk/payload-fields/admin/validated-text-field` | `ValidatedTextFieldComponent` | Admin input for Iranian text fields |
|
|
163
|
+
| `@nexload-sdk/payload-fields/admin/formatted-cell` | `FormattedCell` | List cell for Iranian text fields |
|
|
54
164
|
|
|
55
|
-
|
|
56
|
-
- custom cell component (`DateCell`)
|
|
57
|
-
- Persian/Jalali formatting helpers
|
|
165
|
+
## Configuration
|
|
58
166
|
|
|
59
|
-
|
|
60
|
-
import { dateField } from "@nexload-sdk/payload-fields";
|
|
167
|
+
`payloadFieldsPlugin(options)` accepts:
|
|
61
168
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
169
|
+
| Option | Type | Default | Description |
|
|
170
|
+
| --- | --- | --- | --- |
|
|
171
|
+
| `slugGenerators` | `Record<string, SlugGenerator>` | `undefined` | Named async slug generators invoked by the plugin's slug endpoint |
|
|
172
|
+
| `generateSlugAccess` | `SlugGenerationAccess` | `undefined` | Access predicate `{ req } => boolean \| Promise<boolean>` for slug generation |
|
|
66
173
|
|
|
67
|
-
|
|
174
|
+
The plugin sets `slug: "nexload-fields"` and `order: 900` (`PAYLOAD_FIELDS_PLUGIN_ORDER`).
|
|
68
175
|
|
|
69
|
-
|
|
176
|
+
## Runtime and compatibility
|
|
70
177
|
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
178
|
+
- **Module format:** ESM-only (`type: "module"`).
|
|
179
|
+
- **Runtime:** Field factories and `payloadFieldsPlugin` run in Node.js / Payload config. Admin components under `./admin/*` are React 19 `"use client"` components.
|
|
180
|
+
- **Payload version:** `payload` and `@payloadcms/ui` `>=3.85.0 <4.0.0` with React 19.
|
|
181
|
+
- **Bilingual validation:** Errors follow `req.i18n.language` / `useTranslation()` (`fa*` receives Persian; all other locales receive English).
|
|
74
182
|
|
|
75
|
-
|
|
76
|
-
import { slugField } from "@nexload-sdk/payload-fields";
|
|
183
|
+
## Caveats
|
|
77
184
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
]
|
|
82
|
-
|
|
185
|
+
> [!CAUTION]
|
|
186
|
+
> `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`.
|
|
187
|
+
|
|
188
|
+
> [!WARNING]
|
|
189
|
+
> `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).
|
|
190
|
+
|
|
191
|
+
> [!NOTE]
|
|
192
|
+
> `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.
|
|
193
|
+
|
|
194
|
+
## Migration
|
|
195
|
+
|
|
196
|
+
### From 3.x to 4.0
|
|
197
|
+
|
|
198
|
+
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.
|
|
199
|
+
2. **Monorepo path:** Moved from `packages/refactoring/payload-fields` to `packages/payload-fields`.
|
|
200
|
+
3. **Unique slugs:** Resolve existing duplicate top-level slugs in your database before migrating, or pass `unique: false`.
|
|
201
|
+
4. **Jalali storage:** `dayOnly` and `monthOnly` dates store canonical noon in `timeZone` (`Asia/Tehran` by default).
|
|
202
|
+
5. **Bilingual messages:** Non-`fa` admin locales now receive English validation messages instead of Persian.
|
|
203
|
+
6. **Money strings:** Add `payloadFieldsPlugin()` if clients send money as strings.
|
|
204
|
+
7. **Import map:** Run `pnpm payload generate:importmap` after upgrading to refresh Admin component paths.
|
|
205
|
+
|
|
206
|
+
## Related packages
|
|
207
|
+
|
|
208
|
+
- [persian](../persian/README.md) — Core Persian/Iranian normalization and validation primitives
|
|
209
|
+
- [payload-schema](../payload-schema/README.md) — Canonical entity definitions used by `./schema`
|
|
210
|
+
- [payload-preset](../payload-preset/README.md) — Composed preset that includes `payloadFieldsPlugin()`
|
|
83
211
|
|
|
84
|
-
##
|
|
212
|
+
## License
|
|
85
213
|
|
|
86
|
-
|
|
87
|
-
- Styles are bundled from package submodules (`date/index.scss`, `slug/index.scss`).
|
|
214
|
+
MIT
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GroupField } from "payload";
|
|
2
|
+
export type IranAddressFieldOptions = {
|
|
3
|
+
name?: string;
|
|
4
|
+
label?: {
|
|
5
|
+
fa: string;
|
|
6
|
+
en: string;
|
|
7
|
+
};
|
|
8
|
+
required?: boolean;
|
|
9
|
+
recipient?: boolean;
|
|
10
|
+
overrides?: Partial<GroupField>;
|
|
11
|
+
};
|
|
12
|
+
export declare function iranAddressField(options?: IranAddressFieldOptions): GroupField;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/address/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,UAAU,EAAmD,MAAM,SAAS,CAAC;AAQlG,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACjC,CAAC;AAEF,wBAAgB,gBAAgB,CAAE,OAAO,GAAE,uBAA4B,GAAG,UAAU,CA0EnF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DefaultCellComponentProps } from "payload";
|
|
2
|
+
import type { ValidatedTextKind } from "../internal/validated-text";
|
|
3
|
+
export declare const FormattedCell: ({ kind, ...props }: DefaultCellComponentProps & {
|
|
4
|
+
kind: ValidatedTextKind;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=formatted-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatted-cell.d.ts","sourceRoot":"","sources":["../../src/admin/formatted-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAOzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,eAAO,MAAM,aAAa,GAAI,oBAAoB,yBAAyB,GAAG;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,4CAMxG,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @nexload-sdk/payload-fields v4.0.0 (build 2026-11-25T11:31:43.661Z)
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/admin/formatted-cell.tsx
|
|
5
|
+
import { DefaultCell } from "@payloadcms/ui";
|
|
6
|
+
import { formatCardNumber, formatSheba } from "@nexload-sdk/persian/bank";
|
|
7
|
+
import { formatIranMobile } from "@nexload-sdk/persian/mobile";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var FormattedCell = ({ kind, ...props }) => {
|
|
10
|
+
const { cellData } = props;
|
|
11
|
+
const value = cellData === null || cellData === void 0 || cellData === "" ? "" : String(cellData);
|
|
12
|
+
const formatted = !value ? "\u2014" : kind === "mobile" ? formatIranMobile(value) : kind === "card" ? formatCardNumber(value) : kind === "sheba" ? formatSheba(value) : value;
|
|
13
|
+
return /* @__PURE__ */ jsx(DefaultCell, { ...props, cellData: formatted ?? value });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
FormattedCell
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=formatted-cell.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/admin/formatted-cell.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport type { DefaultCellComponentProps } from \"payload\";\n\nimport { DefaultCell } from \"@payloadcms/ui\";\n\nimport { formatCardNumber, formatSheba } from \"@nexload-sdk/persian/bank\";\nimport { formatIranMobile } from \"@nexload-sdk/persian/mobile\";\n\nimport type { ValidatedTextKind } from \"../internal/validated-text\";\n\nexport const FormattedCell = ({ kind, ...props }: DefaultCellComponentProps & { kind: ValidatedTextKind }) => {\n const { cellData, } = props;\n const value = cellData === null || cellData === undefined || cellData === \"\" ? \"\" : String(cellData);\n const formatted = !value ? \"\u2014\" : kind === \"mobile\" ? formatIranMobile(value) : kind === \"card\" ? formatCardNumber(value) : kind === \"sheba\" ? formatSheba(value) : value;\n\n return <DefaultCell {...props} cellData={formatted ?? value} />;\n};\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,SAAS,mBAAmB;AAE5B,SAAS,kBAAkB,mBAAmB;AAC9C,SAAS,wBAAwB;AASxB;AALF,IAAM,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,MAA+D;AAC5G,QAAM,EAAE,SAAU,IAAI;AACtB,QAAM,QAAQ,aAAa,QAAQ,aAAa,UAAa,aAAa,KAAK,KAAK,OAAO,QAAQ;AACnG,QAAM,YAAY,CAAC,QAAQ,WAAM,SAAS,WAAW,iBAAiB,KAAK,IAAI,SAAS,SAAS,iBAAiB,KAAK,IAAI,SAAS,UAAU,YAAY,KAAK,IAAI;AAEnK,SAAO,oBAAC,eAAa,GAAG,OAAO,UAAU,aAAa,OAAO;AAC/D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DateFieldClient, DefaultCellComponentProps } from "payload";
|
|
2
|
+
import { type JalaliDateDisplayOptions, type JalaliDateValue } from "../date/format-date";
|
|
3
|
+
export declare const JalaliDateCell: ({ display, ...props }: DefaultCellComponentProps<DateFieldClient, JalaliDateValue> & {
|
|
4
|
+
display?: JalaliDateDisplayOptions;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=jalali-date-cell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jalali-date-cell.d.ts","sourceRoot":"","sources":["../../src/admin/jalali-date-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAI1E,OAAO,EAAoB,KAAK,wBAAwB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE5G,eAAO,MAAM,cAAc,GAAI,uBAG5B,yBAAyB,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,wBAAwB,CAAA;CAAE,4CAEtG,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @nexload-sdk/payload-fields v4.0.0 (build 2026-11-25T11:31:43.661Z)
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/admin/jalali-date-cell.tsx
|
|
5
|
+
import { DefaultCell } from "@payloadcms/ui";
|
|
6
|
+
|
|
7
|
+
// src/date/format-date.ts
|
|
8
|
+
import { formatJalali, TEHRAN_TIME_ZONE } from "@nexload-sdk/persian/date";
|
|
9
|
+
function formatJalaliDate(value, options = {}) {
|
|
10
|
+
return formatJalali(value, {
|
|
11
|
+
format: options.dateStyle === "short" ? "short" : options.dateStyle === "long" || options.dateStyle === "full" ? "long" : "medium",
|
|
12
|
+
time: options.timeStyle,
|
|
13
|
+
digits: options.digits,
|
|
14
|
+
timeZone: options.timeZone ?? TEHRAN_TIME_ZONE
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/admin/jalali-date-cell.tsx
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var JalaliDateCell = ({
|
|
21
|
+
display,
|
|
22
|
+
...props
|
|
23
|
+
}) => /* @__PURE__ */ jsx(DefaultCell, { ...props, cellData: formatJalaliDate(props.cellData, display) ?? "\u2014" });
|
|
24
|
+
export {
|
|
25
|
+
JalaliDateCell
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=jalali-date-cell.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/admin/jalali-date-cell.tsx", "../../src/date/format-date.ts"],
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport type { DateFieldClient, DefaultCellComponentProps } from \"payload\";\n\nimport { DefaultCell } from \"@payloadcms/ui\";\n\nimport { formatJalaliDate, type JalaliDateDisplayOptions, type JalaliDateValue } from \"../date/format-date\";\n\nexport const JalaliDateCell = ({\n display,\n ...props\n}: DefaultCellComponentProps<DateFieldClient, JalaliDateValue> & { display?: JalaliDateDisplayOptions }) => (\n <DefaultCell {...props} cellData={formatJalaliDate(props.cellData, display) ?? \"\u2014\"} />\n);\n", "import { formatJalali, TEHRAN_TIME_ZONE } from \"@nexload-sdk/persian/date\";\n\nexport type JalaliDateValue = Date | string | number | null | undefined;\nexport type JalaliDateDisplayOptions = {\n dateStyle?: \"short\" | \"medium\" | \"long\" | \"full\"\n timeStyle?: \"short\" | \"medium\"\n digits?: \"persian\" | \"latin\"\n timeZone?: string\n};\n\nexport function formatJalaliDate (\n value: JalaliDateValue, options: JalaliDateDisplayOptions = {}\n): string | null {\n return formatJalali(value, {\n format: options.dateStyle === \"short\" ? \"short\" : options.dateStyle === \"long\" || options.dateStyle === \"full\" ? \"long\" : \"medium\",\n time: options.timeStyle,\n digits: options.digits,\n timeZone: options.timeZone ?? TEHRAN_TIME_ZONE,\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAIA,SAAS,mBAAmB;;;ACJ5B,SAAS,cAAc,wBAAwB;AAUxC,SAAS,iBACd,OAAwB,UAAoC,CAAC,GAC9C;AACf,SAAO,aAAa,OAAO;AAAA,IACzB,QAAQ,QAAQ,cAAc,UAAU,UAAU,QAAQ,cAAc,UAAU,QAAQ,cAAc,SAAS,SAAS;AAAA,IAC1H,MAAM,QAAQ;AAAA,IACd,QAAQ,QAAQ;AAAA,IAChB,UAAU,QAAQ,YAAY;AAAA,EAChC,CAAC;AACH;;;ADPE;AAJK,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA,GAAG;AACL,MACE,oBAAC,eAAa,GAAG,OAAO,UAAU,iBAAiB,MAAM,UAAU,OAAO,KAAK,UAAK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DateFieldClientProps } from "payload";
|
|
2
|
+
import "react-day-picker/style.css";
|
|
3
|
+
import type { JalaliPickerAppearance } from "../date/picker-types";
|
|
4
|
+
import { type JalaliDateDisplayOptions } from "../date/format-date";
|
|
5
|
+
type Props = {
|
|
6
|
+
appearance: JalaliPickerAppearance;
|
|
7
|
+
display: JalaliDateDisplayOptions;
|
|
8
|
+
timeZone?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const JalaliDateFieldComponent: ({ field, path: providedPath, appearance, display, timeZone, readOnly, }: DateFieldClientProps & Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=jalali-date-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jalali-date-field.d.ts","sourceRoot":"","sources":["../../src/admin/jalali-date-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAUpD,OAAO,4BAA4B,CAAC;AAYpC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAoB,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAItF,KAAK,KAAK,GAAG;IACX,UAAU,EAAE,sBAAsB,CAAA;IAClC,OAAO,EAAE,wBAAwB,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC;AA0BF,eAAO,MAAM,wBAAwB,GAAI,yEAEtC,oBAAoB,GAAG,KAAK,4CAiG9B,CAAC"}
|