cja-phoenix 0.14.3 → 0.14.5

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.
@@ -1839,13 +1839,26 @@ const Om = (e, t) => {
1839
1839
  }), Am = (e, t) => {
1840
1840
  const a = (t == null ? void 0 : t.format) == "mm/yyyy" ? 2 : 3, n = (t == null ? void 0 : t.format) == "mm/yyyy" ? 1 : 2;
1841
1841
  let r = go().transform(
1842
- (s, i) => !(i instanceof Date) && ((t == null ? void 0 : t.format) == "dd/mm/yyyy" || !(t != null && t.format)) && i.split("/").length == 3 && i.split("/")[2].length == 4 || (t == null ? void 0 : t.format) == "mm/yyyy" && i.split("/").length == 2 && i.split("/")[1].length == 4 ? new Date(i.split("/").reverse().join("-")) : s
1843
- ).typeError(e.invalid).test(
1842
+ (s, i) => i == "phone_number" || i instanceof Date ? s : i
1843
+ ).transform((s) => {
1844
+ if (s.split) {
1845
+ const i = s.split("/");
1846
+ switch (t == null ? void 0 : t.format) {
1847
+ case "dd/mm/yyyy":
1848
+ if (i.length == 3 || i[2].length == 4)
1849
+ return new Date(i.reverse().join("-"));
1850
+ case "mm/yyyy":
1851
+ if (i.length == 2 || i[1].length == 4)
1852
+ return new Date(i.reverse().join("-"));
1853
+ }
1854
+ }
1855
+ return s;
1856
+ }).typeError(e.invalid).test(
1844
1857
  "dateTest",
1845
1858
  e.invalid,
1846
1859
  (s, i) => i.originalValue.split("/").length == a && i.originalValue.split("/")[n].length == 4
1847
1860
  );
1848
- return e.required && (r = r.required(e.required)), (t == null ? void 0 : t.maxDate) && e.maxDate && (r = r.min(t.maxDate, e.maxDate)), (t == null ? void 0 : t.minDate) && e.minDate && (r = r.max(t.minDate, e.minDate)), r;
1861
+ return e.required && (r = r.required(e.required)), (t == null ? void 0 : t.minDate) && e.minDate && (r = r.min(t.minDate, e.minDate)), (t == null ? void 0 : t.maxDate) && e.maxDate && (r = r.max(t.maxDate, e.maxDate)), r;
1849
1862
  }, Im = (e) => {
1850
1863
  let t = Xa().transform((a) => a).min(9, e.invalid).test("nifTest", e.invalid, (a) => {
1851
1864
  if (!a)
@@ -10,10 +10,10 @@ declare const _default: import("vue").DefineComponent<{
10
10
  type: import("vue").PropType<"vertical" | "horizontal">;
11
11
  default: string;
12
12
  };
13
- maxDate: {
13
+ minDate: {
14
14
  type: import("vue").PropType<string>;
15
15
  };
16
- minDate: {
16
+ maxDate: {
17
17
  type: import("vue").PropType<string>;
18
18
  };
19
19
  size: {
@@ -64,10 +64,10 @@ declare const _default: import("vue").DefineComponent<{
64
64
  type: import("vue").PropType<"vertical" | "horizontal">;
65
65
  default: string;
66
66
  };
67
- maxDate: {
67
+ minDate: {
68
68
  type: import("vue").PropType<string>;
69
69
  };
70
- minDate: {
70
+ maxDate: {
71
71
  type: import("vue").PropType<string>;
72
72
  };
73
73
  size: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cja-phoenix",
3
- "version": "0.14.3",
3
+ "version": "0.14.5",
4
4
  "scripts": {
5
5
  "build:dev": "rimraf dist && vue-tsc && vite build -m development",
6
6
  "build:link": "rimraf dist && vue-tsc && vite build -m development && npm link",
@@ -165,16 +165,26 @@ export const date = (
165
165
  let validation = yup
166
166
  .date()
167
167
  .transform((v, ogV) =>
168
- (!(ogV instanceof Date) &&
169
- (options?.format == "dd/mm/yyyy" || !options?.format) &&
170
- ogV.split("/").length == 3 &&
171
- ogV.split("/")[2].length == 4) ||
172
- (options?.format == "mm/yyyy" &&
173
- ogV.split("/").length == 2 &&
174
- ogV.split("/")[1].length == 4)
175
- ? new Date(ogV.split("/").reverse().join("-"))
176
- : v
168
+ // ogV as "phone_number" is still as of yet unexplained
169
+ ogV == "phone_number" || ogV instanceof Date ? v : ogV
177
170
  )
171
+ .transform((v) => {
172
+ if (v.split) {
173
+ const vArr = v.split("/");
174
+
175
+ switch (options?.format) {
176
+ case "dd/mm/yyyy":
177
+ if (vArr.length == 3 || vArr[2].length == 4)
178
+ return new Date(vArr.reverse().join("-"));
179
+
180
+ case "mm/yyyy":
181
+ if (vArr.length == 2 || vArr[1].length == 4)
182
+ return new Date(vArr.reverse().join("-"));
183
+ }
184
+ }
185
+
186
+ return v;
187
+ })
178
188
  .typeError(messages.invalid)
179
189
  .test(
180
190
  "dateTest",
@@ -188,14 +198,12 @@ export const date = (
188
198
  validation = validation.required(messages.required);
189
199
  }
190
200
 
191
- // Due to how the calendar picker library works, min and max have to be inverted
192
- // This may be fixed with an in-house implementation of a calendar picker
193
- if (options?.maxDate && messages.maxDate) {
194
- validation = validation.min(options.maxDate, messages.maxDate);
201
+ if (options?.minDate && messages.minDate) {
202
+ validation = validation.min(options.minDate, messages.minDate);
195
203
  }
196
204
 
197
- if (options?.minDate && messages.minDate) {
198
- validation = validation.max(options.minDate, messages.minDate);
205
+ if (options?.maxDate && messages.maxDate) {
206
+ validation = validation.max(options.maxDate, messages.maxDate);
199
207
  }
200
208
 
201
209
  return validation;