@neo4j-ndl/react 4.0.18 → 4.1.1
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/lib/cjs/date-picker/DatePicker.js +11 -3
- package/lib/cjs/date-picker/DatePicker.js.map +1 -1
- package/lib/cjs/date-picker/stories/date-picker-with-timezone-both-mode.story.js +57 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone-both-mode.story.js.map +1 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone.story.js +52 -0
- package/lib/cjs/date-picker/stories/date-picker-with-timezone.story.js.map +1 -0
- package/lib/cjs/date-picker/stories/date-picker.stories.js +27 -1
- package/lib/cjs/date-picker/stories/date-picker.stories.js.map +1 -1
- package/lib/cjs/date-picker/stories/index.js +9 -1
- package/lib/cjs/date-picker/stories/index.js.map +1 -1
- package/lib/cjs/dropzone/Dropzone.js +1 -1
- package/lib/cjs/dropzone/Dropzone.js.map +1 -1
- package/lib/cjs/icon-button-base/IconButtonBase.js +4 -1
- package/lib/cjs/icon-button-base/IconButtonBase.js.map +1 -1
- package/lib/cjs/index.js +4 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/timezone-picker/TimeZonePicker.js +330 -0
- package/lib/cjs/timezone-picker/TimeZonePicker.js.map +1 -0
- package/lib/cjs/timezone-picker/generate-timezone-options.js +256 -0
- package/lib/cjs/timezone-picker/generate-timezone-options.js.map +1 -0
- package/lib/cjs/timezone-picker/index.js +39 -0
- package/lib/cjs/timezone-picker/index.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/index.js +60 -0
- package/lib/cjs/timezone-picker/stories/index.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-both-mode.story.js +41 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-both-mode.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-default.story.js +35 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-default.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-disabled.story.js +30 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-disabled.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js +54 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js +30 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-in-dialog.story.js +47 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-in-dialog.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-sizes.story.js +32 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-sizes.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-utc-only.story.js +49 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker-utc-only.story.js.map +1 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js +145 -0
- package/lib/cjs/timezone-picker/stories/timezone-picker.stories.js.map +1 -0
- package/lib/cjs/timezone-picker/timezone-picker-hooks.js +52 -0
- package/lib/cjs/timezone-picker/timezone-picker-hooks.js.map +1 -0
- package/lib/esm/date-picker/DatePicker.js +11 -3
- package/lib/esm/date-picker/DatePicker.js.map +1 -1
- package/lib/esm/date-picker/stories/date-picker-with-timezone-both-mode.story.js +53 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone-both-mode.story.js.map +1 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone.story.js +50 -0
- package/lib/esm/date-picker/stories/date-picker-with-timezone.story.js.map +1 -0
- package/lib/esm/date-picker/stories/date-picker.stories.js +27 -1
- package/lib/esm/date-picker/stories/date-picker.stories.js.map +1 -1
- package/lib/esm/date-picker/stories/index.js +6 -0
- package/lib/esm/date-picker/stories/index.js.map +1 -1
- package/lib/esm/dropzone/Dropzone.js +1 -1
- package/lib/esm/dropzone/Dropzone.js.map +1 -1
- package/lib/esm/icon-button-base/IconButtonBase.js +4 -1
- package/lib/esm/icon-button-base/IconButtonBase.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/timezone-picker/TimeZonePicker.js +323 -0
- package/lib/esm/timezone-picker/TimeZonePicker.js.map +1 -0
- package/lib/esm/timezone-picker/generate-timezone-options.js +247 -0
- package/lib/esm/timezone-picker/generate-timezone-options.js.map +1 -0
- package/lib/esm/timezone-picker/index.js +23 -0
- package/lib/esm/timezone-picker/index.js.map +1 -0
- package/lib/esm/timezone-picker/stories/index.js +46 -0
- package/lib/esm/timezone-picker/stories/index.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-both-mode.story.js +37 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-both-mode.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-default.story.js +33 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-default.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-disabled.story.js +28 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-disabled.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js +52 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-dst-aware.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js +28 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-fluid.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-in-dialog.story.js +45 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-in-dialog.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-sizes.story.js +30 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-sizes.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-utc-only.story.js +47 -0
- package/lib/esm/timezone-picker/stories/timezone-picker-utc-only.story.js.map +1 -0
- package/lib/esm/timezone-picker/stories/timezone-picker.stories.js +142 -0
- package/lib/esm/timezone-picker/stories/timezone-picker.stories.js.map +1 -0
- package/lib/esm/timezone-picker/timezone-picker-hooks.js +47 -0
- package/lib/esm/timezone-picker/timezone-picker-hooks.js.map +1 -0
- package/lib/types/date-picker/DatePicker.d.ts +4 -1
- package/lib/types/date-picker/DatePicker.d.ts.map +1 -1
- package/lib/types/date-picker/stories/date-picker-with-timezone-both-mode.story.d.ts +23 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone-both-mode.story.d.ts.map +1 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone.story.d.ts +24 -0
- package/lib/types/date-picker/stories/date-picker-with-timezone.story.d.ts.map +1 -0
- package/lib/types/date-picker/stories/date-picker.stories.d.ts +2 -0
- package/lib/types/date-picker/stories/date-picker.stories.d.ts.map +1 -1
- package/lib/types/date-picker/stories/index.d.ts +4 -0
- package/lib/types/date-picker/stories/index.d.ts.map +1 -1
- package/lib/types/dropzone/Dropzone.d.ts.map +1 -1
- package/lib/types/icon-button-base/IconButtonBase.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/timezone-picker/TimeZonePicker.d.ts +68 -0
- package/lib/types/timezone-picker/TimeZonePicker.d.ts.map +1 -0
- package/lib/types/timezone-picker/generate-timezone-options.d.ts +61 -0
- package/lib/types/timezone-picker/generate-timezone-options.d.ts.map +1 -0
- package/lib/types/timezone-picker/index.d.ts +23 -0
- package/lib/types/timezone-picker/index.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/index.d.ts +37 -0
- package/lib/types/timezone-picker/stories/index.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-both-mode.story.d.ts +23 -0
- package/lib/types/timezone-picker/stories/timezone-picker-both-mode.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-default.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-default.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-disabled.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-disabled.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-dst-aware.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-fluid.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-fluid.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-in-dialog.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-in-dialog.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-sizes.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-sizes.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker-utc-only.story.d.ts +24 -0
- package/lib/types/timezone-picker/stories/timezone-picker-utc-only.story.d.ts.map +1 -0
- package/lib/types/timezone-picker/stories/timezone-picker.stories.d.ts +34 -0
- package/lib/types/timezone-picker/stories/timezone-picker.stories.d.ts.map +1 -0
- package/lib/types/timezone-picker/timezone-picker-hooks.d.ts +31 -0
- package/lib/types/timezone-picker/timezone-picker-hooks.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.formatTimeZone = exports.isValidUTCFormat = exports.parseCustomUTCOffset = exports.getUserTimeZone = exports.generateTimeZoneOptions = exports.generateUTCTimeZoneOptions = void 0;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the offset in minutes for a timezone at a specific date
|
|
26
|
+
*/
|
|
27
|
+
const getOffsetMinutes = (timezone, date) => {
|
|
28
|
+
try {
|
|
29
|
+
// Create dates in UTC and in the target timezone
|
|
30
|
+
const utcDate = new Date(date.toLocaleString('en-US', { timeZone: 'UTC' }));
|
|
31
|
+
const tzDate = new Date(date.toLocaleString('en-US', { timeZone: timezone }));
|
|
32
|
+
// Calculate the difference in minutes
|
|
33
|
+
const diffMs = tzDate.getTime() - utcDate.getTime();
|
|
34
|
+
return Math.round(diffMs / (1000 * 60));
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Formats a UTC offset using the Intl API for consistent formatting
|
|
42
|
+
* @param offsetHours - The offset in hours (can be fractional)
|
|
43
|
+
* @returns Formatted UTC offset string (e.g., "UTC+5:30", "UTC-3")
|
|
44
|
+
*/
|
|
45
|
+
const formatUTCOffset = (offsetHours) => {
|
|
46
|
+
if (offsetHours === 0) {
|
|
47
|
+
return 'UTC';
|
|
48
|
+
}
|
|
49
|
+
const sign = offsetHours >= 0 ? '+' : '-';
|
|
50
|
+
const absHours = Math.abs(offsetHours);
|
|
51
|
+
const hours = Math.floor(absHours);
|
|
52
|
+
const minutes = Math.round((absHours - hours) * 60);
|
|
53
|
+
// Use Intl.NumberFormat for consistent number formatting
|
|
54
|
+
const numberFormatter = new Intl.NumberFormat('en-US', {
|
|
55
|
+
maximumFractionDigits: 0,
|
|
56
|
+
minimumIntegerDigits: 1,
|
|
57
|
+
});
|
|
58
|
+
const formattedHours = numberFormatter.format(hours);
|
|
59
|
+
const formattedMinutes = minutes > 0 ? `:${String(minutes).padStart(2, '0')}` : '';
|
|
60
|
+
return `UTC${sign}${formattedHours}${formattedMinutes}`;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Extracts unique UTC offsets from all supported timezones using the Intl API
|
|
64
|
+
* @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)
|
|
65
|
+
* @returns Set of unique offset values in minutes
|
|
66
|
+
*/
|
|
67
|
+
const getUniqueOffsetsFromAPI = (referenceDate) => {
|
|
68
|
+
const uniqueOffsets = new Set();
|
|
69
|
+
const now = referenceDate || new Date();
|
|
70
|
+
try {
|
|
71
|
+
// Get all supported timezones from the Intl API
|
|
72
|
+
const timezones = Intl.supportedValuesOf('timeZone');
|
|
73
|
+
// Extract unique offsets from each timezone
|
|
74
|
+
for (const tz of timezones) {
|
|
75
|
+
try {
|
|
76
|
+
const offsetMinutes = getOffsetMinutes(tz, now);
|
|
77
|
+
uniqueOffsets.add(offsetMinutes);
|
|
78
|
+
}
|
|
79
|
+
catch (_a) {
|
|
80
|
+
// Skip timezones that can't be processed
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (_b) {
|
|
86
|
+
// Fallback to empty set if API is not available
|
|
87
|
+
}
|
|
88
|
+
// Always include UTC (offset 0)
|
|
89
|
+
uniqueOffsets.add(0);
|
|
90
|
+
return uniqueOffsets;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Generates UTC-only timezone options derived from the Intl API
|
|
94
|
+
* Uses the Intl API to discover which UTC offsets are actually used by supported timezones
|
|
95
|
+
* @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)
|
|
96
|
+
*/
|
|
97
|
+
const generateUTCTimeZoneOptions = (referenceDate) => {
|
|
98
|
+
// Get unique offsets from all supported timezones via the Intl API
|
|
99
|
+
const uniqueOffsets = getUniqueOffsetsFromAPI(referenceDate);
|
|
100
|
+
// Convert offset minutes to hours (can be fractional)
|
|
101
|
+
const offsetHours = Array.from(uniqueOffsets)
|
|
102
|
+
.map((minutes) => minutes / 60)
|
|
103
|
+
.sort((a, b) => a - b);
|
|
104
|
+
// Convert to TimeZoneOption format
|
|
105
|
+
const options = offsetHours.map((offsetHours) => {
|
|
106
|
+
const offsetStr = formatUTCOffset(offsetHours);
|
|
107
|
+
return {
|
|
108
|
+
label: offsetStr,
|
|
109
|
+
offset: offsetStr,
|
|
110
|
+
offsetMinutes: Math.round(offsetHours * 60),
|
|
111
|
+
value: offsetStr,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
return options;
|
|
115
|
+
};
|
|
116
|
+
exports.generateUTCTimeZoneOptions = generateUTCTimeZoneOptions;
|
|
117
|
+
/**
|
|
118
|
+
* Generates a list of common timezone options with their UTC offsets
|
|
119
|
+
* @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)
|
|
120
|
+
* @param excludeUTC - Whether to exclude the UTC timezone from the list (useful when combining with UTC-only options)
|
|
121
|
+
*/
|
|
122
|
+
const generateTimeZoneOptions = (referenceDate, excludeUTC = false) => {
|
|
123
|
+
// Common timezones with their IANA identifiers
|
|
124
|
+
const timezones = Intl.supportedValuesOf('timeZone');
|
|
125
|
+
const now = referenceDate || new Date();
|
|
126
|
+
// Filter out UTC if requested
|
|
127
|
+
const filteredTimezones = excludeUTC
|
|
128
|
+
? timezones.filter((tz) => tz !== 'UTC')
|
|
129
|
+
: timezones;
|
|
130
|
+
return filteredTimezones
|
|
131
|
+
.map((tz) => {
|
|
132
|
+
var _a, _b, _c;
|
|
133
|
+
try {
|
|
134
|
+
// Get the offset for this timezone
|
|
135
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
136
|
+
timeZone: tz,
|
|
137
|
+
timeZoneName: 'shortOffset',
|
|
138
|
+
});
|
|
139
|
+
const parts = formatter.formatToParts(now);
|
|
140
|
+
const offsetPart = parts.find((part) => part.type === 'timeZoneName');
|
|
141
|
+
const offset = (_a = offsetPart === null || offsetPart === void 0 ? void 0 : offsetPart.value) !== null && _a !== void 0 ? _a : '';
|
|
142
|
+
// Calculate offset in minutes for proper sorting
|
|
143
|
+
const offsetMinutes = getOffsetMinutes(tz, now);
|
|
144
|
+
// Format the label
|
|
145
|
+
const cityName = (_c = (_b = tz.split('/').pop()) === null || _b === void 0 ? void 0 : _b.replace(/_/g, ' ')) !== null && _c !== void 0 ? _c : tz;
|
|
146
|
+
const label = `${cityName} (${offset})`;
|
|
147
|
+
return {
|
|
148
|
+
label,
|
|
149
|
+
offset,
|
|
150
|
+
offsetMinutes,
|
|
151
|
+
value: tz,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (_d) {
|
|
155
|
+
// Fallback if timezone is not supported
|
|
156
|
+
return {
|
|
157
|
+
label: tz.replace(/_/g, ' '),
|
|
158
|
+
offset: '',
|
|
159
|
+
offsetMinutes: 0,
|
|
160
|
+
value: tz,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
})
|
|
164
|
+
.sort((a, b) => {
|
|
165
|
+
// Sort by offset (negative to positive), then by label
|
|
166
|
+
if (a.offsetMinutes !== b.offsetMinutes) {
|
|
167
|
+
return a.offsetMinutes - b.offsetMinutes;
|
|
168
|
+
}
|
|
169
|
+
return a.label.localeCompare(b.label);
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
exports.generateTimeZoneOptions = generateTimeZoneOptions;
|
|
173
|
+
/**
|
|
174
|
+
* Gets the user's current timezone
|
|
175
|
+
*/
|
|
176
|
+
const getUserTimeZone = () => {
|
|
177
|
+
try {
|
|
178
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
179
|
+
}
|
|
180
|
+
catch (_a) {
|
|
181
|
+
return 'UTC';
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
exports.getUserTimeZone = getUserTimeZone;
|
|
185
|
+
/**
|
|
186
|
+
* Parses a custom UTC offset string (e.g., "UTC+5:30", "UTC-3:45")
|
|
187
|
+
* @param input - The input string to parse
|
|
188
|
+
* @returns The parsed timezone value or null if invalid
|
|
189
|
+
*/
|
|
190
|
+
const parseCustomUTCOffset = (input) => {
|
|
191
|
+
// Match patterns like: UTC+5:30, UTC-3:45, UTC+1, UTC-12, etc.
|
|
192
|
+
// Also accepts single digit minutes which will be padded
|
|
193
|
+
const utcPattern = /^UTC([+-])?(\d{1,2})(?::(\d{1,2}))?$/i;
|
|
194
|
+
const match = input.trim().match(utcPattern);
|
|
195
|
+
if (!match)
|
|
196
|
+
return null;
|
|
197
|
+
const sign = match[1] === '-' ? '-' : '+';
|
|
198
|
+
const hours = parseInt(match[2], 10);
|
|
199
|
+
const minutes = match[3] ? parseInt(match[3], 10) : 0;
|
|
200
|
+
// Validate ranges based on sign
|
|
201
|
+
if (sign === '+') {
|
|
202
|
+
if (hours < 0 || hours > 14)
|
|
203
|
+
return null;
|
|
204
|
+
if (hours === 14 && minutes > 0)
|
|
205
|
+
return null; // UTC+14 is max
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// sign === '-'
|
|
209
|
+
if (hours < 0 || hours > 12)
|
|
210
|
+
return null; // UTC-12 is min
|
|
211
|
+
if (hours === 12 && minutes > 0)
|
|
212
|
+
return null; // UTC-12 is min
|
|
213
|
+
}
|
|
214
|
+
if (minutes < 0 || minutes > 59)
|
|
215
|
+
return null;
|
|
216
|
+
return `UTC${sign}${hours}${minutes > 0 ? `:${String(minutes).padStart(2, '0')}` : ''}`;
|
|
217
|
+
};
|
|
218
|
+
exports.parseCustomUTCOffset = parseCustomUTCOffset;
|
|
219
|
+
/**
|
|
220
|
+
* Validates if a string is a valid UTC timezone format
|
|
221
|
+
* @param input - The input string to validate
|
|
222
|
+
* @returns True if valid UTC timezone format
|
|
223
|
+
*/
|
|
224
|
+
const isValidUTCFormat = (input) => {
|
|
225
|
+
return (0, exports.parseCustomUTCOffset)(input) !== null || input.toUpperCase() === 'UTC';
|
|
226
|
+
};
|
|
227
|
+
exports.isValidUTCFormat = isValidUTCFormat;
|
|
228
|
+
/**
|
|
229
|
+
* Formats a timezone for display
|
|
230
|
+
* @param timezone - The IANA timezone identifier or UTC offset
|
|
231
|
+
* @param referenceDate - The date to use for calculating the offset (defaults to current date)
|
|
232
|
+
*/
|
|
233
|
+
const formatTimeZone = (timezone, referenceDate) => {
|
|
234
|
+
var _a, _b, _c;
|
|
235
|
+
// If it's already a UTC format, return as-is
|
|
236
|
+
if (timezone.toUpperCase().startsWith('UTC')) {
|
|
237
|
+
return timezone;
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const now = referenceDate || new Date();
|
|
241
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
242
|
+
timeZone: timezone,
|
|
243
|
+
timeZoneName: 'shortOffset',
|
|
244
|
+
});
|
|
245
|
+
const parts = formatter.formatToParts(now);
|
|
246
|
+
const offsetPart = parts.find((part) => part.type === 'timeZoneName');
|
|
247
|
+
const offset = (_a = offsetPart === null || offsetPart === void 0 ? void 0 : offsetPart.value) !== null && _a !== void 0 ? _a : '';
|
|
248
|
+
const cityName = (_c = (_b = timezone.split('/').pop()) === null || _b === void 0 ? void 0 : _b.replace(/_/g, ' ')) !== null && _c !== void 0 ? _c : timezone;
|
|
249
|
+
return `${cityName} (${offset})`;
|
|
250
|
+
}
|
|
251
|
+
catch (_d) {
|
|
252
|
+
return timezone.replace(/_/g, ' ');
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
exports.formatTimeZone = formatTimeZone;
|
|
256
|
+
//# sourceMappingURL=generate-timezone-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-timezone-options.js","s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,GAAG,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,mCAAI,EAAE,CAAC;QAEvC,MAAM,QAAQ,GAAG,MAAA,MAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,mCAAI,QAAQ,CAAC;QAC3E,OAAO,GAAG,QAAQ,KAAK,MAAM,GAAG,CAAC;IACnC,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,cAAc,kBAyBzB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport interface TimeZoneOption {\n value: string;\n label: string;\n offset: string;\n offsetMinutes: number;\n}\n\n/**\n * Gets the offset in minutes for a timezone at a specific date\n */\nconst getOffsetMinutes = (timezone: string, date: Date): number => {\n try {\n // Create dates in UTC and in the target timezone\n const utcDate = new Date(date.toLocaleString('en-US', { timeZone: 'UTC' }));\n const tzDate = new Date(\n date.toLocaleString('en-US', { timeZone: timezone }),\n );\n\n // Calculate the difference in minutes\n const diffMs = tzDate.getTime() - utcDate.getTime();\n return Math.round(diffMs / (1000 * 60));\n } catch {\n return 0;\n }\n};\n\n/**\n * Formats a UTC offset using the Intl API for consistent formatting\n * @param offsetHours - The offset in hours (can be fractional)\n * @returns Formatted UTC offset string (e.g., \"UTC+5:30\", \"UTC-3\")\n */\nconst formatUTCOffset = (offsetHours: number): string => {\n if (offsetHours === 0) {\n return 'UTC';\n }\n\n const sign = offsetHours >= 0 ? '+' : '-';\n const absHours = Math.abs(offsetHours);\n const hours = Math.floor(absHours);\n const minutes = Math.round((absHours - hours) * 60);\n\n // Use Intl.NumberFormat for consistent number formatting\n const numberFormatter = new Intl.NumberFormat('en-US', {\n maximumFractionDigits: 0,\n minimumIntegerDigits: 1,\n });\n\n const formattedHours = numberFormatter.format(hours);\n const formattedMinutes =\n minutes > 0 ? `:${String(minutes).padStart(2, '0')}` : '';\n\n return `UTC${sign}${formattedHours}${formattedMinutes}`;\n};\n\n/**\n * Extracts unique UTC offsets from all supported timezones using the Intl API\n * @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)\n * @returns Set of unique offset values in minutes\n */\nconst getUniqueOffsetsFromAPI = (referenceDate?: Date): Set<number> => {\n const uniqueOffsets = new Set<number>();\n const now = referenceDate || new Date();\n\n try {\n // Get all supported timezones from the Intl API\n const timezones = Intl.supportedValuesOf('timeZone');\n\n // Extract unique offsets from each timezone\n for (const tz of timezones) {\n try {\n const offsetMinutes = getOffsetMinutes(tz, now);\n uniqueOffsets.add(offsetMinutes);\n } catch {\n // Skip timezones that can't be processed\n continue;\n }\n }\n } catch {\n // Fallback to empty set if API is not available\n }\n\n // Always include UTC (offset 0)\n uniqueOffsets.add(0);\n\n return uniqueOffsets;\n};\n\n/**\n * Generates UTC-only timezone options derived from the Intl API\n * Uses the Intl API to discover which UTC offsets are actually used by supported timezones\n * @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)\n */\nexport const generateUTCTimeZoneOptions = (\n referenceDate?: Date,\n): TimeZoneOption[] => {\n // Get unique offsets from all supported timezones via the Intl API\n const uniqueOffsets = getUniqueOffsetsFromAPI(referenceDate);\n\n // Convert offset minutes to hours (can be fractional)\n const offsetHours = Array.from(uniqueOffsets)\n .map((minutes) => minutes / 60)\n .sort((a, b) => a - b);\n\n // Convert to TimeZoneOption format\n const options: TimeZoneOption[] = offsetHours.map((offsetHours) => {\n const offsetStr = formatUTCOffset(offsetHours);\n\n return {\n label: offsetStr,\n offset: offsetStr,\n offsetMinutes: Math.round(offsetHours * 60),\n value: offsetStr,\n };\n });\n\n return options;\n};\n\n/**\n * Generates a list of common timezone options with their UTC offsets\n * @param referenceDate - The date to use for calculating timezone offsets (defaults to current date)\n * @param excludeUTC - Whether to exclude the UTC timezone from the list (useful when combining with UTC-only options)\n */\nexport const generateTimeZoneOptions = (\n referenceDate?: Date,\n excludeUTC = false,\n): TimeZoneOption[] => {\n // Common timezones with their IANA identifiers\n const timezones = Intl.supportedValuesOf('timeZone');\n\n const now = referenceDate || new Date();\n\n // Filter out UTC if requested\n const filteredTimezones = excludeUTC\n ? timezones.filter((tz) => tz !== 'UTC')\n : timezones;\n\n return filteredTimezones\n .map((tz) => {\n try {\n // Get the offset for this timezone\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n timeZoneName: 'shortOffset',\n });\n\n const parts = formatter.formatToParts(now);\n const offsetPart = parts.find((part) => part.type === 'timeZoneName');\n const offset = offsetPart?.value ?? '';\n\n // Calculate offset in minutes for proper sorting\n const offsetMinutes = getOffsetMinutes(tz, now);\n\n // Format the label\n const cityName = tz.split('/').pop()?.replace(/_/g, ' ') ?? tz;\n const label = `${cityName} (${offset})`;\n\n return {\n label,\n offset,\n offsetMinutes,\n value: tz,\n };\n } catch {\n // Fallback if timezone is not supported\n return {\n label: tz.replace(/_/g, ' '),\n offset: '',\n offsetMinutes: 0,\n value: tz,\n };\n }\n })\n .sort((a, b) => {\n // Sort by offset (negative to positive), then by label\n if (a.offsetMinutes !== b.offsetMinutes) {\n return a.offsetMinutes - b.offsetMinutes;\n }\n\n return a.label.localeCompare(b.label);\n });\n};\n\n/**\n * Gets the user's current timezone\n */\nexport const getUserTimeZone = (): string => {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n } catch {\n return 'UTC';\n }\n};\n\n/**\n * Parses a custom UTC offset string (e.g., \"UTC+5:30\", \"UTC-3:45\")\n * @param input - The input string to parse\n * @returns The parsed timezone value or null if invalid\n */\nexport const parseCustomUTCOffset = (input: string): string | null => {\n // Match patterns like: UTC+5:30, UTC-3:45, UTC+1, UTC-12, etc.\n // Also accepts single digit minutes which will be padded\n const utcPattern = /^UTC([+-])?(\\d{1,2})(?::(\\d{1,2}))?$/i;\n const match = input.trim().match(utcPattern);\n\n if (!match) return null;\n\n const sign = match[1] === '-' ? '-' : '+';\n const hours = parseInt(match[2], 10);\n const minutes = match[3] ? parseInt(match[3], 10) : 0;\n\n // Validate ranges based on sign\n if (sign === '+') {\n if (hours < 0 || hours > 14) return null;\n if (hours === 14 && minutes > 0) return null; // UTC+14 is max\n } else {\n // sign === '-'\n if (hours < 0 || hours > 12) return null; // UTC-12 is min\n if (hours === 12 && minutes > 0) return null; // UTC-12 is min\n }\n\n if (minutes < 0 || minutes > 59) return null;\n\n return `UTC${sign}${hours}${minutes > 0 ? `:${String(minutes).padStart(2, '0')}` : ''}`;\n};\n\n/**\n * Validates if a string is a valid UTC timezone format\n * @param input - The input string to validate\n * @returns True if valid UTC timezone format\n */\nexport const isValidUTCFormat = (input: string): boolean => {\n return parseCustomUTCOffset(input) !== null || input.toUpperCase() === 'UTC';\n};\n\n/**\n * Formats a timezone for display\n * @param timezone - The IANA timezone identifier or UTC offset\n * @param referenceDate - The date to use for calculating the offset (defaults to current date)\n */\nexport const formatTimeZone = (\n timezone: string,\n referenceDate?: Date,\n): string => {\n // If it's already a UTC format, return as-is\n if (timezone.toUpperCase().startsWith('UTC')) {\n return timezone;\n }\n\n try {\n const now = referenceDate || new Date();\n const formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: timezone,\n timeZoneName: 'shortOffset',\n });\n\n const parts = formatter.formatToParts(now);\n const offsetPart = parts.find((part) => part.type === 'timeZoneName');\n const offset = offsetPart?.value ?? '';\n\n const cityName = timezone.split('/').pop()?.replace(/_/g, ' ') ?? timezone;\n return `${cityName} (${offset})`;\n } catch {\n return timezone.replace(/_/g, ' ');\n }\n};\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
34
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
__exportStar(require("./TimeZonePicker"), exports);
|
|
38
|
+
__exportStar(require("./generate-timezone-options"), exports);
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/timezone-picker/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AAEH,mDAAiC;AACjC,8DAA4C","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport * from './TimeZonePicker';\nexport * from './generate-timezone-options';\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) "Neo4j"
|
|
5
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Neo4j.
|
|
8
|
+
*
|
|
9
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
10
|
+
* it under the terms of the GNU General Public License as published by
|
|
11
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
12
|
+
* (at your option) any later version.
|
|
13
|
+
*
|
|
14
|
+
* This program is distributed in the hope that it will be useful,
|
|
15
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17
|
+
* GNU General Public License for more details.
|
|
18
|
+
*
|
|
19
|
+
* You should have received a copy of the GNU General Public License
|
|
20
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
21
|
+
*/
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TimeZonePickerInDialogSource = exports.TimeZonePickerBothModeSource = exports.TimeZonePickerUTCOnlySource = exports.TimeZonePickerDSTAwareSource = exports.TimeZonePickerDisabledSource = exports.TimeZonePickerSizesSource = exports.TimeZonePickerFluidSource = exports.TimeZonePickerDefaultSource = exports.TimeZonePickerInDialog = exports.TimeZonePickerBothMode = exports.TimeZonePickerUTCOnly = exports.TimeZonePickerDSTAware = exports.TimeZonePickerDisabled = exports.TimeZonePickerSizes = exports.TimeZonePickerFluid = exports.TimeZonePickerDefault = void 0;
|
|
27
|
+
var timezone_picker_default_story_1 = require("./timezone-picker-default.story");
|
|
28
|
+
Object.defineProperty(exports, "TimeZonePickerDefault", { enumerable: true, get: function () { return __importDefault(timezone_picker_default_story_1).default; } });
|
|
29
|
+
var timezone_picker_fluid_story_1 = require("./timezone-picker-fluid.story");
|
|
30
|
+
Object.defineProperty(exports, "TimeZonePickerFluid", { enumerable: true, get: function () { return __importDefault(timezone_picker_fluid_story_1).default; } });
|
|
31
|
+
var timezone_picker_sizes_story_1 = require("./timezone-picker-sizes.story");
|
|
32
|
+
Object.defineProperty(exports, "TimeZonePickerSizes", { enumerable: true, get: function () { return __importDefault(timezone_picker_sizes_story_1).default; } });
|
|
33
|
+
var timezone_picker_disabled_story_1 = require("./timezone-picker-disabled.story");
|
|
34
|
+
Object.defineProperty(exports, "TimeZonePickerDisabled", { enumerable: true, get: function () { return __importDefault(timezone_picker_disabled_story_1).default; } });
|
|
35
|
+
var timezone_picker_dst_aware_story_1 = require("./timezone-picker-dst-aware.story");
|
|
36
|
+
Object.defineProperty(exports, "TimeZonePickerDSTAware", { enumerable: true, get: function () { return __importDefault(timezone_picker_dst_aware_story_1).default; } });
|
|
37
|
+
var timezone_picker_utc_only_story_1 = require("./timezone-picker-utc-only.story");
|
|
38
|
+
Object.defineProperty(exports, "TimeZonePickerUTCOnly", { enumerable: true, get: function () { return __importDefault(timezone_picker_utc_only_story_1).default; } });
|
|
39
|
+
var timezone_picker_both_mode_story_1 = require("./timezone-picker-both-mode.story");
|
|
40
|
+
Object.defineProperty(exports, "TimeZonePickerBothMode", { enumerable: true, get: function () { return __importDefault(timezone_picker_both_mode_story_1).default; } });
|
|
41
|
+
var timezone_picker_in_dialog_story_1 = require("./timezone-picker-in-dialog.story");
|
|
42
|
+
Object.defineProperty(exports, "TimeZonePickerInDialog", { enumerable: true, get: function () { return __importDefault(timezone_picker_in_dialog_story_1).default; } });
|
|
43
|
+
const export_stories_utils_1 = require("@neo4j-ndl/react/_common/export-stories-utils");
|
|
44
|
+
const timezone_picker_both_mode_story_tsx_raw_1 = __importDefault(require("./timezone-picker-both-mode.story.tsx?raw"));
|
|
45
|
+
const timezone_picker_default_story_tsx_raw_1 = __importDefault(require("./timezone-picker-default.story.tsx?raw"));
|
|
46
|
+
const timezone_picker_disabled_story_tsx_raw_1 = __importDefault(require("./timezone-picker-disabled.story.tsx?raw"));
|
|
47
|
+
const timezone_picker_dst_aware_story_tsx_raw_1 = __importDefault(require("./timezone-picker-dst-aware.story.tsx?raw"));
|
|
48
|
+
const timezone_picker_fluid_story_tsx_raw_1 = __importDefault(require("./timezone-picker-fluid.story.tsx?raw"));
|
|
49
|
+
const timezone_picker_in_dialog_story_tsx_raw_1 = __importDefault(require("./timezone-picker-in-dialog.story.tsx?raw"));
|
|
50
|
+
const timezone_picker_sizes_story_tsx_raw_1 = __importDefault(require("./timezone-picker-sizes.story.tsx?raw"));
|
|
51
|
+
const timezone_picker_utc_only_story_tsx_raw_1 = __importDefault(require("./timezone-picker-utc-only.story.tsx?raw"));
|
|
52
|
+
exports.TimeZonePickerDefaultSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_default_story_tsx_raw_1.default);
|
|
53
|
+
exports.TimeZonePickerFluidSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_fluid_story_tsx_raw_1.default);
|
|
54
|
+
exports.TimeZonePickerSizesSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_sizes_story_tsx_raw_1.default);
|
|
55
|
+
exports.TimeZonePickerDisabledSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_disabled_story_tsx_raw_1.default);
|
|
56
|
+
exports.TimeZonePickerDSTAwareSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_dst_aware_story_tsx_raw_1.default);
|
|
57
|
+
exports.TimeZonePickerUTCOnlySource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_utc_only_story_tsx_raw_1.default);
|
|
58
|
+
exports.TimeZonePickerBothModeSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_both_mode_story_tsx_raw_1.default);
|
|
59
|
+
exports.TimeZonePickerInDialogSource = (0, export_stories_utils_1.removeLicenseHeader)(timezone_picker_in_dialog_story_tsx_raw_1.default);
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;AAEH,iFAAmF;AAA1E,uJAAA,OAAO,OAAyB;AACzC,6EAA+E;AAAtE,mJAAA,OAAO,OAAuB;AACvC,6EAA+E;AAAtE,mJAAA,OAAO,OAAuB;AACvC,mFAAqF;AAA5E,yJAAA,OAAO,OAA0B;AAC1C,qFAAsF;AAA7E,0JAAA,OAAO,OAA0B;AAC1C,mFAAoF;AAA3E,wJAAA,OAAO,OAAyB;AACzC,qFAAsF;AAA7E,0JAAA,OAAO,OAA0B;AAC1C,qFAAsF;AAA7E,0JAAA,OAAO,OAA0B;AAE1C,wFAAoF;AAEpF,wHAAwF;AACxF,oHAAqF;AACrF,sHAAuF;AACvF,wHAAwF;AACxF,gHAAiF;AACjF,wHAAwF;AACxF,gHAAiF;AACjF,sHAAsF;AAEzE,QAAA,2BAA2B,GAAG,IAAA,0CAAmB,EAC5D,+CAA8B,CAC/B,CAAC;AACW,QAAA,yBAAyB,GAAG,IAAA,0CAAmB,EAC1D,6CAA4B,CAC7B,CAAC;AACW,QAAA,yBAAyB,GAAG,IAAA,0CAAmB,EAC1D,6CAA4B,CAC7B,CAAC;AACW,QAAA,4BAA4B,GAAG,IAAA,0CAAmB,EAC7D,gDAA+B,CAChC,CAAC;AACW,QAAA,4BAA4B,GAAG,IAAA,0CAAmB,EAC7D,iDAA+B,CAChC,CAAC;AACW,QAAA,2BAA2B,GAAG,IAAA,0CAAmB,EAC5D,gDAA8B,CAC/B,CAAC;AACW,QAAA,4BAA4B,GAAG,IAAA,0CAAmB,EAC7D,iDAA+B,CAChC,CAAC;AACW,QAAA,4BAA4B,GAAG,IAAA,0CAAmB,EAC7D,iDAA+B,CAChC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport { default as TimeZonePickerDefault } from './timezone-picker-default.story';\nexport { default as TimeZonePickerFluid } from './timezone-picker-fluid.story';\nexport { default as TimeZonePickerSizes } from './timezone-picker-sizes.story';\nexport { default as TimeZonePickerDisabled } from './timezone-picker-disabled.story';\nexport { default as TimeZonePickerDSTAware } from './timezone-picker-dst-aware.story';\nexport { default as TimeZonePickerUTCOnly } from './timezone-picker-utc-only.story';\nexport { default as TimeZonePickerBothMode } from './timezone-picker-both-mode.story';\nexport { default as TimeZonePickerInDialog } from './timezone-picker-in-dialog.story';\n\nimport { removeLicenseHeader } from '@neo4j-ndl/react/_common/export-stories-utils';\n\nimport TimeZonePickerBothModeSourceRaw from './timezone-picker-both-mode.story.tsx?raw';\nimport TimeZonePickerDefaultSourceRaw from './timezone-picker-default.story.tsx?raw';\nimport TimeZonePickerDisabledSourceRaw from './timezone-picker-disabled.story.tsx?raw';\nimport TimeZonePickerDSTAwareSourceRaw from './timezone-picker-dst-aware.story.tsx?raw';\nimport TimeZonePickerFluidSourceRaw from './timezone-picker-fluid.story.tsx?raw';\nimport TimeZonePickerInDialogSourceRaw from './timezone-picker-in-dialog.story.tsx?raw';\nimport TimeZonePickerSizesSourceRaw from './timezone-picker-sizes.story.tsx?raw';\nimport TimeZonePickerUTCOnlySourceRaw from './timezone-picker-utc-only.story.tsx?raw';\n\nexport const TimeZonePickerDefaultSource = removeLicenseHeader(\n TimeZonePickerDefaultSourceRaw,\n);\nexport const TimeZonePickerFluidSource = removeLicenseHeader(\n TimeZonePickerFluidSourceRaw,\n);\nexport const TimeZonePickerSizesSource = removeLicenseHeader(\n TimeZonePickerSizesSourceRaw,\n);\nexport const TimeZonePickerDisabledSource = removeLicenseHeader(\n TimeZonePickerDisabledSourceRaw,\n);\nexport const TimeZonePickerDSTAwareSource = removeLicenseHeader(\n TimeZonePickerDSTAwareSourceRaw,\n);\nexport const TimeZonePickerUTCOnlySource = removeLicenseHeader(\n TimeZonePickerUTCOnlySourceRaw,\n);\nexport const TimeZonePickerBothModeSource = removeLicenseHeader(\n TimeZonePickerBothModeSourceRaw,\n);\nexport const TimeZonePickerInDialogSource = removeLicenseHeader(\n TimeZonePickerInDialogSourceRaw,\n);\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeZonePickerBothMode = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) "Neo4j"
|
|
8
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
9
|
+
*
|
|
10
|
+
* This file is part of Neo4j.
|
|
11
|
+
*
|
|
12
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
13
|
+
* it under the terms of the GNU General Public License as published by
|
|
14
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
15
|
+
* (at your option) any later version.
|
|
16
|
+
*
|
|
17
|
+
* This program is distributed in the hope that it will be useful,
|
|
18
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
+
* GNU General Public License for more details.
|
|
21
|
+
*
|
|
22
|
+
* You should have received a copy of the GNU General Public License
|
|
23
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24
|
+
*/
|
|
25
|
+
const react_1 = require("react");
|
|
26
|
+
const typography_1 = require("../../typography");
|
|
27
|
+
const TimeZonePicker_1 = require("../TimeZonePicker");
|
|
28
|
+
const TimeZonePickerBothMode = () => {
|
|
29
|
+
const [selectedTimezone, setSelectedTimezone] = (0, react_1.useState)('America/New_York');
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { maxWidth: '400px', padding: '20px' }, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "title-4", style: { marginBottom: '16px' }, children: "Both Mode - UTC and City-Based Timezones" }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", style: { marginBottom: '24px' }, children: "This mode displays both UTC offsets and city-based timezones in separate sections within the dropdown. Perfect for users who need flexibility in choosing between precise UTC offsets or familiar city names." }), (0, jsx_runtime_1.jsx)(TimeZonePicker_1.TimeZonePicker, { label: "Select Timezone", mode: "both", value: selectedTimezone, onChange: (tz) => {
|
|
31
|
+
setSelectedTimezone(tz);
|
|
32
|
+
} }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
33
|
+
backgroundColor: '#f5f5f5',
|
|
34
|
+
borderRadius: '4px',
|
|
35
|
+
marginTop: '24px',
|
|
36
|
+
padding: '16px',
|
|
37
|
+
}, children: [(0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-small", style: { fontWeight: 600, marginBottom: '8px' }, children: "Selected Timezone:" }), (0, jsx_runtime_1.jsx)(typography_1.Typography, { variant: "body-medium", children: selectedTimezone || 'None' })] }), (0, jsx_runtime_1.jsx)("div", { style: { marginTop: '16px' }, children: (0, jsx_runtime_1.jsxs)(typography_1.Typography, { variant: "body-small", style: { color: '#666' }, children: [(0, jsx_runtime_1.jsx)("strong", { children: "Features:" }), (0, jsx_runtime_1.jsxs)("ul", { style: { marginTop: '8px', paddingLeft: '20px' }, children: [(0, jsx_runtime_1.jsx)("li", { children: "Two separate sections: \"UTC Offsets\" and \"City-Based Timezones\"" }), (0, jsx_runtime_1.jsx)("li", { children: "Search across both sections simultaneously" }), (0, jsx_runtime_1.jsx)("li", { children: "Custom UTC input support (e.g., UTC+5:30)" }), (0, jsx_runtime_1.jsx)("li", { children: "All standard UTC offsets from UTC-12 to UTC+14" }), (0, jsx_runtime_1.jsx)("li", { children: "All IANA timezone identifiers with city names" })] })] }) })] }));
|
|
38
|
+
};
|
|
39
|
+
exports.TimeZonePickerBothMode = TimeZonePickerBothMode;
|
|
40
|
+
exports.default = exports.TimeZonePickerBothMode;
|
|
41
|
+
//# sourceMappingURL=timezone-picker-both-mode.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-both-mode.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-both-mode.story.tsx"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,iCAAiC;AAEjC,iDAA8C;AAC9C,sDAAmD;AAE5C,MAAM,sBAAsB,GAAG,GAAG,EAAE;IACzC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,IAAA,gBAAQ,EAAS,kBAAkB,CAAC,CAAC;IAEvC,OAAO,CACL,iCAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAChD,uBAAC,uBAAU,IAAC,OAAO,EAAC,SAAS,EAAC,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,yDAEhD,EACb,uBAAC,uBAAU,IAAC,OAAO,EAAC,aAAa,EAAC,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,8NAIpD,EAEb,uBAAC,+BAAc,IACb,KAAK,EAAC,iBAAiB,EACvB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE;oBACf,mBAAmB,CAAC,EAAE,CAAC,CAAC;gBAC1B,CAAC,GACD,EAEF,iCACE,KAAK,EAAE;oBACL,eAAe,EAAE,SAAS;oBAC1B,YAAY,EAAE,KAAK;oBACnB,SAAS,EAAE,MAAM;oBACjB,OAAO,EAAE,MAAM;iBAChB,aAED,uBAAC,uBAAU,IACT,OAAO,EAAC,YAAY,EACpB,KAAK,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,mCAGpC,EACb,uBAAC,uBAAU,IAAC,OAAO,EAAC,aAAa,YAC9B,gBAAgB,IAAI,MAAM,GAChB,IACT,EAEN,gCAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAC/B,wBAAC,uBAAU,IAAC,OAAO,EAAC,YAAY,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,aACvD,2DAA0B,EAC1B,gCAAI,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAClD,iHAGK,EACL,wFAAmD,EACnD,uFAAkD,EAClD,4FAAuD,EACvD,2FAAsD,IACnD,IACM,GACT,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AA5DW,QAAA,sBAAsB,0BA4DjC;AAEF,kBAAe,8BAAsB,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { useState } from 'react';\n\nimport { Typography } from '../../typography';\nimport { TimeZonePicker } from '../TimeZonePicker';\n\nexport const TimeZonePickerBothMode = () => {\n const [selectedTimezone, setSelectedTimezone] =\n useState<string>('America/New_York');\n\n return (\n <div style={{ maxWidth: '400px', padding: '20px' }}>\n <Typography variant=\"title-4\" style={{ marginBottom: '16px' }}>\n Both Mode - UTC and City-Based Timezones\n </Typography>\n <Typography variant=\"body-medium\" style={{ marginBottom: '24px' }}>\n This mode displays both UTC offsets and city-based timezones in separate\n sections within the dropdown. Perfect for users who need flexibility in\n choosing between precise UTC offsets or familiar city names.\n </Typography>\n\n <TimeZonePicker\n label=\"Select Timezone\"\n mode=\"both\"\n value={selectedTimezone}\n onChange={(tz) => {\n setSelectedTimezone(tz);\n }}\n />\n\n <div\n style={{\n backgroundColor: '#f5f5f5',\n borderRadius: '4px',\n marginTop: '24px',\n padding: '16px',\n }}\n >\n <Typography\n variant=\"body-small\"\n style={{ fontWeight: 600, marginBottom: '8px' }}\n >\n Selected Timezone:\n </Typography>\n <Typography variant=\"body-medium\">\n {selectedTimezone || 'None'}\n </Typography>\n </div>\n\n <div style={{ marginTop: '16px' }}>\n <Typography variant=\"body-small\" style={{ color: '#666' }}>\n <strong>Features:</strong>\n <ul style={{ marginTop: '8px', paddingLeft: '20px' }}>\n <li>\n Two separate sections: "UTC Offsets" and\n "City-Based Timezones"\n </li>\n <li>Search across both sections simultaneously</li>\n <li>Custom UTC input support (e.g., UTC+5:30)</li>\n <li>All standard UTC offsets from UTC-12 to UTC+14</li>\n <li>All IANA timezone identifiers with city names</li>\n </ul>\n </Typography>\n </div>\n </div>\n );\n};\n\nexport default TimeZonePickerBothMode;\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const react_2 = require("react");
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('UTC');
|
|
29
|
+
const handleTimeZoneChange = (timezone) => {
|
|
30
|
+
setSelectedTimeZone(timezone);
|
|
31
|
+
};
|
|
32
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Select Timezone", value: selectedTimeZone, onChange: handleTimeZoneChange }), (0, jsx_runtime_1.jsx)("div", { style: { marginTop: '1rem' }, children: (0, jsx_runtime_1.jsxs)("p", { children: ["Selected Timezone: ", selectedTimeZone] }) })] }));
|
|
33
|
+
};
|
|
34
|
+
exports.default = Component;
|
|
35
|
+
//# sourceMappingURL=timezone-picker-default.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-default.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-default.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,IAAA,gBAAQ,EAAS,KAAK,CAAC,CAAC;IAExE,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE;QAChD,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO,CACL,4CACE,uBAAC,sBAAc,IACb,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,oBAAoB,GAC9B,EACF,gCAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,YAC/B,iEAAuB,gBAAgB,IAAK,GACxC,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] = useState<string>('UTC');\n\n const handleTimeZoneChange = (timezone: string) => {\n setSelectedTimeZone(timezone);\n };\n\n return (\n <div>\n <TimeZonePicker\n label=\"Select Timezone\"\n value={selectedTimeZone}\n onChange={handleTimeZoneChange}\n />\n <div style={{ marginTop: '1rem' }}>\n <p>Selected Timezone: {selectedTimeZone}</p>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const Component = () => {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Disabled Timezone Picker", value: "Asia/Tokyo", isDisabled: true }));
|
|
28
|
+
};
|
|
29
|
+
exports.default = Component;
|
|
30
|
+
//# sourceMappingURL=timezone-picker-disabled.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-disabled.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-disabled.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAElD,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,OAAO,CACL,uBAAC,sBAAc,IACb,KAAK,EAAC,0BAA0B,EAChC,KAAK,EAAC,YAAY,EAClB,UAAU,SACV,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\n\nconst Component = () => {\n return (\n <TimeZonePicker\n label=\"Disabled Timezone Picker\"\n value=\"Asia/Tokyo\"\n isDisabled\n />\n );\n};\n\nexport default Component;\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) "Neo4j"
|
|
7
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
8
|
+
*
|
|
9
|
+
* This file is part of Neo4j.
|
|
10
|
+
*
|
|
11
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
12
|
+
* it under the terms of the GNU General Public License as published by
|
|
13
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
* (at your option) any later version.
|
|
15
|
+
*
|
|
16
|
+
* This program is distributed in the hope that it will be useful,
|
|
17
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
* GNU General Public License for more details.
|
|
20
|
+
*
|
|
21
|
+
* You should have received a copy of the GNU General Public License
|
|
22
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
require("@neo4j-ndl/base/lib/neo4j-ds-styles.css");
|
|
25
|
+
const react_1 = require("@neo4j-ndl/react");
|
|
26
|
+
const react_2 = require("react");
|
|
27
|
+
const Component = () => {
|
|
28
|
+
const [selectedTimeZone, setSelectedTimeZone] = (0, react_2.useState)('Europe/Stockholm');
|
|
29
|
+
const [referenceDate, setReferenceDate] = (0, react_2.useState)(new Date());
|
|
30
|
+
// Create summer and winter dates for DST demonstration
|
|
31
|
+
const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)
|
|
32
|
+
const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { marginBottom: '1rem' }, children: "DST-Aware Timezone Picker Demo" }), (0, jsx_runtime_1.jsx)("p", { style: { marginBottom: '1rem', color: '#666' }, children: "The timezone offsets change based on the reference date to account for Daylight Saving Time." })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '1rem', marginBottom: '1rem' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setReferenceDate(summerDate), style: {
|
|
34
|
+
padding: '0.5rem 1rem',
|
|
35
|
+
border: '1px solid #ccc',
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
cursor: 'pointer',
|
|
38
|
+
backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',
|
|
39
|
+
color: referenceDate === summerDate ? 'white' : 'black',
|
|
40
|
+
}, children: "Summer Date (July 15, 2024)" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => setReferenceDate(winterDate), style: {
|
|
41
|
+
padding: '0.5rem 1rem',
|
|
42
|
+
border: '1px solid #ccc',
|
|
43
|
+
borderRadius: '4px',
|
|
44
|
+
cursor: 'pointer',
|
|
45
|
+
backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',
|
|
46
|
+
color: referenceDate === winterDate ? 'white' : 'black',
|
|
47
|
+
}, children: "Winter Date (January 15, 2024)" })] }), (0, jsx_runtime_1.jsx)(react_1.TimeZonePicker, { label: "Select Timezone", value: selectedTimeZone, onChange: setSelectedTimeZone, referenceDate: referenceDate }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
48
|
+
backgroundColor: '#f5f5f5',
|
|
49
|
+
borderRadius: '4px',
|
|
50
|
+
padding: '1rem',
|
|
51
|
+
}, children: [(0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Selected Timezone:" }), " ", selectedTimeZone] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Reference Date:" }), " ", referenceDate.toLocaleDateString()] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Example:" }), " New York shows GMT-4 in summer (EDT) and GMT-5 in winter (EST)"] })] })] }));
|
|
52
|
+
};
|
|
53
|
+
exports.default = Component;
|
|
54
|
+
//# sourceMappingURL=timezone-picker-dst-aware.story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-picker-dst-aware.story.js","sourceRoot":"","sources":["../../../../src/timezone-picker/stories/timezone-picker-dst-aware.story.tsx"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,mDAAiD;AAEjD,4CAAkD;AAClD,iCAAiC;AAEjC,MAAM,SAAS,GAAG,GAAG,EAAE;IACrB,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,IAAA,gBAAQ,EAAS,kBAAkB,CAAC,CAAC;IACvC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAO,IAAI,IAAI,EAAE,CAAC,CAAC;IAErE,uDAAuD;IACvD,MAAM,UAAU,GAAG,IAAI,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AAC,OAAO;yBACxD,+CAGM,IACL,EAEN,uBAAC,sBAAc,IACb,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,aAAa,GAC5B,EAEF,iCACE,KAAK,EAAE;oBACL,eAAe,EAAE,SAAS;oBAC1B,YAAY,EAAE,KAAK;oBAEnB,OAAO,EAAE,MAAM;iBAChB,aAED,0CACE,oEAAmC,OAAE,gBAAgB,IACnD,EACJ,0CACE,iEAAgC,OAAE,aAAa,CAAC,kBAAkB,EAAE,IAClE,EACJ,0CACE,0DAAyB,uEAEvB,IACA,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,SAAS,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport '@neo4j-ndl/base/lib/neo4j-ds-styles.css';\n\nimport { TimeZonePicker } from '@neo4j-ndl/react';\nimport { useState } from 'react';\n\nconst Component = () => {\n const [selectedTimeZone, setSelectedTimeZone] =\n useState<string>('Europe/Stockholm');\n const [referenceDate, setReferenceDate] = useState<Date>(new Date());\n\n // Create summer and winter dates for DST demonstration\n const summerDate = new Date('2024-07-15T12:00:00'); // July (DST in effect)\n const winterDate = new Date('2024-01-15T12:00:00'); // January (Standard time)\n\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>\n <div>\n <h3 style={{ marginBottom: '1rem' }}>DST-Aware Timezone Picker Demo</h3>\n <p style={{ marginBottom: '1rem', color: '#666' }}>\n The timezone offsets change based on the reference date to account for\n Daylight Saving Time.\n </p>\n </div>\n\n <div style={{ display: 'flex', gap: '1rem', marginBottom: '1rem' }}>\n <button\n onClick={() => setReferenceDate(summerDate)}\n style={{\n padding: '0.5rem 1rem',\n border: '1px solid #ccc',\n borderRadius: '4px',\n cursor: 'pointer',\n backgroundColor: referenceDate === summerDate ? '#0066cc' : 'white',\n color: referenceDate === summerDate ? 'white' : 'black',\n }}\n >\n Summer Date (July 15, 2024)\n </button>\n <button\n onClick={() => setReferenceDate(winterDate)}\n style={{\n padding: '0.5rem 1rem',\n border: '1px solid #ccc',\n borderRadius: '4px',\n cursor: 'pointer',\n backgroundColor: referenceDate === winterDate ? '#0066cc' : 'white',\n color: referenceDate === winterDate ? 'white' : 'black',\n }}\n >\n Winter Date (January 15, 2024)\n </button>\n </div>\n\n <TimeZonePicker\n label=\"Select Timezone\"\n value={selectedTimeZone}\n onChange={setSelectedTimeZone}\n referenceDate={referenceDate}\n />\n\n <div\n style={{\n backgroundColor: '#f5f5f5',\n borderRadius: '4px',\n\n padding: '1rem',\n }}\n >\n <p>\n <strong>Selected Timezone:</strong> {selectedTimeZone}\n </p>\n <p>\n <strong>Reference Date:</strong> {referenceDate.toLocaleDateString()}\n </p>\n <p>\n <strong>Example:</strong> New York shows GMT-4 in summer (EDT) and\n GMT-5 in winter (EST)\n </p>\n </div>\n </div>\n );\n};\n\nexport default Component;\n"]}
|