@onehat/ui 0.4.13 → 0.4.15

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.
Files changed (31) hide show
  1. package/package.json +1 -1
  2. package/src/Components/Buttons/IconButton.js +3 -6
  3. package/src/Components/Editor/InlineEditor.js +2 -2
  4. package/src/Components/Form/Field/Color.js +24 -7
  5. package/src/Components/Form/Field/Combo/Combo.js +14 -27
  6. package/src/Components/Form/Field/Date.js +29 -30
  7. package/src/Components/Form/Field/FormikForm.js +2 -2
  8. package/src/Components/Form/Field/Input.js +3 -7
  9. package/src/Components/Form/Field/Number.js +0 -4
  10. package/src/Components/Form/Field/Select/Select.js +1 -4
  11. package/src/Components/Form/Field/Tag/Tag.js +4 -4
  12. package/src/Components/Form/Field/Tag/ValueBox.js +13 -3
  13. package/src/Components/Form/Field/Text.js +1 -1
  14. package/src/Components/Form/Field/TextArea.js +1 -6
  15. package/src/Components/Form/Field/Toggle.js +1 -1
  16. package/src/Components/Form/FieldSet.js +10 -20
  17. package/src/Components/Form/Form.js +22 -9
  18. package/src/Components/Form/Label.js +2 -1
  19. package/src/Components/Grid/Grid.js +12 -5
  20. package/src/Components/Grid/GridHeaderRow.js +5 -7
  21. package/src/Components/Grid/GridRow.js +9 -7
  22. package/src/Components/Hoc/withContextMenu.js +7 -9
  23. package/src/Components/Hoc/withFilters.js +1 -1
  24. package/src/Components/Layout/Footer.js +1 -1
  25. package/src/Components/Panel/Header.js +6 -10
  26. package/src/Components/Tab/TabBar.js +3 -3
  27. package/src/Components/Toolbar/Toolbar.js +1 -1
  28. package/src/Components/Tree/TreeNode.js +3 -5
  29. package/src/Components/Viewer/Viewer.js +17 -7
  30. package/src/Constants/Styles.js +62 -76
  31. package/src/PlatformImports/Web/File.js +1 -2
@@ -646,7 +646,7 @@ function Form(props) {
646
646
  }
647
647
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
648
648
  if (!style.width) {
649
- style.width = '100px';
649
+ style.width = '120px';
650
650
  }
651
651
  element = <HStack className="Form-HStack1 w-full py-1">
652
652
  <Label style={style}>{label}</Label>
@@ -812,7 +812,15 @@ function Form(props) {
812
812
  isRequired = true;
813
813
  }
814
814
  if (isRequired) {
815
- requiredIndicator = <Text className="text-[#f00] text-[30px] pr-1">*</Text>;
815
+ requiredIndicator = <Text
816
+ className={`
817
+ Form-requiredIndicator
818
+ self-center
819
+ text-[#f00]
820
+ text-[30px]
821
+ pr-1
822
+ `}
823
+ >*</Text>;
816
824
  }
817
825
  }
818
826
  if (!disableLabels && label && editorType !== EDITOR_TYPE__INLINE) {
@@ -822,15 +830,21 @@ function Form(props) {
822
830
  }
823
831
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
824
832
  if (!style.width) {
825
- style.width = '100px';
833
+ style.width = '120px';
826
834
  }
827
835
  element = <HStack className="Form-HStack8 w-full">
828
- <Label style={style}>{requiredIndicator}{label}</Label>
836
+ <Label style={style}>
837
+ {requiredIndicator}
838
+ {label}
839
+ </Label>
829
840
  {element}
830
841
  </HStack>;
831
842
  } else {
832
843
  element = <VStack className="Form-VStack9 w-full mt-3">
833
- <Label style={style}>{requiredIndicator}{label}</Label>
844
+ <Label style={style}>
845
+ {requiredIndicator}
846
+ {label}
847
+ </Label>
834
848
  {element}
835
849
  </VStack>;
836
850
  }
