@react-querybuilder/datetime 8.20.2 → 8.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/dist/cjs/{getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js → getDatetimeRuleProcessorTanStackDB-CDEB9coD.js} +22 -19
  2. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CDEB9coD.js.map +1 -0
  3. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js +2 -0
  4. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js.map +1 -0
  5. package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +122 -138
  6. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +49 -50
  7. package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +2 -2
  8. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +49 -50
  9. package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +2 -2
  10. package/dist/cjs/react-querybuilder_datetime.cjs.development.js +3 -2
  11. package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
  12. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +52 -53
  13. package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +2 -2
  14. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +49 -50
  15. package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +2 -2
  16. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +100 -114
  17. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js +5 -3
  18. package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js.map +1 -1
  19. package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +122 -138
  20. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +49 -50
  21. package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
  22. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +49 -50
  23. package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
  24. package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
  25. package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
  26. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +52 -53
  27. package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
  28. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +49 -50
  29. package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
  30. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.d.ts +100 -114
  31. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +1 -1
  32. package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -1
  33. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js} +2 -2
  34. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js.map → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map} +1 -1
  35. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js} +2 -2
  36. package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js.map → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map} +1 -1
  37. package/dist/cjs/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
  38. package/dist/cjs/utils-DdBYGWHZ.js +2 -0
  39. package/dist/cjs/utils-DdBYGWHZ.js.map +1 -0
  40. package/dist/cjs/{utils-DUePrC--.js → utils-_X97pUtk.js} +13 -1
  41. package/dist/cjs/utils-_X97pUtk.js.map +1 -0
  42. package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs +2 -0
  43. package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs.map +1 -0
  44. package/dist/{getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js → getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js} +22 -19
  45. package/dist/getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js.map +1 -0
  46. package/dist/{getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs → getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs} +22 -19
  47. package/dist/getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs.map +1 -0
  48. package/dist/{objectSpread2-73AKOozq.js → objectSpread2-MqoZ2hSz.js} +13 -7
  49. package/dist/objectSpread2-MqoZ2hSz.js.map +1 -0
  50. package/dist/react-querybuilder_datetime.d.mts +122 -138
  51. package/dist/react-querybuilder_datetime.date-fns.d.mts +49 -50
  52. package/dist/react-querybuilder_datetime.date-fns.mjs +2 -2
  53. package/dist/react-querybuilder_datetime.dayjs.d.mts +49 -50
  54. package/dist/react-querybuilder_datetime.dayjs.mjs +2 -2
  55. package/dist/react-querybuilder_datetime.jsdate.d.mts +52 -53
  56. package/dist/react-querybuilder_datetime.jsdate.mjs +2 -2
  57. package/dist/react-querybuilder_datetime.legacy-esm.d.ts +122 -138
  58. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +49 -50
  59. package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -2
  60. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +49 -50
  61. package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -2
  62. package/dist/react-querybuilder_datetime.legacy-esm.js +3 -2
  63. package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
  64. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +52 -53
  65. package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -2
  66. package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +49 -50
  67. package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -2
  68. package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +100 -114
  69. package/dist/react-querybuilder_datetime.legacy-esm.ui.js +7 -5
  70. package/dist/react-querybuilder_datetime.legacy-esm.ui.js.map +1 -1
  71. package/dist/react-querybuilder_datetime.luxon.d.mts +49 -50
  72. package/dist/react-querybuilder_datetime.luxon.mjs +2 -2
  73. package/dist/react-querybuilder_datetime.mjs +3 -2
  74. package/dist/react-querybuilder_datetime.mjs.map +1 -1
  75. package/dist/react-querybuilder_datetime.production.d.mts +122 -138
  76. package/dist/react-querybuilder_datetime.production.date-fns.d.mts +49 -50
  77. package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
  78. package/dist/react-querybuilder_datetime.production.dayjs.d.mts +49 -50
  79. package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
  80. package/dist/react-querybuilder_datetime.production.jsdate.d.mts +52 -53
  81. package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
  82. package/dist/react-querybuilder_datetime.production.luxon.d.mts +49 -50
  83. package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
  84. package/dist/react-querybuilder_datetime.production.mjs +1 -1
  85. package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
  86. package/dist/react-querybuilder_datetime.production.ui.d.mts +100 -114
  87. package/dist/react-querybuilder_datetime.production.ui.mjs +1 -1
  88. package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -1
  89. package/dist/react-querybuilder_datetime.ui.d.mts +100 -114
  90. package/dist/react-querybuilder_datetime.ui.mjs +5 -3
  91. package/dist/react-querybuilder_datetime.ui.mjs.map +1 -1
  92. package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js} +2 -2
  93. package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js.map → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map} +1 -1
  94. package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs} +2 -2
  95. package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs.map → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map} +1 -1
  96. package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs} +2 -2
  97. package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs.map → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map} +1 -1
  98. package/dist/{types-Di8kFIXV.d.mts → types-BKA1aoY6.d.mts} +82 -73
  99. package/dist/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
  100. package/dist/{utils-BC2SALFm.mjs → utils-BAgUBdyf.mjs} +8 -2
  101. package/dist/utils-BAgUBdyf.mjs.map +1 -0
  102. package/dist/utils-DA8aluCt.mjs +2 -0
  103. package/dist/utils-DA8aluCt.mjs.map +1 -0
  104. package/package.json +16 -16
  105. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js +0 -2
  106. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js.map +0 -1
  107. package/dist/cjs/getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js.map +0 -1
  108. package/dist/cjs/utils-DUePrC--.js.map +0 -1
  109. package/dist/cjs/utils-jkW5R1AA.js +0 -2
  110. package/dist/cjs/utils-jkW5R1AA.js.map +0 -1
  111. package/dist/getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs.map +0 -1
  112. package/dist/getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js.map +0 -1
  113. package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs +0 -2
  114. package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs.map +0 -1
  115. package/dist/objectSpread2-73AKOozq.js.map +0 -1
  116. package/dist/utils-BC2SALFm.mjs.map +0 -1
  117. package/dist/utils-VKS8YY2D.mjs +0 -2
  118. package/dist/utils-VKS8YY2D.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"react-querybuilder_datetime.cjs.production.ui.js","names":["React","isRelativeDateTimeValue","defaultOperators","defaultDateTimeAPI","isRelativeDateTimeValue","React","standardClassnames","ValueEditor","ValueEditor","QueryBuilderContext"],"sources":["../../src/ui/InheritedValueEditorContext.ts","../../src/ui/relativeDateTimeConstants.ts","../../src/ui/relativeDateTimeModeControllers.tsx","../../src/ui/RelativeDateTimeConfigContext.tsx","../../src/ui/RelativeDateTimeValueEditor.tsx","../../src/ui/QueryBuilderDateTime.tsx"],"sourcesContent":["import type { Context } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\n\n/**\n * Holds the value editor inherited from an outer (compat package) context provider,\n * captured _before_ {@link QueryBuilderDateTime} overrides it. Lets the date/time value\n * editor delegate non-date fields (and absolute date inputs) to the compat editor instead\n * of the bare default {@link react-querybuilder!ValueEditor ValueEditor}. `null` = none\n * inherited (fall back to default).\n */\nexport const InheritedValueEditorContext: Context<React.ComponentType<ValueEditorProps> | null> =\n createContext<React.ComponentType<ValueEditorProps> | null>(null);\n\n/** Inherited (compat) value editor, or `null` if none. See {@link InheritedValueEditorContext}. */\nexport const useInheritedValueEditor = (): React.ComponentType<ValueEditorProps> | null =>\n useContext(InheritedValueEditorContext);\n","import type { FullOption } from '@react-querybuilder/core';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport type { RelativeDateTimeToggleLabels } from './types';\n\n/**\n * Class name applied to the absolute/relative mode toggle button. Package-local (not part\n * of the core `standardClassnames`) to avoid coupling core to this extension.\n */\nexport const relativeDateTimeToggleClassName = 'rule-value-dateTimeRelative-toggle';\n\n/** Default value applied when switching a rule to relative mode. */\nexport const defaultRelativeDateTimeValue: RelativeDateTimeValue = {\n mode: 'relative',\n anchor: 'now',\n offset: 0,\n unit: 'day',\n};\n\n/** Default anchor (reference-point) options for the relative date/time editor. */\nexport const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[] = [\n { name: 'now', value: 'now', label: 'now' },\n { name: 'startOfDay', value: 'startOfDay', label: 'start of day' },\n { name: 'endOfDay', value: 'endOfDay', label: 'end of day' },\n { name: 'startOfWeek', value: 'startOfWeek', label: 'start of week' },\n { name: 'endOfWeek', value: 'endOfWeek', label: 'end of week' },\n { name: 'startOfMonth', value: 'startOfMonth', label: 'start of month' },\n { name: 'endOfMonth', value: 'endOfMonth', label: 'end of month' },\n { name: 'startOfYear', value: 'startOfYear', label: 'start of year' },\n { name: 'endOfYear', value: 'endOfYear', label: 'end of year' },\n];\n\n/** Default unit options for the relative date/time editor. */\nexport const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[] = [\n { name: 'minute', value: 'minute', label: 'minute(s)' },\n { name: 'hour', value: 'hour', label: 'hour(s)' },\n { name: 'day', value: 'day', label: 'day(s)' },\n { name: 'week', value: 'week', label: 'week(s)' },\n { name: 'month', value: 'month', label: 'month(s)' },\n { name: 'year', value: 'year', label: 'year(s)' },\n];\n\n/** Default labels/content for the absolute/relative mode toggle. */\nexport const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels> = {\n label: 'Toggle relative date/time',\n absoluteTitle: 'Absolute date/time (click for relative)',\n relativeTitle: 'Relative date/time (click for absolute)',\n // Empty by default; the CSS pseudo-element renders the glyph based on `aria-checked`.\n absoluteContent: '',\n relativeContent: '',\n};\n","import * as React from 'react';\nimport type { FullOperator } from 'react-querybuilder';\nimport { clsx, defaultOperators } from 'react-querybuilder';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { relativeDateTimeToggleClassName } from './relativeDateTimeConstants';\nimport type { RelativeDateTimeModeController, RelativeDateTimeModeControlProps } from './types';\n\n/**\n * Compact absolute/relative toggle rendered by {@link toggleModeController}. A\n * `role=\"switch\"` button whose default glyph is supplied by CSS (keyed on\n * `aria-checked`); override via the `toggleLabels` config.\n *\n * @group Components\n */\nexport const RelativeDateTimeModeToggle = ({\n isRelative,\n setMode,\n disabled,\n className,\n labels,\n}: RelativeDateTimeModeControlProps): React.JSX.Element => {\n const onClick = React.useCallback(\n () => setMode(isRelative ? 'absolute' : 'relative'),\n [setMode, isRelative]\n );\n\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isRelative}\n aria-label={labels.label}\n title={isRelative ? labels.relativeTitle : labels.absoluteTitle}\n disabled={disabled}\n className={clsx(relativeDateTimeToggleClassName, className)}\n onClick={onClick}>\n {isRelative ? labels.relativeContent : labels.absoluteContent}\n </button>\n );\n};\n\n/**\n * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the\n * value shape and renders a compact toggle button to switch between absolute and\n * relative entry.\n */\nexport const toggleModeController: RelativeDateTimeModeController = {\n isRelative: props => isRelativeDateTimeValue(props.value),\n ModeControl: RelativeDateTimeModeToggle,\n};\n\n/**\n * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode\n * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the\n * editor in relative mode. No toggle is rendered — the operator selector is the mode\n * affordance.\n *\n * NOTE: the chosen operators only signal _mode_; the rule's value remains a\n * {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a\n * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`\n * (e.g. `{ relativeEq: '=' }`). See the documentation.\n */\nexport const createOperatorModeController = (\n relativeOperators: string[] | ((operator: string) => boolean)\n): RelativeDateTimeModeController => ({\n isRelative: props =>\n typeof relativeOperators === 'function'\n ? relativeOperators(props.operator)\n : relativeOperators.includes(props.operator),\n});\n\ninterface FieldWithOperators {\n operators?: FullOperator[];\n [key: string]: unknown;\n}\n\n/**\n * Appends the given `operators` to each field's `operators` list, so the operator-driven\n * controller (see {@link createOperatorModeController}) has an operator to switch into\n * relative mode. Fields without an explicit `operators` list fall back to the core\n * `defaultOperators`.\n */\nexport const withRelativeOperators = <F extends FieldWithOperators>(\n fields: F[],\n operators: FullOperator[]\n): F[] =>\n fields.map(field => ({\n ...field,\n operators: [...(field.operators ?? (defaultOperators as FullOperator[])), ...operators],\n }));\n","import * as React from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { FullOption } from 'react-querybuilder';\nimport { rqbDateTimeLibraryAPI as defaultDateTimeAPI } from '../rqbDateTimeLibraryAPI.jsdate';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RQBDateTimeLibraryAPI } from '../types';\nimport {\n defaultRelativeDateTimeAnchors,\n defaultRelativeDateTimeToggleLabels,\n defaultRelativeDateTimeUnits,\n} from './relativeDateTimeConstants';\nimport { toggleModeController } from './relativeDateTimeModeControllers';\nimport type {\n RelativeDateTimeEditorConfig,\n RelativeDateTimeModeController,\n RelativeDateTimeToggleLabels,\n} from './types';\n\n/** Fully-resolved relative date/time editor config (no optional fields). */\nexport interface ResolvedRelativeDateTimeConfig {\n modeController: RelativeDateTimeModeController;\n anchors: FullOption<RelativeDateTimeAnchor>[];\n units: FullOption<RelativeDateTimeUnit>[];\n toggleLabels: Required<RelativeDateTimeToggleLabels>;\n dateTimeAPI: RQBDateTimeLibraryAPI;\n}\n\n/**\n * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.\n * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.\n */\nexport const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig> =\n createContext<RelativeDateTimeEditorConfig>({});\n\n/** Reads the relative date/time editor config from context, merged with defaults. */\nexport const useRelativeDateTimeConfig = (): ResolvedRelativeDateTimeConfig => {\n const config = useContext(RelativeDateTimeConfigContext);\n return useMemo(\n () => ({\n modeController: config.modeController ?? toggleModeController,\n anchors: config.anchors ?? defaultRelativeDateTimeAnchors,\n units: config.units ?? defaultRelativeDateTimeUnits,\n toggleLabels: { ...defaultRelativeDateTimeToggleLabels, ...config.toggleLabels },\n dateTimeAPI: config.dateTimeAPI ?? defaultDateTimeAPI,\n }),\n [config]\n );\n};\n","import * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport type { FullField, Path, ValueEditorProps, ValueSelectorProps } from 'react-querybuilder';\nimport {\n clsx,\n parseNumber,\n standardClassnames,\n toArray,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { useInheritedValueEditor } from './InheritedValueEditorContext';\nimport { DateTimeValueEditor } from './QueryBuilderDateTime';\nimport type { ResolvedRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { useRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { defaultRelativeDateTimeValue } from './relativeDateTimeConstants';\n\nconst dummyPath: Path = [];\nconst dummyFieldData: FullField = { name: '', value: '', label: '' };\n\n/** Splits a value into the from/to pair used by between/notBetween, object-safe. */\nconst toBetweenArray = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : isRelativeDateTimeValue(value) ? [value] : toArray(value);\n\ninterface RelativeDateTimeSingleValueEditorProps {\n /** The original value editor props (for mode derivation and absolute rendering). */\n baseProps: ValueEditorProps;\n /** The value for this slot (the whole value, or one element of a between pair). */\n value: unknown;\n /** Emits a new value for this slot. */\n onChange: (value: unknown) => void;\n /** Operator passed to the absolute editor (forced to `=` for between slots). */\n absoluteOperator: string;\n config: ResolvedRelativeDateTimeConfig;\n SelectorComponent: React.ComponentType<ValueSelectorProps>;\n /** Themed numeric offset input: the inherited (compat) editor when present, else the default. */\n NumericEditorComponent: React.ComponentType<ValueEditorProps>;\n valueListItemClassName?: string;\n numericSchema: ValueEditorProps['schema'];\n}\n\n/**\n * Renders a single absolute-or-relative date/time value: a mode affordance (per the\n * controller) plus either an absolute date input or anchor + signed offset + unit\n * selectors. Reused once per slot so between/notBetween can mix bounds (e.g. an absolute\n * \"from\" and a relative \"to\").\n */\nconst RelativeDateTimeSingleValueEditor = ({\n baseProps,\n value,\n onChange,\n absoluteOperator,\n config,\n SelectorComponent,\n NumericEditorComponent,\n valueListItemClassName,\n numericSchema,\n}: RelativeDateTimeSingleValueEditorProps): React.JSX.Element => {\n const { schema, disabled, title, testID } = baseProps;\n const { modeController, anchors, units, toggleLabels } = config;\n\n const isRelative = modeController.isRelative({ ...baseProps, value });\n const relValue: RelativeDateTimeValue = isRelativeDateTimeValue(value)\n ? value\n : defaultRelativeDateTimeValue;\n\n const handleSetMode = useCallback(\n (mode: 'absolute' | 'relative') =>\n onChange(mode === 'relative' ? defaultRelativeDateTimeValue : ''),\n [onChange]\n );\n\n const handleChangeAnchor = useCallback(\n (anchor: string) => onChange({ ...relValue, anchor: anchor as RelativeDateTimeAnchor }),\n [onChange, relValue]\n );\n\n const handleChangeOffset = useCallback(\n (offset: unknown) =>\n onChange({\n ...relValue,\n offset: (parseNumber(offset, { parseNumbers: true }) as number) || 0,\n }),\n [onChange, relValue]\n );\n\n const handleChangeUnit = useCallback(\n (unit: string) => onChange({ ...relValue, unit: unit as RelativeDateTimeUnit }),\n [onChange, relValue]\n );\n\n const { ModeControl } = modeController;\n\n return (\n <React.Fragment>\n {ModeControl && (\n <ModeControl\n isRelative={isRelative}\n setMode={handleSetMode}\n schema={schema}\n disabled={disabled}\n className={valueListItemClassName}\n title={title}\n testID={testID}\n labels={toggleLabels}\n />\n )}\n {isRelative ? (\n <React.Fragment>\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeAnchor}\n disabled={disabled}\n value={relValue.anchor}\n options={anchors}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n <NumericEditorComponent\n skipHook\n testID={testID}\n inputType=\"number\"\n title={title}\n className={valueListItemClassName}\n disabled={disabled}\n handleOnChange={handleChangeOffset}\n field={''}\n operator={''}\n value={relValue.offset}\n valueSource={'value'}\n fieldData={dummyFieldData}\n schema={numericSchema}\n path={dummyPath}\n level={0}\n rule={{ field: '', operator: '=', value: relValue.offset }}\n />\n {relValue.offset !== 0 && (\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeUnit}\n disabled={disabled}\n value={relValue.unit}\n options={units}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n )}\n </React.Fragment>\n ) : (\n <DateTimeValueEditor\n {...baseProps}\n operator={absoluteOperator}\n value={value}\n handleOnChange={onChange}\n className={standardClassnames.value}\n />\n )}\n </React.Fragment>\n );\n};\n\n/**\n * Value editor with support for {@link RelativeDateTimeValue relative date/time values}\n * (e.g. \"three months ago\" or \"the beginning of this year\"). How the user switches\n * between absolute and relative modes is delegated to a pluggable\n * {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via\n * {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit\n * selectors; the unit selector is hidden when the offset is `0`.\n *\n * For the `between`/`notBetween` operators it renders two independent value editors (each\n * with its own mode affordance) and stores the bounds as a two-element array, so the from\n * and to bounds can independently be absolute or relative.\n *\n * @group Components\n */\nexport const RelativeDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const { valueListItemClassName } = useValueEditor(props);\n\n const { className, value, handleOnChange, schema, operator, separator } = props;\n const { suppressStandardClassnames } = schema;\n\n const SelectorComponent = props.selectorComponent ?? schema.controls.valueSelector;\n\n // Themed numeric offset input from the inherited (compat) editor when present, else default.\n const NumericEditorComponent = useInheritedValueEditor() ?? ValueEditor;\n\n const config = useRelativeDateTimeConfig();\n\n const numericSchema = useMemo(() => ({ ...schema, parseNumbers: true }), [schema]);\n\n const outerClassname = useMemo(\n () => clsx(suppressStandardClassnames || standardClassnames.valueDateTimeRelative, className),\n [suppressStandardClassnames, className]\n );\n\n const isBetween = operator === 'between' || operator === 'notBetween';\n\n // For between/notBetween, store the bounds as a two-element array. Relative values are\n // objects (which can't survive comma-joining), so the array is emitted directly,\n // regardless of `listsAsArrays`.\n const valueAsArray = useMemo(() => toBetweenArray(value), [value]);\n\n const handleChangeBound = useCallback(\n (index: number) => (boundValue: unknown) => {\n const next = [valueAsArray[0], valueAsArray[1]];\n next[index] = boundValue;\n handleOnChange(next);\n },\n [valueAsArray, handleOnChange]\n );\n\n if (isBetween) {\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[0]}\n onChange={handleChangeBound(0)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n {separator}\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[1]}\n onChange={handleChangeBound(1)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n }\n\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={value}\n onChange={handleOnChange}\n absoluteOperator={operator}\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n};\n","import * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport type { QueryBuilderContextProvider, ValueEditorProps } from 'react-querybuilder';\nimport {\n getCompatContextProvider,\n QueryBuilderContext,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport {\n InheritedValueEditorContext,\n useInheritedValueEditor,\n} from './InheritedValueEditorContext';\nimport {\n RelativeDateTimeConfigContext,\n useRelativeDateTimeConfig,\n} from './RelativeDateTimeConfigContext';\nimport { RelativeDateTimeValueEditor } from './RelativeDateTimeValueEditor';\nimport type { RelativeDateTimeEditorConfig } from './types';\n\n/**\n * Whether a rule should use a date/time editor, based on either the coerced input\n * type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).\n */\nconst isDateTimeEditor = (props: ValueEditorProps, inputTypeCoerced: string | undefined): boolean =>\n (props.type === 'text' &&\n (inputTypeCoerced === 'date' || inputTypeCoerced === 'datetime-local')) ||\n /^(?:date|datetime|timestamp)\\b/i.test(props.fieldData?.datatype as string);\n\nconst pad2 = (n: number): string => `${n}`.padStart(2, '0');\n\n/**\n * Formats a `Date` into the local value expected by a native `date`/`datetime-local`\n * input (library-agnostic; the date library only handles parsing/validation).\n */\nconst formatDateInputValue = (d: Date, withTime: boolean): string => {\n const datePart = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n return withTime ? `${datePart}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : datePart;\n};\n\n/**\n * Renders the inherited (compat) editor when one is provided, otherwise the default\n * {@link react-querybuilder!ValueEditor ValueEditor}. The editor is received as a prop (rather\n * than read from context here) so the JSX element type stays prop-sourced and stable.\n */\nconst FallbackValueEditor = ({\n editor: Editor,\n ...props\n}: ValueEditorProps & {\n editor: React.ComponentType<ValueEditorProps> | null;\n}): React.JSX.Element => (Editor ? <Editor {...props} /> : <ValueEditor {...props} skipHook />);\n\nexport const DateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n const { dateTimeAPI } = useRelativeDateTimeConfig();\n\n // Non-date fields and unparseable values: delegate to the inherited (compat) editor when\n // present, otherwise the default editor.\n const fallback = (p: ValueEditorProps) => <FallbackValueEditor editor={InheritedEditor} {...p} />;\n\n if (!isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return fallback(props);\n }\n\n if (dateTimeAPI.isValid(props.value)) {\n const value = formatDateInputValue(\n dateTimeAPI.toDate(props.value),\n uVE.inputTypeCoerced !== 'date'\n );\n return fallback({ ...props, value });\n }\n\n return fallback(props);\n};\n\n/**\n * Provider value editor: renders the relative-capable {@link RelativeDateTimeValueEditor}\n * for date/time fields and falls back to the inherited (compat) editor for everything else.\n */\nconst QueryBuilderDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n\n if (isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return <RelativeDateTimeValueEditor {...props} />;\n }\n\n return <FallbackValueEditor editor={InheritedEditor} {...props} />;\n};\n\nexport const QueryBuilderDateTimeContext: QueryBuilderContextProvider = getCompatContextProvider({\n controlElements: { valueEditor: QueryBuilderDateTimeValueEditor },\n});\n\n/** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */\nexport interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {\n children?: React.ReactNode;\n}\n\n/**\n * Context provider enabling date/time features for a wrapped\n * {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable\n * {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional\n * {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and\n * toggle labels). With no props it provides the zero-config toggle experience.\n *\n * @group Components\n */\nexport const QueryBuilderDateTime = ({\n children,\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n}: QueryBuilderDateTimeProps): React.JSX.Element => {\n const config = useMemo(\n (): RelativeDateTimeEditorConfig => ({\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n }),\n [modeController, anchors, units, toggleLabels, dateTimeAPI]\n );\n\n // Capture the value editor inherited from any outer compat provider (e.g. QueryBuilderMaterial)\n // _before_ QueryBuilderDateTimeContext overrides it, so date/time editors can delegate to it.\n const inheritedValueEditor = (useContext(QueryBuilderContext).controlElements?.valueEditor ??\n null) as React.ComponentType<ValueEditorProps> | null;\n\n return (\n <RelativeDateTimeConfigContext.Provider value={config}>\n <InheritedValueEditorContext.Provider value={inheritedValueEditor}>\n <QueryBuilderDateTimeContext>{children}</QueryBuilderDateTimeContext>\n </InheritedValueEditorContext.Provider>\n </RelativeDateTimeConfigContext.Provider>\n );\n};\n"],"mappings":"kRAWA,MAAa,GAAA,EAAA,EAAA,cAAA,CACiD,IAAI,EAGrD,OAAA,EAAA,EAAA,WAAA,CACA,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,MAAO,MAAO,QAAS,EAC7C,CAAE,KAAM,OAAQ,MAAO,OAAQ,MAAO,SAAU,EAChD,CAAE,KAAM,QAAS,MAAO,QAAS,MAAO,UAAW,EACnD,CAAE,KAAM,OAAQ,MAAO,OAAQ,MAAO,SAAU,CAClD,EAGa,EAA8E,CACzF,MAAO,4BACP,cAAe,0CACf,cAAe,0CAEf,gBAAiB,GACjB,gBAAiB,EACnB,ECnCa,GAA8B,CACzC,aACA,UACA,WACA,YACA,YACyD,CACzD,I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Q,EACZ,EAAY,OAAO,EAAM,KAAK,EAC9B,EAAI,mBAAqB,MAC3B,EACA,OAAO,EAAS,CAAE,GAAG,EAAO,OAAM,CAAC,CACrC,CAEA,OAAO,EAAS,CAAK,CACvB,EAiBa,GAAA,EAAA,EAAA,yBAAA,CAAoF,CAC/F,gBAAiB,CAAE,YAZoB,GAA+C,CACtF,IAAM,GAAA,EAAA,EAAA,eAAA,CAAqB,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,GAAA,EAAA,EAAA,QAAA,MACiC,CACnC,iBACA,UACA,QACA,eACA,aACF,GACA,CAAC,EAAgB,EAAS,EAAO,EAAc,CAAW,CAC5D,EAIM,GAAA,EAAA,EAAA,WAAA,CAAmCC,EAAAA,mBAAmB,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.cjs.production.ui.js","names":["React","isRelativeDateTimeValue","defaultOperators","defaultDateTimeAPI","isRelativeDateTimeValue","React","standardClassnames","ValueEditor","isNonDateValueSource","ValueEditor","QueryBuilderContext"],"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":"kRAWA,MAAa,GAAA,EAAA,EAAA,cAAA,CACiD,IAAI,EAGrD,OAAA,EAAA,EAAA,WAAA,CACA,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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AG3C,EAAA,cAAC,EAAD,CAAqB,OAAQ,EAAiB,GAAI,CAAQ,CAAA,CACnE,CAGkE,CAClE,CAAC,EAgBY,GAAwB,CACnC,WACA,iBACA,UACA,QACA,eACA,iBACkD,CAClD,IAAM,GAAA,EAAA,EAAA,QAAA,MACiC,CACnC,iBACA,UACA,QACA,eACA,aACF,GACA,CAAC,EAAgB,EAAS,EAAO,EAAc,CAAW,CAC5D,EAIM,GAAA,EAAA,EAAA,WAAA,CAAmCC,EAAAA,mBAAmB,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,2 +1,2 @@
