@onehat/ui 0.2.37 → 0.2.38

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.2.37",
3
+ "version": "0.2.38",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -119,7 +119,7 @@ export default function Container(props) {
119
119
  }
120
120
  if (east) {
121
121
  componentProps.collapseDirection = HORIZONTAL;
122
- if (!east.props.h && !east.props.flex) {
122
+ if (!east.props.w && !east.props.flex) {
123
123
  componentProps.flex = 50;
124
124
  }
125
125
  if (canResize && east.props.isResizable) {
@@ -143,7 +143,7 @@ export default function Container(props) {
143
143
  }
144
144
  if (west) {
145
145
  componentProps.collapseDirection = HORIZONTAL;
146
- if (!west.props.h && !west.props.flex) {
146
+ if (!west.props.w && !west.props.flex) {
147
147
  componentProps.flex = 50;
148
148
  }
149
149
  if (canResize && west.props.isResizable) {
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import {
3
+ Row,
3
4
  Switch,
5
+ Text,
4
6
  } from 'native-base';
5
7
  import UiGlobals from '../../../UiGlobals.js';
6
8
  import withTooltip from '../../Hoc/withTooltip.js';
@@ -19,21 +21,24 @@ const
19
21
  setValue(!value);
20
22
  };
21
23
 
22
- return <Switch
23
- ref={props.outerRef}
24
- onToggle={onToggle}
25
- isChecked={!!value}
26
- // flex={1}
27
- bg={styles.FORM_TOGGLE_BG}
28
- size={styles.FORM_TOGGLE_SIZE}
29
- onTrackColor={styles.FORM_TOGGLE_ON_COLOR}
30
- offTrackColor={styles.FORM_TOGGLE_OFF_COLOR}
31
- _hover={{
32
- onTrackColor: styles.FORM_TOGGLE_ON_HOVER_COLOR,
33
- offTrackColor: styles.FORM_TOGGLE_OFF_HOVER_COLOR,
34
- }}
35
- {...propsToPass}
36
- />;
24
+ return <Row alignItems="center">
25
+ <Switch
26
+ ref={props.outerRef}
27
+ onToggle={onToggle}
28
+ isChecked={!!value}
29
+ // flex={1}
30
+ bg={styles.FORM_TOGGLE_BG}
31
+ size={styles.FORM_TOGGLE_SIZE}
32
+ onTrackColor={styles.FORM_TOGGLE_ON_COLOR}
33
+ offTrackColor={styles.FORM_TOGGLE_OFF_COLOR}
34
+ _hover={{
35
+ onTrackColor: styles.FORM_TOGGLE_ON_HOVER_COLOR,
36
+ offTrackColor: styles.FORM_TOGGLE_OFF_HOVER_COLOR,
37
+ }}
38
+ {...propsToPass}
39
+ />
40
+ <Text fontSize={styles.FORM_TOGGLE_FONTSIZE}>{!!value ? 'Yes' : 'No'}</Text>
41
+ </Row>;
37
42
  },
38
43
  ToggleField = withValue(ToggleElement);
39
44
 
@@ -24,6 +24,7 @@ import withEditor from '../Hoc/withEditor.js';
24
24
  import inArray from '../../Functions/inArray.js';
25
25
  import getComponentFromType from '../../Functions/getComponentFromType.js';
26
26
  import IconButton from '../Buttons/IconButton.js';
27
+ import AngleLeft from '../Icons/AngleLeft.js';
27
28
  import Rotate from '../Icons/Rotate.js';
28
29
  import Pencil from '../Icons/Pencil.js';
29
30
  import Footer from '../Panel/Footer.js';
@@ -37,7 +38,8 @@ import _ from 'lodash';
37
38
  // Form is a single scrollable row, based on columnsConfig and Repository
38
39
  //
39
40
  // EDITOR_TYPE__WINDOWED
40
- // Form is a popup window, used for editing items in a grid. Integrated with Repository
41
+ // EDITOR_TYPE__SIDE
42
+ // Form is a popup or side window, used for editing items in a grid. Integrated with Repository
41
43
  //
42
44
  // EDITOR_TYPE__SMART
43
45
  // Form is a standalone editor
@@ -56,6 +58,8 @@ function Form(props) {
56
58
  validator, // custom validator, mainly for EDITOR_TYPE__PLAIN
57
59
  footerProps = {},
58
60
  buttonGroupProps = {}, // buttons in footer
61
+ onBack,
62
+ ancillaryComponents = [],
59
63
 
60
64
  // sizing of outer container
61
65
  h,
@@ -227,7 +231,9 @@ function Form(props) {
227
231
  return <Row>{elements}</Row>;
228
232
  },
229
233
  buildFromItems = () => {
230
- return _.map(items, (item, ix) => buildNextLayer(item, ix, columnDefaults));
234
+ const
235
+ regularItems = _.map(items, (item, ix) => buildNextLayer(item, ix, columnDefaults));
236
+ return [...regularItems, ...ancillaryComponents];
231
237
  },
232
238
  buildNextLayer = (item, ix, defaults) => {
233
239
  let {
@@ -452,6 +458,16 @@ function Form(props) {
452
458
  }
453
459
 
454
460
  return <Column {...sizeProps} onLayout={onLayout}>
461
+
462
+ {onBack && <Row p={2} alignItems="center">
463
+ <Button
464
+ key="backBtn"
465
+ onPress={onBack}
466
+ leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
467
+ color="#fff"
468
+ >Back</Button>
469
+ <Text ml={2} fontSize={18}>Edit Mode</Text>
470
+ </Row>}
455
471
 
456
472
  {editor}
457
473
 
@@ -2,6 +2,7 @@ import { useState, useEffect, } from 'react';
2
2
  import {
3
3
  Column,
4
4
  Modal,
5
+ Row,
5
6
  Text,
6
7
  } from 'native-base';
7
8
  import inArray from '../../Functions/inArray.js';
@@ -11,6 +12,7 @@ import FormPanel from '../Panel/FormPanel.js';
11
12
  import Ban from '../Icons/Ban.js';
12
13
  import Gear from '../Icons/Gear.js';
13
14
  import Toolbar from '../Toolbar/Toolbar.js';
15
+ import UiGlobals from '../../UiGlobals.js';
14
16
  import _ from 'lodash';
15
17
 
16
18
  // Filters only work with Repository; not data array
@@ -20,6 +22,7 @@ export default function withFilters(WrappedComponent) {
20
22
  const {
21
23
  useFilters = false,
22
24
  searchAllText = true,
25
+ showLabels = true,
23
26
  filter1StartingField = '',
24
27
  filter2StartingField = '',
25
28
  filter3StartingField = '',
@@ -33,7 +36,8 @@ export default function withFilters(WrappedComponent) {
33
36
 
34
37
  // withData
35
38
  Repository,
36
- } = props;
39
+ } = props,
40
+ styles = UiGlobals.styles;
37
41
 
38
42
  let modal,
39
43
  topToolbar = null;
@@ -195,15 +199,22 @@ export default function withFilters(WrappedComponent) {
195
199
  if (!Element) {
196
200
  debugger;
197
201
  }
198
- filterElements.push(<Element
199
- key={ix}
202
+ let filterElement = <Element
203
+ key={'element-' + ix}
200
204
  tooltip={titles[fieldName]}
201
205
  placeholder={titles[fieldName]}
202
206
  value={getFilterValue(ix)}
203
207
  onChangeValue={(value) => onFilterChange(ix, value)}
204
208
  {...filterProps}
205
209
  {...modelProps}
206
- />);
210
+ />;
211
+ if (showLabels) {
212
+ filterElement = <Row key={'label-' + ix}>
213
+ <Text fontSize={styles.FILTER_LABEL_FONTSIZE}>{titles[fieldName]}:</Text>
214
+ {filterElement}
215
+ </Row>;
216
+ }
217
+ filterElements.push(filterElement);
207
218
  };
208
219
  if (searchAllText) {
209
220
  addFilter(null, 'q');
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useState, } from 'react';
2
2
  import Panel from './Panel.js';
3
- import Grid, { InlineGridEditor, } from '../Grid/Grid.js';
3
+ import Grid, { InlineGridEditor, SideGridEditor, } from '../Grid/Grid.js';
4
4
  import {
5
5
  EDITOR_TYPE__INLINE,
6
6
  EDITOR_TYPE__WINDOWED,
@@ -10,15 +10,27 @@ import _ from 'lodash';
10
10
 
11
11
  export function GridPanel(props) {
12
12
  const {
13
- editorType,
13
+ editorType = EDITOR_TYPE__WINDOWED,
14
14
  disableTitleChange = false,
15
15
  selectorSelected,
16
16
  } = props,
17
17
  originalTitle = props.title,
18
- WhichGrid = (editorType === EDITOR_TYPE__INLINE) ? InlineGridEditor : Grid,
19
18
  [isReady, setIsReady] = useState(disableTitleChange),
20
19
  [title, setTitle] = useState(originalTitle);
21
20
 
21
+ let WhichGrid;
22
+ switch(editorType) {
23
+ case EDITOR_TYPE__INLINE:
24
+ WhichGrid = InlineGridEditor;
25
+ break;
26
+ case EDITOR_TYPE__WINDOWED:
27
+ WhichGrid = Grid;
28
+ break;
29
+ case EDITOR_TYPE__SIDE:
30
+ WhichGrid = SideGridEditor;
31
+ break;
32
+ }
33
+
22
34
  useEffect(() => {
23
35
  if (!disableTitleChange && originalTitle) {
24
36
  let newTitle = originalTitle;
@@ -6,6 +6,7 @@ const
6
6
  FOCUS = '#ffd';
7
7
 
8
8
  const defaults = {
9
+ FILTER_LABEL_FONTSIZE: DEFAULT_FONTSIZE,
9
10
  FORM_COLOR_READOUT_FONTSIZE: DEFAULT_FONTSIZE,
10
11
  FORM_COLOR_INPUT_BG: WHITE,
11
12
  FORM_COLOR_INPUT_FOCUS_BG: FOCUS,
@@ -41,6 +42,7 @@ const defaults = {
41
42
  FORM_TEXTAREA_FONTSIZE: DEFAULT_FONTSIZE,
42
43
  FORM_TEXTAREA_HEIGHT: 130,
43
44
  FORM_TOGGLE_BG: null,
45
+ FORM_TOGGLE_FONTSIZE: DEFAULT_FONTSIZE,
44
46
  FORM_TOGGLE_SIZE: 'md',
45
47
  FORM_TOGGLE_ON_COLOR: '#0b0',
46
48
  FORM_TOGGLE_ON_HOVER_COLOR: '#090',