@react-querybuilder/datetime 8.20.2 → 8.21.1
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-cmGqMT0Q.js → getDatetimeRuleProcessorTanStackDB-CDEB9coD.js} +22 -19
- 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 +122 -138
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js +3 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +52 -53
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +100 -114
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js +5 -3
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +122 -138
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +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 +52 -53
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.d.ts +100 -114
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -1
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js} +2 -2
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js.map → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map} +1 -1
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js} +2 -2
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js.map → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map} +1 -1
- package/dist/cjs/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
- package/dist/cjs/utils-DdBYGWHZ.js +2 -0
- package/dist/cjs/utils-DdBYGWHZ.js.map +1 -0
- package/dist/cjs/{utils-DUePrC--.js → utils-_X97pUtk.js} +13 -1
- 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-BDFJlfJh.js → getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js} +22 -19
- package/dist/getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js.map +1 -0
- package/dist/{getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs → getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs} +22 -19
- package/dist/getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs.map +1 -0
- package/dist/{objectSpread2-73AKOozq.js → objectSpread2-MqoZ2hSz.js} +13 -7
- package/dist/objectSpread2-MqoZ2hSz.js.map +1 -0
- package/dist/react-querybuilder_datetime.d.mts +122 -138
- package/dist/react-querybuilder_datetime.date-fns.d.mts +49 -50
- package/dist/react-querybuilder_datetime.date-fns.mjs +2 -2
- package/dist/react-querybuilder_datetime.dayjs.d.mts +49 -50
- package/dist/react-querybuilder_datetime.dayjs.mjs +2 -2
- package/dist/react-querybuilder_datetime.jsdate.d.mts +52 -53
- package/dist/react-querybuilder_datetime.jsdate.mjs +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.d.ts +122 -138
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.js +3 -2
- package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +52 -53
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +100 -114
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js +7 -5
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js.map +1 -1
- package/dist/react-querybuilder_datetime.luxon.d.mts +49 -50
- package/dist/react-querybuilder_datetime.luxon.mjs +2 -2
- package/dist/react-querybuilder_datetime.mjs +3 -2
- package/dist/react-querybuilder_datetime.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.d.mts +122 -138
- package/dist/react-querybuilder_datetime.production.date-fns.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.d.mts +52 -53
- package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.luxon.mjs +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 +100 -114
- package/dist/react-querybuilder_datetime.production.ui.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.ui.d.mts +100 -114
- package/dist/react-querybuilder_datetime.ui.mjs +5 -3
- package/dist/react-querybuilder_datetime.ui.mjs.map +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js.map → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map} +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs.map → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map} +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs.map → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map} +1 -1
- package/dist/{types-Di8kFIXV.d.mts → types-BKA1aoY6.d.mts} +82 -73
- package/dist/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
- package/dist/{utils-BC2SALFm.mjs → utils-BAgUBdyf.mjs} +8 -2
- 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 +16 -16
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js +0 -2
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js.map +0 -1
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js.map +0 -1
- package/dist/cjs/utils-DUePrC--.js.map +0 -1
- package/dist/cjs/utils-jkW5R1AA.js +0 -2
- package/dist/cjs/utils-jkW5R1AA.js.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs +0 -2
- package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs.map +0 -1
- package/dist/objectSpread2-73AKOozq.js.map +0 -1
- package/dist/utils-BC2SALFm.mjs.map +0 -1
- package/dist/utils-VKS8YY2D.mjs +0 -2
- package/dist/utils-VKS8YY2D.mjs.map +0 -1
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { _ as RelativeDateTimeAnchor, b as RelativeDateTimeValue, i as RQBDateTimeLibraryAPI, y as RelativeDateTimeUnit } from "./types-
|
|
1
|
+
import { _ as RelativeDateTimeAnchor, b as RelativeDateTimeValue, i as RQBDateTimeLibraryAPI, y as RelativeDateTimeUnit } from "./types-BKA1aoY6.js";
|
|
2
2
|
import { FullOption } from "@react-querybuilder/core";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { FullOperator, FullOption as FullOption$1, QueryBuilderContextProvider, ValueEditorProps } from "react-querybuilder";
|
|
6
|
-
|
|
7
6
|
//#region src/ui/types.d.ts
|
|
8
7
|
/**
|
|
9
|
-
* Customizable content/labels for the absolute/relative mode toggle rendered by
|
|
10
|
-
* {@link toggleModeController}. The default glyphs come from CSS pseudo-elements, so
|
|
11
|
-
* `absoluteContent`/`relativeContent` are only needed to override them (e.g. to render
|
|
12
|
-
* an icon component or localized text).
|
|
13
|
-
*/
|
|
8
|
+
* Customizable content/labels for the absolute/relative mode toggle rendered by
|
|
9
|
+
* {@link toggleModeController}. The default glyphs come from CSS pseudo-elements, so
|
|
10
|
+
* `absoluteContent`/`relativeContent` are only needed to override them (e.g. to render
|
|
11
|
+
* an icon component or localized text).
|
|
12
|
+
*/
|
|
14
13
|
interface RelativeDateTimeToggleLabels {
|
|
15
14
|
/** Accessible label (`aria-label`) for the toggle button. */
|
|
16
15
|
label?: string;
|
|
@@ -24,10 +23,10 @@ interface RelativeDateTimeToggleLabels {
|
|
|
24
23
|
relativeContent?: ReactNode;
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
|
-
* Props passed to a {@link RelativeDateTimeModeController}'s `ModeControl` component —
|
|
28
|
-
* the affordance (e.g. a toggle button) that switches a rule between absolute and
|
|
29
|
-
* relative date/time entry.
|
|
30
|
-
*/
|
|
26
|
+
* Props passed to a {@link RelativeDateTimeModeController}'s `ModeControl` component —
|
|
27
|
+
* the affordance (e.g. a toggle button) that switches a rule between absolute and
|
|
28
|
+
* relative date/time entry.
|
|
29
|
+
*/
|
|
31
30
|
interface RelativeDateTimeModeControlProps {
|
|
32
31
|
/** Whether the rule is currently in relative mode. */
|
|
33
32
|
isRelative: boolean;
|
|
@@ -47,30 +46,30 @@ interface RelativeDateTimeModeControlProps {
|
|
|
47
46
|
labels: Required<RelativeDateTimeToggleLabels>;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
|
-
* A pluggable strategy that governs how a user switches between absolute and relative
|
|
51
|
-
* date/time entry in the {@link RelativeDateTimeValueEditor}. The stored value shape is
|
|
52
|
-
* unaffected — a controller only decides the current mode and (optionally) renders an
|
|
53
|
-
* affordance to change it.
|
|
54
|
-
*
|
|
55
|
-
* Ships with {@link toggleModeController} (the zero-config default); build an
|
|
56
|
-
* operator-driven controller with {@link createOperatorModeController}, or supply a custom
|
|
57
|
-
* object to fully control the UX.
|
|
58
|
-
*/
|
|
49
|
+
* A pluggable strategy that governs how a user switches between absolute and relative
|
|
50
|
+
* date/time entry in the {@link RelativeDateTimeValueEditor}. The stored value shape is
|
|
51
|
+
* unaffected — a controller only decides the current mode and (optionally) renders an
|
|
52
|
+
* affordance to change it.
|
|
53
|
+
*
|
|
54
|
+
* Ships with {@link toggleModeController} (the zero-config default); build an
|
|
55
|
+
* operator-driven controller with {@link createOperatorModeController}, or supply a custom
|
|
56
|
+
* object to fully control the UX.
|
|
57
|
+
*/
|
|
59
58
|
interface RelativeDateTimeModeController {
|
|
60
59
|
/** Derives the current mode from the rule (its operator and/or value). */
|
|
61
60
|
isRelative: (props: ValueEditorProps) => boolean;
|
|
62
61
|
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
* Optional affordance rendered inside the editor to switch modes. Omit it (as the
|
|
63
|
+
* operator-driven controller does) when the mode is selected elsewhere, e.g. via the
|
|
64
|
+
* operator selector.
|
|
65
|
+
*/
|
|
67
66
|
ModeControl?: ComponentType<RelativeDateTimeModeControlProps>;
|
|
68
67
|
}
|
|
69
68
|
/**
|
|
70
|
-
* Configuration for the {@link RelativeDateTimeValueEditor}, supplied as props to
|
|
71
|
-
* {@link QueryBuilderDateTime} (or via the relative date/time config context). Every
|
|
72
|
-
* field is optional; omitting all of them yields the zero-config toggle experience.
|
|
73
|
-
*/
|
|
69
|
+
* Configuration for the {@link RelativeDateTimeValueEditor}, supplied as props to
|
|
70
|
+
* {@link QueryBuilderDateTime} (or via the relative date/time config context). Every
|
|
71
|
+
* field is optional; omitting all of them yields the zero-config toggle experience.
|
|
72
|
+
*/
|
|
74
73
|
interface RelativeDateTimeEditorConfig {
|
|
75
74
|
/** Strategy for switching between absolute and relative modes. Defaults to {@link toggleModeController}. */
|
|
76
75
|
modeController?: RelativeDateTimeModeController;
|
|
@@ -81,28 +80,28 @@ interface RelativeDateTimeEditorConfig {
|
|
|
81
80
|
/** Content/labels for the absolute/relative toggle. */
|
|
82
81
|
toggleLabels?: RelativeDateTimeToggleLabels;
|
|
83
82
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
* Date/time library adapter used by the value editor to parse/validate the rule value
|
|
84
|
+
* for the native date input. Defaults to the plain JavaScript adapter. Pass the adapter
|
|
85
|
+
* matching your chosen entry point (e.g. from `@react-querybuilder/datetime/luxon`) so the
|
|
86
|
+
* editor interprets values consistently with the rule processors.
|
|
87
|
+
*/
|
|
89
88
|
dateTimeAPI?: RQBDateTimeLibraryAPI;
|
|
90
89
|
}
|
|
91
90
|
/**
|
|
92
|
-
* Maps operator names that are used only to _signal_ relative mode (see
|
|
93
|
-
* {@link createOperatorModeController}) to the real comparison operator that should be used
|
|
94
|
-
* when exporting via `formatQuery`. Supplied through `context.relativeOperatorMap`. Operators
|
|
95
|
-
* not present in the map are exported unchanged.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* formatQuery(query, {
|
|
100
|
-
* format: 'sql',
|
|
101
|
-
* ruleProcessor: datetimeRuleProcessorSQL,
|
|
102
|
-
* context: { relativeOperatorMap: { relativeEq: '=' } },
|
|
103
|
-
* });
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
91
|
+
* Maps operator names that are used only to _signal_ relative mode (see
|
|
92
|
+
* {@link createOperatorModeController}) to the real comparison operator that should be used
|
|
93
|
+
* when exporting via `formatQuery`. Supplied through `context.relativeOperatorMap`. Operators
|
|
94
|
+
* not present in the map are exported unchanged.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* formatQuery(query, {
|
|
99
|
+
* format: 'sql',
|
|
100
|
+
* ruleProcessor: datetimeRuleProcessorSQL,
|
|
101
|
+
* context: { relativeOperatorMap: { relativeEq: '=' } },
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
106
105
|
type RelativeOperatorMap = Record<string, string>;
|
|
107
106
|
//#endregion
|
|
108
107
|
//#region src/ui/QueryBuilderDateTime.d.ts
|
|
@@ -113,22 +112,15 @@ interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
|
|
|
113
112
|
children?: React.ReactNode;
|
|
114
113
|
}
|
|
115
114
|
/**
|
|
116
|
-
* Context provider enabling date/time features for a wrapped
|
|
117
|
-
* {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable
|
|
118
|
-
* {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional
|
|
119
|
-
* {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and
|
|
120
|
-
* toggle labels). With no props it provides the zero-config toggle experience.
|
|
121
|
-
*
|
|
122
|
-
* @group Components
|
|
123
|
-
*/
|
|
124
|
-
declare const QueryBuilderDateTime: ({
|
|
125
|
-
children,
|
|
126
|
-
modeController,
|
|
127
|
-
anchors,
|
|
128
|
-
units,
|
|
129
|
-
toggleLabels,
|
|
130
|
-
dateTimeAPI
|
|
131
|
-
}: QueryBuilderDateTimeProps) => React.JSX.Element;
|
|
115
|
+
* Context provider enabling date/time features for a wrapped
|
|
116
|
+
* {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable
|
|
117
|
+
* {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional
|
|
118
|
+
* {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and
|
|
119
|
+
* toggle labels). With no props it provides the zero-config toggle experience.
|
|
120
|
+
*
|
|
121
|
+
* @group Components
|
|
122
|
+
*/
|
|
123
|
+
declare const QueryBuilderDateTime: ({ children, modeController, anchors, units, toggleLabels, dateTimeAPI }: QueryBuilderDateTimeProps) => React.JSX.Element;
|
|
132
124
|
//#endregion
|
|
133
125
|
//#region src/ui/RelativeDateTimeConfigContext.d.ts
|
|
134
126
|
/** Fully-resolved relative date/time editor config (no optional fields). */
|
|
@@ -140,35 +132,35 @@ interface ResolvedRelativeDateTimeConfig {
|
|
|
140
132
|
dateTimeAPI: RQBDateTimeLibraryAPI;
|
|
141
133
|
}
|
|
142
134
|
/**
|
|
143
|
-
* Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.
|
|
144
|
-
* Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.
|
|
145
|
-
*/
|
|
135
|
+
* Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.
|
|
136
|
+
* Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.
|
|
137
|
+
*/
|
|
146
138
|
declare const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig>;
|
|
147
139
|
/** Reads the relative date/time editor config from context, merged with defaults. */
|
|
148
140
|
declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
|
|
149
141
|
//#endregion
|
|
150
142
|
//#region src/ui/RelativeDateTimeValueEditor.d.ts
|
|
151
143
|
/**
|
|
152
|
-
* Value editor with support for {@link RelativeDateTimeValue relative date/time values}
|
|
153
|
-
* (e.g. "three months ago" or "the beginning of this year"). How the user switches
|
|
154
|
-
* between absolute and relative modes is delegated to a pluggable
|
|
155
|
-
* {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via
|
|
156
|
-
* {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit
|
|
157
|
-
* selectors; the unit selector is hidden when the offset is `0`.
|
|
158
|
-
*
|
|
159
|
-
* For the `between`/`notBetween` operators it renders two independent value editors (each
|
|
160
|
-
* with its own mode affordance) and stores the bounds as a two-element array, so the from
|
|
161
|
-
* and to bounds can independently be absolute or relative.
|
|
162
|
-
*
|
|
163
|
-
* @group Components
|
|
164
|
-
*/
|
|
144
|
+
* Value editor with support for {@link RelativeDateTimeValue relative date/time values}
|
|
145
|
+
* (e.g. "three months ago" or "the beginning of this year"). How the user switches
|
|
146
|
+
* between absolute and relative modes is delegated to a pluggable
|
|
147
|
+
* {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via
|
|
148
|
+
* {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit
|
|
149
|
+
* selectors; the unit selector is hidden when the offset is `0`.
|
|
150
|
+
*
|
|
151
|
+
* For the `between`/`notBetween` operators it renders two independent value editors (each
|
|
152
|
+
* with its own mode affordance) and stores the bounds as a two-element array, so the from
|
|
153
|
+
* and to bounds can independently be absolute or relative.
|
|
154
|
+
*
|
|
155
|
+
* @group Components
|
|
156
|
+
*/
|
|
165
157
|
declare const RelativeDateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
|
|
166
158
|
//#endregion
|
|
167
159
|
//#region src/ui/relativeDateTimeConstants.d.ts
|
|
168
160
|
/**
|
|
169
|
-
* Class name applied to the absolute/relative mode toggle button. Package-local (not part
|
|
170
|
-
* of the core `standardClassnames`) to avoid coupling core to this extension.
|
|
171
|
-
*/
|
|
161
|
+
* Class name applied to the absolute/relative mode toggle button. Package-local (not part
|
|
162
|
+
* of the core `standardClassnames`) to avoid coupling core to this extension.
|
|
163
|
+
*/
|
|
172
164
|
declare const relativeDateTimeToggleClassName = "rule-value-dateTimeRelative-toggle";
|
|
173
165
|
/** Default value applied when switching a rule to relative mode. */
|
|
174
166
|
declare const defaultRelativeDateTimeValue: RelativeDateTimeValue;
|
|
@@ -181,47 +173,41 @@ declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeTogg
|
|
|
181
173
|
//#endregion
|
|
182
174
|
//#region src/ui/relativeDateTimeModeControllers.d.ts
|
|
183
175
|
/**
|
|
184
|
-
* Compact absolute/relative toggle rendered by {@link toggleModeController}. A
|
|
185
|
-
* `role="switch"` button whose default glyph is supplied by CSS (keyed on
|
|
186
|
-
* `aria-checked`); override via the `toggleLabels` config.
|
|
187
|
-
*
|
|
188
|
-
* @group Components
|
|
189
|
-
*/
|
|
190
|
-
declare const RelativeDateTimeModeToggle: ({
|
|
191
|
-
isRelative,
|
|
192
|
-
setMode,
|
|
193
|
-
disabled,
|
|
194
|
-
className,
|
|
195
|
-
labels
|
|
196
|
-
}: RelativeDateTimeModeControlProps) => React.JSX.Element;
|
|
176
|
+
* Compact absolute/relative toggle rendered by {@link toggleModeController}. A
|
|
177
|
+
* `role="switch"` button whose default glyph is supplied by CSS (keyed on
|
|
178
|
+
* `aria-checked`); override via the `toggleLabels` config.
|
|
179
|
+
*
|
|
180
|
+
* @group Components
|
|
181
|
+
*/
|
|
182
|
+
declare const RelativeDateTimeModeToggle: ({ isRelative, setMode, disabled, className, labels }: RelativeDateTimeModeControlProps) => React.JSX.Element;
|
|
197
183
|
/**
|
|
198
|
-
* Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the
|
|
199
|
-
* value shape and renders a compact toggle button to switch between absolute and
|
|
200
|
-
* relative entry.
|
|
201
|
-
*/
|
|
184
|
+
* Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the
|
|
185
|
+
* value shape and renders a compact toggle button to switch between absolute and
|
|
186
|
+
* relative entry.
|
|
187
|
+
*/
|
|
202
188
|
declare const toggleModeController: RelativeDateTimeModeController;
|
|
203
189
|
/**
|
|
204
|
-
* Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode
|
|
205
|
-
* from the rule's operator. Pass the operator name(s) (or a predicate) that should put the
|
|
206
|
-
* editor in relative mode. No toggle is rendered — the operator selector is the mode
|
|
207
|
-
* affordance.
|
|
208
|
-
*
|
|
209
|
-
* NOTE: the chosen operators only signal _mode_; the rule's value remains a
|
|
210
|
-
* {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a
|
|
211
|
-
* real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`
|
|
212
|
-
* (e.g. `{ relativeEq: '=' }`). See the documentation.
|
|
213
|
-
*/
|
|
190
|
+
* Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode
|
|
191
|
+
* from the rule's operator. Pass the operator name(s) (or a predicate) that should put the
|
|
192
|
+
* editor in relative mode. No toggle is rendered — the operator selector is the mode
|
|
193
|
+
* affordance.
|
|
194
|
+
*
|
|
195
|
+
* NOTE: the chosen operators only signal _mode_; the rule's value remains a
|
|
196
|
+
* {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a
|
|
197
|
+
* real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`
|
|
198
|
+
* (e.g. `{ relativeEq: '=' }`). See the documentation.
|
|
199
|
+
*/
|
|
214
200
|
declare const createOperatorModeController: (relativeOperators: string[] | ((operator: string) => boolean)) => RelativeDateTimeModeController;
|
|
215
201
|
interface FieldWithOperators {
|
|
216
202
|
operators?: FullOperator[];
|
|
217
203
|
[key: string]: unknown;
|
|
218
204
|
}
|
|
219
205
|
/**
|
|
220
|
-
* Appends the given `operators` to each field's `operators` list, so the operator-driven
|
|
221
|
-
* controller (see {@link createOperatorModeController}) has an operator to switch into
|
|
222
|
-
* relative mode. Fields without an explicit `operators` list fall back to the core
|
|
223
|
-
* `defaultOperators`.
|
|
224
|
-
*/
|
|
206
|
+
* Appends the given `operators` to each field's `operators` list, so the operator-driven
|
|
207
|
+
* controller (see {@link createOperatorModeController}) has an operator to switch into
|
|
208
|
+
* relative mode. Fields without an explicit `operators` list fall back to the core
|
|
209
|
+
* `defaultOperators`.
|
|
210
|
+
*/
|
|
225
211
|
declare const withRelativeOperators: <F extends FieldWithOperators>(fields: F[], operators: FullOperator[]) => F[];
|
|
226
212
|
//#endregion
|
|
227
213
|
export { DateTimeValueEditor, QueryBuilderDateTime, QueryBuilderDateTimeContext, QueryBuilderDateTimeProps, RelativeDateTimeConfigContext, RelativeDateTimeEditorConfig, RelativeDateTimeModeControlProps, RelativeDateTimeModeController, RelativeDateTimeModeToggle, RelativeDateTimeToggleLabels, RelativeDateTimeValueEditor, RelativeOperatorMap, ResolvedRelativeDateTimeConfig, createOperatorModeController, defaultRelativeDateTimeAnchors, defaultRelativeDateTimeToggleLabels, defaultRelativeDateTimeUnits, defaultRelativeDateTimeValue, relativeDateTimeToggleClassName, toggleModeController, useRelativeDateTimeConfig, withRelativeOperators };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as rqbDateTimeLibraryAPI } from "./rqbDateTimeLibraryAPI.jsdate-
|
|
1
|
+
import { a as isRelativeDateTimeValue, i as isNonDateValueSource, t as _objectSpread2 } from "./objectSpread2-MqoZ2hSz.js";
|
|
2
|
+
import { t as rqbDateTimeLibraryAPI } from "./rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { createContext, useCallback, useContext, useMemo } from "react";
|
|
5
5
|
import { QueryBuilderContext, ValueEditor, clsx, defaultOperators, getCompatContextProvider, parseNumber, standardClassnames, toArray, useValueEditor } from "react-querybuilder";
|
|
@@ -345,7 +345,7 @@ const RelativeDateTimeValueEditor = (props) => {
|
|
|
345
345
|
}));
|
|
346
346
|
};
|
|
347
347
|
//#endregion
|
|
348
|
-
//#region \0@oxc-project+runtime@0.
|
|
348
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
349
349
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
350
350
|
if (null == r) return {};
|
|
351
351
|
var t = {};
|
|
@@ -356,7 +356,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
356
356
|
return t;
|
|
357
357
|
}
|
|
358
358
|
//#endregion
|
|
359
|
-
//#region \0@oxc-project+runtime@0.
|
|
359
|
+
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/objectWithoutProperties.js
|
|
360
360
|
function _objectWithoutProperties(e, t) {
|
|
361
361
|
if (null == e) return {};
|
|
362
362
|
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
@@ -372,10 +372,12 @@ const _excluded = ["editor"];
|
|
|
372
372
|
/**
|
|
373
373
|
* Whether a rule should use a date/time editor, based on either the coerced input
|
|
374
374
|
* type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).
|
|
375
|
+
* Non-`value` sources (`field`/`parameter`) are excluded so they render the standard
|
|
376
|
+
* field/parameter selector instead of the date UI.
|
|
375
377
|
*/
|
|
376
378
|
const isDateTimeEditor = (props, inputTypeCoerced) => {
|
|
377
379
|
var _props$fieldData;
|
|
378
|
-
return props.type === "text" && (inputTypeCoerced === "date" || inputTypeCoerced === "datetime-local") || /^(?:date|datetime|timestamp)\b/i.test((_props$fieldData = props.fieldData) === null || _props$fieldData === void 0 ? void 0 : _props$fieldData.datatype);
|
|
380
|
+
return !isNonDateValueSource(props.valueSource) && (props.type === "text" && (inputTypeCoerced === "date" || inputTypeCoerced === "datetime-local") || /^(?:date|datetime|timestamp)\b/i.test((_props$fieldData = props.fieldData) === null || _props$fieldData === void 0 ? void 0 : _props$fieldData.datatype));
|
|
379
381
|
};
|
|
380
382
|
const pad2 = (n) => `${n}`.padStart(2, "0");
|
|
381
383
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-querybuilder_datetime.legacy-esm.ui.js","names":["defaultDateTimeAPI"],"sources":["../src/ui/InheritedValueEditorContext.ts","../src/ui/relativeDateTimeConstants.ts","../src/ui/relativeDateTimeModeControllers.tsx","../src/ui/RelativeDateTimeConfigContext.tsx","../src/ui/RelativeDateTimeValueEditor.tsx","../src/ui/QueryBuilderDateTime.tsx"],"sourcesContent":["import type { Context } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\n\n/**\n * Holds the value editor inherited from an outer (compat package) context provider,\n * captured _before_ {@link QueryBuilderDateTime} overrides it. Lets the date/time value\n * editor delegate non-date fields (and absolute date inputs) to the compat editor instead\n * of the bare default {@link react-querybuilder!ValueEditor ValueEditor}. `null` = none\n * inherited (fall back to default).\n */\nexport const InheritedValueEditorContext: Context<React.ComponentType<ValueEditorProps> | null> =\n createContext<React.ComponentType<ValueEditorProps> | null>(null);\n\n/** Inherited (compat) value editor, or `null` if none. See {@link InheritedValueEditorContext}. */\nexport const useInheritedValueEditor = (): React.ComponentType<ValueEditorProps> | null =>\n useContext(InheritedValueEditorContext);\n","import type { FullOption } from '@react-querybuilder/core';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport type { RelativeDateTimeToggleLabels } from './types';\n\n/**\n * Class name applied to the absolute/relative mode toggle button. Package-local (not part\n * of the core `standardClassnames`) to avoid coupling core to this extension.\n */\nexport const relativeDateTimeToggleClassName = 'rule-value-dateTimeRelative-toggle';\n\n/** Default value applied when switching a rule to relative mode. */\nexport const defaultRelativeDateTimeValue: RelativeDateTimeValue = {\n mode: 'relative',\n anchor: 'now',\n offset: 0,\n unit: 'day',\n};\n\n/** Default anchor (reference-point) options for the relative date/time editor. */\nexport const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[] = [\n { name: 'now', value: 'now', label: 'now' },\n { name: 'startOfDay', value: 'startOfDay', label: 'start of day' },\n { name: 'endOfDay', value: 'endOfDay', label: 'end of day' },\n { name: 'startOfWeek', value: 'startOfWeek', label: 'start of week' },\n { name: 'endOfWeek', value: 'endOfWeek', label: 'end of week' },\n { name: 'startOfMonth', value: 'startOfMonth', label: 'start of month' },\n { name: 'endOfMonth', value: 'endOfMonth', label: 'end of month' },\n { name: 'startOfYear', value: 'startOfYear', label: 'start of year' },\n { name: 'endOfYear', value: 'endOfYear', label: 'end of year' },\n];\n\n/** Default unit options for the relative date/time editor. */\nexport const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[] = [\n { name: 'minute', value: 'minute', label: 'minute(s)' },\n { name: 'hour', value: 'hour', label: 'hour(s)' },\n { name: 'day', value: 'day', label: 'day(s)' },\n { name: 'week', value: 'week', label: 'week(s)' },\n { name: 'month', value: 'month', label: 'month(s)' },\n { name: 'year', value: 'year', label: 'year(s)' },\n];\n\n/** Default labels/content for the absolute/relative mode toggle. */\nexport const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels> = {\n label: 'Toggle relative date/time',\n absoluteTitle: 'Absolute date/time (click for relative)',\n relativeTitle: 'Relative date/time (click for absolute)',\n // Empty by default; the CSS pseudo-element renders the glyph based on `aria-checked`.\n absoluteContent: '',\n relativeContent: '',\n};\n","import * as React from 'react';\nimport type { FullOperator } from 'react-querybuilder';\nimport { clsx, defaultOperators } from 'react-querybuilder';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { relativeDateTimeToggleClassName } from './relativeDateTimeConstants';\nimport type { RelativeDateTimeModeController, RelativeDateTimeModeControlProps } from './types';\n\n/**\n * Compact absolute/relative toggle rendered by {@link toggleModeController}. A\n * `role=\"switch\"` button whose default glyph is supplied by CSS (keyed on\n * `aria-checked`); override via the `toggleLabels` config.\n *\n * @group Components\n */\nexport const RelativeDateTimeModeToggle = ({\n isRelative,\n setMode,\n disabled,\n className,\n labels,\n}: RelativeDateTimeModeControlProps): React.JSX.Element => {\n const onClick = React.useCallback(\n () => setMode(isRelative ? 'absolute' : 'relative'),\n [setMode, isRelative]\n );\n\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isRelative}\n aria-label={labels.label}\n title={isRelative ? labels.relativeTitle : labels.absoluteTitle}\n disabled={disabled}\n className={clsx(relativeDateTimeToggleClassName, className)}\n onClick={onClick}>\n {isRelative ? labels.relativeContent : labels.absoluteContent}\n </button>\n );\n};\n\n/**\n * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the\n * value shape and renders a compact toggle button to switch between absolute and\n * relative entry.\n */\nexport const toggleModeController: RelativeDateTimeModeController = {\n isRelative: props => isRelativeDateTimeValue(props.value),\n ModeControl: RelativeDateTimeModeToggle,\n};\n\n/**\n * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode\n * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the\n * editor in relative mode. No toggle is rendered — the operator selector is the mode\n * affordance.\n *\n * NOTE: the chosen operators only signal _mode_; the rule's value remains a\n * {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a\n * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`\n * (e.g. `{ relativeEq: '=' }`). See the documentation.\n */\nexport const createOperatorModeController = (\n relativeOperators: string[] | ((operator: string) => boolean)\n): RelativeDateTimeModeController => ({\n isRelative: props =>\n typeof relativeOperators === 'function'\n ? relativeOperators(props.operator)\n : relativeOperators.includes(props.operator),\n});\n\ninterface FieldWithOperators {\n operators?: FullOperator[];\n [key: string]: unknown;\n}\n\n/**\n * Appends the given `operators` to each field's `operators` list, so the operator-driven\n * controller (see {@link createOperatorModeController}) has an operator to switch into\n * relative mode. Fields without an explicit `operators` list fall back to the core\n * `defaultOperators`.\n */\nexport const withRelativeOperators = <F extends FieldWithOperators>(\n fields: F[],\n operators: FullOperator[]\n): F[] =>\n fields.map(field => ({\n ...field,\n operators: [...(field.operators ?? (defaultOperators as FullOperator[])), ...operators],\n }));\n","import * as React from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { FullOption } from 'react-querybuilder';\nimport { rqbDateTimeLibraryAPI as defaultDateTimeAPI } from '../rqbDateTimeLibraryAPI.jsdate';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RQBDateTimeLibraryAPI } from '../types';\nimport {\n defaultRelativeDateTimeAnchors,\n defaultRelativeDateTimeToggleLabels,\n defaultRelativeDateTimeUnits,\n} from './relativeDateTimeConstants';\nimport { toggleModeController } from './relativeDateTimeModeControllers';\nimport type {\n RelativeDateTimeEditorConfig,\n RelativeDateTimeModeController,\n RelativeDateTimeToggleLabels,\n} from './types';\n\n/** Fully-resolved relative date/time editor config (no optional fields). */\nexport interface ResolvedRelativeDateTimeConfig {\n modeController: RelativeDateTimeModeController;\n anchors: FullOption<RelativeDateTimeAnchor>[];\n units: FullOption<RelativeDateTimeUnit>[];\n toggleLabels: Required<RelativeDateTimeToggleLabels>;\n dateTimeAPI: RQBDateTimeLibraryAPI;\n}\n\n/**\n * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.\n * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.\n */\nexport const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig> =\n createContext<RelativeDateTimeEditorConfig>({});\n\n/** Reads the relative date/time editor config from context, merged with defaults. */\nexport const useRelativeDateTimeConfig = (): ResolvedRelativeDateTimeConfig => {\n const config = useContext(RelativeDateTimeConfigContext);\n return useMemo(\n () => ({\n modeController: config.modeController ?? toggleModeController,\n anchors: config.anchors ?? defaultRelativeDateTimeAnchors,\n units: config.units ?? defaultRelativeDateTimeUnits,\n toggleLabels: { ...defaultRelativeDateTimeToggleLabels, ...config.toggleLabels },\n dateTimeAPI: config.dateTimeAPI ?? defaultDateTimeAPI,\n }),\n [config]\n );\n};\n","import * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport type { FullField, Path, ValueEditorProps, ValueSelectorProps } from 'react-querybuilder';\nimport {\n clsx,\n parseNumber,\n standardClassnames,\n toArray,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { useInheritedValueEditor } from './InheritedValueEditorContext';\nimport { DateTimeValueEditor } from './QueryBuilderDateTime';\nimport type { ResolvedRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { useRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { defaultRelativeDateTimeValue } from './relativeDateTimeConstants';\n\nconst dummyPath: Path = [];\nconst dummyFieldData: FullField = { name: '', value: '', label: '' };\n\n/** Splits a value into the from/to pair used by between/notBetween, object-safe. */\nconst toBetweenArray = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : isRelativeDateTimeValue(value) ? [value] : toArray(value);\n\ninterface RelativeDateTimeSingleValueEditorProps {\n /** The original value editor props (for mode derivation and absolute rendering). */\n baseProps: ValueEditorProps;\n /** The value for this slot (the whole value, or one element of a between pair). */\n value: unknown;\n /** Emits a new value for this slot. */\n onChange: (value: unknown) => void;\n /** Operator passed to the absolute editor (forced to `=` for between slots). */\n absoluteOperator: string;\n config: ResolvedRelativeDateTimeConfig;\n SelectorComponent: React.ComponentType<ValueSelectorProps>;\n /** Themed numeric offset input: the inherited (compat) editor when present, else the default. */\n NumericEditorComponent: React.ComponentType<ValueEditorProps>;\n valueListItemClassName?: string;\n numericSchema: ValueEditorProps['schema'];\n}\n\n/**\n * Renders a single absolute-or-relative date/time value: a mode affordance (per the\n * controller) plus either an absolute date input or anchor + signed offset + unit\n * selectors. Reused once per slot so between/notBetween can mix bounds (e.g. an absolute\n * \"from\" and a relative \"to\").\n */\nconst RelativeDateTimeSingleValueEditor = ({\n baseProps,\n value,\n onChange,\n absoluteOperator,\n config,\n SelectorComponent,\n NumericEditorComponent,\n valueListItemClassName,\n numericSchema,\n}: RelativeDateTimeSingleValueEditorProps): React.JSX.Element => {\n const { schema, disabled, title, testID } = baseProps;\n const { modeController, anchors, units, toggleLabels } = config;\n\n const isRelative = modeController.isRelative({ ...baseProps, value });\n const relValue: RelativeDateTimeValue = isRelativeDateTimeValue(value)\n ? value\n : defaultRelativeDateTimeValue;\n\n const handleSetMode = useCallback(\n (mode: 'absolute' | 'relative') =>\n onChange(mode === 'relative' ? defaultRelativeDateTimeValue : ''),\n [onChange]\n );\n\n const handleChangeAnchor = useCallback(\n (anchor: string) => onChange({ ...relValue, anchor: anchor as RelativeDateTimeAnchor }),\n [onChange, relValue]\n );\n\n const handleChangeOffset = useCallback(\n (offset: unknown) =>\n onChange({\n ...relValue,\n offset: (parseNumber(offset, { parseNumbers: true }) as number) || 0,\n }),\n [onChange, relValue]\n );\n\n const handleChangeUnit = useCallback(\n (unit: string) => onChange({ ...relValue, unit: unit as RelativeDateTimeUnit }),\n [onChange, relValue]\n );\n\n const { ModeControl } = modeController;\n\n return (\n <React.Fragment>\n {ModeControl && (\n <ModeControl\n isRelative={isRelative}\n setMode={handleSetMode}\n schema={schema}\n disabled={disabled}\n className={valueListItemClassName}\n title={title}\n testID={testID}\n labels={toggleLabels}\n />\n )}\n {isRelative ? (\n <React.Fragment>\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeAnchor}\n disabled={disabled}\n value={relValue.anchor}\n options={anchors}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n <NumericEditorComponent\n skipHook\n testID={testID}\n inputType=\"number\"\n title={title}\n className={valueListItemClassName}\n disabled={disabled}\n handleOnChange={handleChangeOffset}\n field={''}\n operator={''}\n value={relValue.offset}\n valueSource={'value'}\n fieldData={dummyFieldData}\n schema={numericSchema}\n path={dummyPath}\n level={0}\n rule={{ field: '', operator: '=', value: relValue.offset }}\n />\n {relValue.offset !== 0 && (\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeUnit}\n disabled={disabled}\n value={relValue.unit}\n options={units}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n )}\n </React.Fragment>\n ) : (\n <DateTimeValueEditor\n {...baseProps}\n operator={absoluteOperator}\n value={value}\n handleOnChange={onChange}\n className={standardClassnames.value}\n />\n )}\n </React.Fragment>\n );\n};\n\n/**\n * Value editor with support for {@link RelativeDateTimeValue relative date/time values}\n * (e.g. \"three months ago\" or \"the beginning of this year\"). How the user switches\n * between absolute and relative modes is delegated to a pluggable\n * {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via\n * {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit\n * selectors; the unit selector is hidden when the offset is `0`.\n *\n * For the `between`/`notBetween` operators it renders two independent value editors (each\n * with its own mode affordance) and stores the bounds as a two-element array, so the from\n * and to bounds can independently be absolute or relative.\n *\n * @group Components\n */\nexport const RelativeDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const { valueListItemClassName } = useValueEditor(props);\n\n const { className, value, handleOnChange, schema, operator, separator } = props;\n const { suppressStandardClassnames } = schema;\n\n const SelectorComponent = props.selectorComponent ?? schema.controls.valueSelector;\n\n // Themed numeric offset input from the inherited (compat) editor when present, else default.\n const NumericEditorComponent = useInheritedValueEditor() ?? ValueEditor;\n\n const config = useRelativeDateTimeConfig();\n\n const numericSchema = useMemo(() => ({ ...schema, parseNumbers: true }), [schema]);\n\n const outerClassname = useMemo(\n () => clsx(suppressStandardClassnames || standardClassnames.valueDateTimeRelative, className),\n [suppressStandardClassnames, className]\n );\n\n const isBetween = operator === 'between' || operator === 'notBetween';\n\n // For between/notBetween, store the bounds as a two-element array. Relative values are\n // objects (which can't survive comma-joining), so the array is emitted directly,\n // regardless of `listsAsArrays`.\n const valueAsArray = useMemo(() => toBetweenArray(value), [value]);\n\n const handleChangeBound = useCallback(\n (index: number) => (boundValue: unknown) => {\n const next = [valueAsArray[0], valueAsArray[1]];\n next[index] = boundValue;\n handleOnChange(next);\n },\n [valueAsArray, handleOnChange]\n );\n\n if (isBetween) {\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[0]}\n onChange={handleChangeBound(0)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n {separator}\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[1]}\n onChange={handleChangeBound(1)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n }\n\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={value}\n onChange={handleOnChange}\n absoluteOperator={operator}\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n};\n","import * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport type { QueryBuilderContextProvider, ValueEditorProps } from 'react-querybuilder';\nimport {\n getCompatContextProvider,\n QueryBuilderContext,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport {\n InheritedValueEditorContext,\n useInheritedValueEditor,\n} from './InheritedValueEditorContext';\nimport {\n RelativeDateTimeConfigContext,\n useRelativeDateTimeConfig,\n} from './RelativeDateTimeConfigContext';\nimport { RelativeDateTimeValueEditor } from './RelativeDateTimeValueEditor';\nimport type { RelativeDateTimeEditorConfig } from './types';\n\n/**\n * Whether a rule should use a date/time editor, based on either the coerced input\n * type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).\n */\nconst isDateTimeEditor = (props: ValueEditorProps, inputTypeCoerced: string | undefined): boolean =>\n (props.type === 'text' &&\n (inputTypeCoerced === 'date' || inputTypeCoerced === 'datetime-local')) ||\n /^(?:date|datetime|timestamp)\\b/i.test(props.fieldData?.datatype as string);\n\nconst pad2 = (n: number): string => `${n}`.padStart(2, '0');\n\n/**\n * Formats a `Date` into the local value expected by a native `date`/`datetime-local`\n * input (library-agnostic; the date library only handles parsing/validation).\n */\nconst formatDateInputValue = (d: Date, withTime: boolean): string => {\n const datePart = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n return withTime ? `${datePart}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : datePart;\n};\n\n/**\n * Renders the inherited (compat) editor when one is provided, otherwise the default\n * {@link react-querybuilder!ValueEditor ValueEditor}. The editor is received as a prop (rather\n * than read from context here) so the JSX element type stays prop-sourced and stable.\n */\nconst FallbackValueEditor = ({\n editor: Editor,\n ...props\n}: ValueEditorProps & {\n editor: React.ComponentType<ValueEditorProps> | null;\n}): React.JSX.Element => (Editor ? <Editor {...props} /> : <ValueEditor {...props} skipHook />);\n\nexport const DateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n const { dateTimeAPI } = useRelativeDateTimeConfig();\n\n // Non-date fields and unparseable values: delegate to the inherited (compat) editor when\n // present, otherwise the default editor.\n const fallback = (p: ValueEditorProps) => <FallbackValueEditor editor={InheritedEditor} {...p} />;\n\n if (!isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return fallback(props);\n }\n\n if (dateTimeAPI.isValid(props.value)) {\n const value = formatDateInputValue(\n dateTimeAPI.toDate(props.value),\n uVE.inputTypeCoerced !== 'date'\n );\n return fallback({ ...props, value });\n }\n\n return fallback(props);\n};\n\n/**\n * Provider value editor: renders the relative-capable {@link RelativeDateTimeValueEditor}\n * for date/time fields and falls back to the inherited (compat) editor for everything else.\n */\nconst QueryBuilderDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n\n if (isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return <RelativeDateTimeValueEditor {...props} />;\n }\n\n return <FallbackValueEditor editor={InheritedEditor} {...props} />;\n};\n\nexport const QueryBuilderDateTimeContext: QueryBuilderContextProvider = getCompatContextProvider({\n controlElements: { valueEditor: QueryBuilderDateTimeValueEditor },\n});\n\n/** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */\nexport interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {\n children?: React.ReactNode;\n}\n\n/**\n * Context provider enabling date/time features for a wrapped\n * {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable\n * {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional\n * {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and\n * toggle labels). With no props it provides the zero-config toggle experience.\n *\n * @group Components\n */\nexport const QueryBuilderDateTime = ({\n children,\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n}: QueryBuilderDateTimeProps): React.JSX.Element => {\n const config = useMemo(\n (): RelativeDateTimeEditorConfig => ({\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n }),\n [modeController, anchors, units, toggleLabels, dateTimeAPI]\n );\n\n // Capture the value editor inherited from any outer compat provider (e.g. QueryBuilderMaterial)\n // _before_ QueryBuilderDateTimeContext overrides it, so date/time editors can delegate to it.\n const inheritedValueEditor = (useContext(QueryBuilderContext).controlElements?.valueEditor ??\n null) as React.ComponentType<ValueEditorProps> | null;\n\n return (\n <RelativeDateTimeConfigContext.Provider value={config}>\n <InheritedValueEditorContext.Provider value={inheritedValueEditor}>\n <QueryBuilderDateTimeContext>{children}</QueryBuilderDateTimeContext>\n </InheritedValueEditorContext.Provider>\n </RelativeDateTimeConfigContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,8BACX,cAA4D,IAAI;;AAGlE,MAAa,gCACX,WAAW,2BAA2B;;;;;;;ACRxC,MAAa,kCAAkC;;AAG/C,MAAa,+BAAsD;CACjE,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,iCAAuE;CAClF;EAAE,MAAM;EAAO,OAAO;EAAO,OAAO;CAAM;CAC1C;EAAE,MAAM;EAAc,OAAO;EAAc,OAAO;CAAe;CACjE;EAAE,MAAM;EAAY,OAAO;EAAY,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C7E;CAEF,OACE,sBAAA,cAAC,8BAA8B,UAA/B,EAAwC,OAAO,OAIP,GAHtC,sBAAA,cAAC,4BAA4B,UAA7B,EAAsC,OAAO,qBAEP,GADpC,sBAAA,cAAC,6BAAA,MAA6B,QAAsC,CAChC,CACA;AAE5C"}
|
|
1
|
+
{"version":3,"file":"react-querybuilder_datetime.legacy-esm.ui.js","names":["defaultDateTimeAPI"],"sources":["../src/ui/InheritedValueEditorContext.ts","../src/ui/relativeDateTimeConstants.ts","../src/ui/relativeDateTimeModeControllers.tsx","../src/ui/RelativeDateTimeConfigContext.tsx","../src/ui/RelativeDateTimeValueEditor.tsx","../src/ui/QueryBuilderDateTime.tsx"],"sourcesContent":["import type { Context } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\n\n/**\n * Holds the value editor inherited from an outer (compat package) context provider,\n * captured _before_ {@link QueryBuilderDateTime} overrides it. Lets the date/time value\n * editor delegate non-date fields (and absolute date inputs) to the compat editor instead\n * of the bare default {@link react-querybuilder!ValueEditor ValueEditor}. `null` = none\n * inherited (fall back to default).\n */\nexport const InheritedValueEditorContext: Context<React.ComponentType<ValueEditorProps> | null> =\n createContext<React.ComponentType<ValueEditorProps> | null>(null);\n\n/** Inherited (compat) value editor, or `null` if none. See {@link InheritedValueEditorContext}. */\nexport const useInheritedValueEditor = (): React.ComponentType<ValueEditorProps> | null =>\n useContext(InheritedValueEditorContext);\n","import type { FullOption } from '@react-querybuilder/core';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport type { RelativeDateTimeToggleLabels } from './types';\n\n/**\n * Class name applied to the absolute/relative mode toggle button. Package-local (not part\n * of the core `standardClassnames`) to avoid coupling core to this extension.\n */\nexport const relativeDateTimeToggleClassName = 'rule-value-dateTimeRelative-toggle';\n\n/** Default value applied when switching a rule to relative mode. */\nexport const defaultRelativeDateTimeValue: RelativeDateTimeValue = {\n mode: 'relative',\n anchor: 'now',\n offset: 0,\n unit: 'day',\n};\n\n/** Default anchor (reference-point) options for the relative date/time editor. */\nexport const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[] = [\n { name: 'now', value: 'now', label: 'now' },\n { name: 'startOfDay', value: 'startOfDay', label: 'start of day' },\n { name: 'endOfDay', value: 'endOfDay', label: 'end of day' },\n { name: 'startOfWeek', value: 'startOfWeek', label: 'start of week' },\n { name: 'endOfWeek', value: 'endOfWeek', label: 'end of week' },\n { name: 'startOfMonth', value: 'startOfMonth', label: 'start of month' },\n { name: 'endOfMonth', value: 'endOfMonth', label: 'end of month' },\n { name: 'startOfYear', value: 'startOfYear', label: 'start of year' },\n { name: 'endOfYear', value: 'endOfYear', label: 'end of year' },\n];\n\n/** Default unit options for the relative date/time editor. */\nexport const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[] = [\n { name: 'minute', value: 'minute', label: 'minute(s)' },\n { name: 'hour', value: 'hour', label: 'hour(s)' },\n { name: 'day', value: 'day', label: 'day(s)' },\n { name: 'week', value: 'week', label: 'week(s)' },\n { name: 'month', value: 'month', label: 'month(s)' },\n { name: 'year', value: 'year', label: 'year(s)' },\n];\n\n/** Default labels/content for the absolute/relative mode toggle. */\nexport const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels> = {\n label: 'Toggle relative date/time',\n absoluteTitle: 'Absolute date/time (click for relative)',\n relativeTitle: 'Relative date/time (click for absolute)',\n // Empty by default; the CSS pseudo-element renders the glyph based on `aria-checked`.\n absoluteContent: '',\n relativeContent: '',\n};\n","import * as React from 'react';\nimport type { FullOperator } from 'react-querybuilder';\nimport { clsx, defaultOperators } from 'react-querybuilder';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { relativeDateTimeToggleClassName } from './relativeDateTimeConstants';\nimport type { RelativeDateTimeModeController, RelativeDateTimeModeControlProps } from './types';\n\n/**\n * Compact absolute/relative toggle rendered by {@link toggleModeController}. A\n * `role=\"switch\"` button whose default glyph is supplied by CSS (keyed on\n * `aria-checked`); override via the `toggleLabels` config.\n *\n * @group Components\n */\nexport const RelativeDateTimeModeToggle = ({\n isRelative,\n setMode,\n disabled,\n className,\n labels,\n}: RelativeDateTimeModeControlProps): React.JSX.Element => {\n const onClick = React.useCallback(\n () => setMode(isRelative ? 'absolute' : 'relative'),\n [setMode, isRelative]\n );\n\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isRelative}\n aria-label={labels.label}\n title={isRelative ? labels.relativeTitle : labels.absoluteTitle}\n disabled={disabled}\n className={clsx(relativeDateTimeToggleClassName, className)}\n onClick={onClick}>\n {isRelative ? labels.relativeContent : labels.absoluteContent}\n </button>\n );\n};\n\n/**\n * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the\n * value shape and renders a compact toggle button to switch between absolute and\n * relative entry.\n */\nexport const toggleModeController: RelativeDateTimeModeController = {\n isRelative: props => isRelativeDateTimeValue(props.value),\n ModeControl: RelativeDateTimeModeToggle,\n};\n\n/**\n * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode\n * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the\n * editor in relative mode. No toggle is rendered — the operator selector is the mode\n * affordance.\n *\n * NOTE: the chosen operators only signal _mode_; the rule's value remains a\n * {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a\n * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`\n * (e.g. `{ relativeEq: '=' }`). See the documentation.\n */\nexport const createOperatorModeController = (\n relativeOperators: string[] | ((operator: string) => boolean)\n): RelativeDateTimeModeController => ({\n isRelative: props =>\n typeof relativeOperators === 'function'\n ? relativeOperators(props.operator)\n : relativeOperators.includes(props.operator),\n});\n\ninterface FieldWithOperators {\n operators?: FullOperator[];\n [key: string]: unknown;\n}\n\n/**\n * Appends the given `operators` to each field's `operators` list, so the operator-driven\n * controller (see {@link createOperatorModeController}) has an operator to switch into\n * relative mode. Fields without an explicit `operators` list fall back to the core\n * `defaultOperators`.\n */\nexport const withRelativeOperators = <F extends FieldWithOperators>(\n fields: F[],\n operators: FullOperator[]\n): F[] =>\n fields.map(field => ({\n ...field,\n operators: [...(field.operators ?? (defaultOperators as FullOperator[])), ...operators],\n }));\n","import * as React from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { FullOption } from 'react-querybuilder';\nimport { rqbDateTimeLibraryAPI as defaultDateTimeAPI } from '../rqbDateTimeLibraryAPI.jsdate';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RQBDateTimeLibraryAPI } from '../types';\nimport {\n defaultRelativeDateTimeAnchors,\n defaultRelativeDateTimeToggleLabels,\n defaultRelativeDateTimeUnits,\n} from './relativeDateTimeConstants';\nimport { toggleModeController } from './relativeDateTimeModeControllers';\nimport type {\n RelativeDateTimeEditorConfig,\n RelativeDateTimeModeController,\n RelativeDateTimeToggleLabels,\n} from './types';\n\n/** Fully-resolved relative date/time editor config (no optional fields). */\nexport interface ResolvedRelativeDateTimeConfig {\n modeController: RelativeDateTimeModeController;\n anchors: FullOption<RelativeDateTimeAnchor>[];\n units: FullOption<RelativeDateTimeUnit>[];\n toggleLabels: Required<RelativeDateTimeToggleLabels>;\n dateTimeAPI: RQBDateTimeLibraryAPI;\n}\n\n/**\n * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.\n * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.\n */\nexport const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig> =\n createContext<RelativeDateTimeEditorConfig>({});\n\n/** Reads the relative date/time editor config from context, merged with defaults. */\nexport const useRelativeDateTimeConfig = (): ResolvedRelativeDateTimeConfig => {\n const config = useContext(RelativeDateTimeConfigContext);\n return useMemo(\n () => ({\n modeController: config.modeController ?? toggleModeController,\n anchors: config.anchors ?? defaultRelativeDateTimeAnchors,\n units: config.units ?? defaultRelativeDateTimeUnits,\n toggleLabels: { ...defaultRelativeDateTimeToggleLabels, ...config.toggleLabels },\n dateTimeAPI: config.dateTimeAPI ?? defaultDateTimeAPI,\n }),\n [config]\n );\n};\n","import * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport type { FullField, Path, ValueEditorProps, ValueSelectorProps } from 'react-querybuilder';\nimport {\n clsx,\n parseNumber,\n standardClassnames,\n toArray,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { useInheritedValueEditor } from './InheritedValueEditorContext';\nimport { DateTimeValueEditor } from './QueryBuilderDateTime';\nimport type { ResolvedRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { useRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { defaultRelativeDateTimeValue } from './relativeDateTimeConstants';\n\nconst dummyPath: Path = [];\nconst dummyFieldData: FullField = { name: '', value: '', label: '' };\n\n/** Splits a value into the from/to pair used by between/notBetween, object-safe. */\nconst toBetweenArray = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : isRelativeDateTimeValue(value) ? [value] : toArray(value);\n\ninterface RelativeDateTimeSingleValueEditorProps {\n /** The original value editor props (for mode derivation and absolute rendering). */\n baseProps: ValueEditorProps;\n /** The value for this slot (the whole value, or one element of a between pair). */\n value: unknown;\n /** Emits a new value for this slot. */\n onChange: (value: unknown) => void;\n /** Operator passed to the absolute editor (forced to `=` for between slots). */\n absoluteOperator: string;\n config: ResolvedRelativeDateTimeConfig;\n SelectorComponent: React.ComponentType<ValueSelectorProps>;\n /** Themed numeric offset input: the inherited (compat) editor when present, else the default. */\n NumericEditorComponent: React.ComponentType<ValueEditorProps>;\n valueListItemClassName?: string;\n numericSchema: ValueEditorProps['schema'];\n}\n\n/**\n * Renders a single absolute-or-relative date/time value: a mode affordance (per the\n * controller) plus either an absolute date input or anchor + signed offset + unit\n * selectors. Reused once per slot so between/notBetween can mix bounds (e.g. an absolute\n * \"from\" and a relative \"to\").\n */\nconst RelativeDateTimeSingleValueEditor = ({\n baseProps,\n value,\n onChange,\n absoluteOperator,\n config,\n SelectorComponent,\n NumericEditorComponent,\n valueListItemClassName,\n numericSchema,\n}: RelativeDateTimeSingleValueEditorProps): React.JSX.Element => {\n const { schema, disabled, title, testID } = baseProps;\n const { modeController, anchors, units, toggleLabels } = config;\n\n const isRelative = modeController.isRelative({ ...baseProps, value });\n const relValue: RelativeDateTimeValue = isRelativeDateTimeValue(value)\n ? value\n : defaultRelativeDateTimeValue;\n\n const handleSetMode = useCallback(\n (mode: 'absolute' | 'relative') =>\n onChange(mode === 'relative' ? defaultRelativeDateTimeValue : ''),\n [onChange]\n );\n\n const handleChangeAnchor = useCallback(\n (anchor: string) => onChange({ ...relValue, anchor: anchor as RelativeDateTimeAnchor }),\n [onChange, relValue]\n );\n\n const handleChangeOffset = useCallback(\n (offset: unknown) =>\n onChange({\n ...relValue,\n offset: (parseNumber(offset, { parseNumbers: true }) as number) || 0,\n }),\n [onChange, relValue]\n );\n\n const handleChangeUnit = useCallback(\n (unit: string) => onChange({ ...relValue, unit: unit as RelativeDateTimeUnit }),\n [onChange, relValue]\n );\n\n const { ModeControl } = modeController;\n\n return (\n <React.Fragment>\n {ModeControl && (\n <ModeControl\n isRelative={isRelative}\n setMode={handleSetMode}\n schema={schema}\n disabled={disabled}\n className={valueListItemClassName}\n title={title}\n testID={testID}\n labels={toggleLabels}\n />\n )}\n {isRelative ? (\n <React.Fragment>\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeAnchor}\n disabled={disabled}\n value={relValue.anchor}\n options={anchors}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n <NumericEditorComponent\n skipHook\n testID={testID}\n inputType=\"number\"\n title={title}\n className={valueListItemClassName}\n disabled={disabled}\n handleOnChange={handleChangeOffset}\n field={''}\n operator={''}\n value={relValue.offset}\n valueSource={'value'}\n fieldData={dummyFieldData}\n schema={numericSchema}\n path={dummyPath}\n level={0}\n rule={{ field: '', operator: '=', value: relValue.offset }}\n />\n {relValue.offset !== 0 && (\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeUnit}\n disabled={disabled}\n value={relValue.unit}\n options={units}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n )}\n </React.Fragment>\n ) : (\n <DateTimeValueEditor\n {...baseProps}\n operator={absoluteOperator}\n value={value}\n handleOnChange={onChange}\n className={standardClassnames.value}\n />\n )}\n </React.Fragment>\n );\n};\n\n/**\n * Value editor with support for {@link RelativeDateTimeValue relative date/time values}\n * (e.g. \"three months ago\" or \"the beginning of this year\"). How the user switches\n * between absolute and relative modes is delegated to a pluggable\n * {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via\n * {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit\n * selectors; the unit selector is hidden when the offset is `0`.\n *\n * For the `between`/`notBetween` operators it renders two independent value editors (each\n * with its own mode affordance) and stores the bounds as a two-element array, so the from\n * and to bounds can independently be absolute or relative.\n *\n * @group Components\n */\nexport const RelativeDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const { valueListItemClassName } = useValueEditor(props);\n\n const { className, value, handleOnChange, schema, operator, separator } = props;\n const { suppressStandardClassnames } = schema;\n\n const SelectorComponent = props.selectorComponent ?? schema.controls.valueSelector;\n\n // Themed numeric offset input from the inherited (compat) editor when present, else default.\n const NumericEditorComponent = useInheritedValueEditor() ?? ValueEditor;\n\n const config = useRelativeDateTimeConfig();\n\n const numericSchema = useMemo(() => ({ ...schema, parseNumbers: true }), [schema]);\n\n const outerClassname = useMemo(\n () => clsx(suppressStandardClassnames || standardClassnames.valueDateTimeRelative, className),\n [suppressStandardClassnames, className]\n );\n\n const isBetween = operator === 'between' || operator === 'notBetween';\n\n // For between/notBetween, store the bounds as a two-element array. Relative values are\n // objects (which can't survive comma-joining), so the array is emitted directly,\n // regardless of `listsAsArrays`.\n const valueAsArray = useMemo(() => toBetweenArray(value), [value]);\n\n const handleChangeBound = useCallback(\n (index: number) => (boundValue: unknown) => {\n const next = [valueAsArray[0], valueAsArray[1]];\n next[index] = boundValue;\n handleOnChange(next);\n },\n [valueAsArray, handleOnChange]\n );\n\n if (isBetween) {\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[0]}\n onChange={handleChangeBound(0)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n {separator}\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[1]}\n onChange={handleChangeBound(1)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n }\n\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={value}\n onChange={handleOnChange}\n absoluteOperator={operator}\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n};\n","import * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport type { QueryBuilderContextProvider, ValueEditorProps } from 'react-querybuilder';\nimport {\n getCompatContextProvider,\n QueryBuilderContext,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport { isNonDateValueSource } from '../utils';\nimport {\n InheritedValueEditorContext,\n useInheritedValueEditor,\n} from './InheritedValueEditorContext';\nimport {\n RelativeDateTimeConfigContext,\n useRelativeDateTimeConfig,\n} from './RelativeDateTimeConfigContext';\nimport { RelativeDateTimeValueEditor } from './RelativeDateTimeValueEditor';\nimport type { RelativeDateTimeEditorConfig } from './types';\n\n/**\n * Whether a rule should use a date/time editor, based on either the coerced input\n * type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).\n * Non-`value` sources (`field`/`parameter`) are excluded so they render the standard\n * field/parameter selector instead of the date UI.\n */\nconst isDateTimeEditor = (props: ValueEditorProps, inputTypeCoerced: string | undefined): boolean =>\n !isNonDateValueSource(props.valueSource) &&\n ((props.type === 'text' &&\n (inputTypeCoerced === 'date' || inputTypeCoerced === 'datetime-local')) ||\n /^(?:date|datetime|timestamp)\\b/i.test(props.fieldData?.datatype as string));\n\nconst pad2 = (n: number): string => `${n}`.padStart(2, '0');\n\n/**\n * Formats a `Date` into the local value expected by a native `date`/`datetime-local`\n * input (library-agnostic; the date library only handles parsing/validation).\n */\nconst formatDateInputValue = (d: Date, withTime: boolean): string => {\n const datePart = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n return withTime ? `${datePart}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : datePart;\n};\n\n/**\n * Renders the inherited (compat) editor when one is provided, otherwise the default\n * {@link react-querybuilder!ValueEditor ValueEditor}. The editor is received as a prop (rather\n * than read from context here) so the JSX element type stays prop-sourced and stable.\n */\nconst FallbackValueEditor = ({\n editor: Editor,\n ...props\n}: ValueEditorProps & {\n editor: React.ComponentType<ValueEditorProps> | null;\n}): React.JSX.Element => (Editor ? <Editor {...props} /> : <ValueEditor {...props} skipHook />);\n\nexport const DateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n const { dateTimeAPI } = useRelativeDateTimeConfig();\n\n // Non-date fields and unparseable values: delegate to the inherited (compat) editor when\n // present, otherwise the default editor.\n const fallback = (p: ValueEditorProps) => <FallbackValueEditor editor={InheritedEditor} {...p} />;\n\n if (!isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return fallback(props);\n }\n\n if (dateTimeAPI.isValid(props.value)) {\n const value = formatDateInputValue(\n dateTimeAPI.toDate(props.value),\n uVE.inputTypeCoerced !== 'date'\n );\n return fallback({ ...props, value });\n }\n\n return fallback(props);\n};\n\n/**\n * Provider value editor: renders the relative-capable {@link RelativeDateTimeValueEditor}\n * for date/time fields and falls back to the inherited (compat) editor for everything else.\n */\nconst QueryBuilderDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n\n if (isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return <RelativeDateTimeValueEditor {...props} />;\n }\n\n return <FallbackValueEditor editor={InheritedEditor} {...props} />;\n};\n\nexport const QueryBuilderDateTimeContext: QueryBuilderContextProvider = getCompatContextProvider({\n controlElements: { valueEditor: QueryBuilderDateTimeValueEditor },\n});\n\n/** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */\nexport interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {\n children?: React.ReactNode;\n}\n\n/**\n * Context provider enabling date/time features for a wrapped\n * {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable\n * {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional\n * {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and\n * toggle labels). With no props it provides the zero-config toggle experience.\n *\n * @group Components\n */\nexport const QueryBuilderDateTime = ({\n children,\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n}: QueryBuilderDateTimeProps): React.JSX.Element => {\n const config = useMemo(\n (): RelativeDateTimeEditorConfig => ({\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n }),\n [modeController, anchors, units, toggleLabels, dateTimeAPI]\n );\n\n // Capture the value editor inherited from any outer compat provider (e.g. QueryBuilderMaterial)\n // _before_ QueryBuilderDateTimeContext overrides it, so date/time editors can delegate to it.\n const inheritedValueEditor = (useContext(QueryBuilderContext).controlElements?.valueEditor ??\n null) as React.ComponentType<ValueEditorProps> | null;\n\n return (\n <RelativeDateTimeConfigContext.Provider value={config}>\n <InheritedValueEditorContext.Provider value={inheritedValueEditor}>\n <QueryBuilderDateTimeContext>{children}</QueryBuilderDateTimeContext>\n </InheritedValueEditorContext.Provider>\n </RelativeDateTimeConfigContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,8BACX,cAA4D,IAAI;;AAGlE,MAAa,gCACX,WAAW,2BAA2B;;;;;;;ACRxC,MAAa,kCAAkC;;AAG/C,MAAa,+BAAsD;CACjE,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,iCAAuE;CAClF;EAAE,MAAM;EAAO,OAAO;EAAO,OAAO;CAAM;CAC1C;EAAE,MAAM;EAAc,OAAO;EAAc,OAAO;CAAe;CACjE;EAAE,MAAM;EAAY,OAAO;EAAY,OAAO;CAAa;CAC3D;EAAE,MAAM;EAAe,OAAO;EAAe,OAAO;CAAgB;CACpE;EAAE,MAAM;EAAa,OAAO;EAAa,OAAO;CAAc;CAC9D;EAAE,MAAM;EAAgB,OAAO;EAAgB,OAAO;CAAiB;CACvE;EAAE,MAAM;EAAc,OAAO;EAAc,OAAO;CAAe;CACjE;EAAE,MAAM;EAAe,OAAO;EAAe,OAAO;CAAgB;CACpE;EAAE,MAAM;EAAa,OAAO;EAAa,OAAO;CAAc;AAChE;;AAGA,MAAa,+BAAmE;CAC9E;EAAE,MAAM;EAAU,OAAO;EAAU,OAAO;CAAY;CACtD;EAAE,MAAM;EAAQ,OAAO;EAAQ,OAAO;CAAU;CAChD;EAAE,MAAM;EAAO,OAAO;EAAO,OAAO;CAAS;CAC7C;EAAE,MAAM;EAAQ,OAAO;EAAQ,OAAO;CAAU;CAChD;EAAE,MAAM;EAAS,OAAO;EAAS,OAAO;CAAW;CACnD;EAAE,MAAM;EAAQ,OAAO;EAAQ,OAAO;CAAU;AAClD;;AAGA,MAAa,sCAA8E;CACzF,OAAO;CACP,eAAe;CACf,eAAe;CAEf,iBAAiB;CACjB,iBA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