@nexload-sdk/payload-fields 3.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +196 -17
  2. package/dist/address/index.d.ts +13 -0
  3. package/dist/address/index.d.ts.map +1 -0
  4. package/dist/admin/formatted-cell.d.ts +6 -0
  5. package/dist/admin/formatted-cell.d.ts.map +1 -0
  6. package/dist/admin/formatted-cell.js +18 -0
  7. package/dist/admin/formatted-cell.js.map +7 -0
  8. package/dist/admin/jalali-date-cell.d.ts +3 -3
  9. package/dist/admin/jalali-date-cell.d.ts.map +1 -1
  10. package/dist/admin/jalali-date-cell.js +27 -0
  11. package/dist/admin/jalali-date-cell.js.map +7 -0
  12. package/dist/admin/jalali-date-field.d.ts +4 -3
  13. package/dist/admin/jalali-date-field.d.ts.map +1 -1
  14. package/dist/admin/jalali-date-field.js +250 -0
  15. package/dist/admin/jalali-date-field.js.map +7 -0
  16. package/dist/admin/money-cell.d.ts +10 -0
  17. package/dist/admin/money-cell.d.ts.map +1 -0
  18. package/dist/admin/money-cell.js +124 -0
  19. package/dist/admin/money-cell.js.map +7 -0
  20. package/dist/admin/money-field.d.ts +3 -2
  21. package/dist/admin/money-field.d.ts.map +1 -1
  22. package/dist/admin/money-field.js +183 -0
  23. package/dist/admin/money-field.js.map +7 -0
  24. package/dist/admin/slug-field.d.ts.map +1 -1
  25. package/dist/admin/slug-field.js +210 -0
  26. package/dist/admin/slug-field.js.map +7 -0
  27. package/dist/admin/validated-text-field.d.ts +6 -0
  28. package/dist/admin/validated-text-field.d.ts.map +1 -0
  29. package/dist/admin/validated-text-field.js +35 -0
  30. package/dist/admin/validated-text-field.js.map +7 -0
  31. package/dist/bank/index.d.ts +7 -0
  32. package/dist/bank/index.d.ts.map +1 -0
  33. package/dist/common/index.d.ts +35 -0
  34. package/dist/common/index.d.ts.map +1 -0
  35. package/dist/contact/index.d.ts +9 -0
  36. package/dist/contact/index.d.ts.map +1 -0
  37. package/dist/date/format-date.d.ts.map +1 -1
  38. package/dist/date/index.d.ts +37 -4
  39. package/dist/date/index.d.ts.map +1 -1
  40. package/dist/date/index.js +258 -0
  41. package/dist/date/index.js.map +7 -0
  42. package/dist/i18n/messages.d.ts +6 -0
  43. package/dist/i18n/messages.d.ts.map +1 -0
  44. package/dist/i18n/messages.js +97 -0
  45. package/dist/i18n/messages.js.map +7 -0
  46. package/dist/identity/index.d.ts +9 -0
  47. package/dist/identity/index.d.ts.map +1 -0
  48. package/dist/index.d.ts +6 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +1038 -0
  51. package/dist/index.js.map +7 -0
  52. package/dist/internal/protect.d.ts +7 -0
  53. package/dist/internal/protect.d.ts.map +1 -0
  54. package/dist/internal/validated-text.d.ts +24 -0
  55. package/dist/internal/validated-text.d.ts.map +1 -0
  56. package/dist/internal/validated-text.js +161 -0
  57. package/dist/internal/validated-text.js.map +7 -0
  58. package/dist/money/index.d.ts +6 -0
  59. package/dist/money/index.d.ts.map +1 -1
  60. package/dist/money/index.js +212 -0
  61. package/dist/money/index.js.map +7 -0
  62. package/dist/plugin.d.ts +1 -0
  63. package/dist/plugin.d.ts.map +1 -1
  64. package/dist/schema/index.d.ts +51 -0
  65. package/dist/schema/index.d.ts.map +1 -0
  66. package/dist/schema/index.js +735 -0
  67. package/dist/schema/index.js.map +7 -0
  68. package/dist/slug/format-slug.d.ts +1 -1
  69. package/dist/slug/format-slug.d.ts.map +1 -1
  70. package/dist/slug/index.d.ts +1 -0
  71. package/dist/slug/index.d.ts.map +1 -1
  72. package/dist/slug/{index.mjs → index.js} +47 -43
  73. package/dist/slug/index.js.map +7 -0
  74. package/package.json +64 -27
  75. package/dist/admin/jalali-date-cell.cjs +0 -58
  76. package/dist/admin/jalali-date-cell.cjs.map +0 -7
  77. package/dist/admin/jalali-date-cell.mjs +0 -32
  78. package/dist/admin/jalali-date-cell.mjs.map +0 -7
  79. package/dist/admin/jalali-date-field.cjs +0 -159
  80. package/dist/admin/jalali-date-field.cjs.map +0 -7
  81. package/dist/admin/jalali-date-field.mjs +0 -135
  82. package/dist/admin/jalali-date-field.mjs.map +0 -7
  83. package/dist/admin/jalali-picker-value.cjs +0 -42
  84. package/dist/admin/jalali-picker-value.cjs.map +0 -7
  85. package/dist/admin/jalali-picker-value.d.ts +0 -3
  86. package/dist/admin/jalali-picker-value.d.ts.map +0 -1
  87. package/dist/admin/jalali-picker-value.mjs +0 -18
  88. package/dist/admin/jalali-picker-value.mjs.map +0 -7
  89. package/dist/admin/money-field.cjs +0 -146
  90. package/dist/admin/money-field.cjs.map +0 -7
  91. package/dist/admin/money-field.mjs +0 -122
  92. package/dist/admin/money-field.mjs.map +0 -7
  93. package/dist/admin/slug-field.cjs +0 -135
  94. package/dist/admin/slug-field.cjs.map +0 -7
  95. package/dist/admin/slug-field.mjs +0 -115
  96. package/dist/admin/slug-field.mjs.map +0 -7
  97. package/dist/date/index.cjs +0 -117
  98. package/dist/date/index.cjs.map +0 -7
  99. package/dist/date/index.mjs +0 -86
  100. package/dist/date/index.mjs.map +0 -7
  101. package/dist/index.cjs +0 -469
  102. package/dist/index.cjs.map +0 -7
  103. package/dist/index.mjs +0 -425
  104. package/dist/index.mjs.map +0 -7
  105. package/dist/money/index.cjs +0 -147
  106. package/dist/money/index.cjs.map +0 -7
  107. package/dist/money/index.mjs +0 -117
  108. package/dist/money/index.mjs.map +0 -7
  109. package/dist/slug/index.cjs +0 -183
  110. package/dist/slug/index.cjs.map +0 -7
  111. package/dist/slug/index.mjs.map +0 -7
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/date/format-date.ts", "../../src/admin/jalali-date-cell.tsx"],
4
- "sourcesContent": ["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", "\"use client\";\n\nimport { formatJalaliDate, type JalaliDateDisplayOptions } from \"../date/format-date\";\n\nimport type { DefaultCellComponentProps } from \"payload\";\n\nexport const JalaliDateCell = ({\n cellData,\n display,\n}: DefaultCellComponentProps & { display?: JalaliDateDisplayOptions }) => (\n <>\n {formatJalaliDate(\n cellData as string | null, display\n ) ?? \"\u2014\"}\n </>\n);\n"],
5
- "mappings": ";;;;AAQO,SAAS,iBACd,OAAwB,UAAoC,CAAC,GAC9C;AACf,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,QAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,KAAK;AAC3D,MAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAG,QAAO;AACzC,QAAM,SAAS,QAAQ,WAAW,UAAU,+BAA+B;AAC3E,SAAO,IAAI,KAAK;AAAA,IACd;AAAA,IAAQ;AAAA,MACN,WAAW,QAAQ,aAAa;AAAA,MAChC,GAAI,QAAQ,YAAY,EAAE,WAAW,QAAQ,UAAW,IAAI,CAAC;AAAA,MAC7D,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAU,IAAI,CAAC;AAAA,IAC5D;AAAA,EACF,EAAE,OAAO,IAAI;AACf;;;ACZE;AAJK,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,EACA;AACF,MACE,gCACG;AAAA,EACC;AAAA,EAA2B;AAC7B,KAAK,UACP;",
6
- "names": []
7
- }
@@ -1,159 +0,0 @@
1
- // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:57.614Z)
2
- "use strict";
3
- "use client";
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/admin/jalali-date-field.tsx
23
- var jalali_date_field_exports = {};
24
- __export(jalali_date_field_exports, {
25
- JalaliDateFieldComponent: () => JalaliDateFieldComponent
26
- });
27
- module.exports = __toCommonJS(jalali_date_field_exports);
28
- var import_ui = require("@payloadcms/ui");
29
- var import_react = require("react");
30
- var import_persian2 = require("react-day-picker/persian");
31
- var import_style = require("react-day-picker/style.css");
32
-
33
- // src/admin/jalali-picker-value.ts
34
- var import_persian = require("react-day-picker/persian");
35
- function canonicalizeJalaliPickerDate(date, appearance) {
36
- const result = appearance === "monthOnly" ? (0, import_persian.getDateLib)().startOfMonth(date) : new Date(date);
37
- if (appearance === "dayOnly" || appearance === "monthOnly") result.setHours(
38
- 12,
39
- 0,
40
- 0,
41
- 0
42
- );
43
- return result;
44
- }
45
-
46
- // src/date/format-date.ts
47
- function formatJalaliDate(value, options = {}) {
48
- if (value === null || value === void 0) return null;
49
- const date = value instanceof Date ? value : new Date(value);
50
- if (Number.isNaN(date.getTime())) return null;
51
- const locale = options.digits === "latin" ? "fa-IR-u-ca-persian-nu-latn" : "fa-IR-u-ca-persian";
52
- return new Intl.DateTimeFormat(
53
- locale,
54
- {
55
- dateStyle: options.dateStyle ?? "medium",
56
- ...options.timeStyle ? { timeStyle: options.timeStyle } : {},
57
- ...options.timeZone ? { timeZone: options.timeZone } : {}
58
- }
59
- ).format(date);
60
- }
61
-
62
- // src/admin/jalali-date-field.tsx
63
- var import_jsx_runtime = require("react/jsx-runtime");
64
- var JalaliDateFieldComponent = ({
65
- field,
66
- path,
67
- appearance,
68
- display,
69
- readOnly
70
- }) => {
71
- const { value, setValue } = (0, import_ui.useField)({ path });
72
- const [
73
- selected,
74
- setSelected
75
- ] = (0, import_react.useState)();
76
- (0, import_react.useEffect)(
77
- () => setSelected(value ? new Date(value) : void 0),
78
- [value]
79
- );
80
- const save = (date) => {
81
- setSelected(date);
82
- setValue(date ? date.toISOString() : null);
83
- };
84
- const chooseDay = (date) => {
85
- if (!date) return save(void 0);
86
- save(canonicalizeJalaliPickerDate(
87
- date,
88
- appearance
89
- ));
90
- };
91
- const updateTime = (part, raw) => {
92
- const base = selected ? new Date(selected) : /* @__PURE__ */ new Date();
93
- base[part === "hours" ? "setHours" : "setMinutes"](Number(raw));
94
- save(base);
95
- };
96
- const showCalendar = appearance !== "timeOnly";
97
- const showTime = appearance === "dayAndTime" || appearance === "timeOnly";
98
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "field-type jalali-date-field", children: [
99
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.FieldLabel, { htmlFor: `field-${path}`, label: field.label, required: field.required }),
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- "input",
102
- {
103
- readOnly: true,
104
- value: formatJalaliDate(
105
- value,
106
- display
107
- ) ?? ""
108
- }
109
- ),
110
- showCalendar && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
- import_persian2.DayPicker,
112
- {
113
- captionLayout: "dropdown",
114
- disabled: readOnly,
115
- mode: "single",
116
- onSelect: chooseDay,
117
- selected,
118
- showOutsideDays: true
119
- }
120
- ),
121
- showTime && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
122
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
123
- "input",
124
- {
125
- disabled: readOnly,
126
- max: 23,
127
- min: 0,
128
- onChange: (event) => updateTime(
129
- "hours",
130
- event.target.value
131
- ),
132
- type: "number",
133
- value: (selected == null ? void 0 : selected.getHours()) ?? 0
134
- }
135
- ),
136
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", children: ":" }),
137
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
138
- "input",
139
- {
140
- disabled: readOnly,
141
- max: 59,
142
- min: 0,
143
- onChange: (event) => updateTime(
144
- "minutes",
145
- event.target.value
146
- ),
147
- type: "number",
148
- value: (selected == null ? void 0 : selected.getMinutes()) ?? 0
149
- }
150
- )
151
- ] }),
152
- !readOnly && value && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { onClick: () => save(void 0), type: "button", children: "\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646" })
153
- ] });
154
- };
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- JalaliDateFieldComponent
158
- });
159
- //# sourceMappingURL=jalali-date-field.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/admin/jalali-date-field.tsx", "../../src/admin/jalali-picker-value.ts", "../../src/date/format-date.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport { FieldLabel, useField } from \"@payloadcms/ui\";\nimport { useEffect, useState } from \"react\";\nimport { DayPicker } from \"react-day-picker/persian\";\nimport \"react-day-picker/style.css\";\n\nimport { canonicalizeJalaliPickerDate } from \"./jalali-picker-value\";\nimport { formatJalaliDate, type JalaliDateDisplayOptions } from \"../date/format-date\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\nimport type { DateFieldClientProps } from \"payload\";\n\ntype Props = { appearance: JalaliPickerAppearance, display: JalaliDateDisplayOptions };\n\nexport const JalaliDateFieldComponent = ({\n field, path, appearance, display, readOnly,\n}: DateFieldClientProps & Props) => {\n const { value, setValue, } = useField<string | null>({ path, });\n const [\n selected,\n setSelected\n ] = useState<Date | undefined>();\n useEffect(\n () => setSelected(value ? new Date(value) : undefined), [value]\n );\n const save = (date: Date | undefined) => {\n setSelected(date);\n setValue(date ? date.toISOString() : null);\n };\n const chooseDay = (date: Date | undefined) => {\n if (!date) return save(undefined);\n save(canonicalizeJalaliPickerDate(\n date, appearance\n ));\n };\n const updateTime = (\n part: \"hours\" | \"minutes\", raw: string\n ) => {\n const base = selected ? new Date(selected) : new Date();\n base[part === \"hours\" ? \"setHours\" : \"setMinutes\"](Number(raw));\n save(base);\n };\n const showCalendar = appearance !== \"timeOnly\";\n const showTime = appearance === \"dayAndTime\" || appearance === \"timeOnly\";\n return (\n <div className=\"field-type jalali-date-field\">\n <FieldLabel htmlFor={`field-${path}`} label={field.label} required={field.required} />\n <input\n readOnly value={formatJalaliDate(\n value, display\n ) ?? \"\"}\n />\n {showCalendar && <DayPicker\n captionLayout=\"dropdown\" disabled={readOnly} mode=\"single\"\n onSelect={chooseDay} selected={selected} showOutsideDays\n />}\n {showTime && (\n <div>\n <input\n disabled={readOnly} max={23} min={0}\n onChange={(event) => updateTime(\n \"hours\", event.target.value\n )} type=\"number\" value={selected?.getHours() ?? 0}\n />\n <span aria-hidden=\"true\">:</span>\n <input\n disabled={readOnly} max={59} min={0}\n onChange={(event) => updateTime(\n \"minutes\", event.target.value\n )} type=\"number\" value={selected?.getMinutes() ?? 0}\n />\n </div>\n )}\n {!readOnly && value && <button onClick={() => save(undefined)} type=\"button\">\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646</button>}\n </div>\n );\n};\n", "import { getDateLib } from \"react-day-picker/persian\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\n\nexport function canonicalizeJalaliPickerDate (\n date: Date, appearance: JalaliPickerAppearance\n): Date {\n const result = appearance === \"monthOnly\"\n ? getDateLib().startOfMonth(date)\n : new Date(date);\n\n if (appearance === \"dayOnly\" || appearance === \"monthOnly\") result.setHours(\n 12, 0, 0, 0\n );\n\n return result;\n}\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAAqC;AACrC,mBAAoC;AACpC,IAAAA,kBAA0B;AAC1B,mBAAO;;;ACLP,qBAA2B;AAIpB,SAAS,6BACd,MAAY,YACN;AACN,QAAM,SAAS,eAAe,kBAC1B,2BAAW,EAAE,aAAa,IAAI,IAC9B,IAAI,KAAK,IAAI;AAEjB,MAAI,eAAe,aAAa,eAAe,YAAa,QAAO;AAAA,IACjE;AAAA,IAAI;AAAA,IAAG;AAAA,IAAG;AAAA,EACZ;AAEA,SAAO;AACT;;;ACRO,SAAS,iBACd,OAAwB,UAAoC,CAAC,GAC9C;AACf,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,QAAM,OAAO,iBAAiB,OAAO,QAAQ,IAAI,KAAK,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gCACb;AAAA,gDAAC,wBAAW,SAAS,SAAS,IAAI,IAAI,OAAO,MAAM,OAAO,UAAU,MAAM,UAAU;AAAA,IACpF;AAAA,MAAC;AAAA;AAAA,QACC,UAAQ;AAAA,QAAC,OAAO;AAAA,UACd;AAAA,UAAO;AAAA,QACT,KAAK;AAAA;AAAA,IACP;AAAA,IACC,gBAAgB;AAAA,MAAC;AAAA;AAAA,QAChB,eAAc;AAAA,QAAW,UAAU;AAAA,QAAU,MAAK;AAAA,QAClD,UAAU;AAAA,QAAW;AAAA,QAAoB,iBAAe;AAAA;AAAA,IAC1D;AAAA,IACC,YACC,6CAAC,SACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UAAU,KAAK;AAAA,UAAI,KAAK;AAAA,UAClC,UAAU,CAAC,UAAU;AAAA,YACnB;AAAA,YAAS,MAAM,OAAO;AAAA,UACxB;AAAA,UAAG,MAAK;AAAA,UAAS,QAAO,qCAAU,eAAc;AAAA;AAAA,MAClD;AAAA,MACA,4CAAC,UAAK,eAAY,QAAO,eAAC;AAAA,MAC1B;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UAAU,KAAK;AAAA,UAAI,KAAK;AAAA,UAClC,UAAU,CAAC,UAAU;AAAA,YACnB;AAAA,YAAW,MAAM,OAAO;AAAA,UAC1B;AAAA,UAAG,MAAK;AAAA,UAAS,QAAO,qCAAU,iBAAgB;AAAA;AAAA,MACpD;AAAA,OACF;AAAA,IAED,CAAC,YAAY,SAAS,4CAAC,YAAO,SAAS,MAAM,KAAK,MAAS,GAAG,MAAK,UAAS,yDAAQ;AAAA,KACvF;AAEJ;",
6
- "names": ["import_persian"]
7
- }
@@ -1,135 +0,0 @@
1
- // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:56.848Z)
2
- "use client";
3
-
4
- // src/admin/jalali-date-field.tsx
5
- import { FieldLabel, useField } from "@payloadcms/ui";
6
- import { useEffect, useState } from "react";
7
- import { DayPicker } from "react-day-picker/persian";
8
- import "react-day-picker/style.css";
9
-
10
- // src/admin/jalali-picker-value.ts
11
- import { getDateLib } from "react-day-picker/persian";
12
- function canonicalizeJalaliPickerDate(date, appearance) {
13
- const result = appearance === "monthOnly" ? getDateLib().startOfMonth(date) : new Date(date);
14
- if (appearance === "dayOnly" || appearance === "monthOnly") result.setHours(
15
- 12,
16
- 0,
17
- 0,
18
- 0
19
- );
20
- return result;
21
- }
22
-
23
- // src/date/format-date.ts
24
- function formatJalaliDate(value, options = {}) {
25
- if (value === null || value === void 0) return null;
26
- const date = value instanceof Date ? value : new Date(value);
27
- if (Number.isNaN(date.getTime())) return null;
28
- const locale = options.digits === "latin" ? "fa-IR-u-ca-persian-nu-latn" : "fa-IR-u-ca-persian";
29
- return new Intl.DateTimeFormat(
30
- locale,
31
- {
32
- dateStyle: options.dateStyle ?? "medium",
33
- ...options.timeStyle ? { timeStyle: options.timeStyle } : {},
34
- ...options.timeZone ? { timeZone: options.timeZone } : {}
35
- }
36
- ).format(date);
37
- }
38
-
39
- // src/admin/jalali-date-field.tsx
40
- import { jsx, jsxs } from "react/jsx-runtime";
41
- var JalaliDateFieldComponent = ({
42
- field,
43
- path,
44
- appearance,
45
- display,
46
- readOnly
47
- }) => {
48
- const { value, setValue } = useField({ path });
49
- const [
50
- selected,
51
- setSelected
52
- ] = useState();
53
- useEffect(
54
- () => setSelected(value ? new Date(value) : void 0),
55
- [value]
56
- );
57
- const save = (date) => {
58
- setSelected(date);
59
- setValue(date ? date.toISOString() : null);
60
- };
61
- const chooseDay = (date) => {
62
- if (!date) return save(void 0);
63
- save(canonicalizeJalaliPickerDate(
64
- date,
65
- appearance
66
- ));
67
- };
68
- const updateTime = (part, raw) => {
69
- const base = selected ? new Date(selected) : /* @__PURE__ */ new Date();
70
- base[part === "hours" ? "setHours" : "setMinutes"](Number(raw));
71
- save(base);
72
- };
73
- const showCalendar = appearance !== "timeOnly";
74
- const showTime = appearance === "dayAndTime" || appearance === "timeOnly";
75
- return /* @__PURE__ */ jsxs("div", { className: "field-type jalali-date-field", children: [
76
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: `field-${path}`, label: field.label, required: field.required }),
77
- /* @__PURE__ */ jsx(
78
- "input",
79
- {
80
- readOnly: true,
81
- value: formatJalaliDate(
82
- value,
83
- display
84
- ) ?? ""
85
- }
86
- ),
87
- showCalendar && /* @__PURE__ */ jsx(
88
- DayPicker,
89
- {
90
- captionLayout: "dropdown",
91
- disabled: readOnly,
92
- mode: "single",
93
- onSelect: chooseDay,
94
- selected,
95
- showOutsideDays: true
96
- }
97
- ),
98
- showTime && /* @__PURE__ */ jsxs("div", { children: [
99
- /* @__PURE__ */ jsx(
100
- "input",
101
- {
102
- disabled: readOnly,
103
- max: 23,
104
- min: 0,
105
- onChange: (event) => updateTime(
106
- "hours",
107
- event.target.value
108
- ),
109
- type: "number",
110
- value: selected?.getHours() ?? 0
111
- }
112
- ),
113
- /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: ":" }),
114
- /* @__PURE__ */ jsx(
115
- "input",
116
- {
117
- disabled: readOnly,
118
- max: 59,
119
- min: 0,
120
- onChange: (event) => updateTime(
121
- "minutes",
122
- event.target.value
123
- ),
124
- type: "number",
125
- value: selected?.getMinutes() ?? 0
126
- }
127
- )
128
- ] }),
129
- !readOnly && value && /* @__PURE__ */ jsx("button", { onClick: () => save(void 0), type: "button", children: "\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646" })
130
- ] });
131
- };
132
- export {
133
- JalaliDateFieldComponent
134
- };
135
- //# sourceMappingURL=jalali-date-field.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/admin/jalali-date-field.tsx", "../../src/admin/jalali-picker-value.ts", "../../src/date/format-date.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport { FieldLabel, useField } from \"@payloadcms/ui\";\nimport { useEffect, useState } from \"react\";\nimport { DayPicker } from \"react-day-picker/persian\";\nimport \"react-day-picker/style.css\";\n\nimport { canonicalizeJalaliPickerDate } from \"./jalali-picker-value\";\nimport { formatJalaliDate, type JalaliDateDisplayOptions } from \"../date/format-date\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\nimport type { DateFieldClientProps } from \"payload\";\n\ntype Props = { appearance: JalaliPickerAppearance, display: JalaliDateDisplayOptions };\n\nexport const JalaliDateFieldComponent = ({\n field, path, appearance, display, readOnly,\n}: DateFieldClientProps & Props) => {\n const { value, setValue, } = useField<string | null>({ path, });\n const [\n selected,\n setSelected\n ] = useState<Date | undefined>();\n useEffect(\n () => setSelected(value ? new Date(value) : undefined), [value]\n );\n const save = (date: Date | undefined) => {\n setSelected(date);\n setValue(date ? date.toISOString() : null);\n };\n const chooseDay = (date: Date | undefined) => {\n if (!date) return save(undefined);\n save(canonicalizeJalaliPickerDate(\n date, appearance\n ));\n };\n const updateTime = (\n part: \"hours\" | \"minutes\", raw: string\n ) => {\n const base = selected ? new Date(selected) : new Date();\n base[part === \"hours\" ? \"setHours\" : \"setMinutes\"](Number(raw));\n save(base);\n };\n const showCalendar = appearance !== \"timeOnly\";\n const showTime = appearance === \"dayAndTime\" || appearance === \"timeOnly\";\n return (\n <div className=\"field-type jalali-date-field\">\n <FieldLabel htmlFor={`field-${path}`} label={field.label} required={field.required} />\n <input\n readOnly value={formatJalaliDate(\n value, display\n ) ?? \"\"}\n />\n {showCalendar && <DayPicker\n captionLayout=\"dropdown\" disabled={readOnly} mode=\"single\"\n onSelect={chooseDay} selected={selected} showOutsideDays\n />}\n {showTime && (\n <div>\n <input\n disabled={readOnly} max={23} min={0}\n onChange={(event) => updateTime(\n \"hours\", event.target.value\n )} type=\"number\" value={selected?.getHours() ?? 0}\n />\n <span aria-hidden=\"true\">:</span>\n <input\n disabled={readOnly} max={59} min={0}\n onChange={(event) => updateTime(\n \"minutes\", event.target.value\n )} type=\"number\" value={selected?.getMinutes() ?? 0}\n />\n </div>\n )}\n {!readOnly && value && <button onClick={() => save(undefined)} type=\"button\">\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646</button>}\n </div>\n );\n};\n", "import { getDateLib } from \"react-day-picker/persian\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\n\nexport function canonicalizeJalaliPickerDate (\n date: Date, appearance: JalaliPickerAppearance\n): Date {\n const result = appearance === \"monthOnly\"\n ? getDateLib().startOfMonth(date)\n : new Date(date);\n\n if (appearance === \"dayOnly\" || appearance === \"monthOnly\") result.setHours(\n 12, 0, 0, 0\n );\n\n return result;\n}\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"],
5
- "mappings": ";;;;AAEA,SAAS,YAAY,gBAAgB;AACrC,SAAS,WAAW,gBAAgB;AACpC,SAAS,iBAAiB;AAC1B,OAAO;;;ACLP,SAAS,kBAAkB;AAIpB,SAAS,6BACd,MAAY,YACN;AACN,QAAM,SAAS,eAAe,cAC1B,WAAW,EAAE,aAAa,IAAI,IAC9B,IAAI,KAAK,IAAI;AAEjB,MAAI,eAAe,aAAa,eAAe,YAAa,QAAO;AAAA,IACjE;AAAA,IAAI;AAAA,IAAG;AAAA,IAAG;AAAA,EACZ;AAEA,SAAO;AACT;;;ACRO,SAAS,iBACd,OAAwB,UAA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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/admin/jalali-picker-value.ts
22
- var jalali_picker_value_exports = {};
23
- __export(jalali_picker_value_exports, {
24
- canonicalizeJalaliPickerDate: () => canonicalizeJalaliPickerDate
25
- });
26
- module.exports = __toCommonJS(jalali_picker_value_exports);
27
- var import_persian = require("react-day-picker/persian");
28
- function canonicalizeJalaliPickerDate(date, appearance) {
29
- const result = appearance === "monthOnly" ? (0, import_persian.getDateLib)().startOfMonth(date) : new Date(date);
30
- if (appearance === "dayOnly" || appearance === "monthOnly") result.setHours(
31
- 12,
32
- 0,
33
- 0,
34
- 0
35
- );
36
- return result;
37
- }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- canonicalizeJalaliPickerDate
41
- });
42
- //# sourceMappingURL=jalali-picker-value.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/admin/jalali-picker-value.ts"],
4
- "sourcesContent": ["import { getDateLib } from \"react-day-picker/persian\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\n\nexport function canonicalizeJalaliPickerDate (\n date: Date, appearance: JalaliPickerAppearance\n): Date {\n const result = appearance === \"monthOnly\"\n ? getDateLib().startOfMonth(date)\n : new Date(date);\n\n if (appearance === \"dayOnly\" || appearance === \"monthOnly\") result.setHours(\n 12, 0, 0, 0\n );\n\n return result;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2B;AAIpB,SAAS,6BACd,MAAY,YACN;AACN,QAAM,SAAS,eAAe,kBAC1B,2BAAW,EAAE,aAAa,IAAI,IAC9B,IAAI,KAAK,IAAI;AAEjB,MAAI,eAAe,aAAa,eAAe,YAAa,QAAO;AAAA,IACjE;AAAA,IAAI;AAAA,IAAG;AAAA,IAAG;AAAA,EACZ;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,3 +0,0 @@
1
- import type { JalaliPickerAppearance } from "../date/picker-types";
2
- export declare function canonicalizeJalaliPickerDate(date: Date, appearance: JalaliPickerAppearance): Date;
3
- //# sourceMappingURL=jalali-picker-value.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jalali-picker-value.d.ts","sourceRoot":"","sources":["../../src/admin/jalali-picker-value.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,sBAAsB,GAC7C,IAAI,CAUN"}
@@ -1,18 +0,0 @@
1
- // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:56.848Z)
2
-
3
- // src/admin/jalali-picker-value.ts
4
- import { getDateLib } from "react-day-picker/persian";
5
- function canonicalizeJalaliPickerDate(date, appearance) {
6
- const result = appearance === "monthOnly" ? getDateLib().startOfMonth(date) : new Date(date);
7
- if (appearance === "dayOnly" || appearance === "monthOnly") result.setHours(
8
- 12,
9
- 0,
10
- 0,
11
- 0
12
- );
13
- return result;
14
- }
15
- export {
16
- canonicalizeJalaliPickerDate
17
- };
18
- //# sourceMappingURL=jalali-picker-value.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/admin/jalali-picker-value.ts"],
4
- "sourcesContent": ["import { getDateLib } from \"react-day-picker/persian\";\n\nimport type { JalaliPickerAppearance } from \"../date/picker-types\";\n\nexport function canonicalizeJalaliPickerDate (\n date: Date, appearance: JalaliPickerAppearance\n): Date {\n const result = appearance === \"monthOnly\"\n ? getDateLib().startOfMonth(date)\n : new Date(date);\n\n if (appearance === \"dayOnly\" || appearance === \"monthOnly\") result.setHours(\n 12, 0, 0, 0\n );\n\n return result;\n}\n"],
5
- "mappings": ";;;AAAA,SAAS,kBAAkB;AAIpB,SAAS,6BACd,MAAY,YACN;AACN,QAAM,SAAS,eAAe,cAC1B,WAAW,EAAE,aAAa,IAAI,IAC9B,IAAI,KAAK,IAAI;AAEjB,MAAI,eAAe,aAAa,eAAe,YAAa,QAAO;AAAA,IACjE;AAAA,IAAI;AAAA,IAAG;AAAA,IAAG;AAAA,EACZ;AAEA,SAAO;AACT;",
6
- "names": []
7
- }
@@ -1,146 +0,0 @@
1
- // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:57.614Z)
2
- "use strict";
3
- "use client";
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/admin/money-field.tsx
23
- var money_field_exports = {};
24
- __export(money_field_exports, {
25
- MoneyFieldComponent: () => MoneyFieldComponent
26
- });
27
- module.exports = __toCommonJS(money_field_exports);
28
- var import_ui = require("@payloadcms/ui");
29
- var import_react = require("react");
30
-
31
- // src/money/index.ts
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
-
90
- // src/admin/money-field.tsx
91
- var import_jsx_runtime = require("react/jsx-runtime");
92
- var MoneyFieldComponent = ({
93
- field,
94
- path,
95
- currency,
96
- display,
97
- readOnly
98
- }) => {
99
- const { value, setValue } = (0, import_ui.useField)({ path });
100
- const [
101
- input,
102
- setInput
103
- ] = (0, import_react.useState)("");
104
- (0, import_react.useEffect)(
105
- () => setInput(typeof value === "number" ? formatMoney(
106
- value,
107
- currency,
108
- { ...display, showCurrency: false }
109
- ) ?? "" : ""),
110
- [
111
- currency,
112
- display,
113
- value
114
- ]
115
- );
116
- const change = (next) => {
117
- setInput(next);
118
- if (!next.trim()) return setValue(null);
119
- try {
120
- setValue(parseMoneyToMinorUnits(
121
- next,
122
- currency
123
- ));
124
- } catch {
125
- setValue(next);
126
- }
127
- };
128
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "field-type money-field", children: [
129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.FieldLabel, { htmlFor: `field-${path}`, label: field.label, required: field.required }),
130
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
- "input",
132
- {
133
- inputMode: "decimal",
134
- onChange: (event) => change(event.target.value),
135
- readOnly,
136
- value: input
137
- }
138
- ),
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: currency.label })
140
- ] });
141
- };
142
- // Annotate the CommonJS export names for ESM import in node:
143
- 0 && (module.exports = {
144
- MoneyFieldComponent
145
- });
146
- //# sourceMappingURL=money-field.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/admin/money-field.tsx", "../../src/money/index.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport { FieldLabel, useField } from \"@payloadcms/ui\";\nimport { useEffect, useState } from \"react\";\n\nimport { formatMoney, parseMoneyToMinorUnits, type MoneyCurrencyDefinition, type MoneyDisplayOptions } from \"../money\";\n\nimport type { NumberFieldClientProps } from \"payload\";\n\ntype Props = { currency: MoneyCurrencyDefinition, display: MoneyDisplayOptions, allowNegative: boolean };\n\nexport const MoneyFieldComponent = ({\n field, path, currency, display, readOnly,\n}: NumberFieldClientProps & Props) => {\n const { value, setValue, } = useField<number | string | null>({ path, });\n const [\n input,\n setInput\n ] = useState(\"\");\n useEffect(\n () => setInput(typeof value === \"number\"\n ? (formatMoney(\n value, currency, { ...display, showCurrency: false, }\n ) ?? \"\")\n : \"\"), [\n currency,\n display,\n value\n ]\n );\n const change = (next: string) => {\n setInput(next);\n if (!next.trim()) return setValue(null);\n try {\n setValue(parseMoneyToMinorUnits(\n next, currency\n ));\n } catch { setValue(next); }\n };\n return (\n <div className=\"field-type money-field\">\n <FieldLabel htmlFor={`field-${path}`} label={field.label} required={field.required} />\n <input\n inputMode=\"decimal\" onChange={(event) => change(event.target.value)} readOnly={readOnly}\n value={input}\n />\n <span>\n {currency.label}\n </span>\n </div>\n );\n};\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gBAAqC;AACrC,mBAAoC;;;ACqB7B,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,O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