@ascentgl/ads-ui 21.77.0 → 21.79.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.
|
@@ -7265,6 +7265,7 @@ class AdsColumnSortFilterMenuComponent {
|
|
|
7265
7265
|
allOptionKeys.every((key) => this.selectedFilterValues.includes(key));
|
|
7266
7266
|
// Get the value formatter if provided
|
|
7267
7267
|
const formatter = this.config.filterValueFormatter;
|
|
7268
|
+
const showDateOnly = this.config.showDateOnly ?? false;
|
|
7268
7269
|
const options = this.config.filterOptions.map((rawValue) => {
|
|
7269
7270
|
// Serialize raw value to stable string key for selection/persistence
|
|
7270
7271
|
const key = this.serializeOptionValue(rawValue);
|
|
@@ -7279,8 +7280,12 @@ class AdsColumnSortFilterMenuComponent {
|
|
|
7279
7280
|
}
|
|
7280
7281
|
});
|
|
7281
7282
|
this.optionSubscriptions.push(subscription);
|
|
7282
|
-
//
|
|
7283
|
-
|
|
7283
|
+
// Build the label: use formatter if provided, otherwise convert to string
|
|
7284
|
+
let label = formatter ? formatter(rawValue) : String(rawValue ?? '');
|
|
7285
|
+
// When showDateOnly is enabled, trim date-time labels to date-only
|
|
7286
|
+
if (showDateOnly && label) {
|
|
7287
|
+
label = this.trimToDateOnly(label);
|
|
7288
|
+
}
|
|
7284
7289
|
return {
|
|
7285
7290
|
value: key,
|
|
7286
7291
|
rawValue,
|
|
@@ -7309,6 +7314,26 @@ class AdsColumnSortFilterMenuComponent {
|
|
|
7309
7314
|
return String(value);
|
|
7310
7315
|
}
|
|
7311
7316
|
}
|
|
7317
|
+
/**
|
|
7318
|
+
* @ignore - Trim a date-time string to date-only.
|
|
7319
|
+
* Handles common formatted patterns like "01/09/26, 02:00 AM" or "01/09/2026 14:30".
|
|
7320
|
+
* Strips everything after the date portion (comma+time, space+time).
|
|
7321
|
+
*/
|
|
7322
|
+
trimToDateOnly(value) {
|
|
7323
|
+
// Already date-only (e.g., "01/09/2026") — no comma, no time pattern
|
|
7324
|
+
// Match patterns: "MM/DD/YY, HH:MM AM/PM" or "MM/DD/YYYY HH:MM" etc.
|
|
7325
|
+
// Strip from the comma or from the space before time digits
|
|
7326
|
+
const commaIdx = value.indexOf(',');
|
|
7327
|
+
if (commaIdx > 0) {
|
|
7328
|
+
return value.substring(0, commaIdx).trim();
|
|
7329
|
+
}
|
|
7330
|
+
// Match "date space time" pattern (e.g., "01/09/2026 14:30")
|
|
7331
|
+
const match = value.match(/^(\d{1,2}\/\d{1,2}\/\d{2,4})\s+\d/);
|
|
7332
|
+
if (match) {
|
|
7333
|
+
return match[1];
|
|
7334
|
+
}
|
|
7335
|
+
return value;
|
|
7336
|
+
}
|
|
7312
7337
|
/** @ignore */
|
|
7313
7338
|
setupSearchSubscription() {
|
|
7314
7339
|
this.searchControl.valueChanges.pipe(takeUntil$1(this.destroy$)).subscribe((value) => {
|
|
@@ -8095,10 +8120,68 @@ class AdsTableComponent {
|
|
|
8095
8120
|
}
|
|
8096
8121
|
}
|
|
8097
8122
|
// ============ Custom Sort/Filter Menu Methods ============
|
|
8098
|
-
/** @ignore - Get the
|
|
8123
|
+
/** @ignore - Get the effective filter formatter for a given column field.
|
|
8124
|
+
* When showDateOnly is true, wraps the formatter (or uses a default date formatter)
|
|
8125
|
+
* that trims the output to date-only for dedup and comparison purposes.
|
|
8126
|
+
*/
|
|
8099
8127
|
getFilterValueFormatterForField(field) {
|
|
8100
8128
|
const config = this.columnSortFilterConfigs.find(c => c.field === field);
|
|
8101
|
-
|
|
8129
|
+
if (!config)
|
|
8130
|
+
return undefined;
|
|
8131
|
+
const baseFormatter = config.filterValueFormatter;
|
|
8132
|
+
const showDateOnly = config.showDateOnly ?? false;
|
|
8133
|
+
if (!baseFormatter && !showDateOnly) {
|
|
8134
|
+
return undefined;
|
|
8135
|
+
}
|
|
8136
|
+
if (showDateOnly) {
|
|
8137
|
+
// When showDateOnly is true, use the base formatter (if any) then trim to date-only
|
|
8138
|
+
return (value) => {
|
|
8139
|
+
const formatted = baseFormatter ? baseFormatter(value) : this.formatDateDefault(value);
|
|
8140
|
+
return this.trimToDateOnly(formatted);
|
|
8141
|
+
};
|
|
8142
|
+
}
|
|
8143
|
+
return baseFormatter;
|
|
8144
|
+
}
|
|
8145
|
+
/**
|
|
8146
|
+
* @ignore - Default date formatter for showDateOnly when no filterValueFormatter is provided.
|
|
8147
|
+
* Formats an ISO date-time string to the locale date string.
|
|
8148
|
+
*/
|
|
8149
|
+
formatDateDefault(value) {
|
|
8150
|
+
if (value === null || value === undefined)
|
|
8151
|
+
return '';
|
|
8152
|
+
const str = String(value);
|
|
8153
|
+
try {
|
|
8154
|
+
const date = new Date(str);
|
|
8155
|
+
if (isNaN(date.getTime()))
|
|
8156
|
+
return str;
|
|
8157
|
+
return date.toLocaleDateString('en-US', {
|
|
8158
|
+
month: '2-digit',
|
|
8159
|
+
day: '2-digit',
|
|
8160
|
+
year: 'numeric',
|
|
8161
|
+
});
|
|
8162
|
+
}
|
|
8163
|
+
catch {
|
|
8164
|
+
return str;
|
|
8165
|
+
}
|
|
8166
|
+
}
|
|
8167
|
+
/**
|
|
8168
|
+
* @ignore - Trim a date-time string to date-only.
|
|
8169
|
+
* Strips time portion from common formatted date-time patterns.
|
|
8170
|
+
*/
|
|
8171
|
+
trimToDateOnly(value) {
|
|
8172
|
+
if (!value)
|
|
8173
|
+
return value;
|
|
8174
|
+
// "MM/DD/YY, HH:MM AM/PM" — strip from comma
|
|
8175
|
+
const commaIdx = value.indexOf(',');
|
|
8176
|
+
if (commaIdx > 0) {
|
|
8177
|
+
return value.substring(0, commaIdx).trim();
|
|
8178
|
+
}
|
|
8179
|
+
// "MM/DD/YYYY HH:MM" — strip from space before time digits
|
|
8180
|
+
const match = value.match(/^(\d{1,2}\/\d{1,2}\/\d{2,4})\s+\d/);
|
|
8181
|
+
if (match) {
|
|
8182
|
+
return match[1];
|
|
8183
|
+
}
|
|
8184
|
+
return value;
|
|
8102
8185
|
}
|
|
8103
8186
|
/**
|
|
8104
8187
|
* @ignore - Serialize a cell value for filter key purposes.
|