@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260306085544 → 0.8.1-dev.20260318114337

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/index.mjs CHANGED
@@ -2006,6 +2006,7 @@ var Icon_default = Icon;
2006
2006
 
2007
2007
  // src/FormReducer.tsx
2008
2008
  var FORM_INPUT_UPDATE = "FORM_INPUT_UPDATE";
2009
+ var FORM_INITIAL_UPDATE = "FORM_INITIAL_UPDATE";
2009
2010
  function setNestedProperty(obj, path, value) {
2010
2011
  if (path.includes(".")) {
2011
2012
  const keys = path.split(".");
@@ -2036,6 +2037,11 @@ function FormReducer(state, action) {
2036
2037
  ),
2037
2038
  lastPropertyChanged: action.name.toString()
2038
2039
  };
2040
+ case FORM_INITIAL_UPDATE:
2041
+ return {
2042
+ inputValues: { ...action.values },
2043
+ lastPropertyChanged: action.name?.toString() || ""
2044
+ };
2039
2045
  default:
2040
2046
  return state;
2041
2047
  }
@@ -2494,10 +2500,812 @@ var DataList = (props) => {
2494
2500
  ] });
2495
2501
  };
2496
2502
  var DataList_default = DataList;
2503
+
2504
+ // src/components/pageRenderingEngine/PageBodyRenderer.tsx
2505
+ import React49 from "react";
2506
+
2507
+ // src/components/pageRenderingEngine/nodes/ParagraphNode.tsx
2508
+ import React37 from "react";
2509
+
2510
+ // src/components/pageRenderingEngine/nodes/TextNode.tsx
2511
+ import { jsx as jsx41 } from "react/jsx-runtime";
2512
+ var TextNode = (props) => {
2513
+ const NodeTypes2 = {
2514
+ ["text"]: TextNode
2515
+ };
2516
+ function cssStringToJson(cssString) {
2517
+ const styleObject = {};
2518
+ const matches = cssString.match(/([\w-]+)\s*:\s*([^;]+)\s*;/);
2519
+ if (matches && matches.length === 3) {
2520
+ const property = matches[1].trim();
2521
+ const value = matches[2].trim();
2522
+ {
2523
+ }
2524
+ styleObject[property] = value;
2525
+ }
2526
+ return styleObject;
2527
+ }
2528
+ const Formats = ["", "font-semibold"];
2529
+ const styles = cssStringToJson(props.node.style);
2530
+ return /* @__PURE__ */ jsx41("span", { style: { ...styles }, className: props.node.format < Formats.length ? Formats[props.node.format] : "", children: props.node.text });
2531
+ };
2532
+ var TextNode_default = TextNode;
2533
+
2534
+ // src/components/pageRenderingEngine/nodes/LineBreakNode.tsx
2535
+ import { jsx as jsx42 } from "react/jsx-runtime";
2536
+ var LineBreakNode = (props) => {
2537
+ return /* @__PURE__ */ jsx42("div", { className: "py-0.5 lg:py-1.5" });
2538
+ };
2539
+ var LineBreakNode_default = LineBreakNode;
2540
+
2541
+ // src/components/pageRenderingEngine/nodes/LinkNode.tsx
2542
+ import React36 from "react";
2543
+ import Link2 from "next/link";
2544
+ import { jsx as jsx43, jsxs as jsxs23 } from "react/jsx-runtime";
2545
+ var LinkNode = (props) => {
2546
+ const NodeTypes2 = {
2547
+ ["text"]: TextNode_default
2548
+ };
2549
+ {
2550
+ }
2551
+ let formatClasses = props.node.cssClass || "";
2552
+ return /* @__PURE__ */ jsxs23(Link2, { className: formatClasses, href: props.node.url, title: props.node.title, children: [
2553
+ props.node.children && props.node.children.map((node, index) => {
2554
+ const SelectedNode = NodeTypes2[node.type];
2555
+ return /* @__PURE__ */ jsx43(React36.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx43(SelectedNode, { node }) }, index);
2556
+ }),
2557
+ props.node.children.length == 0 && /* @__PURE__ */ jsx43("br", {})
2558
+ ] });
2559
+ };
2560
+ var LinkNode_default = LinkNode;
2561
+
2562
+ // src/components/pageRenderingEngine/nodes/ParagraphNode.tsx
2563
+ import { jsx as jsx44, jsxs as jsxs24 } from "react/jsx-runtime";
2564
+ var ParagraphNode = (props) => {
2565
+ const NodeTypes2 = {
2566
+ ["text"]: TextNode_default,
2567
+ ["linebreak"]: LineBreakNode_default,
2568
+ ["link"]: LinkNode_default
2569
+ };
2570
+ const getNode = () => {
2571
+ };
2572
+ const FormatClass = {
2573
+ "center": "text-center"
2574
+ };
2575
+ {
2576
+ }
2577
+ let formatClasses = FormatClass[props.node.format] || "";
2578
+ return /* @__PURE__ */ jsxs24("div", { className: "my-1 " + formatClasses, children: [
2579
+ props.node.children && props.node.children.map((node, index) => {
2580
+ const SelectedNode = NodeTypes2[node.type];
2581
+ return /* @__PURE__ */ jsx44(React37.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx44(SelectedNode, { node }) }, index);
2582
+ }),
2583
+ props.node.children.length == 0 && /* @__PURE__ */ jsx44("div", { className: "py-0.5 lg:py-1.5" })
2584
+ ] });
2585
+ };
2586
+ var ParagraphNode_default = ParagraphNode;
2587
+
2588
+ // src/components/pageRenderingEngine/nodes/HeadingNode.tsx
2589
+ import React38 from "react";
2590
+ import { Fragment as Fragment3, jsx as jsx45 } from "react/jsx-runtime";
2591
+ var HeadingNode = (props) => {
2592
+ const NodeTypes2 = {
2593
+ ["text"]: TextNode_default,
2594
+ ["link"]: LinkNode_default
2595
+ };
2596
+ const HeadingTag = `${props.node.tag}`;
2597
+ const FormatClass = {
2598
+ "center": "text-center"
2599
+ };
2600
+ {
2601
+ }
2602
+ let formatClasses = FormatClass[props.node.format] || "";
2603
+ return /* @__PURE__ */ jsx45(Fragment3, { children: React38.createElement(
2604
+ HeadingTag,
2605
+ { className: formatClasses },
2606
+ props.node.children && props.node.children.map((childNode, index) => {
2607
+ const SelectedNode = NodeTypes2[childNode.type];
2608
+ return /* @__PURE__ */ jsx45(React38.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx45(SelectedNode, { node: childNode }) }, index);
2609
+ })
2610
+ ) });
2611
+ };
2612
+ var HeadingNode_default = HeadingNode;
2613
+
2614
+ // src/components/pageRenderingEngine/nodes/ListNode.tsx
2615
+ import React40 from "react";
2616
+
2617
+ // src/components/pageRenderingEngine/nodes/ListItemNode.tsx
2618
+ import React39 from "react";
2619
+ import { jsx as jsx46 } from "react/jsx-runtime";
2620
+ var ListItemNode = (props) => {
2621
+ const NodeTypes2 = {
2622
+ ["text"]: TextNode_default,
2623
+ ["linebreak"]: LineBreakNode_default,
2624
+ ["link"]: LinkNode_default
2625
+ };
2626
+ return /* @__PURE__ */ jsx46("li", { children: props.node.children && props.node.children.map((node, index) => {
2627
+ const SelectedNode = NodeTypes2[node.type];
2628
+ return /* @__PURE__ */ jsx46(React39.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx46(SelectedNode, { node }) }, index);
2629
+ }) });
2630
+ };
2631
+ var ListItemNode_default = ListItemNode;
2632
+
2633
+ // src/components/pageRenderingEngine/nodes/ListNode.tsx
2634
+ import { jsx as jsx47, jsxs as jsxs25 } from "react/jsx-runtime";
2635
+ var ListNode = (props) => {
2636
+ const NodeTypes2 = {
2637
+ listitem: ListItemNode_default
2638
+ };
2639
+ return /* @__PURE__ */ jsxs25(React40.Fragment, { children: [
2640
+ props.node.listType == "bullet" && /* @__PURE__ */ jsx47("ul", { children: props.node.children && props.node.children.map((node, index) => {
2641
+ const SelectedNode = NodeTypes2[node.type];
2642
+ return /* @__PURE__ */ jsx47(React40.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx47(SelectedNode, { node }) }, index);
2643
+ }) }),
2644
+ props.node.listType == "number" && /* @__PURE__ */ jsx47("ol", { children: props.node.children && props.node.children.map((node, index) => {
2645
+ const SelectedNode = NodeTypes2[node.type];
2646
+ return /* @__PURE__ */ jsx47(React40.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx47(SelectedNode, { node }) }, index);
2647
+ }) })
2648
+ ] });
2649
+ };
2650
+ var ListNode_default = ListNode;
2651
+
2652
+ // src/components/pageRenderingEngine/nodes/QuoteNode.tsx
2653
+ import React41 from "react";
2654
+ import { jsx as jsx48 } from "react/jsx-runtime";
2655
+ var QuoteNode = (props) => {
2656
+ const NodeTypes2 = {
2657
+ ["text"]: TextNode_default,
2658
+ ["linebreak"]: LineBreakNode_default,
2659
+ ["link"]: LinkNode_default
2660
+ };
2661
+ return /* @__PURE__ */ jsx48("blockquote", { children: props.node.children && props.node.children.map((node, index) => {
2662
+ const SelectedNode = NodeTypes2[node.type];
2663
+ return /* @__PURE__ */ jsx48(React41.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx48(SelectedNode, { node }) }, index);
2664
+ }) });
2665
+ };
2666
+ var QuoteNode_default = QuoteNode;
2667
+
2668
+ // src/components/pageRenderingEngine/nodes/CodeNode.tsx
2669
+ import React42 from "react";
2670
+ import { jsx as jsx49 } from "react/jsx-runtime";
2671
+ var CodeNode = (props) => {
2672
+ const NodeTypes2 = {
2673
+ ["text"]: TextNode_default,
2674
+ ["linebreak"]: LineBreakNode_default,
2675
+ ["link"]: LinkNode_default
2676
+ };
2677
+ return /* @__PURE__ */ jsx49("code", { children: props.node.children && props.node.children.map((node, index) => {
2678
+ const SelectedNode = NodeTypes2[node.type];
2679
+ return /* @__PURE__ */ jsx49(React42.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx49(SelectedNode, { node }) }, index);
2680
+ }) });
2681
+ };
2682
+ var CodeNode_default = CodeNode;
2683
+
2684
+ // src/components/pageRenderingEngine/nodes/HorizontalRuleNode.tsx
2685
+ import { jsx as jsx50 } from "react/jsx-runtime";
2686
+ var HorizontalRuleNode = (props) => {
2687
+ return /* @__PURE__ */ jsx50("hr", {});
2688
+ };
2689
+ var HorizontalRuleNode_default = HorizontalRuleNode;
2690
+
2691
+ // src/components/pageRenderingEngine/nodes/LayoutContainerNode.tsx
2692
+ import React45 from "react";
2693
+
2694
+ // src/components/pageRenderingEngine/nodes/LayoutItemNode.tsx
2695
+ import React44 from "react";
2696
+
2697
+ // src/components/pageRenderingEngine/nodes/ImageNode.tsx
2698
+ import React43 from "react";
2699
+ import { jsx as jsx51 } from "react/jsx-runtime";
2700
+ var ImageNode = (props) => {
2701
+ const { node, apiBaseUrl = "" } = props;
2702
+ let imageUrl = node.imageUrl.startsWith("http") ? node.imageUrl : `${apiBaseUrl}/digitalassets/storefront/${node.imageUrl}`;
2703
+ return /* @__PURE__ */ jsx51(React43.Fragment, { children: node.width ? /* @__PURE__ */ jsx51("div", { style: { width: node.width }, children: /* @__PURE__ */ jsx51(
2704
+ "img",
2705
+ {
2706
+ loading: "lazy",
2707
+ className: "object-cover",
2708
+ src: imageUrl,
2709
+ width: node.intrinsicWidth,
2710
+ height: node.intrinsicHeight,
2711
+ alt: node.title
2712
+ }
2713
+ ) }) : /* @__PURE__ */ jsx51(
2714
+ "img",
2715
+ {
2716
+ loading: "lazy",
2717
+ className: "object-cover",
2718
+ src: imageUrl,
2719
+ width: node.intrinsicWidth,
2720
+ height: node.intrinsicHeight,
2721
+ alt: node.title
2722
+ }
2723
+ ) });
2724
+ };
2725
+ var ImageNode_default = ImageNode;
2726
+
2727
+ // src/components/pageRenderingEngine/nodes/LayoutItemNode.tsx
2728
+ import { jsx as jsx52 } from "react/jsx-runtime";
2729
+ var LayoutItemNode = (props) => {
2730
+ const NodeTypes2 = {
2731
+ ["paragraph"]: ParagraphNode_default,
2732
+ ["heading"]: HeadingNode_default,
2733
+ ["list"]: ListNode_default,
2734
+ ["quote"]: QuoteNode_default,
2735
+ ["code"]: CodeNode_default,
2736
+ ["horizontalrule"]: HorizontalRuleNode_default,
2737
+ ["image"]: ImageNode_default,
2738
+ ["layout-container"]: LayoutContainerNode_default,
2739
+ ["link"]: LinkNode_default
2740
+ };
2741
+ let cssClasses = "";
2742
+ if (props.order) {
2743
+ cssClasses = "order-" + props.order + " lg:order-1";
2744
+ }
2745
+ if (props.node.itemBoxShadow) {
2746
+ {
2747
+ }
2748
+ cssClasses = cssClasses + " " + (props.node.itemBoxShadow || "");
2749
+ }
2750
+ const styles = {};
2751
+ if (props.node.itemBorderWidth) {
2752
+ styles.borderWidth = props.node.itemBorderWidth;
2753
+ cssClasses = cssClasses + " px-4 py-2";
2754
+ }
2755
+ if (props.node.itemBorderRadius) {
2756
+ styles.borderRadius = props.node.itemBorderRadius;
2757
+ }
2758
+ function removeParagraphsAtStartAndEnd(layoutItem) {
2759
+ let startIndex = 0;
2760
+ {
2761
+ }
2762
+ while (startIndex < layoutItem.children.length && layoutItem.children[startIndex].type === "paragraph" && layoutItem.children[startIndex].children.filter((x) => x.type == "linebreak").length == layoutItem.children[startIndex].children.length) {
2763
+ startIndex++;
2764
+ }
2765
+ let endIndex = layoutItem.children.length - 1;
2766
+ {
2767
+ }
2768
+ while (endIndex >= 0 && layoutItem.children[endIndex].type === "paragraph" && layoutItem.children[endIndex].children.filter((x) => x.type == "linebreak").length == layoutItem.children[endIndex].children.length) {
2769
+ endIndex--;
2770
+ }
2771
+ if (startIndex <= endIndex) {
2772
+ layoutItem.children = layoutItem.children.slice(startIndex, endIndex + 1);
2773
+ }
2774
+ return layoutItem;
2775
+ }
2776
+ let updatedLayout = props.node;
2777
+ if (props.node.itemBoxShadow || props.node.itemBorderWidth) {
2778
+ updatedLayout = props.node;
2779
+ } else {
2780
+ updatedLayout = removeParagraphsAtStartAndEnd(props.node);
2781
+ }
2782
+ return /* @__PURE__ */ jsx52("div", { className: "" + cssClasses, style: { ...styles }, children: updatedLayout.children.map((node, index) => {
2783
+ {
2784
+ }
2785
+ const SelectedNode = NodeTypes2[node.type];
2786
+ return /* @__PURE__ */ jsx52(React44.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx52(SelectedNode, { node }) }, index);
2787
+ }) });
2788
+ };
2789
+ var LayoutItemNode_default = LayoutItemNode;
2790
+
2791
+ // src/components/pageRenderingEngine/nodes/LayoutContainerNode.tsx
2792
+ import { jsx as jsx53, jsxs as jsxs26 } from "react/jsx-runtime";
2793
+ var VERTICAL_ALIGNMENT_CLASSES = {
2794
+ "start": "items-start",
2795
+ "center": "items-center",
2796
+ "end": "items-end",
2797
+ "stretch": "items-stretch",
2798
+ "baseline": "items-baseline"
2799
+ };
2800
+ var LAYOUTGRID_COLS_CLASSES = {
2801
+ "1fr": "layout-grid-col-1",
2802
+ "1fr 1fr": "layout-grid-col-2-equal",
2803
+ "1fr 2fr": "layout-grid-col-2-widths-33-67",
2804
+ "2fr 1fr": "layout-grid-col-2-widths-67-33",
2805
+ "3fr 2fr": "layout-grid-col-2-widths-60-40",
2806
+ "3fr 1fr": "layout-grid-col-2-widths-75-25",
2807
+ "1fr 1fr 1fr": "layout-grid-col-3-equal",
2808
+ "1fr 2fr 1fr": "layout-grid-col-3-widths-25-50-25",
2809
+ "1fr 6fr 1fr": "layout-grid-col-3-widths-15-70-15",
2810
+ "1fr 1fr 1fr 1fr": "layout-grid-col-4-equal"
2811
+ };
2812
+ var LayoutContainerNode = (props) => {
2813
+ const { node, apiBaseUrl = "" } = props;
2814
+ let gridCssClasses = LAYOUTGRID_COLS_CLASSES[node.templateColumns];
2815
+ if (node.contentVerticalAlignment) {
2816
+ {
2817
+ }
2818
+ gridCssClasses = gridCssClasses + " " + (VERTICAL_ALIGNMENT_CLASSES[node.contentVerticalAlignment] || "");
2819
+ }
2820
+ let columnGap = "0.5rem";
2821
+ if (node.columnGap && node.columnGap != "") {
2822
+ columnGap = node.columnGap;
2823
+ }
2824
+ const styles = {};
2825
+ if (node.backgroundColor) {
2826
+ styles.backgroundColor = node.backgroundColor;
2827
+ }
2828
+ let cssClasses = "layout_grid ";
2829
+ let addPadding = false;
2830
+ if (node.boxShadow) {
2831
+ {
2832
+ }
2833
+ cssClasses = cssClasses + " " + (node.boxShadow || "");
2834
+ addPadding = true;
2835
+ }
2836
+ if (node.borderWidth) {
2837
+ styles.borderWidth = node.borderWidth;
2838
+ addPadding = true;
2839
+ }
2840
+ if (node.borderRadius) {
2841
+ styles.borderRadius = node.borderRadius;
2842
+ }
2843
+ let backgroundStyle = "";
2844
+ if (node.backgroundImage) {
2845
+ let resolvedPath = node.backgroundImage;
2846
+ if (!resolvedPath.startsWith("http")) {
2847
+ resolvedPath = `${apiBaseUrl}/digitalassets/storefront/${resolvedPath}`;
2848
+ }
2849
+ backgroundStyle = `url('${resolvedPath}'),`;
2850
+ }
2851
+ if (node.gradientColor1 && node.gradientColor2) {
2852
+ backgroundStyle += `linear-gradient(to bottom, ${node.gradientColor1}, ${node.gradientColor2}),`;
2853
+ }
2854
+ if (node.backgroundColor) {
2855
+ backgroundStyle += `${node.backgroundColor},`;
2856
+ }
2857
+ if (backgroundStyle && backgroundStyle != "") {
2858
+ let stringWithoutTrailingComma = backgroundStyle.replace(/,(\s*)$/, "$1");
2859
+ styles.background = stringWithoutTrailingComma;
2860
+ addPadding = true;
2861
+ }
2862
+ let sectionWidth = "fixed";
2863
+ if (node.sectionWidth) {
2864
+ sectionWidth = node.sectionWidth;
2865
+ }
2866
+ return /* @__PURE__ */ jsxs26(React45.Fragment, { children: [
2867
+ sectionWidth == "mixed" && /* @__PURE__ */ jsx53("div", { className: cssClasses, style: { ...styles }, children: /* @__PURE__ */ jsx53("div", { className: "container", children: /* @__PURE__ */ jsx53("div", { className: "grid gap-y-8 " + gridCssClasses + (addPadding ? " px-4 py-4 lg:px-6 lg:py-6 " : ""), style: { columnGap, minHeight: node.height }, children: node.children && node.children.map((node2, index) => {
2868
+ return /* @__PURE__ */ jsx53(React45.Fragment, { children: /* @__PURE__ */ jsx53(LayoutItemNode_default, { node: node2, order: props.node.smOrder == "reverse" ? node2.children.length - index : index }) }, index);
2869
+ }) }) }) }),
2870
+ sectionWidth == "full" && /* @__PURE__ */ jsx53(
2871
+ "div",
2872
+ {
2873
+ className: "grid gap-y-8 " + cssClasses + " " + gridCssClasses + (addPadding ? " p-4 lg:p-0" : ""),
2874
+ style: { columnGap, ...styles },
2875
+ children: node.children && node.children.map((node2, index) => {
2876
+ return /* @__PURE__ */ jsx53(React45.Fragment, { children: /* @__PURE__ */ jsx53(LayoutItemNode_default, { node: node2, order: props.node.smOrder == "reverse" ? node2.children.length - index : index }) }, index);
2877
+ })
2878
+ }
2879
+ ),
2880
+ sectionWidth == "fixed" && /* @__PURE__ */ jsx53("div", { className: "container", children: /* @__PURE__ */ jsx53(
2881
+ "div",
2882
+ {
2883
+ className: "grid gap-y-8 " + cssClasses + " " + gridCssClasses + (addPadding ? " px-4 py-4 lg:px-6 lg:py-6 " : ""),
2884
+ style: { columnGap, ...styles },
2885
+ children: node.children && node.children.map((node2, index) => {
2886
+ return /* @__PURE__ */ jsx53(React45.Fragment, { children: /* @__PURE__ */ jsx53(LayoutItemNode_default, { node: node2, order: props.node.smOrder == "reverse" ? node2.children.length - index : index }) }, index);
2887
+ })
2888
+ }
2889
+ ) })
2890
+ ] });
2891
+ };
2892
+ var LayoutContainerNode_default = LayoutContainerNode;
2893
+
2894
+ // src/components/pageRenderingEngine/nodes/WidgetNode.tsx
2895
+ import { Suspense } from "react";
2896
+ import { Fragment as Fragment4, jsx as jsx54, jsxs as jsxs27 } from "react/jsx-runtime";
2897
+ var WidgetNode = (props) => {
2898
+ const getWidgetParameters = () => {
2899
+ const widgetInputParameters = { ...props.routeParameters ?? {} };
2900
+ const rawWidgetParams = props.node?.widgetParameters ?? props.node?.widgetParams;
2901
+ let widgetParameters = {};
2902
+ const isJSON = (str) => {
2903
+ if (typeof str !== "string") return false;
2904
+ str = str.trim();
2905
+ return str.startsWith("{") && str.endsWith("}") || str.startsWith("[") && str.endsWith("]");
2906
+ };
2907
+ if (rawWidgetParams) {
2908
+ if (typeof rawWidgetParams === "string" && isJSON(rawWidgetParams)) {
2909
+ widgetParameters = JSON.parse(rawWidgetParams);
2910
+ } else if (typeof rawWidgetParams === "object") {
2911
+ widgetParameters = rawWidgetParams;
2912
+ }
2913
+ }
2914
+ const resolveValue = (val) => {
2915
+ if (typeof val === "string") {
2916
+ const m = /^\{(.+)\}$/.exec(val);
2917
+ if (m) {
2918
+ const actualKey = m[1];
2919
+ return props.routeParameters?.[actualKey] ?? val;
2920
+ }
2921
+ return val;
2922
+ } else if (Array.isArray(val)) {
2923
+ return val.map(resolveValue);
2924
+ } else if (val && typeof val === "object") {
2925
+ const out = {};
2926
+ for (const k of Object.keys(val)) {
2927
+ out[k] = resolveValue(val[k]);
2928
+ }
2929
+ return out;
2930
+ }
2931
+ return val;
2932
+ };
2933
+ Object.keys(widgetParameters).forEach((key) => {
2934
+ const rawVal = widgetParameters[key];
2935
+ if (rawVal === "route") {
2936
+ if (key === "itemPath") {
2937
+ widgetInputParameters[key] = props.path;
2938
+ } else {
2939
+ widgetInputParameters[key] = widgetInputParameters[key] ?? null;
2940
+ }
2941
+ } else {
2942
+ widgetInputParameters[key] = resolveValue(rawVal);
2943
+ }
2944
+ });
2945
+ widgetInputParameters["widgetTitle"] = props.node?.widgetTitle;
2946
+ return widgetInputParameters;
2947
+ };
2948
+ const SelectedWidget = props.widgetResolver?.(props.node.widgetCode);
2949
+ if (!SelectedWidget) {
2950
+ return /* @__PURE__ */ jsxs27(Fragment4, { children: [
2951
+ "Widget not found: ",
2952
+ props.node.widgetCode
2953
+ ] });
2954
+ }
2955
+ return /* @__PURE__ */ jsx54(Suspense, { fallback: /* @__PURE__ */ jsx54("div", { className: "container mt-2", children: "..." }), children: /* @__PURE__ */ jsx54(
2956
+ SelectedWidget,
2957
+ {
2958
+ params: getWidgetParameters(),
2959
+ query: props.query,
2960
+ session: props.session,
2961
+ host: props.host,
2962
+ path: props.path,
2963
+ apiBaseUrl: props.apiBaseUrl
2964
+ }
2965
+ ) });
2966
+ };
2967
+ var WidgetNode_default = WidgetNode;
2968
+
2969
+ // src/components/pageRenderingEngine/nodes/FormContainerNode.tsx
2970
+ import React47, { useRef as useRef3, useReducer as useReducer2, useCallback as useCallback3, useEffect as useEffect7 } from "react";
2971
+
2972
+ // src/components/pageRenderingEngine/nodes/InputControlNode.tsx
2973
+ import { jsx as jsx55 } from "react/jsx-runtime";
2974
+ var InputControlNode = (props) => {
2975
+ return /* @__PURE__ */ jsx55("div", { children: /* @__PURE__ */ jsx55(
2976
+ InputControl_default,
2977
+ {
2978
+ name: props.node.name,
2979
+ controlType: "lineTextInput",
2980
+ value: props.value,
2981
+ callback: props.callback,
2982
+ attributes: {
2983
+ pattern: props.node.pattern,
2984
+ maxLength: props.node.maxLength,
2985
+ minLength: props.node.minLength,
2986
+ //maxValue:props.node.maxV,
2987
+ //minValue?: number,
2988
+ readOnly: props.node.readOnly,
2989
+ label: "name",
2990
+ //props.node.label,
2991
+ hintText: props.node.hintText,
2992
+ placeholder: props.node.placeholder,
2993
+ required: props.node.required,
2994
+ errorMessage: props.node.errorMessage,
2995
+ helpText: props.node.helpText,
2996
+ autoFocus: props.node.autoFocus
2997
+ }
2998
+ }
2999
+ ) });
3000
+ };
3001
+ var InputControlNode_default = InputControlNode;
3002
+
3003
+ // src/components/pageRenderingEngine/nodes/FormContainerNode.tsx
3004
+ import { jsx as jsx56, jsxs as jsxs28 } from "react/jsx-runtime";
3005
+ var FormContainerNode = (props) => {
3006
+ const NodeTypes2 = {
3007
+ ["input-control"]: InputControlNode_default
3008
+ };
3009
+ const { node } = props;
3010
+ const formRef = useRef3(null);
3011
+ const initialState = {
3012
+ inputValues: {},
3013
+ lastPropertyChanged: ""
3014
+ };
3015
+ const [formState, dispatch] = useReducer2(FormReducer_default, initialState);
3016
+ const handleInputChange = useCallback3((updatedValues) => {
3017
+ dispatch({ type: FORM_INPUT_UPDATE, name: updatedValues.name, value: updatedValues.value });
3018
+ }, [dispatch]);
3019
+ const onValidate = async () => {
3020
+ if (formRef.current && !formRef.current.checkValidity()) {
3021
+ formRef.current.classList.add("validated");
3022
+ return false;
3023
+ } else {
3024
+ return true;
3025
+ }
3026
+ };
3027
+ useEffect7(() => {
3028
+ const fetchInitialData = async () => {
3029
+ if (!props.fetchData || !node.dataFetchApi) return;
3030
+ const response = await props.fetchData(
3031
+ node.dataFetchApi,
3032
+ props.routeParameters
3033
+ );
3034
+ if (response?.isSuccessful) {
3035
+ dispatch({
3036
+ type: FORM_INITIAL_UPDATE,
3037
+ values: response.result,
3038
+ name: "all"
3039
+ });
3040
+ }
3041
+ };
3042
+ fetchInitialData();
3043
+ }, [props.fetchData, node.dataFetchApi, props.routeParameters]);
3044
+ return /* @__PURE__ */ jsxs28("form", { className: "group space-y-6 pb-6 overflow-y-auto", noValidate: true, ref: formRef, children: [
3045
+ node.children && node.children.map((node2, index) => {
3046
+ {
3047
+ }
3048
+ const SelectedNode = NodeTypes2[node2.type];
3049
+ return /* @__PURE__ */ jsx56(React47.Fragment, { children: SelectedNode && node2.type == "input-control" && /* @__PURE__ */ jsx56(
3050
+ InputControlNode_default,
3051
+ {
3052
+ value: formState.inputValues[node2.name],
3053
+ callback: handleInputChange,
3054
+ node: node2
3055
+ }
3056
+ ) }, index);
3057
+ }),
3058
+ node.children.length == 0 && /* @__PURE__ */ jsx56("div", { className: "py-0.5 lg:py-1.5" })
3059
+ ] });
3060
+ };
3061
+ var FormContainerNode_default = FormContainerNode;
3062
+
3063
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
3064
+ import React48 from "react";
3065
+ import Link3 from "next/link";
3066
+
3067
+ // src/components/utilities/AssetUtility.tsx
3068
+ var AssetUtility = class {
3069
+ constructor() {
3070
+ }
3071
+ static resolveUrl(apiBaseUrl, url) {
3072
+ if (url) {
3073
+ if (url.startsWith("http")) {
3074
+ return url;
3075
+ } else {
3076
+ return `${apiBaseUrl}/digitalassets-management/${url}`;
3077
+ }
3078
+ }
3079
+ return void 0;
3080
+ }
3081
+ };
3082
+ var AssetUtility_default = AssetUtility;
3083
+
3084
+ // src/components/pageRenderingEngine/nodes/DivContainer.tsx
3085
+ import { jsx as jsx57, jsxs as jsxs29 } from "react/jsx-runtime";
3086
+ var DivContainer = (props) => {
3087
+ const { cssProperties: styles, hoverCssProperties: hoverStyles, mobileCssProperties: mobileStyles } = props.node;
3088
+ const updatedStyles = convertKeysToCamelCase(styles);
3089
+ const NodeTypes2 = {
3090
+ ["paragraph"]: ParagraphNode_default,
3091
+ ["heading"]: HeadingNode_default,
3092
+ ["list"]: ListNode_default,
3093
+ ["quote"]: QuoteNode_default,
3094
+ ["code"]: CodeNode_default,
3095
+ ["image"]: ImageNode_default,
3096
+ ["horizontalrule"]: HorizontalRuleNode_default,
3097
+ ["layout-container"]: LayoutContainerNode_default,
3098
+ ["widget"]: WidgetNode_default,
3099
+ ["div-container"]: DivContainer,
3100
+ ["text"]: TextNode_default
3101
+ };
3102
+ function toCamelCase(str) {
3103
+ return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
3104
+ }
3105
+ function convertKeysToCamelCase(obj) {
3106
+ if (!obj || typeof obj !== "object") return obj;
3107
+ if (Array.isArray(obj)) {
3108
+ return obj.map(convertKeysToCamelCase);
3109
+ }
3110
+ return Object.fromEntries(
3111
+ Object.entries(obj).filter(([_, value]) => value !== "" && value !== void 0).map(([key, value]) => [
3112
+ toCamelCase(key),
3113
+ convertKeysToCamelCase(value)
3114
+ // Recursively convert nested objects
3115
+ ])
3116
+ );
3117
+ }
3118
+ function generateCompleteBackgroundString(layers) {
3119
+ if (!layers || !Array.isArray(layers)) return "";
3120
+ return layers.filter((layer) => layer && layer.type && layer.value).map((layer) => {
3121
+ if (layer.type === "image" && layer.value && typeof layer.value === "object") {
3122
+ const imageValue = layer.value;
3123
+ if (!imageValue.assetUrl) return "";
3124
+ const url = `url('${AssetUtility_default.resolveUrl("/api/images", imageValue.assetUrl)}')`;
3125
+ const repeat = layer.repeat || "no-repeat";
3126
+ const position = layer.position || "center";
3127
+ const size = layer.size || "auto";
3128
+ const attachment = layer.attachment || "scroll";
3129
+ return `${url} ${position} / ${size} ${repeat} ${attachment}`;
3130
+ }
3131
+ if (layer.type === "gradient" && layer.value && typeof layer.value === "object") {
3132
+ const gradient = layer.value;
3133
+ if (!gradient.colors || !gradient.direction) return "";
3134
+ const colors = gradient.colors.map(
3135
+ (colorStop) => `color-mix(in srgb, ${colorStop.color}, transparent ${colorStop.transparency ?? 0}%) ${colorStop.start || "0%"}`
3136
+ ).join(", ");
3137
+ return `linear-gradient(${gradient.direction}, ${colors})`;
3138
+ }
3139
+ return "";
3140
+ }).filter((bg) => bg.trim() !== "").join(", ");
3141
+ }
3142
+ var background = generateCompleteBackgroundString(props.node.backgroundLayers);
3143
+ let containerPaddingClass = "";
3144
+ if (props.node.containerPadding == "small") {
3145
+ containerPaddingClass = "container-small";
3146
+ } else if (props.node.containerPadding == "large") {
3147
+ containerPaddingClass = "container-large";
3148
+ }
3149
+ const updatedStyle = { ...updatedStyles };
3150
+ const backgroundStyle = background && background !== "" ? { background } : {};
3151
+ const guid = "css" + crypto.randomUUID().toLocaleLowerCase();
3152
+ const generateCssString = (stylesObject, hoverStylesObject, mobileStylesObject) => {
3153
+ let gridColumns = stylesObject.gridTemplateColumns ? stylesObject.gridTemplateColumns.match(/\d+/g) : [];
3154
+ let hasGridProperties = gridColumns.length > 0;
3155
+ let tabletColumns = hasGridProperties ? Math.ceil(parseInt(gridColumns[0]) / 2) : 2;
3156
+ let mobileColumns = 1;
3157
+ let cssRules = Object.entries(stylesObject).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
3158
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
3159
+ return `${cssKey}: ${value};`;
3160
+ });
3161
+ let css2 = `#${guid} {
3162
+ ${cssRules.join("\n")}
3163
+
3164
+ transition: all 0.3s ease-in-out;
3165
+ }`;
3166
+ if (hoverStylesObject) {
3167
+ let hoverCssRules = Object.entries(hoverStylesObject).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
3168
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
3169
+ return `${cssKey}: ${value};`;
3170
+ });
3171
+ if (hoverCssRules.length > 0) {
3172
+ css2 += `
3173
+ #${guid}:hover {
3174
+ ${hoverCssRules.join("\n")}
3175
+ }`;
3176
+ }
3177
+ }
3178
+ if (mobileStylesObject) {
3179
+ let mobileCssRules = Object.entries(mobileStylesObject).filter(([_, value]) => value !== void 0 && value !== "").map(([key, value]) => {
3180
+ const cssKey = key.replace(/([A-Z])/g, "-$1").toLowerCase();
3181
+ return `${cssKey}: ${value};`;
3182
+ });
3183
+ if (mobileCssRules.length > 0) {
3184
+ css2 += `
3185
+ @media (max-width: 480px) { #${guid} {
3186
+ ${mobileCssRules.join("\n")}
3187
+ } }`;
3188
+ }
3189
+ }
3190
+ if (hasGridProperties) {
3191
+ css2 += `
3192
+ @media (max-width: 1279px) { #${guid} { grid-template-columns: repeat(${tabletColumns}, minmax(0, 1fr)); } }`;
3193
+ css2 += `
3194
+ @media (max-width: 768px) { #${guid} { grid-template-columns: repeat(${tabletColumns}, minmax(0, 1fr)); } }`;
3195
+ css2 += `
3196
+ @media (max-width: 480px) { #${guid} { grid-template-columns: repeat(${mobileColumns}, minmax(0, 1fr)); } }`;
3197
+ }
3198
+ return css2;
3199
+ };
3200
+ const css = generateCssString(updatedStyle, hoverStyles, mobileStyles);
3201
+ return /* @__PURE__ */ jsxs29(React48.Fragment, { children: [
3202
+ /* @__PURE__ */ jsx57("style", { dangerouslySetInnerHTML: { __html: css } }),
3203
+ props.node.href && props.node.href !== "" ? /* @__PURE__ */ jsx57(Link3, { href: props.node.href, className: "block", children: /* @__PURE__ */ jsx57(
3204
+ "div",
3205
+ {
3206
+ id: guid,
3207
+ style: { ...backgroundStyle, display: "block" },
3208
+ className: containerPaddingClass,
3209
+ children: props.node.children?.map((node, index) => {
3210
+ const SelectedNode = NodeTypes2[node.type];
3211
+ return /* @__PURE__ */ jsx57(React48.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx57(
3212
+ SelectedNode,
3213
+ {
3214
+ node,
3215
+ routeParameters: props.routeParameters,
3216
+ query: props.query,
3217
+ session: props.session,
3218
+ host: props.host,
3219
+ path: props.path,
3220
+ apiBaseUrl: props.apiBaseUrl,
3221
+ breadcrumb: props.breadcrumb
3222
+ }
3223
+ ) }, index);
3224
+ })
3225
+ }
3226
+ ) }) : /* @__PURE__ */ jsx57("div", { id: guid, style: { ...backgroundStyle }, className: containerPaddingClass, children: props.node.children && props.node.children.map((node, index) => {
3227
+ const SelectedNode = NodeTypes2[node.type];
3228
+ return /* @__PURE__ */ jsx57(React48.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx57(
3229
+ SelectedNode,
3230
+ {
3231
+ node,
3232
+ routeParameters: props.routeParameters,
3233
+ query: props.query,
3234
+ session: props.session,
3235
+ host: props.host,
3236
+ path: props.path,
3237
+ apiBaseUrl: props.apiBaseUrl,
3238
+ breadcrumb: props.breadcrumb
3239
+ }
3240
+ ) }, index);
3241
+ }) })
3242
+ ] });
3243
+ };
3244
+ var DivContainer_default = DivContainer;
3245
+
3246
+ // src/components/pageRenderingEngine/PageBodyRenderer.tsx
3247
+ import { jsx as jsx58 } from "react/jsx-runtime";
3248
+ var NodeTypes = {
3249
+ ["paragraph"]: ParagraphNode_default,
3250
+ ["heading"]: HeadingNode_default,
3251
+ ["list"]: ListNode_default,
3252
+ ["quote"]: QuoteNode_default,
3253
+ ["code"]: CodeNode_default,
3254
+ ["image"]: ImageNode_default,
3255
+ ["horizontalrule"]: HorizontalRuleNode_default,
3256
+ ["layout-container"]: LayoutContainerNode_default,
3257
+ ["widget"]: WidgetNode_default,
3258
+ ["form-container"]: FormContainerNode_default,
3259
+ ["div-container"]: DivContainer_default
3260
+ };
3261
+ var PageBodyRenderer = (props) => {
3262
+ let pageBodyTree;
3263
+ if (props.rawBody != void 0 && props.rawBody != null && props.rawBody != "") {
3264
+ try {
3265
+ pageBodyTree = JSON.parse(props.rawBody.toString());
3266
+ } catch (error) {
3267
+ }
3268
+ }
3269
+ let rootNode;
3270
+ if (pageBodyTree && pageBodyTree.root) {
3271
+ rootNode = pageBodyTree.root;
3272
+ }
3273
+ return /* @__PURE__ */ jsx58(React49.Fragment, { children: rootNode && rootNode?.children?.map((node, index) => {
3274
+ {
3275
+ }
3276
+ const SelectedNode = NodeTypes[node.type];
3277
+ return /* @__PURE__ */ jsx58(React49.Fragment, { children: SelectedNode && /* @__PURE__ */ jsx58(React49.Fragment, { children: node.type == "layout-container" ? /* @__PURE__ */ jsx58(React49.Fragment, { children: /* @__PURE__ */ jsx58(
3278
+ SelectedNode,
3279
+ {
3280
+ node,
3281
+ firstNode: true,
3282
+ routeParameters: props.routeParameters,
3283
+ query: props.query,
3284
+ session: props.session,
3285
+ host: props.host,
3286
+ path: props.path,
3287
+ apiBaseUrl: props.apiBaseUrl
3288
+ }
3289
+ ) }) : /* @__PURE__ */ jsx58(React49.Fragment, { children: /* @__PURE__ */ jsx58(
3290
+ SelectedNode,
3291
+ {
3292
+ node,
3293
+ routeParameters: props.routeParameters,
3294
+ query: props.query,
3295
+ session: props.session,
3296
+ host: props.host,
3297
+ path: props.path,
3298
+ apiBaseUrl: props.apiBaseUrl
3299
+ }
3300
+ ) }) }) }, index);
3301
+ }) });
3302
+ };
3303
+ var PageBodyRenderer_default = PageBodyRenderer;
2497
3304
  export {
2498
3305
  DataList_default as DataList,
2499
3306
  InputControl_default as InputControl,
2500
3307
  InputControlType_default as InputControlType,
3308
+ PageBodyRenderer_default as PageBodyRenderer,
2501
3309
  ViewControl_default as ViewControl,
2502
3310
  ViewControlTypes_default as ViewControlTypes
2503
3311
  };