@dayflow/plugin-sidebar 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -16,17 +16,17 @@ views, and plugin architecture.
16
16
 
17
17
  | Monthly | Weekly |
18
18
  | --------------------------------------- | -------------------------------------- |
19
- | ![image](./assets/images/MonthView.png) | ![image](./assets/images/WeekView.png) |
19
+ | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/MonthView.png) | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/WeekView.png) |
20
20
 
21
21
  | Daily | Event Stack Level |
22
22
  | ------------------------------------- | ---------------------------------------- |
23
- | ![image](./assets/images/DayView.png) | ![image](./assets/images/stackLevel.png) |
23
+ | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/DayView.png) | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/stackLevel.png) |
24
24
 
25
25
  ### Default Panel (with multiple Event Detail Panel options available)
26
26
 
27
27
  | Detail Popup | Detail Dialog |
28
28
  | ----------------------------------- | ------------------------------------ |
29
- | ![image](./assets/images/popup.png) | ![image](./assets/images/dialog.png) |
29
+ | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/popup.png) | ![image](https://raw.githubusercontent.com/dayflow-js/calendar/main/assets/images/dialog.png) |
30
30
 
31
31
  ### Easy to resize and drag
32
32
 
package/dist/index.d.ts CHANGED
@@ -13,14 +13,14 @@ interface CalendarSidebarRenderProps {
13
13
  editingCalendarId?: string | null;
14
14
  setEditingCalendarId?: (id: string | null) => void;
15
15
  onCreateCalendar?: () => void;
16
- colorPickerMode?: 'blossom' | 'default';
16
+ colorPickerMode?: 'default' | 'custom';
17
17
  }
18
18
  interface SidebarPluginConfig {
19
19
  width?: number | string;
20
20
  miniWidth?: string;
21
21
  initialCollapsed?: boolean;
22
22
  createCalendarMode?: 'inline' | 'modal';
23
- colorPickerMode?: 'blossom' | 'default';
23
+ colorPickerMode?: 'default' | 'custom';
24
24
  render?: (props: CalendarSidebarRenderProps) => TNode;
25
25
  renderCalendarContextMenu?: (calendar: CalendarType, onClose: () => void) => TNode;
26
26
  renderCreateCalendarDialog?: (props: CreateCalendarDialogProps) => TNode;
package/dist/index.esm.js CHANGED
@@ -49,7 +49,7 @@ const getCalendarInitials = (calendar) => {
49
49
  const name = calendar.name || calendar.id;
50
50
  return name.charAt(0).toUpperCase();
51
51
  };
52
- const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, onColorClick, editingId, setEditingId, activeContextMenuCalendarId, isDraggable = true, isEditable = true, }) => {
52
+ const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, editingId, setEditingId, activeContextMenuCalendarId, isDraggable = true, isEditable = true, }) => {
53
53
  const [editingName, setEditingName] = useState('');
54
54
  const editInputRef = useRef(null);
55
55
  const isProcessedRef = useRef(false);
@@ -182,12 +182,7 @@ const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onCo
182
182
  editingId === calendar.id;
183
183
  return (u("li", { className: "df-calendar-list-item relative", onDragOver: e => handleDragOver(e, calendar.id), onDragLeave: handleDragLeave, onDrop: () => handleDrop(calendar), onContextMenu: e => onContextMenu(e, calendar.id), children: [isDropTarget && dropTarget.position === 'top' && (u("div", { className: "absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" })), u("div", { draggable: isDraggable && !editingId, onDragStart: e => handleDragStart(calendar, e), onDragEnd: handleDragEnd, className: `rounded transition ${draggedCalendarId === calendar.id ? 'opacity-50' : ''} ${isDraggable ? 'cursor-grab' : 'cursor-default'}`, children: u("div", { className: `group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 ${isActive ? 'bg-gray-100 dark:bg-slate-800' : ''}`, title: calendar.name, children: [u("input", { type: "checkbox", className: "calendar-checkbox cursor-pointer shrink-0", style: {
184
184
  '--checkbox-color': calendarColor,
185
- }, checked: isVisible, onChange: event => onToggleVisibility(calendar.id, event.target.checked), onClick: e => {
186
- if (onColorClick && isVisible) {
187
- e.preventDefault();
188
- onColorClick(e, calendar.id);
189
- }
190
- } }), showIcon && (u("span", { className: "ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white", "aria-hidden": "true", children: getCalendarInitials(calendar) })), editingId === calendar.id ? (u("input", { ref: editInputRef, type: "text", value: editingName, onChange: e => setEditingName(e.target.value), onBlur: handleRenameSave, onKeyDown: handleRenameKeyDown, className: "ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100", onClick: e => e.stopPropagation() })) : (u("span", { className: "flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2", onDblClick: () => handleRenameStart(calendar), children: calendar.name || calendar.id }))] }) }), isDropTarget && dropTarget.position === 'bottom' && (u("div", { className: "absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" }))] }, calendar.id));
185
+ }, checked: isVisible, onChange: event => onToggleVisibility(calendar.id, event.target.checked) }), showIcon && (u("span", { className: "ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white", "aria-hidden": "true", children: getCalendarInitials(calendar) })), editingId === calendar.id ? (u("input", { ref: editInputRef, type: "text", value: editingName, onChange: e => setEditingName(e.target.value), onBlur: handleRenameSave, onKeyDown: handleRenameKeyDown, className: "ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100", onClick: e => e.stopPropagation() })) : (u("span", { className: "flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2", onDblClick: () => handleRenameStart(calendar), children: calendar.name || calendar.id }))] }) }), isDropTarget && dropTarget.position === 'bottom' && (u("div", { className: "absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" }))] }, calendar.id));
191
186
  }) }) }));
