@nexload-sdk/payload-fields 2.0.0 → 3.1.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.
Files changed (82) hide show
  1. package/README.md +15 -67
  2. package/dist/admin/jalali-date-cell.cjs +58 -0
  3. package/dist/admin/jalali-date-cell.cjs.map +7 -0
  4. package/dist/admin/jalali-date-cell.d.ts +6 -0
  5. package/dist/admin/jalali-date-cell.d.ts.map +1 -0
  6. package/dist/admin/jalali-date-cell.mjs +32 -0
  7. package/dist/admin/jalali-date-cell.mjs.map +7 -0
  8. package/dist/admin/jalali-date-field.cjs +159 -0
  9. package/dist/admin/jalali-date-field.cjs.map +7 -0
  10. package/dist/admin/jalali-date-field.d.ts +11 -0
  11. package/dist/admin/jalali-date-field.d.ts.map +1 -0
  12. package/dist/admin/jalali-date-field.mjs +135 -0
  13. package/dist/admin/jalali-date-field.mjs.map +7 -0
  14. package/dist/admin/jalali-picker-value.cjs +42 -0
  15. package/dist/admin/jalali-picker-value.cjs.map +7 -0
  16. package/dist/admin/jalali-picker-value.d.ts +3 -0
  17. package/dist/admin/jalali-picker-value.d.ts.map +1 -0
  18. package/dist/admin/jalali-picker-value.mjs +18 -0
  19. package/dist/admin/jalali-picker-value.mjs.map +7 -0
  20. package/dist/admin/money-field.cjs +146 -0
  21. package/dist/admin/money-field.cjs.map +7 -0
  22. package/dist/admin/money-field.d.ts +10 -0
  23. package/dist/admin/money-field.d.ts.map +1 -0
  24. package/dist/admin/money-field.mjs +122 -0
  25. package/dist/admin/money-field.mjs.map +7 -0
  26. package/dist/admin/slug-field.cjs +135 -0
  27. package/dist/admin/slug-field.cjs.map +7 -0
  28. package/dist/admin/slug-field.d.ts +9 -0
  29. package/dist/admin/slug-field.d.ts.map +1 -0
  30. package/dist/admin/slug-field.mjs +115 -0
  31. package/dist/admin/slug-field.mjs.map +7 -0
  32. package/dist/date/format-date.d.ts +8 -1
  33. package/dist/date/format-date.d.ts.map +1 -1
  34. package/dist/date/index.cjs +117 -0
  35. package/dist/date/index.cjs.map +7 -0
  36. package/dist/date/index.d.ts +23 -4
  37. package/dist/date/index.d.ts.map +1 -1
  38. package/dist/date/index.mjs +86 -0
  39. package/dist/date/index.mjs.map +7 -0
  40. package/dist/date/picker-types.d.ts +2 -0
  41. package/dist/date/picker-types.d.ts.map +1 -0
  42. package/dist/index.cjs +411 -113
  43. package/dist/index.cjs.map +4 -4
  44. package/dist/index.d.ts +4 -4
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.mjs +394 -119
  47. package/dist/index.mjs.map +4 -4
  48. package/dist/money/index.cjs +147 -0
  49. package/dist/money/index.cjs.map +7 -0
  50. package/dist/money/index.d.ts +29 -0
  51. package/dist/money/index.d.ts.map +1 -0
  52. package/dist/money/index.mjs +117 -0
  53. package/dist/money/index.mjs.map +7 -0
  54. package/dist/plugin.d.ts +16 -0
  55. package/dist/plugin.d.ts.map +1 -0
  56. package/dist/slug/format-slug.d.ts +8 -2
  57. package/dist/slug/format-slug.d.ts.map +1 -1
  58. package/dist/slug/index.cjs +183 -0
  59. package/dist/slug/index.cjs.map +7 -0
  60. package/dist/slug/index.d.ts +12 -5
  61. package/dist/slug/index.d.ts.map +1 -1
  62. package/dist/slug/index.mjs +154 -0
  63. package/dist/slug/index.mjs.map +7 -0
  64. package/package.json +45 -30
  65. package/dist/date/date-cell.cjs +0 -60
  66. package/dist/date/date-cell.cjs.map +0 -7
  67. package/dist/date/date-cell.d.ts +0 -7
  68. package/dist/date/date-cell.d.ts.map +0 -1
  69. package/dist/date/date-cell.mjs +0 -34
  70. package/dist/date/date-cell.mjs.map +0 -7
  71. package/dist/date/date-picker.cjs +0 -221
  72. package/dist/date/date-picker.cjs.map +0 -7
  73. package/dist/date/date-picker.d.ts +0 -5
  74. package/dist/date/date-picker.d.ts.map +0 -1
  75. package/dist/date/date-picker.mjs +0 -197
  76. package/dist/date/date-picker.mjs.map +0 -7
  77. package/dist/slug/slug-field.cjs +0 -246
  78. package/dist/slug/slug-field.cjs.map +0 -7
  79. package/dist/slug/slug-field.d.ts +0 -10
  80. package/dist/slug/slug-field.d.ts.map +0 -1
  81. package/dist/slug/slug-field.mjs +0 -228
  82. package/dist/slug/slug-field.mjs.map +0 -7
package/dist/index.mjs CHANGED
@@ -1,150 +1,425 @@
1
- // @nexload-sdk/payload-fields v1.0.6 (build 2026-02-24T01:57:28.637Z)
2
-
3
- // src/index.ts
4
- import {
5
- EXPERIMENTAL_TableFeature,
6
- HorizontalRuleFeature,
7
- UploadFeature,
8
- FixedToolbarFeature,
9
- HeadingFeature,
10
- lexicalEditor,
11
- RelationshipFeature
12
- } from "@payloadcms/richtext-lexical";
13
-
14
- // src/date/format-date.ts
15
- import { format as formatJalali } from "date-fns-jalali";
16
- function formatDate(_date) {
17
- if (!_date) return "";
18
- const date = typeof _date === "string" ? new Date(_date) : _date;
19
- let formatted;
20
- try {
21
- formatted = formatJalali(
22
- date,
23
- "EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm"
24
- );
25
- } catch (err) {
26
- console.error(
27
- "error formatting date:",
28
- err
29
- );
30
- formatted = date.toLocaleDateString("fa-IR");
31
- }
32
- return formatted;
33
- }
34
-
35
- // src/date/index.ts
36
- var dateField = (overrides = {
37
- type: "date",
38
- name: "date"
39
- }) => {
40
- const dateField2 = {
41
- index: true,
42
- label: "\u062A\u0627\u0631\u06CC\u062E",
43
- ...overrides || {},
44
- admin: {
45
- position: "sidebar",
46
- ...overrides?.admin || {},
47
- components: {
48
- Cell: { path: "@nexload-sdk/payload-fields/date/date-cell#DateCell" },
49
- Field: { path: "@nexload-sdk/payload-fields/date/date-picker#DatePicker" }
50
- }
51
- }
52
- };
53
- return [dateField2];
54
- };
1
+ // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:56.848Z)
55
2
 
