rc-countdown-view
Advanced tools
+3
-25
@@ -15,3 +15,3 @@ import { __rest, __read, __assign } from 'tslib'; | ||
| else { | ||
| return timestamp + ''; | ||
| return '' + timestamp; | ||
| } | ||
@@ -28,5 +28,2 @@ }; | ||
| }; | ||
| var handleEnd = function () { | ||
| onEnd === null || onEnd === void 0 ? void 0 : onEnd(); | ||
| }; | ||
| var countdownRef = useRef(); | ||
@@ -38,26 +35,7 @@ if (!countdownRef.current) { | ||
| onChange: handleChange, | ||
| onEnd: handleEnd | ||
| onEnd: onEnd | ||
| }); | ||
| } | ||
| useImperativeHandle(ref, function () { return ({ | ||
| get start() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.start.bind(countdownRef.current); | ||
| }, | ||
| get pause() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.pause.bind(countdownRef.current); | ||
| }, | ||
| get reset() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.reset.bind(countdownRef.current); | ||
| } | ||
| }); }, []); | ||
| useImperativeHandle(ref, function () { return countdownRef.current; }, []); | ||
| useEffect(function () { | ||
| if (countdownRef.current) { | ||
| countdownRef.current.options.time = time; | ||
| countdownRef.current.options.interval = interval; | ||
| } | ||
| }, [time, interval]); | ||
| useEffect(function () { | ||
| var _a; | ||
@@ -64,0 +42,0 @@ if (autoStart) { |
+3
-25
@@ -17,3 +17,3 @@ 'use strict'; | ||
| else { | ||
| return timestamp + ''; | ||
| return '' + timestamp; | ||
| } | ||
@@ -30,5 +30,2 @@ }; | ||
| }; | ||
| var handleEnd = function () { | ||
| onEnd === null || onEnd === void 0 ? void 0 : onEnd(); | ||
| }; | ||
| var countdownRef = React.useRef(); | ||
@@ -40,26 +37,7 @@ if (!countdownRef.current) { | ||
| onChange: handleChange, | ||
| onEnd: handleEnd | ||
| onEnd: onEnd | ||
| }); | ||
| } | ||
| React.useImperativeHandle(ref, function () { return ({ | ||
| get start() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.start.bind(countdownRef.current); | ||
| }, | ||
| get pause() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.pause.bind(countdownRef.current); | ||
| }, | ||
| get reset() { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return countdownRef.current.reset.bind(countdownRef.current); | ||
| } | ||
| }); }, []); | ||
| React.useImperativeHandle(ref, function () { return countdownRef.current; }, []); | ||
| React.useEffect(function () { | ||
| if (countdownRef.current) { | ||
| countdownRef.current.options.time = time; | ||
| countdownRef.current.options.interval = interval; | ||
| } | ||
| }, [time, interval]); | ||
| React.useEffect(function () { | ||
| var _a; | ||
@@ -66,0 +44,0 @@ if (autoStart) { |
+36
-36
| { | ||
| "name": "rc-countdown-view", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "description": "A simple countdown react component.", | ||
@@ -25,3 +25,4 @@ "main": "lib/index.js", | ||
| "prepublishOnly": "npm test && npm run build", | ||
| "tsc": "tsc --noEmit" | ||
| "tsc": "tsc --noEmit", | ||
| "prepare": "husky install" | ||
| }, | ||
@@ -37,6 +38,2 @@ "lint-staged": { | ||
| }, | ||
| "gitHooks": { | ||
| "pre-commit": "lint-staged", | ||
| "commit-msg": "npx --no -- commitlint --edit \"$1\"" | ||
| }, | ||
| "repository": { | ||
@@ -58,36 +55,36 @@ "type": "git", | ||
| "dependencies": { | ||
| "countdown-pro": "^2.0.1", | ||
| "tslib": "^2.4.0" | ||
| "countdown-pro": "^2.0.4", | ||
| "tslib": "^2.6.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/preset-env": "^7.19.0", | ||
| "@babel/preset-react": "^7.18.6", | ||
| "@babel/preset-typescript": "^7.18.6", | ||
| "@commitlint/cli": "^17.1.2", | ||
| "@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", | ||
| "@types/react": "^18.0.18", | ||
| "@types/react-dom": "^18.0.6", | ||
| "@types/react-test-renderer": "^18.0.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.36.2", | ||
| "@typescript-eslint/parser": "^5.36.2", | ||
| "babel-jest": "^29.0.2", | ||
| "@babel/preset-env": "^7.24.8", | ||
| "@babel/preset-react": "^7.24.7", | ||
| "@babel/preset-typescript": "^7.24.7", | ||
| "@commitlint/cli": "^17.8.1", | ||
| "@commitlint/config-conventional": "^17.8.1", | ||
| "@rollup/plugin-commonjs": "^25.0.8", | ||
| "@rollup/plugin-node-resolve": "^15.2.3", | ||
| "@rollup/plugin-typescript": "^11.1.6", | ||
| "@types/jest": "^29.5.12", | ||
| "@types/react": "^18.3.3", | ||
| "@types/react-dom": "^18.3.0", | ||
| "@types/react-test-renderer": "^18.3.0", | ||
| "@typescript-eslint/eslint-plugin": "^5.62.0", | ||
| "@typescript-eslint/parser": "^5.62.0", | ||
| "babel-jest": "^29.7.0", | ||
| "cz-conventional-changelog": "^3.3.0", | ||
| "dumi": "^1.1.47", | ||
| "dumi": "^1.1.54", | ||
| "element-remove": "^1.0.4", | ||
| "eslint": "^8.23.0", | ||
| "eslint-plugin-react": "^7.31.8", | ||
| "eslint-plugin-react-hooks": "^4.6.0", | ||
| "jest": "^29.0.2", | ||
| "lint-staged": "^13.0.3", | ||
| "prettier": "^2.7.1", | ||
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0", | ||
| "react-test-renderer": "^18.2.0", | ||
| "rollup": "^3.21.7", | ||
| "typescript": "^4.8.3", | ||
| "yorkie": "^2.0.0" | ||
| "eslint": "^8.57.0", | ||
| "eslint-plugin-react": "^7.34.4", | ||
| "eslint-plugin-react-hooks": "^4.6.2", | ||
| "husky": "^8.0.3", | ||
| "jest": "^29.7.0", | ||
| "lint-staged": "^13.3.0", | ||
| "prettier": "^2.8.8", | ||
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", | ||
| "react-test-renderer": "^18.3.1", | ||
| "rollup": "^3.29.4", | ||
| "typescript": "^4.9.5" | ||
| }, | ||
@@ -100,3 +97,6 @@ "peerDependencies": { | ||
| "react-dom": "18" | ||
| }, | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/" | ||
| } | ||
| } |
+9
-3
@@ -5,3 +5,3 @@ # rc-countdown-view | ||
| 一个简单倒计时 `react` 组件。 | ||
| 一个简单的 `React` 倒计时组件。 | ||
@@ -14,6 +14,12 @@ [查看示例][site] | ||
| npm install rc-countdown-view | ||
| # or | ||
| yarn install rc-countdown-view | ||
| ``` | ||
| ```shell | ||
| yarn add rc-countdown-view | ||
| ``` | ||
| ```shell | ||
| pnpm add rc-countdown-view | ||
| ``` | ||
| ## 示例 | ||
@@ -20,0 +26,0 @@ |
+4
-7
@@ -1,4 +0,4 @@ | ||
| import React from "react"; | ||
| import CountDownPro from "countdown-pro"; | ||
| export declare type ActionType = { | ||
| import React from 'react'; | ||
| import CountDownPro, { Options } from 'countdown-pro'; | ||
| export type ActionType = { | ||
| start: () => void; | ||
@@ -8,11 +8,8 @@ pause: () => void; | ||
| }; | ||
| export interface CountDownProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'> { | ||
| time: number; | ||
| interval?: number; | ||
| export interface CountDownProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'onChange'>, Pick<Options, 'time' | 'interval' | 'onEnd'> { | ||
| 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; |
50
13.64%10583
-14.06%119
-28.31%Updated
Updated