node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

47
server/node_modules/react-intl/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,47 @@
import * as React from 'react';
import { MessageDescriptor, CustomFormatConfig, FormatDateOptions } from '@formatjs/intl';
import { IntlListFormatOptions } from '@formatjs/intl-listformat';
import { DisplayNamesOptions } from '@formatjs/intl-displaynames';
import { NumberFormatOptions } from '@formatjs/ecma402-abstract';
import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, WithIntlProps, WrappedComponentProps } from './src/components/injectIntl';
import useIntl from './src/components/useIntl';
import IntlProvider from './src/components/provider';
import { createIntl } from './src/components/createIntl';
import FormattedRelativeTime from './src/components/relative';
import FormattedPlural from './src/components/plural';
import FormattedMessage from './src/components/message';
import FormattedDateTimeRange from './src/components/dateTimeRange';
export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, WithIntlProps, WrappedComponentProps, createIntl, injectIntl, useIntl, };
export { IntlConfig, ResolvedIntlConfig, IntlShape } from './src/types';
export { createIntlCache, MessageDescriptor, IntlCache, Formatters, IntlFormatters, FormatDisplayNameOptions, FormatListOptions, FormatPluralOptions, FormatRelativeTimeOptions, FormatNumberOptions, FormatDateOptions, CustomFormatConfig, CustomFormats, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
export declare function defineMessages<K extends keyof any, T = MessageDescriptor, U extends Record<K, T> = Record<K, T>>(msgs: U): U;
export declare function defineMessage<T extends MessageDescriptor>(msg: T): T;
export declare const FormattedDate: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
value: string | number | Date | undefined;
children?(formattedDate: string): React.ReactElement | null;
}>;
export declare const FormattedTime: React.FC<Intl.DateTimeFormatOptions & CustomFormatConfig & {
value: string | number | Date | undefined;
children?(formattedTime: string): React.ReactElement | null;
}>;
export declare const FormattedNumber: React.FC<Omit<NumberFormatOptions, 'localeMatcher'> & CustomFormatConfig<'number'> & {
value: number;
children?(formattedNumber: string): React.ReactElement | null;
}>;
export declare const FormattedList: React.FC<IntlListFormatOptions & {
value: readonly React.ReactNode[];
}>;
export declare const FormattedDisplayName: React.FC<DisplayNamesOptions & {
value: string | number | Record<string, unknown>;
}>;
export declare const FormattedDateParts: React.FC<FormatDateOptions & {
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
}>;
export declare const FormattedTimeParts: React.FC<FormatDateOptions & {
value: Parameters<Intl.DateTimeFormat['format']>[0] | string;
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
}>;
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';
export type { MessageFormatElement } from '@formatjs/icu-messageformat-parser';
export type { PrimitiveType } from 'intl-messageformat';

26
server/node_modules/react-intl/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import { createFormattedComponent, createFormattedDateTimePartsComponent, } from './src/components/createFormattedComponent';
import injectIntl, { Provider as RawIntlProvider, Context as IntlContext, } from './src/components/injectIntl';
import useIntl from './src/components/useIntl';
import IntlProvider from './src/components/provider';
import { createIntl } from './src/components/createIntl';
import FormattedRelativeTime from './src/components/relative';
import FormattedPlural from './src/components/plural';
import FormattedMessage from './src/components/message';
import FormattedDateTimeRange from './src/components/dateTimeRange';
export { FormattedDateTimeRange, FormattedMessage, FormattedPlural, FormattedRelativeTime, IntlContext, IntlProvider, RawIntlProvider, createIntl, injectIntl, useIntl, };
export { createIntlCache, UnsupportedFormatterError, InvalidConfigError, MissingDataError, MessageFormatError, MissingTranslationError, IntlErrorCode as ReactIntlErrorCode, IntlError as ReactIntlError, } from '@formatjs/intl';
export function defineMessages(msgs) {
return msgs;
}
export function defineMessage(msg) {
return msg;
}
// IMPORTANT: Explicit here to prevent api-extractor from outputing `import('./src/types').CustomFormatConfig`
export var FormattedDate = createFormattedComponent('formatDate');
export var FormattedTime = createFormattedComponent('formatTime');
export var FormattedNumber = createFormattedComponent('formatNumber');
export var FormattedList = createFormattedComponent('formatList');
export var FormattedDisplayName = createFormattedComponent('formatDisplayName');
export var FormattedDateParts = createFormattedDateTimePartsComponent('formatDate');
export var FormattedTimeParts = createFormattedDateTimePartsComponent('formatTime');
export { FormattedNumberParts, FormattedListParts, } from './src/components/createFormattedComponent';

