@acoustte-digital-services/digitalstore-controls-dev 0.8.1-dev.20260615115948 → 0.8.1-dev.20260616053702

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.js CHANGED
@@ -5505,17 +5505,55 @@ var getNestedValue3 = (obj, path) => {
5505
5505
  return current && current[key] !== void 0 ? current[key] : void 0;
5506
5506
  }, obj);
5507
5507
  };
5508
- {
5509
- }
5510
- function generateCompleteBackgroundString(layers, apiBaseUrl) {
5508
+ function generateCompleteBackgroundString(layers, apiBaseUrl, dataItem) {
5511
5509
  if (!layers || !Array.isArray(layers)) return "";
5512
5510
  return layers.filter((layer) => layer && layer.type && layer.value).map((layer) => {
5513
5511
  if (layer.type === "image" && typeof layer.value === "object") {
5514
5512
  const imageValue = layer.value;
5515
- if (!imageValue.assetUrl) return "";
5513
+ let assetUrl = imageValue.assetUrl || "";
5514
+ if (layer.datafield && dataItem) {
5515
+ const fieldValue = getNestedValue3(
5516
+ dataItem,
5517
+ layer.datafield
5518
+ );
5519
+ if (typeof fieldValue === "string" && fieldValue.trim() !== "") {
5520
+ const trimmedValue = fieldValue.trim();
5521
+ if (trimmedValue.startsWith("[") || trimmedValue.startsWith("{")) {
5522
+ try {
5523
+ const parsed = JSON.parse(trimmedValue);
5524
+ if (Array.isArray(parsed)) {
5525
+ const matchedAsset = layer.tag ? parsed.find(
5526
+ (x) => x?.tag?.toLowerCase() === layer.tag?.toLowerCase()
5527
+ ) : parsed[0];
5528
+ if (matchedAsset?.assetUrl) {
5529
+ assetUrl = matchedAsset.assetUrl;
5530
+ }
5531
+ } else if (parsed?.assetUrl) {
5532
+ assetUrl = parsed.assetUrl;
5533
+ }
5534
+ } catch {
5535
+ assetUrl = trimmedValue;
5536
+ }
5537
+ } else {
5538
+ assetUrl = trimmedValue;
5539
+ }
5540
+ } else if (fieldValue && typeof fieldValue === "object" && fieldValue.assetUrl) {
5541
+ assetUrl = fieldValue.assetUrl;
5542
+ } else if (Array.isArray(fieldValue)) {
5543
+ const matchedAsset = layer.tag ? fieldValue.find(
5544
+ (x) => x?.tag?.toLowerCase() === layer.tag?.toLowerCase()
5545
+ ) : fieldValue[0];
5546
+ if (matchedAsset?.assetUrl) {
5547
+ assetUrl = matchedAsset.assetUrl;
5548
+ }
5549
+ }
5550
+ }
5551
+ if (!assetUrl) {
5552
+ return "";
5553
+ }
5516
5554
  const url = `url('${AssetUtility_default.resolveUrl(
5517
5555
  apiBaseUrl,
5518
- imageValue.assetUrl
5556
+ assetUrl
5519
5557
  )}')`;
5520
5558
  const repeat = layer.repeat || "no-repeat";
5521
5559
  const position = layer.position || "center";
@@ -5525,7 +5563,9 @@ function generateCompleteBackgroundString(layers, apiBaseUrl) {
5525
5563
  }
5526
5564
  if (layer.type === "gradient" && typeof layer.value === "object") {
5527
5565
  const gradient = layer.value;
5528
- if (!gradient.colors || !gradient.direction) return "";
5566
+ if (!gradient.colors || !gradient.direction) {
5567
+ return "";
5568
+ }
5529
5569
  const colors = gradient.colors.map(
5530
5570
  (colorStop) => `color-mix(in srgb, ${colorStop.color}, transparent ${colorStop.transparency ?? 0}%) ${colorStop.start || "0%"}`
5531
5571
  ).join(", ");
@@ -5628,7 +5668,6 @@ var DivContainer = async (props) => {
5628
5668
  const tabletStyles = props.node.tabletCssProperties;
5629
5669
  const dataBindingProperties = props.node.dataBinding;
5630
5670
  const updatedStyles = convertKeysToCamelCase(styles);
5631
- const background = generateCompleteBackgroundString(props.node.backgroundLayers, props.assetBaseUrl);
5632
5671
  let containerPaddingClass = "";
5633
5672
  if (props.node.containerPadding == "small") {
5634
5673
  containerPaddingClass = "container-small";
@@ -5638,14 +5677,6 @@ var DivContainer = async (props) => {
5638
5677
  {
5639
5678
  }
5640
5679
  const updatedStyle = { ...updatedStyles };
5641
- const backgroundStyle = background && background !== "" ? { background } : {};
5642
- const combinedStyles = {
5643
- ...backgroundStyle
5644
- };
5645
- if (props.node.enableBackgroundClipText) {
5646
- combinedStyles.WebkitBackgroundClip = "text";
5647
- combinedStyles.backgroundClip = "text";
5648
- }
5649
5680
  const guid = "css" + crypto.randomUUID().toLocaleLowerCase();
5650
5681
  const { enterAnimation, exitAnimation, hoverAnimation } = props.node;
5651
5682
  let animationCSS = "";
@@ -5766,6 +5797,20 @@ var DivContainer = async (props) => {
5766
5797
  }
5767
5798
  return [props.dataitem];
5768
5799
  })();
5800
+ const backgroundDataItem = dataToRender.length > 0 ? dataToRender[0] : props.dataitem;
5801
+ const background = generateCompleteBackgroundString(
5802
+ props.node.backgroundLayers,
5803
+ props.assetBaseUrl,
5804
+ backgroundDataItem
5805
+ );
5806
+ const backgroundStyle = background && background !== "" ? { background } : {};
5807
+ const combinedStyles = {
5808
+ ...backgroundStyle
5809
+ };
5810
+ if (props.node.enableBackgroundClipText) {
5811
+ combinedStyles.WebkitBackgroundClip = "text";
5812
+ combinedStyles.backgroundClip = "text";
5813
+ }
5769
5814
  const renderLink = result && props.node.dataBinding?.responseType === "array" ? true : false;
5770
5815
  {
5771
5816
  }
package/dist/index.mjs CHANGED
@@ -3899,17 +3899,55 @@ var getNestedValue3 = (obj, path) => {
3899
3899
  return current && current[key] !== void 0 ? current[key] : void 0;
3900
3900
  }, obj);
3901
3901
  };
3902
- {
3903
- }
3904
- function generateCompleteBackgroundString(layers, apiBaseUrl) {
3902
+ function generateCompleteBackgroundString(layers, apiBaseUrl, dataItem) {
3905
3903
  if (!layers || !Array.isArray(layers)) return "";
3906
3904
  return layers.filter((layer) => layer && layer.type && layer.value).map((layer) => {
3907
3905
  if (layer.type === "image" && typeof layer.value === "object") {
3908
3906
  const imageValue = layer.value;
3909
- if (!imageValue.assetUrl) return "";
3907
+ let assetUrl = imageValue.assetUrl || "";
3908
+ if (layer.datafield && dataItem) {
3909
+ const fieldValue = getNestedValue3(
3910
+ dataItem,
3911
+ layer.datafield
3912
+ );
3913
+ if (typeof fieldValue === "string" && fieldValue.trim() !== "") {
3914
+ const trimmedValue = fieldValue.trim();
3915
+ if (trimmedValue.startsWith("[") || trimmedValue.startsWith("{")) {
3916
+ try {
3917
+ const parsed = JSON.parse(trimmedValue);
3918
+ if (Array.isArray(parsed)) {
3919
+ const matchedAsset = layer.tag ? parsed.find(
3920
+ (x) => x?.tag?.toLowerCase() === layer.tag?.toLowerCase()
3921
+ ) : parsed[0];
3922
+ if (matchedAsset?.assetUrl) {
3923
+ assetUrl = matchedAsset.assetUrl;
3924
+ }
3925
+ } else if (parsed?.assetUrl) {
3926
+ assetUrl = parsed.assetUrl;
3927
+ }
3928
+ } catch {
3929
+ assetUrl = trimmedValue;
3930
+ }
3931
+ } else {
3932
+ assetUrl = trimmedValue;
3933
+ }
3934
+ } else if (fieldValue && typeof fieldValue === "object" && fieldValue.assetUrl) {
3935
+ assetUrl = fieldValue.assetUrl;
3936
+ } else if (Array.isArray(fieldValue)) {
3937
+ const matchedAsset = layer.tag ? fieldValue.find(
3938
+ (x) => x?.tag?.toLowerCase() === layer.tag?.toLowerCase()
3939
+ ) : fieldValue[0];
3940
+ if (matchedAsset?.assetUrl) {
3941
+ assetUrl = matchedAsset.assetUrl;
3942
+ }
3943
+ }
3944
+ }
3945
+ if (!assetUrl) {
3946
+ return "";
3947
+ }
3910
3948
  const url = `url('${AssetUtility_default.resolveUrl(
3911
3949
  apiBaseUrl,
3912
- imageValue.assetUrl
3950
+ assetUrl
3913
3951
  )}')`;
3914
3952
  const repeat = layer.repeat || "no-repeat";
3915
3953
  const position = layer.position || "center";
@@ -3919,7 +3957,9 @@ function generateCompleteBackgroundString(layers, apiBaseUrl) {
3919
3957
  }
3920
3958
  if (layer.type === "gradient" && typeof layer.value === "object") {
3921
3959
  const gradient = layer.value;
3922
- if (!gradient.colors || !gradient.direction) return "";
3960
+ if (!gradient.colors || !gradient.direction) {
3961
+ return "";
3962
+ }
3923
3963
  const colors = gradient.colors.map(
3924
3964
  (colorStop) => `color-mix(in srgb, ${colorStop.color}, transparent ${colorStop.transparency ?? 0}%) ${colorStop.start || "0%"}`
3925
3965
  ).join(", ");
@@ -4022,7 +4062,6 @@ var DivContainer = async (props) => {
4022
4062
  const tabletStyles = props.node.tabletCssProperties;
4023
4063
  const dataBindingProperties = props.node.dataBinding;
4024
4064
  const updatedStyles = convertKeysToCamelCase(styles);
4025
- const background = generateCompleteBackgroundString(props.node.backgroundLayers, props.assetBaseUrl);
4026
4065
  let containerPaddingClass = "";
4027
4066
  if (props.node.containerPadding == "small") {
4028
4067
  containerPaddingClass = "container-small";
@@ -4032,14 +4071,6 @@ var DivContainer = async (props) => {
4032
4071
  {
4033
4072
  }
4034
4073
  const updatedStyle = { ...updatedStyles };
4035
- const backgroundStyle = background && background !== "" ? { background } : {};
4036
- const combinedStyles = {
4037
- ...backgroundStyle
4038
- };
4039
- if (props.node.enableBackgroundClipText) {
4040
- combinedStyles.WebkitBackgroundClip = "text";
4041
- combinedStyles.backgroundClip = "text";
4042
- }
4043
4074
  const guid = "css" + crypto.randomUUID().toLocaleLowerCase();
4044
4075
  const { enterAnimation, exitAnimation, hoverAnimation } = props.node;
4045
4076
  let animationCSS = "";
@@ -4160,6 +4191,20 @@ var DivContainer = async (props) => {
4160
4191
  }
4161
4192
  return [props.dataitem];
4162
4193
  })();
4194
+ const backgroundDataItem = dataToRender.length > 0 ? dataToRender[0] : props.dataitem;
4195
+ const background = generateCompleteBackgroundString(
4196
+ props.node.backgroundLayers,
4197
+ props.assetBaseUrl,
4198
+ backgroundDataItem
4199
+ );
4200
+ const backgroundStyle = background && background !== "" ? { background } : {};
4201
+ const combinedStyles = {
4202
+ ...backgroundStyle
4203
+ };
4204
+ if (props.node.enableBackgroundClipText) {
4205
+ combinedStyles.WebkitBackgroundClip = "text";
4206
+ combinedStyles.backgroundClip = "text";
4207
+ }
4163
4208
  const renderLink = result && props.node.dataBinding?.responseType === "array" ? true : false;
4164
4209
  {
4165
4210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acoustte-digital-services/digitalstore-controls-dev",
3
- "version": "0.8.1-dev.20260615115948",
3
+ "version": "0.8.1-dev.20260616053702",
4
4
  "description": "Reusable React components",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",