albinasoft-ui-package 1.0.33 → 1.0.34

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.
@@ -33,3 +33,9 @@
33
33
  .dark .autocomplete-option:hover {
34
34
  background-color: #444;
35
35
  }
36
+
37
+ mark {
38
+ background-color: yellow;
39
+ color: black;
40
+ font-weight: bold;
41
+ }
@@ -63,11 +63,13 @@ var react_1 = __importStar(require("react"));
63
63
  var fa_1 = require("react-icons/fa");
64
64
  var react_bootstrap_1 = require("react-bootstrap");
65
65
  require("../assets/css/custom-autocomplete-input.css");
66
+ var CustomInput_1 = __importStar(require("./CustomInput"));
66
67
  var CustomAutocompleteInput = function (_a) {
67
68
  var id = _a.id, name = _a.name, label = _a.label, value = _a.value, placeholder = _a.placeholder, _b = _a.required, required = _b === void 0 ? false : _b, description = _a.description, errorMessage = _a.errorMessage, conditionalErrorVisible = _a.conditionalErrorVisible, conditionalErrorMessage = _a.conditionalErrorMessage, _c = _a.disabled, disabled = _c === void 0 ? false : _c, tooltip = _a.tooltip, _d = _a.className, className = _d === void 0 ? '' : _d, style = _a.style, fetchOptions = _a.fetchOptions, onSelect = _a.onSelect;
68
69
  var _e = (0, react_1.useState)(value || ''), inputValue = _e[0], setInputValue = _e[1];
69
- var _f = (0, react_1.useState)([]), options = _f[0], setOptions = _f[1];
70
- var _g = (0, react_1.useState)(false), isDropdownVisible = _g[0], setIsDropdownVisible = _g[1];
70
+ var _f = (0, react_1.useState)(null), selectedValue = _f[0], setSelectedValue = _f[1];
71
+ var _g = (0, react_1.useState)([]), options = _g[0], setOptions = _g[1];
72
+ var _h = (0, react_1.useState)(false), isDropdownVisible = _h[0], setIsDropdownVisible = _h[1];
71
73
  var dropdownRef = (0, react_1.useRef)(null);
72
74
  // Input değiştiğinde fetchOptions çağır
73
75
  var handleInputChange = function (e) { return __awaiter(void 0, void 0, void 0, function () {
@@ -77,6 +79,7 @@ var CustomAutocompleteInput = function (_a) {
77
79
  case 0:
78
80
  value = e.target.value;
79
81
  setInputValue(value);
82
+ setSelectedValue(null);
80
83
  if (!value) return [3 /*break*/, 5];
81
84
  _a.label = 1;
82
85
  case 1:
@@ -104,28 +107,43 @@ var CustomAutocompleteInput = function (_a) {
104
107
  }); };
105
108
  // Seçim yapıldığında onSelect çağır
106
109
  var handleOptionClick = function (option) {
110
+ setSelectedValue(option);
107
111
  onSelect(option);
112
+ //setIsDropdownVisible(false);
113
+ //setInputValue(option);
114
+ };
115
+ var handleReset = function () {
108
116
  setIsDropdownVisible(false);
109
- setInputValue(option);
117
+ setInputValue('');
118
+ setSelectedValue('');
110
119
  };
111
120
  // Dropdown dışında tıklanıldığında dropdown'u kapat
112
121
  (0, react_1.useEffect)(function () {
113
- var handleClickOutside = function (event) {
114
- if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
115
- setIsDropdownVisible(false);
116
- }
117
- };
118
- document.addEventListener('mousedown', handleClickOutside);
119
- return function () {
120
- document.removeEventListener('mousedown', handleClickOutside);
121
- };
122
+ // const handleClickOutside = (event: MouseEvent) => {
123
+ // if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
124
+ // setIsDropdownVisible(false);
125
+ // }
126
+ // };
127
+ // document.addEventListener('mousedown', handleClickOutside);
128
+ // return () => {
129
+ // document.removeEventListener('mousedown', handleClickOutside);
130
+ // };
122
131
  }, []);
132
+ var highlightMatch = function (option, query) {
133
+ // Kullanıcı girişini regex için güvenli hale getir
134
+ var escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
135
+ var regex = new RegExp("(".concat(escapedQuery, ")"), 'gi');
136
+ var highlighted = option.replace(regex, '<mark>$1</mark>');
137
+ return highlighted;
138
+ };
123
139
  return (react_1.default.createElement("div", { className: "autocomplete-container ".concat(className), style: style },
124
140
  react_1.default.createElement("div", { className: "form-group" },
125
141
  react_1.default.createElement("label", { htmlFor: id, className: "form-label" }, label),
126
142
  react_1.default.createElement(react_bootstrap_1.OverlayTrigger, { placement: "bottom", overlay: tooltip ? react_1.default.createElement(react_bootstrap_1.Tooltip, { id: "tooltip-".concat(id) }, tooltip) : react_1.default.createElement(react_1.default.Fragment, null) },
127
- react_1.default.createElement("input", { id: id, name: name, type: "text", value: inputValue, onChange: handleInputChange, placeholder: placeholder, className: "form-control", required: required, disabled: disabled })),
128
- isDropdownVisible && (react_1.default.createElement("div", { className: "autocomplete-dropdown", ref: dropdownRef }, options.map(function (option, index) { return (react_1.default.createElement("div", { key: index, className: "autocomplete-option", onClick: function () { return handleOptionClick(option); } }, option)); }))),
143
+ react_1.default.createElement(CustomInput_1.default, { id: id, name: name, inputType: CustomInput_1.InputType.TEXT, value: inputValue, onChange: handleInputChange, placeholder: placeholder, buttonIcon: react_1.default.createElement(fa_1.FaTimes, null), buttonClass: 'btn btn-danger bg-soft-danger', buttonOnClick: handleReset, className: "form-control", required: required, disabled: disabled })),
144
+ isDropdownVisible && (react_1.default.createElement("div", { className: "autocomplete-dropdown", ref: dropdownRef }, options.map(function (option, index) { return (react_1.default.createElement("div", { key: index, className: "autocomplete-option", onClick: function () { return handleOptionClick(option); }, dangerouslySetInnerHTML: {
145
+ __html: highlightMatch(option, inputValue), // Highlighting
146
+ } })); }))),
129
147
  errorMessage && (react_1.default.createElement("div", { className: "invalid-feedback text-danger mt-2" },
130
148
  react_1.default.createElement(fa_1.FaExclamationTriangle, { className: "me-1" }),
131
149
  errorMessage)),
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import '../assets/css/custom-autocomplete-input.css';
2
3
  interface CustomModalProps {
3
4
  show: boolean;
4
5
  title?: string;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var react_1 = __importDefault(require("react"));
7
7
  var react_bootstrap_1 = require("react-bootstrap");
8
+ require("../assets/css/custom-autocomplete-input.css");
8
9
  var CustomModal = function (_a) {
9
10
  var show = _a.show, _b = _a.title, title = _b === void 0 ? 'Default Title' : _b, _c = _a.size, size = _c === void 0 ? 'lg' : _c, onHide = _a.onHide, children = _a.children, footer = _a.footer, style = _a.style, bodyStyle = _a.bodyStyle;
10
11
  return (react_1.default.createElement(react_bootstrap_1.Modal, { show: show, onHide: onHide, size: size !== 'fullscreen' ? size : undefined, fullscreen: size === 'fullscreen' ? true : undefined, centered: size !== 'fullscreen', style: style },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "albinasoft-ui-package",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {