@easy-editor/materials-dashboard-number-flip 0.0.3 → 0.0.5
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/CHANGELOG.md +27 -13
- package/easypack.config.ts +10 -0
- package/package.json +4 -8
- package/src/component.tsx +46 -11
- package/src/configure.ts +183 -342
- package/src/index.tsx +7 -7
- package/src/meta.ts +2 -2
- package/src/snippets.ts +93 -80
- package/tsconfig.json +20 -9
- package/.vite/plugins/vite-plugin-external-deps.ts +0 -224
- package/.vite/plugins/vite-plugin-material-dev.ts +0 -218
- package/dist/component.esm.js +0 -167
- package/dist/component.esm.js.map +0 -1
- package/dist/component.js +0 -176
- package/dist/component.js.map +0 -1
- package/dist/component.min.js +0 -2
- package/dist/component.min.js.map +0 -1
- package/dist/index.cjs +0 -573
- package/dist/index.cjs.map +0 -1
- package/dist/index.esm.js +0 -570
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -578
- package/dist/index.js.map +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
- package/dist/meta.esm.js +0 -407
- package/dist/meta.esm.js.map +0 -1
- package/dist/meta.js +0 -418
- package/dist/meta.js.map +0 -1
- package/dist/meta.min.js +0 -2
- package/dist/meta.min.js.map +0 -1
- package/dist/src/component.d.ts +0 -43
- package/dist/src/configure.d.ts +0 -7
- package/dist/src/constants.d.ts +0 -16
- package/dist/src/index.d.ts +0 -6
- package/dist/src/meta.d.ts +0 -7
- package/dist/src/snippets.d.ts +0 -7
- package/rollup.config.js +0 -222
- package/tsconfig.build.json +0 -12
- package/tsconfig.test.json +0 -7
- package/vite.config.ts +0 -54
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
# @easy-editor/materials-dashboard-number-flip
|
|
2
|
-
|
|
3
|
-
## 0.0.
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- fix:
|
|
8
|
-
|
|
9
|
-
## 0.0.
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
-
|
|
1
|
+
# @easy-editor/materials-dashboard-number-flip
|
|
2
|
+
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: component export error
|
|
8
|
+
|
|
9
|
+
## 0.0.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- perf: configure & datasource
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @easy-editor/materials-shared@0.0.1
|
|
16
|
+
|
|
17
|
+
## 0.0.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- fix: build error
|
|
22
|
+
|
|
23
|
+
## 0.0.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- feat: new setters
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-editor/materials-dashboard-number-flip",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Number Flip component for EasyEditor dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,20 +45,16 @@
|
|
|
45
45
|
"@types/react-dom": "^18 || ^19"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@easy-editor/materials-shared": "0.0.
|
|
48
|
+
"@easy-editor/materials-shared": "0.0.1"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
|
-
"dev": "
|
|
51
|
+
"dev": "easypack dev",
|
|
52
52
|
"dev:debug": "vite --port 5024",
|
|
53
53
|
"format": "biome format --write .",
|
|
54
54
|
"lint": "biome check .",
|
|
55
55
|
"build": "npm-run-all -nl build:*",
|
|
56
56
|
"build:clean": "rimraf dist/",
|
|
57
|
-
"build:js": "
|
|
58
|
-
"build:types": "pnpm types",
|
|
59
|
-
"types": "npm-run-all -nl types:*",
|
|
60
|
-
"types:src": "tsc --project tsconfig.build.json",
|
|
61
|
-
"test-types": "tsc --project tsconfig.test.json"
|
|
57
|
+
"build:js": "easypack build"
|
|
62
58
|
},
|
|
63
59
|
"module": "dist/index.esm.js",
|
|
64
60
|
"unpkg": "dist/index.min.js"
|
package/src/component.tsx
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Number Flip Component
|
|
3
|
-
* 数字翻牌组件 -
|
|
3
|
+
* 数字翻牌组件 - 支持数据源绑定和事件交互
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import { cn } from '@easy-editor/materials-shared'
|
|
6
|
+
import { useMemo, type CSSProperties } from 'react'
|
|
7
|
+
import { cn, type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
|
|
8
8
|
import styles from './component.module.css'
|
|
9
9
|
|
|
10
10
|
export type TrendType = 'up' | 'down' | 'flat'
|
|
11
11
|
|
|
12
|
-
export interface NumberFlipProps {
|
|
13
|
-
ref?: Ref<HTMLDivElement>
|
|
14
|
-
/** 数值 */
|
|
15
|
-
value?: number
|
|
12
|
+
export interface NumberFlipProps extends MaterialComponet {
|
|
16
13
|
/** 小数位数 */
|
|
17
14
|
decimals?: number
|
|
18
15
|
/** 是否显示千分位分隔符 */
|
|
@@ -41,8 +38,14 @@ export interface NumberFlipProps {
|
|
|
41
38
|
trendUpColor?: string
|
|
42
39
|
/** 趋势下降颜色 */
|
|
43
40
|
trendDownColor?: string
|
|
44
|
-
/**
|
|
45
|
-
|
|
41
|
+
/** 点击事件 */
|
|
42
|
+
onClick?: (e: React.MouseEvent) => void
|
|
43
|
+
/** 双击事件 */
|
|
44
|
+
onDoubleClick?: (e: React.MouseEvent) => void
|
|
45
|
+
/** 鼠标进入 */
|
|
46
|
+
onMouseEnter?: (e: React.MouseEvent) => void
|
|
47
|
+
/** 鼠标离开 */
|
|
48
|
+
onMouseLeave?: (e: React.MouseEvent) => void
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
const formatNumber = (value: number, decimals: number, separator: boolean): string => {
|
|
@@ -100,7 +103,8 @@ const TrendIndicator: React.FC<{
|
|
|
100
103
|
|
|
101
104
|
export const NumberFlip: React.FC<NumberFlipProps> = ({
|
|
102
105
|
ref,
|
|
103
|
-
|
|
106
|
+
$data,
|
|
107
|
+
__dataSource,
|
|
104
108
|
decimals = 0,
|
|
105
109
|
separator = true,
|
|
106
110
|
prefix = '',
|
|
@@ -115,8 +119,24 @@ export const NumberFlip: React.FC<NumberFlipProps> = ({
|
|
|
115
119
|
trendSuffix = '%',
|
|
116
120
|
trendUpColor = '#52c41a',
|
|
117
121
|
trendDownColor = '#ff4d4f',
|
|
122
|
+
rotation = 0,
|
|
123
|
+
opacity = 100,
|
|
124
|
+
background = 'transparent',
|
|
118
125
|
style: externalStyle,
|
|
126
|
+
onClick,
|
|
127
|
+
onDoubleClick,
|
|
128
|
+
onMouseEnter,
|
|
129
|
+
onMouseLeave,
|
|
119
130
|
}) => {
|
|
131
|
+
// 解析数据源
|
|
132
|
+
const dataSource = useDataSource($data, __dataSource)
|
|
133
|
+
const value = useMemo<number>(() => {
|
|
134
|
+
if (dataSource.length > 0 && typeof dataSource[0]?.value === 'number') {
|
|
135
|
+
return dataSource[0].value
|
|
136
|
+
}
|
|
137
|
+
return 0
|
|
138
|
+
}, [dataSource])
|
|
139
|
+
|
|
120
140
|
const isDigital = fontFamily === 'digital'
|
|
121
141
|
const formattedValue = formatNumber(value, decimals, separator)
|
|
122
142
|
|
|
@@ -126,8 +146,23 @@ export const NumberFlip: React.FC<NumberFlipProps> = ({
|
|
|
126
146
|
? `0 0 ${10 * glowIntensity}px ${color}, 0 0 ${20 * glowIntensity}px ${color}40, 0 0 ${30 * glowIntensity}px ${color}20`
|
|
127
147
|
: 'none'
|
|
128
148
|
|
|
149
|
+
const containerStyle: CSSProperties = {
|
|
150
|
+
transform: rotation !== 0 ? `rotate(${rotation}deg)` : undefined,
|
|
151
|
+
opacity: opacity / 100,
|
|
152
|
+
backgroundColor: background,
|
|
153
|
+
...externalStyle,
|
|
154
|
+
}
|
|
155
|
+
|
|
129
156
|
return (
|
|
130
|
-
<div
|
|
157
|
+
<div
|
|
158
|
+
className={styles.container}
|
|
159
|
+
onClick={onClick}
|
|
160
|
+
onDoubleClick={onDoubleClick}
|
|
161
|
+
onMouseEnter={onMouseEnter}
|
|
162
|
+
onMouseLeave={onMouseLeave}
|
|
163
|
+
ref={ref}
|
|
164
|
+
style={containerStyle}
|
|
165
|
+
>
|
|
131
166
|
<div className={styles.content}>
|
|
132
167
|
{prefix ? (
|
|
133
168
|
<span
|