@jsb188/calendar 1.1.12 → 1.1.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jsb188
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@jsb188/calendar",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Calendar and scheduling surface for web.",
5
- "license": "ISC",
5
+ "license": "MIT",
6
6
  "author": "jsb188",
7
7
  "type": "module",
8
8
  "exports": {
@@ -22,24 +22,30 @@
22
22
  "./ui/CalendarUI": "./src/ui/CalendarUI.tsx",
23
23
  "./ui/CalendarYearUI": "./src/ui/CalendarYearUI.tsx",
24
24
  "./libs/roster-layout": "./src/libs/roster-layout.ts",
25
- "./ui/RosterUI": "./src/ui/RosterUI.tsx",
26
- "./ui/ShiftFormUI": "./src/ui/ShiftFormUI.tsx",
27
- "./types/shift-form.d.ts": "./src/types/shift-form.d.ts"
25
+ "./ui/RosterUI": "./src/ui/RosterUI.tsx"
28
26
  },
29
27
  "peerDependencies": {
30
- "@jsb188/app": "1.1.12",
31
- "@jsb188/graphql": "1.1.12",
32
- "@jsb188/mday": "1.1.12",
33
- "@jsb188/react": "1.1.12",
34
- "@jsb188/react-web": "1.1.12",
28
+ "@jsb188/app": "1.1.13",
29
+ "@jsb188/graphql": "1.1.13",
30
+ "@jsb188/mday": "1.1.13",
31
+ "@jsb188/react": "1.1.13",
32
+ "@jsb188/react-web": "1.1.13",
35
33
  "jotai": "^2.20.2",
36
34
  "luxon": "^3.7.2",
37
35
  "react": "^19.3.0",
38
36
  "react-router": "^8.4.0",
39
- "@jsb188/form": "1.1.12"
37
+ "@jsb188/form": "1.1.13"
40
38
  },
41
39
  "scripts": {
42
40
  "test": "vitest run --config ./vitest.config.ts --passWithNoTests",
43
41
  "build": "tsc"
44
- }
42
+ },
43
+ "files": [
44
+ "src/**/*.{ts,tsx,css,svg}",
45
+ "!**/*.test.*",
46
+ "!**/*.spec.*",
47
+ "!**/tests/**",
48
+ "!**/*.md",
49
+ "!**/.DS_Store"
50
+ ]
45
51
  }
@@ -111,12 +111,8 @@ export const CALENDAR_SEARCH_PARAMS = {
111
111
  calendar: 'cal',
112
112
  room: 'room',
113
113
  groupByRoom: 'rooms',
114
- panel: 'p',
115
- open: 'o',
116
114
  date: 'd',
117
115
  mine: 'me',
118
- // The calendars the viewer has HIDDEN; absent means show everything
119
- hiddenCalendars: 'hide',
120
116
  } as const;
121
117
 
122
118
  /**
@@ -141,9 +137,9 @@ export const CALENDAR_DEFAULT_VIEW: CalendarViewEnum = 'WEEK';
141
137
  export const CALENDAR_DATE_PARAM_FORMAT = 'yyyy-MM-dd';
142
138
 
143
139
  /**
144
- * Occurrence status → surface treatment. DRAFT is drawn with the shared
145
- * stripe pattern so an unpublished shift reads as provisional at a glance,
146
- * and CANCELED is struck through rather than hidden — somebody looking for a
140
+ * Seat status → surface treatment. DRAFT is drawn with the shared stripe
141
+ * pattern so an unpublished shift reads as provisional at a glance, and
142
+ * CANCELED is struck through rather than hidden — somebody looking for a
147
143
  * shift that was cancelled needs to find it, not wonder where it went.
148
144
  */
149
145
 
