Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,22 +0,0 @@
MIT License
Copyright (c) 2022 Adam Shaw
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,72 +0,0 @@
# FullCalendar React Component
The official [React](https://reactjs.org/) Component for [FullCalendar](https://fullcalendar.io)
## Installation
Install the React connector, the core package, and any plugins (like [daygrid](https://fullcalendar.io/docs/month-view)):
```sh
npm install @fullcalendar/react @fullcalendar/core @fullcalendar/daygrid
```
## Usage
Render a `FullCalendar` component, supplying [options](https://fullcalendar.io/docs#toc) as props:
```jsx
import FullCalendar from '@fullcalendar/react'
import dayGridPlugin from '@fullcalendar/daygrid'
const events = [
{ title: 'Meeting', start: new Date() }
]
export function DemoApp() {
return (
<div>
<h1>Demo App</h1>
<FullCalendar
plugins={[dayGridPlugin]}
initialView='dayGridMonth'
weekends={false}
events={events}
eventContent={renderEventContent}
/>
</div>
)
}
// a custom render function
function renderEventContent(eventInfo) {
return (
<>
<b>{eventInfo.timeText}</b>
<i>{eventInfo.event.title}</i>
</>
)
}
```
## Links
- [Documentation](https://fullcalendar.io/docs/react)
- [Example Project](https://github.com/fullcalendar/fullcalendar-examples/tree/main/react)
## Development
You must install this repo with [PNPM](https://pnpm.io/):
```
pnpm install
```
Available scripts (via `pnpm run <script>`):
- `build` - build production-ready dist files
- `dev` - build & watch development dist files
- `test` - test headlessly
- `test:dev` - test interactively
- `lint`
- `clean`

View File

@@ -1,123 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
var reactDom = require('react-dom');
var index_cjs = require('@fullcalendar/core/index.cjs');
var internal_cjs = require('@fullcalendar/core/internal.cjs');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
const reactMajorVersion = parseInt(String(React__default["default"].version).split('.')[0]);
const syncRenderingByDefault = reactMajorVersion < 18;
class FullCalendar extends React.Component {
constructor() {
super(...arguments);
this.elRef = React.createRef();
this.isUpdating = false;
this.isUnmounting = false;
this.state = {
customRenderingMap: new Map()
};
this.requestResize = () => {
if (!this.isUnmounting) {
this.cancelResize();
this.resizeId = requestAnimationFrame(() => {
this.doResize();
});
}
};
}
render() {
const customRenderingNodes = [];
for (const customRendering of this.state.customRenderingMap.values()) {
customRenderingNodes.push(React__default["default"].createElement(CustomRenderingComponent, { key: customRendering.id, customRendering: customRendering }));
}
return (React__default["default"].createElement("div", { ref: this.elRef }, customRenderingNodes));
}
componentDidMount() {
// reset b/c react strict-mode calls componentWillUnmount/componentDidMount
this.isUnmounting = false;
const customRenderingStore = new internal_cjs.CustomRenderingStore();
this.handleCustomRendering = customRenderingStore.handle.bind(customRenderingStore);
this.calendar = new index_cjs.Calendar(this.elRef.current, Object.assign(Object.assign({}, this.props), { handleCustomRendering: this.handleCustomRendering }));
this.calendar.render();
// attaching with .on() will cause this to fire AFTER internal preact rendering did flushSync
this.calendar.on('_beforeprint', () => {
reactDom.flushSync(() => {
// our `customRenderingMap` state will be flushed at this point
});
});
let lastRequestTimestamp;
customRenderingStore.subscribe((customRenderingMap) => {
const requestTimestamp = Date.now();
const isMounting = !lastRequestTimestamp;
const runFunc = (
// don't call flushSync if React version already does sync rendering by default
// guards against fatal errors:
// https://github.com/fullcalendar/fullcalendar/issues/7448
syncRenderingByDefault ||
//
isMounting ||
this.isUpdating ||
this.isUnmounting ||
(requestTimestamp - lastRequestTimestamp) < 100 // rerendering frequently
) ? runNow // either sync rendering (first-time or React 16/17) or async (React 18)
: reactDom.flushSync; // guaranteed sync rendering
runFunc(() => {
this.setState({ customRenderingMap }, () => {
lastRequestTimestamp = requestTimestamp;
if (isMounting) {
this.doResize();
}
else {
this.requestResize();
}
});
});
});
}
componentDidUpdate() {
this.isUpdating = true;
this.calendar.resetOptions(Object.assign(Object.assign({}, this.props), { handleCustomRendering: this.handleCustomRendering }));
this.isUpdating = false;
}
componentWillUnmount() {
this.isUnmounting = true;
this.cancelResize();
this.calendar.destroy();
}
doResize() {
this.calendar.updateSize();
}
cancelResize() {
if (this.resizeId !== undefined) {
cancelAnimationFrame(this.resizeId);
this.resizeId = undefined;
}
}
getApi() {
return this.calendar;
}
}
FullCalendar.act = runNow; // DEPRECATED. Not leveraged anymore
class CustomRenderingComponent extends React.PureComponent {
render() {
const { customRendering } = this.props;
const { generatorMeta } = customRendering;
const vnode = typeof generatorMeta === 'function' ?
generatorMeta(customRendering.renderProps) :
generatorMeta;
return reactDom.createPortal(vnode, customRendering.containerEl);
}
}
// Util
// -------------------------------------------------------------------------------------------------
function runNow(f) {
f();
}
exports["default"] = FullCalendar;

View File

@@ -1,26 +0,0 @@
import React, { Component } from 'react';
import { CalendarOptions, CalendarApi } from '@fullcalendar/core';
import { CustomRendering } from '@fullcalendar/core/internal';
interface CalendarState {
customRenderingMap: Map<string, CustomRendering<any>>;
}
export default class FullCalendar extends Component<CalendarOptions, CalendarState> {
static act: typeof runNow;
private elRef;
private calendar;
private handleCustomRendering;
private resizeId;
private isUpdating;
private isUnmounting;
state: CalendarState;
render(): React.JSX.Element;
componentDidMount(): void;
componentDidUpdate(): void;
componentWillUnmount(): void;
requestResize: () => void;
doResize(): void;
cancelResize(): void;
getApi(): CalendarApi;
}
declare function runNow(f: () => void): void;
export {};

View File

@@ -1,113 +0,0 @@
import React, { Component, createRef, PureComponent } from 'react';
import { createPortal, flushSync } from 'react-dom';
import { Calendar, } from '@fullcalendar/core';
import { CustomRenderingStore, } from '@fullcalendar/core/internal';
const reactMajorVersion = parseInt(String(React.version).split('.')[0]);
const syncRenderingByDefault = reactMajorVersion < 18;
export default class FullCalendar extends Component {
constructor() {
super(...arguments);
this.elRef = createRef();
this.isUpdating = false;
this.isUnmounting = false;
this.state = {
customRenderingMap: new Map()
};
this.requestResize = () => {
if (!this.isUnmounting) {
this.cancelResize();
this.resizeId = requestAnimationFrame(() => {
this.doResize();
});
}
};
}
render() {
const customRenderingNodes = [];
for (const customRendering of this.state.customRenderingMap.values()) {
customRenderingNodes.push(React.createElement(CustomRenderingComponent, { key: customRendering.id, customRendering: customRendering }));
}
return (React.createElement("div", { ref: this.elRef }, customRenderingNodes));
}
componentDidMount() {
// reset b/c react strict-mode calls componentWillUnmount/componentDidMount
this.isUnmounting = false;
const customRenderingStore = new CustomRenderingStore();
this.handleCustomRendering = customRenderingStore.handle.bind(customRenderingStore);
this.calendar = new Calendar(this.elRef.current, Object.assign(Object.assign({}, this.props), { handleCustomRendering: this.handleCustomRendering }));
this.calendar.render();
// attaching with .on() will cause this to fire AFTER internal preact rendering did flushSync
this.calendar.on('_beforeprint', () => {
flushSync(() => {
// our `customRenderingMap` state will be flushed at this point
});
});
let lastRequestTimestamp;
customRenderingStore.subscribe((customRenderingMap) => {
const requestTimestamp = Date.now();
const isMounting = !lastRequestTimestamp;
const runFunc = (
// don't call flushSync if React version already does sync rendering by default
// guards against fatal errors:
// https://github.com/fullcalendar/fullcalendar/issues/7448
syncRenderingByDefault ||
//
isMounting ||
this.isUpdating ||
this.isUnmounting ||
(requestTimestamp - lastRequestTimestamp) < 100 // rerendering frequently
) ? runNow // either sync rendering (first-time or React 16/17) or async (React 18)
: flushSync; // guaranteed sync rendering
runFunc(() => {
this.setState({ customRenderingMap }, () => {
lastRequestTimestamp = requestTimestamp;
if (isMounting) {
this.doResize();
}
else {
this.requestResize();
}
});
});
});
}
componentDidUpdate() {
this.isUpdating = true;
this.calendar.resetOptions(Object.assign(Object.assign({}, this.props), { handleCustomRendering: this.handleCustomRendering }));
this.isUpdating = false;
}
componentWillUnmount() {
this.isUnmounting = true;
this.cancelResize();
this.calendar.destroy();
}
doResize() {
this.calendar.updateSize();
}
cancelResize() {
if (this.resizeId !== undefined) {
cancelAnimationFrame(this.resizeId);
this.resizeId = undefined;
}
}
getApi() {
return this.calendar;
}
}
FullCalendar.act = runNow; // DEPRECATED. Not leveraged anymore
class CustomRenderingComponent extends PureComponent {
render() {
const { customRendering } = this.props;
const { generatorMeta } = customRendering;
const vnode = typeof generatorMeta === 'function' ?
generatorMeta(customRendering.renderProps) :
generatorMeta;
return createPortal(vnode, customRendering.containerEl);
}
}
// Util
// -------------------------------------------------------------------------------------------------
function runNow(f) {
f();
}
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAGL,QAAQ,GACT,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAEL,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AAEpC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,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,IAAI,CAAC,QAAQ,CAAC,YAAY,iCACrB,IAAI,CAAC,KAAK,KACb,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,IACjD,CAAA;QACF,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;IACzB,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;IAWD,QAAQ;QACN,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IAC5B,CAAC;IAED,YAAY;QACV,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SAC1B;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;;AAxHM,gBAAG,GAAG,MAAM,CAAA,CAAC,oCAAoC;AAkI1D,MAAM,wBAAyB,SAAQ,aAA4C;IACjF,MAAM;QACJ,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QACtC,MAAM,EAAE,aAAa,EAAE,GAAG,eAAe,CAAA;QACzC,MAAM,KAAK,GAAG,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC;YACjD,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;YAC5C,aAAa,CAAA;QAEf,OAAO,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;IACzD,CAAC;CACF;AAED,OAAO;AACP,oGAAoG;AAEpG,SAAS,MAAM,CAAC,CAAa;IAC3B,CAAC,EAAE,CAAA;AACL,CAAC"}

View File

@@ -1,85 +0,0 @@
{
"name": "@fullcalendar/react",
"version": "6.1.15",
"title": "FullCalendar React Component",
"description": "The official React Component for FullCalendar",
"keywords": [
"calendar",
"event",
"full-sized",
"fullcalendar",
"react"
],
"homepage": "https://fullcalendar.io/docs/react",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/fullcalendar/fullcalendar-react.git"
},
"peerDependencies": {
"@fullcalendar/core": "~6.1.15",
"react": "^16.7.0 || ^17 || ^18 || ^19",
"react-dom": "^16.7.0 || ^17 || ^18 || ^19"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.4",
"@fullcalendar/adaptive": "~6.1.15",
"@fullcalendar/core": "~6.1.15",
"@fullcalendar/daygrid": "~6.1.15",
"@fullcalendar/list": "~6.1.15",
"@fullcalendar/resource": "~6.1.15",
"@fullcalendar/resource-timeline": "~6.1.15",
"@fullcalendar/timegrid": "~6.1.15",
"@rollup/plugin-babel": "^5.0.0",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^14.0.1",
"@rollup/plugin-replace": "^5.0.1",
"@testing-library/react": "^13.4.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"concurrently": "^5.3.0",
"karma": "^6.3.2",
"karma-chrome-launcher": "^3.1.0",
"karma-jasmine": "^4.0.1",
"karma-sourcemap-loader": "^0.3.8",
"karma-spec-reporter": "^0.0.32",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rollup": "^2.79.0",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-sourcemaps": "^0.6.3",
"typescript": "^4.0.5"
},
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
}
},
"files": [
"dist",
"src"
],
"sideEffects": false,
"scripts": {
"build": "pnpm run tsc && pnpm run rollup",
"dev": "pnpm run tsc && concurrently 'npm:tsc:dev' 'npm:rollup:dev'",
"test": "karma start karma.config.cjs --browsers ChromeHeadless --single-run --no-auto-watch",
"test:dev": "karma start karma.config.cjs",
"clean": "rm -rf dist tests/dist",
"ci": "pnpm run clean && pnpm run build && pnpm run test",
"tsc": "tsc -p .",
"tsc:dev": "tsc -p . --watch --preserveWatchOutput --pretty",
"rollup": "rollup -c",
"rollup:dev": "rollup -c --watch"
}
}

View File

@@ -1,168 +0,0 @@
import React, { Component, createRef, PureComponent } from 'react'
import { createPortal, flushSync } from 'react-dom'
import {
CalendarOptions,
CalendarApi,
Calendar,
} from '@fullcalendar/core'
import {
CustomRendering,
CustomRenderingStore,
} from '@fullcalendar/core/internal'
const reactMajorVersion = parseInt(String(React.version).split('.')[0])
const syncRenderingByDefault = reactMajorVersion < 18
interface CalendarState {
customRenderingMap: Map<string, CustomRendering<any>>
}
export default class FullCalendar extends Component<CalendarOptions, CalendarState> {
static act = runNow // DEPRECATED. Not leveraged anymore
private elRef = createRef<HTMLDivElement>()
private calendar: Calendar
private handleCustomRendering: (customRendering: CustomRendering<any>) => void
private resizeId: number | undefined
private isUpdating = false
private isUnmounting = false
state: CalendarState = {
customRenderingMap: new Map<string, CustomRendering<any>>()
}
render() {
const customRenderingNodes: JSX.Element[] = []
for (const customRendering of this.state.customRenderingMap.values()) {
customRenderingNodes.push(
<CustomRenderingComponent
key={customRendering.id}
customRendering={customRendering}
/>
)
}
return (
<div ref={this.elRef}>
{customRenderingNodes}
</div>
)
}
componentDidMount() {
// reset b/c react strict-mode calls componentWillUnmount/componentDidMount
this.isUnmounting = false
const customRenderingStore = new CustomRenderingStore<unknown>()
this.handleCustomRendering = customRenderingStore.handle.bind(customRenderingStore)
this.calendar = new Calendar(this.elRef.current, {
...this.props,
handleCustomRendering: this.handleCustomRendering,
})
this.calendar.render()
// attaching with .on() will cause this to fire AFTER internal preact rendering did flushSync
this.calendar.on('_beforeprint', () => {
flushSync(() => {
// our `customRenderingMap` state will be flushed at this point
})
})
let lastRequestTimestamp: number | undefined
customRenderingStore.subscribe((customRenderingMap) => {
const requestTimestamp = Date.now()
const isMounting = !lastRequestTimestamp
const runFunc = (
// don't call flushSync if React version already does sync rendering by default
// guards against fatal errors:
// https://github.com/fullcalendar/fullcalendar/issues/7448
syncRenderingByDefault ||
//
isMounting ||
this.isUpdating ||
this.isUnmounting ||
(requestTimestamp - lastRequestTimestamp) < 100 // rerendering frequently
) ? runNow // either sync rendering (first-time or React 16/17) or async (React 18)
: flushSync // guaranteed sync rendering
runFunc(() => {
this.setState({ customRenderingMap }, () => {
lastRequestTimestamp = requestTimestamp
if (isMounting) {
this.doResize()
} else {
this.requestResize()
}
})
})
})
}
componentDidUpdate() {
this.isUpdating = true
this.calendar.resetOptions({
...this.props,
handleCustomRendering: this.handleCustomRendering,
})
this.isUpdating = false
}
componentWillUnmount() {
this.isUnmounting = true
this.cancelResize()
this.calendar.destroy()
}
requestResize = () => {
if (!this.isUnmounting) {
this.cancelResize()
this.resizeId = requestAnimationFrame(() => {
this.doResize()
})
}
}
doResize() {
this.calendar.updateSize()
}
cancelResize() {
if (this.resizeId !== undefined) {
cancelAnimationFrame(this.resizeId)
this.resizeId = undefined
}
}
getApi(): CalendarApi {
return this.calendar
}
}
// Custom Rendering
// -------------------------------------------------------------------------------------------------
interface CustomRenderingComponentProps {
customRendering: CustomRendering<any>
}
class CustomRenderingComponent extends PureComponent<CustomRenderingComponentProps> {
render() {
const { customRendering } = this.props
const { generatorMeta } = customRendering
const vnode = typeof generatorMeta === 'function' ?
generatorMeta(customRendering.renderProps) :
generatorMeta
return createPortal(vnode, customRendering.containerEl)
}
}
// Util
// -------------------------------------------------------------------------------------------------
function runNow(f: () => void): void {
f()
}