@onehat/ui 0.3.84 → 0.3.86
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
|
@@ -121,6 +121,7 @@ function Form(props) {
|
|
|
121
121
|
record = props.record?.length === 1 ? props.record[0] : props.record,
|
|
122
122
|
isMultiple = _.isArray(record),
|
|
123
123
|
isSingle = !isMultiple, // for convenience
|
|
124
|
+
isPhantom = !!record?.isPhantom,
|
|
124
125
|
forceUpdate = useForceUpdate(),
|
|
125
126
|
[previousRecord, setPreviousRecord] = useState(record),
|
|
126
127
|
[containerWidth, setContainerWidth] = useState(),
|
|
@@ -157,6 +158,7 @@ function Form(props) {
|
|
|
157
158
|
// shouldUnregister: false,
|
|
158
159
|
// shouldUseNativeValidation: false,
|
|
159
160
|
resolver: yupResolver(validator || (isMultiple ? disableRequiredYupFields(Repository?.schema?.model?.validator) : Repository?.schema?.model?.validator) || yup.object()),
|
|
161
|
+
context: { isPhantom },
|
|
160
162
|
}),
|
|
161
163
|
buildFromColumnsConfig = () => {
|
|
162
164
|
// For InlineEditor
|
|
@@ -738,7 +740,7 @@ function Form(props) {
|
|
|
738
740
|
isSaveDisabled = true;
|
|
739
741
|
isSubmitDisabled = true;
|
|
740
742
|
}
|
|
741
|
-
if (_.isEmpty(formState.dirtyFields) && !
|
|
743
|
+
if (_.isEmpty(formState.dirtyFields) && !isPhantom) {
|
|
742
744
|
isSaveDisabled = true;
|
|
743
745
|
}
|
|
744
746
|
|
|
@@ -759,12 +761,10 @@ function Form(props) {
|
|
|
759
761
|
if (isEditorViewOnly) {
|
|
760
762
|
showCloseBtn = true;
|
|
761
763
|
} else {
|
|
762
|
-
const
|
|
763
|
-
formIsDirty = formState.isDirty,
|
|
764
|
-
recordIsPhantom = record?.isPhantom;
|
|
764
|
+
const formIsDirty = formState.isDirty;
|
|
765
765
|
// console.log('formIsDirty', formIsDirty);
|
|
766
|
-
// console.log('
|
|
767
|
-
if (formIsDirty ||
|
|
766
|
+
// console.log('isPhantom', isPhantom);
|
|
767
|
+
if (formIsDirty || isPhantom) {
|
|
768
768
|
if (isSingle && onCancel) {
|
|
769
769
|
showCancelBtn = true;
|
|
770
770
|
}
|
|
@@ -299,24 +299,33 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
setIsSaving(true);
|
|
302
|
-
|
|
302
|
+
let success;
|
|
303
|
+
try {
|
|
304
|
+
await Repository.save();
|
|
305
|
+
success = true;
|
|
306
|
+
} catch (e) {
|
|
307
|
+
success = false;
|
|
308
|
+
}
|
|
303
309
|
setIsSaving(false);
|
|
304
310
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
311
|
+
if (success) {
|
|
312
|
+
setIsAdding(false);
|
|
313
|
+
|
|
314
|
+
setEditorMode(EDITOR_MODE__EDIT);
|
|
315
|
+
// setIsEditorShown(false);
|
|
316
|
+
|
|
317
|
+
if (getListeners().onAfterEdit) {
|
|
318
|
+
await getListeners().onAfterEdit(what);
|
|
319
|
+
}
|
|
320
|
+
if (onChange) {
|
|
321
|
+
onChange();
|
|
322
|
+
}
|
|
323
|
+
if (onSave) {
|
|
324
|
+
onSave(what);
|
|
325
|
+
}
|
|
317
326
|
}
|
|
318
327
|
|
|
319
|
-
return
|
|
328
|
+
return success;
|
|
320
329
|
},
|
|
321
330
|
onEditorCancel = () => {
|
|
322
331
|
async function doIt() {
|
|
@@ -28,7 +28,7 @@ function TabBar(props) {
|
|
|
28
28
|
content, // e.g. Expo Router slot
|
|
29
29
|
direction = HORIZONTAL,
|
|
30
30
|
tabWidth = 150, // used on VERTICAL mode only
|
|
31
|
-
tabHeight = '
|
|
31
|
+
tabHeight = '47px', // used on HORIZONTAL mode only
|
|
32
32
|
additionalButtons,
|
|
33
33
|
initialTabIx = 0,
|
|
34
34
|
currentTabIx,
|
|
@@ -38,6 +38,7 @@ function TabBar(props) {
|
|
|
38
38
|
onChangeIsCollapsed,
|
|
39
39
|
onPressTab,
|
|
40
40
|
onTabClose,
|
|
41
|
+
self,
|
|
41
42
|
...propsToPass
|
|
42
43
|
} = props,
|
|
43
44
|
styles = UiGlobals.styles,
|
|
@@ -196,6 +197,20 @@ function TabBar(props) {
|
|
|
196
197
|
tabIcon.as = Type;
|
|
197
198
|
}
|
|
198
199
|
}
|
|
200
|
+
let closeBtn;
|
|
201
|
+
if (onTabClose && !tab.disableCloseBox) {
|
|
202
|
+
closeBtn = <IconButton
|
|
203
|
+
key={'tabCloseButton' + ix}
|
|
204
|
+
onPress={() => onTabClose(ix)}
|
|
205
|
+
icon={Xmark}
|
|
206
|
+
_icon={{
|
|
207
|
+
color: isCurrentTab ? styles.TAB_ACTIVE_ICON_COLOR : styles.TAB_ICON_COLOR,
|
|
208
|
+
...iconProps,
|
|
209
|
+
}}
|
|
210
|
+
tooltip="Close Tab"
|
|
211
|
+
p={0}
|
|
212
|
+
/>;
|
|
213
|
+
}
|
|
199
214
|
if (useIconButton) {
|
|
200
215
|
button = <IconButton
|
|
201
216
|
key={'tabIconButton' + ix}
|
|
@@ -213,6 +228,11 @@ function TabBar(props) {
|
|
|
213
228
|
bg={isCurrentTab ? styles.TAB_ACTIVE_BG : styles.TAB_BG}
|
|
214
229
|
tooltip={tab.title}
|
|
215
230
|
/>;
|
|
231
|
+
// button = <Row
|
|
232
|
+
// key={'tab' + ix}
|
|
233
|
+
// >
|
|
234
|
+
// {button}
|
|
235
|
+
// </Row>;
|
|
216
236
|
} else {
|
|
217
237
|
button = <Button
|
|
218
238
|
key={'tabButton' + ix}
|
|
@@ -222,12 +242,19 @@ function TabBar(props) {
|
|
|
222
242
|
{...iconProps}
|
|
223
243
|
{...tabIcon}
|
|
224
244
|
/>}
|
|
245
|
+
// endIcon={<Icon
|
|
246
|
+
// color={isCurrentTab ? styles.TAB_ACTIVE_ICON_COLOR : styles.TAB_ICON_COLOR}
|
|
247
|
+
// {...iconProps}
|
|
248
|
+
// {...tabIcon}
|
|
249
|
+
// />}
|
|
250
|
+
endIcon={closeBtn}
|
|
225
251
|
{...buttonProps}
|
|
226
252
|
{...thisButtonProps}
|
|
227
253
|
_hover={{
|
|
228
254
|
bg: isCurrentTab? styles.TAB_ACTIVE_HOVER_BG : styles.TAB_HOVER_BG,
|
|
229
255
|
}}
|
|
230
256
|
bg={isCurrentTab ? styles.TAB_ACTIVE_BG : styles.TAB_BG}
|
|
257
|
+
direction="row"
|
|
231
258
|
>
|
|
232
259
|
<Text
|
|
233
260
|
color={isCurrentTab ? styles.TAB_ACTIVE_COLOR : styles.TAB_COLOR}
|
|
@@ -238,19 +265,6 @@ function TabBar(props) {
|
|
|
238
265
|
>{tab.title}</Text>
|
|
239
266
|
</Button>;
|
|
240
267
|
}
|
|
241
|
-
if (onTabClose) {
|
|
242
|
-
button = <Row
|
|
243
|
-
key={'tab' + ix}
|
|
244
|
-
>
|
|
245
|
-
{button}
|
|
246
|
-
<IconButton
|
|
247
|
-
key={'tabXButton' + ix}
|
|
248
|
-
onPress={() => onTabClose(ix)}
|
|
249
|
-
icon={Xmark}
|
|
250
|
-
tooltip="Close Tab"
|
|
251
|
-
/>
|
|
252
|
-
</Row>;
|
|
253
|
-
}
|
|
254
268
|
buttons.push(button);
|
|
255
269
|
});
|
|
256
270
|
|
|
@@ -371,6 +385,12 @@ function TabBar(props) {
|
|
|
371
385
|
return null;
|
|
372
386
|
}
|
|
373
387
|
|
|
388
|
+
if (self) {
|
|
389
|
+
self.getCurrentTab = getCurrentTab;
|
|
390
|
+
self.setCurrentTab = setCurrentTab;
|
|
391
|
+
self.setIsCollapsed = setIsCollapsed;
|
|
392
|
+
}
|
|
393
|
+
|
|
374
394
|
const
|
|
375
395
|
renderedTabs = renderTabs(),
|
|
376
396
|
renderedCurrentTabContent = renderCurrentTabContent(),
|