@onehat/ui 0.3.240 → 0.3.241
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/Form.js +9 -4
- package/src/Components/Grid/Grid.js +26 -0
- package/src/Components/Hoc/withInlineEditor.js +21 -5
- package/src/Components/Hoc/withInlineSideEditor.js +9 -0
- package/src/Components/Hoc/withSideEditor.js +3 -2
- package/src/Components/Hoc/withWindowedEditor.js +3 -2
- package/src/Constants/Editor.js +1 -0
package/package.json
CHANGED
|
@@ -193,6 +193,7 @@ function Form(props) {
|
|
|
193
193
|
_.each(columnsConfig, (config, ix) => {
|
|
194
194
|
let {
|
|
195
195
|
fieldName,
|
|
196
|
+
editField,
|
|
196
197
|
isEditable,
|
|
197
198
|
editor,
|
|
198
199
|
renderer,
|
|
@@ -211,9 +212,10 @@ function Form(props) {
|
|
|
211
212
|
<Text numberOfLines={1} ellipsizeMode="head">{renderedValue}</Text>
|
|
212
213
|
</Box>);
|
|
213
214
|
} else {
|
|
215
|
+
const fieldToEdit = editField || fieldName;
|
|
214
216
|
elements.push(<Controller
|
|
215
217
|
key={'controller-' + ix}
|
|
216
|
-
name={
|
|
218
|
+
name={fieldToEdit}
|
|
217
219
|
// rules={rules}
|
|
218
220
|
control={control}
|
|
219
221
|
render={(args) => {
|
|
@@ -236,7 +238,7 @@ function Form(props) {
|
|
|
236
238
|
} = fieldState;
|
|
237
239
|
let editorProps = {};
|
|
238
240
|
if (!editor) {
|
|
239
|
-
const propertyDef =
|
|
241
|
+
const propertyDef = fieldToEdit && Repository?.getSchema().getPropertyDefinition(fieldToEdit);
|
|
240
242
|
editor = propertyDef?.editorType;
|
|
241
243
|
if (_.isPlainObject(editor)) {
|
|
242
244
|
const {
|
|
@@ -277,10 +279,13 @@ function Form(props) {
|
|
|
277
279
|
onBlur={onBlur}
|
|
278
280
|
flex={1}
|
|
279
281
|
parent={self}
|
|
280
|
-
reference={
|
|
282
|
+
reference={fieldToEdit}
|
|
281
283
|
{...editorProps}
|
|
282
284
|
/>;
|
|
283
285
|
|
|
286
|
+
if (editor.match(/Tag/)) {
|
|
287
|
+
columnProps.overflow = 'auto';
|
|
288
|
+
}
|
|
284
289
|
// element = <Tooltip key={ix} label={header} placement="bottom">
|
|
285
290
|
// {element}
|
|
286
291
|
// </Tooltip>;
|
|
@@ -901,7 +906,7 @@ function Form(props) {
|
|
|
901
906
|
{editor}
|
|
902
907
|
</ScrollView>}
|
|
903
908
|
|
|
904
|
-
<Footer justifyContent="flex-end" {...footerProps}
|
|
909
|
+
<Footer justifyContent="flex-end" {...footerProps} {...savingProps}>
|
|
905
910
|
{onDelete && editorMode === EDITOR_MODE__EDIT && isSingle &&
|
|
906
911
|
|
|
907
912
|
<Row flex={1} justifyContent="flex-start">
|
|
@@ -44,6 +44,7 @@ import withMultiSelection from '../Hoc/withMultiSelection.js';
|
|
|
44
44
|
import withSelection from '../Hoc/withSelection.js';
|
|
45
45
|
import withWindowedEditor from '../Hoc/withWindowedEditor.js';
|
|
46
46
|
import withInlineEditor from '../Hoc/withInlineEditor.js';
|
|
47
|
+
import withInlineSideEditor from '../Hoc/withInlineSideEditor.js';
|
|
47
48
|
import getSaved from '../../Functions/getSaved.js';
|
|
48
49
|
import setSaved from '../../Functions/setSaved.js';
|
|
49
50
|
import getIconButtonFromConfig from '../../Functions/getIconButtonFromConfig.js';
|
|
@@ -1155,4 +1156,29 @@ export const InlineGridEditor = withComponent(
|
|
|
1155
1156
|
)
|
|
1156
1157
|
);
|
|
1157
1158
|
|
|
1159
|
+
// export const InlineSideGridEditor = withComponent(
|
|
1160
|
+
// withAlert(
|
|
1161
|
+
// withEvents(
|
|
1162
|
+
// withData(
|
|
1163
|
+
// withDropTarget(
|
|
1164
|
+
// withMultiSelection(
|
|
1165
|
+
// withSelection(
|
|
1166
|
+
// withInlineSideEditor(
|
|
1167
|
+
// withFilters(
|
|
1168
|
+
// withPresetButtons(
|
|
1169
|
+
// withContextMenu(
|
|
1170
|
+
// GridComponent
|
|
1171
|
+
// )
|
|
1172
|
+
// ),
|
|
1173
|
+
// true // isGrid
|
|
1174
|
+
// )
|
|
1175
|
+
// )
|
|
1176
|
+
// )
|
|
1177
|
+
// )
|
|
1178
|
+
// )
|
|
1179
|
+
// )
|
|
1180
|
+
// )
|
|
1181
|
+
// )
|
|
1182
|
+
// );
|
|
1183
|
+
|
|
1158
1184
|
export default Grid;
|
|
@@ -31,10 +31,10 @@ function withAdditionalProps(WrappedComponent) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// NOTE: Effectivtly, the HOC composition is:
|
|
34
|
-
// withAdditionalProps(withEditor(
|
|
34
|
+
// withAdditionalProps(withEditor(withInlineEditor))
|
|
35
35
|
|
|
36
|
-
export default function withInlineEditor(WrappedComponent) {
|
|
37
|
-
|
|
36
|
+
export default function withInlineEditor(WrappedComponent, skipWrappers = false) {
|
|
37
|
+
const InlineEditor = (props) => {
|
|
38
38
|
const {
|
|
39
39
|
editorType,
|
|
40
40
|
isEditorShown = false,
|
|
@@ -84,9 +84,15 @@ export default function withInlineEditor(WrappedComponent) {
|
|
|
84
84
|
|
|
85
85
|
editorStyle.top = (-1 * delta) + 'px';
|
|
86
86
|
};
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (maskRef.current) {
|
|
90
|
+
maskRef.current.focus();
|
|
91
|
+
}
|
|
92
|
+
}, [isEditorShown]);
|
|
87
93
|
|
|
88
94
|
if (isEditorShown && selection.length < 1) {
|
|
89
|
-
|
|
95
|
+
return null; // phantom record may have just been deleted
|
|
90
96
|
}
|
|
91
97
|
if (isEditorShown && selection.length !== 1) {
|
|
92
98
|
throw new Error('Can only edit one at a time with inline editor!');
|
|
@@ -114,6 +120,12 @@ export default function withInlineEditor(WrappedComponent) {
|
|
|
114
120
|
e.stopPropagation();
|
|
115
121
|
onEditorCancel();
|
|
116
122
|
}}
|
|
123
|
+
tabIndex={-1}
|
|
124
|
+
onKeyDown={(e) => {
|
|
125
|
+
if (e.key === 'Escape') {
|
|
126
|
+
onEditorCancel();
|
|
127
|
+
}
|
|
128
|
+
}}
|
|
117
129
|
></Box>}
|
|
118
130
|
<Column
|
|
119
131
|
ref={inlineEditorRef}
|
|
@@ -158,5 +170,9 @@ export default function withInlineEditor(WrappedComponent) {
|
|
|
158
170
|
inlineEditor={inlineEditor}
|
|
159
171
|
isInlineEditorShown={isEditorShown}
|
|
160
172
|
/>;
|
|
161
|
-
}
|
|
173
|
+
};
|
|
174
|
+
if (skipWrappers) {
|
|
175
|
+
return InlineEditor; // this is for InlineSideEditor, not yet implemented
|
|
176
|
+
}
|
|
177
|
+
return withAdditionalProps(withEditor(InlineEditor));
|
|
162
178
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
import withInlineEditor from './withInlineEditor.js';
|
|
3
|
+
import withSideEditor from './withSideEditor.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export default function withInlineSideEditor(WrappedComponent) {
|
|
7
|
+
throw Error('Not yet implemented');
|
|
8
|
+
return withSideEditor(withInlineEditor(WrappedComponent, true));
|
|
9
|
+
}
|
|
@@ -20,7 +20,7 @@ function withAdditionalProps(WrappedComponent) {
|
|
|
20
20
|
// withAdditionalProps(withEditor(withSideEditor))
|
|
21
21
|
|
|
22
22
|
export default function withSideEditor(WrappedComponent, isTree = false) {
|
|
23
|
-
|
|
23
|
+
const SideEditor = (props) => {
|
|
24
24
|
const {
|
|
25
25
|
Editor,
|
|
26
26
|
editorProps = {},
|
|
@@ -57,5 +57,6 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
|
|
|
57
57
|
reference="editor"
|
|
58
58
|
/>}
|
|
59
59
|
/>;
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
|
+
return withAdditionalProps(withEditor(SideEditor));
|
|
61
62
|
}
|
|
@@ -42,7 +42,7 @@ function withAdditionalProps(WrappedComponent) {
|
|
|
42
42
|
// withAdditionalProps(withEditor(withWindowedEditor))
|
|
43
43
|
|
|
44
44
|
export default function withWindowedEditor(WrappedComponent, isTree = false) {
|
|
45
|
-
|
|
45
|
+
const WindowedEditor = (props) => {
|
|
46
46
|
const {
|
|
47
47
|
isEditorShown = false,
|
|
48
48
|
setIsEditorShown,
|
|
@@ -81,5 +81,6 @@ export default function withWindowedEditor(WrappedComponent, isTree = false) {
|
|
|
81
81
|
/>
|
|
82
82
|
</Modal>}
|
|
83
83
|
</>;
|
|
84
|
-
}
|
|
84
|
+
};
|
|
85
|
+
return withAdditionalProps(withEditor(WindowedEditor, isTree));
|
|
85
86
|
}
|
package/src/Constants/Editor.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const EDITOR_TYPE__INLINE = 'EDITOR_TYPE__INLINE';
|
|
2
2
|
export const EDITOR_TYPE__WINDOWED = 'EDITOR_TYPE__WINDOWED';
|
|
3
3
|
export const EDITOR_TYPE__SIDE = 'EDITOR_TYPE__SIDE';
|
|
4
|
+
export const EDITOR_TYPE__INLINE_SIDE = 'EDITOR_TYPE__INLINE_SIDE';
|
|
4
5
|
export const EDITOR_TYPE__SMART = 'EDITOR_TYPE__SMART';
|
|
5
6
|
export const EDITOR_TYPE__PLAIN = 'EDITOR_TYPE__PLAIN';
|
|
6
7
|
export const EDITOR_MODE__VIEW = 'EDITOR_MODE__VIEW';
|