@plasmicpkgs/plasmic-cms 0.0.69 → 0.0.72
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/api.d.ts +0 -1
- package/dist/plasmic-cms.cjs.development.js +54 -85
- 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 +16 -48
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/api.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ declare class API {
|
|
|
22
22
|
get(endpoint: string, params?: {}): Promise<any>;
|
|
23
23
|
fetchTables(): Promise<ApiCmsTable[]>;
|
|
24
24
|
query(table: string, params: QueryParams): Promise<ApiCmsRow[]>;
|
|
25
|
-
fetchRow(table: string, row: string, useDraft: boolean): Promise<ApiCmsRow>;
|
|
26
25
|
}
|
|
27
26
|
export declare function mkApi(config: DatabaseConfig | undefined): API;
|
|
28
27
|
export {};
|
|
@@ -9,7 +9,8 @@ var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGl
|
|
|
9
9
|
var host = require('@plasmicapp/host');
|
|
10
10
|
var query = require('@plasmicapp/query');
|
|
11
11
|
var dayjs = _interopDefault(require('dayjs'));
|
|
12
|
-
var React =
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var React__default = _interopDefault(React);
|
|
13
14
|
|
|
14
15
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15
16
|
try {
|
|
@@ -1097,45 +1098,6 @@ var API = /*#__PURE__*/function () {
|
|
|
1097
1098
|
return query;
|
|
1098
1099
|
}();
|
|
1099
1100
|
|
|
1100
|
-
_proto.fetchRow = /*#__PURE__*/function () {
|
|
1101
|
-
var _fetchRow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(table, row, useDraft) {
|
|
1102
|
-
var response;
|
|
1103
|
-
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1104
|
-
while (1) {
|
|
1105
|
-
switch (_context4.prev = _context4.next) {
|
|
1106
|
-
case 0:
|
|
1107
|
-
_context4.prev = 0;
|
|
1108
|
-
_context4.next = 3;
|
|
1109
|
-
return this.get("/tables/" + table + "/rows/" + row, {
|
|
1110
|
-
draft: Number(useDraft),
|
|
1111
|
-
locale: this.config.locale
|
|
1112
|
-
});
|
|
1113
|
-
|
|
1114
|
-
case 3:
|
|
1115
|
-
response = _context4.sent;
|
|
1116
|
-
return _context4.abrupt("return", response);
|
|
1117
|
-
|
|
1118
|
-
case 7:
|
|
1119
|
-
_context4.prev = 7;
|
|
1120
|
-
_context4.t0 = _context4["catch"](0);
|
|
1121
|
-
console.error(_context4.t0);
|
|
1122
|
-
throw _context4.t0;
|
|
1123
|
-
|
|
1124
|
-
case 11:
|
|
1125
|
-
case "end":
|
|
1126
|
-
return _context4.stop();
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}, _callee4, this, [[0, 7]]);
|
|
1130
|
-
}));
|
|
1131
|
-
|
|
1132
|
-
function fetchRow(_x5, _x6, _x7) {
|
|
1133
|
-
return _fetchRow.apply(this, arguments);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
return fetchRow;
|
|
1137
|
-
}();
|
|
1138
|
-
|
|
1139
1101
|
return API;
|
|
1140
1102
|
}();
|
|
1141
1103
|
|
|
@@ -1168,7 +1130,7 @@ function useDatabase() {
|
|
|
1168
1130
|
function DatabaseProvider(_ref) {
|
|
1169
1131
|
var config = _ref.config,
|
|
1170
1132
|
children = _ref.children;
|
|
1171
|
-
return
|
|
1133
|
+
return React__default.createElement(host.DataProvider, {
|
|
1172
1134
|
name: databaseContextKey,
|
|
1173
1135
|
data: config
|
|
1174
1136
|
}, children);
|
|
@@ -1179,7 +1141,7 @@ function useTables() {
|
|
|
1179
1141
|
function TablesProvider(_ref2) {
|
|
1180
1142
|
var children = _ref2.children,
|
|
1181
1143
|
tables = _ref2.tables;
|
|
1182
|
-
return
|
|
1144
|
+
return React__default.createElement(host.DataProvider, {
|
|
1183
1145
|
name: tablesContextKey,
|
|
1184
1146
|
data: tables
|
|
1185
1147
|
}, children);
|
|
@@ -1195,7 +1157,7 @@ function QueryResultProvider(_ref3) {
|
|
|
1195
1157
|
var children = _ref3.children,
|
|
1196
1158
|
table = _ref3.table,
|
|
1197
1159
|
rows = _ref3.rows;
|
|
1198
|
-
return
|
|
1160
|
+
return React__default.createElement(host.DataProvider, {
|
|
1199
1161
|
name: mkQueryContextKey(table),
|
|
1200
1162
|
data: rows
|
|
1201
1163
|
}, children);
|
|
@@ -1243,7 +1205,7 @@ function RowProvider(_ref4) {
|
|
|
1243
1205
|
var children = _ref4.children,
|
|
1244
1206
|
table = _ref4.table,
|
|
1245
1207
|
row = _ref4.row;
|
|
1246
|
-
return
|
|
1208
|
+
return React__default.createElement(host.DataProvider, {
|
|
1247
1209
|
name: mkRowContextKey(table),
|
|
1248
1210
|
data: row
|
|
1249
1211
|
}, children);
|
|
@@ -1296,23 +1258,27 @@ var _excluded = ["children"],
|
|
|
1296
1258
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1297
1259
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1298
1260
|
|
|
1299
|
-
function renderMaybeData(maybeData, renderFn, loaderProps, loadingMessage, forceLoadingState) {
|
|
1261
|
+
function renderMaybeData(maybeData, renderFn, loaderProps, inEditor, loadingMessage, forceLoadingState) {
|
|
1300
1262
|
if ("error" in maybeData) {
|
|
1301
1263
|
var error = maybeData.error;
|
|
1302
1264
|
|
|
1265
|
+
if (!inEditor) {
|
|
1266
|
+
return React__default.createElement(React__default.Fragment, null, loadingMessage != null ? loadingMessage : React__default.createElement("div", null, "Loading..."));
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1303
1269
|
if (error && error instanceof HttpError && error.status === 404) {
|
|
1304
1270
|
if (loaderProps.hideIfNotFound) {
|
|
1305
1271
|
return null;
|
|
1306
1272
|
} else {
|
|
1307
|
-
return
|
|
1273
|
+
return React__default.createElement("div", null, "Error: Data not found");
|
|
1308
1274
|
}
|
|
1309
1275
|
} else {
|
|
1310
|
-
return
|
|
1276
|
+
return React__default.createElement("div", null, "Error: ", error == null ? void 0 : error.message);
|
|
1311
1277
|
}
|
|
1312
1278
|
}
|
|
1313
1279
|
|
|
1314
1280
|
if (!("data" in maybeData) || forceLoadingState) {
|
|
1315
|
-
return
|
|
1281
|
+
return React__default.createElement(React__default.Fragment, null, loadingMessage != null ? loadingMessage : React__default.createElement("div", null, "Loading..."));
|
|
1316
1282
|
}
|
|
1317
1283
|
|
|
1318
1284
|
return renderFn(maybeData.data);
|
|
@@ -1355,9 +1321,9 @@ function CmsCredentialsProvider(_ref) {
|
|
|
1355
1321
|
config = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1356
1322
|
|
|
1357
1323
|
config.host = config.host || defaultHost;
|
|
1358
|
-
return
|
|
1324
|
+
return React__default.createElement(DatabaseProvider, {
|
|
1359
1325
|
config: config
|
|
1360
|
-
},
|
|
1326
|
+
}, React__default.createElement(TablesFetcher, null, children));
|
|
1361
1327
|
}
|
|
1362
1328
|
|
|
1363
1329
|
function TablesFetcher(_ref2) {
|
|
@@ -1393,13 +1359,14 @@ function TablesFetcher(_ref2) {
|
|
|
1393
1359
|
}
|
|
1394
1360
|
}, _callee);
|
|
1395
1361
|
})));
|
|
1362
|
+
var inEditor = !!React.useContext(host.PlasmicCanvasContext);
|
|
1396
1363
|
return renderMaybeData(maybeData, function (tables) {
|
|
1397
|
-
return
|
|
1364
|
+
return React__default.createElement(TablesProvider, {
|
|
1398
1365
|
tables: tables
|
|
1399
1366
|
}, children);
|
|
1400
1367
|
}, {
|
|
1401
1368
|
hideIfNotFound: false
|
|
1402
|
-
}, children);
|
|
1369
|
+
}, inEditor, children);
|
|
1403
1370
|
}
|
|
1404
1371
|
|
|
1405
1372
|
function isDatabaseConfigured(config) {
|
|
@@ -1620,27 +1587,28 @@ function CmsQueryRepeater(_ref5) {
|
|
|
1620
1587
|
}
|
|
1621
1588
|
}, _callee2);
|
|
1622
1589
|
})));
|
|
1590
|
+
var inEditor = !!React.useContext(host.PlasmicCanvasContext);
|
|
1623
1591
|
var node = renderMaybeData(maybeData, function (rows) {
|
|
1624
1592
|
if (rows.length === 0 || forceEmptyState) {
|
|
1625
|
-
return
|
|
1593
|
+
return React__default.createElement(QueryResultProvider, {
|
|
1626
1594
|
table: table,
|
|
1627
1595
|
rows: rows
|
|
1628
1596
|
}, emptyMessage);
|
|
1629
1597
|
}
|
|
1630
1598
|
|
|
1631
|
-
return
|
|
1599
|
+
return React__default.createElement(QueryResultProvider, {
|
|
1632
1600
|
table: table,
|
|
1633
1601
|
rows: rows
|
|
1634
1602
|
}, rows.map(function (row, index) {
|
|
1635
|
-
return
|
|
1603
|
+
return React__default.createElement(RowProvider, {
|
|
1636
1604
|
table: table,
|
|
1637
1605
|
row: row
|
|
1638
1606
|
}, host.repeatedElement(index === 0, children));
|
|
1639
1607
|
}));
|
|
1640
1608
|
}, {
|
|
1641
1609
|
hideIfNotFound: false
|
|
1642
|
-
}, loadingMessage, forceLoadingState);
|
|
1643
|
-
return noLayout ?
|
|
1610
|
+
}, inEditor, loadingMessage, forceLoadingState);
|
|
1611
|
+
return noLayout ? React__default.createElement(React__default.Fragment, null, " ", node, " ") : React__default.createElement("div", {
|
|
1644
1612
|
className: className
|
|
1645
1613
|
}, " ", node, " ");
|
|
1646
1614
|
}
|
|
@@ -1762,15 +1730,16 @@ function CmsRowField(_ref9) {
|
|
|
1762
1730
|
|
|
1763
1731
|
var tables = useTablesWithDataLoaded();
|
|
1764
1732
|
var res = useRow(tables, table);
|
|
1733
|
+
var unknown = React__default.createElement("div", Object.assign({
|
|
1734
|
+
className: className
|
|
1735
|
+
}, rest), "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1765
1736
|
|
|
1766
1737
|
if (!res) {
|
|
1767
|
-
return
|
|
1768
|
-
className: className
|
|
1769
|
-
}, "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
|
|
1738
|
+
return unknown;
|
|
1770
1739
|
}
|
|
1771
1740
|
|
|
1772
1741
|
if (!res.row) {
|
|
1773
|
-
return
|
|
1742
|
+
return React__default.createElement("div", {
|
|
1774
1743
|
className: className
|
|
1775
1744
|
}, "Error: No CMS Entry found");
|
|
1776
1745
|
}
|
|
@@ -1793,7 +1762,7 @@ function CmsRowField(_ref9) {
|
|
|
1793
1762
|
}
|
|
1794
1763
|
|
|
1795
1764
|
if (!fieldMeta) {
|
|
1796
|
-
|
|
1765
|
+
return unknown;
|
|
1797
1766
|
}
|
|
1798
1767
|
|
|
1799
1768
|
var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
|
|
@@ -1842,10 +1811,10 @@ function renderValue(value, type, props) {
|
|
|
1842
1811
|
case "text":
|
|
1843
1812
|
case "long-text":
|
|
1844
1813
|
case "date-time":
|
|
1845
|
-
return
|
|
1814
|
+
return React__default.createElement("div", Object.assign({}, props), value);
|
|
1846
1815
|
|
|
1847
1816
|
case "rich-text":
|
|
1848
|
-
return
|
|
1817
|
+
return React__default.createElement("div", Object.assign({
|
|
1849
1818
|
dangerouslySetInnerHTML: {
|
|
1850
1819
|
__html: value
|
|
1851
1820
|
}
|
|
@@ -1853,7 +1822,7 @@ function renderValue(value, type, props) {
|
|
|
1853
1822
|
|
|
1854
1823
|
case "image":
|
|
1855
1824
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
1856
|
-
return
|
|
1825
|
+
return React__default.createElement("img", Object.assign({
|
|
1857
1826
|
src: value.url,
|
|
1858
1827
|
width: value.imageMeta.width,
|
|
1859
1828
|
height: value.imageMeta.height,
|
|
@@ -1867,7 +1836,7 @@ function renderValue(value, type, props) {
|
|
|
1867
1836
|
|
|
1868
1837
|
case "file":
|
|
1869
1838
|
if (value && typeof value === "object" && value.url && value.name) {
|
|
1870
|
-
return
|
|
1839
|
+
return React__default.createElement("a", Object.assign({
|
|
1871
1840
|
href: value.url,
|
|
1872
1841
|
target: "_blank"
|
|
1873
1842
|
}, props), value.name);
|
|
@@ -1963,7 +1932,7 @@ function CmsRowLink(_ref11) {
|
|
|
1963
1932
|
var res = useRow(tables, table);
|
|
1964
1933
|
|
|
1965
1934
|
if (!res || !res.row) {
|
|
1966
|
-
return
|
|
1935
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
1967
1936
|
}
|
|
1968
1937
|
|
|
1969
1938
|
var fieldMeta = deriveInferredTableField({
|
|
@@ -1984,7 +1953,7 @@ function CmsRowLink(_ref11) {
|
|
|
1984
1953
|
}
|
|
1985
1954
|
|
|
1986
1955
|
if (!fieldMeta) {
|
|
1987
|
-
return
|
|
1956
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
1988
1957
|
}
|
|
1989
1958
|
|
|
1990
1959
|
if (!children) {
|
|
@@ -1992,16 +1961,16 @@ function CmsRowLink(_ref11) {
|
|
|
1992
1961
|
}
|
|
1993
1962
|
|
|
1994
1963
|
var value = ((_res$row$data2 = res.row.data) == null ? void 0 : _res$row$data2[fieldMeta.identifier]) || "";
|
|
1995
|
-
var childrenWithProps =
|
|
1996
|
-
if (
|
|
1964
|
+
var childrenWithProps = React__default.Children.map(children, function (child) {
|
|
1965
|
+
if (React__default.isValidElement(child)) {
|
|
1997
1966
|
var _React$cloneElement;
|
|
1998
1967
|
|
|
1999
|
-
return
|
|
1968
|
+
return React__default.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
2000
1969
|
}
|
|
2001
1970
|
|
|
2002
1971
|
return child;
|
|
2003
1972
|
});
|
|
2004
|
-
return
|
|
1973
|
+
return React__default.createElement(React__default.Fragment, null, childrenWithProps != null ? childrenWithProps : null);
|
|
2005
1974
|
}
|
|
2006
1975
|
var cmsRowImageMeta = {
|
|
2007
1976
|
name: componentPrefix + "-row-image",
|
|
@@ -2063,7 +2032,7 @@ function CmsRowImage(_ref13) {
|
|
|
2063
2032
|
var res = useRow(tables, table);
|
|
2064
2033
|
|
|
2065
2034
|
if (!res || !res.row) {
|
|
2066
|
-
return
|
|
2035
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
2067
2036
|
}
|
|
2068
2037
|
|
|
2069
2038
|
var fieldMeta = deriveInferredTableField({
|
|
@@ -2084,30 +2053,30 @@ function CmsRowImage(_ref13) {
|
|
|
2084
2053
|
}
|
|
2085
2054
|
|
|
2086
2055
|
if (!fieldMeta) {
|
|
2087
|
-
return
|
|
2056
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
2088
2057
|
}
|
|
2089
2058
|
|
|
2090
2059
|
var value = ((_res$row$data3 = res.row.data) == null ? void 0 : _res$row$data3[fieldMeta.identifier]) || "";
|
|
2091
|
-
var childrenWithProps =
|
|
2092
|
-
if (
|
|
2060
|
+
var childrenWithProps = React__default.Children.map(children, function (child) {
|
|
2061
|
+
if (React__default.isValidElement(child) && value) {
|
|
2093
2062
|
var _React$cloneElement3;
|
|
2094
2063
|
|
|
2095
2064
|
if (typeof value === "object" && value.url && value.imageMeta) {
|
|
2096
2065
|
var _React$cloneElement2;
|
|
2097
2066
|
|
|
2098
|
-
return
|
|
2067
|
+
return React__default.cloneElement(child, (_React$cloneElement2 = {}, _React$cloneElement2[srcProp] = {
|
|
2099
2068
|
src: value.url,
|
|
2100
2069
|
fullHeight: value.imageMeta.height,
|
|
2101
2070
|
fullWidth: value.imageMeta.width
|
|
2102
2071
|
}, _React$cloneElement2));
|
|
2103
2072
|
}
|
|
2104
2073
|
|
|
2105
|
-
return
|
|
2074
|
+
return React__default.cloneElement(child, (_React$cloneElement3 = {}, _React$cloneElement3[srcProp] = value, _React$cloneElement3));
|
|
2106
2075
|
}
|
|
2107
2076
|
|
|
2108
2077
|
return child;
|
|
2109
2078
|
});
|
|
2110
|
-
return
|
|
2079
|
+
return React__default.createElement(React__default.Fragment, null, childrenWithProps);
|
|
2111
2080
|
}
|
|
2112
2081
|
var cmsRowFieldValueMeta = {
|
|
2113
2082
|
name: componentPrefix + "-row-value",
|
|
@@ -2167,7 +2136,7 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2167
2136
|
var res = useRow(tables, table);
|
|
2168
2137
|
|
|
2169
2138
|
if (!res || !res.row) {
|
|
2170
|
-
return
|
|
2139
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
2171
2140
|
}
|
|
2172
2141
|
|
|
2173
2142
|
var fieldMeta = deriveInferredTableField({
|
|
@@ -2188,20 +2157,20 @@ function CmsRowFieldValue(_ref15) {
|
|
|
2188
2157
|
}
|
|
2189
2158
|
|
|
2190
2159
|
if (!fieldMeta) {
|
|
2191
|
-
return
|
|
2160
|
+
return React__default.createElement(React__default.Fragment, null, children);
|
|
2192
2161
|
}
|
|
2193
2162
|
|
|
2194
2163
|
var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
|
|
2195
|
-
var childrenWithProps =
|
|
2196
|
-
if (
|
|
2164
|
+
var childrenWithProps = React__default.Children.map(children, function (child) {
|
|
2165
|
+
if (React__default.isValidElement(child)) {
|
|
2197
2166
|
var _extends2;
|
|
2198
2167
|
|
|
2199
|
-
return
|
|
2168
|
+
return React__default.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
|
|
2200
2169
|
}
|
|
2201
2170
|
|
|
2202
2171
|
return child;
|
|
2203
2172
|
});
|
|
2204
|
-
return
|
|
2173
|
+
return React__default.createElement(React__default.Fragment, null, childrenWithProps);
|
|
2205
2174
|
}
|
|
2206
2175
|
|
|
2207
2176
|
function registerAll(loader) {
|