react-kui 3.2.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/kui-components.json +819 -162
- package/es/_virtual/_rolldown/runtime.js +2 -3
- package/es/affix/index.js +73 -185
- package/es/alert/index.js +3 -4
- package/es/anchor/anchor-context.js +2 -3
- package/es/anchor/anchor-link.js +3 -4
- package/es/anchor/anchor.js +195 -398
- package/es/auto-complete/index.js +160 -561
- package/es/avatar/avatar-group-context.js +2 -3
- package/es/avatar/avatar-group.js +32 -124
- package/es/avatar/avatar.js +58 -159
- package/es/back-top/index.js +66 -201
- package/es/badge/index.js +4 -5
- package/es/base/teleport.js +22 -54
- package/es/base/transition-props.js +2 -3
- package/es/base/transition.js +2 -3
- package/es/breadcrumb/breadcrumb-context.js +2 -3
- package/es/breadcrumb/breadcrumb-item.js +19 -102
- package/es/breadcrumb/breadcrumb.js +10 -59
- package/es/button/button-group-context.js +2 -3
- package/es/button/button-group.js +15 -75
- package/es/button/button.js +4 -5
- package/es/calendar/index.js +4 -5
- package/es/card/index.js +4 -5
- package/es/carousel/carousel-context.js +2 -3
- package/es/carousel/carousel-item.js +3 -4
- package/es/carousel/carousel.js +281 -628
- package/es/carousel/drag.js +2 -3
- package/es/cascader/index.js +7 -8
- package/es/check-card/check-card-group.js +53 -179
- package/es/check-card/check-card.js +100 -293
- package/es/check-card/context.js +2 -3
- package/es/checkbox/checkbox-group-context.js +2 -3
- package/es/checkbox/checkbox-group.js +34 -138
- package/es/checkbox/checkbox.js +4 -5
- package/es/checkbox/index.js +2 -3
- package/es/collapse/collapse-panel.js +84 -206
- package/es/collapse/collapse.js +38 -170
- package/es/color-picker/alpha.js +44 -125
- package/es/color-picker/hue.js +39 -108
- package/es/color-picker/index.js +7 -6
- package/es/color-picker/mode.js +76 -159
- package/es/color-picker/paint.js +66 -163
- package/es/color-picker/presets.js +12 -44
- package/es/components.js +37 -32
- package/es/config/config-context.js +2 -3
- package/es/config/context.js +2 -3
- package/es/config/index.js +3 -4
- package/es/config/popup-host.js +3 -4
- package/es/config/size-context.js +2 -3
- package/es/config/use-config-appearance.js +3 -4
- package/es/const/var.js +2 -3
- package/es/date-picker/index.js +8 -9
- package/es/descriptions/descriptions-item.js +3 -4
- package/es/descriptions/descriptions.js +53 -144
- package/es/divider/index.js +2 -3
- package/es/drawer/index.js +171 -465
- package/es/dropdown/dropdown-button.js +25 -128
- package/es/dropdown/dropdown-context.js +2 -3
- package/es/dropdown/dropdown.js +56 -207
- package/es/dropdown/trigger.js +37 -125
- package/es/empty/index.js +34 -111
- package/es/feature-card/index.js +2 -3
- package/es/feedback-panel/index.js +30 -155
- package/es/flame-wrap/index.js +3 -4
- package/es/flame-wrap/types.js +2 -3
- package/es/flex/index.js +2 -3
- package/es/form/field-context.js +3 -4
- package/es/form/form-context.js +2 -3
- package/es/form/form-item.js +4 -5
- package/es/form/form.js +108 -279
- package/es/form/utils.js +2 -3
- package/es/gradient-picker/corners.js +55 -0
- package/es/gradient-picker/index.js +191 -0
- package/es/gradient-picker/stops.js +219 -0
- package/es/gradient-picker/types.js +147 -0
- package/es/grid/grid-item.js +25 -116
- package/es/grid/grid.js +40 -151
- package/es/grid/useBreakpoint.js +3 -4
- package/es/icon/index.js +24 -126
- package/es/image/group.js +3 -4
- package/es/image/image-group-context.js +2 -3
- package/es/image/image.js +5 -6
- package/es/image/instance.js +2 -3
- package/es/image/preview.js +4 -5
- package/es/image/utils.js +2 -3
- package/es/index.js +5 -4
- package/es/input/index.js +2 -3
- package/es/input/input-base.js +4 -5
- package/es/input/input-box.js +2 -3
- package/es/input/input-group.js +4 -5
- package/es/input/input.js +3 -4
- package/es/input/textarea.js +3 -4
- package/es/input-number/drag.js +63 -0
- package/es/input-number/index.js +41 -11
- package/es/input-otp/index.js +3 -4
- package/es/input-tag/index.js +5 -6
- package/es/kanban/index.js +31 -168
- package/es/layout/index.js +43 -215
- package/es/layout/layout-context.js +2 -3
- package/es/list-panel/index.js +47 -185
- package/es/loading/index.js +2 -3
- package/es/loading/loading-bar.js +54 -114
- package/es/locale/de.js +2 -3
- package/es/locale/el.js +2 -3
- package/es/locale/en.js +2 -3
- package/es/locale/fr.js +2 -3
- package/es/locale/it.js +2 -3
- package/es/locale/ja.js +2 -3
- package/es/locale/ko.js +2 -3
- package/es/locale/ru.js +2 -3
- package/es/locale/th.js +2 -3
- package/es/locale/uk.js +2 -3
- package/es/locale/vi.js +2 -3
- package/es/locale/zh-CN.js +2 -3
- package/es/locale/zh-TW.js +2 -3
- package/es/mentions/index.js +214 -581
- package/es/menu/menu-context.js +2 -3
- package/es/menu/menu-divider.js +3 -4
- package/es/menu/menu-group.js +3 -4
- package/es/menu/menu-item.js +2 -3
- package/es/menu/menu-keyboard.js +2 -3
- package/es/menu/menu.js +184 -442
- package/es/menu/recursive-menu.js +3 -4
- package/es/menu/sub-menu.js +5 -6
- package/es/message/index.js +2 -3
- package/es/modal/api.js +2 -3
- package/es/modal/modal.js +263 -599
- package/es/modal/toast.js +63 -179
- package/es/node_modules/.pnpm/kui-icons@5.0.0/node_modules/kui-icons/dist/kui-icons.esm.js +2 -3
- package/es/notice/container.js +2 -3
- package/es/notice/content.js +4 -5
- package/es/notice/index.js +2 -3
- package/es/notice/instance.js +2 -3
- package/es/page/index.js +4 -5
- package/es/page/responsive.js +2 -3
- package/es/page-header/index.js +3 -4
- package/es/popconfirm/index.js +24 -70
- package/es/poptip/index.js +29 -88
- package/es/popup/index.js +8 -6
- package/es/popup/layers.js +2 -3
- package/es/progress/index.js +95 -229
- package/es/qrcode/index.js +3 -4
- package/es/radio/radio-button.js +37 -131
- package/es/radio/radio-group-context.js +2 -3
- package/es/radio/radio-group.js +69 -223
- package/es/radio/radio.js +3 -4
- package/es/rate/index.js +68 -226
- package/es/rate/star.js +38 -129
- package/es/result/index.js +35 -127
- package/es/ripple/index.js +3 -4
- package/es/ripple/types.js +2 -3
- package/es/row-col/col.js +59 -149
- package/es/row-col/row.js +2 -3
- package/es/segmented/index.js +66 -210
- package/es/select/option.js +23 -116
- package/es/select/select.js +9 -10
- package/es/skeleton/skeleton-avatar.js +2 -3
- package/es/skeleton/skeleton-button.js +2 -3
- package/es/skeleton/skeleton-image.js +28 -108
- package/es/skeleton/skeleton-text.js +17 -93
- package/es/skeleton/skeleton.js +46 -133
- package/es/skeleton/use-skeleton-loading.js +3 -4
- package/es/slider/index.js +92 -286
- package/es/slider/thumb.js +43 -133
- package/es/space/index.js +3 -4
- package/es/spin/index.js +2 -3
- package/es/splitter/splitter-panel.js +3 -4
- package/es/splitter/splitter.js +77 -219
- package/es/stat-card/countup.js +46 -141
- package/es/stat-card/rollup.js +27 -105
- package/es/stat-card/stat-card.js +3 -4
- package/es/stat-card/stat-number.js +26 -113
- package/es/stat-card/utils/countup.js +2 -3
- package/es/stat-card/utils/odometer.js +2 -3
- package/es/stat-card/utils/stat-item-key.js +2 -3
- package/es/steps/index.js +45 -123
- package/es/switch/index.js +4 -5
- package/es/table/column-setting.js +43 -139
- package/es/table/index.js +8 -9
- package/es/table/utils.js +2 -3
- package/es/tabs/tab-panel.js +19 -71
- package/es/tabs/tabs.js +6 -7
- package/es/tag/index.js +4 -5
- package/es/time-line/timeline-item.js +3 -4
- package/es/time-line/timeline.js +8 -44
- package/es/tooltip/index.js +41 -142
- package/es/tour/index.js +138 -356
- package/es/transfer/index.js +184 -487
- package/es/tree/index.js +8 -9
- package/es/tree/utils.js +2 -3
- package/es/tree-select/index.js +8 -9
- package/es/typography/index.js +75 -306
- package/es/upload/file-list.js +95 -119
- package/es/upload/index.js +8 -9
- package/es/upload/picture-sort.js +2 -3
- package/es/upload/selector.js +63 -193
- package/es/utils/checked.js +2 -3
- package/es/utils/color.js +2 -3
- package/es/utils/css.js +2 -3
- package/es/utils/focus.js +2 -3
- package/es/utils/number.js +2 -3
- package/es/utils/overlay-order.js +2 -3
- package/es/utils/overlay-stack.js +3 -4
- package/es/utils/placement.js +16 -4
- package/es/utils/popup-arrow.js +45 -0
- package/es/utils/popup.js +2 -3
- package/es/utils/promise.js +2 -3
- package/es/utils/react-node.js +2 -3
- package/es/utils/selection-tags.js +2 -3
- package/es/utils/share.js +2 -3
- package/es/utils/theme.js +2 -3
- package/es/utils/transition.js +2 -3
- package/es/utils/use-value.js +3 -4
- package/es/virtual-list/index.js +49 -187
- package/es/virtual-list/range.js +2 -3
- package/es/watermark/index.js +149 -289
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +1 -1
- package/lib/locale/el.cjs +1 -1
- package/lib/locale/en.cjs +1 -1
- package/lib/locale/fr.cjs +1 -1
- package/lib/locale/it.cjs +1 -1
- package/lib/locale/ja.cjs +1 -1
- package/lib/locale/ko.cjs +1 -1
- package/lib/locale/ru.cjs +1 -1
- package/lib/locale/th.cjs +1 -1
- package/lib/locale/uk.cjs +1 -1
- package/lib/locale/vi.cjs +1 -1
- package/lib/locale/zh-CN.cjs +1 -1
- package/lib/locale/zh-TW.cjs +1 -1
- package/package.json +24 -24
- package/style/base.css +1 -1
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/theme.css +1 -1
- package/types/affix/index.d.cts +1 -1
- package/types/affix/index.d.ts +1 -1
- package/types/anchor/anchor-link.d.cts +1 -1
- package/types/anchor/anchor-link.d.ts +1 -1
- package/types/anchor/anchor.d.cts +1 -1
- package/types/anchor/anchor.d.ts +1 -1
- package/types/back-top/index.d.cts +1 -1
- package/types/back-top/index.d.ts +1 -1
- package/types/carousel/carousel-item.d.cts +1 -1
- package/types/carousel/carousel-item.d.ts +1 -1
- package/types/cascader/index.d.cts +1 -1
- package/types/cascader/index.d.ts +1 -1
- package/types/color-picker/alpha.d.cts +1 -1
- package/types/color-picker/alpha.d.ts +1 -1
- package/types/color-picker/hue.d.cts +1 -1
- package/types/color-picker/hue.d.ts +1 -1
- package/types/color-picker/index.d.cts +3 -2
- package/types/color-picker/index.d.ts +3 -2
- package/types/color-picker/mode.d.cts +1 -1
- package/types/color-picker/mode.d.ts +1 -1
- package/types/color-picker/paint.d.cts +1 -1
- package/types/color-picker/paint.d.ts +1 -1
- package/types/color-picker/presets.d.cts +1 -1
- package/types/color-picker/presets.d.ts +1 -1
- package/types/components.d.cts +3 -0
- package/types/components.d.ts +3 -0
- package/types/date-picker/index.d.cts +2 -2
- package/types/date-picker/index.d.ts +2 -2
- package/types/feature-card/index.d.cts +1 -1
- package/types/feature-card/index.d.ts +1 -1
- package/types/feedback-panel/index.d.cts +1 -1
- package/types/feedback-panel/index.d.ts +1 -1
- package/types/flame-wrap/index.d.cts +1 -1
- package/types/flame-wrap/index.d.ts +1 -1
- package/types/form/form-item.d.cts +1 -1
- package/types/form/form-item.d.ts +1 -1
- package/types/gradient-picker/corners.d.cts +8 -0
- package/types/gradient-picker/corners.d.ts +8 -0
- package/types/gradient-picker/index.d.cts +25 -0
- package/types/gradient-picker/index.d.ts +25 -0
- package/types/gradient-picker/stops.d.cts +12 -0
- package/types/gradient-picker/stops.d.ts +12 -0
- package/types/gradient-picker/types.d.cts +34 -0
- package/types/gradient-picker/types.d.ts +34 -0
- package/types/grid/grid-item.d.cts +1 -1
- package/types/grid/grid-item.d.ts +1 -1
- package/types/grid/grid.d.cts +1 -1
- package/types/grid/grid.d.ts +1 -1
- package/types/image/group.d.cts +1 -1
- package/types/image/group.d.ts +1 -1
- package/types/input-number/drag.d.cts +9 -0
- package/types/input-number/drag.d.ts +9 -0
- package/types/input-number/index.d.cts +1 -0
- package/types/input-number/index.d.ts +1 -0
- package/types/kanban/index.d.cts +1 -1
- package/types/kanban/index.d.ts +1 -1
- package/types/list-panel/index.d.cts +1 -1
- package/types/list-panel/index.d.ts +1 -1
- package/types/loading/loading-bar.d.cts +1 -1
- package/types/loading/loading-bar.d.ts +1 -1
- package/types/modal/toast.d.cts +1 -1
- package/types/modal/toast.d.ts +1 -1
- package/types/notice/content.d.cts +2 -2
- package/types/notice/content.d.ts +2 -2
- package/types/page-header/index.d.cts +1 -1
- package/types/page-header/index.d.ts +1 -1
- package/types/popconfirm/index.d.cts +1 -0
- package/types/popconfirm/index.d.ts +1 -0
- package/types/poptip/index.d.cts +1 -0
- package/types/poptip/index.d.ts +1 -0
- package/types/popup/index.d.cts +1 -0
- package/types/popup/index.d.ts +1 -0
- package/types/result/index.d.cts +1 -1
- package/types/result/index.d.ts +1 -1
- package/types/ripple/index.d.cts +1 -1
- package/types/ripple/index.d.ts +1 -1
- package/types/slider/index.d.cts +1 -1
- package/types/slider/index.d.ts +1 -1
- package/types/splitter/splitter-panel.d.cts +1 -1
- package/types/splitter/splitter-panel.d.ts +1 -1
- package/types/splitter/splitter.d.cts +1 -1
- package/types/splitter/splitter.d.ts +1 -1
- package/types/stat-card/countup.d.cts +1 -1
- package/types/stat-card/countup.d.ts +1 -1
- package/types/stat-card/rollup.d.cts +1 -1
- package/types/stat-card/rollup.d.ts +1 -1
- package/types/stat-card/stat-card.d.cts +1 -1
- package/types/stat-card/stat-card.d.ts +1 -1
- package/types/stat-card/stat-number.d.cts +1 -1
- package/types/stat-card/stat-number.d.ts +1 -1
- package/types/table/column-setting.d.cts +1 -1
- package/types/table/column-setting.d.ts +1 -1
- package/types/table/index.d.cts +1 -1
- package/types/table/index.d.ts +1 -1
- package/types/time-line/timeline-item.d.cts +1 -1
- package/types/time-line/timeline-item.d.ts +1 -1
- package/types/time-line/timeline.d.cts +1 -1
- package/types/time-line/timeline.d.ts +1 -1
- package/types/tooltip/index.d.cts +1 -0
- package/types/tooltip/index.d.ts +1 -0
- package/types/transfer/index.d.cts +1 -1
- package/types/transfer/index.d.ts +1 -1
- package/types/tree-select/index.d.cts +1 -1
- package/types/tree-select/index.d.ts +1 -1
- package/types/upload/file-list.d.cts +1 -1
- package/types/upload/file-list.d.ts +1 -1
- package/types/upload/selector.d.cts +1 -1
- package/types/upload/selector.d.ts +1 -1
- package/types/utils/placement.d.cts +2 -1
- package/types/utils/placement.d.ts +2 -1
- package/types/utils/popup-arrow.d.cts +5 -0
- package/types/utils/popup-arrow.d.ts +5 -0
- package/types/utils/selection-tags.d.cts +1 -1
- package/types/utils/selection-tags.d.ts +1 -1
- package/types/watermark/index.d.cts +1 -1
- package/types/watermark/index.d.ts +1 -1
package/es/stat-card/countup.js
CHANGED
|
@@ -1,161 +1,66 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Odometer } from "./utils/odometer.js";
|
|
10
9
|
import { CountUp } from "./utils/countup.js";
|
|
11
|
-
import {
|
|
10
|
+
import { Odometer } from "./utils/odometer.js";
|
|
12
11
|
import clsx from "clsx";
|
|
13
12
|
import { useEffect, useRef } from "react";
|
|
14
13
|
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
|
|
16
|
-
function CountUpNumber(
|
|
17
|
-
const $ = c(29);
|
|
18
|
-
let className;
|
|
19
|
-
let rest;
|
|
20
|
-
let t1;
|
|
21
|
-
let t2;
|
|
22
|
-
let t3;
|
|
23
|
-
let t4;
|
|
24
|
-
let t5;
|
|
25
|
-
let t6;
|
|
26
|
-
let value;
|
|
27
|
-
if ($[0] !== t0) {
|
|
28
|
-
({value, separator: t1, duration: t2, precision: t3, type: t4, autoAnimate: t5, autoAnimateOnce: t6, className, ...rest} = t0);
|
|
29
|
-
$[0] = t0;
|
|
30
|
-
$[1] = className;
|
|
31
|
-
$[2] = rest;
|
|
32
|
-
$[3] = t1;
|
|
33
|
-
$[4] = t2;
|
|
34
|
-
$[5] = t3;
|
|
35
|
-
$[6] = t4;
|
|
36
|
-
$[7] = t5;
|
|
37
|
-
$[8] = t6;
|
|
38
|
-
$[9] = value;
|
|
39
|
-
} else {
|
|
40
|
-
className = $[1];
|
|
41
|
-
rest = $[2];
|
|
42
|
-
t1 = $[3];
|
|
43
|
-
t2 = $[4];
|
|
44
|
-
t3 = $[5];
|
|
45
|
-
t4 = $[6];
|
|
46
|
-
t5 = $[7];
|
|
47
|
-
t6 = $[8];
|
|
48
|
-
value = $[9];
|
|
49
|
-
}
|
|
50
|
-
const separator = t1 === void 0 ? "," : t1;
|
|
51
|
-
const duration = t2 === void 0 ? 1.2 : t2;
|
|
52
|
-
const precision = t3 === void 0 ? 0 : t3;
|
|
53
|
-
const type = t4 === void 0 ? "countup" : t4;
|
|
54
|
-
const autoAnimate = t5 === void 0 ? false : t5;
|
|
55
|
-
const autoAnimateOnce = t6 === void 0 ? false : t6;
|
|
14
|
+
// components/stat-card/countup.tsx
|
|
15
|
+
function CountUpNumber({ value, separator = ",", duration = 1.2, precision = 0, type = "countup", autoAnimate = false, autoAnimateOnce = false, className, ...rest }) {
|
|
56
16
|
const elementRef = useRef(null);
|
|
57
17
|
const countRef = useRef(null);
|
|
58
18
|
const currentValue = value ?? 0;
|
|
59
19
|
const latestValueRef = useRef(currentValue);
|
|
60
20
|
const renderedValueRef = useRef(currentValue);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
$[12] = t8;
|
|
71
|
-
} else {
|
|
72
|
-
t7 = $[11];
|
|
73
|
-
t8 = $[12];
|
|
74
|
-
}
|
|
75
|
-
useEffect(t7, t8);
|
|
76
|
-
let t10;
|
|
77
|
-
let t9;
|
|
78
|
-
if ($[13] !== autoAnimate || $[14] !== autoAnimateOnce || $[15] !== duration || $[16] !== precision || $[17] !== separator || $[18] !== type) {
|
|
79
|
-
t9 = () => {
|
|
80
|
-
if (!elementRef.current) return;
|
|
81
|
-
const observeVisibility = autoAnimate && typeof IntersectionObserver !== "undefined";
|
|
82
|
-
const safeDuration = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches || !Number.isFinite(duration) ? 0 : Math.max(0, duration);
|
|
83
|
-
const options = {
|
|
84
|
-
duration: type === "rollup" ? 0 : safeDuration,
|
|
85
|
-
separator,
|
|
86
|
-
decimalPlaces: Number.isFinite(precision) ? Math.min(100, Math.max(0, Math.floor(precision))) : 0,
|
|
87
|
-
autoAnimate: observeVisibility,
|
|
88
|
-
autoAnimateOnce,
|
|
89
|
-
plugin: type === "rollup" ? new Odometer({
|
|
90
|
-
duration: safeDuration,
|
|
91
|
-
mode: "continuous"
|
|
92
|
-
}) : void 0
|
|
93
|
-
};
|
|
94
|
-
const count = new CountUp(elementRef.current, latestValueRef.current, options);
|
|
95
|
-
countRef.current = count;
|
|
96
|
-
renderedValueRef.current = latestValueRef.current;
|
|
97
|
-
if (!observeVisibility) count.start();
|
|
98
|
-
return () => {
|
|
99
|
-
count.onDestroy();
|
|
100
|
-
if (countRef.current === count) countRef.current = null;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
t10 = [
|
|
104
|
-
autoAnimate,
|
|
105
|
-
autoAnimateOnce,
|
|
106
|
-
duration,
|
|
107
|
-
precision,
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
latestValueRef.current = currentValue;
|
|
23
|
+
}, [currentValue]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!elementRef.current) return;
|
|
26
|
+
const observeVisibility = autoAnimate && typeof IntersectionObserver !== "undefined";
|
|
27
|
+
const safeDuration = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches || !Number.isFinite(duration) ? 0 : Math.max(0, duration);
|
|
28
|
+
const options = {
|
|
29
|
+
duration: type === "rollup" ? 0 : safeDuration,
|
|
108
30
|
separator,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let t11;
|
|
125
|
-
let t12;
|
|
126
|
-
if ($[21] !== currentValue) {
|
|
127
|
-
t11 = () => {
|
|
128
|
-
if (renderedValueRef.current === currentValue) return;
|
|
129
|
-
renderedValueRef.current = currentValue;
|
|
130
|
-
countRef.current?.update(currentValue);
|
|
31
|
+
decimalPlaces: Number.isFinite(precision) ? Math.min(100, Math.max(0, Math.floor(precision))) : 0,
|
|
32
|
+
autoAnimate: observeVisibility,
|
|
33
|
+
autoAnimateOnce,
|
|
34
|
+
plugin: type === "rollup" ? new Odometer({
|
|
35
|
+
duration: safeDuration,
|
|
36
|
+
mode: "continuous"
|
|
37
|
+
}) : void 0
|
|
38
|
+
};
|
|
39
|
+
const count = new CountUp(elementRef.current, latestValueRef.current, options);
|
|
40
|
+
countRef.current = count;
|
|
41
|
+
renderedValueRef.current = latestValueRef.current;
|
|
42
|
+
if (!observeVisibility) count.start();
|
|
43
|
+
return () => {
|
|
44
|
+
count.onDestroy();
|
|
45
|
+
if (countRef.current === count) countRef.current = null;
|
|
131
46
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
useEffect(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
...rest,
|
|
151
|
-
ref: elementRef,
|
|
152
|
-
className: t13
|
|
153
|
-
});
|
|
154
|
-
$[26] = rest;
|
|
155
|
-
$[27] = t13;
|
|
156
|
-
$[28] = t14;
|
|
157
|
-
} else t14 = $[28];
|
|
158
|
-
return t14;
|
|
47
|
+
}, [
|
|
48
|
+
autoAnimate,
|
|
49
|
+
autoAnimateOnce,
|
|
50
|
+
duration,
|
|
51
|
+
precision,
|
|
52
|
+
separator,
|
|
53
|
+
type
|
|
54
|
+
]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (renderedValueRef.current === currentValue) return;
|
|
57
|
+
renderedValueRef.current = currentValue;
|
|
58
|
+
countRef.current?.update(currentValue);
|
|
59
|
+
}, [currentValue]);
|
|
60
|
+
return /* @__PURE__ */ jsx("span", {
|
|
61
|
+
...rest,
|
|
62
|
+
ref: elementRef,
|
|
63
|
+
className: clsx("k-stat-countup-number", className)
|
|
64
|
+
});
|
|
159
65
|
}
|
|
160
|
-
//#endregion
|
|
161
66
|
export { CountUpNumber as default };
|
package/es/stat-card/rollup.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
@@ -7,116 +7,38 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { Odometer } from "./utils/odometer.js";
|
|
10
|
-
import { c } from "react/compiler-runtime";
|
|
11
10
|
import clsx from "clsx";
|
|
12
11
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
13
12
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
function RollUp(
|
|
16
|
-
const $ = c(27);
|
|
17
|
-
let className;
|
|
18
|
-
let rest;
|
|
19
|
-
let t1;
|
|
20
|
-
let t2;
|
|
21
|
-
let t3;
|
|
22
|
-
let text;
|
|
23
|
-
if ($[0] !== t0) {
|
|
24
|
-
({value: t1, text, duration: t2, precision: t3, className, ...rest} = t0);
|
|
25
|
-
$[0] = t0;
|
|
26
|
-
$[1] = className;
|
|
27
|
-
$[2] = rest;
|
|
28
|
-
$[3] = t1;
|
|
29
|
-
$[4] = t2;
|
|
30
|
-
$[5] = t3;
|
|
31
|
-
$[6] = text;
|
|
32
|
-
} else {
|
|
33
|
-
className = $[1];
|
|
34
|
-
rest = $[2];
|
|
35
|
-
t1 = $[3];
|
|
36
|
-
t2 = $[4];
|
|
37
|
-
t3 = $[5];
|
|
38
|
-
text = $[6];
|
|
39
|
-
}
|
|
40
|
-
const value = t1 === void 0 ? 0 : t1;
|
|
41
|
-
const duration = t2 === void 0 ? .3 : t2;
|
|
42
|
-
const precision = t3 === void 0 ? 0 : t3;
|
|
13
|
+
// components/stat-card/rollup.tsx
|
|
14
|
+
function RollUp({ value = 0, text, duration = .3, precision = 0, className, ...rest }) {
|
|
43
15
|
const element = useRef(null);
|
|
44
16
|
const odometer = useRef(null);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
maximumFractionDigits: precision
|
|
50
|
-
}).format(value);
|
|
51
|
-
$[7] = precision;
|
|
52
|
-
$[8] = text;
|
|
53
|
-
$[9] = value;
|
|
54
|
-
$[10] = t4;
|
|
55
|
-
} else t4 = $[10];
|
|
56
|
-
const formatted = t4;
|
|
17
|
+
const formatted = text ?? new Intl.NumberFormat("en-US", {
|
|
18
|
+
minimumFractionDigits: precision,
|
|
19
|
+
maximumFractionDigits: precision
|
|
20
|
+
}).format(value);
|
|
57
21
|
const [initialText] = useState(formatted);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
odometer.current =
|
|
64
|
-
return () => {
|
|
65
|
-
instance.destroy();
|
|
66
|
-
odometer.current = null;
|
|
67
|
-
};
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
const instance = new Odometer({ duration });
|
|
24
|
+
odometer.current = instance;
|
|
25
|
+
return () => {
|
|
26
|
+
instance.destroy();
|
|
27
|
+
odometer.current = null;
|
|
68
28
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
$[14] = formatted;
|
|
84
|
-
$[15] = value;
|
|
85
|
-
$[16] = t7;
|
|
86
|
-
} else t7 = $[16];
|
|
87
|
-
let t8;
|
|
88
|
-
if ($[17] !== duration || $[18] !== formatted || $[19] !== value) {
|
|
89
|
-
t8 = [
|
|
90
|
-
formatted,
|
|
91
|
-
value,
|
|
92
|
-
duration
|
|
93
|
-
];
|
|
94
|
-
$[17] = duration;
|
|
95
|
-
$[18] = formatted;
|
|
96
|
-
$[19] = value;
|
|
97
|
-
$[20] = t8;
|
|
98
|
-
} else t8 = $[20];
|
|
99
|
-
useLayoutEffect(t7, t8);
|
|
100
|
-
let t9;
|
|
101
|
-
if ($[21] !== className) {
|
|
102
|
-
t9 = clsx("k-roll-number", className);
|
|
103
|
-
$[21] = className;
|
|
104
|
-
$[22] = t9;
|
|
105
|
-
} else t9 = $[22];
|
|
106
|
-
let t10;
|
|
107
|
-
if ($[23] !== initialText || $[24] !== rest || $[25] !== t9) {
|
|
108
|
-
t10 = /* @__PURE__ */ jsx("span", {
|
|
109
|
-
...rest,
|
|
110
|
-
className: t9,
|
|
111
|
-
ref: element,
|
|
112
|
-
children: initialText
|
|
113
|
-
});
|
|
114
|
-
$[23] = initialText;
|
|
115
|
-
$[24] = rest;
|
|
116
|
-
$[25] = t9;
|
|
117
|
-
$[26] = t10;
|
|
118
|
-
} else t10 = $[26];
|
|
119
|
-
return t10;
|
|
29
|
+
}, [duration]);
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
if (element.current) odometer.current?.render(element.current, formatted, value);
|
|
32
|
+
}, [
|
|
33
|
+
formatted,
|
|
34
|
+
value,
|
|
35
|
+
duration
|
|
36
|
+
]);
|
|
37
|
+
return /* @__PURE__ */ jsx("span", {
|
|
38
|
+
...rest,
|
|
39
|
+
className: clsx("k-roll-number", className),
|
|
40
|
+
ref: element,
|
|
41
|
+
children: initialText
|
|
42
|
+
});
|
|
120
43
|
}
|
|
121
|
-
//#endregion
|
|
122
44
|
export { RollUp as default };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { hasRenderableContent } from "../utils/react-node.js";
|
|
10
9
|
import { normalizeSurfaceShape, resolvePaintedTheme, useConfigAppearance } from "../config/use-config-appearance.js";
|
|
10
|
+
import { hasRenderableContent } from "../utils/react-node.js";
|
|
11
11
|
import StatNumber from "./stat-number.js";
|
|
12
12
|
import { statItemKey } from "./utils/stat-item-key.js";
|
|
13
13
|
import clsx from "clsx";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
-
|
|
15
|
+
// components/stat-card/stat-card.tsx
|
|
16
16
|
var PAINTED_THEMES = [
|
|
17
17
|
"fill",
|
|
18
18
|
"outline",
|
|
@@ -68,5 +68,4 @@ function StatCard({ title, precision = 0, items = [], separator, statNumberType
|
|
|
68
68
|
})]
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
//#endregion
|
|
72
71
|
export { StatCard as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
@@ -8,119 +8,32 @@
|
|
|
8
8
|
|
|
9
9
|
import { hasRenderableContent } from "../utils/react-node.js";
|
|
10
10
|
import CountUpNumber from "./countup.js";
|
|
11
|
-
import { c } from "react/compiler-runtime";
|
|
12
11
|
import clsx from "clsx";
|
|
13
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
function StatNumber(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
$[9] = t4;
|
|
40
|
-
$[10] = t5;
|
|
41
|
-
$[11] = value;
|
|
42
|
-
} else {
|
|
43
|
-
className = $[1];
|
|
44
|
-
prefix = $[2];
|
|
45
|
-
rest = $[3];
|
|
46
|
-
separator = $[4];
|
|
47
|
-
suffix = $[5];
|
|
48
|
-
t1 = $[6];
|
|
49
|
-
t2 = $[7];
|
|
50
|
-
t3 = $[8];
|
|
51
|
-
t4 = $[9];
|
|
52
|
-
t5 = $[10];
|
|
53
|
-
value = $[11];
|
|
54
|
-
}
|
|
55
|
-
const duration = t1 === void 0 ? 1.2 : t1;
|
|
56
|
-
const precision = t2 === void 0 ? 0 : t2;
|
|
57
|
-
const type = t3 === void 0 ? "countup" : t3;
|
|
58
|
-
const autoAnimate = t4 === void 0 ? true : t4;
|
|
59
|
-
const autoAnimateOnce = t5 === void 0 ? true : t5;
|
|
60
|
-
let t6;
|
|
61
|
-
if ($[12] !== className) {
|
|
62
|
-
t6 = clsx("k-stat-number", className);
|
|
63
|
-
$[12] = className;
|
|
64
|
-
$[13] = t6;
|
|
65
|
-
} else t6 = $[13];
|
|
66
|
-
let t7;
|
|
67
|
-
if ($[14] !== prefix) {
|
|
68
|
-
t7 = hasRenderableContent(prefix) && /* @__PURE__ */ jsx("span", {
|
|
69
|
-
className: "k-stat-number-prefix",
|
|
70
|
-
children: prefix
|
|
71
|
-
});
|
|
72
|
-
$[14] = prefix;
|
|
73
|
-
$[15] = t7;
|
|
74
|
-
} else t7 = $[15];
|
|
75
|
-
const t8 = value ?? 0;
|
|
76
|
-
let t9;
|
|
77
|
-
if ($[16] !== autoAnimate || $[17] !== autoAnimateOnce || $[18] !== duration || $[19] !== precision || $[20] !== separator || $[21] !== t8 || $[22] !== type) {
|
|
78
|
-
t9 = /* @__PURE__ */ jsx(CountUpNumber, {
|
|
79
|
-
value: t8,
|
|
80
|
-
separator,
|
|
81
|
-
duration,
|
|
82
|
-
precision,
|
|
83
|
-
type,
|
|
84
|
-
autoAnimate,
|
|
85
|
-
autoAnimateOnce
|
|
86
|
-
});
|
|
87
|
-
$[16] = autoAnimate;
|
|
88
|
-
$[17] = autoAnimateOnce;
|
|
89
|
-
$[18] = duration;
|
|
90
|
-
$[19] = precision;
|
|
91
|
-
$[20] = separator;
|
|
92
|
-
$[21] = t8;
|
|
93
|
-
$[22] = type;
|
|
94
|
-
$[23] = t9;
|
|
95
|
-
} else t9 = $[23];
|
|
96
|
-
let t10;
|
|
97
|
-
if ($[24] !== suffix) {
|
|
98
|
-
t10 = hasRenderableContent(suffix) && /* @__PURE__ */ jsx("span", {
|
|
99
|
-
className: "k-stat-number-suffix",
|
|
100
|
-
children: suffix
|
|
101
|
-
});
|
|
102
|
-
$[24] = suffix;
|
|
103
|
-
$[25] = t10;
|
|
104
|
-
} else t10 = $[25];
|
|
105
|
-
let t11;
|
|
106
|
-
if ($[26] !== rest || $[27] !== t10 || $[28] !== t6 || $[29] !== t7 || $[30] !== t9) {
|
|
107
|
-
t11 = /* @__PURE__ */ jsxs("div", {
|
|
108
|
-
...rest,
|
|
109
|
-
className: t6,
|
|
110
|
-
children: [
|
|
111
|
-
t7,
|
|
112
|
-
t9,
|
|
113
|
-
t10
|
|
114
|
-
]
|
|
115
|
-
});
|
|
116
|
-
$[26] = rest;
|
|
117
|
-
$[27] = t10;
|
|
118
|
-
$[28] = t6;
|
|
119
|
-
$[29] = t7;
|
|
120
|
-
$[30] = t9;
|
|
121
|
-
$[31] = t11;
|
|
122
|
-
} else t11 = $[31];
|
|
123
|
-
return t11;
|
|
13
|
+
// components/stat-card/stat-number.tsx
|
|
14
|
+
function StatNumber({ value, separator, duration = 1.2, precision = 0, type = "countup", prefix, suffix, autoAnimate = true, autoAnimateOnce = true, className, ...rest }) {
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
...rest,
|
|
17
|
+
className: clsx("k-stat-number", className),
|
|
18
|
+
children: [
|
|
19
|
+
hasRenderableContent(prefix) && /* @__PURE__ */ jsx("span", {
|
|
20
|
+
className: "k-stat-number-prefix",
|
|
21
|
+
children: prefix
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx(CountUpNumber, {
|
|
24
|
+
value: value ?? 0,
|
|
25
|
+
separator,
|
|
26
|
+
duration,
|
|
27
|
+
precision,
|
|
28
|
+
type,
|
|
29
|
+
autoAnimate,
|
|
30
|
+
autoAnimateOnce
|
|
31
|
+
}),
|
|
32
|
+
hasRenderableContent(suffix) && /* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: "k-stat-number-suffix",
|
|
34
|
+
children: suffix
|
|
35
|
+
})
|
|
36
|
+
]
|
|
37
|
+
});
|
|
124
38
|
}
|
|
125
|
-
//#endregion
|
|
126
39
|
export { StatNumber as default };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// components/stat-card/utils/countup.ts
|
|
10
10
|
/**
|
|
11
11
|
* Animates a number by counting to it.
|
|
12
12
|
* playground: stackblitz.com/edit/countup-typescript
|
|
@@ -287,5 +287,4 @@ var CountUp = class CountUp {
|
|
|
287
287
|
return parseFloat(num);
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
|
-
//#endregion
|
|
291
290
|
export { CountUp };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// components/stat-card/utils/odometer.ts
|
|
10
10
|
/** Bounded digit tracks shared by statistical numbers and badges. */
|
|
11
11
|
var Odometer = class {
|
|
12
12
|
previous;
|
|
@@ -122,5 +122,4 @@ var Odometer = class {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
//#endregion
|
|
126
125
|
export { Odometer };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* react-kui v3.
|
|
2
|
+
* react-kui v3.3.0
|
|
3
3
|
* Copyright 2017-present, kui-react.
|
|
4
4
|
* All rights reserved.
|
|
5
5
|
* Homepage: https://react.k-ui.cn
|
|
6
6
|
* Author: Qiu / https://chuchur.com
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// components/stat-card/utils/stat-item-key.ts
|
|
10
10
|
/**
|
|
11
11
|
* Identity of one `items` entry across renders.
|
|
12
12
|
*
|
|
@@ -18,5 +18,4 @@
|
|
|
18
18
|
function statItemKey(item, index) {
|
|
19
19
|
return String(item.key ?? `kui-item-${index}`);
|
|
20
20
|
}
|
|
21
|
-
//#endregion
|
|
22
21
|
export { statItemKey };
|