@nomideusz/svelte-calendar 0.2.1 → 0.2.2

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 (2) hide show
  1. package/README.md +73 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -175,6 +175,79 @@ const custom = `
175
175
 
176
176
  </details>
177
177
 
178
+ ## Accessibility
179
+
180
+ All interactive elements include proper ARIA attributes and keyboard support:
181
+
182
+ - **EventBlock** — `role="button"`, `aria-label` (title + time + duration + status), `tabindex="0"`, Enter/Space activates
183
+ - **EmptySlot** — `role="button"`, `aria-label` (time range + duration), keyboard-accessible for event creation
184
+ - **NowIndicator** — `role="status"`, `aria-live="polite"` announces the current time
185
+ - **Calendar** — `role="region"`, `aria-label="Calendar"`
186
+ - **Toolbar** — `aria-label="Calendar navigation"`
187
+ - Focus-visible outlines on all interactive primitives
188
+
189
+ ## Locale & i18n
190
+
191
+ The calendar uses `Intl.DateTimeFormat` for all date/time formatting. Pass a BCP 47 locale tag to the `Calendar` shell:
192
+
193
+ ```svelte
194
+ <Calendar {views} {adapter} locale="pl-PL" dir="rtl" />
195
+ ```
196
+
197
+ | Prop | Type | Default | Description |
198
+ |------|------|---------|-------------|
199
+ | `locale` | `string` | `'en-US'` | BCP 47 tag — controls weekday names, month names, date formats |
200
+ | `dir` | `'ltr' \| 'rtl' \| 'auto'` | — | Text direction (for Arabic, Hebrew, etc.) |
201
+
202
+ The `locale` prop automatically switches between 12-hour and 24-hour time display based on the locale's hour cycle.
203
+
204
+ ### Programmatic locale control
205
+
206
+ ```ts
207
+ import { setDefaultLocale, getDefaultLocale, is24HourLocale } from '@nomideusz/svelte-calendar';
208
+
209
+ setDefaultLocale('de-DE'); // All formatting functions now use German
210
+ is24HourLocale('en-US'); // false (12h)
211
+ is24HourLocale('de-DE'); // true (24h)
212
+ ```
213
+
214
+ All formatting functions (`weekdayShort`, `monthLong`, `fmtDay`, `fmtWeekRange`, etc.) accept an optional `locale` parameter to override per-call.
215
+
216
+ ## Timezones
217
+
218
+ Timezone utilities are included via `date-fns-tz`:
219
+
220
+ ```ts
221
+ import {
222
+ toZonedTime,
223
+ fromZonedTime,
224
+ nowInZone,
225
+ formatInTimeZone,
226
+ } from '@nomideusz/svelte-calendar';
227
+
228
+ // Display a UTC date in a specific timezone
229
+ const nyTime = toZonedTime(utcDate, 'America/New_York');
230
+
231
+ // Convert back to UTC for storage
232
+ const utc = fromZonedTime(displayDate, 'America/New_York');
233
+
234
+ // Current time in Tokyo
235
+ const tokyoNow = nowInZone('Asia/Tokyo');
236
+
237
+ // Locale-aware formatting in a timezone
238
+ formatInTimeZone(date, 'Europe/Warsaw', { hour: 'numeric', minute: '2-digit' }, 'pl-PL');
239
+ // → "14:30"
240
+ ```
241
+
242
+ The engine's `createViewState` also accepts a `timezone` option:
243
+
244
+ ```ts
245
+ const viewState = createViewState({
246
+ defaultView: 'week-grid',
247
+ timezone: 'America/New_York', // stored on viewState.timezone
248
+ });
249
+ ```
250
+
178
251
  ## Architecture
179
252
 
180
253
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomideusz/svelte-calendar",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A themeable, pluggable Svelte 5 calendar with Day and Week views — Grid, Timeline, Agenda, Heatmap.",
5
5
  "type": "module",
6
6
  "license": "MIT",