@sme.up/ketchup2 2.0.0-SNAPSHOT-20250516144623 → 2.0.0-SNAPSHOT-20250516152534

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.
@@ -52,4 +52,8 @@ export declare enum DateMessages {
52
52
  TOMORROW = "Date.Tomorrow"
53
53
  }
54
54
  export type MessageVariables = Partial<Record<"field" | "key" | "env", string | number> | Record<number, string | number>>;
55
+ export interface FormatOptions {
56
+ inputIsLocalized?: boolean;
57
+ type?: "number" | "date";
58
+ }
55
59
  //# sourceMappingURL=translation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/types/translation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAChB,YAAY,GACZ,WAAW,GACX,eAAe,GACf,aAAa,CAAA;AAEjB,oBAAY,eAAe;IAEzB,YAAY,qBAAqB;IACjC,KAAK,kBAAkB;CACxB;AAED,oBAAY,WAAW;IAErB,MAAM,eAAe;IACrB,YAAY,oBAAoB;IAChC,OAAO,gBAAgB;IACvB,aAAa,qBAAqB;IAClC,SAAS,kBAAkB;IAC3B,eAAe,uBAAuB;IACtC,QAAQ,iBAAiB;IACzB,cAAc,sBAAsB;IACpC,MAAM,eAAe;IACrB,YAAY,oBAAoB;IAChC,QAAQ,iBAAiB;IACzB,cAAc,sBAAsB;IACpC,MAAM,eAAe;IACrB,YAAY,oBAAoB;CACjC;AAED,oBAAY,aAAa;IAEvB,OAAO,kBAAkB;IACzB,QAAQ,mBAAmB;IAC3B,KAAK,gBAAgB;IACrB,KAAK,gBAAgB;IACrB,GAAG,cAAc;IACjB,IAAI,eAAe;IACnB,IAAI,eAAe;IACnB,MAAM,iBAAiB;IACvB,SAAS,oBAAoB;IAC7B,OAAO,kBAAkB;IACzB,QAAQ,mBAAmB;IAC3B,QAAQ,mBAAmB;CAC5B;AAED,oBAAY,YAAY;IAEtB,YAAY,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YAAY;IAEtB,YAAY,qBAAqB;IACjC,aAAa,sBAAsB;IACnC,cAAc,uBAAuB;IACrC,aAAa,sBAAsB;IAEnC,QAAQ,iBAAiB;IACzB,SAAS,kBAAkB;IAC3B,UAAU,mBAAmB;IAC7B,SAAS,kBAAkB;IAE3B,SAAS,mBAAmB;IAC5B,KAAK,eAAe;IACpB,QAAQ,kBAAkB;CAC3B;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAClC,MAAM,CAAC,OAAO,GAAG,KAAK,GAAG,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,GAChD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAClC,CAAA;AAED,MAAM,WAAW,aAAa;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;CACzB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Normalizes a date string into a JavaScript Date object.
