@ai-matrx/design-system 0.26.0 → 0.28.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.
- package/CHANGELOG.md +39 -0
- package/dist/data-table/copy-helpers.cjs.map +1 -1
- package/dist/data-table/copy-helpers.d.cts +2 -1
- package/dist/data-table/copy-helpers.d.ts +2 -1
- package/dist/data-table/copy-helpers.js.map +1 -1
- package/dist/data-table/data-row-inspector.cjs.map +1 -1
- package/dist/data-table/data-row-inspector.js.map +1 -1
- package/dist/data-table/data-row-window.cjs.map +1 -1
- package/dist/data-table/data-row-window.js.map +1 -1
- package/dist/data-table/date-filter.cjs +145 -0
- package/dist/data-table/date-filter.cjs.map +1 -0
- package/dist/data-table/date-filter.d.cts +31 -0
- package/dist/data-table/date-filter.d.ts +31 -0
- package/dist/data-table/date-filter.js +125 -0
- package/dist/data-table/date-filter.js.map +1 -0
- package/dist/data-table/filter-engine.cjs +88 -0
- package/dist/data-table/filter-engine.cjs.map +1 -1
- package/dist/data-table/filter-engine.d.cts +2 -1
- package/dist/data-table/filter-engine.d.ts +2 -1
- package/dist/data-table/filter-engine.js +88 -0
- package/dist/data-table/filter-engine.js.map +1 -1
- package/dist/data-table/host.d.cts +2 -1
- package/dist/data-table/host.d.ts +2 -1
- package/dist/data-table/index.cjs +238 -7
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.d.cts +3 -2
- package/dist/data-table/index.d.ts +3 -2
- package/dist/data-table/index.js +238 -7
- package/dist/data-table/index.js.map +1 -1
- package/dist/data-table/infer-filter.cjs +2 -0
- package/dist/data-table/infer-filter.cjs.map +1 -1
- package/dist/data-table/infer-filter.d.cts +3 -2
- package/dist/data-table/infer-filter.d.ts +3 -2
- package/dist/data-table/infer-filter.js +2 -0
- package/dist/data-table/infer-filter.js.map +1 -1
- package/dist/data-table/layered-filters.d.cts +2 -1
- package/dist/data-table/layered-filters.d.ts +2 -1
- package/dist/data-table/query-control.cjs.map +1 -1
- package/dist/data-table/query-control.d.cts +2 -1
- package/dist/data-table/query-control.d.ts +2 -1
- package/dist/data-table/query-control.js.map +1 -1
- package/dist/data-table/types.cjs.map +1 -1
- package/dist/data-table/types.d.cts +2 -1
- package/dist/data-table/types.d.ts +2 -1
- package/dist/data-table/url-state.d.cts +2 -1
- package/dist/data-table/url-state.d.ts +2 -1
- package/dist/data-table/xlsx.cjs.map +1 -1
- package/dist/data-table/xlsx.d.cts +2 -1
- package/dist/data-table/xlsx.d.ts +2 -1
- package/dist/data-table/xlsx.js.map +1 -1
- package/dist/field-formats/index.cjs +15 -0
- package/dist/field-formats/index.cjs.map +1 -1
- package/dist/field-formats/index.js +15 -0
- package/dist/field-formats/index.js.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/{types-Cu5_eUG1.d.ts → types-D9JBR6ZU.d.ts} +3 -2
- package/dist/{types-DrJXAAoD.d.cts → types-jQddSUnj.d.cts} +3 -2
- package/package.json +11 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/data-table/date-filter.ts
|
|
22
|
+
var date_filter_exports = {};
|
|
23
|
+
__export(date_filter_exports, {
|
|
24
|
+
TIME_RANGE_PRESETS: () => TIME_RANGE_PRESETS,
|
|
25
|
+
TIME_RANGE_PRESET_VALUES: () => TIME_RANGE_PRESET_VALUES,
|
|
26
|
+
dateFilterBounds: () => dateFilterBounds
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(date_filter_exports);
|
|
29
|
+
var TIME_RANGE_PRESET_VALUES = [
|
|
30
|
+
"all",
|
|
31
|
+
"1m",
|
|
32
|
+
"15m",
|
|
33
|
+
"30m",
|
|
34
|
+
"1h",
|
|
35
|
+
"2h",
|
|
36
|
+
"6h",
|
|
37
|
+
"12h",
|
|
38
|
+
"today",
|
|
39
|
+
"yesterday",
|
|
40
|
+
"this_week",
|
|
41
|
+
"this_month",
|
|
42
|
+
"this_year",
|
|
43
|
+
"older_1m",
|
|
44
|
+
"older_15m",
|
|
45
|
+
"older_30m",
|
|
46
|
+
"older_1h",
|
|
47
|
+
"older_2h",
|
|
48
|
+
"older_6h",
|
|
49
|
+
"older_12h",
|
|
50
|
+
"older_today",
|
|
51
|
+
"older_this_week",
|
|
52
|
+
"older_this_month",
|
|
53
|
+
"older_this_year"
|
|
54
|
+
];
|
|
55
|
+
var TIME_RANGE_PRESETS = [
|
|
56
|
+
{ value: "all", label: "All time", group: "all" },
|
|
57
|
+
{ value: "1m", label: "Last minute", group: "recent" },
|
|
58
|
+
{ value: "15m", label: "Last 15 minutes", group: "recent" },
|
|
59
|
+
{ value: "30m", label: "Last 30 minutes", group: "recent" },
|
|
60
|
+
{ value: "1h", label: "Last hour", group: "recent" },
|
|
61
|
+
{ value: "2h", label: "Last 2 hours", group: "recent" },
|
|
62
|
+
{ value: "6h", label: "Last 6 hours", group: "recent" },
|
|
63
|
+
{ value: "12h", label: "Last 12 hours", group: "recent" },
|
|
64
|
+
{ value: "today", label: "Today", group: "calendar" },
|
|
65
|
+
{ value: "yesterday", label: "Yesterday", group: "calendar" },
|
|
66
|
+
{ value: "this_week", label: "This week", group: "calendar" },
|
|
67
|
+
{ value: "this_month", label: "This month", group: "calendar" },
|
|
68
|
+
{ value: "this_year", label: "This year", group: "calendar" },
|
|
69
|
+
{ value: "older_1m", label: "Older than 1 minute", group: "older" },
|
|
70
|
+
{ value: "older_15m", label: "Older than 15 minutes", group: "older" },
|
|
71
|
+
{ value: "older_30m", label: "Older than 30 minutes", group: "older" },
|
|
72
|
+
{ value: "older_1h", label: "Older than 1 hour", group: "older" },
|
|
73
|
+
{ value: "older_2h", label: "Older than 2 hours", group: "older" },
|
|
74
|
+
{ value: "older_6h", label: "Older than 6 hours", group: "older" },
|
|
75
|
+
{ value: "older_12h", label: "Older than 12 hours", group: "older" },
|
|
76
|
+
{ value: "older_today", label: "Before today", group: "older" },
|
|
77
|
+
{ value: "older_this_week", label: "Before this week", group: "older" },
|
|
78
|
+
{ value: "older_this_month", label: "Before this month", group: "older" },
|
|
79
|
+
{ value: "older_this_year", label: "Before this year", group: "older" }
|
|
80
|
+
];
|
|
81
|
+
function startOfDay(date) {
|
|
82
|
+
const next = new Date(date);
|
|
83
|
+
next.setHours(0, 0, 0, 0);
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
function startOfWeek(date) {
|
|
87
|
+
const next = startOfDay(date);
|
|
88
|
+
next.setDate(next.getDate() - (next.getDay() === 0 ? 6 : next.getDay() - 1));
|
|
89
|
+
return next;
|
|
90
|
+
}
|
|
91
|
+
function startOfMonth(date) {
|
|
92
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
93
|
+
}
|
|
94
|
+
function startOfYear(date) {
|
|
95
|
+
return new Date(date.getFullYear(), 0, 1);
|
|
96
|
+
}
|
|
97
|
+
function validDate(value) {
|
|
98
|
+
if (value === void 0) return void 0;
|
|
99
|
+
const date = value instanceof Date ? new Date(value) : new Date(value);
|
|
100
|
+
return Number.isNaN(date.valueOf()) ? void 0 : date;
|
|
101
|
+
}
|
|
102
|
+
function dateFilterBounds(filter, now = /* @__PURE__ */ new Date()) {
|
|
103
|
+
if (!filter.preset) {
|
|
104
|
+
return {
|
|
105
|
+
...filter.since === void 0 ? {} : { since: filter.since },
|
|
106
|
+
...filter.until === void 0 ? {} : { until: filter.until }
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (filter.preset === "all") return {};
|
|
110
|
+
const anchor = validDate(filter.anchor) ?? validDate(now) ?? /* @__PURE__ */ new Date();
|
|
111
|
+
const ago = (milliseconds) => new Date(anchor.valueOf() - milliseconds).toISOString();
|
|
112
|
+
const recent = {
|
|
113
|
+
"1m": 6e4,
|
|
114
|
+
"15m": 15 * 6e4,
|
|
115
|
+
"30m": 30 * 6e4,
|
|
116
|
+
"1h": 60 * 6e4,
|
|
117
|
+
"2h": 2 * 60 * 6e4,
|
|
118
|
+
"6h": 6 * 60 * 6e4,
|
|
119
|
+
"12h": 12 * 60 * 6e4
|
|
120
|
+
};
|
|
121
|
+
const duration = recent[filter.preset.replace("older_", "")];
|
|
122
|
+
if (duration !== void 0) {
|
|
123
|
+
return filter.preset.startsWith("older_") ? { until: ago(duration) } : { since: ago(duration) };
|
|
124
|
+
}
|
|
125
|
+
const starts = {
|
|
126
|
+
today: startOfDay(anchor),
|
|
127
|
+
this_week: startOfWeek(anchor),
|
|
128
|
+
this_month: startOfMonth(anchor),
|
|
129
|
+
this_year: startOfYear(anchor),
|
|
130
|
+
older_today: startOfDay(anchor),
|
|
131
|
+
older_this_week: startOfWeek(anchor),
|
|
132
|
+
older_this_month: startOfMonth(anchor),
|
|
133
|
+
older_this_year: startOfYear(anchor)
|
|
134
|
+
};
|
|
135
|
+
if (filter.preset === "yesterday") {
|
|
136
|
+
const until = startOfDay(anchor);
|
|
137
|
+
const since = new Date(until);
|
|
138
|
+
since.setDate(since.getDate() - 1);
|
|
139
|
+
return { since: since.toISOString(), until: until.toISOString() };
|
|
140
|
+
}
|
|
141
|
+
const start = starts[filter.preset];
|
|
142
|
+
if (!start) return {};
|
|
143
|
+
return filter.preset.startsWith("older_") ? { until: start.toISOString() } : { since: start.toISOString() };
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=date-filter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data-table/date-filter.ts"],"sourcesContent":["/** Relative time ranges shared by every canonical table date column. */\nexport const TIME_RANGE_PRESET_VALUES = [\n \"all\", \"1m\", \"15m\", \"30m\", \"1h\", \"2h\", \"6h\", \"12h\",\n \"today\", \"yesterday\", \"this_week\", \"this_month\", \"this_year\",\n \"older_1m\", \"older_15m\", \"older_30m\", \"older_1h\", \"older_2h\", \"older_6h\", \"older_12h\",\n \"older_today\", \"older_this_week\", \"older_this_month\", \"older_this_year\",\n] as const;\n\nexport type TimeRangePreset = (typeof TIME_RANGE_PRESET_VALUES)[number];\n\nexport interface TimeRangePresetOption {\n value: TimeRangePreset;\n label: string;\n group: \"all\" | \"recent\" | \"older\" | \"calendar\";\n}\n\n/** A contiguous range: `since` is inclusive and `until` is exclusive. */\nexport interface DateFilterBounds {\n since?: string;\n until?: string;\n}\n\nexport interface DateColumnFilterValue extends DateFilterBounds {\n kind: \"date\";\n /** Date ranges are contiguous only; complement queries need a source contract first. */\n negated?: never;\n /** A relative range. Omit for explicit custom bounds. */\n preset?: TimeRangePreset;\n /** ISO instant captured when a relative preset was chosen. */\n anchor?: string;\n}\n\nexport const TIME_RANGE_PRESETS: readonly TimeRangePresetOption[] = [\n { value: \"all\", label: \"All time\", group: \"all\" },\n { value: \"1m\", label: \"Last minute\", group: \"recent\" },\n { value: \"15m\", label: \"Last 15 minutes\", group: \"recent\" },\n { value: \"30m\", label: \"Last 30 minutes\", group: \"recent\" },\n { value: \"1h\", label: \"Last hour\", group: \"recent\" },\n { value: \"2h\", label: \"Last 2 hours\", group: \"recent\" },\n { value: \"6h\", label: \"Last 6 hours\", group: \"recent\" },\n { value: \"12h\", label: \"Last 12 hours\", group: \"recent\" },\n { value: \"today\", label: \"Today\", group: \"calendar\" },\n { value: \"yesterday\", label: \"Yesterday\", group: \"calendar\" },\n { value: \"this_week\", label: \"This week\", group: \"calendar\" },\n { value: \"this_month\", label: \"This month\", group: \"calendar\" },\n { value: \"this_year\", label: \"This year\", group: \"calendar\" },\n { value: \"older_1m\", label: \"Older than 1 minute\", group: \"older\" },\n { value: \"older_15m\", label: \"Older than 15 minutes\", group: \"older\" },\n { value: \"older_30m\", label: \"Older than 30 minutes\", group: \"older\" },\n { value: \"older_1h\", label: \"Older than 1 hour\", group: \"older\" },\n { value: \"older_2h\", label: \"Older than 2 hours\", group: \"older\" },\n { value: \"older_6h\", label: \"Older than 6 hours\", group: \"older\" },\n { value: \"older_12h\", label: \"Older than 12 hours\", group: \"older\" },\n { value: \"older_today\", label: \"Before today\", group: \"older\" },\n { value: \"older_this_week\", label: \"Before this week\", group: \"older\" },\n { value: \"older_this_month\", label: \"Before this month\", group: \"older\" },\n { value: \"older_this_year\", label: \"Before this year\", group: \"older\" },\n];\n\nfunction startOfDay(date: Date): Date {\n const next = new Date(date);\n next.setHours(0, 0, 0, 0);\n return next;\n}\n\nfunction startOfWeek(date: Date): Date {\n const next = startOfDay(date);\n next.setDate(next.getDate() - (next.getDay() === 0 ? 6 : next.getDay() - 1));\n return next;\n}\n\nfunction startOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n}\n\nfunction startOfYear(date: Date): Date {\n return new Date(date.getFullYear(), 0, 1);\n}\n\nfunction validDate(value: Date | string | undefined): Date | undefined {\n if (value === undefined) return undefined;\n const date = value instanceof Date ? new Date(value) : new Date(value);\n return Number.isNaN(date.valueOf()) ? undefined : date;\n}\n\n/**\n * Resolve a date filter without reading the clock implicitly. Relative presets\n * use their captured `anchor`; callers may provide `now` only for legacy or\n * programmatic values without one. `until` remains exclusive throughout.\n */\nexport function dateFilterBounds(\n filter: DateColumnFilterValue,\n now: Date | string = new Date(),\n): DateFilterBounds {\n if (!filter.preset) {\n return {\n ...(filter.since === undefined ? {} : { since: filter.since }),\n ...(filter.until === undefined ? {} : { until: filter.until }),\n };\n }\n if (filter.preset === \"all\") return {};\n\n const anchor = validDate(filter.anchor) ?? validDate(now) ?? new Date();\n const ago = (milliseconds: number) =>\n new Date(anchor.valueOf() - milliseconds).toISOString();\n const recent: Partial<Record<TimeRangePreset, number>> = {\n \"1m\": 60_000,\n \"15m\": 15 * 60_000,\n \"30m\": 30 * 60_000,\n \"1h\": 60 * 60_000,\n \"2h\": 2 * 60 * 60_000,\n \"6h\": 6 * 60 * 60_000,\n \"12h\": 12 * 60 * 60_000,\n };\n const duration = recent[filter.preset.replace(\"older_\", \"\") as TimeRangePreset];\n if (duration !== undefined) {\n return filter.preset.startsWith(\"older_\") ? { until: ago(duration) } : { since: ago(duration) };\n }\n\n const starts: Partial<Record<TimeRangePreset, Date>> = {\n today: startOfDay(anchor),\n this_week: startOfWeek(anchor),\n this_month: startOfMonth(anchor),\n this_year: startOfYear(anchor),\n older_today: startOfDay(anchor),\n older_this_week: startOfWeek(anchor),\n older_this_month: startOfMonth(anchor),\n older_this_year: startOfYear(anchor),\n };\n if (filter.preset === \"yesterday\") {\n const until = startOfDay(anchor);\n const since = new Date(until);\n since.setDate(since.getDate() - 1);\n return { since: since.toISOString(), until: until.toISOString() };\n }\n const start = starts[filter.preset];\n if (!start) return {};\n return filter.preset.startsWith(\"older_\")\n ? { until: start.toISOString() }\n : { since: start.toISOString() };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EAAO;AAAA,EAAM;AAAA,EAAO;AAAA,EAAO;AAAA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,OAAO,MAAM;AAClC,MAAI,CAAC,MAAO,QAAO,CAAC;AACpB,SAAO,OAAO,OAAO,WAAW,QAAQ,IACpC,EAAE,OAAO,MAAM,YAAY,EAAE,IAC7B,EAAE,OAAO,MAAM,YAAY,EAAE;AACnC;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Relative time ranges shared by every canonical table date column. */
|
|
2
|
+
declare const TIME_RANGE_PRESET_VALUES: readonly ["all", "1m", "15m", "30m", "1h", "2h", "6h", "12h", "today", "yesterday", "this_week", "this_month", "this_year", "older_1m", "older_15m", "older_30m", "older_1h", "older_2h", "older_6h", "older_12h", "older_today", "older_this_week", "older_this_month", "older_this_year"];
|
|
3
|
+
type TimeRangePreset = (typeof TIME_RANGE_PRESET_VALUES)[number];
|
|
4
|
+
interface TimeRangePresetOption {
|
|
5
|
+
value: TimeRangePreset;
|
|
6
|
+
label: string;
|
|
7
|
+
group: "all" | "recent" | "older" | "calendar";
|
|
8
|
+
}
|
|
9
|
+
/** A contiguous range: `since` is inclusive and `until` is exclusive. */
|
|
10
|
+
interface DateFilterBounds {
|
|
11
|
+
since?: string;
|
|
12
|
+
until?: string;
|
|
13
|
+
}
|
|
14
|
+
interface DateColumnFilterValue extends DateFilterBounds {
|
|
15
|
+
kind: "date";
|
|
16
|
+
/** Date ranges are contiguous only; complement queries need a source contract first. */
|
|
17
|
+
negated?: never;
|
|
18
|
+
/** A relative range. Omit for explicit custom bounds. */
|
|
19
|
+
preset?: TimeRangePreset;
|
|
20
|
+
/** ISO instant captured when a relative preset was chosen. */
|
|
21
|
+
anchor?: string;
|
|
22
|
+
}
|
|
23
|
+
declare const TIME_RANGE_PRESETS: readonly TimeRangePresetOption[];
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a date filter without reading the clock implicitly. Relative presets
|
|
26
|
+
* use their captured `anchor`; callers may provide `now` only for legacy or
|
|
27
|
+
* programmatic values without one. `until` remains exclusive throughout.
|
|
28
|
+
*/
|
|
29
|
+
declare function dateFilterBounds(filter: DateColumnFilterValue, now?: Date | string): DateFilterBounds;
|
|
30
|
+
|
|
31
|
+
export { type DateColumnFilterValue, type DateFilterBounds, TIME_RANGE_PRESETS, TIME_RANGE_PRESET_VALUES, type TimeRangePreset, type TimeRangePresetOption, dateFilterBounds };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Relative time ranges shared by every canonical table date column. */
|
|
2
|
+
declare const TIME_RANGE_PRESET_VALUES: readonly ["all", "1m", "15m", "30m", "1h", "2h", "6h", "12h", "today", "yesterday", "this_week", "this_month", "this_year", "older_1m", "older_15m", "older_30m", "older_1h", "older_2h", "older_6h", "older_12h", "older_today", "older_this_week", "older_this_month", "older_this_year"];
|
|
3
|
+
type TimeRangePreset = (typeof TIME_RANGE_PRESET_VALUES)[number];
|
|
4
|
+
interface TimeRangePresetOption {
|
|
5
|
+
value: TimeRangePreset;
|
|
6
|
+
label: string;
|
|
7
|
+
group: "all" | "recent" | "older" | "calendar";
|
|
8
|
+
}
|
|
9
|
+
/** A contiguous range: `since` is inclusive and `until` is exclusive. */
|
|
10
|
+
interface DateFilterBounds {
|
|
11
|
+
since?: string;
|
|
12
|
+
until?: string;
|
|
13
|
+
}
|
|
14
|
+
interface DateColumnFilterValue extends DateFilterBounds {
|
|
15
|
+
kind: "date";
|
|
16
|
+
/** Date ranges are contiguous only; complement queries need a source contract first. */
|
|
17
|
+
negated?: never;
|
|
18
|
+
/** A relative range. Omit for explicit custom bounds. */
|
|
19
|
+
preset?: TimeRangePreset;
|
|
20
|
+
/** ISO instant captured when a relative preset was chosen. */
|
|
21
|
+
anchor?: string;
|
|
22
|
+
}
|
|
23
|
+
declare const TIME_RANGE_PRESETS: readonly TimeRangePresetOption[];
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a date filter without reading the clock implicitly. Relative presets
|
|
26
|
+
* use their captured `anchor`; callers may provide `now` only for legacy or
|
|
27
|
+
* programmatic values without one. `until` remains exclusive throughout.
|
|
28
|
+
*/
|
|
29
|
+
declare function dateFilterBounds(filter: DateColumnFilterValue, now?: Date | string): DateFilterBounds;
|
|
30
|
+
|
|
31
|
+
export { type DateColumnFilterValue, type DateFilterBounds, TIME_RANGE_PRESETS, TIME_RANGE_PRESET_VALUES, type TimeRangePreset, type TimeRangePresetOption, dateFilterBounds };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/data-table/date-filter.ts
|
|
4
|
+
var TIME_RANGE_PRESET_VALUES = [
|
|
5
|
+
"all",
|
|
6
|
+
"1m",
|
|
7
|
+
"15m",
|
|
8
|
+
"30m",
|
|
9
|
+
"1h",
|
|
10
|
+
"2h",
|
|
11
|
+
"6h",
|
|
12
|
+
"12h",
|
|
13
|
+
"today",
|
|
14
|
+
"yesterday",
|
|
15
|
+
"this_week",
|
|
16
|
+
"this_month",
|
|
17
|
+
"this_year",
|
|
18
|
+
"older_1m",
|
|
19
|
+
"older_15m",
|
|
20
|
+
"older_30m",
|
|
21
|
+
"older_1h",
|
|
22
|
+
"older_2h",
|
|
23
|
+
"older_6h",
|
|
24
|
+
"older_12h",
|
|
25
|
+
"older_today",
|
|
26
|
+
"older_this_week",
|
|
27
|
+
"older_this_month",
|
|
28
|
+
"older_this_year"
|
|
29
|
+
];
|
|
30
|
+
var TIME_RANGE_PRESETS = [
|
|
31
|
+
{ value: "all", label: "All time", group: "all" },
|
|
32
|
+
{ value: "1m", label: "Last minute", group: "recent" },
|
|
33
|
+
{ value: "15m", label: "Last 15 minutes", group: "recent" },
|
|
34
|
+
{ value: "30m", label: "Last 30 minutes", group: "recent" },
|
|
35
|
+
{ value: "1h", label: "Last hour", group: "recent" },
|
|
36
|
+
{ value: "2h", label: "Last 2 hours", group: "recent" },
|
|
37
|
+
{ value: "6h", label: "Last 6 hours", group: "recent" },
|
|
38
|
+
{ value: "12h", label: "Last 12 hours", group: "recent" },
|
|
39
|
+
{ value: "today", label: "Today", group: "calendar" },
|
|
40
|
+
{ value: "yesterday", label: "Yesterday", group: "calendar" },
|
|
41
|
+
{ value: "this_week", label: "This week", group: "calendar" },
|
|
42
|
+
{ value: "this_month", label: "This month", group: "calendar" },
|
|
43
|
+
{ value: "this_year", label: "This year", group: "calendar" },
|
|
44
|
+
{ value: "older_1m", label: "Older than 1 minute", group: "older" },
|
|
45
|
+
{ value: "older_15m", label: "Older than 15 minutes", group: "older" },
|
|
46
|
+
{ value: "older_30m", label: "Older than 30 minutes", group: "older" },
|
|
47
|
+
{ value: "older_1h", label: "Older than 1 hour", group: "older" },
|
|
48
|
+
{ value: "older_2h", label: "Older than 2 hours", group: "older" },
|
|
49
|
+
{ value: "older_6h", label: "Older than 6 hours", group: "older" },
|
|
50
|
+
{ value: "older_12h", label: "Older than 12 hours", group: "older" },
|
|
51
|
+
{ value: "older_today", label: "Before today", group: "older" },
|
|
52
|
+
{ value: "older_this_week", label: "Before this week", group: "older" },
|
|
53
|
+
{ value: "older_this_month", label: "Before this month", group: "older" },
|
|
54
|
+
{ value: "older_this_year", label: "Before this year", group: "older" }
|
|
55
|
+
];
|
|
56
|
+
function startOfDay(date) {
|
|
57
|
+
const next = new Date(date);
|
|
58
|
+
next.setHours(0, 0, 0, 0);
|
|
59
|
+
return next;
|
|
60
|
+
}
|
|
61
|
+
function startOfWeek(date) {
|
|
62
|
+
const next = startOfDay(date);
|
|
63
|
+
next.setDate(next.getDate() - (next.getDay() === 0 ? 6 : next.getDay() - 1));
|
|
64
|
+
return next;
|
|
65
|
+
}
|
|
66
|
+
function startOfMonth(date) {
|
|
67
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
68
|
+
}
|
|
69
|
+
function startOfYear(date) {
|
|
70
|
+
return new Date(date.getFullYear(), 0, 1);
|
|
71
|
+
}
|
|
72
|
+
function validDate(value) {
|
|
73
|
+
if (value === void 0) return void 0;
|
|
74
|
+
const date = value instanceof Date ? new Date(value) : new Date(value);
|
|
75
|
+
return Number.isNaN(date.valueOf()) ? void 0 : date;
|
|
76
|
+
}
|
|
77
|
+
function dateFilterBounds(filter, now = /* @__PURE__ */ new Date()) {
|
|
78
|
+
if (!filter.preset) {
|
|
79
|
+
return {
|
|
80
|
+
...filter.since === void 0 ? {} : { since: filter.since },
|
|
81
|
+
...filter.until === void 0 ? {} : { until: filter.until }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (filter.preset === "all") return {};
|
|
85
|
+
const anchor = validDate(filter.anchor) ?? validDate(now) ?? /* @__PURE__ */ new Date();
|
|
86
|
+
const ago = (milliseconds) => new Date(anchor.valueOf() - milliseconds).toISOString();
|
|
87
|
+
const recent = {
|
|
88
|
+
"1m": 6e4,
|
|
89
|
+
"15m": 15 * 6e4,
|
|
90
|
+
"30m": 30 * 6e4,
|
|
91
|
+
"1h": 60 * 6e4,
|
|
92
|
+
"2h": 2 * 60 * 6e4,
|
|
93
|
+
"6h": 6 * 60 * 6e4,
|
|
94
|
+
"12h": 12 * 60 * 6e4
|
|
95
|
+
};
|
|
96
|
+
const duration = recent[filter.preset.replace("older_", "")];
|
|
97
|
+
if (duration !== void 0) {
|
|
98
|
+
return filter.preset.startsWith("older_") ? { until: ago(duration) } : { since: ago(duration) };
|
|
99
|
+
}
|
|
100
|
+
const starts = {
|
|
101
|
+
today: startOfDay(anchor),
|
|
102
|
+
this_week: startOfWeek(anchor),
|
|
103
|
+
this_month: startOfMonth(anchor),
|
|
104
|
+
this_year: startOfYear(anchor),
|
|
105
|
+
older_today: startOfDay(anchor),
|
|
106
|
+
older_this_week: startOfWeek(anchor),
|
|
107
|
+
older_this_month: startOfMonth(anchor),
|
|
108
|
+
older_this_year: startOfYear(anchor)
|
|
109
|
+
};
|
|
110
|
+
if (filter.preset === "yesterday") {
|
|
111
|
+
const until = startOfDay(anchor);
|
|
112
|
+
const since = new Date(until);
|
|
113
|
+
since.setDate(since.getDate() - 1);
|
|
114
|
+
return { since: since.toISOString(), until: until.toISOString() };
|
|
115
|
+
}
|
|
116
|
+
const start = starts[filter.preset];
|
|
117
|
+
if (!start) return {};
|
|
118
|
+
return filter.preset.startsWith("older_") ? { until: start.toISOString() } : { since: start.toISOString() };
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
TIME_RANGE_PRESETS,
|
|
122
|
+
TIME_RANGE_PRESET_VALUES,
|
|
123
|
+
dateFilterBounds
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=date-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data-table/date-filter.ts"],"sourcesContent":["/** Relative time ranges shared by every canonical table date column. */\nexport const TIME_RANGE_PRESET_VALUES = [\n \"all\", \"1m\", \"15m\", \"30m\", \"1h\", \"2h\", \"6h\", \"12h\",\n \"today\", \"yesterday\", \"this_week\", \"this_month\", \"this_year\",\n \"older_1m\", \"older_15m\", \"older_30m\", \"older_1h\", \"older_2h\", \"older_6h\", \"older_12h\",\n \"older_today\", \"older_this_week\", \"older_this_month\", \"older_this_year\",\n] as const;\n\nexport type TimeRangePreset = (typeof TIME_RANGE_PRESET_VALUES)[number];\n\nexport interface TimeRangePresetOption {\n value: TimeRangePreset;\n label: string;\n group: \"all\" | \"recent\" | \"older\" | \"calendar\";\n}\n\n/** A contiguous range: `since` is inclusive and `until` is exclusive. */\nexport interface DateFilterBounds {\n since?: string;\n until?: string;\n}\n\nexport interface DateColumnFilterValue extends DateFilterBounds {\n kind: \"date\";\n /** Date ranges are contiguous only; complement queries need a source contract first. */\n negated?: never;\n /** A relative range. Omit for explicit custom bounds. */\n preset?: TimeRangePreset;\n /** ISO instant captured when a relative preset was chosen. */\n anchor?: string;\n}\n\nexport const TIME_RANGE_PRESETS: readonly TimeRangePresetOption[] = [\n { value: \"all\", label: \"All time\", group: \"all\" },\n { value: \"1m\", label: \"Last minute\", group: \"recent\" },\n { value: \"15m\", label: \"Last 15 minutes\", group: \"recent\" },\n { value: \"30m\", label: \"Last 30 minutes\", group: \"recent\" },\n { value: \"1h\", label: \"Last hour\", group: \"recent\" },\n { value: \"2h\", label: \"Last 2 hours\", group: \"recent\" },\n { value: \"6h\", label: \"Last 6 hours\", group: \"recent\" },\n { value: \"12h\", label: \"Last 12 hours\", group: \"recent\" },\n { value: \"today\", label: \"Today\", group: \"calendar\" },\n { value: \"yesterday\", label: \"Yesterday\", group: \"calendar\" },\n { value: \"this_week\", label: \"This week\", group: \"calendar\" },\n { value: \"this_month\", label: \"This month\", group: \"calendar\" },\n { value: \"this_year\", label: \"This year\", group: \"calendar\" },\n { value: \"older_1m\", label: \"Older than 1 minute\", group: \"older\" },\n { value: \"older_15m\", label: \"Older than 15 minutes\", group: \"older\" },\n { value: \"older_30m\", label: \"Older than 30 minutes\", group: \"older\" },\n { value: \"older_1h\", label: \"Older than 1 hour\", group: \"older\" },\n { value: \"older_2h\", label: \"Older than 2 hours\", group: \"older\" },\n { value: \"older_6h\", label: \"Older than 6 hours\", group: \"older\" },\n { value: \"older_12h\", label: \"Older than 12 hours\", group: \"older\" },\n { value: \"older_today\", label: \"Before today\", group: \"older\" },\n { value: \"older_this_week\", label: \"Before this week\", group: \"older\" },\n { value: \"older_this_month\", label: \"Before this month\", group: \"older\" },\n { value: \"older_this_year\", label: \"Before this year\", group: \"older\" },\n];\n\nfunction startOfDay(date: Date): Date {\n const next = new Date(date);\n next.setHours(0, 0, 0, 0);\n return next;\n}\n\nfunction startOfWeek(date: Date): Date {\n const next = startOfDay(date);\n next.setDate(next.getDate() - (next.getDay() === 0 ? 6 : next.getDay() - 1));\n return next;\n}\n\nfunction startOfMonth(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n}\n\nfunction startOfYear(date: Date): Date {\n return new Date(date.getFullYear(), 0, 1);\n}\n\nfunction validDate(value: Date | string | undefined): Date | undefined {\n if (value === undefined) return undefined;\n const date = value instanceof Date ? new Date(value) : new Date(value);\n return Number.isNaN(date.valueOf()) ? undefined : date;\n}\n\n/**\n * Resolve a date filter without reading the clock implicitly. Relative presets\n * use their captured `anchor`; callers may provide `now` only for legacy or\n * programmatic values without one. `until` remains exclusive throughout.\n */\nexport function dateFilterBounds(\n filter: DateColumnFilterValue,\n now: Date | string = new Date(),\n): DateFilterBounds {\n if (!filter.preset) {\n return {\n ...(filter.since === undefined ? {} : { since: filter.since }),\n ...(filter.until === undefined ? {} : { until: filter.until }),\n };\n }\n if (filter.preset === \"all\") return {};\n\n const anchor = validDate(filter.anchor) ?? validDate(now) ?? new Date();\n const ago = (milliseconds: number) =>\n new Date(anchor.valueOf() - milliseconds).toISOString();\n const recent: Partial<Record<TimeRangePreset, number>> = {\n \"1m\": 60_000,\n \"15m\": 15 * 60_000,\n \"30m\": 30 * 60_000,\n \"1h\": 60 * 60_000,\n \"2h\": 2 * 60 * 60_000,\n \"6h\": 6 * 60 * 60_000,\n \"12h\": 12 * 60 * 60_000,\n };\n const duration = recent[filter.preset.replace(\"older_\", \"\") as TimeRangePreset];\n if (duration !== undefined) {\n return filter.preset.startsWith(\"older_\") ? { until: ago(duration) } : { since: ago(duration) };\n }\n\n const starts: Partial<Record<TimeRangePreset, Date>> = {\n today: startOfDay(anchor),\n this_week: startOfWeek(anchor),\n this_month: startOfMonth(anchor),\n this_year: startOfYear(anchor),\n older_today: startOfDay(anchor),\n older_this_week: startOfWeek(anchor),\n older_this_month: startOfMonth(anchor),\n older_this_year: startOfYear(anchor),\n };\n if (filter.preset === \"yesterday\") {\n const until = startOfDay(anchor);\n const since = new Date(until);\n since.setDate(since.getDate() - 1);\n return { since: since.toISOString(), until: until.toISOString() };\n }\n const start = starts[filter.preset];\n if (!start) return {};\n return filter.preset.startsWith(\"older_\")\n ? { until: start.toISOString() }\n : { since: start.toISOString() };\n}\n"],"mappings":";;;AACO,IAAM,2BAA2B;AAAA,EACtC;AAAA,EAAO;AAAA,EAAM;AAAA,EAAO;AAAA,EAAO;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAC7C;AAAA,EAAS;AAAA,EAAa;AAAA,EAAa;AAAA,EAAc;AAAA,EACjD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,MAAM,YAAY,EAAE,IAC7B,EAAE,OAAO,MAAM,YAAY,EAAE;AACnC;","names":[]}
|
|
@@ -124,6 +124,72 @@ function layeredFilterMatchesValue(value, rule) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// src/data-table/date-filter.ts
|
|
128
|
+
function startOfDay(date) {
|
|
129
|
+
const next = new Date(date);
|
|
130
|
+
next.setHours(0, 0, 0, 0);
|
|
131
|
+
return next;
|
|
132
|
+
}
|
|
133
|
+
function startOfWeek(date) {
|
|
134
|
+
const next = startOfDay(date);
|
|
135
|
+
next.setDate(next.getDate() - (next.getDay() === 0 ? 6 : next.getDay() - 1));
|
|
136
|
+
return next;
|
|
137
|
+
}
|
|
138
|
+
function startOfMonth(date) {
|
|
139
|
+
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
140
|
+
}
|
|
141
|
+
function startOfYear(date) {
|
|
142
|
+
return new Date(date.getFullYear(), 0, 1);
|
|
143
|
+
}
|
|
144
|
+
function validDate(value) {
|
|
145
|
+
if (value === void 0) return void 0;
|
|
146
|
+
const date = value instanceof Date ? new Date(value) : new Date(value);
|
|
147
|
+
return Number.isNaN(date.valueOf()) ? void 0 : date;
|
|
148
|
+
}
|
|
149
|
+
function dateFilterBounds(filter, now = /* @__PURE__ */ new Date()) {
|
|
150
|
+
if (!filter.preset) {
|
|
151
|
+
return {
|
|
152
|
+
...filter.since === void 0 ? {} : { since: filter.since },
|
|
153
|
+
...filter.until === void 0 ? {} : { until: filter.until }
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (filter.preset === "all") return {};
|
|
157
|
+
const anchor = validDate(filter.anchor) ?? validDate(now) ?? /* @__PURE__ */ new Date();
|
|
158
|
+
const ago = (milliseconds) => new Date(anchor.valueOf() - milliseconds).toISOString();
|
|
159
|
+
const recent = {
|
|
160
|
+
"1m": 6e4,
|
|
161
|
+
"15m": 15 * 6e4,
|
|
162
|
+
"30m": 30 * 6e4,
|
|
163
|
+
"1h": 60 * 6e4,
|
|
164
|
+
"2h": 2 * 60 * 6e4,
|
|
165
|
+
"6h": 6 * 60 * 6e4,
|
|
166
|
+
"12h": 12 * 60 * 6e4
|
|
167
|
+
};
|
|
168
|
+
const duration = recent[filter.preset.replace("older_", "")];
|
|
169
|
+
if (duration !== void 0) {
|
|
170
|
+
return filter.preset.startsWith("older_") ? { until: ago(duration) } : { since: ago(duration) };
|
|
171
|
+
}
|
|
172
|
+
const starts = {
|
|
173
|
+
today: startOfDay(anchor),
|
|
174
|
+
this_week: startOfWeek(anchor),
|
|
175
|
+
this_month: startOfMonth(anchor),
|
|
176
|
+
this_year: startOfYear(anchor),
|
|
177
|
+
older_today: startOfDay(anchor),
|
|
178
|
+
older_this_week: startOfWeek(anchor),
|
|
179
|
+
older_this_month: startOfMonth(anchor),
|
|
180
|
+
older_this_year: startOfYear(anchor)
|
|
181
|
+
};
|
|
182
|
+
if (filter.preset === "yesterday") {
|
|
183
|
+
const until = startOfDay(anchor);
|
|
184
|
+
const since = new Date(until);
|
|
185
|
+
since.setDate(since.getDate() - 1);
|
|
186
|
+
return { since: since.toISOString(), until: until.toISOString() };
|
|
187
|
+
}
|
|
188
|
+
const start = starts[filter.preset];
|
|
189
|
+
if (!start) return {};
|
|
190
|
+
return filter.preset.startsWith("older_") ? { until: start.toISOString() } : { since: start.toISOString() };
|
|
191
|
+
}
|
|
192
|
+
|
|
127
193
|
// src/data-table/filter-engine.ts
|
|
128
194
|
var SELECT_EMPTY_VALUE = "__empty__";
|
|
129
195
|
var SELECT_NOT_EMPTY_VALUE = "__not_empty__";
|
|
@@ -226,6 +292,21 @@ function passesColumnFilter(value, filter) {
|
|
|
226
292
|
if (filter.max !== void 0 && n > filter.max) return false;
|
|
227
293
|
return true;
|
|
228
294
|
}
|
|
295
|
+
case "date": {
|
|
296
|
+
const raw = value instanceof Date ? value : new Date(stringifyCellValue(value));
|
|
297
|
+
if (Number.isNaN(raw.valueOf())) return false;
|
|
298
|
+
const { since, until } = dateFilterBounds(filter);
|
|
299
|
+
const timestamp = raw.valueOf();
|
|
300
|
+
if (since !== void 0) {
|
|
301
|
+
const sinceTimestamp = new Date(since).valueOf();
|
|
302
|
+
if (Number.isNaN(sinceTimestamp) || timestamp < sinceTimestamp) return false;
|
|
303
|
+
}
|
|
304
|
+
if (until !== void 0) {
|
|
305
|
+
const untilTimestamp = new Date(until).valueOf();
|
|
306
|
+
if (Number.isNaN(untilTimestamp) || timestamp >= untilTimestamp) return false;
|
|
307
|
+
}
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
229
310
|
}
|
|
230
311
|
})();
|
|
231
312
|
return filter.negated ? !matches : matches;
|
|
@@ -303,6 +384,9 @@ function countActiveColumnFilters(filters) {
|
|
|
303
384
|
case "number":
|
|
304
385
|
if (f.min !== void 0 || f.max !== void 0) n += 1;
|
|
305
386
|
break;
|
|
387
|
+
case "date":
|
|
388
|
+
if (isColumnFilterActive(f)) n += 1;
|
|
389
|
+
break;
|
|
306
390
|
}
|
|
307
391
|
}
|
|
308
392
|
return n;
|
|
@@ -318,6 +402,10 @@ function isColumnFilterActive(filter) {
|
|
|
318
402
|
return true;
|
|
319
403
|
case "number":
|
|
320
404
|
return filter.min !== void 0 || filter.max !== void 0;
|
|
405
|
+
case "date": {
|
|
406
|
+
const bounds = dateFilterBounds(filter);
|
|
407
|
+
return bounds.since !== void 0 || bounds.until !== void 0;
|
|
408
|
+
}
|
|
321
409
|
}
|
|
322
410
|
}
|
|
323
411
|
function applyRowEdits(row, edits) {
|