@react-querybuilder/datetime 8.17.0 → 8.19.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/dist/cjs/getDatetimeRuleProcessorTanStackDB-CL79A1_x.js +1208 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CL79A1_x.js.map +1 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-DgUg_arY.js +2 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-DgUg_arY.js.map +1 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +214 -8
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +93 -15
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +70 -59
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js +482 -71
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +129 -15
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +81 -15
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +214 -8
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +46 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js.map +1 -1
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-BfILPx88.js +2 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-BfILPx88.js.map +1 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js +63 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js.map +1 -0
- package/dist/cjs/types-XYMw0jFT.d.ts +265 -0
- package/dist/datetime-layout.css +1 -0
- package/dist/datetime-layout.css.map +1 -0
- package/dist/datetime-layout.scss +3 -0
- package/dist/datetime.css +1 -0
- package/dist/datetime.css.map +1 -0
- package/dist/datetime.scss +1 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-BcOC-o2A.mjs +1029 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-BcOC-o2A.mjs.map +1 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-Dloxv6k2.mjs +2 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-Dloxv6k2.mjs.map +1 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-LDwhMJg0.js +1035 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-LDwhMJg0.js.map +1 -0
- package/dist/react-querybuilder_datetime.d.mts +214 -8
- package/dist/react-querybuilder_datetime.date-fns.d.mts +46 -2
- package/dist/react-querybuilder_datetime.date-fns.mjs +71 -4
- package/dist/react-querybuilder_datetime.date-fns.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.dayjs.d.mts +46 -2
- package/dist/react-querybuilder_datetime.dayjs.mjs +47 -24
- package/dist/react-querybuilder_datetime.dayjs.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.jsdate.d.mts +46 -2
- package/dist/react-querybuilder_datetime.jsdate.mjs +106 -3
- package/dist/react-querybuilder_datetime.jsdate.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.d.ts +214 -8
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +46 -2
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +71 -4
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +46 -2
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +47 -24
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.js +425 -58
- package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +46 -2
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +106 -3
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +46 -2
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +58 -3
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js.map +1 -1
- package/dist/react-querybuilder_datetime.luxon.d.mts +46 -2
- package/dist/react-querybuilder_datetime.luxon.mjs +58 -3
- package/dist/react-querybuilder_datetime.luxon.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.mjs +443 -57
- package/dist/react-querybuilder_datetime.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.d.mts +214 -8
- package/dist/react-querybuilder_datetime.production.date-fns.d.mts +46 -2
- package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.date-fns.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.d.mts +46 -2
- package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.d.mts +46 -2
- package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.d.mts +46 -2
- package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
- package/dist/rqbDateTimeLibraryAPI.dayjs-BW7faYFD.mjs +29 -0
- package/dist/rqbDateTimeLibraryAPI.dayjs-BW7faYFD.mjs.map +1 -0
- package/dist/rqbDateTimeLibraryAPI.dayjs-BoX90aqZ.mjs +2 -0
- package/dist/rqbDateTimeLibraryAPI.dayjs-BoX90aqZ.mjs.map +1 -0
- package/dist/rqbDateTimeLibraryAPI.dayjs-DvFSxPKu.js +29 -0
- package/dist/rqbDateTimeLibraryAPI.dayjs-DvFSxPKu.js.map +1 -0
- package/dist/styles/_layout.scss +30 -0
- package/dist/styles/_root.scss +5 -0
- package/dist/styles/_variables.scss +8 -0
- package/dist/types-CdjHqQ0k.d.mts +265 -0
- package/dist/types-CdjHqQ0k.d.ts +265 -0
- package/package.json +30 -15
- package/dist/cjs/getDatetimeRuleProcessorSQL-Cca9pzSn.js +0 -2
- package/dist/cjs/getDatetimeRuleProcessorSQL-Cca9pzSn.js.map +0 -1
- package/dist/cjs/getDatetimeRuleProcessorSQL-CrA2ZrSe.js +0 -563
- package/dist/cjs/getDatetimeRuleProcessorSQL-CrA2ZrSe.js.map +0 -1
- package/dist/cjs/types-c6_k1Tpr.d.ts +0 -105
- package/dist/getDatetimeRuleProcessorSQL-Crw01Jo-.js +0 -482
- package/dist/getDatetimeRuleProcessorSQL-Crw01Jo-.js.map +0 -1
- package/dist/getDatetimeRuleProcessorSQL-CvGKzojM.mjs +0 -2
- package/dist/getDatetimeRuleProcessorSQL-CvGKzojM.mjs.map +0 -1
- package/dist/getDatetimeRuleProcessorSQL-Nz_XjNeY.mjs +0 -468
- package/dist/getDatetimeRuleProcessorSQL-Nz_XjNeY.mjs.map +0 -1
- package/dist/types-c6_k1Tpr.d.mts +0 -105
- package/dist/types-c6_k1Tpr.d.ts +0 -105
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
const require_getDatetimeRuleProcessorTanStackDB = require("./getDatetimeRuleProcessorTanStackDB-CL79A1_x.js");
|
|
24
|
+
let dayjs = require("dayjs");
|
|
25
|
+
dayjs = __toESM(dayjs);
|
|
26
|
+
//#region src/rqbDateTimeLibraryAPI.dayjs.ts
|
|
27
|
+
/**
|
|
28
|
+
* {@link RQBDateTimeLibraryAPI} for Day.js
|
|
29
|
+
*/
|
|
30
|
+
const rqbDateTimeLibraryAPI = {
|
|
31
|
+
format: (d, fmt) => (0, dayjs.default)(d).format(fmt),
|
|
32
|
+
isAfter: (a, b) => (0, dayjs.default)(a).isAfter(b),
|
|
33
|
+
isBefore: (a, b) => (0, dayjs.default)(a).isBefore(b),
|
|
34
|
+
isSame: (a, b) => (0, dayjs.default)(a).isSame(b, require_getDatetimeRuleProcessorTanStackDB.isISOStringDateOnly(a) || require_getDatetimeRuleProcessorTanStackDB.isISOStringDateOnly(b) ? "d" : "ms"),
|
|
35
|
+
isValid: (d) => (0, dayjs.default)(d).isValid(),
|
|
36
|
+
toDate: (d) => (0, dayjs.default)(d).toDate(),
|
|
37
|
+
toISOString: (d) => {
|
|
38
|
+
const dToDate = (0, dayjs.default)(d);
|
|
39
|
+
return dToDate.isValid() ? dToDate.toISOString() : "";
|
|
40
|
+
},
|
|
41
|
+
toISOStringDateOnly: (d) => {
|
|
42
|
+
const dToDate = (0, dayjs.default)(d);
|
|
43
|
+
return dToDate.isValid() ? dToDate.format("YYYY-MM-DD") : "";
|
|
44
|
+
},
|
|
45
|
+
startOf: (d, unit) => (0, dayjs.default)(d).startOf(unit).toDate(),
|
|
46
|
+
endOf: (d, unit) => (0, dayjs.default)(d).endOf(unit).toDate(),
|
|
47
|
+
add: (d, amount, unit) => (0, dayjs.default)(d).add(amount, unit).toDate()
|
|
48
|
+
};
|
|
49
|
+
//#endregion
|
|
50
|
+
Object.defineProperty(exports, "__toESM", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function() {
|
|
53
|
+
return __toESM;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "rqbDateTimeLibraryAPI", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function() {
|
|
59
|
+
return rqbDateTimeLibraryAPI;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js","names":["isISOStringDateOnly"],"sources":["../../src/rqbDateTimeLibraryAPI.dayjs.ts"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { RQBDateTimeLibraryAPI } from './types';\nimport { isISOStringDateOnly } from './utils';\n\n/**\n * {@link RQBDateTimeLibraryAPI} for Day.js\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: (d, fmt) => dayjs(d).format(fmt),\n isAfter: (a, b) => dayjs(a).isAfter(b),\n isBefore: (a, b) => dayjs(a).isBefore(b),\n isSame: (a, b) =>\n dayjs(a).isSame(b, isISOStringDateOnly(a) || isISOStringDateOnly(b) ? 'd' : 'ms'),\n isValid: d => dayjs(d).isValid(),\n toDate: d => dayjs(d).toDate(),\n toISOString: d => {\n const dToDate = dayjs(d);\n return dToDate.isValid() ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly: d => {\n const dToDate = dayjs(d);\n return dToDate.isValid() ? dToDate.format('YYYY-MM-DD') : '';\n },\n startOf: (d, unit) => dayjs(d).startOf(unit).toDate(),\n endOf: (d, unit) => dayjs(d).endOf(unit).toDate(),\n add: (d, amount, unit) => dayjs(d).add(amount, unit).toDate(),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,wBAA+C;CAC1D,SAAS,GAAG,SAAA,GAAA,MAAA,QAAA,CAAc,CAAC,CAAC,CAAC,OAAO,GAAG;CACvC,UAAU,GAAG,OAAA,GAAA,MAAA,QAAA,CAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;CACrC,WAAW,GAAG,OAAA,GAAA,MAAA,QAAA,CAAY,CAAC,CAAC,CAAC,SAAS,CAAC;CACvC,SAAS,GAAG,OAAA,GAAA,MAAA,QAAA,CACJ,CAAC,CAAC,CAAC,OAAO,GAAGA,2CAAAA,oBAAoB,CAAC,KAAKA,2CAAAA,oBAAoB,CAAC,IAAI,MAAM,IAAI;CAClF,UAAS,OAAA,GAAA,MAAA,QAAA,CAAW,CAAC,CAAC,CAAC,QAAQ;CAC/B,SAAQ,OAAA,GAAA,MAAA,QAAA,CAAW,CAAC,CAAC,CAAC,OAAO;CAC7B,cAAa,MAAK;EAChB,MAAM,WAAA,GAAA,MAAA,QAAA,CAAgB,CAAC;EACvB,OAAO,QAAQ,QAAQ,IAAI,QAAQ,YAAY,IAAI;CACrD;CACA,sBAAqB,MAAK;EACxB,MAAM,WAAA,GAAA,MAAA,QAAA,CAAgB,CAAC;EACvB,OAAO,QAAQ,QAAQ,IAAI,QAAQ,OAAO,YAAY,IAAI;CAC5D;CACA,UAAU,GAAG,UAAA,GAAA,MAAA,QAAA,CAAe,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,OAAO;CACpD,QAAQ,GAAG,UAAA,GAAA,MAAA,QAAA,CAAe,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO;CAChD,MAAM,GAAG,QAAQ,UAAA,GAAA,MAAA,QAAA,CAAe,CAAC,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC,CAAC,OAAO;AAC9D"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { FullOption, RQBJsonLogic, RuleProcessor, ValueEditorProps } from "react-querybuilder";
|
|
2
|
+
import { RulesLogic } from "json-logic-js";
|
|
3
|
+
import { ComponentType, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
interface RQBJsonLogicDateBetween {
|
|
7
|
+
dateBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
|
|
8
|
+
}
|
|
9
|
+
interface RQBJsonLogicDateNotBetween {
|
|
10
|
+
dateNotBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
|
|
11
|
+
}
|
|
12
|
+
interface RQBJsonLogicDateIn {
|
|
13
|
+
dateIn: [RQBJsonLogic, RQBJsonLogic[]];
|
|
14
|
+
}
|
|
15
|
+
interface RQBJsonLogicDateNotIn {
|
|
16
|
+
dateNotIn: [RQBJsonLogic, RQBJsonLogic[]];
|
|
17
|
+
}
|
|
18
|
+
interface RQBJsonLogicDateBefore {
|
|
19
|
+
dateBefore: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
20
|
+
}
|
|
21
|
+
interface RQBJsonLogicDateOnOrBefore {
|
|
22
|
+
dateOnOrBefore: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
23
|
+
}
|
|
24
|
+
interface RQBJsonLogicDateOn {
|
|
25
|
+
dateOn: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
26
|
+
}
|
|
27
|
+
interface RQBJsonLogicDateNotOn {
|
|
28
|
+
dateNotOn: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
29
|
+
}
|
|
30
|
+
interface RQBJsonLogicDateAfter {
|
|
31
|
+
dateAfter: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
32
|
+
}
|
|
33
|
+
interface RQBJsonLogicDateOnOrAfter {
|
|
34
|
+
dateOnOrAfter: [RQBJsonLogic, RQBJsonLogic, ...RQBJsonLogic[]];
|
|
35
|
+
}
|
|
36
|
+
interface RQBJsonLogicDateRelative {
|
|
37
|
+
dateRelative: [RelativeDateTimeAnchor, number, RelativeDateTimeUnit, boolean];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* JsonLogic rule object with additional operators generated by
|
|
41
|
+
* {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
|
|
42
|
+
* {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
|
|
43
|
+
*/
|
|
44
|
+
type RQBDateTimeJsonLogic = RQBJsonLogic | RulesLogic<RQBJsonLogicDateAfter | RQBJsonLogicDateBefore | RQBJsonLogicDateBetween | RQBJsonLogicDateIn | RQBJsonLogicDateNotBetween | RQBJsonLogicDateNotIn | RQBJsonLogicDateNotOn | RQBJsonLogicDateOn | RQBJsonLogicDateOnOrAfter | RQBJsonLogicDateOnOrBefore | RQBJsonLogicDateRelative>;
|
|
45
|
+
type DateOrString = string | Date;
|
|
46
|
+
/**
|
|
47
|
+
* Unit of measure for a relative date/time offset.
|
|
48
|
+
*/
|
|
49
|
+
type RelativeDateTimeUnit = "minute" | "hour" | "day" | "week" | "month" | "year";
|
|
50
|
+
/**
|
|
51
|
+
* Unit of measure for truncating a date/time to the start or end of a period
|
|
52
|
+
* (the subset of {@link RelativeDateTimeUnit} that represents a calendar period).
|
|
53
|
+
*/
|
|
54
|
+
type RelativeDateTimeTruncationUnit = "day" | "week" | "month" | "year";
|
|
55
|
+
/**
|
|
56
|
+
* Reference point (zero-offset) for a {@link RelativeDateTimeValue}. `'now'` is the
|
|
57
|
+
* current date/time; the `startOf*`/`endOf*` anchors truncate to the start or end
|
|
58
|
+
* of the corresponding calendar period.
|
|
59
|
+
*/
|
|
60
|
+
type RelativeDateTimeAnchor = "now" | "startOfDay" | "endOfDay" | "startOfWeek" | "endOfWeek" | "startOfMonth" | "endOfMonth" | "startOfYear" | "endOfYear";
|
|
61
|
+
/**
|
|
62
|
+
* Structured representation of a relative date/time value, e.g. "three months ago"
|
|
63
|
+
* or "the beginning of this year". Stored as the `value` of a rule (in place of the
|
|
64
|
+
* usual ISO 8601 string) and recognized by the date/time rule processors.
|
|
65
|
+
*
|
|
66
|
+
* The final date/time is computed as: apply the `anchor` to the current date/time,
|
|
67
|
+
* then add `offset` units of `unit`. When `offset` is `0`, `unit` is irrelevant.
|
|
68
|
+
*/
|
|
69
|
+
interface RelativeDateTimeValue {
|
|
70
|
+
/** Discriminant identifying a relative (as opposed to absolute) value. */
|
|
71
|
+
mode: "relative";
|
|
72
|
+
/** Zero-offset reference point. */
|
|
73
|
+
anchor: RelativeDateTimeAnchor;
|
|
74
|
+
/** Signed offset from the anchor; negative = past, positive = future, 0 = exact anchor. */
|
|
75
|
+
offset: number;
|
|
76
|
+
/** Unit of the `offset`. */
|
|
77
|
+
unit: RelativeDateTimeUnit;
|
|
78
|
+
}
|
|
79
|
+
interface RQBDateTimeLibraryAPI {
|
|
80
|
+
/**
|
|
81
|
+
* Formats a date as a string.
|
|
82
|
+
*/
|
|
83
|
+
format: (d: DateOrString, fmt: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Formats a date as an ISO 8601 string, only including
|
|
86
|
+
* the year, month, and day ('YYYY-MM-DD').
|
|
87
|
+
*/
|
|
88
|
+
toISOStringDateOnly: (d: DateOrString) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Determines whether the first date is after the second date.
|
|
91
|
+
*/
|
|
92
|
+
isAfter: (a: DateOrString, b: DateOrString) => boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Determines whether the first date is before the second date.
|
|
95
|
+
*/
|
|
96
|
+
isBefore: (a: DateOrString, b: DateOrString) => boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Determines whether the first date is the same as the second date.
|
|
99
|
+
*
|
|
100
|
+
* If either the first date or the second date is a string in the
|
|
101
|
+
* format 'YYYY-MM-DD', then the dates will only be compared at
|
|
102
|
+
* the date level (no time component). Otherwise, they will be
|
|
103
|
+
* compared to the millisecond.
|
|
104
|
+
*/
|
|
105
|
+
isSame: (a: DateOrString, b: DateOrString) => boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Determines whether the date is either a valid `Date` object or an
|
|
108
|
+
* ISO 8601-formatted string representing a valid date.
|
|
109
|
+
*/
|
|
110
|
+
isValid: (d: DateOrString) => boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Converts a string to a `Date` object or returns a valid `Date` as is.
|
|
113
|
+
*/
|
|
114
|
+
toDate: (d: DateOrString) => Date;
|
|
115
|
+
/**
|
|
116
|
+
* Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
|
|
117
|
+
* string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
|
|
118
|
+
* static; other parts represent standard time units, increasing in precision
|
|
119
|
+
* from left to right).
|
|
120
|
+
*/
|
|
121
|
+
toISOString: (d: DateOrString) => string;
|
|
122
|
+
/**
|
|
123
|
+
* Returns a new `Date` truncated to the start of the given period.
|
|
124
|
+
*
|
|
125
|
+
* Week start follows the date library's own default/locale (e.g. Luxon uses
|
|
126
|
+
* Monday per ISO 8601; Day.js and date-fns default to Sunday).
|
|
127
|
+
*/
|
|
128
|
+
startOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
|
|
129
|
+
/**
|
|
130
|
+
* Returns a new `Date` advanced to the end of the given period (the last
|
|
131
|
+
* representable instant within it).
|
|
132
|
+
*
|
|
133
|
+
* Week start follows the date library's own default/locale (see {@link RQBDateTimeLibraryAPI.startOf}).
|
|
134
|
+
*/
|
|
135
|
+
endOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
|
|
136
|
+
/**
|
|
137
|
+
* Returns a new `Date` offset from the input by `amount` units of `unit`
|
|
138
|
+
* (negative `amount` moves into the past).
|
|
139
|
+
*/
|
|
140
|
+
add: (d: DateOrString, amount: number, unit: RelativeDateTimeUnit) => Date;
|
|
141
|
+
}
|
|
142
|
+
type FnDateDate = (a: DateOrString, b: DateOrString) => boolean;
|
|
143
|
+
type FnDateArrayOfDates = (a: DateOrString, b: DateOrString[]) => boolean;
|
|
144
|
+
type FnDateDateDate = (a: DateOrString, b: DateOrString, c: DateOrString) => boolean;
|
|
145
|
+
type RQBJsonLogicDateTimeOperations = {
|
|
146
|
+
/** Determines if the first date is after the second date. */dateAfter: FnDateDate; /** Determines if the first date is before the second date. */
|
|
147
|
+
dateBefore: FnDateDate; /** Determines if the second date is between the first and third dates (inclusive). */
|
|
148
|
+
dateBetween: FnDateDateDate; /** Determines if the first date is one of the values in the array of dates. */
|
|
149
|
+
dateIn: FnDateArrayOfDates; /** Determines if the second date is not between the first and third dates. */
|
|
150
|
+
dateNotBetween: FnDateDateDate; /** Determines if the first date is not one of the values in the array of dates. */
|
|
151
|
+
dateNotIn: FnDateArrayOfDates; /** Determines if the first date is not the same as the second date. */
|
|
152
|
+
dateNotOn: FnDateDate; /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
|
|
153
|
+
dateOn: FnDateDate; /** Determines if the first date is either the same as the second date or after it. */
|
|
154
|
+
dateOnOrAfter: FnDateDate; /** Determines if the first date is either the same as the second date or before it. */
|
|
155
|
+
dateOnOrBefore: FnDateDate;
|
|
156
|
+
/**
|
|
157
|
+
* Resolves a relative date/time descriptor (anchor, offset, unit, and date-only
|
|
158
|
+
* flag) to a concrete ISO 8601 string at evaluation time ("live" semantics).
|
|
159
|
+
*/
|
|
160
|
+
dateRelative: (anchor: RelativeDateTimeAnchor, offset: number, unit: RelativeDateTimeUnit, dateOnly: boolean) => string;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Customizable content/labels for the absolute/relative mode toggle rendered by
|
|
164
|
+
* {@link toggleModeController}. The default glyphs come from CSS pseudo-elements, so
|
|
165
|
+
* `absoluteContent`/`relativeContent` are only needed to override them (e.g. to render
|
|
166
|
+
* an icon component or localized text).
|
|
167
|
+
*/
|
|
168
|
+
interface RelativeDateTimeToggleLabels {
|
|
169
|
+
/** Accessible label (`aria-label`) for the toggle button. */
|
|
170
|
+
label?: string;
|
|
171
|
+
/** Tooltip shown while in absolute mode (clicking switches to relative). */
|
|
172
|
+
absoluteTitle?: string;
|
|
173
|
+
/** Tooltip shown while in relative mode (clicking switches to absolute). */
|
|
174
|
+
relativeTitle?: string;
|
|
175
|
+
/** Custom content rendered while in absolute mode. Defaults to a CSS glyph. */
|
|
176
|
+
absoluteContent?: ReactNode;
|
|
177
|
+
/** Custom content rendered while in relative mode. Defaults to a CSS glyph. */
|
|
178
|
+
relativeContent?: ReactNode;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Props passed to a {@link RelativeDateTimeModeController}'s `ModeControl` component —
|
|
182
|
+
* the affordance (e.g. a toggle button) that switches a rule between absolute and
|
|
183
|
+
* relative date/time entry.
|
|
184
|
+
*/
|
|
185
|
+
interface RelativeDateTimeModeControlProps {
|
|
186
|
+
/** Whether the rule is currently in relative mode. */
|
|
187
|
+
isRelative: boolean;
|
|
188
|
+
/** Switches the rule between absolute and relative mode. */
|
|
189
|
+
setMode: (mode: "absolute" | "relative") => void;
|
|
190
|
+
/** The value editor's schema (for theme-aware rendering). */
|
|
191
|
+
schema: ValueEditorProps["schema"];
|
|
192
|
+
/** Whether the control is disabled. */
|
|
193
|
+
disabled?: boolean;
|
|
194
|
+
/** Class name applied to the control. */
|
|
195
|
+
className?: string;
|
|
196
|
+
/** Title/tooltip from the value editor (fallback when labels omit titles). */
|
|
197
|
+
title?: string;
|
|
198
|
+
/** Test ID from the value editor. */
|
|
199
|
+
testID?: string;
|
|
200
|
+
/** Resolved toggle labels (merged with defaults). */
|
|
201
|
+
labels: Required<RelativeDateTimeToggleLabels>;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A pluggable strategy that governs how a user switches between absolute and relative
|
|
205
|
+
* date/time entry in the {@link RelativeDateTimeValueEditor}. The stored value shape is
|
|
206
|
+
* unaffected — a controller only decides the current mode and (optionally) renders an
|
|
207
|
+
* affordance to change it.
|
|
208
|
+
*
|
|
209
|
+
* Ships with {@link toggleModeController} (the zero-config default); build an
|
|
210
|
+
* operator-driven controller with {@link createOperatorModeController}, or supply a custom
|
|
211
|
+
* object to fully control the UX.
|
|
212
|
+
*/
|
|
213
|
+
interface RelativeDateTimeModeController {
|
|
214
|
+
/** Derives the current mode from the rule (its operator and/or value). */
|
|
215
|
+
isRelative: (props: ValueEditorProps) => boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Optional affordance rendered inside the editor to switch modes. Omit it (as the
|
|
218
|
+
* operator-driven controller does) when the mode is selected elsewhere, e.g. via the
|
|
219
|
+
* operator selector.
|
|
220
|
+
*/
|
|
221
|
+
ModeControl?: ComponentType<RelativeDateTimeModeControlProps>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Configuration for the {@link RelativeDateTimeValueEditor}, supplied as props to
|
|
225
|
+
* {@link QueryBuilderDateTime} (or via the relative date/time config context). Every
|
|
226
|
+
* field is optional; omitting all of them yields the zero-config toggle experience.
|
|
227
|
+
*/
|
|
228
|
+
interface RelativeDateTimeEditorConfig {
|
|
229
|
+
/** Strategy for switching between absolute and relative modes. Defaults to {@link toggleModeController}. */
|
|
230
|
+
modeController?: RelativeDateTimeModeController;
|
|
231
|
+
/** Anchor (reference-point) options. Defaults to {@link defaultRelativeDateTimeAnchors}. */
|
|
232
|
+
anchors?: FullOption<RelativeDateTimeAnchor>[];
|
|
233
|
+
/** Unit options. Defaults to {@link defaultRelativeDateTimeUnits}. */
|
|
234
|
+
units?: FullOption<RelativeDateTimeUnit>[];
|
|
235
|
+
/** Content/labels for the absolute/relative toggle. */
|
|
236
|
+
toggleLabels?: RelativeDateTimeToggleLabels;
|
|
237
|
+
/**
|
|
238
|
+
* Date/time library adapter used by the value editor to parse/validate the rule value
|
|
239
|
+
* for the native date input. Defaults to the Day.js adapter. Pass the adapter matching
|
|
240
|
+
* your chosen entry point (e.g. from `@react-querybuilder/datetime/luxon`) so the editor
|
|
241
|
+
* interprets values consistently with the rule processors.
|
|
242
|
+
*/
|
|
243
|
+
dateTimeAPI?: RQBDateTimeLibraryAPI;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Maps operator names that are used only to _signal_ relative mode (see
|
|
247
|
+
* {@link createOperatorModeController}) to the real comparison operator that should be used
|
|
248
|
+
* when exporting via `formatQuery`. Supplied through `context.relativeOperatorMap`. Operators
|
|
249
|
+
* not present in the map are exported unchanged.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* formatQuery(query, {
|
|
254
|
+
* format: 'sql',
|
|
255
|
+
* ruleProcessor: datetimeRuleProcessorSQL,
|
|
256
|
+
* context: { relativeOperatorMap: { relativeEq: '=' } },
|
|
257
|
+
* });
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
type RelativeOperatorMap = Record<string, string>;
|
|
261
|
+
type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boolean;
|
|
262
|
+
type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
|
|
263
|
+
//#endregion
|
|
264
|
+
export { RelativeDateTimeUnit as C, RelativeDateTimeTruncationUnit as S, RelativeOperatorMap as T, RelativeDateTimeAnchor as _, RQBJsonLogicDateAfter as a, RelativeDateTimeModeController as b, RQBJsonLogicDateIn as c, RQBJsonLogicDateNotOn as d, RQBJsonLogicDateOn as f, RQBJsonLogicDateTimeOperations as g, RQBJsonLogicDateRelative as h, RQBDateTimeLibraryAPI as i, RQBJsonLogicDateNotBetween as l, RQBJsonLogicDateOnOrBefore as m, IsDateFieldFunction as n, RQBJsonLogicDateBefore as o, RQBJsonLogicDateOnOrAfter as p, RQBDateTimeJsonLogic as r, RQBJsonLogicDateBetween as s, IsDateField as t, RQBJsonLogicDateNotIn as u, RelativeDateTimeEditorConfig as v, RelativeDateTimeValue as w, RelativeDateTimeToggleLabels as x, RelativeDateTimeModeControlProps as y };
|
|
265
|
+
//# sourceMappingURL=types-XYMw0jFT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--rqbdt-spacing: 0.5rem}.rule-value-dateTimeRelative{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--rqbdt-spacing)}.rule-value-dateTimeRelative-toggle{cursor:pointer}.rule-value-dateTimeRelative-toggle:empty::before{content:"📅"}.rule-value-dateTimeRelative-toggle[aria-checked=true]:empty::before{content:"🕒"}.rule-value-dateTimeRelative-toggle:disabled{cursor:not-allowed}/*# sourceMappingURL=datetime-layout.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["styles/_root.scss","styles/_layout.scss"],"names":[],"mappings":"CAEA,MACE,wBCEF,6BACE,oBACA,eACA,mBACA,yBAMF,oCACE,eAEA,kDACE,aAGF,qEACE,aAGF,6CACE","file":"datetime-layout.css"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{--rqbdt-spacing: 0.5rem}.rule-value-dateTimeRelative{display:inline-flex;flex-wrap:wrap;align-items:center;gap:var(--rqbdt-spacing)}.rule-value-dateTimeRelative-toggle{cursor:pointer}.rule-value-dateTimeRelative-toggle:empty::before{content:"📅"}.rule-value-dateTimeRelative-toggle[aria-checked=true]:empty::before{content:"🕒"}.rule-value-dateTimeRelative-toggle:disabled{cursor:not-allowed}/*# sourceMappingURL=datetime.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["styles/_root.scss","styles/_layout.scss"],"names":[],"mappings":"CAEA,MACE,wBCEF,6BACE,oBACA,eACA,mBACA,yBAMF,oCACE,eAEA,kDACE,aAGF,qEACE,aAGF,6CACE","file":"datetime.css"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@forward './datetime-layout';
|