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