@clyrex-digital/clyrex-controls-dev 0.8.1-dev.20260722105036 → 0.8.1-dev.20260723122345

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.
@@ -134,7 +134,7 @@ var Confirm_default = Confirm;
134
134
  }
135
135
 
136
136
  // src/components/Button.tsx
137
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
137
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
138
138
  var Button = (props) => {
139
139
  const [inProgress, setInProgress] = useState2(false);
140
140
  const [isActionPerformed, setIsActionPerformed] = useState2(false);
@@ -144,7 +144,9 @@ var Button = (props) => {
144
144
  event.preventDefault();
145
145
  event.stopPropagation();
146
146
  if (props.confirm) {
147
- const confirmed = await showConfirmation("Are you sure you want to delete this item?");
147
+ const confirmed = await showConfirmation(
148
+ "Are you sure you want to delete this item?"
149
+ );
148
150
  setShowModal(null);
149
151
  if (!confirmed) {
150
152
  return;
@@ -159,7 +161,9 @@ var Button = (props) => {
159
161
  isValid = await props.onValidate();
160
162
  if (!isValid) {
161
163
  setInProgress(false);
162
- ToastService_default.showError("There are errors in the form. Please fix them before proceeding.");
164
+ ToastService_default.showError(
165
+ "There are errors in the form. Please fix them before proceeding."
166
+ );
163
167
  return;
164
168
  }
165
169
  }
@@ -183,7 +187,16 @@ var Button = (props) => {
183
187
  return new Promise((resolve) => {
184
188
  const onConfirm = () => resolve(true);
185
189
  const onCancel = () => resolve(false);
186
- setShowModal(/* @__PURE__ */ jsx3(Confirm_default, { message: props.confirmationMessage, onConfirm, onCancel }));
190
+ setShowModal(
191
+ /* @__PURE__ */ jsx3(
192
+ Confirm_default,
193
+ {
194
+ message: props.confirmationMessage,
195
+ onConfirm,
196
+ onCancel
197
+ }
198
+ )
199
+ );
187
200
  });
188
201
  };
189
202
  let buttonClass = props.ButtonType ? buttonClasses.get(props.ButtonType) : buttonClasses.get("Primary" /* Solid */);
@@ -197,13 +210,39 @@ var Button = (props) => {
197
210
  onClick: execute,
198
211
  disabled: props.disabled,
199
212
  title: isDisabled ? "The button is disabled to prevent any action" : "",
200
- className: buttonClass + " relative " + props.className,
213
+ className: `${buttonClass} relative inline-flex items-center justify-center gap-2 ${props.className ?? ""}`,
201
214
  children: [
202
215
  isActionPerformed && props.oneTimeAction && responseMessage ? responseMessage : props.children,
203
- 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: [
204
- /* @__PURE__ */ jsx3("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
205
- /* @__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" })
206
- ] }) })
216
+ 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(
217
+ "svg",
218
+ {
219
+ className: `animate-spin h-5 w-5 flex-shrink-0 ${progressClass}`,
220
+ xmlns: "http://www.w3.org/2000/svg",
221
+ fill: "none",
222
+ viewBox: "0 0 24 24",
223
+ children: [
224
+ /* @__PURE__ */ jsx3(
225
+ "circle",
226
+ {
227
+ className: "opacity-25",
228
+ cx: "12",
229
+ cy: "12",
230
+ r: "10",
231
+ stroke: "currentColor",
232
+ strokeWidth: "4"
233
+ }
234
+ ),
235
+ /* @__PURE__ */ jsx3(
236
+ "path",
237
+ {
238
+ className: "opacity-75",
239
+ fill: "currentColor",
240
+ 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"
241
+ }
242
+ )
243
+ ]
244
+ }
245
+ ) })
207
246
  ]
208
247
  }
209
248
  ),
