@onehat/ui 0.4.9 → 0.4.10
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/Combo/Combo.js +21 -15
- package/src/Components/Form/Field/Date.js +4 -1
- package/src/Components/Form/Field/Input.js +4 -8
- package/src/Components/Form/Field/Slider.js +17 -13
- package/src/Components/Form/Field/Tag/Tag.js +12 -4
- package/src/Components/Form/Field/TextArea.js +2 -1
- package/src/Components/Form/FieldSet.js +2 -2
- package/src/Components/Form/Form.js +11 -6
- package/src/Components/Grid/Grid.js +4 -2
- package/src/Components/Grid/GridRow.js +5 -7
- package/src/Components/Hoc/withAlert.js +3 -1
- package/src/Components/Hoc/withPresetButtons.js +7 -6
package/package.json
CHANGED
|
@@ -55,6 +55,7 @@ export function ComboComponent(props) {
|
|
|
55
55
|
isEditor = false,
|
|
56
56
|
isDisabled = false,
|
|
57
57
|
isInTag = false,
|
|
58
|
+
minimizeForRow = false,
|
|
58
59
|
tooltipPlacement = 'bottom',
|
|
59
60
|
placeholder,
|
|
60
61
|
onRowPress,
|
|
@@ -542,28 +543,29 @@ export function ComboComponent(props) {
|
|
|
542
543
|
`}
|
|
543
544
|
/>;
|
|
544
545
|
}
|
|
546
|
+
const triggerClassName = `
|
|
547
|
+
Combo-trigger
|
|
548
|
+
h-full
|
|
549
|
+
border
|
|
550
|
+
border-l-0
|
|
551
|
+
border-gray-400
|
|
552
|
+
rounded-l-none
|
|
553
|
+
rounded-r-md
|
|
554
|
+
${styles.FORM_COMBO_TRIGGER_BG}
|
|
555
|
+
${styles.FORM_COMBO_TRIGGER_BG_HOVER}
|
|
556
|
+
`;
|
|
545
557
|
trigger = <IconButton
|
|
546
558
|
{...testProps('trigger')}
|
|
547
559
|
ref={triggerRef}
|
|
548
560
|
icon={CaretDown}
|
|
549
561
|
_icon={{
|
|
550
|
-
size: '
|
|
562
|
+
size: 'md',
|
|
551
563
|
className: 'text-grey-500',
|
|
552
564
|
}}
|
|
553
565
|
isDisabled={isDisabled}
|
|
554
566
|
onPress={onTriggerPress}
|
|
555
567
|
onBlur={onTriggerBlur}
|
|
556
|
-
className={
|
|
557
|
-
trigger
|
|
558
|
-
h-full
|
|
559
|
-
border
|
|
560
|
-
border-l-0
|
|
561
|
-
border-gray-400
|
|
562
|
-
rounded-l-none
|
|
563
|
-
rounded-r-md
|
|
564
|
-
${styles.FORM_COMBO_TRIGGER_BG}
|
|
565
|
-
${styles.FORM_COMBO_TRIGGER_BG_HOVER}
|
|
566
|
-
`}
|
|
568
|
+
className={triggerClassName}
|
|
567
569
|
/>;
|
|
568
570
|
|
|
569
571
|
if (UiGlobals.mode === UI_MODE_WEB) {
|
|
@@ -619,6 +621,7 @@ export function ComboComponent(props) {
|
|
|
619
621
|
grow
|
|
620
622
|
h-full
|
|
621
623
|
min-h-0
|
|
624
|
+
max-h-[40px]
|
|
622
625
|
flex-1
|
|
623
626
|
m-0
|
|
624
627
|
rounded-tr-none
|
|
@@ -1009,16 +1012,19 @@ export function ComboComponent(props) {
|
|
|
1009
1012
|
refProps.ref = tooltipRef;
|
|
1010
1013
|
}
|
|
1011
1014
|
|
|
1012
|
-
|
|
1015
|
+
let className = `
|
|
1013
1016
|
Combo-HStack
|
|
1014
1017
|
flex-1
|
|
1015
1018
|
h-[40px]
|
|
1016
1019
|
min-h-[40px]
|
|
1017
1020
|
justify-center
|
|
1018
|
-
items-
|
|
1021
|
+
items-stretch
|
|
1019
1022
|
`;
|
|
1020
1023
|
if (props.className) {
|
|
1021
|
-
|
|
1024
|
+
className += ' ' + props.className;
|
|
1025
|
+
}
|
|
1026
|
+
if (minimizeForRow) {
|
|
1027
|
+
className += ' h-auto min-h-0 max-h-[40px]';
|
|
1022
1028
|
}
|
|
1023
1029
|
|
|
1024
1030
|
if (isRendered && additionalButtons?.length && containerWidth < 500) {
|
|
@@ -48,6 +48,7 @@ export const DateElement = forwardRef((props, ref) => {
|
|
|
48
48
|
_input = {},
|
|
49
49
|
isDisabled = false,
|
|
50
50
|
limitWidth = false,
|
|
51
|
+
minimizeForRow = false,
|
|
51
52
|
minValue,
|
|
52
53
|
maxValue,
|
|
53
54
|
testID,
|
|
@@ -219,7 +220,6 @@ export const DateElement = forwardRef((props, ref) => {
|
|
|
219
220
|
}
|
|
220
221
|
};
|
|
221
222
|
|
|
222
|
-
|
|
223
223
|
useEffect(() => {
|
|
224
224
|
|
|
225
225
|
// When value changes from outside, adjust text value
|
|
@@ -576,6 +576,9 @@ export const DateElement = forwardRef((props, ref) => {
|
|
|
576
576
|
if (props.className) {
|
|
577
577
|
className += props.className;
|
|
578
578
|
}
|
|
579
|
+
if (minimizeForRow) {
|
|
580
|
+
className += ' h-auto min-h-0 max-h-[50px]';
|
|
581
|
+
}
|
|
579
582
|
const style = props.style || {};
|
|
580
583
|
if (!_.isNil(height)) {
|
|
581
584
|
style.height = height;
|
|
@@ -30,6 +30,7 @@ const InputElement = forwardRef((props, ref) => {
|
|
|
30
30
|
rightIcon,
|
|
31
31
|
rightIconHandler,
|
|
32
32
|
placeholder,
|
|
33
|
+
className,
|
|
33
34
|
...propsToPass
|
|
34
35
|
} = props,
|
|
35
36
|
styles = UiGlobals.styles,
|
|
@@ -109,10 +110,6 @@ const InputElement = forwardRef((props, ref) => {
|
|
|
109
110
|
if (!disableAutoFlex && !hasWidth(props) && !hasFlex(props)) {
|
|
110
111
|
style.flex = 1;
|
|
111
112
|
}
|
|
112
|
-
// flex-1
|
|
113
|
-
// block
|
|
114
|
-
// h-auto
|
|
115
|
-
// h-[10px]
|
|
116
113
|
let inputClassName = `
|
|
117
114
|
Input
|
|
118
115
|
${styles.FORM_INPUT_BG}
|
|
@@ -125,15 +122,14 @@ const InputElement = forwardRef((props, ref) => {
|
|
|
125
122
|
h-auto
|
|
126
123
|
w-full
|
|
127
124
|
p-2
|
|
128
|
-
text-
|
|
125
|
+
text-center
|
|
129
126
|
${styles.FORM_INPUT_FONTSIZE}
|
|
130
127
|
${styles.FORM_INPUT_BG}
|
|
131
128
|
${styles.FORM_INPUT_BG_FOCUS}
|
|
132
129
|
${styles.FORM_INPUT_BG_HOVER}
|
|
133
130
|
`;
|
|
134
|
-
if (
|
|
135
|
-
inputClassName +=
|
|
136
|
-
inputFieldClassName += props.className;
|
|
131
|
+
if (className) {
|
|
132
|
+
inputClassName += className;
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
return <Input
|
|
@@ -30,6 +30,7 @@ const
|
|
|
30
30
|
maxValue = 100,
|
|
31
31
|
step = 10,
|
|
32
32
|
autoSubmitDelay = UiGlobals.autoSubmitDelay,
|
|
33
|
+
minimizeForRow = false,
|
|
33
34
|
tooltip = null,
|
|
34
35
|
isDisabled = false,
|
|
35
36
|
testID,
|
|
@@ -150,12 +151,24 @@ const
|
|
|
150
151
|
}
|
|
151
152
|
|
|
152
153
|
let className = `
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
w-full
|
|
155
|
+
items-center
|
|
156
|
+
`,
|
|
157
|
+
inputClassName = `
|
|
158
|
+
InputWithTooltip
|
|
159
|
+
h-full
|
|
160
|
+
w-[60px]
|
|
161
|
+
mr-4
|
|
162
|
+
text-center
|
|
163
|
+
rounded-md
|
|
164
|
+
${styles.SLIDER_READOUT_FONTSIZE}
|
|
165
|
+
`;
|
|
156
166
|
if (props.className) {
|
|
157
167
|
className += ' ' + props.className;
|
|
158
168
|
}
|
|
169
|
+
if (minimizeForRow) {
|
|
170
|
+
inputClassName += ' h-auto min-h-0 max-h-[50px] mr-1';
|
|
171
|
+
}
|
|
159
172
|
|
|
160
173
|
return <HStack
|
|
161
174
|
className={className}
|
|
@@ -168,16 +181,7 @@ const
|
|
|
168
181
|
onKeyPress={onInputKeyPress}
|
|
169
182
|
isDisabled={isDisabled}
|
|
170
183
|
disableAutoFlex={true}
|
|
171
|
-
className={
|
|
172
|
-
InputWithTooltip
|
|
173
|
-
h-full
|
|
174
|
-
w-[50px]
|
|
175
|
-
p-2
|
|
176
|
-
mr-4
|
|
177
|
-
text-center
|
|
178
|
-
rounded-md
|
|
179
|
-
${styles.SLIDER_READOUT_FONTSIZE}
|
|
180
|
-
`}
|
|
184
|
+
className={inputClassName}
|
|
181
185
|
{...props._input}
|
|
182
186
|
/>
|
|
183
187
|
<HStack className="flex-1">
|
|
@@ -22,7 +22,6 @@ function TagComponent(props) {
|
|
|
22
22
|
isViewOnly = false,
|
|
23
23
|
isValueAlwaysArray,
|
|
24
24
|
isValueAsStringifiedJson,
|
|
25
|
-
isFilter = false,
|
|
26
25
|
minimizeForRow = false,
|
|
27
26
|
Editor,
|
|
28
27
|
_combo = {},
|
|
@@ -286,12 +285,20 @@ function TagComponent(props) {
|
|
|
286
285
|
${styles.FORM_TAG_PADDING}
|
|
287
286
|
`,
|
|
288
287
|
comboClassName = '';
|
|
288
|
+
if (_combo.className) {
|
|
289
|
+
comboClassName = _combo.className;
|
|
290
|
+
}
|
|
289
291
|
if (minimizeForRow) {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
+
if (isViewOnly) {
|
|
293
|
+
// combo is not shown, so allow valueBoxes to take up more space
|
|
294
|
+
valueBoxesClassName += ' h-auto min-h-[50px] max-h-[50px] overflow-auto flex-1';
|
|
295
|
+
} else {
|
|
296
|
+
// shrink both down
|
|
297
|
+
valueBoxesClassName += ' h-auto min-h-[25px] max-h-[25px] overflow-auto flex-1';
|
|
298
|
+
comboClassName += ' h-auto min-h-0 max-h-[25px] flex-1';
|
|
299
|
+
}
|
|
292
300
|
}
|
|
293
301
|
|
|
294
|
-
|
|
295
302
|
return <VStack
|
|
296
303
|
className={className}
|
|
297
304
|
style={style}
|
|
@@ -311,6 +318,7 @@ function TagComponent(props) {
|
|
|
311
318
|
tooltip={tooltip}
|
|
312
319
|
usePermissions={props.usePermissions}
|
|
313
320
|
{..._combo}
|
|
321
|
+
className={comboClassName}
|
|
314
322
|
/>}
|
|
315
323
|
</VStack>;
|
|
316
324
|
|
|
@@ -91,7 +91,8 @@ const
|
|
|
91
91
|
inputClassName += ' ' + props.className;
|
|
92
92
|
}
|
|
93
93
|
if (minimizeForRow) {
|
|
94
|
-
textareaClassName += ' max-h-[
|
|
94
|
+
textareaClassName += ' h-auto min-h-0 max-h-[40px] overflow-auto';
|
|
95
|
+
inputClassName += ' py-0';
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
return <Textarea className={textareaClassName}>
|
|
@@ -76,7 +76,7 @@ export default function FieldSet(props) {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
let className = `
|
|
80
80
|
FieldSet-Box
|
|
81
81
|
mb-4
|
|
82
82
|
mx-0
|
|
@@ -86,7 +86,7 @@ export default function FieldSet(props) {
|
|
|
86
86
|
${styles.FORM_FIELDSET_BG}
|
|
87
87
|
`;
|
|
88
88
|
if (props.className) {
|
|
89
|
-
|
|
89
|
+
className += props.className;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
|
|
@@ -315,6 +315,7 @@ function Form(props) {
|
|
|
315
315
|
let element = <Element
|
|
316
316
|
{...testProps('field-' + fieldName)}
|
|
317
317
|
value={value}
|
|
318
|
+
minimizeForRow={true}
|
|
318
319
|
parent={self}
|
|
319
320
|
reference={fieldName}
|
|
320
321
|
{...configPropsToPass}
|
|
@@ -1150,16 +1151,15 @@ function Form(props) {
|
|
|
1150
1151
|
if (!isEditorViewOnly && !hideResetButton) {
|
|
1151
1152
|
showResetBtn = true;
|
|
1152
1153
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1154
|
+
// determine whether we should show the close or cancel button
|
|
1155
|
+
if (editorType !== EDITOR_TYPE__SIDE) {
|
|
1155
1156
|
if (isEditorViewOnly) {
|
|
1156
1157
|
showCloseBtn = true;
|
|
1157
1158
|
} else {
|
|
1158
|
-
const formIsDirty = formState.isDirty;
|
|
1159
1159
|
// if (editorType === EDITOR_TYPE__WINDOWED && onCancel) {
|
|
1160
1160
|
// showCancelBtn = true;
|
|
1161
1161
|
// }
|
|
1162
|
-
if (
|
|
1162
|
+
if (formState.isDirty || isPhantom) {
|
|
1163
1163
|
if (isSingle && onCancel) {
|
|
1164
1164
|
showCancelBtn = true;
|
|
1165
1165
|
}
|
|
@@ -1169,6 +1169,11 @@ function Form(props) {
|
|
|
1169
1169
|
}
|
|
1170
1170
|
}
|
|
1171
1171
|
}
|
|
1172
|
+
} else {
|
|
1173
|
+
// side editor only
|
|
1174
|
+
if (isPhantom && isSingle && onCancel) {
|
|
1175
|
+
showCancelBtn = true;
|
|
1176
|
+
}
|
|
1172
1177
|
}
|
|
1173
1178
|
if (!isEditorViewOnly && onSave) {
|
|
1174
1179
|
showSaveBtn = true;
|
|
@@ -1208,7 +1213,7 @@ function Form(props) {
|
|
|
1208
1213
|
<Button
|
|
1209
1214
|
{...testProps('cancelBtn')}
|
|
1210
1215
|
key="cancelBtn"
|
|
1211
|
-
variant=
|
|
1216
|
+
variant={editorType === EDITOR_TYPE__INLINE ? 'solid' : 'outline'}
|
|
1212
1217
|
onPress={onCancel}
|
|
1213
1218
|
className="text-white mr-2"
|
|
1214
1219
|
text="Cancel"
|
|
@@ -1218,7 +1223,7 @@ function Form(props) {
|
|
|
1218
1223
|
<Button
|
|
1219
1224
|
{...testProps('closeBtn')}
|
|
1220
1225
|
key="closeBtn"
|
|
1221
|
-
variant=
|
|
1226
|
+
variant={editorType === EDITOR_TYPE__INLINE ? 'solid' : 'outline'}
|
|
1222
1227
|
onPress={onClose}
|
|
1223
1228
|
className="text-white mr-2"
|
|
1224
1229
|
text="Close"
|
|
@@ -107,6 +107,7 @@ const
|
|
|
107
107
|
|
|
108
108
|
function GridComponent(props) {
|
|
109
109
|
const {
|
|
110
|
+
|
|
110
111
|
columnsConfig = [], // json configurations for each column
|
|
111
112
|
columnProps = {},
|
|
112
113
|
defaultHiddenColumns = [],
|
|
@@ -1177,13 +1178,14 @@ function GridComponent(props) {
|
|
|
1177
1178
|
/>;
|
|
1178
1179
|
|
|
1179
1180
|
if (CURRENT_MODE === UI_MODE_WEB) {
|
|
1181
|
+
// fix scrolling bug on nested FlatLists (inner one would not scroll without this)
|
|
1180
1182
|
grid = <ScrollView
|
|
1181
1183
|
horizontal={false}
|
|
1182
|
-
className="ScrollView"
|
|
1184
|
+
className="ScrollView overflow-auto"
|
|
1183
1185
|
contentContainerStyle={{
|
|
1184
1186
|
height: '100%',
|
|
1185
1187
|
}}
|
|
1186
|
-
>{grid}</ScrollView>;
|
|
1188
|
+
>{grid}</ScrollView>;
|
|
1187
1189
|
} else
|
|
1188
1190
|
if (CURRENT_MODE === UI_MODE_NATIVE) {
|
|
1189
1191
|
grid = <ScrollView className="flex-1 w-full">{grid}</ScrollView>
|
|
@@ -250,8 +250,8 @@ function GridRow(props) {
|
|
|
250
250
|
className={`
|
|
251
251
|
GridRow-phantom
|
|
252
252
|
absolute
|
|
253
|
-
h-
|
|
254
|
-
w-
|
|
253
|
+
h-2
|
|
254
|
+
w-2
|
|
255
255
|
top-0
|
|
256
256
|
left-0
|
|
257
257
|
bg-[#f00]
|
|
@@ -310,14 +310,12 @@ function GridRow(props) {
|
|
|
310
310
|
if (isOnlyOneVisibleColumn) {
|
|
311
311
|
rowClassName += ' w-full';
|
|
312
312
|
}
|
|
313
|
-
if (isOver) {
|
|
314
|
-
rowClassName += ' border-4 border-[#0ff]';
|
|
315
|
-
} else {
|
|
316
|
-
rowClassName += ' border-b border-b-grey-100';
|
|
317
|
-
}
|
|
318
313
|
if (rowProps?.className) {
|
|
319
314
|
rowClassName += ' ' + rowProps.className;
|
|
320
315
|
}
|
|
316
|
+
if (isOver) {
|
|
317
|
+
rowClassName += ' border-4 border-[#0ff]';
|
|
318
|
+
}
|
|
321
319
|
return <HStackNative
|
|
322
320
|
{...testProps('row' + (isSelected ? '-selected' : ''))}
|
|
323
321
|
{...rowProps}
|
|
@@ -188,7 +188,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
188
188
|
case ADD:
|
|
189
189
|
key = 'addBtn';
|
|
190
190
|
text = 'Add';
|
|
191
|
-
handler = onAdd;
|
|
191
|
+
handler = (parent, e) => onAdd();
|
|
192
192
|
icon = Plus;
|
|
193
193
|
if (selectorId && !selectorSelected) {
|
|
194
194
|
isDisabled = true;
|
|
@@ -200,7 +200,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
200
200
|
case EDIT:
|
|
201
201
|
key = 'editBtn';
|
|
202
202
|
text = 'Edit';
|
|
203
|
-
handler = onEdit;
|
|
203
|
+
handler = (parent, e) => onEdit();
|
|
204
204
|
icon = Edit;
|
|
205
205
|
if (selectorId && !selectorSelected) {
|
|
206
206
|
isDisabled = true;
|
|
@@ -216,6 +216,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
216
216
|
key = 'deleteBtn';
|
|
217
217
|
text = 'Delete';
|
|
218
218
|
handler = onDelete;
|
|
219
|
+
handler = (parent, e) => onDelete();
|
|
219
220
|
icon = Trash;
|
|
220
221
|
if (selectorId && !selectorSelected) {
|
|
221
222
|
isDisabled = true;
|
|
@@ -236,7 +237,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
236
237
|
case VIEW:
|
|
237
238
|
key = 'viewBtn';
|
|
238
239
|
text = 'View';
|
|
239
|
-
handler = onView;
|
|
240
|
+
handler = (parent, e) => onView();
|
|
240
241
|
icon = Eye;
|
|
241
242
|
isDisabled = !selection.length || selection.length !== 1;
|
|
242
243
|
if (selectorId && !selectorSelected) {
|
|
@@ -249,7 +250,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
249
250
|
case COPY:
|
|
250
251
|
key = 'copyBtn';
|
|
251
252
|
text = 'Copy to Clipboard';
|
|
252
|
-
handler = onCopyToClipboard;
|
|
253
|
+
handler = (parent, e) => onCopyToClipboard();
|
|
253
254
|
icon = Clipboard;
|
|
254
255
|
isDisabled = !selection.length;
|
|
255
256
|
if (selectorId && !selectorSelected) {
|
|
@@ -262,7 +263,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
262
263
|
case DUPLICATE:
|
|
263
264
|
key = 'duplicateBtn';
|
|
264
265
|
text = 'Duplicate';
|
|
265
|
-
handler = onDuplicate;
|
|
266
|
+
handler = (parent, e) => onDuplicate();
|
|
266
267
|
icon = Duplicate;
|
|
267
268
|
isDisabled = !selection.length || selection.length !== 1;
|
|
268
269
|
if (selectorId && !selectorSelected) {
|
|
@@ -283,7 +284,7 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
283
284
|
case UPLOAD_DOWNLOAD:
|
|
284
285
|
key = 'uploadDownloadBtn';
|
|
285
286
|
text = 'Upload/Download';
|
|
286
|
-
handler = onUploadDownload;
|
|
287
|
+
handler = (parent, e) => onUploadDownload();
|
|
287
288
|
icon = UploadDownload;
|
|
288
289
|
break;
|
|
289
290
|
default:
|