@onehat/ui 0.4.70 → 0.4.72

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.
Files changed (120) hide show
  1. package/package.json +2 -1
  2. package/src/Components/Accordion/Accordion.js +1 -0
  3. package/src/Components/Blank.js +1 -0
  4. package/src/Components/Buttons/BackButton.js +1 -0
  5. package/src/Components/Buttons/Button.js +18 -10
  6. package/src/Components/Buttons/CartButtonWithBadge.js +1 -0
  7. package/src/Components/Buttons/IconButton.js +9 -8
  8. package/src/Components/Buttons/PlusMinusButton.js +5 -4
  9. package/src/Components/Buttons/SquareButton.js +19 -18
  10. package/src/Components/Container/Container.js +1 -0
  11. package/src/Components/Container/ContainerColumn.js +4 -3
  12. package/src/Components/Container/ScreenContainer.js +14 -13
  13. package/src/Components/Container/Splitter.js +33 -28
  14. package/src/Components/Editor/InlineEditor.js +32 -30
  15. package/src/Components/Fab/DynamicFab.js +14 -13
  16. package/src/Components/Fab/FabWithTooltip.js +1 -0
  17. package/src/Components/Filter/DateRange.js +8 -7
  18. package/src/Components/Filter/NumberRange.js +8 -7
  19. package/src/Components/Form/Field/CKEditor/CKEditor.js +1 -0
  20. package/src/Components/Form/Field/Checkbox/CheckboxGroup.js +1 -0
  21. package/src/Components/Form/Field/Color.js +41 -40
  22. package/src/Components/Form/Field/Combo/Combo.js +173 -172
  23. package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
  24. package/src/Components/Form/Field/Combo/PageSizeCombo.js +1 -0
  25. package/src/Components/Form/Field/Date.js +117 -116
  26. package/src/Components/Form/Field/DisplayField.js +6 -5
  27. package/src/Components/Form/Field/File.js +1 -0
  28. package/src/Components/Form/Field/FormikForm.js +1 -0
  29. package/src/Components/Form/Field/Input.js +20 -18
  30. package/src/Components/Form/Field/Json.js +7 -6
  31. package/src/Components/Form/Field/Number.js +31 -30
  32. package/src/Components/Form/Field/RadioGroup/RadioGroup.js +1 -0
  33. package/src/Components/Form/Field/Select/PageSizeSelect.js +1 -0
  34. package/src/Components/Form/Field/Select/Select.js +9 -8
  35. package/src/Components/Form/Field/Slider.js +15 -14
  36. package/src/Components/Form/Field/Tag/Tag.js +25 -24
  37. package/src/Components/Form/Field/Tag/ValueBox.js +32 -31
  38. package/src/Components/Form/Field/Text.js +9 -8
  39. package/src/Components/Form/Field/TextArea.js +9 -8
  40. package/src/Components/Form/Field/Toggle.js +16 -15
  41. package/src/Components/Form/FieldSet.js +27 -26
  42. package/src/Components/Form/Form.js +104 -103
  43. package/src/Components/Form/Label.js +15 -14
  44. package/src/Components/Grid/Grid.js +62 -52
  45. package/src/Components/Grid/GridHeaderRow.js +42 -40
  46. package/src/Components/Grid/GridRow.js +92 -90
  47. package/src/Components/Grid/HeaderColumnSelectorHandle.js +9 -8
  48. package/src/Components/Grid/HeaderReorderHandle.js +9 -8
  49. package/src/Components/Grid/HeaderResizeHandle.js +9 -8
  50. package/src/Components/Grid/NoRecordsFound.js +4 -3
  51. package/src/Components/Grid/RowDragHandle.js +26 -10
  52. package/src/Components/Grid/RowHandle.js +55 -0
  53. package/src/Components/Grid/RowSelectHandle.js +1 -0
  54. package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
  55. package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
  56. package/src/Components/Hoc/Secondary/withSecondaryEditor.js +4 -3
  57. package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
  58. package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
  59. package/src/Components/Hoc/Secondary/withSecondaryWindowedEditor.js +6 -5
  60. package/src/Components/Hoc/withAlert.js +38 -35
  61. package/src/Components/Hoc/withCollapsible.js +9 -4
  62. package/src/Components/Hoc/withComponent.js +6 -0
  63. package/src/Components/Hoc/withContextMenu.js +33 -26
  64. package/src/Components/Hoc/withData.js +3 -2
  65. package/src/Components/Hoc/withDnd.js +17 -8
  66. package/src/Components/Hoc/withDraggable.js +21 -5
  67. package/src/Components/Hoc/withEditor.js +3 -2
  68. package/src/Components/Hoc/withEvents.js +11 -1
  69. package/src/Components/Hoc/withFilters.js +26 -20
  70. package/src/Components/Hoc/withModal.js +10 -8
  71. package/src/Components/Hoc/withPdfButtons.js +3 -2
  72. package/src/Components/Hoc/withPermissions.js +3 -2
  73. package/src/Components/Hoc/withPresetButtons.js +3 -2
  74. package/src/Components/Hoc/withSelection.js +2 -8
  75. package/src/Components/Hoc/withToast.js +5 -2
  76. package/src/Components/Hoc/withTooltip.js +10 -1
  77. package/src/Components/Hoc/withValue.js +3 -9
  78. package/src/Components/Hoc/withWindowedEditor.js +6 -5
  79. package/src/Components/Layout/AsyncOperation.js +1 -0
  80. package/src/Components/Layout/CenterBox.js +9 -8
  81. package/src/Components/Layout/Footer.js +11 -10
  82. package/src/Components/Layout/ScreenHeader.js +5 -4
  83. package/src/Components/Layout/TextWithTooltip.js +1 -0
  84. package/src/Components/Messages/ConfirmationMessage.js +6 -5
  85. package/src/Components/Messages/ErrorMessage.js +40 -39
  86. package/src/Components/Messages/GlobalModals.js +47 -0
  87. package/src/Components/Messages/Loading.js +1 -0
  88. package/src/Components/Messages/OkMessage.js +11 -10
  89. package/src/Components/Messages/Unauthorized.js +1 -0
  90. package/src/Components/Messages/WaitMessage.js +16 -15
  91. package/src/Components/Panel/AccordionGridPanel.js +1 -0
  92. package/src/Components/Panel/FormPanel.js +1 -0
  93. package/src/Components/Panel/Header.js +59 -58
  94. package/src/Components/Panel/Mask.js +1 -0
  95. package/src/Components/Panel/Panel.js +7 -6
  96. package/src/Components/Picker/Picker.js +1 -0
  97. package/src/Components/Report/Report.js +35 -34
  98. package/src/Components/Screens/Manager.js +1 -0
  99. package/src/Components/Screens/ReportsManager.js +1 -0
  100. package/src/Components/Tab/Tab.js +1 -0
  101. package/src/Components/Tab/TabBar.js +67 -66
  102. package/src/Components/Toolbar/FilterToolbar.js +14 -11
  103. package/src/Components/Toolbar/Pagination.js +26 -25
  104. package/src/Components/Toolbar/PaginationToolbar.js +13 -12
  105. package/src/Components/Toolbar/Toolbar.js +13 -12
  106. package/src/Components/Tooltip/Tooltip.js +1 -0
  107. package/src/Components/Tree/Tree.js +34 -17
  108. package/src/Components/Tree/TreeNode.js +30 -29
  109. package/src/Components/Tree/TreeNodeDragHandle.js +18 -13
  110. package/src/Components/Viewer/MeterTypeText.js +29 -8
  111. package/src/Components/Viewer/TextWithLinks.js +16 -15
  112. package/src/Components/Viewer/Viewer.js +23 -22
  113. package/src/Components/Window/UploadsDownloadsWindow.js +6 -5
  114. package/src/Components/index.js +1 -0
  115. package/src/Constants/MeterTypes.js +2 -0
  116. package/src/Functions/addIconProps.js +46 -0
  117. package/src/Functions/testProps.js +1 -1
  118. package/src/Hooks/useWhyDidYouUpdate.js +33 -0
  119. package/src/PlatformImports/Web/Attachments.js +1 -1
  120. package/src/Components/Hoc/withBlank.js +0 -10
