@aks-dev/easyui 1.0.81 → 1.0.82

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.
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-05-05 14:52:53
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-05-10 18:10:15
6
- * @FilePath: /@aks/easyui/lib/Echarts/EchartsView.tsx
5
+ * @LastEditTime: 2022-07-14 18:24:09
6
+ * @FilePath: /@aks-dev/easyui/lib/Echarts/EchartsView.tsx
7
7
  */
8
8
  import * as React from 'react'
9
9
  import { MeasureOnSuccessCallback, StyleSheet, View, ViewStyle } from 'react-native'
@@ -35,10 +35,14 @@ const EchartsView: React.FC<EchartsViewProps> = (props) => {
35
35
 
36
36
  React.useEffect(() => {
37
37
  containerRef.current?.measure((...args) => {
38
- dispatch({
39
- width: args[2],
40
- height: args[3]
41
- })
38
+ if (args.length > 3) {
39
+ dispatch({
40
+ width: args[2],
41
+ height: args[3]
42
+ })
43
+ } else {
44
+ console.warn('[sg] EchartsView measure error')
45
+ }
42
46
  })
43
47
 
44
48
  }, [props.style])
package/lib/Hud/Hud.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 14:10:04
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-12 19:12:37
5
+ * @LastEditTime: 2022-07-15 09:58:50
6
6
  * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/Hud.tsx
7
7
  */
8
8
  import * as React from 'react'
@@ -18,12 +18,14 @@ import {
18
18
  import {
19
19
  hideLoading, Loading, loadingRef, showLoading
20
20
  } from './Loading/Loading'
21
+
22
+
21
23
  import {
22
24
  showToast, Toast, toastRef
23
25
  } from './Toast/Toast'
24
26
 
25
27
 
26
-
28
+ import {showPopoverView,hidePopoverView,popoverViewRef,PopoverView} from './PopoverView/PopoverView'
27
29
 
28
30
 
29
31
 
@@ -40,7 +42,8 @@ export const Hud: React.FC<{}> = () => React.cloneElement(
40
42
  <Loading key="hud-0" ref={loadingRef} />,
41
43
  <Toast key="hud-1" ref={toastRef} />,
42
44
  <AlertView key="hud-2" ref={alertViewRef} />,
43
- <AlertBottomView key="hud-3" ref={alertBottomViewRef} />
45
+ <AlertBottomView key="hud-3" ref={alertBottomViewRef} />,
46
+ <PopoverView key="hud-4" ref={popoverViewRef}/>,
44
47
  ]
45
48
  )
46
49
 
@@ -51,4 +54,6 @@ export {
51
54
  showLoading,
52
55
  hideLoading,
53
56
  showAlertBottomModal,
57
+ showPopoverView,
58
+ hidePopoverView
54
59
  }
@@ -0,0 +1,60 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-04-24 14:27:02
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-07-15 10:08:14
6
+ * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/PopoverView/PopoverView.tsx
7
+ */
8
+ import React, { useImperativeHandle, useState } from 'react';
9
+ import { Dimensions, StyleSheet, TouchableOpacity } from 'react-native';
10
+ import type { PopoverViewCurrent, PopoverViewOptions } from '.';
11
+
12
+
13
+
14
+
15
+
16
+
17
+ export const PopoverView = React.forwardRef<PopoverViewCurrent, {}>((_, ref) => {
18
+ const [visible, setVisible] = useState<boolean>(false);
19
+ const [options, setOptions] = useState<Partial<PopoverViewOptions> | undefined>()
20
+
21
+
22
+ useImperativeHandle<unknown, PopoverViewCurrent>(ref, () => ({
23
+ showPopoverView: (options: Partial<PopoverViewOptions>) => {
24
+ setVisible(true);
25
+ setOptions(options)
26
+
27
+ },
28
+ hidePopoverView: () => {
29
+ setVisible(false);
30
+ setOptions(undefined)
31
+ }
32
+ }), [visible])
33
+
34
+ if (!visible)
35
+ return null;
36
+
37
+ return (
38
+ <TouchableOpacity activeOpacity={1} style={[styles.container,options.style]} onPress={e=>{
39
+ setVisible(false);
40
+ setOptions(undefined)
41
+ // e.stopPropagation()
42
+ }}>
43
+ {React.isValidElement(options.content) && options.content}
44
+ </TouchableOpacity>
45
+ )
46
+ })
47
+
48
+ export const popoverViewRef = React.createRef<PopoverViewCurrent>();
49
+ export const showPopoverView = (options: Partial<PopoverViewOptions>) => popoverViewRef.current?.showPopoverView(options)
50
+ export const hidePopoverView = () => popoverViewRef.current?.hidePopoverView()
51
+
52
+
53
+ const styles = StyleSheet.create({
54
+ container: {
55
+ ...StyleSheet.absoluteFillObject,
56
+ display: 'flex',
57
+
58
+ // backgroundColor:'red'
59
+ },
60
+ })
@@ -0,0 +1,38 @@
1
+
2
+ /*
3
+ * @Author: shiguo
4
+ * @Date: 2022-04-24 14:27:02
5
+ * @LastEditors: shiguo
6
+ * @LastEditTime: 2022-07-15 10:07:56
7
+ * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/PopoverView/index.ts
8
+ */
9
+ import * as React from 'react'
10
+
11
+ import {StyleProp,ViewStyle} from 'react-native'
12
+
13
+
14
+ export type PopoverViewOptions = {
15
+ content: React.ReactNode;
16
+ style: StyleProp<ViewStyle>;
17
+ }
18
+
19
+
20
+
21
+ export declare type PopoverViewCurrent = {
22
+ showPopoverView: (options:Partial<PopoverViewOptions>) => void;
23
+ hidePopoverView: () => void;
24
+ }
25
+
26
+
27
+
28
+
29
+ export declare const showPopoverView: (options:Partial<PopoverViewOptions>) => void;
30
+
31
+
32
+ export declare const hidePopoverView: () => void;
33
+
34
+
35
+ export declare const popoverViewRef: React.RefObject<PopoverViewCurrent>;
36
+
37
+ export declare const PopoverView: React.ForwardRefExoticComponent<React.PropsWithoutRef<PopoverViewOptions> & React.RefAttributes<PopoverViewCurrent>>
38
+
package/lib/Hud/index.ts CHANGED
@@ -2,8 +2,8 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-24 14:14:42
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-12 19:14:17
6
- * @FilePath: /cmwy-device-app/node_modules/@aks-dev/easyui/lib/Hud/index.ts
5
+ * @LastEditTime: 2022-07-15 12:40:12
6
+ * @FilePath: /@aks-dev/easyui/lib/Hud/index.ts
7
7
  */
8
8
 
9
9
 
@@ -14,5 +14,6 @@ export * from './AlertView'
14
14
  export * from './Loading'
15
15
  export * from './Toast'
16
16
  export * from './AlertBottomView'
17
+ export * from './PopoverView'
17
18
 
18
19
  export declare const Hud: React.FC<{}>
@@ -0,0 +1,221 @@
1
+ import React from "react";
2
+ import { Image, LayoutRectangle, MeasureInWindowOnSuccessCallback, ScrollView, StatusBar, Text, TouchableOpacity, View } from 'react-native';
3
+ import type { MenuProps } from '.';
4
+ import { deviceHeight, deviceWidth } from '../../screen/px2dp';
5
+ import { hidePopoverView, showPopoverView } from '../Hud/Hud';
6
+
7
+
8
+ type State = {
9
+ target?: LayoutRectangle;
10
+ arrow?: Partial<{
11
+ left: number | string;
12
+ right: number | string;
13
+ top: number;
14
+ bottom: number;
15
+ }>;
16
+ }
17
+
18
+
19
+ type Reducer = (prevState: State, action: Partial<State>) => State
20
+
21
+
22
+
23
+ export default (props: MenuProps) => {
24
+
25
+ const [state, dispatch] = React.useReducer<Reducer>((prevState, action) => Object.assign({}, prevState, action), {})
26
+
27
+ const containerRef = React.useRef<{ measureInWindow: (callback: MeasureInWindowOnSuccessCallback) => void }>()
28
+ const _container = React.useRef<{
29
+ x: number;
30
+ y: number;
31
+ height: number;
32
+ width: number;
33
+ }>({ x: 0, y: 0, width: 0, height: 0 })
34
+
35
+
36
+ React.useEffect(() => {
37
+ containerRef.current?.measureInWindow((...args) => {
38
+ // console.log('containerRef', args)
39
+ if (args.length == 4) {
40
+ _container.current = {
41
+ x: args[0],
42
+ y: args[1],
43
+ width: args[2],
44
+ height: args[3],
45
+ }
46
+ }
47
+ })
48
+
49
+ })
50
+
51
+
52
+ const getLayoutInfos: () => {
53
+ alignVertical: 'bottom' | 'top';
54
+ alignHorizontal: 'left' | 'right';
55
+ width: number;
56
+ height: number;
57
+ x: number;
58
+ y: number;
59
+ target_width: number;
60
+ target_height: number;
61
+ }
62
+ = () => {
63
+ let alignVertical: 'bottom' | 'top' = 'bottom'
64
+ let alignHorizontal: 'left' | 'right' = 'left'
65
+ let width = _container.current.width
66
+ let height = _container.current.height
67
+ let x = _container.current.x
68
+ let y = (StatusBar.currentHeight || 0) + _container.current.y + height
69
+ if (x > Math.abs(deviceWidth - width - x)) {
70
+ alignHorizontal = 'right'
71
+ }
72
+ if (y > deviceHeight * .5) {
73
+ alignVertical = 'top'
74
+ }
75
+ const target_width = state.target?.width || 0
76
+ const target_height = state.target?.height || 0
77
+ return {
78
+ alignVertical,
79
+ alignHorizontal,
80
+ width,
81
+ height,
82
+ x,
83
+ y,
84
+ target_width,
85
+ target_height,
86
+ }
87
+ }
88
+
89
+
90
+ const reLayout = (): Partial<{
91
+ left: number;
92
+ right: number;
93
+ top: number;
94
+ botttom: number;
95
+ }> => {
96
+ let {
97
+ alignVertical,
98
+ alignHorizontal,
99
+ width,
100
+ height,
101
+ x,
102
+ y,
103
+ target_width,
104
+ target_height,
105
+ } = getLayoutInfos()
106
+
107
+ const toAlignHorizontal = () => {
108
+ if (alignHorizontal == 'left') {
109
+ if (target_width + x > deviceWidth) {
110
+ return {
111
+ left: Math.abs(deviceWidth - target_width) * .7,
112
+ top: y,
113
+ }
114
+ }
115
+ return {
116
+ left: Math.max(x, 15),
117
+ top: y,
118
+ }
119
+ } else {
120
+ let _x = deviceWidth - x - width
121
+ if (target_width + _x > deviceWidth) {
122
+ return {
123
+ right: Math.abs(deviceWidth - target_width) * .7,
124
+ top: y
125
+ }
126
+ }
127
+ return {
128
+ right: Math.max(_x, 15),
129
+ top: y
130
+ }
131
+ }
132
+ }
133
+ if (alignVertical == 'bottom') {
134
+ y = y + 10
135
+ return toAlignHorizontal()
136
+ } else {
137
+ y = (StatusBar.currentHeight || 0) + _container.current.y - target_height - 10
138
+ return toAlignHorizontal()
139
+ }
140
+ }
141
+
142
+
143
+ const show = () => {
144
+ // console.log('_container', _container.current, StatusBar.currentHeight)
145
+ showPopoverView({
146
+ content: (
147
+ <TouchableOpacity
148
+ activeOpacity={1}
149
+ style={{
150
+ position: 'absolute',
151
+ minWidth: deviceWidth * 0.36,
152
+ maxWidth: deviceWidth * 0.8,
153
+ minHeight: 36 + 20,
154
+ maxHeight: 36 * 5 + 20,
155
+ borderRadius: 6, backgroundColor: '#000000ee',
156
+ // overflow: 'hidden' ,
157
+ padding: 10,
158
+ ...reLayout()
159
+ }}
160
+ // onLayout={e=>{
161
+ // console.log('onLayout TouchableOpacity', e.nativeEvent.layout)
162
+ // }}
163
+ >
164
+
165
+ <View style={{
166
+ width: 12, height: 12,
167
+ backgroundColor: '#000000ee', position: 'absolute', zIndex: 1,
168
+ transform: [{ rotateZ: '45deg' }],
169
+ ...(() => {
170
+ const {
171
+ alignVertical,
172
+ alignHorizontal,
173
+ } = getLayoutInfos()
174
+ if (alignVertical == 'bottom' && alignHorizontal == 'left') return { left: '20%', top: -5 }
175
+ if (alignVertical == 'bottom' && alignHorizontal == 'right') return { right: '20%', top: -5 }
176
+ if (alignVertical == 'top' && alignHorizontal == 'left') return { left: '20%', bottom: -5 }
177
+ if (alignVertical == 'top' && alignHorizontal == 'right') return { right: '20%', bottom: -5 }
178
+ return {}
179
+ })()
180
+ }} />
181
+
182
+ <ScrollView onLayout={e => {
183
+ // console.log('onLayout', e.nativeEvent.layout)
184
+ let target: LayoutRectangle = e.nativeEvent.layout
185
+ dispatch({ target })
186
+ }}
187
+ style={{}}
188
+ >
189
+ {props.data?.map((i, idx) => {
190
+ return (
191
+ <TouchableOpacity
192
+ activeOpacity={.7}
193
+ key={`sg-memnu-${idx}`}
194
+ style={{
195
+ height: 36, display: 'flex', flexDirection: 'row', alignItems: 'center'
196
+ // ,backgroundColor:utils.randomcolor()
197
+ }}
198
+ onPress={e => {
199
+ props.onItemClick && props.onItemClick(idx, i.extra)
200
+ hidePopoverView()
201
+ }}
202
+ >
203
+ {i.icon &&
204
+ <Image style={{ width: 18, height: 18, marginRight: 4 }} source={i.icon} />
205
+ }
206
+ <Text style={{ flexShrink: 1, fontSize: 14, color: 'white' }}>{i.text}</Text>
207
+ </TouchableOpacity>
208
+ )
209
+ })}
210
+ </ScrollView>
211
+ </TouchableOpacity>
212
+ )
213
+ })
214
+ }
215
+
216
+ return (
217
+ <TouchableOpacity ref={containerRef as any} onPress={e => show()} >
218
+ {props.children}
219
+ </TouchableOpacity>
220
+ )
221
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * @Author: shiguo
3
+ * @Date: 2022-07-14 18:09:02
4
+ * @LastEditors: shiguo
5
+ * @LastEditTime: 2022-07-15 12:39:20
6
+ * @FilePath: /@aks-dev/easyui/lib/MenuView/index.ts
7
+ */
8
+
9
+ import React from "react";
10
+ import { ImageSourcePropType } from 'react-native';
11
+
12
+
13
+
14
+ export type MenuItem = {
15
+ text: string;
16
+ icon?: ImageSourcePropType;
17
+ extra?:any
18
+ }
19
+
20
+ export type MenuProps = {
21
+ data?: MenuItem[];
22
+ onItemClick?: (index: number,extra?:any) => void;
23
+ } & Readonly<{ children?: React.ReactNode | undefined }>
24
+
25
+
26
+ export declare const MenuView: React.FC<MenuProps>;
@@ -3,8 +3,8 @@ import { TextStyle } from 'react-native';
3
3
  * @Author: shiguo
4
4
  * @Date: 2022-04-24 17:38:32
5
5
  * @LastEditors: shiguo
6
- * @LastEditTime: 2022-05-09 19:34:22
7
- * @FilePath: /@aks/easyui/lib/MutiPictureView/index.ts
6
+ * @LastEditTime: 2022-07-14 15:14:53
7
+ * @FilePath: /@aks-dev/easyui/lib/MutiPictureView/index.ts
8
8
  */
9
9
  import { StyleProp, ViewStyle, ImageStyle, ImageSourcePropType } from 'react-native'
10
10
 
@@ -31,7 +31,9 @@ export declare type MutiPictureViewProps = {
31
31
  /**@deprecated title 标题 ,已弃用*/
32
32
  title?: string;
33
33
  bind: BindProps;
34
+ /**default maxCount is 6 */
34
35
  maxCount?: number;
36
+ /**default type is showImagePicker */
35
37
  type?: 'showImagePicker' | 'openCamera';
36
38
  style?:StyleProp<ViewStyle>;
37
39
  addIcon?: ImageSourcePropType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aks-dev/easyui",
3
- "version": "1.0.81",
3
+ "version": "1.0.82",
4
4
  "description": "移动端App开发工具包",
5
5
  "main": "./src/index.ts",
6
6
  "typings": "./src/index.d.ts",
package/screen/px2dp.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-18 14:32:25
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-06-02 11:04:21
5
+ * @LastEditTime: 2022-07-14 20:19:39
6
6
  * @FilePath: /@aks-dev/easyui/screen/px2dp.ts
7
7
  */
8
8
  import { Dimensions, Platform, StatusBar } from 'react-native';
package/src/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: shiguo
3
3
  * @Date: 2022-04-26 11:44:22
4
4
  * @LastEditors: shiguo
5
- * @LastEditTime: 2022-07-12 15:33:26
5
+ * @LastEditTime: 2022-07-15 12:36:37
6
6
  * @FilePath: /@aks-dev/easyui/src/index.d.ts
7
7
  */
8
8
 
@@ -42,6 +42,8 @@ export * from '../lib/RichText'
42
42
 
43
43
  export * from '../lib/DottedLine'
44
44
 
45
+ export * from '../lib/MenuView'
46
+
45
47
  /// 工具
46
48
  import * as utils from '../utils'
47
49
  export {
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * @Author: shiguo
4
4
  * @Date: 2022-04-13 12:47:34
5
5
  * @LastEditors: shiguo
6
- * @LastEditTime: 2022-07-12 19:38:05
6
+ * @LastEditTime: 2022-07-15 12:40:31
7
7
  * @FilePath: /@aks-dev/easyui/src/index.ts
8
8
  */
9
9
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  export * from '../lib/Badge/Badge'
16
16
 
17
- export { Hud, showLoading, hideLoading, showToast, showAlertModal,showAlertBottomModal } from '../lib/Hud/Hud'
17
+ export { Hud, showLoading, hideLoading, showToast, showAlertModal, showAlertBottomModal, showPopoverView, hidePopoverView } from '../lib/Hud/Hud'
18
18
 
19
19
  export * from '../lib/Modal/Modal'
20
20
 
@@ -44,6 +44,8 @@ export { echarts } from '../lib/Echarts'
44
44
  export { default as RichText } from '../lib/RichText/RichText'
45
45
  export { default as DottedLine } from '../lib/DottedLine/DottedLine'
46
46
 
47
+ export { default as MenuView } from '../lib/MenuView/MenuView'
48
+
47
49
  /// 全局适配
48
50
  export * from '../screen/px2dp'
49
51
  export * from '../screen/px2sp'