@onehat/ui 0.4.40 → 0.4.42

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 (32) hide show
  1. package/package.json +1 -1
  2. package/src/Components/Buttons/Button.js +6 -13
  3. package/src/Components/Buttons/ReloadButton.js +0 -1
  4. package/src/Components/Filter/DateRange.js +3 -1
  5. package/src/Components/Filter/NumberRange.js +4 -1
  6. package/src/Components/Form/Field/Checkbox/CheckboxGroup.js +11 -9
  7. package/src/Components/Form/Field/Combo/Combo.js +118 -83
  8. package/src/Components/Form/Field/Combo/PageSizeCombo.js +1 -0
  9. package/src/Components/Form/Field/Date.js +15 -2
  10. package/src/Components/Form/Field/Number.js +5 -6
  11. package/src/Components/Form/Field/RadioGroup/RadioGroup.js +11 -9
  12. package/src/Components/Form/Field/Select/PageSizeSelect.js +2 -1
  13. package/src/Components/Form/Field/Slider.js +186 -191
  14. package/src/Components/Form/Field/Tag/Tag.js +12 -10
  15. package/src/Components/Form/Field/TextArea.js +96 -98
  16. package/src/Components/Form/Form.js +12 -9
  17. package/src/Components/Grid/Grid.js +21 -22
  18. package/src/Components/Grid/GridRow.js +11 -12
  19. package/src/Components/Hoc/Secondary/withSecondarySelection.js +22 -7
  20. package/src/Components/Hoc/withEditor.js +60 -21
  21. package/src/Components/Hoc/withFilters.js +1 -1
  22. package/src/Components/Hoc/withMultiSelection.js +1 -2
  23. package/src/Components/Hoc/withPdfButtons.js +3 -0
  24. package/src/Components/Hoc/withSelection.js +63 -35
  25. package/src/Components/Hoc/withTooltip.js +7 -1
  26. package/src/Components/Toolbar/Pagination.js +56 -56
  27. package/src/Components/Toolbar/PaginationToolbar.js +18 -15
  28. package/src/Components/Toolbar/Toolbar.js +4 -7
  29. package/src/Components/Tooltip/Tooltip.js +13 -10
  30. package/src/Components/Tree/Tree.js +14 -10
  31. package/src/Components/Viewer/MeterTypeText.js +3 -3
  32. package/src/Constants/Styles.js +2 -0
@@ -70,14 +70,23 @@ export default function Pagination(props) {
70
70
  }
71
71
  if (!Repository.isLocal) {
72
72
  items.push(<ReloadButton
73
- key="reloadPageBtn"
74
- className="Pagination-reloadPageBtn"
75
- _icon={iconProps}
76
- Repository={Repository}
77
- self={self}
78
- />);
73
+ key="reloadPageBtn"
74
+ className="Pagination-reloadPageBtn"
75
+ _icon={iconProps}
76
+ Repository={Repository}
77
+ self={self}
78
+ />);
79
79
  }
