@onehat/ui 0.3.47 → 0.3.49

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.47",
3
+ "version": "0.3.49",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -515,7 +515,6 @@ export function ComboComponent(props) {
515
515
  w: '100%',
516
516
  };
517
517
  }}
518
- allowToggleSelection={true}
519
518
  autoAdjustPageSizeToHeight={false}
520
519
  {...props}
521
520
  h={styles.FORM_COMBO_MENU_HEIGHT + 'px'}
@@ -37,6 +37,7 @@ export function DateElement(props) {
37
37
  mode = DATE,
38
38
  tooltip = 'Choose a date.',
39
39
  tooltipPlacement = 'bottom',
40
+ isDisabled = false,
40
41
  } = props,
41
42
  styles = UiGlobals.styles,
42
43
  Datetime = getComponentFromType('Datetime'),
@@ -235,6 +236,7 @@ export function DateElement(props) {
235
236
  onBlur={onTriggerBlur}
236
237
  h={10}
237
238
  w={10}
239
+ isDisabled={isDisabled}
238
240
  borderTopLeftRadius={6}
239
241
  borderBottomLeftRadius={6}
240
242
  borderTopRightRadius={0}
@@ -266,6 +268,7 @@ export function DateElement(props) {
266
268
  _focus={{
267
269
  bg: styles.FORM_DATE_INPUT_FOCUS_BG,
268
270
  }}
271
+ isDisabled={isDisabled}
269
272
  numberOfLines={1}
270
273
  ellipsizeMode="head"
271
274
  onLayout={(e) => {
@@ -26,6 +26,7 @@ function NumberElement(props) {
26
26
  minValue,
27
27
  maxValue,
28
28
  tooltip = null,
29
+ isDisabled = false,
29
30
  } = props,
30
31
  styles = UiGlobals.styles,
31
32
  debouncedSetValueRef = useRef(),
@@ -122,9 +123,9 @@ function NumberElement(props) {
122
123
 
123
124
  return <Row flex={1} h="100%" p={0} borderWidth={1} borderColor="trueGray.400" borderRadius={6} {...props}>
124
125
  <IconButton
125
- icon={<Icon as={Minus} color={isDecrementDisabled ? 'disabled' : 'trueGray.500'} />}
126
+ icon={<Icon as={Minus} color={(isDecrementDisabled || isDisabled) ? 'disabled' : 'trueGray.500'} />}
126
127
  onPress={onDecrement}
127
- isDisabled={isDecrementDisabled}
128
+ isDisabled={isDecrementDisabled || isDisabled}
128
129
  h="100%"
129
130
  flex={1}
130
131
  maxWidth={10}
@@ -148,12 +149,13 @@ function NumberElement(props) {
148
149
  textAlign="center"
149
150
  borderRadius={0}
150
151
  tooltip={tooltip}
152
+ isDisabled={isDisabled}
151
153
  {...props._input}
152
154
  />
153
155
  <IconButton
154
- icon={<Icon as={Plus} color={isIncrementDisabled ? 'disabled' : 'trueGray.500'} />}
156
+ icon={<Icon as={Plus} color={(isIncrementDisabled || isDisabled) ? 'disabled' : 'trueGray.500'} />}
155
157
  onPress={onIncrement}
156
- isDisabled={isIncrementDisabled}
158
+ isDisabled={isIncrementDisabled || isDisabled}
157
159
  h="100%"
158
160
  flex={1}
159
161
  maxWidth={10}
@@ -76,6 +76,7 @@ function Form(props) {
76
76
  onViewMode,
77
77
  submitBtnLabel,
78
78
  onSubmit,
79
+ formSetup, // this fn will be executed after the form setup is complete
79
80
  additionalEditButtons,
80
81
  useAdditionalEditButtons = true,
81
82
  additionalFooterButtons,
@@ -286,10 +287,14 @@ function Form(props) {
286
287
  items,
287
288
  onChange: onEditorChange,
288
289
  useSelectorId = false,
290
+ isHidden = false,
289
291
  ...propsToPass
290
292
  } = item,
291
293
  editorTypeProps = {};
292
294
 
295
+ if (isHidden) {
296
+ return null;
297
+ }
293
298
  const propertyDef = name && Repository?.getSchema().getPropertyDefinition(name);
294
299
  if (!useAdditionalEditButtons) {
295
300
  item = _.omit(item, 'additionalEditButtons');
@@ -449,9 +454,13 @@ function Form(props) {
449
454
  />;
450
455
  if (error) {
451
456
  if (editorType !== EDITOR_TYPE__INLINE) {
457
+ let message = error.message;
458
+ if (label) {
459
+ message = message.replace(error.ref.name, label);
460
+ }
452
461
  element = <Column pt={1} flex={1}>
453
462
  {element}
454
- <Text color="#f00">{error.message}</Text>
463
+ <Text color="#f00">{message}</Text>
455
464
  </Column>;
456
465
  } else {
457
466
  debugger;
@@ -554,6 +563,9 @@ function Form(props) {
554
563
  setPreviousRecord(record);
555
564
  reset(defaultValues);
556
565
  }
566
+ if (formSetup) {
567
+ formSetup(formSetValue, formGetValues, formState)
568
+ }
557
569
  }, [record]);
558
570
 
559
571
  useEffect(() => {
@@ -203,8 +203,7 @@ function GridComponent(props) {
203
203
  let newSelection = selection;
204
204
  if (isInSelection(item)) {
205
205
  // Already selected
206
- const isSingle = selection.length === 1;
207
- if (allowToggle || isSingle) {
206
+ if (allowToggle) {
208
207
  // Create empty selection
209
208
  newSelection = [];
210
209
  } else {