@star-insure/sdk 3.1.2 → 3.2.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.
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.1.2",
5
+ "version": "3.2.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -60,19 +60,21 @@
60
60
  "size-limit": "^7.0.8",
61
61
  "tsdx": "^0.14.1",
62
62
  "tslib": "^2.4.0",
63
- "typescript": "^3.9.10"
63
+ "typescript": "^3.9.10",
64
+ "react": "^18.2.0"
64
65
  },
65
66
  "dependencies": {
66
67
  "@headlessui/react": "^1.6.3",
67
68
  "@inertiajs/react": "^1.0.0",
68
69
  "classnames": "^2.3.2",
69
- "create-slots": "^0.6.1",
70
70
  "date-fns": "^2.28.0",
71
71
  "lodash-es": "^4.17.21",
72
- "react": "^18.2.0",
73
72
  "react-dom": "^18.2.0",
74
73
  "react-icons": "^4.11.0",
75
74
  "react-select": "^5.8.0",
76
75
  "uuid": "^9.0.0"
76
+ },
77
+ "peerDependencies": {
78
+ "react": "^18.2.0"
77
79
  }
78
80
  }
@@ -2,8 +2,9 @@ import { Link } from "@inertiajs/react";
2
2
  import React from "react";
3
3
  import { HiArrowLeft } from "react-icons/hi2";
4
4
  import { usePage } from "../../lib/page";
5
+ import cn from 'classnames';
5
6
 
