@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
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,166 @@ 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
|
+
|
|
1782
|
+
if (!table && tables && tables.length > 0) {
|
|
1783
|
+
table = tables[0].identifier;
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1787
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1788
|
+
while (1) {
|
|
1789
|
+
switch (_context3.prev = _context3.next) {
|
|
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:
|
|
1799
|
+
if (table) {
|
|
1800
|
+
_context3.next = 6;
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
throw new Error("You must select a model to query");
|
|
1805
|
+
|
|
1806
|
+
case 6:
|
|
1807
|
+
if (!(tables && !tables.find(function (t) {
|
|
1808
|
+
return t.identifier === table;
|
|
1809
|
+
}))) {
|
|
1810
|
+
_context3.next = 10;
|
|
1811
|
+
break;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
throw new Error("There is no model called \"" + table + "\"");
|
|
1815
|
+
|
|
1816
|
+
case 10:
|
|
1817
|
+
return _context3.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1818
|
+
|
|
1819
|
+
case 11:
|
|
1820
|
+
case "end":
|
|
1821
|
+
return _context3.stop();
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}, _callee3);
|
|
1825
|
+
})));
|
|
1826
|
+
return renderMaybeData(maybeData, function (rows) {
|
|
1827
|
+
if (rows.length === 0) {
|
|
1828
|
+
return React.createElement("div", null, "No matching entries found.");
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
return React.createElement(QueryResultProvider, {
|
|
1832
|
+
table: table,
|
|
1833
|
+
rows: rows
|
|
1834
|
+
}, rows.map(function (row, index) {
|
|
1835
|
+
return React.createElement(RowProvider, {
|
|
1836
|
+
table: table,
|
|
1837
|
+
row: row
|
|
1838
|
+
}, repeatedElement(index === 0, children));
|
|
1839
|
+
}));
|
|
1840
|
+
}, {
|
|
1841
|
+
hideIfNotFound: false
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1669
1844
|
var cmsRowFieldMeta = {
|
|
1670
1845
|
name: componentPrefix + "-row-field",
|
|
1671
|
-
displayName: "CMS
|
|
1846
|
+
displayName: "CMS Entry Field",
|
|
1672
1847
|
importName: "CmsRowField",
|
|
1673
1848
|
importPath: modulePath,
|
|
1674
1849
|
props: {
|
|
@@ -1684,36 +1859,117 @@ var cmsRowFieldMeta = {
|
|
|
1684
1859
|
type: "choice",
|
|
1685
1860
|
displayName: "Field",
|
|
1686
1861
|
description: "Field (from model schema) to use.",
|
|
1687
|
-
options: function options(
|
|
1862
|
+
options: function options(_ref11, ctx) {
|
|
1688
1863
|
var _ctx$table;
|
|
1689
1864
|
|
|
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"]);
|
|
1865
|
+
var table = _ref11.table;
|
|
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"]);
|
|
1692
1867
|
}
|
|
1868
|
+
},
|
|
1869
|
+
dateFormat: {
|
|
1870
|
+
type: "choice",
|
|
1871
|
+
displayName: "Date Format",
|
|
1872
|
+
hidden: function hidden(_ref12, ctx) {
|
|
1873
|
+
var field = _ref12.field;
|
|
1874
|
+
|
|
1875
|
+
if (!ctx) {
|
|
1876
|
+
return true;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
var tableIdentifier = ctx.table,
|
|
1880
|
+
tables = ctx.tables;
|
|
1881
|
+
var table = tables == null ? void 0 : tables.find(function (t) {
|
|
1882
|
+
return t.identifier === tableIdentifier;
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1885
|
+
if (!table) {
|
|
1886
|
+
return true;
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
var fieldMeta = table.schema.fields.find(function (f) {
|
|
1890
|
+
return f.identifier === field;
|
|
1891
|
+
});
|
|
1892
|
+
|
|
1893
|
+
if (!fieldMeta) {
|
|
1894
|
+
return true;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
return fieldMeta.type !== "date-time";
|
|
1898
|
+
},
|
|
1899
|
+
options: [{
|
|
1900
|
+
label: "July 26, 2014",
|
|
1901
|
+
value: "MMMM D, YYYY"
|
|
1902
|
+
}, {
|
|
1903
|
+
label: "July 26, 2014 10:02 PM",
|
|
1904
|
+
value: "MMMM D, YYYY h:mm A"
|
|
1905
|
+
}, {
|
|
1906
|
+
label: "Jul 26, 2014",
|
|
1907
|
+
value: "MMM D, YYYY"
|
|
1908
|
+
}, {
|
|
1909
|
+
label: "Jul 26, 2014 10:02 PM",
|
|
1910
|
+
value: "MMM D, YYYY h:mm A"
|
|
1911
|
+
}, {
|
|
1912
|
+
label: "Saturday, July 26, 2014",
|
|
1913
|
+
value: "dddd, MMMM D, YYYY"
|
|
1914
|
+
}, {
|
|
1915
|
+
label: "7/26/2014",
|
|
1916
|
+
value: "M/D/YYYY"
|
|
1917
|
+
}, {
|
|
1918
|
+
label: "7/26/2014 10:02 PM",
|
|
1919
|
+
value: "M/D/YYYY h:mm A"
|
|
1920
|
+
}, {
|
|
1921
|
+
label: "26/7/2014",
|
|
1922
|
+
value: "D/M/YYYY"
|
|
1923
|
+
}, {
|
|
1924
|
+
label: "26/7/2014 10:02 PM",
|
|
1925
|
+
value: "D/M/YYYY h:mm A"
|
|
1926
|
+
}, {
|
|
1927
|
+
label: "7/26/14",
|
|
1928
|
+
value: "M/D/YY"
|
|
1929
|
+
}, {
|
|
1930
|
+
label: "7/26/14 10:02 PM",
|
|
1931
|
+
value: "M/D/YY h:mm A"
|
|
1932
|
+
}, {
|
|
1933
|
+
label: "26/7/14",
|
|
1934
|
+
value: "D/M/YY"
|
|
1935
|
+
}, {
|
|
1936
|
+
label: "26/7/14 10:02 PM",
|
|
1937
|
+
value: "D/M/YY h:mm A"
|
|
1938
|
+
}]
|
|
1693
1939
|
}
|
|
1694
1940
|
}
|
|
1695
1941
|
};
|
|
1696
|
-
function CmsRowField(
|
|
1942
|
+
function CmsRowField(_ref13) {
|
|
1697
1943
|
var _res$row$data;
|
|
1698
1944
|
|
|
1699
|
-
var className =
|
|
1700
|
-
table =
|
|
1701
|
-
field =
|
|
1702
|
-
|
|
1703
|
-
|
|
1945
|
+
var className = _ref13.className,
|
|
1946
|
+
table = _ref13.table,
|
|
1947
|
+
field = _ref13.field,
|
|
1948
|
+
dateFormat = _ref13.dateFormat,
|
|
1949
|
+
setControlContextData = _ref13.setControlContextData,
|
|
1950
|
+
rest = _objectWithoutPropertiesLoose(_ref13, _excluded2);
|
|
1704
1951
|
|
|
1705
1952
|
var tables = useTables();
|
|
1706
1953
|
var res = useRow(table);
|
|
1707
1954
|
|
|
1708
|
-
if (!res
|
|
1709
|
-
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");
|
|
1710
1965
|
}
|
|
1711
1966
|
|
|
1712
1967
|
if (tables) {
|
|
1713
1968
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1714
1969
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1715
1970
|
tables: tables,
|
|
1716
|
-
table: res.table
|
|
1971
|
+
table: res.table,
|
|
1972
|
+
row: res.row
|
|
1717
1973
|
});
|
|
1718
1974
|
}
|
|
1719
1975
|
|
|
@@ -1721,14 +1977,23 @@ function CmsRowField(_ref9) {
|
|
|
1721
1977
|
table: res.table,
|
|
1722
1978
|
tables: tables,
|
|
1723
1979
|
field: field,
|
|
1724
|
-
typeFilters: ["text"]
|
|
1980
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1725
1981
|
});
|
|
1726
1982
|
|
|
1727
1983
|
if (!fieldMeta) {
|
|
1728
|
-
|
|
1984
|
+
throw new Error("Please select an entry field to display.");
|
|
1729
1985
|
}
|
|
1730
1986
|
|
|
1731
1987
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
1988
|
+
|
|
1989
|
+
if (!data) {
|
|
1990
|
+
return null;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
1994
|
+
data = dayjs(data).format(dateFormat);
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1732
1997
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
1733
1998
|
className: className
|
|
1734
1999
|
}, rest)) : null;
|
|
@@ -1791,7 +2056,7 @@ function renderValue(value, type, props) {
|
|
|
1791
2056
|
|
|
1792
2057
|
var cmsRowLinkMeta = {
|
|
1793
2058
|
name: componentPrefix + "-row-link",
|
|
1794
|
-
displayName: "CMS
|
|
2059
|
+
displayName: "CMS Entry Link",
|
|
1795
2060
|
importName: "CmsRowLink",
|
|
1796
2061
|
importPath: modulePath,
|
|
1797
2062
|
props: {
|
|
@@ -1815,10 +2080,10 @@ var cmsRowLinkMeta = {
|
|
|
1815
2080
|
type: "choice",
|
|
1816
2081
|
displayName: "Field",
|
|
1817
2082
|
description: "Field (from model schema) to use.",
|
|
1818
|
-
options: function options(
|
|
2083
|
+
options: function options(_ref14, ctx) {
|
|
1819
2084
|
var _ctx$table2;
|
|
1820
2085
|
|
|
1821
|
-
var table =
|
|
2086
|
+
var table = _ref14.table;
|
|
1822
2087
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
1823
2088
|
}
|
|
1824
2089
|
},
|
|
@@ -1830,14 +2095,14 @@ var cmsRowLinkMeta = {
|
|
|
1830
2095
|
}
|
|
1831
2096
|
}
|
|
1832
2097
|
};
|
|
1833
|
-
function CmsRowLink(
|
|
2098
|
+
function CmsRowLink(_ref15) {
|
|
1834
2099
|
var _res$row$data2;
|
|
1835
2100
|
|
|
1836
|
-
var table =
|
|
1837
|
-
field =
|
|
1838
|
-
hrefProp =
|
|
1839
|
-
children =
|
|
1840
|
-
setControlContextData =
|
|
2101
|
+
var table = _ref15.table,
|
|
2102
|
+
field = _ref15.field,
|
|
2103
|
+
hrefProp = _ref15.hrefProp,
|
|
2104
|
+
children = _ref15.children,
|
|
2105
|
+
setControlContextData = _ref15.setControlContextData;
|
|
1841
2106
|
var tables = useTables();
|
|
1842
2107
|
var res = useRow(table);
|
|
1843
2108
|
|
|
@@ -1882,7 +2147,7 @@ function CmsRowLink(_ref11) {
|
|
|
1882
2147
|
}
|
|
1883
2148
|
var cmsRowImageMeta = {
|
|
1884
2149
|
name: componentPrefix + "-row-image",
|
|
1885
|
-
displayName: "CMS
|
|
2150
|
+
displayName: "CMS Entry Image",
|
|
1886
2151
|
importName: "CmsRowImage",
|
|
1887
2152
|
importPath: modulePath,
|
|
1888
2153
|
props: {
|
|
@@ -1905,10 +2170,10 @@ var cmsRowImageMeta = {
|
|
|
1905
2170
|
type: "choice",
|
|
1906
2171
|
displayName: "Field",
|
|
1907
2172
|
description: "Field (from model schema) to use.",
|
|
1908
|
-
options: function options(
|
|
2173
|
+
options: function options(_ref16, ctx) {
|
|
1909
2174
|
var _ctx$table3;
|
|
1910
2175
|
|
|
1911
|
-
var table =
|
|
2176
|
+
var table = _ref16.table;
|
|
1912
2177
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1913
2178
|
}
|
|
1914
2179
|
},
|
|
@@ -1920,14 +2185,14 @@ var cmsRowImageMeta = {
|
|
|
1920
2185
|
}
|
|
1921
2186
|
}
|
|
1922
2187
|
};
|
|
1923
|
-
function CmsRowImage(
|
|
2188
|
+
function CmsRowImage(_ref17) {
|
|
1924
2189
|
var _res$row$data3;
|
|
1925
2190
|
|
|
1926
|
-
var table =
|
|
1927
|
-
field =
|
|
1928
|
-
srcProp =
|
|
1929
|
-
children =
|
|
1930
|
-
setControlContextData =
|
|
2191
|
+
var table = _ref17.table,
|
|
2192
|
+
field = _ref17.field,
|
|
2193
|
+
srcProp = _ref17.srcProp,
|
|
2194
|
+
children = _ref17.children,
|
|
2195
|
+
setControlContextData = _ref17.setControlContextData;
|
|
1931
2196
|
var tables = useTables();
|
|
1932
2197
|
var res = useRow(table);
|
|
1933
2198
|
|
|
@@ -1978,7 +2243,7 @@ function CmsRowImage(_ref13) {
|
|
|
1978
2243
|
}
|
|
1979
2244
|
var cmsRowFieldValueMeta = {
|
|
1980
2245
|
name: componentPrefix + "-row-value",
|
|
1981
|
-
displayName: "CMS
|
|
2246
|
+
displayName: "CMS Entry Value",
|
|
1982
2247
|
importName: "CmsRowValue",
|
|
1983
2248
|
importPath: modulePath,
|
|
1984
2249
|
props: {
|
|
@@ -1997,10 +2262,10 @@ var cmsRowFieldValueMeta = {
|
|
|
1997
2262
|
type: "choice",
|
|
1998
2263
|
displayName: "Field",
|
|
1999
2264
|
description: "Field (from model schema) to use.",
|
|
2000
|
-
options: function options(
|
|
2265
|
+
options: function options(_ref18, ctx) {
|
|
2001
2266
|
var _ctx$table4;
|
|
2002
2267
|
|
|
2003
|
-
var table =
|
|
2268
|
+
var table = _ref18.table;
|
|
2004
2269
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2005
2270
|
}
|
|
2006
2271
|
},
|
|
@@ -2012,14 +2277,16 @@ var cmsRowFieldValueMeta = {
|
|
|
2012
2277
|
}
|
|
2013
2278
|
}
|
|
2014
2279
|
};
|
|
2015
|
-
function CmsRowFieldValue(
|
|
2280
|
+
function CmsRowFieldValue(_ref19) {
|
|
2016
2281
|
var _res$row$data4;
|
|
2017
2282
|
|
|
2018
|
-
var table =
|
|
2019
|
-
field =
|
|
2020
|
-
valueProp =
|
|
2021
|
-
children =
|
|
2022
|
-
setControlContextData =
|
|
2283
|
+
var table = _ref19.table,
|
|
2284
|
+
field = _ref19.field,
|
|
2285
|
+
valueProp = _ref19.valueProp,
|
|
2286
|
+
children = _ref19.children,
|
|
2287
|
+
setControlContextData = _ref19.setControlContextData,
|
|
2288
|
+
rest = _objectWithoutPropertiesLoose(_ref19, _excluded3);
|
|
2289
|
+
|
|
2023
2290
|
var tables = useTables();
|
|
2024
2291
|
var res = useRow(table);
|
|
2025
2292
|
|
|
@@ -2049,9 +2316,9 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2049
2316
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
2050
2317
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
2051
2318
|
if (React.isValidElement(child)) {
|
|
2052
|
-
var
|
|
2319
|
+
var _extends2;
|
|
2053
2320
|
|
|
2054
|
-
return React.cloneElement(child, (
|
|
2321
|
+
return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
2055
2322
|
}
|
|
2056
2323
|
|
|
2057
2324
|
return child;
|
|
@@ -2092,13 +2359,13 @@ var cmsRowLoaderMeta = {
|
|
|
2092
2359
|
}
|
|
2093
2360
|
}, fetcherComponentPropMetas)
|
|
2094
2361
|
};
|
|
2095
|
-
function CmsRowLoader(
|
|
2096
|
-
var table =
|
|
2097
|
-
row =
|
|
2098
|
-
children =
|
|
2099
|
-
useDraft =
|
|
2100
|
-
hideIfNotFound =
|
|
2101
|
-
setControlContextData =
|
|
2362
|
+
function CmsRowLoader(_ref20) {
|
|
2363
|
+
var table = _ref20.table,
|
|
2364
|
+
row = _ref20.row,
|
|
2365
|
+
children = _ref20.children,
|
|
2366
|
+
useDraft = _ref20.useDraft,
|
|
2367
|
+
hideIfNotFound = _ref20.hideIfNotFound,
|
|
2368
|
+
setControlContextData = _ref20.setControlContextData;
|
|
2102
2369
|
var databaseConfig = useDatabase();
|
|
2103
2370
|
var tables = useTables();
|
|
2104
2371
|
|
|
@@ -2115,13 +2382,13 @@ function CmsRowLoader(_ref16) {
|
|
|
2115
2382
|
databaseConfig: databaseConfig,
|
|
2116
2383
|
useDraft: useDraft
|
|
2117
2384
|
});
|
|
2118
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2119
|
-
return runtime_1.wrap(function
|
|
2385
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2386
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2120
2387
|
while (1) {
|
|
2121
|
-
switch (
|
|
2388
|
+
switch (_context4.prev = _context4.next) {
|
|
2122
2389
|
case 0:
|
|
2123
2390
|
if (table) {
|
|
2124
|
-
|
|
2391
|
+
_context4.next = 2;
|
|
2125
2392
|
break;
|
|
2126
2393
|
}
|
|
2127
2394
|
|
|
@@ -2129,25 +2396,25 @@ function CmsRowLoader(_ref16) {
|
|
|
2129
2396
|
|
|
2130
2397
|
case 2:
|
|
2131
2398
|
if (row) {
|
|
2132
|
-
|
|
2399
|
+
_context4.next = 4;
|
|
2133
2400
|
break;
|
|
2134
2401
|
}
|
|
2135
2402
|
|
|
2136
2403
|
throw new Error("You must specify an entry name to fetch.");
|
|
2137
2404
|
|
|
2138
2405
|
case 4:
|
|
2139
|
-
|
|
2406
|
+
_context4.next = 6;
|
|
2140
2407
|
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2141
2408
|
|
|
2142
2409
|
case 6:
|
|
2143
|
-
return
|
|
2410
|
+
return _context4.abrupt("return", _context4.sent);
|
|
2144
2411
|
|
|
2145
2412
|
case 7:
|
|
2146
2413
|
case "end":
|
|
2147
|
-
return
|
|
2414
|
+
return _context4.stop();
|
|
2148
2415
|
}
|
|
2149
2416
|
}
|
|
2150
|
-
},
|
|
2417
|
+
}, _callee4);
|
|
2151
2418
|
})));
|
|
2152
2419
|
return renderMaybeData(maybeData, function (row) {
|
|
2153
2420
|
return React.createElement(RowProvider, {
|
|
@@ -2178,11 +2445,11 @@ function registerAll(loader) {
|
|
|
2178
2445
|
}
|
|
2179
2446
|
};
|
|
2180
2447
|
|
|
2181
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2448
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta); // _registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2449
|
+
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2182
2450
|
|
|
2183
|
-
_registerComponent(CmsQueryLoader, cmsQueryLoaderMeta);
|
|
2184
2451
|
|
|
2185
|
-
_registerComponent(
|
|
2452
|
+
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2186
2453
|
|
|
2187
2454
|
_registerComponent(CmsRowField, cmsRowFieldMeta);
|
|
2188
2455
|
|
|
@@ -2190,10 +2457,9 @@ function registerAll(loader) {
|
|
|
2190
2457
|
|
|
2191
2458
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2192
2459
|
|
|
2193
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2460
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta); // _registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2194
2461
|
|
|
2195
|
-
_registerComponent(CmsRowLoader, cmsRowLoaderMeta);
|
|
2196
2462
|
}
|
|
2197
2463
|
|
|
2198
|
-
export { CmsCredentialsProvider, CmsQueryLoader, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, CmsRowLoader, CmsRowRepeater, cmsCredentialsProviderMeta, cmsQueryLoaderMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, cmsRowLoaderMeta, cmsRowRepeaterMeta, registerAll };
|
|
2464
|
+
export { CmsCredentialsProvider, CmsQueryLoader, CmsQueryRepeater, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, CmsRowLoader, CmsRowRepeater, cmsCredentialsProviderMeta, cmsQueryLoaderMeta, cmsQueryRepeaterMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, cmsRowLoaderMeta, cmsRowRepeaterMeta, registerAll };
|
|
2199
2465
|
//# sourceMappingURL=plasmic-cms.esm.js.map
|