@craftguild/jscalendar 0.5.0 → 0.5.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 +44 -36
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,20 +84,6 @@ const task = new JsCal.Task({
|
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Id maps use `{ id, value }` entries. If you need to merge into an
|
|
88
|
-
existing map, pass it as the second argument. Entries with `id` overwrite
|
|
89
|
-
matching ids; entries without `id` get new generated ids.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
const mergedLocations = JsCal.locations(
|
|
93
|
-
[
|
|
94
|
-
{ id: "l1", value: { name: "Room A Updated" } },
|
|
95
|
-
{ value: { name: "Room B" } },
|
|
96
|
-
],
|
|
97
|
-
existingLocations,
|
|
98
|
-
);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
87
|
### Group
|
|
102
88
|
|
|
103
89
|
`entries` accepts either plain JSCalendar objects (including `eject()` results)
|
|
@@ -204,17 +190,59 @@ plain.title = "Exported";
|
|
|
204
190
|
const updated = event.patch({ title: "Live" });
|
|
205
191
|
```
|
|
206
192
|
|
|
207
|
-
##
|
|
193
|
+
## Patch Usage
|
|
208
194
|
|
|
209
195
|
Patch helpers return new instances and keep metadata such as
|
|
210
196
|
`updated` and `sequence` consistent. Use `patch` for RFC 8984 PatchObject
|
|
211
|
-
semantics.
|
|
197
|
+
semantics. You can set raw values directly, or use helper methods if you
|
|
198
|
+
prefer validated, type-safe inputs.
|
|
212
199
|
|
|
213
200
|
```ts
|
|
214
201
|
const patchedEvent = event.patch({ title: "Updated title" });
|
|
215
202
|
const patchedAgain = patchedEvent.patch({ title: "Patched title" });
|
|
216
203
|
```
|
|
217
204
|
|
|
205
|
+
You can also patch nested maps by replacing the full map in one call:
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
const withParticipants = event.patch({
|
|
209
|
+
participants: {
|
|
210
|
+
p1: { "@type": "Participant", roles: { attendee: true }, email: "a@example.com" },
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Two common patterns for nested patches:
|
|
216
|
+
|
|
217
|
+
1) Set raw values directly
|
|
218
|
+
```ts
|
|
219
|
+
const withLocations = event.patch({
|
|
220
|
+
locations: {
|
|
221
|
+
l1: { "@type": "Location", name: "Room A" },
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
2) Use helpers to build or merge map values
|
|
227
|
+
```ts
|
|
228
|
+
const withLocations = event.patch({
|
|
229
|
+
locations: JsCal.locations([
|
|
230
|
+
{ id: "l1", value: JsCal.Location({ name: "Room A" }) },
|
|
231
|
+
{ value: JsCal.Location({ name: "Room B" }) },
|
|
232
|
+
]),
|
|
233
|
+
});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
To merge into an existing map, pass the current map as the second argument:
|
|
237
|
+
```ts
|
|
238
|
+
const withLocations = event.patch({
|
|
239
|
+
locations: JsCal.locations(
|
|
240
|
+
[{ value: JsCal.Location({ name: "Room C" }) }],
|
|
241
|
+
event.data.locations,
|
|
242
|
+
),
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
218
246
|
## Date Inputs and Time Zones
|
|
219
247
|
|
|
220
248
|
Date fields accept either RFC 8984 strings or JavaScript `Date`. When a
|
|
@@ -351,26 +379,6 @@ const icalMany = JsCal.toICal([event, task], { includeXJSCalendar: true });
|
|
|
351
379
|
console.log(icalMany);
|
|
352
380
|
```
|
|
353
381
|
|
|
354
|
-
## Practical Example
|
|
355
|
-
|
|
356
|
-
**Weekly engineering sync (every Wednesday 10:30, 1 hour)**
|
|
357
|
-
|
|
358
|
-
```ts
|
|
359
|
-
const weekly = new JsCal.Event({
|
|
360
|
-
title: "Engineering Sync",
|
|
361
|
-
start: "2026-02-04T10:30:00",
|
|
362
|
-
timeZone: "Asia/Tokyo",
|
|
363
|
-
duration: JsCal.duration.hours(1),
|
|
364
|
-
recurrenceRules: [
|
|
365
|
-
{
|
|
366
|
-
"@type": "RecurrenceRule",
|
|
367
|
-
frequency: "weekly",
|
|
368
|
-
byDay: [{ "@type": "NDay", day: "we" }],
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
});
|
|
372
|
-
```
|
|
373
|
-
|
|
374
382
|
## Compliance and Deviations
|
|
375
383
|
|
|
376
384
|
### RFC 8984 Conformance (Implemented)
|