@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,154 @@
1
+ // @nexload-sdk/payload-fields v3.0.0 (build 2026-07-20T16:56:56.848Z)
2
+
3
+ // src/slug/format-slug.ts
4
+ var persianDigits = "\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9";
5
+ var arabicDigits = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
6
+ function normalizeDigits(value) {
7
+ return value.replace(
8
+ /[۰-۹٠-٩]/g,
9
+ (digit) => {
10
+ const index = persianDigits.indexOf(digit);
11
+ return String(index >= 0 ? index : arabicDigits.indexOf(digit));
12
+ }
13
+ );
14
+ }
15
+ function getPath(value, path) {
16
+ return path.split(".").reduce(
17
+ (current, key) => {
18
+ if (current && typeof current === "object") return current[key];
19
+ return void 0;
20
+ },
21
+ value
22
+ );
23
+ }
24
+ function hasPath(value, path) {
25
+ return path.split(".").every((key) => {
26
+ if (!value || typeof value !== "object" || !(key in value)) return false;
27
+ value = value[key];
28
+ return true;
29
+ });
30
+ }
31
+ function formatSlug(value) {
32
+ return normalizeDigits(value.normalize("NFKC")).replace(
33
+ /[يى]/g,
34
+ "\u06CC"
35
+ ).replace(
36
+ /ك/g,
37
+ "\u06A9"
38
+ ).replace(
39
+ /[\u064B-\u065F\u0670]/g,
40
+ ""
41
+ ).replace(
42
+ /[\s_]+/g,
43
+ "-"
44
+ ).replace(
45
+ /[^\p{L}\p{N}-]+/gu,
46
+ ""
47
+ ).replace(
48
+ /-+/g,
49
+ "-"
50
+ ).replace(
51
+ /^-+|-+$/g,
52
+ ""
53
+ );
54
+ }
55
+ var formatSlugHook = (options) => ({
56
+ data,
57
+ operation,
58
+ originalDoc,
59
+ siblingData,
60
+ previousSiblingDoc,
61
+ value
62
+ }) => {
63
+ const lock = siblingData?.[options.lockName] ?? data?.[options.lockName];
64
+ const previousSlug = previousSiblingDoc?.[options.name] ?? originalDoc?.[options.name];
65
+ const sourceChanged = hasPath(
66
+ data,
67
+ options.source
68
+ ) && getPath(
69
+ data,
70
+ options.source
71
+ ) !== getPath(
72
+ originalDoc,
73
+ options.source
74
+ );
75
+ const source = hasPath(
76
+ data,
77
+ options.source
78
+ ) ? getPath(
79
+ data,
80
+ options.source
81
+ ) : getPath(
82
+ originalDoc,
83
+ options.source
84
+ );
85
+ if (lock !== false && typeof source === "string" && source.trim() && (operation === "create" || options.regenerateOnSourceChange && sourceChanged)) {
86
+ return formatSlug(source);
87
+ }
88
+ if (operation === "update" && lock !== false && sourceChanged && !source && previousSlug !== void 0) {
89
+ return previousSlug;
90
+ }
91
+ if (lock !== false && operation === "update" && previousSlug !== void 0) return previousSlug;
92
+ if (typeof value === "string") return formatSlug(value);
93
+ return value;
94
+ };
95
+
96
+ // src/slug/index.ts
97
+ function slugField(options = {}) {
98
+ const name = options.name ?? "slug";
99
+ const lockName = options.lockName ?? `${name}Lock`;
100
+ const source = options.source ?? "title";
101
+ const localized = options.overrides?.slug?.localized === true;
102
+ if (options.overrides?.slug?.name && options.overrides.slug.name !== name) throw new Error("Slug field name is protected.");
103
+ if (options.overrides?.lock?.name && options.overrides.lock.name !== lockName) throw new Error("Slug lock name is protected.");
104
+ if (options.overrides?.lock?.localized !== void 0 && options.overrides.lock.localized !== localized) throw new Error("Slug lock localization must match slug localization.");
105
+ if (options.overrides?.slug?.type && options.overrides.slug.type !== "text") throw new Error("Slug field type is protected.");
106
+ if (options.overrides?.lock?.type && options.overrides.lock.type !== "checkbox") throw new Error("Slug lock type is protected.");
107
+ const slugOverrides = options.overrides?.slug ?? {};
108
+ const lockOverrides = options.overrides?.lock ?? {};
109
+ const consumerHooks = slugOverrides.hooks?.beforeValidate ?? [];
110
+ const slug = {
111
+ ...slugOverrides,
112
+ name,
113
+ type: "text",
114
+ index: slugOverrides.index ?? true,
115
+ localized,
116
+ admin: {
117
+ ...slugOverrides.admin,
118
+ position: slugOverrides.admin?.position ?? "sidebar",
119
+ components: {
120
+ ...slugOverrides.admin?.components,
121
+ Field: {
122
+ path: "@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent",
123
+ clientProps: { source, lockName, generator: options.generator }
124
+ }
125
+ }
126
+ },
127
+ custom: { ...slugOverrides.custom, nexload: { ...slugOverrides.custom?.nexload, slug: { source, lockName, generator: options.generator } } },
128
+ hooks: {
129
+ ...slugOverrides.hooks,
130
+ beforeValidate: [
131
+ ...consumerHooks,
132
+ formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true })
133
+ ]
134
+ }
135
+ };
136
+ const lock = {
137
+ ...lockOverrides,
138
+ name: lockName,
139
+ type: "checkbox",
140
+ localized,
141
+ defaultValue: true,
142
+ admin: { ...lockOverrides.admin, hidden: true, position: lockOverrides.admin?.position ?? "sidebar" }
143
+ };
144
+ return [
145
+ slug,
146
+ lock
147
+ ];
148
+ }
149
+ export {
150
+ formatSlug,
151
+ formatSlugHook,
152
+ slugField
153
+ };
154
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/slug/format-slug.ts", "../../src/slug/index.ts"],
4
+ "sourcesContent": ["import type { FieldHook } from \"payload\";\n\nexport type SlugHookOptions = {\n name: string\n lockName: string\n source: string\n regenerateOnSourceChange: boolean\n};\n\nconst persianDigits = \"\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9\";\nconst arabicDigits = \"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\";\n\nfunction normalizeDigits (value: string): string {\n return value.replace(\n /[\u06F0-\u06F9\u0660-\u0669]/g, (digit) => {\n const index = persianDigits.indexOf(digit);\n return String(index >= 0 ? index : arabicDigits.indexOf(digit));\n }\n );\n}\n\nfunction getPath (\n value: unknown, path: string\n): unknown {\n return path.split(\".\").reduce<unknown>(\n (\n current, key\n ) => {\n if (current && typeof current === \"object\") return (current as Record<string, unknown>)[key];\n return undefined;\n }, value\n );\n}\n\nfunction hasPath (\n value: unknown, path: string\n): boolean {\n return path.split(\".\").every((key) => {\n if (!value || typeof value !== \"object\" || !(key in value)) return false;\n value = (value as Record<string, unknown>)[key];\n return true;\n });\n}\n\nexport function formatSlug (value: string): string {\n return normalizeDigits(value.normalize(\"NFKC\"))\n .replace(\n /[\u064A\u0649]/g, \"\u06CC\"\n )\n .replace(\n /\u0643/g, \"\u06A9\"\n )\n .replace(\n /[\\u064B-\\u065F\\u0670]/g, \"\"\n )\n .replace(\n /[\\s_]+/g, \"-\"\n )\n .replace(\n /[^\\p{L}\\p{N}-]+/gu, \"\"\n )\n .replace(\n /-+/g, \"-\"\n )\n .replace(\n /^-+|-+$/g, \"\"\n );\n}\n\nexport const formatSlugHook = (options: SlugHookOptions): FieldHook => ({\n data,\n operation,\n originalDoc,\n siblingData,\n previousSiblingDoc,\n value,\n}) => {\n const lock = siblingData?.[options.lockName] ?? data?.[options.lockName];\n const previousSlug = previousSiblingDoc?.[options.name] ?? originalDoc?.[options.name];\n const sourceChanged = hasPath(\n data, options.source\n )\n && getPath(\n data, options.source\n ) !== getPath(\n originalDoc, options.source\n );\n const source = hasPath(\n data, options.source\n )\n ? getPath(\n data, options.source\n )\n : getPath(\n originalDoc, options.source\n );\n\n if (lock !== false && typeof source === \"string\" && source.trim() && (operation === \"create\" || (options.regenerateOnSourceChange && sourceChanged))) {\n return formatSlug(source);\n }\n\n if (operation === \"update\" && lock !== false && sourceChanged && !source && previousSlug !== undefined) {\n return previousSlug;\n }\n\n if (lock !== false && operation === \"update\" && previousSlug !== undefined) return previousSlug;\n if (typeof value === \"string\") return formatSlug(value);\n return value;\n};\n", "import { formatSlugHook } from \"./format-slug\";\n\nimport type { CheckboxField, TextField } from \"payload\";\n\nexport type SlugFieldOptions = {\n name?: string\n lockName?: string\n source?: string\n generator?: string\n regenerateOnSourceChange?: boolean\n overrides?: { slug?: Partial<TextField>, lock?: Partial<CheckboxField> }\n};\n\nexport type SlugFieldResult = readonly [TextField, CheckboxField];\n\nexport function slugField (options: SlugFieldOptions = {}): SlugFieldResult {\n const name = options.name ?? \"slug\";\n const lockName = options.lockName ?? `${name}Lock`;\n const source = options.source ?? \"title\";\n const localized = options.overrides?.slug?.localized === true;\n if (options.overrides?.slug?.name && options.overrides.slug.name !== name) throw new Error(\"Slug field name is protected.\");\n if (options.overrides?.lock?.name && options.overrides.lock.name !== lockName) throw new Error(\"Slug lock name is protected.\");\n if (options.overrides?.lock?.localized !== undefined && options.overrides.lock.localized !== localized) throw new Error(\"Slug lock localization must match slug localization.\");\n if (options.overrides?.slug?.type && options.overrides.slug.type !== \"text\") throw new Error(\"Slug field type is protected.\");\n if (options.overrides?.lock?.type && options.overrides.lock.type !== \"checkbox\") throw new Error(\"Slug lock type is protected.\");\n\n const slugOverrides = options.overrides?.slug ?? {};\n const lockOverrides = options.overrides?.lock ?? {};\n const consumerHooks = slugOverrides.hooks?.beforeValidate ?? [];\n const slug: TextField = {\n ...slugOverrides,\n name,\n type: \"text\",\n index: slugOverrides.index ?? true,\n localized,\n admin: {\n ...slugOverrides.admin,\n position: slugOverrides.admin?.position ?? \"sidebar\",\n components: {\n ...slugOverrides.admin?.components,\n Field: {\n path: \"@nexload-sdk/payload-fields/admin/slug-field#SlugFieldComponent\",\n clientProps: { source, lockName, generator: options.generator, },\n },\n },\n },\n custom: { ...slugOverrides.custom, nexload: { ...(slugOverrides.custom?.nexload as object), slug: { source, lockName, generator: options.generator, }, }, },\n hooks: {\n ...slugOverrides.hooks, beforeValidate: [\n ...consumerHooks,\n formatSlugHook({ name, lockName, source, regenerateOnSourceChange: options.regenerateOnSourceChange ?? true, })\n ],\n },\n } as TextField;\n const lock: CheckboxField = {\n ...lockOverrides,\n name: lockName,\n type: \"checkbox\",\n localized,\n defaultValue: true,\n admin: { ...lockOverrides.admin, hidden: true, position: lockOverrides.admin?.position ?? \"sidebar\", },\n } as CheckboxField;\n return [\n slug,\n lock\n ];\n}\n\nexport * from \"./format-slug\";\n"],
5
+ "mappings": ";;;AASA,IAAM,gBAAgB;AACtB,IAAM,eAAe;AAErB,SAAS,gBAAiB,OAAuB;AAC/C,SAAO,MAAM;AAAA,IACX;AAAA,IAAa,CAAC,UAAU;AACtB,YAAM,QAAQ,cAAc,QAAQ,KAAK;AACzC,aAAO,OAAO,SAAS,IAAI,QAAQ,aAAa,QAAQ,KAAK,CAAC;AAAA,IAChE;AAAA,EACF;AACF;AAEA,SAAS,QACP,OAAgB,MACP;AACT,SAAO,KAAK,MAAM,GAAG,EAAE;AAAA,IACrB,CACE,SAAS,QACN;AACH,UAAI,WAAW,OAAO,YAAY,SAAU,QAAQ,QAAoC,GAAG;AAC3F,aAAO;AAAA,IACT;AAAA,IAAG;AAAA,EACL;AACF;AAEA,SAAS,QACP,OAAgB,MACP;AACT,SAAO,KAAK,MAAM,GAAG,EAAE,MAAM,CAAC,QAAQ;AACpC,QAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,OAAO,OAAQ,QAAO;AACnE,YAAS,MAAkC,GAAG;AAC9C,WAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,WAAY,OAAuB;AACjD,SAAO,gBAAgB,MAAM,UAAU,MAAM,CAAC,EAC3C;AAAA,IACC;AAAA,IAAS;AAAA,EACX,EACC;AAAA,IACC;AAAA,IAAM;AAAA,EACR,EACC;AAAA,IACC;AAAA,IAA0B;AAAA,EAC5B,EACC;AAAA,IACC;AAAA,IAAW;AAAA,EACb,EACC;AAAA,IACC;AAAA,IAAqB;AAAA,EACvB,EACC;AAAA,IACC;AAAA,IAAO;AAAA,EACT,EACC;AAAA,IACC;AAAA,IAAY;AAAA,EACd;AACJ;AAEO,IAAM,iBAAiB,CAAC,YAAwC,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,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AAE,GAAG,cAAc,OAAO,QAAQ,MAAM,UAAU,cAAc,OAAO,YAAY,UAAW;AAAA,EACvG;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexload-sdk/payload-fields",
3
- "version": "2.0.1",
4
- "description": "A collection of powerful, production-ready, and beautifully designed fields for Payload CMS, including an advanced date picker, automatic slug generator, and a feature-rich Lexical editor.",
3
+ "version": "3.1.0",
4
+ "description": "Production-grade semantic field factories and Admin integrations for Payload CMS.",
5
5
  "keywords": [
6
6
  "payload",
7
7
  "payloadcms",
@@ -10,10 +10,9 @@
10
10
  "fields",
11
11
  "custom-fields",
12
12
  "typescript",
13
- "lexical",
14
- "editor",
15
13
  "slug",
16
- "date-picker",
14
+ "jalali",
15
+ "money",
17
16
  "nexload",
18
17
  "sdk"
19
18
  ],
