@onehat/ui 0.2.26 → 0.2.27

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.26",
3
+ "version": "0.2.27",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -19,7 +19,6 @@
19
19
  },
20
20
  "license": "UNLICENSED",
21
21
  "dependencies": {
22
- "@ckeditor/ckeditor5-react": "^5.0.6",
23
22
  "@onehat/data": "^1.13.6",
24
23
  "@hookform/resolvers": "^2.9.11",
25
24
  "ckeditor5-custom-build": "file:ckeditor5",
@@ -28,11 +27,13 @@
28
27
  "react-hook-form": "^7.43.1"
29
28
  },
30
29
  "peerDependencies": {
30
+ "@ckeditor/ckeditor5-react": "^5.0.6",
31
31
  "react": "*",
32
32
  "react-color": "^2.19.3",
33
33
  "react-datetime": "^3.2.0",
34
34
  "react-draggable": "^4.4.5",
35
35
  "react-native-draggable": "^3.3.0",
36
+ "react-native-ckeditor5": "^1.0.9",
36
37
  "react-dom": "*",
37
38
  "react-native": "*"
38
39
  },
@@ -7,6 +7,11 @@ import {
7
7
  HORIZONTAL,
8
8
  VERTICAL,
9
9
  } from '../../Constants/Directions.js';
10
+ import {
11
+ UI_MODE_WEB,
12
+ UI_MODE_REACT_NATIVE,
13
+ CURRENT_MODE,
14
+ } from '../../Constants/UiModes.js';
10
15
  import Splitter from './Splitter.js';
11
16
 
