v-calendar-3 1.0.0 → 1.1.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.
Files changed (34) hide show
  1. package/README.md +254 -80
  2. package/dist/cjs/index.css +144 -60
  3. package/dist/cjs/index.js +64 -22
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/es/index.js +64 -22
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/style.css +144 -60
  8. package/dist/iife/index.js +1 -1
  9. package/dist/iife/index.js.map +1 -1
  10. package/dist/mjs/index.mjs +64 -22
  11. package/dist/mjs/index.mjs.map +1 -1
  12. package/dist/mjs/style.css +144 -60
  13. package/dist/style.css +144 -60
  14. package/dist/types/components/Calendar/Calendar.vue.d.ts +9 -0
  15. package/dist/types/components/Calendar/CalendarHeader.vue.d.ts +1 -0
  16. package/dist/types/components/DatePicker/DatePicker.vue.d.ts +48 -0
  17. package/dist/types/components/DatePicker/TimePicker.vue.d.ts +32 -0
  18. package/dist/types/index.d.cts +128 -0
  19. package/dist/types/index.d.mts +128 -0
  20. package/dist/types/index.d.ts +128 -0
  21. package/dist/types/use/calendar.d.ts +7 -0
  22. package/dist/types/use/calendarGrid.d.ts +14 -0
  23. package/dist/types/use/datePicker.d.ts +64 -0
  24. package/dist/types/use/timePicker.d.ts +32 -0
  25. package/package.json +1 -1
  26. package/src/components/BaseSelect/BaseSelect.vue +11 -11
  27. package/src/components/Calendar/Calendar.vue +2 -2
  28. package/src/components/Calendar/CalendarDay.vue +12 -13
  29. package/src/components/Calendar/CalendarHeader.vue +49 -18
  30. package/src/components/Calendar/CalendarPage.vue +14 -5
  31. package/src/components/DatePicker/TimePicker.vue +21 -17
  32. package/src/styles/index.css +1 -1
  33. package/src/styles/theme.css +74 -5
  34. package/src/use/calendar.ts +42 -8
package/README.md CHANGED
@@ -1,142 +1,316 @@
1
- # VCalendar Plugin for Vue 3.5.16+
1
+ # v-calendar-3
2
2
 
