@xh/hoist 87.1.0 → 87.2.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/.npmignore +39 -0
- package/CHANGELOG.md +99 -20
- package/admin/AdminUtils.ts +64 -0
- package/admin/App.scss +88 -0
- package/admin/columns/UserData.ts +30 -3
- package/admin/detail/RestDetailModel.ts +64 -0
- package/admin/detail/RestDetailPanel.ts +106 -0
- package/admin/tabs/activity/tracking/ActivityTrackingModel.ts +27 -94
- package/admin/tabs/activity/tracking/ActivityTrackingPanel.ts +23 -60
- package/admin/tabs/activity/tracking/detail/ActivityDetailView.ts +1 -2
- package/admin/tabs/general/alertBanner/AlertBannerPanel.ts +2 -13
- package/admin/tabs/general/config/ConfigDetailPanel.ts +72 -0
- package/admin/tabs/general/config/ConfigPanel.ts +41 -53
- package/admin/tabs/general/config/ConfigPanelModel.ts +3 -0
- package/admin/tabs/general/config/ConfigValue.scss +14 -0
- package/admin/tabs/general/config/ConfigValue.ts +104 -65
- package/admin/tabs/userData/jsonblob/JsonBlobDetailPanel.ts +93 -0
- package/admin/tabs/userData/jsonblob/JsonBlobModel.ts +4 -0
- package/admin/tabs/userData/jsonblob/JsonBlobPanel.ts +2 -0
- package/admin/tabs/userData/prefs/UserPreferenceDetailPanel.ts +62 -0
- package/admin/tabs/userData/prefs/UserPreferenceModel.ts +10 -3
- package/admin/tabs/userData/prefs/UserPreferencePanel.ts +3 -1
- package/admin/tabs/userData/roles/details/RoleDetails.scss +2 -19
- package/admin/tabs/userData/roles/details/RoleDetails.ts +13 -13
- package/appcontainer/AboutDialogModel.ts +1 -0
- package/appcontainer/AppContainerModel.ts +3 -0
- package/appcontainer/AppStateModel.ts +1 -0
- package/appcontainer/BannerSourceModel.ts +1 -0
- package/appcontainer/ChangelogDialogModel.ts +1 -0
- package/appcontainer/ColChooserOptionsModel.ts +1 -0
- package/appcontainer/ExceptionDialogModel.ts +1 -0
- package/appcontainer/FeedbackDialogModel.ts +1 -0
- package/appcontainer/ImpersonationBarModel.ts +1 -0
- package/appcontainer/MessageSourceModel.ts +1 -0
- package/appcontainer/OptionsDialogModel.ts +1 -0
- package/appcontainer/PageStateModel.ts +1 -0
- package/appcontainer/RouterModel.ts +2 -0
- package/appcontainer/SizingModeModel.ts +1 -0
- package/appcontainer/ThemeModel.ts +1 -0
- package/appcontainer/ToastSourceModel.ts +1 -0
- package/appcontainer/UserAgentModel.ts +1 -0
- package/appcontainer/ViewportSizeModel.ts +1 -0
- package/build/types/admin/AdminUtils.d.ts +29 -0
- package/build/types/admin/columns/UserData.d.ts +3 -0
- package/build/types/admin/detail/RestDetailModel.d.ts +20 -0
- package/build/types/admin/detail/RestDetailPanel.d.ts +34 -0
- package/build/types/admin/tabs/activity/tracking/ActivityTrackingModel.d.ts +5 -17
- package/build/types/admin/tabs/general/config/ConfigDetailPanel.d.ts +7 -0
- package/build/types/admin/tabs/general/config/ConfigValue.d.ts +10 -4
- package/build/types/admin/tabs/userData/jsonblob/JsonBlobDetailPanel.d.ts +3 -0
- package/build/types/admin/tabs/userData/prefs/UserPreferenceDetailPanel.d.ts +3 -0
- package/build/types/admin/tabs/userData/prefs/UserPreferenceModel.d.ts +3 -0
- package/build/types/appcontainer/AboutDialogModel.d.ts +1 -0
- package/build/types/appcontainer/AppContainerModel.d.ts +1 -0
- package/build/types/appcontainer/AppStateModel.d.ts +1 -0
- package/build/types/appcontainer/BannerSourceModel.d.ts +1 -0
- package/build/types/appcontainer/ChangelogDialogModel.d.ts +1 -0
- package/build/types/appcontainer/ColChooserOptionsModel.d.ts +1 -0
- package/build/types/appcontainer/ExceptionDialogModel.d.ts +1 -0
- package/build/types/appcontainer/FeedbackDialogModel.d.ts +1 -0
- package/build/types/appcontainer/ImpersonationBarModel.d.ts +1 -0
- package/build/types/appcontainer/MessageSourceModel.d.ts +1 -0
- package/build/types/appcontainer/OptionsDialogModel.d.ts +1 -0
- package/build/types/appcontainer/PageStateModel.d.ts +1 -0
- package/build/types/appcontainer/RouterModel.d.ts +1 -0
- package/build/types/appcontainer/SizingModeModel.d.ts +1 -0
- package/build/types/appcontainer/ThemeModel.d.ts +1 -0
- package/build/types/appcontainer/ToastSourceModel.d.ts +1 -0
- package/build/types/appcontainer/UserAgentModel.d.ts +1 -0
- package/build/types/appcontainer/ViewportSizeModel.d.ts +1 -0
- package/build/types/cmp/ag-grid/AgGridModel.d.ts +3 -1
- package/build/types/cmp/card/Card.d.ts +2 -2
- package/build/types/cmp/chart/ChartModel.d.ts +2 -0
- package/build/types/cmp/dataview/DataViewModel.d.ts +2 -0
- package/build/types/cmp/daterange/DateRangePickerModel.d.ts +266 -0
- package/build/types/cmp/daterange/DateRangePresets.d.ts +26 -0
- package/build/types/cmp/daterange/DateRangeUtils.d.ts +96 -0
- package/build/types/cmp/daterange/Types.d.ts +152 -0
- package/build/types/cmp/daterange/index.d.ts +4 -0
- package/build/types/cmp/filter/FilterChooserModel.d.ts +3 -1
- package/build/types/cmp/form/FormModel.d.ts +3 -1
- package/build/types/cmp/grid/GridModel.d.ts +2 -0
- package/build/types/cmp/grid/Types.d.ts +2 -0
- package/build/types/cmp/grid/filter/GridFilterModel.d.ts +1 -1
- package/build/types/cmp/grouping/GroupingChooserModel.d.ts +3 -1
- package/build/types/cmp/input/HoistInputProps.d.ts +49 -2
- package/build/types/cmp/tab/TabContainerModel.d.ts +3 -1
- package/build/types/cmp/tab/TabModel.d.ts +3 -1
- package/build/types/cmp/treemap/TreeMapModel.d.ts +2 -0
- package/build/types/cmp/viewmanager/ViewManagerModel.d.ts +2 -0
- package/build/types/cmp/zoneGrid/ZoneGridModel.d.ts +2 -0
- package/build/types/core/HoistBase.d.ts +7 -0
- package/build/types/core/HoistProps.d.ts +26 -1
- package/build/types/core/model/RootRefreshContextModel.d.ts +1 -0
- package/build/types/core/types/Telemetry.d.ts +1 -1
- package/build/types/data/Store.d.ts +3 -1
- package/build/types/data/StoreSelectionModel.d.ts +3 -1
- package/build/types/data/cube/Cube.d.ts +5 -2
- package/build/types/data/cube/View.d.ts +2 -0
- package/build/types/desktop/cmp/appOption/AutoRefreshAppOption.d.ts +3 -0
- package/build/types/desktop/cmp/appOption/ThemeAppOption.d.ts +3 -0
- package/build/types/desktop/cmp/button/Button.d.ts +2 -2
- package/build/types/desktop/cmp/button/ButtonGroup.d.ts +2 -2
- package/build/types/desktop/cmp/dash/DashConfig.d.ts +2 -0
- package/build/types/desktop/cmp/dash/DashViewModel.d.ts +3 -1
- package/build/types/desktop/cmp/dash/canvas/DashCanvasModel.d.ts +1 -1
- package/build/types/desktop/cmp/dash/container/DashContainerModel.d.ts +1 -1
- package/build/types/desktop/cmp/daterange/DateRangePicker.d.ts +66 -0
- package/build/types/desktop/cmp/daterange/impl/CustomTab.d.ts +3 -0
- package/build/types/desktop/cmp/daterange/impl/DateRangePickerLocalModel.d.ts +121 -0
- package/build/types/desktop/cmp/daterange/impl/PeriodTab.d.ts +2 -0
- package/build/types/desktop/cmp/daterange/impl/PresetsTab.d.ts +3 -0
- package/build/types/desktop/cmp/daterange/impl/RelativeTab.d.ts +3 -0
- package/build/types/desktop/cmp/daterange/impl/TabUtils.d.ts +21 -0
- package/build/types/desktop/cmp/daterange/index.d.ts +2 -0
- package/build/types/desktop/cmp/dock/DockContainerModel.d.ts +3 -1
- package/build/types/desktop/cmp/dock/DockViewModel.d.ts +3 -1
- package/build/types/desktop/cmp/grouping/GroupingChooser.d.ts +4 -1
- package/build/types/desktop/cmp/input/IntentInput.d.ts +38 -0
- package/build/types/desktop/cmp/input/NumberInput.d.ts +2 -2
- package/build/types/desktop/cmp/input/SegmentedControl.d.ts +25 -4
- package/build/types/desktop/cmp/input/TextArea.d.ts +2 -2
- package/build/types/desktop/cmp/input/TextInput.d.ts +2 -2
- package/build/types/desktop/cmp/input/index.d.ts +1 -0
- package/build/types/desktop/cmp/leftrightchooser/LeftRightChooserModel.d.ts +3 -1
- package/build/types/desktop/cmp/panel/PanelModel.d.ts +3 -1
- package/build/types/desktop/cmp/rest/RestGridModel.d.ts +1 -1
- package/build/types/desktop/cmp/tab/impl/TabContainer.d.ts +1 -1
- package/build/types/icon/Icon.d.ts +3 -0
- package/build/types/inspector/impl/InspectorUtils.d.ts +3 -0
- package/build/types/inspector/instances/InstancesModel.d.ts +4 -0
- package/build/types/kit/react-day-picker/index.d.ts +3 -3
- package/build/types/mobile/cmp/button/Button.d.ts +2 -2
- package/build/types/mobile/cmp/input/NumberInput.d.ts +2 -2
- package/build/types/mobile/cmp/input/SegmentedControl.d.ts +18 -4
- package/build/types/mobile/cmp/input/TextArea.d.ts +2 -2
- package/build/types/mobile/cmp/input/TextInput.d.ts +2 -2
- package/build/types/mobile/cmp/navigator/NavigatorModel.d.ts +3 -1
- package/build/types/mobile/cmp/navigator/PageModel.d.ts +3 -1
- package/build/types/mobile/cmp/tab/impl/TabContainer.d.ts +1 -1
- package/build/types/svc/InspectorService.d.ts +1 -0
- package/build/types/utils/js/LangUtils.d.ts +24 -5
- package/cmp/README.md +1 -0
- package/cmp/ag-grid/AgGridModel.ts +5 -0
- package/cmp/badge/Badge.ts +5 -3
- package/cmp/card/Card.ts +4 -3
- package/cmp/chart/ChartModel.ts +11 -1
- package/cmp/dataview/DataViewModel.ts +7 -1
- package/cmp/daterange/DateRangePickerModel.ts +628 -0
- package/cmp/daterange/DateRangePresets.ts +274 -0
- package/cmp/daterange/DateRangeUtils.ts +557 -0
- package/cmp/daterange/README.md +434 -0
- package/cmp/daterange/Types.ts +203 -0
- package/cmp/daterange/index.ts +10 -0
- package/cmp/filter/FilterChooserModel.ts +7 -4
- package/cmp/form/FormModel.ts +6 -0
- package/cmp/form/README.md +1 -0
- package/cmp/grid/GridModel.ts +24 -4
- package/cmp/grid/Types.ts +3 -0
- package/cmp/grid/filter/GridFilterModel.ts +3 -1
- package/cmp/grid/impl/RecordSortUtils.ts +10 -2
- package/cmp/grouping/GroupingChooserModel.ts +6 -1
- package/cmp/input/HoistInputProps.ts +50 -2
- package/cmp/input/README.md +42 -0
- package/cmp/layout/Box.ts +3 -2
- package/cmp/tab/TabContainerModel.ts +9 -1
- package/cmp/tab/TabModel.ts +5 -0
- package/cmp/treemap/SplitTreeMapModel.ts +12 -2
- package/cmp/treemap/TreeMapModel.ts +6 -1
- package/cmp/viewmanager/ViewManagerModel.ts +6 -1
- package/cmp/zoneGrid/ZoneGridModel.ts +7 -0
- package/core/HoistBase.ts +11 -0
- package/core/HoistProps.ts +27 -0
- package/core/README.md +46 -0
- package/core/impl/InstallServices.ts +5 -1
- package/core/model/RootRefreshContextModel.ts +2 -0
- package/core/types/Telemetry.ts +1 -1
- package/data/README.md +3 -1
- package/data/Store.ts +7 -0
- package/data/StoreSelectionModel.ts +5 -1
- package/data/cube/Cube.ts +12 -3
- package/data/cube/View.ts +5 -1
- package/desktop/README.md +2 -0
- package/desktop/appcontainer/LoginPanel.ts +2 -0
- package/desktop/cmp/button/Button.scss +71 -42
- package/desktop/cmp/button/Button.ts +10 -1
- package/desktop/cmp/button/ButtonGroup.ts +4 -1
- package/desktop/cmp/button/grid/ColChooserButton.ts +9 -1
- package/desktop/cmp/button/zoneGrid/ZoneMapperButton.ts +1 -0
- package/desktop/cmp/dash/DashConfig.ts +3 -0
- package/desktop/cmp/dash/DashViewModel.ts +14 -1
- package/desktop/cmp/dash/canvas/DashCanvasModel.ts +3 -1
- package/desktop/cmp/dash/container/DashContainerModel.ts +3 -1
- package/desktop/cmp/daterange/DateRangePicker.scss +577 -0
- package/desktop/cmp/daterange/DateRangePicker.ts +357 -0
- package/desktop/cmp/daterange/impl/CustomTab.ts +165 -0
- package/desktop/cmp/daterange/impl/DateRangePickerLocalModel.ts +482 -0
- package/desktop/cmp/daterange/impl/PeriodTab.ts +138 -0
- package/desktop/cmp/daterange/impl/PresetsTab.ts +58 -0
- package/desktop/cmp/daterange/impl/RelativeTab.ts +108 -0
- package/desktop/cmp/daterange/impl/TabUtils.ts +34 -0
- package/desktop/cmp/daterange/index.ts +8 -0
- package/desktop/cmp/dock/DockContainerModel.ts +6 -1
- package/desktop/cmp/dock/DockViewModel.ts +6 -1
- package/desktop/cmp/filechooser/FileChooser.ts +4 -0
- package/desktop/cmp/form/FormField.ts +1 -0
- package/desktop/cmp/grouping/GroupingChooser.ts +8 -2
- package/desktop/cmp/input/Checkbox.ts +1 -0
- package/desktop/cmp/input/CodeInput.ts +1 -0
- package/desktop/cmp/input/DateInput.scss +1 -1
- package/desktop/cmp/input/DateInput.ts +1 -0
- package/desktop/cmp/input/IntentInput.scss +202 -0
- package/desktop/cmp/input/IntentInput.ts +213 -0
- package/desktop/cmp/input/NumberInput.ts +11 -2
- package/desktop/cmp/input/Picker.ts +1 -0
- package/desktop/cmp/input/RadioInput.ts +2 -1
- package/desktop/cmp/input/SegmentedControl.scss +45 -2
- package/desktop/cmp/input/SegmentedControl.ts +66 -11
- package/desktop/cmp/input/Select.ts +9 -7
- package/desktop/cmp/input/Slider.ts +2 -0
- package/desktop/cmp/input/SwitchInput.ts +1 -0
- package/desktop/cmp/input/TextArea.ts +11 -2
- package/desktop/cmp/input/TextInput.ts +11 -2
- package/desktop/cmp/input/index.ts +1 -0
- package/desktop/cmp/leftrightchooser/LeftRightChooserModel.ts +5 -0
- package/desktop/cmp/panel/Panel.ts +8 -5
- package/desktop/cmp/panel/PanelModel.ts +8 -0
- package/desktop/cmp/panel/impl/ResizeContainer.ts +2 -1
- package/desktop/cmp/rest/RestGridModel.ts +4 -0
- package/desktop/cmp/tab/impl/TabContainer.ts +2 -0
- package/docs/README.md +2 -0
- package/docs/build-and-publish.md +23 -7
- package/docs/doc-registry.json +8 -0
- package/docs/version-compatibility.md +2 -0
- package/icon/Icon.ts +9 -0
- package/icon/index.ts +24 -0
- package/inspector/README.md +8 -2
- package/inspector/impl/InspectorUtils.ts +12 -0
- package/inspector/instances/DiagnosticsModel.ts +3 -2
- package/inspector/instances/InstancesModel.ts +81 -14
- package/inspector/instances/InstancesPanel.ts +6 -0
- package/kit/react-day-picker/index.ts +3 -3
- package/mobile/appcontainer/LoginPanel.ts +2 -0
- package/mobile/cmp/button/Button.ts +16 -3
- package/mobile/cmp/form/FormField.ts +1 -0
- package/mobile/cmp/input/Checkbox.ts +1 -0
- package/mobile/cmp/input/DateInput.ts +1 -0
- package/mobile/cmp/input/Label.ts +13 -8
- package/mobile/cmp/input/NumberInput.ts +11 -2
- package/mobile/cmp/input/SearchInput.ts +1 -0
- package/mobile/cmp/input/SegmentedControl.scss +36 -6
- package/mobile/cmp/input/SegmentedControl.ts +37 -11
- package/mobile/cmp/input/Select.ts +2 -0
- package/mobile/cmp/input/SwitchInput.ts +1 -0
- package/mobile/cmp/input/TextArea.ts +11 -2
- package/mobile/cmp/input/TextInput.ts +11 -2
- package/mobile/cmp/navigator/NavigatorModel.ts +6 -1
- package/mobile/cmp/navigator/PageModel.ts +6 -1
- package/mobile/cmp/tab/impl/TabContainer.ts +9 -1
- package/package.json +19 -19
- package/styles/vars.scss +32 -2
- package/svc/InspectorService.ts +2 -0
- package/svc/TraceService.ts +5 -2
- package/utils/js/LangUtils.ts +37 -5
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { HoistModel, type PersistOptions } from '@xh/hoist/core';
|
|
2
|
+
import type { FieldFilterSpec } from '@xh/hoist/data';
|
|
3
|
+
import { LocalDate } from '@xh/hoist/utils/datetime';
|
|
4
|
+
import type { DateRangeAnchorDay, DateRangeContext, DateRangeFormat, DateRangePickerTab, DateRangePreset, DateRangePresetToken, DateRangeSelection, LocalDateRange, ResolvedDateRange } from './Types';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for a {@link DateRangePickerModel} - a control for selecting a period of time
|
|
7
|
+
* as a preset, relative lookback, calendar month or year, or custom range of dates.
|
|
8
|
+
*/
|
|
9
|
+
export interface DateRangePickerConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The day that relative and to-date selections resolve against, and (unless `maxDate` is set)
|
|
12
|
+
* the latest selectable date. Default `'localDay'` - the current day in the browser's time
|
|
13
|
+
* zone, kept current as the day rolls. See {@link DateRangeAnchorDay} for the app-day, pinned,
|
|
14
|
+
* and computed alternatives.
|
|
15
|
+
*/
|
|
16
|
+
anchorDay?: DateRangeAnchorDay;
|
|
17
|
+
/**
|
|
18
|
+
* True to treat single days by business day: a live `anchorDay` (`'localDay'` or `'appDay'`)
|
|
19
|
+
* snaps back to the most recent business day, and single-day selections step by business day
|
|
20
|
+
* rather than calendar day. Multi-day ranges are unaffected - seven days is still seven days.
|
|
21
|
+
* A pinned or computed `anchorDay` is honored verbatim, never snapped. Default false.
|
|
22
|
+
*/
|
|
23
|
+
businessDayMode?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* False (default) waits for the user to apply a relative or custom draft before updating the
|
|
26
|
+
* value. True commits those drafts as they change, and applies a tab's current draft as soon
|
|
27
|
+
* as the tab is activated, so the popover never shows a period other than the applied one. The
|
|
28
|
+
* Apply and Cancel buttons are omitted. Preset and month/year picks commit on click either way.
|
|
29
|
+
* Overridable app-wide via `DateRangePickerModel.defaults`.
|
|
30
|
+
*/
|
|
31
|
+
commitOnChange?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Format for the dates of a range - the two ends shown on the trigger, beside presets, and in
|
|
34
|
+
* `rangeLabel`. A moment.js format string, or a function of the date. Default `YYYY-MM-DD`,
|
|
35
|
+
* overridable app-wide via `DateRangePickerModel.defaults`. The Custom tab's date inputs use
|
|
36
|
+
* it when it is a string, else `YYYY-MM-DD`.
|
|
37
|
+
*/
|
|
38
|
+
dateFormat?: DateRangeFormat;
|
|
39
|
+
/**
|
|
40
|
+
* Format for a single day - a one-day range, and the anchor date in the popover footer -
|
|
41
|
+
* where the weekday matters more than the year. A moment.js format string, or a function of
|
|
42
|
+
* the date. Default `ddd MMM D`, overridable app-wide via `DateRangePickerModel.defaults`.
|
|
43
|
+
*/
|
|
44
|
+
singleDayFormat?: DateRangeFormat;
|
|
45
|
+
/**
|
|
46
|
+
* Name of the field to filter in the {@link FieldFilterSpec}s produced by
|
|
47
|
+
* {@link DateRangePickerModel.currentRangeFilter} and `priorRangeFilter`. Required to read
|
|
48
|
+
* those properties.
|
|
49
|
+
*/
|
|
50
|
+
filterField?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Initial value, and the fallback when a persisted value is missing or fails validation.
|
|
53
|
+
* Accepts a preset token string as shorthand for a preset selection. Default: the first
|
|
54
|
+
* configured preset, or a rolling 30 days if no presets are configured.
|
|
55
|
+
*/
|
|
56
|
+
initialValue?: DateRangeSelection | DateRangePresetToken | string;
|
|
57
|
+
/**
|
|
58
|
+
* Test for whether a date is a business day, consulted by `businessDayMode` and available to
|
|
59
|
+
* app-defined presets via {@link DateRangeContext}. Default: weekdays. Supply to honor a
|
|
60
|
+
* holiday calendar.
|
|
61
|
+
*/
|
|
62
|
+
isBusinessDay?: (date: LocalDate) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Latest selectable date. Default: the anchor date, so nothing beyond it can be selected. Set
|
|
65
|
+
* later than the anchor to allow selection of future dates.
|
|
66
|
+
*/
|
|
67
|
+
maxDate?: LocalDate;
|
|
68
|
+
/** Earliest selectable date. Default: none. */
|
|
69
|
+
minDate?: LocalDate;
|
|
70
|
+
/**
|
|
71
|
+
* Options governing persistence. The value persists under a `dateRangePicker.value` path by
|
|
72
|
+
* default - set `path` to disambiguate multiple pickers sharing one provider.
|
|
73
|
+
*/
|
|
74
|
+
persistWith?: DateRangePickerPersistOptions;
|
|
75
|
+
/**
|
|
76
|
+
* Presets offered on the Presets tab, in display order - tokens of Hoist's built-in
|
|
77
|
+
* {@link dateRangePresets}, app-defined {@link DateRangePreset} objects, or a mix.
|
|
78
|
+
* Default: {@link DEFAULT_DATE_RANGE_PRESETS}.
|
|
79
|
+
*/
|
|
80
|
+
presets?: Array<DateRangePresetToken | DateRangePreset>;
|
|
81
|
+
/**
|
|
82
|
+
* Tabs to offer within the picker popover, in display order. Default: all tabs, less the
|
|
83
|
+
* Presets tab when `presets` is empty. A single tab renders without a rail.
|
|
84
|
+
*/
|
|
85
|
+
tabs?: DateRangePickerTab[];
|
|
86
|
+
/** See {@link HoistBase.xhName}. */
|
|
87
|
+
xhName?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface DateRangePickerPersistOptions extends PersistOptions {
|
|
90
|
+
/** True (default) to persist the value, or provide value-specific PersistOptions. */
|
|
91
|
+
persistValue?: boolean | PersistOptions;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* App-wide overridable defaults for {@link DateRangePickerModel}. Instance config takes precedence.
|
|
95
|
+
*/
|
|
96
|
+
export interface DateRangePickerModelDefaults {
|
|
97
|
+
anchorDay?: DateRangeAnchorDay;
|
|
98
|
+
businessDayMode?: boolean;
|
|
99
|
+
commitOnChange?: boolean;
|
|
100
|
+
dateFormat?: DateRangeFormat;
|
|
101
|
+
singleDayFormat?: DateRangeFormat;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Model for a control that allows users to select a period of time - a preset (e.g. MTD, Prev
|
|
105
|
+
* 30 Days), a relative lookback (e.g. Prev 6 Months), a calendar month or year, or a custom
|
|
106
|
+
* range of dates - and the API through which an app reads the applied period.
|
|
107
|
+
*
|
|
108
|
+
* The value is a single compound {@link DateRangeSelection}, which this model resolves to a
|
|
109
|
+
* concrete {@link LocalDateRange} anchored to `anchorDate`, alongside the comparable prior range.
|
|
110
|
+
* The value is plain JSON, so it persists via `persistWith` (including through saved views)
|
|
111
|
+
* without custom serialization, and re-resolves as the anchor date moves forward - a persisted
|
|
112
|
+
* `mtd` stays month-to-date.
|
|
113
|
+
*
|
|
114
|
+
* The anchor date is live by default: this model keeps it on the current day as midnight passes,
|
|
115
|
+
* so every derived range, label, and filter follows without app intervention. See `anchorDay`.
|
|
116
|
+
*
|
|
117
|
+
* Construct one within an app model and render a {@link DateRangePicker} bound to it to let users
|
|
118
|
+
* view and change the value. The value and its derived ranges and filters stay live whether or
|
|
119
|
+
* not a picker is mounted - a locked dashboard widget, for example, can hide its picker but still
|
|
120
|
+
* query by period.
|
|
121
|
+
*
|
|
122
|
+
* @see DateRangePicker
|
|
123
|
+
* @see dateRangePresets
|
|
124
|
+
*/
|
|
125
|
+
export declare class DateRangePickerModel extends HoistModel {
|
|
126
|
+
/** App-level defaults for DateRangePickerModel. Instance config takes precedence. */
|
|
127
|
+
static defaults: DateRangePickerModelDefaults;
|
|
128
|
+
/** The applied selection, always in normalized form. Set via `setValue()`. */
|
|
129
|
+
value: DateRangeSelection;
|
|
130
|
+
/** Tabs offered in the popover, in display order. Set via `setTabs()` - the picker follows. */
|
|
131
|
+
tabs: DateRangePickerTab[];
|
|
132
|
+
/** Presets offered on the Presets tab, in display order. Set via `setPresets()`. */
|
|
133
|
+
presets: DateRangePreset[];
|
|
134
|
+
/** How the anchor date is determined - see {@link DateRangeAnchorDay}. Set via `setAnchorDay()`. */
|
|
135
|
+
anchorDay: DateRangeAnchorDay;
|
|
136
|
+
/**
|
|
137
|
+
* Date that relative and to-date selections resolve against - `anchorDay` resolved, and (in
|
|
138
|
+
* `businessDayMode`) snapped to a business day when live. Kept current by this model.
|
|
139
|
+
*/
|
|
140
|
+
anchorDate: LocalDate;
|
|
141
|
+
/** The current day in the browser's time zone - the reader's "today". Kept current. */
|
|
142
|
+
today: LocalDate;
|
|
143
|
+
/** Earliest selectable date, or null if unbounded. Set via `setMinDate()`. */
|
|
144
|
+
minDate: LocalDate | null;
|
|
145
|
+
/** Business-day test used by `businessDayMode` and presets. Set via `setIsBusinessDay()`. */
|
|
146
|
+
isBusinessDay: (date: LocalDate) => boolean;
|
|
147
|
+
businessDayMode: boolean;
|
|
148
|
+
commitOnChange: boolean;
|
|
149
|
+
dateFormat: DateRangeFormat;
|
|
150
|
+
singleDayFormat: DateRangeFormat;
|
|
151
|
+
filterField: string;
|
|
152
|
+
/** The initial value, and the fallback for a missing or invalid persisted value. */
|
|
153
|
+
readonly defaultValue: DateRangeSelection;
|
|
154
|
+
private explicitMaxDate;
|
|
155
|
+
private anchorTimer;
|
|
156
|
+
/** Latest selectable date - the explicit `maxDate` config if set, otherwise `anchorDate`. */
|
|
157
|
+
get maxDate(): LocalDate;
|
|
158
|
+
/**
|
|
159
|
+
* True if the anchor date is the reader's current day - when `anchorDay` reads "Today". False
|
|
160
|
+
* for any other day, however the anchor got there (pinned, business-day snapped, or an app
|
|
161
|
+
* time zone a day apart from the browser's) - the picker then reads "As Of" with the date.
|
|
162
|
+
*/
|
|
163
|
+
get isAnchorToday(): boolean;
|
|
164
|
+
/** Configured presets, keyed by token. */
|
|
165
|
+
get presetMap(): Record<string, DateRangePreset>;
|
|
166
|
+
/** The live context that selections resolve against. */
|
|
167
|
+
get context(): DateRangeContext;
|
|
168
|
+
/** Resolved date range for the applied value. */
|
|
169
|
+
get currentRange(): LocalDateRange;
|
|
170
|
+
/**
|
|
171
|
+
* The immediately preceding, non-overlapping range of comparable shape - the same span one
|
|
172
|
+
* unit earlier for a period-to-date, `count` units earlier for a lookback in weeks or larger
|
|
173
|
+
* units, an equal number of days for day-based windows. Null when the current range is
|
|
174
|
+
* unbounded.
|
|
175
|
+
*/
|
|
176
|
+
get priorRange(): LocalDateRange | null;
|
|
177
|
+
/** Short label for the applied value - e.g. `MTD`, `Prev 6 Months`, `Aug 2026`, `Custom`. */
|
|
178
|
+
get label(): string;
|
|
179
|
+
/**
|
|
180
|
+
* Resolved range as `start ▸ end` per `dateFormat`, with `…` for an unbounded edge. A single
|
|
181
|
+
* day reads as that one date, per `singleDayFormat`.
|
|
182
|
+
*/
|
|
183
|
+
get rangeLabel(): string;
|
|
184
|
+
/**
|
|
185
|
+
* Longer-form name for the applied value, suitable for panel titles - the period's name
|
|
186
|
+
* rather than its dates, with months spelled out (e.g. `August 2026`). A custom range, and the
|
|
187
|
+
* anchor day when it is not today, have no name beyond their dates, so they read as those.
|
|
188
|
+
*/
|
|
189
|
+
get displayName(): string;
|
|
190
|
+
/**
|
|
191
|
+
* True when `label` alone does not identify the period - a custom range, or the anchor day
|
|
192
|
+
* when it is not today and so reads only as `As Of`. The picker shows the dates instead.
|
|
193
|
+
*/
|
|
194
|
+
get labelNeedsDates(): boolean;
|
|
195
|
+
/** True if `stepRange(-1)` would move the applied range - bounded and not yet at `minDate`. */
|
|
196
|
+
get canStepBack(): boolean;
|
|
197
|
+
/** True if `stepRange(1)` would move the applied range - bounded, and not yet at `maxDate`. */
|
|
198
|
+
get canStepForward(): boolean;
|
|
199
|
+
/** Filters for `currentRange` on `filterField`, ready to apply to a Store, View, or query. */
|
|
200
|
+
get currentRangeFilter(): FieldFilterSpec[];
|
|
201
|
+
/** Filters for `priorRange` on `filterField`. Empty when there is no prior range. */
|
|
202
|
+
get priorRangeFilter(): FieldFilterSpec[];
|
|
203
|
+
constructor({ tabs, presets, initialValue, anchorDay, businessDayMode, commitOnChange, minDate, maxDate, isBusinessDay, filterField, dateFormat, singleDayFormat, persistWith, xhName }?: DateRangePickerConfig);
|
|
204
|
+
/**
|
|
205
|
+
* Set the applied value. Accepts a preset token string as shorthand for a preset selection.
|
|
206
|
+
* An invalid value (unknown preset, out-of-bounds count or year, malformed date) is logged
|
|
207
|
+
* and ignored.
|
|
208
|
+
*/
|
|
209
|
+
setValue(value: DateRangeSelection | DateRangePresetToken | string): void;
|
|
210
|
+
setTabs(tabs: DateRangePickerTab[]): void;
|
|
211
|
+
setPresets(presets: Array<DateRangePresetToken | DateRangePreset>): void;
|
|
212
|
+
/** Set how the anchor date is determined - see {@link DateRangeAnchorDay}. */
|
|
213
|
+
setAnchorDay(anchorDay: DateRangeAnchorDay): void;
|
|
214
|
+
setMinDate(minDate: LocalDate | null): void;
|
|
215
|
+
/** Set the latest selectable date, or null to revert to `anchorDate`. */
|
|
216
|
+
setMaxDate(maxDate: LocalDate | null): void;
|
|
217
|
+
setIsBusinessDay(isBusinessDay: (date: LocalDate) => boolean): void;
|
|
218
|
+
/**
|
|
219
|
+
* Move the applied range by `steps` periods - e.g. `stepRange(-1)` for the previous period.
|
|
220
|
+
* No selection changes kind: presets and relative lookbacks step through their own prior- and
|
|
221
|
+
* next-range logic via `offset`, months and years by calendar unit, and custom ranges by their
|
|
222
|
+
* length. Stops at `minDate` and `maxDate`, and a no-op when the range cannot move - see
|
|
223
|
+
* {@link stepDateRangeSelection}.
|
|
224
|
+
*/
|
|
225
|
+
stepRange(steps: number): void;
|
|
226
|
+
/** The selection `stepRange(steps)` would apply, or null if the range cannot move that way. */
|
|
227
|
+
getSteppedValue(steps: number): DateRangeSelection | null;
|
|
228
|
+
/**
|
|
229
|
+
* Validate and normalize a raw value against this model's presets. Returns null for anything
|
|
230
|
+
* unrecognized - see {@link parseDateRangeSelection}.
|
|
231
|
+
*/
|
|
232
|
+
parseValue(raw: unknown): DateRangeSelection | null;
|
|
233
|
+
validateValue(raw: unknown): boolean;
|
|
234
|
+
/** Resolve any selection against this model's current context. */
|
|
235
|
+
resolve(sel: DateRangeSelection): ResolvedDateRange;
|
|
236
|
+
/** Short label for any selection, as it would read on the picker trigger. */
|
|
237
|
+
getLabel(sel: DateRangeSelection): string;
|
|
238
|
+
/**
|
|
239
|
+
* Filters bounding `field` to the given range - a `>=` filter for a bounded start and a `<=`
|
|
240
|
+
* filter for a bounded end, so an unbounded range produces no filters at all.
|
|
241
|
+
*/
|
|
242
|
+
getRangeFilter(range: LocalDateRange, field?: string): FieldFilterSpec[];
|
|
243
|
+
/** Format a range as `start ▸ end` per this model's `dateFormat` - a single day per `singleDayFormat`. */
|
|
244
|
+
fmtRange(range: LocalDateRange): string;
|
|
245
|
+
/** Format a single day per this model's `singleDayFormat`. */
|
|
246
|
+
fmtSingleDay(date: LocalDate): string;
|
|
247
|
+
private get resolvedValue();
|
|
248
|
+
/** True unless `anchorDay` is a pinned LocalDate. */
|
|
249
|
+
private get isLiveAnchor();
|
|
250
|
+
/**
|
|
251
|
+
* Re-evaluate `today` and `anchorDate` from `anchorDay`. Assignments are identity no-ops until
|
|
252
|
+
* the day actually changes, as LocalDate instances are memoized.
|
|
253
|
+
*/
|
|
254
|
+
private refreshAnchorDate;
|
|
255
|
+
private initPersist;
|
|
256
|
+
/**
|
|
257
|
+
* Persisted state can be missing (a saved view with no value) or stale (a preset since
|
|
258
|
+
* removed) - either way, fall back to the default rather than carrying a prior value over.
|
|
259
|
+
*/
|
|
260
|
+
private restoreValue;
|
|
261
|
+
/**
|
|
262
|
+
* `defaultValue` while it still resolves, else the first configured preset, else a rolling 30
|
|
263
|
+
* days - `defaultValue` can itself name a preset that `setPresets()` has since removed.
|
|
264
|
+
*/
|
|
265
|
+
private get fallbackValue();
|
|
266
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DateRangePreset, DateRangePresetToken } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Presets shipped with Hoist, keyed by token. Offer any subset (in any order) via the `presets`
|
|
4
|
+
* config of {@link DateRangePickerModel}, alongside any app-defined {@link DateRangePreset}s.
|
|
5
|
+
*
|
|
6
|
+
* Labels describe a range without claiming it ends today, since the anchor date need not be
|
|
7
|
+
* today: `Prev 7 Days` rather than `Last 7 Days`. The one exception is `anchorDay`, which reads
|
|
8
|
+
* `Today` when the anchor date is the current day and `As Of` otherwise - the trigger's dates
|
|
9
|
+
* supply the day itself.
|
|
10
|
+
*
|
|
11
|
+
* Period-to-date presets (`wtd`, `mtd`, `qtd`, `ytd`) resolve their prior range as the same span
|
|
12
|
+
* one unit earlier - e.g. MTD on the 12th compares against the 1st through 12th of the prior
|
|
13
|
+
* month. Previous-unit presets (`prevWeek`, `prevMonth`, ...) compare against the unit before.
|
|
14
|
+
* Rolling windows compare against the window of equal length immediately preceding them. The
|
|
15
|
+
* same logic, mirrored by `resolveNext`, drives stepping: `mtd` stepped back once is the prior MTD.
|
|
16
|
+
*
|
|
17
|
+
* A preset that names a specific period reads the same as a pick of that period on the Months &
|
|
18
|
+
* Years tab - `prevMonth` labels as e.g. `Aug 2026` and `prevYear` as `2025` - so the trigger
|
|
19
|
+
* describes the period, whichever way it was chosen. The underlying values stay distinct: a preset
|
|
20
|
+
* re-resolves against the anchor date as time passes, where a pinned month or year does not.
|
|
21
|
+
*/
|
|
22
|
+
export declare const dateRangePresets: Record<DateRangePresetToken, DateRangePreset>;
|
|
23
|
+
/** Tokens of the presets shipped with Hoist, in a sensible display order. */
|
|
24
|
+
export declare const DATE_RANGE_PRESET_TOKENS: DateRangePresetToken[];
|
|
25
|
+
/** Presets offered by {@link DateRangePickerModel} when none are configured. */
|
|
26
|
+
export declare const DEFAULT_DATE_RANGE_PRESETS: DateRangePresetToken[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { LocalDate } from '@xh/hoist/utils/datetime';
|
|
2
|
+
import type { DateRangeContext, DateRangeFormat, DateRangePickerTab, DateRangePreset, DateRangeSelection, DateRangeUnit, LocalDateRange, ResolvedDateRange } from './Types';
|
|
3
|
+
/** All picker tabs, in their default display order. */
|
|
4
|
+
export declare const DATE_RANGE_PICKER_TABS: DateRangePickerTab[];
|
|
5
|
+
/** Units offered on the Relative tab's unit control, in display order. */
|
|
6
|
+
export declare const DATE_RANGE_UNITS: DateRangeUnit[];
|
|
7
|
+
/** Largest `count` accepted for a relative selection. */
|
|
8
|
+
export declare const MAX_RELATIVE_COUNT = 999;
|
|
9
|
+
/** Furthest a preset or relative selection can be stepped from its natural range, either way. */
|
|
10
|
+
export declare const MAX_STEP_OFFSET = 9999;
|
|
11
|
+
/** Year bounds for month and year selections - shared by validation and picker navigation. */
|
|
12
|
+
export declare const MIN_SELECTION_YEAR = 1900;
|
|
13
|
+
export declare const MAX_SELECTION_YEAR = 9999;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a selection to its current range, and to the comparable range immediately before it.
|
|
16
|
+
* Throws if the selection is a preset unknown to the context - validate with
|
|
17
|
+
* {@link parseDateRangeSelection} first for untrusted input.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveDateRange(sel: DateRangeSelection, ctx: DateRangeContext): ResolvedDateRange;
|
|
20
|
+
/** A range of the one given day. */
|
|
21
|
+
export declare function singleDay(day: LocalDate): LocalDateRange;
|
|
22
|
+
/**
|
|
23
|
+
* The nearest business day strictly before `date`, per the context's `isBusinessDay`. Bounded, to
|
|
24
|
+
* guard against a test that never returns true.
|
|
25
|
+
*/
|
|
26
|
+
export declare function previousBusinessDay(date: LocalDate, ctx: BusinessDayContext): LocalDate;
|
|
27
|
+
/** The nearest business day strictly after `date`, per the context's `isBusinessDay`. Bounded. */
|
|
28
|
+
export declare function nextBusinessDay(date: LocalDate, ctx: BusinessDayContext): LocalDate;
|
|
29
|
+
/** `date` itself if it is a business day, else the nearest business day before it. */
|
|
30
|
+
export declare function businessDayOnOrBefore(date: LocalDate, ctx: BusinessDayContext): LocalDate;
|
|
31
|
+
type BusinessDayContext = Pick<DateRangeContext, 'isBusinessDay'>;
|
|
32
|
+
/**
|
|
33
|
+
* The day before `date` - the previous business day in `businessDayMode`, else the previous
|
|
34
|
+
* calendar day. The step taken by single-day presets and their prior ranges.
|
|
35
|
+
*/
|
|
36
|
+
export declare function previousDayInMode(date: LocalDate, ctx: DateRangeContext): LocalDate;
|
|
37
|
+
/** The day after `date` - the next business day in `businessDayMode`, else the next calendar day. */
|
|
38
|
+
export declare function nextDayInMode(date: LocalDate, ctx: DateRangeContext): LocalDate;
|
|
39
|
+
/**
|
|
40
|
+
* Validate and normalize a raw (e.g. persisted or app-supplied) value into a
|
|
41
|
+
* {@link DateRangeSelection}. Accepts a bare preset token string as shorthand for a preset
|
|
42
|
+
* selection. Returns null for anything unrecognized, out of bounds, or naming a preset not in
|
|
43
|
+
* `presets` - callers should substitute their default.
|
|
44
|
+
*/
|
|
45
|
+
export declare function parseDateRangeSelection(raw: unknown, presets: Record<string, DateRangePreset>): DateRangeSelection | null;
|
|
46
|
+
/**
|
|
47
|
+
* Short label for a selection, suitable for the picker trigger - e.g. `MTD`, `Prev 6 Months`,
|
|
48
|
+
* `Aug 2026`, `2025`, or `Custom`.
|
|
49
|
+
*
|
|
50
|
+
* Month and year picks read as the period they name - `Sep 2026`, `2026` - even when clamped to
|
|
51
|
+
* the anchor date, with the trigger's dates showing the clamp. `MTD` and `YTD` are reserved for
|
|
52
|
+
* the presets, which are live and step to the same partial span a unit earlier, where a pinned
|
|
53
|
+
* month or year steps by whole units. The `prevMonth` and `prevYear` presets read as the period
|
|
54
|
+
* too, since they resolve to a full one.
|
|
55
|
+
*
|
|
56
|
+
* Once stepped to a non-zero offset, the trigger's dates locate the range and the label describes
|
|
57
|
+
* only its shape: a rolling window reads as its length (`7 Days`, `3 Months`), a named period as
|
|
58
|
+
* the period (`Jul 2026`), and a to-date preset as its name with the signed offset (`MTD −1`,
|
|
59
|
+
* `MTD +1`).
|
|
60
|
+
*/
|
|
61
|
+
export declare function getDateRangeLabel(sel: DateRangeSelection, ctx: DateRangeContext): string;
|
|
62
|
+
/** Display name for a preset's row within the picker - its `name`, falling back to its `label`. */
|
|
63
|
+
export declare function getDateRangePresetName(preset: DateRangePreset, ctx: DateRangeContext): string;
|
|
64
|
+
/** A signed offset as `−n` or `+n`, with a true minus sign - the default suffix for a stepped label. */
|
|
65
|
+
export declare function fmtDateRangeOffset(offset: number): string;
|
|
66
|
+
/** Title-case unit label, singular when count is 1 - e.g. `Days`, `Month`. */
|
|
67
|
+
export declare function getDateRangeUnitLabel(unit: DateRangeUnit, count?: number): string;
|
|
68
|
+
/** Format a date per a {@link DateRangeFormat} - a moment.js format string or a function. */
|
|
69
|
+
export declare function fmtDate(date: LocalDate, format: DateRangeFormat): string;
|
|
70
|
+
/**
|
|
71
|
+
* Format a range as `start ▸ end` per `dateFormat`, with `…` for an unbounded edge. A single-day
|
|
72
|
+
* range formats as that one date per `singleDayFormat`, which defaults to `dateFormat`. Returns an empty
|
|
73
|
+
* string for a null range.
|
|
74
|
+
*/
|
|
75
|
+
export declare function fmtDateRange(range: LocalDateRange, dateFormat?: DateRangeFormat, singleDayFormat?: DateRangeFormat): string;
|
|
76
|
+
/** First day of the given month (1-12) of the given year. */
|
|
77
|
+
export declare function getMonthStart(year: number, month: number): LocalDate;
|
|
78
|
+
/** First day of the given quarter (1-4) of the given year. */
|
|
79
|
+
export declare function getQuarterStart(year: number, quarter: number): LocalDate;
|
|
80
|
+
/**
|
|
81
|
+
* Move a selection by `steps` periods - negative to go back, positive to go forward. No selection
|
|
82
|
+
* changes kind:
|
|
83
|
+
*
|
|
84
|
+
* - Preset and relative selections adjust their `offset`, stepping through their own prior- and
|
|
85
|
+
* next-range logic - so a lookback in months steps by months, and a single day steps by
|
|
86
|
+
* business day in `businessDayMode`. Their natural range ends on the anchor date, so a positive
|
|
87
|
+
* offset is reachable only when `maxDate` allows dates beyond it.
|
|
88
|
+
* - Month, quarter and year selections step by calendar unit.
|
|
89
|
+
* - Custom selections step by their length in days - or by business day when a single day in
|
|
90
|
+
* `businessDayMode`.
|
|
91
|
+
*
|
|
92
|
+
* Steps stop at the context's `minDate` and `maxDate`. Returns null when the selection cannot
|
|
93
|
+
* move that way: it is already at a bound, or unbounded.
|
|
94
|
+
*/
|
|
95
|
+
export declare function stepDateRangeSelection(sel: DateRangeSelection, steps: number, ctx: DateRangeContext): DateRangeSelection | null;
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { LocalDate } from '@xh/hoist/utils/datetime';
|
|
2
|
+
/** An inclusive range of days. A null edge is unbounded. */
|
|
3
|
+
export interface LocalDateRange {
|
|
4
|
+
start: LocalDate | null;
|
|
5
|
+
end: LocalDate | null;
|
|
6
|
+
}
|
|
7
|
+
/** A selection resolved to its current range and the comparable range immediately before it. */
|
|
8
|
+
export interface ResolvedDateRange {
|
|
9
|
+
current: LocalDateRange;
|
|
10
|
+
/** The immediately preceding, non-overlapping range of comparable shape, or null if none. */
|
|
11
|
+
prior: LocalDateRange | null;
|
|
12
|
+
}
|
|
13
|
+
/** Calendar units supported by relative selections. */
|
|
14
|
+
export type DateRangeUnit = 'days' | 'weeks' | 'months' | 'quarters' | 'years';
|
|
15
|
+
/**
|
|
16
|
+
* How the picker renders a date - a moment.js format string, or a function for formats that
|
|
17
|
+
* depend on the date itself, e.g. one that adds the year only when it is not the current year.
|
|
18
|
+
*/
|
|
19
|
+
export type DateRangeFormat = string | ((date: LocalDate) => string);
|
|
20
|
+
/** Tabs available within the DateRangePicker popover. */
|
|
21
|
+
export type DateRangePickerTab = 'presets' | 'relative' | 'period' | 'custom';
|
|
22
|
+
/**
|
|
23
|
+
* The day that relative and to-date selections resolve against - see the `anchorDay` config of
|
|
24
|
+
* {@link DateRangePickerModel}.
|
|
25
|
+
*
|
|
26
|
+
* - `'localDay'` - the current day in the browser's time zone, kept current as the day rolls.
|
|
27
|
+
* - `'appDay'` - the current day in the app's time zone (`LocalDate.currentAppDay()`), likewise.
|
|
28
|
+
* - A `LocalDate` - a pinned day that never moves, honored verbatim.
|
|
29
|
+
* - A function returning a `LocalDate` - re-evaluated every few seconds and whenever any
|
|
30
|
+
* observables it reads change. Must be pure and cheap. For as-of dates with their own rule, e.g.
|
|
31
|
+
* the latest loaded data date, or a day that rolls forward at an evening cutoff.
|
|
32
|
+
*/
|
|
33
|
+
export type DateRangeAnchorDay = 'localDay' | 'appDay' | LocalDate | (() => LocalDate);
|
|
34
|
+
/** Tokens for the presets shipped with Hoist - see {@link dateRangePresets}. */
|
|
35
|
+
export type DateRangePresetToken = 'anchorDay' | 'prevDay' | 'wtd' | 'mtd' | 'qtd' | 'ytd' | 'prev7Days' | 'prev30Days' | 'prev90Days' | 'prev3Months' | 'prev6Months' | 'prev12Months' | 'prevWeek' | 'prevMonth' | 'prevQuarter' | 'prevYear' | 'all';
|
|
36
|
+
/**
|
|
37
|
+
* The dates a selection resolves against - the live state of a {@link DateRangePickerModel}.
|
|
38
|
+
* Passed to preset resolvers and to the resolution utilities in this package.
|
|
39
|
+
*/
|
|
40
|
+
export interface DateRangeContext {
|
|
41
|
+
/** Date that relative and to-date selections resolve against. */
|
|
42
|
+
anchorDate: LocalDate;
|
|
43
|
+
/**
|
|
44
|
+
* The current day in the browser's time zone - what "Today" means to the person looking at
|
|
45
|
+
* the screen, whatever zone the anchor date is drawn from.
|
|
46
|
+
*/
|
|
47
|
+
today: LocalDate;
|
|
48
|
+
/** Earliest selectable date, or null if unbounded. */
|
|
49
|
+
minDate: LocalDate | null;
|
|
50
|
+
/** Latest selectable date. Month, quarter and year selections spanning it are clamped to it. */
|
|
51
|
+
maxDate: LocalDate;
|
|
52
|
+
/** Whether a date is a business day - weekdays by default, or the model's `isBusinessDay`. */
|
|
53
|
+
isBusinessDay: (date: LocalDate) => boolean;
|
|
54
|
+
/** True if single-day selections step by business day - see the model config of that name. */
|
|
55
|
+
businessDayMode: boolean;
|
|
56
|
+
/** Presets available for selection, keyed by token. */
|
|
57
|
+
presets: Record<string, DateRangePreset>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A named, one-click range offered on the picker's Presets tab. Hoist ships a set of common
|
|
61
|
+
* presets ({@link dateRangePresets}) - apps can offer a subset of those, add their own, or both
|
|
62
|
+
* via the `presets` config of {@link DateRangePickerModel}.
|
|
63
|
+
*/
|
|
64
|
+
export interface DateRangePreset {
|
|
65
|
+
/** Unique key for this preset. Persisted as the `token` of a `preset` selection. */
|
|
66
|
+
token: string;
|
|
67
|
+
/** Short label for the picker trigger, e.g. `MTD`. May be derived from the context. */
|
|
68
|
+
label: string | ((ctx: DateRangeContext) => string);
|
|
69
|
+
/** Longer name for the preset's row in the picker, e.g. `Month to Date`. Default `label`. */
|
|
70
|
+
name?: string | ((ctx: DateRangeContext) => string);
|
|
71
|
+
/** Resolve this preset to a concrete range. */
|
|
72
|
+
resolve: (ctx: DateRangeContext) => LocalDateRange;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve the comparable prior range for a given current range. Default is the immediately
|
|
75
|
+
* preceding range of equal duration in days, or null when the current range is unbounded.
|
|
76
|
+
* Also drives stepping back: a selection at `offset` -n is this applied n times.
|
|
77
|
+
*/
|
|
78
|
+
resolvePrior?: (current: LocalDateRange, ctx: DateRangeContext) => LocalDateRange | null;
|
|
79
|
+
/**
|
|
80
|
+
* Resolve the comparable range immediately after a given current range - the mirror of
|
|
81
|
+
* `resolvePrior`, driving stepping forward when `maxDate` allows dates beyond the anchor.
|
|
82
|
+
* Default is the immediately following range of equal duration in days, or null when the
|
|
83
|
+
* current range is unbounded.
|
|
84
|
+
*/
|
|
85
|
+
resolveNext?: (current: LocalDateRange, ctx: DateRangeContext) => LocalDateRange | null;
|
|
86
|
+
/**
|
|
87
|
+
* Label for this preset once stepped to a non-zero `offset`, when the trigger's dates locate
|
|
88
|
+
* the range and the label need only describe its shape - e.g. `7 Days` for a rolling window,
|
|
89
|
+
* or the month itself for a previous-month preset. Default is the label with the signed
|
|
90
|
+
* offset appended, e.g. `MTD −1`.
|
|
91
|
+
*/
|
|
92
|
+
shiftedLabel?: (range: LocalDateRange, offset: number, ctx: DateRangeContext) => string;
|
|
93
|
+
}
|
|
94
|
+
/** A one-click preset, re-resolved against the anchor date as time passes. */
|
|
95
|
+
export interface PresetDateRangeSelection {
|
|
96
|
+
kind: 'preset';
|
|
97
|
+
/** Token of a preset configured on the owning model. */
|
|
98
|
+
token: string;
|
|
99
|
+
/**
|
|
100
|
+
* Number of periods stepped from the preset's natural range - negative for earlier periods,
|
|
101
|
+
* each applying the preset's prior-range logic once, positive for later ones (reachable only
|
|
102
|
+
* when `maxDate` allows dates beyond the anchor). Omitted when zero. See `stepRange()`.
|
|
103
|
+
*/
|
|
104
|
+
offset?: number;
|
|
105
|
+
}
|
|
106
|
+
/** A lookback of `count` units ending on the anchor date. */
|
|
107
|
+
export interface RelativeDateRangeSelection {
|
|
108
|
+
kind: 'relative';
|
|
109
|
+
/** Number of units, from 1 to {@link MAX_RELATIVE_COUNT}. */
|
|
110
|
+
count: number;
|
|
111
|
+
unit: DateRangeUnit;
|
|
112
|
+
/**
|
|
113
|
+
* True to snap the window to calendar boundaries of `unit`, counting the current (partial)
|
|
114
|
+
* unit as one - e.g. 3 calendar months ending today covers the prior two full months plus
|
|
115
|
+
* the current month to date. False (default) for a rolling window of exactly `count` units
|
|
116
|
+
* ending on the anchor date. Has no effect for days, where each day is its own boundary.
|
|
117
|
+
*/
|
|
118
|
+
snap?: boolean;
|
|
119
|
+
/** Periods stepped from the natural window - negative back, positive forward. Omitted when zero. */
|
|
120
|
+
offset?: number;
|
|
121
|
+
}
|
|
122
|
+
/** A calendar month, clamped to the context's `maxDate` when that date falls within it. */
|
|
123
|
+
export interface MonthDateRangeSelection {
|
|
124
|
+
kind: 'month';
|
|
125
|
+
year: number;
|
|
126
|
+
/** Month of the year, 1-12. */
|
|
127
|
+
month: number;
|
|
128
|
+
}
|
|
129
|
+
/** A calendar quarter, clamped to the context's `maxDate` when that date falls within it. */
|
|
130
|
+
export interface QuarterDateRangeSelection {
|
|
131
|
+
kind: 'quarter';
|
|
132
|
+
year: number;
|
|
133
|
+
/** Quarter of the year, 1-4. */
|
|
134
|
+
quarter: number;
|
|
135
|
+
}
|
|
136
|
+
/** A calendar year, clamped to the context's `maxDate` when that date falls within it. */
|
|
137
|
+
export interface YearDateRangeSelection {
|
|
138
|
+
kind: 'year';
|
|
139
|
+
year: number;
|
|
140
|
+
}
|
|
141
|
+
/** A fixed range of specific dates, as `YYYY-MM-DD` strings so the value persists as plain JSON. */
|
|
142
|
+
export interface CustomDateRangeSelection {
|
|
143
|
+
kind: 'custom';
|
|
144
|
+
start: string;
|
|
145
|
+
end: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The value of a {@link DateRangePickerModel} - a user's period selection, resolved to concrete
|
|
149
|
+
* dates against a {@link DateRangeContext}. Plain JSON in all its forms, so it round-trips through
|
|
150
|
+
* persistence without custom serialization.
|
|
151
|
+
*/
|
|
152
|
+
export type DateRangeSelection = PresetDateRangeSelection | RelativeDateRangeSelection | MonthDateRangeSelection | QuarterDateRangeSelection | YearDateRangeSelection | CustomDateRangeSelection;
|
|
@@ -73,6 +73,8 @@ export interface FilterChooserConfig {
|
|
|
73
73
|
introHelpText?: ReactNode;
|
|
74
74
|
/** Options governing persistence. */
|
|
75
75
|
persistWith?: FilterChooserPersistOptions;
|
|
76
|
+
/** See {@link HoistBase.xhName}. */
|
|
77
|
+
xhName?: string;
|
|
76
78
|
}
|
|
77
79
|
/**
|
|
78
80
|
* Model for a Select-based filter control that allows users to search for and compose filters
|
|
@@ -113,7 +115,7 @@ export declare class FilterChooserModel extends HoistModel {
|
|
|
113
115
|
unsupportedFilter: boolean;
|
|
114
116
|
inputRef: import("react").RefObject<HTMLElement> & import("react").RefCallback<HTMLElement>;
|
|
115
117
|
get tagCount(): number;
|
|
116
|
-
constructor({ fieldSpecs, fieldSpecDefaults, bind, valueSource, initialValue, initialFavorites, suggestFieldsWhenEmpty, sortFieldSuggestions, maxTags, maxResults, persistWith, introHelpText }?: FilterChooserConfig);
|
|
118
|
+
constructor({ fieldSpecs, fieldSpecDefaults, bind, valueSource, initialValue, initialFavorites, suggestFieldsWhenEmpty, sortFieldSuggestions, maxTags, maxResults, persistWith, introHelpText, xhName }?: FilterChooserConfig);
|
|
117
119
|
/**
|
|
118
120
|
* Set the value displayed by this control.
|
|
119
121
|
*
|
|
@@ -20,6 +20,8 @@ export interface FormConfig {
|
|
|
20
20
|
persistWith?: FormPersistOptions;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
readonly?: boolean;
|
|
23
|
+
/** See {@link HoistBase.xhName}. */
|
|
24
|
+
xhName?: string;
|
|
23
25
|
/** @internal */
|
|
24
26
|
xhImpl?: boolean;
|
|
25
27
|
}
|
|
@@ -81,7 +83,7 @@ export declare class FormModel extends HoistModel {
|
|
|
81
83
|
* See {@link getData} instead if you need to get or react to the values of *any/all* fields.
|
|
82
84
|
*/
|
|
83
85
|
get values(): PlainObject;
|
|
84
|
-
constructor({ fields, initialValues, disabled, persistWith, readonly, xhImpl }?: FormConfig);
|
|
86
|
+
constructor({ fields, initialValues, disabled, persistWith, readonly, xhName, xhImpl }?: FormConfig);
|
|
85
87
|
getField(fieldName: string): BaseFieldModel;
|
|
86
88
|
/**
|
|
87
89
|
* Snapshot of current field values, keyed by field name.
|
|
@@ -224,6 +224,8 @@ export interface GridConfig {
|
|
|
224
224
|
experimental?: GridExperimentalFlags;
|
|
225
225
|
/** Extra app-specific data for the GridModel. */
|
|
226
226
|
appData?: PlainObject;
|
|
227
|
+
/** See {@link HoistBase.xhName}. */
|
|
228
|
+
xhName?: string;
|
|
227
229
|
/** @internal */
|
|
228
230
|
xhImpl?: boolean;
|
|
229
231
|
}
|
|
@@ -120,6 +120,8 @@ export interface GridFilterModelConfig {
|
|
|
120
120
|
* Defaults to `Icon.filter()` (the standard funnel icon in regular/outline style).
|
|
121
121
|
*/
|
|
122
122
|
activeFilterIcon?: ReactElement;
|
|
123
|
+
/** See {@link HoistBase.xhName}. */
|
|
124
|
+
xhName?: string;
|
|
123
125
|
}
|
|
124
126
|
/**
|
|
125
127
|
* {@link GridFilterModel} currently accepts a single `bind` target that also provides available
|
|
@@ -22,7 +22,7 @@ export declare class GridFilterModel extends HoistModel {
|
|
|
22
22
|
get filter(): Filter;
|
|
23
23
|
dialogOpen: boolean;
|
|
24
24
|
static BLANK_PLACEHOLDER: string;
|
|
25
|
-
constructor({ bind, commitOnChange, fieldSpecs, fieldSpecDefaults, activeFilterIcon }: GridFilterModelConfig, gridModel: GridModel);
|
|
25
|
+
constructor({ bind, commitOnChange, fieldSpecs, fieldSpecDefaults, activeFilterIcon, xhName }: GridFilterModelConfig, gridModel: GridModel);
|
|
26
26
|
/**
|
|
27
27
|
* Set / replace the filters for a given field.
|
|
28
28
|
* @param field - field to identify this filter
|
|
@@ -51,6 +51,8 @@ export interface GroupingChooserConfig {
|
|
|
51
51
|
* provided in the `dimensions` config.
|
|
52
52
|
*/
|
|
53
53
|
sortDimensions?: boolean;
|
|
54
|
+
/** See {@link HoistBase.xhName}. */
|
|
55
|
+
xhName?: string;
|
|
54
56
|
}
|
|
55
57
|
export interface GroupingChooserModelDefaults {
|
|
56
58
|
commitOnChange?: boolean;
|
|
@@ -104,7 +106,7 @@ export declare class GroupingChooserModel extends HoistModel {
|
|
|
104
106
|
dimensionNames: string[];
|
|
105
107
|
get dimensionSpecs(): DimensionSpec[];
|
|
106
108
|
get valueDisplayNames(): string[];
|
|
107
|
-
constructor({ allowEmpty, bind, commitOnChange, dimensions, initialFavorites, initialValue, maxDepth, persistWith, sortDimensions }: GroupingChooserConfig);
|
|
109
|
+
constructor({ allowEmpty, bind, commitOnChange, dimensions, initialFavorites, initialValue, maxDepth, persistWith, sortDimensions, xhName }: GroupingChooserConfig);
|
|
108
110
|
setDimensions(dimensions: Array<DimensionSpec | string>): void;
|
|
109
111
|
setValue(value: string[]): void;
|
|
110
112
|
validateValue(value: string[]): boolean;
|