@onehat/ui 0.3.323 → 0.3.325
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/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# OneHatUi Patterns
|
|
2
|
+
|
|
3
|
+
The OneHatUi library is a set of pre-built components that make use of the OneHatData library.
|
|
4
|
+
It is built on top of ReactNative, and either NativeBase or GlueStack.
|
|
5
|
+
|
|
6
|
+
Many of the components make use of other components internally.
|
|
7
|
+
For example, the `Grid` component uses `IconButtons` for its pagination toolbar.
|
|
8
|
+
The `Combo` component makes use of the `Grid` component for its menu.
|
|
9
|
+
And the `Tag` component is simply a `Combo` with additional functionality.
|
|
10
|
+
|
|
11
|
+
Many components have “regular” and “editor” versions. For example, there’s a `Grid` and a `GridEditor`.
|
|
12
|
+
The `Grid` is simply for viewing. The `GridEditor` allows the records within the `Grid` to be managed (add/edit/delete).
|
|
13
|
+
|
|
14
|
+
For the most part, it follows the React rules of data flowing only top-down through props, and of components not knowing about
|
|
15
|
+
their relative position in the component tree. But there are some cases where such wooden adherence is counterproductive.
|
|
16
|
+
In such cases, the library makes use of the `withComponent` HOC, which adds a “self” prop to every component,
|
|
17
|
+
which has references to parents and children. In this way, a child component can directly reference its parent(s) or children.
|
|
18
|
+
|
|
19
|
+
For parentage examples, the `Form` component closes its grandparent `Editor` in some cases,
|
|
20
|
+
and the `InlineEditor` queries its parent `Grid` to figure out which row it should align with.
|
|
21
|
+
|
|
22
|
+
For a child example, the `Combo` can directly tell its menu `Grid` to `selectNext()` or `selectPrev()`
|
|
23
|
+
based on user keystrokes.
|
|
24
|
+
|
package/package.json
CHANGED
|
@@ -484,38 +484,6 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
|
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
|
|
487
|
-
useEffect(() => {
|
|
488
|
-
if (!SecondaryRepository) {
|
|
489
|
-
return () => {};
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function handleError(msg, data = null) {
|
|
493
|
-
if (data) {
|
|
494
|
-
if (_.isPlainObject(data)) {
|
|
495
|
-
for (let key in data) { if (data.hasOwnProperty(key)) {
|
|
496
|
-
const val1 = data[key];
|
|
497
|
-
if (_.isPlainObject(val1)) {
|
|
498
|
-
for (let key2 in val1) { if (val1.hasOwnProperty(key2)) {
|
|
499
|
-
const val2 = val1[key2];
|
|
500
|
-
msg += "\n" + key + ': ' + val2;
|
|
501
|
-
} }
|
|
502
|
-
} else if (_.isString(data)) {
|
|
503
|
-
msg += "\n" + data;
|
|
504
|
-
}
|
|
505
|
-
} }
|
|
506
|
-
} else {
|
|
507
|
-
// not sure what to do with data!
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
alert(msg);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
SecondaryRepository.on('error', handleError);
|
|
514
|
-
return () => {
|
|
515
|
-
SecondaryRepository.off('error', handleError);
|
|
516
|
-
};
|
|
517
|
-
}, []);
|
|
518
|
-
|
|
519
487
|
useEffect(() => {
|
|
520
488
|
secondarySetEditorMode(calculateEditorMode(secondaryIsIgnoreNextSelectionChange));
|
|
521
489
|
|
|
@@ -498,38 +498,6 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
498
498
|
}
|
|
499
499
|
};
|
|
500
500
|
|
|
501
|
-
useEffect(() => {
|
|
502
|
-
if (!Repository) {
|
|
503
|
-
return () => {};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function handleError(msg, data = null) {
|
|
507
|
-
if (data) {
|
|
508
|
-
if (_.isPlainObject(data)) {
|
|
509
|
-
for (let key in data) { if (data.hasOwnProperty(key)) {
|
|
510
|
-
const val1 = data[key];
|
|
511
|
-
if (_.isPlainObject(val1)) {
|
|
512
|
-
for (let key2 in val1) { if (val1.hasOwnProperty(key2)) {
|
|
513
|
-
const val2 = val1[key2];
|
|
514
|
-
msg += "\n" + key + ': ' + val2;
|
|
515
|
-
} }
|
|
516
|
-
} else if (_.isString(data)) {
|
|
517
|
-
msg += "\n" + data;
|
|
518
|
-
}
|
|
519
|
-
} }
|
|
520
|
-
} else {
|
|
521
|
-
// not sure what to do with data!
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
alert(msg);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
Repository.on('error', handleError);
|
|
528
|
-
return () => {
|
|
529
|
-
Repository.off('error', handleError);
|
|
530
|
-
};
|
|
531
|
-
}, []);
|
|
532
|
-
|
|
533
501
|
useEffect(() => {
|
|
534
502
|
setEditorMode(calculateEditorMode(isIgnoreNextSelectionChange));
|
|
535
503
|
|
|
@@ -44,6 +44,7 @@ export default function withFilters(WrappedComponent) {
|
|
|
44
44
|
showClearFiltersButton = true,
|
|
45
45
|
defaultFilters = [], // likely a list of field names, possibly could be of shape below
|
|
46
46
|
customFilters = [], // of shape: { title, type, field, value, getRepoFilters(value) }
|
|
47
|
+
clearExceptions = [], // list of fields that should not be cleared when clearFilters button is pressed
|
|
47
48
|
minFilters = 3,
|
|
48
49
|
maxFilters = 6,
|
|
49
50
|
onFilterChange,
|
|
@@ -214,7 +215,9 @@ export default function withFilters(WrappedComponent) {
|
|
|
214
215
|
// Clears values for all active filters
|
|
215
216
|
const newFilters = [];
|
|
216
217
|
_.each(filters, (filter) => {
|
|
217
|
-
filter.
|
|
218
|
+
if (!inArray(filter.field, clearExceptions)) {
|
|
219
|
+
filter.value = null;
|
|
220
|
+
}
|
|
218
221
|
newFilters.push(filter);
|
|
219
222
|
});
|
|
220
223
|
setFilters(newFilters, false);
|