@onehat/ui 0.3.113 → 0.3.115
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/Grid/Grid.js +88 -67
- package/src/Components/Grid/GridHeaderRow.js +1 -1
- package/src/Components/Icons/SortDown.js +1 -1
- package/src/Components/Icons/SortDownAlt.js +14 -0
- package/src/Components/Icons/SortUp.js +2 -6
- package/src/Components/Icons/SortUpAlt.js +18 -0
- package/src/Components/index.js +4 -0
package/package.json
CHANGED
|
@@ -42,6 +42,8 @@ import withMultiSelection from '../Hoc/withMultiSelection.js';
|
|
|
42
42
|
import withSelection from '../Hoc/withSelection.js';
|
|
43
43
|
import withWindowedEditor from '../Hoc/withWindowedEditor.js';
|
|
44
44
|
import withInlineEditor from '../Hoc/withInlineEditor.js';
|
|
45
|
+
import getSaved from '../../Functions/getSaved.js';
|
|
46
|
+
import setSaved from '../../Functions/setSaved.js';
|
|
45
47
|
import getIconButtonFromConfig from '../../Functions/getIconButtonFromConfig.js';
|
|
46
48
|
import testProps from '../../Functions/testProps.js';
|
|
47
49
|
import nbToRgb from '../../Functions/nbToRgb.js';
|
|
@@ -167,6 +169,8 @@ function GridComponent(props) {
|
|
|
167
169
|
|
|
168
170
|
} = props,
|
|
169
171
|
styles = UiGlobals.styles,
|
|
172
|
+
id = props.id || props.self?.path,
|
|
173
|
+
localColumnsConfigKey = id && id + '-localColumnsConfig',
|
|
170
174
|
forceUpdate = useForceUpdate(),
|
|
171
175
|
containerRef = useRef(),
|
|
172
176
|
gridRef = useRef(),
|
|
@@ -180,6 +184,10 @@ function GridComponent(props) {
|
|
|
180
184
|
[dragRowSlot, setDragRowSlot] = useState(null),
|
|
181
185
|
[dragRowIx, setDragRowIx] = useState(),
|
|
182
186
|
setLocalColumnsConfig = (config) => {
|
|
187
|
+
if (localColumnsConfigKey) {
|
|
188
|
+
setSaved(localColumnsConfigKey, config);
|
|
189
|
+
}
|
|
190
|
+
|
|
183
191
|
setLocalColumnsConfigRaw(config);
|
|
184
192
|
if (onChangeColumnsConfig) {
|
|
185
193
|
onChangeColumnsConfig(config);
|
|
@@ -718,79 +726,92 @@ function GridComponent(props) {
|
|
|
718
726
|
return () => {};
|
|
719
727
|
}
|
|
720
728
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
//
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
});
|
|
735
|
-
}
|
|
729
|
+
(async () => {
|
|
730
|
+
|
|
731
|
+
// second call -- do other necessary setup
|
|
732
|
+
|
|
733
|
+
// calculate localColumnsConfig
|
|
734
|
+
let localColumnsConfig = [];
|
|
735
|
+
let savedLocalColumnsConfig;
|
|
736
|
+
if (localColumnsConfigKey) {
|
|
737
|
+
savedLocalColumnsConfig = await getSaved(localColumnsConfigKey);
|
|
738
|
+
}
|
|
739
|
+
if (savedLocalColumnsConfig) {
|
|
740
|
+
// use saved
|
|
741
|
+
localColumnsConfig = savedLocalColumnsConfig;
|
|
736
742
|
} else {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
743
|
+
// calculate new
|
|
744
|
+
|
|
745
|
+
// convert json config into actual elements
|
|
746
|
+
if (_.isEmpty(columnsConfig)) {
|
|
747
|
+
if (Repository) {
|
|
748
|
+
// create a column for the displayProperty
|
|
749
|
+
localColumnsConfig.push({
|
|
750
|
+
fieldName: Repository.schema.model.displayProperty,
|
|
751
|
+
});
|
|
752
|
+
} else {
|
|
753
|
+
localColumnsConfig.push({
|
|
754
|
+
fieldName: displayField,
|
|
755
|
+
});
|
|
741
756
|
}
|
|
757
|
+
} else {
|
|
758
|
+
_.each(columnsConfig, (columnConfig) => {
|
|
759
|
+
if (!_.isPlainObject(columnConfig)) {
|
|
760
|
+
localColumnsConfig.push(columnConfig);
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
742
763
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
764
|
+
// destructure so we can set defaults
|
|
765
|
+
const {
|
|
766
|
+
header,
|
|
767
|
+
fieldName, // from @onehat/data model
|
|
768
|
+
type, // specify which column type to use (custom or built-in)
|
|
769
|
+
isEditable = false,
|
|
770
|
+
editor,
|
|
771
|
+
format,
|
|
772
|
+
renderer, // React component will render the output
|
|
773
|
+
reorderable = true,
|
|
774
|
+
resizable = true,
|
|
775
|
+
sortable = true,
|
|
776
|
+
w,
|
|
777
|
+
flex,
|
|
778
|
+
...propsToPass
|
|
779
|
+
} = columnConfig,
|
|
780
|
+
|
|
781
|
+
config = {
|
|
782
|
+
columnId: uuid(),
|
|
783
|
+
header,
|
|
784
|
+
fieldName,
|
|
785
|
+
type,
|
|
786
|
+
isEditable,
|
|
787
|
+
editor,
|
|
788
|
+
format,
|
|
789
|
+
renderer,
|
|
790
|
+
reorderable,
|
|
791
|
+
resizable,
|
|
792
|
+
sortable,
|
|
793
|
+
w,
|
|
794
|
+
flex,
|
|
795
|
+
showDragHandles: false,
|
|
796
|
+
...propsToPass,
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
if (!(config.w || config.width) && !config.flex) {
|
|
800
|
+
// Neither is set
|
|
801
|
+
config.w = 100; // default
|
|
802
|
+
} else if (config.flex && (config.w || config.width)) {
|
|
803
|
+
// Both are set. Width overrules flex.
|
|
804
|
+
delete config.flex;
|
|
805
|
+
}
|
|
785
806
|
|
|
786
|
-
|
|
787
|
-
|
|
807
|
+
localColumnsConfig.push(config);
|
|
808
|
+
});
|
|
809
|
+
}
|
|
788
810
|
}
|
|
789
|
-
|
|
790
|
-
}
|
|
791
|
-
setLocalColumnsConfig(calculateLocalColumnsConfig());
|
|
811
|
+
setLocalColumnsConfig(localColumnsConfig);
|
|
792
812
|
|
|
793
|
-
|
|
813
|
+
setIsReady(true);
|
|
814
|
+
})();
|
|
794
815
|
|
|
795
816
|
if (!Repository) {
|
|
796
817
|
return () => {};
|
|
@@ -6,7 +6,7 @@ import { Icon } from 'native-base';
|
|
|
6
6
|
function SvgComponent(props) {
|
|
7
7
|
return (
|
|
8
8
|
<Icon xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" {...props}>
|
|
9
|
-
<Path d="M151.6 469.6C145.5 476.2 137 480 128 480s-17.5-3.8-23.6-10.4l-88-96c-11.9-13-11.1-33.3 2-45.2s33.3-11.1 45.2 2L96 365.7V64c0-17.7 14.3-32 32-32s32 14.3 32 32v301.7l32.4-35.4c11.9-13 32.2-13.9 45.2-2s13.9 32.2 2 45.2l-88 96zM320 32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32h-
|
|
9
|
+
<Path d="M151.6 469.6C145.5 476.2 137 480 128 480s-17.5-3.8-23.6-10.4l-88-96c-11.9-13-11.1-33.3 2-45.2s33.3-11.1 45.2 2L96 365.7V64c0-17.7 14.3-32 32-32s32 14.3 32 32v301.7l32.4-35.4c11.9-13 32.2-13.9 45.2-2s13.9 32.2 2 45.2l-88 96zM320 480c-17.7 0-32-14.3-32-32s14.3-32 32-32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32h-32zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32h96c17.7 0 32 14.3 32 32s-14.3 32-32 32h-96zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32h160c17.7 0 32 14.3 32 32s-14.3 32-32 32H320zm0-128c-17.7 0-32-14.3-32-32s14.3-32 32-32h224c17.7 0 32 14.3 32 32s-14.3 32-32 32H320z" />
|
|
10
10
|
</Icon>
|
|
11
11
|
)
|
|
12
12
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" {...props}>
|
|
9
|
+
<Path d="M151.6 469.6C145.5 476.2 137 480 128 480s-17.5-3.8-23.6-10.4l-88-96c-11.9-13-11.1-33.3 2-45.2s33.3-11.1 45.2 2L96 365.7V64c0-17.7 14.3-32 32-32s32 14.3 32 32v301.7l32.4-35.4c11.9-13 32.2-13.9 45.2-2s13.9 32.2 2 45.2l-88 96zM320 32h32c17.7 0 32 14.3 32 32s-14.3 32-32 32h-32c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 128h96c17.7 0 32 14.3 32 32s-14.3 32-32 32h-96c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 128h160c17.7 0 32 14.3 32 32s-14.3 32-32 32H320c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 128h224c17.7 0 32 14.3 32 32s-14.3 32-32 32H320c-17.7 0-32-14.3-32-32s14.3-32 32-32z" />
|
|
10
|
+
</Icon>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default SvgComponent
|
|
@@ -5,12 +5,8 @@ import { Icon } from 'native-base';
|
|
|
5
5
|
|
|
6
6
|
function SvgComponent(props) {
|
|
7
7
|
return (
|
|
8
|
-
<Icon
|
|
9
|
-
|
|
10
|
-
viewBox="0 0 576 512"
|
|
11
|
-
{...props}
|
|
12
|
-
>
|
|
13
|
-
<Path d="M151.6 42.4C145.5 35.8 137 32 128 32s-17.5 3.8-23.6 10.4l-88 96c-11.9 13-11.1 33.3 2 45.2s33.3 11.1 45.2-2L96 146.3V448c0 17.7 14.3 32 32 32s32-14.3 32-32V146.3l32.4 35.4c11.9 13 32.2 13.9 45.2 2s13.9-32.2 2-45.2l-88-96zM320 480h32c17.7 0 32-14.3 32-32s-14.3-32-32-32h-32c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h96c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h224c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32z" />
|
|
8
|
+
<Icon xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" {...props}>
|
|
9
|
+
<Path d="M151.6 42.4C145.5 35.8 137 32 128 32s-17.5 3.8-23.6 10.4l-88 96c-11.9 13-11.1 33.3 2 45.2s33.3 11.1 45.2-2L96 146.3V448c0 17.7 14.3 32 32 32s32-14.3 32-32V146.3l32.4 35.4c11.9 13 32.2 13.9 45.2 2s13.9-32.2 2-45.2l-88-96zM320 480h32c17.7 0 32-14.3 32-32s-14.3-32-32-32h-32c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h96c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h224c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32z" />
|
|
14
10
|
</Icon>
|
|
15
11
|
)
|
|
16
12
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 576 512"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<Path d="M151.6 42.4C145.5 35.8 137 32 128 32s-17.5 3.8-23.6 10.4l-88 96c-11.9 13-11.1 33.3 2 45.2s33.3 11.1 45.2-2L96 146.3V448c0 17.7 14.3 32 32 32s32-14.3 32-32V146.3l32.4 35.4c11.9 13 32.2 13.9 45.2 2s13.9-32.2 2-45.2l-88-96zM320 480h32c17.7 0 32-14.3 32-32s-14.3-32-32-32h-32c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h96c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32zm0-128h224c17.7 0 32-14.3 32-32s-14.3-32-32-32H320c-17.7 0-32 14.3-32 32s14.3 32 32 32z" />
|
|
14
|
+
</Icon>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default SvgComponent
|
package/src/Components/index.js
CHANGED
|
@@ -151,7 +151,9 @@ import Scroll from '../Components/Icons/Scroll.js';
|
|
|
151
151
|
import Share from '../Components/Icons/Share.js';
|
|
152
152
|
import Shop from '../Components/Icons/Shop.js';
|
|
153
153
|
import SideBySide from '../Components/Icons/SideBySide.js';
|
|
154
|
+
import SortDownAlt from '../Components/Icons/SortDownAlt.js';
|
|
154
155
|
import SortDown from '../Components/Icons/SortDown.js';
|
|
156
|
+
import SortUpAlt from '../Components/Icons/SortUpAlt.js';
|
|
155
157
|
import SortUp from '../Components/Icons/SortUp.js';
|
|
156
158
|
import Square from '../Components/Icons/Square.js';
|
|
157
159
|
import SquareCheck from '../Components/Icons/SquareCheck.js';
|
|
@@ -376,7 +378,9 @@ const components = {
|
|
|
376
378
|
Share,
|
|
377
379
|
Shop,
|
|
378
380
|
SideBySide,
|
|
381
|
+
SortDownAlt,
|
|
379
382
|
SortDown,
|
|
383
|
+
SortUpAlt,
|
|
380
384
|
SortUp,
|
|
381
385
|
Square,
|
|
382
386
|
SquareCheck,
|