@umituz/web-design-system 6.10.0 → 6.11.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-design-system",
3
- "version": "6.10.0",
3
+ "version": "6.11.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Web Design System - Tailwind v4 authored, precompiled CSS shipped. Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications.",
@@ -92,6 +92,31 @@ describe('formatDateTime', () => {
92
92
  });
93
93
  });
94
94
 
95
+ describe('preset overrides', () => {
96
+ it('drops the weekday from the long style', () => {
97
+ expect(formatDate('2026-11-10', 'long', { weekday: 'none' })).toBe('November 10, 2026');
98
+ });
99
+
100
+ it('shortens the weekday of the long style', () => {
101
+ expect(formatDate('2026-11-10', 'long', { weekday: 'short' })).toBe('Tue, November 10, 2026');
102
+ });
103
+
104
+ it('lengthens the month of the monthYear style', () => {
105
+ expect(formatDate('2026-01-15', 'monthYear', { month: 'long' })).toBe('January 2026');
106
+ });
107
+
108
+ it('lengthens the month of the medium style', () => {
109
+ expect(formatDate('2026-01-15', 'medium', { month: 'long' })).toBe('January 15, 2026');
110
+ });
111
+
112
+ it('does not leak overrides into other calls through the cache', () => {
113
+ expect(formatDate('2026-11-10', 'monthYear', { month: 'long' })).toBe('November 2026');
114
+ expect(formatDate('2026-11-10', 'monthYear')).toBe('Nov 2026');
115
+ expect(formatDate('2026-11-10', 'long', { weekday: 'none' })).toBe('November 10, 2026');
116
+ expect(formatDate('2026-11-10', 'long')).toBe('Tuesday, November 10, 2026');
117
+ });
118
+ });
119
+
95
120
  describe('formatter cache', () => {
96
121
  it('does not contaminate across locales for the same instant', () => {
97
122
  const en = formatDate('2026-11-10');
@@ -5,6 +5,8 @@ export interface DateFormatOptions {
5
5
  order?: 'dmy' | 'mdy' | 'ymd';
6
6
  separator?: string;
7
7
  invalidOutput?: string;
8
+ weekday?: 'short' | 'long' | 'none';
9
+ month?: 'short' | 'long';
8
10
  }
9
11
 
10
12
  export interface DateTimeFormatOptions extends DateFormatOptions {
@@ -34,6 +36,19 @@ const cachedFormatter = (locale: string, options: Intl.DateTimeFormatOptions): I
34
36
  return formatter;
35
37
  };
36
38
 
39
+ const resolveOptions = (style: Exclude<DateStyle, 'numeric'>, options: DateFormatOptions): Intl.DateTimeFormatOptions => {
40
+ const resolved: Intl.DateTimeFormatOptions = { ...PRESET_OPTIONS[style] };
41
+ if (options.weekday === 'none') {
42
+ delete resolved.weekday;
43
+ } else if (options.weekday !== undefined) {
44
+ resolved.weekday = options.weekday;
45
+ }
46
+ if (options.month !== undefined) {
47
+ resolved.month = options.month;
48
+ }
49
+ return resolved;
50
+ };
51
+
37
52
  export const parseDateInput = (input: string | Date): Date | null => {
38
53
  if (input instanceof Date) {
39
54
  return Number.isNaN(input.getTime()) ? null : input;
@@ -85,7 +100,7 @@ export const formatDate = (
85
100
  if (style === 'numeric') {
86
101
  return formatNumeric(date, locale, options.order ?? 'dmy', options.separator ?? DEFAULT_SEPARATOR);
87
102
  }
88
- return cachedFormatter(locale, PRESET_OPTIONS[style]).format(date);
103
+ return cachedFormatter(locale, resolveOptions(style, options)).format(date);
89
104
  };
90
105
 
91
106
  export const formatDateTime = (