12
17
  export default function Container(props) {
@@ -26,6 +31,7 @@ export default function Container(props) {
26
31
  isWestCollapsed,
27
32
  setIsWestCollapsed,
28
33
  } = props,
34
+ canResize = CURRENT_MODE === UI_MODE_WEB,
29
35
  [localIsNorthCollapsed, setLocalIsNorthCollapsed] = useState(north ? north.props.startsCollapsed : false),
30
36
  [localIsSouthCollapsed, setLocalIsSouthCollapsed] = useState(south ? south.props.startsCollapsed : false),
31
37
  [localIsEastCollapsed, setLocalIsEastCollapsed] = useState(east ? east.props.startsCollapsed : false),
@@ -68,7 +74,7 @@ export default function Container(props) {
68
74
  if (!north.props.h && !north.props.flex) {
69
75
  componentProps.flex = 50;
70
76
  }
71
- if (north.props.isResizable) {
77
+ if (canResize && north.props.isResizable) {
72
78
  if (northHeight) {
73
79
  componentProps.h = northHeight;
74
80
  componentProps.flex = null;
@@ -92,7 +98,7 @@ export default function Container(props) {
92
98
  if (!south.props.h && !south.props.flex) {
93
99
  componentProps.flex = 50;
94
100
  }
95
- if (south.props.isResizable) {
101
+ if (canResize && south.props.isResizable) {
96
102
  if (southHeight) {
97
103
  componentProps.h = southHeight;
98
104
  componentProps.flex = null;
@@ -116,7 +122,7 @@ export default function Container(props) {
116
122
  if (!east.props.h && !east.props.flex) {
117
123
  componentProps.flex = 50;
118
124
  }
119
- if (east.props.isResizable) {
125
+ if (canResize && east.props.isResizable) {
120
126
  if (eastWidth) {
121
127
  componentProps.w = eastWidth;
122
128
  componentProps.flex = null;
@@ -140,7 +146,7 @@ export default function Container(props) {
140
146
  if (!west.props.h && !west.props.flex) {
141
147
  componentProps.flex = 50;
142
148
  }
143
- if (west.props.isResizable) {
149
+ if (canResize && west.props.isResizable) {
144
150
  if (westWidth) {
145
151
  componentProps.w = westWidth;
146
152
  componentProps.flex = null;
@@ -0,0 +1,81 @@
1
+ import {
2
+ Platform,
3
+ RefreshControl,
4
+ useWindowDimensions,
5
+ } from 'react-native';
6
+ import {
7
+ Column,
8
+ ScrollView,
9
+ KeyboardAvoidingView,
10
+ } from 'native-base';
11
+ import { useHeaderHeight } from '@react-navigation/elements';
12
+ // import testProps from '../OneHat/functions/testProps';
13
+
14
+ export default function ScreenContainer(props) {
15
+ const {
16
+ screenName = 'ScreenContainer',
17
+ p = 0,
18
+ safeArea = false,
19
+ bg = '#fff',
20
+ scrollEnabled = false,
21
+ keyboardAvoiding = false,
22
+ subtractHeaderHeight = true,
23
+ setScrollViewRef = () => {},
24
+ onLayout = () => {},
25
+ onRefresh = () => {},
26
+ isRefreshing,
27
+ } = props,
28
+ {
29
+ height,
30
+ } = useWindowDimensions(),
31
+ headerHeight = subtractHeaderHeight ? useHeaderHeight() : 0,
32
+ safeAreaProps = {};
33
+ if (safeArea !== false) {
34
+ safeAreaProps.safeArea = true;
35
+ }
36
+
37
+ const column = <Column
38
+ // {...testProps(screenName)}
39
+ alignItems="center"
40
+ justifyContent="flex-start"
41
+ flex={1}
42
+ w="100%"
43
+ p={p}
44
+ bg={bg}
45
+ overflow="visible"
46
+ onLayout={onLayout}
47
+ {...safeAreaProps}
48
+ >
49
+ {props.children}
50
+ </Column>;
51
+
52
+ if (scrollEnabled) {
53
+ const scrollViewProps = {};
54
+ if (onRefresh && typeof isRefreshing !== 'undefined') {
55
+ scrollViewProps.refreshControl = <RefreshControl refreshing={isRefreshing} onRefresh={onRefresh} />
56
+ }
57
+ const scrollView = <ScrollView
58
+ ref={(ref) => {
59
+ setScrollViewRef(ref);
60
+ }}
61
+ keyboardShouldPersistTaps="handled"
62
+ _contentContainerStyle={{
63
+ minHeight: height - headerHeight,
64
+ }}
65
+ {...scrollViewProps}
66
+ >{column}</ScrollView>;
67
+ if (keyboardAvoiding) {
68
+ return <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} flex={1} width="100%">
69
+ {scrollView}
70
+ </KeyboardAvoidingView>
71
+ } else {
72
+ return scrollView;
73
+ }
74
+ }
75
+ if (keyboardAvoiding) {
76
+ return <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : 'height'} flex={1} width="100%">
77
+ {column}
78
+ </KeyboardAvoidingView>;
79
+ }
80
+ return column;
81
+ }
@@ -38,7 +38,7 @@ export function DateElement(props) {
38
38
  tooltipPlacement = 'bottom',
39
39
  } = props,
40
40
  styles = UiGlobals.styles,
41
- Datetime = getComponentFromType('Draggable'),
41
+ Datetime = getComponentFromType('Datetime'),
42
42
  inputRef = useRef(),
43
43
  triggerRef = useRef(),
44
44
  pickerRef = useRef(),
@@ -4,23 +4,23 @@ import {
4
4
  } from 'native-base';
5
5
  import {
6
6
  AUTO_SUBMIT_DELAY,
7
- } from '../../../../Constants/Input.js';
7
+ } from '../../../Constants/Input.js';
8
8
  import Editor from 'ckeditor5-custom-build/build/ckeditor.js'; // built using https://ckeditor.com/ckeditor-5/online-builder/
9
- import { CKEditor } from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
10
- import withValue from '../../../Hoc/withValue.js';
11
- import withTooltip from '../../../Hoc/withTooltip.js';
9
+ import getComponentFromType from '../../../Functions/getComponentFromType.js';
10
+ import withValue from '../../Hoc/withValue.js';
11
+ import withTooltip from '../../Hoc/withTooltip.js';
12
12
  import _ from 'lodash';
13
- import './styles.css';
14
13
 
15
14
  const
16
- CKEditorElement = (props) => {
15
+ HtmlEditorElement = (props) => {
17
16
  const {
18
17
  value,
19
18
  setValue,
20
19
  h = 150,
21
20
  } = props,
21
+ CKEditor = getComponentFromType('CKEditor'),
22
22
  debouncedSetValueRef = useRef(),
23
- [editor, setEditor] = useState(null),
23
+ [editor, setEditor] = useState(null), // in case you need to adjust things procedurally
24
24
  config = {
25
25
  };
26
26
 
@@ -52,12 +52,12 @@ const
52
52
  />
53
53
  </Row>;
54
54
  },
55
- CKEditorField = withValue(CKEditorElement);
55
+ HtmlEditorField = withValue(HtmlEditorElement);
56
56
 
57
57
 
58
- export default CKEditorField;
58
+ export default HtmlEditorField;
59
59
 
60
60
  // // Tooltip needs us to forwardRef
61
61
  // export default withTooltip(React.forwardRef((props, ref) => {
62
- // return <CKEditorField {...props} outerRef={ref} />;
62
+ // return <HtmlEditorField {...props} outerRef={ref} />;
63
63
  // }));
@@ -116,17 +116,8 @@ export default function Header(props) {
116
116
  w="100%"
117
117
  style={{ userSelect: 'none', ...doubleClickStyle, }}
118
118
  onPress={(e) => {
119
- switch (e.detail) {
120
- case 1: // single click
121
- break;
122
- case 2: // double click
123
- if (isCollapsible) {
124
- onToggleCollapse(e);
125
- }
126
- break;
127
- case 3: // triple click
128
- break;
129
- default:
119
+ if (isCollapsible) {
120
+ onToggleCollapse(e);
130
121
  }
131
122
  }}
132
123
  >
@@ -136,17 +127,24 @@ export default function Header(props) {
136
127
  h="100%"
137
128
  w="100%"
138
129
  bg={styles.PANEL_HEADER_BG_VERTICAL}
139
- style={{ userSelect: 'none', }}
140
130
  >
141
131
  {collapseBtn}
142
- <Text
143
- flex={1}
144
- fontSize={styles.PANEL_HEADER_TEXT_FONTSIZE}
145
- color={styles.PANEL_HEADER_TEXT_COLOR}
146
- numberOfLines={1}
147
- ellipsizeMode="head"
148
- style={{transform: [{ rotate: '-90deg'}]}}
149
- >{title}</Text>
132
+ <Column
133
+ alignItems="center"
134
+ justifyContent="center"
135
+ flex={1}
136
+ w="100%"
137
+ >
138
+ <Text
139
+ textAlign="right"
140
+ fontSize={styles.PANEL_HEADER_TEXT_FONTSIZE}
141
+ color={styles.PANEL_HEADER_TEXT_COLOR}
142
+ numberOfLines={1}
143
+ ellipsizeMode="head"
144
+ w={200}
145
+ style={{ transform: [{ rotate: '-90deg'}] }}
146
+ >{title}</Text>
147
+ </Column>
150
148
  </Column>
151
149
  </Pressable>;
152
150
  }
@@ -154,21 +152,11 @@ export default function Header(props) {
154
152
 
155
153
  return <Pressable
156
154
  testID={testID}
157
- flex={1}
158
155
  w="100%"
159
156
  style={{ userSelect: 'none', ...doubleClickStyle, }}
160
157
  onPress={(e) => {
161
- switch (e.detail) {
162
- case 1: // single click
163
- break;
164
- case 2: // double click
165
- if (isCollapsible) {
166
- onToggleCollapse(e);
167
- }
168
- break;
169
- case 3: // triple click
170
- break;
171
- default:
158
+ if (isCollapsible) {
159
+ onToggleCollapse(e);
172
160
  }
173
161
  }}
174
162
  >
@@ -178,7 +166,6 @@ export default function Header(props) {
178
166
  px={styles.PANEL_HEADER_PX}
179
167
  py={styles.PANEL_HEADER_PY}
180
168
  bg={styles.PANEL_HEADER_BG}
181
- style={{ userSelect: 'none', }}
182
169
  >
183
170
  {closeBtn}
184
171
  <Text
@@ -194,5 +181,4 @@ export default function Header(props) {
194
181
 
195
182
  }
196
183
 
197
-
198
184
  }
@@ -1,4 +1,3 @@
1
- import { useState, } from 'react';
2
1
  import {
3
2
  Column,
4
3
  Row,
@@ -120,22 +119,22 @@ function Panel(props) {
120
119
  }
121
120
 
122
121
  if (isCollapsed) {
123
- if (collapseDirection !== VERTICAL) {
124
- return <Column overflow="hidden" {...framePropsToUse} w="33px" height="100%">
122
+ if (collapseDirection === HORIZONTAL) {
123
+ return <Column overflow="hidden" {...propsToPass} {...framePropsToUse} w="33px" h="100%">
125
124
  {isDisabled && <Mask />}
126
125
  {headerComponent}
127
126
  </Column>;
128
127
  }
129
- return <Column overflow="hidden" {...framePropsToUse}>
128
+ return <Column overflow="hidden" {...propsToPass} {...framePropsToUse} h="33px" w="100%">
130
129
  {isDisabled && <Mask />}
131
130
  {headerComponent}
132
131
  </Column>;
133
132
  }
134
- return <Column overflow="hidden" onLayout={onLayout} {...framePropsToUse} {...sizeProps}>
133
+ return <Column overflow="hidden" {...propsToPass} onLayout={onLayout} {...framePropsToUse} {...sizeProps}>
135
134
  {isDisabled && <Mask />}
136
135
  {headerComponent}
137
136
  {topToolbar}
138
- <Column flex={1} w="100%" overflow="hidden" {...propsToPass}>
137
+ <Column flex={1} w="100%" overflow="hidden">
139
138
  {isScrollable ? <ScrollView>{children}</ScrollView> : children}
140
139
  </Column>
141
140
  {bottomToolbar}
@@ -10,7 +10,6 @@ import Blank from './Blank.js';
10
10
  import BooleanCombo from './Form/Field/Combo/BooleanCombo.js';
11
11
  // import CartButtonWithBadge from '../Components/Buttons/CartButtonWithBadge.js';
12
12
  import CheckboxGroup from './Form/Field/CheckboxGroup/CheckboxGroup.js';
13
- // import CKEditor from './Form/Field/CKEditor/CKEditor.js'; // web only
14
13
  import Color from './Form/Field/Color.js';
15
14
  import Combo from './Form/Field/Combo/Combo.js';
16
15
  // import ComboEditor from '../Components/Form/Field/Combo/ComboEditor.js';
@@ -26,6 +25,7 @@ import FiltersForm from './Form/FiltersForm.js';
26
25
  import Form from './Form/Form.js';
27
26
  import Grid from './Grid/Grid.js';
28
27
  import GridPanel from './Panel/GridPanel.js';
28
+ import HtmlEditor from './Form/Field/HtmlEditor.js';
29
29
  import IconButton from './Buttons/IconButton.js';
30
30
  import Input from './Form/Field/Input.js';
31
31
  import IntervalsCombo from './Form/Field/Combo/IntervalsCombo.js';
@@ -56,7 +56,6 @@ const components = {
56
56
  BooleanCombo,
57
57
  // CartButtonWithBadge,
58
58
  CheckboxGroup,
59
- // CKEditor,
60
59
  Color,
61
60
  Column,
62
61
  Combo,
@@ -73,6 +72,7 @@ const components = {
73
72
  Form,
74
73
  Grid,
75
74
  GridPanel,
75
+ HtmlEditor,
76
76
  IconButton,
77
77
  Input,
78
78
  IntervalsCombo,
@@ -1,11 +1,15 @@
1
1
  import UiGlobals from '../UiGlobals.js';
2
+ import CKEditor from '../PlatformImports/ReactNative/CKEditor';
2
3
  import Datetime from '../PlatformImports/ReactNative/Datetime';
3
4
  import Draggable from '../PlatformImports/ReactNative/Draggable';
5
+ import ScreenContainer from '../Components/Container/ScreenContainer';
4
6
  import _ from 'lodash';
5
7
 
6
8
  export default function registerReactNativeComponents() {
7
9
  _.merge(UiGlobals.components, {
10
+ CKEditor,
8
11
  Datetime,
9
12
  Draggable,
13
+ ScreenContainer,
10
14
  });
11
15
  }
@@ -1,5 +1,5 @@
1
1
  import UiGlobals from '../UiGlobals.js';
2
- import CKEditor from '../Components/Form/Field/CKEditor/CKEditor.js';
2
+ import CKEditor from '../PlatformImports/Web/CKEditor';
3
3
  import Datetime from '../PlatformImports/Web/Datetime.js';
4
4
  import Draggable from '../PlatformImports/Web/Draggable.js';
5
5
  import File from '../Components/Form/Field/File.js';
@@ -0,0 +1,3 @@
1
+ import CKEditor5 from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
2
+
3
+ export default CKEditor5.default || CKEditor5;
@@ -0,0 +1,4 @@
1
+ import { CKEditor } from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
2
+ import './ckeditor.css';
3
+
4
+ export default CKEditor.default || CKEditor;
@@ -1,71 +0,0 @@
1
- import {
2
- Keyboard,
3
- Platform,
4
- TouchableWithoutFeedback,
5
- } from 'react-native';
6
- import {
7
- Column,
8
- KeyboardAvoidingView,
9
- ScrollView,
10
- } from 'native-base';
11
- import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
12
- import { useDimensions } from '@react-native-community/Hooks';
13
- import { useHeaderHeight } from '@react-navigation/elements';
14
- import testProps from '../Functions/testProps';
15
-
16
- export default function ScreenContainer(props) {
17
- const {
18
- screenName = 'ScreenContainer',
19
- p = 0,
20
- safeArea = false,
21
- bg = '#fff',
22
- scrollEnabled = false,
23
- keyboardAvoiding = false,
24
- behavior = Platform.OS === 'ios' ? 'padding' : 'height', // for the KeyboardAvoidingView. 'height', 'position', 'padding'
25
- justifyContent = 'flex-start',
26
- alignItems = 'center',
27
- onLayout = () => {},
28
- } = props,
29
- screen = useDimensions().screen,
30
- headerHeight = useHeaderHeight(),
31
- safeAreaProps = {};
32
- if (safeArea !== false) {
33
- safeAreaProps.safeAreaTop = true;
34
- }
35
-
36
- let content = <Column
37
- {...testProps(screenName)}
38
- alignItems={alignItems}
39
- justifyContent={justifyContent}
40
- flex={1}
41
- w="100%"
42
- p={p}
43
- bg={bg}
44
- overflow="visible"
45
- onLayout={onLayout}
46
- {...safeAreaProps}
47
- >
48
- {props.children}
49
- </Column>;
50
- if (keyboardAvoiding && scrollEnabled) {
51
- content = <KeyboardAwareScrollView behavior={behavior} contentContainerStyle={{ flex: 1, }}>
52
- <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
53
- {content}
54
- </TouchableWithoutFeedback>
55
- </KeyboardAwareScrollView>;
56
- } else {
57
- if (keyboardAvoiding) {
58
- content = <KeyboardAvoidingView behavior={behavior} flex={1}>
59
- <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
60
- {content}
61
- </TouchableWithoutFeedback>
62
- </KeyboardAvoidingView>;
63
- }
64
- if (scrollEnabled) {
65
- content = <ScrollView keyboardShouldPersistTaps="always" _contentContainerStyle={{
66
- minHeight: screen.height - headerHeight,
67
- }}>{content}</ScrollView>;
68
- }
69
- }
70
- return content;
71
- }