@onehat/ui 0.2.29 → 0.2.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.
- package/package.json +2 -2
- package/src/Components/Form/Field/CKEditor/CKEditor.js +7 -7
- package/src/Components/Form/Field/Number.js +14 -4
- package/src/Components/Form/Field/Toggle.js +4 -1
- package/src/Components/Grid/Grid.js +14 -10
- package/src/Components/index.js +2 -2
- /package/{OneHatUi.code-workspace → OneHatUi Library.code-workspace} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onehat/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.33",
|
|
4
4
|
"description": "Base UI for OneHat apps",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@onehat/data": "^1.
|
|
22
|
+
"@onehat/data": "^1.15.5",
|
|
23
23
|
"@hookform/resolvers": "^2.9.11",
|
|
24
24
|
"ckeditor5-custom-build": "file:ckeditor5",
|
|
25
25
|
"js-cookie": "^3.0.1",
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
} from 'native-base';
|
|
5
5
|
import {
|
|
6
6
|
AUTO_SUBMIT_DELAY,
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../../../Constants/Input.js';
|
|
8
8
|
import { CKEditor } from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
|
|
9
9
|
import './ckeditor.css';
|
|
10
10
|
import Editor from 'ckeditor5-custom-build/build/ckeditor.js'; // built using https://ckeditor.com/ckeditor-5/online-builder/
|
|
11
|
-
import withValue from '
|
|
12
|
-
import withTooltip from '
|
|
11
|
+
import withValue from '../../../Hoc/withValue.js';
|
|
12
|
+
import withTooltip from '../../../Hoc/withTooltip.js';
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
const
|
|
17
|
-
|
|
17
|
+
CKEditorElement = (props) => {
|
|
18
18
|
const {
|
|
19
19
|
value,
|
|
20
20
|
setValue,
|
|
@@ -53,12 +53,12 @@ const
|
|
|
53
53
|
/>
|
|
54
54
|
</Row>;
|
|
55
55
|
},
|
|
56
|
-
|
|
56
|
+
CKEditorField = withValue(CKEditorElement);
|
|
57
57
|
|
|
58
58
|
|
|
59
|
-
export default
|
|
59
|
+
export default CKEditorField;
|
|
60
60
|
|
|
61
61
|
// // Tooltip needs us to forwardRef
|
|
62
62
|
// export default withTooltip(React.forwardRef((props, ref) => {
|
|
63
|
-
// return <
|
|
63
|
+
// return <CKEditorField {...props} outerRef={ref} />;
|
|
64
64
|
// }));
|
|
@@ -30,7 +30,8 @@ function NumberElement(props) {
|
|
|
30
30
|
debouncedSetValueRef = useRef(),
|
|
31
31
|
[localValue, setLocalValue] = useState(value),
|
|
32
32
|
onInputKeyPress = (e) => {
|
|
33
|
-
|
|
33
|
+
const key = e.nativeEvent.key; // e.key works on web, but not mobile; so use e.nativeEvent.key which works on both
|
|
34
|
+
switch(key) {
|
|
34
35
|
case 'ArrowDown':
|
|
35
36
|
case 'ArrowLeft':
|
|
36
37
|
onDecrement();
|
|
@@ -48,7 +49,7 @@ function NumberElement(props) {
|
|
|
48
49
|
break;
|
|
49
50
|
default:
|
|
50
51
|
}
|
|
51
|
-
if (!
|
|
52
|
+
if (!key.match(/^[\-\d\.]*$/)) {
|
|
52
53
|
e.preventDefault(); // kill anything that's not a number
|
|
53
54
|
}
|
|
54
55
|
},
|
|
@@ -56,6 +57,7 @@ function NumberElement(props) {
|
|
|
56
57
|
if (value === '') {
|
|
57
58
|
value = null; // empty string makes value null
|
|
58
59
|
}
|
|
60
|
+
value = parseFloat(value, 10);
|
|
59
61
|
setLocalValue(value);
|
|
60
62
|
debouncedSetValueRef.current(value);
|
|
61
63
|
},
|
|
@@ -91,7 +93,9 @@ function NumberElement(props) {
|
|
|
91
93
|
useEffect(() => {
|
|
92
94
|
|
|
93
95
|
// Make local value conform to externally changed value
|
|
94
|
-
|
|
96
|
+
if (value !== localValue) {
|
|
97
|
+
setLocalValue(value);
|
|
98
|
+
}
|
|
95
99
|
|
|
96
100
|
}, [value]);
|
|
97
101
|
|
|
@@ -99,6 +103,12 @@ function NumberElement(props) {
|
|
|
99
103
|
localValue = ''; // If the value is null or undefined, don't let this be an uncontrolled input
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
// convert localValue to string if necessary, because numbers work on web but not mobile; while strings work in both places
|
|
107
|
+
let inputValue = localValue;
|
|
108
|
+
if (_.isNumber(inputValue)) {
|
|
109
|
+
inputValue = '' + inputValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
102
112
|
const
|
|
103
113
|
isIncrementDisabled = typeof maxValue !== 'undefined' && value === maxValue,
|
|
104
114
|
isDecrementDisabled = typeof minValue !== 'undefined' && (value === minValue || (!value && minValue === 0));
|
|
@@ -118,7 +128,7 @@ function NumberElement(props) {
|
|
|
118
128
|
zIndex={10}
|
|
119
129
|
/>
|
|
120
130
|
<InputWithTooltip
|
|
121
|
-
value={
|
|
131
|
+
value={inputValue}
|
|
122
132
|
onChangeText={onChangeText}
|
|
123
133
|
onKeyPress={onInputKeyPress}
|
|
124
134
|
flex={5}
|
|
@@ -11,11 +11,14 @@ const
|
|
|
11
11
|
const {
|
|
12
12
|
value,
|
|
13
13
|
setValue,
|
|
14
|
+
flex, // flex doesn't work right on mobile
|
|
15
|
+
...propsToPass
|
|
14
16
|
} = props,
|
|
15
17
|
styles = UiGlobals.styles,
|
|
16
18
|
onToggle = () => {
|
|
17
19
|
setValue(!value);
|
|
18
20
|
};
|
|
21
|
+
|
|
19
22
|
return <Switch
|
|
20
23
|
ref={props.outerRef}
|
|
21
24
|
onToggle={onToggle}
|
|
@@ -29,7 +32,7 @@ const
|
|
|
29
32
|
onTrackColor: styles.FORM_TOGGLE_ON_HOVER_COLOR,
|
|
30
33
|
offTrackColor: styles.FORM_TOGGLE_OFF_HOVER_COLOR,
|
|
31
34
|
}}
|
|
32
|
-
{...
|
|
35
|
+
{...propsToPass}
|
|
33
36
|
/>;
|
|
34
37
|
},
|
|
35
38
|
ToggleField = withValue(ToggleElement);
|
|
@@ -361,10 +361,22 @@ export function Grid(props) {
|
|
|
361
361
|
bg = styles.GRID_ROW_BG;
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
let WhichGridRow = GridRow
|
|
364
|
+
let WhichGridRow = GridRow,
|
|
365
|
+
rowReorderProps = {};
|
|
365
366
|
if (canRowsReorder && isReorderMode) {
|
|
366
367
|
WhichGridRow = ReorderableGridRow;
|
|
368
|
+
reorderProps = {
|
|
369
|
+
mode: VERTICAL,
|
|
370
|
+
onDragStart: onRowReorderDragStart,
|
|
371
|
+
onDrag: onRowReorderDrag,
|
|
372
|
+
onDragStop: onRowReorderDragStop,
|
|
373
|
+
proxyParent: gridRef.current?.getScrollableNode().children[0],
|
|
374
|
+
proxyPositionRelativeToParent: true,
|
|
375
|
+
getParentNode: (node) => node.parentElement.parentElement.parentElement,
|
|
376
|
+
getProxy: getReorderProxy,
|
|
377
|
+
};
|
|
367
378
|
}
|
|
379
|
+
|
|
368
380
|
return <WhichGridRow
|
|
369
381
|
columnsConfig={localColumnsConfig}
|
|
370
382
|
columnProps={columnProps}
|
|
@@ -373,15 +385,7 @@ export function Grid(props) {
|
|
|
373
385
|
hideNavColumn={hideNavColumn}
|
|
374
386
|
bg={bg}
|
|
375
387
|
item={item}
|
|
376
|
-
|
|
377
|
-
mode={VERTICAL}
|
|
378
|
-
onDragStart={onRowReorderDragStart}
|
|
379
|
-
onDrag={onRowReorderDrag}
|
|
380
|
-
onDragStop={onRowReorderDragStop}
|
|
381
|
-
proxyParent={gridRef.current?.getScrollableNode().children[0]}
|
|
382
|
-
proxyPositionRelativeToParent={true}
|
|
383
|
-
getParentNode={(node) => node.parentElement.parentElement.parentElement}
|
|
384
|
-
getProxy={getReorderProxy}
|
|
388
|
+
{...rowReorderProps}
|
|
385
389
|
/>;
|
|
386
390
|
}}
|
|
387
391
|
</Pressable>;
|
package/src/Components/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import ArrayRadioGroup from './Form/Field/RadioGroup/ArrayRadioGroup.js';
|
|
|
9
9
|
import Blank from './Blank.js';
|
|
10
10
|
import BooleanCombo from './Form/Field/Combo/BooleanCombo.js';
|
|
11
11
|
// import CartButtonWithBadge from '../Components/Buttons/CartButtonWithBadge.js';
|
|
12
|
+
// import CKEditor from './Form/Field/CKEditor/CKEditor.js'; // web only
|
|
12
13
|
import CheckboxGroup from './Form/Field/CheckboxGroup/CheckboxGroup.js';
|
|
13
14
|
import Color from './Form/Field/Color.js';
|
|
14
15
|
import Combo from './Form/Field/Combo/Combo.js';
|
|
@@ -25,7 +26,6 @@ import FiltersForm from './Form/FiltersForm.js';
|
|
|
25
26
|
import Form from './Form/Form.js';
|
|
26
27
|
import Grid from './Grid/Grid.js';
|
|
27
28
|
import GridPanel from './Panel/GridPanel.js';
|
|
28
|
-
import HtmlEditor from './Form/Field/HtmlEditor.js';
|
|
29
29
|
import IconButton from './Buttons/IconButton.js';
|
|
30
30
|
import Input from './Form/Field/Input.js';
|
|
31
31
|
import IntervalsCombo from './Form/Field/Combo/IntervalsCombo.js';
|
|
@@ -56,6 +56,7 @@ const components = {
|
|
|
56
56
|
BooleanCombo,
|
|
57
57
|
// CartButtonWithBadge,
|
|
58
58
|
CheckboxGroup,
|
|
59
|
+
// CKEditor,
|
|
59
60
|
Color,
|
|
60
61
|
Column,
|
|
61
62
|
Combo,
|
|
@@ -72,7 +73,6 @@ const components = {
|
|
|
72
73
|
Form,
|
|
73
74
|
Grid,
|
|
74
75
|
GridPanel,
|
|
75
|
-
HtmlEditor,
|
|
76
76
|
IconButton,
|
|
77
77
|
Input,
|
|
78
78
|
IntervalsCombo,
|
|
File without changes
|