View File

@@ -0,0 +1,28 @@
import * as React from 'react';
import { FormatDateOptions, FormatNumberOptions, FormatListOptions, FormatDisplayNameOptions } from '@formatjs/intl';
import { IntlShape } from '../types';
import { Part } from '@formatjs/intl-listformat';
type Formatter = {
formatDate: FormatDateOptions;
formatTime: FormatDateOptions;
formatNumber: FormatNumberOptions;
formatList: FormatListOptions;
formatDisplayName: FormatDisplayNameOptions;
};
export declare const FormattedNumberParts: React.FC<Formatter['formatNumber'] & {
value: Parameters<IntlShape['formatNumber']>[0];
children(val: Intl.NumberFormatPart[]): React.ReactElement | null;
}>;
export declare const FormattedListParts: React.FC<Formatter['formatList'] & {
value: Parameters<IntlShape['formatList']>[0];
children(val: Part[]): React.ReactElement | null;
}>;
export declare function createFormattedDateTimePartsComponent<Name extends 'formatDate' | 'formatTime'>(name: Name): React.FC<Formatter[Name] & {
value: Parameters<IntlShape[Name]>[0];
children(val: Intl.DateTimeFormatPart[]): React.ReactElement | null;
}>;
export declare function createFormattedComponent<Name extends keyof Formatter>(name: Name): React.FC<Formatter[Name] & {
value: Parameters<IntlShape[Name]>[0];
children?(val: string): React.ReactElement | null;
}>;
export {};

View File

@@ -0,0 +1,62 @@
import { __rest } from "tslib";
import * as React from 'react';
import useIntl from './useIntl';
var DisplayName;
(function (DisplayName) {
DisplayName["formatDate"] = "FormattedDate";
DisplayName["formatTime"] = "FormattedTime";
DisplayName["formatNumber"] = "FormattedNumber";
DisplayName["formatList"] = "FormattedList";
// Note that this DisplayName is the locale display name, not to be confused with
// the name of the enum, which is for React component display name in dev tools.
DisplayName["formatDisplayName"] = "FormattedDisplayName";
})(DisplayName || (DisplayName = {}));
var DisplayNameParts;
(function (DisplayNameParts) {
DisplayNameParts["formatDate"] = "FormattedDateParts";
DisplayNameParts["formatTime"] = "FormattedTimeParts";
DisplayNameParts["formatNumber"] = "FormattedNumberParts";
DisplayNameParts["formatList"] = "FormattedListParts";
})(DisplayNameParts || (DisplayNameParts = {}));
export var FormattedNumberParts = function (props) {
var intl = useIntl();
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
return children(intl.formatNumberToParts(value, formatProps));
};
FormattedNumberParts.displayName = 'FormattedNumberParts';
export var FormattedListParts = function (props) {
var intl = useIntl();
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
return children(intl.formatListToParts(value, formatProps));
};
FormattedNumberParts.displayName = 'FormattedNumberParts';
export function createFormattedDateTimePartsComponent(name) {
var ComponentParts = function (props) {
var intl = useIntl();
var value = props.value, children = props.children, formatProps = __rest(props, ["value", "children"]);
var date = typeof value === 'string' ? new Date(value || 0) : value;
var formattedParts = name === 'formatDate'
? intl.formatDateToParts(date, formatProps)
: intl.formatTimeToParts(date, formatProps);
return children(formattedParts);
};
ComponentParts.displayName = DisplayNameParts[name];
return ComponentParts;
}
export function createFormattedComponent(name) {
var Component = function (props) {
var intl = useIntl();
var value = props.value, children = props.children, formatProps = __rest(props
// TODO: fix TS type definition for localeMatcher upstream
, ["value", "children"]);
// TODO: fix TS type definition for localeMatcher upstream
var formattedValue = intl[name](value, formatProps);
if (typeof children === 'function') {
return children(formattedValue);
}
var Text = intl.textComponent || React.Fragment;
return React.createElement(Text, null, formattedValue);
};
Component.displayName = DisplayName[name];
return Component;
}

