@cakemail-org/ui-components-v2 2.0.76 → 2.0.77

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,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { TDropMenuItem } from "./types";
3
- export declare function MenuOption({ preContent, text, postContent, desc, onClick, onMouseDown, divider, value, disabled, isAction, isMultiSelect, selected, isTitle, className, ...parentProps }: TDropMenuItem): React.JSX.Element;
3
+ export declare function MenuOption({ preContent, text, postContent, desc, onClick, onMouseDown, divider, value, disabled, isAction, isMultiSelect, selected, isTitle, ...parentProps }: TDropMenuItem): React.JSX.Element;
4
4
  export default MenuOption;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import "./styles.scss";
3
3
  import { TSearch } from "./types";
4
- export declare function Search({ initValue, name, onChange, intervalTime, placeholder, onClose, className, useClickAway, onEnter }: TSearch): React.JSX.Element;
4
+ export declare function Search({ initValue, name, onChange, intervalTime, placeholder, onClose, className, useClickAway, onEnter, useKeyDownForChange }: TSearch): React.JSX.Element;
5
5
  export default Search;
@@ -8,4 +8,5 @@ export type TSearch = {
8
8
  name?: string;
9
9
  placeholder?: string;
10
10
  intervalTime?: number;
11
+ useKeyDownForChange?: boolean;
11
12
  };
package/dist/cjs/index.js CHANGED
@@ -7958,8 +7958,8 @@ function Checkbox(_a) {
7958
7958
  }
7959
7959
 
