@react-querybuilder/datetime 8.23.1 → 8.24.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.
Files changed (77) hide show
  1. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CW3VX3A5.js +6 -0
  2. package/dist/cjs/{getDatetimeRuleProcessorTanStackDB-BK2fKPFN.js.map → getDatetimeRuleProcessorTanStackDB-CW3VX3A5.js.map} +1 -1
  3. package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +27 -27
  4. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +24 -25
  5. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +24 -25
  6. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +24 -25
  7. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +24 -25
  8. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +22 -23
  9. package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +27 -27
  10. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +24 -25
  11. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
  12. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +24 -25
  13. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
  14. package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
  15. package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
  16. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +24 -25
  17. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
  18. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +24 -25
  19. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
  20. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.d.ts +22 -23
  21. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +1 -1
  22. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -1
  23. package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-BhJEU5Yh.js +2 -0
  24. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-sJb39vcq.js.map → rqbDateTimeLibraryAPI.jsdate-BhJEU5Yh.js.map} +1 -1
  25. package/dist/cjs/utils-DDIzdVP8.js +4 -0
  26. package/dist/cjs/{utils-DdBYGWHZ.js.map → utils-DDIzdVP8.js.map} +1 -1
  27. package/dist/{getDatetimeRuleProcessorTanStackDB-Dpb4aOi1.js → getDatetimeRuleProcessorTanStackDB-BIClZR9Z.js} +2 -2
  28. package/dist/{getDatetimeRuleProcessorTanStackDB-Dpb4aOi1.js.map → getDatetimeRuleProcessorTanStackDB-BIClZR9Z.js.map} +1 -1
  29. package/dist/getDatetimeRuleProcessorTanStackDB-CeEUppsm.mjs +6 -0
  30. package/dist/{getDatetimeRuleProcessorTanStackDB-BWErgzW4.mjs.map → getDatetimeRuleProcessorTanStackDB-CeEUppsm.mjs.map} +1 -1
  31. package/dist/{objectSpread2-DzvyTx0z.js → objectSpread2-BRzeI7ye.js} +6 -6
  32. package/dist/{objectSpread2-DzvyTx0z.js.map → objectSpread2-BRzeI7ye.js.map} +1 -1
  33. package/dist/react-querybuilder_datetime.d.mts +27 -27
  34. package/dist/react-querybuilder_datetime.date-fns.d.mts +24 -25
  35. package/dist/react-querybuilder_datetime.dayjs.d.mts +24 -25
  36. package/dist/react-querybuilder_datetime.jsdate.d.mts +24 -25
  37. package/dist/react-querybuilder_datetime.legacy-esm.d.ts +27 -27
  38. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +24 -25
  39. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -2
  40. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +24 -25
  41. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -2
  42. package/dist/react-querybuilder_datetime.legacy-esm.js +2 -2
  43. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +24 -25
  44. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -2
  45. package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +24 -25
  46. package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -2
  47. package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +22 -23
  48. package/dist/react-querybuilder_datetime.legacy-esm.ui.js +4 -4
  49. package/dist/react-querybuilder_datetime.luxon.d.mts +24 -25
  50. package/dist/react-querybuilder_datetime.production.d.mts +27 -27
  51. package/dist/react-querybuilder_datetime.production.date-fns.d.mts +24 -25
  52. package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
  53. package/dist/react-querybuilder_datetime.production.dayjs.d.mts +24 -25
  54. package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
  55. package/dist/react-querybuilder_datetime.production.jsdate.d.mts +24 -25
  56. package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
  57. package/dist/react-querybuilder_datetime.production.luxon.d.mts +24 -25
  58. package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
  59. package/dist/react-querybuilder_datetime.production.mjs +1 -1
  60. package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
  61. package/dist/react-querybuilder_datetime.production.ui.d.mts +22 -23
  62. package/dist/react-querybuilder_datetime.production.ui.mjs +1 -1
  63. package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -1
  64. package/dist/react-querybuilder_datetime.ui.d.mts +22 -23
  65. package/dist/{rqbDateTimeLibraryAPI.jsdate-DTPN_G2s.js → rqbDateTimeLibraryAPI.jsdate-CKn6JOt9.js} +2 -2
  66. package/dist/{rqbDateTimeLibraryAPI.jsdate-DTPN_G2s.js.map → rqbDateTimeLibraryAPI.jsdate-CKn6JOt9.js.map} +1 -1
  67. package/dist/rqbDateTimeLibraryAPI.jsdate-D-7pwJfN.mjs +2 -0
  68. package/dist/{rqbDateTimeLibraryAPI.jsdate-Bpo2F8gW.mjs.map → rqbDateTimeLibraryAPI.jsdate-D-7pwJfN.mjs.map} +1 -1
  69. package/dist/utils-DJad3fT3.mjs +4 -0
  70. package/dist/{utils-DA8aluCt.mjs.map → utils-DJad3fT3.mjs.map} +1 -1
  71. package/package.json +23 -22
  72. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BK2fKPFN.js +0 -2
  73. package/dist/cjs/rqbDateTimeLibraryAPI.jsdate-sJb39vcq.js +0 -2
  74. package/dist/cjs/utils-DdBYGWHZ.js +0 -2
  75. package/dist/getDatetimeRuleProcessorTanStackDB-BWErgzW4.mjs +0 -2
  76. package/dist/rqbDateTimeLibraryAPI.jsdate-Bpo2F8gW.mjs +0 -2
  77. package/dist/utils-DA8aluCt.mjs +0 -2
