@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.
- package/dist/cjs/{getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js → getDatetimeRuleProcessorTanStackDB-CDEB9coD.js} +22 -19
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-CDEB9coD.js.map +1 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js +2 -0
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-X6tZv7yV.js.map +1 -0
- package/dist/cjs/react-querybuilder_datetime.cjs.development.d.ts +122 -138
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.date-fns.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.dayjs.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js +3 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.d.ts +52 -53
- package/dist/cjs/react-querybuilder_datetime.cjs.development.jsdate.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.development.luxon.js +2 -2
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.d.ts +100 -114
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js +5 -3
- package/dist/cjs/react-querybuilder_datetime.cjs.development.ui.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.d.ts +122 -138
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.date-fns.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.dayjs.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.js.map +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.d.ts +52 -53
- package/dist/cjs/react-querybuilder_datetime.cjs.production.jsdate.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.d.ts +49 -50
- package/dist/cjs/react-querybuilder_datetime.cjs.production.luxon.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.d.ts +100 -114
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js +1 -1
- package/dist/cjs/react-querybuilder_datetime.cjs.production.ui.js.map +1 -1
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js} +2 -2
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-ioz2B1zh.js.map → rqbDateTimeLibraryAPI.jsdate-BuSiVdk7.js.map} +1 -1
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js} +2 -2
- package/dist/cjs/{rqbDateTimeLibraryAPI.jsdate-BPEcMhhr.js.map → rqbDateTimeLibraryAPI.jsdate-C3jJb6ip.js.map} +1 -1
- package/dist/cjs/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
- package/dist/cjs/utils-DdBYGWHZ.js +2 -0
- package/dist/cjs/utils-DdBYGWHZ.js.map +1 -0
- package/dist/cjs/{utils-DUePrC--.js → utils-_X97pUtk.js} +13 -1
- package/dist/cjs/utils-_X97pUtk.js.map +1 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs +2 -0
- package/dist/getDatetimeRuleProcessorTanStackDB-6K1DsuEV.mjs.map +1 -0
- package/dist/{getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js → getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js} +22 -19
- package/dist/getDatetimeRuleProcessorTanStackDB-BrSD2e9G.js.map +1 -0
- package/dist/{getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs → getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs} +22 -19
- package/dist/getDatetimeRuleProcessorTanStackDB-DR8aYrUa.mjs.map +1 -0
- package/dist/{objectSpread2-73AKOozq.js → objectSpread2-MqoZ2hSz.js} +13 -7
- package/dist/objectSpread2-MqoZ2hSz.js.map +1 -0
- package/dist/react-querybuilder_datetime.d.mts +122 -138
- package/dist/react-querybuilder_datetime.date-fns.d.mts +49 -50
- package/dist/react-querybuilder_datetime.date-fns.mjs +2 -2
- package/dist/react-querybuilder_datetime.dayjs.d.mts +49 -50
- package/dist/react-querybuilder_datetime.dayjs.mjs +2 -2
- package/dist/react-querybuilder_datetime.jsdate.d.mts +52 -53
- package/dist/react-querybuilder_datetime.jsdate.mjs +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.d.ts +122 -138
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.date-fns.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.dayjs.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.js +3 -2
- package/dist/react-querybuilder_datetime.legacy-esm.js.map +1 -1
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.d.ts +52 -53
- package/dist/react-querybuilder_datetime.legacy-esm.jsdate.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.d.ts +49 -50
- package/dist/react-querybuilder_datetime.legacy-esm.luxon.js +2 -2
- package/dist/react-querybuilder_datetime.legacy-esm.ui.d.ts +100 -114
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js +7 -5
- package/dist/react-querybuilder_datetime.legacy-esm.ui.js.map +1 -1
- package/dist/react-querybuilder_datetime.luxon.d.mts +49 -50
- package/dist/react-querybuilder_datetime.luxon.mjs +2 -2
- package/dist/react-querybuilder_datetime.mjs +3 -2
- package/dist/react-querybuilder_datetime.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.d.mts +122 -138
- package/dist/react-querybuilder_datetime.production.date-fns.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.date-fns.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.dayjs.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.dayjs.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.jsdate.d.mts +52 -53
- package/dist/react-querybuilder_datetime.production.jsdate.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.luxon.d.mts +49 -50
- package/dist/react-querybuilder_datetime.production.luxon.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.production.ui.d.mts +100 -114
- package/dist/react-querybuilder_datetime.production.ui.mjs +1 -1
- package/dist/react-querybuilder_datetime.production.ui.mjs.map +1 -1
- package/dist/react-querybuilder_datetime.ui.d.mts +100 -114
- package/dist/react-querybuilder_datetime.ui.mjs +5 -3
- package/dist/react-querybuilder_datetime.ui.mjs.map +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js.map → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map} +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs.map → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map} +1 -1
- package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs} +2 -2
- package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs.map → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map} +1 -1
- package/dist/{types-Di8kFIXV.d.mts → types-BKA1aoY6.d.mts} +82 -73
- package/dist/{types-Di8kFIXV.d.ts → types-BKA1aoY6.d.ts} +82 -73
- package/dist/{utils-BC2SALFm.mjs → utils-BAgUBdyf.mjs} +8 -2
- package/dist/utils-BAgUBdyf.mjs.map +1 -0
- package/dist/utils-DA8aluCt.mjs +2 -0
- package/dist/utils-DA8aluCt.mjs.map +1 -0
- package/package.json +16 -16
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js +0 -2
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-BVNfYaIj.js.map +0 -1
- package/dist/cjs/getDatetimeRuleProcessorTanStackDB-cmGqMT0Q.js.map +0 -1
- package/dist/cjs/utils-DUePrC--.js.map +0 -1
- package/dist/cjs/utils-jkW5R1AA.js +0 -2
- package/dist/cjs/utils-jkW5R1AA.js.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-B93XaPdB.mjs.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-BDFJlfJh.js.map +0 -1
- package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs +0 -2
- package/dist/getDatetimeRuleProcessorTanStackDB-Czg9Fbb8.mjs.map +0 -1
- package/dist/objectSpread2-73AKOozq.js.map +0 -1
- package/dist/utils-BC2SALFm.mjs.map +0 -1
- package/dist/utils-VKS8YY2D.mjs +0 -2
- package/dist/utils-VKS8YY2D.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-querybuilder_datetime.ui.mjs","names":["defaultDateTimeAPI"],"sources":["../src/ui/InheritedValueEditorContext.ts","../src/ui/relativeDateTimeConstants.ts","../src/ui/relativeDateTimeModeControllers.tsx","../src/ui/RelativeDateTimeConfigContext.tsx","../src/ui/RelativeDateTimeValueEditor.tsx","../src/ui/QueryBuilderDateTime.tsx"],"sourcesContent":["import type { Context } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\n\n/**\n * Holds the value editor inherited from an outer (compat package) context provider,\n * captured _before_ {@link QueryBuilderDateTime} overrides it. Lets the date/time value\n * editor delegate non-date fields (and absolute date inputs) to the compat editor instead\n * of the bare default {@link react-querybuilder!ValueEditor ValueEditor}. `null` = none\n * inherited (fall back to default).\n */\nexport const InheritedValueEditorContext: Context<React.ComponentType<ValueEditorProps> | null> =\n createContext<React.ComponentType<ValueEditorProps> | null>(null);\n\n/** Inherited (compat) value editor, or `null` if none. See {@link InheritedValueEditorContext}. */\nexport const useInheritedValueEditor = (): React.ComponentType<ValueEditorProps> | null =>\n useContext(InheritedValueEditorContext);\n","import type { FullOption } from '@react-querybuilder/core';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport type { RelativeDateTimeToggleLabels } from './types';\n\n/**\n * Class name applied to the absolute/relative mode toggle button. Package-local (not part\n * of the core `standardClassnames`) to avoid coupling core to this extension.\n */\nexport const relativeDateTimeToggleClassName = 'rule-value-dateTimeRelative-toggle';\n\n/** Default value applied when switching a rule to relative mode. */\nexport const defaultRelativeDateTimeValue: RelativeDateTimeValue = {\n mode: 'relative',\n anchor: 'now',\n offset: 0,\n unit: 'day',\n};\n\n/** Default anchor (reference-point) options for the relative date/time editor. */\nexport const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[] = [\n { name: 'now', value: 'now', label: 'now' },\n { name: 'startOfDay', value: 'startOfDay', label: 'start of day' },\n { name: 'endOfDay', value: 'endOfDay', label: 'end of day' },\n { name: 'startOfWeek', value: 'startOfWeek', label: 'start of week' },\n { name: 'endOfWeek', value: 'endOfWeek', label: 'end of week' },\n { name: 'startOfMonth', value: 'startOfMonth', label: 'start of month' },\n { name: 'endOfMonth', value: 'endOfMonth', label: 'end of month' },\n { name: 'startOfYear', value: 'startOfYear', label: 'start of year' },\n { name: 'endOfYear', value: 'endOfYear', label: 'end of year' },\n];\n\n/** Default unit options for the relative date/time editor. */\nexport const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[] = [\n { name: 'minute', value: 'minute', label: 'minute(s)' },\n { name: 'hour', value: 'hour', label: 'hour(s)' },\n { name: 'day', value: 'day', label: 'day(s)' },\n { name: 'week', value: 'week', label: 'week(s)' },\n { name: 'month', value: 'month', label: 'month(s)' },\n { name: 'year', value: 'year', label: 'year(s)' },\n];\n\n/** Default labels/content for the absolute/relative mode toggle. */\nexport const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels> = {\n label: 'Toggle relative date/time',\n absoluteTitle: 'Absolute date/time (click for relative)',\n relativeTitle: 'Relative date/time (click for absolute)',\n // Empty by default; the CSS pseudo-element renders the glyph based on `aria-checked`.\n absoluteContent: '',\n relativeContent: '',\n};\n","import * as React from 'react';\nimport type { FullOperator } from 'react-querybuilder';\nimport { clsx, defaultOperators } from 'react-querybuilder';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { relativeDateTimeToggleClassName } from './relativeDateTimeConstants';\nimport type { RelativeDateTimeModeController, RelativeDateTimeModeControlProps } from './types';\n\n/**\n * Compact absolute/relative toggle rendered by {@link toggleModeController}. A\n * `role=\"switch\"` button whose default glyph is supplied by CSS (keyed on\n * `aria-checked`); override via the `toggleLabels` config.\n *\n * @group Components\n */\nexport const RelativeDateTimeModeToggle = ({\n isRelative,\n setMode,\n disabled,\n className,\n labels,\n}: RelativeDateTimeModeControlProps): React.JSX.Element => {\n const onClick = React.useCallback(\n () => setMode(isRelative ? 'absolute' : 'relative'),\n [setMode, isRelative]\n );\n\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isRelative}\n aria-label={labels.label}\n title={isRelative ? labels.relativeTitle : labels.absoluteTitle}\n disabled={disabled}\n className={clsx(relativeDateTimeToggleClassName, className)}\n onClick={onClick}>\n {isRelative ? labels.relativeContent : labels.absoluteContent}\n </button>\n );\n};\n\n/**\n * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the\n * value shape and renders a compact toggle button to switch between absolute and\n * relative entry.\n */\nexport const toggleModeController: RelativeDateTimeModeController = {\n isRelative: props => isRelativeDateTimeValue(props.value),\n ModeControl: RelativeDateTimeModeToggle,\n};\n\n/**\n * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode\n * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the\n * editor in relative mode. No toggle is rendered — the operator selector is the mode\n * affordance.\n *\n * NOTE: the chosen operators only signal _mode_; the rule's value remains a\n * {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a\n * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`\n * (e.g. `{ relativeEq: '=' }`). See the documentation.\n */\nexport const createOperatorModeController = (\n relativeOperators: string[] | ((operator: string) => boolean)\n): RelativeDateTimeModeController => ({\n isRelative: props =>\n typeof relativeOperators === 'function'\n ? relativeOperators(props.operator)\n : relativeOperators.includes(props.operator),\n});\n\ninterface FieldWithOperators {\n operators?: FullOperator[];\n [key: string]: unknown;\n}\n\n/**\n * Appends the given `operators` to each field's `operators` list, so the operator-driven\n * controller (see {@link createOperatorModeController}) has an operator to switch into\n * relative mode. Fields without an explicit `operators` list fall back to the core\n * `defaultOperators`.\n */\nexport const withRelativeOperators = <F extends FieldWithOperators>(\n fields: F[],\n operators: FullOperator[]\n): F[] =>\n fields.map(field => ({\n ...field,\n operators: [...(field.operators ?? (defaultOperators as FullOperator[])), ...operators],\n }));\n","import * as React from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { FullOption } from 'react-querybuilder';\nimport { rqbDateTimeLibraryAPI as defaultDateTimeAPI } from '../rqbDateTimeLibraryAPI.jsdate';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RQBDateTimeLibraryAPI } from '../types';\nimport {\n defaultRelativeDateTimeAnchors,\n defaultRelativeDateTimeToggleLabels,\n defaultRelativeDateTimeUnits,\n} from './relativeDateTimeConstants';\nimport { toggleModeController } from './relativeDateTimeModeControllers';\nimport type {\n RelativeDateTimeEditorConfig,\n RelativeDateTimeModeController,\n RelativeDateTimeToggleLabels,\n} from './types';\n\n/** Fully-resolved relative date/time editor config (no optional fields). */\nexport interface ResolvedRelativeDateTimeConfig {\n modeController: RelativeDateTimeModeController;\n anchors: FullOption<RelativeDateTimeAnchor>[];\n units: FullOption<RelativeDateTimeUnit>[];\n toggleLabels: Required<RelativeDateTimeToggleLabels>;\n dateTimeAPI: RQBDateTimeLibraryAPI;\n}\n\n/**\n * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.\n * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.\n */\nexport const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig> =\n createContext<RelativeDateTimeEditorConfig>({});\n\n/** Reads the relative date/time editor config from context, merged with defaults. */\nexport const useRelativeDateTimeConfig = (): ResolvedRelativeDateTimeConfig => {\n const config = useContext(RelativeDateTimeConfigContext);\n return useMemo(\n () => ({\n modeController: config.modeController ?? toggleModeController,\n anchors: config.anchors ?? defaultRelativeDateTimeAnchors,\n units: config.units ?? defaultRelativeDateTimeUnits,\n toggleLabels: { ...defaultRelativeDateTimeToggleLabels, ...config.toggleLabels },\n dateTimeAPI: config.dateTimeAPI ?? defaultDateTimeAPI,\n }),\n [config]\n );\n};\n","import * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport type { FullField, Path, ValueEditorProps, ValueSelectorProps } from 'react-querybuilder';\nimport {\n clsx,\n parseNumber,\n standardClassnames,\n toArray,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { useInheritedValueEditor } from './InheritedValueEditorContext';\nimport { DateTimeValueEditor } from './QueryBuilderDateTime';\nimport type { ResolvedRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { useRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { defaultRelativeDateTimeValue } from './relativeDateTimeConstants';\n\nconst dummyPath: Path = [];\nconst dummyFieldData: FullField = { name: '', value: '', label: '' };\n\n/** Splits a value into the from/to pair used by between/notBetween, object-safe. */\nconst toBetweenArray = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : isRelativeDateTimeValue(value) ? [value] : toArray(value);\n\ninterface RelativeDateTimeSingleValueEditorProps {\n /** The original value editor props (for mode derivation and absolute rendering). */\n baseProps: ValueEditorProps;\n /** The value for this slot (the whole value, or one element of a between pair). */\n value: unknown;\n /** Emits a new value for this slot. */\n onChange: (value: unknown) => void;\n /** Operator passed to the absolute editor (forced to `=` for between slots). */\n absoluteOperator: string;\n config: ResolvedRelativeDateTimeConfig;\n SelectorComponent: React.ComponentType<ValueSelectorProps>;\n /** Themed numeric offset input: the inherited (compat) editor when present, else the default. */\n NumericEditorComponent: React.ComponentType<ValueEditorProps>;\n valueListItemClassName?: string;\n numericSchema: ValueEditorProps['schema'];\n}\n\n/**\n * Renders a single absolute-or-relative date/time value: a mode affordance (per the\n * controller) plus either an absolute date input or anchor + signed offset + unit\n * selectors. Reused once per slot so between/notBetween can mix bounds (e.g. an absolute\n * \"from\" and a relative \"to\").\n */\nconst RelativeDateTimeSingleValueEditor = ({\n baseProps,\n value,\n onChange,\n absoluteOperator,\n config,\n SelectorComponent,\n NumericEditorComponent,\n valueListItemClassName,\n numericSchema,\n}: RelativeDateTimeSingleValueEditorProps): React.JSX.Element => {\n const { schema, disabled, title, testID } = baseProps;\n const { modeController, anchors, units, toggleLabels } = config;\n\n const isRelative = modeController.isRelative({ ...baseProps, value });\n const relValue: RelativeDateTimeValue = isRelativeDateTimeValue(value)\n ? value\n : defaultRelativeDateTimeValue;\n\n const handleSetMode = useCallback(\n (mode: 'absolute' | 'relative') =>\n onChange(mode === 'relative' ? defaultRelativeDateTimeValue : ''),\n [onChange]\n );\n\n const handleChangeAnchor = useCallback(\n (anchor: string) => onChange({ ...relValue, anchor: anchor as RelativeDateTimeAnchor }),\n [onChange, relValue]\n );\n\n const handleChangeOffset = useCallback(\n (offset: unknown) =>\n onChange({\n ...relValue,\n offset: (parseNumber(offset, { parseNumbers: true }) as number) || 0,\n }),\n [onChange, relValue]\n );\n\n const handleChangeUnit = useCallback(\n (unit: string) => onChange({ ...relValue, unit: unit as RelativeDateTimeUnit }),\n [onChange, relValue]\n );\n\n const { ModeControl } = modeController;\n\n return (\n <React.Fragment>\n {ModeControl && (\n <ModeControl\n isRelative={isRelative}\n setMode={handleSetMode}\n schema={schema}\n disabled={disabled}\n className={valueListItemClassName}\n title={title}\n testID={testID}\n labels={toggleLabels}\n />\n )}\n {isRelative ? (\n <React.Fragment>\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeAnchor}\n disabled={disabled}\n value={relValue.anchor}\n options={anchors}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n <NumericEditorComponent\n skipHook\n testID={testID}\n inputType=\"number\"\n title={title}\n className={valueListItemClassName}\n disabled={disabled}\n handleOnChange={handleChangeOffset}\n field={''}\n operator={''}\n value={relValue.offset}\n valueSource={'value'}\n fieldData={dummyFieldData}\n schema={numericSchema}\n path={dummyPath}\n level={0}\n rule={{ field: '', operator: '=', value: relValue.offset }}\n />\n {relValue.offset !== 0 && (\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeUnit}\n disabled={disabled}\n value={relValue.unit}\n options={units}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n )}\n </React.Fragment>\n ) : (\n <DateTimeValueEditor\n {...baseProps}\n operator={absoluteOperator}\n value={value}\n handleOnChange={onChange}\n className={standardClassnames.value}\n />\n )}\n </React.Fragment>\n );\n};\n\n/**\n * Value editor with support for {@link RelativeDateTimeValue relative date/time values}\n * (e.g. \"three months ago\" or \"the beginning of this year\"). How the user switches\n * between absolute and relative modes is delegated to a pluggable\n * {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via\n * {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit\n * selectors; the unit selector is hidden when the offset is `0`.\n *\n * For the `between`/`notBetween` operators it renders two independent value editors (each\n * with its own mode affordance) and stores the bounds as a two-element array, so the from\n * and to bounds can independently be absolute or relative.\n *\n * @group Components\n */\nexport const RelativeDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const { valueListItemClassName } = useValueEditor(props);\n\n const { className, value, handleOnChange, schema, operator, separator } = props;\n const { suppressStandardClassnames } = schema;\n\n const SelectorComponent = props.selectorComponent ?? schema.controls.valueSelector;\n\n // Themed numeric offset input from the inherited (compat) editor when present, else default.\n const NumericEditorComponent = useInheritedValueEditor() ?? ValueEditor;\n\n const config = useRelativeDateTimeConfig();\n\n const numericSchema = useMemo(() => ({ ...schema, parseNumbers: true }), [schema]);\n\n const outerClassname = useMemo(\n () => clsx(suppressStandardClassnames || standardClassnames.valueDateTimeRelative, className),\n [suppressStandardClassnames, className]\n );\n\n const isBetween = operator === 'between' || operator === 'notBetween';\n\n // For between/notBetween, store the bounds as a two-element array. Relative values are\n // objects (which can't survive comma-joining), so the array is emitted directly,\n // regardless of `listsAsArrays`.\n const valueAsArray = useMemo(() => toBetweenArray(value), [value]);\n\n const handleChangeBound = useCallback(\n (index: number) => (boundValue: unknown) => {\n const next = [valueAsArray[0], valueAsArray[1]];\n next[index] = boundValue;\n handleOnChange(next);\n },\n [valueAsArray, handleOnChange]\n );\n\n if (isBetween) {\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[0]}\n onChange={handleChangeBound(0)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n {separator}\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[1]}\n onChange={handleChangeBound(1)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n }\n\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={value}\n onChange={handleOnChange}\n absoluteOperator={operator}\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n};\n","import * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport type { QueryBuilderContextProvider, ValueEditorProps } from 'react-querybuilder';\nimport {\n getCompatContextProvider,\n QueryBuilderContext,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport {\n InheritedValueEditorContext,\n useInheritedValueEditor,\n} from './InheritedValueEditorContext';\nimport {\n RelativeDateTimeConfigContext,\n useRelativeDateTimeConfig,\n} from './RelativeDateTimeConfigContext';\nimport { RelativeDateTimeValueEditor } from './RelativeDateTimeValueEditor';\nimport type { RelativeDateTimeEditorConfig } from './types';\n\n/**\n * Whether a rule should use a date/time editor, based on either the coerced input\n * type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).\n */\nconst isDateTimeEditor = (props: ValueEditorProps, inputTypeCoerced: string | undefined): boolean =>\n (props.type === 'text' &&\n (inputTypeCoerced === 'date' || inputTypeCoerced === 'datetime-local')) ||\n /^(?:date|datetime|timestamp)\\b/i.test(props.fieldData?.datatype as string);\n\nconst pad2 = (n: number): string => `${n}`.padStart(2, '0');\n\n/**\n * Formats a `Date` into the local value expected by a native `date`/`datetime-local`\n * input (library-agnostic; the date library only handles parsing/validation).\n */\nconst formatDateInputValue = (d: Date, withTime: boolean): string => {\n const datePart = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n return withTime ? `${datePart}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : datePart;\n};\n\n/**\n * Renders the inherited (compat) editor when one is provided, otherwise the default\n * {@link react-querybuilder!ValueEditor ValueEditor}. The editor is received as a prop (rather\n * than read from context here) so the JSX element type stays prop-sourced and stable.\n */\nconst FallbackValueEditor = ({\n editor: Editor,\n ...props\n}: ValueEditorProps & {\n editor: React.ComponentType<ValueEditorProps> | null;\n}): React.JSX.Element => (Editor ? <Editor {...props} /> : <ValueEditor {...props} skipHook />);\n\nexport const DateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n const { dateTimeAPI } = useRelativeDateTimeConfig();\n\n // Non-date fields and unparseable values: delegate to the inherited (compat) editor when\n // present, otherwise the default editor.\n const fallback = (p: ValueEditorProps) => <FallbackValueEditor editor={InheritedEditor} {...p} />;\n\n if (!isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return fallback(props);\n }\n\n if (dateTimeAPI.isValid(props.value)) {\n const value = formatDateInputValue(\n dateTimeAPI.toDate(props.value),\n uVE.inputTypeCoerced !== 'date'\n );\n return fallback({ ...props, value });\n }\n\n return fallback(props);\n};\n\n/**\n * Provider value editor: renders the relative-capable {@link RelativeDateTimeValueEditor}\n * for date/time fields and falls back to the inherited (compat) editor for everything else.\n */\nconst QueryBuilderDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n\n if (isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return <RelativeDateTimeValueEditor {...props} />;\n }\n\n return <FallbackValueEditor editor={InheritedEditor} {...props} />;\n};\n\nexport const QueryBuilderDateTimeContext: QueryBuilderContextProvider = getCompatContextProvider({\n controlElements: { valueEditor: QueryBuilderDateTimeValueEditor },\n});\n\n/** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */\nexport interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {\n children?: React.ReactNode;\n}\n\n/**\n * Context provider enabling date/time features for a wrapped\n * {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable\n * {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional\n * {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and\n * toggle labels). With no props it provides the zero-config toggle experience.\n *\n * @group Components\n */\nexport const QueryBuilderDateTime = ({\n children,\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n}: QueryBuilderDateTimeProps): React.JSX.Element => {\n const config = useMemo(\n (): RelativeDateTimeEditorConfig => ({\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n }),\n [modeController, anchors, units, toggleLabels, dateTimeAPI]\n );\n\n // Capture the value editor inherited from any outer compat provider (e.g. QueryBuilderMaterial)\n // _before_ QueryBuilderDateTimeContext overrides it, so date/time editors can delegate to it.\n const inheritedValueEditor = (useContext(QueryBuilderContext).controlElements?.valueEditor ??\n null) as React.ComponentType<ValueEditorProps> | null;\n\n return (\n <RelativeDateTimeConfigContext.Provider value={config}>\n <InheritedValueEditorContext.Provider value={inheritedValueEditor}>\n <QueryBuilderDateTimeContext>{children}</QueryBuilderDateTimeContext>\n </InheritedValueEditorContext.Provider>\n </RelativeDateTimeConfigContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,8BACX,cAA4D,IAAI;;AAGlE,MAAa,gCACX,WAAW,2BAA2B;;;;;;;ACRxC,MAAa,kCAAkC;;AAG/C,MAAa,+BAAsD;CACjE,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,iCAAuE;CAClF;EAAE,MAAM;EAAO,OAAO;EAA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C,KAAQ;CAGlD,OAAO,sBAAA,cAAC,qBAAD;EAAqB,QAAQ;EAAiB,GAAI;CAAQ,CAAA;AACnE;AAEA,MAAa,8BAA2D,yBAAyB,EAC/F,iBAAiB,EAAE,aAAa,gCAAgC,EAClE,CAAC;;;;;;;;;;AAgBD,MAAa,wBAAwB,EACnC,UACA,gBACA,SACA,OACA,cACA,kBACkD;CAClD,MAAM,SAAS,eACwB;EACnC;EACA;EACA;EACA;EACA;CACF,IACA;EAAC;EAAgB;EAAS;EAAO;EAAc;CAAW,CAC5D;CAIA,MAAM,uBAAwB,WAAW,mBAAmB,CAAC,CAAC,iBAAiB,eAC7E;CAEF,OACE,sBAAA,cAAC,8BAA8B,UAA/B,EAAwC,OAAO,OAIP,GAHtC,sBAAA,cAAC,4BAA4B,UAA7B,EAAsC,OAAO,qBAEP,GADpC,sBAAA,cAAC,6BAAA,MAA6B,QAAsC,CAChC,CACA;AAE5C"}
|
|
1
|
+
{"version":3,"file":"react-querybuilder_datetime.ui.mjs","names":["defaultDateTimeAPI"],"sources":["../src/ui/InheritedValueEditorContext.ts","../src/ui/relativeDateTimeConstants.ts","../src/ui/relativeDateTimeModeControllers.tsx","../src/ui/RelativeDateTimeConfigContext.tsx","../src/ui/RelativeDateTimeValueEditor.tsx","../src/ui/QueryBuilderDateTime.tsx"],"sourcesContent":["import type { Context } from 'react';\nimport { createContext, useContext } from 'react';\nimport type { ValueEditorProps } from 'react-querybuilder';\n\n/**\n * Holds the value editor inherited from an outer (compat package) context provider,\n * captured _before_ {@link QueryBuilderDateTime} overrides it. Lets the date/time value\n * editor delegate non-date fields (and absolute date inputs) to the compat editor instead\n * of the bare default {@link react-querybuilder!ValueEditor ValueEditor}. `null` = none\n * inherited (fall back to default).\n */\nexport const InheritedValueEditorContext: Context<React.ComponentType<ValueEditorProps> | null> =\n createContext<React.ComponentType<ValueEditorProps> | null>(null);\n\n/** Inherited (compat) value editor, or `null` if none. See {@link InheritedValueEditorContext}. */\nexport const useInheritedValueEditor = (): React.ComponentType<ValueEditorProps> | null =>\n useContext(InheritedValueEditorContext);\n","import type { FullOption } from '@react-querybuilder/core';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport type { RelativeDateTimeToggleLabels } from './types';\n\n/**\n * Class name applied to the absolute/relative mode toggle button. Package-local (not part\n * of the core `standardClassnames`) to avoid coupling core to this extension.\n */\nexport const relativeDateTimeToggleClassName = 'rule-value-dateTimeRelative-toggle';\n\n/** Default value applied when switching a rule to relative mode. */\nexport const defaultRelativeDateTimeValue: RelativeDateTimeValue = {\n mode: 'relative',\n anchor: 'now',\n offset: 0,\n unit: 'day',\n};\n\n/** Default anchor (reference-point) options for the relative date/time editor. */\nexport const defaultRelativeDateTimeAnchors: FullOption<RelativeDateTimeAnchor>[] = [\n { name: 'now', value: 'now', label: 'now' },\n { name: 'startOfDay', value: 'startOfDay', label: 'start of day' },\n { name: 'endOfDay', value: 'endOfDay', label: 'end of day' },\n { name: 'startOfWeek', value: 'startOfWeek', label: 'start of week' },\n { name: 'endOfWeek', value: 'endOfWeek', label: 'end of week' },\n { name: 'startOfMonth', value: 'startOfMonth', label: 'start of month' },\n { name: 'endOfMonth', value: 'endOfMonth', label: 'end of month' },\n { name: 'startOfYear', value: 'startOfYear', label: 'start of year' },\n { name: 'endOfYear', value: 'endOfYear', label: 'end of year' },\n];\n\n/** Default unit options for the relative date/time editor. */\nexport const defaultRelativeDateTimeUnits: FullOption<RelativeDateTimeUnit>[] = [\n { name: 'minute', value: 'minute', label: 'minute(s)' },\n { name: 'hour', value: 'hour', label: 'hour(s)' },\n { name: 'day', value: 'day', label: 'day(s)' },\n { name: 'week', value: 'week', label: 'week(s)' },\n { name: 'month', value: 'month', label: 'month(s)' },\n { name: 'year', value: 'year', label: 'year(s)' },\n];\n\n/** Default labels/content for the absolute/relative mode toggle. */\nexport const defaultRelativeDateTimeToggleLabels: Required<RelativeDateTimeToggleLabels> = {\n label: 'Toggle relative date/time',\n absoluteTitle: 'Absolute date/time (click for relative)',\n relativeTitle: 'Relative date/time (click for absolute)',\n // Empty by default; the CSS pseudo-element renders the glyph based on `aria-checked`.\n absoluteContent: '',\n relativeContent: '',\n};\n","import * as React from 'react';\nimport type { FullOperator } from 'react-querybuilder';\nimport { clsx, defaultOperators } from 'react-querybuilder';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { relativeDateTimeToggleClassName } from './relativeDateTimeConstants';\nimport type { RelativeDateTimeModeController, RelativeDateTimeModeControlProps } from './types';\n\n/**\n * Compact absolute/relative toggle rendered by {@link toggleModeController}. A\n * `role=\"switch\"` button whose default glyph is supplied by CSS (keyed on\n * `aria-checked`); override via the `toggleLabels` config.\n *\n * @group Components\n */\nexport const RelativeDateTimeModeToggle = ({\n isRelative,\n setMode,\n disabled,\n className,\n labels,\n}: RelativeDateTimeModeControlProps): React.JSX.Element => {\n const onClick = React.useCallback(\n () => setMode(isRelative ? 'absolute' : 'relative'),\n [setMode, isRelative]\n );\n\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={isRelative}\n aria-label={labels.label}\n title={isRelative ? labels.relativeTitle : labels.absoluteTitle}\n disabled={disabled}\n className={clsx(relativeDateTimeToggleClassName, className)}\n onClick={onClick}>\n {isRelative ? labels.relativeContent : labels.absoluteContent}\n </button>\n );\n};\n\n/**\n * Zero-config default {@link RelativeDateTimeModeController}: derives the mode from the\n * value shape and renders a compact toggle button to switch between absolute and\n * relative entry.\n */\nexport const toggleModeController: RelativeDateTimeModeController = {\n isRelative: props => isRelativeDateTimeValue(props.value),\n ModeControl: RelativeDateTimeModeToggle,\n};\n\n/**\n * Builds an operator-driven {@link RelativeDateTimeModeController} that derives the mode\n * from the rule's operator. Pass the operator name(s) (or a predicate) that should put the\n * editor in relative mode. No toggle is rendered — the operator selector is the mode\n * affordance.\n *\n * NOTE: the chosen operators only signal _mode_; the rule's value remains a\n * {@link RelativeDateTimeValue}. For these operators to export correctly, map each one to a\n * real comparison operator via `context.relativeOperatorMap` when calling `formatQuery`\n * (e.g. `{ relativeEq: '=' }`). See the documentation.\n */\nexport const createOperatorModeController = (\n relativeOperators: string[] | ((operator: string) => boolean)\n): RelativeDateTimeModeController => ({\n isRelative: props =>\n typeof relativeOperators === 'function'\n ? relativeOperators(props.operator)\n : relativeOperators.includes(props.operator),\n});\n\ninterface FieldWithOperators {\n operators?: FullOperator[];\n [key: string]: unknown;\n}\n\n/**\n * Appends the given `operators` to each field's `operators` list, so the operator-driven\n * controller (see {@link createOperatorModeController}) has an operator to switch into\n * relative mode. Fields without an explicit `operators` list fall back to the core\n * `defaultOperators`.\n */\nexport const withRelativeOperators = <F extends FieldWithOperators>(\n fields: F[],\n operators: FullOperator[]\n): F[] =>\n fields.map(field => ({\n ...field,\n operators: [...(field.operators ?? (defaultOperators as FullOperator[])), ...operators],\n }));\n","import * as React from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { FullOption } from 'react-querybuilder';\nimport { rqbDateTimeLibraryAPI as defaultDateTimeAPI } from '../rqbDateTimeLibraryAPI.jsdate';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RQBDateTimeLibraryAPI } from '../types';\nimport {\n defaultRelativeDateTimeAnchors,\n defaultRelativeDateTimeToggleLabels,\n defaultRelativeDateTimeUnits,\n} from './relativeDateTimeConstants';\nimport { toggleModeController } from './relativeDateTimeModeControllers';\nimport type {\n RelativeDateTimeEditorConfig,\n RelativeDateTimeModeController,\n RelativeDateTimeToggleLabels,\n} from './types';\n\n/** Fully-resolved relative date/time editor config (no optional fields). */\nexport interface ResolvedRelativeDateTimeConfig {\n modeController: RelativeDateTimeModeController;\n anchors: FullOption<RelativeDateTimeAnchor>[];\n units: FullOption<RelativeDateTimeUnit>[];\n toggleLabels: Required<RelativeDateTimeToggleLabels>;\n dateTimeAPI: RQBDateTimeLibraryAPI;\n}\n\n/**\n * Carries {@link RelativeDateTimeEditorConfig} to the {@link RelativeDateTimeValueEditor}.\n * Provided by {@link QueryBuilderDateTime}; defaults apply when no provider is present.\n */\nexport const RelativeDateTimeConfigContext: React.Context<RelativeDateTimeEditorConfig> =\n createContext<RelativeDateTimeEditorConfig>({});\n\n/** Reads the relative date/time editor config from context, merged with defaults. */\nexport const useRelativeDateTimeConfig = (): ResolvedRelativeDateTimeConfig => {\n const config = useContext(RelativeDateTimeConfigContext);\n return useMemo(\n () => ({\n modeController: config.modeController ?? toggleModeController,\n anchors: config.anchors ?? defaultRelativeDateTimeAnchors,\n units: config.units ?? defaultRelativeDateTimeUnits,\n toggleLabels: { ...defaultRelativeDateTimeToggleLabels, ...config.toggleLabels },\n dateTimeAPI: config.dateTimeAPI ?? defaultDateTimeAPI,\n }),\n [config]\n );\n};\n","import * as React from 'react';\nimport { useCallback, useMemo } from 'react';\nimport type { FullField, Path, ValueEditorProps, ValueSelectorProps } from 'react-querybuilder';\nimport {\n clsx,\n parseNumber,\n standardClassnames,\n toArray,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport type { RelativeDateTimeAnchor, RelativeDateTimeUnit, RelativeDateTimeValue } from '../types';\nimport { isRelativeDateTimeValue } from '../utils';\nimport { useInheritedValueEditor } from './InheritedValueEditorContext';\nimport { DateTimeValueEditor } from './QueryBuilderDateTime';\nimport type { ResolvedRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { useRelativeDateTimeConfig } from './RelativeDateTimeConfigContext';\nimport { defaultRelativeDateTimeValue } from './relativeDateTimeConstants';\n\nconst dummyPath: Path = [];\nconst dummyFieldData: FullField = { name: '', value: '', label: '' };\n\n/** Splits a value into the from/to pair used by between/notBetween, object-safe. */\nconst toBetweenArray = (value: unknown): unknown[] =>\n Array.isArray(value) ? value : isRelativeDateTimeValue(value) ? [value] : toArray(value);\n\ninterface RelativeDateTimeSingleValueEditorProps {\n /** The original value editor props (for mode derivation and absolute rendering). */\n baseProps: ValueEditorProps;\n /** The value for this slot (the whole value, or one element of a between pair). */\n value: unknown;\n /** Emits a new value for this slot. */\n onChange: (value: unknown) => void;\n /** Operator passed to the absolute editor (forced to `=` for between slots). */\n absoluteOperator: string;\n config: ResolvedRelativeDateTimeConfig;\n SelectorComponent: React.ComponentType<ValueSelectorProps>;\n /** Themed numeric offset input: the inherited (compat) editor when present, else the default. */\n NumericEditorComponent: React.ComponentType<ValueEditorProps>;\n valueListItemClassName?: string;\n numericSchema: ValueEditorProps['schema'];\n}\n\n/**\n * Renders a single absolute-or-relative date/time value: a mode affordance (per the\n * controller) plus either an absolute date input or anchor + signed offset + unit\n * selectors. Reused once per slot so between/notBetween can mix bounds (e.g. an absolute\n * \"from\" and a relative \"to\").\n */\nconst RelativeDateTimeSingleValueEditor = ({\n baseProps,\n value,\n onChange,\n absoluteOperator,\n config,\n SelectorComponent,\n NumericEditorComponent,\n valueListItemClassName,\n numericSchema,\n}: RelativeDateTimeSingleValueEditorProps): React.JSX.Element => {\n const { schema, disabled, title, testID } = baseProps;\n const { modeController, anchors, units, toggleLabels } = config;\n\n const isRelative = modeController.isRelative({ ...baseProps, value });\n const relValue: RelativeDateTimeValue = isRelativeDateTimeValue(value)\n ? value\n : defaultRelativeDateTimeValue;\n\n const handleSetMode = useCallback(\n (mode: 'absolute' | 'relative') =>\n onChange(mode === 'relative' ? defaultRelativeDateTimeValue : ''),\n [onChange]\n );\n\n const handleChangeAnchor = useCallback(\n (anchor: string) => onChange({ ...relValue, anchor: anchor as RelativeDateTimeAnchor }),\n [onChange, relValue]\n );\n\n const handleChangeOffset = useCallback(\n (offset: unknown) =>\n onChange({\n ...relValue,\n offset: (parseNumber(offset, { parseNumbers: true }) as number) || 0,\n }),\n [onChange, relValue]\n );\n\n const handleChangeUnit = useCallback(\n (unit: string) => onChange({ ...relValue, unit: unit as RelativeDateTimeUnit }),\n [onChange, relValue]\n );\n\n const { ModeControl } = modeController;\n\n return (\n <React.Fragment>\n {ModeControl && (\n <ModeControl\n isRelative={isRelative}\n setMode={handleSetMode}\n schema={schema}\n disabled={disabled}\n className={valueListItemClassName}\n title={title}\n testID={testID}\n labels={toggleLabels}\n />\n )}\n {isRelative ? (\n <React.Fragment>\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeAnchor}\n disabled={disabled}\n value={relValue.anchor}\n options={anchors}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n <NumericEditorComponent\n skipHook\n testID={testID}\n inputType=\"number\"\n title={title}\n className={valueListItemClassName}\n disabled={disabled}\n handleOnChange={handleChangeOffset}\n field={''}\n operator={''}\n value={relValue.offset}\n valueSource={'value'}\n fieldData={dummyFieldData}\n schema={numericSchema}\n path={dummyPath}\n level={0}\n rule={{ field: '', operator: '=', value: relValue.offset }}\n />\n {relValue.offset !== 0 && (\n <SelectorComponent\n schema={schema}\n testID={testID}\n title={title}\n className={valueListItemClassName}\n handleOnChange={handleChangeUnit}\n disabled={disabled}\n value={relValue.unit}\n options={units}\n multiple={false}\n listsAsArrays={false}\n path={dummyPath}\n level={0}\n />\n )}\n </React.Fragment>\n ) : (\n <DateTimeValueEditor\n {...baseProps}\n operator={absoluteOperator}\n value={value}\n handleOnChange={onChange}\n className={standardClassnames.value}\n />\n )}\n </React.Fragment>\n );\n};\n\n/**\n * Value editor with support for {@link RelativeDateTimeValue relative date/time values}\n * (e.g. \"three months ago\" or \"the beginning of this year\"). How the user switches\n * between absolute and relative modes is delegated to a pluggable\n * {@link RelativeDateTimeModeController} (default: a compact toggle), supplied via\n * {@link QueryBuilderDateTime}. In relative mode it renders anchor + signed offset + unit\n * selectors; the unit selector is hidden when the offset is `0`.\n *\n * For the `between`/`notBetween` operators it renders two independent value editors (each\n * with its own mode affordance) and stores the bounds as a two-element array, so the from\n * and to bounds can independently be absolute or relative.\n *\n * @group Components\n */\nexport const RelativeDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const { valueListItemClassName } = useValueEditor(props);\n\n const { className, value, handleOnChange, schema, operator, separator } = props;\n const { suppressStandardClassnames } = schema;\n\n const SelectorComponent = props.selectorComponent ?? schema.controls.valueSelector;\n\n // Themed numeric offset input from the inherited (compat) editor when present, else default.\n const NumericEditorComponent = useInheritedValueEditor() ?? ValueEditor;\n\n const config = useRelativeDateTimeConfig();\n\n const numericSchema = useMemo(() => ({ ...schema, parseNumbers: true }), [schema]);\n\n const outerClassname = useMemo(\n () => clsx(suppressStandardClassnames || standardClassnames.valueDateTimeRelative, className),\n [suppressStandardClassnames, className]\n );\n\n const isBetween = operator === 'between' || operator === 'notBetween';\n\n // For between/notBetween, store the bounds as a two-element array. Relative values are\n // objects (which can't survive comma-joining), so the array is emitted directly,\n // regardless of `listsAsArrays`.\n const valueAsArray = useMemo(() => toBetweenArray(value), [value]);\n\n const handleChangeBound = useCallback(\n (index: number) => (boundValue: unknown) => {\n const next = [valueAsArray[0], valueAsArray[1]];\n next[index] = boundValue;\n handleOnChange(next);\n },\n [valueAsArray, handleOnChange]\n );\n\n if (isBetween) {\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[0]}\n onChange={handleChangeBound(0)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n {separator}\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={valueAsArray[1]}\n onChange={handleChangeBound(1)}\n absoluteOperator=\"=\"\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n }\n\n return (\n <span className={outerClassname}>\n <RelativeDateTimeSingleValueEditor\n baseProps={props}\n value={value}\n onChange={handleOnChange}\n absoluteOperator={operator}\n config={config}\n SelectorComponent={SelectorComponent}\n NumericEditorComponent={NumericEditorComponent}\n valueListItemClassName={valueListItemClassName}\n numericSchema={numericSchema}\n />\n </span>\n );\n};\n","import * as React from 'react';\nimport { useContext, useMemo } from 'react';\nimport type { QueryBuilderContextProvider, ValueEditorProps } from 'react-querybuilder';\nimport {\n getCompatContextProvider,\n QueryBuilderContext,\n useValueEditor,\n ValueEditor,\n} from 'react-querybuilder';\nimport { isNonDateValueSource } from '../utils';\nimport {\n InheritedValueEditorContext,\n useInheritedValueEditor,\n} from './InheritedValueEditorContext';\nimport {\n RelativeDateTimeConfigContext,\n useRelativeDateTimeConfig,\n} from './RelativeDateTimeConfigContext';\nimport { RelativeDateTimeValueEditor } from './RelativeDateTimeValueEditor';\nimport type { RelativeDateTimeEditorConfig } from './types';\n\n/**\n * Whether a rule should use a date/time editor, based on either the coerced input\n * type (`date`/`datetime-local`) or a date-like `datatype` (`date`/`datetime`/`timestamp`).\n * Non-`value` sources (`field`/`parameter`) are excluded so they render the standard\n * field/parameter selector instead of the date UI.\n */\nconst isDateTimeEditor = (props: ValueEditorProps, inputTypeCoerced: string | undefined): boolean =>\n !isNonDateValueSource(props.valueSource) &&\n ((props.type === 'text' &&\n (inputTypeCoerced === 'date' || inputTypeCoerced === 'datetime-local')) ||\n /^(?:date|datetime|timestamp)\\b/i.test(props.fieldData?.datatype as string));\n\nconst pad2 = (n: number): string => `${n}`.padStart(2, '0');\n\n/**\n * Formats a `Date` into the local value expected by a native `date`/`datetime-local`\n * input (library-agnostic; the date library only handles parsing/validation).\n */\nconst formatDateInputValue = (d: Date, withTime: boolean): string => {\n const datePart = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;\n return withTime ? `${datePart}T${pad2(d.getHours())}:${pad2(d.getMinutes())}` : datePart;\n};\n\n/**\n * Renders the inherited (compat) editor when one is provided, otherwise the default\n * {@link react-querybuilder!ValueEditor ValueEditor}. The editor is received as a prop (rather\n * than read from context here) so the JSX element type stays prop-sourced and stable.\n */\nconst FallbackValueEditor = ({\n editor: Editor,\n ...props\n}: ValueEditorProps & {\n editor: React.ComponentType<ValueEditorProps> | null;\n}): React.JSX.Element => (Editor ? <Editor {...props} /> : <ValueEditor {...props} skipHook />);\n\nexport const DateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n const { dateTimeAPI } = useRelativeDateTimeConfig();\n\n // Non-date fields and unparseable values: delegate to the inherited (compat) editor when\n // present, otherwise the default editor.\n const fallback = (p: ValueEditorProps) => <FallbackValueEditor editor={InheritedEditor} {...p} />;\n\n if (!isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return fallback(props);\n }\n\n if (dateTimeAPI.isValid(props.value)) {\n const value = formatDateInputValue(\n dateTimeAPI.toDate(props.value),\n uVE.inputTypeCoerced !== 'date'\n );\n return fallback({ ...props, value });\n }\n\n return fallback(props);\n};\n\n/**\n * Provider value editor: renders the relative-capable {@link RelativeDateTimeValueEditor}\n * for date/time fields and falls back to the inherited (compat) editor for everything else.\n */\nconst QueryBuilderDateTimeValueEditor = (props: ValueEditorProps): React.JSX.Element => {\n const uVE = useValueEditor(props);\n const InheritedEditor = useInheritedValueEditor();\n\n if (isDateTimeEditor(props, uVE.inputTypeCoerced)) {\n return <RelativeDateTimeValueEditor {...props} />;\n }\n\n return <FallbackValueEditor editor={InheritedEditor} {...props} />;\n};\n\nexport const QueryBuilderDateTimeContext: QueryBuilderContextProvider = getCompatContextProvider({\n controlElements: { valueEditor: QueryBuilderDateTimeValueEditor },\n});\n\n/** Props for {@link QueryBuilderDateTime}: {@link RelativeDateTimeEditorConfig} plus children. */\nexport interface QueryBuilderDateTimeProps extends RelativeDateTimeEditorConfig {\n children?: React.ReactNode;\n}\n\n/**\n * Context provider enabling date/time features for a wrapped\n * {@link react-querybuilder!QueryBuilder QueryBuilder}: renders the relative-capable\n * {@link RelativeDateTimeValueEditor} for date/time fields, and accepts optional\n * {@link RelativeDateTimeEditorConfig} props (mode controller, anchor/unit options, and\n * toggle labels). With no props it provides the zero-config toggle experience.\n *\n * @group Components\n */\nexport const QueryBuilderDateTime = ({\n children,\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n}: QueryBuilderDateTimeProps): React.JSX.Element => {\n const config = useMemo(\n (): RelativeDateTimeEditorConfig => ({\n modeController,\n anchors,\n units,\n toggleLabels,\n dateTimeAPI,\n }),\n [modeController, anchors, units, toggleLabels, dateTimeAPI]\n );\n\n // Capture the value editor inherited from any outer compat provider (e.g. QueryBuilderMaterial)\n // _before_ QueryBuilderDateTimeContext overrides it, so date/time editors can delegate to it.\n const inheritedValueEditor = (useContext(QueryBuilderContext).controlElements?.valueEditor ??\n null) as React.ComponentType<ValueEditorProps> | null;\n\n return (\n <RelativeDateTimeConfigContext.Provider value={config}>\n <InheritedValueEditorContext.Provider value={inheritedValueEditor}>\n <QueryBuilderDateTimeContext>{children}</QueryBuilderDateTimeContext>\n </InheritedValueEditorContext.Provider>\n </RelativeDateTimeConfigContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,8BACX,cAA4D,IAAI;;AAGlE,MAAa,gCACX,WAAW,2BAA2B;;;;;;;ACRxC,MAAa,kCAAkC;;AAG/C,MAAa,+BAAsD;CACjE,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,MAAM;AACR;;AAGA,MAAa,iCAAuE;CAClF;EAAE,MAAM;EAAO,OAAO;EAAO,OAAO;CAAM;CAC1C;EAAE,MAAM;EAAc,OAAO;EAAc,OAAO;CAAe;CACjE;EAAE,MAAM;EAAY,OAAO;EAAY,OAAO;CAAa;CAC3D;EAAE,MAAM;EAAe,OAAO;EAAe,OAAO;CAAgB;CACpE;EAAE,MAAM;EAAa,OAAO;EAAa,OAAO;CAAc;CAC9D;EAAE,MAAM;EAAgB,OAAO;EAAgB,OAAO;CAAiB;CACvE;EAAE,MAAM;EAAc,OAAO;EAAc,OAAO;CAAe;CACjE;EAAE,MAAM;EAAe,OAAO;EAAe,OAAO;CAAgB;CACpE;EAAE,MAAM;EAAa,OAAO;EAAa,OAAO;CAAc;AAChE;;AAGA,MAAa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AiB,eAC7E;CAEF,OACE,sBAAA,cAAC,8BAA8B,UAA/B,EAAwC,OAAO,OAIP,GAHtC,sBAAA,cAAC,4BAA4B,UAA7B,EAAsC,OAAO,qBAEP,GADpC,sBAAA,cAAC,6BAAA,MAA6B,QAAsC,CAChC,CACA;AAE5C"}
|
package/dist/{rqbDateTimeLibraryAPI.jsdate-CpGoQAje.js → rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as isISOStringDateOnly } from "./objectSpread2-
|
|
1
|
+
import { r as isISOStringDateOnly } from "./objectSpread2-MqoZ2hSz.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}))?)?/;
|
|
@@ -120,4 +120,4 @@ const rqbDateTimeLibraryAPI = {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
export { rqbDateTimeLibraryAPI as t };
|
|
122
122
|
|
|
123
|
-
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-
|
|
123
|
+
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-
|
|
1
|
+
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-COp9qTw_.js","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endOf,\n add,\n};\n"],"mappings":";;AAOA,MAAM,8BAAc,IAAI,KAAK,GAAU;AAEvC,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAqB;CACnC,IAAI,aAAa,MAAM,OAAO;CAE9B,MAAM,UAAU,WAAW,KAAK,CAAC;CAEjC,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,OAAO,IAAI,IAAI,IAAI,UAAU,OAAO;CAC/D,MAAM,CAAC,MAAM,OAAO,KAAK,OAAO,SAAS,SAAS,MAAM;EAAC;EAAM;EAAI;EAAI;EAAI;EAAI;EAAI,QAAA,QAAA,QAAA,KAAA,IAAA,MAAO;CAAG,CAAC,CAC3F,OAAO,OAAO,CAAC,CACf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AI,QAAQ,YAAY,IAAI;CACpD;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/{rqbDateTimeLibraryAPI.jsdate-CDOtydFq.mjs → rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./utils-
|
|
2
|
-
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-
|
|
1
|
+
import{n as e}from"./utils-DA8aluCt.mjs";const 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(t)||e(n)?a(t)===a(n):i.getTime()===o.getTime()},isValid:i,toDate:r,toISOString:e=>{let t=r(e);return i(t)?t.toISOString():``},toISOStringDateOnly:a,startOf:(e,t)=>{let n=new Date(r(e).getTime());switch(n.setHours(0,0,0,0),t){case`week`:n.setDate(n.getDate()-n.getDay());break;case`month`:n.setDate(1);break;case`year`:n.setMonth(0,1);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}};export{o as t};
|
|
2
|
+
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-
|
|
1
|
+
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-DxBmxW2C.mjs","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endOf,\n add,\n};\n"],"mappings":"yCAOA,MAAM,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,MAAQ,CAAC,OAAO,MAAM,EAAQ,QAAQ,CAAC,CACnE,EAEM,EAAuB,GAAqB,CAChD,IAAM,EAAU,EAAO,CAAC,EACxB,OAAO,EAAQ,CAAO,EAAI,EAAQ,YAAY,CAAC,CAAC,MAAM,EAAG,EAAE,EAAI,EACjE,EAoEa,EAA+C,CAC1D,OAAQ,GAAK,EAAO,CAAC,CAAC,CAAC,YAAY,EACnC,SAAU,EAAG,IAAM,CACjB,IAAM,EAAQ,EAAO,CAAC,CAAC,CAA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AE,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"}
|
package/dist/{rqbDateTimeLibraryAPI.jsdate-D66yJ1hK.mjs → rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isISOStringDateOnly } from "./utils-
|
|
1
|
+
import { n as isISOStringDateOnly } from "./utils-BAgUBdyf.mjs";
|
|
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}))?)?/;
|
|
@@ -120,4 +120,4 @@ const rqbDateTimeLibraryAPI = {
|
|
|
120
120
|
//#endregion
|
|
121
121
|
export { rqbDateTimeLibraryAPI as t };
|
|
122
122
|
|
|
123
|
-
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-
|
|
123
|
+
//# sourceMappingURL=rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-
|
|
1
|
+
{"version":3,"file":"rqbDateTimeLibraryAPI.jsdate-WHnzblie.mjs","names":[],"sources":["../src/rqbDateTimeLibraryAPI.jsdate.ts"],"sourcesContent":["import type {\n RelativeDateTimeTruncationUnit,\n RelativeDateTimeUnit,\n RQBDateTimeLibraryAPI,\n} from './types';\nimport { isISOStringDateOnly } from './utils';\n\nconst invalidDate = new Date(Number.NaN);\n\nconst dateRegExp = /^(\\d{4})-(\\d{2})-(\\d{2})([T ](\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{1,3}))?)?/;\n\nconst toDate = (d: string | Date) => {\n if (d instanceof Date) return d;\n\n const reMatch = dateRegExp.exec(d);\n\n if (!reMatch) return invalidDate;\n\n const [_all, yyyy, mm, dd, _time, hh, mi, ss, _decimal, sss] = reMatch;\n const [year, month, day, hours, minutes, seconds, ms] = [yyyy, mm, dd, hh, mi, ss, sss ?? '0']\n .filter(Boolean)\n .map(Number);\n\n const monthIndex = month - 1;\n\n return hh\n ? new Date(Date.UTC(year, monthIndex, day, hours, minutes, seconds, ms))\n : new Date(year, monthIndex, day);\n};\n\nconst isValid = (d: string | Date) => {\n const dToDate = toDate(d);\n return dToDate instanceof Date && !Number.isNaN(dToDate.getTime());\n};\n\nconst toISOStringDateOnly = (d: string | Date) => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString().slice(0, 10) : '';\n};\n\n// Week starts on Sunday (matching Day.js/date-fns defaults).\nconst startOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(0, 0, 0, 0);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() - r.getDay());\n break;\n case 'month':\n r.setDate(1);\n break;\n case 'year':\n r.setMonth(0, 1);\n break;\n }\n return r;\n};\n\nconst endOf = (d: string | Date, unit: RelativeDateTimeTruncationUnit): Date => {\n const r = new Date(toDate(d).getTime());\n r.setHours(23, 59, 59, 999);\n switch (unit) {\n case 'week':\n r.setDate(r.getDate() + (6 - r.getDay()));\n break;\n case 'month':\n r.setMonth(r.getMonth() + 1, 0);\n break;\n case 'year':\n r.setMonth(11, 31);\n break;\n }\n return r;\n};\n\nconst add = (d: string | Date, amount: number, unit: RelativeDateTimeUnit): Date => {\n const r = new Date(toDate(d).getTime());\n switch (unit) {\n case 'minute':\n r.setMinutes(r.getMinutes() + amount);\n break;\n case 'hour':\n r.setHours(r.getHours() + amount);\n break;\n case 'day':\n r.setDate(r.getDate() + amount);\n break;\n case 'week':\n r.setDate(r.getDate() + amount * 7);\n break;\n case 'month':\n r.setMonth(r.getMonth() + amount);\n break;\n case 'year':\n r.setFullYear(r.getFullYear() + amount);\n break;\n }\n return r;\n};\n\n/**\n * {@link RQBDateTimeLibraryAPI} for JavaScript `Date`\n *\n * @deprecated This API will not be removed, but we recommend using one of the other\n * {@link RQBDateTimeLibraryAPI}s based on a popular library instead.\n */\nexport const rqbDateTimeLibraryAPI: RQBDateTimeLibraryAPI = {\n format: d => toDate(d).toISOString(),\n isAfter: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA > dateB;\n },\n isBefore: (a, b) => {\n const dateA = toDate(a).getTime();\n const dateB = toDate(b).getTime();\n return !Number.isNaN(dateA) && !Number.isNaN(dateB) && dateA < dateB;\n },\n isSame: (a, b) => {\n const aToDate = toDate(a);\n const bToDate = toDate(b);\n return isISOStringDateOnly(a) || isISOStringDateOnly(b)\n ? toISOStringDateOnly(a) === toISOStringDateOnly(b)\n : aToDate.getTime() === bToDate.getTime();\n },\n isValid,\n toDate,\n toISOString: d => {\n const dToDate = toDate(d);\n return isValid(dToDate) ? dToDate.toISOString() : '';\n },\n toISOStringDateOnly,\n startOf,\n endO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,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,QAAQ;EAChC,OAAO,CAAC,OAAO,MAAM,KAAK,KAAK,CAAC,OAAO,MAAM,KAAK,KAAK,QAAQ;CACjE;CACA,SAAS,GAAG,MAAM;EAChB,MAAM,UAAU,OAAO,CAAC;EACxB,MAAM,UAAU,OAAO,CAAC;EACxB,OAAO,oBAAoB,CAAC,KAAK,oBAAoB,CAAC,IAClD,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,IAChD,QAAQ,QAAQ,MAAM,QAAQ,QAAQ;CAC5C;CACA;CACA;CACA,cAAa,MAAK;EAChB,MAAM,UAAU,OAAO,CAAC;EACxB,OAAO,QAAQ,OAAO,IAAI,QAAQ,YAAY,IAAI;CACpD;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -1,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
|
-
|
|
81
|
-
|
|
79
|
+
* Formats a date as a string.
|
|
80
|
+
*/
|
|
82
81
|
format: (d: DateOrString, fmt: string) => string;
|
|
83
82
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
90
|
-
|
|
88
|
+
* Determines whether the first date is after the second date.
|
|
89
|
+
*/
|
|
91
90
|
isAfter: (a: DateOrString, b: DateOrString) => boolean;
|
|
92
91
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
* Determines whether the first date is before the second date.
|
|
93
|
+
*/
|
|
95
94
|
isBefore: (a: DateOrString, b: DateOrString) => boolean;
|
|
96
95
|
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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. */
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
157
|
-
|
|
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-
|
|
174
|
+
//# sourceMappingURL=types-BKA1aoY6.d.mts.map
|