@onehat/ui 0.3.74 → 0.3.75

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.74",
3
+ "version": "0.3.75",
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 React, { useState, useEffect, useRef, } from 'react';
2
2
  import {
3
+ Icon,
3
4
  Modal,
4
5
  Popover,
5
6
  Pressable,
@@ -43,6 +44,7 @@ export function ComboComponent(props) {
43
44
  tooltipPlacement = 'bottom',
44
45
  placeholder,
45
46
  onRowPress,
47
+ icon,
46
48
 
47
49
  // withComponent
48
50
  self,
@@ -215,10 +217,10 @@ export function ComboComponent(props) {
215
217
  // showMenu();
216
218
  // selectNext();
217
219
  // setTimeout(() => {
218
- // if (!self.children?.dropdownGrid?.selectPrev) {
220
+ // if (!self.children?.grid?.selectPrev) {
219
221
  // debugger;
220
222
  // }
221
- // self.children.dropdownGrid.selectNext();
223
+ // self.children.grid.selectNext();
222
224
  // }, 10);
223
225
  // break;
224
226
  // case 'ArrowUp':
@@ -226,7 +228,7 @@ export function ComboComponent(props) {
226
228
  // showMenu();
227
229
  // selectPrev();
228
230
  // setTimeout(() => {
229
- // self.children.dropdownGrid.selectPrev();
231
+ // self.children.grid.selectPrev();
230
232
  // }, 10);
231
233
  // break;
232
234
  default:
@@ -285,13 +287,13 @@ export function ComboComponent(props) {
285
287
  resetTextInputValue();
286
288
  hideMenu();
287
289
  },
288
- onClearBtn = () => {
289
- setTextInputValue('');
290
+ onXButtonPress = () => {
290
291
  setValue(null);
292
+ clearGridFilters();
293
+ clearGridSelection();
291
294
  },
292
- onXBtnPress = () => {
295
+ onCheckButtonPress = () => {
293
296
  hideMenu();
294
- setValue(null);
295
297
  },
296
298
  isEventStillInComponent = (e) => {
297
299
  const {
@@ -341,6 +343,11 @@ export function ComboComponent(props) {
341
343
  setFilteredData(data);
342
344
  }
343
345
  },
346
+ clearGridSelection = () => {
347
+ if (self?.children.grid?.deselectAll) {
348
+ self?.children.grid?.deselectAll();
349
+ }
350
+ },
344
351
  searchForMatches = async (value) => {
345
352
  if (!isMenuShown) {
346
353
  showMenu();
@@ -427,13 +434,10 @@ export function ComboComponent(props) {
427
434
  return null;
428
435
  }
429
436
 
430
- if (self) {
431
- self.clear = onClearBtn;
432
- }
433
-
437
+ const inputIconElement = icon ? <Icon as={icon} color="trueGray.300" size="md" ml={2} mr={3} /> : null;
434
438
  let xButton = null,
435
439
  inputAndTrigger = null,
436
- checkBtn = null,
440
+ checkButton = null,
437
441
  grid = null,
438
442
  dropdownMenu = null,
439
443
  assembledComponents = null;
@@ -446,7 +450,7 @@ export function ComboComponent(props) {
446
450
  size: 'sm',
447
451
  }}
448
452
  isDisabled={isDisabled}
449
- onPress={onXBtnPress}
453
+ onPress={onXButtonPress}
450
454
  h="100%"
451
455
  bg={styles.FORM_COMBO_TRIGGER_BG}
452
456
  _hover={{
@@ -462,25 +466,24 @@ export function ComboComponent(props) {
462
466
  onPress={toggleMenu}
463
467
  flex={1}
464
468
  h="100%"
469
+ flexDirection="row"
470
+ borderWidth={1}
471
+ borderColor="trueGray.400"
472
+ borderTopRightRadius={0}
473
+ borderBottomRightRadius={0}
474
+ bg={styles.FORM_COMBO_INPUT_BG}
475
+ m={0}
476
+ p={2}
465
477
  >
478
+ {inputIconElement}
466
479
  <Text
467
480
  ref={inputRef}
468
481
  flex={1}
469
482
  h="100%"
470
483
  numberOfLines={1}
471
484
  ellipsizeMode="head"
472
- m={0}
473
- p={2}
474
- borderWidth={1}
475
- borderColor="trueGray.400"
476
- borderTopRightRadius={0}
477
- borderBottomRightRadius={0}
478
485
  fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
479
486
  color={_.isEmpty(textInputValue) ? 'trueGray.400' : '#000'}
480
- bg={styles.FORM_COMBO_INPUT_BG}
481
- _focus={{
482
- bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
483
- }}
484
487
  >{_.isEmpty(textInputValue) ? placeholder : textInputValue}</Text>
485
488
  </Pressable> :
486
489
  <Input
@@ -496,6 +499,7 @@ export function ComboComponent(props) {
496
499
  flex={1}
497
500
  h="100%"
498
501
  m={0}
502
+ InputLeftElement={inputIconElement}
499
503
  autoSubmitDelay={0}
500
504
  borderTopRightRadius={0}
501
505
  borderBottomRightRadius={0}
@@ -539,24 +543,23 @@ export function ComboComponent(props) {
539
543
  <Pressable
540
544
  onPress={showMenu}
541
545
  flex={1}
546
+ flexDirection="row"
547
+ borderWidth={1}
548
+ borderColor="trueGray.400"
549
+ borderTopRightRadius={0}
550
+ borderBottomRightRadius={0}
551
+ bg={styles.FORM_COMBO_INPUT_BG}
552
+ m={0}
553
+ p={2}
542
554
  >
555
+ {inputIconElement}
543
556
  <Text
544
557
  flex={1}
545
558
  h="100%"
546
559
  numberOfLines={1}
547
560
  ellipsizeMode="head"
548
- m={0}
549
- p={2}
550
- borderWidth={1}
551
- borderColor="trueGray.400"
552
- borderTopRightRadius={0}
553
- borderBottomRightRadius={0}
554
561
  color={_.isEmpty(displayValue) ? 'trueGray.400' : '#000'}
555
562
  fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
556
- bg={styles.FORM_COMBO_INPUT_BG}
557
- _focus={{
558
- bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
559
- }}
560
563
  >{_.isEmpty(displayValue) ? placeholder : displayValue}</Text>
561
564
  </Pressable>
562
565
  <IconButton
@@ -614,7 +617,7 @@ export function ComboComponent(props) {
614
617
  autoAdjustPageSizeToHeight={false}
615
618
  {...gridProps}
616
619
  data={filteredData}
617
- reference="dropdownGrid"
620
+ reference="grid"
618
621
  parent={self}
619
622
  h={UiGlobals.mode === UI_MODE_WEB ? styles.FORM_COMBO_MENU_HEIGHT + 'px' : null}
620
623
  newEntityDisplayValue={newEntityDisplayValue}
@@ -737,13 +740,14 @@ export function ComboComponent(props) {
737
740
  if (UiGlobals.mode === UI_MODE_REACT_NATIVE) {
738
741
  if (isEditor) {
739
742
  // in RN, an editor has no way to accept the selection of the grid, so we need to add a check button to do this
740
- checkBtn = <IconButton
743
+ checkButton = <IconButton
741
744
  _icon={{
742
745
  as: Check,
743
746
  color: 'trueGray.600',
744
747
  size: 'sm',
745
748
  }}
746
- onPress={onXBtnPress}
749
+ onPress={onCheckButtonPress}
750
+ isDisabled={!value}
747
751
  h="100%"
748
752
  borderWidth={1}
749
753
  borderColor="#bbb"
@@ -789,6 +793,7 @@ export function ComboComponent(props) {
789
793
  flex={1}
790
794
  h="100%"
791
795
  m={0}
796
+ InputLeftElement={inputIconElement}
792
797
  autoSubmitDelay={0}
793
798
  borderTopRightRadius={0}
794
799
  borderBottomRightRadius={0}
@@ -819,7 +824,7 @@ export function ComboComponent(props) {
819
824
  bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
820
825
  }}
821
826
  />
822
- {checkBtn}
827
+ {checkButton}
823
828
  </Row>;
824
829
  dropdownMenu = <Modal
825
830
  isOpen={true}
@@ -17,6 +17,7 @@ function InputElement(props) {
17
17
  setValue,
18
18
  autoSubmit = true, // automatically setValue after user stops typing for autoSubmitDelay
19
19
  autoSubmitDelay = AUTO_SUBMIT_DELAY,
20
+ autoCapitalize = 'none',
20
21
  maxLength,
21
22
  onKeyPress,
22
23
  onChangeText,
@@ -82,6 +83,7 @@ function InputElement(props) {
82
83
  _focus={{
83
84
  bg: styles.FORM_INPUT_FOCUS_BG,
84
85
  }}
86
+ autoCapitalize={autoCapitalize}
85
87
  {...sizeProps}
86
88
  {...props}
87
89
  value={localValue}
@@ -393,7 +393,11 @@ function Form(props) {
393
393
  if (defaults?.labelWidth) {
394
394
  labelProps.w = defaults.labelWidth;
395
395
  }
396
- element = <><Label {...labelProps}>{label}</Label>{element}</>;
396
+ if (containerWidth > 400) {
397
+ element = <><Label {...labelProps}>{label}</Label>{element}</>;
398
+ } else {
399
+ element = <Column><Label {...labelProps}>{label}</Label>{element}</Column>;
400
+ }
397
401
  }
398
402
  return <Row key={ix} px={2} pb={1}>{element}</Row>;
399
403
  }
@@ -504,10 +508,17 @@ function Form(props) {
504
508
  if (defaults?.labelWidth) {
505
509
  labelProps.w = defaults.labelWidth;
506
510
  }
507
- element = <Row w="100%" py={1}>
508
- <Label {...labelProps}>{requiredIndicator}{label}</Label>
509
- {element}
510
- </Row>;
511
+ if (containerWidth > 400) {
512
+ element = <Row w="100%" py={1}>
513
+ <Label {...labelProps}>{requiredIndicator}{label}</Label>
514
+ {element}
515
+ </Row>;
516
+ } else {
517
+ element = <Column w="100%" py={1} mt={3}>
518
+ <Label {...labelProps}>{requiredIndicator}{label}</Label>
519
+ {element}
520
+ </Column>;
521
+ }
511
522
  } else if (disableLabels && requiredIndicator) {
512
523
  element = <Row w="100%" py={1}>
513
524
  {requiredIndicator}
@@ -761,7 +772,7 @@ function Form(props) {
761
772
  }
762
773
  }
763
774
 
764
- return <Column {...sizeProps} pb={10} onLayout={onLayoutDecorated} ref={formRef}>
775
+ return <Column {...sizeProps} onLayout={onLayoutDecorated} ref={formRef}>
765
776
  {!!containerWidth && <>
766
777
  {editorType === EDITOR_TYPE__INLINE &&
767
778
  <ScrollView
@@ -0,0 +1,20 @@
1
+ // Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
2
+ import * as React from "react"
3
+ import Svg, { Path } from "react-native-svg"
4
+ import { Icon } from 'native-base';
5
+
6
+ function SvgComponent(props) {
7
+ return (
8
+ <Icon
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ viewBox="0 0 384 512"
11
+ {...props}
12
+ >
13
+ <Path
14
+ d="M192 0c-41.8 0-77.4 26.7-90.5 64H64C28.7 64 0 92.7 0 128v320c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V128c0-35.3-28.7-64-64-64h-37.5C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 110 64 32 32 0 110-64zM72 272a24 24 0 1148 0 24 24 0 11-48 0zm104-16h128c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16s7.2-16 16-16zM72 368a24 24 0 1148 0 24 24 0 11-48 0zm88 0c0-8.8 7.2-16 16-16h128c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16z"
15
+ />
16
+ </Icon>
17
+ )
18
+ }
19
+
20
+ export default SvgComponent
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  Row,
3
3
  Spinner,
4
+ Text,
4
5
  } from 'native-base';
5
6
  import ScreenContainer from '../Container/ScreenContainer.js';
6
7
 
7
8
  export default function Loading(props) {
8
9
  if (props.isScreen) {
9
10
  return <ScreenContainer {...props}>
10
- <Spinner flex={1} color="primary.500" />
11
+ <Row flex={1} justifyContent="center" alignItems="center">
12
+ <Spinner color="primary.500" mr={2} />
13
+ <Text>Loading</Text>
14
+ </Row>
11
15
  </ScreenContainer>;
12
16
  }
13
17
  return <Row justifyContent="center" minHeight={100} {...props}>