@cakemail-org/ui-components-v2 2.0.75 → 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.
@@ -20,6 +20,7 @@ export type TDropMenuItem = {
20
20
  isMultiSelect?: boolean;
21
21
  selected?: boolean;
22
22
  isTitle?: boolean;
23
+ className?: string;
23
24
  };
24
25
  export type TDropMenuItemClick = (event: MouseEventHandler<HTMLLIElement> | undefined) => void;
25
26
  export type TDropMenuItemMouseDown = (event: MouseEventHandler<HTMLLIElement> | undefined) => void;
@@ -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
@@ -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
  }),
@@ -20,6 +20,7 @@ export type TDropMenuItem = {
20
20
  isMultiSelect?: boolean;
21
21
  selected?: boolean;
22
22
  isTitle?: boolean;
23
+ className?: string;
23
24
  };
24
25
  export type TDropMenuItemClick = (event: MouseEventHandler<HTMLLIElement> | undefined) => void;
25
26
  export type TDropMenuItemMouseDown = (event: MouseEventHandler<HTMLLIElement> | undefined) => void;
@@ -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
@@ -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.75",
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",