View File

@@ -0,0 +1,9 @@
import { CreateIntlFn } from '@formatjs/intl';
import * as React from 'react';
import type { IntlConfig, IntlShape } from '../types';
/**
* Create intl object
* @param config intl config
* @param cache cache for formatter instances to prevent memory leak
*/
export declare const createIntl: CreateIntlFn<React.ReactNode, IntlConfig, IntlShape>;

View File

@@ -0,0 +1,63 @@
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import { __assign, __rest, __spreadArray } from "tslib";
import { createIntl as coreCreateIntl, formatMessage as coreFormatMessage, } from '@formatjs/intl';
import * as React from 'react';
import { DEFAULT_INTL_CONFIG, assignUniqueKeysToParts } from '../utils';
import { isFormatXMLElementFn, } from 'intl-messageformat';
function assignUniqueKeysToFormatXMLElementFnArgument(values) {
if (!values) {
return values;
}
return Object.keys(values).reduce(function (acc, k) {
var v = values[k];
acc[k] = isFormatXMLElementFn(v)
? assignUniqueKeysToParts(v)
: v;
return acc;
}, {});
}
var formatMessage = function (config, formatters, descriptor, rawValues) {
var rest = [];
for (var _i = 4; _i < arguments.length; _i++) {
rest[_i - 4] = arguments[_i];
}
var values = assignUniqueKeysToFormatXMLElementFnArgument(rawValues);
var chunks = coreFormatMessage.apply(void 0, __spreadArray([config,
formatters,
descriptor,
values], rest, false));
if (Array.isArray(chunks)) {
return React.Children.toArray(chunks);
}
return chunks;
};
/**
* Create intl object
* @param config intl config
* @param cache cache for formatter instances to prevent memory leak
*/
export var createIntl = function (_a, cache) {
var rawDefaultRichTextElements = _a.defaultRichTextElements, config = __rest(_a, ["defaultRichTextElements"]);
var defaultRichTextElements = assignUniqueKeysToFormatXMLElementFnArgument(rawDefaultRichTextElements);
var coreIntl = coreCreateIntl(__assign(__assign(__assign({}, DEFAULT_INTL_CONFIG), config), { defaultRichTextElements: defaultRichTextElements }), cache);
var resolvedConfig = {
locale: coreIntl.locale,
timeZone: coreIntl.timeZone,
fallbackOnEmptyString: coreIntl.fallbackOnEmptyString,
formats: coreIntl.formats,
defaultLocale: coreIntl.defaultLocale,
defaultFormats: coreIntl.defaultFormats,
messages: coreIntl.messages,
onError: coreIntl.onError,
defaultRichTextElements: defaultRichTextElements,
};
return __assign(__assign({}, coreIntl), { formatMessage: formatMessage.bind(null, resolvedConfig,
// @ts-expect-error fix this
coreIntl.formatters),
// @ts-expect-error fix this
$t: formatMessage.bind(null, resolvedConfig, coreIntl.formatters) });
};

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
import { FormatDateOptions } from '@formatjs/intl';
import { DateTimeFormat } from '@formatjs/ecma402-abstract';
interface Props extends FormatDateOptions {
from: Parameters<DateTimeFormat['formatRange']>[0];
to: Parameters<DateTimeFormat['formatRange']>[1];
children?(value: React.ReactNode): React.ReactElement | null;
}
declare const FormattedDateTimeRange: React.FC<Props>;
export default FormattedDateTimeRange;

View File

