@uniformdev/canvas 19.88.1-alpha.7 → 19.89.0

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.esm.js CHANGED
@@ -1650,9 +1650,7 @@ function localize(options) {
1650
1650
  }
1651
1651
  return;
1652
1652
  }
1653
- if (typeof locale === "string") {
1654
- localizeProperties(getPropertiesValue(node), locale);
1655
- }
1653
+ const shouldRunPropertyLocalization = typeof locale === "string";
1656
1654
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1657
1655
  const locales = extractLocales({ component: node });
1658
1656
  const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
@@ -1661,6 +1659,12 @@ function localize(options) {
1661
1659
  replaceComponent = locales[resolvedLocale];
1662
1660
  }
1663
1661
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1662
+ replaceComponent.forEach((component) => {
1663
+ removeLocaleProperty(component);
1664
+ if (shouldRunPropertyLocalization) {
1665
+ localizeProperties(getPropertiesValue(component), locale);
1666
+ }
1667
+ });
1664
1668
  const [first, ...rest] = replaceComponent;
1665
1669
  actions.replace(first);
1666
1670
  if (rest.length) {
@@ -1669,9 +1673,26 @@ function localize(options) {
1669
1673
  } else {
1670
1674
  actions.remove();
1671
1675
  }
1676
+ } else if (shouldRunPropertyLocalization) {
1677
+ localizeProperties(getPropertiesValue(node), locale);
1672
1678
  }
1673
1679
  });
1674
1680
  }
1681
+ function removeLocaleProperty(component) {
1682
+ const properties = getPropertiesValue(component);
1683
+ const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
1684
+ if (localeTagProperty) {
1685
+ delete properties[CANVAS_LOCALE_TAG_PARAM];
1686
+ }
1687
+ if (properties && Object.keys(properties).length === 0) {
1688
+ if ("fields" in component) {
1689
+ delete component.fields;
1690
+ }
1691
+ if ("parameters" in component) {
1692
+ delete component.parameters;
1693
+ }
1694
+ }
1695
+ }
1675
1696
  function localizeProperties(properties, locale) {
1676
1697
  if (!properties) {
1677
1698
  return void 0;
package/dist/index.js CHANGED
@@ -1777,9 +1777,7 @@ function localize(options) {
1777
1777
  }
1778
1778
  return;
1779
1779
  }
1780
- if (typeof locale === "string") {
1781
- localizeProperties(getPropertiesValue(node), locale);
1782
- }
1780
+ const shouldRunPropertyLocalization = typeof locale === "string";
1783
1781
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1784
1782
  const locales = extractLocales({ component: node });
1785
1783
  const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
@@ -1788,6 +1786,12 @@ function localize(options) {
1788
1786
  replaceComponent = locales[resolvedLocale];
1789
1787
  }
1790
1788
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1789
+ replaceComponent.forEach((component) => {
1790
+ removeLocaleProperty(component);
1791
+ if (shouldRunPropertyLocalization) {
1792
+ localizeProperties(getPropertiesValue(component), locale);
1793
+ }
1794
+ });
1791
1795
  const [first, ...rest] = replaceComponent;
1792
1796
  actions.replace(first);
1793
1797
  if (rest.length) {
@@ -1796,9 +1800,26 @@ function localize(options) {
1796
1800
  } else {
1797
1801
  actions.remove();
1798
1802
  }
1803
+ } else if (shouldRunPropertyLocalization) {
1804
+ localizeProperties(getPropertiesValue(node), locale);
1799
1805
  }
1800
1806
  });
1801
1807
  }
1808
+ function removeLocaleProperty(component) {
1809
+ const properties = getPropertiesValue(component);
1810
+ const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
1811
+ if (localeTagProperty) {
1812
+ delete properties[CANVAS_LOCALE_TAG_PARAM];
1813
+ }
1814
+ if (properties && Object.keys(properties).length === 0) {
1815
+ if ("fields" in component) {
1816
+ delete component.fields;
1817
+ }
1818
+ if ("parameters" in component) {
1819
+ delete component.parameters;
1820
+ }
1821
+ }
1822
+ }
1802
1823
  function localizeProperties(properties, locale) {
1803
1824
  if (!properties) {
1804
1825
  return void 0;
package/dist/index.mjs CHANGED
@@ -1650,9 +1650,7 @@ function localize(options) {
1650
1650
  }
1651
1651
  return;
1652
1652
  }
1653
- if (typeof locale === "string") {
1654
- localizeProperties(getPropertiesValue(node), locale);
1655
- }
1653
+ const shouldRunPropertyLocalization = typeof locale === "string";
1656
1654
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1657
1655
  const locales = extractLocales({ component: node });
1658
1656
  const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
@@ -1661,6 +1659,12 @@ function localize(options) {
1661
1659
  replaceComponent = locales[resolvedLocale];
1662
1660
  }
1663
1661
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1662
+ replaceComponent.forEach((component) => {
1663
+ removeLocaleProperty(component);
1664
+ if (shouldRunPropertyLocalization) {
1665
+ localizeProperties(getPropertiesValue(component), locale);
1666
+ }
1667
+ });
1664
1668
  const [first, ...rest] = replaceComponent;
1665
1669
  actions.replace(first);
1666
1670
  if (rest.length) {
@@ -1669,9 +1673,26 @@ function localize(options) {
1669
1673
  } else {
1670
1674
  actions.remove();
1671
1675
  }
1676
+ } else if (shouldRunPropertyLocalization) {
1677
+ localizeProperties(getPropertiesValue(node), locale);
1672
1678
  }
1673
1679
  });
1674
1680
  }
1681
+ function removeLocaleProperty(component) {
1682
+ const properties = getPropertiesValue(component);
1683
+ const localeTagProperty = properties == null ? void 0 : properties[CANVAS_LOCALE_TAG_PARAM];
1684
+ if (localeTagProperty) {
1685
+ delete properties[CANVAS_LOCALE_TAG_PARAM];
1686
+ }
1687
+ if (properties && Object.keys(properties).length === 0) {
1688
+ if ("fields" in component) {
1689
+ delete component.fields;
1690
+ }
1691
+ if ("parameters" in component) {
1692
+ delete component.parameters;
1693
+ }
1694
+ }
1695
+ }
1675
1696
  function localizeProperties(properties, locale) {
1676
1697
  if (!properties) {
1677
1698
  return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "19.88.1-alpha.7+69b3ccba4",
3
+ "version": "19.89.0",
4
4
  "description": "Common functionality and types for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -38,8 +38,8 @@
38
38
  "pusher-js": "8.2.0"
39
39
  },
40
40
  "dependencies": {
41
- "@uniformdev/assets": "19.88.1-alpha.7+69b3ccba4",
42
- "@uniformdev/context": "19.88.1-alpha.7+69b3ccba4",
41
+ "@uniformdev/assets": "19.89.0",
42
+ "@uniformdev/context": "19.89.0",
43
43
  "immer": "10.0.3"
44
44
  },
45
45
  "files": [
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "69b3ccba4050c4ff412c4f226f54a36d74cf9a39"
51
+ "gitHead": "247189fb1039d0f81498949534646baaffb8bca7"
52
52
  }