@onehat/ui 0.2.38 → 0.2.39

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.38",
3
+ "version": "0.2.39",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,12 +1,17 @@
1
- import React from 'react';
1
+ import React, { useRef, } from 'react';
2
2
  import {
3
+ Icon,
4
+ Pressable,
3
5
  Row,
4
6
  Switch,
5
7
  Text,
6
8
  } from 'native-base';
7
9
  import UiGlobals from '../../../UiGlobals.js';
10
+ import IconButton from '../../Buttons/IconButton.js';
11
+ import Na from '../../Icons/Na.js';
8
12
  import withTooltip from '../../Hoc/withTooltip.js';
9
13
  import withValue from '../../Hoc/withValue.js';
14
+ import _ from 'lodash';
10
15
 
11
16
  const
12
17
  ToggleElement = (props) => {
@@ -16,28 +21,52 @@ const
16
21
  flex, // flex doesn't work right on mobile
17
22
  ...propsToPass
18
23
  } = props,
24
+ isBlocked = useRef(false),
19
25
  styles = UiGlobals.styles,
20
- onToggle = () => {
21
- setValue(!value);
26
+ onToggle = (val, e) => {
27
+ if (!isBlocked.current) {
28
+ setValue(!value);
29
+ }
30
+ },
31
+ onNullify = (e) => {
32
+ if (e.shiftKey) {
33
+ // If user presses shift key while pressing...
34
+ // Set value to null, and tempoarily disable the onToggle method
35
+ setValue(null);
36
+ isBlocked.current = true;
37
+ setTimeout(() => {
38
+ isBlocked.current = false;
39
+ }, 200);
40
+ }
22
41
  };
23
42
 
43
+ if (_.isNil(value)) {
44
+ return <IconButton
45
+ icon={<Icon as={Na} color="trueGray.400" />}
46
+ onPress={onToggle}
47
+ borderWidth={1}
48
+ borderColor="trueGray.700"
49
+ />;
50
+ }
51
+
24
52
  return <Row alignItems="center">
25
- <Switch
26
- ref={props.outerRef}
27
- onToggle={onToggle}
28
- isChecked={!!value}
29
- // flex={1}
30
- bg={styles.FORM_TOGGLE_BG}
31
- size={styles.FORM_TOGGLE_SIZE}
32
- onTrackColor={styles.FORM_TOGGLE_ON_COLOR}
33
- offTrackColor={styles.FORM_TOGGLE_OFF_COLOR}
34
- _hover={{
35
- onTrackColor: styles.FORM_TOGGLE_ON_HOVER_COLOR,
36
- offTrackColor: styles.FORM_TOGGLE_OFF_HOVER_COLOR,
37
- }}
38
- {...propsToPass}
39
- />
40
- <Text fontSize={styles.FORM_TOGGLE_FONTSIZE}>{!!value ? 'Yes' : 'No'}</Text>
53
+ <Pressable onPress={onNullify}>
54
+ <Switch
55
+ ref={props.outerRef}
56
+ onToggle={onToggle}
57
+ isChecked={!!value}
58
+ bg={styles.FORM_TOGGLE_BG}
59
+ size={styles.FORM_TOGGLE_SIZE}
60
+ onTrackColor={styles.FORM_TOGGLE_ON_COLOR}
61
+ offTrackColor={styles.FORM_TOGGLE_OFF_COLOR}
62
+ _hover={{
63
+ onTrackColor: styles.FORM_TOGGLE_ON_HOVER_COLOR,
64
+ offTrackColor: styles.FORM_TOGGLE_OFF_HOVER_COLOR,
65
+ }}
66
+ {...propsToPass}
67
+ />
68
+ </Pressable>
69
+ <Text ml={2} fontSize={styles.FORM_TOGGLE_FONTSIZE}>{_.isNil(value) ? 'N/A' : (!!value ? 'Yes' : 'No')}</Text>
41
70
  </Row>;
42
71
  },
43
72
  ToggleField = withValue(ToggleElement);
@@ -209,8 +209,8 @@ export default function withFilters(WrappedComponent) {
209
209
  {...modelProps}
210
210
  />;
211
211
  if (showLabels) {
212
- filterElement = <Row key={'label-' + ix}>
213
- <Text fontSize={styles.FILTER_LABEL_FONTSIZE}>{titles[fieldName]}:</Text>
212
+ filterElement = <Row key={'label-' + ix} alignItems="center">
213
+ <Text ml={2} mr={1} fontSize={styles.FILTER_LABEL_FONTSIZE}>{titles[fieldName]}</Text>
214
214
  {filterElement}
215
215
  </Row>;
216
216
  }
@@ -11,12 +11,14 @@ export default function withSideEditor(WrappedComponent) {
11
11
  const {
12
12
  Editor,
13
13
  editorProps = {},
14
+ sideFlex = 100,
14
15
  } = props;
15
16
 
16
17
  return <Container
17
18
  center={<WrappedComponent {...props} />}
18
19
  east={<Editor
19
20
  editorType={EDITOR_TYPE__SIDE}
21
+ flex={sideFlex}
20
22
  {...props}
21
23
  {...editorProps}
22
24
  />}
@@ -0,0 +1,17 @@
1
+ import * as React from "react"
2
+ import Svg, { Path } from "react-native-svg"
3
+ import { Icon } from 'native-base';
4
+
5
+ function SvgComponent(props) {
6
+ return (
7
+ <Icon
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 512.24 402.86"
10
+ {...props}
11
+ >
12
+ <Path d="M0 54.41h36.81L76.09 171.3c11.39 33.02 21.44 68.25 30.17 105.7-3.16-22.64-5.5-43.14-7.02-61.48-1.52-18.34-2.28-35.61-2.28-51.8V54.41h39.66V347.4h-37L55.41 215.52c-4.05-12.27-7.88-24.86-11.48-37.76s-6.93-26.44-9.96-40.61c-.26-1.77-.66-3.92-1.23-6.45-.57-2.53-1.23-5.44-1.99-8.73.38 3.29.69 6.1.95 8.44.25 2.34.44 4.33.57 5.98l2.09 29.79 2.09 36.24c.12 2.03.22 4.49.28 7.4.06 2.91.09 6.2.09 9.87l2.09 127.71H0V54.41zM335.39 0h30.55L191.36 402.86h-30.93L335.39 0zM418.69 54.41h30.74l62.81 292.99h-39.09l-11.01-57.12h-58.07l-11.2 57.12h-37.95l63.76-292.99zm37.76 205.32l-8.73-46.68c-5.82-31.75-10.56-65.66-14.23-101.71-1.77 17.59-4.05 35.39-6.83 53.42-2.79 18.03-6.07 37.16-9.87 57.4l-7.21 37.57h46.87z" />
13
+ </Icon>
14
+ )
15
+ }
16
+
17
+ export default SvgComponent