@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260505044510 → 0.8.1-dev.20260505094649
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DateViewClient-Y4J3UH4R.mjs +116 -0
- package/dist/index.js +67 -187
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/DateViewClient-UCGTXQNC.mjs +0 -231
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/controls/view/DateViewClient.tsx
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var DateViewClient = (props) => {
|
|
7
|
+
const [timeZoneAbbr, setTimeZoneAbbr] = useState("");
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const parts = new Intl.DateTimeFormat("en", {
|
|
10
|
+
timeZoneName: "short"
|
|
11
|
+
}).formatToParts(/* @__PURE__ */ new Date());
|
|
12
|
+
const abbr = parts.find((part) => part.type === "timeZoneName")?.value || "";
|
|
13
|
+
setTimeZoneAbbr(abbr);
|
|
14
|
+
}, []);
|
|
15
|
+
const toUtcDate = (dateString) => {
|
|
16
|
+
const s = dateString.trim();
|
|
17
|
+
if (!s) {
|
|
18
|
+
throw new Error("Empty date string");
|
|
19
|
+
}
|
|
20
|
+
const iso = s.replace(" ", "T");
|
|
21
|
+
const hasTimeZone = /Z$/i.test(iso) || /[+-]\d{2}:\d{2}$/.test(iso);
|
|
22
|
+
const utc = hasTimeZone ? iso : `${iso}Z`;
|
|
23
|
+
const date = new Date(utc);
|
|
24
|
+
if (Number.isNaN(date.getTime())) {
|
|
25
|
+
throw new Error(`Invalid date: ${dateString}`);
|
|
26
|
+
}
|
|
27
|
+
return date;
|
|
28
|
+
};
|
|
29
|
+
const formatDate = (date) => {
|
|
30
|
+
return new Intl.DateTimeFormat("en", {
|
|
31
|
+
day: "2-digit",
|
|
32
|
+
month: "short",
|
|
33
|
+
year: "numeric"
|
|
34
|
+
}).format(date);
|
|
35
|
+
};
|
|
36
|
+
const formatTime = (date) => {
|
|
37
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
38
|
+
hour: "2-digit",
|
|
39
|
+
minute: "2-digit"
|
|
40
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
41
|
+
hour: "2-digit",
|
|
42
|
+
minute: "2-digit",
|
|
43
|
+
second: "2-digit"
|
|
44
|
+
}).format(date);
|
|
45
|
+
};
|
|
46
|
+
const formatDateTime = (date) => {
|
|
47
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
48
|
+
day: "2-digit",
|
|
49
|
+
month: "short",
|
|
50
|
+
year: "numeric",
|
|
51
|
+
hour: "2-digit",
|
|
52
|
+
minute: "2-digit"
|
|
53
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
54
|
+
day: "2-digit",
|
|
55
|
+
month: "short",
|
|
56
|
+
year: "numeric",
|
|
57
|
+
hour: "2-digit",
|
|
58
|
+
minute: "2-digit",
|
|
59
|
+
second: "2-digit"
|
|
60
|
+
}).format(date);
|
|
61
|
+
};
|
|
62
|
+
const getTimePeriod = (date) => {
|
|
63
|
+
const hours = date.getHours();
|
|
64
|
+
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
65
|
+
if (hours >= 8 && hours < 12) return "Morning";
|
|
66
|
+
if (hours >= 12 && hours < 14) return "Noon";
|
|
67
|
+
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
68
|
+
if (hours >= 17 && hours < 20) return "Evening";
|
|
69
|
+
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
70
|
+
return "Night";
|
|
71
|
+
};
|
|
72
|
+
const getRelativeTime = (dateString) => {
|
|
73
|
+
const now = /* @__PURE__ */ new Date();
|
|
74
|
+
const utcDate = toUtcDate(dateString);
|
|
75
|
+
const diffMs = now.getTime() - utcDate.getTime();
|
|
76
|
+
const diffSec = Math.floor(diffMs / 1e3);
|
|
77
|
+
const diffMin = Math.floor(diffSec / 60);
|
|
78
|
+
const diffHr = Math.floor(diffMin / 60);
|
|
79
|
+
const diffDay = Math.floor(diffHr / 24);
|
|
80
|
+
if (diffSec < 60) return "Just now";
|
|
81
|
+
if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
|
|
82
|
+
if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
|
|
83
|
+
if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
|
|
84
|
+
return formatDate(utcDate);
|
|
85
|
+
};
|
|
86
|
+
const parseAndFormatDate = (dateString, format) => {
|
|
87
|
+
if (format === "relative") {
|
|
88
|
+
return getRelativeTime(dateString);
|
|
89
|
+
}
|
|
90
|
+
const utcDate = toUtcDate(dateString);
|
|
91
|
+
switch (props.controlType) {
|
|
92
|
+
case "date":
|
|
93
|
+
return formatDate(utcDate);
|
|
94
|
+
case "time":
|
|
95
|
+
return `${formatTime(utcDate)} ${timeZoneAbbr} (${getTimePeriod(
|
|
96
|
+
utcDate
|
|
97
|
+
)})`;
|
|
98
|
+
default:
|
|
99
|
+
return formatDateTime(utcDate);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
let localDateTime = "";
|
|
103
|
+
try {
|
|
104
|
+
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error("Error parsing date:", props.value, error);
|
|
107
|
+
}
|
|
108
|
+
return /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
|
|
109
|
+
/* @__PURE__ */ jsx("span", { children: localDateTime }),
|
|
110
|
+
!props.format && props.controlType !== "date" && timeZoneAbbr && /* @__PURE__ */ jsx("span", { children: timeZoneAbbr })
|
|
111
|
+
] });
|
|
112
|
+
};
|
|
113
|
+
var DateViewClient_default = DateViewClient;
|
|
114
|
+
export {
|
|
115
|
+
DateViewClient_default as default
|
|
116
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -30,128 +30,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/components/controls/view/TimeZoneAbbrevations.tsx
|
|
34
|
-
var timeZoneAbbreviations;
|
|
35
|
-
var init_TimeZoneAbbrevations = __esm({
|
|
36
|
-
"src/components/controls/view/TimeZoneAbbrevations.tsx"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
timeZoneAbbreviations = {
|
|
39
|
-
"Asia/Calcutta": "IST",
|
|
40
|
-
"Asia/Kolkata": "IST",
|
|
41
|
-
"America/New_York": "EST",
|
|
42
|
-
"America/Los_Angeles": "PST",
|
|
43
|
-
"Europe/London": "GMT",
|
|
44
|
-
"Europe/Paris": "CET",
|
|
45
|
-
"Asia/Tokyo": "JST",
|
|
46
|
-
"America/Chicago": "CST",
|
|
47
|
-
"America/Denver": "MST",
|
|
48
|
-
"Asia/Shanghai": "CST",
|
|
49
|
-
"Asia/Hong_Kong": "HKT",
|
|
50
|
-
"Australia/Sydney": "AEST",
|
|
51
|
-
"Australia/Melbourne": "AEST",
|
|
52
|
-
"Australia/Perth": "AWST",
|
|
53
|
-
"Pacific/Auckland": "NZST",
|
|
54
|
-
"Europe/Berlin": "CET",
|
|
55
|
-
"Europe/Madrid": "CET",
|
|
56
|
-
"Europe/Rome": "CET",
|
|
57
|
-
"Europe/Athens": "EET",
|
|
58
|
-
"Europe/Istanbul": "TRT",
|
|
59
|
-
"Africa/Cairo": "EET",
|
|
60
|
-
"Africa/Johannesburg": "SAST",
|
|
61
|
-
"Asia/Dubai": "GST",
|
|
62
|
-
"Asia/Singapore": "SGT",
|
|
63
|
-
"Asia/Seoul": "KST",
|
|
64
|
-
"America/Toronto": "EST",
|
|
65
|
-
"America/Vancouver": "PST",
|
|
66
|
-
"America/Sao_Paulo": "BRT",
|
|
67
|
-
"America/Mexico_City": "CST",
|
|
68
|
-
"Asia/Manila": "PHT",
|
|
69
|
-
"Asia/Jakarta": "WIB",
|
|
70
|
-
"Asia/Bangkok": "ICT",
|
|
71
|
-
"Asia/Karachi": "PKT",
|
|
72
|
-
"Asia/Tehran": "IRST",
|
|
73
|
-
"Asia/Baghdad": "AST",
|
|
74
|
-
"Europe/Moscow": "MSK",
|
|
75
|
-
"Europe/Amsterdam": "CET",
|
|
76
|
-
"Europe/Brussels": "CET",
|
|
77
|
-
"Europe/Zurich": "CET",
|
|
78
|
-
"America/Anchorage": "AKST",
|
|
79
|
-
"Pacific/Honolulu": "HST",
|
|
80
|
-
"Antarctica/McMurdo": "NZST",
|
|
81
|
-
"Atlantic/Reykjavik": "GMT",
|
|
82
|
-
"Asia/Riyadh": "AST",
|
|
83
|
-
"America/Argentina/Buenos_Aires": "ART",
|
|
84
|
-
"America/Bogota": "COT",
|
|
85
|
-
"Africa/Nairobi": "EAT",
|
|
86
|
-
"Asia/Kuala_Lumpur": "MYT",
|
|
87
|
-
"Asia/Ho_Chi_Minh": "ICT",
|
|
88
|
-
"Europe/Warsaw": "CET",
|
|
89
|
-
"Europe/Prague": "CET",
|
|
90
|
-
"America/Phoenix": "MST",
|
|
91
|
-
"America/Indianapolis": "EST",
|
|
92
|
-
"Pacific/Fiji": "FJT",
|
|
93
|
-
"Asia/Colombo": "IST",
|
|
94
|
-
"Africa/Lagos": "WAT",
|
|
95
|
-
"America/Caracas": "VET",
|
|
96
|
-
"America/Halifax": "AST",
|
|
97
|
-
"Pacific/Tahiti": "TAHT",
|
|
98
|
-
"America/St_Johns": "NST",
|
|
99
|
-
"Europe/Bucharest": "EET",
|
|
100
|
-
"Europe/Helsinki": "EET",
|
|
101
|
-
"Europe/Kiev": "EET",
|
|
102
|
-
"Europe/Oslo": "CET",
|
|
103
|
-
"Europe/Stockholm": "CET",
|
|
104
|
-
"Europe/Lisbon": "WET",
|
|
105
|
-
"Asia/Beirut": "EET",
|
|
106
|
-
"Asia/Damascus": "EET",
|
|
107
|
-
"Asia/Jerusalem": "IST",
|
|
108
|
-
"Asia/Amman": "EET",
|
|
109
|
-
"America/Santiago": "CLT",
|
|
110
|
-
"America/Lima": "PET",
|
|
111
|
-
"America/Montevideo": "UYT",
|
|
112
|
-
"Asia/Tashkent": "UZT",
|
|
113
|
-
"Asia/Yerevan": "AMT",
|
|
114
|
-
"Asia/Baku": "AZT",
|
|
115
|
-
"Europe/Vilnius": "EET",
|
|
116
|
-
"Europe/Riga": "EET",
|
|
117
|
-
"Europe/Tallinn": "EET",
|
|
118
|
-
"Europe/Sofia": "EET",
|
|
119
|
-
"Africa/Casablanca": "WET",
|
|
120
|
-
"America/Guatemala": "CST",
|
|
121
|
-
"America/Panama": "EST",
|
|
122
|
-
"America/Costa_Rica": "CST",
|
|
123
|
-
"Pacific/Port_Moresby": "PGT",
|
|
124
|
-
"Asia/Makassar": "WITA",
|
|
125
|
-
"Asia/Vladivostok": "VLAT",
|
|
126
|
-
"Asia/Krasnoyarsk": "KRAT",
|
|
127
|
-
"Asia/Novosibirsk": "NOVT",
|
|
128
|
-
"Asia/Yakutsk": "YAKT",
|
|
129
|
-
"Asia/Sakhalin": "SAKT",
|
|
130
|
-
"Asia/Ulaanbaatar": "ULAT",
|
|
131
|
-
"Asia/Choibalsan": "CHOT",
|
|
132
|
-
"Asia/Omsk": "OMST",
|
|
133
|
-
"Asia/Kamchatka": "PETT",
|
|
134
|
-
"Pacific/Pago_Pago": "SST",
|
|
135
|
-
"Pacific/Guam": "ChST",
|
|
136
|
-
"Pacific/Saipan": "ChST",
|
|
137
|
-
"Pacific/Palau": "PWT",
|
|
138
|
-
"Pacific/Efate": "VUT",
|
|
139
|
-
"Pacific/Kosrae": "KOST",
|
|
140
|
-
"Pacific/Nauru": "NRT",
|
|
141
|
-
"Pacific/Tarawa": "GILT",
|
|
142
|
-
"Pacific/Enderbury": "PHOT",
|
|
143
|
-
"Pacific/Fakaofo": "TKT",
|
|
144
|
-
"Pacific/Chatham": "CHAST",
|
|
145
|
-
"Pacific/Tongatapu": "TOT",
|
|
146
|
-
"Pacific/Funafuti": "TVT",
|
|
147
|
-
"Pacific/Majuro": "MHT",
|
|
148
|
-
"Pacific/Kwajalein": "MHT",
|
|
149
|
-
"Pacific/Wake": "WAKT",
|
|
150
|
-
"Pacific/Wallis": "WFT"
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
33
|
// src/components/controls/view/DateViewClient.tsx
|
|
156
34
|
var DateViewClient_exports = {};
|
|
157
35
|
__export(DateViewClient_exports, {
|
|
@@ -162,28 +40,73 @@ var init_DateViewClient = __esm({
|
|
|
162
40
|
"src/components/controls/view/DateViewClient.tsx"() {
|
|
163
41
|
"use strict";
|
|
164
42
|
"use client";
|
|
165
|
-
import_react2 =
|
|
166
|
-
init_TimeZoneAbbrevations();
|
|
43
|
+
import_react2 = require("react");
|
|
167
44
|
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
168
45
|
DateViewClient = (props) => {
|
|
169
|
-
const [offsetMilliseconds, setOffsetMilliseconds] = (0, import_react2.useState)(0);
|
|
170
46
|
const [timeZoneAbbr, setTimeZoneAbbr] = (0, import_react2.useState)("");
|
|
171
47
|
(0, import_react2.useEffect)(() => {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
);
|
|
48
|
+
const parts = new Intl.DateTimeFormat("en", {
|
|
49
|
+
timeZoneName: "short"
|
|
50
|
+
}).formatToParts(/* @__PURE__ */ new Date());
|
|
51
|
+
const abbr = parts.find((part) => part.type === "timeZoneName")?.value || "";
|
|
52
|
+
setTimeZoneAbbr(abbr);
|
|
178
53
|
}, []);
|
|
179
54
|
const toUtcDate = (dateString) => {
|
|
180
55
|
const s = dateString.trim();
|
|
56
|
+
if (!s) {
|
|
57
|
+
throw new Error("Empty date string");
|
|
58
|
+
}
|
|
181
59
|
const iso = s.replace(" ", "T");
|
|
182
|
-
const
|
|
183
|
-
|
|
60
|
+
const hasTimeZone = /Z$/i.test(iso) || /[+-]\d{2}:\d{2}$/.test(iso);
|
|
61
|
+
const utc = hasTimeZone ? iso : `${iso}Z`;
|
|
62
|
+
const date = new Date(utc);
|
|
63
|
+
if (Number.isNaN(date.getTime())) {
|
|
64
|
+
throw new Error(`Invalid date: ${dateString}`);
|
|
65
|
+
}
|
|
66
|
+
return date;
|
|
67
|
+
};
|
|
68
|
+
const formatDate = (date) => {
|
|
69
|
+
return new Intl.DateTimeFormat("en", {
|
|
70
|
+
day: "2-digit",
|
|
71
|
+
month: "short",
|
|
72
|
+
year: "numeric"
|
|
73
|
+
}).format(date);
|
|
74
|
+
};
|
|
75
|
+
const formatTime = (date) => {
|
|
76
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
77
|
+
hour: "2-digit",
|
|
78
|
+
minute: "2-digit"
|
|
79
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
80
|
+
hour: "2-digit",
|
|
81
|
+
minute: "2-digit",
|
|
82
|
+
second: "2-digit"
|
|
83
|
+
}).format(date);
|
|
84
|
+
};
|
|
85
|
+
const formatDateTime = (date) => {
|
|
86
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
87
|
+
day: "2-digit",
|
|
88
|
+
month: "short",
|
|
89
|
+
year: "numeric",
|
|
90
|
+
hour: "2-digit",
|
|
91
|
+
minute: "2-digit"
|
|
92
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
93
|
+
day: "2-digit",
|
|
94
|
+
month: "short",
|
|
95
|
+
year: "numeric",
|
|
96
|
+
hour: "2-digit",
|
|
97
|
+
minute: "2-digit",
|
|
98
|
+
second: "2-digit"
|
|
99
|
+
}).format(date);
|
|
184
100
|
};
|
|
185
|
-
const
|
|
186
|
-
|
|
101
|
+
const getTimePeriod = (date) => {
|
|
102
|
+
const hours = date.getHours();
|
|
103
|
+
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
104
|
+
if (hours >= 8 && hours < 12) return "Morning";
|
|
105
|
+
if (hours >= 12 && hours < 14) return "Noon";
|
|
106
|
+
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
107
|
+
if (hours >= 17 && hours < 20) return "Evening";
|
|
108
|
+
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
109
|
+
return "Night";
|
|
187
110
|
};
|
|
188
111
|
const getRelativeTime = (dateString) => {
|
|
189
112
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -197,77 +120,34 @@ var init_DateViewClient = __esm({
|
|
|
197
120
|
if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
|
|
198
121
|
if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
|
|
199
122
|
if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
|
|
200
|
-
return
|
|
201
|
-
day: "2-digit",
|
|
202
|
-
month: "short",
|
|
203
|
-
year: "numeric"
|
|
204
|
-
}).format(toLocalDate(utcDate));
|
|
123
|
+
return formatDate(utcDate);
|
|
205
124
|
};
|
|
206
125
|
const parseAndFormatDate = (dateString, format) => {
|
|
207
126
|
if (format === "relative") {
|
|
208
127
|
return getRelativeTime(dateString);
|
|
209
128
|
}
|
|
210
129
|
const utcDate = toUtcDate(dateString);
|
|
211
|
-
const localDate = toLocalDate(utcDate);
|
|
212
130
|
switch (props.controlType) {
|
|
213
131
|
case "date":
|
|
214
|
-
return
|
|
215
|
-
day: "2-digit",
|
|
216
|
-
month: "short",
|
|
217
|
-
year: "numeric"
|
|
218
|
-
}).format(localDate);
|
|
132
|
+
return formatDate(utcDate);
|
|
219
133
|
case "time":
|
|
220
|
-
return `${formatTime(
|
|
134
|
+
return `${formatTime(utcDate)} ${timeZoneAbbr} (${getTimePeriod(
|
|
135
|
+
utcDate
|
|
136
|
+
)})`;
|
|
221
137
|
default:
|
|
222
|
-
return utcDate
|
|
223
|
-
day: "2-digit",
|
|
224
|
-
month: "short",
|
|
225
|
-
year: "numeric",
|
|
226
|
-
hour: "2-digit",
|
|
227
|
-
minute: "2-digit"
|
|
228
|
-
}).format(localDate) : new Intl.DateTimeFormat("en", {
|
|
229
|
-
day: "2-digit",
|
|
230
|
-
month: "short",
|
|
231
|
-
year: "numeric",
|
|
232
|
-
hour: "2-digit",
|
|
233
|
-
minute: "2-digit",
|
|
234
|
-
second: "2-digit"
|
|
235
|
-
}).format(localDate);
|
|
138
|
+
return formatDateTime(utcDate);
|
|
236
139
|
}
|
|
237
140
|
};
|
|
238
|
-
const formatTime = (localDate) => {
|
|
239
|
-
return localDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
240
|
-
hour: "2-digit",
|
|
241
|
-
minute: "2-digit"
|
|
242
|
-
}).format(localDate) : new Intl.DateTimeFormat("en", {
|
|
243
|
-
hour: "2-digit",
|
|
244
|
-
minute: "2-digit",
|
|
245
|
-
second: "2-digit"
|
|
246
|
-
}).format(localDate);
|
|
247
|
-
};
|
|
248
|
-
const getTimePeriod = (localDate) => {
|
|
249
|
-
const hours = localDate.getHours();
|
|
250
|
-
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
251
|
-
if (hours >= 8 && hours < 12) return "Morning";
|
|
252
|
-
if (hours >= 12 && hours < 14) return "Noon";
|
|
253
|
-
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
254
|
-
if (hours >= 17 && hours < 20) return "Evening";
|
|
255
|
-
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
256
|
-
return "Night";
|
|
257
|
-
};
|
|
258
|
-
const getTimeZoneAbbreviation = (timeZone) => {
|
|
259
|
-
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
260
|
-
};
|
|
261
141
|
let localDateTime = "";
|
|
262
142
|
try {
|
|
263
143
|
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
264
144
|
} catch (error) {
|
|
265
145
|
console.error("Error parsing date:", props.value, error);
|
|
266
146
|
}
|
|
267
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "inline-flex flex-wrap gap-1", children: [
|
|
268
148
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
|
|
269
|
-
!props.format && props.controlType
|
|
270
|
-
] })
|
|
149
|
+
!props.format && props.controlType !== "date" && timeZoneAbbr && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbr })
|
|
150
|
+
] });
|
|
271
151
|
};
|
|
272
152
|
DateViewClient_default = DateViewClient;
|
|
273
153
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ var NumberView_default = NumberView;
|
|
|
44
44
|
|
|
45
45
|
// src/components/controls/view/DateView.tsx
|
|
46
46
|
import dynamic from "next/dynamic";
|
|
47
|
-
var DateView = dynamic(() => import("./DateViewClient-
|
|
47
|
+
var DateView = dynamic(() => import("./DateViewClient-Y4J3UH4R.mjs"), {
|
|
48
48
|
ssr: false
|
|
49
49
|
});
|
|
50
50
|
var DateView_default = DateView;
|
package/package.json
CHANGED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/components/controls/view/DateViewClient.tsx
|
|
4
|
-
import React, { useState, useEffect } from "react";
|
|
5
|
-
|
|
6
|
-
// src/components/controls/view/TimeZoneAbbrevations.tsx
|
|
7
|
-
var timeZoneAbbreviations = {
|
|
8
|
-
"Asia/Calcutta": "IST",
|
|
9
|
-
"Asia/Kolkata": "IST",
|
|
10
|
-
"America/New_York": "EST",
|
|
11
|
-
"America/Los_Angeles": "PST",
|
|
12
|
-
"Europe/London": "GMT",
|
|
13
|
-
"Europe/Paris": "CET",
|
|
14
|
-
"Asia/Tokyo": "JST",
|
|
15
|
-
"America/Chicago": "CST",
|
|
16
|
-
"America/Denver": "MST",
|
|
17
|
-
"Asia/Shanghai": "CST",
|
|
18
|
-
"Asia/Hong_Kong": "HKT",
|
|
19
|
-
"Australia/Sydney": "AEST",
|
|
20
|
-
"Australia/Melbourne": "AEST",
|
|
21
|
-
"Australia/Perth": "AWST",
|
|
22
|
-
"Pacific/Auckland": "NZST",
|
|
23
|
-
"Europe/Berlin": "CET",
|
|
24
|
-
"Europe/Madrid": "CET",
|
|
25
|
-
"Europe/Rome": "CET",
|
|
26
|
-
"Europe/Athens": "EET",
|
|
27
|
-
"Europe/Istanbul": "TRT",
|
|
28
|
-
"Africa/Cairo": "EET",
|
|
29
|
-
"Africa/Johannesburg": "SAST",
|
|
30
|
-
"Asia/Dubai": "GST",
|
|
31
|
-
"Asia/Singapore": "SGT",
|
|
32
|
-
"Asia/Seoul": "KST",
|
|
33
|
-
"America/Toronto": "EST",
|
|
34
|
-
"America/Vancouver": "PST",
|
|
35
|
-
"America/Sao_Paulo": "BRT",
|
|
36
|
-
"America/Mexico_City": "CST",
|
|
37
|
-
"Asia/Manila": "PHT",
|
|
38
|
-
"Asia/Jakarta": "WIB",
|
|
39
|
-
"Asia/Bangkok": "ICT",
|
|
40
|
-
"Asia/Karachi": "PKT",
|
|
41
|
-
"Asia/Tehran": "IRST",
|
|
42
|
-
"Asia/Baghdad": "AST",
|
|
43
|
-
"Europe/Moscow": "MSK",
|
|
44
|
-
"Europe/Amsterdam": "CET",
|
|
45
|
-
"Europe/Brussels": "CET",
|
|
46
|
-
"Europe/Zurich": "CET",
|
|
47
|
-
"America/Anchorage": "AKST",
|
|
48
|
-
"Pacific/Honolulu": "HST",
|
|
49
|
-
"Antarctica/McMurdo": "NZST",
|
|
50
|
-
"Atlantic/Reykjavik": "GMT",
|
|
51
|
-
"Asia/Riyadh": "AST",
|
|
52
|
-
"America/Argentina/Buenos_Aires": "ART",
|
|
53
|
-
"America/Bogota": "COT",
|
|
54
|
-
"Africa/Nairobi": "EAT",
|
|
55
|
-
"Asia/Kuala_Lumpur": "MYT",
|
|
56
|
-
"Asia/Ho_Chi_Minh": "ICT",
|
|
57
|
-
"Europe/Warsaw": "CET",
|
|
58
|
-
"Europe/Prague": "CET",
|
|
59
|
-
"America/Phoenix": "MST",
|
|
60
|
-
"America/Indianapolis": "EST",
|
|
61
|
-
"Pacific/Fiji": "FJT",
|
|
62
|
-
"Asia/Colombo": "IST",
|
|
63
|
-
"Africa/Lagos": "WAT",
|
|
64
|
-
"America/Caracas": "VET",
|
|
65
|
-
"America/Halifax": "AST",
|
|
66
|
-
"Pacific/Tahiti": "TAHT",
|
|
67
|
-
"America/St_Johns": "NST",
|
|
68
|
-
"Europe/Bucharest": "EET",
|
|
69
|
-
"Europe/Helsinki": "EET",
|
|
70
|
-
"Europe/Kiev": "EET",
|
|
71
|
-
"Europe/Oslo": "CET",
|
|
72
|
-
"Europe/Stockholm": "CET",
|
|
73
|
-
"Europe/Lisbon": "WET",
|
|
74
|
-
"Asia/Beirut": "EET",
|
|
75
|
-
"Asia/Damascus": "EET",
|
|
76
|
-
"Asia/Jerusalem": "IST",
|
|
77
|
-
"Asia/Amman": "EET",
|
|
78
|
-
"America/Santiago": "CLT",
|
|
79
|
-
"America/Lima": "PET",
|
|
80
|
-
"America/Montevideo": "UYT",
|
|
81
|
-
"Asia/Tashkent": "UZT",
|
|
82
|
-
"Asia/Yerevan": "AMT",
|
|
83
|
-
"Asia/Baku": "AZT",
|
|
84
|
-
"Europe/Vilnius": "EET",
|
|
85
|
-
"Europe/Riga": "EET",
|
|
86
|
-
"Europe/Tallinn": "EET",
|
|
87
|
-
"Europe/Sofia": "EET",
|
|
88
|
-
"Africa/Casablanca": "WET",
|
|
89
|
-
"America/Guatemala": "CST",
|
|
90
|
-
"America/Panama": "EST",
|
|
91
|
-
"America/Costa_Rica": "CST",
|
|
92
|
-
"Pacific/Port_Moresby": "PGT",
|
|
93
|
-
"Asia/Makassar": "WITA",
|
|
94
|
-
"Asia/Vladivostok": "VLAT",
|
|
95
|
-
"Asia/Krasnoyarsk": "KRAT",
|
|
96
|
-
"Asia/Novosibirsk": "NOVT",
|
|
97
|
-
"Asia/Yakutsk": "YAKT",
|
|
98
|
-
"Asia/Sakhalin": "SAKT",
|
|
99
|
-
"Asia/Ulaanbaatar": "ULAT",
|
|
100
|
-
"Asia/Choibalsan": "CHOT",
|
|
101
|
-
"Asia/Omsk": "OMST",
|
|
102
|
-
"Asia/Kamchatka": "PETT",
|
|
103
|
-
"Pacific/Pago_Pago": "SST",
|
|
104
|
-
"Pacific/Guam": "ChST",
|
|
105
|
-
"Pacific/Saipan": "ChST",
|
|
106
|
-
"Pacific/Palau": "PWT",
|
|
107
|
-
"Pacific/Efate": "VUT",
|
|
108
|
-
"Pacific/Kosrae": "KOST",
|
|
109
|
-
"Pacific/Nauru": "NRT",
|
|
110
|
-
"Pacific/Tarawa": "GILT",
|
|
111
|
-
"Pacific/Enderbury": "PHOT",
|
|
112
|
-
"Pacific/Fakaofo": "TKT",
|
|
113
|
-
"Pacific/Chatham": "CHAST",
|
|
114
|
-
"Pacific/Tongatapu": "TOT",
|
|
115
|
-
"Pacific/Funafuti": "TVT",
|
|
116
|
-
"Pacific/Majuro": "MHT",
|
|
117
|
-
"Pacific/Kwajalein": "MHT",
|
|
118
|
-
"Pacific/Wake": "WAKT",
|
|
119
|
-
"Pacific/Wallis": "WFT"
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/components/controls/view/DateViewClient.tsx
|
|
123
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
124
|
-
var DateViewClient = (props) => {
|
|
125
|
-
const [offsetMilliseconds, setOffsetMilliseconds] = useState(0);
|
|
126
|
-
const [timeZoneAbbr, setTimeZoneAbbr] = useState("");
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
const now = /* @__PURE__ */ new Date();
|
|
129
|
-
const offsetMinutes = now.getTimezoneOffset();
|
|
130
|
-
setOffsetMilliseconds(offsetMinutes * 60 * 1e3);
|
|
131
|
-
setTimeZoneAbbr(
|
|
132
|
-
now.toLocaleTimeString("en", { timeZoneName: "short" }).split(" ")[2]
|
|
133
|
-
);
|
|
134
|
-
}, []);
|
|
135
|
-
const toUtcDate = (dateString) => {
|
|
136
|
-
const s = dateString.trim();
|
|
137
|
-
const iso = s.replace(" ", "T");
|
|
138
|
-
const utc = iso.endsWith("Z") || iso.includes("+") ? iso : iso + "Z";
|
|
139
|
-
return new Date(utc);
|
|
140
|
-
};
|
|
141
|
-
const toLocalDate = (utcDate) => {
|
|
142
|
-
return new Date(utcDate.getTime() - offsetMilliseconds);
|
|
143
|
-
};
|
|
144
|
-
const getRelativeTime = (dateString) => {
|
|
145
|
-
const now = /* @__PURE__ */ new Date();
|
|
146
|
-
const utcDate = toUtcDate(dateString);
|
|
147
|
-
const diffMs = now.getTime() - utcDate.getTime();
|
|
148
|
-
const diffSec = Math.floor(diffMs / 1e3);
|
|
149
|
-
const diffMin = Math.floor(diffSec / 60);
|
|
150
|
-
const diffHr = Math.floor(diffMin / 60);
|
|
151
|
-
const diffDay = Math.floor(diffHr / 24);
|
|
152
|
-
if (diffSec < 60) return "Just now";
|
|
153
|
-
if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
|
|
154
|
-
if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
|
|
155
|
-
if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
|
|
156
|
-
return new Intl.DateTimeFormat("en", {
|
|
157
|
-
day: "2-digit",
|
|
158
|
-
month: "short",
|
|
159
|
-
year: "numeric"
|
|
160
|
-
}).format(toLocalDate(utcDate));
|
|
161
|
-
};
|
|
162
|
-
const parseAndFormatDate = (dateString, format) => {
|
|
163
|
-
if (format === "relative") {
|
|
164
|
-
return getRelativeTime(dateString);
|
|
165
|
-
}
|
|
166
|
-
const utcDate = toUtcDate(dateString);
|
|
167
|
-
const localDate = toLocalDate(utcDate);
|
|
168
|
-
switch (props.controlType) {
|
|
169
|
-
case "date":
|
|
170
|
-
return new Intl.DateTimeFormat("en", {
|
|
171
|
-
day: "2-digit",
|
|
172
|
-
month: "short",
|
|
173
|
-
year: "numeric"
|
|
174
|
-
}).format(localDate);
|
|
175
|
-
case "time":
|
|
176
|
-
return `${formatTime(localDate)} ${timeZoneAbbr} (${getTimePeriod(localDate)})`;
|
|
177
|
-
default:
|
|
178
|
-
return utcDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
179
|
-
day: "2-digit",
|
|
180
|
-
month: "short",
|
|
181
|
-
year: "numeric",
|
|
182
|
-
hour: "2-digit",
|
|
183
|
-
minute: "2-digit"
|
|
184
|
-
}).format(localDate) : new Intl.DateTimeFormat("en", {
|
|
185
|
-
day: "2-digit",
|
|
186
|
-
month: "short",
|
|
187
|
-
year: "numeric",
|
|
188
|
-
hour: "2-digit",
|
|
189
|
-
minute: "2-digit",
|
|
190
|
-
second: "2-digit"
|
|
191
|
-
}).format(localDate);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
const formatTime = (localDate) => {
|
|
195
|
-
return localDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
196
|
-
hour: "2-digit",
|
|
197
|
-
minute: "2-digit"
|
|
198
|
-
}).format(localDate) : new Intl.DateTimeFormat("en", {
|
|
199
|
-
hour: "2-digit",
|
|
200
|
-
minute: "2-digit",
|
|
201
|
-
second: "2-digit"
|
|
202
|
-
}).format(localDate);
|
|
203
|
-
};
|
|
204
|
-
const getTimePeriod = (localDate) => {
|
|
205
|
-
const hours = localDate.getHours();
|
|
206
|
-
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
207
|
-
if (hours >= 8 && hours < 12) return "Morning";
|
|
208
|
-
if (hours >= 12 && hours < 14) return "Noon";
|
|
209
|
-
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
210
|
-
if (hours >= 17 && hours < 20) return "Evening";
|
|
211
|
-
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
212
|
-
return "Night";
|
|
213
|
-
};
|
|
214
|
-
const getTimeZoneAbbreviation = (timeZone) => {
|
|
215
|
-
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
216
|
-
};
|
|
217
|
-
let localDateTime = "";
|
|
218
|
-
try {
|
|
219
|
-
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
220
|
-
} catch (error) {
|
|
221
|
-
console.error("Error parsing date:", props.value, error);
|
|
222
|
-
}
|
|
223
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
|
|
224
|
-
/* @__PURE__ */ jsx("span", { children: localDateTime }),
|
|
225
|
-
!props.format && props.controlType != "date" && /* @__PURE__ */ jsx("span", { children: timeZoneAbbr })
|
|
226
|
-
] }) });
|
|
227
|
-
};
|
|
228
|
-
var DateViewClient_default = DateViewClient;
|
|
229
|
-
export {
|
|
230
|
-
DateViewClient_default as default
|
|
231
|
-
};
|