@react-agendfy/plugin-export-reports 0.0.0-stage → 2.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/CHANGELOG.md +70 -0
- package/dist/index.cjs.js +4 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +90 -0
- package/dist/index.es.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/package.json +34 -3
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @react-agendfy/plugin-export-reports
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f9a62af: v2 modernization release. See MIGRATION.md for the full v1 → v2 guide.
|
|
8
|
+
|
|
9
|
+
**@react-agendfy/core (major — breaking):**
|
|
10
|
+
|
|
11
|
+
- Fully typed public API: `CalendarProps`/`Config` no longer accept arbitrary
|
|
12
|
+
keys; `Calendar` is a named export with a working `forwardRef`.
|
|
13
|
+
- CSS class namespace unified to `react-agendfy-*` (old `react-agenfy-*` typo
|
|
14
|
+
and `fc-*` classes removed) — custom CSS overrides must update selectors.
|
|
15
|
+
- New 3-layer design-token system scoped under `.agendfy`
|
|
16
|
+
(`--agendfy-*`; legacy `--color-*`/`--padding-*` names kept via a compat
|
|
17
|
+
layer), OS-aware dark mode, `theme` now applied via a scoped `data-theme`
|
|
18
|
+
attribute on the calendar root instead of mutating `document.documentElement`.
|
|
19
|
+
- Built-in i18n catalog (en, pt, pt-BR, es, fr, ar) with user-config override;
|
|
20
|
+
`lang: 'pt'` now resolves to European Portuguese (use `'pt-BR'` for
|
|
21
|
+
Brazilian). Automatic RTL via `lang` or the new `direction` prop.
|
|
22
|
+
- WCAG 2.1 AA accessibility: grid semantics, roving-tabindex arrow-key
|
|
23
|
+
navigation, keyboard-operable events and drag & drop.
|
|
24
|
+
- Correctness fixes: export crash, horizontal drag discarded as click,
|
|
25
|
+
off-slot events not rendering, multi-day duration collapse on drag, resize
|
|
26
|
+
off-by-one and timezone drift, inert data-source plugins.
|
|
27
|
+
|
|
28
|
+
**@react-agendfy/ai (new):** provider-agnostic AI layer — natural-language
|
|
29
|
+
event parsing (with an offline deterministic fallback), conflict detection and
|
|
30
|
+
free-slot search (deterministic), LLM-assisted scheduling suggestions,
|
|
31
|
+
calendar insights, React hooks, and a Quick Add header plugin. Ships an
|
|
32
|
+
optional Claude adapter and an HTTP adapter for backend proxies.
|
|
33
|
+
|
|
34
|
+
**Plugins (minor):** publish manifests fixed to ship built `dist` output,
|
|
35
|
+
normalized peer dependencies, theme plugin now applies a complete dark token
|
|
36
|
+
set to the calendar root.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 89c638a: FullCalendar-parity features for migrating scheduling apps:
|
|
41
|
+
|
|
42
|
+
- Recurrence is expanded once in the calendar context and works in every view
|
|
43
|
+
(month, week, day, list, agenda). Accepts RRULE strings (incl. DTSTART /
|
|
44
|
+
EXDATE / RDATE lines) or FullCalendar-style objects, the `rrule` alias, and
|
|
45
|
+
`exdate` exclusions. Wall-clock times are kept across DST. Each occurrence
|
|
46
|
+
carries `originalEventId` and `occurrenceStart`. `expandRecurrences` is
|
|
47
|
+
exported.
|
|
48
|
+
- New config: `weekStartsOn` (defaults to the locale's convention),
|
|
49
|
+
`hiddenDays`, `weekends`, and `validRange` (days outside it are disabled,
|
|
50
|
+
prev/next is clamped and disabled).
|
|
51
|
+
- New `eventContent` prop, plus `event-rendering` plugins that now actually
|
|
52
|
+
render, in every view. Only the inner content is replaced; drag and resize
|
|
53
|
+
are kept.
|
|
54
|
+
- `currentDate` and `onDateChange` props now work.
|
|
55
|
+
- Business hours are shaded in the day view. In the week view they now honour
|
|
56
|
+
`slotMin` and the calendar time zone.
|
|
57
|
+
- Views render inside `<Suspense>`, so SSR (`renderToString`) works.
|
|
58
|
+
- Fixes: the header and grids agreed on different first days of the week; the
|
|
59
|
+
agenda dropped events in the middle of the week; the list view used the
|
|
60
|
+
time zone as its locale.
|
|
61
|
+
- Published type declarations were empty (the `vite-plugin-dts` option
|
|
62
|
+
`outputDir` → `outDir`).
|
|
63
|
+
|
|
64
|
+
- Updated dependencies [f5aa769]
|
|
65
|
+
- Updated dependencies [6fc7fc6]
|
|
66
|
+
- Updated dependencies [89c638a]
|
|
67
|
+
- Updated dependencies [c26c3e0]
|
|
68
|
+
- Updated dependencies [3c59b01]
|
|
69
|
+
- Updated dependencies [f9a62af]
|
|
70
|
+
- @react-agendfy/core@2.0.0
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const p=require("@react-agendfy/core"),n=t=>`"${(t??"").toString().trim().replace(/"/g,'""')}"`,l=(t,o,e)=>{p.downloadBlob(new Blob([t],{type:e}),o)},x=t=>{const o=["id","title","start","end","isAllDay","color","description"],e=t.map(r=>[n(r.id),n(r.title),n(r.start),n(r.end),r.isAllDay?"true":"false",n(r.color),n(r.description)].join(","));return[o.join(","),...e].join(`
|
|
2
|
+
`)},u=t=>JSON.stringify(t,null,2),d=t=>{const o=["BEGIN:VCALENDAR","VERSION:2.0","PRODID:-//react-agendfy//EN"];return t.forEach(e=>{const r=new Date(e.start).toISOString().replace(/[-:]/g,"").split(".")[0],s=new Date(e.end).toISOString().replace(/[-:]/g,"").split(".")[0];o.push("BEGIN:VEVENT",`UID:${e.id}`,`DTSTAMP:${new Date().toISOString().replace(/[-:]/g,"").split(".")[0]}Z`,`DTSTART:${r}Z`,`DTEND:${s}Z`,`SUMMARY:${e.title}`,e.description?`DESCRIPTION:${e.description}`:"","END:VEVENT")}),o.push("END:VCALENDAR"),o.join(`
|
|
3
|
+
`)},a=async(t,o,e="csv")=>{try{if(!t||!Array.isArray(t))throw new Error("Invalid events array.");const r=new Date().toISOString().split("T")[0];let s="";const c=`calendar-export-${r}.${e}`;let i="text/plain;charset=utf-8;";switch(e){case"csv":s=x(t),i="text/csv;charset=utf-8;";break;case"ics":s=d(t),i="text/calendar;charset=utf-8;";break;case"json":s=u(t),i="application/json;charset=utf-8;";break;default:throw new Error(`Unsupported export format: ${e}`)}return(o==null?void 0:o.autoDownload)!==!1&&typeof window<"u"&&l(s,c,i),s}catch(r){throw console.error("Error exporting events:",r),r}},E={key:"csv-export-plugin",type:"export",formatName:"csv",label:"Export to CSV",fileExtension:"csv",mimeType:"text/csv;charset=utf-8;",exportFunction:(t,o)=>a(t,o,"csv")},y={key:"json-export-plugin",type:"export",formatName:"json",label:"Export to JSON",fileExtension:"json",mimeType:"application/json;charset=utf-8;",exportFunction:(t,o)=>a(t,o,"json")},f={key:"ics-export-plugin",type:"export",formatName:"ics",label:"Export to ICS",fileExtension:"ics",mimeType:"text/calendar;charset=utf-8;",exportFunction:(t,o)=>a(t,o,"ics")},D=[E,y,f];module.exports=D;
|
|
4
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/reportsExportPlugin.ts"],"sourcesContent":["import type { EventProps, Config } from '@react-agendfy/core';\nimport { downloadBlob } from '@react-agendfy/core';\n\nconst sanitize = (value: any): string => {\n const s = (value ?? \"\").toString().trim();\n return `\"${s.replace(/\"/g, '\"\"')}\"`;\n};\n\nconst downloadFile = (content: string, fileName: string, mimeType: string) => {\n downloadBlob(new Blob([content], { type: mimeType }), fileName);\n};\n\n\nconst exportToCsv = (events: EventProps[]): string => {\n const headers = [\"id\", \"title\", \"start\", \"end\", \"isAllDay\", \"color\", \"description\"];\n const rows = events.map(event =>\n [\n sanitize(event.id),\n sanitize(event.title),\n sanitize(event.start),\n sanitize(event.end),\n event.isAllDay ? \"true\" : \"false\",\n sanitize(event.color),\n sanitize(event.description),\n ].join(\",\")\n );\n return [headers.join(\",\"), ...rows].join(\"\\n\");\n};\n\nconst exportToJson = (events: EventProps[]): string =>\n JSON.stringify(events, null, 2);\n\nconst exportToIcs = (events: EventProps[]): string => {\n const icsLines = [\n \"BEGIN:VCALENDAR\",\n \"VERSION:2.0\",\n \"PRODID:-//react-agendfy//EN\",\n ];\n events.forEach((event) => {\n const start = new Date(event.start).toISOString().replace(/[-:]/g, \"\").split(\".\")[0];\n const end = new Date(event.end).toISOString().replace(/[-:]/g, \"\").split(\".\")[0];\n icsLines.push(\n \"BEGIN:VEVENT\", \n `UID:${event.id}`,\n `DTSTAMP:${new Date().toISOString().replace(/[-:]/g, \"\").split(\".\")[0]}Z`,\n `DTSTART:${start}Z`,\n `DTEND:${end}Z`,\n `SUMMARY:${event.title}`,\n event.description ? `DESCRIPTION:${event.description}` : \"\",\n \"END:VEVENT\"\n );\n });\n icsLines.push(\"END:VCALENDAR\");\n return icsLines.join(\"\\n\");\n};\n\nconst exportCalendarEvents = async (\n events: EventProps[],\n config: Config,\n format: \"csv\" | \"ics\" | \"json\" = \"csv\"\n): Promise<string> => {\n try {\n if (!events || !Array.isArray(events)) throw new Error(\"Invalid events array.\");\n\n const date = new Date().toISOString().split(\"T\")[0];\n let fileContent = \"\";\n const fileName = `calendar-export-${date}.${format}`;\n let mimeType = \"text/plain;charset=utf-8;\";\n\n switch (format) {\n case \"csv\":\n fileContent = exportToCsv(events);\n mimeType = \"text/csv;charset=utf-8;\";\n break;\n case \"ics\":\n fileContent = exportToIcs(events);\n mimeType = \"text/calendar;charset=utf-8;\";\n break;\n case \"json\":\n fileContent = exportToJson(events);\n mimeType = \"application/json;charset=utf-8;\";\n break;\n default:\n throw new Error(`Unsupported export format: ${format}`);\n }\n\n if (config?.autoDownload !== false && typeof window !== \"undefined\") {\n downloadFile(fileContent, fileName, mimeType);\n }\n\n return fileContent;\n } catch (err) {\n console.error(\"Error exporting events:\", err);\n throw err;\n }\n};\n\nconst csvExportPlugin = {\n key: \"csv-export-plugin\",\n type: \"export\" as const,\n formatName: \"csv\",\n label: \"Export to CSV\",\n fileExtension: \"csv\",\n mimeType: \"text/csv;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"csv\"),\n};\n\nconst jsonExportPlugin = {\n key: \"json-export-plugin\",\n type: \"export\" as const,\n formatName: \"json\",\n label: \"Export to JSON\",\n fileExtension: \"json\",\n mimeType: \"application/json;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"json\"),\n};\n\nconst icsExportPlugin = {\n key: \"ics-export-plugin\",\n type: \"export\" as const,\n formatName: \"ics\",\n label: \"Export to ICS\",\n fileExtension: \"ics\",\n mimeType: \"text/calendar;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"ics\"),\n};\n\nconst reportsExportPlugin = [csvExportPlugin, jsonExportPlugin, icsExportPlugin];\n\nexport default reportsExportPlugin;\n"],"names":["sanitize","value","downloadFile","content","fileName","mimeType","downloadBlob","exportToCsv","events","headers","rows","event","exportToJson","exportToIcs","icsLines","start","end","exportCalendarEvents","config","format","date","fileContent","err","csvExportPlugin","jsonExportPlugin","icsExportPlugin","reportsExportPlugin"],"mappings":"oDAGMA,EAAYC,GAET,KADIA,GAAS,IAAI,SAAA,EAAW,KAAA,EACtB,QAAQ,KAAM,IAAI,CAAC,IAG5BC,EAAe,CAACC,EAAiBC,EAAkBC,IAAqB,CAC5EC,eAAa,IAAI,KAAK,CAACH,CAAO,EAAG,CAAE,KAAME,EAAU,EAAGD,CAAQ,CAChE,EAGMG,EAAeC,GAAiC,CACpD,MAAMC,EAAU,CAAC,KAAM,QAAS,QAAS,MAAO,WAAY,QAAS,aAAa,EAC5EC,EAAOF,EAAO,IAAIG,GACtB,CACEX,EAASW,EAAM,EAAE,EACjBX,EAASW,EAAM,KAAK,EACpBX,EAASW,EAAM,KAAK,EACpBX,EAASW,EAAM,GAAG,EAClBA,EAAM,SAAW,OAAS,QAC1BX,EAASW,EAAM,KAAK,EACpBX,EAASW,EAAM,WAAW,CAAA,EAC1B,KAAK,GAAG,CAAA,EAEZ,MAAO,CAACF,EAAQ,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,EAAW,kCACX,MACF,QACE,MAAM,IAAI,MAAM,8BAA8Bc,CAAM,EAAE,CAAA,CAG1D,OAAID,GAAA,YAAAA,EAAQ,gBAAiB,IAAS,OAAO,OAAW,KACtDhB,EAAamB,EAAajB,EAAUC,CAAQ,EAGvCgB,CACT,OAASC,EAAK,CACZ,cAAQ,MAAM,0BAA2BA,CAAG,EACtCA,CACR,CACF,EAEMC,EAAkB,CACtB,IAAK,oBACL,KAAM,SACN,WAAY,MACZ,MAAO,gBACP,cAAe,MACf,SAAU,0BACV,eAAgB,CAACf,EAAsBU,IACrCD,EAAqBT,EAAQU,EAAQ,KAAK,CAC9C,EAEMM,EAAmB,CACvB,IAAK,qBACL,KAAM,SACN,WAAY,OACZ,MAAO,iBACP,cAAe,OACf,SAAU,kCACV,eAAgB,CAAChB,EAAsBU,IACrCD,EAAqBT,EAAQU,EAAQ,MAAM,CAC/C,EAEMO,EAAkB,CACtB,IAAK,oBACL,KAAM,SACN,WAAY,MACZ,MAAO,gBACP,cAAe,MACf,SAAU,+BACV,eAAgB,CAACjB,EAAsBU,IACrCD,EAAqBT,EAAQU,EAAQ,KAAK,CAC9C,EAEMQ,EAAsB,CAACH,EAAiBC,EAAkBC,CAAe"}
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { downloadBlob as p } from "@react-agendfy/core";
|
|
2
|
+
const n = (t) => `"${(t ?? "").toString().trim().replace(/"/g, '""')}"`, l = (t, o, r) => {
|
|
3
|
+
p(new Blob([t], { type: r }), o);
|
|
4
|
+
}, x = (t) => {
|
|
5
|
+
const o = ["id", "title", "start", "end", "isAllDay", "color", "description"], r = t.map(
|
|
6
|
+
(e) => [
|
|
7
|
+
n(e.id),
|
|
8
|
+
n(e.title),
|
|
9
|
+
n(e.start),
|
|
10
|
+
n(e.end),
|
|
11
|
+
e.isAllDay ? "true" : "false",
|
|
12
|
+
n(e.color),
|
|
13
|
+
n(e.description)
|
|
14
|
+
].join(",")
|
|
15
|
+
);
|
|
16
|
+
return [o.join(","), ...r].join(`
|
|
17
|
+
`);
|
|
18
|
+
}, d = (t) => JSON.stringify(t, null, 2), u = (t) => {
|
|
19
|
+
const o = [
|
|
20
|
+
"BEGIN:VCALENDAR",
|
|
21
|
+
"VERSION:2.0",
|
|
22
|
+
"PRODID:-//react-agendfy//EN"
|
|
23
|
+
];
|
|
24
|
+
return t.forEach((r) => {
|
|
25
|
+
const e = new Date(r.start).toISOString().replace(/[-:]/g, "").split(".")[0], s = new Date(r.end).toISOString().replace(/[-:]/g, "").split(".")[0];
|
|
26
|
+
o.push(
|
|
27
|
+
"BEGIN:VEVENT",
|
|
28
|
+
`UID:${r.id}`,
|
|
29
|
+
`DTSTAMP:${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").split(".")[0]}Z`,
|
|
30
|
+
`DTSTART:${e}Z`,
|
|
31
|
+
`DTEND:${s}Z`,
|
|
32
|
+
`SUMMARY:${r.title}`,
|
|
33
|
+
r.description ? `DESCRIPTION:${r.description}` : "",
|
|
34
|
+
"END:VEVENT"
|
|
35
|
+
);
|
|
36
|
+
}), o.push("END:VCALENDAR"), o.join(`
|
|
37
|
+
`);
|
|
38
|
+
}, a = async (t, o, r = "csv") => {
|
|
39
|
+
try {
|
|
40
|
+
if (!t || !Array.isArray(t)) throw new Error("Invalid events array.");
|
|
41
|
+
const e = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
42
|
+
let s = "";
|
|
43
|
+
const c = `calendar-export-${e}.${r}`;
|
|
44
|
+
let i = "text/plain;charset=utf-8;";
|
|
45
|
+
switch (r) {
|
|
46
|
+
case "csv":
|
|
47
|
+
s = x(t), i = "text/csv;charset=utf-8;";
|
|
48
|
+
break;
|
|
49
|
+
case "ics":
|
|
50
|
+
s = u(t), i = "text/calendar;charset=utf-8;";
|
|
51
|
+
break;
|
|
52
|
+
case "json":
|
|
53
|
+
s = d(t), i = "application/json;charset=utf-8;";
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
throw new Error(`Unsupported export format: ${r}`);
|
|
57
|
+
}
|
|
58
|
+
return (o == null ? void 0 : o.autoDownload) !== !1 && typeof window < "u" && l(s, c, i), s;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
throw console.error("Error exporting events:", e), e;
|
|
61
|
+
}
|
|
62
|
+
}, E = {
|
|
63
|
+
key: "csv-export-plugin",
|
|
64
|
+
type: "export",
|
|
65
|
+
formatName: "csv",
|
|
66
|
+
label: "Export to CSV",
|
|
67
|
+
fileExtension: "csv",
|
|
68
|
+
mimeType: "text/csv;charset=utf-8;",
|
|
69
|
+
exportFunction: (t, o) => a(t, o, "csv")
|
|
70
|
+
}, f = {
|
|
71
|
+
key: "json-export-plugin",
|
|
72
|
+
type: "export",
|
|
73
|
+
formatName: "json",
|
|
74
|
+
label: "Export to JSON",
|
|
75
|
+
fileExtension: "json",
|
|
76
|
+
mimeType: "application/json;charset=utf-8;",
|
|
77
|
+
exportFunction: (t, o) => a(t, o, "json")
|
|
78
|
+
}, y = {
|
|
79
|
+
key: "ics-export-plugin",
|
|
80
|
+
type: "export",
|
|
81
|
+
formatName: "ics",
|
|
82
|
+
label: "Export to ICS",
|
|
83
|
+
fileExtension: "ics",
|
|
84
|
+
mimeType: "text/calendar;charset=utf-8;",
|
|
85
|
+
exportFunction: (t, o) => a(t, o, "ics")
|
|
86
|
+
}, m = [E, f, y];
|
|
87
|
+
export {
|
|
88
|
+
m as default
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/reportsExportPlugin.ts"],"sourcesContent":["import type { EventProps, Config } from '@react-agendfy/core';\nimport { downloadBlob } from '@react-agendfy/core';\n\nconst sanitize = (value: any): string => {\n const s = (value ?? \"\").toString().trim();\n return `\"${s.replace(/\"/g, '\"\"')}\"`;\n};\n\nconst downloadFile = (content: string, fileName: string, mimeType: string) => {\n downloadBlob(new Blob([content], { type: mimeType }), fileName);\n};\n\n\nconst exportToCsv = (events: EventProps[]): string => {\n const headers = [\"id\", \"title\", \"start\", \"end\", \"isAllDay\", \"color\", \"description\"];\n const rows = events.map(event =>\n [\n sanitize(event.id),\n sanitize(event.title),\n sanitize(event.start),\n sanitize(event.end),\n event.isAllDay ? \"true\" : \"false\",\n sanitize(event.color),\n sanitize(event.description),\n ].join(\",\")\n );\n return [headers.join(\",\"), ...rows].join(\"\\n\");\n};\n\nconst exportToJson = (events: EventProps[]): string =>\n JSON.stringify(events, null, 2);\n\nconst exportToIcs = (events: EventProps[]): string => {\n const icsLines = [\n \"BEGIN:VCALENDAR\",\n \"VERSION:2.0\",\n \"PRODID:-//react-agendfy//EN\",\n ];\n events.forEach((event) => {\n const start = new Date(event.start).toISOString().replace(/[-:]/g, \"\").split(\".\")[0];\n const end = new Date(event.end).toISOString().replace(/[-:]/g, \"\").split(\".\")[0];\n icsLines.push(\n \"BEGIN:VEVENT\", \n `UID:${event.id}`,\n `DTSTAMP:${new Date().toISOString().replace(/[-:]/g, \"\").split(\".\")[0]}Z`,\n `DTSTART:${start}Z`,\n `DTEND:${end}Z`,\n `SUMMARY:${event.title}`,\n event.description ? `DESCRIPTION:${event.description}` : \"\",\n \"END:VEVENT\"\n );\n });\n icsLines.push(\"END:VCALENDAR\");\n return icsLines.join(\"\\n\");\n};\n\nconst exportCalendarEvents = async (\n events: EventProps[],\n config: Config,\n format: \"csv\" | \"ics\" | \"json\" = \"csv\"\n): Promise<string> => {\n try {\n if (!events || !Array.isArray(events)) throw new Error(\"Invalid events array.\");\n\n const date = new Date().toISOString().split(\"T\")[0];\n let fileContent = \"\";\n const fileName = `calendar-export-${date}.${format}`;\n let mimeType = \"text/plain;charset=utf-8;\";\n\n switch (format) {\n case \"csv\":\n fileContent = exportToCsv(events);\n mimeType = \"text/csv;charset=utf-8;\";\n break;\n case \"ics\":\n fileContent = exportToIcs(events);\n mimeType = \"text/calendar;charset=utf-8;\";\n break;\n case \"json\":\n fileContent = exportToJson(events);\n mimeType = \"application/json;charset=utf-8;\";\n break;\n default:\n throw new Error(`Unsupported export format: ${format}`);\n }\n\n if (config?.autoDownload !== false && typeof window !== \"undefined\") {\n downloadFile(fileContent, fileName, mimeType);\n }\n\n return fileContent;\n } catch (err) {\n console.error(\"Error exporting events:\", err);\n throw err;\n }\n};\n\nconst csvExportPlugin = {\n key: \"csv-export-plugin\",\n type: \"export\" as const,\n formatName: \"csv\",\n label: \"Export to CSV\",\n fileExtension: \"csv\",\n mimeType: \"text/csv;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"csv\"),\n};\n\nconst jsonExportPlugin = {\n key: \"json-export-plugin\",\n type: \"export\" as const,\n formatName: \"json\",\n label: \"Export to JSON\",\n fileExtension: \"json\",\n mimeType: \"application/json;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"json\"),\n};\n\nconst icsExportPlugin = {\n key: \"ics-export-plugin\",\n type: \"export\" as const,\n formatName: \"ics\",\n label: \"Export to ICS\",\n fileExtension: \"ics\",\n mimeType: \"text/calendar;charset=utf-8;\",\n exportFunction: (events: EventProps[], config: Config) =>\n exportCalendarEvents(events, config, \"ics\"),\n};\n\nconst reportsExportPlugin = [csvExportPlugin, jsonExportPlugin, icsExportPlugin];\n\nexport default reportsExportPlugin;\n"],"names":["sanitize","value","downloadFile","content","fileName","mimeType","downloadBlob","exportToCsv","events","headers","rows","event","exportToJson","exportToIcs","icsLines","start","end","exportCalendarEvents","config","format","date","fileContent","err","csvExportPlugin","jsonExportPlugin","icsExportPlugin","reportsExportPlugin"],"mappings":";AAGA,MAAMA,IAAW,CAACC,MAET,KADIA,KAAS,IAAI,SAAA,EAAW,KAAA,EACtB,QAAQ,MAAM,IAAI,CAAC,KAG5BC,IAAe,CAACC,GAAiBC,GAAkBC,MAAqB;AAC5E,EAAAC,EAAa,IAAI,KAAK,CAACH,CAAO,GA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CD,EAAqBT,GAAQU,GAAQ,MAAM;AAC/C,GAEMO,IAAkB;AAAA,EACtB,KAAK;AAAA,EACL,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,eAAe;AAAA,EACf,UAAU;AAAA,EACV,gBAAgB,CAACjB,GAAsBU,MACrCD,EAAqBT,GAAQU,GAAQ,KAAK;AAC9C,GAEMQ,IAAsB,CAACH,GAAiBC,GAAkBC,CAAe;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Config } from '@react-agendfy/core';
|
|
2
|
+
import { EventProps } from '@react-agendfy/core';
|
|
3
|
+
|
|
4
|
+
declare const reportsExportPlugin: {
|
|
5
|
+
key: string;
|
|
6
|
+
type: "export";
|
|
7
|
+
formatName: string;
|
|
8
|
+
label: string;
|
|
9
|
+
fileExtension: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
exportFunction: (events: EventProps[], config: Config) => Promise<string>;
|
|
12
|
+
}[];
|
|
13
|
+
export default reportsExportPlugin;
|
|
14
|
+
|
|
15
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-agendfy/plugin-export-reports",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"module": "dist/index.es.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"import": "./dist/index.es.js",
|
|
16
|
+
"require": "./dist/index.cjs.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "vite build --config vite.config.ts",
|
|
24
|
+
"dev": "vite",
|
|
25
|
+
"test": "jest"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@react-agendfy/core": "^2.0.0",
|
|
29
|
+
"react": "^18 || ^19",
|
|
30
|
+
"react-dom": "^18 || ^19"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^5.7.3",
|
|
34
|
+
"vite": "^6.1.0",
|
|
35
|
+
"vite-plugin-dts": "^4.5.0"
|
|
36
|
+
}
|
|
6
37
|
}
|
package/README.md
DELETED