56
3
  // src/slug/format-slug.ts
57
- function formatSlug(val) {
58
- const formatted = val?.replace(
59
- / /g,
4
+ var persianDigits = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
5
+ var arabicDigits = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
6
+ function normalizeDigits(value) {
7
+ return value.replace(
8
+ /[۰-۹٠-٩]/g,
9
+ (digit) => {
10
+ const index = persianDigits.indexOf(digit);
11
+ return String(index >= 0 ? index : arabicDigits.indexOf(digit));
12
+ }
13
+ );
14
+ }
15
+ function getPath(value, path) {
16
+ return path.split(".").reduce(
17
+ (current, key) => {
18
+ if (current && typeof current === "object") return current[key];
19
+ return void 0;
20
+ },
21
+ value
22
+ );
23
+ }
24
+ function hasPath(value, path) {
25
+ return path.split(".").every((key) => {
26
+ if (!value || typeof value !== "object" || !(key in value)) return false;
27
+ value = value[key];
28
+ return true;
29
+ });
30
+ }
31
+ function formatSlug(value) {
32
+ return normalizeDigits(value.normalize("NFKC")).replace(
33
+ /[يى]/g,
34
+ "\u06CC"
35
+ ).replace(
36
+ /ك/g,
37
+ "\u06A9"
38
+ ).replace(
39
+ /[\u064B-\u065F\u0670]/g,
40
+ ""
41
+ ).replace(
42
+ /[\s_]+/g,
43
+ "-"
44
+ ).replace(
45
+ /[^\p{L}\p{N}-]+/gu,
46
+ ""
47
+ ).replace(
48
+ /-+/g,
60
49
  "-"
61
50
  ).replace(
62
- /[^\w-]+/g,
51
+ /^-+|-+$/g,
63
52
  ""
64
- ).toLowerCase();
65
- return formatted;
53
+ );
66
54
  }
67
- var formatSlugHook = (fallback) => ({ data, operation, value }) => {
68
- if (typeof value === "string") {
69
- return formatSlug(value);
55
+ var formatSlugHook = (options) => ({
56
+ data,
57
+ operation,
58
+ originalDoc,
59
+ siblingData,
60
+ previousSiblingDoc,
61
+ value
62
+ }) => {
63
+ const lock = siblingData?.[options.lockName] ?? data?.[options.lockName];
64
+ const previousSlug = previousSiblingDoc?.[options.name] ?? originalDoc?.[options.name];
65
+ const sourceChanged = hasPath(
66
+ data,
67
+ options.source
68
+ ) && getPath(
69
+ data,
70
+ options.source
71
+ ) !== getPath(
72
+ originalDoc,
73
+ options.source
74
+ );
75
+ const source = hasPath(
76
+ data,
77
+ options.source
78
+ ) ? getPath(
79
+ data,
80
+ options.source
81
+ ) : getPath(
82
+ originalDoc,
83
+ options.source
84
+ );
85
+ if (lock !== false && typeof source === "string" && source.trim() && (operation === "create" || options.regenerateOnSourceChange && sourceChanged)) {
86
+ return formatSlug(source);
70
87
  }
71
- if (operation === "create" || data?.slug === void 0) {
72
- const fallbackData = data?.[fallback];
73
- if (typeof fallbackData === "string") {
74
- return formatSlug(fallbackData);
75
- }
88
+ if (operation === "update" && lock !== false && sourceChanged && !source && previousSlug !== void 0) {
89
+ return previousSlug;
76
90
  }
91
+ if (lock !== false && operation === "update" && previousSlug !== void 0) return previousSlug;
92
+ if (typeof value === "string") return formatSlug(value);
77
93
  return value;
78
94
  };
79
95
 
80
96
  // src/slug/index.ts
81
- var slugField = (fieldToUse = "title", overrides = {}) => {
82
- const { slugOverrides, checkboxOverrides } = overrides;
83
- const checkBoxField = {
84
- name: "slugLock",
97
+ function slugField(options = {}) {
98
+ const name = options.name ?? "slug";
99
+ const lockName = options.lockName ?? `${name}Lock`;
100
+ const source = options.source ?? "title";
101
+ const localized = options.overrides?.slug?.localized === true;
102
+ if (options.overrides?.slug?.name && options.overrides.slug.name !== name) throw new Error("Slug field name is protected.");
103
+ if (options.overrides?.lock?.name && options.overrides.lock.name !== lockName) throw new Error("Slug lock name is protected.");
104
+ if (options.overrides?.lock?.localized !== void 0 && options.overrides.lock.localized !== localized) throw new Error("Slug lock localization must match slug localization.");
105
+ if (options.overrides?.slug?.type && options.overrides.slug.type !== "text") throw new Error("Slug field type is protected.");
106
+ if (options.overrides?.lock?.type && options.overrides.lock.type !== "checkbox") throw new Error("Slug lock type is protected.");
107
+ const slugOverrides = options.overrides?.slug ?? {};
108
+ const lockOverrides = options.overrides?.lock ?? {};
109
+ const consumerHooks = slugOverrides.hooks?.beforeValidate ?? [];
110
+ const slug = {
111
+ ...slugOverrides,
112
+ name,
113
+ type: "text",
114
+ index: slugOverrides.index ?? true,
115
+ localized,
116
+ admin: {
117
+ ...slugOverrides.admin,
118
+ position: slugOverrides.admin?.position ?? "sidebar",
119
+ components: {
120
+ ...slugOverrides.admin?.components,
121
+ Field: {
122
+ path: "@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent",
123
+ clientProps: { source, lockName, generator: options.generator }
124
+ }
125
+ }
126
+ },
127
+ custom: { ...slugOverrides.custom, nexload: { ...slugOverrides.custom?.nexload, slug: { source, lockName, generator: options.generator } } },
128
+ hooks: {
129
+ ...slugOverrides.hooks,
130
+ beforeValidate: [
131
+ ...consumerHooks,
132
+ formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true })
133
+ ]
134
+ }
135
+ };
136
+ const lock = {
137
+ ...lockOverrides,
138
+ name: lockName,
85
139
  type: "checkbox",
140
+ localized,
86
141
  defaultValue: true,
142
+ admin: { ...lockOverrides.admin, hidden: true, position: lockOverrides.admin?.position ?? "sidebar" }
143
+ };
144
+ return [
145
+ slug,
146
+ lock
147
+ ];
148
+ }
149
+
150
+ // src/date/format-date.ts
151
+ function formatJalaliDate(value, options = {}) {
152
+ if (value === null || value === void 0) return null;
153
+ const date = value instanceof Date ? value : new Date(value);
154
+ if (Number.isNaN(date.getTime())) return null;
155
+ const locale = options.digits === "latin" ? "fa-IR-u-ca-persian-nu-latn" : "fa-IR-u-ca-persian";
156
+ return new Intl.DateTimeFormat(
157
+ locale,
158
+ {
159
+ dateStyle: options.dateStyle ?? "medium",
160
+ ...options.timeStyle ? { timeStyle: options.timeStyle } : {},
161
+ ...options.timeZone ? { timeZone: options.timeZone } : {}
162
+ }
163
+ ).format(date);
164
+ }
165
+
166
+ // src/date/index.ts
167
+ function jalaliDateField(options) {
168
+ const overrides = options.overrides ?? {};
169
+ if (overrides.name && overrides.name !== options.name) throw new Error("Jalali date field name is protected.");
170
+ if (overrides.type && overrides.type !== "date") throw new Error("Jalali date field type is protected.");
171
+ const appearance = options.pickerAppearance ?? "dayOnly";
172
+ const display = {
173
+ digits: "persian",
174
+ dateStyle: "medium",
175
+ ...appearance === "dayAndTime" || appearance === "timeOnly" ? { timeStyle: "short" } : {},
176
+ ...options.display
177
+ };
178
+ return {
179
+ ...overrides,
180
+ name: options.name,
181
+ type: "date",
87
182
  admin: {
88
- hidden: true,
89
- position: "sidebar"
183
+ ...overrides.admin,
184
+ date: { ...overrides.admin?.date, pickerAppearance: appearance },
185
+ components: {
186
+ ...overrides.admin?.components,
187
+ Field: { path: "@nexload-sdk/payload-fields/admin/jalali-date-field#JalaliDateFieldComponent", clientProps: { appearance, display } },
188
+ Cell: { path: "@nexload-sdk/payload-fields/admin/jalali-date-cell#JalaliDateCell", clientProps: { display } }
189
+ }
90
190
  },
91
- ...checkboxOverrides
191
+ custom: { ...overrides.custom, nexload: { ...overrides.custom?.nexload, jalaliDate: { appearance, display } } }
92
192
  };
93
- const slugField2 = {
94
- name: "slug",
95
- type: "text",
96
- index: true,
97
- label: "\u0627\u0633\u0644\u0627\u06AF",
98
- ...slugOverrides || {},
99
- hooks: {
100
- // Kept this in for hook or API based updates
101
- beforeValidate: [formatSlugHook(fieldToUse)]
102
- },
193
+ }
194
+ function withJalaliTimestamps(fields, options = {}) {
195
+ const output = [...fields];
196
+ const add = (name, source, override) => {
197
+ if (output.some((field) => "name" in field && field.name === name)) throw new Error(`Duplicate Jalali timestamp field: ${name}`);
198
+ output.push({
199
+ ...override,
200
+ name,
201
+ type: "text",
202
+ virtual: true,
203
+ admin: { ...override?.admin, readOnly: true },
204
+ hooks: {
205
+ ...override?.hooks,
206
+ afterRead: [
207
+ ...override?.hooks?.afterRead ?? [],
208
+ ({ siblingData }) => formatJalaliDate(
209
+ siblingData?.[source],
210
+ options.display
211
+ )
212
+ ]
213
+ }
214
+ });
215
+ };
216
+ if (options.createdAt !== false) add(
217
+ "createdAtJalali",
218
+ "createdAt",
219
+ options.overrides?.createdAt
220
+ );
221
+ if (options.updatedAt !== false) add(
222
+ "updatedAtJalali",
223
+ "updatedAt",
224
+ options.overrides?.updatedAt
225
+ );
226
+ return output;
227
+ }
228
+
229
+ // src/money/index.ts
230
+ var IRR = { code: "IRR", label: "\u0631\u06CC\u0627\u0644", fractionDigits: 0 };
231
+ var IRT = { code: "IRT", label: "\u062A\u0648\u0645\u0627\u0646", fractionDigits: 0 };
232
+ function resolveCurrency(currency) {
233
+ const result = currency === "IRR" ? IRR : currency === "IRT" ? IRT : currency;
234
+ if (!result.code.trim() || !result.label.trim() || !Number.isInteger(result.fractionDigits) || result.fractionDigits < 0 || result.fractionDigits > 20) throw new Error("Invalid money currency definition.");
235
+ return result;
236
+ }
237
+ function normalizedNumber(value) {
238
+ const persian = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
239
+ const arabic = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
240
+ return value.trim().replace(
241
+ /[۰-۹٠-٩]/g,
242
+ (digit) => String(Math.max(
243
+ persian.indexOf(digit),
244
+ arabic.indexOf(digit)
245
+ ) % 10)
246
+ ).replace(
247
+ /[٬,\s]/g,
248
+ ""
249
+ ).replace(
250
+ /٫/g,
251
+ "."
252
+ );
253
+ }
254
+ function parseMoneyToMinorUnits(input, currency) {
255
+ const definition = resolveCurrency(currency);
256
+ const value = normalizedNumber(input);
257
+ if (!/^-?\d+(?:\.\d+)?$/.test(value)) throw new TypeError("Invalid money input.");
258
+ const negative = value.startsWith("-");
259
+ const [
260
+ whole,
261
+ fraction = ""
262
+ ] = (negative ? value.slice(1) : value).split(".");
263
+ if (fraction.length > definition.fractionDigits) throw new RangeError("Money input has unsupported precision.");
264
+ const digits = `${whole}${fraction.padEnd(
265
+ definition.fractionDigits,
266
+ "0"
267
+ )}`.replace(
268
+ /^0+(?=\d)/,
269
+ ""
270
+ ) || "0";
271
+ const minor = Number(`${negative ? "-" : ""}${digits}`);
272
+ if (!Number.isSafeInteger(minor)) throw new RangeError("Money value is outside the safe integer range.");
273
+ return minor;
274
+ }
275
+ function formatMoney(value, currency, display = {}) {
276
+ if (value === null || value === void 0) return null;
277
+ if (!Number.isSafeInteger(value)) throw new RangeError("Money value is outside the safe integer range.");
278
+ const definition = resolveCurrency(currency);
279
+ const locale = display.locale ?? (display.digits === "latin" ? "fa-IR-u-nu-latn" : "fa-IR");
280
+ const major = value / 10 ** definition.fractionDigits;
281
+ const formatted = new Intl.NumberFormat(
282
+ locale,
283
+ { useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits }
284
+ ).format(major);
285
+ return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;
286
+ }
287
+ function moneyField(options) {
288
+ const overrides = options.overrides ?? {};
289
+ if (overrides.name && overrides.name !== options.name) throw new Error("Money field name is protected.");
290
+ if (overrides.type && overrides.type !== "number") throw new Error("Money field type is protected.");
291
+ const currency = resolveCurrency(options.currency);
292
+ if (options.minMinorUnits !== void 0 && (!Number.isSafeInteger(options.minMinorUnits) || options.maxMinorUnits !== void 0 && options.minMinorUnits > options.maxMinorUnits)) throw new Error("Invalid money bounds.");
293
+ if (options.maxMinorUnits !== void 0 && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error("Invalid money bounds.");
294
+ const consumerValidate = overrides.validate;
295
+ const validate = (value, args) => {
296
+ if (value === null || value === void 0 || value === "") return args?.required ? "\u0648\u0627\u0631\u062F \u06A9\u0631\u062F\u0646 \u0645\u0628\u0644\u063A \u0627\u0644\u0632\u0627\u0645\u06CC \u0627\u0633\u062A." : true;
297
+ if (typeof value !== "number" || !Number.isSafeInteger(value)) return "\u0645\u0628\u0644\u063A \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F.";
298
+ if (!options.allowNegative && value < 0) return "\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.";
299
+ if (options.minMinorUnits !== void 0 && value < options.minMinorUnits) return "\u0645\u0628\u0644\u063A \u06A9\u0645\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.";
300
+ if (options.maxMinorUnits !== void 0 && value > options.maxMinorUnits) return "\u0645\u0628\u0644\u063A \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.";
301
+ return consumerValidate ? consumerValidate(
302
+ value,
303
+ args
304
+ ) : true;
305
+ };
306
+ const display = {
307
+ locale: "fa-IR",
308
+ digits: "persian",
309
+ grouping: true,
310
+ showCurrency: true,
311
+ ...options.display
312
+ };
313
+ return {
314
+ ...overrides,
315
+ name: options.name,
316
+ type: "number",
317
+ validate,
103
318
  admin: {
104
- position: "sidebar",
105
- ...slugOverrides?.admin || {},
319
+ ...overrides.admin,
106
320
  components: {
321
+ ...overrides.admin?.components,
107
322
  Field: {
108
- path: "@nexload-sdk/payload-fields/slug/slug-field#SlugComponent",
323
+ path: "@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent",
109
324
  clientProps: {
110
- fieldToUse,
111
- checkboxFieldPath: checkBoxField.name
325
+ currency,
326
+ display,
327
+ allowNegative: options.allowNegative ?? false
112
328
  }
113
329
  }
114
330
  }
115
- }
331
+ },
332
+ custom: { ...overrides.custom, nexload: { ...overrides.custom?.nexload, money: currency } }
116
333
  };
117
- return [slugField2, checkBoxField];
118
- };
334
+ }
119
335
 
120
- // src/index.ts
121
- var editor = lexicalEditor({
122
- admin: {
123
- hideInsertParagraphAtEnd: true,
124
- hideGutter: true
125
- },
126
- features: ({ defaultFeatures }) => {
127
- return [
128
- ...defaultFeatures,
129
- HeadingFeature({
130
- enabledHeadingSizes: ["h1", "h2", "h3", "h4"]
131
- }),
132
- FixedToolbarFeature({ applyToFocusedEditor: true }),
133
- HorizontalRuleFeature(),
134
- UploadFeature(),
135
- EXPERIMENTAL_TableFeature(),
136
- RelationshipFeature({
137
- enabledCollections: ["products", "articles"]
138
- })
139
- ];
140
- }
141
- });
336
+ // src/plugin.ts
337
+ function failure(code, message, status) {
338
+ return Response.json(
339
+ { error: { code, message } },
340
+ { status }
341
+ );
342
+ }
343
+ function payloadFieldsPlugin(options = {}) {
344
+ return (config) => ({
345
+ ...config,
346
+ endpoints: [
347
+ ...config.endpoints ?? [],
348
+ {
349
+ path: "/payload-fields/generate-slug",
350
+ method: "post",
351
+ handler: async (req) => {
352
+ if (!req.user) return failure(
353
+ "PAYLOAD_FIELDS_UNAUTHENTICATED",
354
+ "\u0628\u0631\u0627\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627\u06CC\u062F \u0648\u0627\u0631\u062F \u0634\u0648\u06CC\u062F.",
355
+ 401
356
+ );
357
+ if (options.generateSlugAccess && !await options.generateSlugAccess({ req })) return failure(
358
+ "PAYLOAD_FIELDS_FORBIDDEN",
359
+ "\u0627\u062C\u0627\u0632\u0647 \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0631\u0627 \u0646\u062F\u0627\u0631\u06CC\u062F.",
360
+ 403
361
+ );
362
+ let body;
363
+ try {
364
+ body = await req.json?.();
365
+ } catch {
366
+ return failure(
367
+ "PAYLOAD_FIELDS_INVALID_INPUT",
368
+ "\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
369
+ 400
370
+ );
371
+ }
372
+ if (!body || typeof body !== "object" || Array.isArray(body)) return failure(
373
+ "PAYLOAD_FIELDS_INVALID_INPUT",
374
+ "\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
375
+ 400
376
+ );
377
+ const input = body;
378
+ if (typeof input.generator !== "string" || typeof input.sourceValue !== "string" || input.currentSlug !== void 0 && typeof input.currentSlug !== "string") return failure(
379
+ "PAYLOAD_FIELDS_INVALID_INPUT",
380
+ "\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.",
381
+ 400
382
+ );
383
+ const generator = options.slugGenerators && Object.prototype.hasOwnProperty.call(
384
+ options.slugGenerators,
385
+ input.generator
386
+ ) ? options.slugGenerators[input.generator] : void 0;
387
+ if (!generator) return failure(
388
+ "PAYLOAD_FIELDS_GENERATOR_NOT_FOUND",
389
+ "\u062A\u0648\u0644\u06CC\u062F\u06A9\u0646\u0646\u062F\u0647 \u0627\u0633\u0644\u0627\u06AF \u067E\u06CC\u062F\u0627 \u0646\u0634\u062F.",
390
+ 404
391
+ );
392
+ try {
393
+ const result = await generator(
394
+ { sourceValue: input.sourceValue, currentSlug: input.currentSlug },
395
+ { req }
396
+ );
397
+ return Response.json({ slug: formatSlug(result) });
398
+ } catch {
399
+ return failure(
400
+ "PAYLOAD_FIELDS_GENERATION_FAILED",
401
+ "\u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627 \u062E\u0637\u0627 \u0645\u0648\u0627\u062C\u0647 \u0634\u062F.",
402
+ 500
403
+ );
404
+ }
405
+ }
406
+ }
407
+ ]
408
+ });
409
+ }
142
410
  export {
143
- dateField,
144
- editor,
145
- formatDate,
411
+ IRR,
412
+ IRT,
413
+ formatJalaliDate,
414
+ formatMoney,
146
415
  formatSlug,
147
416
  formatSlugHook,
148
- slugField
417
+ jalaliDateField,
418
+ moneyField,
419
+ parseMoneyToMinorUnits,
420
+ payloadFieldsPlugin,
421
+ resolveCurrency,
422
+ slugField,
423
+ withJalaliTimestamps
149
424
  };
150
425
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/date/format-date.ts", "../src/date/index.ts", "../src/slug/format-slug.ts", "../src/slug/index.ts"],
4
- "sourcesContent": ["import {\n EXPERIMENTAL_TableFeature,\n HorizontalRuleFeature,\n UploadFeature,\n FixedToolbarFeature,\n HeadingFeature,\n lexicalEditor,\n RelationshipFeature,\n} from \"@payloadcms/richtext-lexical\";\nimport { RichTextAdapterProvider } from \"payload\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const editor: RichTextAdapterProvider<any, any, any> = lexicalEditor({\n admin: {\n hideInsertParagraphAtEnd: true,\n hideGutter: true,\n },\n features: ({ defaultFeatures }) => {\n return [\n ...defaultFeatures,\n HeadingFeature({\n enabledHeadingSizes: [\"h1\", \"h2\", \"h3\", \"h4\"],\n }),\n FixedToolbarFeature({ applyToFocusedEditor: true }),\n HorizontalRuleFeature(),\n UploadFeature(),\n EXPERIMENTAL_TableFeature(),\n RelationshipFeature({\n enabledCollections: [\"products\", \"articles\"],\n }),\n ];\n },\n});\n\nexport * from './date';\nexport * from './slug';\n", "import { format as formatJalali } from \"date-fns-jalali\";\n\nexport function formatDate (_date?: Date | string): string {\n if (!_date) return \"\";\n\n const date = typeof _date === \"string\" ? new Date(_date) : _date;\n\n let formatted: string;\n try {\n formatted = formatJalali(\n date, \"EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm\"\n );\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n \"error formatting date:\", err\n );\n // if error, show ISO simple\n formatted = date.toLocaleDateString(\"fa-IR\");\n }\n\n return formatted;\n}\n", "import type { DateField } from \"payload\";\n\ntype Date = (overrides?: DateField) => [DateField];\n\nexport const dateField: Date = (overrides = {\n type: \"date\",\n name: \"date\",\n}) => {\n const dateField: DateField = {\n index: true,\n label: \"\u062A\u0627\u0631\u06CC\u062E\",\n ...(overrides || {}),\n admin: {\n position: \"sidebar\",\n ...(overrides?.admin || {}),\n components: {\n Cell: { path: \"@nexload-sdk/payload-fields/date/date-cell#DateCell\", },\n Field: { path: \"@nexload-sdk/payload-fields/date/date-picker#DatePicker\", },\n },\n },\n };\n\n return [dateField];\n};\n\nexport * from './format-date';", "import type { FieldHook } from \"payload\";\n\nexport function formatSlug (val: string): string | undefined {\n const formatted = val\n ?.replace(\n / /g, \"-\"\n )\n .replace(\n /[^\\w-]+/g, \"\"\n )\n .toLowerCase();\n\n return formatted;\n}\n\nexport const formatSlugHook\n = (fallback: string): FieldHook => ({ data, operation, value, }) => {\n if (typeof value === \"string\") {\n return formatSlug(value);\n }\n\n if (operation === \"create\" || data?.slug === undefined) {\n const fallbackData = data?.[fallback];\n\n if (typeof fallbackData === \"string\") {\n return formatSlug(fallbackData);\n }\n }\n\n return value;\n };\n", "import { formatSlugHook } from \"./format-slug\";\n\nimport type { CheckboxField, TextField } from \"payload\";\n\ntype Overrides = {\n slugOverrides?: Partial<TextField>;\n checkboxOverrides?: Partial<CheckboxField>;\n};\n\ntype Slug = (\n fieldToUse?: string,\n overrides?: Overrides\n) => [TextField, CheckboxField];\n\nexport const slugField: Slug = (fieldToUse = \"title\", overrides = {}) => {\n const { slugOverrides, checkboxOverrides } = overrides;\n\n const checkBoxField: CheckboxField = {\n name: \"slugLock\",\n type: \"checkbox\",\n defaultValue: true,\n admin: {\n hidden: true,\n position: \"sidebar\",\n },\n ...checkboxOverrides,\n };\n\n // @ts-expect-error - ts mismatch Partial<TextField> with TextField\n const slugField: TextField = {\n name: \"slug\",\n type: \"text\",\n index: true,\n label: \"\u0627\u0633\u0644\u0627\u06AF\",\n ...(slugOverrides || {}),\n hooks: {\n // Kept this in for hook or API based updates\n beforeValidate: [formatSlugHook(fieldToUse)],\n },\n admin: {\n position: \"sidebar\",\n ...(slugOverrides?.admin || {}),\n components: {\n Field: {\n path: \"@nexload-sdk/payload-fields/slug/slug-field#SlugComponent\",\n clientProps: {\n fieldToUse,\n checkboxFieldPath: checkBoxField.name,\n },\n },\n },\n },\n };\n\n return [slugField, checkBoxField];\n};\n\nexport * from \"./format-slug\";\n"],
5
- "mappings": ";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACRP,SAAS,UAAU,oBAAoB;AAEhC,SAAS,WAAY,OAA+B;AACzD,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,OAAO,OAAO,UAAU,WAAW,IAAI,KAAK,KAAK,IAAI;AAE3D,MAAI;AACJ,MAAI;AACF,gBAAY;AAAA,MACV;AAAA,MAAM;AAAA,IACR;AAAA,EACF,SAAS,KAAK;AAEZ,YAAQ;AAAA,MACN;AAAA,MAA0B;AAAA,IAC5B;AAEA,gBAAY,KAAK,mBAAmB,OAAO;AAAA,EAC7C;AAEA,SAAO;AACT;;;AClBO,IAAM,YAAkB,CAAC,YAAY;AAAA,EAC1C,MAAM;AAAA,EACN,MAAM;AACR,MAAM;AACJ,QAAMA,aAAuB;AAAA,IAC3B,OAAO;AAAA,IACP,OAAO;AAAA,IACP,GAAI,aAAa,CAAC;AAAA,IAClB,OAAO;AAAA,MACL,UAAU;AAAA,MACV,GAAI,WAAW,SAAS,CAAC;AAAA,MACzB,YAAY;AAAA,QACV,MAAM,EAAE,MAAM,sDAAuD;AAAA,QACrE,OAAO,EAAE,MAAM,0DAA2D;AAAA,MAC5E;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAACA,UAAS;AACnB;;;ACrBO,SAAS,WAAY,KAAiC;AAC3D,QAAM,YAAY,KACd;AAAA,IACA;AAAA,IAAM;AAAA,EACR,EACC;AAAA,IACC;AAAA,IAAY;AAAA,EACd,EACC,YAAY;AAEf,SAAO;AACT;AAEO,IAAM,iBACT,CAAC,aAAgC,CAAC,EAAE,MAAM,WAAW,MAAO,MAAM;AAClE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,WAAW,KAAK;A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B;AAAA,MACtB,cAAc;AAAA,MACd,0BAA0B;AAAA,MAC1B,oBAAoB;AAAA,QAClB,oBAAoB,CAAC,YAAY,UAAU;AAAA,MAC7C,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;",
6
- "names": ["dateField", "slugField"]
3
+ "sources": ["../src/slug/format-slug.ts", "../src/slug/index.ts", "../src/date/format-date.ts", "../src/date/index.ts", "../src/money/index.ts", "../src/plugin.ts"],
4
+ "sourcesContent": ["import type { FieldHook } from \"payload\";\n\nexport type SlugHookOptions = {\n name: string\n lockName: string\n source: string\n regenerateOnSourceChange: boolean\n};\n\nconst persianDigits = \"\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\";\nconst arabicDigits = \"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\";\n\nfunction normalizeDigits (value: string): string {\n return value.replace(\n /[\u06F0-\u06F9\u0660-\u0669]/g, (digit) => {\n const index = persianDigits.indexOf(digit);\n return String(index >= 0 ? index : arabicDigits.indexOf(digit));\n }\n );\n}\n\nfunction getPath (\n value: unknown, path: string\n): unknown {\n return path.split(\".\").reduce<unknown>(\n (\n current, key\n ) => {\n if (current && typeof current === \"object\") return (current as Record<string, unknown>)[key];\n return undefined;\n }, value\n );\n}\n\nfunction hasPath (\n value: unknown, path: string\n): boolean {\n return path.split(\".\").every((key) => {\n if (!value || typeof value !== \"object\" || !(key in value)) return false;\n value = (value as Record<string, unknown>)[key];\n return true;\n });\n}\n\nexport function formatSlug (value: string): string {\n return normalizeDigits(value.normalize(\"NFKC\"))\n .replace(\n /[\u064A\u0649]/g, \"\u06CC\"\n )\n .replace(\n /\u0643/g, \"\u06A9\"\n )\n .replace(\n /[\\u064B-\\u065F\\u0670]/g, \"\"\n )\n .replace(\n /[\\s_]+/g, \"-\"\n )\n .replace(\n /[^\\p{L}\\p{N}-]+/gu, \"\"\n )\n .replace(\n /-+/g, \"-\"\n )\n .replace(\n /^-+|-+$/g, \"\"\n );\n}\n\nexport const formatSlugHook = (options: SlugHookOptions): FieldHook => ({\n data,\n operation,\n originalDoc,\n siblingData,\n previousSiblingDoc,\n value,\n}) => {\n const lock = siblingData?.[options.lockName] ?? data?.[options.lockName];\n const previousSlug = previousSiblingDoc?.[options.name] ?? originalDoc?.[options.name];\n const sourceChanged = hasPath(\n data, options.source\n )\n && getPath(\n data, options.source\n ) !== getPath(\n originalDoc, options.source\n );\n const source = hasPath(\n data, options.source\n )\n ? getPath(\n data, options.source\n )\n : getPath(\n originalDoc, options.source\n );\n\n if (lock !== false && typeof source === \"string\" && source.trim() && (operation === \"create\" || (options.regenerateOnSourceChange && sourceChanged))) {\n return formatSlug(source);\n }\n\n if (operation === \"update\" && lock !== false && sourceChanged && !source && previousSlug !== undefined) {\n return previousSlug;\n }\n\n if (lock !== false && operation === \"update\" && previousSlug !== undefined) return previousSlug;\n if (typeof value === \"string\") return formatSlug(value);\n return value;\n};\n", "import { formatSlugHook } from \"./format-slug\";\n\nimport type { CheckboxField, TextField } from \"payload\";\n\nexport type SlugFieldOptions = {\n name?: string\n lockName?: string\n source?: string\n generator?: string\n regenerateOnSourceChange?: boolean\n overrides?: { slug?: Partial<TextField>, lock?: Partial<CheckboxField> }\n};\n\nexport type SlugFieldResult = readonly [TextField, CheckboxField];\n\nexport function slugField (options: SlugFieldOptions = {}): SlugFieldResult {\n const name = options.name ?? \"slug\";\n const lockName = options.lockName ?? `${name}Lock`;\n const source = options.source ?? \"title\";\n const localized = options.overrides?.slug?.localized === true;\n if (options.overrides?.slug?.name && options.overrides.slug.name !== name) throw new Error(\"Slug field name is protected.\");\n if (options.overrides?.lock?.name && options.overrides.lock.name !== lockName) throw new Error(\"Slug lock name is protected.\");\n if (options.overrides?.lock?.localized !== undefined && options.overrides.lock.localized !== localized) throw new Error(\"Slug lock localization must match slug localization.\");\n if (options.overrides?.slug?.type && options.overrides.slug.type !== \"text\") throw new Error(\"Slug field type is protected.\");\n if (options.overrides?.lock?.type && options.overrides.lock.type !== \"checkbox\") throw new Error(\"Slug lock type is protected.\");\n\n const slugOverrides = options.overrides?.slug ?? {};\n const lockOverrides = options.overrides?.lock ?? {};\n const consumerHooks = slugOverrides.hooks?.beforeValidate ?? [];\n const slug: TextField = {\n ...slugOverrides,\n name,\n type: \"text\",\n index: slugOverrides.index ?? true,\n localized,\n admin: {\n ...slugOverrides.admin,\n position: slugOverrides.admin?.position ?? \"sidebar\",\n components: {\n ...slugOverrides.admin?.components,\n Field: {\n path: \"@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent\",\n clientProps: { source, lockName, generator: options.generator, },\n },\n },\n },\n custom: { ...slugOverrides.custom, nexload: { ...(slugOverrides.custom?.nexload as object), slug: { source, lockName, generator: options.generator, }, }, },\n hooks: {\n ...slugOverrides.hooks, beforeValidate: [\n ...consumerHooks,\n formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true, })\n ],\n },\n } as TextField;\n const lock: CheckboxField = {\n ...lockOverrides,\n name: lockName,\n type: \"checkbox\",\n localized,\n defaultValue: true,\n admin: { ...lockOverrides.admin, hidden: true, position: lockOverrides.admin?.position ?? \"sidebar\", },\n } as CheckboxField;\n return [\n slug,\n lock\n ];\n}\n\nexport * from \"./format-slug\";\n", "export 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 if (value === null || value === undefined) return null;\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) return null;\n const locale = options.digits === \"latin\" ? \"fa-IR-u-ca-persian-nu-latn\" : \"fa-IR-u-ca-persian\";\n return new Intl.DateTimeFormat(\n locale, {\n dateStyle: options.dateStyle ?? \"medium\",\n ...(options.timeStyle ? { timeStyle: options.timeStyle, } : {}),\n ...(options.timeZone ? { timeZone: options.timeZone, } : {}),\n }\n ).format(date);\n}\n", "import { formatJalaliDate } from \"./format-date\";\n\nimport type { JalaliPickerAppearance } from \"./picker-types\";\nimport type { DateField, Field, TextField } from \"payload\";\n\nexport type { JalaliDateDisplayOptions, JalaliDateValue } from \"./format-date\";\nexport type { JalaliPickerAppearance } from \"./picker-types\";\nexport type JalaliDateFieldOptions = {\n name: string\n pickerAppearance?: JalaliPickerAppearance\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: Partial<DateField>\n};\nexport type JalaliTimestampsOptions = {\n createdAt?: boolean\n updatedAt?: boolean\n display?: import(\"./format-date\").JalaliDateDisplayOptions\n overrides?: { createdAt?: Partial<TextField>, updatedAt?: Partial<TextField> }\n};\n\nexport function jalaliDateField (options: JalaliDateFieldOptions): DateField {\n const overrides = options.overrides ?? {};\n if (overrides.name && overrides.name !== options.name) throw new Error(\"Jalali date field name is protected.\");\n if (overrides.type && overrides.type !== \"date\") throw new Error(\"Jalali date field type is protected.\");\n const appearance = options.pickerAppearance ?? \"dayOnly\";\n const display = {\n digits: \"persian\" as const,\n dateStyle: \"medium\" as const,\n ...(\n appearance === \"dayAndTime\" || appearance === \"timeOnly\"\n ? { timeStyle: \"short\" as const, }\n : {}\n ),\n ...options.display,\n };\n return {\n ...overrides,\n name: options.name,\n type: \"date\",\n admin: {\n ...overrides.admin,\n date: { ...overrides.admin?.date, pickerAppearance: appearance, },\n components: {\n ...overrides.admin?.components,\n Field: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-field#JalaliDateFieldComponent\", clientProps: { appearance, display, }, },\n Cell: { path: \"@nexload-sdk/payload-fields/admin/jalali-date-cell#JalaliDateCell\", clientProps: { display, }, },\n },\n },\n custom: { ...overrides.custom, nexload: { ...(overrides.custom?.nexload as object), jalaliDate: { appearance, display, }, }, },\n } as DateField;\n}\n\nexport function withJalaliTimestamps<T extends Field[]> (\n fields: T, options: JalaliTimestampsOptions = {}\n): Field[] {\n const output = [...fields];\n const add = (\n name: \"createdAtJalali\" | \"updatedAtJalali\", source: \"createdAt\" | \"updatedAt\", override?: Partial<TextField>\n ) => {\n if (output.some((field) => \"name\" in field && field.name === name)) throw new Error(`Duplicate Jalali timestamp field: ${name}`);\n output.push({\n ...override,\n name,\n type: \"text\",\n virtual: true,\n admin: { ...override?.admin, readOnly: true, },\n hooks: {\n ...override?.hooks, afterRead: [\n ...(override?.hooks?.afterRead ?? []),\n ({ siblingData, }) => formatJalaliDate(\n siblingData?.[source] as import(\"./format-date\").JalaliDateValue, options.display\n )\n ],\n },\n } as TextField);\n };\n if (options.createdAt !== false) add(\n \"createdAtJalali\", \"createdAt\", options.overrides?.createdAt\n );\n if (options.updatedAt !== false) add(\n \"updatedAtJalali\", \"updatedAt\", options.overrides?.updatedAt\n );\n return output;\n}\n\nexport { formatJalaliDate };\n", "import type { NumberField } from \"payload\";\n\nexport type MoneyCurrencyDefinition = {\n code: string\n label: string\n fractionDigits: number\n};\nexport type MoneyCurrency = \"IRR\" | \"IRT\" | MoneyCurrencyDefinition;\nexport type MoneyDisplayOptions = {\n locale?: string\n digits?: \"persian\" | \"latin\"\n grouping?: boolean\n showCurrency?: boolean\n};\nexport type MoneyFieldOptions = {\n name: string\n currency: MoneyCurrency\n minMinorUnits?: number\n maxMinorUnits?: number\n allowNegative?: boolean\n display?: MoneyDisplayOptions\n overrides?: Partial<NumberField>\n};\n\nexport const IRR: Readonly<MoneyCurrencyDefinition> = { code: \"IRR\", label: \"\u0631\u06CC\u0627\u0644\", fractionDigits: 0, };\nexport const IRT: Readonly<MoneyCurrencyDefinition> = { code: \"IRT\", label: \"\u062A\u0648\u0645\u0627\u0646\", fractionDigits: 0, };\n\nexport function resolveCurrency (currency: MoneyCurrency): MoneyCurrencyDefinition {\n const result = currency === \"IRR\" ? IRR : currency === \"IRT\" ? IRT : currency;\n if (\n !result.code.trim()\n || !result.label.trim()\n || !Number.isInteger(result.fractionDigits)\n || result.fractionDigits < 0\n || result.fractionDigits > 20\n ) throw new Error(\"Invalid money currency definition.\");\n return result;\n}\n\nfunction normalizedNumber (value: string): string {\n const persian = \"\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\";\n const arabic = \"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\";\n return value.trim().replace(\n /[\u06F0-\u06F9\u0660-\u0669]/g, (digit) => String(Math.max(\n persian.indexOf(digit), arabic.indexOf(digit)\n ) % 10)\n )\n .replace(\n /[\u066C,\\s]/g, \"\"\n )\n .replace(\n /\u066B/g, \".\"\n );\n}\n\nexport function parseMoneyToMinorUnits (\n input: string, currency: MoneyCurrency\n): number {\n const definition = resolveCurrency(currency);\n const value = normalizedNumber(input);\n if (!(/^-?\\d+(?:\\.\\d+)?$/).test(value)) throw new TypeError(\"Invalid money input.\");\n const negative = value.startsWith(\"-\");\n const [\n whole,\n fraction = \"\"\n ] = (negative ? value.slice(1) : value).split(\".\");\n if (fraction.length > definition.fractionDigits) throw new RangeError(\"Money input has unsupported precision.\");\n const digits = `${whole}${fraction.padEnd(\n definition.fractionDigits, \"0\"\n )}`.replace(\n /^0+(?=\\d)/, \"\"\n ) || \"0\";\n const minor = Number(`${negative ? \"-\" : \"\"}${digits}`);\n if (!Number.isSafeInteger(minor)) throw new RangeError(\"Money value is outside the safe integer range.\");\n return minor;\n}\n\nexport function formatMoney (\n value: number | null | undefined,\n currency: MoneyCurrency,\n display: MoneyDisplayOptions = {}\n): string | null {\n if (value === null || value === undefined) return null;\n if (!Number.isSafeInteger(value)) throw new RangeError(\"Money value is outside the safe integer range.\");\n const definition = resolveCurrency(currency);\n const locale = display.locale ?? (display.digits === \"latin\" ? \"fa-IR-u-nu-latn\" : \"fa-IR\");\n const major = value / 10 ** definition.fractionDigits;\n const formatted = new Intl.NumberFormat(\n locale, { useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits, }\n ).format(major);\n return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;\n}\n\nexport function moneyField (options: MoneyFieldOptions): NumberField {\n const overrides = options.overrides ?? {};\n if (overrides.name && overrides.name !== options.name) throw new Error(\"Money field name is protected.\");\n if (overrides.type && overrides.type !== \"number\") throw new Error(\"Money field type is protected.\");\n const currency = resolveCurrency(options.currency);\n if (\n options.minMinorUnits !== undefined\n && (\n !Number.isSafeInteger(options.minMinorUnits)\n || (\n options.maxMinorUnits !== undefined\n && options.minMinorUnits > options.maxMinorUnits\n )\n )\n ) throw new Error(\"Invalid money bounds.\");\n if (options.maxMinorUnits !== undefined && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error(\"Invalid money bounds.\");\n const consumerValidate = overrides.validate;\n const validate: NumberField[\"validate\"] = (\n value: unknown, args: { required?: boolean } | undefined\n ) => {\n if (value === null || value === undefined || value === \"\") return args?.required ? \"\u0648\u0627\u0631\u062F \u06A9\u0631\u062F\u0646 \u0645\u0628\u0644\u063A \u0627\u0644\u0632\u0627\u0645\u06CC \u0627\u0633\u062A.\" : true;\n if (typeof value !== \"number\" || !Number.isSafeInteger(value)) return \"\u0645\u0628\u0644\u063A \u0628\u0627\u06CC\u062F \u06CC\u06A9 \u0639\u062F\u062F \u0635\u062D\u06CC\u062D \u0645\u0639\u062A\u0628\u0631 \u0628\u0627\u0634\u062F.\";\n if (!options.allowNegative && value < 0) return \"\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.\";\n if (options.minMinorUnits !== undefined && value < options.minMinorUnits) return \"\u0645\u0628\u0644\u063A \u06A9\u0645\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.\";\n if (options.maxMinorUnits !== undefined && value > options.maxMinorUnits) return \"\u0645\u0628\u0644\u063A \u0628\u06CC\u0634\u062A\u0631 \u0627\u0632 \u062D\u062F \u0645\u062C\u0627\u0632 \u0627\u0633\u062A.\";\n return consumerValidate\n ? (consumerValidate as (value: number, args: unknown) => string | true)(\n value, args\n )\n : true;\n };\n const display = {\n locale: \"fa-IR\", digits: \"persian\" as const, grouping: true, showCurrency: true, ...options.display,\n };\n return {\n ...overrides,\n name: options.name,\n type: \"number\",\n validate,\n admin: {\n ...overrides.admin,\n components: {\n ...overrides.admin?.components,\n Field: {\n path: \"@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent\",\n clientProps: {\n currency,\n display,\n allowNegative: options.allowNegative ?? false,\n },\n },\n },\n },\n custom: { ...overrides.custom, nexload: { ...(overrides.custom?.nexload as object), money: currency, }, },\n } as NumberField;\n}\n", "import { formatSlug } from \"./slug/format-slug\";\n\nimport type { PayloadRequest, Plugin } from \"payload\";\n\nexport type SlugGeneratorInput = { sourceValue: string, currentSlug?: string };\nexport type SlugGeneratorContext = { req: PayloadRequest };\nexport type SlugGenerator = (input: SlugGeneratorInput, context: SlugGeneratorContext) => Promise<string>;\nexport type SlugGenerationAccess = (context: SlugGeneratorContext) => boolean | Promise<boolean>;\nexport type PayloadFieldsPluginOptions = { slugGenerators?: Record<string, SlugGenerator>, generateSlugAccess?: SlugGenerationAccess };\n\nfunction failure (\n code: string, message: string, status: number\n): Response {\n return Response.json(\n { error: { code, message, }, }, { status, }\n );\n}\n\nexport function payloadFieldsPlugin (options: PayloadFieldsPluginOptions = {}): Plugin {\n return (config) => ({\n ...config,\n endpoints: [\n ...(config.endpoints ?? []),\n {\n path: \"/payload-fields/generate-slug\",\n method: \"post\" as const,\n handler: async (req: PayloadRequest) => {\n if (!req.user) return failure(\n \"PAYLOAD_FIELDS_UNAUTHENTICATED\", \"\u0628\u0631\u0627\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627\u06CC\u062F \u0648\u0627\u0631\u062F \u0634\u0648\u06CC\u062F.\", 401\n );\n if (options.generateSlugAccess && !await options.generateSlugAccess({ req, })) return failure(\n \"PAYLOAD_FIELDS_FORBIDDEN\", \"\u0627\u062C\u0627\u0632\u0647 \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0631\u0627 \u0646\u062F\u0627\u0631\u06CC\u062F.\", 403\n );\n let body: unknown;\n try {\n body = await req.json?.();\n } catch {\n return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n }\n if (!body || typeof body !== \"object\" || Array.isArray(body)) return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n const input = body as {\n generator?: unknown\n sourceValue?: unknown\n currentSlug?: unknown\n };\n if (\n typeof input.generator !== \"string\"\n || typeof input.sourceValue !== \"string\"\n || (input.currentSlug !== undefined && typeof input.currentSlug !== \"string\")\n ) return failure(\n \"PAYLOAD_FIELDS_INVALID_INPUT\", \"\u0648\u0631\u0648\u062F\u06CC \u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0645\u0639\u062A\u0628\u0631 \u0646\u06CC\u0633\u062A.\", 400\n );\n const generator = options.slugGenerators && Object.prototype.hasOwnProperty.call(\n options.slugGenerators, input.generator\n )\n ? options.slugGenerators[input.generator]\n : undefined;\n if (!generator) return failure(\n \"PAYLOAD_FIELDS_GENERATOR_NOT_FOUND\", \"\u062A\u0648\u0644\u06CC\u062F\u06A9\u0646\u0646\u062F\u0647 \u0627\u0633\u0644\u0627\u06AF \u067E\u06CC\u062F\u0627 \u0646\u0634\u062F.\", 404\n );\n try {\n const result = await generator(\n { sourceValue: input.sourceValue, currentSlug: input.currentSlug, }, { req, }\n );\n return Response.json({ slug: formatSlug(result), });\n } catch {\n return failure(\n \"PAYLOAD_FIELDS_GENERATION_FAILED\", \"\u062A\u0648\u0644\u06CC\u062F \u0627\u0633\u0644\u0627\u06AF \u0628\u0627 \u062E\u0637\u0627 \u0645\u0648\u0627\u062C\u0647 \u0634\u062F.\", 500\n );\n }\n },\n }\n ],\n });\n}\n"],
5
+ "mappings": ";;;AASA,IAAM,gBAAgB;AACtB,IAAM,eAAe;AAErB,SAAS,gBAAiB,OAAuB;AAC/C,SAAO,MAAM;AAAA,IACX;AAAA,IAAa,CAAC,UAAU;AACtB,YAAM,QAAQ,cAAc,QAAQ,KAAK;AACzC,aAAO,OAAO,SAAS,IAAI,QAAQ,aAAa,QAAQ,KAAK,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEA,SAAS,QACP,OAAgB,MACP;AACT,SAAO,KAAK,MAAM,GAAG,EAAE;AAAA,IACrB,CACE,SAAS,QACN;AACH,UAAI,WAAW,OAAO,YAAY,SAAU,QAAQ,QAAoC,GAAG;AAC3F,aAAO;AAAA,IACT;AAAA,IAAG;AAAA,EACL;AACF;AAEA,SAAS,QACP,OAAgB,MACP;AACT,SAAO,KAAK,MAAM,GAAG,EAAE,MAAM,CAAC,QAAQ;AACpC,QAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,OAAO,OAAQ,QAAO;AACnE,YAAS,MAAkC,GAAG;AAC9C,WAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,WAAY,OAAuB;AACjD,SAAO,gBAAgB,MAAM,UAAU,MAAM,CAAC,EAC3C;AAAA,IACC;AAAA,IAAS;AAAA,EACX,EACC;AAAA,IACC;AAAA,IAAM;AAAA,EACR,EACC;AAAA,IACC;AAAA,IAA0B;AAAA,EAC5B,EACC;AAAA,IACC;AAAA,IAAW;AAAA,EACb,EACC;AAAA,IACC;AAAA,IAAqB;AAAA,EACvB,EACC;AAAA,IACC;AAAA,IAAO;AAAA,EACT,EACC;AAAA,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