@vuu-ui/vuu-utils 0.8.14-debug → 0.8.15-debug
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/cjs/index.js +87 -31
- package/cjs/index.js.map +3 -3
- package/esm/index.js +87 -31
- package/esm/index.js.map +3 -3
- package/package.json +4 -4
- package/types/column-utils.d.ts +9 -2
- package/types/date/formatter.d.ts +2 -0
- package/types/date/helpers.d.ts +5 -0
- package/types/date/index.d.ts +2 -0
- package/types/date/types.d.ts +7 -0
- package/types/filter-utils.d.ts +2 -0
- package/types/formatting-utils.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/date-utils.d.ts +0 -7
package/esm/index.js
CHANGED
|
@@ -1071,28 +1071,77 @@ function getMovingValueDirection(newValue, direction, prevValue, decimalPlaces)
|
|
|
1071
1071
|
}
|
|
1072
1072
|
}
|
|
1073
1073
|
|
|
1074
|
-
// src/date
|
|
1075
|
-
var
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
const hh = date.getHours();
|
|
1089
|
-
const mm = date.getMinutes();
|
|
1090
|
-
const ss = date.getSeconds();
|
|
1091
|
-
return `${leadZero(hh)}:${leadZero(mm)}:${leadZero(ss)}`;
|
|
1092
|
-
} else {
|
|
1093
|
-
return date.toUTCString();
|
|
1074
|
+
// src/date/formatter.ts
|
|
1075
|
+
var baseTimeFormatOptions = {
|
|
1076
|
+
hour: "2-digit",
|
|
1077
|
+
minute: "2-digit",
|
|
1078
|
+
second: "2-digit"
|
|
1079
|
+
};
|
|
1080
|
+
var formatConfigByTimePatterns = {
|
|
1081
|
+
"hh:mm:ss": {
|
|
1082
|
+
locale: "en-GB",
|
|
1083
|
+
options: { ...baseTimeFormatOptions, hour12: false }
|
|
1084
|
+
},
|
|
1085
|
+
"hh:mm:ss a": {
|
|
1086
|
+
locale: "en-GB",
|
|
1087
|
+
options: { ...baseTimeFormatOptions, hour12: true }
|
|
1094
1088
|
}
|
|
1095
1089
|
};
|
|
1090
|
+
var baseDateFormatOptions = {
|
|
1091
|
+
day: "2-digit",
|
|
1092
|
+
month: "2-digit",
|
|
1093
|
+
year: "numeric"
|
|
1094
|
+
};
|
|
1095
|
+
var formatConfigByDatePatterns = {
|
|
1096
|
+
"dd.mm.yyyy": {
|
|
1097
|
+
locale: "en-GB",
|
|
1098
|
+
options: { ...baseDateFormatOptions },
|
|
1099
|
+
postProcessor: (s) => s.replaceAll("/", ".")
|
|
1100
|
+
},
|
|
1101
|
+
"dd/mm/yyyy": { locale: "en-GB", options: { ...baseDateFormatOptions } },
|
|
1102
|
+
"dd MMM yyyy": {
|
|
1103
|
+
locale: "en-GB",
|
|
1104
|
+
options: { ...baseDateFormatOptions, month: "short" }
|
|
1105
|
+
},
|
|
1106
|
+
"dd MMMM yyyy": {
|
|
1107
|
+
locale: "en-GB",
|
|
1108
|
+
options: { ...baseDateFormatOptions, month: "long" }
|
|
1109
|
+
},
|
|
1110
|
+
"mm/dd/yyyy": { locale: "en-US", options: { ...baseDateFormatOptions } },
|
|
1111
|
+
"MMM dd, yyyy": {
|
|
1112
|
+
locale: "en-US",
|
|
1113
|
+
options: { ...baseDateFormatOptions, month: "short" }
|
|
1114
|
+
},
|
|
1115
|
+
"MMMM dd, yyyy": {
|
|
1116
|
+
locale: "en-US",
|
|
1117
|
+
options: { ...baseDateFormatOptions, month: "long" }
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
var formatConfigByDateTimePatterns = { ...formatConfigByDatePatterns, ...formatConfigByTimePatterns };
|
|
1121
|
+
function formatDate(pattern) {
|
|
1122
|
+
const { locale, options, postProcessor } = formatConfigByDateTimePatterns[pattern];
|
|
1123
|
+
const dateTimeFormat = Intl.DateTimeFormat(locale, options);
|
|
1124
|
+
return (d) => {
|
|
1125
|
+
const dateStr = dateTimeFormat.format(d);
|
|
1126
|
+
console.log({ dateStr });
|
|
1127
|
+
return postProcessor ? postProcessor(dateStr) : dateStr;
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
// src/date/types.ts
|
|
1132
|
+
var supportedDatePatterns = [
|
|
1133
|
+
"dd.mm.yyyy",
|
|
1134
|
+
"dd/mm/yyyy",
|
|
1135
|
+
"dd MMM yyyy",
|
|
1136
|
+
"dd MMMM yyyy",
|
|
1137
|
+
"mm/dd/yyyy",
|
|
1138
|
+
"MMM dd, yyyy",
|
|
1139
|
+
"MMMM dd, yyyy"
|
|
1140
|
+
];
|
|
1141
|
+
var supportedTimePatterns = ["hh:mm:ss", "hh:mm:ss a"];
|
|
1142
|
+
var isDatePattern = (pattern) => supportedDatePatterns.includes(pattern);
|
|
1143
|
+
var isTimePattern = (pattern) => supportedTimePatterns.includes(pattern);
|
|
1144
|
+
var isDateTimePattern = (pattern) => pattern !== void 0 && (isDatePattern(pattern) || isTimePattern(pattern));
|
|
1096
1145
|
|
|
1097
1146
|
// src/logging-utils.ts
|
|
1098
1147
|
var logLevels = ["error", "warn", "info", "debug"];
|
|
@@ -1470,20 +1519,28 @@ function roundDecimal(value, align = Align.Right, decimals = 4, zeroPad, alignOn
|
|
|
1470
1519
|
return integral + (fraction ? "." + fraction : "");
|
|
1471
1520
|
}
|
|
1472
1521
|
|
|
1522
|
+
// src/date/helpers.ts
|
|
1523
|
+
var defaultPatternByTypes = { time: "hh:mm:ss", date: "dd.mm.yyyy" };
|
|
1524
|
+
function dateTimePattern(type) {
|
|
1525
|
+
if (isTypeDescriptor(type)) {
|
|
1526
|
+
if (type.formatting && isDateTimePattern(type.formatting.pattern)) {
|
|
1527
|
+
return type.formatting.pattern;
|
|
1528
|
+
}
|
|
1529
|
+
return defaultPatternByTypes[type.name];
|
|
1530
|
+
} else {
|
|
1531
|
+
return defaultPatternByTypes[type];
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1473
1535
|
// src/formatting-utils.ts
|
|
1474
1536
|
var DEFAULT_NUMERIC_FORMAT = {};
|
|
1475
1537
|
var defaultValueFormatter = (value) => value == null ? "" : typeof value === "string" ? value : value.toString();
|
|
1476
1538
|
var dateFormatter = (column) => {
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
if (isTypeDescriptor(type) && type.formatting) {
|
|
1480
|
-
if (isDateTimePattern(type.formatting.pattern)) {
|
|
1481
|
-
pattern = type.formatting.pattern;
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1539
|
+
const pattern = dateTimePattern(column.type);
|
|
1540
|
+
const formatter = formatDate(pattern);
|
|
1484
1541
|
return (value) => {
|
|
1485
1542
|
if (typeof value === "number" && value !== 0) {
|
|
1486
|
-
return
|
|
1543
|
+
return formatter(new Date(value));
|
|
1487
1544
|
} else {
|
|
1488
1545
|
return "";
|
|
1489
1546
|
}
|
|
@@ -2900,7 +2957,6 @@ export {
|
|
|
2900
2957
|
boxContainsPoint,
|
|
2901
2958
|
buildColumnMap,
|
|
2902
2959
|
createEl,
|
|
2903
|
-
dateFormatter,
|
|
2904
2960
|
debounce,
|
|
2905
2961
|
defaultValueFormatter,
|
|
2906
2962
|
deselectItem,
|
|
@@ -2910,6 +2966,7 @@ export {
|
|
|
2910
2966
|
extractFilterForColumn,
|
|
2911
2967
|
extractGroupColumn,
|
|
2912
2968
|
filterAsQuery,
|
|
2969
|
+
filterValue,
|
|
2913
2970
|
findColumn,
|
|
2914
2971
|
flattenColumnGroup,
|
|
2915
2972
|
focusFirstFocusableElement,
|
|
@@ -2962,7 +3019,6 @@ export {
|
|
|
2962
3019
|
isCompleteFilter,
|
|
2963
3020
|
isDataLoading,
|
|
2964
3021
|
isDateColumn,
|
|
2965
|
-
isDatePattern,
|
|
2966
3022
|
isDateTimeColumn,
|
|
2967
3023
|
isDateTimePattern,
|
|
2968
3024
|
isFilterClause,
|
|
@@ -2993,7 +3049,6 @@ export {
|
|
|
2993
3049
|
isSingleValueFilter,
|
|
2994
3050
|
isTextColumn,
|
|
2995
3051
|
isTimeColumn,
|
|
2996
|
-
isTimePattern,
|
|
2997
3052
|
isTypeDescriptor,
|
|
2998
3053
|
isValidColumnAlignment,
|
|
2999
3054
|
isValidFilterClauseOp,
|
|
@@ -3014,6 +3069,7 @@ export {
|
|
|
3014
3069
|
numericFormatter,
|
|
3015
3070
|
partition,
|
|
3016
3071
|
projectUpdates,
|
|
3072
|
+
quotedStrings,
|
|
3017
3073
|
rangeNewItems,
|
|
3018
3074
|
registerComponent,
|
|
3019
3075
|
registerConfigurationEditor,
|