3
+ *
4
+ * If the input string is in ISO format (YYYY-MM-DD), it is parsed directly.
5
+ *
6
+ * This function transforms a date string that may include delimiters ("/" or "-")
7
+ * into a Date object by parsing the input according to its length and the specified language.
8
+ * The parsing strategy depends on the number of digits in the input (after removing delimiters):
9
+ *
10
+ * - 1 or 2 digits: The input is treated as a day of the current month.
11
+ * - 3 or 4 digits: The input is split into two parts representing day and month,
12
+ * where the order depends on the language:
13
+ * - For languages other than "it", the order is MMDD.
14
+ * - For "it", the order is DDMM.
15
+ * - 5 or 6 digits: The input includes day, month, and a two-digit year.
16
+ * The two-digit year is expanded:
17
+ * - If greater than 50, it is assumed to be in the 1900s.
18
+ * - Otherwise, it is assumed to be in the 2000s.
19
+ * - 7 or 8 digits: The input includes day, month, and a four-digit year.
20
+ *
21
+ * The language parameter determines the order in which day and month are interpreted:
22
+ * - If language is "it", the order is DDMMYYYY.
23
+ * - For all other languages, the order is MMDDYYYY.
24
+ *
25
+ * Note that JavaScript’s Date object uses zero-based month indexing, so the month
26
+ * value is adjusted accordingly.
27
+ *
28
+ * @param input - The date string to normalize. It may contain slashes or hyphens.
29
+ * @param language - A string indicating the language format ("it" for Italian, defaults to other formats).
30
+ * @returns A Date object representing the normalized date. If parts of the date are missing,
31
+ * the corresponding value from the current date is used. If the date is invalid,
32
+ * the original input string is returned.
33
+ */
34
+ export declare function normalizeDate(input: string, language: string): string | Date;
35
+ /**
36
+ * Determines if the provided string is a valid ISO date in the 'YYYY-MM-DD' format.
37
+ *
38
+ * This function checks that the input string conforms to the format where:
39
+ * - The first four characters represent the year.
40
+ * - The fifth character is a hyphen.
41
+ * - The next two characters represent the month.
42
+ * - The eighth character is a hyphen.
43
+ * - The final two characters represent the day.
44
+ *
45
+ * The check is performed using a regular expression and ensures that the length
46
+ * of the string is exactly 10 characters.
47
+ *
48
+ * @param date - The date string to validate.
49
+ * @returns True if the string is a valid ISO date in 'YYYY-MM-DD' format; otherwise, false.
50
+ */
51
+ export declare function isISODate(date: string): boolean;
52
+ /**
53
+ * Determines whether the provided value is a valid Date object.
54
+ *
55
+ * The function checks if the given parameter is an instance of the Date class and that its
56
+ * time value is not NaN, ensuring that it represents a valid date.
57
+ *
58
+ * @param date - The Date object to validate.
59
+ * @returns True if the input is a valid Date, otherwise false.
60
+ */
61
+ export declare function isValidDate(date: Date): boolean;
62
+ /**
63
+ * Validates whether a given string is in the format "YYYYMMDD" and represents a valid date.
64
+ *
65
+ * @param dateStr - The date string to validate, expected to be in the format "YYYYMMDD".
66
+ * @returns `true` if the string is a valid date in the "YYYYMMDD" format, otherwise `false`.
67
+ */
68
+ export declare function isValidYYYYMMDD(dateStr: string): boolean;
69
+ /**
70
+ * This function checks if the provided date is a valid date according to the
71
+ * calendar rules.
72
+ * Days should be in the range of 1-31 and consistent with the month.
73
+ * Months should be in the range of 0-11 (January is 0, December is 11).
74
+ * Leap years should be checked for February.
75
+ *
76
+ * @param dd - The day to check.
77
+ * @param mm - The month to check.
78
+ * @param yyyy - The year to check (not used in this function).
79
+ * @returns True if the date is valid, otherwise false.
80
+ */
81
+ export declare function isCalendarDate(dd: number, mm: number, yyyy: number): boolean;
82
+ /**
83
+ * Checks if a given year is a leap year.
84
+ * A year is considered a leap year if:
85
+ * - It is divisible by 4.
86
+ * - If it is divisible by 100, it must also be divisible by 400.
87
+ *
88
+ * @param year - The year to check.
89
+ * @returns True if the year is a leap year, otherwise false.
90
+ */
91
+ export declare function isLeapYear(year: number): boolean;
92
+ /**
93
+ * Formats a Date object into a string with the format "YYYY-MM-DD" (ISO).
94
+ * This function is useful when the toISOString() method is not reliable because
95
+ * the date is not in UTC.
96
+ *
97
+ * @param date - The Date instance to be formatted.
98
+ * @returns The date in ISO format.
99
+ */
100
+ export declare function formatLocalDate(date: Date): string;
101
+ //# sourceMappingURL=date.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/utils/date.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA8F5E;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,WAErC;AAID;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,WAErC;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQxD;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAyBlE;AAID;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,WAEtC;AAID;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,UAUzC"}
@@ -1,6 +1,4 @@
1
- import { Messages, MessageVariables } from '../types/translation';
2
- export declare const doFormat: (value: string | number, format?: string, lng?: string, options?: {
3
- inputIsLocalized?: boolean;
4
- }) => string;
1
+ import { FormatOptions, Messages, MessageVariables } from '../types/translation';
2
+ export declare const doFormat: (value: string | number | Date, format?: string, lng?: string, options?: FormatOptions) => string;
5
3
  export declare const doTranslation: (message: Messages, options?: MessageVariables) => string;
6
4
  //# sourceMappingURL=translation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/utils/translation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AA6BjE,eAAO,MAAM,QAAQ,UACZ,MAAM,GAAG,MAAM,WACb,MAAM,QACT,MAAM,YACF;IACR,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,KACA,MAEF,CAAA;AAED,eAAO,MAAM,aAAa,YACf,QAAQ,YACP,gBAAgB,KACzB,MAEF,CAAA"}
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/utils/translation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AA+ChF,eAAO,MAAM,QAAQ,UACZ,MAAM,GAAG,MAAM,GAAG,IAAI,WACpB,MAAM,QACT,MAAM,YACF,aAAa,KACtB,MAEF,CAAA;AAED,eAAO,MAAM,aAAa,YACf,QAAQ,YACP,gBAAgB,KACzB,MAEF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/utils/wrapper-types/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD;;;GAGG;AACH,cAAM,SAAU,YAAW,YAAY,CAAC,MAAM,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,IAAI,CAAQ;gBAER,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM;IAKjD,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;IAS3C,cAAc,IAAI,MAAM;IAaxB,QAAQ,IAAI,MAAM;CAGnB;AAsBD,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/utils/wrapper-types/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAGlD;;;GAGG;AACH,cAAM,SAAU,YAAW,YAAY,CAAC,MAAM,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,IAAI,CAAQ;gBAER,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM;IAKjD,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS;IAS3C,cAAc,IAAI,MAAM;IAaxB,QAAQ,IAAI,MAAM;CAGnB;AAsBD,eAAe,SAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sme.up/ketchup2",
3
- "version": "2.0.0-SNAPSHOT-20250516144623",
3
+ "version": "2.0.0-SNAPSHOT-20250516152534",
4
4
  "description": "Sme.UP web components library",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Smeup LAB <info@smeup.com> (https://www.smeup.com/)",
@@ -60,7 +60,7 @@
60
60
  "eslint-plugin-react-refresh": "^0.4.19",
61
61
  "eslint-plugin-storybook": "^0.12.0",
62
62
  "globals": "^15.15.0",
63
- "i18next": "^25.0.0",
63
+ "i18next": "^25",
64
64
  "jsdom": "^26.0.0",
65
65
  "playwright": "^1.51.0",
66
66
  "postcss": "^8.5.3",
@@ -78,7 +78,7 @@
78
78
  "vitest": "^3.0.8"
79
79
  },
80
80
  "peerDependencies": {
81
- "i18next": "^25.0.0"
81
+ "i18next": "^25"
82
82
  },
83
83
  "eslintConfig": {
84
84
  "extends": [