@sydsoft/base 1.35.0 → 1.37.0

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.
@@ -13,14 +13,13 @@ interface Props extends PropsInput {
13
13
  labelKey?: string;
14
14
  itemComponent?: any;
15
15
  isDataFromApi?: boolean;
16
+ parentInputValue?: string | number | undefined;
16
17
  onText?: (text: string) => void;
17
18
  onSelect?: (item: any) => void;
18
19
  onLoad?: (value: string | number) => void;
19
20
  newCreate?: boolean;
20
- refModal?: any;
21
21
  style?: React.CSSProperties;
22
22
  disabled?: boolean;
23
- parentInputValue?: string | number | undefined;
24
23
  listPositionRelative?: boolean;
25
24
  }
26
25
  type handle = {
@@ -7,7 +7,7 @@ import { Icon } from '../icon';
7
7
  import { Button } from './Button';
8
8
  import styles from './styles/SearchableInput.module.css';
9
9
  var Component = function (_a, forwardedRef) {
10
- var _b = _a.autoCompleteList, autoCompleteList = _b === void 0 ? [] : _b, _c = _a.isDataFromApi, isDataFromApi = _c === void 0 ? false : _c, onText = _a.onText, onSelect = _a.onSelect, onLoad = _a.onLoad, onChange = _a.onChange, _d = _a.newCreate, newCreate = _d === void 0 ? false : _d, name = _a.name, value = _a.value, itemComponent = _a.itemComponent, inputRef = _a.inputRef, _e = _a.valueKey, valueKey = _e === void 0 ? 'value' : _e, _f = _a.labelKey, labelKey = _f === void 0 ? 'label' : _f, placeholder = _a.placeholder, endAdornment = _a.endAdornment, refModal = _a.refModal, style = _a.style, disabled = _a.disabled, parentInputValue = _a.parentInputValue, _g = _a.listPositionRelative, listPositionRelative = _g === void 0 ? false : _g, other = __rest(_a, ["autoCompleteList", "isDataFromApi", "onText", "onSelect", "onLoad", "onChange", "newCreate", "name", "value", "itemComponent", "inputRef", "valueKey", "labelKey", "placeholder", "endAdornment", "refModal", "style", "disabled", "parentInputValue", "listPositionRelative"]);
10
+ var _b = _a.autoCompleteList, autoCompleteList = _b === void 0 ? [] : _b, _c = _a.isDataFromApi, isDataFromApi = _c === void 0 ? false : _c, onText = _a.onText, onSelect = _a.onSelect, onLoad = _a.onLoad, onChange = _a.onChange, _d = _a.newCreate, newCreate = _d === void 0 ? false : _d, name = _a.name, value = _a.value, itemComponent = _a.itemComponent, inputRef = _a.inputRef, _e = _a.valueKey, valueKey = _e === void 0 ? 'value' : _e, _f = _a.labelKey, labelKey = _f === void 0 ? 'label' : _f, placeholder = _a.placeholder, endAdornment = _a.endAdornment, style = _a.style, disabled = _a.disabled, parentInputValue = _a.parentInputValue, _g = _a.listPositionRelative, listPositionRelative = _g === void 0 ? false : _g, other = __rest(_a, ["autoCompleteList", "isDataFromApi", "onText", "onSelect", "onLoad", "onChange", "newCreate", "name", "value", "itemComponent", "inputRef", "valueKey", "labelKey", "placeholder", "endAdornment", "style", "disabled", "parentInputValue", "listPositionRelative"]);
11
11
  var refMain = useRef(null);
12
12
  var refInput = useRef(null);
13
13
  var refComponentInput = useRef(null);
@@ -16,10 +16,13 @@ var Component = function (_a, forwardedRef) {
16
16
  var _j = useState(''), text = _j[0], setText = _j[1]; //Inputta görünen
17
17
  var _k = useState(''), filter = _k[0], setFilter = _k[1]; // Filtrelemeye tabi tutulan
18
18
  var _l = useState(false), open = _l[0], setOpen = _l[1];
19
- var _m = useState(isDataFromApi), loading = _m[0], setLoading = _m[1];
19
+ var _m = useState(isDataFromApi && autoCompleteList.length === 0), loading = _m[0], setLoading = _m[1];
20
20
  var _o = useState({ created: false }), newItemCreate = _o[0], setNewItemCreate = _o[1];
21
21
  useImperativeHandle(forwardedRef, function () { return ({
22
- open: function () { return setOpen(true); },
22
+ open: function () {
23
+ setOpen(true);
24
+ refInput.current && refInput.current.focus();
25
+ },
23
26
  close: function () { return setOpen(false); },
24
27
  checkByValue: function (value, openList) {
25
28
  if (openList === void 0) { openList = false; }
@@ -92,19 +95,8 @@ var Component = function (_a, forwardedRef) {
92
95
  window.addEventListener('mousedown', checkHideBackDrop);
93
96
  if (refMain.current)
94
97
  refMain.current.addEventListener('keydown', checkESC);
95
- if (refModal && refModal.current) {
96
- if (open) {
97
- refModal.current.style.overflow = 'visible';
98
- }
99
- else {
100
- refModal.current.style.overflow = 'auto overlay';
101
- }
102
- }
103
98
  if (open) {
104
99
  setScrollPosition();
105
- if (refModal && refModal.current && refMain && refMain.current) {
106
- refModal.current.scrollTop = refMain.current.offsetTop + 300;
107
- }
108
100
  if (!listPositionRelative) {
109
101
  window.addEventListener('scroll', handleUpdatePosition, true);
110
102
  window.addEventListener('resize', handleUpdatePosition);
@@ -322,14 +314,11 @@ var Component = function (_a, forwardedRef) {
322
314
  }
323
315
  setScrollPosition();
324
316
  };
325
- var ListComponent = function () {
326
- return (_jsx("div", { className: 'listDiv', "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "list ".concat(open ? 'open' : ''), children: [(filteredData.length === 0 || loading) && _jsx("div", { className: "message ".concat(loading ? 'loading' : ''), children: loading ? 'Lütfen bekleyiniz...' : 'Kayıt bulunamadı...' }), filteredData.map(function (item, key) {
327
- var itemValue = item[valueKey];
328
- var itemLabel = item[labelKey];
329
- return (_jsxs("li", { className: "item ".concat(itemValue === value ? 'active' : ''), "data-value": itemValue, "data-label": itemLabel, onClick: function () { return setValue(item, false); }, children: [item.create && _jsx("span", { className: 'newCreate', children: "Yeni Olu\u015Ftur: " }), itemComponent ? itemComponent(item) : itemLabel] }, key));
330
- })] }) }));
331
- };
332
- return (_jsxs("div", { ref: refMain, className: styles.searchableInputComponent, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { name: name, value: text, inputRef: refInput, componentRef: refComponentInput, onFocus: function () { return setOpen(true); }, onChange: Change, endAdornment: !disabled && (_jsxs("div", { style: { marginRight: 5 }, tabIndex: -1, children: [_jsx(Button, { title: 'Temizle', tabIndex: -1, hidden: !(text && text.length > 0), onClick: function () { return clear(true, true); }, onlyIcon: _jsx(Icon, { name: 'close', style: { color: '#444' } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !(data.length > 0), onClick: function () { return setOpen(!open); }, onlyIcon: _jsx(Icon, { name: open ? 'keyboard_arrow_up' : 'keyboard_arrow_down', style: { color: '#444' } }) })] })), placeholder: loading ? 'Lütfen bekleyiniz...' : placeholder, loading: loading, disabled: disabled, propsInput: __assign(__assign({}, other === null || other === void 0 ? void 0 : other.propsInput), { autoComplete: 'off' }) })), open && _jsx(ListComponent, {})] }));
317
+ return (_jsxs("div", { ref: refMain, className: styles.searchableInputComponent, onKeyDown: onKeyDown, style: style, children: [_jsx(Input, __assign({}, other, { name: name, value: text, inputRef: refInput, componentRef: refComponentInput, onFocus: function () { return setOpen(true); }, onChange: Change, endAdornment: !disabled && (_jsxs("div", { style: { marginRight: 5 }, tabIndex: -1, children: [_jsx(Button, { title: 'Temizle', tabIndex: -1, hidden: !(text && text.length > 0), onClick: function () { return clear(true, true); }, onlyIcon: _jsx(Icon, { name: 'close', style: { color: '#444' } }) }), endAdornment, _jsx(Button, { tabIndex: -1, hidden: !(data.length > 0), onClick: function () { return setOpen(!open); }, onlyIcon: _jsx(Icon, { name: open ? 'keyboard_arrow_up' : 'keyboard_arrow_down', style: { color: '#444' } }) })] })), placeholder: loading ? 'Lütfen bekleyiniz...' : placeholder, loading: loading, disabled: disabled, propsInput: __assign(__assign({}, other === null || other === void 0 ? void 0 : other.propsInput), { autoComplete: 'off' }) })), open && (_jsx("div", { className: 'listDiv', "data-relative": listPositionRelative, children: _jsxs("ul", { ref: refList, className: "list ".concat(open ? 'open' : ''), children: [(filteredData.length === 0 || loading) && _jsx("div", { className: "message ".concat(loading ? 'loading' : ''), children: loading ? 'Lütfen bekleyiniz...' : 'Kayıt bulunamadı...' }), filteredData.map(function (item, key) {
318
+ var itemValue = item[valueKey];
319
+ var itemLabel = item[labelKey];
320
+ return (_jsxs("li", { className: "item ".concat(itemValue === value ? 'active' : ''), "data-value": itemValue, "data-label": itemLabel, onClick: function () { return setValue(item, false); }, children: [item.create && _jsx("span", { className: 'newCreate', children: "Yeni Olu\u015Ftur: " }), itemComponent ? itemComponent(item) : itemLabel] }, key));
321
+ })] }) }))] }));
333
322
  };
334
323
  export var SearchableInput = React.forwardRef(Component);
335
324
  var setFixedPosition = function (refMain) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sydsoft/base",
3
3
  "private": false,
4
- "version": "1.35.0",
4
+ "version": "1.37.0",
5
5
  "description": "",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",