@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260429063933 → 0.8.1-dev.20260430100756

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.
@@ -0,0 +1,231 @@
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
+ };