@@ -0,0 +1,15 @@
import { __rest } from "tslib";
import * as React from 'react';
import useIntl from './useIntl';
var FormattedDateTimeRange = function (props) {
var intl = useIntl();
var from = props.from, to = props.to, children = props.children, formatProps = __rest(props, ["from", "to", "children"]);
var formattedValue = intl.formatDateTimeRange(from, to, formatProps);
if (typeof children === 'function') {
return children(formattedValue);
}
var Text = intl.textComponent || React.Fragment;
return React.createElement(Text, null, formattedValue);
};
FormattedDateTimeRange.displayName = 'FormattedDateTimeRange';
export default FormattedDateTimeRange;

View File

@@ -0,0 +1,39 @@
import * as React from 'react';
import { IntlShape } from '../types';
declare global {
interface Window {
/**
* Set this to `true` prior to mounting to bypass using a globally-exposed context.
*/
__REACT_INTL_BYPASS_GLOBAL_CONTEXT__: boolean | undefined;
__REACT_INTL_CONTEXT__: React.Context<IntlShape> | undefined;
}
}
export declare const Provider: React.Provider<IntlShape>;
export declare const Context: React.Context<IntlShape>;
export interface Opts<IntlPropName extends string = 'intl', ForwardRef extends boolean = false> {
intlPropName?: IntlPropName;
forwardRef?: ForwardRef;
enforceContext?: boolean;
}
export type WrappedComponentProps<IntlPropName extends string = 'intl'> = {
[k in IntlPropName]: IntlShape;
};
/**
* Utility type to help deal with the fact that `Omit` doesn't play well with unions:
* - https://github.com/microsoft/TypeScript/issues/31501
* - https://github.com/microsoft/TypeScript/issues/28339
*
* @example
* DistributedOmit<X | Y, K> --> Omit<X, K> | Omit<Y, K>
*/
export type DistributedOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
export type WithIntlProps<P> = DistributedOmit<P, keyof WrappedComponentProps> & {
forwardedRef?: React.Ref<any>;
};
export default function injectIntl<IntlPropName extends string = 'intl', P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, false>): React.FC<WithIntlProps<P>> & {
WrappedComponent: React.ComponentType<P>;
};
export default function injectIntl<IntlPropName extends string = 'intl', P extends WrappedComponentProps<IntlPropName> = WrappedComponentProps<any>, T extends React.ComponentType<P> = any>(WrappedComponent: React.ComponentType<P>, options?: Opts<IntlPropName, true>): React.ForwardRefExoticComponent<React.PropsWithoutRef<WithIntlProps<React.PropsWithChildren<P>>> & React.RefAttributes<T>> & {
WrappedComponent: React.ComponentType<P>;
};

View File

@@ -0,0 +1,33 @@
import { __assign } from "tslib";
import * as React from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { invariantIntlContext } from '../utils';
function getDisplayName(Component) {
return Component.displayName || Component.name || 'Component';
}
// This is primarily dealing with packaging systems where multiple copies of react-intl
// might exist
var IntlContext = typeof window !== 'undefined' && !window.__REACT_INTL_BYPASS_GLOBAL_CONTEXT__
? window.__REACT_INTL_CONTEXT__ ||
(window.__REACT_INTL_CONTEXT__ = React.createContext(null))
: React.createContext(null);
var IntlConsumer = IntlContext.Consumer, IntlProvider = IntlContext.Provider;
export var Provider = IntlProvider;
export var Context = IntlContext;
export default function injectIntl(WrappedComponent, options) {
var _a = options || {}, _b = _a.intlPropName, intlPropName = _b === void 0 ? 'intl' : _b, _c = _a.forwardRef, forwardRef = _c === void 0 ? false : _c, _d = _a.enforceContext, enforceContext = _d === void 0 ? true : _d;
var WithIntl = function (props) { return (React.createElement(IntlConsumer, null, function (intl) {
var _a;
if (enforceContext) {
invariantIntlContext(intl);
}
var intlProp = (_a = {}, _a[intlPropName] = intl, _a);
return (React.createElement(WrappedComponent, __assign({}, props, intlProp, { ref: forwardRef ? props.forwardedRef : null })));
})); };
WithIntl.displayName = "injectIntl(".concat(getDisplayName(WrappedComponent), ")");
WithIntl.WrappedComponent = WrappedComponent;
if (forwardRef) {
return hoistNonReactStatics(React.forwardRef(function (props, ref) { return (React.createElement(WithIntl, __assign({}, props, { forwardedRef: ref }))); }), WrappedComponent);
}
return hoistNonReactStatics(WithIntl, WrappedComponent);
}

