@star-insure/sdk 1.1.43 → 2.0.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/dist/components/common/Button.d.ts +2 -2
- package/dist/components/forms/DateOfBirthField.d.ts +6 -2
- package/dist/components/forms/ErrorList.d.ts +2 -2
- package/dist/components/tables/TableHeader.d.ts +2 -2
- package/dist/lib/inertiaOptions.d.ts +1 -1
- package/dist/lib/quoteRequestForm.d.ts +4 -3
- package/dist/sdk.cjs.development.js +59 -65
- 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 +43 -49
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/misc/index.d.ts +0 -1
- package/package.json +2 -3
- package/src/components/common/Button.tsx +65 -48
- package/src/components/common/Pagination.tsx +1 -1
- package/src/components/forms/DateOfBirthField.tsx +112 -72
- package/src/components/forms/ErrorList.tsx +30 -25
- package/src/components/tables/TableHeader.tsx +61 -44
- package/src/lib/auth.tsx +13 -3
- package/src/lib/calculatePricing.tsx +1 -1
- package/src/lib/inertiaOptions.tsx +1 -1
- package/src/lib/quoteRequestForm.tsx +7 -4
- package/src/types/misc/index.ts +0 -2
- package/dist/types/misc/inertia.d.ts +0 -8
- package/src/types/misc/inertia.ts +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
3
|
className?: string;
|
|
4
4
|
href?: string;
|
|
@@ -10,5 +10,5 @@ interface Props {
|
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
as?: 'link' | 'button' | 'a';
|
|
12
12
|
}
|
|
13
|
-
export default function Button({ className, href, target, onClick, type, children, status, disabled, as }: Props): JSX.Element;
|
|
13
|
+
export default function Button({ className, href, target, onClick, type, children, status, disabled, as, }: Props): JSX.Element;
|
|
14
14
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
interface Props {
|
|
3
|
+
name?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
onChange: (dateString: string) => void;
|
|
3
6
|
value?: string;
|
|
4
|
-
|
|
7
|
+
maxYear?: number;
|
|
8
|
+
showAge?: boolean;
|
|
5
9
|
}
|
|
6
|
-
export default function DateOfBirthField({
|
|
10
|
+
export default function DateOfBirthField({ name, id, onChange, value, maxYear, showAge, }: Props): JSX.Element;
|
|
7
11
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ErrorBag, Errors } from
|
|
2
|
+
import { ErrorBag, Errors } from '@inertiajs/core';
|
|
3
3
|
interface Props {
|
|
4
4
|
heading?: string;
|
|
5
5
|
errors?: Errors & ErrorBag;
|
|
6
6
|
renderKeys?: boolean;
|
|
7
7
|
className?: string;
|
|
8
8
|
}
|
|
9
|
-
export default function ErrorList({ heading, errors, renderKeys, className }: Props): JSX.Element;
|
|
9
|
+
export default function ErrorList({ heading, errors, renderKeys, className, }: Props): JSX.Element;
|
|
10
10
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
5
|
textAlign?: 'left' | 'right' | 'center';
|
|
6
6
|
sort?: string;
|
|
7
7
|
}
|
|
8
|
-
export default function TableHeader({ children, className, sort, textAlign }: Props): JSX.Element;
|
|
8
|
+
export default function TableHeader({ children, className, sort, textAlign, }: Props): JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { InertiaFormProps } from "@inertiajs/
|
|
2
|
+
import { InertiaFormProps } from "@inertiajs/react/types/useForm";
|
|
3
3
|
import type { QuoteRequest } from '../types';
|
|
4
|
+
declare type QuoteRequestForm = QuoteRequest & Record<string, any>;
|
|
4
5
|
interface QuoteRequestFormContextInterface {
|
|
5
|
-
form?: InertiaFormProps<
|
|
6
|
+
form?: InertiaFormProps<QuoteRequestForm>;
|
|
6
7
|
handleChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => void;
|
|
7
8
|
}
|
|
8
|
-
export declare const initialData:
|
|
9
|
+
export declare const initialData: QuoteRequestForm;
|
|
9
10
|
export declare const QuoteRequestFormContext: React.Context<QuoteRequestFormContextInterface>;
|
|
10
11
|
export declare function QuoteRequestFormProvider({ children }: {
|
|
11
12
|
children: React.ReactNode;
|
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var dateFns = require('date-fns');
|
|
8
|
-
var
|
|
8
|
+
var react = require('@inertiajs/react');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var React__default = _interopDefault(React);
|
|
11
11
|
var uuid = require('uuid');
|
|
12
|
-
var react = require('@headlessui/react');
|
|
13
|
-
var
|
|
12
|
+
var react$1 = require('@headlessui/react');
|
|
13
|
+
var lodash = require('lodash');
|
|
14
14
|
var cn = _interopDefault(require('classnames'));
|
|
15
15
|
|
|
16
16
|
function parseDate(dateString) {
|
|
@@ -166,7 +166,7 @@ function sanitiseVehicleType(inputType) {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
function useAuth() {
|
|
169
|
-
var _usePage =
|
|
169
|
+
var _usePage = react.usePage(),
|
|
170
170
|
props = _usePage.props;
|
|
171
171
|
|
|
172
172
|
return props.auth;
|
|
@@ -784,7 +784,7 @@ var initialData = {
|
|
|
784
784
|
var QuoteRequestFormContext = /*#__PURE__*/React__default.createContext({});
|
|
785
785
|
function QuoteRequestFormProvider(_ref) {
|
|
786
786
|
var children = _ref.children;
|
|
787
|
-
var form =
|
|
787
|
+
var form = react.useForm(initialData);
|
|
788
788
|
/**
|
|
789
789
|
* Handle the change event for all form inputs
|
|
790
790
|
*/
|
|
@@ -1134,7 +1134,7 @@ function Button(_ref) {
|
|
|
1134
1134
|
}, children);
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
|
-
return React__default.createElement(
|
|
1137
|
+
return React__default.createElement(react.Link, {
|
|
1138
1138
|
href: href,
|
|
1139
1139
|
className: classes
|
|
1140
1140
|
}, children);
|
|
@@ -1199,7 +1199,7 @@ function Pagination(_ref) {
|
|
|
1199
1199
|
className: "" + (className != null ? className : '')
|
|
1200
1200
|
}, React__default.createElement("nav", {
|
|
1201
1201
|
className: "font-bold flex justify-between items-center gap-6"
|
|
1202
|
-
}, React__default.createElement(
|
|
1202
|
+
}, React__default.createElement(react.Link, {
|
|
1203
1203
|
href: prevPageLink,
|
|
1204
1204
|
className: "flex items-center gap-2",
|
|
1205
1205
|
disabled: current_page === 1
|
|
@@ -1227,7 +1227,7 @@ function Pagination(_ref) {
|
|
|
1227
1227
|
value: "50"
|
|
1228
1228
|
}, "50 per page"), React__default.createElement("option", {
|
|
1229
1229
|
value: "100"
|
|
1230
|
-
}, "100 per page")) : ''), React__default.createElement(
|
|
1230
|
+
}, "100 per page")) : ''), React__default.createElement(react.Link, {
|
|
1231
1231
|
href: nextPageLink,
|
|
1232
1232
|
className: "flex items-center gap-2",
|
|
1233
1233
|
disabled: current_page === page_count
|
|
@@ -1263,7 +1263,7 @@ function ToastItem(_ref) {
|
|
|
1263
1263
|
removeToast(_id);
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
|
-
return React__default.createElement(react.Transition, {
|
|
1266
|
+
return React__default.createElement(react$1.Transition, {
|
|
1267
1267
|
show: true,
|
|
1268
1268
|
appear: true,
|
|
1269
1269
|
enter: "transition-all duration-300",
|
|
@@ -1311,16 +1311,16 @@ function Modal(_ref) {
|
|
|
1311
1311
|
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
1312
1312
|
onClose = _ref.onClose,
|
|
1313
1313
|
title = _ref.title;
|
|
1314
|
-
return React__default.createElement(react.Transition.Root, {
|
|
1314
|
+
return React__default.createElement(react$1.Transition.Root, {
|
|
1315
1315
|
show: isActive,
|
|
1316
1316
|
as: React.Fragment
|
|
1317
|
-
}, React__default.createElement(react.Dialog, {
|
|
1317
|
+
}, React__default.createElement(react$1.Dialog, {
|
|
1318
1318
|
as: "div",
|
|
1319
1319
|
className: "fixed z-[110] inset-0 overflow-y-auto",
|
|
1320
1320
|
onClose: onClose
|
|
1321
1321
|
}, React__default.createElement("div", {
|
|
1322
1322
|
className: "flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"
|
|
1323
|
-
}, React__default.createElement(react.Transition.Child, {
|
|
1323
|
+
}, React__default.createElement(react$1.Transition.Child, {
|
|
1324
1324
|
as: React.Fragment,
|
|
1325
1325
|
enter: "ease-out duration-300",
|
|
1326
1326
|
enterFrom: "opacity-0",
|
|
@@ -1328,9 +1328,9 @@ function Modal(_ref) {
|
|
|
1328
1328
|
leave: "ease-in duration-200",
|
|
1329
1329
|
leaveFrom: "opacity-100",
|
|
1330
1330
|
leaveTo: "opacity-0"
|
|
1331
|
-
}, React__default.createElement(react.Dialog.Overlay, {
|
|
1331
|
+
}, React__default.createElement(react$1.Dialog.Overlay, {
|
|
1332
1332
|
className: "fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
|
|
1333
|
-
})), React__default.createElement(react.Transition.Child, {
|
|
1333
|
+
})), React__default.createElement(react$1.Transition.Child, {
|
|
1334
1334
|
as: React.Fragment,
|
|
1335
1335
|
enter: "ease-out duration-300",
|
|
1336
1336
|
enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
|
|
@@ -1444,7 +1444,7 @@ function TableHeader(_ref) {
|
|
|
1444
1444
|
className: className + " py-3.5 px-3 text-sm font-semibold text-left"
|
|
1445
1445
|
}, React__default.createElement("div", {
|
|
1446
1446
|
className: "flex items-center gap-3 " + textAlignClass
|
|
1447
|
-
}, children, sort && React__default.createElement(
|
|
1447
|
+
}, children, sort && React__default.createElement(react.Link, {
|
|
1448
1448
|
href: sortLink
|
|
1449
1449
|
}, React__default.createElement("svg", {
|
|
1450
1450
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1474,67 +1474,57 @@ function TableRow(_ref) {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
1476
|
function DateOfBirthField(_ref) {
|
|
1477
|
-
var
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1477
|
+
var _ref$name = _ref.name,
|
|
1478
|
+
name = _ref$name === void 0 ? 'dob' : _ref$name,
|
|
1479
|
+
_ref$id = _ref.id,
|
|
1480
|
+
id = _ref$id === void 0 ? 'dob' : _ref$id,
|
|
1481
|
+
onChange = _ref.onChange,
|
|
1482
|
+
value = _ref.value,
|
|
1483
|
+
_ref$maxYear = _ref.maxYear,
|
|
1484
|
+
maxYear = _ref$maxYear === void 0 ? 0 : _ref$maxYear,
|
|
1485
|
+
_ref$showAge = _ref.showAge,
|
|
1486
|
+
showAge = _ref$showAge === void 0 ? false : _ref$showAge;
|
|
1488
1487
|
var dayOptions = [].concat(Array.from(Array(31).keys())).map(function (value) {
|
|
1489
|
-
return
|
|
1488
|
+
return lodash.padStart("" + (value + 1), 2, '0');
|
|
1490
1489
|
});
|
|
1491
1490
|
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
1492
1491
|
var monthOptions = [].concat(Array.from(Array(12).keys())).map(function (value) {
|
|
1493
1492
|
return {
|
|
1494
1493
|
title: months[value],
|
|
1495
|
-
value:
|
|
1494
|
+
value: lodash.padStart("" + (value + 1), 2, '0')
|
|
1496
1495
|
};
|
|
1497
|
-
});
|
|
1498
|
-
|
|
1496
|
+
}); // Create 100 years of options, subtracting the maximum year if provided
|
|
1497
|
+
|
|
1499
1498
|
var yearOptions = [].concat(Array.from(Array(100).keys())).map(function (value) {
|
|
1500
|
-
return
|
|
1499
|
+
return maxYear ? maxYear - value : new Date().getFullYear() - value;
|
|
1501
1500
|
});
|
|
1502
1501
|
|
|
1503
|
-
function
|
|
1504
|
-
var _extends2;
|
|
1505
|
-
|
|
1502
|
+
function handleChange(e) {
|
|
1506
1503
|
var _e$currentTarget = e.currentTarget,
|
|
1507
1504
|
name = _e$currentTarget.name,
|
|
1508
1505
|
value = _e$currentTarget.value;
|
|
1509
|
-
|
|
1510
|
-
var
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
setDateOfBirth(newDob); // Format the date for the API
|
|
1514
|
-
|
|
1515
|
-
var formattedDate = newDob.year + "-" + newDob.month + "-" + newDob.day; // Call the upstream prop if we have all of the date parts
|
|
1516
|
-
|
|
1517
|
-
if (Object.values(newDob).every(function (value) {
|
|
1518
|
-
return value !== '';
|
|
1519
|
-
})) {
|
|
1520
|
-
onChange(formattedDate);
|
|
1521
|
-
} else {
|
|
1522
|
-
// Otherwise, clear the value
|
|
1523
|
-
onChange('');
|
|
1524
|
-
}
|
|
1506
|
+
var y = name.includes('year') ? value : year;
|
|
1507
|
+
var m = name.includes('month') ? value : month;
|
|
1508
|
+
var d = name.includes('day') ? value : day;
|
|
1509
|
+
onChange(y + "-" + m + "-" + d);
|
|
1525
1510
|
}
|
|
1526
1511
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1512
|
+
var _ref2 = value ? value.split('-') : ['', '', ''],
|
|
1513
|
+
year = _ref2[0],
|
|
1514
|
+
month = _ref2[1],
|
|
1515
|
+
day = _ref2[2];
|
|
1516
|
+
|
|
1517
|
+
var isValidDate = year && month && day && !isNaN(Date.parse(year + "-" + month + "-" + day));
|
|
1518
|
+
return React__default.createElement("span", {
|
|
1519
|
+
className: "flex flex-col gap-2"
|
|
1529
1520
|
}, React__default.createElement("span", {
|
|
1530
|
-
className: "
|
|
1531
|
-
}, React__default.createElement("span", null, "Date of birth")), React__default.createElement("span", {
|
|
1532
|
-
className: "flex space-x-4 border border-gray-300 rounded-lg mt-1 bg-white"
|
|
1521
|
+
className: "flex space-x-4 border border-gray-300 rounded-lg bg-white"
|
|
1533
1522
|
}, React__default.createElement("select", {
|
|
1534
|
-
name: "
|
|
1535
|
-
|
|
1523
|
+
name: name + "_day",
|
|
1524
|
+
id: id + "_day",
|
|
1525
|
+
value: day,
|
|
1536
1526
|
className: "flex-grow focus:outline-none border-0",
|
|
1537
|
-
onChange:
|
|
1527
|
+
onChange: handleChange,
|
|
1538
1528
|
required: true
|
|
1539
1529
|
}, React__default.createElement("option", {
|
|
1540
1530
|
value: ""
|
|
@@ -1544,10 +1534,11 @@ function DateOfBirthField(_ref) {
|
|
|
1544
1534
|
value: option
|
|
1545
1535
|
}, option);
|
|
1546
1536
|
})), React__default.createElement("select", {
|
|
1547
|
-
name: "
|
|
1548
|
-
|
|
1537
|
+
name: name + "_month",
|
|
1538
|
+
id: id + "_month",
|
|
1539
|
+
value: month,
|
|
1549
1540
|
className: "flex-grow focus:outline-none border-0",
|
|
1550
|
-
onChange:
|
|
1541
|
+
onChange: handleChange,
|
|
1551
1542
|
required: true
|
|
1552
1543
|
}, React__default.createElement("option", {
|
|
1553
1544
|
value: ""
|
|
@@ -1557,10 +1548,11 @@ function DateOfBirthField(_ref) {
|
|
|
1557
1548
|
value: option.value
|
|
1558
1549
|
}, option.title);
|
|
1559
1550
|
})), React__default.createElement("select", {
|
|
1560
|
-
name: "
|
|
1561
|
-
|
|
1551
|
+
name: name + "_year",
|
|
1552
|
+
id: id + "_year",
|
|
1553
|
+
value: year,
|
|
1562
1554
|
className: "flex-grow focus:outline-none border-0",
|
|
1563
|
-
onChange:
|
|
1555
|
+
onChange: handleChange,
|
|
1564
1556
|
required: true
|
|
1565
1557
|
}, React__default.createElement("option", {
|
|
1566
1558
|
value: ""
|
|
@@ -1569,7 +1561,9 @@ function DateOfBirthField(_ref) {
|
|
|
1569
1561
|
key: option,
|
|
1570
1562
|
value: option
|
|
1571
1563
|
}, option);
|
|
1572
|
-
})))
|
|
1564
|
+
}))), showAge && value && isValidDate && React__default.createElement("span", {
|
|
1565
|
+
className: "font-bold"
|
|
1566
|
+
}, "Age: ", calculateAge(value), " years"));
|
|
1573
1567
|
}
|
|
1574
1568
|
|
|
1575
1569
|
function MoneyField(_ref) {
|