@onehat/ui 0.3.31 → 0.3.33

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.
Files changed (51) hide show
  1. package/package.json +1 -1
  2. package/src/Components/Buttons/Button.js +20 -0
  3. package/src/Components/Buttons/IconButton.js +68 -51
  4. package/src/Components/Buttons/SquareButton.js +6 -4
  5. package/src/Components/Container/Container.js +4 -1
  6. package/src/Components/Container/ScreenContainer.js +4 -1
  7. package/src/Components/Editor/Editor.js +15 -1
  8. package/src/Components/Form/Field/CKEditor/CKEditor.js +2 -1
  9. package/src/Components/Form/Field/Checkbox/Checkbox.js +2 -1
  10. package/src/Components/Form/Field/Color.js +2 -1
  11. package/src/Components/Form/Field/Combo/Combo.js +7 -4
  12. package/src/Components/Form/Field/Date.js +2 -1
  13. package/src/Components/Form/Field/DisplayField.js +2 -1
  14. package/src/Components/Form/Field/File.js +2 -1
  15. package/src/Components/Form/Field/Input.js +2 -1
  16. package/src/Components/Form/Field/Number.js +2 -1
  17. package/src/Components/Form/Field/RadioGroup/RadioGroup.js +2 -1
  18. package/src/Components/Form/Field/Text.js +2 -1
  19. package/src/Components/Form/Field/TextArea.js +3 -2
  20. package/src/Components/Form/Field/Toggle.js +2 -1
  21. package/src/Components/Form/Form.js +93 -45
  22. package/src/Components/Grid/Grid.js +67 -53
  23. package/src/Components/Grid/GridHeaderRow.js +5 -2
  24. package/src/Components/Grid/GridRow.js +8 -2
  25. package/src/Components/Hoc/withAlert.js +1 -3
  26. package/src/Components/Hoc/withComponent.js +65 -0
  27. package/src/Components/Hoc/withData.js +6 -0
  28. package/src/Components/Hoc/withEditor.js +54 -4
  29. package/src/Components/Hoc/withFilters.js +35 -5
  30. package/src/Components/Hoc/withInlineEditor.js +4 -0
  31. package/src/Components/Hoc/withPdfButton.js +12 -13
  32. package/src/Components/Hoc/withPresetButtons.js +14 -1
  33. package/src/Components/Hoc/withSelection.js +16 -0
  34. package/src/Components/Hoc/withSideEditor.js +7 -1
  35. package/src/Components/Hoc/withWindowedEditor.js +7 -1
  36. package/src/Components/Icons/HighPriority.js +20 -0
  37. package/src/Components/Icons/LowPriority.js +20 -0
  38. package/src/Components/Icons/MedPriority.js +20 -0
  39. package/src/Components/Icons/Pdf.js +14 -0
  40. package/src/Components/Screens/Manager.js +5 -2
  41. package/src/Components/Tab/TabBar.js +5 -2
  42. package/src/Components/Toolbar/Pagination.js +2 -1
  43. package/src/Components/Tree/Tree.js +47 -40
  44. package/src/Components/Viewer/TagViewer.js +3 -1
  45. package/src/Components/Viewer/Viewer.js +57 -14
  46. package/src/Components/index.js +2 -0
  47. package/src/Functions/getIconButtonFromConfig.js +3 -1
  48. package/src/Components/Form/Field/Field.js +0 -14
  49. package/src/Components/Grid/ReactGrid.js +0 -468
  50. package/src/Components/Grid/SenchaGrid.js +0 -421
  51. 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
- }
@@ -1,6 +0,0 @@
1
- .reactgrid {
2
- flex: 1;
3
- width: 100% !important;
4
- height: auto;
5
- overflow: scroll;
6
- }