@@ -907,7 +921,7 @@ function Form(props) {
907
921
  className={`
908
922
  Form-Ancillary-Title
909
923
  font-bold
910
- ${styles.FORM_ANCILLARY_TITLE_FONTSIZE}
924
+ ${styles.FORM_ANCILLARY_TITLE_CLASSNAME}
911
925
  `}
912
926
  >{title}</Text>;
913
927
  }
@@ -916,7 +930,7 @@ function Form(props) {
916
930
  className={`
917
931
  Form-Ancillary-Description
918
932
  italic
919
- ${styles.FORM_ANCILLARY_DESCRIPTION_FONTSIZE}
933
+ ${styles.FORM_ANCILLARY_DESCRIPTION_CLASSNAME}
920
934
  `}
921
935
  >{description}</Text>;
922
936
  }
@@ -1280,8 +1294,7 @@ function Form(props) {
1280
1294
  justify-center
1281
1295
  items-center
1282
1296
  rounded-b-lg
1283
- bg-red-500
1284
- ${styles.GRID_INLINE_EDITOR_BG}
1297
+ bg-primary-700
1285
1298
  `}
1286
1299
  >{footerButtons}</HStack>
1287
1300
  </Box>;
@@ -16,8 +16,9 @@ export default function Label(props) {
16
16
  }
17
17
  let textClassName = `
18
18
  Label-TextNative
19
+ flex
19
20
  text-ellipsis
20
- ${styles.FORM_LABEL_FONTSIZE}
21
+ ${styles.FORM_LABEL_CLASSNAME}
21
22
  `;
22
23
  if (props._text?.className) {
23
24
  textClassName += ' ' + props._text.className;
@@ -489,7 +489,7 @@ function GridComponent(props) {
489
489
  showColumnsSelector={showColumnsSelector}
490
490
  />;
491
491
  if (showRowExpander) {
492
- // align the header row to content rows
492
+ // align the header row to content rows by adding a spacer that matches the width of the Grid-rowExpander-expandBtn
493
493
  headerRow = <HStack className="">
494
494
  <Box className="w-[40px]"></Box>
495
495
  {headerRow}
@@ -602,7 +602,10 @@ function GridComponent(props) {
602
602
  _icon={{
603
603
  size: 'sm',
604
604
  }}
605
- className="Grid-rowExpander-expandBtn py-0"
605
+ className={`
606
+ Grid-rowExpander-expandBtn
607
+ ${styles.GRID_EXPAND_BTN_CLASSNAME}
608
+ `}
606
609
  tooltip="Expand/Contract Row"
607
610
  />
608
611
  {rowComponent}
@@ -943,7 +946,8 @@ function GridComponent(props) {
943
946
  // second call -- do other necessary setup
944
947
 
945
948
 
946
- let localColumnsConfig = [],
949
+ let columnsConfigVariable = columnsConfig,
950
+ localColumnsConfig = [],
947
951
  savedLocalColumnsConfig,
948
952
  calculateLocalColumnsConfig = false;
949
953
  if (localColumnsConfigKey && !UiGlobals.disableSavedColumnsConfig) {
@@ -954,7 +958,10 @@ function GridComponent(props) {
954
958
  calculateLocalColumnsConfig = true;
955
959
  }
956
960
  if (calculateLocalColumnsConfig) {
957
- if (_.isEmpty(columnsConfig)) {
961
+ if (_.isFunction(columnsConfigVariable)) {
962
+ columnsConfigVariable = columnsConfigVariable();
963
+ }
964
+ if (_.isEmpty(columnsConfigVariable)) {
958
965
  if (Repository) {
959
966
  // create a column for the displayProperty
960
967
  localColumnsConfig.push({
@@ -966,7 +973,7 @@ function GridComponent(props) {
966
973
  });
967
974
  }
968
975
  } else {
969
- _.each(columnsConfig, (columnConfig) => {
976
+ _.each(columnsConfigVariable, (columnConfig) => {
970
977
  if (!_.isPlainObject(columnConfig)) {
971
978
  localColumnsConfig.push(columnConfig);
972
979
  return;
@@ -363,8 +363,7 @@ export default function GridHeaderRow(props) {
363
363
  items-center
364
364
  justify-center
365
365
  ${rowClassName}
366
- ${styles.GRID_HEADER_BG}
367
- ${styles.GRID_HEADER_BG_HOVER}
366
+ ${styles.GRID_HEADER_PRESSABLE_CLASSNAME}
368
367
  `}
