@forcecalendar/core 0.2.1 → 0.3.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.
@@ -142,6 +142,14 @@ export class Calendar {
142
142
  });
143
143
  }
144
144
 
145
+ /**
146
+ * Alias for goToDate (compat)
147
+ * @param {Date} date - The date to navigate to
148
+ */
149
+ setDate(date) {
150
+ this.goToDate(date);
151
+ }
152
+
145
153
  /**
146
154
  * Get the current date
147
155
  * @returns {Date}
@@ -199,6 +207,15 @@ export class Calendar {
199
207
  return removed;
200
208
  }
201
209
 
210
+ /**
211
+ * Alias for removeEvent (compat)
212
+ * @param {string} eventId - The event ID
213
+ * @returns {boolean} True if removed
214
+ */
215
+ deleteEvent(eventId) {
216
+ return this.removeEvent(eventId);
217
+ }
218
+
202
219
  /**
203
220
  * Get an event by ID
204
221
  * @param {string} eventId - The event ID
@@ -281,6 +298,26 @@ export class Calendar {
281
298
  return this.config.timeZone;
282
299
  }
283
300
 
301
+ /**
302
+ * Set the calendar locale
303
+ * @param {string} locale - Locale identifier (e.g. 'en-US')
304
+ */
305
+ setLocale(locale) {
306
+ this.config.locale = locale;
307
+ this.state.setState({ locale });
308
+ this._emit('localeChange', { locale });
309
+ }
310
+
311
+ /**
312
+ * Set the week start day
313
+ * @param {number} weekStartsOn - 0 = Sunday, 1 = Monday, etc.
314
+ */
315
+ setWeekStartsOn(weekStartsOn) {
316
+ this.config.weekStartsOn = weekStartsOn;
317
+ this.state.setState({ weekStartsOn });
318
+ this._emit('weekStartsOnChange', { weekStartsOn });
319
+ }
320
+
284
321
  /**
285
322
  * Convert a date from one timezone to another
286
323
  * @param {Date} date - Date to convert
@@ -178,10 +178,12 @@ export class Event {
178
178
  organizer = null,
179
179
  attendees = [],
180
180
  reminders = [],
181
- categories = [],
181
+ category, // Support singular category (no default)
182
+ categories, // Support plural categories (no default)
182
183
  attachments = [],
183
184
  conferenceData = null,
184
- metadata = {}
185
+ metadata = {},
186
+ ...rest // Capture any extra properties
185
187
  }) {
186
188
  // Normalize and validate input
187
189
  const normalized = Event.normalize({
@@ -205,10 +207,12 @@ export class Event {
205
207
  organizer,
206
208
  attendees,
207
209
  reminders,
208
- categories,
210
+ category, // Pass category to normalize
211
+ categories, // Pass categories to normalize
209
212
  attachments,
210
213
  conferenceData,
211
- metadata
214
+ metadata,
215
+ ...rest // Pass any extra properties
212
216
  });
213
217
 
214
218
  // Validate normalized data
@@ -262,7 +266,7 @@ export class Event {
262
266
  this.reminders = [...normalized.reminders];
263
267
 
264
268
  // Categories/Tags
265
- this.categories = [...normalized.categories];
269
+ this.categories = normalized.categories ? [...normalized.categories] : [];
266
270
 
267
271
  // Attachments
268
272
  this.attachments = [...normalized.attachments];
package/core/index.js CHANGED
@@ -19,7 +19,7 @@ export { ICSHandler } from './ics/ICSHandler.js';
19
19
  export { EventSearch } from './search/EventSearch.js';
20
20
 
21
21
  // Version
22
- export const VERSION = '0.2.0';
22
+ export const VERSION = '0.3.0';
23
23
 
24
24
  // Default export
25
25
  export { Calendar as default } from './calendar/Calendar.js';
@@ -295,8 +295,8 @@ export class TimezoneManager {
295
295
  const offsetHours = -offset / 60;
296
296
 
297
297
  // Try to match offset to known timezone
298
- for (const [tz, tzOffset] of Object.entries(this.timezoneOffsets)) {
299
- if (tzOffset === offsetHours) {
298
+ for (const [tz, tzData] of Object.entries(this.database.timezones)) {
299
+ if (tzData.offset / 60 === offsetHours) {
300
300
  return tz;
301
301
  }
302
302
  }
@@ -313,14 +313,14 @@ export class TimezoneManager {
313
313
  if (!tzString) return 'UTC';
314
314
 
315
315
  // Check if it's already an IANA identifier
316
- if (this.timezoneOffsets.hasOwnProperty(tzString)) {
316
+ if (this.database.timezones.hasOwnProperty(tzString)) {
317
317
  return tzString;
318
318
  }
319
319
 
320
320
  // Check abbreviations
321
321
  const upperTz = tzString.toUpperCase();
322
- if (this.timezoneAbbreviations.hasOwnProperty(upperTz)) {
323
- return this.timezoneAbbreviations[upperTz];
322
+ if (this.database.abbreviations && this.database.abbreviations.hasOwnProperty(upperTz)) {
323
+ return this.database.abbreviations[upperTz];
324
324
  }
325
325
 
326
326
  // Try to parse offset format (e.g., "+05:30", "-08:00")
@@ -332,8 +332,8 @@ export class TimezoneManager {
332
332
  const totalOffset = sign * (hours + minutes / 60);
333
333
 
334
334
  // Find matching timezone
335
- for (const [tz, offset] of Object.entries(this.timezoneOffsets)) {
336
- if (offset === totalOffset) {
335
+ for (const [tz, tzData] of Object.entries(this.database.timezones)) {
336
+ if (tzData.offset / 60 === totalOffset) {
337
337
  return tz;
338
338
  }
339
339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forcecalendar/core",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "A modern, lightweight, framework-agnostic calendar engine optimized for Salesforce",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "git+https://github.com/ForceCalendar/force-calendar-core.git"
27
+ "url": "git+https://github.com/forceCalendar/core.git"
28
28
  },
29
29
  "keywords": [
30
30
  "calendar",
@@ -40,9 +40,9 @@
40
40
  "author": "",
41
41
  "license": "MIT",
42
42
  "bugs": {
43
- "url": "https://github.com/ForceCalendar/force-calendar-core/issues"
43
+ "url": "https://github.com/forceCalendar/core/issues"
44
44
  },
45
- "homepage": "https://github.com/ForceCalendar/force-calendar-core#readme",
45
+ "homepage": "https://github.com/forceCalendar/core#readme",
46
46
  "devDependencies": {
47
47
  "@babel/core": "^7.23.0",
48
48
  "@babel/preset-env": "^7.23.0",