ag-common 0.0.521 → 0.0.523
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const CheckboxEdit: ({ defaultValue, onSubmit, noGrow, allowUndo, }: {
|
|
2
|
+
export declare const CheckboxEdit: ({ defaultValue, onSubmit, noGrow, allowUndo, rightSpan, }: {
|
|
3
3
|
defaultValue: boolean;
|
|
4
4
|
onSubmit: (val: boolean) => void;
|
|
5
5
|
noGrow?: boolean | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* if true, will add undo button after changes. if false, will submit after every keypress. default true
|
|
8
8
|
*/
|
|
9
|
-
allowUndo
|
|
9
|
+
allowUndo: boolean;
|
|
10
|
+
/** display to right of CB */
|
|
11
|
+
rightSpan?: React.ReactNode;
|
|
10
12
|
}) => React.JSX.Element;
|
|
@@ -41,7 +41,9 @@ const Icons = (0, styled_1.default)(FlexRow_1.FlexRow) `
|
|
|
41
41
|
top: 0;
|
|
42
42
|
right: -2rem;
|
|
43
43
|
`;
|
|
44
|
-
const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false,
|
|
44
|
+
const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false,
|
|
45
|
+
/** default allowUndo=true */
|
|
46
|
+
allowUndo = true, rightSpan, }) => {
|
|
45
47
|
const ref = (0, react_1.useRef)(null);
|
|
46
48
|
const [value, setValue] = (0, react_1.useState)(defaultValue);
|
|
47
49
|
(0, react_1.useEffect)(() => {
|
|
@@ -53,19 +55,20 @@ const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false, allowUndo = true
|
|
|
53
55
|
onSubmit(value);
|
|
54
56
|
}
|
|
55
57
|
});
|
|
56
|
-
return (react_1.default.createElement(common_2.ValueBox, Object.assign({}, common_1.noDrag, { ref: ref, "data-nogrow": noGrow
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
return (react_1.default.createElement(common_2.ValueBox, Object.assign({}, common_1.noDrag, { style: { cursor: 'pointer' }, ref: ref, "data-nogrow": noGrow, onClick: () => {
|
|
59
|
+
if (allowUndo) {
|
|
60
|
+
setValue(!value);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
onSubmit(!value);
|
|
64
|
+
}
|
|
65
|
+
} }),
|
|
66
|
+
react_1.default.createElement(common_2.ValueInputCB, { type: "checkbox", "data-type": "checkbox", checked: value, onKeyDown: (e) => e.key === 'Enter' && value !== defaultValue && onSubmit(value) }),
|
|
65
67
|
allowUndo && value !== defaultValue && (react_1.default.createElement(Icons, { center: true, enableOverflow: true },
|
|
66
68
|
react_1.default.createElement(common_2.IconD, { style: common_2.iconLeft, onClick: () => value !== defaultValue && onSubmit(value) },
|
|
67
69
|
react_1.default.createElement(Save_1.Save, null)),
|
|
68
70
|
react_1.default.createElement(common_2.IconD, { style: Object.assign(Object.assign({}, common_2.iconRight), { fill: '#134563' }), onClick: () => setValue(defaultValue) },
|
|
69
|
-
react_1.default.createElement(Undo_1.Undo, null))))
|
|
71
|
+
react_1.default.createElement(Undo_1.Undo, null)))),
|
|
72
|
+
!rightSpan ? '' : rightSpan));
|
|
70
73
|
};
|
|
71
74
|
exports.CheckboxEdit = CheckboxEdit;
|
package/package.json
CHANGED