View File

@@ -0,0 +1,11 @@
import * as React from 'react';
import type { FormatXMLElementFn, Options as IntlMessageFormatOptions, PrimitiveType } from 'intl-messageformat';
import { MessageDescriptor } from '@formatjs/intl';
export interface Props<V extends Record<string, any> = Record<string, React.ReactNode | PrimitiveType | FormatXMLElementFn<React.ReactNode, React.ReactNode>>> extends MessageDescriptor {
values?: V;
tagName?: React.ElementType<any>;
children?(nodes: React.ReactNode[]): React.ReactElement | null;
ignoreTag?: IntlMessageFormatOptions['ignoreTag'];
}
declare const MemoizedFormattedMessage: React.ComponentType<Props>;
export default MemoizedFormattedMessage;

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import { __rest } from "tslib";
import * as React from 'react';
import useIntl from './useIntl';
import { shallowEqual } from '../utils';
function areEqual(prevProps, nextProps) {
var values = prevProps.values, otherProps = __rest(prevProps, ["values"]);
var nextValues = nextProps.values, nextOtherProps = __rest(nextProps, ["values"]);
return (shallowEqual(nextValues, values) &&
shallowEqual(otherProps, nextOtherProps));
}
function FormattedMessage(props) {
var intl = useIntl();
var formatMessage = intl.formatMessage, _a = intl.textComponent, Text = _a === void 0 ? React.Fragment : _a;
var id = props.id, description = props.description, defaultMessage = props.defaultMessage, values = props.values, children = props.children, _b = props.tagName, Component = _b === void 0 ? Text : _b, ignoreTag = props.ignoreTag;
var descriptor = { id: id, description: description, defaultMessage: defaultMessage };
var nodes = formatMessage(descriptor, values, {
ignoreTag: ignoreTag,
});
if (typeof children === 'function') {
return children(Array.isArray(nodes) ? nodes : [nodes]);
}
if (Component) {
return React.createElement(Component, null, React.Children.toArray(nodes));
}
return React.createElement(React.Fragment, null, nodes);
}
FormattedMessage.displayName = 'FormattedMessage';
var MemoizedFormattedMessage = React.memo(FormattedMessage, areEqual);
MemoizedFormattedMessage.displayName = 'MemoizedFormattedMessage';
export default MemoizedFormattedMessage;

View File

@@ -0,0 +1,14 @@
import * as React from 'react';
import { FormatPluralOptions } from '@formatjs/intl';
interface Props extends FormatPluralOptions {
value: number;
other: React.ReactNode;
zero?: React.ReactNode;
one?: React.ReactNode;
two?: React.ReactNode;
few?: React.ReactNode;
many?: React.ReactNode;
children?(value: React.ReactNode): React.ReactElement | null;
}
declare const FormattedPlural: React.FC<Props>;
export default FormattedPlural;

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import * as React from 'react';
import useIntl from './useIntl';
var FormattedPlural = function (props) {
var _a = useIntl(), formatPlural = _a.formatPlural, Text = _a.textComponent;
var value = props.value, other = props.other, children = props.children;
var pluralCategory = formatPlural(value, props);
var formattedPlural = props[pluralCategory] || other;
if (typeof children === 'function') {
return children(formattedPlural);
}
if (Text) {
return React.createElement(Text, null, formattedPlural);
}
// Work around @types/react where React.FC cannot return string
return formattedPlural;
};
FormattedPlural.displayName = 'FormattedPlural';
export default FormattedPlural;

View File

