react-timezone-range-picker 0.1.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/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/index.css +80 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +1007 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +997 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +68 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,997 @@
|
|
|
1
|
+
import { forwardRef, createElement, useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
import { Flex, Box, Text, Popover, Button, Input, Select, useMantineColorScheme, useMantineTheme } from '@mantine/core';
|
|
3
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import dayjs4 from 'dayjs';
|
|
5
|
+
import utc from 'dayjs/plugin/utc';
|
|
6
|
+
import timezone from 'dayjs/plugin/timezone';
|
|
7
|
+
import { DatePickerInput, TimeInput } from '@mantine/dates';
|
|
8
|
+
import { useForm } from '@mantine/form';
|
|
9
|
+
|
|
10
|
+
// src/TimezonePanel/index.tsx
|
|
11
|
+
function useTimeoutFn(fn, ms) {
|
|
12
|
+
var ready = useRef(false);
|
|
13
|
+
var timeout = useRef();
|
|
14
|
+
var callback = useRef(fn);
|
|
15
|
+
var isReady = useCallback(function() {
|
|
16
|
+
return ready.current;
|
|
17
|
+
}, []);
|
|
18
|
+
var set = useCallback(function() {
|
|
19
|
+
ready.current = false;
|
|
20
|
+
timeout.current && clearTimeout(timeout.current);
|
|
21
|
+
timeout.current = setTimeout(function() {
|
|
22
|
+
ready.current = true;
|
|
23
|
+
callback.current();
|
|
24
|
+
}, ms);
|
|
25
|
+
}, [ms]);
|
|
26
|
+
var clear = useCallback(function() {
|
|
27
|
+
ready.current = null;
|
|
28
|
+
timeout.current && clearTimeout(timeout.current);
|
|
29
|
+
}, []);
|
|
30
|
+
useEffect(function() {
|
|
31
|
+
callback.current = fn;
|
|
32
|
+
}, [fn]);
|
|
33
|
+
useEffect(function() {
|
|
34
|
+
set();
|
|
35
|
+
return clear;
|
|
36
|
+
}, [ms]);
|
|
37
|
+
return [isReady, clear, set];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/.pnpm/react-use@17.6.0_react-dom@19.1.1_react@19.1.1__react@19.1.1/node_modules/react-use/esm/useDebounce.js
|
|
41
|
+
function useDebounce(fn, ms, deps) {
|
|
42
|
+
if (deps === void 0) {
|
|
43
|
+
deps = [];
|
|
44
|
+
}
|
|
45
|
+
var _a = useTimeoutFn(fn, ms), isReady = _a[0], cancel = _a[1], reset = _a[2];
|
|
46
|
+
useEffect(reset, deps);
|
|
47
|
+
return [isReady, cancel];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
51
|
+
function r(e) {
|
|
52
|
+
var t, f, n = "";
|
|
53
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
54
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
55
|
+
var o = e.length;
|
|
56
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
57
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
58
|
+
return n;
|
|
59
|
+
}
|
|
60
|
+
function clsx() {
|
|
61
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
62
|
+
return n;
|
|
63
|
+
}
|
|
64
|
+
var clsx_default = clsx;
|
|
65
|
+
|
|
66
|
+
// src/TimezonePanel/components/TimezoneList/index.module.css
|
|
67
|
+
var TimezoneList_default = {};
|
|
68
|
+
var useAppTheme = () => {
|
|
69
|
+
const { colorScheme } = useMantineColorScheme();
|
|
70
|
+
const theme = useMantineTheme();
|
|
71
|
+
return { colorScheme, theme, appTheme: theme.other.appTheme[colorScheme] };
|
|
72
|
+
};
|
|
73
|
+
var TimezoneList = ({
|
|
74
|
+
name,
|
|
75
|
+
longName,
|
|
76
|
+
currentTime,
|
|
77
|
+
utcOffset,
|
|
78
|
+
selectedTimezone,
|
|
79
|
+
isBrowserTimezone = false,
|
|
80
|
+
handleTimezoneMouseClick = void 0
|
|
81
|
+
}) => {
|
|
82
|
+
const { colorScheme } = useAppTheme();
|
|
83
|
+
const onClick = () => {
|
|
84
|
+
if (isBrowserTimezone) return;
|
|
85
|
+
handleTimezoneMouseClick({
|
|
86
|
+
name,
|
|
87
|
+
longName,
|
|
88
|
+
utcOffset
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return /* @__PURE__ */ jsxs(
|
|
92
|
+
Flex,
|
|
93
|
+
{
|
|
94
|
+
direction: "column",
|
|
95
|
+
className: clsx_default(
|
|
96
|
+
TimezoneList_default.row,
|
|
97
|
+
isBrowserTimezone ? void 0 : colorScheme === "dark" ? TimezoneList_default["row-dark"] : TimezoneList_default["row-light"],
|
|
98
|
+
selectedTimezone?.name === name ? colorScheme === "dark" ? TimezoneList_default["row-selected-dark"] : TimezoneList_default["row-selected-light"] : void 0
|
|
99
|
+
),
|
|
100
|
+
onClick,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsxs(Flex, { justify: "space-between", children: [
|
|
103
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: name }),
|
|
104
|
+
/* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
105
|
+
currentTime,
|
|
106
|
+
" \u2022 UTC",
|
|
107
|
+
utcOffset
|
|
108
|
+
] })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: longName })
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/defaultAttributes.mjs
|
|
117
|
+
var defaultAttributes = {
|
|
118
|
+
outline: {
|
|
119
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
120
|
+
width: 24,
|
|
121
|
+
height: 24,
|
|
122
|
+
viewBox: "0 0 24 24",
|
|
123
|
+
fill: "none",
|
|
124
|
+
stroke: "currentColor",
|
|
125
|
+
strokeWidth: 2,
|
|
126
|
+
strokeLinecap: "round",
|
|
127
|
+
strokeLinejoin: "round"
|
|
128
|
+
},
|
|
129
|
+
filled: {
|
|
130
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
131
|
+
width: 24,
|
|
132
|
+
height: 24,
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "currentColor",
|
|
135
|
+
stroke: "none"
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/createReactComponent.mjs
|
|
140
|
+
var createReactComponent = (type, iconName, iconNamePascal, iconNode) => {
|
|
141
|
+
const Component = forwardRef(
|
|
142
|
+
({ color = "currentColor", size = 24, stroke = 2, title, className, children, ...rest }, ref) => createElement(
|
|
143
|
+
"svg",
|
|
144
|
+
{
|
|
145
|
+
ref,
|
|
146
|
+
...defaultAttributes[type],
|
|
147
|
+
width: size,
|
|
148
|
+
height: size,
|
|
149
|
+
className: [`tabler-icon`, `tabler-icon-${iconName}`, className].join(" "),
|
|
150
|
+
...type === "filled" ? {
|
|
151
|
+
fill: color
|
|
152
|
+
} : {
|
|
153
|
+
strokeWidth: stroke,
|
|
154
|
+
stroke: color
|
|
155
|
+
},
|
|
156
|
+
...rest
|
|
157
|
+
},
|
|
158
|
+
[
|
|
159
|
+
title && createElement("title", { key: "svg-title" }, title),
|
|
160
|
+
...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
|
|
161
|
+
...Array.isArray(children) ? children : [children]
|
|
162
|
+
]
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
Component.displayName = `${iconNamePascal}`;
|
|
166
|
+
return Component;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendar.mjs
|
|
170
|
+
var __iconNode = [["path", { "d": "M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12z", "key": "svg-0" }], ["path", { "d": "M16 3v4", "key": "svg-1" }], ["path", { "d": "M8 3v4", "key": "svg-2" }], ["path", { "d": "M4 11h16", "key": "svg-3" }], ["path", { "d": "M11 15h1", "key": "svg-4" }], ["path", { "d": "M12 15v3", "key": "svg-5" }]];
|
|
171
|
+
var IconCalendar = createReactComponent("outline", "calendar", "Calendar", __iconNode);
|
|
172
|
+
|
|
173
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronRight.mjs
|
|
174
|
+
var __iconNode2 = [["path", { "d": "M9 6l6 6l-6 6", "key": "svg-0" }]];
|
|
175
|
+
var IconChevronRight = createReactComponent("outline", "chevron-right", "ChevronRight", __iconNode2);
|
|
176
|
+
|
|
177
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconClock.mjs
|
|
178
|
+
var __iconNode3 = [["path", { "d": "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0", "key": "svg-0" }], ["path", { "d": "M12 7v5l3 3", "key": "svg-1" }]];
|
|
179
|
+
var IconClock = createReactComponent("outline", "clock", "Clock", __iconNode3);
|
|
180
|
+
|
|
181
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconFilter2.mjs
|
|
182
|
+
var __iconNode4 = [["path", { "d": "M4 6h16", "key": "svg-0" }], ["path", { "d": "M6 12h12", "key": "svg-1" }], ["path", { "d": "M9 18h6", "key": "svg-2" }]];
|
|
183
|
+
var IconFilter2 = createReactComponent("outline", "filter-2", "Filter2", __iconNode4);
|
|
184
|
+
|
|
185
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconWorld.mjs
|
|
186
|
+
var __iconNode5 = [["path", { "d": "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0", "key": "svg-0" }], ["path", { "d": "M3.6 9h16.8", "key": "svg-1" }], ["path", { "d": "M3.6 15h16.8", "key": "svg-2" }], ["path", { "d": "M11.5 3a17 17 0 0 0 0 18", "key": "svg-3" }], ["path", { "d": "M12.5 3a17 17 0 0 1 0 18", "key": "svg-4" }]];
|
|
187
|
+
var IconWorld = createReactComponent("outline", "world", "World", __iconNode5);
|
|
188
|
+
|
|
189
|
+
// ../../node_modules/.pnpm/@tabler+icons-react@3.35.0_react@19.1.1/node_modules/@tabler/icons-react/dist/esm/icons/IconCalendarWeekFilled.mjs
|
|
190
|
+
var __iconNode6 = [["path", { "d": "M16 2c.183 0 .355 .05 .502 .135l.033 .02c.28 .177 .465 .49 .465 .845v1h1a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h1v-1a1 1 0 0 1 .514 -.874l.093 -.046l.066 -.025l.1 -.029l.107 -.019l.12 -.007q .083 0 .161 .013l.122 .029l.04 .012l.06 .023c.328 .135 .568 .44 .61 .806l.007 .117v1h6v-1a1 1 0 0 1 1 -1m3 7h-14v9.625c0 .705 .386 1.286 .883 1.366l.117 .009h12c.513 0 .936 -.53 .993 -1.215l.007 -.16z", "key": "svg-0" }], ["path", { "d": "M9.015 13a1 1 0 0 1 -1 1a1.001 1.001 0 1 1 -.005 -2c.557 0 1.005 .448 1.005 1", "key": "svg-1" }], ["path", { "d": "M13.015 13a1 1 0 0 1 -1 1a1.001 1.001 0 1 1 -.005 -2c.557 0 1.005 .448 1.005 1", "key": "svg-2" }], ["path", { "d": "M17.02 13a1 1 0 0 1 -1 1a1.001 1.001 0 1 1 -.005 -2c.557 0 1.005 .448 1.005 1", "key": "svg-3" }], ["path", { "d": "M12.02 15a1 1 0 0 1 0 2a1.001 1.001 0 1 1 -.005 -2z", "key": "svg-4" }], ["path", { "d": "M9.015 16a1 1 0 0 1 -1 1a1.001 1.001 0 1 1 -.005 -2c.557 0 1.005 .448 1.005 1", "key": "svg-5" }]];
|
|
191
|
+
var IconCalendarWeekFilled = createReactComponent("filled", "calendar-week-filled", "CalendarWeekFilled", __iconNode6);
|
|
192
|
+
var TimezoneSearch = ({ searchText, setSearchText }) => {
|
|
193
|
+
return /* @__PURE__ */ jsx(
|
|
194
|
+
Input,
|
|
195
|
+
{
|
|
196
|
+
placeholder: "Timezone search (Asia, Tokyo, +09:00, etc)",
|
|
197
|
+
leftSection: /* @__PURE__ */ jsx(IconFilter2, { stroke: 2 }),
|
|
198
|
+
value: searchText,
|
|
199
|
+
onChange: (e) => setSearchText(e.currentTarget.value)
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// src/TimezonePanel/util/longTzName.ts
|
|
205
|
+
var longTzName = (timezone3, locale = "en-US") => {
|
|
206
|
+
return new Intl.DateTimeFormat(locale, {
|
|
207
|
+
timeZone: timezone3,
|
|
208
|
+
timeZoneName: "long"
|
|
209
|
+
}).formatToParts(/* @__PURE__ */ new Date()).find((p) => p.type === "timeZoneName")?.value || "";
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/TimezonePanel/util/parseOffest.ts
|
|
213
|
+
var parseOffset = (offsetUtc) => {
|
|
214
|
+
const sign = offsetUtc[0] === "-" ? -1 : 1;
|
|
215
|
+
const [hours, minutes] = offsetUtc.slice(1).split(":").map(Number);
|
|
216
|
+
return sign * (hours * 60 + minutes);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// src/TimezonePanel/util/getTimezones.ts
|
|
220
|
+
dayjs4.extend(utc);
|
|
221
|
+
dayjs4.extend(timezone);
|
|
222
|
+
var getTimezones = () => {
|
|
223
|
+
const timezones = Intl.supportedValuesOf("timeZone");
|
|
224
|
+
return timezones.map((timezone3) => {
|
|
225
|
+
const offset = dayjs4().tz(timezone3).format("Z");
|
|
226
|
+
return {
|
|
227
|
+
name: timezone3,
|
|
228
|
+
longName: longTzName(timezone3),
|
|
229
|
+
currentTime: dayjs4().tz(timezone3).format("h:mm A"),
|
|
230
|
+
utcOffset: offset,
|
|
231
|
+
offsetMinutes: parseOffset(offset)
|
|
232
|
+
};
|
|
233
|
+
}).sort((a, b) => a.offsetMinutes - b.offsetMinutes);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// src/TimezonePanel/index.module.css
|
|
237
|
+
var TimezonePanel_default = {};
|
|
238
|
+
|
|
239
|
+
// src/styles/index.module.css
|
|
240
|
+
var styles_default = {};
|
|
241
|
+
dayjs4.extend(utc);
|
|
242
|
+
dayjs4.extend(timezone);
|
|
243
|
+
var getBrowserTimezone = () => {
|
|
244
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
245
|
+
const offset = dayjs4().tz(tz).format("Z");
|
|
246
|
+
return {
|
|
247
|
+
name: tz,
|
|
248
|
+
longName: longTzName(tz),
|
|
249
|
+
currentTime: dayjs4().tz(tz).format("h:mm A"),
|
|
250
|
+
utcOffset: offset,
|
|
251
|
+
offsetMinutes: parseOffset(offset)
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
var Footer = ({ handleCancelClick }) => {
|
|
255
|
+
const { theme } = useAppTheme();
|
|
256
|
+
return /* @__PURE__ */ jsx(Flex, { justify: "flex-end", children: /* @__PURE__ */ jsxs(Flex, { columnGap: 16, children: [
|
|
257
|
+
/* @__PURE__ */ jsx(Button, { size: "xs", variant: "subtle", color: theme.primaryColor, onClick: handleCancelClick, children: "Cancel" }),
|
|
258
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", size: "xs", color: theme.primaryColor, children: "Apply" })
|
|
259
|
+
] }) });
|
|
260
|
+
};
|
|
261
|
+
var TimezonePanel = ({ tzRange }) => {
|
|
262
|
+
const [selectedTimezone, setSelectedTimezone] = useState(tzRange.timezone);
|
|
263
|
+
const [filteredTimezones, setFilteredTimezones] = useState([]);
|
|
264
|
+
const [searchText, setSearchText] = useState("");
|
|
265
|
+
const timezones = useMemo(() => getTimezones(), []);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
setFilteredTimezones(timezones);
|
|
268
|
+
}, []);
|
|
269
|
+
useDebounce(
|
|
270
|
+
() => {
|
|
271
|
+
if (searchText === "") {
|
|
272
|
+
setFilteredTimezones(timezones);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
setFilteredTimezones(
|
|
276
|
+
timezones.filter(
|
|
277
|
+
(timezone3) => timezone3.name.toLowerCase().includes(searchText.toLocaleLowerCase()) || timezone3.longName.toLowerCase().includes(searchText.toLocaleLowerCase()) || timezone3.currentTime.toLowerCase().includes(searchText.toLocaleLowerCase()) || timezone3.utcOffset.toLowerCase().includes(searchText.toLocaleLowerCase())
|
|
278
|
+
)
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
250,
|
|
282
|
+
[searchText]
|
|
283
|
+
);
|
|
284
|
+
useMemo(() => getBrowserTimezone(), []);
|
|
285
|
+
const handleTimezoneMouseClick = (selectedTimezone2) => {
|
|
286
|
+
setSelectedTimezone(selectedTimezone2);
|
|
287
|
+
};
|
|
288
|
+
const handleApply = (e) => {
|
|
289
|
+
e.preventDefault();
|
|
290
|
+
tzRange.onApply({
|
|
291
|
+
startDate: tzRange.startDate,
|
|
292
|
+
startTime: tzRange.startTime,
|
|
293
|
+
endDate: tzRange.endDate,
|
|
294
|
+
endTime: tzRange.endTime,
|
|
295
|
+
timezone: selectedTimezone || {
|
|
296
|
+
name: null,
|
|
297
|
+
longName: null,
|
|
298
|
+
utcOffset: null
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
const getCurrentTimeInTz = (tzName) => {
|
|
303
|
+
if (!tzName) return "";
|
|
304
|
+
return dayjs4().tz(tzName).format("h:mm A");
|
|
305
|
+
};
|
|
306
|
+
return /* @__PURE__ */ jsxs("form", { className: styles_default["form-container"], onSubmit: handleApply, children: [
|
|
307
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", style: { height: "calc(100% - 40px)" }, children: [
|
|
308
|
+
/* @__PURE__ */ jsx(Box, { style: { width: "95%" }, mx: "auto", children: /* @__PURE__ */ jsx(TimezoneSearch, { searchText, setSearchText }) }),
|
|
309
|
+
/* @__PURE__ */ jsxs(Box, { style: { overflowY: "scroll" }, children: [
|
|
310
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, px: 12, children: "My Location" }),
|
|
311
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", children: /* @__PURE__ */ jsx(
|
|
312
|
+
TimezoneList,
|
|
313
|
+
{
|
|
314
|
+
isBrowserTimezone: true,
|
|
315
|
+
name: tzRange.timezone?.name,
|
|
316
|
+
longName: tzRange.timezone?.longName,
|
|
317
|
+
currentTime: getCurrentTimeInTz(tzRange.timezone?.name),
|
|
318
|
+
utcOffset: tzRange.timezone?.utcOffset,
|
|
319
|
+
selectedTimezone
|
|
320
|
+
}
|
|
321
|
+
) }),
|
|
322
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, px: 12, children: "Locations" }),
|
|
323
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", className: TimezonePanel_default["list-container"], children: filteredTimezones.map((tz, idx) => /* @__PURE__ */ jsx(
|
|
324
|
+
TimezoneList,
|
|
325
|
+
{
|
|
326
|
+
name: tz.name,
|
|
327
|
+
longName: tz.longName,
|
|
328
|
+
currentTime: tz.currentTime,
|
|
329
|
+
utcOffset: tz.utcOffset,
|
|
330
|
+
selectedTimezone,
|
|
331
|
+
handleTimezoneMouseClick
|
|
332
|
+
},
|
|
333
|
+
idx
|
|
334
|
+
)) })
|
|
335
|
+
] })
|
|
336
|
+
] }),
|
|
337
|
+
/* @__PURE__ */ jsx(Box, { px: 12, children: /* @__PURE__ */ jsx(Footer, {}) })
|
|
338
|
+
] });
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
// src/Sidebar/index.module.css
|
|
342
|
+
var Sidebar_default = {};
|
|
343
|
+
var getTimeOptions = (timezoneName) => [
|
|
344
|
+
{
|
|
345
|
+
label: "Today",
|
|
346
|
+
searchKey: "today",
|
|
347
|
+
startTime: dayjs4().tz(timezoneName).startOf("day").format(),
|
|
348
|
+
endTime: dayjs4().tz(timezoneName).endOf("day").format()
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
label: "Tomorrow",
|
|
352
|
+
searchKey: "tomorrow",
|
|
353
|
+
startTime: dayjs4().tz(timezoneName).add(1, "day").startOf("day").format(),
|
|
354
|
+
endTime: dayjs4().tz(timezoneName).add(1, "day").endOf("day").format()
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
label: "Yesterday",
|
|
358
|
+
searchKey: "yesterday",
|
|
359
|
+
startTime: dayjs4().tz(timezoneName).subtract(1, "day").startOf("day").format(),
|
|
360
|
+
endTime: dayjs4().tz(timezoneName).subtract(1, "day").endOf("day").format(),
|
|
361
|
+
lineBreak: true
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
label: "Last 15 seconds",
|
|
365
|
+
searchKey: "-15s",
|
|
366
|
+
startTime: dayjs4().tz(timezoneName).subtract(15, "second").format(),
|
|
367
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: "Last 30 seconds",
|
|
371
|
+
searchKey: "-30s",
|
|
372
|
+
startTime: dayjs4().tz(timezoneName).subtract(30, "second").format(),
|
|
373
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
label: "Next 15 seconds",
|
|
377
|
+
searchKey: "+15s",
|
|
378
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
379
|
+
endTime: dayjs4().tz(timezoneName).add(15, "second").format()
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
label: "Next 30 seconds",
|
|
383
|
+
searchKey: "+30s",
|
|
384
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
385
|
+
endTime: dayjs4().tz(timezoneName).add(30, "second").format(),
|
|
386
|
+
lineBreak: true
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
label: "Last 5 minutes",
|
|
390
|
+
searchKey: "-5m",
|
|
391
|
+
startTime: dayjs4().tz(timezoneName).subtract(5, "minute").format(),
|
|
392
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
label: "Last 10 minutes",
|
|
396
|
+
searchKey: "-10m",
|
|
397
|
+
startTime: dayjs4().tz(timezoneName).subtract(10, "minute").format(),
|
|
398
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
label: "Last 15 minutes",
|
|
402
|
+
searchKey: "-15m",
|
|
403
|
+
startTime: dayjs4().tz(timezoneName).subtract(15, "minute").format(),
|
|
404
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
label: "Last 30 minutes",
|
|
408
|
+
searchKey: "-30m",
|
|
409
|
+
startTime: dayjs4().tz(timezoneName).subtract(30, "minute").format(),
|
|
410
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
label: "Last 45 minutes",
|
|
414
|
+
searchKey: "-45m",
|
|
415
|
+
startTime: dayjs4().tz(timezoneName).subtract(45, "minute").format(),
|
|
416
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
label: "Next 5 minutes",
|
|
420
|
+
searchKey: "+5m",
|
|
421
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
422
|
+
endTime: dayjs4().tz(timezoneName).add(5, "minute").format()
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
label: "Next 10 minutes",
|
|
426
|
+
searchKey: "+10m",
|
|
427
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
428
|
+
endTime: dayjs4().tz(timezoneName).add(10, "minute").format()
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
label: "Next 15 minutes",
|
|
432
|
+
searchKey: "+15m",
|
|
433
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
434
|
+
endTime: dayjs4().tz(timezoneName).add(15, "minute").format()
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
label: "Next 30 minutes",
|
|
438
|
+
searchKey: "+30m",
|
|
439
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
440
|
+
endTime: dayjs4().tz(timezoneName).add(30, "minute").format()
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
label: "Next 45 minutes",
|
|
444
|
+
searchKey: "+45m",
|
|
445
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
446
|
+
endTime: dayjs4().tz(timezoneName).add(45, "minute").format(),
|
|
447
|
+
lineBreak: true
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
label: "Last 1 hour",
|
|
451
|
+
searchKey: "-1h",
|
|
452
|
+
startTime: dayjs4().tz(timezoneName).subtract(1, "hour").format(),
|
|
453
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
label: "Last 3 hours",
|
|
457
|
+
searchKey: "-3h",
|
|
458
|
+
startTime: dayjs4().tz(timezoneName).subtract(3, "hour").format(),
|
|
459
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
label: "Last 6 hours",
|
|
463
|
+
searchKey: "-6h",
|
|
464
|
+
startTime: dayjs4().tz(timezoneName).subtract(6, "hour").format(),
|
|
465
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
label: "Last 12 hours",
|
|
469
|
+
searchKey: "-12h",
|
|
470
|
+
startTime: dayjs4().tz(timezoneName).subtract(12, "hour").format(),
|
|
471
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
label: "Next 1 hour",
|
|
475
|
+
searchKey: "+1h",
|
|
476
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
477
|
+
endTime: dayjs4().tz(timezoneName).add(1, "hour").format()
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
label: "Next 3 hours",
|
|
481
|
+
searchKey: "+3h",
|
|
482
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
483
|
+
endTime: dayjs4().tz(timezoneName).add(3, "hour").format()
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
label: "Next 6 hours",
|
|
487
|
+
searchKey: "+6h",
|
|
488
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
489
|
+
endTime: dayjs4().tz(timezoneName).add(6, "hour").format()
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
label: "Next 12 hours",
|
|
493
|
+
searchKey: "+12h",
|
|
494
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
495
|
+
endTime: dayjs4().tz(timezoneName).add(12, "hour").format(),
|
|
496
|
+
lineBreak: true
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
label: "Last 1 day",
|
|
500
|
+
searchKey: "-1d",
|
|
501
|
+
startTime: dayjs4().tz(timezoneName).subtract(1, "day").format(),
|
|
502
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
label: "Last 2 days",
|
|
506
|
+
searchKey: "-2d",
|
|
507
|
+
startTime: dayjs4().tz(timezoneName).subtract(2, "day").format(),
|
|
508
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
label: "Last 7 days",
|
|
512
|
+
searchKey: "-7d",
|
|
513
|
+
startTime: dayjs4().tz(timezoneName).subtract(7, "day").format(),
|
|
514
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
label: "Last 14 days",
|
|
518
|
+
searchKey: "-14d",
|
|
519
|
+
startTime: dayjs4().tz(timezoneName).subtract(14, "day").format(),
|
|
520
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
label: "Last 30 days",
|
|
524
|
+
searchKey: "-30d",
|
|
525
|
+
startTime: dayjs4().tz(timezoneName).subtract(30, "day").format(),
|
|
526
|
+
endTime: dayjs4().tz(timezoneName).format()
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
label: "Next 1 day",
|
|
530
|
+
searchKey: "+1d",
|
|
531
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
532
|
+
endTime: dayjs4().tz(timezoneName).add(1, "day").format()
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
label: "Next 2 days",
|
|
536
|
+
searchKey: "+2d",
|
|
537
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
538
|
+
endTime: dayjs4().tz(timezoneName).add(2, "day").format()
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
label: "Next 7 days",
|
|
542
|
+
searchKey: "+7d",
|
|
543
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
544
|
+
endTime: dayjs4().tz(timezoneName).add(7, "day").format()
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
label: "Next 14 days",
|
|
548
|
+
searchKey: "+14d",
|
|
549
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
550
|
+
endTime: dayjs4().tz(timezoneName).add(14, "day").format()
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
label: "Next 30 days",
|
|
554
|
+
searchKey: "+30d",
|
|
555
|
+
startTime: dayjs4().tz(timezoneName).format(),
|
|
556
|
+
endTime: dayjs4().tz(timezoneName).add(30, "day").format()
|
|
557
|
+
}
|
|
558
|
+
];
|
|
559
|
+
|
|
560
|
+
// src/RelativeTimePanel/index.module.css
|
|
561
|
+
var RelativeTimePanel_default = {};
|
|
562
|
+
var RelativeTimePanel = ({ tzRange }) => {
|
|
563
|
+
const [filteredOptions, setFilteredOptions] = useState([]);
|
|
564
|
+
const [searchText, setSearchText] = useState("");
|
|
565
|
+
const { colorScheme } = useAppTheme();
|
|
566
|
+
useEffect(() => {
|
|
567
|
+
if (tzRange.timezone.name !== null) {
|
|
568
|
+
const timeOptions = getTimeOptions(tzRange.timezone.name);
|
|
569
|
+
setFilteredOptions(timeOptions);
|
|
570
|
+
}
|
|
571
|
+
}, [tzRange.timezone]);
|
|
572
|
+
useDebounce(
|
|
573
|
+
() => {
|
|
574
|
+
if (searchText === "") {
|
|
575
|
+
setFilteredOptions(getTimeOptions(tzRange.timezone.name));
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
const newTimeOptions = filteredOptions.filter(
|
|
579
|
+
(value) => value.searchKey.includes(searchText)
|
|
580
|
+
);
|
|
581
|
+
setFilteredOptions(newTimeOptions);
|
|
582
|
+
},
|
|
583
|
+
250,
|
|
584
|
+
[searchText]
|
|
585
|
+
);
|
|
586
|
+
const handleRowClick = (option) => {
|
|
587
|
+
const [startDate, startTime] = option.startTime.split("T");
|
|
588
|
+
const [endDate, endTime] = option.endTime.split("T");
|
|
589
|
+
tzRange.onApply({
|
|
590
|
+
startDate,
|
|
591
|
+
startTime: startTime.slice(0, 8),
|
|
592
|
+
endDate,
|
|
593
|
+
endTime: endTime.slice(0, 8),
|
|
594
|
+
timezone: tzRange.timezone
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
598
|
+
/* @__PURE__ */ jsx(Box, { style: { width: "90%" }, mx: "auto", children: /* @__PURE__ */ jsx(
|
|
599
|
+
Input,
|
|
600
|
+
{
|
|
601
|
+
placeholder: "Relative time (15m, 1h, 1d, 1w)",
|
|
602
|
+
value: searchText,
|
|
603
|
+
onChange: (e) => setSearchText(e.currentTarget.value)
|
|
604
|
+
}
|
|
605
|
+
) }),
|
|
606
|
+
/* @__PURE__ */ jsx(Flex, { direction: "column", className: RelativeTimePanel_default["relative-time-panel-container"], children: filteredOptions.map((op) => /* @__PURE__ */ jsxs(
|
|
607
|
+
Flex,
|
|
608
|
+
{
|
|
609
|
+
align: "center",
|
|
610
|
+
justify: "space-between",
|
|
611
|
+
className: clsx_default(
|
|
612
|
+
colorScheme === "dark" ? RelativeTimePanel_default["time-row-dark"] : RelativeTimePanel_default["time-row-light"],
|
|
613
|
+
RelativeTimePanel_default["time-row"]
|
|
614
|
+
),
|
|
615
|
+
py: 4,
|
|
616
|
+
px: 12,
|
|
617
|
+
mb: op.lineBreak ? 8 : 0,
|
|
618
|
+
onClick: () => handleRowClick(op),
|
|
619
|
+
children: [
|
|
620
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: op.label }),
|
|
621
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "#5f6368", children: op.searchKey })
|
|
622
|
+
]
|
|
623
|
+
},
|
|
624
|
+
op.label
|
|
625
|
+
)) })
|
|
626
|
+
] });
|
|
627
|
+
};
|
|
628
|
+
var Sidebar = ({ setSelectedPanel, tzRange }) => {
|
|
629
|
+
return /* @__PURE__ */ jsxs(Box, { className: Sidebar_default["sidebar-container"], flex: 1, children: [
|
|
630
|
+
/* @__PURE__ */ jsx(RelativeTimePanel, { tzRange }),
|
|
631
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", rowGap: 16, py: 8, style: { borderTop: "1px solid #ddd" }, children: [
|
|
632
|
+
/* @__PURE__ */ jsxs(
|
|
633
|
+
Flex,
|
|
634
|
+
{
|
|
635
|
+
className: Sidebar_default["sidebar-row"],
|
|
636
|
+
justify: "space-between",
|
|
637
|
+
align: "center",
|
|
638
|
+
px: 12,
|
|
639
|
+
onClick: () => setSelectedPanel("Start and end times" /* START_END_TIME */),
|
|
640
|
+
children: [
|
|
641
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
642
|
+
/* @__PURE__ */ jsx(IconCalendarWeekFilled, { stroke: 1.5 }),
|
|
643
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: "Start and end times" })
|
|
644
|
+
] }),
|
|
645
|
+
/* @__PURE__ */ jsx(IconChevronRight, { stroke: 1.5 })
|
|
646
|
+
]
|
|
647
|
+
}
|
|
648
|
+
),
|
|
649
|
+
/* @__PURE__ */ jsxs(
|
|
650
|
+
Flex,
|
|
651
|
+
{
|
|
652
|
+
className: Sidebar_default["sidebar-row"],
|
|
653
|
+
justify: "space-between",
|
|
654
|
+
align: "center",
|
|
655
|
+
px: 12,
|
|
656
|
+
onClick: () => setSelectedPanel("Around a time" /* AROUND_TIME */),
|
|
657
|
+
children: [
|
|
658
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
659
|
+
/* @__PURE__ */ jsx(IconClock, { stroke: 1.5 }),
|
|
660
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: "Around a time" })
|
|
661
|
+
] }),
|
|
662
|
+
/* @__PURE__ */ jsx(IconChevronRight, { stroke: 1.5 })
|
|
663
|
+
]
|
|
664
|
+
}
|
|
665
|
+
),
|
|
666
|
+
/* @__PURE__ */ jsxs(
|
|
667
|
+
Flex,
|
|
668
|
+
{
|
|
669
|
+
className: Sidebar_default["sidebar-row"],
|
|
670
|
+
justify: "space-between",
|
|
671
|
+
align: "center",
|
|
672
|
+
px: 12,
|
|
673
|
+
onClick: () => setSelectedPanel("Time zone" /* TIMEZONE */),
|
|
674
|
+
children: [
|
|
675
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
676
|
+
/* @__PURE__ */ jsx(IconWorld, { stroke: 1.5 }),
|
|
677
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: "Time zone" })
|
|
678
|
+
] }),
|
|
679
|
+
/* @__PURE__ */ jsx(IconChevronRight, { stroke: 1.5 })
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
] })
|
|
684
|
+
] });
|
|
685
|
+
};
|
|
686
|
+
var getCurrentTime = () => dayjs4().format("HH:mm:ss");
|
|
687
|
+
var getCurrentDate = () => dayjs4().format("YYYY-MM-DD");
|
|
688
|
+
var getCurrentPlusDate = (amount) => dayjs4().add(amount, "day").format("YYYY-MM-DD");
|
|
689
|
+
var getShortTimezoneName = (tz) => {
|
|
690
|
+
if (!tz) return tz;
|
|
691
|
+
return dayjs4().tz(tz).format("Z");
|
|
692
|
+
};
|
|
693
|
+
var getPopoverButtonText = (tzRange) => {
|
|
694
|
+
return `${dayjs4(tzRange.startDate).format("YYYY/MM/DD")} ${tzRange.startTime} - ${dayjs4(
|
|
695
|
+
tzRange.endDate
|
|
696
|
+
).format("YYYY/MM/DD")} ${tzRange.endTime} (${getShortTimezoneName(tzRange.timezone.name)})`;
|
|
697
|
+
};
|
|
698
|
+
var getPastDateTime = (date, time, amount, unit) => {
|
|
699
|
+
const d = dayjs4(`${date} ${time}`).subtract(amount, unit);
|
|
700
|
+
return {
|
|
701
|
+
date: d.format("YYYY-MM-DD"),
|
|
702
|
+
time: d.format("HH:mm:ss")
|
|
703
|
+
};
|
|
704
|
+
};
|
|
705
|
+
var getFutureDateTime = (date, time, amount, unit) => {
|
|
706
|
+
const d = dayjs4(`${date} ${time}`).add(amount, unit);
|
|
707
|
+
return {
|
|
708
|
+
date: d.format("YYYY-MM-DD"),
|
|
709
|
+
time: d.format("HH:mm:ss")
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// src/AroundTimePanel/util.ts
|
|
714
|
+
var TIME_OPTIONS = [
|
|
715
|
+
"\xB1 30 seconds" /* ThirtySeconds */,
|
|
716
|
+
"\xB1 1 minute" /* OneMinute */,
|
|
717
|
+
"\xB1 15 minutes" /* FifteenMinutes */,
|
|
718
|
+
"\xB1 30 minutes" /* ThirtyMinutes */,
|
|
719
|
+
"\xB1 1 hour" /* OneHour */,
|
|
720
|
+
"\xB1 1 day" /* OneDay */
|
|
721
|
+
];
|
|
722
|
+
var getStartEndDateTime = (date, time, timeOption) => {
|
|
723
|
+
switch (timeOption) {
|
|
724
|
+
case "\xB1 30 seconds" /* ThirtySeconds */:
|
|
725
|
+
const startDateTime = getPastDateTime(date, time, 30, "second");
|
|
726
|
+
const endDateTime = getFutureDateTime(date, time, 30, "second");
|
|
727
|
+
return {
|
|
728
|
+
startDate: startDateTime.date,
|
|
729
|
+
startTime: startDateTime.time,
|
|
730
|
+
endDate: endDateTime.date,
|
|
731
|
+
endTime: endDateTime.time
|
|
732
|
+
};
|
|
733
|
+
case "\xB1 1 minute" /* OneMinute */:
|
|
734
|
+
const startDateTime1 = getPastDateTime(date, time, 1, "minute");
|
|
735
|
+
const endDateTime1 = getFutureDateTime(date, time, 1, "minute");
|
|
736
|
+
return {
|
|
737
|
+
startDate: startDateTime1.date,
|
|
738
|
+
startTime: startDateTime1.time,
|
|
739
|
+
endDate: endDateTime1.date,
|
|
740
|
+
endTime: endDateTime1.time
|
|
741
|
+
};
|
|
742
|
+
case "\xB1 15 minutes" /* FifteenMinutes */:
|
|
743
|
+
const startDateTime15 = getPastDateTime(date, time, 15, "minute");
|
|
744
|
+
const endDateTime15 = getFutureDateTime(date, time, 15, "minute");
|
|
745
|
+
return {
|
|
746
|
+
startDate: startDateTime15.date,
|
|
747
|
+
startTime: startDateTime15.time,
|
|
748
|
+
endDate: endDateTime15.date,
|
|
749
|
+
endTime: endDateTime15.time
|
|
750
|
+
};
|
|
751
|
+
case "\xB1 30 minutes" /* ThirtyMinutes */:
|
|
752
|
+
const startDateTime30 = getPastDateTime(date, time, 30, "minute");
|
|
753
|
+
const endDateTime30 = getFutureDateTime(date, time, 30, "minute");
|
|
754
|
+
return {
|
|
755
|
+
startDate: startDateTime30.date,
|
|
756
|
+
startTime: startDateTime30.time,
|
|
757
|
+
endDate: endDateTime30.date,
|
|
758
|
+
endTime: endDateTime30.time
|
|
759
|
+
};
|
|
760
|
+
case "\xB1 1 hour" /* OneHour */:
|
|
761
|
+
const startDateTime60 = getPastDateTime(date, time, 1, "hour");
|
|
762
|
+
const endDateTime60 = getFutureDateTime(date, time, 1, "hour");
|
|
763
|
+
return {
|
|
764
|
+
startDate: startDateTime60.date,
|
|
765
|
+
startTime: startDateTime60.time,
|
|
766
|
+
endDate: endDateTime60.date,
|
|
767
|
+
endTime: endDateTime60.time
|
|
768
|
+
};
|
|
769
|
+
case "\xB1 1 day" /* OneDay */:
|
|
770
|
+
const startDateTimeDay = getPastDateTime(date, time, 1, "day");
|
|
771
|
+
const endDateTimeDay = getFutureDateTime(date, time, 1, "day");
|
|
772
|
+
return {
|
|
773
|
+
startDate: startDateTimeDay.date,
|
|
774
|
+
startTime: startDateTimeDay.time,
|
|
775
|
+
endDate: endDateTimeDay.date,
|
|
776
|
+
endTime: endDateTimeDay.time
|
|
777
|
+
};
|
|
778
|
+
default:
|
|
779
|
+
return {
|
|
780
|
+
startDate: date,
|
|
781
|
+
startTime: time,
|
|
782
|
+
endDate: date,
|
|
783
|
+
endTime: time
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
var AroundTimePanel = ({ tzRange }) => {
|
|
788
|
+
const form = useForm({
|
|
789
|
+
initialValues: {
|
|
790
|
+
date: getCurrentDate(),
|
|
791
|
+
time: getCurrentTime(),
|
|
792
|
+
duration: "\xB1 1 day" /* OneDay */
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
const onSubmit = (values) => {
|
|
796
|
+
const { startDate, startTime, endDate, endTime } = getStartEndDateTime(
|
|
797
|
+
values.date,
|
|
798
|
+
values.time,
|
|
799
|
+
values.duration
|
|
800
|
+
);
|
|
801
|
+
tzRange.onApply({
|
|
802
|
+
startDate,
|
|
803
|
+
startTime,
|
|
804
|
+
endDate,
|
|
805
|
+
endTime,
|
|
806
|
+
timezone: tzRange.timezone
|
|
807
|
+
});
|
|
808
|
+
};
|
|
809
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 2, justify: "space-between", style: { height: "100%" }, px: 12, children: /* @__PURE__ */ jsxs("form", { className: styles_default["form-container"], onSubmit: form.onSubmit(onSubmit), children: [
|
|
810
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
811
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Around a time" }),
|
|
812
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 8, mt: 12, children: [
|
|
813
|
+
/* @__PURE__ */ jsx(
|
|
814
|
+
DatePickerInput,
|
|
815
|
+
{
|
|
816
|
+
label: "Pick date",
|
|
817
|
+
placeholder: "Pick date",
|
|
818
|
+
...form.getInputProps("date"),
|
|
819
|
+
popoverProps: { withinPortal: false },
|
|
820
|
+
valueFormat: "YYYY/MM/DD",
|
|
821
|
+
leftSection: /* @__PURE__ */ jsx(IconCalendar, { stroke: 1.5 })
|
|
822
|
+
},
|
|
823
|
+
form.key("date")
|
|
824
|
+
),
|
|
825
|
+
/* @__PURE__ */ jsx(
|
|
826
|
+
TimeInput,
|
|
827
|
+
{
|
|
828
|
+
label: "Pick time",
|
|
829
|
+
placeholder: "Pick time",
|
|
830
|
+
withSeconds: true,
|
|
831
|
+
defaultValue: getCurrentTime(),
|
|
832
|
+
...form.getInputProps("time"),
|
|
833
|
+
leftSection: /* @__PURE__ */ jsx(IconClock, { stroke: 1.5 }),
|
|
834
|
+
rightSection: /* @__PURE__ */ jsx(Text, { style: { fontSize: 12, fontStyle: "italic", textAlign: "right" }, children: tzRange.timezone?.longName }),
|
|
835
|
+
rightSectionWidth: 180,
|
|
836
|
+
rightSectionProps: {
|
|
837
|
+
style: {
|
|
838
|
+
paddingRight: 1
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
form.key("time")
|
|
843
|
+
),
|
|
844
|
+
/* @__PURE__ */ jsx(
|
|
845
|
+
Select,
|
|
846
|
+
{
|
|
847
|
+
label: "Duration",
|
|
848
|
+
placeholder: "Pick value",
|
|
849
|
+
data: TIME_OPTIONS,
|
|
850
|
+
...form.getInputProps("duration"),
|
|
851
|
+
comboboxProps: { withinPortal: false }
|
|
852
|
+
},
|
|
853
|
+
form.key("duration")
|
|
854
|
+
)
|
|
855
|
+
] })
|
|
856
|
+
] }),
|
|
857
|
+
/* @__PURE__ */ jsx(Footer, {})
|
|
858
|
+
] }) });
|
|
859
|
+
};
|
|
860
|
+
var StartEndTimePanel = ({ tzRange }) => {
|
|
861
|
+
const form = useForm({
|
|
862
|
+
mode: "uncontrolled",
|
|
863
|
+
initialValues: {
|
|
864
|
+
startDate: getCurrentDate(),
|
|
865
|
+
startTime: getCurrentTime(),
|
|
866
|
+
endDate: getCurrentPlusDate(30),
|
|
867
|
+
endTime: getCurrentTime()
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
const onSubmit = (values) => {
|
|
871
|
+
tzRange.onApply({
|
|
872
|
+
startDate: values.startDate,
|
|
873
|
+
startTime: values.startTime,
|
|
874
|
+
endDate: values.endDate,
|
|
875
|
+
endTime: values.endTime,
|
|
876
|
+
timezone: tzRange.timezone
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 2, style: { height: "100%" }, px: 12, children: /* @__PURE__ */ jsxs("form", { className: styles_default["form-container"], onSubmit: form.onSubmit(onSubmit), children: [
|
|
880
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
881
|
+
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Start and end times" }),
|
|
882
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 8, mt: 12, children: [
|
|
883
|
+
/* @__PURE__ */ jsx(
|
|
884
|
+
DatePickerInput,
|
|
885
|
+
{
|
|
886
|
+
label: "Start time",
|
|
887
|
+
...form.getInputProps("startDate"),
|
|
888
|
+
popoverProps: { withinPortal: false },
|
|
889
|
+
valueFormat: "YYYY/MM/DD",
|
|
890
|
+
leftSection: /* @__PURE__ */ jsx(IconCalendar, { stroke: 1.5 })
|
|
891
|
+
},
|
|
892
|
+
form.key("startDate")
|
|
893
|
+
),
|
|
894
|
+
/* @__PURE__ */ jsx(
|
|
895
|
+
TimeInput,
|
|
896
|
+
{
|
|
897
|
+
withSeconds: true,
|
|
898
|
+
defaultValue: getCurrentTime(),
|
|
899
|
+
...form.getInputProps("startTime"),
|
|
900
|
+
leftSection: /* @__PURE__ */ jsx(IconClock, { stroke: 1.5 }),
|
|
901
|
+
rightSection: /* @__PURE__ */ jsx(Text, { style: { fontSize: 12, fontStyle: "italic" }, children: tzRange.timezone?.longName }),
|
|
902
|
+
rightSectionWidth: 180,
|
|
903
|
+
rightSectionProps: {
|
|
904
|
+
style: {
|
|
905
|
+
paddingRight: 1
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
form.key("startTime")
|
|
910
|
+
),
|
|
911
|
+
/* @__PURE__ */ jsx(
|
|
912
|
+
DatePickerInput,
|
|
913
|
+
{
|
|
914
|
+
label: "End time",
|
|
915
|
+
...form.getInputProps("endDate"),
|
|
916
|
+
popoverProps: { withinPortal: false },
|
|
917
|
+
valueFormat: "YYYY/MM/DD",
|
|
918
|
+
leftSection: /* @__PURE__ */ jsx(IconCalendar, { stroke: 1.5 })
|
|
919
|
+
},
|
|
920
|
+
form.key("endDate")
|
|
921
|
+
),
|
|
922
|
+
/* @__PURE__ */ jsx(
|
|
923
|
+
TimeInput,
|
|
924
|
+
{
|
|
925
|
+
withSeconds: true,
|
|
926
|
+
defaultValue: getCurrentTime(),
|
|
927
|
+
...form.getInputProps("endTime"),
|
|
928
|
+
leftSection: /* @__PURE__ */ jsx(IconClock, { stroke: 1.5 }),
|
|
929
|
+
rightSection: /* @__PURE__ */ jsx(Text, { style: { fontSize: 12, fontStyle: "italic" }, children: tzRange.timezone?.longName }),
|
|
930
|
+
rightSectionWidth: 180,
|
|
931
|
+
rightSectionProps: {
|
|
932
|
+
style: {
|
|
933
|
+
paddingRight: 1
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
},
|
|
937
|
+
form.key("endTime")
|
|
938
|
+
)
|
|
939
|
+
] })
|
|
940
|
+
] }),
|
|
941
|
+
/* @__PURE__ */ jsx(Footer, {})
|
|
942
|
+
] }) });
|
|
943
|
+
};
|
|
944
|
+
var Panel = /* @__PURE__ */ ((Panel2) => {
|
|
945
|
+
Panel2["START_END_TIME"] = "Start and end times";
|
|
946
|
+
Panel2["AROUND_TIME"] = "Around a time";
|
|
947
|
+
Panel2["TIMEZONE"] = "Time zone";
|
|
948
|
+
return Panel2;
|
|
949
|
+
})(Panel || {});
|
|
950
|
+
var TimezoneRangePicker = (tzRange) => {
|
|
951
|
+
const [selectedPanel, setSelectedPanel] = useState("Start and end times" /* START_END_TIME */);
|
|
952
|
+
const renderPanel = () => {
|
|
953
|
+
switch (selectedPanel) {
|
|
954
|
+
case "Start and end times" /* START_END_TIME */:
|
|
955
|
+
return /* @__PURE__ */ jsx(StartEndTimePanel, { tzRange });
|
|
956
|
+
case "Around a time" /* AROUND_TIME */:
|
|
957
|
+
return /* @__PURE__ */ jsx(AroundTimePanel, { tzRange });
|
|
958
|
+
case "Time zone" /* TIMEZONE */:
|
|
959
|
+
return /* @__PURE__ */ jsx(TimezonePanel, { tzRange });
|
|
960
|
+
default:
|
|
961
|
+
return null;
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
const getButtonText = useMemo(
|
|
965
|
+
() => getPopoverButtonText(tzRange),
|
|
966
|
+
[tzRange.startDate, tzRange.startTime, tzRange.endDate, tzRange.endTime, tzRange.timezone]
|
|
967
|
+
);
|
|
968
|
+
return /* @__PURE__ */ jsxs(Popover, { position: "bottom", shadow: "md", children: [
|
|
969
|
+
/* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(Button, { children: getButtonText }) }),
|
|
970
|
+
/* @__PURE__ */ jsx(Popover.Dropdown, { style: { width: 700, height: 400, padding: 0 }, py: 8, children: /* @__PURE__ */ jsxs(Flex, { style: { height: "100%" }, children: [
|
|
971
|
+
/* @__PURE__ */ jsx(Sidebar, { tzRange, setSelectedPanel }),
|
|
972
|
+
renderPanel()
|
|
973
|
+
] }) })
|
|
974
|
+
] });
|
|
975
|
+
};
|
|
976
|
+
/*! Bundled license information:
|
|
977
|
+
|
|
978
|
+
@tabler/icons-react/dist/esm/defaultAttributes.mjs:
|
|
979
|
+
@tabler/icons-react/dist/esm/createReactComponent.mjs:
|
|
980
|
+
@tabler/icons-react/dist/esm/icons/IconCalendar.mjs:
|
|
981
|
+
@tabler/icons-react/dist/esm/icons/IconChevronRight.mjs:
|
|
982
|
+
@tabler/icons-react/dist/esm/icons/IconClock.mjs:
|
|
983
|
+
@tabler/icons-react/dist/esm/icons/IconFilter2.mjs:
|
|
984
|
+
@tabler/icons-react/dist/esm/icons/IconWorld.mjs:
|
|
985
|
+
@tabler/icons-react/dist/esm/icons/IconCalendarWeekFilled.mjs:
|
|
986
|
+
@tabler/icons-react/dist/esm/tabler-icons-react.mjs:
|
|
987
|
+
(**
|
|
988
|
+
* @license @tabler/icons-react v3.35.0 - MIT
|
|
989
|
+
*
|
|
990
|
+
* This source code is licensed under the MIT license.
|
|
991
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
992
|
+
*)
|
|
993
|
+
*/
|
|
994
|
+
|
|
995
|
+
export { Panel, TimezonePanel, TimezoneRangePicker };
|
|
996
|
+
//# sourceMappingURL=index.mjs.map
|
|
997
|
+
//# sourceMappingURL=index.mjs.map
|