@onehat/ui 0.3.30 → 0.3.32
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/Buttons/Button.js +20 -0
- package/src/Components/Buttons/IconButton.js +68 -51
- package/src/Components/Buttons/SquareButton.js +60 -0
- package/src/Components/Container/Container.js +4 -1
- package/src/Components/Container/ScreenContainer.js +4 -1
- package/src/Components/Editor/Editor.js +15 -1
- package/src/Components/Form/Field/CKEditor/CKEditor.js +2 -1
- package/src/Components/Form/Field/Checkbox/Checkbox.js +2 -1
- package/src/Components/Form/Field/Color.js +2 -1
- package/src/Components/Form/Field/Combo/Combo.js +7 -4
- package/src/Components/Form/Field/Date.js +2 -1
- package/src/Components/Form/Field/DisplayField.js +2 -1
- package/src/Components/Form/Field/File.js +2 -1
- package/src/Components/Form/Field/Input.js +2 -1
- package/src/Components/Form/Field/Number.js +2 -1
- package/src/Components/Form/Field/RadioGroup/RadioGroup.js +2 -1
- package/src/Components/Form/Field/Text.js +2 -1
- package/src/Components/Form/Field/TextArea.js +3 -2
- package/src/Components/Form/Field/Toggle.js +2 -1
- package/src/Components/Form/Form.js +91 -44
- package/src/Components/Grid/Grid.js +67 -53
- package/src/Components/Grid/GridHeaderRow.js +5 -2
- package/src/Components/Grid/GridRow.js +8 -2
- package/src/Components/Hoc/withAlert.js +1 -3
- package/src/Components/Hoc/withComponent.js +59 -0
- package/src/Components/Hoc/withEditor.js +16 -4
- package/src/Components/Hoc/withInlineEditor.js +4 -0
- package/src/Components/Hoc/withPdfButton.js +34 -28
- package/src/Components/Hoc/withPresetButtons.js +26 -1
- package/src/Components/Hoc/withSideEditor.js +7 -1
- package/src/Components/Hoc/withWindowedEditor.js +7 -1
- package/src/Components/Icons/HighPriority.js +20 -0
- package/src/Components/Icons/LowPriority.js +20 -0
- package/src/Components/Icons/MedPriority.js +20 -0
- package/src/Components/Icons/Pdf.js +14 -0
- package/src/Components/Screens/Manager.js +5 -2
- package/src/Components/Tab/TabBar.js +5 -2
- package/src/Components/Toolbar/Pagination.js +2 -1
- package/src/Components/Tree/Tree.js +47 -40
- package/src/Components/Viewer/TagViewer.js +3 -1
- package/src/Components/Viewer/Viewer.js +58 -14
- package/src/Components/index.js +4 -0
- package/src/Functions/getIconButtonFromConfig.js +3 -1
- package/src/Components/Form/Field/Field.js +0 -14
- package/src/Components/Grid/ReactGrid.js +0 -468
- package/src/Components/Grid/SenchaGrid.js +0 -421
- package/src/Components/Grid/reactgrid.css +0 -6
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Column,
|
|
4
|
-
Row,
|
|
5
|
-
Text,
|
|
6
|
-
} from 'native-base';
|
|
7
|
-
import {
|
|
8
|
-
SenchaGrid,
|
|
9
|
-
AddressColumn,
|
|
10
|
-
BooleanColumn,
|
|
11
|
-
CheckboxColumn,
|
|
12
|
-
ColorColumn,
|
|
13
|
-
Column as Col,
|
|
14
|
-
DateColumn,
|
|
15
|
-
DecimalColumn,
|
|
16
|
-
EmailColumn,
|
|
17
|
-
FloatColumn,
|
|
18
|
-
IntegerColumn,
|
|
19
|
-
MoneyColumn,
|
|
20
|
-
NumberColumn,
|
|
21
|
-
PercentageColumn,
|
|
22
|
-
PhoneColumn,
|
|
23
|
-
TreeColumn,
|
|
24
|
-
} from '@sencha/sencha-grid'; // https://www.npmjs.com/package/@sencha/sencha-grid
|
|
25
|
-
import '@sencha/sencha-grid/dist/themes/grui.css';
|
|
26
|
-
import testProps from '../../Functions/testProps';
|
|
27
|
-
import useForceUpdate from '../../Hooks/useForceUpdate';
|
|
28
|
-
import Loading from '../Messages/Loading';
|
|
29
|
-
import Toolbar from '../Toolbar/Toolbar';
|
|
30
|
-
import PaginationToolbar from '../Toolbar/PaginationToolbar';
|
|
31
|
-
import NoRecordsFound from './NoRecordsFound';
|
|
32
|
-
import AngleRight from '../Icons/AngleRight';
|
|
33
|
-
import _ from 'lodash';
|
|
34
|
-
|
|
35
|
-
// This grid makes use of @sencha/sencha-grid
|
|
36
|
-
|
|
37
|
-
export default function Grid(props) {
|
|
38
|
-
const {
|
|
39
|
-
Repository,
|
|
40
|
-
topToolbar,
|
|
41
|
-
bottomToolbar = 'pagination',
|
|
42
|
-
columnsConfig = [], // json configurations for each column
|
|
43
|
-
showSummaries = false,
|
|
44
|
-
showEditors = false,
|
|
45
|
-
showFilters = false,
|
|
46
|
-
showRowExpander = false,
|
|
47
|
-
cellEditing = false,
|
|
48
|
-
rowEditing = false,
|
|
49
|
-
// columnProps = {},
|
|
50
|
-
// getRowProps = () => {
|
|
51
|
-
// return {
|
|
52
|
-
// bg: '#fff',
|
|
53
|
-
// p: 2,
|
|
54
|
-
// };
|
|
55
|
-
// },
|
|
56
|
-
gridProps = {},
|
|
57
|
-
pullToRefresh = true,
|
|
58
|
-
hideRightColumn = true,
|
|
59
|
-
disableLoadingIndicator = false,
|
|
60
|
-
noneFoundText,
|
|
61
|
-
disableReloadOnChangeFilters = false,
|
|
62
|
-
|
|
63
|
-
// properties
|
|
64
|
-
data,
|
|
65
|
-
treeData,
|
|
66
|
-
columnLines = true,
|
|
67
|
-
grouped = false,
|
|
68
|
-
groupFooter = false,
|
|
69
|
-
groupField,
|
|
70
|
-
hideHeaders = false,
|
|
71
|
-
scrollable = false,
|
|
72
|
-
itemConfig, // { body: <RowBodyComponent /> },
|
|
73
|
-
itemRipple, // { color: 'green' },
|
|
74
|
-
hideRowLines = false,
|
|
75
|
-
rowNumbers = false,
|
|
76
|
-
selectable = {
|
|
77
|
-
cells: false,
|
|
78
|
-
checkbox: true,
|
|
79
|
-
// checkboxColumnIndex: 0,
|
|
80
|
-
columns: true,
|
|
81
|
-
deselectable: true,
|
|
82
|
-
disabled: false,
|
|
83
|
-
drag: true,
|
|
84
|
-
extensible: true,
|
|
85
|
-
headerCheckbox: true,
|
|
86
|
-
mode: 'multi', // single | multi
|
|
87
|
-
reducible: true,
|
|
88
|
-
rows: true,
|
|
89
|
-
},
|
|
90
|
-
shadow = false,
|
|
91
|
-
sortable = true,
|
|
92
|
-
variableHeights = true,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// events
|
|
96
|
-
onBeforeComplete,
|
|
97
|
-
onBeforeEdit,
|
|
98
|
-
onBeforeGroupCollapse,
|
|
99
|
-
onBeforeGroupExpand,
|
|
100
|
-
onBeforeStartEdit,
|
|
101
|
-
onBeforeCancelEdit,
|
|
102
|
-
onCellSelection,
|
|
103
|
-
onColumnAdd,
|
|
104
|
-
onColumnHide,
|
|
105
|
-
onColumnMenuCreated,
|
|
106
|
-
onColumnMove,
|
|
107
|
-
onColumnResize,
|
|
108
|
-
onColumnSelection,
|
|
109
|
-
onColumnSort,
|
|
110
|
-
onCompleteEdit,
|
|
111
|
-
onDeselect,
|
|
112
|
-
onEdit,
|
|
113
|
-
onEditRestrict,
|
|
114
|
-
onInitialized,
|
|
115
|
-
onPainted,
|
|
116
|
-
onSelect,
|
|
117
|
-
onStartEdit,
|
|
118
|
-
onUpdateData,
|
|
119
|
-
onValidateEdit,
|
|
120
|
-
|
|
121
|
-
} = props,
|
|
122
|
-
entities = Repository.entities,
|
|
123
|
-
[isLoading, setIsLoading] = useState(false),
|
|
124
|
-
forceUpdate = useForceUpdate(),
|
|
125
|
-
onRefresh = () => Repository.load(),
|
|
126
|
-
generateColumnComponents = () => {
|
|
127
|
-
const columnComponents = [];
|
|
128
|
-
_.each(columnsConfig, (column, ix) => {
|
|
129
|
-
|
|
130
|
-
// This destructuring sets the default values
|
|
131
|
-
const {
|
|
132
|
-
type, // specify which sencha column type to use
|
|
133
|
-
|
|
134
|
-
align = 'left',
|
|
135
|
-
dateTimeFormatLocales = 'en-US',
|
|
136
|
-
editable = false,
|
|
137
|
-
editor, // BooleanEditor | CheckboxEditor | ColorEditor | DateEditor | IEditor | NumberEditor | PhoneEditor | SelectEditor | TextEditor |
|
|
138
|
-
flex,
|
|
139
|
-
field, // required
|
|
140
|
-
format,
|
|
141
|
-
groupable = false,
|
|
142
|
-
hideable = false,
|
|
143
|
-
hidden = false,
|
|
144
|
-
locked = false,
|
|
145
|
-
menu, // [{ text: 'menu1' }, { text: 'menu2' }]
|
|
146
|
-
menuDisabled = false,
|
|
147
|
-
minWidth,
|
|
148
|
-
renderer, // React component will render the output
|
|
149
|
-
resizable = true,
|
|
150
|
-
sortable = true,
|
|
151
|
-
style,
|
|
152
|
-
summary, // sum, min, max, average, variance, variancep, stddev, stddevp
|
|
153
|
-
summaryCell, // 'numbercell'
|
|
154
|
-
summaryRenderer, // fn that returns value as formatted string, like (value) => 'Maximum Cost: ' + value;
|
|
155
|
-
text, // i.e. header
|
|
156
|
-
width,
|
|
157
|
-
} = column,
|
|
158
|
-
|
|
159
|
-
// This var incorporates the default values, and puts them back in an obj we pass to column
|
|
160
|
-
propsToPass = {
|
|
161
|
-
align,
|
|
162
|
-
dateTimeFormatLocales,
|
|
163
|
-
editable,
|
|
164
|
-
field,
|
|
165
|
-
groupable,
|
|
166
|
-
hideable,
|
|
167
|
-
hidden,
|
|
168
|
-
locked,
|
|
169
|
-
menuDisabled,
|
|
170
|
-
resizable,
|
|
171
|
-
sortable,
|
|
172
|
-
},
|
|
173
|
-
propsToCheck = {
|
|
174
|
-
editor,
|
|
175
|
-
format,
|
|
176
|
-
menu,
|
|
177
|
-
minWidth,
|
|
178
|
-
renderer,
|
|
179
|
-
style,
|
|
180
|
-
summary,
|
|
181
|
-
summaryCell,
|
|
182
|
-
summaryRenderer,
|
|
183
|
-
text,
|
|
184
|
-
};
|
|
185
|
-
_.each(propsToCheck, (prop, name) => {
|
|
186
|
-
if (!_.isEmpty(prop)) {
|
|
187
|
-
propsToPass[name] = prop;
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if (!flex && !width) {
|
|
192
|
-
propsToPass.flex = 1;
|
|
193
|
-
} else if (flex) {
|
|
194
|
-
propsToPass.flex = flex;
|
|
195
|
-
} else if (width) {
|
|
196
|
-
propsToPass.width = width;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
let ColumnType;
|
|
200
|
-
switch(type) {
|
|
201
|
-
case 'address':
|
|
202
|
-
ColumnType = AddressColumn;
|
|
203
|
-
break;
|
|
204
|
-
case 'bool':
|
|
205
|
-
ColumnType = BooleanColumn;
|
|
206
|
-
break;
|
|
207
|
-
case 'checkbox':
|
|
208
|
-
ColumnType = CheckboxColumn;
|
|
209
|
-
break;
|
|
210
|
-
case 'color':
|
|
211
|
-
ColumnType = ColorColumn;
|
|
212
|
-
break;
|
|
213
|
-
case 'date':
|
|
214
|
-
case 'datetime':
|
|
215
|
-
// case 'time':
|
|
216
|
-
ColumnType = DateColumn;
|
|
217
|
-
break;
|
|
218
|
-
case 'decimal':
|
|
219
|
-
ColumnType = DecimalColumn;
|
|
220
|
-
break;
|
|
221
|
-
case 'email':
|
|
222
|
-
ColumnType = EmailColumn;
|
|
223
|
-
break;
|
|
224
|
-
case 'float':
|
|
225
|
-
ColumnType = FloatColumn;
|
|
226
|
-
break;
|
|
227
|
-
case 'int':
|
|
228
|
-
ColumnType = IntegerColumn;
|
|
229
|
-
break;
|
|
230
|
-
case 'currency':
|
|
231
|
-
ColumnType = MoneyColumn;
|
|
232
|
-
break;
|
|
233
|
-
case 'percentInt':
|
|
234
|
-
ColumnType = NumberColumn;
|
|
235
|
-
break;
|
|
236
|
-
case 'percent':
|
|
237
|
-
ColumnType = PercentageColumn;
|
|
238
|
-
break;
|
|
239
|
-
case 'phone':
|
|
240
|
-
ColumnType = PhoneColumn;
|
|
241
|
-
break;
|
|
242
|
-
case 'tree':
|
|
243
|
-
ColumnType = TreeColumn;
|
|
244
|
-
break;
|
|
245
|
-
default:
|
|
246
|
-
ColumnType = Col;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (!_.isEmpty(editor)) {
|
|
250
|
-
propsToPass.editor = editor;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
columnComponents.push(<ColumnType key={ix} {...propsToPass} />);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
if (!hideRightColumn) {
|
|
257
|
-
columnComponents.push(<AngleRight
|
|
258
|
-
key={columnComponents.length}
|
|
259
|
-
color="#aaa"
|
|
260
|
-
variant="ghost"
|
|
261
|
-
w={30}
|
|
262
|
-
alignSelf="center"
|
|
263
|
-
ml={3}
|
|
264
|
-
/>);
|
|
265
|
-
}
|
|
266
|
-
return columnComponents;
|
|
267
|
-
},
|
|
268
|
-
convertEntitiesToSenchaGrid = () => {
|
|
269
|
-
return _.map(Repository.entities, (entity) => {
|
|
270
|
-
const rec = {};
|
|
271
|
-
_.each(columnsConfig, (config) => {
|
|
272
|
-
rec[config.field] = entity[config.field];
|
|
273
|
-
});
|
|
274
|
-
return rec;
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
getPlugins = () => {
|
|
278
|
-
const plugins = {};
|
|
279
|
-
if (showSummaries) {
|
|
280
|
-
plugins.gridsummaryrow = true;
|
|
281
|
-
}
|
|
282
|
-
if (showEditors) {
|
|
283
|
-
plugins.gridcellediting = true;
|
|
284
|
-
}
|
|
285
|
-
if (rowEditing) {
|
|
286
|
-
plugins.rowedit = { autoConfirm: false, };
|
|
287
|
-
}
|
|
288
|
-
if (showRowExpander) {
|
|
289
|
-
plugins.rowexpander = true;
|
|
290
|
-
}
|
|
291
|
-
if (cellEditing) {
|
|
292
|
-
plugins.cellediting = { clicksToEdit: 2, };
|
|
293
|
-
}
|
|
294
|
-
if (showFilters) {
|
|
295
|
-
plugins.gridfilters = true;
|
|
296
|
-
}
|
|
297
|
-
if (grouped) {
|
|
298
|
-
plugins.groupingpanel = true;
|
|
299
|
-
}
|
|
300
|
-
if (pullToRefresh) {
|
|
301
|
-
// plugins.pullrefresh = true; // causes a crash!
|
|
302
|
-
}
|
|
303
|
-
return plugins;
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
useEffect(() => {
|
|
307
|
-
if (!Repository || !Repository.on) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
if (disableLoadingIndicator) {
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
const
|
|
314
|
-
setTrue = () => setIsLoading(true),
|
|
315
|
-
setFalse = () => setIsLoading(false),
|
|
316
|
-
onChangeFilters = () => {
|
|
317
|
-
if (!Repository.isAutoLoad && Repository.isLoaded && !disableReloadOnChangeFilters) {
|
|
318
|
-
Repository.reload();
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
Repository.on('beforeLoad', setTrue);
|
|
323
|
-
Repository.on('load', setFalse);
|
|
324
|
-
Repository.ons(['changePage', 'changePageSize', 'changeData', 'change'], forceUpdate);
|
|
325
|
-
Repository.on('changeFilters', onChangeFilters);
|
|
326
|
-
|
|
327
|
-
// LEFT OFF HERE.
|
|
328
|
-
// If changing the pageSize to 5, it says that it's showing page 1, but it doesn't show the first item.
|
|
329
|
-
// Nav to other pages doesn't work right yet.
|
|
330
|
-
|
|
331
|
-
return () => {
|
|
332
|
-
Repository.off('beforeLoad', setTrue);
|
|
333
|
-
Repository.off('load', setFalse);
|
|
334
|
-
Repository.offs(['changePage', 'changePageSize', 'changeData', 'change'], forceUpdate);
|
|
335
|
-
Repository.off('changeFilters', onChangeFilters);
|
|
336
|
-
};
|
|
337
|
-
}, [Repository, disableLoadingIndicator, disableReloadOnChangeFilters, forceUpdate]);
|
|
338
|
-
|
|
339
|
-
if (!props.Repository) {
|
|
340
|
-
return null;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const propsToPass = {
|
|
344
|
-
columnLines,
|
|
345
|
-
grouped,
|
|
346
|
-
groupFooter,
|
|
347
|
-
hideHeaders,
|
|
348
|
-
scrollable,
|
|
349
|
-
hideRowLines,
|
|
350
|
-
rowNumbers,
|
|
351
|
-
selectable,
|
|
352
|
-
shadow,
|
|
353
|
-
sortable,
|
|
354
|
-
variableHeights,
|
|
355
|
-
},
|
|
356
|
-
columnComponents = generateColumnComponents(),
|
|
357
|
-
plugins = getPlugins(),
|
|
358
|
-
propsToCheck = {
|
|
359
|
-
plugins,
|
|
360
|
-
groupField,
|
|
361
|
-
itemConfig,
|
|
362
|
-
itemRipple,
|
|
363
|
-
onBeforeComplete,
|
|
364
|
-
onBeforeEdit,
|
|
365
|
-
onBeforeGroupCollapse,
|
|
366
|
-
onBeforeGroupExpand,
|
|
367
|
-
onBeforeStartEdit,
|
|
368
|
-
onBeforeCancelEdit,
|
|
369
|
-
onCellSelection,
|
|
370
|
-
onColumnAdd,
|
|
371
|
-
onColumnHide,
|
|
372
|
-
onColumnMenuCreated,
|
|
373
|
-
onColumnMove,
|
|
374
|
-
onColumnResize,
|
|
375
|
-
onColumnSelection,
|
|
376
|
-
onColumnSort,
|
|
377
|
-
onCompleteEdit,
|
|
378
|
-
onDeselect,
|
|
379
|
-
onEdit,
|
|
380
|
-
onEditRestrict,
|
|
381
|
-
onInitialized,
|
|
382
|
-
onPainted,
|
|
383
|
-
onSelect,
|
|
384
|
-
onStartEdit,
|
|
385
|
-
onUpdateData,
|
|
386
|
-
onValidateEdit,
|
|
387
|
-
}
|
|
388
|
-
_.each(propsToCheck, (prop, name) => {
|
|
389
|
-
if (!_.isEmpty(prop)) {
|
|
390
|
-
propsToPass[name] = prop;
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
if (!_.isEmpty(data)) {
|
|
394
|
-
propsToPass.data = data;
|
|
395
|
-
} else if (!_.isEmpty(treeData)) {
|
|
396
|
-
propsToPass.treeData = treeData;
|
|
397
|
-
} else {
|
|
398
|
-
propsToPass.data = convertEntitiesToSenchaGrid();
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
return <Column
|
|
402
|
-
{...testProps('GridPanelContainer')}
|
|
403
|
-
flex={1}
|
|
404
|
-
w="100%"
|
|
405
|
-
>
|
|
406
|
-
{topToolbar && <Toolbar>{topToolbar}</Toolbar>}
|
|
407
|
-
|
|
408
|
-
{isLoading && <Column flex={1}><Loading /></Column>}
|
|
409
|
-
|
|
410
|
-
{!isLoading && (!entities.length ? <NoRecordsFound text={noneFoundText} onRefresh={onRefresh} /> :
|
|
411
|
-
|
|
412
|
-
<SenchaGrid {...propsToPass} style={{ width: "100%", height: "100%", flex: 1, }} {...gridProps}>
|
|
413
|
-
{columnComponents}
|
|
414
|
-
</SenchaGrid>)}
|
|
415
|
-
|
|
416
|
-
{bottomToolbar && (bottomToolbar === 'pagination' ?
|
|
417
|
-
<PaginationToolbar Repository={Repository} />:
|
|
418
|
-
<Toolbar>{bottomToolbar}</Toolbar>)}
|
|
419
|
-
</Column>;
|
|
420
|
-
|
|
421
|
-
}
|