@easy-editor/materials-dashboard-number-flip 0.0.4 → 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 CHANGED
@@ -1,21 +1,27 @@
1
- # @easy-editor/materials-dashboard-number-flip
2
-
3
- ## 0.0.4
4
-
5
- ### Patch Changes
6
-
7
- - perf: configure & datasource
8
- - Updated dependencies
9
- - @easy-editor/materials-shared@0.0.1
10
-
11
- ## 0.0.3
12
-
13
- ### Patch Changes
14
-
15
- - fix: build error
16
-
17
- ## 0.0.2
18
-
19
- ### Patch Changes
20
-
21
- - feat: new setters
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.4",
3
+ "version": "0.0.5",
4
4
  "description": "Number Flip component for EasyEditor dashboard",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/component.tsx CHANGED
@@ -1,212 +1,214 @@
1
- /**
2
- * Number Flip Component
3
- * 数字翻牌组件 - 支持数据源绑定和事件交互
4
- */
5
-
6
- import { useMemo, type CSSProperties } from 'react'
7
- import { cn, type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
8
- import styles from './component.module.css'
9
-
10
- export type TrendType = 'up' | 'down' | 'flat'
11
-
12
- export interface NumberFlipProps extends MaterialComponet {
13
- /** 小数位数 */
14
- decimals?: number
15
- /** 是否显示千分位分隔符 */
16
- separator?: boolean
17
- /** 前缀 */
18
- prefix?: string
19
- /** 后缀 */
20
- suffix?: string
21
- /** 字体大小 */
22
- fontSize?: number
23
- /** 字体类型 */
24
- fontFamily?: 'digital' | 'default'
25
- /** 颜色 */
26
- color?: string
27
- /** 发光强度 (0-2) */
28
- glowIntensity?: number
29
- /** 是否显示趋势 */
30
- trendEnable?: boolean
31
- /** 趋势值 */
32
- trendValue?: number
33
- /** 趋势类型 */
34
- trendType?: TrendType
35
- /** 趋势后缀 */
36
- trendSuffix?: string
37
- /** 趋势上升颜色 */
38
- trendUpColor?: string
39
- /** 趋势下降颜色 */
40
- trendDownColor?: string
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
49
- }
50
-
51
- const formatNumber = (value: number, decimals: number, separator: boolean): string => {
52
- const fixed = value.toFixed(decimals)
53
- if (!separator) {
54
- return fixed
55
- }
56
-
57
- const [intPart, decPart] = fixed.split('.')
58
- const formattedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
59
- return decPart ? `${formattedInt}.${decPart}` : formattedInt
60
- }
61
-
62
- const TrendIndicator: React.FC<{
63
- type: TrendType
64
- value: number
65
- suffix: string
66
- upColor: string
67
- downColor: string
68
- size: number
69
- }> = ({ type, value, suffix, upColor, downColor, size }) => {
70
- let color = '#8899aa'
71
- if (type === 'up') {
72
- color = upColor
73
- } else if (type === 'down') {
74
- color = downColor
75
- }
76
-
77
- return (
78
- <div className={styles.trend} style={{ fontSize: size * 0.35 }}>
79
- {type !== 'flat' && (
80
- <svg
81
- aria-label={`Trend ${type}`}
82
- fill='none'
83
- height={size * 0.3}
84
- role='img'
85
- style={{
86
- transform: type === 'down' ? 'rotate(180deg)' : undefined,
87
- }}
88
- viewBox='0 0 24 24'
89
- width={size * 0.3}
90
- >
91
- <title>Trend arrow {type}</title>
92
- <path d='M12 4L20 14H4L12 4Z' fill={color} />
93
- </svg>
94
- )}
95
- {type === 'flat' && <span style={{ color, marginRight: 4 }}>—</span>}
96
- <span style={{ color }}>
97
- {value}
98
- {suffix}
99
- </span>
100
- </div>
101
- )
102
- }
103
-
104
- export const NumberFlip: React.FC<NumberFlipProps> = ({
105
- ref,
106
- $data,
107
- __dataSource,
108
- decimals = 0,
109
- separator = true,
110
- prefix = '',
111
- suffix = '',
112
- fontSize = 48,
113
- fontFamily = 'digital',
114
- color = '#00d4ff',
115
- glowIntensity = 0.5,
116
- trendEnable = false,
117
- trendValue = 0,
118
- trendType = 'up',
119
- trendSuffix = '%',
120
- trendUpColor = '#52c41a',
121
- trendDownColor = '#ff4d4f',
122
- rotation = 0,
123
- opacity = 100,
124
- background = 'transparent',
125
- style: externalStyle,
126
- onClick,
127
- onDoubleClick,
128
- onMouseEnter,
129
- onMouseLeave,
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
-
140
- const isDigital = fontFamily === 'digital'
141
- const formattedValue = formatNumber(value, decimals, separator)
142
-
143
- // 计算发光效果的 text-shadow
144
- const glowShadow =
145
- glowIntensity > 0
146
- ? `0 0 ${10 * glowIntensity}px ${color}, 0 0 ${20 * glowIntensity}px ${color}40, 0 0 ${30 * glowIntensity}px ${color}20`
147
- : 'none'
148
-
149
- const containerStyle: CSSProperties = {
150
- transform: rotation !== 0 ? `rotate(${rotation}deg)` : undefined,
151
- opacity: opacity / 100,
152
- backgroundColor: background,
153
- ...externalStyle,
154
- }
155
-
156
- return (
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
- >
166
- <div className={styles.content}>
167
- {prefix ? (
168
- <span
169
- className={cn(styles.prefix, isDigital && styles.prefixDigital)}
170
- style={{
171
- fontSize: `${fontSize * 0.5}px`,
172
- color,
173
- }}
174
- >
175
- {prefix}
176
- </span>
177
- ) : null}
178
- <span
179
- className={cn(styles.value, isDigital && styles.valueDigital)}
180
- style={{
181
- fontSize: `${fontSize}px`,
182
- color,
183
- textShadow: glowShadow,
184
- }}
185
- >
186
- {formattedValue}
187
- </span>
188
- {suffix ? (
189
- <span
190
- className={cn(styles.suffix, isDigital && styles.suffixDigital)}
191
- style={{
192
- fontSize: `${fontSize * 0.4}px`,
193
- color,
194
- }}
195
- >
196
- {suffix}
197
- </span>
198
- ) : null}
199
- </div>
200
- {trendEnable ? (
201
- <TrendIndicator
202
- downColor={trendDownColor}
203
- size={fontSize}
204
- suffix={trendSuffix}
205
- type={trendType}
206
- upColor={trendUpColor}
207
- value={trendValue}
208
- />
209
- ) : null}
210
- </div>
211
- )
212
- }
1
+ /**
2
+ * Number Flip Component
3
+ * 数字翻牌组件 - 支持数据源绑定和事件交互
4
+ */
5
+
6
+ import { useMemo, type CSSProperties } from 'react'
7
+ import { cn, type MaterialComponet, useDataSource } from '@easy-editor/materials-shared'
8
+ import styles from './component.module.css'
9
+
10
+ export type TrendType = 'up' | 'down' | 'flat'
11
+
12
+ export interface NumberFlipProps extends MaterialComponet {
13
+ /** 小数位数 */
14
+ decimals?: number
15
+ /** 是否显示千分位分隔符 */
16
+ separator?: boolean
17
+ /** 前缀 */
18
+ prefix?: string
19
+ /** 后缀 */
20
+ suffix?: string
21
+ /** 字体大小 */
22
+ fontSize?: number
23
+ /** 字体类型 */
24
+ fontFamily?: 'digital' | 'default'
25
+ /** 颜色 */
26
+ color?: string
27
+ /** 发光强度 (0-2) */
28
+ glowIntensity?: number
29
+ /** 是否显示趋势 */
30
+ trendEnable?: boolean
31
+ /** 趋势值 */
32
+ trendValue?: number
33
+ /** 趋势类型 */
34
+ trendType?: TrendType
35
+ /** 趋势后缀 */
36
+ trendSuffix?: string
37
+ /** 趋势上升颜色 */
38
+ trendUpColor?: string
39
+ /** 趋势下降颜色 */
40
+ trendDownColor?: string
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
49
+ }
50
+
51
+ const formatNumber = (value: number, decimals: number, separator: boolean): string => {
52
+ const fixed = value.toFixed(decimals)
53
+ if (!separator) {
54
+ return fixed
55
+ }
56
+
57
+ const [intPart, decPart] = fixed.split('.')
58
+ const formattedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
59
+ return decPart ? `${formattedInt}.${decPart}` : formattedInt
60
+ }
61
+
62
+ const TrendIndicator: React.FC<{
63
+ type: TrendType
64
+ value: number
65
+ suffix: string
66
+ upColor: string
67
+ downColor: string
68
+ size: number
69
+ }> = ({ type, value, suffix, upColor, downColor, size }) => {
70
+ let color = '#8899aa'
71
+ if (type === 'up') {
72
+ color = upColor
73
+ } else if (type === 'down') {
74
+ color = downColor
75
+ }
76
+
77
+ return (
78
+ <div className={styles.trend} style={{ fontSize: size * 0.35 }}>
79
+ {type !== 'flat' && (
80
+ <svg
81
+ aria-label={`Trend ${type}`}
82
+ fill='none'
83
+ height={size * 0.3}
84
+ role='img'
85
+ style={{
86
+ transform: type === 'down' ? 'rotate(180deg)' : undefined,
87
+ }}
88
+ viewBox='0 0 24 24'
89
+ width={size * 0.3}
90
+ >
91
+ <title>Trend arrow {type}</title>
92
+ <path d='M12 4L20 14H4L12 4Z' fill={color} />
93
+ </svg>
94
+ )}
95
+ {type === 'flat' && <span style={{ color, marginRight: 4 }}>—</span>}
96
+ <span style={{ color }}>
97
+ {value}
98
+ {suffix}
99
+ </span>
100
+ </div>
101
+ )
102
+ }
103
+
104
+ export const NumberFlip: React.FC<NumberFlipProps> = ({
105
+ ref,
106
+ $data,
107
+ __dataSource,
108
+ decimals = 0,
109
+ separator = true,
110
+ prefix = '',
111
+ suffix = '',
112
+ fontSize = 48,
113
+ fontFamily = 'digital',
114
+ color = '#00d4ff',
115
+ glowIntensity = 0.5,
116
+ trendEnable = false,
117
+ trendValue = 0,
118
+ trendType = 'up',
119
+ trendSuffix = '%',
120
+ trendUpColor = '#52c41a',
121
+ trendDownColor = '#ff4d4f',
122
+ rotation = 0,
123
+ opacity = 100,
124
+ background = 'transparent',
125
+ style: externalStyle,
126
+ onClick,
127
+ onDoubleClick,
128
+ onMouseEnter,
129
+ onMouseLeave,
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
+
140
+ const isDigital = fontFamily === 'digital'
141
+ const formattedValue = formatNumber(value, decimals, separator)
142
+
143
+ // 计算发光效果的 text-shadow
144
+ const glowShadow =
145
+ glowIntensity > 0
146
+ ? `0 0 ${10 * glowIntensity}px ${color}, 0 0 ${20 * glowIntensity}px ${color}40, 0 0 ${30 * glowIntensity}px ${color}20`
147
+ : 'none'
148
+
149
+ const containerStyle: CSSProperties = {
150
+ transform: rotation !== 0 ? `rotate(${rotation}deg)` : undefined,
151
+ opacity: opacity / 100,
152
+ backgroundColor: background,
153
+ ...externalStyle,
154
+ }
155
+
156
+ return (
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
+ >
166
+ <div className={styles.content}>
167
+ {prefix ? (
168
+ <span
169
+ className={cn(styles.prefix, isDigital && styles.prefixDigital)}
170
+ style={{
171
+ fontSize: `${fontSize * 0.5}px`,
172
+ color,
173
+ }}
174
+ >
175
+ {prefix}
176
+ </span>
177
+ ) : null}
178
+ <span
179
+ className={cn(styles.value, isDigital && styles.valueDigital)}
180
+ style={{
181
+ fontSize: `${fontSize}px`,
182
+ color,
183
+ textShadow: glowShadow,
184
+ }}
185
+ >
186
+ {formattedValue}
187
+ </span>
188
+ {suffix ? (
189
+ <span
190
+ className={cn(styles.suffix, isDigital && styles.suffixDigital)}
191
+ style={{
192
+ fontSize: `${fontSize * 0.4}px`,
193
+ color,
194
+ }}
195
+ >
196
+ {suffix}
197
+ </span>
198
+ ) : null}
199
+ </div>
200
+ {trendEnable ? (
201
+ <TrendIndicator
202
+ downColor={trendDownColor}
203
+ size={fontSize}
204
+ suffix={trendSuffix}
205
+ type={trendType}
206
+ upColor={trendUpColor}
207
+ value={trendValue}
208
+ />
209
+ ) : null}
210
+ </div>
211
+ )
212
+ }
213
+
214
+ export default NumberFlip
package/src/meta.ts CHANGED
@@ -1,26 +1,28 @@
1
- /**
2
- * Number Flip Meta
3
- * 数字翻牌组件元数据
4
- */
5
-
6
- import type { ComponentMetadata } from '@easy-editor/core'
7
- import { MaterialGroup } from '@easy-editor/materials-shared'
8
- import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
9
- import { configure } from './configure'
10
- import { snippets } from './snippets'
11
- import pkg from '../package.json'
12
-
13
- export const meta: ComponentMetadata = {
14
- componentName: COMPONENT_NAME,
15
- title: '数字翻牌',
16
- group: MaterialGroup.DISPLAY,
17
- devMode: 'proCode',
18
- npm: {
19
- package: PACKAGE_NAME,
20
- version: pkg.version,
21
- globalName: COMPONENT_NAME,
22
- componentName: COMPONENT_NAME,
23
- },
24
- snippets,
25
- configure,
26
- }
1
+ /**
2
+ * Number Flip Meta
3
+ * 数字翻牌组件元数据
4
+ */
5
+
6
+ import type { ComponentMetadata } from '@easy-editor/core'
7
+ import { MaterialGroup } from '@easy-editor/materials-shared'
8
+ import { COMPONENT_NAME, PACKAGE_NAME } from './constants'
9
+ import { configure } from './configure'
10
+ import { snippets } from './snippets'
11
+ import pkg from '../package.json'
12
+
13
+ export const meta: ComponentMetadata = {
14
+ componentName: COMPONENT_NAME,
15
+ title: '数字翻牌',
16
+ group: MaterialGroup.DISPLAY,
17
+ devMode: 'proCode',
18
+ npm: {
19
+ package: PACKAGE_NAME,
20
+ version: pkg.version,
21
+ globalName: COMPONENT_NAME,
22
+ componentName: COMPONENT_NAME,
23
+ },
24
+ snippets,
25
+ configure,
26
+ }
27
+
28
+ export default meta
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EasyEditorMaterialsNumberFlipComponent={},e.React,e.jsxRuntime)}(this,function(e,t,o){"use strict";function n(...e){const t=[];for(const o of e)if(o)if("string"==typeof o||"number"==typeof o)t.push(String(o));else if(Array.isArray(o)){const e=n(...o);e&&t.push(e)}else if("object"==typeof o)for(const[e,n]of Object.entries(o))n&&t.push(e);return t.join(" ")}const r=(e,t)=>{if(!t)return e;const o=t.split(".");let n=e;for(const e of o){if(null==n)return;if("object"!=typeof n)return;n=n[e]}return n},i=e=>void 0===e?[]:Array.isArray(e)?e:e&&"object"==typeof e?[e]:[],a=(e,t)=>{const o=((e,t)=>{if(!e)return[];if("static"===e.sourceType)return Array.isArray(e.staticData)?e.staticData:[];if("global"===e.sourceType&&e.datasourceId){const o=t?.page?.[e.datasourceId];return i(o)}if("datasource"===e.sourceType&&e.datasourceId){const o=t?.component?.[e.datasourceId];return i(o)}return[]})(e,t);return((e,t)=>t&&0!==t.length?e.map(e=>{const o={};for(const{componentField:n,sourceField:i}of t)n&&i&&(o[n]=r(e,i));return o}):e)(o,e?.fieldMappings)};const l=(e,t,o)=>({type:"group",title:e,setter:{componentName:"CollapseSetter",props:{icon:!1,...o}},items:t});l("基础配置",[{name:"title",title:"标题",setter:"StringSetter",extraProps:{getValue:e=>e.getExtraPropValue("title"),setValue(e,t){e.setExtraPropValue("title",t)}}},{name:"rect",title:"位置尺寸",setter:"RectSetter",extraProps:{getValue:e=>e.getExtraPropValue("$dashboard.rect"),setValue(e,t){e.setExtraPropValue("$dashboard.rect",t)}}},{name:"rotation",title:"旋转角度",setter:{componentName:"SliderSetter",props:{min:0,max:360,suffix:"°"}},extraProps:{defaultValue:0}},{name:"opacity",title:"不透明度",setter:{componentName:"SliderSetter",props:{min:0,max:100,suffix:"%"}},extraProps:{defaultValue:100}},{name:"background",title:"背景颜色",setter:"ColorSetter",extraProps:{defaultValue:"transparent"}}]);const s=[{title:"点击事件",children:[{label:"点击",value:"onClick",description:"鼠标点击时触发"},{label:"双击",value:"onDoubleClick",description:"鼠标双击时触发"}]},{title:"鼠标事件",children:[{label:"鼠标进入",value:"onMouseEnter",description:"鼠标进入时触发"},{label:"鼠标离开",value:"onMouseLeave",description:"鼠标离开时触发"}]}];((e=s)=>{l("事件绑定",[{name:"events",title:"事件",setter:{componentName:"EventSetter",props:{events:e}},extraProps:{label:!1}}])})(),l("高级配置",[{title:"条件渲染",setter:"SwitchSetter",extraProps:{supportVariable:!0,getValue:e=>e.getNode().getExtraPropValue("condition"),setValue(e,t){e.getNode().setExtraProp("condition",t)}}}]);var c="component-module__container___VbZSk",u="component-module__content___344U8",p="component-module__prefix___RIPOo",d="component-module__prefixDigital___Q-IGu",f="component-module__value___Fg70k",m="component-module__valueDigital___saOYz",_="component-module__suffix___9U3yv",x="component-module__suffixDigital___WiYn4",g="component-module__trend___fgbi4";!function(e,t){void 0===t&&(t={});var o=t.insertAt;if("undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}(".component-module__container___VbZSk{align-items:center;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;height:100%;justify-content:center;width:100%}.component-module__content___344U8{align-items:baseline;display:flex;gap:4px}.component-module__prefix___RIPOo{font-weight:600;opacity:.8}.component-module__prefixDigital___Q-IGu{font-family:Courier New,Courier,monospace}.component-module__value___Fg70k{font-weight:700}.component-module__valueDigital___saOYz{font-family:Courier New,Courier,monospace;letter-spacing:.05em}.component-module__suffix___9U3yv{font-weight:500;margin-left:4px;opacity:.7}.component-module__suffixDigital___WiYn4{font-family:Courier New,Courier,monospace}.component-module__trend___fgbi4{align-items:center;display:flex;font-weight:500;gap:4px}");const y=({type:e,value:t,suffix:n,upColor:r,downColor:i,size:a})=>{let l="#8899aa";return"up"===e?l=r:"down"===e&&(l=i),o.jsxs("div",{className:g,style:{fontSize:.35*a},children:["flat"!==e&&o.jsxs("svg",{"aria-label":`Trend ${e}`,fill:"none",height:.3*a,role:"img",style:{transform:"down"===e?"rotate(180deg)":void 0},viewBox:"0 0 24 24",width:.3*a,children:[o.jsxs("title",{children:["Trend arrow ",e]}),o.jsx("path",{d:"M12 4L20 14H4L12 4Z",fill:l})]}),"flat"===e&&o.jsx("span",{style:{color:l,marginRight:4},children:"—"}),o.jsxs("span",{style:{color:l},children:[t,n]})]})};e.NumberFlip=({ref:e,$data:r,__dataSource:i,decimals:l=0,separator:s=!0,prefix:g="",suffix:h="",fontSize:b=48,fontFamily:v="digital",color:C="#00d4ff",glowIntensity:S=.5,trendEnable:j=!1,trendValue:w=0,trendType:N="up",trendSuffix:V="%",trendUpColor:E="#52c41a",trendDownColor:P="#ff4d4f",rotation:$=0,opacity:k=100,background:D="transparent",style:M,onClick:T,onDoubleClick:z,onMouseEnter:I,onMouseLeave:F})=>{const A=function(e,o){return t.useMemo(()=>a(e,o),[e,o])}(r,i),R="digital"===v,L=((e,t,o)=>{const n=e.toFixed(t);if(!o)return n;const[r,i]=n.split("."),a=r.replace(/\B(?=(\d{3})+(?!\d))/g,",");return i?`${a}.${i}`:a})(t.useMemo(()=>A.length>0&&"number"==typeof A[0]?.value?A[0].value:0,[A]),l,s),O=S>0?`0 0 ${10*S}px ${C}, 0 0 ${20*S}px ${C}40, 0 0 ${30*S}px ${C}20`:"none",U={transform:0!==$?`rotate(${$}deg)`:void 0,opacity:k/100,backgroundColor:D,...M};return o.jsxs("div",{className:c,onClick:T,onDoubleClick:z,onMouseEnter:I,onMouseLeave:F,ref:e,style:U,children:[o.jsxs("div",{className:u,children:[g?o.jsx("span",{className:n(p,R&&d),style:{fontSize:.5*b+"px",color:C},children:g}):null,o.jsx("span",{className:n(f,R&&m),style:{fontSize:`${b}px`,color:C,textShadow:O},children:L}),h?o.jsx("span",{className:n(_,R&&x),style:{fontSize:.4*b+"px",color:C},children:h}):null]}),j?o.jsx(y,{downColor:P,size:b,suffix:V,type:N,upColor:E,value:w}):null]})}});
package/dist/index.min.js DELETED
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react/jsx-runtime")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EasyEditorMaterialsNumberFlip={},e.React,e.jsxRuntime)}(this,function(e,t,o){"use strict";function r(...e){const t=[];for(const o of e)if(o)if("string"==typeof o||"number"==typeof o)t.push(String(o));else if(Array.isArray(o)){const e=r(...o);e&&t.push(e)}else if("object"==typeof o)for(const[e,r]of Object.entries(o))r&&t.push(e);return t.join(" ")}const a=(e,t)=>{if(!t)return e;const o=t.split(".");let r=e;for(const e of o){if(null==r)return;if("object"!=typeof r)return;r=r[e]}return r},n=e=>void 0===e?[]:Array.isArray(e)?e:e&&"object"==typeof e?[e]:[],i=(e,t)=>{const o=((e,t)=>{if(!e)return[];if("static"===e.sourceType)return Array.isArray(e.staticData)?e.staticData:[];if("global"===e.sourceType&&e.datasourceId){const o=t?.page?.[e.datasourceId];return n(o)}if("datasource"===e.sourceType&&e.datasourceId){const o=t?.component?.[e.datasourceId];return n(o)}return[]})(e,t);return((e,t)=>t&&0!==t.length?e.map(e=>{const o={};for(const{componentField:r,sourceField:n}of t)r&&n&&(o[r]=a(e,n));return o}):e)(o,e?.fieldMappings)};const l=(e,t)=>{const o=Array.isArray(e)?e:[e],r=o[0]||{};return{sourceType:"static",staticData:o,fieldMappings:Object.keys(r).map(e=>({componentField:e,sourceField:e}))}},s=(e,t,o)=>({type:"group",title:e,setter:{componentName:"CollapseSetter",props:{icon:!1,...o}},items:t}),p={name:"nodeInfo",title:"节点信息",setter:"NodeInfoSetter",extraProps:{label:!1}},u=s("基础配置",[{name:"title",title:"标题",setter:"StringSetter",extraProps:{getValue:e=>e.getExtraPropValue("title"),setValue(e,t){e.setExtraPropValue("title",t)}}},{name:"rect",title:"位置尺寸",setter:"RectSetter",extraProps:{getValue:e=>e.getExtraPropValue("$dashboard.rect"),setValue(e,t){e.setExtraPropValue("$dashboard.rect",t)}}},{name:"rotation",title:"旋转角度",setter:{componentName:"SliderSetter",props:{min:0,max:360,suffix:"°"}},extraProps:{defaultValue:0}},{name:"opacity",title:"不透明度",setter:{componentName:"SliderSetter",props:{min:0,max:100,suffix:"%"}},extraProps:{defaultValue:100}},{name:"background",title:"背景颜色",setter:"ColorSetter",extraProps:{defaultValue:"transparent"}}]),c=[{title:"点击事件",children:[{label:"点击",value:"onClick",description:"鼠标点击时触发"},{label:"双击",value:"onDoubleClick",description:"鼠标双击时触发"}]},{title:"鼠标事件",children:[{label:"鼠标进入",value:"onMouseEnter",description:"鼠标进入时触发"},{label:"鼠标离开",value:"onMouseLeave",description:"鼠标离开时触发"}]}],d=((e=c)=>s("事件绑定",[{name:"events",title:"事件",setter:{componentName:"EventSetter",props:{events:e}},extraProps:{label:!1}}]))(),m=s("高级配置",[{title:"条件渲染",setter:"SwitchSetter",extraProps:{supportVariable:!0,getValue:e=>e.getNode().getExtraPropValue("condition"),setValue(e,t){e.getNode().setExtraProp("condition",t)}}}]);var f="component-module__container___VbZSk",x="component-module__content___344U8",g="component-module__prefix___RIPOo",_="component-module__prefixDigital___Q-IGu",y="component-module__value___Fg70k",h="component-module__valueDigital___saOYz",b="component-module__suffix___9U3yv",S="component-module__suffixDigital___WiYn4",v="component-module__trend___fgbi4";!function(e,t){void 0===t&&(t={});var o=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===o&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".component-module__container___VbZSk{align-items:center;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;height:100%;justify-content:center;width:100%}.component-module__content___344U8{align-items:baseline;display:flex;gap:4px}.component-module__prefix___RIPOo{font-weight:600;opacity:.8}.component-module__prefixDigital___Q-IGu{font-family:Courier New,Courier,monospace}.component-module__value___Fg70k{font-weight:700}.component-module__valueDigital___saOYz{font-family:Courier New,Courier,monospace;letter-spacing:.05em}.component-module__suffix___9U3yv{font-weight:500;margin-left:4px;opacity:.7}.component-module__suffixDigital___WiYn4{font-family:Courier New,Courier,monospace}.component-module__trend___fgbi4{align-items:center;display:flex;font-weight:500;gap:4px}");const N=({type:e,value:t,suffix:r,upColor:a,downColor:n,size:i})=>{let l="#8899aa";return"up"===e?l=a:"down"===e&&(l=n),o.jsxs("div",{className:v,style:{fontSize:.35*i},children:["flat"!==e&&o.jsxs("svg",{"aria-label":`Trend ${e}`,fill:"none",height:.3*i,role:"img",style:{transform:"down"===e?"rotate(180deg)":void 0},viewBox:"0 0 24 24",width:.3*i,children:[o.jsxs("title",{children:["Trend arrow ",e]}),o.jsx("path",{d:"M12 4L20 14H4L12 4Z",fill:l})]}),"flat"===e&&o.jsx("span",{style:{color:l,marginRight:4},children:"—"}),o.jsxs("span",{style:{color:l},children:[t,r]})]})},w="EasyEditorMaterialsNumberFlip";const V=((e,t)=>({props:[{type:"group",title:"属性",setter:"TabSetter",items:[{type:"group",key:"config",title:"配置",items:[p,u,e]},{type:"group",key:"data",title:"数据",items:[p,t]},{type:"group",key:"advanced",title:"高级",items:[p,d,m]}]}],component:{},supports:{},advanced:{}}))(s("组件配置",[{type:"group",title:"组件配置",setter:"SubTabSetter",items:[{type:"group",key:"value",title:"数值",items:[{name:"decimals",title:"小数位数",setter:{componentName:"NumberSetter",props:{min:0,max:10}},extraProps:{defaultValue:0}},{name:"separator",title:"千分位分隔",setter:"SwitchSetter",extraProps:{defaultValue:!0}},{name:"prefix",title:"前缀",setter:"StringSetter"},{name:"suffix",title:"后缀",setter:"StringSetter"}]},{type:"group",key:"trend",title:"趋势",items:[{name:"trendEnable",title:"显示趋势",setter:"SwitchSetter",extraProps:{defaultValue:!1}},{name:"trendValue",title:"趋势值",setter:"NumberSetter",extraProps:{defaultValue:0}},{name:"trendType",title:"趋势类型",setter:{componentName:"SegmentedSetter",props:{options:[{label:"上升",value:"up"},{label:"下降",value:"down"},{label:"持平",value:"flat"}]}},extraProps:{defaultValue:"up"}},{name:"trendSuffix",title:"趋势后缀",setter:"StringSetter",extraProps:{defaultValue:"%"}}]},{type:"group",key:"style",title:"样式",items:[{name:"fontSize",title:"字体大小",setter:{componentName:"SliderSetter",props:{min:12,max:120,step:2,suffix:"px"}},extraProps:{defaultValue:48}},{name:"fontFamily",title:"字体类型",setter:{componentName:"SelectSetter",props:{options:[{label:"数码字体",value:"digital"},{label:"默认字体",value:"default"}]}},extraProps:{defaultValue:"digital"}},{name:"color",title:"颜色",setter:"ColorSetter",extraProps:{defaultValue:"#00d4ff"}},{name:"glowIntensity",title:"发光强度",setter:{componentName:"SliderSetter",props:{min:0,max:2,step:.1}},extraProps:{defaultValue:.5}}]}]}],{padding:"6px 16px 12px"}),{name:"$data",title:"数据配置",setter:{componentName:"DataSetter",props:{expectedFields:[{name:"value",label:"value",type:"number",required:!0,description:"数值"}],showPreview:!0,previewLimit:10}},extraProps:{label:!1}});const P={componentName:w,title:"数字翻牌",group:"display",devMode:"proCode",npm:{package:"@easy-editor/materials-dashboard-number-flip",version:"0.0.4",globalName:w,componentName:w},snippets:[{title:"数字翻牌",screenshot:"",schema:{componentName:w,title:"数字翻牌",props:{$data:l({value:1234567}),decimals:0,separator:!0,fontSize:48,fontFamily:"digital",color:"#00d4ff",glowIntensity:.5,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:280,height:80}}}},{title:"货币数字",screenshot:"",schema:{componentName:w,title:"货币数字",props:{$data:l({value:99999.99}),decimals:2,separator:!0,prefix:"$",fontSize:42,fontFamily:"digital",color:"#00ff88",glowIntensity:.6,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:260,height:70}}}},{title:"百分比",screenshot:"",schema:{componentName:w,title:"百分比",props:{$data:l({value:87.5}),decimals:1,separator:!1,suffix:"%",fontSize:56,fontFamily:"digital",color:"#ff6b6b",glowIntensity:.8,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:200,height:90}}}}],configure:V};e.component=({ref:e,$data:a,__dataSource:n,decimals:l=0,separator:s=!0,prefix:p="",suffix:u="",fontSize:c=48,fontFamily:d="digital",color:m="#00d4ff",glowIntensity:v=.5,trendEnable:w=!1,trendValue:V=0,trendType:P="up",trendSuffix:C="%",trendUpColor:k="#52c41a",trendDownColor:j="#ff4d4f",rotation:$=0,opacity:E=100,background:F="transparent",style:I,onClick:T,onDoubleClick:z,onMouseEnter:D,onMouseLeave:M})=>{const A=function(e,o){return t.useMemo(()=>i(e,o),[e,o])}(a,n),L="digital"===d,O=((e,t,o)=>{const r=e.toFixed(t);if(!o)return r;const[a,n]=r.split("."),i=a.replace(/\B(?=(\d{3})+(?!\d))/g,",");return n?`${i}.${n}`:i})(t.useMemo(()=>A.length>0&&"number"==typeof A[0]?.value?A[0].value:0,[A]),l,s),R=v>0?`0 0 ${10*v}px ${m}, 0 0 ${20*v}px ${m}40, 0 0 ${30*v}px ${m}20`:"none",U={transform:0!==$?`rotate(${$}deg)`:void 0,opacity:E/100,backgroundColor:F,...I};return o.jsxs("div",{className:f,onClick:T,onDoubleClick:z,onMouseEnter:D,onMouseLeave:M,ref:e,style:U,children:[o.jsxs("div",{className:x,children:[p?o.jsx("span",{className:r(g,L&&_),style:{fontSize:.5*c+"px",color:m},children:p}):null,o.jsx("span",{className:r(y,L&&h),style:{fontSize:`${c}px`,color:m,textShadow:R},children:O}),u?o.jsx("span",{className:r(b,L&&S),style:{fontSize:.4*c+"px",color:m},children:u}):null]}),w?o.jsx(N,{downColor:j,size:c,suffix:C,type:P,upColor:k,value:V}):null]})},e.meta=P});
package/dist/meta.min.js DELETED
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).EasyEditorMaterialsNumberFlipMeta={})}(this,function(e){"use strict";const t=(e,t)=>{const a=Array.isArray(e)?e:[e],r=a[0]||{};return{sourceType:"static",staticData:a,fieldMappings:Object.keys(r).map(e=>({componentField:e,sourceField:e}))}},a=(e,t,a)=>({type:"group",title:e,setter:{componentName:"CollapseSetter",props:{icon:!1,...a}},items:t}),r={name:"nodeInfo",title:"节点信息",setter:"NodeInfoSetter",extraProps:{label:!1}},o=a("基础配置",[{name:"title",title:"标题",setter:"StringSetter",extraProps:{getValue:e=>e.getExtraPropValue("title"),setValue(e,t){e.setExtraPropValue("title",t)}}},{name:"rect",title:"位置尺寸",setter:"RectSetter",extraProps:{getValue:e=>e.getExtraPropValue("$dashboard.rect"),setValue(e,t){e.setExtraPropValue("$dashboard.rect",t)}}},{name:"rotation",title:"旋转角度",setter:{componentName:"SliderSetter",props:{min:0,max:360,suffix:"°"}},extraProps:{defaultValue:0}},{name:"opacity",title:"不透明度",setter:{componentName:"SliderSetter",props:{min:0,max:100,suffix:"%"}},extraProps:{defaultValue:100}},{name:"background",title:"背景颜色",setter:"ColorSetter",extraProps:{defaultValue:"transparent"}}]),l=[{title:"点击事件",children:[{label:"点击",value:"onClick",description:"鼠标点击时触发"},{label:"双击",value:"onDoubleClick",description:"鼠标双击时触发"}]},{title:"鼠标事件",children:[{label:"鼠标进入",value:"onMouseEnter",description:"鼠标进入时触发"},{label:"鼠标离开",value:"onMouseLeave",description:"鼠标离开时触发"}]}],i=((e=l)=>a("事件绑定",[{name:"events",title:"事件",setter:{componentName:"EventSetter",props:{events:e}},extraProps:{label:!1}}]))(),n=a("高级配置",[{title:"条件渲染",setter:"SwitchSetter",extraProps:{supportVariable:!0,getValue:e=>e.getNode().getExtraPropValue("condition"),setValue(e,t){e.getNode().setExtraProp("condition",t)}}}]),s="EasyEditorMaterialsNumberFlip";const p=((e,t)=>({props:[{type:"group",title:"属性",setter:"TabSetter",items:[{type:"group",key:"config",title:"配置",items:[r,o,e]},{type:"group",key:"data",title:"数据",items:[r,t]},{type:"group",key:"advanced",title:"高级",items:[r,i,n]}]}],component:{},supports:{},advanced:{}}))(a("组件配置",[{type:"group",title:"组件配置",setter:"SubTabSetter",items:[{type:"group",key:"value",title:"数值",items:[{name:"decimals",title:"小数位数",setter:{componentName:"NumberSetter",props:{min:0,max:10}},extraProps:{defaultValue:0}},{name:"separator",title:"千分位分隔",setter:"SwitchSetter",extraProps:{defaultValue:!0}},{name:"prefix",title:"前缀",setter:"StringSetter"},{name:"suffix",title:"后缀",setter:"StringSetter"}]},{type:"group",key:"trend",title:"趋势",items:[{name:"trendEnable",title:"显示趋势",setter:"SwitchSetter",extraProps:{defaultValue:!1}},{name:"trendValue",title:"趋势值",setter:"NumberSetter",extraProps:{defaultValue:0}},{name:"trendType",title:"趋势类型",setter:{componentName:"SegmentedSetter",props:{options:[{label:"上升",value:"up"},{label:"下降",value:"down"},{label:"持平",value:"flat"}]}},extraProps:{defaultValue:"up"}},{name:"trendSuffix",title:"趋势后缀",setter:"StringSetter",extraProps:{defaultValue:"%"}}]},{type:"group",key:"style",title:"样式",items:[{name:"fontSize",title:"字体大小",setter:{componentName:"SliderSetter",props:{min:12,max:120,step:2,suffix:"px"}},extraProps:{defaultValue:48}},{name:"fontFamily",title:"字体类型",setter:{componentName:"SelectSetter",props:{options:[{label:"数码字体",value:"digital"},{label:"默认字体",value:"default"}]}},extraProps:{defaultValue:"digital"}},{name:"color",title:"颜色",setter:"ColorSetter",extraProps:{defaultValue:"#00d4ff"}},{name:"glowIntensity",title:"发光强度",setter:{componentName:"SliderSetter",props:{min:0,max:2,step:.1}},extraProps:{defaultValue:.5}}]}]}],{padding:"6px 16px 12px"}),{name:"$data",title:"数据配置",setter:{componentName:"DataSetter",props:{expectedFields:[{name:"value",label:"value",type:"number",required:!0,description:"数值"}],showPreview:!0,previewLimit:10}},extraProps:{label:!1}});const d={componentName:s,title:"数字翻牌",group:"display",devMode:"proCode",npm:{package:"@easy-editor/materials-dashboard-number-flip",version:"0.0.4",globalName:s,componentName:s},snippets:[{title:"数字翻牌",screenshot:"",schema:{componentName:s,title:"数字翻牌",props:{$data:t({value:1234567}),decimals:0,separator:!0,fontSize:48,fontFamily:"digital",color:"#00d4ff",glowIntensity:.5,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:280,height:80}}}},{title:"货币数字",screenshot:"",schema:{componentName:s,title:"货币数字",props:{$data:t({value:99999.99}),decimals:2,separator:!0,prefix:"$",fontSize:42,fontFamily:"digital",color:"#00ff88",glowIntensity:.6,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:260,height:70}}}},{title:"百分比",screenshot:"",schema:{componentName:s,title:"百分比",props:{$data:t({value:87.5}),decimals:1,separator:!1,suffix:"%",fontSize:56,fontFamily:"digital",color:"#ff6b6b",glowIntensity:.8,rotation:0,opacity:100,background:"transparent"},$dashboard:{rect:{width:200,height:90}}}}],configure:p};e.meta=d});