@plasmicpkgs/plasmic-cms 0.0.46 → 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 +16 -33
- package/dist/context.d.ts +2 -1
- package/dist/plasmic-cms.cjs.development.js +231 -533
- 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 +232 -528
- 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) {
|
|
@@ -1281,7 +1194,7 @@ function QueryResultProvider(_ref3) {
|
|
|
1281
1194
|
data: rows
|
|
1282
1195
|
}, children);
|
|
1283
1196
|
}
|
|
1284
|
-
function
|
|
1197
|
+
function useTablesWithDataLoaded() {
|
|
1285
1198
|
var env = useDataEnv();
|
|
1286
1199
|
var tables = useTables();
|
|
1287
1200
|
|
|
@@ -1289,39 +1202,33 @@ function useRow(table) {
|
|
|
1289
1202
|
return undefined;
|
|
1290
1203
|
}
|
|
1291
1204
|
|
|
1292
|
-
if (table) {
|
|
1293
|
-
return {
|
|
1294
|
-
table: table,
|
|
1295
|
-
row: env[mkRowContextKey(table)]
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
1205
|
if (!tables) {
|
|
1300
1206
|
return undefined;
|
|
1301
1207
|
}
|
|
1302
1208
|
|
|
1303
1209
|
var matchingKeys = getClosestMatchingKeys(env, rowContextPrefix);
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
var inferredTable = tables.find(function (t) {
|
|
1308
|
-
return mkRowContextKey(t.identifier) === key;
|
|
1210
|
+
return tables.filter(function (table) {
|
|
1211
|
+
return matchingKeys.some(function (key) {
|
|
1212
|
+
return mkRowContextKey(table.identifier) === key;
|
|
1309
1213
|
});
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
function useRow(tables, table) {
|
|
1217
|
+
var env = useDataEnv();
|
|
1310
1218
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
table: inferredTable.identifier,
|
|
1315
|
-
row: env[key]
|
|
1316
|
-
}
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
};
|
|
1219
|
+
if (!env) {
|
|
1220
|
+
return undefined;
|
|
1221
|
+
}
|
|
1320
1222
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1223
|
+
if (!table && tables && tables.length > 0) {
|
|
1224
|
+
table = tables[0].identifier;
|
|
1225
|
+
}
|
|
1323
1226
|
|
|
1324
|
-
|
|
1227
|
+
if (table) {
|
|
1228
|
+
return {
|
|
1229
|
+
table: table,
|
|
1230
|
+
row: env[mkRowContextKey(table)]
|
|
1231
|
+
};
|
|
1325
1232
|
}
|
|
1326
1233
|
|
|
1327
1234
|
return undefined;
|
|
@@ -1382,15 +1289,8 @@ var _excluded = ["children"],
|
|
|
1382
1289
|
_excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
|
|
1383
1290
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1384
1291
|
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
1292
|
|
|
1393
|
-
function renderMaybeData(maybeData, renderFn, loaderProps) {
|
|
1293
|
+
function renderMaybeData(maybeData, renderFn, loaderProps, loadingMessage, forceLoadingState) {
|
|
1394
1294
|
if ("error" in maybeData) {
|
|
1395
1295
|
var error = maybeData.error;
|
|
1396
1296
|
|
|
@@ -1405,8 +1305,8 @@ function renderMaybeData(maybeData, renderFn, loaderProps) {
|
|
|
1405
1305
|
}
|
|
1406
1306
|
}
|
|
1407
1307
|
|
|
1408
|
-
if (!("data" in maybeData)) {
|
|
1409
|
-
return React.createElement("div", null, "Loading...");
|
|
1308
|
+
if (!("data" in maybeData) || forceLoadingState) {
|
|
1309
|
+
return React.createElement(React.Fragment, null, loadingMessage != null ? loadingMessage : React.createElement("div", null, "Loading..."));
|
|
1410
1310
|
}
|
|
1411
1311
|
|
|
1412
1312
|
return renderFn(maybeData.data);
|
|
@@ -1416,6 +1316,7 @@ var defaultHost = "https://studio.plasmic.app";
|
|
|
1416
1316
|
var cmsCredentialsProviderMeta = {
|
|
1417
1317
|
name: componentPrefix + "-credentials-provider",
|
|
1418
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.",
|
|
1419
1320
|
importName: "CmsCredentialsProvider",
|
|
1420
1321
|
importPath: modulePath,
|
|
1421
1322
|
props: {
|
|
@@ -1495,204 +1396,26 @@ function TablesFetcher(_ref2) {
|
|
|
1495
1396
|
});
|
|
1496
1397
|
}
|
|
1497
1398
|
|
|
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
1399
|
function isDatabaseConfigured(config) {
|
|
1555
1400
|
return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
|
|
1556
1401
|
}
|
|
1557
1402
|
|
|
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 = 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
|
-
}, repeatedElement(index === 0, children));
|
|
1685
|
-
}));
|
|
1686
|
-
}
|
|
1687
1403
|
var cmsQueryRepeaterMeta = {
|
|
1688
1404
|
name: componentPrefix + "-query-repeater",
|
|
1689
1405
|
displayName: "CMS Data Loader",
|
|
1690
1406
|
description: "Fetches CMS data and repeats content of children once for every row fetched.",
|
|
1691
1407
|
importName: "CmsQueryRepeater",
|
|
1692
1408
|
importPath: modulePath,
|
|
1409
|
+
defaultStyles: {
|
|
1410
|
+
display: "flex",
|
|
1411
|
+
width: "stretch",
|
|
1412
|
+
maxWidth: "100%",
|
|
1413
|
+
flexDirection: "column"
|
|
1414
|
+
},
|
|
1693
1415
|
props: {
|
|
1694
1416
|
children: {
|
|
1695
1417
|
type: "slot",
|
|
1418
|
+
isRepeated: true,
|
|
1696
1419
|
defaultValue: {
|
|
1697
1420
|
type: "vbox",
|
|
1698
1421
|
children: [{
|
|
@@ -1707,13 +1430,19 @@ var cmsQueryRepeaterMeta = {
|
|
|
1707
1430
|
description: "CMS model (table) to query.",
|
|
1708
1431
|
options: function options(_, ctx) {
|
|
1709
1432
|
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1433
|
+
},
|
|
1434
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1435
|
+
return ctx == null ? void 0 : ctx.table;
|
|
1710
1436
|
}
|
|
1711
1437
|
},
|
|
1712
1438
|
useDraft: {
|
|
1713
1439
|
type: "boolean",
|
|
1714
1440
|
displayName: "Use drafts?",
|
|
1715
1441
|
description: "If set, also query unpublished content.",
|
|
1716
|
-
defaultValue: false
|
|
1442
|
+
defaultValue: false,
|
|
1443
|
+
hidden: function hidden() {
|
|
1444
|
+
return true;
|
|
1445
|
+
}
|
|
1717
1446
|
},
|
|
1718
1447
|
where: {
|
|
1719
1448
|
type: "object",
|
|
@@ -1727,9 +1456,8 @@ var cmsQueryRepeaterMeta = {
|
|
|
1727
1456
|
type: "choice",
|
|
1728
1457
|
displayName: "Order by",
|
|
1729
1458
|
description: "Field to order by.",
|
|
1730
|
-
options: function options(
|
|
1731
|
-
|
|
1732
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, table);
|
|
1459
|
+
options: function options(_, ctx) {
|
|
1460
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table);
|
|
1733
1461
|
}
|
|
1734
1462
|
},
|
|
1735
1463
|
desc: {
|
|
@@ -1743,28 +1471,51 @@ var cmsQueryRepeaterMeta = {
|
|
|
1743
1471
|
displayName: "Limit",
|
|
1744
1472
|
description: "Maximum number of entries to fetch (0 for unlimited).",
|
|
1745
1473
|
defaultValue: 0
|
|
1474
|
+
},
|
|
1475
|
+
emptyMessage: {
|
|
1476
|
+
type: "slot",
|
|
1477
|
+
defaultValue: {
|
|
1478
|
+
type: "text",
|
|
1479
|
+
value: "No matching published entries found."
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
forceEmptyState: {
|
|
1483
|
+
type: "boolean",
|
|
1484
|
+
displayName: "Force empty state",
|
|
1485
|
+
description: "If set, will render as if no matching entries were found.",
|
|
1486
|
+
defaultValue: false
|
|
1487
|
+
},
|
|
1488
|
+
loadingMessage: {
|
|
1489
|
+
type: "slot",
|
|
1490
|
+
defaultValue: {
|
|
1491
|
+
type: "text",
|
|
1492
|
+
value: "Loading..."
|
|
1493
|
+
}
|
|
1494
|
+
},
|
|
1495
|
+
forceLoadingState: {
|
|
1496
|
+
type: "boolean",
|
|
1497
|
+
displayName: "Force loading state",
|
|
1498
|
+
description: "If set, will render as if it is waiting for the query to run.",
|
|
1499
|
+
defaultValue: false
|
|
1746
1500
|
}
|
|
1747
1501
|
}
|
|
1748
1502
|
};
|
|
1749
|
-
function CmsQueryRepeater(
|
|
1750
|
-
var table =
|
|
1751
|
-
children =
|
|
1752
|
-
setControlContextData =
|
|
1753
|
-
where =
|
|
1754
|
-
useDraft =
|
|
1755
|
-
orderBy =
|
|
1756
|
-
desc =
|
|
1757
|
-
limit =
|
|
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;
|
|
1758
1517
|
var databaseConfig = useDatabase();
|
|
1759
1518
|
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
1519
|
var params = {
|
|
1769
1520
|
where: where,
|
|
1770
1521
|
useDraft: useDraft,
|
|
@@ -1783,13 +1534,21 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1783
1534
|
table = tables[0].identifier;
|
|
1784
1535
|
}
|
|
1785
1536
|
|
|
1786
|
-
|
|
1787
|
-
|
|
1537
|
+
if (tables) {
|
|
1538
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1539
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1540
|
+
tables: tables,
|
|
1541
|
+
table: table
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1546
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1788
1547
|
while (1) {
|
|
1789
|
-
switch (
|
|
1548
|
+
switch (_context2.prev = _context2.next) {
|
|
1790
1549
|
case 0:
|
|
1791
1550
|
if (isDatabaseConfigured(databaseConfig)) {
|
|
1792
|
-
|
|
1551
|
+
_context2.next = 2;
|
|
1793
1552
|
break;
|
|
1794
1553
|
}
|
|
1795
1554
|
|
|
@@ -1797,7 +1556,7 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1797
1556
|
|
|
1798
1557
|
case 2:
|
|
1799
1558
|
if (table) {
|
|
1800
|
-
|
|
1559
|
+
_context2.next = 6;
|
|
1801
1560
|
break;
|
|
1802
1561
|
}
|
|
1803
1562
|
|
|
@@ -1807,25 +1566,30 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1807
1566
|
if (!(tables && !tables.find(function (t) {
|
|
1808
1567
|
return t.identifier === table;
|
|
1809
1568
|
}))) {
|
|
1810
|
-
|
|
1569
|
+
_context2.next = 10;
|
|
1811
1570
|
break;
|
|
1812
1571
|
}
|
|
1813
1572
|
|
|
1814
1573
|
throw new Error("There is no model called \"" + table + "\"");
|
|
1815
1574
|
|
|
1816
1575
|
case 10:
|
|
1817
|
-
return
|
|
1576
|
+
return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
|
|
1818
1577
|
|
|
1819
1578
|
case 11:
|
|
1820
1579
|
case "end":
|
|
1821
|
-
return
|
|
1580
|
+
return _context2.stop();
|
|
1822
1581
|
}
|
|
1823
1582
|
}
|
|
1824
|
-
},
|
|
1583
|
+
}, _callee2);
|
|
1825
1584
|
})));
|
|
1826
|
-
return
|
|
1827
|
-
|
|
1828
|
-
|
|
1585
|
+
return React.createElement("div", {
|
|
1586
|
+
className: className
|
|
1587
|
+
}, renderMaybeData(maybeData, function (rows) {
|
|
1588
|
+
if (rows.length === 0 || forceEmptyState) {
|
|
1589
|
+
return React.createElement(QueryResultProvider, {
|
|
1590
|
+
table: table,
|
|
1591
|
+
rows: rows
|
|
1592
|
+
}, emptyMessage);
|
|
1829
1593
|
}
|
|
1830
1594
|
|
|
1831
1595
|
return React.createElement(QueryResultProvider, {
|
|
@@ -1839,7 +1603,7 @@ function CmsQueryRepeater(_ref9) {
|
|
|
1839
1603
|
}));
|
|
1840
1604
|
}, {
|
|
1841
1605
|
hideIfNotFound: false
|
|
1842
|
-
});
|
|
1606
|
+
}, loadingMessage, forceLoadingState));
|
|
1843
1607
|
}
|
|
1844
1608
|
var cmsRowFieldMeta = {
|
|
1845
1609
|
name: componentPrefix + "-row-field",
|
|
@@ -1853,24 +1617,32 @@ var cmsRowFieldMeta = {
|
|
|
1853
1617
|
description: "CMS model (table) to use.",
|
|
1854
1618
|
options: function options(_, ctx) {
|
|
1855
1619
|
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1620
|
+
},
|
|
1621
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1622
|
+
return ctx == null ? void 0 : ctx.table;
|
|
1856
1623
|
}
|
|
1857
1624
|
},
|
|
1858
1625
|
field: {
|
|
1859
1626
|
type: "choice",
|
|
1860
1627
|
displayName: "Field",
|
|
1861
1628
|
description: "Field (from model schema) to use.",
|
|
1862
|
-
options: function options(
|
|
1629
|
+
options: function options(_ref6, ctx) {
|
|
1863
1630
|
var _ctx$table;
|
|
1864
1631
|
|
|
1865
|
-
var table =
|
|
1632
|
+
var table = _ref6.table;
|
|
1866
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"]);
|
|
1634
|
+
},
|
|
1635
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1636
|
+
var _ctx$fieldMeta, _ctx$fieldMeta2;
|
|
1637
|
+
|
|
1638
|
+
return (ctx == null ? void 0 : (_ctx$fieldMeta = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta.name) || (ctx == null ? void 0 : (_ctx$fieldMeta2 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta2.identifier);
|
|
1867
1639
|
}
|
|
1868
1640
|
},
|
|
1869
1641
|
dateFormat: {
|
|
1870
1642
|
type: "choice",
|
|
1871
1643
|
displayName: "Date Format",
|
|
1872
|
-
hidden: function hidden(
|
|
1873
|
-
var field =
|
|
1644
|
+
hidden: function hidden(_ref7, ctx) {
|
|
1645
|
+
var field = _ref7.field;
|
|
1874
1646
|
|
|
1875
1647
|
if (!ctx) {
|
|
1876
1648
|
return true;
|
|
@@ -1939,18 +1711,18 @@ var cmsRowFieldMeta = {
|
|
|
1939
1711
|
}
|
|
1940
1712
|
}
|
|
1941
1713
|
};
|
|
1942
|
-
function CmsRowField(
|
|
1714
|
+
function CmsRowField(_ref8) {
|
|
1943
1715
|
var _res$row$data;
|
|
1944
1716
|
|
|
1945
|
-
var className =
|
|
1946
|
-
table =
|
|
1947
|
-
field =
|
|
1948
|
-
dateFormat =
|
|
1949
|
-
setControlContextData =
|
|
1950
|
-
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);
|
|
1951
1723
|
|
|
1952
|
-
var tables =
|
|
1953
|
-
var res = useRow(table);
|
|
1724
|
+
var tables = useTablesWithDataLoaded();
|
|
1725
|
+
var res = useRow(tables, table);
|
|
1954
1726
|
|
|
1955
1727
|
if (!res) {
|
|
1956
1728
|
return React.createElement("div", {
|
|
@@ -1964,22 +1736,23 @@ function CmsRowField(_ref13) {
|
|
|
1964
1736
|
}, "Error: No CMS Entry found");
|
|
1965
1737
|
}
|
|
1966
1738
|
|
|
1739
|
+
var fieldMeta = deriveInferredTableField({
|
|
1740
|
+
table: res.table,
|
|
1741
|
+
tables: tables,
|
|
1742
|
+
field: field,
|
|
1743
|
+
typeFilters: ["text", "long-text", "rich-text"]
|
|
1744
|
+
});
|
|
1745
|
+
|
|
1967
1746
|
if (tables) {
|
|
1968
1747
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1969
1748
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1970
1749
|
tables: tables,
|
|
1971
1750
|
table: res.table,
|
|
1972
|
-
row: res.row
|
|
1751
|
+
row: res.row,
|
|
1752
|
+
fieldMeta: fieldMeta
|
|
1973
1753
|
});
|
|
1974
1754
|
}
|
|
1975
1755
|
|
|
1976
|
-
var fieldMeta = deriveInferredTableField({
|
|
1977
|
-
table: res.table,
|
|
1978
|
-
tables: tables,
|
|
1979
|
-
field: field,
|
|
1980
|
-
typeFilters: ["text", "long-text", "rich-text"]
|
|
1981
|
-
});
|
|
1982
|
-
|
|
1983
1756
|
if (!fieldMeta) {
|
|
1984
1757
|
throw new Error("Please select an entry field to display.");
|
|
1985
1758
|
}
|
|
@@ -2007,6 +1780,7 @@ function deriveInferredTableField(opts) {
|
|
|
2007
1780
|
tables = opts.tables,
|
|
2008
1781
|
field = opts.field,
|
|
2009
1782
|
typeFilters = opts.typeFilters;
|
|
1783
|
+
if (!table) return undefined;
|
|
2010
1784
|
var schema = tables == null ? void 0 : (_tables$find = tables.find(function (t) {
|
|
2011
1785
|
return t.identifier === table;
|
|
2012
1786
|
})) == null ? void 0 : _tables$find.schema;
|
|
@@ -2042,8 +1816,11 @@ function renderValue(value, type, props) {
|
|
|
2042
1816
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
2043
1817
|
return React.createElement("img", Object.assign({
|
|
2044
1818
|
src: value.url,
|
|
2045
|
-
width: value.imageMeta.
|
|
2046
|
-
height: value.imageMeta.height
|
|
1819
|
+
width: value.imageMeta.width,
|
|
1820
|
+
height: value.imageMeta.height,
|
|
1821
|
+
style: {
|
|
1822
|
+
objectFit: "cover"
|
|
1823
|
+
}
|
|
2047
1824
|
}, props));
|
|
2048
1825
|
}
|
|
2049
1826
|
|
|
@@ -2074,17 +1851,25 @@ var cmsRowLinkMeta = {
|
|
|
2074
1851
|
description: "CMS model (table) to use.",
|
|
2075
1852
|
options: function options(_, ctx) {
|
|
2076
1853
|
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1854
|
+
},
|
|
1855
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1856
|
+
return ctx == null ? void 0 : ctx.table;
|
|
2077
1857
|
}
|
|
2078
1858
|
},
|
|
2079
1859
|
field: {
|
|
2080
1860
|
type: "choice",
|
|
2081
1861
|
displayName: "Field",
|
|
2082
1862
|
description: "Field (from model schema) to use.",
|
|
2083
|
-
options: function options(
|
|
1863
|
+
options: function options(_ref9, ctx) {
|
|
2084
1864
|
var _ctx$table2;
|
|
2085
1865
|
|
|
2086
|
-
var table =
|
|
1866
|
+
var table = _ref9.table;
|
|
2087
1867
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
|
|
1868
|
+
},
|
|
1869
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1870
|
+
var _ctx$fieldMeta3, _ctx$fieldMeta4;
|
|
1871
|
+
|
|
1872
|
+
return (ctx == null ? void 0 : (_ctx$fieldMeta3 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta3.name) || (ctx == null ? void 0 : (_ctx$fieldMeta4 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta4.identifier);
|
|
2088
1873
|
}
|
|
2089
1874
|
},
|
|
2090
1875
|
hrefProp: {
|
|
@@ -2105,31 +1890,23 @@ var cmsRowLinkMeta = {
|
|
|
2105
1890
|
}
|
|
2106
1891
|
}
|
|
2107
1892
|
};
|
|
2108
|
-
function CmsRowLink(
|
|
1893
|
+
function CmsRowLink(_ref10) {
|
|
2109
1894
|
var _res$row$data2;
|
|
2110
1895
|
|
|
2111
|
-
var table =
|
|
2112
|
-
field =
|
|
2113
|
-
hrefProp =
|
|
2114
|
-
children =
|
|
2115
|
-
setControlContextData =
|
|
2116
|
-
prefix =
|
|
2117
|
-
suffix =
|
|
2118
|
-
var tables =
|
|
2119
|
-
var res = useRow(table);
|
|
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;
|
|
1903
|
+
var tables = useTablesWithDataLoaded();
|
|
1904
|
+
var res = useRow(tables, table);
|
|
2120
1905
|
|
|
2121
1906
|
if (!res || !res.row) {
|
|
2122
1907
|
return React.createElement(React.Fragment, null, children);
|
|
2123
1908
|
}
|
|
2124
1909
|
|
|
2125
|
-
if (tables) {
|
|
2126
|
-
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
2127
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2128
|
-
tables: tables,
|
|
2129
|
-
table: res.table
|
|
2130
|
-
});
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
1910
|
var fieldMeta = deriveInferredTableField({
|
|
2134
1911
|
table: res.table,
|
|
2135
1912
|
tables: tables,
|
|
@@ -2137,6 +1914,16 @@ function CmsRowLink(_ref15) {
|
|
|
2137
1914
|
typeFilters: ["text"]
|
|
2138
1915
|
});
|
|
2139
1916
|
|
|
1917
|
+
if (tables) {
|
|
1918
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1919
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1920
|
+
tables: tables,
|
|
1921
|
+
table: res.table,
|
|
1922
|
+
row: res.row,
|
|
1923
|
+
fieldMeta: fieldMeta
|
|
1924
|
+
});
|
|
1925
|
+
}
|
|
1926
|
+
|
|
2140
1927
|
if (!fieldMeta) {
|
|
2141
1928
|
return React.createElement(React.Fragment, null, children);
|
|
2142
1929
|
}
|
|
@@ -2176,17 +1963,25 @@ var cmsRowImageMeta = {
|
|
|
2176
1963
|
description: "CMS model (table) to use.",
|
|
2177
1964
|
options: function options(_, ctx) {
|
|
2178
1965
|
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
1966
|
+
},
|
|
1967
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1968
|
+
return ctx == null ? void 0 : ctx.table;
|
|
2179
1969
|
}
|
|
2180
1970
|
},
|
|
2181
1971
|
field: {
|
|
2182
1972
|
type: "choice",
|
|
2183
1973
|
displayName: "Field",
|
|
2184
1974
|
description: "Field (from model schema) to use.",
|
|
2185
|
-
options: function options(
|
|
1975
|
+
options: function options(_ref11, ctx) {
|
|
2186
1976
|
var _ctx$table3;
|
|
2187
1977
|
|
|
2188
|
-
var table =
|
|
2189
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table);
|
|
1978
|
+
var table = _ref11.table;
|
|
1979
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["image"]);
|
|
1980
|
+
},
|
|
1981
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1982
|
+
var _ctx$fieldMeta5, _ctx$fieldMeta6;
|
|
1983
|
+
|
|
1984
|
+
return (ctx == null ? void 0 : (_ctx$fieldMeta5 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta5.name) || (ctx == null ? void 0 : (_ctx$fieldMeta6 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta6.identifier);
|
|
2190
1985
|
}
|
|
2191
1986
|
},
|
|
2192
1987
|
srcProp: {
|
|
@@ -2197,29 +1992,21 @@ var cmsRowImageMeta = {
|
|
|
2197
1992
|
}
|
|
2198
1993
|
}
|
|
2199
1994
|
};
|
|
2200
|
-
function CmsRowImage(
|
|
1995
|
+
function CmsRowImage(_ref12) {
|
|
2201
1996
|
var _res$row$data3;
|
|
2202
1997
|
|
|
2203
|
-
var table =
|
|
2204
|
-
field =
|
|
2205
|
-
srcProp =
|
|
2206
|
-
children =
|
|
2207
|
-
setControlContextData =
|
|
2208
|
-
var tables =
|
|
2209
|
-
var res = useRow(table);
|
|
1998
|
+
var table = _ref12.table,
|
|
1999
|
+
field = _ref12.field,
|
|
2000
|
+
srcProp = _ref12.srcProp,
|
|
2001
|
+
children = _ref12.children,
|
|
2002
|
+
setControlContextData = _ref12.setControlContextData;
|
|
2003
|
+
var tables = useTablesWithDataLoaded();
|
|
2004
|
+
var res = useRow(tables, table);
|
|
2210
2005
|
|
|
2211
2006
|
if (!res || !res.row) {
|
|
2212
2007
|
return React.createElement(React.Fragment, null, children);
|
|
2213
2008
|
}
|
|
2214
2009
|
|
|
2215
|
-
if (tables) {
|
|
2216
|
-
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
2217
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2218
|
-
tables: tables,
|
|
2219
|
-
table: res.table
|
|
2220
|
-
});
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
2010
|
var fieldMeta = deriveInferredTableField({
|
|
2224
2011
|
table: res.table,
|
|
2225
2012
|
tables: tables,
|
|
@@ -2227,6 +2014,16 @@ function CmsRowImage(_ref17) {
|
|
|
2227
2014
|
typeFilters: ["image"]
|
|
2228
2015
|
});
|
|
2229
2016
|
|
|
2017
|
+
if (tables) {
|
|
2018
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
2019
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
2020
|
+
tables: tables,
|
|
2021
|
+
table: res.table,
|
|
2022
|
+
row: res.row,
|
|
2023
|
+
fieldMeta: fieldMeta
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2230
2027
|
if (!fieldMeta) {
|
|
2231
2028
|
return React.createElement(React.Fragment, null, children);
|
|
2232
2029
|
}
|
|
@@ -2268,17 +2065,25 @@ var cmsRowFieldValueMeta = {
|
|
|
2268
2065
|
description: "CMS model (table) to use.",
|
|
2269
2066
|
options: function options(_, ctx) {
|
|
2270
2067
|
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
2068
|
+
},
|
|
2069
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
2070
|
+
return ctx == null ? void 0 : ctx.table;
|
|
2271
2071
|
}
|
|
2272
2072
|
},
|
|
2273
2073
|
field: {
|
|
2274
2074
|
type: "choice",
|
|
2275
2075
|
displayName: "Field",
|
|
2276
2076
|
description: "Field (from model schema) to use.",
|
|
2277
|
-
options: function options(
|
|
2077
|
+
options: function options(_ref13, ctx) {
|
|
2278
2078
|
var _ctx$table4;
|
|
2279
2079
|
|
|
2280
|
-
var table =
|
|
2080
|
+
var table = _ref13.table;
|
|
2281
2081
|
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
|
|
2082
|
+
},
|
|
2083
|
+
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
2084
|
+
var _ctx$fieldMeta7, _ctx$fieldMeta8;
|
|
2085
|
+
|
|
2086
|
+
return (ctx == null ? void 0 : (_ctx$fieldMeta7 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta7.name) || (ctx == null ? void 0 : (_ctx$fieldMeta8 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta8.identifier);
|
|
2282
2087
|
}
|
|
2283
2088
|
},
|
|
2284
2089
|
valueProp: {
|
|
@@ -2289,31 +2094,23 @@ var cmsRowFieldValueMeta = {
|
|
|
2289
2094
|
}
|
|
2290
2095
|
}
|
|
2291
2096
|
};
|
|
2292
|
-
function CmsRowFieldValue(
|
|
2097
|
+
function CmsRowFieldValue(_ref14) {
|
|
2293
2098
|
var _res$row$data4;
|
|
2294
2099
|
|
|
2295
|
-
var table =
|
|
2296
|
-
field =
|
|
2297
|
-
valueProp =
|
|
2298
|
-
children =
|
|
2299
|
-
setControlContextData =
|
|
2300
|
-
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);
|
|
2301
2106
|
|
|
2302
|
-
var tables =
|
|
2303
|
-
var res = useRow(table);
|
|
2107
|
+
var tables = useTablesWithDataLoaded();
|
|
2108
|
+
var res = useRow(tables, table);
|
|
2304
2109
|
|
|
2305
2110
|
if (!res || !res.row) {
|
|
2306
2111
|
return React.createElement(React.Fragment, null, children);
|
|
2307
2112
|
}
|
|
2308
2113
|
|
|
2309
|
-
if (tables) {
|
|
2310
|
-
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
2311
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2312
|
-
tables: tables,
|
|
2313
|
-
table: res.table
|
|
2314
|
-
});
|
|
2315
|
-
}
|
|
2316
|
-
|
|
2317
2114
|
var fieldMeta = deriveInferredTableField({
|
|
2318
2115
|
table: res.table,
|
|
2319
2116
|
tables: tables,
|
|
@@ -2321,6 +2118,16 @@ function CmsRowFieldValue(_ref19) {
|
|
|
2321
2118
|
typeFilters: ["text"]
|
|
2322
2119
|
});
|
|
2323
2120
|
|
|
2121
|
+
if (tables) {
|
|
2122
|
+
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
2123
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
2124
|
+
tables: tables,
|
|
2125
|
+
table: res.table,
|
|
2126
|
+
row: res.row,
|
|
2127
|
+
fieldMeta: fieldMeta
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2324
2131
|
if (!fieldMeta) {
|
|
2325
2132
|
return React.createElement(React.Fragment, null, children);
|
|
2326
2133
|
}
|
|
@@ -2337,106 +2144,6 @@ function CmsRowFieldValue(_ref19) {
|
|
|
2337
2144
|
});
|
|
2338
2145
|
return React.createElement(React.Fragment, null, childrenWithProps);
|
|
2339
2146
|
}
|
|
2340
|
-
var cmsRowLoaderMeta = {
|
|
2341
|
-
name: componentPrefix + "-row-loader",
|
|
2342
|
-
displayName: "CMS Row Loader",
|
|
2343
|
-
importName: "CmsRowLoader",
|
|
2344
|
-
importPath: modulePath,
|
|
2345
|
-
props: /*#__PURE__*/_extends({
|
|
2346
|
-
children: {
|
|
2347
|
-
type: "slot",
|
|
2348
|
-
defaultValue: {
|
|
2349
|
-
type: "component",
|
|
2350
|
-
name: componentPrefix + "-row-field"
|
|
2351
|
-
}
|
|
2352
|
-
},
|
|
2353
|
-
row: {
|
|
2354
|
-
type: "string",
|
|
2355
|
-
displayName: "Entry ID",
|
|
2356
|
-
description: "Row identifier to query."
|
|
2357
|
-
},
|
|
2358
|
-
table: {
|
|
2359
|
-
type: "choice",
|
|
2360
|
-
displayName: "Model",
|
|
2361
|
-
description: "CMS model (table) to query.",
|
|
2362
|
-
options: function options(_, ctx) {
|
|
2363
|
-
return mkTableOptions(ctx == null ? void 0 : ctx.tables);
|
|
2364
|
-
}
|
|
2365
|
-
},
|
|
2366
|
-
useDraft: {
|
|
2367
|
-
type: "boolean",
|
|
2368
|
-
displayName: "Use drafts?",
|
|
2369
|
-
description: "If set, also query unpublished content.",
|
|
2370
|
-
defaultValue: false
|
|
2371
|
-
}
|
|
2372
|
-
}, fetcherComponentPropMetas)
|
|
2373
|
-
};
|
|
2374
|
-
function CmsRowLoader(_ref20) {
|
|
2375
|
-
var table = _ref20.table,
|
|
2376
|
-
row = _ref20.row,
|
|
2377
|
-
children = _ref20.children,
|
|
2378
|
-
useDraft = _ref20.useDraft,
|
|
2379
|
-
hideIfNotFound = _ref20.hideIfNotFound,
|
|
2380
|
-
setControlContextData = _ref20.setControlContextData;
|
|
2381
|
-
var databaseConfig = useDatabase();
|
|
2382
|
-
var tables = useTables();
|
|
2383
|
-
|
|
2384
|
-
if (tables) {
|
|
2385
|
-
setControlContextData == null ? void 0 : setControlContextData({
|
|
2386
|
-
tables: tables
|
|
2387
|
-
});
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
var cacheKey = JSON.stringify({
|
|
2391
|
-
component: "CmsRowLoader",
|
|
2392
|
-
table: table,
|
|
2393
|
-
row: row,
|
|
2394
|
-
databaseConfig: databaseConfig,
|
|
2395
|
-
useDraft: useDraft
|
|
2396
|
-
});
|
|
2397
|
-
var maybeData = usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
2398
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2399
|
-
while (1) {
|
|
2400
|
-
switch (_context4.prev = _context4.next) {
|
|
2401
|
-
case 0:
|
|
2402
|
-
if (table) {
|
|
2403
|
-
_context4.next = 2;
|
|
2404
|
-
break;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
throw new Error("You must specify a model to fetch from.");
|
|
2408
|
-
|
|
2409
|
-
case 2:
|
|
2410
|
-
if (row) {
|
|
2411
|
-
_context4.next = 4;
|
|
2412
|
-
break;
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
throw new Error("You must specify an entry name to fetch.");
|
|
2416
|
-
|
|
2417
|
-
case 4:
|
|
2418
|
-
_context4.next = 6;
|
|
2419
|
-
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
2420
|
-
|
|
2421
|
-
case 6:
|
|
2422
|
-
return _context4.abrupt("return", _context4.sent);
|
|
2423
|
-
|
|
2424
|
-
case 7:
|
|
2425
|
-
case "end":
|
|
2426
|
-
return _context4.stop();
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
}, _callee4);
|
|
2430
|
-
})));
|
|
2431
|
-
return renderMaybeData(maybeData, function (row) {
|
|
2432
|
-
return React.createElement(RowProvider, {
|
|
2433
|
-
table: table,
|
|
2434
|
-
row: row
|
|
2435
|
-
}, children);
|
|
2436
|
-
}, {
|
|
2437
|
-
hideIfNotFound: hideIfNotFound
|
|
2438
|
-
});
|
|
2439
|
-
}
|
|
2440
2147
|
|
|
2441
2148
|
function registerAll(loader) {
|
|
2442
2149
|
//const registerContext = loader?.registerContext ?? hostRegisterContext;
|
|
@@ -2457,9 +2164,7 @@ function registerAll(loader) {
|
|
|
2457
2164
|
}
|
|
2458
2165
|
};
|
|
2459
2166
|
|
|
2460
|
-
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2461
|
-
// _registerComponent(CmsRowRepeater, cmsRowRepeaterMeta);
|
|
2462
|
-
|
|
2167
|
+
_registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
|
|
2463
2168
|
|
|
2464
2169
|
_registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
|
|
2465
2170
|
|
|
@@ -2469,9 +2174,8 @@ function registerAll(loader) {
|
|
|
2469
2174
|
|
|
2470
2175
|
_registerComponent(CmsRowImage, cmsRowImageMeta);
|
|
2471
2176
|
|
|
2472
|
-
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2473
|
-
|
|
2177
|
+
_registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
|
|
2474
2178
|
}
|
|
2475
2179
|
|
|
2476
|
-
export { CmsCredentialsProvider,
|
|
2180
|
+
export { CmsCredentialsProvider, CmsQueryRepeater, CmsRowField, CmsRowFieldValue, CmsRowImage, CmsRowLink, cmsCredentialsProviderMeta, cmsQueryRepeaterMeta, cmsRowFieldMeta, cmsRowFieldValueMeta, cmsRowImageMeta, cmsRowLinkMeta, registerAll };
|
|
2477
2181
|
//# sourceMappingURL=plasmic-cms.esm.js.map
|