@plasmicpkgs/plasmic-cms 0.0.7 → 0.0.10
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 +4 -0
- package/dist/components.d.ts +6 -3
- package/dist/plasmic-cms.cjs.development.js +225 -16
- 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 +225 -16
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/plasmic-cms.esm.js
CHANGED
|
@@ -39,6 +39,115 @@ function _asyncToGenerator(fn) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
function _extends() {
|
|
43
|
+
_extends = Object.assign || function (target) {
|
|
44
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
45
|
+
var source = arguments[i];
|
|
46
|
+
|
|
47
|
+
for (var key in source) {
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
49
|
+
target[key] = source[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return target;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return _extends.apply(this, arguments);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _inheritsLoose(subClass, superClass) {
|
|
61
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
62
|
+
subClass.prototype.constructor = subClass;
|
|
63
|
+
|
|
64
|
+
_setPrototypeOf(subClass, superClass);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _getPrototypeOf(o) {
|
|
68
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
69
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
70
|
+
};
|
|
71
|
+
return _getPrototypeOf(o);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _setPrototypeOf(o, p) {
|
|
75
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
76
|
+
o.__proto__ = p;
|
|
77
|
+
return o;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return _setPrototypeOf(o, p);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function _isNativeReflectConstruct() {
|
|
84
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
85
|
+
if (Reflect.construct.sham) return false;
|
|
86
|
+
if (typeof Proxy === "function") return true;
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
90
|
+
return true;
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function _construct(Parent, args, Class) {
|
|
97
|
+
if (_isNativeReflectConstruct()) {
|
|
98
|
+
_construct = Reflect.construct;
|
|
99
|
+
} else {
|
|
100
|
+
_construct = function _construct(Parent, args, Class) {
|
|
101
|
+
var a = [null];
|
|
102
|
+
a.push.apply(a, args);
|
|
103
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
104
|
+
var instance = new Constructor();
|
|
105
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
106
|
+
return instance;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return _construct.apply(null, arguments);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function _isNativeFunction(fn) {
|
|
114
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function _wrapNativeSuper(Class) {
|
|
118
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
119
|
+
|
|
120
|
+
_wrapNativeSuper = function _wrapNativeSuper(Class) {
|
|
121
|
+
if (Class === null || !_isNativeFunction(Class)) return Class;
|
|
122
|
+
|
|
123
|
+
if (typeof Class !== "function") {
|
|
124
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (typeof _cache !== "undefined") {
|
|
128
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
129
|
+
|
|
130
|
+
_cache.set(Class, Wrapper);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function Wrapper() {
|
|
134
|
+
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
138
|
+
constructor: {
|
|
139
|
+
value: Wrapper,
|
|
140
|
+
enumerable: false,
|
|
141
|
+
writable: true,
|
|
142
|
+
configurable: true
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return _setPrototypeOf(Wrapper, Class);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return _wrapNativeSuper(Class);
|
|
149
|
+
}
|
|
150
|
+
|
|
42
151
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
43
152
|
if (source == null) return {};
|
|
44
153
|
var target = {};
|
|
@@ -863,6 +972,20 @@ function queryParamsToApi(params) {
|
|
|
863
972
|
};
|
|
864
973
|
}
|
|
865
974
|
|
|
975
|
+
var HttpError = /*#__PURE__*/function (_Error) {
|
|
976
|
+
_inheritsLoose(HttpError, _Error);
|
|
977
|
+
|
|
978
|
+
function HttpError(status, message) {
|
|
979
|
+
var _this;
|
|
980
|
+
|
|
981
|
+
_this = _Error.call(this, message) || this;
|
|
982
|
+
_this.status = status;
|
|
983
|
+
return _this;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
return HttpError;
|
|
987
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
988
|
+
|
|
866
989
|
var API = /*#__PURE__*/function () {
|
|
867
990
|
function API(config) {
|
|
868
991
|
this.config = config;
|
|
@@ -872,7 +995,8 @@ var API = /*#__PURE__*/function () {
|
|
|
872
995
|
|
|
873
996
|
_proto.get = /*#__PURE__*/function () {
|
|
874
997
|
var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(endpoint, params) {
|
|
875
|
-
var url, response
|
|
998
|
+
var url, response, message, _yield$response$json, _yield$response$json$;
|
|
999
|
+
|
|
876
1000
|
return runtime_1.wrap(function _callee$(_context) {
|
|
877
1001
|
while (1) {
|
|
878
1002
|
switch (_context.prev = _context.next) {
|
|
@@ -895,18 +1019,61 @@ var API = /*#__PURE__*/function () {
|
|
|
895
1019
|
|
|
896
1020
|
case 5:
|
|
897
1021
|
response = _context.sent;
|
|
898
|
-
|
|
1022
|
+
|
|
1023
|
+
if (!(response.status !== 200)) {
|
|
1024
|
+
_context.next = 25;
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
_context.prev = 7;
|
|
1029
|
+
_context.next = 10;
|
|
899
1030
|
return response.json();
|
|
900
1031
|
|
|
901
|
-
case
|
|
1032
|
+
case 10:
|
|
1033
|
+
_context.t0 = _yield$response$json = _context.sent;
|
|
1034
|
+
|
|
1035
|
+
if (!(_context.t0 == null)) {
|
|
1036
|
+
_context.next = 15;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
_context.t1 = void 0;
|
|
1041
|
+
_context.next = 16;
|
|
1042
|
+
break;
|
|
1043
|
+
|
|
1044
|
+
case 15:
|
|
1045
|
+
_context.t1 = (_yield$response$json$ = _yield$response$json.error) == null ? void 0 : _yield$response$json$.message;
|
|
1046
|
+
|
|
1047
|
+
case 16:
|
|
1048
|
+
message = _context.t1;
|
|
1049
|
+
_context.next = 24;
|
|
1050
|
+
break;
|
|
1051
|
+
|
|
1052
|
+
case 19:
|
|
1053
|
+
_context.prev = 19;
|
|
1054
|
+
_context.t2 = _context["catch"](7);
|
|
1055
|
+
_context.next = 23;
|
|
1056
|
+
return response.text();
|
|
1057
|
+
|
|
1058
|
+
case 23:
|
|
1059
|
+
message = _context.sent;
|
|
1060
|
+
|
|
1061
|
+
case 24:
|
|
1062
|
+
throw new HttpError(response.status, message);
|
|
1063
|
+
|
|
1064
|
+
case 25:
|
|
1065
|
+
_context.next = 27;
|
|
1066
|
+
return response.json();
|
|
1067
|
+
|
|
1068
|
+
case 27:
|
|
902
1069
|
return _context.abrupt("return", _context.sent);
|
|
903
1070
|
|
|
904
|
-
case
|
|
1071
|
+
case 28:
|
|
905
1072
|
case "end":
|
|
906
1073
|
return _context.stop();
|
|
907
1074
|
}
|
|
908
1075
|
}
|
|
909
|
-
}, _callee, this);
|
|
1076
|
+
}, _callee, this, [[7, 19]]);
|
|
910
1077
|
}));
|
|
911
1078
|
|
|
912
1079
|
function get(_x, _x2) {
|
|
@@ -935,7 +1102,7 @@ var API = /*#__PURE__*/function () {
|
|
|
935
1102
|
_context2.prev = 7;
|
|
936
1103
|
_context2.t0 = _context2["catch"](0);
|
|
937
1104
|
console.error(_context2.t0);
|
|
938
|
-
throw
|
|
1105
|
+
throw _context2.t0;
|
|
939
1106
|
|
|
940
1107
|
case 11:
|
|
941
1108
|
case "end":
|
|
@@ -974,7 +1141,7 @@ var API = /*#__PURE__*/function () {
|
|
|
974
1141
|
_context3.prev = 7;
|
|
975
1142
|
_context3.t0 = _context3["catch"](0);
|
|
976
1143
|
console.error(_context3.t0);
|
|
977
|
-
throw
|
|
1144
|
+
throw _context3.t0;
|
|
978
1145
|
|
|
979
1146
|
case 11:
|
|
980
1147
|
case "end":
|
|
@@ -999,7 +1166,7 @@ var API = /*#__PURE__*/function () {
|
|
|
999
1166
|
switch (_context4.prev = _context4.next) {
|
|
1000
1167
|
case 0:
|
|
1001
1168
|
_context4.prev = 0;
|
|
1002
|
-
maybeUseDraft = useDraft ? "?
|
|
1169
|
+
maybeUseDraft = useDraft ? "?draft=1" : "";
|
|
1003
1170
|
_context4.next = 4;
|
|
1004
1171
|
return this.get("/tables/" + table + "/rows/" + row + maybeUseDraft);
|
|
1005
1172
|
|
|
@@ -1011,7 +1178,7 @@ var API = /*#__PURE__*/function () {
|
|
|
1011
1178
|
_context4.prev = 8;
|
|
1012
1179
|
_context4.t0 = _context4["catch"](0);
|
|
1013
1180
|
console.error(_context4.t0);
|
|
1014
|
-
throw
|
|
1181
|
+
throw _context4.t0;
|
|
1015
1182
|
|
|
1016
1183
|
case 12:
|
|
1017
1184
|
case "end":
|
|
@@ -1233,12 +1400,27 @@ var _excluded = ["children"],
|
|
|
1233
1400
|
_excluded2 = ["table", "children", "setControlContextData"];
|
|
1234
1401
|
var modulePath = "@plasmicpkgs/plasmic-cms";
|
|
1235
1402
|
var componentPrefix = "hostless-plasmic-cms";
|
|
1403
|
+
var fetcherComponentPropMetas = {
|
|
1404
|
+
hideIfNotFound: {
|
|
1405
|
+
type: "boolean",
|
|
1406
|
+
defaultValue: false,
|
|
1407
|
+
description: "Whether to show an error if no result is found"
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1236
1410
|
|
|
1237
|
-
function renderMaybeData(maybeData, renderFn) {
|
|
1411
|
+
function renderMaybeData(maybeData, renderFn, loaderProps) {
|
|
1238
1412
|
if ("error" in maybeData) {
|
|
1239
|
-
var
|
|
1413
|
+
var error = maybeData.error;
|
|
1240
1414
|
|
|
1241
|
-
|
|
1415
|
+
if (error && error instanceof HttpError && error.status === 404) {
|
|
1416
|
+
if (loaderProps.hideIfNotFound) {
|
|
1417
|
+
return null;
|
|
1418
|
+
} else {
|
|
1419
|
+
return React.createElement("div", null, "Error: Data not found");
|
|
1420
|
+
}
|
|
1421
|
+
} else {
|
|
1422
|
+
return React.createElement("div", null, "Error: ", error == null ? void 0 : error.message);
|
|
1423
|
+
}
|
|
1242
1424
|
}
|
|
1243
1425
|
|
|
1244
1426
|
if (!("data" in maybeData)) {
|
|
@@ -1323,6 +1505,8 @@ function TablesFetcher(_ref2) {
|
|
|
1323
1505
|
return React.createElement(TablesProvider, {
|
|
1324
1506
|
tables: tables
|
|
1325
1507
|
}, children);
|
|
1508
|
+
}, {
|
|
1509
|
+
hideIfNotFound: false
|
|
1326
1510
|
});
|
|
1327
1511
|
}
|
|
1328
1512
|
|
|
@@ -1440,6 +1624,8 @@ function CmsQueryLoader(_ref5) {
|
|
|
1440
1624
|
table: table,
|
|
1441
1625
|
rows: rows
|
|
1442
1626
|
}, children);
|
|
1627
|
+
}, {
|
|
1628
|
+
hideIfNotFound: false
|
|
1443
1629
|
});
|
|
1444
1630
|
}
|
|
1445
1631
|
var cmsRowRepeaterMeta = {
|
|
@@ -1682,7 +1868,7 @@ var cmsRowLoaderMeta = {
|
|
|
1682
1868
|
displayName: "CMS Row Loader",
|
|
1683
1869
|
importName: "CmsRowLoader",
|
|
1684
1870
|
importPath: modulePath,
|
|
1685
|
-
props: {
|
|
1871
|
+
props: /*#__PURE__*/_extends({
|
|
1686
1872
|
children: {
|
|
1687
1873
|
type: "slot",
|
|
1688
1874
|
defaultValue: {
|
|
@@ -1709,13 +1895,14 @@ var cmsRowLoaderMeta = {
|
|
|
1709
1895
|
description: "If set, also query unpublished content.",
|
|
1710
1896
|
defaultValue: false
|
|
1711
1897
|
}
|
|
1712
|
-
}
|
|
1898
|
+
}, fetcherComponentPropMetas)
|
|
1713
1899
|
};
|
|
1714
1900
|
function CmsRowLoader(_ref12) {
|
|
1715
1901
|
var table = _ref12.table,
|
|
1716
1902
|
row = _ref12.row,
|
|
1717
1903
|
children = _ref12.children,
|
|
1718
1904
|
useDraft = _ref12.useDraft,
|
|
1905
|
+
hideIfNotFound = _ref12.hideIfNotFound,
|
|
1719
1906
|
setControlContextData = _ref12.setControlContextData;
|
|
1720
1907
|
var databaseConfig = useDatabase();
|
|
1721
1908
|
var tables = useTables();
|
|
@@ -1738,9 +1925,29 @@ function CmsRowLoader(_ref12) {
|
|
|
1738
1925
|
while (1) {
|
|
1739
1926
|
switch (_context3.prev = _context3.next) {
|
|
1740
1927
|
case 0:
|
|
1741
|
-
|
|
1928
|
+
if (table) {
|
|
1929
|
+
_context3.next = 2;
|
|
1930
|
+
break;
|
|
1931
|
+
}
|
|
1742
1932
|
|
|
1743
|
-
|
|
1933
|
+
throw new Error("You must specify a model to fetch from.");
|
|
1934
|
+
|
|
1935
|
+
case 2:
|
|
1936
|
+
if (row) {
|
|
1937
|
+
_context3.next = 4;
|
|
1938
|
+
break;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
throw new Error("You must specify an entry name to fetch.");
|
|
1942
|
+
|
|
1943
|
+
case 4:
|
|
1944
|
+
_context3.next = 6;
|
|
1945
|
+
return mkApi(databaseConfig).fetchRow(table, row, useDraft);
|
|
1946
|
+
|
|
1947
|
+
case 6:
|
|
1948
|
+
return _context3.abrupt("return", _context3.sent);
|
|
1949
|
+
|
|
1950
|
+
case 7:
|
|
1744
1951
|
case "end":
|
|
1745
1952
|
return _context3.stop();
|
|
1746
1953
|
}
|
|
@@ -1752,6 +1959,8 @@ function CmsRowLoader(_ref12) {
|
|
|
1752
1959
|
table: table,
|
|
1753
1960
|
row: row
|
|
1754
1961
|
}, children);
|
|
1962
|
+
}, {
|
|
1963
|
+
hideIfNotFound: hideIfNotFound
|
|
1755
1964
|
});
|
|
1756
1965
|
}
|
|
1757
1966
|
|