@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260722073037 → 0.8.1-dev.20260722075037

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,253 @@
1
+ "use client";
2
+
3
+ import {
4
+ buttonClasses,
5
+ progressClasses
6
+ } from "./chunk-IMNQO57B.mjs";
7
+
8
+ // src/components/ToastService.tsx
9
+ var toastHandlersKey = "__digitalStoreToastHandlers";
10
+ var getToastHandlers = () => {
11
+ const globalScope = globalThis;
12
+ if (!globalScope[toastHandlersKey]) {
13
+ globalScope[toastHandlersKey] = {};
14
+ }
15
+ return globalScope[toastHandlersKey];
16
+ };
17
+ var ToastService = class {
18
+ static initialize(showToast, closeToast) {
19
+ const handlers = getToastHandlers();
20
+ handlers.showToast = showToast;
21
+ handlers.closeToast = closeToast;
22
+ }
23
+ static showError(message) {
24
+ const handlers = getToastHandlers();
25
+ if (handlers.showToast) {
26
+ handlers.showToast(message, "error");
27
+ }
28
+ }
29
+ static showInfo(message) {
30
+ const handlers = getToastHandlers();
31
+ if (handlers.showToast) {
32
+ handlers.showToast(message, "info");
33
+ }
34
+ }
35
+ static showWarning(message) {
36
+ const handlers = getToastHandlers();
37
+ if (handlers.showToast) {
38
+ handlers.showToast(message, "warning");
39
+ }
40
+ }
41
+ static showSuccess(message) {
42
+ const handlers = getToastHandlers();
43
+ if (handlers.showToast) {
44
+ handlers.showToast(message, "success");
45
+ }
46
+ }
47
+ static close() {
48
+ const handlers = getToastHandlers();
49
+ if (handlers.closeToast) {
50
+ handlers.closeToast();
51
+ }
52
+ }
53
+ };
54
+ var ToastService_default = ToastService;
55
+
56
+ // src/components/Button.tsx
57
+ import React3, { useState as useState2 } from "react";
58
+
59
+ // src/components/Confirm.tsx
60
+ import { useState } from "react";
61
+
62
+ // src/components/ClientButton.tsx
63
+ import React from "react";
64
+ import { jsx } from "react/jsx-runtime";
65
+ var ClientButton = (props) => {
66
+ const execute = async (event) => {
67
+ if (props.onClick !== void 0) {
68
+ props.onClick();
69
+ } else {
70
+ ToastService_default.showError("No action defined.");
71
+ }
72
+ };
73
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
74
+ return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(
75
+ "button",
76
+ {
77
+ type: "button",
78
+ onClick: execute,
79
+ className: buttonClass + " " + props.className,
80
+ children: props.children
81
+ }
82
+ ) });
83
+ };
84
+ var ClientButton_default = ClientButton;
85
+
86
+ // src/components/Confirm.tsx
87
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
88
+ var Confirm = ({ message, onConfirm, onCancel }) => {
89
+ const [showModal, setShowModal] = useState(true);
90
+ const handleConfirmAction = () => {
91
+ setShowModal(false);
92
+ if (onConfirm) {
93
+ onConfirm();
94
+ }
95
+ };
96
+ const handleCancelAction = () => {
97
+ setShowModal(false);
98
+ if (onCancel) {
99
+ onCancel();
100
+ }
101
+ };
102
+ return /* @__PURE__ */ jsx2(Fragment, { children: showModal && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 flex items-center justify-center z-50", children: [
103
+ /* @__PURE__ */ jsx2("div", { className: "absolute inset-0 bg-black opacity-70" }),
104
+ /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-md p-6 w-2/6 shadow border z-50", children: [
105
+ /* @__PURE__ */ jsx2("p", { className: "text-xl font-medium mb-4", children: "Confirmation" }),
106
+ /* @__PURE__ */ jsx2("p", { className: "mb-4", children: message }),
107
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-8", children: [
108
+ /* @__PURE__ */ jsx2(
109
+ ClientButton_default,
110
+ {
111
+ onClick: handleCancelAction,
112
+ ButtonType: "PrimaryHollow" /* Hollow */,
113
+ children: "Cancel"
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx2(
117
+ ClientButton_default,
118
+ {
119
+ onClick: handleConfirmAction,
120
+ children: "Confirm"
121
+ }
122
+ )
123
+ ] })
124
+ ] })
125
+ ] }) });
126
+ };
127
+ var Confirm_default = Confirm;
128
+ {
129
+ }
130
+
131
+ // src/components/Button.tsx
132
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
133
+ var Button = (props) => {
134
+ const [inProgress, setInProgress] = useState2(false);
135
+ const [isActionPerformed, setIsActionPerformed] = useState2(false);
136
+ const [responseMessage, setResponseMessage] = useState2(null);
137
+ const [showModal, setShowModal] = useState2(null);
138
+ const execute = async (event) => {
139
+ event.preventDefault();
140
+ event.stopPropagation();
141
+ if (props.confirm) {
142
+ const confirmed = await showConfirmation(
143
+ "Are you sure you want to delete this item?"
144
+ );
145
+ setShowModal(null);
146
+ if (!confirmed) {
147
+ return;
148
+ }
149
+ }
150
+ if (props.oneTimeAction && isActionPerformed) {
151
+ return;
152
+ }
153
+ setInProgress(true);
154
+ let isValid = true;
155
+ if (props.onValidate !== void 0) {
156
+ isValid = await props.onValidate();
157
+ if (!isValid) {
158
+ setInProgress(false);
159
+ ToastService_default.showError(
160
+ "There are errors in the form. Please fix them before proceeding."
161
+ );
162
+ return;
163
+ }
164
+ }
165
+ if (props.onClick !== void 0) {
166
+ let response = await props.onClick();
167
+ if (response.isSuccessful) {
168
+ setIsActionPerformed(true);
169
+ setResponseMessage(response.message);
170
+ if (props.showToast) {
171
+ ToastService_default.showInfo(response.message || "");
172
+ }
173
+ } else {
174
+ ToastService_default.showError(response.message || "");
175
+ }
176
+ } else {
177
+ ToastService_default.showError("No action defined.");
178
+ }
179
+ setInProgress(false);
180
+ };
181
+ const showConfirmation = (message) => {
182
+ return new Promise((resolve) => {
183
+ const onConfirm = () => resolve(true);
184
+ const onCancel = () => resolve(false);
185
+ setShowModal(
186
+ /* @__PURE__ */ jsx3(
187
+ Confirm_default,
188
+ {
189
+ message: props.confirmationMessage,
190
+ onConfirm,
191
+ onCancel
192
+ }
193
+ )
194
+ );
195
+ });
196
+ };
197
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
198
+ let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
199
+ const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
200
+ return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
201
+ /* @__PURE__ */ jsxs2(
202
+ "button",
203
+ {
204
+ type: "submit",
205
+ onClick: execute,
206
+ disabled: props.disabled,
207
+ title: isDisabled ? "The button is disabled to prevent any action" : "",
208
+ className: `${buttonClass} relative inline-flex items-center justify-center gap-2 ${props.className ?? ""}`,
209
+ children: [
210
+ isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
211
+ inProgress && /* @__PURE__ */ jsx3(Fragment2, { children: props.hideProgressIndicator ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2(
212
+ "svg",
213
+ {
214
+ className: `animate-spin h-5 w-5 flex-shrink-0 ${progressClass}`,
215
+ xmlns: "http://www.w3.org/2000/svg",
216
+ fill: "none",
217
+ viewBox: "0 0 24 24",
218
+ children: [
219
+ /* @__PURE__ */ jsx3(
220
+ "circle",
221
+ {
222
+ className: "opacity-25",
223
+ cx: "12",
224
+ cy: "12",
225
+ r: "10",
226
+ stroke: "currentColor",
227
+ strokeWidth: "4"
228
+ }
229
+ ),
230
+ /* @__PURE__ */ jsx3(
231
+ "path",
232
+ {
233
+ className: "opacity-75",
234
+ fill: "currentColor",
235
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ ) })
241
+ ]
242
+ }
243
+ ),
244
+ showModal
245
+ ] });
246
+ };
247
+ var Button_default = Button;
248
+
249
+ export {
250
+ ToastService_default,
251
+ ClientButton_default,
252
+ Button_default
253
+ };
@@ -0,0 +1,120 @@
1
+ // src/components/controls/view/DateViewClient.tsx
2
+ import { useEffect, useState } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ var dateFormatter = new Intl.DateTimeFormat("en", {
5
+ day: "2-digit",
6
+ month: "short",
7
+ year: "numeric"
8
+ });
9
+ var timeFormatterNoSeconds = new Intl.DateTimeFormat("en", {
10
+ hour: "2-digit",
11
+ minute: "2-digit"
12
+ });
13
+ var timeFormatterWithSeconds = new Intl.DateTimeFormat("en", {
14
+ hour: "2-digit",
15
+ minute: "2-digit",
16
+ second: "2-digit"
17
+ });
18
+ var dateTimeFormatterNoSeconds = new Intl.DateTimeFormat("en", {
19
+ day: "2-digit",
20
+ month: "short",
21
+ year: "numeric",
22
+ hour: "2-digit",
23
+ minute: "2-digit"
24
+ });
25
+ var dateTimeFormatterWithSeconds = new Intl.DateTimeFormat("en", {
26
+ day: "2-digit",
27
+ month: "short",
28
+ year: "numeric",
29
+ hour: "2-digit",
30
+ minute: "2-digit",
31
+ second: "2-digit"
32
+ });
33
+ var DateViewClient = (props) => {
34
+ const [timeZoneAbbr, setTimeZoneAbbr] = useState("");
35
+ useEffect(() => {
36
+ const parts = new Intl.DateTimeFormat("en", {
37
+ timeZoneName: "short"
38
+ }).formatToParts(/* @__PURE__ */ new Date());
39
+ const abbr = parts.find((part) => part.type === "timeZoneName")?.value || "";
40
+ setTimeZoneAbbr(abbr);
41
+ }, []);
42
+ const toUtcDate = (dateString) => {
43
+ const s = dateString.trim();
44
+ if (!s) {
45
+ throw new Error("Empty date string");
46
+ }
47
+ const iso = s.replace(" ", "T");
48
+ const hasTimeZone = /Z$/i.test(iso) || /[+-]\d{2}:\d{2}$/.test(iso);
49
+ const utc = hasTimeZone ? iso : `${iso}Z`;
50
+ const date = new Date(utc);
51
+ if (Number.isNaN(date.getTime())) {
52
+ throw new Error(`Invalid date: ${dateString}`);
53
+ }
54
+ return date;
55
+ };
56
+ const formatDate = (date) => {
57
+ return dateFormatter.format(date);
58
+ };
59
+ const formatTime = (date) => {
60
+ return date.getSeconds() === 0 ? timeFormatterNoSeconds.format(date) : timeFormatterWithSeconds.format(date);
61
+ };
62
+ const formatDateTime = (date) => {
63
+ return date.getSeconds() === 0 ? dateTimeFormatterNoSeconds.format(date) : dateTimeFormatterWithSeconds.format(date);
64
+ };
65
+ const getTimePeriod = (date) => {
66
+ const hours = date.getHours();
67
+ if (hours >= 5 && hours < 8) return "Early Morning";
68
+ if (hours >= 8 && hours < 12) return "Morning";
69
+ if (hours >= 12 && hours < 14) return "Noon";
70
+ if (hours >= 14 && hours < 17) return "Afternoon";
71
+ if (hours >= 17 && hours < 20) return "Evening";
72
+ if (hours >= 20 && hours < 22) return "Late Evening";
73
+ return "Night";
74
+ };
75
+ const getRelativeTime = (dateString) => {
76
+ const now = /* @__PURE__ */ new Date();
77
+ const utcDate = toUtcDate(dateString);
78
+ const diffMs = now.getTime() - utcDate.getTime();
79
+ const diffSec = Math.floor(diffMs / 1e3);
80
+ const diffMin = Math.floor(diffSec / 60);
81
+ const diffHr = Math.floor(diffMin / 60);
82
+ const diffDay = Math.floor(diffHr / 24);
83
+ if (diffSec < 60) return "Just now";
84
+ if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
85
+ if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
86
+ if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
87
+ return formatDate(utcDate);
88
+ };
89
+ const parseAndFormatDate = (dateString, format) => {
90
+ if (format === "relative") {
91
+ return getRelativeTime(dateString);
92
+ }
93
+ const utcDate = toUtcDate(dateString);
94
+ switch (props.controlType) {
95
+ case "date":
96
+ return formatDate(utcDate);
97
+ case "time":
98
+ return `${formatTime(utcDate)} ${timeZoneAbbr} (${getTimePeriod(
99
+ utcDate
100
+ )})`;
101
+ default:
102
+ return formatDateTime(utcDate);
103
+ }
104
+ };
105
+ let localDateTime = "";
106
+ try {
107
+ localDateTime = parseAndFormatDate(props.value, props.format);
108
+ } catch (error) {
109
+ console.error("Error parsing date:", props.value, error);
110
+ }
111
+ return /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
112
+ /* @__PURE__ */ jsx("span", { children: localDateTime }),
113
+ !props.format && props.controlType !== "date" && props.controlType !== "datetime" && timeZoneAbbr && /* @__PURE__ */ jsx("span", { children: timeZoneAbbr })
114
+ ] });
115
+ };
116
+ var DateViewClient_default = DateViewClient;
117
+
118
+ export {
119
+ DateViewClient_default
120
+ };
@@ -127,7 +127,7 @@ var Confirm_default = Confirm;
127
127
  }
