@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260722101954

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.
Files changed (60) hide show
  1. package/dist/CopyButton-UPJPMJUB.mjs +57 -0
  2. package/dist/CopyButton-XONTQQW7.mjs +55 -0
  3. package/dist/DateTimeViewClient-22GW4AD7.mjs +14 -0
  4. package/dist/DateTimeViewClient-K5FE5VSN.mjs +14 -0
  5. package/dist/DateTimeViewClient-M7V35KUW.mjs +16 -0
  6. package/dist/DateTimeViewClient-R3M6ISVK.mjs +16 -0
  7. package/dist/DateViewClient-4CTEMOMJ.mjs +7 -0
  8. package/dist/DateViewClient-ELEHLGWS.mjs +7 -0
  9. package/dist/DateViewClient-JBS5UXMD.mjs +9 -0
  10. package/dist/DateViewClient-VLTRN47D.mjs +9 -0
  11. package/dist/EnterAnimationClient-4OKXLKSA.mjs +45 -0
  12. package/dist/EnterAnimationClient-ZN3NLFNO.mjs +47 -0
  13. package/dist/HlsPlayer-57543DTW.mjs +599 -0
  14. package/dist/HlsPlayer-5AWFZ2P6.mjs +601 -0
  15. package/dist/IframeClient-J22NMEVY.mjs +96 -0
  16. package/dist/IframeClient-RGJFZ5P2.mjs +98 -0
  17. package/dist/InputControlClient-7NS4QUWO.mjs +677 -0
  18. package/dist/InputControlClient-AZRPSTUZ.mjs +677 -0
  19. package/dist/InputControlClient-BUOYZNWQ.mjs +675 -0
  20. package/dist/InputControlClient-HIZOJLKW.mjs +677 -0
  21. package/dist/LinkNodeButton-AOEDCCL7.mjs +227 -0
  22. package/dist/LinkNodeButton-BIZA2NPE.mjs +225 -0
  23. package/dist/LinkNodeButton-LX3KKGZY.mjs +173 -0
  24. package/dist/LinkNodeButton-U7T2NP22.mjs +374 -0
  25. package/dist/Pagination-6OFACRMQ.mjs +229 -0
  26. package/dist/Pagination-NCJCOYHF.mjs +181 -0
  27. package/dist/Pagination-OQT7Q2XO.mjs +183 -0
  28. package/dist/Pagination-T7YN2OMV.mjs +183 -0
  29. package/dist/Slider-554BKC7N.mjs +322 -0
  30. package/dist/Slider-PEIVH6A5.mjs +320 -0
  31. package/dist/chunk-23WJE3YB.mjs +253 -0
  32. package/dist/chunk-3GWLDT7C.mjs +204 -0
  33. package/dist/chunk-3R4VVVNK.mjs +903 -0
  34. package/dist/chunk-56HSDML5.mjs +22 -0
  35. package/dist/chunk-5GHPW7SJ.mjs +111 -0
  36. package/dist/chunk-7ZFZLN56.mjs +903 -0
  37. package/dist/chunk-DBHUCH4B.mjs +109 -0
  38. package/dist/chunk-DKW4DXCU.mjs +120 -0
  39. package/dist/chunk-FI2KJBK2.mjs +110 -0
  40. package/dist/chunk-IMNQO57B.mjs +25 -0
  41. package/dist/chunk-JKP4XOZB.mjs +214 -0
  42. package/dist/chunk-OGGIS4AN.mjs +201 -0
  43. package/dist/chunk-RHVNJMS4.mjs +251 -0
  44. package/dist/chunk-SPRVN5IM.mjs +118 -0
  45. package/dist/chunk-TVL6KVD5.mjs +229 -0
  46. package/dist/chunk-UFKPTMM7.mjs +199 -0
  47. package/dist/chunk-WEV5U33G.mjs +207 -0
  48. package/dist/chunk-X3YSXTD2.mjs +201 -0
  49. package/dist/chunk-XG6SXZWP.mjs +115 -0
  50. package/dist/chunk-YBNWT4TV.mjs +123 -0
  51. package/dist/chunk-YG6FKKQJ.mjs +900 -0
  52. package/dist/index.d.mts +456 -0
  53. package/dist/index.d.ts +456 -0
  54. package/dist/index.js +8566 -0
  55. package/dist/index.mjs +4285 -0
  56. package/dist/server.d.mts +113 -0
  57. package/dist/server.d.ts +113 -0
  58. package/dist/server.js +5179 -0
  59. package/dist/server.mjs +2736 -0
  60. package/package.json +95 -0
