@onehat/ui 0.4.8 → 0.4.9

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.4.8",
3
+ "version": "0.4.9",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -1013,6 +1013,7 @@ export function ComboComponent(props) {
1013
1013
  Combo-HStack
1014
1014
  flex-1
1015
1015
  h-[40px]
1016
+ min-h-[40px]
1016
1017
  justify-center
1017
1018
  items-center
1018
1019
  `;
@@ -274,8 +274,8 @@ function TagComponent(props) {
274
274
  Tag-valueBoxes-container
275
275
  w-full
276
276
  min-h-[40px]
277
- flex-wrap
278
277
  max-h-[200px]
278
+ flex-wrap
279
279
  overflow-auto
280
280
  border
281
281
  border-grey-300
@@ -378,7 +378,7 @@ function Form(props) {
378
378
  dynamicProps = getDynamicProps({ fieldState, formSetValue, formGetValues, formState });
379
379
  }
380
380
 
381
- let elementClassName = 'Form-Element flex-1';
381
+ let elementClassName = 'Form-Element';
382
382
  if (type.match(/Tag/)) {
383
383
  elementClassName += ' overflow-auto';
384
384
  }
@@ -643,10 +643,10 @@ function Form(props) {
643
643
  if (defaults?.labelWidth) {
644
644
  style.width = defaults.labelWidth;
645
645
  }
646
- if (!style.width) {
647
- style.width = '50px';
648
- }
649
646
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
647
+ if (!style.width) {
648
+ style.width = '100px';
649
+ }
650
650
  element = <HStack className="Form-HStack1 w-full py-1">
651
651
  <Label style={style}>{label}</Label>
652
652
  {element}
@@ -724,7 +724,7 @@ function Form(props) {
724
724
  dynamicProps = getDynamicProps({ fieldState, formSetValue, formGetValues, formState });
725
725
  }
726
726
 
727
- let elementClassName = 'Form-Element field-' + name + ' flex-1';
727
+ let elementClassName = 'Form-Element field-' + name + ' w-full';
728
728
  const defaultsClassName = defaults.className;
729
729
  if (defaultsClassName) {
730
730
  elementClassName += ' ' + defaultsClassName;
@@ -774,7 +774,7 @@ function Form(props) {
774
774
  if (message) {
775
775
  message = <Text className="text-[#f00]">{message}</Text>;
776
776
  }
777
- element = <VStack className="Form-VStack4 pt-1 flex-1">
777
+ element = <VStack className="Form-VStack4 w-full pt-1">
778
778
  {element}
779
779
  {message}
780
780
  </VStack>;
@@ -782,14 +782,14 @@ function Form(props) {
782
782
  if (item.additionalEditButtons) {
783
783
  const buttons = buildAdditionalButtons(item.additionalEditButtons, self, { fieldState, formSetValue, formGetValues, formState });
784
784
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
785
- element = <HStack className="Form-HStack5 flex-1 flex-wrap">
785
+ element = <HStack className="Form-HStack5 w-full flex-wrap">
786
786
  {element}
787
787
  {buttons}
788
788
  </HStack>;
789
789
  } else {
790
- element = <VStack className="Form-VStack6 flex-1 w-full">
790
+ element = <VStack className="Form-VStack6 w-full">
791
791
  {element}
792
- <HStack className="Form-HStack7-VStack flex-1 w-full mt-1 flex-wrap">
792
+ <HStack className="Form-HStack7-VStack w-full mt-1 flex-wrap">
793
793
  {buttons}
794
794
  </HStack>
795
795
  </VStack>;
@@ -819,22 +819,22 @@ function Form(props) {
819
819
  if (defaults?.labelWidth) {
820
820
  style.width = defaults.labelWidth;
821
821
  }
822
- if (!style.width) {
823
- style.width = '50px';
824
- }
825
822
  if (containerWidth > styles.FORM_STACK_ROW_THRESHOLD) {
826
- element = <HStack className="Form-HStack8 flex-1">
823
+ if (!style.width) {
824
+ style.width = '100px';
825
+ }
826
+ element = <HStack className="Form-HStack8 w-full">
827
827
  <Label style={style}>{requiredIndicator}{label}</Label>
828
828
  {element}
829
829
  </HStack>;
830
830
  } else {
831
- element = <VStack className="Form-VStack9 flex-1 mt-3">
831
+ element = <VStack className="Form-VStack9 w-full mt-3">
832
832
  <Label style={style}>{requiredIndicator}{label}</Label>
833
833
  {element}
834
834
  </VStack>;
835
835
  }
836
836
  } else if (disableLabels && requiredIndicator) {
837
- element = <HStack className="Form-HStack10 flex-1">
837
+ element = <HStack className="Form-HStack10 w-full">
838
838
  {requiredIndicator}
839
839
  {element}
840
840
  </HStack>;
@@ -855,9 +855,10 @@ function Form(props) {
855
855
  key={ix}
856
856
  className={`
857
857
  Form-HStack11
858
+ min-h-[50px]
859
+ w-full
858
860
  flex-none
859
861
  pb-2
860
- h-[50px]
861
862
  ${error ? 'bg-[#fdd]' : ''}
862
863
  `}
863
864
  >
@@ -107,7 +107,6 @@ const
107
107
 
108
108
  function GridComponent(props) {
109
109
  const {
110
-
111
110
  columnsConfig = [], // json configurations for each column
112
111
  columnProps = {},
113
112
  defaultHiddenColumns = [],
@@ -365,7 +364,7 @@ function GridComponent(props) {
365
364
  onPress={() => setIsReorderMode(!isReorderMode)}
366
365
  icon={isReorderMode ? NoReorderRows : ReorderRows}
367
366
  _icon={{
368
- className: styles.GRID_TOOLBAR_ITEMS_COLOR,
367
+ className: styles.TOOLBAR_ITEMS_COLOR,
369
368
  }}
370
369
  tooltip="Reorder Rows"
371
370
  />);
@@ -466,28 +465,36 @@ function GridComponent(props) {
466
465
  onContextMenu(item, e, selection);
467
466
  }
468
467
  }}
469
- className="flex-row grow-1">
468
+ className="flex-row grow">
470
469
  {({
471
470
  hovered,
472
471
  focused,
473
472
  pressed,
474
473
  }) => {
475
474
  if (isHeaderRow) {
476
- return <GridHeaderRow
477
- Repository={Repository}
478
- columnsConfig={localColumnsConfig}
479
- setColumnsConfig={setLocalColumnsConfig}
480
- hideNavColumn={hideNavColumn}
481
- canColumnsSort={canColumnsSort}
482
- canColumnsReorder={canColumnsReorder}
483
- canColumnsResize={canColumnsResize}
484
- setSelection={setSelection}
485
- gridRef={gridRef}
486
- isHovered={hovered}
487
- isInlineEditorShown={isInlineEditorShown}
488
- areRowsDragSource={areRowsDragSource}
489
- showColumnsSelector={showColumnsSelector}
490
- />;
475
+ let headerRow = <GridHeaderRow
476
+ Repository={Repository}
477
+ columnsConfig={localColumnsConfig}
478
+ setColumnsConfig={setLocalColumnsConfig}
479
+ hideNavColumn={hideNavColumn}
480
+ canColumnsSort={canColumnsSort}
481
+ canColumnsReorder={canColumnsReorder}
482
+ canColumnsResize={canColumnsResize}
483
+ setSelection={setSelection}
484
+ gridRef={gridRef}
485
+ isHovered={hovered}
486
+ isInlineEditorShown={isInlineEditorShown}
487
+ areRowsDragSource={areRowsDragSource}
488
+ showColumnsSelector={showColumnsSelector}
489
+ />;
490
+ if (showRowExpander) {
491
+ // align the header row to content rows
492
+ headerRow = <HStack className="">
493
+ <Box className="w-[40px]"></Box>
494
+ {headerRow}
495
+ </HStack>;
496
+ }
497
+ return headerRow;
491
498
  }
492
499
 
493
500
  const
@@ -572,15 +579,29 @@ function GridComponent(props) {
572
579
 
573
580
  if (showRowExpander && !isHeaderRow) {
574
581
  const isExpanded = getIsExpanded(index);
575
- rowComponent = <VStack>
576
- <HStack>
582
+ let className = `
583
+ Grid-rowExpander
584
+ w-full
585
+ flex-none
586
+ `;
587
+ if (rowProps?.className) {
588
+ className += ' ' + rowProps.className;
589
+ }
590
+ rowComponent = <VStack className={className}>
591
+ <HStack
592
+ className={`
593
+ Grid-rowExpander-HStack
594
+ w-full
595
+ grow
596
+ `}
597
+ >
577
598
  <ExpandButton
578
599
  isExpanded={isExpanded}
579
600
  onToggle={() => setIsExpanded(index, !isExpanded)}
580
601
  _icon={{
581
602
  size: 'sm',
582
603
  }}
583
- className="py-0"
604
+ className="Grid-rowExpander-expandBtn py-0"
584
605
  tooltip="Expand/Contract Row"
585
606
  />
586
607
  {rowComponent}
@@ -1228,6 +1249,7 @@ function GridComponent(props) {
1228
1249
  className={`
1229
1250
  gridContainer
1230
1251
  w-full
1252
+ h-full
1231
1253
  flex-1
1232
1254
  min-h-[40px]
1233
1255
  ${gridContainerBorderClassName}
@@ -1244,7 +1266,8 @@ function GridComponent(props) {
1244
1266
  grid = <Box
1245
1267
  ref={dropTargetRef}
1246
1268
  className={`
1247
- dropTarget
1269
+ Grid-dropTarget
1270
+ h-full
1248
1271
  w-full
1249
1272
  border-[#0ff]
1250
1273
  ${canDrop && isOver ? "border-[4px]" : "border-[0px]"}
@@ -315,6 +315,9 @@ function GridRow(props) {
315
315
  } else {
316
316
  rowClassName += ' border-b border-b-grey-100';
317
317
  }
318
+ if (rowProps?.className) {
319
+ rowClassName += ' ' + rowProps.className;
320
+ }
318
321
  return <HStackNative
319
322
  {...testProps('row' + (isSelected ? '-selected' : ''))}
320
323
  {...rowProps}
@@ -337,6 +340,7 @@ function GridRow(props) {
337
340
  isInlineEditorShown,
338
341
  isSelected,
339
342
  isHovered,
343
+ isOver,
340
344
  index,
341
345
  dragSourceRef,
342
346
  dropTargetRef,
@@ -4,8 +4,8 @@ import { Path, Svg } from 'react-native-svg';
4
4
 
5
5
  const SvgComponent = createIcon({
6
6
  Root: Svg,
7
- viewBox: '0 0 10.46 10.46',
8
- path: <Path d="M0 5.23C0 2.34 2.34 0 5.23 0s5.23 2.34 5.23 5.23-2.34 5.23-5.23 5.23S0 8.12 0 5.23zm5.89-3.27c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65zM5.24 8.5c.72 0 1.31-.59 1.31-1.31 0-.36-.14-.68-.37-.91L7.49 3.3c.11-.25 0-.54-.25-.65s-.54 0-.65.25L5.28 5.88h-.04c-.72 0-1.31.59-1.31 1.31S4.52 8.5 5.24 8.5zM3.6 2.94c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65zM1.96 5.88c.36 0 .65-.29.65-.65s-.29-.65-.65-.65-.65.29-.65.65.29.65.65.65zm7.19-.65c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65z" />
7
+ viewBox: '0 0 512 512',
8
+ path: <Path d="M0 256a256 256 0 11512 0 256 256 0 11-512 0zm320 96c0-26.9-16.5-49.9-40-59.3V88c0-13.3-10.7-24-24-24s-24 10.7-24 24v204.7c-23.5 9.5-40 32.5-40 59.3 0 35.3 28.7 64 64 64s64-28.7 64-64zM144 176a32 32 0 100-64 32 32 0 100 64zm-16 80a32 32 0 10-64 0 32 32 0 1064 0zm288 32a32 32 0 100-64 32 32 0 100 64zm-16-144a32 32 0 10-64 0 32 32 0 1064 0z" />,
9
9
  });
10
10
 
11
11
  export default SvgComponent
@@ -61,6 +61,7 @@ export default function Pagination(props) {
61
61
  {...testProps('showMoreBtn')}
62
62
  key="showMoreBtn"
63
63
  reference="showMoreBtn"
64
+ className="Pagination-showMoreBtn"
64
65
  parent={self}
65
66
  onPress={() => Repository.showMore()}
66
67
  isDisabled={isDisabled}
@@ -70,6 +71,7 @@ export default function Pagination(props) {
70
71
  if (!Repository.isLocal) {
71
72
  items.push(<ReloadButton
72
73
  key="reloadPageBtn"
74
+ className="Pagination-reloadPageBtn"
73
75
  _icon={iconProps}
74
76
  Repository={Repository}
75
77
  self={self}
@@ -82,6 +84,7 @@ export default function Pagination(props) {
82
84
  {...testProps('firstPageBtn')}
83
85
  key="firstPageBtn"
84
86
  reference="firstPageBtn"
87
+ className="Pagination-firstPageBtn"
85
88
  parent={self}
86
89
  isDisabled={isDisabled}
87
90
  icon={AnglesLeft}
@@ -93,6 +96,7 @@ export default function Pagination(props) {
93
96
  {...testProps('prevPageBtn')}
94
97
  key="prevPageBtn"
95
98
  reference="prevPageBtn"
99
+ className="Pagination-prevPageBtn"
96
100
  parent={self}
97
101
  isDisabled={isDisabled}
98
102
  icon={AngleLeft}
@@ -101,31 +105,38 @@ export default function Pagination(props) {
101
105
  tooltip="Previous Page"
102
106
  />);
103
107
  if (!minimize) {
104
- items.push(<HStack
105
- key="pageSelector"
106
- className={`
107
- pageSelector
108
- w-[100px]
109
- mx-2
110
- justify-center
111
- items-center
112
- bg-[#f00]
113
- `}>
114
- {/* <Text className="page mr-1">Page</Text>
115
- <Input
116
- {...testProps('pageInput')}
117
- reference="pageInput"
118
- parent={self}
119
- keyboardType="numeric"
120
- value={page?.toString()}
121
- onChangeValue={(value) => Repository.setPage(value)}
122
- maxValue={totalPages}
123
- isDisabled={totalPages === 1}
124
- className="pageInput w-[30px] text-center bg-grey-100"
125
- tooltip="Set Page"
126
- />
127
- <Text className="of ml-1">of {totalPages}</Text> */}
128
- </HStack>);
108
+ items.push(<Text
109
+ key="page"
110
+ className="Pagination-page mx-1"
111
+ >Page</Text>);
112
+ items.push(<Input
113
+ {...testProps('pageInput')}
114
+ key="pageInput"
115
+ reference="pageInput"
116
+ parent={self}
117
+ keyboardType="numeric"
118
+ value={page?.toString()}
119
+ onChangeValue={(value) => Repository.setPage(value)}
120
+ maxValue={totalPages}
121
+ isDisabled={totalPages === 1}
122
+ className={`
123
+ Pagination-pageInput
124
+ min-w-[40px]
125
+ w-[40px]
126
+ text-center
127
+ bg-grey-100
128
+ `}
129
+ tooltip="Set Page"
130
+ />);
131
+ items.push(<Text
132
+ key="totalPages"
133
+ className={`
134
+ Pagination-totalPages
135
+ whitespace-nowrap
136
+ inline-flex
137
+ mx-1
138
+ `}
139
+ >{`of ${totalPages}`}</Text>);
129
140
  }
130
141
 
131
142
  isDisabled = page === totalPages || totalPages <= 1;
@@ -133,6 +144,7 @@ export default function Pagination(props) {
133
144
  {...testProps('nextPageBtn')}
134
145
  key="nextPageBtn"
135
146
  reference="nextPageBtn"
147
+ className="Pagination-nextPageBtn"
136
148
  parent={self}
137
149
  isDisabled={isDisabled}
138
150
  icon={AngleRight}
@@ -144,6 +156,7 @@ export default function Pagination(props) {
144
156
  {...testProps('lastPageBtn')}
145
157
  key="lastPageBtn"
146
158
  reference="lastPageBtn"
159
+ className="Pagination-lastPageBtn"
147
160
  parent={self}
148
161
  isDisabled={isDisabled}
149
162
  icon={AnglesRight}
@@ -156,6 +169,7 @@ export default function Pagination(props) {
156
169
  if (!Repository.isLocal) {
157
170
  items.push(<ReloadButton
158
171
  key="reloadPageBtn"
172
+ className="Pagination-reloadPageBtn"
159
173
  _icon={iconProps}
160
174
  Repository={Repository}
161
175
  self={self}
@@ -178,13 +192,26 @@ export default function Pagination(props) {
178
192
  }
179
193
  items.push(<Text
180
194
  key="pageDisplay"
181
- className="pageDisplay ml-3 min-w-[200px]"
182
- >Displaying {pageSpan} of {total}</Text>);
195
+ className={`
196
+ Pagination-pageDisplay
197
+ whitespace-nowrap
198
+ inline-flex
199
+ mx-1
200
+ `}
201
+ >{`Displaying ${pageSpan} of ${total}`}</Text>);
183
202
  }
184
203
  }
185
204
  return <HStack
186
205
  style={{ userSelect: 'none', }}
187
- className="Pagination justify-start items-center px-2 "
206
+ className={`
207
+ Pagination
208
+ flex-none
209
+ gap-1
210
+ justify-start
211
+ items-center
212
+ px-2
213
+ mr-3
214
+ `}
188
215
  >
189
216
  {items}
190
217
  </HStack>;