@onehat/ui 0.4.70 → 0.4.72
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 +2 -1
- package/src/Components/Accordion/Accordion.js +1 -0
- package/src/Components/Blank.js +1 -0
- package/src/Components/Buttons/BackButton.js +1 -0
- package/src/Components/Buttons/Button.js +18 -10
- package/src/Components/Buttons/CartButtonWithBadge.js +1 -0
- package/src/Components/Buttons/IconButton.js +9 -8
- package/src/Components/Buttons/PlusMinusButton.js +5 -4
- package/src/Components/Buttons/SquareButton.js +19 -18
- package/src/Components/Container/Container.js +1 -0
- package/src/Components/Container/ContainerColumn.js +4 -3
- package/src/Components/Container/ScreenContainer.js +14 -13
- package/src/Components/Container/Splitter.js +33 -28
- package/src/Components/Editor/InlineEditor.js +32 -30
- package/src/Components/Fab/DynamicFab.js +14 -13
- package/src/Components/Fab/FabWithTooltip.js +1 -0
- package/src/Components/Filter/DateRange.js +8 -7
- package/src/Components/Filter/NumberRange.js +8 -7
- package/src/Components/Form/Field/CKEditor/CKEditor.js +1 -0
- package/src/Components/Form/Field/Checkbox/CheckboxGroup.js +1 -0
- package/src/Components/Form/Field/Color.js +41 -40
- package/src/Components/Form/Field/Combo/Combo.js +173 -172
- package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
- package/src/Components/Form/Field/Combo/PageSizeCombo.js +1 -0
- package/src/Components/Form/Field/Date.js +117 -116
- package/src/Components/Form/Field/DisplayField.js +6 -5
- package/src/Components/Form/Field/File.js +1 -0
- package/src/Components/Form/Field/FormikForm.js +1 -0
- package/src/Components/Form/Field/Input.js +20 -18
- package/src/Components/Form/Field/Json.js +7 -6
- package/src/Components/Form/Field/Number.js +31 -30
- package/src/Components/Form/Field/RadioGroup/RadioGroup.js +1 -0
- package/src/Components/Form/Field/Select/PageSizeSelect.js +1 -0
- package/src/Components/Form/Field/Select/Select.js +9 -8
- package/src/Components/Form/Field/Slider.js +15 -14
- package/src/Components/Form/Field/Tag/Tag.js +25 -24
- package/src/Components/Form/Field/Tag/ValueBox.js +32 -31
- package/src/Components/Form/Field/Text.js +9 -8
- package/src/Components/Form/Field/TextArea.js +9 -8
- package/src/Components/Form/Field/Toggle.js +16 -15
- package/src/Components/Form/FieldSet.js +27 -26
- package/src/Components/Form/Form.js +104 -103
- package/src/Components/Form/Label.js +15 -14
- package/src/Components/Grid/Grid.js +62 -52
- package/src/Components/Grid/GridHeaderRow.js +42 -40
- package/src/Components/Grid/GridRow.js +92 -90
- package/src/Components/Grid/HeaderColumnSelectorHandle.js +9 -8
- package/src/Components/Grid/HeaderReorderHandle.js +9 -8
- package/src/Components/Grid/HeaderResizeHandle.js +9 -8
- package/src/Components/Grid/NoRecordsFound.js +4 -3
- package/src/Components/Grid/RowDragHandle.js +26 -10
- package/src/Components/Grid/RowHandle.js +55 -0
- package/src/Components/Grid/RowSelectHandle.js +1 -0
- package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
- package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +4 -3
- package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
- package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
- package/src/Components/Hoc/Secondary/withSecondaryWindowedEditor.js +6 -5
- package/src/Components/Hoc/withAlert.js +38 -35
- package/src/Components/Hoc/withCollapsible.js +9 -4
- package/src/Components/Hoc/withComponent.js +6 -0
- package/src/Components/Hoc/withContextMenu.js +33 -26
- package/src/Components/Hoc/withData.js +3 -2
- package/src/Components/Hoc/withDnd.js +17 -8
- package/src/Components/Hoc/withDraggable.js +21 -5
- package/src/Components/Hoc/withEditor.js +3 -2
- package/src/Components/Hoc/withEvents.js +11 -1
- package/src/Components/Hoc/withFilters.js +26 -20
- package/src/Components/Hoc/withModal.js +10 -8
- package/src/Components/Hoc/withPdfButtons.js +3 -2
- package/src/Components/Hoc/withPermissions.js +3 -2
- package/src/Components/Hoc/withPresetButtons.js +3 -2
- package/src/Components/Hoc/withSelection.js +2 -8
- package/src/Components/Hoc/withToast.js +5 -2
- package/src/Components/Hoc/withTooltip.js +10 -1
- package/src/Components/Hoc/withValue.js +3 -9
- package/src/Components/Hoc/withWindowedEditor.js +6 -5
- package/src/Components/Layout/AsyncOperation.js +1 -0
- package/src/Components/Layout/CenterBox.js +9 -8
- package/src/Components/Layout/Footer.js +11 -10
- package/src/Components/Layout/ScreenHeader.js +5 -4
- package/src/Components/Layout/TextWithTooltip.js +1 -0
- package/src/Components/Messages/ConfirmationMessage.js +6 -5
- package/src/Components/Messages/ErrorMessage.js +40 -39
- package/src/Components/Messages/GlobalModals.js +47 -0
- package/src/Components/Messages/Loading.js +1 -0
- package/src/Components/Messages/OkMessage.js +11 -10
- package/src/Components/Messages/Unauthorized.js +1 -0
- package/src/Components/Messages/WaitMessage.js +16 -15
- package/src/Components/Panel/AccordionGridPanel.js +1 -0
- package/src/Components/Panel/FormPanel.js +1 -0
- package/src/Components/Panel/Header.js +59 -58
- package/src/Components/Panel/Mask.js +1 -0
- package/src/Components/Panel/Panel.js +7 -6
- package/src/Components/Picker/Picker.js +1 -0
- package/src/Components/Report/Report.js +35 -34
- package/src/Components/Screens/Manager.js +1 -0
- package/src/Components/Screens/ReportsManager.js +1 -0
- package/src/Components/Tab/Tab.js +1 -0
- package/src/Components/Tab/TabBar.js +67 -66
- package/src/Components/Toolbar/FilterToolbar.js +14 -11
- package/src/Components/Toolbar/Pagination.js +26 -25
- package/src/Components/Toolbar/PaginationToolbar.js +13 -12
- package/src/Components/Toolbar/Toolbar.js +13 -12
- package/src/Components/Tooltip/Tooltip.js +1 -0
- package/src/Components/Tree/Tree.js +34 -17
- package/src/Components/Tree/TreeNode.js +30 -29
- package/src/Components/Tree/TreeNodeDragHandle.js +18 -13
- package/src/Components/Viewer/MeterTypeText.js +29 -8
- package/src/Components/Viewer/TextWithLinks.js +16 -15
- package/src/Components/Viewer/Viewer.js +23 -22
- package/src/Components/Window/UploadsDownloadsWindow.js +6 -5
- package/src/Components/index.js +1 -0
- package/src/Constants/MeterTypes.js +2 -0
- package/src/Functions/addIconProps.js +46 -0
- package/src/Functions/testProps.js +1 -1
- package/src/Hooks/useWhyDidYouUpdate.js +33 -0
- package/src/PlatformImports/Web/Attachments.js +1 -1
- package/src/Components/Hoc/withBlank.js +0 -10
|
@@ -2,26 +2,27 @@ import {
|
|
|
2
2
|
HStack,
|
|
3
3
|
TextNative,
|
|
4
4
|
} from '@project-components/Gluestack';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
import styles from '../../Constants/Styles.js';
|
|
6
7
|
|
|
7
8
|
export default function Label(props) {
|
|
8
|
-
let className =
|
|
9
|
-
Label
|
|
10
|
-
items-center
|
|
11
|
-
min-w-[120px]
|
|
12
|
-
pl-2
|
|
13
|
-
|
|
9
|
+
let className = clsx(
|
|
10
|
+
'Label',
|
|
11
|
+
'items-center',
|
|
12
|
+
'min-w-[120px]',
|
|
13
|
+
'pl-2',
|
|
14
|
+
);
|
|
14
15
|
if (props.className) {
|
|
15
16
|
className += ' ' + props.className;
|
|
16
17
|
}
|
|
17
|
-
let textClassName =
|
|
18
|
-
Label-TextNative
|
|
19
|
-
inline-block
|
|
20
|
-
text-ellipsis
|
|
21
|
-
text-base
|
|
22
|
-
w-full
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
let textClassName = clsx(
|
|
19
|
+
'Label-TextNative',
|
|
20
|
+
'inline-block',
|
|
21
|
+
'text-ellipsis',
|
|
22
|
+
'text-base',
|
|
23
|
+
'w-full',
|
|
24
|
+
styles.FORM_LABEL_CLASSNAME,
|
|
25
|
+
);
|
|
25
26
|
if (props._text?.className) {
|
|
26
27
|
textClassName += ' ' + props._text.className;
|
|
27
28
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
VStack,
|
|
9
9
|
VStackNative,
|
|
10
10
|
} from '@project-components/Gluestack';
|
|
11
|
+
import clsx from 'clsx';
|
|
11
12
|
import {
|
|
12
13
|
ScrollView,
|
|
13
14
|
} from 'react-native';
|
|
@@ -34,7 +35,6 @@ import {
|
|
|
34
35
|
hasFlex,
|
|
35
36
|
} from '../../Functions/tailwindFunctions.js';
|
|
36
37
|
import * as yup from 'yup'; // https://github.com/jquense/yup#string
|
|
37
|
-
import Inflector from 'inflector-js';
|
|
38
38
|
import { EDITOR_TYPE__PLAIN } from '../../Constants/Editor.js';
|
|
39
39
|
import UiGlobals from '../../UiGlobals.js';
|
|
40
40
|
import useForceUpdate from '../../Hooks/useForceUpdate.js';
|
|
@@ -113,10 +113,10 @@ function GridComponent(props) {
|
|
|
113
113
|
defaultHiddenColumns = [],
|
|
114
114
|
getRowProps = (item) => {
|
|
115
115
|
return {
|
|
116
|
-
className:
|
|
117
|
-
border-bottom-1
|
|
118
|
-
border-bottom-grey-500
|
|
119
|
-
|
|
116
|
+
className: clsx(
|
|
117
|
+
'border-bottom-1',
|
|
118
|
+
'border-bottom-grey-500',
|
|
119
|
+
),
|
|
120
120
|
};
|
|
121
121
|
},
|
|
122
122
|
flatListProps = {},
|
|
@@ -170,6 +170,7 @@ function GridComponent(props) {
|
|
|
170
170
|
|
|
171
171
|
// DND
|
|
172
172
|
canRowsReorder = false,
|
|
173
|
+
canRowDrag, // optional fn to customize whether each row can be dragged
|
|
173
174
|
canRowAcceptDrop, // optional fn to customize whether each node can accept a dropped item: (targetItem, draggedItem) => boolean
|
|
174
175
|
getCustomDragProxy, // optional fn to render custom drag preview: (item, selection) => ReactElement
|
|
175
176
|
dragPreviewOptions, // optional object for drag preview positioning options
|
|
@@ -481,12 +482,12 @@ function GridComponent(props) {
|
|
|
481
482
|
onContextMenu(item, e, newSelection);
|
|
482
483
|
}
|
|
483
484
|
}}
|
|
484
|
-
className={
|
|
485
|
-
Pressable
|
|
486
|
-
Row
|
|
487
|
-
flex-row
|
|
488
|
-
grow
|
|
489
|
-
|
|
485
|
+
className={clsx(
|
|
486
|
+
'Pressable',
|
|
487
|
+
'Row',
|
|
488
|
+
'flex-row',
|
|
489
|
+
'grow',
|
|
490
|
+
)}
|
|
490
491
|
>
|
|
491
492
|
{({
|
|
492
493
|
hovered,
|
|
@@ -539,6 +540,7 @@ function GridComponent(props) {
|
|
|
539
540
|
rowReorderProps.dragSourceItem = {
|
|
540
541
|
id: item.id,
|
|
541
542
|
getSelection,
|
|
543
|
+
isInSelection,
|
|
542
544
|
onDrag: (dragState) => {
|
|
543
545
|
onRowReorderDrag(dragState, dragIx);
|
|
544
546
|
},
|
|
@@ -546,20 +548,30 @@ function GridComponent(props) {
|
|
|
546
548
|
rowReorderProps.onDragEnd = onRowReorderEnd;
|
|
547
549
|
} else {
|
|
548
550
|
// Don't allow drag/drop from withDnd while reordering
|
|
549
|
-
if (areRowsDragSource) {
|
|
551
|
+
if (areRowsDragSource && (!canRowDrag || canRowDrag(item))) {
|
|
550
552
|
WhichRow = DragSourceGridRow;
|
|
551
553
|
rowDragProps.isDragSource = true;
|
|
552
554
|
rowDragProps.dragSourceType = rowDragSourceType;
|
|
553
555
|
if (getRowDragSourceItem) {
|
|
554
|
-
rowDragProps.dragSourceItem = getRowDragSourceItem(item, getSelection, rowDragSourceType);
|
|
556
|
+
rowDragProps.dragSourceItem = getRowDragSourceItem(item, getSelection, isInSelection, rowDragSourceType);
|
|
555
557
|
} else {
|
|
556
558
|
rowDragProps.dragSourceItem = {
|
|
557
559
|
id: item.id,
|
|
558
560
|
item,
|
|
559
561
|
getSelection,
|
|
562
|
+
isInSelection,
|
|
560
563
|
type: rowDragSourceType,
|
|
561
564
|
};
|
|
562
565
|
}
|
|
566
|
+
rowDragProps.dragSourceItem.onDragStart = () => {
|
|
567
|
+
if (!isInSelection(item)) { // get updated isSelected (will be stale if using one in closure)
|
|
568
|
+
// reset the selection to just this one node if it's not already selected
|
|
569
|
+
setSelection([item]);
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
if (canRowDrag) {
|
|
573
|
+
rowDragProps.canDrag = () => canRowDrag(item, rowDragProps.dragSourceItem);
|
|
574
|
+
}
|
|
563
575
|
|
|
564
576
|
// Add custom drag preview options
|
|
565
577
|
if (dragPreviewOptions) {
|
|
@@ -623,21 +635,21 @@ function GridComponent(props) {
|
|
|
623
635
|
|
|
624
636
|
if (showRowExpander && !isHeaderRow) {
|
|
625
637
|
const isExpanded = getIsExpanded(index);
|
|
626
|
-
let className =
|
|
627
|
-
Grid-rowExpander
|
|
628
|
-
w-full
|
|
629
|
-
flex-none
|
|
630
|
-
|
|
638
|
+
let className = clsx(
|
|
639
|
+
'Grid-rowExpander',
|
|
640
|
+
'w-full',
|
|
641
|
+
'flex-none',
|
|
642
|
+
);
|
|
631
643
|
if (rowProps?.className) {
|
|
632
644
|
className += ' ' + rowProps.className;
|
|
633
645
|
}
|
|
634
646
|
rowComponent = <VStack className={className}>
|
|
635
647
|
<HStack
|
|
636
|
-
className={
|
|
637
|
-
Grid-rowExpander-HStack
|
|
638
|
-
w-full
|
|
639
|
-
grow
|
|
640
|
-
|
|
648
|
+
className={clsx(
|
|
649
|
+
'Grid-rowExpander-HStack',
|
|
650
|
+
'w-full',
|
|
651
|
+
'grow',
|
|
652
|
+
)}
|
|
641
653
|
>
|
|
642
654
|
<ExpandButton
|
|
643
655
|
{...testProps((Repository ? Repository.schema.name : 'GridRow') + '-expandBtn-' + item?.id)}
|
|
@@ -646,10 +658,10 @@ function GridComponent(props) {
|
|
|
646
658
|
_icon={{
|
|
647
659
|
size: 'sm',
|
|
648
660
|
}}
|
|
649
|
-
className={
|
|
650
|
-
Grid-rowExpander-expandBtn
|
|
651
|
-
|
|
652
|
-
|
|
661
|
+
className={clsx(
|
|
662
|
+
'Grid-rowExpander-expandBtn',
|
|
663
|
+
styles.GRID_EXPAND_BTN_CLASSNAME,
|
|
664
|
+
)}
|
|
653
665
|
tooltip="Expand/Contract Row"
|
|
654
666
|
/>
|
|
655
667
|
{rowComponent}
|
|
@@ -696,8 +708,7 @@ function GridComponent(props) {
|
|
|
696
708
|
};
|
|
697
709
|
},
|
|
698
710
|
buildCachedDragElements = (dragState) => {
|
|
699
|
-
const
|
|
700
|
-
{
|
|
711
|
+
const {
|
|
701
712
|
canDrag,
|
|
702
713
|
isDragging,
|
|
703
714
|
clientOffset,
|
|
@@ -746,8 +757,7 @@ function GridComponent(props) {
|
|
|
746
757
|
cachedDragElements.current = buildCachedDragElements(dragState);
|
|
747
758
|
}
|
|
748
759
|
|
|
749
|
-
const
|
|
750
|
-
{
|
|
760
|
+
const {
|
|
751
761
|
canDrag,
|
|
752
762
|
isDragging,
|
|
753
763
|
clientOffset,
|
|
@@ -1276,12 +1286,12 @@ function GridComponent(props) {
|
|
|
1276
1286
|
if (!hasHeight(props) && !hasWidth(props) && !hasFlex(props)) {
|
|
1277
1287
|
style.flex = 1;
|
|
1278
1288
|
}
|
|
1279
|
-
let className =
|
|
1280
|
-
Grid-VStackNative
|
|
1281
|
-
w-full
|
|
1282
|
-
border
|
|
1283
|
-
border-grey-300
|
|
1284
|
-
|
|
1289
|
+
let className = clsx(
|
|
1290
|
+
'Grid-VStackNative',
|
|
1291
|
+
'w-full',
|
|
1292
|
+
'border',
|
|
1293
|
+
'border-grey-300',
|
|
1294
|
+
);
|
|
1285
1295
|
if (props.className) {
|
|
1286
1296
|
className += props.className;
|
|
1287
1297
|
}
|
|
@@ -1304,14 +1314,14 @@ function GridComponent(props) {
|
|
|
1304
1314
|
deselectAll();
|
|
1305
1315
|
}
|
|
1306
1316
|
}}
|
|
1307
|
-
className={
|
|
1308
|
-
gridContainer
|
|
1309
|
-
w-full
|
|
1310
|
-
h-full
|
|
1311
|
-
flex-1
|
|
1312
|
-
min-h-[40px]
|
|
1313
|
-
|
|
1314
|
-
|
|
1317
|
+
className={clsx(
|
|
1318
|
+
'gridContainer',
|
|
1319
|
+
'w-full',
|
|
1320
|
+
'h-full',
|
|
1321
|
+
'flex-1',
|
|
1322
|
+
'min-h-[40px]',
|
|
1323
|
+
gridContainerBorderClassName,
|
|
1324
|
+
)}
|
|
1315
1325
|
>
|
|
1316
1326
|
{grid}
|
|
1317
1327
|
</VStack>
|
|
@@ -1324,13 +1334,13 @@ function GridComponent(props) {
|
|
|
1324
1334
|
grid = <VStackNative
|
|
1325
1335
|
{...testProps(self, '-dropTarget')}
|
|
1326
1336
|
ref={dropTargetRef}
|
|
1327
|
-
className={
|
|
1328
|
-
Grid-dropTarget
|
|
1329
|
-
h-full
|
|
1330
|
-
w-full
|
|
1331
|
-
border-[#0ff]
|
|
1332
|
-
|
|
1333
|
-
|
|
1337
|
+
className={clsx(
|
|
1338
|
+
'Grid-dropTarget',
|
|
1339
|
+
'h-full',
|
|
1340
|
+
'w-full',
|
|
1341
|
+
'border-[#0ff]',
|
|
1342
|
+
canDrop && isOver ? 'border-[4px]' : 'border-[0px]',
|
|
1343
|
+
)}
|
|
1334
1344
|
>{grid}</VStackNative>
|
|
1335
1345
|
}
|
|
1336
1346
|
return grid;
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Pressable,
|
|
7
7
|
TextNative,
|
|
8
8
|
} from '@project-components/Gluestack';
|
|
9
|
+
import clsx from 'clsx';
|
|
9
10
|
import {
|
|
10
11
|
SORT_ASCENDING,
|
|
11
12
|
SORT_DESCENDING,
|
|
@@ -309,10 +310,10 @@ export default function GridHeaderRow(props) {
|
|
|
309
310
|
isSorter = isSortable && canColumnsSort && sortField === fieldName,
|
|
310
311
|
isReorderable = canColumnsReorder && configIsReorderable,
|
|
311
312
|
isResizable = canColumnsResize && configIsResizable,
|
|
312
|
-
rowClassName =
|
|
313
|
-
border-r-2
|
|
314
|
-
border-r-white
|
|
315
|
-
|
|
313
|
+
rowClassName = clsx(
|
|
314
|
+
'border-r-2',
|
|
315
|
+
'border-r-white',
|
|
316
|
+
);
|
|
316
317
|
if (isHidden) {
|
|
317
318
|
return null;
|
|
318
319
|
}
|
|
@@ -357,16 +358,16 @@ export default function GridHeaderRow(props) {
|
|
|
357
358
|
}}
|
|
358
359
|
onMouseEnter={(e) => onHeaderMouseEnter(e, ix)}
|
|
359
360
|
onMouseLeave={(e) => onHeaderMouseLeave(e, ix)}
|
|
360
|
-
className={
|
|
361
|
-
GridHeaderRow-Pressable
|
|
362
|
-
h-full
|
|
363
|
-
flex-row
|
|
364
|
-
p-0
|
|
365
|
-
items-center
|
|
366
|
-
justify-center
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
361
|
+
className={clsx(
|
|
362
|
+
'GridHeaderRow-Pressable',
|
|
363
|
+
'h-full',
|
|
364
|
+
'flex-row',
|
|
365
|
+
'p-0',
|
|
366
|
+
'items-center',
|
|
367
|
+
'justify-center',
|
|
368
|
+
rowClassName,
|
|
369
|
+
styles.GRID_HEADER_PRESSABLE_CLASSNAME,
|
|
370
|
+
)}
|
|
370
371
|
style={rowStyle}
|
|
371
372
|
>
|
|
372
373
|
{isReorderable && isOver &&
|
|
@@ -395,20 +396,20 @@ export default function GridHeaderRow(props) {
|
|
|
395
396
|
<TextNative
|
|
396
397
|
key="Text"
|
|
397
398
|
numberOfLines={1}
|
|
398
|
-
className={
|
|
399
|
-
GridHeaderRow-TextNative
|
|
400
|
-
h-auto
|
|
401
|
-
flex-1
|
|
402
|
-
items-center
|
|
403
|
-
justify-center
|
|
404
|
-
leading-tight
|
|
405
|
-
text-center
|
|
406
|
-
overflow-hidden
|
|
407
|
-
text-ellipsis
|
|
408
|
-
px-2
|
|
409
|
-
py-3
|
|
410
|
-
|
|
411
|
-
|
|
399
|
+
className={clsx(
|
|
400
|
+
'GridHeaderRow-TextNative',
|
|
401
|
+
'h-auto',
|
|
402
|
+
'flex-1',
|
|
403
|
+
'items-center',
|
|
404
|
+
'justify-center',
|
|
405
|
+
'leading-tight',
|
|
406
|
+
'text-center',
|
|
407
|
+
'overflow-hidden',
|
|
408
|
+
'text-ellipsis',
|
|
409
|
+
'px-2',
|
|
410
|
+
'py-3',
|
|
411
|
+
styles.GRID_HEADER_CLASSNAME,
|
|
412
|
+
)}
|
|
412
413
|
>{header}</TextNative>
|
|
413
414
|
|
|
414
415
|
{isSorter &&
|
|
@@ -416,12 +417,13 @@ export default function GridHeaderRow(props) {
|
|
|
416
417
|
key="Icon"
|
|
417
418
|
as={isSortDirectionAsc ? SortUp : SortDown}
|
|
418
419
|
size={styles.GRID_HEADER_ICON_SIZE}
|
|
419
|
-
className={
|
|
420
|
-
GridHeaderRow-Icon
|
|
421
|
-
text-center
|
|
422
|
-
text-grey-500
|
|
423
|
-
|
|
424
|
-
|
|
420
|
+
className={clsx(
|
|
421
|
+
'GridHeaderRow-Icon',
|
|
422
|
+
'text-center',
|
|
423
|
+
'text-grey-500',
|
|
424
|
+
styles.GRID_HEADER_ICON_CLASSNAME,
|
|
425
|
+
)}
|
|
426
|
+
/>}
|
|
425
427
|
|
|
426
428
|
{isOver && UiGlobals.mode === UI_MODE_WEB && // only works for web for now
|
|
427
429
|
<HeaderColumnSelectorHandle
|
|
@@ -488,12 +490,12 @@ export default function GridHeaderRow(props) {
|
|
|
488
490
|
style={{
|
|
489
491
|
scrollbarWidth: 'none',
|
|
490
492
|
}}
|
|
491
|
-
className={
|
|
492
|
-
GridHeaderRow-HStack
|
|
493
|
-
w-full
|
|
494
|
-
h-[40px]
|
|
495
|
-
bg-grey-200
|
|
496
|
-
|
|
493
|
+
className={clsx(
|
|
494
|
+
'GridHeaderRow-HStack',
|
|
495
|
+
'w-full',
|
|
496
|
+
'h-[40px]',
|
|
497
|
+
'bg-grey-200',
|
|
498
|
+
)}
|
|
497
499
|
>
|
|
498
500
|
{renderHeaders()}
|
|
499
501
|
</HStack>;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Text,
|
|
8
8
|
TextNative,
|
|
9
9
|
} from '@project-components/Gluestack';
|
|
10
|
+
import clsx from 'clsx';
|
|
10
11
|
import {
|
|
11
12
|
UI_MODE_WEB,
|
|
12
13
|
UI_MODE_NATIVE,
|
|
@@ -19,9 +20,8 @@ import { withDragSource, withDropTarget } from '../Hoc/withDnd.js';
|
|
|
19
20
|
import testProps from '../../Functions/testProps.js';
|
|
20
21
|
import Loading from '../Messages/Loading.js';
|
|
21
22
|
import AngleRight from '../Icons/AngleRight.js';
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import useAsyncRenderers from '../../Hooks/useAsyncRenderers.js';
|
|
23
|
+
import RowHandle from './RowHandle.js';
|
|
24
|
+
import useAsyncRenderers from './useAsyncRenderers.js';
|
|
25
25
|
import _ from 'lodash';
|
|
26
26
|
|
|
27
27
|
// Conditional import for web only
|
|
@@ -44,7 +44,6 @@ function GridRow(props) {
|
|
|
44
44
|
rowProps,
|
|
45
45
|
hideNavColumn,
|
|
46
46
|
showSelectHandle,
|
|
47
|
-
isRowSelectable,
|
|
48
47
|
isRowHoverable,
|
|
49
48
|
isSelected,
|
|
50
49
|
isHovered,
|
|
@@ -101,7 +100,7 @@ function GridRow(props) {
|
|
|
101
100
|
actualCanDrop = validateDrop(draggedItem);
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
if (
|
|
103
|
+
if (showSelectHandle && isSelected) {
|
|
105
104
|
if (showHovers && isHovered) {
|
|
106
105
|
mixWith = styles.GRID_ROW_SELECTED_BG_HOVER;
|
|
107
106
|
} else {
|
|
@@ -133,16 +132,16 @@ function GridRow(props) {
|
|
|
133
132
|
propsToPass = columnProps[key] || {},
|
|
134
133
|
colStyle = {},
|
|
135
134
|
whichCursor = showSelectHandle ? 'cursor-text' : 'cursor-pointer'; // when using rowSelectHandle, indicate that the row text is selectable, otherwise indicate that the row itself is selectable
|
|
136
|
-
let colClassName =
|
|
137
|
-
GridRow-column
|
|
138
|
-
p-1
|
|
139
|
-
justify-center
|
|
140
|
-
border-r-black-100
|
|
141
|
-
block
|
|
142
|
-
overflow-auto
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
135
|
+
let colClassName = clsx(
|
|
136
|
+
'GridRow-column',
|
|
137
|
+
'p-1',
|
|
138
|
+
'justify-center',
|
|
139
|
+
'border-r-black-100',
|
|
140
|
+
'block',
|
|
141
|
+
'overflow-auto',
|
|
142
|
+
whichCursor,
|
|
143
|
+
styles.GRID_ROW_MAX_HEIGHT_EXTRA,
|
|
144
|
+
);
|
|
146
145
|
if (isOnlyOneVisibleColumn) {
|
|
147
146
|
colClassName = ' w-full';
|
|
148
147
|
} else {
|
|
@@ -197,13 +196,33 @@ function GridRow(props) {
|
|
|
197
196
|
};
|
|
198
197
|
|
|
199
198
|
let content = null;
|
|
199
|
+
let textClassName = clsx(
|
|
200
|
+
'GridRow-TextNative',
|
|
201
|
+
'self-center',
|
|
202
|
+
'overflow-hidden',
|
|
203
|
+
colClassName,
|
|
204
|
+
styles.GRID_CELL_CLASSNAME,
|
|
205
|
+
styles.GRID_ROW_MAX_HEIGHT_EXTRA,
|
|
206
|
+
);
|
|
207
|
+
if (config.className) {
|
|
208
|
+
textClassName += ' ' + config.className;
|
|
209
|
+
}
|
|
210
|
+
const rendererProps = {
|
|
211
|
+
...testProps('rendererCol-' + config.fieldName),
|
|
212
|
+
className: textClassName,
|
|
213
|
+
...propsToPass,
|
|
214
|
+
...extraProps,
|
|
215
|
+
style: colStyle,
|
|
216
|
+
};
|
|
200
217
|
if (config.isAsync) {
|
|
218
|
+
// TODO: Figure out how to pass the rendererProps to the async renderer function
|
|
219
|
+
throw Error('Not yet working correctly!');
|
|
201
220
|
// Async renderer
|
|
202
221
|
if (isLoading) {
|
|
203
222
|
content = <Loading />;
|
|
204
223
|
} else if (asyncResult) {
|
|
205
224
|
if (asyncResult.error) {
|
|
206
|
-
content = <Text>Render Error: {asyncResult.error.message || String(asyncResult.error)}</Text>;
|
|
225
|
+
content = <Text key={key}>Render Error: {asyncResult.error.message || String(asyncResult.error)}</Text>;
|
|
207
226
|
} else {
|
|
208
227
|
content = asyncResult.result;
|
|
209
228
|
}
|
|
@@ -211,24 +230,17 @@ function GridRow(props) {
|
|
|
211
230
|
} else {
|
|
212
231
|
// Synchronous renderer
|
|
213
232
|
try {
|
|
214
|
-
const result = config.renderer(item);
|
|
233
|
+
const result = config.renderer(item, config.fieldName, rendererProps, key);
|
|
215
234
|
if (result && typeof result.then === 'function') {
|
|
216
|
-
content = <Text>Error: Async renderer not properly configured</Text>;
|
|
235
|
+
content = <Text key={key}>Error: Async renderer not properly configured</Text>;
|
|
217
236
|
} else {
|
|
218
237
|
content = result;
|
|
219
238
|
}
|
|
220
239
|
} catch (error) {
|
|
221
|
-
content = <Text>Render Error: {error}</Text>;
|
|
240
|
+
content = <Text key={key}>Render Error: {error}</Text>;
|
|
222
241
|
}
|
|
223
242
|
}
|
|
224
|
-
return
|
|
225
|
-
key={key}
|
|
226
|
-
{...testProps('rendererCol-' + key)}
|
|
227
|
-
className={colClassName}
|
|
228
|
-
{...propsToPass}
|
|
229
|
-
{...extraProps}
|
|
230
|
-
style={colStyle}
|
|
231
|
-
>{content}</HStackNative>;
|
|
243
|
+
return content;
|
|
232
244
|
}
|
|
233
245
|
if (config.fieldName) {
|
|
234
246
|
|
|
@@ -248,18 +260,18 @@ function GridRow(props) {
|
|
|
248
260
|
if (config.getCellProps) {
|
|
249
261
|
_.assign(cellProps, config.getCellProps(item));
|
|
250
262
|
}
|
|
251
|
-
let elementClassName =
|
|
252
|
-
GridRow-Element
|
|
253
|
-
self-center
|
|
254
|
-
text-ellipsis
|
|
255
|
-
px-2
|
|
256
|
-
py-3
|
|
257
|
-
block
|
|
258
|
-
overflow-scroll
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
+
let elementClassName = clsx(
|
|
264
|
+
'GridRow-Element',
|
|
265
|
+
'self-center',
|
|
266
|
+
'text-ellipsis',
|
|
267
|
+
'px-2',
|
|
268
|
+
'py-3',
|
|
269
|
+
'block',
|
|
270
|
+
'overflow-scroll',
|
|
271
|
+
colClassName,
|
|
272
|
+
styles.GRID_CELL_CLASSNAME,
|
|
273
|
+
styles.GRID_ROW_MAX_HEIGHT_NORMAL,
|
|
274
|
+
);
|
|
263
275
|
if (config.className) {
|
|
264
276
|
elementClassName += ' ' + config.className;
|
|
265
277
|
}
|
|
@@ -309,14 +321,14 @@ function GridRow(props) {
|
|
|
309
321
|
if (config.getCellProps) {
|
|
310
322
|
_.assign(elementProps, config.getCellProps(item));
|
|
311
323
|
}
|
|
312
|
-
let textClassName =
|
|
313
|
-
GridRow-TextNative
|
|
314
|
-
self-center
|
|
315
|
-
overflow-hidden
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
324
|
+
let textClassName = clsx(
|
|
325
|
+
'GridRow-TextNative',
|
|
326
|
+
'self-center',
|
|
327
|
+
'overflow-hidden',
|
|
328
|
+
colClassName,
|
|
329
|
+
styles.GRID_CELL_CLASSNAME,
|
|
330
|
+
styles.GRID_ROW_MAX_HEIGHT_EXTRA,
|
|
331
|
+
);
|
|
320
332
|
if (config.className) {
|
|
321
333
|
textClassName += ' ' + config.className;
|
|
322
334
|
}
|
|
@@ -341,20 +353,25 @@ function GridRow(props) {
|
|
|
341
353
|
};
|
|
342
354
|
|
|
343
355
|
let rowContents = <>
|
|
344
|
-
{(isDragSource || isDraggable) &&
|
|
345
|
-
|
|
356
|
+
{(isDragSource || isDraggable || showSelectHandle) &&
|
|
357
|
+
<RowHandle
|
|
358
|
+
ref={dragSourceRef}
|
|
359
|
+
isDragSource={isDragSource}
|
|
360
|
+
isDraggable={isDraggable}
|
|
361
|
+
showSelectHandle={showSelectHandle}
|
|
362
|
+
/>}
|
|
346
363
|
|
|
347
364
|
{isPhantom &&
|
|
348
365
|
<Box
|
|
349
|
-
className={
|
|
350
|
-
GridRow-phantom
|
|
351
|
-
absolute
|
|
352
|
-
h-2
|
|
353
|
-
w-2
|
|
354
|
-
top-0
|
|
355
|
-
left-0
|
|
356
|
-
bg-[#f00]
|
|
357
|
-
|
|
366
|
+
className={clsx(
|
|
367
|
+
'GridRow-phantom',
|
|
368
|
+
'absolute',
|
|
369
|
+
'h-2',
|
|
370
|
+
'w-2',
|
|
371
|
+
'top-0',
|
|
372
|
+
'left-0',
|
|
373
|
+
'bg-[#f00]',
|
|
374
|
+
)}
|
|
358
375
|
/>}
|
|
359
376
|
|
|
360
377
|
{renderColumns(item)}
|
|
@@ -363,49 +380,34 @@ function GridRow(props) {
|
|
|
363
380
|
<Icon
|
|
364
381
|
as={AngleRight}
|
|
365
382
|
variant="outline"
|
|
366
|
-
className={
|
|
367
|
-
GridRow-Icon
|
|
368
|
-
w-30
|
|
369
|
-
self-center
|
|
370
|
-
mx-3
|
|
371
|
-
|
|
372
|
-
|
|
383
|
+
className={clsx(
|
|
384
|
+
'GridRow-Icon',
|
|
385
|
+
'w-30',
|
|
386
|
+
'self-center',
|
|
387
|
+
'mx-3',
|
|
388
|
+
styles.GRID_NAV_COLUMN_COLOR,
|
|
389
|
+
)}
|
|
373
390
|
/>}
|
|
374
391
|
</>;
|
|
375
|
-
|
|
376
|
-
if (dragSourceRef) {
|
|
377
|
-
rowContents = <HStack
|
|
378
|
-
ref={dragSourceRef}
|
|
379
|
-
className={`
|
|
380
|
-
GridRow-dragSourceRef
|
|
381
|
-
w-full
|
|
382
|
-
flex-1
|
|
383
|
-
grow-1
|
|
384
|
-
`}
|
|
385
|
-
style={{
|
|
386
|
-
backgroundColor: bg,
|
|
387
|
-
}}
|
|
388
|
-
>{rowContents}</HStack>;
|
|
389
|
-
}
|
|
390
392
|
if (dropTargetRef) {
|
|
391
393
|
rowContents = <HStack
|
|
392
394
|
ref={dropTargetRef}
|
|
393
|
-
className={
|
|
394
|
-
GridRow-dropTargetRef
|
|
395
|
-
w-full
|
|
396
|
-
flex-1
|
|
397
|
-
grow-1
|
|
398
|
-
|
|
395
|
+
className={clsx(
|
|
396
|
+
'GridRow-dropTargetRef',
|
|
397
|
+
'w-full',
|
|
398
|
+
'flex-1',
|
|
399
|
+
'grow-1',
|
|
400
|
+
)}
|
|
399
401
|
style={{
|
|
400
402
|
backgroundColor: bg,
|
|
401
403
|
}}
|
|
402
404
|
>{rowContents}</HStack>;
|
|
403
405
|
}
|
|
404
406
|
|
|
405
|
-
let rowClassName =
|
|
406
|
-
GridRow-HStackNative
|
|
407
|
-
items-center
|
|
408
|
-
|
|
407
|
+
let rowClassName = clsx(
|
|
408
|
+
'GridRow-HStackNative',
|
|
409
|
+
'items-center',
|
|
410
|
+
);
|
|
409
411
|
if (isOnlyOneVisibleColumn) {
|
|
410
412
|
rowClassName += ' w-full';
|
|
411
413
|
}
|