@dayflow/react 3.0.0
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/dist/DayFlowCalendar.d.ts +45 -0
- package/dist/hooks/useCalendarApp.d.ts +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ReactNode, type FC } from 'react';
|
|
2
|
+
import { type ICalendarApp, type UseCalendarAppReturn } from '@dayflow/core';
|
|
3
|
+
export interface DayFlowCalendarProps {
|
|
4
|
+
calendar: ICalendarApp | UseCalendarAppReturn;
|
|
5
|
+
/** Custom event content renderer (React) */
|
|
6
|
+
eventContent?: (args: {
|
|
7
|
+
event: any;
|
|
8
|
+
isAllDay: boolean;
|
|
9
|
+
isMobile: boolean;
|
|
10
|
+
}) => ReactNode;
|
|
11
|
+
/** Custom event detail panel content (React) */
|
|
12
|
+
eventDetailContent?: (args: {
|
|
13
|
+
event: any;
|
|
14
|
+
position: any;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}) => ReactNode;
|
|
17
|
+
/** Custom event detail dialog (React) */
|
|
18
|
+
eventDetailDialog?: (args: {
|
|
19
|
+
event: any;
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
onEventUpdate: any;
|
|
23
|
+
onEventDelete: any;
|
|
24
|
+
isAllDay: boolean;
|
|
25
|
+
app: any;
|
|
26
|
+
}) => ReactNode;
|
|
27
|
+
/** Custom calendar header content (React) */
|
|
28
|
+
headerContent?: (args: any) => ReactNode;
|
|
29
|
+
/** Custom create calendar dialog (React) */
|
|
30
|
+
createCalendarDialog?: (args: {
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
onCreate: (calendar: any) => void;
|
|
33
|
+
colorPickerMode?: string;
|
|
34
|
+
}) => ReactNode;
|
|
35
|
+
/** Title bar slot (React) */
|
|
36
|
+
titleBarSlot?: ReactNode | ((context: {
|
|
37
|
+
isCollapsed: boolean;
|
|
38
|
+
toggleCollapsed: () => void;
|
|
39
|
+
}) => ReactNode);
|
|
40
|
+
/** Custom color picker renderer (React) */
|
|
41
|
+
colorPicker?: (args: any) => ReactNode;
|
|
42
|
+
/** Custom color picker wrapper renderer (React) */
|
|
43
|
+
colorPickerWrapper?: (args: any) => ReactNode;
|
|
44
|
+
}
|
|
45
|
+
export declare const DayFlowCalendar: FC<DayFlowCalendarProps>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './DayFlowCalendar';
|
|
2
|
+
export * from './hooks/useCalendarApp';
|
|
3
|
+
export { CalendarApp, CalendarRegistry, createDragPlugin, createEventsPlugin, createDayView, createWeekView, createMonthView, createYearView, ViewType, } from '@dayflow/core';
|
|
4
|
+
export * from '@dayflow/core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{useRef as n,useState as a,useEffect as i,useMemo as o}from"react";import{createPortal as s}from"react-dom";import{CalendarRenderer as l,CalendarApp as c}from"@dayflow/core";export*from"@dayflow/core";export{CalendarApp,CalendarRegistry,ViewType,createDayView,createDragPlugin,createEventsPlugin,createMonthView,createWeekView,createYearView}from"@dayflow/core";const u=({calendar:c,...u})=>{const g=n(null),d=n(null),[f,p]=a(new Map),[y,C]=a(!1),m=c?.app||c,v=n([]);i(()=>{if(C(!0),!g.current||!m)return;const e=new l(m);d.current=e,e.mount(g.current);const t=e.getCustomRenderingStore().subscribe(e=>{p(new Map(e))});return()=>{t(),e.unmount(),d.current=null}},[m]),i(()=>{if(!d.current)return;const e=d.current.getCustomRenderingStore(),t=Object.keys(u).filter(e=>void 0!==u[e]);JSON.stringify(v.current)!==JSON.stringify(t)&&(e.setOverrides(t),v.current=t)},[u]);const w=o(()=>y?Array.from(f.values()).map(e=>{const{id:t,containerEl:r,generatorName:n,generatorArgs:a}=e,i=u[n];if(!i)return null;const o="function"==typeof i?i(a):i;return s(o,r,t)}):[],[f,u,y]);return e(t,{children:[r("div",{ref:g,className:"df-calendar-wrapper"}),y&&w]})};function g(e){const t=o(()=>new c(e),[]),[,r]=a(0),s=n(e);return i(()=>{if(!t)return;const e=t.subscribe(()=>{r(e=>e+1)});return()=>{e()}},[t]),i(()=>{t&&JSON.stringify(s.current)!==JSON.stringify(e)&&(t.updateConfig(e),s.current=e)},[t,e]),{app:t,currentView:t.state.currentView,currentDate:t.state.currentDate,events:t.getEvents(),applyEventsChanges:t.applyEventsChanges,changeView:t.changeView,setCurrentDate:t.setCurrentDate,addEvent:t.addEvent,updateEvent:t.updateEvent,deleteEvent:t.deleteEvent,undo:t.undo,goToToday:t.goToToday,goToPrevious:t.goToPrevious,goToNext:t.goToNext,selectDate:t.selectDate,getCalendars:t.getCalendars,createCalendar:t.createCalendar,mergeCalendars:t.mergeCalendars,setCalendarVisibility:t.setCalendarVisibility,setAllCalendarsVisibility:t.setAllCalendarsVisibility,getAllEvents:t.getAllEvents,highlightEvent:t.highlightEvent,setVisibleMonth:t.setVisibleMonth,getVisibleMonth:t.getVisibleMonth,sidebarConfig:t.getSidebarConfig(),readOnlyConfig:t.getReadOnlyConfig()}}export{u as DayFlowCalendar,g as useCalendarApp};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("react-dom"),n=require("@dayflow/core");Object.defineProperty(exports,"CalendarApp",{enumerable:!0,get:function(){return n.CalendarApp}}),Object.defineProperty(exports,"CalendarRegistry",{enumerable:!0,get:function(){return n.CalendarRegistry}}),Object.defineProperty(exports,"ViewType",{enumerable:!0,get:function(){return n.ViewType}}),Object.defineProperty(exports,"createDayView",{enumerable:!0,get:function(){return n.createDayView}}),Object.defineProperty(exports,"createDragPlugin",{enumerable:!0,get:function(){return n.createDragPlugin}}),Object.defineProperty(exports,"createEventsPlugin",{enumerable:!0,get:function(){return n.createEventsPlugin}}),Object.defineProperty(exports,"createMonthView",{enumerable:!0,get:function(){return n.createMonthView}}),Object.defineProperty(exports,"createWeekView",{enumerable:!0,get:function(){return n.createWeekView}}),Object.defineProperty(exports,"createYearView",{enumerable:!0,get:function(){return n.createYearView}}),exports.DayFlowCalendar=({calendar:a,...i})=>{const s=t.useRef(null),u=t.useRef(null),[o,c]=t.useState(new Map),[l,g]=t.useState(!1),d=a?.app||a,f=t.useRef([]);t.useEffect(()=>{if(g(!0),!s.current||!d)return;const e=new n.CalendarRenderer(d);u.current=e,e.mount(s.current);const t=e.getCustomRenderingStore().subscribe(e=>{c(new Map(e))});return()=>{t(),e.unmount(),u.current=null}},[d]),t.useEffect(()=>{if(!u.current)return;const e=u.current.getCustomRenderingStore(),t=Object.keys(i).filter(e=>void 0!==i[e]);JSON.stringify(f.current)!==JSON.stringify(t)&&(e.setOverrides(t),f.current=t)},[i]);const p=t.useMemo(()=>l?Array.from(o.values()).map(e=>{const{id:t,containerEl:n,generatorName:a,generatorArgs:s}=e,u=i[a];if(!u)return null;const o="function"==typeof u?u(s):u;return r.createPortal(o,n,t)}):[],[o,i,l]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:s,className:"df-calendar-wrapper"}),l&&p]})},exports.useCalendarApp=function(e){const r=t.useMemo(()=>new n.CalendarApp(e),[]),[,a]=t.useState(0),i=t.useRef(e);return t.useEffect(()=>{if(!r)return;const e=r.subscribe(()=>{a(e=>e+1)});return()=>{e()}},[r]),t.useEffect(()=>{r&&JSON.stringify(i.current)!==JSON.stringify(e)&&(r.updateConfig(e),i.current=e)},[r,e]),{app:r,currentView:r.state.currentView,currentDate:r.state.currentDate,events:r.getEvents(),applyEventsChanges:r.applyEventsChanges,changeView:r.changeView,setCurrentDate:r.setCurrentDate,addEvent:r.addEvent,updateEvent:r.updateEvent,deleteEvent:r.deleteEvent,undo:r.undo,goToToday:r.goToToday,goToPrevious:r.goToPrevious,goToNext:r.goToNext,selectDate:r.selectDate,getCalendars:r.getCalendars,createCalendar:r.createCalendar,mergeCalendars:r.mergeCalendars,setCalendarVisibility:r.setCalendarVisibility,setAllCalendarsVisibility:r.setAllCalendarsVisibility,getAllEvents:r.getAllEvents,highlightEvent:r.highlightEvent,setVisibleMonth:r.setVisibleMonth,getVisibleMonth:r.getVisibleMonth,sidebarConfig:r.getSidebarConfig(),readOnlyConfig:r.getReadOnlyConfig()}},Object.keys(n).forEach(function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dayflow/react",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "React adapter for DayFlow calendar",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"build": "rollup -c"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": ">=18.0.0",
|
|
19
|
+
"react-dom": ">=18.0.0",
|
|
20
|
+
"@dayflow/core": "workspace:*"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"react": "^18.3.1",
|
|
24
|
+
"react-dom": "^18.3.1",
|
|
25
|
+
"@dayflow/core": "workspace:*",
|
|
26
|
+
"typescript": "^5.7.2",
|
|
27
|
+
"rollup": "^4.29.1",
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
30
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
31
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
32
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
33
|
+
"@types/react": "^18.3.12",
|
|
34
|
+
"@types/react-dom": "^18.3.1"
|
|
35
|
+
}
|
|
36
|
+
}
|