@@ -1,23 +1,44 @@
1
1
  import {
2
2
  TextNative,
3
3
  } from '@project-components/Gluestack';
4
+ import clsx from 'clsx';
5
+ import {
6
+ METER_TYPES__HOURS,
7
+ METER_TYPES__MILES,
8
+ METER_TYPES__HOURS_TEXT,
9
+ METER_TYPES__MILES_TEXT,
10
+ } from '../../Constants/MeterTypes';
11
+
4
12
  import UiGlobals from '../../UiGlobals';
5
13
 
6
14
  export default function MeterTypeText(props) {
7
15
  const styles = UiGlobals.styles;
8
16
 
9
- let className = `
10
- Text
11
- flex-1
12
- px-3
13
- py-2
14
- ${styles.FORM_TEXT_CLASSNAME}
15
- `;
17
+ let className = clsx(
18
+ 'Text',
19
+ 'flex-1',
20
+ 'px-3',
21
+ 'py-2',
22
+ styles.FORM_TEXT_CLASSNAME,
23
+ );
16
24
  if (props.className) {
17
25
  className += ' ' + props.className;
18
26
  }
27
+ let meterType = '';
28
+ switch(props.value) {
29
+ case METER_TYPES__HOURS:
30
+ meterType = METER_TYPES__HOURS_TEXT;
31
+ break;
32
+ case METER_TYPES__MILES:
33
+ meterType = METER_TYPES__MILES_TEXT;
34
+ break;
35
+ default:
36
+ meterType = 'unknown';
37
+ break;
38
+ }
39
+
19
40
  return <TextNative
20
41
  {...props}
21
42
  className={className}
22
- >{props.value ? 'Time (hrs)' : 'Distance (mi/km)'}</TextNative>;
43
+ >{meterType}</TextNative>;
23
44
  };