@@ -0,0 +1,109 @@
1
+ import {
2
+ buttonClasses
3
+ } from "./chunk-56HSDML5.mjs";
4
+
5
+ // src/components/controls/edit/InputControlType.tsx
6
+ var Constants = {
7
+ pagesize: 10
8
+ };
9
+ var InputControlType = {
10
+ lineTextInput: "text",
11
+ multilineTextInput: "multilinetext",
12
+ emailInput: "email",
13
+ moneyInput: "money",
14
+ select: "select",
15
+ percentageInput: "percentage",
16
+ asset: "asset",
17
+ phoneInput: "phone",
18
+ numberInput: "number",
19
+ checkboxInput: "boolean",
20
+ otpInput: "otp",
21
+ datetimeInput: "datetime",
22
+ timeInput: "time",
23
+ colorInput: "colorInput",
24
+ selectWithSearchInput: "selectWithSearchInput",
25
+ selectWithSearchPanel: "selectWithSearchPanel",
26
+ booleanSelect: "booleanSelect",
27
+ switchInput: "switchInput",
28
+ videoInput: "videoInput"
29
+ };
30
+ var InputControlType_default = InputControlType;
31
+
32
+ // src/components/dataForm/Hyperlink.tsx
33
+ import Link from "next/link";
34
+ import { Fragment, jsx } from "react/jsx-runtime";
35
+ function Hyperlink(props) {
36
+ let linkClass = props.linkType ? buttonClasses.get(props.linkType) : buttonClasses.get("Link" /* Link */);
37
+ const target = props?.href?.startsWith("http") ? "_blank" : "_self";
38
+ const additionalProps = {};
39
+ if (target == "_blank") {
40
+ additionalProps.rel = "noopener noreferrer";
41
+ }
42
+ return /* @__PURE__ */ jsx(Fragment, { children: props.href ? /* @__PURE__ */ jsx(
43
+ Link,
44
+ {
45
+ href: props.href,
46
+ prefetch: false,
47
+ className: [linkClass, props.className].filter(Boolean).join(" "),
48
+ ...additionalProps,
49
+ target,
50
+ children: props.children
51
+ }
52
+ ) : props.isHeading ? /* @__PURE__ */ jsx("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ jsx("span", { className: props.className, children: props.children }) });
53
+ }
54
+
55
+ // src/svg/chevron-updown.tsx
56
+ import { jsx as jsx2 } from "react/jsx-runtime";
57
+ var ChevronUpDown = (props) => {
58
+ return /* @__PURE__ */ jsx2("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) });
59
+ };
60
+ var chevron_updown_default = ChevronUpDown;
61
+
62
+ // src/svg/chevron-down.tsx
63
+ import { jsx as jsx3 } from "react/jsx-runtime";
64
+ var ChevronDown = (props) => {
65
+ return /* @__PURE__ */ jsx3("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) });
66
+ };
67
+ var chevron_down_default = ChevronDown;
68
+
69
+ // src/svg/chevron-up.tsx
70
+ import { jsx as jsx4 } from "react/jsx-runtime";
71
+ var ChevronUp = (props) => {
72
+ return /* @__PURE__ */ jsx4("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) });
73
+ };
74
+ var chevron_up_default = ChevronUp;
75
+
76
+ // src/svg/plus.tsx
77
+ import { jsx as jsx5 } from "react/jsx-runtime";
78
+ var Plus = (props) => {
79
+ return /* @__PURE__ */ jsx5("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx5("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" }) });
80
+ };
81
+ var plus_default = Plus;
82
+
83
+ // src/svg/Icons.tsx
84
+ var Icons = {
85
+ chevronUpDown: chevron_updown_default,
86
+ chevronDown: chevron_down_default,
87
+ chevronUp: chevron_up_default,
88
+ plus: plus_default
89
+ };
90
+ var Icons_default = Icons;
91
+
92
+ // src/svg/Icon.tsx
93
+ import { jsx as jsx6 } from "react/jsx-runtime";
94
+ var Icon = ({ name, className, ...props }) => {
95
+ const IconComponent = Icons_default[name];
96
+ if (!IconComponent) {
97
+ console.error(`Icon "${name}" not found.`);
98
+ return null;
99
+ }
100
+ return /* @__PURE__ */ jsx6(IconComponent, { ...props, className });
101
+ };
102
+ var Icon_default = Icon;
103
+
104
+ export {
105
+ Constants,
106
+ InputControlType_default,
107
+ Hyperlink,
108
+ Icon_default
109
+ };
@@ -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
+ };
@@ -0,0 +1,110 @@
1
+ "use client";
2
+
3
+ import {
4
+ buttonClasses
5
+ } from "./chunk-IMNQO57B.mjs";
6
+
7
+ // src/components/controls/edit/InputControlType.tsx
8
+ var Constants = {
9
+ pagesize: 10
10
+ };
11
+ var InputControlType = {
12
+ lineTextInput: "text",
13
+ multilineTextInput: "multilinetext",
14
+ emailInput: "email",
15
+ moneyInput: "money",
16
+ select: "select",
17
+ percentageInput: "percentage",
18
+ asset: "asset",
19
+ phoneInput: "phone",
20
+ numberInput: "number",
21
+ checkboxInput: "boolean",
22
+ otpInput: "otp",
23
+ datetimeInput: "datetime",
24
+ timeInput: "time",
25
+ colorInput: "colorInput",
26
+ selectWithSearchInput: "selectWithSearchInput",
27
+ selectWithSearchPanel: "selectWithSearchPanel",
28
+ booleanSelect: "booleanSelect",
29
+ switchInput: "switchInput"
30
+ };
31
+ var InputControlType_default = InputControlType;
32
+
33
+ // src/components/dataForm/Hyperlink.tsx
34
+ import Link from "next/link";
35
+ import { Fragment, jsx } from "react/jsx-runtime";
36
+ function Hyperlink(props) {
37
+ let linkClass = props.linkType ? buttonClasses.get(props.linkType) : buttonClasses.get("Link" /* Link */);
38
+ const target = props?.href?.startsWith("http") ? "_blank" : "_self";
39
+ const additionalProps = {};
40
+ if (target == "_blank") {
41
+ additionalProps.rel = "noopener noreferrer";
42
+ }
43
+ return /* @__PURE__ */ jsx(Fragment, { children: props.href ? /* @__PURE__ */ jsx(
44
+ Link,
45
+ {
46
+ href: props.href,
47
+ prefetch: false,
48
+ className: [linkClass, props.className].filter(Boolean).join(" "),
49
+ ...additionalProps,
50
+ target,
51
+ children: props.children
52
+ }
53
+ ) : props.isHeading ? /* @__PURE__ */ jsx("h5", { className: props.className + "inline-block", children: props.children }) : /* @__PURE__ */ jsx("span", { className: props.className, children: props.children }) });
54
+ }
55
+
56
+ // src/svg/chevron-updown.tsx
57
+ import { jsx as jsx2 } from "react/jsx-runtime";
58
+ var ChevronUpDown = (props) => {
59
+ return /* @__PURE__ */ jsx2("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) });
60
+ };
61
+ var chevron_updown_default = ChevronUpDown;
62
+
63
+ // src/svg/chevron-down.tsx
64
+ import { jsx as jsx3 } from "react/jsx-runtime";
65
+ var ChevronDown = (props) => {
66
+ return /* @__PURE__ */ jsx3("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) });
67
+ };
68
+ var chevron_down_default = ChevronDown;
69
+
70
+ // src/svg/chevron-up.tsx
71
+ import { jsx as jsx4 } from "react/jsx-runtime";
72
+ var ChevronUp = (props) => {
73
+ return /* @__PURE__ */ jsx4("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx4("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) });
74
+ };
75
+ var chevron_up_default = ChevronUp;
76
+
77
+ // src/svg/plus.tsx
78
+ import { jsx as jsx5 } from "react/jsx-runtime";
79
+ var Plus = (props) => {
80
+ return /* @__PURE__ */ jsx5("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: props.className, children: /* @__PURE__ */ jsx5("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" }) });
81
+ };
82
+ var plus_default = Plus;
83
+
84
+ // src/svg/Icons.tsx
85
+ var Icons = {
86
+ chevronUpDown: chevron_updown_default,
87
+ chevronDown: chevron_down_default,
88
+ chevronUp: chevron_up_default,
89
+ plus: plus_default
90
+ };
91
+ var Icons_default = Icons;
92
+
93
+ // src/svg/Icon.tsx
94
+ import { jsx as jsx6 } from "react/jsx-runtime";
95
+ var Icon = ({ name, className, ...props }) => {
96
+ const IconComponent = Icons_default[name];
97
+ if (!IconComponent) {
98
+ console.error(`Icon "${name}" not found.`);
99
+ return null;
100
+ }
101
+ return /* @__PURE__ */ jsx6(IconComponent, { ...props, className });
102
+ };
103
+ var Icon_default = Icon;
104
+
105
+ export {
106
+ Constants,
107
+ InputControlType_default,
108
+ Hyperlink,
109
+ Icon_default
110
+ };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+
4
+ // src/components/StyleTypes.tsx
5
+ var buttonClasses = /* @__PURE__ */ new Map([
6
+ [
7
+ "Primary" /* Solid */,
8
+ "btn-solid relative inline-flex items-center justify-center rounded px-4 py-3 lg:py-2 font-medium shadow-sm hover:shadow-lg focus:outline-none active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed transition duration-150 ease-in-out"
9
+ ],
10
+ [
11
+ "PrimaryHollow" /* Hollow */,
12
+ "btn-hollow inline-flex font-medium items-center justify-center px-4 py-3 lg:py-2 rounded hover:shadow-md focus:outline-none transition duration-150 ease-in-out active:scale-95"
13
+ ],
14
+ ["Link" /* Link */, "btn-link"]
15
+ ]);
16
+ var progressClasses = /* @__PURE__ */ new Map([
17
+ ["Primary" /* Solid */, ""],
18
+ ["PrimaryHollow" /* Hollow */, ""],
19
+ ["Link" /* Link */, ""]
20
+ ]);
21
+
22
+ export {
23
+ buttonClasses,
24
+ progressClasses
25
+ };
@@ -0,0 +1,214 @@
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 { 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("Are you sure you want to delete this item?");
143
+ setShowModal(null);
144
+ if (!confirmed) {
145
+ return;
146
+ }
147
+ }
148
+ if (props.oneTimeAction && isActionPerformed) {
149
+ return;
150
+ }
151
+ setInProgress(true);
152
+ let isValid = true;
153
+ if (props.onValidate !== void 0) {
154
+ isValid = await props.onValidate();
155
+ if (!isValid) {
156
+ setInProgress(false);
157
+ ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
158
+ return;
159
+ }
160
+ }
161
+ if (props.onClick !== void 0) {
162
+ let response = await props.onClick();
163
+ if (response.isSuccessful) {
164
+ setIsActionPerformed(true);
165
+ setResponseMessage(response.message);
166
+ if (props.showToast) {
167
+ ToastService_default.showInfo(response.message || "");
168
+ }
169
+ } else {
170
+ ToastService_default.showError(response.message || "");
171
+ }
172
+ } else {
173
+ ToastService_default.showError("No action defined.");
174
+ }
175
+ setInProgress(false);
176
+ };
177
+ const showConfirmation = (message) => {
178
+ return new Promise((resolve) => {
179
+ const onConfirm = () => resolve(true);
180
+ const onCancel = () => resolve(false);
181
+ setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
182
+ });
183
+ };
184
+ let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
185
+ let progressClass = props.ButtonType ? progressClasses.get(props.ButtonType) : progressClasses.get("Primary" /* Solid */);
186
+ const isDisabled = inProgress || isActionPerformed && props.oneTimeAction;
187
+ return /* @__PURE__ */ jsxs2(React3.Fragment, { children: [
188
+ /* @__PURE__ */ jsxs2(
189
+ "button",
190
+ {
191
+ type: "submit",
192
+ onClick: execute,
193
+ disabled: props.disabled,
194
+ title: isDisabled ? "The button is disabled to prevent any action" : "",
195
+ className: buttonClass + " relative " + props.className,
196
+ children: [
197
+ isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
198
+ 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: [
199
+ /* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
200
+ /* @__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" })
201
+ ] }) })
202
+ ]
203
+ }
204
+ ),
205
+ showModal
206
+ ] });
207
+ };
208
+ var Button_default = Button;
209
+
210
+ export {
211
+ ToastService_default,
212
+ ClientButton_default,
213
+ Button_default
214
+ };