@onehat/ui 0.3.83 → 0.3.85

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.83",
3
+ "version": "0.3.85",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -61,6 +61,7 @@ const
61
61
  bg: styles.ICON_BUTTON_BG_PRESSED,
62
62
  }}
63
63
  {...props}
64
+ size={null /* this prop was coming from above and messing things up! */}
64
65
  >
65
66
  {icon}
66
67
  </Pressable>;
@@ -299,24 +299,33 @@ export default function withEditor(WrappedComponent, isTree = false) {
299
299
  }
300
300
 
301
301
  setIsSaving(true);
302
- await Repository.save();
302
+ let success;
303
+ try {
304
+ await Repository.save();
305
+ success = true;
306
+ } catch (e) {
307
+ success = false;
308
+ }
303
309
  setIsSaving(false);
304
310
 
305
- setIsAdding(false);
306
- setEditorMode(EDITOR_MODE__EDIT);
307
- // setIsEditorShown(false);
308
-
309
- if (getListeners().onAfterEdit) {
310
- await getListeners().onAfterEdit(what);
311
- }
312
- if (onChange) {
313
- onChange();
314
- }
315
- if (onSave) {
316
- onSave(what);
311
+ if (success) {
312
+ setIsAdding(false);
313
+
314
+ setEditorMode(EDITOR_MODE__EDIT);
315
+ // setIsEditorShown(false);
316
+
317
+ if (getListeners().onAfterEdit) {
318
+ await getListeners().onAfterEdit(what);
319
+ }
320
+ if (onChange) {
321
+ onChange();
322
+ }
323
+ if (onSave) {
324
+ onSave(what);
325
+ }
317
326
  }
318
327
 
319
- return true;
328
+ return success;
320
329
  },
321
330
  onEditorCancel = () => {
322
331
  async function doIt() {
@@ -28,7 +28,7 @@ function TabBar(props) {
28
28
  content, // e.g. Expo Router slot
29
29
  direction = HORIZONTAL,
30
30
  tabWidth = 150, // used on VERTICAL mode only
31
- tabHeight = '44px', // used on HORIZONTAL mode only
31
+ tabHeight = '47px', // used on HORIZONTAL mode only
32
32
  additionalButtons,
33
33
  initialTabIx = 0,
34
34
  currentTabIx,
@@ -36,7 +36,9 @@ function TabBar(props) {
36
36
  startsCollapsed = true,
37
37
  onChangeCurrentTab,
38
38
  onChangeIsCollapsed,
39
+ onPressTab,
39
40
  onTabClose,
41
+ self,
40
42
  ...propsToPass
41
43
  } = props,
42
44
  styles = UiGlobals.styles,
@@ -60,6 +62,9 @@ function TabBar(props) {
60
62
  },
61
63
  setCurrentTab = (ix) => {
62
64
  if ((useLocal && ix === currentTabIxLocal) || ix === currentTabIx) {
65
+ if (onPressTab) {
66
+ onPressTab(ix); // for when an already shown tab is pressed
67
+ }
63
68
  return; // no change
64
69
  }
65
70
  if (useLocal) {
@@ -192,6 +197,20 @@ function TabBar(props) {
192
197
  tabIcon.as = Type;
193
198
  }
194
199
  }
200
+ let closeBtn;
201
+ if (onTabClose && !tab.disableCloseBox) {
202
+ closeBtn = <IconButton
203
+ key={'tabCloseButton' + ix}
204
+ onPress={() => onTabClose(ix)}
205
+ icon={Xmark}
206
+ _icon={{
207
+ color: isCurrentTab ? styles.TAB_ACTIVE_ICON_COLOR : styles.TAB_ICON_COLOR,
208
+ ...iconProps,
209
+ }}
210
+ tooltip="Close Tab"
211
+ p={0}
212
+ />;
213
+ }
195
214
  if (useIconButton) {
196
215
  button = <IconButton
197
216
  key={'tabIconButton' + ix}
@@ -209,6 +228,11 @@ function TabBar(props) {
209
228
  bg={isCurrentTab ? styles.TAB_ACTIVE_BG : styles.TAB_BG}
210
229
  tooltip={tab.title}
211
230
  />;
231
+ // button = <Row
232
+ // key={'tab' + ix}
233
+ // >
234
+ // {button}
235
+ // </Row>;
212
236
  } else {
213
237
  button = <Button
214
238
  key={'tabButton' + ix}
@@ -218,12 +242,19 @@ function TabBar(props) {
218
242
  {...iconProps}
219
243
  {...tabIcon}
220
244
  />}
245
+ // endIcon={<Icon
246
+ // color={isCurrentTab ? styles.TAB_ACTIVE_ICON_COLOR : styles.TAB_ICON_COLOR}
247
+ // {...iconProps}
248
+ // {...tabIcon}
249
+ // />}
250
+ endIcon={closeBtn}
221
251
  {...buttonProps}
222
252
  {...thisButtonProps}
223
253
  _hover={{
224
254
  bg: isCurrentTab? styles.TAB_ACTIVE_HOVER_BG : styles.TAB_HOVER_BG,
225
255
  }}
226
256
  bg={isCurrentTab ? styles.TAB_ACTIVE_BG : styles.TAB_BG}
257
+ direction="row"
227
258
  >
228
259
  <Text
229
260
  color={isCurrentTab ? styles.TAB_ACTIVE_COLOR : styles.TAB_COLOR}
@@ -234,19 +265,6 @@ function TabBar(props) {
234
265
  >{tab.title}</Text>
235
266
  </Button>;
236
267
  }
237
- if (onTabClose) {
238
- button = <Row
239
- key={'tab' + ix}
240
- >
241
- {button}
242
- <IconButton
243
- key={'tabXButton' + ix}
244
- onPress={() => onTabClose(ix)}
245
- icon={Xmark}
246
- tooltip="Close Tab"
247
- />
248
- </Row>;
249
- }
250
268
  buttons.push(button);
251
269
  });
252
270
 
@@ -367,6 +385,12 @@ function TabBar(props) {
367
385
  return null;
368
386
  }
369
387
 
388
+ if (self) {
389
+ self.getCurrentTab = getCurrentTab;
390
+ self.setCurrentTab = setCurrentTab;
391
+ self.setIsCollapsed = setIsCollapsed;
392
+ }
393
+
370
394
  const
371
395
  renderedTabs = renderTabs(),
372
396
  renderedCurrentTabContent = renderCurrentTabContent(),