@shival99/z-ui 2.5.7 → 2.5.8

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.
@@ -18,6 +18,11 @@ import { merge } from 'rxjs';
18
18
  import { cva } from 'class-variance-authority';
19
19
 
20
20
  const createDate = (year, month, day, hour = 0, minute = 0, second = 0) => new Date(year, month, day, hour, minute, second);
21
+ /**
22
+ * Accept the date-fns-style year/day tokens commonly used by Angular forms.
23
+ * The calendar's canonical tokens remain YYYY/MM/DD for backwards compatibility.
24
+ */
25
+ const normalizeCalendarFormat = (format) => format.replace(/yyyy/g, 'YYYY').replace(/dd/g, 'DD');
21
26
  const cloneDate = (date) => new Date(date.getTime());
22
27
  const getToday = () => {
23
28
  const now = new Date();
@@ -235,7 +240,7 @@ const formatDate = (date, format, locale = 'vi-VN') => {
235
240
  mm: String(date.getMinutes()).padStart(2, '0'),
236
241
  ss: String(date.getSeconds()).padStart(2, '0'),
237
242
  };
238
- let result = format;
243
+ let result = normalizeCalendarFormat(format);
239
244
  // Sort tokens by length (longest first) to avoid partial replacements
240
245
  // e.g., MMMM should be replaced before MM
241
246
  const sortedTokens = Object.keys(tokens).sort((a, b) => b.length - a.length);
@@ -264,6 +269,7 @@ const parseDate = (dateString, format, locale = 'vi-VN') => {
264
269
  const sortedNames = [...names].sort((a, b) => b.length - a.length);
265
270
  return `(${sortedNames.map(name => name.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&')).join('|')})`;
266
271
  };
272
+ format = normalizeCalendarFormat(format);
267
273
  const tokens = {
268
274
  YYYY: '_T_0_',
269
275
  MMMM: '_T_1_',
@@ -1030,8 +1036,7 @@ class ZCalendarComponent {
1030
1036
  zAllowEdit = input(true, { ...(ngDevMode ? { debugName: "zAllowEdit" } : /* istanbul ignore next */ {}), transform: zTransform });
1031
1037
  zShortTime = input(false, { ...(ngDevMode ? { debugName: "zShortTime" } : /* istanbul ignore next */ {}), transform: zTransform });
1032
1038
  zAllowClear = input(true, { ...(ngDevMode ? { debugName: "zAllowClear" } : /* istanbul ignore next */ {}), transform: zTransform });
1033
- zFormat = input('DD/MM/YYYY', /* @ts-ignore */
1034
- ...(ngDevMode ? [{ debugName: "zFormat" }] : /* istanbul ignore next */ []));
1039
+ zFormat = input('DD/MM/YYYY', { ...(ngDevMode ? { debugName: "zFormat" } : /* istanbul ignore next */ {}), transform: (value) => (typeof value === 'string' ? normalizeCalendarFormat(value) : 'DD/MM/YYYY') });
1035
1040
  zMinDate = input(null, /* @ts-ignore */
1036
1041
  ...(ngDevMode ? [{ debugName: "zMinDate" }] : /* istanbul ignore next */ []));
1037
1042
  zMaxDate = input(null, /* @ts-ignore */