@plasmicpkgs/plasmic-cms 0.0.35 → 0.0.39
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/plasmic-cms.cjs.development.js +87 -40
- package/dist/plasmic-cms.cjs.development.js.map +1 -1
- package/dist/plasmic-cms.cjs.production.min.js +1 -1
- package/dist/plasmic-cms.cjs.production.min.js.map +1 -1
- package/dist/plasmic-cms.esm.js +87 -40
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1454,15 +1454,6 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1454
1454
|
config = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1455
1455
|
|
|
1456
1456
|
config.host = config.host || defaultHost;
|
|
1457
|
-
|
|
1458
|
-
if (!config.databaseId) {
|
|
1459
|
-
throw new Error("You must specify the CMS database ID to use.");
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
if (!config.databaseToken) {
|
|
1463
|
-
throw new Error("You must specify the token of the CMS database you are using.");
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
1457
|
return React.createElement(DatabaseProvider, {
|
|
1467
1458
|
config: config
|
|
1468
1459
|
}, React.createElement(TablesFetcher, null, children));
|
|
@@ -1480,9 +1471,21 @@ function TablesFetcher(_ref2) {
|
|
|
1480
1471
|
while (1) {
|
|
1481
1472
|
switch (_context.prev = _context.next) {
|
|
1482
1473
|
case 0:
|
|
1483
|
-
|
|
1474
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1475
|
+
_context.next = 2;
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1484
1478
|
|
|
1485
|
-
|
|
1479
|
+
return _context.abrupt("return", []);
|
|
1480
|
+
|
|
1481
|
+
case 2:
|
|
1482
|
+
_context.next = 4;
|
|
1483
|
+
return mkApi(databaseConfig).fetchTables();
|
|
1484
|
+
|
|
1485
|
+
case 4:
|
|
1486
|
+
return _context.abrupt("return", _context.sent);
|
|
1487
|
+
|
|
1488
|
+
case 5:
|
|
1486
1489
|
case "end":
|
|
1487
1490
|
return _context.stop();
|
|
1488
1491
|
}
|
|
@@ -1500,7 +1503,7 @@ function TablesFetcher(_ref2) {
|
|
|
1500
1503
|
|
|
1501
1504
|
var cmsQueryLoaderMeta = {
|
|
1502
1505
|
name: componentPrefix + "-query-loader",
|
|
1503
|
-
displayName: "CMS
|
|
1506
|
+
displayName: "CMS Data Loader",
|
|
1504
1507
|
importName: "CmsQueryLoader",
|
|
1505
1508
|
importPath: modulePath,
|
|
1506
1509
|
props: {
|
|
@@ -1553,6 +1556,11 @@ var cmsQueryLoaderMeta = {
|
|
|
1553
1556
|
}
|
|
1554
1557
|
}
|
|
1555
1558
|
};
|
|
1559
|
+
|
|
1560
|
+
function isDatabaseConfigured(config) {
|
|
1561
|
+
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1556
1564
|
function CmsQueryLoader(_ref5) {
|
|
1557
1565
|
var table = _ref5.table,
|
|
1558
1566
|
children = _ref5.children,
|
|
@@ -1590,27 +1598,35 @@ function CmsQueryLoader(_ref5) {
|
|
|
1590
1598
|
while (1) {
|
|
1591
1599
|
switch (_context2.prev = _context2.next) {
|
|
1592
1600
|
case 0:
|
|
1601
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1602
|
+
_context2.next = 2;
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
throw new Error("You must specify the CMS ID and API key");
|
|
1607
|
+
|
|
1608
|
+
case 2:
|
|
1593
1609
|
if (table) {
|
|
1594
|
-
_context2.next =
|
|
1610
|
+
_context2.next = 6;
|
|
1595
1611
|
break;
|
|
1596
1612
|
}
|
|
1597
1613
|
|
|
1598
|
-
throw new Error("You must select a
|
|
1614
|
+
throw new Error("You must select a model to query");
|
|
1599
1615
|
|
|
1600
|
-
case
|
|
1616
|
+
case 6:
|
|
1601
1617
|
if (!(tables && !tables.find(function (t) {
|
|
1602
1618
|
return t.identifier === table;
|
|
1603
1619
|
}))) {
|
|
1604
|
-
_context2.next =
|
|
1620
|
+
_context2.next = 8;
|
|
1605
1621
|
break;
|
|
1606
1622
|
}
|
|
1607
1623
|
|
|
1608
|
-
throw new Error("There is no
|
|
1624
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1609
1625
|
|
|
1610
|
-
case
|
|
1626
|
+
case 8:
|
|
1611
1627
|
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1612
1628
|
|
|
1613
|
-
case
|
|
1629
|
+
case 9:
|
|
1614
1630
|
case "end":
|
|
1615
1631
|
return _context2.stop();
|
|
1616
1632
|
}
|
|
@@ -1628,7 +1644,7 @@ function CmsQueryLoader(_ref5) {
|
|
|
1628
1644
|
}
|
|
1629
1645
|
var cmsRowRepeaterMeta = {
|
|
1630
1646
|
name: componentPrefix + "-row-repeater",
|
|
1631
|
-
displayName: "CMS
|
|
1647
|
+
displayName: "CMS Entry Repeater",
|
|
1632
1648
|
importName: "CmsRowRepeater",
|
|
1633
1649
|
importPath: modulePath,
|
|
1634
1650
|
props: {
|
|
@@ -1676,7 +1692,7 @@ function CmsRowRepeater(_ref7) {
|
|
|
1676
1692
|
}
|
|
1677
1693
|
var cmsQueryRepeaterMeta = {
|
|
1678
1694
|
name: componentPrefix + "-query-repeater",
|
|
1679
|
-
displayName: "CMS
|
|
1695
|
+
displayName: "CMS Data Loader",
|
|
1680
1696
|
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1681
1697
|
importName: "CmsQueryRepeater",
|
|
1682
1698
|
importPath: modulePath,
|
|
@@ -1684,8 +1700,11 @@ var cmsQueryRepeaterMeta = {
|
|
|
1684
1700
|
children: {
|
|
1685
1701
|
type: "slot",
|
|
1686
1702
|
defaultValue: {
|
|
1687
|
-
type: "
|
|
1688
|
-
|
|
1703
|
+
type: "vbox",
|
|
1704
|
+
children: [{
|
|
1705
|
+
type: "component",
|
|
1706
|
+
name: componentPrefix + "-row-field"
|
|
1707
|
+
}]
|
|
1689
1708
|
}
|
|
1690
1709
|
},
|
|
1691
1710
|
table: {
|
|
@@ -1705,7 +1724,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1705
1724
|
where: {
|
|
1706
1725
|
type: "object",
|
|
1707
1726
|
displayName: "Filter",
|
|
1708
|
-
description: "Filter clause, in JSON format."
|
|
1727
|
+
description: "Filter clause, in JSON format.",
|
|
1728
|
+
hidden: function hidden() {
|
|
1729
|
+
return true;
|
|
1730
|
+
}
|
|
1709
1731
|
},
|
|
1710
1732
|
orderBy: {
|
|
1711
1733
|
type: "choice",
|
|
@@ -1762,32 +1784,45 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1762
1784
|
databaseConfig: databaseConfig,
|
|
1763
1785
|
params: params
|
|
1764
1786
|
});
|
|
1787
|
+
|
|
1788
|
+
if (!table && tables && tables.length > 0) {
|
|
1789
|
+
table = tables[0].identifier;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1765
1792
|
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1766
1793
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1767
1794
|
while (1) {
|
|
1768
1795
|
switch (_context3.prev = _context3.next) {
|
|
1769
1796
|
case 0:
|
|
1797
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1798
|
+
_context3.next = 2;
|
|
1799
|
+
break;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
throw new Error("You must specify a CMS ID and API key");
|
|
1803
|
+
|
|
1804
|
+
case 2:
|
|
1770
1805
|
if (table) {
|
|
1771
|
-
_context3.next =
|
|
1806
|
+
_context3.next = 6;
|
|
1772
1807
|
break;
|
|
1773
1808
|
}
|
|
1774
1809
|
|
|
1775
|
-
throw new Error("You must select a
|
|
1810
|
+
throw new Error("You must select a model to query");
|
|
1776
1811
|
|
|
1777
|
-
case
|
|
1812
|
+
case 6:
|
|
1778
1813
|
if (!(tables && !tables.find(function (t) {
|
|
1779
1814
|
return t.identifier === table;
|
|
1780
1815
|
}))) {
|
|
1781
|
-
_context3.next =
|
|
1816
|
+
_context3.next = 10;
|
|
1782
1817
|
break;
|
|
1783
1818
|
}
|
|
1784
1819
|
|
|
1785
|
-
throw new Error("There is no
|
|
1820
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1786
1821
|
|
|
1787
|
-
case
|
|
1822
|
+
case 10:
|
|
1788
1823
|
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1789
1824
|
|
|
1790
|
-
case
|
|
1825
|
+
case 11:
|
|
1791
1826
|
case "end":
|
|
1792
1827
|
return _context3.stop();
|
|
1793
1828
|
}
|
|
@@ -1795,6 +1830,10 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1795
1830
|
}, _callee3);
|
|
1796
1831
|
})));
|
|
1797
1832
|
return renderMaybeData(maybeData, function (rows) {
|
|
1833
|
+
if (rows.length === 0) {
|
|
1834
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1798
1837
|
return React.createElement(QueryResultProvider, {
|
|
1799
1838
|
table: table,
|
|
1800
1839
|
rows: rows
|
|
@@ -1810,7 +1849,7 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1810
1849
|
}
|
|
1811
1850
|
var cmsRowFieldMeta = {
|
|
1812
1851
|
name: componentPrefix + "-row-field",
|
|
1813
|
-
displayName: "CMS
|
|
1852
|
+
displayName: "CMS Entry Field",
|
|
1814
1853
|
importName: "CmsRowField",
|
|
1815
1854
|
importPath: modulePath,
|
|
1816
1855
|
props: {
|
|
@@ -1830,7 +1869,7 @@ var cmsRowFieldMeta = {
|
|
|
1830
1869
|
var _ctx$table;
|
|
1831
1870
|
|
|
1832
1871
|
var table = _ref11.table;
|
|
1833
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number", "boolean", "text", "long-text", "date-time", "rich-text"]);
|
|
1872
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number", "boolean", "text", "long-text", "date-time", "rich-text", "image"]);
|
|
1834
1873
|
}
|
|
1835
1874
|
},
|
|
1836
1875
|
dateFormat: {
|
|
@@ -1919,8 +1958,16 @@ function CmsRowField(_ref13) {
|
|
|
1919
1958
|
var tables = useTables();
|
|
1920
1959
|
var res = useRow(table);
|
|
1921
1960
|
|
|
1922
|
-
if (!res
|
|
1923
|
-
return React.createElement("div",
|
|
1961
|
+
if (!res) {
|
|
1962
|
+
return React.createElement("div", {
|
|
1963
|
+
className: className
|
|
1964
|
+
}, "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
if (!res.row) {
|
|
1968
|
+
return React.createElement("div", {
|
|
1969
|
+
className: className
|
|
1970
|
+
}, "Error: No CMS Entry found");
|
|
1924
1971
|
}
|
|
1925
1972
|
|
|
1926
1973
|
if (tables) {
|
|
@@ -1936,11 +1983,11 @@ function CmsRowField(_ref13) {
|
|
|
1936
1983
|
table: res.table,
|
|
1937
1984
|
tables: tables,
|
|
1938
1985
|
field: field,
|
|
1939
|
-
typeFilters: ["text"]
|
|
1986
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1940
1987
|
});
|
|
1941
1988
|
|
|
1942
1989
|
if (!fieldMeta) {
|
|
1943
|
-
|
|
1990
|
+
throw new Error("Please select an entry field to display.");
|
|
1944
1991
|
}
|
|
1945
1992
|
|
|
1946
1993
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
@@ -2015,7 +2062,7 @@ function renderValue(value, type, props) {
|
|
|
2015
2062
|
|
|
2016
2063
|
var cmsRowLinkMeta = {
|
|
2017
2064
|
name: componentPrefix + "-row-link",
|
|
2018
|
-
displayName: "CMS
|
|
2065
|
+
displayName: "CMS Entry Link",
|
|
2019
2066
|
importName: "CmsRowLink",
|
|
2020
2067
|
importPath: modulePath,
|
|
2021
2068
|
props: {
|
|
@@ -2106,7 +2153,7 @@ function CmsRowLink(_ref15) {
|
|
|
2106
2153
|
}
|
|
2107
2154
|
var cmsRowImageMeta = {
|
|
2108
2155
|
name: componentPrefix + "-row-image",
|
|
2109
|
-
displayName: "CMS
|
|
2156
|
+
displayName: "CMS Entry Image",
|
|
2110
2157
|
importName: "CmsRowImage",
|
|
2111
2158
|
importPath: modulePath,
|
|
2112
2159
|
props: {
|
|
@@ -2202,7 +2249,7 @@ function CmsRowImage(_ref17) {
|
|
|
2202
2249
|
}
|
|
2203
2250
|
var cmsRowFieldValueMeta = {
|
|
2204
2251
|
name: componentPrefix + "-row-value",
|
|
2205
|
-
displayName: "CMS
|
|
2252
|
+
displayName: "CMS Entry Value",
|
|
2206
2253
|
importName: "CmsRowValue",
|
|
2207
2254
|
importPath: modulePath,
|
|
2208
2255
|
props: {
|