@star-insure/sdk 4.2.0 → 4.3.1

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.
@@ -9,7 +9,7 @@ export interface FilterOption {
9
9
  label: string;
10
10
  name: string;
11
11
  options?: FilterValue[];
12
- type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column';
12
+ type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text';
13
13
  }
14
14
  export interface FilterValue {
15
15
  label: string;
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": "4.2.0",
5
+ "version": "4.3.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -114,6 +114,16 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
114
114
  }
115
115
  }
116
116
 
117
+ function handleText(e: React.SyntheticEvent<HTMLInputElement>) {
118
+ const { value } = e.currentTarget;
119
+
120
+ if (value) {
121
+ setSelected([value]);
122
+ } else {
123
+ setSelected([]);
124
+ }
125
+ }
126
+
117
127
  function handleApply(e: React.FormEvent) {
118
128
  e.preventDefault();
119
129
 
@@ -304,6 +314,18 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
304
314
  />
305
315
  </div>
306
316
  )}
317
+ {filter.type === 'text' && (
318
+ <div className={'w-full'}>
319
+ <input
320
+ type="text"
321
+ name={filter.name}
322
+ placeholder={filter.label}
323
+ value={selected[0] ?? ''}
324
+ onChange={handleText}
325
+ className="!p-2 text-sm w-full"
326
+ />
327
+ </div>
328
+ )}
307
329
  </div>
308
330
  <div className="bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky">
309
331
  <Button type="button" className="!min-w-[0px] flex-grow !px-2 text-sm !transition-none" onClick={handleClear} small>
@@ -18,6 +18,7 @@ interface Props {
18
18
  backText?: string;
19
19
  filterOptions?: FilterOption[];
20
20
  focusSearchShortcut?: boolean;
21
+ children?: React.ReactNode;
21
22
  }
22
23
 
23
24
  export default function PageHeader({
@@ -29,12 +30,24 @@ export default function PageHeader({
29
30
  actions = [],
30
31
  filterOptions = [],
31
32
  focusSearchShortcut = false,
33
+ children
32
34
  }: Props) {
33
35
  const [isSearchActive, setSearchActive] = React.useState<boolean>(false);
34
36
  const scrollContainerRef = React.useRef<HTMLDivElement | null>(null);
35
37
 
36
38
  const [overScroll, setOverScroll] = React.useState<boolean>(false);
37
39
 
40
+ const actionChildren: React.ReactNode[] = [];
41
+
42
+ // Categorize children based on their type
43
+ React.Children.forEach(children, (child) => {
44
+ if (React.isValidElement(child)) {
45
+ if (child.type === PageHeader.Action) {
46
+ actionChildren.push(child);
47
+ }
48
+ }
49
+ });
50
+
38
51
  React.useEffect(() => {
39
52
  const current = scrollContainerRef.current;
40
53
  if (!current) return;
@@ -145,7 +158,7 @@ export default function PageHeader({
145
158
  <BackButton back={back} className="bg-gray-100 h-[60px] w-[60px] rounded" />
146
159
  )}
147
160
 
148
- <div className={cn('w-full grid grid-cols-[auto_1fr_auto] h-[60px] rounded bg-gray-100 p-3 gap-4', innerClassName)}>
161
+ <div className={cn('w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-gray-100 p-3 gap-4', innerClassName)}>
149
162
  <button
150
163
  type="button"
151
164
  disabled={!search}
@@ -185,7 +198,15 @@ export default function PageHeader({
185
198
  </nav>
186
199
  </div>
187
200
  )}
201
+ {actionChildren && (
202
+ <div className="flex items-center gap-3 bg-gray-100">
203
+ {actionChildren}
204
+ </div>
205
+ )}
188
206
  </div>
189
207
  </section>
190
208
  );
191
209
  }
210
+
211
+ // Subcomponents
212
+ PageHeader.Action = ({ children }: {children: React.ReactNode}) => <div>{children}</div>;
@@ -11,7 +11,7 @@ export interface FilterOption {
11
11
  label: string;
12
12
  name: string;
13
13
  options?: FilterValue[];
14
- type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column';
14
+ type?: 'options' | 'date' | 'greaterThan' | 'scope' | 'select' | 'datalist' | 'column' | 'text';
15
15
  }
16
16
 
17
17
  export interface FilterValue {