@onehat/ui 0.3.31 → 0.3.33

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/Components/Buttons/Button.js +20 -0
  3. package/src/Components/Buttons/IconButton.js +68 -51
  4. package/src/Components/Buttons/SquareButton.js +6 -4
  5. package/src/Components/Container/Container.js +4 -1
  6. package/src/Components/Container/ScreenContainer.js +4 -1
  7. package/src/Components/Editor/Editor.js +15 -1
  8. package/src/Components/Form/Field/CKEditor/CKEditor.js +2 -1
  9. package/src/Components/Form/Field/Checkbox/Checkbox.js +2 -1
  10. package/src/Components/Form/Field/Color.js +2 -1
  11. package/src/Components/Form/Field/Combo/Combo.js +7 -4
  12. package/src/Components/Form/Field/Date.js +2 -1
  13. package/src/Components/Form/Field/DisplayField.js +2 -1
  14. package/src/Components/Form/Field/File.js +2 -1
  15. package/src/Components/Form/Field/Input.js +2 -1
  16. package/src/Components/Form/Field/Number.js +2 -1
  17. package/src/Components/Form/Field/RadioGroup/RadioGroup.js +2 -1
  18. package/src/Components/Form/Field/Text.js +2 -1
  19. package/src/Components/Form/Field/TextArea.js +3 -2
  20. package/src/Components/Form/Field/Toggle.js +2 -1
  21. package/src/Components/Form/Form.js +93 -45
  22. package/src/Components/Grid/Grid.js +67 -53
  23. package/src/Components/Grid/GridHeaderRow.js +5 -2
  24. package/src/Components/Grid/GridRow.js +8 -2
  25. package/src/Components/Hoc/withAlert.js +1 -3
  26. package/src/Components/Hoc/withComponent.js +65 -0
  27. package/src/Components/Hoc/withData.js +6 -0
  28. package/src/Components/Hoc/withEditor.js +54 -4
  29. package/src/Components/Hoc/withFilters.js +35 -5
  30. package/src/Components/Hoc/withInlineEditor.js +4 -0
  31. package/src/Components/Hoc/withPdfButton.js +12 -13
  32. package/src/Components/Hoc/withPresetButtons.js +14 -1
  33. package/src/Components/Hoc/withSelection.js +16 -0
  34. package/src/Components/Hoc/withSideEditor.js +7 -1
  35. package/src/Components/Hoc/withWindowedEditor.js +7 -1
  36. package/src/Components/Icons/HighPriority.js +20 -0
  37. package/src/Components/Icons/LowPriority.js +20 -0
  38. package/src/Components/Icons/MedPriority.js +20 -0
  39. package/src/Components/Icons/Pdf.js +14 -0
  40. package/src/Components/Screens/Manager.js +5 -2
  41. package/src/Components/Tab/TabBar.js +5 -2
  42. package/src/Components/Toolbar/Pagination.js +2 -1
  43. package/src/Components/Tree/Tree.js +47 -40
  44. package/src/Components/Viewer/TagViewer.js +3 -1
  45. package/src/Components/Viewer/Viewer.js +57 -14
  46. package/src/Components/index.js +2 -0
  47. package/src/Functions/getIconButtonFromConfig.js +3 -1
  48. package/src/Components/Form/Field/Field.js +0 -14
  49. package/src/Components/Grid/ReactGrid.js +0 -468
  50. package/src/Components/Grid/SenchaGrid.js +0 -421
  51. package/src/Components/Grid/reactgrid.css +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -0,0 +1,20 @@
