@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260418062449 → 0.8.1-dev.20260418064017
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 +39 -44
- package/dist/index.mjs +39 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1153,6 +1153,7 @@ var DateView = (props) => {
|
|
|
1153
1153
|
const getTimeZoneAbbreviation = (timeZone) => {
|
|
1154
1154
|
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
1155
1155
|
};
|
|
1156
|
+
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1156
1157
|
const getRelativeTime = (dateString) => {
|
|
1157
1158
|
const now = /* @__PURE__ */ new Date();
|
|
1158
1159
|
const date = new Date(
|
|
@@ -1173,30 +1174,48 @@ var DateView = (props) => {
|
|
|
1173
1174
|
year: "numeric"
|
|
1174
1175
|
}).format(date);
|
|
1175
1176
|
};
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1177
|
+
const formatTime = (date) => {
|
|
1178
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
1179
|
+
timeZone: userTimeZone,
|
|
1180
|
+
hour: "2-digit",
|
|
1181
|
+
minute: "2-digit"
|
|
1182
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
1183
|
+
timeZone: userTimeZone,
|
|
1184
|
+
hour: "2-digit",
|
|
1185
|
+
minute: "2-digit",
|
|
1186
|
+
second: "2-digit"
|
|
1187
|
+
}).format(date);
|
|
1188
|
+
};
|
|
1189
|
+
const getTimePeriod = (date) => {
|
|
1190
|
+
const hours = date.getHours();
|
|
1191
|
+
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
1192
|
+
if (hours >= 8 && hours < 12) return "Morning";
|
|
1193
|
+
if (hours >= 12 && hours < 14) return "Noon";
|
|
1194
|
+
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
1195
|
+
if (hours >= 17 && hours < 20) return "Evening";
|
|
1196
|
+
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
1197
|
+
if (hours >= 22 || hours < 5) return "Night";
|
|
1198
|
+
return "Late Night";
|
|
1183
1199
|
};
|
|
1184
1200
|
const parseAndFormatDate = (dateString, format) => {
|
|
1185
|
-
|
|
1186
|
-
dateString.includes("Z") ? dateString : dateString + "Z"
|
|
1187
|
-
);
|
|
1188
|
-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1201
|
+
if (!dateString) return "";
|
|
1189
1202
|
if (format === "relative") {
|
|
1190
1203
|
return getRelativeTime(dateString);
|
|
1191
1204
|
}
|
|
1205
|
+
if (props.controlType === "date") {
|
|
1206
|
+
const datePart = dateString.split("T")[0];
|
|
1207
|
+
const [year, month, day] = datePart.split("-");
|
|
1208
|
+
const safeDate = new Date(Number(year), Number(month) - 1, Number(day));
|
|
1209
|
+
return new Intl.DateTimeFormat("en", {
|
|
1210
|
+
day: "2-digit",
|
|
1211
|
+
month: "short",
|
|
1212
|
+
year: "numeric"
|
|
1213
|
+
}).format(safeDate);
|
|
1214
|
+
}
|
|
1215
|
+
const parsedDate = new Date(
|
|
1216
|
+
dateString.includes("Z") ? dateString : dateString + "Z"
|
|
1217
|
+
);
|
|
1192
1218
|
switch (props.controlType) {
|
|
1193
|
-
case "date":
|
|
1194
|
-
return new Intl.DateTimeFormat("en", {
|
|
1195
|
-
timeZone: userTimeZone,
|
|
1196
|
-
day: "2-digit",
|
|
1197
|
-
month: "short",
|
|
1198
|
-
year: "numeric"
|
|
1199
|
-
}).format(parsedDate);
|
|
1200
1219
|
case "time":
|
|
1201
1220
|
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
|
|
1202
1221
|
userTimeZone
|
|
@@ -1220,41 +1239,17 @@ var DateView = (props) => {
|
|
|
1220
1239
|
}).format(parsedDate);
|
|
1221
1240
|
}
|
|
1222
1241
|
};
|
|
1223
|
-
const formatTime = (date) => {
|
|
1224
|
-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1225
|
-
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
1226
|
-
timeZone: userTimeZone,
|
|
1227
|
-
hour: "2-digit",
|
|
1228
|
-
minute: "2-digit"
|
|
1229
|
-
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
1230
|
-
timeZone: userTimeZone,
|
|
1231
|
-
hour: "2-digit",
|
|
1232
|
-
minute: "2-digit",
|
|
1233
|
-
second: "2-digit"
|
|
1234
|
-
}).format(date);
|
|
1235
|
-
};
|
|
1236
|
-
const getTimePeriod = (date) => {
|
|
1237
|
-
const hours = date.getHours();
|
|
1238
|
-
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
1239
|
-
if (hours >= 8 && hours < 12) return "Morning";
|
|
1240
|
-
if (hours >= 12 && hours < 14) return "Noon";
|
|
1241
|
-
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
1242
|
-
if (hours >= 17 && hours < 20) return "Evening";
|
|
1243
|
-
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
1244
|
-
if (hours >= 22 || hours < 5) return "Night";
|
|
1245
|
-
return "Late Night";
|
|
1246
|
-
};
|
|
1247
1242
|
let localDateTime = "";
|
|
1248
1243
|
let timeZoneAbbreviation = "";
|
|
1249
1244
|
try {
|
|
1250
1245
|
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
1251
|
-
timeZoneAbbreviation = getTimeZoneAbbreviation(
|
|
1246
|
+
timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
|
|
1252
1247
|
} catch (error) {
|
|
1253
1248
|
console.error("Error parsing date:", props.value, error);
|
|
1254
1249
|
}
|
|
1255
1250
|
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: [
|
|
1256
1251
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: localDateTime }),
|
|
1257
|
-
!props.format && props.controlType
|
|
1252
|
+
!props.format && props.controlType !== "date" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: timeZoneAbbreviation })
|
|
1258
1253
|
] }) });
|
|
1259
1254
|
};
|
|
1260
1255
|
var DateView_default = DateView;
|
package/dist/index.mjs
CHANGED
|
@@ -165,6 +165,7 @@ var DateView = (props) => {
|
|
|
165
165
|
const getTimeZoneAbbreviation = (timeZone) => {
|
|
166
166
|
return timeZoneAbbreviations[timeZone] || timeZone;
|
|
167
167
|
};
|
|
168
|
+
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
168
169
|
const getRelativeTime = (dateString) => {
|
|
169
170
|
const now = /* @__PURE__ */ new Date();
|
|
170
171
|
const date = new Date(
|
|
@@ -185,30 +186,48 @@ var DateView = (props) => {
|
|
|
185
186
|
year: "numeric"
|
|
186
187
|
}).format(date);
|
|
187
188
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
189
|
+
const formatTime = (date) => {
|
|
190
|
+
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
191
|
+
timeZone: userTimeZone,
|
|
192
|
+
hour: "2-digit",
|
|
193
|
+
minute: "2-digit"
|
|
194
|
+
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
195
|
+
timeZone: userTimeZone,
|
|
196
|
+
hour: "2-digit",
|
|
197
|
+
minute: "2-digit",
|
|
198
|
+
second: "2-digit"
|
|
199
|
+
}).format(date);
|
|
200
|
+
};
|
|
201
|
+
const getTimePeriod = (date) => {
|
|
202
|
+
const hours = date.getHours();
|
|
203
|
+
if (hours >= 5 && hours < 8) return "Early Morning";
|
|
204
|
+
if (hours >= 8 && hours < 12) return "Morning";
|
|
205
|
+
if (hours >= 12 && hours < 14) return "Noon";
|
|
206
|
+
if (hours >= 14 && hours < 17) return "Afternoon";
|
|
207
|
+
if (hours >= 17 && hours < 20) return "Evening";
|
|
208
|
+
if (hours >= 20 && hours < 22) return "Late Evening";
|
|
209
|
+
if (hours >= 22 || hours < 5) return "Night";
|
|
210
|
+
return "Late Night";
|
|
195
211
|
};
|
|
196
212
|
const parseAndFormatDate = (dateString, format) => {
|
|
197
|
-
|
|
198
|
-
dateString.includes("Z") ? dateString : dateString + "Z"
|
|
199
|
-
);
|
|
200
|
-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
213
|
+
if (!dateString) return "";
|
|
201
214
|
if (format === "relative") {
|
|
202
215
|
return getRelativeTime(dateString);
|
|
203
216
|
}
|
|
217
|
+
if (props.controlType === "date") {
|
|
218
|
+
const datePart = dateString.split("T")[0];
|
|
219
|
+
const [year, month, day] = datePart.split("-");
|
|
220
|
+
const safeDate = new Date(Number(year), Number(month) - 1, Number(day));
|
|
221
|
+
return new Intl.DateTimeFormat("en", {
|
|
222
|
+
day: "2-digit",
|
|
223
|
+
month: "short",
|
|
224
|
+
year: "numeric"
|
|
225
|
+
}).format(safeDate);
|
|
226
|
+
}
|
|
227
|
+
const parsedDate = new Date(
|
|
228
|
+
dateString.includes("Z") ? dateString : dateString + "Z"
|
|
229
|
+
);
|
|
204
230
|
switch (props.controlType) {
|
|
205
|
-
case "date":
|
|
206
|
-
return new Intl.DateTimeFormat("en", {
|
|
207
|
-
timeZone: userTimeZone,
|
|
208
|
-
day: "2-digit",
|
|
209
|
-
month: "short",
|
|
210
|
-
year: "numeric"
|
|
211
|
-
}).format(parsedDate);
|
|
212
231
|
case "time":
|
|
213
232
|
return `${formatTime(parsedDate)} ${getTimeZoneAbbreviation(
|
|
214
233
|
userTimeZone
|
|
@@ -232,41 +251,17 @@ var DateView = (props) => {
|
|
|
232
251
|
}).format(parsedDate);
|
|
233
252
|
}
|
|
234
253
|
};
|
|
235
|
-
const formatTime = (date) => {
|
|
236
|
-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
237
|
-
return date.getSeconds() === 0 ? new Intl.DateTimeFormat("en", {
|
|
238
|
-
timeZone: userTimeZone,
|
|
239
|
-
hour: "2-digit",
|
|
240
|
-
minute: "2-digit"
|
|
241
|
-
}).format(date) : new Intl.DateTimeFormat("en", {
|
|
242
|
-
timeZone: userTimeZone,
|
|
243
|
-
hour: "2-digit",
|
|
244
|
-
minute: "2-digit",
|
|
245
|
-
second: "2-digit"
|
|
246
|
-
}).format(date);
|
|
247
|
-
};
|
|
248
|
-
const getTimePeriod = (date) => {
|
|
249
|
-
const hours = date.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
|
-
if (hours >= 22 || hours < 5) return "Night";
|
|
257
|
-
return "Late Night";
|
|
258
|
-
};
|
|
259
254
|
let localDateTime = "";
|
|
260
255
|
let timeZoneAbbreviation = "";
|
|
261
256
|
try {
|
|
262
257
|
localDateTime = parseAndFormatDate(props.value, props.format);
|
|
263
|
-
timeZoneAbbreviation = getTimeZoneAbbreviation(
|
|
258
|
+
timeZoneAbbreviation = getTimeZoneAbbreviation(userTimeZone);
|
|
264
259
|
} catch (error) {
|
|
265
260
|
console.error("Error parsing date:", props.value, error);
|
|
266
261
|
}
|
|
267
262
|
return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
|
|
268
263
|
/* @__PURE__ */ jsx2("span", { children: localDateTime }),
|
|
269
|
-
!props.format && props.controlType
|
|
264
|
+
!props.format && props.controlType !== "date" && /* @__PURE__ */ jsx2("span", { children: timeZoneAbbreviation })
|
|
270
265
|
] }) });
|
|
271
266
|
};
|
|
272
267
|
var DateView_default = DateView;
|
package/package.json
CHANGED