@@ -179,9 +179,8 @@ function buildMonthDays(
179
179
  *
180
180
  * The year view is a NAVIGATION surface, not a display one: twelve mini month
181
181
  * grids you click to jump into. It deliberately does not draw events, so this
182
- * only has to produce the days — which is also why the page skips the
183
- * occurrence query entirely for this view rather than asking for a year of
184
- * shifts and silently truncating them at the window limit.
182
+ * only has to produce the days; a caller should not fetch events for this
183
+ * view (a year of them would be truncated at any read limit).
185
184
  */
186
185
 
187
186
  function buildYearDays(anchor: DateTime, todayKey: string): CalendarDayObj[] {
@@ -13,12 +13,12 @@ import {
13
13
  * The calendar's URL state.
14
14
  *
15
15
  * The URL is the calendar's state store for anything a person might want to
16
- * link to or come back to: which view, which date, whose shifts, which
17
- * calendars. It is kept deliberately terse and readable — one- and two-letter
18
- * keys, lowercase view slugs, and every default omitted — so that
16
+ * link to or come back to: which calendar, which view, which date, whose
17
+ * shifts, which room. It is kept deliberately terse and readable — one- and
18
+ * two-letter keys, lowercase view slugs, and every default omitted — so that
19
19
  *
20
20
  * /app/calendar
21
- * /app/calendar?v=month&d=2026-07-25
21
+ * /app/calendar?cal=<id>&v=roster&d=2026-07-25
22
22
  * /app/calendar?me=1
23
23
  *
24
24
  * are what somebody actually sees in the address bar, rather than a query
@@ -33,16 +33,9 @@ export interface CalendarUrlState {
33
33
  calendarId: string | null;
34
34
  roomId: string | null;
35
35
  groupByRoom: boolean;
36
- panel: 'open' | 'requests' | 'timeoff' | 'publish' | 'settings' | null;
37
- openId: string | null;
38
36
  view: CalendarViewEnum;
39
37
  anchorDate: Date;
40
38
  mineOnly: boolean;
41
- // Calendars the viewer has explicitly HIDDEN — a blocklist, not a
42
- // whitelist. Empty therefore means "show everything", which is what makes
43
- // a calendar the viewer was just granted access to appear on its own
44
- // instead of staying invisible until they find and tick it.
45
- hiddenCalendarIds: string[];
46
39
  }
47
40
 
48
41
  const VIEW_BY_SLUG: Record<string, CalendarViewEnum> = Object.fromEntries(
@@ -95,18 +88,10 @@ export function readCalendarUrlState(
95
88
  now: Date,
96
89
  timeZone?: string | null,
97
90
  ): CalendarUrlState {
98
- const calendars = searchParams.get(CALENDAR_SEARCH_PARAMS.hiddenCalendars);
99
-
100
91
  return {
101
- calendarId: searchParams.get('cal') || null,
102
- roomId: searchParams.get('room') || null,
103
- groupByRoom: searchParams.get('rooms') === '1',
104
- panel: ['open', 'requests', 'timeoff', 'publish', 'settings'].includes(
105
- searchParams.get('p') || '',
106
- )
107
- ? (searchParams.get('p') as CalendarUrlState['panel'])
108
- : null,
109
- openId: searchParams.get('o') || null,
92
+ calendarId: searchParams.get(CALENDAR_SEARCH_PARAMS.calendar) || null,
93
+ roomId: searchParams.get(CALENDAR_SEARCH_PARAMS.room) || null,
94
+ groupByRoom: searchParams.get(CALENDAR_SEARCH_PARAMS.groupByRoom) === '1',
110
95
  view: parseCalendarViewSlug(searchParams.get(CALENDAR_SEARCH_PARAMS.view)),
111
96
  anchorDate: parseCalendarDateParam(
112
97
  searchParams.get(CALENDAR_SEARCH_PARAMS.date),
@@ -114,12 +99,6 @@ export function readCalendarUrlState(
114
99
  timeZone,
115
100
  ),
116
101
  mineOnly: searchParams.get(CALENDAR_SEARCH_PARAMS.mine) === '1',
117
- hiddenCalendarIds: calendars
118
- ? calendars
119
- .split(',')
120
- .map((id) => id.trim())
121
- .filter(Boolean)
122
- : [],
123
102
  };
124
103
  }
125
104
 
@@ -170,22 +149,20 @@ export function writeCalendarUrlState(
170
149
  setOrDelete(CALENDAR_SEARCH_PARAMS.mine, next.mineOnly ? '1' : null);
171
150
  }
172
151
 
173
- if (next.hiddenCalendarIds !== undefined) {
152
+ if (next.calendarId !== undefined) {
153
+ setOrDelete(CALENDAR_SEARCH_PARAMS.calendar, next.calendarId || null);
154
+ }
155
+
156
+ if (next.roomId !== undefined) {
157
+ setOrDelete(CALENDAR_SEARCH_PARAMS.room, next.roomId || null);
158
+ }
159
+
160
+ if (next.groupByRoom !== undefined) {
174
161
  setOrDelete(
175
- CALENDAR_SEARCH_PARAMS.hiddenCalendars,
176
- next.hiddenCalendarIds.length ? next.hiddenCalendarIds.join(',') : null,
162
+ CALENDAR_SEARCH_PARAMS.groupByRoom,
163
+ next.groupByRoom ? '1' : null,
177
164
  );
178
165
  }
179
166
 
180
- for (const [field, key] of [
181
- ['calendarId', 'cal'],
182
- ['roomId', 'room'],
183
- ['panel', 'p'],
184
- ['openId', 'o'],
185
- ] as const) {
186
- if (next[field] !== undefined) setOrDelete(key, next[field] || null);
187
- }
188
- if (next.groupByRoom !== undefined)
189
- setOrDelete('rooms', next.groupByRoom ? '1' : null);
190
167
  return params;
191
168
  }