@onehat/ui 0.4.25 → 0.4.26

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.4.25",
3
+ "version": "0.4.26",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  EDITOR_MODE__VIEW,
3
+ EDITOR_TYPE__SIDE,
3
4
  } from '../../Constants/Editor.js';
4
5
  import withComponent from '../Hoc/withComponent.js';
5
6
  import withPdfButtons from '../Hoc/withPdfButtons.js';
@@ -34,7 +35,10 @@ function Editor(props) {
34
35
  return null; // hide the editor when no selection
35
36
  }
36
37
 
37
- const propsToPass = _.omit(props, ['self', 'reference', 'parent']);
38
+ const propsToPass = _.omit(props, ['self', 'reference', 'parent', 'style']);
39
+ if (propsToPass.editorType === EDITOR_TYPE__SIDE) {
40
+ propsToPass.style = props.style; // side editor needs the style prop, but a windowed editor can get messed up if it's present (and withModal is used)!
41
+ }
38
42
 
39
43
  let canEdit = true;
40
44
  if (canRecordBeEdited && !canRecordBeEdited(selection)) {
@@ -77,7 +77,6 @@ function TagComponent(props) {
77
77
  showModal({
78
78
  body: <Editor
79
79
  editorType={EDITOR_TYPE__WINDOWED}
80
- {...propsToPass}
81
80
  parent={self}
82
81
  reference="viewer"
83
82
  isEditorViewOnly={true}
@@ -234,6 +233,7 @@ function TagComponent(props) {
234
233
  onView={() => onView(val)}
235
234
  onDelete={!isViewOnly ? () => onDelete(val) : null}
236
235
  showEye={showEye}
236
+ minimizeForRow={minimizeForRow}
237
237
  />;
238
238
  });
239
239
 
@@ -297,7 +297,7 @@ function TagComponent(props) {
297
297
  valueBoxesClassName += ' min-h-[25px] h-full overflow-auto flex-1';
298
298
  } else {
299
299
  // shrink both down
300
- valueBoxesClassName += ' h-auto min-h-[25px] max-h-[25px] overflow-auto flex-1';
300
+ valueBoxesClassName += ' Scott h-auto min-h-[25px] max-h-[35px] overflow-auto flex-1';
301
301
  comboClassName += ' h-auto min-h-0 max-h-[25px] flex-1';
302
302
  }
303
303
  }
@@ -15,6 +15,7 @@ export default function ValueBox(props) {
15
15
  onView,
16
16
  onDelete,
17
17
  showEye,
18
+ minimizeForRow = false,
18
19
  } = props,
19
20
  styles = UiGlobals.styles;
20
21
  return <HStackNative
@@ -31,20 +32,22 @@ export default function ValueBox(props) {
31
32
  ${!onDelete && 'pr-4'}
32
33
  `}
33
34
  >
34
- {showEye && <IconButton
35
- {...testProps('eyeBtn')}
36
- icon={Eye}
37
- _icon={{
38
- size: styles.FORM_TAG_VALUEBOX_ICON_SIZE,
39
- className: 'text-grey-600',
40
- }}
41
- onPress={onView}
42
- className={`
43
- ValueBox-eyeBtn
44
- h-full
45
- ${styles.FORM_TAG_BTN_CLASSNAME}
46
- `}
47
- />}
35
+ {showEye &&
36
+ <IconButton
37
+ {...testProps('eyeBtn')}
38
+ icon={Eye}
39
+ _icon={{
40
+ size: styles.FORM_TAG_VALUEBOX_ICON_SIZE,
41
+ className: 'text-grey-600',
42
+ }}
43
+ onPress={onView}
44
+ className={`
45
+ ValueBox-eyeBtn
46
+ h-full
47
+ ${minimizeForRow ? 'py-0' : ''}
48
+ ${styles.FORM_TAG_BTN_CLASSNAME}
49
+ `}
50
+ />}
48
51
  <Text
49
52
  className={`
50
53
  ValueBox-Text
@@ -52,6 +55,7 @@ export default function ValueBox(props) {
52
55
  ${styles.FORM_TAG_VALUEBOX_CLASSNAME}
53
56
  ${showEye ? 'ml-0' : 'ml-1'}
54
57
  ${onDelete ? 'mr-0' : 'mr-1'}
58
+ ${minimizeForRow ? 'py-0' : ''}
55
59
  `}
56
60
  >{text}</Text>
57
61
  {onDelete &&
@@ -66,6 +70,7 @@ export default function ValueBox(props) {
66
70
  className={`
67
71
  ValueBox-xBtn
68
72
  h-full
73
+ ${minimizeForRow ? 'py-0' : ''}
69
74
  ${styles.FORM_TAG_BTN_CLASSNAME}
70
75
  `}
71
76
  />}
@@ -153,6 +153,7 @@ function GridComponent(props) {
153
153
  alternateRowBackgrounds = true,
154
154
  alternatingInterval = 2,
155
155
  defaultRowHeight = 48,
156
+ getRowTestId,
156
157
 
157
158
  // The selectorSelected mechanism allows us to filter results of the primary model, (e.g. WorkOrders)
158
159
  // by the selection on the secondary model (e.g. Equipment). It's used on Grids, Trees, Forms, etc.
@@ -390,7 +391,7 @@ function GridComponent(props) {
390
391
 
391
392
  let rowComponent =
392
393
  <Pressable
393
- {...testProps((Repository ? Repository.schema.name : 'GridRow') + '-' + item?.id)}
394
+ {...testProps(getRowTestId ? getRowTestId(row) : ((Repository ? Repository.schema.name : 'GridRow') + '-' + item?.id))}
394
395
  onPress={(e) => {
395
396
  if (e.preventDefault && e.cancelable) {
396
397
  e.preventDefault();
@@ -597,6 +598,7 @@ function GridComponent(props) {
597
598
  `}
598
599
  >
599
600
  <ExpandButton
601
+ {...testProps((Repository ? Repository.schema.name : 'GridRow') + '-expandBtn-' + item?.id)}
600
602
  isExpanded={isExpanded}
601
603
  onToggle={() => setIsExpanded(index, !isExpanded)}
602
604
  _icon={{
@@ -1272,7 +1274,8 @@ function GridComponent(props) {
1272
1274
  </VStackNative>
1273
1275
 
1274
1276
  if (isDropTarget) {
1275
- grid = <Box
1277
+ grid = <VStackNative
1278
+ {...testProps(self, '-dropTarget')}
1276
1279
  ref={dropTargetRef}
1277
1280
  className={`
1278
1281
  Grid-dropTarget
@@ -1281,7 +1284,7 @@ function GridComponent(props) {
1281
1284
  border-[#0ff]
1282
1285
  ${canDrop && isOver ? "border-[4px]" : "border-[0px]"}
1283
1286
  `}
1284
- >{grid}</Box>
1287
+ >{grid}</VStackNative>
1285
1288
  }
1286
1289
  return grid;
1287
1290
  }
@@ -47,8 +47,9 @@ export default function PaginationToolbar(props) {
47
47
  minimize={minimize}
48
48
  disablePageSize={disablePageSize}
49
49
  />
50
- {toolbarItems.length &&
50
+ {toolbarItems.length ?
51
51
  <HStack className={`
52
+ PaginationToolbar-HStack
52
53
  flex-1
53
54
  space-x-1
54
55
  border-l
@@ -56,6 +57,6 @@ export default function PaginationToolbar(props) {
56
57
  ml-3
57
58
  pl-3
58
59
  `}
59
- >{toolbarItems}</HStack>}
60
+ >{toolbarItems}</HStack> : null}
60
61
  </Toolbar>;
61
62
  };
@@ -37,6 +37,12 @@ export function getTestIdSelectors(selectors, isGetFirst = false) {
37
37
  if (selector.match(/=/)) { // selector is something like [role="switch"], so don't use data-testid
38
38
  return selector;
39
39
  }
40
+ if (selector.match(/^\./)) { // selector is something like .my-class, so don't use data-testid
41
+ return selector;
42
+ }
43
+ if (selector.match(/^#/)) { // selector is something like #my-id, so don't use data-testid
44
+ return selector;
45
+ }
40
46
  return '[data-testid="' + selector + '"]' + (isGetFirst ? ':first' : '');
41
47
  });
42
48
  return selectorParts.join(' ');
@@ -4,7 +4,7 @@ import UiGlobals from '../UiGlobals.js';
4
4
  // This adds a data-testid attribute to the DOM node,
5
5
  // which can be quried in Cypress by: document.querySelector(`[data-testid='MyTestId']`);
6
6
 
7
- export default function testProps(id) {
7
+ export default function testProps(id, suffix) {
8
8
  if (!UiGlobals.debugMode) {
9
9
  return {};
10
10
  }
@@ -19,6 +19,9 @@ export default function testProps(id) {
19
19
  if (id.match(/\s/g)) {
20
20
  id = id.replace(/\s/g, '_'); // convert any spaces to underscores
21
21
  }
22
+ if (suffix) {
23
+ id += suffix; // this is used in conjunction with 'self' object
24
+ }
22
25
  if (!window && Platform.OS === 'android') {
23
26
  return {
24
27
  accessibilityLabel: id,
@@ -1,6 +1,6 @@
1
1
  html, body {
2
- -webkit-user-select: none;
3
- user-select: none;
2
+ /* -webkit-user-select: none;
3
+ user-select: none; */
4
4
  }
5
5
 
6
6
  /* to fix the inline editor */
@@ -1,14 +0,0 @@
1
- import Container from '../Container/Container.js';
2
- import emptyFn from '../../Functions/emptyFn.js';
3
- import _ from 'lodash';
4
-
5
- export default function EditorWindow(props) {
6
- const {
7
- title,
8
- isOpen = false,
9
- onClose = emptyFn,
10
- ...propsToPass
11
- } = props;
12
-
13
-
14
- }