@onehat/ui 0.3.270 → 0.3.272

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.270",
3
+ "version": "0.3.272",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -308,6 +308,7 @@ function GridComponent(props) {
308
308
  const items = _.map(additionalToolbarButtons, (config, ix) => getIconButtonFromConfig(config, ix, self));
309
309
  if (canRowsReorder && CURRENT_MODE === UI_MODE_WEB) { // DND is currently web-only TODO: implement for RN
310
310
  items.unshift(<IconButton
311
+ {...testProps('reorderBtn')}
311
312
  key="reorderBtn"
312
313
  parent={self}
313
314
  reference="reorderBtn"
@@ -15,6 +15,7 @@ import {
15
15
  ALERT_MODE_CUSTOM,
16
16
  ALERT_MODE_INFO,
17
17
  } from '../../Constants/Alert.js';
18
+ import testProps from '../../Functions/testProps.js';
18
19
  import TriangleExclamation from '../Icons/TriangleExclamation.js';
19
20
  import CircleInfo from '../Icons/CircleInfo.js';
20
21
  import _ from 'lodash';
@@ -194,7 +195,7 @@ export default function withAlert(WrappedComponent) {
194
195
  {canClose && <AlertDialog.CloseButton />}
195
196
  <AlertDialog.Header>{title}</AlertDialog.Header>
196
197
  <AlertDialog.Body>
197
- <Row alignItems="center">
198
+ <Row alignItems="center" {...testProps('AlertDialog')}>
198
199
  <Column w="40px" p={0} mr={5}>
199
200
  <Icon as={mode === ALERT_MODE_INFO ? CircleInfo : TriangleExclamation} size={10} color={mode === ALERT_MODE_INFO ? '#000' : '#f00'} />
200
201
  </Column>
@@ -101,13 +101,18 @@ export default function withPdfButton(WrappedComponent) {
101
101
  item.defaults.labelWidth = '90%';
102
102
  if (!_.isEmpty(items)) {
103
103
  const defaults = item.defaults;
104
- item.children = _.map(items, (item, ix) => {
104
+ item.items = _.map(items, (item, ix) => {
105
105
  return buildNextLayer(item, ix, defaults);
106
106
  });
107
107
  }
108
108
  return item;
109
109
  }
110
110
 
111
+
112
+ if (item.isHiddenInViewMode || type === 'Button') {
113
+ return null;
114
+ }
115
+
111
116
  if (!item.title) {
112
117
  const propertyDef = name && Repository?.getSchema().getPropertyDefinition(name);
113
118
  if (propertyDef?.title) {
@@ -130,6 +135,9 @@ export default function withPdfButton(WrappedComponent) {
130
135
  getStartingValues = (modalItems) => {
131
136
  const startingValues = {};
132
137
  function walkTree(item) {
138
+ if (!item) {
139
+ return;
140
+ }
133
141
  let {
134
142
  name,
135
143
  items,
@@ -185,7 +193,7 @@ export default function withPdfButton(WrappedComponent) {
185
193
  <Column bg="#fff" w={width} h={height}>
186
194
  <FormPanel
187
195
  title="PDF Fields to Show"
188
- instructions="Please select which fields to show in the PDF."
196
+ instructions="Please select which parts to show in the PDF."
189
197
  editorType={EDITOR_TYPE__PLAIN}
190
198
  flex={1}
191
199
  Repository={Repository}
@@ -5,6 +5,7 @@ import {
5
5
  Modal,
6
6
  Text,
7
7
  } from 'native-base';
8
+ import testProps from '../../Functions/testProps.js';
8
9
  import TriangleExclamation from '../Icons/TriangleExclamation.js';
9
10
 
10
11
  export default function ErrorMessage(props) {
@@ -14,7 +15,7 @@ export default function ErrorMessage(props) {
14
15
  onOk,
15
16
  } = props;
16
17
 
17
- return <Modal isOpen={true} {...props} _backdrop={{ bg: "#000" }}>
18
+ return <Modal isOpen={true} {...props} _backdrop={{ bg: "#000" }} {...testProps('ErrorMessage')}>
18
19
  <Modal.Content>
19
20
  <Modal.Header>Alert</Modal.Header>
20
21
  <Modal.Body
@@ -5,6 +5,7 @@ import {
5
5
  Text,
6
6
  } from 'native-base';
7
7
  import withComponent from '../Hoc/withComponent.js';
8
+ import testProps from '../../Functions/testProps.js';
8
9
  import UiGlobals from '../../UiGlobals.js';
9
10
  import IconButton from '../Buttons/IconButton';
10
11
  import FullWidth from '../Icons/FullWidth';
@@ -95,6 +96,7 @@ function ManagerScreen(props) {
95
96
  {allowSideBySide &&
96
97
  <>
97
98
  <IconButton
99
+ {...testProps('fullModeBtn')}
98
100
  icon={FullWidth}
99
101
  _icon={{
100
102
  size: '25px',
@@ -105,6 +107,7 @@ function ManagerScreen(props) {
105
107
  tooltip="Full Width"
106
108
  />
107
109
  <IconButton
110
+ {...testProps('sideModeBtn')}
108
111
  icon={SideBySide}
109
112
  _icon={{
110
113
  size: '25px',
@@ -13,6 +13,7 @@ import {
13
13
  } from '../../Constants/Directions.js';
14
14
  import UiGlobals from '../../UiGlobals.js';
15
15
  import getComponentFromType from '../../Functions/getComponentFromType.js';
16
+ import testProps from '../../Functions/testProps.js';
16
17
  import withComponent from '../Hoc/withComponent.js';
17
18
  import IconButton from '../Buttons/IconButton.js';
18
19
  import Minimize from '../Icons/Minimize.js';
@@ -97,6 +98,7 @@ function TabBar(props) {
97
98
  let button;
98
99
  if (isCollapsed) {
99
100
  button = <IconButton
101
+ {...testProps('toggleBtn')}
100
102
  key="toggleBtn"
101
103
  onPress={onToggleCollapse}
102
104
  {...buttonProps}
@@ -112,6 +114,7 @@ function TabBar(props) {
112
114
  />;
113
115
  } else {
114
116
  button = <Button
117
+ {...testProps('toggleBtn')}
115
118
  key="toggleBtn"
116
119
  onPress={onToggleCollapse}
117
120
  leftIcon={<Icon
@@ -209,6 +212,7 @@ function TabBar(props) {
209
212
  let closeBtn;
210
213
  if (onTabClose && !tab.disableCloseBox) {
211
214
  closeBtn = <IconButton
215
+ {...testProps('tabCloseButton-' + ix)}
212
216
  key={'tabCloseButton' + ix}
213
217
  onPress={() => onTabClose(ix)}
214
218
  icon={Xmark}
@@ -222,6 +226,7 @@ function TabBar(props) {
222
226
  }
223
227
  if (useIconButton) {
224
228
  button = <IconButton
229
+ {...testProps(tab.path)}
225
230
  key={'tabIconButton' + ix}
226
231
  onPress={() => setCurrentTab(ix)}
227
232
  {...buttonProps}
@@ -244,6 +249,7 @@ function TabBar(props) {
244
249
  // </Row>;
245
250
  } else {
246
251
  button = <Button
252
+ {...testProps(tab.path)}
247
253
  key={'tabButton' + ix}
248
254
  onPress={() => setCurrentTab(ix)}
249
255
  leftIcon={<Icon
@@ -411,12 +417,14 @@ function TabBar(props) {
411
417
  let tabBar = null;
412
418
  if (direction === VERTICAL) {
413
419
  tabBar = <Column
420
+ {...testProps('TabBar')}
414
421
  alignItems="center"
415
422
  justifyContent="flex-start"
416
423
  py={2}
417
424
  pl={isCollapsed ? 1 : 4}
418
425
  bg={styles.TAB_BAR_BG}
419
426
  w={isCollapsed ? '50px' : tabWidth}
427
+ {...propsToPass}
420
428
  >
421
429
  {renderedTabs}
422
430
  <Column flex={1} w="100%" justifyContent="flex-end">
@@ -438,6 +446,7 @@ function TabBar(props) {
438
446
  }
439
447
  if (direction === HORIZONTAL) {
440
448
  tabBar = <Row
449
+ {...testProps('TabBar')}
441
450
  alignItems="center"
442
451
  justifyContent="flex-start"
443
452
  p={2}
@@ -5,6 +5,7 @@ import {
5
5
  Text,
6
6
  } from 'native-base';
7
7
  import useForceUpdate from '../../Hooks/useForceUpdate.js';
8
+ import testProps from '../../Functions/testProps.js';
8
9
  import Button from '../Buttons/Button.js';
9
10
  import IconButton from '../Buttons/IconButton.js';
10
11
  import AngleLeft from '../Icons/AngleLeft.js';
@@ -64,6 +65,7 @@ export default function Pagination(props) {
64
65
  isDisabled = (pageEnd === total);
65
66
  if (showPagination) {
66
67
  items.push(<Button
68
+ {...testProps('showMoreBtn')}
67
69
  key="showMore"
68
70
  parent={self}
69
71
  reference="showMoreBtn"
@@ -74,6 +76,7 @@ export default function Pagination(props) {
74
76
  }
75
77
  if (!Repository.isLocal) {
76
78
  items.push(<IconButton
79
+ {...testProps('reloadPageBtn')}
77
80
  key="reload"
78
81
  parent={self}
79
82
  reference="reloadPageBtn"
@@ -88,6 +91,7 @@ export default function Pagination(props) {
88
91
  isDisabled = page === 1;
89
92
  if (showPagination) {
90
93
  items.push(<IconButton
94
+ {...testProps('firstPageBtn')}
91
95
  key="first"
92
96
  parent={self}
93
97
  reference="firstPageBtn"
@@ -98,6 +102,7 @@ export default function Pagination(props) {
98
102
  tooltip="First Page"
99
103
  />);
100
104
  items.push(<IconButton
105
+ {...testProps('prevPageBtn')}
101
106
  key="prev"
102
107
  parent={self}
103
108
  reference="prevPageBtn"
@@ -116,6 +121,7 @@ export default function Pagination(props) {
116
121
  >
117
122
  <Text mr={2}>Page</Text>
118
123
  <Input
124
+ {...testProps('pageInput')}
119
125
  parent={self}
120
126
  reference="pageInput"
121
127
  keyboardType="numeric"
@@ -132,6 +138,7 @@ export default function Pagination(props) {
132
138
 
133
139
  isDisabled = page === totalPages || totalPages <= 1;
134
140
  items.push(<IconButton
141
+ {...testProps('nextPageBtn')}
135
142
  key="next"
136
143
  parent={self}
137
144
  reference="nextPageBtn"
@@ -142,6 +149,7 @@ export default function Pagination(props) {
142
149
  tooltip="Next Page"
143
150
  />);
144
151
  items.push(<IconButton
152
+ {...testProps('lastPageBtn')}
145
153
  key="last"
146
154
  parent={self}
147
155
  reference="lastPageBtn"
@@ -155,6 +163,7 @@ export default function Pagination(props) {
155
163
 
156
164
  if (!Repository.isLocal) {
157
165
  items.push(<IconButton
166
+ {...testProps('reloadPageBtn')}
158
167
  key="reload"
159
168
  parent={self}
160
169
  reference="reloadPageBtn"
@@ -165,7 +174,12 @@ export default function Pagination(props) {
165
174
  />);
166
175
  }
167
176
  if (showPagination && !minimize && !disablePageSize) {
168
- items.push(<PageSizeCombo key="pageSize" pageSize={pageSize} Repository={Repository} />);
177
+ items.push(<PageSizeCombo
178
+ {...testProps('pageSize')}
179
+ key="pageSize"
180
+ pageSize={pageSize}
181
+ Repository={Repository}
182
+ />);
169
183
  }
170
184
  if (showPagination && !minimize) {
171
185
  let pageSpan = `${pageStart} – ${pageEnd}`;
@@ -1,4 +1,5 @@
1
1
  import IconButton from '../Components/Buttons/IconButton.js';
2
+ import testProps from './testProps.js';
2
3
  import UiGlobals from '../UiGlobals.js';
3
4
 
4
5
  export default function getIconButtonFromConfig(config, ix, parent) {
@@ -26,6 +27,7 @@ export default function getIconButtonFromConfig(config, ix, parent) {
26
27
  color: isDisabled ? styles.TOOLBAR_ITEMS_DISABLED_COLOR : styles.TOOLBAR_ITEMS_COLOR,
27
28
  };
28
29
  return <IconButton
30
+ {...testProps(key || 'btn-' + ix)}
29
31
  key={key || ix}
30
32
  parent={parent}
31
33
  reference={key || ix}
@@ -11,7 +11,7 @@ export default function testProps(id) {
11
11
  // id is actually 'self' object
12
12
  id = id.reference;
13
13
  }
14
- if (id.match(/\s/g)) {
14
+ if (id?.match(/\s/g)) {
15
15
  id = id.replace(/\s/g, '_'); // convert any spaces to underscores
16
16
  }
17
17
  if (!window && Platform.OS === 'android') {