192
187
  };
193
188
 
@@ -357,29 +352,6 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
357
352
  const handleCloseSidebarContextMenu = useCallback(() => {
358
353
  setSidebarContextMenu(null);
359
354
  }, []);
360
- const handleColorClick = useCallback((e, calendarId) => {
361
- e.preventDefault();
362
- e.stopPropagation();
363
- const calendar = calendars.find(c => c.id === calendarId);
364
- if (calendar) {
365
- const { l, h } = hexToHsl(calendar.colors.lineColor);
366
- const sliderValue = lightnessToSliderValue(l);
367
- const rect = e.currentTarget.getBoundingClientRect();
368
- setCustomColorPicker({
369
- x: rect.left + rect.width / 2,
370
- y: rect.top + rect.height / 2,
371
- calendarId: calendarId,
372
- initialColor: {
373
- hue: h,
374
- saturation: sliderValue,
375
- lightness: l,
376
- alpha: 100,
377
- layer: 'outer',
378
- },
379
- currentColor: calendar.colors.lineColor,
380
- });
381
- }
382
- }, [calendars]);
383
355
  const handleDeleteCalendar = useCallback(() => {
384
356
  if (contextMenu) {
385
357
  setDeleteState({ calendarId: contextMenu.calendarId, step: 'initial' });
@@ -552,9 +524,9 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
552
524
  const isDraggable = readOnlyConfig.draggable !== false;
553
525
  return (u("div", { className: sidebarContainer, onContextMenu: isEditable ? handleSidebarContextMenu : undefined, children: [u(SidebarHeader, { isCollapsed: isCollapsed, onCollapseToggle: () => setCollapsed(!isCollapsed) }), !isCollapsed ? (u(Fragment, { children: [u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
554
526
  ? (id, newName) => app.updateCalendar(id, { name: newName })
555
- : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, onColorClick: isEditable ? handleColorClick : undefined, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable }), u("div", { className: "border-t border-gray-200 dark:border-slate-800", children: u(MiniCalendar, { visibleMonth: app.getVisibleMonth(), currentDate: app.getCurrentDate(), showHeader: true, onMonthChange: handleMonthChange, onDateSelect: date => app.setCurrentDate(date) }) })] })) : (u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
527
+ : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable }), u("div", { className: "border-t border-gray-200 dark:border-slate-800", children: u(MiniCalendar, { visibleMonth: app.getVisibleMonth(), currentDate: app.getCurrentDate(), showHeader: true, onMonthChange: handleMonthChange, onDateSelect: date => app.setCurrentDate(date) }) })] })) : (u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
556
528
  ? (id, newName) => app.updateCalendar(id, { name: newName })
557
- : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, onColorClick: isEditable ? handleColorClick : undefined, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable })), contextMenu && (u(ContextMenu, { ref: contextMenuRef, x: contextMenu.x, y: contextMenu.y, onClose: handleCloseContextMenu, className: "w-64 p-2", children: u(ContentSlot, { generatorName: "calendarContextMenu", generatorArgs: {
529
+ : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable })), contextMenu && (u(ContextMenu, { ref: contextMenuRef, x: contextMenu.x, y: contextMenu.y, onClose: handleCloseContextMenu, className: "w-64 p-2", children: u(ContentSlot, { generatorName: "calendarContextMenu", generatorArgs: {
558
530
  calendar: calendars.find(c => c.id === contextMenu.calendarId),
559
531
  onClose: handleCloseContextMenu,
560
532
  }, defaultContent: renderCalendarContextMenu ? (renderCalendarContextMenu(calendars.find(c => c.id === contextMenu.calendarId), handleCloseContextMenu)) : (u(Fragment, { children: [u(ContextMenuLabel, { children: t('calendarOptions') }), u(MergeMenuItem, { calendars: calendars, currentCalendarId: contextMenu.calendarId, onMergeSelect: handleMergeSelect }), u(ContextMenuItem, { onClick: handleDeleteCalendar, children: t('delete') }), u(ContextMenuItem, { onClick: handleExportCalendar, children: t('exportCalendar') || 'Export Calendar' }), u(ContextMenuSeparator, {}), u(ContextMenuColorPicker, { selectedColor: (_d = calendars.find(c => c.id === contextMenu.calendarId)) === null || _d === void 0 ? void 0 : _d.colors.lineColor, onSelect: handleColorSelect, onCustomColor: handleCustomColor })] })) }) })), sidebarContextMenu &&
@@ -575,7 +547,7 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
575
547
  top: customColorPicker.y,
576
548
  left: customColorPicker.x,
577
549
  transform: 'translate(280%, -50%)',
578
- }, onMouseDown: e => e.stopPropagation(), children: colorPickerMode === 'blossom' ? (u(BlossomColorPicker, { defaultValue: customColorPicker.initialColor, coreSize: 28, petalSize: 28, initialExpanded: true, adaptivePositioning: true, openOnHover: false, onChange: color => {
550
+ }, onMouseDown: e => e.stopPropagation(), children: colorPickerMode === 'custom' ? (u(BlossomColorPicker, { defaultValue: customColorPicker.initialColor, coreSize: 28, petalSize: 28, initialExpanded: true, adaptivePositioning: true, openOnHover: false, onChange: color => {
579
551
  const { colors, darkColors } = getCalendarColorsForHex(color.hex);
580
552
  app.updateCalendar(customColorPicker.calendarId, {
581
553
  colors,
@@ -585,7 +557,7 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
585
557
  app.updateCalendar(customColorPicker.calendarId, {});
586
558
  setCustomColorPicker(null);
587
559
  } })) : (u(ContentSlot, { generatorName: "colorPicker", generatorArgs: {
588
- variant: 'sketch',
560
+ variant: 'sketch', // TODO: change name
589
561
  color: customColorPicker.currentColor,
590
562
  onChange: (color) => {
591
563
  setCustomColorPicker(prev => prev ? Object.assign(Object.assign({}, prev), { currentColor: color.hex }) : null);
@@ -641,6 +613,11 @@ function createSidebarPlugin(config = {}) {
641
613
  const refreshSidebar = useCallback(() => {
642
614
  setSidebarVersion(prev => prev + 1);
643
615
  }, []);
616
+ useEffect(() => {
617
+ return app.subscribe(() => {
618
+ refreshSidebar();
619
+ });
620
+ }, [app, refreshSidebar]);
644
621
  const calendars = useMemo(() => app.getCalendars(), [app, sidebarVersion]);
645
622
  const handleToggleCalendarVisibility = useCallback((calendarId, visible) => {
646
623
  app.setCalendarVisibility(calendarId, visible);
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ const getCalendarInitials = (calendar) => {
51
51
  const name = calendar.name || calendar.id;
52
52
  return name.charAt(0).toUpperCase();
53
53
  };
54
- const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, onColorClick, editingId, setEditingId, activeContextMenuCalendarId, isDraggable = true, isEditable = true, }) => {
54
+ const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, editingId, setEditingId, activeContextMenuCalendarId, isDraggable = true, isEditable = true, }) => {
55
55
  const [editingName, setEditingName] = hooks.useState('');
56
56
  const editInputRef = hooks.useRef(null);
57
57
  const isProcessedRef = hooks.useRef(false);
@@ -184,12 +184,7 @@ const CalendarList = ({ calendars, onToggleVisibility, onReorder, onRename, onCo
184
184
  editingId === calendar.id;
185
185
  return (u("li", { className: "df-calendar-list-item relative", onDragOver: e => handleDragOver(e, calendar.id), onDragLeave: handleDragLeave, onDrop: () => handleDrop(calendar), onContextMenu: e => onContextMenu(e, calendar.id), children: [isDropTarget && dropTarget.position === 'top' && (u("div", { className: "absolute top-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" })), u("div", { draggable: isDraggable && !editingId, onDragStart: e => handleDragStart(calendar, e), onDragEnd: handleDragEnd, className: `rounded transition ${draggedCalendarId === calendar.id ? 'opacity-50' : ''} ${isDraggable ? 'cursor-grab' : 'cursor-default'}`, children: u("div", { className: `group flex items-center rounded px-2 py-2 transition hover:bg-gray-100 dark:hover:bg-slate-800 ${isActive ? 'bg-gray-100 dark:bg-slate-800' : ''}`, title: calendar.name, children: [u("input", { type: "checkbox", className: "calendar-checkbox cursor-pointer shrink-0", style: {
186
186
  '--checkbox-color': calendarColor,
187
- }, checked: isVisible, onChange: event => onToggleVisibility(calendar.id, event.target.checked), onClick: e => {
188
- if (onColorClick && isVisible) {
189
- e.preventDefault();
190
- onColorClick(e, calendar.id);
191
- }
192
- } }), showIcon && (u("span", { className: "ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white", "aria-hidden": "true", children: getCalendarInitials(calendar) })), editingId === calendar.id ? (u("input", { ref: editInputRef, type: "text", value: editingName, onChange: e => setEditingName(e.target.value), onBlur: handleRenameSave, onKeyDown: handleRenameKeyDown, className: "ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100", onClick: e => e.stopPropagation() })) : (u("span", { className: "flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2", onDblClick: () => handleRenameStart(calendar), children: calendar.name || calendar.id }))] }) }), isDropTarget && dropTarget.position === 'bottom' && (u("div", { className: "absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" }))] }, calendar.id));
187
+ }, checked: isVisible, onChange: event => onToggleVisibility(calendar.id, event.target.checked) }), showIcon && (u("span", { className: "ml-2 flex h-5 w-5 shrink-0 items-center justify-center text-xs font-semibold text-white", "aria-hidden": "true", children: getCalendarInitials(calendar) })), editingId === calendar.id ? (u("input", { ref: editInputRef, type: "text", value: editingName, onChange: e => setEditingName(e.target.value), onBlur: handleRenameSave, onKeyDown: handleRenameKeyDown, className: "ml-2 flex-1 min-w-0 h-5 rounded bg-white px-0 py-0 text-sm text-gray-900 focus:outline-none dark:bg-slate-700 dark:text-gray-100", onClick: e => e.stopPropagation() })) : (u("span", { className: "flex-1 pl-1 truncate text-sm text-gray-700 group-hover:text-gray-900 dark:text-gray-200 dark:group-hover:text-white ml-2", onDblClick: () => handleRenameStart(calendar), children: calendar.name || calendar.id }))] }) }), isDropTarget && dropTarget.position === 'bottom' && (u("div", { className: "absolute bottom-0 left-0 right-0 h-0.5 bg-primary z-10 pointer-events-none" }))] }, calendar.id));
193
188
  }) }) }));
