v-calendar-3 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,142 +1,308 @@
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.0.1`
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" />
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
+ The `string` and `number` model modifiers are also supported. Numeric values use
143
+ JavaScript timestamp milliseconds.
90
144
 
91
- export default {
92
- components: {
93
- Calendar,
94
- DatePicker,
95
- },
96
- data() {
97
- return {
98
- date: new Date(),
99
- };
100
- },
101
- }
102
- </script>
145
+ ```vue
146
+ <DatePicker v-model.string="isoDate" />
147
+ <DatePicker v-model.number="timestamp" />
103
148
  ```
104
149
 
105
- ## Source setup
150
+ ## Custom input
106
151
 
107
- Please follow below mentioned steps to clone and build this project:
152
+ Provide the default slot to connect the date picker to an application-owned
153
+ input. The supplied event object handles parsing, debouncing, focus, and popover
154
+ visibility.
108
155
 
109
- ### Clone the repo
156
+ ```vue
157
+ <DatePicker v-model="selectedDate">
158
+ <template #default="{ inputValue, inputEvents }">
159
+ <input
160
+ :value="inputValue"
161
+ v-on="inputEvents"
162
+ aria-label="Select date"
163
+ />
164
+ </template>
165
+ </DatePicker>
166
+ ```
110
167
 
111
- ```sh
112
- git clone https://github.com/BEJIbXEOP/v-calendar
168
+ For a range picker, `inputValue` and `inputEvents` contain separate `start` and
169
+ `end` properties.
113
170
 
114
- # Move to directory
115
- cd v-calendar
171
+ ## Bounds and disabled dates
172
+
173
+ `min-date`, `max-date`, `disabled-dates`, and attribute dates accept native
174
+ `Date` values, JavaScript timestamps, and supported ISO strings.
175
+
176
+ ```vue
177
+ <Calendar
178
+ min-date="2026-01-01"
179
+ max-date="2026-12-31"
180
+ :disabled-dates="[
181
+ '2026-12-25',
182
+ { start: '2026-12-31', end: '2027-01-02' },
183
+ ]"
184
+ />
116
185
  ```
117
186
 
118
- ### Install dependencies
187
+ ISO date-only strings are interpreted as calendar dates in the configured
188
+ timezone. Invalid bounds are ignored instead of disabling the entire calendar.
189
+ Non-standard date strings such as `1900.01.01` are deliberately rejected.
119
190
 
120
- ```sh
121
- yarn
191
+ ## Timezones
192
+
193
+ Use an IANA timezone name or `UTC`. When omitted, the browser's local timezone
194
+ is used.
195
+
196
+ ```vue
197
+ <Calendar timezone="America/New_York" />
198
+ <DatePicker v-model="dateTime" mode="dateTime" timezone="UTC" />
122
199
  ```
123
200
 
124
- ### Build library
201
+ Timezone calculations preserve local-midnight dates and account for daylight
202
+ saving transitions.
203
+
204
+ ## Themes
205
+
206
+ Light mode is the default. Explicit component configuration takes precedence
207
+ over document and operating-system preferences.
208
+
209
+ ```vue
210
+ <Calendar :is-dark="false" />
211
+ <Calendar :is-dark="true" />
212
+ <Calendar is-dark="system" />
213
+ <Calendar :is-dark="{ selector: ':root', darkClass: 'dark' }" />
214
+ ```
215
+
216
+ Automatic mode observes system-theme changes. It also respects explicit
217
+ ancestor themes such as `data-bs-theme="light"`, `data-theme="dark"`, and
218
+ inline `color-scheme` declarations.
219
+
220
+ The built-in color names are `gray`, `red`, `orange`, `yellow`, `green`, `teal`,
221
+ `blue`, `indigo`, `purple`, and `pink`.
222
+
223
+ ## Layout customization
224
+
225
+ Calendar geometry is exposed through CSS custom properties. Override variables
226
+ on a calendar instance or an application wrapper instead of coupling application
227
+ styles to internal selectors.
228
+
229
+ ```css
230
+ .compact-calendar {
231
+ --vc-container-bg: transparent;
232
+ --vc-pane-min-width: 13rem;
233
+ --vc-weeks-min-width: 13rem;
234
+ --vc-day-min-height: 1.75rem;
235
+ --vc-day-content-width: 1.75rem;
236
+ --vc-day-content-height: 1.75rem;
237
+ --vc-highlight-width: 1.75rem;
238
+ --vc-highlight-height: 1.75rem;
239
+ --vc-header-margin-top: 0;
240
+ --vc-time-picker-padding: 0 0.5rem;
241
+ --vc-time-select-group-bg: transparent;
242
+ }
243
+ ```
244
+
245
+ The variables cover container backgrounds, pane and week dimensions, header
246
+ spacing, day and highlight geometry, time-picker layout, and select controls.
247
+ Defaults are listed in [`src/styles/theme.css`](src/styles/theme.css).
248
+
249
+ ## Public exports
250
+
251
+ | Export | Purpose |
252
+ | --- | --- |
253
+ | default | Vue plugin that registers all public components |
254
+ | `Calendar` | Calendar component |
255
+ | `DatePicker` | Date and time picker component |
256
+ | `Popover`, `PopoverRow` | Public popover components |
257
+ | `setupCalendar` | Installs global defaults without registering components |
258
+ | `popoverDirective` | Popover trigger directive |
259
+ | `PopoverOptions` | TypeScript type for popover configuration |
260
+ | `createCalendar`, `useCalendar` | Calendar composables |
261
+ | `createDatePicker`, `useDatePicker` | Date picker composables |
262
+
263
+ Detailed API documentation is available under [`docs/calendar`](docs/calendar)
264
+ and [`docs/datepicker`](docs/datepicker).
265
+
266
+ ## Migration from `v-calendar-fixed`
267
+
268
+ `v-calendar-3@1.0.1` starts a new package lineage. Replace package imports and
269
+ the CSS import; the Vue component API remains compatible.
270
+
271
+ ```diff
272
+ - import VCalendar from 'v-calendar-fixed';
273
+ - import 'v-calendar-fixed/style.css';
274
+ + import VCalendar from 'v-calendar-3';
275
+ + import 'v-calendar-3/style.css';
276
+ ```
277
+
278
+ ## Development
125
279
 
126
280
  ```sh
127
- # Types, ES, ESM, CommonJS, IIFE
128
- yarn build
281
+ git clone https://github.com/BEJIbXEOP/v-calendar.git
282
+ cd v-calendar
283
+ npm install
129
284
  ```
130
285
 
131
- ### Lint and fix files
286
+ Install the browser binaries before the first browser-test run.
132
287
 
133
288
  ```sh
134
- yarn lint
289
+ npx playwright install
135
290
  ```
136
291
 
137
- ### Test library
292
+ Available validation commands:
138
293
 
139
294
  ```sh
140
- # Types, ES, ESM, CommonJS, IIFE
141
- yarn test
295
+ npm run lint
296
+ npm run typecheck
297
+ npm run test:unit
298
+ npm run test:browser
299
+ npm run build
300
+ npm run check:package
301
+ npm run validate
142
302
  ```
303
+
304
+ The browser matrix includes Chromium, Firefox, desktop WebKit, and touch WebKit.
305
+
306
+ ## License
307
+
308
+ [MIT](LICENSE)