@synerise/ds-search 1.5.9 → 1.5.11
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.
- package/CHANGELOG.md +8 -0
- package/dist/Elements/SearchButton/SearchButton.d.ts +2 -2
- package/dist/Elements/SearchButton/SearchButton.js +16 -28
- package/dist/Elements/SearchButton/SearchButton.types.js +1 -1
- package/dist/Elements/SearchHeader/SearchHeader.d.ts +2 -2
- package/dist/Elements/SearchHeader/SearchHeader.js +15 -15
- package/dist/Elements/SearchHeader/SearchHeader.types.js +1 -1
- package/dist/Elements/SearchInput/SearchInput.d.ts +2 -2
- package/dist/Elements/SearchInput/SearchInput.js +74 -117
- package/dist/Elements/SearchInput/SearchInput.types.d.ts +3 -3
- package/dist/Elements/SearchInput/SearchInput.types.js +1 -1
- package/dist/Elements/SearchItems/SearchItems.d.ts +2 -2
- package/dist/Elements/SearchItems/SearchItems.js +54 -58
- package/dist/Elements/SearchItems/SearchItems.types.d.ts +1 -1
- package/dist/Elements/SearchItems/SearchItems.types.js +1 -1
- package/dist/Elements/SearchRenderer/SearchRenderer.d.ts +1 -1
- package/dist/Elements/SearchRenderer/SearchRenderer.js +22 -33
- package/dist/Elements/SearchRenderer/SearchRenderer.types.d.ts +2 -2
- package/dist/Elements/SearchRenderer/SearchRenderer.types.js +1 -1
- package/dist/Elements/index.js +12 -4
- package/dist/Elements/utils/searchUtils.d.ts +1 -1
- package/dist/Elements/utils/searchUtils.js +16 -17
- package/dist/Search.d.ts +2 -3
- package/dist/Search.js +145 -230
- package/dist/Search.styles.d.ts +15 -15
- package/dist/Search.styles.js +59 -62
- package/dist/Search.types.d.ts +4 -4
- package/dist/Search.types.js +8 -7
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/const.js +16 -7
- package/dist/index.js +14 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.5.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@1.5.10...@synerise/ds-search@1.5.11) (2026-04-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-search
|
|
9
|
+
|
|
10
|
+
## [1.5.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@1.5.9...@synerise/ds-search@1.5.10) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-search
|
|
13
|
+
|
|
6
14
|
## [1.5.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search@1.5.8...@synerise/ds-search@1.5.9) (2026-03-20)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-search
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SearchButtonProps } from './SearchButton.types';
|
|
3
3
|
declare const SearchButton: React.FC<SearchButtonProps>;
|
|
4
4
|
export default SearchButton;
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Button from
|
|
3
|
-
import Icon, { SearchM } from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
clickable: !disabled && clickable,
|
|
18
|
-
onClick: onClick
|
|
19
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
20
|
-
mode: "single-icon",
|
|
21
|
-
type: "ghost",
|
|
22
|
-
disabled: disabled,
|
|
23
|
-
className: inputOpen ? 'btn-search-open' : 'btn-search',
|
|
24
|
-
"data-testid": "btn"
|
|
25
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
26
|
-
component: /*#__PURE__*/React.createElement(SearchM, null)
|
|
27
|
-
})));
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import Icon, { SearchM } from "@synerise/ds-icon";
|
|
4
|
+
import { SearchButton as SearchButton$1 } from "../../Search.styles.js";
|
|
5
|
+
const SearchButton = ({
|
|
6
|
+
inputOpen,
|
|
7
|
+
hidden,
|
|
8
|
+
onClick,
|
|
9
|
+
inputFocused,
|
|
10
|
+
clickable,
|
|
11
|
+
disabled
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */ jsx(SearchButton$1, { isOpen: inputOpen, hidden, className: "SearchButton", inputFocused, clickable: !disabled && clickable, onClick, children: /* @__PURE__ */ jsx(Button, { mode: "single-icon", type: "ghost", disabled, className: inputOpen ? "btn-search-open" : "btn-search", "data-testid": "btn", children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(SearchM, {}) }) }) });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
SearchButton as default
|
|
28
17
|
};
|
|
29
|
-
export default SearchButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SearchHeaderProps } from './SearchHeader.types';
|
|
3
3
|
declare const SearchHeader: React.FC<SearchHeaderProps>;
|
|
4
4
|
export default SearchHeader;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Icon, { InfoFillS } from
|
|
3
|
-
import Tooltip from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
title: tooltip || headerText
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import Icon, { InfoFillS } from "@synerise/ds-icon";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip/dist/Tooltip";
|
|
4
|
+
import { MenuHeader, HeaderIconWrapper } from "../../Search.styles.js";
|
|
5
|
+
const SearchHeader = ({
|
|
6
|
+
headerText,
|
|
7
|
+
tooltip
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ jsxs(MenuHeader, { children: [
|
|
10
|
+
headerText,
|
|
11
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip, { type: "default", trigger: "hover", title: tooltip || headerText, children: /* @__PURE__ */ jsx(HeaderIconWrapper, { children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(InfoFillS, {}) }) }) })
|
|
12
|
+
] });
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
SearchHeader as default
|
|
15
16
|
};
|
|
16
|
-
export default SearchHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { SearchInputProps } from './SearchInput.types';
|
|
3
3
|
declare const SearchInput: ({ alwaysExpanded, alwaysHighlight, clearTooltip, filterLabel, filterLookupKey, onKeyDown, onClick, onChange, onClear, onToggle, onButtonClick, moveCursorToEnd, placeholder, textLookupKey, value, closeOnClickOutside, disableInput, disabled, focusTrigger, toggleTrigger, inputProps, searchTooltipProps, }: SearchInputProps) => React.JSX.Element;
|
|
4
4
|
export default SearchInput;
|
|
@@ -1,158 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
import Input from
|
|
3
|
-
import
|
|
4
|
-
import { theme } from
|
|
5
|
-
import Icon, { Close3M } from
|
|
6
|
-
import Tooltip from
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import SearchButton from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setIsResultChosen = _useState3[1];
|
|
46
|
-
var _useState4 = useState(true),
|
|
47
|
-
isInputFocused = _useState4[0],
|
|
48
|
-
setIsInputFocused = _useState4[1];
|
|
49
|
-
var renderInputOpened = isInputOpen || !!value || !!filterLabel;
|
|
50
|
-
var prevFocusTrigger = usePrevious(focusTrigger);
|
|
51
|
-
var prevToggleTrigger = usePrevious(toggleTrigger);
|
|
52
|
-
useLayoutEffect(function () {
|
|
53
|
-
if (prevFocusTrigger !== undefined && prevFocusTrigger !== focusTrigger) {
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import Input from "antd/lib/input";
|
|
3
|
+
import { useRef, useState, useLayoutEffect, useEffect } from "react";
|
|
4
|
+
import { theme } from "@synerise/ds-core";
|
|
5
|
+
import Icon, { Close3M } from "@synerise/ds-icon";
|
|
6
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
7
|
+
import { usePrevious, useOnClickOutside } from "@synerise/ds-utils";
|
|
8
|
+
import { SearchInputWrapper, SearchInputContent, LeftSide, Filter, SearchInner, ClearButton } from "../../Search.styles.js";
|
|
9
|
+
import SearchButton from "../SearchButton/SearchButton.js";
|
|
10
|
+
const SearchInput = ({
|
|
11
|
+
alwaysExpanded,
|
|
12
|
+
alwaysHighlight,
|
|
13
|
+
clearTooltip,
|
|
14
|
+
filterLabel,
|
|
15
|
+
filterLookupKey,
|
|
16
|
+
onKeyDown,
|
|
17
|
+
onClick,
|
|
18
|
+
onChange,
|
|
19
|
+
onClear,
|
|
20
|
+
onToggle,
|
|
21
|
+
onButtonClick,
|
|
22
|
+
moveCursorToEnd,
|
|
23
|
+
placeholder,
|
|
24
|
+
textLookupKey,
|
|
25
|
+
value,
|
|
26
|
+
closeOnClickOutside,
|
|
27
|
+
disableInput,
|
|
28
|
+
disabled,
|
|
29
|
+
focusTrigger,
|
|
30
|
+
toggleTrigger,
|
|
31
|
+
inputProps = {},
|
|
32
|
+
searchTooltipProps = {}
|
|
33
|
+
}) => {
|
|
34
|
+
const inputRef = useRef(null);
|
|
35
|
+
const wrapperRef = useRef(null);
|
|
36
|
+
const [isInputOpen, setIsInputOpen] = useState(alwaysExpanded || !!value || !!filterLabel);
|
|
37
|
+
const [inputOffset, setInputOffset] = useState(0);
|
|
38
|
+
const [isResultChosen, setIsResultChosen] = useState(false);
|
|
39
|
+
const [isInputFocused, setIsInputFocused] = useState(true);
|
|
40
|
+
const renderInputOpened = isInputOpen || !!value || !!filterLabel;
|
|
41
|
+
const prevFocusTrigger = usePrevious(focusTrigger);
|
|
42
|
+
const prevToggleTrigger = usePrevious(toggleTrigger);
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
if (prevFocusTrigger !== void 0 && prevFocusTrigger !== focusTrigger) {
|
|
54
45
|
focusInput();
|
|
55
46
|
}
|
|
56
|
-
if (prevToggleTrigger !==
|
|
47
|
+
if (prevToggleTrigger !== void 0 && prevToggleTrigger !== toggleTrigger) {
|
|
57
48
|
toggleOpen();
|
|
58
49
|
}
|
|
59
50
|
});
|
|
60
|
-
useOnClickOutside(wrapperRef,
|
|
51
|
+
useOnClickOutside(wrapperRef, () => {
|
|
61
52
|
if (closeOnClickOutside && !alwaysExpanded) {
|
|
62
53
|
setIsInputOpen(false);
|
|
63
54
|
onToggle && onToggle(false);
|
|
64
55
|
}
|
|
65
56
|
});
|
|
66
|
-
|
|
57
|
+
const focusInput = () => {
|
|
67
58
|
inputRef.current && inputRef.current.focus();
|
|
68
59
|
};
|
|
69
|
-
|
|
60
|
+
const handleSearchInputContentClick = () => {
|
|
70
61
|
onClick && onClick();
|
|
71
62
|
focusInput();
|
|
72
63
|
};
|
|
73
|
-
|
|
64
|
+
const handleOffsetWithFilter = (ref) => {
|
|
74
65
|
ref && setInputOffset(ref.getBoundingClientRect().width);
|
|
75
66
|
};
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
const handleChangeValue = ({
|
|
68
|
+
target: {
|
|
69
|
+
value: changedValue
|
|
70
|
+
}
|
|
71
|
+
}) => {
|
|
78
72
|
onChange(changedValue);
|
|
79
73
|
setIsResultChosen(false);
|
|
80
74
|
};
|
|
81
|
-
|
|
82
|
-
setIsInputOpen(
|
|
75
|
+
const toggleOpen = () => {
|
|
76
|
+
setIsInputOpen((open) => {
|
|
83
77
|
onToggle && onToggle(!open);
|
|
84
78
|
return !open;
|
|
85
79
|
});
|
|
86
80
|
};
|
|
87
|
-
|
|
81
|
+
const handleSearchButtonClick = () => {
|
|
88
82
|
if (!alwaysExpanded) {
|
|
89
83
|
toggleOpen();
|
|
90
84
|
focusInput();
|
|
91
85
|
onButtonClick && onButtonClick();
|
|
92
86
|
}
|
|
93
87
|
};
|
|
94
|
-
|
|
88
|
+
const handleClearValue = () => {
|
|
95
89
|
setInputOffset(0);
|
|
96
90
|
setIsResultChosen(false);
|
|
97
91
|
onClear();
|
|
98
92
|
setIsInputOpen(true);
|
|
99
93
|
focusInput();
|
|
100
94
|
};
|
|
101
|
-
useEffect(
|
|
102
|
-
|
|
103
|
-
if (moveCursorToEnd && (_inputRef$current = inputRef.current) != null && _inputRef$current.input) {
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (moveCursorToEnd && inputRef.current?.input) {
|
|
104
97
|
inputRef.current.input.selectionStart = value.length || 0;
|
|
105
98
|
inputRef.current.input.selectionEnd = value.length || 0;
|
|
106
99
|
}
|
|
107
100
|
}, [moveCursorToEnd, value.length]);
|
|
108
|
-
return
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
hasValue: !!value,
|
|
123
|
-
alwaysHighlight: alwaysHighlight
|
|
124
|
-
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
125
|
-
placeholder: placeholder,
|
|
126
|
-
ref: inputRef,
|
|
127
|
-
value: value,
|
|
128
|
-
onChange: handleChangeValue,
|
|
129
|
-
onKeyDown: onKeyDown,
|
|
130
|
-
onFocus: function onFocus() {
|
|
131
|
-
return setIsInputFocused(true);
|
|
132
|
-
},
|
|
133
|
-
onBlur: function onBlur() {
|
|
134
|
-
return setIsInputFocused(false);
|
|
135
|
-
},
|
|
136
|
-
autoComplete: "off",
|
|
137
|
-
autoFocus: true,
|
|
138
|
-
disabled: disableInput
|
|
139
|
-
}, inputProps))))), /*#__PURE__*/React.createElement(SearchButton, {
|
|
140
|
-
disabled: disabled,
|
|
141
|
-
inputOpen: isInputOpen,
|
|
142
|
-
hidden: !!value || !!filterLabel,
|
|
143
|
-
inputFocused: isInputFocused,
|
|
144
|
-
clickable: !disabled && !alwaysExpanded,
|
|
145
|
-
onClick: handleSearchButtonClick
|
|
146
|
-
}), !disabled && /*#__PURE__*/React.createElement(S.ClearButton, {
|
|
147
|
-
hidden: !value && !filterLabel
|
|
148
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
149
|
-
"data-testid": "clear",
|
|
150
|
-
onClick: handleClearValue,
|
|
151
|
-
component: /*#__PURE__*/React.createElement(Tooltip, {
|
|
152
|
-
title: clearTooltip
|
|
153
|
-
}, /*#__PURE__*/React.createElement(Close3M, null)),
|
|
154
|
-
color: theme.palette['red-600'],
|
|
155
|
-
size: 18
|
|
156
|
-
})));
|
|
101
|
+
return /* @__PURE__ */ jsxs(SearchInputWrapper, { ref: wrapperRef, children: [
|
|
102
|
+
!disabled && /* @__PURE__ */ jsxs(SearchInputContent, { className: renderInputOpened ? "is-open search-input-wrapper" : "search-input-wrapper", offset: inputOffset, filterLabel, onClick: handleSearchInputContentClick, children: [
|
|
103
|
+
/* @__PURE__ */ jsx(LeftSide, { isOpen: isInputOpen, children: filterLabel && /* @__PURE__ */ jsxs(Filter, { ref: handleOffsetWithFilter, children: [
|
|
104
|
+
filterLabel.icon && !isResultChosen && /* @__PURE__ */ jsx(Icon, { component: filterLabel.icon }),
|
|
105
|
+
/* @__PURE__ */ jsx("span", { children: filterLabel[filterLookupKey || ""] || filterLabel[textLookupKey || ""] })
|
|
106
|
+
] }) }),
|
|
107
|
+
/* @__PURE__ */ jsx(Tooltip, { ...searchTooltipProps, children: /* @__PURE__ */ jsx(SearchInner, { hasValue: !!value, alwaysHighlight, children: /* @__PURE__ */ jsx(Input, { placeholder, ref: inputRef, value, onChange: handleChangeValue, onKeyDown, onFocus: () => setIsInputFocused(true), onBlur: () => setIsInputFocused(false), autoComplete: "off", autoFocus: true, disabled: disableInput, ...inputProps }) }) })
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ jsx(SearchButton, { disabled, inputOpen: isInputOpen, hidden: !!value || !!filterLabel, inputFocused: isInputFocused, clickable: !disabled && !alwaysExpanded, onClick: handleSearchButtonClick }),
|
|
110
|
+
!disabled && /* @__PURE__ */ jsx(ClearButton, { hidden: !value && !filterLabel, children: /* @__PURE__ */ jsx(Icon, { "data-testid": "clear", onClick: handleClearValue, component: /* @__PURE__ */ jsx(Tooltip, { title: clearTooltip, children: /* @__PURE__ */ jsx(Close3M, {}) }), color: theme.palette["red-600"], size: 18 }) })
|
|
111
|
+
] });
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
SearchInput as default
|
|
157
115
|
};
|
|
158
|
-
export default SearchInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { InputProps } from 'antd/lib/input';
|
|
2
|
+
import { KeyboardEvent, ReactNode } from 'react';
|
|
3
|
+
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
4
4
|
export type SearchInputProps = {
|
|
5
5
|
alwaysExpanded?: boolean;
|
|
6
6
|
alwaysHighlight?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React,
|
|
2
|
-
import {
|
|
1
|
+
import { default as React, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { SearchItemListProps } from './SearchItems.types';
|
|
3
3
|
export declare function renderSearchList<V>(props: SearchItemListProps<V>, children?: ReactNode): ReactElement<SearchItemListProps<V>>;
|
|
4
4
|
declare const SearchItems: ({ data, height, highlight, itemRender, listProps, onItemClick, rowHeight, visibleRows, width, renderInMenu, }: SearchItemListProps<any>) => React.JSX.Element;
|
|
5
5
|
export default SearchItems;
|
|
@@ -1,48 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { FixedSizeList
|
|
4
|
-
import { ListContextProvider } from
|
|
5
|
-
import Menu from
|
|
6
|
-
|
|
7
|
-
overflowX:
|
|
8
|
-
overflowY:
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useMemo, useEffect, cloneElement } from "react";
|
|
3
|
+
import { FixedSizeList } from "react-window";
|
|
4
|
+
import { ListContextProvider } from "@synerise/ds-list-item";
|
|
5
|
+
import Menu from "@synerise/ds-menu";
|
|
6
|
+
const listStyle = {
|
|
7
|
+
overflowX: "unset",
|
|
8
|
+
overflowY: "unset"
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
function renderSearchList(props, children) {
|
|
11
|
+
return /* @__PURE__ */ jsx(SearchItems, { ...props, children });
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const rowRenderer = ({
|
|
14
|
+
index,
|
|
15
|
+
style,
|
|
16
|
+
data
|
|
17
|
+
}) => {
|
|
18
|
+
const item = data && data.items[index];
|
|
19
|
+
const itemReturnedFromRenderer = data.itemRender(item);
|
|
20
|
+
const rendererCustomStyles = itemReturnedFromRenderer && itemReturnedFromRenderer.props && itemReturnedFromRenderer.props.style || {};
|
|
21
|
+
const mergedStyles = {
|
|
22
|
+
...rendererCustomStyles,
|
|
23
|
+
...style
|
|
24
|
+
};
|
|
25
|
+
return cloneElement(itemReturnedFromRenderer, {
|
|
26
|
+
...itemReturnedFromRenderer.props,
|
|
22
27
|
style: mergedStyles,
|
|
23
28
|
highlight: data.highlight,
|
|
24
|
-
onClick:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
className: 'ds-search-item'
|
|
28
|
-
}));
|
|
29
|
+
onClick: () => data.onItemClick && data.onItemClick(item),
|
|
30
|
+
className: "ds-search-item"
|
|
31
|
+
});
|
|
29
32
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
const SearchItems = ({
|
|
34
|
+
data,
|
|
35
|
+
height,
|
|
36
|
+
highlight,
|
|
37
|
+
itemRender,
|
|
38
|
+
listProps,
|
|
39
|
+
onItemClick,
|
|
40
|
+
rowHeight,
|
|
41
|
+
visibleRows,
|
|
42
|
+
width,
|
|
43
|
+
renderInMenu = true
|
|
44
|
+
}) => {
|
|
45
|
+
const listRef = useRef(null);
|
|
46
|
+
const listHeight = useMemo(() => {
|
|
44
47
|
if (data) {
|
|
45
|
-
|
|
48
|
+
const dataHeight = data.length * rowHeight;
|
|
46
49
|
if (visibleRows) {
|
|
47
50
|
return visibleRows < data.length ? visibleRows * rowHeight : dataHeight;
|
|
48
51
|
}
|
|
@@ -53,27 +56,20 @@ var SearchItems = function SearchItems(_ref2) {
|
|
|
53
56
|
}
|
|
54
57
|
return 0;
|
|
55
58
|
}, [data, height, rowHeight, visibleRows]);
|
|
56
|
-
useEffect(
|
|
59
|
+
useEffect(() => {
|
|
57
60
|
if (listRef.current && listProps) {
|
|
58
61
|
listRef.current.scrollTo(Math.max(0, listProps.scrollTop || 0));
|
|
59
62
|
}
|
|
60
63
|
}, [listProps]);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
style: listStyle,
|
|
73
|
-
width: width
|
|
74
|
-
}, listProps), rowRenderer);
|
|
75
|
-
return renderInMenu ? /*#__PURE__*/React.createElement(Menu, {
|
|
76
|
-
tabIndex: -1
|
|
77
|
-
}, list) : /*#__PURE__*/React.createElement(ListContextProvider, null, list);
|
|
64
|
+
const list = data && /* @__PURE__ */ jsx(FixedSizeList, { height: listHeight, itemCount: data.length, itemData: {
|
|
65
|
+
highlight,
|
|
66
|
+
itemRender,
|
|
67
|
+
items: data,
|
|
68
|
+
onItemClick
|
|
69
|
+
}, itemSize: rowHeight, ref: listRef, style: listStyle, width, ...listProps, children: rowRenderer });
|
|
70
|
+
return renderInMenu ? /* @__PURE__ */ jsx(Menu, { tabIndex: -1, children: list }) : /* @__PURE__ */ jsx(ListContextProvider, { children: list });
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
SearchItems as default,
|
|
74
|
+
renderSearchList
|
|
78
75
|
};
|
|
79
|
-
export default SearchItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SearchRendererProps } from './SearchRenderer.types';
|
|
2
2
|
declare const SearchRenderer: ({ title, tooltip, data, width, height, rowHeight, listProps, itemRender, highlight, onItemClick, }: SearchRendererProps) => JSX.Element | null;
|
|
3
3
|
export default SearchRenderer;
|
|
@@ -1,34 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import SearchHeader from
|
|
3
|
-
import SearchItems from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
onItemClick
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
data: data,
|
|
24
|
-
height: height,
|
|
25
|
-
highlight: highlight,
|
|
26
|
-
width: width,
|
|
27
|
-
rowHeight: rowHeight,
|
|
28
|
-
itemRender: itemRender,
|
|
29
|
-
onItemClick: onItemClick,
|
|
30
|
-
listProps: listProps,
|
|
31
|
-
renderInMenu: false
|
|
32
|
-
}));
|
|
1
|
+
import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import SearchHeader from "../SearchHeader/SearchHeader.js";
|
|
3
|
+
import SearchItems from "../SearchItems/SearchItems.js";
|
|
4
|
+
const SearchRenderer = ({
|
|
5
|
+
title,
|
|
6
|
+
tooltip,
|
|
7
|
+
data,
|
|
8
|
+
width,
|
|
9
|
+
height,
|
|
10
|
+
rowHeight = 30,
|
|
11
|
+
listProps,
|
|
12
|
+
itemRender = (item) => /* @__PURE__ */ jsx(Fragment, { children: item }),
|
|
13
|
+
highlight,
|
|
14
|
+
onItemClick
|
|
15
|
+
}) => {
|
|
16
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
17
|
+
!!title && /* @__PURE__ */ jsx(SearchHeader, { headerText: title, tooltip }),
|
|
18
|
+
/* @__PURE__ */ jsx(SearchItems, { data, height, highlight, width, rowHeight, itemRender, onItemClick, listProps, renderInMenu: false })
|
|
19
|
+
] });
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
SearchRenderer as default
|
|
33
23
|
};
|
|
34
|
-
export default SearchRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/Elements/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { default as default2 } from "./SearchInput/SearchInput.js";
|
|
2
|
+
import { default as default3 } from "./SearchHeader/SearchHeader.js";
|
|
3
|
+
import { default as default4, default as default5, renderSearchList } from "./SearchItems/SearchItems.js";
|
|
4
|
+
import { default as default6 } from "./SearchButton/SearchButton.js";
|
|
5
|
+
export {
|
|
6
|
+
default6 as SearchButton,
|
|
7
|
+
default3 as SearchHeader,
|
|
8
|
+
default2 as SearchInput,
|
|
9
|
+
default4 as SearchItemList,
|
|
10
|
+
default5 as SearchItems,
|
|
11
|
+
renderSearchList
|
|
12
|
+
};
|