@plasmicpkgs/plasmic-cms 0.0.31 → 0.0.37
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/components.d.ts +11 -3
- package/dist/index.d.ts +1 -1
- package/dist/plasmic-cms.cjs.development.js +360 -89
- 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 +359 -90
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +4 -3
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
-
var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
|
|
8
7
|
var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
|
|
8
|
+
var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
|
|
9
9
|
var host = require('@plasmicapp/host');
|
|
10
10
|
var query = require('@plasmicapp/query');
|
|
11
|
+
var dayjs = _interopDefault(require('dayjs'));
|
|
11
12
|
var React = _interopDefault(require('react'));
|
|
12
13
|
|
|
13
14
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1353,13 +1354,13 @@ function mkTableOptions(tables) {
|
|
|
1353
1354
|
};
|
|
1354
1355
|
});
|
|
1355
1356
|
}
|
|
1356
|
-
function mkFieldOptions(tables,
|
|
1357
|
+
function mkFieldOptions(tables, tableIdentifier, types) {
|
|
1357
1358
|
if (!tables) {
|
|
1358
1359
|
return [];
|
|
1359
1360
|
}
|
|
1360
1361
|
|
|
1361
1362
|
var table = tables.find(function (t) {
|
|
1362
|
-
return t.identifier ===
|
|
1363
|
+
return t.identifier === tableIdentifier;
|
|
1363
1364
|
});
|
|
1364
1365
|
|
|
1365
1366
|
if (!table) {
|
|
@@ -1383,7 +1384,8 @@ function mkFieldOptions(tables, tableId, types) {
|
|
|
1383
1384
|
}
|
|
1384
1385
|
|
|
1385
1386
|
var _excluded = ["children"],
|
|
1386
|
-
_excluded2 = ["className", "table", "field", "setControlContextData"]
|
|
1387
|
+
_excluded2 = ["className", "table", "field", "dateFormat", "setControlContextData"],
|
|
1388
|
+
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1387
1389
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1388
1390
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1389
1391
|
var fetcherComponentPropMetas = {
|
|
@@ -1452,15 +1454,6 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1452
1454
|
config = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1453
1455
|
|
|
1454
1456
|
config.host = config.host || defaultHost;
|
|
1455
|
-
|
|
1456
|
-
if (!config.databaseId) {
|
|
1457
|
-
throw new Error("You must specify the CMS database ID to use.");
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
if (!config.databaseToken) {
|
|
1461
|
-
throw new Error("You must specify the token of the CMS database you are using.");
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
1457
|
return React.createElement(DatabaseProvider, {
|
|
1465
1458
|
config: config
|
|
1466
1459
|
}, React.createElement(TablesFetcher, null, children));
|
|
@@ -1478,9 +1471,21 @@ function TablesFetcher(_ref2) {
|
|
|
1478
1471
|
while (1) {
|
|
1479
1472
|
switch (_context.prev = _context.next) {
|
|
1480
1473
|
case 0:
|
|
1481
|
-
|
|
1474
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1475
|
+
_context.next = 2;
|
|
1476
|
+
break;
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
return _context.abrupt("return", []);
|
|
1482
1480
|
|
|
1483
|
-
case
|
|
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:
|
|
1484
1489
|
case "end":
|
|
1485
1490
|
return _context.stop();
|
|
1486
1491
|
}
|
|
@@ -1498,7 +1503,7 @@ function TablesFetcher(_ref2) {
|
|
|
1498
1503
|
|
|
1499
1504
|
var cmsQueryLoaderMeta = {
|
|
1500
1505
|
name: componentPrefix + "-query-loader",
|
|
1501
|
-
displayName: "CMS
|
|
1506
|
+
displayName: "CMS Data Loader",
|
|
1502
1507
|
importName: "CmsQueryLoader",
|
|
1503
1508
|
importPath: modulePath,
|
|
1504
1509
|
props: {
|
|
@@ -1551,6 +1556,11 @@ var cmsQueryLoaderMeta = {
|
|
|
1551
1556
|
}
|
|
1552
1557
|
}
|
|
1553
1558
|
};
|
|
1559
|
+
|
|
1560
|
+
function isDatabaseConfigured(config) {
|
|
1561
|
+
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1554
1564
|
function CmsQueryLoader(_ref5) {
|
|
1555
1565
|
var table = _ref5.table,
|
|
1556
1566
|
children = _ref5.children,
|
|
@@ -1588,27 +1598,35 @@ function CmsQueryLoader(_ref5) {
|
|
|
1588
1598
|
while (1) {
|
|
1589
1599
|
switch (_context2.prev = _context2.next) {
|
|
1590
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:
|
|
1591
1609
|
if (table) {
|
|
1592
|
-
_context2.next =
|
|
1610
|
+
_context2.next = 6;
|
|
1593
1611
|
break;
|
|
1594
1612
|
}
|
|
1595
1613
|
|
|
1596
|
-
throw new Error("You must select a
|
|
1614
|
+
throw new Error("You must select a model to query");
|
|
1597
1615
|
|
|
1598
|
-
case
|
|
1616
|
+
case 6:
|
|
1599
1617
|
if (!(tables && !tables.find(function (t) {
|
|
1600
1618
|
return t.identifier === table;
|
|
1601
1619
|
}))) {
|
|
1602
|
-
_context2.next =
|
|
1620
|
+
_context2.next = 8;
|
|
1603
1621
|
break;
|
|
1604
1622
|
}
|
|
1605
1623
|
|
|
1606
|
-
throw new Error("There is no
|
|
1624
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1607
1625
|
|
|
1608
|
-
case
|
|
1626
|
+
case 8:
|
|
1609
1627
|
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1610
1628
|
|
|
1611
|
-
case
|
|
1629
|
+
case 9:
|
|
1612
1630
|
case "end":
|
|
1613
1631
|
return _context2.stop();
|
|
1614
1632
|
}
|
|
@@ -1626,7 +1644,7 @@ function CmsQueryLoader(_ref5) {
|
|
|
1626
1644
|
}
|
|
1627
1645
|
var cmsRowRepeaterMeta = {
|
|
1628
1646
|
name: componentPrefix + "-row-repeater",
|
|
1629
|
-
displayName: "CMS
|
|
1647
|
+
displayName: "CMS Entry Repeater",
|
|
1630
1648
|
importName: "CmsRowRepeater",
|
|
1631
1649
|
importPath: modulePath,
|
|
1632
1650
|
props: {
|
|
@@ -1672,9 +1690,169 @@ function CmsRowRepeater(_ref7) {
|
|
|
1672
1690
|
}, host.repeatedElement(index === 0, children));
|
|
1673
1691
|
}));
|
|
1674
1692
|
}
|
|
1693
|
+
var cmsQueryRepeaterMeta = {
|
|
1694
|
+
name: componentPrefix + "-query-repeater",
|
|
1695
|
+
displayName: "CMS Data Loader",
|
|
1696
|
+
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1697
|
+
importName: "CmsQueryRepeater",
|
|
1698
|
+
importPath: modulePath,
|
|
1699
|
+
props: {
|
|
1700
|
+
children: {
|
|
1701
|
+
type: "slot",
|
|
1702
|
+
defaultValue: {
|
|
1703
|
+
type: "vbox",
|
|
1704
|
+
children: [{
|
|
1705
|
+
type: "component",
|
|
1706
|
+
name: componentPrefix + "-row-field"
|
|
1707
|
+
}]
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
table: {
|
|
1711
|
+
type: "choice",
|
|
1712
|
+
displayName: "Model",
|
|
1713
|
+
description: "CMS model (table) to query.",
|
|
1714
|
+
options: function options(_, ctx) {
|
|
1715
|
+
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1716
|
+
}
|
|
1717
|
+
},
|
|
1718
|
+
useDraft: {
|
|
1719
|
+
type: "boolean",
|
|
1720
|
+
displayName: "Use drafts?",
|
|
1721
|
+
description: "If set, also query unpublished content.",
|
|
1722
|
+
defaultValue: false
|
|
1723
|
+
},
|
|
1724
|
+
where: {
|
|
1725
|
+
type: "object",
|
|
1726
|
+
displayName: "Filter",
|
|
1727
|
+
description: "Filter clause, in JSON format.",
|
|
1728
|
+
hidden: function hidden() {
|
|
1729
|
+
return true;
|
|
1730
|
+
}
|
|
1731
|
+
},
|
|
1732
|
+
orderBy: {
|
|
1733
|
+
type: "choice",
|
|
1734
|
+
displayName: "Order by",
|
|
1735
|
+
description: "Field to order by.",
|
|
1736
|
+
options: function options(_ref8, ctx) {
|
|
1737
|
+
var table = _ref8.table;
|
|
1738
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, table);
|
|
1739
|
+
}
|
|
1740
|
+
},
|
|
1741
|
+
desc: {
|
|
1742
|
+
type: "boolean",
|
|
1743
|
+
displayName: "Sort descending?",
|
|
1744
|
+
description: 'Sort descending by "Order by" field.',
|
|
1745
|
+
defaultValue: false
|
|
1746
|
+
},
|
|
1747
|
+
limit: {
|
|
1748
|
+
type: "number",
|
|
1749
|
+
displayName: "Limit",
|
|
1750
|
+
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1751
|
+
defaultValue: 0
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
function CmsQueryRepeater(_ref9) {
|
|
1756
|
+
var table = _ref9.table,
|
|
1757
|
+
children = _ref9.children,
|
|
1758
|
+
setControlContextData = _ref9.setControlContextData,
|
|
1759
|
+
where = _ref9.where,
|
|
1760
|
+
useDraft = _ref9.useDraft,
|
|
1761
|
+
orderBy = _ref9.orderBy,
|
|
1762
|
+
desc = _ref9.desc,
|
|
1763
|
+
limit = _ref9.limit;
|
|
1764
|
+
var databaseConfig = useDatabase();
|
|
1765
|
+
var tables = useTables();
|
|
1766
|
+
|
|
1767
|
+
if (tables) {
|
|
1768
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1769
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1770
|
+
tables: tables
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
var params = {
|
|
1775
|
+
where: where,
|
|
1776
|
+
useDraft: useDraft,
|
|
1777
|
+
orderBy: orderBy,
|
|
1778
|
+
desc: desc,
|
|
1779
|
+
limit: limit
|
|
1780
|
+
};
|
|
1781
|
+
var cacheKey = JSON.stringify({
|
|
1782
|
+
component: "CmsQueryLoader",
|
|
1783
|
+
table: table,
|
|
1784
|
+
databaseConfig: databaseConfig,
|
|
1785
|
+
params: params
|
|
1786
|
+
});
|
|
1787
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1788
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1789
|
+
while (1) {
|
|
1790
|
+
switch (_context3.prev = _context3.next) {
|
|
1791
|
+
case 0:
|
|
1792
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1793
|
+
_context3.next = 2;
|
|
1794
|
+
break;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
throw new Error("You must specify a CMS ID and API key");
|
|
1798
|
+
|
|
1799
|
+
case 2:
|
|
1800
|
+
if (table) {
|
|
1801
|
+
_context3.next = 6;
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
if (!(!tables || tables.length === 0)) {
|
|
1806
|
+
_context3.next = 5;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
throw new Error("You must select a model to query");
|
|
1811
|
+
|
|
1812
|
+
case 5:
|
|
1813
|
+
table = tables[0].identifier;
|
|
1814
|
+
|
|
1815
|
+
case 6:
|
|
1816
|
+
if (!(tables && !tables.find(function (t) {
|
|
1817
|
+
return t.identifier === table;
|
|
1818
|
+
}))) {
|
|
1819
|
+
_context3.next = 8;
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1824
|
+
|
|
1825
|
+
case 8:
|
|
1826
|
+
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1827
|
+
|
|
1828
|
+
case 9:
|
|
1829
|
+
case "end":
|
|
1830
|
+
return _context3.stop();
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}, _callee3);
|
|
1834
|
+
})));
|
|
1835
|
+
return renderMaybeData(maybeData, function (rows) {
|
|
1836
|
+
if (rows.length === 0) {
|
|
1837
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
return React.createElement(QueryResultProvider, {
|
|
1841
|
+
table: table,
|
|
1842
|
+
rows: rows
|
|
1843
|
+
}, rows.map(function (row, index) {
|
|
1844
|
+
return React.createElement(RowProvider, {
|
|
1845
|
+
table: table,
|
|
1846
|
+
row: row
|
|
1847
|
+
}, host.repeatedElement(index === 0, children));
|
|
1848
|
+
}));
|
|
1849
|
+
}, {
|
|
1850
|
+
hideIfNotFound: false
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1675
1853
|
var cmsRowFieldMeta = {
|
|
1676
1854
|
name: componentPrefix + "-row-field",
|
|
1677
|
-
displayName: "CMS
|
|
1855
|
+
displayName: "CMS Entry Field",
|
|
1678
1856
|
importName: "CmsRowField",
|
|
1679
1857
|
importPath: modulePath,
|
|
1680
1858
|
props: {
|
|
@@ -1690,36 +1868,117 @@ var cmsRowFieldMeta = {
|
|
|
1690
1868
|
type: "choice",
|
|
1691
1869
|
displayName: "Field",
|
|
1692
1870
|
description: "Field (from model schema) to use.",
|
|
1693
|
-
options: function options(
|
|
1871
|
+
options: function options(_ref11, ctx) {
|
|
1694
1872
|
var _ctx$table;
|
|
1695
1873
|
|
|
1696
|
-
var table =
|
|
1697
|
-
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"]);
|
|
1874
|
+
var table = _ref11.table;
|
|
1875
|
+
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"]);
|
|
1698
1876
|
}
|
|
1877
|
+
},
|
|
1878
|
+
dateFormat: {
|
|
1879
|
+
type: "choice",
|
|
1880
|
+
displayName: "Date Format",
|
|
1881
|
+
hidden: function hidden(_ref12, ctx) {
|
|
1882
|
+
var field = _ref12.field;
|
|
1883
|
+
|
|
1884
|
+
if (!ctx) {
|
|
1885
|
+
return true;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
var tableIdentifier = ctx.table,
|
|
1889
|
+
tables = ctx.tables;
|
|
1890
|
+
var table = tables == null ? void 0 : tables.find(function (t) {
|
|
1891
|
+
return t.identifier === tableIdentifier;
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1894
|
+
if (!table) {
|
|
1895
|
+
return true;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
var fieldMeta = table.schema.fields.find(function (f) {
|
|
1899
|
+
return f.identifier === field;
|
|
1900
|
+
});
|
|
1901
|
+
|
|
1902
|
+
if (!fieldMeta) {
|
|
1903
|
+
return true;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
return fieldMeta.type !== "date-time";
|
|
1907
|
+
},
|
|
1908
|
+
options: [{
|
|
1909
|
+
label: "July 26, 2014",
|
|
1910
|
+
value: "MMMM D, YYYY"
|
|
1911
|
+
}, {
|
|
1912
|
+
label: "July 26, 2014 10:02 PM",
|
|
1913
|
+
value: "MMMM D, YYYY h:mm A"
|
|
1914
|
+
}, {
|
|
1915
|
+
label: "Jul 26, 2014",
|
|
1916
|
+
value: "MMM D, YYYY"
|
|
1917
|
+
}, {
|
|
1918
|
+
label: "Jul 26, 2014 10:02 PM",
|
|
1919
|
+
value: "MMM D, YYYY h:mm A"
|
|
1920
|
+
}, {
|
|
1921
|
+
label: "Saturday, July 26, 2014",
|
|
1922
|
+
value: "dddd, MMMM D, YYYY"
|
|
1923
|
+
}, {
|
|
1924
|
+
label: "7/26/2014",
|
|
1925
|
+
value: "M/D/YYYY"
|
|
1926
|
+
}, {
|
|
1927
|
+
label: "7/26/2014 10:02 PM",
|
|
1928
|
+
value: "M/D/YYYY h:mm A"
|
|
1929
|
+
}, {
|
|
1930
|
+
label: "26/7/2014",
|
|
1931
|
+
value: "D/M/YYYY"
|
|
1932
|
+
}, {
|
|
1933
|
+
label: "26/7/2014 10:02 PM",
|
|
1934
|
+
value: "D/M/YYYY h:mm A"
|
|
1935
|
+
}, {
|
|
1936
|
+
label: "7/26/14",
|
|
1937
|
+
value: "M/D/YY"
|
|
1938
|
+
}, {
|
|
1939
|
+
label: "7/26/14 10:02 PM",
|
|
1940
|
+
value: "M/D/YY h:mm A"
|
|
1941
|
+
}, {
|
|
1942
|
+
label: "26/7/14",
|
|
1943
|
+
value: "D/M/YY"
|
|
1944
|
+
}, {
|
|
1945
|
+
label: "26/7/14 10:02 PM",
|
|
1946
|
+
value: "D/M/YY h:mm A"
|
|
1947
|
+
}]
|
|
1699
1948
|
}
|
|
1700
1949
|
}
|
|
1701
1950
|
};
|
|
1702
|
-
function CmsRowField(
|
|
1951
|
+
function CmsRowField(_ref13) {
|
|
1703
1952
|
var _res$row$data;
|
|
1704
1953
|
|
|
1705
|
-
var className =
|
|
1706
|
-
table =
|
|
1707
|
-
field =
|
|
1708
|
-
|
|
1709
|
-
|
|
1954
|
+
var className = _ref13.className,
|
|
1955
|
+
table = _ref13.table,
|
|
1956
|
+
field = _ref13.field,
|
|
1957
|
+
dateFormat = _ref13.dateFormat,
|
|
1958
|
+
setControlContextData = _ref13.setControlContextData,
|
|
1959
|
+
rest = _objectWithoutPropertiesLoose(_ref13, _excluded2);
|
|
1710
1960
|
|
|
1711
1961
|
var tables = useTables();
|
|
1712
1962
|
var res = useRow(table);
|
|
1713
1963
|
|
|
1714
|
-
if (!res
|
|
1715
|
-
return React.createElement("div",
|
|
1964
|
+
if (!res) {
|
|
1965
|
+
return React.createElement("div", {
|
|
1966
|
+
className: className
|
|
1967
|
+
}, "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
if (!res.row) {
|
|
1971
|
+
return React.createElement("div", {
|
|
1972
|
+
className: className
|
|
1973
|
+
}, "Error: No CMS Entry found");
|
|
1716
1974
|
}
|
|
1717
1975
|
|
|
1718
1976
|
if (tables) {
|
|
1719
1977
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1720
1978
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1721
1979
|
tables: tables,
|
|
1722
|
-
table: res.table
|
|
1980
|
+
table: res.table,
|
|
1981
|
+
row: res.row
|
|
1723
1982
|
});
|
|
1724
1983
|
}
|
|
1725
1984
|
|
|
@@ -1727,14 +1986,23 @@ function CmsRowField(_ref9) {
|
|
|
1727
1986
|
table: res.table,
|
|
1728
1987
|
tables: tables,
|
|
1729
1988
|
field: field,
|
|
1730
|
-
typeFilters: ["text"]
|
|
1989
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1731
1990
|
});
|
|
1732
1991
|
|
|
1733
1992
|
if (!fieldMeta) {
|
|
1734
|
-
|
|
1993
|
+
throw new Error("Please select an entry field to display.");
|
|
1735
1994
|
}
|
|
1736
1995
|
|
|
1737
1996
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
1997
|
+
|
|
1998
|
+
if (!data) {
|
|
1999
|
+
return null;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
2003
|
+
data = dayjs(data).format(dateFormat);
|
|
2004
|
+
}
|
|
2005
|
+
|
|
1738
2006
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
1739
2007
|
className: className
|
|
1740
2008
|
}, rest)) : null;
|
|
@@ -1797,7 +2065,7 @@ function renderValue(value, type, props) {
|
|
|
1797
2065
|
|
|
1798
2066
|
var cmsRowLinkMeta = {
|
|
1799
2067
|
name: componentPrefix + "-row-link",
|
|
1800
|
-
displayName: "CMS
|
|
2068
|
+
displayName: "CMS Entry Link",
|
|
1801
2069
|
importName: "CmsRowLink",
|
|
1802
2070
|
importPath: modulePath,
|
|
1803
2071
|
props: {
|
|
@@ -1821,10 +2089,10 @@ var cmsRowLinkMeta = {
|
|
|
1821
2089
|
type: "choice",
|
|
1822
2090
|
displayName: "Field",
|
|
1823
2091
|
description: "Field (from model schema) to use.",
|
|
1824
|
-
options: function options(
|
|
2092
|
+
options: function options(_ref14, ctx) {
|
|
1825
2093
|
var _ctx$table2;
|
|
1826
2094
|
|
|
1827
|
-
var table =
|
|
2095
|
+
var table = _ref14.table;
|
|
1828
2096
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
1829
2097
|
}
|
|
1830
2098
|
},
|
|
@@ -1836,14 +2104,14 @@ var cmsRowLinkMeta = {
|
|
|
1836
2104
|
}
|
|
1837
2105
|
}
|
|
1838
2106
|
};
|
|
1839
|
-
function CmsRowLink(
|
|
2107
|
+
function CmsRowLink(_ref15) {
|
|
1840
2108
|
var _res$row$data2;
|
|
1841
2109
|
|
|
1842
|
-
var table =
|
|
1843
|
-
field =
|
|
1844
|
-
hrefProp =
|
|
1845
|
-
children =
|
|
1846
|
-
setControlContextData =
|
|
2110
|
+
var table = _ref15.table,
|
|
2111
|
+
field = _ref15.field,
|
|
2112
|
+
hrefProp = _ref15.hrefProp,
|
|
2113
|
+
children = _ref15.children,
|
|
2114
|
+
setControlContextData = _ref15.setControlContextData;
|
|
1847
2115
|
var tables = useTables();
|
|
1848
2116
|
var res = useRow(table);
|
|
1849
2117
|
|
|
@@ -1888,7 +2156,7 @@ function CmsRowLink(_ref11) {
|
|
|
1888
2156
|
}
|
|
1889
2157
|
var cmsRowImageMeta = {
|
|
1890
2158
|
name: componentPrefix + "-row-image",
|
|
1891
|
-
displayName: "CMS
|
|
2159
|
+
displayName: "CMS Entry Image",
|
|
1892
2160
|
importName: "CmsRowImage",
|
|
1893
2161
|
importPath: modulePath,
|
|
1894
2162
|
props: {
|
|
@@ -1911,10 +2179,10 @@ var cmsRowImageMeta = {
|
|
|
1911
2179
|
type: "choice",
|
|
1912
2180
|
displayName: "Field",
|
|
1913
2181
|
description: "Field (from model schema) to use.",
|
|
1914
|
-
options: function options(
|
|
2182
|
+
options: function options(_ref16, ctx) {
|
|
1915
2183
|
var _ctx$table3;
|
|
1916
2184
|
|
|
1917
|
-
var table =
|
|
2185
|
+
var table = _ref16.table;
|
|
1918
2186
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1919
2187
|
}
|
|
1920
2188
|
},
|
|
@@ -1926,14 +2194,14 @@ var cmsRowImageMeta = {
|
|
|
1926
2194
|
}
|
|
1927
2195
|
}
|
|
1928
2196
|
};
|
|
1929
|
-
function CmsRowImage(
|
|
2197
|
+
function CmsRowImage(_ref17) {
|
|
1930
2198
|
var _res$row$data3;
|
|
1931
2199
|
|
|
1932
|
-
var table =
|
|
1933
|
-
field =
|
|
1934
|
-
srcProp =
|
|
1935
|
-
children =
|
|
1936
|
-
setControlContextData =
|
|
2200
|
+
var table = _ref17.table,
|
|
2201
|
+
field = _ref17.field,
|
|
2202
|
+
srcProp = _ref17.srcProp,
|
|
2203
|
+
children = _ref17.children,
|
|
2204
|
+
setControlContextData = _ref17.setControlContextData;
|
|
1937
2205
|
var tables = useTables();
|
|
1938
2206
|
var res = useRow(table);
|
|
1939
2207
|
|
|
@@ -1984,7 +2252,7 @@ function CmsRowImage(_ref13) {
|
|
|
1984
2252
|
}
|
|
1985
2253
|
var cmsRowFieldValueMeta = {
|
|
1986
2254
|
name: componentPrefix + "-row-value",
|
|
1987
|
-
displayName: "CMS
|
|
2255
|
+
displayName: "CMS Entry Value",
|
|
1988
2256
|
importName: "CmsRowValue",
|
|
1989
2257
|
importPath: modulePath,
|
|
1990
2258
|
props: {
|
|
@@ -2003,10 +2271,10 @@ var cmsRowFieldValueMeta = {
|
|
|
2003
2271
|
type: "choice",
|
|
2004
2272
|
displayName: "Field",
|
|
2005
2273
|
description: "Field (from model schema) to use.",
|
|
2006
|
-
options: function options(
|
|
2274
|
+
options: function options(_ref18, ctx) {
|
|
2007
2275
|
var _ctx$table4;
|
|
2008
2276
|
|
|
2009
|
-
var table =
|
|
2277
|
+
var table = _ref18.table;
|
|
2010
2278
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2011
2279
|
}
|
|
2012
2280
|
},
|
|
@@ -2018,14 +2286,16 @@ var cmsRowFieldValueMeta = {
|
|
|
2018
2286
|
}
|
|
2019
2287
|
}
|
|
2020
2288
|
};
|
|
2021
|
-
function CmsRowFieldValue(
|
|
2289
|
+
function CmsRowFieldValue(_ref19) {
|
|
2022
2290
|
var _res$row$data4;
|
|
2023
2291
|
|
|
2024
|
-
var table =
|
|
2025
|
-
field =
|
|
2026
|
-
valueProp =
|
|
2027
|
-
children =
|
|
2028
|
-
setControlContextData =
|
|
2292
|
+
var table = _ref19.table,
|
|
2293
|
+
field = _ref19.field,
|
|
2294
|
+
valueProp = _ref19.valueProp,
|
|
2295
|
+
children = _ref19.children,
|
|
2296
|
+
setControlContextData = _ref19.setControlContextData,
|
|
2297
|
+
rest = _objectWithoutPropertiesLoose(_ref19, _excluded3);
|
|
2298
|
+
|
|
2029
2299
|
var tables = useTables();
|
|
2030
2300
|
var res = useRow(table);
|
|
2031
2301
|
|
|
@@ -2055,9 +2325,9 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2055
2325
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
2056
2326
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
2057
2327
|
if (React.isValidElement(child)) {
|
|
2058
|
-
var
|
|
2328
|
+
var _extends2;
|
|
2059
2329
|
|
|
2060
|
-
return React.cloneElement(child, (
|
|
2330
|
+
return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
2061
2331
|
}
|
|
2062
2332
|
|
|
2063
2333
|
return child;
|
|
@@ -2098,13 +2368,13 @@ var cmsRowLoaderMeta = {
|
|
|
2098
2368
|
}
|
|
2099
2369
|
}, fetcherComponentPropMetas)
|
|
2100
2370
|
};
|
|
2101
|
-
function CmsRowLoader(
|
|
2102
|
-
var table =
|
|
2103
|
-
row =
|
|
2104
|
-
children =
|
|
2105
|
-
useDraft =
|
|
2106
|
-
hideIfNotFound =
|
|
2107
|
-
setControlContextData =
|
|
2371
|
+
function CmsRowLoader(_ref20) {
|
|
2372
|
+
var table = _ref20.table,
|
|
2373
|
+
row = _ref20.row,
|
|
2374
|
+
children = _ref20.children,
|
|
2375
|
+
useDraft = _ref20.useDraft,
|
|
2376
|
+
hideIfNotFound = _ref20.hideIfNotFound,
|
|
2377
|
+
setControlContextData = _ref20.setControlContextData;
|
|
2108
2378
|
var databaseConfig = useDatabase();
|
|
2109
2379
|
var tables = useTables();
|
|
2110
2380
|
|
|
@@ -2121,13 +2391,13 @@ function CmsRowLoader(_ref16) {
|
|
|
2121
2391
|
databaseConfig: databaseConfig,
|
|
2122
2392
|
useDraft: useDraft
|
|
2123
2393
|
});
|
|
2124
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2125
|
-
return runtime_1.wrap(function
|
|
2394
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2395
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2126
2396
|
while (1) {
|
|
2127
|
-
switch (
|
|
2397
|
+
switch (_context4.prev = _context4.next) {
|
|
2128
2398
|
case 0:
|
|
2129
2399
|
if (table) {
|
|
2130
|
-
|
|
2400
|
+
_context4.next = 2;
|
|
2131
2401
|
break;
|
|
2132
2402
|
}
|
|
2133
2403
|
|
|
@@ -2135,25 +2405,25 @@ function CmsRowLoader(_ref16) {
|
|
|
2135
2405
|
|
|
2136
2406
|
case 2:
|
|
2137
2407
|
if (row) {
|
|
2138
|
-
|
|
2408
|
+
_context4.next = 4;
|
|
2139
2409
|
break;
|
|
2140
2410
|
}
|
|
2141
2411
|
|
|
2142
2412
|
throw new Error("You must specify an entry name to fetch.");
|
|
2143
2413
|
|
|
2144
2414
|
case 4:
|
|
2145
|
-
|
|
2415
|
+
_context4.next = 6;
|
|
2146
2416
|
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2147
2417
|
|
|
2148
2418
|
case 6:
|
|
2149
|
-
return
|
|
2419
|
+
return _context4.abrupt("return", _context4.sent);
|
|
2150
2420
|
|
|
2151
2421
|
case 7:
|
|
2152
2422
|
case "end":
|
|
2153
|
-
return
|
|
2423
|
+
return _context4.stop();
|
|
2154
2424
|
}
|
|
2155
2425
|
}
|
|
2156
|
-
},
|
|
2426
|
+
}, _callee4);
|
|
2157
2427
|
})));
|
|
2158
2428
|
return renderMaybeData(maybeData, function (row) {
|
|
2159
2429
|
return React.createElement(RowProvider, {
|
|
@@ -2184,11 +2454,11 @@ function registerAll(loader) {
|
|
|
2184
2454
|
}
|
|
2185
2455
|
};
|
|
2186
2456
|
|
|
2187
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2457
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta); // _registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2458
|
+
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2188
2459
|
|
|
2189
|
-
_registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2190
2460
|
|
|
2191
|
-
_registerComponent(
|
|
2461
|
+
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2192
2462
|
|
|
2193
2463
|
_registerComponent(CmsRowField, cmsRowFieldMeta);
|
|
2194
2464
|
|
|
@@ -2196,13 +2466,13 @@ function registerAll(loader) {
|
|
|
2196
2466
|
|
|
2197
2467
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2198
2468
|
|
|
2199
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2469
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta); // _registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2200
2470
|
|
|
2201
|
-
_registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2202
2471
|
}
|
|
2203
2472
|
|
|
2204
2473
|
exports.CmsCredentialsProvider = CmsCredentialsProvider;
|
|
2205
2474
|
exports.CmsQueryLoader = CmsQueryLoader;
|
|
2475
|
+
exports.CmsQueryRepeater = CmsQueryRepeater;
|
|
2206
2476
|
exports.CmsRowField = CmsRowField;
|
|
2207
2477
|
exports.CmsRowFieldValue = CmsRowFieldValue;
|
|
2208
2478
|
exports.CmsRowImage = CmsRowImage;
|
|
@@ -2211,6 +2481,7 @@ exports.CmsRowLoader = CmsRowLoader;
|
|
|
2211
2481
|
exports.CmsRowRepeater = CmsRowRepeater;
|
|
2212
2482
|
exports.cmsCredentialsProviderMeta = cmsCredentialsProviderMeta;
|
|
2213
2483
|
exports.cmsQueryLoaderMeta = cmsQueryLoaderMeta;
|
|
2484
|
+
exports.cmsQueryRepeaterMeta = cmsQueryRepeaterMeta;
|
|
2214
2485
|
exports.cmsRowFieldMeta = cmsRowFieldMeta;
|
|
2215
2486
|
exports.cmsRowFieldValueMeta = cmsRowFieldValueMeta;
|
|
2216
2487
|
exports.cmsRowImageMeta = cmsRowImageMeta;
|