@nexload-sdk/payload-fields 2.0.1 → 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 +42 -27
  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
@@ -0,0 +1,147 @@
1
+ // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:57.614Z)
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/money/index.ts
22
+ var money_exports = {};
23
+ __export(money_exports, {
24
+ IRR: () => IRR,
25
+ IRT: () => IRT,
26
+ formatMoney: () => formatMoney,
27
+ moneyField: () => moneyField,
28
+ parseMoneyToMinorUnits: () => parseMoneyToMinorUnits,
29
+ resolveCurrency: () => resolveCurrency
30
+ });
31
+ module.exports = __toCommonJS(money_exports);
32
+ var IRR = { code: "IRR", label: "\u0631\u06CC\u0627\u0644", fractionDigits: 0 };
33
+ var IRT = { code: "IRT", label: "\u062A\u0648\u0645\u0627\u0646", fractionDigits: 0 };
34
+ function resolveCurrency(currency) {
35
+ const result = currency === "IRR" ? IRR : currency === "IRT" ? IRT : currency;
36
+ if (!result.code.trim() || !result.label.trim() || !Number.isInteger(result.fractionDigits) || result.fractionDigits < 0 || result.fractionDigits > 20) throw new Error("Invalid money currency definition.");
37
+ return result;
38
+ }
39
+ function normalizedNumber(value) {
40
+ const persian = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
41
+ const arabic = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
42
+ return value.trim().replace(
43
+ /[۰-۹٠-٩]/g,
44
+ (digit) => String(Math.max(
45
+ persian.indexOf(digit),
46
+ arabic.indexOf(digit)
47
+ ) % 10)
48
+ ).replace(
49
+ /[٬,\s]/g,
50
+ ""
51
+ ).replace(
52
+ /٫/g,
53
+ "."
54
+ );
55
+ }
56
+ function parseMoneyToMinorUnits(input, currency) {
57
+ const definition = resolveCurrency(currency);
58
+ const value = normalizedNumber(input);
59
+ if (!/^-?\d+(?:\.\d+)?$/.test(value)) throw new TypeError("Invalid money input.");
60
+ const negative = value.startsWith("-");
61
+ const [
62
+ whole,
63
+ fraction = ""
64
+ ] = (negative ? value.slice(1) : value).split(".");
65
+ if (fraction.length > definition.fractionDigits) throw new RangeError("Money input has unsupported precision.");
66
+ const digits = `${whole}${fraction.padEnd(
67
+ definition.fractionDigits,
68
+ "0"
69
+ )}`.replace(
70
+ /^0+(?=\d)/,
71
+ ""
72
+ ) || "0";
73
+ const minor = Number(`${negative ? "-" : ""}${digits}`);
74
+ if (!Number.isSafeInteger(minor)) throw new RangeError("Money value is outside the safe integer range.");
75
+ return minor;
76
+ }
77
+ function formatMoney(value, currency, display = {}) {
78
+ if (value === null || value === void 0) return null;
79
+ if (!Number.isSafeInteger(value)) throw new RangeError("Money value is outside the safe integer range.");
80
+ const definition = resolveCurrency(currency);
81
+ const locale = display.locale ?? (display.digits === "latin" ? "fa-IR-u-nu-latn" : "fa-IR");
82
+ const major = value / 10 ** definition.fractionDigits;
83
+ const formatted = new Intl.NumberFormat(
84
+ locale,
85
+ { useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits }
86
+ ).format(major);
87
+ return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;
88
+ }
89
+ function moneyField(options) {
90
+ var _a, _b;
91
+ const overrides = options.overrides ?? {};
92
+ if (overrides.name && overrides.name !== options.name) throw new Error("Money field name is protected.");
93
+ if (overrides.type && overrides.type !== "number") throw new Error("Money field type is protected.");
94
+ const currency = resolveCurrency(options.currency);
95
+ if (options.minMinorUnits !== void 0 && (!Number.isSafeInteger(options.minMinorUnits) || options.maxMinorUnits !== void 0 && options.minMinorUnits > options.maxMinorUnits)) throw new Error("Invalid money bounds.");
96
+ if (options.maxMinorUnits !== void 0 && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error("Invalid money bounds.");
97
+ const consumerValidate = overrides.validate;
98
+ const validate = (value, args) => {
99
+ if (value === null || value === void 0 || value === "") return (args == null ? void 0 : args.required) ? "\u0648\u0627\u0631\u062F \u06A9\u0631\u062F\u0646 \u0645\u0628\u0644\u063A \u0627\u0644\u0632\u0627\u0645\u06CC \u0627\u0633\u062A." : true;
100
+ 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.";
101
+ if (!options.allowNegative && value < 0) return "\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.";
102
+ 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.";
103
+ 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.";
104
+ return consumerValidate ? consumerValidate(
105
+ value,
106
+ args
107
+ ) : true;
108
+ };
109
+ const display = {
110
+ locale: "fa-IR",
111
+ digits: "persian",
112
+ grouping: true,
113
+ showCurrency: true,
114
+ ...options.display
115
+ };
116
+ return {
117
+ ...overrides,
118
+ name: options.name,
119
+ type: "number",
120
+ validate,
121
+ admin: {
122
+ ...overrides.admin,
123
+ components: {
124
+ ...(_a = overrides.admin) == null ? void 0 : _a.components,
125
+ Field: {
126
+ path: "@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent",
127
+ clientProps: {
128
+ currency,
129
+ display,
130
+ allowNegative: options.allowNegative ?? false
131
+ }
132
+ }
133
+ }
134
+ },
135
+ custom: { ...overrides.custom, nexload: { ...(_b = overrides.custom) == null ? void 0 : _b.nexload, money: currency } }
136
+ };
137
+ }
138
+ // Annotate the CommonJS export names for ESM import in node:
139
+ 0 && (module.exports = {
140
+ IRR,
141
+ IRT,
142
+ formatMoney,
143
+ moneyField,
144
+ parseMoneyToMinorUnits,
145
+ resolveCurrency
146
+ });
147
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/money/index.ts"],
4
+ "sourcesContent": ["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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBO,IAAM,MAAyC,EAAE,MAAM,OAAO,OAAO,4BAAQ,gBAAgB,EAAG;AAChG,IAAM,MAAyC,EAAE,MAAM,OAAO,OAAO,kCAAS,gBAAgB,EAAG;AAEjG,SAAS,gBAAiB,UAAkD;AACjF,QAAM,SAAS,aAAa,QAAQ,MAAM,aAAa,QAAQ,MAAM;AACrE,MACE,CAAC,OAAO,KAAK,KAAK,KACf,CAAC,OAAO,MAAM,KAAK,KACnB,CAAC,OAAO,UAAU,OAAO,cAAc,KACvC,OAAO,iBAAiB,KACxB,OAAO,iBAAiB,GAC3B,OAAM,IAAI,MAAM,oCAAoC;AACtD,SAAO;AACT;AAEA,SAAS,iBAAkB,OAAuB;AAChD,QAAM,UAAU;AAChB,QAAM,SAAS;AACf,SAAO,MAAM,KAAK,EAA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AAc;AAAA,IAAM,GAAG,QAAQ;AAAA,EAC9F;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,QAAQ;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,MACL,GAAG,UAAU;AAAA,MACb,YAAY;AAAA,QACV,IAAG,eAAU,UAAV,mBAAiB;AAAA,QACpB,OAAO;AAAA,UACL,MAAM;AAAA,UACN,aAAa;AAAA,YACX;AAAA,YACA;AAAA,YACA,eAAe,QAAQ,iBAAiB;AAAA,UAC1C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ,EAAE,GAAG,UAAU,QAAQ,SAAS,EAAE,IAAI,eAAU,WAAV,mBAAkB,SAAoB,OAAO,SAAU,EAAG;AAAA,EAC1G;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,29 @@
1
+ import type { NumberField } from "payload";
2
+ export type MoneyCurrencyDefinition = {
3
+ code: string;
4
+ label: string;
5
+ fractionDigits: number;
6
+ };
7
+ export type MoneyCurrency = "IRR" | "IRT" | MoneyCurrencyDefinition;
8
+ export type MoneyDisplayOptions = {
9
+ locale?: string;
10
+ digits?: "persian" | "latin";
11
+ grouping?: boolean;
12
+ showCurrency?: boolean;
13
+ };
14
+ export type MoneyFieldOptions = {
15
+ name: string;
16
+ currency: MoneyCurrency;
17
+ minMinorUnits?: number;
18
+ maxMinorUnits?: number;
19
+ allowNegative?: boolean;
20
+ display?: MoneyDisplayOptions;
21
+ overrides?: Partial<NumberField>;
22
+ };
23
+ export declare const IRR: Readonly<MoneyCurrencyDefinition>;
24
+ export declare const IRT: Readonly<MoneyCurrencyDefinition>;
25
+ export declare function resolveCurrency(currency: MoneyCurrency): MoneyCurrencyDefinition;
26
+ export declare function parseMoneyToMinorUnits(input: string, currency: MoneyCurrency): number;
27
+ export declare function formatMoney(value: number | null | undefined, currency: MoneyCurrency, display?: MoneyDisplayOptions): string | null;
28
+ export declare function moneyField(options: MoneyFieldOptions): NumberField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AG,SAAS,EAChC,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,mBAAwB,GAChC,MAAM,GAAG,IAAI,CAUf;AAED,wBAAgB,UAAU,CAAE,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAuDnE"}
@@ -0,0 +1,117 @@
1
+ // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:56.848Z)
2
+
3
+ // src/money/index.ts
4
+ var IRR = { code: "IRR", label: "\u0631\u06CC\u0627\u0644", fractionDigits: 0 };
5
+ var IRT = { code: "IRT", label: "\u062A\u0648\u0645\u0627\u0646", fractionDigits: 0 };
6
+ function resolveCurrency(currency) {
7
+ const result = currency === "IRR" ? IRR : currency === "IRT" ? IRT : currency;
8
+ if (!result.code.trim() || !result.label.trim() || !Number.isInteger(result.fractionDigits) || result.fractionDigits < 0 || result.fractionDigits > 20) throw new Error("Invalid money currency definition.");
9
+ return result;
10
+ }
11
+ function normalizedNumber(value) {
12
+ const persian = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
13
+ const arabic = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
14
+ return value.trim().replace(
15
+ /[۰-۹٠-٩]/g,
16
+ (digit) => String(Math.max(
17
+ persian.indexOf(digit),
18
+ arabic.indexOf(digit)
19
+ ) % 10)
20
+ ).replace(
21
+ /[٬,\s]/g,
22
+ ""
23
+ ).replace(
24
+ /٫/g,
25
+ "."
26
+ );
27
+ }
28
+ function parseMoneyToMinorUnits(input, currency) {
29
+ const definition = resolveCurrency(currency);
30
+ const value = normalizedNumber(input);
31
+ if (!/^-?\d+(?:\.\d+)?$/.test(value)) throw new TypeError("Invalid money input.");
32
+ const negative = value.startsWith("-");
33
+ const [
34
+ whole,
35
+ fraction = ""
36
+ ] = (negative ? value.slice(1) : value).split(".");
37
+ if (fraction.length > definition.fractionDigits) throw new RangeError("Money input has unsupported precision.");
38
+ const digits = `${whole}${fraction.padEnd(
39
+ definition.fractionDigits,
40
+ "0"
41
+ )}`.replace(
42
+ /^0+(?=\d)/,
43
+ ""
44
+ ) || "0";
45
+ const minor = Number(`${negative ? "-" : ""}${digits}`);
46
+ if (!Number.isSafeInteger(minor)) throw new RangeError("Money value is outside the safe integer range.");
47
+ return minor;
48
+ }
49
+ function formatMoney(value, currency, display = {}) {
50
+ if (value === null || value === void 0) return null;
51
+ if (!Number.isSafeInteger(value)) throw new RangeError("Money value is outside the safe integer range.");
52
+ const definition = resolveCurrency(currency);
53
+ const locale = display.locale ?? (display.digits === "latin" ? "fa-IR-u-nu-latn" : "fa-IR");
54
+ const major = value / 10 ** definition.fractionDigits;
55
+ const formatted = new Intl.NumberFormat(
56
+ locale,
57
+ { useGrouping: display.grouping ?? true, minimumFractionDigits: definition.fractionDigits, maximumFractionDigits: definition.fractionDigits }
58
+ ).format(major);
59
+ return display.showCurrency ?? true ? `${formatted} ${definition.label}` : formatted;
60
+ }
61
+ function moneyField(options) {
62
+ const overrides = options.overrides ?? {};
63
+ if (overrides.name && overrides.name !== options.name) throw new Error("Money field name is protected.");
64
+ if (overrides.type && overrides.type !== "number") throw new Error("Money field type is protected.");
65
+ const currency = resolveCurrency(options.currency);
66
+ if (options.minMinorUnits !== void 0 && (!Number.isSafeInteger(options.minMinorUnits) || options.maxMinorUnits !== void 0 && options.minMinorUnits > options.maxMinorUnits)) throw new Error("Invalid money bounds.");
67
+ if (options.maxMinorUnits !== void 0 && !Number.isSafeInteger(options.maxMinorUnits)) throw new Error("Invalid money bounds.");
68
+ const consumerValidate = overrides.validate;
69
+ const validate = (value, args) => {
70
+ 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;
71
+ 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.";
72
+ if (!options.allowNegative && value < 0) return "\u0645\u0628\u0644\u063A \u0645\u0646\u0641\u06CC \u0645\u062C\u0627\u0632 \u0646\u06CC\u0633\u062A.";
73
+ 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.";
74
+ 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.";
75
+ return consumerValidate ? consumerValidate(
76
+ value,
77
+ args
78
+ ) : true;
79
+ };
80
+ const display = {
81
+ locale: "fa-IR",
82
+ digits: "persian",
83
+ grouping: true,
84
+ showCurrency: true,
85
+ ...options.display
86
+ };
87
+ return {
88
+ ...overrides,
89
+ name: options.name,
90
+ type: "number",
91
+ validate,
92
+ admin: {
93
+ ...overrides.admin,
94
+ components: {
95
+ ...overrides.admin?.components,
96
+ Field: {
97
+ path: "@nexload-sdk/payload-fields/admin/money-field#MoneyFieldComponent",
98
+ clientProps: {
99
+ currency,
100
+ display,
101
+ allowNegative: options.allowNegative ?? false
102
+ }
103
+ }
104
+ }
105
+ },
106
+ custom: { ...overrides.custom, nexload: { ...overrides.custom?.nexload, money: currency } }
107
+ };
108
+ }
109
+ export {
110
+ IRR,
111
+ IRT,
112
+ formatMoney,
113
+ moneyField,
114
+ parseMoneyToMinorUnits,
115
+ resolveCurrency
116
+ };
117
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/money/index.ts"],
4
+ "sourcesContent": ["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"],
5
+ "mappings": ";;;AAwBO,IAAM,MAAyC,EAAE,MAAM,OAAO,OAAO,4BAAQ,gBAAgB,EAAG;AAChG,IAAM,MAAyC,EAAE,MAAM,OAAO,OAAO,kCAAS,gBAAgB,EAAG;AAEjG,SAAS,gBAAiB,UAAkD;AACjF,Q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AAI,CAAC,QAAQ,iBAAiB,QAAQ,EAAG,QAAO;AAChD,QAAI,QAAQ,kBAAkB,UAAa,QAAQ,QAAQ,cAAe,QAAO;AACjF,QAAI,QAAQ,kBAAkB,UAAa,QAAQ,QAAQ,cAAe,QAAO;AACjF,WAAO,mBACF;AAAA,MACD;AAAA,MAAO;AAAA,IACT,IACE;AAAA,EACN;AACA,QAAM,UAAU;AAAA,IACd,QAAQ;AAAA,IAAS,QAAQ;AAAA,IAAoB,UAAU;AAAA,IAAM,cAAc;AAAA,IAAM,GAAG,QAAQ;AAAA,EAC9F;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,MAAM,QAAQ;AAAA,IACd,MAAM;AAAA,IACN;AAAA,IACA,OAAO;AAAA,MACL,GAAG,UAAU;AAAA,MACb,YAAY;AAAA,QACV,GAAG,UAAU,OAAO;AAAA,QACpB,OAAO;AAAA,UACL,MAAM;AAAA,UACN,aAAa;AAAA,YACX;AAAA,YACA;AAAA,YACA,eAAe,QAAQ,iBAAiB;AAAA,UAC1C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ,EAAE,GAAG,UAAU,QAAQ,SAAS,EAAE,GAAI,UAAU,QAAQ,SAAoB,OAAO,SAAU,EAAG;AAAA,EAC1G;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,16 @@
1
+ import type { PayloadRequest, Plugin } from "payload";
2
+ export type SlugGeneratorInput = {
3
+ sourceValue: string;
4
+ currentSlug?: string;
5
+ };
6
+ export type SlugGeneratorContext = {
7
+ req: PayloadRequest;
8
+ };
9
+ export type SlugGenerator = (input: SlugGeneratorInput, context: SlugGeneratorContext) => Promise<string>;
10
+ export type SlugGenerationAccess = (context: SlugGeneratorContext) => boolean | Promise<boolean>;
11
+ export type PayloadFieldsPluginOptions = {
12
+ slugGenerators?: Record<string, SlugGenerator>;
13
+ generateSlugAccess?: SlugGenerationAccess;
14
+ };
15
+ export declare function payloadFieldsPlugin(options?: PayloadFieldsPluginOptions): Plugin;
16
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/E,MAAM,MAAM,oBAAoB,GAAG;IAAE,GAAG,EAAE,cAAc,CAAA;CAAE,CAAC;AAC3D,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAC1G,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACjG,MAAM,MAAM,0BAA0B,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAAC,kBAAkB,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAUvI,wBAAgB,mBAAmB,CAAE,OAAO,GAAE,0BAA+B,GAAG,MAAM,CA4DrF"}
@@ -1,4 +1,10 @@
1
1
  import type { FieldHook } from "payload";
2
- export declare function formatSlug(val: string): string | undefined;
3
- export declare const formatSlugHook: (fallback: string) => FieldHook;
2
+ export type SlugHookOptions = {
3
+ name: string;
4
+ lockName: string;
5
+ source: string;
6
+ regenerateOnSourceChange: boolean;
7
+ };
8
+ export declare function formatSlug(value: string): string;
9
+ export declare const formatSlugHook: (options: SlugHookOptions) => FieldHook;
4
10
  //# sourceMappingURL=format-slug.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-slug.d.ts","sourceRoot":"","sources":["../../src/slug/format-slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,UAAU,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW3D;AAED,eAAO,MAAM,cAAc,GACtB,UAAU,MAAM,KAAG,SAcrB,CAAC"}
1
+ {"version":3,"file":"format-slug.d.ts","sourceRoot":"","sources":["../../src/slug/format-slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,wBAAwB,EAAE,OAAO,CAAA;CAClC,CAAC;AAqCF,wBAAgB,UAAU,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAuBjD;AAED,eAAO,MAAM,cAAc,GAAI,SAAS,eAAe,KAAG,SAuCzD,CAAC"}
@@ -0,0 +1,183 @@
1
+ // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:57.614Z)
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/slug/index.ts
22
+ var slug_exports = {};
23
+ __export(slug_exports, {
24
+ formatSlug: () => formatSlug,
25
+ formatSlugHook: () => formatSlugHook,
26
+ slugField: () => slugField
27
+ });
28
+ module.exports = __toCommonJS(slug_exports);
29
+
30
+ // src/slug/format-slug.ts
31
+ var persianDigits = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
32
+ var arabicDigits = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
33
+ function normalizeDigits(value) {
34
+ return value.replace(
35
+ /[۰-۹٠-٩]/g,
36
+ (digit) => {
37
+ const index = persianDigits.indexOf(digit);
38
+ return String(index >= 0 ? index : arabicDigits.indexOf(digit));
39
+ }
40
+ );
41
+ }
42
+ function getPath(value, path) {
43
+ return path.split(".").reduce(
44
+ (current, key) => {
45
+ if (current && typeof current === "object") return current[key];
46
+ return void 0;
47
+ },
48
+ value
49
+ );
50
+ }
51
+ function hasPath(value, path) {
52
+ return path.split(".").every((key) => {
53
+ if (!value || typeof value !== "object" || !(key in value)) return false;
54
+ value = value[key];
55
+ return true;
56
+ });
57
+ }
58
+ function formatSlug(value) {
59
+ return normalizeDigits(value.normalize("NFKC")).replace(
60
+ /[يى]/g,
61
+ "\u06CC"
62
+ ).replace(
63
+ /ك/g,
64
+ "\u06A9"
65
+ ).replace(
66
+ /[\u064B-\u065F\u0670]/g,
67
+ ""
68
+ ).replace(
69
+ /[\s_]+/g,
70
+ "-"
71
+ ).replace(
72
+ /[^\p{L}\p{N}-]+/gu,
73
+ ""
74
+ ).replace(
75
+ /-+/g,
76
+ "-"
77
+ ).replace(
78
+ /^-+|-+$/g,
79
+ ""
80
+ );
81
+ }
82
+ var formatSlugHook = (options) => ({
83
+ data,
84
+ operation,
85
+ originalDoc,
86
+ siblingData,
87
+ previousSiblingDoc,
88
+ value
89
+ }) => {
90
+ const lock = (siblingData == null ? void 0 : siblingData[options.lockName]) ?? (data == null ? void 0 : data[options.lockName]);
91
+ const previousSlug = (previousSiblingDoc == null ? void 0 : previousSiblingDoc[options.name]) ?? (originalDoc == null ? void 0 : originalDoc[options.name]);
92
+ const sourceChanged = hasPath(
93
+ data,
94
+ options.source
95
+ ) && getPath(
96
+ data,
97
+ options.source
98
+ ) !== getPath(
99
+ originalDoc,
100
+ options.source
101
+ );
102
+ const source = hasPath(
103
+ data,
104
+ options.source
105
+ ) ? getPath(
106
+ data,
107
+ options.source
108
+ ) : getPath(
109
+ originalDoc,
110
+ options.source
111
+ );
112
+ if (lock !== false && typeof source === "string" && source.trim() && (operation === "create" || options.regenerateOnSourceChange && sourceChanged)) {
113
+ return formatSlug(source);
114
+ }
115
+ if (operation === "update" && lock !== false && sourceChanged && !source && previousSlug !== void 0) {
116
+ return previousSlug;
117
+ }
118
+ if (lock !== false && operation === "update" && previousSlug !== void 0) return previousSlug;
119
+ if (typeof value === "string") return formatSlug(value);
120
+ return value;
121
+ };
122
+
123
+ // src/slug/index.ts
124
+ function slugField(options = {}) {
125
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
126
+ const name = options.name ?? "slug";
127
+ const lockName = options.lockName ?? `${name}Lock`;
128
+ const source = options.source ?? "title";
129
+ const localized = ((_b = (_a = options.overrides) == null ? void 0 : _a.slug) == null ? void 0 : _b.localized) === true;
130
+ if (((_d = (_c = options.overrides) == null ? void 0 : _c.slug) == null ? void 0 : _d.name) && options.overrides.slug.name !== name) throw new Error("Slug field name is protected.");
131
+ if (((_f = (_e = options.overrides) == null ? void 0 : _e.lock) == null ? void 0 : _f.name) && options.overrides.lock.name !== lockName) throw new Error("Slug lock name is protected.");
132
+ if (((_h = (_g = options.overrides) == null ? void 0 : _g.lock) == null ? void 0 : _h.localized) !== void 0 && options.overrides.lock.localized !== localized) throw new Error("Slug lock localization must match slug localization.");
133
+ if (((_j = (_i = options.overrides) == null ? void 0 : _i.slug) == null ? void 0 : _j.type) && options.overrides.slug.type !== "text") throw new Error("Slug field type is protected.");
134
+ if (((_l = (_k = options.overrides) == null ? void 0 : _k.lock) == null ? void 0 : _l.type) && options.overrides.lock.type !== "checkbox") throw new Error("Slug lock type is protected.");
135
+ const slugOverrides = ((_m = options.overrides) == null ? void 0 : _m.slug) ?? {};
136
+ const lockOverrides = ((_n = options.overrides) == null ? void 0 : _n.lock) ?? {};
137
+ const consumerHooks = ((_o = slugOverrides.hooks) == null ? void 0 : _o.beforeValidate) ?? [];
138
+ const slug = {
139
+ ...slugOverrides,
140
+ name,
141
+ type: "text",
142
+ index: slugOverrides.index ?? true,
143
+ localized,
144
+ admin: {
145
+ ...slugOverrides.admin,
146
+ position: ((_p = slugOverrides.admin) == null ? void 0 : _p.position) ?? "sidebar",
147
+ components: {
148
+ ...(_q = slugOverrides.admin) == null ? void 0 : _q.components,
149
+ Field: {
150
+ path: "@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent",
151
+ clientProps: { source, lockName, generator: options.generator }
152
+ }
153
+ }
154
+ },
155
+ custom: { ...slugOverrides.custom, nexload: { ...(_r = slugOverrides.custom) == null ? void 0 : _r.nexload, slug: { source, lockName, generator: options.generator } } },
156
+ hooks: {
157
+ ...slugOverrides.hooks,
158
+ beforeValidate: [
159
+ ...consumerHooks,
160
+ formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true })
161
+ ]
162
+ }
163
+ };
164
+ const lock = {
165
+ ...lockOverrides,
166
+ name: lockName,
167
+ type: "checkbox",
168
+ localized,
169
+ defaultValue: true,
170
+ admin: { ...lockOverrides.admin, hidden: true, position: ((_s = lockOverrides.admin) == null ? void 0 : _s.position) ?? "sidebar" }
171
+ };
172
+ return [
173
+ slug,
174
+ lock
175
+ ];
176
+ }
177
+ // Annotate the CommonJS export names for ESM import in node:
178
+ 0 && (module.exports = {
179
+ formatSlug,
180
+ formatSlugHook,
181
+ slugField
182
+ });
183
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/slug/index.ts", "../../src/slug/format-slug.ts"],
4
+ "sourcesContent": ["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", "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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSA,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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AAd,mBAAqB,aAAY;AAAA,MAC3C,YAAY;AAAA,QACV,IAAG,mBAAc,UAAd,mBAAqB;AAAA,QACxB,OAAO;AAAA,UACL,MAAM;AAAA,UACN,aAAa,EAAE,QAAQ,UAAU,WAAW,QAAQ,UAAW;AAAA,QACjE;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ,EAAE,GAAG,cAAc,QAAQ,SAAS,EAAE,IAAI,mBAAc,WAAd,mBAAsB,SAAoB,MAAM,EAAE,QAAQ,UAAU,WAAW,QAAQ,UAAW,EAAG,EAAG;AAAA,IAC1J,OAAO;AAAA,MACL,GAAG,cAAc;AAAA,MAAO,gBAAgB;AAAA,QACtC,GAAG;AAAA,QACH,eAAe,EAAE,MAAM,UAAU,QAAQ,0BAA0B,QAAQ,4BAA4B,KAAM,CAAC;AAAA,MAChH;AAAA,IACF;AAAA,EACF;AACA,QAAM,OAAsB;AAAA,IAC1B,GAAG;AAAA,IACH,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,cAAc;AAAA,IACd,OAAO,EAAE,GAAG,cAAc,OAAO,QAAQ,MAAM,YAAU,mBAAc,UAAd,mBAAqB,aAAY,UAAW;AAAA,EACvG;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,9 +1,16 @@
1
1
  import type { CheckboxField, TextField } from "payload";
2
- type Overrides = {
3
- slugOverrides?: Partial<TextField>;
4
- checkboxOverrides?: Partial<CheckboxField>;
2
+ export type SlugFieldOptions = {
3
+ name?: string;
4
+ lockName?: string;
5
+ source?: string;
6
+ generator?: string;
7
+ regenerateOnSourceChange?: boolean;
8
+ overrides?: {
9
+ slug?: Partial<TextField>;
10
+ lock?: Partial<CheckboxField>;
11
+ };
5
12
  };
6
- type Slug = (fieldToUse?: string, overrides?: Overrides) => [TextField, CheckboxField];
7
- export declare const slugField: Slug;
13
+ export type SlugFieldResult = readonly [TextField, CheckboxField];
14
+ export declare function slugField(options?: SlugFieldOptions): SlugFieldResult;
8
15
  export * from "./format-slug";
9
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slug/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,SAAS,GAAG;IACf,aAAa,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,IAAI,GAAG,CACV,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,SAAS,KAClB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAEhC,eAAO,MAAM,SAAS,EAAE,IAyCvB,CAAC;AAEF,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/slug/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,SAAS,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;KAAE,CAAA;CACzE,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AAElE,wBAAgB,SAAS,CAAE,OAAO,GAAE,gBAAqB,GAAG,eAAe,CAmD1E;AAED,cAAc,eAAe,CAAC"}