@@ -213,10 +252,12 @@ var Button = (props) => {
213
252
  var Button_default = Button;
214
253
 
215
254
  // src/components/pageRenderingEngine/nodes/LinkNodeButton.tsx
216
- import { jsx as jsx4 } from "react/jsx-runtime";
255
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
217
256
  var LinkNodeButton = (props) => {
218
257
  const { node, dataitem, children, linkText, linkType, linkUrl } = props;
219
258
  const [isLoading, setIsLoading] = useState3(false);
259
+ const [successMessage, setSuccessMessage] = useState3(null);
260
+ console.log("LinkNodeButton props:", props);
220
261
  const extractFieldNames = useCallback((template) => {
221
262
  if (!template) return [];
222
263
  const regex = /\{(\{\})?([a-zA-Z_$][a-zA-Z0-9_$]*)(?:\}\})?\}/g;
@@ -224,35 +265,38 @@ var LinkNodeButton = (props) => {
224
265
  const fieldNames = matches.map((match) => match[2] || match[1]).filter((name, index, self) => self.indexOf(name) === index);
225
266
  return fieldNames;
226
267
  }, []);
227
- const replaceTemplateVariables = useCallback((template, responseData) => {
228
- if (!template) return template;
229
- let result = template;
230
- const fieldNames = extractFieldNames(template);
231
- if (responseData) {
232
- fieldNames.forEach((fieldName) => {
233
- const value = getNestedValue(responseData, fieldName);
234
- if (value !== void 0) {
235
- const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
236
- const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
237
- result = result.replace(regex1, String(value));
238
- result = result.replace(regex2, String(value));
239
- }
240
- });
241
- }
242
- if (props.routeParameters) {
243
- Object.entries(props.routeParameters).forEach(([key, value]) => {
244
- const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
245
- result = result.replace(regex, String(value));
246
- });
247
- }
248
- if (dataitem) {
249
- Object.entries(dataitem).forEach(([key, value]) => {
250
- const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
251
- result = result.replace(regex, String(value));
252
- });
253
- }
254
- return result;
255
- }, [props.routeParameters, dataitem, extractFieldNames]);
268
+ const replaceTemplateVariables = useCallback(
269
+ (template, responseData) => {
270
+ if (!template) return template;
271
+ let result = template;
272
+ const fieldNames = extractFieldNames(template);
273
+ if (responseData) {
274
+ fieldNames.forEach((fieldName) => {
275
+ const value = getNestedValue(responseData, fieldName);
276
+ if (value !== void 0) {
277
+ const regex1 = new RegExp(`\\{${fieldName}\\}`, "g");
278
+ const regex2 = new RegExp(`\\{\\{${fieldName}\\}\\}`, "g");
279
+ result = result.replace(regex1, String(value));
280
+ result = result.replace(regex2, String(value));
281
+ }
282
+ });
283
+ }
284
+ if (props.routeParameters) {
285
+ Object.entries(props.routeParameters).forEach(([key, value]) => {
286
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
287
+ result = result.replace(regex, String(value));
288
+ });
289
+ }
290
+ if (dataitem) {
291
+ Object.entries(dataitem).forEach(([key, value]) => {
292
+ const regex = new RegExp(`\\{\\{${key}\\}\\}`, "g");
293
+ result = result.replace(regex, String(value));
294
+ });
295
+ }
296
+ return result;
297
+ },
298
+ [props.routeParameters, dataitem, extractFieldNames]
299
+ );
256
300
  const getNestedValue = useCallback((obj, path) => {
257
301
  if (!obj || !path) return void 0;
258
302
  if (obj[path] !== void 0) {
@@ -270,7 +314,10 @@ var LinkNodeButton = (props) => {
270
314
  }, []);
271
315
  const onClick = useCallback(async () => {
272
316
  if (!node.postUrl) {
273
- return { isSuccessful: false, message: "No POST URL configured for this button" };
317
+ return {
318
+ isSuccessful: false,
319
+ message: "No POST URL configured for this button"
320
+ };
274
321
  }
275
322
  setIsLoading(true);
276
323
  try {
@@ -296,6 +343,7 @@ var LinkNodeButton = (props) => {
296
343
  }
297
344
  if (response?.message) {
298
345
  ToastService_default.showSuccess(response.message);
346
+ setSuccessMessage(response.message);
299
347
  }
300
348
  if (response && node.redirectUrl) {
301
349
  const fieldNames = extractFieldNames(node.redirectUrl);
@@ -318,7 +366,9 @@ var LinkNodeButton = (props) => {
318
366
  }
319
367
  });
320
368
  console.log("Field value map:", fieldValueMap);
321
- const missingFields = fieldNames.filter((fieldName) => !fieldValueMap[fieldName]);
369
+ const missingFields = fieldNames.filter(
370
+ (fieldName) => !fieldValueMap[fieldName]
371
+ );
322
372
  if (missingFields.length > 0) {
323
373
  console.warn(`Missing field values for: ${missingFields.join(", ")}`);
324
374
  }
@@ -329,7 +379,10 @@ var LinkNodeButton = (props) => {
329
379
  resolvedRedirectUrl = resolvedRedirectUrl.replace(regex1, value);
330
380
  resolvedRedirectUrl = resolvedRedirectUrl.replace(regex2, value);
331
381
  });
332
- resolvedRedirectUrl = replaceTemplateVariables(resolvedRedirectUrl, response);
382
+ resolvedRedirectUrl = replaceTemplateVariables(
383
+ resolvedRedirectUrl,
384
+ response
385
+ );
333
386
  console.log("Final redirect URL:", resolvedRedirectUrl);
334
387
  if (resolvedRedirectUrl && !resolvedRedirectUrl.includes("{")) {
335
388
  window.location.href = resolvedRedirectUrl;
@@ -340,14 +393,27 @@ var LinkNodeButton = (props) => {
340
393
  return { isSuccessful: false, message: errorMessage };
341
394
  }
342
395
  setIsLoading(false);
343
- return { isSuccessful: true, message: response?.message, result: response };
396
+ return {
397
+ isSuccessful: true,
398
+ message: response?.message,
399
+ result: response
400
+ };
344
401
  } catch (err) {
345
402
  console.error("Button API call failed:", err);
346
403
  const errorMessage = err.message || "An unexpected error occurred";
347
404
  setIsLoading(false);
348
405
  return { isSuccessful: false, message: errorMessage };
349
406
  }
350
- }, [node.postUrl, node.payload, node.redirectUrl, replaceTemplateVariables, extractFieldNames, getNestedValue, props.apiBaseUrl, props.session]);
407
+ }, [
408
+ node.postUrl,
409
+ node.payload,
410
+ node.redirectUrl,
411
+ replaceTemplateVariables,
412
+ extractFieldNames,
413
+ getNestedValue,
414
+ props.apiBaseUrl,
415
+ props.session
416
+ ]);
351
417
  const renderButtonContent = () => {
352
418
  if (children) {
353
419
  return children;
@@ -357,14 +423,41 @@ var LinkNodeButton = (props) => {
357
423
  }
358
424
  return node.title || "Button";
359
425
  };
426
+ const fontSize = node.children?.[0]?.style?.match(/font-size:\s*([^;]+)/)?.[1];
360
427
  return /* @__PURE__ */ jsx4("div", { className: "link-button-wrapper", children: /* @__PURE__ */ jsx4(
361
428
  Button_default,
362
429
  {
363
430
  ButtonType: linkType,
364
431
  onClick,
365
- disabled: isLoading,
432
+ disabled: isLoading || !!successMessage,
366
433
  className: "w-full",
367
- children: renderButtonContent()
434
+ children: successMessage ? /* @__PURE__ */ jsxs3(
435
+ "span",
436
+ {
437
+ style: fontSize ? { fontSize } : void 0,
438
+ className: "inline-flex items-center gap-2",
439
+ children: [
440
+ /* @__PURE__ */ jsx4(
441
+ "svg",
442
+ {
443
+ xmlns: "http://www.w3.org/2000/svg",
444
+ viewBox: "0 0 20 20",
445
+ fill: "currentColor",
446
+ className: "w-5 h-5",
447
+ children: /* @__PURE__ */ jsx4(
448
+ "path",
449
+ {
450
+ fillRule: "evenodd",
451
+ 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",
452
+ clipRule: "evenodd"
453
+ }
454
+ )
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx4("span", { children: successMessage })
458
+ ]
459
+ }
460
+ ) : renderButtonContent()
368
461
  }
369
462
  ) });
370
463
  };