ag-common 0.0.385 → 0.0.387
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/dist/ui/components/Button/index.d.ts +1 -1
- package/dist/ui/components/Chevron/index.js +1 -1
- package/dist/ui/components/Search/SearchBox.d.ts +3 -2
- package/dist/ui/components/Search/SearchBox.js +19 -7
- package/dist/ui/components/TextEdit/CheckboxEdit.js +1 -1
- package/dist/ui/components/TextEdit/TextEdit.js +2 -4
- package/dist/ui/components/TextEdit/types.d.ts +2 -0
- package/dist/ui/components/TextWithButton/index.js +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export interface IButton {
|
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
className?: string;
|
|
8
8
|
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
9
|
-
|
|
9
|
+
onKeyDown?: KeyboardEventHandler<HTMLButtonElement>;
|
|
10
10
|
children: string | JSX.Element;
|
|
11
11
|
href?: string;
|
|
12
12
|
colourTheme?: 'green' | 'red';
|
|
@@ -38,7 +38,7 @@ const Chevron = ({ width = '1.2rem', className, colour = 'black', onToggle, poin
|
|
|
38
38
|
rotate = 0;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
return (react_1.default.createElement(Base, { className: className, onClick: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(), onTouchStart: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(),
|
|
41
|
+
return (react_1.default.createElement(Base, { className: className, onClick: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(), onTouchStart: () => onToggle === null || onToggle === void 0 ? void 0 : onToggle(), onKeyDown: (e) => e.key === 'Enter' && (onToggle === null || onToggle === void 0 ? void 0 : onToggle()) },
|
|
42
42
|
react_1.default.createElement(IconStyled, { rotate: rotate, fill: colour, width: width, height: width }, ChevronRight_1.ChevronRight)));
|
|
43
43
|
};
|
|
44
44
|
exports.Chevron = Chevron;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IRefTextEdit } from '../TextEdit';
|
|
2
3
|
export interface ISearchBox {
|
|
3
4
|
placeholderText?: string;
|
|
4
5
|
searchText: string;
|
|
@@ -6,4 +7,4 @@ export interface ISearchBox {
|
|
|
6
7
|
defaultValue?: string;
|
|
7
8
|
className?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const SearchBox:
|
|
10
|
+
export declare const SearchBox: React.ForwardRefExoticComponent<ISearchBox & React.RefAttributes<IRefTextEdit>>;
|
|
@@ -50,10 +50,11 @@ const Base = styled_1.default.div `
|
|
|
50
50
|
width: 100%;
|
|
51
51
|
}
|
|
52
52
|
`;
|
|
53
|
-
const
|
|
53
|
+
const MagnifyIcon = styled_1.default.div `
|
|
54
54
|
width: 1.5rem;
|
|
55
55
|
height: 1.5rem;
|
|
56
56
|
margin-right: 0.5rem;
|
|
57
|
+
cursor: pointer;
|
|
57
58
|
`;
|
|
58
59
|
const CrossIconStyled = (0, styled_1.default)(icons_1.CrossIcon) `
|
|
59
60
|
position: absolute;
|
|
@@ -62,21 +63,32 @@ const CrossIconStyled = (0, styled_1.default)(icons_1.CrossIcon) `
|
|
|
62
63
|
right: 2rem;
|
|
63
64
|
}
|
|
64
65
|
`;
|
|
65
|
-
|
|
66
|
+
exports.SearchBox = (0, react_1.forwardRef)((p, ref) => {
|
|
66
67
|
const textEditRef = (0, react_1.createRef)();
|
|
68
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
69
|
+
setValue: (v) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const value = (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue();
|
|
72
|
+
if (v === value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
(_b = textEditRef.current) === null || _b === void 0 ? void 0 : _b.setValue(v);
|
|
76
|
+
},
|
|
77
|
+
focus: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
78
|
+
getValue: () => { var _a; return (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue(); },
|
|
79
|
+
}));
|
|
67
80
|
(0, react_1.useEffect)(() => {
|
|
68
81
|
var _a;
|
|
69
|
-
(_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
|
|
82
|
+
(_a = textEditRef === null || textEditRef === void 0 ? void 0 : textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
|
|
70
83
|
}, [p.searchText, textEditRef]);
|
|
71
84
|
return (react_1.default.createElement(Base, Object.assign({ "data-type": "search", className: p.className }, (0, helpers_1.filterDataProps)(p)),
|
|
72
|
-
react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(
|
|
85
|
+
react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(MagnifyIcon, { onClick: () => { var _a; return p.setSearchText(((_a = textEditRef === null || textEditRef === void 0 ? void 0 : textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
|
|
73
86
|
react_1.default.createElement(icons_1.Magnify, null)), noGrow: true, allowUndo: false, onClickOutsideWithNoValue: null, onSubmit: (v, enterPressed) => (0, helpers_1.debounce)(() => {
|
|
74
87
|
p.setSearchText(v, enterPressed);
|
|
75
88
|
}, { key: 'pagesearch', time: 200 }), defaultValue: p.defaultValue }),
|
|
76
89
|
p.searchText && (react_1.default.createElement(CrossIconStyled, { onClick: () => {
|
|
77
90
|
var _a;
|
|
78
91
|
(_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
|
|
79
|
-
p.setSearchText('',
|
|
92
|
+
p.setSearchText('', true);
|
|
80
93
|
} }))));
|
|
81
|
-
};
|
|
82
|
-
exports.SearchBox = SearchBox;
|
|
94
|
+
});
|
|
@@ -60,7 +60,7 @@ const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false, allowUndo = true
|
|
|
60
60
|
else {
|
|
61
61
|
onSubmit(!value);
|
|
62
62
|
}
|
|
63
|
-
},
|
|
63
|
+
}, onKeyDown: (e) => e.key === 'Enter' && value !== defaultValue && onSubmit(value) }),
|
|
64
64
|
allowUndo && value !== defaultValue && (react_1.default.createElement(Icons, { center: true, enableOverflow: true },
|
|
65
65
|
react_1.default.createElement(common_2.IconD, { style: common_2.iconLeft, onClick: () => value !== defaultValue && onSubmit(value) },
|
|
66
66
|
react_1.default.createElement(Save_1.Save, null)),
|
|
@@ -103,10 +103,8 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
|
|
|
103
103
|
}
|
|
104
104
|
setValue(v);
|
|
105
105
|
},
|
|
106
|
-
focus: () => {
|
|
107
|
-
|
|
108
|
-
(_b = (_a = taref.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
109
|
-
},
|
|
106
|
+
focus: () => { var _a; return (_a = taref.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
107
|
+
getValue: () => { var _a; return (_a = taref.current) === null || _a === void 0 ? void 0 : _a.value; },
|
|
110
108
|
}));
|
|
111
109
|
(0, useOnClickOutside_1.useOnClickOutside)({
|
|
112
110
|
disabled: p.onClickOutsideWithNoValue === null || disableEdit,
|
|
@@ -2,6 +2,8 @@ import React from 'react';
|
|
|
2
2
|
export interface IRefTextEdit {
|
|
3
3
|
/** Set the internal value of the typed string. Can be used to clear externally */
|
|
4
4
|
setValue: React.Dispatch<React.SetStateAction<string>>;
|
|
5
|
+
getValue: () => string | undefined;
|
|
6
|
+
focus: () => void;
|
|
5
7
|
}
|
|
6
8
|
export interface ITextEdit {
|
|
7
9
|
/**
|
|
@@ -71,7 +71,7 @@ const TextWithButton = ({ submitText = 'Submit', placeholder, validateF, onSubmi
|
|
|
71
71
|
const [value, setValue] = (0, react_1.useState)('');
|
|
72
72
|
const valid = !validateF ? true : validateF(value);
|
|
73
73
|
return (react_1.default.createElement(Base, null,
|
|
74
|
-
react_1.default.createElement(Input, { "data-type": "input", "data-valid": valid, placeholder: placeholder, value: value, onChange: (s) => setValue(s.target.value),
|
|
74
|
+
react_1.default.createElement(Input, { "data-type": "input", "data-valid": valid, placeholder: placeholder, value: value, onChange: (s) => setValue(s.target.value), onKeyDown: (e) => e.key === 'Enter' && valid && onSubmit(value) }),
|
|
75
75
|
react_1.default.createElement(Button, { "data-type": "button", "data-valid": valid, disabled: !valid, onClick: () => valid && onSubmit(value) }, submitText)));
|
|
76
76
|
};
|
|
77
77
|
exports.TextWithButton = TextWithButton;
|