6
- export function BackButton({ back }: { back?: string | boolean }) {
7
+ export function BackButton({ back, className }: { back?: string | boolean; className?: string; }) {
7
8
  const [backUrl, setBackUrl] = React.useState<string | undefined>(typeof back === 'string' ? back : undefined);
8
9
  const { breadcrumbs } = usePage().props;
9
10
 
@@ -12,6 +13,7 @@ export function BackButton({ back }: { back?: string | boolean }) {
12
13
  */
13
14
  React.useEffect(() => {
14
15
  if (typeof window !== 'undefined') {
16
+ if (!breadcrumbs) return;
15
17
  // Set back button URL
16
18
  if (back && typeof back === 'boolean') {
17
19
  // If we haven't provided a path as a prop, use the last breadcrumb that's not the current one
@@ -28,7 +30,7 @@ export function BackButton({ back }: { back?: string | boolean }) {
28
30
  }, [breadcrumbs]);
29
31
 
30
32
  return (
31
- <Link href={backUrl || '/'} className="hover:text-teal transition-all p-1 -mr-1">
33
+ <Link href={backUrl || '/'} className={cn(className, 'flex items-center justify-center hover:text-teal transition-all')}>
32
34
  <HiArrowLeft className="h-5 w-5 stroke-[1.25]" />
33
35
  </Link>
34
36
  );
@@ -1,18 +1,15 @@
1
1
  import React from "react";
2
2
 
3
- import { createHost, createSlot } from 'create-slots';
4
3
  import { useClickOutside } from "../../lib";
5
4
 
6
- const DropdownTitle = createSlot('button');
7
- const DropdownContent = createSlot('form');
8
-
9
5
  type Props = {
10
- children: React.ReactNode;
11
6
  onClose: Function;
12
7
  active: boolean;
8
+ title: React.ReactNode;
9
+ children: React.ReactNode;
13
10
  }
14
11
 
15
- function Dropdown({ children, onClose, active }: Props) {
12
+ function Dropdown({ onClose, active, title, children }: Props) {
16
13
  const ref = React.useRef<HTMLDivElement | null>(null);
17
14
  const innerRef = React.useRef<HTMLDivElement | null>(null);
18
15
 
@@ -30,22 +27,17 @@ function Dropdown({ children, onClose, active }: Props) {
30
27
  innerCurrent.style.setProperty('left', `${pos?.left}px`)
31
28
  }, [active, ref.current, innerRef.current]);
32
29
 
33
- return createHost(children, (Slots) => {
34
- return (
35
- <div ref={ref} className="static inline-block">
36
- {Slots.get(DropdownTitle)}
37
-
38
- {active && (
39
- <div ref={innerRef} className="absolute children z-10 flex flex-col">
40
- {Slots.get(DropdownContent)}
41
- </div>
42
- )}
43
- </div>
44
- )
45
- });
30
+ return (
31
+ <div ref={ref} className="static inline-block">
32
+ {title}
33
+
34
+ {active && (
35
+ <div ref={innerRef} className="absolute children z-10 flex flex-col">
36
+ {children}
37
+ </div>
38
+ )}
39
+ </div>
40
+ );
46
41
  };
47
42
 
48
- Dropdown.Title = DropdownTitle;
49
- Dropdown.Content = DropdownContent;
50
-
51
43
  export default Dropdown;
@@ -184,21 +184,20 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
184
184
  }
185
185
 
186
186
  return (
187
- <Dropdown onClose={() => setOpen(!open)} active={isOpen}>
188
- <Dropdown.Title
187
+ <Dropdown onClose={() => setOpen(!open)} active={isOpen} title={
188
+ <div
189
189
  onClick={() => handleClick()}
190
190
  className={cn(
191
- 'flex rounded-2xl border hover:border-teal bg-gray-600 min-w-[90px] px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-teal transition-colors',
191
+ 'flex rounded-2xl border hover:border-teal bg-gray-600 px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-teal transition-colors',
192
192
  {
193
193
  '!bg-teal border-teal': hasFilters,
194
194
  }
195
- )}
196
- >
195
+ )}>
197
196
  <p className="whitespace-nowrap">{filter.label}</p>
198
197
  <HiChevronDown />
199
- </Dropdown.Title>
200
-
201
- <Dropdown.Content
198
+ </div>
199
+ }>
200
+ <form
202
201
  className={`mt-2 flex max-h-[350px] min-w-[200px] flex-col gap-2 rounded-md border border-gray-300 bg-white p-4 shadow-lg ${ filter.type && filter.type === 'select' ? '' : 'overflow-y-scroll'}`}
203
202
  onSubmit={handleApply}
204
203
  >
@@ -312,7 +311,7 @@ export function FilterItem({ filter }: { filter: FilterOption, path?: string })
312
311
  Apply
313
312
  </Button>
314
313
  </div>
315
- </Dropdown.Content>
314
+ </form>
316
315
  </Dropdown>
317
316
  );
318
317
  }
@@ -138,17 +138,19 @@ export default function PageHeader({
138
138
  }, [actions]);
139
139
 
140
140
  return (
141
- <section className={cn('col-span-full max-w-full rounded-lg bg-white p-2 shadow', className)}>
142
- <div className={cn('grid grid-cols-[auto_1fr_auto] min-h-[60px] rounded gap-4 bg-gray-100 p-3', innerClassName)}>
143
- <div className="mr-auto flex items-center gap-4">
144
- {back && <BackButton back={back} />}
145
-
141
+ <section className={cn('col-span-full flex items-center gap-2 max-w-full rounded-lg bg-white p-2 shadow', className)}>
142
+ {back && (
143
+ <BackButton back={back} className="bg-gray-100 h-[60px] w-[60px] rounded" />
144
+ )}
145
+
146
+ <div className={cn('w-full grid grid-cols-[auto_1fr_auto] h-[60px] rounded bg-gray-100 p-3 gap-4', innerClassName)}>
147
+ <div className="mr-auto flex items-center gap-4 ml-1">
146
148
  {search && <SearchBar search={search} active={isSearchActive} onActive={setSearchActive} placeholder={`Search ${title}...`} />}
147
149
 
148
150
  {!isSearchActive && <h1 className="text-base font-bold">{title}</h1>}
149
151
  </div>
150
152
 
151
- <div className="flex ml-auto items-center max-w-sm md:max-w-md lg:max-w-lg xl:max-w-2xl gap-2 h-full min-w-0">
153
+ <div className="flex items-center ml-auto gap-2 h-full min-w-0 max-w-full">
152
154
  {filterOptions.length > 0 && (
153
155
  <>
154
156
  <button onClick={handleClear} className="p-1.5 hover:text-red-500"><HiXMark className="w-5 h-5 stroke-[1.25]" /></button>
@@ -165,7 +167,7 @@ export default function PageHeader({
165
167
  </div>
166
168
 
167
169
  {filteredActions.length > 0 && (
168
- <div className="flex items-center gap-3">
170
+ <div className="flex items-center gap-3 bg-gray-100">
169
171
  {filterOptions.length > 0 && <div className="w-[1px] h-full bg-gray-300" />}
170
172
  <nav className="flex items-center gap-2">
171
173
  {filteredActions.map((action) => (
package/src/lib/page.tsx CHANGED
@@ -7,7 +7,7 @@ import { AuthContext, Breadcrumb, Environment } from '../types';
7
7
  */
8
8
  type CustomPageProps = {
9
9
  env: Environment;
10
- breadcrumbs: Breadcrumb[];
10
+ breadcrumbs?: Breadcrumb[];
11
11
  links: Record<string, string>;
12
12
  access_token?: string;
13
13
  impersonate_id?: number;