first commit
This commit is contained in:
10
frontend/node_modules/antd/es/statistic/Countdown.d.ts
generated
vendored
Normal file
10
frontend/node_modules/antd/es/statistic/Countdown.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import type { StatisticProps } from './Statistic';
|
||||
import type { valueType } from './utils';
|
||||
export interface CountdownProps extends StatisticProps {
|
||||
format?: string;
|
||||
onFinish?: () => void;
|
||||
onChange?: (value?: valueType) => void;
|
||||
}
|
||||
declare const _default: React.NamedExoticComponent<CountdownProps>;
|
||||
export default _default;
|
||||
15
frontend/node_modules/antd/es/statistic/Countdown.js
generated
vendored
Normal file
15
frontend/node_modules/antd/es/statistic/Countdown.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import * as React from 'react';
|
||||
import { devUseWarning } from '../_util/warning';
|
||||
import StatisticTimer from './Timer';
|
||||
const Countdown = props => {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const warning = devUseWarning('Countdown');
|
||||
warning.deprecated(false, '<Statistic.Countdown />', '<Statistic.Timer type="countdown" />');
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(StatisticTimer, Object.assign({}, props, {
|
||||
type: "countdown"
|
||||
}));
|
||||
};
|
||||
export default /*#__PURE__*/React.memo(Countdown);
|
||||
8
frontend/node_modules/antd/es/statistic/Number.d.ts
generated
vendored
Normal file
8
frontend/node_modules/antd/es/statistic/Number.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import type { FormatConfig, valueType } from './utils';
|
||||
interface NumberProps extends FormatConfig {
|
||||
value: valueType;
|
||||
prefixCls?: string;
|
||||
}
|
||||
declare const StatisticNumber: React.FC<NumberProps>;
|
||||
export default StatisticNumber;
|
||||
48
frontend/node_modules/antd/es/statistic/Number.js
generated
vendored
Normal file
48
frontend/node_modules/antd/es/statistic/Number.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import * as React from 'react';
|
||||
const StatisticNumber = props => {
|
||||
const {
|
||||
value,
|
||||
formatter,
|
||||
precision,
|
||||
decimalSeparator,
|
||||
groupSeparator = '',
|
||||
prefixCls
|
||||
} = props;
|
||||
let valueNode;
|
||||
if (typeof formatter === 'function') {
|
||||
// Customize formatter
|
||||
valueNode = formatter(value);
|
||||
} else {
|
||||
// Internal formatter
|
||||
const val = String(value);
|
||||
const cells = val.match(/^(-?)(\d*)(\.(\d+))?$/);
|
||||
// Process if illegal number
|
||||
if (!cells || val === '-') {
|
||||
valueNode = val;
|
||||
} else {
|
||||
const negative = cells[1];
|
||||
let int = cells[2] || '0';
|
||||
let decimal = cells[4] || '';
|
||||
int = int.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
|
||||
if (typeof precision === 'number') {
|
||||
decimal = decimal.padEnd(precision, '0').slice(0, precision > 0 ? precision : 0);
|
||||
}
|
||||
if (decimal) {
|
||||
decimal = `${decimalSeparator}${decimal}`;
|
||||
}
|
||||
valueNode = [/*#__PURE__*/React.createElement("span", {
|
||||
key: "int",
|
||||
className: `${prefixCls}-content-value-int`
|
||||
}, negative, int), decimal && (/*#__PURE__*/React.createElement("span", {
|
||||
key: "decimal",
|
||||
className: `${prefixCls}-content-value-decimal`
|
||||
}, decimal))];
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/React.createElement("span", {
|
||||
className: `${prefixCls}-content-value`
|
||||
}, valueNode);
|
||||
};
|
||||
export default StatisticNumber;
|
||||
26
frontend/node_modules/antd/es/statistic/Statistic.d.ts
generated
vendored
Normal file
26
frontend/node_modules/antd/es/statistic/Statistic.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as React from 'react';
|
||||
import type { HTMLAriaDataAttributes } from '../_util/aria-data-attrs';
|
||||
import type { FormatConfig, valueType } from './utils';
|
||||
export interface StatisticRef {
|
||||
nativeElement: HTMLDivElement;
|
||||
}
|
||||
interface StatisticReactProps extends FormatConfig {
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
rootClassName?: string;
|
||||
style?: React.CSSProperties;
|
||||
value?: valueType;
|
||||
valueStyle?: React.CSSProperties;
|
||||
valueRender?: (node: React.ReactNode) => React.ReactNode;
|
||||
title?: React.ReactNode;
|
||||
prefix?: React.ReactNode;
|
||||
suffix?: React.ReactNode;
|
||||
loading?: boolean;
|
||||
onMouseEnter?: React.MouseEventHandler<HTMLDivElement>;
|
||||
onMouseLeave?: React.MouseEventHandler<HTMLDivElement>;
|
||||
}
|
||||
export type StatisticProps = HTMLAriaDataAttributes & StatisticReactProps;
|
||||
declare const Statistic: React.ForwardRefExoticComponent<React.AriaAttributes & {
|
||||
[key: `data-${string}`]: unknown;
|
||||
} & Pick<React.HTMLAttributes<HTMLDivElement>, "role"> & StatisticReactProps & React.RefAttributes<StatisticRef>>;
|
||||
export default Statistic;
|
||||
93
frontend/node_modules/antd/es/statistic/Statistic.js
generated
vendored
Normal file
93
frontend/node_modules/antd/es/statistic/Statistic.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use client";
|
||||
|
||||
var __rest = this && this.__rest || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import pickAttrs from "rc-util/es/pickAttrs";
|
||||
import { useComponentConfig } from '../config-provider/context';
|
||||
import Skeleton from '../skeleton';
|
||||
import StatisticNumber from './Number';
|
||||
import useStyle from './style';
|
||||
const Statistic = /*#__PURE__*/React.forwardRef((props, ref) => {
|
||||
const {
|
||||
prefixCls: customizePrefixCls,
|
||||
className,
|
||||
rootClassName,
|
||||
style,
|
||||
valueStyle,
|
||||
value = 0,
|
||||
title,
|
||||
valueRender,
|
||||
prefix,
|
||||
suffix,
|
||||
loading = false,
|
||||
/* --- FormatConfig starts --- */
|
||||
formatter,
|
||||
precision,
|
||||
decimalSeparator = '.',
|
||||
groupSeparator = ',',
|
||||
/* --- FormatConfig starts --- */
|
||||
onMouseEnter,
|
||||
onMouseLeave
|
||||
} = props,
|
||||
rest = __rest(props, ["prefixCls", "className", "rootClassName", "style", "valueStyle", "value", "title", "valueRender", "prefix", "suffix", "loading", "formatter", "precision", "decimalSeparator", "groupSeparator", "onMouseEnter", "onMouseLeave"]);
|
||||
const {
|
||||
getPrefixCls,
|
||||
direction,
|
||||
className: contextClassName,
|
||||
style: contextStyle
|
||||
} = useComponentConfig('statistic');
|
||||
const prefixCls = getPrefixCls('statistic', customizePrefixCls);
|
||||
const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
|
||||
const valueNode = /*#__PURE__*/React.createElement(StatisticNumber, {
|
||||
decimalSeparator: decimalSeparator,
|
||||
groupSeparator: groupSeparator,
|
||||
prefixCls: prefixCls,
|
||||
formatter: formatter,
|
||||
precision: precision,
|
||||
value: value
|
||||
});
|
||||
const cls = classNames(prefixCls, {
|
||||
[`${prefixCls}-rtl`]: direction === 'rtl'
|
||||
}, contextClassName, className, rootClassName, hashId, cssVarCls);
|
||||
const internalRef = React.useRef(null);
|
||||
React.useImperativeHandle(ref, () => ({
|
||||
nativeElement: internalRef.current
|
||||
}));
|
||||
const restProps = pickAttrs(rest, {
|
||||
aria: true,
|
||||
data: true
|
||||
});
|
||||
return wrapCSSVar(/*#__PURE__*/React.createElement("div", Object.assign({}, restProps, {
|
||||
ref: internalRef,
|
||||
className: cls,
|
||||
style: Object.assign(Object.assign({}, contextStyle), style),
|
||||
onMouseEnter: onMouseEnter,
|
||||
onMouseLeave: onMouseLeave
|
||||
}), title && /*#__PURE__*/React.createElement("div", {
|
||||
className: `${prefixCls}-title`
|
||||
}, title), /*#__PURE__*/React.createElement(Skeleton, {
|
||||
paragraph: false,
|
||||
loading: loading,
|
||||
className: `${prefixCls}-skeleton`,
|
||||
active: true
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
style: valueStyle,
|
||||
className: `${prefixCls}-content`
|
||||
}, prefix && /*#__PURE__*/React.createElement("span", {
|
||||
className: `${prefixCls}-content-prefix`
|
||||
}, prefix), valueRender ? valueRender(valueNode) : valueNode, suffix && /*#__PURE__*/React.createElement("span", {
|
||||
className: `${prefixCls}-content-suffix`
|
||||
}, suffix)))));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Statistic.displayName = 'Statistic';
|
||||
}
|
||||
export default Statistic;
|
||||
15
frontend/node_modules/antd/es/statistic/Timer.d.ts
generated
vendored
Normal file
15
frontend/node_modules/antd/es/statistic/Timer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as React from 'react';
|
||||
import type { StatisticProps } from './Statistic';
|
||||
import type { FormatConfig, valueType } from './utils';
|
||||
export type TimerType = 'countdown' | 'countup';
|
||||
export interface StatisticTimerProps extends FormatConfig, StatisticProps {
|
||||
type: TimerType;
|
||||
format?: string;
|
||||
/**
|
||||
* Only to be called when the type is `countdown`.
|
||||
*/
|
||||
onFinish?: () => void;
|
||||
onChange?: (value?: valueType) => void;
|
||||
}
|
||||
declare const StatisticTimer: React.FC<StatisticTimerProps>;
|
||||
export default StatisticTimer;
|
||||
77
frontend/node_modules/antd/es/statistic/Timer.js
generated
vendored
Normal file
77
frontend/node_modules/antd/es/statistic/Timer.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use client";
|
||||
|
||||
var __rest = this && this.__rest || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
import * as React from 'react';
|
||||
import { useEvent } from 'rc-util';
|
||||
import raf from "rc-util/es/raf";
|
||||
import { cloneElement } from '../_util/reactNode';
|
||||
import Statistic from './Statistic';
|
||||
import { formatCounter } from './utils';
|
||||
function getTime(value) {
|
||||
return new Date(value).getTime();
|
||||
}
|
||||
const StatisticTimer = props => {
|
||||
const {
|
||||
value,
|
||||
format = 'HH:mm:ss',
|
||||
onChange,
|
||||
onFinish,
|
||||
type
|
||||
} = props,
|
||||
rest = __rest(props, ["value", "format", "onChange", "onFinish", "type"]);
|
||||
const down = type === 'countdown';
|
||||
// We reuse state here to do same as `forceUpdate`
|
||||
const [showTime, setShowTime] = React.useState(null);
|
||||
// ======================== Update ========================
|
||||
const update = useEvent(() => {
|
||||
const now = Date.now();
|
||||
const timestamp = getTime(value);
|
||||
setShowTime({});
|
||||
const timeDiff = !down ? now - timestamp : timestamp - now;
|
||||
onChange === null || onChange === void 0 ? void 0 : onChange(timeDiff);
|
||||
// Only countdown will trigger `onFinish`
|
||||
if (down && timestamp < now) {
|
||||
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
// Effect trigger
|
||||
React.useEffect(() => {
|
||||
let rafId;
|
||||
const clear = () => raf.cancel(rafId);
|
||||
const rafUpdate = () => {
|
||||
rafId = raf(() => {
|
||||
if (update()) {
|
||||
rafUpdate();
|
||||
}
|
||||
});
|
||||
};
|
||||
rafUpdate();
|
||||
return clear;
|
||||
}, [value, down]);
|
||||
React.useEffect(() => {
|
||||
setShowTime({});
|
||||
}, []);
|
||||
// ======================== Format ========================
|
||||
const formatter = (formatValue, config) => showTime ? formatCounter(formatValue, Object.assign(Object.assign({}, config), {
|
||||
format
|
||||
}), down) : '-';
|
||||
const valueRender = node => cloneElement(node, {
|
||||
title: undefined
|
||||
});
|
||||
// ======================== Render ========================
|
||||
return /*#__PURE__*/React.createElement(Statistic, Object.assign({}, rest, {
|
||||
value: value,
|
||||
valueRender: valueRender,
|
||||
formatter: formatter
|
||||
}));
|
||||
};
|
||||
export default StatisticTimer;
|
||||
17
frontend/node_modules/antd/es/statistic/index.d.ts
generated
vendored
Normal file
17
frontend/node_modules/antd/es/statistic/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { CountdownProps } from './Countdown';
|
||||
import Countdown from './Countdown';
|
||||
import type { StatisticProps } from './Statistic';
|
||||
import Statistic from './Statistic';
|
||||
import type { StatisticTimerProps } from './Timer';
|
||||
import Timer from './Timer';
|
||||
export type { CountdownProps, StatisticTimerProps, StatisticProps };
|
||||
type CompoundedComponent = {
|
||||
/**
|
||||
* @deprecated Please use `Statistic.Timer` instead
|
||||
*/
|
||||
Countdown: typeof Countdown;
|
||||
Timer: typeof Timer;
|
||||
};
|
||||
export type CompoundedStatistic = typeof Statistic & CompoundedComponent;
|
||||
declare const _default: CompoundedStatistic;
|
||||
export default _default;
|
||||
8
frontend/node_modules/antd/es/statistic/index.js
generated
vendored
Normal file
8
frontend/node_modules/antd/es/statistic/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import Countdown from './Countdown';
|
||||
import Statistic from './Statistic';
|
||||
import Timer from './Timer';
|
||||
Statistic.Timer = Timer;
|
||||
Statistic.Countdown = Countdown;
|
||||
export default Statistic;
|
||||
0
frontend/node_modules/antd/es/statistic/interface.d.ts
generated
vendored
Normal file
0
frontend/node_modules/antd/es/statistic/interface.d.ts
generated
vendored
Normal file
1
frontend/node_modules/antd/es/statistic/interface.js
generated
vendored
Normal file
1
frontend/node_modules/antd/es/statistic/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
"use strict";
|
||||
16
frontend/node_modules/antd/es/statistic/style/index.d.ts
generated
vendored
Normal file
16
frontend/node_modules/antd/es/statistic/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { GetDefaultToken } from '../../theme/internal';
|
||||
export interface ComponentToken {
|
||||
/**
|
||||
* @desc 标题字体大小
|
||||
* @descEN Title font size
|
||||
*/
|
||||
titleFontSize: number;
|
||||
/**
|
||||
* @desc 内容字体大小
|
||||
* @descEN Content font size
|
||||
*/
|
||||
contentFontSize: number;
|
||||
}
|
||||
export declare const prepareComponentToken: GetDefaultToken<'Statistic'>;
|
||||
declare const _default: (prefixCls: string, rootCls?: string) => readonly [(node: React.ReactElement) => React.ReactElement, string, string];
|
||||
export default _default;
|
||||
59
frontend/node_modules/antd/es/statistic/style/index.js
generated
vendored
Normal file
59
frontend/node_modules/antd/es/statistic/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { resetComponent } from '../../style';
|
||||
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
||||
const genStatisticStyle = token => {
|
||||
const {
|
||||
componentCls,
|
||||
marginXXS,
|
||||
padding,
|
||||
colorTextDescription,
|
||||
titleFontSize,
|
||||
colorTextHeading,
|
||||
contentFontSize,
|
||||
fontFamily
|
||||
} = token;
|
||||
return {
|
||||
[componentCls]: Object.assign(Object.assign({}, resetComponent(token)), {
|
||||
[`${componentCls}-title`]: {
|
||||
marginBottom: marginXXS,
|
||||
color: colorTextDescription,
|
||||
fontSize: titleFontSize
|
||||
},
|
||||
[`${componentCls}-skeleton`]: {
|
||||
paddingTop: padding
|
||||
},
|
||||
[`${componentCls}-content`]: {
|
||||
color: colorTextHeading,
|
||||
fontSize: contentFontSize,
|
||||
fontFamily,
|
||||
[`${componentCls}-content-value`]: {
|
||||
display: 'inline-block',
|
||||
direction: 'ltr'
|
||||
},
|
||||
[`${componentCls}-content-prefix, ${componentCls}-content-suffix`]: {
|
||||
display: 'inline-block'
|
||||
},
|
||||
[`${componentCls}-content-prefix`]: {
|
||||
marginInlineEnd: marginXXS
|
||||
},
|
||||
[`${componentCls}-content-suffix`]: {
|
||||
marginInlineStart: marginXXS
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
||||
// ============================== Export ==============================
|
||||
export const prepareComponentToken = token => {
|
||||
const {
|
||||
fontSizeHeading3,
|
||||
fontSize
|
||||
} = token;
|
||||
return {
|
||||
titleFontSize: fontSize,
|
||||
contentFontSize: fontSizeHeading3
|
||||
};
|
||||
};
|
||||
export default genStyleHooks('Statistic', token => {
|
||||
const statisticToken = mergeToken(token, {});
|
||||
return genStatisticStyle(statisticToken);
|
||||
}, prepareComponentToken);
|
||||
15
frontend/node_modules/antd/es/statistic/utils.d.ts
generated
vendored
Normal file
15
frontend/node_modules/antd/es/statistic/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import type * as React from 'react';
|
||||
export type valueType = number | string;
|
||||
export type countdownValueType = number | string;
|
||||
export type Formatter = false | 'number' | 'countdown' | ((value: valueType, config?: FormatConfig) => React.ReactNode);
|
||||
export interface FormatConfig {
|
||||
formatter?: Formatter;
|
||||
decimalSeparator?: string;
|
||||
groupSeparator?: string;
|
||||
precision?: number;
|
||||
}
|
||||
export interface CountdownFormatConfig extends FormatConfig {
|
||||
format?: string;
|
||||
}
|
||||
export declare function formatTimeStr(duration: number, format: string): string;
|
||||
export declare function formatCounter(value: valueType, config: CountdownFormatConfig, down: boolean): string;
|
||||
47
frontend/node_modules/antd/es/statistic/utils.js
generated
vendored
Normal file
47
frontend/node_modules/antd/es/statistic/utils.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// Countdown
|
||||
const timeUnits = [['Y', 1000 * 60 * 60 * 24 * 365],
|
||||
// years
|
||||
['M', 1000 * 60 * 60 * 24 * 30],
|
||||
// months
|
||||
['D', 1000 * 60 * 60 * 24],
|
||||
// days
|
||||
['H', 1000 * 60 * 60],
|
||||
// hours
|
||||
['m', 1000 * 60],
|
||||
// minutes
|
||||
['s', 1000],
|
||||
// seconds
|
||||
['S', 1] // million seconds
|
||||
];
|
||||
export function formatTimeStr(duration, format) {
|
||||
let leftDuration = duration;
|
||||
const escapeRegex = /\[[^\]]*]/g;
|
||||
const keepList = (format.match(escapeRegex) || []).map(str => str.slice(1, -1));
|
||||
const templateText = format.replace(escapeRegex, '[]');
|
||||
const replacedText = timeUnits.reduce((current, [name, unit]) => {
|
||||
if (current.includes(name)) {
|
||||
const value = Math.floor(leftDuration / unit);
|
||||
leftDuration -= value * unit;
|
||||
return current.replace(new RegExp(`${name}+`, 'g'), match => {
|
||||
const len = match.length;
|
||||
return value.toString().padStart(len, '0');
|
||||
});
|
||||
}
|
||||
return current;
|
||||
}, templateText);
|
||||
let index = 0;
|
||||
return replacedText.replace(escapeRegex, () => {
|
||||
const match = keepList[index];
|
||||
index += 1;
|
||||
return match;
|
||||
});
|
||||
}
|
||||
export function formatCounter(value, config, down) {
|
||||
const {
|
||||
format = ''
|
||||
} = config;
|
||||
const target = new Date(value).getTime();
|
||||
const current = Date.now();
|
||||
const diff = down ? Math.max(target - current, 0) : Math.max(current - target, 0);
|
||||
return formatTimeStr(diff, format);
|
||||
}
|
||||
Reference in New Issue
Block a user