@@ -10,7 +10,7 @@ import { FullOperator, FullOption as FullOption$1, QueryBuilderContextProvider,
10
10
  * `absoluteContent`/`relativeContent` are only needed to override them (e.g. to render
11
11
  * an icon component or localized text).
12
12
  */
13
- interface RelativeDateTimeToggleLabels {
13
+ export interface RelativeDateTimeToggleLabels {
14
14
  /** Accessible label (`aria-label`) for the toggle button. */
15
15
  label?: string;
16
16
  /** Tooltip shown while in absolute mode (clicking switches to relative). */
@@ -27,7 +27,7 @@ interface RelativeDateTimeToggleLabels {
27
27
  * the affordance (e.g. a toggle button) that switches a rule between absolute and
28
28
  * relative date/time entry.
29
29
  */
30
- interface RelativeDateTimeModeControlProps {
30
+ export interface RelativeDateTimeModeControlProps {
31
31
  /** Whether the rule is currently in relative mode. */
32
32
  isRelative: boolean;
33
33
  /** Switches the rule between absolute and relative mode. */
@@ -55,7 +55,7 @@ interface RelativeDateTimeModeControlProps {
55
55
  * operator-driven controller with {@link createOperatorModeController}, or supply a custom
56
56
  * object to fully control the UX.
57
57
  */
58
- interface RelativeDateTimeModeController {
58
+ export interface RelativeDateTimeModeController {
59
59
  /** Derives the current mode from the rule (its operator and/or value). */
60
60
  isRelative: (props: ValueEditorProps) => boolean;
61
61
  /**
@@ -70,7 +70,7 @@ interface RelativeDateTimeModeController {
70
70
  * {@link QueryBuilderDateTime} (or via the relative date/time config context). Every
71
71
  * field is optional; omitting all of them yields the zero-config toggle experience.
72
72
  */
73
- interface RelativeDateTimeEditorConfig {
73
+ export interface RelativeDateTimeEditorConfig {
74
74
  /** Strategy for switching between absolute and relative modes. Defaults to {@link toggleModeController}. */
75
75
  modeController?: RelativeDateTimeModeController;
76
76
  /** Anchor (reference-point) options. Defaults to {@link defaultRelativeDateTimeAnchors}. */
@@ -102,13 +102,13 @@ interface RelativeDateTimeEditorConfig {
102
102
  * });
103
103
  * ```
104
104
  */
105
- type RelativeOperatorMap = Record<string, string>;
105
+ export type RelativeOperatorMap = Record<string, string>;
106
106
  //#endregion
107
107
  //#region src/ui/QueryBuilderDateTime.d.ts
108
- declare const DateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
109
- declare const QueryBuilderDateTimeContext: QueryBuilderContextProvider;
108
+ export declare const DateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
109
+ export declare const QueryBuilderDateTimeContext: QueryBuilderContextProvider;
110
110
  /** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */
111
- interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
111
+ export interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
112
112
  children?: React.ReactNode;
113
113
  }
114
114
  /**
@@ -120,11 +120,11 @@ interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
120
120
  *
121
121
  * @group Components
122
122
  */
123
- declare const QueryBuilderDateTime: ({ children, modeController, anchors, units, toggleLabels, dateTimeAPI }: QueryBuilderDateTimeProps) => React.JSX.Element;
123
+ export declare const QueryBuilderDateTime: ({ children, modeController, anchors, units, toggleLabels, dateTimeAPI }: QueryBuilderDateTimeProps) => React.JSX.Element;
124
124
  //#endregion
125
125
  //#region src/ui/RelativeDateTimeConfigContext.d.ts
126
126
  /** Fully-resolved relative date/time editor config (no optional fields). */
127
- interface ResolvedRelativeDateTimeConfig {
127
+ export interface ResolvedRelativeDateTimeConfig {
128
128
  modeController: RelativeDateTimeModeController;
129
129
  anchors: FullOption$1<RelativeDateTimeAnchor>[];
130
130
  units: FullOption$1<RelativeDateTimeUnit>[];
@@ -135,9 +135,9 @@ interface ResolvedRelativeDateTimeConfig {
135
135
  * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.
136
136
  * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.
137
137
  */
138
- declare const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig>;
138
+ export declare const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig>;
139
139
  /** Reads the relative date/time editor config from context, merged with defaults. */
140
- declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
140
+ export declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
141
141
  //#endregion
142
142
  //#region src/ui/RelativeDateTimeValueEditor.d.ts
143
143
  /**
@@ -154,22 +154,22 @@ declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
154
154
  *
155
155
  * @group Components
156
156
  */
157
- declare const RelativeDateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
157
+ export declare const RelativeDateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
158
158
  //#endregion
159
159
  //#region src/ui/relativeDateTimeConstants.d.ts
160
160
  /**
161
161
  * Class name applied to the absolute/relative mode toggle button. Package-local (not part
162
162
  * of the core `standardClassnames`) to avoid coupling core to this extension.
163
163
  */
164
- declare const relativeDateTimeToggleClassName = "rule-value-dateTimeRelative-toggle";
164
+ export declare const relativeDateTimeToggleClassName = "rule-value-dateTimeRelative-toggle";
165
165
  /** Default value applied when switching a rule to relative mode. */
166
- declare const defaultRelativeDateTimeValue: RelativeDateTimeValue;
166
+ export declare const defaultRelativeDateTimeValue: RelativeDateTimeValue;
167
167
  /** Default anchor (reference-point) options for the relative date/time editor. */
168
- declare const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[];
168
+ export declare const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[];
169
169
  /** Default unit options for the relative date/time editor. */
170
- declare const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[];
170
+ export declare const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[];
171
171
  /** Default labels/content for the absolute/relative mode toggle. */
172
- declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels>;
172
+ export declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels>;
173
173
  //#endregion
174
174
  //#region src/ui/relativeDateTimeModeControllers.d.ts
175
175
  /**
@@ -179,13 +179,13 @@ declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeTogg
179
179
  *
180
180
  * @group Components
181
181
  */
182
- declare const RelativeDateTimeModeToggle: ({ isRelative, setMode, disabled, className, labels }: RelativeDateTimeModeControlProps) => React.JSX.Element;
182
+ export declare const RelativeDateTimeModeToggle: ({ isRelative, setMode, disabled, className, labels }: RelativeDateTimeModeControlProps) => React.JSX.Element;
183
183
  /**
184
184
  * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the
185
185
  * value shape and renders a compact toggle button to switch between absolute and
186
186
  * relative entry.
187
187
  */
188
- declare const toggleModeController: RelativeDateTimeModeController;
188
+ export declare const toggleModeController: RelativeDateTimeModeController;
189
189
  /**
190
190
  * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode
191
191
  * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the
@@ -197,7 +197,7 @@ declare const toggleModeController: RelativeDateTimeModeController;
197
197
  * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`
198
198
  * (e.g. `{ relativeEq: '=' }`). See the documentation.
199
199
  */
200
- declare const createOperatorModeController: (relativeOperators: string[] | ((operator: string) => boolean)) => RelativeDateTimeModeController;
200
+ export declare const createOperatorModeController: (relativeOperators: string[] | ((operator: string) => boolean)) => RelativeDateTimeModeController;
201
201
  interface FieldWithOperators {
202
202
  operators?: FullOperator[];
203
203
  [key: string]: unknown;
@@ -208,7 +208,6 @@ interface FieldWithOperators {
208
208
  * relative mode. Fields without an explicit `operators` list fall back to the core
209
209
  * `defaultOperators`.
210
210
  */
211
- declare const withRelativeOperators: <F extends FieldWithOperators>(fields: F[], operators: FullOperator[]) => F[];
211
+ export declare const withRelativeOperators: <F extends FieldWithOperators>(fields: F[], operators: FullOperator[]) => F[];
212
212
  //#endregion
213
- export { DateTimeValueEditor, QueryBuilderDateTime, QueryBuilderDateTimeContext, QueryBuilderDateTimeProps, RelativeDateTimeConfigContext, RelativeDateTimeEditorConfig, RelativeDateTimeModeControlProps, RelativeDateTimeModeController, RelativeDateTimeModeToggle, RelativeDateTimeToggleLabels, RelativeDateTimeValueEditor, RelativeOperatorMap, ResolvedRelativeDateTimeConfig, createOperatorModeController, defaultRelativeDateTimeAnchors, defaultRelativeDateTimeToggleLabels, defaultRelativeDateTimeUnits, defaultRelativeDateTimeValue, relativeDateTimeToggleClassName, toggleModeController, useRelativeDateTimeConfig, withRelativeOperators };
214
213
  //# sourceMappingURL=react-querybuilder_datetime.production.ui.d.mts.map
@@ -1,2 +1,2 @@
1
- import{i as e,r as t}from"./utils-DA8aluCt.mjs";import{t as n}from"./rqbDateTimeLibraryAPI.jsdate-Bpo2F8gW.mjs";import*as r from"react";import{createContext as i,useCallback as a,useContext as o,useMemo as s}from"react";import{QueryBuilderContext as c,ValueEditor as l,clsx as u,defaultOperators as d,getCompatContextProvider as f,parseNumber as p,standardClassnames as m,toArray as h,useValueEditor as g}from"react-querybuilder";const _=i(null),v=()=>o(_),y=`rule-value-dateTimeRelative-toggle`,b={mode:`relative`,anchor:`now`,offset:0,unit:`day`},x=[{name:`now`,value:`now`,label:`now`},{name:`startOfDay`,value:`startOfDay`,label:`start of day`},{name:`endOfDay`,value:`endOfDay`,label:`end of day`},{name:`startOfWeek`,value:`startOfWeek`,label:`start of week`},{name:`endOfWeek`,value:`endOfWeek`,label:`end of week`},{name:`startOfMonth`,value:`startOfMonth`,label:`start of month`},{name:`endOfMonth`,value:`endOfMonth`,label:`end of month`},{name:`startOfYear`,value:`startOfYear`,label:`start of year`},{name:`endOfYear`,value:`endOfYear`,label:`end of year`}],S=[{name:`minute`,value:`minute`,label:`minute(s)`},{name:`hour`,value:`hour`,label:`hour(s)`},{name:`day`,value:`day`,label:`day(s)`},{name:`week`,value:`week`,label:`week(s)`},{name:`month`,value:`month`,label:`month(s)`},{name:`year`,value:`year`,label:`year(s)`}],C={label:`Toggle relative date/time`,absoluteTitle:`Absolute date/time (click for relative)`,relativeTitle:`Relative date/time (click for absolute)`,absoluteContent:``,relativeContent:``},w=({isRelative:e,setMode:t,disabled:n,className:i,labels:a})=>{let o=r.useCallback(()=>t(e?`absolute`:`relative`),[t,e]);return r.createElement(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a.label,title:e?a.relativeTitle:a.absoluteTitle,disabled:n,className:u(y,i),onClick:o},e?a.relativeContent:a.absoluteContent)},T={isRelative:t=>e(t.value),ModeControl:w},E=e=>({isRelative:t=>typeof e==`function`?e(t.operator):e.includes(t.operator)}),D=(e,t)=>e.map(e=>({...e,operators:[...e.operators??d,...t]})),O=i({}),k=()=>{let e=o(O);return s(()=>({modeController:e.modeController??T,anchors:e.anchors??x,units:e.units??S,toggleLabels:{...C,...e.toggleLabels},dateTimeAPI:e.dateTimeAPI??n}),[e])},A=[],j={name:``,value:``,label:``},M=t=>Array.isArray(t)?t:e(t)?[t]:h(t),N=({baseProps:t,value:n,onChange:i,absoluteOperator:o,config:s,SelectorComponent:c,NumericEditorComponent:l,valueListItemClassName:u,numericSchema:d})=>{let{schema:f,disabled:h,title:g,testID:_}=t,{modeController:v,anchors:y,units:x,toggleLabels:S}=s,C=v.isRelative({...t,value:n}),w=e(n)?n:b,T=a(e=>i(e===`relative`?b:``),[i]),E=a(e=>i({...w,anchor:e}),[i,w]),D=a(e=>i({...w,offset:p(e,{parseNumbers:!0})||0}),[i,w]),O=a(e=>i({...w,unit:e}),[i,w]),{ModeControl:k}=v;return r.createElement(r.Fragment,null,k&&r.createElement(k,{isRelative:C,setMode:T,schema:f,disabled:h,className:u,title:g,testID:_,labels:S}),C?r.createElement(r.Fragment,null,r.createElement(c,{schema:f,testID:_,title:g,className:u,handleOnChange:E,disabled:h,value:w.anchor,options:y,multiple:!1,listsAsArrays:!1,path:A,level:0}),r.createElement(l,{skipHook:!0,testID:_,inputType:`number`,title:g,className:u,disabled:h,handleOnChange:D,field:``,operator:``,value:w.offset,valueSource:`value`,fieldData:j,schema:d,path:A,level:0,rule:{field:``,operator:`=`,value:w.offset}}),w.offset!==0&&r.createElement(c,{schema:f,testID:_,title:g,className:u,handleOnChange:O,disabled:h,value:w.unit,options:x,multiple:!1,listsAsArrays:!1,path:A,level:0})):r.createElement(z,{...t,operator:o,value:n,handleOnChange:i,className:m.value}))},P=e=>{let{valueListItemClassName:t}=g(e),{className:n,value:i,handleOnChange:o,schema:c,operator:d,separator:f}=e,{suppressStandardClassnames:p}=c,h=e.selectorComponent??c.controls.valueSelector,_=v()??l,y=k(),b=s(()=>({...c,parseNumbers:!0}),[c]),x=s(()=>u(p||m.valueDateTimeRelative,n),[p,n]),S=d===`between`||d===`notBetween`,C=s(()=>M(i),[i]),w=a(e=>t=>{let n=[C[0],C[1]];n[e]=t,o(n)},[C,o]);return S?r.createElement(`span`,{className:x},r.createElement(N,{baseProps:e,value:C[0],onChange:w(0),absoluteOperator:`=`,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b}),f,r.createElement(N,{baseProps:e,value:C[1],onChange:w(1),absoluteOperator:`=`,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b})):r.createElement(`span`,{className:x},r.createElement(N,{baseProps:e,value:i,onChange:o,absoluteOperator:d,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b}))},F=(e,n)=>!t(e.valueSource)&&(e.type===`text`&&(n===`date`||n===`datetime-local`)||/^(?:date|datetime|timestamp)\b/i.test(e.fieldData?.datatype)),I=e=>`${e}`.padStart(2,`0`),L=(e,t)=>{let n=`${e.getFullYear()}-${I(e.getMonth()+1)}-${I(e.getDate())}`;return t?`${n}T${I(e.getHours())}:${I(e.getMinutes())}`:n},R=({editor:e,...t})=>e?r.createElement(e,t):r.createElement(l,{...t,skipHook:!0}),z=e=>{let t=g(e),n=v(),{dateTimeAPI:i}=k(),a=e=>r.createElement(R,{editor:n,...e});if(!F(e,t.inputTypeCoerced))return a(e);if(i.isValid(e.value)){let n=L(i.toDate(e.value),t.inputTypeCoerced!==`date`);return a({...e,value:n})}return a(e)},B=f({controlElements:{valueEditor:e=>{let t=g(e),n=v();return F(e,t.inputTypeCoerced)?r.createElement(P,e):r.createElement(R,{editor:n,...e})}}}),V=({children:e,modeController:t,anchors:n,units:i,toggleLabels:a,dateTimeAPI:l})=>{let u=s(()=>({modeController:t,anchors:n,units:i,toggleLabels:a,dateTimeAPI:l}),[t,n,i,a,l]),d=o(c).controlElements?.valueEditor??null;return r.createElement(O.Provider,{value:u},r.createElement(_.Provider,{value:d},r.createElement(B,null,e)))};export{z as DateTimeValueEditor,V as QueryBuilderDateTime,B as QueryBuilderDateTimeContext,O as RelativeDateTimeConfigContext,w as RelativeDateTimeModeToggle,P as RelativeDateTimeValueEditor,E as createOperatorModeController,x as defaultRelativeDateTimeAnchors,C as defaultRelativeDateTimeToggleLabels,S as defaultRelativeDateTimeUnits,b as defaultRelativeDateTimeValue,y as relativeDateTimeToggleClassName,T as toggleModeController,k as useRelativeDateTimeConfig,D as withRelativeOperators};
1
+ import{i as e,r as t}from"./utils-DJad3fT3.mjs";import{t as n}from"./rqbDateTimeLibraryAPI.jsdate-D-7pwJfN.mjs";import*as r from"react";import{createContext as i,useCallback as a,useContext as o,useMemo as s}from"react";import{QueryBuilderContext as c,ValueEditor as l,clsx as u,defaultOperators as d,getCompatContextProvider as f,parseNumber as p,standardClassnames as m,toArray as h,useValueEditor as g}from"react-querybuilder";const _=i(null),v=()=>o(_),y=`rule-value-dateTimeRelative-toggle`,b={mode:`relative`,anchor:`now`,offset:0,unit:`day`},x=[{name:`now`,value:`now`,label:`now`},{name:`startOfDay`,value:`startOfDay`,label:`start of day`},{name:`endOfDay`,value:`endOfDay`,label:`end of day`},{name:`startOfWeek`,value:`startOfWeek`,label:`start of week`},{name:`endOfWeek`,value:`endOfWeek`,label:`end of week`},{name:`startOfMonth`,value:`startOfMonth`,label:`start of month`},{name:`endOfMonth`,value:`endOfMonth`,label:`end of month`},{name:`startOfYear`,value:`startOfYear`,label:`start of year`},{name:`endOfYear`,value:`endOfYear`,label:`end of year`}],S=[{name:`minute`,value:`minute`,label:`minute(s)`},{name:`hour`,value:`hour`,label:`hour(s)`},{name:`day`,value:`day`,label:`day(s)`},{name:`week`,value:`week`,label:`week(s)`},{name:`month`,value:`month`,label:`month(s)`},{name:`year`,value:`year`,label:`year(s)`}],C={label:`Toggle relative date/time`,absoluteTitle:`Absolute date/time (click for relative)`,relativeTitle:`Relative date/time (click for absolute)`,absoluteContent:``,relativeContent:``},w=({isRelative:e,setMode:t,disabled:n,className:i,labels:a})=>{let o=r.useCallback(()=>t(e?`absolute`:`relative`),[t,e]);return/* @__PURE__ */ r.createElement(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":a.label,title:e?a.relativeTitle:a.absoluteTitle,disabled:n,className:u(y,i),onClick:o},e?a.relativeContent:a.absoluteContent)},T={isRelative:t=>e(t.value),ModeControl:w},E=e=>({isRelative:t=>typeof e==`function`?e(t.operator):e.includes(t.operator)}),D=(e,t)=>e.map(e=>({...e,operators:[...e.operators??d,...t]})),O=i({}),k=()=>{let e=o(O);return s(()=>({modeController:e.modeController??T,anchors:e.anchors??x,units:e.units??S,toggleLabels:{...C,...e.toggleLabels},dateTimeAPI:e.dateTimeAPI??n}),[e])},A=[],j={name:``,value:``,label:``},M=t=>Array.isArray(t)?t:e(t)?[t]:h(t),N=({baseProps:t,value:n,onChange:i,absoluteOperator:o,config:s,SelectorComponent:c,NumericEditorComponent:l,valueListItemClassName:u,numericSchema:d})=>{let{schema:f,disabled:h,title:g,testID:_}=t,{modeController:v,anchors:y,units:x,toggleLabels:S}=s,C=v.isRelative({...t,value:n}),w=e(n)?n:b,T=a(e=>i(e===`relative`?b:``),[i]),E=a(e=>i({...w,anchor:e}),[i,w]),D=a(e=>i({...w,offset:p(e,{parseNumbers:!0})||0}),[i,w]),O=a(e=>i({...w,unit:e}),[i,w]),{ModeControl:k}=v;return/* @__PURE__ */ r.createElement(r.Fragment,null,k&&/* @__PURE__ */ r.createElement(k,{isRelative:C,setMode:T,schema:f,disabled:h,className:u,title:g,testID:_,labels:S}),C?/* @__PURE__ */ r.createElement(r.Fragment,null,/* @__PURE__ */ r.createElement(c,{schema:f,testID:_,title:g,className:u,handleOnChange:E,disabled:h,value:w.anchor,options:y,multiple:!1,listsAsArrays:!1,path:A,level:0}),/* @__PURE__ */ r.createElement(l,{skipHook:!0,testID:_,inputType:`number`,title:g,className:u,disabled:h,handleOnChange:D,field:``,operator:``,value:w.offset,valueSource:`value`,fieldData:j,schema:d,path:A,level:0,rule:{field:``,operator:`=`,value:w.offset}}),w.offset!==0&&/* @__PURE__ */ r.createElement(c,{schema:f,testID:_,title:g,className:u,handleOnChange:O,disabled:h,value:w.unit,options:x,multiple:!1,listsAsArrays:!1,path:A,level:0})):/* @__PURE__ */ r.createElement(z,{...t,operator:o,value:n,handleOnChange:i,className:m.value}))},P=e=>{let{valueListItemClassName:t}=g(e),{className:n,value:i,handleOnChange:o,schema:c,operator:d,separator:f}=e,{suppressStandardClassnames:p}=c,h=e.selectorComponent??c.controls.valueSelector,_=v()??l,y=k(),b=s(()=>({...c,parseNumbers:!0}),[c]),x=s(()=>u(p||m.valueDateTimeRelative,n),[p,n]),S=d===`between`||d===`notBetween`,C=s(()=>M(i),[i]),w=a(e=>t=>{let n=[C[0],C[1]];n[e]=t,o(n)},[C,o]);return S?/* @__PURE__ */ r.createElement(`span`,{className:x},/* @__PURE__ */ r.createElement(N,{baseProps:e,value:C[0],onChange:w(0),absoluteOperator:`=`,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b}),f,/* @__PURE__ */ r.createElement(N,{baseProps:e,value:C[1],onChange:w(1),absoluteOperator:`=`,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b})):/* @__PURE__ */ r.createElement(`span`,{className:x},/* @__PURE__ */ r.createElement(N,{baseProps:e,value:i,onChange:o,absoluteOperator:d,config:y,SelectorComponent:h,NumericEditorComponent:_,valueListItemClassName:t,numericSchema:b}))},F=(e,n)=>!t(e.valueSource)&&(e.type===`text`&&(n===`date`||n===`datetime-local`)||/^(?:date|datetime|timestamp)\b/i.test(e.fieldData?.datatype)),I=e=>`${e}`.padStart(2,`0`),L=(e,t)=>{let n=`${e.getFullYear()}-${I(e.getMonth()+1)}-${I(e.getDate())}`;return t?`${n}T${I(e.getHours())}:${I(e.getMinutes())}`:n},R=({editor:e,...t})=>e?/* @__PURE__ */ r.createElement(e,t):/* @__PURE__ */ r.createElement(l,{...t,skipHook:!0}),z=e=>{let t=g(e),n=v(),{dateTimeAPI:i}=k(),a=e=>/* @__PURE__ */ r.createElement(R,{editor:n,...e});if(!F(e,t.inputTypeCoerced))return a(e);if(i.isValid(e.value)){let n=L(i.toDate(e.value),t.inputTypeCoerced!==`date`);return a({...e,value:n})}return a(e)},B=f({controlElements:{valueEditor:e=>{let t=g(e),n=v();return F(e,t.inputTypeCoerced)?/* @__PURE__ */ r.createElement(P,e):/* @__PURE__ */ r.createElement(R,{editor:n,...e})}}}),V=({children:e,modeController:t,anchors:n,units:i,toggleLabels:a,dateTimeAPI:l})=>{let u=s(()=>({modeController:t,anchors:n,units:i,toggleLabels:a,dateTimeAPI:l}),[t,n,i,a,l]),d=o(c).controlElements?.valueEditor??null;return/* @__PURE__ */ r.createElement(O.Provider,{value:u},/* @__PURE__ */ r.createElement(_.Provider,{value:d},/* @__PURE__ */ r.createElement(B,null,e)))};export{z as DateTimeValueEditor,V as QueryBuilderDateTime,B as QueryBuilderDateTimeContext,O as RelativeDateTimeConfigContext,w as RelativeDateTimeModeToggle,P as RelativeDateTimeValueEditor,E as createOperatorModeController,x as defaultRelativeDateTimeAnchors,C as defaultRelativeDateTimeToggleLabels,S as defaultRelativeDateTimeUnits,b as defaultRelativeDateTimeValue,y as relativeDateTimeToggleClassName,T as toggleModeController,k as useRelativeDateTimeConfig,D as withRelativeOperators};
2
2
  //# sourceMappingURL=react-querybuilder_datetime.production.ui.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-querybuilder_datetime.production.ui.mjs","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":"8aAWA,MAAa,EACX,EAA4D,IAAI,EAGrD,MACX,EAAW,CAA2B,ECR3B,EAAkC,qCAGlC,EAAsD,CACjE,KAAM,WACN,OAAQ,MACR,OAAQ,EACR,KAAM,KACR,EAGa,EAAuE,CAClF,CAAE,KAAM,MAAO,MAAO,MAAO,MAAO,KAAM,EAC1C,CAAE,KAAM,aAAc,MAAO,aAAc,MAAO,cAAe,EACjE,CAAE,KAAM,WAAY,MAAO,WAAY,MAAO,YAAa,EAC3D,CAAE,KAAM,cAAe,MAAO,cAAe,MAAO,eAAgB,EACpE,CAAE,KAAM,YAAa,MAAO,YAAa,MAAO,aAAc,EAC9D,CAAE,KAAM,eAAgB,MAAO,eAAgB,MAAO,gBAAiB,EACvE,CAAE,KAAM,aAAc,MAAO,aAAc,MAAO,cAAe,EACjE,CAAE,KAAM,cAAe,MAAO,cAAe,MAAO,eAAgB,EACpE,CAAE,KAAM,YAAa,MAAO,YAAa,MAAO,aAAc,CAChE,EAGa,EAAmE,CAC9E,CAAE,KAAM,SAAU,MAAO,SAAU,MAAO,WAAY,EACtD,CAAE,KAAM,OAAQ,MAAO,OAAQ,MAAO,SAAU,EAChD,CAAE,KAAM,MAAO,MAAO,MAA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AC9B,EAAI,mBAAqB,MAC3B,EACA,OAAO,EAAS,CAAE,GAAG,EAAO,OAAM,CAAC,CACrC,CAEA,OAAO,EAAS,CAAK,CACvB,EAiBa,EAA2D,EAAyB,CAC/F,gBAAiB,CAAE,YAZoB,GAA+C,CACtF,IAAM,EAAM,EAAe,CAAK,EAC1B,EAAkB,EAAwB,EAMhD,OAJI,EAAiB,EAAO,EAAI,gBAAgB,EACvC,EAAA,cAAC,EAAgC,CAAQ,EAG3C,EAAA,cAAC,EAAD,CAAqB,OAAQ,EAAiB,GAAI,CAAQ,CAAA,CACnE,CAGkE,CAClE,CAAC,EAgBY,GAAwB,CACnC,WACA,iBACA,UACA,QACA,eACA,iBACkD,CAClD,IAAM,EAAS,OACwB,CACnC,iBACA,UACA,QACA,eACA,aACF,GACA,CAAC,EAAgB,EAAS,EAAO,EAAc,CAAW,CAC5D,EAIM,EAAwB,EAAW,CAAmB,CAAC,CAAC,iBAAiB,aAC7E,KAEF,OACE,EAAA,cAAC,EAA8B,SAA/B,CAAwC,MAAO,CAIP,EAHtC,EAAA,cAAC,EAA4B,SAA7B,CAAsC,MAAO,CAEP,EADpC,EAAA,cAAC,EAAA,KAA6B,CAAsC,CAChC,CACA,CAE5C"}
1
+ {"version":3,"file":"react-querybuilder_datetime.production.ui.mjs","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":"8aAWA,MAAa,EACX,EAA4D,IAAI,EAGrD,MACX,EAAW,CAA2B,ECR3B,EAAkC,qCAGlC,EAAsD,CACjE,KAAM,WACN,OAAQ,MACR,OAAQ,EACR,KAAM,KACR,EAGa,EAAuE,CAClF,CAAE,KAAM,MAAO,MAAO,MAAO,MAAO,KAAM,EAC1C,CAAE,KAAM,aAAc,MAAO,aAAc,MAAO,cAAe,EACjE,CAAE,KAAM,WAAY,MAAO,WAAY,MAAO,YAAa,EAC3D,CAAE,KAAM,cAAe,MAAO,cAAe,MAAO,eAAgB,EACpE,CAAE,KAAM,YAAa,MAAO,YAAa,MAAO,aAAc,EAC9D,CAAE,KAAM,eAAgB,MAAO,eAAgB,MAAO,gBAAiB,EACvE,CAAE,KAAM,aAAc,MAAO,aAAc,M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AAwB,EAC1C,CAAE,eAAgB,EAA0B,EAI5C,EAAY,GAAwB,kBAAA,cAAC,EAAD,CAAqB,OAAQ,EAAiB,GAAI,CAAI,CAAA,EAEhG,GAAI,CAAC,EAAiB,EAAO,EAAI,gBAAgB,EAC/C,OAAO,EAAS,CAAK,EAGvB,GAAI,EAAY,QAAQ,EAAM,KAAK,EAAG,CACpC,IAAM,EAAQ,EACZ,EAAY,OAAO,EAAM,KAAK,EAC9B,EAAI,mBAAqB,MAC3B,EACA,OAAO,EAAS,CAAE,GAAG,EAAO,OAAM,CAAC,CACrC,CAEA,OAAO,EAAS,CAAK,CACvB,EAiBa,EAA2D,EAAyB,CAC/F,gBAAiB,CAAE,YAZoB,GAA+C,CACtF,IAAM,EAAM,EAAe,CAAK,EAC1B,EAAkB,EAAwB,EAMhD,OAJI,EAAiB,EAAO,EAAI,gBAAgB,EACvC,kBAAA,cAAC,EAAgC,CAAQ,EAG3C,kBAAA,cAAC,EAAD,CAAqB,OAAQ,EAAiB,GAAI,CAAQ,CAAA,CACnE,CAGkE,CAClE,CAAC,EAgBY,GAAwB,CACnC,WACA,iBACA,UACA,QACA,eACA,iBACkD,CAClD,IAAM,EAAS,OACwB,CACnC,iBACA,UACA,QACA,eACA,aACF,GACA,CAAC,EAAgB,EAAS,EAAO,EAAc,CAAW,CAC5D,EAIM,EAAwB,EAAW,CAAmB,CAAC,CAAC,iBAAiB,aAC7E,KAEF,MACE,kBAAA,cAAC,EAA8B,SAA/B,CAAwC,MAAO,CAIP,EAHtC,kBAAA,cAAC,EAA4B,SAA7B,CAAsC,MAAO,CAEP,EADpC,kBAAA,cAAC,EAAA,KAA6B,CAAsC,CAChC,CACA,CAE5C"}
@@ -10,7 +10,7 @@ import { FullOperator, FullOption as FullOption$1, QueryBuilderContextProvider,
10
10
  * `absoluteContent`/`relativeContent` are only needed to override them (e.g. to render
11
11
  * an icon component or localized text).
12
12
  */
13
- interface RelativeDateTimeToggleLabels {
13
+ export interface RelativeDateTimeToggleLabels {
14
14
  /** Accessible label (`aria-label`) for the toggle button. */
15
15
  label?: string;
16
16
  /** Tooltip shown while in absolute mode (clicking switches to relative). */
@@ -27,7 +27,7 @@ interface RelativeDateTimeToggleLabels {
27
27
  * the affordance (e.g. a toggle button) that switches a rule between absolute and
28
28
  * relative date/time entry.
29
29
  */
30
- interface RelativeDateTimeModeControlProps {
30
+ export interface RelativeDateTimeModeControlProps {
31
31
  /** Whether the rule is currently in relative mode. */
32
32
  isRelative: boolean;
33
33
  /** Switches the rule between absolute and relative mode. */
@@ -55,7 +55,7 @@ interface RelativeDateTimeModeControlProps {
55
55
  * operator-driven controller with {@link createOperatorModeController}, or supply a custom
56
56
  * object to fully control the UX.
57
57
  */
58
- interface RelativeDateTimeModeController {
58
+ export interface RelativeDateTimeModeController {
59
59
  /** Derives the current mode from the rule (its operator and/or value). */
60
60
  isRelative: (props: ValueEditorProps) => boolean;
61
61
  /**
@@ -70,7 +70,7 @@ interface RelativeDateTimeModeController {
70
70
  * {@link QueryBuilderDateTime} (or via the relative date/time config context). Every
71
71
  * field is optional; omitting all of them yields the zero-config toggle experience.
72
72
  */
73
- interface RelativeDateTimeEditorConfig {
73
+ export interface RelativeDateTimeEditorConfig {
74
74
  /** Strategy for switching between absolute and relative modes. Defaults to {@link toggleModeController}. */
75
75
  modeController?: RelativeDateTimeModeController;
76
76
  /** Anchor (reference-point) options. Defaults to {@link defaultRelativeDateTimeAnchors}. */
@@ -102,13 +102,13 @@ interface RelativeDateTimeEditorConfig {
102
102
  * });
103
103
  * ```
104
104
  */
105
- type RelativeOperatorMap = Record<string, string>;
105
+ export type RelativeOperatorMap = Record<string, string>;
106
106
  //#endregion
107
107
  //#region src/ui/QueryBuilderDateTime.d.ts
108
- declare const DateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
109
- declare const QueryBuilderDateTimeContext: QueryBuilderContextProvider;
108
+ export declare const DateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
109
+ export declare const QueryBuilderDateTimeContext: QueryBuilderContextProvider;
110
110
  /** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */
111
- interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
111
+ export interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
112
112
  children?: React.ReactNode;
113
113
  }
114
114
  /**
@@ -120,11 +120,11 @@ interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {
120
120
  *
121
121
  * @group Components
122
122
  */
123
- declare const QueryBuilderDateTime: ({ children, modeController, anchors, units, toggleLabels, dateTimeAPI }: QueryBuilderDateTimeProps) => React.JSX.Element;
123
+ export declare const QueryBuilderDateTime: ({ children, modeController, anchors, units, toggleLabels, dateTimeAPI }: QueryBuilderDateTimeProps) => React.JSX.Element;
124
124
  //#endregion
125
125
  //#region src/ui/RelativeDateTimeConfigContext.d.ts
126
126
  /** Fully-resolved relative date/time editor config (no optional fields). */
127
- interface ResolvedRelativeDateTimeConfig {
127
+ export interface ResolvedRelativeDateTimeConfig {
128
128
  modeController: RelativeDateTimeModeController;
129
129
  anchors: FullOption$1<RelativeDateTimeAnchor>[];
130
130
  units: FullOption$1<RelativeDateTimeUnit>[];
@@ -135,9 +135,9 @@ interface ResolvedRelativeDateTimeConfig {
135
135
  * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.
136
136
  * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.
137
137
  */
138
- declare const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig>;
138
+ export declare const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig>;
139
139
  /** Reads the relative date/time editor config from context, merged with defaults. */
140
- declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
140
+ export declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
141
141
  //#endregion
142
142
  //#region src/ui/RelativeDateTimeValueEditor.d.ts
143
143
  /**
@@ -154,22 +154,22 @@ declare const useRelativeDateTimeConfig: () => ResolvedRelativeDateTimeConfig;
154
154
  *
155
155
  * @group Components
156
156
  */
157
- declare const RelativeDateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
157
+ export declare const RelativeDateTimeValueEditor: (props: ValueEditorProps) => React.JSX.Element;
158
158
  //#endregion
159
159
  //#region src/ui/relativeDateTimeConstants.d.ts
160
160
  /**
161
161
  * Class name applied to the absolute/relative mode toggle button. Package-local (not part
162
162
  * of the core `standardClassnames`) to avoid coupling core to this extension.
163
163
  */
164
- declare const relativeDateTimeToggleClassName = "rule-value-dateTimeRelative-toggle";
164
+ export declare const relativeDateTimeToggleClassName = "rule-value-dateTimeRelative-toggle";
165
165
  /** Default value applied when switching a rule to relative mode. */
166
- declare const defaultRelativeDateTimeValue: RelativeDateTimeValue;
166
+ export declare const defaultRelativeDateTimeValue: RelativeDateTimeValue;
167
167
  /** Default anchor (reference-point) options for the relative date/time editor. */
168
- declare const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[];
168
+ export declare const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[];
169
169
  /** Default unit options for the relative date/time editor. */
170
- declare const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[];
170
+ export declare const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[];
171
171
  /** Default labels/content for the absolute/relative mode toggle. */
172
- declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels>;
172
+ export declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels>;
173
173
  //#endregion
174
174
  //#region src/ui/relativeDateTimeModeControllers.d.ts
175
175
  /**
@@ -179,13 +179,13 @@ declare const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeTogg
179
179
  *
180
180
  * @group Components
181
181
  */
182
- declare const RelativeDateTimeModeToggle: ({ isRelative, setMode, disabled, className, labels }: RelativeDateTimeModeControlProps) => React.JSX.Element;
182
+ export declare const RelativeDateTimeModeToggle: ({ isRelative, setMode, disabled, className, labels }: RelativeDateTimeModeControlProps) => React.JSX.Element;
183
183
  /**
184
184
  * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the
185
185
  * value shape and renders a compact toggle button to switch between absolute and
186
186
  * relative entry.
187
187
  */
188
- declare const toggleModeController: RelativeDateTimeModeController;
188
+ export declare const toggleModeController: RelativeDateTimeModeController;
189
189
  /**
190
190
  * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode
191
191
  * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the
@@ -197,7 +197,7 @@ declare const toggleModeController: RelativeDateTimeModeController;
197
197
  * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`
198
198
  * (e.g. `{ relativeEq: '=' }`). See the documentation.
199
199
  */
200
- declare const createOperatorModeController: (relativeOperators: string[] | ((operator: string) => boolean)) => RelativeDateTimeModeController;
200
+ export declare const createOperatorModeController: (relativeOperators: string[] | ((operator: string) => boolean)) => RelativeDateTimeModeController;
201
201
  interface FieldWithOperators {
202
202
  operators?: FullOperator[];
203
203
  [key: string]: unknown;
@@ -208,7 +208,6 @@ interface FieldWithOperators {
208
208
  * relative mode. Fields without an explicit `operators` list fall back to the core
209
209
  * `defaultOperators`.
210
210
  */
211
- declare const withRelativeOperators: <F extends FieldWithOperators>(fields: F[], operators: FullOperator[]) => F[];
211
+ export declare const withRelativeOperators: <F extends FieldWithOperators>(fields: F[], operators: FullOperator[]) => F[];
212
212
  //#endregion
213
- export { DateTimeValueEditor, QueryBuilderDateTime, QueryBuilderDateTimeContext, QueryBuilderDateTimeProps, RelativeDateTimeConfigContext, RelativeDateTimeEditorConfig, RelativeDateTimeModeControlProps, RelativeDateTimeModeController, RelativeDateTimeModeToggle, RelativeDateTimeToggleLabels, RelativeDateTimeValueEditor, RelativeOperatorMap, ResolvedRelativeDateTimeConfig, createOperatorModeController, defaultRelativeDateTimeAnchors, defaultRelativeDateTimeToggleLabels, defaultRelativeDateTimeUnits, defaultRelativeDateTimeValue, relativeDateTimeToggleClassName, toggleModeController, useRelativeDateTimeConfig, withRelativeOperators };
214
213
  //# sourceMappingURL=react-querybuilder_datetime.ui.d.mts.map
@@ -1,4 +1,4 @@
1
- import { r as isISOStringDateOnly } from "./objectSpread2-DzvyTx0z.js";
1
+ import { r as isISOStringDateOnly } from "./objectSpread2-BRzeI7ye.js";
2
2
  //#region src/rqbDateTimeLibraryAPI.jsdate.ts
3
3
  const invalidDate = /* @__PURE__ */ new Date(NaN);
4
4
  const dateRegExp = /^(\d{4})-(\d{2})-(\d{2})([T ](\d{2}):(\d{2}):(\d{2})(\.(\d{1,3}))?)?/;
@@ -114,4 +114,4 @@ const rqbDateTimeLibraryAPI = {
114
114
  //#endregion
115
115
  export { rqbDateTimeLibraryAPI as t };
116
116
 
117
- //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-DTPN_G2s.js.map
117
+ //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-CKn6JOt9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-DTPN_G2s.js","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endOf,\n add,\n};\n"],"mappings":";;AAOA,MAAM,8BAAc,IAAI,KAAK,GAAU;AAEvC,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAqB;CACnC,IAAI,aAAa,MAAM,OAAO;CAE9B,MAAM,UAAU,WAAW,KAAK,CAAC;CAEjC,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,UAAU,OAAO;CAC/D,MAAM,CAAC,MAAM,OAAO,KAAK,OAAO,SAAS,SAAS,MAAM;EAAC;EAAM;EAAI;EAAI;EAAI;EAAI;EAAI,QAAA,QAAA,QAAA,KAAA,IAAA,MAAO;CAAG,CAAC,CAC3F,OAAO,OAAO,CAAC,CACf,IAAI,MAAM;CAEb,MAAM,aAAa,QAAQ;CAE3B,OAAO,KACH,IAAI,KAAK,KAAK,IAAI,MAAM,YAAY,KAAK,OAAO,SAAS,SAAS,EAAE,CAAC,IACrE,IAAI,KAAK,MAAM,YAAY,GAAG;AACpC;AAEA,MAAM,WAAW,MAAqB;CACpC,MAAM,UAAU,OAAO,CAAC;CACxB,OAAO,mBAAmB,QAAQ,CAAC,OAAO,MAAM,QAA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C;GAClC;EACF,KAAK;GACH,EAAE,SAAS,EAAE,SAAS,IAAI,MAAM;GAChC;EACF,KAAK,QACH,EAAE,YAAY,EAAE,YAAY,IAAI,MAAM;CAE1C;CACA,OAAO;AACT;;;;;;;AAQA,MAAa,wBAA+C;CAC1D,SAAQ,MAAK,OAAO,CAAC,CAAC,CAAC,YAAY;CACnC,UAAU,GAAG,MAAM;EACjB,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ;EAChC,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ;EAChC,OAAO,CAAC,OAAO,MAAM,KAAK,KAAK,CAAC,OAAO,MAAM,KAAK,KAAK,QAAQ;CACjE;CACA,WAAW,GAAG,MAAM;EAClB,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ;EAChC,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ;EAChC,OAAO,CAAC,OAAO,MAAM,KAAK,KAAK,CAAC,OAAO,MAAM,KAAK,KAAK,QAAQ;CACjE;CACA,SAAS,GAAG,MAAM;EAChB,MAAM,UAAU,OAAO,CAAC;EACxB,MAAM,UAAU,OAAO,CAAC;EACxB,OAAO,oBAAoB,CAAC,KAAK,oBAAoB,CAAC,IAClD,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,IAChD,QAAQ,QAAQ,MAAM,QAAQ,QAAQ;CAC5C;CACA;CACA;CACA,cAAa,MAAK;EAChB,MAAM,UAAU,OAAO,CAAC;EACxB,OAAO,QAAQ,OAAO,IAAI,QAAQ,YAAY,IAAI;CACpD;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-CKn6JOt9.js","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endOf,\n add,\n};\n"],"mappings":";;AAOA,MAAM,8BAAc,IAAI,KAAK,GAAU;AAEvC,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAqB;CACnC,IAAI,aAAa,MAAM,OAAO;CAE9B,MAAM,UAAU,WAAW,KAAK,CAAC;CAEjC,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,UAAU,OAAO;CAC/D,MAAM,CAAC,MAAM,OAAO,KAAK,OAAO,SAAS,SAAS,MAAM;EAAC;EAAM;EAAI;EAAI;EAAI;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CACA,cAAa,MAAK;EAChB,MAAM,UAAU,OAAO,CAAC;EACxB,OAAO,QAAQ,OAAO,IAAI,QAAQ,YAAY,IAAI;CACpD;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,2 @@
1
+ import{n as e}from"./utils-DJad3fT3.mjs";const t=/* @__PURE__ */ new Date(NaN),n=/^(\d{4})-(\d{2})-(\d{2})([T ](\d{2}):(\d{2}):(\d{2})(\.(\d{1,3}))?)?/,r=e=>{if(e instanceof Date)return e;let r=n.exec(e);if(!r)return t;let[i,a,o,s,c,l,u,d,f,p]=r,[m,h,g,_,v,y,b]=[a,o,s,l,u,d,p??`0`].filter(Boolean).map(Number),x=h-1;return l?new Date(Date.UTC(m,x,g,_,v,y,b)):new Date(m,x,g)},i=e=>{let t=r(e);return t instanceof Date&&!Number.isNaN(t.getTime())},a=e=>{let t=r(e);return i(t)?t.toISOString().slice(0,10):``},o={format:e=>r(e).toISOString(),isAfter:(e,t)=>{let n=r(e).getTime(),i=r(t).getTime();return!Number.isNaN(n)&&!Number.isNaN(i)&&n>i},isBefore:(e,t)=>{let n=r(e).getTime(),i=r(t).getTime();return!Number.isNaN(n)&&!Number.isNaN(i)&&n<i},isSame:(t,n)=>{let i=r(t),o=r(n);return e(t)||e(n)?a(t)===a(n):i.getTime()===o.getTime()},isValid:i,toDate:r,toISOString:e=>{let t=r(e);return i(t)?t.toISOString():``},toISOStringDateOnly:a,startOf:(e,t)=>{let n=new Date(r(e).getTime());switch(n.setHours(0,0,0,0),t){case`week`:n.setDate(n.getDate()-n.getDay());break;case`month`:n.setDate(1);break;case`year`:n.setMonth(0,1)}return n},endOf:(e,t)=>{let n=new Date(r(e).getTime());switch(n.setHours(23,59,59,999),t){case`week`:n.setDate(n.getDate()+(6-n.getDay()));break;case`month`:n.setMonth(n.getMonth()+1,0);break;case`year`:n.setMonth(11,31)}return n},add:(e,t,n)=>{let i=new Date(r(e).getTime());switch(n){case`minute`:i.setMinutes(i.getMinutes()+t);break;case`hour`:i.setHours(i.getHours()+t);break;case`day`:i.setDate(i.getDate()+t);break;case`week`:i.setDate(i.getDate()+t*7);break;case`month`:i.setMonth(i.getMonth()+t);break;case`year`:i.setFullYear(i.getFullYear()+t)}return i}};export{o as t};
2
+ //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-D-7pwJfN.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-Bpo2F8gW.mjs","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toIS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M,EAAI,IAAI,KAAK,EAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EACtC,OAAQ,EAAR,CACE,IAAK,SACH,EAAE,WAAW,EAAE,WAAW,EAAI,CAAM,EACpC,MACF,IAAK,OACH,EAAE,SAAS,EAAE,SAAS,EAAI,CAAM,EAChC,MACF,IAAK,MACH,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAM,EAC9B,MACF,IAAK,OACH,EAAE,QAAQ,EAAE,QAAQ,EAAI,EAAS,CAAC,EAClC,MACF,IAAK,QACH,EAAE,SAAS,EAAE,SAAS,EAAI,CAAM,EAChC,MACF,IAAK,OACH,EAAE,YAAY,EAAE,YAAY,EAAI,CAAM,CAE1C,CACA,OAAO,CACT,CAqCA"}
1
+ {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-D-7pwJfN.mjs","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endOf,\n add,\n};\n"],"mappings":"yCAOA,MAAM,kBAAc,IAAI,KAAK,GAAU,EAEjC,EAAa,uEAEb,EAAU,GAAqB,CACnC,GAAI,aAAa,KAAM,OAAO,EAE9B,IAAM,EAAU,EAAW,KAAK,CAAC,EAEjC,GAAI,CAAC,EAAS,OAAO,EAErB,GAAM,CAAC,EAAM,EAAM,EAAI,EAAI,EAAO,EAAI,EAAI,EAAI,EAAU,GAAO,EACzD,CAAC,EAAM,EAAO,EAAK,EAAO,EAAS,EAAS,GAAM,CAAC,EAAM,EAAI,EAAI,EAAI,EAAI,EAAI,GAAO,GAAG,CAAC,CAC3F,OAAO,OAAO,CAAC,CACf,IAAI,MAAM,EAEP,EAAa,EAAQ,EAE3B,OAAO,EACH,IAAI,KAAK,KAAK,IAAI,EAAM,EAAY,EAAK,EAAO,EAAS,EAAS,CAAE,CAAC,EACrE,IAAI,KAAK,EAAM,EAAY,CAAG,CACpC,EAEM,EAAW,GAAqB,CACpC,IAAM,EAAU,EAAO,CAAC,EACxB,OAAO,aAAmB,MAAQ,CAAC,OAAO,MAAM,EAAQ,QAAQ,CAAC,CACnE,EAEM,EAAuB,GAAqB,CAChD,IAAM,EAAU,EAAO,CAAC,EACxB,OAAO,EAAQ,CAAO,EAAI,EAAQ,YAAY,CAAC,CAAC,MAAM,EAAG,EAAE,EAAI,EACjE,EAoEa,EAA+C,CAC1D,OAAQ,GAAK,EAAO,CAAC,CAAC,CAAC,YAAY,EACnC,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H,EAAE,QAAQ,EAAE,QAAQ,GAAK,EAAI,EAAE,OAAO,EAAE,EACxC,MACF,IAAK,QACH,EAAE,SAAS,EAAE,SAAS,EAAI,EAAG,CAAC,EAC9B,MACF,IAAK,OACH,EAAE,SAAS,GAAI,EAAE,CAErB,CACA,OAAO,CACT,EA6DE,KA3DW,EAAkB,EAAgB,IAAqC,CAClF,IAAM,EAAI,IAAI,KAAK,EAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EACtC,OAAQ,EAAR,CACE,IAAK,SACH,EAAE,WAAW,EAAE,WAAW,EAAI,CAAM,EACpC,MACF,IAAK,OACH,EAAE,SAAS,EAAE,SAAS,EAAI,CAAM,EAChC,MACF,IAAK,MACH,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAM,EAC9B,MACF,IAAK,OACH,EAAE,QAAQ,EAAE,QAAQ,EAAI,EAAS,CAAC,EAClC,MACF,IAAK,QACH,EAAE,SAAS,EAAE,SAAS,EAAI,CAAM,EAChC,MACF,IAAK,OACH,EAAE,YAAY,EAAE,YAAY,EAAI,CAAM,CAE1C,CACA,OAAO,CACT,CAqCA"}
@@ -0,0 +1,4 @@
1
+ const e=e=>typeof e==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e),t=e=>e===`field`||e===`parameter`,n=e=>typeof e==`object`&&!!e&&e.mode===`relative`&&typeof e.anchor==`string`,r=/^(start|end)Of(Day|Week|Month|Year)$/,i=(e,t,n=/* @__PURE__ */ new Date)=>{let i=n;if(t.anchor!==`now`){let n=r.exec(t.anchor);
2
+ // v8 ignore next -- guarded by the RelativeDateTimeAnchor type
3
+ if(n){let t=n[2].toLowerCase();i=n[1]===`start`?e.startOf(i,t):e.endOf(i,t)}}return t.offset&&(i=e.add(i,t.offset,t.unit)),i},a=e=>/^date\b/i.test(e),o=(e,t,r)=>{let o=r?.context?.relativeDateTimeBase,s=a(r?.fieldData?.datatype),c=t=>{if(!n(t))return t;let r=i(e,t,o);return s?e.toISOStringDateOnly(r):e.toISOString(r)};return Array.isArray(t)?t.map(c):c(t)},s=(...[e,t])=>t?.context?.relativeOperatorMap?.[e.operator]??e.operator,c=(e,t,n,r=!1)=>{let i=s(t,n),a=o(e,t.value,n),c=a;if(Array.isArray(a)&&a.length>=2){let t=i.toLowerCase();if(t===`between`||t===`notbetween`){let t=e.toDate(a[0]),n=e.toDate(a[1]);e.isValid(t)&&e.isValid(n)&&!e.isBefore(t,n)&&(c=[a[1],a[0],...a.slice(2)])}}if(!r)return{operator:i,value:c};let l=t=>{let n=e.toDate(t);return e.isValid(n)?n:t};return{operator:i,value:Array.isArray(c)?c.map(l):l(c)}},l=(...[e,t])=>e.operator!==`contains`&&e.operator!==`beginsWith`&&e.operator!==`endsWith`&&e.operator!==`doesNotContain`&&e.operator!==`doesNotBeginWith`&&e.operator!==`doesNotEndWith`&&e.operator!==`null`&&e.operator!==`notNull`&&/^(?:date|datetime|datetimeoffset|timestamp)\b/i.test(t?.fieldData?.datatype),u=(e,...[t,n])=>typeof e==`boolean`?e:typeof e==`function`?e(t,n):Array.isArray(e)?e.some(e=>Object.entries(e).every(([e,t])=>n?.fieldData?.[e]===t)):typeof e==`object`?Object.entries(e).every(([e,t])=>n?.fieldData?.[e]===t):l(t,n);export{c as a,s as c,n as i,i as l,e as n,o,t as r,u as s,a as t};
4
+ //# sourceMappingURL=utils-DJad3fT3.mjs.map