@shipfox/react-ui 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/components/dashboard/context/dashboard-context.d.ts +12 -8
  2. package/dist/components/dashboard/context/dashboard-context.js +42 -7
  3. package/dist/components/dashboard/context/index.d.ts +2 -2
  4. package/dist/components/dashboard/context/index.js +1 -1
  5. package/dist/components/dashboard/context/types.d.ts +9 -7
  6. package/dist/components/dashboard/index.d.ts +2 -4
  7. package/dist/components/dashboard/index.js +1 -2
  8. package/dist/components/dashboard/pages/analytics-page.js +2 -9
  9. package/dist/components/dashboard/pages/jobs-page.js +2 -4
  10. package/dist/components/dashboard/toolbar/filter-button.d.ts +6 -10
  11. package/dist/components/dashboard/toolbar/filter-button.js +109 -76
  12. package/dist/components/dashboard/toolbar/page-toolbar.d.ts +7 -19
  13. package/dist/components/dashboard/toolbar/page-toolbar.js +11 -99
  14. package/dist/components/dashboard/toolbar/toolbar-actions.js +3 -3
  15. package/dist/components/index.d.ts +1 -0
  16. package/dist/components/index.js +1 -0
  17. package/dist/components/interval-selector/hooks/index.d.ts +4 -0
  18. package/dist/components/interval-selector/hooks/index.js +5 -0
  19. package/dist/components/interval-selector/hooks/use-interval-selector-input.d.ts +30 -0
  20. package/dist/components/interval-selector/hooks/use-interval-selector-input.js +125 -0
  21. package/dist/components/interval-selector/hooks/use-interval-selector-navigation.d.ts +21 -0
  22. package/dist/components/interval-selector/hooks/use-interval-selector-navigation.js +58 -0
  23. package/dist/components/interval-selector/hooks/use-interval-selector.d.ts +25 -0
  24. package/dist/components/interval-selector/hooks/use-interval-selector.js +75 -0
  25. package/dist/components/interval-selector/index.d.ts +3 -0
  26. package/dist/components/interval-selector/index.js +4 -0
  27. package/dist/components/interval-selector/interval-selector-calendar.d.ts +7 -0
  28. package/dist/components/interval-selector/interval-selector-calendar.js +47 -0
  29. package/dist/components/interval-selector/interval-selector-input.d.ts +8 -0
  30. package/dist/components/interval-selector/interval-selector-input.js +34 -0
  31. package/dist/components/interval-selector/interval-selector-suggestions.d.ts +11 -0
  32. package/dist/components/interval-selector/interval-selector-suggestions.js +107 -0
  33. package/dist/components/interval-selector/interval-selector.d.ts +12 -0
  34. package/dist/components/interval-selector/interval-selector.js +56 -0
  35. package/dist/components/interval-selector/interval-selector.stories.js +232 -0
  36. package/dist/components/interval-selector/types.d.ts +19 -0
  37. package/dist/components/interval-selector/types.js +3 -0
  38. package/dist/components/interval-selector/utils/constants.d.ts +24 -0
  39. package/dist/components/interval-selector/utils/constants.js +129 -0
  40. package/dist/components/interval-selector/utils/format.d.ts +16 -0
  41. package/dist/components/interval-selector/utils/format.js +23 -0
  42. package/dist/components/interval-selector/utils/index.d.ts +3 -0
  43. package/dist/components/interval-selector/utils/index.js +4 -0
  44. package/dist/components/popover/popover.d.ts +3 -1
  45. package/dist/components/popover/popover.js +2 -1
  46. package/dist/styles.css +1 -1
  47. package/dist/utils/date.js +130 -22
  48. package/dist/utils/format/date.d.ts +1 -0
  49. package/dist/utils/format/date.js +11 -4
  50. package/package.json +3 -2
  51. package/dist/components/dashboard/filters/expression-filter-bar.d.ts +0 -42
  52. package/dist/components/dashboard/filters/expression-filter-bar.js +0 -80
  53. package/dist/components/dashboard/filters/index.d.ts +0 -6
  54. package/dist/components/dashboard/filters/index.js +0 -5
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from '../../components/button/index.js';
3
+ import { Icon } from '../../components/icon/index.js';
4
+ import { Kbd } from '../../components/kbd/index.js';
5
+ import { Label } from '../../components/label/index.js';
6
+ import { useEffect, useRef } from 'react';
7
+ import { cn } from '../../utils/cn.js';
8
+ import { generateDurationShortcut, humanizeDurationToNow } from '../../utils/date.js';
9
+ export function IntervalSelectorSuggestions({ relativeSuggestions, intervalSuggestions, onSelect, onOpenCalendar, highlightedIndex }) {
10
+ const pastIntervalsStartIndex = 0;
11
+ const calendarIntervalsStartIndex = relativeSuggestions.length;
12
+ const calendarButtonIndex = calendarIntervalsStartIndex + intervalSuggestions.length;
13
+ const itemRefs = useRef([]);
14
+ useEffect(()=>{
15
+ if (highlightedIndex >= 0 && itemRefs.current[highlightedIndex]) {
16
+ itemRefs.current[highlightedIndex]?.scrollIntoView({
17
+ behavior: 'smooth',
18
+ block: 'nearest'
19
+ });
20
+ }
21
+ }, [
22
+ highlightedIndex
23
+ ]);
24
+ return /*#__PURE__*/ _jsxs("div", {
25
+ className: "flex flex-col gap-8",
26
+ children: [
27
+ /*#__PURE__*/ _jsx("div", {
28
+ className: "flex flex-col gap-4 p-4",
29
+ children: relativeSuggestions.map((option, index)=>{
30
+ const itemIndex = pastIntervalsStartIndex + index;
31
+ const isHighlighted = highlightedIndex === itemIndex;
32
+ const shortcut = generateDurationShortcut(option.duration);
33
+ const label = humanizeDurationToNow(option.duration);
34
+ return /*#__PURE__*/ _jsxs(Button, {
35
+ ref: (el)=>{
36
+ itemRefs.current[itemIndex] = el;
37
+ },
38
+ type: "button",
39
+ variant: "transparent",
40
+ onClick: ()=>onSelect(option),
41
+ className: cn('w-full text-foreground-neutral-subtle justify-start', isHighlighted && 'bg-background-button-transparent-hover'),
42
+ children: [
43
+ /*#__PURE__*/ _jsx(Kbd, {
44
+ className: "h-16 shrink-0 min-w-36",
45
+ children: shortcut
46
+ }),
47
+ /*#__PURE__*/ _jsx("span", {
48
+ children: label
49
+ })
50
+ ]
51
+ }, shortcut);
52
+ })
53
+ }),
54
+ /*#__PURE__*/ _jsxs("div", {
55
+ className: "border-t border-border-neutral-base-component flex flex-col gap-4 p-4",
56
+ children: [
57
+ /*#__PURE__*/ _jsx(Label, {
58
+ className: "px-8 py-4 text-xs leading-20 text-foreground-neutral-subtle select-none",
59
+ children: "Calendar Time"
60
+ }),
61
+ /*#__PURE__*/ _jsx("div", {
62
+ className: "grid grid-cols-1 md:grid-cols-2 gap-4 [&>*:only-child]:md:col-span-2",
63
+ children: intervalSuggestions.map((option, index)=>{
64
+ const itemIndex = calendarIntervalsStartIndex + index;
65
+ const isHighlighted = highlightedIndex === itemIndex;
66
+ return /*#__PURE__*/ _jsx(Button, {
67
+ ref: (el)=>{
68
+ itemRefs.current[itemIndex] = el;
69
+ },
70
+ type: "button",
71
+ variant: "transparent",
72
+ onClick: ()=>onSelect(option),
73
+ className: cn('w-full text-foreground-neutral-subtle justify-start', isHighlighted && 'bg-background-button-transparent-hover'),
74
+ children: /*#__PURE__*/ _jsx("span", {
75
+ children: option.label
76
+ })
77
+ }, option.label);
78
+ })
79
+ })
80
+ ]
81
+ }),
82
+ /*#__PURE__*/ _jsx("div", {
83
+ className: "border-t border-border-neutral-base-component p-4",
84
+ children: /*#__PURE__*/ _jsxs(Button, {
85
+ ref: (el)=>{
86
+ itemRefs.current[calendarButtonIndex] = el;
87
+ },
88
+ type: "button",
89
+ variant: "transparent",
90
+ onClick: onOpenCalendar,
91
+ className: cn('w-full text-foreground-neutral-subtle justify-start', highlightedIndex === calendarButtonIndex && 'bg-background-button-transparent-hover'),
92
+ children: [
93
+ /*#__PURE__*/ _jsx(Icon, {
94
+ name: "calendar2Line",
95
+ className: "size-16 shrink-0"
96
+ }),
97
+ /*#__PURE__*/ _jsx("span", {
98
+ children: "Select from calendar"
99
+ })
100
+ ]
101
+ })
102
+ })
103
+ ]
104
+ });
105
+ }
106
+
107
+ //# sourceMappingURL=interval-selector-suggestions.js.map
@@ -0,0 +1,12 @@
1
+ import type { IntervalSelection, IntervalSuggestion, RelativeSuggestion } from './types';
2
+ export interface IntervalSelectorProps {
3
+ selection: IntervalSelection;
4
+ onSelectionChange: (selection: IntervalSelection) => void;
5
+ container?: HTMLElement | null;
6
+ className?: string;
7
+ inputClassName?: string;
8
+ relativeSuggestions?: RelativeSuggestion[];
9
+ intervalSuggestions?: IntervalSuggestion[];
10
+ }
11
+ export declare function IntervalSelector({ selection, onSelectionChange, container, className, inputClassName, relativeSuggestions, intervalSuggestions, }: IntervalSelectorProps): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=interval-selector.d.ts.map
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Popover, PopoverContent } from '../../components/popover/index.js';
3
+ import { useIntervalSelector } from './hooks/use-interval-selector.js';
4
+ import { IntervalSelectorCalendar } from './interval-selector-calendar.js';
5
+ import { IntervalSelectorInput } from './interval-selector-input.js';
6
+ import { IntervalSelectorSuggestions } from './interval-selector-suggestions.js';
7
+ import { defaultIntervalSuggestions, defaultRelativeSuggestions } from './utils/index.js';
8
+ export function IntervalSelector({ selection, onSelectionChange, container, className, inputClassName, relativeSuggestions = defaultRelativeSuggestions, intervalSuggestions = defaultIntervalSuggestions }) {
9
+ const { onSelect, popoverOpen, calendarOpen, highlightedIndex, inputRef, isNavigating, isFocused, setIsFocused, onBlur, onFocus, onKeyDown, onChange, onOpenCalendar, closeAll, onInteractOutside } = useIntervalSelector({
10
+ onSelectionChange,
11
+ relativeSuggestions,
12
+ intervalSuggestions
13
+ });
14
+ return /*#__PURE__*/ _jsxs(Popover, {
15
+ open: popoverOpen,
16
+ children: [
17
+ /*#__PURE__*/ _jsx(IntervalSelectorInput, {
18
+ onSelect: onSelect,
19
+ selection: selection,
20
+ isNavigating: isNavigating,
21
+ className: className,
22
+ inputClassName: inputClassName,
23
+ onChange: onChange,
24
+ onKeyDown: onKeyDown,
25
+ onFocus: onFocus,
26
+ onBlur: onBlur,
27
+ inputRef: inputRef,
28
+ isFocused: isFocused,
29
+ setIsFocused: setIsFocused
30
+ }),
31
+ /*#__PURE__*/ _jsx(PopoverContent, {
32
+ align: "start",
33
+ sideOffset: 8,
34
+ className: "w-(--radix-popover-trigger-width) p-0",
35
+ onOpenAutoFocus: (e)=>e.preventDefault(),
36
+ onInteractOutside: onInteractOutside,
37
+ onEscapeKeyDown: (e)=>{
38
+ e.preventDefault();
39
+ closeAll();
40
+ },
41
+ container: container,
42
+ children: calendarOpen ? /*#__PURE__*/ _jsx(IntervalSelectorCalendar, {
43
+ onSelect: onSelect
44
+ }) : popoverOpen ? /*#__PURE__*/ _jsx(IntervalSelectorSuggestions, {
45
+ relativeSuggestions: relativeSuggestions,
46
+ intervalSuggestions: intervalSuggestions,
47
+ onSelect: onSelect,
48
+ onOpenCalendar: onOpenCalendar,
49
+ highlightedIndex: highlightedIndex
50
+ }) : null
51
+ })
52
+ ]
53
+ });
54
+ }
55
+
56
+ //# sourceMappingURL=interval-selector.js.map
@@ -0,0 +1,232 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { endOfDay, startOfDay } from 'date-fns';
3
+ import { useState } from 'react';
4
+ import { IntervalSelector } from './interval-selector.js';
5
+ const meta = {
6
+ title: 'Components/IntervalSelector',
7
+ component: IntervalSelector,
8
+ tags: [
9
+ 'autodocs'
10
+ ],
11
+ parameters: {
12
+ layout: 'centered'
13
+ }
14
+ };
15
+ export default meta;
16
+ function RelativeIntervalSelector() {
17
+ const [selection, setSelection] = useState({
18
+ type: 'relative',
19
+ duration: {
20
+ days: 1
21
+ }
22
+ });
23
+ return /*#__PURE__*/ _jsxs("div", {
24
+ className: "space-y-8",
25
+ children: [
26
+ /*#__PURE__*/ _jsxs("div", {
27
+ className: "text-sm text-foreground-neutral-subtle",
28
+ children: [
29
+ /*#__PURE__*/ _jsx("strong", {
30
+ children: "Relative Mode:"
31
+ }),
32
+ ' Duration-based selection (e.g., "Past 1 Day"). The interval updates automatically based on the current time.'
33
+ ]
34
+ }),
35
+ /*#__PURE__*/ _jsx(IntervalSelector, {
36
+ selection: selection,
37
+ onSelectionChange: setSelection,
38
+ className: "w-[75vw] md:w-350"
39
+ }),
40
+ /*#__PURE__*/ _jsxs("div", {
41
+ className: "text-xs text-foreground-neutral-muted font-mono",
42
+ children: [
43
+ "Selection: ",
44
+ JSON.stringify(selection, null, 2)
45
+ ]
46
+ })
47
+ ]
48
+ });
49
+ }
50
+ function AbsoluteIntervalSelector() {
51
+ const now = new Date();
52
+ const [selection, setSelection] = useState({
53
+ type: 'interval',
54
+ interval: {
55
+ start: new Date(now.getFullYear(), 0, 1),
56
+ end: new Date(now.getFullYear(), 0, 15)
57
+ }
58
+ });
59
+ return /*#__PURE__*/ _jsxs("div", {
60
+ className: "space-y-8",
61
+ children: [
62
+ /*#__PURE__*/ _jsxs("div", {
63
+ className: "text-sm text-foreground-neutral-subtle",
64
+ children: [
65
+ /*#__PURE__*/ _jsx("strong", {
66
+ children: "Absolute Mode:"
67
+ }),
68
+ ' Fixed date range selection (e.g., "Jan 1 - Jan 15"). The interval stays the same regardless of when you refresh the page.'
69
+ ]
70
+ }),
71
+ /*#__PURE__*/ _jsx(IntervalSelector, {
72
+ selection: selection,
73
+ onSelectionChange: setSelection,
74
+ className: "w-[75vw] md:w-350"
75
+ }),
76
+ /*#__PURE__*/ _jsxs("div", {
77
+ className: "text-xs text-foreground-neutral-muted font-mono",
78
+ children: [
79
+ "Selection: ",
80
+ JSON.stringify(selection, null, 2)
81
+ ]
82
+ })
83
+ ]
84
+ });
85
+ }
86
+ export const Relative = {
87
+ args: {
88
+ selection: {
89
+ type: 'relative',
90
+ duration: {
91
+ days: 1
92
+ }
93
+ },
94
+ onSelectionChange: ()=>undefined
95
+ },
96
+ render: ()=>/*#__PURE__*/ _jsx("div", {
97
+ className: "w-screen h-screen p-16",
98
+ children: /*#__PURE__*/ _jsx(RelativeIntervalSelector, {})
99
+ })
100
+ };
101
+ export const Absolute = {
102
+ args: {
103
+ selection: (()=>{
104
+ const now = new Date();
105
+ return {
106
+ type: 'interval',
107
+ interval: {
108
+ start: new Date(now.getFullYear(), 0, 1),
109
+ end: new Date(now.getFullYear(), 0, 15)
110
+ }
111
+ };
112
+ })(),
113
+ onSelectionChange: ()=>undefined
114
+ },
115
+ render: ()=>/*#__PURE__*/ _jsx("div", {
116
+ className: "w-screen h-screen p-16",
117
+ children: /*#__PURE__*/ _jsx(AbsoluteIntervalSelector, {})
118
+ })
119
+ };
120
+ function CustomIntervalsSelector() {
121
+ const [selection, setSelection] = useState({
122
+ type: 'relative',
123
+ duration: {
124
+ hours: 1
125
+ }
126
+ });
127
+ const customRelativeSuggestions = [
128
+ {
129
+ duration: {
130
+ minutes: 15
131
+ },
132
+ type: 'relative'
133
+ },
134
+ {
135
+ duration: {
136
+ hours: 1
137
+ },
138
+ type: 'relative'
139
+ },
140
+ {
141
+ duration: {
142
+ hours: 6
143
+ },
144
+ type: 'relative'
145
+ },
146
+ {
147
+ duration: {
148
+ hours: 24
149
+ },
150
+ type: 'relative'
151
+ },
152
+ {
153
+ duration: {
154
+ days: 3
155
+ },
156
+ type: 'relative'
157
+ },
158
+ {
159
+ duration: {
160
+ weeks: 1
161
+ },
162
+ type: 'relative'
163
+ },
164
+ {
165
+ duration: {
166
+ weeks: 2
167
+ },
168
+ type: 'relative'
169
+ },
170
+ {
171
+ duration: {
172
+ months: 1
173
+ },
174
+ type: 'relative'
175
+ }
176
+ ];
177
+ const customIntervalSuggestions = [
178
+ {
179
+ type: 'interval',
180
+ label: "During Einstein's lifetime",
181
+ interval: {
182
+ start: startOfDay(new Date('1879-03-14')),
183
+ end: endOfDay(new Date('1955-04-18'))
184
+ }
185
+ }
186
+ ];
187
+ return /*#__PURE__*/ _jsxs("div", {
188
+ className: "space-y-8",
189
+ children: [
190
+ /*#__PURE__*/ _jsxs("div", {
191
+ className: "text-sm text-foreground-neutral-subtle",
192
+ children: [
193
+ /*#__PURE__*/ _jsx("strong", {
194
+ children: "Custom Intervals:"
195
+ }),
196
+ " This is useful for internationalization, branding, or context-specific options."
197
+ ]
198
+ }),
199
+ /*#__PURE__*/ _jsx(IntervalSelector, {
200
+ selection: selection,
201
+ onSelectionChange: setSelection,
202
+ relativeSuggestions: customRelativeSuggestions,
203
+ intervalSuggestions: customIntervalSuggestions,
204
+ className: "w-[75vw] md:w-350"
205
+ }),
206
+ /*#__PURE__*/ _jsxs("div", {
207
+ className: "text-xs text-foreground-neutral-muted font-mono",
208
+ children: [
209
+ "Selection: ",
210
+ JSON.stringify(selection, null, 2)
211
+ ]
212
+ })
213
+ ]
214
+ });
215
+ }
216
+ export const CustomIntervals = {
217
+ args: {
218
+ selection: {
219
+ type: 'relative',
220
+ duration: {
221
+ hours: 1
222
+ }
223
+ },
224
+ onSelectionChange: ()=>undefined
225
+ },
226
+ render: ()=>/*#__PURE__*/ _jsx("div", {
227
+ className: "w-screen h-screen p-16",
228
+ children: /*#__PURE__*/ _jsx(CustomIntervalsSelector, {})
229
+ })
230
+ };
231
+
232
+ //# sourceMappingURL=interval-selector.stories.js.map
@@ -0,0 +1,19 @@
1
+ import type { Duration, NormalizedInterval } from 'date-fns';
2
+ export type IntervalSelection = {
3
+ type: 'relative';
4
+ duration: Duration;
5
+ } | {
6
+ type: 'interval';
7
+ interval: NormalizedInterval;
8
+ };
9
+ export interface RelativeSuggestion {
10
+ type: 'relative';
11
+ duration: Duration;
12
+ }
13
+ export interface IntervalSuggestion {
14
+ label: string;
15
+ type: 'interval';
16
+ interval: NormalizedInterval;
17
+ }
18
+ export type Suggestion = RelativeSuggestion | IntervalSuggestion;
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,24 @@
1
+ import { type Duration, type NormalizedInterval } from 'date-fns';
2
+ export interface RelativeSuggestion {
3
+ type: 'relative';
4
+ duration: Duration;
5
+ }
6
+ export interface IntervalSuggestion {
7
+ label: string;
8
+ type: 'interval';
9
+ interval: NormalizedInterval;
10
+ }
11
+ export type Suggestion = RelativeSuggestion | IntervalSuggestion;
12
+ export interface ParsedShortcut {
13
+ shortcut: string;
14
+ duration: Duration;
15
+ label: string;
16
+ }
17
+ export interface CalendarShortcutResult {
18
+ shortcut: string | undefined;
19
+ label: string;
20
+ value: string | undefined;
21
+ }
22
+ export declare const defaultRelativeSuggestions: RelativeSuggestion[];
23
+ export declare const defaultIntervalSuggestions: IntervalSuggestion[];
24
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,129 @@
1
+ import { endOfDay, endOfMonth, endOfWeek, endOfYear, startOfDay, startOfMonth, startOfWeek, startOfYear, subDays, subMonths, subWeeks, subYears } from 'date-fns';
2
+ export const defaultRelativeSuggestions = [
3
+ {
4
+ duration: {
5
+ minutes: 5
6
+ },
7
+ type: 'relative'
8
+ },
9
+ {
10
+ duration: {
11
+ minutes: 15
12
+ },
13
+ type: 'relative'
14
+ },
15
+ {
16
+ duration: {
17
+ minutes: 30
18
+ },
19
+ type: 'relative'
20
+ },
21
+ {
22
+ duration: {
23
+ hours: 1
24
+ },
25
+ type: 'relative'
26
+ },
27
+ {
28
+ duration: {
29
+ hours: 4
30
+ },
31
+ type: 'relative'
32
+ },
33
+ {
34
+ duration: {
35
+ days: 1
36
+ },
37
+ type: 'relative'
38
+ },
39
+ {
40
+ duration: {
41
+ days: 2
42
+ },
43
+ type: 'relative'
44
+ },
45
+ {
46
+ duration: {
47
+ weeks: 1
48
+ },
49
+ type: 'relative'
50
+ },
51
+ {
52
+ duration: {
53
+ months: 1
54
+ },
55
+ type: 'relative'
56
+ }
57
+ ];
58
+ const WEEK_OPTIONS = {
59
+ weekStartsOn: 1
60
+ };
61
+ const now = new Date();
62
+ export const defaultIntervalSuggestions = [
63
+ {
64
+ label: 'Today',
65
+ type: 'interval',
66
+ interval: {
67
+ start: startOfDay(now),
68
+ end: endOfDay(now)
69
+ }
70
+ },
71
+ {
72
+ label: 'Yesterday',
73
+ type: 'interval',
74
+ interval: {
75
+ start: startOfDay(subDays(now, 1)),
76
+ end: endOfDay(subDays(now, 1))
77
+ }
78
+ },
79
+ {
80
+ label: 'Week to Date',
81
+ type: 'interval',
82
+ interval: {
83
+ start: startOfWeek(now, WEEK_OPTIONS),
84
+ end: endOfDay(now)
85
+ }
86
+ },
87
+ {
88
+ label: 'Previous Week',
89
+ type: 'interval',
90
+ interval: {
91
+ start: startOfWeek(subWeeks(now, 1), WEEK_OPTIONS),
92
+ end: endOfWeek(subWeeks(now, 1), WEEK_OPTIONS)
93
+ }
94
+ },
95
+ {
96
+ label: 'Month to Date',
97
+ type: 'interval',
98
+ interval: {
99
+ start: startOfMonth(now),
100
+ end: endOfDay(now)
101
+ }
102
+ },
103
+ {
104
+ label: 'Previous Month',
105
+ type: 'interval',
106
+ interval: {
107
+ start: startOfMonth(subMonths(now, 1)),
108
+ end: endOfMonth(subMonths(now, 1))
109
+ }
110
+ },
111
+ {
112
+ label: 'Year to Date',
113
+ type: 'interval',
114
+ interval: {
115
+ start: startOfYear(now),
116
+ end: endOfDay(now)
117
+ }
118
+ },
119
+ {
120
+ label: 'Previous Year',
121
+ type: 'interval',
122
+ interval: {
123
+ start: startOfYear(subYears(now, 1)),
124
+ end: endOfYear(subYears(now, 1))
125
+ }
126
+ }
127
+ ];
128
+
129
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1,16 @@
1
+ import type { IntervalSelection } from '../types';
2
+ export declare function formatSelectionForInput(selection: IntervalSelection): string;
3
+ interface FormatSelectionParams {
4
+ selection: IntervalSelection;
5
+ inputValue: string;
6
+ isFocused: boolean;
7
+ }
8
+ export declare function formatSelection({ selection, isFocused, inputValue }: FormatSelectionParams): string;
9
+ interface FormatShortcutParams {
10
+ selection: IntervalSelection;
11
+ inputValue: string;
12
+ isFocused: boolean;
13
+ }
14
+ export declare function formatShortcut({ selection, inputValue, isFocused }: FormatShortcutParams): string;
15
+ export {};
16
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { intervalToDuration } from 'date-fns';
2
+ import { generateDurationShortcut, humanizeDurationToNow, intervalToNowFromDuration, parseTextDurationShortcut, parseTextInterval } from '../../../utils/date.js';
3
+ import { formatDateTime, formatDateTimeRange } from '../../../utils/format/date.js';
4
+ export function formatSelectionForInput(selection) {
5
+ const interval = selection.type === 'relative' ? intervalToNowFromDuration(selection.duration) : selection.interval;
6
+ return `${formatDateTime(interval.start)}\u2009\u2013\u2009${formatDateTime(interval.end)}`;
7
+ }
8
+ export function formatSelection({ selection, isFocused, inputValue }) {
9
+ if (isFocused) return inputValue;
10
+ if (selection.type === 'relative') return humanizeDurationToNow(selection.duration);
11
+ return formatDateTimeRange(selection.interval);
12
+ }
13
+ export function formatShortcut({ selection, inputValue, isFocused }) {
14
+ const inputShortcut = parseTextDurationShortcut(inputValue);
15
+ const inputInterval = parseTextInterval(inputValue);
16
+ if (isFocused && inputShortcut) return generateDurationShortcut(inputShortcut);
17
+ if (isFocused && inputInterval) return generateDurationShortcut(intervalToDuration(inputInterval));
18
+ if (isFocused) return '-';
19
+ if (selection.type === 'relative') return generateDurationShortcut(selection.duration);
20
+ return generateDurationShortcut(intervalToDuration(selection.interval));
21
+ }
22
+
23
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,3 @@
1
+ export * from './constants';
2
+ export * from './format';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from './constants.js';
2
+ export * from './format.js';
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -3,7 +3,9 @@ import type { ComponentProps } from 'react';
3
3
  declare function Popover({ ...props }: ComponentProps<typeof PopoverPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
4
  declare function PopoverTrigger({ ...props }: ComponentProps<typeof PopoverPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
5
  declare function PopoverAnchor({ ...props }: ComponentProps<typeof PopoverPrimitive.Anchor>): import("react/jsx-runtime").JSX.Element;
6
- declare function PopoverContent({ className, align, sideOffset, ...props }: ComponentProps<typeof PopoverPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
6
+ declare function PopoverContent({ className, align, sideOffset, container, ...props }: ComponentProps<typeof PopoverPrimitive.Content> & {
7
+ container?: HTMLElement | null;
8
+ }): import("react/jsx-runtime").JSX.Element;
7
9
  declare function PopoverArrow({ className, ...props }: ComponentProps<typeof PopoverPrimitive.Arrow>): import("react/jsx-runtime").JSX.Element;
8
10
  declare function PopoverClose({ ...props }: ComponentProps<typeof PopoverPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
9
11
  export { Popover, PopoverTrigger, PopoverAnchor, PopoverContent, PopoverArrow, PopoverClose };
@@ -21,8 +21,9 @@ function PopoverPortal({ ...props }) {
21
21
  ...props
22
22
  });
23
23
  }
24
- function PopoverContent({ className, align = 'center', sideOffset = 4, ...props }) {
24
+ function PopoverContent({ className, align = 'center', sideOffset = 4, container, ...props }) {
25
25
  return /*#__PURE__*/ _jsx(PopoverPortal, {
26
+ container: container,
26
27
  children: /*#__PURE__*/ _jsx(PopoverPrimitive.Content, {
27
28
  align: align,
28
29
  sideOffset: sideOffset,