@antify/ui 4.1.25 → 4.1.26

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.
@@ -4,6 +4,7 @@ import {
4
4
  format,
5
5
  addDays,
6
6
  subDays,
7
+ getISOWeek,
7
8
  } from 'date-fns';
8
9
  import {
9
10
  ref,
@@ -13,7 +14,6 @@ import {
13
14
  onMounted,
14
15
  } from 'vue';
15
16
  import AntDateSwitcher from './AntDateSwitcher.vue';
16
- import AntButton from '../AntButton.vue';
17
17
  import AntSkeleton from '../AntSkeleton.vue';
18
18
  import AntTooltip from '../AntTooltip.vue';
19
19
 
@@ -24,7 +24,7 @@ const props = withDefaults(defineProps<{
24
24
  */
25
25
  modelValue: number;
26
26
  showWeekend?: boolean;
27
- showTodayButton?: boolean;
27
+ showWeekNumbers?: boolean;
28
28
  skeleton?: boolean;
29
29
  /**
30
30
  * To highlight specific days with a custom color e.g. legal holidays
@@ -37,7 +37,7 @@ const props = withDefaults(defineProps<{
37
37
  }[];
38
38
  }>(), {
39
39
  showWeekend: false,
40
- showTodayButton: true,
40
+ showWeekNumbers: false,
41
41
  skeleton: false,
42
42
  specialDays: () => [],
43
43
  });
@@ -53,68 +53,79 @@ const currentMonthIndex = ref(new Date(props.modelValue).getMonth());
53
53
  const currentYear = ref(new Date(props.modelValue).getFullYear());
54
54
  const matrix = computed(() => {
55
55
  /**
56
- * The picker always starts with Monday.
57
- * So if the first day of the current month is for example a wednesday,
58
- * the first two days (Monday and Tuesday) should be from the previous month.
59
- * Also, the last days of the matrix should be filled with the next month's days.
60
- */
56
+ * The picker always starts with Monday.
57
+ * So if the first day of the current month is for example a wednesday,
58
+ * the first two days (Monday and Tuesday) should be from the previous month.
59
+ * Also, the last days of the matrix should be filled with the next month's days.
60
+ */
61
61
  const firstDateOfMonth = new Date(currentYear.value, currentMonthIndex.value, 1);
62
- const _matrix = Array.from({
63
- length: COUNT_ROWS,
64
- }, () => Array(COUNT_COLUMNS).fill(null));
62
+ const _matrix = [];
65
63
 
66
64
  // Emit on which weekday the first day of the month is.
67
- const weekdayIndexOfFirstDay = (firstDateOfMonth.getDay() - 1); // 0 is Monday, 6 is Sunday
65
+ let weekdayIndexOfFirstDay = firstDateOfMonth.getDay() - 1;
66
+
67
+ if (weekdayIndexOfFirstDay === -1) {
68
+ weekdayIndexOfFirstDay = 6;
69
+ }
68
70
 
69
71
  // Subtract the gap from the currentDate
70
72
  let currentDate = subDays(firstDateOfMonth, weekdayIndexOfFirstDay);
71
73
 
72
- for (let weekIndex = 0; weekIndex < _matrix.length; weekIndex++) {
74
+ for (let weekIndex = 0; weekIndex < COUNT_ROWS; weekIndex++) {
75
+ const weekDays = [];
76
+ const weekNumber = getISOWeek(currentDate);
77
+
73
78
  for (let weekdayIndex = 0; weekdayIndex < COUNT_COLUMNS; weekdayIndex++) {
74
79
  const date = format(currentDate, 'yyyy-MM-dd');
75
80
  const isCurrentMonth = getMonth(currentDate) === currentMonthIndex.value;
76
81
 
77
- _matrix[weekIndex][weekdayIndex] = {
82
+ weekDays.push({
78
83
  date,
79
84
  label: format(currentDate, 'd'),
80
85
  month: getMonth(currentDate),
81
86
  isCurrentMonth,
82
87
  isWeekend: weekdayIndex === 5 || weekdayIndex === 6,
83
88
  isToday: date === format(Date.now(), 'yyyy-MM-dd') && isCurrentMonth,
84
- isSpecialDay: !!props.specialDays.find(specialDay => specialDay.date === date),
85
- specialDayColor: props.specialDays.find(specialDay => specialDay.date === date)?.color,
86
- };
89
+ isSpecialDay: !!props.specialDays.find(sd => sd.date === date),
90
+ specialDayColor: props.specialDays.find(sd => sd.date === date)?.color,
91
+ });
87
92
 
88
93
  currentDate = addDays(currentDate, 1);
89
94
  }
90
- }
91
95
 
92
- if (props.showWeekend) {
93
- return _matrix;
96
+ _matrix.push({
97
+ weekNumber,
98
+ days: props.showWeekend ? weekDays : weekDays.filter(day => !day.isWeekend),
99
+ });
94
100
  }
95
101
 
96
- // Filter out weekends
97
- return _matrix.map(week => week.filter(day => !day.isWeekend));
102
+ return _matrix;
98
103
  });
99
104
  const weekDays = computed(() => {
100
105
  // TODO:: Add translation support
101
- return props.showWeekend
102
- ? [
103
- 'M',
104
- 'D',
105
- 'M',
106
- 'D',
107
- 'F',
108
- 'S',
109
- 'S',
110
- ]
111
- : [
112
- 'M',
113
- 'D',
114
- 'M',
115
- 'D',
116
- 'F',
106
+ const days = props.showWeekend ? [
107
+ 'M',
108
+ 'D',
109
+ 'M',
110
+ 'D',
111
+ 'F',
112
+ 'S',
113
+ 'S',
114
+ ] : [
115
+ 'M',
116
+ 'D',
117
+ 'M',
118
+ 'D',
119
+ 'F',
120
+ ];
121
+ if (props.showWeekNumbers) {
122
+ return [
123
+ 'KW',
124
+ ...days,
117
125
  ];
126
+ }
127
+
128
+ return days;
118
129
  });
119
130
 
120
131
  const getColorNumber = (color: string) => {
@@ -158,34 +169,52 @@ onMounted(() => {
158
169
  v-model:month="currentMonthIndex"
159
170
  v-model:year="currentYear"
160
171
  :skeleton="skeleton"
172
+ class="pb-1"
161
173
  />
162
174
 
163
175
  <div
164
- class="grid gap-1 p-px"
165
- :class="{
166
- 'grid-cols-7': showWeekend,
167
- 'grid-cols-5': !showWeekend,
176
+ class="grid gap-1"
177
+ :style="{
178
+ gridTemplateColumns: `repeat(${weekDays.length}, minmax(0, 1fr))`
168
179
  }"
169
180
  >
170
181
  <div
171
182
  v-for="day in weekDays"
172
183
  :key="day"
173
- class="text-for-white-bg-font p-2 text-center"
184
+ class="text-for-white-bg-font text-center flex items-center justify-center"
174
185
  >
175
186
  <AntSkeleton
176
187
  :visible="skeleton"
177
188
  rounded
189
+ class="w-full"
178
190
  >
179
- {{ day }}
191
+ <div class="flex items-center justify-center w-full py-2">
192
+ {{ day }}
193
+ </div>
180
194
  </AntSkeleton>
181
195
  </div>
182
196
 
183
197
  <template
184
- v-for="week in matrix"
185
- :key="week"
198
+ v-for="(week, wIndex) in matrix"
199
+ :key="wIndex"
186
200
  >
201
+ <div
202
+ v-if="showWeekNumbers"
203
+ class="flex text-base-500 font-semibold bg-base-100 rounded-md"
204
+ >
205
+ <AntSkeleton
206
+ :visible="skeleton"
207
+ rounded
208
+ class="w-full"
209
+ >
210
+ <div class="flex items-center justify-center w-full py-2">
211
+ {{ week.weekNumber }}
212
+ </div>
213
+ </AntSkeleton>
214
+ </div>
215
+
187
216
  <template
188
- v-for="day in week"
217
+ v-for="day in week.days"
189
218
  :key="day.date"
190
219
  >
191
220
  <AntSkeleton
@@ -227,18 +256,5 @@ onMounted(() => {
227
256
  </template>
228
257
  </template>
229
258
  </div>
230
-
231
- <div
232
- v-if="showTodayButton"
233
- class="flex items-center justify-center p-2"
234
- >
235
- <AntButton
236
- :skeleton="skeleton"
237
- data-e2e="today-button"
238
- @click="() => $emit('update:modelValue', Date.now())"
239
- >
240
- Heute
241
- </AntButton>
242
- </div>
243
259
  </div>
244
260
  </template>
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof AntCalendar>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof AntCalendar>;
6
6
  export declare const Docs: Story;
7
+ export declare const Summary: Story;
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- module.exports = exports.Docs = void 0;
6
+ module.exports = exports.Summary = exports.Docs = void 0;
7
7
  var _AntDatePicker = _interopRequireDefault(require("../AntDatePicker.vue"));
8
8
  var _AntDateSwitcher = _interopRequireDefault(require("../AntDateSwitcher.vue"));
9
9
  var _vue = require("vue");
10
10
  var _dateFns = require("date-fns");
11
+ var _AntFormGroup = _interopRequireDefault(require("../../forms/AntFormGroup.vue"));
12
+ var _AntFormGroupLabel = _interopRequireDefault(require("../../forms/AntFormGroupLabel.vue"));
11
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
14
  const meta = {
13
15
  title: "Components/Date Picker",
@@ -21,6 +23,14 @@ const meta = {
21
23
  AntDateSwitcher: _AntDateSwitcher.default
22
24
  },
23
25
  argTypes: {
26
+ modelValue: {
27
+ control: "number",
28
+ table: {
29
+ type: {
30
+ summary: "number"
31
+ }
32
+ }
33
+ },
24
34
  onSelect: {
25
35
  action: "select"
26
36
  }
@@ -28,37 +38,140 @@ const meta = {
28
38
  };
29
39
  module.exports = meta;
30
40
  const Docs = exports.Docs = {
31
- parameters: {
32
- chromatic: {
33
- // disableSnapshot: false,
34
- }
35
- },
36
41
  render: args => ({
37
42
  components: {
38
43
  AntCalendar: _AntDatePicker.default
39
44
  },
40
45
  setup() {
41
- const value = (0, _vue.ref)(Date.now());
42
46
  return {
43
- value,
44
47
  args
45
48
  };
46
49
  },
47
50
  template: `
48
51
  <div class="p-4">
49
- <div class="dashed w-64">
52
+ <div class="dashed w-72.5">
50
53
  <AntCalendar
51
54
  v-bind="args"
52
- v-model="value"
55
+ v-model="args.modelValue"
53
56
  />
54
57
  </div>
55
58
  </div>`
56
59
  }),
57
60
  args: {
61
+ modelValue: (/* @__PURE__ */new Date()).setHours(0, 0, 0, 0),
58
62
  specialDays: [{
59
63
  name: "Special Day",
60
64
  date: (0, _dateFns.format)((0, _dateFns.addDays)(/* @__PURE__ */new Date(), 1), "yyyy-MM-dd"),
61
65
  color: "success-300"
62
66
  }]
63
67
  }
68
+ };
69
+ const Summary = exports.Summary = {
70
+ parameters: {
71
+ chromatic: {
72
+ disableSnapshot: false
73
+ }
74
+ },
75
+ render: args => ({
76
+ components: {
77
+ AntCalendar: _AntDatePicker.default,
78
+ AntFormGroup: _AntFormGroup.default,
79
+ AntFormGroupLabel: _AntFormGroupLabel.default
80
+ },
81
+ setup() {
82
+ const fixedDate = (/* @__PURE__ */new Date("2026-01-01")).getTime();
83
+ const value = (0, _vue.ref)(fixedDate);
84
+ return {
85
+ value,
86
+ args,
87
+ fixedDate
88
+ };
89
+ },
90
+ template: `
91
+ <AntFormGroup class="p-4 flex flex-col gap-4 w-fit">
92
+ <AntFormGroup>
93
+ <AntFormGroupLabel>Standard States</AntFormGroupLabel>
94
+
95
+ <AntFormGroup class="grid grid-cols-4 gap-10">
96
+ <div class="flex flex-col w-64 gap-2">
97
+ <span>1. Working days only</span>
98
+ <AntCalendar v-model="value" :show-weekend="false" />
99
+ </div>
100
+
101
+ <div class="flex flex-col w-64 gap-2">
102
+ <span>2. With Weekends</span>
103
+ <AntCalendar v-model="value" :show-weekend="true" />
104
+ </div>
105
+
106
+ <div class="flex flex-col w-64 gap-2">
107
+ <span>3. With Week Numbers</span>
108
+ <AntCalendar v-model="value" :show-week-numbers="true" />
109
+ </div>
110
+
111
+ <div class="flex flex-col w-64 gap-2">
112
+ <span>4. Weekends & Week Numbers</span>
113
+ <AntCalendar v-model="value" :show-weekend="true" :show-week-numbers="true" />
114
+ </div>
115
+ </AntFormGroup>
116
+ </AntFormGroup>
117
+
118
+ <AntFormGroup>
119
+ <AntFormGroupLabel>Skeleton States</AntFormGroupLabel>
120
+
121
+ <AntFormGroup class="grid grid-cols-4 gap-10">
122
+ <div class="flex flex-col w-64 gap-2">
123
+ <span>1. Basic Skeleton</span>
124
+ <AntCalendar :model-value="fixedDate" skeleton />
125
+ </div>
126
+
127
+ <div class="flex flex-col w-64 gap-2">
128
+ <span>2. Skeleton + Weekends</span>
129
+ <AntCalendar :model-value="fixedDate" skeleton :show-weekend="true" />
130
+ </div>
131
+
132
+ <div class="flex flex-col w-64 gap-2">
133
+ <span>3. Skeleton + Week Numbers</span>
134
+ <AntCalendar :model-value="fixedDate" skeleton :show-week-numbers="true" />
135
+ </div>
136
+
137
+ <div class="flex flex-col w-64 gap-2">
138
+ <span>4. Full Skeleton</span>
139
+ <AntCalendar :model-value="fixedDate" skeleton :show-weekend="true" :show-week-numbers="true" />
140
+ </div>
141
+ </AntFormGroup>
142
+ </AntFormGroup>
143
+
144
+ <AntFormGroup>
145
+ <AntFormGroupLabel>Special Days</AntFormGroupLabel>
146
+
147
+ <AntFormGroup class="grid grid-cols-4 gap-4">
148
+ <div class="flex flex-col gap-2 w-64 col-span-2">
149
+ <span class="text-center">Calendar with highlights (Jan 2026)</span>
150
+ <AntCalendar
151
+ v-model="value"
152
+ :show-weekend="true"
153
+ :show-week-numbers="true"
154
+ :special-days="args.specialDays"
155
+ />
156
+ </div>
157
+ </AntFormGroup>
158
+ </AntFormGroup>
159
+ </AntFormGroup>`
160
+ }),
161
+ args: {
162
+ modelValue: (/* @__PURE__ */new Date("2026-01-01")).getTime(),
163
+ specialDays: [{
164
+ name: "New Year Day",
165
+ date: "2026-01-01",
166
+ color: "danger-200"
167
+ }, {
168
+ name: "Success Event",
169
+ date: "2026-01-05",
170
+ color: "success-200"
171
+ }, {
172
+ name: "Another Special",
173
+ date: "2026-01-15",
174
+ color: "warning-200"
175
+ }]
176
+ }
64
177
  };
@@ -7,6 +7,8 @@ import {
7
7
  addDays,
8
8
  format
9
9
  } from "date-fns";
10
+ import AntFormGroup from "../../forms/AntFormGroup.vue";
11
+ import AntFormGroupLabel from "../../forms/AntFormGroupLabel.vue";
10
12
  const meta = {
11
13
  title: "Components/Date Picker",
12
14
  component: AntCalendar,
@@ -19,6 +21,14 @@ const meta = {
19
21
  AntDateSwitcher
20
22
  },
21
23
  argTypes: {
24
+ modelValue: {
25
+ control: "number",
26
+ table: {
27
+ type: {
28
+ summary: "number"
29
+ }
30
+ }
31
+ },
22
32
  onSelect: {
23
33
  action: "select"
24
34
  }
@@ -26,33 +36,27 @@ const meta = {
26
36
  };
27
37
  export default meta;
28
38
  export const Docs = {
29
- parameters: {
30
- chromatic: {
31
- // disableSnapshot: false,
32
- }
33
- },
34
39
  render: (args) => ({
35
40
  components: {
36
41
  AntCalendar
37
42
  },
38
43
  setup() {
39
- const value = ref(Date.now());
40
44
  return {
41
- value,
42
45
  args
43
46
  };
44
47
  },
45
48
  template: `
46
49
  <div class="p-4">
47
- <div class="dashed w-64">
50
+ <div class="dashed w-72.5">
48
51
  <AntCalendar
49
52
  v-bind="args"
50
- v-model="value"
53
+ v-model="args.modelValue"
51
54
  />
52
55
  </div>
53
56
  </div>`
54
57
  }),
55
58
  args: {
59
+ modelValue: (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0),
56
60
  specialDays: [
57
61
  {
58
62
  name: "Special Day",
@@ -62,3 +66,116 @@ export const Docs = {
62
66
  ]
63
67
  }
64
68
  };
69
+ export const Summary = {
70
+ parameters: {
71
+ chromatic: {
72
+ disableSnapshot: false
73
+ }
74
+ },
75
+ render: (args) => ({
76
+ components: {
77
+ AntCalendar,
78
+ AntFormGroup,
79
+ AntFormGroupLabel
80
+ },
81
+ setup() {
82
+ const fixedDate = (/* @__PURE__ */ new Date("2026-01-01")).getTime();
83
+ const value = ref(fixedDate);
84
+ return {
85
+ value,
86
+ args,
87
+ fixedDate
88
+ };
89
+ },
90
+ template: `
91
+ <AntFormGroup class="p-4 flex flex-col gap-4 w-fit">
92
+ <AntFormGroup>
93
+ <AntFormGroupLabel>Standard States</AntFormGroupLabel>
94
+
95
+ <AntFormGroup class="grid grid-cols-4 gap-10">
96
+ <div class="flex flex-col w-64 gap-2">
97
+ <span>1. Working days only</span>
98
+ <AntCalendar v-model="value" :show-weekend="false" />
99
+ </div>
100
+
101
+ <div class="flex flex-col w-64 gap-2">
102
+ <span>2. With Weekends</span>
103
+ <AntCalendar v-model="value" :show-weekend="true" />
104
+ </div>
105
+
106
+ <div class="flex flex-col w-64 gap-2">
107
+ <span>3. With Week Numbers</span>
108
+ <AntCalendar v-model="value" :show-week-numbers="true" />
109
+ </div>
110
+
111
+ <div class="flex flex-col w-64 gap-2">
112
+ <span>4. Weekends & Week Numbers</span>
113
+ <AntCalendar v-model="value" :show-weekend="true" :show-week-numbers="true" />
114
+ </div>
115
+ </AntFormGroup>
116
+ </AntFormGroup>
117
+
118
+ <AntFormGroup>
119
+ <AntFormGroupLabel>Skeleton States</AntFormGroupLabel>
120
+
121
+ <AntFormGroup class="grid grid-cols-4 gap-10">
122
+ <div class="flex flex-col w-64 gap-2">
123
+ <span>1. Basic Skeleton</span>
124
+ <AntCalendar :model-value="fixedDate" skeleton />
125
+ </div>
126
+
127
+ <div class="flex flex-col w-64 gap-2">
128
+ <span>2. Skeleton + Weekends</span>
129
+ <AntCalendar :model-value="fixedDate" skeleton :show-weekend="true" />
130
+ </div>
131
+
132
+ <div class="flex flex-col w-64 gap-2">
133
+ <span>3. Skeleton + Week Numbers</span>
134
+ <AntCalendar :model-value="fixedDate" skeleton :show-week-numbers="true" />
135
+ </div>
136
+
137
+ <div class="flex flex-col w-64 gap-2">
138
+ <span>4. Full Skeleton</span>
139
+ <AntCalendar :model-value="fixedDate" skeleton :show-weekend="true" :show-week-numbers="true" />
140
+ </div>
141
+ </AntFormGroup>
142
+ </AntFormGroup>
143
+
144
+ <AntFormGroup>
145
+ <AntFormGroupLabel>Special Days</AntFormGroupLabel>
146
+
147
+ <AntFormGroup class="grid grid-cols-4 gap-4">
148
+ <div class="flex flex-col gap-2 w-64 col-span-2">
149
+ <span class="text-center">Calendar with highlights (Jan 2026)</span>
150
+ <AntCalendar
151
+ v-model="value"
152
+ :show-weekend="true"
153
+ :show-week-numbers="true"
154
+ :special-days="args.specialDays"
155
+ />
156
+ </div>
157
+ </AntFormGroup>
158
+ </AntFormGroup>
159
+ </AntFormGroup>`
160
+ }),
161
+ args: {
162
+ modelValue: (/* @__PURE__ */ new Date("2026-01-01")).getTime(),
163
+ specialDays: [
164
+ {
165
+ name: "New Year Day",
166
+ date: "2026-01-01",
167
+ color: "danger-200"
168
+ },
169
+ {
170
+ name: "Success Event",
171
+ date: "2026-01-05",
172
+ color: "success-200"
173
+ },
174
+ {
175
+ name: "Another Special",
176
+ date: "2026-01-15",
177
+ color: "warning-200"
178
+ }
179
+ ]
180
+ }
181
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "4.1.25",
3
+ "version": "4.1.26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {