@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260722073037 → 0.8.1-dev.20260722074927
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/{InputControlClient-QAZKQLFO.mjs → InputControlClient-7NS4QUWO.mjs} +1 -1
- package/dist/{InputControlClient-QQCQD4EG.mjs → InputControlClient-BUOYZNWQ.mjs} +1 -1
- package/dist/LinkNodeButton-AOEDCCL7.mjs +227 -0
- package/dist/{LinkNodeButton-XA7Z5IDR.mjs → LinkNodeButton-BIZA2NPE.mjs} +92 -38
- package/dist/chunk-23WJE3YB.mjs +253 -0
- package/dist/{chunk-YL6E76X2.mjs → chunk-RHVNJMS4.mjs} +48 -9
- package/dist/index.js +137 -44
- package/dist/index.mjs +17 -19
- package/package.json +1 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import {
|
|
5
|
+
ServiceClient_default
|
|
6
|
+
} from "./chunk-WEV5U33G.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Button_default,
|
|
9
|
+
ToastService_default
|
|
10
|
+
} from "./chunk-23WJE3YB.mjs";
|
|
11
|
+
import "./chunk-IMNQO57B.mjs";
|
|
12
|
+
|
|
13
|
+
// src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
|
|
14
|
+
import { useCallback, useState } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
var LinkNodeButton = (props) => {
|
|
17
|
+
const { node, dataitem, children, linkText, linkType, linkUrl } = props;
|
|
18
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
19
|
+
const [successMessage, setSuccessMessage] = useState(null);
|
|
20
|
+
console.log("LinkNodeButton props:", props);
|
|
21
|
+
const extractFieldNames = useCallback((template) => {
|
|
22
|
+
if (!template) return [];
|
|
23
|
+
const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
|
|
24
|
+
const matches = Array.from(template.matchAll(regex));
|
|
25
|
+
const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
|
|
26
|
+
return fieldNames;
|
|
27
|
+
}, []);
|
|
28
|
+
const replaceTemplateVariables = useCallback(
|
|
29
|
+
(template, responseData) => {
|
|
30
|
+
if (!template) return template;
|
|
31
|
+
let result = template;
|
|
32
|
+
const fieldNames = extractFieldNames(template);
|
|
33
|
+
if (responseData) {
|
|
34
|
+
fieldNames.forEach((fieldName) => {
|
|
35
|
+
const value = getNestedValue(responseData, fieldName);
|
|
36
|
+
if (value !== void 0) {
|
|
37
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
38
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
39
|
+
result = result.replace(regex1, String(value));
|
|
40
|
+
result = result.replace(regex2, String(value));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (props.routeParameters) {
|
|
45
|
+
Object.entries(props.routeParameters).forEach(([key, value]) => {
|
|
46
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
47
|
+
result = result.replace(regex, String(value));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (dataitem) {
|
|
51
|
+
Object.entries(dataitem).forEach(([key, value]) => {
|
|
52
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
53
|
+
result = result.replace(regex, String(value));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
},
|
|
58
|
+
[props.routeParameters, dataitem, extractFieldNames]
|
|
59
|
+
);
|
|
60
|
+
const getNestedValue = useCallback((obj, path) => {
|
|
61
|
+
if (!obj || !path) return void 0;
|
|
62
|
+
if (obj[path] !== void 0) {
|
|
63
|
+
return obj[path];
|
|
64
|
+
}
|
|
65
|
+
const keys = path.split(".");
|
|
66
|
+
let current = obj;
|
|
67
|
+
for (const key of keys) {
|
|
68
|
+
if (current[key] === void 0) {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
current = current[key];
|
|
72
|
+
}
|
|
73
|
+
return current;
|
|
74
|
+
}, []);
|
|
75
|
+
const onClick = useCallback(async () => {
|
|
76
|
+
if (!node.postUrl) {
|
|
77
|
+
return {
|
|
78
|
+
isSuccessful: false,
|
|
79
|
+
message: "No POST URL configured for this button"
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
setIsLoading(true);
|
|
83
|
+
try {
|
|
84
|
+
const resolvedPostUrl = replaceTemplateVariables(node.postUrl);
|
|
85
|
+
let parsedPayload = {};
|
|
86
|
+
if (node.payload) {
|
|
87
|
+
try {
|
|
88
|
+
const payloadStr = replaceTemplateVariables(node.payload);
|
|
89
|
+
parsedPayload = JSON.parse(payloadStr);
|
|
90
|
+
console.log("Parsed payload:", parsedPayload);
|
|
91
|
+
} catch (err) {
|
|
92
|
+
console.error("Failed to parse payload JSON:", err);
|
|
93
|
+
parsedPayload = { error: "Invalid payload JSON" };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const serviceClient = new ServiceClient_default(props.apiBaseUrl, props.session);
|
|
97
|
+
const response = await serviceClient.post(resolvedPostUrl, parsedPayload);
|
|
98
|
+
console.log("API Response:", response);
|
|
99
|
+
if (response && !response.isSuccessful) {
|
|
100
|
+
const errorMessage = response.message || "API request failed";
|
|
101
|
+
setIsLoading(false);
|
|
102
|
+
return { isSuccessful: false, message: errorMessage };
|
|
103
|
+
}
|
|
104
|
+
if (response?.message) {
|
|
105
|
+
ToastService_default.showSuccess(response.message);
|
|
106
|
+
setSuccessMessage(response.message);
|
|
107
|
+
}
|
|
108
|
+
if (response && node.redirectUrl) {
|
|
109
|
+
const fieldNames = extractFieldNames(node.redirectUrl);
|
|
110
|
+
console.log("Field names in redirect URL:", fieldNames);
|
|
111
|
+
const fieldValueMap = {};
|
|
112
|
+
fieldNames.forEach((fieldName) => {
|
|
113
|
+
const value = getNestedValue(response, fieldName);
|
|
114
|
+
if (value !== void 0) {
|
|
115
|
+
fieldValueMap[fieldName] = String(value);
|
|
116
|
+
} else {
|
|
117
|
+
const resultValue = getNestedValue(response, `result.${fieldName}`);
|
|
118
|
+
if (resultValue !== void 0) {
|
|
119
|
+
fieldValueMap[fieldName] = String(resultValue);
|
|
120
|
+
} else {
|
|
121
|
+
const dataValue = getNestedValue(response, `data.${fieldName}`);
|
|
122
|
+
if (dataValue !== void 0) {
|
|
123
|
+
fieldValueMap[fieldName] = String(dataValue);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
console.log("Field value map:", fieldValueMap);
|
|
129
|
+
const missingFields = fieldNames.filter(
|
|
130
|
+
(fieldName) => !fieldValueMap[fieldName]
|
|
131
|
+
);
|
|
132
|
+
if (missingFields.length > 0) {
|
|
133
|
+
console.warn(`Missing field values for: ${missingFields.join(", ")}`);
|
|
134
|
+
}
|
|
135
|
+
let resolvedRedirectUrl = node.redirectUrl;
|
|
136
|
+
Object.entries(fieldValueMap).forEach(([fieldName, value]) => {
|
|
137
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
138
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
139
|
+
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
|
|
140
|
+
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
|
|
141
|
+
});
|
|
142
|
+
resolvedRedirectUrl = replaceTemplateVariables(
|
|
143
|
+
resolvedRedirectUrl,
|
|
144
|
+
response
|
|
145
|
+
);
|
|
146
|
+
console.log("Final redirect URL:", resolvedRedirectUrl);
|
|
147
|
+
if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
|
|
148
|
+
window.location.href = resolvedRedirectUrl;
|
|
149
|
+
}
|
|
150
|
+
} else if (!response) {
|
|
151
|
+
const errorMessage = "No response from server";
|
|
152
|
+
setIsLoading(false);
|
|
153
|
+
return { isSuccessful: false, message: errorMessage };
|
|
154
|
+
}
|
|
155
|
+
setIsLoading(false);
|
|
156
|
+
return {
|
|
157
|
+
isSuccessful: true,
|
|
158
|
+
message: response?.message,
|
|
159
|
+
result: response
|
|
160
|
+
};
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.error("Button API call failed:", err);
|
|
163
|
+
const errorMessage = err.message || "An unexpected error occurred";
|
|
164
|
+
setIsLoading(false);
|
|
165
|
+
return { isSuccessful: false, message: errorMessage };
|
|
166
|
+
}
|
|
167
|
+
}, [
|
|
168
|
+
node.postUrl,
|
|
169
|
+
node.payload,
|
|
170
|
+
node.redirectUrl,
|
|
171
|
+
replaceTemplateVariables,
|
|
172
|
+
extractFieldNames,
|
|
173
|
+
getNestedValue,
|
|
174
|
+
props.apiBaseUrl,
|
|
175
|
+
props.session
|
|
176
|
+
]);
|
|
177
|
+
const renderButtonContent = () => {
|
|
178
|
+
if (children) {
|
|
179
|
+
return children;
|
|
180
|
+
}
|
|
181
|
+
if (linkText) {
|
|
182
|
+
return /* @__PURE__ */ jsx("span", { children: linkText });
|
|
183
|
+
}
|
|
184
|
+
return node.title || "Button";
|
|
185
|
+
};
|
|
186
|
+
const fontSize = node.children?.[0]?.style?.match(/font-size:\s*([^;]+)/)?.[1];
|
|
187
|
+
return /* @__PURE__ */ jsx("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx(
|
|
188
|
+
Button_default,
|
|
189
|
+
{
|
|
190
|
+
ButtonType: linkType,
|
|
191
|
+
onClick,
|
|
192
|
+
disabled: isLoading || !!successMessage,
|
|
193
|
+
className: "w-full",
|
|
194
|
+
children: successMessage ? /* @__PURE__ */ jsxs(
|
|
195
|
+
"span",
|
|
196
|
+
{
|
|
197
|
+
style: fontSize ? { fontSize } : void 0,
|
|
198
|
+
className: "inline-flex items-center gap-2",
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
"svg",
|
|
202
|
+
{
|
|
203
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
204
|
+
viewBox: "0 0 20 20",
|
|
205
|
+
fill: "currentColor",
|
|
206
|
+
className: "w-5 h-5",
|
|
207
|
+
children: /* @__PURE__ */ jsx(
|
|
208
|
+
"path",
|
|
209
|
+
{
|
|
210
|
+
fillRule: "evenodd",
|
|
211
|
+
d: "M16.704 5.29a1 1 0 010 1.42l-7.25 7.25a1 1 0 01-1.415 0L3.29 9.21a1 1 0 111.415-1.414l4.042 4.042 6.543-6.543a1 1 0 011.414 0z",
|
|
212
|
+
clipRule: "evenodd"
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ jsx("span", { children: successMessage })
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
) : renderButtonContent()
|
|
221
|
+
}
|
|
222
|
+
) });
|
|
223
|
+
};
|
|
224
|
+
var LinkNodeButton_default = LinkNodeButton;
|
|
225
|
+
export {
|
|
226
|
+
LinkNodeButton_default as default
|
|
227
|
+
};
|
|
@@ -5,15 +5,17 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
Button_default,
|
|
7
7
|
ToastService_default
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RHVNJMS4.mjs";
|
|
9
9
|
import "./chunk-56HSDML5.mjs";
|
|
10
10
|
|
|
11
11
|
// src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
|
|
12
12
|
import { useCallback, useState } from "react";
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
var LinkNodeButton = (props) => {
|
|
15
15
|
const { node, dataitem, children, linkText, linkType, linkUrl } = props;
|
|
16
16
|
const [isLoading, setIsLoading] = useState(false);
|
|
17
|
+
const [successMessage, setSuccessMessage] = useState(null);
|
|
18
|
+
console.log("LinkNodeButton props:", props);
|
|
17
19
|
const extractFieldNames = useCallback((template) => {
|
|
18
20
|
if (!template) return [];
|
|
19
21
|
const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
|
|
@@ -21,35 +23,38 @@ var LinkNodeButton = (props) => {
|
|
|
21
23
|
const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
|
|
22
24
|
return fieldNames;
|
|
23
25
|
}, []);
|
|
24
|
-
const replaceTemplateVariables = useCallback(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
const replaceTemplateVariables = useCallback(
|
|
27
|
+
(template, responseData) => {
|
|
28
|
+
if (!template) return template;
|
|
29
|
+
let result = template;
|
|
30
|
+
const fieldNames = extractFieldNames(template);
|
|
31
|
+
if (responseData) {
|
|
32
|
+
fieldNames.forEach((fieldName) => {
|
|
33
|
+
const value = getNestedValue(responseData, fieldName);
|
|
34
|
+
if (value !== void 0) {
|
|
35
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
36
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
37
|
+
result = result.replace(regex1, String(value));
|
|
38
|
+
result = result.replace(regex2, String(value));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (props.routeParameters) {
|
|
43
|
+
Object.entries(props.routeParameters).forEach(([key, value]) => {
|
|
44
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
45
|
+
result = result.replace(regex, String(value));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (dataitem) {
|
|
49
|
+
Object.entries(dataitem).forEach(([key, value]) => {
|
|
50
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
51
|
+
result = result.replace(regex, String(value));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
},
|
|
56
|
+
[props.routeParameters, dataitem, extractFieldNames]
|
|
57
|
+
);
|
|
53
58
|
const getNestedValue = useCallback((obj, path) => {
|
|
54
59
|
if (!obj || !path) return void 0;
|
|
55
60
|
if (obj[path] !== void 0) {
|
|
@@ -67,7 +72,10 @@ var LinkNodeButton = (props) => {
|
|
|
67
72
|
}, []);
|
|
68
73
|
const onClick = useCallback(async () => {
|
|
69
74
|
if (!node.postUrl) {
|
|
70
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
isSuccessful: false,
|
|
77
|
+
message: "No POST URL configured for this button"
|
|
78
|
+
};
|
|
71
79
|
}
|
|
72
80
|
setIsLoading(true);
|
|
73
81
|
try {
|
|
@@ -93,6 +101,7 @@ var LinkNodeButton = (props) => {
|
|
|
93
101
|
}
|
|
94
102
|
if (response?.message) {
|
|
95
103
|
ToastService_default.showSuccess(response.message);
|
|
104
|
+
setSuccessMessage(response.message);
|
|
96
105
|
}
|
|
97
106
|
if (response && node.redirectUrl) {
|
|
98
107
|
const fieldNames = extractFieldNames(node.redirectUrl);
|
|
@@ -115,7 +124,9 @@ var LinkNodeButton = (props) => {
|
|
|
115
124
|
}
|
|
116
125
|
});
|
|
117
126
|
console.log("Field value map:", fieldValueMap);
|
|
118
|
-
const missingFields = fieldNames.filter(
|
|
127
|
+
const missingFields = fieldNames.filter(
|
|
128
|
+
(fieldName) => !fieldValueMap[fieldName]
|
|
129
|
+
);
|
|
119
130
|
if (missingFields.length > 0) {
|
|
120
131
|
console.warn(`Missing field values for: ${missingFields.join(", ")}`);
|
|
121
132
|
}
|
|
@@ -126,7 +137,10 @@ var LinkNodeButton = (props) => {
|
|
|
126
137
|
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
|
|
127
138
|
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
|
|
128
139
|
});
|
|
129
|
-
resolvedRedirectUrl = replaceTemplateVariables(
|
|
140
|
+
resolvedRedirectUrl = replaceTemplateVariables(
|
|
141
|
+
resolvedRedirectUrl,
|
|
142
|
+
response
|
|
143
|
+
);
|
|
130
144
|
console.log("Final redirect URL:", resolvedRedirectUrl);
|
|
131
145
|
if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
|
|
132
146
|
window.location.href = resolvedRedirectUrl;
|
|
@@ -137,14 +151,27 @@ var LinkNodeButton = (props) => {
|
|
|
137
151
|
return { isSuccessful: false, message: errorMessage };
|
|
138
152
|
}
|
|
139
153
|
setIsLoading(false);
|
|
140
|
-
return {
|
|
154
|
+
return {
|
|
155
|
+
isSuccessful: true,
|
|
156
|
+
message: response?.message,
|
|
157
|
+
result: response
|
|
158
|
+
};
|
|
141
159
|
} catch (err) {
|
|
142
160
|
console.error("Button API call failed:", err);
|
|
143
161
|
const errorMessage = err.message || "An unexpected error occurred";
|
|
144
162
|
setIsLoading(false);
|
|
145
163
|
return { isSuccessful: false, message: errorMessage };
|
|
146
164
|
}
|
|
147
|
-
}, [
|
|
165
|
+
}, [
|
|
166
|
+
node.postUrl,
|
|
167
|
+
node.payload,
|
|
168
|
+
node.redirectUrl,
|
|
169
|
+
replaceTemplateVariables,
|
|
170
|
+
extractFieldNames,
|
|
171
|
+
getNestedValue,
|
|
172
|
+
props.apiBaseUrl,
|
|
173
|
+
props.session
|
|
174
|
+
]);
|
|
148
175
|
const renderButtonContent = () => {
|
|
149
176
|
if (children) {
|
|
150
177
|
return children;
|
|
@@ -154,14 +181,41 @@ var LinkNodeButton = (props) => {
|
|
|
154
181
|
}
|
|
155
182
|
return node.title || "Button";
|
|
156
183
|
};
|
|
184
|
+
const fontSize = node.children?.[0]?.style?.match(/font-size:\s*([^;]+)/)?.[1];
|
|
157
185
|
return /* @__PURE__ */ jsx("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx(
|
|
158
186
|
Button_default,
|
|
159
187
|
{
|
|
160
188
|
ButtonType: linkType,
|
|
161
189
|
onClick,
|
|
162
|
-
disabled: isLoading,
|
|
190
|
+
disabled: isLoading || !!successMessage,
|
|
163
191
|
className: "w-full",
|
|
164
|
-
children:
|
|
192
|
+
children: successMessage ? /* @__PURE__ */ jsxs(
|
|
193
|
+
"span",
|
|
194
|
+
{
|
|
195
|
+
style: fontSize ? { fontSize } : void 0,
|
|
196
|
+
className: "inline-flex items-center gap-2",
|
|
197
|
+
children: [
|
|
198
|
+
/* @__PURE__ */ jsx(
|
|
199
|
+
"svg",
|
|
200
|
+
{
|
|
201
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
202
|
+
viewBox: "0 0 20 20",
|
|
203
|
+
fill: "currentColor",
|
|
204
|
+
className: "w-5 h-5",
|
|
205
|
+
children: /* @__PURE__ */ jsx(
|
|
206
|
+
"path",
|
|
207
|
+
{
|
|
208
|
+
fillRule: "evenodd",
|
|
209
|
+
d: "M16.704 5.29a1 1 0 010 1.42l-7.25 7.25a1 1 0 01-1.415 0L3.29 9.21a1 1 0 111.415-1.414l4.042 4.042 6.543-6.543a1 1 0 011.414 0z",
|
|
210
|
+
clipRule: "evenodd"
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
/* @__PURE__ */ jsx("span", { children: successMessage })
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
) : renderButtonContent()
|
|
165
219
|
}
|
|
166
220
|
) });
|
|
167
221
|
};
|
|
@@ -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
|
+
};
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
197
|
-
|
|
198
|
-
|
|
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
|
),
|
package/dist/index.js
CHANGED
|
@@ -1869,7 +1869,9 @@ var init_Button = __esm({
|
|
|
1869
1869
|
event.preventDefault();
|
|
1870
1870
|
event.stopPropagation();
|
|
1871
1871
|
if (props.confirm) {
|
|
1872
|
-
const confirmed = await showConfirmation(
|
|
1872
|
+
const confirmed = await showConfirmation(
|
|
1873
|
+
"Are you sure you want to delete this item?"
|
|
1874
|
+
);
|
|
1873
1875
|
setShowModal(null);
|
|
1874
1876
|
if (!confirmed) {
|
|
1875
1877
|
return;
|
|
@@ -1884,7 +1886,9 @@ var init_Button = __esm({
|
|
|
1884
1886
|
isValid = await props.onValidate();
|
|
1885
1887
|
if (!isValid) {
|
|
1886
1888
|
setInProgress(false);
|
|
1887
|
-
ToastService_default.showError(
|
|
1889
|
+
ToastService_default.showError(
|
|
1890
|
+
"There are errors in the form. Please fix them before proceeding."
|
|
1891
|
+
);
|
|
1888
1892
|
return;
|
|
1889
1893
|
}
|
|
1890
1894
|
}
|
|
@@ -1908,7 +1912,16 @@ var init_Button = __esm({
|
|
|
1908
1912
|
return new Promise((resolve) => {
|
|
1909
1913
|
const onConfirm = () => resolve(true);
|
|
1910
1914
|
const onCancel = () => resolve(false);
|
|
1911
|
-
setShowModal(
|
|
1915
|
+
setShowModal(
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1917
|
+
Confirm_default,
|
|
1918
|
+
{
|
|
1919
|
+
message: props.confirmationMessage,
|
|
1920
|
+
onConfirm,
|
|
1921
|
+
onCancel
|
|
1922
|
+
}
|
|
1923
|
+
)
|
|
1924
|
+
);
|
|
1912
1925
|
});
|
|
1913
1926
|
};
|
|
1914
1927
|
let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
|
|
@@ -1922,13 +1935,39 @@ var init_Button = __esm({
|
|
|
1922
1935
|
onClick: execute,
|
|
1923
1936
|
disabled: props.disabled,
|
|
1924
1937
|
title: isDisabled ? "The button is disabled to prevent any action" : "",
|
|
1925
|
-
className: buttonClass
|
|
1938
|
+
className: `${buttonClass} relative inline-flex items-center justify-center gap-2 ${props.className ?? ""}`,
|
|
1926
1939
|
children: [
|
|
1927
1940
|
isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
|
|
1928
|
-
inProgress && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1941
|
+
inProgress && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: props.hideProgressIndicator ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "absolute bottom-0 left-0 h-0.5 bg-gray-400 rounded animate-progress" }) : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
1942
|
+
"svg",
|
|
1943
|
+
{
|
|
1944
|
+
className: `animate-spin h-5 w-5 flex-shrink-0 ${progressClass}`,
|
|
1945
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1946
|
+
fill: "none",
|
|
1947
|
+
viewBox: "0 0 24 24",
|
|
1948
|
+
children: [
|
|
1949
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1950
|
+
"circle",
|
|
1951
|
+
{
|
|
1952
|
+
className: "opacity-25",
|
|
1953
|
+
cx: "12",
|
|
1954
|
+
cy: "12",
|
|
1955
|
+
r: "10",
|
|
1956
|
+
stroke: "currentColor",
|
|
1957
|
+
strokeWidth: "4"
|
|
1958
|
+
}
|
|
1959
|
+
),
|
|
1960
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
1961
|
+
"path",
|
|
1962
|
+
{
|
|
1963
|
+
className: "opacity-75",
|
|
1964
|
+
fill: "currentColor",
|
|
1965
|
+
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"
|
|
1966
|
+
}
|
|
1967
|
+
)
|
|
1968
|
+
]
|
|
1969
|
+
}
|
|
1970
|
+
) })
|
|
1932
1971
|
]
|
|
1933
1972
|
}
|
|
1934
1973
|
),
|
|
@@ -3090,6 +3129,8 @@ var init_LinkNodeButton = __esm({
|
|
|
3090
3129
|
LinkNodeButton = (props) => {
|
|
3091
3130
|
const { node, dataitem, children, linkText, linkType, linkUrl } = props;
|
|
3092
3131
|
const [isLoading, setIsLoading] = (0, import_react38.useState)(false);
|
|
3132
|
+
const [successMessage, setSuccessMessage] = (0, import_react38.useState)(null);
|
|
3133
|
+
console.log("LinkNodeButton props:", props);
|
|
3093
3134
|
const extractFieldNames = (0, import_react38.useCallback)((template) => {
|
|
3094
3135
|
if (!template) return [];
|
|
3095
3136
|
const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
|
|
@@ -3097,35 +3138,38 @@ var init_LinkNodeButton = __esm({
|
|
|
3097
3138
|
const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
|
|
3098
3139
|
return fieldNames;
|
|
3099
3140
|
}, []);
|
|
3100
|
-
const replaceTemplateVariables = (0, import_react38.useCallback)(
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3141
|
+
const replaceTemplateVariables = (0, import_react38.useCallback)(
|
|
3142
|
+
(template, responseData) => {
|
|
3143
|
+
if (!template) return template;
|
|
3144
|
+
let result = template;
|
|
3145
|
+
const fieldNames = extractFieldNames(template);
|
|
3146
|
+
if (responseData) {
|
|
3147
|
+
fieldNames.forEach((fieldName) => {
|
|
3148
|
+
const value = getNestedValue7(responseData, fieldName);
|
|
3149
|
+
if (value !== void 0) {
|
|
3150
|
+
const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
|
|
3151
|
+
const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
|
|
3152
|
+
result = result.replace(regex1, String(value));
|
|
3153
|
+
result = result.replace(regex2, String(value));
|
|
3154
|
+
}
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
if (props.routeParameters) {
|
|
3158
|
+
Object.entries(props.routeParameters).forEach(([key, value]) => {
|
|
3159
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
3160
|
+
result = result.replace(regex, String(value));
|
|
3161
|
+
});
|
|
3162
|
+
}
|
|
3163
|
+
if (dataitem) {
|
|
3164
|
+
Object.entries(dataitem).forEach(([key, value]) => {
|
|
3165
|
+
const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
|
|
3166
|
+
result = result.replace(regex, String(value));
|
|
3167
|
+
});
|
|
3168
|
+
}
|
|
3169
|
+
return result;
|
|
3170
|
+
},
|
|
3171
|
+
[props.routeParameters, dataitem, extractFieldNames]
|
|
3172
|
+
);
|
|
3129
3173
|
const getNestedValue7 = (0, import_react38.useCallback)((obj, path) => {
|
|
3130
3174
|
if (!obj || !path) return void 0;
|
|
3131
3175
|
if (obj[path] !== void 0) {
|
|
@@ -3143,7 +3187,10 @@ var init_LinkNodeButton = __esm({
|
|
|
3143
3187
|
}, []);
|
|
3144
3188
|
const onClick = (0, import_react38.useCallback)(async () => {
|
|
3145
3189
|
if (!node.postUrl) {
|
|
3146
|
-
return {
|
|
3190
|
+
return {
|
|
3191
|
+
isSuccessful: false,
|
|
3192
|
+
message: "No POST URL configured for this button"
|
|
3193
|
+
};
|
|
3147
3194
|
}
|
|
3148
3195
|
setIsLoading(true);
|
|
3149
3196
|
try {
|
|
@@ -3169,6 +3216,7 @@ var init_LinkNodeButton = __esm({
|
|
|
3169
3216
|
}
|
|
3170
3217
|
if (response?.message) {
|
|
3171
3218
|
ToastService_default.showSuccess(response.message);
|
|
3219
|
+
setSuccessMessage(response.message);
|
|
3172
3220
|
}
|
|
3173
3221
|
if (response && node.redirectUrl) {
|
|
3174
3222
|
const fieldNames = extractFieldNames(node.redirectUrl);
|
|
@@ -3191,7 +3239,9 @@ var init_LinkNodeButton = __esm({
|
|
|
3191
3239
|
}
|
|
3192
3240
|
});
|
|
3193
3241
|
console.log("Field value map:", fieldValueMap);
|
|
3194
|
-
const missingFields = fieldNames.filter(
|
|
3242
|
+
const missingFields = fieldNames.filter(
|
|
3243
|
+
(fieldName) => !fieldValueMap[fieldName]
|
|
3244
|
+
);
|
|
3195
3245
|
if (missingFields.length > 0) {
|
|
3196
3246
|
console.warn(`Missing field values for: ${missingFields.join(", ")}`);
|
|
3197
3247
|
}
|
|
@@ -3202,7 +3252,10 @@ var init_LinkNodeButton = __esm({
|
|
|
3202
3252
|
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
|
|
3203
3253
|
resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
|
|
3204
3254
|
});
|
|
3205
|
-
resolvedRedirectUrl = replaceTemplateVariables(
|
|
3255
|
+
resolvedRedirectUrl = replaceTemplateVariables(
|
|
3256
|
+
resolvedRedirectUrl,
|
|
3257
|
+
response
|
|
3258
|
+
);
|
|
3206
3259
|
console.log("Final redirect URL:", resolvedRedirectUrl);
|
|
3207
3260
|
if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
|
|
3208
3261
|
window.location.href = resolvedRedirectUrl;
|
|
@@ -3213,14 +3266,27 @@ var init_LinkNodeButton = __esm({
|
|
|
3213
3266
|
return { isSuccessful: false, message: errorMessage };
|
|
3214
3267
|
}
|
|
3215
3268
|
setIsLoading(false);
|
|
3216
|
-
return {
|
|
3269
|
+
return {
|
|
3270
|
+
isSuccessful: true,
|
|
3271
|
+
message: response?.message,
|
|
3272
|
+
result: response
|
|
3273
|
+
};
|
|
3217
3274
|
} catch (err) {
|
|
3218
3275
|
console.error("Button API call failed:", err);
|
|
3219
3276
|
const errorMessage = err.message || "An unexpected error occurred";
|
|
3220
3277
|
setIsLoading(false);
|
|
3221
3278
|
return { isSuccessful: false, message: errorMessage };
|
|
3222
3279
|
}
|
|
3223
|
-
}, [
|
|
3280
|
+
}, [
|
|
3281
|
+
node.postUrl,
|
|
3282
|
+
node.payload,
|
|
3283
|
+
node.redirectUrl,
|
|
3284
|
+
replaceTemplateVariables,
|
|
3285
|
+
extractFieldNames,
|
|
3286
|
+
getNestedValue7,
|
|
3287
|
+
props.apiBaseUrl,
|
|
3288
|
+
props.session
|
|
3289
|
+
]);
|
|
3224
3290
|
const renderButtonContent = () => {
|
|
3225
3291
|
if (children) {
|
|
3226
3292
|
return children;
|
|
@@ -3230,14 +3296,41 @@ var init_LinkNodeButton = __esm({
|
|
|
3230
3296
|
}
|
|
3231
3297
|
return node.title || "Button";
|
|
3232
3298
|
};
|
|
3299
|
+
const fontSize = node.children?.[0]?.style?.match(/font-size:\s*([^;]+)/)?.[1];
|
|
3233
3300
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "link-button-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3234
3301
|
Button_default,
|
|
3235
3302
|
{
|
|
3236
3303
|
ButtonType: linkType,
|
|
3237
3304
|
onClick,
|
|
3238
|
-
disabled: isLoading,
|
|
3305
|
+
disabled: isLoading || !!successMessage,
|
|
3239
3306
|
className: "w-full",
|
|
3240
|
-
children:
|
|
3307
|
+
children: successMessage ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
3308
|
+
"span",
|
|
3309
|
+
{
|
|
3310
|
+
style: fontSize ? { fontSize } : void 0,
|
|
3311
|
+
className: "inline-flex items-center gap-2",
|
|
3312
|
+
children: [
|
|
3313
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3314
|
+
"svg",
|
|
3315
|
+
{
|
|
3316
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3317
|
+
viewBox: "0 0 20 20",
|
|
3318
|
+
fill: "currentColor",
|
|
3319
|
+
className: "w-5 h-5",
|
|
3320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
3321
|
+
"path",
|
|
3322
|
+
{
|
|
3323
|
+
fillRule: "evenodd",
|
|
3324
|
+
d: "M16.704 5.29a1 1 0 010 1.42l-7.25 7.25a1 1 0 01-1.415 0L3.29 9.21a1 1 0 111.415-1.414l4.042 4.042 6.543-6.543a1 1 0 011.414 0z",
|
|
3325
|
+
clipRule: "evenodd"
|
|
3326
|
+
}
|
|
3327
|
+
)
|
|
3328
|
+
}
|
|
3329
|
+
),
|
|
3330
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: successMessage })
|
|
3331
|
+
]
|
|
3332
|
+
}
|
|
3333
|
+
) : renderButtonContent()
|
|
3241
3334
|
}
|
|
3242
3335
|
) });
|
|
3243
3336
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
OdataBuilder
|
|
5
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UFKPTMM7.mjs";
|
|
6
4
|
import {
|
|
7
5
|
AssetUtility_default,
|
|
8
6
|
BooleanSelect_default,
|
|
@@ -19,22 +17,22 @@ import {
|
|
|
19
17
|
PhoneInput_default,
|
|
20
18
|
SelectWithSearchInput_default,
|
|
21
19
|
TimeInput_default
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YG6FKKQJ.mjs";
|
|
23
21
|
import {
|
|
24
22
|
Constants,
|
|
25
23
|
Hyperlink,
|
|
26
24
|
Icon_default,
|
|
27
25
|
InputControlType_default
|
|
28
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-DBHUCH4B.mjs";
|
|
29
27
|
import {
|
|
30
28
|
ServiceClient_default
|
|
31
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-3GWLDT7C.mjs";
|
|
32
30
|
import {
|
|
33
31
|
Button_default,
|
|
34
32
|
ClientButton_default,
|
|
35
33
|
ToastService_default
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
34
|
+
} from "./chunk-RHVNJMS4.mjs";
|
|
35
|
+
import "./chunk-56HSDML5.mjs";
|
|
38
36
|
|
|
39
37
|
// src/components/controls/view/ViewControl.tsx
|
|
40
38
|
import React13 from "react";
|
|
@@ -78,7 +76,7 @@ var NumberView_default = NumberView;
|
|
|
78
76
|
|
|
79
77
|
// src/components/controls/view/DateView.tsx
|
|
80
78
|
import dynamic from "next/dynamic";
|
|
81
|
-
var DateView = dynamic(() => import("./DateViewClient-
|
|
79
|
+
var DateView = dynamic(() => import("./DateViewClient-ELEHLGWS.mjs"), {
|
|
82
80
|
ssr: false
|
|
83
81
|
});
|
|
84
82
|
var DateView_default = DateView;
|
|
@@ -133,7 +131,7 @@ import React3 from "react";
|
|
|
133
131
|
// src/components/DeviceAssetSelector.tsx
|
|
134
132
|
import dynamic2 from "next/dynamic";
|
|
135
133
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
136
|
-
var HlsPlayer = dynamic2(() => import("./HlsPlayer-
|
|
134
|
+
var HlsPlayer = dynamic2(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
|
|
137
135
|
var FORMAT_CLASSES = {
|
|
138
136
|
center: "justify-center",
|
|
139
137
|
left: "justify-start",
|
|
@@ -368,7 +366,7 @@ var AiGeneratedSummary_default = AiGeneratedSummary;
|
|
|
368
366
|
|
|
369
367
|
// src/components/controls/view/DateTimeVew.tsx
|
|
370
368
|
import dynamic3 from "next/dynamic";
|
|
371
|
-
var DateTimeView = dynamic3(() => import("./DateTimeViewClient-
|
|
369
|
+
var DateTimeView = dynamic3(() => import("./DateTimeViewClient-22GW4AD7.mjs"), {
|
|
372
370
|
ssr: false
|
|
373
371
|
});
|
|
374
372
|
var DateTimeVew_default = DateTimeView;
|
|
@@ -409,7 +407,7 @@ var ViewControl_default = ViewControl;
|
|
|
409
407
|
|
|
410
408
|
// src/components/controls/edit/InputControl.tsx
|
|
411
409
|
import dynamic4 from "next/dynamic";
|
|
412
|
-
var InputControl = dynamic4(() => import("./InputControlClient-
|
|
410
|
+
var InputControl = dynamic4(() => import("./InputControlClient-BUOYZNWQ.mjs"), {
|
|
413
411
|
ssr: false
|
|
414
412
|
});
|
|
415
413
|
var InputControl_default = InputControl;
|
|
@@ -505,7 +503,7 @@ import React14 from "react";
|
|
|
505
503
|
// src/components/pageRenderingEngine/nodes/ImageNode.tsx
|
|
506
504
|
import dynamic5 from "next/dynamic";
|
|
507
505
|
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
508
|
-
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-
|
|
506
|
+
var HlsPlayer2 = dynamic5(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
|
|
509
507
|
var getNestedValue = (obj, path) => {
|
|
510
508
|
if (!obj || !path) return void 0;
|
|
511
509
|
return path.split(".").reduce((current, key) => {
|
|
@@ -613,7 +611,7 @@ var ImageNode_default = ImageNode;
|
|
|
613
611
|
// src/components/pageRenderingEngine/nodes/LinkNode.tsx
|
|
614
612
|
import dynamic6 from "next/dynamic";
|
|
615
613
|
import { Fragment, jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
616
|
-
var LinkNodeButton = dynamic6(() => import("./LinkNodeButton-
|
|
614
|
+
var LinkNodeButton = dynamic6(() => import("./LinkNodeButton-BIZA2NPE.mjs"), {
|
|
617
615
|
ssr: false
|
|
618
616
|
});
|
|
619
617
|
function getNestedValue2(obj, path) {
|
|
@@ -1048,7 +1046,7 @@ var QuoteNode_default = QuoteNode;
|
|
|
1048
1046
|
import React20 from "react";
|
|
1049
1047
|
import dynamic7 from "next/dynamic";
|
|
1050
1048
|
import { jsx as jsx27, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1051
|
-
var CopyButton = dynamic7(() => import("./CopyButton-
|
|
1049
|
+
var CopyButton = dynamic7(() => import("./CopyButton-XONTQQW7.mjs"), {
|
|
1052
1050
|
ssr: false,
|
|
1053
1051
|
// optional: fallback UI while loading
|
|
1054
1052
|
loading: () => /* @__PURE__ */ jsx27("span", { className: "text-gray-400 text-xs", children: "Copy" })
|
|
@@ -1191,7 +1189,7 @@ import React22 from "react";
|
|
|
1191
1189
|
// src/components/pageRenderingEngine/nodes/EmbedNode.tsx
|
|
1192
1190
|
import dynamic8 from "next/dynamic";
|
|
1193
1191
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
1194
|
-
var IframeClient = dynamic8(() => import("./IframeClient-
|
|
1192
|
+
var IframeClient = dynamic8(() => import("./IframeClient-J22NMEVY.mjs"), {
|
|
1195
1193
|
ssr: false
|
|
1196
1194
|
});
|
|
1197
1195
|
var EmbedNode = (props) => {
|
|
@@ -1427,7 +1425,7 @@ var NoDataFound_default = NoDataFound;
|
|
|
1427
1425
|
// src/components/pageRenderingEngine/nodes/ImageGalleryNode.tsx
|
|
1428
1426
|
import dynamic9 from "next/dynamic";
|
|
1429
1427
|
import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1430
|
-
var HlsPlayer3 = dynamic9(() => import("./HlsPlayer-
|
|
1428
|
+
var HlsPlayer3 = dynamic9(() => import("./HlsPlayer-57543DTW.mjs"), { ssr: false });
|
|
1431
1429
|
var deviceToMediaQuery = (device) => {
|
|
1432
1430
|
switch (device) {
|
|
1433
1431
|
case "lg":
|
|
@@ -2242,8 +2240,8 @@ var DocumentNode_default = DocumentNode;
|
|
|
2242
2240
|
|
|
2243
2241
|
// src/components/pageRenderingEngine/nodes/DivContainer.tsx
|
|
2244
2242
|
import { jsx as jsx34, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2245
|
-
var Pagination = dynamic10(() => import("./Pagination-
|
|
2246
|
-
var Slider = dynamic10(() => import("./Slider-
|
|
2243
|
+
var Pagination = dynamic10(() => import("./Pagination-NCJCOYHF.mjs"), { ssr: true });
|
|
2244
|
+
var Slider = dynamic10(() => import("./Slider-PEIVH6A5.mjs"), {
|
|
2247
2245
|
ssr: false
|
|
2248
2246
|
});
|
|
2249
2247
|
function toCamelCase(str) {
|
package/package.json
CHANGED