1
- const e=require("./utils-jkW5R1AA.js"),t=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.n(t)||e.n(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);break}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);break}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);break}return i}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
2
- //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js.map
1
+ const e=require("./utils-DdBYGWHZ.js"),t=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.n(t)||e.n(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);break}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);break}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);break}return i}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
2
+ //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js","names":["isISOStringDateOnly"],"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":"uCAOM,EAAc,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,MAA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ACF,IAAK,QACH,EAAE,QAAQ,CAAC,EACX,MACF,IAAK,OACH,EAAE,SAAS,EAAG,CAAC,EACf,KACJ,CACA,OAAO,CACT,EA6EE,OA3Ea,EAAkB,IAA+C,CAC9E,IAAM,EAAI,IAAI,KAAK,EAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAEtC,OADA,EAAE,SAAS,GAAI,GAAI,GAAI,GAAG,EAClB,EAAR,CACE,IAAK,OACH,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,EACjB,KACJ,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,EACtC,KACJ,CACA,OAAO,CACT,CAqCA"}
1
+ {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js","names":["isISOStringDateOnly"],"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":"uCAOM,EAAc,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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,CACA,OAAO,CACT,CAqCA"}
@@ -1,4 +1,4 @@
1
- const require_utils = require("./utils-DUePrC--.js");
1
+ const require_utils = require("./utils-_X97pUtk.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}))?)?/;
@@ -125,4 +125,4 @@ Object.defineProperty(exports, "rqbDateTimeLibraryAPI", {
125
125
  }
126
126
  });
127
127
 
128
- //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js.map
128
+ //# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js","names":["isISOStringDateOnly"],"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,OAAO;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,QAAQ,QAAQ,CAAC;AACnE;AAEA,MAAM,uBAAuB,MAAqB;CAChD,MAAM,UAAU,OAAO,CAAC;CACxB,OAAO,QAAQ,OAAO,IAAI,QAAQ,YAAY,CAAC,CAAC,MAAM,GAAG,EAAE,IA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;;;;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,OAAOA,cAAAA,oBAAoB,CAAC,KAAKA,cAAAA,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-C3jJb6ip.js","names":["isISOStringDateOnly"],"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,OAAO;CAAG,CAAC,CAC3F,OAAO,OAAO,CAAC,CACf,IAAI,MAAM;CAEb,MAAM,aAAa,QAAQ;CAE3B,OAAO,K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A;CACA;CACA;AACF"}
@@ -1,6 +1,5 @@
1
1
  import { RQBJsonLogic, RuleProcessor } from "@react-querybuilder/core";
2
2
  import { RulesLogic } from "json-logic-js";
3
-
4
3
  //#region src/types.d.ts
5
4
  interface RQBJsonLogicDateBetween {
6
5
  dateBetween: [RQBJsonLogic, RQBJsonLogic, RQBJsonLogic];
@@ -36,35 +35,35 @@ interface RQBJsonLogicDateRelative {
36
35
  dateRelative: [RelativeDateTimeAnchor, number, RelativeDateTimeUnit, boolean];
37
36
  }
38
37
  /**
39
- * JsonLogic rule object with additional operators generated by
40
- * {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
41
- * {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
42
- */
38
+ * JsonLogic rule object with additional operators generated by
39
+ * {@link @react-querybuilder/core!formatQuery formatQuery} and accepted by
40
+ * {@link @react-querybuilder/core!parseJsonLogic parseJsonLogic}.
41
+ */
43
42
  type RQBDateTimeJsonLogic = RQBJsonLogic | RulesLogic<RQBJsonLogicDateAfter | RQBJsonLogicDateBefore | RQBJsonLogicDateBetween | RQBJsonLogicDateIn | RQBJsonLogicDateNotBetween | RQBJsonLogicDateNotIn | RQBJsonLogicDateNotOn | RQBJsonLogicDateOn | RQBJsonLogicDateOnOrAfter | RQBJsonLogicDateOnOrBefore | RQBJsonLogicDateRelative>;
44
43
  type DateOrString = string | Date;
45
44
  /**
46
- * Unit of measure for a relative date/time offset.
47
- */
45
+ * Unit of measure for a relative date/time offset.
46
+ */
48
47
  type RelativeDateTimeUnit = "minute" | "hour" | "day" | "week" | "month" | "year";
49
48
  /**
50
- * Unit of measure for truncating a date/time to the start or end of a period
51
- * (the subset of {@link RelativeDateTimeUnit} that represents a calendar period).
52
- */
49
+ * Unit of measure for truncating a date/time to the start or end of a period
50
+ * (the subset of {@link RelativeDateTimeUnit} that represents a calendar period).
51
+ */
53
52
  type RelativeDateTimeTruncationUnit = "day" | "week" | "month" | "year";
54
53
  /**
55
- * Reference point (zero-offset) for a {@link RelativeDateTimeValue}. `'now'` is the
56
- * current date/time; the `startOf*`/`endOf*` anchors truncate to the start or end
57
- * of the corresponding calendar period.
58
- */
54
+ * Reference point (zero-offset) for a {@link RelativeDateTimeValue}. `'now'` is the
55
+ * current date/time; the `startOf*`/`endOf*` anchors truncate to the start or end
56
+ * of the corresponding calendar period.
57
+ */
59
58
  type RelativeDateTimeAnchor = "now" | "startOfDay" | "endOfDay" | "startOfWeek" | "endOfWeek" | "startOfMonth" | "endOfMonth" | "startOfYear" | "endOfYear";
60
59
  /**
61
- * Structured representation of a relative date/time value, e.g. "three months ago"
62
- * or "the beginning of this year". Stored as the `value` of a rule (in place of the
63
- * usual ISO 8601 string) and recognized by the date/time rule processors.
64
- *
65
- * The final date/time is computed as: apply the `anchor` to the current date/time,
66
- * then add `offset` units of `unit`. When `offset` is `0`, `unit` is irrelevant.
67
- */
60
+ * Structured representation of a relative date/time value, e.g. "three months ago"
61
+ * or "the beginning of this year". Stored as the `value` of a rule (in place of the
62
+ * usual ISO 8601 string) and recognized by the date/time rule processors.
63
+ *
64
+ * The final date/time is computed as: apply the `anchor` to the current date/time,
65
+ * then add `offset` units of `unit`. When `offset` is `0`, `unit` is irrelevant.
66
+ */
68
67
  interface RelativeDateTimeValue {
69
68
  /** Discriminant identifying a relative (as opposed to absolute) value. */
70
69
  mode: "relative";
@@ -77,89 +76,99 @@ interface RelativeDateTimeValue {
77
76
  }
78
77
  interface RQBDateTimeLibraryAPI {
79
78
  /**
80
- * Formats a date as a string.
81
- */
79
+ * Formats a date as a string.
80
+ */
82
81
  format: (d: DateOrString, fmt: string) => string;
83
82
  /**
84
- * Formats a date as an ISO 8601 string, only including
85
- * the year, month, and day ('YYYY-MM-DD').
86
- */
83
+ * Formats a date as an ISO 8601 string, only including
84
+ * the year, month, and day ('YYYY-MM-DD').
85
+ */
87
86
  toISOStringDateOnly: (d: DateOrString) => string;
88
87
  /**
89
- * Determines whether the first date is after the second date.
90
- */
88
+ * Determines whether the first date is after the second date.
89
+ */
91
90
  isAfter: (a: DateOrString, b: DateOrString) => boolean;
92
91
  /**
93
- * Determines whether the first date is before the second date.
94
- */
92
+ * Determines whether the first date is before the second date.
93
+ */
95
94
  isBefore: (a: DateOrString, b: DateOrString) => boolean;
96
95
  /**
97
- * Determines whether the first date is the same as the second date.
98
- *
99
- * If either the first date or the second date is a string in the
100
- * format 'YYYY-MM-DD', then the dates will only be compared at
101
- * the date level (no time component). Otherwise, they will be
102
- * compared to the millisecond.
103
- */
96
+ * Determines whether the first date is the same as the second date.
97
+ *
98
+ * If either the first date or the second date is a string in the
99
+ * format 'YYYY-MM-DD', then the dates will only be compared at
100
+ * the date level (no time component). Otherwise, they will be
101
+ * compared to the millisecond.
102
+ */
104
103
  isSame: (a: DateOrString, b: DateOrString) => boolean;
105
104
  /**
106
- * Determines whether the date is either a valid `Date` object or an
107
- * ISO 8601-formatted string representing a valid date.
108
- */
105
+ * Determines whether the date is either a valid `Date` object or an
106
+ * ISO 8601-formatted string representing a valid date.
107
+ */
109
108
  isValid: (d: DateOrString) => boolean;
110
109
  /**
111
- * Converts a string to a `Date` object or returns a valid `Date` as is.
112
- */
110
+ * Converts a string to a `Date` object or returns a valid `Date` as is.
111
+ */
113
112
  toDate: (d: DateOrString) => Date;
114
113
  /**
115
- * Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
116
- * string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
117
- * static; other parts represent standard time units, increasing in precision
118
- * from left to right).
119
- */
114
+ * Converts a `Date` or ISO 8601-formatted string into a full ISO 8601 UTC
115
+ * string, in the format 'YYYY-MM-DDTHH:mm:ss.SSSZ' (the "T" and "Z" are
116
+ * static; other parts represent standard time units, increasing in precision
117
+ * from left to right).
118
+ */
120
119
  toISOString: (d: DateOrString) => string;
121
120
  /**
122
- * Returns a new `Date` truncated to the start of the given period.
123
- *
124
- * Week start follows the date library's own default/locale (e.g. Luxon uses
125
- * Monday per ISO 8601; Day.js and date-fns default to Sunday).
126
- */
121
+ * Returns a new `Date` truncated to the start of the given period.
122
+ *
123
+ * Week start follows the date library's own default/locale (e.g. Luxon uses
124
+ * Monday per ISO 8601; Day.js and date-fns default to Sunday).
125
+ */
127
126
  startOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
128
127
  /**
129
- * Returns a new `Date` advanced to the end of the given period (the last
130
- * representable instant within it).
131
- *
132
- * Week start follows the date library's own default/locale (see {@link RQBDateTimeLibraryAPI.startOf}).
133
- */
128
+ * Returns a new `Date` advanced to the end of the given period (the last
129
+ * representable instant within it).
130
+ *
131
+ * Week start follows the date library's own default/locale (see {@link RQBDateTimeLibraryAPI.startOf}).
132
+ */
134
133
  endOf: (d: DateOrString, unit: RelativeDateTimeTruncationUnit) => Date;
135
134
  /**
136
- * Returns a new `Date` offset from the input by `amount` units of `unit`
137
- * (negative `amount` moves into the past).
138
- */
135
+ * Returns a new `Date` offset from the input by `amount` units of `unit`
136
+ * (negative `amount` moves into the past).
137
+ */
139
138
  add: (d: DateOrString, amount: number, unit: RelativeDateTimeUnit) => Date;
140
139
  }
141
140
  type FnDateDate = (a: DateOrString, b: DateOrString) => boolean;
142
141
  type FnDateArrayOfDates = (a: DateOrString, b: DateOrString[]) => boolean;
143
142
  type FnDateDateDate = (a: DateOrString, b: DateOrString, c: DateOrString) => boolean;
144
143
  type RQBJsonLogicDateTimeOperations = {
145
- /** Determines if the first date is after the second date. */dateAfter: FnDateDate; /** Determines if the first date is before the second date. */
146
- dateBefore: FnDateDate; /** Determines if the second date is between the first and third dates (inclusive). */
147
- dateBetween: FnDateDateDate; /** Determines if the first date is one of the values in the array of dates. */
148
- dateIn: FnDateArrayOfDates; /** Determines if the second date is not between the first and third dates. */
149
- dateNotBetween: FnDateDateDate; /** Determines if the first date is not one of the values in the array of dates. */
150
- dateNotIn: FnDateArrayOfDates; /** Determines if the first date is not the same as the second date. */
151
- dateNotOn: FnDateDate; /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
152
- dateOn: FnDateDate; /** Determines if the first date is either the same as the second date or after it. */
153
- dateOnOrAfter: FnDateDate; /** Determines if the first date is either the same as the second date or before it. */
144
+ /** Determines if the first date is after the second date. */
145
+ dateAfter: FnDateDate;
146
+ /** Determines if the first date is before the second date. */
147
+ dateBefore: FnDateDate;
148
+ /** Determines if the second date is between the first and third dates (inclusive). */
149
+ dateBetween: FnDateDateDate;
150
+ /** Determines if the first date is one of the values in the array of dates. */
151
+ dateIn: FnDateArrayOfDates;
152
+ /** Determines if the second date is not between the first and third dates. */
153
+ dateNotBetween: FnDateDateDate;
154
+ /** Determines if the first date is not one of the values in the array of dates. */
155
+ dateNotIn: FnDateArrayOfDates;
156
+ /** Determines if the first date is not the same as the second date. */
157
+ dateNotOn: FnDateDate;
158
+ /** Determines if the first date is the same as the second date (at the level of least precision between the two). */
159
+ dateOn: FnDateDate;
160
+ /** Determines if the first date is either the same as the second date or after it. */
161
+ dateOnOrAfter: FnDateDate;
162
+ /** Determines if the first date is either the same as the second date or before it. */
154
163
  dateOnOrBefore: FnDateDate;
155
164
  /**
156
- * Resolves a relative date/time descriptor (anchor, offset, unit, and date-only
157
- * flag) to a concrete ISO 8601 string at evaluation time ("live" semantics).
158
- */
165
+ * Resolves a relative date/time descriptor (anchor, offset, unit, and date-only
166
+ * flag) to a concrete ISO 8601 string at evaluation time ("live" semantics).
167
+ */
159
168
  dateRelative: (anchor: RelativeDateTimeAnchor, offset: number, unit: RelativeDateTimeUnit, dateOnly: boolean) => string;
160
169
  };
161
170
  type IsDateFieldFunction = (...[rule, opts]: Parameters<RuleProcessor>) => boolean;
162
171
  type IsDateField = IsDateFieldFunction | Record<string, unknown> | Record<string, unknown>[] | boolean | undefined;
163
172
  //#endregion
164
173
  export { RelativeDateTimeAnchor as _, RQBJsonLogicDateAfter as a, RelativeDateTimeValue as b, RQBJsonLogicDateIn as c, RQBJsonLogicDateNotOn as d, RQBJsonLogicDateOn as f, RQBJsonLogicDateTimeOperations as g, RQBJsonLogicDateRelative as h, RQBDateTimeLibraryAPI as i, RQBJsonLogicDateNotBetween as l, RQBJsonLogicDateOnOrBefore as m, IsDateFieldFunction as n, RQBJsonLogicDateBefore as o, RQBJsonLogicDateOnOrAfter as p, RQBDateTimeJsonLogic as r, RQBJsonLogicDateBetween as s, IsDateField as t, RQBJsonLogicDateNotIn as u, RelativeDateTimeTruncationUnit as v, RelativeDateTimeUnit as y };
165
- //# sourceMappingURL=types-Di8kFIXV.d.ts.map
174
+ //# sourceMappingURL=types-BKA1aoY6.d.ts.map
@@ -0,0 +1,2 @@
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=new Date)=>{let i=n;if(t.anchor!==`now`){let n=r.exec(t.anchor);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);Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
2
+ //# sourceMappingURL=utils-DdBYGWHZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-DdBYGWHZ.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import type { RuleProcessor, ValueSource } from '@react-querybuilder/core';\nimport type {\n IsDateField,\n IsDateFieldFunction,\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeValue,\n RQBDateTimeLibraryAPI,\n} from './types';\n\nexport const isISOStringDateOnly = (\n date: unknown\n): date is `${number}${number}${number}${number}-${number}${number}-${number}${number}` =>\n typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date);\n\n/**\n * Whether a rule's value source is one that datetime processors must NOT materialize as a\n * date (`field` references another column; `parameter` is a named bind placeholder). Both\n * are delegated to the core default processor, which serializes them per format.\n */\nexport const isNonDateValueSource = (valueSource: ValueSource | undefined): boolean =>\n valueSource === 'field' || valueSource === 'parameter';\n\n/**\n * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects\n * (distinguishing them from the ISO 8601 strings used for absolute date/time values).\n */\nexport const isRelativeDateTimeValue = (value: unknown): value is RelativeDateTimeValue =>\n typeof value === 'object' &&\n value !== null &&\n (value as { mode?: unknown }).mode === 'relative' &&\n typeof (value as RelativeDateTimeValue).anchor === 'string';\n\nconst anchorRegExp = /^(start|end)Of(Day|Week|Month|Year)$/;\n\n/**\n * Resolves a {@link RelativeDateTimeValue} into a concrete `Date` using the given\n * date library API. The anchor is applied relative to `base` (defaulting to now),\n * then the signed offset is added.\n */\nexport const resolveRelativeDateTime = (\n apiFns: RQBDateTimeLibraryAPI,\n value: RelativeDateTimeValue,\n base: Date = new Date()\n): Date => {\n let result: Date = base;\n\n if (value.anchor !== 'now') {\n const match = anchorRegExp.exec(value.anchor);\n // v8 ignore next -- guarded by the RelativeDateTimeAnchor type\n if (match) {\n const unit = match[2].toLowerCase() as RelativeDateTimeTruncationUnit;\n result = match[1] === 'start' ? apiFns.startOf(result, unit) : apiFns.endOf(result, unit);\n }\n }\n\n if (value.offset) {\n result = apiFns.add(result, value.offset, value.unit);\n }\n\n return result;\n};\n\n/**\n * Whether a `datatype` represents a date-only (no time component) type, e.g. `date`\n * but not `datetime`/`datetimeoffset`/`timestamp`. Used to choose the precision when\n * materializing a relative value to an ISO 8601 string.\n */\nexport const isDateOnlyDatatype = (datatype: unknown): boolean =>\n /^date\\b/i.test(datatype as string);\n\n/**\n * Replaces any {@link RelativeDateTimeValue} in `value` (or in each element, if `value`\n * is an array) with a concrete ISO 8601 string, resolved via\n * {@link resolveRelativeDateTime}. The \"now\" reference can be pinned with\n * `opts.context.relativeDateTimeBase` for deterministic output; precision (date-only vs\n * full) follows the field's `datatype`. Non-relative values pass through unchanged.\n */\nexport const materializeRelativeValues = (\n apiFns: RQBDateTimeLibraryAPI,\n value: unknown,\n opts: Parameters<RuleProcessor>[1]\n): unknown => {\n const base = opts?.context?.relativeDateTimeBase as Date | undefined;\n const dateOnly = isDateOnlyDatatype(opts?.fieldData?.datatype);\n const conv = (v: unknown): unknown => {\n if (!isRelativeDateTimeValue(v)) return v;\n const resolved = resolveRelativeDateTime(apiFns, v, base);\n return dateOnly ? apiFns.toISOStringDateOnly(resolved) : apiFns.toISOString(resolved);\n };\n return Array.isArray(value) ? value.map(conv) : conv(value);\n};\n\n/**\n * Resolves a rule's operator for export, applying any `context.relativeOperatorMap`\n * entry. Operator-driven mode controllers (see `createOperatorModeController`) use\n * dedicated operator names to signal relative mode; this maps those names to the real\n * comparison operator at format time. Operators absent from the map pass through unchanged.\n */\nexport const resolveDatetimeOperator = (...[rule, opts]: Parameters<RuleProcessor>): string =>\n (opts?.context?.relativeOperatorMap as Record<string, string> | undefined)?.[rule.operator] ??\n rule.operator;\n\n/**\n * Prepares a date/time rule for delegation to a non-symbolic default rule processor\n * (e.g. \"parameterized\", \"spel\", \"ldap\", \"gremlin\", \"prisma\", \"sequelize\", \"drizzle\",\n * \"tanstack_db\"). Relative values are materialized to concrete dates (these formats have\n * no symbolic relative form), and `between`/`notBetween` operands are ordered\n * chronologically (defaults can't reorder non-numeric date operands). When `asDate` is\n * set, each valid value is converted to a `Date` (for object-based formats); otherwise\n * the materialized ISO 8601 strings are passed through. The resolved `operator` (after\n * any `relativeOperatorMap` mapping) is returned alongside the prepared `value`.\n */\nexport const materializeForExport = (\n apiFns: RQBDateTimeLibraryAPI,\n rule: Parameters<RuleProcessor>[0],\n opts: Parameters<RuleProcessor>[1],\n asDate = false\n): { operator: string; value: unknown } => {\n const operator = resolveDatetimeOperator(rule, opts);\n const materialized = materializeRelativeValues(apiFns, rule.value, opts);\n\n let prepared = materialized;\n if (Array.isArray(materialized) && materialized.length >= 2) {\n const opLC = operator.toLowerCase();\n if (opLC === 'between' || opLC === 'notbetween') {\n const first = apiFns.toDate(materialized[0] as string | Date);\n const second = apiFns.toDate(materialized[1] as string | Date);\n if (apiFns.isValid(first) && apiFns.isValid(second) && !apiFns.isBefore(first, second)) {\n prepared = [materialized[1], materialized[0], ...materialized.slice(2)];\n }\n }\n }\n\n if (!asDate) return { operator, value: prepared };\n\n const toDateVal = (v: unknown) => {\n const d = apiFns.toDate(v as string | Date);\n return apiFns.isValid(d) ? d : v;\n };\n return {\n operator,\n value: Array.isArray(prepared) ? prepared.map(toDateVal) : toDateVal(prepared),\n };\n};\n\nexport const defaultIsDateField: IsDateFieldFunction = (\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean =>\n rule.operator !== 'contains' &&\n rule.operator !== 'beginsWith' &&\n rule.operator !== 'endsWith' &&\n rule.operator !== 'doesNotContain' &&\n rule.operator !== 'doesNotBeginWith' &&\n rule.operator !== 'doesNotEndWith' &&\n rule.operator !== 'null' &&\n rule.operator !== 'notNull' &&\n /^(?:date|datetime|datetimeoffset|timestamp)\\b/i.test(opts?.fieldData?.datatype as string);\n\nexport const processIsDateField = (\n isDateField: IsDateField,\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean => {\n if (typeof isDateField === 'boolean') {\n return isDateField;\n }\n\n if (typeof isDateField === 'function') {\n return isDateField(rule, opts);\n }\n\n if (Array.isArray(isDateField)) {\n return isDateField.some(condition =>\n Object.entries(condition).every(([key, value]) => opts?.fieldData?.[key] === value)\n );\n }\n\n if (typeof isDateField === 'object') {\n return Object.entries(isDateField).every(([key, value]) => opts?.fieldData?.[key] === value);\n }\n\n return defaultIsDateField(rule, opts);\n};\n"],"mappings":"AASA,MAAa,EACX,GAEA,OAAO,GAAS,UAAY,sBAAsB,KAAK,CAAI,EAOhD,EAAwB,GACnC,IAAgB,SAAW,IAAgB,YAMhC,EAA2B,GACtC,OAAO,GAAU,YACjB,GACC,EAA6B,OAAS,YACvC,OAAQ,EAAgC,QAAW,SAE/C,EAAe,uCAOR,GACX,EACA,EACA,EAAa,IAAI,OACR,CACT,IAAI,EAAe,EAEnB,GAAI,EAAM,SAAW,MA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AG,EAAa,MAAM,CAAC,CAAC,EAE1E,CACF,CAEA,GAAI,CAAC,EAAQ,MAAO,CAAE,WAAU,MAAO,CAAS,EAEhD,IAAM,EAAa,GAAe,CAChC,IAAM,EAAI,EAAO,OAAO,CAAkB,EAC1C,OAAO,EAAO,QAAQ,CAAC,EAAI,EAAI,CACjC,EACA,MAAO,CACL,WACA,MAAO,MAAM,QAAQ,CAAQ,EAAI,EAAS,IAAI,CAAS,EAAI,EAAU,CAAQ,CAC/E,CACF,EAEa,GACX,GAAG,CAAC,EAAM,KAEV,EAAK,WAAa,YAClB,EAAK,WAAa,cAClB,EAAK,WAAa,YAClB,EAAK,WAAa,kBAClB,EAAK,WAAa,oBAClB,EAAK,WAAa,kBAClB,EAAK,WAAa,QAClB,EAAK,WAAa,WAClB,iDAAiD,KAAK,GAAM,WAAW,QAAkB,EAE9E,GACX,EACA,GAAG,CAAC,EAAM,KAEN,OAAO,GAAgB,UAClB,EAGL,OAAO,GAAgB,WAClB,EAAY,EAAM,CAAI,EAG3B,MAAM,QAAQ,CAAW,EACpB,EAAY,KAAK,GACtB,OAAO,QAAQ,CAAS,CAAC,CAAC,OAAO,CAAC,EAAK,KAAW,GAAM,YAAY,KAAS,CAAK,CACpF,EAGE,OAAO,GAAgB,SAClB,OAAO,QAAQ,CAAW,CAAC,CAAC,OAAO,CAAC,EAAK,KAAW,GAAM,YAAY,KAAS,CAAK,EAGtF,EAAmB,EAAM,CAAI"}
@@ -1,6 +1,12 @@
1
1
  //#region src/utils.ts
2
2
  const isISOStringDateOnly = (date) => typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date);
3
3
  /**
4
+ * Whether a rule's value source is one that datetime processors must NOT materialize as a
5
+ * date (`field` references another column; `parameter` is a named bind placeholder). Both
6
+ * are delegated to the core default processor, which serializes them per format.
7
+ */
8
+ const isNonDateValueSource = (valueSource) => valueSource === "field" || valueSource === "parameter";
9
+ /**
4
10
  * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects
5
11
  * (distinguishing them from the ISO 8601 strings used for absolute date/time values).
6
12
  */
@@ -114,6 +120,12 @@ Object.defineProperty(exports, "isISOStringDateOnly", {
114
120
  return isISOStringDateOnly;
115
121
  }
116
122
  });
