@onehat/ui 0.3.121 → 0.3.123

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.121",
3
+ "version": "0.3.123",
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,
@@ -455,6 +481,22 @@ export function ComboComponent(props) {
455
481
  }}
456
482
  />;
457
483
  }
484
+ if (showEyeButton && !_.isNil(value)) {
485
+ eyeButton = <IconButton
486
+ _icon={{
487
+ as: Eye,
488
+ color: 'trueGray.600',
489
+ size: 'sm',
490
+ }}
491
+ isDisabled={isDisabled}
492
+ onPress={onEyeButtonPress}
493
+ h="100%"
494
+ bg={styles.FORM_COMBO_TRIGGER_BG}
495
+ _hover={{
496
+ bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
497
+ }}
498
+ />;
499
+ }
458
500
 
459
501
  if (UiGlobals.mode === UI_MODE_WEB) {
460
502
  inputAndTrigger = <>
@@ -760,6 +802,7 @@ export function ComboComponent(props) {
760
802
  const inputAndTriggerClone = // for RN, this is the actual input and trigger, as we need them to appear up above in the modal
761
803
  <Row h={10}>
762
804
  {xButton}
805
+ {eyeButton}
763
806
  {disableDirectEntry ?
764
807
  <Text
765
808
  ref={inputRef}
@@ -847,6 +890,7 @@ export function ComboComponent(props) {
847
890
  }
848
891
  assembledComponents = <Row {...refProps} justifyContent="center" alignItems="center" h={styles.FORM_COMBO_HEIGHT} flex={1} onLayout={() => setIsRendered(true)}>
849
892
  {xButton}
893
+ {eyeButton}
850
894
  {inputAndTrigger}
851
895
  {additionalButtons}
852
896
  {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;
@@ -340,11 +340,18 @@ export default function withFilters(WrappedComponent) {
340
340
  }
341
341
 
342
342
  if (isUsingCustomFilters) {
343
- _.each(filtersToUse, (filter) => {
344
- const repoFiltersFromFilter = filter.getRepoFilters(filter.value);
345
- _.each(repoFiltersFromFilter, (repoFilter) => { // one custom filter might generate multiple filters for the repository
346
- newRepoFilters.push(repoFilter);
347
- });
343
+ _.each(filtersToUse, ({ field, value, getRepoFilters }) => {
344
+ if (getRepoFilters) {
345
+ let repoFiltersFromFilter = getRepoFilters(value) || [];
346
+ if (!_.isArray(repoFiltersFromFilter)) {
347
+ repoFiltersFromFilter = [repoFiltersFromFilter];
348
+ }
349
+ _.each(repoFiltersFromFilter, (repoFilter) => { // one custom filter might generate multiple filters for the repository
350
+ newRepoFilters.push(repoFilter);
351
+ });
352
+ } else {
353
+ newRepoFilters.push({ name: field, value, });
354
+ }
348
355
  });
349
356
  } else {
350
357
  const newFilterNames = [];