@onehat/ui 0.2.22 → 0.2.24

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.22",
3
+ "version": "0.2.24",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -22,7 +22,6 @@
22
22
  "@ckeditor/ckeditor5-react": "^5.0.6",
23
23
  "@onehat/data": "^1.13.6",
24
24
  "@hookform/resolvers": "^2.9.11",
25
- "browser-or-node": "^2.1.1",
26
25
  "ckeditor5-custom-build": "file:ckeditor5",
27
26
  "js-cookie": "^3.0.1",
28
27
  "native-base": "^3.4.25",
@@ -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,4 +1,4 @@
1
- import { isBrowser, isNode, isWebWorker, isJsDom, isDeno } from "browser-or-node";
1
+ import { isBrowser, isNode, isWebWorker, } from '../Functions/PlatformDetector.js';
2
2
 
3
3
 
4
4
  export const UI_MODE_WEB = 'Web';
@@ -0,0 +1,29 @@
1
+ // Taken from https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js
2
+
3
+ const isBrowser =
4
+ typeof window !== "undefined" && typeof window.document !== "undefined";
5
+
6
+ const isNode =
7
+ typeof process !== "undefined" &&
8
+ process.versions != null &&
9
+ process.versions.node != null;
10
+
11
+ const isWebWorker =
12
+ typeof self === "object" &&
13
+ self.constructor &&
14
+ self.constructor.name === "DedicatedWorkerGlobalScope";
15
+
16
+ /**
17
+ * @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
18
+ * @see https://github.com/jsdom/jsdom/issues/1537
19
+ */
20
+ const isJsDom =
21
+ (typeof window !== "undefined" && window.name === "nodejs") ||
22
+ (typeof navigator !== "undefined" &&
23
+ (navigator.userAgent?.includes("Node.js") ||
24
+ navigator.userAgent?.includes("jsdom")));
25
+
26
+ const isDeno =
27
+ typeof Deno !== "undefined" && Deno.version?.deno;
28
+
29
+ export { isBrowser, isWebWorker, isNode, isJsDom, isDeno };
@@ -2,7 +2,7 @@ import UiGlobals from '../UiGlobals.js';
2
2
  import CKEditor from '../Components/Form/Field/CKEditor/CKEditor.js';
3
3
  import Datetime from '../PlatformImports/Web/Datetime.js';
4
4
  import Draggable from '../PlatformImports/Web/Draggable.js';
5
- import File from './Form/Field/File.js';
5
+ import File from '../Components/Form/Field/File.js';
6
6
  import _ from 'lodash';
7
7
 
8
8
  export default function registerWebComponents() {
@@ -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
- }