@plasmicpkgs/plasmic-cms 0.0.32 → 0.0.38
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 +357 -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 +356 -90
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/dist/util.d.ts +1 -1
- package/package.json +3 -2
|
@@ -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,166 @@ 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
|
+
|
|
1788
|
+
if (!table && tables && tables.length > 0) {
|
|
1789
|
+
table = tables[0].identifier;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1793
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1794
|
+
while (1) {
|
|
1795
|
+
switch (_context3.prev = _context3.next) {
|
|
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:
|
|
1805
|
+
if (table) {
|
|
1806
|
+
_context3.next = 6;
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
throw new Error("You must select a model to query");
|
|
1811
|
+
|
|
1812
|
+
case 6:
|
|
1813
|
+
if (!(tables && !tables.find(function (t) {
|
|
1814
|
+
return t.identifier === table;
|
|
1815
|
+
}))) {
|
|
1816
|
+
_context3.next = 10;
|
|
1817
|
+
break;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1821
|
+
|
|
1822
|
+
case 10:
|
|
1823
|
+
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1824
|
+
|
|
1825
|
+
case 11:
|
|
1826
|
+
case "end":
|
|
1827
|
+
return _context3.stop();
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
}, _callee3);
|
|
1831
|
+
})));
|
|
1832
|
+
return renderMaybeData(maybeData, function (rows) {
|
|
1833
|
+
if (rows.length === 0) {
|
|
1834
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
return React.createElement(QueryResultProvider, {
|
|
1838
|
+
table: table,
|
|
1839
|
+
rows: rows
|
|
1840
|
+
}, rows.map(function (row, index) {
|
|
1841
|
+
return React.createElement(RowProvider, {
|
|
1842
|
+
table: table,
|
|
1843
|
+
row: row
|
|
1844
|
+
}, host.repeatedElement(index === 0, children));
|
|
1845
|
+
}));
|
|
1846
|
+
}, {
|
|
1847
|
+
hideIfNotFound: false
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1675
1850
|
var cmsRowFieldMeta = {
|
|
1676
1851
|
name: componentPrefix + "-row-field",
|
|
1677
|
-
displayName: "CMS
|
|
1852
|
+
displayName: "CMS Entry Field",
|
|
1678
1853
|
importName: "CmsRowField",
|
|
1679
1854
|
importPath: modulePath,
|
|
1680
1855
|
props: {
|
|
@@ -1690,36 +1865,117 @@ var cmsRowFieldMeta = {
|
|
|
1690
1865
|
type: "choice",
|
|
1691
1866
|
displayName: "Field",
|
|
1692
1867
|
description: "Field (from model schema) to use.",
|
|
1693
|
-
options: function options(
|
|
1868
|
+
options: function options(_ref11, ctx) {
|
|
1694
1869
|
var _ctx$table;
|
|
1695
1870
|
|
|
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"]);
|
|
1871
|
+
var table = _ref11.table;
|
|
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"]);
|
|
1698
1873
|
}
|
|
1874
|
+
},
|
|
1875
|
+
dateFormat: {
|
|
1876
|
+
type: "choice",
|
|
1877
|
+
displayName: "Date Format",
|
|
1878
|
+
hidden: function hidden(_ref12, ctx) {
|
|
1879
|
+
var field = _ref12.field;
|
|
1880
|
+
|
|
1881
|
+
if (!ctx) {
|
|
1882
|
+
return true;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
var tableIdentifier = ctx.table,
|
|
1886
|
+
tables = ctx.tables;
|
|
1887
|
+
var table = tables == null ? void 0 : tables.find(function (t) {
|
|
1888
|
+
return t.identifier === tableIdentifier;
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
if (!table) {
|
|
1892
|
+
return true;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
var fieldMeta = table.schema.fields.find(function (f) {
|
|
1896
|
+
return f.identifier === field;
|
|
1897
|
+
});
|
|
1898
|
+
|
|
1899
|
+
if (!fieldMeta) {
|
|
1900
|
+
return true;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
return fieldMeta.type !== "date-time";
|
|
1904
|
+
},
|
|
1905
|
+
options: [{
|
|
1906
|
+
label: "July 26, 2014",
|
|
1907
|
+
value: "MMMM D, YYYY"
|
|
1908
|
+
}, {
|
|
1909
|
+
label: "July 26, 2014 10:02 PM",
|
|
1910
|
+
value: "MMMM D, YYYY h:mm A"
|
|
1911
|
+
}, {
|
|
1912
|
+
label: "Jul 26, 2014",
|
|
1913
|
+
value: "MMM D, YYYY"
|
|
1914
|
+
}, {
|
|
1915
|
+
label: "Jul 26, 2014 10:02 PM",
|
|
1916
|
+
value: "MMM D, YYYY h:mm A"
|
|
1917
|
+
}, {
|
|
1918
|
+
label: "Saturday, July 26, 2014",
|
|
1919
|
+
value: "dddd, MMMM D, YYYY"
|
|
1920
|
+
}, {
|
|
1921
|
+
label: "7/26/2014",
|
|
1922
|
+
value: "M/D/YYYY"
|
|
1923
|
+
}, {
|
|
1924
|
+
label: "7/26/2014 10:02 PM",
|
|
1925
|
+
value: "M/D/YYYY h:mm A"
|
|
1926
|
+
}, {
|
|
1927
|
+
label: "26/7/2014",
|
|
1928
|
+
value: "D/M/YYYY"
|
|
1929
|
+
}, {
|
|
1930
|
+
label: "26/7/2014 10:02 PM",
|
|
1931
|
+
value: "D/M/YYYY h:mm A"
|
|
1932
|
+
}, {
|
|
1933
|
+
label: "7/26/14",
|
|
1934
|
+
value: "M/D/YY"
|
|
1935
|
+
}, {
|
|
1936
|
+
label: "7/26/14 10:02 PM",
|
|
1937
|
+
value: "M/D/YY h:mm A"
|
|
1938
|
+
}, {
|
|
1939
|
+
label: "26/7/14",
|
|
1940
|
+
value: "D/M/YY"
|
|
1941
|
+
}, {
|
|
1942
|
+
label: "26/7/14 10:02 PM",
|
|
1943
|
+
value: "D/M/YY h:mm A"
|
|
1944
|
+
}]
|
|
1699
1945
|
}
|
|
1700
1946
|
}
|
|
1701
1947
|
};
|
|
1702
|
-
function CmsRowField(
|
|
1948
|
+
function CmsRowField(_ref13) {
|
|
1703
1949
|
var _res$row$data;
|
|
1704
1950
|
|
|
1705
|
-
var className =
|
|
1706
|
-
table =
|
|
1707
|
-
field =
|
|
1708
|
-
|
|
1709
|
-
|
|
1951
|
+
var className = _ref13.className,
|
|
1952
|
+
table = _ref13.table,
|
|
1953
|
+
field = _ref13.field,
|
|
1954
|
+
dateFormat = _ref13.dateFormat,
|
|
1955
|
+
setControlContextData = _ref13.setControlContextData,
|
|
1956
|
+
rest = _objectWithoutPropertiesLoose(_ref13, _excluded2);
|
|
1710
1957
|
|
|
1711
1958
|
var tables = useTables();
|
|
1712
1959
|
var res = useRow(table);
|
|
1713
1960
|
|
|
1714
|
-
if (!res
|
|
1715
|
-
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");
|
|
1716
1971
|
}
|
|
1717
1972
|
|
|
1718
1973
|
if (tables) {
|
|
1719
1974
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1720
1975
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1721
1976
|
tables: tables,
|
|
1722
|
-
table: res.table
|
|
1977
|
+
table: res.table,
|
|
1978
|
+
row: res.row
|
|
1723
1979
|
});
|
|
1724
1980
|
}
|
|
1725
1981
|
|
|
@@ -1727,14 +1983,23 @@ function CmsRowField(_ref9) {
|
|
|
1727
1983
|
table: res.table,
|
|
1728
1984
|
tables: tables,
|
|
1729
1985
|
field: field,
|
|
1730
|
-
typeFilters: ["text"]
|
|
1986
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1731
1987
|
});
|
|
1732
1988
|
|
|
1733
1989
|
if (!fieldMeta) {
|
|
1734
|
-
|
|
1990
|
+
throw new Error("Please select an entry field to display.");
|
|
1735
1991
|
}
|
|
1736
1992
|
|
|
1737
1993
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
1994
|
+
|
|
1995
|
+
if (!data) {
|
|
1996
|
+
return null;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
2000
|
+
data = dayjs(data).format(dateFormat);
|
|
2001
|
+
}
|
|
2002
|
+
|
|
1738
2003
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
1739
2004
|
className: className
|
|
1740
2005
|
}, rest)) : null;
|
|
@@ -1797,7 +2062,7 @@ function renderValue(value, type, props) {
|
|
|
1797
2062
|
|
|
1798
2063
|
var cmsRowLinkMeta = {
|
|
1799
2064
|
name: componentPrefix + "-row-link",
|
|
1800
|
-
displayName: "CMS
|
|
2065
|
+
displayName: "CMS Entry Link",
|
|
1801
2066
|
importName: "CmsRowLink",
|
|
1802
2067
|
importPath: modulePath,
|
|
1803
2068
|
props: {
|
|
@@ -1821,10 +2086,10 @@ var cmsRowLinkMeta = {
|
|
|
1821
2086
|
type: "choice",
|
|
1822
2087
|
displayName: "Field",
|
|
1823
2088
|
description: "Field (from model schema) to use.",
|
|
1824
|
-
options: function options(
|
|
2089
|
+
options: function options(_ref14, ctx) {
|
|
1825
2090
|
var _ctx$table2;
|
|
1826
2091
|
|
|
1827
|
-
var table =
|
|
2092
|
+
var table = _ref14.table;
|
|
1828
2093
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
1829
2094
|
}
|
|
1830
2095
|
},
|
|
@@ -1836,14 +2101,14 @@ var cmsRowLinkMeta = {
|
|
|
1836
2101
|
}
|
|
1837
2102
|
}
|
|
1838
2103
|
};
|
|
1839
|
-
function CmsRowLink(
|
|
2104
|
+
function CmsRowLink(_ref15) {
|
|
1840
2105
|
var _res$row$data2;
|
|
1841
2106
|
|
|
1842
|
-
var table =
|
|
1843
|
-
field =
|
|
1844
|
-
hrefProp =
|
|
1845
|
-
children =
|
|
1846
|
-
setControlContextData =
|
|
2107
|
+
var table = _ref15.table,
|
|
2108
|
+
field = _ref15.field,
|
|
2109
|
+
hrefProp = _ref15.hrefProp,
|
|
2110
|
+
children = _ref15.children,
|
|
2111
|
+
setControlContextData = _ref15.setControlContextData;
|
|
1847
2112
|
var tables = useTables();
|
|
1848
2113
|
var res = useRow(table);
|
|
1849
2114
|
|
|
@@ -1888,7 +2153,7 @@ function CmsRowLink(_ref11) {
|
|
|
1888
2153
|
}
|
|
1889
2154
|
var cmsRowImageMeta = {
|
|
1890
2155
|
name: componentPrefix + "-row-image",
|
|
1891
|
-
displayName: "CMS
|
|
2156
|
+
displayName: "CMS Entry Image",
|
|
1892
2157
|
importName: "CmsRowImage",
|
|
1893
2158
|
importPath: modulePath,
|
|
1894
2159
|
props: {
|
|
@@ -1911,10 +2176,10 @@ var cmsRowImageMeta = {
|
|
|
1911
2176
|
type: "choice",
|
|
1912
2177
|
displayName: "Field",
|
|
1913
2178
|
description: "Field (from model schema) to use.",
|
|
1914
|
-
options: function options(
|
|
2179
|
+
options: function options(_ref16, ctx) {
|
|
1915
2180
|
var _ctx$table3;
|
|
1916
2181
|
|
|
1917
|
-
var table =
|
|
2182
|
+
var table = _ref16.table;
|
|
1918
2183
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1919
2184
|
}
|
|
1920
2185
|
},
|
|
@@ -1926,14 +2191,14 @@ var cmsRowImageMeta = {
|
|
|
1926
2191
|
}
|
|
1927
2192
|
}
|
|
1928
2193
|
};
|
|
1929
|
-
function CmsRowImage(
|
|
2194
|
+
function CmsRowImage(_ref17) {
|
|
1930
2195
|
var _res$row$data3;
|
|
1931
2196
|
|
|
1932
|
-
var table =
|
|
1933
|
-
field =
|
|
1934
|
-
srcProp =
|
|
1935
|
-
children =
|
|
1936
|
-
setControlContextData =
|
|
2197
|
+
var table = _ref17.table,
|
|
2198
|
+
field = _ref17.field,
|
|
2199
|
+
srcProp = _ref17.srcProp,
|
|
2200
|
+
children = _ref17.children,
|
|
2201
|
+
setControlContextData = _ref17.setControlContextData;
|
|
1937
2202
|
var tables = useTables();
|
|
1938
2203
|
var res = useRow(table);
|
|
1939
2204
|
|
|
@@ -1984,7 +2249,7 @@ function CmsRowImage(_ref13) {
|
|
|
1984
2249
|
}
|
|
1985
2250
|
var cmsRowFieldValueMeta = {
|
|
1986
2251
|
name: componentPrefix + "-row-value",
|
|
1987
|
-
displayName: "CMS
|
|
2252
|
+
displayName: "CMS Entry Value",
|
|
1988
2253
|
importName: "CmsRowValue",
|
|
1989
2254
|
importPath: modulePath,
|
|
1990
2255
|
props: {
|
|
@@ -2003,10 +2268,10 @@ var cmsRowFieldValueMeta = {
|
|
|
2003
2268
|
type: "choice",
|
|
2004
2269
|
displayName: "Field",
|
|
2005
2270
|
description: "Field (from model schema) to use.",
|
|
2006
|
-
options: function options(
|
|
2271
|
+
options: function options(_ref18, ctx) {
|
|
2007
2272
|
var _ctx$table4;
|
|
2008
2273
|
|
|
2009
|
-
var table =
|
|
2274
|
+
var table = _ref18.table;
|
|
2010
2275
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2011
2276
|
}
|
|
2012
2277
|
},
|
|
@@ -2018,14 +2283,16 @@ var cmsRowFieldValueMeta = {
|
|
|
2018
2283
|
}
|
|
2019
2284
|
}
|
|
2020
2285
|
};
|
|
2021
|
-
function CmsRowFieldValue(
|
|
2286
|
+
function CmsRowFieldValue(_ref19) {
|
|
2022
2287
|
var _res$row$data4;
|
|
2023
2288
|
|
|
2024
|
-
var table =
|
|
2025
|
-
field =
|
|
2026
|
-
valueProp =
|
|
2027
|
-
children =
|
|
2028
|
-
setControlContextData =
|
|
2289
|
+
var table = _ref19.table,
|
|
2290
|
+
field = _ref19.field,
|
|
2291
|
+
valueProp = _ref19.valueProp,
|
|
2292
|
+
children = _ref19.children,
|
|
2293
|
+
setControlContextData = _ref19.setControlContextData,
|
|
2294
|
+
rest = _objectWithoutPropertiesLoose(_ref19, _excluded3);
|
|
2295
|
+
|
|
2029
2296
|
var tables = useTables();
|
|
2030
2297
|
var res = useRow(table);
|
|
2031
2298
|
|
|
@@ -2055,9 +2322,9 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2055
2322
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
2056
2323
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
2057
2324
|
if (React.isValidElement(child)) {
|
|
2058
|
-
var
|
|
2325
|
+
var _extends2;
|
|
2059
2326
|
|
|
2060
|
-
return React.cloneElement(child, (
|
|
2327
|
+
return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
2061
2328
|
}
|
|
2062
2329
|
|
|
2063
2330
|
return child;
|
|
@@ -2098,13 +2365,13 @@ var cmsRowLoaderMeta = {
|
|
|
2098
2365
|
}
|
|
2099
2366
|
}, fetcherComponentPropMetas)
|
|
2100
2367
|
};
|
|
2101
|
-
function CmsRowLoader(
|
|
2102
|
-
var table =
|
|
2103
|
-
row =
|
|
2104
|
-
children =
|
|
2105
|
-
useDraft =
|
|
2106
|
-
hideIfNotFound =
|
|
2107
|
-
setControlContextData =
|
|
2368
|
+
function CmsRowLoader(_ref20) {
|
|
2369
|
+
var table = _ref20.table,
|
|
2370
|
+
row = _ref20.row,
|
|
2371
|
+
children = _ref20.children,
|
|
2372
|
+
useDraft = _ref20.useDraft,
|
|
2373
|
+
hideIfNotFound = _ref20.hideIfNotFound,
|
|
2374
|
+
setControlContextData = _ref20.setControlContextData;
|
|
2108
2375
|
var databaseConfig = useDatabase();
|
|
2109
2376
|
var tables = useTables();
|
|
2110
2377
|
|
|
@@ -2121,13 +2388,13 @@ function CmsRowLoader(_ref16) {
|
|
|
2121
2388
|
databaseConfig: databaseConfig,
|
|
2122
2389
|
useDraft: useDraft
|
|
2123
2390
|
});
|
|
2124
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2125
|
-
return runtime_1.wrap(function
|
|
2391
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2392
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2126
2393
|
while (1) {
|
|
2127
|
-
switch (
|
|
2394
|
+
switch (_context4.prev = _context4.next) {
|
|
2128
2395
|
case 0:
|
|
2129
2396
|
if (table) {
|
|
2130
|
-
|
|
2397
|
+
_context4.next = 2;
|
|
2131
2398
|
break;
|
|
2132
2399
|
}
|
|
2133
2400
|
|
|
@@ -2135,25 +2402,25 @@ function CmsRowLoader(_ref16) {
|
|
|
2135
2402
|
|
|
2136
2403
|
case 2:
|
|
2137
2404
|
if (row) {
|
|
2138
|
-
|
|
2405
|
+
_context4.next = 4;
|
|
2139
2406
|
break;
|
|
2140
2407
|
}
|
|
2141
2408
|
|
|
2142
2409
|
throw new Error("You must specify an entry name to fetch.");
|
|
2143
2410
|
|
|
2144
2411
|
case 4:
|
|
2145
|
-
|
|
2412
|
+
_context4.next = 6;
|
|
2146
2413
|
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2147
2414
|
|
|
2148
2415
|
case 6:
|
|
2149
|
-
return
|
|
2416
|
+
return _context4.abrupt("return", _context4.sent);
|
|
2150
2417
|
|
|
2151
2418
|
case 7:
|
|
2152
2419
|
case "end":
|
|
2153
|
-
return
|
|
2420
|
+
return _context4.stop();
|
|
2154
2421
|
}
|
|
2155
2422
|
}
|
|
2156
|
-
},
|
|
2423
|
+
}, _callee4);
|
|
2157
2424
|
})));
|
|
2158
2425
|
return renderMaybeData(maybeData, function (row) {
|
|
2159
2426
|
return React.createElement(RowProvider, {
|
|
@@ -2184,11 +2451,11 @@ function registerAll(loader) {
|
|
|
2184
2451
|
}
|
|
2185
2452
|
};
|
|
2186
2453
|
|
|
2187
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2454
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta); // _registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2455
|
+
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2188
2456
|
|
|
2189
|
-
_registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2190
2457
|
|
|
2191
|
-
_registerComponent(
|
|
2458
|
+
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2192
2459
|
|
|
2193
2460
|
_registerComponent(CmsRowField, cmsRowFieldMeta);
|
|
2194
2461
|
|
|
@@ -2196,13 +2463,13 @@ function registerAll(loader) {
|
|
|
2196
2463
|
|
|
2197
2464
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2198
2465
|
|
|
2199
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2466
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta); // _registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2200
2467
|
|
|
2201
|
-
_registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2202
2468
|
}
|
|
2203
2469
|
|
|
2204
2470
|
exports.CmsCredentialsProvider = CmsCredentialsProvider;
|
|
2205
2471
|
exports.CmsQueryLoader = CmsQueryLoader;
|
|
2472
|
+
exports.CmsQueryRepeater = CmsQueryRepeater;
|
|
2206
2473
|
exports.CmsRowField = CmsRowField;
|
|
2207
2474
|
exports.CmsRowFieldValue = CmsRowFieldValue;
|
|
2208
2475
|
exports.CmsRowImage = CmsRowImage;
|
|
@@ -2211,6 +2478,7 @@ exports.CmsRowLoader = CmsRowLoader;
|
|
|
2211
2478
|
exports.CmsRowRepeater = CmsRowRepeater;
|
|
2212
2479
|
exports.cmsCredentialsProviderMeta = cmsCredentialsProviderMeta;
|
|
2213
2480
|
exports.cmsQueryLoaderMeta = cmsQueryLoaderMeta;
|
|
2481
|
+
exports.cmsQueryRepeaterMeta = cmsQueryRepeaterMeta;
|
|
2214
2482
|
exports.cmsRowFieldMeta = cmsRowFieldMeta;
|
|
2215
2483
|
exports.cmsRowFieldValueMeta = cmsRowFieldValueMeta;
|
|
2216
2484
|
exports.cmsRowImageMeta = cmsRowImageMeta;
|