@@ -0,0 +1,28 @@
import { IntlCache } from '@formatjs/intl';
import * as React from 'react';
import type { IntlConfig, IntlShape } from '../types';
interface State {
/**
* Explicit intl cache to prevent memory leaks
*/
cache: IntlCache;
/**
* Intl object we created
*/
intl?: IntlShape;
/**
* list of memoized config we care about.
* This is important since creating intl is
* very expensive
*/
prevConfig: IntlConfig;
}
export default class IntlProvider extends React.PureComponent<React.PropsWithChildren<IntlConfig>, State> {
static displayName: string;
static defaultProps: Pick<import("../types").ResolvedIntlConfig, "timeZone" | "onError" | "fallbackOnEmptyString" | "formats" | "messages" | "defaultLocale" | "defaultFormats" | "textComponent">;
private cache;
state: State;
static getDerivedStateFromProps(props: Readonly<IntlConfig>, { prevConfig, cache }: State): Partial<State> | null;
render(): JSX.Element;
}
export {};

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import { __extends } from "tslib";
import { createIntlCache } from '@formatjs/intl';
import * as React from 'react';
import { DEFAULT_INTL_CONFIG, invariantIntlContext, shallowEqual } from '../utils';
import { Provider } from './injectIntl';
import { createIntl } from './createIntl';
function processIntlConfig(config) {
return {
locale: config.locale,
timeZone: config.timeZone,
fallbackOnEmptyString: config.fallbackOnEmptyString,
formats: config.formats,
textComponent: config.textComponent,
messages: config.messages,
defaultLocale: config.defaultLocale,
defaultFormats: config.defaultFormats,
onError: config.onError,
onWarn: config.onWarn,
wrapRichTextChunksInFragment: config.wrapRichTextChunksInFragment,
defaultRichTextElements: config.defaultRichTextElements,
};
}
var IntlProvider = /** @class */ (function (_super) {
__extends(IntlProvider, _super);
function IntlProvider() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cache = createIntlCache();
_this.state = {
cache: _this.cache,
intl: createIntl(processIntlConfig(_this.props), _this.cache),
prevConfig: processIntlConfig(_this.props),
};
return _this;
}
IntlProvider.getDerivedStateFromProps = function (props, _a) {
var prevConfig = _a.prevConfig, cache = _a.cache;
var config = processIntlConfig(props);
if (!shallowEqual(prevConfig, config)) {
return {
intl: createIntl(config, cache),
prevConfig: config,
};
}
return null;
};
IntlProvider.prototype.render = function () {
invariantIntlContext(this.state.intl);
return React.createElement(Provider, { value: this.state.intl }, this.props.children);
};
IntlProvider.displayName = 'IntlProvider';
IntlProvider.defaultProps = DEFAULT_INTL_CONFIG;
return IntlProvider;
}(React.PureComponent));
export default IntlProvider;

View File

@@ -0,0 +1,11 @@
import * as React from 'react';
import { RelativeTimeFormatSingularUnit } from '@formatjs/ecma402-abstract';
import { FormatRelativeTimeOptions } from '@formatjs/intl';
export interface Props extends FormatRelativeTimeOptions {
value?: number;
unit?: RelativeTimeFormatSingularUnit;
updateIntervalInSeconds?: number;
children?(value: string): React.ReactElement | null;
}
declare const FormattedRelativeTime: React.FC<Props>;
export default FormattedRelativeTime;

View File

