rc-countdown-view
Advanced tools
| import React from "react"; | ||
| import CountDownPro from "countdown-pro"; | ||
| export declare type ActionType = { | ||
| start: () => void; | ||
| pause: () => void; | ||
| reset: () => void; | ||
| }; | ||
| export interface CountDownProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> { | ||
| time: number; | ||
| interval?: number; | ||
| format?: string | ((timestamp: number, formatRes: ReturnType<typeof CountDownPro.parseTimeData>) => string); | ||
| autoStart?: boolean; | ||
| onChange?: (formatTime: string) => void; | ||
| onEnd?: () => void; | ||
| } | ||
| declare const CountDown: React.ForwardRefExoticComponent<CountDownProps & React.RefAttributes<ActionType>>; | ||
| export default CountDown; |
+6
-4
@@ -1,4 +0,5 @@ | ||
| import { __assign, __read, __rest } from "tslib"; | ||
| import React, { forwardRef, useState, useEffect, useImperativeHandle, useRef } from "react"; | ||
| import CountDownPro from "countdown-pro"; | ||
| import { __rest, __read, __assign } from 'tslib'; | ||
| import React, { forwardRef, useRef, useState, useImperativeHandle, useEffect } from 'react'; | ||
| import CountDownPro from 'countdown-pro'; | ||
| var CountDown = forwardRef(function (_a, ref) { | ||
@@ -73,2 +74,3 @@ var _b = _a.time, time = _b === void 0 ? 0 : _b, _c = _a.interval, interval = _c === void 0 ? 1000 : _c, _d = _a.format, format = _d === void 0 ? 'HH:mm:ss' : _d, _e = _a.autoStart, autoStart = _e === void 0 ? true : _e, onChange = _a.onChange, onEnd = _a.onEnd, restProps = __rest(_a, ["time", "interval", "format", "autoStart", "onChange", "onEnd"]); | ||
| CountDown.displayName = 'CountDown'; | ||
| export default CountDown; | ||
| export { CountDown as default }; |
+20
-18
@@ -1,14 +0,15 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var tslib_1 = require("tslib"); | ||
| var react_1 = tslib_1.__importStar(require("react")); | ||
| var countdown_pro_1 = tslib_1.__importDefault(require("countdown-pro")); | ||
| var CountDown = (0, react_1.forwardRef)(function (_a, ref) { | ||
| var _b = _a.time, time = _b === void 0 ? 0 : _b, _c = _a.interval, interval = _c === void 0 ? 1000 : _c, _d = _a.format, format = _d === void 0 ? 'HH:mm:ss' : _d, _e = _a.autoStart, autoStart = _e === void 0 ? true : _e, onChange = _a.onChange, onEnd = _a.onEnd, restProps = tslib_1.__rest(_a, ["time", "interval", "format", "autoStart", "onChange", "onEnd"]); | ||
| 'use strict'; | ||
| var tslib = require('tslib'); | ||
| var React = require('react'); | ||
| var CountDownPro = require('countdown-pro'); | ||
| var CountDown = React.forwardRef(function (_a, ref) { | ||
| var _b = _a.time, time = _b === void 0 ? 0 : _b, _c = _a.interval, interval = _c === void 0 ? 1000 : _c, _d = _a.format, format = _d === void 0 ? 'HH:mm:ss' : _d, _e = _a.autoStart, autoStart = _e === void 0 ? true : _e, onChange = _a.onChange, onEnd = _a.onEnd, restProps = tslib.__rest(_a, ["time", "interval", "format", "autoStart", "onChange", "onEnd"]); | ||
| var formatTime = function (timestamp) { | ||
| if (typeof format === 'string') { | ||
| return countdown_pro_1.default.format(timestamp, format); | ||
| return CountDownPro.format(timestamp, format); | ||
| } | ||
| else if (format instanceof Function) { | ||
| return format(timestamp, countdown_pro_1.default.parseTimeData(timestamp)); | ||
| return format(timestamp, CountDownPro.parseTimeData(timestamp)); | ||
| } | ||
@@ -19,4 +20,4 @@ else { | ||
| }; | ||
| var unmountedRef = (0, react_1.useRef)(false); | ||
| var _f = tslib_1.__read((0, react_1.useState)(function () { return formatTime(time); }), 2), timeState = _f[0], setTimeState = _f[1]; | ||
| var unmountedRef = React.useRef(false); | ||
| var _f = tslib.__read(React.useState(function () { return formatTime(time); }), 2), timeState = _f[0], setTimeState = _f[1]; | ||
| var handleChange = function (currentTime) { | ||
@@ -32,5 +33,5 @@ if (!unmountedRef.current) { | ||
| }; | ||
| var countdownRef = (0, react_1.useRef)(); | ||
| var countdownRef = React.useRef(); | ||
| if (!countdownRef.current) { | ||
| countdownRef.current = new countdown_pro_1.default({ | ||
| countdownRef.current = new CountDownPro({ | ||
| time: time, | ||
@@ -42,3 +43,3 @@ interval: interval, | ||
| } | ||
| (0, react_1.useImperativeHandle)(ref, function () { return ({ | ||
| React.useImperativeHandle(ref, function () { return ({ | ||
| get start() { | ||
@@ -57,3 +58,3 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| }); }, []); | ||
| (0, react_1.useEffect)(function () { | ||
| React.useEffect(function () { | ||
| if (countdownRef.current) { | ||
@@ -64,3 +65,3 @@ countdownRef.current.options.time = time; | ||
| }, [time, interval]); | ||
| (0, react_1.useEffect)(function () { | ||
| React.useEffect(function () { | ||
| var _a; | ||
@@ -77,5 +78,6 @@ if (autoStart) { | ||
| }, []); | ||
| return react_1.default.createElement("span", tslib_1.__assign({}, restProps), timeState); | ||
| return React.createElement("span", tslib.__assign({}, restProps), timeState); | ||
| }); | ||
| CountDown.displayName = 'CountDown'; | ||
| exports.default = CountDown; | ||
| module.exports = CountDown; |
+16
-8
| { | ||
| "name": "rc-countdown-view", | ||
| "version": "2.0.0", | ||
| "version": "2.0.1", | ||
| "description": "A simple countdown react component.", | ||
| "main": "lib/index.js", | ||
| "module": "es/index.js", | ||
| "types": "types/index.d.ts", | ||
| "files": [ | ||
| "es", | ||
| "lib" | ||
| "lib", | ||
| "types" | ||
| ], | ||
@@ -15,5 +17,5 @@ "scripts": { | ||
| "doc": "dumi build", | ||
| "build": "npm run build:cjs && npm run build:es", | ||
| "build:cjs": "rm -rf lib && tsc --outDir lib -t es5 -m commonjs", | ||
| "build:es": "rm -rf es && tsc --outDir es -t es5 -m es2015", | ||
| "build": "npm run build:module && npm run build:types", | ||
| "build:module": "rm -rf lib && rm -rf es && rollup -c", | ||
| "build:types": "rm -rf types && tsc -p tsconfig.build.json --outDir types -d --emitDeclarationOnly", | ||
| "lint": "eslint --ext .js,.jsx,.ts,.tsx src", | ||
@@ -23,3 +25,4 @@ "lint-fix": "npm run lint -- --fix", | ||
| "commit": "cz", | ||
| "prepublishOnly": "npm test && npm run build" | ||
| "prepublishOnly": "npm test && npm run build", | ||
| "tsc": "tsc --noEmit" | ||
| }, | ||
@@ -55,3 +58,3 @@ "lint-staged": { | ||
| "dependencies": { | ||
| "countdown-pro": "^2.0.0", | ||
| "countdown-pro": "^2.0.1", | ||
| "tslib": "^2.4.0" | ||
@@ -65,2 +68,5 @@ }, | ||
| "@commitlint/config-conventional": "^17.1.0", | ||
| "@rollup/plugin-commonjs": "^25.0.0", | ||
| "@rollup/plugin-node-resolve": "^15.0.2", | ||
| "@rollup/plugin-typescript": "^11.1.1", | ||
| "@types/jest": "^29.0.0", | ||
@@ -75,2 +81,3 @@ "@types/react": "^18.0.18", | ||
| "dumi": "^1.1.47", | ||
| "element-remove": "^1.0.4", | ||
| "eslint": "^8.23.0", | ||
@@ -85,2 +92,3 @@ "eslint-plugin-react": "^7.31.8", | ||
| "react-test-renderer": "^18.2.0", | ||
| "rollup": "^3.21.7", | ||
| "typescript": "^4.8.3", | ||
@@ -90,3 +98,3 @@ "yorkie": "^2.0.0" | ||
| "peerDependencies": { | ||
| "react": "^16.8.6" | ||
| "react": ">=16.8.6" | ||
| }, | ||
@@ -93,0 +101,0 @@ "resolutions": { |
| import React from "react"; | ||
| import CountDownPro from "countdown-pro"; | ||
| export declare type ActionType = { | ||
| start: () => void; | ||
| pause: () => void; | ||
| reset: () => void; | ||
| }; | ||
| export interface CountDownProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> { | ||
| time: number; | ||
| interval?: number; | ||
| format?: string | ((timestamp: number, formatRes: ReturnType<typeof CountDownPro.parseTimeData>) => string); | ||
| autoStart?: boolean; | ||
| onChange?: (formatTime: string) => void; | ||
| onEnd?: () => void; | ||
| } | ||
| declare const CountDown: React.ForwardRefExoticComponent<CountDownProps & React.RefAttributes<ActionType>>; | ||
| export default CountDown; |
| import React from "react"; | ||
| import CountDownPro from "countdown-pro"; | ||
| export declare type ActionType = { | ||
| start: () => void; | ||
| pause: () => void; | ||
| reset: () => void; | ||
| }; | ||
| export interface CountDownProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> { | ||
| time: number; | ||
| interval?: number; | ||
| format?: string | ((timestamp: number, formatRes: ReturnType<typeof CountDownPro.parseTimeData>) => string); | ||
| autoStart?: boolean; | ||
| onChange?: (formatTime: string) => void; | ||
| onEnd?: () => void; | ||
| } | ||
| declare const CountDown: React.ForwardRefExoticComponent<CountDownProps & React.RefAttributes<ActionType>>; | ||
| export default CountDown; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
0
-100%12314
-4.39%30
20%6
-14.29%166
-9.78%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated