ag-common 0.0.385 → 0.0.386

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.
@@ -6,7 +6,7 @@ export interface IButton {
6
6
  disabled?: boolean;
7
7
  className?: string;
8
8
  onClick?: MouseEventHandler<HTMLButtonElement>;
9
- onKeyPress?: KeyboardEventHandler<HTMLButtonElement>;
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(), onKeyPress: (e) => e.key === 'Enter' && (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;
@@ -69,14 +69,14 @@ const SearchBox = (p) => {
69
69
  (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue(p.searchText);
70
70
  }, [p.searchText, textEditRef]);
71
71
  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(Icon, null,
72
+ react_1.default.createElement(TextEdit_1.TextEdit, { ref: textEditRef, placeholder: p.placeholderText, defaultEditing: { focus: true }, singleLine: true, leftContent: react_1.default.createElement(Icon, { onClick: () => { var _a; return p.setSearchText(((_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.getValue()) || '', true); } },
73
73
  react_1.default.createElement(icons_1.Magnify, null)), noGrow: true, allowUndo: false, onClickOutsideWithNoValue: null, onSubmit: (v, enterPressed) => (0, helpers_1.debounce)(() => {
74
74
  p.setSearchText(v, enterPressed);
75
75
  }, { key: 'pagesearch', time: 200 }), defaultValue: p.defaultValue }),
76
76
  p.searchText && (react_1.default.createElement(CrossIconStyled, { onClick: () => {
77
77
  var _a;
78
78
  (_a = textEditRef.current) === null || _a === void 0 ? void 0 : _a.setValue('');
79
- p.setSearchText('', false);
79
+ p.setSearchText('', true);
80
80
  } }))));
81
81
  };
82
82
  exports.SearchBox = SearchBox;
@@ -60,7 +60,7 @@ const CheckboxEdit = ({ defaultValue, onSubmit, noGrow = false, allowUndo = true
60
60
  else {
61
61
  onSubmit(!value);
62
62
  }
63
- }, onKeyPress: (e) => e.key === 'Enter' && value !== defaultValue && onSubmit(value) }),
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)),
@@ -107,6 +107,7 @@ exports.TextEdit = (0, react_2.forwardRef)((p, ref) => {
107
107
  var _a, _b;
108
108
  (_b = (_a = taref.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
109
109
  },
110
+ getValue: () => { var _a; return (_a = taref.current) === null || _a === void 0 ? void 0 : _a.value; },
110
111
  }));
111
112
  (0, useOnClickOutside_1.useOnClickOutside)({
112
113
  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), onKeyPress: (e) => e.key === 'Enter' && valid && onSubmit(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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.385",
3
+ "version": "0.0.386",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",