@onehat/ui 0.4.14 → 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.
- package/package.json +1 -1
- package/src/Components/Form/Field/Tag/Tag.js +1 -1
- package/src/Components/Form/Field/Tag/ValueBox.js +10 -2
- package/src/Components/Grid/Grid.js +12 -5
- package/src/Components/Grid/GridRow.js +0 -1
- package/src/Components/Hoc/withContextMenu.js +7 -9
- package/src/Components/Viewer/Viewer.js +17 -7
- package/src/Constants/Styles.js +4 -0
package/package.json
CHANGED
|
@@ -291,7 +291,7 @@ function TagComponent(props) {
|
|
|
291
291
|
if (minimizeForRow) {
|
|
292
292
|
if (isViewOnly) {
|
|
293
293
|
// combo is not shown, so allow valueBoxes to take up more space
|
|
294
|
-
valueBoxesClassName += '
|
|
294
|
+
valueBoxesClassName += ' min-h-[25px] h-full overflow-auto flex-1';
|
|
295
295
|
} else {
|
|
296
296
|
// shrink both down
|
|
297
297
|
valueBoxesClassName += ' h-auto min-h-[25px] max-h-[25px] overflow-auto flex-1';
|
|
@@ -38,7 +38,11 @@ export default function ValueBox(props) {
|
|
|
38
38
|
className: 'text-grey-600',
|
|
39
39
|
}}
|
|
40
40
|
onPress={onView}
|
|
41
|
-
className=
|
|
41
|
+
className={`
|
|
42
|
+
ValueBox-eyeBtn
|
|
43
|
+
h-full
|
|
44
|
+
${styles.FORM_TAG_BTN_CLASSNAME}
|
|
45
|
+
`}
|
|
42
46
|
/>
|
|
43
47
|
<Text
|
|
44
48
|
className={`
|
|
@@ -57,7 +61,11 @@ export default function ValueBox(props) {
|
|
|
57
61
|
className: 'text-grey-600',
|
|
58
62
|
}}
|
|
59
63
|
onPress={onDelete}
|
|
60
|
-
className=
|
|
64
|
+
className={`
|
|
65
|
+
ValueBox-xBtn
|
|
66
|
+
h-full
|
|
67
|
+
${styles.FORM_TAG_BTN_CLASSNAME}
|
|
68
|
+
`}
|
|
61
69
|
/>}
|
|
62
70
|
</HStackNative>;
|
|
63
71
|
}
|
|
@@ -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=
|
|
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
|
|
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 (_.
|
|
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(
|
|
976
|
+
_.each(columnsConfigVariable, (columnConfig) => {
|
|
970
977
|
if (!_.isPlainObject(columnConfig)) {
|
|
971
978
|
localColumnsConfig.push(columnConfig);
|
|
972
979
|
return;
|
|
@@ -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({
|
|
@@ -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="
|
|
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="
|
|
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="
|
|
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
|
-
|
|
385
|
+
style={style}
|
|
377
386
|
onLayout={onLayout}
|
|
387
|
+
className={className}
|
|
378
388
|
>
|
|
379
389
|
{containerWidth && <>
|
|
380
390
|
|
package/src/Constants/Styles.js
CHANGED
|
@@ -9,6 +9,8 @@ const
|
|
|
9
9
|
|
|
10
10
|
const defaults = {
|
|
11
11
|
ATTACHMENTS_MAX_FILESIZE: 1024 * 1024 * 5, // 5MB
|
|
12
|
+
CONTEXT_MENU_WIDTH: 180,
|
|
13
|
+
CONTEXT_MENU_ITEM_HEIGHT: 30,
|
|
12
14
|
DEFAULT_WINDOW_WIDTH: 900,
|
|
13
15
|
DEFAULT_WINDOW_HEIGHT: 800,
|
|
14
16
|
FILTER_LABEL_CLASSNAME: 'text-' + DEFAULT_FONTSIZE,
|
|
@@ -51,6 +53,7 @@ const defaults = {
|
|
|
51
53
|
FORM_TAG_CLASSNAME: '',
|
|
52
54
|
FORM_TAG_VALUEBOX_CLASSNAME: 'text-' + DEFAULT_FONTSIZE,
|
|
53
55
|
FORM_TAG_VALUEBOX_ICON_SIZE: 'sm',
|
|
56
|
+
FORM_TAG_BTN_CLASSNAME: '',
|
|
54
57
|
FORM_TEXT_CLASSNAME: 'text-' + DEFAULT_FONTSIZE,
|
|
55
58
|
FORM_TEXTAREA_CLASSNAME: 'bg-' + WHITE + ' ' +
|
|
56
59
|
'text-' + DEFAULT_FONTSIZE + ' ' +
|
|
@@ -63,6 +66,7 @@ const defaults = {
|
|
|
63
66
|
FORM_ONE_COLUMN_THRESHOLD: 900, // only allow one column in form unless form is wider than this
|
|
64
67
|
FORM_STACK_ROW_THRESHOLD: 400, // stack labels & fields if row is less than this width
|
|
65
68
|
GRID_CELL_CLASSNAME: 'text-' + DEFAULT_FONTSIZE,
|
|
69
|
+
GRID_EXPAND_BTN_CLASSNAME: '',
|
|
66
70
|
GRID_HEADER_PRESSABLE_CLASSNAME: 'bg-[#eee] ' +
|
|
67
71
|
'hover:bg-[#ddd]',
|
|
68
72
|
GRID_HEADER_CLASSNAME: 'text-' + DEFAULT_FONTSIZE,
|