@plasmicpkgs/plasmic-cms 0.0.269 → 0.0.271
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/context.d.ts +4 -0
- package/dist/plasmic-cms.cjs.development.js +72 -38
- 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 +72 -38
- package/dist/plasmic-cms.esm.js.map +1 -1
- package/dist/schema.d.ts +30 -10
- package/package.json +2 -2
package/dist/plasmic-cms.esm.js
CHANGED
|
@@ -642,6 +642,7 @@ var _excluded = ["databaseToken"];
|
|
|
642
642
|
var contextPrefix = "plasmicCms";
|
|
643
643
|
var databaseContextKey = contextPrefix + "Database";
|
|
644
644
|
var tablesContextKey = contextPrefix + "Tables";
|
|
645
|
+
var tableSchemaContextKey = contextPrefix + "TableSchema";
|
|
645
646
|
var collectionResultSuffix = "Collection";
|
|
646
647
|
var mkQueryContextKey = function mkQueryContextKey(table) {
|
|
647
648
|
return "" + contextPrefix + capitalizeFirst(table) + collectionResultSuffix;
|
|
@@ -693,16 +694,37 @@ function TablesProvider(_ref2) {
|
|
|
693
694
|
hidden: true
|
|
694
695
|
}, children);
|
|
695
696
|
}
|
|
697
|
+
function TableSchemaProvider(_ref3) {
|
|
698
|
+
var children = _ref3.children,
|
|
699
|
+
table = _ref3.table;
|
|
700
|
+
var tables = useTables();
|
|
701
|
+
var schema;
|
|
702
|
+
if (tables && (tables == null ? void 0 : tables.length) > 0) {
|
|
703
|
+
if (!table) {
|
|
704
|
+
var _tables$;
|
|
705
|
+
schema = (_tables$ = tables[0]) == null ? void 0 : _tables$.schema;
|
|
706
|
+
} else {
|
|
707
|
+
var _tables$find;
|
|
708
|
+
schema = tables == null || (_tables$find = tables.find(function (t) {
|
|
709
|
+
return (t == null ? void 0 : t.identifier) === table;
|
|
710
|
+
})) == null ? void 0 : _tables$find.schema;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return React.createElement(DataProvider, {
|
|
714
|
+
name: tableSchemaContextKey,
|
|
715
|
+
data: schema
|
|
716
|
+
}, children);
|
|
717
|
+
}
|
|
696
718
|
function getClosestMatchingKeysBy(env, pred) {
|
|
697
719
|
return [].concat(Object.keys(env).reverse()).filter(function (key) {
|
|
698
720
|
return pred(key);
|
|
699
721
|
});
|
|
700
722
|
}
|
|
701
|
-
function QueryResultProvider(
|
|
702
|
-
var children =
|
|
703
|
-
table =
|
|
704
|
-
rows =
|
|
705
|
-
hidden =
|
|
723
|
+
function QueryResultProvider(_ref4) {
|
|
724
|
+
var children = _ref4.children,
|
|
725
|
+
table = _ref4.table,
|
|
726
|
+
rows = _ref4.rows,
|
|
727
|
+
hidden = _ref4.hidden;
|
|
706
728
|
return React.createElement(DataProvider, {
|
|
707
729
|
name: table ? mkModeContextKey(table) : undefined,
|
|
708
730
|
data: "rows",
|
|
@@ -777,19 +799,19 @@ function useCount(tables, table) {
|
|
|
777
799
|
}
|
|
778
800
|
return undefined;
|
|
779
801
|
}
|
|
780
|
-
function RowProvider(
|
|
781
|
-
var children =
|
|
782
|
-
table =
|
|
783
|
-
row =
|
|
802
|
+
function RowProvider(_ref5) {
|
|
803
|
+
var children = _ref5.children,
|
|
804
|
+
table = _ref5.table,
|
|
805
|
+
row = _ref5.row;
|
|
784
806
|
return React.createElement(DataProvider, {
|
|
785
807
|
name: mkRowContextKey(table),
|
|
786
808
|
data: row
|
|
787
809
|
}, children);
|
|
788
810
|
}
|
|
789
|
-
function CountProvider(
|
|
790
|
-
var children =
|
|
791
|
-
table =
|
|
792
|
-
count =
|
|
811
|
+
function CountProvider(_ref6) {
|
|
812
|
+
var children = _ref6.children,
|
|
813
|
+
table = _ref6.table,
|
|
814
|
+
count = _ref6.count;
|
|
793
815
|
return React.createElement(DataProvider, {
|
|
794
816
|
name: table ? mkModeContextKey(table) : undefined,
|
|
795
817
|
data: "count",
|
|
@@ -1026,9 +1048,10 @@ var cmsQueryRepeaterMeta = {
|
|
|
1026
1048
|
options: function options(_ref4, ctx) {
|
|
1027
1049
|
var _ctx$table;
|
|
1028
1050
|
var table = _ref4.table;
|
|
1029
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number"
|
|
1051
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "ref" /* REF */]);
|
|
1030
1052
|
}
|
|
1031
1053
|
},
|
|
1054
|
+
|
|
1032
1055
|
filterValue: {
|
|
1033
1056
|
type: "string",
|
|
1034
1057
|
displayName: "Filter value",
|
|
@@ -1039,8 +1062,9 @@ var cmsQueryRepeaterMeta = {
|
|
|
1039
1062
|
displayName: "Order by",
|
|
1040
1063
|
description: "Field to order by.",
|
|
1041
1064
|
options: function options(_, ctx) {
|
|
1042
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number"
|
|
1065
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "date-time" /* DATE_TIME */, "long-text" /* LONG_TEXT */, "text" /* TEXT */]);
|
|
1043
1066
|
},
|
|
1067
|
+
|
|
1044
1068
|
hidden: function hidden(ps) {
|
|
1045
1069
|
return ps.mode === "count";
|
|
1046
1070
|
}
|
|
@@ -1225,10 +1249,12 @@ function CmsQueryRepeater(_ref6) {
|
|
|
1225
1249
|
}, {
|
|
1226
1250
|
hideIfNotFound: false
|
|
1227
1251
|
}, inEditor, loadingMessage, forceLoadingState);
|
|
1228
|
-
return React.createElement(
|
|
1252
|
+
return React.createElement(TableSchemaProvider, {
|
|
1253
|
+
table: table
|
|
1254
|
+
}, React.createElement(CountProvider, {
|
|
1229
1255
|
table: table,
|
|
1230
1256
|
count: typeof (maybeData == null ? void 0 : maybeData.data) === "number" ? maybeData.data : undefined
|
|
1231
|
-
}, node);
|
|
1257
|
+
}, node));
|
|
1232
1258
|
} else {
|
|
1233
1259
|
var _node = renderMaybeData(maybeData, function (rows) {
|
|
1234
1260
|
if (rows.length === 0 || forceEmptyState) {
|
|
@@ -1244,12 +1270,14 @@ function CmsQueryRepeater(_ref6) {
|
|
|
1244
1270
|
}, {
|
|
1245
1271
|
hideIfNotFound: false
|
|
1246
1272
|
}, inEditor, loadingMessage, forceLoadingState);
|
|
1247
|
-
return React.createElement(
|
|
1273
|
+
return React.createElement(TableSchemaProvider, {
|
|
1274
|
+
table: table
|
|
1275
|
+
}, React.createElement(QueryResultProvider, {
|
|
1248
1276
|
rows: Array.isArray(maybeData == null ? void 0 : maybeData.data) ? maybeData.data : undefined,
|
|
1249
1277
|
table: table
|
|
1250
1278
|
}, noLayout ? React.createElement(React.Fragment, null, " ", _node, " ") : React.createElement("div", {
|
|
1251
1279
|
className: className
|
|
1252
|
-
}, " ", _node, " "));
|
|
1280
|
+
}, " ", _node, " ")));
|
|
1253
1281
|
}
|
|
1254
1282
|
}
|
|
1255
1283
|
var cmsRowFieldMeta = {
|
|
@@ -1281,8 +1309,9 @@ var cmsRowFieldMeta = {
|
|
|
1281
1309
|
options: function options(_ref8, ctx) {
|
|
1282
1310
|
var _ctx$table3;
|
|
1283
1311
|
var table = _ref8.table;
|
|
1284
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["number"
|
|
1312
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "date-time" /* DATE_TIME */, "rich-text" /* RICH_TEXT */, "image" /* IMAGE */, "file" /* FILE */, "enum" /* ENUM */]);
|
|
1285
1313
|
},
|
|
1314
|
+
|
|
1286
1315
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1287
1316
|
var _ctx$fieldMeta, _ctx$fieldMeta2;
|
|
1288
1317
|
return (ctx == null || (_ctx$fieldMeta = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta.name) || (ctx == null || (_ctx$fieldMeta2 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta2.identifier);
|
|
@@ -1310,8 +1339,9 @@ var cmsRowFieldMeta = {
|
|
|
1310
1339
|
if (!fieldMeta) {
|
|
1311
1340
|
return true;
|
|
1312
1341
|
}
|
|
1313
|
-
return fieldMeta.type !== "date-time"
|
|
1342
|
+
return fieldMeta.type !== "date-time" /* DATE_TIME */;
|
|
1314
1343
|
},
|
|
1344
|
+
|
|
1315
1345
|
options: [{
|
|
1316
1346
|
label: "July 26, 2014",
|
|
1317
1347
|
value: "MMMM D, YYYY"
|
|
@@ -1387,7 +1417,7 @@ function CmsRowField(_ref10) {
|
|
|
1387
1417
|
table: res.table,
|
|
1388
1418
|
tables: tables,
|
|
1389
1419
|
field: field,
|
|
1390
|
-
typeFilters: ["text"
|
|
1420
|
+
typeFilters: ["text" /* TEXT */, "long-text" /* LONG_TEXT */, "rich-text" /* RICH_TEXT */]
|
|
1391
1421
|
}) : undefined;
|
|
1392
1422
|
if (tables) {
|
|
1393
1423
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
@@ -1414,7 +1444,7 @@ function CmsRowField(_ref10) {
|
|
|
1414
1444
|
if (!data) {
|
|
1415
1445
|
return null;
|
|
1416
1446
|
}
|
|
1417
|
-
if (fieldMeta.type === "date-time" && dateFormat) {
|
|
1447
|
+
if (fieldMeta.type === "date-time" /* DATE_TIME */ && dateFormat) {
|
|
1418
1448
|
data = dayjs(data).format(dateFormat);
|
|
1419
1449
|
}
|
|
1420
1450
|
return data ? renderValue(data, fieldMeta.type, _extends({
|
|
@@ -1465,7 +1495,7 @@ function CmsCount(_ref11) {
|
|
|
1465
1495
|
}, rest), new Intl.NumberFormat().format(res.count));
|
|
1466
1496
|
}
|
|
1467
1497
|
}
|
|
1468
|
-
var DEFAULT_TYPE_FILTERS = ["text"];
|
|
1498
|
+
var DEFAULT_TYPE_FILTERS = ["text" /* TEXT */];
|
|
1469
1499
|
function deriveInferredTableField(opts) {
|
|
1470
1500
|
var _tables$find;
|
|
1471
1501
|
var table = opts.table,
|
|
@@ -1488,14 +1518,15 @@ function assertNever(_) {
|
|
|
1488
1518
|
}
|
|
1489
1519
|
function renderValue(value, type, props) {
|
|
1490
1520
|
switch (type) {
|
|
1491
|
-
case "number"
|
|
1492
|
-
case "boolean"
|
|
1493
|
-
case "text"
|
|
1494
|
-
case "long-text"
|
|
1495
|
-
case "date-time"
|
|
1496
|
-
case "
|
|
1521
|
+
case "number" /* NUMBER */:
|
|
1522
|
+
case "boolean" /* BOOLEAN */:
|
|
1523
|
+
case "text" /* TEXT */:
|
|
1524
|
+
case "long-text" /* LONG_TEXT */:
|
|
1525
|
+
case "date-time" /* DATE_TIME */:
|
|
1526
|
+
case "enum" /* ENUM */:
|
|
1527
|
+
case "ref" /* REF */:
|
|
1497
1528
|
return React.createElement("div", Object.assign({}, props), value);
|
|
1498
|
-
case "rich-text"
|
|
1529
|
+
case "rich-text" /* RICH_TEXT */:
|
|
1499
1530
|
return React.createElement("div", Object.assign({
|
|
1500
1531
|
dangerouslySetInnerHTML: {
|
|
1501
1532
|
__html: value
|
|
@@ -1504,7 +1535,7 @@ function renderValue(value, type, props) {
|
|
|
1504
1535
|
whiteSpace: "normal"
|
|
1505
1536
|
}
|
|
1506
1537
|
}, props));
|
|
1507
|
-
case "image"
|
|
1538
|
+
case "image" /* IMAGE */:
|
|
1508
1539
|
if (value && typeof value === "object" && value.url && value.imageMeta) {
|
|
1509
1540
|
return React.createElement("img", Object.assign({
|
|
1510
1541
|
src: value.url,
|
|
@@ -1513,7 +1544,7 @@ function renderValue(value, type, props) {
|
|
|
1513
1544
|
}, props));
|
|
1514
1545
|
}
|
|
1515
1546
|
return null;
|
|
1516
|
-
case "file"
|
|
1547
|
+
case "file" /* FILE */:
|
|
1517
1548
|
if (value && typeof value === "object" && value.url && value.name) {
|
|
1518
1549
|
return React.createElement("a", Object.assign({
|
|
1519
1550
|
href: value.url,
|
|
@@ -1613,8 +1644,9 @@ function CmsRowLink(_ref13) {
|
|
|
1613
1644
|
table: res.table,
|
|
1614
1645
|
tables: tables,
|
|
1615
1646
|
field: field,
|
|
1616
|
-
typeFilters: ["file"
|
|
1647
|
+
typeFilters: ["file" /* FILE */, "text" /* TEXT */]
|
|
1617
1648
|
});
|
|
1649
|
+
|
|
1618
1650
|
if (tables) {
|
|
1619
1651
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1620
1652
|
setControlContextData == null || setControlContextData({
|
|
@@ -1634,7 +1666,7 @@ function CmsRowLink(_ref13) {
|
|
|
1634
1666
|
var childrenWithProps = React.Children.map(children, function (child) {
|
|
1635
1667
|
if (React.isValidElement(child)) {
|
|
1636
1668
|
var _React$cloneElement;
|
|
1637
|
-
return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
1669
|
+
return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" /* FILE */ ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
|
|
1638
1670
|
}
|
|
1639
1671
|
return child;
|
|
1640
1672
|
});
|
|
@@ -1676,7 +1708,7 @@ var cmsRowImageMeta = {
|
|
|
1676
1708
|
options: function options(_ref14, ctx) {
|
|
1677
1709
|
var _ctx$table5;
|
|
1678
1710
|
var table = _ref14.table;
|
|
1679
|
-
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table, ["image"]);
|
|
1711
|
+
return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table, ["image" /* IMAGE */]);
|
|
1680
1712
|
},
|
|
1681
1713
|
defaultValueHint: function defaultValueHint(_, ctx) {
|
|
1682
1714
|
var _ctx$fieldMeta7, _ctx$fieldMeta8;
|
|
@@ -1707,8 +1739,9 @@ function CmsRowImage(_ref15) {
|
|
|
1707
1739
|
table: res.table,
|
|
1708
1740
|
tables: tables,
|
|
1709
1741
|
field: field,
|
|
1710
|
-
typeFilters: ["image"]
|
|
1742
|
+
typeFilters: ["image" /* IMAGE */]
|
|
1711
1743
|
});
|
|
1744
|
+
|
|
1712
1745
|
if (tables) {
|
|
1713
1746
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1714
1747
|
setControlContextData == null || setControlContextData({
|
|
@@ -1803,8 +1836,9 @@ function CmsRowFieldValue(_ref17) {
|
|
|
1803
1836
|
table: res.table,
|
|
1804
1837
|
tables: tables,
|
|
1805
1838
|
field: field,
|
|
1806
|
-
typeFilters: ["text"]
|
|
1839
|
+
typeFilters: ["text" /* TEXT */]
|
|
1807
1840
|
});
|
|
1841
|
+
|
|
1808
1842
|
if (tables) {
|
|
1809
1843
|
// TODO: Only include table if __plasmic_cms_row_{table} exists.
|
|
1810
1844
|
setControlContextData == null || setControlContextData({
|