asv-hlps 1.2.93 → 1.2.95

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.
@@ -58,7 +58,7 @@ export declare const formatNgbDate: (date: any) => {
58
58
  };
59
59
  export declare const genRandomColour: () => string;
60
60
  export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
61
- export declare const getPeriodDateColor: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "danger" | "warning" | "purple" | "success" | "info";
61
+ export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
62
62
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
63
63
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
64
64
  export declare const unCheckedAll: (checks?: any[]) => void;
package/lib/cjs/utils.js CHANGED
@@ -336,26 +336,55 @@ const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, period3 =
336
336
  return "#339900";
337
337
  };
338
338
  exports.getColorAccordingToDate = getColorAccordingToDate;
339
- const getPeriodDateColor = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
340
- const date = new Date();
341
- const date2 = new Date(inputDate);
342
- const diffNumber = Math.ceil((0, exports.getNbOfDaysBetweenTwoDates)(date2, date));
343
- period1 = period1 * 30;
344
- period2 = period2 * 30;
345
- period3 = period3 * 30;
346
- if (diffNumber <= period1) {
339
+ const getPeriodDateColor = (inputDate, period = 30, colors) => {
340
+ const month0 = 0;
341
+ const month3 = period * 3;
342
+ const month6 = period * 6;
343
+ const month9 = period * 9;
344
+ const month12 = period * 12;
345
+ const today = (0, dayjs_1.default)(new Date());
346
+ const expDate = new Date(inputDate);
347
+ const diff = (0, dayjs_1.default)(expDate).diff(today, "day");
348
+ if (colors.length >= 4) {
349
+ if (diff <= month0) {
350
+ // return "dark";
351
+ return colors.length >= 6 ? colors[4] : "danger";
352
+ }
353
+ if (diff <= month3) {
354
+ return colors[0];
355
+ }
356
+ if (diff <= month6) {
357
+ return colors[1];
358
+ }
359
+ if (diff <= month9) {
360
+ return colors[2];
361
+ }
362
+ if (diff <= month12) {
363
+ return colors[3];
364
+ }
365
+ if (diff > month12) {
366
+ return colors.length >= 5 ? colors[4] : "info";
367
+ }
368
+ }
369
+ if (diff <= month0) {
370
+ // return "dark";
347
371
  return "danger";
348
372
  }
349
- else if (diffNumber > period1 && diffNumber <= period2) {
373
+ if (diff <= month3) {
374
+ return "danger";
375
+ }
376
+ if (diff <= month6) {
350
377
  return "warning";
351
378
  }
352
- else if (diffNumber > period2 && diffNumber <= period3) {
379
+ if (diff <= month9) {
353
380
  return "purple";
354
381
  }
355
- else if (diffNumber > period3) {
382
+ if (diff <= month12) {
356
383
  return "success";
357
384
  }
358
- return "info";
385
+ if (diff > month12) {
386
+ return "info";
387
+ }
359
388
  };
360
389
  exports.getPeriodDateColor = getPeriodDateColor;
361
390
  const arrayMultiChecked = (objet, event, item) => {
@@ -58,7 +58,7 @@ export declare const formatNgbDate: (date: any) => {
58
58
  };
59
59
  export declare const genRandomColour: () => string;
60
60
  export declare const getColorAccordingToDate: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "red" | "DarkOrange" | "turquoise" | "blue" | "green" | "#f46a6a" | "#f1b44c" | "#cce5ff" | "#34c38f" | "#339900";
61
- export declare const getPeriodDateColor: (inputDate: Date, period1?: number, period2?: number, period3?: number, ifClass?: boolean) => "danger" | "warning" | "purple" | "success" | "info";
61
+ export declare const getPeriodDateColor: (inputDate: string, period?: number, colors?: [string, string, string, string, ...string[]]) => string;
62
62
  export declare const arrayMultiChecked: (objet: any[], event: boolean, item: any) => any[];
63
63
  export declare const inputChecked: (event: any, item: any, checks: any[], isChecked?: boolean) => any[];
64
64
  export declare const unCheckedAll: (checks?: any[]) => void;
package/lib/esm/utils.js CHANGED
@@ -284,26 +284,55 @@ export const getColorAccordingToDate = (inputDate, period1 = 3, period2 = 6, per
284
284
  }
285
285
  return "#339900";
286
286
  };
287
- export const getPeriodDateColor = (inputDate, period1 = 3, period2 = 6, period3 = 9, ifClass) => {
288
- const date = new Date();
289
- const date2 = new Date(inputDate);
290
- const diffNumber = Math.ceil(getNbOfDaysBetweenTwoDates(date2, date));
291
- period1 = period1 * 30;
292
- period2 = period2 * 30;
293
- period3 = period3 * 30;
294
- if (diffNumber <= period1) {
287
+ export const getPeriodDateColor = (inputDate, period = 30, colors) => {
288
+ const month0 = 0;
289
+ const month3 = period * 3;
290
+ const month6 = period * 6;
291
+ const month9 = period * 9;
292
+ const month12 = period * 12;
293
+ const today = dayjs(new Date());
294
+ const expDate = new Date(inputDate);
295
+ const diff = dayjs(expDate).diff(today, "day");
296
+ if (colors.length >= 4) {
297
+ if (diff <= month0) {
298
+ // return "dark";
299
+ return colors.length >= 6 ? colors[4] : "danger";
300
+ }
301
+ if (diff <= month3) {
302
+ return colors[0];
303
+ }
304
+ if (diff <= month6) {
305
+ return colors[1];
306
+ }
307
+ if (diff <= month9) {
308
+ return colors[2];
309
+ }
310
+ if (diff <= month12) {
311
+ return colors[3];
312
+ }
313
+ if (diff > month12) {
314
+ return colors.length >= 5 ? colors[4] : "info";
315
+ }
316
+ }
317
+ if (diff <= month0) {
318
+ // return "dark";
295
319
  return "danger";
296
320
  }
297
- else if (diffNumber > period1 && diffNumber <= period2) {
321
+ if (diff <= month3) {
322
+ return "danger";
323
+ }
324
+ if (diff <= month6) {
298
325
  return "warning";
299
326
  }
300
- else if (diffNumber > period2 && diffNumber <= period3) {
327
+ if (diff <= month9) {
301
328
  return "purple";
302
329
  }
303
- else if (diffNumber > period3) {
330
+ if (diff <= month12) {
304
331
  return "success";
305
332
  }
306
- return "info";
333
+ if (diff > month12) {
334
+ return "info";
335
+ }
307
336
  };
308
337
  export const arrayMultiChecked = (objet, event, item) => {
309
338
  const findItem = objet.find((x) => x.id === item.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.2.93",
3
+ "version": "1.2.95",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",