80
80
  } else {
81
+ if (!Repository.isLocal) {
82
+ items.push(<ReloadButton
83
+ key="reloadPageBtn"
84
+ className="Pagination-reloadPageBtn"
85
+ _icon={iconProps}
86
+ Repository={Repository}
87
+ self={self}
88
+ />);
89
+ }
81
90
  isDisabled = page === 1;
82
91
  if (showPagination) {
83
92
  items.push(<IconButton
@@ -104,41 +113,6 @@ export default function Pagination(props) {
104
113
  onPress={() => Repository.prevPage()}
105
114
  tooltip="Previous Page"
106
115
  />);
107
- if (!minimize) {
108
- items.push(<Text
109
- key="page"
110
- className="Pagination-page mx-1"
111
- >Page</Text>);
112
- items.push(<Input
113
- {...testProps('pageInput')}
114
- key="pageInput"
115
- reference="pageInput"
116
- parent={self}
117
- keyboardType="numeric"
118
- value={page?.toString()}
119
- onChangeValue={(value) => Repository.setPage(value)}
120
- maxValue={totalPages}
121
- isDisabled={totalPages === 1}
122
- className={`
123
- Pagination-pageInput
124
- min-w-[40px]
125
- w-[40px]
126
- text-center
127
- bg-grey-100
128
- `}
129
- textAlignIsCenter={true}
130
- tooltip="Set Page"
131
- />);
132
- items.push(<Text
133
- key="totalPages"
134
- className={`
135
- Pagination-totalPages
136
- whitespace-nowrap
137
- inline-flex
138
- mx-1
139
- `}
140
- >{`of ${totalPages}`}</Text>);
141
- }
142
116
 
143
117
  isDisabled = page === totalPages || totalPages <= 1;
144
118
  items.push(<IconButton
@@ -165,17 +139,44 @@ export default function Pagination(props) {
165
139
  onPress={() => Repository.setPage(totalPages)}
166
140
  tooltip="Last Page"
167
141
  />);
142
+ if (!minimize) {
143
+ items.push(<Text
144
+ key="page"
145
+ className="Pagination-page mx-1"
146
+ >Page</Text>);
147
+ items.push(<Input
148
+ {...testProps('pageInput')}
149
+ key="pageInput"
150
+ reference="pageInput"
151
+ parent={self}
152
+ keyboardType="numeric"
153
+ value={page?.toString()}
154
+ onChangeValue={(value) => Repository.setPage(value)}
155
+ maxValue={totalPages}
156
+ isDisabled={totalPages === 1}
157
+ className={`
158
+ Pagination-pageInput
159
+ min-w-[40px]
160
+ w-[40px]
161
+ text-center
162
+ bg-grey-100
163
+ `}
164
+ textAlignIsCenter={true}
165
+ tooltip="Set Page"
166
+ tooltipClassName="w-[40px]"
167
+ />);
168
+ items.push(<Text
169
+ key="totalPages"
170
+ className={`
171
+ Pagination-totalPages
172
+ whitespace-nowrap
173
+ inline-flex
174
+ mx-1
175
+ `}
176
+ >{`of ${totalPages}`}</Text>);
177
+ }
168
178
  }
169
179
 
170
- if (!Repository.isLocal) {
171
- items.push(<ReloadButton
172
- key="reloadPageBtn"
173
- className="Pagination-reloadPageBtn"
174
- _icon={iconProps}
175
- Repository={Repository}
176
- self={self}
177
- />);
178
- }
179
180
  if (showPagination && !minimize && !disablePageSize) {
180
181
  items.push(<PageSizeSelect
181
182
  {...testProps('pageSize')}
@@ -203,15 +204,14 @@ export default function Pagination(props) {
203
204
  }
204
205
  }
205
206
  return <HStack
206
- style={{ userSelect: 'none', }}
207
+ style={{
208
+ userSelect: 'none',
209
+ }}
207
210
  className={`
208
211
  Pagination
209
- flex-none
210
- gap-1
211
- justify-start
212
212
  items-center
213
- px-2
214
- mr-3
213
+ shrink-0
214
+ gap-2
215
215
  `}
216
216
  >
217
217
  {items}
@@ -10,11 +10,15 @@ export default function PaginationToolbar(props) {
10
10
  const {
11
11
  toolbarItems = [],
12
12
  disablePageSize = false,
13
+ minimize,
13
14
  } = props,
14
- [minimize, setMinimize] = useState(false),
15
+ [minimizeLocal, setMinimizeLocal] = useState(minimize),
15
16
  propsToPass = _.omit(props, 'toolbarItems'),
16
17
  showPagination = true,//props.Repository?.totalPages > 1,
17
18
  onLayout = (e) => {
19
+ if (minimize) {
20
+ return; // skip if already minimized
21
+ }
18
22
  // Note to future self: this is using hard-coded values.
19
23
  // Eventually might want to make it responsive to actual sizes
20
24
 
@@ -28,7 +32,7 @@ export default function PaginationToolbar(props) {
28
32
  shouldMinimize = width < threshold;
29
33
 
30
34
  if (shouldMinimize !== minimize) {
31
- setMinimize(shouldMinimize);
35
+ setMinimizeLocal(shouldMinimize);
32
36
  }
33
37
  };
34
38
 
@@ -36,27 +40,26 @@ export default function PaginationToolbar(props) {
36
40
  className={`
37
41
  border-t
38
42
  border-t-grey-400
39
- w-full
40
43
  `}
41
44
  onLayout={(e) => onLayout(e)}
42
45
  >
46
+ {toolbarItems.length ?
47
+ <HStack
48
+ className={`
49
+ PaginationToolbar-HStack
50
+ shrink-0
51
+ border-r
52
+ border-r-grey-400
53
+ mr-3
54
+ pr-3
55
+ `}
56
+ >{toolbarItems}</HStack> : null}
43
57
  <Pagination
44
58
  {...propsToPass}
45
59
  showPagination={showPagination}
46
60
  w={toolbarItems.length ? null : '100%'}
47
- minimize={minimize}
61
+ minimize={minimizeLocal}
48
62
  disablePageSize={disablePageSize}
49
63
  />
50
- {toolbarItems.length ?
51
- <HStack className={`
52
- PaginationToolbar-HStack
53
- flex-1
54
- space-x-1
55
- border-l
56
- border-l-grey-400
57
- ml-3
58
- pl-3
59
- `}
60
- >{toolbarItems}</HStack> : null}
61
64
  </Toolbar>;
62
65
  };
@@ -9,14 +9,11 @@ export default function Toolbar(props) {
9
9
 
10
10
  let className = `
11
11
  Toolbar
12
- flex
13
- w-full
14
- justify-start
15
- items-center
16
12
  overflow-auto
17
- space-x-2
18
- px-2
19
- py-2
13
+ items-center
14
+ justify-start
15
+ gap-2
16
+ p-2
20
17
  border-b
21
18
  border-solid
22
19
  border-b-grey-400
@@ -1,5 +1,8 @@
1
- import { forwardRef, cloneElement } from 'react';
2
- import { Tooltip, TooltipContent, TooltipText } from '@project-components/Gluestack';
1
+ import { forwardRef } from 'react';
2
+ import {
3
+ BoxNative as Box,
4
+ Tooltip, TooltipContent, TooltipText,
5
+ } from '@project-components/Gluestack';
3
6
 
4
7
  const TooltipElement = forwardRef((props, ref) => {
5
8
  const {
@@ -12,18 +15,18 @@ const TooltipElement = forwardRef((props, ref) => {
12
15
  if (props.className) {
13
16
  className += ' ' + props.className;
14
17
  }
18
+
19
+ let triggerClassName = 'Tooltip-trigger';
20
+ if (props.className) {
21
+ triggerClassName += ' ' + props.className;
22
+ }
15
23
 
16
24
  return <Tooltip
17
25
  placement={placement}
18
26
  trigger={(triggerProps) => {
19
- const propsToPass = {
20
- ...triggerProps,
21
- ...children.props,
22
- };
23
- if (ref) {
24
- propsToPass.ref = ref;
25
- }
26
- return cloneElement(children, propsToPass);
27
+ return <Box className={triggerClassName} {...triggerProps}>
28
+ {children}
29
+ </Box>;
27
30
  }}
28
31
  >
29
32
  <TooltipContent className={className}>
@@ -534,10 +534,12 @@ function TreeComponent(props) {
534
534
  buildAndSetTreeNodeData = async () => {
535
535
  let nodes = [];
536
536
  if (Repository) {
537
- if (!Repository.areRootNodesLoaded) {
538
- nodes = await Repository.loadRootNodes(1);
539
- } else {
540
- nodes = Repository.getRootNodes();
537
+ if (!Repository.isDestroyed) {
538
+ if (!Repository.areRootNodesLoaded) {
539
+ nodes = await Repository.loadRootNodes(1);
540
+ } else {
541
+ nodes = Repository.getRootNodes();
542
+ }
541
543
  }
542
544
  } else {
543
545
  nodes = assembleDataTreeNodes();
@@ -611,7 +613,9 @@ function TreeComponent(props) {
611
613
  },
612
614
  getTreeNodeByNodeId = (node_id) => {
613
615
  if (Repository) {
614
- return Repository.getById(node_id);
616
+ if (!Repository.isDestroyed) {
617
+ return Repository.getById(node_id);
618
+ }
615
619
  }
616
620
  return data[node_id]; // TODO: This is probably not right!
617
621
  },
@@ -1217,11 +1221,11 @@ function TreeComponent(props) {
1217
1221
  dropRowRecord = dropRowDatum.item;
1218
1222
 
1219
1223
  if (Repository) {
1220
-
1221
- const commonAncestorId = await Repository.moveTreeNode(dragRowRecord, dropRowRecord.id);
1222
- const commonAncestorDatum = getDatumById(commonAncestorId);
1223
- reloadNode(commonAncestorDatum.item);
1224
-
1224
+ if (!Repository.isDestroyed) {
1225
+ const commonAncestorId = await Repository.moveTreeNode(dragRowRecord, dropRowRecord.id);
1226
+ const commonAncestorDatum = getDatumById(commonAncestorId);
1227
+ reloadNode(commonAncestorDatum.item);
1228
+ }
1225
1229
  } else {
1226
1230
 
1227
1231
  throw Error('Not yet implemented');
@@ -1,5 +1,5 @@
1
1
  import {
2
- Text,
2
+ TextNative,
3
3
  } from '@project-components/Gluestack';
4
4
  import UiGlobals from '../../UiGlobals';
5
5
 
@@ -16,8 +16,8 @@ export default function MeterTypeText(props) {
16
16
  if (props.className) {
17
17
  className += ' ' + props.className;
18
18
  }
19
- return <Text
19
+ return <TextNative
20
20
  {...props}
21
21
  className={className}
22
- >{props.value ? 'Time (hrs)' : 'Distance (mi/km)'}</Text>;
22
+ >{props.value ? 'Time (hrs)' : 'Distance (mi/km)'}</TextNative>;
23
23
  };
@@ -78,6 +78,8 @@ const defaults = {
78
78
  GRID_ROW_BG_HOVER: '#ccc', // must be hex
79
79
  GRID_ROW_SELECTED_BG: '#ff0', // must be hex
80
80
  GRID_ROW_SELECTED_BG_HOVER: '#cc0', // must be hex
81
+ GRID_ROW_MAX_HEIGHT_NORMAL: 'max-h-[40px]',
82
+ GRID_ROW_MAX_HEIGHT_EXTRA: 'max-h-[80px]',
81
83
  GRID_REORDER_BORDER_COLOR: 'border-[#23d9ea]',
82
84
  GRID_REORDER_BORDER_WIDTH: 'border-4',
83
85
  GRID_REORDER_BORDER_STYLE: 'border-dashed',