@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260422090829 → 0.8.1-dev.20260422124624

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/index.js CHANGED
@@ -1186,15 +1186,12 @@ var timeZoneAbbreviations = {
1186
1186
  // src/components/controls/view/DateView.tsx
1187
1187
  var import_jsx_runtime2 = require("react/jsx-runtime");
1188
1188
  var DateView = (props) => {
1189
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1190
1189
  const getTimeZoneAbbreviation = (timeZone) => {
1191
1190
  return timeZoneAbbreviations[timeZone] || timeZone;
1192
1191
  };
1193
1192
  const getRelativeTime = (dateString) => {
1194
1193
  const now = /* @__PURE__ */ new Date();
1195
- const date = new Date(
1196
- dateString.includes("Z") ? dateString : dateString + "Z"
1197
- );
1194
+ const date = /* @__PURE__ */ new Date(dateString + "Z");
1198
1195
  const diffMs = now.getTime() - date.getTime();
1199
1196
  const diffSec = Math.floor(diffMs / 1e3);
1200
1197
  const diffMin = Math.floor(diffSec / 60);
@@ -1205,19 +1202,48 @@ var DateView = (props) => {
1205
1202
  if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
1206
1203
  if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
1207
1204
  return new Intl.DateTimeFormat("en", {
1208
- timeZone: userTimeZone,
1209
1205
  day: "2-digit",
1210
1206
  month: "short",
1211
1207
  year: "numeric"
1212
1208
  }).format(date);
1213
1209
  };
1210
+ console.log("DateView props:", props);
1211
+ const parseAndFormatDate = (dateString, format) => {
1212
+ const parsedDate = /* @__PURE__ */ new Date(dateString + "Z");
1213
+ if (format === "relative") {
1214
+ return getRelativeTime(dateString);
1215
+ }
1216
+ switch (props.controlType) {
1217
+ case "date":
1218
+ return new Intl.DateTimeFormat("en", {
1219
+ day: "2-digit",
1220
+ month: "short",
1221
+ year: "numeric"
1222
+ }).format(parsedDate);
1223
+ case "time":
1224
+ return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone)} (${getTimePeriod(parsedDate)})`;
1225
+ default:
1226
+ return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1227
+ day: "2-digit",
1228
+ month: "short",
1229
+ year: "numeric",
1230
+ hour: "2-digit",
1231
+ minute: "2-digit"
1232
+ }).format(parsedDate) : new Intl.DateTimeFormat("en", {
1233
+ day: "2-digit",
1234
+ month: "short",
1235
+ year: "numeric",
1236
+ hour: "2-digit",
1237
+ minute: "2-digit",
1238
+ second: "2-digit"
1239
+ }).format(parsedDate);
1240
+ }
1241
+ };
1214
1242
  const formatTime = (date) => {
1215
1243
  return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1216
- timeZone: userTimeZone,
1217
1244
  hour: "2-digit",
1218
1245
  minute: "2-digit"
1219
1246
  }).format(date) : new Intl.DateTimeFormat("en", {
1220
- timeZone: userTimeZone,
1221
1247
  hour: "2-digit",
1222
1248
  minute: "2-digit",
1223
1249
  second: "2-digit"
@@ -1234,55 +1260,19 @@ var DateView = (props) => {
1234
1260
  if (hours >= 22 || hours < 5) return "Night";
1235
1261
  return "Late Night";
1236
1262
  };
1237
- const parseAndFormatDate = (dateString, format) => {
1238
- if (!dateString) return "";
1239
- if (format === "relative") {
1240
- return getRelativeTime(dateString);
1241
- }
1242
- const parsedDate = new Date(
1243
- dateString.includes("Z") ? dateString : dateString + "Z"
1244
- );
1245
- if (props.controlType === "date") {
1246
- return new Intl.DateTimeFormat("en", {
1247
- timeZone: userTimeZone,
1248
- day: "2-digit",
1249
- month: "short",
1250
- year: "numeric"
1251
- }).format(parsedDate);
1252
- }
1253
- if (props.controlType === "time") {
1254
- return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
1255
- userTimeZone
1256
- )} (${getTimePeriod(parsedDate)})`;
1257
- }
1258
- return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
1259
- timeZone: userTimeZone,
1260
- day: "2-digit",
1261
- month: "short",
1262
- year: "numeric",
1263
- hour: "2-digit",
1264
- minute: "2-digit"
1265
- }).format(parsedDate) : new Intl.DateTimeFormat("en", {
1266
- timeZone: userTimeZone,
1267
- day: "2-digit",
1268
- month: "short",
1269
- year: "numeric",
1270
- hour: "2-digit",
1271
- minute: "2-digit",
1272
- second: "2-digit"
1273
- }).format(parsedDate);
1274
- };
1275
1263
  let localDateTime = "";
1276
1264
  let timeZoneAbbreviation = "";
1277
1265
  try {
1278
1266
  localDateTime = parseAndFormatDate(props.value, props.format);
1279
- timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
1267
+ timeZoneAbbreviation = getTimeZoneAbbreviation(
1268
+ Intl.DateTimeFormat().resolvedOptions().timeZone
1269
+ );
1280
1270
  } catch (error) {
1281
1271
  console.error("Error parsing date:", props.value, error);
1282
1272
  }
1283
1273
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "inline-flex flex-wrap gap-1", children: [
1284
1274
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
1285
- !props.format && props.controlType !== "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1275
+ !props.format && props.controlType != "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
1286
1276
  ] }) });
