@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260326110644 → 0.8.1-dev.20260328105340
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/CopyButton-XONTQQW7.mjs +55 -0
- package/dist/HlsPlayer-FFEIK6FG.mjs +7 -0
- package/dist/IframeClient-J22NMEVY.mjs +96 -0
- package/dist/LinkNodeButton-KBSXOEHS.mjs +169 -0
- package/dist/chunk-3IDT4246.mjs +400 -0
- package/dist/chunk-CVVLFQ4J.mjs +131 -0
- package/dist/index.d.mts +32 -17
- package/dist/index.d.ts +32 -17
- package/dist/index.js +3636 -1392
- package/dist/index.mjs +2571 -1263
- package/package.json +7 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/CopyButton.tsx
|
|
4
|
+
import { useState, useRef, useEffect } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
function CopyButton({ text }) {
|
|
7
|
+
const [copied, setCopied] = useState(false);
|
|
8
|
+
const timeoutRef = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
return () => {
|
|
11
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
12
|
+
};
|
|
13
|
+
}, []);
|
|
14
|
+
const handleCopy = async () => {
|
|
15
|
+
try {
|
|
16
|
+
await navigator.clipboard.writeText(text);
|
|
17
|
+
setCopied(true);
|
|
18
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
19
|
+
timeoutRef.current = setTimeout(() => setCopied(false), 2e3);
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error("Failed to copy: ", err);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return /* @__PURE__ */ jsxs(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
onClick: handleCopy,
|
|
28
|
+
className: "flex gap-1 items-center hover:text-white transition",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
"svg",
|
|
32
|
+
{
|
|
33
|
+
width: "16",
|
|
34
|
+
height: "16",
|
|
35
|
+
viewBox: "0 0 24 24",
|
|
36
|
+
className: "w-4 h-4",
|
|
37
|
+
fill: "currentColor",
|
|
38
|
+
children: /* @__PURE__ */ jsx(
|
|
39
|
+
"path",
|
|
40
|
+
{
|
|
41
|
+
fillRule: "evenodd",
|
|
42
|
+
clipRule: "evenodd",
|
|
43
|
+
d: "M12 4C10.8954 4 10 4.89543 10 6H14C14 4.89543 13.1046 4 12 4ZM8.53513 4C9.22675 2.8044 10.5194 2 12 2C13.4806 2 14.7733 2.8044 15.4649 4H17C18.6569 4 20 5.34315 20 7V19C20 20.6569 18.6569 22 17 22H7C5.34315 22 4 20.6569 4 19V7C4 5.34315 5.34315 4 7 4H8.53513ZM8 6H7C6.44772 6 6 6.44772 6 7V19C6 19.5523 6.44772 20 7 20H17C17.5523 20 18 19.5523 18 19V7C18 6.44772 17.5523 6 17 6H16C16 7.10457 15.1046 8 14 8H10C8.89543 8 8 7.10457 8 6Z"
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
copied ? "Copied!" : "Copy code"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
CopyButton as default
|
|
55
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/components/pageRenderingEngine/nodes/IframeClient.tsx
|
|
4
|
+
import React2, { useEffect, useRef, useState } from "react";
|
|
5
|
+
|
|
6
|
+
// src/components/IFrameLoaderView.tsx
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var IFrameLoaderView = (props) => {
|
|
10
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
11
|
+
props.isDataFound == null && /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsxs("div", { className: "mt-4 bg-gray-200 rounded-md p-4 animate-pulse", children: [
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center mb-4", children: [
|
|
13
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 h-8 w-8 rounded-full animate-pulse" }),
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { className: "ml-2", children: [
|
|
15
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 h-3 w-16 animate-pulse" }),
|
|
16
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 h-2 w-12 animate-pulse" })
|
|
17
|
+
] })
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4 mt-6", children: [
|
|
20
|
+
/* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
|
|
21
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
|
|
22
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
|
|
23
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
|
|
24
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
|
|
25
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
|
|
26
|
+
] }),
|
|
27
|
+
/* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
|
|
28
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
|
|
29
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
|
|
30
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
|
|
31
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
|
|
32
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
|
|
33
|
+
] }),
|
|
34
|
+
/* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
|
|
35
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-12 mb-2" }),
|
|
36
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-24 mb-2" }),
|
|
37
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-32 mb-2" }),
|
|
38
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-16 mb-2" }),
|
|
39
|
+
/* @__PURE__ */ jsx("div", { className: "bg-gray-300 rounded-full h-3 w-28 mb-2" })
|
|
40
|
+
] })
|
|
41
|
+
] })
|
|
42
|
+
] }) }),
|
|
43
|
+
props.children
|
|
44
|
+
] });
|
|
45
|
+
};
|
|
46
|
+
var IFrameLoaderView_default = IFrameLoaderView;
|
|
47
|
+
|
|
48
|
+
// src/components/pageRenderingEngine/nodes/IframeClient.tsx
|
|
49
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
50
|
+
var IframeClient = ({ src }) => {
|
|
51
|
+
const iframeRef = useRef(null);
|
|
52
|
+
const [iframeHeight, setIframeHeight] = useState("100%");
|
|
53
|
+
const [isDataFound, setIsDataFound] = useState(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const handleReceiveMessage = (event) => {
|
|
56
|
+
const eventName = event?.data?.eventName;
|
|
57
|
+
const payload = event?.data?.payload;
|
|
58
|
+
if (eventName === "SET_HEIGHT" && payload?.height) {
|
|
59
|
+
let height = 500;
|
|
60
|
+
if (payload.height > 500) {
|
|
61
|
+
height = payload.height + 50;
|
|
62
|
+
}
|
|
63
|
+
setIframeHeight(`${height}px`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
window.addEventListener("message", handleReceiveMessage);
|
|
67
|
+
return () => window.removeEventListener("message", handleReceiveMessage);
|
|
68
|
+
}, []);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const handleResize = () => {
|
|
71
|
+
if (iframeRef.current) {
|
|
72
|
+
iframeRef.current.contentWindow?.postMessage({ eventName: "RESIZE" }, "*");
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener("resize", handleResize);
|
|
76
|
+
return () => window.removeEventListener("resize", handleResize);
|
|
77
|
+
}, []);
|
|
78
|
+
const handleIframeLoad = () => {
|
|
79
|
+
setIsDataFound(true);
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsx2(React2.Fragment, { children: /* @__PURE__ */ jsx2(IFrameLoaderView_default, { isDataFound, children: /* @__PURE__ */ jsx2(
|
|
82
|
+
"iframe",
|
|
83
|
+
{
|
|
84
|
+
ref: iframeRef,
|
|
85
|
+
src,
|
|
86
|
+
className: "w-full h-full border-none",
|
|
87
|
+
scrolling: "no",
|
|
88
|
+
style: { height: iframeHeight },
|
|
89
|
+
onLoad: handleIframeLoad
|
|
90
|
+
}
|
|
91
|
+
) }) });
|
|
92
|
+
};
|
|
93
|
+
var IframeClient_default = IframeClient;
|
|
94
|
+
export {
|
|
95
|
+
IframeClient_default as default
|
|
96
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Button_default,
|
|
4
|
+
ServiceClient_default
|
|
5
|
+
} from "./chunk-3IDT4246.mjs";
|
|
6
|
+
|
|
7
|
+
// src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
|
|
8
|
+
import { useCallback, useState } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var LinkNodeButton = (props) => {
|
|
11
|
+
const { node, dataitem, children, linkText, linkType, linkUrl } = props;
|
|
12
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
13
|
+
const [error, setError] = useState(null);
|
|
14
|
+
const extractFieldNames = useCallback((template) => {
|
|
15
|
+
if (!template) return [];
|
|
16
|
+
const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
|
|
17
|
+
const matches = Array.from(template.matchAll(regex));
|
|
18
|
+
const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
|
|
19
|
+
return fieldNames;
|
|
20
|
+
}, []);
|
|
21
|
+
const replaceTemplateVariables = useCallback((template, responseData) => {
|
|
22
|
+
if (!template) return template;
|
|
23
|
+
let result = template;
|
|
24
|
+
const fieldNames = extractFieldNames(template);
|
|
25
|
+
if (responseData) {
|
|
26
|
+
fieldNames.forEach((fieldName) => {
|
|
27
|
+
const value = getNestedValue(responseData, fieldName);
|
|
28
|
+
if (value !== void 0) {
|
|
29
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
30
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
31
|
+
result = result.replace(regex1, String(value));
|
|
32
|
+
result = result.replace(regex2, String(value));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (props.routeParameters) {
|
|
37
|
+
Object.entries(props.routeParameters).forEach(([key, value]) => {
|
|
38
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
39
|
+
result = result.replace(regex, String(value));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (dataitem) {
|
|
43
|
+
Object.entries(dataitem).forEach(([key, value]) => {
|
|
44
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
45
|
+
result = result.replace(regex, String(value));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}, [props.routeParameters, dataitem, extractFieldNames]);
|
|
50
|
+
const getNestedValue = useCallback((obj, path) => {
|
|
51
|
+
if (!obj || !path) return void 0;
|
|
52
|
+
if (obj[path] !== void 0) {
|
|
53
|
+
return obj[path];
|
|
54
|
+
}
|
|
55
|
+
const keys = path.split(".");
|
|
56
|
+
let current = obj;
|
|
57
|
+
for (const key of keys) {
|
|
58
|
+
if (current[key] === void 0) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
current = current[key];
|
|
62
|
+
}
|
|
63
|
+
return current;
|
|
64
|
+
}, []);
|
|
65
|
+
const onClick = useCallback(async (e) => {
|
|
66
|
+
if (!node.postUrl) {
|
|
67
|
+
setError("No POST URL configured for this button");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
setIsLoading(true);
|
|
71
|
+
setError(null);
|
|
72
|
+
try {
|
|
73
|
+
const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
|
|
74
|
+
let parsedPayload = {};
|
|
75
|
+
if (node.payload) {
|
|
76
|
+
try {
|
|
77
|
+
const payloadStr = replaceTemplateVariables(node.payload);
|
|
78
|
+
parsedPayload = JSON.parse(payloadStr);
|
|
79
|
+
console.log("Parsed payload:", parsedPayload);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error("Failed to parse payload JSON:", err);
|
|
82
|
+
parsedPayload = { error: "Invalid payload JSON" };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
|
|
86
|
+
const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
|
|
87
|
+
console.log("API Response:", response);
|
|
88
|
+
if (response && !response.isSuccessful) {
|
|
89
|
+
const errorMessage = response.message || "API request failed";
|
|
90
|
+
setError(errorMessage);
|
|
91
|
+
setIsLoading(false);
|
|
92
|
+
return { isSuccessful: false, message: errorMessage };
|
|
93
|
+
}
|
|
94
|
+
if (response && node.redirectUrl) {
|
|
95
|
+
const fieldNames = extractFieldNames(node.redirectUrl);
|
|
96
|
+
console.log("Field names in redirect URL:", fieldNames);
|
|
97
|
+
const fieldValueMap = {};
|
|
98
|
+
fieldNames.forEach((fieldName) => {
|
|
99
|
+
const value = getNestedValue(response, fieldName);
|
|
100
|
+
if (value !== void 0) {
|
|
101
|
+
fieldValueMap[fieldName] = String(value);
|
|
102
|
+
} else {
|
|
103
|
+
const resultValue = getNestedValue(response, `result.${fieldName}`);
|
|
104
|
+
if (resultValue !== void 0) {
|
|
105
|
+
fieldValueMap[fieldName] = String(resultValue);
|
|
106
|
+
} else {
|
|
107
|
+
const dataValue = getNestedValue(response, `data.${fieldName}`);
|
|
108
|
+
if (dataValue !== void 0) {
|
|
109
|
+
fieldValueMap[fieldName] = String(dataValue);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
console.log("Field value map:", fieldValueMap);
|
|
115
|
+
const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
|
|
116
|
+
if (missingFields.length > 0) {
|
|
117
|
+
console.warn(`Missing field values for: ${missingFields.join(", ")}`);
|
|
118
|
+
}
|
|
119
|
+
let resolvedRedirectUrl = node.redirectUrl;
|
|
120
|
+
Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
|
|
121
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
122
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
123
|
+
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
|
|
124
|
+
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
|
|
125
|
+
});
|
|
126
|
+
resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
|
|
127
|
+
console.log("Final redirect URL:", resolvedRedirectUrl);
|
|
128
|
+
if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
|
|
129
|
+
window.location.href = resolvedRedirectUrl;
|
|
130
|
+
}
|
|
131
|
+
} else if (response && !response.result && response.message) {
|
|
132
|
+
setError(response.message);
|
|
133
|
+
throw new Error(response.message);
|
|
134
|
+
} else if (!response) {
|
|
135
|
+
setError("No response from server");
|
|
136
|
+
}
|
|
137
|
+
setIsLoading(false);
|
|
138
|
+
return { isSuccessful: true, response };
|
|
139
|
+
} catch (err) {
|
|
140
|
+
console.error("Button API call failed:", err);
|
|
141
|
+
setError(err.message || "An unexpected error occurred");
|
|
142
|
+
setIsLoading(false);
|
|
143
|
+
return { isSuccessful: false, message: err.message };
|
|
144
|
+
}
|
|
145
|
+
}, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue, props.apiBaseUrl, props.session]);
|
|
146
|
+
const renderButtonContent = () => {
|
|
147
|
+
if (children) {
|
|
148
|
+
return children;
|
|
149
|
+
}
|
|
150
|
+
if (linkText) {
|
|
151
|
+
return /* @__PURE__ */ jsx("span", { children: linkText });
|
|
152
|
+
}
|
|
153
|
+
return node.title || "Button";
|
|
154
|
+
};
|
|
155
|
+
return /* @__PURE__ */ jsx("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx(
|
|
156
|
+
Button_default,
|
|
157
|
+
{
|
|
158
|
+
ButtonType: linkType,
|
|
159
|
+
onClick,
|
|
160
|
+
disabled: isLoading,
|
|
161
|
+
className: "w-full",
|
|
162
|
+
children: renderButtonContent()
|
|
163
|
+
}
|
|
164
|
+
) });
|
|
165
|
+
};
|
|
166
|
+
var LinkNodeButton_default = LinkNodeButton;
|
|
167
|
+
export {
|
|
168
|
+
LinkNodeButton_default as default
|
|
169
|
+
};
|