@@ -6,6 +6,7 @@ import {
6
6
  Text,
7
7
  TextNative,
8
8
  } from '@project-components/Gluestack';
9
+ import clsx from 'clsx';
9
10
  import {
10
11
  UI_MODE_WEB,
11
12
  } from '../../Constants/UiModes.js';
@@ -48,11 +49,11 @@ function TextWithLinksElement(props) {
48
49
  });
49
50
 
50
51
  const
51
- textClassName = `
52
- TextWithLinks-Text
53
- text-base
54
- overflow-hidden
55
- `,
52
+ textClassName = clsx(
53
+ 'TextWithLinks-Text',
54
+ 'text-base',
55
+ 'overflow-hidden',
56
+ ),
56
57
  textSegments = modifiedText.split(/(link_\d+)/);
57
58
  if (textSegments.length === 1) {
58
59
  return <Text className={textClassName}>{modifiedText}</Text>;
@@ -65,10 +66,10 @@ function TextWithLinksElement(props) {
65
66
  if (foundLink) {
66
67
  ret = <TextNative
67
68
  key={foundLink.key}
68
- className={`
69
- text-blue-600
70
- ${textClassName}
71
- `}
69
+ className={clsx(
70
+ 'text-blue-600',
71
+ textClassName,
72
+ )}
72
73
  onPress={() => openLink(foundLink.link)}
73
74
  >{foundLink.link}</TextNative>;
74
75
  }
@@ -80,12 +81,12 @@ function TextWithLinksElement(props) {
80
81
  if (UiGlobals.mode === UI_MODE_WEB) {
81
82
  elementProps.textOverflow = 'ellipsis';
82
83
  }
83
- let className = `
84
- overflow-auto
85
- min-h-[40px]
86
- px-3
87
- py-2
88
- `;
84
+ let className = clsx(
85
+ 'overflow-auto',
86
+ 'min-h-[40px]',
87
+ 'px-3',
88
+ 'py-2',
89
+ );
89
90
  if (props.className) {
90
91
  className += ` ${props.className}`;
91
92
  }
@@ -8,6 +8,7 @@ import {
8
8
  VStack,
9
9
  VStackNative,
10
10
  } from '@project-components/Gluestack';
11
+ import clsx from 'clsx';
11
12
  import Animated, {
12
13
  useSharedValue,
13
14
  useAnimatedStyle,
@@ -264,12 +265,12 @@ function Viewer(props) {
264
265
  }
265
266
  }
266
267
 
267
- let elementClassName = `
268
- Viewer-field
269
- basis-auto
270
- grow
271
- shrink
272
- `;
268
+ let elementClassName = clsx(
269
+ 'Viewer-field',
270
+ 'basis-auto',
271
+ 'grow',
272
+ 'shrink',
273
+ );
273
274
  const defaultsClassName = defaults.className;
274
275
  if (defaultsClassName) {
275
276
  elementClassName += ' ' + defaultsClassName;
@@ -474,11 +475,11 @@ function Viewer(props) {
474
475
  if (!hasWidth(props) && !hasFlex(props)) {
475
476
  style.flex = 1;
476
477
  }
477
- let className = `
478
- Viewer-VStackNative
479
- h-full
480
- bg-white
481
- `;
478
+ let className = clsx(
479
+ 'Viewer-VStackNative',
480
+ 'h-full',
481
+ 'bg-white',
482
+ );
482
483
  if (props.className) {
483
484
  className += ' ' + props.className;
484
485
  }
@@ -491,11 +492,11 @@ function Viewer(props) {
491
492
  {...testProps('deleteBtn')}
492
493
  key="deleteBtn"
493
494
  onPress={onDelete}
494
- className={`
495
- text-white
496
- bg-warning-500
497
- hover:bg-warning-600
498
- `}
495
+ className={clsx(
496
+ 'text-white',
497
+ 'bg-warning-500',
498
+ 'hover:bg-warning-600',
499
+ )}
499
500
  text="Delete"
500
501
  />
501
502
  </HStack>}
@@ -523,12 +524,12 @@ function Viewer(props) {
523
524
  ref={scrollViewRef}
524
525
  onScroll={onScroll}
525
526
  scrollEventThrottle={16 /* ms */}
526
- className={`
527
- Viewer-ScrollView
528
- w-full
529
- pb-1
530
- flex-1
531
- `}
527
+ className={clsx(
528
+ 'Viewer-ScrollView',
529
+ 'w-full',
530
+ 'pb-1',
531
+ 'flex-1',
532
+ )}
532
533
  >
533
534
  {scrollToTopAnchor}
534
535
  {canEdit && onEditMode &&
@@ -5,6 +5,7 @@
5
5
  * "LICENSE.txt" file, which is part of this source code package.
6
6
  */
7
7
  import { useState, } from 'react';
8
+ import clsx from 'clsx';
8
9
  import Excel from '../Icons/Excel';
9
10
  import Panel from '../Panel/Panel.js';
10
11
  import Form from '../Form/Form.js';
@@ -187,11 +188,11 @@ function UploadsDownloadsWindow(props) {
187
188
  reference="UploadsDownloadsWindow"
188
189
  isCollapsible={false}
189
190
  title="Uploads & Downloads"
190
- className={`
191
- flex-none
192
- bg-white
193
- shadow-lg
194
- `}
191
+ className={clsx(
192
+ 'flex-none',
193
+ 'bg-white',
194
+ 'shadow-lg',
195
+ )}
195
196
  style={{
196
197
  height,
197
198
  width,
@@ -2,6 +2,7 @@ import {
2
2
  HStackNative,
3
3
  VStackNative,
4
4
  } from '@project-components/Gluestack';
5
+ import clsx from 'clsx';
5
6
  import AddressBook from './Icons/AddressBook.js';
6
7
  import Alt from './Icons/Alt.js';
7
8
  import AngleLeft from './Icons/AngleLeft.js';
@@ -1,2 +1,4 @@
1
1
  export const METER_TYPES__HOURS = 1;
2
2
  export const METER_TYPES__MILES = 2;
3
+ export const METER_TYPES__HOURS_TEXT = 'Time (hrs)';
4
+ export const METER_TYPES__MILES_TEXT = 'Distance (mi/km)';
@@ -0,0 +1,46 @@
1
+
2
+ import clsx from 'clsx';
3
+ import {
4
+ UI_MODE_WEB,
5
+ UI_MODE_NATIVE,
6
+ CURRENT_MODE,
7
+ } from '../Constants/UiModes.js';
8
+ import _ from 'lodash';
9
+
10
+ export default function addIconProps(iconProps = {}) {
11
+
12
+ iconProps = _.cloneDeep(iconProps); // avoid mutating the original props, as they may be submitted to multiple components
13
+
14
+ iconProps.className = clsx(
15
+ 'Icon',
16
+ iconProps.className,
17
+ );
18
+
19
+ if (CURRENT_MODE === UI_MODE_WEB) {
20
+ return iconProps;
21
+ }
22
+
23
+ // native only
24
+
25
+ // marginx
26
+ iconProps.style = {
27
+ marginHorizontal: 8,
28
+ ...iconProps.style,
29
+ };
30
+
31
+ // On native, react-native-svg ignores className and will only size the icon based on
32
+ // explicit width / height props (or size if the wrapper supports it).
33
+ // If no size set, it falls back to the full intrinsic viewBox size, so we need to ensure we set a default size.
34
+ // If you want to override the size, pass width and height props to the icon.
35
+ if (iconProps.width || iconProps.height) {
36
+ return iconProps;
37
+ }
38
+ const nativeDefaults = {
39
+ width: 24,
40
+ height: 24,
41
+ };
42
+ return {
43
+ ...nativeDefaults,
44
+ ...iconProps,
45
+ };
46
+ }
@@ -22,7 +22,7 @@ export default function testProps(id, suffix) {
22
22
  if (suffix) {
23
23
  id += suffix; // this is used in conjunction with 'self' object
24
24
  }
25
- if (!window && Platform.OS === 'android') {
25
+ if (typeof window === 'undefined' && Platform.OS === 'android') {
26
26
  return {
27
27
  accessibilityLabel: id,
28
28
  accessible: true,
@@ -0,0 +1,33 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ // This custom hook logs changes in props for debugging purposes.
4
+ // It can be used to track why a component re-renders by comparing current props with previous props
5
+
6
+ // Usage in your component:
7
+ // useWhyDidYouUpdate('withMhTree', { enterpriseId, getEquipment, showInactiveEquipment });
8
+
9
+ export default function useWhyDidYouUpdate(name, props) {
10
+ const previous = useRef();
11
+
12
+ useEffect(() => {
13
+ if (previous.current) {
14
+ const allKeys = Object.keys({ ...previous.current, ...props });
15
+ const changedProps = {};
16
+
17
+ allKeys.forEach(key => {
18
+ if (previous.current[key] !== props[key]) {
19
+ changedProps[key] = {
20
+ from: previous.current[key],
21
+ to: props[key]
22
+ };
23
+ }
24
+ });
25
+
26
+ if (Object.keys(changedProps).length) {
27
+ console.log('[why-did-you-update]', name, changedProps);
28
+ }
29
+ }
30
+
31
+ previous.current = props;
32
+ });
33
+ }
@@ -37,7 +37,7 @@ import _ from 'lodash';
37
37
  const
38
38
  EXPANDED_MAX = 100,
39
39
  COLLAPSED_MAX = 4,
40
- isPwa = !!window?.navigator?.standalone;
40
+ isPwa = typeof window !== 'undefined' && !!window?.navigator?.standalone;
41
41
 
42
42
  function FileCardCustom(props) {
43
43
  const {
@@ -1,10 +0,0 @@
1
- import { forwardRef } from 'react';
2
-
3
- export default function withBlank(WrappedComponent) {
4
- return forwardRef((props, ref) => {
5
- const {
6
-
7
- } = props;
8
- return <WrappedComponent {...props} ref={ref} />;
9
- });
10
- }