123
+ Object.defineProperty(exports, "isNonDateValueSource", {
124
+ enumerable: true,
125
+ get: function() {
126
+ return isNonDateValueSource;
127
+ }
128
+ });
117
129
  Object.defineProperty(exports, "isRelativeDateTimeValue", {
118
130
  enumerable: true,
119
131
  get: function() {
@@ -151,4 +163,4 @@ Object.defineProperty(exports, "resolveRelativeDateTime", {
151
163
  }
152
164
  });
153
165
 
154
- //# sourceMappingURL=utils-DUePrC--.js.map
166
+ //# sourceMappingURL=utils-_X97pUtk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-_X97pUtk.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import type { RuleProcessor, ValueSource } from '@react-querybuilder/core';\nimport type {\n IsDateField,\n IsDateFieldFunction,\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeValue,\n RQBDateTimeLibraryAPI,\n} from './types';\n\nexport const isISOStringDateOnly = (\n date: unknown\n): date is `${number}${number}${number}${number}-${number}${number}-${number}${number}` =>\n typeof date === 'string' && /^\\d{4}-\\d{2}-\\d{2}$/.test(date);\n\n/**\n * Whether a rule's value source is one that datetime processors must NOT materialize as a\n * date (`field` references another column; `parameter` is a named bind placeholder). Both\n * are delegated to the core default processor, which serializes them per format.\n */\nexport const isNonDateValueSource = (valueSource: ValueSource | undefined): boolean =>\n valueSource === 'field' || valueSource === 'parameter';\n\n/**\n * Type guard for {@link RelativeDateTimeValue}. Relative values are stored as objects\n * (distinguishing them from the ISO 8601 strings used for absolute date/time values).\n */\nexport const isRelativeDateTimeValue = (value: unknown): value is RelativeDateTimeValue =>\n typeof value === 'object' &&\n value !== null &&\n (value as { mode?: unknown }).mode === 'relative' &&\n typeof (value as RelativeDateTimeValue).anchor === 'string';\n\nconst anchorRegExp = /^(start|end)Of(Day|Week|Month|Year)$/;\n\n/**\n * Resolves a {@link RelativeDateTimeValue} into a concrete `Date` using the given\n * date library API. The anchor is applied relative to `base` (defaulting to now),\n * then the signed offset is added.\n */\nexport const resolveRelativeDateTime = (\n apiFns: RQBDateTimeLibraryAPI,\n value: RelativeDateTimeValue,\n base: Date = new Date()\n): Date => {\n let result: Date = base;\n\n if (value.anchor !== 'now') {\n const match = anchorRegExp.exec(value.anchor);\n // v8 ignore next -- guarded by the RelativeDateTimeAnchor type\n if (match) {\n const unit = match[2].toLowerCase() as RelativeDateTimeTruncationUnit;\n result = match[1] === 'start' ? apiFns.startOf(result, unit) : apiFns.endOf(result, unit);\n }\n }\n\n if (value.offset) {\n result = apiFns.add(result, value.offset, value.unit);\n }\n\n return result;\n};\n\n/**\n * Whether a `datatype` represents a date-only (no time component) type, e.g. `date`\n * but not `datetime`/`datetimeoffset`/`timestamp`. Used to choose the precision when\n * materializing a relative value to an ISO 8601 string.\n */\nexport const isDateOnlyDatatype = (datatype: unknown): boolean =>\n /^date\\b/i.test(datatype as string);\n\n/**\n * Replaces any {@link RelativeDateTimeValue} in `value` (or in each element, if `value`\n * is an array) with a concrete ISO 8601 string, resolved via\n * {@link resolveRelativeDateTime}. The \"now\" reference can be pinned with\n * `opts.context.relativeDateTimeBase` for deterministic output; precision (date-only vs\n * full) follows the field's `datatype`. Non-relative values pass through unchanged.\n */\nexport const materializeRelativeValues = (\n apiFns: RQBDateTimeLibraryAPI,\n value: unknown,\n opts: Parameters<RuleProcessor>[1]\n): unknown => {\n const base = opts?.context?.relativeDateTimeBase as Date | undefined;\n const dateOnly = isDateOnlyDatatype(opts?.fieldData?.datatype);\n const conv = (v: unknown): unknown => {\n if (!isRelativeDateTimeValue(v)) return v;\n const resolved = resolveRelativeDateTime(apiFns, v, base);\n return dateOnly ? apiFns.toISOStringDateOnly(resolved) : apiFns.toISOString(resolved);\n };\n return Array.isArray(value) ? value.map(conv) : conv(value);\n};\n\n/**\n * Resolves a rule's operator for export, applying any `context.relativeOperatorMap`\n * entry. Operator-driven mode controllers (see `createOperatorModeController`) use\n * dedicated operator names to signal relative mode; this maps those names to the real\n * comparison operator at format time. Operators absent from the map pass through unchanged.\n */\nexport const resolveDatetimeOperator = (...[rule, opts]: Parameters<RuleProcessor>): string =>\n (opts?.context?.relativeOperatorMap as Record<string, string> | undefined)?.[rule.operator] ??\n rule.operator;\n\n/**\n * Prepares a date/time rule for delegation to a non-symbolic default rule processor\n * (e.g. \"parameterized\", \"spel\", \"ldap\", \"gremlin\", \"prisma\", \"sequelize\", \"drizzle\",\n * \"tanstack_db\"). Relative values are materialized to concrete dates (these formats have\n * no symbolic relative form), and `between`/`notBetween` operands are ordered\n * chronologically (defaults can't reorder non-numeric date operands). When `asDate` is\n * set, each valid value is converted to a `Date` (for object-based formats); otherwise\n * the materialized ISO 8601 strings are passed through. The resolved `operator` (after\n * any `relativeOperatorMap` mapping) is returned alongside the prepared `value`.\n */\nexport const materializeForExport = (\n apiFns: RQBDateTimeLibraryAPI,\n rule: Parameters<RuleProcessor>[0],\n opts: Parameters<RuleProcessor>[1],\n asDate = false\n): { operator: string; value: unknown } => {\n const operator = resolveDatetimeOperator(rule, opts);\n const materialized = materializeRelativeValues(apiFns, rule.value, opts);\n\n let prepared = materialized;\n if (Array.isArray(materialized) && materialized.length >= 2) {\n const opLC = operator.toLowerCase();\n if (opLC === 'between' || opLC === 'notbetween') {\n const first = apiFns.toDate(materialized[0] as string | Date);\n const second = apiFns.toDate(materialized[1] as string | Date);\n if (apiFns.isValid(first) && apiFns.isValid(second) && !apiFns.isBefore(first, second)) {\n prepared = [materialized[1], materialized[0], ...materialized.slice(2)];\n }\n }\n }\n\n if (!asDate) return { operator, value: prepared };\n\n const toDateVal = (v: unknown) => {\n const d = apiFns.toDate(v as string | Date);\n return apiFns.isValid(d) ? d : v;\n };\n return {\n operator,\n value: Array.isArray(prepared) ? prepared.map(toDateVal) : toDateVal(prepared),\n };\n};\n\nexport const defaultIsDateField: IsDateFieldFunction = (\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean =>\n rule.operator !== 'contains' &&\n rule.operator !== 'beginsWith' &&\n rule.operator !== 'endsWith' &&\n rule.operator !== 'doesNotContain' &&\n rule.operator !== 'doesNotBeginWith' &&\n rule.operator !== 'doesNotEndWith' &&\n rule.operator !== 'null' &&\n rule.operator !== 'notNull' &&\n /^(?:date|datetime|datetimeoffset|timestamp)\\b/i.test(opts?.fieldData?.datatype as string);\n\nexport const processIsDateField = (\n isDateField: IsDateField,\n ...[rule, opts]: Parameters<RuleProcessor>\n): boolean => {\n if (typeof isDateField === 'boolean') {\n return isDateField;\n }\n\n if (typeof isDateField === 'function') {\n return isDateField(rule, opts);\n }\n\n if (Array.isArray(isDateField)) {\n return isDateField.some(condition =>\n Object.entries(condition).every(([key, value]) => opts?.fieldData?.[key] === value)\n );\n }\n\n if (typeof isDateField === 'object') {\n return Object.entries(isDateField).every(([key, value]) => opts?.fieldData?.[key] === value);\n }\n\n return defaultIsDateField(rule, opts);\n};\n"],"mappings":";AASA,MAAa,uBACX,SAEA,OAAO,SAAS,YAAY,sBAAsB,KAAK,IAAI;;;;;;AAO7D,MAAa,wBAAwB,gBACnC,gBAAgB,WAAW,gBAAgB;;;;;AAM7C,MAAa,2BAA2B,UACtC,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,cACvC,OAAQ,MAAgC,WAAW;AAErD,MAAM,eAAe;;;;;;AAOrB,MAAa,2BACX,QACA,OACA,uBAAa,IAAI,KAAK,MACb;CACT,IAAI,SAAe;CAEnB,IAAI,MAAM,WAAW,OAAO;EAC1B,MAAM,QAAQ,aAAa,KAAK,MAAM,MAAM;;EAE5C,IAAI,OAAO;GACT,MAAM,OAAO,MAAM,EAAE,CAAC,YAAY;GAClC,SAAS,MAAM,OAAO,UAAU,OAAO,QAAQ,QAAQ,IAAI,IAAI,OAAO,MAAM,QAAQ,IAAI;EAC1F;CACF;CAEA,IAAI,MAAM,QACR,SAAS,OAAO,IA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MAAM,IAAI,OAAO,OAAO,CAAkB;EAC1C,OAAO,OAAO,QAAQ,CAAC,IAAI,IAAI;CACjC;CACA,OAAO;EACL;EACA,OAAO,MAAM,QAAQ,QAAQ,IAAI,SAAS,IAAI,SAAS,IAAI,UAAU,QAAQ;CAC/E;AACF;AAEA,MAAa,sBACX,GAAG,CAAC,MAAM,UAEV,KAAK,aAAa,cAClB,KAAK,aAAa,gBAClB,KAAK,aAAa,cAClB,KAAK,aAAa,oBAClB,KAAK,aAAa,sBAClB,KAAK,aAAa,oBAClB,KAAK,aAAa,UAClB,KAAK,aAAa,aAClB,iDAAiD,KAAK,MAAM,WAAW,QAAkB;AAE3F,MAAa,sBACX,aACA,GAAG,CAAC,MAAM,UACE;CACZ,IAAI,OAAO,gBAAgB,WACzB,OAAO;CAGT,IAAI,OAAO,gBAAgB,YACzB,OAAO,YAAY,MAAM,IAAI;CAG/B,IAAI,MAAM,QAAQ,WAAW,GAC3B,OAAO,YAAY,MAAK,cACtB,OAAO,QAAQ,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,MAAM,YAAY,SAAS,KAAK,CACpF;CAGF,IAAI,OAAO,gBAAgB,UACzB,OAAO,OAAO,QAAQ,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,MAAM,YAAY,SAAS,KAAK;CAG7F,OAAO,mBAAmB,MAAM,IAAI;AACtC"}
@@ -0,0 +1,2 @@
1
+ import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s}from"./utils-DA8aluCt.mjs";import{defaultOperatorProcessorNL as c,defaultRuleProcessorCEL as l,defaultRuleProcessorCypher as u,defaultRuleProcessorDrizzle as d,defaultRuleProcessorElasticSearch as f,defaultRuleProcessorGremlin as p,defaultRuleProcessorJSONata as m,defaultRuleProcessorLDAP as h,defaultRuleProcessorMongoDBQuery as g,defaultRuleProcessorNL as _,defaultRuleProcessorParameterized as v,defaultRuleProcessorPrisma as y,defaultRuleProcessorSPARQL as b,defaultRuleProcessorSQL as x,defaultRuleProcessorSequelize as S,defaultRuleProcessorSpEL as C,defaultRuleProcessorTanStackDB as w,defaultValueProcessorByRule as T,getQuotedFieldName as E,lc as D,mapSQLOperator as O,mongoOperators as k,normalizeConstituentWordOrder as ee,nullOrUndefinedOrEmpty as A,sparqlVar as te,toArray as j}from"@react-querybuilder/core";const ne=e=>{let{isAfter:t,isBefore:n,isSame:i}=e;return{dateAfter:(e,n)=>t(e,n),dateBefore:(e,t)=>n(e,t),dateBetween:(e,r,a)=>i(r,e)||i(r,a)||t(r,e)&&n(r,a)||t(r,a)&&n(r,e),dateNotBetween:(e,r,a)=>!i(r,e)&&!i(r,a)&&(n(e,a)&&(n(r,e)||t(r,a))||t(e,a)&&(n(r,a)||t(r,e))),dateIn:(e,t)=>t.some(t=>i(e,t)),dateNotIn:(e,t)=>t.every(t=>!i(e,t)),dateNotOn:(e,t)=>!i(e,t),dateOn:(e,t)=>i(e,t),dateOnOrAfter:(e,n)=>t(e,n)||i(e,n),dateOnOrBefore:(e,t)=>n(e,t)||i(e,t),dateRelative:(t,n,i,a)=>{let o=r(e,{mode:`relative`,anchor:t,offset:n,unit:i});return a?e.toISOStringDateOnly(o):e.toISOString(o)}}},re=e=>/^(does)?not/i.test(e),M=e=>(n,r)=>{let i=r??{},{context:c={}}=i;if(o(n.valueSource)||!s(c.isDateField,n,i))return l(n,i);let u=t=>`timestamp("${e.toISOString(t)}")`,d=a(e,n.value,i),f=D(t(n,i).replace(/^=$/,`==`));switch(f){case`<`:case`<=`:case`==`:case`!=`:case`>`:case`>=`:return`${n.field} ${f} ${u(d)}`}let p=j(d,{retainEmptyStrings:!1}).map(t=>e.toDate(t)).filter(t=>e.isValid(t));switch(f){case`in`:case`notin`:{if(p.length===0)return``;let[e,t]=re(f)?[`!(`,`)`]:[``,``];return`${e}${n.field} in [${p.map(e=>u(e)).join(`, `)}]${t}`}case`between`:case`notbetween`:{if(p.length<2)return``;let[t,r]=p,[i,a]=e.isBefore(t,r)?[t,r]:[r,t];return f===`between`?`(${n.field} >= ${u(i)} && ${n.field} <= ${u(a)})`:`(${n.field} < ${u(i)} || ${n.field} > ${u(a)})`}}return l(n,i)},N=e=>/^(does)?not/i.test(e),ie=(e,t)=>t?`date('${e}')`:`datetime('${e}')`,P=e=>(n,r)=>{let c=r??{},{context:l={}}=c;if(o(n.valueSource)||!s(l.isDateField,n,c))return u(n,c);let{field:d}=n,f=D(t(n,c));if(f===`olderthanduration`)return`datetime() - ${d} > duration('${n.value}')`;if(f===`withinduration`)return`datetime() - ${d} <= duration('${n.value}')`;let p=j(a(e,n.value,c),{retainEmptyStrings:!1}).map(t=>[t,e.toDate(t)]).filter(([,t])=>e.isValid(t)),m=t=>{let n=i(t),r=n?e.toISOStringDateOnly(t):e.toISOString(t);return ie(r,n)};switch(f){case`in`:case`notin`:{if(p.length===0)return``;let e=p.map(([e])=>m(e));return`${N(f)?`NOT `:``}${d} IN [${e.join(`, `)}]`}case`between`:case`notbetween`:{if(p.length<2)return``;let[t,n]=p,[r,i]=e.isBefore(t[1],n[1])?[t,n]:[n,t],a=`${m(r[0])} <= ${d} AND ${d} <= ${m(i[0])}`;return f===`notbetween`?`NOT (${a})`:a}default:{if(p.length===0)return``;let[e]=p[0];return`${d} ${f===`<>`?`<>`:f} ${m(e)}`}}},ae=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return d(n,i);let{operator:c,value:l}=e(t,n,i,!0);return d({...n,operator:c,value:l},i)},oe=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return f(n,i);let{operator:c,value:l}=e(t,n,i);return f({...n,operator:c,value:l},i)},se=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return p(n,i);let{operator:c,value:l}=e(t,n,i);return p({...n,operator:c,value:l},i)},F=e=>/^(does)?not/i.test(e),I=(e,t)=>t?`$not(${e})`:`${e}`,ce=e=>(n,r)=>{let i=r??{},{context:o={}}=i,{quoteFieldNamesWith:c=[``,``],fieldIdentifierSeparator:l=``}=i,{field:u,valueSource:d}=n,f=t(n,i);if(!s(o.isDateField,n,i)||d===`parameter`)return m(n,i);let p=d===`field`,h=p?n.value:a(e,n.value,i),g=e=>`$toMillis(${E(e,{quoteFieldNamesWith:c,fieldIdentifierSeparator:l})})`,_=t=>`$toMillis("${e.toISOString(t)}")`;switch(f){case`<`:case`<=`:case`=`:case`!=`:case`>`:case`>=`:return`${g(u)} ${f} ${p?g(h):_(h)}`}let v=j(h,{retainEmptyStrings:!1}),y=v.map(t=>e.toDate(t)).filter(t=>e.isValid(t));switch(f){case`in`:case`notIn`:return p?v.length===0?``:I(`${g(u)} in [${v.map(e=>g(e)).join(`, `)}]`,F(f)):y.length===0?``:I(`${g(u)} in [${y.map(e=>_(e)).join(`, `)}]`,F(f));case`between`:case`notBetween`:{if(v.length<2||A(v[0])||A(v[1])||!p&&y.length<2)return``;if(p){let[e,t]=v,n=`${g(u)} >= ${g(e)} and ${g(u)} <= ${g(t)}`;return f===`between`?`(${n})`:I(n,!0)}let[t,n]=y,[r,i]=e.isBefore(t,n)?[t,n]:[n,t],a=`${g(u)} >= ${_(r)} and ${g(u)} <= ${_(i)}`;return f===`between`?`(${a})`:I(a,!0)}}return m(n,i)},L=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return h(n,i);let{operator:c,value:l}=e(t,n,i);return h({...n,operator:c,value:l},i)},R=e=>(n,r)=>{let i=r??{},{field:c,valueSource:l}=n,u=t(n,i);if(o(l)||!s(i.context?.isDateField,n,i))return g(n,i);let d=a(e,n.value,i);if(u===`=`)return{[c]:e.toDate(d)};switch(u){case`<`:case`<=`:case`!=`:case`>`:case`>=`:return{[c]:{[k[u]]:e.toDate(d)}}}let f=j(d,{retainEmptyStrings:!1}).map(t=>e.toDate(t)).filter(t=>e.isValid(t));switch(u){case`in`:case`notIn`:return{[c]:{[k[u]]:f}};case`between`:case`notBetween`:{if(f.length<2)return``;let[t,n]=f,r=e.isBefore(t,n)?[t,n]:[n,t];return u===`between`?{[c]:{$gte:r[0],$lte:r[1]}}:{$or:[{[c]:{$lt:r[0]}},{[c]:{$gt:r[1]}}]}}}return g(n,i)},z=e=>{let t=R(e);return(e,n)=>{let r=t(e,n);return r?JSON.stringify(r):``}},B={"<":`is before`,">":`is after`,"<=":`is on or before`,">=":`is on or after`,in:[`is one of the dates`,`is the same as a date in`],notin:[`is not one of the dates`,`is not the same as any date in`],between:[`is between`,`is between the dates in`],notbetween:[`is not between`,`is not between the dates in`]},V=(e,t)=>i(t?.context?.originalValue)?new Intl.DateTimeFormat(t?.context?.locales,{dateStyle:`full`,...t?.context?.dateFormat}).format(e.value):new Intl.DateTimeFormat(t?.context?.locales,{dateStyle:`full`,timeStyle:`long`,...t?.context?.dateTimeFormat}).format(e.value),H=e=>(n,r)=>{let i=r??{},l=t(n,i),u=D(l),d=``,{fieldData:f,quoteFieldNamesWith:p=[``,``],fieldIdentifierSeparator:m=``,operatorProcessor:h=c,wordOrder:g=`SVO`,context:v={},operatorMap:y=B}=i;if(!s(v.isDateField,n,i))return _(n,i);if(o(n.valueSource))return _(n,{...i,operatorMap:B});if((u===`in`||u===`notin`||u===`between`||u===`notbetween`)&&!n.value)return``;let b=j(a(e,n.value,i),{retainEmptyStrings:!1}).map(t=>[t,e.toDate(t)]).filter(t=>e.isValid(t[1]));switch(u){case`in`:case`notin`:if(b.length===0)return``;d=`(${b.map(e=>V({field:n.field,operator:`=`,value:e[1]},{...i,context:{...v,originalValue:e[0]}})).join(`, `)})`;break;case`between`:case`notbetween`:{if(b.length<2)return``;let[t,r]=b;d=(e.isBefore(t[1],r[1])?[t,r]:[r,t]).map(([e,t])=>V({field:n.field,operator:`=`,value:t},{...i,context:{...v,originalValue:e}})).join(` ${i.translations?.and??`and`} `)}break;default:{let[e,t]=b[0]??[``,``];d=e?V({field:n.field,operator:`=`,value:t},{...i,context:{...v,originalValue:e}}):``}}let x={S:E(f?.label??n.field,{quoteFieldNamesWith:p,fieldIdentifierSeparator:m}),V:h({...n,operator:l},{...i,operatorMap:{...B,...y}}),O:d};return ee(g).map(e=>`${x[e]}`).join(` `).trim()},U=t=>(n,r,i)=>{let a=r??{},{context:c={}}=a;if(o(n.valueSource)||!s(c.isDateField,n,a))return v(n,a,i);let{operator:l,value:u}=e(t,n,a);return v({...n,operator:l,value:u},a,i)},W=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return y(n,i);let{operator:c,value:l}=e(t,n,i,!0);return y({...n,operator:c,value:l},i)},G=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return S(n,i);let{operator:c,value:l}=e(t,n,i,!0);return S({...n,operator:c,value:l},i)},le=e=>/^(does)?not/i.test(e),ue=(e,t)=>t?`"${e}"^^xsd:date`:`"${e}"^^xsd:dateTime`,de=e=>(n,r)=>{let c=r??{},{context:l={}}=c;if(o(n.valueSource)||!s(l.isDateField,n,c))return b(n,c);let{field:u,value:d}=n,f=t(n,c),p=te(u),m=D(f);if(m===`olderthanduration`)return`NOW() - ${p} > "${d}"^^xsd:duration`;if(m===`withinduration`)return`NOW() - ${p} <= "${d}"^^xsd:duration`;let h=j(a(e,d,c),{retainEmptyStrings:!1}).map(t=>[t,e.toDate(t)]).filter(([,t])=>e.isValid(t)),g=t=>{let n=i(t),r=n?e.toISOStringDateOnly(t):e.toISOString(t);return ue(r,n)};switch(m){case`in`:case`notin`:{if(h.length===0)return``;let e=h.map(([e])=>g(e));return`${p} ${le(m)?`NOT `:``}IN (${e.join(`, `)})`}case`between`:case`notbetween`:{if(h.length<2)return``;let[t,n]=h,[r,i]=e.isBefore(t[1],n[1])?[t,n]:[n,t];return m===`notbetween`?`(${p} < ${g(r[0])} || ${p} > ${g(i[0])})`:`${p} >= ${g(r[0])} && ${p} <= ${g(i[0])}`}default:{if(h.length===0)return``;let[e]=h[0];return`${p} ${m===`<>`?`!=`:m} ${g(e)}`}}},fe=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return C(n,i);let{operator:c,value:l}=e(t,n,i);return C({...n,operator:c,value:l},i)},K=e=>{if(e===`now`)return{bound:`now`};let t=/^(start|end)Of(Day|Week|Month|Year)$/.exec(e);return{bound:t[1],unit:t[2].toLowerCase()}},q=e=>`${e}s`,J=(e,t)=>{let n=t?`current_date`:`current_timestamp`,{bound:r,unit:i}=K(e.anchor),a=n,o=!1;if(r===`start`&&i?(a=`date_trunc('${i}', ${n})`,o=!0):r===`end`&&i&&(a=`date_trunc('${i}', ${n}) + interval '1 ${i}' - ${t?`interval '1 day'`:`interval '1 microsecond'`}`,o=!0),e.offset){let t=e.offset<0?`-`:`+`;a=`${a} ${t} interval '${Math.abs(e.offset)} ${q(e.unit)}'`,o=!0}return t&&o?`cast(${a} as date)`:a},pe=(e,t,n)=>{if(t===`start`)switch(n){case`day`:return`date(${e})`;case`week`:return`date_sub(date(${e}), interval dayofweek(${e}) - 1 day)`;case`month`:return`date_format(${e}, '%Y-%m-01')`;case`year`:return`date_format(${e}, '%Y-01-01')`}switch(n){case`day`:return`date(${e})`;case`week`:return`date_add(date(${e}), interval 7 - dayofweek(${e}) day)`;case`month`:return`last_day(${e})`}return`date_format(${e}, '%Y-12-31')`},me=(e,t)=>{let n=t?`curdate()`:`now()`,{bound:r,unit:i}=K(e.anchor),a=n;return r!==`now`&&i&&(a=pe(n,r,i),r===`end`&&!t&&(a=`date_sub(date_add(${a}, interval 1 day), interval 1 microsecond)`)),e.offset&&(a=`${e.offset<0?`date_sub`:`date_add`}(${a}, interval ${Math.abs(e.offset)} ${e.unit})`),a},he=(e,t,n,r)=>{let i=`dateadd(${n}, datediff(${n}, 0, ${e}), 0)`;if(t===`start`)return i;let a=`dateadd(${n}, datediff(${n}, 0, ${e}) + 1, 0)`;return r?`dateadd(day, -1, ${a})`:`dateadd(nanosecond, -100, cast(${a} as datetime2))`},ge=(e,t)=>{let n=t?`cast(getdate() as date)`:`getdate()`,{bound:r,unit:i}=K(e.anchor),a=n;return r!==`now`&&i&&(a=he(n,r,i,t)),e.offset&&(a=`dateadd(${e.unit}, ${e.offset}, ${a})`),a},_e={day:`DDD`,week:`IW`,month:`MM`,year:`YYYY`},ve=(e,t)=>{let n=t?`trunc(sysdate)`:`systimestamp`,{bound:r,unit:i}=K(e.anchor),a=n,o=!1;if(r!==`now`&&i){let e=`trunc(${n}, '${_e[i]}')`;if(r===`start`)a=e;else{let n=i===`month`||i===`year`?`add_months(${e}, ${i===`month`?1:12})`:`${e} + interval '1' day${i===`week`?` * 7`:``}`;t?a=`${n} - interval '1' second`:(a=n,o=!0)}}if(e.offset)if(e.unit===`month`||e.unit===`year`)a=`add_months(${a}, ${e.offset*(e.unit===`year`?12:1)})`;else{let t={day:1,week:7}[e.unit];a=t?`${a} ${e.offset<0?`-`:`+`} ${Math.abs(e.offset)*t}`:`${a} + numtodsinterval(${e.offset}, '${e.unit.toUpperCase()}')`}return o&&(a=`cast(${a} as timestamp) - numtodsinterval(0.000001, 'second')`),a},ye={day:`'start of day'`,week:`'weekday 0', '-7 days'`,month:`'start of month'`,year:`'start of year'`},be={ansi:J,mssql:ge,mysql:me,oracle:ve,postgresql:J,sqlite:(e,t)=>{let n=t?`date`:`datetime`,r=[`'now'`],{bound:i,unit:a}=K(e.anchor);if(i!==`now`&&a)if(i===`start`)r.push(ye[a]);else switch(a){case`day`:r.push(`'start of day'`,`'+1 day'`,t?`'-1 day'`:`'-1 second'`);break;case`week`:r.push(`'weekday 0'`,t?`'-1 day'`:`'-1 second'`);break;case`month`:r.push(`'start of month'`,`'+1 month'`,t?`'-1 day'`:`'-1 second'`);break;case`year`:r.push(`'start of year'`,`'+1 year'`,t?`'-1 day'`:`'-1 second'`);break}if(e.offset){let t=e.offset<0?`-`:`+`;r.push(`'${t}${Math.abs(e.offset)} ${q(e.unit)}'`)}return`${n}(${r.join(`, `)})`}},xe=(e,t)=>{let n=t;switch(e){case`mssql`:return!/^(?:small)?datetime/i.test(n);case`mysql`:return!/^(?:datetime|timestamp)/i.test(n);case`oracle`:case`postgresql`:return!/^timestamp/i.test(n);default:return!/^(?:datetime|timestamp)/i.test(n)}},Se=(e,t,n)=>be[t](e,xe(t,n)),Y=({toISOStringDateOnly:e,toISOString:t})=>(n,r)=>i(r?.context?.originalValue)?T({...n,value:e(n.value)},r):T({...n,value:t(n.value)},r),X=({toISOStringDateOnly:e,toISOString:t})=>(n,r)=>{let i=/^(?:small)?datetime/i.test(r?.fieldData?.datatype)?`datetimeoffset`:`date`,a=i===`datetimeoffset`?t(n.value):e(n.value);return T({...n,value:a},{...r,wrapValueWith:[`cast(`,` as ${i})`]})},Z=({toISOStringDateOnly:e,toISOString:t})=>(n,r)=>{let i=/^(?:datetime|timestamp)/i.test(r?.fieldData?.datatype)?`datetime`:`date`,a=i===`datetime`?t(n.value):e(n.value);return T({...n,value:a},{...r,wrapValueWith:[`cast(`,` as ${i})`]})},Q=({toISOStringDateOnly:e,toISOString:t})=>(n,r)=>{let i=/^timestamp/i.test(r?.fieldData?.datatype)?`timestamp`:`date`,a=i===`timestamp`?t(n.value).replaceAll(`T`,` `).replace(`Z`,` UTC`):e(n.value);return T({...n,value:a},{...r,wrapValueWith:[i,``]})},$=({toISOStringDateOnly:e,toISOString:t})=>(n,r)=>{let i=/^timestamp/i.test(r?.fieldData?.datatype)?`timestamp`:`date`,a=i===`timestamp`?t(n.value):e(n.value);return T({...n,value:a},{...r,wrapValueWith:[i,``]})},Ce={ansi:Y,mssql:X,mysql:Z,oracle:Q,postgresql:$,sqlite:Y},we=e=>(r,i)=>{let c=i??{},l=O(t(r,c)),u=D(l),{quoteFieldNamesWith:d=[``,``],fieldIdentifierSeparator:f=``,context:p={}}=c,m=``;if(o(r.valueSource)||!s(p.isDateField,r,c))return x(r,c);let h=Ce[c.preset](e),g=E(r.field,{quoteFieldNamesWith:d,fieldIdentifierSeparator:f}),_=p.materializeRelativeDateTime?a(e,r.value,c):r.value,v=Array.isArray(_)?_:[_];if(v.some(n)){let t=t=>{if(n(t))return Se(t,c.preset,c.fieldData?.datatype);let i=e.toDate(t);if(e.isValid(i))return h({field:r.field,operator:`=`,value:i},{...c,context:{originalValue:t}})};switch(u){case`in`:case`not in`:{let e=v.map(t).filter(e=>e!==void 0);if(e.length===0)return``;m=`(${e.join(`, `)})`;break}case`between`:case`not between`:{let e=t(v[0]),n=t(v[1]);if(e===void 0||n===void 0)return``;m=`${e} and ${n}`;break}default:{let e=t(v[0]);if(e===void 0)return``;m=e}}return`${g} ${l} ${m}`.trim()}let y=j(_,{retainEmptyStrings:!1}).map(t=>[t,e.toDate(t)]).filter(t=>e.isValid(t[1]));switch(u){case`in`:case`not in`:if(y.length===0)return``;m=`(${y.map(e=>h({field:r.field,operator:`=`,value:e[1]},{...c,context:{originalValue:e[0]}})).join(`, `)})`;break;case`between`:case`not between`:{if(y.length<2)return``;let[t,n]=y;m=(e.isBefore(t[1],n[1])?[t,n]:[n,t]).map(([e,t])=>h({field:r.field,operator:`=`,value:t},{...c,context:{originalValue:e}})).join(` and `)}break;default:{let[e,t]=y[0]??[``,``];m=h({field:r.field,operator:`=`,value:t},{...c,context:{originalValue:e}})}}return`${g} ${l} ${m}`.trim()},Te=t=>(n,r)=>{let i=r??{},{context:a={}}=i;if(o(n.valueSource)||!s(a.isDateField,n,i))return w(n,i);let{operator:c,value:l}=e(t,n,i,!0);return w({...n,operator:c,value:l},i)};export{P as C,ae as S,ne as T,R as _,Z as a,se as b,fe as c,W as d,U as f,z as g,H as h,X as i,de as l,B as m,we as n,Q as o,V as p,Y as r,$ as s,Te as t,G as u,L as v,M as w,oe as x,ce as y};
2
+ //# sourceMappingURL=getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs.map