7960
7960
  function MenuOption(_a) {
7961
- var preContent = _a.preContent, text = _a.text, postContent = _a.postContent, desc = _a.desc, onClick = _a.onClick, onMouseDown = _a.onMouseDown, divider = _a.divider, value = _a.value, disabled = _a.disabled, isAction = _a.isAction, isMultiSelect = _a.isMultiSelect, selected = _a.selected, isTitle = _a.isTitle, className = _a.className, parentProps = __rest(_a, ["preContent", "text", "postContent", "desc", "onClick", "onMouseDown", "divider", "value", "disabled", "isAction", "isMultiSelect", "selected", "isTitle", "className"]);
7962
- var menuItemClasses = classNames("menuOption-component-v2", className, {
7961
+ var preContent = _a.preContent, text = _a.text, postContent = _a.postContent, desc = _a.desc, onClick = _a.onClick, onMouseDown = _a.onMouseDown, divider = _a.divider, value = _a.value, disabled = _a.disabled, isAction = _a.isAction, isMultiSelect = _a.isMultiSelect, selected = _a.selected, isTitle = _a.isTitle, parentProps = __rest(_a, ["preContent", "text", "postContent", "desc", "onClick", "onMouseDown", "divider", "value", "disabled", "isAction", "isMultiSelect", "selected", "isTitle"]);
7962
+ var menuItemClasses = classNames("menuOption-component-v2", {
7963
7963
  "showPreContent": !!preContent,
7964
7964
  "showDivider": divider,
7965
7965
  "disabled": disabled,
@@ -8276,9 +8276,9 @@ var css_248z$h = ".search-component-v2 {\n width: 100%;\n}\n.search-component-v
8276
8276
  styleInject(css_248z$h);
8277
8277
 
8278
8278
  function Search(_a) {
8279
- var _b = _a.initValue, initValue = _b === void 0 ? "" : _b, name = _a.name, onChange = _a.onChange, _c = _a.intervalTime, intervalTime = _c === void 0 ? 800 : _c, placeholder = _a.placeholder, onClose = _a.onClose, _d = _a.className, className = _d === void 0 ? "" : _d, useClickAway = _a.useClickAway, onEnter = _a.onEnter;
8279
+ var _b = _a.initValue, initValue = _b === void 0 ? "" : _b, name = _a.name, onChange = _a.onChange, _c = _a.intervalTime, intervalTime = _c === void 0 ? 800 : _c, placeholder = _a.placeholder, onClose = _a.onClose, _d = _a.className, className = _d === void 0 ? "" : _d, useClickAway = _a.useClickAway, onEnter = _a.onEnter, _e = _a.useKeyDownForChange, useKeyDownForChange = _e === void 0 ? false : _e;
8280
8280
  var timeoutRef = React.useRef(undefined);
8281
- var _e = React.useState(initValue), value = _e[0], setValue = _e[1];
8281
+ var _f = React.useState(initValue), value = _f[0], setValue = _f[1];
8282
8282
  function handleKeyDown(event) {
8283
8283
  if (event.key === 'Escape') {
8284
8284
  setValue("");
@@ -8293,6 +8293,31 @@ function Search(_a) {
8293
8293
  }
8294
8294
  clearTimeout(timeoutRef.current);
8295
8295
  }
8296
+ else if (useKeyDownForChange) {
8297
+ // To Prevent Material UI Dropdown Auto-Selection by typing
8298
+ handleOnKeyDownChange(event);
8299
+ }
8300
+ }
8301
+ function handleOnKeyDownChange(event) {
8302
+ var target = event.target;
8303
+ target.name;
8304
+ var currentValue = target.value;
8305
+ if (event.key.length === 1) {
8306
+ if (target.selectionStart !== target.selectionEnd) {
8307
+ // Replace selected text with typed character
8308
+ var start = target.selectionStart || 0;
8309
+ var end = target.selectionEnd || 0;
8310
+ currentValue = currentValue.substring(0, start) + event.key + currentValue.substring(end);
8311
+ }
8312
+ else {
8313
+ // Single character keys (letters, numbers, symbols)
8314
+ currentValue = currentValue + event.key;
8315
+ }
8316
+ event.stopPropagation();
8317
+ event.preventDefault();
8318
+ setValue(currentValue);
8319
+ changeTimer(currentValue);
8320
+ }
8296
8321
  }
8297
8322
  function handleOnChange(event) {
8298
8323
  var _a = event === null || event === void 0 ? void 0 : event.currentTarget; _a.name; var value = _a.value;
@@ -8410,7 +8435,7 @@ function Dropdown(_a) {
8410
8435
  }, SelectDisplayProps: {
8411
8436
  color: color
8412
8437
  }, className: "".concat(selectClass, " ").concat(hasValue ? "filled" : "") }),
8413
- searchProps && React.createElement(Search, __assign({}, searchProps)), options === null || options === void 0 ? void 0 :
8438
+ searchProps && React.createElement(Search, __assign({ useKeyDownForChange: true }, searchProps)), options === null || options === void 0 ? void 0 :
8414
8439
  options.map(function (args, index) {
8415
8440
  return React.createElement(MenuOption, __assign({ key: "".concat(id, "-").concat(index), isMultiSelect: isMultiSelect, selected: isMultiSelect ? value === null || value === void 0 ? void 0 : value.includes(args.value || "") : undefined }, args));
8416
8441
  }),
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { TDropMenuItem } from "./types";
3
- export declare function MenuOption({ preContent, text, postContent, desc, onClick, onMouseDown, divider, value, disabled, isAction, isMultiSelect, selected, isTitle, className, ...parentProps }: TDropMenuItem): React.JSX.Element;
3
+ export declare function MenuOption({ preContent, text, postContent, desc, onClick, onMouseDown, divider, value, disabled, isAction, isMultiSelect, selected, isTitle, ...parentProps }: TDropMenuItem): React.JSX.Element;
4
4
  export default MenuOption;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
2
  import "./styles.scss";
3
3
  import { TSearch } from "./types";
4
- export declare function Search({ initValue, name, onChange, intervalTime, placeholder, onClose, className, useClickAway, onEnter }: TSearch): React.JSX.Element;
4
+ export declare function Search({ initValue, name, onChange, intervalTime, placeholder, onClose, className, useClickAway, onEnter, useKeyDownForChange }: TSearch): React.JSX.Element;
5
5
  export default Search;
@@ -8,4 +8,5 @@ export type TSearch = {
8
8
  name?: string;
9
9
  placeholder?: string;
10
10
  intervalTime?: number;
11
+ useKeyDownForChange?: boolean;
11
12
  };
package/dist/esm/index.js CHANGED
@@ -7938,8 +7938,8 @@ function Checkbox(_a) {
7938
7938
  }
7939
7939
 
7940
7940
  function MenuOption(_a) {
7941
- var preContent = _a.preContent, text = _a.text, postContent = _a.postContent, desc = _a.desc, onClick = _a.onClick, onMouseDown = _a.onMouseDown, divider = _a.divider, value = _a.value, disabled = _a.disabled, isAction = _a.isAction, isMultiSelect = _a.isMultiSelect, selected = _a.selected, isTitle = _a.isTitle, className = _a.className, parentProps = __rest(_a, ["preContent", "text", "postContent", "desc", "onClick", "onMouseDown", "divider", "value", "disabled", "isAction", "isMultiSelect", "selected", "isTitle", "className"]);
7942
- var menuItemClasses = classNames("menuOption-component-v2", className, {
7941
+ var preContent = _a.preContent, text = _a.text, postContent = _a.postContent, desc = _a.desc, onClick = _a.onClick, onMouseDown = _a.onMouseDown, divider = _a.divider, value = _a.value, disabled = _a.disabled, isAction = _a.isAction, isMultiSelect = _a.isMultiSelect, selected = _a.selected, isTitle = _a.isTitle, parentProps = __rest(_a, ["preContent", "text", "postContent", "desc", "onClick", "onMouseDown", "divider", "value", "disabled", "isAction", "isMultiSelect", "selected", "isTitle"]);
7942
+ var menuItemClasses = classNames("menuOption-component-v2", {
7943
7943
  "showPreContent": !!preContent,
7944
7944
  "showDivider": divider,
7945
7945
  "disabled": disabled,
@@ -8256,9 +8256,9 @@ var css_248z$h = ".search-component-v2 {\n width: 100%;\n}\n.search-component-v
8256
8256
  styleInject(css_248z$h);
8257
8257
 
8258
8258
  function Search(_a) {
8259
- var _b = _a.initValue, initValue = _b === void 0 ? "" : _b, name = _a.name, onChange = _a.onChange, _c = _a.intervalTime, intervalTime = _c === void 0 ? 800 : _c, placeholder = _a.placeholder, onClose = _a.onClose, _d = _a.className, className = _d === void 0 ? "" : _d, useClickAway = _a.useClickAway, onEnter = _a.onEnter;
8259
+ var _b = _a.initValue, initValue = _b === void 0 ? "" : _b, name = _a.name, onChange = _a.onChange, _c = _a.intervalTime, intervalTime = _c === void 0 ? 800 : _c, placeholder = _a.placeholder, onClose = _a.onClose, _d = _a.className, className = _d === void 0 ? "" : _d, useClickAway = _a.useClickAway, onEnter = _a.onEnter, _e = _a.useKeyDownForChange, useKeyDownForChange = _e === void 0 ? false : _e;
8260
8260
  var timeoutRef = useRef(undefined);
8261
- var _e = useState(initValue), value = _e[0], setValue = _e[1];
8261
+ var _f = useState(initValue), value = _f[0], setValue = _f[1];
8262
8262
  function handleKeyDown(event) {
8263
8263
  if (event.key === 'Escape') {
8264
8264
  setValue("");
@@ -8273,6 +8273,31 @@ function Search(_a) {
8273
8273
  }
8274
8274
  clearTimeout(timeoutRef.current);
8275
8275
  }
8276
+ else if (useKeyDownForChange) {
8277
+ // To Prevent Material UI Dropdown Auto-Selection by typing
8278
+ handleOnKeyDownChange(event);
8279
+ }
8280
+ }
8281
+ function handleOnKeyDownChange(event) {
8282
+ var target = event.target;
8283
+ target.name;
8284
+ var currentValue = target.value;
8285
+ if (event.key.length === 1) {
8286
+ if (target.selectionStart !== target.selectionEnd) {
8287
+ // Replace selected text with typed character
8288
+ var start = target.selectionStart || 0;
8289
+ var end = target.selectionEnd || 0;
8290
+ currentValue = currentValue.substring(0, start) + event.key + currentValue.substring(end);
8291
+ }
8292
+ else {
8293
+ // Single character keys (letters, numbers, symbols)
8294
+ currentValue = currentValue + event.key;
8295
+ }
8296
+ event.stopPropagation();
8297
+ event.preventDefault();
8298
+ setValue(currentValue);
8299
+ changeTimer(currentValue);
8300
+ }
8276
8301
  }
8277
8302
  function handleOnChange(event) {
8278
8303
  var _a = event === null || event === void 0 ? void 0 : event.currentTarget; _a.name; var value = _a.value;
@@ -8390,7 +8415,7 @@ function Dropdown(_a) {
8390
8415
  }, SelectDisplayProps: {
8391
8416
  color: color
8392
8417
  }, className: "".concat(selectClass, " ").concat(hasValue ? "filled" : "") }),
8393
- searchProps && React__default.createElement(Search, __assign({}, searchProps)), options === null || options === void 0 ? void 0 :
8418
+ searchProps && React__default.createElement(Search, __assign({ useKeyDownForChange: true }, searchProps)), options === null || options === void 0 ? void 0 :
8394
8419
  options.map(function (args, index) {
8395
8420
  return React__default.createElement(MenuOption, __assign({ key: "".concat(id, "-").concat(index), isMultiSelect: isMultiSelect, selected: isMultiSelect ? value === null || value === void 0 ? void 0 : value.includes(args.value || "") : undefined }, args));
8396
8421
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cakemail-org/ui-components-v2",
3
- "version": "2.0.76",
3
+ "version": "2.0.77",
4
4
  "description": "ui library kit made with material UI",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",