@star-insure/sdk 3.2.7 → 3.2.8
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/dist/components/filter/PageHeader.d.ts +2 -1
- package/dist/components/filter/SearchBar.d.ts +5 -2
- package/dist/sdk.cjs.development.js +10 -5
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +10 -5
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/filter/PageHeader.tsx +6 -4
- package/src/components/filter/SearchBar.tsx +10 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@star-insure/sdk",
|
|
3
3
|
"description": "The SDK for Star Insure client apps with shared helper functions and TypeScript definitions.",
|
|
4
4
|
"author": "alexclark_nz",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.8",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -17,6 +17,7 @@ interface Props {
|
|
|
17
17
|
actions?: TPageHeaderAction[];
|
|
18
18
|
backText?: string;
|
|
19
19
|
filterOptions?: FilterOption[];
|
|
20
|
+
focusSearchShortcut?: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export default function PageHeader({
|
|
@@ -27,6 +28,7 @@ export default function PageHeader({
|
|
|
27
28
|
back = true,
|
|
28
29
|
actions = [],
|
|
29
30
|
filterOptions = [],
|
|
31
|
+
focusSearchShortcut = false,
|
|
30
32
|
}: Props) {
|
|
31
33
|
const [isSearchActive, setSearchActive] = React.useState<boolean>(false);
|
|
32
34
|
const scrollContainerRef = React.useRef<HTMLDivElement | null>(null);
|
|
@@ -76,7 +78,7 @@ export default function PageHeader({
|
|
|
76
78
|
|
|
77
79
|
current.addEventListener('scroll', listener);
|
|
78
80
|
document.addEventListener('mousemove', mouseListener)
|
|
79
|
-
|
|
81
|
+
|
|
80
82
|
return () => {
|
|
81
83
|
current.removeEventListener('scroll', listener);
|
|
82
84
|
document.removeEventListener('mousemove', mouseListener)
|
|
@@ -142,7 +144,7 @@ export default function PageHeader({
|
|
|
142
144
|
{back && (
|
|
143
145
|
<BackButton back={back} className="bg-gray-100 h-[60px] w-[60px] rounded" />
|
|
144
146
|
)}
|
|
145
|
-
|
|
147
|
+
|
|
146
148
|
<div className={cn('w-full grid grid-cols-[auto_1fr_auto] h-[60px] rounded bg-gray-100 p-3 gap-4', innerClassName)}>
|
|
147
149
|
<button
|
|
148
150
|
type="button"
|
|
@@ -152,7 +154,7 @@ export default function PageHeader({
|
|
|
152
154
|
'hover:text-teal': search && !isSearchActive,
|
|
153
155
|
}
|
|
154
156
|
)}>
|
|
155
|
-
{search && <SearchBar search={search} active={isSearchActive} onActive={setSearchActive} placeholder={`Search ${title}...`} />}
|
|
157
|
+
{search && <SearchBar search={search} active={isSearchActive} onActive={setSearchActive} placeholder={`Search ${title}...`} focusSearchShortcut={focusSearchShortcut} />}
|
|
156
158
|
|
|
157
159
|
{!isSearchActive && <h1 className="text-base font-bold">{title}</h1>}
|
|
158
160
|
</button>
|
|
@@ -161,7 +163,7 @@ export default function PageHeader({
|
|
|
161
163
|
{filterOptions.length > 0 && (
|
|
162
164
|
<>
|
|
163
165
|
<button onClick={handleClear} className="p-1.5 hover:text-red-500"><HiXMark className="w-5 h-5 stroke-[1.25]" /></button>
|
|
164
|
-
|
|
166
|
+
|
|
165
167
|
{hasScroll && <HiChevronLeft onClick={clickLeft} className="w-5 h-5 text-gray-400 stroke-[1.25]" />}
|
|
166
168
|
<div ref={scrollContainerRef} className="flex items-center h-full w-full gap-3 overflow-x-scroll hide-scroll">
|
|
167
169
|
{filterOptions.map(filter => (
|
|
@@ -3,8 +3,15 @@ import React from "react";
|
|
|
3
3
|
import { HiMagnifyingGlass, HiXMark } from "react-icons/hi2";
|
|
4
4
|
import { useClickOutside } from "../../lib";
|
|
5
5
|
|
|
6
|
+
interface Props {
|
|
7
|
+
search?: string;
|
|
8
|
+
active: boolean;
|
|
9
|
+
onActive: Function;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
focusSearchShortcut?: boolean;
|
|
12
|
+
}
|
|
6
13
|
|
|
7
|
-
export default function SearchBar({ search, active, onActive, placeholder
|
|
14
|
+
export default function SearchBar({ search, active, onActive, placeholder, focusSearchShortcut = false }: Props) {
|
|
8
15
|
const [query, setQuery] = React.useState<string>('');
|
|
9
16
|
|
|
10
17
|
const searchRef = React.useRef<HTMLDivElement | null>(null);
|
|
@@ -26,7 +33,7 @@ export default function SearchBar({ search, active, onActive, placeholder }: { s
|
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
const listener = (e: KeyboardEvent) => {
|
|
29
|
-
if (e.key === '/') {
|
|
36
|
+
if (focusSearchShortcut && e.key === '/') {
|
|
30
37
|
e.preventDefault();
|
|
31
38
|
onActive(true);
|
|
32
39
|
}
|
|
@@ -41,7 +48,7 @@ export default function SearchBar({ search, active, onActive, placeholder }: { s
|
|
|
41
48
|
return () => {
|
|
42
49
|
window.removeEventListener('keydown', listener);
|
|
43
50
|
};
|
|
44
|
-
}, []);
|
|
51
|
+
}, [focusSearchShortcut]);
|
|
45
52
|
|
|
46
53
|
/**
|
|
47
54
|
* Minimise the search bar on click outside if there's no search query
|
|
@@ -119,4 +126,3 @@ export default function SearchBar({ search, active, onActive, placeholder }: { s
|
|
|
119
126
|
</div>
|
|
120
127
|
);
|
|
121
128
|
}
|
|
122
|
-
|