@onehat/ui 0.3.122 → 0.3.124

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.122",
3
+ "version": "0.3.124",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -24,6 +24,7 @@ import IconButton from '../../../Buttons/IconButton.js';
24
24
  import CaretDown from '../../../Icons/CaretDown.js';
25
25
  import Check from '../../../Icons/Check.js';
26
26
  import Xmark from '../../../Icons/Xmark.js';
27
+ import Eye from '../../../Icons/Eye.js';
27
28
  import _ from 'lodash';
28
29
 
29
30
  const FILTER_NAME = 'q';
@@ -38,6 +39,7 @@ export function ComboComponent(props) {
38
39
  disableDirectEntry = false,
39
40
  hideMenuOnSelection = true,
40
41
  showXButton = false,
42
+ showEyeButton = false,
41
43
  _input = {},
42
44
  isEditor = false,
43
45
  isDisabled = false,
@@ -69,6 +71,8 @@ export function ComboComponent(props) {
69
71
  displayValueRef = useRef(),
70
72
  typingTimeout = useRef(),
71
73
  [isMenuShown, setIsMenuShown] = useState(false),
74
+ [isViewerShown, setIsViewerShown] = useState(false),
75
+ [viewerSelection, setViewerSelection] = useState([]),
72
76
  [isRendered, setIsRendered] = useState(false),
73
77
  [isReady, setIsReady] = useState(false),
74
78
  [isSearchMode, setIsSearchMode] = useState(false),
@@ -292,6 +296,27 @@ export function ComboComponent(props) {
292
296
  clearGridFilters();
293
297
  clearGridSelection();
294
298
  },
299
+ onEyeButtonPress = async () => {
300
+ const id = value;
301
+ if (!Repository.isLoaded) {
302
+ await Repository.load();
303
+ }
304
+ if (Repository.isLoading) {
305
+ await Repository.waitUntilDoneLoading();
306
+ }
307
+ let record = Repository.getById(id); // first try to get from entities in memory
308
+ if (!record && Repository.getSingleEntityFromServer) {
309
+ record = await Repository.getSingleEntityFromServer(id);
310
+ }
311
+
312
+ if (!record) {
313
+ alert('Record could not be found!');
314
+ return;
315
+ }
316
+
317
+ setViewerSelection([record]);
318
+ setIsViewerShown(true);
319
+ },
295
320
  onCheckButtonPress = () => {
296
321
  hideMenu();
297
322
  },
@@ -433,6 +458,7 @@ export function ComboComponent(props) {
433
458
 
434
459
  const inputIconElement = icon ? <Icon as={icon} color="trueGray.300" size="md" ml={2} mr={3} /> : null;
435
460
  let xButton = null,
461
+ eyeButton = null,
436
462
  inputAndTrigger = null,
437
463
  checkButton = null,
438
464
  grid = null,
@@ -453,6 +479,24 @@ export function ComboComponent(props) {
453
479
  _hover={{
454
480
  bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
455
481
  }}
482
+ mr={1}
483
+ />;
484
+ }
485
+ if (showEyeButton && !_.isNil(value)) {
486
+ eyeButton = <IconButton
487
+ _icon={{
488
+ as: Eye,
489
+ color: 'trueGray.600',
490
+ size: 'sm',
491
+ }}
492
+ isDisabled={isDisabled}
493
+ onPress={onEyeButtonPress}
494
+ h="100%"
495
+ bg={styles.FORM_COMBO_TRIGGER_BG}
496
+ _hover={{
497
+ bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
498
+ }}
499
+ mr={1}
456
500
  />;
457
501
  }
458
502
 
@@ -760,6 +804,7 @@ export function ComboComponent(props) {
760
804
  const inputAndTriggerClone = // for RN, this is the actual input and trigger, as we need them to appear up above in the modal
761
805
  <Row h={10}>
762
806
  {xButton}
807
+ {eyeButton}
763
808
  {disableDirectEntry ?
764
809
  <Text
765
810
  ref={inputRef}
@@ -847,6 +892,7 @@ export function ComboComponent(props) {
847
892
  }
848
893
  assembledComponents = <Row {...refProps} justifyContent="center" alignItems="center" h={styles.FORM_COMBO_HEIGHT} flex={1} onLayout={() => setIsRendered(true)}>
849
894
  {xButton}
895
+ {eyeButton}
850
896
  {inputAndTrigger}
851
897
  {additionalButtons}
852
898
  {dropdownMenu}
@@ -42,7 +42,7 @@ function TagComponent(props) {
42
42
  } = props,
43
43
  ignoreNextComboValueChangeRef = useRef(false),
44
44
  [isViewerShown, setIsViewerShown] = useState(false),
45
- [viewerSelection, setViewerSelection] = useState(false),
45
+ [viewerSelection, setViewerSelection] = useState([]),
46
46
  getIgnoreNextComboValueChange = () => {
47
47
  return ignoreNextComboValueChangeRef.current;
48
48
  },
@@ -345,8 +345,11 @@ function Form(props) {
345
345
  editorTypeProps.autoLoad = true;
346
346
  }
347
347
  }
348
- if (isCombo && _.isNil(propsToPass.showXButton)) {
349
- editorTypeProps.showXButton = true;
348
+ if (isCombo) {
349
+ editorTypeProps.showEyeButton = true;
350
+ if (_.isNil(propsToPass.showXButton)) {
351
+ editorTypeProps.showXButton = true;
352
+ }
350
353
  }
351
354
  const Element = getComponentFromType(type);
352
355
  let children;
@@ -342,7 +342,10 @@ export default function withFilters(WrappedComponent) {
342
342
  if (isUsingCustomFilters) {
343
343
  _.each(filtersToUse, ({ field, value, getRepoFilters }) => {
344
344
  if (getRepoFilters) {
345
- const repoFiltersFromFilter = getRepoFilters(value);
345
+ let repoFiltersFromFilter = getRepoFilters(value) || [];
346
+ if (!_.isArray(repoFiltersFromFilter)) {
347
+ repoFiltersFromFilter = [repoFiltersFromFilter];
348
+ }
346
349
  _.each(repoFiltersFromFilter, (repoFilter) => { // one custom filter might generate multiple filters for the repository
347
350
  newRepoFilters.push(repoFilter);
348
351
  });