@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
package/dist/plasmic-cms.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import registerGlobalContext from '@plasmicapp/host/registerGlobalContext';
|
|
2
1
|
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
2
|
+
import registerGlobalContext from '@plasmicapp/host/registerGlobalContext';
|
|
3
3
|
import { useSelector, DataProvider, useDataEnv, repeatedElement } from '@plasmicapp/host';
|
|
4
4
|
import { usePlasmicQueryData } from '@plasmicapp/query';
|
|
5
|
+
import dayjs from 'dayjs';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1347,13 +1348,13 @@ function mkTableOptions(tables) {
|
|
|
1347
1348
|
};
|
|
1348
1349
|
});
|
|
1349
1350
|
}
|
|
1350
|
-
function mkFieldOptions(tables,
|
|
1351
|
+
function mkFieldOptions(tables, tableIdentifier, types) {
|
|
1351
1352
|
if (!tables) {
|
|
1352
1353
|
return [];
|
|
1353
1354
|
}
|
|
1354
1355
|
|
|
1355
1356
|
var table = tables.find(function (t) {
|
|
1356
|
-
return t.identifier ===
|
|
1357
|
+
return t.identifier === tableIdentifier;
|
|
1357
1358
|
});
|
|
1358
1359
|
|
|
1359
1360
|
if (!table) {
|
|
@@ -1377,7 +1378,8 @@ function mkFieldOptions(tables, tableId, types) {
|
|
|
1377
1378
|
}
|
|
1378
1379
|
|
|
1379
1380
|
var _excluded = ["children"],
|
|
1380
|
-
_excluded2 = ["className", "table", "field", "setControlContextData"]
|
|
1381
|
+
_excluded2 = ["className", "table", "field", "dateFormat", "setControlContextData"],
|
|
1382
|
+
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1381
1383
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1382
1384
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1383
1385
|
var fetcherComponentPropMetas = {
|
|
@@ -1446,15 +1448,6 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1446
1448
|
config = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1447
1449
|
|
|
1448
1450
|
config.host = config.host || defaultHost;
|
|
1449
|
-
|
|
1450
|
-
if (!config.databaseId) {
|
|
1451
|
-
throw new Error("You must specify the CMS database ID to use.");
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
if (!config.databaseToken) {
|
|
1455
|
-
throw new Error("You must specify the token of the CMS database you are using.");
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
1451
|
return React.createElement(DatabaseProvider, {
|
|
1459
1452
|
config: config
|
|
1460
1453
|
}, React.createElement(TablesFetcher, null, children));
|
|
@@ -1472,9 +1465,21 @@ function TablesFetcher(_ref2) {
|
|
|
1472
1465
|
while (1) {
|
|
1473
1466
|
switch (_context.prev = _context.next) {
|
|
1474
1467
|
case 0:
|
|
1475
|
-
|
|
1468
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1469
|
+
_context.next = 2;
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
return _context.abrupt("return", []);
|
|
1476
1474
|
|
|
1477
|
-
case
|
|
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:
|
|
1478
1483
|
case "end":
|
|
1479
1484
|
return _context.stop();
|
|
1480
1485
|
}
|
|
@@ -1492,7 +1497,7 @@ function TablesFetcher(_ref2) {
|
|
|
1492
1497
|
|
|
1493
1498
|
var cmsQueryLoaderMeta = {
|
|
1494
1499
|
name: componentPrefix + "-query-loader",
|
|
1495
|
-
displayName: "CMS
|
|
1500
|
+
displayName: "CMS Data Loader",
|
|
1496
1501
|
importName: "CmsQueryLoader",
|
|
1497
1502
|
importPath: modulePath,
|
|
1498
1503
|
props: {
|
|
@@ -1545,6 +1550,11 @@ var cmsQueryLoaderMeta = {
|
|
|
1545
1550
|
}
|
|
1546
1551
|
}
|
|
1547
1552
|
};
|
|
1553
|
+
|
|
1554
|
+
function isDatabaseConfigured(config) {
|
|
1555
|
+
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1548
1558
|
function CmsQueryLoader(_ref5) {
|
|
1549
1559
|
var table = _ref5.table,
|
|
1550
1560
|
children = _ref5.children,
|
|
@@ -1582,27 +1592,35 @@ function CmsQueryLoader(_ref5) {
|
|
|
1582
1592
|
while (1) {
|
|
1583
1593
|
switch (_context2.prev = _context2.next) {
|
|
1584
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:
|
|
1585
1603
|
if (table) {
|
|
1586
|
-
_context2.next =
|
|
1604
|
+
_context2.next = 6;
|
|
1587
1605
|
break;
|
|
1588
1606
|
}
|
|
1589
1607
|
|
|
1590
|
-
throw new Error("You must select a
|
|
1608
|
+
throw new Error("You must select a model to query");
|
|
1591
1609
|
|
|
1592
|
-
case
|
|
1610
|
+
case 6:
|
|
1593
1611
|
if (!(tables && !tables.find(function (t) {
|
|
1594
1612
|
return t.identifier === table;
|
|
1595
1613
|
}))) {
|
|
1596
|
-
_context2.next =
|
|
1614
|
+
_context2.next = 8;
|
|
1597
1615
|
break;
|
|
1598
1616
|
}
|
|
1599
1617
|
|
|
1600
|
-
throw new Error("There is no
|
|
1618
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1601
1619
|
|
|
1602
|
-
case
|
|
1620
|
+
case 8:
|
|
1603
1621
|
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1604
1622
|
|
|
1605
|
-
case
|
|
1623
|
+
case 9:
|
|
1606
1624
|
case "end":
|
|
1607
1625
|
return _context2.stop();
|
|
1608
1626
|
}
|
|
@@ -1620,7 +1638,7 @@ function CmsQueryLoader(_ref5) {
|
|
|
1620
1638
|
}
|
|
1621
1639
|
var cmsRowRepeaterMeta = {
|
|
1622
1640
|
name: componentPrefix + "-row-repeater",
|
|
1623
|
-
displayName: "CMS
|
|
1641
|
+
displayName: "CMS Entry Repeater",
|
|
1624
1642
|
importName: "CmsRowRepeater",
|
|
1625
1643
|
importPath: modulePath,
|
|
1626
1644
|
props: {
|
|
@@ -1666,9 +1684,169 @@ function CmsRowRepeater(_ref7) {
|
|
|
1666
1684
|
}, repeatedElement(index === 0, children));
|
|
1667
1685
|
}));
|
|
1668
1686
|
}
|
|
1687
|
+
var cmsQueryRepeaterMeta = {
|
|
1688
|
+
name: componentPrefix + "-query-repeater",
|
|
1689
|
+
displayName: "CMS Data Loader",
|
|
1690
|
+
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1691
|
+
importName: "CmsQueryRepeater",
|
|
1692
|
+
importPath: modulePath,
|
|
1693
|
+
props: {
|
|
1694
|
+
children: {
|
|
1695
|
+
type: "slot",
|
|
1696
|
+
defaultValue: {
|
|
1697
|
+
type: "vbox",
|
|
1698
|
+
children: [{
|
|
1699
|
+
type: "component",
|
|
1700
|
+
name: componentPrefix + "-row-field"
|
|
1701
|
+
}]
|
|
1702
|
+
}
|
|
1703
|
+
},
|
|
1704
|
+
table: {
|
|
1705
|
+
type: "choice",
|
|
1706
|
+
displayName: "Model",
|
|
1707
|
+
description: "CMS model (table) to query.",
|
|
1708
|
+
options: function options(_, ctx) {
|
|
1709
|
+
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1710
|
+
}
|
|
1711
|
+
},
|
|
1712
|
+
useDraft: {
|
|
1713
|
+
type: "boolean",
|
|
1714
|
+
displayName: "Use drafts?",
|
|
1715
|
+
description: "If set, also query unpublished content.",
|
|
1716
|
+
defaultValue: false
|
|
1717
|
+
},
|
|
1718
|
+
where: {
|
|
1719
|
+
type: "object",
|
|
1720
|
+
displayName: "Filter",
|
|
1721
|
+
description: "Filter clause, in JSON format.",
|
|
1722
|
+
hidden: function hidden() {
|
|
1723
|
+
return true;
|
|
1724
|
+
}
|
|
1725
|
+
},
|
|
1726
|
+
orderBy: {
|
|
1727
|
+
type: "choice",
|
|
1728
|
+
displayName: "Order by",
|
|
1729
|
+
description: "Field to order by.",
|
|
1730
|
+
options: function options(_ref8, ctx) {
|
|
1731
|
+
var table = _ref8.table;
|
|
1732
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, table);
|
|
1733
|
+
}
|
|
1734
|
+
},
|
|
1735
|
+
desc: {
|
|
1736
|
+
type: "boolean",
|
|
1737
|
+
displayName: "Sort descending?",
|
|
1738
|
+
description: 'Sort descending by "Order by" field.',
|
|
1739
|
+
defaultValue: false
|
|
1740
|
+
},
|
|
1741
|
+
limit: {
|
|
1742
|
+
type: "number",
|
|
1743
|
+
displayName: "Limit",
|
|
1744
|
+
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1745
|
+
defaultValue: 0
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
function CmsQueryRepeater(_ref9) {
|
|
1750
|
+
var table = _ref9.table,
|
|
1751
|
+
children = _ref9.children,
|
|
1752
|
+
setControlContextData = _ref9.setControlContextData,
|
|
1753
|
+
where = _ref9.where,
|
|
1754
|
+
useDraft = _ref9.useDraft,
|
|
1755
|
+
orderBy = _ref9.orderBy,
|
|
1756
|
+
desc = _ref9.desc,
|
|
1757
|
+
limit = _ref9.limit;
|
|
1758
|
+
var databaseConfig = useDatabase();
|
|
1759
|
+
var tables = useTables();
|
|
1760
|
+
|
|
1761
|
+
if (tables) {
|
|
1762
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1763
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1764
|
+
tables: tables
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
var params = {
|
|
1769
|
+
where: where,
|
|
1770
|
+
useDraft: useDraft,
|
|
1771
|
+
orderBy: orderBy,
|
|
1772
|
+
desc: desc,
|
|
1773
|
+
limit: limit
|
|
1774
|
+
};
|
|
1775
|
+
var cacheKey = JSON.stringify({
|
|
1776
|
+
component: "CmsQueryLoader",
|
|
1777
|
+
table: table,
|
|
1778
|
+
databaseConfig: databaseConfig,
|
|
1779
|
+
params: params
|
|
1780
|
+
});
|
|
1781
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1782
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1783
|
+
while (1) {
|
|
1784
|
+
switch (_context3.prev = _context3.next) {
|
|
1785
|
+
case 0:
|
|
1786
|
+
if (isDatabaseConfigured(databaseConfig)) {
|
|
1787
|
+
_context3.next = 2;
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
|
|
1791
|
+
throw new Error("You must specify a CMS ID and API key");
|
|
1792
|
+
|
|
1793
|
+
case 2:
|
|
1794
|
+
if (table) {
|
|
1795
|
+
_context3.next = 6;
|
|
1796
|
+
break;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
if (!(!tables || tables.length === 0)) {
|
|
1800
|
+
_context3.next = 5;
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
throw new Error("You must select a model to query");
|
|
1805
|
+
|
|
1806
|
+
case 5:
|
|
1807
|
+
table = tables[0].identifier;
|
|
1808
|
+
|
|
1809
|
+
case 6:
|
|
1810
|
+
if (!(tables && !tables.find(function (t) {
|
|
1811
|
+
return t.identifier === table;
|
|
1812
|
+
}))) {
|
|
1813
|
+
_context3.next = 8;
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1818
|
+
|
|
1819
|
+
case 8:
|
|
1820
|
+
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1821
|
+
|
|
1822
|
+
case 9:
|
|
1823
|
+
case "end":
|
|
1824
|
+
return _context3.stop();
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
}, _callee3);
|
|
1828
|
+
})));
|
|
1829
|
+
return renderMaybeData(maybeData, function (rows) {
|
|
1830
|
+
if (rows.length === 0) {
|
|
1831
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
return React.createElement(QueryResultProvider, {
|
|
1835
|
+
table: table,
|
|
1836
|
+
rows: rows
|
|
1837
|
+
}, rows.map(function (row, index) {
|
|
1838
|
+
return React.createElement(RowProvider, {
|
|
1839
|
+
table: table,
|
|
1840
|
+
row: row
|
|
1841
|
+
}, repeatedElement(index === 0, children));
|
|
1842
|
+
}));
|
|
1843
|
+
}, {
|
|
1844
|
+
hideIfNotFound: false
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1669
1847
|
var cmsRowFieldMeta = {
|
|
1670
1848
|
name: componentPrefix + "-row-field",
|
|
1671
|
-
displayName: "CMS
|
|
1849
|
+
displayName: "CMS Entry Field",
|
|
1672
1850
|
importName: "CmsRowField",
|
|
1673
1851
|
importPath: modulePath,
|
|
1674
1852
|
props: {
|
|
@@ -1684,36 +1862,117 @@ var cmsRowFieldMeta = {
|
|
|
1684
1862
|
type: "choice",
|
|
1685
1863
|
displayName: "Field",
|
|
1686
1864
|
description: "Field (from model schema) to use.",
|
|
1687
|
-
options: function options(
|
|
1865
|
+
options: function options(_ref11, ctx) {
|
|
1688
1866
|
var _ctx$table;
|
|
1689
1867
|
|
|
1690
|
-
var table =
|
|
1691
|
-
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"]);
|
|
1868
|
+
var table = _ref11.table;
|
|
1869
|
+
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"]);
|
|
1692
1870
|
}
|
|
1871
|
+
},
|
|
1872
|
+
dateFormat: {
|
|
1873
|
+
type: "choice",
|
|
1874
|
+
displayName: "Date Format",
|
|
1875
|
+
hidden: function hidden(_ref12, ctx) {
|
|
1876
|
+
var field = _ref12.field;
|
|
1877
|
+
|
|
1878
|
+
if (!ctx) {
|
|
1879
|
+
return true;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
var tableIdentifier = ctx.table,
|
|
1883
|
+
tables = ctx.tables;
|
|
1884
|
+
var table = tables == null ? void 0 : tables.find(function (t) {
|
|
1885
|
+
return t.identifier === tableIdentifier;
|
|
1886
|
+
});
|
|
1887
|
+
|
|
1888
|
+
if (!table) {
|
|
1889
|
+
return true;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
var fieldMeta = table.schema.fields.find(function (f) {
|
|
1893
|
+
return f.identifier === field;
|
|
1894
|
+
});
|
|
1895
|
+
|
|
1896
|
+
if (!fieldMeta) {
|
|
1897
|
+
return true;
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
return fieldMeta.type !== "date-time";
|
|
1901
|
+
},
|
|
1902
|
+
options: [{
|
|
1903
|
+
label: "July 26, 2014",
|
|
1904
|
+
value: "MMMM D, YYYY"
|
|
1905
|
+
}, {
|
|
1906
|
+
label: "July 26, 2014 10:02 PM",
|
|
1907
|
+
value: "MMMM D, YYYY h:mm A"
|
|
1908
|
+
}, {
|
|
1909
|
+
label: "Jul 26, 2014",
|
|
1910
|
+
value: "MMM D, YYYY"
|
|
1911
|
+
}, {
|
|
1912
|
+
label: "Jul 26, 2014 10:02 PM",
|
|
1913
|
+
value: "MMM D, YYYY h:mm A"
|
|
1914
|
+
}, {
|
|
1915
|
+
label: "Saturday, July 26, 2014",
|
|
1916
|
+
value: "dddd, MMMM D, YYYY"
|
|
1917
|
+
}, {
|
|
1918
|
+
label: "7/26/2014",
|
|
1919
|
+
value: "M/D/YYYY"
|
|
1920
|
+
}, {
|
|
1921
|
+
label: "7/26/2014 10:02 PM",
|
|
1922
|
+
value: "M/D/YYYY h:mm A"
|
|
1923
|
+
}, {
|
|
1924
|
+
label: "26/7/2014",
|
|
1925
|
+
value: "D/M/YYYY"
|
|
1926
|
+
}, {
|
|
1927
|
+
label: "26/7/2014 10:02 PM",
|
|
1928
|
+
value: "D/M/YYYY h:mm A"
|
|
1929
|
+
}, {
|
|
1930
|
+
label: "7/26/14",
|
|
1931
|
+
value: "M/D/YY"
|
|
1932
|
+
}, {
|
|
1933
|
+
label: "7/26/14 10:02 PM",
|
|
1934
|
+
value: "M/D/YY h:mm A"
|
|
1935
|
+
}, {
|
|
1936
|
+
label: "26/7/14",
|
|
1937
|
+
value: "D/M/YY"
|
|
1938
|
+
}, {
|
|
1939
|
+
label: "26/7/14 10:02 PM",
|
|
1940
|
+
value: "D/M/YY h:mm A"
|
|
1941
|
+
}]
|
|
1693
1942
|
}
|
|
1694
1943
|
}
|
|
1695
1944
|
};
|
|
1696
|
-
function CmsRowField(
|
|
1945
|
+
function CmsRowField(_ref13) {
|
|
1697
1946
|
var _res$row$data;
|
|
1698
1947
|
|
|
1699
|
-
var className =
|
|
1700
|
-
table =
|
|
1701
|
-
field =
|
|
1702
|
-
|
|
1703
|
-
|
|
1948
|
+
var className = _ref13.className,
|
|
1949
|
+
table = _ref13.table,
|
|
1950
|
+
field = _ref13.field,
|
|
1951
|
+
dateFormat = _ref13.dateFormat,
|
|
1952
|
+
setControlContextData = _ref13.setControlContextData,
|
|
1953
|
+
rest = _objectWithoutPropertiesLoose(_ref13, _excluded2);
|
|
1704
1954
|
|
|
1705
1955
|
var tables = useTables();
|
|
1706
1956
|
var res = useRow(table);
|
|
1707
1957
|
|
|
1708
|
-
if (!res
|
|
1709
|
-
return React.createElement("div",
|
|
1958
|
+
if (!res) {
|
|
1959
|
+
return React.createElement("div", {
|
|
1960
|
+
className: className
|
|
1961
|
+
}, "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
if (!res.row) {
|
|
1965
|
+
return React.createElement("div", {
|
|
1966
|
+
className: className
|
|
1967
|
+
}, "Error: No CMS Entry found");
|
|
1710
1968
|
}
|
|
1711
1969
|
|
|
1712
1970
|
if (tables) {
|
|
1713
1971
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1714
1972
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1715
1973
|
tables: tables,
|
|
1716
|
-
table: res.table
|
|
1974
|
+
table: res.table,
|
|
1975
|
+
row: res.row
|
|
1717
1976
|
});
|
|
1718
1977
|
}
|
|
1719
1978
|
|
|
@@ -1721,14 +1980,23 @@ function CmsRowField(_ref9) {
|
|
|
1721
1980
|
table: res.table,
|
|
1722
1981
|
tables: tables,
|
|
1723
1982
|
field: field,
|
|
1724
|
-
typeFilters: ["text"]
|
|
1983
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1725
1984
|
});
|
|
1726
1985
|
|
|
1727
1986
|
if (!fieldMeta) {
|
|
1728
|
-
|
|
1987
|
+
throw new Error("Please select an entry field to display.");
|
|
1729
1988
|
}
|
|
1730
1989
|
|
|
1731
1990
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
1991
|
+
|
|
1992
|
+
if (!data) {
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
1997
|
+
data = dayjs(data).format(dateFormat);
|
|
1998
|
+
}
|
|
1999
|
+
|
|
1732
2000
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
1733
2001
|
className: className
|
|
1734
2002
|
}, rest)) : null;
|
|
@@ -1791,7 +2059,7 @@ function renderValue(value, type, props) {
|
|
|
1791
2059
|
|
|
1792
2060
|
var cmsRowLinkMeta = {
|
|
1793
2061
|
name: componentPrefix + "-row-link",
|
|
1794
|
-
displayName: "CMS
|
|
2062
|
+
displayName: "CMS Entry Link",
|
|
1795
2063
|
importName: "CmsRowLink",
|
|
1796
2064
|
importPath: modulePath,
|
|
1797
2065
|
props: {
|
|
@@ -1815,10 +2083,10 @@ var cmsRowLinkMeta = {
|
|
|
1815
2083
|
type: "choice",
|
|
1816
2084
|
displayName: "Field",
|
|
1817
2085
|
description: "Field (from model schema) to use.",
|
|
1818
|
-
options: function options(
|
|
2086
|
+
options: function options(_ref14, ctx) {
|
|
1819
2087
|
var _ctx$table2;
|
|
1820
2088
|
|
|
1821
|
-
var table =
|
|
2089
|
+
var table = _ref14.table;
|
|
1822
2090
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
1823
2091
|
}
|
|
1824
2092
|
},
|
|
@@ -1830,14 +2098,14 @@ var cmsRowLinkMeta = {
|
|
|
1830
2098
|
}
|
|
1831
2099
|
}
|
|
1832
2100
|
};
|
|
1833
|
-
function CmsRowLink(
|
|
2101
|
+
function CmsRowLink(_ref15) {
|
|
1834
2102
|
var _res$row$data2;
|
|
1835
2103
|
|
|
1836
|
-
var table =
|
|
1837
|
-
field =
|
|
1838
|
-
hrefProp =
|
|
1839
|
-
children =
|
|
1840
|
-
setControlContextData =
|
|
2104
|
+
var table = _ref15.table,
|
|
2105
|
+
field = _ref15.field,
|
|
2106
|
+
hrefProp = _ref15.hrefProp,
|
|
2107
|
+
children = _ref15.children,
|
|
2108
|
+
setControlContextData = _ref15.setControlContextData;
|
|
1841
2109
|
var tables = useTables();
|
|
1842
2110
|
var res = useRow(table);
|
|
1843
2111
|
|
|
@@ -1882,7 +2150,7 @@ function CmsRowLink(_ref11) {
|
|
|
1882
2150
|
}
|
|
1883
2151
|
var cmsRowImageMeta = {
|
|
1884
2152
|
name: componentPrefix + "-row-image",
|
|
1885
|
-
displayName: "CMS
|
|
2153
|
+
displayName: "CMS Entry Image",
|
|
1886
2154
|
importName: "CmsRowImage",
|
|
1887
2155
|
importPath: modulePath,
|
|
1888
2156
|
props: {
|
|
@@ -1905,10 +2173,10 @@ var cmsRowImageMeta = {
|
|
|
1905
2173
|
type: "choice",
|
|
1906
2174
|
displayName: "Field",
|
|
1907
2175
|
description: "Field (from model schema) to use.",
|
|
1908
|
-
options: function options(
|
|
2176
|
+
options: function options(_ref16, ctx) {
|
|
1909
2177
|
var _ctx$table3;
|
|
1910
2178
|
|
|
1911
|
-
var table =
|
|
2179
|
+
var table = _ref16.table;
|
|
1912
2180
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1913
2181
|
}
|
|
1914
2182
|
},
|
|
@@ -1920,14 +2188,14 @@ var cmsRowImageMeta = {
|
|
|
1920
2188
|
}
|
|
1921
2189
|
}
|
|
1922
2190
|
};
|
|
1923
|
-
function CmsRowImage(
|
|
2191
|
+
function CmsRowImage(_ref17) {
|
|
1924
2192
|
var _res$row$data3;
|
|
1925
2193
|
|
|
1926
|
-
var table =
|
|
1927
|
-
field =
|
|
1928
|
-
srcProp =
|
|
1929
|
-
children =
|
|
1930
|
-
setControlContextData =
|
|
2194
|
+
var table = _ref17.table,
|
|
2195
|
+
field = _ref17.field,
|
|
2196
|
+
srcProp = _ref17.srcProp,
|
|
2197
|
+
children = _ref17.children,
|
|
2198
|
+
setControlContextData = _ref17.setControlContextData;
|
|
1931
2199
|
var tables = useTables();
|
|
1932
2200
|
var res = useRow(table);
|
|
1933
2201
|
|
|
@@ -1978,7 +2246,7 @@ function CmsRowImage(_ref13) {
|
|
|
1978
2246
|
}
|
|
1979
2247
|
var cmsRowFieldValueMeta = {
|
|
1980
2248
|
name: componentPrefix + "-row-value",
|
|
1981
|
-
displayName: "CMS
|
|
2249
|
+
displayName: "CMS Entry Value",
|
|
1982
2250
|
importName: "CmsRowValue",
|
|
1983
2251
|
importPath: modulePath,
|
|
1984
2252
|
props: {
|
|
@@ -1997,10 +2265,10 @@ var cmsRowFieldValueMeta = {
|
|
|
1997
2265
|
type: "choice",
|
|
1998
2266
|
displayName: "Field",
|
|
1999
2267
|
description: "Field (from model schema) to use.",
|
|
2000
|
-
options: function options(
|
|
2268
|
+
options: function options(_ref18, ctx) {
|
|
2001
2269
|
var _ctx$table4;
|
|
2002
2270
|
|
|
2003
|
-
var table =
|
|
2271
|
+
var table = _ref18.table;
|
|
2004
2272
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2005
2273
|
}
|
|
2006
2274
|
},
|
|
@@ -2012,14 +2280,16 @@ var cmsRowFieldValueMeta = {
|
|
|
2012
2280
|
}
|
|
2013
2281
|
}
|
|
2014
2282
|
};
|
|
2015
|
-
function CmsRowFieldValue(
|
|
2283
|
+
function CmsRowFieldValue(_ref19) {
|
|
2016
2284
|
var _res$row$data4;
|
|
2017
2285
|
|
|
2018
|
-
var table =
|
|
2019
|
-
field =
|
|
2020
|
-
valueProp =
|
|
2021
|
-
children =
|
|
2022
|
-
setControlContextData =
|
|
2286
|
+
var table = _ref19.table,
|
|
2287
|
+
field = _ref19.field,
|
|
2288
|
+
valueProp = _ref19.valueProp,
|
|
2289
|
+
children = _ref19.children,
|
|
2290
|
+
setControlContextData = _ref19.setControlContextData,
|
|
2291
|
+
rest = _objectWithoutPropertiesLoose(_ref19, _excluded3);
|
|
2292
|
+
|
|
2023
2293
|
var tables = useTables();
|
|
2024
2294
|
var res = useRow(table);
|
|
2025
2295
|
|
|
@@ -2049,9 +2319,9 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2049
2319
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
2050
2320
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
2051
2321
|
if (React.isValidElement(child)) {
|
|
2052
|
-
var
|
|
2322
|
+
var _extends2;
|
|
2053
2323
|
|
|
2054
|
-
return React.cloneElement(child, (
|
|
2324
|
+
return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
2055
2325
|
}
|
|
2056
2326
|
|
|
2057
2327
|
return child;
|
|
@@ -2092,13 +2362,13 @@ var cmsRowLoaderMeta = {
|
|
|
2092
2362
|
}
|
|
2093
2363
|
}, fetcherComponentPropMetas)
|
|
2094
2364
|
};
|
|
2095
|
-
function CmsRowLoader(
|
|
2096
|
-
var table =
|
|
2097
|
-
row =
|
|
2098
|
-
children =
|
|
2099
|
-
useDraft =
|
|
2100
|
-
hideIfNotFound =
|
|
2101
|
-
setControlContextData =
|
|
2365
|
+
function CmsRowLoader(_ref20) {
|
|
2366
|
+
var table = _ref20.table,
|
|
2367
|
+
row = _ref20.row,
|
|
2368
|
+
children = _ref20.children,
|
|
2369
|
+
useDraft = _ref20.useDraft,
|
|
2370
|
+
hideIfNotFound = _ref20.hideIfNotFound,
|
|
2371
|
+
setControlContextData = _ref20.setControlContextData;
|
|
2102
2372
|
var databaseConfig = useDatabase();
|
|
2103
2373
|
var tables = useTables();
|
|
2104
2374
|
|
|
@@ -2115,13 +2385,13 @@ function CmsRowLoader(_ref16) {
|
|
|
2115
2385
|
databaseConfig: databaseConfig,
|
|
2116
2386
|
useDraft: useDraft
|
|
2117
2387
|
});
|
|
2118
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2119
|
-
return runtime_1.wrap(function
|
|
2388
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2389
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2120
2390
|
while (1) {
|
|
2121
|
-
switch (
|
|
2391
|
+
switch (_context4.prev = _context4.next) {
|
|
2122
2392
|
case 0:
|
|
2123
2393
|
if (table) {
|
|
2124
|
-
|
|
2394
|
+
_context4.next = 2;
|
|
2125
2395
|
break;
|
|
2126
2396
|
}
|
|
2127
2397
|
|
|
@@ -2129,25 +2399,25 @@ function CmsRowLoader(_ref16) {
|
|
|
2129
2399
|
|
|
2130
2400
|
case 2:
|
|
2131
2401
|
if (row) {
|
|
2132
|
-
|
|
2402
|
+
_context4.next = 4;
|
|
2133
2403
|
break;
|
|
2134
2404
|
}
|
|
2135
2405
|
|
|
2136
2406
|
throw new Error("You must specify an entry name to fetch.");
|
|
2137
2407
|
|
|
2138
2408
|
case 4:
|
|
2139
|
-
|
|
2409
|
+
_context4.next = 6;
|
|
2140
2410
|
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2141
2411
|
|
|
2142
2412
|
case 6:
|
|
2143
|
-
return
|
|
2413
|
+
return _context4.abrupt("return", _context4.sent);
|
|
2144
2414
|
|
|
2145
2415
|
case 7:
|
|
2146
2416
|
case "end":
|
|
2147
|
-
return
|
|
2417
|
+
return _context4.stop();
|
|
2148
2418
|
}
|
|
2149
2419
|
}
|
|
2150
|
-
},
|
|
2420
|
+
}, _callee4);
|
|
2151
2421
|
})));
|
|
2152
2422
|
return renderMaybeData(maybeData, function (row) {
|
|
2153
2423
|
return React.createElement(RowProvider, {
|
|
@@ -2178,11 +2448,11 @@ function registerAll(loader) {
|
|
|
2178
2448
|
}
|
|
2179
2449
|
};
|
|
2180
2450
|
|
|
2181
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2451
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta); // _registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2452
|
+
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2182
2453
|
|
|
2183
|
-
_registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2184
2454
|
|
|
2185
|
-
_registerComponent(
|
|
2455
|
+
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2186
2456
|
|
|
2187
2457
|
_registerComponent(CmsRowField, cmsRowFieldMeta);
|
|
2188
2458
|
|
|
@@ -2190,10 +2460,9 @@ function registerAll(loader) {
|
|
|
2190
2460
|
|
|
2191
2461
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2192
2462
|
|
|
2193
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2463
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta); // _registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2194
2464
|
|
|
2195
|
-
_registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2196
2465
|
}
|
|
2197
2466
|
|
|
2198
|
-
export { CmsCredentialsProvider, CmsQueryLoader, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, CmsRowLoader, CmsRowRepeater, cmsCredentialsProviderMeta, cmsQueryLoaderMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, cmsRowLoaderMeta, cmsRowRepeaterMeta, registerAll };
|
|
2467
|
+
export { CmsCredentialsProvider, CmsQueryLoader, CmsQueryRepeater, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, CmsRowLoader, CmsRowRepeater, cmsCredentialsProviderMeta, cmsQueryLoaderMeta, cmsQueryRepeaterMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, cmsRowLoaderMeta, cmsRowRepeaterMeta, registerAll };
|
|
2199
2468
|
//# sourceMappingURL=plasmic-cms.esm.js.map
|