@plasmicpkgs/plasmic-cms 0.0.48 → 0.0.50
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 +2 -24
- package/dist/plasmic-cms.cjs.development.js +88 -457
- 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 +89 -452
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/plasmic-cms.esm.js
CHANGED
|
@@ -165,44 +165,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
165
165
|
return target;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
169
|
-
if (!o) return;
|
|
170
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
171
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
172
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
173
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
174
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _arrayLikeToArray(arr, len) {
|
|
178
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
179
|
-
|
|
180
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
181
|
-
|
|
182
|
-
return arr2;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
186
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
187
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
188
|
-
|
|
189
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
190
|
-
if (it) o = it;
|
|
191
|
-
var i = 0;
|
|
192
|
-
return function () {
|
|
193
|
-
if (i >= o.length) return {
|
|
194
|
-
done: true
|
|
195
|
-
};
|
|
196
|
-
return {
|
|
197
|
-
done: false,
|
|
198
|
-
value: o[i++]
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
204
|
-
}
|
|
205
|
-
|
|
206
168
|
function createCommonjsModule(fn, module) {
|
|
207
169
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
208
170
|
}
|
|
@@ -1216,55 +1178,6 @@ function TablesProvider(_ref2) {
|
|
|
1216
1178
|
data: tables
|
|
1217
1179
|
}, children);
|
|
1218
1180
|
}
|
|
1219
|
-
function useQueryResults(table) {
|
|
1220
|
-
var env = useDataEnv();
|
|
1221
|
-
var tables = useTables();
|
|
1222
|
-
|
|
1223
|
-
if (!env) {
|
|
1224
|
-
return undefined;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
if (table) {
|
|
1228
|
-
var _env$mkQueryContextKe;
|
|
1229
|
-
|
|
1230
|
-
return {
|
|
1231
|
-
table: table,
|
|
1232
|
-
rows: (_env$mkQueryContextKe = env[mkQueryContextKey(table)]) != null ? _env$mkQueryContextKe : []
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
if (!tables) {
|
|
1237
|
-
return undefined;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
var matchingKeys = getClosestMatchingKeys(env, queryResultPrefix);
|
|
1241
|
-
|
|
1242
|
-
var _loop = function _loop() {
|
|
1243
|
-
var key = _step.value;
|
|
1244
|
-
var inferredTable = tables.find(function (t) {
|
|
1245
|
-
return mkQueryContextKey(t.identifier) === key;
|
|
1246
|
-
});
|
|
1247
|
-
|
|
1248
|
-
if (inferredTable) {
|
|
1249
|
-
var _env$key;
|
|
1250
|
-
|
|
1251
|
-
return {
|
|
1252
|
-
v: {
|
|
1253
|
-
table: inferredTable.identifier,
|
|
1254
|
-
rows: (_env$key = env[key]) != null ? _env$key : []
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
|
-
for (var _iterator = _createForOfIteratorHelperLoose(matchingKeys), _step; !(_step = _iterator()).done;) {
|
|
1261
|
-
var _ret = _loop();
|
|
1262
|
-
|
|
1263
|
-
if (typeof _ret === "object") return _ret.v;
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
return undefined;
|
|
1267
|
-
}
|
|
1268
1181
|
|
|
1269
1182
|
function getClosestMatchingKeys(env, prefix) {
|
|
1270
1183
|
return [].concat(Object.keys(env).reverse()).filter(function (k) {
|
|
@@ -1376,13 +1289,6 @@ var _excluded = ["children"],
|
|
|
1376
1289
|
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1377
1290
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1378
1291
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1379
|
-
var fetcherComponentPropMetas = {
|
|
1380
|
-
hideIfNotFound: {
|
|
1381
|
-
type: "boolean",
|
|
1382
|
-
defaultValue: false,
|
|
1383
|
-
description: "Whether to show an error if no result is found"
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
1292
|
|
|
1387
1293
|
function renderMaybeData(maybeData, renderFn, loaderProps, loadingMessage, forceLoadingState) {
|
|
1388
1294
|
if ("error" in maybeData) {
|
|
@@ -1410,6 +1316,7 @@ var defaultHost = "https://studio.plasmic.app";
|
|
|
1410
1316
|
var cmsCredentialsProviderMeta = {
|
|
1411
1317
|
name: componentPrefix + "-credentials-provider",
|
|
1412
1318
|
displayName: "CMS Credentials Provider",
|
|
1319
|
+
description: "Find your CMS in the [dashboard](https://studio.plasmic.app), and go to the Settings tab for the ID and token.",
|
|
1413
1320
|
importName: "CmsCredentialsProvider",
|
|
1414
1321
|
importPath: modulePath,
|
|
1415
1322
|
props: {
|
|
@@ -1489,201 +1396,22 @@ function TablesFetcher(_ref2) {
|
|
|
1489
1396
|
});
|
|
1490
1397
|
}
|
|
1491
1398
|
|
|
1492
|
-
var cmsQueryLoaderMeta = {
|
|
1493
|
-
name: componentPrefix + "-query-loader",
|
|
1494
|
-
displayName: "CMS Data Loader",
|
|
1495
|
-
importName: "CmsQueryLoader",
|
|
1496
|
-
importPath: modulePath,
|
|
1497
|
-
props: {
|
|
1498
|
-
children: {
|
|
1499
|
-
type: "slot",
|
|
1500
|
-
defaultValue: {
|
|
1501
|
-
type: "component",
|
|
1502
|
-
name: componentPrefix + "-row-repeater"
|
|
1503
|
-
}
|
|
1504
|
-
},
|
|
1505
|
-
table: {
|
|
1506
|
-
type: "choice",
|
|
1507
|
-
displayName: "Model",
|
|
1508
|
-
description: "CMS model (table) to query.",
|
|
1509
|
-
options: function options(_, ctx) {
|
|
1510
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1511
|
-
}
|
|
1512
|
-
},
|
|
1513
|
-
useDraft: {
|
|
1514
|
-
type: "boolean",
|
|
1515
|
-
displayName: "Use drafts?",
|
|
1516
|
-
description: "If set, also query unpublished content.",
|
|
1517
|
-
defaultValue: false
|
|
1518
|
-
},
|
|
1519
|
-
where: {
|
|
1520
|
-
type: "object",
|
|
1521
|
-
displayName: "Filter",
|
|
1522
|
-
description: "Filter clause, in JSON format."
|
|
1523
|
-
},
|
|
1524
|
-
orderBy: {
|
|
1525
|
-
type: "choice",
|
|
1526
|
-
displayName: "Order by",
|
|
1527
|
-
description: "Field to order by.",
|
|
1528
|
-
options: function options(_ref4, ctx) {
|
|
1529
|
-
var table = _ref4.table;
|
|
1530
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, table);
|
|
1531
|
-
}
|
|
1532
|
-
},
|
|
1533
|
-
desc: {
|
|
1534
|
-
type: "boolean",
|
|
1535
|
-
displayName: "Sort descending?",
|
|
1536
|
-
description: 'Sort descending by "Order by" field.',
|
|
1537
|
-
defaultValue: false
|
|
1538
|
-
},
|
|
1539
|
-
limit: {
|
|
1540
|
-
type: "number",
|
|
1541
|
-
displayName: "Limit",
|
|
1542
|
-
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1543
|
-
defaultValue: 0
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
};
|
|
1547
|
-
|
|
1548
1399
|
function isDatabaseConfigured(config) {
|
|
1549
1400
|
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1550
1401
|
}
|
|
1551
1402
|
|
|
1552
|
-
function CmsQueryLoader(_ref5) {
|
|
1553
|
-
var table = _ref5.table,
|
|
1554
|
-
children = _ref5.children,
|
|
1555
|
-
setControlContextData = _ref5.setControlContextData,
|
|
1556
|
-
where = _ref5.where,
|
|
1557
|
-
useDraft = _ref5.useDraft,
|
|
1558
|
-
orderBy = _ref5.orderBy,
|
|
1559
|
-
desc = _ref5.desc,
|
|
1560
|
-
limit = _ref5.limit;
|
|
1561
|
-
var databaseConfig = useDatabase();
|
|
1562
|
-
var tables = useTables();
|
|
1563
|
-
|
|
1564
|
-
if (tables) {
|
|
1565
|
-
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1566
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
1567
|
-
tables: tables
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
var params = {
|
|
1572
|
-
where: where,
|
|
1573
|
-
useDraft: useDraft,
|
|
1574
|
-
orderBy: orderBy,
|
|
1575
|
-
desc: desc,
|
|
1576
|
-
limit: limit
|
|
1577
|
-
};
|
|
1578
|
-
var cacheKey = JSON.stringify({
|
|
1579
|
-
component: "CmsQueryLoader",
|
|
1580
|
-
table: table,
|
|
1581
|
-
databaseConfig: databaseConfig,
|
|
1582
|
-
params: params
|
|
1583
|
-
});
|
|
1584
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1585
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1586
|
-
while (1) {
|
|
1587
|
-
switch (_context2.prev = _context2.next) {
|
|
1588
|
-
case 0:
|
|
1589
|
-
if (isDatabaseConfigured(databaseConfig)) {
|
|
1590
|
-
_context2.next = 2;
|
|
1591
|
-
break;
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
throw new Error("You must specify the CMS ID and API key");
|
|
1595
|
-
|
|
1596
|
-
case 2:
|
|
1597
|
-
if (table) {
|
|
1598
|
-
_context2.next = 6;
|
|
1599
|
-
break;
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
throw new Error("You must select a model to query");
|
|
1603
|
-
|
|
1604
|
-
case 6:
|
|
1605
|
-
if (!(tables && !tables.find(function (t) {
|
|
1606
|
-
return t.identifier === table;
|
|
1607
|
-
}))) {
|
|
1608
|
-
_context2.next = 8;
|
|
1609
|
-
break;
|
|
1610
|
-
}
|
|
1611
|
-
|
|
1612
|
-
throw new Error("There is no model called \"" + table + "\"");
|
|
1613
|
-
|
|
1614
|
-
case 8:
|
|
1615
|
-
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1616
|
-
|
|
1617
|
-
case 9:
|
|
1618
|
-
case "end":
|
|
1619
|
-
return _context2.stop();
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
}, _callee2);
|
|
1623
|
-
})));
|
|
1624
|
-
return renderMaybeData(maybeData, function (rows) {
|
|
1625
|
-
return React.createElement(QueryResultProvider, {
|
|
1626
|
-
table: table,
|
|
1627
|
-
rows: rows
|
|
1628
|
-
}, children);
|
|
1629
|
-
}, {
|
|
1630
|
-
hideIfNotFound: false
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
var cmsRowRepeaterMeta = {
|
|
1634
|
-
name: componentPrefix + "-row-repeater",
|
|
1635
|
-
displayName: "CMS Entry Repeater",
|
|
1636
|
-
importName: "CmsRowRepeater",
|
|
1637
|
-
importPath: modulePath,
|
|
1638
|
-
props: {
|
|
1639
|
-
children: {
|
|
1640
|
-
type: "slot",
|
|
1641
|
-
defaultValue: {
|
|
1642
|
-
type: "component",
|
|
1643
|
-
name: componentPrefix + "-row-field"
|
|
1644
|
-
}
|
|
1645
|
-
},
|
|
1646
|
-
table: {
|
|
1647
|
-
type: "choice",
|
|
1648
|
-
displayName: "Model",
|
|
1649
|
-
description: "CMS model (table) to use.",
|
|
1650
|
-
options: function options(_, ctx) {
|
|
1651
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
function CmsRowRepeater(_ref7) {
|
|
1657
|
-
var table = _ref7.table,
|
|
1658
|
-
children = _ref7.children,
|
|
1659
|
-
setControlContextData = _ref7.setControlContextData;
|
|
1660
|
-
var tables = useTables();
|
|
1661
|
-
|
|
1662
|
-
if (tables) {
|
|
1663
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
1664
|
-
tables: tables
|
|
1665
|
-
});
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
var res = useQueryResults(table);
|
|
1669
|
-
|
|
1670
|
-
if (!res) {
|
|
1671
|
-
return React.createElement("div", null, "Error: No CMS query result to repeat.");
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
return React.createElement(React.Fragment, null, res.rows.map(function (row, index) {
|
|
1675
|
-
return React.createElement(RowProvider, {
|
|
1676
|
-
table: res.table,
|
|
1677
|
-
row: row
|
|
1678
|
-
}, repeatedElement(index === 0, children));
|
|
1679
|
-
}));
|
|
1680
|
-
}
|
|
1681
1403
|
var cmsQueryRepeaterMeta = {
|
|
1682
1404
|
name: componentPrefix + "-query-repeater",
|
|
1683
1405
|
displayName: "CMS Data Loader",
|
|
1684
1406
|
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1685
1407
|
importName: "CmsQueryRepeater",
|
|
1686
1408
|
importPath: modulePath,
|
|
1409
|
+
defaultStyles: {
|
|
1410
|
+
display: "flex",
|
|
1411
|
+
width: "stretch",
|
|
1412
|
+
maxWidth: "100%",
|
|
1413
|
+
flexDirection: "column"
|
|
1414
|
+
},
|
|
1687
1415
|
props: {
|
|
1688
1416
|
children: {
|
|
1689
1417
|
type: "slot",
|
|
@@ -1711,7 +1439,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1711
1439
|
type: "boolean",
|
|
1712
1440
|
displayName: "Use drafts?",
|
|
1713
1441
|
description: "If set, also query unpublished content.",
|
|
1714
|
-
defaultValue: false
|
|
1442
|
+
defaultValue: false,
|
|
1443
|
+
hidden: function hidden() {
|
|
1444
|
+
return true;
|
|
1445
|
+
}
|
|
1715
1446
|
},
|
|
1716
1447
|
where: {
|
|
1717
1448
|
type: "object",
|
|
@@ -1745,7 +1476,7 @@ var cmsQueryRepeaterMeta = {
|
|
|
1745
1476
|
type: "slot",
|
|
1746
1477
|
defaultValue: {
|
|
1747
1478
|
type: "text",
|
|
1748
|
-
value: "No matching entries found."
|
|
1479
|
+
value: "No matching published entries found."
|
|
1749
1480
|
}
|
|
1750
1481
|
},
|
|
1751
1482
|
forceEmptyState: {
|
|
@@ -1769,19 +1500,20 @@ var cmsQueryRepeaterMeta = {
|
|
|
1769
1500
|
}
|
|
1770
1501
|
}
|
|
1771
1502
|
};
|
|
1772
|
-
function CmsQueryRepeater(
|
|
1773
|
-
var table =
|
|
1774
|
-
children =
|
|
1775
|
-
setControlContextData =
|
|
1776
|
-
where =
|
|
1777
|
-
useDraft =
|
|
1778
|
-
orderBy =
|
|
1779
|
-
desc =
|
|
1780
|
-
limit =
|
|
1781
|
-
emptyMessage =
|
|
1782
|
-
forceEmptyState =
|
|
1783
|
-
loadingMessage =
|
|
1784
|
-
forceLoadingState =
|
|
1503
|
+
function CmsQueryRepeater(_ref4) {
|
|
1504
|
+
var table = _ref4.table,
|
|
1505
|
+
children = _ref4.children,
|
|
1506
|
+
setControlContextData = _ref4.setControlContextData,
|
|
1507
|
+
where = _ref4.where,
|
|
1508
|
+
useDraft = _ref4.useDraft,
|
|
1509
|
+
orderBy = _ref4.orderBy,
|
|
1510
|
+
desc = _ref4.desc,
|
|
1511
|
+
limit = _ref4.limit,
|
|
1512
|
+
emptyMessage = _ref4.emptyMessage,
|
|
1513
|
+
forceEmptyState = _ref4.forceEmptyState,
|
|
1514
|
+
loadingMessage = _ref4.loadingMessage,
|
|
1515
|
+
forceLoadingState = _ref4.forceLoadingState,
|
|
1516
|
+
className = _ref4.className;
|
|
1785
1517
|
var databaseConfig = useDatabase();
|
|
1786
1518
|
var tables = useTables();
|
|
1787
1519
|
var params = {
|
|
@@ -1810,13 +1542,13 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1810
1542
|
});
|
|
1811
1543
|
}
|
|
1812
1544
|
|
|
1813
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1814
|
-
return runtime_1.wrap(function
|
|
1545
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1546
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1815
1547
|
while (1) {
|
|
1816
|
-
switch (
|
|
1548
|
+
switch (_context2.prev = _context2.next) {
|
|
1817
1549
|
case 0:
|
|
1818
1550
|
if (isDatabaseConfigured(databaseConfig)) {
|
|
1819
|
-
|
|
1551
|
+
_context2.next = 2;
|
|
1820
1552
|
break;
|
|
1821
1553
|
}
|
|
1822
1554
|
|
|
@@ -1824,7 +1556,7 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1824
1556
|
|
|
1825
1557
|
case 2:
|
|
1826
1558
|
if (table) {
|
|
1827
|
-
|
|
1559
|
+
_context2.next = 6;
|
|
1828
1560
|
break;
|
|
1829
1561
|
}
|
|
1830
1562
|
|
|
@@ -1834,25 +1566,30 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1834
1566
|
if (!(tables && !tables.find(function (t) {
|
|
1835
1567
|
return t.identifier === table;
|
|
1836
1568
|
}))) {
|
|
1837
|
-
|
|
1569
|
+
_context2.next = 10;
|
|
1838
1570
|
break;
|
|
1839
1571
|
}
|
|
1840
1572
|
|
|
1841
1573
|
throw new Error("There is no model called \"" + table + "\"");
|
|
1842
1574
|
|
|
1843
1575
|
case 10:
|
|
1844
|
-
return
|
|
1576
|
+
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1845
1577
|
|
|
1846
1578
|
case 11:
|
|
1847
1579
|
case "end":
|
|
1848
|
-
return
|
|
1580
|
+
return _context2.stop();
|
|
1849
1581
|
}
|
|
1850
1582
|
}
|
|
1851
|
-
},
|
|
1583
|
+
}, _callee2);
|
|
1852
1584
|
})));
|
|
1853
|
-
return
|
|
1585
|
+
return React.createElement("div", {
|
|
1586
|
+
className: className
|
|
1587
|
+
}, renderMaybeData(maybeData, function (rows) {
|
|
1854
1588
|
if (rows.length === 0 || forceEmptyState) {
|
|
1855
|
-
return React.createElement(
|
|
1589
|
+
return React.createElement(QueryResultProvider, {
|
|
1590
|
+
table: table,
|
|
1591
|
+
rows: rows
|
|
1592
|
+
}, emptyMessage);
|
|
1856
1593
|
}
|
|
1857
1594
|
|
|
1858
1595
|
return React.createElement(QueryResultProvider, {
|
|
@@ -1866,7 +1603,7 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1866
1603
|
}));
|
|
1867
1604
|
}, {
|
|
1868
1605
|
hideIfNotFound: false
|
|
1869
|
-
}, loadingMessage, forceLoadingState);
|
|
1606
|
+
}, loadingMessage, forceLoadingState));
|
|
1870
1607
|
}
|
|
1871
1608
|
var cmsRowFieldMeta = {
|
|
1872
1609
|
name: componentPrefix + "-row-field",
|
|
@@ -1889,10 +1626,10 @@ var cmsRowFieldMeta = {
|
|
|
1889
1626
|
type: "choice",
|
|
1890
1627
|
displayName: "Field",
|
|
1891
1628
|
description: "Field (from model schema) to use.",
|
|
1892
|
-
options: function options(
|
|
1629
|
+
options: function options(_ref6, ctx) {
|
|
1893
1630
|
var _ctx$table;
|
|
1894
1631
|
|
|
1895
|
-
var table =
|
|
1632
|
+
var table = _ref6.table;
|
|
1896
1633
|
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"]);
|
|
1897
1634
|
},
|
|
1898
1635
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -1904,8 +1641,8 @@ var cmsRowFieldMeta = {
|
|
|
1904
1641
|
dateFormat: {
|
|
1905
1642
|
type: "choice",
|
|
1906
1643
|
displayName: "Date Format",
|
|
1907
|
-
hidden: function hidden(
|
|
1908
|
-
var field =
|
|
1644
|
+
hidden: function hidden(_ref7, ctx) {
|
|
1645
|
+
var field = _ref7.field;
|
|
1909
1646
|
|
|
1910
1647
|
if (!ctx) {
|
|
1911
1648
|
return true;
|
|
@@ -1974,15 +1711,15 @@ var cmsRowFieldMeta = {
|
|
|
1974
1711
|
}
|
|
1975
1712
|
}
|
|
1976
1713
|
};
|
|
1977
|
-
function CmsRowField(
|
|
1714
|
+
function CmsRowField(_ref8) {
|
|
1978
1715
|
var _res$row$data;
|
|
1979
1716
|
|
|
1980
|
-
var className =
|
|
1981
|
-
table =
|
|
1982
|
-
field =
|
|
1983
|
-
dateFormat =
|
|
1984
|
-
setControlContextData =
|
|
1985
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1717
|
+
var className = _ref8.className,
|
|
1718
|
+
table = _ref8.table,
|
|
1719
|
+
field = _ref8.field,
|
|
1720
|
+
dateFormat = _ref8.dateFormat,
|
|
1721
|
+
setControlContextData = _ref8.setControlContextData,
|
|
1722
|
+
rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
1986
1723
|
|
|
1987
1724
|
var tables = useTablesWithDataLoaded();
|
|
1988
1725
|
var res = useRow(tables, table);
|
|
@@ -2079,8 +1816,11 @@ function renderValue(value, type, props) {
|
|
|
2079
1816
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
2080
1817
|
return React.createElement("img", Object.assign({
|
|
2081
1818
|
src: value.url,
|
|
2082
|
-
width: value.imageMeta.
|
|
2083
|
-
height: value.imageMeta.height
|
|
1819
|
+
width: value.imageMeta.width,
|
|
1820
|
+
height: value.imageMeta.height,
|
|
1821
|
+
style: {
|
|
1822
|
+
objectFit: "cover"
|
|
1823
|
+
}
|
|
2084
1824
|
}, props));
|
|
2085
1825
|
}
|
|
2086
1826
|
|
|
@@ -2120,10 +1860,10 @@ var cmsRowLinkMeta = {
|
|
|
2120
1860
|
type: "choice",
|
|
2121
1861
|
displayName: "Field",
|
|
2122
1862
|
description: "Field (from model schema) to use.",
|
|
2123
|
-
options: function options(
|
|
1863
|
+
options: function options(_ref9, ctx) {
|
|
2124
1864
|
var _ctx$table2;
|
|
2125
1865
|
|
|
2126
|
-
var table =
|
|
1866
|
+
var table = _ref9.table;
|
|
2127
1867
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
2128
1868
|
},
|
|
2129
1869
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2150,16 +1890,16 @@ var cmsRowLinkMeta = {
|
|
|
2150
1890
|
}
|
|
2151
1891
|
}
|
|
2152
1892
|
};
|
|
2153
|
-
function CmsRowLink(
|
|
1893
|
+
function CmsRowLink(_ref10) {
|
|
2154
1894
|
var _res$row$data2;
|
|
2155
1895
|
|
|
2156
|
-
var table =
|
|
2157
|
-
field =
|
|
2158
|
-
hrefProp =
|
|
2159
|
-
children =
|
|
2160
|
-
setControlContextData =
|
|
2161
|
-
prefix =
|
|
2162
|
-
suffix =
|
|
1896
|
+
var table = _ref10.table,
|
|
1897
|
+
field = _ref10.field,
|
|
1898
|
+
hrefProp = _ref10.hrefProp,
|
|
1899
|
+
children = _ref10.children,
|
|
1900
|
+
setControlContextData = _ref10.setControlContextData,
|
|
1901
|
+
prefix = _ref10.prefix,
|
|
1902
|
+
suffix = _ref10.suffix;
|
|
2163
1903
|
var tables = useTablesWithDataLoaded();
|
|
2164
1904
|
var res = useRow(tables, table);
|
|
2165
1905
|
|
|
@@ -2232,10 +1972,10 @@ var cmsRowImageMeta = {
|
|
|
2232
1972
|
type: "choice",
|
|
2233
1973
|
displayName: "Field",
|
|
2234
1974
|
description: "Field (from model schema) to use.",
|
|
2235
|
-
options: function options(
|
|
1975
|
+
options: function options(_ref11, ctx) {
|
|
2236
1976
|
var _ctx$table3;
|
|
2237
1977
|
|
|
2238
|
-
var table =
|
|
1978
|
+
var table = _ref11.table;
|
|
2239
1979
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["image"]);
|
|
2240
1980
|
},
|
|
2241
1981
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2252,14 +1992,14 @@ var cmsRowImageMeta = {
|
|
|
2252
1992
|
}
|
|
2253
1993
|
}
|
|
2254
1994
|
};
|
|
2255
|
-
function CmsRowImage(
|
|
1995
|
+
function CmsRowImage(_ref12) {
|
|
2256
1996
|
var _res$row$data3;
|
|
2257
1997
|
|
|
2258
|
-
var table =
|
|
2259
|
-
field =
|
|
2260
|
-
srcProp =
|
|
2261
|
-
children =
|
|
2262
|
-
setControlContextData =
|
|
1998
|
+
var table = _ref12.table,
|
|
1999
|
+
field = _ref12.field,
|
|
2000
|
+
srcProp = _ref12.srcProp,
|
|
2001
|
+
children = _ref12.children,
|
|
2002
|
+
setControlContextData = _ref12.setControlContextData;
|
|
2263
2003
|
var tables = useTablesWithDataLoaded();
|
|
2264
2004
|
var res = useRow(tables, table);
|
|
2265
2005
|
|
|
@@ -2334,10 +2074,10 @@ var cmsRowFieldValueMeta = {
|
|
|
2334
2074
|
type: "choice",
|
|
2335
2075
|
displayName: "Field",
|
|
2336
2076
|
description: "Field (from model schema) to use.",
|
|
2337
|
-
options: function options(
|
|
2077
|
+
options: function options(_ref13, ctx) {
|
|
2338
2078
|
var _ctx$table4;
|
|
2339
2079
|
|
|
2340
|
-
var table =
|
|
2080
|
+
var table = _ref13.table;
|
|
2341
2081
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2342
2082
|
},
|
|
2343
2083
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2354,15 +2094,15 @@ var cmsRowFieldValueMeta = {
|
|
|
2354
2094
|
}
|
|
2355
2095
|
}
|
|
2356
2096
|
};
|
|
2357
|
-
function CmsRowFieldValue(
|
|
2097
|
+
function CmsRowFieldValue(_ref14) {
|
|
2358
2098
|
var _res$row$data4;
|
|
2359
2099
|
|
|
2360
|
-
var table =
|
|
2361
|
-
field =
|
|
2362
|
-
valueProp =
|
|
2363
|
-
children =
|
|
2364
|
-
setControlContextData =
|
|
2365
|
-
rest = _objectWithoutPropertiesLoose(
|
|
2100
|
+
var table = _ref14.table,
|
|
2101
|
+
field = _ref14.field,
|
|
2102
|
+
valueProp = _ref14.valueProp,
|
|
2103
|
+
children = _ref14.children,
|
|
2104
|
+
setControlContextData = _ref14.setControlContextData,
|
|
2105
|
+
rest = _objectWithoutPropertiesLoose(_ref14, _excluded3);
|
|
2366
2106
|
|
|
2367
2107
|
var tables = useTablesWithDataLoaded();
|
|
2368
2108
|
var res = useRow(tables, table);
|
|
@@ -2404,106 +2144,6 @@ function CmsRowFieldValue(_ref18) {
|
|
|
2404
2144
|
});
|
|
2405
2145
|
return React.createElement(React.Fragment, null, childrenWithProps);
|
|
2406
2146
|
}
|
|
2407
|
-
var cmsRowLoaderMeta = {
|
|
2408
|
-
name: componentPrefix + "-row-loader",
|
|
2409
|
-
displayName: "CMS Row Loader",
|
|
2410
|
-
importName: "CmsRowLoader",
|
|
2411
|
-
importPath: modulePath,
|
|
2412
|
-
props: /*#__PURE__*/_extends({
|
|
2413
|
-
children: {
|
|
2414
|
-
type: "slot",
|
|
2415
|
-
defaultValue: {
|
|
2416
|
-
type: "component",
|
|
2417
|
-
name: componentPrefix + "-row-field"
|
|
2418
|
-
}
|
|
2419
|
-
},
|
|
2420
|
-
row: {
|
|
2421
|
-
type: "string",
|
|
2422
|
-
displayName: "Entry ID",
|
|
2423
|
-
description: "Row identifier to query."
|
|
2424
|
-
},
|
|
2425
|
-
table: {
|
|
2426
|
-
type: "choice",
|
|
2427
|
-
displayName: "Model",
|
|
2428
|
-
description: "CMS model (table) to query.",
|
|
2429
|
-
options: function options(_, ctx) {
|
|
2430
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
2431
|
-
}
|
|
2432
|
-
},
|
|
2433
|
-
useDraft: {
|
|
2434
|
-
type: "boolean",
|
|
2435
|
-
displayName: "Use drafts?",
|
|
2436
|
-
description: "If set, also query unpublished content.",
|
|
2437
|
-
defaultValue: false
|
|
2438
|
-
}
|
|
2439
|
-
}, fetcherComponentPropMetas)
|
|
2440
|
-
};
|
|
2441
|
-
function CmsRowLoader(_ref19) {
|
|
2442
|
-
var table = _ref19.table,
|
|
2443
|
-
row = _ref19.row,
|
|
2444
|
-
children = _ref19.children,
|
|
2445
|
-
useDraft = _ref19.useDraft,
|
|
2446
|
-
hideIfNotFound = _ref19.hideIfNotFound,
|
|
2447
|
-
setControlContextData = _ref19.setControlContextData;
|
|
2448
|
-
var databaseConfig = useDatabase();
|
|
2449
|
-
var tables = useTables();
|
|
2450
|
-
|
|
2451
|
-
if (tables) {
|
|
2452
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2453
|
-
tables: tables
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
var cacheKey = JSON.stringify({
|
|
2458
|
-
component: "CmsRowLoader",
|
|
2459
|
-
table: table,
|
|
2460
|
-
row: row,
|
|
2461
|
-
databaseConfig: databaseConfig,
|
|
2462
|
-
useDraft: useDraft
|
|
2463
|
-
});
|
|
2464
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2465
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2466
|
-
while (1) {
|
|
2467
|
-
switch (_context4.prev = _context4.next) {
|
|
2468
|
-
case 0:
|
|
2469
|
-
if (table) {
|
|
2470
|
-
_context4.next = 2;
|
|
2471
|
-
break;
|
|
2472
|
-
}
|
|
2473
|
-
|
|
2474
|
-
throw new Error("You must specify a model to fetch from.");
|
|
2475
|
-
|
|
2476
|
-
case 2:
|
|
2477
|
-
if (row) {
|
|
2478
|
-
_context4.next = 4;
|
|
2479
|
-
break;
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
throw new Error("You must specify an entry name to fetch.");
|
|
2483
|
-
|
|
2484
|
-
case 4:
|
|
2485
|
-
_context4.next = 6;
|
|
2486
|
-
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2487
|
-
|
|
2488
|
-
case 6:
|
|
2489
|
-
return _context4.abrupt("return", _context4.sent);
|
|
2490
|
-
|
|
2491
|
-
case 7:
|
|
2492
|
-
case "end":
|
|
2493
|
-
return _context4.stop();
|
|
2494
|
-
}
|
|
2495
|
-
}
|
|
2496
|
-
}, _callee4);
|
|
2497
|
-
})));
|
|
2498
|
-
return renderMaybeData(maybeData, function (row) {
|
|
2499
|
-
return React.createElement(RowProvider, {
|
|
2500
|
-
table: table,
|
|
2501
|
-
row: row
|
|
2502
|
-
}, children);
|
|
2503
|
-
}, {
|
|
2504
|
-
hideIfNotFound: hideIfNotFound
|
|
2505
|
-
});
|
|
2506
|
-
}
|
|
2507
2147
|
|
|
2508
2148
|
function registerAll(loader) {
|
|
2509
2149
|
//const registerContext = loader?.registerContext ?? hostRegisterContext;
|
|
@@ -2524,9 +2164,7 @@ function registerAll(loader) {
|
|
|
2524
2164
|
}
|
|
2525
2165
|
};
|
|
2526
2166
|
|
|
2527
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2528
|
-
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2529
|
-
|
|
2167
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2530
2168
|
|
|
2531
2169
|
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2532
2170
|
|
|
@@ -2536,9 +2174,8 @@ function registerAll(loader) {
|
|
|
2536
2174
|
|
|
2537
2175
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2538
2176
|
|
|
2539
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2540
|
-
|
|
2177
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2541
2178
|
}
|
|
2542
2179
|
|
|
2543
|
-
export { CmsCredentialsProvider,
|
|
2180
|
+
export { CmsCredentialsProvider, CmsQueryRepeater, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, cmsCredentialsProviderMeta, cmsQueryRepeaterMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, registerAll };
|
|
2544
2181
|
//# sourceMappingURL=plasmic-cms.esm.js.map
|