1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-02 17:29:20 +02:00

Show a report for total users chart

This commit is contained in:
Daniel Neto 2025-07-10 15:28:42 -03:00
parent 794938db72
commit 4d064adf1b
5397 changed files with 313100 additions and 365 deletions

59
node_modules/.package-lock.json generated vendored
View file

@ -257,6 +257,12 @@
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
"integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA=="
},
"node_modules/@types/hammerjs": {
"version": "2.0.46",
"resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.46.tgz",
"integrity": "sha512-ynRvcq6wvqexJ9brDMS4BnBLzmr0e14d6ZJTEShTBWKymQiHwlAyGu0ZPEFI2Fh1U53F7tN9ufClWM5KvqkKOw==",
"license": "MIT"
},
"node_modules/@videojs/http-streaming": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/@videojs/http-streaming/-/http-streaming-3.17.0.tgz",
@ -463,6 +469,39 @@
"pnpm": ">=8"
}
},
"node_modules/chartjs-adapter-date-fns": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chartjs-adapter-date-fns/-/chartjs-adapter-date-fns-3.0.0.tgz",
"integrity": "sha512-Rs3iEB3Q5pJ973J93OBTpnP7qoGwvq3nUnoMdtxO+9aoJof7UFcRbWcIDteXuYd1fgAvct/32T9qaLyLuZVwCg==",
"license": "MIT",
"peerDependencies": {
"chart.js": ">=2.8.0",
"date-fns": ">=2.0.0"
}
},
"node_modules/chartjs-adapter-moment": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/chartjs-adapter-moment/-/chartjs-adapter-moment-1.0.1.tgz",
"integrity": "sha512-Uz+nTX/GxocuqXpGylxK19YG4R3OSVf8326D+HwSTsNw1LgzyIGRo+Qujwro1wy6X+soNSnfj5t2vZ+r6EaDmA==",
"license": "MIT",
"peerDependencies": {
"chart.js": ">=3.0.0",
"moment": "^2.10.2"
}
},
"node_modules/chartjs-plugin-zoom": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/chartjs-plugin-zoom/-/chartjs-plugin-zoom-2.2.0.tgz",
"integrity": "sha512-in6kcdiTlP6npIVLMd4zXZ08PDUXC52gZ4FAy5oyjk1zX3gKarXMAof7B9eFiisf9WOC3bh2saHg+J5WtLXZeA==",
"license": "MIT",
"dependencies": {
"@types/hammerjs": "^2.0.45",
"hammerjs": "^2.0.8"
},
"peerDependencies": {
"chart.js": ">=3.2.0"
}
},
"node_modules/codemirror": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz",
@ -493,6 +532,16 @@
"resolved": "https://registry.npmjs.org/croppie/-/croppie-2.6.5.tgz",
"integrity": "sha512-IlChnVUGG5T3w2gRZIaQgBtlvyuYnlUWs2YZIXXR3H9KrlO1PtBT3j+ykxvy9eZIWhk+V5SpBmhCQz5UXKrEKQ=="
},
"node_modules/date-fns": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/debug": {
"version": "4.3.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
@ -686,6 +735,15 @@
"process": "^0.11.10"
}
},
"node_modules/hammerjs": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz",
"integrity": "sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==",
"license": "MIT",
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/hls.js": {
"version": "1.6.6",
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.6.tgz",
@ -1107,6 +1165,7 @@
"version": "2.30.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz",
"integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==",
"license": "MIT",
"engines": {
"node": "*"
}

21
node_modules/@types/hammerjs/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
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

15
node_modules/@types/hammerjs/README.md generated vendored Normal file
View file