@@ -0,0 +1,125 @@
import { __assign, __rest } from "tslib";
/*
* Copyright 2015, Yahoo Inc.
* Copyrights licensed under the New BSD License.
* See the accompanying LICENSE file for terms.
*/
import * as React from 'react';
import { invariant, } from '@formatjs/ecma402-abstract';
import useIntl from './useIntl';
var MINUTE = 60;
var HOUR = 60 * 60;
var DAY = 60 * 60 * 24;
function selectUnit(seconds) {
var absValue = Math.abs(seconds);
if (absValue < MINUTE) {
return 'second';
}
if (absValue < HOUR) {
return 'minute';
}
if (absValue < DAY) {
return 'hour';
}
return 'day';
}
function getDurationInSeconds(unit) {
switch (unit) {
case 'second':
return 1;
case 'minute':
return MINUTE;
case 'hour':
return HOUR;
default:
return DAY;
}
}
function valueToSeconds(value, unit) {
if (!value) {
return 0;
}
switch (unit) {
case 'second':
return value;
case 'minute':
return value * MINUTE;
default:
return value * HOUR;
}
}
var INCREMENTABLE_UNITS = [
'second',
'minute',
'hour',
];
function canIncrement(unit) {
if (unit === void 0) { unit = 'second'; }
return INCREMENTABLE_UNITS.indexOf(unit) > -1;
}
var SimpleFormattedRelativeTime = function (props) {
var _a = useIntl(), formatRelativeTime = _a.formatRelativeTime, Text = _a.textComponent;
var children = props.children, value = props.value, unit = props.unit, otherProps = __rest(props, ["children", "value", "unit"]);
var formattedRelativeTime = formatRelativeTime(value || 0, unit, otherProps);
if (typeof children === 'function') {
return children(formattedRelativeTime);
}
if (Text) {
return React.createElement(Text, null, formattedRelativeTime);
}
return React.createElement(React.Fragment, null, formattedRelativeTime);
};
var FormattedRelativeTime = function (_a) {
var _b = _a.value, value = _b === void 0 ? 0 : _b, _c = _a.unit, unit = _c === void 0 ? 'second' : _c, updateIntervalInSeconds = _a.updateIntervalInSeconds, otherProps = __rest(_a, ["value", "unit", "updateIntervalInSeconds"]);
invariant(!updateIntervalInSeconds ||
!!(updateIntervalInSeconds && canIncrement(unit)), 'Cannot schedule update with unit longer than hour');
var _d = React.useState(), prevUnit = _d[0], setPrevUnit = _d[1];
var _e = React.useState(0), prevValue = _e[0], setPrevValue = _e[1];
var _f = React.useState(0), currentValueInSeconds = _f[0], setCurrentValueInSeconds = _f[1];
var updateTimer;
if (unit !== prevUnit || value !== prevValue) {
setPrevValue(value || 0);
setPrevUnit(unit);
setCurrentValueInSeconds(canIncrement(unit) ? valueToSeconds(value, unit) : 0);
}
React.useEffect(function () {
function clearUpdateTimer() {
clearTimeout(updateTimer);
}
clearUpdateTimer();
// If there's no interval and we cannot increment this unit, do nothing
if (!updateIntervalInSeconds || !canIncrement(unit)) {
return clearUpdateTimer;
}
// Figure out the next interesting time
var nextValueInSeconds = currentValueInSeconds - updateIntervalInSeconds;
var nextUnit = selectUnit(nextValueInSeconds);
// We've reached the max auto incrementable unit, don't schedule another update
if (nextUnit === 'day') {
return clearUpdateTimer;
}
var unitDuration = getDurationInSeconds(nextUnit);
var remainder = nextValueInSeconds % unitDuration;
var prevInterestingValueInSeconds = nextValueInSeconds - remainder;
var nextInterestingValueInSeconds = prevInterestingValueInSeconds >= currentValueInSeconds
? prevInterestingValueInSeconds - unitDuration
: prevInterestingValueInSeconds;
var delayInSeconds = Math.abs(nextInterestingValueInSeconds - currentValueInSeconds);
if (currentValueInSeconds !== nextInterestingValueInSeconds) {
updateTimer = setTimeout(function () { return setCurrentValueInSeconds(nextInterestingValueInSeconds); }, delayInSeconds * 1e3);
}
return clearUpdateTimer;
}, [currentValueInSeconds, updateIntervalInSeconds, unit]);
var currentValue = value || 0;
var currentUnit = unit;
if (canIncrement(unit) &&
typeof currentValueInSeconds === 'number' &&
updateIntervalInSeconds) {
currentUnit = selectUnit(currentValueInSeconds);
var unitDuration = getDurationInSeconds(currentUnit);
currentValue = Math.round(currentValueInSeconds / unitDuration);
}
return (React.createElement(SimpleFormattedRelativeTime, __assign({ value: currentValue, unit: currentUnit }, otherProps)));
};
FormattedRelativeTime.displayName = 'FormattedRelativeTime';
export default FormattedRelativeTime;

