design-zystem 1.0.256 → 1.0.257
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/index.d.mts +64 -1
- package/dist/index.d.ts +64 -1
- package/dist/index.js +369 -3
- package/dist/index.mjs +343 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1035,4 +1035,67 @@ interface OptimizeImageOptions {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
declare const optimizeImage: (file: File | null | undefined, desiredBaseName: string, opts?: OptimizeImageOptions) => Promise<OptimizeImageResult>;
|
|
1037
1037
|
|
|
1038
|
-
|
|
1038
|
+
declare const getRelativeTime: (date: Date | string) => string;
|
|
1039
|
+
|
|
1040
|
+
declare const formatTime: (time: string | null | undefined) => string;
|
|
1041
|
+
|
|
1042
|
+
declare const easterDate: (year: number) => Date;
|
|
1043
|
+
|
|
1044
|
+
declare const isHoliday: (date: Date) => boolean;
|
|
1045
|
+
|
|
1046
|
+
declare const addBusinessDays: (originalDate: Date, numDaysToAdd: number) => Date;
|
|
1047
|
+
|
|
1048
|
+
declare const formatAddress: (address: string | null | undefined) => string | null;
|
|
1049
|
+
|
|
1050
|
+
declare const formatLocality: (locality: string | null | undefined) => string | null;
|
|
1051
|
+
|
|
1052
|
+
declare const formatRegionCode: (postalCode: string | null | undefined) => string;
|
|
1053
|
+
|
|
1054
|
+
declare const formatCityFromFormattedAddress: (address: string | null | undefined) => string;
|
|
1055
|
+
|
|
1056
|
+
declare const formatPostalCodeFromFormattedAddress: (address: string | null | undefined) => string;
|
|
1057
|
+
|
|
1058
|
+
declare const isolateCity: (addr: string | null | undefined) => string;
|
|
1059
|
+
|
|
1060
|
+
declare const formatPhoneNumber: (phone: string | null | undefined) => string | null;
|
|
1061
|
+
|
|
1062
|
+
declare const formatPlate: (plate: string | null | undefined) => string | null;
|
|
1063
|
+
|
|
1064
|
+
declare const formatPlateWithoutDashes: (plate: string | null | undefined) => string | null;
|
|
1065
|
+
|
|
1066
|
+
declare const capitalizeFirstLetter: (str: string | null | undefined) => string | null;
|
|
1067
|
+
|
|
1068
|
+
declare const generateHexColor: (firstName?: string, lastName?: string) => string;
|
|
1069
|
+
|
|
1070
|
+
interface AuthorLike {
|
|
1071
|
+
first_name?: string | null;
|
|
1072
|
+
firstname?: string | null;
|
|
1073
|
+
firstName?: string | null;
|
|
1074
|
+
last_name?: string | null;
|
|
1075
|
+
lastname?: string | null;
|
|
1076
|
+
lastName?: string | null;
|
|
1077
|
+
name?: string | null;
|
|
1078
|
+
display_name?: string | null;
|
|
1079
|
+
email?: string | null;
|
|
1080
|
+
}
|
|
1081
|
+
declare const getInitials: (author: AuthorLike | null | undefined) => string;
|
|
1082
|
+
|
|
1083
|
+
declare const getAvatarColor: (key: string) => string;
|
|
1084
|
+
|
|
1085
|
+
declare const getFileNameFromUrl: (url: string | null | undefined, fallback?: string) => string;
|
|
1086
|
+
|
|
1087
|
+
declare const getFileKind: (url: string | null | undefined) => "image" | "pdf" | "other";
|
|
1088
|
+
|
|
1089
|
+
declare const appendQueryParam: (url: string, key: string, value: string) => string;
|
|
1090
|
+
|
|
1091
|
+
declare const appendCacheBuster: (url: string) => string;
|
|
1092
|
+
|
|
1093
|
+
declare const getMimeCategory: (mimeType: string | null | undefined) => string;
|
|
1094
|
+
|
|
1095
|
+
declare const getCleanFileName: (fileName: string | null | undefined) => string;
|
|
1096
|
+
|
|
1097
|
+
declare const formatVin: (vin: string | null | undefined) => string;
|
|
1098
|
+
|
|
1099
|
+
declare const formatKM: (value: string | number | null | undefined) => string;
|
|
1100
|
+
|
|
1101
|
+
export { Accordion, type AccordionItem, Avatar, Box, Bubble, Bulk, Button, CardSkeleton, Checkbox, Col, Collapse, ColorPicker, DatePicker, Divider, Drawer, EmptyState, FileUploadZone, type FloatingAction, FloatingButton, type FloatingButtonProps, Grid, Icon, IconTabs, Image, Input, Link, List, ListItem, MetricCard, Modal, ModalConfirmation, MultiSelect, NewModal, Options, PageContainer, Pagination, Popover, ProgressBar, Radio, Row, Select, type SelectOption, type SelectProps, SkeletonRow, SliderInput, type SortOrder, Spinner, Stepper, Switch, Table, TableBody, TableCell, TableFooter, TableFooterCell, TableFooterRow, TableHeader, TableHeaderCell, type TableHeaderCellProps, TableHeaderRow, TableRow, Tabs, TagBubble, Text, Timeline, type TimelineItem, Tooltip, addBusinessDays, appendCacheBuster, appendQueryParam, capitalizeFirstLetter, colors, easterDate, formatAddress, formatCityFromFormattedAddress, formatDate, formatDistance, formatDuration, formatEuro, formatKM, formatLocality, formatName, formatPhoneNumber, formatPlate, formatPlateWithoutDashes, formatPostalCodeFromFormattedAddress, formatRegionCode, formatTime, formatVin, generateHexColor, getAvatarColor, getCleanFileName, getFileKind, getFileNameFromUrl, getInitials, getMimeCategory, getRelativeTime, isHoliday, isolateCity, optimizeImage, truncateFileName, truncateText };
|
package/dist/index.d.ts
CHANGED
|
@@ -1035,4 +1035,67 @@ interface OptimizeImageOptions {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
declare const optimizeImage: (file: File | null | undefined, desiredBaseName: string, opts?: OptimizeImageOptions) => Promise<OptimizeImageResult>;
|
|
1037
1037
|
|
|
1038
|
-
|
|
1038
|
+
declare const getRelativeTime: (date: Date | string) => string;
|
|
1039
|
+
|
|
1040
|
+
declare const formatTime: (time: string | null | undefined) => string;
|
|
1041
|
+
|
|
1042
|
+
declare const easterDate: (year: number) => Date;
|
|
1043
|
+
|
|
1044
|
+
declare const isHoliday: (date: Date) => boolean;
|
|
1045
|
+
|
|
1046
|
+
declare const addBusinessDays: (originalDate: Date, numDaysToAdd: number) => Date;
|
|
1047
|
+
|
|
1048
|
+
declare const formatAddress: (address: string | null | undefined) => string | null;
|
|
1049
|
+
|
|
1050
|
+
declare const formatLocality: (locality: string | null | undefined) => string | null;
|
|
1051
|
+
|
|
1052
|
+
declare const formatRegionCode: (postalCode: string | null | undefined) => string;
|
|
1053
|
+
|
|
1054
|
+
declare const formatCityFromFormattedAddress: (address: string | null | undefined) => string;
|
|
1055
|
+
|
|
1056
|
+
declare const formatPostalCodeFromFormattedAddress: (address: string | null | undefined) => string;
|
|
1057
|
+
|
|
1058
|
+
declare const isolateCity: (addr: string | null | undefined) => string;
|
|
1059
|
+
|
|
1060
|
+
declare const formatPhoneNumber: (phone: string | null | undefined) => string | null;
|
|
1061
|
+
|
|
1062
|
+
declare const formatPlate: (plate: string | null | undefined) => string | null;
|
|
1063
|
+
|
|
1064
|
+
declare const formatPlateWithoutDashes: (plate: string | null | undefined) => string | null;
|
|
1065
|
+
|
|
1066
|
+
declare const capitalizeFirstLetter: (str: string | null | undefined) => string | null;
|
|
1067
|
+
|
|
1068
|
+
declare const generateHexColor: (firstName?: string, lastName?: string) => string;
|
|
1069
|
+
|
|
1070
|
+
interface AuthorLike {
|
|
1071
|
+
first_name?: string | null;
|
|
1072
|
+
firstname?: string | null;
|
|
1073
|
+
firstName?: string | null;
|
|
1074
|
+
last_name?: string | null;
|
|
1075
|
+
lastname?: string | null;
|
|
1076
|
+
lastName?: string | null;
|
|
1077
|
+
name?: string | null;
|
|
1078
|
+
display_name?: string | null;
|
|
1079
|
+
email?: string | null;
|
|
1080
|
+
}
|
|
1081
|
+
declare const getInitials: (author: AuthorLike | null | undefined) => string;
|
|
1082
|
+
|
|
1083
|
+
declare const getAvatarColor: (key: string) => string;
|
|
1084
|
+
|
|
1085
|
+
declare const getFileNameFromUrl: (url: string | null | undefined, fallback?: string) => string;
|
|
1086
|
+
|
|
1087
|
+
declare const getFileKind: (url: string | null | undefined) => "image" | "pdf" | "other";
|
|
1088
|
+
|
|
1089
|
+
declare const appendQueryParam: (url: string, key: string, value: string) => string;
|
|
1090
|
+
|
|
1091
|
+
declare const appendCacheBuster: (url: string) => string;
|
|
1092
|
+
|
|
1093
|
+
declare const getMimeCategory: (mimeType: string | null | undefined) => string;
|
|
1094
|
+
|
|
1095
|
+
declare const getCleanFileName: (fileName: string | null | undefined) => string;
|
|
1096
|
+
|
|
1097
|
+
declare const formatVin: (vin: string | null | undefined) => string;
|
|
1098
|
+
|
|
1099
|
+
declare const formatKM: (value: string | number | null | undefined) => string;
|
|
1100
|
+
|
|
1101
|
+
export { Accordion, type AccordionItem, Avatar, Box, Bubble, Bulk, Button, CardSkeleton, Checkbox, Col, Collapse, ColorPicker, DatePicker, Divider, Drawer, EmptyState, FileUploadZone, type FloatingAction, FloatingButton, type FloatingButtonProps, Grid, Icon, IconTabs, Image, Input, Link, List, ListItem, MetricCard, Modal, ModalConfirmation, MultiSelect, NewModal, Options, PageContainer, Pagination, Popover, ProgressBar, Radio, Row, Select, type SelectOption, type SelectProps, SkeletonRow, SliderInput, type SortOrder, Spinner, Stepper, Switch, Table, TableBody, TableCell, TableFooter, TableFooterCell, TableFooterRow, TableHeader, TableHeaderCell, type TableHeaderCellProps, TableHeaderRow, TableRow, Tabs, TagBubble, Text, Timeline, type TimelineItem, Tooltip, addBusinessDays, appendCacheBuster, appendQueryParam, capitalizeFirstLetter, colors, easterDate, formatAddress, formatCityFromFormattedAddress, formatDate, formatDistance, formatDuration, formatEuro, formatKM, formatLocality, formatName, formatPhoneNumber, formatPlate, formatPlateWithoutDashes, formatPostalCodeFromFormattedAddress, formatRegionCode, formatTime, formatVin, generateHexColor, getAvatarColor, getCleanFileName, getFileKind, getFileNameFromUrl, getInitials, getMimeCategory, getRelativeTime, isHoliday, isolateCity, optimizeImage, truncateFileName, truncateText };
|
package/dist/index.js
CHANGED
|
@@ -117,12 +117,38 @@ __export(index_exports, {
|
|
|
117
117
|
Text: () => Text,
|
|
118
118
|
Timeline: () => Timeline,
|
|
119
119
|
Tooltip: () => Tooltip,
|
|
120
|
+
addBusinessDays: () => addBusinessDays,
|
|
121
|
+
appendCacheBuster: () => appendCacheBuster,
|
|
122
|
+
appendQueryParam: () => appendQueryParam,
|
|
123
|
+
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
120
124
|
colors: () => colors,
|
|
125
|
+
easterDate: () => easterDate,
|
|
126
|
+
formatAddress: () => formatAddress,
|
|
127
|
+
formatCityFromFormattedAddress: () => formatCityFromFormattedAddress,
|
|
121
128
|
formatDate: () => formatDate,
|
|
122
129
|
formatDistance: () => formatDistance,
|
|
123
130
|
formatDuration: () => formatDuration,
|
|
124
131
|
formatEuro: () => formatEuro,
|
|
132
|
+
formatKM: () => formatKM,
|
|
133
|
+
formatLocality: () => formatLocality,
|
|
125
134
|
formatName: () => formatName,
|
|
135
|
+
formatPhoneNumber: () => formatPhoneNumber,
|
|
136
|
+
formatPlate: () => formatPlate,
|
|
137
|
+
formatPlateWithoutDashes: () => formatPlateWithoutDashes,
|
|
138
|
+
formatPostalCodeFromFormattedAddress: () => formatPostalCodeFromFormattedAddress,
|
|
139
|
+
formatRegionCode: () => formatRegionCode,
|
|
140
|
+
formatTime: () => formatTime,
|
|
141
|
+
formatVin: () => formatVin,
|
|
142
|
+
generateHexColor: () => generateHexColor,
|
|
143
|
+
getAvatarColor: () => getAvatarColor,
|
|
144
|
+
getCleanFileName: () => getCleanFileName,
|
|
145
|
+
getFileKind: () => getFileKind,
|
|
146
|
+
getFileNameFromUrl: () => getFileNameFromUrl,
|
|
147
|
+
getInitials: () => getInitials2,
|
|
148
|
+
getMimeCategory: () => getMimeCategory,
|
|
149
|
+
getRelativeTime: () => getRelativeTime,
|
|
150
|
+
isHoliday: () => isHoliday,
|
|
151
|
+
isolateCity: () => isolateCity,
|
|
126
152
|
optimizeImage: () => optimizeImage_default,
|
|
127
153
|
truncateFileName: () => truncateFileName,
|
|
128
154
|
truncateText: () => truncateText
|
|
@@ -5550,7 +5576,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5550
5576
|
const baseLang = typeof language === "string" ? language.split("-")[0] : "en";
|
|
5551
5577
|
const locale = localeMap[language] || localeMap[baseLang] || language || "en-GB";
|
|
5552
5578
|
const format = (options) => new Intl.DateTimeFormat(locale, options).format(date);
|
|
5553
|
-
const
|
|
5579
|
+
const formatTime2 = () => new Intl.DateTimeFormat(locale, {
|
|
5554
5580
|
hour: "2-digit",
|
|
5555
5581
|
minute: "2-digit",
|
|
5556
5582
|
hourCycle: "h23"
|
|
@@ -5564,7 +5590,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5564
5590
|
month: "2-digit",
|
|
5565
5591
|
year: "numeric"
|
|
5566
5592
|
});
|
|
5567
|
-
return `${dayPart} ${
|
|
5593
|
+
return `${dayPart} ${formatTime2()}`;
|
|
5568
5594
|
}
|
|
5569
5595
|
case "dateISO": {
|
|
5570
5596
|
const year = date.getFullYear();
|
|
@@ -5596,7 +5622,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5596
5622
|
day: "numeric",
|
|
5597
5623
|
month: "short"
|
|
5598
5624
|
});
|
|
5599
|
-
return `${dayPart} ${
|
|
5625
|
+
return `${dayPart} ${formatTime2()}`;
|
|
5600
5626
|
}
|
|
5601
5627
|
case "longDate":
|
|
5602
5628
|
return format({ day: "numeric", month: "long", year: "numeric" });
|
|
@@ -5788,6 +5814,320 @@ var optimizeImage = async (file, desiredBaseName, opts = {}) => {
|
|
|
5788
5814
|
}
|
|
5789
5815
|
};
|
|
5790
5816
|
var optimizeImage_default = optimizeImage;
|
|
5817
|
+
|
|
5818
|
+
// src/utils/date/getRelativeTime.ts
|
|
5819
|
+
var UNITS = [
|
|
5820
|
+
{ name: "ann\xE9e", seconds: 31536e3, pluralize: true },
|
|
5821
|
+
{ name: "mois", seconds: 2592e3, pluralize: false },
|
|
5822
|
+
{ name: "jour", seconds: 86400, pluralize: true },
|
|
5823
|
+
{ name: "heure", seconds: 3600, pluralize: true },
|
|
5824
|
+
{ name: "minute", seconds: 60, pluralize: true },
|
|
5825
|
+
{ name: "seconde", seconds: 1, pluralize: true }
|
|
5826
|
+
];
|
|
5827
|
+
var getRelativeTime = (date) => {
|
|
5828
|
+
const diffInSeconds = Math.floor(
|
|
5829
|
+
(Date.now() - new Date(date).getTime()) / 1e3
|
|
5830
|
+
);
|
|
5831
|
+
for (const unit of UNITS) {
|
|
5832
|
+
const interval = Math.floor(diffInSeconds / unit.seconds);
|
|
5833
|
+
if (interval >= 1) {
|
|
5834
|
+
const suffix = unit.pluralize && interval > 1 ? "s" : "";
|
|
5835
|
+
return `il y a ${interval} ${unit.name}${suffix}`;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
return "\xE0 l'instant";
|
|
5839
|
+
};
|
|
5840
|
+
|
|
5841
|
+
// src/utils/date/formatTime.ts
|
|
5842
|
+
var formatTime = (time) => {
|
|
5843
|
+
if (!time) return "";
|
|
5844
|
+
const [hours, minutes] = time.split(":");
|
|
5845
|
+
return minutes !== "00" ? `${hours}h${minutes}` : `${hours}h`;
|
|
5846
|
+
};
|
|
5847
|
+
|
|
5848
|
+
// src/utils/date/easterDate.ts
|
|
5849
|
+
var easterDate = (year) => {
|
|
5850
|
+
const f = Math.floor;
|
|
5851
|
+
const a = year % 19;
|
|
5852
|
+
const b = f(year / 100);
|
|
5853
|
+
const c = year % 100;
|
|
5854
|
+
const d = f(b / 4);
|
|
5855
|
+
const e = b % 4;
|
|
5856
|
+
const f1 = f((b + 8) / 25);
|
|
5857
|
+
const g = f((b - f1 + 1) / 3);
|
|
5858
|
+
const h = (19 * a + b - d - g + 15) % 30;
|
|
5859
|
+
const i = f(c / 4);
|
|
5860
|
+
const k = c % 4;
|
|
5861
|
+
const l = (32 + 2 * e + 2 * i - h - k) % 7;
|
|
5862
|
+
const m = f((a + 11 * h + 22 * l) / 451);
|
|
5863
|
+
const month = f((h + l - 7 * m + 114) / 31);
|
|
5864
|
+
const day = (h + l - 7 * m + 114) % 31 + 1;
|
|
5865
|
+
return new Date(year, month - 1, day);
|
|
5866
|
+
};
|
|
5867
|
+
|
|
5868
|
+
// src/utils/date/isHoliday.ts
|
|
5869
|
+
var isHoliday = (date) => {
|
|
5870
|
+
const year = date.getFullYear();
|
|
5871
|
+
const easter = easterDate(year);
|
|
5872
|
+
const ascension = new Date(easter.getTime());
|
|
5873
|
+
ascension.setDate(easter.getDate() + 39);
|
|
5874
|
+
const pentecost = new Date(easter.getTime());
|
|
5875
|
+
pentecost.setDate(easter.getDate() + 50);
|
|
5876
|
+
const easterMonday = new Date(easter.getTime());
|
|
5877
|
+
easterMonday.setDate(easter.getDate() + 1);
|
|
5878
|
+
const holidays = {
|
|
5879
|
+
"1/1": "Nouvel An",
|
|
5880
|
+
"1/5": "F\xEAte du Travail",
|
|
5881
|
+
"8/5": "Victoire 1945",
|
|
5882
|
+
"14/7": "F\xEAte Nationale",
|
|
5883
|
+
"15/8": "Assomption",
|
|
5884
|
+
"1/11": "Toussaint",
|
|
5885
|
+
"11/11": "Armistice",
|
|
5886
|
+
"25/12": "No\xEBl",
|
|
5887
|
+
[`${easterMonday.getDate()}/${easterMonday.getMonth() + 1}`]: "Lundi de P\xE2ques",
|
|
5888
|
+
[`${ascension.getDate()}/${ascension.getMonth() + 1}`]: "Ascension",
|
|
5889
|
+
[`${pentecost.getDate()}/${pentecost.getMonth() + 1}`]: "Pentec\xF4te"
|
|
5890
|
+
};
|
|
5891
|
+
const key = `${date.getDate()}/${date.getMonth() + 1}`;
|
|
5892
|
+
return Object.prototype.hasOwnProperty.call(holidays, key);
|
|
5893
|
+
};
|
|
5894
|
+
|
|
5895
|
+
// src/utils/date/addBusinessDays.ts
|
|
5896
|
+
var addBusinessDays = (originalDate, numDaysToAdd) => {
|
|
5897
|
+
let daysAdded = 0;
|
|
5898
|
+
const newDate = new Date(originalDate.getTime());
|
|
5899
|
+
while (daysAdded < numDaysToAdd) {
|
|
5900
|
+
newDate.setDate(newDate.getDate() + 1);
|
|
5901
|
+
const dayOfWeek = newDate.getDay();
|
|
5902
|
+
if (dayOfWeek !== 0 && dayOfWeek !== 6 && !isHoliday(newDate)) {
|
|
5903
|
+
daysAdded++;
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
return newDate;
|
|
5907
|
+
};
|
|
5908
|
+
|
|
5909
|
+
// src/utils/address/formatAddress.ts
|
|
5910
|
+
var formatAddress = (address) => {
|
|
5911
|
+
if (!address) return null;
|
|
5912
|
+
const match = address.match(/(\b\d{5}\b)\s+([\p{L}\s'-]+)/u);
|
|
5913
|
+
if (match) return `${match[1]} ${match[2].trim()}`;
|
|
5914
|
+
return address;
|
|
5915
|
+
};
|
|
5916
|
+
|
|
5917
|
+
// src/utils/address/formatLocality.ts
|
|
5918
|
+
var formatLocality = (locality) => {
|
|
5919
|
+
if (!locality) return null;
|
|
5920
|
+
const parts = locality.split(",").map((p) => p.trim());
|
|
5921
|
+
if (parts.length >= 4) {
|
|
5922
|
+
const city = parts[1];
|
|
5923
|
+
const department = parts[3].slice(0, 2);
|
|
5924
|
+
return `${city} (${department})`;
|
|
5925
|
+
}
|
|
5926
|
+
return null;
|
|
5927
|
+
};
|
|
5928
|
+
|
|
5929
|
+
// src/utils/address/formatRegionCode.ts
|
|
5930
|
+
var formatRegionCode = (postalCode) => {
|
|
5931
|
+
if (!postalCode) return "";
|
|
5932
|
+
const cleaned = postalCode.replace(/\D/g, "");
|
|
5933
|
+
return cleaned.length >= 2 ? cleaned.slice(0, 2) : cleaned;
|
|
5934
|
+
};
|
|
5935
|
+
|
|
5936
|
+
// src/utils/address/formatCityFromFormattedAddress.ts
|
|
5937
|
+
var formatCityFromFormattedAddress = (address) => {
|
|
5938
|
+
if (!address) return "";
|
|
5939
|
+
const parts = address.split(",");
|
|
5940
|
+
if (parts.length < 2) return "";
|
|
5941
|
+
const localityPart = parts[parts.length - 2].trim();
|
|
5942
|
+
const locality = localityPart.split(" ").slice(1).join(" ");
|
|
5943
|
+
return locality.charAt(0).toUpperCase() + locality.slice(1);
|
|
5944
|
+
};
|
|
5945
|
+
|
|
5946
|
+
// src/utils/address/formatPostalCodeFromFormattedAddress.ts
|
|
5947
|
+
var formatPostalCodeFromFormattedAddress = (address) => {
|
|
5948
|
+
if (!address) return "";
|
|
5949
|
+
const parts = address.split(",");
|
|
5950
|
+
if (parts.length < 2) return "";
|
|
5951
|
+
const postalCodePart = parts[parts.length - 2].trim();
|
|
5952
|
+
return postalCodePart.split(" ")[0];
|
|
5953
|
+
};
|
|
5954
|
+
|
|
5955
|
+
// src/utils/address/isolateCity.ts
|
|
5956
|
+
var isolateCity = (addr) => {
|
|
5957
|
+
var _a, _b, _c;
|
|
5958
|
+
const cityWithPostalCode = (_c = (_b = (_a = addr == null ? void 0 : addr.split(",")) == null ? void 0 : _a.pop()) == null ? void 0 : _b.trim()) != null ? _c : "";
|
|
5959
|
+
const postalCode = cityWithPostalCode.slice(0, 5).trim();
|
|
5960
|
+
const city = cityWithPostalCode.slice(6).trim();
|
|
5961
|
+
const dept = postalCode ? postalCode.slice(0, 2) : "";
|
|
5962
|
+
return city ? `${city}${dept ? ` (${dept})` : ""}` : "\u2014";
|
|
5963
|
+
};
|
|
5964
|
+
|
|
5965
|
+
// src/utils/phone/formatPhoneNumber.ts
|
|
5966
|
+
var formatPhoneNumber = (phone) => {
|
|
5967
|
+
if (!phone) return null;
|
|
5968
|
+
let cleaned = phone.replace(/\D/g, "");
|
|
5969
|
+
if (cleaned.startsWith("33")) cleaned = "+" + cleaned;
|
|
5970
|
+
else if (cleaned.startsWith("0")) cleaned = "+33" + cleaned.substring(1);
|
|
5971
|
+
else if (!cleaned.startsWith("+33")) cleaned = "+33" + cleaned;
|
|
5972
|
+
const match = cleaned.match(/^(\+33)(\d{1})(\d{2})(\d{2})(\d{2})(\d{2})$/);
|
|
5973
|
+
if (match)
|
|
5974
|
+
return `${match[1]} ${match[2]} ${match[3]} ${match[4]} ${match[5]} ${match[6]}`;
|
|
5975
|
+
return phone;
|
|
5976
|
+
};
|
|
5977
|
+
|
|
5978
|
+
// src/utils/plate/formatPlate.ts
|
|
5979
|
+
var formatPlate = (plate) => {
|
|
5980
|
+
if (!plate) return null;
|
|
5981
|
+
if (plate.length === 7) {
|
|
5982
|
+
return `${plate.substring(0, 2).toUpperCase()}-${plate.substring(2, 5).toUpperCase()}-${plate.substring(5).toUpperCase()}`;
|
|
5983
|
+
}
|
|
5984
|
+
if (plate.length === 6) {
|
|
5985
|
+
return `${plate.substring(0, 1).toUpperCase()}-${plate.substring(1, 4).toUpperCase()}-${plate.substring(4).toUpperCase()}`;
|
|
5986
|
+
}
|
|
5987
|
+
if (plate.length === 9 && plate.includes("-")) return plate.toUpperCase();
|
|
5988
|
+
return plate;
|
|
5989
|
+
};
|
|
5990
|
+
|
|
5991
|
+
// src/utils/plate/formatPlateWithoutDashes.ts
|
|
5992
|
+
var formatPlateWithoutDashes = (plate) => {
|
|
5993
|
+
if (!plate) return null;
|
|
5994
|
+
return plate.replace(/-/g, "").toUpperCase();
|
|
5995
|
+
};
|
|
5996
|
+
|
|
5997
|
+
// src/utils/string/capitalizeFirstLetter.ts
|
|
5998
|
+
var capitalizeFirstLetter = (str) => {
|
|
5999
|
+
if (!str) return null;
|
|
6000
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
6001
|
+
};
|
|
6002
|
+
|
|
6003
|
+
// src/utils/string/generateHexColor.ts
|
|
6004
|
+
var generateHexColor = (firstName = "", lastName = "") => {
|
|
6005
|
+
const fullName = firstName.trim().toLowerCase() + lastName.trim().toLowerCase();
|
|
6006
|
+
let hash = 0;
|
|
6007
|
+
for (let i = 0; i < fullName.length; i++) {
|
|
6008
|
+
hash = fullName.charCodeAt(i) + ((hash << 5) - hash);
|
|
6009
|
+
}
|
|
6010
|
+
let color = "#";
|
|
6011
|
+
for (let i = 0; i < 3; i++) {
|
|
6012
|
+
const value = hash >> i * 8 & 255;
|
|
6013
|
+
color += ("00" + value.toString(16)).slice(-2);
|
|
6014
|
+
}
|
|
6015
|
+
return color;
|
|
6016
|
+
};
|
|
6017
|
+
|
|
6018
|
+
// src/utils/string/getInitials.ts
|
|
6019
|
+
var firstLetter = (s) => {
|
|
6020
|
+
var _a, _b;
|
|
6021
|
+
if (!s) return "";
|
|
6022
|
+
const token = String(s).trim().split(/[\s-]+/)[0];
|
|
6023
|
+
return (_b = (_a = token[0]) == null ? void 0 : _a.toUpperCase()) != null ? _b : "";
|
|
6024
|
+
};
|
|
6025
|
+
var getInitials2 = (author) => {
|
|
6026
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6027
|
+
if (!author) return "?";
|
|
6028
|
+
const f = (_c = (_b = (_a = author.first_name) != null ? _a : author.firstname) != null ? _b : author.firstName) != null ? _c : "";
|
|
6029
|
+
const l = (_f = (_e = (_d = author.last_name) != null ? _d : author.lastname) != null ? _e : author.lastName) != null ? _f : "";
|
|
6030
|
+
let initials = firstLetter(f) + firstLetter(l);
|
|
6031
|
+
if (!initials) {
|
|
6032
|
+
const name = (_i = (_h = (_g = author.name) != null ? _g : author.display_name) != null ? _h : author.email) != null ? _i : "";
|
|
6033
|
+
const parts = String(name).trim().split(/[\s.]+/).filter(Boolean);
|
|
6034
|
+
if (parts.length >= 2)
|
|
6035
|
+
initials = firstLetter(parts[0]) + firstLetter(parts[1]);
|
|
6036
|
+
else if (parts.length === 1) initials = parts[0].slice(0, 2).toUpperCase();
|
|
6037
|
+
}
|
|
6038
|
+
return initials || "?";
|
|
6039
|
+
};
|
|
6040
|
+
|
|
6041
|
+
// src/utils/string/getAvatarColor.ts
|
|
6042
|
+
var AVATAR_COLORS = [
|
|
6043
|
+
"#12638B",
|
|
6044
|
+
"#0B6E40",
|
|
6045
|
+
"#6D28D9",
|
|
6046
|
+
"#DC2626",
|
|
6047
|
+
"#0EA5E9",
|
|
6048
|
+
"#16A34A",
|
|
6049
|
+
"#F59E0B",
|
|
6050
|
+
"#059669",
|
|
6051
|
+
"#EF4444",
|
|
6052
|
+
"#3B82F6",
|
|
6053
|
+
"#9333EA",
|
|
6054
|
+
"#EA580C"
|
|
6055
|
+
];
|
|
6056
|
+
var hashString = (str = "") => {
|
|
6057
|
+
let h = 0;
|
|
6058
|
+
for (let i = 0; i < str.length; i++) {
|
|
6059
|
+
h = h * 31 + str.charCodeAt(i) | 0;
|
|
6060
|
+
}
|
|
6061
|
+
return Math.abs(h);
|
|
6062
|
+
};
|
|
6063
|
+
var getAvatarColor = (key) => {
|
|
6064
|
+
return AVATAR_COLORS[hashString(key) % AVATAR_COLORS.length];
|
|
6065
|
+
};
|
|
6066
|
+
|
|
6067
|
+
// src/utils/file/getFileNameFromUrl.ts
|
|
6068
|
+
var getFileNameFromUrl = (url, fallback = "") => {
|
|
6069
|
+
if (!url) return fallback;
|
|
6070
|
+
return url.split("/").pop() || fallback;
|
|
6071
|
+
};
|
|
6072
|
+
|
|
6073
|
+
// src/utils/file/getFileKind.ts
|
|
6074
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6075
|
+
"jpg",
|
|
6076
|
+
"jpeg",
|
|
6077
|
+
"png",
|
|
6078
|
+
"gif",
|
|
6079
|
+
"webp",
|
|
6080
|
+
"svg",
|
|
6081
|
+
"bmp",
|
|
6082
|
+
"avif"
|
|
6083
|
+
]);
|
|
6084
|
+
var getFileKind = (url) => {
|
|
6085
|
+
var _a, _b;
|
|
6086
|
+
if (!url) return "other";
|
|
6087
|
+
const ext = (_b = (_a = url.split("?")[0].split(".").pop()) == null ? void 0 : _a.toLowerCase()) != null ? _b : "";
|
|
6088
|
+
if (ext === "pdf") return "pdf";
|
|
6089
|
+
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
|
6090
|
+
return "other";
|
|
6091
|
+
};
|
|
6092
|
+
|
|
6093
|
+
// src/utils/file/appendQueryParam.ts
|
|
6094
|
+
var appendQueryParam = (url, key, value) => {
|
|
6095
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
6096
|
+
return `${url}${separator}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
6097
|
+
};
|
|
6098
|
+
|
|
6099
|
+
// src/utils/file/appendCacheBuster.ts
|
|
6100
|
+
var appendCacheBuster = (url) => {
|
|
6101
|
+
return appendQueryParam(url, "hash", Date.now().toString());
|
|
6102
|
+
};
|
|
6103
|
+
|
|
6104
|
+
// src/utils/file/getMimeCategory.ts
|
|
6105
|
+
var getMimeCategory = (mimeType) => {
|
|
6106
|
+
if (!mimeType) return "";
|
|
6107
|
+
return mimeType.split("/")[0];
|
|
6108
|
+
};
|
|
6109
|
+
|
|
6110
|
+
// src/utils/file/getCleanFileName.ts
|
|
6111
|
+
var getCleanFileName = (fileName) => {
|
|
6112
|
+
if (!fileName) return "";
|
|
6113
|
+
const parts = fileName.split("_");
|
|
6114
|
+
if (/^\d{13}$/.test(parts[0])) return parts.slice(1).join("_");
|
|
6115
|
+
return fileName;
|
|
6116
|
+
};
|
|
6117
|
+
|
|
6118
|
+
// src/utils/vehicle/formatVin.ts
|
|
6119
|
+
var formatVin = (vin) => {
|
|
6120
|
+
if (!vin) return "";
|
|
6121
|
+
return vin.length > 7 ? vin.slice(-7) : vin;
|
|
6122
|
+
};
|
|
6123
|
+
|
|
6124
|
+
// src/utils/vehicle/formatKM.ts
|
|
6125
|
+
var formatKM = (value) => {
|
|
6126
|
+
if (value === null || value === void 0 || value === "") return "";
|
|
6127
|
+
const parsed = parseInt(String(value), 10);
|
|
6128
|
+
if (isNaN(parsed) || parsed < 0) return "";
|
|
6129
|
+
return `${parsed} km`;
|
|
6130
|
+
};
|
|
5791
6131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5792
6132
|
0 && (module.exports = {
|
|
5793
6133
|
Accordion,
|
|
@@ -5848,12 +6188,38 @@ var optimizeImage_default = optimizeImage;
|
|
|
5848
6188
|
Text,
|
|
5849
6189
|
Timeline,
|
|
5850
6190
|
Tooltip,
|
|
6191
|
+
addBusinessDays,
|
|
6192
|
+
appendCacheBuster,
|
|
6193
|
+
appendQueryParam,
|
|
6194
|
+
capitalizeFirstLetter,
|
|
5851
6195
|
colors,
|
|
6196
|
+
easterDate,
|
|
6197
|
+
formatAddress,
|
|
6198
|
+
formatCityFromFormattedAddress,
|
|
5852
6199
|
formatDate,
|
|
5853
6200
|
formatDistance,
|
|
5854
6201
|
formatDuration,
|
|
5855
6202
|
formatEuro,
|
|
6203
|
+
formatKM,
|
|
6204
|
+
formatLocality,
|
|
5856
6205
|
formatName,
|
|
6206
|
+
formatPhoneNumber,
|
|
6207
|
+
formatPlate,
|
|
6208
|
+
formatPlateWithoutDashes,
|
|
6209
|
+
formatPostalCodeFromFormattedAddress,
|
|
6210
|
+
formatRegionCode,
|
|
6211
|
+
formatTime,
|
|
6212
|
+
formatVin,
|
|
6213
|
+
generateHexColor,
|
|
6214
|
+
getAvatarColor,
|
|
6215
|
+
getCleanFileName,
|
|
6216
|
+
getFileKind,
|
|
6217
|
+
getFileNameFromUrl,
|
|
6218
|
+
getInitials,
|
|
6219
|
+
getMimeCategory,
|
|
6220
|
+
getRelativeTime,
|
|
6221
|
+
isHoliday,
|
|
6222
|
+
isolateCity,
|
|
5857
6223
|
optimizeImage,
|
|
5858
6224
|
truncateFileName,
|
|
5859
6225
|
truncateText
|
package/dist/index.mjs
CHANGED
|
@@ -5471,7 +5471,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5471
5471
|
const baseLang = typeof language === "string" ? language.split("-")[0] : "en";
|
|
5472
5472
|
const locale = localeMap[language] || localeMap[baseLang] || language || "en-GB";
|
|
5473
5473
|
const format = (options) => new Intl.DateTimeFormat(locale, options).format(date);
|
|
5474
|
-
const
|
|
5474
|
+
const formatTime2 = () => new Intl.DateTimeFormat(locale, {
|
|
5475
5475
|
hour: "2-digit",
|
|
5476
5476
|
minute: "2-digit",
|
|
5477
5477
|
hourCycle: "h23"
|
|
@@ -5485,7 +5485,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5485
5485
|
month: "2-digit",
|
|
5486
5486
|
year: "numeric"
|
|
5487
5487
|
});
|
|
5488
|
-
return `${dayPart} ${
|
|
5488
|
+
return `${dayPart} ${formatTime2()}`;
|
|
5489
5489
|
}
|
|
5490
5490
|
case "dateISO": {
|
|
5491
5491
|
const year = date.getFullYear();
|
|
@@ -5517,7 +5517,7 @@ var formatDate = (dateString, type = "date", language = "en") => {
|
|
|
5517
5517
|
day: "numeric",
|
|
5518
5518
|
month: "short"
|
|
5519
5519
|
});
|
|
5520
|
-
return `${dayPart} ${
|
|
5520
|
+
return `${dayPart} ${formatTime2()}`;
|
|
5521
5521
|
}
|
|
5522
5522
|
case "longDate":
|
|
5523
5523
|
return format({ day: "numeric", month: "long", year: "numeric" });
|
|
@@ -5709,6 +5709,320 @@ var optimizeImage = async (file, desiredBaseName, opts = {}) => {
|
|
|
5709
5709
|
}
|
|
5710
5710
|
};
|
|
5711
5711
|
var optimizeImage_default = optimizeImage;
|
|
5712
|
+
|
|
5713
|
+
// src/utils/date/getRelativeTime.ts
|
|
5714
|
+
var UNITS = [
|
|
5715
|
+
{ name: "ann\xE9e", seconds: 31536e3, pluralize: true },
|
|
5716
|
+
{ name: "mois", seconds: 2592e3, pluralize: false },
|
|
5717
|
+
{ name: "jour", seconds: 86400, pluralize: true },
|
|
5718
|
+
{ name: "heure", seconds: 3600, pluralize: true },
|
|
5719
|
+
{ name: "minute", seconds: 60, pluralize: true },
|
|
5720
|
+
{ name: "seconde", seconds: 1, pluralize: true }
|
|
5721
|
+
];
|
|
5722
|
+
var getRelativeTime = (date) => {
|
|
5723
|
+
const diffInSeconds = Math.floor(
|
|
5724
|
+
(Date.now() - new Date(date).getTime()) / 1e3
|
|
5725
|
+
);
|
|
5726
|
+
for (const unit of UNITS) {
|
|
5727
|
+
const interval = Math.floor(diffInSeconds / unit.seconds);
|
|
5728
|
+
if (interval >= 1) {
|
|
5729
|
+
const suffix = unit.pluralize && interval > 1 ? "s" : "";
|
|
5730
|
+
return `il y a ${interval} ${unit.name}${suffix}`;
|
|
5731
|
+
}
|
|
5732
|
+
}
|
|
5733
|
+
return "\xE0 l'instant";
|
|
5734
|
+
};
|
|
5735
|
+
|
|
5736
|
+
// src/utils/date/formatTime.ts
|
|
5737
|
+
var formatTime = (time) => {
|
|
5738
|
+
if (!time) return "";
|
|
5739
|
+
const [hours, minutes] = time.split(":");
|
|
5740
|
+
return minutes !== "00" ? `${hours}h${minutes}` : `${hours}h`;
|
|
5741
|
+
};
|
|
5742
|
+
|
|
5743
|
+
// src/utils/date/easterDate.ts
|
|
5744
|
+
var easterDate = (year) => {
|
|
5745
|
+
const f = Math.floor;
|
|
5746
|
+
const a = year % 19;
|
|
5747
|
+
const b = f(year / 100);
|
|
5748
|
+
const c = year % 100;
|
|
5749
|
+
const d = f(b / 4);
|
|
5750
|
+
const e = b % 4;
|
|
5751
|
+
const f1 = f((b + 8) / 25);
|
|
5752
|
+
const g = f((b - f1 + 1) / 3);
|
|
5753
|
+
const h = (19 * a + b - d - g + 15) % 30;
|
|
5754
|
+
const i = f(c / 4);
|
|
5755
|
+
const k = c % 4;
|
|
5756
|
+
const l = (32 + 2 * e + 2 * i - h - k) % 7;
|
|
5757
|
+
const m = f((a + 11 * h + 22 * l) / 451);
|
|
5758
|
+
const month = f((h + l - 7 * m + 114) / 31);
|
|
5759
|
+
const day = (h + l - 7 * m + 114) % 31 + 1;
|
|
5760
|
+
return new Date(year, month - 1, day);
|
|
5761
|
+
};
|
|
5762
|
+
|
|
5763
|
+
// src/utils/date/isHoliday.ts
|
|
5764
|
+
var isHoliday = (date) => {
|
|
5765
|
+
const year = date.getFullYear();
|
|
5766
|
+
const easter = easterDate(year);
|
|
5767
|
+
const ascension = new Date(easter.getTime());
|
|
5768
|
+
ascension.setDate(easter.getDate() + 39);
|
|
5769
|
+
const pentecost = new Date(easter.getTime());
|
|
5770
|
+
pentecost.setDate(easter.getDate() + 50);
|
|
5771
|
+
const easterMonday = new Date(easter.getTime());
|
|
5772
|
+
easterMonday.setDate(easter.getDate() + 1);
|
|
5773
|
+
const holidays = {
|
|
5774
|
+
"1/1": "Nouvel An",
|
|
5775
|
+
"1/5": "F\xEAte du Travail",
|
|
5776
|
+
"8/5": "Victoire 1945",
|
|
5777
|
+
"14/7": "F\xEAte Nationale",
|
|
5778
|
+
"15/8": "Assomption",
|
|
5779
|
+
"1/11": "Toussaint",
|
|
5780
|
+
"11/11": "Armistice",
|
|
5781
|
+
"25/12": "No\xEBl",
|
|
5782
|
+
[`${easterMonday.getDate()}/${easterMonday.getMonth() + 1}`]: "Lundi de P\xE2ques",
|
|
5783
|
+
[`${ascension.getDate()}/${ascension.getMonth() + 1}`]: "Ascension",
|
|
5784
|
+
[`${pentecost.getDate()}/${pentecost.getMonth() + 1}`]: "Pentec\xF4te"
|
|
5785
|
+
};
|
|
5786
|
+
const key = `${date.getDate()}/${date.getMonth() + 1}`;
|
|
5787
|
+
return Object.prototype.hasOwnProperty.call(holidays, key);
|
|
5788
|
+
};
|
|
5789
|
+
|
|
5790
|
+
// src/utils/date/addBusinessDays.ts
|
|
5791
|
+
var addBusinessDays = (originalDate, numDaysToAdd) => {
|
|
5792
|
+
let daysAdded = 0;
|
|
5793
|
+
const newDate = new Date(originalDate.getTime());
|
|
5794
|
+
while (daysAdded < numDaysToAdd) {
|
|
5795
|
+
newDate.setDate(newDate.getDate() + 1);
|
|
5796
|
+
const dayOfWeek = newDate.getDay();
|
|
5797
|
+
if (dayOfWeek !== 0 && dayOfWeek !== 6 && !isHoliday(newDate)) {
|
|
5798
|
+
daysAdded++;
|
|
5799
|
+
}
|
|
5800
|
+
}
|
|
5801
|
+
return newDate;
|
|
5802
|
+
};
|
|
5803
|
+
|
|
5804
|
+
// src/utils/address/formatAddress.ts
|
|
5805
|
+
var formatAddress = (address) => {
|
|
5806
|
+
if (!address) return null;
|
|
5807
|
+
const match = address.match(/(\b\d{5}\b)\s+([\p{L}\s'-]+)/u);
|
|
5808
|
+
if (match) return `${match[1]} ${match[2].trim()}`;
|
|
5809
|
+
return address;
|
|
5810
|
+
};
|
|
5811
|
+
|
|
5812
|
+
// src/utils/address/formatLocality.ts
|
|
5813
|
+
var formatLocality = (locality) => {
|
|
5814
|
+
if (!locality) return null;
|
|
5815
|
+
const parts = locality.split(",").map((p) => p.trim());
|
|
5816
|
+
if (parts.length >= 4) {
|
|
5817
|
+
const city = parts[1];
|
|
5818
|
+
const department = parts[3].slice(0, 2);
|
|
5819
|
+
return `${city} (${department})`;
|
|
5820
|
+
}
|
|
5821
|
+
return null;
|
|
5822
|
+
};
|
|
5823
|
+
|
|
5824
|
+
// src/utils/address/formatRegionCode.ts
|
|
5825
|
+
var formatRegionCode = (postalCode) => {
|
|
5826
|
+
if (!postalCode) return "";
|
|
5827
|
+
const cleaned = postalCode.replace(/\D/g, "");
|
|
5828
|
+
return cleaned.length >= 2 ? cleaned.slice(0, 2) : cleaned;
|
|
5829
|
+
};
|
|
5830
|
+
|
|
5831
|
+
// src/utils/address/formatCityFromFormattedAddress.ts
|
|
5832
|
+
var formatCityFromFormattedAddress = (address) => {
|
|
5833
|
+
if (!address) return "";
|
|
5834
|
+
const parts = address.split(",");
|
|
5835
|
+
if (parts.length < 2) return "";
|
|
5836
|
+
const localityPart = parts[parts.length - 2].trim();
|
|
5837
|
+
const locality = localityPart.split(" ").slice(1).join(" ");
|
|
5838
|
+
return locality.charAt(0).toUpperCase() + locality.slice(1);
|
|
5839
|
+
};
|
|
5840
|
+
|
|
5841
|
+
// src/utils/address/formatPostalCodeFromFormattedAddress.ts
|
|
5842
|
+
var formatPostalCodeFromFormattedAddress = (address) => {
|
|
5843
|
+
if (!address) return "";
|
|
5844
|
+
const parts = address.split(",");
|
|
5845
|
+
if (parts.length < 2) return "";
|
|
5846
|
+
const postalCodePart = parts[parts.length - 2].trim();
|
|
5847
|
+
return postalCodePart.split(" ")[0];
|
|
5848
|
+
};
|
|
5849
|
+
|
|
5850
|
+
// src/utils/address/isolateCity.ts
|
|
5851
|
+
var isolateCity = (addr) => {
|
|
5852
|
+
var _a, _b, _c;
|
|
5853
|
+
const cityWithPostalCode = (_c = (_b = (_a = addr == null ? void 0 : addr.split(",")) == null ? void 0 : _a.pop()) == null ? void 0 : _b.trim()) != null ? _c : "";
|
|
5854
|
+
const postalCode = cityWithPostalCode.slice(0, 5).trim();
|
|
5855
|
+
const city = cityWithPostalCode.slice(6).trim();
|
|
5856
|
+
const dept = postalCode ? postalCode.slice(0, 2) : "";
|
|
5857
|
+
return city ? `${city}${dept ? ` (${dept})` : ""}` : "\u2014";
|
|
5858
|
+
};
|
|
5859
|
+
|
|
5860
|
+
// src/utils/phone/formatPhoneNumber.ts
|
|
5861
|
+
var formatPhoneNumber = (phone) => {
|
|
5862
|
+
if (!phone) return null;
|
|
5863
|
+
let cleaned = phone.replace(/\D/g, "");
|
|
5864
|
+
if (cleaned.startsWith("33")) cleaned = "+" + cleaned;
|
|
5865
|
+
else if (cleaned.startsWith("0")) cleaned = "+33" + cleaned.substring(1);
|
|
5866
|
+
else if (!cleaned.startsWith("+33")) cleaned = "+33" + cleaned;
|
|
5867
|
+
const match = cleaned.match(/^(\+33)(\d{1})(\d{2})(\d{2})(\d{2})(\d{2})$/);
|
|
5868
|
+
if (match)
|
|
5869
|
+
return `${match[1]} ${match[2]} ${match[3]} ${match[4]} ${match[5]} ${match[6]}`;
|
|
5870
|
+
return phone;
|
|
5871
|
+
};
|
|
5872
|
+
|
|
5873
|
+
// src/utils/plate/formatPlate.ts
|
|
5874
|
+
var formatPlate = (plate) => {
|
|
5875
|
+
if (!plate) return null;
|
|
5876
|
+
if (plate.length === 7) {
|
|
5877
|
+
return `${plate.substring(0, 2).toUpperCase()}-${plate.substring(2, 5).toUpperCase()}-${plate.substring(5).toUpperCase()}`;
|
|
5878
|
+
}
|
|
5879
|
+
if (plate.length === 6) {
|
|
5880
|
+
return `${plate.substring(0, 1).toUpperCase()}-${plate.substring(1, 4).toUpperCase()}-${plate.substring(4).toUpperCase()}`;
|
|
5881
|
+
}
|
|
5882
|
+
if (plate.length === 9 && plate.includes("-")) return plate.toUpperCase();
|
|
5883
|
+
return plate;
|
|
5884
|
+
};
|
|
5885
|
+
|
|
5886
|
+
// src/utils/plate/formatPlateWithoutDashes.ts
|
|
5887
|
+
var formatPlateWithoutDashes = (plate) => {
|
|
5888
|
+
if (!plate) return null;
|
|
5889
|
+
return plate.replace(/-/g, "").toUpperCase();
|
|
5890
|
+
};
|
|
5891
|
+
|
|
5892
|
+
// src/utils/string/capitalizeFirstLetter.ts
|
|
5893
|
+
var capitalizeFirstLetter = (str) => {
|
|
5894
|
+
if (!str) return null;
|
|
5895
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
5896
|
+
};
|
|
5897
|
+
|
|
5898
|
+
// src/utils/string/generateHexColor.ts
|
|
5899
|
+
var generateHexColor = (firstName = "", lastName = "") => {
|
|
5900
|
+
const fullName = firstName.trim().toLowerCase() + lastName.trim().toLowerCase();
|
|
5901
|
+
let hash = 0;
|
|
5902
|
+
for (let i = 0; i < fullName.length; i++) {
|
|
5903
|
+
hash = fullName.charCodeAt(i) + ((hash << 5) - hash);
|
|
5904
|
+
}
|
|
5905
|
+
let color = "#";
|
|
5906
|
+
for (let i = 0; i < 3; i++) {
|
|
5907
|
+
const value = hash >> i * 8 & 255;
|
|
5908
|
+
color += ("00" + value.toString(16)).slice(-2);
|
|
5909
|
+
}
|
|
5910
|
+
return color;
|
|
5911
|
+
};
|
|
5912
|
+
|
|
5913
|
+
// src/utils/string/getInitials.ts
|
|
5914
|
+
var firstLetter = (s) => {
|
|
5915
|
+
var _a, _b;
|
|
5916
|
+
if (!s) return "";
|
|
5917
|
+
const token = String(s).trim().split(/[\s-]+/)[0];
|
|
5918
|
+
return (_b = (_a = token[0]) == null ? void 0 : _a.toUpperCase()) != null ? _b : "";
|
|
5919
|
+
};
|
|
5920
|
+
var getInitials2 = (author) => {
|
|
5921
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5922
|
+
if (!author) return "?";
|
|
5923
|
+
const f = (_c = (_b = (_a = author.first_name) != null ? _a : author.firstname) != null ? _b : author.firstName) != null ? _c : "";
|
|
5924
|
+
const l = (_f = (_e = (_d = author.last_name) != null ? _d : author.lastname) != null ? _e : author.lastName) != null ? _f : "";
|
|
5925
|
+
let initials = firstLetter(f) + firstLetter(l);
|
|
5926
|
+
if (!initials) {
|
|
5927
|
+
const name = (_i = (_h = (_g = author.name) != null ? _g : author.display_name) != null ? _h : author.email) != null ? _i : "";
|
|
5928
|
+
const parts = String(name).trim().split(/[\s.]+/).filter(Boolean);
|
|
5929
|
+
if (parts.length >= 2)
|
|
5930
|
+
initials = firstLetter(parts[0]) + firstLetter(parts[1]);
|
|
5931
|
+
else if (parts.length === 1) initials = parts[0].slice(0, 2).toUpperCase();
|
|
5932
|
+
}
|
|
5933
|
+
return initials || "?";
|
|
5934
|
+
};
|
|
5935
|
+
|
|
5936
|
+
// src/utils/string/getAvatarColor.ts
|
|
5937
|
+
var AVATAR_COLORS = [
|
|
5938
|
+
"#12638B",
|
|
5939
|
+
"#0B6E40",
|
|
5940
|
+
"#6D28D9",
|
|
5941
|
+
"#DC2626",
|
|
5942
|
+
"#0EA5E9",
|
|
5943
|
+
"#16A34A",
|
|
5944
|
+
"#F59E0B",
|
|
5945
|
+
"#059669",
|
|
5946
|
+
"#EF4444",
|
|
5947
|
+
"#3B82F6",
|
|
5948
|
+
"#9333EA",
|
|
5949
|
+
"#EA580C"
|
|
5950
|
+
];
|
|
5951
|
+
var hashString = (str = "") => {
|
|
5952
|
+
let h = 0;
|
|
5953
|
+
for (let i = 0; i < str.length; i++) {
|
|
5954
|
+
h = h * 31 + str.charCodeAt(i) | 0;
|
|
5955
|
+
}
|
|
5956
|
+
return Math.abs(h);
|
|
5957
|
+
};
|
|
5958
|
+
var getAvatarColor = (key) => {
|
|
5959
|
+
return AVATAR_COLORS[hashString(key) % AVATAR_COLORS.length];
|
|
5960
|
+
};
|
|
5961
|
+
|
|
5962
|
+
// src/utils/file/getFileNameFromUrl.ts
|
|
5963
|
+
var getFileNameFromUrl = (url, fallback = "") => {
|
|
5964
|
+
if (!url) return fallback;
|
|
5965
|
+
return url.split("/").pop() || fallback;
|
|
5966
|
+
};
|
|
5967
|
+
|
|
5968
|
+
// src/utils/file/getFileKind.ts
|
|
5969
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
5970
|
+
"jpg",
|
|
5971
|
+
"jpeg",
|
|
5972
|
+
"png",
|
|
5973
|
+
"gif",
|
|
5974
|
+
"webp",
|
|
5975
|
+
"svg",
|
|
5976
|
+
"bmp",
|
|
5977
|
+
"avif"
|
|
5978
|
+
]);
|
|
5979
|
+
var getFileKind = (url) => {
|
|
5980
|
+
var _a, _b;
|
|
5981
|
+
if (!url) return "other";
|
|
5982
|
+
const ext = (_b = (_a = url.split("?")[0].split(".").pop()) == null ? void 0 : _a.toLowerCase()) != null ? _b : "";
|
|
5983
|
+
if (ext === "pdf") return "pdf";
|
|
5984
|
+
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
|
5985
|
+
return "other";
|
|
5986
|
+
};
|
|
5987
|
+
|
|
5988
|
+
// src/utils/file/appendQueryParam.ts
|
|
5989
|
+
var appendQueryParam = (url, key, value) => {
|
|
5990
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
5991
|
+
return `${url}${separator}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
5992
|
+
};
|
|
5993
|
+
|
|
5994
|
+
// src/utils/file/appendCacheBuster.ts
|
|
5995
|
+
var appendCacheBuster = (url) => {
|
|
5996
|
+
return appendQueryParam(url, "hash", Date.now().toString());
|
|
5997
|
+
};
|
|
5998
|
+
|
|
5999
|
+
// src/utils/file/getMimeCategory.ts
|
|
6000
|
+
var getMimeCategory = (mimeType) => {
|
|
6001
|
+
if (!mimeType) return "";
|
|
6002
|
+
return mimeType.split("/")[0];
|
|
6003
|
+
};
|
|
6004
|
+
|
|
6005
|
+
// src/utils/file/getCleanFileName.ts
|
|
6006
|
+
var getCleanFileName = (fileName) => {
|
|
6007
|
+
if (!fileName) return "";
|
|
6008
|
+
const parts = fileName.split("_");
|
|
6009
|
+
if (/^\d{13}$/.test(parts[0])) return parts.slice(1).join("_");
|
|
6010
|
+
return fileName;
|
|
6011
|
+
};
|
|
6012
|
+
|
|
6013
|
+
// src/utils/vehicle/formatVin.ts
|
|
6014
|
+
var formatVin = (vin) => {
|
|
6015
|
+
if (!vin) return "";
|
|
6016
|
+
return vin.length > 7 ? vin.slice(-7) : vin;
|
|
6017
|
+
};
|
|
6018
|
+
|
|
6019
|
+
// src/utils/vehicle/formatKM.ts
|
|
6020
|
+
var formatKM = (value) => {
|
|
6021
|
+
if (value === null || value === void 0 || value === "") return "";
|
|
6022
|
+
const parsed = parseInt(String(value), 10);
|
|
6023
|
+
if (isNaN(parsed) || parsed < 0) return "";
|
|
6024
|
+
return `${parsed} km`;
|
|
6025
|
+
};
|
|
5712
6026
|
export {
|
|
5713
6027
|
Accordion,
|
|
5714
6028
|
Avatar,
|
|
@@ -5768,12 +6082,38 @@ export {
|
|
|
5768
6082
|
Text,
|
|
5769
6083
|
Timeline,
|
|
5770
6084
|
Tooltip,
|
|
6085
|
+
addBusinessDays,
|
|
6086
|
+
appendCacheBuster,
|
|
6087
|
+
appendQueryParam,
|
|
6088
|
+
capitalizeFirstLetter,
|
|
5771
6089
|
colors,
|
|
6090
|
+
easterDate,
|
|
6091
|
+
formatAddress,
|
|
6092
|
+
formatCityFromFormattedAddress,
|
|
5772
6093
|
formatDate,
|
|
5773
6094
|
formatDistance,
|
|
5774
6095
|
formatDuration,
|
|
5775
6096
|
formatEuro,
|
|
6097
|
+
formatKM,
|
|
6098
|
+
formatLocality,
|
|
5776
6099
|
formatName,
|
|
6100
|
+
formatPhoneNumber,
|
|
6101
|
+
formatPlate,
|
|
6102
|
+
formatPlateWithoutDashes,
|
|
6103
|
+
formatPostalCodeFromFormattedAddress,
|
|
6104
|
+
formatRegionCode,
|
|
6105
|
+
formatTime,
|
|
6106
|
+
formatVin,
|
|
6107
|
+
generateHexColor,
|
|
6108
|
+
getAvatarColor,
|
|
6109
|
+
getCleanFileName,
|
|
6110
|
+
getFileKind,
|
|
6111
|
+
getFileNameFromUrl,
|
|
6112
|
+
getInitials2 as getInitials,
|
|
6113
|
+
getMimeCategory,
|
|
6114
|
+
getRelativeTime,
|
|
6115
|
+
isHoliday,
|
|
6116
|
+
isolateCity,
|
|
5777
6117
|
optimizeImage_default as optimizeImage,
|
|
5778
6118
|
truncateFileName,
|
|
5779
6119
|
truncateText
|