@@ -23,30 +22,40 @@
23
22
  "import": "./dist/index.mjs",
24
23
  "require": "./dist/index.cjs"
25
24
  },
25
+ "./slug": {
26
+ "types": "./dist/slug/index.d.ts",
27
+ "import": "./dist/slug/index.mjs",
28
+ "require": "./dist/slug/index.cjs"
29
+ },
26
30
  "./date": {
27
31
  "types": "./dist/date/index.d.ts",
28
32
  "import": "./dist/date/index.mjs",
29
33
  "require": "./dist/date/index.cjs"
30
34
  },
31
- "./date/date-picker": {
32
- "types": "./dist/date/date-picker.d.ts",
33
- "import": "./dist/date/date-picker.mjs",
34
- "require": "./dist/date/date-picker.cjs"
35
+ "./money": {
36
+ "types": "./dist/money/index.d.ts",
37
+ "import": "./dist/money/index.mjs",
38
+ "require": "./dist/money/index.cjs"
35
39
  },
36
- "./date/date-cell": {
37
- "types": "./dist/date/date-cell.d.ts",
38
- "import": "./dist/date/date-cell.mjs",
39
- "require": "./dist/date/date-cell.cjs"
40
+ "./admin/slug-field": {
41
+ "types": "./dist/admin/slug-field.d.ts",
42
+ "import": "./dist/admin/slug-field.mjs",
43
+ "require": "./dist/admin/slug-field.cjs"
40
44
  },
41
- "./slug": {
42
- "types": "./dist/slug/index.d.ts",
43
- "import": "./dist/slug/index.mjs",
44
- "require": "./dist/slug/index.cjs"
45
+ "./admin/jalali-date-field": {
46
+ "types": "./dist/admin/jalali-date-field.d.ts",
47
+ "import": "./dist/admin/jalali-date-field.mjs",
48
+ "require": "./dist/admin/jalali-date-field.cjs"
49
+ },
50
+ "./admin/jalali-date-cell": {
51
+ "types": "./dist/admin/jalali-date-cell.d.ts",
52
+ "import": "./dist/admin/jalali-date-cell.mjs",
53
+ "require": "./dist/admin/jalali-date-cell.cjs"
45
54
  },
46
- "./slug/slug-field": {
47
- "types": "./dist/slug/slug-field.d.ts",
48
- "import": "./dist/slug/slug-field.mjs",
49
- "require": "./dist/slug/slug-field.cjs"
55
+ "./admin/money-field": {
56
+ "types": "./dist/admin/money-field.d.ts",
57
+ "import": "./dist/admin/money-field.mjs",
58
+ "require": "./dist/admin/money-field.cjs"
50
59
  }
51
60
  },
52
61
  "files": [
@@ -58,15 +67,20 @@
58
67
  "access": "public"
59
68
  },
60
69
  "dependencies": {
61
- "@payloadcms/richtext-lexical": "^3.68.5",
62
- "@payloadcms/ui": "^3.68.5",
63
- "date-fns-jalali": "4.1.0-0",
64
- "payload": "^3.68.5",
65
- "react": "^19.2.3",
66
70
  "react-day-picker": "^9.12.0"
67
71
  },
72
+ "peerDependencies": {
73
+ "@payloadcms/ui": ">=3.68.5 <4",
74
+ "payload": ">=3.68.5 <4",
75
+ "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
76
+ "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1"
77
+ },
68
78
  "devDependencies": {
69
79
  "@types/react": "^19.2.7",
80
+ "@payloadcms/ui": "3.68.5",
81
+ "payload": "3.68.5",
82
+ "react": "^19.2.3",
83
+ "react-dom": "^19.2.3",
70
84
  "eslint": "^9.39.2",
71
85
  "typescript": "5.9.3",
72
86
  "@nexload-sdk/bundler": "4.0.1",
@@ -75,6 +89,7 @@
75
89
  },
76
90
  "scripts": {
77
91
  "build": "node esbuild.config.mjs",
78
- "lint": "eslint . --ext .ts,.tsx"
92
+ "lint": "eslint src --ext .ts,.tsx",
93
+ "test": "node --test test/*.test.mjs"
79
94
  }
80
95
  }
@@ -1,60 +0,0 @@
1
- // @nexload-sdk/payload-fields v2.0.0 (build 2026-06-21T16:01:23.950Z)
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/date/date-cell.tsx
23
- var date_cell_exports = {};
24
- __export(date_cell_exports, {
25
- DateCell: () => DateCell
26
- });
27
- module.exports = __toCommonJS(date_cell_exports);
28
-
29
- // src/date/format-date.ts
30
- var import_date_fns_jalali = require("date-fns-jalali");
31
- function formatDate(_date) {
32
- if (!_date) return "";
33
- const date = typeof _date === "string" ? new Date(_date) : _date;
34
- let formatted;
35
- try {
36
- formatted = (0, import_date_fns_jalali.format)(
37
- date,
38
- "EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm"
39
- );
40
- } catch (err) {
41
- console.error(
42
- "error formatting date:",
43
- err
44
- );
45
- formatted = date.toLocaleDateString("fa-IR");
46
- }
47
- return formatted;
48
- }
49
-
50
- // src/date/date-cell.tsx
51
- var import_jsx_runtime = require("react/jsx-runtime");
52
- var DateCell = ({ cellData }) => {
53
- if (!cellData) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "\u2014" });
54
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: formatDate(cellData) });
55
- };
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- DateCell
59
- });
60
- //# sourceMappingURL=date-cell.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/date/date-cell.tsx", "../../src/date/format-date.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport React from \"react\";\n\nimport { formatDate } from \"./format-date\";\n\ninterface Props { cellData?: string | Date | null }\n\nexport const DateCell: React.FC<Props> = ({ cellData, }) => {\n if (!cellData) return <>\u2014</>;\n\n return (\n <>\n {formatDate(cellData)}\n </>\n );\n};\n", "import { format as formatJalali } from \"date-fns-jalali\";\n\nexport function formatDate (_date?: Date | string): string {\n if (!_date) return \"\";\n\n const date = typeof _date === \"string\" ? new Date(_date) : _date;\n\n let formatted: string;\n try {\n formatted = formatJalali(\n date, \"EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm\"\n );\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n \"error formatting date:\", err\n );\n // if error, show ISO simple\n formatted = date.toLocaleDateString(\"fa-IR\");\n }\n\n return formatted;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,6BAAuC;AAEhC,SAAS,WAAY,OAA+B;AACzD,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,OAAO,OAAO,UAAU,WAAW,IAAI,KAAK,KAAK,IAAI;AAE3D,MAAI;AACJ,MAAI;AACF,oBAAY,uBAAAA;AAAA,MACV;AAAA,MAAM;AAAA,IACR;AAAA,EACF,SAAS,KAAK;AAEZ,YAAQ;AAAA,MACN;AAAA,MAA0B;AAAA,IAC5B;AAEA,gBAAY,KAAK,mBAAmB,OAAO;AAAA,EAC7C;AAEA,SAAO;AACT;;;ADbwB;AADjB,IAAM,WAA4B,CAAC,EAAE,SAAU,MAAM;AAC1D,MAAI,CAAC,SAAU,QAAO,2EAAE,oBAAC;AAEzB,SACE,2EACG,qBAAW,QAAQ,GACtB;AAEJ;",
6
- "names": ["formatJalali"]
7
- }
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- interface Props {
3
- cellData?: string | Date | null;
4
- }
5
- export declare const DateCell: React.FC<Props>;
6
- export {};
7
- //# sourceMappingURL=date-cell.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-cell.d.ts","sourceRoot":"","sources":["../../src/date/date-cell.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,KAAK;IAAG,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;CAAE;AAEnD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAQpC,CAAC"}
@@ -1,34 +0,0 @@
1
- // @nexload-sdk/payload-fields v2.0.0 (build 2026-06-21T16:01:23.386Z)
2
- "use client";
3
-
4
- // src/date/format-date.ts
5
- import { format as formatJalali } from "date-fns-jalali";
6
- function formatDate(_date) {
7
- if (!_date) return "";
8
- const date = typeof _date === "string" ? new Date(_date) : _date;
9
- let formatted;
10
- try {
11
- formatted = formatJalali(
12
- date,
13
- "EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm"
14
- );
15
- } catch (err) {
16
- console.error(
17
- "error formatting date:",
18
- err
19
- );
20
- formatted = date.toLocaleDateString("fa-IR");
21
- }
22
- return formatted;
23
- }
24
-
25
- // src/date/date-cell.tsx
26
- import { Fragment, jsx } from "react/jsx-runtime";
27
- var DateCell = ({ cellData }) => {
28
- if (!cellData) return /* @__PURE__ */ jsx(Fragment, { children: "\u2014" });
29
- return /* @__PURE__ */ jsx(Fragment, { children: formatDate(cellData) });
30
- };
31
- export {
32
- DateCell
33
- };
34
- //# sourceMappingURL=date-cell.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/date/format-date.ts", "../../src/date/date-cell.tsx"],
4
- "sourcesContent": ["import { format as formatJalali } from \"date-fns-jalali\";\n\nexport function formatDate (_date?: Date | string): string {\n if (!_date) return \"\";\n\n const date = typeof _date === \"string\" ? new Date(_date) : _date;\n\n let formatted: string;\n try {\n formatted = formatJalali(\n date, \"EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm\"\n );\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n \"error formatting date:\", err\n );\n // if error, show ISO simple\n formatted = date.toLocaleDateString(\"fa-IR\");\n }\n\n return formatted;\n}\n", "\"use client\";\n\nimport React from \"react\";\n\nimport { formatDate } from \"./format-date\";\n\ninterface Props { cellData?: string | Date | null }\n\nexport const DateCell: React.FC<Props> = ({ cellData, }) => {\n if (!cellData) return <>\u2014</>;\n\n return (\n <>\n {formatDate(cellData)}\n </>\n );\n};\n"],
5
- "mappings": ";;;;AAAA,SAAS,UAAU,oBAAoB;AAEhC,SAAS,WAAY,OAA+B;AACzD,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,OAAO,OAAO,UAAU,WAAW,IAAI,KAAK,KAAK,IAAI;AAE3D,MAAI;AACJ,MAAI;AACF,gBAAY;AAAA,MACV;AAAA,MAAM;AAAA,IACR;AAAA,EACF,SAAS,KAAK;AAEZ,YAAQ;AAAA,MACN;AAAA,MAA0B;AAAA,IAC5B;AAEA,gBAAY,KAAK,mBAAmB,OAAO;AAAA,EAC7C;AAEA,SAAO;AACT;;;ACbwB;AADjB,IAAM,WAA4B,CAAC,EAAE,SAAU,MAAM;AAC1D,MAAI,CAAC,SAAU,QAAO,gCAAE,oBAAC;AAEzB,SACE,gCACG,qBAAW,QAAQ,GACtB;AAEJ;",
6
- "names": []
7
- }
@@ -1,221 +0,0 @@
1
- // @nexload-sdk/payload-fields v2.0.0 (build 2026-06-21T16:01:23.950Z)
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/date/date-picker.tsx
23
- var date_picker_exports = {};
24
- __export(date_picker_exports, {
25
- DatePicker: () => DatePicker
26
- });
27
- module.exports = __toCommonJS(date_picker_exports);
28
- var import_ui = require("@payloadcms/ui");
29
- var import_react = require("react");
30
- var import_persian = require("react-day-picker/persian");
31
- var import_style = require("react-day-picker/style.css");
32
-
33
- // src/date/format-date.ts
34
- var import_date_fns_jalali = require("date-fns-jalali");
35
- function formatDate(_date) {
36
- if (!_date) return "";
37
- const date = typeof _date === "string" ? new Date(_date) : _date;
38
- let formatted;
39
- try {
40
- formatted = (0, import_date_fns_jalali.format)(
41
- date,
42
- "EEEE d MMMM y \u0633\u0627\u0639\u062A HH:mm"
43
- );
44
- } catch (err) {
45
- console.error(
46
- "error formatting date:",
47
- err
48
- );
49
- formatted = date.toLocaleDateString("fa-IR");
50
- }
51
- return formatted;
52
- }
53
-
54
- // src/date/index.scss
55
- var css = `.jalali-date-field {
56
- position: relative;
57
- }
58
- .jalali-date-field:focus-within > .jalali-date-picker {
59
- max-height: 32rem;
60
- min-height: 30rem;
61
- padding: 1rem;
62
- border: 1px solid var(--theme-elevation-150);
63
- box-shadow: 0 1.5rem 3rem -2rem var(--theme-elevation-250);
64
- opacity: 1;
65
- }
66
- .jalali-date-field .jalali-date-picker {
67
- max-height: 0rem;
68
- min-height: 0rem;
69
- padding: 0rem;
70
- border: 0px solid var(--theme-elevation-150);
71
- box-shadow: 0 0 0 0 var(--theme-elevation-250);
72
- opacity: 0;
73
- transition: box-shadow 0.3s ease-in-out, max-height 0.6s ease-in-out, min-height 0.3s ease-in-out, padding 0.1s ease-in-out, border 0.1s ease-in-out, opacity 0.15s ease-in-out;
74
- display: flex;
75
- flex-direction: column;
76
- align-items: center;
77
- justify-content: center;
78
- position: absolute;
79
- overflow: hidden;
80
- border-radius: var(--style-radius-l);
81
- top: 110%;
82
- font-family: var(--font-body);
83
- width: 100%;
84
- height: 100%;
85
- min-width: 26rem;
86
- max-width: 28rem;
87
- z-index: 9999;
88
- background: var(--theme-input-bg);
89
- right: 50%;
90
- translate: 50% 0;
91
- }
92
- @supports (backdrop-filter: blur(0.1rem)) {
93
- .jalali-date-field .jalali-date-picker {
94
- backdrop-filter: blur(1.5rem);
95
- background: var(--theme-elevation-150)/40%;
96
- }
97
- }
98
- .jalali-date-field .jalali-date-picker .jalali-date-picker-input {
99
- display: flex;
100
- align-items: center;
101
- justify-content: center;
102
- gap: 0.5rem;
103
- width: 100%;
104
- }
105
- .jalali-date-field .jalali-date-picker .jalali-date-picker-input span {
106
- font-size: 3rem;
107
- }
108
- .jalali-date-field .jalali-date-picker .jalali-date-picker-input input {
109
- -moz-appearance: textfield;
110
- appearance: textfield;
111
- text-align: center;
112
- flex-grow: 1;
113
- font-size: 1.5rem;
114
- padding: 0.5rem;
115
- border: 1px solid var(--theme-elevation-150);
116
- border-radius: var(--style-radius-l);
117
- }
118
- .jalali-date-field .jalali-date-picker .jalali-date-picker-input input::-webkit-outer-spin-button,
119
- .jalali-date-field .jalali-date-picker .jalali-date-picker-input input::-webkit-inner-spin-button {
120
- /* display: none; <- Crashes Chrome on hover */
121
- -webkit-appearance: none;
122
- margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
123
- }
124
- /*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VSb290IjoiL1VzZXJzL21tMjV6YW1hbmlhbi9Db2Rlcy9uZXhsb2FkLXNkay9wYWNrYWdlcy9wYXlsb2FkLWZpZWxkcy9zcmMvZGF0ZSIsInNvdXJjZXMiOlsiaW5kZXguc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtFQUNFOztBQUVBO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBOztBQUdGO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBRUEsWUFDRTtFQU9GO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUVBO0VBQ0E7O0FBRUE7RUFuQ0Y7SUFvQ0k7SUFDQTs7O0FBR0Y7RUFDRTtFQUNBO0VBQ0E7RUFDQTtFQUNBOztBQUVBO0VBQ0U7O0FBR0Y7RUFDRTtFQUNBO0VBRUE7RUFDQTtFQUNBO0VBQ0E7RUFDQTtFQUNBOztBQUdGO0FBQUE7QUFFRTtFQUNBO0VBQ0EiLCJzb3VyY2VzQ29udGVudCI6WyIuamFsYWxpLWRhdGUtZmllbGQge1xuICBwb3NpdGlvbjogcmVsYXRpdmU7XG5cbiAgJjpmb2N1cy13aXRoaW4gPiAuamFsYWxpLWRhdGUtcGlja2VyIHtcbiAgICBtYXgtaGVpZ2h0OiAzMnJlbTtcbiAgICBtaW4taGVpZ2h0OiAzMHJlbTtcbiAgICBwYWRkaW5nOiAxcmVtO1xuICAgIGJvcmRlcjogMXB4IHNvbGlkIHZhcigtLXRoZW1lLWVsZXZhdGlvbi0xNTApO1xuICAgIGJveC1zaGFkb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bi1idXR0b24sXG4gICAgICBpbnB1dDo6LXdlYmtpdC1pbm5lci1zcGluLWJ1dHRvbiB7XG4gICAgICAgIC8qIGRpc3BsYXk6IG5vbmU7IDwtIENyYXNoZXMgQ2hyb21lIG9uIGhvdmVyICovXG4gICAgICAgIC13ZWJraXQtYXBwZWFyYW5jZTogbm9uZTtcbiAgICAgICAgbWFyZ2luOiAwOyAvKiA8LS0gQXBwYXJlbnRseSBzb21lIG1hcmdpbiBhcmUgc3RpbGwgdGhlcmUgZXZlbiB0aG91Z2ggaXQncyBoaWRkZW4gKi9cbiAgICAgIH1cbiAgICB9XG4gIH1cbn1cbiJdfQ== */`;
125
- if (typeof document !== "undefined" && document.head) {
126
- document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
127
- }
128
-
129
- // src/date/date-picker.tsx
130
- var import_jsx_runtime = require("react/jsx-runtime");
131
- var DatePicker = ({
132
- path,
133
- field: { label }
134
- }) => {
135
- const { value, setValue } = (0, import_ui.useField)({ path });
136
- const [
137
- selected,
138
- setSelected
139
- ] = (0, import_react.useState)(void 0);
140
- (0, import_react.useEffect)(
141
- () => {
142
- if (value) {
143
- setSelected(new Date(value));
144
- }
145
- },
146
- [value]
147
- );
148
- const handleChange = (date) => {
149
- setSelected(date);
150
- if (date) {
151
- setValue(date.toISOString());
152
- }
153
- };
154
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "field-type text jalali-date-field", tabIndex: 0, children: [
155
- label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "field-label", htmlFor: path, children: String(label) }),
156
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
- "input",
158
- {
159
- readOnly: true,
160
- type: "text",
161
- value: (value && formatDate(value)) ?? void 0
162
- }
163
- ),
164
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "jalali-date-picker", children: [
165
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
166
- import_persian.DayPicker,
167
- {
168
- animate: true,
169
- captionLayout: "dropdown",
170
- mode: "single",
171
- navLayout: "around",
172
- onSelect: handleChange,
173
- required: false,
174
- selected,
175
- showOutsideDays: true
176
- }
177
- ),
178
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", {}),
179
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "jalali-date-picker-input", children: [
180
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
- "input",
182
- {
183
- max: 59,
184
- min: 0,
185
- onInput: (e) => {
186
- if (!selected) return;
187
- const target = e.target;
188
- const newDate = new Date(selected);
189
- newDate.setMinutes(target.valueAsNumber);
190
- handleChange(newDate);
191
- },
192
- type: "number",
193
- value: (selected == null ? void 0 : selected.getMinutes()) ?? 0
194
- }
195
- ),
196
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: ":" }),
197
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
198
- "input",
199
- {
200
- max: 23,
201
- min: 0,
202
- onInput: (e) => {
203
- if (!selected) return;
204
- const target = e.target;
205
- const newDate = new Date(selected);
206
- newDate.setHours(target.valueAsNumber);
207
- handleChange(newDate);
208
- },
209
- type: "number",
210
- value: (selected == null ? void 0 : selected.getHours()) ?? 0
211
- }
212
- )
213
- ] })
214
- ] })
215
- ] });
216
- };
217
- // Annotate the CommonJS export names for ESM import in node:
218
- 0 && (module.exports = {
219
- DatePicker
220
- });
221
- //# sourceMappingURL=date-picker.cjs.map