@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
|
@@ -171,44 +171,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
171
171
|
return target;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
175
|
-
if (!o) return;
|
|
176
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
177
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
178
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
179
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
180
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function _arrayLikeToArray(arr, len) {
|
|
184
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
185
|
-
|
|
186
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
187
|
-
|
|
188
|
-
return arr2;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
192
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
193
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
194
|
-
|
|
195
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
196
|
-
if (it) o = it;
|
|
197
|
-
var i = 0;
|
|
198
|
-
return function () {
|
|
199
|
-
if (i >= o.length) return {
|
|
200
|
-
done: true
|
|
201
|
-
};
|
|
202
|
-
return {
|
|
203
|
-
done: false,
|
|
204
|
-
value: o[i++]
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
210
|
-
}
|
|
211
|
-
|
|
212
174
|
function createCommonjsModule(fn, module) {
|
|
213
175
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
214
176
|
}
|
|
@@ -1222,55 +1184,6 @@ function TablesProvider(_ref2) {
|
|
|
1222
1184
|
data: tables
|
|
1223
1185
|
}, children);
|
|
1224
1186
|
}
|
|
1225
|
-
function useQueryResults(table) {
|
|
1226
|
-
var env = host.useDataEnv();
|
|
1227
|
-
var tables = useTables();
|
|
1228
|
-
|
|
1229
|
-
if (!env) {
|
|
1230
|
-
return undefined;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
if (table) {
|
|
1234
|
-
var _env$mkQueryContextKe;
|
|
1235
|
-
|
|
1236
|
-
return {
|
|
1237
|
-
table: table,
|
|
1238
|
-
rows: (_env$mkQueryContextKe = env[mkQueryContextKey(table)]) != null ? _env$mkQueryContextKe : []
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
if (!tables) {
|
|
1243
|
-
return undefined;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
var matchingKeys = getClosestMatchingKeys(env, queryResultPrefix);
|
|
1247
|
-
|
|
1248
|
-
var _loop = function _loop() {
|
|
1249
|
-
var key = _step.value;
|
|
1250
|
-
var inferredTable = tables.find(function (t) {
|
|
1251
|
-
return mkQueryContextKey(t.identifier) === key;
|
|
1252
|
-
});
|
|
1253
|
-
|
|
1254
|
-
if (inferredTable) {
|
|
1255
|
-
var _env$key;
|
|
1256
|
-
|
|
1257
|
-
return {
|
|
1258
|
-
v: {
|
|
1259
|
-
table: inferredTable.identifier,
|
|
1260
|
-
rows: (_env$key = env[key]) != null ? _env$key : []
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
};
|
|
1265
|
-
|
|
1266
|
-
for (var _iterator = _createForOfIteratorHelperLoose(matchingKeys), _step; !(_step = _iterator()).done;) {
|
|
1267
|
-
var _ret = _loop();
|
|
1268
|
-
|
|
1269
|
-
if (typeof _ret === "object") return _ret.v;
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
return undefined;
|
|
1273
|
-
}
|
|
1274
1187
|
|
|
1275
1188
|
function getClosestMatchingKeys(env, prefix) {
|
|
1276
1189
|
return [].concat(Object.keys(env).reverse()).filter(function (k) {
|
|
@@ -1382,13 +1295,6 @@ var _excluded = ["children"],
|
|
|
1382
1295
|
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1383
1296
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1384
1297
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1385
|
-
var fetcherComponentPropMetas = {
|
|
1386
|
-
hideIfNotFound: {
|
|
1387
|
-
type: "boolean",
|
|
1388
|
-
defaultValue: false,
|
|
1389
|
-
description: "Whether to show an error if no result is found"
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
1298
|
|
|
1393
1299
|
function renderMaybeData(maybeData, renderFn, loaderProps, loadingMessage, forceLoadingState) {
|
|
1394
1300
|
if ("error" in maybeData) {
|
|
@@ -1416,6 +1322,7 @@ var defaultHost = "https://studio.plasmic.app";
|
|
|
1416
1322
|
var cmsCredentialsProviderMeta = {
|
|
1417
1323
|
name: componentPrefix + "-credentials-provider",
|
|
1418
1324
|
displayName: "CMS Credentials Provider",
|
|
1325
|
+
description: "Find your CMS in the [dashboard](https://studio.plasmic.app), and go to the Settings tab for the ID and token.",
|
|
1419
1326
|
importName: "CmsCredentialsProvider",
|
|
1420
1327
|
importPath: modulePath,
|
|
1421
1328
|
props: {
|
|
@@ -1495,201 +1402,22 @@ function TablesFetcher(_ref2) {
|
|
|
1495
1402
|
});
|
|
1496
1403
|
}
|
|
1497
1404
|
|
|
1498
|
-
var cmsQueryLoaderMeta = {
|
|
1499
|
-
name: componentPrefix + "-query-loader",
|
|
1500
|
-
displayName: "CMS Data Loader",
|
|
1501
|
-
importName: "CmsQueryLoader",
|
|
1502
|
-
importPath: modulePath,
|
|
1503
|
-
props: {
|
|
1504
|
-
children: {
|
|
1505
|
-
type: "slot",
|
|
1506
|
-
defaultValue: {
|
|
1507
|
-
type: "component",
|
|
1508
|
-
name: componentPrefix + "-row-repeater"
|
|
1509
|
-
}
|
|
1510
|
-
},
|
|
1511
|
-
table: {
|
|
1512
|
-
type: "choice",
|
|
1513
|
-
displayName: "Model",
|
|
1514
|
-
description: "CMS model (table) to query.",
|
|
1515
|
-
options: function options(_, ctx) {
|
|
1516
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1517
|
-
}
|
|
1518
|
-
},
|
|
1519
|
-
useDraft: {
|
|
1520
|
-
type: "boolean",
|
|
1521
|
-
displayName: "Use drafts?",
|
|
1522
|
-
description: "If set, also query unpublished content.",
|
|
1523
|
-
defaultValue: false
|
|
1524
|
-
},
|
|
1525
|
-
where: {
|
|
1526
|
-
type: "object",
|
|
1527
|
-
displayName: "Filter",
|
|
1528
|
-
description: "Filter clause, in JSON format."
|
|
1529
|
-
},
|
|
1530
|
-
orderBy: {
|
|
1531
|
-
type: "choice",
|
|
1532
|
-
displayName: "Order by",
|
|
1533
|
-
description: "Field to order by.",
|
|
1534
|
-
options: function options(_ref4, ctx) {
|
|
1535
|
-
var table = _ref4.table;
|
|
1536
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, table);
|
|
1537
|
-
}
|
|
1538
|
-
},
|
|
1539
|
-
desc: {
|
|
1540
|
-
type: "boolean",
|
|
1541
|
-
displayName: "Sort descending?",
|
|
1542
|
-
description: 'Sort descending by "Order by" field.',
|
|
1543
|
-
defaultValue: false
|
|
1544
|
-
},
|
|
1545
|
-
limit: {
|
|
1546
|
-
type: "number",
|
|
1547
|
-
displayName: "Limit",
|
|
1548
|
-
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1549
|
-
defaultValue: 0
|
|
1550
|
-
}
|
|
1551
|
-
}
|
|
1552
|
-
};
|
|
1553
|
-
|
|
1554
1405
|
function isDatabaseConfigured(config) {
|
|
1555
1406
|
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1556
1407
|
}
|
|
1557
1408
|
|
|
1558
|
-
function CmsQueryLoader(_ref5) {
|
|
1559
|
-
var table = _ref5.table,
|
|
1560
|
-
children = _ref5.children,
|
|
1561
|
-
setControlContextData = _ref5.setControlContextData,
|
|
1562
|
-
where = _ref5.where,
|
|
1563
|
-
useDraft = _ref5.useDraft,
|
|
1564
|
-
orderBy = _ref5.orderBy,
|
|
1565
|
-
desc = _ref5.desc,
|
|
1566
|
-
limit = _ref5.limit;
|
|
1567
|
-
var databaseConfig = useDatabase();
|
|
1568
|
-
var tables = useTables();
|
|
1569
|
-
|
|
1570
|
-
if (tables) {
|
|
1571
|
-
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1572
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
1573
|
-
tables: tables
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
var params = {
|
|
1578
|
-
where: where,
|
|
1579
|
-
useDraft: useDraft,
|
|
1580
|
-
orderBy: orderBy,
|
|
1581
|
-
desc: desc,
|
|
1582
|
-
limit: limit
|
|
1583
|
-
};
|
|
1584
|
-
var cacheKey = JSON.stringify({
|
|
1585
|
-
component: "CmsQueryLoader",
|
|
1586
|
-
table: table,
|
|
1587
|
-
databaseConfig: databaseConfig,
|
|
1588
|
-
params: params
|
|
1589
|
-
});
|
|
1590
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1591
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1592
|
-
while (1) {
|
|
1593
|
-
switch (_context2.prev = _context2.next) {
|
|
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:
|
|
1603
|
-
if (table) {
|
|
1604
|
-
_context2.next = 6;
|
|
1605
|
-
break;
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
throw new Error("You must select a model to query");
|
|
1609
|
-
|
|
1610
|
-
case 6:
|
|
1611
|
-
if (!(tables && !tables.find(function (t) {
|
|
1612
|
-
return t.identifier === table;
|
|
1613
|
-
}))) {
|
|
1614
|
-
_context2.next = 8;
|
|
1615
|
-
break;
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
throw new Error("There is no model called \"" + table + "\"");
|
|
1619
|
-
|
|
1620
|
-
case 8:
|
|
1621
|
-
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1622
|
-
|
|
1623
|
-
case 9:
|
|
1624
|
-
case "end":
|
|
1625
|
-
return _context2.stop();
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
}, _callee2);
|
|
1629
|
-
})));
|
|
1630
|
-
return renderMaybeData(maybeData, function (rows) {
|
|
1631
|
-
return React.createElement(QueryResultProvider, {
|
|
1632
|
-
table: table,
|
|
1633
|
-
rows: rows
|
|
1634
|
-
}, children);
|
|
1635
|
-
}, {
|
|
1636
|
-
hideIfNotFound: false
|
|
1637
|
-
});
|
|
1638
|
-
}
|
|
1639
|
-
var cmsRowRepeaterMeta = {
|
|
1640
|
-
name: componentPrefix + "-row-repeater",
|
|
1641
|
-
displayName: "CMS Entry Repeater",
|
|
1642
|
-
importName: "CmsRowRepeater",
|
|
1643
|
-
importPath: modulePath,
|
|
1644
|
-
props: {
|
|
1645
|
-
children: {
|
|
1646
|
-
type: "slot",
|
|
1647
|
-
defaultValue: {
|
|
1648
|
-
type: "component",
|
|
1649
|
-
name: componentPrefix + "-row-field"
|
|
1650
|
-
}
|
|
1651
|
-
},
|
|
1652
|
-
table: {
|
|
1653
|
-
type: "choice",
|
|
1654
|
-
displayName: "Model",
|
|
1655
|
-
description: "CMS model (table) to use.",
|
|
1656
|
-
options: function options(_, ctx) {
|
|
1657
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
};
|
|
1662
|
-
function CmsRowRepeater(_ref7) {
|
|
1663
|
-
var table = _ref7.table,
|
|
1664
|
-
children = _ref7.children,
|
|
1665
|
-
setControlContextData = _ref7.setControlContextData;
|
|
1666
|
-
var tables = useTables();
|
|
1667
|
-
|
|
1668
|
-
if (tables) {
|
|
1669
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
1670
|
-
tables: tables
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
var res = useQueryResults(table);
|
|
1675
|
-
|
|
1676
|
-
if (!res) {
|
|
1677
|
-
return React.createElement("div", null, "Error: No CMS query result to repeat.");
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
return React.createElement(React.Fragment, null, res.rows.map(function (row, index) {
|
|
1681
|
-
return React.createElement(RowProvider, {
|
|
1682
|
-
table: res.table,
|
|
1683
|
-
row: row
|
|
1684
|
-
}, host.repeatedElement(index === 0, children));
|
|
1685
|
-
}));
|
|
1686
|
-
}
|
|
1687
1409
|
var cmsQueryRepeaterMeta = {
|
|
1688
1410
|
name: componentPrefix + "-query-repeater",
|
|
1689
1411
|
displayName: "CMS Data Loader",
|
|
1690
1412
|
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1691
1413
|
importName: "CmsQueryRepeater",
|
|
1692
1414
|
importPath: modulePath,
|
|
1415
|
+
defaultStyles: {
|
|
1416
|
+
display: "flex",
|
|
1417
|
+
width: "stretch",
|
|
1418
|
+
maxWidth: "100%",
|
|
1419
|
+
flexDirection: "column"
|
|
1420
|
+
},
|
|
1693
1421
|
props: {
|
|
1694
1422
|
children: {
|
|
1695
1423
|
type: "slot",
|
|
@@ -1717,7 +1445,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1717
1445
|
type: "boolean",
|
|
1718
1446
|
displayName: "Use drafts?",
|
|
1719
1447
|
description: "If set, also query unpublished content.",
|
|
1720
|
-
defaultValue: false
|
|
1448
|
+
defaultValue: false,
|
|
1449
|
+
hidden: function hidden() {
|
|
1450
|
+
return true;
|
|
1451
|
+
}
|
|
1721
1452
|
},
|
|
1722
1453
|
where: {
|
|
1723
1454
|
type: "object",
|
|
@@ -1751,7 +1482,7 @@ var cmsQueryRepeaterMeta = {
|
|
|
1751
1482
|
type: "slot",
|
|
1752
1483
|
defaultValue: {
|
|
1753
1484
|
type: "text",
|
|
1754
|
-
value: "No matching entries found."
|
|
1485
|
+
value: "No matching published entries found."
|
|
1755
1486
|
}
|
|
1756
1487
|
},
|
|
1757
1488
|
forceEmptyState: {
|
|
@@ -1775,19 +1506,20 @@ var cmsQueryRepeaterMeta = {
|
|
|
1775
1506
|
}
|
|
1776
1507
|
}
|
|
1777
1508
|
};
|
|
1778
|
-
function CmsQueryRepeater(
|
|
1779
|
-
var table =
|
|
1780
|
-
children =
|
|
1781
|
-
setControlContextData =
|
|
1782
|
-
where =
|
|
1783
|
-
useDraft =
|
|
1784
|
-
orderBy =
|
|
1785
|
-
desc =
|
|
1786
|
-
limit =
|
|
1787
|
-
emptyMessage =
|
|
1788
|
-
forceEmptyState =
|
|
1789
|
-
loadingMessage =
|
|
1790
|
-
forceLoadingState =
|
|
1509
|
+
function CmsQueryRepeater(_ref4) {
|
|
1510
|
+
var table = _ref4.table,
|
|
1511
|
+
children = _ref4.children,
|
|
1512
|
+
setControlContextData = _ref4.setControlContextData,
|
|
1513
|
+
where = _ref4.where,
|
|
1514
|
+
useDraft = _ref4.useDraft,
|
|
1515
|
+
orderBy = _ref4.orderBy,
|
|
1516
|
+
desc = _ref4.desc,
|
|
1517
|
+
limit = _ref4.limit,
|
|
1518
|
+
emptyMessage = _ref4.emptyMessage,
|
|
1519
|
+
forceEmptyState = _ref4.forceEmptyState,
|
|
1520
|
+
loadingMessage = _ref4.loadingMessage,
|
|
1521
|
+
forceLoadingState = _ref4.forceLoadingState,
|
|
1522
|
+
className = _ref4.className;
|
|
1791
1523
|
var databaseConfig = useDatabase();
|
|
1792
1524
|
var tables = useTables();
|
|
1793
1525
|
var params = {
|
|
@@ -1816,13 +1548,13 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1816
1548
|
});
|
|
1817
1549
|
}
|
|
1818
1550
|
|
|
1819
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1820
|
-
return runtime_1.wrap(function
|
|
1551
|
+
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1552
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1821
1553
|
while (1) {
|
|
1822
|
-
switch (
|
|
1554
|
+
switch (_context2.prev = _context2.next) {
|
|
1823
1555
|
case 0:
|
|
1824
1556
|
if (isDatabaseConfigured(databaseConfig)) {
|
|
1825
|
-
|
|
1557
|
+
_context2.next = 2;
|
|
1826
1558
|
break;
|
|
1827
1559
|
}
|
|
1828
1560
|
|
|
@@ -1830,7 +1562,7 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1830
1562
|
|
|
1831
1563
|
case 2:
|
|
1832
1564
|
if (table) {
|
|
1833
|
-
|
|
1565
|
+
_context2.next = 6;
|
|
1834
1566
|
break;
|
|
1835
1567
|
}
|
|
1836
1568
|
|
|
@@ -1840,25 +1572,30 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1840
1572
|
if (!(tables && !tables.find(function (t) {
|
|
1841
1573
|
return t.identifier === table;
|
|
1842
1574
|
}))) {
|
|
1843
|
-
|
|
1575
|
+
_context2.next = 10;
|
|
1844
1576
|
break;
|
|
1845
1577
|
}
|
|
1846
1578
|
|
|
1847
1579
|
throw new Error("There is no model called \"" + table + "\"");
|
|
1848
1580
|
|
|
1849
1581
|
case 10:
|
|
1850
|
-
return
|
|
1582
|
+
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1851
1583
|
|
|
1852
1584
|
case 11:
|
|
1853
1585
|
case "end":
|
|
1854
|
-
return
|
|
1586
|
+
return _context2.stop();
|
|
1855
1587
|
}
|
|
1856
1588
|
}
|
|
1857
|
-
},
|
|
1589
|
+
}, _callee2);
|
|
1858
1590
|
})));
|
|
1859
|
-
return
|
|
1591
|
+
return React.createElement("div", {
|
|
1592
|
+
className: className
|
|
1593
|
+
}, renderMaybeData(maybeData, function (rows) {
|
|
1860
1594
|
if (rows.length === 0 || forceEmptyState) {
|
|
1861
|
-
return React.createElement(
|
|
1595
|
+
return React.createElement(QueryResultProvider, {
|
|
1596
|
+
table: table,
|
|
1597
|
+
rows: rows
|
|
1598
|
+
}, emptyMessage);
|
|
1862
1599
|
}
|
|
1863
1600
|
|
|
1864
1601
|
return React.createElement(QueryResultProvider, {
|
|
@@ -1872,7 +1609,7 @@ function CmsQueryRepeater(_ref8) {
|
|
|
1872
1609
|
}));
|
|
1873
1610
|
}, {
|
|
1874
1611
|
hideIfNotFound: false
|
|
1875
|
-
}, loadingMessage, forceLoadingState);
|
|
1612
|
+
}, loadingMessage, forceLoadingState));
|
|
1876
1613
|
}
|
|
1877
1614
|
var cmsRowFieldMeta = {
|
|
1878
1615
|
name: componentPrefix + "-row-field",
|
|
@@ -1895,10 +1632,10 @@ var cmsRowFieldMeta = {
|
|
|
1895
1632
|
type: "choice",
|
|
1896
1633
|
displayName: "Field",
|
|
1897
1634
|
description: "Field (from model schema) to use.",
|
|
1898
|
-
options: function options(
|
|
1635
|
+
options: function options(_ref6, ctx) {
|
|
1899
1636
|
var _ctx$table;
|
|
1900
1637
|
|
|
1901
|
-
var table =
|
|
1638
|
+
var table = _ref6.table;
|
|
1902
1639
|
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"]);
|
|
1903
1640
|
},
|
|
1904
1641
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -1910,8 +1647,8 @@ var cmsRowFieldMeta = {
|
|
|
1910
1647
|
dateFormat: {
|
|
1911
1648
|
type: "choice",
|
|
1912
1649
|
displayName: "Date Format",
|
|
1913
|
-
hidden: function hidden(
|
|
1914
|
-
var field =
|
|
1650
|
+
hidden: function hidden(_ref7, ctx) {
|
|
1651
|
+
var field = _ref7.field;
|
|
1915
1652
|
|
|
1916
1653
|
if (!ctx) {
|
|
1917
1654
|
return true;
|
|
@@ -1980,15 +1717,15 @@ var cmsRowFieldMeta = {
|
|
|
1980
1717
|
}
|
|
1981
1718
|
}
|
|
1982
1719
|
};
|
|
1983
|
-
function CmsRowField(
|
|
1720
|
+
function CmsRowField(_ref8) {
|
|
1984
1721
|
var _res$row$data;
|
|
1985
1722
|
|
|
1986
|
-
var className =
|
|
1987
|
-
table =
|
|
1988
|
-
field =
|
|
1989
|
-
dateFormat =
|
|
1990
|
-
setControlContextData =
|
|
1991
|
-
rest = _objectWithoutPropertiesLoose(
|
|
1723
|
+
var className = _ref8.className,
|
|
1724
|
+
table = _ref8.table,
|
|
1725
|
+
field = _ref8.field,
|
|
1726
|
+
dateFormat = _ref8.dateFormat,
|
|
1727
|
+
setControlContextData = _ref8.setControlContextData,
|
|
1728
|
+
rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
|
|
1992
1729
|
|
|
1993
1730
|
var tables = useTablesWithDataLoaded();
|
|
1994
1731
|
var res = useRow(tables, table);
|
|
@@ -2085,8 +1822,11 @@ function renderValue(value, type, props) {
|
|
|
2085
1822
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
2086
1823
|
return React.createElement("img", Object.assign({
|
|
2087
1824
|
src: value.url,
|
|
2088
|
-
width: value.imageMeta.
|
|
2089
|
-
height: value.imageMeta.height
|
|
1825
|
+
width: value.imageMeta.width,
|
|
1826
|
+
height: value.imageMeta.height,
|
|
1827
|
+
style: {
|
|
1828
|
+
objectFit: "cover"
|
|
1829
|
+
}
|
|
2090
1830
|
}, props));
|
|
2091
1831
|
}
|
|
2092
1832
|
|
|
@@ -2126,10 +1866,10 @@ var cmsRowLinkMeta = {
|
|
|
2126
1866
|
type: "choice",
|
|
2127
1867
|
displayName: "Field",
|
|
2128
1868
|
description: "Field (from model schema) to use.",
|
|
2129
|
-
options: function options(
|
|
1869
|
+
options: function options(_ref9, ctx) {
|
|
2130
1870
|
var _ctx$table2;
|
|
2131
1871
|
|
|
2132
|
-
var table =
|
|
1872
|
+
var table = _ref9.table;
|
|
2133
1873
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
2134
1874
|
},
|
|
2135
1875
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2156,16 +1896,16 @@ var cmsRowLinkMeta = {
|
|
|
2156
1896
|
}
|
|
2157
1897
|
}
|
|
2158
1898
|
};
|
|
2159
|
-
function CmsRowLink(
|
|
1899
|
+
function CmsRowLink(_ref10) {
|
|
2160
1900
|
var _res$row$data2;
|
|
2161
1901
|
|
|
2162
|
-
var table =
|
|
2163
|
-
field =
|
|
2164
|
-
hrefProp =
|
|
2165
|
-
children =
|
|
2166
|
-
setControlContextData =
|
|
2167
|
-
prefix =
|
|
2168
|
-
suffix =
|
|
1902
|
+
var table = _ref10.table,
|
|
1903
|
+
field = _ref10.field,
|
|
1904
|
+
hrefProp = _ref10.hrefProp,
|
|
1905
|
+
children = _ref10.children,
|
|
1906
|
+
setControlContextData = _ref10.setControlContextData,
|
|
1907
|
+
prefix = _ref10.prefix,
|
|
1908
|
+
suffix = _ref10.suffix;
|
|
2169
1909
|
var tables = useTablesWithDataLoaded();
|
|
2170
1910
|
var res = useRow(tables, table);
|
|
2171
1911
|
|
|
@@ -2238,10 +1978,10 @@ var cmsRowImageMeta = {
|
|
|
2238
1978
|
type: "choice",
|
|
2239
1979
|
displayName: "Field",
|
|
2240
1980
|
description: "Field (from model schema) to use.",
|
|
2241
|
-
options: function options(
|
|
1981
|
+
options: function options(_ref11, ctx) {
|
|
2242
1982
|
var _ctx$table3;
|
|
2243
1983
|
|
|
2244
|
-
var table =
|
|
1984
|
+
var table = _ref11.table;
|
|
2245
1985
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["image"]);
|
|
2246
1986
|
},
|
|
2247
1987
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2258,14 +1998,14 @@ var cmsRowImageMeta = {
|
|
|
2258
1998
|
}
|
|
2259
1999
|
}
|
|
2260
2000
|
};
|
|
2261
|
-
function CmsRowImage(
|
|
2001
|
+
function CmsRowImage(_ref12) {
|
|
2262
2002
|
var _res$row$data3;
|
|
2263
2003
|
|
|
2264
|
-
var table =
|
|
2265
|
-
field =
|
|
2266
|
-
srcProp =
|
|
2267
|
-
children =
|
|
2268
|
-
setControlContextData =
|
|
2004
|
+
var table = _ref12.table,
|
|
2005
|
+
field = _ref12.field,
|
|
2006
|
+
srcProp = _ref12.srcProp,
|
|
2007
|
+
children = _ref12.children,
|
|
2008
|
+
setControlContextData = _ref12.setControlContextData;
|
|
2269
2009
|
var tables = useTablesWithDataLoaded();
|
|
2270
2010
|
var res = useRow(tables, table);
|
|
2271
2011
|
|
|
@@ -2340,10 +2080,10 @@ var cmsRowFieldValueMeta = {
|
|
|
2340
2080
|
type: "choice",
|
|
2341
2081
|
displayName: "Field",
|
|
2342
2082
|
description: "Field (from model schema) to use.",
|
|
2343
|
-
options: function options(
|
|
2083
|
+
options: function options(_ref13, ctx) {
|
|
2344
2084
|
var _ctx$table4;
|
|
2345
2085
|
|
|
2346
|
-
var table =
|
|
2086
|
+
var table = _ref13.table;
|
|
2347
2087
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2348
2088
|
},
|
|
2349
2089
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
@@ -2360,15 +2100,15 @@ var cmsRowFieldValueMeta = {
|
|
|
2360
2100
|
}
|
|
2361
2101
|
}
|
|
2362
2102
|
};
|
|
2363
|
-
function CmsRowFieldValue(
|
|
2103
|
+
function CmsRowFieldValue(_ref14) {
|
|
2364
2104
|
var _res$row$data4;
|
|
2365
2105
|
|
|
2366
|
-
var table =
|
|
2367
|
-
field =
|
|
2368
|
-
valueProp =
|
|
2369
|
-
children =
|
|
2370
|
-
setControlContextData =
|
|
2371
|
-
rest = _objectWithoutPropertiesLoose(
|
|
2106
|
+
var table = _ref14.table,
|
|
2107
|
+
field = _ref14.field,
|
|
2108
|
+
valueProp = _ref14.valueProp,
|
|
2109
|
+
children = _ref14.children,
|
|
2110
|
+
setControlContextData = _ref14.setControlContextData,
|
|
2111
|
+
rest = _objectWithoutPropertiesLoose(_ref14, _excluded3);
|
|
2372
2112
|
|
|
2373
2113
|
var tables = useTablesWithDataLoaded();
|
|
2374
2114
|
var res = useRow(tables, table);
|
|
@@ -2410,106 +2150,6 @@ function CmsRowFieldValue(_ref18) {
|
|
|
2410
2150
|
});
|
|
2411
2151
|
return React.createElement(React.Fragment, null, childrenWithProps);
|
|
2412
2152
|
}
|
|
2413
|
-
var cmsRowLoaderMeta = {
|
|
2414
|
-
name: componentPrefix + "-row-loader",
|
|
2415
|
-
displayName: "CMS Row Loader",
|
|
2416
|
-
importName: "CmsRowLoader",
|
|
2417
|
-
importPath: modulePath,
|
|
2418
|
-
props: /*#__PURE__*/_extends({
|
|
2419
|
-
children: {
|
|
2420
|
-
type: "slot",
|
|
2421
|
-
defaultValue: {
|
|
2422
|
-
type: "component",
|
|
2423
|
-
name: componentPrefix + "-row-field"
|
|
2424
|
-
}
|
|
2425
|
-
},
|
|
2426
|
-
row: {
|
|
2427
|
-
type: "string",
|
|
2428
|
-
displayName: "Entry ID",
|
|
2429
|
-
description: "Row identifier to query."
|
|
2430
|
-
},
|
|
2431
|
-
table: {
|
|
2432
|
-
type: "choice",
|
|
2433
|
-
displayName: "Model",
|
|
2434
|
-
description: "CMS model (table) to query.",
|
|
2435
|
-
options: function options(_, ctx) {
|
|
2436
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
2437
|
-
}
|
|
2438
|
-
},
|
|
2439
|
-
useDraft: {
|
|
2440
|
-
type: "boolean",
|
|
2441
|
-
displayName: "Use drafts?",
|
|
2442
|
-
description: "If set, also query unpublished content.",
|
|
2443
|
-
defaultValue: false
|
|
2444
|
-
}
|
|
2445
|
-
}, fetcherComponentPropMetas)
|
|
2446
|
-
};
|
|
2447
|
-
function CmsRowLoader(_ref19) {
|
|
2448
|
-
var table = _ref19.table,
|
|
2449
|
-
row = _ref19.row,
|
|
2450
|
-
children = _ref19.children,
|
|
2451
|
-
useDraft = _ref19.useDraft,
|
|
2452
|
-
hideIfNotFound = _ref19.hideIfNotFound,
|
|
2453
|
-
setControlContextData = _ref19.setControlContextData;
|
|
2454
|
-
var databaseConfig = useDatabase();
|
|
2455
|
-
var tables = useTables();
|
|
2456
|
-
|
|
2457
|
-
if (tables) {
|
|
2458
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2459
|
-
tables: tables
|
|
2460
|
-
});
|
|
2461
|
-
}
|
|
2462
|
-
|
|
2463
|
-
var cacheKey = JSON.stringify({
|
|
2464
|
-
component: "CmsRowLoader",
|
|
2465
|
-
table: table,
|
|
2466
|
-
row: row,
|
|
2467
|
-
databaseConfig: databaseConfig,
|
|
2468
|
-
useDraft: useDraft
|
|
2469
|
-
});
|
|
2470
|
-
var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2471
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2472
|
-
while (1) {
|
|
2473
|
-
switch (_context4.prev = _context4.next) {
|
|
2474
|
-
case 0:
|
|
2475
|
-
if (table) {
|
|
2476
|
-
_context4.next = 2;
|
|
2477
|
-
break;
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
|
-
throw new Error("You must specify a model to fetch from.");
|
|
2481
|
-
|
|
2482
|
-
case 2:
|
|
2483
|
-
if (row) {
|
|
2484
|
-
_context4.next = 4;
|
|
2485
|
-
break;
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
throw new Error("You must specify an entry name to fetch.");
|
|
2489
|
-
|
|
2490
|
-
case 4:
|
|
2491
|
-
_context4.next = 6;
|
|
2492
|
-
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2493
|
-
|
|
2494
|
-
case 6:
|
|
2495
|
-
return _context4.abrupt("return", _context4.sent);
|
|
2496
|
-
|
|
2497
|
-
case 7:
|
|
2498
|
-
case "end":
|
|
2499
|
-
return _context4.stop();
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
}, _callee4);
|
|
2503
|
-
})));
|
|
2504
|
-
return renderMaybeData(maybeData, function (row) {
|
|
2505
|
-
return React.createElement(RowProvider, {
|
|
2506
|
-
table: table,
|
|
2507
|
-
row: row
|
|
2508
|
-
}, children);
|
|
2509
|
-
}, {
|
|
2510
|
-
hideIfNotFound: hideIfNotFound
|
|
2511
|
-
});
|
|
2512
|
-
}
|
|
2513
2153
|
|
|
2514
2154
|
function registerAll(loader) {
|
|
2515
2155
|
//const registerContext = loader?.registerContext ?? hostRegisterContext;
|
|
@@ -2530,9 +2170,7 @@ function registerAll(loader) {
|
|
|
2530
2170
|
}
|
|
2531
2171
|
};
|
|
2532
2172
|
|
|
2533
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2534
|
-
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2535
|
-
|
|
2173
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2536
2174
|
|
|
2537
2175
|
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2538
2176
|
|
|
@@ -2542,27 +2180,20 @@ function registerAll(loader) {
|
|
|
2542
2180
|
|
|
2543
2181
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2544
2182
|
|
|
2545
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2546
|
-
|
|
2183
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2547
2184
|
}
|
|
2548
2185
|
|
|
2549
2186
|
exports.CmsCredentialsProvider = CmsCredentialsProvider;
|
|
2550
|
-
exports.CmsQueryLoader = CmsQueryLoader;
|
|
2551
2187
|
exports.CmsQueryRepeater = CmsQueryRepeater;
|
|
2552
2188
|
exports.CmsRowField = CmsRowField;
|
|
2553
2189
|
exports.CmsRowFieldValue = CmsRowFieldValue;
|
|
2554
2190
|
exports.CmsRowImage = CmsRowImage;
|
|
2555
2191
|
exports.CmsRowLink = CmsRowLink;
|
|
2556
|
-
exports.CmsRowLoader = CmsRowLoader;
|
|
2557
|
-
exports.CmsRowRepeater = CmsRowRepeater;
|
|
2558
2192
|
exports.cmsCredentialsProviderMeta = cmsCredentialsProviderMeta;
|
|
2559
|
-
exports.cmsQueryLoaderMeta = cmsQueryLoaderMeta;
|
|
2560
2193
|
exports.cmsQueryRepeaterMeta = cmsQueryRepeaterMeta;
|
|
2561
2194
|
exports.cmsRowFieldMeta = cmsRowFieldMeta;
|
|
2562
2195
|
exports.cmsRowFieldValueMeta = cmsRowFieldValueMeta;
|
|
2563
2196
|
exports.cmsRowImageMeta = cmsRowImageMeta;
|
|
2564
2197
|
exports.cmsRowLinkMeta = cmsRowLinkMeta;
|
|
2565
|
-
exports.cmsRowLoaderMeta = cmsRowLoaderMeta;
|
|
2566
|
-
exports.cmsRowRepeaterMeta = cmsRowRepeaterMeta;
|
|
2567
2198
|
exports.registerAll = registerAll;
|
|
2568
2199
|
//# sourceMappingURL=plasmic-cms.cjs.development.js.map
|