@onehat/ui 0.3.296 → 0.3.298

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.3.296",
3
+ "version": "0.3.298",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -31,6 +31,7 @@ import inArray from '../../Functions/inArray.js';
31
31
  import getComponentFromType from '../../Functions/getComponentFromType.js';
32
32
  import buildAdditionalButtons from '../../Functions/buildAdditionalButtons.js';
33
33
  import testProps from '../../Functions/testProps.js';
34
+ import Toolbar from '../Toolbar/Toolbar.js';
34
35
  import Button from '../Buttons/Button.js';
35
36
  import IconButton from '../Buttons/IconButton.js';
36
37
  import AngleLeft from '../Icons/AngleLeft.js';
@@ -848,7 +849,8 @@ function Form(props) {
848
849
  }
849
850
 
850
851
  const formButtons = [];
851
- let formComponents,
852
+ let modeHeader = null,
853
+ formComponents,
852
854
  editor,
853
855
  additionalButtons,
854
856
  isSaveDisabled = false,
@@ -889,16 +891,23 @@ function Form(props) {
889
891
 
890
892
  additionalButtons = buildAdditionalButtons(additionalEditButtons);
891
893
 
892
- formButtons.push(<Row key="buttonsRow" px={4} pt={4} alignItems="center" justifyContent="flex-end">
893
- {isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
894
- <Button
895
- {...testProps('backBtn')}
896
- key="backBtn"
897
- onPress={onBack}
898
- leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
899
- color="#fff"
900
- >Back</Button>}
901
- {isSingle && editorMode === EDITOR_MODE__EDIT && onViewMode && !disableView &&
894
+ if (inArray(editorType, [EDITOR_TYPE__SIDE, EDITOR_TYPE__SMART, EDITOR_TYPE__WINDOWED]) &&
895
+ isSingle && editorMode === EDITOR_MODE__EDIT &&
896
+ (onBack || (onViewMode && !disableView))) {
897
+ modeHeader = <Toolbar>
898
+ <Row flex={1} alignItems="center">
899
+ {onBack &&
900
+ <Button
901
+ {...testProps('backBtn')}
902
+ key="backBtn"
903
+ onPress={onBack}
904
+ leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
905
+ color="#fff"
906
+ mr={4}
907
+ >Back</Button>}
908
+ <Text fontSize={20} ml={2} color="trueGray.500">Edit Mode</Text>
909
+ </Row>
910
+ {onViewMode && !disableView &&
902
911
  <Button
903
912
  {...testProps('toViewBtn')}
904
913
  key="viewBtn"
@@ -906,11 +915,12 @@ function Form(props) {
906
915
  leftIcon={<Icon as={Eye} color="#fff" size="sm" />}
907
916
  color="#fff"
908
917
  >To View</Button>}
909
- </Row>);
918
+ </Toolbar>;
919
+ }
910
920
  if (editorMode === EDITOR_MODE__EDIT && !_.isEmpty(additionalButtons)) {
911
- formButtons.push(<Row key="additionalButtonsRow" p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
921
+ formButtons.push(<Toolbar justifyContent="flex-end" flexWrap="wrap">
912
922
  {additionalButtons}
913
- </Row>)
923
+ </Toolbar>)
914
924
  }
915
925
  }
916
926
 
@@ -948,11 +958,9 @@ function Form(props) {
948
958
  showCloseBtn = true;
949
959
  } else {
950
960
  const formIsDirty = formState.isDirty;
951
- // console.log('formIsDirty', formIsDirty);
952
- // console.log('isPhantom', isPhantom);
953
- if (editorType === EDITOR_TYPE__WINDOWED && onCancel) {
954
- showCancelBtn = true;
955
- }
961
+ // if (editorType === EDITOR_TYPE__WINDOWED && onCancel) {
962
+ // showCancelBtn = true;
963
+ // }
956
964
  if (formIsDirty || isPhantom) {
957
965
  if (isSingle && onCancel) {
958
966
  showCancelBtn = true;
@@ -987,6 +995,7 @@ function Form(props) {
987
995
  >{editor}</Row>}
988
996
  {editorType !== EDITOR_TYPE__INLINE &&
989
997
  <ScrollView _web={{ minHeight, }} width="100%" pb={1}>
998
+ {modeHeader}
990
999
  {formHeader}
991
1000
  {formButtons}
992
1001
  {editor}
@@ -63,13 +63,16 @@ export default function withModal(WrappedComponent) {
63
63
  w,
64
64
  } = args;
65
65
 
66
+ if (!message && !body) {
67
+ throw new Error('Either message or body is required for showModal');
68
+ }
69
+
66
70
  if (title) {
67
71
  setTitle(title);
68
72
  }
69
- if (!message) {
70
- throw new Error('Message is required for showModal');
73
+ if (message) {
74
+ setMessage(message);
71
75
  }
72
- setMessage(message);
73
76
  setCanClose(canClose);
74
77
  setIncludeCancel(includeCancel);
75
78
  if (onNo) {
@@ -167,6 +170,7 @@ export default function withModal(WrappedComponent) {
167
170
  h={height}
168
171
  flex={null}
169
172
  >
173
+ {canClose && <Modal.CloseButton />}
170
174
  {title && <Modal.Header>{title}</Modal.Header>}
171
175
  <Modal.Body
172
176
  borderTopWidth={0}
@@ -80,7 +80,17 @@ export default function Header(props) {
80
80
  }
81
81
  }}
82
82
  >
83
- <Column alignItems="center" justifyContent="flex-start" h="100%" w="100%" bg={styles.PANEL_HEADER_BG_VERTICAL} style={{ userSelect: 'none', }} testID={testID}>
83
+ <Column
84
+ alignItems="center"
85
+ justifyContent="flex-start"
86
+ h="100%"
87
+ w="100%"
88
+ bg={styles.PANEL_HEADER_BG_VERTICAL}
89
+ borderBottomWidth={styles.PANEL_HEADER_BORDER_BOTTOM_WIDTH}
90
+ borderBottomColor={styles.PANEL_HEADER_BORDER_BOTTOM_COLOR}
91
+ style={{ userSelect: 'none', }}
92
+ testID={testID}
93
+ >
84
94
  {collapseBtn}
85
95
  <div style={{ textOrientation: 'mixed', writingMode: 'vertical-rl', }}>
86
96
  <Text flex={1} fontSize={styles.PANEL_HEADER_TEXT_FONTSIZE} color={styles.PANEL_HEADER_TEXT_COLOR} numberOfLines={1} ellipsizeMode="head" testID="text">{title}</Text>
@@ -99,7 +109,16 @@ export default function Header(props) {
99
109
  }
100
110
  }}
101
111
  >
102
- <Row alignItems="center" justifyContent="flex-start" px={styles.PANEL_HEADER_PX} py={styles.PANEL_HEADER_PY} bg={styles.PANEL_HEADER_BG} style={{ userSelect: 'none', }} testID={testID}>
112
+ <Row
113
+ alignItems="center"
114
+ justifyContent="flex-start"
115
+ px={styles.PANEL_HEADER_PX}
116
+ py={styles.PANEL_HEADER_PY}
117
+ bg={styles.PANEL_HEADER_BG}
118
+ borderBottomWidth={styles.PANEL_HEADER_BORDER_BOTTOM_WIDTH}
119
+ borderBottomColor={styles.PANEL_HEADER_BORDER_BOTTOM_COLOR}
120
+ style={{ userSelect: 'none', }}
121
+ testID={testID}>
103
122
  {closeBtn}
104
123
  <Text flex={1} fontSize={styles.PANEL_HEADER_TEXT_FONTSIZE} color={styles.PANEL_HEADER_TEXT_COLOR} numberOfLines={1} ellipsizeMode="head" testID="text">{title}</Text>
105
124
  {collapseBtn}
@@ -128,6 +147,8 @@ export default function Header(props) {
128
147
  h="100%"
129
148
  w="100%"
130
149
  bg={styles.PANEL_HEADER_BG_VERTICAL}
150
+ borderBottomWidth={styles.PANEL_HEADER_BORDER_BOTTOM_WIDTH}
151
+ borderBottomColor={styles.PANEL_HEADER_BORDER_BOTTOM_COLOR}
131
152
  >
132
153
  {collapseBtn}
133
154
  <Column
@@ -167,6 +188,8 @@ export default function Header(props) {
167
188
  px={styles.PANEL_HEADER_PX}
168
189
  py={styles.PANEL_HEADER_PY}
169
190
  bg={styles.PANEL_HEADER_BG}
191
+ borderBottomWidth={styles.PANEL_HEADER_BORDER_BOTTOM_WIDTH}
192
+ borderBottomColor={styles.PANEL_HEADER_BORDER_BOTTOM_COLOR}
170
193
  >
171
194
  {closeBtn}
172
195
  <Text
@@ -16,6 +16,7 @@ import inArray from '../../Functions/inArray.js';
16
16
  import getComponentFromType from '../../Functions/getComponentFromType.js';
17
17
  import buildAdditionalButtons from '../../Functions/buildAdditionalButtons.js';
18
18
  import testProps from '../../Functions/testProps.js';
19
+ import Toolbar from '../Toolbar/Toolbar.js';
19
20
  import Button from '../Buttons/Button.js';
20
21
  import Label from '../Form/Label.js';
21
22
  import Pencil from '../Icons/Pencil.js';
@@ -254,7 +255,10 @@ function Viewer(props) {
254
255
 
255
256
  <ScrollView _web={{ height: 1 }} width="100%" pb={1} ref={scrollViewRef}>
256
257
  {canEdit && onEditMode &&
257
- <Row px={4} pt={4} alignItems="center" justifyContent="flex-end">
258
+ <Toolbar justifyContent="flex-end">
259
+ <Row flex={1} alignItems="center">
260
+ <Text fontSize={20} ml={2} color="trueGray.500">View Mode</Text>
261
+ </Row>
258
262
  <Button
259
263
  {...testProps('toEditBtn')}
260
264
  key="editBtn"
@@ -262,11 +266,11 @@ function Viewer(props) {
262
266
  leftIcon={<Icon as={Pencil} color="#fff" size="sm" />}
263
267
  color="#fff"
264
268
  >To Edit</Button>
265
- </Row>}
269
+ </Toolbar>}
266
270
  {!_.isEmpty(additionalButtons) &&
267
- <Row p={4} alignItems="center" justifyContent="flex-end" flexWrap="wrap">
271
+ <Toolbar justifyContent="flex-end" flexWrap="wrap">
268
272
  {additionalButtons}
269
- </Row>}
273
+ </Toolbar>}
270
274
  <Column>
271
275
  {containerWidth >= CONTAINER_THRESHOLD ? <Row p={4} pl={0}>{viewerComponents}</Row> : null}
272
276
  {containerWidth < CONTAINER_THRESHOLD ? <Column p={4}>{viewerComponents}</Column> : null}
@@ -87,6 +87,8 @@ const defaults = {
87
87
  ICON_BUTTON_PY: 2,
88
88
  INLINE_EDITOR_MIN_WIDTH: 150,
89
89
  PANEL_FOOTER_BG: 'primary.100', // :alpha.50
90
+ PANEL_HEADER_BORDER_BOTTOM_COLOR: 'trueGray.400',
91
+ PANEL_HEADER_BORDER_BOTTOM_WIDTH: 1,
90
92
  PANEL_HEADER_BG: 'primary.100',
91
93
  PANEL_HEADER_BG_VERTICAL: 'primary.100',
92
94
  PANEL_HEADER_ICON_COLOR: WHITE,