@onehat/ui 0.2.13 → 0.2.15
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onehat/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "Base UI for OneHat apps",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"react-color": "^2.19.3",
|
|
33
33
|
"react-datetime": "^3.2.0",
|
|
34
34
|
"react-draggable": "^4.4.5",
|
|
35
|
+
"react-native-draggable": "^3.3.0",
|
|
35
36
|
"react-dom": "*",
|
|
36
37
|
"react-native": "*"
|
|
37
38
|
},
|
|
@@ -50,7 +50,8 @@ const
|
|
|
50
50
|
setRadioes(radios);
|
|
51
51
|
}, [value]);
|
|
52
52
|
|
|
53
|
-
return <Radio.Group onChange={props.setValue} accessibilityLabel={props.name} ref={props.outerRef} {...props}>
|
|
53
|
+
// return <Radio.Group onChange={props.setValue} accessibilityLabel={props.name} ref={props.outerRef} {...props}> // RadioGroup from NativeBase doesn't yet allow refs
|
|
54
|
+
return <Radio.Group onChange={props.setValue} accessibilityLabel={props.name} {...props}>
|
|
54
55
|
{radios}
|
|
55
56
|
</Radio.Group>;
|
|
56
57
|
},
|
|
@@ -6,14 +6,20 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
UI_MODE_WEB,
|
|
8
8
|
UI_MODE_REACT_NATIVE,
|
|
9
|
+
CURRENT_MODE,
|
|
9
10
|
} from '../../Constants/UiModes.js';
|
|
10
|
-
import UiGlobals from '../../UiGlobals.js';
|
|
11
|
-
import Draggable from 'react-draggable'; // https://github.com/react-grid-layout/react-draggable
|
|
12
11
|
import useBlocking from '../../Hooks/useBlocking.js';
|
|
13
12
|
import {
|
|
14
13
|
v4 as uuid,
|
|
15
14
|
} from 'uuid';
|
|
16
15
|
|
|
16
|
+
let Draggable;
|
|
17
|
+
if (CURRENT_MODE === UI_MODE_WEB) {
|
|
18
|
+
Draggable = await import('react-draggable'); // https://github.com/react-grid-layout/react-draggable
|
|
19
|
+
} else if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
|
|
20
|
+
Draggable = await import('react-native-draggable'); // https://github.com/tongyy/react-native-draggable
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
// Note on modes:
|
|
18
24
|
// HORIZONTAL means the component moves along the X axis.
|
|
19
25
|
// VERTICAL means the component moves along the Y axis.
|
|
@@ -21,9 +27,6 @@ import {
|
|
|
21
27
|
export default function withDraggable(WrappedComponent) {
|
|
22
28
|
return (props) => {
|
|
23
29
|
|
|
24
|
-
if (UiGlobals.mode === UI_MODE_REACT_NATIVE) {
|
|
25
|
-
throw new Error('Not yet implemented for RN.');
|
|
26
|
-
}
|
|
27
30
|
const {
|
|
28
31
|
// extract and pass
|
|
29
32
|
onDragStart,
|
|
@@ -216,44 +219,54 @@ export default function withDraggable(WrappedComponent) {
|
|
|
216
219
|
};
|
|
217
220
|
propsToPass.isDragging = isDragging;
|
|
218
221
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
222
|
+
|
|
223
|
+
if (CURRENT_MODE === UI_MODE_WEB) {
|
|
224
|
+
if (mode === VERTICAL) {
|
|
225
|
+
return <Draggable
|
|
226
|
+
axis="x"
|
|
227
|
+
onStart={handleStart}
|
|
228
|
+
onDrag={handleDrag}
|
|
229
|
+
onStop={handleStop}
|
|
230
|
+
position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
231
|
+
// bounds={bounds}
|
|
232
|
+
>
|
|
233
|
+
<div className="nsResize" style={{ width: '100%', }}>
|
|
234
|
+
<WrappedComponent {...propsToPass} />
|
|
235
|
+
</div>
|
|
236
|
+
</Draggable>;
|
|
237
|
+
} else if (mode === HORIZONTAL) {
|
|
238
|
+
return <Draggable
|
|
239
|
+
axis="y"
|
|
240
|
+
onStart={handleStart}
|
|
241
|
+
onDrag={handleDrag}
|
|
242
|
+
onStop={handleStop}
|
|
243
|
+
position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
244
|
+
// bounds={bounds}
|
|
245
|
+
>
|
|
246
|
+
<div className="ewResize" style={{ height: '100%', }}>
|
|
247
|
+
<WrappedComponent {...propsToPass} />
|
|
248
|
+
</div>
|
|
249
|
+
</Draggable>;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// can drag in all directions
|
|
233
253
|
return <Draggable
|
|
234
|
-
axis="
|
|
254
|
+
axis="both"
|
|
235
255
|
onStart={handleStart}
|
|
236
256
|
onDrag={handleDrag}
|
|
237
257
|
onStop={handleStop}
|
|
238
|
-
position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
239
|
-
|
|
258
|
+
// position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
259
|
+
handle={handle}
|
|
240
260
|
>
|
|
241
|
-
<
|
|
242
|
-
<WrappedComponent {...propsToPass} />
|
|
243
|
-
</div>
|
|
261
|
+
<WrappedComponent {...propsToPass} />
|
|
244
262
|
</Draggable>;
|
|
245
|
-
}
|
|
263
|
+
} else if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
|
|
246
264
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// position={{ x: 0, y: 0, /* reset to dropped position */ }}
|
|
254
|
-
handle={handle}
|
|
255
|
-
>
|
|
256
|
-
<WrappedComponent {...propsToPass} />
|
|
257
|
-
</Draggable>;
|
|
265
|
+
// NOT YET IMPLEMENTED
|
|
266
|
+
// Really need to replace most of this, as much of it is web-centric.
|
|
267
|
+
|
|
268
|
+
return <WrappedComponent {...propsToPass} />; // TEMP
|
|
269
|
+
|
|
270
|
+
}
|
|
258
271
|
};
|
|
259
272
|
}
|
package/src/UiGlobals.js
CHANGED