@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
package/dist/sdk.esm.js
CHANGED
|
@@ -1098,19 +1098,27 @@ function _getAddressData() {
|
|
|
1098
1098
|
|
|
1099
1099
|
/**
|
|
1100
1100
|
* Calculate someone's age from a date of birth.
|
|
1101
|
-
* @param date YYYY-MM-DD
|
|
1102
1101
|
*/
|
|
1103
1102
|
function calculateAge(date) {
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
var age = today.getFullYear() - birthDate.getFullYear();
|
|
1107
|
-
var m = today.getMonth() - birthDate.getMonth();
|
|
1108
|
-
|
|
1109
|
-
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
1110
|
-
return age - 1;
|
|
1103
|
+
if (!date) {
|
|
1104
|
+
return 0;
|
|
1111
1105
|
}
|
|
1112
1106
|
|
|
1113
|
-
|
|
1107
|
+
try {
|
|
1108
|
+
var today = new Date();
|
|
1109
|
+
var birthDate = new Date(date);
|
|
1110
|
+
var age = today.getFullYear() - birthDate.getFullYear();
|
|
1111
|
+
var m = today.getMonth() - birthDate.getMonth();
|
|
1112
|
+
|
|
1113
|
+
if (m < 0 || m === 0 && today.getDate() < birthDate.getDate()) {
|
|
1114
|
+
return age - 1;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
return age;
|
|
1118
|
+
} catch (error) {
|
|
1119
|
+
console.error(error);
|
|
1120
|
+
return 0;
|
|
1121
|
+
}
|
|
1114
1122
|
}
|
|
1115
1123
|
|
|
1116
1124
|
function calculateMonthly(_ref) {
|
|
@@ -2826,10 +2834,10 @@ function FilterItem(_ref) {
|
|
|
2826
2834
|
className: "whitespace-nowrap"
|
|
2827
2835
|
}, filter.label), React__default.createElement(HiChevronDown, null))
|
|
2828
2836
|
}, React__default.createElement("form", {
|
|
2829
|
-
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
|
|
2837
|
+
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'),
|
|
2830
2838
|
onSubmit: handleApply
|
|
2831
2839
|
}, React__default.createElement("div", {
|
|
2832
|
-
className: "flex flex-col items-start gap-1"
|
|
2840
|
+
className: "flex flex-col items-start gap-1 p-4"
|
|
2833
2841
|
}, (!filter.type || filter.type === 'options') && ((_filter$options = filter.options) == null ? void 0 : _filter$options.map(function (option, i) {
|
|
2834
2842
|
return React__default.createElement("div", {
|
|
2835
2843
|
className: "checkbox text-sm ",
|
|
@@ -2854,7 +2862,7 @@ function FilterItem(_ref) {
|
|
|
2854
2862
|
id: filter.label,
|
|
2855
2863
|
value: selected[0],
|
|
2856
2864
|
onChange: handleSelect,
|
|
2857
|
-
className: "w-full"
|
|
2865
|
+
className: "!p-2 text-sm w-full"
|
|
2858
2866
|
}, React__default.createElement("option", {
|
|
2859
2867
|
value: ""
|
|
2860
2868
|
}, "Select option"), (_filter$options2 = filter.options) == null ? void 0 : _filter$options2.map(function (option) {
|
|
@@ -2869,7 +2877,7 @@ function FilterItem(_ref) {
|
|
|
2869
2877
|
id: filter.label,
|
|
2870
2878
|
value: selected[0],
|
|
2871
2879
|
onChange: handleSelect,
|
|
2872
|
-
className: "w-full"
|
|
2880
|
+
className: "!p-2 text-sm w-full"
|
|
2873
2881
|
}, React__default.createElement("option", {
|
|
2874
2882
|
value: ""
|
|
2875
2883
|
}, "Select option"), (_filter$options3 = filter.options) == null ? void 0 : _filter$options3.map(function (option) {
|
|
@@ -2878,23 +2886,25 @@ function FilterItem(_ref) {
|
|
|
2878
2886
|
value: option.value
|
|
2879
2887
|
}, option.label);
|
|
2880
2888
|
}))), filter.type === 'date' && React__default.createElement("div", {
|
|
2881
|
-
className: "mb-2 flex flex-col gap-4"
|
|
2889
|
+
className: "mb-2 flex flex-col gap-4 w-full"
|
|
2882
2890
|
}, React__default.createElement("label", {
|
|
2883
|
-
className: "text-xs"
|
|
2891
|
+
className: "text-xs w-full"
|
|
2884
2892
|
}, "From", React__default.createElement("input", {
|
|
2885
2893
|
type: "date",
|
|
2886
2894
|
name: filter.name + "[from]",
|
|
2887
2895
|
id: filter.name + "[from]",
|
|
2888
2896
|
onChange: handleDateSelect,
|
|
2889
|
-
value: (_selected$ = selected[0]) != null ? _selected$ : ''
|
|
2897
|
+
value: (_selected$ = selected[0]) != null ? _selected$ : '',
|
|
2898
|
+
className: "!p-2 text-sm w-full"
|
|
2890
2899
|
})), React__default.createElement("label", {
|
|
2891
|
-
className: "text-xs"
|
|
2900
|
+
className: "text-xs w-full"
|
|
2892
2901
|
}, "To", React__default.createElement("input", {
|
|
2893
2902
|
type: "date",
|
|
2894
2903
|
name: filter.name + "[to]",
|
|
2895
2904
|
id: filter.name + "[to]",
|
|
2896
2905
|
onChange: handleDateSelect,
|
|
2897
|
-
value: (_selected$2 = selected[1]) != null ? _selected$2 : ''
|
|
2906
|
+
value: (_selected$2 = selected[1]) != null ? _selected$2 : '',
|
|
2907
|
+
className: "!p-2 text-sm w-full"
|
|
2898
2908
|
}))), filter.type === 'select' && filter.options && React__default.createElement("div", {
|
|
2899
2909
|
className: "w-full"
|
|
2900
2910
|
}, React__default.createElement(Select, {
|
|
@@ -2916,7 +2926,7 @@ function FilterItem(_ref) {
|
|
|
2916
2926
|
});
|
|
2917
2927
|
}
|
|
2918
2928
|
}))), React__default.createElement("div", {
|
|
2919
|
-
className: "flex items-center gap-2
|
|
2929
|
+
className: "bg-gray-100 border-t border-gray-200 flex items-center gap-2 p-4 bottom-0 sticky"
|
|
2920
2930
|
}, React__default.createElement(Button, {
|
|
2921
2931
|
type: "button",
|
|
2922
2932
|
className: "!min-w-[0px] flex-grow !px-2 text-sm !transition-none",
|