3
- A calendar and date picker plugin for [Vue.js](https://vuejs.org).
3
+ A maintained Vue 3 calendar and date picker with TypeScript declarations,
4
+ timezone support, keyboard navigation, touch interaction, and responsive theme
5
+ handling.
4
6
 
5
- [Vue.js](https://vuejs.org) 3.2+, [Popper.js](https://popper.js.org/docs/v2/) 2.0+ are required.
7
+ Current version: `1.1.0`
6
8
 
7
- ## Install Plugin
9
+ ## Features
8
10
 
9
- ### NPM
11
+ - Monthly, weekly, and daily calendar views
12
+ - Single-date, range, date-time, and time selection
13
+ - Date attributes, highlights, dots, bars, popovers, and disabled dates
14
+ - Locale-aware formatting and IANA timezone conversion
15
+ - Strict ISO date parsing without UTC shifts for `YYYY-MM-DD` values
16
+ - Explicit light/dark themes and automatic system-theme updates
17
+ - Keyboard navigation, Escape handling, Pointer Events, and touch support
18
+ - SSR-safe browser access and iframe-aware theme/popover handling
19
+ - ESM, Node ESM, CommonJS, IIFE, CSS, and TypeScript declaration builds
10
20
 
11
- ```shell
12
- npm install v-calendar-3 @popperjs/core
13
- ```
21
+ ## Requirements
14
22
 
15
- ### Yarn
23
+ | Dependency | Supported version |
24
+ | --- | --- |
25
+ | Vue | `^3.5.16` |
26
+ | `@popperjs/core` | `^2.11.8` |
27
+ | Node.js for development | `^20.19.0 || >=22.12.0` |
16
28
 
17
- ```shell
18
- yarn add v-calendar-3 @popperjs/core
19
- ```
29
+ ## Installation
20
30
 
21
- ## Use Plugin
31
+ ```sh
32
+ npm install v-calendar-3 @popperjs/core
33
+ ```
22
34
 
23
- :warning: **As of `v3.0.0-alpha.7`, all installation methods require manual import of component styles. This is due to Vite build restrictions in libary mode.**
35
+ The stylesheet is a separate package export and must be imported once by the
36
+ application.
24
37
 
25
- ```js
38
+ ```ts
26
39
  import 'v-calendar-3/style.css';
27
40
  ```
28
41
 
29
- ### Method 1: Use Globally
42
+ ## Global plugin setup
30
43
 
31
- ```js
44
+ The default plugin registers `VCalendar`, `VDatePicker`, `VPopover`, and
45
+ `VPopoverRow`.
46
+
47
+ ```ts
48
+ // main.ts
49
+ import { createApp } from 'vue';
32
50
  import VCalendar from 'v-calendar-3';
33
51
  import 'v-calendar-3/style.css';
52
+ import App from './App.vue';
53
+
54
+ const app = createApp(App);
34
55
 
35
- // Use plugin with optional defaults
36
- app.use(VCalendar, {})
56
+ app.use(VCalendar, {
57
+ color: 'blue',
58
+ isDark: 'system',
59
+ });
60
+
61
+ app.mount('#app');
37
62
  ```
38
63
 
39
- ```html
40
- <!-- MyComponent.vue -->
64
+ ```vue
65
+ <script setup lang="ts">
66
+ import { ref } from 'vue';
67
+
68
+ const selectedDate = ref<Date | null>(new Date());
69
+ </script>
70
+
41
71
  <template>
42
72
  <VCalendar />
43
- <VDatePicker v-model="date" />
73
+ <VDatePicker v-model="selectedDate" />
44
74
  </template>
45
75
  ```
46
76
 
47
- ### Method 2: Use Components Globally
48
-
49
- ```js
50
- // main.js
51
- import { setupCalendar, Calendar, DatePicker } from 'v-calendar-3';
52
- import 'v-calendar-3/style.css';
77
+ The component prefix defaults to `V` and can be changed during plugin setup.
53
78
 
54
- // Use plugin defaults (optional)
55
- app.use(setupCalendar, {})
79
+ ```ts
80
+ app.use(VCalendar, {
81
+ componentPrefix: 'App',
82
+ });
56
83
 
57
- // Use the components
58
- app.component('VCalendar', Calendar)
59
- app.component('VDatePicker', DatePicker)
84
+ // Registers AppCalendar, AppDatePicker, AppPopover, and AppPopoverRow.
60
85
  ```
61
86
 
62
- ```html
63
- <!-- MyComponent.vue -->
87
+ ## Local component setup
88
+
89
+ Components can be imported without installing the global plugin.
90
+
91
+ ```vue
92
+ <script setup lang="ts">
93
+ import { ref } from 'vue';
94
+ import { Calendar, DatePicker } from 'v-calendar-3';
95
+ import 'v-calendar-3/style.css';
96
+
97
+ const selectedDate = ref<Date | null>(new Date());
98
+ const range = ref({
99
+ start: new Date(2026, 6, 13),
100
+ end: new Date(2026, 6, 17),
101
+ });
102
+
103
+ const attributes = [
104
+ {
105
+ key: 'today',
106
+ highlight: true,
107
+ dates: new Date(),
108
+ },
109
+ ];
110
+ </script>
111
+
64
112
  <template>
65
- <VCalendar />
66
- <VDatePicker v-model="date" />
113
+ <Calendar :attributes="attributes" />
114
+ <DatePicker v-model="selectedDate" />
115
+ <DatePicker v-model.range="range" :rows="2" />
67
116
  </template>
68
117
  ```
69
118
 
70
- ### Method 3: Use Components As Needed
119
+ Application-wide defaults can still be installed separately.
71
120
 
72
- ```js
73
- // main.js
121
+ ```ts
74
122
  import { setupCalendar } from 'v-calendar-3';
75
123
 
76
- // Use calendar defaults (optional)
77
- app.use(setupCalendar, {})
124
+ app.use(setupCalendar, {
125
+ color: 'indigo',
126
+ titlePosition: 'left',
127
+ });
78
128
  ```
79
129
 
130
+ ## Date picker modes
131
+
132
+ The default model is a JavaScript `Date`. Use the `range` modifier for date
133
+ ranges and the `mode` prop when time selection is required.
134
+
80
135
  ```vue
81
- <!-- MyComponent.vue -->
82
- <template>
83
- <Calendar />
84
- <DatePicker v-model="date">
85
- </template>
136
+ <DatePicker v-model="date" />
137
+ <DatePicker v-model.range="range" />
138
+ <DatePicker v-model="dateTime" mode="dateTime" is24hr />
139
+ <DatePicker v-model="time" mode="time" is24hr />
140
+ ```
86
141
 
87
- <script>
88
- import { Calendar, DatePicker } from 'v-calendar-3';
89
- import 'v-calendar-3/style.css';
142
+ `rows="2"` with the default `columns="1"` is the two-month period layout. It
143
+ renders both months horizontally with a complete navigation header and a
144
+ month/year picker on each pane. The displayed months remain consecutive, and
145
+ each pane includes muted leading and trailing dates from adjacent months so its
146
+ week rows are complete. With `trim-weeks`, both period panes are balanced to the
147
+ larger visible week count.
90
148
 
91
- export default {
92
- components: {
93
- Calendar,
94
- DatePicker,
95
- },
96
- data() {
97
- return {
98
- date: new Date(),
99
- };
100
- },
101
- }
102
- </script>
149
+ The `string` and `number` model modifiers are also supported. Numeric values use
150
+ JavaScript timestamp milliseconds.
151
+
152
+ ```vue
153
+ <DatePicker v-model.string="isoDate" />
154
+ <DatePicker v-model.number="timestamp" />
103
155
  ```
104
156
 
105
- ## Source setup
157
+ ## Custom input
158
+
159
+ Provide the default slot to connect the date picker to an application-owned
160
+ input. The supplied event object handles parsing, debouncing, focus, and popover
161
+ visibility.
162
+
163
+ ```vue
164
+ <DatePicker v-model="selectedDate">
165
+ <template #default="{ inputValue, inputEvents }">
166
+ <input
167
+ :value="inputValue"
168
+ v-on="inputEvents"
169
+ aria-label="Select date"
170
+ />
171
+ </template>
172
+ </DatePicker>
173
+ ```
106
174
 
107
- Please follow below mentioned steps to clone and build this project:
175
+ For a range picker, `inputValue` and `inputEvents` contain separate `start` and
176
+ `end` properties.
108
177
 
109
- ### Clone the repo
178
+ ## Bounds and disabled dates
110
179
 
111
- ```sh
112
- git clone https://github.com/BEJIbXEOP/v-calendar
180
+ `min-date`, `max-date`, `disabled-dates`, and attribute dates accept native
181
+ `Date` values, JavaScript timestamps, and supported ISO strings.
113
182
 
114
- # Move to directory
115
- cd v-calendar
183
+ ```vue
184
+ <Calendar
185
+ min-date="2026-01-01"
186
+ max-date="2026-12-31"
187
+ :disabled-dates="[
188
+ '2026-12-25',
189
+ { start: '2026-12-31', end: '2027-01-02' },
190
+ ]"
191
+ />
116
192
  ```
117
193
 
118
- ### Install dependencies
194
+ ISO date-only strings are interpreted as calendar dates in the configured
195
+ timezone. Invalid bounds are ignored instead of disabling the entire calendar.
196
+ Non-standard date strings such as `1900.01.01` are deliberately rejected.
119
197
 
120
- ```sh
121
- yarn
198
+ ## Timezones
199
+
200
+ Use an IANA timezone name or `UTC`. When omitted, the browser's local timezone
201
+ is used.
202
+
203
+ ```vue
204
+ <Calendar timezone="America/New_York" />
205
+ <DatePicker v-model="dateTime" mode="dateTime" timezone="UTC" />
206
+ ```
207
+
208
+ Timezone calculations preserve local-midnight dates and account for daylight
209
+ saving transitions.
210
+
211
+ ## Themes
212
+
213
+ Light mode is the default. Explicit component configuration takes precedence
214
+ over document and operating-system preferences.
215
+
216
+ ```vue
217
+ <Calendar :is-dark="false" />
218
+ <Calendar :is-dark="true" />
219
+ <Calendar is-dark="system" />
220
+ <Calendar :is-dark="{ selector: ':root', darkClass: 'dark' }" />
221
+ ```
222
+
223
+ Automatic mode observes system-theme changes. It also respects explicit
224
+ ancestor themes such as `data-bs-theme="light"`, `data-theme="dark"`, and
225
+ inline `color-scheme` declarations.
226
+
227
+ The built-in color names are `gray`, `red`, `orange`, `yellow`, `green`, `teal`,
228
+ `blue`, `indigo`, `purple`, and `pink`.
229
+
230
+ ## Layout customization
231
+
232
+ Calendar geometry is exposed through CSS custom properties. Override variables
233
+ on a calendar instance or an application wrapper instead of coupling application
234
+ styles to internal selectors.
235
+
236
+ ```css
237
+ .compact-calendar {
238
+ --vc-container-bg: transparent;
239
+ --vc-pane-min-width: 13rem;
240
+ --vc-weeks-min-width: 13rem;
241
+ --vc-day-min-height: 1.75rem;
242
+ --vc-day-content-width: 1.75rem;
243
+ --vc-day-content-height: 1.75rem;
244
+ --vc-day-content-outside-month-opacity: 0.6;
245
+ --vc-highlight-width: 1.75rem;
246
+ --vc-highlight-height: 1.75rem;
247
+ --vc-header-margin-top: 0;
248
+ --vc-time-picker-padding: 0 0.5rem;
249
+ --vc-time-select-group-bg: transparent;
250
+ }
251
+ ```
252
+
253
+ The variables cover container backgrounds, pane and week dimensions, header
254
+ spacing, day and highlight geometry, time-picker layout, and select controls.
255
+ Defaults are listed in [`src/styles/theme.css`](src/styles/theme.css).
256
+
257
+ ## Public exports
258
+
259
+ | Export | Purpose |
260
+ | --- | --- |
261
+ | default | Vue plugin that registers all public components |
262
+ | `Calendar` | Calendar component |
263
+ | `DatePicker` | Date and time picker component |
264
+ | `Popover`, `PopoverRow` | Public popover components |
265
+ | `setupCalendar` | Installs global defaults without registering components |
266
+ | `popoverDirective` | Popover trigger directive |
267
+ | `PopoverOptions` | TypeScript type for popover configuration |
268
+ | `createCalendar`, `useCalendar` | Calendar composables |
269
+ | `createDatePicker`, `useDatePicker` | Date picker composables |
270
+
271
+ Detailed API documentation is available under [`docs/calendar`](docs/calendar)
272
+ and [`docs/datepicker`](docs/datepicker).
273
+
274
+ ## Migration from `v-calendar-fixed`
275
+
276
+ `v-calendar-3@1.0.1` starts a new package lineage. Replace package imports and
277
+ the CSS import; the Vue component API remains compatible.
278
+
279
+ ```diff
280
+ - import VCalendar from 'v-calendar-fixed';
281
+ - import 'v-calendar-fixed/style.css';
282
+ + import VCalendar from 'v-calendar-3';
283
+ + import 'v-calendar-3/style.css';
122
284
  ```
123
285
 
124
- ### Build library
286
+ ## Development
125
287
 
126
288
  ```sh
127
- # Types, ES, ESM, CommonJS, IIFE
128
- yarn build
289
+ git clone https://github.com/BEJIbXEOP/v-calendar.git
290
+ cd v-calendar
291
+ npm install
129
292
  ```
130
293
 
131
- ### Lint and fix files
294
+ Install the browser binaries before the first browser-test run.
132
295
 
133
296
  ```sh
134
- yarn lint
297
+ npx playwright install
135
298
  ```
136
299
 
137
- ### Test library
300
+ Available validation commands:
138
301
 
139
302
  ```sh
140
- # Types, ES, ESM, CommonJS, IIFE
141
- yarn test
303
+ npm run lint
304
+ npm run typecheck
305
+ npm run test:unit
306
+ npm run test:browser
307
+ npm run build
308
+ npm run check:package
309
+ npm run validate
142
310
  ```
311
+
312
+ The browser matrix includes Chromium, Firefox, desktop WebKit, and touch WebKit.
313
+
314
+ ## License
315
+
316
+ [MIT](LICENSE)