194
189
  };
195
190
 
@@ -359,29 +354,6 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
359
354
  const handleCloseSidebarContextMenu = hooks.useCallback(() => {
360
355
  setSidebarContextMenu(null);
361
356
  }, []);
362
- const handleColorClick = hooks.useCallback((e, calendarId) => {
363
- e.preventDefault();
364
- e.stopPropagation();
365
- const calendar = calendars.find(c => c.id === calendarId);
366
- if (calendar) {
367
- const { l, h } = blossomColorPicker.hexToHsl(calendar.colors.lineColor);
368
- const sliderValue = blossomColorPicker.lightnessToSliderValue(l);
369
- const rect = e.currentTarget.getBoundingClientRect();
370
- setCustomColorPicker({
371
- x: rect.left + rect.width / 2,
372
- y: rect.top + rect.height / 2,
373
- calendarId: calendarId,
374
- initialColor: {
375
- hue: h,
376
- saturation: sliderValue,
377
- lightness: l,
378
- alpha: 100,
379
- layer: 'outer',
380
- },
381
- currentColor: calendar.colors.lineColor,
382
- });
383
- }
384
- }, [calendars]);
385
357
  const handleDeleteCalendar = hooks.useCallback(() => {
386
358
  if (contextMenu) {
387
359
  setDeleteState({ calendarId: contextMenu.calendarId, step: 'initial' });
@@ -554,9 +526,9 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
554
526
  const isDraggable = readOnlyConfig.draggable !== false;
555
527
  return (u("div", { className: core.sidebarContainer, onContextMenu: isEditable ? handleSidebarContextMenu : undefined, children: [u(SidebarHeader, { isCollapsed: isCollapsed, onCollapseToggle: () => setCollapsed(!isCollapsed) }), !isCollapsed ? (u(preact.Fragment, { children: [u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
556
528
  ? (id, newName) => app.updateCalendar(id, { name: newName })
557
- : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, onColorClick: isEditable ? handleColorClick : undefined, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable }), u("div", { className: "border-t border-gray-200 dark:border-slate-800", children: u(core.MiniCalendar, { visibleMonth: app.getVisibleMonth(), currentDate: app.getCurrentDate(), showHeader: true, onMonthChange: handleMonthChange, onDateSelect: date => app.setCurrentDate(date) }) })] })) : (u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
529
+ : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable }), u("div", { className: "border-t border-gray-200 dark:border-slate-800", children: u(core.MiniCalendar, { visibleMonth: app.getVisibleMonth(), currentDate: app.getCurrentDate(), showHeader: true, onMonthChange: handleMonthChange, onDateSelect: date => app.setCurrentDate(date) }) })] })) : (u(CalendarList, { calendars: calendars, onToggleVisibility: toggleCalendarVisibility, onReorder: isDraggable ? app.reorderCalendars : () => { }, onRename: isEditable
558
530
  ? (id, newName) => app.updateCalendar(id, { name: newName })
559
- : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, onColorClick: isEditable ? handleColorClick : undefined, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable })), contextMenu && (u(core.ContextMenu, { ref: contextMenuRef, x: contextMenu.x, y: contextMenu.y, onClose: handleCloseContextMenu, className: "w-64 p-2", children: u(core.ContentSlot, { generatorName: "calendarContextMenu", generatorArgs: {
531
+ : () => { }, onContextMenu: isEditable ? handleContextMenu : () => { }, editingId: editingCalendarId, setEditingId: setEditingCalendarId, activeContextMenuCalendarId: contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.calendarId, isDraggable: isDraggable, isEditable: isEditable })), contextMenu && (u(core.ContextMenu, { ref: contextMenuRef, x: contextMenu.x, y: contextMenu.y, onClose: handleCloseContextMenu, className: "w-64 p-2", children: u(core.ContentSlot, { generatorName: "calendarContextMenu", generatorArgs: {
560
532
  calendar: calendars.find(c => c.id === contextMenu.calendarId),
561
533
  onClose: handleCloseContextMenu,
562
534
  }, defaultContent: renderCalendarContextMenu ? (renderCalendarContextMenu(calendars.find(c => c.id === contextMenu.calendarId), handleCloseContextMenu)) : (u(preact.Fragment, { children: [u(core.ContextMenuLabel, { children: t('calendarOptions') }), u(MergeMenuItem, { calendars: calendars, currentCalendarId: contextMenu.calendarId, onMergeSelect: handleMergeSelect }), u(core.ContextMenuItem, { onClick: handleDeleteCalendar, children: t('delete') }), u(core.ContextMenuItem, { onClick: handleExportCalendar, children: t('exportCalendar') || 'Export Calendar' }), u(core.ContextMenuSeparator, {}), u(core.ContextMenuColorPicker, { selectedColor: (_d = calendars.find(c => c.id === contextMenu.calendarId)) === null || _d === void 0 ? void 0 : _d.colors.lineColor, onSelect: handleColorSelect, onCustomColor: handleCustomColor })] })) }) })), sidebarContextMenu &&
@@ -577,7 +549,7 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
577
549
  top: customColorPicker.y,
578
550
  left: customColorPicker.x,
579
551
  transform: 'translate(280%, -50%)',
580
- }, onMouseDown: e => e.stopPropagation(), children: colorPickerMode === 'blossom' ? (u(core.BlossomColorPicker, { defaultValue: customColorPicker.initialColor, coreSize: 28, petalSize: 28, initialExpanded: true, adaptivePositioning: true, openOnHover: false, onChange: color => {
552
+ }, onMouseDown: e => e.stopPropagation(), children: colorPickerMode === 'custom' ? (u(core.BlossomColorPicker, { defaultValue: customColorPicker.initialColor, coreSize: 28, petalSize: 28, initialExpanded: true, adaptivePositioning: true, openOnHover: false, onChange: color => {
581
553
  const { colors, darkColors } = core.getCalendarColorsForHex(color.hex);
582
554
  app.updateCalendar(customColorPicker.calendarId, {
583
555
  colors,
@@ -587,7 +559,7 @@ const DefaultCalendarSidebar = ({ app, calendars, toggleCalendarVisibility, isCo
587
559
  app.updateCalendar(customColorPicker.calendarId, {});
588
560
  setCustomColorPicker(null);
589
561
  } })) : (u(core.ContentSlot, { generatorName: "colorPicker", generatorArgs: {
590
- variant: 'sketch',
562
+ variant: 'sketch', // TODO: change name
591
563
  color: customColorPicker.currentColor,
592
564
  onChange: (color) => {
593
565
  setCustomColorPicker(prev => prev ? Object.assign(Object.assign({}, prev), { currentColor: color.hex }) : null);
@@ -643,6 +615,11 @@ function createSidebarPlugin(config = {}) {
643
615
  const refreshSidebar = hooks.useCallback(() => {
644
616
  setSidebarVersion(prev => prev + 1);
645
617
  }, []);
618
+ hooks.useEffect(() => {
619
+ return app.subscribe(() => {
620
+ refreshSidebar();
621
+ });
622
+ }, [app, refreshSidebar]);
646
623
  const calendars = hooks.useMemo(() => app.getCalendars(), [app, sidebarVersion]);
647
624
  const handleToggleCalendarVisibility = hooks.useCallback((calendarId, visible) => {
648
625
  app.setCalendarVisibility(calendarId, visible);
@@ -5,12 +5,11 @@ interface CalendarListProps {
5
5
  onReorder: (fromIndex: number, toIndex: number) => void;
6
6
  onRename: (id: string, newName: string) => void;
7
7
  onContextMenu: (e: any, id: string) => void;
8
- onColorClick?: (e: any, id: string) => void;
9
8
  editingId: string | null;
10
9
  setEditingId: (id: string | null) => void;
11
10
  activeContextMenuCalendarId?: string | null;
12
11
  isDraggable?: boolean;
13
12
  isEditable?: boolean;
14
13
  }
15
- export declare const CalendarList: ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, onColorClick, editingId, setEditingId, activeContextMenuCalendarId, isDraggable, isEditable, }: CalendarListProps) => import("preact").JSX.Element;
14
+ export declare const CalendarList: ({ calendars, onToggleVisibility, onReorder, onRename, onContextMenu, editingId, setEditingId, activeContextMenuCalendarId, isDraggable, isEditable, }: CalendarListProps) => import("preact").JSX.Element;
16
15
  export {};
@@ -12,14 +12,14 @@ export interface CalendarSidebarRenderProps {
12
12
  editingCalendarId?: string | null;
13
13
  setEditingCalendarId?: (id: string | null) => void;
14
14
  onCreateCalendar?: () => void;
15
- colorPickerMode?: 'blossom' | 'default';
15
+ colorPickerMode?: 'default' | 'custom';
16
16
  }
17
17
  export interface SidebarPluginConfig {
18
18
  width?: number | string;
19
19
  miniWidth?: string;
20
20
  initialCollapsed?: boolean;
21
21
  createCalendarMode?: 'inline' | 'modal';
22
- colorPickerMode?: 'blossom' | 'default';
22
+ colorPickerMode?: 'default' | 'custom';
23
23
  render?: (props: CalendarSidebarRenderProps) => TNode;
24
24
  renderCalendarContextMenu?: (calendar: CalendarType, onClose: () => void) => TNode;
25
25
  renderCreateCalendarDialog?: (props: CreateCalendarDialogProps) => TNode;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@dayflow/plugin-sidebar",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
+ "type": "module",
4
5
  "description": "Sidebar plugin for DayFlow calendar",
5
6
  "main": "dist/index.js",
6
7
  "module": "dist/index.esm.js",
@@ -26,7 +27,7 @@
26
27
  "author": "Jayce Li",
27
28
  "license": "MIT",
28
29
  "peerDependencies": {
29
- "@dayflow/core": "3.1.0"
30
+ "@dayflow/core": "3.1.2"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@dayflow/blossom-color-picker": "^2.0.1",
@@ -38,7 +39,7 @@
38
39
  "preact": "^10.25.4",
39
40
  "temporal-polyfill": "^0.3.0",
40
41
  "typescript": "^5.7.2",
41
- "@dayflow/core": "3.1.0"
42
+ "@dayflow/core": "3.1.2"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "tsc -p tsconfig.build.json && rollup -c",