@star-insure/sdk 4.1.1 → 4.1.3
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/lib/calculateAge.d.ts +1 -2
- package/dist/sdk.cjs.development.js +29 -19
- 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 +29 -19
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/filter/FilterItem.tsx +10 -8
- package/src/lib/calculateAge.ts +17 -10
|
@@ -1105,19 +1105,27 @@ function _getAddressData() {
|
|
|
1105
1105
|
|
|
1106
1106
|
/**
|
|
1107
1107
|
* Calculate someone's age from a date of birth.
|
|
1108
|
-
* @param date YYYY-MM-DD
|
|
1109
1108
|
*/
|
|
1110
1109
|
function calculateAge(date) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
var age = today.getFullYear() - birthDate.getFullYear();
|
|
1114
|
-
var m = today.getMonth() - birthDate.getMonth();
|
|
1115
|
-
|
|
1116
|
-
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
1117
|
-
return age - 1;
|
|
1110
|
+
if (!date) {
|
|
1111
|
+
return 0;
|
|
1118
1112
|
}
|
|
1119
1113
|
|
|
1120
|
-
|
|
1114
|
+
try {
|
|
1115
|
+
var today = new Date();
|
|
1116
|
+
var birthDate = new Date(date);
|
|
1117
|
+
var age = today.getFullYear() - birthDate.getFullYear();
|
|
1118
|
+
var m = today.getMonth() - birthDate.getMonth();
|
|
1119
|
+
|
|
1120
|
+
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
1121
|
+
return age - 1;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
return age;
|
|
1125
|
+
} catch (error) {
|
|
1126
|
+
console.error(error);
|
|
1127
|
+
return 0;
|
|
1128
|
+
}
|
|
1121
1129
|
}
|
|
1122
1130
|
|
|
1123
1131
|
function calculateMonthly(_ref) {
|
|
@@ -2833,10 +2841,10 @@ function FilterItem(_ref) {
|
|
|
2833
2841
|
className: "whitespace-nowrap"
|
|
2834
2842
|
}, filter.label), React__default.createElement(hi2.HiChevronDown, null))
|
|
2835
2843
|
}, React__default.createElement("form", {
|
|
2836
|
-
className: "mt-2 flex max-h-[350px] min-w-[200px] max-w-[260px] flex-col gap-2 rounded-md border border-gray-300 bg-white
|
|
2844
|
+
className: "mt-2 flex max-h-[350px] min-w-[200px] max-w-[260px] flex-col gap-2 rounded-md border border-gray-300 bg-white shadow-lg " + (filter.type && filter.type === 'select' ? '' : 'overflow-y-scroll'),
|
|
2837
2845
|
onSubmit: handleApply
|
|
2838
2846
|
}, React__default.createElement("div", {
|
|
2839
|
-
className: "flex flex-col items-start gap-1"
|
|
2847
|
+
className: "flex flex-col items-start gap-1 p-4"
|
|
2840
2848
|
}, (!filter.type || filter.type === 'options') && ((_filter$options = filter.options) == null ? void 0 : _filter$options.map(function (option, i) {
|
|
2841
2849
|
return React__default.createElement("div", {
|
|
2842
2850
|
className: "checkbox text-sm ",
|
|
@@ -2861,7 +2869,7 @@ function FilterItem(_ref) {
|
|
|
2861
2869
|
id: filter.label,
|
|
2862
2870
|
value: selected[0],
|
|
2863
2871
|
onChange: handleSelect,
|
|
2864
|
-
className: "w-full"
|
|
2872
|
+
className: "!p-2 text-sm w-full"
|
|
2865
2873
|
}, React__default.createElement("option", {
|
|
2866
2874
|
value: ""
|
|
2867
2875
|
}, "Select option"), (_filter$options2 = filter.options) == null ? void 0 : _filter$options2.map(function (option) {
|
|
@@ -2876,7 +2884,7 @@ function FilterItem(_ref) {
|
|
|
2876
2884
|
id: filter.label,
|
|
2877
2885
|
value: selected[0],
|
|
2878
2886
|
onChange: handleSelect,
|
|
2879
|
-
className: "w-full"
|
|
2887
|
+
className: "!p-2 text-sm w-full"
|
|
2880
2888
|
}, React__default.createElement("option", {
|
|
2881
2889
|
value: ""
|
|
2882
2890
|
}, "Select option"), (_filter$options3 = filter.options) == null ? void 0 : _filter$options3.map(function (option) {
|
|
@@ -2885,23 +2893,25 @@ function FilterItem(_ref) {
|
|
|
2885
2893
|
value: option.value
|
|
2886
2894
|
}, option.label);
|
|
2887
2895
|
}))), filter.type === 'date' && React__default.createElement("div", {
|
|
2888
|
-
className: "mb-2 flex flex-col gap-4"
|
|
2896
|
+
className: "mb-2 flex flex-col gap-4 w-full"
|
|
2889
2897
|
}, React__default.createElement("label", {
|
|
2890
|
-
className: "text-xs"
|
|
2898
|
+
className: "text-xs w-full"
|
|
2891
2899
|
}, "From", React__default.createElement("input", {
|
|
2892
2900
|
type: "date",
|
|
2893
2901
|
name: filter.name + "[from]",
|
|
2894
2902
|
id: filter.name + "[from]",
|
|
2895
2903
|
onChange: handleDateSelect,
|
|
2896
|
-
value: (_selected$ = selected[0]) != null ? _selected$ : ''
|
|
2904
|
+
value: (_selected$ = selected[0]) != null ? _selected$ : '',
|
|
2905
|
+
className: "!p-2 text-sm w-full"
|
|
2897
2906
|
})), React__default.createElement("label", {
|
|
2898
|
-
className: "text-xs"
|
|
2907
|
+
className: "text-xs w-full"
|
|
2899
2908
|
}, "To", React__default.createElement("input", {
|
|
2900
2909
|
type: "date",
|
|
2901
2910
|
name: filter.name + "[to]",
|
|
2902
2911
|
id: filter.name + "[to]",
|
|
2903
2912
|
onChange: handleDateSelect,
|
|
2904
|
-
value: (_selected$2 = selected[1]) != null ? _selected$2 : ''
|
|
2913
|
+
value: (_selected$2 = selected[1]) != null ? _selected$2 : '',
|
|
2914
|
+
className: "!p-2 text-sm w-full"
|
|
2905
2915
|
}))), filter.type === 'select' && filter.options && React__default.createElement("div", {
|
|
2906
2916
|
className: "w-full"
|
|
2907
2917
|
}, React__default.createElement(Select, {
|
|
@@ -2923,7 +2933,7 @@ function FilterItem(_ref) {
|
|
|
2923
2933
|
});
|
|
2924
2934
|
}
|
|
2925
2935
|
}))), React__default.createElement("div", {
|
|
2926
|
-
className: "flex items-center gap-2
|
|
2936
|
+
className: "bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky"
|
|
2927
2937
|
}, React__default.createElement(Button, {
|
|
2928
2938
|
type: "button",
|
|
2929
2939
|
className: "!min-w-[0px] flex-grow !px-2 text-sm !transition-none",
|