@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/hammerjs`
# Summary
This package contains type definitions for hammerjs (http://hammerjs.github.io/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hammerjs.
### Additional Details
* Last updated: Mon, 07 Oct 2024 22:07:58 GMT
* Dependencies: none
# Credits
These definitions were written by [Han Lin Yap](https://github.com/codler).

345
node_modules/@types/hammerjs/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,345 @@
declare var Hammer: HammerStatic;
declare module "hammerjs" {
export = Hammer;
}
interface HammerStatic {
new(element: HTMLElement | SVGElement, options?: HammerOptions): HammerManager;
defaults: HammerDefaults;
VERSION: number;
INPUT_START: 1;
INPUT_MOVE: 2;
INPUT_END: 4;
INPUT_CANCEL: 8;
STATE_POSSIBLE: 1;
STATE_BEGAN: 2;
STATE_CHANGED: 4;
STATE_ENDED: 8;
STATE_RECOGNIZED: 8; // same as STATE_ENDED
STATE_CANCELLED: 16;
STATE_FAILED: 32;
DIRECTION_NONE: 1;
DIRECTION_LEFT: 2;
DIRECTION_RIGHT: 4;
DIRECTION_UP: 8;
DIRECTION_DOWN: 16;
DIRECTION_HORIZONTAL: 6; // DIRECTION_LEFT | DIRECTION_RIGHT
DIRECTION_VERTICAL: 24; // DIRECTION_UP | DIRECTION_DOWN
DIRECTION_ALL: 30; // DIRECTION_HORIZONTAL | DIRECTION_VERTICAL
Manager: HammerManagerConstructor;
Input: HammerInput;
TouchAction: TouchAction;
TouchInput: TouchInput;
MouseInput: MouseInput;
PointerEventInput: PointerEventInput;
TouchMouseInput: TouchMouseInput;
SingleTouchInput: SingleTouchInput;
Recognizer: RecognizerStatic;
AttrRecognizer: AttrRecognizerStatic;
Tap: TapRecognizerStatic;
Pan: PanRecognizerStatic;
Swipe: SwipeRecognizerStatic;
Pinch: PinchRecognizerStatic;
Rotate: RotateRecognizerStatic;
Press: PressRecognizerStatic;
on(target: EventTarget, types: string, handler: Function): void;
off(target: EventTarget, types: string, handler: Function): void;
each(obj: any, iterator: Function, context: any): void;
merge(dest: any, src: any): any;
extend(dest: any, src: any, merge: boolean): any;
inherit(child: Function, base: Function, properties: any): any;
bindFn(fn: Function, context: any): Function;
prefixed(obj: any, property: string): string;
}
type RecognizerTuple =
| [RecognizerStatic]
| [RecognizerStatic, RecognizerOptions]
| [RecognizerStatic, RecognizerOptions, string | string[]]
| [RecognizerStatic, RecognizerOptions, string | string[], (string | Recognizer) | Array<string | Recognizer>];
interface HammerDefaults extends HammerOptions {
domEvents: boolean;
enable: boolean;
preset: RecognizerTuple[];
touchAction: string;
cssProps: CssProps;
inputClass: HammerInput;
inputTarget: EventTarget;
}
interface CssProps {
contentZooming: string;
tapHighlightColor: string;
touchCallout: string;
touchSelect: string;
userDrag: string;
userSelect: string;
}
interface HammerOptions {
cssProps?: CssProps | undefined;
domEvents?: boolean | undefined;
enable?: boolean | ((manager: HammerManager) => boolean) | undefined;
preset?: RecognizerTuple[] | undefined;
touchAction?: string | undefined;
recognizers?: RecognizerTuple[] | undefined;
inputClass?: HammerInput | undefined;
inputTarget?: EventTarget | undefined;
}
interface HammerManagerConstructor {
new(element: EventTarget, options?: HammerOptions): HammerManager;
}
interface HammerListener {
(event: HammerInput): void;
}
interface HammerManager {
add(recogniser: Recognizer): Recognizer;
add(recogniser: Recognizer): HammerManager;
add(recogniser: Recognizer[]): Recognizer;
add(recogniser: Recognizer[]): HammerManager;
destroy(): void;
emit(event: string, data: any): void;
get(recogniser: Recognizer): Recognizer;
get(recogniser: string): Recognizer;
off(events: string, handler?: HammerListener): void;
on(events: string, handler: HammerListener): void;
recognize(inputData: any): void;
remove(recogniser: Recognizer): HammerManager;
remove(recogniser: string): HammerManager;
set(options: HammerOptions): HammerManager;
stop(force: boolean): void;
}
declare class HammerInput {
constructor(manager: HammerManager, callback: Function);
destroy(): void;
handler(): void;
init(): void;
/** Name of the event. Like panstart. */
type: string;
/** Movement of the X axis. */
deltaX: number;
/** Movement of the Y axis. */
deltaY: number;
/** Total time in ms since the first input. */
deltaTime: number;
/** Distance moved. */
distance: number;
/** Angle moved. */
angle: number;
/** Velocity on the X axis, in px/ms. */
velocityX: number;
/** Velocity on the Y axis, in px/ms */
velocityY: number;
/** Highest velocityX/Y value. */
velocity: number;
overallVelocity: number;
overallVelocityX: number;
overallVelocityY: number;
/** Direction moved. Matches the DIRECTION constants. */
direction: number;
/** Direction moved from it's starting point. Matches the DIRECTION constants. */
offsetDirection: number;
/** Scaling that has been done when multi-touch. 1 on a single touch. */
scale: number;
/** Rotation that has been done when multi-touch. 0 on a single touch. */
rotation: number;
/** Center position for multi-touch, or just the single pointer. */
center: HammerPoint;
/** The amount of multi-taps being recognized. */
tapCount?: number;
/** Source event object, type TouchEvent, MouseEvent or PointerEvent. */
srcEvent: TouchEvent | MouseEvent | PointerEvent;
/** Target that received the event. */
target: HTMLElement;
/** Primary pointer type, could be touch, mouse, pen or kinect. */
pointerType: string;
/** Event type, matches the INPUT constants. */
eventType:
| HammerStatic["INPUT_START"]
| HammerStatic["INPUT_MOVE"]
| HammerStatic["INPUT_END"]
| HammerStatic["INPUT_CANCEL"];
/** true when the first input. */
isFirst: boolean;
/** true when the final (last) input. */
isFinal: boolean;
/** Array with all pointers, including the ended pointers (touchend, mouseup). */
pointers: any[];
/** Array with all new/moved/lost pointers. */
changedPointers: any[];
/** Maximum number of pointers detected in the gesture */
maxPointers: number;
/** Timestamp of a gesture */
timeStamp: number;
/** Reference to the srcEvent.preventDefault() method. Only for experts! */
preventDefault: Function;
}
declare class MouseInput extends HammerInput {
constructor(manager: HammerManager, callback: Function);
}
declare class PointerEventInput extends HammerInput {
constructor(manager: HammerManager, callback: Function);
}
declare class SingleTouchInput extends HammerInput {
constructor(manager: HammerManager, callback: Function);
}
declare class TouchInput extends HammerInput {
constructor(manager: HammerManager, callback: Function);
}
declare class TouchMouseInput extends HammerInput {
constructor(manager: HammerManager, callback: Function);
}
interface RecognizerOptions {
direction?: number | undefined;
enable?: boolean | ((recognizer: Recognizer, inputData: HammerInput) => boolean) | undefined;
event?: string | undefined;
interval?: number | undefined;
pointers?: number | undefined;
posThreshold?: number | undefined;
taps?: number | undefined;
threshold?: number | undefined;
time?: number | undefined;
velocity?: number | undefined;
}
interface RecognizerStatic {
new(options?: RecognizerOptions): Recognizer;
}
interface Recognizer {
defaults: any;
canEmit(): boolean;
canRecognizeWith(otherRecognizer: Recognizer): boolean;
dropRecognizeWith(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer;
dropRequireFailure(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer;
emit(input: HammerInput): void;
getTouchAction(): any[];
hasRequireFailures(): boolean;
process(inputData: HammerInput): string;
recognize(inputData: HammerInput): void;
recognizeWith(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer;
requireFailure(otherRecognizer: Recognizer | Recognizer[] | string): Recognizer;
reset(): void;
set(options?: RecognizerOptions): Recognizer;
tryEmit(input: HammerInput): void;
}
interface AttrRecognizerStatic {
attrTest(input: HammerInput): boolean;
process(input: HammerInput): any;
}
interface AttrRecognizer extends Recognizer {
new(options?: RecognizerOptions): AttrRecognizer;
}
interface PanRecognizerStatic {
new(options?: RecognizerOptions): PanRecognizer;
}
interface PanRecognizer extends AttrRecognizer {
}
interface PinchRecognizerStatic {
new(options?: RecognizerOptions): PinchRecognizer;
}
interface PinchRecognizer extends AttrRecognizer {
}
interface PressRecognizerStatic {
new(options?: RecognizerOptions): PressRecognizer;
}
interface PressRecognizer extends AttrRecognizer {
}
interface RotateRecognizerStatic {
new(options?: RecognizerOptions): RotateRecognizer;
}
interface RotateRecognizer extends AttrRecognizer {
}
interface SwipeRecognizerStatic {
new(options?: RecognizerOptions): SwipeRecognizer;
}
interface SwipeRecognizer extends AttrRecognizer {
}
interface TapRecognizerStatic {
new(options?: RecognizerOptions): TapRecognizer;
}
interface TapRecognizer extends AttrRecognizer {
}
declare class TouchAction {
constructor(manager: HammerManager, value: string);
compute(): string;
preventDefaults(input: HammerInput): void;
preventSrc(srcEvent: any): void;
set(value: string): void;
update(): void;
}
interface HammerPoint {
x: number;
y: number;
}

25
node_modules/@types/hammerjs/package.json generated vendored Normal file
View file

@ -0,0 +1,25 @@
{
"name": "@types/hammerjs",
"version": "2.0.46",
"description": "TypeScript definitions for hammerjs",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hammerjs",
"license": "MIT",
"contributors": [
{
"name": "Han Lin Yap",
"githubUsername": "codler",
"url": "https://github.com/codler"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/hammerjs"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "940610a83da8b99e3035028564e9536f6c44025e0387899fdaafa00474821be4",
"typeScriptVersion": "4.8"
}

9
node_modules/chartjs-adapter-date-fns/LICENSE.md generated vendored Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2019 Chart.js Contributors
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.

79
node_modules/chartjs-adapter-date-fns/README.md generated vendored Normal file
View file

@ -0,0 +1,79 @@
# chartjs-adapter-date-fns
[![release](https://img.shields.io/github/release/chartjs/chartjs-adapter-date-fns.svg?style=flat-square)](https://github.com/chartjs/chartjs-adapter-date-fns/releases/latest) [![travis](https://img.shields.io/travis/chartjs/chartjs-adapter-date-fns.svg?style=flat-square&maxAge=60)](https://travis-ci.org/chartjs/chartjs-adapter-date-fns) [![awesome](https://awesome.re/badge-flat2.svg)](https://github.com/chartjs/awesome)
## Overview
This adapter allows the use of date-fns with Chart.js.
Requires [Chart.js](https://github.com/chartjs/Chart.js/releases) **2.8.0** or later and [date-fns](https://date-fns.org/) **2.0.0** or later.
**Note:** once loaded, this adapter overrides the default date-adapter provided in Chart.js (as a side-effect).
## Installation
### npm
```bash
npm install date-fns chartjs-adapter-date-fns --save
```
```javascript
import { Chart } from 'chart.js';
import 'chartjs-adapter-date-fns';
```
### CDN
By default, `https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns` returns the latest (minified) version, however it's [highly recommended](https://www.jsdelivr.com/features) to always specify a version in order to avoid breaking changes. This can be achieved by appending `@{version}` to the url:
```html
<script src="https://cdn.jsdelivr.net/npm/chart.js/dist/chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
```
Read more about jsDeliver versioning on their [website](http://www.jsdelivr.com/).
## Configuration
### Locale support via scale options
date-fns requires a date-fns locale object to be tagged on to each `format()` call, which requires the locale to be explicitly set via the `adapters.date` option: [Chart.js documentation on adapters.date](https://www.chartjs.org/docs/next/axes/cartesian/time#date-adapters)
For example:
```javascript
// import date-fns locale:
import {de} from 'date-fns/locale';
// scale options:
{
adapters: {
date: {
locale: de
}
}
}
```
Further, read the [Chart.js documentation](https://www.chartjs.org/docs/next) for other possible date/time related options. For example, the time scale [`time.*` options](https://www.chartjs.org/docs/next/axes/cartesian/time#configuration-options) can be overridden using the [date-fns tokens](https://date-fns.org/docs/format).
## Development
You first need to install node dependencies (requires [Node.js](https://nodejs.org/)):
```bash
> npm install
```
The following commands will then be available from the repository root:
```bash
> npm run build // build dist files
> npm run lint // perform code linting
```
## License
`chartjs-adapter-date-fns` is available under the [MIT license](LICENSE.md).

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,109 @@
/*!
* chartjs-adapter-date-fns v3.0.0
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-date-fns Contributors
* Released under the MIT license
*/
import { _adapters } from 'chart.js';
import { toDate, parse, parseISO, isValid, format, addYears, addQuarters, addMonths, addWeeks, addDays, addHours, addMinutes, addSeconds, addMilliseconds, differenceInYears, differenceInQuarters, differenceInMonths, differenceInWeeks, differenceInDays, differenceInHours, differenceInMinutes, differenceInSeconds, differenceInMilliseconds, startOfYear, startOfQuarter, startOfMonth, startOfWeek, startOfDay, startOfHour, startOfMinute, startOfSecond, endOfYear, endOfQuarter, endOfMonth, endOfWeek, endOfDay, endOfHour, endOfMinute, endOfSecond } from 'date-fns';
const FORMATS = {
datetime: 'MMM d, yyyy, h:mm:ss aaaa',
millisecond: 'h:mm:ss.SSS aaaa',
second: 'h:mm:ss aaaa',
minute: 'h:mm aaaa',
hour: 'ha',
day: 'MMM d',
week: 'PP',
month: 'MMM yyyy',
quarter: 'qqq - yyyy',
year: 'yyyy'
};
_adapters._date.override({
_id: 'date-fns', // DEBUG
formats: function() {
return FORMATS;
},
parse: function(value, fmt) {
if (value === null || typeof value === 'undefined') {
return null;
}
const type = typeof value;
if (type === 'number' || value instanceof Date) {
value = toDate(value);
} else if (type === 'string') {
if (typeof fmt === 'string') {
value = parse(value, fmt, new Date(), this.options);
} else {
value = parseISO(value, this.options);
}
}
return isValid(value) ? value.getTime() : null;
},
format: function(time, fmt) {
return format(time, fmt, this.options);
},
add: function(time, amount, unit) {
switch (unit) {
case 'millisecond': return addMilliseconds(time, amount);
case 'second': return addSeconds(time, amount);
case 'minute': return addMinutes(time, amount);
case 'hour': return addHours(time, amount);
case 'day': return addDays(time, amount);
case 'week': return addWeeks(time, amount);
case 'month': return addMonths(time, amount);
case 'quarter': return addQuarters(time, amount);
case 'year': return addYears(time, amount);
default: return time;
}
},
diff: function(max, min, unit) {
switch (unit) {
case 'millisecond': return differenceInMilliseconds(max, min);
case 'second': return differenceInSeconds(max, min);
case 'minute': return differenceInMinutes(max, min);
case 'hour': return differenceInHours(max, min);
case 'day': return differenceInDays(max, min);
case 'week': return differenceInWeeks(max, min);
case 'month': return differenceInMonths(max, min);
case 'quarter': return differenceInQuarters(max, min);
case 'year': return differenceInYears(max, min);
default: return 0;
}
},
startOf: function(time, unit, weekday) {
switch (unit) {
case 'second': return startOfSecond(time);
case 'minute': return startOfMinute(time);
case 'hour': return startOfHour(time);
case 'day': return startOfDay(time);
case 'week': return startOfWeek(time);
case 'isoWeek': return startOfWeek(time, {weekStartsOn: +weekday});
case 'month': return startOfMonth(time);
case 'quarter': return startOfQuarter(time);
case 'year': return startOfYear(time);
default: return time;
}
},
endOf: function(time, unit) {
switch (unit) {
case 'second': return endOfSecond(time);
case 'minute': return endOfMinute(time);
case 'hour': return endOfHour(time);
case 'day': return endOfDay(time);
case 'week': return endOfWeek(time);
case 'month': return endOfMonth(time);
case 'quarter': return endOfQuarter(time);
case 'year': return endOfYear(time);
default: return time;
}
}
});

View file

@ -0,0 +1,114 @@
/*!
* chartjs-adapter-date-fns v3.0.0
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-date-fns Contributors
* Released under the MIT license
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('chart.js'), require('date-fns')) :
typeof define === 'function' && define.amd ? define(['chart.js', 'date-fns'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Chart, global.dateFns));
})(this, (function (chart_js, dateFns) { 'use strict';
const FORMATS = {
datetime: 'MMM d, yyyy, h:mm:ss aaaa',
millisecond: 'h:mm:ss.SSS aaaa',
second: 'h:mm:ss aaaa',
minute: 'h:mm aaaa',
hour: 'ha',
day: 'MMM d',
week: 'PP',
month: 'MMM yyyy',
quarter: 'qqq - yyyy',
year: 'yyyy'
};
chart_js._adapters._date.override({
_id: 'date-fns', // DEBUG
formats: function() {
return FORMATS;
},
parse: function(value, fmt) {
if (value === null || typeof value === 'undefined') {
return null;
}
const type = typeof value;
if (type === 'number' || value instanceof Date) {
value = dateFns.toDate(value);
} else if (type === 'string') {
if (typeof fmt === 'string') {
value = dateFns.parse(value, fmt, new Date(), this.options);
} else {
value = dateFns.parseISO(value, this.options);
}
}
return dateFns.isValid(value) ? value.getTime() : null;
},
format: function(time, fmt) {
return dateFns.format(time, fmt, this.options);
},
add: function(time, amount, unit) {
switch (unit) {
case 'millisecond': return dateFns.addMilliseconds(time, amount);
case 'second': return dateFns.addSeconds(time, amount);
case 'minute': return dateFns.addMinutes(time, amount);
case 'hour': return dateFns.addHours(time, amount);
case 'day': return dateFns.addDays(time, amount);
case 'week': return dateFns.addWeeks(time, amount);
case 'month': return dateFns.addMonths(time, amount);
case 'quarter': return dateFns.addQuarters(time, amount);
case 'year': return dateFns.addYears(time, amount);
default: return time;
}
},
diff: function(max, min, unit) {
switch (unit) {
case 'millisecond': return dateFns.differenceInMilliseconds(max, min);
case 'second': return dateFns.differenceInSeconds(max, min);
case 'minute': return dateFns.differenceInMinutes(max, min);
case 'hour': return dateFns.differenceInHours(max, min);
case 'day': return dateFns.differenceInDays(max, min);
case 'week': return dateFns.differenceInWeeks(max, min);
case 'month': return dateFns.differenceInMonths(max, min);
case 'quarter': return dateFns.differenceInQuarters(max, min);
case 'year': return dateFns.differenceInYears(max, min);
default: return 0;
}
},
startOf: function(time, unit, weekday) {
switch (unit) {
case 'second': return dateFns.startOfSecond(time);
case 'minute': return dateFns.startOfMinute(time);
case 'hour': return dateFns.startOfHour(time);
case 'day': return dateFns.startOfDay(time);
case 'week': return dateFns.startOfWeek(time);
case 'isoWeek': return dateFns.startOfWeek(time, {weekStartsOn: +weekday});
case 'month': return dateFns.startOfMonth(time);
case 'quarter': return dateFns.startOfQuarter(time);
case 'year': return dateFns.startOfYear(time);
default: return time;
}
},
endOf: function(time, unit) {
switch (unit) {
case 'second': return dateFns.endOfSecond(time);
case 'minute': return dateFns.endOfMinute(time);
case 'hour': return dateFns.endOfHour(time);
case 'day': return dateFns.endOfDay(time);
case 'week': return dateFns.endOfWeek(time);
case 'month': return dateFns.endOfMonth(time);
case 'quarter': return dateFns.endOfQuarter(time);
case 'year': return dateFns.endOfYear(time);
default: return time;
}
}
});
}));

View file

@ -0,0 +1,7 @@
/*!
* chartjs-adapter-date-fns v3.0.0
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-date-fns Contributors
* Released under the MIT license
*/
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("chart.js"),require("date-fns")):"function"==typeof define&&define.amd?define(["chart.js","date-fns"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).Chart,e.dateFns)}(this,(function(e,r){"use strict";const t={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};e._adapters._date.override({_id:"date-fns",formats:function(){return t},parse:function(e,t){if(null==e)return null;const n=typeof e;return"number"===n||e instanceof Date?e=r.toDate(e):"string"===n&&(e="string"==typeof t?r.parse(e,t,new Date,this.options):r.parseISO(e,this.options)),r.isValid(e)?e.getTime():null},format:function(e,t){return r.format(e,t,this.options)},add:function(e,t,n){switch(n){case"millisecond":return r.addMilliseconds(e,t);case"second":return r.addSeconds(e,t);case"minute":return r.addMinutes(e,t);case"hour":return r.addHours(e,t);case"day":return r.addDays(e,t);case"week":return r.addWeeks(e,t);case"month":return r.addMonths(e,t);case"quarter":return r.addQuarters(e,t);case"year":return r.addYears(e,t);default:return e}},diff:function(e,t,n){switch(n){case"millisecond":return r.differenceInMilliseconds(e,t);case"second":return r.differenceInSeconds(e,t);case"minute":return r.differenceInMinutes(e,t);case"hour":return r.differenceInHours(e,t);case"day":return r.differenceInDays(e,t);case"week":return r.differenceInWeeks(e,t);case"month":return r.differenceInMonths(e,t);case"quarter":return r.differenceInQuarters(e,t);case"year":return r.differenceInYears(e,t);default:return 0}},startOf:function(e,t,n){switch(t){case"second":return r.startOfSecond(e);case"minute":return r.startOfMinute(e);case"hour":return r.startOfHour(e);case"day":return r.startOfDay(e);case"week":return r.startOfWeek(e);case"isoWeek":return r.startOfWeek(e,{weekStartsOn:+n});case"month":return r.startOfMonth(e);case"quarter":return r.startOfQuarter(e);case"year":return r.startOfYear(e);default:return e}},endOf:function(e,t){switch(t){case"second":return r.endOfSecond(e);case"minute":return r.endOfMinute(e);case"hour":return r.endOfHour(e);case"day":return r.endOfDay(e);case"week":return r.endOfWeek(e);case"month":return r.endOfMonth(e);case"quarter":return r.endOfQuarter(e);case"year":return r.endOfYear(e);default:return e}}})}));

61
node_modules/chartjs-adapter-date-fns/package.json generated vendored Normal file
View file

@ -0,0 +1,61 @@
{
"name": "chartjs-adapter-date-fns",
"homepage": "https://www.chartjs.org",
"description": "Chart.js adapter to use date-fns for time functionalities",
"version": "3.0.0",
"license": "MIT",
"type": "module",
"main": "dist/chartjs-adapter-date-fns.esm.js",
"jsdelivr": "dist/chartjs-adapter-date-fns.bundle.min.js",
"unpkg": "dist/chartjs-adapter-date-fns.bundle.min.js",
"exports": {
"import": "./dist/chartjs-adapter-date-fns.esm.js",
"require": "./dist/chartjs-adapter-date-fns.min.js"
},
"repository": {
"type": "git",
"url": "https://github.com/chartjs/chartjs-adapter-date-fns.git"
},
"scripts": {
"build": "rollup -c",
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome",
"lint": "eslint test/**/*.js src/**/*.js",
"test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
"test-lint": "npm run lint",
"test-karma": "karma start ./karma.conf.cjs --auto-watch --single-run"
},
"keywords": [
"chart.js",
"date",
"date-fns",
"time"
],
"files": [
"dist/*.js"
],
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.1.0",
"chart.js": "^4.0.1",
"chartjs-test-utils": "^0.5.0",
"concurrently": "^7.6.0",
"cross-env": "^7.0.3",
"date-fns": "2.19",
"eslint": "^8.29.0",
"eslint-config-chartjs": "^0.3.0",
"eslint-plugin-es": "^4.1.0",
"karma": "^6.1.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-firefox-launcher": "^2.1.0",
"karma-jasmine": "^5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"karma-rollup-preprocessor": "7.0.7",
"rollup": "^3.7.2",
"rollup-plugin-istanbul": "^4.0.0"
},
"peerDependencies": {
"chart.js": ">=2.8.0",
"date-fns": ">=2.0.0"
}
}

9
node_modules/chartjs-adapter-moment/LICENSE.md generated vendored Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2019 Chart.js Contributors
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.

60
node_modules/chartjs-adapter-moment/README.md generated vendored Normal file
View file

@ -0,0 +1,60 @@
# chartjs-adapter-moment
[![release](https://img.shields.io/github/release/chartjs/chartjs-adapter-moment.svg?style=flat-square&maxAge=600)](https://github.com/chartjs/chartjs-adapter-moment/releases/latest) [![travis](https://img.shields.io/travis/chartjs/chartjs-adapter-moment.svg?style=flat-square&maxAge=60)](https://travis-ci.org/chartjs/chartjs-adapter-moment) [![awesome](https://awesome.re/badge-flat2.svg)](https://github.com/chartjs/awesome)
## Overview
This adapter allows the use of Moment.js with Chart.js. Moment.js is a very heavy library and thus not recommended for client-side development. However, it was previously the only library supported by Chart.js and so continues to be supported. You may prefer [chartjs-adapter-date-fns](https://github.com/chartjs/chartjs-adapter-date-fns) for a minimal bundle size or [chartjs-adapter-luxon](https://github.com/chartjs/chartjs-adapter-luxon) for larger bundle size with additional functionality included such as i18n and time zone support.
Requires [Chart.js](https://github.com/chartjs/Chart.js/releases) **3.0.0** or later and [Moment.js](https://momentjs.com/) **2.0.0** or later. To use Chart.js v2.x, utilize v0.1.2 of the adapter.
**Note:** once loaded, this adapter overrides the default date-adapter provided in Chart.js (as a side-effect).
## Installation
### npm
```
npm install moment chartjs-adapter-moment --save
```
```javascript
import { Chart } from 'chart.js';
import 'chartjs-adapter-moment';
```
### CDN
By default, `https://cdn.jsdelivr.net/npm/chartjs-adapter-moment` returns the latest (minified) version, however it's [highly recommended](https://www.jsdelivr.com/features) to always specify a version in order to avoid breaking changes. This can be achieved by appending `@{version}` to the URL:
```html
<script src="https://cdn.jsdelivr.net/npm/chart.js@^3"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@^2"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-moment@^1"></script>
```
Read more about jsDelivr versioning on their [website](http://www.jsdelivr.com/).
## Configuration
Read the [Chart.js documention](https://www.chartjs.org/docs/latest) for possible date/time related options. For example, the time scale [`time.*` options](https://www.chartjs.org/docs/latest/axes/cartesian/time.html#configuration-options) can be overridden using the [Moment formats](https://momentjs.com/docs/#/displaying/).
## Development
You first need to install node dependencies (requires [Node.js](https://nodejs.org/)):
```
> npm install
```
The following commands will then be available from the repository root:
```
> gulp build // build dist files
> gulp build --watch // build and watch for changes
> gulp lint // perform code linting
```
## License
`chartjs-adapter-moment` is available under the [MIT license](LICENSE.md).

View file

@ -0,0 +1,63 @@
/*!
* chartjs-adapter-moment v1.0.1
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-moment Contributors
* Released under the MIT license
*/
import moment from 'moment';
import { _adapters } from 'chart.js';
const FORMATS = {
datetime: 'MMM D, YYYY, h:mm:ss a',
millisecond: 'h:mm:ss.SSS a',
second: 'h:mm:ss a',
minute: 'h:mm a',
hour: 'hA',
day: 'MMM D',
week: 'll',
month: 'MMM YYYY',
quarter: '[Q]Q - YYYY',
year: 'YYYY'
};
_adapters._date.override(typeof moment === 'function' ? {
_id: 'moment', // DEBUG ONLY
formats: function() {
return FORMATS;
},
parse: function(value, format) {
if (typeof value === 'string' && typeof format === 'string') {
value = moment(value, format);
} else if (!(value instanceof moment)) {
value = moment(value);
}
return value.isValid() ? value.valueOf() : null;
},
format: function(time, format) {
return moment(time).format(format);
},
add: function(time, amount, unit) {
return moment(time).add(amount, unit).valueOf();
},
diff: function(max, min, unit) {
return moment(max).diff(moment(min), unit);
},
startOf: function(time, unit, weekday) {
time = moment(time);
if (unit === 'isoWeek') {
weekday = Math.trunc(Math.min(Math.max(0, weekday), 6));
return time.isoWeekday(weekday).startOf('day').valueOf();
}
return time.startOf(unit).valueOf();
},
endOf: function(time, unit) {
return moment(time).endOf(unit).valueOf();
}
} : {});

View file

@ -0,0 +1,72 @@
/*!
* chartjs-adapter-moment v1.0.1
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-moment Contributors
* Released under the MIT license
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('moment'), require('chart.js')) :
typeof define === 'function' && define.amd ? define(['moment', 'chart.js'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.moment, global.Chart));
}(this, (function (moment, chart_js) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
const FORMATS = {
datetime: 'MMM D, YYYY, h:mm:ss a',
millisecond: 'h:mm:ss.SSS a',
second: 'h:mm:ss a',
minute: 'h:mm a',
hour: 'hA',
day: 'MMM D',
week: 'll',
month: 'MMM YYYY',
quarter: '[Q]Q - YYYY',
year: 'YYYY'
};
chart_js._adapters._date.override(typeof moment__default['default'] === 'function' ? {
_id: 'moment', // DEBUG ONLY
formats: function() {
return FORMATS;
},
parse: function(value, format) {
if (typeof value === 'string' && typeof format === 'string') {
value = moment__default['default'](value, format);
} else if (!(value instanceof moment__default['default'])) {
value = moment__default['default'](value);
}
return value.isValid() ? value.valueOf() : null;
},
format: function(time, format) {
return moment__default['default'](time).format(format);
},
add: function(time, amount, unit) {
return moment__default['default'](time).add(amount, unit).valueOf();
},
diff: function(max, min, unit) {
return moment__default['default'](max).diff(moment__default['default'](min), unit);
},
startOf: function(time, unit, weekday) {
time = moment__default['default'](time);
if (unit === 'isoWeek') {
weekday = Math.trunc(Math.min(Math.max(0, weekday), 6));
return time.isoWeekday(weekday).startOf('day').valueOf();
}
return time.startOf(unit).valueOf();
},
endOf: function(time, unit) {
return moment__default['default'](time).endOf(unit).valueOf();
}
} : {});
})));

View file

@ -0,0 +1,7 @@
/*!
* chartjs-adapter-moment v1.0.1
* https://www.chartjs.org
* (c) 2022 chartjs-adapter-moment Contributors
* Released under the MIT license
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("moment"),require("chart.js")):"function"==typeof define&&define.amd?define(["moment","chart.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).moment,e.Chart)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=n(e);const a={datetime:"MMM D, YYYY, h:mm:ss a",millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"};t._adapters._date.override("function"==typeof f.default?{_id:"moment",formats:function(){return a},parse:function(e,t){return"string"==typeof e&&"string"==typeof t?e=f.default(e,t):e instanceof f.default||(e=f.default(e)),e.isValid()?e.valueOf():null},format:function(e,t){return f.default(e).format(t)},add:function(e,t,n){return f.default(e).add(t,n).valueOf()},diff:function(e,t,n){return f.default(e).diff(f.default(t),n)},startOf:function(e,t,n){return e=f.default(e),"isoWeek"===t?(n=Math.trunc(Math.min(Math.max(0,n),6)),e.isoWeekday(n).startOf("day").valueOf()):e.startOf(t).valueOf()},endOf:function(e,t){return f.default(e).endOf(t).valueOf()}}:{})}));

56
node_modules/chartjs-adapter-moment/package.json generated vendored Normal file
View file

@ -0,0 +1,56 @@
{
"name": "chartjs-adapter-moment",
"homepage": "https://www.chartjs.org",
"description": "Chart.js adapter to use Moment.js for time functionalities",
"version": "1.0.1",
"license": "MIT",
"main": "dist/chartjs-adapter-moment.js",
"module": "dist/chartjs-adapter-moment.esm.js",
"repository": {
"type": "git",
"url": "https://github.com/chartjs/chartjs-adapter-moment.git"
},
"keywords": [
"chart.js",
"date",
"moment",
"time"
],
"files": [
"dist/*.js"
],
"scripts": {
"build": "rollup -c",
"dev": "karma start --auto-watch --no-single-run --browsers chrome",
"lint": "eslint test/**/*.js src/**/*.js",
"test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
"test-lint": "npm run lint",
"test-karma": "karma start --auto-watch --single-run"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^11.1.1",
"chart.js": "^4.0.0",
"chartjs-test-utils": "^0.3.0",
"concurrently": "^5.3.0",
"cross-env": "^7.0.3",
"eslint": "^7.19.0",
"eslint-config-chartjs": "^0.3.0",
"eslint-plugin-es": "^4.1.0",
"karma": "^6.0.4",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.3",
"karma-firefox-launcher": "^2.1.0",
"karma-jasmine": "^4.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"karma-rollup-preprocessor": "7.0.5",
"moment": "^2.10.2",
"rollup": "^2.38.4",
"rollup-plugin-istanbul": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"yargs": "^15.0.2"
},
"peerDependencies": {
"chart.js": ">=3.0.0",
"moment": "^2.10.2"
}
}

9
node_modules/chartjs-plugin-zoom/LICENSE.md generated vendored Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2013-2021 chartjs-plugin-zoom contributors
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.

30
node_modules/chartjs-plugin-zoom/README.md generated vendored Normal file
View file

@ -0,0 +1,30 @@
# chartjs-plugin-zoom
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/chartjs/chartjs-plugin-zoom/ci.yml)](https://github.com/chartjs/chartjs-plugin-zoom/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/chartjs/chartjs-plugin-zoom/badge.svg?branch=master)](https://coveralls.io/github/chartjs/chartjs-plugin-zoom?branch=master)
[![release](https://img.shields.io/github/v/release/chartjs/chartjs-plugin-zoom?include_prereleases)](https://github.com/chartjs/chartjs-plugin-zoom/releases)
[![npm (latest)](https://img.shields.io/npm/v/chartjs-plugin-zoom/latest)](https://www.npmjs.com/package/chartjs-plugin-zoom/v/latest)
[![npm (next)](https://img.shields.io/npm/v/chartjs-plugin-zoom/next)](https://www.npmjs.com/package/chartjs-plugin-zoom/v/next)
[![documentation](https://img.shields.io/static/v1?message=Documentation&color=informational)](https://www.chartjs.org/chartjs-plugin-zoom/index)
<a href="https://github.com/chartjs/awesome"><img src="https://awesome.re/badge-flat2.svg" alt="Awesome"></a>
A zoom and pan plugin for Chart.js >= 3.0.0
For Chart.js 2.6.0 to 2.9.x support, use [version 0.7.7 of this plugin](https://github.com/chartjs/chartjs-plugin-zoom/releases/tag/v0.7.7).
Panning can be done via the mouse or with a finger.
Zooming is done via the mouse wheel or via a pinch gesture. [Hammer.js](https://hammerjs.github.io/) is used for gesture recognition.
## Documentation
You can find documentation for chartjs-plugin-zoom at [www.chartjs.org/chartjs-plugin-zoom](https://www.chartjs.org/chartjs-plugin-zoom/).
Prior to v0.4.0, this plugin was known as 'Chart.Zoom.js'. Old versions are still available on npm under that name.
## Contributing
Before submitting an issue or a pull request to the project, please take a moment to look over the [contributing guidelines](CONTRIBUTING.md) first.
## License
chartjs-plugin-zoom.js is available under the [MIT license](https://opensource.org/licenses/MIT).

View file

@ -0,0 +1,972 @@
/*!
* chartjs-plugin-zoom v2.2.0
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
* (c) 2016-2024 chartjs-plugin-zoom Contributors
* Released under the MIT License
*/
import Hammer from 'hammerjs';
import { each, valueOrDefault, almostEquals, callback, sign, getRelativePosition, _isPointInArea } from 'chart.js/helpers';
const getModifierKey = opts => opts && opts.enabled && opts.modifierKey;
const keyPressed = (key, event) => key && event[key + 'Key'];
const keyNotPressed = (key, event) => key && !event[key + 'Key'];
function directionEnabled(mode, dir, chart) {
if (mode === undefined) {
return true;
} else if (typeof mode === 'string') {
return mode.indexOf(dir) !== -1;
} else if (typeof mode === 'function') {
return mode({chart}).indexOf(dir) !== -1;
}
return false;
}
function directionsEnabled(mode, chart) {
if (typeof mode === 'function') {
mode = mode({chart});
}
if (typeof mode === 'string') {
return {x: mode.indexOf('x') !== -1, y: mode.indexOf('y') !== -1};
}
return {x: false, y: false};
}
function debounce(fn, delay) {
let timeout;
return function() {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
return delay;
};
}
function getScaleUnderPoint({x, y}, chart) {
const scales = chart.scales;
const scaleIds = Object.keys(scales);
for (let i = 0; i < scaleIds.length; i++) {
const scale = scales[scaleIds[i]];
if (y >= scale.top && y <= scale.bottom && x >= scale.left && x <= scale.right) {
return scale;
}
}
return null;
}
function getEnabledScalesByPoint(options, point, chart) {
const {mode = 'xy', scaleMode, overScaleMode} = options || {};
const scale = getScaleUnderPoint(point, chart);
const enabled = directionsEnabled(mode, chart);
const scaleEnabled = directionsEnabled(scaleMode, chart);
if (overScaleMode) {
const overScaleEnabled = directionsEnabled(overScaleMode, chart);
for (const axis of ['x', 'y']) {
if (overScaleEnabled[axis]) {
scaleEnabled[axis] = enabled[axis];
enabled[axis] = false;
}
}
}
if (scale && scaleEnabled[scale.axis]) {
return [scale];
}
const enabledScales = [];
each(chart.scales, function(scaleItem) {
if (enabled[scaleItem.axis]) {
enabledScales.push(scaleItem);
}
});
return enabledScales;
}
const chartStates = new WeakMap();
function getState(chart) {
let state = chartStates.get(chart);
if (!state) {
state = {
originalScaleLimits: {},
updatedScaleLimits: {},
handlers: {},
panDelta: {},
dragging: false,
panning: false
};
chartStates.set(chart, state);
}
return state;
}
function removeState(chart) {
chartStates.delete(chart);
}
function zoomDelta(val, min, range, newRange) {
const minPercent = Math.max(0, Math.min(1, (val - min) / range || 0));
const maxPercent = 1 - minPercent;
return {
min: newRange * minPercent,
max: newRange * maxPercent
};
}
function getValueAtPoint(scale, point) {
const pixel = scale.isHorizontal() ? point.x : point.y;
return scale.getValueForPixel(pixel);
}
function linearZoomDelta(scale, zoom, center) {
const range = scale.max - scale.min;
const newRange = range * (zoom - 1);
const centerValue = getValueAtPoint(scale, center);
return zoomDelta(centerValue, scale.min, range, newRange);
}
function logarithmicZoomRange(scale, zoom, center) {
const centerValue = getValueAtPoint(scale, center);
if (centerValue === undefined) {
return {min: scale.min, max: scale.max};
}
const logMin = Math.log10(scale.min);
const logMax = Math.log10(scale.max);
const logCenter = Math.log10(centerValue);
const logRange = logMax - logMin;
const newLogRange = logRange * (zoom - 1);
const delta = zoomDelta(logCenter, logMin, logRange, newLogRange);
return {
min: Math.pow(10, logMin + delta.min),
max: Math.pow(10, logMax - delta.max),
};
}
function getScaleLimits(scale, limits) {
return limits && (limits[scale.id] || limits[scale.axis]) || {};
}
function getLimit(state, scale, scaleLimits, prop, fallback) {
let limit = scaleLimits[prop];
if (limit === 'original') {
const original = state.originalScaleLimits[scale.id][prop];
limit = valueOrDefault(original.options, original.scale);
}
return valueOrDefault(limit, fallback);
}
function linearRange(scale, pixel0, pixel1) {
const v0 = scale.getValueForPixel(pixel0);
const v1 = scale.getValueForPixel(pixel1);
return {
min: Math.min(v0, v1),
max: Math.max(v0, v1)
};
}
function fixRange(range, {min, max, minLimit, maxLimit}, originalLimits) {
const offset = (range - max + min) / 2;
min -= offset;
max += offset;
const origMin = originalLimits.min.options ?? originalLimits.min.scale;
const origMax = originalLimits.max.options ?? originalLimits.max.scale;
const epsilon = range / 1e6;
if (almostEquals(min, origMin, epsilon)) {
min = origMin;
}
if (almostEquals(max, origMax, epsilon)) {
max = origMax;
}
if (min < minLimit) {
min = minLimit;
max = Math.min(minLimit + range, maxLimit);
} else if (max > maxLimit) {
max = maxLimit;
min = Math.max(maxLimit - range, minLimit);
}
return {min, max};
}
function updateRange(scale, {min, max}, limits, zoom = false) {
const state = getState(scale.chart);
const {options: scaleOpts} = scale;
const scaleLimits = getScaleLimits(scale, limits);
const {minRange = 0} = scaleLimits;
const minLimit = getLimit(state, scale, scaleLimits, 'min', -Infinity);
const maxLimit = getLimit(state, scale, scaleLimits, 'max', Infinity);
if (zoom === 'pan' && (min < minLimit || max > maxLimit)) {
return true;
}
const scaleRange = scale.max - scale.min;
const range = zoom ? Math.max(max - min, minRange) : scaleRange;
if (zoom && range === minRange && scaleRange <= minRange) {
return true;
}
const newRange = fixRange(range, {min, max, minLimit, maxLimit}, state.originalScaleLimits[scale.id]);
scaleOpts.min = newRange.min;
scaleOpts.max = newRange.max;
state.updatedScaleLimits[scale.id] = newRange;
return scale.parse(newRange.min) !== scale.min || scale.parse(newRange.max) !== scale.max;
}
function zoomNumericalScale(scale, zoom, center, limits) {
const delta = linearZoomDelta(scale, zoom, center);
const newRange = {min: scale.min + delta.min, max: scale.max - delta.max};
return updateRange(scale, newRange, limits, true);
}
function zoomLogarithmicScale(scale, zoom, center, limits) {
const newRange = logarithmicZoomRange(scale, zoom, center);
return updateRange(scale, newRange, limits, true);
}
function zoomRectNumericalScale(scale, from, to, limits) {
updateRange(scale, linearRange(scale, from, to), limits, true);
}
const integerChange = (v) => v === 0 || isNaN(v) ? 0 : v < 0 ? Math.min(Math.round(v), -1) : Math.max(Math.round(v), 1);
function existCategoryFromMaxZoom(scale) {
const labels = scale.getLabels();
const maxIndex = labels.length - 1;
if (scale.min > 0) {
scale.min -= 1;
}
if (scale.max < maxIndex) {
scale.max += 1;
}
}
function zoomCategoryScale(scale, zoom, center, limits) {
const delta = linearZoomDelta(scale, zoom, center);
if (scale.min === scale.max && zoom < 1) {
existCategoryFromMaxZoom(scale);
}
const newRange = {min: scale.min + integerChange(delta.min), max: scale.max - integerChange(delta.max)};
return updateRange(scale, newRange, limits, true);
}
function scaleLength(scale) {
return scale.isHorizontal() ? scale.width : scale.height;
}
function panCategoryScale(scale, delta, limits) {
const labels = scale.getLabels();
const lastLabelIndex = labels.length - 1;
let {min, max} = scale;
const range = Math.max(max - min, 1);
const stepDelta = Math.round(scaleLength(scale) / Math.max(range, 10));
const stepSize = Math.round(Math.abs(delta / stepDelta));
let applied;
if (delta < -stepDelta) {
max = Math.min(max + stepSize, lastLabelIndex);
min = range === 1 ? max : max - range;
applied = max === lastLabelIndex;
} else if (delta > stepDelta) {
min = Math.max(0, min - stepSize);
max = range === 1 ? min : min + range;
applied = min === 0;
}
return updateRange(scale, {min, max}, limits) || applied;
}
const OFFSETS = {
second: 500,
minute: 30 * 1000,
hour: 30 * 60 * 1000,
day: 12 * 60 * 60 * 1000,
week: 3.5 * 24 * 60 * 60 * 1000,
month: 15 * 24 * 60 * 60 * 1000,
quarter: 60 * 24 * 60 * 60 * 1000,
year: 182 * 24 * 60 * 60 * 1000
};
function panNumericalScale(scale, delta, limits, pan = false) {
const {min: prevStart, max: prevEnd, options} = scale;
const round = options.time && options.time.round;
const offset = OFFSETS[round] || 0;
const newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart + offset) - delta);
const newMax = scale.getValueForPixel(scale.getPixelForValue(prevEnd + offset) - delta);
if (isNaN(newMin) || isNaN(newMax)) {
return true;
}
return updateRange(scale, {min: newMin, max: newMax}, limits, pan ? 'pan' : false);
}
function panNonLinearScale(scale, delta, limits) {
return panNumericalScale(scale, delta, limits, true);
}
const zoomFunctions = {
category: zoomCategoryScale,
default: zoomNumericalScale,
logarithmic: zoomLogarithmicScale,
};
const zoomRectFunctions = {
default: zoomRectNumericalScale,
};
const panFunctions = {
category: panCategoryScale,
default: panNumericalScale,
logarithmic: panNonLinearScale,
timeseries: panNonLinearScale,
};
function shouldUpdateScaleLimits(scale, originalScaleLimits, updatedScaleLimits) {
const {id, options: {min, max}} = scale;
if (!originalScaleLimits[id] || !updatedScaleLimits[id]) {
return true;
}
const previous = updatedScaleLimits[id];
return previous.min !== min || previous.max !== max;
}
function removeMissingScales(limits, scales) {
each(limits, (opt, key) => {
if (!scales[key]) {
delete limits[key];
}
});
}
function storeOriginalScaleLimits(chart, state) {
const {scales} = chart;
const {originalScaleLimits, updatedScaleLimits} = state;
each(scales, function(scale) {
if (shouldUpdateScaleLimits(scale, originalScaleLimits, updatedScaleLimits)) {
originalScaleLimits[scale.id] = {
min: {scale: scale.min, options: scale.options.min},
max: {scale: scale.max, options: scale.options.max},
};
}
});
removeMissingScales(originalScaleLimits, scales);
removeMissingScales(updatedScaleLimits, scales);
return originalScaleLimits;
}
function doZoom(scale, amount, center, limits) {
const fn = zoomFunctions[scale.type] || zoomFunctions.default;
callback(fn, [scale, amount, center, limits]);
}
function doZoomRect(scale, from, to, limits) {
const fn = zoomRectFunctions[scale.type] || zoomRectFunctions.default;
callback(fn, [scale, from, to, limits]);
}
function getCenter(chart) {
const ca = chart.chartArea;
return {
x: (ca.left + ca.right) / 2,
y: (ca.top + ca.bottom) / 2,
};
}
function zoom(chart, amount, transition = 'none', trigger = 'api') {
const {x = 1, y = 1, focalPoint = getCenter(chart)} = typeof amount === 'number' ? {x: amount, y: amount} : amount;
const state = getState(chart);
const {options: {limits, zoom: zoomOptions}} = state;
storeOriginalScaleLimits(chart, state);
const xEnabled = x !== 1;
const yEnabled = y !== 1;
const enabledScales = getEnabledScalesByPoint(zoomOptions, focalPoint, chart);
each(enabledScales || chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
doZoom(scale, x, focalPoint, limits);
} else if (!scale.isHorizontal() && yEnabled) {
doZoom(scale, y, focalPoint, limits);
}
});
chart.update(transition);
callback(zoomOptions.onZoom, [{chart, trigger}]);
}
function zoomRect(chart, p0, p1, transition = 'none', trigger = 'api') {
const state = getState(chart);
const {options: {limits, zoom: zoomOptions}} = state;
const {mode = 'xy'} = zoomOptions;
storeOriginalScaleLimits(chart, state);
const xEnabled = directionEnabled(mode, 'x', chart);
const yEnabled = directionEnabled(mode, 'y', chart);
each(chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
doZoomRect(scale, p0.x, p1.x, limits);
} else if (!scale.isHorizontal() && yEnabled) {
doZoomRect(scale, p0.y, p1.y, limits);
}
});
chart.update(transition);
callback(zoomOptions.onZoom, [{chart, trigger}]);
}
function zoomScale(chart, scaleId, range, transition = 'none', trigger = 'api') {
const state = getState(chart);
storeOriginalScaleLimits(chart, state);
const scale = chart.scales[scaleId];
updateRange(scale, range, undefined, true);
chart.update(transition);
callback(state.options.zoom?.onZoom, [{chart, trigger}]);
}
function resetZoom(chart, transition = 'default') {
const state = getState(chart);
const originalScaleLimits = storeOriginalScaleLimits(chart, state);
each(chart.scales, function(scale) {
const scaleOptions = scale.options;
if (originalScaleLimits[scale.id]) {
scaleOptions.min = originalScaleLimits[scale.id].min.options;
scaleOptions.max = originalScaleLimits[scale.id].max.options;
} else {
delete scaleOptions.min;
delete scaleOptions.max;
}
delete state.updatedScaleLimits[scale.id];
});
chart.update(transition);
callback(state.options.zoom.onZoomComplete, [{chart}]);
}
function getOriginalRange(state, scaleId) {
const original = state.originalScaleLimits[scaleId];
if (!original) {
return;
}
const {min, max} = original;
return valueOrDefault(max.options, max.scale) - valueOrDefault(min.options, min.scale);
}
function getZoomLevel(chart) {
const state = getState(chart);
let min = 1;
let max = 1;
each(chart.scales, function(scale) {
const origRange = getOriginalRange(state, scale.id);
if (origRange) {
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
min = Math.min(min, level);
max = Math.max(max, level);
}
});
return min < 1 ? min : max;
}
function panScale(scale, delta, limits, state) {
const {panDelta} = state;
const storedDelta = panDelta[scale.id] || 0;
if (sign(storedDelta) === sign(delta)) {
delta += storedDelta;
}
const fn = panFunctions[scale.type] || panFunctions.default;
if (callback(fn, [scale, delta, limits])) {
panDelta[scale.id] = 0;
} else {
panDelta[scale.id] = delta;
}
}
function pan(chart, delta, enabledScales, transition = 'none') {
const {x = 0, y = 0} = typeof delta === 'number' ? {x: delta, y: delta} : delta;
const state = getState(chart);
const {options: {pan: panOptions, limits}} = state;
const {onPan} = panOptions || {};
storeOriginalScaleLimits(chart, state);
const xEnabled = x !== 0;
const yEnabled = y !== 0;
each(enabledScales || chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
panScale(scale, x, limits, state);
} else if (!scale.isHorizontal() && yEnabled) {
panScale(scale, y, limits, state);
}
});
chart.update(transition);
callback(onPan, [{chart}]);
}
function getInitialScaleBounds(chart) {
const state = getState(chart);
storeOriginalScaleLimits(chart, state);
const scaleBounds = {};
for (const scaleId of Object.keys(chart.scales)) {
const {min, max} = state.originalScaleLimits[scaleId] || {min: {}, max: {}};
scaleBounds[scaleId] = {min: min.scale, max: max.scale};
}
return scaleBounds;
}
function getZoomedScaleBounds(chart) {
const state = getState(chart);
const scaleBounds = {};
for (const scaleId of Object.keys(chart.scales)) {
scaleBounds[scaleId] = state.updatedScaleLimits[scaleId];
}
return scaleBounds;
}
function isZoomedOrPanned(chart) {
const scaleBounds = getInitialScaleBounds(chart);
for (const scaleId of Object.keys(chart.scales)) {
const {min: originalMin, max: originalMax} = scaleBounds[scaleId];
if (originalMin !== undefined && chart.scales[scaleId].min !== originalMin) {
return true;
}
if (originalMax !== undefined && chart.scales[scaleId].max !== originalMax) {
return true;
}
}
return false;
}
function isZoomingOrPanning(chart) {
const state = getState(chart);
return state.panning || state.dragging;
}
const clamp = (x, from, to) => Math.min(to, Math.max(from, x));
function removeHandler(chart, type) {
const {handlers} = getState(chart);
const handler = handlers[type];
if (handler && handler.target) {
handler.target.removeEventListener(type, handler);
delete handlers[type];
}
}
function addHandler(chart, target, type, handler) {
const {handlers, options} = getState(chart);
const oldHandler = handlers[type];
if (oldHandler && oldHandler.target === target) {
return;
}
removeHandler(chart, type);
handlers[type] = (event) => handler(chart, event, options);
handlers[type].target = target;
const passive = type === 'wheel' ? false : undefined;
target.addEventListener(type, handlers[type], {passive});
}
function mouseMove(chart, event) {
const state = getState(chart);
if (state.dragStart) {
state.dragging = true;
state.dragEnd = event;
chart.update('none');
}
}
function keyDown(chart, event) {
const state = getState(chart);
if (!state.dragStart || event.key !== 'Escape') {
return;
}
removeHandler(chart, 'keydown');
state.dragging = false;
state.dragStart = state.dragEnd = null;
chart.update('none');
}
function getPointPosition(event, chart) {
if (event.target !== chart.canvas) {
const canvasArea = chart.canvas.getBoundingClientRect();
return {
x: event.clientX - canvasArea.left,
y: event.clientY - canvasArea.top,
};
}
return getRelativePosition(event, chart);
}
function zoomStart(chart, event, zoomOptions) {
const {onZoomStart, onZoomRejected} = zoomOptions;
if (onZoomStart) {
const point = getPointPosition(event, chart);
if (callback(onZoomStart, [{chart, event, point}]) === false) {
callback(onZoomRejected, [{chart, event}]);
return false;
}
}
}
function mouseDown(chart, event) {
if (chart.legend) {
const point = getRelativePosition(event, chart);
if (_isPointInArea(point, chart.legend)) {
return;
}
}
const state = getState(chart);
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
if (
event.button !== 0 ||
keyPressed(getModifierKey(panOptions), event) ||
keyNotPressed(getModifierKey(zoomOptions.drag), event)
) {
return callback(zoomOptions.onZoomRejected, [{chart, event}]);
}
if (zoomStart(chart, event, zoomOptions) === false) {
return;
}
state.dragStart = event;
addHandler(chart, chart.canvas.ownerDocument, 'mousemove', mouseMove);
addHandler(chart, window.document, 'keydown', keyDown);
}
function applyAspectRatio({begin, end}, aspectRatio) {
let width = end.x - begin.x;
let height = end.y - begin.y;
const ratio = Math.abs(width / height);
if (ratio > aspectRatio) {
width = Math.sign(width) * Math.abs(height * aspectRatio);
} else if (ratio < aspectRatio) {
height = Math.sign(height) * Math.abs(width / aspectRatio);
}
end.x = begin.x + width;
end.y = begin.y + height;
}
function applyMinMaxProps(rect, chartArea, points, {min, max, prop}) {
rect[min] = clamp(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
rect[max] = clamp(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
}
function getRelativePoints(chart, pointEvents, maintainAspectRatio) {
const points = {
begin: getPointPosition(pointEvents.dragStart, chart),
end: getPointPosition(pointEvents.dragEnd, chart),
};
if (maintainAspectRatio) {
const aspectRatio = chart.chartArea.width / chart.chartArea.height;
applyAspectRatio(points, aspectRatio);
}
return points;
}
function computeDragRect(chart, mode, pointEvents, maintainAspectRatio) {
const xEnabled = directionEnabled(mode, 'x', chart);
const yEnabled = directionEnabled(mode, 'y', chart);
const {top, left, right, bottom, width: chartWidth, height: chartHeight} = chart.chartArea;
const rect = {top, left, right, bottom};
const points = getRelativePoints(chart, pointEvents, maintainAspectRatio && xEnabled && yEnabled);
if (xEnabled) {
applyMinMaxProps(rect, chart.chartArea, points, {min: 'left', max: 'right', prop: 'x'});
}
if (yEnabled) {
applyMinMaxProps(rect, chart.chartArea, points, {min: 'top', max: 'bottom', prop: 'y'});
}
const width = rect.right - rect.left;
const height = rect.bottom - rect.top;
return {
...rect,
width,
height,
zoomX: xEnabled && width ? 1 + ((chartWidth - width) / chartWidth) : 1,
zoomY: yEnabled && height ? 1 + ((chartHeight - height) / chartHeight) : 1
};
}
function mouseUp(chart, event) {
const state = getState(chart);
if (!state.dragStart) {
return;
}
removeHandler(chart, 'mousemove');
const {mode, onZoomComplete, drag: {threshold = 0, maintainAspectRatio}} = state.options.zoom;
const rect = computeDragRect(chart, mode, {dragStart: state.dragStart, dragEnd: event}, maintainAspectRatio);
const distanceX = directionEnabled(mode, 'x', chart) ? rect.width : 0;
const distanceY = directionEnabled(mode, 'y', chart) ? rect.height : 0;
const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
state.dragStart = state.dragEnd = null;
if (distance <= threshold) {
state.dragging = false;
chart.update('none');
return;
}
zoomRect(chart, {x: rect.left, y: rect.top}, {x: rect.right, y: rect.bottom}, 'zoom', 'drag');
state.dragging = false;
state.filterNextClick = true;
callback(onZoomComplete, [{chart}]);
}
function wheelPreconditions(chart, event, zoomOptions) {
if (keyNotPressed(getModifierKey(zoomOptions.wheel), event)) {
callback(zoomOptions.onZoomRejected, [{chart, event}]);
return;
}
if (zoomStart(chart, event, zoomOptions) === false) {
return;
}
if (event.cancelable) {
event.preventDefault();
}
if (event.deltaY === undefined) {
return;
}
return true;
}
function wheel(chart, event) {
const {handlers: {onZoomComplete}, options: {zoom: zoomOptions}} = getState(chart);
if (!wheelPreconditions(chart, event, zoomOptions)) {
return;
}
const rect = event.target.getBoundingClientRect();
const speed = zoomOptions.wheel.speed;
const percentage = event.deltaY >= 0 ? 2 - 1 / (1 - speed) : 1 + speed;
const amount = {
x: percentage,
y: percentage,
focalPoint: {
x: event.clientX - rect.left,
y: event.clientY - rect.top
}
};
zoom(chart, amount, 'zoom', 'wheel');
callback(onZoomComplete, [{chart}]);
}
function addDebouncedHandler(chart, name, handler, delay) {
if (handler) {
getState(chart).handlers[name] = debounce(() => callback(handler, [{chart}]), delay);
}
}
function addListeners(chart, options) {
const canvas = chart.canvas;
const {wheel: wheelOptions, drag: dragOptions, onZoomComplete} = options.zoom;
if (wheelOptions.enabled) {
addHandler(chart, canvas, 'wheel', wheel);
addDebouncedHandler(chart, 'onZoomComplete', onZoomComplete, 250);
} else {
removeHandler(chart, 'wheel');
}
if (dragOptions.enabled) {
addHandler(chart, canvas, 'mousedown', mouseDown);
addHandler(chart, canvas.ownerDocument, 'mouseup', mouseUp);
} else {
removeHandler(chart, 'mousedown');
removeHandler(chart, 'mousemove');
removeHandler(chart, 'mouseup');
removeHandler(chart, 'keydown');
}
}
function removeListeners(chart) {
removeHandler(chart, 'mousedown');
removeHandler(chart, 'mousemove');
removeHandler(chart, 'mouseup');
removeHandler(chart, 'wheel');
removeHandler(chart, 'click');
removeHandler(chart, 'keydown');
}
function createEnabler(chart, state) {
return function(recognizer, event) {
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
if (!panOptions || !panOptions.enabled) {
return false;
}
const srcEvent = event && event.srcEvent;
if (!srcEvent) {
return true;
}
if (!state.panning && event.pointerType === 'mouse' && (
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions.drag), srcEvent))
) {
callback(panOptions.onPanRejected, [{chart, event}]);
return false;
}
return true;
};
}
function pinchAxes(p0, p1) {
const pinchX = Math.abs(p0.clientX - p1.clientX);
const pinchY = Math.abs(p0.clientY - p1.clientY);
const p = pinchX / pinchY;
let x, y;
if (p > 0.3 && p < 1.7) {
x = y = true;
} else if (pinchX > pinchY) {
x = true;
} else {
y = true;
}
return {x, y};
}
function handlePinch(chart, state, e) {
if (state.scale) {
const {center, pointers} = e;
const zoomPercent = 1 / state.scale * e.scale;
const rect = e.target.getBoundingClientRect();
const pinch = pinchAxes(pointers[0], pointers[1]);
const mode = state.options.zoom.mode;
const amount = {
x: pinch.x && directionEnabled(mode, 'x', chart) ? zoomPercent : 1,
y: pinch.y && directionEnabled(mode, 'y', chart) ? zoomPercent : 1,
focalPoint: {
x: center.x - rect.left,
y: center.y - rect.top
}
};
zoom(chart, amount, 'zoom', 'pinch');
state.scale = e.scale;
}
}
function startPinch(chart, state, event) {
if (state.options.zoom.pinch.enabled) {
const point = getRelativePosition(event, chart);
if (callback(state.options.zoom.onZoomStart, [{chart, event, point}]) === false) {
state.scale = null;
callback(state.options.zoom.onZoomRejected, [{chart, event}]);
} else {
state.scale = 1;
}
}
}
function endPinch(chart, state, e) {
if (state.scale) {
handlePinch(chart, state, e);
state.scale = null;
callback(state.options.zoom.onZoomComplete, [{chart}]);
}
}
function handlePan(chart, state, e) {
const delta = state.delta;
if (delta) {
state.panning = true;
pan(chart, {x: e.deltaX - delta.x, y: e.deltaY - delta.y}, state.panScales);
state.delta = {x: e.deltaX, y: e.deltaY};
}
}
function startPan(chart, state, event) {
const {enabled, onPanStart, onPanRejected} = state.options.pan;
if (!enabled) {
return;
}
const rect = event.target.getBoundingClientRect();
const point = {
x: event.center.x - rect.left,
y: event.center.y - rect.top
};
if (callback(onPanStart, [{chart, event, point}]) === false) {
return callback(onPanRejected, [{chart, event}]);
}
state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart);
state.delta = {x: 0, y: 0};
handlePan(chart, state, event);
}
function endPan(chart, state) {
state.delta = null;
if (state.panning) {
state.panning = false;
state.filterNextClick = true;
callback(state.options.pan.onPanComplete, [{chart}]);
}
}
const hammers = new WeakMap();
function startHammer(chart, options) {
const state = getState(chart);
const canvas = chart.canvas;
const {pan: panOptions, zoom: zoomOptions} = options;
const mc = new Hammer.Manager(canvas);
if (zoomOptions && zoomOptions.pinch.enabled) {
mc.add(new Hammer.Pinch());
mc.on('pinchstart', (e) => startPinch(chart, state, e));
mc.on('pinch', (e) => handlePinch(chart, state, e));
mc.on('pinchend', (e) => endPinch(chart, state, e));
}
if (panOptions && panOptions.enabled) {
mc.add(new Hammer.Pan({
threshold: panOptions.threshold,
enable: createEnabler(chart, state)
}));
mc.on('panstart', (e) => startPan(chart, state, e));
mc.on('panmove', (e) => handlePan(chart, state, e));
mc.on('panend', () => endPan(chart, state));
}
hammers.set(chart, mc);
}
function stopHammer(chart) {
const mc = hammers.get(chart);
if (mc) {
mc.remove('pinchstart');
mc.remove('pinch');
mc.remove('pinchend');
mc.remove('panstart');
mc.remove('pan');
mc.remove('panend');
mc.destroy();
hammers.delete(chart);
}
}
function hammerOptionsChanged(oldOptions, newOptions) {
const {pan: oldPan, zoom: oldZoom} = oldOptions;
const {pan: newPan, zoom: newZoom} = newOptions;
if (oldZoom?.zoom?.pinch?.enabled !== newZoom?.zoom?.pinch?.enabled) {
return true;
}
if (oldPan?.enabled !== newPan?.enabled) {
return true;
}
if (oldPan?.threshold !== newPan?.threshold) {
return true;
}
return false;
}
var version = "2.2.0";
function draw(chart, caller, options) {
const dragOptions = options.zoom.drag;
const {dragStart, dragEnd} = getState(chart);
if (dragOptions.drawTime !== caller || !dragEnd) {
return;
}
const {left, top, width, height} = computeDragRect(chart, options.zoom.mode, {dragStart, dragEnd}, dragOptions.maintainAspectRatio);
const ctx = chart.ctx;
ctx.save();
ctx.beginPath();
ctx.fillStyle = dragOptions.backgroundColor || 'rgba(225,225,225,0.3)';
ctx.fillRect(left, top, width, height);
if (dragOptions.borderWidth > 0) {
ctx.lineWidth = dragOptions.borderWidth;
ctx.strokeStyle = dragOptions.borderColor || 'rgba(225,225,225)';
ctx.strokeRect(left, top, width, height);
}
ctx.restore();
}
var plugin = {
id: 'zoom',
version,
defaults: {
pan: {
enabled: false,
mode: 'xy',
threshold: 10,
modifierKey: null,
},
zoom: {
wheel: {
enabled: false,
speed: 0.1,
modifierKey: null
},
drag: {
enabled: false,
drawTime: 'beforeDatasetsDraw',
modifierKey: null
},
pinch: {
enabled: false
},
mode: 'xy',
}
},
start: function(chart, _args, options) {
const state = getState(chart);
state.options = options;
if (Object.prototype.hasOwnProperty.call(options.zoom, 'enabled')) {
console.warn('The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`.');
}
if (Object.prototype.hasOwnProperty.call(options.zoom, 'overScaleMode')
|| Object.prototype.hasOwnProperty.call(options.pan, 'overScaleMode')) {
console.warn('The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired).');
}
if (Hammer) {
startHammer(chart, options);
}
chart.pan = (delta, panScales, transition) => pan(chart, delta, panScales, transition);
chart.zoom = (args, transition) => zoom(chart, args, transition);
chart.zoomRect = (p0, p1, transition) => zoomRect(chart, p0, p1, transition);
chart.zoomScale = (id, range, transition) => zoomScale(chart, id, range, transition);
chart.resetZoom = (transition) => resetZoom(chart, transition);
chart.getZoomLevel = () => getZoomLevel(chart);
chart.getInitialScaleBounds = () => getInitialScaleBounds(chart);
chart.getZoomedScaleBounds = () => getZoomedScaleBounds(chart);
chart.isZoomedOrPanned = () => isZoomedOrPanned(chart);
chart.isZoomingOrPanning = () => isZoomingOrPanning(chart);
},
beforeEvent(chart, {event}) {
if (isZoomingOrPanning(chart)) {
return false;
}
if (event.type === 'click' || event.type === 'mouseup') {
const state = getState(chart);
if (state.filterNextClick) {
state.filterNextClick = false;
return false;
}
}
},
beforeUpdate: function(chart, args, options) {
const state = getState(chart);
const previousOptions = state.options;
state.options = options;
if (hammerOptionsChanged(previousOptions, options)) {
stopHammer(chart);
startHammer(chart, options);
}
addListeners(chart, options);
},
beforeDatasetsDraw(chart, _args, options) {
draw(chart, 'beforeDatasetsDraw', options);
},
afterDatasetsDraw(chart, _args, options) {
draw(chart, 'afterDatasetsDraw', options);
},
beforeDraw(chart, _args, options) {
draw(chart, 'beforeDraw', options);
},
afterDraw(chart, _args, options) {
draw(chart, 'afterDraw', options);
},
stop: function(chart) {
removeListeners(chart);
if (Hammer) {
stopHammer(chart);
}
removeState(chart);
},
panFunctions,
zoomFunctions,
zoomRectFunctions,
};
export { plugin as default, pan, resetZoom, zoom, zoomRect, zoomScale };

View file

@ -0,0 +1,979 @@
/*!
* chartjs-plugin-zoom v2.2.0
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
* (c) 2016-2024 chartjs-plugin-zoom Contributors
* Released under the MIT License
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('chart.js'), require('hammerjs'), require('chart.js/helpers')) :
typeof define === 'function' && define.amd ? define(['chart.js', 'hammerjs', 'chart.js/helpers'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ChartZoom = factory(global.Chart, global.Hammer, global.Chart.helpers));
})(this, (function (chart_js, Hammer, helpers) { 'use strict';
const getModifierKey = opts => opts && opts.enabled && opts.modifierKey;
const keyPressed = (key, event) => key && event[key + 'Key'];
const keyNotPressed = (key, event) => key && !event[key + 'Key'];
function directionEnabled(mode, dir, chart) {
if (mode === undefined) {
return true;
} else if (typeof mode === 'string') {
return mode.indexOf(dir) !== -1;
} else if (typeof mode === 'function') {
return mode({chart}).indexOf(dir) !== -1;
}
return false;
}
function directionsEnabled(mode, chart) {
if (typeof mode === 'function') {
mode = mode({chart});
}
if (typeof mode === 'string') {
return {x: mode.indexOf('x') !== -1, y: mode.indexOf('y') !== -1};
}
return {x: false, y: false};
}
function debounce(fn, delay) {
let timeout;
return function() {
clearTimeout(timeout);
timeout = setTimeout(fn, delay);
return delay;
};
}
function getScaleUnderPoint({x, y}, chart) {
const scales = chart.scales;
const scaleIds = Object.keys(scales);
for (let i = 0; i < scaleIds.length; i++) {
const scale = scales[scaleIds[i]];
if (y >= scale.top && y <= scale.bottom && x >= scale.left && x <= scale.right) {
return scale;
}
}
return null;
}
function getEnabledScalesByPoint(options, point, chart) {
const {mode = 'xy', scaleMode, overScaleMode} = options || {};
const scale = getScaleUnderPoint(point, chart);
const enabled = directionsEnabled(mode, chart);
const scaleEnabled = directionsEnabled(scaleMode, chart);
if (overScaleMode) {
const overScaleEnabled = directionsEnabled(overScaleMode, chart);
for (const axis of ['x', 'y']) {
if (overScaleEnabled[axis]) {
scaleEnabled[axis] = enabled[axis];
enabled[axis] = false;
}
}
}
if (scale && scaleEnabled[scale.axis]) {
return [scale];
}
const enabledScales = [];
helpers.each(chart.scales, function(scaleItem) {
if (enabled[scaleItem.axis]) {
enabledScales.push(scaleItem);
}
});
return enabledScales;
}
const chartStates = new WeakMap();
function getState(chart) {
let state = chartStates.get(chart);
if (!state) {
state = {
originalScaleLimits: {},
updatedScaleLimits: {},
handlers: {},
panDelta: {},
dragging: false,
panning: false
};
chartStates.set(chart, state);
}
return state;
}
function removeState(chart) {
chartStates.delete(chart);
}
function zoomDelta(val, min, range, newRange) {
const minPercent = Math.max(0, Math.min(1, (val - min) / range || 0));
const maxPercent = 1 - minPercent;
return {
min: newRange * minPercent,
max: newRange * maxPercent
};
}
function getValueAtPoint(scale, point) {
const pixel = scale.isHorizontal() ? point.x : point.y;
return scale.getValueForPixel(pixel);
}
function linearZoomDelta(scale, zoom, center) {
const range = scale.max - scale.min;
const newRange = range * (zoom - 1);
const centerValue = getValueAtPoint(scale, center);
return zoomDelta(centerValue, scale.min, range, newRange);
}
function logarithmicZoomRange(scale, zoom, center) {
const centerValue = getValueAtPoint(scale, center);
if (centerValue === undefined) {
return {min: scale.min, max: scale.max};
}
const logMin = Math.log10(scale.min);
const logMax = Math.log10(scale.max);
const logCenter = Math.log10(centerValue);
const logRange = logMax - logMin;
const newLogRange = logRange * (zoom - 1);
const delta = zoomDelta(logCenter, logMin, logRange, newLogRange);
return {
min: Math.pow(10, logMin + delta.min),
max: Math.pow(10, logMax - delta.max),
};
}
function getScaleLimits(scale, limits) {
return limits && (limits[scale.id] || limits[scale.axis]) || {};
}
function getLimit(state, scale, scaleLimits, prop, fallback) {
let limit = scaleLimits[prop];
if (limit === 'original') {
const original = state.originalScaleLimits[scale.id][prop];
limit = helpers.valueOrDefault(original.options, original.scale);
}
return helpers.valueOrDefault(limit, fallback);
}
function linearRange(scale, pixel0, pixel1) {
const v0 = scale.getValueForPixel(pixel0);
const v1 = scale.getValueForPixel(pixel1);
return {
min: Math.min(v0, v1),
max: Math.max(v0, v1)
};
}
function fixRange(range, {min, max, minLimit, maxLimit}, originalLimits) {
const offset = (range - max + min) / 2;
min -= offset;
max += offset;
const origMin = originalLimits.min.options ?? originalLimits.min.scale;
const origMax = originalLimits.max.options ?? originalLimits.max.scale;
const epsilon = range / 1e6;
if (helpers.almostEquals(min, origMin, epsilon)) {
min = origMin;
}
if (helpers.almostEquals(max, origMax, epsilon)) {
max = origMax;
}
if (min < minLimit) {
min = minLimit;
max = Math.min(minLimit + range, maxLimit);
} else if (max > maxLimit) {
max = maxLimit;
min = Math.max(maxLimit - range, minLimit);
}
return {min, max};
}
function updateRange(scale, {min, max}, limits, zoom = false) {
const state = getState(scale.chart);
const {options: scaleOpts} = scale;
const scaleLimits = getScaleLimits(scale, limits);
const {minRange = 0} = scaleLimits;
const minLimit = getLimit(state, scale, scaleLimits, 'min', -Infinity);
const maxLimit = getLimit(state, scale, scaleLimits, 'max', Infinity);
if (zoom === 'pan' && (min < minLimit || max > maxLimit)) {
return true;
}
const scaleRange = scale.max - scale.min;
const range = zoom ? Math.max(max - min, minRange) : scaleRange;
if (zoom && range === minRange && scaleRange <= minRange) {
return true;
}
const newRange = fixRange(range, {min, max, minLimit, maxLimit}, state.originalScaleLimits[scale.id]);
scaleOpts.min = newRange.min;
scaleOpts.max = newRange.max;
state.updatedScaleLimits[scale.id] = newRange;
return scale.parse(newRange.min) !== scale.min || scale.parse(newRange.max) !== scale.max;
}
function zoomNumericalScale(scale, zoom, center, limits) {
const delta = linearZoomDelta(scale, zoom, center);
const newRange = {min: scale.min + delta.min, max: scale.max - delta.max};
return updateRange(scale, newRange, limits, true);
}
function zoomLogarithmicScale(scale, zoom, center, limits) {
const newRange = logarithmicZoomRange(scale, zoom, center);
return updateRange(scale, newRange, limits, true);
}
function zoomRectNumericalScale(scale, from, to, limits) {
updateRange(scale, linearRange(scale, from, to), limits, true);
}
const integerChange = (v) => v === 0 || isNaN(v) ? 0 : v < 0 ? Math.min(Math.round(v), -1) : Math.max(Math.round(v), 1);
function existCategoryFromMaxZoom(scale) {
const labels = scale.getLabels();
const maxIndex = labels.length - 1;
if (scale.min > 0) {
scale.min -= 1;
}
if (scale.max < maxIndex) {
scale.max += 1;
}
}
function zoomCategoryScale(scale, zoom, center, limits) {
const delta = linearZoomDelta(scale, zoom, center);
if (scale.min === scale.max && zoom < 1) {
existCategoryFromMaxZoom(scale);
}
const newRange = {min: scale.min + integerChange(delta.min), max: scale.max - integerChange(delta.max)};
return updateRange(scale, newRange, limits, true);
}
function scaleLength(scale) {
return scale.isHorizontal() ? scale.width : scale.height;
}
function panCategoryScale(scale, delta, limits) {
const labels = scale.getLabels();
const lastLabelIndex = labels.length - 1;
let {min, max} = scale;
const range = Math.max(max - min, 1);
const stepDelta = Math.round(scaleLength(scale) / Math.max(range, 10));
const stepSize = Math.round(Math.abs(delta / stepDelta));
let applied;
if (delta < -stepDelta) {
max = Math.min(max + stepSize, lastLabelIndex);
min = range === 1 ? max : max - range;
applied = max === lastLabelIndex;
} else if (delta > stepDelta) {
min = Math.max(0, min - stepSize);
max = range === 1 ? min : min + range;
applied = min === 0;
}
return updateRange(scale, {min, max}, limits) || applied;
}
const OFFSETS = {
second: 500,
minute: 30 * 1000,
hour: 30 * 60 * 1000,
day: 12 * 60 * 60 * 1000,
week: 3.5 * 24 * 60 * 60 * 1000,
month: 15 * 24 * 60 * 60 * 1000,
quarter: 60 * 24 * 60 * 60 * 1000,
year: 182 * 24 * 60 * 60 * 1000
};
function panNumericalScale(scale, delta, limits, pan = false) {
const {min: prevStart, max: prevEnd, options} = scale;
const round = options.time && options.time.round;
const offset = OFFSETS[round] || 0;
const newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart + offset) - delta);
const newMax = scale.getValueForPixel(scale.getPixelForValue(prevEnd + offset) - delta);
if (isNaN(newMin) || isNaN(newMax)) {
return true;
}
return updateRange(scale, {min: newMin, max: newMax}, limits, pan ? 'pan' : false);
}
function panNonLinearScale(scale, delta, limits) {
return panNumericalScale(scale, delta, limits, true);
}
const zoomFunctions = {
category: zoomCategoryScale,
default: zoomNumericalScale,
logarithmic: zoomLogarithmicScale,
};
const zoomRectFunctions = {
default: zoomRectNumericalScale,
};
const panFunctions = {
category: panCategoryScale,
default: panNumericalScale,
logarithmic: panNonLinearScale,
timeseries: panNonLinearScale,
};
function shouldUpdateScaleLimits(scale, originalScaleLimits, updatedScaleLimits) {
const {id, options: {min, max}} = scale;
if (!originalScaleLimits[id] || !updatedScaleLimits[id]) {
return true;
}
const previous = updatedScaleLimits[id];
return previous.min !== min || previous.max !== max;
}
function removeMissingScales(limits, scales) {
helpers.each(limits, (opt, key) => {
if (!scales[key]) {
delete limits[key];
}
});
}
function storeOriginalScaleLimits(chart, state) {
const {scales} = chart;
const {originalScaleLimits, updatedScaleLimits} = state;
helpers.each(scales, function(scale) {
if (shouldUpdateScaleLimits(scale, originalScaleLimits, updatedScaleLimits)) {
originalScaleLimits[scale.id] = {
min: {scale: scale.min, options: scale.options.min},
max: {scale: scale.max, options: scale.options.max},
};
}
});
removeMissingScales(originalScaleLimits, scales);
removeMissingScales(updatedScaleLimits, scales);
return originalScaleLimits;
}
function doZoom(scale, amount, center, limits) {
const fn = zoomFunctions[scale.type] || zoomFunctions.default;
helpers.callback(fn, [scale, amount, center, limits]);
}
function doZoomRect(scale, from, to, limits) {
const fn = zoomRectFunctions[scale.type] || zoomRectFunctions.default;
helpers.callback(fn, [scale, from, to, limits]);
}
function getCenter(chart) {
const ca = chart.chartArea;
return {
x: (ca.left + ca.right) / 2,
y: (ca.top + ca.bottom) / 2,
};
}
function zoom(chart, amount, transition = 'none', trigger = 'api') {
const {x = 1, y = 1, focalPoint = getCenter(chart)} = typeof amount === 'number' ? {x: amount, y: amount} : amount;
const state = getState(chart);
const {options: {limits, zoom: zoomOptions}} = state;
storeOriginalScaleLimits(chart, state);
const xEnabled = x !== 1;
const yEnabled = y !== 1;
const enabledScales = getEnabledScalesByPoint(zoomOptions, focalPoint, chart);
helpers.each(enabledScales || chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
doZoom(scale, x, focalPoint, limits);
} else if (!scale.isHorizontal() && yEnabled) {
doZoom(scale, y, focalPoint, limits);
}
});
chart.update(transition);
helpers.callback(zoomOptions.onZoom, [{chart, trigger}]);
}
function zoomRect(chart, p0, p1, transition = 'none', trigger = 'api') {
const state = getState(chart);
const {options: {limits, zoom: zoomOptions}} = state;
const {mode = 'xy'} = zoomOptions;
storeOriginalScaleLimits(chart, state);
const xEnabled = directionEnabled(mode, 'x', chart);
const yEnabled = directionEnabled(mode, 'y', chart);
helpers.each(chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
doZoomRect(scale, p0.x, p1.x, limits);
} else if (!scale.isHorizontal() && yEnabled) {
doZoomRect(scale, p0.y, p1.y, limits);
}
});
chart.update(transition);
helpers.callback(zoomOptions.onZoom, [{chart, trigger}]);
}
function zoomScale(chart, scaleId, range, transition = 'none', trigger = 'api') {
const state = getState(chart);
storeOriginalScaleLimits(chart, state);
const scale = chart.scales[scaleId];
updateRange(scale, range, undefined, true);
chart.update(transition);
helpers.callback(state.options.zoom?.onZoom, [{chart, trigger}]);
}
function resetZoom(chart, transition = 'default') {
const state = getState(chart);
const originalScaleLimits = storeOriginalScaleLimits(chart, state);
helpers.each(chart.scales, function(scale) {
const scaleOptions = scale.options;
if (originalScaleLimits[scale.id]) {
scaleOptions.min = originalScaleLimits[scale.id].min.options;
scaleOptions.max = originalScaleLimits[scale.id].max.options;
} else {
delete scaleOptions.min;
delete scaleOptions.max;
}
delete state.updatedScaleLimits[scale.id];
});
chart.update(transition);
helpers.callback(state.options.zoom.onZoomComplete, [{chart}]);
}
function getOriginalRange(state, scaleId) {
const original = state.originalScaleLimits[scaleId];
if (!original) {
return;
}
const {min, max} = original;
return helpers.valueOrDefault(max.options, max.scale) - helpers.valueOrDefault(min.options, min.scale);
}
function getZoomLevel(chart) {
const state = getState(chart);
let min = 1;
let max = 1;
helpers.each(chart.scales, function(scale) {
const origRange = getOriginalRange(state, scale.id);
if (origRange) {
const level = Math.round(origRange / (scale.max - scale.min) * 100) / 100;
min = Math.min(min, level);
max = Math.max(max, level);
}
});
return min < 1 ? min : max;
}
function panScale(scale, delta, limits, state) {
const {panDelta} = state;
const storedDelta = panDelta[scale.id] || 0;
if (helpers.sign(storedDelta) === helpers.sign(delta)) {
delta += storedDelta;
}
const fn = panFunctions[scale.type] || panFunctions.default;
if (helpers.callback(fn, [scale, delta, limits])) {
panDelta[scale.id] = 0;
} else {
panDelta[scale.id] = delta;
}
}
function pan(chart, delta, enabledScales, transition = 'none') {
const {x = 0, y = 0} = typeof delta === 'number' ? {x: delta, y: delta} : delta;
const state = getState(chart);
const {options: {pan: panOptions, limits}} = state;
const {onPan} = panOptions || {};
storeOriginalScaleLimits(chart, state);
const xEnabled = x !== 0;
const yEnabled = y !== 0;
helpers.each(enabledScales || chart.scales, function(scale) {
if (scale.isHorizontal() && xEnabled) {
panScale(scale, x, limits, state);
} else if (!scale.isHorizontal() && yEnabled) {
panScale(scale, y, limits, state);
}
});
chart.update(transition);
helpers.callback(onPan, [{chart}]);
}
function getInitialScaleBounds(chart) {
const state = getState(chart);
storeOriginalScaleLimits(chart, state);
const scaleBounds = {};
for (const scaleId of Object.keys(chart.scales)) {
const {min, max} = state.originalScaleLimits[scaleId] || {min: {}, max: {}};
scaleBounds[scaleId] = {min: min.scale, max: max.scale};
}
return scaleBounds;
}
function getZoomedScaleBounds(chart) {
const state = getState(chart);
const scaleBounds = {};
for (const scaleId of Object.keys(chart.scales)) {
scaleBounds[scaleId] = state.updatedScaleLimits[scaleId];
}
return scaleBounds;
}
function isZoomedOrPanned(chart) {
const scaleBounds = getInitialScaleBounds(chart);
for (const scaleId of Object.keys(chart.scales)) {
const {min: originalMin, max: originalMax} = scaleBounds[scaleId];
if (originalMin !== undefined && chart.scales[scaleId].min !== originalMin) {
return true;
}
if (originalMax !== undefined && chart.scales[scaleId].max !== originalMax) {
return true;
}
}
return false;
}
function isZoomingOrPanning(chart) {
const state = getState(chart);
return state.panning || state.dragging;
}
const clamp = (x, from, to) => Math.min(to, Math.max(from, x));
function removeHandler(chart, type) {
const {handlers} = getState(chart);
const handler = handlers[type];
if (handler && handler.target) {
handler.target.removeEventListener(type, handler);
delete handlers[type];
}
}
function addHandler(chart, target, type, handler) {
const {handlers, options} = getState(chart);
const oldHandler = handlers[type];
if (oldHandler && oldHandler.target === target) {
return;
}
removeHandler(chart, type);
handlers[type] = (event) => handler(chart, event, options);
handlers[type].target = target;
const passive = type === 'wheel' ? false : undefined;
target.addEventListener(type, handlers[type], {passive});
}
function mouseMove(chart, event) {
const state = getState(chart);
if (state.dragStart) {
state.dragging = true;
state.dragEnd = event;
chart.update('none');
}
}
function keyDown(chart, event) {
const state = getState(chart);
if (!state.dragStart || event.key !== 'Escape') {
return;
}
removeHandler(chart, 'keydown');
state.dragging = false;
state.dragStart = state.dragEnd = null;
chart.update('none');
}
function getPointPosition(event, chart) {
if (event.target !== chart.canvas) {
const canvasArea = chart.canvas.getBoundingClientRect();
return {
x: event.clientX - canvasArea.left,
y: event.clientY - canvasArea.top,
};
}
return helpers.getRelativePosition(event, chart);
}
function zoomStart(chart, event, zoomOptions) {
const {onZoomStart, onZoomRejected} = zoomOptions;
if (onZoomStart) {
const point = getPointPosition(event, chart);
if (helpers.callback(onZoomStart, [{chart, event, point}]) === false) {
helpers.callback(onZoomRejected, [{chart, event}]);
return false;
}
}
}
function mouseDown(chart, event) {
if (chart.legend) {
const point = helpers.getRelativePosition(event, chart);
if (helpers._isPointInArea(point, chart.legend)) {
return;
}
}
const state = getState(chart);
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
if (
event.button !== 0 ||
keyPressed(getModifierKey(panOptions), event) ||
keyNotPressed(getModifierKey(zoomOptions.drag), event)
) {
return helpers.callback(zoomOptions.onZoomRejected, [{chart, event}]);
}
if (zoomStart(chart, event, zoomOptions) === false) {
return;
}
state.dragStart = event;
addHandler(chart, chart.canvas.ownerDocument, 'mousemove', mouseMove);
addHandler(chart, window.document, 'keydown', keyDown);
}
function applyAspectRatio({begin, end}, aspectRatio) {
let width = end.x - begin.x;
let height = end.y - begin.y;
const ratio = Math.abs(width / height);
if (ratio > aspectRatio) {
width = Math.sign(width) * Math.abs(height * aspectRatio);
} else if (ratio < aspectRatio) {
height = Math.sign(height) * Math.abs(width / aspectRatio);
}
end.x = begin.x + width;
end.y = begin.y + height;
}
function applyMinMaxProps(rect, chartArea, points, {min, max, prop}) {
rect[min] = clamp(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
rect[max] = clamp(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
}
function getRelativePoints(chart, pointEvents, maintainAspectRatio) {
const points = {
begin: getPointPosition(pointEvents.dragStart, chart),
end: getPointPosition(pointEvents.dragEnd, chart),
};
if (maintainAspectRatio) {
const aspectRatio = chart.chartArea.width / chart.chartArea.height;
applyAspectRatio(points, aspectRatio);
}
return points;
}
function computeDragRect(chart, mode, pointEvents, maintainAspectRatio) {
const xEnabled = directionEnabled(mode, 'x', chart);
const yEnabled = directionEnabled(mode, 'y', chart);
const {top, left, right, bottom, width: chartWidth, height: chartHeight} = chart.chartArea;
const rect = {top, left, right, bottom};
const points = getRelativePoints(chart, pointEvents, maintainAspectRatio && xEnabled && yEnabled);
if (xEnabled) {
applyMinMaxProps(rect, chart.chartArea, points, {min: 'left', max: 'right', prop: 'x'});
}
if (yEnabled) {
applyMinMaxProps(rect, chart.chartArea, points, {min: 'top', max: 'bottom', prop: 'y'});
}
const width = rect.right - rect.left;
const height = rect.bottom - rect.top;
return {
...rect,
width,
height,
zoomX: xEnabled && width ? 1 + ((chartWidth - width) / chartWidth) : 1,
zoomY: yEnabled && height ? 1 + ((chartHeight - height) / chartHeight) : 1
};
}
function mouseUp(chart, event) {
const state = getState(chart);
if (!state.dragStart) {
return;
}
removeHandler(chart, 'mousemove');
const {mode, onZoomComplete, drag: {threshold = 0, maintainAspectRatio}} = state.options.zoom;
const rect = computeDragRect(chart, mode, {dragStart: state.dragStart, dragEnd: event}, maintainAspectRatio);
const distanceX = directionEnabled(mode, 'x', chart) ? rect.width : 0;
const distanceY = directionEnabled(mode, 'y', chart) ? rect.height : 0;
const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
state.dragStart = state.dragEnd = null;
if (distance <= threshold) {
state.dragging = false;
chart.update('none');
return;
}
zoomRect(chart, {x: rect.left, y: rect.top}, {x: rect.right, y: rect.bottom}, 'zoom', 'drag');
state.dragging = false;
state.filterNextClick = true;
helpers.callback(onZoomComplete, [{chart}]);
}
function wheelPreconditions(chart, event, zoomOptions) {
if (keyNotPressed(getModifierKey(zoomOptions.wheel), event)) {
helpers.callback(zoomOptions.onZoomRejected, [{chart, event}]);
return;
}
if (zoomStart(chart, event, zoomOptions) === false) {
return;
}
if (event.cancelable) {
event.preventDefault();
}
if (event.deltaY === undefined) {
return;
}
return true;
}
function wheel(chart, event) {
const {handlers: {onZoomComplete}, options: {zoom: zoomOptions}} = getState(chart);
if (!wheelPreconditions(chart, event, zoomOptions)) {
return;
}
const rect = event.target.getBoundingClientRect();
const speed = zoomOptions.wheel.speed;
const percentage = event.deltaY >= 0 ? 2 - 1 / (1 - speed) : 1 + speed;
const amount = {
x: percentage,
y: percentage,
focalPoint: {
x: event.clientX - rect.left,
y: event.clientY - rect.top
}
};
zoom(chart, amount, 'zoom', 'wheel');
helpers.callback(onZoomComplete, [{chart}]);
}
function addDebouncedHandler(chart, name, handler, delay) {
if (handler) {
getState(chart).handlers[name] = debounce(() => helpers.callback(handler, [{chart}]), delay);
}
}
function addListeners(chart, options) {
const canvas = chart.canvas;
const {wheel: wheelOptions, drag: dragOptions, onZoomComplete} = options.zoom;
if (wheelOptions.enabled) {
addHandler(chart, canvas, 'wheel', wheel);
addDebouncedHandler(chart, 'onZoomComplete', onZoomComplete, 250);
} else {
removeHandler(chart, 'wheel');
}
if (dragOptions.enabled) {
addHandler(chart, canvas, 'mousedown', mouseDown);
addHandler(chart, canvas.ownerDocument, 'mouseup', mouseUp);
} else {
removeHandler(chart, 'mousedown');
removeHandler(chart, 'mousemove');
removeHandler(chart, 'mouseup');
removeHandler(chart, 'keydown');
}
}
function removeListeners(chart) {
removeHandler(chart, 'mousedown');
removeHandler(chart, 'mousemove');
removeHandler(chart, 'mouseup');
removeHandler(chart, 'wheel');
removeHandler(chart, 'click');
removeHandler(chart, 'keydown');
}
function createEnabler(chart, state) {
return function(recognizer, event) {
const {pan: panOptions, zoom: zoomOptions = {}} = state.options;
if (!panOptions || !panOptions.enabled) {
return false;
}
const srcEvent = event && event.srcEvent;
if (!srcEvent) {
return true;
}
if (!state.panning && event.pointerType === 'mouse' && (
keyNotPressed(getModifierKey(panOptions), srcEvent) || keyPressed(getModifierKey(zoomOptions.drag), srcEvent))
) {
helpers.callback(panOptions.onPanRejected, [{chart, event}]);
return false;
}
return true;
};
}
function pinchAxes(p0, p1) {
const pinchX = Math.abs(p0.clientX - p1.clientX);
const pinchY = Math.abs(p0.clientY - p1.clientY);
const p = pinchX / pinchY;
let x, y;
if (p > 0.3 && p < 1.7) {
x = y = true;
} else if (pinchX > pinchY) {
x = true;
} else {
y = true;
}
return {x, y};
}
function handlePinch(chart, state, e) {
if (state.scale) {
const {center, pointers} = e;
const zoomPercent = 1 / state.scale * e.scale;
const rect = e.target.getBoundingClientRect();
const pinch = pinchAxes(pointers[0], pointers[1]);
const mode = state.options.zoom.mode;
const amount = {
x: pinch.x && directionEnabled(mode, 'x', chart) ? zoomPercent : 1,
y: pinch.y && directionEnabled(mode, 'y', chart) ? zoomPercent : 1,
focalPoint: {
x: center.x - rect.left,
y: center.y - rect.top
}
};
zoom(chart, amount, 'zoom', 'pinch');
state.scale = e.scale;
}
}
function startPinch(chart, state, event) {
if (state.options.zoom.pinch.enabled) {
const point = helpers.getRelativePosition(event, chart);
if (helpers.callback(state.options.zoom.onZoomStart, [{chart, event, point}]) === false) {
state.scale = null;
helpers.callback(state.options.zoom.onZoomRejected, [{chart, event}]);
} else {
state.scale = 1;
}
}
}
function endPinch(chart, state, e) {
if (state.scale) {
handlePinch(chart, state, e);
state.scale = null;
helpers.callback(state.options.zoom.onZoomComplete, [{chart}]);
}
}
function handlePan(chart, state, e) {
const delta = state.delta;
if (delta) {
state.panning = true;
pan(chart, {x: e.deltaX - delta.x, y: e.deltaY - delta.y}, state.panScales);
state.delta = {x: e.deltaX, y: e.deltaY};
}
}
function startPan(chart, state, event) {
const {enabled, onPanStart, onPanRejected} = state.options.pan;
if (!enabled) {
return;
}
const rect = event.target.getBoundingClientRect();
const point = {
x: event.center.x - rect.left,
y: event.center.y - rect.top
};
if (helpers.callback(onPanStart, [{chart, event, point}]) === false) {
return helpers.callback(onPanRejected, [{chart, event}]);
}
state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart);
state.delta = {x: 0, y: 0};
handlePan(chart, state, event);
}
function endPan(chart, state) {
state.delta = null;
if (state.panning) {
state.panning = false;
state.filterNextClick = true;
helpers.callback(state.options.pan.onPanComplete, [{chart}]);
}
}
const hammers = new WeakMap();
function startHammer(chart, options) {
const state = getState(chart);
const canvas = chart.canvas;
const {pan: panOptions, zoom: zoomOptions} = options;
const mc = new Hammer.Manager(canvas);
if (zoomOptions && zoomOptions.pinch.enabled) {
mc.add(new Hammer.Pinch());
mc.on('pinchstart', (e) => startPinch(chart, state, e));
mc.on('pinch', (e) => handlePinch(chart, state, e));
mc.on('pinchend', (e) => endPinch(chart, state, e));
}
if (panOptions && panOptions.enabled) {
mc.add(new Hammer.Pan({
threshold: panOptions.threshold,
enable: createEnabler(chart, state)
}));
mc.on('panstart', (e) => startPan(chart, state, e));
mc.on('panmove', (e) => handlePan(chart, state, e));
mc.on('panend', () => endPan(chart, state));
}
hammers.set(chart, mc);
}
function stopHammer(chart) {
const mc = hammers.get(chart);
if (mc) {
mc.remove('pinchstart');
mc.remove('pinch');
mc.remove('pinchend');
mc.remove('panstart');
mc.remove('pan');
mc.remove('panend');
mc.destroy();
hammers.delete(chart);
}
}
function hammerOptionsChanged(oldOptions, newOptions) {
const {pan: oldPan, zoom: oldZoom} = oldOptions;
const {pan: newPan, zoom: newZoom} = newOptions;
if (oldZoom?.zoom?.pinch?.enabled !== newZoom?.zoom?.pinch?.enabled) {
return true;
}
if (oldPan?.enabled !== newPan?.enabled) {
return true;
}
if (oldPan?.threshold !== newPan?.threshold) {
return true;
}
return false;
}
var version = "2.2.0";
function draw(chart, caller, options) {
const dragOptions = options.zoom.drag;
const {dragStart, dragEnd} = getState(chart);
if (dragOptions.drawTime !== caller || !dragEnd) {
return;
}
const {left, top, width, height} = computeDragRect(chart, options.zoom.mode, {dragStart, dragEnd}, dragOptions.maintainAspectRatio);
const ctx = chart.ctx;
ctx.save();
ctx.beginPath();
ctx.fillStyle = dragOptions.backgroundColor || 'rgba(225,225,225,0.3)';
ctx.fillRect(left, top, width, height);
if (dragOptions.borderWidth > 0) {
ctx.lineWidth = dragOptions.borderWidth;
ctx.strokeStyle = dragOptions.borderColor || 'rgba(225,225,225)';
ctx.strokeRect(left, top, width, height);
}
ctx.restore();
}
var Zoom = {
id: 'zoom',
version,
defaults: {
pan: {
enabled: false,
mode: 'xy',
threshold: 10,
modifierKey: null,
},
zoom: {
wheel: {
enabled: false,
speed: 0.1,
modifierKey: null
},
drag: {
enabled: false,
drawTime: 'beforeDatasetsDraw',
modifierKey: null
},
pinch: {
enabled: false
},
mode: 'xy',
}
},
start: function(chart, _args, options) {
const state = getState(chart);
state.options = options;
if (Object.prototype.hasOwnProperty.call(options.zoom, 'enabled')) {
console.warn('The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`.');
}
if (Object.prototype.hasOwnProperty.call(options.zoom, 'overScaleMode')
|| Object.prototype.hasOwnProperty.call(options.pan, 'overScaleMode')) {
console.warn('The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired).');
}
if (Hammer) {
startHammer(chart, options);
}
chart.pan = (delta, panScales, transition) => pan(chart, delta, panScales, transition);
chart.zoom = (args, transition) => zoom(chart, args, transition);
chart.zoomRect = (p0, p1, transition) => zoomRect(chart, p0, p1, transition);
chart.zoomScale = (id, range, transition) => zoomScale(chart, id, range, transition);
chart.resetZoom = (transition) => resetZoom(chart, transition);
chart.getZoomLevel = () => getZoomLevel(chart);
chart.getInitialScaleBounds = () => getInitialScaleBounds(chart);
chart.getZoomedScaleBounds = () => getZoomedScaleBounds(chart);
chart.isZoomedOrPanned = () => isZoomedOrPanned(chart);
chart.isZoomingOrPanning = () => isZoomingOrPanning(chart);
},
beforeEvent(chart, {event}) {
if (isZoomingOrPanning(chart)) {
return false;
}
if (event.type === 'click' || event.type === 'mouseup') {
const state = getState(chart);
if (state.filterNextClick) {
state.filterNextClick = false;
return false;
}
}
},
beforeUpdate: function(chart, args, options) {
const state = getState(chart);
const previousOptions = state.options;
state.options = options;
if (hammerOptionsChanged(previousOptions, options)) {
stopHammer(chart);
startHammer(chart, options);
}
addListeners(chart, options);
},
beforeDatasetsDraw(chart, _args, options) {
draw(chart, 'beforeDatasetsDraw', options);
},
afterDatasetsDraw(chart, _args, options) {
draw(chart, 'afterDatasetsDraw', options);
},
beforeDraw(chart, _args, options) {
draw(chart, 'beforeDraw', options);
},
afterDraw(chart, _args, options) {
draw(chart, 'afterDraw', options);
},
stop: function(chart) {
removeListeners(chart);
if (Hammer) {
stopHammer(chart);
}
removeState(chart);
},
panFunctions,
zoomFunctions,
zoomRectFunctions,
};
chart_js.Chart.register(Zoom);
return Zoom;
}));

File diff suppressed because one or more lines are too long

90
node_modules/chartjs-plugin-zoom/package.json generated vendored Normal file
View file

@ -0,0 +1,90 @@
{
"name": "chartjs-plugin-zoom",
"homepage": "https://www.chartjs.org/chartjs-plugin-zoom/",
"description": "Plugin that enables zoom and pan functionality in Chart.js charts.",
"version": "2.2.0",
"license": "MIT",
"jsdelivr": "dist/chartjs-plugin-zoom.min.js",
"unpkg": "dist/chartjs-plugin-zoom.min.js",
"main": "dist/chartjs-plugin-zoom.js",
"module": "dist/chartjs-plugin-zoom.esm.js",
"types": "types/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/chartjs/chartjs-plugin-zoom.git"
},
"scripts": {
"autobuild": "rollup -c -w",
"build": "rollup -c",
"dev": "karma start --auto-watch --no-single-run --browsers chrome",
"dev:ff": "karma start --auto-watch --no-single-run --browsers firefox",
"docs": "npm run build && vuepress build docs --no-cache",
"docs:dev": "concurrently \"npm run autobuild\" \"vuepress dev docs --no-cache\"",
"lint-js": "eslint \"samples/**/*.html\" \"test/**/*.js\" \"src/**/*.js\"",
"lint-md": "eslint \"**/*.md\"",
"lint-tsc": "tsc",
"lint-types": "eslint \"types/**/*.ts\" && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"",
"test": "cross-env NODE_ENV=test concurrently \"npm:test-*\"",
"test-karma": "karma start --auto-watch --single-run --coverage",
"test-types": "tsc -p types/tests/"
},
"files": [
"dist/*.js",
"types/*.d.ts"
],
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@simonbrunel/vuepress-plugin-versions": "^0.2.0",
"@types/linkify-it": "^3.0.5",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"babel-loader": "^8.3.0",
"chart.js": "^4.3.2",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-test-utils": "^0.5.0",
"concurrently": "^9.1.0",
"coveralls": "^3.1.0",
"cross-env": "^7.0.3",
"date-fns": "^2.21.1",
"eslint": "^8.2.0",
"eslint-config-chartjs": "^0.3.0",
"eslint-plugin-html": "^8.1.2",
"eslint-plugin-markdown": "^2.0.1",
"hammer-simulator": "^0.0.1",
"jasmine": "^5.4.0",
"karma": "^6.4.4",
"karma-chrome-launcher": "^3.2.0",
"karma-coverage": "^2.2.1",
"karma-firefox-launcher": "^2.1.3",
"karma-jasmine": "^5.1.0",
"karma-jasmine-html-reporter": "^2.1.0",
"karma-rollup-preprocessor": "7.0.7",
"karma-spec-reporter": "0.0.36",
"ng-hammerjs": "^2.0.8",
"pixelmatch": "^6.0.0",
"rollup": "^4.12.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-istanbul": "^5.0.0",
"typedoc": "^0.26.11",
"typedoc-plugin-markdown": "^4.2.10",
"typescript": "^5.6.3",
"vuepress": "^1.8.2",
"vuepress-plugin-flexsearch": "^0.3.0",
"vuepress-plugin-redirect": "^1.2.5",
"vuepress-plugin-typedoc": "^0.9.2",
"vuepress-theme-chartjs": "^0.2.0"
},
"peerDependencies": {
"chart.js": ">=3.2.0"
},
"dependencies": {
"@types/hammerjs": "^2.0.45",
"hammerjs": "^2.0.8"
}
}

63
node_modules/chartjs-plugin-zoom/types/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,63 @@
import { Plugin, ChartType, Chart, Scale, UpdateMode, ScaleTypeRegistry, ChartTypeRegistry } from 'chart.js';
import { LimitOptions, ZoomPluginOptions } from './options';
type Point = { x: number, y: number };
type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never
export type PanAmount = number | Partial<Point>;
export type ScaleRange = { min: number, max: number };
export type ZoomAmount = number | Partial<Point> & { focalPoint?: Point };
declare module 'chart.js' {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface PluginOptionsByType<TType extends ChartType> {
zoom: ZoomPluginOptions;
}
enum UpdateModeEnum {
zoom = 'zoom'
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chart<TType extends keyof ChartTypeRegistry = keyof ChartTypeRegistry, TData = DistributiveArray<ChartTypeRegistry[TType]['defaultDataPoint']>, TLabel = unknown> {
pan(pan: PanAmount, scales?: Scale[], mode?: UpdateMode): void;
zoom(zoom: ZoomAmount, mode?: UpdateMode): void;
zoomRect(p0: Point, p1: Point, mode?: UpdateMode): void;
zoomScale(id: string, range: ScaleRange, mode?: UpdateMode): void;
resetZoom(mode?: UpdateMode): void;
getZoomLevel(): number;
getInitialScaleBounds(): Record<string, {min: number | undefined, max: number | undefined}>;
getZoomedScaleBounds(): Record<string, ScaleRange | undefined>;
isZoomedOrPanned(): boolean;
isZoomingOrPanning(): boolean;
}
}
export type ZoomFunction = (scale: Scale, zoom: number, center: Point, limits: LimitOptions) => boolean;
export type ZoomRectFunction = (scale: Scale, from: number, to: number, limits: LimitOptions) => boolean;
export type PanFunction = (scale: Scale, delta: number, limits: LimitOptions) => boolean;
type ScaleFunctions<T> = {
[scaleType in keyof ScaleTypeRegistry]?: T | undefined;
} & {
default: T;
};
declare const Zoom: Plugin & {
zoomFunctions: ScaleFunctions<ZoomFunction>;
zoomRectFunctions: ScaleFunctions<ZoomRectFunction>;
panFunctions: ScaleFunctions<PanFunction>;
};
export default Zoom;
export function pan(chart: Chart, amount: PanAmount, scales?: Scale[], mode?: UpdateMode): void;
export function zoom(chart: Chart, amount: ZoomAmount, mode?: UpdateMode): void;
export function zoomRect(chart: Chart, p0: Point, p1: Point, mode?: UpdateMode): void;
export function zoomScale(chart: Chart, scaleId: string, range: ScaleRange, mode?: UpdateMode): void;
export function resetZoom(chart: Chart, mode?: UpdateMode): void;
export function getZoomLevel(chart: Chart): number;
export function getInitialScaleBounds(chart: Chart): Record<string, {min: number | undefined, max: number | undefined}>;
export function getZoomedScaleBounds(chart: Chart): Record<string, ScaleRange | undefined>;
export function isZoomedOrPanned(chart: Chart): boolean;
export function isZoomingOrPanning(chart: Chart): boolean;

196
node_modules/chartjs-plugin-zoom/types/options.d.ts generated vendored Normal file
View file

@ -0,0 +1,196 @@
import { Chart, Color, Point } from 'chart.js';
import { Input as HammerInput } from 'hammerjs';
export type Mode = 'x' | 'y' | 'xy';
export type ModifierKey = 'ctrl' | 'alt' | 'shift' | 'meta';
export type DrawTime = 'afterDraw' | 'afterDatasetsDraw' | 'beforeDraw' | 'beforeDatasetsDraw';
export type ZoomTrigger = 'api' | 'drag' | 'wheel' | 'pinch'
export interface WheelOptions {
/**
* Enable the zoom via mouse wheel
*/
enabled?: boolean;
/**
* Speed of zoom via mouse wheel
* (percentage of zoom on a wheel event)
*/
speed?: number;
/**
* Modifier key required for zooming with mouse
*/
modifierKey?: ModifierKey;
}
export interface DragOptions {
/**
* Enable the zoom via drag
*/
enabled?: boolean;
/**
* Minimal zoom distance required before actually applying zoom
*/
threshold?: number;
/**
* Border color of the drag area
*/
borderColor?: Color;
/**
* Border width of the drag area
*/
borderWidth?: number;
/**
* Background color of the drag area
*/
backgroundColor?: Color;
/**
* Modifier key required for drag-to-zoom
*/
modifierKey?: ModifierKey;
/**
* Draw time required for drag-to-zoom
*/
drawTime?: DrawTime;
/**
* Maintain aspect ratio of the drag rectangle
*/
maintainAspectRatio?: boolean;
}
export interface PinchOptions {
/**
* Enable the zoom via pinch
*/
enabled?: boolean;
}
/**
* Container for zoom options
*/
export interface ZoomOptions {
/**
* Zooming directions. Remove the appropriate direction to disable
* E.g. 'y' would only allow zooming in the y direction
* A function that is called as the user is zooming and returns the
* available directions can also be used:
* mode: function({ chart }) {
* return 'xy';
* },
*/
mode?: Mode | { (chart: Chart): Mode };
/**
* Options of the mouse wheel mode
*/
wheel?: WheelOptions;
/**
* Options of the drag-to-zoom mode
*/
drag?: DragOptions;
/**
* Options of the pinch mode
*/
pinch?: PinchOptions;
scaleMode?: Mode | { (chart: Chart): Mode };
/** @deprecated Use scaleMode instead */
overScaleMode?: Mode | { (chart: Chart): Mode };
/**
* Function called while the user is zooming
*/
onZoom?: (context: { chart: Chart, trigger: ZoomTrigger }) => void;
/**
* Function called once zooming is completed
*/
onZoomComplete?: (context: { chart: Chart }) => void;
/**
* Function called when wheel input occurs without modifier key
*/
onZoomRejected?: (context: { chart: Chart, event: Event }) => void;
onZoomStart?: (context: { chart: Chart, event: Event, point: Point }) => boolean | undefined;
}
/**
* Container for pan options
*/
export interface PanOptions {
/**
* Boolean to enable panning
*/
enabled?: boolean;
/**
* Panning directions. Remove the appropriate direction to disable
* E.g. 'y' would only allow panning in the y direction
* A function that is called as the user is panning and returns the
* available directions can also be used:
* mode: function({ chart }) {
* return 'xy';
* },
*/
mode?: Mode | { (chart: Chart): Mode };
/**
* Modifier key required for panning with mouse
*/
modifierKey?: ModifierKey;
scaleMode?: Mode | { (chart: Chart): Mode };
/** @deprecated Use scaleMode instead */
overScaleMode?: Mode | { (chart: Chart): Mode };
/**
* Minimal pan distance required before actually applying pan
*/
threshold?: number;
/**
* Function called while the user is panning
*/
onPan?: (context: { chart: Chart }) => void;
/**
* Function called once panning is completed
*/
onPanComplete?: (context: { chart: Chart }) => void;
/**
* Function called when pan fails because modifier key was not detected.
* event is the Hammer event that failed - see https://hammerjs.github.io/api#event-object
*/
onPanRejected?: (context: { chart: Chart, event: HammerInput }) => void;
onPanStart?: (context: { chart: Chart, event: HammerInput, point: Point }) => boolean | undefined;
}
export interface ScaleLimits {
min?: number | 'original';
max?: number | 'original';
minRange?: number;
}
export interface LimitOptions {
// Scale limits, indexed by the scale's ID (key) or by axis (x/y)
[axisId: string]: ScaleLimits;
}
export interface ZoomPluginOptions {
pan?: PanOptions;
limits?: LimitOptions;
zoom?: ZoomOptions;
}

2844
node_modules/date-fns/CHANGELOG.md generated vendored Normal file

File diff suppressed because it is too large Load diff

21
node_modules/date-fns/LICENSE.md generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org
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.

58
node_modules/date-fns/README.md generated vendored Normal file
View file

@ -0,0 +1,58 @@
🔥️ **NEW**: [date-fns v4.0 with first-class time zone support is out!](https://blog.date-fns.org/v40-with-time-zone-support/)
<img alt="date-fns" title="date-fns" src="https://raw.githubusercontent.com/date-fns/date-fns/master/docs/logotype.svg" width="150" />
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js
👉 [Documentation](https://date-fns.org/)
👉 [Blog](https://blog.date-fns.org/)
<hr>
It's like [Lodash](https://lodash.com) for dates
- It has [**200+ functions** for all occasions](https://date-fns.org/docs/Getting-Started/).
- **Modular**: Pick what you need. Works with webpack, Browserify, or Rollup and also supports tree-shaking.
- **Native dates**: Uses existing native type. It doesn't extend core objects for safety's sake.
- **Immutable & Pure**: Built using pure functions and always returns a new date instance.
- **TypeScript**: The library is 100% TypeScript with brand-new handcrafted types.
- **I18n**: Dozens of locales. Include only what you need.
- [and many more benefits](https://date-fns.org/)
```js
import { compareAsc, format } from "date-fns";
format(new Date(2014, 1, 11), "yyyy-MM-dd");
//=> '2014-02-11'
const dates = [
new Date(1995, 6, 2),
new Date(1987, 1, 11),
new Date(1989, 6, 10),
];
dates.sort(compareAsc);
//=> [
// Wed Feb 11 1987 00:00:00,
// Mon Jul 10 1989 00:00:00,
// Sun Jul 02 1995 00:00:00
// ]
```
The library is available as an [npm package](https://www.npmjs.com/package/date-fns).
To install the package run:
```bash
npm install date-fns --save
```
## Docs
[See date-fns.org](https://date-fns.org/) for more details, API,
and other docs.
<br />
## License
[MIT © Sasha Koss](https://kossnocorp.mit-license.org/)

12
node_modules/date-fns/SECURITY.md generated vendored Normal file
View file

@ -0,0 +1,12 @@
# Security Policy
## Supported Versions
Security updates are applied only to the latest release.
## Reporting a Vulnerability
If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.**
This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released.
Please disclose it to [Sasha Koss](mailto:koss@nocorp.me). This project is maintained by a team of volunteers
on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure.

7
node_modules/date-fns/_lib/addLeadingZeros.cjs generated vendored Normal file
View file

@ -0,0 +1,7 @@
"use strict";
exports.addLeadingZeros = addLeadingZeros;
function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? "-" : "";
const output = Math.abs(number).toString().padStart(targetLength, "0");
return sign + output;
}

4
node_modules/date-fns/_lib/addLeadingZeros.d.cts generated vendored Normal file
View file

@ -0,0 +1,4 @@
export declare function addLeadingZeros(
number: number,
targetLength: number,
): string;

4
node_modules/date-fns/_lib/addLeadingZeros.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
export declare function addLeadingZeros(
number: number,
targetLength: number,
): string;

5
node_modules/date-fns/_lib/addLeadingZeros.js generated vendored Normal file
View file

@ -0,0 +1,5 @@
export function addLeadingZeros(number, targetLength) {
const sign = number < 0 ? "-" : "";
const output = Math.abs(number).toString().padStart(targetLength, "0");
return sign + output;
}

8
node_modules/date-fns/_lib/defaultLocale.cjs generated vendored Normal file
View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "defaultLocale", {
enumerable: true,
get: function () {
return _index.enUS;
},
});
var _index = require("../locale/en-US.cjs");

1
node_modules/date-fns/_lib/defaultLocale.d.cts generated vendored Normal file
View file

@ -0,0 +1 @@
export { enUS as defaultLocale } from "../locale/en-US.js";

1
node_modules/date-fns/_lib/defaultLocale.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export { enUS as defaultLocale } from "../locale/en-US.js";

1
node_modules/date-fns/_lib/defaultLocale.js generated vendored Normal file
View file

@ -0,0 +1 @@
export { enUS as defaultLocale } from "../locale/en-US.js";

13
node_modules/date-fns/_lib/defaultOptions.cjs generated vendored Normal file
View file

@ -0,0 +1,13 @@
"use strict";
exports.getDefaultOptions = getDefaultOptions;
exports.setDefaultOptions = setDefaultOptions;
let defaultOptions = {};
function getDefaultOptions() {
return defaultOptions;
}
function setDefaultOptions(newOptions) {
defaultOptions = newOptions;
}

11
node_modules/date-fns/_lib/defaultOptions.d.cts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import type {
FirstWeekContainsDateOptions,
Locale,
LocalizedOptions,
WeekOptions,
} from "../types.js";
export type DefaultOptions = LocalizedOptions<keyof Locale> &
WeekOptions &
FirstWeekContainsDateOptions;
export declare function getDefaultOptions(): DefaultOptions;
export declare function setDefaultOptions(newOptions: DefaultOptions): void;

11
node_modules/date-fns/_lib/defaultOptions.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
import type {
FirstWeekContainsDateOptions,
Locale,
LocalizedOptions,
WeekOptions,
} from "../types.js";
export type DefaultOptions = LocalizedOptions<keyof Locale> &
WeekOptions &
FirstWeekContainsDateOptions;
export declare function getDefaultOptions(): DefaultOptions;
export declare function setDefaultOptions(newOptions: DefaultOptions): void;

9
node_modules/date-fns/_lib/defaultOptions.js generated vendored Normal file
View file

@ -0,0 +1,9 @@
let defaultOptions = {};
export function getDefaultOptions() {
return defaultOptions;
}
export function setDefaultOptions(newOptions) {
defaultOptions = newOptions;
}

780
node_modules/date-fns/_lib/format/formatters.cjs generated vendored Normal file
View file

@ -0,0 +1,780 @@
"use strict";
exports.formatters = void 0;
var _index = require("../../getDayOfYear.cjs");
var _index2 = require("../../getISOWeek.cjs");
var _index3 = require("../../getISOWeekYear.cjs");
var _index4 = require("../../getWeek.cjs");
var _index5 = require("../../getWeekYear.cjs");
var _index6 = require("../addLeadingZeros.cjs");
var _index7 = require("./lightFormatters.cjs");
const dayPeriodEnum = {
am: "am",
pm: "pm",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night",
};
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | Milliseconds in day |
* | b | AM, PM, noon, midnight | B | Flexible day period |
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
* | d | Day of month | D | Day of year |
* | e | Local day of week | E | Day of week |
* | f | | F* | Day of week in month |
* | g* | Modified Julian day | G | Era |
* | h | Hour [1-12] | H | Hour [0-23] |
* | i! | ISO day of week | I! | ISO week of year |
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
* | k | Hour [1-24] | K | Hour [0-11] |
* | l* | (deprecated) | L | Stand-alone month |
* | m | Minute | M | Month |
* | n | | N | |
* | o! | Ordinal number modifier | O | Timezone (GMT) |
* | p! | Long localized time | P! | Long localized date |
* | q | Stand-alone quarter | Q | Quarter |
* | r* | Related Gregorian year | R! | ISO week-numbering year |
* | s | Second | S | Fraction of second |
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
* | u | Extended year | U* | Cyclic year |
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
* | w | Local week of year | W* | Week of month |
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
* | y | Year (abs) | Y | Local week-numbering year |
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*
* Letters marked by ! are non-standard, but implemented by date-fns:
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
* i.e. 7 for Sunday, 1 for Monday, etc.
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
* `R` is supposed to be used in conjunction with `I` and `i`
* for universal ISO week-numbering date, whereas
* `Y` is supposed to be used in conjunction with `w` and `e`
* for week-numbering date specific to the locale.
* - `P` is long localized date format
* - `p` is long localized time format
*/
const formatters = (exports.formatters = {
// Era
G: function (date, token, localize) {
const era = date.getFullYear() > 0 ? 1 : 0;
switch (token) {
// AD, BC
case "G":
case "GG":
case "GGG":
return localize.era(era, { width: "abbreviated" });
// A, B
case "GGGGG":
return localize.era(era, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return localize.era(era, { width: "wide" });
}
},
// Year
y: function (date, token, localize) {
// Ordinal number
if (token === "yo") {
const signedYear = date.getFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return localize.ordinalNumber(year, { unit: "year" });
}
return _index7.lightFormatters.y(date, token);
},
// Local week-numbering year
Y: function (date, token, localize, options) {
const signedWeekYear = (0, _index5.getWeekYear)(date, options);
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
// Two digit year
if (token === "YY") {
const twoDigitYear = weekYear % 100;
return (0, _index6.addLeadingZeros)(twoDigitYear, 2);
}
// Ordinal number
if (token === "Yo") {
return localize.ordinalNumber(weekYear, { unit: "year" });
}
// Padding
return (0, _index6.addLeadingZeros)(weekYear, token.length);
},
// ISO week-numbering year
R: function (date, token) {
const isoWeekYear = (0, _index3.getISOWeekYear)(date);
// Padding
return (0, _index6.addLeadingZeros)(isoWeekYear, token.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function (date, token) {
const year = date.getFullYear();
return (0, _index6.addLeadingZeros)(year, token.length);
},
// Quarter
Q: function (date, token, localize) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "Q":
return String(quarter);
// 01, 02, 03, 04
case "QQ":
return (0, _index6.addLeadingZeros)(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return localize.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "QQQ":
return localize.quarter(quarter, {
width: "abbreviated",
context: "formatting",
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return localize.quarter(quarter, {
width: "narrow",
context: "formatting",
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return localize.quarter(quarter, {
width: "wide",
context: "formatting",
});
}
},
// Stand-alone quarter
q: function (date, token, localize) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "q":
return String(quarter);
// 01, 02, 03, 04
case "qq":
return (0, _index6.addLeadingZeros)(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return localize.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "qqq":
return localize.quarter(quarter, {
width: "abbreviated",
context: "standalone",
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return localize.quarter(quarter, {
width: "narrow",
context: "standalone",
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return localize.quarter(quarter, {
width: "wide",
context: "standalone",
});
}
},
// Month
M: function (date, token, localize) {
const month = date.getMonth();
switch (token) {
case "M":
case "MM":
return _index7.lightFormatters.M(date, token);
// 1st, 2nd, ..., 12th
case "Mo":
return localize.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "MMM":
return localize.month(month, {
width: "abbreviated",
context: "formatting",
});
// J, F, ..., D
case "MMMMM":
return localize.month(month, {
width: "narrow",
context: "formatting",
});
// January, February, ..., December
case "MMMM":
default:
return localize.month(month, { width: "wide", context: "formatting" });
}
},
// Stand-alone month
L: function (date, token, localize) {
const month = date.getMonth();
switch (token) {
// 1, 2, ..., 12
case "L":
return String(month + 1);
// 01, 02, ..., 12
case "LL":
return (0, _index6.addLeadingZeros)(month + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return localize.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "LLL":
return localize.month(month, {
width: "abbreviated",
context: "standalone",
});
// J, F, ..., D
case "LLLLL":
return localize.month(month, {
width: "narrow",
context: "standalone",
});
// January, February, ..., December
case "LLLL":
default:
return localize.month(month, { width: "wide", context: "standalone" });
}
},
// Local week of year
w: function (date, token, localize, options) {
const week = (0, _index4.getWeek)(date, options);
if (token === "wo") {
return localize.ordinalNumber(week, { unit: "week" });
}
return (0, _index6.addLeadingZeros)(week, token.length);
},
// ISO week of year
I: function (date, token, localize) {
const isoWeek = (0, _index2.getISOWeek)(date);
if (token === "Io") {
return localize.ordinalNumber(isoWeek, { unit: "week" });
}
return (0, _index6.addLeadingZeros)(isoWeek, token.length);
},
// Day of the month
d: function (date, token, localize) {
if (token === "do") {
return localize.ordinalNumber(date.getDate(), { unit: "date" });
}
return _index7.lightFormatters.d(date, token);
},
// Day of year
D: function (date, token, localize) {
const dayOfYear = (0, _index.getDayOfYear)(date);
if (token === "Do") {
return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
}
return (0, _index6.addLeadingZeros)(dayOfYear, token.length);
},
// Day of week
E: function (date, token, localize) {
const dayOfWeek = date.getDay();
switch (token) {
// Tue
case "E":
case "EE":
case "EEE":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "EEEEE":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "EEEEEE":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "EEEE":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// Local day of week
e: function (date, token, localize, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(localDayOfWeek);
// Padded numerical value
case "ee":
return (0, _index6.addLeadingZeros)(localDayOfWeek, 2);
// 1st, 2nd, ..., 7th
case "eo":
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
case "eee":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "eeeee":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "eeeeee":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "eeee":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// Stand-alone local day of week
c: function (date, token, localize, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (same as in `e`)
case "c":
return String(localDayOfWeek);
// Padded numerical value
case "cc":
return (0, _index6.addLeadingZeros)(localDayOfWeek, token.length);
// 1st, 2nd, ..., 7th
case "co":
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
case "ccc":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "standalone",
});
// T
case "ccccc":
return localize.day(dayOfWeek, {
width: "narrow",
context: "standalone",
});
// Tu
case "cccccc":
return localize.day(dayOfWeek, {
width: "short",
context: "standalone",
});
// Tuesday
case "cccc":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "standalone",
});
}
},
// ISO day of week
i: function (date, token, localize) {
const dayOfWeek = date.getDay();
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
switch (token) {
// 2
case "i":
return String(isoDayOfWeek);
// 02
case "ii":
return (0, _index6.addLeadingZeros)(isoDayOfWeek, token.length);
// 2nd
case "io":
return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
// Tue
case "iii":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "iiiii":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "iiiiii":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "iiii":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// AM or PM
a: function (date, token, localize) {
const hours = date.getHours();
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "aaa":
return localize
.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
})
.toLowerCase();
case "aaaaa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "aaaa":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// AM, PM, midnight, noon
b: function (date, token, localize) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours === 12) {
dayPeriodEnumValue = dayPeriodEnum.noon;
} else if (hours === 0) {
dayPeriodEnumValue = dayPeriodEnum.midnight;
} else {
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
}
switch (token) {
case "b":
case "bb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "bbb":
return localize
.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
})
.toLowerCase();
case "bbbbb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "bbbb":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function (date, token, localize) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours >= 17) {
dayPeriodEnumValue = dayPeriodEnum.evening;
} else if (hours >= 12) {
dayPeriodEnumValue = dayPeriodEnum.afternoon;
} else if (hours >= 4) {
dayPeriodEnumValue = dayPeriodEnum.morning;
} else {
dayPeriodEnumValue = dayPeriodEnum.night;
}
switch (token) {
case "B":
case "BB":
case "BBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "BBBBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "BBBB":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// Hour [1-12]
h: function (date, token, localize) {
if (token === "ho") {
let hours = date.getHours() % 12;
if (hours === 0) hours = 12;
return localize.ordinalNumber(hours, { unit: "hour" });
}
return _index7.lightFormatters.h(date, token);
},
// Hour [0-23]
H: function (date, token, localize) {
if (token === "Ho") {
return localize.ordinalNumber(date.getHours(), { unit: "hour" });
}
return _index7.lightFormatters.H(date, token);
},
// Hour [0-11]
K: function (date, token, localize) {
const hours = date.getHours() % 12;
if (token === "Ko") {
return localize.ordinalNumber(hours, { unit: "hour" });
}
return (0, _index6.addLeadingZeros)(hours, token.length);
},
// Hour [1-24]
k: function (date, token, localize) {
let hours = date.getHours();
if (hours === 0) hours = 24;
if (token === "ko") {
return localize.ordinalNumber(hours, { unit: "hour" });
}
return (0, _index6.addLeadingZeros)(hours, token.length);
},
// Minute
m: function (date, token, localize) {
if (token === "mo") {
return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
}
return _index7.lightFormatters.m(date, token);
},
// Second
s: function (date, token, localize) {
if (token === "so") {
return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
}
return _index7.lightFormatters.s(date, token);
},
// Fraction of second
S: function (date, token) {
return _index7.lightFormatters.S(date, token);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
if (timezoneOffset === 0) {
return "Z";
}
switch (token) {
// Hours and optional minutes
case "X":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX": // Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX": // Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Hours and optional minutes
case "x":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx": // Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx": // Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (GMT)
O: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "OOOO":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Timezone (specific non-location)
z: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "zzzz":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Seconds timestamp
t: function (date, token, _localize) {
const timestamp = Math.trunc(+date / 1000);
return (0, _index6.addLeadingZeros)(timestamp, token.length);
},
// Milliseconds timestamp
T: function (date, token, _localize) {
return (0, _index6.addLeadingZeros)(+date, token.length);
},
});
function formatTimezoneShort(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = Math.trunc(absOffset / 60);
const minutes = absOffset % 60;
if (minutes === 0) {
return sign + String(hours);
}
return (
sign + String(hours) + delimiter + (0, _index6.addLeadingZeros)(minutes, 2)
);
}
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
if (offset % 60 === 0) {
const sign = offset > 0 ? "-" : "+";
return sign + (0, _index6.addLeadingZeros)(Math.abs(offset) / 60, 2);
}
return formatTimezone(offset, delimiter);
}
function formatTimezone(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = (0, _index6.addLeadingZeros)(Math.trunc(absOffset / 60), 2);
const minutes = (0, _index6.addLeadingZeros)(absOffset % 60, 2);
return sign + hours + delimiter + minutes;
}

18
node_modules/date-fns/_lib/format/formatters.d.cts generated vendored Normal file
View file

@ -0,0 +1,18 @@
import type { Localize } from "../../locale/types.js";
import type {
FirstWeekContainsDateOptions,
LocalizedOptions,
WeekOptions,
} from "../../types.js";
type Formatter = (
date: Date,
token: string,
localize: Localize,
options: Required<
LocalizedOptions<"options"> & WeekOptions & FirstWeekContainsDateOptions
>,
) => string;
export declare const formatters: {
[token: string]: Formatter;
};
export {};

18
node_modules/date-fns/_lib/format/formatters.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
import type { Localize } from "../../locale/types.js";
import type {
FirstWeekContainsDateOptions,
LocalizedOptions,
WeekOptions,
} from "../../types.js";
type Formatter = (
date: Date,
token: string,
localize: Localize,
options: Required<
LocalizedOptions<"options"> & WeekOptions & FirstWeekContainsDateOptions
>,
) => string;
export declare const formatters: {
[token: string]: Formatter;
};
export {};

776
node_modules/date-fns/_lib/format/formatters.js generated vendored Normal file
View file

@ -0,0 +1,776 @@
import { getDayOfYear } from "../../getDayOfYear.js";
import { getISOWeek } from "../../getISOWeek.js";
import { getISOWeekYear } from "../../getISOWeekYear.js";
import { getWeek } from "../../getWeek.js";
import { getWeekYear } from "../../getWeekYear.js";
import { addLeadingZeros } from "../addLeadingZeros.js";
import { lightFormatters } from "./lightFormatters.js";
const dayPeriodEnum = {
am: "am",
pm: "pm",
midnight: "midnight",
noon: "noon",
morning: "morning",
afternoon: "afternoon",
evening: "evening",
night: "night",
};
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | Milliseconds in day |
* | b | AM, PM, noon, midnight | B | Flexible day period |
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
* | d | Day of month | D | Day of year |
* | e | Local day of week | E | Day of week |
* | f | | F* | Day of week in month |
* | g* | Modified Julian day | G | Era |
* | h | Hour [1-12] | H | Hour [0-23] |
* | i! | ISO day of week | I! | ISO week of year |
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
* | k | Hour [1-24] | K | Hour [0-11] |
* | l* | (deprecated) | L | Stand-alone month |
* | m | Minute | M | Month |
* | n | | N | |
* | o! | Ordinal number modifier | O | Timezone (GMT) |
* | p! | Long localized time | P! | Long localized date |
* | q | Stand-alone quarter | Q | Quarter |
* | r* | Related Gregorian year | R! | ISO week-numbering year |
* | s | Second | S | Fraction of second |
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
* | u | Extended year | U* | Cyclic year |
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
* | w | Local week of year | W* | Week of month |
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
* | y | Year (abs) | Y | Local week-numbering year |
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*
* Letters marked by ! are non-standard, but implemented by date-fns:
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
* i.e. 7 for Sunday, 1 for Monday, etc.
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
* `R` is supposed to be used in conjunction with `I` and `i`
* for universal ISO week-numbering date, whereas
* `Y` is supposed to be used in conjunction with `w` and `e`
* for week-numbering date specific to the locale.
* - `P` is long localized date format
* - `p` is long localized time format
*/
export const formatters = {
// Era
G: function (date, token, localize) {
const era = date.getFullYear() > 0 ? 1 : 0;
switch (token) {
// AD, BC
case "G":
case "GG":
case "GGG":
return localize.era(era, { width: "abbreviated" });
// A, B
case "GGGGG":
return localize.era(era, { width: "narrow" });
// Anno Domini, Before Christ
case "GGGG":
default:
return localize.era(era, { width: "wide" });
}
},
// Year
y: function (date, token, localize) {
// Ordinal number
if (token === "yo") {
const signedYear = date.getFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return localize.ordinalNumber(year, { unit: "year" });
}
return lightFormatters.y(date, token);
},
// Local week-numbering year
Y: function (date, token, localize, options) {
const signedWeekYear = getWeekYear(date, options);
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
// Two digit year
if (token === "YY") {
const twoDigitYear = weekYear % 100;
return addLeadingZeros(twoDigitYear, 2);
}
// Ordinal number
if (token === "Yo") {
return localize.ordinalNumber(weekYear, { unit: "year" });
}
// Padding
return addLeadingZeros(weekYear, token.length);
},
// ISO week-numbering year
R: function (date, token) {
const isoWeekYear = getISOWeekYear(date);
// Padding
return addLeadingZeros(isoWeekYear, token.length);
},
// Extended year. This is a single number designating the year of this calendar system.
// The main difference between `y` and `u` localizers are B.C. years:
// | Year | `y` | `u` |
// |------|-----|-----|
// | AC 1 | 1 | 1 |
// | BC 1 | 1 | 0 |
// | BC 2 | 2 | -1 |
// Also `yy` always returns the last two digits of a year,
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
u: function (date, token) {
const year = date.getFullYear();
return addLeadingZeros(year, token.length);
},
// Quarter
Q: function (date, token, localize) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "Q":
return String(quarter);
// 01, 02, 03, 04
case "QQ":
return addLeadingZeros(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "Qo":
return localize.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "QQQ":
return localize.quarter(quarter, {
width: "abbreviated",
context: "formatting",
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "QQQQQ":
return localize.quarter(quarter, {
width: "narrow",
context: "formatting",
});
// 1st quarter, 2nd quarter, ...
case "QQQQ":
default:
return localize.quarter(quarter, {
width: "wide",
context: "formatting",
});
}
},
// Stand-alone quarter
q: function (date, token, localize) {
const quarter = Math.ceil((date.getMonth() + 1) / 3);
switch (token) {
// 1, 2, 3, 4
case "q":
return String(quarter);
// 01, 02, 03, 04
case "qq":
return addLeadingZeros(quarter, 2);
// 1st, 2nd, 3rd, 4th
case "qo":
return localize.ordinalNumber(quarter, { unit: "quarter" });
// Q1, Q2, Q3, Q4
case "qqq":
return localize.quarter(quarter, {
width: "abbreviated",
context: "standalone",
});
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
case "qqqqq":
return localize.quarter(quarter, {
width: "narrow",
context: "standalone",
});
// 1st quarter, 2nd quarter, ...
case "qqqq":
default:
return localize.quarter(quarter, {
width: "wide",
context: "standalone",
});
}
},
// Month
M: function (date, token, localize) {
const month = date.getMonth();
switch (token) {
case "M":
case "MM":
return lightFormatters.M(date, token);
// 1st, 2nd, ..., 12th
case "Mo":
return localize.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "MMM":
return localize.month(month, {
width: "abbreviated",
context: "formatting",
});
// J, F, ..., D
case "MMMMM":
return localize.month(month, {
width: "narrow",
context: "formatting",
});
// January, February, ..., December
case "MMMM":
default:
return localize.month(month, { width: "wide", context: "formatting" });
}
},
// Stand-alone month
L: function (date, token, localize) {
const month = date.getMonth();
switch (token) {
// 1, 2, ..., 12
case "L":
return String(month + 1);
// 01, 02, ..., 12
case "LL":
return addLeadingZeros(month + 1, 2);
// 1st, 2nd, ..., 12th
case "Lo":
return localize.ordinalNumber(month + 1, { unit: "month" });
// Jan, Feb, ..., Dec
case "LLL":
return localize.month(month, {
width: "abbreviated",
context: "standalone",
});
// J, F, ..., D
case "LLLLL":
return localize.month(month, {
width: "narrow",
context: "standalone",
});
// January, February, ..., December
case "LLLL":
default:
return localize.month(month, { width: "wide", context: "standalone" });
}
},
// Local week of year
w: function (date, token, localize, options) {
const week = getWeek(date, options);
if (token === "wo") {
return localize.ordinalNumber(week, { unit: "week" });
}
return addLeadingZeros(week, token.length);
},
// ISO week of year
I: function (date, token, localize) {
const isoWeek = getISOWeek(date);
if (token === "Io") {
return localize.ordinalNumber(isoWeek, { unit: "week" });
}
return addLeadingZeros(isoWeek, token.length);
},
// Day of the month
d: function (date, token, localize) {
if (token === "do") {
return localize.ordinalNumber(date.getDate(), { unit: "date" });
}
return lightFormatters.d(date, token);
},
// Day of year
D: function (date, token, localize) {
const dayOfYear = getDayOfYear(date);
if (token === "Do") {
return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
}
return addLeadingZeros(dayOfYear, token.length);
},
// Day of week
E: function (date, token, localize) {
const dayOfWeek = date.getDay();
switch (token) {
// Tue
case "E":
case "EE":
case "EEE":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "EEEEE":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "EEEEEE":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "EEEE":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// Local day of week
e: function (date, token, localize, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (Nth day of week with current locale or weekStartsOn)
case "e":
return String(localDayOfWeek);
// Padded numerical value
case "ee":
return addLeadingZeros(localDayOfWeek, 2);
// 1st, 2nd, ..., 7th
case "eo":
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
case "eee":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "eeeee":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "eeeeee":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "eeee":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// Stand-alone local day of week
c: function (date, token, localize, options) {
const dayOfWeek = date.getDay();
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
switch (token) {
// Numerical value (same as in `e`)
case "c":
return String(localDayOfWeek);
// Padded numerical value
case "cc":
return addLeadingZeros(localDayOfWeek, token.length);
// 1st, 2nd, ..., 7th
case "co":
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
case "ccc":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "standalone",
});
// T
case "ccccc":
return localize.day(dayOfWeek, {
width: "narrow",
context: "standalone",
});
// Tu
case "cccccc":
return localize.day(dayOfWeek, {
width: "short",
context: "standalone",
});
// Tuesday
case "cccc":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "standalone",
});
}
},
// ISO day of week
i: function (date, token, localize) {
const dayOfWeek = date.getDay();
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
switch (token) {
// 2
case "i":
return String(isoDayOfWeek);
// 02
case "ii":
return addLeadingZeros(isoDayOfWeek, token.length);
// 2nd
case "io":
return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
// Tue
case "iii":
return localize.day(dayOfWeek, {
width: "abbreviated",
context: "formatting",
});
// T
case "iiiii":
return localize.day(dayOfWeek, {
width: "narrow",
context: "formatting",
});
// Tu
case "iiiiii":
return localize.day(dayOfWeek, {
width: "short",
context: "formatting",
});
// Tuesday
case "iiii":
default:
return localize.day(dayOfWeek, {
width: "wide",
context: "formatting",
});
}
},
// AM or PM
a: function (date, token, localize) {
const hours = date.getHours();
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "aaa":
return localize
.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
})
.toLowerCase();
case "aaaaa":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "aaaa":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// AM, PM, midnight, noon
b: function (date, token, localize) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours === 12) {
dayPeriodEnumValue = dayPeriodEnum.noon;
} else if (hours === 0) {
dayPeriodEnumValue = dayPeriodEnum.midnight;
} else {
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
}
switch (token) {
case "b":
case "bb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "bbb":
return localize
.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
})
.toLowerCase();
case "bbbbb":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "bbbb":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// in the morning, in the afternoon, in the evening, at night
B: function (date, token, localize) {
const hours = date.getHours();
let dayPeriodEnumValue;
if (hours >= 17) {
dayPeriodEnumValue = dayPeriodEnum.evening;
} else if (hours >= 12) {
dayPeriodEnumValue = dayPeriodEnum.afternoon;
} else if (hours >= 4) {
dayPeriodEnumValue = dayPeriodEnum.morning;
} else {
dayPeriodEnumValue = dayPeriodEnum.night;
}
switch (token) {
case "B":
case "BB":
case "BBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "abbreviated",
context: "formatting",
});
case "BBBBB":
return localize.dayPeriod(dayPeriodEnumValue, {
width: "narrow",
context: "formatting",
});
case "BBBB":
default:
return localize.dayPeriod(dayPeriodEnumValue, {
width: "wide",
context: "formatting",
});
}
},
// Hour [1-12]
h: function (date, token, localize) {
if (token === "ho") {
let hours = date.getHours() % 12;
if (hours === 0) hours = 12;
return localize.ordinalNumber(hours, { unit: "hour" });
}
return lightFormatters.h(date, token);
},
// Hour [0-23]
H: function (date, token, localize) {
if (token === "Ho") {
return localize.ordinalNumber(date.getHours(), { unit: "hour" });
}
return lightFormatters.H(date, token);
},
// Hour [0-11]
K: function (date, token, localize) {
const hours = date.getHours() % 12;
if (token === "Ko") {
return localize.ordinalNumber(hours, { unit: "hour" });
}
return addLeadingZeros(hours, token.length);
},
// Hour [1-24]
k: function (date, token, localize) {
let hours = date.getHours();
if (hours === 0) hours = 24;
if (token === "ko") {
return localize.ordinalNumber(hours, { unit: "hour" });
}
return addLeadingZeros(hours, token.length);
},
// Minute
m: function (date, token, localize) {
if (token === "mo") {
return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
}
return lightFormatters.m(date, token);
},
// Second
s: function (date, token, localize) {
if (token === "so") {
return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
}
return lightFormatters.s(date, token);
},
// Fraction of second
S: function (date, token) {
return lightFormatters.S(date, token);
},
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
X: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
if (timezoneOffset === 0) {
return "Z";
}
switch (token) {
// Hours and optional minutes
case "X":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XX`
case "XXXX":
case "XX": // Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `XXX`
case "XXXXX":
case "XXX": // Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
x: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Hours and optional minutes
case "x":
return formatTimezoneWithOptionalMinutes(timezoneOffset);
// Hours, minutes and optional seconds without `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xx`
case "xxxx":
case "xx": // Hours and minutes without `:` delimiter
return formatTimezone(timezoneOffset);
// Hours, minutes and optional seconds with `:` delimiter
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
// so this token always has the same output as `xxx`
case "xxxxx":
case "xxx": // Hours and minutes with `:` delimiter
default:
return formatTimezone(timezoneOffset, ":");
}
},
// Timezone (GMT)
O: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "O":
case "OO":
case "OOO":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "OOOO":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Timezone (specific non-location)
z: function (date, token, _localize) {
const timezoneOffset = date.getTimezoneOffset();
switch (token) {
// Short
case "z":
case "zz":
case "zzz":
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
// Long
case "zzzz":
default:
return "GMT" + formatTimezone(timezoneOffset, ":");
}
},
// Seconds timestamp
t: function (date, token, _localize) {
const timestamp = Math.trunc(+date / 1000);
return addLeadingZeros(timestamp, token.length);
},
// Milliseconds timestamp
T: function (date, token, _localize) {
return addLeadingZeros(+date, token.length);
},
};
function formatTimezoneShort(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = Math.trunc(absOffset / 60);
const minutes = absOffset % 60;
if (minutes === 0) {
return sign + String(hours);
}
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
}
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
if (offset % 60 === 0) {
const sign = offset > 0 ? "-" : "+";
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
}
return formatTimezone(offset, delimiter);
}
function formatTimezone(offset, delimiter = "") {
const sign = offset > 0 ? "-" : "+";
const absOffset = Math.abs(offset);
const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
const minutes = addLeadingZeros(absOffset % 60, 2);
return sign + hours + delimiter + minutes;
}

102
node_modules/date-fns/_lib/format/lightFormatters.cjs generated vendored Normal file
View file

@ -0,0 +1,102 @@
"use strict";
exports.lightFormatters = void 0;
var _index = require("../addLeadingZeros.cjs");
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | |
* | d | Day of month | D | |
* | h | Hour [1-12] | H | Hour [0-23] |
* | m | Minute | M | Month |
* | s | Second | S | Fraction of second |
* | y | Year (abs) | Y | |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*/
const lightFormatters = (exports.lightFormatters = {
// Year
y(date, token) {
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
// | Year | y | yy | yyy | yyyy | yyyyy |
// |----------|-------|----|-------|-------|-------|
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
const signedYear = date.getFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return (0, _index.addLeadingZeros)(
token === "yy" ? year % 100 : year,
token.length,
);
},
// Month
M(date, token) {
const month = date.getMonth();
return token === "M"
? String(month + 1)
: (0, _index.addLeadingZeros)(month + 1, 2);
},
// Day of the month
d(date, token) {
return (0, _index.addLeadingZeros)(date.getDate(), token.length);
},
// AM or PM
a(date, token) {
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return dayPeriodEnumValue.toUpperCase();
case "aaa":
return dayPeriodEnumValue;
case "aaaaa":
return dayPeriodEnumValue[0];
case "aaaa":
default:
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(date, token) {
return (0, _index.addLeadingZeros)(
date.getHours() % 12 || 12,
token.length,
);
},
// Hour [0-23]
H(date, token) {
return (0, _index.addLeadingZeros)(date.getHours(), token.length);
},
// Minute
m(date, token) {
return (0, _index.addLeadingZeros)(date.getMinutes(), token.length);
},
// Second
s(date, token) {
return (0, _index.addLeadingZeros)(date.getSeconds(), token.length);
},
// Fraction of second
S(date, token) {
const numberOfDigits = token.length;
const milliseconds = date.getMilliseconds();
const fractionalSeconds = Math.trunc(
milliseconds * Math.pow(10, numberOfDigits - 3),
);
return (0, _index.addLeadingZeros)(fractionalSeconds, token.length);
},
});

View file

@ -0,0 +1,11 @@
export declare const lightFormatters: {
y(date: Date, token: string): string;
M(date: Date, token: string): string;
d(date: Date, token: string): string;
a(date: Date, token: string): string;
h(date: Date, token: string): string;
H(date: Date, token: string): string;
m(date: Date, token: string): string;
s(date: Date, token: string): string;
S(date: Date, token: string): string;
};

11
node_modules/date-fns/_lib/format/lightFormatters.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
export declare const lightFormatters: {
y(date: Date, token: string): string;
M(date: Date, token: string): string;
d(date: Date, token: string): string;
a(date: Date, token: string): string;
h(date: Date, token: string): string;
H(date: Date, token: string): string;
m(date: Date, token: string): string;
s(date: Date, token: string): string;
S(date: Date, token: string): string;
};

92
node_modules/date-fns/_lib/format/lightFormatters.js generated vendored Normal file
View file

@ -0,0 +1,92 @@
import { addLeadingZeros } from "../addLeadingZeros.js";
/*
* | | Unit | | Unit |
* |-----|--------------------------------|-----|--------------------------------|
* | a | AM, PM | A* | |
* | d | Day of month | D | |
* | h | Hour [1-12] | H | Hour [0-23] |
* | m | Minute | M | Month |
* | s | Second | S | Fraction of second |
* | y | Year (abs) | Y | |
*
* Letters marked by * are not implemented but reserved by Unicode standard.
*/
export const lightFormatters = {
// Year
y(date, token) {
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
// | Year | y | yy | yyy | yyyy | yyyyy |
// |----------|-------|----|-------|-------|-------|
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
const signedYear = date.getFullYear();
// Returns 1 for 1 BC (which is year 0 in JavaScript)
const year = signedYear > 0 ? signedYear : 1 - signedYear;
return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
},
// Month
M(date, token) {
const month = date.getMonth();
return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
},
// Day of the month
d(date, token) {
return addLeadingZeros(date.getDate(), token.length);
},
// AM or PM
a(date, token) {
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
switch (token) {
case "a":
case "aa":
return dayPeriodEnumValue.toUpperCase();
case "aaa":
return dayPeriodEnumValue;
case "aaaaa":
return dayPeriodEnumValue[0];
case "aaaa":
default:
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
}
},
// Hour [1-12]
h(date, token) {
return addLeadingZeros(date.getHours() % 12 || 12, token.length);
},
// Hour [0-23]
H(date, token) {
return addLeadingZeros(date.getHours(), token.length);
},
// Minute
m(date, token) {
return addLeadingZeros(date.getMinutes(), token.length);
},
// Second
s(date, token) {
return addLeadingZeros(date.getSeconds(), token.length);
},
// Fraction of second
S(date, token) {
const numberOfDigits = token.length;
const milliseconds = date.getMilliseconds();
const fractionalSeconds = Math.trunc(
milliseconds * Math.pow(10, numberOfDigits - 3),
);
return addLeadingZeros(fractionalSeconds, token.length);
},
};

67
node_modules/date-fns/_lib/format/longFormatters.cjs generated vendored Normal file
View file

@ -0,0 +1,67 @@
"use strict";
exports.longFormatters = void 0;
const dateLongFormatter = (pattern, formatLong) => {
switch (pattern) {
case "P":
return formatLong.date({ width: "short" });
case "PP":
return formatLong.date({ width: "medium" });
case "PPP":
return formatLong.date({ width: "long" });
case "PPPP":
default:
return formatLong.date({ width: "full" });
}
};
const timeLongFormatter = (pattern, formatLong) => {
switch (pattern) {
case "p":
return formatLong.time({ width: "short" });
case "pp":
return formatLong.time({ width: "medium" });
case "ppp":
return formatLong.time({ width: "long" });
case "pppp":
default:
return formatLong.time({ width: "full" });
}
};
const dateTimeLongFormatter = (pattern, formatLong) => {
const matchResult = pattern.match(/(P+)(p+)?/) || [];
const datePattern = matchResult[1];
const timePattern = matchResult[2];
if (!timePattern) {
return dateLongFormatter(pattern, formatLong);
}
let dateTimeFormat;
switch (datePattern) {
case "P":
dateTimeFormat = formatLong.dateTime({ width: "short" });
break;
case "PP":
dateTimeFormat = formatLong.dateTime({ width: "medium" });
break;
case "PPP":
dateTimeFormat = formatLong.dateTime({ width: "long" });
break;
case "PPPP":
default:
dateTimeFormat = formatLong.dateTime({ width: "full" });
break;
}
return dateTimeFormat
.replace("{{date}}", dateLongFormatter(datePattern, formatLong))
.replace("{{time}}", timeLongFormatter(timePattern, formatLong));
};
const longFormatters = (exports.longFormatters = {
p: timeLongFormatter,
P: dateTimeLongFormatter,
});

View file

@ -0,0 +1,4 @@
import type { FormatLong } from "../../locale/types.js";
type LongFormatter = (pattern: string, formatLong: FormatLong) => string;
export declare const longFormatters: Record<string, LongFormatter>;
export {};

View file

@ -0,0 +1,4 @@
import type { FormatLong } from "../../locale/types.js";
type LongFormatter = (pattern: string, formatLong: FormatLong) => string;
export declare const longFormatters: Record<string, LongFormatter>;
export {};

64
node_modules/date-fns/_lib/format/longFormatters.js generated vendored Normal file
View file

@ -0,0 +1,64 @@
const dateLongFormatter = (pattern, formatLong) => {
switch (pattern) {
case "P":
return formatLong.date({ width: "short" });
case "PP":
return formatLong.date({ width: "medium" });
case "PPP":
return formatLong.date({ width: "long" });
case "PPPP":
default:
return formatLong.date({ width: "full" });
}
};
const timeLongFormatter = (pattern, formatLong) => {
switch (pattern) {
case "p":
return formatLong.time({ width: "short" });
case "pp":
return formatLong.time({ width: "medium" });
case "ppp":
return formatLong.time({ width: "long" });
case "pppp":
default:
return formatLong.time({ width: "full" });
}
};
const dateTimeLongFormatter = (pattern, formatLong) => {
const matchResult = pattern.match(/(P+)(p+)?/) || [];
const datePattern = matchResult[1];
const timePattern = matchResult[2];
if (!timePattern) {
return dateLongFormatter(pattern, formatLong);
}
let dateTimeFormat;
switch (datePattern) {
case "P":
dateTimeFormat = formatLong.dateTime({ width: "short" });
break;
case "PP":
dateTimeFormat = formatLong.dateTime({ width: "medium" });
break;
case "PPP":
dateTimeFormat = formatLong.dateTime({ width: "long" });
break;
case "PPPP":
default:
dateTimeFormat = formatLong.dateTime({ width: "full" });
break;
}
return dateTimeFormat
.replace("{{date}}", dateLongFormatter(datePattern, formatLong))
.replace("{{time}}", timeLongFormatter(timePattern, formatLong));
};
export const longFormatters = {
p: timeLongFormatter,
P: dateTimeLongFormatter,
};

11
node_modules/date-fns/_lib/getRoundingMethod.cjs generated vendored Normal file
View file

@ -0,0 +1,11 @@
"use strict";
exports.getRoundingMethod = getRoundingMethod;
function getRoundingMethod(method) {
return (number) => {
const round = method ? Math[method] : Math.trunc;
const result = round(number);
// Prevent negative zero
return result === 0 ? 0 : result;
};
}

4
node_modules/date-fns/_lib/getRoundingMethod.d.cts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import type { RoundingMethod } from "../types.js";
export declare function getRoundingMethod(
method: RoundingMethod | undefined,
): (number: number) => number;

4
node_modules/date-fns/_lib/getRoundingMethod.d.ts generated vendored Normal file
View file

@ -0,0 +1,4 @@
import type { RoundingMethod } from "../types.js";
export declare function getRoundingMethod(
method: RoundingMethod | undefined,
): (number: number) => number;

8
node_modules/date-fns/_lib/getRoundingMethod.js generated vendored Normal file
View file

@ -0,0 +1,8 @@
export function getRoundingMethod(method) {
return (number) => {
const round = method ? Math[method] : Math.trunc;
const result = round(number);
// Prevent negative zero
return result === 0 ? 0 : result;
};
}

View file

@ -0,0 +1,31 @@
"use strict";
exports.getTimezoneOffsetInMilliseconds = getTimezoneOffsetInMilliseconds;
var _index = require("../toDate.cjs");
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
function getTimezoneOffsetInMilliseconds(date) {
const _date = (0, _index.toDate)(date);
const utcDate = new Date(
Date.UTC(
_date.getFullYear(),
_date.getMonth(),
_date.getDate(),
_date.getHours(),
_date.getMinutes(),
_date.getSeconds(),
_date.getMilliseconds(),
),
);
utcDate.setUTCFullYear(_date.getFullYear());
return +date - +utcDate;
}

View file

@ -0,0 +1,15 @@
import type { DateArg } from "../types.js";
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
export declare function getTimezoneOffsetInMilliseconds(
date: DateArg<Date> & {},
): number;

View file

@ -0,0 +1,15 @@
import type { DateArg } from "../types.js";
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
export declare function getTimezoneOffsetInMilliseconds(
date: DateArg<Date> & {},
): number;

View file

@ -0,0 +1,29 @@
import { toDate } from "../toDate.js";
/**
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
* They usually appear for dates that denote time before the timezones were introduced
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
* and GMT+01:00:00 after that date)
*
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
* which would lead to incorrect calculations.
*
* This function returns the timezone offset in milliseconds that takes seconds in account.
*/
export function getTimezoneOffsetInMilliseconds(date) {
const _date = toDate(date);
const utcDate = new Date(
Date.UTC(
_date.getFullYear(),
_date.getMonth(),
_date.getDate(),
_date.getHours(),
_date.getMinutes(),
_date.getSeconds(),
_date.getMilliseconds(),
),
);
utcDate.setUTCFullYear(_date.getFullYear());
return +date - +utcDate;
}

11
node_modules/date-fns/_lib/normalizeDates.cjs generated vendored Normal file
View file

@ -0,0 +1,11 @@
"use strict";
exports.normalizeDates = normalizeDates;
var _index = require("../constructFrom.cjs");
function normalizeDates(context, ...dates) {
const normalize = _index.constructFrom.bind(
null,
context || dates.find((date) => typeof date === "object"),
);
return dates.map(normalize);
}

13
node_modules/date-fns/_lib/normalizeDates.d.cts generated vendored Normal file
View file

@ -0,0 +1,13 @@
import type { ContextFn, DateArg } from "../types.js";
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: [DateArg<Date>, DateArg<Date>, DateArg<Date>]
): [Date, Date, Date];
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: [DateArg<Date>, DateArg<Date>]
): [Date, Date];
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: Array<DateArg<Date> & {}>
): Date[];

13
node_modules/date-fns/_lib/normalizeDates.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
import type { ContextFn, DateArg } from "../types.js";
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: [DateArg<Date>, DateArg<Date>, DateArg<Date>]
): [Date, Date, Date];
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: [DateArg<Date>, DateArg<Date>]
): [Date, Date];
export declare function normalizeDates(
context: ContextFn<Date> | undefined,
...dates: Array<DateArg<Date> & {}>
): Date[];

9
node_modules/date-fns/_lib/normalizeDates.js generated vendored Normal file
View file

@ -0,0 +1,9 @@
import { constructFrom } from "../constructFrom.js";
export function normalizeDates(context, ...dates) {
const normalize = constructFrom.bind(
null,
context || dates.find((date) => typeof date === "object"),
);
return dates.map(normalize);
}

12
node_modules/date-fns/_lib/normalizeInterval.cjs generated vendored Normal file
View file

@ -0,0 +1,12 @@
"use strict";
exports.normalizeInterval = normalizeInterval;
var _index = require("./normalizeDates.cjs");
function normalizeInterval(context, interval) {
const [start, end] = (0, _index.normalizeDates)(
context,
interval.start,
interval.end,
);
return { start, end };
}

5
node_modules/date-fns/_lib/normalizeInterval.d.cts generated vendored Normal file
View file

@ -0,0 +1,5 @@
import type { ContextFn, Interval, NormalizedInterval } from "../types.js";
export declare function normalizeInterval(
context: ContextFn<Date> | undefined,
interval: Interval,
): NormalizedInterval<Date>;

5
node_modules/date-fns/_lib/normalizeInterval.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
import type { ContextFn, Interval, NormalizedInterval } from "../types.js";
export declare function normalizeInterval(
context: ContextFn<Date> | undefined,
interval: Interval,
): NormalizedInterval<Date>;

6
node_modules/date-fns/_lib/normalizeInterval.js generated vendored Normal file
View file

@ -0,0 +1,6 @@
import { normalizeDates } from "./normalizeDates.js";
export function normalizeInterval(context, interval) {
const [start, end] = normalizeDates(context, interval.start, interval.end);
return { start, end };
}

27
node_modules/date-fns/_lib/protectedTokens.cjs generated vendored Normal file
View file

@ -0,0 +1,27 @@
"use strict";
exports.isProtectedDayOfYearToken = isProtectedDayOfYearToken;
exports.isProtectedWeekYearToken = isProtectedWeekYearToken;
exports.warnOrThrowProtectedError = warnOrThrowProtectedError;
const dayOfYearTokenRE = /^D+$/;
const weekYearTokenRE = /^Y+$/;
const throwTokens = ["D", "DD", "YY", "YYYY"];
function isProtectedDayOfYearToken(token) {
return dayOfYearTokenRE.test(token);
}
function isProtectedWeekYearToken(token) {
return weekYearTokenRE.test(token);
}
function warnOrThrowProtectedError(token, format, input) {
const _message = message(token, format, input);
console.warn(_message);
if (throwTokens.includes(token)) throw new RangeError(_message);
}
function message(token, format, input) {
const subject = token[0] === "Y" ? "years" : "days of the month";
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}

7
node_modules/date-fns/_lib/protectedTokens.d.cts generated vendored Normal file
View file

@ -0,0 +1,7 @@
export declare function isProtectedDayOfYearToken(token: string): boolean;
export declare function isProtectedWeekYearToken(token: string): boolean;
export declare function warnOrThrowProtectedError(
token: string,
format: string,
input: string,
): void;

7
node_modules/date-fns/_lib/protectedTokens.d.ts generated vendored Normal file
View file

@ -0,0 +1,7 @@
export declare function isProtectedDayOfYearToken(token: string): boolean;
export declare function isProtectedWeekYearToken(token: string): boolean;
export declare function warnOrThrowProtectedError(
token: string,
format: string,
input: string,
): void;

23
node_modules/date-fns/_lib/protectedTokens.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
const dayOfYearTokenRE = /^D+$/;
const weekYearTokenRE = /^Y+$/;
const throwTokens = ["D", "DD", "YY", "YYYY"];
export function isProtectedDayOfYearToken(token) {
return dayOfYearTokenRE.test(token);
}
export function isProtectedWeekYearToken(token) {
return weekYearTokenRE.test(token);
}
export function warnOrThrowProtectedError(token, format, input) {
const _message = message(token, format, input);
console.warn(_message);
if (throwTokens.includes(token)) throw new RangeError(_message);
}
function message(token, format, input) {
const subject = token[0] === "Y" ? "years" : "days of the month";
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}

75
node_modules/date-fns/add.cjs generated vendored Normal file
View file

@ -0,0 +1,75 @@
"use strict";
exports.add = add;
var _index = require("./addDays.cjs");
var _index2 = require("./addMonths.cjs");
var _index3 = require("./constructFrom.cjs");
var _index4 = require("./toDate.cjs");
/**
* The {@link add} function options.
*/
/**
* @name add
* @category Common Helpers
* @summary Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @description
* Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @typeParam DateType - The `Date` type the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes, and seconds to be added.
* @param options - An object with options
*
* @returns The new date with the seconds added
*
* @example
* // Add the following duration to 1 September 2014, 10:19:50
* const result = add(new Date(2014, 8, 1, 10, 19, 50), {
* years: 2,
* months: 9,
* weeks: 1,
* days: 7,
* hours: 5,
* minutes: 9,
* seconds: 30,
* })
* //=> Thu Jun 15 2017 15:29:20
*/
function add(date, duration, options) {
const {
years = 0,
months = 0,
weeks = 0,
days = 0,
hours = 0,
minutes = 0,
seconds = 0,
} = duration;
// Add years and months
const _date = (0, _index4.toDate)(date, options?.in);
const dateWithMonths =
months || years
? (0, _index2.addMonths)(_date, months + years * 12)
: _date;
// Add weeks and days
const dateWithDays =
days || weeks
? (0, _index.addDays)(dateWithMonths, days + weeks * 7)
: dateWithMonths;
// Add days, hours, minutes, and seconds
const minutesToAdd = minutes + hours * 60;
const secondsToAdd = seconds + minutesToAdd * 60;
const msToAdd = secondsToAdd * 1000;
return (0, _index3.constructFrom)(
options?.in || date,
+dateWithDays + msToAdd,
);
}

44
node_modules/date-fns/add.d.cts generated vendored Normal file
View file

@ -0,0 +1,44 @@
import type { ContextOptions, DateArg, Duration } from "./types.js";
/**
* The {@link add} function options.
*/
export interface AddOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name add
* @category Common Helpers
* @summary Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @description
* Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @typeParam DateType - The `Date` type the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes, and seconds to be added.
* @param options - An object with options
*
* @returns The new date with the seconds added
*
* @example
* // Add the following duration to 1 September 2014, 10:19:50
* const result = add(new Date(2014, 8, 1, 10, 19, 50), {
* years: 2,
* months: 9,
* weeks: 1,
* days: 7,
* hours: 5,
* minutes: 9,
* seconds: 30,
* })
* //=> Thu Jun 15 2017 15:29:20
*/
export declare function add<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
duration: Duration,
options?: AddOptions<ResultDate> | undefined,
): ResultDate;

44
node_modules/date-fns/add.d.ts generated vendored Normal file
View file

@ -0,0 +1,44 @@
import type { ContextOptions, DateArg, Duration } from "./types.js";
/**
* The {@link add} function options.
*/
export interface AddOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name add
* @category Common Helpers
* @summary Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @description
* Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @typeParam DateType - The `Date` type the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes, and seconds to be added.
* @param options - An object with options
*
* @returns The new date with the seconds added
*
* @example
* // Add the following duration to 1 September 2014, 10:19:50
* const result = add(new Date(2014, 8, 1, 10, 19, 50), {
* years: 2,
* months: 9,
* weeks: 1,
* days: 7,
* hours: 5,
* minutes: 9,
* seconds: 30,
* })
* //=> Thu Jun 15 2017 15:29:20
*/
export declare function add<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
duration: Duration,
options?: AddOptions<ResultDate> | undefined,
): ResultDate;

69
node_modules/date-fns/add.js generated vendored Normal file
View file

@ -0,0 +1,69 @@
import { addDays } from "./addDays.js";
import { addMonths } from "./addMonths.js";
import { constructFrom } from "./constructFrom.js";
import { toDate } from "./toDate.js";
/**
* The {@link add} function options.
*/
/**
* @name add
* @category Common Helpers
* @summary Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @description
* Add the specified years, months, weeks, days, hours, minutes, and seconds to the given date.
*
* @typeParam DateType - The `Date` type the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param duration - The object with years, months, weeks, days, hours, minutes, and seconds to be added.
* @param options - An object with options
*
* @returns The new date with the seconds added
*
* @example
* // Add the following duration to 1 September 2014, 10:19:50
* const result = add(new Date(2014, 8, 1, 10, 19, 50), {
* years: 2,
* months: 9,
* weeks: 1,
* days: 7,
* hours: 5,
* minutes: 9,
* seconds: 30,
* })
* //=> Thu Jun 15 2017 15:29:20
*/
export function add(date, duration, options) {
const {
years = 0,
months = 0,
weeks = 0,
days = 0,
hours = 0,
minutes = 0,
seconds = 0,
} = duration;
// Add years and months
const _date = toDate(date, options?.in);
const dateWithMonths =
months || years ? addMonths(_date, months + years * 12) : _date;
// Add weeks and days
const dateWithDays =
days || weeks ? addDays(dateWithMonths, days + weeks * 7) : dateWithMonths;
// Add days, hours, minutes, and seconds
const minutesToAdd = minutes + hours * 60;
const secondsToAdd = seconds + minutesToAdd * 60;
const msToAdd = secondsToAdd * 1000;
return constructFrom(options?.in || date, +dateWithDays + msToAdd);
}
// Fallback for modularized imports:
export default add;

76
node_modules/date-fns/addBusinessDays.cjs generated vendored Normal file
View file

@ -0,0 +1,76 @@
"use strict";
exports.addBusinessDays = addBusinessDays;
var _index = require("./constructFrom.cjs");
var _index2 = require("./isSaturday.cjs");
var _index3 = require("./isSunday.cjs");
var _index4 = require("./isWeekend.cjs");
var _index5 = require("./toDate.cjs");
/**
* The {@link addBusinessDays} function options.
*/
/**
* @name addBusinessDays
* @category Day Helpers
* @summary Add the specified number of business days (mon - fri) to the given date.
*
* @description
* Add the specified number of business days (mon - fri) to the given date, ignoring weekends.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of business days to be added.
* @param options - An object with options
*
* @returns The new date with the business days added
*
* @example
* // Add 10 business days to 1 September 2014:
* const result = addBusinessDays(new Date(2014, 8, 1), 10)
* //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)
*/
function addBusinessDays(date, amount, options) {
const _date = (0, _index5.toDate)(date, options?.in);
const startedOnWeekend = (0, _index4.isWeekend)(_date, options);
if (isNaN(amount)) return (0, _index.constructFrom)(options?.in, NaN);
const hours = _date.getHours();
const sign = amount < 0 ? -1 : 1;
const fullWeeks = Math.trunc(amount / 5);
_date.setDate(_date.getDate() + fullWeeks * 7);
// Get remaining days not part of a full week
let restDays = Math.abs(amount % 5);
// Loops over remaining days
while (restDays > 0) {
_date.setDate(_date.getDate() + sign);
if (!(0, _index4.isWeekend)(_date, options)) restDays -= 1;
}
// If the date is a weekend day and we reduce a dividable of
// 5 from it, we land on a weekend date.
// To counter this, we add days accordingly to land on the next business day
if (
startedOnWeekend &&
(0, _index4.isWeekend)(_date, options) &&
amount !== 0
) {
// If we're reducing days, we want to add days until we land on a weekday
// If we're adding days we want to reduce days until we land on a weekday
if ((0, _index2.isSaturday)(_date, options))
_date.setDate(_date.getDate() + (sign < 0 ? 2 : -1));
if ((0, _index3.isSunday)(_date, options))
_date.setDate(_date.getDate() + (sign < 0 ? 1 : -2));
}
// Restore hours to avoid DST lag
_date.setHours(hours);
return _date;
}

36
node_modules/date-fns/addBusinessDays.d.cts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addBusinessDays} function options.
*/
export interface AddBusinessDaysOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addBusinessDays
* @category Day Helpers
* @summary Add the specified number of business days (mon - fri) to the given date.
*
* @description
* Add the specified number of business days (mon - fri) to the given date, ignoring weekends.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of business days to be added.
* @param options - An object with options
*
* @returns The new date with the business days added
*
* @example
* // Add 10 business days to 1 September 2014:
* const result = addBusinessDays(new Date(2014, 8, 1), 10)
* //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)
*/
export declare function addBusinessDays<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddBusinessDaysOptions<ResultDate> | undefined,
): ResultDate;

36
node_modules/date-fns/addBusinessDays.d.ts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addBusinessDays} function options.
*/
export interface AddBusinessDaysOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addBusinessDays
* @category Day Helpers
* @summary Add the specified number of business days (mon - fri) to the given date.
*
* @description
* Add the specified number of business days (mon - fri) to the given date, ignoring weekends.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of business days to be added.
* @param options - An object with options
*
* @returns The new date with the business days added
*
* @example
* // Add 10 business days to 1 September 2014:
* const result = addBusinessDays(new Date(2014, 8, 1), 10)
* //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)
*/
export declare function addBusinessDays<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddBusinessDaysOptions<ResultDate> | undefined,
): ResultDate;

73
node_modules/date-fns/addBusinessDays.js generated vendored Normal file
View file

@ -0,0 +1,73 @@
import { constructFrom } from "./constructFrom.js";
import { isSaturday } from "./isSaturday.js";
import { isSunday } from "./isSunday.js";
import { isWeekend } from "./isWeekend.js";
import { toDate } from "./toDate.js";
/**
* The {@link addBusinessDays} function options.
*/
/**
* @name addBusinessDays
* @category Day Helpers
* @summary Add the specified number of business days (mon - fri) to the given date.
*
* @description
* Add the specified number of business days (mon - fri) to the given date, ignoring weekends.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of business days to be added.
* @param options - An object with options
*
* @returns The new date with the business days added
*
* @example
* // Add 10 business days to 1 September 2014:
* const result = addBusinessDays(new Date(2014, 8, 1), 10)
* //=> Mon Sep 15 2014 00:00:00 (skipped weekend days)
*/
export function addBusinessDays(date, amount, options) {
const _date = toDate(date, options?.in);
const startedOnWeekend = isWeekend(_date, options);
if (isNaN(amount)) return constructFrom(options?.in, NaN);
const hours = _date.getHours();
const sign = amount < 0 ? -1 : 1;
const fullWeeks = Math.trunc(amount / 5);
_date.setDate(_date.getDate() + fullWeeks * 7);
// Get remaining days not part of a full week
let restDays = Math.abs(amount % 5);
// Loops over remaining days
while (restDays > 0) {
_date.setDate(_date.getDate() + sign);
if (!isWeekend(_date, options)) restDays -= 1;
}
// If the date is a weekend day and we reduce a dividable of
// 5 from it, we land on a weekend date.
// To counter this, we add days accordingly to land on the next business day
if (startedOnWeekend && isWeekend(_date, options) && amount !== 0) {
// If we're reducing days, we want to add days until we land on a weekday
// If we're adding days we want to reduce days until we land on a weekday
if (isSaturday(_date, options))
_date.setDate(_date.getDate() + (sign < 0 ? 2 : -1));
if (isSunday(_date, options))
_date.setDate(_date.getDate() + (sign < 0 ? 1 : -2));
}
// Restore hours to avoid DST lag
_date.setHours(hours);
return _date;
}
// Fallback for modularized imports:
export default addBusinessDays;

41
node_modules/date-fns/addDays.cjs generated vendored Normal file
View file

@ -0,0 +1,41 @@
"use strict";
exports.addDays = addDays;
var _index = require("./constructFrom.cjs");
var _index2 = require("./toDate.cjs");
/**
* The {@link addDays} function options.
*/
/**
* @name addDays
* @category Day Helpers
* @summary Add the specified number of days to the given date.
*
* @description
* Add the specified number of days to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of days to be added.
* @param options - An object with options
*
* @returns The new date with the days added
*
* @example
* // Add 10 days to 1 September 2014:
* const result = addDays(new Date(2014, 8, 1), 10)
* //=> Thu Sep 11 2014 00:00:00
*/
function addDays(date, amount, options) {
const _date = (0, _index2.toDate)(date, options?.in);
if (isNaN(amount)) return (0, _index.constructFrom)(options?.in || date, NaN);
// If 0 days, no-op to avoid changing times in the hour before end of DST
if (!amount) return _date;
_date.setDate(_date.getDate() + amount);
return _date;
}

36
node_modules/date-fns/addDays.d.cts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addDays} function options.
*/
export interface AddDaysOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addDays
* @category Day Helpers
* @summary Add the specified number of days to the given date.
*
* @description
* Add the specified number of days to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of days to be added.
* @param options - An object with options
*
* @returns The new date with the days added
*
* @example
* // Add 10 days to 1 September 2014:
* const result = addDays(new Date(2014, 8, 1), 10)
* //=> Thu Sep 11 2014 00:00:00
*/
export declare function addDays<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddDaysOptions<ResultDate> | undefined,
): ResultDate;

36
node_modules/date-fns/addDays.d.ts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addDays} function options.
*/
export interface AddDaysOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addDays
* @category Day Helpers
* @summary Add the specified number of days to the given date.
*
* @description
* Add the specified number of days to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of days to be added.
* @param options - An object with options
*
* @returns The new date with the days added
*
* @example
* // Add 10 days to 1 September 2014:
* const result = addDays(new Date(2014, 8, 1), 10)
* //=> Thu Sep 11 2014 00:00:00
*/
export declare function addDays<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddDaysOptions<ResultDate> | undefined,
): ResultDate;

42
node_modules/date-fns/addDays.js generated vendored Normal file
View file

@ -0,0 +1,42 @@
import { constructFrom } from "./constructFrom.js";
import { toDate } from "./toDate.js";
/**
* The {@link addDays} function options.
*/
/**
* @name addDays
* @category Day Helpers
* @summary Add the specified number of days to the given date.
*
* @description
* Add the specified number of days to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of days to be added.
* @param options - An object with options
*
* @returns The new date with the days added
*
* @example
* // Add 10 days to 1 September 2014:
* const result = addDays(new Date(2014, 8, 1), 10)
* //=> Thu Sep 11 2014 00:00:00
*/
export function addDays(date, amount, options) {
const _date = toDate(date, options?.in);
if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
// If 0 days, no-op to avoid changing times in the hour before end of DST
if (!amount) return _date;
_date.setDate(_date.getDate() + amount);
return _date;
}
// Fallback for modularized imports:
export default addDays;

38
node_modules/date-fns/addHours.cjs generated vendored Normal file
View file

@ -0,0 +1,38 @@
"use strict";
exports.addHours = addHours;
var _index = require("./addMilliseconds.cjs");
var _index2 = require("./constants.cjs");
/**
* The {@link addHours} function options.
*/
/**
* @name addHours
* @category Hour Helpers
* @summary Add the specified number of hours to the given date.
*
* @description
* Add the specified number of hours to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of hours to be added
* @param options - An object with options
*
* @returns The new date with the hours added
*
* @example
* // Add 2 hours to 10 July 2014 23:00:00:
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
* //=> Fri Jul 11 2014 01:00:00
*/
function addHours(date, amount, options) {
return (0, _index.addMilliseconds)(
date,
amount * _index2.millisecondsInHour,
options,
);
}

36
node_modules/date-fns/addHours.d.cts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addHours} function options.
*/
export interface AddHoursOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addHours
* @category Hour Helpers
* @summary Add the specified number of hours to the given date.
*
* @description
* Add the specified number of hours to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of hours to be added
* @param options - An object with options
*
* @returns The new date with the hours added
*
* @example
* // Add 2 hours to 10 July 2014 23:00:00:
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
* //=> Fri Jul 11 2014 01:00:00
*/
export declare function addHours<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddHoursOptions<ResultDate> | undefined,
): ResultDate;

36
node_modules/date-fns/addHours.d.ts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addHours} function options.
*/
export interface AddHoursOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addHours
* @category Hour Helpers
* @summary Add the specified number of hours to the given date.
*
* @description
* Add the specified number of hours to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of hours to be added
* @param options - An object with options
*
* @returns The new date with the hours added
*
* @example
* // Add 2 hours to 10 July 2014 23:00:00:
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
* //=> Fri Jul 11 2014 01:00:00
*/
export declare function addHours<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddHoursOptions<ResultDate> | undefined,
): ResultDate;

35
node_modules/date-fns/addHours.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
import { addMilliseconds } from "./addMilliseconds.js";
import { millisecondsInHour } from "./constants.js";
/**
* The {@link addHours} function options.
*/
/**
* @name addHours
* @category Hour Helpers
* @summary Add the specified number of hours to the given date.
*
* @description
* Add the specified number of hours to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of hours to be added
* @param options - An object with options
*
* @returns The new date with the hours added
*
* @example
* // Add 2 hours to 10 July 2014 23:00:00:
* const result = addHours(new Date(2014, 6, 10, 23, 0), 2)
* //=> Fri Jul 11 2014 01:00:00
*/
export function addHours(date, amount, options) {
return addMilliseconds(date, amount * millisecondsInHour, options);
}
// Fallback for modularized imports:
export default addHours;

39
node_modules/date-fns/addISOWeekYears.cjs generated vendored Normal file
View file

@ -0,0 +1,39 @@
"use strict";
exports.addISOWeekYears = addISOWeekYears;
var _index = require("./getISOWeekYear.cjs");
var _index2 = require("./setISOWeekYear.cjs");
/**
* The {@link addISOWeekYears} function options.
*/
/**
* @name addISOWeekYears
* @category ISO Week-Numbering Year Helpers
* @summary Add the specified number of ISO week-numbering years to the given date.
*
* @description
* Add the specified number of ISO week-numbering years to the given date.
*
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
*
* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added.
* @param options - An object with options
*
* @returns The new date with the ISO week-numbering years added
*
* @example
* // Add 5 ISO week-numbering years to 2 July 2010:
* const result = addISOWeekYears(new Date(2010, 6, 2), 5)
* //=> Fri Jun 26 2015 00:00:00
*/
function addISOWeekYears(date, amount, options) {
return (0, _index2.setISOWeekYear)(
date,
(0, _index.getISOWeekYear)(date, options) + amount,
options,
);
}

37
node_modules/date-fns/addISOWeekYears.d.cts generated vendored Normal file
View file

@ -0,0 +1,37 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addISOWeekYears} function options.
*/
export interface AddISOWeekYearsOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addISOWeekYears
* @category ISO Week-Numbering Year Helpers
* @summary Add the specified number of ISO week-numbering years to the given date.
*
* @description
* Add the specified number of ISO week-numbering years to the given date.
*
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
*
* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added.
* @param options - An object with options
*
* @returns The new date with the ISO week-numbering years added
*
* @example
* // Add 5 ISO week-numbering years to 2 July 2010:
* const result = addISOWeekYears(new Date(2010, 6, 2), 5)
* //=> Fri Jun 26 2015 00:00:00
*/
export declare function addISOWeekYears<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddISOWeekYearsOptions<ResultDate> | undefined,
): ResultDate;

37
node_modules/date-fns/addISOWeekYears.d.ts generated vendored Normal file
View file

@ -0,0 +1,37 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addISOWeekYears} function options.
*/
export interface AddISOWeekYearsOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addISOWeekYears
* @category ISO Week-Numbering Year Helpers
* @summary Add the specified number of ISO week-numbering years to the given date.
*
* @description
* Add the specified number of ISO week-numbering years to the given date.
*
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
*
* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added.
* @param options - An object with options
*
* @returns The new date with the ISO week-numbering years added
*
* @example
* // Add 5 ISO week-numbering years to 2 July 2010:
* const result = addISOWeekYears(new Date(2010, 6, 2), 5)
* //=> Fri Jun 26 2015 00:00:00
*/
export declare function addISOWeekYears<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddISOWeekYearsOptions<ResultDate> | undefined,
): ResultDate;

36
node_modules/date-fns/addISOWeekYears.js generated vendored Normal file
View file

@ -0,0 +1,36 @@
import { getISOWeekYear } from "./getISOWeekYear.js";
import { setISOWeekYear } from "./setISOWeekYear.js";
/**
* The {@link addISOWeekYears} function options.
*/
/**
* @name addISOWeekYears
* @category ISO Week-Numbering Year Helpers
* @summary Add the specified number of ISO week-numbering years to the given date.
*
* @description
* Add the specified number of ISO week-numbering years to the given date.
*
* ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
*
* @param date - The date to be changed
* @param amount - The amount of ISO week-numbering years to be added.
* @param options - An object with options
*
* @returns The new date with the ISO week-numbering years added
*
* @example
* // Add 5 ISO week-numbering years to 2 July 2010:
* const result = addISOWeekYears(new Date(2010, 6, 2), 5)
* //=> Fri Jun 26 2015 00:00:00
*/
export function addISOWeekYears(date, amount, options) {
return setISOWeekYear(date, getISOWeekYear(date, options) + amount, options);
}
// Fallback for modularized imports:
export default addISOWeekYears;

37
node_modules/date-fns/addMilliseconds.cjs generated vendored Normal file
View file

@ -0,0 +1,37 @@
"use strict";
exports.addMilliseconds = addMilliseconds;
var _index = require("./constructFrom.cjs");
var _index2 = require("./toDate.cjs");
/**
* The {@link addMilliseconds} function options.
*/
/**
* @name addMilliseconds
* @category Millisecond Helpers
* @summary Add the specified number of milliseconds to the given date.
*
* @description
* Add the specified number of milliseconds to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added.
* @param options - The options object
*
* @returns The new date with the milliseconds added
*
* @example
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
* //=> Thu Jul 10 2014 12:45:30.750
*/
function addMilliseconds(date, amount, options) {
return (0, _index.constructFrom)(
options?.in || date,
+(0, _index2.toDate)(date) + amount,
);
}

36
node_modules/date-fns/addMilliseconds.d.cts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addMilliseconds} function options.
*/
export interface AddMillisecondsOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addMilliseconds
* @category Millisecond Helpers
* @summary Add the specified number of milliseconds to the given date.
*
* @description
* Add the specified number of milliseconds to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added.
* @param options - The options object
*
* @returns The new date with the milliseconds added
*
* @example
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
* //=> Thu Jul 10 2014 12:45:30.750
*/
export declare function addMilliseconds<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddMillisecondsOptions<ResultDate> | undefined,
): ResultDate;

36
node_modules/date-fns/addMilliseconds.d.ts generated vendored Normal file
View file

@ -0,0 +1,36 @@
import type { ContextOptions, DateArg } from "./types.js";
/**
* The {@link addMilliseconds} function options.
*/
export interface AddMillisecondsOptions<DateType extends Date = Date>
extends ContextOptions<DateType> {}
/**
* @name addMilliseconds
* @category Millisecond Helpers
* @summary Add the specified number of milliseconds to the given date.
*
* @description
* Add the specified number of milliseconds to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added.
* @param options - The options object
*
* @returns The new date with the milliseconds added
*
* @example
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
* //=> Thu Jul 10 2014 12:45:30.750
*/
export declare function addMilliseconds<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
amount: number,
options?: AddMillisecondsOptions<ResultDate> | undefined,
): ResultDate;

35
node_modules/date-fns/addMilliseconds.js generated vendored Normal file
View file

@ -0,0 +1,35 @@
import { constructFrom } from "./constructFrom.js";
import { toDate } from "./toDate.js";
/**
* The {@link addMilliseconds} function options.
*/
/**
* @name addMilliseconds
* @category Millisecond Helpers
* @summary Add the specified number of milliseconds to the given date.
*
* @description
* Add the specified number of milliseconds to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of milliseconds to be added.
* @param options - The options object
*
* @returns The new date with the milliseconds added
*
* @example
* // Add 750 milliseconds to 10 July 2014 12:45:30.000:
* const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
* //=> Thu Jul 10 2014 12:45:30.750
*/
export function addMilliseconds(date, amount, options) {
return constructFrom(options?.in || date, +toDate(date) + amount);
}
// Fallback for modularized imports:
export default addMilliseconds;

36
node_modules/date-fns/addMinutes.cjs generated vendored Normal file
View file

@ -0,0 +1,36 @@
"use strict";
exports.addMinutes = addMinutes;
var _index = require("./constants.cjs");
var _index2 = require("./toDate.cjs");
/**
* The {@link addMinutes} function options.
*/
/**
* @name addMinutes
* @category Minute Helpers
* @summary Add the specified number of minutes to the given date.
*
* @description
* Add the specified number of minutes to the given date.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param date - The date to be changed
* @param amount - The amount of minutes to be added.
* @param options - An object with options
*
* @returns The new date with the minutes added
*
* @example
* // Add 30 minutes to 10 July 2014 12:00:00:
* const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)
* //=> Thu Jul 10 2014 12:30:00
*/
function addMinutes(date, amount, options) {
const _date = (0, _index2.toDate)(date, options?.in);
_date.setTime(_date.getTime() + amount * _index.millisecondsInMinute);
return _date;
}

Some files were not shown because too many files have changed in this diff Show more