@onehat/ui 0.4.85 → 0.4.86

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.4.85",
3
+ "version": "0.4.86",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1138,6 +1138,24 @@ export const ComboComponent = forwardRef((props, ref) => {
1138
1138
  />
1139
1139
  {checkButton}
1140
1140
  </HStack>;
1141
+ let modalBackdrop = <ModalBackdrop />
1142
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
1143
+ // Gluestack's ModalBackdrop was not working on Native,
1144
+ // so workaround is to do it manually for now
1145
+ modalBackdrop = <Pressable
1146
+ onPress={() => setIsMenuShown(false)}
1147
+ className={clsx(
1148
+ 'ModalBackdrop-replacment',
1149
+ 'h-full',
1150
+ 'w-full',
1151
+ 'absolute',
1152
+ 'top-0',
1153
+ 'left-0',
1154
+ 'bg-[#000]',
1155
+ 'opacity-50',
1156
+ )}
1157
+ />;
1158
+ }
1141
1159
  dropdownMenu = <Modal
1142
1160
  isOpen={true}
1143
1161
  safeAreaTop={true}
@@ -1147,7 +1165,7 @@ export const ComboComponent = forwardRef((props, ref) => {
1147
1165
  'w-full',
1148
1166
  )}
1149
1167
  >
1150
- <ModalBackdrop />
1168
+ {modalBackdrop}
1151
1169
  <VStackNative
1152
1170
  className={clsx(
1153
1171
  'h-[400px]',
@@ -1118,13 +1118,10 @@ function GridComponent(props) {
1118
1118
  // Keep the current estimated pageSize, just hide the loading overlay
1119
1119
  }
1120
1120
  },
1121
- adjustPageSizeToHeight = (e) => {
1121
+ adjustPageSizeToHeight = (containerHeight) => {
1122
1122
  if (!Repository || Repository.isDestroyed) { // This method gets delayed, so it's possible for Repository to have been destroyed. Check for this
1123
1123
  return;
1124
1124
  }
1125
- if (onLayout) {
1126
- onLayout(e);
1127
- }
1128
1125
  if (DEBUG) {
1129
1126
  console.log(`${getMeasurementPhase()}, adjustPageSizeToHeight A`);
1130
1127
  }
@@ -1135,11 +1132,7 @@ function GridComponent(props) {
1135
1132
  doAdjustment = false;
1136
1133
  }
1137
1134
  if (DEBUG) {
1138
- console.log(`${getMeasurementPhase()}, adjustPageSizeToHeight A2 doAdjustment=${doAdjustment}, autoAdjustPageSizeToHeight=${autoAdjustPageSizeToHeight}, UiGlobals.autoAdjustPageSizeToHeight=${UiGlobals.autoAdjustPageSizeToHeight}`);
1139
- }
1140
- const containerHeight = e.nativeEvent.layout.height;
1141
- if (DEBUG) {
1142
- console.log(`${getMeasurementPhase()}, adjustPageSizeToHeight A3 containerHeight=${containerHeight}`);
1135
+ console.log(`${getMeasurementPhase()}, adjustPageSizeToHeight A2 doAdjustment=${doAdjustment}, autoAdjustPageSizeToHeight=${autoAdjustPageSizeToHeight}, UiGlobals.autoAdjustPageSizeToHeight=${UiGlobals.autoAdjustPageSizeToHeight}, containerHeight=${containerHeight}`);
1143
1136
  }
1144
1137
 
1145
1138
  // Only proceed if height changed significantly
@@ -1570,11 +1563,15 @@ function GridComponent(props) {
1570
1563
  if (DEBUG) {
1571
1564
  console.log(`${getMeasurementPhase()}, placeholder onLayout, call adjustPageSizeToHeight()`);
1572
1565
  }
1573
- adjustPageSizeToHeight(e);
1566
+ const containerHeight = e.nativeEvent.layout.height;
1567
+ adjustPageSizeToHeight(containerHeight);
1574
1568
  if (DEBUG) {
1575
1569
  console.log(`${getMeasurementPhase()}, placeholder onLayout, call setIsInited(true)`);
1576
1570
  }
1577
1571
  setIsInited(true);
1572
+ if (onLayout) {
1573
+ onLayout(e);
1574
+ }
1578
1575
  }}
1579
1576
  className="w-full flex-1"
1580
1577
  />;
@@ -1716,7 +1713,10 @@ function GridComponent(props) {
1716
1713
  ref={containerRef}
1717
1714
  tabIndex={0}
1718
1715
  onKeyDown={onGridKeyDown}
1719
- onLayout={(e) => debouncedAdjustPageSizeToHeight(e)}
1716
+ onLayout={(e) => {
1717
+ const containerHeight = e.nativeEvent.layout.height;
1718
+ debouncedAdjustPageSizeToHeight(containerHeight);
1719
+ }}
1720
1720
  className={className}
1721
1721
  style={style}
1722
1722
  >
@@ -1748,7 +1748,7 @@ function GridComponent(props) {
1748
1748
  (getMeasurementPhase() === PHASES__INITIAL || getMeasurementPhase() === PHASES__MEASURING) &&
1749
1749
  entities?.length > 0 && (
1750
1750
  <VStack className="absolute inset-0 z-10 bg-white">
1751
- <Loading isScreen={true} />
1751
+ <Loading />
1752
1752
  </VStack>
1753
1753
  )}
1754
1754
  </VStack>
@@ -1,10 +1,15 @@
1
1
  import { forwardRef, useState, useRef } from 'react';
2
2
  import {
3
- Box,
4
3
  Icon,
5
4
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
5
+ Pressable,
6
6
  Text,
7
7
  } from '@project-components/Gluestack';
8
+ import {
9
+ CURRENT_MODE,
10
+ UI_MODE_WEB,
11
+ UI_MODE_NATIVE,
12
+ } from '../../Constants/UiModes.js';
8
13
  import clsx from 'clsx';
9
14
  import Button from '../Buttons/Button.js';
10
15
  import Panel from '../Panel/Panel.js';
@@ -179,6 +184,25 @@ export default function withModal(WrappedComponent) {
179
184
  >{modalBody}</Panel>
180
185
  }
181
186
  }
187
+
188
+ let modalBackdrop = <ModalBackdrop className="withModal-ModalBackdrop" />
189
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
190
+ // Gluestack's ModalBackdrop was not working on Native,
191
+ // so workaround is to do it manually for now
192
+ modalBackdrop = <Pressable
193
+ onPress={() => hideModal()}
194
+ className={clsx(
195
+ 'withModal-ModalBackdrop-replacment',
196
+ 'h-full',
197
+ 'w-full',
198
+ 'absolute',
199
+ 'top-0',
200
+ 'left-0',
201
+ 'bg-[#000]',
202
+ 'opacity-50',
203
+ )}
204
+ />;
205
+ }
182
206
 
183
207
  return <>
184
208
  <WrappedComponent
@@ -199,7 +223,7 @@ export default function withModal(WrappedComponent) {
199
223
  className="withModal-Modal"
200
224
  {...testProps(testID)}
201
225
  >
202
- <ModalBackdrop className="withModal-ModalBackdrop" />
226
+ {modalBackdrop}
203
227
  {modalBody}
204
228
  </Modal>}
205
229
 
@@ -1,8 +1,14 @@
1
1
  import { forwardRef } from 'react';
2
2
  import {
3
3
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
4
+ Pressable,
4
5
  } from '@project-components/Gluestack';
5
6
  import clsx from 'clsx';
7
+ import {
8
+ CURRENT_MODE,
9
+ UI_MODE_WEB,
10
+ UI_MODE_NATIVE,
11
+ } from '../../Constants/UiModes.js';
6
12
  import {
7
13
  EDITOR_TYPE__WINDOWED,
8
14
  } from '../../Constants/Editor.js';
@@ -69,6 +75,25 @@ export default function withWindowedEditor(WrappedComponent, isTree = false) {
69
75
  throw Error('Editor is not defined');
70
76
  }
71
77
 
78
+ let modalBackdrop = <ModalBackdrop className="withEditor-ModalBackdrop" />
79
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
80
+ // Gluestack's ModalBackdrop was not working on Native,
81
+ // so workaround is to do it manually for now
82
+ modalBackdrop = <Pressable
83
+ onPress={() => onEditorCancel()}
84
+ className={clsx(
85
+ 'withEditor-ModalBackdrop-replacment',
86
+ 'h-full',
87
+ 'w-full',
88
+ 'absolute',
89
+ 'top-0',
90
+ 'left-0',
91
+ 'bg-[#000]',
92
+ 'opacity-50',
93
+ )}
94
+ />;
95
+ }
96
+
72
97
  return <>
73
98
  <WrappedComponent {...props} ref={ref} />
74
99
  {isEditorShown &&
@@ -77,7 +102,7 @@ export default function withWindowedEditor(WrappedComponent, isTree = false) {
77
102
  onClose={onEditorCancel}
78
103
  className="withEditor-Modal"
79
104
  >
80
- <ModalBackdrop className="withEditor-ModalBackdrop" />
105
+ {modalBackdrop}
81
106
  <Editor
82
107
  editorType={EDITOR_TYPE__WINDOWED}
83
108
  {...propsToPass}
@@ -1,8 +1,15 @@
1
1
  import {
2
+ Box,
2
3
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
4
+ Pressable,
3
5
  Text,
4
6
  } from '@project-components/Gluestack';
5
7
  import clsx from 'clsx';
8
+ import {
9
+ CURRENT_MODE,
10
+ UI_MODE_WEB,
11
+ UI_MODE_NATIVE,
12
+ } from '../../Constants/UiModes.js';
6
13
  import Button from '../Buttons/Button';
7
14
  import emptyFn from '../../Functions/emptyFn.js';
8
15
 
@@ -13,8 +20,26 @@ export default function ConfirmationMessage(props) {
13
20
  onOk = emptyFn,
14
21
  } = props;
15
22
 
23
+ let modalBackdrop = <ModalBackdrop className="ConfirmationMessage-ModalBackdrop" />
24
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
25
+ // Gluestack's ModalBackdrop was not working on Native,
26
+ // so workaround is to do it manually for now
27
+ modalBackdrop = <Box
28
+ className={clsx(
29
+ 'ConfirmationMessage-ModalBackdrop-replacment',
30
+ 'h-full',
31
+ 'w-full',
32
+ 'absolute',
33
+ 'top-0',
34
+ 'left-0',
35
+ 'bg-[#000]',
36
+ 'opacity-50',
37
+ )}
38
+ />;
39
+ }
40
+
16
41
  return <Modal isOpen={true} {...props} _backdrop={{ bg: "#000" }}>
17
- <ModalBackdrop />
42
+ {modalBackdrop}
18
43
  <ModalContent maxWidth="400px">
19
44
  <ModalHeader>Confirm</ModalHeader>
20
45
  <ModalBody
@@ -6,6 +6,11 @@ import {
6
6
  Text,
7
7
  } from '@project-components/Gluestack';
8
8
  import clsx from 'clsx';
9
+ import {
10
+ CURRENT_MODE,
11
+ UI_MODE_WEB,
12
+ UI_MODE_NATIVE,
13
+ } from '../../Constants/UiModes.js';
9
14
  import useAdjustedWindowSize from '../../Hooks/useAdjustedWindowSize.js';
10
15
  import Button from '../Buttons/Button.js';
11
16
  import Panel from '../Panel/Panel.js';
@@ -21,8 +26,26 @@ export default function ErrorMessage(props) {
21
26
  } = props,
22
27
  [width, height] = useAdjustedWindowSize(500, 250);
23
28
 
29
+ let modalBackdrop = <ModalBackdrop className="ErrorMessage-ModalBackdrop" />
30
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
31
+ // Gluestack's ModalBackdrop was not working on Native,
32
+ // so workaround is to do it manually for now
33
+ modalBackdrop = <Box
34
+ className={clsx(
35
+ 'ErrorMessage-ModalBackdrop-replacment',
36
+ 'h-full',
37
+ 'w-full',
38
+ 'absolute',
39
+ 'top-0',
40
+ 'left-0',
41
+ 'bg-[#000]',
42
+ 'opacity-50',
43
+ )}
44
+ />;
45
+ }
46
+
24
47
  return <Modal isOpen={true} {...props} {...testProps('ErrorMessage')}>
25
- <ModalBackdrop />
48
+ {modalBackdrop}
26
49
 
27
50
  <Panel
28
51
  title="Alert"
@@ -1,8 +1,14 @@
1
1
  import {
2
+ Box,
2
3
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
3
4
  Text,
4
5
  } from '@project-components/Gluestack';
5
6
  import clsx from 'clsx';
7
+ import {
8
+ CURRENT_MODE,
9
+ UI_MODE_WEB,
10
+ UI_MODE_NATIVE,
11
+ } from '../../Constants/UiModes.js';
6
12
  import Button from '../Buttons/Button';
7
13
 
8
14
  export default function OkMessage(props) {
@@ -11,8 +17,26 @@ export default function OkMessage(props) {
11
17
  onClose,
12
18
  } = props;
13
19
 
20
+ let modalBackdrop = <ModalBackdrop className="OkMessage-ModalBackdrop" />
21
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
22
+ // Gluestack's ModalBackdrop was not working on Native,
23
+ // so workaround is to do it manually for now
24
+ modalBackdrop = <Box
25
+ className={clsx(
26
+ 'OkMessage-ModalBackdrop-replacment',
27
+ 'h-full',
28
+ 'w-full',
29
+ 'absolute',
30
+ 'top-0',
31
+ 'left-0',
32
+ 'bg-[#000]',
33
+ 'opacity-50',
34
+ )}
35
+ />;
36
+ }
37
+
14
38
  return <Modal {...props} _backdrop={{ bg: "#000" }}>
15
- <ModalBackdrop />
39
+ {modalBackdrop}
16
40
  <ModalContent maxWidth="400px">
17
41
  <ModalBody
18
42
  className={clsx(
@@ -1,4 +1,6 @@
1
- import { useState, useEffect, } from 'react';import {
1
+ import { useState, useEffect, } from 'react';
2
+ import {
3
+ Box,
2
4
  HStack,
3
5
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
4
6
  Spinner,
@@ -6,6 +8,11 @@ import { useState, useEffect, } from 'react';import {
6
8
  VStack,
7
9
  } from '@project-components/Gluestack';
8
10
  import clsx from 'clsx';
11
+ import {
12
+ CURRENT_MODE,
13
+ UI_MODE_WEB,
14
+ UI_MODE_NATIVE,
15
+ } from '../../Constants/UiModes.js';
9
16
  import { useSelector } from 'react-redux';
10
17
  import * as Progress from 'react-native-progress';
11
18
  import testProps from '../../Functions/testProps';
@@ -21,13 +28,31 @@ export default function ProgressModal(props) {
21
28
  [progressBarWidth, setProgressBarWidth] = useState(175),
22
29
  [isInited, setIsInited] = useState(false);
23
30
 
31
+ let modalBackdrop = <ModalBackdrop className="ProgressModal-ModalBackdrop" />
32
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
33
+ // Gluestack's ModalBackdrop was not working on Native,
34
+ // so workaround is to do it manually for now
35
+ modalBackdrop = <Box
36
+ className={clsx(
37
+ 'ProgressModal-ModalBackdrop-replacment',
38
+ 'h-full',
39
+ 'w-full',
40
+ 'absolute',
41
+ 'top-0',
42
+ 'left-0',
43
+ 'bg-[#000]',
44
+ 'opacity-50',
45
+ )}
46
+ />;
47
+ }
48
+
24
49
  return <Modal
25
50
  {...testProps('ProgressModal')}
26
51
  isOpen={true}
27
52
  className="Modal"
28
53
  aria-disabled={true}
29
54
  >
30
- <ModalBackdrop />
55
+ {modalBackdrop}
31
56
  <ModalContent
32
57
  className={clsx(
33
58
  'ModalContent',
@@ -1,6 +1,8 @@
1
1
  import {
2
+ Box,
2
3
  HStack,
3
4
  Modal, ModalBackdrop, ModalHeader, ModalContent, ModalCloseButton, ModalBody, ModalFooter,
5
+ Pressable,
4
6
  Spinner,
5
7
  Text,
6
8
  } from '@project-components/Gluestack';
@@ -20,13 +22,32 @@ export default function WaitMessage(props) {
20
22
  if (!text) { // do this here instead of setting default value in deconstructor, so we can use the default for text, even if text is defined and passed as null or empty string
21
23
  text = 'Please wait...';
22
24
  }
25
+
26
+ let modalBackdrop = <ModalBackdrop className="WaitMessage-ModalBackdrop" />
27
+ if (CURRENT_MODE === UI_MODE_NATIVE) {
28
+ // Gluestack's ModalBackdrop was not working on Native,
29
+ // so workaround is to do it manually for now
30
+ modalBackdrop = <Box
31
+ className={clsx(
32
+ 'WaitMessage-ModalBackdrop-replacment',
33
+ 'h-full',
34
+ 'w-full',
35
+ 'absolute',
36
+ 'top-0',
37
+ 'left-0',
38
+ 'bg-[#000]',
39
+ 'opacity-50',
40
+ )}
41
+ />;
42
+ }
43
+
23
44
  return <Modal
24
45
  {...testProps('WaitMessage')}
25
46
  isOpen={true}
26
47
  className="Modal"
27
48
  aria-disabled={true}
28
49
  >
29
- <ModalBackdrop />
50
+ {modalBackdrop}
30
51
  <ModalContent
31
52
  className={clsx(
32
53
  'ModalContent',
@@ -1145,7 +1145,7 @@ function TreeComponent(props) {
1145
1145
  pressed,
1146
1146
  }) => {
1147
1147
  const nodeDragProps = {};
1148
- let WhichNode = TreeNode;
1148
+ let WhichNode = TreeNode,
1149
1149
  nodeCanSelect = true,
1150
1150
  nodeCanDrag = false;
1151
1151
  if (CURRENT_MODE === UI_MODE_WEB) { // DND is currently web-only TODO: implement for RN