1
+ import { useEffect, useRef, } from 'react';
2
+ import {
3
+ Button,
4
+ } from 'native-base';
5
+ import withComponent from '../Hoc/withComponent.js';
6
+
7
+ const ButtonComponent = function(props) {
8
+ const {
9
+ self,
10
+ } = props,
11
+ buttonRef = useRef();
12
+
13
+ useEffect(() => {
14
+ self.ref = buttonRef.current;
15
+ }, []);
16
+
17
+ return <Button ref={buttonRef} {...props} />;
18
+ }
19
+
20
+ export default withComponent(ButtonComponent);
@@ -1,62 +1,79 @@
1
- import React from 'react';
1
+ import React, { useEffect, useRef, } from 'react';
2
2
  import {
3
3
  Icon,
4
4
  Pressable,
5
5
  Spinner,
6
6
  Tooltip,
7
7
  } from 'native-base';
8
+ import withComponent from '../Hoc/withComponent.js';
8
9
  import styles from '../../Constants/Styles.js';
9
10
  import _ from 'lodash';
10
11
 
11
- const IconButton = React.forwardRef((props, ref) => {
12
- const {
13
- // _icon, // props for the icon component
14
- // icon, // The actual icon component to use
15
- _spinner,
16
- isLoading = false,
17
- tooltip,
18
- tooltipPlacement = 'bottom',
19
- } = props;
20
- const propsIcon = props._icon || {};
21
- let icon = props.icon,
22
- ret;
23
- if (isLoading) {
24
- icon = <Spinner {..._spinner} />;
25
- }
26
- if (React.isValidElement(icon)) {
27
- if (!_.isEmpty(propsIcon)) {
28
- icon = React.cloneElement(icon, {...propsIcon});
12
+ const
13
+ IconButton = (props) => {
14
+ const {
15
+ // _icon, // props for the icon component
16
+ // icon, // The actual icon component to use
17
+ _spinner,
18
+ isLoading = false,
19
+ tooltip,
20
+ tooltipPlacement = 'bottom',
21
+ self,
22
+ } = props;
23
+ let ref = props.outerRef;
24
+
25
+ if (!ref) {
26
+ ref = useRef();
29
27
  }
30
- } else {
31
- icon = <Icon as={icon} {...propsIcon} />;
32
- }
33
- const pressable = <Pressable
34
- ref={ref}
35
- borderRadius="md"
36
- colorScheme="primary"
37
- flexDirection="row"
38
- justifyContent="center"
39
- alignItems="center"
40
- p={2}
41
- // bg={styles.ICON_BUTTON_BG}
42
- _hover={{
43
- bg: styles.ICON_BUTTON_BG_HOVER,
44
- }}
45
- _disabled={{
46
- bg: styles.ICON_BUTTON_BG_DISABLED,
47
- }}
48
- _pressed={{
49
- bg: styles.ICON_BUTTON_BG_PRESSED,
50
- }}
51
- {...props}
52
- >
53
- {icon}
54
- </Pressable>;
55
- ret = pressable;
56
- if (tooltip) {
57
- ret = <Tooltip label={tooltip} placement={tooltipPlacement}>{ret}</Tooltip>;
58
- }
59
- return ret;
60
- });
61
28
 
62
- export default IconButton;
29
+ useEffect(() => {
30
+ self.ref = ref.current;
31
+ }, []);
32
+
33
+ const propsIcon = props._icon || {};
34
+ let icon = props.icon,
35
+ ret;
36
+ if (isLoading) {
37
+ icon = <Spinner {..._spinner} />;
38
+ }
39
+ if (React.isValidElement(icon)) {
40
+ if (!_.isEmpty(propsIcon)) {
41
+ icon = React.cloneElement(icon, {...propsIcon});
42
+ }
43
+ } else {
44
+ icon = <Icon as={icon} {...propsIcon} />;
45
+ }
46
+ const pressable = <Pressable
47
+ ref={ref}
48
+ borderRadius="md"
49
+ colorScheme="primary"
50
+ flexDirection="row"
51
+ justifyContent="center"
52
+ alignItems="center"
53
+ p={2}
54
+ // bg={styles.ICON_BUTTON_BG}
55
+ _hover={{
56
+ bg: styles.ICON_BUTTON_BG_HOVER,
57
+ }}
58
+ _disabled={{
59
+ bg: styles.ICON_BUTTON_BG_DISABLED,
60
+ }}
61
+ _pressed={{
62
+ bg: styles.ICON_BUTTON_BG_PRESSED,
63
+ }}
64
+ {...props}
65
+ >
66
+ {icon}
67
+ </Pressable>;
68
+ ret = pressable;
69
+ if (tooltip) {
70
+ ret = <Tooltip label={tooltip} placement={tooltipPlacement}>{ret}</Tooltip>;
71
+ }
72
+ return ret;
73
+ },
74
+ IconButtonComponent = withComponent(IconButton);
75
+
76
+ // withComponent needs us to forwardRef
77
+ export default React.forwardRef((props, ref) => {
78
+ return <IconButtonComponent {...props} outerRef={ref} />;
79
+ });
@@ -10,11 +10,13 @@ export default function SquareButton(props) {
10
10
  const {
11
11
  text,
12
12
  isActive = false,
13
+ activeColor,
14
+ invertColorWhenActive = false,
13
15
  disableInteractions = false,
14
16
  ...propsToPass
15
17
  } = props,
16
18
  styles = UiGlobals.styles,
17
- color = isActive ? '#fff' : '#000';
19
+ color = invertColorWhenActive && isActive ? '#fff' : '#000';
18
20
  const propsIcon = props._icon || {};
19
21
  let icon = props.icon;
20
22
  if (!icon) {
@@ -47,9 +49,9 @@ export default function SquareButton(props) {
47
49
  alignItems="center"
48
50
  p={2}
49
51
  {...propsToPass}
50
- bg={isActive ? '#56a6f8' : '#fff'}
51
- _hover={hoverProps}
52
- _pressed={pressedProps}
52
+ bg={isActive ? activeColor || '#56a6f8' : '#fff'}
53
+ // _hover={hoverProps}
54
+ // _pressed={pressedProps}
53
55
  >
54
56
  <Icon as={icon} color={color} size="xl" />
55
57
  <Text fontSize={20} color={color}>{text}</Text>
@@ -12,12 +12,13 @@ import {
12
12
  UI_MODE_REACT_NATIVE,
13
13
  CURRENT_MODE,
14
14
  } from '../../Constants/UiModes.js';
15
+ import withComponent from '../Hoc/withComponent.js';
15
16
  import getSaved from '../../Functions/getSaved.js';
16
17
  import setSaved from '../../Functions/setSaved.js';
17
18
  import Splitter from './Splitter.js';
18
19
  import _ from 'lodash';
19
20
 
20
- export default function Container(props) {
21
+ function Container(props) {
21
22
  const {
22
23
  center,
23
24
  north,
@@ -281,3 +282,5 @@ export default function Container(props) {
281
282
  {southComponent}
282
283
  </Column>;
283
284
  }
285
+
286
+ export default withComponent(Container);
@@ -8,10 +8,11 @@ import {
8
8
  ScrollView,
9
9
  KeyboardAvoidingView,
10
10
  } from 'native-base';
11
+ import withComponent from '../Hoc/withComponent.js';
11
12
  // import { useHeaderHeight } from '@react-navigation/elements';
12
13
  // import testProps from '../OneHat/functions/testProps';
13
14
 
14
- export default function ScreenContainer(props) {
15
+ function ScreenContainer(props) {
15
16
  const {
16
17
  screenName = 'ScreenContainer',
17
18
  p = 0,
@@ -79,3 +80,5 @@ export default function ScreenContainer(props) {
79
80
  }
80
81
  return column;
81
82
  }
83
+
84
+ export default withComponent(ScreenContainer);
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  EDITOR_MODE__VIEW,
3
3
  } from '../../Constants/Editor.js';
4
+ import withComponent from '../Hoc/withComponent.js';
4
5
  import Form from '../Form/Form.js';
5
6
  import Viewer from '../Viewer/Viewer.js';
6
7
  import _ from 'lodash';
7
8
 
8
- export default function Editor(props) {
9
+ function Editor(props) {
9
10
  const {
10
11
  isEditorViewOnly,
11
12
  onEditorCancel: onCancel,
@@ -14,6 +15,11 @@ export default function Editor(props) {
14
15
  onEditorDelete: onDelete,
15
16
  editorMode,
16
17
  onEditMode,
18
+ _viewer = {},
19
+ _form = {},
20
+
21
+ // withComponent
22
+ self,
17
23
 
18
24
  // withSelection
19
25
  selection,
@@ -36,6 +42,9 @@ export default function Editor(props) {
36
42
  onEditMode={isEditorViewOnly ? null : onEditMode}
37
43
  onClose={onClose}
38
44
  onDelete={onDelete}
45
+ parent={self}
46
+ reference="viewer"
47
+ {..._viewer}
39
48
  />;
40
49
  }
41
50
 
@@ -46,5 +55,10 @@ export default function Editor(props) {
46
55
  onSave={onSave}
47
56
  onClose={onClose}
48
57
  onDelete={onDelete}
58
+ parent={self}
59
+ reference="form"
60
+ {..._form}
49
61
  />;
50
62
  }
63
+
64
+ export default withComponent(Editor);
@@ -8,6 +8,7 @@ import {
8
8
  import { CKEditor } from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
9
9
  import './ckeditor.css';
10
10
  import Editor from '../../../../../ckeditor5/build/ckeditor.js'; // built using https://ckeditor.com/ckeditor-5/online-builder/
11
+ import withComponent from '../../../Hoc/withComponent.js';
11
12
  import withValue from '../../../Hoc/withValue.js';
12
13
  import withTooltip from '../../../Hoc/withTooltip.js';
13
14
  import _ from 'lodash';
@@ -53,7 +54,7 @@ const
53
54
  />
54
55
  </Row>;
55
56
  },
56
- CKEditorField = withValue(CKEditorElement);
57
+ CKEditorField = withComponent(withValue(CKEditorElement));
57
58
 
58
59
 
59
60
  export default CKEditorField;
@@ -1,4 +1,5 @@
1
1
  import CheckboxButton from '../../../Buttons/CheckboxButton.js';
2
+ import withComponent from '../../../Hoc/withComponent.js';
2
3
  import withValue from '../../../Hoc/withValue.js';
3
4
  import _ from 'lodash';
4
5
 
@@ -21,6 +22,6 @@ const
21
22
  />;
22
23
 
23
24
  },
24
- CheckboxEField = withValue(CheckboxElement);
25
+ CheckboxEField = withComponent(withValue(CheckboxElement));
25
26
 
26
27
  export default CheckboxEField;
@@ -12,6 +12,7 @@ import {
12
12
  } from '../../../Constants/UiModes.js';
13
13
  import UiGlobals from '../../../UiGlobals.js';
14
14
  import Input from '../Field/Input.js';
15
+ import withComponent from '../../Hoc/withComponent.js';
15
16
  import withValue from '../../Hoc/withValue.js';
16
17
  import emptyFn from '../../../Functions/emptyFn.js';
17
18
  import _ from 'lodash';
@@ -223,4 +224,4 @@ export function ColorElement(props) {
223
224
 
224
225
  }
225
226
 
226
- export default withValue(ColorElement);
227
+ export default withComponent(withValue(ColorElement));
@@ -12,6 +12,7 @@ import {
12
12
  } from '../../../../Constants/UiModes.js';
13
13
  import UiGlobals from '../../../../UiGlobals.js';
14
14
  import Input from '../Input.js';
15
+ import withComponent from '../../../Hoc/withComponent.js';
15
16
  import withData from '../../../Hoc/withData.js';
16
17
  import withSelection from '../../../Hoc/withSelection.js';
17
18
  import withValue from '../../../Hoc/withValue.js';
@@ -540,10 +541,12 @@ export function ComboComponent(props) {
540
541
  return comboComponent;
541
542
  }
542
543
 
543
- export const Combo = withData(
544
- withValue(
545
- withSelection(
546
- ComboComponent
544
+ export const Combo = withComponent(
545
+ withData(
546
+ withValue(
547
+ withSelection(
548
+ ComboComponent
549
+ )
547
550
  )
548
551
  )
549
552
  );
@@ -20,6 +20,7 @@ import Formatters from '@onehat/data/src/Util/Formatters.js';
20
20
  import Parsers from '@onehat/data/src/Util/Parsers.js';
21
21
  import Input from '../Field/Input.js';
22
22
  import IconButton from '../../Buttons/IconButton.js';
23
+ import withComponent from '../../Hoc/withComponent.js';
23
24
  import withValue from '../../Hoc/withValue.js';
24
25
  import emptyFn from '../../../Functions/emptyFn.js';
25
26
  import Calendar from '../../Icons/Calendar.js';
@@ -365,4 +366,4 @@ export function DateElement(props) {
365
366
  // </Box>;
366
367
  };
367
368
 
368
- export default withValue(DateElement);
369
+ export default withComponent(withValue(DateElement));
@@ -3,6 +3,7 @@ import {
3
3
  Text,
4
4
  } from 'native-base';
5
5
  import UiGlobals from '../../../UiGlobals.js';
6
+ import withComponent from '../../Hoc/withComponent.js';
6
7
  import withTooltip from '../../Hoc/withTooltip.js';
7
8
  import withValue from '../../Hoc/withValue.js';
8
9
 
@@ -21,7 +22,7 @@ const
21
22
  {...props}
22
23
  >{text}</Text>;
23
24
  },
24
- DisplayField = withValue(DisplayElement);
25
+ DisplayField = withComponent(withValue(DisplayElement));
25
26
 
26
27
  // Tooltip needs us to forwardRef
27
28
  export default withTooltip(React.forwardRef((props, ref) => {
@@ -17,6 +17,7 @@ import {
17
17
  FILE_MODE_FILE,
18
18
  } from '../../../Constants/File.js';
19
19
  import IconButton from '../../Buttons/IconButton.js';
20
+ import withComponent from '../../Hoc/withComponent.js';
20
21
  import withValue from '../../Hoc/withValue.js';
21
22
  import File from '../../Icons/File.js';
22
23
  import Trash from '../../Icons/Trash.js';
@@ -219,4 +220,4 @@ function FileElement(props) {
219
220
  </div>;
220
221
  }
221
222
 
222
- export default withValue(FileElement);
223
+ export default withComponent(withValue(FileElement));
@@ -7,6 +7,7 @@ import {
7
7
  AUTO_SUBMIT_DELAY,
8
8
  } from '../../../Constants/Input.js';
9
9
  import UiGlobals from '../../../UiGlobals.js';
10
+ import withComponent from '../../Hoc/withComponent.js';
10
11
  import withValue from '../../Hoc/withValue.js';
11
12
  import _ from 'lodash';
12
13
 
@@ -89,7 +90,7 @@ function InputElement(props) {
89
90
  }
90
91
 
91
92
  const
92
- InputField = withValue(InputElement),
93
+ InputField = withComponent(withValue(InputElement)),
93
94
  InputForwardRef = React.forwardRef((props, ref) => {
94
95
  return <InputField {...props} outerRef={ref} component="Input" />;
95
96
  });
@@ -10,6 +10,7 @@ import {
10
10
  } from '../../../Constants/Input.js';
11
11
  import UiGlobals from '../../../UiGlobals.js';
12
12
  import IconButton from '../../Buttons/IconButton.js';
13
+ import withComponent from '../../Hoc/withComponent.js';
13
14
  import withTooltip from '../../Hoc/withTooltip.js';
14
15
  import withValue from '../../Hoc/withValue.js';
15
16
  import Plus from '../../Icons/Plus.js';
@@ -165,4 +166,4 @@ function NumberElement(props) {
165
166
  </Row>;
166
167
  }
167
168
 
168
- export default withValue(NumberElement);
169
+ export default withComponent(withValue(NumberElement));
@@ -4,6 +4,7 @@ import {
4
4
  Radio,
5
5
  Row,
6
6
  } from 'native-base';
7
+ import withComponent from '../../../Hoc/withComponent.js';
7
8
  import withData from '../../../Hoc/withData.js';
8
9
  import withValue from '../../../Hoc/withValue.js';
9
10
  import withTooltip from '../../../Hoc/withTooltip.js';
@@ -55,7 +56,7 @@ const
55
56
  {radios}
56
57
  </Radio.Group>;
57
58
  },
58
- RadioGroupField = withValue(withData(RadioGroupElement));
59
+ RadioGroupField = withComponent(withValue(withData(RadioGroupElement)));
59
60
 
60
61
  // Tooltip needs us to forwardRef
61
62
  export default withTooltip(React.forwardRef((props, ref) => {
@@ -3,6 +3,7 @@ import {
3
3
  Text,
4
4
  } from 'native-base';
5
5
  import UiGlobals from '../../../UiGlobals.js';
6
+ import withComponent from '../../Hoc/withComponent.js';
6
7
  import withTooltip from '../../Hoc/withTooltip.js';
7
8
 
8
9
  const
@@ -20,7 +21,7 @@ const
20
21
  {...props}
21
22
  >{props.value}</Text>;
22
23
  },
23
- TextField = TextElement; // NOT using withValue on Text element, as this element is simply for display purposes!
24
+ TextField = withComponent(TextElement); // NOT using withValue on Text element, as this element is simply for display purposes!
24
25
 
25
26
  // Tooltip needs us to forwardRef
26
27
  export default withTooltip(React.forwardRef((props, ref) => {
@@ -3,6 +3,7 @@ import {
3
3
  TextArea,
4
4
  } from 'native-base';
5
5
  import UiGlobals from '../../../UiGlobals.js';
6
+ import withComponent from '../../Hoc/withComponent.js';
6
7
  import withTooltip from '../../Hoc/withTooltip.js';
7
8
  import withValue from '../../Hoc/withValue.js';
8
9
  import _ from 'lodash';
@@ -23,9 +24,9 @@ const
23
24
  value={value}
24
25
  />;
25
26
  },
26
- TextAreaField = withValue(TextAreaElement);
27
+ TextAreaField = withComponent(withValue(TextAreaElement));
27
28
 
28
- // Tooltip needs us to forwardRef
29
+ // withTooltip needs us to forwardRef
29
30
  export default withTooltip(React.forwardRef((props, ref) => {
30
31
  return <TextAreaField {...props} outerRef={ref} />;
31
32
  }));
@@ -9,6 +9,7 @@ import {
9
9
  import UiGlobals from '../../../UiGlobals.js';
10
10
  import IconButton from '../../Buttons/IconButton.js';
11
11
  import Na from '../../Icons/Na.js';
12
+ import withComponent from '../../Hoc/withComponent.js';
12
13
  import withTooltip from '../../Hoc/withTooltip.js';
13
14
  import withValue from '../../Hoc/withValue.js';
14
15
  import _ from 'lodash';
@@ -72,7 +73,7 @@ const
72
73
  </Pressable>
73
74
  </Row>;
74
75
  },
75
- ToggleField = withValue(ToggleElement);
76
+ ToggleField = withComponent(withValue(ToggleElement));
76
77
 
77
78
  // Tooltip needs us to forwardRef
78
79
  export default withTooltip(React.forwardRef((props, ref) => {