@star-insure/sdk 4.5.0 → 5.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.
@@ -14,3 +14,7 @@ export declare function formatDate(date: Date | string | null | undefined, overr
14
14
  * Formats a dateTime to Star Insure standard format - dd/mm/yyyy hh:mm
15
15
  */
16
16
  export declare function formatDateTime(dateTime: Date | string | null | undefined, overrideFormatString?: string): string;
17
+ /**
18
+ * Attempts to create a date object from a date string
19
+ */
20
+ export declare function createDate(dateString: Date | string | null | undefined): Date | null;
@@ -125,6 +125,26 @@ function formatDateTime(dateTime, overrideFormatString) {
125
125
 
126
126
  return '';
127
127
  }
128
+ /**
129
+ * Attempts to create a date object from a date string
130
+ */
131
+
132
+ function createDate(dateString) {
133
+ // Re-use our logic from formatDateTime
134
+ var formattedDateTime = formatDateTime(dateString);
135
+
136
+ if (!formattedDateTime) {
137
+ return null;
138
+ } // Attempt to parse the formatted date to a date object
139
+
140
+
141
+ try {
142
+ return dateFns.parse(formattedDateTime, 'dd/MM/yyyy HH:mm', new Date());
143
+ } catch (error) {
144
+ console.error("Error parsing date: " + (dateString == null ? void 0 : dateString.toString()));
145
+ return null;
146
+ }
147
+ }
128
148
 
129
149
  /**
130
150
  * Safely rounds a number
@@ -1328,7 +1348,7 @@ function Button(_ref) {
1328
1348
  _ref$small = _ref.small,
1329
1349
  small = _ref$small === void 0 ? false : _ref$small;
1330
1350
  var baseClasses = small ? 'font-bold text-sm inline-flex items-center gap-3 justify-center text-white text-center px-3 py-1 rounded min-w-[80px] transition-all hover:brightness-110' : 'font-black inline-flex items-center gap-3 justify-center text-white text-center px-5 py-2 rounded-md min-w-[120px] transition-all hover:brightness-110';
1331
- var statusClass = status === 'primary' && 'bg-teal' || status === 'danger' && 'bg-red-500' || status === 'warning' && 'bg-yellow-400' || status === 'info' && 'bg-blue-400' || 'bg-gray-600';
1351
+ var statusClass = status === 'primary' && 'bg-primary' || status === 'danger' && 'bg-red-500' || status === 'warning' && 'bg-yellow-400' || status === 'info' && 'bg-blue-400' || 'bg-gray-600';
1332
1352
  var classes = (className != null ? className : '') + " " + baseClasses + " " + statusClass;
1333
1353
 
1334
1354
  if (_onClick) {
@@ -1587,7 +1607,7 @@ function ToastItem(_ref) {
1587
1607
  removeToast = _useToast.removeToast;
1588
1608
 
1589
1609
  var defaultClasses = 'w-full min-w-[250px] p-4 shadow flex justify-between items-center font-black rounded-md not:';
1590
- var statusClasses = status === 'success' && 'bg-teal text-white' || status === 'error' && 'bg-red-500 text-white' || status === 'warning' && 'bg-yellow-400 text-white' || 'bg-white text-asphalt';
1610
+ var statusClasses = status === 'success' && 'bg-primary text-white' || status === 'error' && 'bg-red-500 text-white' || status === 'warning' && 'bg-yellow-400 text-white' || 'bg-white text-secondary';
1591
1611
  var classes = defaultClasses + " " + statusClasses;
1592
1612
 
1593
1613
  function handleClick() {
@@ -1676,7 +1696,7 @@ function Modal(_ref) {
1676
1696
  }, React__default.createElement("div", {
1677
1697
  className: className + " w-full align-start inline-block bg-white rounded-lg px-4 pt-5 pb-4 text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-7xl sm:p-6 " + width
1678
1698
  }, React__default.createElement("div", {
1679
- className: "flex gap-4 mb-4 text-asphalt " + (title ? 'border-b-2 border-asphalt pb-4' : '')
1699
+ className: "flex gap-4 mb-4 text-secondary " + (title ? 'border-b-2 border-secondary pb-4' : '')
1680
1700
  }, title && React__default.createElement("h3", {
1681
1701
  className: "font-black text-lg"
1682
1702
  }, title), React__default.createElement("button", {
@@ -1754,7 +1774,7 @@ function TableHead(_ref) {
1754
1774
  props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
1755
1775
 
1756
1776
  return React__default.createElement("thead", Object.assign({}, props, {
1757
- className: cn(className, 'px-3 py-4 text-sm text-white bg-gray-600')
1777
+ className: cn(className, 'px-3 py-4 text-sm text-white bg-table-header-background')
1758
1778
  }), children);
1759
1779
  }
1760
1780
 
@@ -1821,7 +1841,7 @@ function TableRow(_ref) {
1821
1841
  _onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
1822
1842
  props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
1823
1843
 
1824
- var bgClass = className.includes('bg') ? '' : 'bg-white even:bg-gray-50';
1844
+ var bgClass = className.includes('bg') ? '' : 'bg-white even:bg-table-row-alternative-background';
1825
1845
  return React__default.createElement("tr", Object.assign({}, props, {
1826
1846
  className: cn(className, bgClass, 'hover:bg-gray-100'),
1827
1847
  onClick: function onClick(e) {
@@ -1964,7 +1984,7 @@ function MoneyField(_ref) {
1964
1984
 
1965
1985
  var displayValue = formatMoney(value, 0);
1966
1986
  return React__default.createElement("div", {
1967
- className: className + " flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-teal focus-within:outline-none focus-within:ring focus-within:ring-teal focus-within:ring-opacity-50"
1987
+ className: className + " flex items-center gap-2 pl-4 rounded-md border border-gray-300 transition-all focus-within:border-primary focus-within:outline-none focus-within:ring focus-within:ring-primary focus-within:ring-opacity-50"
1968
1988
  }, React__default.createElement("span", {
1969
1989
  className: "font-bold pr-2"
1970
1990
  }, "$"), React__default.createElement("input", {
@@ -2194,7 +2214,7 @@ function RegistrationSearchField(_ref) {
2194
2214
  type: "button",
2195
2215
  onClick: handleSearch,
2196
2216
  disabled: status === 'processing',
2197
- className: cn(searchBtnClassName, "bg-teal px-4 py-3 rounded-md transition-all")
2217
+ className: cn(searchBtnClassName, "bg-primary px-4 py-3 rounded-md transition-all")
2198
2218
  }, React__default.createElement("span", {
2199
2219
  className: "sr-only"
2200
2220
  }, "Search"), React__default.createElement("svg", {
@@ -2468,7 +2488,7 @@ function BackButton(_ref) {
2468
2488
  }, [breadcrumbs]);
2469
2489
  return React__default.createElement(react.Link, {
2470
2490
  href: backUrl || '/',
2471
- className: cn(className, 'flex items-center justify-center hover:text-teal transition-all')
2491
+ className: cn(className, 'flex items-center justify-center text-back-button-text hover:text-primary transition-all')
2472
2492
  }, React__default.createElement(hi2.HiArrowLeft, {
2473
2493
  className: "h-5 w-5 stroke-[1.25]"
2474
2494
  }));
@@ -2559,12 +2579,12 @@ function SearchBar(_ref) {
2559
2579
  onClick: function onClick() {
2560
2580
  return onActive(true);
2561
2581
  },
2562
- className: "flex items-center justify-center rounded-full hover:text-teal p-1 hover:bg-gray-100"
2582
+ className: "flex items-center justify-center rounded-full hover:text-primary p-1 hover:bg-gray-100"
2563
2583
  }, React__default.createElement(hi2.HiMagnifyingGlass, {
2564
2584
  className: "h-5 w-5 stroke-[1.25]"
2565
2585
  })), active && React__default.createElement("form", {
2566
2586
  onSubmit: handleSearch,
2567
- className: "group flex items-center gap-2 rounded-full bg-white pr-4 pl-1 shadow transition-all focus-within:outline-none focus-within:ring-1 focus-within:ring-teal"
2587
+ className: "group flex items-center gap-2 rounded-full bg-white pr-4 pl-1 shadow transition-all focus-within:outline-none focus-within:ring-1 focus-within:ring-primary"
2568
2588
  }, React__default.createElement("input", {
2569
2589
  type: "text",
2570
2590
  name: "search",
@@ -2981,8 +3001,8 @@ function FilterItem(_ref) {
2981
3001
  onClick: function onClick() {
2982
3002
  return handleClick();
2983
3003
  },
2984
- className: cn('flex rounded-2xl border hover:cursor-pointer 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', {
2985
- '!bg-teal border-teal': hasFilters
3004
+ className: cn('flex rounded-2xl border hover:cursor-pointer hover:border-primary bg-gray-600 px-2 py-1 items-center justify-between shrink-0 gap-2 text-xs text-white hover:bg-primary transition-colors', {
3005
+ '!bg-primary border-primary': hasFilters
2986
3006
  })
2987
3007
  }, React__default.createElement("p", {
2988
3008
  className: "whitespace-nowrap"
@@ -3256,17 +3276,17 @@ function PageHeader(_ref) {
3256
3276
  className: cn('col-span-full flex items-center gap-2 max-w-full rounded-lg bg-white p-2 shadow', className)
3257
3277
  }, back && React__default.createElement(BackButton, {
3258
3278
  back: back,
3259
- className: "bg-gray-100 h-[60px] w-[60px] rounded"
3279
+ className: "bg-back-button-background h-[60px] w-[60px] rounded"
3260
3280
  }), React__default.createElement("div", {
3261
- className: cn('w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-gray-100 p-3 gap-4', innerClassName)
3281
+ className: cn('w-full grid grid-cols-[auto_1fr_auto_auto] h-[60px] rounded bg-page-header-background p-3 gap-4', innerClassName)
3262
3282
  }, React__default.createElement("button", {
3263
3283
  type: "button",
3264
3284
  disabled: !search,
3265
3285
  onClick: function onClick() {
3266
3286
  return setSearchActive(true);
3267
3287
  },
3268
- className: cn('mr-auto flex items-center gap-4 transition-colors pr-6 pl-1 disabled:opacity-100', {
3269
- 'hover:text-teal': search && !isSearchActive
3288
+ className: cn('mr-auto flex items-center gap-4 transition-colors pr-6 pl-1 disabled:opacity-100 text-page-header-text', {
3289
+ 'hover:text-primary': search && !isSearchActive
3270
3290
  })
3271
3291
  }, search && React__default.createElement(SearchBar, {
3272
3292
  search: search,
@@ -3275,7 +3295,7 @@ function PageHeader(_ref) {
3275
3295
  placeholder: "Search " + title + "...",
3276
3296
  focusSearchShortcut: focusSearchShortcut
3277
3297
  }), !isSearchActive && React__default.createElement("h1", {
3278
- className: "text-base font-black"
3298
+ className: "text-base text-page-header-text font-black"
3279
3299
  }, title)), React__default.createElement("div", {
3280
3300
  className: "flex items-center ml-auto gap-2 h-full min-w-0 max-w-full"
3281
3301
  }, filterOptions.length > 0 && React__default.createElement(React__default.Fragment, null, React__default.createElement("button", {
@@ -3298,7 +3318,7 @@ function PageHeader(_ref) {
3298
3318
  onClick: clickRight,
3299
3319
  className: "w-5 h-5 text-gray-400 stroke-[1.25]"
3300
3320
  }))), filteredActions.length > 0 && React__default.createElement("div", {
3301
- className: "flex items-center gap-3 bg-gray-100"
3321
+ className: "flex items-center gap-3 bg-page-header-background"
3302
3322
  }, filterOptions.length > 0 && React__default.createElement("div", {
3303
3323
  className: "w-[1px] h-full bg-gray-300"
3304
3324
  }), React__default.createElement("nav", {
@@ -3346,6 +3366,7 @@ exports.autocomplete = autocomplete;
3346
3366
  exports.calcMonthlyEnhancementPrice = calcMonthlyEnhancementPrice;
3347
3367
  exports.calcPurchaseOptionPricing = calcPurchaseOptionPricing;
3348
3368
  exports.calculateAge = calculateAge;
3369
+ exports.createDate = createDate;
3349
3370
  exports.fixRoundingError = fixRoundingError;
3350
3371
  exports.formatDate = formatDate;
3351
3372
  exports.formatDateForTable = formatDateForTable;