128
128
 
129
129
  // src/components/Button.tsx
130
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
130
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
131
131
  var Button = (props) => {
132
132
  const [inProgress, setInProgress] = useState2(false);
133
133
  const [isActionPerformed, setIsActionPerformed] = useState2(false);
@@ -137,7 +137,9 @@ var Button = (props) => {
137
137
  event.preventDefault();
138
138
  event.stopPropagation();
139
139
  if (props.confirm) {
140
- const confirmed = await showConfirmation("Are you sure you want to delete this item?");
140
+ const confirmed = await showConfirmation(
141
+ "Are you sure you want to delete this item?"
142
+ );
141
143
  setShowModal(null);
142
144
  if (!confirmed) {
143
145
  return;
@@ -152,7 +154,9 @@ var Button = (props) => {
152
154
  isValid = await props.onValidate();
153
155
  if (!isValid) {
154
156
  setInProgress(false);
155
- ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
157
+ ToastService_default.showError(
158
+ "There are errors in the form. Please fix them before proceeding."
159
+ );
156
160
  return;
157
161
  }
158
162
  }
@@ -176,7 +180,16 @@ var Button = (props) => {
176
180
  return new Promise((resolve) => {
177
181
  const onConfirm = () => resolve(true);
178
182
  const onCancel = () => resolve(false);
179
- setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
183
+ setShowModal(
184
+ /* @__PURE__ */ jsx3(
185
+ Confirm_default,
186
+ {
187
+ message: props.confirmationMessage,
188
+ onConfirm,
189
+ onCancel
190
+ }
191
+ )
192
+ );
180
193
  });
181
194
  };
182
195
  let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
@@ -190,13 +203,39 @@ var Button = (props) => {
190
203
  onClick: execute,
191
204
  disabled: props.disabled,
192
205
  title: isDisabled ? "The button is disabled to prevent any action" : "",
193
- className: buttonClass + " relative " + props.className,
206
+ className: `${buttonClass} relative inline-flex items-center justify-center gap-2 ${props.className ?? ""}`,
194
207
  children: [
195
208
  isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
196
- inProgress && /* @__PURE__ */ jsx3(React3.Fragment, { children: props.hideProgressIndicator === true ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2("svg", { className: "animate-spin ml-2 mr-3 h-5 w-5 " + progressClass, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
197
- /* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
198
- /* @__PURE__ */ jsx3("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
199
- ] }) })
209
+ inProgress && /* @__PURE__ */ jsx3(Fragment2, { children: props.hideProgressIndicator ? /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ jsxs2(
210
+ "svg",
211
+ {
212
+ className: `animate-spin h-5 w-5 flex-shrink-0 ${progressClass}`,
213
+ xmlns: "http://www.w3.org/2000/svg",
214
+ fill: "none",
215
+ viewBox: "0 0 24 24",
216
+ children: [
217
+ /* @__PURE__ */ jsx3(
218
+ "circle",
219
+ {
220
+ className: "opacity-25",
221
+ cx: "12",
222
+ cy: "12",
223
+ r: "10",
224
+ stroke: "currentColor",
225
+ strokeWidth: "4"
226
+ }
227
+ ),
228
+ /* @__PURE__ */ jsx3(
229
+ "path",
230
+ {
231
+ className: "opacity-75",
232
+ fill: "currentColor",
233
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
234
+ }
235
+ )
236
+ ]
237
+ }
238
+ ) })
200
239
  ]
201
240
  }
202
241
  ),
@@ -0,0 +1,123 @@
1
+ "use client";
2
+
3
+
4
+ // src/components/controls/view/DateViewClient.tsx
5
+ import { useEffect, useState } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ var dateFormatter = new Intl.DateTimeFormat("en", {
8
+ day: "2-digit",
9
+ month: "short",
10
+ year: "numeric"
11
+ });
12
+ var timeFormatterNoSeconds = new Intl.DateTimeFormat("en", {
13
+ hour: "2-digit",
14
+ minute: "2-digit"
15
+ });
16
+ var timeFormatterWithSeconds = new Intl.DateTimeFormat("en", {
17
+ hour: "2-digit",
18
+ minute: "2-digit",
19
+ second: "2-digit"
20
+ });
21
+ var dateTimeFormatterNoSeconds = new Intl.DateTimeFormat("en", {
22
+ day: "2-digit",
23
+ month: "short",
24
+ year: "numeric",
25
+ hour: "2-digit",
26
+ minute: "2-digit"
27
+ });
28
+ var dateTimeFormatterWithSeconds = new Intl.DateTimeFormat("en", {
29
+ day: "2-digit",
30
+ month: "short",
31
+ year: "numeric",
32
+ hour: "2-digit",
33
+ minute: "2-digit",
34
+ second: "2-digit"
35
+ });
36
+ var DateViewClient = (props) => {
37
+ const [timeZoneAbbr, setTimeZoneAbbr] = useState("");
38
+ useEffect(() => {
39
+ const parts = new Intl.DateTimeFormat("en", {
40
+ timeZoneName: "short"
41
+ }).formatToParts(/* @__PURE__ */ new Date());
42
+ const abbr = parts.find((part) => part.type === "timeZoneName")?.value || "";
43
+ setTimeZoneAbbr(abbr);
44
+ }, []);
45
+ const toUtcDate = (dateString) => {
46
+ const s = dateString.trim();
47
+ if (!s) {
48
+ throw new Error("Empty date string");
49
+ }
50
+ const iso = s.replace(" ", "T");
51
+ const hasTimeZone = /Z$/i.test(iso) || /[+-]\d{2}:\d{2}$/.test(iso);
52
+ const utc = hasTimeZone ? iso : `${iso}Z`;
53
+ const date = new Date(utc);
54
+ if (Number.isNaN(date.getTime())) {
55
+ throw new Error(`Invalid date: ${dateString}`);
56
+ }
57
+ return date;
58
+ };
59
+ const formatDate = (date) => {
60
+ return dateFormatter.format(date);
61
+ };
62
+ const formatTime = (date) => {
63
+ return date.getSeconds() === 0 ? timeFormatterNoSeconds.format(date) : timeFormatterWithSeconds.format(date);
64
+ };
65
+ const formatDateTime = (date) => {
66
+ return date.getSeconds() === 0 ? dateTimeFormatterNoSeconds.format(date) : dateTimeFormatterWithSeconds.format(date);
67
+ };
68
+ const getTimePeriod = (date) => {
69
+ const hours = date.getHours();
70
+ if (hours >= 5 && hours < 8) return "Early Morning";
71
+ if (hours >= 8 && hours < 12) return "Morning";
72
+ if (hours >= 12 && hours < 14) return "Noon";
73
+ if (hours >= 14 && hours < 17) return "Afternoon";
74
+ if (hours >= 17 && hours < 20) return "Evening";
75
+ if (hours >= 20 && hours < 22) return "Late Evening";
76
+ return "Night";
77
+ };
78
+ const getRelativeTime = (dateString) => {
79
+ const now = /* @__PURE__ */ new Date();
80
+ const utcDate = toUtcDate(dateString);
81
+ const diffMs = now.getTime() - utcDate.getTime();
82
+ const diffSec = Math.floor(diffMs / 1e3);
83
+ const diffMin = Math.floor(diffSec / 60);
84
+ const diffHr = Math.floor(diffMin / 60);
85
+ const diffDay = Math.floor(diffHr / 24);
86
+ if (diffSec < 60) return "Just now";
87
+ if (diffMin < 60) return `${diffMin} minute${diffMin > 1 ? "s" : ""} ago`;
88
+ if (diffHr < 24) return `${diffHr} hour${diffHr > 1 ? "s" : ""} ago`;
89
+ if (diffDay < 7) return `${diffDay} day${diffDay > 1 ? "s" : ""} ago`;
90
+ return formatDate(utcDate);
91
+ };
92
+ const parseAndFormatDate = (dateString, format) => {
93
+ if (format === "relative") {
94
+ return getRelativeTime(dateString);
95
+ }
96
+ const utcDate = toUtcDate(dateString);
97
+ switch (props.controlType) {
98
+ case "date":
99
+ return formatDate(utcDate);
100
+ case "time":
101
+ return `${formatTime(utcDate)} ${timeZoneAbbr} (${getTimePeriod(
102
+ utcDate
103
+ )})`;
104
+ default:
105
+ return formatDateTime(utcDate);
106
+ }
107
+ };
108
+ let localDateTime = "";
109
+ try {
110
+ localDateTime = parseAndFormatDate(props.value, props.format);
111
+ } catch (error) {
112
+ console.error("Error parsing date:", props.value, error);
113
+ }
114
+ return /* @__PURE__ */ jsxs("div", { className: "inline-flex flex-wrap gap-1", children: [
115
+ /* @__PURE__ */ jsx("span", { children: localDateTime }),
116
+ !props.format && props.controlType !== "date" && props.controlType !== "datetime" && timeZoneAbbr && /* @__PURE__ */ jsx("span", { children: timeZoneAbbr })
117
+ ] });
118
+ };
119
+ var DateViewClient_default = DateViewClient;
120
+
121
+ export {
122
+ DateViewClient_default
123
+ };