@reservi/react 1.1.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/LICENSE +21 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Reservi
|
|
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/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),n=require("react"),g=require("@reservi/preact"),e=require("@reservi/core");function s({onReady:u,className:c,...r}){const i=n.useRef(null),t=n.useRef(null);return n.useEffect(()=>{if(!i.current)return;const l=g.mount(i.current,r);return t.current=l,u==null||u(l.api),()=>{l.destroy(),t.current=null}},[]),n.useEffect(()=>{t.current&&r.events&&t.current.api.refetchEvents(r.events)},[r.events]),f.jsx("div",{ref:i,className:c})}Object.defineProperty(exports,"dayGridPlugin",{enumerable:!0,get:()=>e.dayGridPlugin});Object.defineProperty(exports,"definePlugin",{enumerable:!0,get:()=>e.definePlugin});Object.defineProperty(exports,"defineTheme",{enumerable:!0,get:()=>e.defineTheme});Object.defineProperty(exports,"listPlugin",{enumerable:!0,get:()=>e.listPlugin});Object.defineProperty(exports,"multiMonthPlugin",{enumerable:!0,get:()=>e.multiMonthPlugin});Object.defineProperty(exports,"resourcePlugin",{enumerable:!0,get:()=>e.resourcePlugin});Object.defineProperty(exports,"timeGridPlugin",{enumerable:!0,get:()=>e.timeGridPlugin});Object.defineProperty(exports,"timelinePlugin",{enumerable:!0,get:()=>e.timelinePlugin});exports.ReserviCalendar=s;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/ReserviCalendar.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { mount, type ReserviCalendarHandle, type ReserviCalendarOptions } from \"@reservi/preact\";\nimport type { CalendarApi } from \"@reservi/core\";\n\nexport interface ReserviCalendarProps extends ReserviCalendarOptions {\n /** Se invoca con la API del calendario tras montar. */\n onReady?: (api: CalendarApi) => void;\n /** Clase del contenedor host. */\n className?: string;\n}\n\n/**\n * Componente React. Monta el calendario agnóstico (Preact) en un div y mantiene\n * sincronizados los eventos; el resto se controla vía la API (onReady).\n */\nexport function ReserviCalendar({ onReady, className, ...options }: ReserviCalendarProps) {\n const hostRef = useRef<HTMLDivElement>(null);\n const handleRef = useRef<ReserviCalendarHandle | null>(null);\n\n // Montaje único (la identidad de la instancia se mantiene entre renders).\n useEffect(() => {\n if (!hostRef.current) return;\n const handle = mount(hostRef.current, options);\n handleRef.current = handle;\n onReady?.(handle.api);\n return () => {\n handle.destroy();\n handleRef.current = null;\n };\n }, []);\n\n // Sincroniza eventos cuando cambia la prop.\n useEffect(() => {\n if (handleRef.current && options.events) {\n handleRef.current.api.refetchEvents(options.events);\n }\n }, [options.events]);\n\n return <div ref={hostRef} className={className} />;\n}\n"],"names":["ReserviCalendar","onReady","className","options","hostRef","useRef","handleRef","useEffect","handle","mount","jsx"],"mappings":"gMAeO,SAASA,EAAgB,CAAE,QAAAC,EAAS,UAAAC,EAAW,GAAGC,GAAiC,CACxF,MAAMC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAYD,EAAAA,OAAqC,IAAI,EAG3DE,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAI,CAACH,EAAQ,QAAS,OACtB,MAAMI,EAASC,EAAAA,MAAML,EAAQ,QAASD,CAAO,EAC7C,OAAAG,EAAU,QAAUE,EACpBP,GAAA,MAAAA,EAAUO,EAAO,KACV,IAAM,CACXA,EAAO,QAAA,EACPF,EAAU,QAAU,IACtB,CACF,EAAG,CAAA,CAAE,EAGLC,EAAAA,UAAU,IAAM,CACVD,EAAU,SAAWH,EAAQ,QAC/BG,EAAU,QAAQ,IAAI,cAAcH,EAAQ,MAAM,CAEtD,EAAG,CAACA,EAAQ,MAAM,CAAC,EAEZO,EAAAA,IAAC,MAAA,CAAI,IAAKN,EAAS,UAAAF,CAAA,CAAsB,CAClD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CalendarApi } from '@reservi/core';
|
|
2
|
+
import { CalendarOptions } from '@reservi/core';
|
|
3
|
+
import { dayGridPlugin } from '@reservi/core';
|
|
4
|
+
import { definePlugin } from '@reservi/core';
|
|
5
|
+
import { defineTheme } from '@reservi/core';
|
|
6
|
+
import { EventDef } from '@reservi/core';
|
|
7
|
+
import { EventInput } from '@reservi/core';
|
|
8
|
+
import { JSX } from 'react';
|
|
9
|
+
import { listPlugin } from '@reservi/core';
|
|
10
|
+
import { multiMonthPlugin } from '@reservi/core';
|
|
11
|
+
import { ReserviCalendarOptions } from '@reservi/preact';
|
|
12
|
+
import { ReserviClassNames } from '@reservi/preact';
|
|
13
|
+
import { ReserviSlots } from '@reservi/preact';
|
|
14
|
+
import { ReserviThemeTokens } from '@reservi/core';
|
|
15
|
+
import { ResourceInput } from '@reservi/core';
|
|
16
|
+
import { resourcePlugin } from '@reservi/core';
|
|
17
|
+
import { timeGridPlugin } from '@reservi/core';
|
|
18
|
+
import { timelinePlugin } from '@reservi/core';
|
|
19
|
+
|
|
20
|
+
export { CalendarApi }
|
|
21
|
+
|
|
22
|
+
export { CalendarOptions }
|
|
23
|
+
|
|
24
|
+
export { dayGridPlugin }
|
|
25
|
+
|
|
26
|
+
export { definePlugin }
|
|
27
|
+
|
|
28
|
+
export { defineTheme }
|
|
29
|
+
|
|
30
|
+
export { EventDef }
|
|
31
|
+
|
|
32
|
+
export { EventInput }
|
|
33
|
+
|
|
34
|
+
export { listPlugin }
|
|
35
|
+
|
|
36
|
+
export { multiMonthPlugin }
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Componente React. Monta el calendario agnóstico (Preact) en un div y mantiene
|
|
40
|
+
* sincronizados los eventos; el resto se controla vía la API (onReady).
|
|
41
|
+
*/
|
|
42
|
+
export declare function ReserviCalendar({ onReady, className, ...options }: ReserviCalendarProps): JSX.Element;
|
|
43
|
+
|
|
44
|
+
export { ReserviCalendarOptions }
|
|
45
|
+
|
|
46
|
+
export declare interface ReserviCalendarProps extends ReserviCalendarOptions {
|
|
47
|
+
/** Se invoca con la API del calendario tras montar. */
|
|
48
|
+
onReady?: (api: CalendarApi) => void;
|
|
49
|
+
/** Clase del contenedor host. */
|
|
50
|
+
className?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { ReserviClassNames }
|
|
54
|
+
|
|
55
|
+
export { ReserviSlots }
|
|
56
|
+
|
|
57
|
+
export { ReserviThemeTokens }
|
|
58
|
+
|
|
59
|
+
export { ResourceInput }
|
|
60
|
+
|
|
61
|
+
export { resourcePlugin }
|
|
62
|
+
|
|
63
|
+
export { timeGridPlugin }
|
|
64
|
+
|
|
65
|
+
export { timelinePlugin }
|
|
66
|
+
|
|
67
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as i, useEffect as l } from "react";
|
|
3
|
+
import { mount as m } from "@reservi/preact";
|
|
4
|
+
import { dayGridPlugin as v, definePlugin as p, defineTheme as a, listPlugin as x, multiMonthPlugin as E, resourcePlugin as G, timeGridPlugin as j, timelinePlugin as C } from "@reservi/core";
|
|
5
|
+
function P({ onReady: n, className: f, ...e }) {
|
|
6
|
+
const t = i(null), r = i(null);
|
|
7
|
+
return l(() => {
|
|
8
|
+
if (!t.current) return;
|
|
9
|
+
const u = m(t.current, e);
|
|
10
|
+
return r.current = u, n == null || n(u.api), () => {
|
|
11
|
+
u.destroy(), r.current = null;
|
|
12
|
+
};
|
|
13
|
+
}, []), l(() => {
|
|
14
|
+
r.current && e.events && r.current.api.refetchEvents(e.events);
|
|
15
|
+
}, [e.events]), /* @__PURE__ */ c("div", { ref: t, className: f });
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
P as ReserviCalendar,
|
|
19
|
+
v as dayGridPlugin,
|
|
20
|
+
p as definePlugin,
|
|
21
|
+
a as defineTheme,
|
|
22
|
+
x as listPlugin,
|
|
23
|
+
E as multiMonthPlugin,
|
|
24
|
+
G as resourcePlugin,
|
|
25
|
+
j as timeGridPlugin,
|
|
26
|
+
C as timelinePlugin
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/ReserviCalendar.tsx"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport { mount, type ReserviCalendarHandle, type ReserviCalendarOptions } from \"@reservi/preact\";\nimport type { CalendarApi } from \"@reservi/core\";\n\nexport interface ReserviCalendarProps extends ReserviCalendarOptions {\n /** Se invoca con la API del calendario tras montar. */\n onReady?: (api: CalendarApi) => void;\n /** Clase del contenedor host. */\n className?: string;\n}\n\n/**\n * Componente React. Monta el calendario agnóstico (Preact) en un div y mantiene\n * sincronizados los eventos; el resto se controla vía la API (onReady).\n */\nexport function ReserviCalendar({ onReady, className, ...options }: ReserviCalendarProps) {\n const hostRef = useRef<HTMLDivElement>(null);\n const handleRef = useRef<ReserviCalendarHandle | null>(null);\n\n // Montaje único (la identidad de la instancia se mantiene entre renders).\n useEffect(() => {\n if (!hostRef.current) return;\n const handle = mount(hostRef.current, options);\n handleRef.current = handle;\n onReady?.(handle.api);\n return () => {\n handle.destroy();\n handleRef.current = null;\n };\n }, []);\n\n // Sincroniza eventos cuando cambia la prop.\n useEffect(() => {\n if (handleRef.current && options.events) {\n handleRef.current.api.refetchEvents(options.events);\n }\n }, [options.events]);\n\n return <div ref={hostRef} className={className} />;\n}\n"],"names":["ReserviCalendar","onReady","className","options","hostRef","useRef","handleRef","useEffect","handle","mount","jsx"],"mappings":";;;;AAeO,SAASA,EAAgB,EAAE,SAAAC,GAAS,WAAAC,GAAW,GAAGC,KAAiC;AACxF,QAAMC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAqC,IAAI;AAG3D,SAAAE,EAAU,MAAM;AACd,QAAI,CAACH,EAAQ,QAAS;AACtB,UAAMI,IAASC,EAAML,EAAQ,SAASD,CAAO;AAC7C,WAAAG,EAAU,UAAUE,GACpBP,KAAA,QAAAA,EAAUO,EAAO,MACV,MAAM;AACX,MAAAA,EAAO,QAAA,GACPF,EAAU,UAAU;AAAA,IACtB;AAAA,EACF,GAAG,CAAA,CAAE,GAGLC,EAAU,MAAM;AACd,IAAID,EAAU,WAAWH,EAAQ,UAC/BG,EAAU,QAAQ,IAAI,cAAcH,EAAQ,MAAM;AAAA,EAEtD,GAAG,CAACA,EAAQ,MAAM,CAAC,GAEZ,gBAAAO,EAAC,OAAA,EAAI,KAAKN,GAAS,WAAAF,EAAA,CAAsB;AAClD;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reservi/react",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Wrapper de React para Reservi Calendar.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@reservi/core": "1.1.0",
|
|
23
|
+
"@reservi/preact": "1.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
27
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@testing-library/dom": "^10.4.0",
|
|
31
|
+
"@testing-library/react": "^16.1.0",
|
|
32
|
+
"@types/react": "^19.0.2",
|
|
33
|
+
"@types/react-dom": "^19.0.2",
|
|
34
|
+
"jsdom": "^25.0.1",
|
|
35
|
+
"react": "^19.0.0",
|
|
36
|
+
"react-dom": "^19.0.0",
|
|
37
|
+
"typescript": "^5.7.2",
|
|
38
|
+
"vite": "^6.0.0",
|
|
39
|
+
"vite-plugin-dts": "^4.3.0",
|
|
40
|
+
"vitest": "^2.1.8",
|
|
41
|
+
"@reservi/eslint-config": "1.1.0",
|
|
42
|
+
"@reservi/tsconfig": "1.1.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vite build",
|
|
46
|
+
"dev": "vite build --watch",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"lint": "eslint src",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|