@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
package/dist/plasmic-cms.esm.js
CHANGED
|
@@ -1448,15 +1448,6 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1448
1448
|
config = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1449
1449
|
|
|
1450
1450
|
config.host = config.host || defaultHost;
|
|
1451
|
-
|
|
1452
|
-
if (!config.databaseId) {
|
|
1453
|
-
throw new Error("You must specify the CMS database ID to use.");
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
if (!config.databaseToken) {
|
|
1457
|
-
throw new Error("You must specify the token of the CMS database you are using.");
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
1451
|
return React.createElement(DatabaseProvider, {
|
|
1461
1452
|
config: config
|
|
1462
1453
|
}, React.createElement(TablesFetcher, null, children));
|
|
@@ -1474,9 +1465,21 @@ function TablesFetcher(_ref2) {
|
|
|
1474
1465
|
while (1) {
|
|
1475
1466
|
switch (_context.prev = _context.next) {
|
|
1476
1467
|
case 0:
|
|
1477
|
-
|
|
1468
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1469
|
+
_context.next = 2;
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1478
1472
|
|
|
1479
|
-
|
|
1473
|
+
return _context.abrupt("return", []);
|
|
1474
|
+
|
|
1475
|
+
case 2:
|
|
1476
|
+
_context.next = 4;
|
|
1477
|
+
return mkApi(databaseConfig).fetchTables();
|
|
1478
|
+
|
|
1479
|
+
case 4:
|
|
1480
|
+
return _context.abrupt("return", _context.sent);
|
|
1481
|
+
|
|
1482
|
+
case 5:
|
|
1480
1483
|
case "end":
|
|
1481
1484
|
return _context.stop();
|
|
1482
1485
|
}
|
|
@@ -1494,7 +1497,7 @@ function TablesFetcher(_ref2) {
|
|
|
1494
1497
|
|
|
1495
1498
|
var cmsQueryLoaderMeta = {
|
|
1496
1499
|
name: componentPrefix + "-query-loader",
|
|
1497
|
-
displayName: "CMS
|
|
1500
|
+
displayName: "CMS Data Loader",
|
|
1498
1501
|
importName: "CmsQueryLoader",
|
|
1499
1502
|
importPath: modulePath,
|
|
1500
1503
|
props: {
|
|
@@ -1547,6 +1550,11 @@ var cmsQueryLoaderMeta = {
|
|
|
1547
1550
|
}
|
|
1548
1551
|
}
|
|
1549
1552
|
};
|
|
1553
|
+
|
|
1554
|
+
function isDatabaseConfigured(config) {
|
|
1555
|
+
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1550
1558
|
function CmsQueryLoader(_ref5) {
|
|
1551
1559
|
var table = _ref5.table,
|
|
1552
1560
|
children = _ref5.children,
|
|
@@ -1584,27 +1592,35 @@ function CmsQueryLoader(_ref5) {
|
|
|
1584
1592
|
while (1) {
|
|
1585
1593
|
switch (_context2.prev = _context2.next) {
|
|
1586
1594
|
case 0:
|
|
1595
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1596
|
+
_context2.next = 2;
|
|
1597
|
+
break;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
throw new Error("You must specify the CMS ID and API key");
|
|
1601
|
+
|
|
1602
|
+
case 2:
|
|
1587
1603
|
if (table) {
|
|
1588
|
-
_context2.next =
|
|
1604
|
+
_context2.next = 6;
|
|
1589
1605
|
break;
|
|
1590
1606
|
}
|
|
1591
1607
|
|
|
1592
|
-
throw new Error("You must select a
|
|
1608
|
+
throw new Error("You must select a model to query");
|
|
1593
1609
|
|
|
1594
|
-
case
|
|
1610
|
+
case 6:
|
|
1595
1611
|
if (!(tables && !tables.find(function (t) {
|
|
1596
1612
|
return t.identifier === table;
|
|
1597
1613
|
}))) {
|
|
1598
|
-
_context2.next =
|
|
1614
|
+
_context2.next = 8;
|
|
1599
1615
|
break;
|
|
1600
1616
|
}
|
|
1601
1617
|
|
|
1602
|
-
throw new Error("There is no
|
|
1618
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1603
1619
|
|
|
1604
|
-
case
|
|
1620
|
+
case 8:
|
|
1605
1621
|
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1606
1622
|
|
|
1607
|
-
case
|
|
1623
|
+
case 9:
|
|
1608
1624
|
case "end":
|
|
1609
1625
|
return _context2.stop();
|
|
1610
1626
|
}
|
|
@@ -1622,7 +1638,7 @@ function CmsQueryLoader(_ref5) {
|
|
|
1622
1638
|
}
|
|
1623
1639
|
var cmsRowRepeaterMeta = {
|
|
1624
1640
|
name: componentPrefix + "-row-repeater",
|
|
1625
|
-
displayName: "CMS
|
|
1641
|
+
displayName: "CMS Entry Repeater",
|
|
1626
1642
|
importName: "CmsRowRepeater",
|
|
1627
1643
|
importPath: modulePath,
|
|
1628
1644
|
props: {
|
|
@@ -1670,7 +1686,7 @@ function CmsRowRepeater(_ref7) {
|
|
|
1670
1686
|
}
|
|
1671
1687
|
var cmsQueryRepeaterMeta = {
|
|
1672
1688
|
name: componentPrefix + "-query-repeater",
|
|
1673
|
-
displayName: "CMS
|
|
1689
|
+
displayName: "CMS Data Loader",
|
|
1674
1690
|
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1675
1691
|
importName: "CmsQueryRepeater",
|
|
1676
1692
|
importPath: modulePath,
|
|
@@ -1678,8 +1694,11 @@ var cmsQueryRepeaterMeta = {
|
|
|
1678
1694
|
children: {
|
|
1679
1695
|
type: "slot",
|
|
1680
1696
|
defaultValue: {
|
|
1681
|
-
type: "
|
|
1682
|
-
|
|
1697
|
+
type: "vbox",
|
|
1698
|
+
children: [{
|
|
1699
|
+
type: "component",
|
|
1700
|
+
name: componentPrefix + "-row-field"
|
|
1701
|
+
}]
|
|
1683
1702
|
}
|
|
1684
1703
|
},
|
|
1685
1704
|
table: {
|
|
@@ -1699,7 +1718,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1699
1718
|
where: {
|
|
1700
1719
|
type: "object",
|
|
1701
1720
|
displayName: "Filter",
|
|
1702
|
-
description: "Filter clause, in JSON format."
|
|
1721
|
+
description: "Filter clause, in JSON format.",
|
|
1722
|
+
hidden: function hidden() {
|
|
1723
|
+
return true;
|
|
1724
|
+
}
|
|
1703
1725
|
},
|
|
1704
1726
|
orderBy: {
|
|
1705
1727
|
type: "choice",
|
|
@@ -1756,32 +1778,45 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1756
1778
|
databaseConfig: databaseConfig,
|
|
1757
1779
|
params: params
|
|
1758
1780
|
});
|
|
1781
|
+
|
|
1782
|
+
if (!table && tables && tables.length > 0) {
|
|
1783
|
+
table = tables[0].identifier;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1759
1786
|
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1760
1787
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1761
1788
|
while (1) {
|
|
1762
1789
|
switch (_context3.prev = _context3.next) {
|
|
1763
1790
|
case 0:
|
|
1791
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1792
|
+
_context3.next = 2;
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
throw new Error("You must specify a CMS ID and API key");
|
|
1797
|
+
|
|
1798
|
+
case 2:
|
|
1764
1799
|
if (table) {
|
|
1765
|
-
_context3.next =
|
|
1800
|
+
_context3.next = 6;
|
|
1766
1801
|
break;
|
|
1767
1802
|
}
|
|
1768
1803
|
|
|
1769
|
-
throw new Error("You must select a
|
|
1804
|
+
throw new Error("You must select a model to query");
|
|
1770
1805
|
|
|
1771
|
-
case
|
|
1806
|
+
case 6:
|
|
1772
1807
|
if (!(tables && !tables.find(function (t) {
|
|
1773
1808
|
return t.identifier === table;
|
|
1774
1809
|
}))) {
|
|
1775
|
-
_context3.next =
|
|
1810
|
+
_context3.next = 10;
|
|
1776
1811
|
break;
|
|
1777
1812
|
}
|
|
1778
1813
|
|
|
1779
|
-
throw new Error("There is no
|
|
1814
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1780
1815
|
|
|
1781
|
-
case
|
|
1816
|
+
case 10:
|
|
1782
1817
|
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1783
1818
|
|
|
1784
|
-
case
|
|
1819
|
+
case 11:
|
|
1785
1820
|
case "end":
|
|
1786
1821
|
return _context3.stop();
|
|
1787
1822
|
}
|
|
@@ -1789,6 +1824,10 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1789
1824
|
}, _callee3);
|
|
1790
1825
|
})));
|
|
1791
1826
|
return renderMaybeData(maybeData, function (rows) {
|
|
1827
|
+
if (rows.length === 0) {
|
|
1828
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1792
1831
|
return React.createElement(QueryResultProvider, {
|
|
1793
1832
|
table: table,
|
|
1794
1833
|
rows: rows
|
|
@@ -1804,7 +1843,7 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1804
1843
|
}
|
|
1805
1844
|
var cmsRowFieldMeta = {
|
|
1806
1845
|
name: componentPrefix + "-row-field",
|
|
1807
|
-
displayName: "CMS
|
|
1846
|
+
displayName: "CMS Entry Field",
|
|
1808
1847
|
importName: "CmsRowField",
|
|
1809
1848
|
importPath: modulePath,
|
|
1810
1849
|
props: {
|
|
@@ -1824,7 +1863,7 @@ var cmsRowFieldMeta = {
|
|
|
1824
1863
|
var _ctx$table;
|
|
1825
1864
|
|
|
1826
1865
|
var table = _ref11.table;
|
|
1827
|
-
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"]);
|
|
1866
|
+
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"]);
|
|
1828
1867
|
}
|
|
1829
1868
|
},
|
|
1830
1869
|
dateFormat: {
|
|
@@ -1913,8 +1952,16 @@ function CmsRowField(_ref13) {
|
|
|
1913
1952
|
var tables = useTables();
|
|
1914
1953
|
var res = useRow(table);
|
|
1915
1954
|
|
|
1916
|
-
if (!res
|
|
1917
|
-
return React.createElement("div",
|
|
1955
|
+
if (!res) {
|
|
1956
|
+
return React.createElement("div", {
|
|
1957
|
+
className: className
|
|
1958
|
+
}, "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
if (!res.row) {
|
|
1962
|
+
return React.createElement("div", {
|
|
1963
|
+
className: className
|
|
1964
|
+
}, "Error: No CMS Entry found");
|
|
1918
1965
|
}
|
|
1919
1966
|
|
|
1920
1967
|
if (tables) {
|
|
@@ -1930,11 +1977,11 @@ function CmsRowField(_ref13) {
|
|
|
1930
1977
|
table: res.table,
|
|
1931
1978
|
tables: tables,
|
|
1932
1979
|
field: field,
|
|
1933
|
-
typeFilters: ["text"]
|
|
1980
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1934
1981
|
});
|
|
1935
1982
|
|
|
1936
1983
|
if (!fieldMeta) {
|
|
1937
|
-
|
|
1984
|
+
throw new Error("Please select an entry field to display.");
|
|
1938
1985
|
}
|
|
1939
1986
|
|
|
1940
1987
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
@@ -2009,7 +2056,7 @@ function renderValue(value, type, props) {
|
|
|
2009
2056
|
|
|
2010
2057
|
var cmsRowLinkMeta = {
|
|
2011
2058
|
name: componentPrefix + "-row-link",
|
|
2012
|
-
displayName: "CMS
|
|
2059
|
+
displayName: "CMS Entry Link",
|
|
2013
2060
|
importName: "CmsRowLink",
|
|
2014
2061
|
importPath: modulePath,
|
|
2015
2062
|
props: {
|
|
@@ -2100,7 +2147,7 @@ function CmsRowLink(_ref15) {
|
|
|
2100
2147
|
}
|
|
2101
2148
|
var cmsRowImageMeta = {
|
|
2102
2149
|
name: componentPrefix + "-row-image",
|
|
2103
|
-
displayName: "CMS
|
|
2150
|
+
displayName: "CMS Entry Image",
|
|
2104
2151
|
importName: "CmsRowImage",
|
|
2105
2152
|
importPath: modulePath,
|
|
2106
2153
|
props: {
|
|
@@ -2196,7 +2243,7 @@ function CmsRowImage(_ref17) {
|
|
|
2196
2243
|
}
|
|
2197
2244
|
var cmsRowFieldValueMeta = {
|
|
2198
2245
|
name: componentPrefix + "-row-value",
|
|
2199
|
-
displayName: "CMS
|
|
2246
|
+
displayName: "CMS Entry Value",
|
|
2200
2247
|
importName: "CmsRowValue",
|
|
2201
2248
|
importPath: modulePath,
|
|
2202
2249
|
props: {
|