@react-querybuilder/datetime 8.20.1 → 8.21.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/README.md +9 -3
- package/dist/cjs/{getDatetimeRuleProcessorTanStackDB-CL79A1_x.js → getDatetimeRuleProcessorTanStackDB-CDEB9coD.js} +88 -218
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CDEB9coD.js.map +1 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js +2 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js.map +1 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +124 -260
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +50 -51
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +3 -2
- 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 +50 -51
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +53 -26
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js +11 -467
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +53 -54
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +26 -144
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +50 -51
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +3 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +214 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js +466 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js.map +1 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +124 -260
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +50 -51
- 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 +50 -51
- 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 +53 -54
- 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 +50 -51
- 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/react-querybuilder_datetime.cjs.production.ui.d.ts +214 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +2 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -0
- package/dist/cjs/rolldown-runtime-CMqjfN_6.js +1 -0
- package/dist/cjs/rolldown-runtime-D6vf50IK.js +28 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js +2 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map +1 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js +128 -0
- package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map +1 -0
- package/dist/cjs/types-BKA1aoY6.d.ts +174 -0
- package/dist/cjs/ui.d.ts +1 -0
- package/dist/cjs/ui.js +6 -0
- package/dist/cjs/utils-DdBYGWHZ.js +2 -0
- package/dist/cjs/utils-DdBYGWHZ.js.map +1 -0
- package/dist/cjs/utils-_X97pUtk.js +166 -0
- package/dist/cjs/utils-_X97pUtk.js.map +1 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs +2 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs.map +1 -0
- package/dist/{getDatetimeRuleProcessorTanStackDB-BL8mbdbl.js → getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js} +24 -198
- package/dist/getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js.map +1 -0
- package/dist/{getDatetimeRuleProcessorTanStackDB-BcOC-o2A.mjs → getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs} +24 -124
- package/dist/getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs.map +1 -0
- package/dist/objectSpread2-MqoZ2hSz.js +187 -0
- package/dist/objectSpread2-MqoZ2hSz.js.map +1 -0
- package/dist/react-querybuilder_datetime.d.mts +124 -260
- package/dist/react-querybuilder_datetime.date-fns.d.mts +50 -51
- package/dist/react-querybuilder_datetime.date-fns.mjs +2 -1
- package/dist/react-querybuilder_datetime.date-fns.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.dayjs.d.mts +50 -51
- package/dist/react-querybuilder_datetime.dayjs.mjs +27 -2
- package/dist/react-querybuilder_datetime.dayjs.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.jsdate.d.mts +53 -54
- package/dist/react-querybuilder_datetime.jsdate.mjs +2 -120
- package/dist/react-querybuilder_datetime.jsdate.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.d.ts +124 -260
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +50 -51
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -1
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +50 -51
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +27 -2
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.js +5 -449
- package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +53 -54
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -120
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +50 -51
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -1
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +214 -0
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js +453 -0
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js.map +1 -0
- package/dist/react-querybuilder_datetime.luxon.d.mts +50 -51
- package/dist/react-querybuilder_datetime.luxon.mjs +2 -1
- package/dist/react-querybuilder_datetime.luxon.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.mjs +5 -446
- package/dist/react-querybuilder_datetime.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.d.mts +124 -260
- package/dist/react-querybuilder_datetime.production.date-fns.d.mts +50 -51
- 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 +50 -51
- 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 +53 -54
- 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 +50 -51
- 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/react-querybuilder_datetime.production.ui.d.mts +214 -0
- package/dist/react-querybuilder_datetime.production.ui.mjs +2 -0
- package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -0
- package/dist/react-querybuilder_datetime.ui.d.mts +214 -0
- package/dist/react-querybuilder_datetime.ui.mjs +450 -0
- package/dist/react-querybuilder_datetime.ui.mjs.map +1 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js +123 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map +1 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs +2 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map +1 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs +123 -0
- package/dist/rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map +1 -0
- package/dist/types-BKA1aoY6.d.mts +174 -0
- package/dist/types-BKA1aoY6.d.ts +174 -0
- package/dist/utils-BAgUBdyf.mjs +113 -0
- package/dist/utils-BAgUBdyf.mjs.map +1 -0
- package/dist/utils-DA8aluCt.mjs +2 -0
- package/dist/utils-DA8aluCt.mjs.map +1 -0
- package/package.json +36 -17
- package/ui/package.json +4 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CL79A1_x.js.map +0 -1
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-DgUg_arY.js +0 -2
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-DgUg_arY.js.map +0 -1
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-BfILPx88.js +0 -2
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-BfILPx88.js.map +0 -1
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js +0 -63
- package/dist/cjs/rqbDateTimeLibraryAPI.dayjs-CzLh_zi9.js.map +0 -1
- package/dist/cjs/types-XYMw0jFT.d.ts +0 -265
- package/dist/getDatetimeRuleProcessorTanStackDB-BL8mbdbl.js.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-BcOC-o2A.mjs.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-Dloxv6k2.mjs +0 -2
- package/dist/getDatetimeRuleProcessorTanStackDB-Dloxv6k2.mjs.map +0 -1
- package/dist/rqbDateTimeLibraryAPI.dayjs-BW7faYFD.mjs +0 -29
- package/dist/rqbDateTimeLibraryAPI.dayjs-BW7faYFD.mjs.map +0 -1
- package/dist/rqbDateTimeLibraryAPI.dayjs-BoX90aqZ.mjs +0 -2
- package/dist/rqbDateTimeLibraryAPI.dayjs-BoX90aqZ.mjs.map +0 -1
- package/dist/rqbDateTimeLibraryAPI.dayjs-Da4VXvFM.js +0 -29
- package/dist/rqbDateTimeLibraryAPI.dayjs-Da4VXvFM.js.map +0 -1
- package/dist/types-CdjHqQ0k.d.mts +0 -265
- package/dist/types-CdjHqQ0k.d.ts +0 -265
package/README.md
CHANGED
|
@@ -17,11 +17,10 @@ npm i react-querybuilder @react-querybuilder/datetime
|
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
<!--
|
|
21
20
|
To enable the date and time functionality of a query builder, nest the `QueryBuilder` element under `QueryBuilderDateTime`.
|
|
22
21
|
|
|
23
22
|
```tsx
|
|
24
|
-
import { QueryBuilderDateTime } from '@react-querybuilder/datetime';
|
|
23
|
+
import { QueryBuilderDateTime } from '@react-querybuilder/datetime/ui';
|
|
25
24
|
import { useState } from 'react';
|
|
26
25
|
import { QueryBuilder, RuleGroupType } from 'react-querybuilder';
|
|
27
26
|
|
|
@@ -40,7 +39,14 @@ const App = () => {
|
|
|
40
39
|
);
|
|
41
40
|
};
|
|
42
41
|
```
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
All React exports live in the `/ui` entry point (`@react-querybuilder/datetime/ui`); the root entry is framework-agnostic, exporting only rule processors, utilities, and types.
|
|
44
|
+
|
|
45
|
+
- **`QueryBuilderDateTime`** — the context provider shown above. Accepts optional config props (`anchors`, `units`, `toggleLabels`, `modeController`, `dateTimeAPI`) to customize the relative date/time editor.
|
|
46
|
+
- **`RelativeDateTimeValueEditor`** — the value editor itself, for use directly via `controlElements` when you'd rather not wrap with the provider.
|
|
47
|
+
- **Mode controllers** — `toggleModeController` (the default absolute/relative toggle button) and `createOperatorModeController` (derives the mode from the rule's operator), plus the `withRelativeOperators` field helper.
|
|
48
|
+
|
|
49
|
+
See the [Components documentation](https://react-querybuilder.js.org/docs/datetime#components) for relative values, mode controllers, and configuration.
|
|
44
50
|
|
|
45
51
|
To add date/time functionality to `formatQuery`, import a rule processor from `@react-querybuilder/datetime/dayjs`, `@react-querybuilder/datetime/date-fns`, or `@react-querybuilder/datetime/luxon`—depending on which library you wish to use or are already using—and pass it to the `ruleProcessor` option.
|
|
46
52
|
|
|
@@ -1,108 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const isISOStringDateOnly = (date) => typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date);
|
|
4
|
-
/**
|
|
5
|
-
* Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects
|
|
6
|
-
* (distinguishing them from the ISO 8601 strings used for absolute date/time values).
|
|
7
|
-
*/
|
|
8
|
-
const isRelativeDateTimeValue = (value) => typeof value === "object" && value !== null && value.mode === "relative" && typeof value.anchor === "string";
|
|
9
|
-
const anchorRegExp = /^(start|end)Of(Day|Week|Month|Year)$/;
|
|
10
|
-
/**
|
|
11
|
-
* Resolves a {@link RelativeDateTimeValue} into a concrete `Date` using the given
|
|
12
|
-
* date library API. The anchor is applied relative to `base` (defaulting to now),
|
|
13
|
-
* then the signed offset is added.
|
|
14
|
-
*/
|
|
15
|
-
const resolveRelativeDateTime = (apiFns, value, base = /* @__PURE__ */ new Date()) => {
|
|
16
|
-
let result = base;
|
|
17
|
-
if (value.anchor !== "now") {
|
|
18
|
-
const match = anchorRegExp.exec(value.anchor);
|
|
19
|
-
// v8 ignore next -- guarded by the RelativeDateTimeAnchor type
|
|
20
|
-
if (match) {
|
|
21
|
-
const unit = match[2].toLowerCase();
|
|
22
|
-
result = match[1] === "start" ? apiFns.startOf(result, unit) : apiFns.endOf(result, unit);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (value.offset) result = apiFns.add(result, value.offset, value.unit);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Whether a `datatype` represents a date-only (no time component) type, e.g. `date`
|
|
30
|
-
* but not `datetime`/`datetimeoffset`/`timestamp`. Used to choose the precision when
|
|
31
|
-
* materializing a relative value to an ISO 8601 string.
|
|
32
|
-
*/
|
|
33
|
-
const isDateOnlyDatatype = (datatype) => /^date\b/i.test(datatype);
|
|
34
|
-
/**
|
|
35
|
-
* Replaces any {@link RelativeDateTimeValue} in `value` (or in each element, if `value`
|
|
36
|
-
* is an array) with a concrete ISO 8601 string, resolved via
|
|
37
|
-
* {@link resolveRelativeDateTime}. The "now" reference can be pinned with
|
|
38
|
-
* `opts.context.relativeDateTimeBase` for deterministic output; precision (date-only vs
|
|
39
|
-
* full) follows the field's `datatype`. Non-relative values pass through unchanged.
|
|
40
|
-
*/
|
|
41
|
-
const materializeRelativeValues = (apiFns, value, opts) => {
|
|
42
|
-
const base = opts?.context?.relativeDateTimeBase;
|
|
43
|
-
const dateOnly = isDateOnlyDatatype(opts?.fieldData?.datatype);
|
|
44
|
-
const conv = (v) => {
|
|
45
|
-
if (!isRelativeDateTimeValue(v)) return v;
|
|
46
|
-
const resolved = resolveRelativeDateTime(apiFns, v, base);
|
|
47
|
-
return dateOnly ? apiFns.toISOStringDateOnly(resolved) : apiFns.toISOString(resolved);
|
|
48
|
-
};
|
|
49
|
-
return Array.isArray(value) ? value.map(conv) : conv(value);
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Resolves a rule's operator for export, applying any `context.relativeOperatorMap`
|
|
53
|
-
* entry. Operator-driven mode controllers (see `createOperatorModeController`) use
|
|
54
|
-
* dedicated operator names to signal relative mode; this maps those names to the real
|
|
55
|
-
* comparison operator at format time. Operators absent from the map pass through unchanged.
|
|
56
|
-
*/
|
|
57
|
-
const resolveDatetimeOperator = (...[rule, opts]) => (opts?.context?.relativeOperatorMap)?.[rule.operator] ?? rule.operator;
|
|
58
|
-
/**
|
|
59
|
-
* Prepares a date/time rule for delegation to a non-symbolic default rule processor
|
|
60
|
-
* (e.g. "parameterized", "spel", "ldap", "gremlin", "prisma", "sequelize", "drizzle",
|
|
61
|
-
* "tanstack_db"). Relative values are materialized to concrete dates (these formats have
|
|
62
|
-
* no symbolic relative form), and `between`/`notBetween` operands are ordered
|
|
63
|
-
* chronologically (defaults can't reorder non-numeric date operands). When `asDate` is
|
|
64
|
-
* set, each valid value is converted to a `Date` (for object-based formats); otherwise
|
|
65
|
-
* the materialized ISO 8601 strings are passed through. The resolved `operator` (after
|
|
66
|
-
* any `relativeOperatorMap` mapping) is returned alongside the prepared `value`.
|
|
67
|
-
*/
|
|
68
|
-
const materializeForExport = (apiFns, rule, opts, asDate = false) => {
|
|
69
|
-
const operator = resolveDatetimeOperator(rule, opts);
|
|
70
|
-
const materialized = materializeRelativeValues(apiFns, rule.value, opts);
|
|
71
|
-
let prepared = materialized;
|
|
72
|
-
if (Array.isArray(materialized) && materialized.length >= 2) {
|
|
73
|
-
const opLC = operator.toLowerCase();
|
|
74
|
-
if (opLC === "between" || opLC === "notbetween") {
|
|
75
|
-
const first = apiFns.toDate(materialized[0]);
|
|
76
|
-
const second = apiFns.toDate(materialized[1]);
|
|
77
|
-
if (apiFns.isValid(first) && apiFns.isValid(second) && !apiFns.isBefore(first, second)) prepared = [
|
|
78
|
-
materialized[1],
|
|
79
|
-
materialized[0],
|
|
80
|
-
...materialized.slice(2)
|
|
81
|
-
];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (!asDate) return {
|
|
85
|
-
operator,
|
|
86
|
-
value: prepared
|
|
87
|
-
};
|
|
88
|
-
const toDateVal = (v) => {
|
|
89
|
-
const d = apiFns.toDate(v);
|
|
90
|
-
return apiFns.isValid(d) ? d : v;
|
|
91
|
-
};
|
|
92
|
-
return {
|
|
93
|
-
operator,
|
|
94
|
-
value: Array.isArray(prepared) ? prepared.map(toDateVal) : toDateVal(prepared)
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
const defaultIsDateField = (...[rule, opts]) => rule.operator !== "contains" && rule.operator !== "beginsWith" && rule.operator !== "endsWith" && rule.operator !== "doesNotContain" && rule.operator !== "doesNotBeginWith" && rule.operator !== "doesNotEndWith" && rule.operator !== "null" && rule.operator !== "notNull" && /^(?:date|datetime|datetimeoffset|timestamp)\b/i.test(opts?.fieldData?.datatype);
|
|
98
|
-
const processIsDateField = (isDateField, ...[rule, opts]) => {
|
|
99
|
-
if (typeof isDateField === "boolean") return isDateField;
|
|
100
|
-
if (typeof isDateField === "function") return isDateField(rule, opts);
|
|
101
|
-
if (Array.isArray(isDateField)) return isDateField.some((condition) => Object.entries(condition).every(([key, value]) => opts?.fieldData?.[key] === value));
|
|
102
|
-
if (typeof isDateField === "object") return Object.entries(isDateField).every(([key, value]) => opts?.fieldData?.[key] === value);
|
|
103
|
-
return defaultIsDateField(rule, opts);
|
|
104
|
-
};
|
|
105
|
-
//#endregion
|
|
1
|
+
const require_utils = require("./utils-_X97pUtk.js");
|
|
2
|
+
let _react_querybuilder_core = require("@react-querybuilder/core");
|
|
106
3
|
//#region src/getDatetimeJsonLogicOperations.ts
|
|
107
4
|
/**
|
|
108
5
|
* Custom operations for use with JsonLogic objects generated by
|
|
@@ -122,7 +19,7 @@ const getDatetimeJsonLogicOperations = (apiFns) => {
|
|
|
122
19
|
dateOnOrAfter: (a, b) => isAfter(a, b) || isSame(a, b),
|
|
123
20
|
dateOnOrBefore: (a, b) => isBefore(a, b) || isSame(a, b),
|
|
124
21
|
dateRelative: (anchor, offset, unit, dateOnly) => {
|
|
125
|
-
const resolved = resolveRelativeDateTime(apiFns, {
|
|
22
|
+
const resolved = require_utils.resolveRelativeDateTime(apiFns, {
|
|
126
23
|
mode: "relative",
|
|
127
24
|
anchor,
|
|
128
25
|
offset,
|
|
@@ -142,10 +39,10 @@ const shouldNegate$3 = (op) => /^(does)?not/i.test(op);
|
|
|
142
39
|
const getDatetimeRuleProcessorCEL = (apiFns) => (rule, options) => {
|
|
143
40
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
144
41
|
const { context = {} } = opts;
|
|
145
|
-
if (rule.valueSource
|
|
42
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorCEL)(rule, opts);
|
|
146
43
|
const ts = (d) => `timestamp("${apiFns.toISOString(d)}")`;
|
|
147
|
-
const value = materializeRelativeValues(apiFns, rule.value, opts);
|
|
148
|
-
const operatorTL = (0,
|
|
44
|
+
const value = require_utils.materializeRelativeValues(apiFns, rule.value, opts);
|
|
45
|
+
const operatorTL = (0, _react_querybuilder_core.lc)(require_utils.resolveDatetimeOperator(rule, opts).replace(/^=$/, "=="));
|
|
149
46
|
switch (operatorTL) {
|
|
150
47
|
case "<":
|
|
151
48
|
case "<=":
|
|
@@ -154,7 +51,7 @@ const getDatetimeRuleProcessorCEL = (apiFns) => (rule, options) => {
|
|
|
154
51
|
case ">":
|
|
155
52
|
case ">=": return `${rule.field} ${operatorTL} ${ts(value)}`;
|
|
156
53
|
}
|
|
157
|
-
const valueAsDateArray = (0,
|
|
54
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(value, { retainEmptyStrings: false }).map((v) => apiFns.toDate(v)).filter((dateVal) => apiFns.isValid(dateVal));
|
|
158
55
|
switch (operatorTL) {
|
|
159
56
|
case "in":
|
|
160
57
|
case "notin": {
|
|
@@ -170,7 +67,7 @@ const getDatetimeRuleProcessorCEL = (apiFns) => (rule, options) => {
|
|
|
170
67
|
return operatorTL === "between" ? `(${rule.field} >= ${ts(firstDate)} && ${rule.field} <= ${ts(secondDate)})` : `(${rule.field} < ${ts(firstDate)} || ${rule.field} > ${ts(secondDate)})`;
|
|
171
68
|
}
|
|
172
69
|
}
|
|
173
|
-
return (0,
|
|
70
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorCEL)(rule, opts);
|
|
174
71
|
};
|
|
175
72
|
//#endregion
|
|
176
73
|
//#region src/getDatetimeRuleProcessorCypher.ts
|
|
@@ -194,15 +91,16 @@ const cypherTemporal = (iso, dateOnly) => dateOnly ? `date('${iso}')` : `datetim
|
|
|
194
91
|
const getDatetimeRuleProcessorCypher = (apiFns) => (rule, options) => {
|
|
195
92
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
196
93
|
const { context = {} } = opts;
|
|
197
|
-
if (rule.valueSource
|
|
94
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorCypher)(rule, opts);
|
|
198
95
|
const { field } = rule;
|
|
199
|
-
const operatorTL = (0,
|
|
96
|
+
const operatorTL = (0, _react_querybuilder_core.lc)(require_utils.resolveDatetimeOperator(rule, opts));
|
|
200
97
|
if (operatorTL === "olderthanduration") return `datetime() - ${field} > duration('${rule.value}')`;
|
|
201
98
|
if (operatorTL === "withinduration") return `datetime() - ${field} <= duration('${rule.value}')`;
|
|
202
|
-
const valueAsDateArray = (0,
|
|
99
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(require_utils.materializeRelativeValues(apiFns, rule.value, opts), { retainEmptyStrings: false }).map((v) => [v, apiFns.toDate(v)]).filter(([, d]) => apiFns.isValid(d));
|
|
203
100
|
const fmtDate = (originalValue) => {
|
|
204
|
-
const dateOnly = isISOStringDateOnly(originalValue);
|
|
205
|
-
|
|
101
|
+
const dateOnly = require_utils.isISOStringDateOnly(originalValue);
|
|
102
|
+
const iso = dateOnly ? apiFns.toISOStringDateOnly(originalValue) : apiFns.toISOString(originalValue);
|
|
103
|
+
return cypherTemporal(iso, dateOnly);
|
|
206
104
|
};
|
|
207
105
|
switch (operatorTL) {
|
|
208
106
|
case "in":
|
|
@@ -237,9 +135,9 @@ const getDatetimeRuleProcessorCypher = (apiFns) => (rule, options) => {
|
|
|
237
135
|
const getDatetimeRuleProcessorDrizzle = (apiFns) => (rule, options) => {
|
|
238
136
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
239
137
|
const { context = {} } = opts;
|
|
240
|
-
if (rule.valueSource
|
|
241
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts, true);
|
|
242
|
-
return (0,
|
|
138
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorDrizzle)(rule, opts);
|
|
139
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts, true);
|
|
140
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorDrizzle)({
|
|
243
141
|
...rule,
|
|
244
142
|
operator,
|
|
245
143
|
value
|
|
@@ -256,9 +154,9 @@ const getDatetimeRuleProcessorDrizzle = (apiFns) => (rule, options) => {
|
|
|
256
154
|
const getDatetimeRuleProcessorElasticSearch = (apiFns) => (rule, options) => {
|
|
257
155
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
258
156
|
const { context = {} } = opts;
|
|
259
|
-
if (rule.valueSource
|
|
260
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts);
|
|
261
|
-
return (0,
|
|
157
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorElasticSearch)(rule, opts);
|
|
158
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts);
|
|
159
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorElasticSearch)({
|
|
262
160
|
...rule,
|
|
263
161
|
operator,
|
|
264
162
|
value
|
|
@@ -275,9 +173,9 @@ const getDatetimeRuleProcessorElasticSearch = (apiFns) => (rule, options) => {
|
|
|
275
173
|
const getDatetimeRuleProcessorGremlin = (apiFns) => (rule, options) => {
|
|
276
174
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
277
175
|
const { context = {} } = opts;
|
|
278
|
-
if (rule.valueSource
|
|
279
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts);
|
|
280
|
-
return (0,
|
|
176
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorGremlin)(rule, opts);
|
|
177
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts);
|
|
178
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorGremlin)({
|
|
281
179
|
...rule,
|
|
282
180
|
operator,
|
|
283
181
|
value
|
|
@@ -297,11 +195,12 @@ const getDatetimeRuleProcessorJSONata = (apiFns) => (rule, options) => {
|
|
|
297
195
|
// v8 ignore next
|
|
298
196
|
const { quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "" } = opts;
|
|
299
197
|
const { field, valueSource } = rule;
|
|
300
|
-
const operator = resolveDatetimeOperator(rule, opts);
|
|
301
|
-
if (!processIsDateField(context.isDateField, rule, opts)) return (0,
|
|
198
|
+
const operator = require_utils.resolveDatetimeOperator(rule, opts);
|
|
199
|
+
if (!require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorJSONata)(rule, opts);
|
|
200
|
+
if (valueSource === "parameter") return (0, _react_querybuilder_core.defaultRuleProcessorJSONata)(rule, opts);
|
|
302
201
|
const valueIsField = valueSource === "field";
|
|
303
|
-
const value = valueIsField ? rule.value : materializeRelativeValues(apiFns, rule.value, opts);
|
|
304
|
-
const fldToMs = (f) => `$toMillis(${(0,
|
|
202
|
+
const value = valueIsField ? rule.value : require_utils.materializeRelativeValues(apiFns, rule.value, opts);
|
|
203
|
+
const fldToMs = (f) => `$toMillis(${(0, _react_querybuilder_core.getQuotedFieldName)(f, {
|
|
305
204
|
quoteFieldNamesWith,
|
|
306
205
|
fieldIdentifierSeparator
|
|
307
206
|
})})`;
|
|
@@ -314,7 +213,7 @@ const getDatetimeRuleProcessorJSONata = (apiFns) => (rule, options) => {
|
|
|
314
213
|
case ">":
|
|
315
214
|
case ">=": return `${fldToMs(field)} ${operator} ${valueIsField ? fldToMs(value) : valToMs(value)}`;
|
|
316
215
|
}
|
|
317
|
-
const valueAsArray = (0,
|
|
216
|
+
const valueAsArray = (0, _react_querybuilder_core.toArray)(value, { retainEmptyStrings: false });
|
|
318
217
|
const valueAsDateArray = valueAsArray.map((v) => apiFns.toDate(v)).filter((dateVal) => apiFns.isValid(dateVal));
|
|
319
218
|
switch (operator) {
|
|
320
219
|
case "in":
|
|
@@ -327,7 +226,7 @@ const getDatetimeRuleProcessorJSONata = (apiFns) => (rule, options) => {
|
|
|
327
226
|
return negate(`${fldToMs(field)} in [${valueAsDateArray.map((val) => valToMs(val)).join(", ")}]`, shouldNegate$1(operator));
|
|
328
227
|
case "between":
|
|
329
228
|
case "notBetween": {
|
|
330
|
-
if (valueAsArray.length < 2 || (0,
|
|
229
|
+
if (valueAsArray.length < 2 || (0, _react_querybuilder_core.nullOrUndefinedOrEmpty)(valueAsArray[0]) || (0, _react_querybuilder_core.nullOrUndefinedOrEmpty)(valueAsArray[1]) || !valueIsField && valueAsDateArray.length < 2) return "";
|
|
331
230
|
if (valueIsField) {
|
|
332
231
|
const [firstValue, secondValue] = valueAsArray;
|
|
333
232
|
const expression = `${fldToMs(field)} >= ${fldToMs(firstValue)} and ${fldToMs(field)} <= ${fldToMs(secondValue)}`;
|
|
@@ -339,7 +238,7 @@ const getDatetimeRuleProcessorJSONata = (apiFns) => (rule, options) => {
|
|
|
339
238
|
return operator === "between" ? `(${expression})` : negate(expression, true);
|
|
340
239
|
}
|
|
341
240
|
}
|
|
342
|
-
return (0,
|
|
241
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorJSONata)(rule, opts);
|
|
343
242
|
};
|
|
344
243
|
//#endregion
|
|
345
244
|
//#region src/getDatetimeRuleProcessorLDAP.ts
|
|
@@ -352,9 +251,9 @@ const getDatetimeRuleProcessorJSONata = (apiFns) => (rule, options) => {
|
|
|
352
251
|
const getDatetimeRuleProcessorLDAP = (apiFns) => (rule, options) => {
|
|
353
252
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
354
253
|
const { context = {} } = opts;
|
|
355
|
-
if (rule.valueSource
|
|
356
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts);
|
|
357
|
-
return (0,
|
|
254
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorLDAP)(rule, opts);
|
|
255
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts);
|
|
256
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorLDAP)({
|
|
358
257
|
...rule,
|
|
359
258
|
operator,
|
|
360
259
|
value
|
|
@@ -369,21 +268,21 @@ const getDatetimeRuleProcessorLDAP = (apiFns) => (rule, options) => {
|
|
|
369
268
|
const getDatetimeRuleProcessorMongoDBQuery = (apiFns) => (rule, options) => {
|
|
370
269
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
371
270
|
const { field, valueSource } = rule;
|
|
372
|
-
const operator = resolveDatetimeOperator(rule, opts);
|
|
373
|
-
if (valueSource
|
|
374
|
-
const value = materializeRelativeValues(apiFns, rule.value, opts);
|
|
271
|
+
const operator = require_utils.resolveDatetimeOperator(rule, opts);
|
|
272
|
+
if (require_utils.isNonDateValueSource(valueSource) || !require_utils.processIsDateField(opts.context?.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorMongoDBQuery)(rule, opts);
|
|
273
|
+
const value = require_utils.materializeRelativeValues(apiFns, rule.value, opts);
|
|
375
274
|
if (operator === "=") return { [field]: apiFns.toDate(value) };
|
|
376
275
|
switch (operator) {
|
|
377
276
|
case "<":
|
|
378
277
|
case "<=":
|
|
379
278
|
case "!=":
|
|
380
279
|
case ">":
|
|
381
|
-
case ">=": return { [field]: { [
|
|
280
|
+
case ">=": return { [field]: { [_react_querybuilder_core.mongoOperators[operator]]: apiFns.toDate(value) } };
|
|
382
281
|
}
|
|
383
|
-
const valueAsDateArray = (0,
|
|
282
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(value, { retainEmptyStrings: false }).map((v) => apiFns.toDate(v)).filter((dateVal) => apiFns.isValid(dateVal));
|
|
384
283
|
switch (operator) {
|
|
385
284
|
case "in":
|
|
386
|
-
case "notIn": return { [field]: { [
|
|
285
|
+
case "notIn": return { [field]: { [_react_querybuilder_core.mongoOperators[operator]]: valueAsDateArray } };
|
|
387
286
|
case "between":
|
|
388
287
|
case "notBetween": {
|
|
389
288
|
if (valueAsDateArray.length < 2) return "";
|
|
@@ -395,7 +294,7 @@ const getDatetimeRuleProcessorMongoDBQuery = (apiFns) => (rule, options) => {
|
|
|
395
294
|
} } : { $or: [{ [field]: { $lt: orderedArray[0] } }, { [field]: { $gt: orderedArray[1] } }] };
|
|
396
295
|
}
|
|
397
296
|
}
|
|
398
|
-
return (0,
|
|
297
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorMongoDBQuery)(rule, opts);
|
|
399
298
|
};
|
|
400
299
|
//#endregion
|
|
401
300
|
//#region src/getDatetimeRuleProcessorMongoDB.ts
|
|
@@ -429,7 +328,7 @@ const defaultDateTimeNLOperatorMap = {
|
|
|
429
328
|
* {@link @react-querybuilder/core!formatQuery formatQuery} with the "natural_language" format.
|
|
430
329
|
*/
|
|
431
330
|
const datetimeValueProcessorNL = (rule, opts) => {
|
|
432
|
-
if (isISOStringDateOnly(opts?.context?.originalValue)) return new Intl.DateTimeFormat(opts?.context?.locales, {
|
|
331
|
+
if (require_utils.isISOStringDateOnly(opts?.context?.originalValue)) return new Intl.DateTimeFormat(opts?.context?.locales, {
|
|
433
332
|
dateStyle: "full",
|
|
434
333
|
...opts?.context?.dateFormat
|
|
435
334
|
}).format(rule.value);
|
|
@@ -445,18 +344,18 @@ const datetimeValueProcessorNL = (rule, opts) => {
|
|
|
445
344
|
*/
|
|
446
345
|
const getDatetimeRuleProcessorNL = (apiFns) => (rule, options) => {
|
|
447
346
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
448
|
-
const operator = resolveDatetimeOperator(rule, opts);
|
|
449
|
-
const operatorLowerCase = (0,
|
|
347
|
+
const operator = require_utils.resolveDatetimeOperator(rule, opts);
|
|
348
|
+
const operatorLowerCase = (0, _react_querybuilder_core.lc)(operator);
|
|
450
349
|
let finalValue = "";
|
|
451
350
|
// v8 ignore next
|
|
452
|
-
const { fieldData, quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "", operatorProcessor =
|
|
453
|
-
if (!processIsDateField(context.isDateField, rule, opts)) return (0,
|
|
454
|
-
if (rule.valueSource
|
|
351
|
+
const { fieldData, quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "", operatorProcessor = _react_querybuilder_core.defaultOperatorProcessorNL, wordOrder = "SVO", context = {}, operatorMap = defaultDateTimeNLOperatorMap } = opts;
|
|
352
|
+
if (!require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorNL)(rule, opts);
|
|
353
|
+
if (require_utils.isNonDateValueSource(rule.valueSource)) return (0, _react_querybuilder_core.defaultRuleProcessorNL)(rule, {
|
|
455
354
|
...opts,
|
|
456
355
|
operatorMap: defaultDateTimeNLOperatorMap
|
|
457
356
|
});
|
|
458
357
|
if ((operatorLowerCase === "in" || operatorLowerCase === "notin" || operatorLowerCase === "between" || operatorLowerCase === "notbetween") && !rule.value) return "";
|
|
459
|
-
const valueAsDateArray = (0,
|
|
358
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(require_utils.materializeRelativeValues(apiFns, rule.value, opts), { retainEmptyStrings: false }).map((v) => [v, apiFns.toDate(v)]).filter((v) => apiFns.isValid(v[1]));
|
|
460
359
|
switch (operatorLowerCase) {
|
|
461
360
|
case "in":
|
|
462
361
|
case "notin":
|
|
@@ -507,7 +406,7 @@ const getDatetimeRuleProcessorNL = (apiFns) => (rule, options) => {
|
|
|
507
406
|
}
|
|
508
407
|
}
|
|
509
408
|
const wordOrderMap = {
|
|
510
|
-
S: (0,
|
|
409
|
+
S: (0, _react_querybuilder_core.getQuotedFieldName)(fieldData?.label ?? rule.field, {
|
|
511
410
|
quoteFieldNamesWith,
|
|
512
411
|
fieldIdentifierSeparator
|
|
513
412
|
}),
|
|
@@ -523,7 +422,7 @@ const getDatetimeRuleProcessorNL = (apiFns) => (rule, options) => {
|
|
|
523
422
|
}),
|
|
524
423
|
O: finalValue
|
|
525
424
|
};
|
|
526
|
-
return (0,
|
|
425
|
+
return (0, _react_querybuilder_core.normalizeConstituentWordOrder)(wordOrder).map((term) => `${wordOrderMap[term]}`).join(" ").trim();
|
|
527
426
|
};
|
|
528
427
|
//#endregion
|
|
529
428
|
//#region src/getDatetimeRuleProcessorParameterized.ts
|
|
@@ -536,9 +435,9 @@ const getDatetimeRuleProcessorNL = (apiFns) => (rule, options) => {
|
|
|
536
435
|
const getDatetimeRuleProcessorParameterized = (apiFns) => (rule, options, meta) => {
|
|
537
436
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
538
437
|
const { context = {} } = opts;
|
|
539
|
-
if (rule.valueSource
|
|
540
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts);
|
|
541
|
-
return (0,
|
|
438
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorParameterized)(rule, opts, meta);
|
|
439
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts);
|
|
440
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorParameterized)({
|
|
542
441
|
...rule,
|
|
543
442
|
operator,
|
|
544
443
|
value
|
|
@@ -555,9 +454,9 @@ const getDatetimeRuleProcessorParameterized = (apiFns) => (rule, options, meta)
|
|
|
555
454
|
const getDatetimeRuleProcessorPrisma = (apiFns) => (rule, options) => {
|
|
556
455
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
557
456
|
const { context = {} } = opts;
|
|
558
|
-
if (rule.valueSource
|
|
559
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts, true);
|
|
560
|
-
return (0,
|
|
457
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorPrisma)(rule, opts);
|
|
458
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts, true);
|
|
459
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorPrisma)({
|
|
561
460
|
...rule,
|
|
562
461
|
operator,
|
|
563
462
|
value
|
|
@@ -574,9 +473,9 @@ const getDatetimeRuleProcessorPrisma = (apiFns) => (rule, options) => {
|
|
|
574
473
|
const getDatetimeRuleProcessorSequelize = (apiFns) => (rule, options) => {
|
|
575
474
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
576
475
|
const { context = {} } = opts;
|
|
577
|
-
if (rule.valueSource
|
|
578
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts, true);
|
|
579
|
-
return (0,
|
|
476
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorSequelize)(rule, opts);
|
|
477
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts, true);
|
|
478
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorSequelize)({
|
|
580
479
|
...rule,
|
|
581
480
|
operator,
|
|
582
481
|
value
|
|
@@ -604,17 +503,18 @@ const sparqlTemporal = (iso, dateOnly) => dateOnly ? `"${iso}"^^xsd:date` : `"${
|
|
|
604
503
|
const getDatetimeRuleProcessorSPARQL = (apiFns) => (rule, options) => {
|
|
605
504
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
606
505
|
const { context = {} } = opts;
|
|
607
|
-
if (rule.valueSource
|
|
506
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorSPARQL)(rule, opts);
|
|
608
507
|
const { field: rawField, value } = rule;
|
|
609
|
-
const operator = resolveDatetimeOperator(rule, opts);
|
|
610
|
-
const field = (0,
|
|
611
|
-
const operatorTL = (0,
|
|
508
|
+
const operator = require_utils.resolveDatetimeOperator(rule, opts);
|
|
509
|
+
const field = (0, _react_querybuilder_core.sparqlVar)(rawField);
|
|
510
|
+
const operatorTL = (0, _react_querybuilder_core.lc)(operator);
|
|
612
511
|
if (operatorTL === "olderthanduration") return `NOW() - ${field} > "${value}"^^xsd:duration`;
|
|
613
512
|
if (operatorTL === "withinduration") return `NOW() - ${field} <= "${value}"^^xsd:duration`;
|
|
614
|
-
const valueAsDateArray = (0,
|
|
513
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(require_utils.materializeRelativeValues(apiFns, value, opts), { retainEmptyStrings: false }).map((v) => [v, apiFns.toDate(v)]).filter(([, d]) => apiFns.isValid(d));
|
|
615
514
|
const fmtDate = (originalValue) => {
|
|
616
|
-
const dateOnly = isISOStringDateOnly(originalValue);
|
|
617
|
-
|
|
515
|
+
const dateOnly = require_utils.isISOStringDateOnly(originalValue);
|
|
516
|
+
const iso = dateOnly ? apiFns.toISOStringDateOnly(originalValue) : apiFns.toISOString(originalValue);
|
|
517
|
+
return sparqlTemporal(iso, dateOnly);
|
|
618
518
|
};
|
|
619
519
|
switch (operatorTL) {
|
|
620
520
|
case "in":
|
|
@@ -649,9 +549,9 @@ const getDatetimeRuleProcessorSPARQL = (apiFns) => (rule, options) => {
|
|
|
649
549
|
const getDatetimeRuleProcessorSpEL = (apiFns) => (rule, options) => {
|
|
650
550
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
651
551
|
const { context = {} } = opts;
|
|
652
|
-
if (rule.valueSource
|
|
653
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts);
|
|
654
|
-
return (0,
|
|
552
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorSpEL)(rule, opts);
|
|
553
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts);
|
|
554
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorSpEL)({
|
|
655
555
|
...rule,
|
|
656
556
|
operator,
|
|
657
557
|
value
|
|
@@ -825,11 +725,11 @@ const getRelativeDateTimeSQL = (value, preset, datatype) => presetToRelativeBuil
|
|
|
825
725
|
* {@link @react-querybuilder/core!formatQuery formatQuery} with the "sql" format and "ansi" preset.
|
|
826
726
|
*/
|
|
827
727
|
const getDatetimeValueProcessorANSI = ({ toISOStringDateOnly, toISOString }) => (rule, opts) => {
|
|
828
|
-
if (isISOStringDateOnly(opts?.context?.originalValue)) return (0,
|
|
728
|
+
if (require_utils.isISOStringDateOnly(opts?.context?.originalValue)) return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
829
729
|
...rule,
|
|
830
730
|
value: toISOStringDateOnly(rule.value)
|
|
831
731
|
}, opts);
|
|
832
|
-
return (0,
|
|
732
|
+
return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
833
733
|
...rule,
|
|
834
734
|
value: toISOString(rule.value)
|
|
835
735
|
}, opts);
|
|
@@ -841,7 +741,7 @@ const getDatetimeValueProcessorANSI = ({ toISOStringDateOnly, toISOString }) =>
|
|
|
841
741
|
const getDatetimeValueProcessorMSSQL = ({ toISOStringDateOnly, toISOString }) => (rule, opts) => {
|
|
842
742
|
const datatype = /^(?:small)?datetime/i.test(opts?.fieldData?.datatype) ? "datetimeoffset" : "date";
|
|
843
743
|
const value = datatype === "datetimeoffset" ? toISOString(rule.value) : toISOStringDateOnly(rule.value);
|
|
844
|
-
return (0,
|
|
744
|
+
return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
845
745
|
...rule,
|
|
846
746
|
value
|
|
847
747
|
}, {
|
|
@@ -856,7 +756,7 @@ const getDatetimeValueProcessorMSSQL = ({ toISOStringDateOnly, toISOString }) =>
|
|
|
856
756
|
const getDatetimeValueProcessorMySQL = ({ toISOStringDateOnly, toISOString }) => (rule, opts) => {
|
|
857
757
|
const datatype = /^(?:datetime|timestamp)/i.test(opts?.fieldData?.datatype) ? "datetime" : "date";
|
|
858
758
|
const value = datatype === "datetime" ? toISOString(rule.value) : toISOStringDateOnly(rule.value);
|
|
859
|
-
return (0,
|
|
759
|
+
return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
860
760
|
...rule,
|
|
861
761
|
value
|
|
862
762
|
}, {
|
|
@@ -871,7 +771,7 @@ const getDatetimeValueProcessorMySQL = ({ toISOStringDateOnly, toISOString }) =>
|
|
|
871
771
|
const getDatetimeValueProcessorOracle = ({ toISOStringDateOnly, toISOString }) => (rule, opts) => {
|
|
872
772
|
const datatype = /^timestamp/i.test(opts?.fieldData?.datatype) ? "timestamp" : "date";
|
|
873
773
|
const value = datatype === "timestamp" ? toISOString(rule.value).replaceAll("T", " ").replace("Z", " UTC") : toISOStringDateOnly(rule.value);
|
|
874
|
-
return (0,
|
|
774
|
+
return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
875
775
|
...rule,
|
|
876
776
|
value
|
|
877
777
|
}, {
|
|
@@ -886,7 +786,7 @@ const getDatetimeValueProcessorOracle = ({ toISOStringDateOnly, toISOString }) =
|
|
|
886
786
|
const getDatetimeValueProcessorPostgreSQL = ({ toISOStringDateOnly, toISOString }) => (rule, opts) => {
|
|
887
787
|
const datatype = /^timestamp/i.test(opts?.fieldData?.datatype) ? "timestamp" : "date";
|
|
888
788
|
const value = datatype === "timestamp" ? toISOString(rule.value) : toISOStringDateOnly(rule.value);
|
|
889
|
-
return (0,
|
|
789
|
+
return (0, _react_querybuilder_core.defaultValueProcessorByRule)({
|
|
890
790
|
...rule,
|
|
891
791
|
value
|
|
892
792
|
}, {
|
|
@@ -908,22 +808,22 @@ const presetToValueProcessorMap = {
|
|
|
908
808
|
*/
|
|
909
809
|
const getDatetimeRuleProcessorSQL = (apiFns) => (rule, options) => {
|
|
910
810
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
911
|
-
const operator = (0,
|
|
912
|
-
const operatorLowerCase = (0,
|
|
811
|
+
const operator = (0, _react_querybuilder_core.mapSQLOperator)(require_utils.resolveDatetimeOperator(rule, opts));
|
|
812
|
+
const operatorLowerCase = (0, _react_querybuilder_core.lc)(operator);
|
|
913
813
|
// v8 ignore next
|
|
914
814
|
const { quoteFieldNamesWith = ["", ""], fieldIdentifierSeparator = "", context = {} } = opts;
|
|
915
815
|
let finalValue = "";
|
|
916
|
-
if (rule.valueSource
|
|
816
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorSQL)(rule, opts);
|
|
917
817
|
const valueProcessor = presetToValueProcessorMap[opts.preset](apiFns);
|
|
918
|
-
const quotedField = (0,
|
|
818
|
+
const quotedField = (0, _react_querybuilder_core.getQuotedFieldName)(rule.field, {
|
|
919
819
|
quoteFieldNamesWith,
|
|
920
820
|
fieldIdentifierSeparator
|
|
921
821
|
});
|
|
922
|
-
const ruleValue = context.materializeRelativeDateTime ? materializeRelativeValues(apiFns, rule.value, opts) : rule.value;
|
|
822
|
+
const ruleValue = context.materializeRelativeDateTime ? require_utils.materializeRelativeValues(apiFns, rule.value, opts) : rule.value;
|
|
923
823
|
const rawValues = Array.isArray(ruleValue) ? ruleValue : [ruleValue];
|
|
924
|
-
if (rawValues.some(isRelativeDateTimeValue)) {
|
|
824
|
+
if (rawValues.some(require_utils.isRelativeDateTimeValue)) {
|
|
925
825
|
const exprFor = (v) => {
|
|
926
|
-
if (isRelativeDateTimeValue(v)) return getRelativeDateTimeSQL(v, opts.preset, opts.fieldData?.datatype);
|
|
826
|
+
if (require_utils.isRelativeDateTimeValue(v)) return getRelativeDateTimeSQL(v, opts.preset, opts.fieldData?.datatype);
|
|
927
827
|
const dateVal = apiFns.toDate(v);
|
|
928
828
|
if (!apiFns.isValid(dateVal)) return void 0;
|
|
929
829
|
return valueProcessor({
|
|
@@ -961,7 +861,7 @@ const getDatetimeRuleProcessorSQL = (apiFns) => (rule, options) => {
|
|
|
961
861
|
}
|
|
962
862
|
return `${quotedField} ${operator} ${finalValue}`.trim();
|
|
963
863
|
}
|
|
964
|
-
const valueAsDateArray = (0,
|
|
864
|
+
const valueAsDateArray = (0, _react_querybuilder_core.toArray)(ruleValue, { retainEmptyStrings: false }).map((v) => [v, apiFns.toDate(v)]).filter((v) => apiFns.isValid(v[1]));
|
|
965
865
|
switch (operatorLowerCase) {
|
|
966
866
|
case "in":
|
|
967
867
|
case "not in":
|
|
@@ -1015,9 +915,9 @@ const getDatetimeRuleProcessorSQL = (apiFns) => (rule, options) => {
|
|
|
1015
915
|
const getDatetimeRuleProcessorTanStackDB = (apiFns) => (rule, options) => {
|
|
1016
916
|
const opts = options ?? ( /* v8 ignore start -- @preserve */ {});
|
|
1017
917
|
const { context = {} } = opts;
|
|
1018
|
-
if (rule.valueSource
|
|
1019
|
-
const { operator, value } = materializeForExport(apiFns, rule, opts, true);
|
|
1020
|
-
return (0,
|
|
918
|
+
if (require_utils.isNonDateValueSource(rule.valueSource) || !require_utils.processIsDateField(context.isDateField, rule, opts)) return (0, _react_querybuilder_core.defaultRuleProcessorTanStackDB)(rule, opts);
|
|
919
|
+
const { operator, value } = require_utils.materializeForExport(apiFns, rule, opts, true);
|
|
920
|
+
return (0, _react_querybuilder_core.defaultRuleProcessorTanStackDB)({
|
|
1021
921
|
...rule,
|
|
1022
922
|
operator,
|
|
1023
923
|
value
|
|
@@ -1174,35 +1074,5 @@ Object.defineProperty(exports, "getDatetimeValueProcessorPostgreSQL", {
|
|
|
1174
1074
|
return getDatetimeValueProcessorPostgreSQL;
|
|
1175
1075
|
}
|
|
1176
1076
|
});
|
|
1177
|
-
Object.defineProperty(exports, "isDateOnlyDatatype", {
|
|
1178
|
-
enumerable: true,
|
|
1179
|
-
get: function() {
|
|
1180
|
-
return isDateOnlyDatatype;
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
Object.defineProperty(exports, "isISOStringDateOnly", {
|
|
1184
|
-
enumerable: true,
|
|
1185
|
-
get: function() {
|
|
1186
|
-
return isISOStringDateOnly;
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
Object.defineProperty(exports, "isRelativeDateTimeValue", {
|
|
1190
|
-
enumerable: true,
|
|
1191
|
-
get: function() {
|
|
1192
|
-
return isRelativeDateTimeValue;
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
|
-
Object.defineProperty(exports, "processIsDateField", {
|
|
1196
|
-
enumerable: true,
|
|
1197
|
-
get: function() {
|
|
1198
|
-
return processIsDateField;
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
Object.defineProperty(exports, "resolveDatetimeOperator", {
|
|
1202
|
-
enumerable: true,
|
|
1203
|
-
get: function() {
|
|
1204
|
-
return resolveDatetimeOperator;
|
|
1205
|
-
}
|
|
1206
|
-
});
|
|
1207
1077
|
|
|
1208
|
-
//# sourceMappingURL=getDatetimeRuleProcessorTanStackDB-
|
|
1078
|
+
//# sourceMappingURL=getDatetimeRuleProcessorTanStackDB-CDEB9coD.js.map
|