369
368
  style={rowStyle}
370
369
  >
@@ -404,9 +403,9 @@ export default function GridHeaderRow(props) {
404
403
  text-center
405
404
  overflow-hidden
406
405
  text-ellipsis
407
- ${styles.GRID_HEADER_FONTSIZE}
408
- ${styles.GRID_HEADER_CELL_PX}
409
- ${styles.GRID_HEADER_CELL_PY}
406
+ px-2
407
+ py-3
408
+ ${styles.GRID_HEADER_CLASSNAME}
410
409
  `}
411
410
  >{header}</TextNative>
412
411
 
@@ -419,8 +418,7 @@ export default function GridHeaderRow(props) {
419
418
  GridHeaderRow-Icon
420
419
  text-center
421
420
  text-grey-500
422
- ${styles.GRID_HEADER_ICON_MT}
423
- ${styles.GRID_HEADER_ICON_MR}
421
+ ${styles.GRID_HEADER_ICON_CLASSNAME}
424
422
  `} />}
425
423
 
426
424
  {isOver && UiGlobals.mode === UI_MODE_WEB && // only works for web for now
@@ -90,7 +90,6 @@ function GridRow(props) {
90
90
  p-1
91
91
  justify-center
92
92
  border-r-black-100
93
- mr-1
94
93
  `;
95
94
  if (isOnlyOneVisibleColumn) {
96
95
  colClassName = ' w-full';
@@ -180,10 +179,10 @@ function GridRow(props) {
180
179
  GridRow-Element
181
180
  self-center
182
181
  text-ellipsis
182
+ px-2
183
+ py-3
183
184
  ${colClassName}
184
- ${styles.GRID_CELL_FONTSIZE}
185
- ${styles.GRID_CELL_PX}
186
- ${styles.GRID_CELL_PY}
185
+ ${styles.GRID_CELL_CLASSNAME}
187
186
  `}
188
187
  numberOfLines={1}
189
188
  ellipsizeMode="head"
@@ -228,8 +227,11 @@ function GridRow(props) {
228
227
  self-center
229
228
  overflow-hidden
230
229
  text-ellipsis
230
+ truncate
231
+ whitespace-nowrap
232
+ overflow-hidden
231
233
  ${colClassName}
232
- ${styles.GRID_CELL_FONTSIZE}
234
+ ${styles.GRID_CELL_CLASSNAME}
233
235
  ${styles.GRID_CELL_PX}
234
236
  ${styles.GRID_CELL_PY}
235
237
  `}
@@ -278,7 +280,7 @@ function GridRow(props) {
278
280
  rowContents = <HStack
279
281
  ref={dragSourceRef}
280
282
  className={`
281
- dragSourceRef
283
+ GridRow-dragSourceRef
282
284
  w-full
283
285
  flex-1
284
286
  grow-1
@@ -292,7 +294,7 @@ function GridRow(props) {
292
294
  rowContents = <HStack
293
295
  ref={dropTargetRef}
294
296
  className={`
295
- dropTargetRef
297
+ GridRow-dropTargetRef
296
298
  w-full
297
299
  flex-1
298
300
  grow-1
@@ -3,14 +3,11 @@ import {
3
3
  Text,
4
4
  VStack,
5
5
  } from '@project-components/Gluestack';
6
+ import UiGlobals from '../../UiGlobals.js';
6
7
  import Button from '../Buttons/Button.js';
7
8
  import testProps from '../../Functions/testProps.js';
8
9
  import _ from 'lodash';
9
10
 
10
- const
11
- CONTEXT_MENU_WIDTH = 180,
12
- CONTEXT_MENU_ITEM_HEIGHT = 30;
13
-
14
11
  export default function withContextMenu(WrappedComponent) {
15
12
  return forwardRef((props, ref) => {
16
13
  const {
@@ -30,6 +27,7 @@ export default function withContextMenu(WrappedComponent) {
30
27
  isModalShown,
31
28
  whichModal,
32
29
  } = props,
30
+ styles = UiGlobals.styles,
33
31
  [doShowContextMenu, setDoShowContextMenu] = useState(false),
34
32
  [left, setLeft] = useState(0),
35
33
  [top, setTop] = useState(0),
@@ -133,16 +131,16 @@ export default function withContextMenu(WrappedComponent) {
133
131
  screenHeight = window.innerHeight;
134
132
  let l = left,
135
133
  t = top;
136
- if (screenWidth - CONTEXT_MENU_WIDTH < l) {
137
- l = screenWidth - CONTEXT_MENU_WIDTH;
134
+ if (screenWidth - styles.CONTEXT_MENU_WIDTH < l) {
135
+ l = screenWidth - styles.CONTEXT_MENU_WIDTH;
138
136
  }
139
- if (screenHeight - (contextMenuItemComponents.length * CONTEXT_MENU_ITEM_HEIGHT) < t) {
140
- t = screenHeight - (contextMenuItemComponents.length * CONTEXT_MENU_ITEM_HEIGHT);
137
+ if (screenHeight - (contextMenuItemComponents.length * styles.CONTEXT_MENU_ITEM_HEIGHT) < t) {
138
+ t = screenHeight - (contextMenuItemComponents.length * styles.CONTEXT_MENU_ITEM_HEIGHT);
141
139
  }
142
140
  const style = {
143
141
  left: l,
144
142
  top: t,
145
- width: CONTEXT_MENU_WIDTH,
143
+ width: styles.CONTEXT_MENU_WIDTH,
146
144
  };
147
145
 
148
146
  showModal({
@@ -313,7 +313,7 @@ export default function withFilters(WrappedComponent) {
313
313
  <Label
314
314
  className="min-w-0 mr-1"
315
315
  _text={{
316
- className: UiGlobals.styles.FILTER_LABEL_FONTSIZE,
316
+ className: UiGlobals.styles.FILTER_LABEL_CLASSNAME,
317
317
  }}
318
318
  >{title}</Label>
319
319
  {filterElement}
@@ -13,7 +13,7 @@ export default function Footer(props) {
13
13
  self-end
14
14
  p-2
15
15
  border-t-2
16
- ${styles.PANEL_FOOTER_BORDER_TOP_COLOR}
16
+ ${styles.PANEL_FOOTER_CLASSNAME}
17
17
  `;
18
18
  if (props.className) {
19
19
  className += ' ' + props.className
@@ -55,7 +55,7 @@ export default function Header(props) {
55
55
  icon={Xmark}
56
56
  _icon={{
57
57
  // size: styles.PANEL_HEADER_ICON_SIZE,
58
- className: styles.PANEL_HEADER_ICON_COLOR,
58
+ className: styles.PANEL_HEADER_ICON_CLASSNAME,
59
59
  }}
60
60
  className={closeClassName}
61
61
  />;
@@ -76,7 +76,7 @@ export default function Header(props) {
76
76
  icon={isCollapsed ? Plus : Minus}
77
77
  _icon={{
78
78
  size: styles.PANEL_HEADER_ICON_SIZE,
79
- className: styles.PANEL_HEADER_ICON_COLOR,
79
+ className: styles.PANEL_HEADER_ICON_CLASSNAME,
80
80
  }}
81
81
  className={collapseClassName}
82
82
  />;
@@ -131,8 +131,7 @@ export default function Header(props) {
131
131
  Header-TextNative1
132
132
  flex-1
133
133
  font-bold
134
- ${styles.PANEL_HEADER_TEXT_COLOR}
135
- ${styles.PANEL_HEADER_TEXT_FONTSIZE}
134
+ ${styles.PANEL_HEADER_TEXT_CLASSNAME}
136
135
  `}>{title}</TextNative>
137
136
  </div>
138
137
  </VStack>
@@ -169,8 +168,7 @@ export default function Header(props) {
169
168
  Header-TextNative2
170
169
  flex-1
171
170
  font-bold
172
- ${styles.PANEL_HEADER_TEXT_COLOR}
173
- ${styles.PANEL_HEADER_TEXT_FONTSIZE}
171
+ ${styles.PANEL_HEADER_TEXT_CLASSNAME}
174
172
  `}
175
173
  >{title}</TextNative>
176
174
  {collapseBtn}
@@ -211,8 +209,7 @@ export default function Header(props) {
211
209
  font-bold
212
210
  w-[200px]
213
211
  text-right
214
- ${styles.PANEL_HEADER_TEXT_COLOR}
215
- ${styles.PANEL_HEADER_TEXT_FONTSIZE}
212
+ ${styles.PANEL_HEADER_TEXT_CLASSNAME}
216
213
  `}
217
214
  >{title}</TextNative>
218
215
  </VStack>
@@ -246,8 +243,7 @@ export default function Header(props) {
246
243
  Header-TextNative4
247
244
  font-bold
248
245
  flex-1
249
- ${styles.PANEL_HEADER_TEXT_COLOR}
250
- ${styles.PANEL_HEADER_TEXT_FONTSIZE}
246
+ ${styles.PANEL_HEADER_TEXT_CLASSNAME}
251
247
  `}>{title}</TextNative>
252
248
  {collapseBtn}
253
249
  </HStack>
@@ -155,10 +155,10 @@ function TabBar(props) {
155
155
  buttonProps = {
156
156
  className: `
157
157
  ${styles.TAB_BG}
158
+ ${isCollapsed ? 'justify-center' : 'justify-start'}
158
159
  ${styles.TAB_BG_HOVER}
159
160
  ${styles.TAB_BG_ACTIVE}
160
161
  ${styles.TAB_BG_DISABLED}
161
- ${isCollapsed ? 'justify-center' : 'justify-start'}
162
162
  `,
163
163
  },
164
164
  textProps = {
@@ -496,10 +496,10 @@ function TabBar(props) {
496
496
  className={`
497
497
  ${isCollapsed ? 'w-[50px]' : 'w-[' + tabWidth + 'px]'}
498
498
  ${isCollapsed ? 'pl-1' : 'pl-4'}
499
- ${styles.TAB_BAR_BG}
500
499
  items-center
501
500
  justify-start
502
501
  py-2
502
+ ${styles.TAB_BAR_CLASSNAME}
503
503
  `}
504
504
  >
505
505
  {renderedTabs}
@@ -521,11 +521,11 @@ function TabBar(props) {
521
521
  {...testProps('TabBar')}
522
522
  className={`
523
523
  ${isCollapsed ? 'h-[38px]' : 'h-[' + tabHeight + 'px]'}
524
- ${styles.TAB_BAR_BG}
525
524
  items-center
526
525
  justify-start
527
526
  p-1
528
527
  pb-0
528
+ ${styles.TAB_BAR_CLASSNAME}
529
529
  `}
530
530
  >
531
531
  <ScrollView
@@ -20,7 +20,7 @@ export default function Toolbar(props) {
20
20
  border-b
21
21
  border-solid
22
22
  border-b-grey-400
23
- ${styles.TOOLBAR_BG}
23
+ ${styles.TOOLBAR_CLASSNAME}
24
24
  `;
25
25
  if (props.className) {
26
26
  className += ' ' + props.className
@@ -65,7 +65,7 @@ export default function TreeNode(props) {
65
65
  }
66
66
 
67
67
  let className = `
68
- treenode
68
+ TreeNode
69
69
  items-center
70
70
  flex
71
71
  flex-1
@@ -101,15 +101,13 @@ export default function TreeNode(props) {
101
101
  ellipsizeMode="head"
102
102
  // {...propsToPass}
103
103
  className={`
104
- treenode-text
104
+ TreeNode-TextNative
105
105
  self-center
106
106
  overflow-hidden
107
107
  flex
108
108
  flex-1
109
109
  text-ellipsis
110
- ${styles.TREE_NODE_PY}
111
- ${styles.TREE_NODE_PX}
112
- ${styles.TREE_NODE_FONTSIZE}
110
+ ${styles.TREE_NODE_CLASSNAME}
113
111
  `}
114
112
  style={{ userSelect: 'none', }}
115
113
  >{text}</TextNative>
@@ -183,7 +183,7 @@ function Viewer(props) {
183
183
  return buildFromItem(item, ix, {...defaults, ...itemDefaults});
184
184
  });
185
185
 
186
- let elementClassName = '';
186
+ let elementClassName = 'Viewer-ElementFromItem';
187
187
  const defaultsClassName = defaults.className;
188
188
  if (defaultsClassName) {
189
189
  elementClassName += ' ' + defaultsClassName;
@@ -234,7 +234,7 @@ function Viewer(props) {
234
234
  }
235
235
  }
236
236
 
237
- let elementClassName = 'field-' + name;
237
+ let elementClassName = 'Viewer-field-' + name;
238
238
  const defaultsClassName = defaults.className;
239
239
  if (defaultsClassName) {
240
240
  elementClassName += ' ' + defaultsClassName;
@@ -260,7 +260,7 @@ function Viewer(props) {
260
260
  />;
261
261
 
262
262
  if (item.additionalViewButtons) {
263
- element = <HStack className="flex-wrap">
263
+ element = <HStack className="Viewer-HStack1 flex-wrap">
264
264
  {element}
265
265
  {buildAdditionalButtons(item.additionalViewButtons, self)}
266
266
  </HStack>;
@@ -275,18 +275,18 @@ function Viewer(props) {
275
275
  style.width = '50px';
276
276
  }
277
277
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
278
- element = <HStack className="HStackA py-1">
278
+ element = <HStack className="Viewer-HStack2 py-1 w-full">
279
279
  <Label style={style}>{label}</Label>
280
280
  {element}
281
281
  </HStack>;
282
282
  } else {
283
- element = <VStack className="HStackA w-full py-1 mt-3">
283
+ element = <VStack className="Viewer-HStack3 w-full py-1 mt-3">
284
284
  <Label style={style}>{label}</Label>
285
285
  {element}
286
286
  </VStack>;
287
287
  }
288
288
  }
289
- return <HStack key={ix} className="HStackB px-2 pb-1">{element}</HStack>;
289
+ return <HStack key={ix} className="Viewer-HStack4 px-2 pb-1">{element}</HStack>;
290
290
  },
291
291
  buildAncillary = () => {
292
292
  const components = [];
@@ -304,6 +304,10 @@ function Viewer(props) {
304
304
  if (type.match(/Grid/) && !itemPropsToPass.h) {
305
305
  itemPropsToPass.h = 400;
306
306
  }
307
+ let className = 'Viewer-ancillary-' + type;
308
+ if (itemPropsToPass.className) {
309
+ className += ' ' + itemPropsToPass.className;
310
+ }
307
311
 
308
312
  const
309
313
  Element = getComponentFromType(type),
@@ -317,6 +321,7 @@ function Viewer(props) {
317
321
  uniqueRepository={true}
318
322
  parent={self}
319
323
  {...itemPropsToPass}
324
+ className={className}
320
325
  canRowsReorder={false}
321
326
  />;
322
327
  if (title) {
@@ -362,6 +367,10 @@ function Viewer(props) {
362
367
  canEdit = false;
363
368
  }
364
369
 
370
+ const style = props.style || {};
371
+ if (!hasWidth(props) && !hasFlex(props)) {
372
+ style.flex = 1;
373
+ }
365
374
  let className = `
366
375
  Viewer-VStackNative
367
376
  h-full
@@ -373,8 +382,9 @@ function Viewer(props) {
373
382
 
374
383
  return <VStackNative
375
384
  {...testProps(self)}
376
- className={className}
385
+ style={style}
377
386
  onLayout={onLayout}
387
+ className={className}
378
388
  >
379
389
  {containerWidth && <>
380
390