View File

@@ -0,0 +1,2 @@
import { IntlShape } from '../types';
export default function useIntl(): IntlShape;

View File

@@ -0,0 +1,8 @@
import * as React from 'react';
import { Context } from './injectIntl';
import { invariantIntlContext } from '../utils';
export default function useIntl() {
var intl = React.useContext(Context);
invariantIntlContext(intl);
return intl;
}

11
server/node_modules/react-intl/lib/src/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import * as React from 'react';
import { ResolvedIntlConfig as CoreResolvedIntlConfig, IntlFormatters, Formatters } from '@formatjs/intl';
import { DEFAULT_INTL_CONFIG } from './utils';
export type IntlConfig = Omit<ResolvedIntlConfig, keyof typeof DEFAULT_INTL_CONFIG> & Partial<typeof DEFAULT_INTL_CONFIG>;
export interface ResolvedIntlConfig extends CoreResolvedIntlConfig<React.ReactNode> {
textComponent?: React.ComponentType | keyof React.ReactHTML;
wrapRichTextChunksInFragment?: boolean;
}
export interface IntlShape extends ResolvedIntlConfig, IntlFormatters<React.ReactNode> {
formatters: Formatters;
}

1
server/node_modules/react-intl/lib/src/types.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

13
server/node_modules/react-intl/lib/src/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { ResolvedIntlConfig } from './types';
import * as React from 'react';
import { FormatXMLElementFn } from 'intl-messageformat';
export declare function invariantIntlContext(intl?: any): asserts intl;
export declare const DEFAULT_INTL_CONFIG: Pick<ResolvedIntlConfig, 'fallbackOnEmptyString' | 'formats' | 'messages' | 'timeZone' | 'textComponent' | 'defaultLocale' | 'defaultFormats' | 'onError'>;
/**
* Takes a `formatXMLElementFn`, and composes it in function, which passes
* argument `parts` through, assigning unique key to each part, to prevent
* "Each child in a list should have a unique "key"" React error.
* @param formatXMLElementFn
*/
export declare function assignUniqueKeysToParts(formatXMLElementFn: FormatXMLElementFn<React.ReactNode>): FormatXMLElementFn<React.ReactNode>;
export declare function shallowEqual<T extends Record<string, unknown> = Record<string, unknown>>(objA?: T, objB?: T): boolean;

43
server/node_modules/react-intl/lib/src/utils.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
import { __assign } from "tslib";
import * as React from 'react';
import { invariant } from '@formatjs/ecma402-abstract';
import { DEFAULT_INTL_CONFIG as CORE_DEFAULT_INTL_CONFIG } from '@formatjs/intl';
export function invariantIntlContext(intl) {
invariant(intl, '[React Intl] Could not find required `intl` object. ' +
'<IntlProvider> needs to exist in the component ancestry.');
}
export var DEFAULT_INTL_CONFIG = __assign(__assign({}, CORE_DEFAULT_INTL_CONFIG), { textComponent: React.Fragment });
/**
* Takes a `formatXMLElementFn`, and composes it in function, which passes
* argument `parts` through, assigning unique key to each part, to prevent
* "Each child in a list should have a unique "key"" React error.
* @param formatXMLElementFn
*/
export function assignUniqueKeysToParts(formatXMLElementFn) {
return function (parts) {
// eslint-disable-next-line prefer-rest-params
return formatXMLElementFn(React.Children.toArray(parts));
};
}
export function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
if (!objA || !objB) {
return false;
}
var aKeys = Object.keys(objA);
var bKeys = Object.keys(objB);
var len = aKeys.length;
if (bKeys.length !== len) {
return false;
}
for (var i = 0; i < len; i++) {
var key = aKeys[i];
if (objA[key] !== objB[key] ||
!Object.prototype.hasOwnProperty.call(objB, key)) {
return false;
}
}
return true;
}