@onehat/ui 0.2.23 → 0.2.25

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.23",
3
+ "version": "0.2.25",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -0,0 +1,20 @@
1
+ import {
2
+ Box,
3
+ } from 'native-base';
4
+ import {
5
+ CURRENT_MODE,
6
+ UI_MODE_WEB,
7
+ UI_MODE_REACT_NATIVE,
8
+ } from '../../Constants/UiModes.js';
9
+
10
+ export default function Mask(props) {
11
+ if (CURRENT_MODE === UI_MODE_WEB) {
12
+
13
+ return <div className="mask"></div>;
14
+
15
+ } else if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
16
+
17
+ return <Box position="absolute" h="100%" w="100%" bg="trueGray.400:alpha.20" zIndex={100000}></Box>;
18
+
19
+ }
20
+ }
@@ -9,12 +9,8 @@ import {
9
9
  HORIZONTAL,
10
10
  VERTICAL,
11
11
  } from '../../Constants/Directions.js';
12
- import {
13
- CURRENT_MODE,
14
- UI_MODE_WEB,
15
- UI_MODE_REACT_NATIVE,
16
- } from '../../Constants/UiModes.js';
17
12
  import Header from './Header.js';
13
+ import Mask from './Mask.js';
18
14
  import withCollapsible from '../Hoc/withCollapsible.js';
19
15
  import emptyFn from '../../Functions/emptyFn.js';
20
16
  import _ from 'lodash';
@@ -123,36 +119,29 @@ function Panel(props) {
123
119
  framePropsToUse = frameProps;
124
120
  }
125
121
 
126
- if (CURRENT_MODE === UI_MODE_WEB) {
127
-
128
- if (isCollapsed) {
129
- if (collapseDirection !== VERTICAL) {
130
- return <Column overflow="hidden" {...framePropsToUse} w="33px" height="100%">
131
- {isDisabled && <div className="mask"></div>}
132
- {headerComponent}
133
- </Column>;
134
- }
135
- return <Column overflow="hidden" {...framePropsToUse}>
136
- {isDisabled && <div className="mask"></div>}
122
+ if (isCollapsed) {
123
+ if (collapseDirection !== VERTICAL) {
124
+ return <Column overflow="hidden" {...framePropsToUse} w="33px" height="100%">
125
+ {isDisabled && <Mask />}
137
126
  {headerComponent}
138
127
  </Column>;
139
128
  }
140
- return <Column overflow="hidden" onLayout={onLayout} {...framePropsToUse} {...sizeProps}>
141
- {isDisabled && <div className="mask"></div>}
129
+ return <Column overflow="hidden" {...framePropsToUse}>
130
+ {isDisabled && <Mask />}
142
131
  {headerComponent}
143
- {topToolbar}
144
- <Column flex={1} w="100%" overflow="hidden" {...propsToPass}>
145
- {isScrollable ? <ScrollView>{children}</ScrollView> : children}
146
- </Column>
147
- {bottomToolbar}
148
- {footer}
149
132
  </Column>;
150
-
151
- } else if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
152
-
153
- return null;
154
-
155
133
  }
134
+ return <Column overflow="hidden" onLayout={onLayout} {...framePropsToUse} {...sizeProps}>
135
+ {isDisabled && <Mask />}
136
+ {headerComponent}
137
+ {topToolbar}
138
+ <Column flex={1} w="100%" overflow="hidden" {...propsToPass}>
139
+ {isScrollable ? <ScrollView>{children}</ScrollView> : children}
140
+ </Column>
141
+ {bottomToolbar}
142
+ {footer}
143
+ </Column>;
144
+
156
145
  }
157
146
 
158
147
  export default withCollapsible(Panel);
@@ -1,12 +1,12 @@
1
- import { isBrowser, isNode, isWebWorker, } from '../Functions/PlatformDetector.js';
1
+ import { isReactNative, isBrowser, isWebWorker, } from '../Functions/PlatformDetector.js';
2
2
 
3
3
 
4
4
  export const UI_MODE_WEB = 'Web';
5
5
  export const UI_MODE_REACT_NATIVE = 'ReactNative';
6
6
 
7
7
  export let CURRENT_MODE;
8
- if (isBrowser || isWebWorker) {
9
- CURRENT_MODE = UI_MODE_WEB;
10
- } else if (isNode) {
8
+ if (isReactNative) {
11
9
  CURRENT_MODE = UI_MODE_REACT_NATIVE;
10
+ } else if (isBrowser || isWebWorker) {
11
+ CURRENT_MODE = UI_MODE_WEB;
12
12
  }
@@ -1,4 +1,7 @@
1
- // Taken from https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js
1
+ // Based on https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js
2
+
3
+ const isReactNative =
4
+ typeof process !== 'undefined' && !!process.env;
2
5
 
3
6
  const isBrowser =
4
7
  typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -24,6 +27,8 @@ const isJsDom =
24
27
  navigator.userAgent?.includes("jsdom")));
25
28
 
26
29
  const isDeno =
27
- typeof Deno !== "undefined" && Deno.version?.deno;
30
+ typeof Deno !== "undefined" &&
31
+ typeof Deno.version !== "undefined" &&
32
+ typeof Deno.version.deno !== "undefined";
28
33
 
29
- export { isBrowser, isWebWorker, isNode, isJsDom, isDeno };
34
+ export { isReactNative, isBrowser, isWebWorker, isNode, isJsDom, isDeno };
@@ -1,11 +0,0 @@
1
- import {
2
- Box,
3
- } from 'native-base';
4
- import _ from 'lodash';
5
-
6
- export default function Mask(props) {
7
- const propsToPass = _.omit(props, 'children');
8
- return <Box bg="trueGray.400" {...propsToPass} testID="mask">
9
- {props.children}
10
- </Box>;
11
- }