1287
1277
  };
1288
1278
  var DateView_default = DateView;
package/dist/index.mjs CHANGED
@@ -162,15 +162,12 @@ var timeZoneAbbreviations = {
162
162
  // src/components/controls/view/DateView.tsx
163
163
  import { jsx as jsx2, jsxs } from "react/jsx-runtime";
164
164
  var DateView = (props) => {
165
- const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
166
165
  const getTimeZoneAbbreviation = (timeZone) => {
167
166
  return timeZoneAbbreviations[timeZone] || timeZone;
168
167
  };
169
168
  const getRelativeTime = (dateString) => {
170
169
  const now = /* @__PURE__ */ new Date();
171
- const date = new Date(
172
- dateString.includes("Z") ? dateString : dateString + "Z"
173
- );
170
+ const date = /* @__PURE__ */ new Date(dateString + "Z");
174
171
  const diffMs = now.getTime() - date.getTime();
175
172
  const diffSec = Math.floor(diffMs / 1e3);
176
173
  const diffMin = Math.floor(diffSec / 60);
@@ -181,19 +178,48 @@ var DateView = (props) => {
181
178
  if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
182
179
  if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
183
180
  return new Intl.DateTimeFormat("en", {
184
- timeZone: userTimeZone,
185
181
  day: "2-digit",
186
182
  month: "short",
187
183
  year: "numeric"
188
184
  }).format(date);
189
185
  };
186
+ console.log("DateView props:", props);
187
+ const parseAndFormatDate = (dateString, format) => {
188
+ const parsedDate = /* @__PURE__ */ new Date(dateString + "Z");
189
+ if (format === "relative") {
190
+ return getRelativeTime(dateString);
191
+ }
192
+ switch (props.controlType) {
193
+ case "date":
194
+ return new Intl.DateTimeFormat("en", {
195
+ day: "2-digit",
196
+ month: "short",
197
+ year: "numeric"
198
+ }).format(parsedDate);
199
+ case "time":
200
+ return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(Intl.DateTimeFormat().resolvedOptions().timeZone)} (${getTimePeriod(parsedDate)})`;
201
+ default:
202
+ return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
203
+ day: "2-digit",
204
+ month: "short",
205
+ year: "numeric",
206
+ hour: "2-digit",
207
+ minute: "2-digit"
208
+ }).format(parsedDate) : new Intl.DateTimeFormat("en", {
209
+ day: "2-digit",
210
+ month: "short",
211
+ year: "numeric",
212
+ hour: "2-digit",
213
+ minute: "2-digit",
214
+ second: "2-digit"
215
+ }).format(parsedDate);
216
+ }
217
+ };
190
218
  const formatTime = (date) => {
191
219
  return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
192
- timeZone: userTimeZone,
193
220
  hour: "2-digit",
194
221
  minute: "2-digit"
195
222
  }).format(date) : new Intl.DateTimeFormat("en", {
196
- timeZone: userTimeZone,
197
223
  hour: "2-digit",
198
224
  minute: "2-digit",
199
225
  second: "2-digit"
@@ -210,55 +236,19 @@ var DateView = (props) => {
210
236
  if (hours >= 22 || hours < 5) return "Night";
211
237
  return "Late Night";
212
238
  };
213
- const parseAndFormatDate = (dateString, format) => {
214
- if (!dateString) return "";
215
- if (format === "relative") {
216
- return getRelativeTime(dateString);
217
- }
218
- const parsedDate = new Date(
219
- dateString.includes("Z") ? dateString : dateString + "Z"
220
- );
221
- if (props.controlType === "date") {
222
- return new Intl.DateTimeFormat("en", {
223
- timeZone: userTimeZone,
224
- day: "2-digit",
225
- month: "short",
226
- year: "numeric"
227
- }).format(parsedDate);
228
- }
229
- if (props.controlType === "time") {
230
- return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
231
- userTimeZone
232
- )} (${getTimePeriod(parsedDate)})`;
233
- }
234
- return parsedDate.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
235
- timeZone: userTimeZone,
236
- day: "2-digit",
237
- month: "short",
238
- year: "numeric",
239
- hour: "2-digit",
240
- minute: "2-digit"
241
- }).format(parsedDate) : new Intl.DateTimeFormat("en", {
242
- timeZone: userTimeZone,
243
- day: "2-digit",
244
- month: "short",
245
- year: "numeric",
246
- hour: "2-digit",
247
- minute: "2-digit",
248
- second: "2-digit"
249
- }).format(parsedDate);
250
- };
251
239
  let localDateTime = "";
252
240
  let timeZoneAbbreviation = "";
253
241
  try {
254
242
  localDateTime = parseAndFormatDate(props.value, props.format);
255
- timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
243
+ timeZoneAbbreviation = getTimeZoneAbbreviation(
244
+ Intl.DateTimeFormat().resolvedOptions().timeZone
245
+ );
256
246
  } catch (error) {
257
247
  console.error("Error parsing date:", props.value, error);
258
248
  }
259
249
  return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
260
250
  /* @__PURE__ */ jsx2("span", { children: localDateTime }),
261
- !props.format && props.controlType !== "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
251
+ !props.format && props.controlType != "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
262
252
  ] }) });
263
253
  };
264
254
  var DateView_default = DateView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acoustte-digital-services/digitalstore-controls-dev",
3
- "version": "0.8.1-dev.20260422090829",
3
+ "version": "0.8.1-dev.20260422124624",
4
4
  "description": "Reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",